docrev 0.6.13 → 0.7.6

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.
@@ -73,8 +73,8 @@ export function prepareMarkdownWithMarkers(markdown) {
73
73
 
74
74
  // Detect reply relationships based on adjacency
75
75
  // First comment in a cluster = parent, all subsequent = replies to that parent
76
- // Comments are "adjacent" if there's only whitespace between them (< 50 chars)
77
- const ADJACENT_THRESHOLD = 50;
76
+ // Comments are "adjacent" if there's minimal text between them (< 10 chars)
77
+ const ADJACENT_THRESHOLD = 10;
78
78
  const comments = [];
79
79
  let clusterParentIdx = -1; // Index of first comment in current cluster
80
80
  let lastCommentEnd = -1;
@@ -170,23 +170,9 @@ export function prepareMarkdownWithMarkers(markdown) {
170
170
  markedMarkdown = markedMarkdown.slice(0, removeStart) + markedMarkdown.slice(c.end);
171
171
  } else {
172
172
  // Normal case: replace with markers
173
- let anchor = c.anchor || '';
174
-
175
- // If no anchor, try to use the next word as fallback to avoid empty ranges
176
- if (!anchor) {
177
- const afterComment = markedMarkdown.slice(c.end);
178
- // Match the next word (skip leading whitespace/punctuation)
179
- const nextWordMatch = afterComment.match(/^\s*([a-zA-Z0-9]+)/);
180
- if (nextWordMatch) {
181
- anchor = nextWordMatch[1];
182
- // Also need to consume the matched text from afterComment
183
- c.consumeAfter = nextWordMatch[0].length;
184
- }
185
- }
186
-
173
+ const anchor = c.anchor || '';
187
174
  const replacement = `${MARKER_START_PREFIX}${i}${MARKER_SUFFIX}${anchor}${MARKER_END_PREFIX}${i}${MARKER_SUFFIX}`;
188
- const endPos = c.end + (c.consumeAfter || 0);
189
- markedMarkdown = markedMarkdown.slice(0, c.start) + replacement + markedMarkdown.slice(endPos);
175
+ markedMarkdown = markedMarkdown.slice(0, c.start) + replacement + markedMarkdown.slice(c.end);
190
176
  }
191
177
  }
192
178
  }
