docrev 0.11.1 → 0.11.3

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 (144) hide show
  1. package/.gitattributes +1 -1
  2. package/CHANGELOG.md +207 -197
  3. package/PLAN-tables-and-postprocess.md +850 -850
  4. package/README.md +433 -433
  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/annotations.d.ts.map +1 -1
  11. package/dist/lib/annotations.js +28 -0
  12. package/dist/lib/annotations.js.map +1 -1
  13. package/dist/lib/build.d.ts +28 -0
  14. package/dist/lib/build.d.ts.map +1 -1
  15. package/dist/lib/build.js +81 -4
  16. package/dist/lib/build.js.map +1 -1
  17. package/dist/lib/commands/comments.d.ts.map +1 -1
  18. package/dist/lib/commands/comments.js +58 -28
  19. package/dist/lib/commands/comments.js.map +1 -1
  20. package/dist/lib/commands/context.d.ts +1 -0
  21. package/dist/lib/commands/context.d.ts.map +1 -1
  22. package/dist/lib/commands/context.js +1 -0
  23. package/dist/lib/commands/context.js.map +1 -1
  24. package/dist/lib/commands/core.d.ts.map +1 -1
  25. package/dist/lib/commands/core.js +25 -8
  26. package/dist/lib/commands/core.js.map +1 -1
  27. package/dist/lib/commands/response.js +1 -1
  28. package/dist/lib/commands/response.js.map +1 -1
  29. package/dist/lib/commands/utilities.js +164 -164
  30. package/dist/lib/commands/word-tools.js +8 -8
  31. package/dist/lib/grammar.js +3 -3
  32. package/dist/lib/import.d.ts +14 -0
  33. package/dist/lib/import.d.ts.map +1 -1
  34. package/dist/lib/import.js +23 -0
  35. package/dist/lib/import.js.map +1 -1
  36. package/dist/lib/input.d.ts +67 -0
  37. package/dist/lib/input.d.ts.map +1 -0
  38. package/dist/lib/input.js +164 -0
  39. package/dist/lib/input.js.map +1 -0
  40. package/dist/lib/macro-filter.lua +201 -201
  41. package/dist/lib/pdf-comments.js +44 -44
  42. package/dist/lib/plugins.js +57 -57
  43. package/dist/lib/pptx-color-filter.lua +37 -37
  44. package/dist/lib/pptx-themes.js +115 -115
  45. package/dist/lib/response.d.ts +1 -1
  46. package/dist/lib/response.d.ts.map +1 -1
  47. package/dist/lib/response.js +5 -2
  48. package/dist/lib/response.js.map +1 -1
  49. package/dist/lib/schema.d.ts.map +1 -1
  50. package/dist/lib/schema.js +8 -2
  51. package/dist/lib/schema.js.map +1 -1
  52. package/dist/lib/spelling.js +2 -2
  53. package/dist/lib/templates.js +387 -387
  54. package/dist/lib/themes.js +51 -51
  55. package/eslint.config.js +27 -27
  56. package/lib/anchor-match.ts +307 -307
  57. package/lib/annotations.ts +695 -664
  58. package/lib/build.ts +2047 -1956
  59. package/lib/citations.ts +160 -160
  60. package/lib/commands/build.ts +885 -885
  61. package/lib/commands/citations.ts +515 -515
  62. package/lib/commands/comments.ts +1077 -1050
  63. package/lib/commands/context.ts +185 -176
  64. package/lib/commands/core.ts +328 -309
  65. package/lib/commands/doi.ts +451 -451
  66. package/lib/commands/file-ops.ts +372 -372
  67. package/lib/commands/history.ts +320 -320
  68. package/lib/commands/index.ts +87 -87
  69. package/lib/commands/init.ts +259 -259
  70. package/lib/commands/merge-resolve.ts +378 -378
  71. package/lib/commands/preview.ts +178 -178
  72. package/lib/commands/project-info.ts +244 -244
  73. package/lib/commands/quality.ts +517 -517
  74. package/lib/commands/response.ts +454 -454
  75. package/lib/commands/section-boundaries.ts +82 -82
  76. package/lib/commands/sections.ts +451 -451
  77. package/lib/commands/sync.ts +689 -689
  78. package/lib/commands/text-ops.ts +449 -449
  79. package/lib/commands/utilities.ts +448 -448
  80. package/lib/commands/verify-anchors.ts +272 -272
  81. package/lib/commands/word-tools.ts +340 -340
  82. package/lib/comment-realign.ts +99 -99
  83. package/lib/config.ts +84 -84
  84. package/lib/crossref.ts +781 -781
  85. package/lib/csl.ts +191 -191
  86. package/lib/dependencies.ts +132 -132
  87. package/lib/diff-engine.ts +465 -465
  88. package/lib/doi-cache.ts +115 -115
  89. package/lib/doi.ts +879 -879
  90. package/lib/equations.ts +506 -506
  91. package/lib/errors.ts +350 -350
  92. package/lib/format.ts +541 -541
  93. package/lib/git.ts +326 -326
  94. package/lib/grammar.ts +303 -303
  95. package/lib/image-registry.ts +180 -180
  96. package/lib/import.ts +932 -906
  97. package/lib/input.ts +174 -0
  98. package/lib/journals.ts +543 -543
  99. package/lib/macro-filter.lua +201 -201
  100. package/lib/macros.ts +273 -273
  101. package/lib/merge.ts +633 -633
  102. package/lib/ooxml.ts +768 -768
  103. package/lib/orcid.ts +144 -144
  104. package/lib/pdf-comments.ts +263 -263
  105. package/lib/pdf-import.ts +524 -524
  106. package/lib/plugins.ts +362 -362
  107. package/lib/postprocess.ts +188 -188
  108. package/lib/pptx-color-filter.lua +37 -37
  109. package/lib/pptx-template.ts +469 -469
  110. package/lib/pptx-themes.ts +483 -483
  111. package/lib/protect-restore.ts +520 -520
  112. package/lib/rate-limiter.ts +127 -127
  113. package/lib/response.ts +200 -197
  114. package/lib/restore-references.ts +240 -240
  115. package/lib/review.ts +327 -327
  116. package/lib/schema.ts +494 -488
  117. package/lib/scientific-words.ts +73 -73
  118. package/lib/sections.ts +428 -428
  119. package/lib/slides.ts +756 -756
  120. package/lib/spelling.ts +334 -334
  121. package/lib/templates.ts +526 -526
  122. package/lib/themes.ts +742 -742
  123. package/lib/trackchanges.ts +166 -166
  124. package/lib/tui.ts +450 -450
  125. package/lib/types.ts +546 -546
  126. package/lib/undo.ts +250 -250
  127. package/lib/utils.ts +69 -69
  128. package/lib/variables.ts +179 -179
  129. package/lib/word-extraction.ts +525 -525
  130. package/lib/word.ts +526 -526
  131. package/lib/wordcomments.ts +789 -789
  132. package/package.json +1 -1
  133. package/scripts/postbuild.js +47 -47
  134. package/skill/REFERENCE.md +550 -550
  135. package/skill/SKILL.md +302 -302
  136. package/tsconfig.json +26 -26
  137. package/types/index.d.ts +531 -531
  138. package/issues.md +0 -180
  139. package/site/assets/extra.css +0 -208
  140. package/site/commands.html +0 -926
  141. package/site/configuration.html +0 -469
  142. package/site/index.html +0 -288
  143. package/site/troubleshooting.html +0 -461
  144. package/site/workflow.html +0 -518
