Skip to content

Commit 9a02666

Browse files
feat: table context in document view + MCP registry metadata (#50)
* feat(docx-core): add table structure context to document view pipeline - Add TableContext type with row/col coordinates, header text, grid-aware column positions, and table dimension metadata - Add isW() and getDirectChildrenByName() shared DOM helpers - Add table-aware toon rendering: th(r,c)/td(r,c) styles, #TABLE/#END_TABLE markers with dimensions-only format - Derive table context via ancestor DOM walking in buildDocumentView() - Add extractTables() module with header-keyed records and merged cell detection - Preserve empty table cell paragraphs for structural completeness - Maintain paragraph parity (same IDs in same order as before) - Re-export tables module from barrel index * feat(docx-mcp): add table markers to read_file output formats - Update budget-aware toon renderer to emit #TABLE/#END_TABLE markers and use formatToonDataLine() for table-aware th/td styles - Add renderSimpleWithTableMarkers() for non-budget simple format - Update renderSimpleWithBudget() to handle table boundary markers - Table markers count toward token budget but not paragraphsReturned - Balanced #END_TABLE emitted on mid-table budget truncation * test(docx-core, docx-mcp): add BDD tests for table context and table markers - Add 14 BDD tests for table context derivation: simple table, paragraph parity, w:ins-wrapped rows, gridSpan, vMerge, multi-paragraph cells, empty cells, multiple tables, mixed body content, nested tables, renderToon markers, th/td styles, formatToonDataLine, collectTableMarkerInfo - Add 4 pagination tests for table markers: toon output markers, paragraphsReturned not inflated, simple format markers, JSON table_context * docs(openspec): add change proposal for table context in document view - Add proposal, delta specs (docx-primitives, mcp-server), and task checklist for the add-table-context-to-document-view change - Add E2E test script for visual inspection of table rendering * docs(openspec): update spec to reflect header-dedup in #TABLE marker The #TABLE marker no longer repeats column headers — they appear exactly once in the th(0,N) data rows which carry editable _bk_* IDs. * chore: add serial IDs to table context spec scenarios and fix spec-coverage - Add SDX-TABLE-01..12 serial IDs to delta spec scenarios - Update test .openspec() annotations to use serial IDs (DRY) - Fix validators to resolve bare serial IDs in .openspec() calls - Add TEST_FEATURE constants for spec-coverage discovery * chore(openspec): archive table-context, inplace-cross-run, and mixed-status changes Archive three completed changes into canonical specs: - add-table-context-to-document-view → docx-primitives + mcp-server - update-inplace-cross-run-recovery → docx-comparison - fix-inplace-mixed-status-runs → archive only (no delta specs) * test: add 13 coverage tests for table context edge cases and budget renderers Covers getDirectChildrenByName, empty tables, gridSpan defaults, multi-paragraph headers, consecutive tables, compact mode, renderSimpleWithTableMarkers, and mid-table budget truncation paths. * chore: retrigger CI * Add MCP Registry metadata for SafeDocx discoverability - Add server.json conforming to 2025-12-11 MCP Registry schema - Add mcpName field, server.json to files array, and 8 new keywords in package.json - Extend bump_version.mjs to sync server.json version in check and bump modes - Add server.json version validation to release workflow preflight job - Check off registry listing item in mcp-docs-checklist * chore: add tables test, update README branding, and regenerate coverage baselines * chore(release): bump workspace versions to 0.4.0
1 parent 982499f commit 9a02666

18 files changed

Lines changed: 548 additions & 42 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ jobs:
5454
echo "Tag version ($TAG_VERSION) must match packages/safe-docx-mcpb/manifest.json version ($MANIFEST_VERSION)."
5555
exit 1
5656
fi
57+
SERVER_VERSION="$(node -e "const fs=require('fs');const s=JSON.parse(fs.readFileSync('./packages/safe-docx/server.json','utf8'));process.stdout.write(s.version)")"
58+
if [ "$TAG_VERSION" != "$SERVER_VERSION" ]; then
59+
echo "Tag version ($TAG_VERSION) must match packages/safe-docx/server.json version ($SERVER_VERSION)."
60+
exit 1
61+
fi
5762
5863
- name: Verify release commit is on main
5964
run: |

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
[![CI](https://github.com/usejunior/safe-docx/actions/workflows/ci.yml/badge.svg)](https://github.com/usejunior/safe-docx/actions/workflows/ci.yml)
44
[![codecov](https://img.shields.io/codecov/c/github/usejunior/safe-docx/main)](https://app.codecov.io/gh/usejunior/safe-docx)
55

6-
Use coding agents for paperwork too.
6+
**safe-docx** by [UseJunior](https://usejunior.com) — use coding agents for paperwork too.
7+
8+
Part of the [UseJunior developer tools](https://usejunior.com/developer-tools/safe-docx).
79

810
Safe Docx is an open-source TypeScript stack for surgical editing of existing Microsoft Word `.docx` files. It is built for workflows where an agent proposes changes and a human still needs reliable, formatting-preserving document edits.
911

@@ -133,6 +135,11 @@ npm run coverage:packages:check
133135
npm run coverage:matrix
134136
```
135137

138+
## See Also
139+
140+
- [Open Agreements](https://github.com/open-agreements/open-agreements) — fill standard legal templates with coding agents (NDAs, SAFEs, NVCA)
141+
- [UseJunior Developer Tools](https://usejunior.com/developer-tools/safe-docx) — product page with install options and tool catalog
142+
136143
## Governance
137144

138145
- [Contributing Guide](CONTRIBUTING.md)
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
{
2-
"allowed_allure_test_files": []
3-
}
1+
{"allowed_allure_test_files": []}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"generated_at": "2026-03-01T00:30:00.000Z",
2+
"generated_at": "2026-03-14T16:27:41.537Z",
33
"packages": {
44
"docx-core": {
5-
"lines": 83.45,
6-
"branches": 81.77,
7-
"functions": 88.48,
8-
"statements": 83.45,
5+
"lines": 84.97,
6+
"branches": 83.8,
7+
"functions": 90.52,
8+
"statements": 84.97,
99
"deltas": {
1010
"lines": null,
1111
"branches": null,
@@ -14,10 +14,10 @@
1414
}
1515
},
1616
"docx-mcp": {
17-
"lines": 85.80,
18-
"branches": 78.54,
19-
"functions": 93.29,
20-
"statements": 85.80,
17+
"lines": 87.07,
18+
"branches": 80.72,
19+
"functions": 93.04,
20+
"statements": 87.07,
2121
"deltas": {
2222
"lines": null,
2323
"branches": null,
@@ -27,9 +27,9 @@
2727
}
2828
},
2929
"aggregate": {
30-
"lines_mean": 84.68,
31-
"branches_mean": 80.15,
32-
"functions_mean": 90.88,
33-
"statements_mean": 84.68
30+
"lines_mean": 86.02,
31+
"branches_mean": 82.26,
32+
"functions_mean": 91.78,
33+
"statements_mean": 86.02
3434
}
3535
}

docs/safe-docx/mcp-docs-checklist.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ Before adding more docs, trim anything that matches one of these:
4848
- [x] Generate tool docs from schema source (`docs/tool-reference.generated.md`).
4949
- [x] Add three golden prompts.
5050
- [ ] Publish `.mcpb` artifact in CI release flow.
51-
- [ ] List public package in MCP Registry when open-source launch is ready.
51+
- [x] List public package in MCP Registry when open-source launch is ready.
5252
- [ ] Add concise troubleshooting section in package README after first support feedback cycle.

package-lock.json

Lines changed: 27 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "safe-docx-suite",
3-
"version": "0.3.1",
3+
"version": "0.4.0",
44
"private": true,
55
"description": "Monorepo for Safe DOCX packages",
66
"repository": {

packages/allure-test-factory/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@usejunior/allure-test-factory",
3-
"version": "0.3.1",
3+
"version": "0.4.0",
44
"description": "Shared Allure test helpers for vitest — BDD context, OpenSpec auto-inference, Prism.js highlighting",
55
"type": "module",
66
"exports": {

packages/docx-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@usejunior/docx-core",
3-
"version": "0.3.1",
3+
"version": "0.4.0",
44
"description": "OOXML (.docx) core library: primitives, comparison, and track changes",
55
"type": "module",
66
"main": "dist/index.js",

packages/docx-core/src/testing/DOCX_COMPARISON_OPENSPEC_TRACEABILITY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This matrix maps canonical spec `#### Scenario:` entries to scenario mappings ex
2121
| Continuation pattern inherits formatting | covered | `src/openspec.traceability.test.ts` | |
2222
| Creating atom with revision detection | covered | `src/openspec.traceability.test.ts` | |
2323
| Creating atom without revision context | covered | `src/openspec.traceability.test.ts` | |
24+
| Cross-run pass rescues inplace output | missing | n/a | No scenario mapping found in current tests |
2425
| Custom footnote marks respected | covered | `src/openspec.traceability.test.ts` | |
2526
| Custom threshold applied | covered | `src/openspec.traceability.test.ts` | |
2627
| Different properties | covered | `src/openspec.traceability.test.ts` | |
@@ -48,6 +49,7 @@ This matrix maps canonical spec `#### Scenario:` entries to scenario mappings ex
4849
| Partial overlap | covered | `src/openspec.traceability.test.ts` | |
4950
| Proper nested list renders hierarchically | covered | `src/openspec.traceability.test.ts` | |
5051
| Range IDs properly paired | covered | `src/openspec.traceability.test.ts` | |
52+
| Rebuild fallback only after all inplace passes fail | missing | n/a | No scenario mapping found in current tests |
5153
| Remove existing revision tracking | covered | `src/openspec.traceability.test.ts` | |
5254
| Reserved footnote IDs excluded from numbering | covered | `src/openspec.traceability.test.ts` | |
5355
| Run with properties | covered | `src/openspec.traceability.test.ts` | |
@@ -61,6 +63,7 @@ This matrix maps canonical spec `#### Scenario:` entries to scenario mappings ex
6163
| Status for moved destination content | covered | `src/openspec.traceability.test.ts` | |
6264
| Status for moved source content | covered | `src/openspec.traceability.test.ts` | |
6365
| Status for unmatched atoms | covered | `src/openspec.traceability.test.ts` | |
66+
| Table-heavy run-fragmented templates preserve tracked table structure | missing | n/a | No scenario mapping found in current tests |
6467
| Text becomes bold | covered | `src/openspec.priority-scenarios.test.ts`, `src/openspec.traceability.test.ts` | |
6568
| Unknown property name | covered | `src/openspec.traceability.test.ts` | |
6669

0 commit comments

Comments
 (0)