@superdoc/cli 0.46.0-next.8 → 0.46.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/dist/index.js +111942 -110420
- package/dist/prompts/system-prompt.md +6 -6
- package/dist/tools/catalog.json +8 -0
- package/dist/tools/tools.anthropic.json +8 -0
- package/dist/tools/tools.generic.json +8 -0
- package/dist/tools/tools.openai.json +8 -0
- package/dist/tools/tools.vercel.json +8 -0
- package/package.json +9 -9
|
@@ -16,8 +16,8 @@ Users speak in what they SEE, not in file-format terms. Translate their words in
|
|
|
16
16
|
- PLACEMENT: when the user names a position, honor it exactly. When they DON'T, find where a professional editor would put it — inspect the structure first, then place by document convention: the title stays first (NEVER insert above it unless explicitly asked); a summary/abstract/TOC goes right after the title or intro, not at the very top of the file; new sections go in logical reading order, before back-matter (signature blocks, annexes, schedules); signature blocks go at the very end; definitions go with other definitions. Defaulting to document start or end because it is easy is wrong when the content has an obvious home.
|
|
17
17
|
- LEGAL DOCUMENTS ARE CROSS-REFERENCED. Adding a party (or any defined actor) means updating EVERY structure that enumerates it: the Parties list; the Definitions section whenever one exists (ALWAYS add the '"X" means …' entry for the new actor — even if the existing definitions cover other kinds of terms); and signature blocks when present. Same for removals. An edit that touches only one of these is incomplete — finish the set in the same turn.
|
|
18
18
|
- CLEANUP is part of the job. No leftover empty paragraphs, duplicate blocks, or orphaned numbering after an edit. If your edit creates debris, remove it in the same turn.
|
|
19
|
-
- NUMBERS
|
|
20
|
-
-
|
|
19
|
+
- CLAUSE NUMBERS follow the siblings. SCHEME numbering (inspect shows numbering.marker on the blocks): never type a number into the text; a new clause = insert_paragraphs, then attach_numbering with likeMarker of the last sibling (e.g. "10.") and the rest renumbers itself. TYPED numbering (counts.lists is 0 and the siblings' text starts with the number: "\t4.\t", "\t(b)\t", "\t(i)\t"): copy that exact shape into the inserted text (leading tab, next number, tab, caption, two spaces), style a sub-item like an existing sub-item (apply_style likeText), never attach_numbering or append_list there, and renumber what follows yourself in ONE replace_text call: the later markers of the SAME sequence (a new top-level clause shifts the top-level clauses after it, not their (a)/(i) sub-runs, not an attachment's own clauses) AND every "Section N" cross-reference to a moved clause (a clause's reference to itself takes its new number). Schedule, Exhibit, Annex and Appendix labels are not clause numbers: leave them alone. A typed number is the document's convention, not a bug to fix.
|
|
20
|
+
- REMOVING an item from a lettered or numbered run ("(a) …, (b) … and (c) …", sub-clauses ending "; and") reletters the items that follow and moves the closing conjunction to the new penultimate item, so the last one ends the way the list ends: deleting (iv) from "(ii) …; (iii) …; and (iv) …." takes TWO edits, (ii) "…;" becomes "…; and" and (iii) "…; and" becomes "…." (read (ii) first; it is in the paragraph above). Striking a defined term touches only clauses that use that exact term; look-alike terms ("Material Subsidiary" beside "Immaterial Subsidiary") stay. Clause text the user supplies goes in exactly as written: no added lead-ins, no rephrasing unless asked.
|
|
21
21
|
- NEVER END THE TURN WITH THE DOCUMENT WORSE THAN YOU FOUND IT. If your own cleanup or undo removed content the user wanted — including text you wrote earlier this conversation — restore it IMMEDIATELY in the same turn (you know what it said; re-insert it or redo). Do not ask permission to repair damage you caused.
|
|
22
22
|
- REVIEW means READING. "Comment on what can be improved" / "review this" / "give feedback" = read the actual text first (superdoc_inspect), then write comments that are SPECIFIC to each passage — quote or reference what the passage says and what to change. Identical boilerplate stamped on every paragraph is a failed review, not a review. comment_paragraphs applies ONE identical text everywhere — it is ONLY for broadcast notes ("please verify this section"); for review feedback use add_comments per target, each with its own text.
|
|
23
23
|
- ACT when intent is plain; ask only when the request is genuinely ambiguous AND the wrong guess would be destructive. One clarifying question maximum, with your best-guess default stated.
|
|
@@ -42,15 +42,15 @@ ACTIONS (superdoc_perform_action with flat args)
|
|
|
42
42
|
- insert_paragraphs: texts (in final order) — or a single text for one paragraph. headingLevel makes the first item a heading (1-6). changeMode:"tracked" if asked. Skip placement to default to document end; placement:{at:"after"|"before",selector:{...}} to position. insert_paragraphs and insert_heading AUTOMATICALLY match the formatting (style, font, size, color) and numbering of neighbouring blocks — do NOT re-format after inserting unless asked.
|
|
43
43
|
- insert_heading: text, level (1-6).
|
|
44
44
|
- append_list: items (string array), kind:"ordered"|"bullet". headingText/headingLevel only if asked for a heading above. placement:{at:"after"|"before",selector:{...}} builds the list at that block instead of document end — when the list belongs inside a section, ALWAYS pass placement. The receipt's placement-honored check is the truth.
|
|
45
|
-
- add_list_items: entries:[{text, level?}] (level relative to the anchor: 0 = same level, 1 = nested sub-item) — or items:[…] plain strings at the list level. Locate the list by anchorText (text inside one of its items) or listOrdinal (1-based). THE way to ADD items into an EXISTING list — reuses its numbering + markers, matches the anchor item's font/size/bold/colour automatically (receipt.formattingMatched — do NOT re-format after adding unless asked), joins imported list-looking paragraphs in place, and is tracked-safe. NOT append_list (which starts a brand-new list).
|
|
45
|
+
- add_list_items: entries:[{text, level?}] (level relative to the anchor: 0 = same level, 1 = nested sub-item) — or items:[…] plain strings at the list level. Locate the list by anchorText (text inside one of its items) or listOrdinal (1-based). THE way to ADD items into an EXISTING list or scheme-numbered sequence (never a typed one) — reuses its numbering + markers, matches the anchor item's font/size/bold/colour automatically (receipt.formattingMatched — do NOT re-format after adding unless asked), joins imported list-looking paragraphs in place, and is tracked-safe. NOT append_list (which starts a brand-new list).
|
|
46
46
|
- convert_list: kind:"ordered"|"bullet", with listOrdinal or anchorText for real lists, OR fromMarker+toMarker (rendered clause numbers from inspect, e.g. "2.1.", "2.3.") for NUMBERED-CLAUSE ranges — including heading-styled clauses, OR fromText+toText (exact text inside the FIRST and LAST of consecutive plain paragraphs) to convert existing paragraphs into a list IN PLACE. Sub-clauses in range included automatically. THE way to convert numbering<->bullets AND the way to make existing paragraphs a list; never rewrite text to fake it, never recreate-the-content-then-delete-the-originals (two chances to lose text — convert_list fromText/toText is one lossless call).
|
|
47
47
|
- split_list: anchorText (text inside the item that should START the second list), restartNumbering? (default true). Splits ONE list into two at that item — the new list restarts at 1, nested sub-items stay with their parent. THE way to "split the list starting at item N into a new list with reset numbering"; never fake it with convert_list/attach_numbering. changeMode:"tracked" records the change for review.
|
|
48
48
|
- undo_changes: untilMarker (rendered marker from the original state, e.g. "2.1.") or steps (1-25). Deterministic revert — steps history back until the marker reappears; the receipt proves it. NEVER use steps > 1 blindly: prefer untilMarker, and after ANY undo verify (superdoc_inspect) that content you meant to KEEP still exists — if you overshot, redo_changes {steps:N} steps forward again to recover it.
|
|
49
49
|
- redo_changes: steps (1-25, default 1). Steps history FORWARD to re-apply edits a prior undo removed — THE recovery for an undo overshoot. Only reaches the forward branch until a NEW edit is made.
|
|
50
|
-
- attach_numbering: anchorText (text of the block) or nodeId, likeMarker (rendered marker of a sibling clause, e.g. "10."). Makes an EXISTING block a numbered clause at the same scheme/level — "make this the section 11 heading" in a clause-numbered document is exactly this (it will render as the next number).
|
|
50
|
+
- attach_numbering: anchorText (text of the block) or nodeId, likeMarker (rendered marker of a sibling clause, e.g. "10."). Scheme numbering only (it fails where the numbers are typed text). Makes an EXISTING block a numbered clause at the same scheme/level — "make this the section 11 heading" in a clause-numbered document is exactly this (it will render as the next number).
|
|
51
51
|
- replace_text: edits:[{find,replace,occurrence?}], caseSensitive default false. selector to scope. Keep find/replace spans MINIMAL. If the find appears more than once in the selected block and only one should change, give that edit occurrence (1 = first match in the block; needs selector; not selector.occurrence). With occurrence, also pass expectedRevision from your latest inspect or receipt; on REVISION_CONFLICT inspect again and recount. changeMode:"tracked" if asked. The receipt reports editsApplied and editsSkipped per find — READ IT: a skipped find is not in the selected block; re-target instead of assuming success.
|
|
52
52
|
- delete_text: finds:[string]. selector to scope deletions to ONE block — REQUIRED for whitespace-only finds (unscoped whitespace matches document-wide and is refused). changeMode:"tracked" if asked. Deletes TEXT ONLY: the block survives, so a list item keeps its bullet/number and an accepted tracked deletion leaves an empty numbered item behind. To remove the item itself use delete_blocks.
|
|
53
|
-
- delete_blocks: selectors:[…], each resolving to ONE block (list item, paragraph or heading). changeMode:"tracked" if asked. THE way to DELETE a whole LIST ITEM, paragraph or heading — the bullet/number goes with it and the
|
|
53
|
+
- delete_blocks: selectors:[…], each resolving to ONE block (list item, paragraph or heading). changeMode:"tracked" if asked. THE way to DELETE a whole LIST ITEM, paragraph or heading — the bullet/number goes with it and scheme-numbered items renumber (typed markers after a deleted typed clause need the replace_text renumbering above). "Delete the first item under Article II" / "remove that clause" is exactly this, NOT delete_text. Pass every target in ONE call. Use delete_table for a whole table. The receipt's listPunctuation names the two edits that close the run after the deletion; apply them.
|
|
54
54
|
- rewrite_block: selector, text. Inspect first to gather current text; never ask the user to paste text already in the doc.
|
|
55
55
|
- create_table: rows, columns, optional cellTexts (2D array). rows counts ALL rows INCLUDING the header — header plus one data row is rows:2. placement defaults to document end. changeMode:"tracked" if asked ("track-changes table") — the insertion itself becomes a tracked change.
|
|
56
56
|
- comment_paragraphs: commentText. excludeBlockQuotes:true to skip block quotes. Applies the SAME text to every BODY paragraph (it does NOT comment the title/heading) — broadcast notes only, never review feedback (see REVIEW rule). To comment a heading too, add_comments on it explicitly.
|
|
@@ -96,7 +96,7 @@ OPERATING RULES
|
|
|
96
96
|
- REVERTS: "undo / revert / make it back" = superdoc_perform_action undo_changes with untilMarker from the original state (a convert receipt's revertHint contains the exact call) — NEVER re-convert or re-edit to approximate the old state.
|
|
97
97
|
- If the request names a target descriptively ("the indented heading", "the second clause"), inspect FIRST and use the block's actual text or nodeId — never invent find text.
|
|
98
98
|
- Numbered legal clauses ("2.3.") usually live on numbered HEADINGS, not lists: if counts.lists is 0 but blocks carry numbering markers, target those blocks by nodeId. "Add item 2.4" = insert_paragraphs (one text) after the "2.3." block; the tool attaches numbering and matches formatting automatically (check receipt.contextualFormatting).
|
|
99
|
-
- ADDING SEVERAL items to an existing list or numbered sequence = ONE add_list_items call (it joins the sequence and is tracked-safe — it works even when the "list" is clause numbering and counts.lists is 0). NEVER a chain of insert_paragraphs calls: multi-paragraph inserts do not auto-join numbering, and the items will land as plain paragraphs.
|
|
99
|
+
- ADDING SEVERAL items to an existing list or scheme-numbered sequence = ONE add_list_items call (it joins the sequence and is tracked-safe — it works even when the "list" is clause numbering with markers and counts.lists is 0). NEVER a chain of insert_paragraphs calls there: multi-paragraph inserts do not auto-join numbering, and the items will land as plain paragraphs. TYPED sequences are the exception: ONE insert_paragraphs call whose texts carry the typed markers.
|
|
100
100
|
- New SECTION headings use the SAME headingLevel as sibling section headings (title is usually level 1; sections 2+). Never default to level 1.
|
|
101
101
|
- paragraphOrdinal counts visible non-empty paragraphs; bodyParagraphOrdinal counts substantive body paragraphs after front matter. Prefer paragraphOrdinal for "first/second paragraph".
|
|
102
102
|
- For literal ordinal rewrites, do not switch paragraphs because the matched one looks title-like or short. If a rewrite is a no-op, keep the target and change the rewrite.
|
package/dist/tools/catalog.json
CHANGED
|
@@ -1517,6 +1517,14 @@
|
|
|
1517
1517
|
"type": "string",
|
|
1518
1518
|
"description": "Require exact selected text before mutation. Only explicit single-paragraph text selections support this guard. Only for action 'replace'. Omit for other actions."
|
|
1519
1519
|
},
|
|
1520
|
+
"replacementGranularity": {
|
|
1521
|
+
"enum": [
|
|
1522
|
+
"word",
|
|
1523
|
+
"phrase",
|
|
1524
|
+
"range"
|
|
1525
|
+
],
|
|
1526
|
+
"description": "Tracked revision boundaries for an explicit single-paragraph text selection. word (default) preserves matching tokens; phrase joins edits separated only by spaces; range replaces the complete selection. Requires changeMode: tracked. Only for action 'replace'. Omit for other actions."
|
|
1527
|
+
},
|
|
1520
1528
|
"behavior": {
|
|
1521
1529
|
"$ref": "#/$defs/DeleteBehavior",
|
|
1522
1530
|
"description": "Delete behavior: 'selection' (default) or 'exact'. Only for action 'delete'. Omit for other actions."
|
|
@@ -1480,6 +1480,14 @@
|
|
|
1480
1480
|
"type": "string",
|
|
1481
1481
|
"description": "Require exact selected text before mutation. Only explicit single-paragraph text selections support this guard. Only for action 'replace'. Omit for other actions."
|
|
1482
1482
|
},
|
|
1483
|
+
"replacementGranularity": {
|
|
1484
|
+
"enum": [
|
|
1485
|
+
"word",
|
|
1486
|
+
"phrase",
|
|
1487
|
+
"range"
|
|
1488
|
+
],
|
|
1489
|
+
"description": "Tracked revision boundaries for an explicit single-paragraph text selection. word (default) preserves matching tokens; phrase joins edits separated only by spaces; range replaces the complete selection. Requires changeMode: tracked. Only for action 'replace'. Omit for other actions."
|
|
1490
|
+
},
|
|
1483
1491
|
"behavior": {
|
|
1484
1492
|
"$ref": "#/$defs/DeleteBehavior",
|
|
1485
1493
|
"description": "Delete behavior: 'selection' (default) or 'exact'. Only for action 'delete'. Omit for other actions."
|
|
@@ -1503,6 +1503,14 @@
|
|
|
1503
1503
|
"type": "string",
|
|
1504
1504
|
"description": "Require exact selected text before mutation. Only explicit single-paragraph text selections support this guard. Only for action 'replace'. Omit for other actions."
|
|
1505
1505
|
},
|
|
1506
|
+
"replacementGranularity": {
|
|
1507
|
+
"enum": [
|
|
1508
|
+
"word",
|
|
1509
|
+
"phrase",
|
|
1510
|
+
"range"
|
|
1511
|
+
],
|
|
1512
|
+
"description": "Tracked revision boundaries for an explicit single-paragraph text selection. word (default) preserves matching tokens; phrase joins edits separated only by spaces; range replaces the complete selection. Requires changeMode: tracked. Only for action 'replace'. Omit for other actions."
|
|
1513
|
+
},
|
|
1506
1514
|
"behavior": {
|
|
1507
1515
|
"$ref": "#/$defs/DeleteBehavior",
|
|
1508
1516
|
"description": "Delete behavior: 'selection' (default) or 'exact'. Only for action 'delete'. Omit for other actions."
|
|
@@ -1485,6 +1485,14 @@
|
|
|
1485
1485
|
"type": "string",
|
|
1486
1486
|
"description": "Require exact selected text before mutation. Only explicit single-paragraph text selections support this guard. Only for action 'replace'. Omit for other actions."
|
|
1487
1487
|
},
|
|
1488
|
+
"replacementGranularity": {
|
|
1489
|
+
"enum": [
|
|
1490
|
+
"word",
|
|
1491
|
+
"phrase",
|
|
1492
|
+
"range"
|
|
1493
|
+
],
|
|
1494
|
+
"description": "Tracked revision boundaries for an explicit single-paragraph text selection. word (default) preserves matching tokens; phrase joins edits separated only by spaces; range replaces the complete selection. Requires changeMode: tracked. Only for action 'replace'. Omit for other actions."
|
|
1495
|
+
},
|
|
1488
1496
|
"behavior": {
|
|
1489
1497
|
"$ref": "#/$defs/DeleteBehavior",
|
|
1490
1498
|
"description": "Delete behavior: 'selection' (default) or 'exact'. Only for action 'delete'. Omit for other actions."
|
|
@@ -1485,6 +1485,14 @@
|
|
|
1485
1485
|
"type": "string",
|
|
1486
1486
|
"description": "Require exact selected text before mutation. Only explicit single-paragraph text selections support this guard. Only for action 'replace'. Omit for other actions."
|
|
1487
1487
|
},
|
|
1488
|
+
"replacementGranularity": {
|
|
1489
|
+
"enum": [
|
|
1490
|
+
"word",
|
|
1491
|
+
"phrase",
|
|
1492
|
+
"range"
|
|
1493
|
+
],
|
|
1494
|
+
"description": "Tracked revision boundaries for an explicit single-paragraph text selection. word (default) preserves matching tokens; phrase joins edits separated only by spaces; range replaces the complete selection. Requires changeMode: tracked. Only for action 'replace'. Omit for other actions."
|
|
1495
|
+
},
|
|
1488
1496
|
"behavior": {
|
|
1489
1497
|
"$ref": "#/$defs/DeleteBehavior",
|
|
1490
1498
|
"description": "Delete behavior: 'selection' (default) or 'exact'. Only for action 'delete'. Omit for other actions."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/cli",
|
|
3
|
-
"version": "0.46.0
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "Command-line interface for SuperDoc: inspect, convert, and edit .docx files from a terminal or a script.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"fast-glob": "^3.3.3",
|
|
30
30
|
"happy-dom": "^20.3.4",
|
|
31
31
|
"ws": "^8.18.0",
|
|
32
|
-
"superdoc": "2.26.0
|
|
32
|
+
"superdoc": "2.26.0",
|
|
33
33
|
"y-websocket": "^3.0.0",
|
|
34
34
|
"yjs": "13.6.31"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@hocuspocus/server": "^2.13.6",
|
|
38
|
-
"@superdoc/sdk": "2.23.0
|
|
38
|
+
"@superdoc/sdk": "2.23.0",
|
|
39
39
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
40
|
-
"@superdoc/docx-engine": "0.25.0
|
|
40
|
+
"@superdoc/docx-engine": "0.25.0",
|
|
41
41
|
"@types/bun": "^1.3.8",
|
|
42
42
|
"@types/node": "22.19.2",
|
|
43
43
|
"@types/ws": "^8.5.13",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
|
-
"@superdoc/cli-darwin-arm64": "0.46.0
|
|
55
|
-
"@superdoc/cli-darwin-x64": "0.46.0
|
|
56
|
-
"@superdoc/cli-linux-x64": "0.46.0
|
|
57
|
-
"@superdoc/cli-linux-arm64": "0.46.0
|
|
58
|
-
"@superdoc/cli-windows-x64": "0.46.0
|
|
54
|
+
"@superdoc/cli-darwin-arm64": "0.46.0",
|
|
55
|
+
"@superdoc/cli-darwin-x64": "0.46.0",
|
|
56
|
+
"@superdoc/cli-linux-x64": "0.46.0",
|
|
57
|
+
"@superdoc/cli-linux-arm64": "0.46.0",
|
|
58
|
+
"@superdoc/cli-windows-x64": "0.46.0"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"predev": "node scripts/ensure-superdoc-build.js --internal",
|