@sinoia/hubdoc-tools 1.12.0 → 1.13.1
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 +65 -0
- package/package.json +1 -1
package/docs/llm-usage.md
CHANGED
|
@@ -408,6 +408,71 @@ 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 — server-side, current limitations** :
|
|
432
|
+
|
|
433
|
+
Each write action executes on the server as a single load-blob → mutate
|
|
434
|
+
→ save-blob → `publish Documents::FileContentUpdated` cycle. Cross-modal
|
|
435
|
+
broadcasts still work: every server-side write broadcasts
|
|
436
|
+
`content_refresh` over `DocumentEditingChannel`, and the web UI's Y.js
|
|
437
|
+
session reloads from server content. Cf. the corex design
|
|
438
|
+
`.claude/context/designs/y-rb-implementation.md`.
|
|
439
|
+
|
|
440
|
+
> ⚠️ **Known limitation — lost-update race on concurrent writes**
|
|
441
|
+
> (tracked in [corex#595](https://code.plugandwork.net/sinoia/corex/-/issues/595)):
|
|
442
|
+
> two `hubdoc md insert`/`replace`/`write-section` calls firing in
|
|
443
|
+
> parallel on the **same file** may silently drop one of the writes —
|
|
444
|
+
> the load→save cycle is not yet atomic. Until corex ships a PG advisory
|
|
445
|
+
> lock on `MarkdownEditor#execute`, treat writes on any given file as
|
|
446
|
+
> **sequential**: chain your CLI calls with `await`, or coordinate via
|
|
447
|
+
> an out-of-band lock. Writes on *different* files stay safe.
|
|
448
|
+
|
|
449
|
+
> ⚠️ **Known limitation — `Documents::*` events not yet on `/api/v1/events`**
|
|
450
|
+
> (tracked in [corex#596](https://code.plugandwork.net/sinoia/corex/-/issues/596)):
|
|
451
|
+
> the events API was initially scoped to `Projects::*` types (corex#593).
|
|
452
|
+
> `hubdoc events watch --type Documents::FileContentUpdated` returns
|
|
453
|
+
> nothing today — agent-to-agent coordination on markdown edits is on
|
|
454
|
+
> hold until that scope is opened. In the meantime, coordinate via the
|
|
455
|
+
> ticket the file belongs to (`ticket.updated`, `ticket.comment`) or via
|
|
456
|
+
> an external channel.
|
|
457
|
+
|
|
458
|
+
**Typical agent workflow — build a section incrementally without racing** :
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
# 1. Discover current structure (10 KB, no side effects).
|
|
462
|
+
hubdoc md structure "$FID" --json
|
|
463
|
+
|
|
464
|
+
# 2. Read just the section we care about.
|
|
465
|
+
hubdoc md read-section "$FID" --heading "Analyse" --json > current.md
|
|
466
|
+
|
|
467
|
+
# 3. Regenerate its body locally, push atomically.
|
|
468
|
+
llm-generate-analysis > new-analysis.md
|
|
469
|
+
hubdoc md write-section "$FID" --heading "Analyse" \
|
|
470
|
+
--content-file new-analysis.md --json
|
|
471
|
+
|
|
472
|
+
# 4. Snapshot when done.
|
|
473
|
+
hubdoc md save "$FID" --create-version --version-comment "Analyse v2" --json
|
|
474
|
+
```
|
|
475
|
+
|
|
411
476
|
### Events — react to what's happening (corex#593)
|
|
412
477
|
|
|
413
478
|
`hubdoc events ls` and `hubdoc events watch` sit on top of the Rails
|