@superdoc/cli 0.23.0-next.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/LICENSE +661 -0
- package/README.md +396 -0
- package/dist/assets/blank.docx +0 -0
- package/dist/index.js +569197 -0
- package/dist/prompts/mcp-prompt.md +23 -0
- package/dist/prompts/system-prompt.md +108 -0
- package/dist/tools/catalog.json +8775 -0
- package/dist/tools/system-prompt-mcp.md +467 -0
- package/dist/tools/system-prompt.md +422 -0
- package/dist/tools/tools.anthropic.json +8099 -0
- package/dist/tools/tools.generic.json +8312 -0
- package/dist/tools/tools.openai.json +8129 -0
- package/dist/tools/tools.vercel.json +8129 -0
- package/package.json +72 -0
- package/skill/SKILL.md +205 -0
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@superdoc/cli",
|
|
3
|
+
"version": "0.23.0-next.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"superdoc": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"skill"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@hocuspocus/provider": "^2.13.6",
|
|
16
|
+
"@liveblocks/client": "^3.15.5",
|
|
17
|
+
"@liveblocks/yjs": "^3.15.5",
|
|
18
|
+
"fast-glob": "^3.3.3",
|
|
19
|
+
"happy-dom": "^20.3.4",
|
|
20
|
+
"ws": "^8.18.0",
|
|
21
|
+
"y-websocket": "^3.0.0",
|
|
22
|
+
"yjs": "13.6.31",
|
|
23
|
+
"superdoc": "2.0.0-next.36"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/bun": "^1.3.8",
|
|
27
|
+
"@types/node": "22.19.2",
|
|
28
|
+
"@types/ws": "^8.5.13",
|
|
29
|
+
"jszip": "3.10.1",
|
|
30
|
+
"lib0": "^0.2.114",
|
|
31
|
+
"typescript": "^5.9.2",
|
|
32
|
+
"y-protocols": "^1.0.6",
|
|
33
|
+
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
34
|
+
"@superdoc-dev/sdk": "2.0.0-next.1",
|
|
35
|
+
"@superdoc/docx-engine": "0.2.0-next.8"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"optionalDependencies": {
|
|
41
|
+
"@superdoc/cli-darwin-x64": "0.23.0-next.1",
|
|
42
|
+
"@superdoc/cli-linux-x64": "0.23.0-next.1",
|
|
43
|
+
"@superdoc/cli-darwin-arm64": "0.23.0-next.1",
|
|
44
|
+
"@superdoc/cli-windows-x64": "0.23.0-next.1",
|
|
45
|
+
"@superdoc/cli-linux-arm64": "0.23.0-next.1"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"predev": "node scripts/ensure-superdoc-build.js",
|
|
49
|
+
"dev": "bun run src/index.ts",
|
|
50
|
+
"prebuild": "node scripts/ensure-superdoc-build.js",
|
|
51
|
+
"build": "bun build src/index.ts --outdir dist --target node --format esm --sourcemap=none && node scripts/copy-runtime-assets.js && rm -rf dist/prompts && mkdir -p dist/prompts && cp ../../packages/sdk/langs/node/src/prompts/*.md dist/prompts/ && rm -rf dist/tools && mkdir -p dist/tools && cp ../../packages/sdk/tools/catalog.json ../../packages/sdk/tools/tools.openai.json ../../packages/sdk/tools/tools.anthropic.json ../../packages/sdk/tools/tools.vercel.json ../../packages/sdk/tools/tools.generic.json ../../packages/sdk/tools/system-prompt.md ../../packages/sdk/tools/system-prompt-mcp.md dist/tools/ && pnpm run audit:artifacts",
|
|
52
|
+
"audit:artifacts": "node scripts/audit-cli-artifacts.js",
|
|
53
|
+
"prebuild:native": "node scripts/ensure-superdoc-build.js",
|
|
54
|
+
"build:native": "bun build src/index.ts --compile --minify --outfile dist/superdoc --sourcemap=none && node scripts/copy-runtime-assets.js && rm -rf dist/tools && mkdir -p dist/tools && cp ../../packages/sdk/tools/catalog.json ../../packages/sdk/tools/tools.openai.json ../../packages/sdk/tools/tools.anthropic.json ../../packages/sdk/tools/tools.vercel.json ../../packages/sdk/tools/tools.generic.json ../../packages/sdk/tools/system-prompt.md ../../packages/sdk/tools/system-prompt-mcp.md dist/tools/ && pnpm run audit:artifacts",
|
|
55
|
+
"build:native:all": "node scripts/build-native-cli.js --all",
|
|
56
|
+
"build:native:host": "node scripts/build-native-cli.js",
|
|
57
|
+
"build:stage": "node scripts/stage-artifacts.js",
|
|
58
|
+
"build:sync-version": "node scripts/sync-version.js",
|
|
59
|
+
"build:prepublish": "node scripts/build-and-stage.js",
|
|
60
|
+
"publish:platforms": "node scripts/publish.js --tag latest",
|
|
61
|
+
"publish:platforms:dry": "node scripts/publish.js --tag latest --dry-run",
|
|
62
|
+
"pretest": "node scripts/ensure-superdoc-build.js",
|
|
63
|
+
"test": "NODE_ENV=test bun test",
|
|
64
|
+
"lint": "eslint .",
|
|
65
|
+
"lint:fix": "eslint --fix .",
|
|
66
|
+
"format": "prettier --write .",
|
|
67
|
+
"pretypecheck": "node scripts/ensure-superdoc-build.js --types",
|
|
68
|
+
"typecheck": "tsc --noEmit -p tsconfig.check.json",
|
|
69
|
+
"release": "pnpx semantic-release",
|
|
70
|
+
"release:dry-run": "pnpx semantic-release --dry-run"
|
|
71
|
+
}
|
|
72
|
+
}
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: superdoc-edit-docx
|
|
3
|
+
description: Edit, query, and transform Word documents with the SuperDoc CLI v1 operation surface. Use when the user asks to read, search, modify, comment, or review changes in .docx files.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SuperDoc CLI (v1)
|
|
7
|
+
|
|
8
|
+
Use SuperDoc CLI for DOCX work. Use v1 commands (canonical operations and their helper wrappers).
|
|
9
|
+
Do not default to legacy commands unless explicitly needed for v0-style bulk workflows.
|
|
10
|
+
|
|
11
|
+
Use `superdoc` if installed, or `npx @superdoc-dev/cli@latest` as a fallback.
|
|
12
|
+
|
|
13
|
+
## First Step: Discover Exact Params
|
|
14
|
+
|
|
15
|
+
For unknown commands or flags, inspect runtime metadata first:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
superdoc describe
|
|
19
|
+
superdoc describe command find
|
|
20
|
+
superdoc describe command "comments add"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Use `describe command` for per-command args and constraints.
|
|
24
|
+
|
|
25
|
+
## Preferred Workflows
|
|
26
|
+
|
|
27
|
+
### 1) Edit an existing document (recommended for targeted changes)
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
superdoc open ./contract.docx
|
|
31
|
+
superdoc query match --select-json '{"type":"text","pattern":"termination"}' --require exactlyOne
|
|
32
|
+
superdoc replace --target-json '{"kind":"text","blockId":"p1","range":{"start":0,"end":11}}' --text "expiration"
|
|
33
|
+
superdoc save --in-place
|
|
34
|
+
superdoc close
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- Use `query match` when you are modifying existing content and need an exact mutation target.
|
|
38
|
+
- After `open`, commands run against the active/default session when `<doc>` is omitted.
|
|
39
|
+
- Use `superdoc session list|set-default|save|close` for explicit session control.
|
|
40
|
+
- `close` on dirty state requires `--discard` or a prior `save`.
|
|
41
|
+
|
|
42
|
+
### 2) Generate or seed a document body (recommended for synthetic/probe docs)
|
|
43
|
+
|
|
44
|
+
Use `open --content-override` when you want to create a new body from Markdown, HTML, or plain text in one step.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
superdoc open --content-override "# Probe Title\n\nALPHA01" --override-type markdown
|
|
48
|
+
superdoc save --out ./probe.docx
|
|
49
|
+
superdoc close
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
superdoc open template.docx \
|
|
54
|
+
--content-override '<p>ALPHA01 <strong>BRAVO02</strong><br/>CHARLIE03</p>' \
|
|
55
|
+
--override-type html
|
|
56
|
+
superdoc save --out ./probe.docx
|
|
57
|
+
superdoc close
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- `--content-override` is the fastest way to seed paragraphs, headings, lists, and `<br/>` line breaks.
|
|
61
|
+
- Use `--override-type markdown|html|text` explicitly. `open` rejects `--content-override` without it.
|
|
62
|
+
- For generation, do not start with `query match` unless you are modifying content that already exists.
|
|
63
|
+
|
|
64
|
+
### 3) Generate incrementally, then reuse the insert receipt target
|
|
65
|
+
|
|
66
|
+
When you need deterministic inline formatting after seeding text, insert first, then reuse the returned target block/range.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
superdoc open
|
|
70
|
+
superdoc insert --value "ALPHA01 BRAVO02 CHARLIE03"
|
|
71
|
+
superdoc format apply --block-id <from-insert-receipt> --start 8 --end 15 --inline-json '{"fontSize":16,"fontFamily":"Times New Roman"}'
|
|
72
|
+
superdoc format apply --block-id <from-insert-receipt> --start 16 --end 25 --inline-json '{"fontSize":10,"fontFamily":"Arial"}'
|
|
73
|
+
superdoc save --out ./probe.docx
|
|
74
|
+
superdoc close
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
- The insert receipt contains the resolved target under `receipt.resolution.target`.
|
|
78
|
+
- For a simple one-paragraph synthetic doc, direct `--block-id --start --end` formatting is usually shorter than re-querying.
|
|
79
|
+
- Use `query match` again only if later steps need to rediscover content by meaning, not by the range you just created.
|
|
80
|
+
|
|
81
|
+
### 4) Stateless one-off reads
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
superdoc get-text ./proposal.docx
|
|
85
|
+
superdoc get-markdown ./proposal.docx
|
|
86
|
+
superdoc info ./proposal.docx
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 5) Stateless one-off mutations
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
superdoc replace ./proposal.docx \
|
|
93
|
+
--target-json '{"kind":"text","blockId":"p1","range":{"start":0,"end":5}}' \
|
|
94
|
+
--text "Updated" \
|
|
95
|
+
--out ./proposal.updated.docx
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- In stateless mode (`<doc>` provided), mutating commands require `--out` unless using `--dry-run`.
|
|
99
|
+
|
|
100
|
+
### 6) Inline special nodes: tabs vs line breaks
|
|
101
|
+
|
|
102
|
+
- `insert line-break` inserts a real Word line break node inside the current paragraph.
|
|
103
|
+
- `insert tab` inserts a real Word tab node inside the current paragraph.
|
|
104
|
+
- Paragraph tab stops are different. Tab stops control layout positions; tab nodes are inline content characters that advance to the next tab stop.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
superdoc insert line-break --block-id p1 --offset 12
|
|
108
|
+
superdoc insert tab --block-id p1 --offset 12
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- Use `format paragraph set-tab-stop` / related paragraph formatting commands when you need the tab stop definitions themselves.
|
|
112
|
+
- Use the inline insert commands when you need actual `w:br` or `w:tab` content in exported DOCX.
|
|
113
|
+
|
|
114
|
+
### Safety: preview before apply
|
|
115
|
+
|
|
116
|
+
- Use `--dry-run` to preview any mutation without applying it.
|
|
117
|
+
- Use `--expected-revision <n>` with stateful mutations for optimistic concurrency checks.
|
|
118
|
+
|
|
119
|
+
## Common v1 Commands
|
|
120
|
+
|
|
121
|
+
### Query & inspect
|
|
122
|
+
|
|
123
|
+
- Search/browse content: `find --type text --pattern "..."` or `find --query-json '{...}'`
|
|
124
|
+
- Find mutation target: `query match --select-json '{...}' --require exactlyOne`
|
|
125
|
+
- Inspect blocks: `blocks list`, `get-node`, `get-node-by-id`
|
|
126
|
+
- Extract content: `get-text`, `get-markdown`, `get-html`
|
|
127
|
+
|
|
128
|
+
### Mutate
|
|
129
|
+
|
|
130
|
+
- Replace text: `replace --target-json '{...}' --text "..."`
|
|
131
|
+
- Insert inline text: `insert --block-id <id> --offset <n> --value "..."`
|
|
132
|
+
- Insert inline tab/line break nodes: `insert tab`, `insert line-break`
|
|
133
|
+
- Delete text/node: `delete --target-json '{...}'`
|
|
134
|
+
- Delete blocks: `blocks delete`, `blocks delete-range`
|
|
135
|
+
- Batch mutations: `mutations apply --steps-json '[...]' --atomic true --change-mode direct`
|
|
136
|
+
- Create paragraph: `create paragraph --text "..."` (with optional `--at-json`)
|
|
137
|
+
- Create heading: `create heading --input-json '{"level":<n>,"text":"..."}'`
|
|
138
|
+
|
|
139
|
+
### Format
|
|
140
|
+
|
|
141
|
+
- Apply formatting: `format apply --block-id <id> --start <n> --end <n> --inline-json '{"bold":true}'`
|
|
142
|
+
- Shortcuts: `format bold`, `format italic`, `format underline`, `format strikethrough`
|
|
143
|
+
|
|
144
|
+
### Lists
|
|
145
|
+
|
|
146
|
+
- List items: `lists list`, `lists get`
|
|
147
|
+
- Insert list item: `lists insert --node-id <id> --position after --text "..."`
|
|
148
|
+
- Modify: `lists indent`, `lists outdent`, `lists set-level`, `lists set-type`, `lists convert-to-text`
|
|
149
|
+
|
|
150
|
+
### Comments
|
|
151
|
+
|
|
152
|
+
- Add/reply: `comments add`, `comments reply`
|
|
153
|
+
- Read: `comments get`, `comments list`
|
|
154
|
+
- Edit/resolve/move: `comments edit`, `comments resolve`, `comments move`, `comments set-internal`
|
|
155
|
+
- Delete: `comments delete` (canonical) or `comments remove` (alias)
|
|
156
|
+
|
|
157
|
+
### Track changes
|
|
158
|
+
|
|
159
|
+
- List: `track-changes list`, `track-changes get`
|
|
160
|
+
- Decide: `track-changes accept`, `track-changes reject`, `track-changes accept-all`, `track-changes reject-all`
|
|
161
|
+
|
|
162
|
+
### History
|
|
163
|
+
|
|
164
|
+
- `history get`, `history undo`, `history redo`
|
|
165
|
+
|
|
166
|
+
### Low-level
|
|
167
|
+
|
|
168
|
+
- Direct invoke: `call <operationId> --input-json '{...}'` (JSON output only — `--pretty` is not supported)
|
|
169
|
+
|
|
170
|
+
## JSON/File Payload Flags
|
|
171
|
+
|
|
172
|
+
Not all `--*-file` variants are available on every command. Use `describe command <name>` to check.
|
|
173
|
+
|
|
174
|
+
Always supported alongside their `-json` counterpart (use one, not both):
|
|
175
|
+
|
|
176
|
+
| Flag pair | Available on |
|
|
177
|
+
|-----------|-------------|
|
|
178
|
+
| `--query-json` / `--query-file` | `find`, `lists list` |
|
|
179
|
+
| `--address-json` / `--address-file` | `get-node`, `lists get` |
|
|
180
|
+
| `--input-json` / `--input-file` | `call`, `create paragraph` |
|
|
181
|
+
| `--at-json` / `--at-file` | `create paragraph` |
|
|
182
|
+
|
|
183
|
+
`--target-json` is widely available on mutation commands but has **no** `--target-file` counterpart. Use flat flags (`--block-id`, `--start`, `--end`) as an alternative to `--target-json`.
|
|
184
|
+
|
|
185
|
+
## Output and Global Flags
|
|
186
|
+
|
|
187
|
+
- Default output is JSON envelope.
|
|
188
|
+
- In JSON mode, command results are returned as a JSON envelope.
|
|
189
|
+
- Use `--pretty` for human-readable output (not supported by `call`).
|
|
190
|
+
- Use `--quiet` to suppress non-essential warnings in pretty mode.
|
|
191
|
+
- Global flags: `--output <json|pretty>`, `--session <id>`, `--timeout-ms <n>`, `--quiet`.
|
|
192
|
+
- `<doc>` can be `-` to read DOCX bytes from stdin.
|
|
193
|
+
|
|
194
|
+
## Legacy Compatibility (Use Sparingly)
|
|
195
|
+
|
|
196
|
+
Legacy v0.x bridge commands still exist:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
superdoc search <pattern> <files...>
|
|
200
|
+
superdoc replace-legacy <find> <to> <files...>
|
|
201
|
+
superdoc read <file>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Use these only when you specifically need v0-style behavior (especially multi-file glob search/replace).
|
|
205
|
+
For new automations, prefer v1 operations.
|