package/lib/types.ts CHANGED
@@ -1,546 +1,546 @@
1
- /**
2
- * Shared TypeScript type definitions for docrev
3
- * Extracted from types/index.d.ts for internal use
4
- */
5
-
6
- // ============================================
7
- // Annotations
8
- // ============================================
9
-
10
- export interface Annotation {
11
- type: 'insert' | 'delete' | 'substitute' | 'comment' | 'highlight';
12
- match: string;
13
- content: string;
14
- replacement?: string;
15
- author?: string;
16
- position: number;
17
- line: number;
18
- before?: string;
19
- after?: string;
20
- resolved?: boolean;
21
- }
22
-
23
- export interface Comment extends Annotation {
24
- type: 'comment';
25
- author: string;
26
- resolved: boolean;
27
- }
28
-
29
- export interface AnnotationCounts {
30
- inserts: number;
31
- deletes: number;
32
- substitutes: number;
33
- comments: number;
34
- total: number;
35
- }
36
-
37
- export interface StripOptions {
38
- keepComments?: boolean;
39
- }
40
-
41
- export interface CommentFilterOptions {
42
- pendingOnly?: boolean;
43
- resolvedOnly?: boolean;
44
- }
45
-
46
- // ============================================
47
- // Build
48
- // ============================================
49
-
50
- export interface Author {
51
- name: string;
52
- affiliation?: string;
53
- affiliations?: string[];
54
- corresponding?: boolean;
55
- email?: string;
56
- orcid?: string;
57
- }
58
-
59
- export interface CrossrefConfig {
60
- figureTitle?: string;
61
- tableTitle?: string;
62
- figPrefix?: string | string[];
63
- tblPrefix?: string | string[];
64
- }
65
-
66
- export interface PdfConfig {
67
- documentclass?: string;
68
- fontsize?: string;
69
- geometry?: string;
70
- linestretch?: number;
71
- toc?: boolean;
72
- /**
73
- * LaTeX engine to use for PDF output. One of `pdflatex` (default),
74
- * `xelatex`, `lualatex`, `tectonic`, etc. xelatex/lualatex are required
75
- * for native UTF-8 rendering of diacritics in author names, place
76
- * names, and species epithets.
77
- */
78
- engine?: string;
79
- /** Roman/serif main font (xelatex/lualatex only — uses fontspec). */
80
- mainfont?: string;
81
- /** Sans-serif font (xelatex/lualatex only). */
82
- sansfont?: string;
83
- /** Monospace font (xelatex/lualatex only). */
84
- monofont?: string;
85
- numbersections?: boolean;
86
- template?: string;
87
- headerIncludes?: string;
88
- }
89
-
90
- export interface DocxConfig {
91
- reference?: string;
92
- keepComments?: boolean;
93
- toc?: boolean;
94
- }
95
-
96
- export interface BuildConfig {
97
- title?: string;
98
- authors?: Author[];
99
- sections?: string[];
100
- bibliography?: string;
101
- csl?: string;
102
- crossref?: CrossrefConfig;
103
- pdf?: PdfConfig;
104
- docx?: DocxConfig;
105
- postprocess?: { [key: string]: string };
106
- _configPath?: string;
107
- [key: string]: unknown;
108
- }
109
-
110
- export interface BuildResult {
111
- format: string;
112
- output: string;
113
- success: boolean;
114
- error?: string;
115
- }
116
-
117
- // ============================================
118
- // Citations
119
- // ============================================
120
-
121
- export interface Citation {
122
- key: string;
123
- line: number;
124
- file: string;
125
- }
126
-
127
- export interface CitationValidation {
128
- valid: Citation[];
129
- missing: Citation[];
130
- unused: string[];
131
- duplicates: Array<{ key: string; count: number; locations: Citation[] }>;
132
- }
133
-
134
- export interface CitationStats {
135
- totalCitations: number;
136
- uniqueCited: number;
137
- valid: number;
138
- missing: number;
139
- missingKeys: string[];
140
- bibEntries: number;
141
- unused: number;
142
- unusedKeys: string[];
143
- }
144
-
145
- // ============================================
146
- // Crossref
147
- // ============================================
148
-
149
- export interface RefNumber {
150
- num: number;
151
- isSupp: boolean;
152
- suffix: string | null;
153
- }
154
-
155
- export interface HardcodedRef {
156
- type: 'fig' | 'tbl' | 'eq';
157
- match: string;
158
- numbers: RefNumber[];
159
- position: number;
160
- }
161
-
162
- export interface DynamicRef {
163
- type: 'fig' | 'tbl' | 'eq';
164
- label: string;
165
- match: string;
166
- position: number;
167
- }
168
-
169
- export interface FigureInfo {
170
- label: string;
171
- num: number;
172
- isSupp: boolean;
173
- file: string;
174
- }
175
-
176
- export interface Registry {
177
- figures: Map<string, FigureInfo>;
178
- tables: Map<string, FigureInfo>;
179
- equations: Map<string, FigureInfo>;
180
- byNumber: {
181
- fig: Map<number, string>;
182
- figS: Map<number, string>;
183
- tbl: Map<number, string>;
184
- tblS: Map<number, string>;
185
- eq: Map<number, string>;
186
- };
187
- }
188
-
189
- export interface RefStatus {
190
- dynamic: DynamicRef[];
191
- hardcoded: HardcodedRef[];
192
- anchors: { figures: number; tables: number; equations: number };
193
- }
194
-
195
- export interface ConversionResult {
196
- converted: string;
197
- conversions: Array<{ from: string; to: string }>;
198
- warnings: string[];
199
- }
200
-
201
- // ============================================
202
- // DOI
203
- // ============================================
204
-
205
- export interface BibEntry {
206
- key: string;
207
- type: string;
208
- doi: string | null;
209
- title: string;
210
- authorRaw: string;
211
- year: number | null;
212
- journal: string;
213
- skip: boolean;
214
- expectDoi: boolean;
215
- noDoi: boolean;
216
- line: number;
217
- }
218
-
219
- export interface DoiCheckResult {
220
- valid: boolean;
221
- source?: 'crossref' | 'datacite' | 'doi.org';
222
- /**
223
- * True when the registry could not be reached (network error, timeout, or
224
- * 5xx) — the DOI's validity is unknown, distinct from a definitive "not
225
- * found". Callers must not report an unreachable DOI as invalid.
226
- */
227
- unreachable?: boolean;
228
- metadata?: {
229
- title: string;
230
- authors: string[];
231
- year: number;
232
- journal: string;
233
- type?: string;
234
- };
235
- error?: string;
236
- }
237
-
238
- export interface BibtexFetchResult {
239
- success: boolean;
240
- bibtex?: string;
241
- error?: string;
242
- }
243
-
244
- export interface DoiLookupResult {
245
- found: boolean;
246
- doi?: string;
247
- confidence?: 'low' | 'medium' | 'high';
248
- score?: number;
249
- metadata?: {
250
- title: string;
251
- authors: string[];
252
- year: number;
253
- journal: string;
254
- };
255
- alternatives?: Array<{
256
- doi: string;
257
- title: string;
258
- score: number;
259
- }>;
260
- error?: string;
261
- }
262
-
263
- export interface BibCheckResult {
264
- entries: Array<BibEntry & { status: string; message?: string; metadata?: object }>;
265
- valid: number;
266
- invalid: number;
267
- /** DOIs whose registry could not be reached (network/timeout) — not invalid. */
268
- unreachable: number;
269
- missing: number;
270
- skipped: number;
271
- }
272
-
273
- // ============================================
274
- // Equations
275
- // ============================================
276
-
277
- export interface Equation {
278
- type: 'inline' | 'display';
279
- content: string;
280
- line: number;
281
- file: string;
282
- }
283
-
284
- export interface EquationStats {
285
- total: number;
286
- display: number;
287
- inline: number;
288
- byFile: Array<{ file: string; display: number; inline: number }>;
289
- }
290
-
291
- export interface WordEquationResult {
292
- success: boolean;
293
- equations: Array<{
294
- type: 'inline' | 'display' | 'unknown';
295
- latex: string | null;
296
- position: number;
297
- line?: number;
298
- raw?: string;
299
- error?: string;
300
- }>;
301
- error?: string;
302
- }
303
-
304
- // ============================================
305
- // Git
306
- // ============================================
307
-
308
- export interface FileChange {
309
- added: number;
310
- removed: number;
311
- changes: Array<{ added?: boolean; removed?: boolean; value: string }>;
312
- }
313
-
314
- export interface CommitInfo {
315
- hash: string;
316
- date: string;
317
- author: string;
318
- message: string;
319
- }
320
-
321
- export interface ChangedFile {
322
- file: string;
323
- status: 'added' | 'deleted' | 'modified';
324
- }
325
-
326
- export interface BlameEntry {
327
- line: number;
328
- author: string;
329
- date: string;
330
- hash: string;
331
- content: string;
332
- }
333
-
334
- export interface AuthorStats {
335
- lines: number;
336
- percentage: number;
337
- }
338
-
339
- export interface ContributorStats {
340
- lines: number;
341
- files: number;
342
- }
343
-
344
- // ============================================
345
- // Journals
346
- // ============================================
347
-
348
- export interface JournalRequirements {
349
- wordLimit?: { main?: number; abstract?: number };
350
- references?: { max?: number; doiRequired?: boolean };
351
- figures?: { max?: number };
352
- tables?: { max?: number };
353
- sections?: string[];
354
- }
355
-
356
- export interface JournalFormatting {
357
- csl?: string;
358
- pdf?: {
359
- documentclass?: string;
360
- fontsize?: string;
361
- geometry?: string;
362
- linestretch?: number;
363
- template?: string;
364
- numbersections?: boolean;
365
- engine?: string;
366
- mainfont?: string;
367
- sansfont?: string;
368
- monofont?: string;
369
- };
370
- docx?: {
371
- reference?: string;
372
- };
373
- crossref?: {
374
- figPrefix?: string | string[];
375
- tblPrefix?: string | string[];
376
- };
377
- }
378
-
379
- export interface JournalProfile {
380
- name: string;
381
- url: string;
382
- requirements: JournalRequirements;
383
- formatting?: JournalFormatting;
384
- }
385
-
386
- export interface ValidationResult {
387
- journal: string;
388
- valid: boolean;
389
- wordCount: { main: number; abstract: number; limit: { main: number; abstract: number } };
390
- figures: { count: number; max: number };
391
- tables: { count: number; max: number };
392
- references: { count: number; max: number };
393
- sections: { found: string[]; missing: string[]; required: string[] };
394
- errors: string[];
395
- warnings: string[];
396
- }
397
-
398
- // ============================================
399
- // Merge
400
- // ============================================
401
-
402
- export interface ReviewerChange {
403
- reviewer: string;
404
- type: 'insert' | 'delete' | 'replace';
405
- start: number;
406
- end: number;
407
- oldText: string;
408
- newText: string;
409
- }
410
-
411
- export interface Conflict {
412
- id: string;
413
- start: number;
414
- end: number;
415
- original: string;
416
- changes: ReviewerChange[];
417
- section?: string;
418
- line?: number;
419
- resolved: string | null;
420
- }
421
-
422
- export interface MergeResult {
423
- merged: string;
424
- conflicts: Conflict[];
425
- stats: {
426
- reviewers: number;
427
- totalChanges: number;
428
- nonConflicting: number;
429
- conflicts: number;
430
- comments: number;
431
- };
432
- originalText: string;
433
- }
434
-
435
- // ============================================
436
- // Sections
437
- // ============================================
438
-
439
- export interface SectionConfig {
440
- header: string;
441
- aliases?: string[];
442
- order?: number;
443
- }
444
-
445
- export interface SectionsConfig {
446
- version: number;
447
- description?: string;
448
- sections: Record<string, SectionConfig>;
449
- }
450
-
451
- export interface ExtractedSection {
452
- file: string;
453
- header: string;
454
- content: string;
455
- matched: boolean;
456
- }
457
-
458
- // ============================================
459
- // Word
460
- // ============================================
461
-
462
- export interface WordComment {
463
- id: string;
464
- author: string;
465
- date?: string;
466
- text: string;
467
- }
468
-
469
- export interface WordMetadata {
470
- title?: string;
471
- author?: string;
472
- created?: string;
473
- modified?: string;
474
- }
475
-
476
- export interface CommentAnchor {
477
- text: string;
478
- context: string;
479
- }
480
-
481
- export interface WordContent {
482
- text: string;
483
- html: string;
484
- }
485
-
486
- export interface TrackChangesResult {
487
- hasTrackChanges: boolean;
488
- content: string | null;
489
- stats: { insertions: number; deletions: number };
490
- }
491
-
492
- // ============================================
493
- // Spelling
494
- // ============================================
495
-
496
- export interface SpellingIssue {
497
- word: string;
498
- line: number;
499
- column: number;
500
- file?: string;
501
- suggestions?: string[];
502
- }
503
-
504
- export interface SpellingResult {
505
- misspelled: SpellingIssue[];
506
- possibleNames: SpellingIssue[];
507
- }
508
-
509
- // ============================================
510
- // Config
511
- // ============================================
512
-
513
- export interface UserConfig {
514
- userName?: string;
515
- defaultSections?: string[];
516
- }
517
-
518
- // ============================================
519
- // DOI Cache
520
- // ============================================
521
-
522
- export interface DoiCacheEntry {
523
- result: DoiCheckResult | DoiLookupResult;
524
- timestamp: number;
525
- }
526
-
527
- export interface DoiCache {
528
- entries: Record<string, DoiCacheEntry>;
529
- version: number;
530
- }
531
-
532
- export interface DoiCacheStats {
533
- size: number;
534
- path: string;
535
- }
536
-
537
- // ============================================
538
- // Errors
539
- // ============================================
540
-
541
- export interface ErrorInfo {
542
- code: string;
543
- message: string;
544
- help?: string;
545
- cause?: Error;
546
- }
1
+ /**
2
+ * Shared TypeScript type definitions for docrev
3
+ * Extracted from types/index.d.ts for internal use
4
+ */
5
+
6
+ // ============================================
7
+ // Annotations
8
+ // ============================================
9
+
10
+ export interface Annotation {
11
+ type: 'insert' | 'delete' | 'substitute' | 'comment' | 'highlight';
12
+ match: string;
13
+ content: string;
14
+ replacement?: string;
15
+ author?: string;
16
+ position: number;
17
+ line: number;
18
+ before?: string;
19
+ after?: string;
20
+ resolved?: boolean;
21
+ }
22
+
23
+ export interface Comment extends Annotation {
24
+ type: 'comment';
25
+ author: string;
26
+ resolved: boolean;
27
+ }
28
+
29
+ export interface AnnotationCounts {
30
+ inserts: number;
31
+ deletes: number;
32
+ substitutes: number;
33
+ comments: number;
34
+ total: number;
35
+ }
36
+
37
+ export interface StripOptions {
38
+ keepComments?: boolean;
39
+ }
40
+
41
+ export interface CommentFilterOptions {
42
+ pendingOnly?: boolean;
43
+ resolvedOnly?: boolean;
44
+ }
45
+
46
+ // ============================================
47
+ // Build
48
+ // ============================================
49
+
50
+ export interface Author {
51
+ name: string;
52
+ affiliation?: string;
53
+ affiliations?: string[];
54
+ corresponding?: boolean;
55
+ email?: string;
56
+ orcid?: string;
57
+ }
58
+
59
+ export interface CrossrefConfig {
60
+ figureTitle?: string;
61
+ tableTitle?: string;
62
+ figPrefix?: string | string[];
63
+ tblPrefix?: string | string[];
64
+ }
65
+
66
+ export interface PdfConfig {
67
+ documentclass?: string;
68
+ fontsize?: string;
69
+ geometry?: string;
70
+ linestretch?: number;
71
+ toc?: boolean;
72
+ /**
73
+ * LaTeX engine to use for PDF output. One of `pdflatex` (default),
74
+ * `xelatex`, `lualatex`, `tectonic`, etc. xelatex/lualatex are required
75
+ * for native UTF-8 rendering of diacritics in author names, place
76
+ * names, and species epithets.
77
+ */
78
+ engine?: string;
79
+ /** Roman/serif main font (xelatex/lualatex only — uses fontspec). */
80
+ mainfont?: string;
81
+ /** Sans-serif font (xelatex/lualatex only). */
82
+ sansfont?: string;
83
+ /** Monospace font (xelatex/lualatex only). */
84
+ monofont?: string;
85
+ numbersections?: boolean;
86
+ template?: string;
87
+ headerIncludes?: string;
88
+ }
89
+
90
+ export interface DocxConfig {
91
+ reference?: string;
92
+ keepComments?: boolean;
93
+ toc?: boolean;
94
+ }
95
+
96
+ export interface BuildConfig {
97
+ title?: string;
98
+ authors?: Author[];
99
+ sections?: string[];
100
+ bibliography?: string;
101
+ csl?: string;
102
+ crossref?: CrossrefConfig;
103
+ pdf?: PdfConfig;
104
+ docx?: DocxConfig;
105
+ postprocess?: { [key: string]: string };
106
+ _configPath?: string;
107
+ [key: string]: unknown;
108
+ }
109
+
110
+ export interface BuildResult {
111
+ format: string;
112
+ output: string;
113
+ success: boolean;
114
+ error?: string;
115
+ }
116
+
117
+ // ============================================
118
+ // Citations
119
+ // ============================================
120
+
121
+ export interface Citation {
122
+ key: string;
123
+ line: number;
124
+ file: string;
125
+ }
126
+
127
+ export interface CitationValidation {
128
+ valid: Citation[];
129
+ missing: Citation[];
130
+ unused: string[];
131
+ duplicates: Array<{ key: string; count: number; locations: Citation[] }>;
132
+ }
133
+
134
+ export interface CitationStats {
135
+ totalCitations: number;
136
+ uniqueCited: number;
137
+ valid: number;
138
+ missing: number;
139
+ missingKeys: string[];
140
+ bibEntries: number;
141
+ unused: number;
142
+ unusedKeys: string[];
143
+ }
144
+
145
+ // ============================================
146
+ // Crossref
147
+ // ============================================
148
+
149
+ export interface RefNumber {
150
+ num: number;
151
+ isSupp: boolean;
152
+ suffix: string | null;
153
+ }
154
+
155
+ export interface HardcodedRef {
156
+ type: 'fig' | 'tbl' | 'eq';
157
+ match: string;
158
+ numbers: RefNumber[];
159
+ position: number;
160
+ }
161
+
162
+ export interface DynamicRef {
163
+ type: 'fig' | 'tbl' | 'eq';
164
+ label: string;
165
+ match: string;
166
+ position: number;
167
+ }
168
+
169
+ export interface FigureInfo {
170
+ label: string;
171
+ num: number;
172
+ isSupp: boolean;
173
+ file: string;
174
+ }
175
+
176
+ export interface Registry {
177
+ figures: Map<string, FigureInfo>;
178
+ tables: Map<string, FigureInfo>;
179
+ equations: Map<string, FigureInfo>;
180
+ byNumber: {
181
+ fig: Map<number, string>;
182
+ figS: Map<number, string>;
183
+ tbl: Map<number, string>;
184
+ tblS: Map<number, string>;
185
+ eq: Map<number, string>;
186
+ };
187
+ }
188
+
189
+ export interface RefStatus {
190
+ dynamic: DynamicRef[];
191
+ hardcoded: HardcodedRef[];
192
+ anchors: { figures: number; tables: number; equations: number };
193
+ }
194
+
195
+ export interface ConversionResult {
196
+ converted: string;
197
+ conversions: Array<{ from: string; to: string }>;
198
+ warnings: string[];
199
+ }
200
+
201
+ // ============================================
202
+ // DOI
203
+ // ============================================
204
+
205
+ export interface BibEntry {
206
+ key: string;
207
+ type: string;
208
+ doi: string | null;
209
+ title: string;
210
+ authorRaw: string;
211
+ year: number | null;
212
+ journal: string;
213
+ skip: boolean;
214
+ expectDoi: boolean;
215
+ noDoi: boolean;
216
+ line: number;
217
+ }
218
+
219
+ export interface DoiCheckResult {
220
+ valid: boolean;
221
+ source?: 'crossref' | 'datacite' | 'doi.org';
222
+ /**
223
+ * True when the registry could not be reached (network error, timeout, or
224
+ * 5xx) — the DOI's validity is unknown, distinct from a definitive "not
225
+ * found". Callers must not report an unreachable DOI as invalid.
226
+ */
227
+ unreachable?: boolean;
228
+ metadata?: {
229
+ title: string;
230
+ authors: string[];
231
+ year: number;
232
+ journal: string;
233
+ type?: string;
234
+ };
235
+ error?: string;
236
+ }
237
+
238
+ export interface BibtexFetchResult {
239
+ success: boolean;
240
+ bibtex?: string;
241
+ error?: string;
242
+ }
243
+
244
+ export interface DoiLookupResult {
245
+ found: boolean;
246
+ doi?: string;
247
+ confidence?: 'low' | 'medium' | 'high';
248
+ score?: number;
249
+ metadata?: {
250
+ title: string;
251
+ authors: string[];
252
+ year: number;
253
+ journal: string;
254
+ };
255
+ alternatives?: Array<{
256
+ doi: string;
257
+ title: string;
258
+ score: number;
259
+ }>;
260
+ error?: string;
261
+ }
262
+
263
+ export interface BibCheckResult {
264
+ entries: Array<BibEntry & { status: string; message?: string; metadata?: object }>;
265
+ valid: number;
266
+ invalid: number;
267
+ /** DOIs whose registry could not be reached (network/timeout) — not invalid. */
268
+ unreachable: number;
269
+ missing: number;
270
+ skipped: number;
271
+ }
272
+
273
+ // ============================================
274
+ // Equations
275
+ // ============================================
276
+
277
+ export interface Equation {
278
+ type: 'inline' | 'display';
279
+ content: string;
280
+ line: number;
281
+ file: string;
282
+ }
283
+
284
+ export interface EquationStats {
285
+ total: number;
286
+ display: number;
287
+ inline: number;
288
+ byFile: Array<{ file: string; display: number; inline: number }>;
289
+ }
290
+
291
+ export interface WordEquationResult {
292
+ success: boolean;
293
+ equations: Array<{
294
+ type: 'inline' | 'display' | 'unknown';
295
+ latex: string | null;
296
+ position: number;
297
+ line?: number;
298
+ raw?: string;
299
+ error?: string;
300
+ }>;
301
+ error?: string;
302
+ }
303
+
304
+ // ============================================
305
+ // Git
306
+ // ============================================
307
+
308
+ export interface FileChange {
309
+ added: number;
310
+ removed: number;
311
+ changes: Array<{ added?: boolean; removed?: boolean; value: string }>;
312
+ }
313
+
314
+ export interface CommitInfo {
315
+ hash: string;
316
+ date: string;
317
+ author: string;
318
+ message: string;
319
+ }
320
+
321
+ export interface ChangedFile {
322
+ file: string;
323
+ status: 'added' | 'deleted' | 'modified';
324
+ }
325
+
326
+ export interface BlameEntry {
327
+ line: number;
328
+ author: string;
329
+ date: string;
330
+ hash: string;
331
+ content: string;
332
+ }
333
+
334
+ export interface AuthorStats {
335
+ lines: number;
336
+ percentage: number;
337
+ }
338
+
339
+ export interface ContributorStats {
340
+ lines: number;
341
+ files: number;
342
+ }
343
+
344
+ // ============================================
345
+ // Journals
346
+ // ============================================
347
+
348
+ export interface JournalRequirements {
349
+ wordLimit?: { main?: number; abstract?: number };
350
+ references?: { max?: number; doiRequired?: boolean };
351
+ figures?: { max?: number };
352
+ tables?: { max?: number };
353
+ sections?: string[];
354
+ }
355
+
356
+ export interface JournalFormatting {
357
+ csl?: string;
358
+ pdf?: {
359
+ documentclass?: string;
360
+ fontsize?: string;
361
+ geometry?: string;
362
+ linestretch?: number;
363
+ template?: string;
364
+ numbersections?: boolean;
365
+ engine?: string;
366
+ mainfont?: string;
367
+ sansfont?: string;
368
+ monofont?: string;
369
+ };
370
+ docx?: {
371
+ reference?: string;
372
+ };
373
+ crossref?: {
374
+ figPrefix?: string | string[];
375
+ tblPrefix?: string | string[];
376
+ };
377
+ }
378
+
379
+ export interface JournalProfile {
380
+ name: string;
381
+ url: string;
382
+ requirements: JournalRequirements;
383
+ formatting?: JournalFormatting;
384
+ }
385
+
386
+ export interface ValidationResult {
387
+ journal: string;
388
+ valid: boolean;
389
+ wordCount: { main: number; abstract: number; limit: { main: number; abstract: number } };
390
+ figures: { count: number; max: number };
391
+ tables: { count: number; max: number };
392
+ references: { count: number; max: number };
393
+ sections: { found: string[]; missing: string[]; required: string[] };
394
+ errors: string[];
395
+ warnings: string[];
396
+ }
397
+
398
+ // ============================================
399
+ // Merge
400
+ // ============================================
401
+
402
+ export interface ReviewerChange {
403
+ reviewer: string;
404
+ type: 'insert' | 'delete' | 'replace';
405
+ start: number;
406
+ end: number;
407
+ oldText: string;
408
+ newText: string;
409
+ }
410
+
411
+ export interface Conflict {
412
+ id: string;
413
+ start: number;
414
+ end: number;
415
+ original: string;
416
+ changes: ReviewerChange[];
417
+ section?: string;
418
+ line?: number;
419
+ resolved: string | null;
420
+ }
421
+
422
+ export interface MergeResult {
423
+ merged: string;
424
+ conflicts: Conflict[];
425
+ stats: {
426
+ reviewers: number;
427
+ totalChanges: number;
428
+ nonConflicting: number;
429
+ conflicts: number;
430
+ comments: number;
431
+ };
432
+ originalText: string;
433
+ }
434
+
435
+ // ============================================
436
+ // Sections
437
+ // ============================================
438
+
439
+ export interface SectionConfig {
440
+ header: string;
441
+ aliases?: string[];
442
+ order?: number;
443
+ }
444
+
445
+ export interface SectionsConfig {
446
+ version: number;
447
+ description?: string;
448
+ sections: Record<string, SectionConfig>;
449
+ }
450
+
451
+ export interface ExtractedSection {
452
+ file: string;
453
+ header: string;
454
+ content: string;
455
+ matched: boolean;
456
+ }
457
+
458
+ // ============================================
459
+ // Word
460
+ // ============================================
461
+
462
+ export interface WordComment {
463
+ id: string;
464
+ author: string;
465
+ date?: string;
466
+ text: string;
467
+ }
468
+
469
+ export interface WordMetadata {
470
+ title?: string;
471
+ author?: string;
472
+ created?: string;
473
+ modified?: string;
474
+ }
475
+
476
+ export interface CommentAnchor {
477
+ text: string;
478
+ context: string;
479
+ }
480
+
481
+ export interface WordContent {
482
+ text: string;
483
+ html: string;
484
+ }
485
+
486
+ export interface TrackChangesResult {
487
+ hasTrackChanges: boolean;
488
+ content: string | null;
489
+ stats: { insertions: number; deletions: number };
490
+ }
491
+
492
+ // ============================================
493
+ // Spelling
494
+ // ============================================
495
+
496
+ export interface SpellingIssue {
497
+ word: string;
498
+ line: number;
499
+ column: number;
500
+ file?: string;
501
+ suggestions?: string[];
502
+ }
503
+
504
+ export interface SpellingResult {
505
+ misspelled: SpellingIssue[];
506
+ possibleNames: SpellingIssue[];
507
+ }
508
+
509
+ // ============================================
510
+ // Config
511
+ // ============================================
512
+
513
+ export interface UserConfig {
514
+ userName?: string;
515
+ defaultSections?: string[];
516
+ }
517
+
518
+ // ============================================
519
+ // DOI Cache
520
+ // ============================================
521
+
522
+ export interface DoiCacheEntry {
523
+ result: DoiCheckResult | DoiLookupResult;
524
+ timestamp: number;
525
+ }
526
+
527
+ export interface DoiCache {
528
+ entries: Record<string, DoiCacheEntry>;
529
+ version: number;
530
+ }
531
+
532
+ export interface DoiCacheStats {
533
+ size: number;
534
+ path: string;
535
+ }
536
+
537
+ // ============================================
538
+ // Errors
539
+ // ============================================
540
+
541
+ export interface ErrorInfo {
542
+ code: string;
543
+ message: string;
544
+ help?: string;
545
+ cause?: Error;
546
+ }