revise 3.0.1 → 3.1.1
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/CHANGELOG.md +68 -0
- package/README.md +56 -71
- package/chunks/{chunk-ZLQVPMBN.js → chunk-SCNG3PKR.js} +582 -61
- package/cli-output.schema.json +114 -6
- package/cli.js +315 -91
- package/document.d.ts +98 -18
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/package.json +3 -3
package/document.d.ts
CHANGED
|
@@ -39,14 +39,27 @@ export interface ChangeEntry {
|
|
|
39
39
|
deleted: string;
|
|
40
40
|
inserted: string;
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
export interface
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
/** Narrows tracked changes by where they are. Filters combine: a change
|
|
43
|
+
* must pass every one given. */
|
|
44
|
+
export interface ChangeFilter {
|
|
45
|
+
/** A heading and everything under it, subsections included: its number
|
|
46
|
+
* ("8", "8.", "8.1", including Word's automatic numbering) or its title
|
|
47
|
+
* ("Allocation of risk", or part of it). */
|
|
48
48
|
section?: string;
|
|
49
|
+
/** Everything outside that section. */
|
|
49
50
|
exceptSection?: string;
|
|
51
|
+
/** Block ids, and inclusive `{ from, to }` ranges in document order. Ids
|
|
52
|
+
* of list items, table cells, and blocks inside them work. */
|
|
53
|
+
blocks?: Array<string | {
|
|
54
|
+
from: string;
|
|
55
|
+
to: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/** Which tracked changes to settle: exactly one of `ids`, `all`, or
|
|
59
|
+
* filters (`section`, `exceptSection`, `blocks`). */
|
|
60
|
+
export interface ChangeSelection extends ChangeFilter {
|
|
61
|
+
ids?: string[];
|
|
62
|
+
all?: boolean;
|
|
50
63
|
}
|
|
51
64
|
export interface SettleResult {
|
|
52
65
|
resolved: string[];
|
|
@@ -55,17 +68,47 @@ export interface SettleResult {
|
|
|
55
68
|
/** Pending changes that could not be settled. */
|
|
56
69
|
unresolved: string[];
|
|
57
70
|
}
|
|
71
|
+
/** How pending tracked changes read: "tracked" shows them (deleted and
|
|
72
|
+
* inserted text, marked), "accepted" as if every one were accepted (what
|
|
73
|
+
* the editing tools see), "original" as if every one were rejected. */
|
|
74
|
+
export type ReadView = "tracked" | "accepted" | "original";
|
|
75
|
+
export interface GrepMatch {
|
|
76
|
+
text: string;
|
|
77
|
+
/** Inside text a pending change inserted or deleted; null for text no
|
|
78
|
+
* change touches. */
|
|
79
|
+
change: "inserted" | "deleted" | null;
|
|
80
|
+
changeId: string | null;
|
|
81
|
+
}
|
|
58
82
|
export interface GrepHit {
|
|
59
83
|
id: string;
|
|
60
84
|
blockIndex: number;
|
|
61
85
|
count: number;
|
|
86
|
+
/** The block's text in the view. Tracked marks changes inline:
|
|
87
|
+
* "Fees are [-$100-]{+$120+} per hour." */
|
|
62
88
|
text: string;
|
|
89
|
+
matches: GrepMatch[];
|
|
90
|
+
}
|
|
91
|
+
/** Where a block is: the body, a page header or footer, or a note. */
|
|
92
|
+
export type TextRegion = "body" | "header" | "footer" | "footnote" | "endnote";
|
|
93
|
+
export interface ReplaceAllOptions {
|
|
94
|
+
/** Only in these blocks (ids from `read`, `grep`, `search`). */
|
|
95
|
+
blocks?: string[];
|
|
96
|
+
/** @deprecated The older name for `blocks`. */
|
|
97
|
+
ids?: string[];
|
|
98
|
+
/** Match regardless of case: "Provider" also finds "PROVIDER". */
|
|
99
|
+
ignoreCase?: boolean;
|
|
100
|
+
/** Match characters exactly. By default curly and straight quotes,
|
|
101
|
+
* non-breaking and ordinary spaces, and non-breaking and ordinary
|
|
102
|
+
* hyphens match each other, the way Word's Find treats quotes. */
|
|
103
|
+
exact?: boolean;
|
|
63
104
|
}
|
|
64
105
|
export interface ReplaceTextResult {
|
|
65
106
|
/** Occurrences replaced. */
|
|
66
107
|
replaced: number;
|
|
67
108
|
/** Ids of the blocks that contained the text. */
|
|
68
109
|
blocks: string[];
|
|
110
|
+
/** Occurrences replaced in each part of the document. */
|
|
111
|
+
regions: Partial<Record<TextRegion, number>>;
|
|
69
112
|
/** Tracked changes the replacement created (none in editing mode). */
|
|
70
113
|
changeIds: string[];
|
|
71
114
|
/** Blocks that contained the text but could not be edited. */
|
|
@@ -74,6 +117,13 @@ export interface ReplaceTextResult {
|
|
|
74
117
|
code: string;
|
|
75
118
|
message: string;
|
|
76
119
|
}>;
|
|
120
|
+
/** Text that would match with looser options but wasn't replaced: other
|
|
121
|
+
* capitalization (`ignoreCase`) or other quotes and spaces (`exact`). */
|
|
122
|
+
nearMisses: Array<{
|
|
123
|
+
text: string;
|
|
124
|
+
count: number;
|
|
125
|
+
reason: "case" | "characters";
|
|
126
|
+
}>;
|
|
77
127
|
}
|
|
78
128
|
export interface TextDiff {
|
|
79
129
|
/** Paragraph-level diff with word detail: `~ a [-old-]{+new+} b`. */
|
|
@@ -108,6 +158,10 @@ export interface ExportOptions {
|
|
|
108
158
|
* Only .docx can hold tracked changes: PDF, Markdown, HTML, and text
|
|
109
159
|
* always show them accepted. */
|
|
110
160
|
mode?: "review" | "final";
|
|
161
|
+
/** The same choice in read's words, and one more: "tracked" is
|
|
162
|
+
* "review", "accepted" is "final", and "original" writes the document as
|
|
163
|
+
* it was before every pending change. Give `mode` or `view`, not both. */
|
|
164
|
+
view?: ReadView;
|
|
111
165
|
title?: string;
|
|
112
166
|
}
|
|
113
167
|
export interface ExportResult {
|
|
@@ -115,6 +169,8 @@ export interface ExportResult {
|
|
|
115
169
|
format: ExportFormat;
|
|
116
170
|
/** The mode the output actually has: only .docx can be "review". */
|
|
117
171
|
mode: "review" | "final";
|
|
172
|
+
/** The view the output shows: "tracked" only for a .docx. */
|
|
173
|
+
view: ReadView;
|
|
118
174
|
/** Tracked changes still pending in the output. */
|
|
119
175
|
pendingTrackedChanges: number;
|
|
120
176
|
/** For .docx, what the export actually did: "graft" carried untouched
|
|
@@ -243,21 +299,37 @@ export declare class ReviseDocument {
|
|
|
243
299
|
* items, table-cell paragraphs), with their ids. */
|
|
244
300
|
grep(pattern: string | RegExp, options?: {
|
|
245
301
|
ignoreCase?: boolean;
|
|
302
|
+
view?: ReadView;
|
|
246
303
|
}): GrepHit[];
|
|
304
|
+
/**
|
|
305
|
+
* HTML the read tools returned (`read_blocks_from_index`,
|
|
306
|
+
* `read_specific_blocks`), in a view. The tools read the accepted view;
|
|
307
|
+
* "tracked" marks pending changes as `<ins>`/`<del>` with
|
|
308
|
+
* `data-change-id` and `data-author`, and shows whole blocks a change
|
|
309
|
+
* deletes where they were; "original" shows the text before every change.
|
|
310
|
+
* Block ids are unchanged. The editing tools read `<ins>` as its text and
|
|
311
|
+
* ignore `<del>`, so tracked HTML pasted back edits the accepted text.
|
|
312
|
+
*/
|
|
313
|
+
viewHtml(html: string, view: ReadView): Promise<string>;
|
|
247
314
|
/** What the document holds, in one glance: page setup, header and footer
|
|
248
315
|
* text with live fields, title, headings, lists, tables, review state. */
|
|
249
316
|
summary(): Promise<DocumentSummary>;
|
|
250
|
-
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Replace every occurrence everywhere: the body, tables, lists, page
|
|
319
|
+
* headers and footers, and footnotes and endnotes. Tracked changes in
|
|
320
|
+
* suggesting mode. Curly and straight quotes and non-breaking spaces match
|
|
321
|
+
* each other unless `exact`, and the replacement keeps the document's
|
|
322
|
+
* characters (see matchDocumentCharacters). Replacing text with itself
|
|
323
|
+
* changes nothing and is not a failure.
|
|
324
|
+
*/
|
|
325
|
+
replaceAll(find: string, replace: string, options?: ReplaceAllOptions): Promise<ReplaceTextResult>;
|
|
326
|
+
/** @deprecated The 3.0 name of `replaceAll`. */
|
|
327
|
+
replaceText(find: string, replace: string, options?: ReplaceAllOptions): Promise<ReplaceTextResult>;
|
|
328
|
+
/** The document as it was before every pending change, exported from
|
|
329
|
+
* a copy: this document keeps its changes. */
|
|
330
|
+
private exportOriginal;
|
|
256
331
|
/** Pending tracked changes with where they are and what they do. */
|
|
257
|
-
changes(filter?:
|
|
258
|
-
section?: string;
|
|
259
|
-
exceptSection?: string;
|
|
260
|
-
}): Promise<ChangeEntry[]>;
|
|
332
|
+
changes(filter?: ChangeFilter): Promise<ChangeEntry[]>;
|
|
261
333
|
private filteredChanges;
|
|
262
334
|
/** The tracked changes a selection would settle, without settling them. */
|
|
263
335
|
preview(selection: ChangeSelection): Promise<ChangeEntry[]>;
|
|
@@ -315,6 +387,14 @@ export declare function compare(originalSource: DocumentSource, revisedSource: D
|
|
|
315
387
|
/** Convert a document to another format in one step. */
|
|
316
388
|
export declare function convert(source: DocumentSource, format: ExportFormat, options?: {
|
|
317
389
|
mode?: "review" | "final";
|
|
390
|
+
view?: ReadView;
|
|
318
391
|
}): Promise<Uint8Array>;
|
|
319
|
-
/**
|
|
320
|
-
|
|
392
|
+
/** Whether a heading is the one a section query names: "8", "8.", "8.1",
|
|
393
|
+
* "Allocation of risk", or "8. Allocation". */
|
|
394
|
+
export declare function headingMatches(title: string, query: string): boolean;
|
|
395
|
+
/** A --blocks query: block ids and `first..last` ranges ("…" and "..."
|
|
396
|
+
* work too), e.g. "a1,b2..c3". */
|
|
397
|
+
export declare function parseBlockQuery(query: string): Array<string | {
|
|
398
|
+
from: string;
|
|
399
|
+
to: string;
|
|
400
|
+
}>;
|
package/index.d.ts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* `revise`: read, edit, review, render, and convert documents from Node.
|
|
3
3
|
*
|
|
4
4
|
* const doc = await ReviseDocument.open("contract.docx", { author: "Legal bot" });
|
|
5
|
-
* await doc.
|
|
5
|
+
* await doc.replaceAll("Provider", "Northstar"); // tracked changes
|
|
6
6
|
* await doc.reject({ section: "8" });
|
|
7
7
|
* const { bytes } = await doc.export({ format: "docx" });
|
|
8
8
|
* fs.writeFileSync("contract-out.docx", bytes);
|
|
9
9
|
*
|
|
10
10
|
* The `revise` CLI is built on exactly this API.
|
|
11
11
|
*/
|
|
12
|
-
export { ReviseDocument, compare, convert, formatForPath, seedYDoc, type ChangeEntry, type ChangeSelection, type CompareResult, type DocumentMode, type DocumentSource, type DocumentSummary, type ExportFormat, type ExportOptions, type ExportResult, type GrepHit, type OpenOptions, type ReplaceTextResult, type SettleResult, type TextDiff, } from "./document.js";
|
|
12
|
+
export { ReviseDocument, compare, convert, formatForPath, seedYDoc, type ChangeEntry, type ChangeFilter, type ChangeSelection, type CompareResult, type DocumentMode, type DocumentSource, type DocumentSummary, type ExportFormat, type ExportOptions, type ExportResult, type GrepHit, type GrepMatch, type ReadView, type OpenOptions, type ReplaceAllOptions, type ReplaceTextResult, type TextRegion, type SettleResult, type TextDiff, } from "./document.js";
|
|
13
13
|
export { agentTools, formatToolResult, type AgentProvider, type AgentTools, type AgentToolsOptions, type AnthropicToolUse, type OpenAIResponsesFunctionCall, type OpenAIToolCall, } from "./agent.js";
|
|
14
14
|
export { catPart, listParts, patchPackage, type PatchRequest, type PatchResult, } from "./package.js";
|
|
15
15
|
export type { ImageFetchPolicy, ReviseJsonObject, ReviseToolName, ReviseToolResult, ServerDocumentSession, } from "@reviseio/engine";
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "revise",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"reviseBuild": "
|
|
3
|
+
"version": "3.1.1",
|
|
4
|
+
"reviseBuild": "2953a6472",
|
|
5
5
|
"description": "Read, edit, and redline Word documents from the command line or TypeScript, with tracked changes, comments, and tools for AI agents.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"docx",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
],
|
|
56
56
|
"sideEffects": false,
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@reviseio/engine": "3.
|
|
58
|
+
"@reviseio/engine": "3.1.1",
|
|
59
59
|
"jszip": "^3.10.1",
|
|
60
60
|
"yjs": "^13.6.27"
|
|
61
61
|
},
|