revise 3.0.1 → 3.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,62 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Added
6
+
7
+ - **`--blocks` on `changes`, `accept`, and `reject`.** Select tracked
8
+ changes by block: ids (`--blocks a1B2c3,d4E5f6`) or a range in document
9
+ order (`--blocks a1B2c3..d4E5f6`). Ids of list items, table cells, and
10
+ paragraphs inside them work. In the library: `{ blocks: [...] }`, with
11
+ ranges as `{ from, to }`.
12
+ - **`--view tracked|accepted|original`** on `read`, `grep`, `search`,
13
+ `export`, and `convert`. `read` now shows pending changes inline as
14
+ `<del>` and `<ins>` with their change ids and authors; `grep` and `search`
15
+ find text on both sides of a change and say which side it's on. `export`
16
+ and `convert` with `--view original` write the document as it was before
17
+ every pending change. `--final` still means `--view accepted`.
18
+ - **`replace-all --ignore-case` and `--exact`.**
19
+
20
+ ### Changed
21
+
22
+ - **`replace-text` is now `replace-all`** (`replaceAll` in the library). It
23
+ replaces in page headers and footers and in footnotes and endnotes as well
24
+ as the body, and says where. Curly and straight quotes, no-break and plain
25
+ spaces, and no-break and plain hyphens match each other unless `--exact`,
26
+ and the replacement keeps the document's characters: `"net 30"` →
27
+ `"net 45"` keeps its no-break space. Matches it leaves alone, like other
28
+ capitalization, are reported as `nearMisses`. `replace-text` and
29
+ `replaceText` still work, and JSON output run under `replace-text` still
30
+ names it.
31
+ - **`--section` is a heading and everything under it.** `--section 8`
32
+ includes 8.1 and 8.2. Numbers match whether typed or Word's automatic
33
+ numbering. A title matches in full, or by text in only one heading; text in
34
+ several headings is an error (`section_ambiguous`), and a section that
35
+ doesn't exist is `section_not_found` instead of an empty result.
36
+ - **Clearer flag names:** `new --content` (was `--from`), `new --page-size`
37
+ (was `--page`), `search --results-page` (was `--page`), and `--blocks` for
38
+ block ids on `read` and `replace-all` (was `--ids`). The old names still
39
+ work.
40
+ - **`changes` lists header, footer, and note changes as such** ("Header",
41
+ "Footnote 1"), with their text.
42
+
43
+ ### Fixed
44
+
45
+ - **Word-numbered headings.** Headings numbered by Word's heading styles, how
46
+ most contracts number clauses, are headings again: `outline` lists them
47
+ with their numbers ("8.1 Cap on liability") and `--section 8` finds them.
48
+ - **Comparing numbered documents.** Two copies of the same numbered document
49
+ compare as unchanged, instead of every numbered clause deleted and
50
+ reinserted.
51
+ - **Comparing against a file revise edited.** A one-word edit compares as a
52
+ one-word change, not a whole paragraph replaced: editing a paragraph no
53
+ longer adds fonts and sizes to it or its neighbors.
54
+ - **Tracked changes in headers and footers** are saved as Word revisions, and
55
+ ones made in Word open as pending changes.
56
+ - **Markdown export** numbers nested list items per level (8.1 was written
57
+ as "9."), and writes numbered headings as headings: `## 8.1 Cap on
58
+ liability`.
59
+
3
60
  ## 3.0.1
4
61
 
5
62
  ### Fixed
package/README.md CHANGED
@@ -1,119 +1,104 @@
1
1
  # revise
2
2
 
3
- The swiss army knife for documents. Read, edit, and redline Word documents
4
- from the command line or from TypeScript. Edits land as tracked changes, with
5
- comments, review, and undo, and untouched content is written back to the
6
- .docx byte for byte. Built for AI agents and the programs that run them.
3
+ Read, edit, and redline Word documents from the command line or TypeScript.
7
4
 
8
- **Using a coding agent?** Paste this into it:
5
+ ```bash
6
+ npm i -g revise # or: npx revise <command>
7
+ ```
8
+
9
+ AI agents using `revise` can edit documents several times faster. Paste this into your agent:
9
10
 
