@sinoia/hubdoc-tools 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +1060 -820
- package/docs/llm-usage.md +62 -0
- package/package.json +1 -1
package/docs/llm-usage.md
CHANGED
|
@@ -408,6 +408,68 @@ without going through a workspace-scoped ACL. Example:
|
|
|
408
408
|
`hubdoc permissions grant --to <user-id> --to-type user --on <project-id>
|
|
409
409
|
--on-type project --level admin`.
|
|
410
410
|
|
|
411
|
+
### Concurrent markdown editing (`hubdoc md`, corex#594)
|
|
412
|
+
|
|
413
|
+
`hubdoc md` exposes the corex `Tools::Documents::MarkdownEditor` (the
|
|
414
|
+
same tool internal Ruby agents use) through a single HTTP endpoint
|
|
415
|
+
(`POST /api/v1/documents/files/:id/markdown_editor`). Eleven surgical
|
|
416
|
+
actions, one HTTP round-trip each:
|
|
417
|
+
|
|
418
|
+
- **Discovery** : `structure` (outline + line numbers), `stats` (word
|
|
419
|
+
counts, section sizes, TODOs), `search --pattern <regex> [--context N]`.
|
|
420
|
+
- **Read** : `read [--from-line N --to-line M | --offset N --limit M]`,
|
|
421
|
+
`read-section --heading "…" [--level N] [--index N]`.
|
|
422
|
+
- **Write** : `write-section --heading "…" (--content <text> |
|
|
423
|
+
--content-file <path>)`, `append`, `insert (--at-line N | --at-offset
|
|
424
|
+
N)`, `delete (--from-line/--to-line | --from-offset/--to-offset)`,
|
|
425
|
+
`replace --find "…" (--replace-with "…" | --replace-with-file <path>)
|
|
426
|
+
[--all]`.
|
|
427
|
+
- **Save** : `save [--create-version] [--version-comment "…"]` — the
|
|
428
|
+
content is auto-saved by every write; `save` is just for the explicit
|
|
429
|
+
version snapshot.
|
|
430
|
+
|
|
431
|
+
**Concurrency & merge — handled server-side, no client state** :
|
|
432
|
+
|
|
433
|
+
Each write action executes on the server as a single load-blob → mutate
|
|
434
|
+
→ save-blob → `publish Documents::FileContentUpdated` cycle. Two agents
|
|
435
|
+
running `hubdoc md insert` in parallel serialise at the Rails +
|
|
436
|
+
ActiveStorage level; the second one loads the first one's result before
|
|
437
|
+
applying its own. No client-side coordination or CRDT to maintain.
|
|
438
|
+
|
|
439
|
+
Cross-modal coordination (agent + human on the web UI): every write
|
|
440
|
+
broadcasts `content_refresh` over `DocumentEditingChannel`, which the
|
|
441
|
+
frontend's Y.js session reloads from server content. Cf. the corex
|
|
442
|
+
design `.claude/context/designs/y-rb-implementation.md`.
|
|
443
|
+
|
|
444
|
+
**Inter-agent coordination via events** :
|
|
445
|
+
|
|
446
|
+
```bash
|
|
447
|
+
# Agent B watches for edits on the file, reacts.
|
|
448
|
+
hubdoc events watch \
|
|
449
|
+
--type Documents::FileContentUpdated \
|
|
450
|
+
--timeout 900 --json \
|
|
451
|
+
| jq -r '.items[-1].data.file_id'
|
|
452
|
+
# → returns as soon as another agent (or the human) touches the file.
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
**Typical agent workflow — build a section incrementally without racing** :
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
# 1. Discover current structure (10 KB, no side effects).
|
|
459
|
+
hubdoc md structure "$FID" --json
|
|
460
|
+
|
|
461
|
+
# 2. Read just the section we care about.
|
|
462
|
+
hubdoc md read-section "$FID" --heading "Analyse" --json > current.md
|
|
463
|
+
|
|
464
|
+
# 3. Regenerate its body locally, push atomically.
|
|
465
|
+
llm-generate-analysis > new-analysis.md
|
|
466
|
+
hubdoc md write-section "$FID" --heading "Analyse" \
|
|
467
|
+
--content-file new-analysis.md --json
|
|
468
|
+
|
|
469
|
+
# 4. Snapshot when done.
|
|
470
|
+
hubdoc md save "$FID" --create-version --version-comment "Analyse v2" --json
|
|
471
|
+
```
|
|
472
|
+
|
|
411
473
|
### Events — react to what's happening (corex#593)
|
|
412
474
|
|
|
413
475
|
`hubdoc events ls` and `hubdoc events watch` sit on top of the Rails
|