@ansonlai/docx-redline-js 0.7.1 → 0.8.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/AGENTS.md +38 -49
- package/ARCHITECTURE.md +30 -10
- package/CHANGELOG.md +63 -3
- package/README.md +35 -23
- package/adapters/xml-adapter.js +84 -56
- package/core/sha256.js +120 -0
- package/dist/docx-redline-js.esm.js +7969 -600
- package/dist/docx-redline-js.esm.js.map +4 -4
- package/dist/docx-redline-js.esm.min.js +115 -102
- package/dist/docx-redline-js.esm.min.js.map +4 -4
- package/dist/docx-redline.bundle.cjs +27385 -0
- package/dist/docx-redline.bundle.cjs.map +7 -0
- package/dist/docx-redline.bundle.js +27376 -0
- package/dist/docx-redline.bundle.js.map +7 -0
- package/docs/AGENT_FAST_START.md +32 -34
- package/docs/AGENT_KNOWLEDGE_BASE.md +408 -380
- package/docs/SKILL_AUTHORING.md +85 -101
- package/docs/TESTING.md +2 -1
- package/docs/validation-reports/2026-09-14-agent-surface-simplification.md +75 -0
- package/document/docx-document.d.ts +39 -0
- package/document/docx-document.js +616 -0
- package/document/zip-archive.js +258 -0
- package/index.d.ts +45 -1
- package/index.js +8 -0
- package/node/cli-help.js +1 -1
- package/node/cli.js +12 -4
- package/node/docx-document.js +11 -355
- package/node/zip-archive.js +28 -38
- package/package.json +16 -11
- package/scripts/build.mjs +40 -5
- package/services/localized-replacement-compiler.js +73 -7
- package/services/revision-token.js +11 -7
- package/services/standalone-operation-runner.d.ts +1 -0
package/docs/AGENT_FAST_START.md
CHANGED
|
@@ -1,58 +1,56 @@
|
|
|
1
1
|
# Agent Fast Start
|
|
2
2
|
|
|
3
|
-
Use this page for ordinary `.docx` edits. For
|
|
3
|
+
Use this page for ordinary `.docx` edits. For unusual Word structures or optional shortcuts, follow the links at the end.
|
|
4
4
|
|
|
5
5
|
## Structured agent tool
|
|
6
6
|
|
|
7
|
-
If
|
|
7
|
+
If the host provides a document-session wrapper (or directly calls `openDocx` from `@ansonlai/docx-redline-js` with `Uint8Array` binary payloads):
|
|
8
8
|
|
|
9
|
-
1. Inspect
|
|
10
|
-
2. Apply with the revision-bound handle
|
|
11
|
-
3.
|
|
9
|
+
1. Inspect once with enough surrounding context to draft the change.
|
|
10
|
+
2. Apply once with the returned revision-bound handle.
|
|
11
|
+
3. Accept only the wrapper's complete-success result; refresh failed handles.
|
|
12
12
|
|
|
13
|
-
The
|
|
14
|
-
|
|
13
|
+
The universal `DocxDocument` and `openDocx` facade operates natively on `Uint8Array` across Node, browsers, edge workers, and sandboxes without requiring Node built-ins.
|
|
14
|
+
The repository's `examples/agent-session-wrapper.mjs` is a development sample, not a package API.
|
|
15
15
|
|
|
16
|
-
## CLI
|
|
16
|
+
## CLI workflow
|
|
17
17
|
|
|
18
|
-
1.
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
docx-redline apply contract.docx --find "thirty (30) days" --replace "sixty (60) days" --profile agent --output reviewed.docx
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
The source must occur in one eligible paragraph. To narrow it, use a longer, fairly unique phrase: `--search "distinctive nearby heading or phrase" --context-range 1:3`.
|
|
25
|
-
Generic/repeated anchors can cause `AMBIGUOUS_TARGET` and waste a recovery turn. If `anchorMatchCount > 1`, confirm the returned location and excerpts. `--around 3` is symmetric.
|
|
26
|
-
|
|
27
|
-
2. For semantic drafting such as “make this provision mutual,” extract enough
|
|
28
|
-
context, then copy `exactText` with `paragraphId` or `fingerprint`:
|
|
18
|
+
1. Extract the relevant clause or range:
|
|
29
19
|
|
|
30
20
|
```bash
|
|
31
21
|
docx-redline extract contract.docx --search "termination" --around 3
|
|
32
22
|
```
|
|
33
23
|
|
|
34
|
-
Search is case-insensitive
|
|
24
|
+
Search is case-insensitive. Follow `selection.nextAfter` when truncated. Preserve `selection`, `humanReference`, target descriptors, and revision cues when reshaping output. Report `humanReference`, not a machine paragraph number.
|
|
25
|
+
|
|
26
|
+
2. Retain inspected `exactText` for drafting and target with its `paragraphId` plus `fingerprint`, then apply once with a UTF-8 operations file or serializer-backed stdin:
|
|
35
27
|
|
|
36
28
|
```bash
|
|
37
29
|
node emit-operations.mjs | docx-redline apply contract.docx --operations - --profile agent --compact --output reviewed.docx
|
|
38
30
|
```
|
|
39
31
|
|
|
40
|
-
Use `
|
|
32
|
+
Use complete `modified` text for a broad semantic revision. For a small literal change in that inspected target, use
|
|
33
|
+
`replacements: [{ "find": "old text", "replace": "new text" }]` instead.
|
|
34
|
+
Use `JSON.stringify`; never interpolate document text through shell quoting. Preserve intentionally relative wording unless the user asks for a concrete value.
|
|
35
|
+
|
|
36
|
+
## Restore branch
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
If the user requests deleted text, search with `--view rejected` first. Otherwise follow `selection.hint` only when it identifies an alternate revision view. Restore the inspected strong target; do not infer adjacent content. Run `docx-redline apply --help` for canonical restore shapes.
|
|
43
39
|
|
|
44
|
-
##
|
|
40
|
+
## Completion and recovery
|
|
45
41
|
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
|
|
42
|
+
- Require `completion: true` and a non-null `outputPath`; the CLI computes this from write, operation, commit, and localized-verification results.
|
|
43
|
+
- On failure, follow `error.recovery.action`; never retry unchanged arguments.
|
|
44
|
+
- Use `retryPlan.base: "original"` to replay a batch and `"output"` to retain
|
|
45
|
+
committed progressive work and retry the reported indexes.
|
|
46
|
+
- The source is not overwritten unless `--in-place` is explicit.
|
|
47
|
+
- Never accept/reject revisions or remove comments without authorization.
|
|
48
|
+
- Add `--atomic` or a non-default revision policy only when deliberately needed;
|
|
49
|
+
confirm `effectiveOptions`.
|
|
50
|
+
- Strong inspected targets bind to batch start. Consolidate writes to one source
|
|
51
|
+
and use captures only for intentional created-content dependencies.
|
|
56
52
|
|
|
57
|
-
Advanced
|
|
53
|
+
Advanced speculative apply, directional scoping, operation constraints, and
|
|
54
|
+
recovery: [Agent Knowledge Base](AGENT_KNOWLEDGE_BASE.md). Canonical schema:
|
|
55
|
+
[document-operations.schema.json](schemas/document-operations.schema.json).
|
|
58
56
|
Wrapper design: [README](../README.md#example-agent-session-wrapper-development-only)
|