10
11
  ```text
11
12
  Read https://revise.io/skills/cli.md and follow it.
12
13
  ```
13
14
 
14
- ## Install
15
+ ## CLI
15
16
 
16
17
  ```bash
17
- npm i -g revise # or: npx revise <command>
18
+ revise outline contract.docx # headings with block ranges
19
+ revise read contract.docx 0 # blocks as HTML, with ids
20
+ revise replace-all contract.docx "Provider" "Northstar" # a tracked change, saved in place
21
+ revise replace-all contract.docx "net 30" "net 45" --author "Legal bot" --out v2.docx
22
+ revise changes contract.docx # what's pending
23
+ revise accept contract.docx --all
24
+ revise reject contract.docx --section 8
25
+ revise undo contract.docx
26
+ revise compare v1.docx v2.docx --out redline.docx
27
+ revise export contract.docx contract.pdf # .docx .pdf .md .html .txt
28
+ cat notes.md | revise convert - notes.docx
18
29
  ```
19
30
 
20
- Node 20 or newer. No account, API key, or telemetry, and documents never
21
- leave your machine. Two things fetch over the network: PDF export downloads
22
- its fonts from revise.io, and an image you insert by URL is downloaded.
23
-
24
- ## The CLI
25
-
26
- Every command names its file. Edits save the file in place.
27
-
28
31
  ```bash
29
- revise outline contract.docx # headings with block ranges
30
- revise read contract.docx 0 # blocks as HTML, with ids
31
- revise replace-text contract.docx "Provider" "Northstar" # tracked change
32
- revise changes contract.docx # what's pending
33
- revise reject contract.docx --section 8 # review by section
34
- revise export contract.docx contract.pdf # .docx .pdf .md .html .txt
35
- revise compare v1.docx v2.docx --out redline.docx # redline two versions
36
- revise undo contract.docx
32
+ revise tools # every editing tool
33
+ revise call contract.docx set_header_footer '{"side":"footer","center":"Page {PAGE} of {PAGES}"}'
34
+ revise status contract.docx --json # one versioned JSON object
35
+ revise examples # more
37
36
  ```
38
37
 
