@ansonlai/docx-redline-js 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -22,8 +22,9 @@ specific advanced operation, API, or recovery topic you need.
22
22
  ## Ordinary document edits
23
23
 
24
24
  Use one focused extraction and one apply call. With a structured wrapper, use
25
- its revision-bound target handles. For shell-only work, use a UTF-8 operations
26
- file or serializer-backed stdin and the explicit agent profile:
25
+ its revision-bound target handles. Follow `selection.hint` when a search for
26
+ restorable text yields 0 matches in accepted view. For shell-only work, use a
27
+ UTF-8 operations file or serializer-backed stdin and the explicit agent profile:
27
28
 
28
29
  ```bash
29
30
  docx-redline extract contract.docx --search "termination" --around 3
package/README.md CHANGED
@@ -147,10 +147,13 @@ const inventory = inspectDocumentParts({ documentXml, commentsXml, numberingXml
147
147
  Inspection returns exact paragraph text, target IDs/fingerprints, headings,
148
148
  table/list context, revision authors, and joined comment anchors. Filters such
149
149
  as `search`, `indexes`, `range`, `revisedOnly`, `inTable`, and `skipEmpty`
150
- limit output. Search is a case-insensitive substring match; `around` adds nearby
151
- drafting context, while `limit` and `after` page direct hits. `revisionView`
152
- accepts `accepted`, `rejected`, or `current`. Returned paragraphs identify
153
- matches versus context and include `humanReference` for user-facing summaries.
150
+ limit output. Search is a case-insensitive substring match; `around` adds nearby drafting
151
+ context, while `limit` and `after` page direct hits. When a search yields 0
152
+ matches in the active view, `selection.hint` provides guidance if matches exist
153
+ in the alternate revision view (such as searching for deleted text to restore).
154
+ `revisionView` accepts `accepted`, `rejected`, or `current`. Returned
155
+ paragraphs identify matches versus context and include `humanReference` for
156
+ user-facing summaries.
154
157
 
155
158
  For complete `.docx` buffers in Node:
156
159
 
@@ -252,13 +255,16 @@ All commands emit JSON on stdout. `apply` defaults:
252
255
  - **Compact mutation results**: `apply`, `accept`, `reject`, and `delete-comments` omit full OOXML/package payloads and inspection text from stdout. CLI operation results omit duplicate nested receipt bodies; the ordered top-level `receipts` array is authoritative. Successful exact target-match diagnostics are omitted and equivalent-whitespace matches retain only mode/count. Node and standalone-runner results remain unchanged. Use `validate` when full issue arrays are needed.
253
256
 
254
257
  Inspection commands default to 20 direct matches and a 48 KiB soft response
255
- budget when no explicit positional scope is supplied. Use `--limit` with
256
- `--after <paragraph-index>` to continue, `--around N` (aliases `--context` and
257
- `-C`) to include nearby paragraphs, and `--all` only for deliberate unbounded
258
- inspection. Every retained target is complete; an individually oversized
259
- paragraph is returned whole with an `oversizeItem` marker. Machine `index` and
260
- `ref` fields are for targeting and pagination, not user-facing Word locations;
261
- use `humanReference`, `provision`, or `nearestHeading` in reports.
258
+ budget when no explicit positional scope is supplied. When a search returns 0
259
+ matches in the requested view, `selection.hint` provides immediate guidance if
260
+ matches exist in the alternate view (such as searching for a deleted clause to
261
+ restore). Use `--limit` with `--after <paragraph-index>` to continue, `--around N`
262
+ (aliases `--context` and `-C`) to include nearby paragraphs, and `--all` only
263
+ for deliberate unbounded inspection. Every retained target is complete; an
264
+ individually oversized paragraph is returned whole with an `oversizeItem`
265
+ marker. Machine `index` and `ref` fields are for targeting and pagination, not
266
+ user-facing Word locations; use `humanReference`, `provision`, or
267
+ `nearestHeading` in reports.
262
268
 
263
269
  `docx-redline version` reports contract version 7 and the additive
264
270
  `command-help-v1`, `inspection-context-v1`, `bounded-inspection-v1`,
@@ -267,7 +273,7 @@ use `humanReference`, `provision`, or `nearestHeading` in reports.
267
273
  `agent-safety-profile-v2`, `deduplicated-cli-receipts`, and
268
274
  `compact-cli-json-v1` capabilities. Wrappers should negotiate only the
269
275
  capabilities they use. Run `docx-redline <command> --help` for that command's
270
- machine-readable options, behavior, exit codes, and compact examples.
276
+ machine-readable options, behavior, exit codes, canonical GitHub documentation links, and compact examples.
271
277
 
272
278
  See the [compact agent fast start](./docs/AGENT_FAST_START.md), the
273
279
  [skill/harness authoring contract](./docs/SKILL_AUTHORING.md), and the
@@ -1,4 +1,4 @@
1
- // @ansonlai/docx-redline-js v0.6.1 — https://github.com/AnsonLai/docx-redline-js
1
+ // @ansonlai/docx-redline-js v0.6.2 — https://github.com/AnsonLai/docx-redline-js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -11594,6 +11594,34 @@ function inspectDocumentParts(parts, options = {}) {
11594
11594
  comments.set(id, definition);
11595
11595
  }
11596
11596
  const selected = selectInspectionParagraphs(paragraphs, options);
11597
+ if (options.search && selected.selection && selected.selection.totalMatches === 0) {
11598
+ const needle = String(options.search).toLowerCase();
11599
+ const alternateView = revisionView === "accepted" ? "rejected" : "accepted";
11600
+ let rangeStart = 1;
11601
+ let rangeEnd = paragraphNodes.length;
11602
+ if (options.range) {
11603
+ rangeStart = Number(options.range.start ?? options.range[0]);
11604
+ rangeEnd = Number(options.range.end ?? options.range[1]);
11605
+ }
11606
+ let alternateMatches = 0;
11607
+ for (let i = 0; i < paragraphNodes.length; i++) {
11608
+ const index = i + 1;
11609
+ if (options.range && (index < rangeStart || index > rangeEnd)) continue;
11610
+ if (Array.isArray(options.indexes) && !options.indexes.includes(index)) continue;
11611
+ const pNode = paragraphNodes[i];
11612
+ if (options.table && !hasAncestor(pNode, "tc")) continue;
11613
+ if (options.body && hasAncestor(pNode, "tc")) continue;
11614
+ if (options.revised && revisionAuthors(pNode).length === 0) continue;
11615
+ const altText = extractCanonicalParagraphText(pNode, { revisionView: alternateView });
11616
+ if (options.skipEmpty && altText.length === 0) continue;
11617
+ if (altText.toLowerCase().includes(needle)) {
11618
+ alternateMatches++;
11619
+ }
11620
+ }
11621
+ if (alternateMatches > 0) {
11622
+ selected.selection.hint = revisionView === "accepted" ? `0 matches in accepted view, but ${alternateMatches} match${alternateMatches === 1 ? "" : "es"} found in --view rejected. If searching for deleted text to restore, re-run with --view rejected.` : `0 matches in rejected view, but ${alternateMatches} match${alternateMatches === 1 ? "" : "es"} found in --view accepted. Re-run with --view accepted.`;
11623
+ }
11624
+ }
11597
11625
  paragraphs = selected.paragraphs;
11598
11626
  const allRevisionAuthors = [...new Set(paragraphs.flatMap((item) => item.revisionAuthors))].sort();
11599
11627
  const coveredEntries = extractDocumentPartsEntries(parts);