Skip to content

Commit 914a4b2

Browse files
onekanyuncoderyhk
andauthored
docs: clarify docz collab skill workflow (#26)
Co-authored-by: yhk <yanhongkang@yuanfudao.com>
1 parent 55090c5 commit 914a4b2

1 file changed

Lines changed: 44 additions & 9 deletions

File tree

skills/SKILL.md

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: docz
33
description: Read, write, and collaboratively edit company DocSync documents. Triggers on "docs", "documents", "upload file", "read space", "docz", "DocSync", "save file", "rollback", "restore", "trash", "version history", "comment", "share link", "diff", "collab", "collaborative editing", "Neovim"
4-
version: 0.14.0
4+
version: 0.15.0
55
author: kris
66
tags:
77
- docsync
@@ -110,11 +110,12 @@ Use `cat --ref` only if you need to display or log the Git ref; the safe-edit wo
110110

111111
### Realtime Collaborative Editing
112112

113-
Use `collab` commands when the user is editing the same document in the browser, when multiple agents/people may edit at the same time, or when the task explicitly mentions collaborative editing. These commands connect to the Docz realtime room over WebSocket, so they see unflushed browser/editor content, not only the latest Git commit.
113+
For AI edits to existing text documents, prefer the `collab` path by default. It connects to the Docz realtime room over WebSocket, so it sees browser/editor content that may not have been flushed to Git yet and avoids the plain-save path that can create `.conflict.web` copies.
114+
115+
Use plain `cat/write` only when the edit is a simple one-shot update where no browser/editor room is expected and only persisted Git content matters.
114116

115117
```bash
116118
npx docz-cli@latest collab cat <space>:<path> # read realtime room content, prints collab_hash to stderr
117-
npx docz-cli@latest collab cat --raw <space>:<path> # raw content only
118119
npx docz-cli@latest collab write <space>:<path> '<text>' --base-collab-hash <hash>
119120
npx docz-cli@latest collab write <space>:<path> - --base-collab-hash <hash>
120121
npx docz-cli@latest collab write --no-publish <space>:<path> '<text>' --base-collab-hash <hash>
@@ -130,15 +131,42 @@ npx docz-cli@latest collab bridge # local JS
130131
4. On conflict: re-run `collab cat`, re-apply the change to the latest realtime content, then retry
131132
5. On "Unknown state" / exit code 75: re-read before retrying because the server may already have processed the publish
132133

133-
Use `--force` only when intentionally replacing current realtime content. Use `--no-publish` when updating the room without flushing to Git yet. After a successful publish, commit history should show the client source in the commit message, for example `web: collab edit ...` or CLI/client-specific metadata if supported by the server.
134+
**Agent-friendly read/write pattern**:
135+
136+
```bash
137+
npx docz-cli@latest collab cat <target> > /tmp/docz-content.md 2> /tmp/docz-meta.txt
138+
```
139+
140+
Edit `/tmp/docz-content.md`. Read `/tmp/docz-meta.txt` to get metadata:
141+
142+
```text
143+
collab_hash: sha256:...
144+
read_only: false
145+
---
146+
```
147+
148+
Extract `collab_hash`, then write back from stdin:
149+
150+
```bash
151+
cat /tmp/docz-content.md | npx docz-cli@latest collab write <target> - --base-collab-hash <hash>
152+
```
153+
154+
For collaborative edits that need to write back, always use normal `collab cat` first so the agent can capture `collab_hash`, then use `collab write --base-collab-hash`. Use `--force` only when intentionally replacing current realtime content. Use `--no-publish` when updating the room without flushing to Git yet. After a successful publish, commit history should show the client source in the commit message, for example `web: collab edit ...` or CLI/client-specific metadata if supported by the server.
134155

135-
**Choosing write vs collab write**:
156+
**Write strategy**:
136157

137-
- Prefer `write` for one-shot file updates where only persisted Git content matters.
138-
- Prefer `collab cat/write` when a browser/editor room may be open, when the user asks to test browser + CLI collaboration, or when avoiding `.external` conflicts is important.
158+
- Prefer `collab cat/write` for editing existing DocSync text documents, especially `.md`, `.txt`, `.csv`, `.html`, and docs the user may have open in Web.
159+
- Always use `collab cat/write` when the user mentions collaboration, browser editing, CLI + browser testing, conflicts, shared editing, or reducing conflict files.
160+
- Use plain `cat/write` only for simple one-shot updates where no active editor is expected.
139161
- Do not mix `cat` + `collab write`; use `collab cat` to get `collab_hash`.
140162
- Do not mix `collab cat` + plain `write` unless the user explicitly wants to bypass the realtime room.
141163

164+
**Connection lifecycle**:
165+
166+
- `collab cat`, `collab write`, and `collab publish` are short-lived commands: they open a WebSocket, finish the operation, then close it automatically.
167+
- `collab bridge` is long-lived. It opens a realtime room and keeps the WebSocket alive until `close`, stdin EOF, or process exit.
168+
- There is no CLI-side idle auto-close for bridge. If a test or editor integration needs "edit, wait 10 seconds, then close", the bridge caller must send `close` after waiting.
169+
142170
### Version Management
143171

144172
```bash
@@ -166,6 +194,7 @@ npx docz-cli@latest comment rm <space> <id> # delete comment
166194

167195
```bash
168196
npx docz-cli@latest share create <space>:<path> [--expires 7d] [--users user@co.com]
197+
npx docz-cli@latest share create <url> [--expires 7d] # create share link from normal DocSync URL
169198
npx docz-cli@latest share list <space> [--file <path>]
170199
npx docz-cli@latest share update <space> <link-id> [--expires 30d]
171200
npx docz-cli@latest share cat <token-or-url> [--raw]
@@ -185,7 +214,7 @@ npx docz-cli@latest diff G160-研发 af0fb9b # space-lev
185214

186215
### Neovim / Terminal Editor Bridge
187216

188-
The repo includes a minimal `docz.nvim` plugin under `plugins/nvim`. It shells out to `docz collab bridge`, which speaks local JSONL over stdio and keeps the Neovim buffer connected to the Docz realtime room.
217+
The repo includes a minimal `docz.nvim` plugin under `plugins/nvim`. It shells out to `docz collab bridge`, which speaks local JSONL over stdio and keeps the Neovim buffer connected to the Docz realtime room. Use bridge only for real terminal editor integrations; for ordinary AI/scripted edits, use `collab cat/write`.
189218

190219
```vim
191220
:DoczCollabOpen <space>:<path>
@@ -194,7 +223,13 @@ The repo includes a minimal `docz.nvim` plugin under `plugins/nvim`. It shells o
194223
:DoczCollabClose
195224
```
196225

197-
This is for true terminal realtime editing. For ordinary scripted edits, prefer `collab cat/write`; for editor UX, use the Neovim plugin.
226+
Bridge protocol summary for editor integrations:
227+
228+
- `open` opens the realtime room and returns content/hash.
229+
- `local_change` sends local buffer content with `base_hash`.
230+
- `publish` flushes the room to the Docz repository.
231+
- `status` reports connection/read state.
232+
- `close` closes the realtime room.
198233

199234
## Unix Pipes
200235

0 commit comments

Comments
 (0)