docrev 0.9.4 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/lib/commands/comments.d.ts.map +1 -1
  2. package/dist/lib/commands/comments.js +19 -27
  3. package/dist/lib/commands/comments.js.map +1 -1
  4. package/dist/lib/commands/context.d.ts +1 -0
  5. package/dist/lib/commands/context.d.ts.map +1 -1
  6. package/dist/lib/commands/context.js +1 -2
  7. package/dist/lib/commands/context.js.map +1 -1
  8. package/dist/lib/commands/file-ops.d.ts +11 -0
  9. package/dist/lib/commands/file-ops.d.ts.map +1 -0
  10. package/dist/lib/commands/file-ops.js +301 -0
  11. package/dist/lib/commands/file-ops.js.map +1 -0
  12. package/dist/lib/commands/index.d.ts +9 -1
  13. package/dist/lib/commands/index.d.ts.map +1 -1
  14. package/dist/lib/commands/index.js +17 -1
  15. package/dist/lib/commands/index.js.map +1 -1
  16. package/dist/lib/commands/merge-resolve.d.ts +12 -0
  17. package/dist/lib/commands/merge-resolve.d.ts.map +1 -0
  18. package/dist/lib/commands/merge-resolve.js +318 -0
  19. package/dist/lib/commands/merge-resolve.js.map +1 -0
  20. package/dist/lib/commands/preview.d.ts +11 -0
  21. package/dist/lib/commands/preview.d.ts.map +1 -0
  22. package/dist/lib/commands/preview.js +138 -0
  23. package/dist/lib/commands/preview.js.map +1 -0
  24. package/dist/lib/commands/project-info.d.ts +11 -0
  25. package/dist/lib/commands/project-info.d.ts.map +1 -0
  26. package/dist/lib/commands/project-info.js +187 -0
  27. package/dist/lib/commands/project-info.js.map +1 -0
  28. package/dist/lib/commands/quality.d.ts +11 -0
  29. package/dist/lib/commands/quality.d.ts.map +1 -0
  30. package/dist/lib/commands/quality.js +384 -0
  31. package/dist/lib/commands/quality.js.map +1 -0
  32. package/dist/lib/commands/sections.d.ts +3 -2
  33. package/dist/lib/commands/sections.d.ts.map +1 -1
  34. package/dist/lib/commands/sections.js +4 -723
  35. package/dist/lib/commands/sections.js.map +1 -1
  36. package/dist/lib/commands/sync.d.ts +11 -0
  37. package/dist/lib/commands/sync.d.ts.map +1 -0
  38. package/dist/lib/commands/sync.js +441 -0
  39. package/dist/lib/commands/sync.js.map +1 -0
  40. package/dist/lib/commands/text-ops.d.ts +11 -0
  41. package/dist/lib/commands/text-ops.d.ts.map +1 -0
  42. package/dist/lib/commands/text-ops.js +357 -0
  43. package/dist/lib/commands/text-ops.js.map +1 -0
  44. package/dist/lib/commands/utilities.d.ts +2 -4
  45. package/dist/lib/commands/utilities.d.ts.map +1 -1
  46. package/dist/lib/commands/utilities.js +3 -1605
  47. package/dist/lib/commands/utilities.js.map +1 -1
  48. package/dist/lib/commands/word-tools.d.ts +11 -0
  49. package/dist/lib/commands/word-tools.d.ts.map +1 -0
  50. package/dist/lib/commands/word-tools.js +272 -0
  51. package/dist/lib/commands/word-tools.js.map +1 -0
  52. package/dist/lib/comment-realign.d.ts.map +1 -1
  53. package/dist/lib/comment-realign.js +0 -7
  54. package/dist/lib/comment-realign.js.map +1 -1
  55. package/dist/lib/dependencies.d.ts.map +1 -1
  56. package/dist/lib/dependencies.js +11 -23
  57. package/dist/lib/dependencies.js.map +1 -1
  58. package/dist/lib/diff-engine.d.ts +25 -0
  59. package/dist/lib/diff-engine.d.ts.map +1 -0
  60. package/dist/lib/diff-engine.js +354 -0
  61. package/dist/lib/diff-engine.js.map +1 -0
  62. package/dist/lib/git.d.ts.map +1 -1
  63. package/dist/lib/git.js +18 -28
  64. package/dist/lib/git.js.map +1 -1
  65. package/dist/lib/import.d.ts +37 -117
  66. package/dist/lib/import.d.ts.map +1 -1
  67. package/dist/lib/import.js +10 -1039
  68. package/dist/lib/import.js.map +1 -1
  69. package/dist/lib/merge.d.ts.map +1 -1
  70. package/dist/lib/merge.js +29 -117
  71. package/dist/lib/merge.js.map +1 -1
  72. package/dist/lib/pdf-comments.d.ts.map +1 -1
  73. package/dist/lib/pdf-comments.js +1 -13
  74. package/dist/lib/pdf-comments.js.map +1 -1
  75. package/dist/lib/pptx-themes.d.ts.map +1 -1
  76. package/dist/lib/pptx-themes.js +0 -403
  77. package/dist/lib/pptx-themes.js.map +1 -1
  78. package/dist/lib/protect-restore.d.ts.map +1 -1
  79. package/dist/lib/protect-restore.js +34 -36
  80. package/dist/lib/protect-restore.js.map +1 -1
  81. package/dist/lib/restore-references.d.ts +35 -0
  82. package/dist/lib/restore-references.d.ts.map +1 -0
  83. package/dist/lib/restore-references.js +188 -0
  84. package/dist/lib/restore-references.js.map +1 -0
  85. package/dist/lib/slides.d.ts.map +1 -1
  86. package/dist/lib/slides.js +0 -35
  87. package/dist/lib/slides.js.map +1 -1
  88. package/dist/lib/trackchanges.d.ts.map +1 -1
  89. package/dist/lib/trackchanges.js +1 -11
  90. package/dist/lib/trackchanges.js.map +1 -1
  91. package/dist/lib/tui.d.ts +36 -45
  92. package/dist/lib/tui.d.ts.map +1 -1
  93. package/dist/lib/tui.js +92 -108
  94. package/dist/lib/tui.js.map +1 -1
  95. package/dist/lib/undo.d.ts +3 -4
  96. package/dist/lib/undo.d.ts.map +1 -1
  97. package/dist/lib/undo.js +0 -7
  98. package/dist/lib/undo.js.map +1 -1
  99. package/dist/lib/utils.d.ts +12 -0
  100. package/dist/lib/utils.d.ts.map +1 -1
  101. package/dist/lib/utils.js +26 -0
  102. package/dist/lib/utils.js.map +1 -1
  103. package/dist/lib/word-extraction.d.ts +77 -0
  104. package/dist/lib/word-extraction.d.ts.map +1 -0
  105. package/dist/lib/word-extraction.js +515 -0
  106. package/dist/lib/word-extraction.js.map +1 -0
  107. package/dist/lib/wordcomments.d.ts.map +1 -1
  108. package/dist/lib/wordcomments.js +1 -8
  109. package/dist/lib/wordcomments.js.map +1 -1
  110. package/dist/package.json +137 -0
  111. package/lib/commands/comments.ts +20 -25
  112. package/lib/commands/context.ts +1 -2
  113. package/lib/commands/file-ops.ts +372 -0
  114. package/lib/commands/index.ts +24 -0
  115. package/lib/commands/merge-resolve.ts +378 -0
  116. package/lib/commands/preview.ts +178 -0
  117. package/lib/commands/project-info.ts +244 -0
  118. package/lib/commands/quality.ts +517 -0
  119. package/lib/commands/sections.ts +3 -857
  120. package/lib/commands/sync.ts +536 -0
  121. package/lib/commands/text-ops.ts +449 -0
  122. package/lib/commands/utilities.ts +62 -2066
  123. package/lib/commands/word-tools.ts +340 -0
  124. package/lib/comment-realign.ts +0 -8
  125. package/lib/dependencies.ts +12 -20
  126. package/lib/diff-engine.ts +465 -0
  127. package/lib/git.ts +24 -31
  128. package/lib/import.ts +78 -1348
  129. package/lib/merge.ts +42 -132
  130. package/lib/pdf-comments.ts +2 -14
  131. package/lib/pptx-themes.ts +0 -413
  132. package/lib/protect-restore.ts +48 -44
  133. package/lib/restore-references.ts +240 -0
  134. package/lib/slides.ts +0 -37
  135. package/lib/trackchanges.ts +1 -12
  136. package/lib/{tui.js → tui.ts} +139 -126
  137. package/lib/undo.ts +3 -12
  138. package/lib/utils.ts +28 -0
  139. package/lib/word-extraction.ts +666 -0
  140. package/lib/wordcomments.ts +1 -9
  141. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../lib/commands/preview.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,KAAK,EACL,EAAE,EAEF,GAAG,EACH,eAAe,GAChB,MAAM,cAAc,CAAC;AActB;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,6EAA6E;IAC7E,4CAA4C;IAC5C,6EAA6E;IAE7E,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,wCAAwC,CAAC;SACrD,QAAQ,CAAC,UAAU,EAAE,8BAA8B,EAAE,KAAK,CAAC;SAC3D,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,QAAwB,EAAE,EAAE;QACzD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;QAC/C,MAAM,EAA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CAAC,GAAG,OAAO,CAAC,CAAC;gBAClF,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC;YAElF,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;oBACxC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;gBACpE,IAAI,CAAC,GAAG,OAAO,KAAK,UAAU,GAAG,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAED,cAAc;QACd,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAChC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,EAAE,EAAE;gBACjD,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;oBAC3B,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Project information commands: word-count (wc), stats, search
