docrev 0.11.0 → 0.11.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.
Files changed (123) hide show
  1. package/.gitattributes +1 -1
  2. package/CHANGELOG.md +202 -184
  3. package/PLAN-tables-and-postprocess.md +850 -850
  4. package/README.md +433 -431
  5. package/bin/rev.js +11 -11
  6. package/bin/rev.ts +145 -145
  7. package/completions/rev.bash +127 -127
  8. package/completions/rev.ps1 +210 -210
  9. package/completions/rev.zsh +207 -207
  10. package/dist/lib/build.d.ts +80 -0
  11. package/dist/lib/build.d.ts.map +1 -1
  12. package/dist/lib/build.js +207 -4
  13. package/dist/lib/build.js.map +1 -1
  14. package/dist/lib/commands/build.d.ts.map +1 -1
  15. package/dist/lib/commands/build.js +34 -12
  16. package/dist/lib/commands/build.js.map +1 -1
  17. package/dist/lib/commands/utilities.js +164 -164
  18. package/dist/lib/commands/word-tools.js +8 -8
  19. package/dist/lib/grammar.js +3 -3
  20. package/dist/lib/macro-filter.lua +201 -201
  21. package/dist/lib/pdf-comments.js +44 -44
  22. package/dist/lib/plugins.js +57 -57
  23. package/dist/lib/pptx-color-filter.lua +37 -37
  24. package/dist/lib/pptx-themes.js +115 -115
  25. package/dist/lib/schema.d.ts.map +1 -1
  26. package/dist/lib/schema.js +8 -2
  27. package/dist/lib/schema.js.map +1 -1
  28. package/dist/lib/spelling.js +2 -2
  29. package/dist/lib/templates.js +387 -387
  30. package/dist/lib/themes.js +51 -51
  31. package/dist/lib/trackchanges.d.ts +41 -25
  32. package/dist/lib/trackchanges.d.ts.map +1 -1
  33. package/dist/lib/trackchanges.js +90 -151
  34. package/dist/lib/trackchanges.js.map +1 -1
  35. package/dist/lib/types.d.ts +0 -7
  36. package/dist/lib/types.d.ts.map +1 -1
  37. package/docs-src/build.py +113 -113
  38. package/docs-src/extra.css +208 -208
  39. package/docs-src/md-to-html.lua +6 -6
  40. package/docs-src/template.html +116 -116
  41. package/eslint.config.js +27 -27
  42. package/lib/anchor-match.ts +307 -307
  43. package/lib/annotations.ts +664 -664
  44. package/lib/build.ts +2047 -1770
  45. package/lib/citations.ts +160 -160
  46. package/lib/commands/build.ts +885 -860
  47. package/lib/commands/citations.ts +515 -515
  48. package/lib/commands/comments.ts +1050 -1050
  49. package/lib/commands/context.ts +176 -176
  50. package/lib/commands/core.ts +309 -309
  51. package/lib/commands/doi.ts +451 -451
  52. package/lib/commands/file-ops.ts +372 -372
  53. package/lib/commands/history.ts +320 -320
  54. package/lib/commands/index.ts +87 -87
  55. package/lib/commands/init.ts +259 -259
  56. package/lib/commands/merge-resolve.ts +378 -378
  57. package/lib/commands/preview.ts +178 -178
  58. package/lib/commands/project-info.ts +244 -244
  59. package/lib/commands/quality.ts +517 -517
  60. package/lib/commands/response.ts +454 -454
  61. package/lib/commands/section-boundaries.ts +82 -82
  62. package/lib/commands/sections.ts +451 -451
  63. package/lib/commands/sync.ts +689 -689
  64. package/lib/commands/text-ops.ts +449 -449
  65. package/lib/commands/utilities.ts +448 -448
  66. package/lib/commands/verify-anchors.ts +272 -272
  67. package/lib/commands/word-tools.ts +340 -340
  68. package/lib/comment-realign.ts +99 -99
  69. package/lib/config.ts +84 -84
  70. package/lib/crossref.ts +781 -781
  71. package/lib/csl.ts +191 -191
  72. package/lib/dependencies.ts +132 -132
  73. package/lib/diff-engine.ts +465 -465
  74. package/lib/doi-cache.ts +115 -115
  75. package/lib/doi.ts +879 -879
  76. package/lib/equations.ts +506 -506
  77. package/lib/errors.ts +350 -350
  78. package/lib/format.ts +541 -541
  79. package/lib/git.ts +326 -326
  80. package/lib/grammar.ts +303 -303
  81. package/lib/image-registry.ts +180 -180
  82. package/lib/import.ts +906 -906
  83. package/lib/journals.ts +543 -543
  84. package/lib/macro-filter.lua +201 -201
  85. package/lib/macros.ts +273 -273
  86. package/lib/merge.ts +633 -633
  87. package/lib/ooxml.ts +768 -768
  88. package/lib/orcid.ts +144 -144
  89. package/lib/pdf-comments.ts +263 -263
  90. package/lib/pdf-import.ts +524 -524
  91. package/lib/plugins.ts +362 -362
  92. package/lib/postprocess.ts +188 -188
  93. package/lib/pptx-color-filter.lua +37 -37
  94. package/lib/pptx-template.ts +469 -469
  95. package/lib/pptx-themes.ts +483 -483
  96. package/lib/protect-restore.ts +520 -520
  97. package/lib/rate-limiter.ts +127 -127
  98. package/lib/response.ts +197 -197
  99. package/lib/restore-references.ts +240 -240
  100. package/lib/review.ts +327 -327
  101. package/lib/schema.ts +494 -488
  102. package/lib/scientific-words.ts +73 -73
  103. package/lib/sections.ts +428 -428
  104. package/lib/slides.ts +756 -756
  105. package/lib/spelling.ts +334 -334
  106. package/lib/templates.ts +526 -526
  107. package/lib/themes.ts +742 -742
  108. package/lib/trackchanges.ts +166 -247
  109. package/lib/tui.ts +450 -450
  110. package/lib/types.ts +546 -558
  111. package/lib/undo.ts +250 -250
  112. package/lib/utils.ts +69 -69
  113. package/lib/variables.ts +179 -179
  114. package/lib/word-extraction.ts +525 -525
  115. package/lib/word.ts +526 -526
  116. package/lib/wordcomments.ts +789 -789
  117. package/mkdocs.yml +64 -64
  118. package/package.json +137 -137
  119. package/scripts/postbuild.js +47 -47
  120. package/skill/REFERENCE.md +550 -539
  121. package/skill/SKILL.md +302 -295
  122. package/tsconfig.json +26 -26
  123. package/types/index.d.ts +531 -525
