bun-docx 0.8.0 → 0.9.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/README.md +4 -3
- package/dist/index.js +51 -56
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ The repo includes a Common Paper Mutual NDA template at `tests/fixtures/mnda.doc
|
|
|
42
42
|
cp tests/fixtures/mnda.docx mnda-filled.docx
|
|
43
43
|
|
|
44
44
|
# Read the cover-page table so the agent knows what placeholders exist
|
|
45
|
-
docx read mnda-filled.docx --
|
|
45
|
+
docx read mnda-filled.docx --to t1
|
|
46
46
|
|
|
47
47
|
# Fill the yellow-highlighted bracketed placeholders
|
|
48
48
|
docx replace mnda-filled.docx "Fill in: today’s date" "May 6, 2026"
|
|
@@ -72,7 +72,8 @@ Open `mnda-filled.docx` in Word: tracked changes and comments appear in the revi
|
|
|
72
72
|
|
|
73
73
|
```sh
|
|
74
74
|
docx create FILE [--title T] [--author A] [--text "..."]
|
|
75
|
-
docx read FILE [--
|
|
75
|
+
docx read FILE [--from pN] [--to pN] [--accepted | --baseline | --current] [--comments]
|
|
76
|
+
docx read FILE --ast # JSON-AST opt-in (every other read flag is markdown-only)
|
|
76
77
|
docx insert FILE --after p3 --text "..." [--style HeadingN] [--color HEX] [--bold] [--italic] [--url URL]
|
|
77
78
|
docx insert FILE --after p3 --runs '[{"type":"text","text":"X","bold":true}]'
|
|
78
79
|
docx insert FILE --after p3 --page-break | --column-break
|
|
@@ -124,7 +125,7 @@ Every command has `--help`. Mutating commands accept `--dry-run`, `-o/--output P
|
|
|
124
125
|
|
|
125
126
|
### Markdown rendering
|
|
126
127
|
|
|
127
|
-
`docx read FILE
|
|
128
|
+
`docx read FILE` renders the document body as GitHub-flavored Markdown — the default since v0.9. Useful when an LLM wants to skim a doc without parsing the AST. Each rendered paragraph is followed by an HTML comment with its locator (`<!-- p3 -->`) so the markdown is invisible-pinned: humans see clean prose in a renderer, agents parse the locators from raw text. Pass `--ast` for the structured JSON when programmatic walks need the typed tree (`docx read FILE --ast | jq '.blocks[] | select(.type == "paragraph")'`).
|
|
128
129
|
|
|
129
130
|
`--from LOC` and `--to LOC` slice by top-level block (both inclusive). Accepts paragraph, table, cell, span, and range locators; cell/span/range collapse to their enclosing top-level block.
|
|
130
131
|
|
package/dist/index.js
CHANGED
|
@@ -8953,7 +8953,7 @@ var require_zipEntries = __commonJS((exports, module) => {
|
|
|
8953
8953
|
if (this.centralDirRecords !== this.files.length) {
|
|
8954
8954
|
if (this.centralDirRecords !== 0 && this.files.length === 0) {
|
|
8955
8955
|
throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
|
|
8956
|
-
}
|
|
8956
|
+
}
|
|
8957
8957
|
}
|
|
8958
8958
|
},
|
|
8959
8959
|
readEndOfCentral: function() {
|
|
@@ -18680,7 +18680,7 @@ Options:
|
|
|
18680
18680
|
--current search the raw concatenation (both ins and del text)
|
|
18681
18681
|
--baseline search the pre-change text (skip ins/moveTo)
|
|
18682
18682
|
default: accepted view (skip del/moveFrom) \u2014 matches
|
|
18683
|
-
"docx read
|
|
18683
|
+
"docx read" / "docx wc" / "docx comments add"
|
|
18684
18684
|
--exact disable query normalization (no markdown-emphasis stripping,
|
|
18685
18685
|
no smart/straight quote or em/en-dash equivalence)
|
|
18686
18686
|
-h, --help show this help
|
|
@@ -21445,7 +21445,7 @@ async function run25(args) {
|
|
|
21445
21445
|
args,
|
|
21446
21446
|
allowPositionals: true,
|
|
21447
21447
|
options: {
|
|
21448
|
-
|
|
21448
|
+
ast: { type: "boolean" },
|
|
21449
21449
|
from: { type: "string" },
|
|
21450
21450
|
to: { type: "string" },
|
|
21451
21451
|
accepted: { type: "boolean" },
|
|
@@ -21465,15 +21465,15 @@ async function run25(args) {
|
|
|
21465
21465
|
const path = parsed.positionals[0];
|
|
21466
21466
|
if (!path)
|
|
21467
21467
|
return fail("USAGE", "Missing FILE argument", HELP25);
|
|
21468
|
-
const
|
|
21468
|
+
const ast = Boolean(parsed.values.ast);
|
|
21469
21469
|
const from = parsed.values.from;
|
|
21470
21470
|
const to = parsed.values.to;
|
|
21471
21471
|
const accepted = Boolean(parsed.values.accepted);
|
|
21472
21472
|
const baseline = Boolean(parsed.values.baseline);
|
|
21473
21473
|
const current = Boolean(parsed.values.current);
|
|
21474
21474
|
const showComments = Boolean(parsed.values.comments);
|
|
21475
|
-
if (
|
|
21476
|
-
return fail("USAGE", "--from, --to, --accepted, --baseline, --current, and --comments
|
|
21475
|
+
if (ast && (from || to || accepted || baseline || current || showComments)) {
|
|
21476
|
+
return fail("USAGE", "--from, --to, --accepted, --baseline, --current, and --comments are Markdown-only and cannot be combined with --ast", HELP25);
|
|
21477
21477
|
}
|
|
21478
21478
|
const viewFlagCount = (accepted ? 1 : 0) + (baseline ? 1 : 0) + (current ? 1 : 0);
|
|
21479
21479
|
if (viewFlagCount > 1) {
|
|
@@ -21483,68 +21483,63 @@ async function run25(args) {
|
|
|
21483
21483
|
const docView = await openOrFail(path);
|
|
21484
21484
|
if (typeof docView === "number")
|
|
21485
21485
|
return docView;
|
|
21486
|
-
if (
|
|
21487
|
-
|
|
21488
|
-
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
21492
|
-
|
|
21493
|
-
|
|
21494
|
-
|
|
21495
|
-
|
|
21496
|
-
|
|
21497
|
-
|
|
21498
|
-
|
|
21499
|
-
|
|
21500
|
-
|
|
21486
|
+
if (ast) {
|
|
21487
|
+
await enrichImageHashes(docView);
|
|
21488
|
+
await respond(docView.doc);
|
|
21489
|
+
return EXIT.OK;
|
|
21490
|
+
}
|
|
21491
|
+
try {
|
|
21492
|
+
const rendered = renderMarkdown(docView.doc, {
|
|
21493
|
+
from,
|
|
21494
|
+
to,
|
|
21495
|
+
view,
|
|
21496
|
+
showComments
|
|
21497
|
+
});
|
|
21498
|
+
await writeStdout(rendered);
|
|
21499
|
+
return EXIT.OK;
|
|
21500
|
+
} catch (err) {
|
|
21501
|
+
if (err instanceof MarkdownLocatorError) {
|
|
21502
|
+
return fail("INVALID_LOCATOR", err.message);
|
|
21501
21503
|
}
|
|
21504
|
+
throw err;
|
|
21502
21505
|
}
|
|
21503
|
-
await enrichImageHashes(docView);
|
|
21504
|
-
await respond(docView.doc);
|
|
21505
|
-
return EXIT.OK;
|
|
21506
21506
|
}
|
|
21507
|
-
var HELP25 = `docx read \u2014
|
|
21507
|
+
var HELP25 = `docx read \u2014 render document body as Markdown, or print AST as JSON
|
|
21508
21508
|
|
|
21509
21509
|
Usage:
|
|
21510
21510
|
docx read FILE [options]
|
|
21511
21511
|
|
|
21512
21512
|
Options:
|
|
21513
|
-
--
|
|
21514
|
-
|
|
21515
|
-
|
|
21516
|
-
|
|
21517
|
-
but parseable from raw markdown).
|
|
21518
|
-
--from LOC Start markdown rendering at top-level block LOC (inclusive)
|
|
21519
|
-
--to LOC End markdown rendering at top-level block LOC (inclusive)
|
|
21513
|
+
--ast Print the typed AST as JSON instead of rendering Markdown.
|
|
21514
|
+
Disables all the Markdown-only flags below.
|
|
21515
|
+
--from LOC Start rendering at top-level block LOC (inclusive)
|
|
21516
|
+
--to LOC End rendering at top-level block LOC (inclusive)
|
|
21520
21517
|
Accepts pN, tN, tN:rRcC[:pK[:S-E]], pN:S-E, pN:S-pM:E.
|
|
21521
21518
|
Cell/span/range locators collapse to their enclosing
|
|
21522
21519
|
top-level block (the table or paragraph).
|
|
21523
|
-
--accepted Default
|
|
21524
|
-
|
|
21520
|
+
--accepted Default view: render the post-accept document \u2014 drop
|
|
21521
|
+
subtractive wrappers (<w:del>, <w:moveFrom>), inline
|
|
21525
21522
|
additive wrappers (<w:ins>, <w:moveTo>) as plain text,
|
|
21526
21523
|
no markers/refs. Kept as an explicit alias for clarity.
|
|
21527
|
-
--baseline
|
|
21528
|
-
|
|
21529
|
-
|
|
21530
|
-
|
|
21531
|
-
|
|
21532
|
-
|
|
21533
|
-
|
|
21534
|
-
|
|
21535
|
-
|
|
21536
|
-
|
|
21537
|
-
|
|
21538
|
-
end of the output (author, date, body).
|
|
21524
|
+
--baseline Render the pre-change view: drop additive wrappers
|
|
21525
|
+
(<w:ins>, <w:moveTo>), inline subtractive wrappers
|
|
21526
|
+
(<w:del>, <w:moveFrom>) as plain text, no markers/refs.
|
|
21527
|
+
--current Render the raw concatenation: additive wrappers as
|
|
21528
|
+
{++text++}[^tcN] and subtractive as {--text--}[^tcN]
|
|
21529
|
+
(CriticMarkup); the [^tcN] footnote spells out the kind
|
|
21530
|
+
(insertion / deletion / moveTo / moveFrom). Mutually
|
|
21531
|
+
exclusive with --accepted/--baseline.
|
|
21532
|
+
--comments Append [^cN] after each commented span and emit a
|
|
21533
|
+
footnote definition for each comment at the end of the
|
|
21534
|
+
output (author, date, body).
|
|
21539
21535
|
-h, --help Show this help
|
|
21540
21536
|
|
|
21541
21537
|
Examples:
|
|
21542
21538
|
docx read input.docx
|
|
21543
|
-
docx read input.docx --
|
|
21544
|
-
docx read input.docx --
|
|
21545
|
-
docx read input.docx --
|
|
21546
|
-
docx read input.docx --
|
|
21547
|
-
docx read input.docx | jq '.blocks[] | select(.type == "paragraph")'
|
|
21539
|
+
docx read input.docx --from p3 --to p20
|
|
21540
|
+
docx read input.docx --accepted --comments
|
|
21541
|
+
docx read input.docx --baseline
|
|
21542
|
+
docx read input.docx --ast | jq '.blocks[] | select(.type == "paragraph")'
|
|
21548
21543
|
`;
|
|
21549
21544
|
var init_read2 = __esm(() => {
|
|
21550
21545
|
init_core();
|
|
@@ -22159,7 +22154,7 @@ Options:
|
|
|
22159
22154
|
--current operate on the raw concatenation (both ins and del text)
|
|
22160
22155
|
--baseline operate on the pre-change text (skip ins/moveTo)
|
|
22161
22156
|
default: accepted view (skip del/moveFrom) \u2014 matches
|
|
22162
|
-
"docx find" / "docx read
|
|
22157
|
+
"docx find" / "docx read"
|
|
22163
22158
|
--exact disable pattern normalization (no markdown-emphasis stripping,
|
|
22164
22159
|
no smart/straight quote or em/en-dash equivalence)
|
|
22165
22160
|
-o, --output PATH write to PATH instead of overwriting FILE
|
|
@@ -23256,7 +23251,7 @@ Options:
|
|
|
23256
23251
|
--accepted Default. Count the accepted view: skip subtractive
|
|
23257
23252
|
wrappers (<w:del>, <w:moveFrom>); keep additive
|
|
23258
23253
|
wrappers (<w:ins>, <w:moveTo>) as plain text. Mirrors
|
|
23259
|
-
"docx read
|
|
23254
|
+
"docx read" / "docx find" defaults.
|
|
23260
23255
|
--baseline Count the baseline view: skip additive wrappers
|
|
23261
23256
|
(<w:ins>, <w:moveTo>); keep subtractive wrappers
|
|
23262
23257
|
(<w:del>, <w:moveFrom>) as plain text \u2014 i.e., the doc as
|
|
@@ -23286,7 +23281,7 @@ var init_wc = __esm(() => {
|
|
|
23286
23281
|
// package.json
|
|
23287
23282
|
var package_default = {
|
|
23288
23283
|
name: "bun-docx",
|
|
23289
|
-
version: "0.
|
|
23284
|
+
version: "0.9.0",
|
|
23290
23285
|
description: "CLI for AI agents (Claude, Codex) to read, edit, and comment on .docx files with full format fidelity.",
|
|
23291
23286
|
keywords: [
|
|
23292
23287
|
"docx",
|
|
@@ -23355,7 +23350,7 @@ Usage:
|
|
|
23355
23350
|
|
|
23356
23351
|
Commands:
|
|
23357
23352
|
create FILE Create a new minimal .docx
|
|
23358
|
-
read FILE
|
|
23353
|
+
read FILE Render body as Markdown (--ast for JSON)
|
|
23359
23354
|
edit FILE Replace text/properties at a locator
|
|
23360
23355
|
insert FILE Insert a block or run
|
|
23361
23356
|
delete FILE Remove a block or run range
|
|
@@ -23394,7 +23389,7 @@ Tracked changes:
|
|
|
23394
23389
|
with the next paragraph; reject-ins removes the entire owning paragraph).
|
|
23395
23390
|
Out of scope: rPrChange / pPrChange formatting revisions.
|
|
23396
23391
|
|
|
23397
|
-
"docx read
|
|
23392
|
+
"docx read" surfaces them as CriticMarkup:
|
|
23398
23393
|
{++inserted++}[^tcN] {--deleted--}[^tcN]
|
|
23399
23394
|
with a [^tcN]: definition appendix. Switch view with --accepted (post-accept:
|
|
23400
23395
|
drop del, ins as plain) or --baseline (pre-change: drop ins, del as plain).
|