crewship doc
Work with the Docs service’s structured document protocol in the selected workspace. Native WordCraft/GridCraft use a separate whole-snapshot and edit-lease profile; these commands operate on Docs documents. A document is saved on an artifact, and the artifact’s slug or@<artifact-id> addresses it.
With the Artifacts library enabled, Docs documents are listed there as Word.
The service rechecks your current credential and document permissions before reading or
saving. Scoped credentials need pages:read for reads and both pages:read and
pages:write for editing; pages:* covers both. These scopes do not grant access
to somebody else’s document.
Availability
doc create, doc draft and the chat Create document control also need
the workspace’s agent artifact policy to allow the crew
(crewship workspace artifact-policy show).
A reader refuses unsupported saved document schemas, including initialization
retries, without returning their content. Use a compatible document service;
confirmed data stays retained rather than being silently replaced.
crewship doc create --file <request.json>
Create a populated document during a run admitted for one human’s creation
request. This command uses that run’s credential and the local sidecar; it does
not fall back to a saved human profile. Document support and the workspace’s
creation policy must allow the request.
Supply one JSON object of at most 1 MiB with slug, name, mutation_id and a
blocks array. Use --file - for stdin. For example:
doc_create in the Crewship routines MCP tools with the
same four fields. The tool uses the same run permission and saved result; an
exact retry can recover that result across the CLI and MCP interfaces.
An admitted run of an agent added to an already running crew can create and
draft its Document without restarting the shared crew container. The host still
checks the run capability, the requesting human’s current access and the original
creation or drafting permission; startup roster labels do not grant access.
crewship doc draft
Save progress while fulfilling an admitted creation request. The original human
request must include drafting permission. These commands use the current run’s
credential and local sidecar, without a saved human profile or an artifact selector.
They apply only to the document created for that request and stop when the run
ends, its permission expires or is revoked, or a human changes the document.
A replacement run inherits no drafting permission.
- Run
crewship doc draft viewto read a bounded view of confirmed headings and paragraphs, their block IDs and hashes, and the document’s revision and epoch. - Run
crewship doc draft prepare --file <input.json>withview,target,textand a stablemutation_idof at most 117 ASCII letters, digits, underscores or hyphens. It prepares an immutable edit and checkpoint packet locally; preparation does not save text. - Retain that output and run
crewship doc draft apply --file <packet.json>to apply the guarded text replacement and checkpoint the confirmed revision.
--file - for stdin. Keep the original prepared packet after an uncertain
response. Applying that same packet again recovers its receipts without another
write. Changing an existing mutation’s contents conflicts; rereading does not
rebase or authorize a replacement edit automatically.
Draft commands return JSON by default and honor --format json, --format yaml
and --format ndjson. Use JSON output for packets passed to another draft
command; input files remain JSON. Output formats preserve original integer
revisions and checkpoint identities.
If the text edit commits but the checkpoint confirmation fails, the edit remains
saved. The result reports committed_checkpoint_pending; retry only its original
checkpoint with crewship doc draft checkpoint --file <packet.json>. Do not
report committed content as lost or silently generate a new mutation.
The routines MCP tools doc_draft_view, doc_draft_prepare, doc_draft_apply
and doc_draft_checkpoint use the same permission and immutable requests. They
do not accept raw Yjs updates or whole-document replacement.
Proposing on a schema 4, 5 or 6 document
On a schema 4, 5 or 6 document an agent never edits directly: it proposes, and a person with edit access accepts or rejects each proposal. The run needs a targeted message from the person who asked that names the document’s own schema (document_iteration_intent with "schema": 4, "schema": 5 or "schema": 6; a
mandate naming another schema than the document has is refused), optionally "blocks": ["<block-id>", …] to limit it to up to 16
blocks). The person needs edit access to the document. On anything but their
own personal private document the agent also needs a live write grant naming
it (crewship page grant <slug> --agent <agent> --level write); a read grant
or a crew grant is not enough, and another person’s private document is never
reachable.
crewship doc draft viewreturns"mode": "propose"and lists only the paragraphs and headings inside the mandate.crewship doc draft prepare --file <input.json>builds an immutable proposal packet from that view.crewship doc draft propose --file <packet.json>stores it. The result is"status": "proposed"; the document, its revision and its formatting are unchanged. Resending the same packet returns the same receipt.
crewship doc draft apply and checkpoint are refused on a propose mandate.
A proposal replaces one block’s text; bold, italic, strike, inline code and
links on unchanged text are kept, and code blocks, quotes and task lists
elsewhere in the document are untouched. The MCP tool is doc_draft_propose.
crewship doc status
Read whether document support is configured on the selected instance. This
command takes no artifact argument. A disabled instance returns enabled: false.
wordcraft_native and gridcraft_native report whether the native Craft Word
and Sheet editors are configured.
crewship doc initialize <page-slug>
Populate an empty artifact that you own personally with its first document.
The artifact must not be owned by a crew and must hold no other output. Create
one with crewship page create and --allow-empty. Page creation
needs a credential with the workspace:admin CLI scope; document initialization
uses pages:write. A minimal definition
is enough:
slides initialize target.)
Then supply a JSON request
containing an operation id, explicit schema (2, 3, 4, 5 or 6), and a body document
tree. Schemas 3 to 6 also require the original page_id. Headings, paragraphs,
lists and simple tables use schema 2; schema 3 adds links, inline code and code
blocks; schema 4 adds bold, italic and strikethrough, a code block language,
block quotes and checklists; schema 5 adds underline, text colour and
highlight; schema 6 adds the Canvas surface and accepts the same body as
schema 5, starting with an empty canvas. Initialization does not silently upgrade an
existing document.
Schema 4 nodes and marks:
Schema 5 adds three marks to these; every schema 4 document is valid schema 5
content unchanged:
<name> is one of gray, red, orange, yellow, green, blue, purple,
pink. Any other value, including CSS colours, is refused. These marks combine
with each other, with emphasis and with link; inline code still stands alone.
A reader shows a date in their own locale and a mention as the name they may
see (
crewship doc people); anyone else, including a person without access to
the document, appears as Unknown member. Block text in read and outline
leaves both out. Markdown writes the date as YYYY-MM-DD and a mention as @
and a name only when the export is given the names its reader may see, otherwise
as @Unknown member. A semantic edit that would insert text beside a date or
mention, or delete across one, is refused with ambiguous_inline_atom.
doc create, start at schema 5, the creation schema; documents created earlier keep
their schema and are never upgraded automatically. crewship doc read lists
what the document’s schema supports in capabilities:
draft is the run that created the document with your drafting permission
editing it directly. On a schema 4, 5 or 6 document any other agent request is a
proposal at the document’s own schema, and a person accepts it; see
Proposing on a schema 4, 5 or 6 document.
A proposal keeps every mark, date and mention outside the text it changes; one
that would insert text beside a date or mention, or delete across one, is
refused with ambiguous_inline_atom. A proposal made at one schema is never
accepted after the document’s schema changed; it can still be rejected.
Schema 6 is schema 5 plus the Docs Canvas. Placements of Page blocks, notes and
shapes are stored beside the page in their own roots. Moving a block on the
canvas never changes its text, block ID or hash, so the page, its Markdown, its
comment anchors and agent proposals work as at schema 5; an agent proposes on
Page blocks and never writes the canvas. The canvas has its own share of the
document budget (512 KiB of history, counted as an upper bound of its stored
bytes); a save that would exceed it, or the 2000-entry limit, is refused
with status 413 and code surface_quota, and the page keeps room for text.
A document becomes schema 6 only when a person enables Canvas for it
(crewship doc upgrade, or the first switch to Canvas in the Docs view).
--file is required. Use --file - to read stdin. The file must contain one JSON
object of at most 2 MiB. Keep the same operation ID and contents when retrying
an operation whose confirmation was lost.
schema, rev: 0, a numeric
epoch, generation, database, contentGeneration, blocks (block id and
hash) and the stored snapshot.
An exact retry returns the original receipt with duplicate: true instead:
crewship doc checkpoints <page-slug>
crewship doc checkpoints <page-slug> lists at most the latest 1,000 retained
checkpoint pins, ordered by revision and identity. Checkpoints are saved pins,
not every editor keystroke: the initial state, explicit checkpoints, and a
session checkpoint of the confirmed result when an edit arrives at least ten
minutes after the newest checkpoint, or at least five minutes after another
author’s (never one identical to the newest checkpoint). Session checkpoints
share at most half of the document’s History budget, pause while the
workspace or instance storage would be more than 80% used, and are not deleted
while the document exists. They never refuse an edit. While History is not
adding them for lack of space, the response includes
"history_limit_reached": true (the field is absent otherwise; after a server
restart it is an estimate until the next skip). The session- ID prefix is
reserved: an explicit checkpoint with that prefix is refused. Older pins remain retained and can be read by ID.
Each entry in checkpoints has id, rev, schema, actor and created_at.
A valid document with no retained pins returns an empty checkpoints list.
404 document history unavailable means the document state or selected
checkpoint was not found, not simply that the list is empty.
crewship doc checkpoint <page-slug> <checkpoint-id>
Read that exact confirmed
body as content, with its page_id, checkpoint id, rev and schema. The
checkpoint ID must be 1 to 128 letters, digits, underscores or hyphens; anything
else stops locally with bounded checkpoint identity required. Both commands accept
@<artifact-id> and the standard JSON, YAML and NDJSON output formats.
These commands use current human read access, including the private audience;
an old run or checkpoint ID grants no access. Reads never restore content or
change a draft. The public response omits binary snapshots and writer fences.
crewship doc restore <page-slug> --file request.json
Restore one retained checkpoint as a new confirmed revision. The original JSON
packet (at most 4 KiB) contains page_id, a unique operation id, the current schema, opaque
epoch, current ifRev, and the retained checkpoint ID. Read the current
Document first and confirm the intended checkpoint. Keep the exact same packet
for a retry after uncertain confirmation; never refresh its revision or epoch.
The server checks current human write access. A successful restore increments
the revision and generation and invalidates the previous writer epoch. The
receipt has page_id, id, rev, epoch, kind and schema, the
document’s schema after the restore; a replay also has duplicate. A schema 5
document stays at schema 5 when you restore a checkpoint from before its
upgrade, so new agent proposals are made at schema 5, never silently at 4.
A Canvas (schema 6) document likewise stays at schema 6; restoring a
checkpoint from before Canvas was enabled leaves its layout, cards and notes
empty.
The content a restore replaces stays in History (#5165): in the same commit
the server keeps the replaced revision as a checkpoint at that revision
(crewship doc checkpoints lists it, attributed to the person who restored),
unless History already holds that exact content. When History has no room
for it, the restore is refused (429, Document restore refused; confirmed content preserved) and nothing changes: checkpoints are never pruned, so a
page whose History is full cannot be restored until room is made. A replay of
the same packet adds nothing.
crewship doc read <page-slug>
For a saved Document identity, crewship doc read @<artifact-id> keeps the original
object bound to the request. A deleted identity returns 404 even if another
document reuses its former slug. Current workspace and access checks still apply.
Read the currently confirmed document, content tree, block outline and revision.
Use the returned opaque epoch, rev and target block hash when preparing an
edit. Read after initialization to obtain the editing epoch.
The epoch names the content you edited, not the server process. A server or
Docs engine restart keeps it, so an edit prepared before the restart still
applies. It changes when content is replaced: a History restore, a schema
upgrade, or a restore from backup (which gives the database a new identity).
After an epoch change, read again and prepare the edit against the new content.
generation,
incarnation, snapshot, snapshotRev, updates and blocks). This
abbreviated example uses placeholders for the binary snapshot and updates:
outline entry has the block id, its node type, the parent block ID
(null at the top level), its hash and its plain text.
An empty artifact with no document yet returns 404 document not found. An
artifact that holds a different output, such as a typed version, Slides deck,
board, workbook, panels or a Project, returns 403 document access denied.
crewship doc outline <page-slug>
Print a JSON array of the current blocks, each with id, type, parent,
hash and text. This command
reads the same confirmed document as read; it does not mutate it. It always
prints JSON, whatever --format you pass.
crewship doc export <page-slug>
Exports include the current confirmed Page content only. Canvas-only items and
layout, unsent changes and selected historical revisions are not included. Mention
names use the exporting reader’s current document access; unavailable people remain
unknown. If the Page changes while export is prepared, retry the export.
Download the confirmed document as Markdown (--as md, the default) or as a
Word document (--as docx). It reads what doc read reads,
with the same access: you need read access to the document (scoped tokens:
pages:read), and without it fails exactly as doc read does. Restricted
members cannot export, not even their own private output. Content the chosen
format cannot represent fails with the reason instead of a file with parts
missing: a code block inside a table has no Markdown form (Word keeps it), and
lists nested deeper than nine levels have no Word form. Math blocks export as
their LaTeX source in both formats.
The file is written atomically to --out (default: the server’s file name,
such as launch-notes.md, in the current directory) and standard output
carries a JSON receipt with path, media_type, byte_length and sha256.
An existing file is not replaced unless you pass --force. --out - writes
the file itself to standard output. --as selects the file type: md
(text/markdown, at most 4 MiB) or docx (Word package, just under 3 MiB).
crewship doc patch <page-slug>
Save an explicitly guarded update. --file is required; --file - reads stdin.
Supply one JSON object of at most 2 MiB. A semantic text replacement contains
id, schema, the confirmed epoch, target block ID, replacement text,
ifRev and ifHash. Schemas 3 to 6 also require the original page_id. The editor’s
binary update form uses kind: "human" and a base64 update instead.
A changed revision, target hash or epoch refuses the edit. Read the confirmed
state again and decide on a new edit; the command never rebases it automatically.
For a lost confirmation, resend the original request with its original ID.
The receipt identifies the durable revision; a successful exact retry does not
create another write. Revoked credentials cannot replay saved requests.
found: true and
duplicate: true, plus the request’s schema and the current epoch.
crewship doc upgrade <page-slug>
Upgrade a document to the newest schema. Today that enables the Canvas
(schema 6) on an older document; in the Docs view the first switch to Canvas
asks the same question. Read the document first and send its current values:
duplicate: true.
Editors still open at the old schema are refused when they save and must
reload.
crewship doc presence <page-slug>
Send one presence heartbeat and print who else has the document open: one entry
per other person with tabs (how many of their tabs are open), user_id, the
name the server resolved, a color index and the client and caret
(anchor/head, base64 Yjs relative positions, when shared) of their tab
that moved last. Presence lives in server memory for 6 seconds and is
never stored. The heartbeat is authorized like a document read: without read
access it fails with 404 and lists nobody. --client reuses a tab id (8–64
letters, digits, - or _); --leave removes that tab at once.
People on the Canvas view (schema 6 documents; the server relays it as given
and checks only its bounds) also carry a canvas object: their pointer (x, y in canvas coordinates, absent once it leaves
the canvas) and the cards they selected (selection, Page block or canvas item
IDs). --pointer X,Y (each between -1000000 and 1000000) and --select ID,ID
(at most 8 different IDs) send this tab’s own; neither combines with --leave.
crewship doc comments <page-slug>
List the document’s comment threads and their replies, oldest first. Reading
comments needs the same access as reading the document (pages:read for scoped
CLI credentials). The response has comments, plus can_comment and
can_resolve for you. Each comment has id, body, actor, created_at,
rev (the document revision it was written against), version and
resolved. A thread also has the quoted text: block, quote, the current
UTF-16 range from/to and status: attached, collapsed (its text was
deleted), detached (its block was removed) or resolved. A reply has
parent, the thread it answers, and no quote of its own.
crewship doc comment <page-slug>
Start a thread on quoted text, or reply to one. --file is required; --file -
reads stdin. You need Comment or Edit access to the document (pages:write for
scoped CLI credentials). On private output only its owner comments. Comments
never change the document’s content, revision or epoch.
A thread names the text it is about: block is a paragraph, heading or code
block ID from crewship doc outline, and from/to are the UTF-16 offsets of
the quoted text inside it. A reply names parent instead. Both need id,
schema, the confirmed epoch and ifRev and text (1–10,000 characters);
schemas 3 to 6 also need page_id.
kind: "comment". Resend the exact request
after a lost confirmation; the same id with different content returns 409, as
does a changed revision or epoch. Read again and send a new request.
crewship doc comment-resolve <page-slug>
Resolve a thread, or reopen it with "resolved": false. --file is required;
--file - reads stdin. The request has id, schema, epoch, ifRev,
page_id (schemas 3 to 6), comment (the thread ID), version (from
crewship doc comments) and resolved. A changed version returns 409, so two
people cannot silently undo each other. You need Comment or Edit access.
crewship doc proposals <page-slug>
List an agent’s proposals on a schema 4, 5 or 6 document, oldest first. Each has id,
author, run_id, target.block_ids, base_rev, status, text and
created_at. status is open, stale (its block changed after it was made,
so it can no longer be accepted), accepted or rejected. Reading needs read
access to the document. crewship doc read reports "proposals": true where
the server serves them.
crewship doc proposal <page-slug> <proposal-id>
Show one proposal with base_content (the block as the agent saw it) and
proposed_content (the block after the change), both as document JSON.
crewship doc proposal-accept <page-slug> <proposal-id>
Apply exactly the proposal as a new revision made by you. Pass the revision you
reviewed as --expected-rev and a stable --request-id. A newer head, or a
proposed block changed since the proposal was made, returns 409 and changes
nothing. You need edit access. Resending the same --request-id returns the
original receipt with "duplicate": true.
crewship doc proposal-reject <page-slug> <proposal-id>
Close an open proposal without changing the document. It takes the same
--expected-rev and --request-id and needs edit access.
crewship doc people <page-slug>
Name the people mentioned in a schema 5 document, or find people to mention.
--ids takes up to 100 comma-separated user ids; --query (or no flag) lists
at most 20 people whose name contains the text. Only people who can read this
document appear, and only when you can read it. Any other id is simply left out,
so the answer never says whether an id exists; readers show it as
Unknown member. Lookups are limited per person (30 at once, then 2 per
second); past that the command fails with HTTP 429 and you retry after the
Retry-After time.
Errors
With-f json, errors are printed as an error object with message,
status, detail and exit_code. See
exit codes.
Requesting a document in chat
With Document support and the workspace creation policy enabled, open a private agent chat without selecting an existing artifact. Select Create document in the composer, then describe what you want and send the message. For example, write “Please draft a garden plan. Include three sections!” or “Napiš mi plán zahrady.” The request can use Czech or English, punctuation, and multiple lines. The selection applies to one sent message. It authorizes creating a new private document and saving drafts of that document during the original live run. Sending successfully clears the selection; changing users or conversations also clears it. A failed local send preserves the selection for retry. The control is unavailable while Document support is unconfirmed or an existing artifact is selected. The server rechecks the original human and private-chat permissions. The composer carriesdocument_creation_intent metadata with a submission_id
and drafting: true; it leaves the message text unchanged. The older
document_creation metadata shape remains supported for existing clients.
Sending both shapes is rejected. Text returned by a model does not grant consent.
If a connection loses the reply, resending the same explicit submission key and
request is refused as already accepted, with the original human message ID.
Reload the conversation and inspect its saved result; the retry does not append
a second human turn, start another run, or renew drafting permission. Reusing the
key with different text or drafting permission is refused as a conflict. Current
human and chat authority are checked before either refusal. A message saved
before a consent-persistence failure remains visible, but its retry cannot mint
permission or start a run; report the unconfirmed request instead of silently
issuing a new key.
The narrow command vytvoř dokument o plánu uvedení produktu remains a fallback.
Its topic must be a single line containing letters, digits, spaces or hyphens;
quoted, negated or ambiguous text does not grant creation permission. Use the
composer control for other wording.
A Document created from a private chat has an explicit private audience: its
human owner and the workspace OWNER. Other roles, including ADMIN, cannot see
its title, catalog entry or content; direct reads return 404. Opening somebody
else’s private document as OWNER requires a durable audit entry before access.
Crew membership, folder inheritance and ordinary sharing grants do not widen this
audience. Legacy public links cannot publish it. Storage limits continue
to count the whole workspace. If its owner leaves, removal returns 409 until
the workspace OWNER explicitly selects an active human successor.
The source conversation keeps that private audience from the original creation
consent, even if creation fails or the execution permission later expires.
Its stored tool results and live messages cannot expose the output to an ADMIN;
OWNER inspection is audited before delivery. Existing transcript-sharing links
cannot publish this protected conversation. Create new private documents from
your own private conversation; administrative chat access is not creation consent.
Deleting a protected source conversation currently returns 409: retained log
copies still depend on its privacy record. Ordinary chat deletion is unaffected.
Configured chat retention also keeps protected source conversations and excludes
them from its deletion preview while those copies depend on their privacy record.
The run creates a populated document and returns its saved link. Reopening a
result does not grant a later run permission to edit it. Repeating an uncertain
operation must reuse the original request, rather than issuing a new chat task.
crewship doc chat-results <chat-id>
List saved documents linked to an accessible chat. This command requires your
current human credential, pages:read for scoped CLI tokens, access to the chat
and access to each document. Unavailable documents are omitted. Results contain
saved links and provenance, without document contents or transcript text. Each
entry in results has page_id, type, page_slug, title, revision,
created_at, agent_id, agent_name, run_id and on_behalf_of_user_id.