@superdoc-dev/sdk 1.0.0-alpha.2 → 1.0.0-alpha.22
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/README.md +126 -0
- package/dist/generated/client.cjs +236 -0
- package/dist/generated/client.d.ts +6318 -0
- package/dist/generated/client.d.ts.map +1 -0
- package/dist/generated/client.js +231 -0
- package/dist/generated/contract.cjs +62387 -0
- package/dist/generated/contract.d.ts +45999 -0
- package/dist/generated/contract.d.ts.map +1 -0
- package/dist/generated/contract.js +62402 -0
- package/dist/helpers/format.d.ts +79 -0
- package/dist/helpers/format.d.ts.map +1 -0
- package/dist/helpers/format.js +121 -0
- package/dist/index.cjs +45 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/runtime/embedded-cli.cjs +100 -0
- package/dist/runtime/embedded-cli.d.ts +5 -0
- package/dist/runtime/embedded-cli.d.ts.map +1 -0
- package/dist/runtime/embedded-cli.js +94 -0
- package/dist/runtime/errors.cjs +22 -0
- package/dist/runtime/errors.d.ts +17 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +18 -0
- package/dist/runtime/host.cjs +352 -0
- package/dist/runtime/host.d.ts +37 -0
- package/dist/runtime/host.d.ts.map +1 -0
- package/dist/runtime/host.js +347 -0
- package/dist/runtime/process.cjs +32 -0
- package/dist/runtime/process.d.ts +16 -0
- package/dist/runtime/process.d.ts.map +1 -0
- package/dist/runtime/process.js +27 -0
- package/dist/runtime/transport-common.cjs +77 -0
- package/dist/runtime/transport-common.d.ts +49 -0
- package/dist/runtime/transport-common.d.ts.map +1 -0
- package/dist/runtime/transport-common.js +72 -0
- package/dist/skills.cjs +148 -0
- package/dist/skills.d.ts +25 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +140 -0
- package/dist/tools.cjs +371 -0
- package/dist/tools.d.ts +113 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +360 -0
- package/package.json +31 -18
- package/skills/editing-docx.md +24 -146
- package/tools/catalog.json +66563 -0
- package/tools/tool-name-map.json +382 -0
- package/tools/tools-policy.json +100 -0
- package/tools/tools.anthropic.json +27979 -0
- package/tools/tools.generic.json +64075 -0
- package/tools/tools.openai.json +29119 -0
- package/tools/tools.vercel.json +29119 -0
- package/LICENSE +0 -661
- package/skills/.gitkeep +0 -0
- package/src/__tests__/skills.test.ts +0 -93
- package/src/generated/DO_NOT_EDIT +0 -2
- package/src/generated/client.ts +0 -3151
- package/src/generated/contract.ts +0 -13396
- package/src/index.ts +0 -72
- package/src/runtime/__tests__/transport-common.test.ts +0 -151
- package/src/runtime/embedded-cli.ts +0 -109
- package/src/runtime/errors.ts +0 -30
- package/src/runtime/host.ts +0 -465
- package/src/runtime/process.ts +0 -45
- package/src/runtime/transport-common.ts +0 -159
- package/src/skills.ts +0 -91
package/skills/editing-docx.md
CHANGED
|
@@ -1,153 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
name: editing-docx
|
|
3
|
-
description: Session-first SuperDoc CLI workflows for querying and editing DOCX files (find/inspect, comments lifecycle, text mutations, tracked-changes review, and close safely).
|
|
4
|
-
---
|
|
1
|
+
# Editing DOCX Documents with SuperDoc SDK
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
You are a document editing assistant using the SuperDoc SDK. You have access to tools
|
|
4
|
+
that let you open, read, search, and modify `.docx` files programmatically.
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
## Workflow
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
1. **Open** the document with `doc.open`
|
|
9
|
+
2. **Inspect** it with `doc.info` to understand structure
|
|
10
|
+
3. **Find** content with `doc.find` using text search or node type queries
|
|
11
|
+
4. **Modify** content using `doc.insert`, `doc.replace`, `doc.delete`, or formatting operations
|
|
12
|
+
5. **Save** changes with `doc.save`
|
|
13
|
+
6. **Close** when done with `doc.close`
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
2. Prefer session mode: `open` once, then run commands without `<doc>`.
|
|
14
|
-
3. Treat CLI envelopes as truth (`ok`, `data`, `error`).
|
|
15
|
-
4. Re-query before mutating if target addresses might be stale.
|
|
16
|
-
5. If matches are ambiguous, ask user which match(es) to modify.
|
|
17
|
-
6. End every workflow with an explicit persistence + close decision:
|
|
18
|
-
- `save --out ...` then `close`
|
|
19
|
-
- `save --in-place` then `close`
|
|
20
|
-
- `close --discard`
|
|
15
|
+
## Key Operations
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
- `doc.find` — Search by text pattern, node type, or structured query
|
|
18
|
+
- `doc.getNode` — Get a specific node by address
|
|
19
|
+
- `doc.insert` — Insert text at a position
|
|
20
|
+
- `doc.replace` — Replace content at a position
|
|
21
|
+
- `doc.delete` — Delete content at a position
|
|
22
|
+
- `doc.format.*` — Apply bold, italic, underline, strikethrough
|
|
23
|
+
- `doc.comments.*` — Add, edit, resolve, remove comments
|
|
24
|
+
- `doc.trackChanges.*` — Accept/reject tracked changes
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
## Best Practices
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
1. Open a session:
|
|
32
|
-
```bash
|
|
33
|
-
superdoc open ./contract.docx --output json
|
|
34
|
-
```
|
|
35
|
-
2. Query and inspect:
|
|
36
|
-
```bash
|
|
37
|
-
superdoc describe --output json
|
|
38
|
-
superdoc describe command doc.find --output json
|
|
39
|
-
superdoc info --output json
|
|
40
|
-
superdoc find --type text --pattern "termination" --output json
|
|
41
|
-
superdoc get-node --address-json '{"kind":"block","nodeType":"paragraph","nodeId":"p1"}' --output json
|
|
42
|
-
```
|
|
43
|
-
3. Mutate (using target JSON from `find` results):
|
|
44
|
-
```bash
|
|
45
|
-
superdoc comments add --target-json '{"kind":"text","blockId":"p1","range":{"start":10,"end":20}}' --text "Please clarify this clause." --output json
|
|
46
|
-
superdoc replace --target-json '{"kind":"text","blockId":"p1","range":{"start":10,"end":20}}' --text "Updated clause text" --dry-run --output json
|
|
47
|
-
superdoc replace --target-json '{"kind":"text","blockId":"p1","range":{"start":10,"end":20}}' --text "Updated clause text" --output json
|
|
48
|
-
```
|
|
49
|
-
4. Verify:
|
|
50
|
-
```bash
|
|
51
|
-
superdoc find --type text --pattern "Updated clause text" --output json
|
|
52
|
-
```
|
|
53
|
-
5. Save and close:
|
|
54
|
-
```bash
|
|
55
|
-
superdoc save --out ./contract.reviewed.docx --output json
|
|
56
|
-
superdoc close --output json
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Command Patterns (Session Mode)
|
|
60
|
-
|
|
61
|
-
### Session lifecycle
|
|
62
|
-
- `superdoc open <doc> [--session <id>] --output json`
|
|
63
|
-
- `superdoc status [--session <id>] --output json`
|
|
64
|
-
- `superdoc save [--in-place] [--out <path>] [--force] --output json`
|
|
65
|
-
- `superdoc close [--discard] --output json`
|
|
66
|
-
- `superdoc session list --output json`
|
|
67
|
-
- `superdoc session save <id> [--in-place] [--out <path>] [--force] --output json`
|
|
68
|
-
- `superdoc session use <id> --output json`
|
|
69
|
-
- `superdoc session set-default <id> --output json`
|
|
70
|
-
- `superdoc session close <id> --discard --output json`
|
|
71
|
-
|
|
72
|
-
### Query
|
|
73
|
-
- `superdoc describe --output json`
|
|
74
|
-
- `superdoc describe command <operationId> --output json`
|
|
75
|
-
- `superdoc info --output json`
|
|
76
|
-
- `superdoc find --type text --pattern "<text>" --output json`
|
|
77
|
-
- `superdoc find --query-json '{...}' --output json`
|
|
78
|
-
- `superdoc get-node --address-json '{...}' --output json`
|
|
79
|
-
- `superdoc get-node-by-id --id <nodeId> [--node-type <type>] --output json`
|
|
80
|
-
|
|
81
|
-
### Mutate
|
|
82
|
-
- `superdoc create paragraph [--input-json '{...}'] [--text "..."] [--at document-start|document-end] [--before-address-json '{...}'] [--after-address-json '{...}'] [--dry-run] [--change-mode direct|tracked] --output json`
|
|
83
|
-
- `superdoc comments add --target-json '{...}' --text "..." --output json`
|
|
84
|
-
- `superdoc comments edit --id <commentId> --text "..." [--expected-revision <n>] [--force] --output json`
|
|
85
|
-
- `superdoc comments reply --parent-id <commentId> --text "..." [--expected-revision <n>] [--force] --output json`
|
|
86
|
-
- `superdoc comments move --id <commentId> --target-json '{...}' [--expected-revision <n>] [--force] --output json`
|
|
87
|
-
- `superdoc comments resolve --id <commentId> [--expected-revision <n>] [--force] --output json`
|
|
88
|
-
- `superdoc comments remove --id <commentId> [--expected-revision <n>] [--force] --output json`
|
|
89
|
-
- `superdoc comments set-internal --id <commentId> --is-internal <true|false> [--expected-revision <n>] [--force] --output json`
|
|
90
|
-
- `superdoc insert [--target-json '{...}'] --text "..." [--dry-run] [--change-mode direct|tracked] --output json`
|
|
91
|
-
- `superdoc replace --target-json '{...}' --text "..." [--dry-run] [--change-mode direct|tracked] --output json`
|
|
92
|
-
- `superdoc delete --target-json '{...}' [--dry-run] [--change-mode direct|tracked] --output json`
|
|
93
|
-
- `superdoc format bold --target-json '{...}' [--dry-run] [--change-mode direct|tracked] --output json`
|
|
94
|
-
|
|
95
|
-
### Comments read/navigation
|
|
96
|
-
- `superdoc comments get --id <commentId> --output json`
|
|
97
|
-
- `superdoc comments list [--include-resolved <true|false>] --output json`
|
|
98
|
-
- `superdoc comments set-active --id <commentId> --output json`
|
|
99
|
-
- `superdoc comments set-active --clear --output json`
|
|
100
|
-
- `superdoc comments go-to --id <commentId> --output json`
|
|
101
|
-
|
|
102
|
-
### Track changes
|
|
103
|
-
- `superdoc track-changes list [--type insert|delete|format] [--limit <n>] [--offset <n>] --output json`
|
|
104
|
-
- `superdoc track-changes get --id <trackedChangeId> --output json`
|
|
105
|
-
- `superdoc track-changes accept --id <trackedChangeId> [--expected-revision <n>] [--force] --output json`
|
|
106
|
-
- `superdoc track-changes reject --id <trackedChangeId> [--expected-revision <n>] [--force] --output json`
|
|
107
|
-
- `superdoc track-changes accept-all [--expected-revision <n>] [--force] --output json`
|
|
108
|
-
- `superdoc track-changes reject-all [--expected-revision <n>] [--force] --output json`
|
|
109
|
-
|
|
110
|
-
### Stateless fallback
|
|
111
|
-
If a command includes `<doc>` (or `--doc`), it runs statelessly for that call.
|
|
112
|
-
For stateless mutate commands, provide `--out <path>`.
|
|
113
|
-
|
|
114
|
-
## Target Selection Guidance
|
|
115
|
-
|
|
116
|
-
- Prefer structural creation for new block insertion:
|
|
117
|
-
- `create paragraph` creates a new paragraph block and returns structural handles (`paragraph`, `insertionPoint`).
|
|
118
|
-
- Prefer `find --type text --pattern ...` first.
|
|
119
|
-
- Use `data.result.context[*].textRanges[*]` as `--target-json` for text edits/comments.
|
|
120
|
-
- `insert` may omit `--target-json`; it defaults to the first editable insertion point (first paragraph start when available).
|
|
121
|
-
- When multiple matches exist, apply a deterministic policy:
|
|
122
|
-
- first match only, or
|
|
123
|
-
- first N matches, or
|
|
124
|
-
- user-selected match indexes.
|
|
125
|
-
- For uncertain targets, run `get-node` before mutate.
|
|
126
|
-
|
|
127
|
-
## Mutation Mode Guidance
|
|
128
|
-
|
|
129
|
-
- Use `--change-mode direct|tracked` to control whether edits create tracked changes.
|
|
130
|
-
- `create paragraph` supports `--change-mode tracked` for tracked structural creation.
|
|
131
|
-
- `replace`, `insert`, `delete`, and `format bold` support `--change-mode tracked`.
|
|
132
|
-
- `track-changes *` commands are for review lifecycle (list/get/accept/reject), not content insertion.
|
|
133
|
-
|
|
134
|
-
## Scenario Prompts (Copy/Paste)
|
|
135
|
-
|
|
136
|
-
1. Open `./contracts/msa.docx`, find `termination`, add comments to the first 2 matches asking for clearer notice period, then save to `./contracts/msa.reviewed.docx`.
|
|
137
|
-
2. Use the active session to find `governing law`, inspect the top match node, then add a concise legal-risk comment.
|
|
138
|
-
3. Open two sessions (`vendor-a`, `vendor-b`) on different docs, switch between them, and add one comment in each.
|
|
139
|
-
4. Run a redline pass replacing `shall` with `must` for the first 3 matches: dry-run first, then apply.
|
|
140
|
-
5. Run `track-changes list`, inspect one change with `track-changes get`, then accept it by id.
|
|
141
|
-
6. Open from stdin (`open -`), run `find`, add one comment, then `save --out` and `close`.
|
|
142
|
-
|
|
143
|
-
## Collaboration (Node-Only, Optional)
|
|
144
|
-
|
|
145
|
-
Use only when collaboration runtime is available in your environment.
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
superdoc open ./contract.docx --collaboration-json '{"providerType":"hocuspocus","url":"ws://localhost:1234","documentId":"contract-1","tokenEnv":"SUPERDOC_COLLAB_TOKEN"}' --output json
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Notes:
|
|
152
|
-
- Collaboration commands are command-scoped (connect -> sync -> operate -> disconnect).
|
|
153
|
-
- Python collaboration is not supported; expect `NOT_SUPPORTED`.
|
|
28
|
+
- Always open before operating, save when done
|
|
29
|
+
- Use `doc.find` to locate content before modifying
|
|
30
|
+
- Use `doc.info` to check document capabilities
|
|
31
|
+
- Handle errors gracefully — operations may fail if targets are invalid
|