jubarte 0.21.0

Word-faithful DOCX redline engine — compare two Word documents into a tracked-changes document that opens cleanly in Microsoft Word; list, accept, or reject revisions
Documentation
1
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
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
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
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
<!--
SPDX-FileCopyrightText: 2026 Jandira Technologies, LLC

SPDX-License-Identifier: Apache-2.0
-->

> **See every page side by side: [jandira-tech.github.io/neurotic_docx_bench]https://jandira-tech.github.io/neurotic_docx_bench/**  
> jubarte vs Microsoft Word, docxide-pdf, LibreOffice, PyMuPDF Pro, MiniPdf, rdocx and office2pdf on 808 documents, DOCX to PDF, scored per page.

# jubarte

**Word-faithful DOCX redlines and rendering, without Word.**

Compare two Word documents into native tracked changes, inspect or resolve
changes programmatically, apply validated edit plans, and render DOCX to PDF
or PNG — from Rust, Python, Node/browser, or the CLI.

[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/15267/badge)](https://www.bestpractices.dev/projects/15267)
[![CI](https://github.com/jandira-tech/jubarte/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/jandira-tech/jubarte/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/jandira-tech/jubarte/branch/main/graph/badge.svg)](https://codecov.io/gh/jandira-tech/jubarte)
[![CodSpeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://app.codspeed.io/jandira-tech/jubarte?utm_source=badge)
[![crates.io](https://img.shields.io/crates/v/jubarte.svg)](https://crates.io/crates/jubarte)
[![docs.rs](https://docs.rs/jubarte/badge.svg)](https://docs.rs/jubarte)
[![PyPI](https://img.shields.io/pypi/v/jubarte-docx.svg)](https://pypi.org/project/jubarte-docx/)
[![npm](https://img.shields.io/npm/v/jubarte-wasm.svg)](https://www.npmjs.com/package/jubarte-wasm)
[![MSRV](https://img.shields.io/badge/MSRV-1.94-blue)](./Cargo.toml)
[![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
[![Socket Badge](https://badge.socket.dev/cargo/package/jubarte/0.21.0)](https://badge.socket.dev/cargo/package/jubarte/0.21.0)

Jubarte is an in-process DOCX engine for applications that need Microsoft
Word-style review workflows without automating Microsoft Word or LibreOffice.

- **Compare DOCX → tracked DOCX** with native insertions, deletions, moves and
  formatting changes.
- **List, accept or reject changes** globally or selectively by change ID,
  author and kind.
- **Render DOCX → PDF / PNG** with an independent Word-oriented layout engine.
- **Inspect and edit documents safely** using paragraph IDs, source hashes and
  atomic JSON edit plans.
- **Use the same core engine everywhere**: Rust, CLI, Python and WebAssembly
  for Node/browser.
- **Keep the original package**: relationships, styles, headers/footers,
  notes, media and other DOCX parts are preserved by the comparison workflow.

> Jubarte is not affiliated with Microsoft. “Word-faithful” describes
> engineering targets measured against Microsoft Word behavior; it is not a
> claim that every DOCX will render byte-for-byte or page-for-page identically.

**Live benchmark, every page against Microsoft Word:
[jandira-tech.github.io/neurotic_docx_bench](https://jandira-tech.github.io/neurotic_docx_bench/)**
· tables: [neurotic_docx_bench RESULTS.md](https://github.com/jandira-tech/neurotic_docx_bench/blob/main/RESULTS.md)

## Feedback and contributions

Report bugs and request enhancements in the public
[issue tracker](https://github.com/jandira-tech/jubarte/issues), which
also archives reports and responses. English reports are welcome. See
[CONTRIBUTING.md](CONTRIBUTING.md) for pull requests, coding requirements,
building and tests, and [SECURITY.md](SECURITY.md) for private vulnerability
reports. The [OpenSSF evidence review](docs/maintainers/OPENSSF.md) tracks the criteria
and outstanding maintainer attestations.

## Quick start

Install the CLI:

```sh
cargo install jubarte
jubarte --version
```

Prebuilt archives are also published on
[GitHub Releases](https://github.com/jandira-tech/jubarte/releases).
Check the assets attached to the release you intend to install.

### Compare two Word documents

```sh
jubarte original.docx modified.docx \
  -o redline.docx \
  --author "Reviewer"
```

`redline.docx` contains native Word tracked changes.

Without `-o`, jubarte prints the redline as the agent view and writes
nothing; `-o redline.pdf` renders it instead.

### Inspect and resolve tracked changes

```sh
jubarte changes redline.docx          # one change per line (a replacement is one): r12, kind, target, author, paragraph, text

# Resolve one specific change and leave the others tracked:
jubarte accept redline.docx \
  -o partially-accepted.docx \
  --id r12

# Or resolve everything:
jubarte accept redline.docx -o final.docx
jubarte reject redline.docx -o original-state.docx
```

Selection flags can be repeated and combined:

```sh
jubarte reject redline.docx \
  -o reviewed.docx \
  --author "Reviewer A" \
  --kind formatting
```

### Render DOCX to PDF or PNG

```sh
# PDF
jubarte convert redline.docx \
  -o redline.pdf \
  --revisions word \
  --compress

# Page images: redline-page-01.png, redline-page-02.png, ...
jubarte convert redline.docx \
  -o redline.png \
  --dpi 120
```

No Microsoft Word or LibreOffice process is launched.

## How the workflow fits together

```mermaid
flowchart LR
    A[original.docx] --> C[Compare]
    B[modified.docx] --> C
    C --> D[redline.docx]
    D --> E[List changes]
    E --> F[Accept / Reject]
    F --> G[resolved.docx]

    H[DOCX] --> I[Read]
    I --> J[JSON edit plan]
    J --> K[Edit]
    K --> L[clean.docx]
    K --> M[redline.docx]

    D --> N[Render]
    G --> N
    L --> N
    M --> N
    N --> O[PDF / PNG]
```

## Documentation

Per-surface guides, each ending in a **generated** reference (CLI help from
the real runner, API from the shipped module) that CI keeps drift-free —
`scripts/gen_docs.sh` regenerates them:

- [Rust guide]docs/rust.md — crate features, API tour, rendering styles, `jubarte` CLI reference
- [Python guide]docs/python.md — wheel and `uvx`, the three library tiers, generated API reference
- [Node and browser guide]docs/javascript.md — `jubarte-wasm` and `npx jubarte-redlines`, entry points, generated API reference

Topical documents: [Markdown pipeline](docs/MARKDOWN.md) ·
[Word differences](docs/WORD_DIFFERENCES.md) ·
[Word layout rules](docs/WORD_LAYOUT_RULES.md) ·
[comment balloons](docs/WORD_COMMENT_BALLOONS.md) ·
[self-update](docs/SELF_UPDATE.md) ·
[benchmark classes](docs/maintainers/bench_classes.md) ·
[bomb prevention](docs/bomb_prevention.md) ·
[per-release API snapshots](docs/api/README.md).

## Install

### CLI

```sh
cargo install jubarte
```

The installed binary is named `jubarte`.

The Python wheel and the npm package also run the CLI without an
install:

```sh
uvx --from jubarte-docx jubarte redline a.docx b.docx -o redline.docx
npx jubarte-redlines redline a.docx b.docx -o redline.docx
```

Both runners speak the shared command set — `compare`/`redline`, `diff`,
`changes`, `accept`, `reject`, `read`, `edit`, `add`,
`convert`, `capabilities` — and share the Rust clap parser for help,
defaults, aliases and usage errors. The Python wheel also runs `comments`,
`validate` and `visual-diff`; `append`, `scrub`, `debug` and `self-update`
remain in the binary. The npm CLI renders no PNG pages
([`jubarte-wasm/cli/README.md`](jubarte-wasm/cli/README.md)).

For a GitHub-style text review of two Word documents:

```sh
jubarte diff a.docx b.docx --format github
jubarte diff a.docx b.docx --format github --context 5 -o changes.patch
uvx --from jubarte-docx jubarte diff a.docx b.docx --format github
npx jubarte-redlines diff a.docx b.docx --format github
```

`github` (also `unified` or `text`) prints a standard unified patch with
`diff --git`, file headers, hunk ranges and context. It compares the complete
`debug -c text` view, including existing revision marks and story text in
headers, footers, notes, comments, tables and text boxes. It extracts all content before display clipping and never caps the number of changes, and does not create an implicit
DOCX. Header/footer part renumbering is paired by section role. This is a
patch of extracted **text**, for review; it cannot patch a binary DOCX.
Formatting and media differences belong to `compare`, `debug` or `visual-diff`.

CriticMarkup keeps its existing role: representing a document's current
content with its tracked marks and comments. `github` gives a separate
comparison of those contents; it does not accept, reject or reinterpret the
marks unless `--accept-changes` is requested. `--format word` always accepts
ALL changes in both inputs first, then produces fresh word-level CriticMarkup.
`normal`, `context` and `side-by-side` are also available. Long lines show a
70-character window around the first change; `--full-lines` shows everything.
See [text diff details](docs/TEXT_DIFF.md).

Markdown sits beside Word: `jubarte diff` prints the changes between any
two documents, Word or Markdown, as a git-style patch; `jubarte convert
draft.md` writes CommonMark (with CriticMarkup as tracked changes) to
DOCX/PDF/PNG; and `jubarte edit` writes the redline's patch as
`patch.diff`. See [`docs/MARKDOWN.md`](docs/MARKDOWN.md).

For a source checkout, the repository also contains installation scripts that
can install supplemental fonts used by the renderer:

```sh
scripts/install.sh
scripts/install.sh --fonts-only
```

On Windows, see `scripts/install.ps1`.

### Rust library

```sh
cargo add jubarte --no-default-features
```

The crate is `jubarte`, the import path `jubarte`. It re-exports the
workspace crates (`jubarte-dom`, `jubarte-opc`, `jubarte-redlines` for
comparison, `jubarte-render`, `jubarte-doc`, `jubarte-markdown`,
`jubarte-edit`), which can also be depended on alone.
Since 0.19.0, `jubarte-redlines` on crates.io is the compare-only crate
(library name `jubarte_redlines`); a 0.18 dependency on `jubarte-redlines`
moves to `jubarte = "0.19"` and keeps its `use jubarte::…` paths (see the
[changelog](CHANGELOG.md)).

```rust
use jubarte::{convert, document_comparer};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let original = std::fs::read("original.docx")?;
    let modified = std::fs::read("modified.docx")?;

    let redline =
        document_comparer::compare_documents(&original, &modified, "Reviewer")?;
    std::fs::write("redline.docx", &redline)?;

    let pdf = convert::docx_to_pdf(&redline)?;
    std::fs::write("redline.pdf", &pdf)?;

    Ok(())
}
```

The default crate features include the CLI, fast allocator, self-update
support and the embedded fonts (`embedded-fonts`). Library-only consumers
can disable defaults and opt into features deliberately. `cli` on its own
(`--no-default-features --features cli`) builds without the 16 embedded font
programs: a render then takes its faces from the document and the machine,
and refuses a family the document does not embed, the machine does not
have, and no open substitute covers with `FONT_UNAVAILABLE`, before writing
anything.

MSRV: **Rust 1.94**.

### Python

Python requires CPython 3.10 or later.

```sh
pip install jubarte-docx
```

Low-level byte API:

```python
from pathlib import Path
from jubarte import (
    compare_documents,
    get_revisions,
    docx_to_pdf,
)

original = Path("original.docx").read_bytes()
modified = Path("modified.docx").read_bytes()

redline = compare_documents(
    original,
    modified,
    author="Reviewer",
)
Path("redline.docx").write_bytes(redline)

for revision in get_revisions(redline):
    print(revision)

Path("redline.pdf").write_bytes(
    docx_to_pdf(redline, revisions="word")
)
```

The richer `Document` API additionally supports inspection, Markdown
projection, selective change resolution, edit plans, PDF/PNG rendering and
preview.

### Node and browser

Node 18+:

```sh
npm install jubarte-wasm
```

```js
const {
  compareDocuments,
  docxToPdf,
  listChanges,
  acceptChanges,
  rejectChanges,
} = require("jubarte-wasm");

const redline = compareDocuments(originalBytes, modifiedBytes, "Reviewer");
const pdf = docxToPdf(redline, false, "word");
```

For applications that do not need the PDF renderer, use the slim package
exports:

```js
const {
  compareDocuments
} = require("jubarte-wasm/slim");
```

Browser builds are exported from `jubarte-wasm/web` and
`jubarte-wasm/web-slim`.

### MCP server and Agent Skill

The native `jubarte mcp --root /absolute/documents` server exposes the Rust
engine over stdio. Both full and slim skill packages contain its tools,
immutable skill text and MCP Apps document card. `docx_view` accepts at most five
rendered pages total across all documents per call; larger requests return
`INVALID_ARGUMENT`. Full embeds fonts; slim
needs host fonts for PDF/PNG. Run `jubarte doctor --json`; a font-less render
returns `FONT_UNAVAILABLE`. Read, edit, compare and validate need no fonts.
Full exceeds the 16 MiB skill ceiling; choose slim for hosts with that limit.

Use a tagged release containing the skill artifacts. `VERSION`, `TARGET`,
`VARIANT`, `PLATFORM`, extraction and verification are explained in the
[installation guide](docs/adoption/skill.md); the source checkout contains no
bundled executable. Generated manifests do not prove directory acceptance.

In Claude Code 2.1.275 or later, install the default slim plugin for macOS arm64
in one step. The command reads the repository's marketplace, which each
release pins to its own archives and their digests:

```text
/plugin install jubarte-slim-macos-aarch64 --marketplace jandira-tech/jubarte
```

For the full variant with embedded fonts:

```text
/plugin install jubarte-full-macos-aarch64 --marketplace jandira-tech/jubarte
```

For older Claude Code, keep the two-step released-marketplace form below.

| Market | Install after download and extraction |
| --- | --- |
| Claude Code plugin marketplace | `claude plugin marketplace add "https://github.com/jandira-tech/jubarte/releases/download/v$VERSION/marketplace.json"`, then `claude plugin install jubarte-slim-macos-aarch64@jubarte` (choose your CPU/variant) |
| Claude Desktop | `open "jubarte-$VARIANT-$VERSION-$PLATFORM.mcpb"` on macOS, or open the bundle through Desktop's extension UI |
| Gemini CLI extension | `gemini extensions install "$(pwd)/plugin"` |
| Codex | `codex mcp add jubarte -- "$(pwd)/skill/jubarte/bin/jubarte" mcp --root /absolute/documents` |
| MCP Registry | `gh release download "v$VERSION" --repo jandira-tech/jubarte --pattern "server-$VARIANT-$PLATFORM.json"`; install its referenced MCPB in a compatible client |
| Agent Skills folder | `mkdir -p /absolute/project/.agents/skills` then `cp -R skill/jubarte /absolute/project/.agents/skills/` |
| Smithery via MCPB | Download the same `.mcpb` and use Smithery's MCPB import/upload flow; a public listing remains subject to acceptance |
| Direct stdio | `/absolute/path/to/skill/jubarte/bin/jubarte mcp --root /absolute/documents` |

skills.sh / agentskills listings and Codex's plugin loader are covered in the
[skill guide](docs/adoption/skill.md). Tool schemas, security and protocol:
[docs/adoption/mcp.md](docs/adoption/mcp.md).

## CLI reference

Every command, from `jubarte --help` (regenerated by `scripts/gen_docs.sh`).
The complete per-command `--help` of every runner (the `jubarte` binary, the
Python wheel, the npm CLI) is in the [per-surface guides](#documentation).

<!-- gen:cli-summary:start -->
| Command | What it does |
|---|---|
| `jubarte ORIGINAL MODIFIED` | Read, edit, compare and render Word documents |
| `jubarte compare` | Compare documents: print the redline as the agent view, or write it with -o [alias: redline] |
| `jubarte changes` | List tracked changes with IDs for accept, reject and edit plans |
| `jubarte accept` | Accept all tracked changes, or select by ID, author or kind |
| `jubarte reject` | Reject all tracked changes, or select by ID, author or kind |
| `jubarte convert` | Convert Word or Markdown to DOCX, PDF, PNG or Markdown |
| `jubarte diff` | Review differences as GitHub, word, normal, context or side-by-side text |
| `jubarte read` | Read the agent view: YAML header, `<!-- pN -->` id lines, changes and comments with ids |
| `jubarte edit` | Edit a document: -p WHERE with --anchor, --content, --delete, --resolve, --reply, --accept, --reject, --strike, --restore or --style (several -p per command), or a JSON plan. Writes FILE_modified.docx (--in-place replaces FILE; --out-dir: the bundle), then prints SUCCESS and a fenced before/after diff of the full agent views (refusal: exit 3) |
| `jubarte add` | Add a paragraph, a comment or a reply: -p WHERE --content TEXT (several -p per command). Writes FILE_modified.docx, as edit does (--in-place replaces FILE), and prints SUCCESS and a fenced before/after diff of the full agent views |
| `jubarte capabilities` | What this binary can do, for agents choosing an operation |
| `jubarte doctor` | Report what this build can draw with: the fonts compiled in, the folders searched, and the four open substitute families found on this machine. Also lists installed script fallback candidates. This is not a document-specific availability check |
| `jubarte visual-diff` | Compare rendered pages pixel by pixel (different pages: exit 5) |
| `jubarte comments` | List comments, threads and the text they annotate |
| `jubarte append` | Join documents in order, preserving images, styles, lists and notes |
| `jubarte validate` | Check Word validity, tracked edits, accessibility, style and structure; or repair Word validity |
| `jubarte check` | Check a document against a source-bound expectation contract |
| `jubarte scrub` | Remove authors, editing IDs, metadata and comments before sharing |
| `jubarte self-update` | Check or install a release from GitHub |
<!-- gen:cli-summary:end -->

### Compare

```text
jubarte ORIGINAL MODIFIED [OPTIONS]
```

Without `-o`, `jubarte A B` (or `jubarte compare A B`) prints the redline
as the agent view (the `read` options apply) and writes nothing. With `-o`,
the extension picks what is written:

| `-o` | Writes |
|---|---|
| `.docx` (or no or an unknown extension) | the redline |
| `.md`, `.markdown`, `.txt` | the agent view of the redline; CriticMarkup when both inputs are Markdown |
| `.pdf` | the redline, rendered (`--revisions`, `--pages`, `--changed-pages` apply) |
| `.png` | one `STEM-page-NN.png` per page |
| `.json` | the snapshot of the redline, as `read --json` prints it |

`jubarte FILE` alone is `jubarte read FILE`; a lone name without an
extension is taken for a mistyped task, so read such a file with
`jubarte read FILE`.

Common options:

| Option | Purpose |
|---|---|
| `-b, --original FILE` | Original document |
| `-m, --modified FILE` | Modified document |
| `-o, --output FILE` | Write the redline; the extension picks the format (above) |
| `-a, --author NAME` | Revision author (default: `Redline`) |
| `-d, --datetime ISO8601` | Revision timestamp (default: now, UTC) |
| `--detail-threshold RATIO` | Comparison-detail tuning |
| `--mode word|powertools` | Word-oriented or classic PowerTools comparison behavior |
| `--force` | Replace an existing output |
| `--reference-doc FILE`, `--critic`, `--resource-path DIR` | Markdown inputs |
| `--revisions`, `--dpi`, `--pages`, `--changed-pages` | Rendering, for `-o FILE.pdf` or `.png` |
| `-q, --quiet` | No status lines on success; a reading task still prints what it read |

The command line dates the revisions now; pin `-d 1970-01-01T00:00:00Z` for
byte-identical output from identical inputs. The library calls keep the
epoch as their default, so they stay deterministic.

### List tracked changes

```sh
jubarte changes FILE.docx
jubarte changes FILE.docx --json
```

`changes` is intended for individually addressable review operations and
reports stable IDs while the corresponding tracked change remains present.
The text listing prints short ids (`r12`, `header1.r1`, `footnotes.r3`);
`--json` prints JSON Lines with the same short `id` (and `ref`). `--id`
takes the short ids: `r12`, `r1+2` (both marks of one
change), `header1.r1`. A change that holds a comment's reference mark ends
its line with `holds comment c4's mark` (`holds comment marks c4, c5` for a
thread's reply too), and `--json` lists them in `holds_comments`: resolving
the change so its content goes (accepting a deletion, rejecting an
insertion) removes those threads, as Word does. The `read` view says so on
the note: `{>>c4 @AC in r13: …<<}` when the note prints outside r13.


With human-readable CLI output, every command that writes a DOCX from a
document prints a confirmation after publication (unless `-q`):

````text
SUCCESS:
~~~~diff
--- before in.docx
+++ after out.docx
@@ -1,3 +1,3 @@
 ---
-source: in.docx
+source: out.docx
 sha256: …
~~~~
````

The diff compares the full input and output agent views, including `source:`
and `sha256:`. It uses three context lines; the output view comes from the
published bytes. Markdown conversion uses the original Markdown text as its
before-view; comparison uses its first input. Identical views print
`no differences` inside the fence. The fence grows past any leading tilde
run in the diff. Edit's former changed-range view and resolved-lines output
are replaced by this block; an existing bundle summary stays before it,
with one block per DOCX. The `wrote …` lines and notes remain on stderr.
`-q` silences the block, summary and status; warnings and errors still print.
Dry runs, saved plans and non-DOCX outputs retain their existing output.
Template generation writes a JSON plan; applying it writes the DOCX.
Typed `--json`/`--jsonl` delivery retains its machine-readable receipt.

### Accept or reject

```sh
jubarte accept FILE.docx -o OUTPUT.docx
jubarte reject FILE.docx -o OUTPUT.docx
```

Optional selection filters:

```text
--id ID          r12, r1+2, header1.r1
--author NAME
--kind insertion|deletion|move|formatting
```

Filters are repeatable. Categories combine, so a change must satisfy each
category you supplied. `jubarte edit FILE -p r12 --accept` (or `--reject`)
resolves one change and writes `FILE_modified.docx`.

Add `--keep-nested-comment` to `accept` or `reject` to preserve a comment
and its replies when settlement removes their whole anchor. Their markers
move together to an empty, untracked anchor where the removed text was;
the command reports, for example, `kept c0 and its reply c1 on an empty anchor
in p1`. Partial overlaps keep the existing behavior. The default removes
wholly removed threads, as Word does.

### Convert to PDF / PNG

```sh
jubarte convert FILE.docx [OPTIONS]
```

| Option | Purpose |
|---|---|
| `-o, --output FILE` | Output path; the extension picks the format: `.docx`, `.md`, `.pdf`, `.png` (pages named `STEM-page-NN.png`) or `.json` (the snapshot) |
| `--dpi DPI` | PNG resolution; default 96 |
| `--compress` | Deflate PDF content streams |
| `--revisions conventional|word|custom` | Tracked-change visualization |
| `--keep-nested-comment` | With `--track-changes accept` or `reject`, keep comment threads whose whole anchor is removed, on an empty anchor; off by default |
| `--revision-palette SPEC` | Custom change colors/lines |
| `--font-report FILE` | Write font-resolution JSON |
| `--report FILE` | Write page/render report |
| `--force` | Replace existing output |
| `--fail-on-substitution` | Exit 4 when a requested font was substituted |
| `--pages SPEC` | Only these pages, for example `1-3,7`, in the PDF and the PNGs alike; PNGs keep the document's page numbers |
| `--move-comments` | List comments after the last page; the text keeps its tint and a `[JR1]` marker |
| `--changed-pages` | Keep only the pages a change touches: a body or note revision, a comment anchor, or the first page a revised header or footer paints on (page numbers stay the document's) |
| `-f, --from` / `-t, --to` | `docx`, `md`, `pdf`, `png` or `json`, when `-o` has no extension: Markdown in (CriticMarkup becomes tracked changes) or out ([`docs/MARKDOWN.md`]docs/MARKDOWN.md) |

Without `-o`, a `.docx` becomes `STEM.pdf` beside it and Markdown becomes
`STEM.docx`; `-t md` prints to stdout.

Markdown to Word: a change or comment that names no author or date (by its
tag or the `authors:` table) takes `-a, --author` and `-d, --datetime`,
else the front matter's `author:` and `last_modified:` (else `modified:`,
`date:`, `created:`), else the `--reference-doc`'s `dc:creator` and
`dcterms:created`, else `Redline` and now. Pin `-d 1970-01-01T00:00:00Z`
for byte-identical output; the library calls keep `Redline` and that
epoch as their default and read no reference document's metadata.
`compare`, `edit`, `add` and `diff` never take the files' metadata: their
changes carry `--author` and `--datetime` (default `Redline` and now).

Examples:

```sh
jubarte convert contract.docx
jubarte convert redline.docx --revisions word
jubarte convert redline.docx -o pages.png --dpi 144
jubarte convert long.docx -o excerpt.pdf --pages 1-3,7
jubarte convert redline.docx -o changed.pdf --changed-pages
jubarte convert contract.docx --compress --font-report fonts.json
```

A document with comments gets Word's markup pane: each comment in a
balloon beside its range, joined to it by a dotted connector, with the
range tinted and bracketed. As Word does, no style writes a PDF comment
annotation: a viewer would paint it as a note icon over the text
([`docs/WORD_DIFFERENCES.md`](docs/WORD_DIFFERENCES.md)).

A custom palette can be supplied with:

```sh
jubarte convert redline.docx \
  --revisions custom \
  --revision-palette \
  "deleted=#AA0000:strike,inserted=#0055FF:double-underline"
```

### Read a document

```sh
jubarte read contract.docx               # the agent view
jubarte read contract.docx --json        # the snapshot: paragraphs, runs, tables, changes, comments
jubarte read contract.docx --tables      # top-level tN grids, with nested cell paths
jubarte read contract.docx --tables -p t0 # t0 and its nested tables: grid, then view
jubarte read contract.docx -p p12,p40-p48 -o excerpt.md
```

`read` prints the agent view: a YAML header (`sha256:` of the file, the
revision and comment counts, authors and their handles, page setup,
styles, headers, footers), then Markdown with an id line before every
paragraph (`p12`, the body's paragraph 12) and an id on every
tracked change and comment (`r3+4` is the two marks with `w:id` 3 and 4, `c5`
is comment 5, `header1.r1` a change in a header). A table cell's paragraph is
`t0.row1.cell2`, a footnote's `footnotes.p0`, and `c5.text` the text comment
5 covers. No id needs quoting in bash, zsh or csh.

`--json` prints the snapshot instead: document metadata, story and
paragraph coordinates, `source_sha256`, runs, structural limitations,
tables, content controls, and the changes and comments with their short
`ref`. The selection flags (`-p`, `--head`, `--tail`, `--changed`, `--by`)
narrow it as they narrow the view. `-o FILE.md` or `-o FILE.json` writes
either to a file.

The snapshot uses `schema_version: 3`. `changes` lists logical changes:
a change Word wrote as several marks is one entry with its `members`,
and a deletion followed by its author's insertion is one `replacement`.
`summary.tables` and `tables[]`
count top-level body tables only; each `index` is the view's `tN`.
Every table has a `nested` array (empty for a leaf), containing its cell tables.
A nested entry has `parent` (for example `t0.row2.cell0`) and no `index`.
A deeper parent includes the cell-local table ordinal, for example
`t0.row2.cell0.t0.row0.cell1`. Paragraph ids and edit-plan schemas are unchanged.

`--tables` numbers only top-level tables as `table N`, matching `tN` in
the view and `-p tN`. Nested tables follow their containing cell row,
indented two spaces per nesting level and labelled `nested in CELL_PATH`.
For example, `nested in t0.row2.cell0`; a further level uses
`t0.row2.cell0.t0.row0.cell1`. `--tables -p t0` includes this whole tree.

```text
<!-- p0 center -->
# Consulting Agreement

<!-- p1 justify -->
This Consulting Agreement (the “Agreement”) is made between Harbor Point Analytics LLC ("Consultant") and Juniper Freight Co. ("Client").

<!-- p2 -->
## 1. Services

<!-- p3 -->
Consultant will deliver the services in each Statement of Work, including {++quarterly++}{r0 @AC} route-cost reports and a {~~weekly~>monthly~~}{r1+2 @AC} review call.
```

Attribution uses braces after the change closer: `{++new++}{r1 @AL}`.
`{>>c5 @AC: note<<}` remains a comment. A deletion inside another author's
insertion names its parent with `{r3 @BO re r1 @AL}`. Distinct revision ids
stay separate; only a deletion directly followed in the rendered stream by
a live insertion from the same author forms `{~~old~>new~~}{r4+5 @AL}`.
Different inline dates keep the two marks separate. An inserted paragraph
mark is `¶{r7 @AL}`. To write literal attribution-shaped text after a closer,
escape the opening brace: `{++new++}\{r1 @AL}`; write literal `¶\{` likewise.

See [docs/MARKDOWN.md](docs/MARKDOWN.md#agent-view) for the grammar.

### Validate

```sh
jubarte validate contract.docx
jubarte validate contract.docx --json
jubarte validate contract.docx --repair fixed.docx
jubarte validate review/redline.docx --original contract.docx --author Claude
```

`validate` lists what makes Word refuse or repair a file, beyond what an
XSD sees: one line per finding (`code`, `part#path`, message, a `*` when
it is Word-fatal), or one JSON object each with `--json`. `--repair` writes
a copy with every repairable finding fixed and lists what remains;
`--original` with `--author` audits that every text change against the
original is a revision by that author (`UNTRACKED_EDIT`, `FOREIGN_AUTHOR`),
and that no other author's comment is gone, reworded, resolved or reopened
and every new comment is signed by that author (`FOREIGN_COMMENT`).
The `edits` rules also report permission endpoints lost from any part
(`PERMISSION_RANGE_DROPPED`); losing an editable region is not Word-invalid.
`--rules a11y,style,structure` adds accessibility, style and structure
findings (heading skips, images without alt text, tables without a header
row, literal bullets, stale caches), each located by paragraph id;
`--rules` also takes single rule codes.

`NESTED_SAME_REVISION` is non-fatal: direct same-kind nesting is `info`
(Word opens and reads it faithfully); alternating nesting such as
`ins > del > ins` is a `warning` because Word opens it but misreads
reject-all (#1134, Word probes 2026-10-17).

`NESTED_TEXT_BOX` is a Word-fatal Ring-1 error: a DrawingML or VML text box
inside another box's readable content prevents Word from opening the file
(#1132, Word probes 2026-10-18). The check covers every story part and ignores
nesting only in `mc:Fallback`; `--repair` leaves it unchanged.

Any `word` or `edits` finding exits 2, and so does any `error`; `--strict`
fails on warnings too. A file that cannot be read exits 1.

| Option | Purpose |
|---|---|
| `--json` | JSON Lines: one object per finding, nothing when there is none |
| `--rules SETS` | `word` (the default), `edits`, `a11y`, `style`, `structure`, or rule codes, comma-separated |
| `--strict` | Fail on warnings too |
| `--repair FILE` | Write the repaired package; remaining findings still exit 2 |
| `--original FILE` | Audit tracked edits against this original (needs `--author`) |
| `--author NAME` | The author every change must carry |
| `--force` | Replace an existing `--repair` output |

`jubarte audit FILE` still runs, as `validate --rules a11y,style,structure`
with a note; it is removed in 0.14.

### Scrub

```sh
jubarte scrub contract.docx -o outgoing.docx
jubarte scrub contract.docx -o outgoing.docx --rsids --docprops
```

Removes who touched a document before it goes out: author names (as one
alias, `--author-alias NAME`), rsids, the people and dates in the document
properties, and comments. Text and tracked changes stay. Without a flag all
four go, under the alias "Author"; with flags, only those given.

### Append documents

```sh
jubarte append a.docx b.docx c.docx -o combined.docx
jubarte append a.docx b.docx -o combined.docx --section-break continuous --keep-sections
```

B after A, then C after that, carrying images, links, styles, lists and
notes. Comments are dropped with a warning unless `--carry-comments`.
`--section-break` is `next-page` (the default), `continuous` or `none`;
`--keep-sections` keeps each document's page setup, headers and footers.

### Comments

```sh
jubarte comments contract.docx
jubarte comments contract.docx --json --author "Reviewer" --latest
```

Every comment with its thread (`parent`, `done`) and the text it is
anchored to. Edit plans reply to, resolve, edit and delete comments (see
the operation table below).

### Fields

```sh
jubarte convert contract.docx -o updated.docx --update-fields --report fields.json
```

`--update-fields` refreshes the cached results of `PAGEREF`, `REF`, `NUMPAGES`, `SEQ` and
`TOC` fields from jubarte's layout; TOCs are rebuilt from the headings. Field
codes stay, so Word can update them again. Page numbers are jubarte's layout,
not Word's ([`docs/WORD_DIFFERENCES.md`](docs/WORD_DIFFERENCES.md)). It
runs after `--track-changes accept|reject`; `--report` lists the fields
written with their old and new results.

### Compare rendered pages

```sh
jubarte visual-diff before.docx after.docx
jubarte visual-diff before.docx after.docx --out-dir pages --dpi 150 --json
```

Lays out and rasterizes both documents at one resolution and compares them
pixel for pixel. Exit 0 when every page is the same, 5 when any page
differs; `--out-dir` writes the changed pages, overlays and `diff.json`.

### Apply an edit plan

First read the source:

```sh
jubarte read contract.docx -o contract.json
```

Create `plan.json`:

```json
{
  "schema_version": 1,
  "source_sha256": "<the sha256: line of jubarte read>",
  "author": "Reviewer",
  "operations": [
    {
      "id": "term",
      "kind": "replace",
      "paragraph": "p12",
      "find": "two years",
      "replacement": "three years"
    }
  ]
}
```

Or record it from flags, one command at a time. Nothing is edited until
the plan runs:

```sh
jubarte edit contract.docx --plan plan.json -p p12 --anchor "two years" --content "three years"
jubarte add contract.docx --plan plan.json -p p14 --comment --content "Why three?"
```

Each recording is checked against `contract.docx` and pins its
`source_sha256`; one that does not apply leaves `plan.json` as it was.
`--consume` deletes the plan once it has been applied.

Preview it:

```sh
jubarte edit contract.docx \
  --plan plan.json \
  --out-dir review \
  --dry-run
```

Apply and render:

```sh
jubarte edit contract.docx \
  --plan plan.json \
  --out-dir review \
  --pdf \
  --png \
  --dpi 100
```

A successful edit can produce:

```text
review/
  clean.docx
  redline.docx
  patch.diff
  report.jsonl
  clean.pdf
  redline.pdf
  clean-page-01.png
  redline-page-01.png
  ...
```

Operation kinds (`jubarte capabilities` lists the ones the installed build
supports):

| Kind | What it does |
|---|---|
| `replace` | Replace `find` with `replacement` in one paragraph; only the words that differ are written, so kept words keep their formatting and characters (a curly quote or a non-breaking space stays where the replacement has the plain one); optional `format` for the new text, `"whole": true` for one deletion then one insertion as typed |
| `insert` | Insert text `after` or `before` a match, or at `position` `start`/`end` |
| `delete` | Delete a match |
| `rewrite` | Give a paragraph's whole new text; only the words that differ are edited |
| `format_run` | Restyle existing text as a tracked formatting change |
| `comment` | Comment on a match, a whole paragraph, or every paragraph up to `through` |
| `reply_comment`, `resolve_comment`, `edit_comment`, `delete_comment` | Work on a comment thread by `comment_id`. Rewording, resolving or deleting another author's comment is allowed and noted; `"others": "keep"` refuses it (`COMMENT_NOT_YOURS`) and a reply is the keeping move. `"rewrite_others_comments": true` is accepted and ignored |
| `strike` | Reject another author's insertion `revision` visibly: your tracked deletion inside it, with an optional `comment` on the struck words |
| `restore` | Reject another author's deletion `revision` visibly: your tracked copy of its words right after it, with an optional `comment` |
| `insert_paragraph` | A new paragraph after the anchor, with its properties (or those `like` selects) |
| `delete_paragraph` | Delete a paragraph, optionally commenting on the deleted text |
| `format_paragraph` | Style, alignment, line spacing, space before and after, as a tracked property change |
| `merge_paragraphs` | Join the next paragraph onto this one |
| `insert_table` | A table before or after a body paragraph, tracked as inserted rows |
| `list` | Bulleted, numbered or lettered list, tracked as property changes |
| `insert_footnote` | A footnote after an anchor |
| `insert_image` | A picture paragraph (PNG, JPEG, GIF, BMP or TIFF) |
| `insert_toc` | A table of contents field; with `"update_fields": true` it is filled from the headings |
| `page_setup` | Page size, orientation and margins |
| `watermark` | Word's diagonal text watermark in every default header (untracked) |
| `fill_control` | Fill a content control (text, choice, checkbox or date) by id, tag or alias |
| `redact` | Replace text with `█` blocks in both copies, untracked; refused if the text still occurs anywhere. No report, refusal or confirmation repeats the text or the document's copy of it: a plan with a redaction confirms with the published view, not the before/after diff |
| `settings` | `trackRevisions`, `updateFields` and document protection in `word/settings.xml` |

Plans are atomic: stale sources, ambiguous anchors, overlapping edits or
unsupported structures refuse the plan instead of making a guessed edit.

See
[`skills/jubarte/SKILL.md`](skills/jubarte/SKILL.md)
and
[`examples/agents/acme-letter`](examples/agents/acme-letter)
for the full plan schema and a complete example.

### Capabilities

```sh
jubarte capabilities          # one line per capability
jubarte capabilities --json   # the manifest: formats, ids, validate rules, operation kinds
```

Use this when an application or agent needs to discover the exact surface
supported by the installed build.

### Self-update

```sh
jubarte self-update --check
jubarte self-update
```

Optional:

```text
-y, --yes
--version VERSION
```

See [`docs/SELF_UPDATE.md`](docs/SELF_UPDATE.md).

### Debugging DOCX behavior

```sh
jubarte debug FILE.docx --list
jubarte debug FILE.docx --check render
jubarte debug FILE.docx -c text
jubarte debug FILE.docx -c runs
jubarte debug FILE.docx -c xml

jubarte debug diff A.docx B.docx
jubarte debug diff A.docx B.docx C.docx --full
```

`debug` is hidden from `jubarte --help`: it is a diagnostic tool for
engine work, not part of the stable surface. Debug catalogs cover package structure, fields, bookmarks, IDs, styles,
text boxes, revision changes, numbering, normalized XML/text/runs and render
information.

Use `jubarte <command> --help` for the authoritative option list for the
installed release.

## Rendering and fonts

The PDF engine reconstructs Word-oriented layout directly; it does not call
Microsoft Word or LibreOffice.

The documented rendering surface includes:

- tracked changes, and comments as Word's balloons in the markup pane
  (a resolved comment faded, a reply numbered under its thread);
- paragraph/run formatting and advanced line layout;
- CJK and RTL/complex-script text;
- installed and embedded fonts;
- merged, vertically merged, autofit and floating tables;
- DrawingML/VML graphics, text boxes, charts and SmartArt;
- raster and EMF/WMF images;
- headers, footers and floating frames;
- sections, columns, backgrounds and page borders;
- footnotes and selected fields.

Rendering fidelity still depends on fonts and on document features.
WebAssembly has no installed fonts: `docxToPdf` paints with the fonts a
document embeds and the bundled Carlito and Liberation faces, so Chinese,
Japanese or Korean text without an embedded font is not painted (see
[`KNOWN_ISSUES.md`](KNOWN_ISSUES.md), item 9).

Supplemental font lookup can be configured with:

```sh
export JUBARTE_FONT_DIR=/path/to/jubarte/fonts
export JUBARTE_FONT_INDEX=/path/to/font-index.tsv
```

Set:

```sh
export JUBARTE_FONT_INDEX=off
```

to disable the persistent font index, and:

```sh
export JUBARTE_SYSTEM_FONTS=off
```

to leave the system, Word and cloud-font folders out of the search: a render
then uses the fonts a document embeds, the faces compiled in and
`JUBARTE_FONT_DIR` alone, so it depends on no font the machine happens to
have. These variables, and `jubarte doctor` below, belong to the native
command line and Rust crates; the WebAssembly packages search no folders
and draw with the faces compiled in and the fonts a document embeds.

The Carlito and Liberation faces are compiled in by the crate's
`embedded-fonts` feature. A build without it draws with the faces of the
machine instead, and refuses a family that is neither installed there nor
covered by its open substitute with `FONT_UNAVAILABLE` (exit 1, nothing
written). `jubarte doctor` says which build it is and what the machine has:

```sh
jubarte doctor            # the faces compiled in, the folders searched, what is missing
jubarte doctor --json
```

`doctor --json` has `schema_version: 1`. Its family report covers the four
open substitutes; it is not a document-specific availability check. An
installed family outside that list can still render a document.

The `FONT_UNAVAILABLE` guarantee covers missing catalogue faces, not missing
script glyphs. CJK/Thai/Devanagari/Thaana without a covering document or
installed fallback face paint `.notdef` blanks, even if a Latin substitute
is available. `doctor` lists the installed styles of the known script
fallback candidates in `script_families`; an empty `host` means missing.
Neither this list nor the substitute list proves coverage of every glyph.

Default per-user font directories are documented in the installation section
of this repository.

For known Word-layout differences, see:

- [`docs/WORD_LAYOUT_RULES.md`]docs/WORD_LAYOUT_RULES.md
- [`docs/WORD_DIFFERENCES.md`]docs/WORD_DIFFERENCES.md
- [`docs/WORD_COMMENT_BALLOONS.md`]docs/WORD_COMMENT_BALLOONS.md

## Comparison modes

The default comparison mode is:

```sh
--mode word
```

It targets Word-like comparison behavior.

Classic PowerTools behavior is available with:

```sh
--mode powertools
```

Choose explicitly if exact comparison semantics matter to a regression test
or downstream workflow.

## Existing revisions in edit plans

An edit plan can refuse documents that already contain tracked changes, or
resolve them according to an explicit policy.

List changes before editing:

```sh
jubarte changes source.docx --json
```

Selective resolution can be part of the plan, for example:

```json
{
  "resolve_revisions": {
    "accept": {
      "ids": ["r12"]
    },
    "reject": {
      "authors": ["Previous Reviewer"]
    }
  }
}
```

Conflicting selections are rejected instead of silently choosing a side.

Settling a revision that removes a comment's whole anchor removes the thread
and its replies, as Word does. Edit receipts report each removed thread as
`removed_comments` (using source ids `c0`, `c1`, etc.), each saying `why`:
`anchor removed by accepting r13`, the change that held its mark. Legacy `edit --dry-run`
prints the JSONL preview; `edit --out-dir` writes the summary event in
`report.jsonl`. Typed `edit apply --json` includes the same records in `data`.
To preserve the thread, set `"removed_anchor_comments": "keep"` in a v1 or
v2 plan. Its range markers and reference runs move together to an empty,
untracked anchor where the removed text was. A reply in the same plan can
then use that anchor. The receipt reports `kept_comments` with `anchor: "empty"`.
Comments the plan subsequently deletes are not listed; deleted replies leave
the kept thread's `replies`, while its surviving root stays listed.
This opt-in is a jubarte convention that Word opens with threaded balloons;
the default `"remove"` follows Word's removal behavior. Partial overlaps
keep the existing behavior. Unknown values are refused as `INVALID_PLAN`.
The policy is available in plans; `accept`/`reject` keep their existing warnings.
A reply to a comment whose paragraph the same plan deletes goes on the
deleted text beside its parent, where Word shows the thread; a v2 plan with
`"track": "off"` deletes the anchor outright, and is refused with
`COMMENT_ANCHOR_REMOVED`.
Comment and bookmark ids stay stable while a plan runs, so later operations
still address the source comments. After all operations finish, the preserving
path numbers the revision-free working document once; its clean copy, tracked
replay and operation receipts share that allocation. Pending source revisions
retain their ids. The comparer path retains ids in both outputs: it unions
comments from its original and edited inputs, so numbering only the edited
input would change comment matching. Settlement receipts retain source comment
ids; newly added comments report their written ids.

If settlement removes a kept thread's row, cell or whole table, its empty
anchor moves to the end of the last surviving paragraph before that container
in the same story, or the start of the first paragraph after it. Removed and
kept receipts never list the same comment. Removal text names the acceptance
or rejection that removed the thread; kept text names its published paragraph.

The v1 plan envelope is documented in `schemas/edit-plan-v1.schema.json`,
and the typed v2 schema in `schemas/edit-plan-v2.schema.json`.

## Examples

### CLI

```sh
jubarte original.docx revised.docx \
  -o redline.docx \
  --author "Legal"

jubarte changes redline.docx --json

jubarte convert redline.docx \
  -o redline.pdf \
  --revisions word
```

### Python `Document`

```python
import jubarte

doc = jubarte.read("contract.docx")

print(doc.markdown())
snapshot = doc.inspect()
print(snapshot)

pages = doc.to_png(dpi=120)
```

### Agent-style document editing

See
[`examples/agents/acme-letter`](examples/agents/acme-letter), which includes
an edit plan, generated report and rendered redline page.

## Safety and validation

CI currently includes:

- `cargo fmt --check`
- Clippy with `-D warnings` on the workspace crates and on the Python, WASM
  (`wasm32-unknown-unknown`) and in-process bench bindings
- all-feature Rust tests on Linux, macOS and Windows
- source-based code coverage with a line-coverage floor
- MSRV testing on Rust 1.94 (the all-feature test suite, on Linux)
- `cargo publish --dry-run`
- `cargo-deny`
- SPDX headers, and a third-party notice beside every file adapted from
  another project
- Python binding tests

The project also maintains package/schema validation and real-Microsoft-Word
opening probes for release work because an OOXML document can be schema-valid
and still trigger Word repair behavior.

See:

- [`KNOWN_ISSUES.md`]KNOWN_ISSUES.md
- [`docs/maintainers/VERSIONING.md`]docs/maintainers/VERSIONING.md
- [`docs/maintainers/bench_classes.md`]docs/maintainers/bench_classes.md

## Benchmarks

Jubarte maintains Word-oracle benchmarks for both document comparison and
DOCX rendering.

The benchmark methodology, corpus provenance, current numbers and historical
results belong in:

- the [neurotic_docx_bench RESULTS.md]https://github.com/jandira-tech/neurotic_docx_bench/blob/main/RESULTS.md
- the [page-by-page comparison site]https://jandira-tech.github.io/neurotic_docx_bench/

Treat these as reproducible project-maintained measurements rather than as a
substitute for testing your own document corpus.

For important production workloads, benchmark representative documents from
your own environment before choosing an engine.

## Supported environments

| Surface | Supported/tested target |
|---|---|
| Rust / CLI | CI tests Linux, macOS and Windows |
| Rust toolchain | Rust 1.94+ |
| Python | CPython 3.10+ |
| Python release wheels | macOS x86_64/arm64, manylinux_2_28 x86_64/arm64, musllinux_1_2 x86_64/arm64, Windows x86_64 (abi3, CPython 3.10+) |
| Node | Node 18+ |
| Browser | WebAssembly builds |
| CLI release workflow | Linux x86_64/arm64, macOS x86_64/arm64, Windows x86_64 targets |

Release assets can vary by tag. Check the
[release page](https://github.com/jandira-tech/jubarte/releases)
before scripting a binary download.

A Word 97-2003 `.doc` converts to `.docx` with the native binary's
`jubarte convert old.doc` (or `jubarte::legacy_doc::doc_to_docx` in Rust):
text, headings, lists, bold, italic and tables. Every other command, and
the Python and JavaScript packages (the npm command line too), refuse a `.doc` (or an encrypted document of any Word
version) with `LEGACY_DOC` and the hint to save it as `.docx` without a
password, and RTF with `UNSUPPORTED_PACKAGE`. Convert them to `.docx` first.

## Troubleshooting

| Problem | What to check |
|---|---|
| PDF layout differs from Word | Verify required fonts; inspect `--font-report`; read `docs/WORD_DIFFERENCES.md` |
| Text is missing or wraps differently | Check font resolution and embedded/system font availability |
| Edit exits with a refusal | Read `report.jsonl` / stdout for `STALE_SOURCE`, `ANCHOR_NOT_FOUND`, `AMBIGUOUS_ANCHOR`, `OVERLAPPING_EDITS`, `UNSUPPORTED_STRUCTURE`, etc. |
| `STALE_SOURCE` | Re-run `jubarte read` and regenerate the plan from its new `sha256:` line |
| `AMBIGUOUS_ANCHOR` | Use a paragraph ID or a more specific exact anchor |
| Document already contains revisions | List them with `jubarte changes`; explicitly accept/reject them or set an edit-plan revision policy |
| Comment is present in DOCX but missing from rendered markup | Check the documented comment-balloon limitations and `docs/WORD_COMMENT_BALLOONS.md` |
| Output page count is not exactly Word's | The renderer targets Word behavior but is independent; inspect known differences before treating page count as an invariant |
| Prebuilt archive is absent for a platform | Install with Cargo or build from source; then check the release assets for a later tag |
| Need exact package differences | Use `jubarte debug diff` and the `text`, `runs`, `xml` or `render` debug catalogs |

## Contributing

Contributions that improve Word compatibility, package validity, diagnostics,
documentation, examples or platform support are welcome.

Before opening a PR:

```sh
cargo fmt --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo nextest run --workspace
scripts/gen_docs.sh --check
```

If you change any CLI flag, subcommand or public API, also run
`scripts/gen_docs.sh` and commit the regenerated guide pages — the CI docs
job fails when they drift.

For Python binding changes, run the Python test suite from `jubarte-python`.

Please include a minimal fixture or regression test for document-behavior
changes. For Word-compatibility changes, describe what Microsoft Word does and
how the fixture demonstrates it.

For security vulnerabilities, use a private GitHub security advisory or the
private contact documented by the project rather than a public issue.

## Roadmap

Proposed areas of focus:

- [ ] Stabilize and document a `1.0` compatibility policy.
- [ ] Keep every advertised binary/wheel target release-complete.
- [ ] Expand newcomer examples for CLI, Rust, Python, Node and browser.
- [ ] Improve editable coverage for currently unsupported DOCX structures.
- [ ] Continue closing documented Word-layout differences.
- [ ] Add a polished browser demo for compare/review/render workflows.
- [ ] Make benchmark environments easier for third parties to reproduce.
- [ ] Expand community documentation and contributor onboarding.

Roadmap items are goals, not compatibility guarantees.

## Project structure

```text
src/
  lib.rs                 the `jubarte` facade: re-exports every crate below
  bin/jubarte.rs         the `jubarte` CLI binary

crates/
  jubarte-dom/           shared XML model (xmllinq), namespaces, ids
  jubarte-opc/           DOCX package layer, admission, styles, numbering
  jubarte-redlines/      compare / revisions / accept and reject
  jubarte-render/        DOCX → PDF/PNG layout engine and embedded fonts
  jubarte-doc/           changes, comments, validate, audit, scrub, inspect, debug
  jubarte-markdown/      Markdown in and out, .doc reading
  jubarte-edit/          validated JSON edit plans, text diffs
  jubarte-cli/           CLI commands (compare, edit, convert, diff, debug, …)

jubarte-python/           PyO3 / maturin Python package
jubarte-wasm/             wasm-bindgen / npm package
jubarte-app/              Tauri desktop shell: its own repository (arthrod/jubarte-app), cloned here untracked
examples/                 examples and profiling tools
tests/                    integration tests, goldens and corpus
docs/                     compatibility and engineering documentation
tools/                    validation / benchmark tooling
scripts/                  installation, release and Word-probe scripts
```

## License

Jubarte is licensed under the [Apache License, Version 2.0](LICENSE)
(`Apache-2.0`) from version 0.19.0. Versions 0.18.0 and earlier were
released under `AGPL-3.0-only` and stay under it.

Parts of the engine are adapted from other projects under the MIT
License, and the renderer embeds fonts under the SIL Open Font License.
A `THIRD_PARTY_NOTICES.md` names them and carries their notices: one in
each crate that adapts upstream code, one in each package that ships the
compiled engine (the Python wheel, the npm library and the release
archives), one beside the installable fonts and one for the test
documents.

## Links

[Engine comparison site](https://jandira-tech.github.io/neurotic_docx_bench/) ·
[jandira.tech](https://www.jandira.tech) ·
[Discussions](https://github.com/jandira-tech/jubarte/discussions) ·
[Support](SUPPORT.md) · [Security](SECURITY.md)

- [GitHub]https://github.com/jandira-tech/jubarte
- [crates.io]https://crates.io/crates/jubarte
- [docs.rs]https://docs.rs/jubarte
- [PyPI]https://pypi.org/project/jubarte-docx/
- [npm]https://www.npmjs.com/package/jubarte-wasm
- [Releases]https://github.com/jandira-tech/jubarte/releases
- [npm CLI]https://www.npmjs.com/package/jubarte-redlines

MCP Registry installation is pending until the owner configures three
repository variables and OIDC publishing: `MCP_REGISTRY_NAMESPACE`,
`MCP_PUBLISHER_VERSION` (the pinned `mcp-publisher` release, as `vX.Y.Z`) and
`MCP_PUBLISHER_SHA256` (that archive's 64-character lowercase SHA-256). With
the namespace unset, the release skips Registry publication with a warning;
with the namespace set and either pin missing or malformed, the Registry job
fails. Direct release downloads work either way.