@superdoc-dev/sdk 1.0.0-alpha.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/package.json +29 -0
- package/skills/.gitkeep +0 -0
- package/skills/editing-docx.md +113 -0
- package/src/generated/client.ts +857 -0
- package/src/generated/contract.ts +3467 -0
- package/src/index.ts +33 -0
- package/src/runtime/embedded-cli.ts +99 -0
- package/src/runtime/errors.ts +13 -0
- package/src/runtime/host.ts +463 -0
- package/src/runtime/process.ts +69 -0
- package/src/runtime/spawn.ts +190 -0
- package/src/runtime/transport-common.ts +134 -0
- package/src/skills.ts +76 -0
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@superdoc-dev/sdk",
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"module": "./src/index.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"src",
|
|
10
|
+
"skills"
|
|
11
|
+
],
|
|
12
|
+
"optionalDependencies": {
|
|
13
|
+
"@superdoc-dev/sdk-darwin-arm64": "1.0.0-alpha.1",
|
|
14
|
+
"@superdoc-dev/sdk-darwin-x64": "1.0.0-alpha.1",
|
|
15
|
+
"@superdoc-dev/sdk-linux-arm64": "1.0.0-alpha.1",
|
|
16
|
+
"@superdoc-dev/sdk-linux-x64": "1.0.0-alpha.1",
|
|
17
|
+
"@superdoc-dev/sdk-windows-x64": "1.0.0-alpha.1"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "22.19.2",
|
|
21
|
+
"typescript": "^5.9.2"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"typecheck": "tsc --noEmit"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/skills/.gitkeep
ADDED
|
File without changes
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: editing-docx
|
|
3
|
+
description: Session-first SuperDoc CLI workflows for querying and editing DOCX files (find, inspect, comment, replace, format, and close safely).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SuperDoc Playground Skill
|
|
7
|
+
|
|
8
|
+
Use this skill for manual DOCX exploration/editing in Codex CLI or Claude CLI.
|
|
9
|
+
|
|
10
|
+
## Interaction Rules (Must Follow)
|
|
11
|
+
|
|
12
|
+
1. Always run CLI commands in JSON mode: `--output json`.
|
|
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 close decision:
|
|
18
|
+
- `close --save --out ...`
|
|
19
|
+
- `close --save --in-place`
|
|
20
|
+
- `close --discard`
|
|
21
|
+
|
|
22
|
+
## CLI Invocation
|
|
23
|
+
|
|
24
|
+
Use `superdoc ...` commands.
|
|
25
|
+
|
|
26
|
+
If `superdoc` is not installed in this repo environment, use:
|
|
27
|
+
`bun apps/cli-alpha/src/index.ts ...`
|
|
28
|
+
|
|
29
|
+
## Canonical Session Workflow
|
|
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 info --output json
|
|
38
|
+
superdoc find --type text --pattern "termination" --output json
|
|
39
|
+
superdoc get-node --address-json '{"kind":"block","nodeType":"paragraph","nodeId":"p1"}' --output json
|
|
40
|
+
```
|
|
41
|
+
3. Mutate (using target JSON from `find` results):
|
|
42
|
+
```bash
|
|
43
|
+
superdoc comments add --target-json '{"kind":"text","blockId":"p1","range":{"start":10,"end":20}}' --text "Please clarify this clause." --output json
|
|
44
|
+
superdoc replace --target-json '{"kind":"text","blockId":"p1","range":{"start":10,"end":20}}' --text "Updated clause text" --dry-run --output json
|
|
45
|
+
superdoc replace --target-json '{"kind":"text","blockId":"p1","range":{"start":10,"end":20}}' --text "Updated clause text" --output json
|
|
46
|
+
```
|
|
47
|
+
4. Verify:
|
|
48
|
+
```bash
|
|
49
|
+
superdoc find --type text --pattern "Updated clause text" --output json
|
|
50
|
+
```
|
|
51
|
+
5. Close:
|
|
52
|
+
```bash
|
|
53
|
+
superdoc close --save --out ./contract.reviewed.docx --output json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Command Patterns (Session Mode)
|
|
57
|
+
|
|
58
|
+
### Session lifecycle
|
|
59
|
+
- `superdoc open <doc> [--session <id>] [--replace] --output json`
|
|
60
|
+
- `superdoc status [--session <id>] --output json`
|
|
61
|
+
- `superdoc session list --output json`
|
|
62
|
+
- `superdoc session use <id> --output json`
|
|
63
|
+
- `superdoc session set-default <id> --output json`
|
|
64
|
+
- `superdoc session close <id> --discard --output json`
|
|
65
|
+
- `superdoc close --save --in-place --output json`
|
|
66
|
+
- `superdoc close --save --out <path> --output json`
|
|
67
|
+
- `superdoc close --discard --output json`
|
|
68
|
+
|
|
69
|
+
### Query
|
|
70
|
+
- `superdoc info --output json`
|
|
71
|
+
- `superdoc find --type text --pattern "<text>" --output json`
|
|
72
|
+
- `superdoc find --query-json '{...}' --output json`
|
|
73
|
+
- `superdoc get-node --address-json '{...}' --output json`
|
|
74
|
+
- `superdoc get-node-by-id --id <nodeId> [--node-type <type>] --output json`
|
|
75
|
+
|
|
76
|
+
### Mutate
|
|
77
|
+
- `superdoc comments add --target-json '{...}' --text "..." --output json`
|
|
78
|
+
- `superdoc replace --target-json '{...}' --text "..." [--dry-run] --output json`
|
|
79
|
+
- `superdoc format bold --target-json '{...}' [--dry-run] --output json`
|
|
80
|
+
|
|
81
|
+
### Stateless fallback
|
|
82
|
+
If a command includes `<doc>` (or `--doc`), it runs statelessly for that call.
|
|
83
|
+
For stateless mutate commands, provide `--out <path>`.
|
|
84
|
+
|
|
85
|
+
## Target Selection Guidance
|
|
86
|
+
|
|
87
|
+
- Prefer `find --type text --pattern ...` first.
|
|
88
|
+
- Use `data.result.context[*].textRanges[*]` as `--target-json` for text edits/comments.
|
|
89
|
+
- When multiple matches exist, apply a deterministic policy:
|
|
90
|
+
- first match only, or
|
|
91
|
+
- first N matches, or
|
|
92
|
+
- user-selected match indexes.
|
|
93
|
+
- For uncertain targets, run `get-node` before mutate.
|
|
94
|
+
|
|
95
|
+
## Scenario Prompts (Copy/Paste)
|
|
96
|
+
|
|
97
|
+
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`.
|
|
98
|
+
2. Use the active session to find `governing law`, inspect the top match node, then add a concise legal-risk comment.
|
|
99
|
+
3. Open two sessions (`vendor-a`, `vendor-b`) on different docs, switch between them, and add one comment in each.
|
|
100
|
+
4. Run a redline pass replacing `shall` with `must` for the first 3 matches: dry-run first, then apply.
|
|
101
|
+
5. Open from stdin (`open -`), run `find`, add one comment, then close and save to a chosen output path.
|
|
102
|
+
|
|
103
|
+
## Collaboration (Node-Only, Optional)
|
|
104
|
+
|
|
105
|
+
Use only when collaboration runtime is available in your environment.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
superdoc open ./contract.docx --collaboration-json '{"providerType":"hocuspocus","url":"ws://localhost:1234","documentId":"contract-1","tokenEnv":"SUPERDOC_COLLAB_TOKEN"}' --output json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Notes:
|
|
112
|
+
- Collaboration commands are command-scoped (connect -> sync -> operate -> disconnect).
|
|
113
|
+
- Python collaboration is not supported; expect `NOT_SUPPORTED`.
|