3
+ *
4
+ * Read-only queries about the project state.
5
+ */
6
+ import type { Command } from 'commander';
7
+ /**
8
+ * Register project-info commands with the program
9
+ */
10
+ export declare function register(program: Command): void;
11
+ //# sourceMappingURL=project-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-info.d.ts","sourceRoot":"","sources":["../../../lib/commands/project-info.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+BzC;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2M/C"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Project information commands: word-count (wc), stats, search
3
+ *
4
+ * Read-only queries about the project state.
5
+ */
6
+ import { chalk, fs, fmt, loadBuildConfig, getComments, countWords, } from './context.js';
7
+ /**
8
+ * Register project-info commands with the program
9
+ */
10
+ export function register(program) {
11
+ // ==========================================================================
12
+ // WORD-COUNT command - Per-section word counts
13
+ // ==========================================================================
14
+ program
15
+ .command('word-count')
16
+ .alias('wc')
17
+ .description('Show word counts per section')
18
+ .option('-l, --limit <number>', 'Warn if total exceeds limit', parseInt)
19
+ .option('-j, --journal <name>', 'Use journal word limit')
20
+ .action(async (options) => {
21
+ let config = {};
22
+ try {
23
+ config = loadBuildConfig('.') || {};
24
+ }
25
+ catch {
26
+ // Not in a rev project, that's ok
27
+ }
28
+ const sections = config.sections || [];
29
+ if (sections.length === 0) {
30
+ // Try to find .md files
31
+ const mdFiles = fs.readdirSync('.').filter(f => f.endsWith('.md') && !['README.md', 'CLAUDE.md', 'paper.md'].includes(f));
32
+ if (mdFiles.length === 0) {
33
+ console.error(chalk.red('No section files found. Run from a rev project directory.'));
34
+ process.exit(1);
35
+ }
36
+ sections.push(...mdFiles);
37
+ }
38
+ let total = 0;
39
+ const rows = [];
40
+ for (const section of sections) {
41
+ if (!fs.existsSync(section))
42
+ continue;
43
+ const text = fs.readFileSync(section, 'utf-8');
44
+ const words = countWords(text);
45
+ total += words;
46
+ rows.push([section, words.toLocaleString()]);
47
+ }
48
+ rows.push(['', '']);
49
+ rows.push([chalk.bold('Total'), chalk.bold(total.toLocaleString())]);
50
+ console.log(fmt.header('Word Count'));
51
+ console.log(fmt.table(['Section', 'Words'], rows));
52
+ // Check limit
53
+ let limit = options.limit;
54
+ if (options.journal) {
55
+ const { getJournalProfile } = await import('../journals.js');
56
+ const profile = getJournalProfile(options.journal);
57
+ if (profile?.requirements?.wordLimit?.main) {
58
+ limit = profile.requirements.wordLimit.main;
59
+ console.log(chalk.dim(`\nUsing ${profile.name} word limit: ${limit.toLocaleString()}`));
60
+ }
61
+ }
62
+ if (limit && total > limit) {
63
+ console.log(chalk.red(`\n⚠ Over limit by ${(total - limit).toLocaleString()} words`));
64
+ }
65
+ else if (limit) {
66
+ console.log(chalk.green(`\n✓ Within limit (${(limit - total).toLocaleString()} words remaining)`));
67
+ }
68
+ });
69
+ // ==========================================================================
70
+ // STATS command - Project dashboard
71
+ // ==========================================================================
72
+ program
73
+ .command('stats')
74
+ .description('Show project statistics dashboard')
75
+ .action(async (_options) => {
76
+ let config = {};
77
+ try {
78
+ config = loadBuildConfig('.') || {};
79
+ }
80
+ catch {
81
+ // Not in a rev project, that's ok
82
+ }
83
+ let sections = config.sections || [];
84
+ if (sections.length === 0) {
85
+ sections = fs.readdirSync('.').filter(f => f.endsWith('.md') && !['README.md', 'CLAUDE.md', 'paper.md'].includes(f));
86
+ }
87
+ let totalWords = 0;
88
+ let totalFigures = 0;
89
+ let totalTables = 0;
90
+ let totalComments = 0;
91
+ let pendingComments = 0;
92
+ const citations = new Set();
93
+ for (const section of sections) {
94
+ if (!fs.existsSync(section))
95
+ continue;
96
+ const text = fs.readFileSync(section, 'utf-8');
97
+ totalWords += countWords(text);
98
+ totalFigures += (text.match(/!\[.*?\]\(.*?\)/g) || []).length;
99
+ totalTables += (text.match(/^\|[^|]+\|/gm) || []).length / 5; // Approximate
100
+ const comments = getComments(text);
101
+ totalComments += comments.length;
102
+ pendingComments += comments.filter(c => !c.resolved).length;
103
+ const cites = text.match(/@(\w+)(?![:\w])/g) || [];
104
+ cites.forEach(c => citations.add(c.slice(1)));
105
+ }
106
+ console.log(fmt.header('Project Statistics'));
107
+ console.log();
108
+ const stats = [
109
+ ['Sections', sections.length],
110
+ ['Words', totalWords.toLocaleString()],
111
+ ['Figures', Math.round(totalFigures)],
112
+ ['Tables', Math.round(totalTables)],
113
+ ['Citations', citations.size],
114
+ ['Comments', `${totalComments} (${pendingComments} pending)`],
115
+ ];
116
+ for (const [label, value] of stats) {
117
+ console.log(` ${chalk.dim(label.padEnd(12))} ${chalk.bold(value)}`);
118
+ }
119
+ // Bibliography stats
120
+ const bibPath = config.bibliography || 'references.bib';
121
+ if (fs.existsSync(bibPath)) {
122
+ const bibContent = fs.readFileSync(bibPath, 'utf-8');
123
+ const bibEntries = (bibContent.match(/@\w+\s*\{/g) || []).length;
124
+ console.log(` ${chalk.dim('Bib entries'.padEnd(12))} ${chalk.bold(bibEntries)}`);
125
+ }
126
+ console.log();
127
+ });
128
+ // ==========================================================================
129
+ // SEARCH command - Search across section files
130
+ // ==========================================================================
131
+ program
132
+ .command('search')
133
+ .description('Search across all section files')
134
+ .argument('<query>', 'Search query (supports regex)')
135
+ .option('-i, --ignore-case', 'Case-insensitive search')
136
+ .option('-c, --context <lines>', 'Show context lines', parseInt, 1)
137
+ .action((query, options) => {
138
+ let config = {};
139
+ try {
140
+ config = loadBuildConfig('.') || {};
141
+ }
142
+ catch {
143
+ // Not in a rev project, that's ok
144
+ }
145
+ let sections = config.sections || [];
146
+ if (sections.length === 0) {
147
+ sections = fs.readdirSync('.').filter(f => f.endsWith('.md') && !['README.md', 'CLAUDE.md'].includes(f));
148
+ }
149
+ const flags = options.ignoreCase ? 'gi' : 'g';
150
+ let pattern;
151
+ try {
152
+ pattern = new RegExp(query, flags);
153
+ }
154
+ catch {
155
+ pattern = new RegExp(query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), flags);
156
+ }
157
+ let totalMatches = 0;
158
+ for (const section of sections) {
159
+ if (!fs.existsSync(section))
160
+ continue;
161
+ const text = fs.readFileSync(section, 'utf-8');
162
+ const lines = text.split('\n');
163
+ const matches = [];
164
+ for (let i = 0; i < lines.length; i++) {
165
+ if (pattern.test(lines[i])) {
166
+ matches.push({ line: i + 1, text: lines[i] });
167
+ pattern.lastIndex = 0;
168
+ }
169
+ }
170
+ if (matches.length > 0) {
171
+ console.log(chalk.cyan.bold(`\n${section}`));
172
+ for (const match of matches) {
173
+ const highlighted = match.text.replace(pattern, (m) => chalk.yellow.bold(m));
174
+ console.log(` ${chalk.dim(match.line + ':')} ${highlighted}`);
175
+ }
176
+ totalMatches += matches.length;
177
+ }
178
+ }
179
+ if (totalMatches === 0) {
180
+ console.log(chalk.yellow(`No matches found for "${query}"`));
181
+ }
182
+ else {
183
+ console.log(chalk.dim(`\n${totalMatches} match${totalMatches === 1 ? '' : 'es'} found`));
184
+ }
185
+ });
186
+ }
187
+ //# sourceMappingURL=project-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-info.js","sourceRoot":"","sources":["../../../lib/commands/project-info.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,KAAK,EACL,EAAE,EAEF,GAAG,EAEH,eAAe,EAEf,WAAW,EACX,UAAU,GACX,MAAM,cAAc,CAAC;AAoBtB;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,6EAA6E;IAC7E,+CAA+C;IAC/C,6EAA6E;IAE7E,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,KAAK,CAAC,IAAI,CAAC;SACX,WAAW,CAAC,8BAA8B,CAAC;SAC3C,MAAM,CAAC,sBAAsB,EAAE,6BAA6B,EAAE,QAAQ,CAAC;SACvE,MAAM,CAAC,sBAAsB,EAAE,wBAAwB,CAAC;SACxD,MAAM,CAAC,KAAK,EAAE,OAAyB,EAAE,EAAE;QAC1C,IAAI,MAAM,GAAyB,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACtC,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;QAEvC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,wBAAwB;YACxB,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MA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AAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;gBAC7C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;oBAC5B,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC7E,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC;gBACjE,CAAC;gBACD,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;YACjC,CAAC;QACH,CAAC;QAED,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,yBAAyB,KAAK,GAAG,CAAC,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,YAAY,SAAS,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Quality commands: lint, grammar, check
3
+ *
4
+ * Commands for checking project quality before submission.
5
+ */
6
+ import type { Command } from 'commander';
7
+ /**
8
+ * Register quality commands with the program
9
+ */
10
+ export declare function register(program: Command): void;
11
+ //# sourceMappingURL=quality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quality.d.ts","sourceRoot":"","sources":["../../../lib/commands/quality.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8EzC;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6a/C"}
@@ -0,0 +1,384 @@
1
+ /**
2
+ * Quality commands: lint, grammar, check
3
+ *
4
+ * Commands for checking project quality before submission.
5
+ */
6
+ import { chalk, fs, fmt, loadBuildConfig, getComments, } from './context.js';
7
+ /**
8
+ * Register quality commands with the program
9
+ */
10
+ export function register(program) {
11
+ // ==========================================================================
12
+ // LINT command - Check for common issues
13
+ // ==========================================================================
14
+ program
15
+ .command('lint')
16
+ .description('Check for common issues in the project')
17
+ .option('--fix', 'Auto-fix issues where possible')
18
+ .action(async (_options) => {
19
+ let config = {};
20
+ try {
21
+ config = loadBuildConfig('.') || {};
22
+ }
23
+ catch {
24
+ // Not in a rev project, that's ok
25
+ }
26
+ let sections = config.sections || [];
27
+ if (sections.length === 0) {
28
+ sections = fs.readdirSync('.').filter(f => f.endsWith('.md') && !['README.md', 'CLAUDE.md', 'paper.md'].includes(f));
29
+ }
30
+ const issues = [];
31
+ const warnings = [];
32
+ // Collect all content
33
+ let allText = '';
34
+ for (const section of sections) {
35
+ if (fs.existsSync(section)) {
36
+ allText += fs.readFileSync(section, 'utf-8') + '\n';
37
+ }
38
+ }
39
+ // Check 1: Broken cross-references
40
+ const figAnchors = new Set();
41
+ const tblAnchors = new Set();
42
+ const eqAnchors = new Set();
43
+ const anchorPattern = /\{#(fig|tbl|eq):([^}]+)\}/g;
44
+ let match;
45
+ while ((match = anchorPattern.exec(allText)) !== null) {
46
+ if (match[1] === 'fig')
47
+ figAnchors.add(match[2]);
48
+ else if (match[1] === 'tbl')
49
+ tblAnchors.add(match[2]);
50
+ else if (match[1] === 'eq')
51
+ eqAnchors.add(match[2]);
52
+ }
53
+ const refPattern = /@(fig|tbl|eq):([a-zA-Z0-9_-]+)/g;
54
+ while ((match = refPattern.exec(allText)) !== null) {
55
+ const type = match[1];
56
+ const label = match[2];
57
+ const anchors = type === 'fig' ? figAnchors : type === 'tbl' ? tblAnchors : eqAnchors;
58
+ if (!anchors.has(label)) {
59
+ issues.push({
60
+ type: 'error',
61
+ message: `Broken reference: @${type}:${label}`,
62
+ fix: null
63
+ });
64
+ }
65
+ }
66
+ // Check 2: Orphaned figures
67
+ for (const label of figAnchors) {
68
+ if (!allText.includes(`@fig:${label}`)) {
69
+ warnings.push({
70
+ type: 'warning',
71
+ message: `Unreferenced figure: {#fig:${label}}`,
72
+ });
73
+ }
74
+ }
75
+ // Check 3: Missing citations
76
+ const bibPath = config.bibliography || 'references.bib';
77
+ if (fs.existsSync(bibPath)) {
78
+ const bibContent = fs.readFileSync(bibPath, 'utf-8');
79
+ const bibKeys = new Set();
80
+ const bibPattern = /@\w+\s*\{\s*([^,]+)/g;
81
+ while ((match = bibPattern.exec(bibContent)) !== null) {
82
+ bibKeys.add(match[1].trim());
83
+ }
84
+ const citePattern = /@([a-zA-Z][a-zA-Z0-9_-]*)(?![:\w])/g;
85
+ while ((match = citePattern.exec(allText)) !== null) {
86
+ const key = match[1];
87
+ if (!bibKeys.has(key) && !['fig', 'tbl', 'eq'].includes(key)) {
88
+ issues.push({
89
+ type: 'error',
90
+ message: `Missing citation: @${key}`,
91
+ });
92
+ }
93
+ }
94
+ }
95
+ // Check 4: Unresolved comments
96
+ const comments = getComments(allText);
97
+ const pending = comments.filter(c => !c.resolved);
98
+ if (pending.length > 0) {
99
+ warnings.push({
100
+ type: 'warning',
101
+ message: `${pending.length} unresolved comment${pending.length === 1 ? '' : 's'}`,
102
+ });
103
+ }
104
+ // Check 5: Empty sections
105
+ for (const section of sections) {
106
+ if (fs.existsSync(section)) {
107
+ const content = fs.readFileSync(section, 'utf-8').trim();
108
+ if (content.length < 50) {
109
+ warnings.push({
110
+ type: 'warning',
111
+ message: `Section appears empty: ${section}`,
112
+ });
113
+ }
114
+ }
115
+ }
116
+ // Output results
117
+ console.log(fmt.header('Lint Results'));
118
+ console.log();
119
+ if (issues.length === 0 && warnings.length === 0) {
120
+ console.log(chalk.green('✓ No issues found'));
121
+ return;
122
+ }
123
+ for (const issue of issues) {
124
+ console.log(chalk.red(` ✗ ${issue.message}`));
125
+ }
126
+ for (const warning of warnings) {
127
+ console.log(chalk.yellow(` ⚠ ${warning.message}`));
128
+ }
129
+ console.log();
130
+ console.log(chalk.dim(`${issues.length} error${issues.length === 1 ? '' : 's'}, ${warnings.length} warning${warnings.length === 1 ? '' : 's'}`));
131
+ if (issues.length > 0) {
132
+ process.exit(1);
133
+ }
134
+ });
135
+ // ==========================================================================
136
+ // GRAMMAR command - Check grammar and style
137
+ // ==========================================================================
138
+ program
139
+ .command('grammar')
140
+ .description('Check grammar and style issues')
141
+ .argument('[files...]', 'Markdown files to check')
142
+ .option('--learn <word>', 'Add word to custom dictionary')
143
+ .option('--forget <word>', 'Remove word from custom dictionary')
144
+ .option('--list', 'List custom dictionary words')
145
+ .option('--rules', 'List available grammar rules')
146
+ .option('--no-scientific', 'Disable scientific writing rules')
147
+ .option('-s, --severity <level>', 'Minimum severity: error, warning, info', 'info')
148
+ .action(async (files, options) => {
149
+ const { checkGrammar, getGrammarSummary, loadDictionary, addToDictionary, removeFromDictionary, listRules, } = await import('../grammar.js');
150
+ // Handle dictionary management
151
+ if (options.learn) {
152
+ const added = addToDictionary(options.learn);
153
+ if (added) {
154
+ console.log(fmt.status('success', `Added "${options.learn}" to dictionary`));
155
+ }
156
+ else {
157
+ console.log(chalk.dim(`"${options.learn}" already in dictionary`));
158
+ }
159
+ return;
160
+ }
161
+ if (options.forget) {
162
+ const removed = removeFromDictionary(options.forget);
163
+ if (removed) {
164
+ console.log(fmt.status('success', `Removed "${options.forget}" from dictionary`));
165
+ }
166
+ else {
167
+ console.log(chalk.yellow(`"${options.forget}" not in dictionary`));
168
+ }
169
+ return;
170
+ }
171
+ if (options.list) {
172
+ const words = loadDictionary();
173
+ console.log(fmt.header('Custom Dictionary'));
174
+ console.log();
175
+ if (words.size === 0) {
176
+ console.log(chalk.dim(' No custom words defined'));
177
+ console.log(chalk.dim(' Use --learn <word> to add words'));
178
+ }
179
+ else {
180
+ const sorted = [...words].sort();
181
+ for (const word of sorted) {
182
+ console.log(` ${word}`);
183
+ }
184
+ console.log();
185
+ console.log(chalk.dim(`${words.size} word(s)`));
186
+ }
187
+ return;
188
+ }
189
+ if (options.rules) {
190
+ const rules = listRules(options.scientific);
191
+ console.log(fmt.header('Grammar Rules'));
192
+ console.log();
193
+ for (const rule of rules) {
194
+ const icon = rule.severity === 'error' ? chalk.red('●') :
195
+ rule.severity === 'warning' ? chalk.yellow('●') :
196
+ chalk.blue('●');
197
+ console.log(` ${icon} ${chalk.bold(rule.id)}`);
198
+ console.log(chalk.dim(` ${rule.message}`));
199
+ }
200
+ return;
201
+ }
202
+ // Get files to check
203
+ let mdFiles = files;
204
+ if (!mdFiles || mdFiles.length === 0) {
205
+ let config = {};
206
+ try {
207
+ config = loadBuildConfig('.') || {};
208
+ }
209
+ catch {
210
+ // Not in a rev project
211
+ }
212
+ mdFiles = config.sections || [];
213
+ if (mdFiles.length === 0) {
214
+ mdFiles = fs.readdirSync('.').filter(f => f.endsWith('.md') && !['README.md', 'CLAUDE.md', 'paper.md'].includes(f));
215
+ }
216
+ }
217
+ if (mdFiles.length === 0) {
218
+ console.error(chalk.red('No markdown files found'));
219
+ process.exit(1);
220
+ }
221
+ console.log(fmt.header('Grammar Check'));
222
+ console.log();
223
+ const severityLevels = { error: 3, warning: 2, info: 1 };
224
+ const minSeverity = severityLevels[options.severity || 'info'] || 1;
225
+ let allIssues = [];
226
+ for (const file of mdFiles) {
227
+ if (!fs.existsSync(file))
228
+ continue;
229
+ const text = fs.readFileSync(file, 'utf-8');
230
+ const issues = checkGrammar(text, { scientific: options.scientific });
231
+ // Filter by severity
232
+ const filtered = issues.filter((i) => severityLevels[i.severity] >= minSeverity);
233
+ if (filtered.length > 0) {
234
+ console.log(chalk.cyan.bold(file));
235
+ for (const issue of filtered) {
236
+ const icon = issue.severity === 'error' ? chalk.red('●') :
237
+ issue.severity === 'warning' ? chalk.yellow('●') :
238
+ chalk.blue('●');
239
+ console.log(` ${chalk.dim(`L${issue.line}:`)} ${icon} ${issue.message}`);
240
+ console.log(chalk.dim(` "${issue.match}" in: ${issue.context.slice(0, 60)}...`));
241
+ }
242
+ console.log();
243
+ allIssues.push(...filtered.map(i => ({ ...i, file })));
244
+ }
245
+ }
246
+ const summary = getGrammarSummary(allIssues);
247
+ if (summary.total === 0) {
248
+ console.log(chalk.green('✓ No issues found'));
249
+ }
250
+ else {
251
+ console.log(chalk.dim(`Found ${summary.total} issue(s): ${summary.errors} errors, ${summary.warnings} warnings, ${summary.info} info`));
252
+ console.log();
253
+ console.log(chalk.dim('Tip: Use --learn <word> to add words to dictionary'));
254
+ }
255
+ });
256
+ // ==========================================================================
257
+ // CHECK command - Pre-submission check
258
+ // ==========================================================================
259
+ program
260
+ .command('check')
261
+ .description('Run all checks before submission (lint + grammar + citations)')
262
+ .option('--fix', 'Auto-fix issues where possible')
263
+ .option('-s, --severity <level>', 'Minimum grammar severity', 'warning')
264
+ .action(async (options) => {
265
+ const { validateCitations } = await import('../citations.js');
266
+ const { checkGrammar, getGrammarSummary } = await import('../grammar.js');
267
+ console.log(fmt.header('Pre-Submission Check'));
268
+ console.log();
269
+ let hasErrors = false;
270
+ let totalIssues = 0;
271
+ // 1. Run lint
272
+ console.log(chalk.cyan.bold('1. Linting...'));
273
+ let config = {};
274
+ try {
275
+ config = loadBuildConfig('.') || {};
276
+ }
277
+ catch {
278
+ // Not in a rev project
279
+ }
280
+ let sections = config.sections || [];
281
+ if (sections.length === 0) {
282
+ sections = fs.readdirSync('.').filter(f => f.endsWith('.md') && !['README.md', 'CLAUDE.md', 'paper.md'].includes(f));
283
+ }
284
+ const lintIssues = [];
285
+ const lintWarnings = [];
286
+ for (const file of sections) {
287
+ if (!fs.existsSync(file))
288
+ continue;
289
+ const content = fs.readFileSync(file, 'utf-8');
290
+ // Check for broken cross-references
291
+ const refs = content.match(/@(fig|tbl|eq|sec):\w+/g) || [];
292
+ const anchors = content.match(/\{#(fig|tbl|eq|sec):[^}]+\}/g) || [];
293
+ const anchorLabels = anchors.map(a => a.match(/#([^}]+)/)[1]);
294
+ for (const ref of refs) {
295
+ const label = ref.slice(1);
296
+ if (!anchorLabels.includes(label)) {
297
+ lintIssues.push({ file, message: `Broken reference: ${ref}` });
298
+ }
299
+ }
300
+ // Check for unresolved comments
301
+ const unresolvedComments = (content.match(/\{>>[^<]*<<\}/g) || [])
302
+ .filter(c => !c.includes('[RESOLVED]'));
303
+ if (unresolvedComments.length > 0) {
304
+ lintWarnings.push({ file, message: `${unresolvedComments.length} unresolved comment(s)` });
305
+ }
306
+ }
307
+ if (lintIssues.length > 0) {
308
+ for (const issue of lintIssues) {
309
+ console.log(chalk.red(` ✗ ${issue.file}: ${issue.message}`));
310
+ }
311
+ hasErrors = true;
312
+ totalIssues += lintIssues.length;
313
+ }
314
+ for (const warning of lintWarnings) {
315
+ console.log(chalk.yellow(` ⚠ ${warning.file}: ${warning.message}`));
316
+ totalIssues++;
317
+ }
318
+ if (lintIssues.length === 0 && lintWarnings.length === 0) {
319
+ console.log(chalk.green(' ✓ No lint issues'));
320
+ }
321
+ console.log();
322
+ // 2. Run grammar check
323
+ console.log(chalk.cyan.bold('2. Grammar check...'));
324
+ const severityLevels = { error: 3, warning: 2, info: 1 };
325
+ const minSeverity = severityLevels[options.severity || 'warning'] || 2;
326
+ let grammarIssues = [];
327
+ for (const file of sections) {
328
+ if (!fs.existsSync(file))
329
+ continue;
330
+ const text = fs.readFileSync(file, 'utf-8');
331
+ const issues = checkGrammar(text, { scientific: true });
332
+ const filtered = issues.filter((i) => severityLevels[i.severity] >= minSeverity);
333
+ grammarIssues.push(...filtered.map(i => ({ ...i, file })));
334
+ }
335
+ const grammarSummary = getGrammarSummary(grammarIssues);
336
+ if (grammarSummary.errors > 0) {
337
+ hasErrors = true;
338
+ }
339
+ totalIssues += grammarSummary.total;
340
+ if (grammarSummary.total > 0) {
341
+ console.log(chalk.yellow(` ⚠ ${grammarSummary.total} grammar issue(s): ${grammarSummary.errors} errors, ${grammarSummary.warnings} warnings`));
342
+ }
343
+ else {
344
+ console.log(chalk.green(' ✓ No grammar issues'));
345
+ }
346
+ console.log();
347
+ // 3. Run citation check
348
+ console.log(chalk.cyan.bold('3. Citation check...'));
349
+ const bibFile = config.bibliography || 'references.bib';
350
+ if (fs.existsSync(bibFile)) {
351
+ const existingSections = sections.filter(f => fs.existsSync(f));
352
+ const result = validateCitations(existingSections, bibFile);
353
+ if (result.missing.length > 0) {
354
+ console.log(chalk.red(` ✗ ${result.missing.length} missing citation(s): ${result.missing.slice(0, 3).join(', ')}${result.missing.length > 3 ? '...' : ''}`));
355
+ hasErrors = true;
356
+ totalIssues += result.missing.length;
357
+ }
358
+ if (result.unused.length > 0) {
359
+ console.log(chalk.yellow(` ⚠ ${result.unused.length} unused citation(s)`));
360
+ totalIssues += result.unused.length;
361
+ }
362
+ if (result.missing.length === 0 && result.unused.length === 0) {
363
+ console.log(chalk.green(' ✓ All citations valid'));
364
+ }
365
+ }
366
+ else {
367
+ console.log(chalk.dim(' - No bibliography file found'));
368
+ }
369
+ console.log();
370
+ // Summary
371
+ console.log(chalk.bold('Summary'));
372
+ if (hasErrors) {
373
+ console.log(chalk.red(` ${totalIssues} issue(s) found. Please fix before submission.`));
374
+ process.exit(1);
375
+ }
376
+ else if (totalIssues > 0) {
377
+ console.log(chalk.yellow(` ${totalIssues} warning(s). Review before submission.`));
378
+ }
379
+ else {
380
+ console.log(chalk.green(' ✓ All checks passed! Ready for submission.'));
381
+ }
382
+ });
383
+ }
384
+ //# sourceMappingURL=quality.js.map