docrev 0.9.11 → 0.9.14

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 (138) hide show
  1. package/.claude/settings.local.json +9 -9
  2. package/.gitattributes +1 -1
  3. package/CHANGELOG.md +149 -149
  4. package/PLAN-tables-and-postprocess.md +850 -850
  5. package/README.md +391 -391
  6. package/bin/rev.js +11 -11
  7. package/bin/rev.ts +145 -145
  8. package/completions/rev.bash +127 -127
  9. package/completions/rev.ps1 +210 -210
  10. package/completions/rev.zsh +207 -207
  11. package/dev_notes/stress2/build_adversarial.ts +186 -186
  12. package/dev_notes/stress2/drift_matcher.ts +62 -62
  13. package/dev_notes/stress2/probe_anchors.ts +35 -35
  14. package/dev_notes/stress2/project/discussion.before.md +3 -3
  15. package/dev_notes/stress2/project/discussion.md +3 -3
  16. package/dev_notes/stress2/project/methods.before.md +20 -20
  17. package/dev_notes/stress2/project/methods.md +20 -20
  18. package/dev_notes/stress2/project/rev.yaml +5 -5
  19. package/dev_notes/stress2/project/sections.yaml +4 -4
  20. package/dev_notes/stress2/sections.yaml +5 -5
  21. package/dev_notes/stress2/trace_placement.ts +50 -50
  22. package/dev_notes/stresstest_boundaries.ts +27 -27
  23. package/dev_notes/stresstest_drift_apply.ts +43 -43
  24. package/dev_notes/stresstest_drift_compare.ts +43 -43
  25. package/dev_notes/stresstest_drift_v2.ts +54 -54
  26. package/dev_notes/stresstest_inspect.ts +54 -54
  27. package/dev_notes/stresstest_pstyle.ts +55 -55
  28. package/dev_notes/stresstest_section_debug.ts +23 -23
  29. package/dev_notes/stresstest_split.ts +70 -70
  30. package/dev_notes/stresstest_trace.ts +19 -19
  31. package/dev_notes/stresstest_verify_no_overwrite.ts +40 -40
  32. package/dist/lib/build.d.ts +50 -1
  33. package/dist/lib/build.d.ts.map +1 -1
  34. package/dist/lib/build.js +80 -30
  35. package/dist/lib/build.js.map +1 -1
  36. package/dist/lib/commands/build.d.ts.map +1 -1
  37. package/dist/lib/commands/build.js +38 -5
  38. package/dist/lib/commands/build.js.map +1 -1
  39. package/dist/lib/commands/utilities.js +164 -164
  40. package/dist/lib/commands/word-tools.js +8 -8
  41. package/dist/lib/grammar.js +3 -3
  42. package/dist/lib/import.d.ts.map +1 -1
  43. package/dist/lib/import.js +146 -24
  44. package/dist/lib/import.js.map +1 -1
  45. package/dist/lib/pdf-comments.js +44 -44
  46. package/dist/lib/plugins.js +57 -57
  47. package/dist/lib/pptx-themes.js +115 -115
  48. package/dist/lib/spelling.js +2 -2
  49. package/dist/lib/templates.js +387 -387
  50. package/dist/lib/themes.js +51 -51
  51. package/dist/lib/types.d.ts +20 -0
  52. package/dist/lib/types.d.ts.map +1 -1
  53. package/dist/lib/word-extraction.d.ts +6 -0
  54. package/dist/lib/word-extraction.d.ts.map +1 -1
  55. package/dist/lib/word-extraction.js +46 -3
  56. package/dist/lib/word-extraction.js.map +1 -1
  57. package/dist/lib/wordcomments.d.ts.map +1 -1
  58. package/dist/lib/wordcomments.js +23 -5
  59. package/dist/lib/wordcomments.js.map +1 -1
  60. package/eslint.config.js +27 -27
  61. package/lib/anchor-match.ts +276 -276
  62. package/lib/annotations.ts +644 -644
  63. package/lib/build.ts +1300 -1227
  64. package/lib/citations.ts +160 -160
  65. package/lib/commands/build.ts +833 -801
  66. package/lib/commands/citations.ts +515 -515
  67. package/lib/commands/comments.ts +1050 -1050
  68. package/lib/commands/context.ts +174 -174
  69. package/lib/commands/core.ts +309 -309
  70. package/lib/commands/doi.ts +435 -435
  71. package/lib/commands/file-ops.ts +372 -372
  72. package/lib/commands/history.ts +320 -320
  73. package/lib/commands/index.ts +87 -87
  74. package/lib/commands/init.ts +259 -259
  75. package/lib/commands/merge-resolve.ts +378 -378
  76. package/lib/commands/preview.ts +178 -178
  77. package/lib/commands/project-info.ts +244 -244
  78. package/lib/commands/quality.ts +517 -517
  79. package/lib/commands/response.ts +454 -454
  80. package/lib/commands/section-boundaries.ts +82 -82
  81. package/lib/commands/sections.ts +451 -451
  82. package/lib/commands/sync.ts +706 -706
  83. package/lib/commands/text-ops.ts +449 -449
  84. package/lib/commands/utilities.ts +448 -448
  85. package/lib/commands/verify-anchors.ts +272 -272
  86. package/lib/commands/word-tools.ts +340 -340
  87. package/lib/comment-realign.ts +517 -517
  88. package/lib/config.ts +84 -84
  89. package/lib/crossref.ts +781 -781
  90. package/lib/csl.ts +191 -191
  91. package/lib/dependencies.ts +98 -98
  92. package/lib/diff-engine.ts +465 -465
  93. package/lib/doi-cache.ts +115 -115
  94. package/lib/doi.ts +897 -897
  95. package/lib/equations.ts +506 -506
  96. package/lib/errors.ts +346 -346
  97. package/lib/format.ts +541 -541
  98. package/lib/git.ts +326 -326
  99. package/lib/grammar.ts +303 -303
  100. package/lib/image-registry.ts +180 -180
  101. package/lib/import.ts +911 -792
  102. package/lib/journals.ts +543 -543
  103. package/lib/merge.ts +633 -633
  104. package/lib/orcid.ts +144 -144
  105. package/lib/pdf-comments.ts +263 -263
  106. package/lib/pdf-import.ts +524 -524
  107. package/lib/plugins.ts +362 -362
  108. package/lib/postprocess.ts +188 -188
  109. package/lib/pptx-color-filter.lua +37 -37
  110. package/lib/pptx-template.ts +469 -469
  111. package/lib/pptx-themes.ts +483 -483
  112. package/lib/protect-restore.ts +520 -520
  113. package/lib/rate-limiter.ts +94 -94
  114. package/lib/response.ts +197 -197
  115. package/lib/restore-references.ts +240 -240
  116. package/lib/review.ts +327 -327
  117. package/lib/schema.ts +417 -417
  118. package/lib/scientific-words.ts +73 -73
  119. package/lib/sections.ts +335 -335
  120. package/lib/slides.ts +756 -756
  121. package/lib/spelling.ts +334 -334
  122. package/lib/templates.ts +526 -526
  123. package/lib/themes.ts +742 -742
  124. package/lib/trackchanges.ts +247 -247
  125. package/lib/tui.ts +450 -450
  126. package/lib/types.ts +550 -530
  127. package/lib/undo.ts +250 -250
  128. package/lib/utils.ts +69 -69
  129. package/lib/variables.ts +179 -179
  130. package/lib/word-extraction.ts +806 -759
  131. package/lib/word.ts +643 -643
  132. package/lib/wordcomments.ts +817 -798
  133. package/package.json +137 -137
  134. package/scripts/postbuild.js +28 -28
  135. package/skill/REFERENCE.md +431 -431
  136. package/skill/SKILL.md +258 -258
  137. package/tsconfig.json +26 -26
  138. package/types/index.d.ts +525 -525
