@ansonlai/docx-redline-js 0.5.3 → 0.6.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.
Files changed (59) hide show
  1. package/AGENTS.md +82 -667
  2. package/ARCHITECTURE.md +51 -4
  3. package/CHANGELOG.md +11 -0
  4. package/README.md +176 -39
  5. package/core/paragraph-revision-safety.js +10 -8
  6. package/core/paragraph-targeting.js +14 -2
  7. package/core/redline-validation.js +7 -4
  8. package/core/revision-cloning.js +21 -0
  9. package/core/validation-delta.js +23 -0
  10. package/dist/docx-redline-js.esm.js +275 -45
  11. package/dist/docx-redline-js.esm.js.map +3 -3
  12. package/dist/docx-redline-js.esm.min.js +82 -82
  13. package/dist/docx-redline-js.esm.min.js.map +4 -4
  14. package/docs/AGENT_FAST_START.md +59 -0
  15. package/docs/AGENT_KNOWLEDGE_BASE.md +868 -0
  16. package/docs/TESTING.md +20 -1
  17. package/docs/schemas/document-operations.schema.json +16 -2
  18. package/docs/validation-reports/2026-09-12-agent-protocol-rollout.md +82 -0
  19. package/engine/oxml-engine.js +80 -13
  20. package/engine/run-builders.js +5 -15
  21. package/engine/surgical-mode.js +148 -3
  22. package/engine/surgical-run-splitting.js +19 -7
  23. package/engine/surgical-spans.js +2 -1
  24. package/index.d.ts +17 -1
  25. package/node/cli.js +235 -36
  26. package/node/docx-document.js +137 -83
  27. package/node/index.d.ts +6 -2
  28. package/package.json +10 -3
  29. package/pipeline/diff-engine.js +15 -0
  30. package/scripts/generate-cross-author-slicing-fixtures.ps1 +25 -25
  31. package/services/batch-operation-orchestrator.js +215 -120
  32. package/services/document-inspection.js +5 -3
  33. package/services/document-operation-applier.js +99 -36
  34. package/services/document-operation-contract.js +50 -6
  35. package/services/document-operation-mutations.js +404 -41
  36. package/services/document-operation-session.js +4 -0
  37. package/services/error-recovery.js +174 -0
  38. package/services/operation-batch-compiler.js +394 -0
  39. package/services/operation-preflight.js +91 -72
  40. package/services/standalone-operation-runner.d.ts +35 -1
  41. package/docs/plans/2026-09-05-structural-revisions-and-fidelity-oracles.md +0 -1669
  42. package/docs/plans/2026-09-08-cross-author-revision-slicing.md +0 -856
  43. package/docs/plans/completed/2026-03-01-release-0.1.4-design.md +0 -33
  44. package/docs/plans/completed/2026-03-01-release-0.1.4.md +0 -110
  45. package/docs/plans/completed/2026-05-31-architectural changes.md +0 -593
  46. package/docs/plans/completed/2026-08-02-reliability-improvements.md +0 -1155
  47. package/docs/plans/completed/2026-08-30-reliability-testing-improvements.md +0 -488
  48. package/docs/plans/completed/2026-09-01-performance-and-complexity-reduction.md +0 -669
  49. package/docs/plans/completed/2026-09-03-agent-friendly-document-workflows.md +0 -427
  50. package/docs/plans/completed/2026-09-04-comment-anchor-and-cli-reliability.md +0 -519
  51. package/docs/plans/completed/PERFORMANCE-CONSOLIDATION.md +0 -69
  52. package/docs/plans/completed/structural-revision-capability-matrix.md +0 -115
  53. package/docs/test-comparison-dashboard.html +0 -4338
  54. package/docs/validation-reports/2026-08-30-phase-1-word-visual-preflight.md +0 -22
  55. package/docs/validation-reports/2026-08-30-phase-2-word-visual-preflight.md +0 -24
  56. package/docs/validation-reports/2026-08-30-phase-3-coverage.md +0 -73
  57. package/docs/validation-reports/2026-09-02-multilevel-bullets-visual-review.md +0 -82
  58. package/docs/validation-reports/2026-09-02-multimodal-visual-samples.md +0 -114
  59. package/docs/validation-reports/2026-09-02-visual-failures-preflight.md +0 -79
@@ -0,0 +1,59 @@
1
+ # Agent Fast Start
2
+
3
+ Use this page for ordinary `.docx` edits. For source changes or unusual Word structures, follow the links at the end.
4
+
5
+ ## Structured agent tool
6
+
7
+ If your host provides a document-session wrapper:
8
+
9
+ 1. Inspect/search once with enough surrounding context to draft the change.
10
+ 2. Apply using the returned revision-bound target handle. Send either the
11
+ complete desired paragraph or exact replacements supported by that wrapper.
12
+ 3. Treat only `ok: true` as complete. A failed handle must be refreshed by
13
+ inspection; never reuse it against a changed document.
14
+
15
+ The repository's `examples/agent-session-wrapper.mjs` demonstrates this pattern.
16
+ It is a development sample, not a package API.
17
+
18
+ ## CLI fallback
19
+
20
+ 1. Extract only the relevant clause or range:
21
+
22
+ ```bash
23
+ docx-redline extract contract.docx --search "termination"
24
+ ```
25
+
26
+ 2. Copy `exactText` with `paragraphId` or `fingerprint`. Serialize the final
27
+ operation array directly to stdin, then apply once:
28
+
29
+ ```bash
30
+ node emit-operations.mjs | docx-redline apply contract.docx --operations - --profile agent --output reviewed.docx
31
+ ```
32
+
33
+ `emit-operations.mjs` should use `JSON.stringify`; do not interpolate legal
34
+ text through shell quoting. `modified` is the complete desired accepted-view
35
+ paragraph, not only the inserted words.
36
+
37
+ The `agent` profile is explicit and reproducible. It uses atomic rollback,
38
+ strict targets, validation, tracked changes, `merge-same-author`, and nonzero
39
+ exit codes for incomplete work. The result reports `effectiveOptions`.
40
+
41
+ ## Batch and result rules
42
+
43
+ - Strong inspected targets are bound to the batch-start document. Independent
44
+ edits do not need bottom-up sorting around earlier paragraph splits.
45
+ - Consolidate multiple desired texts for the same source paragraph. Follow an
46
+ explicit capture dependency for non-unique content created earlier in a batch.
47
+ - Require `completion: true`, `written: true`, a non-null `outputPath`, and no
48
+ per-operation error. The source is not overwritten unless `--in-place` is
49
+ explicit.
50
+ - On failure, follow `error.recovery.action`. Never retry unchanged arguments.
51
+ - `retryPlan.base: "original"` means correct and replay the complete batch.
52
+ `base: "output"` means keep committed progressive work and retry only the
53
+ reported failed or unattempted indexes.
54
+ - Never accept/reject revisions or remove comments without user authorization.
55
+ `slice-cross-author` is the history-preserving option for a surgical edit
56
+ inside another reviewer's pending insertion.
57
+
58
+ Advanced operations and recovery: [Agent Knowledge Base](AGENT_KNOWLEDGE_BASE.md); canonical contract: [document-operations.schema.json](schemas/document-operations.schema.json)
59
+ Wrapper design: [README](../README.md#example-agent-session-wrapper-development-only)