@ansonlai/docx-redline-js 0.8.3 → 0.8.4

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/CHANGELOG.md CHANGED
@@ -1,586 +1,627 @@
1
- # Changelog
2
-
3
- ## 0.8.3
4
-
5
- ### Fixed
6
-
7
- - **Reject All no longer leaves an empty paragraph after an inserted paragraph:** `modified: "<original>\n<new>"` on a plain
8
- paragraph did not track the new paragraph's mark as inserted. It now does.
9
- - **Reject All no longer merges source paragraphs after a list range replacement:** replacing a multi-paragraph list range
10
- (`target` + `targetEnd`) collapsed the sources into one deleted paragraph, so Reject All gave results such as
11
- `Bullet Root ABullet Insertion Anchor`, `AlphaGamma` for an empty middle paragraph, and lost both paragraphs of an
12
- all-empty range. Each source paragraph, empty ones included, now keeps its own tracked-deleted paragraph. Confirmed in Word.
13
- - **Inspection no longer reports historical paragraph properties as current:** `list`, `styleId` and `headingLevel` (and list
14
- targeting) could read `numPr`, `pStyle` or `outlineLvl` stored under `w:pPrChange`. Only the paragraph's direct `w:pPr`
15
- is read now.
16
- - **`openDocx` list range replacement no longer renumbers or re-points lists:** deleted source paragraphs were remapped to a
17
- new generic `numId` (Reject All restored them with the wrong list type), new items started a separate list (untouched
18
- following items restarted at 1), and unused numbering definitions were added. Deleted source paragraphs now keep their
19
- `numPr`, and a same-kind replacement reuses the source `numId`, leaving `numbering.xml` unchanged. Reuse applies when the
20
- range uses one `numId` and the generated level formats match; format-changing edits still allocate new definitions, and
21
- definitions created earlier in the same batch are not reused. Confirmed in Word.
22
- - **Explicit list start values are applied:** generated list fragments without `xmlns:w` failed to parse in
23
- `orchestration/list-structural-fallback.js`, so `7. Header` lost its `startOverride` and xmldom logged parse warnings.
24
-
25
- ### Tests
26
-
27
- - New `tests/list_reject_fidelity_tests.mjs` and `tests/facade_list_numbering_tests.mjs`, with the Word-authored fixture
28
- `tests/fixtures/agentic-lists/nested-lists-source.docx`; extended inspection and list structural fallback suites.
29
-
30
- ### Known limitations
31
-
32
- - Plain paragraph to list conversion and list format changes are not yet supported canonically; see
33
- `docs/plans/2026-09-30-canonical-list-operations.md`.
34
- - `1. Header` to `1. Header` on a bare `document.xml` (not a packaged `.docx`) can fail with `RECEIPT_RECONCILIATION_FAILED`.
35
-
36
- ## 0.8.2
37
-
38
- ### Fixed
39
-
40
- - **Replacement next to a hyperlink no longer pulls adjacent plain text into the link** ([#3](https://github.com/AnsonLai/docx-redline-js/issues/3)):
41
- replacing `example.org` with `example.net` (localized `replacements` or full `modified`) in a hyperlink followed by a
42
- plain `.` run produced a link showing `example.net.` after Accept All. The reconstruction-mode word diff treated
43
- `example.org.` as one token spanning the hyperlink edge. Where a replacement's shared prefix or suffix reaches a wrapper
44
- boundary inside the deleted text, it is now kept unchanged.
45
- - **Reject All no longer reorders text around a manual line break** ([#4](https://github.com/AnsonLai/docx-redline-js/issues/4)):
46
- replacing `tabbed` with `aligned` in `<tab>tabbed<w:br/>Line with ` rejected to `<tab>tabbedLine<break> with `, moving
47
- deleted text across the break. Break and note-reference placeholders are now standalone word-diff tokens (new internal
48
- `atomicChars` option), and change groups are split at references present on both sides. Covered by `tests/reconstruction_boundary_fidelity_tests.mjs`.
49
-
50
- ## 0.8.1
51
-
52
- ### Added
53
-
54
- - **Header and footer editing:** add `part` to an operation (a selector `{ kind, type?, section? }` or a part path) to edit a
55
- header or footer; `inspect().headersFooters` lists the parts with their text, the sections they apply to (including
56
- inherited ones) and whether they contain fields. Body edits are unchanged and headers/footers are opt-in. Fields such as
57
- PAGE are atomic (`FIELD_EDIT_REFUSED`), comments are refused (`COMMENT_IN_HEADER_FOOTER`), bad selectors fail closed
58
- (`PART_NOT_FOUND`, `PART_AMBIGUOUS`), atomic batches roll back across body and parts, revision ids stay unique across the
59
- package, receipts name the part, `accept`/`reject` also resolve revisions inside headers and footers, and
60
- `validateDocxPackage` checks header/footer references, relationships and content types.
61
- - **Resolve and reopen comment threads:** `doc.resolveComment(id, { resolved })` and the batch operation
62
- `{ "type": "comment_resolve", "commentId": "0", "resolved": true }`, so the CLI can resolve through `apply --operations`.
63
- Word resolves whole threads, so the root and every reply change together, whichever id is given. Only
64
- `word/commentsExtended.xml` changes; `document.xml` stays byte-identical. Unknown ids fail with `COMMENT_NOT_FOUND`
65
- (also in `preflight`).
66
- - **Delete comments by id:** `doc.deleteComments({ ids })` and `docx-redline delete-comments --comment-id 3,4`. Deleting a
67
- thread root also deletes its replies; unknown ids fail closed with `COMMENT_NOT_FOUND`.
68
- - CLI capabilities `comment-resolve-operation-v1`, `delete-comments-by-id-v1` and `header-footer-parts-v1` (additive; the
69
- contract version is unchanged).
70
- - `services/package-parts.js`, a registry of package part paths, content types and relationship types checked against
71
- Word-saved fixtures (`tests/fixtures/word-authored/`), and `npm run test:word:package`, which opens generated outputs in
72
- real Word with repair disabled and checks comment counts, thread parents, resolved state and header/footer revisions
73
- through Word's object model.
74
-
75
- ### Fixed
76
-
77
- - **Word "unreadable content" prompt on commented documents:** `word/commentsExtended.xml` was relabeled
78
- `application/vnd.ms-word.commentsExtended+xml` on every save of any document that already had comments.
79
- Word expects `application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml` and
80
- offered to repair the file. The constant is corrected, an edit that does not change comment threading no
81
- longer rewrites the extended part or its content type/relationship, and files already damaged by earlier
82
- versions are repaired on the next save (`repairKnownContentTypes`, also exported). `validateDocxPackage`
83
- now rejects the wrong type instead of accepting it. `tests/package_content_type_contract_tests.mjs` checks this
84
- against a Word-authored content-type table on every OS.
85
- - **Comment threads keyed on the last paragraph:** Word joins `comments.xml` to `commentsExtended.xml` and
86
- `commentsIds.xml` through the `w14:paraId` of a comment's LAST paragraph. Inspection, package validation,
87
- replies and delete-cascade used the first, so Word's own multi-paragraph threaded documents failed
88
- validation and replies to them attached to the wrong key.
89
- - **Edits no longer drop comment anchors:** a mid-paragraph edit of a commented paragraph dropped the trailing
90
- `commentRangeEnd` and `commentReference` (markers at the very end of the paragraph text were only emitted when the
91
- last diff part was an insert), leaving the comment unanchored and failing package validation. Found by
92
- opening our output in real Word; covered by `tests/comment_marker_preservation_tests.mjs`.
93
- - **Replies are now visible in Word:** `comment_reply` only wrote `comments.xml`/`commentsExtended.xml`, and Word
94
- does not show a reply that has no body markers. Replies now get their own `commentRangeStart`/`commentRangeEnd`/
95
- `commentReference` next to the thread's, laid out like Word writes them. A reply to a reply joins the root thread.
96
- A parent with no body anchor fails with `PARENT_ANCHOR_NOT_FOUND`.
97
- - **Replies to a resolved thread are resolved too**, as Word writes them (`reply-to-resolved.docx` fixture). They were
98
- written open, leaving a thread that was half resolved.
99
- - `commentsIds.xml` and `commentsExtensible.xml` are kept consistent with `comments.xml` on add/delete when present.
100
- - `deleteComments` and `resolveRevisions` report `artifactsChanged` from a real diff of the package (they listed a fixed
101
- set of parts and missed `commentsIds.xml`, `commentsExtensible.xml` and `[Content_Types].xml`).
102
-
103
- ## 0.8.0
104
-
105
- ### Universal Document Facade & Zero-Node Architecture
106
-
107
- - **Universal `DocxDocument` & `openDocx`:** Implemented complete-DOCX lifecycle operations
108
- (`openDocx`, `doc.inspect()`, `doc.applyOperations()`, `doc.resolveRevisions()`, `doc.deleteComments()`,
109
- `doc.toUint8Array()`, `doc.getRevisionToken()`) on standard `Uint8Array` in `document/docx-document.js`,
110
- re-exported directly from `index.js`. Enables complete-document redline workflows in any JavaScript
111
- runtime without Node.js dependencies.
112
- - **Pure-JS ZIP container (`fflate`):** Replaced `node:zlib` with lightweight, zero-dependency `fflate`
113
- in `document/zip-archive.js`, providing cross-runtime raw DEFLATE / INFLATE compression and decompression
114
- with full OOXML archive compatibility.
115
- - **Pure-JS FIPS 180-4 SHA-256:** Created zero-dependency, synchronous SHA-256 implementation in
116
- `core/sha256.js`, removing `node:crypto` from package revision token calculations while retaining
117
- exact deterministic hash parity with standard NIST vectors.
118
- - **Transparent XML DOM fallback:** Added `resolveDomParserConstructor()` and
119
- `resolveXmlSerializerConstructor()` in `adapters/xml-adapter.js`, automatically utilizing native
120
- `globalThis.DOMParser`/`globalThis.XMLSerializer` when present and falling back transparently to
121
- `@xmldom/xmldom` in headless, server, edge, and sandbox environments without requiring manual provider setup.
122
- - **Zero-dependency sandbox bundles:** Configured `scripts/build.mjs` with `esbuild` (`platform: 'neutral'`)
123
- to produce single-file, zero-dependency standalone bundles in both ESM (`dist/docx-redline.bundle.js`)
124
- and CommonJS (`dist/docx-redline.bundle.cjs`), exported as `@ansonlai/docx-redline-js/bundle` for direct
125
- use in workflow engines (e.g., n8n Code nodes), Cloudflare Workers, AWS Lambda, Deno, and QuickJS sandboxes.
126
- - **Strict runtime boundary enforcement:** Removed `node:zlib` and `node:crypto` from allowed external
127
- imports in `tests/no_word_api_index_check.mjs`. Automated sandbox isolation tests
128
- (`tests/sandbox_bundle_isolation_tests.mjs`) verify zero Node built-in imports and full document
129
- reconciliation in restricted VM contexts without `process`, `Buffer`, or `require`.
130
- - **Backward compatibility:** Preserved full API and `Buffer` compatibility for `@ansonlai/docx-redline-js/node`
131
- consumers and `doc.toBuffer()`.
132
-
133
- ## 0.7.2
134
-
135
- ### Agent Surface Simplification
136
-
137
- - **Extraction-first golden path:** Re-established the single deterministic two-turn
138
- "extract-then-apply" sequence as the default agent workflow across `AGENTS.md`,
139
- `docs/AGENT_FAST_START.md`, and `docs/SKILL_AUTHORING.md`. Eliminates the
140
- upfront "choice tax" and model deliberation overhead.
141
- - **Localized replacements after inspection:** Decoupled localized patching from
142
- speculation. Agents inspect the target paragraph first, then supply compact
143
- `replacements` instructions, achieving 60.6%–90.8% payload reductions without
144
- speculative ambiguity risk.
145
- - **Computed success gate:** Consolidated standard success verification onto
146
- `completion: true` and non-null `outputPath`, removing multi-field verification
147
- checklists from primary prompts while retaining full `change` audit evidence.
148
- - **Advanced features relocated:** Speculative 1-turn apply, directional context
149
- windows (`--context-range`), and anchor diagnostics are relocated to
150
- `docs/AGENT_KNOWLEDGE_BASE.md` and CLI help as opt-in harness policies.
151
- - **Observed-state restoration:** Restructured restoration as a clean request-
152
- or hint-driven branch (`--view rejected` or `selection.hint`) rather than an
153
- upfront classification decision.
154
- - **Empirical surface evaluation:** Added synthetic replay benchmark
155
- (`npm run benchmark:agent-surface`) and validation report documenting 100%
156
- first-attempt task correctness and payload savings across three workflow policies.
157
-
158
- ## 0.7.1
159
-
160
- ### Reliability and Discovery Refinements
161
-
162
- - Localized replacement matching now tries exact case-sensitive text first,
163
- then a narrow ASCII-space/non-breaking-space equivalent match. Ambiguous
164
- equivalent matches still fail closed, and unchanged boundary NBSPs are
165
- retained to avoid incidental whitespace redlines.
166
- - Added a narrow single-paragraph restore shortcut. A restore with a strong
167
- rejected-view target may omit `modified` for verbatim restoration or provide
168
- exact `replacements`; the CLI exposes the same path through `apply --restore
169
- --target-id ID`. Ranges, captures, weak targets, and inferred companion
170
- content remain excluded.
171
- - Fixed rejected-view restore receipts so `resolvedTarget` text, fingerprint,
172
- revision view, and match diagnostics describe the view actually used to
173
- resolve the target.
174
- - Fixed alternate-view search hints to honor `--revised`, `--table`, and
175
- `--body`, and retained compact revision authors plus `deleted`/`inserted` cues
176
- in `extract` output so empty revision-view paragraphs are self-explanatory.
177
-
178
- ## 0.7.0
179
-
180
- ### Agent Performance and Localized Editing
181
-
182
- - **Localized exact replacements:** `redline`/`replace` operations may provide
183
- `replacements: [{ find, replace, occurrence? }]` instead of a complete
184
- `modified` paragraph. The compiler resolves the accepted-view source once,
185
- applies non-overlapping exact replacements simultaneously, synthesizes the
186
- canonical desired paragraph, and delegates to the unchanged OOXML engine.
187
- - **One-turn speculative apply:** `docx-redline apply --find ... --replace ...`
188
- can resolve a globally unique source literal without preliminary extraction.
189
- `--search` plus signed `--context-range START:END` scopes visible headings and
190
- nearby content; `--around N` is symmetric shorthand. Longer, distinctive
191
- anchors are recommended because generic or repeated phrases widen the unioned
192
- scope and may cost an ambiguity-recovery turn.
193
- - **Fail-closed selection:** Missing anchors and patch sources, multiple eligible
194
- paragraphs, ambiguous occurrences, overlaps, conflicts, and unsupported
195
- localized shapes refuse mutation. A failed speculative command never writes
196
- or truncates its output path.
197
- - **Verified change evidence:** Localized operation results include a compact
198
- `change` object with target location, contextual anchor/range, exact
199
- replacement entries, bounded before/after excerpts, commit disposition, and
200
- post-mutation accepted-view verification. Atomic rollback marks the evidence
201
- non-committed and `rolled_back`.
202
- - **CLI contract version 8:** Adds `localized-replacements-v1`,
203
- `speculative-search-apply-v1`, and `localized-change-summary-v1`. Skills and
204
- harnesses should pin version 0.7.0 and negotiate only the capabilities used.
205
- - **Measured workflow reduction:** The checked benchmark records 50% fewer tool
206
- turns and a 64.77%–78.98% smaller deterministic request-token proxy across
207
- three literal-edit cases. Median native engine/I/O time remained effectively
208
- neutral; provider reasoning and network latency were not estimated.
209
-
210
- ### Compatibility
211
-
212
- - Existing `modified` operations, strong targets, operations files/stdin,
213
- tracked-change generation, package validation, rollback, comments,
214
- Accept/Reject, and revision policies remain supported.
215
- - Localized replacement fields and successful `change` evidence are additive.
216
- Wrappers that adopt them must require CLI contract 8; integrations using only
217
- earlier capabilities can continue using their existing operation shapes.
218
- - The implementation remains OOXML-only and adds no runtime dependency or Word,
219
- Office automation, COM, or proprietary document API requirement.
220
-
221
- ## 0.6.0–0.6.2
222
-
223
- ### Safety Fixes
224
-
225
- - **Foreign deleted-paragraph resurrection guard**: Refuses non-empty same-paragraph edits when another author owns the paragraph-mark deletion and all existing paragraph content is deleted. The operation now returns `FOREIGN_PARAGRAPH_MARK_DELETION` with the owning author instead of emitting lifecycle-unsafe OOXML; atomic document operations roll back byte-for-byte. `validateRedlineOoxml` reports already-authored instances as warnings.
226
- - **Source-truth whitespace replacement alignment (WP09a)**: Strict target resolution may equate ordinary spaces with NBSPs, but mutation offsets now always come from the resolved paragraph's exact accepted view. Space-equivalent word replacement hunks are refined to character-local edits, and multiple plain-text edits are applied right-to-left against refreshed live spans. This tracks NBSP-to-space substitutions exactly while preserving unchanged hyperlinks and prevents earlier run splits from invalidating later anchors.
227
- - **Exact mismatch diagnostics**: `PATCH_ROUNDTRIP_MISMATCH` now includes the expected and actual code points at the first mismatch. Document-operation results also report bounded `targetTextMatch` diagnostics when target selection used equivalent whitespace.
228
- - **Baseline-delta validation (WP09c)**: Restoration, operation, and package validation now compare issue multisets against the source. Unchanged legacy defects remain visible without blocking safe work, while any added occurrence or mutation-envelope error fails closed with `GENERATED_OOXML_INVALID` before an operation is reported as applied.
229
- - **Revision identity sanitation (WP09d)**: New paragraph/list builders inherit effective `pPr`/`rPr` formatting without cloning historical revision descendants. Operation-level whole-document validation catches duplicate revision IDs and rolls back the operation savepoint before committing its receipt.
230
- - **View-consistent restore targeting**: `restore` targets now default to the rejected view, where a wholly deleted paragraph's source text exists. Rejected-view inspection now computes fingerprints from rejected-view text and reports the view beside each paragraph. Explicit cross-view text or fingerprint mistakes retain strict refusal while returning an actionable view hint.
231
-
232
- ### New Features
233
-
234
- - **Self-describing and bounded agent discovery (WP-00–WP-02)**: CLI contract version 6 adds command-specific JSON help, canonical redline/comment/restore examples, case-insensitive contextual search with `--around`/`--context`/`-C`, direct-hit pagination through `--limit` and `--after`, and deliberate `--all` opt-out. Unscoped inspection is capped at 20 direct records and a 48 KiB soft budget without truncating any returned `exactText`; extraction now distinguishes matches from context and prioritizes human-facing provision/heading references over machine paragraph ordinals.
235
- - **Composable agent safety and compact output (WP-03–WP-04)**: CLI contract version 7 replaces the atomic-coupled agent profile capability with `agent-safety-profile-v2`. `--profile agent` now enforces complete-success exits while preserving progressive execution and the ordinary revision policy; `--atomic` and `--existing-revisions` compose explicitly. Compact CLI JSON keeps receipts only in the authoritative top-level array, omits exact-match diagnostics, summarizes successful equivalent-whitespace matches, and supports one-line `--compact` output without changing Node or standalone-runner results.
236
- - **Packaged skill-authoring contract (WP-05)**: `docs/SKILL_AUTHORING.md` separates automation invariants from transaction/revision policy, file-versus-stdin transport, reviewer preferences, recovery-envelope behavior, and human-facing presentation. It requires contract/capability negotiation, focused contextual extraction, and library delegation while retaining the visible `AI Redliner` fallback without a new author guard.
237
- - **Batch-start source binding (WP-04)**: Strong document-operation targets are compiled once against the immutable source DOM and carried through structural index/fingerprint drift with rollback-aware session identities. Independent edits no longer need manual bottom-up sorting; same-source writes, incompatible revision/format combinations, and unsafe capture fan-out fail before mutation with causal conflict codes. Unique references to paragraph text created elsewhere in the same batch become explicit internal capture dependencies.
238
- - **Machine-actionable recovery (WP-05)**: Operation, package-facade, example-session, and compact CLI failures now carry recovery envelope version 1 with stable stage/category/action metadata, bounded corrective context, and authorization flags. Failed and partial mutation results include an explicit original-vs-output retry plan and operation indexes. `apply --require-complete` exits with code 3 for partial work while preserving legacy behavior without the flag.
239
- - **Compact shell-agent protocol (WP-06)**: CLI contract version 5 adds `operations-stdin` and `agent-profile-v1`. `--operations -` accepts UTF-8 operation arrays/envelopes without a temporary operations file, while explicit `--profile agent` combines atomic rollback and complete-success exit behavior and reports its effective settings. `AGENTS.md` is now a 527-word routing card, and the 349-word `docs/AGENT_FAST_START.md` carries the ordinary edit contract. Ambient project configuration was deliberately deferred because it would save only the profile flag while adding hidden state.
240
- - **Agent rollout audit (WP-07)**: The observational benchmark now compares canonical Node, legacy file-based CLI, compact stdin/profile CLI, and the development session example while verifying accepted/rejected text, comment preservation, independent batch permutations, recovery behavior, and cross-author attribution. The checked run records 82.75% fewer ordinary instruction words, one fewer shell tool turn (33.33%), and 82.22–89.96% smaller localized session requests than canonical Node envelopes without claiming unmeasured provider/model latency.
241
- - **Explicit paragraph restoration (`type: 'restore'`)**: Restores or counterproposes another reviewer's pending whole-paragraph deletion as a separately tracked sibling paragraph. The source deletion remains untouched; the restored paragraph receives its own inserted paragraph mark, content insertion, sanitized paragraph properties, and fresh `w14:paraId`. Single paragraphs and contiguous ranges are supported, with full Accept/Reject lifecycle verification and structured refusals at unsafe table-row, move, section-break, and terminal-paragraph boundaries.
242
- - **Compact mutation CLI contract (WP09b)**: CLI contract version 3 removes `documentXml`, OOXML/package artifacts, full inspection data, and full validation issue arrays from normal `apply`, `accept`, `reject`, and `delete-comments` stdout. Mutation responses retain actionable errors, per-operation receipts, output durability fields, code/count validation summaries, and a derived `completion` flag that cannot report success for failed, partial, or unwritten work.
243
- - **Word-native deleted-section editing (WP09e)**: An explicit rejected-view `insert` operation can split a foreign deletion at an exact anchor-relative offset into sibling `del(A) / ins(B) / del(A)` carriers. Contiguous paragraph restorations now follow their untouched deleted source block, matching Microsoft Word's ordering. Ambiguous anchors and unsupported structural split boundaries remain fail-closed.
244
-
245
- ## 0.5.1
246
-
247
- ### Highlights & New Features
248
-
249
- - **Cross-Author Revision Slicing (`existingRevisions: 'slice-cross-author'`)**: Adds native support for editing text inside another reviewer's pending tracked insertion without erasing their attribution or requiring prior acceptance.
250
- - **Word-Native Insertion Slicing**: When inserting text inside another author's pending `<w:ins>`, the engine splits the outer carrier into sibling `<w:ins>` elements at the paragraph level (`[ins(A), ins(B), ins(A)]`), ensuring strict ECMA-376 schema compliance without illegal `ins/ins` nesting.
251
- - **Word-Native Deletion Slicing**: When deleting text inside another author's pending `<w:ins>`, the engine nests `<w:del>` directly inside `<w:ins>` per ECMA-376 Part 1 `CT_RunTrackChange` Section 17.13.5.21 and Microsoft Word Desktop 365 native behavior.
252
- - **Boundary & Straddle Deletions**: Deletions straddling baseline text and pending insertions cleanly partition into separate top-level and nested `<w:del>` containers while sharing unified event/author attribution.
253
- - **Multi-Author Stacked Revisions**: Multiple reviewers can independently delete or insert content within the same carrier insertion without cross-author interference.
254
- - **Cascading & Coalescing Lifecycles**: Full round-trip lifecycle parity with Microsoft Word Desktop:
255
- - Rejecting Author A cleanly discards Author A's insertion and any dependent nested deletions by Author B.
256
- - Accepting Author A unwraps the insertion into baseline text while leaving Author B's deletions pending against the baseline.
257
- - Rejecting Author B restores Author B's deleted text within Author A's insertion, and coalesces adjacent split `<w:ins>` fragments back into a single continuous carrier.
258
- - **CLI & Facade Integration**: Fully exposed via the `docx-redline` CLI (`--existing-revisions slice-cross-author`), Node facade (`openDocx`), and batch operation runner.
259
-
260
- ### Non-breaking Changes & Improvements
261
-
262
- - **Validation Update (`validateRedlineOoxml`)**: Refined `NESTED_REVISION` checks to permit direct `<w:ins><w:del>...</w:del></w:ins>` nesting (standard ECMA-376 and Word Desktop behavior), while continuing to strictly reject `ins/ins`, `del/del`, and `del/ins` nesting.
263
- - **Slicing Round-Trip Guard**: Cross-author surgical edits now preserve whitespace-only insertions (including ordinary-space replacements for NBSP characters beside hyperlinks) and verify the exact accepted-view text before reporting success. A mismatch fails closed with `PATCH_ROUNDTRIP_MISMATCH` and returns the original OOXML unchanged.
264
- - **Hyperlink-Adjacent Replacement Anchoring**: Paired replacements immediately before or after a hyperlink now retain a stable insertion point after the deletion run is split, preventing qualifiers from being relocated past the hyperlink or following formatted runs.
265
- - **Multiple Same-Run Insertions**: Insertion-only slicing operations with multiple edit points now apply from right to left against a refreshed live span index, preventing an earlier run split from relocating later insertions.
266
- - **Insertion Stress Hardening**: Slicing now detects edge whitespace changes exactly, uses a character-local insertion-only diff when the original text is an exact subsequence of the modified text, and coalesces new text into an existing same-author carrier when foreign revisions are also present. This prevents repeated phrases from relocating insertions and prevents invalid `w:ins/w:ins` nesting in mixed-author paragraphs.
267
- - **Preflight Inspection**: `preflightOperations` now inspects and validates `slice-cross-author` batches, reporting pending foreign-author carrier targets as `ready` instead of `EXISTING_REVISIONS`.
268
- - **Test Suite Expansion**: Added 7 new test suites covering 36 Word Desktop COM golden fixtures, carrier splitting invariants, the SYN-01..12d synthetic test matrix, PKG-01..06 strict package differential replay, the repeated-text/hyperlink whitespace regression, 76 deterministic insertion stress scenarios, and 12 replacement-anchor lifecycle scenarios (expanding the suite from 88 to 95 passing suites).
269
-
270
- ## 0.5.0
271
-
272
- ### ⚠️ Breaking changes
273
-
274
- The following changes can require caller or contributor updates. No public
275
- export or valid existing function signature was removed.
276
-
277
- #### Runtime and result-contract changes
278
-
279
- - **Canonical paragraph text:** `getParagraphText(...)` now returns the
280
- accepted/current view instead of the earlier simplified `w:t`/`w:tab`
281
- concatenation. It excludes deleted and `w:moveFrom` content and includes
282
- structural breaks, soft hyphens, and non-breaking hyphens.
283
- **Migration:** regenerate compared/cached text with the upgraded library. Use
284
- `extractCanonicalParagraphText(...)` when accepted/rejected-view semantics
285
- are intended; integrations that require the former raw traversal must retain
286
- their own legacy extractor before upgrading.
287
- - **Paragraph fingerprints:** fingerprints now incorporate canonical paragraph
288
- text. Stored fingerprints can become stale for paragraphs containing
289
- revisions, moves, breaks, soft hyphens, or non-breaking hyphens.
290
- **Migration:** do not carry fingerprints across this upgrade; re-extract the
291
- document and regenerate target descriptors.
292
- - **Invalid operations:** malformed or field-incompatible document-operation
293
- objects now return a structured `INVALID_OPERATION` error at the runner
294
- boundary instead of reaching later failure/no-op paths.
295
- **Migration:** validate operation files against the published schema and
296
- handle `status === 'error'` plus `error.code === 'INVALID_OPERATION'`.
297
- - **Commented paragraph deletion:** deleting a complete paragraph that contains
298
- an existing comment now fails with `COMMENTED_CONTENT_DELETE` instead of
299
- producing OOXML with dangling comment references.
300
- **Migration:** preserve or deliberately remove/relocate the comment before
301
- deleting the paragraph, and handle the structured error. Atomic callers keep
302
- the original document unchanged.
303
- - **Comment anchor failures:** missing or ambiguous comment anchors now return
304
- `ANCHOR_NOT_FOUND` or `AMBIGUOUS_ANCHOR` and fail/roll back an atomic batch;
305
- they are no longer reported as successful `no_change` operations.
306
- **Migration:** treat these codes as failed operations and use a unique exact
307
- anchor or stricter target descriptor before retrying.
308
- - **Stricter package validation:** DOCX package validation now rejects
309
- unbalanced comment ranges, dangling references/usages, orphan definitions,
310
- and duplicate comment-definition IDs that earlier validation could allow.
311
- **Migration:** repair the comment anchors and `word/comments.xml` definitions
312
- before applying or validating further changes.
313
-
314
- #### Development workflow change
315
-
316
- - **Parallel tests by default:** `npm test` now runs up to four isolated child
317
- processes concurrently. This does not change the published runtime API, but
318
- contributor automation that depends on test execution order or shared files
319
- must be updated. **Migration:** make tests independent or set
320
- `DOCX_TEST_CONCURRENCY=1` for the previous serial scheduling behavior.
321
-
322
- Strict targeting remains opt-in on existing low-level mutation APIs; it is the
323
- default only on the newly added Node facade and CLI.
324
-
325
- ### Deprecations and future breaking changes
326
-
327
- - Replacing an existing numbering part without a merge callback now emits a
328
- deprecation warning. The Node facade and CLI already merge safely by default.
329
- **This remains supported in this release but will become an error in the next
330
- major version.** Migrate low-level callers to
331
- `mergeNumberingXmlBySchemaOrder` before that release.
332
- - **Permissive target resolution deprecation (`AMBIGUOUS_TARGET_HEURISTIC_USED`):**
333
- Lower-level document operation runners currently default to permissive targeting.
334
- In v1.0.0, application will default to `strictTargets: true`. In this release,
335
- when permissive resolution encounters multiple identical candidate paragraphs and
336
- heuristically chooses the first candidate, it emits an `AMBIGUOUS_TARGET_HEURISTIC_USED`
337
- warning with candidate count and migration guidance.
338
- **Migration:** Disambiguate operations using `paragraphId`, `index`, `occurrence`,
339
- or `fingerprint` and pass `{ strictTargets: true }`.
340
-
341
- ### ℹ️ Noteworthy Default & Usability Changes (Non-breaking)
342
-
343
- The following improvements update default behaviors to maximize agent speed, reduce friction, and eliminate unnecessary errors during iterative editing. These changes are **not technically breaking changes** (no public APIs or exports were removed, and all existing options remain configurable), but represent important behavioral refinements that callers should note:
344
-
345
- - **Fallback Author Default (`'AI Redliner'`):** `setDefaultAuthor`, `node/cli.js`, and `openDocx` now default to `'AI Redliner'` (configurable via the `DOCX_REDLINE_AUTHOR` environment variable or `--author`). The CLI `apply` command and core APIs no longer error with `AUTHOR_REQUIRED` when operations omit an author.
346
- - **Output Overwrite by Default:** Destination files provided via `--output` now overwrite by default instead of failing with `OUTPUT_EXISTS`. Callers wanting protection against accidental overwrites can pass `--no-overwrite` or `--no-clobber`. The source document remains protected and is never overwritten unless `--in-place` is explicitly passed.
347
- - **Replacement Event Pairing (`pairReplacements: true` by default):** Adjacent `<w:del>` and `<w:ins>` revisions now default to sharing linked revision metadata and identical timestamps so Microsoft Word groups them as a single replacement in the Reviewing Pane. Pass `pairReplacements: false` for independent revision timestamps.
348
- - **Structured Content Auto-Detection (`structuredContent: true` by default):** Markdown tables, headings (`#`), and lists in replacement text automatically render as native Word elements (`w:tbl`, `w:pStyle`, `w:numPr`). Single outline-numbered legal clauses (e.g. `13.2.1.1`) continue to be treated as ordinary paragraphs without spurious list conversion. Pass `structuredContent: false` to treat replacement text strictly as plain text.
349
- - **Progressive Batch Mode (`atomic: false` default, `atomic: true` opt-in):** Batch operations and CLI `apply` now apply edits progressively by default (`atomic: false`): valid edits commit directly, while failing edits report structured errors in `results` for faster debugging. Pass `{ atomic: true }` (or `--atomic` on the CLI) for all-or-nothing rollback when any operation fails.
350
- - **Clean Direct Edits (`generateRedlines: false` / `--no-redlines`):** Prominently documented that tracked redlines are not always the preferred method. Callers can pass `generateRedlines: false` (or `--no-redlines` on the CLI) for clean execution drafts, document restructuring, or minor typo fixes without tracked changes markup.
351
- - **Existing Revisions Policy (`existingRevisions: 'merge-same-author'` by default):** When editing a paragraph that already contains tracked changes from the same author, prior revisions by that author are merged against the pre-revision baseline (prior changes by that author are reverted and re-diffed to the new modified text), avoiding revision accumulation and nested markup. If a paragraph contains tracked changes from another reviewer, the operation fails closed with `EXISTING_REVISIONS` to protect third-party review marks. Commented revision content fails closed with `COMMENTED_CONTENT_MERGE` so comment anchors cannot be removed or orphaned. Callers can explicitly pass `'accept-all-first'` to normalize prior revisions or `'reject-input'` to refuse editing any revised paragraph.
352
- - **Inline One-Liner CLI Edits:** Added `--target <text>` with `--modified <text>` or `--comment <text>` on `docx-redline apply` for fast 1–2 edit workflows without creating a JSON operations file.
353
-
354
- ### Added
355
-
356
- - Added **Mutation Receipts** (`receipt` on `DocumentOperationResult` and `receipts`
357
- on `BatchOperationResult`). Every operation execution returns structured,
358
- commit-aware telemetry capturing durable revision IDs (with kind and target part),
359
- comment IDs, numbering IDs, relationship IDs, affected targets, and warnings.
360
- Supports `not_attempted`, `applied`, `refused`, `no_change`, and `rolled_back`
361
- dispositions.
362
- - Added **Commit-Aware Output Reconciliation Oracle** (`reconcileReceiptsAgainstOutput`).
363
- Before completing any transaction, reported durable IDs are checked against a
364
- fresh parse of the generated output OOXML parts. Any reconciliation discrepancy
365
- immediately fails the transaction and triggers atomic rollback.
366
- - Exported receipt primitives: `ReceiptCollector`, `createEmptyReceipt`, and
367
- `reconcileReceiptsAgainstOutput` along with `MutationReceipt` and
368
- `MutationReceiptRevisionItem` TypeScript declarations.
369
- - Added **Paragraph Mark Revisions** (`w:pPrChange`, `markParagraphMarkInserted`,
370
- `markParagraphMarkDeleted`) ensuring whole-paragraph deletions and insertions
371
- cleanly track paragraph mark lifecycles for full Accept All / Reject All symmetry.
372
- - Added **Paragraph Boundary Mutation Validation** (`validateParagraphBoundaryMutation`)
373
- guarding against invalid cross-paragraph boundary merges.
374
-
375
- - Added `analyzeStructuredContent(...)` and `planStructuredReplacement(...)`
376
- for agent-authored attachments and schedules containing mixed headings,
377
- paragraphs, lists, and tables. The planner returns typed blocks and produces
378
- one atomic `structuredContent` operation only when the Markdown is valid.
379
-
380
- - Added session-scoped paragraph metadata indexing for canonical text,
381
- normalized text, paragraph IDs, fingerprints, table context, and document
382
- indexes, plus deterministic targeting and route-profiling benchmarks.
383
- - Added a shared list-marker grammar and parsed list-item vocabulary used by
384
- pipeline analysis, orchestration, normalization, and list targeting.
385
- - Added an internal reconciliation capability matrix and opt-in route
386
- instrumentation. Public reconciliation result shapes and route selection
387
- policy remain unchanged.
388
-
389
- - Added `scripts/extract_text.mjs` and `scripts/apply_changes.mjs` as thin
390
- compatibility entrypoints for legacy skill installations. They delegate to
391
- the supported CLI, retain strict atomic validated writes, and accept legacy
392
- operation files with a top-level `changes` array.
393
- - Added typed operations, per-operation authors, strict target descriptors,
394
- deterministic preflight diagnostics, and auditable resolution metadata.
395
- - Added `inspectDocumentParts(...)`, a structured document inventory using the
396
- same canonical text extractor as targeting and ingestion.
397
- - Added `@ansonlai/docx-redline-js/node`. `openDocx(...)` applies batches to
398
- complete DOCX buffers transactionally and validates before commit.
399
- - Added the cross-platform `docx-redline` CLI with JSON `inspect`, `extract`,
400
- `preflight`, `apply`, `accept`, `reject`, `delete-comments`, and `validate`
401
- commands, plus a published operation-file JSON Schema.
402
-
403
- ### Behavior and reliability
404
-
405
- - Explicit structured replacements now reject missing Markdown table separator
406
- - Generated Markdown tables repeat their header row and prevent logical data rows from splitting across pages.
407
- rows, missing data rows, and inconsistent column counts with
408
- `STRUCTURED_CONTENT_INVALID` instead of inserting literal pipe-delimited text.
409
- - Tables created inside mixed replacements are tracked once at block scope,
410
- avoiding nested revisions while keeping Accept All and Reject All symmetric.
411
-
412
- - Target preflight and live mutation reuse one document-scoped paragraph index;
413
- strict duplicate detection and resolution metadata retain their prior
414
- semantics while avoiding repeated whole-document text traversal.
415
- - Revision-ID seeding now walks the DOM with child/sibling pointers instead of
416
- allocating an array containing every element.
417
- - Single-source-paragraph list expansion uses the focused list generator
418
- directly. Multi-paragraph marked-list edits deliberately retain the legacy
419
- run-aware reconciliation pipeline for structural parity.
420
- - Fixed paragraph-to-list expansion when a manually numbered heading carries
421
- `w:numId w:val="0"`. Numbering suppression is no longer reused as a generated
422
- list ID, so inserted bullet and numbered items receive valid positive IDs.
423
- - Tracked heading-to-list replacements now keep the deleted source heading in
424
- its own paragraph and track the paragraph marks of every inserted list item.
425
- This prevents deleted heading text from joining the first item and preserves
426
- exact Accept/Reject structure without adding a full-document sentinel
427
- paragraph.
428
- - Inserted list items now inherit source font family, size, language, and
429
- related script typography without inheriting heading-only bold, underline,
430
- italic, or strike formatting unless requested by the replacement markdown.
431
- - Canonical-only table-cell targeting now consumes the shared paragraph-text
432
- extractor, while offset- and sentinel-producing walkers remain specialized.
433
- Their accepted visible projections now agree on soft hyphens as well as tabs,
434
- breaks, hyperlinks, and non-breaking hyphens.
435
-
436
- - Comment preflight and application now share one anchor resolver. Exact
437
- matches take priority, unique ordinary-space/NBSP differences preserve raw
438
- offsets, and missing or repeated anchors return structured
439
- `ANCHOR_NOT_FOUND` or `AMBIGUOUS_ANCHOR` errors.
440
- - Full-document operation batches now share one live DOM and revision-ID
441
- allocator, reducing complete-document parsing and serialization from once per
442
- operation to once per changed batch. Scoped reconciliation engines and their
443
- targeting decisions are unchanged.
444
- - Each live-session operation uses a DOM and allocator savepoint. Errors and
445
- reported no-ops restore the savepoint; atomic failures and all-no-op batches
446
- still return the exact original XML without serializing it.
447
- - Decomposed the standalone document-operation runner into a stable 13-line
448
- compatibility facade plus focused session, applier, batch-orchestrator,
449
- heuristic, and OOXML-mutation modules. Runtime exports and declarations are
450
- unchanged, and operation internals now use leaf imports instead of importing
451
- the root entry point.
452
- - Package comment IDs are seeded from existing anchors and definitions, and
453
- the Node facade merges numbering without discarding prior definitions.
454
- - Canonical paragraph text consistently handles revisions, moves, tabs,
455
- breaks, soft hyphens, and non-breaking hyphens; see the breaking-change note
456
- above for `getParagraphText(...)` and fingerprint compatibility.
457
- - Structured inspection now explicitly supports the `current` view as the
458
- accepted/current document view and resolves comment ranges spanning multiple
459
- paragraphs as one exact anchor string.
460
- - Transactional no-op results preserve the original DOCX bytes exactly,
461
- including when the same facade instance has already committed an edit.
462
-
463
- ### Testing and development
464
-
465
- - Added focused and semantic visual-failure regressions for suppressed
466
- numbering, paragraph separation, paragraph-mark revisions, selective
467
- typography inheritance, and exact accepted/rejected paragraph sequences,
468
- plus seeded fuzz variants across list length, marker, font, and size.
469
- Added the independently specified
470
- `legal-suppressed-heading-to-bullet-list` and
471
- `legal-structured-attachment-mixed-blocks` Microsoft Word differential
472
- fixtures; the synthetic catalogue now contains 49 cases and 49 task types.
473
-
474
- - The JavaScript test runner now uses bounded asynchronous subprocess workers,
475
- capped at four by default, while retaining one fresh Node process per file,
476
- sorted reporting, timeouts, captured diagnostics, and failure-marker checks.
477
- Set `DOCX_TEST_CONCURRENCY=1` for serial reproduction.
478
- - Added `npm run benchmark:tests` and a Phase 6 runner regression. The checked
479
- benchmark reduced median suite time from 18.02 seconds to 7.96 seconds
480
- (55.80%); 20 consecutive parallel runs and a separate serial run passed all
481
- 63 files. Parallel c8 collection remains valid at 89.90% statements/lines,
482
- 77.40% branches, and 93.10% functions.
483
-
484
- - Added Phase 3 targeting/traversal, Phase 4 list/text parity, and Phase 5 route
485
- compatibility regressions. Together with the Phase 6 runner regression, the
486
- suite now contains 63 passing test files.
487
- - Added `npm run benchmark:targeting` and `npm run profile:routes`. The checked
488
- 10,000-paragraph benchmark showed no single-operation regression and a 47.16x
489
- Node median improvement for 100 cached resolutions. The equivalent native
490
- Chrome benchmark showed no single-operation regression and a 36.45x batch
491
- improvement. All 47 Microsoft Word differential fixtures and all 60 real-
492
- document Word corpus scenarios passed after the routing changes.
493
-
494
- - Added subprocess coverage for legacy wrapper selection, operation-file
495
- compatibility, successful output, atomic anchor failure, source-byte
496
- preservation, and protection of pre-existing output files.
497
- - Added a live-session accuracy and instrumentation suite covering accepted and
498
- rejected text, structural validity, sequential equivalence, comments, lists,
499
- tables, highlights, one-parse/one-serialize execution, exact no-ops, and
500
- atomic rollback. Added `npm run benchmark:session`; the checked accuracy-first
501
- benchmark reduced parse/serialize counts from 10/10 to 1/1 and measured a
502
- 1.58x median speedup with per-operation savepoints retained.
503
- - Added a Phase 2 architecture regression covering facade export identity,
504
- direct leaf imports, exact session rollback, isolated context commit, and
505
- stable comment-first scheduling.
506
- - Added five edge-case suites for canonical text views, cross-paragraph comment
507
- inspection, table/list/reference context, sequential package transactions,
508
- selective multi-author cleanup, ZIP rejection behavior, CLI filters, JSON
509
- exit contracts, and destructive-output safeguards. Together with the Phase 2
510
- Phase 1 and Phase 2 regressions, these established the earlier 57-file
511
- baseline expanded by the subsequent performance phases.
512
-
513
- ## 0.3.0
514
-
515
- ### Breaking changes
516
-
517
- - Malformed OOXML no longer escapes public transform APIs as a raw parser
518
- exception. In particular, revision accept/reject and comment-deletion callers
519
- that previously used `try`/`catch` must now inspect `status === 'error'` and
520
- `error.code === 'PARSE_ERROR'` on the returned result.
521
- - Caller content is no longer sanitized by default. Pass `sanitizeInput: true`
522
- to remove a standalone leading assistant-preface line. Dollar-delimited text
523
- and literal `\\n` / `\\r\\n` sequences are never removed implicitly.
524
- - The exported `sanitizeAiResponse` helper no longer removes dollar-delimited
525
- spans or converts literal `\\n` / `\\r\\n` sequences. Direct callers that
526
- relied on those transformations must perform them explicitly.
527
- - `applyOperationsToDocumentXml` is atomic by default. Failed batches return
528
- the original document with `rolledBack: true`; pass `atomic: false` to retain
529
- partial-result behavior.
530
- - Missing multi-line targets now return `TARGET_NOT_FOUND` instead of being
531
- indistinguishable from a no-op. Stale batch anchors also return
532
- `TARGET_NOT_FOUND` instead of falling back to a visibly different paragraph.
533
-
534
- ### Behavior changes and fixes
535
-
536
- - Revision IDs are now allocated per document. Near-limit prior IDs restart in
537
- a safe low range, and unrelated bookmark/relationship IDs no longer seed the
538
- revision counter.
539
- - Concurrent calls with explicit authors keep their revision attribution
540
- isolated from process-global defaults.
541
- - `existingRevisions: 'accept-all-first'` now preserves the original OOXML when
542
- the requested edit is a no-op.
543
- - Added `existingRevisions: 'accept-all-first-keep-normalized'` for callers that
544
- explicitly want accepted existing revisions returned even when no redline is
545
- added.
546
- - Diff output is deterministic by default. Inputs exceeding 262,144 unique
547
- tokens return `DIFF_TOKEN_LIMIT` with the original OOXML unchanged instead of
548
- risking truncated text; leading whitespace is preserved exactly.
549
- - Reconstruction preserves structural line breaks and body section-property
550
- placement. A target that names only part of a reconstruction range now
551
- returns `PARTIAL_TARGET` instead of risking deletion of untargeted content.
552
- - Paragraph targeting and reconstruction now preserve leading, middle, and
553
- trailing `w:tab` elements as literal tab characters instead of omitting or
554
- trimming them.
555
- - Adjacent redline edits now preserve complex-field instructions, begin/
556
- separate/end markers, and unchanged cached display results in their original
557
- field boundary. Field instructions remain inert and are not evaluated.
558
- - Added structured XML parse results and result-returning ingestion helpers.
559
- - Hardened deterministic diff token handling and leading-whitespace fidelity.
560
-
561
- ### Testing and development
562
-
563
- - Expanded the desktop Word differential from 20 to 25 cases, adding structural
564
- checks for bookmarks, internal hyperlinks, mixed formatting, content
565
- controls, and tables.
566
- - Expanded the desktop Word differential from 25 to 28 cases with structural
567
- tabs and a locked PAGE field, and added tab/field shapes to focused and fuzz
568
- regression testing.
569
- - Expanded the desktop Word differential from 28 to 33 cases with comments,
570
- footnotes, endnotes, headers/footers, and an external hyperlink.
571
- - Extended the deterministic script-only DOCX packager with opt-in related
572
- parts, relationship/content-type validation, reusable fixture constructors,
573
- and SHA-256 verification that supplied parts remain byte-identical. Runtime
574
- library code and dependencies are unchanged.
575
- - Added validated task, structure, oracle, and manual-review metadata across the
576
- 33 synthetic and 20 SuperDoc Word cases. `npm run report:word:coverage`
577
- produces a deterministic coverage matrix with explicit high-priority gap
578
- dispositions, while `npm run review:word:prepare` creates a pending rotating
579
- human-review manifest without self-certifying visual results.
580
- - Added detailed production-function coverage reporting and a checked per-file
581
- regression baseline. Five behavior-focused Phase 3 suites exercise numbering
582
- collisions/remapping, every reconciliation route, list construction and
583
- fallback, patch/format boundaries, table decisions, pipeline modes, and
584
- standalone rollback/highlight paths. Production function coverage moved from
585
- 437/540 to 496/542 and all reachable P0 functions are covered; no runtime
586
- behavior or compatibility contract changed.
1
+ # Changelog
2
+
3
+ ## 0.8.4
4
+
5
+ ### Added
6
+
7
+ - **`textOccurrence` on `format` / `character-format`:** a 1-based match of `textToFormat` inside the resolved paragraph,
8
+ independent of `target.occurrence` (which selects the paragraph). Out of range fails with `PATCH_SOURCE_NOT_FOUND`;
9
+ calls without it still read `target.occurrence`. CLI capability `format-text-occurrence-v1`; contract stays version 8.
10
+ - **`applyRedlineToOxml` numbering options:** `numberingXml` and `numberingIdState` remap generated list definitions to
11
+ IDs that do not collide with the source numbering.
12
+
13
+ ### Fixed
14
+
15
+ - **Soft-break text can be converted to a list:** a paragraph whose `A. …`, `B. …` items are separated by `<w:br/>` was
16
+ refused with `TARGET_NOT_FOUND`, and an explicit list request identical to typed markers was a no-op. In-run `\n`/`\t`
17
+ now serialize back to `<w:br/>`/`<w:tab/>`, including inside `w:delText`, so Reject All restores the breaks.
18
+ - **Localized `replacements` work in paragraphs with soft line breaks:** they were refused with `INVALID_OPERATION`.
19
+ A `find` within one line now applies and keeps the breaks; a `find` or `replace` that spans or adds a break is refused.
20
+ - **Generated bullets no longer reuse existing numbering IDs:** bullets generated into a document that already defined
21
+ `numId 1` continued an existing decimal list in Word. The bare runner and `applyRedlineToOxml` now allocate new IDs
22
+ from the supplied `numberingXml`, as `openDocx` already did.
23
+ - **Appending a table after a paragraph keeps its underline:** the paragraph was tracked as deleted and re-inserted as
24
+ plain text, so a prior same-author underline, or a `++underline++` sent with the table, was lost on Accept All. The
25
+ source paragraph is now kept in place.
26
+ - **Word's Reject All removes generated tables:** tracked tables were wrapped in one `w:ins` around `w:tbl`, which Word
27
+ does not recognize. Reject All left an empty table, and a table at the end of a document could hang Word. Tables now
28
+ use row-level `w:trPr/w:ins` with inserted cell content and marks, and `rejectTrackedChangesInOoxml` removes a table
29
+ once all of its rows are rejected. Confirmed in Word.
30
+
31
+ ### Tests
32
+
33
+ - New `tests/soft_break_list_conversion_tests.mjs`, `tests/soft_break_localized_replacements_tests.mjs`,
34
+ `tests/generated_bullet_numbering_collision_tests.mjs`, `tests/format_text_occurrence_tests.mjs` and
35
+ `tests/table_append_fidelity_tests.mjs`.
36
+
37
+ ### Known limitations
38
+
39
+ - Localized restore in the rejected view still refuses paragraphs with line breaks.
40
+ - The table-append path covers one paragraph followed by one table.
41
+ - Under `merge-same-author`, editing the text of a paragraph that carries your own pending formatting change still drops
42
+ that formatting on Accept All.
43
+
44
+ ## 0.8.3
45
+
46
+ ### Fixed
47
+
48
+ - **Reject All no longer leaves an empty paragraph after an inserted paragraph:** `modified: "<original>\n<new>"` on a plain
49
+ paragraph did not track the new paragraph's mark as inserted. It now does.
50
+ - **Reject All no longer merges source paragraphs after a list range replacement:** replacing a multi-paragraph list range
51
+ (`target` + `targetEnd`) collapsed the sources into one deleted paragraph, so Reject All gave results such as
52
+ `Bullet Root ABullet Insertion Anchor`, `AlphaGamma` for an empty middle paragraph, and lost both paragraphs of an
53
+ all-empty range. Each source paragraph, empty ones included, now keeps its own tracked-deleted paragraph. Confirmed in Word.
54
+ - **Inspection no longer reports historical paragraph properties as current:** `list`, `styleId` and `headingLevel` (and list
55
+ targeting) could read `numPr`, `pStyle` or `outlineLvl` stored under `w:pPrChange`. Only the paragraph's direct `w:pPr`
56
+ is read now.
57
+ - **`openDocx` list range replacement no longer renumbers or re-points lists:** deleted source paragraphs were remapped to a
58
+ new generic `numId` (Reject All restored them with the wrong list type), new items started a separate list (untouched
59
+ following items restarted at 1), and unused numbering definitions were added. Deleted source paragraphs now keep their
60
+ `numPr`, and a same-kind replacement reuses the source `numId`, leaving `numbering.xml` unchanged. Reuse applies when the
61
+ range uses one `numId` and the generated level formats match; format-changing edits still allocate new definitions, and
62
+ definitions created earlier in the same batch are not reused. Confirmed in Word.
63
+ - **Explicit list start values are applied:** generated list fragments without `xmlns:w` failed to parse in
64
+ `orchestration/list-structural-fallback.js`, so `7. Header` lost its `startOverride` and xmldom logged parse warnings.
65
+
66
+ ### Tests
67
+
68
+ - New `tests/list_reject_fidelity_tests.mjs` and `tests/facade_list_numbering_tests.mjs`, with the Word-authored fixture
69
+ `tests/fixtures/agentic-lists/nested-lists-source.docx`; extended inspection and list structural fallback suites.
70
+
71
+ ### Known limitations
72
+
73
+ - Plain paragraph to list conversion and list format changes are not yet supported canonically; see
74
+ `docs/plans/2026-09-30-canonical-list-operations.md`.
75
+ - `1. Header` to `1. Header` on a bare `document.xml` (not a packaged `.docx`) can fail with `RECEIPT_RECONCILIATION_FAILED`.
76
+
77
+ ## 0.8.2
78
+
79
+ ### Fixed
80
+
81
+ - **Replacement next to a hyperlink no longer pulls adjacent plain text into the link** ([#3](https://github.com/AnsonLai/docx-redline-js/issues/3)):
82
+ replacing `example.org` with `example.net` (localized `replacements` or full `modified`) in a hyperlink followed by a
83
+ plain `.` run produced a link showing `example.net.` after Accept All. The reconstruction-mode word diff treated
84
+ `example.org.` as one token spanning the hyperlink edge. Where a replacement's shared prefix or suffix reaches a wrapper
85
+ boundary inside the deleted text, it is now kept unchanged.
86
+ - **Reject All no longer reorders text around a manual line break** ([#4](https://github.com/AnsonLai/docx-redline-js/issues/4)):
87
+ replacing `tabbed` with `aligned` in `<tab>tabbed<w:br/>Line with ` rejected to `<tab>tabbedLine<break> with `, moving
88
+ deleted text across the break. Break and note-reference placeholders are now standalone word-diff tokens (new internal
89
+ `atomicChars` option), and change groups are split at references present on both sides. Covered by `tests/reconstruction_boundary_fidelity_tests.mjs`.
90
+
91
+ ## 0.8.1
92
+
93
+ ### Added
94
+
95
+ - **Header and footer editing:** add `part` to an operation (a selector `{ kind, type?, section? }` or a part path) to edit a
96
+ header or footer; `inspect().headersFooters` lists the parts with their text, the sections they apply to (including
97
+ inherited ones) and whether they contain fields. Body edits are unchanged and headers/footers are opt-in. Fields such as
98
+ PAGE are atomic (`FIELD_EDIT_REFUSED`), comments are refused (`COMMENT_IN_HEADER_FOOTER`), bad selectors fail closed
99
+ (`PART_NOT_FOUND`, `PART_AMBIGUOUS`), atomic batches roll back across body and parts, revision ids stay unique across the
100
+ package, receipts name the part, `accept`/`reject` also resolve revisions inside headers and footers, and
101
+ `validateDocxPackage` checks header/footer references, relationships and content types.
102
+ - **Resolve and reopen comment threads:** `doc.resolveComment(id, { resolved })` and the batch operation
103
+ `{ "type": "comment_resolve", "commentId": "0", "resolved": true }`, so the CLI can resolve through `apply --operations`.
104
+ Word resolves whole threads, so the root and every reply change together, whichever id is given. Only
105
+ `word/commentsExtended.xml` changes; `document.xml` stays byte-identical. Unknown ids fail with `COMMENT_NOT_FOUND`
106
+ (also in `preflight`).
107
+ - **Delete comments by id:** `doc.deleteComments({ ids })` and `docx-redline delete-comments --comment-id 3,4`. Deleting a
108
+ thread root also deletes its replies; unknown ids fail closed with `COMMENT_NOT_FOUND`.
109
+ - CLI capabilities `comment-resolve-operation-v1`, `delete-comments-by-id-v1` and `header-footer-parts-v1` (additive; the
110
+ contract version is unchanged).
111
+ - `services/package-parts.js`, a registry of package part paths, content types and relationship types checked against
112
+ Word-saved fixtures (`tests/fixtures/word-authored/`), and `npm run test:word:package`, which opens generated outputs in
113
+ real Word with repair disabled and checks comment counts, thread parents, resolved state and header/footer revisions
114
+ through Word's object model.
115
+
116
+ ### Fixed
117
+
118
+ - **Word "unreadable content" prompt on commented documents:** `word/commentsExtended.xml` was relabeled
119
+ `application/vnd.ms-word.commentsExtended+xml` on every save of any document that already had comments.
120
+ Word expects `application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml` and
121
+ offered to repair the file. The constant is corrected, an edit that does not change comment threading no
122
+ longer rewrites the extended part or its content type/relationship, and files already damaged by earlier
123
+ versions are repaired on the next save (`repairKnownContentTypes`, also exported). `validateDocxPackage`
124
+ now rejects the wrong type instead of accepting it. `tests/package_content_type_contract_tests.mjs` checks this
125
+ against a Word-authored content-type table on every OS.
126
+ - **Comment threads keyed on the last paragraph:** Word joins `comments.xml` to `commentsExtended.xml` and
127
+ `commentsIds.xml` through the `w14:paraId` of a comment's LAST paragraph. Inspection, package validation,
128
+ replies and delete-cascade used the first, so Word's own multi-paragraph threaded documents failed
129
+ validation and replies to them attached to the wrong key.
130
+ - **Edits no longer drop comment anchors:** a mid-paragraph edit of a commented paragraph dropped the trailing
131
+ `commentRangeEnd` and `commentReference` (markers at the very end of the paragraph text were only emitted when the
132
+ last diff part was an insert), leaving the comment unanchored and failing package validation. Found by
133
+ opening our output in real Word; covered by `tests/comment_marker_preservation_tests.mjs`.
134
+ - **Replies are now visible in Word:** `comment_reply` only wrote `comments.xml`/`commentsExtended.xml`, and Word
135
+ does not show a reply that has no body markers. Replies now get their own `commentRangeStart`/`commentRangeEnd`/
136
+ `commentReference` next to the thread's, laid out like Word writes them. A reply to a reply joins the root thread.
137
+ A parent with no body anchor fails with `PARENT_ANCHOR_NOT_FOUND`.
138
+ - **Replies to a resolved thread are resolved too**, as Word writes them (`reply-to-resolved.docx` fixture). They were
139
+ written open, leaving a thread that was half resolved.
140
+ - `commentsIds.xml` and `commentsExtensible.xml` are kept consistent with `comments.xml` on add/delete when present.
141
+ - `deleteComments` and `resolveRevisions` report `artifactsChanged` from a real diff of the package (they listed a fixed
142
+ set of parts and missed `commentsIds.xml`, `commentsExtensible.xml` and `[Content_Types].xml`).
143
+
144
+ ## 0.8.0
145
+
146
+ ### Universal Document Facade & Zero-Node Architecture
147
+
148
+ - **Universal `DocxDocument` & `openDocx`:** Implemented complete-DOCX lifecycle operations
149
+ (`openDocx`, `doc.inspect()`, `doc.applyOperations()`, `doc.resolveRevisions()`, `doc.deleteComments()`,
150
+ `doc.toUint8Array()`, `doc.getRevisionToken()`) on standard `Uint8Array` in `document/docx-document.js`,
151
+ re-exported directly from `index.js`. Enables complete-document redline workflows in any JavaScript
152
+ runtime without Node.js dependencies.
153
+ - **Pure-JS ZIP container (`fflate`):** Replaced `node:zlib` with lightweight, zero-dependency `fflate`
154
+ in `document/zip-archive.js`, providing cross-runtime raw DEFLATE / INFLATE compression and decompression
155
+ with full OOXML archive compatibility.
156
+ - **Pure-JS FIPS 180-4 SHA-256:** Created zero-dependency, synchronous SHA-256 implementation in
157
+ `core/sha256.js`, removing `node:crypto` from package revision token calculations while retaining
158
+ exact deterministic hash parity with standard NIST vectors.
159
+ - **Transparent XML DOM fallback:** Added `resolveDomParserConstructor()` and
160
+ `resolveXmlSerializerConstructor()` in `adapters/xml-adapter.js`, automatically utilizing native
161
+ `globalThis.DOMParser`/`globalThis.XMLSerializer` when present and falling back transparently to
162
+ `@xmldom/xmldom` in headless, server, edge, and sandbox environments without requiring manual provider setup.
163
+ - **Zero-dependency sandbox bundles:** Configured `scripts/build.mjs` with `esbuild` (`platform: 'neutral'`)
164
+ to produce single-file, zero-dependency standalone bundles in both ESM (`dist/docx-redline.bundle.js`)
165
+ and CommonJS (`dist/docx-redline.bundle.cjs`), exported as `@ansonlai/docx-redline-js/bundle` for direct
166
+ use in workflow engines (e.g., n8n Code nodes), Cloudflare Workers, AWS Lambda, Deno, and QuickJS sandboxes.
167
+ - **Strict runtime boundary enforcement:** Removed `node:zlib` and `node:crypto` from allowed external
168
+ imports in `tests/no_word_api_index_check.mjs`. Automated sandbox isolation tests
169
+ (`tests/sandbox_bundle_isolation_tests.mjs`) verify zero Node built-in imports and full document
170
+ reconciliation in restricted VM contexts without `process`, `Buffer`, or `require`.
171
+ - **Backward compatibility:** Preserved full API and `Buffer` compatibility for `@ansonlai/docx-redline-js/node`
172
+ consumers and `doc.toBuffer()`.
173
+
174
+ ## 0.7.2
175
+
176
+ ### Agent Surface Simplification
177
+
178
+ - **Extraction-first golden path:** Re-established the single deterministic two-turn
179
+ "extract-then-apply" sequence as the default agent workflow across `AGENTS.md`,
180
+ `docs/AGENT_FAST_START.md`, and `docs/SKILL_AUTHORING.md`. Eliminates the
181
+ upfront "choice tax" and model deliberation overhead.
182
+ - **Localized replacements after inspection:** Decoupled localized patching from
183
+ speculation. Agents inspect the target paragraph first, then supply compact
184
+ `replacements` instructions, achieving 60.6%–90.8% payload reductions without
185
+ speculative ambiguity risk.
186
+ - **Computed success gate:** Consolidated standard success verification onto
187
+ `completion: true` and non-null `outputPath`, removing multi-field verification
188
+ checklists from primary prompts while retaining full `change` audit evidence.
189
+ - **Advanced features relocated:** Speculative 1-turn apply, directional context
190
+ windows (`--context-range`), and anchor diagnostics are relocated to
191
+ `docs/AGENT_KNOWLEDGE_BASE.md` and CLI help as opt-in harness policies.
192
+ - **Observed-state restoration:** Restructured restoration as a clean request-
193
+ or hint-driven branch (`--view rejected` or `selection.hint`) rather than an
194
+ upfront classification decision.
195
+ - **Empirical surface evaluation:** Added synthetic replay benchmark
196
+ (`npm run benchmark:agent-surface`) and validation report documenting 100%
197
+ first-attempt task correctness and payload savings across three workflow policies.
198
+
199
+ ## 0.7.1
200
+
201
+ ### Reliability and Discovery Refinements
202
+
203
+ - Localized replacement matching now tries exact case-sensitive text first,
204
+ then a narrow ASCII-space/non-breaking-space equivalent match. Ambiguous
205
+ equivalent matches still fail closed, and unchanged boundary NBSPs are
206
+ retained to avoid incidental whitespace redlines.
207
+ - Added a narrow single-paragraph restore shortcut. A restore with a strong
208
+ rejected-view target may omit `modified` for verbatim restoration or provide
209
+ exact `replacements`; the CLI exposes the same path through `apply --restore
210
+ --target-id ID`. Ranges, captures, weak targets, and inferred companion
211
+ content remain excluded.
212
+ - Fixed rejected-view restore receipts so `resolvedTarget` text, fingerprint,
213
+ revision view, and match diagnostics describe the view actually used to
214
+ resolve the target.
215
+ - Fixed alternate-view search hints to honor `--revised`, `--table`, and
216
+ `--body`, and retained compact revision authors plus `deleted`/`inserted` cues
217
+ in `extract` output so empty revision-view paragraphs are self-explanatory.
218
+
219
+ ## 0.7.0
220
+
221
+ ### Agent Performance and Localized Editing
222
+
223
+ - **Localized exact replacements:** `redline`/`replace` operations may provide
224
+ `replacements: [{ find, replace, occurrence? }]` instead of a complete
225
+ `modified` paragraph. The compiler resolves the accepted-view source once,
226
+ applies non-overlapping exact replacements simultaneously, synthesizes the
227
+ canonical desired paragraph, and delegates to the unchanged OOXML engine.
228
+ - **One-turn speculative apply:** `docx-redline apply --find ... --replace ...`
229
+ can resolve a globally unique source literal without preliminary extraction.
230
+ `--search` plus signed `--context-range START:END` scopes visible headings and
231
+ nearby content; `--around N` is symmetric shorthand. Longer, distinctive
232
+ anchors are recommended because generic or repeated phrases widen the unioned
233
+ scope and may cost an ambiguity-recovery turn.
234
+ - **Fail-closed selection:** Missing anchors and patch sources, multiple eligible
235
+ paragraphs, ambiguous occurrences, overlaps, conflicts, and unsupported
236
+ localized shapes refuse mutation. A failed speculative command never writes
237
+ or truncates its output path.
238
+ - **Verified change evidence:** Localized operation results include a compact
239
+ `change` object with target location, contextual anchor/range, exact
240
+ replacement entries, bounded before/after excerpts, commit disposition, and
241
+ post-mutation accepted-view verification. Atomic rollback marks the evidence
242
+ non-committed and `rolled_back`.
243
+ - **CLI contract version 8:** Adds `localized-replacements-v1`,
244
+ `speculative-search-apply-v1`, and `localized-change-summary-v1`. Skills and
245
+ harnesses should pin version 0.7.0 and negotiate only the capabilities used.
246
+ - **Measured workflow reduction:** The checked benchmark records 50% fewer tool
247
+ turns and a 64.77%–78.98% smaller deterministic request-token proxy across
248
+ three literal-edit cases. Median native engine/I/O time remained effectively
249
+ neutral; provider reasoning and network latency were not estimated.
250
+
251
+ ### Compatibility
252
+
253
+ - Existing `modified` operations, strong targets, operations files/stdin,
254
+ tracked-change generation, package validation, rollback, comments,
255
+ Accept/Reject, and revision policies remain supported.
256
+ - Localized replacement fields and successful `change` evidence are additive.
257
+ Wrappers that adopt them must require CLI contract 8; integrations using only
258
+ earlier capabilities can continue using their existing operation shapes.
259
+ - The implementation remains OOXML-only and adds no runtime dependency or Word,
260
+ Office automation, COM, or proprietary document API requirement.
261
+
262
+ ## 0.6.0–0.6.2
263
+
264
+ ### Safety Fixes
265
+
266
+ - **Foreign deleted-paragraph resurrection guard**: Refuses non-empty same-paragraph edits when another author owns the paragraph-mark deletion and all existing paragraph content is deleted. The operation now returns `FOREIGN_PARAGRAPH_MARK_DELETION` with the owning author instead of emitting lifecycle-unsafe OOXML; atomic document operations roll back byte-for-byte. `validateRedlineOoxml` reports already-authored instances as warnings.
267
+ - **Source-truth whitespace replacement alignment (WP09a)**: Strict target resolution may equate ordinary spaces with NBSPs, but mutation offsets now always come from the resolved paragraph's exact accepted view. Space-equivalent word replacement hunks are refined to character-local edits, and multiple plain-text edits are applied right-to-left against refreshed live spans. This tracks NBSP-to-space substitutions exactly while preserving unchanged hyperlinks and prevents earlier run splits from invalidating later anchors.
268
+ - **Exact mismatch diagnostics**: `PATCH_ROUNDTRIP_MISMATCH` now includes the expected and actual code points at the first mismatch. Document-operation results also report bounded `targetTextMatch` diagnostics when target selection used equivalent whitespace.
269
+ - **Baseline-delta validation (WP09c)**: Restoration, operation, and package validation now compare issue multisets against the source. Unchanged legacy defects remain visible without blocking safe work, while any added occurrence or mutation-envelope error fails closed with `GENERATED_OOXML_INVALID` before an operation is reported as applied.
270
+ - **Revision identity sanitation (WP09d)**: New paragraph/list builders inherit effective `pPr`/`rPr` formatting without cloning historical revision descendants. Operation-level whole-document validation catches duplicate revision IDs and rolls back the operation savepoint before committing its receipt.
271
+ - **View-consistent restore targeting**: `restore` targets now default to the rejected view, where a wholly deleted paragraph's source text exists. Rejected-view inspection now computes fingerprints from rejected-view text and reports the view beside each paragraph. Explicit cross-view text or fingerprint mistakes retain strict refusal while returning an actionable view hint.
272
+
273
+ ### New Features
274
+
275
+ - **Self-describing and bounded agent discovery (WP-00–WP-02)**: CLI contract version 6 adds command-specific JSON help, canonical redline/comment/restore examples, case-insensitive contextual search with `--around`/`--context`/`-C`, direct-hit pagination through `--limit` and `--after`, and deliberate `--all` opt-out. Unscoped inspection is capped at 20 direct records and a 48 KiB soft budget without truncating any returned `exactText`; extraction now distinguishes matches from context and prioritizes human-facing provision/heading references over machine paragraph ordinals.
276
+ - **Composable agent safety and compact output (WP-03–WP-04)**: CLI contract version 7 replaces the atomic-coupled agent profile capability with `agent-safety-profile-v2`. `--profile agent` now enforces complete-success exits while preserving progressive execution and the ordinary revision policy; `--atomic` and `--existing-revisions` compose explicitly. Compact CLI JSON keeps receipts only in the authoritative top-level array, omits exact-match diagnostics, summarizes successful equivalent-whitespace matches, and supports one-line `--compact` output without changing Node or standalone-runner results.
277
+ - **Packaged skill-authoring contract (WP-05)**: `docs/SKILL_AUTHORING.md` separates automation invariants from transaction/revision policy, file-versus-stdin transport, reviewer preferences, recovery-envelope behavior, and human-facing presentation. It requires contract/capability negotiation, focused contextual extraction, and library delegation while retaining the visible `AI Redliner` fallback without a new author guard.
278
+ - **Batch-start source binding (WP-04)**: Strong document-operation targets are compiled once against the immutable source DOM and carried through structural index/fingerprint drift with rollback-aware session identities. Independent edits no longer need manual bottom-up sorting; same-source writes, incompatible revision/format combinations, and unsafe capture fan-out fail before mutation with causal conflict codes. Unique references to paragraph text created elsewhere in the same batch become explicit internal capture dependencies.
279
+ - **Machine-actionable recovery (WP-05)**: Operation, package-facade, example-session, and compact CLI failures now carry recovery envelope version 1 with stable stage/category/action metadata, bounded corrective context, and authorization flags. Failed and partial mutation results include an explicit original-vs-output retry plan and operation indexes. `apply --require-complete` exits with code 3 for partial work while preserving legacy behavior without the flag.
280
+ - **Compact shell-agent protocol (WP-06)**: CLI contract version 5 adds `operations-stdin` and `agent-profile-v1`. `--operations -` accepts UTF-8 operation arrays/envelopes without a temporary operations file, while explicit `--profile agent` combines atomic rollback and complete-success exit behavior and reports its effective settings. `AGENTS.md` is now a 527-word routing card, and the 349-word `docs/AGENT_FAST_START.md` carries the ordinary edit contract. Ambient project configuration was deliberately deferred because it would save only the profile flag while adding hidden state.
281
+ - **Agent rollout audit (WP-07)**: The observational benchmark now compares canonical Node, legacy file-based CLI, compact stdin/profile CLI, and the development session example while verifying accepted/rejected text, comment preservation, independent batch permutations, recovery behavior, and cross-author attribution. The checked run records 82.75% fewer ordinary instruction words, one fewer shell tool turn (33.33%), and 82.22–89.96% smaller localized session requests than canonical Node envelopes without claiming unmeasured provider/model latency.
282
+ - **Explicit paragraph restoration (`type: 'restore'`)**: Restores or counterproposes another reviewer's pending whole-paragraph deletion as a separately tracked sibling paragraph. The source deletion remains untouched; the restored paragraph receives its own inserted paragraph mark, content insertion, sanitized paragraph properties, and fresh `w14:paraId`. Single paragraphs and contiguous ranges are supported, with full Accept/Reject lifecycle verification and structured refusals at unsafe table-row, move, section-break, and terminal-paragraph boundaries.
283
+ - **Compact mutation CLI contract (WP09b)**: CLI contract version 3 removes `documentXml`, OOXML/package artifacts, full inspection data, and full validation issue arrays from normal `apply`, `accept`, `reject`, and `delete-comments` stdout. Mutation responses retain actionable errors, per-operation receipts, output durability fields, code/count validation summaries, and a derived `completion` flag that cannot report success for failed, partial, or unwritten work.
284
+ - **Word-native deleted-section editing (WP09e)**: An explicit rejected-view `insert` operation can split a foreign deletion at an exact anchor-relative offset into sibling `del(A) / ins(B) / del(A)` carriers. Contiguous paragraph restorations now follow their untouched deleted source block, matching Microsoft Word's ordering. Ambiguous anchors and unsupported structural split boundaries remain fail-closed.
285
+
286
+ ## 0.5.1
287
+
288
+ ### Highlights & New Features
289
+
290
+ - **Cross-Author Revision Slicing (`existingRevisions: 'slice-cross-author'`)**: Adds native support for editing text inside another reviewer's pending tracked insertion without erasing their attribution or requiring prior acceptance.
291
+ - **Word-Native Insertion Slicing**: When inserting text inside another author's pending `<w:ins>`, the engine splits the outer carrier into sibling `<w:ins>` elements at the paragraph level (`[ins(A), ins(B), ins(A)]`), ensuring strict ECMA-376 schema compliance without illegal `ins/ins` nesting.
292
+ - **Word-Native Deletion Slicing**: When deleting text inside another author's pending `<w:ins>`, the engine nests `<w:del>` directly inside `<w:ins>` per ECMA-376 Part 1 `CT_RunTrackChange` Section 17.13.5.21 and Microsoft Word Desktop 365 native behavior.
293
+ - **Boundary & Straddle Deletions**: Deletions straddling baseline text and pending insertions cleanly partition into separate top-level and nested `<w:del>` containers while sharing unified event/author attribution.
294
+ - **Multi-Author Stacked Revisions**: Multiple reviewers can independently delete or insert content within the same carrier insertion without cross-author interference.
295
+ - **Cascading & Coalescing Lifecycles**: Full round-trip lifecycle parity with Microsoft Word Desktop:
296
+ - Rejecting Author A cleanly discards Author A's insertion and any dependent nested deletions by Author B.
297
+ - Accepting Author A unwraps the insertion into baseline text while leaving Author B's deletions pending against the baseline.
298
+ - Rejecting Author B restores Author B's deleted text within Author A's insertion, and coalesces adjacent split `<w:ins>` fragments back into a single continuous carrier.
299
+ - **CLI & Facade Integration**: Fully exposed via the `docx-redline` CLI (`--existing-revisions slice-cross-author`), Node facade (`openDocx`), and batch operation runner.
300
+
301
+ ### Non-breaking Changes & Improvements
302
+
303
+ - **Validation Update (`validateRedlineOoxml`)**: Refined `NESTED_REVISION` checks to permit direct `<w:ins><w:del>...</w:del></w:ins>` nesting (standard ECMA-376 and Word Desktop behavior), while continuing to strictly reject `ins/ins`, `del/del`, and `del/ins` nesting.
304
+ - **Slicing Round-Trip Guard**: Cross-author surgical edits now preserve whitespace-only insertions (including ordinary-space replacements for NBSP characters beside hyperlinks) and verify the exact accepted-view text before reporting success. A mismatch fails closed with `PATCH_ROUNDTRIP_MISMATCH` and returns the original OOXML unchanged.
305
+ - **Hyperlink-Adjacent Replacement Anchoring**: Paired replacements immediately before or after a hyperlink now retain a stable insertion point after the deletion run is split, preventing qualifiers from being relocated past the hyperlink or following formatted runs.
306
+ - **Multiple Same-Run Insertions**: Insertion-only slicing operations with multiple edit points now apply from right to left against a refreshed live span index, preventing an earlier run split from relocating later insertions.
307
+ - **Insertion Stress Hardening**: Slicing now detects edge whitespace changes exactly, uses a character-local insertion-only diff when the original text is an exact subsequence of the modified text, and coalesces new text into an existing same-author carrier when foreign revisions are also present. This prevents repeated phrases from relocating insertions and prevents invalid `w:ins/w:ins` nesting in mixed-author paragraphs.
308
+ - **Preflight Inspection**: `preflightOperations` now inspects and validates `slice-cross-author` batches, reporting pending foreign-author carrier targets as `ready` instead of `EXISTING_REVISIONS`.
309
+ - **Test Suite Expansion**: Added 7 new test suites covering 36 Word Desktop COM golden fixtures, carrier splitting invariants, the SYN-01..12d synthetic test matrix, PKG-01..06 strict package differential replay, the repeated-text/hyperlink whitespace regression, 76 deterministic insertion stress scenarios, and 12 replacement-anchor lifecycle scenarios (expanding the suite from 88 to 95 passing suites).
310
+
311
+ ## 0.5.0
312
+
313
+ ### ⚠️ Breaking changes
314
+
315
+ The following changes can require caller or contributor updates. No public
316
+ export or valid existing function signature was removed.
317
+
318
+ #### Runtime and result-contract changes
319
+
320
+ - **Canonical paragraph text:** `getParagraphText(...)` now returns the
321
+ accepted/current view instead of the earlier simplified `w:t`/`w:tab`
322
+ concatenation. It excludes deleted and `w:moveFrom` content and includes
323
+ structural breaks, soft hyphens, and non-breaking hyphens.
324
+ **Migration:** regenerate compared/cached text with the upgraded library. Use
325
+ `extractCanonicalParagraphText(...)` when accepted/rejected-view semantics
326
+ are intended; integrations that require the former raw traversal must retain
327
+ their own legacy extractor before upgrading.
328
+ - **Paragraph fingerprints:** fingerprints now incorporate canonical paragraph
329
+ text. Stored fingerprints can become stale for paragraphs containing
330
+ revisions, moves, breaks, soft hyphens, or non-breaking hyphens.
331
+ **Migration:** do not carry fingerprints across this upgrade; re-extract the
332
+ document and regenerate target descriptors.
333
+ - **Invalid operations:** malformed or field-incompatible document-operation
334
+ objects now return a structured `INVALID_OPERATION` error at the runner
335
+ boundary instead of reaching later failure/no-op paths.
336
+ **Migration:** validate operation files against the published schema and
337
+ handle `status === 'error'` plus `error.code === 'INVALID_OPERATION'`.
338
+ - **Commented paragraph deletion:** deleting a complete paragraph that contains
339
+ an existing comment now fails with `COMMENTED_CONTENT_DELETE` instead of
340
+ producing OOXML with dangling comment references.
341
+ **Migration:** preserve or deliberately remove/relocate the comment before
342
+ deleting the paragraph, and handle the structured error. Atomic callers keep
343
+ the original document unchanged.
344
+ - **Comment anchor failures:** missing or ambiguous comment anchors now return
345
+ `ANCHOR_NOT_FOUND` or `AMBIGUOUS_ANCHOR` and fail/roll back an atomic batch;
346
+ they are no longer reported as successful `no_change` operations.
347
+ **Migration:** treat these codes as failed operations and use a unique exact
348
+ anchor or stricter target descriptor before retrying.
349
+ - **Stricter package validation:** DOCX package validation now rejects
350
+ unbalanced comment ranges, dangling references/usages, orphan definitions,
351
+ and duplicate comment-definition IDs that earlier validation could allow.
352
+ **Migration:** repair the comment anchors and `word/comments.xml` definitions
353
+ before applying or validating further changes.
354
+
355
+ #### Development workflow change
356
+
357
+ - **Parallel tests by default:** `npm test` now runs up to four isolated child
358
+ processes concurrently. This does not change the published runtime API, but
359
+ contributor automation that depends on test execution order or shared files
360
+ must be updated. **Migration:** make tests independent or set
361
+ `DOCX_TEST_CONCURRENCY=1` for the previous serial scheduling behavior.
362
+
363
+ Strict targeting remains opt-in on existing low-level mutation APIs; it is the
364
+ default only on the newly added Node facade and CLI.
365
+
366
+ ### Deprecations and future breaking changes
367
+
368
+ - Replacing an existing numbering part without a merge callback now emits a
369
+ deprecation warning. The Node facade and CLI already merge safely by default.
370
+ **This remains supported in this release but will become an error in the next
371
+ major version.** Migrate low-level callers to
372
+ `mergeNumberingXmlBySchemaOrder` before that release.
373
+ - **Permissive target resolution deprecation (`AMBIGUOUS_TARGET_HEURISTIC_USED`):**
374
+ Lower-level document operation runners currently default to permissive targeting.
375
+ In v1.0.0, application will default to `strictTargets: true`. In this release,
376
+ when permissive resolution encounters multiple identical candidate paragraphs and
377
+ heuristically chooses the first candidate, it emits an `AMBIGUOUS_TARGET_HEURISTIC_USED`
378
+ warning with candidate count and migration guidance.
379
+ **Migration:** Disambiguate operations using `paragraphId`, `index`, `occurrence`,
380
+ or `fingerprint` and pass `{ strictTargets: true }`.
381
+
382
+ ### ℹ️ Noteworthy Default & Usability Changes (Non-breaking)
383
+
384
+ The following improvements update default behaviors to maximize agent speed, reduce friction, and eliminate unnecessary errors during iterative editing. These changes are **not technically breaking changes** (no public APIs or exports were removed, and all existing options remain configurable), but represent important behavioral refinements that callers should note:
385
+
386
+ - **Fallback Author Default (`'AI Redliner'`):** `setDefaultAuthor`, `node/cli.js`, and `openDocx` now default to `'AI Redliner'` (configurable via the `DOCX_REDLINE_AUTHOR` environment variable or `--author`). The CLI `apply` command and core APIs no longer error with `AUTHOR_REQUIRED` when operations omit an author.
387
+ - **Output Overwrite by Default:** Destination files provided via `--output` now overwrite by default instead of failing with `OUTPUT_EXISTS`. Callers wanting protection against accidental overwrites can pass `--no-overwrite` or `--no-clobber`. The source document remains protected and is never overwritten unless `--in-place` is explicitly passed.
388
+ - **Replacement Event Pairing (`pairReplacements: true` by default):** Adjacent `<w:del>` and `<w:ins>` revisions now default to sharing linked revision metadata and identical timestamps so Microsoft Word groups them as a single replacement in the Reviewing Pane. Pass `pairReplacements: false` for independent revision timestamps.
389
+ - **Structured Content Auto-Detection (`structuredContent: true` by default):** Markdown tables, headings (`#`), and lists in replacement text automatically render as native Word elements (`w:tbl`, `w:pStyle`, `w:numPr`). Single outline-numbered legal clauses (e.g. `13.2.1.1`) continue to be treated as ordinary paragraphs without spurious list conversion. Pass `structuredContent: false` to treat replacement text strictly as plain text.
390
+ - **Progressive Batch Mode (`atomic: false` default, `atomic: true` opt-in):** Batch operations and CLI `apply` now apply edits progressively by default (`atomic: false`): valid edits commit directly, while failing edits report structured errors in `results` for faster debugging. Pass `{ atomic: true }` (or `--atomic` on the CLI) for all-or-nothing rollback when any operation fails.
391
+ - **Clean Direct Edits (`generateRedlines: false` / `--no-redlines`):** Prominently documented that tracked redlines are not always the preferred method. Callers can pass `generateRedlines: false` (or `--no-redlines` on the CLI) for clean execution drafts, document restructuring, or minor typo fixes without tracked changes markup.
392
+ - **Existing Revisions Policy (`existingRevisions: 'merge-same-author'` by default):** When editing a paragraph that already contains tracked changes from the same author, prior revisions by that author are merged against the pre-revision baseline (prior changes by that author are reverted and re-diffed to the new modified text), avoiding revision accumulation and nested markup. If a paragraph contains tracked changes from another reviewer, the operation fails closed with `EXISTING_REVISIONS` to protect third-party review marks. Commented revision content fails closed with `COMMENTED_CONTENT_MERGE` so comment anchors cannot be removed or orphaned. Callers can explicitly pass `'accept-all-first'` to normalize prior revisions or `'reject-input'` to refuse editing any revised paragraph.
393
+ - **Inline One-Liner CLI Edits:** Added `--target <text>` with `--modified <text>` or `--comment <text>` on `docx-redline apply` for fast 1–2 edit workflows without creating a JSON operations file.
394
+
395
+ ### Added
396
+
397
+ - Added **Mutation Receipts** (`receipt` on `DocumentOperationResult` and `receipts`
398
+ on `BatchOperationResult`). Every operation execution returns structured,
399
+ commit-aware telemetry capturing durable revision IDs (with kind and target part),
400
+ comment IDs, numbering IDs, relationship IDs, affected targets, and warnings.
401
+ Supports `not_attempted`, `applied`, `refused`, `no_change`, and `rolled_back`
402
+ dispositions.
403
+ - Added **Commit-Aware Output Reconciliation Oracle** (`reconcileReceiptsAgainstOutput`).
404
+ Before completing any transaction, reported durable IDs are checked against a
405
+ fresh parse of the generated output OOXML parts. Any reconciliation discrepancy
406
+ immediately fails the transaction and triggers atomic rollback.
407
+ - Exported receipt primitives: `ReceiptCollector`, `createEmptyReceipt`, and
408
+ `reconcileReceiptsAgainstOutput` along with `MutationReceipt` and
409
+ `MutationReceiptRevisionItem` TypeScript declarations.
410
+ - Added **Paragraph Mark Revisions** (`w:pPrChange`, `markParagraphMarkInserted`,
411
+ `markParagraphMarkDeleted`) ensuring whole-paragraph deletions and insertions
412
+ cleanly track paragraph mark lifecycles for full Accept All / Reject All symmetry.
413
+ - Added **Paragraph Boundary Mutation Validation** (`validateParagraphBoundaryMutation`)
414
+ guarding against invalid cross-paragraph boundary merges.
415
+
416
+ - Added `analyzeStructuredContent(...)` and `planStructuredReplacement(...)`
417
+ for agent-authored attachments and schedules containing mixed headings,
418
+ paragraphs, lists, and tables. The planner returns typed blocks and produces
419
+ one atomic `structuredContent` operation only when the Markdown is valid.
420
+
421
+ - Added session-scoped paragraph metadata indexing for canonical text,
422
+ normalized text, paragraph IDs, fingerprints, table context, and document
423
+ indexes, plus deterministic targeting and route-profiling benchmarks.
424
+ - Added a shared list-marker grammar and parsed list-item vocabulary used by
425
+ pipeline analysis, orchestration, normalization, and list targeting.
426
+ - Added an internal reconciliation capability matrix and opt-in route
427
+ instrumentation. Public reconciliation result shapes and route selection
428
+ policy remain unchanged.
429
+
430
+ - Added `scripts/extract_text.mjs` and `scripts/apply_changes.mjs` as thin
431
+ compatibility entrypoints for legacy skill installations. They delegate to
432
+ the supported CLI, retain strict atomic validated writes, and accept legacy
433
+ operation files with a top-level `changes` array.
434
+ - Added typed operations, per-operation authors, strict target descriptors,
435
+ deterministic preflight diagnostics, and auditable resolution metadata.
436
+ - Added `inspectDocumentParts(...)`, a structured document inventory using the
437
+ same canonical text extractor as targeting and ingestion.
438
+ - Added `@ansonlai/docx-redline-js/node`. `openDocx(...)` applies batches to
439
+ complete DOCX buffers transactionally and validates before commit.
440
+ - Added the cross-platform `docx-redline` CLI with JSON `inspect`, `extract`,
441
+ `preflight`, `apply`, `accept`, `reject`, `delete-comments`, and `validate`
442
+ commands, plus a published operation-file JSON Schema.
443
+
444
+ ### Behavior and reliability
445
+
446
+ - Explicit structured replacements now reject missing Markdown table separator
447
+ - Generated Markdown tables repeat their header row and prevent logical data rows from splitting across pages.
448
+ rows, missing data rows, and inconsistent column counts with
449
+ `STRUCTURED_CONTENT_INVALID` instead of inserting literal pipe-delimited text.
450
+ - Tables created inside mixed replacements are tracked once at block scope,
451
+ avoiding nested revisions while keeping Accept All and Reject All symmetric.
452
+
453
+ - Target preflight and live mutation reuse one document-scoped paragraph index;
454
+ strict duplicate detection and resolution metadata retain their prior
455
+ semantics while avoiding repeated whole-document text traversal.
456
+ - Revision-ID seeding now walks the DOM with child/sibling pointers instead of
457
+ allocating an array containing every element.
458
+ - Single-source-paragraph list expansion uses the focused list generator
459
+ directly. Multi-paragraph marked-list edits deliberately retain the legacy
460
+ run-aware reconciliation pipeline for structural parity.
461
+ - Fixed paragraph-to-list expansion when a manually numbered heading carries
462
+ `w:numId w:val="0"`. Numbering suppression is no longer reused as a generated
463
+ list ID, so inserted bullet and numbered items receive valid positive IDs.
464
+ - Tracked heading-to-list replacements now keep the deleted source heading in
465
+ its own paragraph and track the paragraph marks of every inserted list item.
466
+ This prevents deleted heading text from joining the first item and preserves
467
+ exact Accept/Reject structure without adding a full-document sentinel
468
+ paragraph.
469
+ - Inserted list items now inherit source font family, size, language, and
470
+ related script typography without inheriting heading-only bold, underline,
471
+ italic, or strike formatting unless requested by the replacement markdown.
472
+ - Canonical-only table-cell targeting now consumes the shared paragraph-text
473
+ extractor, while offset- and sentinel-producing walkers remain specialized.
474
+ Their accepted visible projections now agree on soft hyphens as well as tabs,
475
+ breaks, hyperlinks, and non-breaking hyphens.
476
+
477
+ - Comment preflight and application now share one anchor resolver. Exact
478
+ matches take priority, unique ordinary-space/NBSP differences preserve raw
479
+ offsets, and missing or repeated anchors return structured
480
+ `ANCHOR_NOT_FOUND` or `AMBIGUOUS_ANCHOR` errors.
481
+ - Full-document operation batches now share one live DOM and revision-ID
482
+ allocator, reducing complete-document parsing and serialization from once per
483
+ operation to once per changed batch. Scoped reconciliation engines and their
484
+ targeting decisions are unchanged.
485
+ - Each live-session operation uses a DOM and allocator savepoint. Errors and
486
+ reported no-ops restore the savepoint; atomic failures and all-no-op batches
487
+ still return the exact original XML without serializing it.
488
+ - Decomposed the standalone document-operation runner into a stable 13-line
489
+ compatibility facade plus focused session, applier, batch-orchestrator,
490
+ heuristic, and OOXML-mutation modules. Runtime exports and declarations are
491
+ unchanged, and operation internals now use leaf imports instead of importing
492
+ the root entry point.
493
+ - Package comment IDs are seeded from existing anchors and definitions, and
494
+ the Node facade merges numbering without discarding prior definitions.
495
+ - Canonical paragraph text consistently handles revisions, moves, tabs,
496
+ breaks, soft hyphens, and non-breaking hyphens; see the breaking-change note
497
+ above for `getParagraphText(...)` and fingerprint compatibility.
498
+ - Structured inspection now explicitly supports the `current` view as the
499
+ accepted/current document view and resolves comment ranges spanning multiple
500
+ paragraphs as one exact anchor string.
501
+ - Transactional no-op results preserve the original DOCX bytes exactly,
502
+ including when the same facade instance has already committed an edit.
503
+
504
+ ### Testing and development
505
+
506
+ - Added focused and semantic visual-failure regressions for suppressed
507
+ numbering, paragraph separation, paragraph-mark revisions, selective
508
+ typography inheritance, and exact accepted/rejected paragraph sequences,
509
+ plus seeded fuzz variants across list length, marker, font, and size.
510
+ Added the independently specified
511
+ `legal-suppressed-heading-to-bullet-list` and
512
+ `legal-structured-attachment-mixed-blocks` Microsoft Word differential
513
+ fixtures; the synthetic catalogue now contains 49 cases and 49 task types.
514
+
515
+ - The JavaScript test runner now uses bounded asynchronous subprocess workers,
516
+ capped at four by default, while retaining one fresh Node process per file,
517
+ sorted reporting, timeouts, captured diagnostics, and failure-marker checks.
518
+ Set `DOCX_TEST_CONCURRENCY=1` for serial reproduction.
519
+ - Added `npm run benchmark:tests` and a Phase 6 runner regression. The checked
520
+ benchmark reduced median suite time from 18.02 seconds to 7.96 seconds
521
+ (55.80%); 20 consecutive parallel runs and a separate serial run passed all
522
+ 63 files. Parallel c8 collection remains valid at 89.90% statements/lines,
523
+ 77.40% branches, and 93.10% functions.
524
+
525
+ - Added Phase 3 targeting/traversal, Phase 4 list/text parity, and Phase 5 route
526
+ compatibility regressions. Together with the Phase 6 runner regression, the
527
+ suite now contains 63 passing test files.
528
+ - Added `npm run benchmark:targeting` and `npm run profile:routes`. The checked
529
+ 10,000-paragraph benchmark showed no single-operation regression and a 47.16x
530
+ Node median improvement for 100 cached resolutions. The equivalent native
531
+ Chrome benchmark showed no single-operation regression and a 36.45x batch
532
+ improvement. All 47 Microsoft Word differential fixtures and all 60 real-
533
+ document Word corpus scenarios passed after the routing changes.
534
+
535
+ - Added subprocess coverage for legacy wrapper selection, operation-file
536
+ compatibility, successful output, atomic anchor failure, source-byte
537
+ preservation, and protection of pre-existing output files.
538
+ - Added a live-session accuracy and instrumentation suite covering accepted and
539
+ rejected text, structural validity, sequential equivalence, comments, lists,
540
+ tables, highlights, one-parse/one-serialize execution, exact no-ops, and
541
+ atomic rollback. Added `npm run benchmark:session`; the checked accuracy-first
542
+ benchmark reduced parse/serialize counts from 10/10 to 1/1 and measured a
543
+ 1.58x median speedup with per-operation savepoints retained.
544
+ - Added a Phase 2 architecture regression covering facade export identity,
545
+ direct leaf imports, exact session rollback, isolated context commit, and
546
+ stable comment-first scheduling.
547
+ - Added five edge-case suites for canonical text views, cross-paragraph comment
548
+ inspection, table/list/reference context, sequential package transactions,
549
+ selective multi-author cleanup, ZIP rejection behavior, CLI filters, JSON
550
+ exit contracts, and destructive-output safeguards. Together with the Phase 2
551
+ Phase 1 and Phase 2 regressions, these established the earlier 57-file
552
+ baseline expanded by the subsequent performance phases.
553
+
554
+ ## 0.3.0
555
+
556
+ ### Breaking changes
557
+
558
+ - Malformed OOXML no longer escapes public transform APIs as a raw parser
559
+ exception. In particular, revision accept/reject and comment-deletion callers
560
+ that previously used `try`/`catch` must now inspect `status === 'error'` and
561
+ `error.code === 'PARSE_ERROR'` on the returned result.
562
+ - Caller content is no longer sanitized by default. Pass `sanitizeInput: true`
563
+ to remove a standalone leading assistant-preface line. Dollar-delimited text
564
+ and literal `\\n` / `\\r\\n` sequences are never removed implicitly.
565
+ - The exported `sanitizeAiResponse` helper no longer removes dollar-delimited
566
+ spans or converts literal `\\n` / `\\r\\n` sequences. Direct callers that
567
+ relied on those transformations must perform them explicitly.
568
+ - `applyOperationsToDocumentXml` is atomic by default. Failed batches return
569
+ the original document with `rolledBack: true`; pass `atomic: false` to retain
570
+ partial-result behavior.
571
+ - Missing multi-line targets now return `TARGET_NOT_FOUND` instead of being
572
+ indistinguishable from a no-op. Stale batch anchors also return
573
+ `TARGET_NOT_FOUND` instead of falling back to a visibly different paragraph.
574
+
575
+ ### Behavior changes and fixes
576
+
577
+ - Revision IDs are now allocated per document. Near-limit prior IDs restart in
578
+ a safe low range, and unrelated bookmark/relationship IDs no longer seed the
579
+ revision counter.
580
+ - Concurrent calls with explicit authors keep their revision attribution
581
+ isolated from process-global defaults.
582
+ - `existingRevisions: 'accept-all-first'` now preserves the original OOXML when
583
+ the requested edit is a no-op.
584
+ - Added `existingRevisions: 'accept-all-first-keep-normalized'` for callers that
585
+ explicitly want accepted existing revisions returned even when no redline is
586
+ added.
587
+ - Diff output is deterministic by default. Inputs exceeding 262,144 unique
588
+ tokens return `DIFF_TOKEN_LIMIT` with the original OOXML unchanged instead of
589
+ risking truncated text; leading whitespace is preserved exactly.
590
+ - Reconstruction preserves structural line breaks and body section-property
591
+ placement. A target that names only part of a reconstruction range now
592
+ returns `PARTIAL_TARGET` instead of risking deletion of untargeted content.
593
+ - Paragraph targeting and reconstruction now preserve leading, middle, and
594
+ trailing `w:tab` elements as literal tab characters instead of omitting or
595
+ trimming them.
596
+ - Adjacent redline edits now preserve complex-field instructions, begin/
597
+ separate/end markers, and unchanged cached display results in their original
598
+ field boundary. Field instructions remain inert and are not evaluated.
599
+ - Added structured XML parse results and result-returning ingestion helpers.
600
+ - Hardened deterministic diff token handling and leading-whitespace fidelity.
601
+
602
+ ### Testing and development
603
+
604
+ - Expanded the desktop Word differential from 20 to 25 cases, adding structural
605
+ checks for bookmarks, internal hyperlinks, mixed formatting, content
606
+ controls, and tables.
607
+ - Expanded the desktop Word differential from 25 to 28 cases with structural
608
+ tabs and a locked PAGE field, and added tab/field shapes to focused and fuzz
609
+ regression testing.
610
+ - Expanded the desktop Word differential from 28 to 33 cases with comments,
611
+ footnotes, endnotes, headers/footers, and an external hyperlink.
612
+ - Extended the deterministic script-only DOCX packager with opt-in related
613
+ parts, relationship/content-type validation, reusable fixture constructors,
614
+ and SHA-256 verification that supplied parts remain byte-identical. Runtime
615
+ library code and dependencies are unchanged.
616
+ - Added validated task, structure, oracle, and manual-review metadata across the
617
+ 33 synthetic and 20 SuperDoc Word cases. `npm run report:word:coverage`
618
+ produces a deterministic coverage matrix with explicit high-priority gap
619
+ dispositions, while `npm run review:word:prepare` creates a pending rotating
620
+ human-review manifest without self-certifying visual results.
621
+ - Added detailed production-function coverage reporting and a checked per-file
622
+ regression baseline. Five behavior-focused Phase 3 suites exercise numbering
623
+ collisions/remapping, every reconciliation route, list construction and
624
+ fallback, patch/format boundaries, table decisions, pipeline modes, and
625
+ standalone rollback/highlight paths. Production function coverage moved from
626
+ 437/540 to 496/542 and all reachable P0 functions are covered; no runtime
627
+ behavior or compatibility contract changed.