@@ -1,539 +1,550 @@
1
- # docrev Command Reference
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
-
12
- ## Document Import/Export
13
-
14
- ### rev import
15
- Import a Word document with track changes and comments.
16
- ```bash
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
27
- rev sync reviewed.docx --comments-only # Insert comments only; never modify prose
28
- ```
29
-
30
- `--comments-only` skips the Word→Markdown diff entirely. Use it when the
31
- markdown has been revised between sending the docx out for review and
32
- receiving it back: applying track changes from a stale draft would clobber
33
- newer edits, but comments still need to land. Comments are placed at
34
- fuzzy-matched anchors against the current prose. Pair with
35
- `rev verify-anchors` to see which ones won't fit before you run sync.
36
-
37
- ### rev verify-anchors
38
- Report drift between Word comment anchors and the current markdown.
39
- ```bash
40
- rev verify-anchors reviewed.docx # Print per-comment match quality
41
- rev verify-anchors reviewed.docx --json # Machine-readable report
42
- ```
43
-
44
- Each comment is classified by how well its anchor still matches the current
45
- section prose:
46
-
47
- - `clean` – exact or whitespace-normalized hit
48
- - `drift` – anchor only matches via stripped-CriticMarkup or partial-prefix fallbacks
49
- - `context-only` – anchor text is gone, only surrounding context survives
50
- - `ambiguous` – multiple candidate positions; needs context to disambiguate
51
- - `unmatched` – nothing maps; user must place the comment manually
52
-
53
- Useful before `rev sync --comments-only` to plan which comments will land
54
- automatically and which need manual placement.
55
-
56
- ### rev build
57
- Build output documents from markdown sections.
58
- ```bash
59
- rev build # Build PDF and DOCX
60
- rev build pdf # PDF only
61
- rev build docx # DOCX only
62
- rev build --toc # Include table of contents
63
- rev build docx --dual # Clean + annotated versions
64
- rev build docx --show-changes # DOCX with visible track changes (audit)
65
- rev build docx --pandoc-arg=--lua-filter=tofill.lua # Pass extra args to pandoc
66
- rev build -o Final_Report # Override output filename (extension auto-added)
67
- rev build pdf --verbose # Echo the pandoc invocation (useful for filter debugging)
68
- ```
69
-
70
- By default, outputs land in `output/` next to `rev.yaml`. Override or
71
- disable via the `outputDir` field in rev.yaml (see below).
72
-
73
- #### Choosing output filenames
74
-
75
- By default, the output basename is derived from `title:` (slugified — e.g.
76
- "My Paper" `my-paper.docx`). Long titles are truncated at word boundaries
77
- (at the last `-` at-or-before 80 chars), so `communities` stays whole instead
78
- of becoming `communitie`.
79
-
80
- To pick your own filename, set per-format names in `rev.yaml`:
81
-
82
- ```yaml
83
- output:
84
- docx: ADAPT_proposal_draft.docx
85
- pdf: ADAPT_proposal_draft.pdf
86
- ```
87
-
88
- Extensions are optional — `ADAPT_proposal_draft` is fine, the right extension
89
- is added per format. Relative paths resolve under `outputDir`; absolute paths
90
- bypass `outputDir`.
91
-
92
- Or override on the command line with `-o, --output <path>`:
93
-
94
- ```bash
95
- rev build docx -o Final_Report # → output/Final_Report.docx
96
- rev build pdf docx -o Final_Report # Applies to both formats
97
- rev build -o /tmp/draft.docx docx # Absolute path bypasses outputDir
98
- ```
99
-
100
- CLI `-o` wins over `output:` in `rev.yaml`. When `--dual` is on, the
101
- `_comments` variant piggybacks on the chosen name (e.g.
102
- `Final_Report_comments.docx`). When `--show-changes` is on, the audit DOCX
103
- uses the chosen name with a `-changes` suffix
104
- (e.g. `Final_Report-changes.docx`).
105
-
106
- #### Passing custom pandoc args
107
-
108
- For pandoc flags rev doesn't surface directly (Lua/JSON filters, custom
109
- templates, variables, etc.), use the repeatable `--pandoc-arg` flag or the
110
- `pandoc-args` field in `rev.yaml`:
111
-
112
- ```yaml
113
- # rev.yaml — applies to every format
114
- pandoc-args:
115
- - --lua-filter=tofill.lua
116
- - --shift-heading-level-by=1
117
-
118
- # Format-specific (concatenated after the top-level list)
119
- docx:
120
- pandoc-args:
121
- - --lua-filter=docx_only.lua
122
- pdf:
123
- pandoc-args:
124
- - --variable=papersize:a4
125
- ```
126
-
127
- ```bash
128
- # CLI overrides — appended last, so pandoc's last-wins rule lets CLI flags
129
- # beat repeated config flags
130
- rev build docx --pandoc-arg=--lua-filter=cli.lua --pandoc-arg=--metadata=draft:true
131
- ```
132
-
133
- Run with `--verbose` to print the full pandoc command line (one per format).
134
- Copy-paste it into a terminal to reproduce a build manually.
135
-
136
- The `--dual` flag produces:
137
- - `output/<title>.docx` clean, for submission
138
- - `output/<title>_comments.docx` — includes comment threads as Word comments
139
-
140
- The `--show-changes` flag (DOCX only) produces a single audit document
141
- where every accepted/rejected revision and substitution is exported as a
142
- visible Word track change, attributed to the configured user. Useful when
143
- a co-author wants to see what changed since the last shared version.
144
-
145
- ### rev preview
146
- Build and open document in default app.
147
- ```bash
148
- rev preview pdf # Build and open PDF
149
- rev preview docx # Build and open Word
150
- ```
151
-
152
- ### rev export
153
- Export project as distributable zip.
154
- ```bash
155
- rev export # Creates project.zip (no node_modules)
156
- ```
157
-
158
- ### rev backup
159
- Create timestamped project backup.
160
- ```bash
161
- rev backup # Creates backup-2024-12-29.zip
162
- rev backup --name v1-draft # Creates v1-draft.zip
163
- ```
164
-
165
- ## Comments & Annotations
166
-
167
- ### rev comments
168
- List all comments with context.
169
- ```bash
170
- rev comments methods.md # Show comments
171
- rev comments methods.md --export out.csv # Export to CSV
172
- ```
173
-
174
- ### rev reply
175
- Reply to a specific comment (non-interactive).
176
- ```bash
177
- rev reply methods.md -n 1 -m "Added clarification"
178
- rev reply results.md -n 3 -m "Updated figure"
179
- ```
180
-
181
- ### rev resolve
182
- Mark a comment as resolved.
183
- ```bash
184
- rev resolve methods.md -n 1
185
- rev resolve methods.md -n 1,2,3 # Multiple comments
186
- ```
187
-
188
- ### rev status
189
- Show project overview or annotation counts for a file.
190
- ```bash
191
- rev status # Project overview (words, comments, changes)
192
- rev status methods.md # Specific file annotations
193
- ```
194
-
195
- ### rev next / rev prev
196
- Navigate pending comments.
197
- ```bash
198
- rev next # Show next pending comment
199
- rev next -n 3 # Show 3rd pending comment
200
- rev prev # Show last pending comment
201
- rev first methods # First comment in methods section
202
- rev last # Last comment overall
203
- ```
204
-
205
- ### rev todo
206
- List all pending comments as a checklist.
207
- ```bash
208
- rev todo # List all pending
209
- rev todo --by-author # Group by author
210
- ```
211
-
212
- ### rev accept / rev reject
213
- Accept or reject track changes.
214
- ```bash
215
- rev accept methods.md # List all changes
216
- rev accept methods.md -n 1 # Accept change #1
217
- rev accept methods.md -a # Accept all
218
- rev reject methods.md -n 2 # Reject change #2
219
- ```
220
-
221
- ### rev archive
222
- Archive reviewer .docx files.
223
- ```bash
224
- rev archive # Move all .docx to archive/
225
- rev archive --by Smith # Specify reviewer name
226
- rev archive --dry-run # Preview without moving
227
- ```
228
-
229
- ### rev strip
230
- Remove all annotations from markdown.
231
- ```bash
232
- rev strip methods.md --output clean.md
233
- rev strip methods.md --accept # Accept all changes
234
- rev strip methods.md --reject # Reject all changes
235
- ```
236
-
237
- ## Response Letter
238
-
239
- ### rev response
240
- Generate point-by-point response letter from comments.
241
- ```bash
242
- rev response # Generate response letter
243
- ```
244
-
245
- ## Validation & Checks
246
-
247
- ### rev check
248
- Run all pre-submission checks (lint + grammar + citations).
249
- ```bash
250
- rev check # Run all checks
251
- rev check --fix # Auto-fix where possible
252
- ```
253
-
254
- ### rev lint
255
- Check for common issues.
256
- ```bash
257
- rev lint # Run all checks
258
- rev lint --fix # Auto-fix where possible
259
- ```
260
- Checks: broken cross-references, missing citations, orphaned figures, unresolved comments.
261
-
262
- ### rev grammar
263
- Check grammar and style.
264
- ```bash
265
- rev grammar # Check all sections
266
- rev grammar --rules # List available rules
267
- rev grammar --learn word # Add to custom dictionary
268
- rev grammar --forget word # Remove from dictionary
269
- rev grammar --list # Show custom dictionary
270
- rev grammar -s warning # Filter by severity
271
- ```
272
-
273
- ### rev spelling
274
- Check spelling in all sections.
275
- ```bash
276
- rev spelling # Check all sections
277
- rev spelling --british # Use British English dictionary
278
- rev spelling --learn word # Add to global dictionary (~/.rev-dictionary)
279
- rev spelling --learn-project word # Add to project dictionary
280
- rev spelling --forget word # Remove from global dictionary
281
- rev spelling --list # Show global dictionary
282
- rev spelling --list-all # Show global + project dictionaries
283
- ```
284
- Built-in scientific vocabulary reduces false positives. Possible author names are shown separately for easy review.
285
-
286
- ### rev validate
287
- Check against journal requirements.
288
- ```bash
289
- rev validate --journal nature
290
- rev validate --list # List 22 available journals
291
- ```
292
-
293
- ### rev citations
294
- Validate citations against bibliography.
295
- ```bash
296
- rev citations
297
- ```
298
-
299
- ## DOI Management
300
-
301
- ### rev doi check
302
- Validate DOIs in bibliography.
303
- ```bash
304
- rev doi check references.bib
305
- rev doi check references.bib --strict # Fail if articles missing DOIs
306
- ```
307
-
308
- ### rev doi lookup
309
- Find missing DOIs by title/author/year.
310
- ```bash
311
- rev doi lookup references.bib
312
- rev doi lookup references.bib --confidence high
313
- ```
314
-
315
- ### rev doi fetch
316
- Get BibTeX from a DOI.
317
- ```bash
318
- rev doi fetch 10.1234/example
319
- ```
320
-
321
- ### rev doi add
322
- Add citation to .bib file from DOI.
323
- ```bash
324
- rev doi add 10.1234/example
325
- rev doi add 10.1234/example --file references.bib
326
- ```
327
-
328
- ## Content Analysis
329
-
330
- ### rev word-count
331
- Show word counts per section.
332
- ```bash
333
- rev word-count # Per-section counts
334
- rev word-count --limit 5000 # Warn if over limit
335
- rev word-count -j nature # Use journal word limit
336
- ```
337
-
338
- ### rev stats
339
- Project dashboard showing overview.
340
- ```bash
341
- rev stats # Words, figures, citations, comments
342
- ```
343
-
344
- ### rev search
345
- Search across all section files.
346
- ```bash
347
- rev search "climate change"
348
- rev search -i "method" # Case-insensitive
349
- ```
350
-
351
- ### rev figures
352
- List figures with reference counts.
353
- ```bash
354
- rev figures methods.md
355
- ```
356
-
357
- ### rev equations
358
- Work with LaTeX equations.
359
- ```bash
360
- rev equations list # List all equations
361
- rev equations from-word manuscript.docx # Extract from Word
362
- ```
363
-
364
- ## Direct DOCX Editing (Layout Workflow)
365
-
366
- ### rev annotate
367
- Add comments directly to Word document.
368
- ```bash
369
- rev annotate paper.docx -m "Comment" -s "text to find"
370
- ```
371
-
372
- ### rev apply
373
- Apply MD annotations as Word track changes.
374
- ```bash
375
- rev apply paper.md output.docx
376
- ```
377
-
378
- ### rev comment
379
- Interactive comment mode for Word documents.
380
- ```bash
381
- rev comment paper.docx
382
- ```
383
-
384
- ## Project Management
385
-
386
- ### rev clean
387
- Remove generated files.
388
- ```bash
389
- rev clean # Remove paper.md, PDFs, DOCXs
390
- rev clean --dry-run # Show what would be deleted
391
- rev clean --all # Also remove backups and exports
392
- ```
393
-
394
- ### rev open
395
- Open project folder or file.
396
- ```bash
397
- rev open # Open project folder
398
- rev open paper.pdf # Open specific file
399
- ```
400
-
401
- ### rev watch
402
- Auto-rebuild on file changes.
403
- ```bash
404
- rev watch # Watch and rebuild
405
- rev watch pdf # Only rebuild PDF
406
- rev watch --no-open # Don't open after build
407
- ```
408
-
409
- ## Configuration
410
-
411
- ### rev config
412
- Configure user settings.
413
- ```bash
414
- rev config user "Your Name" # Set author name for replies
415
- rev config # Show current config
416
- ```
417
-
418
- ## rev.yaml Settings
419
-
420
- ### Output Directory
421
-
422
- By default, built artefacts land in `output/` next to `rev.yaml`. Both the
423
- clean output and `--dual` companion (`*_comments.docx` / `*_comments.pdf`)
424
- follow the configured location. Override or disable:
425
-
426
- ```yaml
427
- outputDir: output # default — outputs land in ./output/
428
- outputDir: dist # custom subdirectory
429
- outputDir: null # legacy layout — outputs alongside paper.md
430
- ```
431
-
432
- Explicit caller-supplied output paths (e.g. internal temp files in the
433
- dual flow) bypass `outputDir`.
434
-
435
- ### PDF Engine and Fonts
436
-
437
- The default PDF engine is `pdflatex`. Switch to xelatex/lualatex when the
438
- manuscript needs native UTF-8 rendering of Latin-Extended diacritics
439
- (Czech/Polish/Croatian/Spanish author names, species epithets):
440
-
441
- ```yaml
442
- pdf:
443
- engine: xelatex # or lualatex, tectonic, etc.
444
- mainfont: "TeX Gyre Termes" # serif (xelatex/lualatex only — uses fontspec)
445
- sansfont: "TeX Gyre Heros" # sans (optional)
446
- monofont: "TeX Gyre Cursor" # monospace (optional)
447
- ```
448
-
449
- `mainfont`/`sansfont`/`monofont` are forwarded as pandoc `-V` flags and
450
- require an engine that loads `fontspec` (xelatex or lualatex). They are
451
- ignored under `pdflatex`.
452
-
453
- ### Tables
454
-
455
- Configure table formatting for PDF output:
456
-
457
- ```yaml
458
- tables:
459
- nowrap:
460
- - Prior # Column headers to keep on one line
461
- - "$\\widehat{R}$"
462
- ```
463
-
464
- In `nowrap` columns, distribution notation is auto-converted to LaTeX math:
465
- - `Normal(0, 0.5)` → `$\mathcal{N}(0, 0.5)$`
466
- - `Student-t(3, 0, 1)` `$t_3(0, 1)$`
467
- - `Gamma(2, 0.5)` → `$\text{Gamma}(2, 0.5)$`
468
- - `Half-Normal(0, 1)` → `$\text{Half-Normal}(0, 1)$`
469
- - `Exponential(1)` → `$\text{Exp}(1)$`
470
-
471
- **Tip:** For complex tables, use simple tables (space-aligned with dashes) instead of pipe tables to avoid column width issues:
472
-
473
- ```markdown
474
- Parameter Prior Description
475
- ---------- ------------------------- ------------------
476
- alpha $\mathcal{N}(0, 0.5)$ Intercept prior
477
- beta $t_3(0, 2.5)$ Slope prior
478
- ```
479
-
480
- ### Postprocess Scripts
481
-
482
- Run custom scripts after output generation:
483
-
484
- ```yaml
485
- postprocess:
486
- pdf: ./scripts/fix-pdf.py # Runs after PDF
487
- docx: ./scripts/add-meta.js # Runs after DOCX
488
- tex: ./scripts/tweak-latex.sh # Runs after TEX
489
- pptx: ./scripts/fix-slides.ps1 # Runs after PPTX
490
- all: ./scripts/notify.js # Runs after ANY format
491
- ```
492
-
493
- **Environment variables** available to scripts:
494
-
495
- | Variable | Description |
496
- |----------|-------------|
497
- | `OUTPUT_FILE` | Full path to generated file |
498
- | `OUTPUT_FORMAT` | Format: `pdf`, `docx`, `tex`, `pptx`, `beamer` |
499
- | `PROJECT_DIR` | Directory containing rev.yaml |
500
- | `CONFIG_PATH` | Full path to rev.yaml |
501
-
502
- **Supported script types:** `.js`, `.mjs` (Node), `.py` (Python), `.ps1` (PowerShell), `.sh` (Bash)
503
-
504
- **Example Python script** (add DOCX metadata):
505
- ```python
506
- import os
507
- from docx import Document
508
- doc = Document(os.environ['OUTPUT_FILE'])
509
- doc.core_properties.author = "Research Team"
510
- doc.save(os.environ['OUTPUT_FILE'])
511
- ```
512
-
513
- Use `--verbose` flag to see script output:
514
- ```bash
515
- rev build pdf --verbose
516
- ```
517
-
518
- ## Shell Completions
519
-
520
- ### rev completions
521
- Output shell completions.
522
- ```bash
523
- eval "$(rev completions bash)" # Bash
524
- eval "$(rev completions zsh)" # Zsh
525
- ```
526
-
527
- ## AI Skill Installation
528
-
529
- ### rev install-cli-skill
530
- Install the docrev skill for AI coding assistants.
531
- ```bash
532
- rev install-cli-skill # Install to ~/.claude/skills/docrev
533
- ```
534
-
535
- ### rev uninstall-cli-skill
536
- Remove the installed skill.
537
- ```bash
538
- rev uninstall-cli-skill
539
- ```
1
+ # docrev Command Reference
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
+
12
+ ## Document Import/Export
13
+
14
+ ### rev import
15
+ Import a Word document with track changes and comments.
16
+ ```bash
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
27
+ rev sync reviewed.docx --comments-only # Insert comments only; never modify prose
28
+ ```
29
+
30
+ `--comments-only` skips the Word→Markdown diff entirely. Use it when the
31
+ markdown has been revised between sending the docx out for review and
32
+ receiving it back: applying track changes from a stale draft would clobber
33
+ newer edits, but comments still need to land. Comments are placed at
34
+ fuzzy-matched anchors against the current prose. Pair with
35
+ `rev verify-anchors` to see which ones won't fit before you run sync.
36
+
37
+ ### rev verify-anchors
38
+ Report drift between Word comment anchors and the current markdown.
39
+ ```bash
40
+ rev verify-anchors reviewed.docx # Print per-comment match quality
41
+ rev verify-anchors reviewed.docx --json # Machine-readable report
42
+ ```
43
+
44
+ Each comment is classified by how well its anchor still matches the current
45
+ section prose:
46
+
47
+ - `clean` – exact or whitespace-normalized hit
48
+ - `drift` – anchor only matches via stripped-CriticMarkup or partial-prefix fallbacks
49
+ - `context-only` – anchor text is gone, only surrounding context survives
50
+ - `ambiguous` – multiple candidate positions; needs context to disambiguate
51
+ - `unmatched` – nothing maps; user must place the comment manually
52
+
53
+ Useful before `rev sync --comments-only` to plan which comments will land
54
+ automatically and which need manual placement.
55
+
56
+ ### rev build
57
+ Build output documents from markdown sections.
58
+ ```bash
59
+ rev build # Build PDF and DOCX
60
+ rev build pdf # PDF only
61
+ rev build docx # DOCX only
62
+ rev build --toc # Include table of contents
63
+ rev build docx --dual # Clean + annotated versions
64
+ rev build docx --show-changes # DOCX with visible track changes (audit)
65
+ rev build docx --dual --show-changes # One DOCX: tracked changes + threaded comments
66
+ rev build docx --pandoc-arg=--lua-filter=tofill.lua # Pass extra args to pandoc
67
+ rev build -o Final_Report # Override output filename (extension auto-added)
68
+ rev build pdf --verbose # Echo the pandoc invocation (useful for filter debugging)
69
+ ```
70
+
71
+ By default, outputs land in `output/` next to `rev.yaml`. Override or
72
+ disable via the `outputDir` field in rev.yaml (see below).
73
+
74
+ #### Choosing output filenames
75
+
76
+ By default, the output basename is derived from `title:` (slugified — e.g.
77
+ "My Paper" `my-paper.docx`). Long titles are truncated at word boundaries
78
+ (at the last `-` at-or-before 80 chars), so `communities` stays whole instead
79
+ of becoming `communitie`.
80
+
81
+ To pick your own filename, set per-format names in `rev.yaml`:
82
+
83
+ ```yaml
84
+ output:
85
+ docx: ADAPT_proposal_draft.docx
86
+ pdf: ADAPT_proposal_draft.pdf
87
+ ```
88
+
89
+ Extensions are optional `ADAPT_proposal_draft` is fine, the right extension
90
+ is added per format. Relative paths resolve under `outputDir`; absolute paths
91
+ bypass `outputDir`.
92
+
93
+ Or override on the command line with `-o, --output <path>`:
94
+
95
+ ```bash
96
+ rev build docx -o Final_Report # output/Final_Report.docx
97
+ rev build pdf docx -o Final_Report # Applies to both formats
98
+ rev build -o /tmp/draft.docx docx # Absolute path bypasses outputDir
99
+ ```
100
+
101
+ CLI `-o` wins over `output:` in `rev.yaml`. When `--dual` is on, the
102
+ `_comments` variant piggybacks on the chosen name (e.g.
103
+ `Final_Report_comments.docx`). When `--show-changes` is on, the audit DOCX
104
+ uses the chosen name with a `-changes` suffix
105
+ (e.g. `Final_Report-changes.docx`).
106
+
107
+ #### Passing custom pandoc args
108
+
109
+ For pandoc flags rev doesn't surface directly (Lua/JSON filters, custom
110
+ templates, variables, etc.), use the repeatable `--pandoc-arg` flag or the
111
+ `pandoc-args` field in `rev.yaml`:
112
+
113
+ ```yaml
114
+ # rev.yaml — applies to every format
115
+ pandoc-args:
116
+ - --lua-filter=tofill.lua
117
+ - --shift-heading-level-by=1
118
+
119
+ # Format-specific (concatenated after the top-level list)
120
+ docx:
121
+ pandoc-args:
122
+ - --lua-filter=docx_only.lua
123
+ pdf:
124
+ pandoc-args:
125
+ - --variable=papersize:a4
126
+ ```
127
+
128
+ ```bash
129
+ # CLI overrides appended last, so pandoc's last-wins rule lets CLI flags
130
+ # beat repeated config flags
131
+ rev build docx --pandoc-arg=--lua-filter=cli.lua --pandoc-arg=--metadata=draft:true
132
+ ```
133
+
134
+ Run with `--verbose` to print the full pandoc command line (one per format).
135
+ Copy-paste it into a terminal to reproduce a build manually.
136
+
137
+ The `--dual` flag produces:
138
+ - `output/<title>.docx` — clean, for submission
139
+ - `output/<title>_comments.docx` — includes comment threads as Word comments
140
+
141
+ The `--show-changes` flag (DOCX only) produces a single audit document
142
+ (`output/<title>-changes.docx`) where every insertion/deletion/substitution is
143
+ exported as a visible Word track change, attributed to the configured user.
144
+ Useful when a co-author wants to see what changed since the last shared
145
+ version. The revisions are emitted by pandoc as native run-level `w:ins`/`w:del`
146
+ elements through the full filter chain (crossref, citeproc, reference-doc,
147
+ macros) — not post-processed markers.
148
+
149
+ Combine `--dual --show-changes` to get one `output/<title>-changes.docx` with
150
+ tracked changes AND threaded comments: your `{++..++}`/`{--..--}` edits as
151
+ track changes alongside the reviewer's `{>>..<<}` comments and your threaded
152
+ replies. This is the standard "return to senior author" artifact. Add
153
+ `--reference <docx>` to realign comment anchors against a reviewer's copy
154
+ before injecting.
155
+
156
+ ### rev preview
157
+ Build and open document in default app.
158
+ ```bash
159
+ rev preview pdf # Build and open PDF
160
+ rev preview docx # Build and open Word
161
+ ```
162
+
163
+ ### rev export
164
+ Export project as distributable zip.
165
+ ```bash
166
+ rev export # Creates project.zip (no node_modules)
167
+ ```
168
+
169
+ ### rev backup
170
+ Create timestamped project backup.
171
+ ```bash
172
+ rev backup # Creates backup-2024-12-29.zip
173
+ rev backup --name v1-draft # Creates v1-draft.zip
174
+ ```
175
+
176
+ ## Comments & Annotations
177
+
178
+ ### rev comments
179
+ List all comments with context.
180
+ ```bash
181
+ rev comments methods.md # Show comments
182
+ rev comments methods.md --export out.csv # Export to CSV
183
+ ```
184
+
185
+ ### rev reply
186
+ Reply to a specific comment (non-interactive).
187
+ ```bash
188
+ rev reply methods.md -n 1 -m "Added clarification"
189
+ rev reply results.md -n 3 -m "Updated figure"
190
+ ```
191
+
192
+ ### rev resolve
193
+ Mark a comment as resolved.
194
+ ```bash
195
+ rev resolve methods.md -n 1
196
+ rev resolve methods.md -n 1,2,3 # Multiple comments
197
+ ```
198
+
199
+ ### rev status
200
+ Show project overview or annotation counts for a file.
201
+ ```bash
202
+ rev status # Project overview (words, comments, changes)
203
+ rev status methods.md # Specific file annotations
204
+ ```
205
+
206
+ ### rev next / rev prev
207
+ Navigate pending comments.
208
+ ```bash
209
+ rev next # Show next pending comment
210
+ rev next -n 3 # Show 3rd pending comment
211
+ rev prev # Show last pending comment
212
+ rev first methods # First comment in methods section
213
+ rev last # Last comment overall
214
+ ```
215
+
216
+ ### rev todo
217
+ List all pending comments as a checklist.
218
+ ```bash
219
+ rev todo # List all pending
220
+ rev todo --by-author # Group by author
221
+ ```
222
+
223
+ ### rev accept / rev reject
224
+ Accept or reject track changes.
225
+ ```bash
226
+ rev accept methods.md # List all changes
227
+ rev accept methods.md -n 1 # Accept change #1
228
+ rev accept methods.md -a # Accept all
229
+ rev reject methods.md -n 2 # Reject change #2
230
+ ```
231
+
232
+ ### rev archive
233
+ Archive reviewer .docx files.
234
+ ```bash
235
+ rev archive # Move all .docx to archive/
236
+ rev archive --by Smith # Specify reviewer name
237
+ rev archive --dry-run # Preview without moving
238
+ ```
239
+
240
+ ### rev strip
241
+ Remove all annotations from markdown.
242
+ ```bash
243
+ rev strip methods.md --output clean.md
244
+ rev strip methods.md --accept # Accept all changes
245
+ rev strip methods.md --reject # Reject all changes
246
+ ```
247
+
248
+ ## Response Letter
249
+
250
+ ### rev response
251
+ Generate point-by-point response letter from comments.
252
+ ```bash
253
+ rev response # Generate response letter
254
+ ```
255
+
256
+ ## Validation & Checks
257
+
258
+ ### rev check
259
+ Run all pre-submission checks (lint + grammar + citations).
260
+ ```bash
261
+ rev check # Run all checks
262
+ rev check --fix # Auto-fix where possible
263
+ ```
264
+
265
+ ### rev lint
266
+ Check for common issues.
267
+ ```bash
268
+ rev lint # Run all checks
269
+ rev lint --fix # Auto-fix where possible
270
+ ```
271
+ Checks: broken cross-references, missing citations, orphaned figures, unresolved comments.
272
+
273
+ ### rev grammar
274
+ Check grammar and style.
275
+ ```bash
276
+ rev grammar # Check all sections
277
+ rev grammar --rules # List available rules
278
+ rev grammar --learn word # Add to custom dictionary
279
+ rev grammar --forget word # Remove from dictionary
280
+ rev grammar --list # Show custom dictionary
281
+ rev grammar -s warning # Filter by severity
282
+ ```
283
+
284
+ ### rev spelling
285
+ Check spelling in all sections.
286
+ ```bash
287
+ rev spelling # Check all sections
288
+ rev spelling --british # Use British English dictionary
289
+ rev spelling --learn word # Add to global dictionary (~/.rev-dictionary)
290
+ rev spelling --learn-project word # Add to project dictionary
291
+ rev spelling --forget word # Remove from global dictionary
292
+ rev spelling --list # Show global dictionary
293
+ rev spelling --list-all # Show global + project dictionaries
294
+ ```
295
+ Built-in scientific vocabulary reduces false positives. Possible author names are shown separately for easy review.
296
+
297
+ ### rev validate
298
+ Check against journal requirements.
299
+ ```bash
300
+ rev validate --journal nature
301
+ rev validate --list # List 22 available journals
302
+ ```
303
+
304
+ ### rev citations
305
+ Validate citations against bibliography.
306
+ ```bash
307
+ rev citations
308
+ ```
309
+
310
+ ## DOI Management
311
+
312
+ ### rev doi check
313
+ Validate DOIs in bibliography.
314
+ ```bash
315
+ rev doi check references.bib
316
+ rev doi check references.bib --strict # Fail if articles missing DOIs
317
+ ```
318
+
319
+ ### rev doi lookup
320
+ Find missing DOIs by title/author/year.
321
+ ```bash
322
+ rev doi lookup references.bib
323
+ rev doi lookup references.bib --confidence high
324
+ ```
325
+
326
+ ### rev doi fetch
327
+ Get BibTeX from a DOI.
328
+ ```bash
329
+ rev doi fetch 10.1234/example
330
+ ```
331
+
332
+ ### rev doi add
333
+ Add citation to .bib file from DOI.
334
+ ```bash
335
+ rev doi add 10.1234/example
336
+ rev doi add 10.1234/example --file references.bib
337
+ ```
338
+
339
+ ## Content Analysis
340
+
341
+ ### rev word-count
342
+ Show word counts per section.
343
+ ```bash
344
+ rev word-count # Per-section counts
345
+ rev word-count --limit 5000 # Warn if over limit
346
+ rev word-count -j nature # Use journal word limit
347
+ ```
348
+
349
+ ### rev stats
350
+ Project dashboard showing overview.
351
+ ```bash
352
+ rev stats # Words, figures, citations, comments
353
+ ```
354
+
355
+ ### rev search
356
+ Search across all section files.
357
+ ```bash
358
+ rev search "climate change"
359
+ rev search -i "method" # Case-insensitive
360
+ ```
361
+
362
+ ### rev figures
363
+ List figures with reference counts.
364
+ ```bash
365
+ rev figures methods.md
366
+ ```
367
+
368
+ ### rev equations
369
+ Work with LaTeX equations.
370
+ ```bash
371
+ rev equations list # List all equations
372
+ rev equations from-word manuscript.docx # Extract from Word
373
+ ```
374
+
375
+ ## Direct DOCX Editing (Layout Workflow)
376
+
377
+ ### rev annotate
378
+ Add comments directly to Word document.
379
+ ```bash
380
+ rev annotate paper.docx -m "Comment" -s "text to find"
381
+ ```
382
+
383
+ ### rev apply
384
+ Apply MD annotations as Word track changes.
385
+ ```bash
386
+ rev apply paper.md output.docx
387
+ ```
388
+
389
+ ### rev comment
390
+ Interactive comment mode for Word documents.
391
+ ```bash
392
+ rev comment paper.docx
393
+ ```
394
+
395
+ ## Project Management
396
+
397
+ ### rev clean
398
+ Remove generated files.
399
+ ```bash
400
+ rev clean # Remove paper.md, PDFs, DOCXs
401
+ rev clean --dry-run # Show what would be deleted
402
+ rev clean --all # Also remove backups and exports
403
+ ```
404
+
405
+ ### rev open
406
+ Open project folder or file.
407
+ ```bash
408
+ rev open # Open project folder
409
+ rev open paper.pdf # Open specific file
410
+ ```
411
+
412
+ ### rev watch
413
+ Auto-rebuild on file changes.
414
+ ```bash
415
+ rev watch # Watch and rebuild
416
+ rev watch pdf # Only rebuild PDF
417
+ rev watch --no-open # Don't open after build
418
+ ```
419
+
420
+ ## Configuration
421
+
422
+ ### rev config
423
+ Configure user settings.
424
+ ```bash
425
+ rev config user "Your Name" # Set author name for replies
426
+ rev config # Show current config
427
+ ```
428
+
429
+ ## rev.yaml Settings
430
+
431
+ ### Output Directory
432
+
433
+ By default, built artefacts land in `output/` next to `rev.yaml`. Both the
434
+ clean output and `--dual` companion (`*_comments.docx` / `*_comments.pdf`)
435
+ follow the configured location. Override or disable:
436
+
437
+ ```yaml
438
+ outputDir: output # default outputs land in ./output/
439
+ outputDir: dist # custom subdirectory
440
+ outputDir: null # legacy layout — outputs alongside paper.md
441
+ ```
442
+
443
+ Explicit caller-supplied output paths (e.g. internal temp files in the
444
+ dual flow) bypass `outputDir`.
445
+
446
+ ### PDF Engine and Fonts
447
+
448
+ The default PDF engine is `pdflatex`. Switch to xelatex/lualatex when the
449
+ manuscript needs native UTF-8 rendering of Latin-Extended diacritics
450
+ (Czech/Polish/Croatian/Spanish author names, species epithets):
451
+
452
+ ```yaml
453
+ pdf:
454
+ engine: xelatex # or lualatex, tectonic, etc.
455
+ mainfont: "TeX Gyre Termes" # serif (xelatex/lualatex only — uses fontspec)
456
+ sansfont: "TeX Gyre Heros" # sans (optional)
457
+ monofont: "TeX Gyre Cursor" # monospace (optional)
458
+ ```
459
+
460
+ `mainfont`/`sansfont`/`monofont` are forwarded as pandoc `-V` flags and
461
+ require an engine that loads `fontspec` (xelatex or lualatex). They are
462
+ ignored under `pdflatex`.
463
+
464
+ ### Tables
465
+
466
+ Configure table formatting for PDF output:
467
+
468
+ ```yaml
469
+ tables:
470
+ nowrap:
471
+ - Prior # Column headers to keep on one line
472
+ - "$\\widehat{R}$"
473
+ ```
474
+
475
+ In `nowrap` columns, distribution notation is auto-converted to LaTeX math:
476
+ - `Normal(0, 0.5)` → `$\mathcal{N}(0, 0.5)$`
477
+ - `Student-t(3, 0, 1)` → `$t_3(0, 1)$`
478
+ - `Gamma(2, 0.5)` → `$\text{Gamma}(2, 0.5)$`
479
+ - `Half-Normal(0, 1)` → `$\text{Half-Normal}(0, 1)$`
480
+ - `Exponential(1)` → `$\text{Exp}(1)$`
481
+
482
+ **Tip:** For complex tables, use simple tables (space-aligned with dashes) instead of pipe tables to avoid column width issues:
483
+
484
+ ```markdown
485
+ Parameter Prior Description
486
+ ---------- ------------------------- ------------------
487
+ alpha $\mathcal{N}(0, 0.5)$ Intercept prior
488
+ beta $t_3(0, 2.5)$ Slope prior
489
+ ```
490
+
491
+ ### Postprocess Scripts
492
+
493
+ Run custom scripts after output generation:
494
+
495
+ ```yaml
496
+ postprocess:
497
+ pdf: ./scripts/fix-pdf.py # Runs after PDF
498
+ docx: ./scripts/add-meta.js # Runs after DOCX
499
+ tex: ./scripts/tweak-latex.sh # Runs after TEX
500
+ pptx: ./scripts/fix-slides.ps1 # Runs after PPTX
501
+ all: ./scripts/notify.js # Runs after ANY format
502
+ ```
503
+
504
+ **Environment variables** available to scripts:
505
+
506
+ | Variable | Description |
507
+ |----------|-------------|
508
+ | `OUTPUT_FILE` | Full path to generated file |
509
+ | `OUTPUT_FORMAT` | Format: `pdf`, `docx`, `tex`, `pptx`, `beamer` |
510
+ | `PROJECT_DIR` | Directory containing rev.yaml |
511
+ | `CONFIG_PATH` | Full path to rev.yaml |
512
+
513
+ **Supported script types:** `.js`, `.mjs` (Node), `.py` (Python), `.ps1` (PowerShell), `.sh` (Bash)
514
+
515
+ **Example Python script** (add DOCX metadata):
516
+ ```python
517
+ import os
518
+ from docx import Document
519
+ doc = Document(os.environ['OUTPUT_FILE'])
520
+ doc.core_properties.author = "Research Team"
521
+ doc.save(os.environ['OUTPUT_FILE'])
522
+ ```
523
+
524
+ Use `--verbose` flag to see script output:
525
+ ```bash
526
+ rev build pdf --verbose
527
+ ```
528
+
529
+ ## Shell Completions
530
+
531
+ ### rev completions
532
+ Output shell completions.
533
+ ```bash
534
+ eval "$(rev completions bash)" # Bash
535
+ eval "$(rev completions zsh)" # Zsh
536
+ ```
537
+
538
+ ## AI Skill Installation
539
+
540
+ ### rev install-cli-skill
541
+ Install the docrev skill for AI coding assistants.
542
+ ```bash
543
+ rev install-cli-skill # Install to ~/.claude/skills/docrev
544
+ ```
545
+
546
+ ### rev uninstall-cli-skill
547
+ Remove the installed skill.
548
+ ```bash
549
+ rev uninstall-cli-skill
550
+ ```