You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -110,11 +110,12 @@ Use `cat --ref` only if you need to display or log the Git ref; the safe-edit wo
110
110
111
111
### Realtime Collaborative Editing
112
112
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.
114
116
115
117
```bash
116
118
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
4. On conflict: re-run `collab cat`, re-apply the change to the latest realtime content, then retry
131
132
5. On "Unknown state" / exit code 75: re-read before retrying because the server may already have processed the publish
132
133
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.
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.
134
155
135
-
**Choosing write vs collab write**:
156
+
**Write strategy**:
136
157
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.
139
161
- Do not mix `cat` + `collab write`; use `collab cat` to get `collab_hash`.
140
162
- Do not mix `collab cat` + plain `write` unless the user explicitly wants to bypass the realtime room.
141
163
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.
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`.
189
218
190
219
```vim
191
220
:DoczCollabOpen <space>:<path>
@@ -194,7 +223,13 @@ The repo includes a minimal `docz.nvim` plugin under `plugins/nvim`. It shells o
194
223
:DoczCollabClose
195
224
```
196
225
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.
0 commit comments