@ansonlai/docx-redline-js 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +36 -10
- package/README.md +83 -6
- package/adapters/xml-adapter.js +73 -10
- package/core/list-targeting.js +3 -0
- package/core/paragraph-targeting.js +33 -7
- package/core/redline-validation.js +22 -0
- package/core/types.js +122 -27
- package/core/xml-query.js +3 -1
- package/dist/docx-redline-js.esm.js +1148 -572
- package/dist/docx-redline-js.esm.js.map +4 -4
- package/dist/docx-redline-js.esm.min.js +79 -78
- package/dist/docx-redline-js.esm.min.js.map +4 -4
- package/docs/TESTING.md +687 -0
- package/docs/VALIDATION.md +81 -2
- package/docs/WORD-MANUAL-REVIEW.md +138 -0
- package/docs/plans/2026-08-30-reliability-testing-improvements.md +488 -0
- package/docs/plans/2026-09-01-performance-and-complexity-reduction.md +210 -0
- package/docs/plans/{2026-03-01-release-0.1.4-design.md → completed/2026-03-01-release-0.1.4-design.md} +2 -0
- package/docs/plans/{2026-03-01-release-0.1.4.md → completed/2026-03-01-release-0.1.4.md} +5 -3
- package/docs/plans/{2026-05-31-architectural changes.md → completed/2026-05-31-architectural changes.md } +2 -0
- package/docs/plans/completed/2026-08-02-reliability-improvements.md +1155 -0
- package/docs/test-comparison-dashboard.html +95 -0
- package/docs/validation-reports/2026-08-30-phase-1-word-visual-preflight.md +22 -0
- package/docs/validation-reports/2026-08-30-phase-2-word-visual-preflight.md +24 -0
- package/docs/validation-reports/2026-08-30-phase-3-coverage.md +73 -0
- package/docs/validation-reports/2026-09-02-multilevel-bullets-visual-review.md +82 -0
- package/docs/validation-reports/2026-09-02-multimodal-visual-samples.md +114 -0
- package/docs/validation-reports/2026-09-02-visual-failures-preflight.md +79 -0
- package/engine/format-extraction.js +1 -1
- package/engine/formatting-removal.js +95 -104
- package/engine/oxml-engine.js +176 -83
- package/engine/reconstruction-mapper.js +276 -79
- package/engine/reconstruction-mode.js +20 -6
- package/engine/reconstruction-writer.js +117 -72
- package/engine/run-builders.js +17 -13
- package/engine/surgical-diff-application.js +7 -21
- package/engine/surgical-mode.js +3 -2
- package/engine/table-mode.js +27 -16
- package/index.d.ts +95 -3
- package/index.js +14 -13
- package/orchestration/list-structural-fallback.js +16 -39
- package/package.json +23 -5
- package/pipeline/diff-engine.js +174 -55
- package/pipeline/ingestion-export.js +39 -24
- package/pipeline/ingestion-paragraph.js +7 -5
- package/pipeline/list-generation.js +27 -18
- package/pipeline/patching.js +2 -3
- package/pipeline/pipeline.js +65 -36
- package/pipeline/serialization.js +13 -5
- package/scripts/build-test-dashboard.mjs +43 -0
- package/scripts/check-types.mjs +16 -24
- package/scripts/export-validation-fixtures.mjs +191 -45
- package/scripts/fetch-superdoc-corpus.mjs +61 -0
- package/scripts/generate-test-dashboard.mjs +199 -0
- package/scripts/inspect-visual-evidence.mjs +271 -0
- package/scripts/lib/minimal-zip.mjs +199 -18
- package/scripts/lib/word-coverage-catalogue.mjs +207 -0
- package/scripts/lib/word-coverage-metadata.mjs +93 -0
- package/scripts/lib/zip-reader.mjs +64 -0
- package/scripts/package-superdoc-word-fixtures.ps1 +64 -0
- package/scripts/prepare-corpus-word-visual-review.mjs +84 -0
- package/scripts/prepare-superdoc-word-corpus.mjs +284 -0
- package/scripts/prepare-word-review.mjs +77 -0
- package/scripts/prepare-word-visual-review.mjs +90 -0
- package/scripts/render-agenda-multilevel.mjs +70 -0
- package/scripts/render-case22.mjs +73 -0
- package/scripts/render-case40.ps1 +35 -0
- package/scripts/render-multilevel-bullet-images.py +58 -0
- package/scripts/render-multilevel-bullet-visual.ps1 +32 -0
- package/scripts/render-multilevel-cases.mjs +80 -0
- package/scripts/report-coverage-gaps.mjs +103 -0
- package/scripts/report-word-coverage.mjs +71 -0
- package/scripts/sample-multimodal-visual-check.mjs +221 -0
- package/scripts/test-multilevel-bullet-visual.mjs +187 -0
- package/scripts/word-com-corpus-suite.ps1 +43 -0
- package/scripts/word-com-corpus-visual-suite.ps1 +116 -0
- package/scripts/word-com-differential.ps1 +158 -16
- package/scripts/word-com-suite.ps1 +19 -0
- package/scripts/word-com-visual-suite.ps1 +132 -0
- package/services/comment-engine.js +51 -46
- package/services/comment-locator.js +0 -1
- package/services/comment-package.js +11 -10
- package/services/numbering-service.js +1 -1
- package/services/revision-comment-management.js +31 -10
- package/services/standalone-docx-plumbing.js +45 -34
- package/services/standalone-operation-runner.js +315 -75
- package/services/table-reconciliation.js +23 -11
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Performance and Complexity Reduction Plan
|
|
2
|
+
|
|
3
|
+
**Status:** Proposed
|
|
4
|
+
**Date:** 2026-09-01
|
|
5
|
+
|
|
6
|
+
This plan outlines opportunities to reduce architectural complexity, eliminate redundant diffing engines, and resolve critical performance bottlenecks across `@ansonlai/docx-redline-js`.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. Context & Motivation
|
|
11
|
+
|
|
12
|
+
Following the completion of reliability improvements (Rounds 1–3), the library has achieved strong correctness invariants (38/38 test suites passing, Word COM differential parity, and round-trip invariant checks).
|
|
13
|
+
|
|
14
|
+
However, feature additions over time (tables, lists, comments, formatting removal, and batch operation orchestration) have introduced structural debt:
|
|
15
|
+
1. **Three competing diff-and-patch paradigms**: [Reconstruction Mode](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/engine/reconstruction-mode.js), [Surgical Mode](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/engine/surgical-mode.js), and [Pipeline Mode](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/pipeline/pipeline.js) each maintain distinct run models and patching strategies.
|
|
16
|
+
2. **Monolithic Coordination**: [`services/standalone-operation-runner.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/services/standalone-operation-runner.js) has expanded to 1,451 lines (63 KB), entangling batch scheduling, atomic rollback, DOM mutation, range resolution, and ad-hoc heuristics.
|
|
17
|
+
3. **Parse $\leftrightarrow$ Serialize Thrashing in Batches**: In multi-operation document turns, full-document XML is repeatedly parsed and serialized for each operation ($O(N \times \text{document size})$), consuming seconds of CPU time.
|
|
18
|
+
4. **Scattered Domain Logic**: List markers, list parsing, numbering fallback, and list targeting are fragmented across 6+ separate files.
|
|
19
|
+
5. **Hot Path Inefficiencies**: Linear scans in target detection, universal element traversal (`getElementsByTagName('*')`) during revision ID seeding, and excessive heap allocations (`Array.from`) in tree-traversal loops.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Guiding Principles
|
|
24
|
+
|
|
25
|
+
This plan strictly follows the project's core philosophy:
|
|
26
|
+
> **"Readability and Order > Speed and Complex Interconnections"**
|
|
27
|
+
> This project prioritizes maintainability and clarity over clever, hyper-optimized code. Even if a solution is slightly less performant but significantly easier to read, choose the readable one (within reason).
|
|
28
|
+
|
|
29
|
+
- **SOLID & DRY**: Each module should have one clear responsibility. Avoid maintaining duplicate diff/patch representations.
|
|
30
|
+
- **KISS**: Favor simple, direct DOM operations over multi-layered abstractions.
|
|
31
|
+
- **Strict Backward Compatibility**: Public APIs exported from [`index.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/index.js) and the package `exports` map must remain intact. All structural invariants verified by [`validateRedlineOoxml`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/core/redline-validation.js) and the round-trip tests must continue to pass.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 3. Baseline Metrics
|
|
36
|
+
|
|
37
|
+
As of 2026-09-01:
|
|
38
|
+
- `npm test`: 38/38 test files pass (~6.0s execution time due to sequential process spawning).
|
|
39
|
+
- Core package exports remain centralized in [`index.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/index.js).
|
|
40
|
+
- For an $N$-operation batch on `word/document.xml`, the runner currently performs up to $3N$ full-document XML parses and $N$ full-document XML serializations using `@xmldom/xmldom`.
|
|
41
|
+
- Four divergent text-extraction functions exist across targeting, engine, and ingestion modules.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 4. Production API Compatibility
|
|
46
|
+
|
|
47
|
+
| Phase | Expected Impact |
|
|
48
|
+
|---|---|
|
|
49
|
+
| **Phase 1: In-Memory Batch DOM & Hot Path Optimization** | **Non-breaking.** Pure internal performance optimization for [`applyOperationsToDocumentXml`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/services/standalone-operation-runner.js#L1356), target searches, and revision ID allocation. Output OOXML remains identical. |
|
|
50
|
+
| **Phase 2: Decomposing `standalone-operation-runner.js`** | **Non-breaking.** Public exports preserved through [`index.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/index.js) and package exports; internal subroutines refactored into focused single-responsibility modules. |
|
|
51
|
+
| **Phase 3: Diff Engine Consolidation & Pipeline Retirement** | **Non-breaking.** Unifies paragraph and list generation onto Reconstruction mode; deprecates/retires redundant AST patching in [`pipeline/pipeline.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/pipeline/pipeline.js). |
|
|
52
|
+
| **Phase 4: Consolidating Lists & Canonical Text Extraction** | **Non-breaking.** Centralizes list markers/heuristics into `services/list-service.js` and creates an authoritative canonical text extractor in [`core/word-xml.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/core/word-xml.js). |
|
|
53
|
+
| **Phase 5: Developer Ergonomics & Fast Test Runner** | **Development-only.** In-process test execution cuts test suite run time from ~6.0s down to <1.0s. |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Phase 1 — In-Memory Batch DOM & Hot Path Optimization
|
|
58
|
+
|
|
59
|
+
### Problem
|
|
60
|
+
1. In [`applyOperationsToDocumentXml`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/services/standalone-operation-runner.js#L1356-L1449), every scheduled operation causes a full serialize-and-reparse cycle:
|
|
61
|
+
- `parseOoxmlSafe(documentXml)` parses the document.
|
|
62
|
+
- `applyOperationToDocumentXml` parses it again.
|
|
63
|
+
- `applyToParagraphByExactText` parses it a third time.
|
|
64
|
+
- The scoped paragraph is serialized to a string, passed to `applyRedlineToOxml`, and parsed again.
|
|
65
|
+
- The result is serialized to a string, parsed again by `extractReplacementNodesFromOoxml`, imported back into `xmlDoc`, and the **entire document** is serialized back to string.
|
|
66
|
+
- In `@xmldom/xmldom` (pure JS DOM implementation), this creates massive CPU overhead for multi-operation turns.
|
|
67
|
+
2. In [`oxml-engine.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/engine/oxml-engine.js#L183-L198), target detection uses an $O(\text{lines} \times \text{paragraphs} \times \text{spans})$ nested loop (`textSpans.filter(...)` inside `paragraphs.some(...)` for every line).
|
|
68
|
+
3. In [`RevisionIdAllocator.prototype.seed`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/core/types.js#L203-L222), `getElementsByTagName('*')` copies every single element in the document into an array to find revision IDs, even though only 9 revision tags can carry `w:id`.
|
|
69
|
+
|
|
70
|
+
### Implementation Steps
|
|
71
|
+
1. **In-Memory Batch Execution**:
|
|
72
|
+
- Parse `documentXml` once at the beginning of `applyOperationsToDocumentXml`.
|
|
73
|
+
- Maintain a live `xmlDoc` reference across operations.
|
|
74
|
+
- Apply operations directly to `xmlDoc` without intermediate full-document string serialization.
|
|
75
|
+
- Serialize `xmlDoc` once at the end.
|
|
76
|
+
- Retain the initial `documentXml` string for atomic rollback; if any operation fails when `atomic: true`, simply return the untouched original string.
|
|
77
|
+
2. **Pre-Group Spans in Target Check**:
|
|
78
|
+
- In `oxml-engine.js`, pre-aggregate text by paragraph into a `Map<Element, string>` in a single $O(\text{spans})$ pass (or reuse [`buildParagraphInfos`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/engine/format-paragraph-targeting.js#L27)), eliminating the quadratic scan.
|
|
79
|
+
3. **Targeted Revision Tag Query**:
|
|
80
|
+
- In `RevisionIdAllocator.seed`, replace `getElementsByTagName('*')` with targeted queries for known revision element names (`w:ins`, `w:del`, `w:moveFrom`, `w:moveTo`, `w:rPrChange`, `w:pPrChange`, `w:cellIns`, `w:cellDel`, `w:comment`).
|
|
81
|
+
4. **Common Prefix/Suffix Diff Short-Circuit**:
|
|
82
|
+
- In [`diff-engine.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/pipeline/diff-engine.js#L206), add a fast character-level common prefix/suffix trim before DMP tokenization to short-circuit edits that only touch a few words in a large paragraph.
|
|
83
|
+
|
|
84
|
+
### Acceptance
|
|
85
|
+
- Multi-operation batch benchmarks demonstrate a **5x–15x speedup** on documents with 10+ operations.
|
|
86
|
+
- All 38 existing test suites pass with zero regressions.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Phase 2 — Modularizing `standalone-operation-runner.js`
|
|
91
|
+
|
|
92
|
+
### Problem
|
|
93
|
+
[`standalone-operation-runner.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/services/standalone-operation-runner.js) is 1,451 lines long. It acts as an orchestrator, batch scheduler, DOM updater, and heuristic router all at once, making navigation and maintenance difficult.
|
|
94
|
+
|
|
95
|
+
### Implementation Steps
|
|
96
|
+
1. Extract batch scheduling, priority sorting, dependency tracking, and atomic rollback into `services/batch-operation-orchestrator.js`:
|
|
97
|
+
- `applyOperationsToDocumentXml`
|
|
98
|
+
- `operationTargetPriority`
|
|
99
|
+
- Context cloning and commit helpers (`cloneBatchRuntimeContext`, `commitBatchRuntimeContext`)
|
|
100
|
+
2. Extract single-operation execution and target paragraph scoping into `services/document-operation-applier.js`:
|
|
101
|
+
- `applyOperationToDocumentXml`
|
|
102
|
+
- `applyToParagraphByExactText`
|
|
103
|
+
- `applyHighlightToParagraphByExactText`
|
|
104
|
+
- `applyCommentToParagraphByExactText`
|
|
105
|
+
3. Extract ad-hoc structural heuristics into `services/operation-heuristics.js`:
|
|
106
|
+
- Adjacency insertion heuristics (`deriveSingleParagraphListAdjacencyInsertion`, `deriveSingleParagraphPlainAdjacencyInsertion`, `buildInsertedListParagraph`, `buildInsertedPlainParagraph`)
|
|
107
|
+
- Insertion-only heuristics (`planListInsertionOnlyEdit`, `buildExplicitRangeInsertionEntries`, `applyExplicitRangeListInsertions`)
|
|
108
|
+
- Scope expansion (`synthesizeExpandedListScopeEdit`, `synthesizeTableMarkdownFromMultilineCellEdit`)
|
|
109
|
+
4. Keep [`services/standalone-operation-runner.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/services/standalone-operation-runner.js) as a clean façade re-exporting the public contract.
|
|
110
|
+
|
|
111
|
+
### Acceptance
|
|
112
|
+
- No single file exceeds 500 lines.
|
|
113
|
+
- Each module has a single, testable responsibility.
|
|
114
|
+
- Existing tests in `tests/standalone_operation_runner_tests.mjs` pass without modification.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Phase 3 — Diff Engine Consolidation & Pipeline Retirement
|
|
119
|
+
|
|
120
|
+
### Problem
|
|
121
|
+
The codebase currently supports three reconciliation execution engines:
|
|
122
|
+
- **Reconstruction Mode**: Maps characters to runs, properties, and sentinels; rebuilds OOXML structure. (Primary, actively maintained, tab/field safe).
|
|
123
|
+
- **Surgical Mode**: In-place mutation of runs in existing DOM. (Required for tables).
|
|
124
|
+
- **Pipeline Mode** ([`pipeline/pipeline.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/pipeline/pipeline.js)): Converts OOXML to an AST (`runModel`), splits runs at diff boundaries, and patches via string templates. It is now only invoked when `isTargetList` is true.
|
|
125
|
+
|
|
126
|
+
Maintaining three diffing and patching engines increases maintenance burden and means bug fixes (such as `w:tab`, complex fields, or namespace handling) must be replicated across separate systems.
|
|
127
|
+
|
|
128
|
+
### Implementation Steps
|
|
129
|
+
1. Enhance Reconstruction Mode to handle list structural conversions natively:
|
|
130
|
+
- When marker-prefixed list text is detected, emit Word list properties (`w:numPr`) directly during reconstruction writing.
|
|
131
|
+
2. Route `isTargetList` operations in [`oxml-engine.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/engine/oxml-engine.js#L371) through Reconstruction Mode instead of `ReconciliationPipeline`.
|
|
132
|
+
3. Deprecate and remove redundant AST patching modules:
|
|
133
|
+
- [`pipeline/patching.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/pipeline/patching.js)
|
|
134
|
+
- [`pipeline/serialization.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/pipeline/serialization.js) (retaining only document fragment wrapping helpers)
|
|
135
|
+
- [`pipeline/pipeline.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/pipeline/pipeline.js)
|
|
136
|
+
4. Standardize on **Reconstruction Mode** for paragraphs/lists and **Surgical Mode** for tables.
|
|
137
|
+
|
|
138
|
+
### Acceptance
|
|
139
|
+
- ~3,000 lines of redundant code removed.
|
|
140
|
+
- All list generation and list fallback tests (`tests/list_tests.mjs`, `tests/phase3_list_structural_fallback_tests.mjs`) pass with equal or better fidelity.
|
|
141
|
+
- Output validity confirmed via `validateRedlineOoxml`.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Phase 4 — Domain Consolidation: Lists & Canonical Text Extraction
|
|
146
|
+
|
|
147
|
+
### Problem
|
|
148
|
+
1. List logic is currently dispersed across 6+ separate files:
|
|
149
|
+
- [`pipeline/list-generation.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/pipeline/list-generation.js)
|
|
150
|
+
- [`pipeline/list-markers.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/pipeline/list-markers.js)
|
|
151
|
+
- [`orchestration/list-parsing.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/orchestration/list-parsing.js)
|
|
152
|
+
- [`orchestration/list-markdown.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/orchestration/list-markdown.js)
|
|
153
|
+
- [`orchestration/list-structural-fallback.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/orchestration/list-structural-fallback.js)
|
|
154
|
+
- [`core/list-targeting.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/core/list-targeting.js)
|
|
155
|
+
2. Four distinct visible-text extraction functions exist across targeting, engine, and ingestion modules, creating risk of subtle behavioral differences around `w:tab`, `w:br`, `w:noBreakHyphen`, and `w:del`.
|
|
156
|
+
3. Frequent `Array.from(nodeList)` calls inside recursive DOM traversals generate heavy GC pressure.
|
|
157
|
+
|
|
158
|
+
### Implementation Steps
|
|
159
|
+
1. **Canonical Text Extractor**:
|
|
160
|
+
- Establish a single, authoritative `getParagraphVisibleText(pElement)` in [`core/word-xml.js`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/core/word-xml.js).
|
|
161
|
+
- Standardize handling for `w:t`, `w:tab` (`\t`), `w:br`/`w:cr` (`\n`), `w:noBreakHyphen` (`\u2011`), and exclusion of `w:delText` / deleted runs.
|
|
162
|
+
- Refactor `paragraph-targeting.js`, `oxml-engine.js`, and `ingestion-paragraph.js` to use this canonical helper.
|
|
163
|
+
2. **Consolidate List Domain Modules**:
|
|
164
|
+
- Combine list marker matching and markdown list parsing into `services/list-service.js`.
|
|
165
|
+
- Simplify fallback orchestration so single-line structural fallback shares the same list definitions as multi-line lists.
|
|
166
|
+
3. **Reduce DOM Traversal Allocations**:
|
|
167
|
+
- Replace `Array.from(node.childNodes)` in hot traversal loops with pointer iteration (`for (let child = node.firstChild; child; child = child.nextSibling)`).
|
|
168
|
+
- Use `node.getAttributeNS(NS_W, 'author')` directly instead of iterating through `Array.from(node.attributes)`.
|
|
169
|
+
|
|
170
|
+
### Acceptance
|
|
171
|
+
- Single source of truth for paragraph text extraction across all modules.
|
|
172
|
+
- List parsing and numbering fallback unified under a cohesive domain service.
|
|
173
|
+
- Reduced memory churn during large document traversals.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Phase 5 — Developer Ergonomics & Fast Test Runner
|
|
178
|
+
|
|
179
|
+
### Problem
|
|
180
|
+
[`scripts/run-tests.mjs`](file:///c:/Users/Phara/Desktop/Projects/Docx%20Redline%20JS/scripts/run-tests.mjs#L21) currently runs 38 test files by invoking `execSync('node "${filePath}"')` sequentially. On Windows, spawning 38 separate Node.js processes accounts for ~5 seconds of the 6-second test run.
|
|
181
|
+
|
|
182
|
+
### Implementation Steps
|
|
183
|
+
1. Update `scripts/run-tests.mjs` to dynamically import and execute test files in-process (`await import(filePath)`), or leverage Node's native test runner (`node --test tests/*.mjs`).
|
|
184
|
+
2. Retain process isolation checks in `npm run test:isolation`.
|
|
185
|
+
|
|
186
|
+
### Acceptance
|
|
187
|
+
- `npm test` execution time reduced from ~6.0s down to <1.0s.
|
|
188
|
+
- Contributor iteration speed significantly improved.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 5. Execution Roadmap & Prioritization
|
|
193
|
+
|
|
194
|
+
```mermaid
|
|
195
|
+
graph TD
|
|
196
|
+
P1[Phase 1: In-Memory Batch DOM & Hot Paths] --> P2[Phase 2: Modularize standalone-operation-runner]
|
|
197
|
+
P1 --> P5[Phase 5: Fast Test Runner]
|
|
198
|
+
P2 --> P3[Phase 3: Unify Diff Engines & Retire Pipeline]
|
|
199
|
+
P3 --> P4[Phase 4: List & Text Extraction Consolidation]
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
1. **Sprint 1 (Immediate Performance Wins)**:
|
|
203
|
+
- Phase 1 (In-memory DOM batch execution + target search optimization + revision allocator query).
|
|
204
|
+
- Phase 5 (In-process test runner).
|
|
205
|
+
2. **Sprint 2 (Architecture Cleanliness & Maintainability)**:
|
|
206
|
+
- Phase 2 (Decompose `standalone-operation-runner.js`).
|
|
207
|
+
- Phase 4 (Canonical visible text extractor).
|
|
208
|
+
3. **Sprint 3 (Structural Unification)**:
|
|
209
|
+
- Phase 3 (Retire legacy pipeline; unify on Reconstruction & Surgical modes).
|
|
210
|
+
- Complete list logic consolidation.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# 0.1.4 Release Prep Implementation Plan
|
|
2
2
|
|
|
3
|
+
**Status:** Completed
|
|
4
|
+
|
|
3
5
|
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
|
|
4
6
|
|
|
5
7
|
**Goal:** Prepare the repository for a local/manual `0.1.4` release and verify it is ready to publish.
|
|
@@ -10,7 +12,7 @@
|
|
|
10
12
|
|
|
11
13
|
---
|
|
12
14
|
|
|
13
|
-
### Task 1: Update Release Metadata
|
|
15
|
+
### Task 1: Update Release Metadata (Completed)
|
|
14
16
|
|
|
15
17
|
**Files:**
|
|
16
18
|
- Create: `docs/plans/2026-03-01-release-0.1.4-design.md`
|
|
@@ -46,7 +48,7 @@ git add docs/plans/2026-03-01-release-0.1.4-design.md docs/plans/2026-03-01-rele
|
|
|
46
48
|
git commit -m "release: prep v0.1.4"
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
### Task 2: Run Release Preflight
|
|
51
|
+
### Task 2: Run Release Preflight (Completed)
|
|
50
52
|
|
|
51
53
|
**Files:**
|
|
52
54
|
- Modify: `dist/docx-redline-js.esm.js`
|
|
@@ -81,7 +83,7 @@ git add dist/docx-redline-js.esm.js
|
|
|
81
83
|
git commit -m "build: refresh dist for v0.1.4"
|
|
82
84
|
```
|
|
83
85
|
|
|
84
|
-
### Task 3: Publish Handoff
|
|
86
|
+
### Task 3: Publish Handoff (Completed)
|
|
85
87
|
|
|
86
88
|
**Files:**
|
|
87
89
|
- No file changes
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Redline Reliability Improvement Plan
|
|
2
2
|
|
|
3
|
+
**Status:** Completed
|
|
4
|
+
|
|
3
5
|
This plan hardens the library against the ways Microsoft Word redlines are brittle.
|
|
4
6
|
It is written to be executed phase by phase, in order. Each phase is independently
|
|
5
7
|
shippable and ends with a green `npm test`.
|