39
- `revise tools` lists the editing tools (insert, replace, move, tables,
40
- comments, footnotes, styles, headers and footers…) and `revise call` runs
41
- one with JSON input. `--author "Legal bot"` signs tracked changes, `--out
42
- copy.docx` saves an edit as a new file, and `-` reads or writes a pipe
43
- (`cat notes.md | revise convert - notes.docx`). `--json` on any command prints
44
- one versioned object ([contract](https://revise.io/developer/docs/revise/json)).
45
- `revise examples` shows more.
38
+ [JSON output contract](https://revise.io/developer/docs/revise/json)
46
39
 
47
40
  ## Agent skills
48
41
 
49
- The skill teaches a coding agent the CLI: reading by block id, tracked edits,
50
- review, creating documents, and the `xml` escape hatch.
51
-
52
- | Agent | Install |
53
- | --------------------------------- | ------------------------------------------------------------------------------------------------- |
54
- | Claude Code | `claude plugin marketplace add reviseio/skills`, then `claude plugin install revise@revise` |
55
- | Codex, ChatGPT desktop | `codex plugin marketplace add reviseio/skills`, then `codex plugin add revise@revise` |
56
- | Cursor, Copilot, Windsurf, Cline… | `npx skills add reviseio/skills --skill revise` |
57
- | Anything else | `revise skill install` (into `.agents/skills` or `.claude/skills`), or `revise skill` to print it |
58
-
59
- Building a browser editor instead? The `revise-editor` skill covers
60
- [`@reviseio/editor`](https://www.npmjs.com/package/@reviseio/editor):
61
- `npx skills add reviseio/skills --skill revise-editor`.
42
+ ```bash
43
+ claude plugin marketplace add reviseio/skills && claude plugin install revise@revise # Claude Code
44
+ codex plugin marketplace add reviseio/skills && codex plugin add revise@revise # Codex
45
+ npx skills add reviseio/skills --skill revise # Cursor, Copilot, Windsurf…
46
+ revise skill install # anything else
47
+ ```
62
48
 
63
- ## The library
49
+ ## Library
64
50
 
65
51
  ```ts
66
52
  import { ReviseDocument } from "revise";
67
53
 
68
54
  const doc = await ReviseDocument.open("contract.docx", { author: "Legal bot" });
69
- await doc.replaceText("Provider", "Northstar"); // tracked changes
55
+ await doc.replaceAll("Provider", "Northstar");
70
56
  await doc.reject({ section: "8" });
71
- const { bytes, fidelity } = await doc.export({ format: "docx" });
57
+ const { bytes } = await doc.export({ format: "docx" });
72
58
  doc.dispose();
73
59
  ```
74
60
 
75
- Run the editing tools with typed input, or hand them to a model:
61
+ Give the editing tools to a model:
76
62
 
77
63
  ```ts
78
64
  import Anthropic from "@anthropic-ai/sdk";
79
65
  import { ReviseDocument, agentTools } from "revise";
80
66
 
81
67
  const doc = await ReviseDocument.open("brief.docx");
82
- const { tools, handle } = agentTools(doc, { provider: "anthropic" });
83
- const client = new Anthropic();
84
- // Pass `tools` to client.messages.create(); answer each tool_use block in
85
- // the response with `await handle(block)`, which returns its tool_result.
68
+ const agent = agentTools(doc, { provider: "anthropic" }); // or "openai"
69
+ const reply = await new Anthropic().messages.create({
70
+ model,
71
+ max_tokens,
72
+ messages,
73
+ tools: agent.tools,
74
+ });
75
+ const results = await Promise.all(
76
+ reply.content.filter((b) => b.type === "tool_use").map(agent.handle),
77
+ );
78
+ messages.push(
79
+ { role: "assistant", content: reply.content },
80
+ { role: "user", content: results },
81
+ );
86
82
  ```
87
83
 
88
- ### Collaboration servers
89
-
90
- Seed a sync server's room from a file, and edit or export the live room:
84
+ Edit a live collaboration room (Y.js):
91
85
 
92
86
  ```ts
93
87
  import { ReviseDocument, seedYDoc } from "revise";
94
88
 
95
- // e.g. Hocuspocus onLoadDocument: safe on every connection
96
- await seedYDoc(room, "contract.docx");
97
-
89
+ await seedYDoc(room, "contract.docx"); // safe on every connection
98
90
  const doc = await ReviseDocument.fromYDoc(room, { author: "Review bot" });
99
- await doc.tools.call("replace", {
100
- /* ... */
101
- });
91
+ await doc.replaceAll("draft", "final");
102
92
  const { bytes } = await doc.export({ format: "docx" });
103
93
  ```
104
94
 
105
- The browser editor for the same documents is
106
- [`@reviseio/editor`](https://www.npmjs.com/package/@reviseio/editor).
107
-
108
- ## Docs
95
+ ## Links
109
96
 
110
- - [revise.io/developer/docs](https://revise.io/developer/docs)
111
- - [Build with AI](https://revise.io/developer/docs/build-with-ai): skills,
112
- plugins, and Markdown versions of every page
113
- - [Changelog](https://revise.io/developer/docs/revise/changelog)
97
+ [Docs](https://revise.io/developer/docs/revise/introduction) ·
98
+ [Changelog](https://revise.io/developer/docs/revise/changelog) ·
99
+ [Browser editor (`@reviseio/editor`)](https://www.npmjs.com/package/@reviseio/editor)
114
100
 
115
101
  ## License
116
102
 
117
- MIT. `revise` runs on [`@reviseio/engine`](https://www.npmjs.com/package/@reviseio/engine),
118
- Revise's document engine, which is installed with it and is free for any use,
119
- including commercial, under its own license.
103
+ MIT. Runs on [`@reviseio/engine`](https://www.npmjs.com/package/@reviseio/engine),
104
+ free for any use under its own license.