@@ -414,10 +400,19 @@ export async function injectCommentsAtMarkers(docxPath, comments, outputPath) {
414
400
  if (startInText === -1 || endInText === -1) continue;
415
401
 
416
402
  let textBefore = fullText.slice(0, startInText);
417
- const anchorText = fullText.slice(startInText + startMarker.length, endInText);
403
+ let anchorText = fullText.slice(startInText + startMarker.length, endInText);
418
404
  let textAfter = fullText.slice(endInText + endMarker.length);
419
405
 
420
- // When anchor is empty, normalize double spaces to single space
406
+ // When anchor is empty, use the first word from textAfter as fallback
407
+ if (!anchorText && textAfter) {
408
+ const wordMatch = textAfter.match(/^\s*(\S+)/);
409
+ if (wordMatch) {
410
+ anchorText = wordMatch[1];
411
+ textAfter = textAfter.slice(wordMatch[0].length);
412
+ }
413
+ }
414
+
415
+ // When anchor is still empty, normalize double spaces to single space
421
416
  if (!anchorText && textBefore.endsWith(' ') && textAfter.startsWith(' ')) {
422
417
  textAfter = textAfter.slice(1); // Remove leading space from textAfter
423
418
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docrev",
3
- "version": "0.6.13",
3
+ "version": "0.7.6",
4
4
  "description": "Academic paper revision workflow: Word ↔ Markdown round-trips, DOI validation, reviewer comments",
5
5
  "type": "module",
6
6
  "types": "types/index.d.ts",
@@ -114,11 +114,13 @@
114
114
  "dictionary-en": "^4.0.0",
115
115
  "dictionary-en-gb": "^3.0.0",
116
116
  "diff": "^8.0.2",
117
- "js-yaml": "^4.1.1",
118
117
  "mammoth": "^1.6.0",
119
118
  "mathml-to-latex": "^1.5.0",
120
119
  "nspell": "^2.1.5",
121
- "xml2js": "^0.6.2"
120
+ "pdf-lib": "^1.17.1",
121
+ "pdfjs-dist": "^5.4.530",
122
+ "xml2js": "^0.6.2",
123
+ "yaml": "^2.8.2"
122
124
  },
123
125
  "devDependencies": {
124
126
  "c8": "^10.1.2"
@@ -1,12 +1,29 @@
1
1
  # docrev Command Reference
2
2
 
3
+ ## Project Creation
4
+
5
+ ### rev new
6
+ Create a new document project.
7
+ ```bash
8
+ rev new my-document # Creates my-document/ with section files
9
+ rev new my-document --template apa
10
+ ```
11
+
3
12
  ## Document Import/Export
4
13
 
5
14
  ### rev import
6
15
  Import a Word document with track changes and comments.
7
16
  ```bash
8
- rev import --file manuscript.docx
9
- rev import -f manuscript.docx --output ./project
17
+ rev import manuscript.docx
18
+ rev import manuscript.docx --output ./project
19
+ ```
20
+
21
+ ### rev sync
22
+ Sync feedback from a reviewed Word document into existing markdown sections.
23
+ ```bash
24
+ rev sync reviewed.docx # Updates markdown with track changes/comments
25
+ rev sync # Auto-detect most recent .docx
26
+ rev sync reviewed.docx methods # Sync only methods section
10
27
  ```
11
28
 
12
29
  ### rev build
@@ -16,8 +33,13 @@ rev build # Build PDF and DOCX
16
33
  rev build pdf # PDF only
17
34
  rev build docx # DOCX only
18
35
  rev build --toc # Include table of contents
36
+ rev build docx --dual # Clean + annotated versions
19
37
  ```
20
38
 
39
+ The `--dual` flag produces:
40
+ - `paper.docx` — clean, for submission
41
+ - `paper_comments.docx` — includes comment threads as Word comments
42
+
21
43
  ### rev preview
22
44
  Build and open document in default app.
23
45
  ```bash
@@ -62,9 +84,44 @@ rev resolve methods.md -n 1,2,3 # Multiple comments
62
84
  ```
63
85
 
64
86
  ### rev status
65
- Show annotation counts for a file.
87
+ Show project overview or annotation counts for a file.
88
+ ```bash
89
+ rev status # Project overview (words, comments, changes)
90
+ rev status methods.md # Specific file annotations
91
+ ```
92
+
93
+ ### rev next / rev prev
94
+ Navigate pending comments.
95
+ ```bash
96
+ rev next # Show next pending comment
97
+ rev next -n 3 # Show 3rd pending comment
98
+ rev prev # Show last pending comment
99
+ rev first methods # First comment in methods section
100
+ rev last # Last comment overall
101
+ ```
102
+
103
+ ### rev todo
104
+ List all pending comments as a checklist.
105
+ ```bash
106
+ rev todo # List all pending
107
+ rev todo --by-author # Group by author
108
+ ```
109
+
110
+ ### rev accept / rev reject
111
+ Accept or reject track changes.
66
112
  ```bash
67
- rev status methods.md
113
+ rev accept methods.md # List all changes
114
+ rev accept methods.md -n 1 # Accept change #1
115
+ rev accept methods.md -a # Accept all
116
+ rev reject methods.md -n 2 # Reject change #2
117
+ ```
118
+
119
+ ### rev archive
120
+ Archive reviewer .docx files.
121
+ ```bash
122
+ rev archive # Move all .docx to archive/
123
+ rev archive --by Smith # Specify reviewer name
124
+ rev archive --dry-run # Preview without moving
68
125
  ```
69
126
 
70
127
  ### rev strip
@@ -202,7 +259,7 @@ rev equations list # List all equations
202
259
  rev equations from-word manuscript.docx # Extract from Word
203
260
  ```
204
261
 
205
- ## Direct DOCX Editing
262
+ ## Direct DOCX Editing (Layout Workflow)
206
263
 
207
264
  ### rev annotate
208
265
  Add comments directly to Word document.
@@ -224,19 +281,6 @@ rev comment paper.docx
224
281
 
225
282
  ## Project Management
226
283
 
227
- ### rev init
228
- Initialize a new paper project.
229
- ```bash
230
- rev init my-paper
231
- rev init my-paper --template apa
232
- ```
233
-
234
- ### rev sections
235
- List and manage section files.
236
- ```bash
237
- rev sections # List all sections
238
- ```
239
-
240
284
  ### rev clean
241
285
  Remove generated files.
242
286
  ```bash
@@ -277,3 +321,17 @@ Output shell completions.
277
321
  eval "$(rev completions bash)" # Bash
278
322
  eval "$(rev completions zsh)" # Zsh
279
323
  ```
324
+
325
+ ## AI Skill Installation
326
+
327
+ ### rev install-cli-skill
328
+ Install the docrev skill for AI coding assistants.
329
+ ```bash
330
+ rev install-cli-skill # Install to ~/.claude/skills/docrev
331
+ ```
332
+
333
+ ### rev uninstall-cli-skill
334
+ Remove the installed skill.
335
+ ```bash
336
+ rev uninstall-cli-skill
337
+ ```
package/skill/SKILL.md CHANGED
@@ -1,30 +1,63 @@
1
1
  ---
2
2
  name: docrev
3
- description: "Academic paper revision workflow tool (CLI: `rev`). Use when working with Word documents containing reviewer comments, importing track changes to markdown, replying to reviewer comments, building PDF/DOCX outputs, generating response letters, validating citations/DOIs, or any academic paper revision task."
3
+ description: "Document revision workflow tool (CLI: `rev`). Use when working with Word documents containing reviewer comments, importing track changes to markdown, replying to reviewer comments, building PDF/DOCX outputs, generating response letters, validating citations/DOIs, or any document revision task."
4
4
  ---
5
5
 
6
- # docrev - Academic Paper Revision Tool
6
+ # docrev - Document Revision Tool
7
7
 
8
- `rev` is a CLI tool for academic paper workflows with Word ↔ Markdown round-trips.
8
+ `rev` is a CLI tool for document workflows with Word ↔ Markdown round-trips.
9
+
10
+ Works for any document that goes through Word-based review: scientific papers, contracts, reports, proposals, manuals.
11
+
12
+ ## Content and Layout, Separated
13
+
14
+ In Markdown, you focus on content. Write text, add citations with `[@key]`, insert equations with `$...$`, reference figures with `@fig:label`. No fiddling with fonts or styles.
15
+
16
+ Layout is controlled in `rev.yaml`:
17
+
18
+ ```yaml
19
+ title: "My Document"
20
+ output:
21
+ docx:
22
+ reference-doc: template.docx
23
+ ```
24
+
25
+ Change the template, rebuild, and every document gets the new formatting.
9
26
 
10
27
  ## Core Workflow
11
28
 
12
- ### 1. Import reviewed Word document
29
+ ### 1. Create or import a project
30
+
31
+ ```bash
32
+ rev new my-document # Start from scratch
33
+ rev import manuscript.docx # Start from existing Word doc
34
+ ```
35
+
36
+ ### 2. Build and share
13
37
 
14
38
  ```bash
15
- rev import --file manuscript-reviewed.docx
39
+ rev build docx # Generate Word document
16
40
  ```
17
41
 
18
- This extracts track changes and comments as CriticMarkup annotations in markdown files.
42
+ Send to reviewers. They add comments and track changes in Word.
19
43
 
20
- ### 2. View and address comments
44
+ ### 3. Import feedback
21
45
 
22
46
  ```bash
23
- rev comments methods.md # List all comments with context
24
- rev status methods.md # Show annotation counts
47
+ rev sync reviewed.docx # Updates markdown with annotations
48
+ rev sync # Auto-detect most recent .docx
25
49
  ```
26
50
 
27
- ### 3. Reply to reviewer comments
51
+ ### 4. View and address comments
52
+
53
+ ```bash
54
+ rev status # Project overview
55
+ rev todo # List all pending comments
56
+ rev next # Show next pending comment
57
+ rev comments methods.md # List all comments with context
58
+ ```
59
+
60
+ ### 5. Reply to reviewer comments
28
61
 
29
62
  **Always use the non-interactive reply mode:**
30
63
 
@@ -35,25 +68,31 @@ rev reply results.md -n 3 -m "Updated figure to include 95% CI"
35
68
 
36
69
  Replies appear as: `{>>Reviewer: Original<<} {>>User: Reply<<}`
37
70
 
38
- ### 4. Resolve addressed comments
71
+ ### 6. Resolve addressed comments
72
+
73
+ ```bash
74
+ rev resolve methods.md -n 1 # Mark comment #1 as resolved
75
+ ```
76
+
77
+ ### 7. Rebuild with comment threads
39
78
 
40
79
  ```bash
41
- rev resolve methods.md -n 1 # Mark comment #1 as resolved
80
+ rev build docx --dual # Produces clean + annotated versions
42
81
  ```
43
82
 
44
- ### 5. Build output documents
83
+ - `paper.docx` clean, for submission
84
+ - `paper_comments.docx` — includes comment threads as Word comments
85
+
86
+ ### 8. Archive reviewer files
45
87
 
46
88
  ```bash
47
- rev build # Build both PDF and DOCX
48
- rev build docx # Word only
49
- rev build pdf # PDF only
50
- rev build --toc # Include table of contents
89
+ rev archive # Move reviewer files to archive/
51
90
  ```
52
91
 
53
- ### 6. Generate response letter
92
+ ### 9. Generate response letter
54
93
 
55
94
  ```bash
56
- rev response # Generate point-by-point response letter
95
+ rev response # Generate point-by-point response letter
57
96
  ```
58
97
 
59
98
  ## Annotation Syntax (CriticMarkup)
@@ -68,8 +107,28 @@ rev response # Generate point-by-point response letter
68
107
 
69
108
  | Task | Command |
70
109
  |------|---------|
110
+ | Create project | `rev new my-project` |
111
+ | Create LaTeX project | `rev new my-project --template latex` |
112
+ | Import Word doc | `rev import manuscript.docx` |
113
+ | Sync Word feedback | `rev sync reviewed.docx` |
114
+ | Sync PDF comments | `rev sync annotated.pdf` |
115
+ | Extract PDF comments | `rev pdf-comments annotated.pdf` |
116
+ | Extract with highlighted text | `rev pdf-comments file.pdf --with-text` |
117
+ | Append PDF comments | `rev pdf-comments annotated.pdf --append methods.md` |
118
+ | Project status | `rev status` |
119
+ | Next pending | `rev next` |
120
+ | List pending | `rev todo` |
121
+ | Filter by author | `rev comments file.md --author "Reviewer 2"` |
122
+ | Reply to all pending | `rev reply file.md --all -m "Addressed"` |
123
+ | Accept all changes | `rev accept file.md -a` |
124
+ | Build Word | `rev build docx` |
125
+ | Build PDF | `rev build pdf` |
126
+ | Build clean + annotated Word | `rev build docx --dual` |
127
+ | Build clean + annotated PDF | `rev build pdf --dual` |
128
+ | Show contributors | `rev contributors` |
129
+ | Lookup ORCID | `rev orcid 0000-0002-1825-0097` |
130
+ | Archive reviewer files | `rev archive` |
71
131
  | Word count per section | `rev word-count` |
72
- | Word count with limit | `rev word-count --limit 5000` |
73
132
  | Project dashboard | `rev stats` |
74
133
  | Search all sections | `rev search "query"` |
75
134
  | Pre-submission check | `rev check` |
@@ -78,6 +137,7 @@ rev response # Generate point-by-point response letter
78
137
  | Check spelling | `rev spelling` |
79
138
  | Open PDF preview | `rev preview pdf` |
80
139
  | Auto-rebuild on changes | `rev watch` |
140
+ | Check for updates | `rev upgrade --check` |
81
141
 
82
142
  ## DOI Management
83
143
 
@@ -115,7 +175,7 @@ Available in section files (processed during build):
115
175
  ## Project Structure
116
176
 
117
177
  ```
118
- my-paper/
178
+ my-document/
119
179
  ├── rev.yaml # Project config
120
180
  ├── introduction.md # Section files with annotations
121
181
  ├── methods.md
@@ -126,17 +186,52 @@ my-paper/
126
186
  └── paper.docx # Built output
127
187
  ```
128
188
 
189
+ ## PDF Comment Workflow
190
+
191
+ For reviewers who annotate PDFs instead of Word documents:
192
+
193
+ ### 1. Extract comments from PDF
194
+
195
+ ```bash
196
+ rev pdf-comments annotated.pdf # Display all comments
197
+ rev pdf-comments annotated.pdf --by-author # Group by reviewer
198
+ rev pdf-comments annotated.pdf --json # Output as JSON
199
+ ```
200
+
201
+ ### 2. Import into markdown
202
+
203
+ ```bash
204
+ rev sync annotated.pdf # Auto-import to sections
205
+ rev pdf-comments annotated.pdf --append methods.md # Append to specific file
206
+ ```
207
+
208
+ ### 3. Build PDF with margin notes
209
+
210
+ ```bash
211
+ rev build pdf --dual
212
+ ```
213
+
214
+ Produces:
215
+ - `paper.pdf` — clean version for submission
216
+ - `paper_comments.pdf` — comments rendered as LaTeX margin notes
217
+
218
+ **Supported PDF Annotations:**
219
+ - Sticky notes, text boxes, highlights, underlines, strikethrough, squiggly
220
+
129
221
  ## When Helping Users
130
222
 
131
- 1. **Import phase**: Run `rev import` to get track changes as markdown
132
- 2. **Review phase**: Use `rev comments` to see all comments, then `rev reply` to respond
133
- 3. **Build phase**: Run `rev build docx` to generate the updated Word document
134
- 4. **Validation phase**: Run `rev check` before submission (lint + grammar + citations)
135
- 5. **Response letter**: Use `rev response` to generate point-by-point responses
223
+ 1. **Setup**: Ensure `rev config user "Name"` is set for replies
224
+ 2. **Sync phase**: Run `rev sync` to get feedback (works with both Word and PDF)
225
+ 3. **Review phase**: Use `rev todo` and `rev next` to navigate comments, `rev reply` to respond
226
+ 4. **Accept phase**: Use `rev accept -a` or `rev review` to handle track changes
227
+ 5. **Build phase**: Run `rev build docx --dual` or `rev build pdf --dual` for annotated versions
228
+ 6. **Archive phase**: Run `rev archive` to move reviewer files
229
+ 7. **Validation phase**: Run `rev check` before submission
230
+ 8. **Response letter**: Use `rev response` to generate point-by-point responses
136
231
 
137
232
  ## Critical: Ask Questions When Unsure
138
233
 
139
- When addressing reviewer comments or editing scientific papers:
234
+ When addressing reviewer comments or editing documents:
140
235
 
141
236
  - **Never guess methods or numbers** - If a comment asks for clarification about methodology, sample sizes, statistical parameters, dates, or any quantitative information, ASK the user rather than inventing values
142
237
  - **Placeholders are acceptable** - Use `[???]` or `[TODO: specify X]` when information is missing rather than fabricating data
package/.rev-dictionary DELETED
@@ -1,4 +0,0 @@
1
- # Custom dictionary for docrev
2
- # Add one word per line
3
- # Lines starting with # are comments
4
-