package/types/index.d.ts CHANGED
@@ -1,525 +1,525 @@
1
- /**
2
- * TypeScript type definitions for docrev
3
- */
4
-
5
- // ============================================
6
- // Annotations (lib/annotations.js)
7
- // ============================================
8
-
9
- export interface Annotation {
10
- type: 'insert' | 'delete' | 'substitute' | 'comment' | 'highlight';
11
- match: string;
12
- content: string;
13
- replacement?: string;
14
- author?: string;
15
- position: number;
16
- line: number;
17
- before?: string;
18
- after?: string;
19
- }
20
-
21
- export interface Comment extends Annotation {
22
- type: 'comment';
23
- author: string;
24
- resolved: boolean;
25
- }
26
-
27
- export interface AnnotationCounts {
28
- inserts: number;
29
- deletes: number;
30
- substitutes: number;
31
- comments: number;
32
- total: number;
33
- }
34
-
35
- export interface StripOptions {
36
- keepComments?: boolean;
37
- }
38
-
39
- export interface CommentFilterOptions {
40
- pendingOnly?: boolean;
41
- resolvedOnly?: boolean;
42
- }
43
-
44
- export function parseAnnotations(text: string): Annotation[];
45
- export function stripAnnotations(text: string, options?: StripOptions): string;
46
- export function applyDecision(text: string, annotation: Annotation, accept: boolean): string;
47
- export function getTrackChanges(text: string): Annotation[];
48
- export function getComments(text: string, options?: CommentFilterOptions): Comment[];
49
- export function setCommentStatus(text: string, comment: Comment, resolved: boolean): string;
50
- export function countAnnotations(text: string): AnnotationCounts;
51
-
52
- // ============================================
53
- // Build (lib/build.js)
54
- // ============================================
55
-
56
- export interface BuildConfig {
57
- title?: string;
58
- authors?: Author[];
59
- sections?: string[];
60
- bibliography?: string;
61
- csl?: string;
62
- crossref?: CrossrefConfig;
63
- pdf?: PdfConfig;
64
- docx?: DocxConfig;
65
- }
66
-
67
- export interface Author {
68
- name: string;
69
- affiliation?: string;
70
- email?: string;
71
- orcid?: string;
72
- }
73
-
74
- export interface CrossrefConfig {
75
- figureTitle?: string;
76
- tableTitle?: string;
77
- figPrefix?: string | string[];
78
- tblPrefix?: string | string[];
79
- }
80
-
81
- export interface PdfConfig {
82
- documentclass?: string;
83
- fontsize?: string;
84
- geometry?: string;
85
- linestretch?: number;
86
- toc?: boolean;
87
- }
88
-
89
- export interface DocxConfig {
90
- reference?: string;
91
- keepComments?: boolean;
92
- toc?: boolean;
93
- }
94
-
95
- export interface BuildResult {
96
- format: string;
97
- output: string;
98
- success: boolean;
99
- error?: string;
100
- }
101
-
102
- export function loadConfig(directory?: string): BuildConfig;
103
- export function findSections(directory: string, config: BuildConfig): string[];
104
- export function combineSections(files: string[], options?: object): string;
105
- export function build(formats?: string[], options?: object): Promise<BuildResult[]>;
106
- export function hasPandoc(): Promise<boolean>;
107
- export function hasPandocCrossref(): Promise<boolean>;
108
-
109
- // ============================================
110
- // Citations (lib/citations.js)
111
- // ============================================
112
-
113
- export interface Citation {
114
- key: string;
115
- line: number;
116
- file: string;
117
- }
118
-
119
- export interface CitationValidation {
120
- valid: Citation[];
121
- missing: Citation[];
122
- unused: string[];
123
- duplicates: Array<{ key: string; count: number; locations: Citation[] }>;
124
- }
125
-
126
- export interface CitationStats {
127
- totalCitations: number;
128
- uniqueCited: number;
129
- valid: number;
130
- missing: number;
131
- missingKeys: string[];
132
- bibEntries: number;
133
- unused: number;
134
- unusedKeys: string[];
135
- }
136
-
137
- export function extractCitations(text: string, file?: string): Citation[];
138
- export function parseBibFile(bibPath: string): Set<string>;
139
- export function validateCitations(mdFiles: string[], bibPath: string): CitationValidation;
140
- export function getCitationStats(mdFiles: string[], bibPath: string): CitationStats;
141
-
142
- // ============================================
143
- // Crossref (lib/crossref.js)
144
- // ============================================
145
-
146
- export interface RefNumber {
147
- num: number;
148
- isSupp: boolean;
149
- suffix: string | null;
150
- }
151
-
152
- export interface HardcodedRef {
153
- type: 'fig' | 'tbl' | 'eq';
154
- match: string;
155
- numbers: RefNumber[];
156
- position: number;
157
- }
158
-
159
- export interface DynamicRef {
160
- type: 'fig' | 'tbl' | 'eq';
161
- label: string;
162
- match: string;
163
- position: number;
164
- }
165
-
166
- export interface FigureInfo {
167
- label: string;
168
- num: number;
169
- isSupp: boolean;
170
- file: string;
171
- }
172
-
173
- export interface Registry {
174
- figures: Map<string, FigureInfo>;
175
- tables: Map<string, FigureInfo>;
176
- equations: Map<string, FigureInfo>;
177
- byNumber: {
178
- fig: Map<number, string>;
179
- figS: Map<number, string>;
180
- tbl: Map<number, string>;
181
- tblS: Map<number, string>;
182
- eq: Map<number, string>;
183
- };
184
- }
185
-
186
- export interface RefStatus {
187
- dynamic: DynamicRef[];
188
- hardcoded: HardcodedRef[];
189
- anchors: { figures: number; tables: number; equations: number };
190
- }
191
-
192
- export function normalizeType(typeStr: string): 'fig' | 'tbl' | 'eq' | string;
193
- export function parseRefNumber(numStr: string, suffix?: string): RefNumber;
194
- export function parseReferenceList(listStr: string): RefNumber[];
195
- export function buildRegistry(directory: string, excludeFiles?: string[]): Registry;
196
- export function labelToDisplay(type: string, label: string, registry: Registry): string | null;
197
- export function numberToLabel(type: string, num: number, isSupp: boolean, registry: Registry): string | null;
198
- export function detectHardcodedRefs(text: string): HardcodedRef[];
199
- export function detectDynamicRefs(text: string): DynamicRef[];
200
- export function convertHardcodedRefs(text: string, registry: Registry): { converted: string; conversions: Array<{ from: string; to: string }>; warnings: string[] };
201
- export function getRefStatus(text: string, registry: Registry): RefStatus;
202
-
203
- // ============================================
204
- // DOI (lib/doi.js)
205
- // ============================================
206
-
207
- export interface BibEntry {
208
- key: string;
209
- type: string;
210
- doi: string | null;
211
- title: string;
212
- authorRaw: string;
213
- year: number | null;
214
- journal: string;
215
- skip: boolean;
216
- expectDoi: boolean;
217
- noDoi: boolean;
218
- line: number;
219
- }
220
-
221
- export interface DoiCheckResult {
222
- valid: boolean;
223
- source?: 'crossref' | 'datacite';
224
- metadata?: {
225
- title: string;
226
- authors: string[];
227
- year: number;
228
- journal: string;
229
- type?: string;
230
- };
231
- error?: string;
232
- }
233
-
234
- export interface BibtexFetchResult {
235
- success: boolean;
236
- bibtex?: string;
237
- error?: string;
238
- }
239
-
240
- export interface DoiLookupResult {
241
- found: boolean;
242
- doi?: string;
243
- confidence?: 'low' | 'medium' | 'high';
244
- score?: number;
245
- metadata?: {
246
- title: string;
247
- authors: string[];
248
- year: number;
249
- journal: string;
250
- };
251
- alternatives?: Array<{
252
- doi: string;
253
- title: string;
254
- score: number;
255
- }>;
256
- error?: string;
257
- }
258
-
259
- export interface BibCheckResult {
260
- entries: Array<BibEntry & { status: string; message?: string; metadata?: object }>;
261
- valid: number;
262
- invalid: number;
263
- missing: number;
264
- skipped: number;
265
- }
266
-
267
- export function parseBibEntries(bibPath: string): BibEntry[];
268
- export function isValidDoiFormat(doi: string): boolean;
269
- export function checkDoi(doi: string): Promise<DoiCheckResult>;
270
- export function fetchBibtex(doi: string): Promise<BibtexFetchResult>;
271
- export function checkBibDois(bibPath: string, options?: { checkMissing?: boolean; parallel?: number }): Promise<BibCheckResult>;
272
- export function lookupDoi(title: string, author?: string, year?: number, journal?: string): Promise<DoiLookupResult>;
273
- export function lookupMissingDois(bibPath: string, options?: { parallel?: number; onProgress?: (current: number, total: number) => void }): Promise<Array<{ key: string; title: string; type: string; journal: string; result: DoiLookupResult }>>;
274
- export function addToBib(bibPath: string, bibtex: string): { success: boolean; key?: string; error?: string };
275
-
276
- // ============================================
277
- // Equations (lib/equations.js)
278
- // ============================================
279
-
280
- export interface Equation {
281
- type: 'inline' | 'display';
282
- content: string;
283
- line: number;
284
- file: string;
285
- }
286
-
287
- export interface EquationStats {
288
- total: number;
289
- display: number;
290
- inline: number;
291
- byFile: Array<{ file: string; display: number; inline: number }>;
292
- }
293
-
294
- export interface WordEquationResult {
295
- success: boolean;
296
- equations: Array<{
297
- type: 'inline' | 'display' | 'unknown';
298
- latex: string | null;
299
- position: number;
300
- line?: number;
301
- raw?: string;
302
- error?: string;
303
- }>;
304
- error?: string;
305
- }
306
-
307
- export function extractEquations(text: string, file?: string): Equation[];
308
- export function generateEquationSheet(equations: Equation[]): string;
309
- export function convertToWord(inputPath: string, outputPath: string, options?: { preserveLatex?: boolean }): Promise<{ success: boolean; message: string }>;
310
- export function createEquationsDoc(inputPath: string, outputPath: string): Promise<{ success: boolean; message: string; stats: { display: number; inline: number } | null }>;
311
- export function getEquationStats(files: string[]): EquationStats;
312
- export function extractEquationsFromWord(docxPath: string): Promise<WordEquationResult>;
313
- export function getWordEquationStats(docxPath: string): Promise<{ count: number; display: number; inline: number; converted: number; error?: string }>;
314
-
315
- // ============================================
316
- // Git (lib/git.js)
317
- // ============================================
318
-
319
- export interface FileChange {
320
- added: number;
321
- removed: number;
322
- changes: Array<{ added: boolean; removed: boolean; value: string }>;
323
- }
324
-
325
- export interface CommitInfo {
326
- hash: string;
327
- date: string;
328
- author: string;
329
- message: string;
330
- }
331
-
332
- export function isGitRepo(directory?: string): boolean;
333
- export function getCurrentBranch(directory?: string): string | null;
334
- export function getDefaultBranch(directory?: string): string;
335
- export function getFileAtRef(filePath: string, ref: string): string | null;
336
- export function getChangedFiles(fromRef: string, toRef?: string): string[];
337
- export function getFileHistory(filePath: string, limit?: number): CommitInfo[];
338
- export function compareFileVersions(filePath: string, fromRef: string, toRef?: string): FileChange;
339
- export function getWordCountDiff(filePath: string, fromRef: string, toRef?: string): { before: number; after: number; diff: number };
340
- export function getRecentCommits(directory?: string, limit?: number): CommitInfo[];
341
- export function hasUncommittedChanges(directory?: string): boolean;
342
- export function getTags(directory?: string): string[];
343
-
344
- // ============================================
345
- // Journals (lib/journals.js)
346
- // ============================================
347
-
348
- export interface JournalProfile {
349
- name: string;
350
- url: string;
351
- requirements: {
352
- wordLimit?: { main: number; abstract?: number };
353
- references?: { max?: number; doiRequired?: boolean };
354
- figures?: { max?: number };
355
- tables?: { max?: number };
356
- sections?: string[];
357
- formatting?: object;
358
- };
359
- }
360
-
361
- export interface ValidationResult {
362
- journal: string;
363
- valid: boolean;
364
- wordCount: { main: number; abstract: number; limit: { main: number; abstract: number } };
365
- figures: { count: number; max: number };
366
- tables: { count: number; max: number };
367
- references: { count: number; max: number };
368
- sections: { found: string[]; missing: string[]; required: string[] };
369
- errors: string[];
370
- warnings: string[];
371
- }
372
-
373
- export function listJournals(): Array<{ id: string; name: string; url: string }>;
374
- export function getJournalProfile(journalId: string): JournalProfile | null;
375
- export function validateManuscript(text: string, journalId: string, options?: { bibPath?: string }): ValidationResult;
376
- export function validateProject(directory: string, journalId: string): Promise<ValidationResult>;
377
-
378
- // ============================================
379
- // Merge (lib/merge.js)
380
- // ============================================
381
-
382
- export interface ReviewerChange {
383
- reviewer: string;
384
- type: 'insert' | 'delete' | 'replace';
385
- start: number;
386
- end: number;
387
- oldText: string;
388
- newText: string;
389
- }
390
-
391
- export interface Conflict {
392
- start: number;
393
- end: number;
394
- original: string;
395
- changes: ReviewerChange[];
396
- }
397
-
398
- export interface MergeResult {
399
- merged: string;
400
- conflicts: Conflict[];
401
- stats: {
402
- reviewers: number;
403
- totalChanges: number;
404
- nonConflicting: number;
405
- conflicts: number;
406
- comments: number;
407
- };
408
- originalText: string;
409
- }
410
-
411
- export function extractChanges(originalText: string, wordText: string, reviewer: string): ReviewerChange[];
412
- export function detectConflicts(allChanges: ReviewerChange[][]): { conflicts: Conflict[]; nonConflicting: ReviewerChange[] };
413
- export function applyChanges(originalText: string, changes: ReviewerChange[]): string;
414
- export function applyChangesAsAnnotations(originalText: string, changes: ReviewerChange[]): string;
415
- export function formatConflict(conflict: Conflict, originalText: string): string;
416
- export function mergeReviewerDocs(originalPath: string, reviewerDocs: Array<{ path: string; name: string }>, options?: { autoResolve?: boolean }): Promise<MergeResult>;
417
- export function resolveConflict(text: string, conflict: Conflict, choice: number, originalText: string): string;
418
-
419
- // ============================================
420
- // Sections (lib/sections.js)
421
- // ============================================
422
-
423
- export interface SectionConfig {
424
- header: string;
425
- aliases?: string[];
426
- order?: number;
427
- }
428
-
429
- export interface SectionsConfig {
430
- version: number;
431
- description?: string;
432
- sections: Record<string, SectionConfig>;
433
- }
434
-
435
- export interface ExtractedSection {
436
- file: string;
437
- header: string;
438
- content: string;
439
- matched: boolean;
440
- }
441
-
442
- export function extractHeader(filePath: string): string | null;
443
- export function generateConfig(directory: string, excludePatterns?: string[]): SectionsConfig;
444
- export function loadConfig(configPath: string): SectionsConfig;
445
- export function saveConfig(configPath: string, config: SectionsConfig): void;
446
- export function matchHeading(heading: string, sections: Record<string, SectionConfig>): { file: string; config: SectionConfig } | null;
447
- export function extractSectionsFromText(text: string, sections: Record<string, SectionConfig>): ExtractedSection[];
448
- export function splitAnnotatedPaper(paperContent: string, sections: Record<string, SectionConfig>): Map<string, string>;
449
- export function getOrderedSections(config: SectionsConfig): string[];
450
-
451
- // ============================================
452
- // Word (lib/word.js)
453
- // ============================================
454
-
455
- export interface WordComment {
456
- id: string;
457
- author: string;
458
- date: string;
459
- text: string;
460
- }
461
-
462
- export interface WordMetadata {
463
- title?: string;
464
- author?: string;
465
- created?: string;
466
- modified?: string;
467
- }
468
-
469
- export interface CommentAnchor {
470
- text: string;
471
- context: string;
472
- }
473
-
474
- export function extractWordComments(docxPath: string): Promise<WordComment[]>;
475
- export function extractCommentAnchors(docxPath: string): Promise<Map<string, CommentAnchor>>;
476
- export function extractTextFromWord(docxPath: string): Promise<string>;
477
- export function extractFromWord(docxPath: string): Promise<{ text: string; html: string }>;
478
- export function getWordMetadata(docxPath: string): Promise<WordMetadata>;
479
- export function isWordDocument(filePath: string): boolean;
480
-
481
- // ============================================
482
- // TrackChanges (lib/trackchanges.js)
483
- // ============================================
484
-
485
- export interface TrackChangeMarker {
486
- type: 'insert' | 'delete';
487
- start: number;
488
- end: number;
489
- content: string;
490
- }
491
-
492
- export function prepareForTrackChanges(text: string): { text: string; markers: TrackChangeMarker[] };
493
- export function applyTrackChangesToDocx(docxPath: string, markers: TrackChangeMarker[], author?: string): Promise<void>;
494
- export function buildWithTrackChanges(markdownPath: string, outputPath: string, options?: object): Promise<{ success: boolean; message: string }>;
495
-
496
- // ============================================
497
- // Spelling (lib/spelling.js)
498
- // ============================================
499
-
500
- export interface SpellingIssue {
501
- word: string;
502
- line: number;
503
- column: number;
504
- file?: string;
505
- suggestions?: string[];
506
- }
507
-
508
- export interface SpellingResult {
509
- misspelled: SpellingIssue[];
510
- possibleNames: SpellingIssue[];
511
- }
512
-
513
- export function getGlobalDictPath(): string;
514
- export function getProjectDictPath(directory?: string): string;
515
- export function loadDictionaryFile(dictPath: string): Set<string>;
516
- export function saveDictionaryFile(words: Set<string>, dictPath: string): void;
517
- export function loadAllCustomWords(projectDir?: string): Set<string>;
518
- export function addWord(word: string, global?: boolean, projectDir?: string): boolean;
519
- export function removeWord(word: string, global?: boolean, projectDir?: string): boolean;
520
- export function listWords(global?: boolean, projectDir?: string): string[];
521
- export function getSpellchecker(projectDir?: string, lang?: 'en' | 'en-gb'): Promise<object>;
522
- export function clearCache(): void;
523
- export function extractWords(text: string): Array<{ word: string; line: number; column: number }>;
524
- export function checkSpelling(text: string, options?: { projectDir?: string; lang?: 'en' | 'en-gb' }): Promise<SpellingResult>;
525
- export function checkFile(filePath: string, options?: { projectDir?: string; lang?: 'en' | 'en-gb' }): Promise<SpellingResult>;
1
+ /**
2
+ * TypeScript type definitions for docrev
3
+ */
4
+
5
+ // ============================================
6
+ // Annotations (lib/annotations.js)
7
+ // ============================================
8
+
9
+ export interface Annotation {
10
+ type: 'insert' | 'delete' | 'substitute' | 'comment' | 'highlight';
11
+ match: string;
12
+ content: string;
13
+ replacement?: string;
14
+ author?: string;
15
+ position: number;
16
+ line: number;
17
+ before?: string;
18
+ after?: string;
19
+ }
20
+
21
+ export interface Comment extends Annotation {
22
+ type: 'comment';
23
+ author: string;
24
+ resolved: boolean;
25
+ }
26
+
27
+ export interface AnnotationCounts {
28
+ inserts: number;
29
+ deletes: number;
30
+ substitutes: number;
31
+ comments: number;
32
+ total: number;
33
+ }
34
+
35
+ export interface StripOptions {
36
+ keepComments?: boolean;
37
+ }
38
+
39
+ export interface CommentFilterOptions {
40
+ pendingOnly?: boolean;
41
+ resolvedOnly?: boolean;
42
+ }
43
+
44
+ export function parseAnnotations(text: string): Annotation[];
45
+ export function stripAnnotations(text: string, options?: StripOptions): string;
46
+ export function applyDecision(text: string, annotation: Annotation, accept: boolean): string;
47
+ export function getTrackChanges(text: string): Annotation[];
48
+ export function getComments(text: string, options?: CommentFilterOptions): Comment[];
49
+ export function setCommentStatus(text: string, comment: Comment, resolved: boolean): string;
50
+ export function countAnnotations(text: string): AnnotationCounts;
51
+
52
+ // ============================================
53
+ // Build (lib/build.js)
54
+ // ============================================
55
+
56
+ export interface BuildConfig {
57
+ title?: string;
58
+ authors?: Author[];
59
+ sections?: string[];
60
+ bibliography?: string;
61
+ csl?: string;
62
+ crossref?: CrossrefConfig;
63
+ pdf?: PdfConfig;
64
+ docx?: DocxConfig;
65
+ }
66
+
67
+ export interface Author {
68
+ name: string;
69
+ affiliation?: string;
70
+ email?: string;
71
+ orcid?: string;
72
+ }
73
+
74
+ export interface CrossrefConfig {
75
+ figureTitle?: string;
76
+ tableTitle?: string;
77
+ figPrefix?: string | string[];
78
+ tblPrefix?: string | string[];
79
+ }
80
+
81
+ export interface PdfConfig {
82
+ documentclass?: string;
83
+ fontsize?: string;
84
+ geometry?: string;
85
+ linestretch?: number;
86
+ toc?: boolean;
87
+ }
88
+
89
+ export interface DocxConfig {
90
+ reference?: string;
91
+ keepComments?: boolean;
92
+ toc?: boolean;
93
+ }
94
+
95
+ export interface BuildResult {
96
+ format: string;
97
+ output: string;
98
+ success: boolean;
99
+ error?: string;
100
+ }
101
+
102
+ export function loadConfig(directory?: string): BuildConfig;
103
+ export function findSections(directory: string, config: BuildConfig): string[];
104
+ export function combineSections(files: string[], options?: object): string;
105
+ export function build(formats?: string[], options?: object): Promise<BuildResult[]>;
106
+ export function hasPandoc(): Promise<boolean>;
107
+ export function hasPandocCrossref(): Promise<boolean>;
108
+
109
+ // ============================================
110
+ // Citations (lib/citations.js)
111
+ // ============================================
112
+
113
+ export interface Citation {
114
+ key: string;
115
+ line: number;
116
+ file: string;
117
+ }
118
+
119
+ export interface CitationValidation {
120
+ valid: Citation[];
121
+ missing: Citation[];
122
+ unused: string[];
123
+ duplicates: Array<{ key: string; count: number; locations: Citation[] }>;
124
+ }
125
+
126
+ export interface CitationStats {
127
+ totalCitations: number;
128
+ uniqueCited: number;
129
+ valid: number;
130
+ missing: number;
131
+ missingKeys: string[];
132
+ bibEntries: number;
133
+ unused: number;
134
+ unusedKeys: string[];
135
+ }
136
+
137
+ export function extractCitations(text: string, file?: string): Citation[];
138
+ export function parseBibFile(bibPath: string): Set<string>;
139
+ export function validateCitations(mdFiles: string[], bibPath: string): CitationValidation;
140
+ export function getCitationStats(mdFiles: string[], bibPath: string): CitationStats;
141
+
142
+ // ============================================
143
+ // Crossref (lib/crossref.js)
144
+ // ============================================
145
+
146
+ export interface RefNumber {
147
+ num: number;
148
+ isSupp: boolean;
149
+ suffix: string | null;
150
+ }
151
+
152
+ export interface HardcodedRef {
153
+ type: 'fig' | 'tbl' | 'eq';
154
+ match: string;
155
+ numbers: RefNumber[];
156
+ position: number;
157
+ }
158
+
159
+ export interface DynamicRef {
160
+ type: 'fig' | 'tbl' | 'eq';
161
+ label: string;
162
+ match: string;
163
+ position: number;
164
+ }
165
+
166
+ export interface FigureInfo {
167
+ label: string;
168
+ num: number;
169
+ isSupp: boolean;
170
+ file: string;
171
+ }
172
+
173
+ export interface Registry {
174
+ figures: Map<string, FigureInfo>;
175
+ tables: Map<string, FigureInfo>;
176
+ equations: Map<string, FigureInfo>;
177
+ byNumber: {
178
+ fig: Map<number, string>;
179
+ figS: Map<number, string>;
180
+ tbl: Map<number, string>;
181
+ tblS: Map<number, string>;
182
+ eq: Map<number, string>;
183
+ };
184
+ }
185
+
186
+ export interface RefStatus {
187
+ dynamic: DynamicRef[];
188
+ hardcoded: HardcodedRef[];
189
+ anchors: { figures: number; tables: number; equations: number };
190
+ }
191
+
192
+ export function normalizeType(typeStr: string): 'fig' | 'tbl' | 'eq' | string;
193
+ export function parseRefNumber(numStr: string, suffix?: string): RefNumber;
194
+ export function parseReferenceList(listStr: string): RefNumber[];
195
+ export function buildRegistry(directory: string, excludeFiles?: string[]): Registry;
196
+ export function labelToDisplay(type: string, label: string, registry: Registry): string | null;
197
+ export function numberToLabel(type: string, num: number, isSupp: boolean, registry: Registry): string | null;
198
+ export function detectHardcodedRefs(text: string): HardcodedRef[];
199
+ export function detectDynamicRefs(text: string): DynamicRef[];
200
+ export function convertHardcodedRefs(text: string, registry: Registry): { converted: string; conversions: Array<{ from: string; to: string }>; warnings: string[] };
201
+ export function getRefStatus(text: string, registry: Registry): RefStatus;
202
+
203
+ // ============================================
204
+ // DOI (lib/doi.js)
205
+ // ============================================
206
+
207
+ export interface BibEntry {
208
+ key: string;
209
+ type: string;
210
+ doi: string | null;
211
+ title: string;
212
+ authorRaw: string;
213
+ year: number | null;
214
+ journal: string;
215
+ skip: boolean;
216
+ expectDoi: boolean;
217
+ noDoi: boolean;
218
+ line: number;
219
+ }
220
+
221
+ export interface DoiCheckResult {
222
+ valid: boolean;
223
+ source?: 'crossref' | 'datacite';
224
+ metadata?: {
225
+ title: string;
226
+ authors: string[];
227
+ year: number;
228
+ journal: string;
229
+ type?: string;
230
+ };
231
+ error?: string;
232
+ }
233
+
234
+ export interface BibtexFetchResult {
235
+ success: boolean;
236
+ bibtex?: string;
237
+ error?: string;
238
+ }
239
+
240
+ export interface DoiLookupResult {
241
+ found: boolean;
242
+ doi?: string;
243
+ confidence?: 'low' | 'medium' | 'high';
244
+ score?: number;
245
+ metadata?: {
246
+ title: string;
247
+ authors: string[];
248
+ year: number;
249
+ journal: string;
250
+ };
251
+ alternatives?: Array<{
252
+ doi: string;
253
+ title: string;
254
+ score: number;
255
+ }>;
256
+ error?: string;
257
+ }
258
+
259
+ export interface BibCheckResult {
260
+ entries: Array<BibEntry & { status: string; message?: string; metadata?: object }>;
261
+ valid: number;
262
+ invalid: number;
263
+ missing: number;
264
+ skipped: number;
265
+ }
266
+
267
+ export function parseBibEntries(bibPath: string): BibEntry[];
268
+ export function isValidDoiFormat(doi: string): boolean;
269
+ export function checkDoi(doi: string): Promise<DoiCheckResult>;
270
+ export function fetchBibtex(doi: string): Promise<BibtexFetchResult>;
271
+ export function checkBibDois(bibPath: string, options?: { checkMissing?: boolean; parallel?: number }): Promise<BibCheckResult>;
272
+ export function lookupDoi(title: string, author?: string, year?: number, journal?: string): Promise<DoiLookupResult>;
273
+ export function lookupMissingDois(bibPath: string, options?: { parallel?: number; onProgress?: (current: number, total: number) => void }): Promise<Array<{ key: string; title: string; type: string; journal: string; result: DoiLookupResult }>>;
274
+ export function addToBib(bibPath: string, bibtex: string): { success: boolean; key?: string; error?: string };
275
+
276
+ // ============================================
277
+ // Equations (lib/equations.js)
278
+ // ============================================
279
+
280
+ export interface Equation {
281
+ type: 'inline' | 'display';
282
+ content: string;
283
+ line: number;
284
+ file: string;
285
+ }
286
+
287
+ export interface EquationStats {
288
+ total: number;
289
+ display: number;
290
+ inline: number;
291
+ byFile: Array<{ file: string; display: number; inline: number }>;
292
+ }
293
+
294
+ export interface WordEquationResult {
295
+ success: boolean;
296
+ equations: Array<{
297
+ type: 'inline' | 'display' | 'unknown';
298
+ latex: string | null;
299
+ position: number;
300
+ line?: number;
301
+ raw?: string;
302
+ error?: string;
303
+ }>;
304
+ error?: string;
305
+ }
306
+
307
+ export function extractEquations(text: string, file?: string): Equation[];
308
+ export function generateEquationSheet(equations: Equation[]): string;
309
+ export function convertToWord(inputPath: string, outputPath: string, options?: { preserveLatex?: boolean }): Promise<{ success: boolean; message: string }>;
310
+ export function createEquationsDoc(inputPath: string, outputPath: string): Promise<{ success: boolean; message: string; stats: { display: number; inline: number } | null }>;
311
+ export function getEquationStats(files: string[]): EquationStats;
312
+ export function extractEquationsFromWord(docxPath: string): Promise<WordEquationResult>;
313
+ export function getWordEquationStats(docxPath: string): Promise<{ count: number; display: number; inline: number; converted: number; error?: string }>;
314
+
315
+ // ============================================
316
+ // Git (lib/git.js)
317
+ // ============================================
318
+
319
+ export interface FileChange {
320
+ added: number;
321
+ removed: number;
322
+ changes: Array<{ added: boolean; removed: boolean; value: string }>;
323
+ }
324
+
325
+ export interface CommitInfo {
326
+ hash: string;
327
+ date: string;
328
+ author: string;
329
+ message: string;
330
+ }
331
+
332
+ export function isGitRepo(directory?: string): boolean;
333
+ export function getCurrentBranch(directory?: string): string | null;
334
+ export function getDefaultBranch(directory?: string): string;
335
+ export function getFileAtRef(filePath: string, ref: string): string | null;
336
+ export function getChangedFiles(fromRef: string, toRef?: string): string[];
337
+ export function getFileHistory(filePath: string, limit?: number): CommitInfo[];
338
+ export function compareFileVersions(filePath: string, fromRef: string, toRef?: string): FileChange;
339
+ export function getWordCountDiff(filePath: string, fromRef: string, toRef?: string): { before: number; after: number; diff: number };
340
+ export function getRecentCommits(directory?: string, limit?: number): CommitInfo[];
341
+ export function hasUncommittedChanges(directory?: string): boolean;
342
+ export function getTags(directory?: string): string[];
343
+
344
+ // ============================================
345
+ // Journals (lib/journals.js)
346
+ // ============================================
347
+
348
+ export interface JournalProfile {
349
+ name: string;
350
+ url: string;
351
+ requirements: {
352
+ wordLimit?: { main: number; abstract?: number };
353
+ references?: { max?: number; doiRequired?: boolean };
354
+ figures?: { max?: number };
355
+ tables?: { max?: number };
356
+ sections?: string[];
357
+ formatting?: object;
358
+ };
359
+ }
360
+
361
+ export interface ValidationResult {
362
+ journal: string;
363
+ valid: boolean;
364
+ wordCount: { main: number; abstract: number; limit: { main: number; abstract: number } };
365
+ figures: { count: number; max: number };
366
+ tables: { count: number; max: number };
367
+ references: { count: number; max: number };
368
+ sections: { found: string[]; missing: string[]; required: string[] };
369
+ errors: string[];
370
+ warnings: string[];
371
+ }
372
+
373
+ export function listJournals(): Array<{ id: string; name: string; url: string }>;
374
+ export function getJournalProfile(journalId: string): JournalProfile | null;
375
+ export function validateManuscript(text: string, journalId: string, options?: { bibPath?: string }): ValidationResult;
376
+ export function validateProject(directory: string, journalId: string): Promise<ValidationResult>;
377
+
378
+ // ============================================
379
+ // Merge (lib/merge.js)
380
+ // ============================================
381
+
382
+ export interface ReviewerChange {
383
+ reviewer: string;
384
+ type: 'insert' | 'delete' | 'replace';
385
+ start: number;
386
+ end: number;
387
+ oldText: string;
388
+ newText: string;
389
+ }
390
+
391
+ export interface Conflict {
392
+ start: number;
393
+ end: number;
394
+ original: string;
395
+ changes: ReviewerChange[];
396
+ }
397
+
398
+ export interface MergeResult {
399
+ merged: string;
400
+ conflicts: Conflict[];
401
+ stats: {
402
+ reviewers: number;
403
+ totalChanges: number;
404
+ nonConflicting: number;
405
+ conflicts: number;
406
+ comments: number;
407
+ };
408
+ originalText: string;
409
+ }
410
+
411
+ export function extractChanges(originalText: string, wordText: string, reviewer: string): ReviewerChange[];
412
+ export function detectConflicts(allChanges: ReviewerChange[][]): { conflicts: Conflict[]; nonConflicting: ReviewerChange[] };
413
+ export function applyChanges(originalText: string, changes: ReviewerChange[]): string;
414
+ export function applyChangesAsAnnotations(originalText: string, changes: ReviewerChange[]): string;
415
+ export function formatConflict(conflict: Conflict, originalText: string): string;
416
+ export function mergeReviewerDocs(originalPath: string, reviewerDocs: Array<{ path: string; name: string }>, options?: { autoResolve?: boolean }): Promise<MergeResult>;
417
+ export function resolveConflict(text: string, conflict: Conflict, choice: number, originalText: string): string;
418
+
419
+ // ============================================
420
+ // Sections (lib/sections.js)
421
+ // ============================================
422
+
423
+ export interface SectionConfig {
424
+ header: string;
425
+ aliases?: string[];
426
+ order?: number;
427
+ }
428
+
429
+ export interface SectionsConfig {
430
+ version: number;
431
+ description?: string;
432
+ sections: Record<string, SectionConfig>;
433
+ }
434
+
435
+ export interface ExtractedSection {
436
+ file: string;
437
+ header: string;
438
+ content: string;
439
+ matched: boolean;
440
+ }
441
+
442
+ export function extractHeader(filePath: string): string | null;
443
+ export function generateConfig(directory: string, excludePatterns?: string[]): SectionsConfig;
444
+ export function loadConfig(configPath: string): SectionsConfig;
445
+ export function saveConfig(configPath: string, config: SectionsConfig): void;
446
+ export function matchHeading(heading: string, sections: Record<string, SectionConfig>): { file: string; config: SectionConfig } | null;
447
+ export function extractSectionsFromText(text: string, sections: Record<string, SectionConfig>): ExtractedSection[];
448
+ export function splitAnnotatedPaper(paperContent: string, sections: Record<string, SectionConfig>): Map<string, string>;
449
+ export function getOrderedSections(config: SectionsConfig): string[];
450
+
451
+ // ============================================
452
+ // Word (lib/word.js)
453
+ // ============================================
454
+
455
+ export interface WordComment {
456
+ id: string;
457
+ author: string;
458
+ date: string;
459
+ text: string;
460
+ }
461
+
462
+ export interface WordMetadata {
463
+ title?: string;
464
+ author?: string;
465
+ created?: string;
466
+ modified?: string;
467
+ }
468
+
469
+ export interface CommentAnchor {
470
+ text: string;
471
+ context: string;
472
+ }
473
+
474
+ export function extractWordComments(docxPath: string): Promise<WordComment[]>;
475
+ export function extractCommentAnchors(docxPath: string): Promise<Map<string, CommentAnchor>>;
476
+ export function extractTextFromWord(docxPath: string): Promise<string>;
477
+ export function extractFromWord(docxPath: string): Promise<{ text: string; html: string }>;
478
+ export function getWordMetadata(docxPath: string): Promise<WordMetadata>;
479
+ export function isWordDocument(filePath: string): boolean;
480
+
481
+ // ============================================
482
+ // TrackChanges (lib/trackchanges.js)
483
+ // ============================================
484
+
485
+ export interface TrackChangeMarker {
486
+ type: 'insert' | 'delete';
487
+ start: number;
488
+ end: number;
489
+ content: string;
490
+ }
491
+
492
+ export function prepareForTrackChanges(text: string): { text: string; markers: TrackChangeMarker[] };
493
+ export function applyTrackChangesToDocx(docxPath: string, markers: TrackChangeMarker[], author?: string): Promise<void>;
494
+ export function buildWithTrackChanges(markdownPath: string, outputPath: string, options?: object): Promise<{ success: boolean; message: string }>;
495
+
496
+ // ============================================
497
+ // Spelling (lib/spelling.js)
498
+ // ============================================
499
+
500
+ export interface SpellingIssue {
501
+ word: string;
502
+ line: number;
503
+ column: number;
504
+ file?: string;
505
+ suggestions?: string[];
506
+ }
507
+
508
+ export interface SpellingResult {
509
+ misspelled: SpellingIssue[];
510
+ possibleNames: SpellingIssue[];
511
+ }
512
+
513
+ export function getGlobalDictPath(): string;
514
+ export function getProjectDictPath(directory?: string): string;
515
+ export function loadDictionaryFile(dictPath: string): Set<string>;
516
+ export function saveDictionaryFile(words: Set<string>, dictPath: string): void;
517
+ export function loadAllCustomWords(projectDir?: string): Set<string>;
518
+ export function addWord(word: string, global?: boolean, projectDir?: string): boolean;
519
+ export function removeWord(word: string, global?: boolean, projectDir?: string): boolean;
520
+ export function listWords(global?: boolean, projectDir?: string): string[];
521
+ export function getSpellchecker(projectDir?: string, lang?: 'en' | 'en-gb'): Promise<object>;
522
+ export function clearCache(): void;
523
+ export function extractWords(text: string): Array<{ word: string; line: number; column: number }>;
524
+ export function checkSpelling(text: string, options?: { projectDir?: string; lang?: 'en' | 'en-gb' }): Promise<SpellingResult>;
525
+ export function checkFile(filePath: string, options?: { projectDir?: string; lang?: 'en' | 'en-gb' }): Promise<SpellingResult>;