@ansonlai/docx-redline-js 0.8.0 → 0.8.2
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 +553 -486
- package/README.md +331 -309
- package/dist/docx-redline-js.esm.js +1209 -168
- package/dist/docx-redline-js.esm.js.map +4 -4
- package/dist/docx-redline-js.esm.min.js +107 -107
- package/dist/docx-redline-js.esm.min.js.map +4 -4
- package/dist/docx-redline.bundle.cjs +1209 -168
- package/dist/docx-redline.bundle.cjs.map +4 -4
- package/dist/docx-redline.bundle.js +1209 -168
- package/dist/docx-redline.bundle.js.map +4 -4
- package/docs/AGENT_KNOWLEDGE_BASE.md +69 -8
- package/docs/schemas/document-operations.schema.json +29 -0
- package/document/docx-document.js +416 -22
- package/engine/reconstruction-mode.js +183 -54
- package/engine/reconstruction-writer.js +18 -0
- package/index.d.ts +598 -575
- package/index.js +349 -348
- package/node/cli-help.js +5 -5
- package/node/cli.js +760 -754
- package/node/index.d.ts +1 -1
- package/package.json +2 -1
- package/pipeline/diff-engine.js +274 -258
- package/scripts/generate-word-comment-edge-case-fixture.ps1 +58 -0
- package/scripts/generate-word-comment-thread-fixture.ps1 +36 -0
- package/scripts/generate-word-header-footer-fixture.ps1 +32 -0
- package/scripts/generate-word-multi-section-fixture.ps1 +27 -0
- package/scripts/generate-word-package-integrity-cases.mjs +141 -0
- package/scripts/generate-word-thread-state-fixtures.ps1 +50 -0
- package/scripts/run-tests.mjs +14 -2
- package/scripts/word-com-package-integrity.ps1 +98 -0
- package/services/batch-operation-orchestrator.js +262 -259
- package/services/comment-replies.js +96 -95
- package/services/comment-thread-parts.js +280 -0
- package/services/document-inspection.js +366 -365
- package/services/document-operation-applier.js +230 -202
- package/services/document-operation-contract.js +17 -2
- package/services/error-recovery.js +6 -0
- package/services/headers-footers.js +206 -0
- package/services/operation-batch-compiler.js +1 -0
- package/services/operation-preflight.js +231 -218
- package/services/package-parts.js +80 -0
- package/services/standalone-docx-plumbing.js +631 -569
- package/services/standalone-operation-runner.d.ts +19 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,486 +1,553 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- **
|
|
8
|
-
|
|
9
|
-
`
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- **
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
- **
|
|
83
|
-
`
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
- **
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
- **
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
-
|
|
135
|
-
|
|
136
|
-
-
|
|
137
|
-
|
|
138
|
-
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
## 0.
|
|
146
|
-
|
|
147
|
-
###
|
|
148
|
-
|
|
149
|
-
- **
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
- **
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
- **
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
- **
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
- **
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
- **
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
- **
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
- **
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
- **
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
-
|
|
316
|
-
|
|
317
|
-
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
plus
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Replacement next to a hyperlink no longer pulls adjacent plain text into the link** ([#3](https://github.com/AnsonLai/docx-redline-js/issues/3)):
|
|
8
|
+
replacing `example.org` with `example.net` (localized `replacements` or full `modified`) in a hyperlink followed by a
|
|
9
|
+
plain `.` run produced a link showing `example.net.` after Accept All. The reconstruction-mode word diff treated
|
|
10
|
+
`example.org.` as one token spanning the hyperlink edge. Where a replacement's shared prefix or suffix reaches a wrapper
|
|
11
|
+
boundary inside the deleted text, it is now kept unchanged.
|
|
12
|
+
- **Reject All no longer reorders text around a manual line break** ([#4](https://github.com/AnsonLai/docx-redline-js/issues/4)):
|
|
13
|
+
replacing `tabbed` with `aligned` in `<tab>tabbed<w:br/>Line with ` rejected to `<tab>tabbedLine<break> with `, moving
|
|
14
|
+
deleted text across the break. Break and note-reference placeholders are now standalone word-diff tokens (new internal
|
|
15
|
+
`atomicChars` option), and change groups are split at references present on both sides. Covered by `tests/reconstruction_boundary_fidelity_tests.mjs`.
|
|
16
|
+
|
|
17
|
+
## 0.8.1
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **Header and footer editing:** add `part` to an operation (a selector `{ kind, type?, section? }` or a part path) to edit a
|
|
22
|
+
header or footer; `inspect().headersFooters` lists the parts with their text, the sections they apply to (including
|
|
23
|
+
inherited ones) and whether they contain fields. Body edits are unchanged and headers/footers are opt-in. Fields such as
|
|
24
|
+
PAGE are atomic (`FIELD_EDIT_REFUSED`), comments are refused (`COMMENT_IN_HEADER_FOOTER`), bad selectors fail closed
|
|
25
|
+
(`PART_NOT_FOUND`, `PART_AMBIGUOUS`), atomic batches roll back across body and parts, revision ids stay unique across the
|
|
26
|
+
package, receipts name the part, `accept`/`reject` also resolve revisions inside headers and footers, and
|
|
27
|
+
`validateDocxPackage` checks header/footer references, relationships and content types.
|
|
28
|
+
- **Resolve and reopen comment threads:** `doc.resolveComment(id, { resolved })` and the batch operation
|
|
29
|
+
`{ "type": "comment_resolve", "commentId": "0", "resolved": true }`, so the CLI can resolve through `apply --operations`.
|
|
30
|
+
Word resolves whole threads, so the root and every reply change together, whichever id is given. Only
|
|
31
|
+
`word/commentsExtended.xml` changes; `document.xml` stays byte-identical. Unknown ids fail with `COMMENT_NOT_FOUND`
|
|
32
|
+
(also in `preflight`).
|
|
33
|
+
- **Delete comments by id:** `doc.deleteComments({ ids })` and `docx-redline delete-comments --comment-id 3,4`. Deleting a
|
|
34
|
+
thread root also deletes its replies; unknown ids fail closed with `COMMENT_NOT_FOUND`.
|
|
35
|
+
- CLI capabilities `comment-resolve-operation-v1`, `delete-comments-by-id-v1` and `header-footer-parts-v1` (additive; the
|
|
36
|
+
contract version is unchanged).
|
|
37
|
+
- `services/package-parts.js`, a registry of package part paths, content types and relationship types checked against
|
|
38
|
+
Word-saved fixtures (`tests/fixtures/word-authored/`), and `npm run test:word:package`, which opens generated outputs in
|
|
39
|
+
real Word with repair disabled and checks comment counts, thread parents, resolved state and header/footer revisions
|
|
40
|
+
through Word's object model.
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- **Word "unreadable content" prompt on commented documents:** `word/commentsExtended.xml` was relabeled
|
|
45
|
+
`application/vnd.ms-word.commentsExtended+xml` on every save of any document that already had comments.
|
|
46
|
+
Word expects `application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml` and
|
|
47
|
+
offered to repair the file. The constant is corrected, an edit that does not change comment threading no
|
|
48
|
+
longer rewrites the extended part or its content type/relationship, and files already damaged by earlier
|
|
49
|
+
versions are repaired on the next save (`repairKnownContentTypes`, also exported). `validateDocxPackage`
|
|
50
|
+
now rejects the wrong type instead of accepting it. `tests/package_content_type_contract_tests.mjs` checks this
|
|
51
|
+
against a Word-authored content-type table on every OS.
|
|
52
|
+
- **Comment threads keyed on the last paragraph:** Word joins `comments.xml` to `commentsExtended.xml` and
|
|
53
|
+
`commentsIds.xml` through the `w14:paraId` of a comment's LAST paragraph. Inspection, package validation,
|
|
54
|
+
replies and delete-cascade used the first, so Word's own multi-paragraph threaded documents failed
|
|
55
|
+
validation and replies to them attached to the wrong key.
|
|
56
|
+
- **Edits no longer drop comment anchors:** a mid-paragraph edit of a commented paragraph dropped the trailing
|
|
57
|
+
`commentRangeEnd` and `commentReference` (markers at the very end of the paragraph text were only emitted when the
|
|
58
|
+
last diff part was an insert), leaving the comment unanchored and failing package validation. Found by
|
|
59
|
+
opening our output in real Word; covered by `tests/comment_marker_preservation_tests.mjs`.
|
|
60
|
+
- **Replies are now visible in Word:** `comment_reply` only wrote `comments.xml`/`commentsExtended.xml`, and Word
|
|
61
|
+
does not show a reply that has no body markers. Replies now get their own `commentRangeStart`/`commentRangeEnd`/
|
|
62
|
+
`commentReference` next to the thread's, laid out like Word writes them. A reply to a reply joins the root thread.
|
|
63
|
+
A parent with no body anchor fails with `PARENT_ANCHOR_NOT_FOUND`.
|
|
64
|
+
- **Replies to a resolved thread are resolved too**, as Word writes them (`reply-to-resolved.docx` fixture). They were
|
|
65
|
+
written open, leaving a thread that was half resolved.
|
|
66
|
+
- `commentsIds.xml` and `commentsExtensible.xml` are kept consistent with `comments.xml` on add/delete when present.
|
|
67
|
+
- `deleteComments` and `resolveRevisions` report `artifactsChanged` from a real diff of the package (they listed a fixed
|
|
68
|
+
set of parts and missed `commentsIds.xml`, `commentsExtensible.xml` and `[Content_Types].xml`).
|
|
69
|
+
|
|
70
|
+
## 0.8.0
|
|
71
|
+
|
|
72
|
+
### Universal Document Facade & Zero-Node Architecture
|
|
73
|
+
|
|
74
|
+
- **Universal `DocxDocument` & `openDocx`:** Implemented complete-DOCX lifecycle operations
|
|
75
|
+
(`openDocx`, `doc.inspect()`, `doc.applyOperations()`, `doc.resolveRevisions()`, `doc.deleteComments()`,
|
|
76
|
+
`doc.toUint8Array()`, `doc.getRevisionToken()`) on standard `Uint8Array` in `document/docx-document.js`,
|
|
77
|
+
re-exported directly from `index.js`. Enables complete-document redline workflows in any JavaScript
|
|
78
|
+
runtime without Node.js dependencies.
|
|
79
|
+
- **Pure-JS ZIP container (`fflate`):** Replaced `node:zlib` with lightweight, zero-dependency `fflate`
|
|
80
|
+
in `document/zip-archive.js`, providing cross-runtime raw DEFLATE / INFLATE compression and decompression
|
|
81
|
+
with full OOXML archive compatibility.
|
|
82
|
+
- **Pure-JS FIPS 180-4 SHA-256:** Created zero-dependency, synchronous SHA-256 implementation in
|
|
83
|
+
`core/sha256.js`, removing `node:crypto` from package revision token calculations while retaining
|
|
84
|
+
exact deterministic hash parity with standard NIST vectors.
|
|
85
|
+
- **Transparent XML DOM fallback:** Added `resolveDomParserConstructor()` and
|
|
86
|
+
`resolveXmlSerializerConstructor()` in `adapters/xml-adapter.js`, automatically utilizing native
|
|
87
|
+
`globalThis.DOMParser`/`globalThis.XMLSerializer` when present and falling back transparently to
|
|
88
|
+
`@xmldom/xmldom` in headless, server, edge, and sandbox environments without requiring manual provider setup.
|
|
89
|
+
- **Zero-dependency sandbox bundles:** Configured `scripts/build.mjs` with `esbuild` (`platform: 'neutral'`)
|
|
90
|
+
to produce single-file, zero-dependency standalone bundles in both ESM (`dist/docx-redline.bundle.js`)
|
|
91
|
+
and CommonJS (`dist/docx-redline.bundle.cjs`), exported as `@ansonlai/docx-redline-js/bundle` for direct
|
|
92
|
+
use in workflow engines (e.g., n8n Code nodes), Cloudflare Workers, AWS Lambda, Deno, and QuickJS sandboxes.
|
|
93
|
+
- **Strict runtime boundary enforcement:** Removed `node:zlib` and `node:crypto` from allowed external
|
|
94
|
+
imports in `tests/no_word_api_index_check.mjs`. Automated sandbox isolation tests
|
|
95
|
+
(`tests/sandbox_bundle_isolation_tests.mjs`) verify zero Node built-in imports and full document
|
|
96
|
+
reconciliation in restricted VM contexts without `process`, `Buffer`, or `require`.
|
|
97
|
+
- **Backward compatibility:** Preserved full API and `Buffer` compatibility for `@ansonlai/docx-redline-js/node`
|
|
98
|
+
consumers and `doc.toBuffer()`.
|
|
99
|
+
|
|
100
|
+
## 0.7.2
|
|
101
|
+
|
|
102
|
+
### Agent Surface Simplification
|
|
103
|
+
|
|
104
|
+
- **Extraction-first golden path:** Re-established the single deterministic two-turn
|
|
105
|
+
"extract-then-apply" sequence as the default agent workflow across `AGENTS.md`,
|
|
106
|
+
`docs/AGENT_FAST_START.md`, and `docs/SKILL_AUTHORING.md`. Eliminates the
|
|
107
|
+
upfront "choice tax" and model deliberation overhead.
|
|
108
|
+
- **Localized replacements after inspection:** Decoupled localized patching from
|
|
109
|
+
speculation. Agents inspect the target paragraph first, then supply compact
|
|
110
|
+
`replacements` instructions, achieving 60.6%–90.8% payload reductions without
|
|
111
|
+
speculative ambiguity risk.
|
|
112
|
+
- **Computed success gate:** Consolidated standard success verification onto
|
|
113
|
+
`completion: true` and non-null `outputPath`, removing multi-field verification
|
|
114
|
+
checklists from primary prompts while retaining full `change` audit evidence.
|
|
115
|
+
- **Advanced features relocated:** Speculative 1-turn apply, directional context
|
|
116
|
+
windows (`--context-range`), and anchor diagnostics are relocated to
|
|
117
|
+
`docs/AGENT_KNOWLEDGE_BASE.md` and CLI help as opt-in harness policies.
|
|
118
|
+
- **Observed-state restoration:** Restructured restoration as a clean request-
|
|
119
|
+
or hint-driven branch (`--view rejected` or `selection.hint`) rather than an
|
|
120
|
+
upfront classification decision.
|
|
121
|
+
- **Empirical surface evaluation:** Added synthetic replay benchmark
|
|
122
|
+
(`npm run benchmark:agent-surface`) and validation report documenting 100%
|
|
123
|
+
first-attempt task correctness and payload savings across three workflow policies.
|
|
124
|
+
|
|
125
|
+
## 0.7.1
|
|
126
|
+
|
|
127
|
+
### Reliability and Discovery Refinements
|
|
128
|
+
|
|
129
|
+
- Localized replacement matching now tries exact case-sensitive text first,
|
|
130
|
+
then a narrow ASCII-space/non-breaking-space equivalent match. Ambiguous
|
|
131
|
+
equivalent matches still fail closed, and unchanged boundary NBSPs are
|
|
132
|
+
retained to avoid incidental whitespace redlines.
|
|
133
|
+
- Added a narrow single-paragraph restore shortcut. A restore with a strong
|
|
134
|
+
rejected-view target may omit `modified` for verbatim restoration or provide
|
|
135
|
+
exact `replacements`; the CLI exposes the same path through `apply --restore
|
|
136
|
+
--target-id ID`. Ranges, captures, weak targets, and inferred companion
|
|
137
|
+
content remain excluded.
|
|
138
|
+
- Fixed rejected-view restore receipts so `resolvedTarget` text, fingerprint,
|
|
139
|
+
revision view, and match diagnostics describe the view actually used to
|
|
140
|
+
resolve the target.
|
|
141
|
+
- Fixed alternate-view search hints to honor `--revised`, `--table`, and
|
|
142
|
+
`--body`, and retained compact revision authors plus `deleted`/`inserted` cues
|
|
143
|
+
in `extract` output so empty revision-view paragraphs are self-explanatory.
|
|
144
|
+
|
|
145
|
+
## 0.7.0
|
|
146
|
+
|
|
147
|
+
### Agent Performance and Localized Editing
|
|
148
|
+
|
|
149
|
+
- **Localized exact replacements:** `redline`/`replace` operations may provide
|
|
150
|
+
`replacements: [{ find, replace, occurrence? }]` instead of a complete
|
|
151
|
+
`modified` paragraph. The compiler resolves the accepted-view source once,
|
|
152
|
+
applies non-overlapping exact replacements simultaneously, synthesizes the
|
|
153
|
+
canonical desired paragraph, and delegates to the unchanged OOXML engine.
|
|
154
|
+
- **One-turn speculative apply:** `docx-redline apply --find ... --replace ...`
|
|
155
|
+
can resolve a globally unique source literal without preliminary extraction.
|
|
156
|
+
`--search` plus signed `--context-range START:END` scopes visible headings and
|
|
157
|
+
nearby content; `--around N` is symmetric shorthand. Longer, distinctive
|
|
158
|
+
anchors are recommended because generic or repeated phrases widen the unioned
|
|
159
|
+
scope and may cost an ambiguity-recovery turn.
|
|
160
|
+
- **Fail-closed selection:** Missing anchors and patch sources, multiple eligible
|
|
161
|
+
paragraphs, ambiguous occurrences, overlaps, conflicts, and unsupported
|
|
162
|
+
localized shapes refuse mutation. A failed speculative command never writes
|
|
163
|
+
or truncates its output path.
|
|
164
|
+
- **Verified change evidence:** Localized operation results include a compact
|
|
165
|
+
`change` object with target location, contextual anchor/range, exact
|
|
166
|
+
replacement entries, bounded before/after excerpts, commit disposition, and
|
|
167
|
+
post-mutation accepted-view verification. Atomic rollback marks the evidence
|
|
168
|
+
non-committed and `rolled_back`.
|
|
169
|
+
- **CLI contract version 8:** Adds `localized-replacements-v1`,
|
|
170
|
+
`speculative-search-apply-v1`, and `localized-change-summary-v1`. Skills and
|
|
171
|
+
harnesses should pin version 0.7.0 and negotiate only the capabilities used.
|
|
172
|
+
- **Measured workflow reduction:** The checked benchmark records 50% fewer tool
|
|
173
|
+
turns and a 64.77%–78.98% smaller deterministic request-token proxy across
|
|
174
|
+
three literal-edit cases. Median native engine/I/O time remained effectively
|
|
175
|
+
neutral; provider reasoning and network latency were not estimated.
|
|
176
|
+
|
|
177
|
+
### Compatibility
|
|
178
|
+
|
|
179
|
+
- Existing `modified` operations, strong targets, operations files/stdin,
|
|
180
|
+
tracked-change generation, package validation, rollback, comments,
|
|
181
|
+
Accept/Reject, and revision policies remain supported.
|
|
182
|
+
- Localized replacement fields and successful `change` evidence are additive.
|
|
183
|
+
Wrappers that adopt them must require CLI contract 8; integrations using only
|
|
184
|
+
earlier capabilities can continue using their existing operation shapes.
|
|
185
|
+
- The implementation remains OOXML-only and adds no runtime dependency or Word,
|
|
186
|
+
Office automation, COM, or proprietary document API requirement.
|
|
187
|
+
|
|
188
|
+
## 0.6.0–0.6.2
|
|
189
|
+
|
|
190
|
+
### Safety Fixes
|
|
191
|
+
|
|
192
|
+
- **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.
|
|
193
|
+
- **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.
|
|
194
|
+
- **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.
|
|
195
|
+
- **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.
|
|
196
|
+
- **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.
|
|
197
|
+
- **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.
|
|
198
|
+
|
|
199
|
+
### New Features
|
|
200
|
+
|
|
201
|
+
- **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.
|
|
202
|
+
- **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.
|
|
203
|
+
- **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.
|
|
204
|
+
- **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.
|
|
205
|
+
- **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.
|
|
206
|
+
- **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.
|
|
207
|
+
- **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.
|
|
208
|
+
- **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.
|
|
209
|
+
- **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.
|
|
210
|
+
- **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.
|
|
211
|
+
|
|
212
|
+
## 0.5.1
|
|
213
|
+
|
|
214
|
+
### Highlights & New Features
|
|
215
|
+
|
|
216
|
+
- **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.
|
|
217
|
+
- **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.
|
|
218
|
+
- **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.
|
|
219
|
+
- **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.
|
|
220
|
+
- **Multi-Author Stacked Revisions**: Multiple reviewers can independently delete or insert content within the same carrier insertion without cross-author interference.
|
|
221
|
+
- **Cascading & Coalescing Lifecycles**: Full round-trip lifecycle parity with Microsoft Word Desktop:
|
|
222
|
+
- Rejecting Author A cleanly discards Author A's insertion and any dependent nested deletions by Author B.
|
|
223
|
+
- Accepting Author A unwraps the insertion into baseline text while leaving Author B's deletions pending against the baseline.
|
|
224
|
+
- 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.
|
|
225
|
+
- **CLI & Facade Integration**: Fully exposed via the `docx-redline` CLI (`--existing-revisions slice-cross-author`), Node facade (`openDocx`), and batch operation runner.
|
|
226
|
+
|
|
227
|
+
### Non-breaking Changes & Improvements
|
|
228
|
+
|
|
229
|
+
- **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.
|
|
230
|
+
- **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.
|
|
231
|
+
- **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.
|
|
232
|
+
- **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.
|
|
233
|
+
- **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.
|
|
234
|
+
- **Preflight Inspection**: `preflightOperations` now inspects and validates `slice-cross-author` batches, reporting pending foreign-author carrier targets as `ready` instead of `EXISTING_REVISIONS`.
|
|
235
|
+
- **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).
|
|
236
|
+
|
|
237
|
+
## 0.5.0
|
|
238
|
+
|
|
239
|
+
### ⚠️ Breaking changes
|
|
240
|
+
|
|
241
|
+
The following changes can require caller or contributor updates. No public
|
|
242
|
+
export or valid existing function signature was removed.
|
|
243
|
+
|
|
244
|
+
#### Runtime and result-contract changes
|
|
245
|
+
|
|
246
|
+
- **Canonical paragraph text:** `getParagraphText(...)` now returns the
|
|
247
|
+
accepted/current view instead of the earlier simplified `w:t`/`w:tab`
|
|
248
|
+
concatenation. It excludes deleted and `w:moveFrom` content and includes
|
|
249
|
+
structural breaks, soft hyphens, and non-breaking hyphens.
|
|
250
|
+
**Migration:** regenerate compared/cached text with the upgraded library. Use
|
|
251
|
+
`extractCanonicalParagraphText(...)` when accepted/rejected-view semantics
|
|
252
|
+
are intended; integrations that require the former raw traversal must retain
|
|
253
|
+
their own legacy extractor before upgrading.
|
|
254
|
+
- **Paragraph fingerprints:** fingerprints now incorporate canonical paragraph
|
|
255
|
+
text. Stored fingerprints can become stale for paragraphs containing
|
|
256
|
+
revisions, moves, breaks, soft hyphens, or non-breaking hyphens.
|
|
257
|
+
**Migration:** do not carry fingerprints across this upgrade; re-extract the
|
|
258
|
+
document and regenerate target descriptors.
|
|
259
|
+
- **Invalid operations:** malformed or field-incompatible document-operation
|
|
260
|
+
objects now return a structured `INVALID_OPERATION` error at the runner
|
|
261
|
+
boundary instead of reaching later failure/no-op paths.
|
|
262
|
+
**Migration:** validate operation files against the published schema and
|
|
263
|
+
handle `status === 'error'` plus `error.code === 'INVALID_OPERATION'`.
|
|
264
|
+
- **Commented paragraph deletion:** deleting a complete paragraph that contains
|
|
265
|
+
an existing comment now fails with `COMMENTED_CONTENT_DELETE` instead of
|
|
266
|
+
producing OOXML with dangling comment references.
|
|
267
|
+
**Migration:** preserve or deliberately remove/relocate the comment before
|
|
268
|
+
deleting the paragraph, and handle the structured error. Atomic callers keep
|
|
269
|
+
the original document unchanged.
|
|
270
|
+
- **Comment anchor failures:** missing or ambiguous comment anchors now return
|
|
271
|
+
`ANCHOR_NOT_FOUND` or `AMBIGUOUS_ANCHOR` and fail/roll back an atomic batch;
|
|
272
|
+
they are no longer reported as successful `no_change` operations.
|
|
273
|
+
**Migration:** treat these codes as failed operations and use a unique exact
|
|
274
|
+
anchor or stricter target descriptor before retrying.
|
|
275
|
+
- **Stricter package validation:** DOCX package validation now rejects
|
|
276
|
+
unbalanced comment ranges, dangling references/usages, orphan definitions,
|
|
277
|
+
and duplicate comment-definition IDs that earlier validation could allow.
|
|
278
|
+
**Migration:** repair the comment anchors and `word/comments.xml` definitions
|
|
279
|
+
before applying or validating further changes.
|
|
280
|
+
|
|
281
|
+
#### Development workflow change
|
|
282
|
+
|
|
283
|
+
- **Parallel tests by default:** `npm test` now runs up to four isolated child
|
|
284
|
+
processes concurrently. This does not change the published runtime API, but
|
|
285
|
+
contributor automation that depends on test execution order or shared files
|
|
286
|
+
must be updated. **Migration:** make tests independent or set
|
|
287
|
+
`DOCX_TEST_CONCURRENCY=1` for the previous serial scheduling behavior.
|
|
288
|
+
|
|
289
|
+
Strict targeting remains opt-in on existing low-level mutation APIs; it is the
|
|
290
|
+
default only on the newly added Node facade and CLI.
|
|
291
|
+
|
|
292
|
+
### Deprecations and future breaking changes
|
|
293
|
+
|
|
294
|
+
- Replacing an existing numbering part without a merge callback now emits a
|
|
295
|
+
deprecation warning. The Node facade and CLI already merge safely by default.
|
|
296
|
+
**This remains supported in this release but will become an error in the next
|
|
297
|
+
major version.** Migrate low-level callers to
|
|
298
|
+
`mergeNumberingXmlBySchemaOrder` before that release.
|
|
299
|
+
- **Permissive target resolution deprecation (`AMBIGUOUS_TARGET_HEURISTIC_USED`):**
|
|
300
|
+
Lower-level document operation runners currently default to permissive targeting.
|
|
301
|
+
In v1.0.0, application will default to `strictTargets: true`. In this release,
|
|
302
|
+
when permissive resolution encounters multiple identical candidate paragraphs and
|
|
303
|
+
heuristically chooses the first candidate, it emits an `AMBIGUOUS_TARGET_HEURISTIC_USED`
|
|
304
|
+
warning with candidate count and migration guidance.
|
|
305
|
+
**Migration:** Disambiguate operations using `paragraphId`, `index`, `occurrence`,
|
|
306
|
+
or `fingerprint` and pass `{ strictTargets: true }`.
|
|
307
|
+
|
|
308
|
+
### ℹ️ Noteworthy Default & Usability Changes (Non-breaking)
|
|
309
|
+
|
|
310
|
+
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:
|
|
311
|
+
|
|
312
|
+
- **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.
|
|
313
|
+
- **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.
|
|
314
|
+
- **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.
|
|
315
|
+
- **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.
|
|
316
|
+
- **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.
|
|
317
|
+
- **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.
|
|
318
|
+
- **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.
|
|
319
|
+
- **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.
|
|
320
|
+
|
|
321
|
+
### Added
|
|
322
|
+
|
|
323
|
+
- Added **Mutation Receipts** (`receipt` on `DocumentOperationResult` and `receipts`
|
|
324
|
+
on `BatchOperationResult`). Every operation execution returns structured,
|
|
325
|
+
commit-aware telemetry capturing durable revision IDs (with kind and target part),
|
|
326
|
+
comment IDs, numbering IDs, relationship IDs, affected targets, and warnings.
|
|
327
|
+
Supports `not_attempted`, `applied`, `refused`, `no_change`, and `rolled_back`
|
|
328
|
+
dispositions.
|
|
329
|
+
- Added **Commit-Aware Output Reconciliation Oracle** (`reconcileReceiptsAgainstOutput`).
|
|
330
|
+
Before completing any transaction, reported durable IDs are checked against a
|
|
331
|
+
fresh parse of the generated output OOXML parts. Any reconciliation discrepancy
|
|
332
|
+
immediately fails the transaction and triggers atomic rollback.
|
|
333
|
+
- Exported receipt primitives: `ReceiptCollector`, `createEmptyReceipt`, and
|
|
334
|
+
`reconcileReceiptsAgainstOutput` along with `MutationReceipt` and
|
|
335
|
+
`MutationReceiptRevisionItem` TypeScript declarations.
|
|
336
|
+
- Added **Paragraph Mark Revisions** (`w:pPrChange`, `markParagraphMarkInserted`,
|
|
337
|
+
`markParagraphMarkDeleted`) ensuring whole-paragraph deletions and insertions
|
|
338
|
+
cleanly track paragraph mark lifecycles for full Accept All / Reject All symmetry.
|
|
339
|
+
- Added **Paragraph Boundary Mutation Validation** (`validateParagraphBoundaryMutation`)
|
|
340
|
+
guarding against invalid cross-paragraph boundary merges.
|
|
341
|
+
|
|
342
|
+
- Added `analyzeStructuredContent(...)` and `planStructuredReplacement(...)`
|
|
343
|
+
for agent-authored attachments and schedules containing mixed headings,
|
|
344
|
+
paragraphs, lists, and tables. The planner returns typed blocks and produces
|
|
345
|
+
one atomic `structuredContent` operation only when the Markdown is valid.
|
|
346
|
+
|
|
347
|
+
- Added session-scoped paragraph metadata indexing for canonical text,
|
|
348
|
+
normalized text, paragraph IDs, fingerprints, table context, and document
|
|
349
|
+
indexes, plus deterministic targeting and route-profiling benchmarks.
|
|
350
|
+
- Added a shared list-marker grammar and parsed list-item vocabulary used by
|
|
351
|
+
pipeline analysis, orchestration, normalization, and list targeting.
|
|
352
|
+
- Added an internal reconciliation capability matrix and opt-in route
|
|
353
|
+
instrumentation. Public reconciliation result shapes and route selection
|
|
354
|
+
policy remain unchanged.
|
|
355
|
+
|
|
356
|
+
- Added `scripts/extract_text.mjs` and `scripts/apply_changes.mjs` as thin
|
|
357
|
+
compatibility entrypoints for legacy skill installations. They delegate to
|
|
358
|
+
the supported CLI, retain strict atomic validated writes, and accept legacy
|
|
359
|
+
operation files with a top-level `changes` array.
|
|
360
|
+
- Added typed operations, per-operation authors, strict target descriptors,
|
|
361
|
+
deterministic preflight diagnostics, and auditable resolution metadata.
|
|
362
|
+
- Added `inspectDocumentParts(...)`, a structured document inventory using the
|
|
363
|
+
same canonical text extractor as targeting and ingestion.
|
|
364
|
+
- Added `@ansonlai/docx-redline-js/node`. `openDocx(...)` applies batches to
|
|
365
|
+
complete DOCX buffers transactionally and validates before commit.
|
|
366
|
+
- Added the cross-platform `docx-redline` CLI with JSON `inspect`, `extract`,
|
|
367
|
+
`preflight`, `apply`, `accept`, `reject`, `delete-comments`, and `validate`
|
|
368
|
+
commands, plus a published operation-file JSON Schema.
|
|
369
|
+
|
|
370
|
+
### Behavior and reliability
|
|
371
|
+
|
|
372
|
+
- Explicit structured replacements now reject missing Markdown table separator
|
|
373
|
+
- Generated Markdown tables repeat their header row and prevent logical data rows from splitting across pages.
|
|
374
|
+
rows, missing data rows, and inconsistent column counts with
|
|
375
|
+
`STRUCTURED_CONTENT_INVALID` instead of inserting literal pipe-delimited text.
|
|
376
|
+
- Tables created inside mixed replacements are tracked once at block scope,
|
|
377
|
+
avoiding nested revisions while keeping Accept All and Reject All symmetric.
|
|
378
|
+
|
|
379
|
+
- Target preflight and live mutation reuse one document-scoped paragraph index;
|
|
380
|
+
strict duplicate detection and resolution metadata retain their prior
|
|
381
|
+
semantics while avoiding repeated whole-document text traversal.
|
|
382
|
+
- Revision-ID seeding now walks the DOM with child/sibling pointers instead of
|
|
383
|
+
allocating an array containing every element.
|
|
384
|
+
- Single-source-paragraph list expansion uses the focused list generator
|
|
385
|
+
directly. Multi-paragraph marked-list edits deliberately retain the legacy
|
|
386
|
+
run-aware reconciliation pipeline for structural parity.
|
|
387
|
+
- Fixed paragraph-to-list expansion when a manually numbered heading carries
|
|
388
|
+
`w:numId w:val="0"`. Numbering suppression is no longer reused as a generated
|
|
389
|
+
list ID, so inserted bullet and numbered items receive valid positive IDs.
|
|
390
|
+
- Tracked heading-to-list replacements now keep the deleted source heading in
|
|
391
|
+
its own paragraph and track the paragraph marks of every inserted list item.
|
|
392
|
+
This prevents deleted heading text from joining the first item and preserves
|
|
393
|
+
exact Accept/Reject structure without adding a full-document sentinel
|
|
394
|
+
paragraph.
|
|
395
|
+
- Inserted list items now inherit source font family, size, language, and
|
|
396
|
+
related script typography without inheriting heading-only bold, underline,
|
|
397
|
+
italic, or strike formatting unless requested by the replacement markdown.
|
|
398
|
+
- Canonical-only table-cell targeting now consumes the shared paragraph-text
|
|
399
|
+
extractor, while offset- and sentinel-producing walkers remain specialized.
|
|
400
|
+
Their accepted visible projections now agree on soft hyphens as well as tabs,
|
|
401
|
+
breaks, hyperlinks, and non-breaking hyphens.
|
|
402
|
+
|
|
403
|
+
- Comment preflight and application now share one anchor resolver. Exact
|
|
404
|
+
matches take priority, unique ordinary-space/NBSP differences preserve raw
|
|
405
|
+
offsets, and missing or repeated anchors return structured
|
|
406
|
+
`ANCHOR_NOT_FOUND` or `AMBIGUOUS_ANCHOR` errors.
|
|
407
|
+
- Full-document operation batches now share one live DOM and revision-ID
|
|
408
|
+
allocator, reducing complete-document parsing and serialization from once per
|
|
409
|
+
operation to once per changed batch. Scoped reconciliation engines and their
|
|
410
|
+
targeting decisions are unchanged.
|
|
411
|
+
- Each live-session operation uses a DOM and allocator savepoint. Errors and
|
|
412
|
+
reported no-ops restore the savepoint; atomic failures and all-no-op batches
|
|
413
|
+
still return the exact original XML without serializing it.
|
|
414
|
+
- Decomposed the standalone document-operation runner into a stable 13-line
|
|
415
|
+
compatibility facade plus focused session, applier, batch-orchestrator,
|
|
416
|
+
heuristic, and OOXML-mutation modules. Runtime exports and declarations are
|
|
417
|
+
unchanged, and operation internals now use leaf imports instead of importing
|
|
418
|
+
the root entry point.
|
|
419
|
+
- Package comment IDs are seeded from existing anchors and definitions, and
|
|
420
|
+
the Node facade merges numbering without discarding prior definitions.
|
|
421
|
+
- Canonical paragraph text consistently handles revisions, moves, tabs,
|
|
422
|
+
breaks, soft hyphens, and non-breaking hyphens; see the breaking-change note
|
|
423
|
+
above for `getParagraphText(...)` and fingerprint compatibility.
|
|
424
|
+
- Structured inspection now explicitly supports the `current` view as the
|
|
425
|
+
accepted/current document view and resolves comment ranges spanning multiple
|
|
426
|
+
paragraphs as one exact anchor string.
|
|
427
|
+
- Transactional no-op results preserve the original DOCX bytes exactly,
|
|
428
|
+
including when the same facade instance has already committed an edit.
|
|
429
|
+
|
|
430
|
+
### Testing and development
|
|
431
|
+
|
|
432
|
+
- Added focused and semantic visual-failure regressions for suppressed
|
|
433
|
+
numbering, paragraph separation, paragraph-mark revisions, selective
|
|
434
|
+
typography inheritance, and exact accepted/rejected paragraph sequences,
|
|
435
|
+
plus seeded fuzz variants across list length, marker, font, and size.
|
|
436
|
+
Added the independently specified
|
|
437
|
+
`legal-suppressed-heading-to-bullet-list` and
|
|
438
|
+
`legal-structured-attachment-mixed-blocks` Microsoft Word differential
|
|
439
|
+
fixtures; the synthetic catalogue now contains 49 cases and 49 task types.
|
|
440
|
+
|
|
441
|
+
- The JavaScript test runner now uses bounded asynchronous subprocess workers,
|
|
442
|
+
capped at four by default, while retaining one fresh Node process per file,
|
|
443
|
+
sorted reporting, timeouts, captured diagnostics, and failure-marker checks.
|
|
444
|
+
Set `DOCX_TEST_CONCURRENCY=1` for serial reproduction.
|
|
445
|
+
- Added `npm run benchmark:tests` and a Phase 6 runner regression. The checked
|
|
446
|
+
benchmark reduced median suite time from 18.02 seconds to 7.96 seconds
|
|
447
|
+
(55.80%); 20 consecutive parallel runs and a separate serial run passed all
|
|
448
|
+
63 files. Parallel c8 collection remains valid at 89.90% statements/lines,
|
|
449
|
+
77.40% branches, and 93.10% functions.
|
|
450
|
+
|
|
451
|
+
- Added Phase 3 targeting/traversal, Phase 4 list/text parity, and Phase 5 route
|
|
452
|
+
compatibility regressions. Together with the Phase 6 runner regression, the
|
|
453
|
+
suite now contains 63 passing test files.
|
|
454
|
+
- Added `npm run benchmark:targeting` and `npm run profile:routes`. The checked
|
|
455
|
+
10,000-paragraph benchmark showed no single-operation regression and a 47.16x
|
|
456
|
+
Node median improvement for 100 cached resolutions. The equivalent native
|
|
457
|
+
Chrome benchmark showed no single-operation regression and a 36.45x batch
|
|
458
|
+
improvement. All 47 Microsoft Word differential fixtures and all 60 real-
|
|
459
|
+
document Word corpus scenarios passed after the routing changes.
|
|
460
|
+
|
|
461
|
+
- Added subprocess coverage for legacy wrapper selection, operation-file
|
|
462
|
+
compatibility, successful output, atomic anchor failure, source-byte
|
|
463
|
+
preservation, and protection of pre-existing output files.
|
|
464
|
+
- Added a live-session accuracy and instrumentation suite covering accepted and
|
|
465
|
+
rejected text, structural validity, sequential equivalence, comments, lists,
|
|
466
|
+
tables, highlights, one-parse/one-serialize execution, exact no-ops, and
|
|
467
|
+
atomic rollback. Added `npm run benchmark:session`; the checked accuracy-first
|
|
468
|
+
benchmark reduced parse/serialize counts from 10/10 to 1/1 and measured a
|
|
469
|
+
1.58x median speedup with per-operation savepoints retained.
|
|
470
|
+
- Added a Phase 2 architecture regression covering facade export identity,
|
|
471
|
+
direct leaf imports, exact session rollback, isolated context commit, and
|
|
472
|
+
stable comment-first scheduling.
|
|
473
|
+
- Added five edge-case suites for canonical text views, cross-paragraph comment
|
|
474
|
+
inspection, table/list/reference context, sequential package transactions,
|
|
475
|
+
selective multi-author cleanup, ZIP rejection behavior, CLI filters, JSON
|
|
476
|
+
exit contracts, and destructive-output safeguards. Together with the Phase 2
|
|
477
|
+
Phase 1 and Phase 2 regressions, these established the earlier 57-file
|
|
478
|
+
baseline expanded by the subsequent performance phases.
|
|
479
|
+
|
|
480
|
+
## 0.3.0
|
|
481
|
+
|
|
482
|
+
### Breaking changes
|
|
483
|
+
|
|
484
|
+
- Malformed OOXML no longer escapes public transform APIs as a raw parser
|
|
485
|
+
exception. In particular, revision accept/reject and comment-deletion callers
|
|
486
|
+
that previously used `try`/`catch` must now inspect `status === 'error'` and
|
|
487
|
+
`error.code === 'PARSE_ERROR'` on the returned result.
|
|
488
|
+
- Caller content is no longer sanitized by default. Pass `sanitizeInput: true`
|
|
489
|
+
to remove a standalone leading assistant-preface line. Dollar-delimited text
|
|
490
|
+
and literal `\\n` / `\\r\\n` sequences are never removed implicitly.
|
|
491
|
+
- The exported `sanitizeAiResponse` helper no longer removes dollar-delimited
|
|
492
|
+
spans or converts literal `\\n` / `\\r\\n` sequences. Direct callers that
|
|
493
|
+
relied on those transformations must perform them explicitly.
|
|
494
|
+
- `applyOperationsToDocumentXml` is atomic by default. Failed batches return
|
|
495
|
+
the original document with `rolledBack: true`; pass `atomic: false` to retain
|
|
496
|
+
partial-result behavior.
|
|
497
|
+
- Missing multi-line targets now return `TARGET_NOT_FOUND` instead of being
|
|
498
|
+
indistinguishable from a no-op. Stale batch anchors also return
|
|
499
|
+
`TARGET_NOT_FOUND` instead of falling back to a visibly different paragraph.
|
|
500
|
+
|
|
501
|
+
### Behavior changes and fixes
|
|
502
|
+
|
|
503
|
+
- Revision IDs are now allocated per document. Near-limit prior IDs restart in
|
|
504
|
+
a safe low range, and unrelated bookmark/relationship IDs no longer seed the
|
|
505
|
+
revision counter.
|
|
506
|
+
- Concurrent calls with explicit authors keep their revision attribution
|
|
507
|
+
isolated from process-global defaults.
|
|
508
|
+
- `existingRevisions: 'accept-all-first'` now preserves the original OOXML when
|
|
509
|
+
the requested edit is a no-op.
|
|
510
|
+
- Added `existingRevisions: 'accept-all-first-keep-normalized'` for callers that
|
|
511
|
+
explicitly want accepted existing revisions returned even when no redline is
|
|
512
|
+
added.
|
|
513
|
+
- Diff output is deterministic by default. Inputs exceeding 262,144 unique
|
|
514
|
+
tokens return `DIFF_TOKEN_LIMIT` with the original OOXML unchanged instead of
|
|
515
|
+
risking truncated text; leading whitespace is preserved exactly.
|
|
516
|
+
- Reconstruction preserves structural line breaks and body section-property
|
|
517
|
+
placement. A target that names only part of a reconstruction range now
|
|
518
|
+
returns `PARTIAL_TARGET` instead of risking deletion of untargeted content.
|
|
519
|
+
- Paragraph targeting and reconstruction now preserve leading, middle, and
|
|
520
|
+
trailing `w:tab` elements as literal tab characters instead of omitting or
|
|
521
|
+
trimming them.
|
|
522
|
+
- Adjacent redline edits now preserve complex-field instructions, begin/
|
|
523
|
+
separate/end markers, and unchanged cached display results in their original
|
|
524
|
+
field boundary. Field instructions remain inert and are not evaluated.
|
|
525
|
+
- Added structured XML parse results and result-returning ingestion helpers.
|
|
526
|
+
- Hardened deterministic diff token handling and leading-whitespace fidelity.
|
|
527
|
+
|
|
528
|
+
### Testing and development
|
|
529
|
+
|
|
530
|
+
- Expanded the desktop Word differential from 20 to 25 cases, adding structural
|
|
531
|
+
checks for bookmarks, internal hyperlinks, mixed formatting, content
|
|
532
|
+
controls, and tables.
|
|
533
|
+
- Expanded the desktop Word differential from 25 to 28 cases with structural
|
|
534
|
+
tabs and a locked PAGE field, and added tab/field shapes to focused and fuzz
|
|
535
|
+
regression testing.
|
|
536
|
+
- Expanded the desktop Word differential from 28 to 33 cases with comments,
|
|
537
|
+
footnotes, endnotes, headers/footers, and an external hyperlink.
|
|
538
|
+
- Extended the deterministic script-only DOCX packager with opt-in related
|
|
539
|
+
parts, relationship/content-type validation, reusable fixture constructors,
|
|
540
|
+
and SHA-256 verification that supplied parts remain byte-identical. Runtime
|
|
541
|
+
library code and dependencies are unchanged.
|
|
542
|
+
- Added validated task, structure, oracle, and manual-review metadata across the
|
|
543
|
+
33 synthetic and 20 SuperDoc Word cases. `npm run report:word:coverage`
|
|
544
|
+
produces a deterministic coverage matrix with explicit high-priority gap
|
|
545
|
+
dispositions, while `npm run review:word:prepare` creates a pending rotating
|
|
546
|
+
human-review manifest without self-certifying visual results.
|
|
547
|
+
- Added detailed production-function coverage reporting and a checked per-file
|
|
548
|
+
regression baseline. Five behavior-focused Phase 3 suites exercise numbering
|
|
549
|
+
collisions/remapping, every reconciliation route, list construction and
|
|
550
|
+
fallback, patch/format boundaries, table decisions, pipeline modes, and
|
|
551
|
+
standalone rollback/highlight paths. Production function coverage moved from
|
|
552
|
+
437/540 to 496/542 and all reachable P0 functions are covered; no runtime
|
|
553
|
+
behavior or compatibility contract changed.
|