capsid_write_doc
Write a document, on Capsid. Needs the write grant.
What it does
Write a document: create or change it, restore an earlier version, or move it to a new path. Every overwrite snapshots the prior body to document_versions and writes audit_log. Needs the write grant.
What a client is told
The MCP hints it carries, so a client can ask before it acts (src/tool-annotations.ts).
- Writes: some action changes state.
- Can overwrite or remove what exists.
- A repeat can change things again.
- Stays inside Capsid.
Its 3 actions
Chosen by the action argument, with a default when it is left out.
writeCreate or change a document.Create or update a document. Snapshots the prior version and writes an audit log entry. mode selects how body is applied: 'replace' (default, full body, needs title and body), 'append' (body is added to the end; no title or confirmation needed), 'patch' (needs find and replace_with; find must occur EXACTLY ONCE or the write is refused), or 'meta' (change type, tags, status or title and leave the body byte-identical). Every response carries sha256 and bytes of the resulting body. Optional if_match: the sha256 of the body you believe is stored; when it does not match, the write is REFUSED and the error carries the current sha256. Overwriting with replace or patch needs confirmation: the server elicits it when the client supports elicitation, otherwise pass confirm: true. Optional links: a JSON array of outgoing edges [{"type":"references","to_path":"conventions.md","to_ns":"capsid"}] (types: governs, references, supersedes, replaces, depends-on; to_ns defaults to this namespace) that replaces this document's outgoing edges; omit it to keep them, pass [] to clear them. CANON: a write to capsid/conventions*.md, any namespace's core.md, or decisions.md and its archived volumes, by a caller that is not the seat or the admin, is NOT applied: it is stored as a proposal for the seat or Dustin to approve and returns action 'pending_review' with the proposal id (links are refused on such a write). Needs the write grant.
Takes
namespace,path,title,body,mode,find,replace_with,type,tags,status,confirm,links,if_match,allow_improve_paths.restoreRestore a version.Restore a document's title and body from one of its retained versions (see capsid_read_doc action versions). The current body is snapshotted first and the restore is audit-logged, so a restore can itself be undone. The stored bytes go back exactly, with no dash normalization; type, status, tags and links are not restored. Restoring a deleted document recreates it. Refused on a canon document for a caller that is not the seat or the admin (see capsid_write_doc action write). Optional if_match: the sha256 of the body you believe is live; the restore is refused if it changed. Needs the write grant and confirm: true.
Takes
namespace,path,version_id,confirm,if_match,allow_improve_paths.moveMove to a new path.Rename a document path within its namespace, repointing every typed edge that touches it. Audit logged. Refused when either path is a canon document, for a caller that is not the seat or the admin (see capsid_write_doc action write). Needs confirmation: the server elicits it when the client supports elicitation, otherwise pass confirm: true. Needs the write grant.
Takes
namespace,path,new_path,confirm,allow_improve_paths.
Arguments
| Argument | Type | Needed | What it is |
|---|---|---|---|
action | one of: write, restore, move | no | write | restore | move. Defaults to write. |
namespace | string | always | |
path | string | always | |
title | string | no | |
body | string | no | |
mode | one of: replace, append, patch, meta | no | |
find | string | no | |
replace_with | string | no | |
type | string | no | |
tags | string | no | |
status | string | no | |
confirm | boolean | no | |
links | string | no | |
if_match | string | no | |
allow_improve_paths | boolean | no | |
version_id | whole number | no | |
new_path | string | no |