@ansonlai/docx-redline-js 0.5.4 → 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.
- package/AGENTS.md +78 -697
- package/ARCHITECTURE.md +13 -1
- package/CHANGELOG.md +5 -0
- package/README.md +140 -30
- package/core/paragraph-targeting.js +14 -2
- package/dist/docx-redline-js.esm.js +113 -33
- package/dist/docx-redline-js.esm.js.map +3 -3
- package/dist/docx-redline-js.esm.min.js +75 -75
- package/dist/docx-redline-js.esm.min.js.map +4 -4
- package/docs/AGENT_FAST_START.md +59 -0
- package/docs/AGENT_KNOWLEDGE_BASE.md +868 -0
- package/docs/TESTING.md +20 -1
- package/docs/schemas/document-operations.schema.json +5 -1
- package/docs/validation-reports/2026-09-12-agent-protocol-rollout.md +82 -0
- package/engine/oxml-engine.js +80 -13
- package/engine/run-builders.js +5 -15
- package/index.d.ts +17 -1
- package/node/cli.js +111 -27
- package/node/docx-document.js +120 -69
- package/node/index.d.ts +6 -2
- package/package.json +10 -3
- package/scripts/generate-cross-author-slicing-fixtures.ps1 +25 -25
- package/services/batch-operation-orchestrator.js +215 -120
- package/services/document-inspection.js +5 -3
- package/services/document-operation-applier.js +52 -34
- package/services/document-operation-contract.js +10 -6
- package/services/document-operation-mutations.js +51 -5
- package/services/document-operation-session.js +4 -0
- package/services/error-recovery.js +174 -0
- package/services/operation-batch-compiler.js +394 -0
- package/services/operation-preflight.js +91 -72
- package/services/standalone-operation-runner.d.ts +17 -1
- package/docs/plans/2026-09-05-structural-revisions-and-fidelity-oracles.md +0 -1669
- package/docs/plans/2026-09-08-cross-author-revision-slicing.md +0 -1399
- package/docs/plans/completed/2026-03-01-release-0.1.4-design.md +0 -33
- package/docs/plans/completed/2026-03-01-release-0.1.4.md +0 -110
- package/docs/plans/completed/2026-05-31-architectural changes.md +0 -593
- package/docs/plans/completed/2026-08-02-reliability-improvements.md +0 -1155
- package/docs/plans/completed/2026-08-30-reliability-testing-improvements.md +0 -488
- package/docs/plans/completed/2026-09-01-performance-and-complexity-reduction.md +0 -669
- package/docs/plans/completed/2026-09-03-agent-friendly-document-workflows.md +0 -427
- package/docs/plans/completed/2026-09-04-comment-anchor-and-cli-reliability.md +0 -519
- package/docs/plans/completed/PERFORMANCE-CONSOLIDATION.md +0 -69
- package/docs/plans/completed/structural-revision-capability-matrix.md +0 -115
- package/docs/test-comparison-dashboard.html +0 -4338
- package/docs/validation-reports/2026-08-30-phase-1-word-visual-preflight.md +0 -22
- package/docs/validation-reports/2026-08-30-phase-2-word-visual-preflight.md +0 -24
- package/docs/validation-reports/2026-08-30-phase-3-coverage.md +0 -73
- package/docs/validation-reports/2026-09-02-multilevel-bullets-visual-review.md +0 -82
- package/docs/validation-reports/2026-09-02-multimodal-visual-samples.md +0 -114
- package/docs/validation-reports/2026-09-02-visual-failures-preflight.md +0 -79
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Structural Revision Capability Matrix
|
|
2
|
-
|
|
3
|
-
**Date:** 2026-09-05
|
|
4
|
-
**Baseline Version:** v0.4.0
|
|
5
|
-
**Companion Plan:** [2026-09-05-structural-revisions-and-fidelity-oracles.md](./2026-09-05-structural-revisions-and-fidelity-oracles.md)
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 1. Executive Summary
|
|
10
|
-
|
|
11
|
-
This document establishes the required capability and gap baseline for `@ansonlai/docx-redline-js` prior to implementing new mutation semantics in the v0.5.0–v1.0.0 series.
|
|
12
|
-
|
|
13
|
-
Each row corresponds to an architectural behavior cataloged in Section 2 of the companion plan. Per Section 18 (WP-00), a capability is marked:
|
|
14
|
-
- `implemented`: generation, validation, Accept All, and Reject All are all verified by passing regression tests.
|
|
15
|
-
- `partial`: implemented only for specific sub-cases (e.g. lists, whole paragraphs) or missing specific lifecycle guarantees/metadata.
|
|
16
|
-
- `missing`: no production implementation exists.
|
|
17
|
-
- `intentionally unsupported`: explicitly refused by design with structured diagnostics.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 2. Capability & Gap Matrix
|
|
22
|
-
|
|
23
|
-
| Capability Category | Behavior / Sub-Case | Status | Production Symbol(s) | Existing Regression Test(s) | Missing Case / Gap | Work Package |
|
|
24
|
-
|---|---|---|---|---|---|---|
|
|
25
|
-
| **Text Mutations** | Text insertion (`w:ins`) | `implemented` | `processInsert` in `engine/surgical-diff-application.js`, `createTrackChange` in `engine/run-builders.js` | `tests/diff_engine_reliability_tests.mjs`, `tests/standalone_smoke.mjs` | None for basic insertion | Complete |
|
|
26
|
-
| **Text Mutations** | Text deletion (`w:del`) | `implemented` | `processDelete` in `engine/surgical-diff-application.js`, `createTrackChange` in `engine/run-builders.js` | `tests/diff_engine_reliability_tests.mjs`, `tests/standalone_smoke.mjs` | None for basic deletion | Complete |
|
|
27
|
-
| **Text Mutations** | Paired text replacement (`w:del` + `w:ins`) | `partial` | `processDelete` + `processInsert` in `engine/surgical-diff-application.js` | `tests/standalone_smoke.mjs`, `tests/redline_validation_tests.mjs` | Replacement events currently allocate revision IDs and timestamps independently without paired metadata synchronization required for Word unified review balloons; structural boundary preservation rules not formal. | WP-07 |
|
|
28
|
-
| **Text Mutations** | Insertion container boundary affinity | `partial` | `processInsert` in `engine/surgical-diff-application.js`, `surgical-spans.js` | `tests/structural_tab_field_tests.mjs` | No explicit `InsertionAffinity` contract; run splitting at hyperlink/bookmark/comment boundaries relies on implicit order without `inside` vs `outside` control. | WP-08 |
|
|
29
|
-
| **Paragraph Boundaries** | Paragraph-mark insertion / split | `partial` | `markParagraphMarkInserted` in `engine/run-builders.js`, `applyReconstructionMode` in `engine/reconstruction-mode.js` | `tests/paragraph_mark_revision_tests.mjs` | Text splits spanning newlines fall back to destructive reconstruction mode, dropping paragraph properties (`w:spacing`, `w:ind`, `w:pStyle`) and bookmarks. | WP-09, WP-10 |
|
|
30
|
-
| **Paragraph Boundaries** | Paragraph boundary removal (join) | `partial` | `markParagraphMarkDeleted` in `engine/run-builders.js`, `mergeParagraphIntoNextAndRemove` in `services/revision-comment-management.js` | `tests/paragraph_mark_revision_tests.mjs` | Joins retaining both texts fall back to block reconstruction; native pilcrow deletion join algorithm not wired to surgical diff application. | WP-09, WP-10 |
|
|
31
|
-
| **Paragraph Boundaries** | Whole paragraph deletion | `implemented` | `markParagraphMarkDeleted`, `processDelete` in `engine/surgical-diff-application.js`, `services/document-operation-mutations.js` | `tests/paragraph_mark_revision_tests.mjs`, `tests/interagency_agreement_multi_author_tests.mjs` | None for whole paragraph deletion | Complete |
|
|
32
|
-
| **Property Revisions** | Run property revisions (`w:rPrChange`) | `partial` | `injectFormattingToRPr`, `snapshotAndAttachRPrChange` in `engine/run-builders.js`, `rejectPropertyChangeNode` in `services/revision-comment-management.js` | `tests/formatting_tests.mjs`, `tests/revision_comment_management_tests.mjs` | Gated behind Markdown formatting hints rather than explicit `CharacterFormatOperation`; author-aware coalescing (editing own pending insertion) missing. | WP-11 |
|
|
33
|
-
| **Property Revisions** | Paragraph property revisions (`w:pPrChange`) | `partial` | `rejectPropertyChangeNode`, `acceptTrackedChangesInOoxml` in `services/revision-comment-management.js` | `tests/revision_comment_management_tests.mjs` | Supported during Accept/Reject lifecycle, but no public operation exists to author a `w:pPrChange` in surgical mode. | WP-11 |
|
|
34
|
-
| **Structural Elements** | Hyperlinks (`w:hyperlink`) | `implemented` | `readCanonicalRunText` in `core/paragraph-text.js`, `surgical-spans.js` | `tests/structural_tab_field_tests.mjs` | Boundary affinity (`inside` vs `outside` link) when prepending/appending text. | WP-08 |
|
|
35
|
-
| **Structural Elements** | Bookmarks (`w:bookmarkStart`, `w:bookmarkEnd`) | `implemented` | `surgical-spans.js`, `core/word-xml.js` | `tests/structural_tab_field_tests.mjs`, `tests/docx_fixture_tests.mjs` | Range markers preserved during edits; boundary positioning needs explicit tests. | WP-08 |
|
|
36
|
-
| **Structural Elements** | Comments (`word/comments.xml` & markers) | `implemented` | `injectCommentsIntoOoxml` in `services/comment-engine.js`, `deleteCommentsByAuthorInOoxml` in `services/revision-comment-management.js` | `tests/comment_tests.mjs`, `tests/comment_anchor_locator_tests.mjs` | Targeting deleted text in `rejected` view for comment placement is currently unsupported. | WP-05, WP-06 |
|
|
37
|
-
| **Structural Elements** | Fields (`w:fldSimple`, `w:fldChar`) | `implemented` | `appendVisibleTextPieces` in `engine/run-builders.js`, `surgical-spans.js` | `tests/structural_tab_field_tests.mjs` | Splitting inside complex field instruction blocks is intentionally unsupported. | Intentionally Unsupported |
|
|
38
|
-
| **Structural Elements** | Structured Document Tags (`w:sdt`) | `implemented` | `core/word-xml.js`, `core/paragraph-targeting.js` | `tests/docx_fixture_tests.mjs` | SDTs survive as containers; container boundary affinity needs explicit tests. | WP-08 |
|
|
39
|
-
| **Structural Elements** | Tabs, breaks, hyphens (`w:tab`, `w:br`, `w:cr`, `w:noBreakHyphen`) | `implemented` | `appendVisibleTextPieces` in `engine/run-builders.js`, `cloneRunPiece` in `engine/surgical-run-splitting.js`, `readCanonicalRunText` in `core/paragraph-text.js` | `tests/structural_tab_field_tests.mjs`, `tests/canonical_paragraph_text_tests.mjs` | None | Complete |
|
|
40
|
-
| **Structural Elements** | Footnotes & Endnotes (`w:footnoteReference`) | `implemented` | `core/word-xml.js`, `surgical-spans.js` | `tests/docx_fixture_tests.mjs` | Footnote reference markers preserved during adjacent text edits. | Complete |
|
|
41
|
-
| **Lists & Tables** | List generation from markdown | `implemented` | `executeListGeneration` in `pipeline/list-generation.js`, `numbering-service.js` | `tests/list_tests.mjs`, `tests/list_replacement_structure_tests.mjs` | None | Complete |
|
|
42
|
-
| **Lists & Tables** | Markdown table reconciliation | `implemented` | `reconcileMarkdownTableOoxml`, `generateTableOoxml` in `services/table-reconciliation.js` | `tests/table_tests.mjs`, `tests/table_targeting_and_format_flags.mjs` | None | Complete |
|
|
43
|
-
| **Lists & Tables** | Structured content planning | `implemented` | `analyzeStructuredContent`, `planStructuredReplacement` in `pipeline/structured-content.js` | `tests/structured_content_planner_tests.mjs` | None | Complete |
|
|
44
|
-
| **Text Extraction** | Accepted text extraction | `implemented` | `extractCanonicalParagraphText`, `readCanonicalRunText` in `core/paragraph-text.js` | `tests/canonical_paragraph_text_tests.mjs` | None | Complete |
|
|
45
|
-
| **Text Extraction** | Rejected text extraction | `implemented` | `extractCanonicalParagraphText(p, { revisionView: 'rejected' })` in `core/paragraph-text.js` | `tests/canonical_paragraph_text_tests.mjs` | Detailed segment breakdown (`RevisionTextSegment[]`) with offsets and kinds missing. | WP-04 |
|
|
46
|
-
| **Target Resolution** | Accepted-view targeting | `implemented` | `resolveTargetParagraph`, `buildParagraphMetadataIndex` in `core/paragraph-targeting.js` | `tests/standalone_operation_runner_tests.mjs`, `tests/error_contract_tests.mjs` | None | Complete |
|
|
47
|
-
| **Target Resolution** | Rejected-view targeting | `missing` | None | None | `revisionView: 'rejected'` not supported in `core/paragraph-targeting.js` or `services/operation-preflight.js`. | WP-05 |
|
|
48
|
-
| **Target Resolution** | Fail-closed strict targeting | `implemented` (preflight & node facade) / `partial` (runner default) | `preflightOperations` in `services/operation-preflight.js`, `DocxDocument` in `node/docx-document.js` | `tests/agent_operation_contract_tests.mjs`, `tests/agent_cli_tests.mjs` | Lower-level runner currently defaults to permissive matching; strict mode must become default in v1.0.0. | WP-18 |
|
|
49
|
-
| **Session & Batch** | Live DOM session & savepoints | `implemented` | `DocumentOperationSession` in `services/document-operation-session.js` | `tests/performance_phase1_session_tests.mjs` | Capture table state not yet part of savepoint tracking. | WP-15 |
|
|
50
|
-
| **Session & Batch** | Stepwise capture chaining | `missing` | None | None | Batches cannot target entities produced by earlier steps within the same batch. | WP-14, WP-15 |
|
|
51
|
-
| **Session & Batch** | Optimistic concurrency tokens | `missing` | None | None | No `expectedRevision` precondition assertion on document/package state. | WP-12, WP-13 |
|
|
52
|
-
| **Session & Batch** | Structured mutation receipts | `missing` | None | None | Results return high-level boolean `hasChanges` but do not report allocated `w:id` revision or comment telemetry. | WP-16, WP-17 |
|
|
53
|
-
| **Package Plumbing** | Package artifact merging (comments, numbering) | `implemented` | `ensureCommentsArtifactsInZip`, `ensureNumberingArtifactsInZip` in `services/standalone-docx-plumbing.js` | `tests/docx_package_transaction_edge_tests.mjs`, `tests/docx_package_facade_tests.mjs` | None | Complete |
|
|
54
|
-
| **Package Plumbing** | Package entry byte-fidelity verification | `missing` | None | None | No automated oracle verifying bitwise invariance of non-targeted ZIP entries. | WP-01, WP-03 |
|
|
55
|
-
| **Package Plumbing** | Canonical subtree XML fidelity verification | `missing` | None | None | No automated oracle verifying canonical invariance of non-targeted `<w:p>` subtrees. | WP-02, WP-03 |
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## 3. Canonical Serialized Output for Partial Areas
|
|
60
|
-
|
|
61
|
-
### 3.1 Paired Text Replacement (Current Output)
|
|
62
|
-
Currently, replacement operations emit independent `<w:del>` and `<w:ins>` elements with separate revision IDs and independent timestamps:
|
|
63
|
-
|
|
64
|
-
```xml
|
|
65
|
-
<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
66
|
-
<w:r><w:t>The term shall be </w:t></w:r>
|
|
67
|
-
<w:del w:id="1" w:author="Reviewer" w:date="2026-09-05T12:00:00Z">
|
|
68
|
-
<w:r><w:delText xml:space="preserve">thirty (30) days</w:delText></w:r>
|
|
69
|
-
</w:del>
|
|
70
|
-
<w:ins w:id="2" w:author="Reviewer" w:date="2026-09-05T12:00:00Z">
|
|
71
|
-
<w:r><w:t xml:space="preserve">sixty (60) days</w:t></w:r>
|
|
72
|
-
</w:ins>
|
|
73
|
-
<w:r><w:t> from receipt.</w:t></w:r>
|
|
74
|
-
</w:p>
|
|
75
|
-
```
|
|
76
|
-
*Gap:* WP-07 will guarantee unified event-level metadata synchronization, zero-length run removal, and structural container boundaries.
|
|
77
|
-
|
|
78
|
-
### 3.2 Paragraph Boundary Split / Join (Current Output)
|
|
79
|
-
Currently, paragraph splits and joins trigger block reconstruction in `engine/reconstruction-mode.js`, which discards original paragraph properties and IDs:
|
|
80
|
-
|
|
81
|
-
```xml
|
|
82
|
-
<!-- Reconstruction generates fresh paragraphs, losing original w14:paraId and custom styles -->
|
|
83
|
-
<w:p w14:paraId="NEW_01">
|
|
84
|
-
<w:pPr><w:rPr><w:ins w:id="3" w:author="Reviewer" w:date="..."/></w:rPr></w:pPr>
|
|
85
|
-
<w:r><w:t>Split second paragraph content.</w:t></w:r>
|
|
86
|
-
</w:p>
|
|
87
|
-
```
|
|
88
|
-
*Gap:* WP-09/WP-10 will preserve original paragraph nodes, transferring trailing runs and marking paragraph-mark revisions natively.
|
|
89
|
-
|
|
90
|
-
### 3.3 Run Property Changes (Current Output)
|
|
91
|
-
Currently, `injectFormattingToRPr` creates `<w:rPrChange>`:
|
|
92
|
-
|
|
93
|
-
```xml
|
|
94
|
-
<w:r>
|
|
95
|
-
<w:rPr>
|
|
96
|
-
<w:b w:val="1"/>
|
|
97
|
-
<w:rPrChange w:id="4" w:author="Reviewer" w:date="2026-09-05T12:00:00Z">
|
|
98
|
-
<w:rPr>
|
|
99
|
-
<w:b w:val="0"/>
|
|
100
|
-
</w:rPr>
|
|
101
|
-
</w:rPrChange>
|
|
102
|
-
</w:rPr>
|
|
103
|
-
<w:t>Indemnified Parties</w:t>
|
|
104
|
-
</w:r>
|
|
105
|
-
```
|
|
106
|
-
*Gap:* WP-11 will expose this via explicit `CharacterFormatOperation` and `ParagraphFormatOperation`, with author-aware coalescing.
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## 4. Audit Sign-Off
|
|
111
|
-
|
|
112
|
-
- **Baseline Tests Verified:** All 67 regression test suites pass (`npm test` $\rightarrow$ 67 passed, 0 failed).
|
|
113
|
-
- **Isolation Checks Verified:** `npm run test:isolation` passes.
|
|
114
|
-
- **Type Declarations Verified:** `npm run check:types` passes (108 runtime exports).
|
|
115
|
-
- **Audit Gate:** Every gap identified above maps directly to WP-01 through WP-18 in the companion plan.
|