pgserve 0.1.1

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 (158) hide show
  1. package/.genie/AGENTS.md +13 -0
  2. package/.genie/agents/README.md +110 -0
  3. package/.genie/agents/analyze.md +176 -0
  4. package/.genie/agents/forge.md +290 -0
  5. package/.genie/agents/garbage-cleaner.md +324 -0
  6. package/.genie/agents/garbage-collector.md +596 -0
  7. package/.genie/agents/github-issue-gc.md +618 -0
  8. package/.genie/agents/review.md +380 -0
  9. package/.genie/agents/semantic-analyzer/find-duplicates.md +90 -0
  10. package/.genie/agents/semantic-analyzer/find-orphans.md +99 -0
  11. package/.genie/agents/semantic-analyzer.md +101 -0
  12. package/.genie/agents/update.md +182 -0
  13. package/.genie/agents/wish.md +357 -0
  14. package/.genie/code/AGENTS.md +692 -0
  15. package/.genie/code/agents/audit/risk.md +173 -0
  16. package/.genie/code/agents/audit/security.md +189 -0
  17. package/.genie/code/agents/audit.md +145 -0
  18. package/.genie/code/agents/challenge.md +230 -0
  19. package/.genie/code/agents/change-reviewer.md +295 -0
  20. package/.genie/code/agents/code-garbage-collector.md +425 -0
  21. package/.genie/code/agents/code-quality.md +410 -0
  22. package/.genie/code/agents/commit-suggester.md +255 -0
  23. package/.genie/code/agents/commit.md +124 -0
  24. package/.genie/code/agents/consensus.md +204 -0
  25. package/.genie/code/agents/daily-standup.md +722 -0
  26. package/.genie/code/agents/docgen.md +48 -0
  27. package/.genie/code/agents/explore.md +79 -0
  28. package/.genie/code/agents/fix.md +100 -0
  29. package/.genie/code/agents/git/commit-advisory.md +219 -0
  30. package/.genie/code/agents/git/workflows/issue.md +244 -0
  31. package/.genie/code/agents/git/workflows/pr.md +179 -0
  32. package/.genie/code/agents/git/workflows/release.md +460 -0
  33. package/.genie/code/agents/git/workflows/report.md +342 -0
  34. package/.genie/code/agents/git.md +432 -0
  35. package/.genie/code/agents/implementor.md +161 -0
  36. package/.genie/code/agents/install.md +515 -0
  37. package/.genie/code/agents/issue-creator.md +344 -0
  38. package/.genie/code/agents/polish.md +116 -0
  39. package/.genie/code/agents/qa.md +653 -0
  40. package/.genie/code/agents/refactor.md +294 -0
  41. package/.genie/code/agents/release.md +1129 -0
  42. package/.genie/code/agents/roadmap.md +885 -0
  43. package/.genie/code/agents/tests.md +557 -0
  44. package/.genie/code/agents/tracer.md +50 -0
  45. package/.genie/code/agents/update/upstream-update.md +85 -0
  46. package/.genie/code/agents/update/versions/generic-update.md +305 -0
  47. package/.genie/code/agents/vibe.md +1317 -0
  48. package/.genie/code/spells/agent-configuration.md +58 -0
  49. package/.genie/code/spells/automated-rc-publishing.md +106 -0
  50. package/.genie/code/spells/branch-tracker-guidance.md +28 -0
  51. package/.genie/code/spells/debug.md +320 -0
  52. package/.genie/code/spells/emoji-naming-convention.md +303 -0
  53. package/.genie/code/spells/evidence-storage.md +26 -0
  54. package/.genie/code/spells/file-naming-rules.md +35 -0
  55. package/.genie/code/spells/forge-code-blueprints.md +195 -0
  56. package/.genie/code/spells/genie-integration.md +153 -0
  57. package/.genie/code/spells/publishing-protocol.md +61 -0
  58. package/.genie/code/spells/team-consultation-protocol.md +284 -0
  59. package/.genie/code/spells/tool-requirements.md +20 -0
  60. package/.genie/code/spells/triad-maintenance-protocol.md +154 -0
  61. package/.genie/code/teams/tech-council/council.md +328 -0
  62. package/.genie/code/teams/tech-council/jt.md +352 -0
  63. package/.genie/code/teams/tech-council/nayr.md +305 -0
  64. package/.genie/code/teams/tech-council/oettam.md +375 -0
  65. package/.genie/neurons/README.md +193 -0
  66. package/.genie/neurons/forge.md +106 -0
  67. package/.genie/neurons/genie.md +63 -0
  68. package/.genie/neurons/review.md +106 -0
  69. package/.genie/neurons/wish.md +104 -0
  70. package/.genie/product/README.md +20 -0
  71. package/.genie/product/cli-automation.md +359 -0
  72. package/.genie/product/environment.md +60 -0
  73. package/.genie/product/mission.md +60 -0
  74. package/.genie/product/roadmap.md +44 -0
  75. package/.genie/product/tech-stack.md +34 -0
  76. package/.genie/product/templates/context-template.md +218 -0
  77. package/.genie/product/templates/qa-done-report-template.md +68 -0
  78. package/.genie/product/templates/review-report-template.md +89 -0
  79. package/.genie/product/templates/wish-template.md +120 -0
  80. package/.genie/scripts/helpers/analyze-commit.js +195 -0
  81. package/.genie/scripts/helpers/bullet-counter.js +194 -0
  82. package/.genie/scripts/helpers/bullet-find.js +289 -0
  83. package/.genie/scripts/helpers/bullet-id.js +244 -0
  84. package/.genie/scripts/helpers/check-secrets.js +237 -0
  85. package/.genie/scripts/helpers/count-tokens.js +200 -0
  86. package/.genie/scripts/helpers/create-frontmatter.js +456 -0
  87. package/.genie/scripts/helpers/detect-markers.js +293 -0
  88. package/.genie/scripts/helpers/detect-todos.js +267 -0
  89. package/.genie/scripts/helpers/detect-unlabeled-blocks.js +135 -0
  90. package/.genie/scripts/helpers/embeddings.js +344 -0
  91. package/.genie/scripts/helpers/find-empty-sections.js +158 -0
  92. package/.genie/scripts/helpers/index.js +319 -0
  93. package/.genie/scripts/helpers/validate-frontmatter.js +578 -0
  94. package/.genie/scripts/helpers/validate-links.js +207 -0
  95. package/.genie/scripts/helpers/validate-paths.js +373 -0
  96. package/.genie/spells/README.md +9 -0
  97. package/.genie/spells/ace-protocol.md +118 -0
  98. package/.genie/spells/ask-one-at-a-time.md +175 -0
  99. package/.genie/spells/backup-analyzer.md +542 -0
  100. package/.genie/spells/blocker.md +12 -0
  101. package/.genie/spells/break-things-move-fast.md +56 -0
  102. package/.genie/spells/context-candidates.md +72 -0
  103. package/.genie/spells/context-critic.md +51 -0
  104. package/.genie/spells/defer-to-expertise.md +278 -0
  105. package/.genie/spells/delegate-dont-do.md +292 -0
  106. package/.genie/spells/error-investigation-protocol.md +328 -0
  107. package/.genie/spells/evidence-based-completion.md +273 -0
  108. package/.genie/spells/experiment.md +65 -0
  109. package/.genie/spells/file-creation-protocol.md +229 -0
  110. package/.genie/spells/forge-integration.md +281 -0
  111. package/.genie/spells/forge-orchestration.md +514 -0
  112. package/.genie/spells/gather-context.md +18 -0
  113. package/.genie/spells/global-health-check.md +34 -0
  114. package/.genie/spells/global-noop-roundtrip.md +25 -0
  115. package/.genie/spells/install-genie.md +1232 -0
  116. package/.genie/spells/install.md +82 -0
  117. package/.genie/spells/investigate-before-commit.md +112 -0
  118. package/.genie/spells/know-yourself.md +288 -0
  119. package/.genie/spells/learn.md +828 -0
  120. package/.genie/spells/mcp-diagnostic-protocol.md +246 -0
  121. package/.genie/spells/mcp-first.md +124 -0
  122. package/.genie/spells/multi-step-execution.md +67 -0
  123. package/.genie/spells/orchestration-boundary-protocol.md +256 -0
  124. package/.genie/spells/orchestrator-not-implementor.md +189 -0
  125. package/.genie/spells/prompt.md +746 -0
  126. package/.genie/spells/reflect.md +404 -0
  127. package/.genie/spells/routing-decision-matrix.md +368 -0
  128. package/.genie/spells/run-in-parallel.md +12 -0
  129. package/.genie/spells/session-state-updater-example.md +196 -0
  130. package/.genie/spells/session-state-updater.md +220 -0
  131. package/.genie/spells/track-long-running-tasks.md +133 -0
  132. package/.genie/spells/troubleshoot-infrastructure.md +176 -0
  133. package/.genie/spells/upgrade-genie.md +415 -0
  134. package/.genie/spells/url-presentation-protocol.md +301 -0
  135. package/.genie/spells/wish-initiation.md +158 -0
  136. package/.genie/spells/wish-issue-linkage.md +410 -0
  137. package/.genie/spells/wish-lifecycle.md +100 -0
  138. package/.genie/state/provider-status.json +3 -0
  139. package/.genie/state/version.json +16 -0
  140. package/AGENTS.md +422 -0
  141. package/CLAUDE.md +1 -0
  142. package/LICENSE +21 -0
  143. package/Makefile +235 -0
  144. package/README.md +323 -0
  145. package/bin/pglite-server.js +457 -0
  146. package/ecosystem.config.cjs +23 -0
  147. package/examples/multi-tenant-demo.js +104 -0
  148. package/package.json +47 -0
  149. package/src/detector.js +105 -0
  150. package/src/index.js +177 -0
  151. package/src/pool.js +320 -0
  152. package/src/ports.js +114 -0
  153. package/src/protocol.js +216 -0
  154. package/src/registry.js +134 -0
  155. package/src/router.js +289 -0
  156. package/src/server.js +265 -0
  157. package/tests/benchmarks/runner.js +489 -0
  158. package/tests/multi-tenant.test.js +201 -0
@@ -0,0 +1,293 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * TODO/FIXME/WIP Marker Detector
5
+ *
6
+ * Scans files for incomplete work markers:
7
+ * - TODO, FIXME, XXX, HACK, WIP, TBD
8
+ * - Placeholder text patterns
9
+ *
10
+ * Usage:
11
+ * node detect-markers.js [path]
12
+ * (defaults to current directory if no path provided)
13
+ */
14
+
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+
18
+ // Marker patterns
19
+ const MARKERS = {
20
+ todo: /\bTODO\b:?/gi,
21
+ fixme: /\bFIXME\b:?/gi,
22
+ xxx: /\bXXX\b:?/gi,
23
+ hack: /\bHACK\b:?/gi,
24
+ wip: /\bWIP\b:?/gi,
25
+ tbd: /\bTBD\b:?/gi,
26
+ };
27
+
28
+ const PLACEHOLDER_PATTERNS = [
29
+ /coming soon/gi,
30
+ /to be documented/gi,
31
+ /fill this in later/gi,
32
+ /\[placeholder\]/gi,
33
+ /lorem ipsum/gi,
34
+ /TODO: write this section/gi,
35
+ ];
36
+
37
+ // Git conflict markers (CRITICAL)
38
+ const CONFLICT_MARKERS = [
39
+ /^<<<<<<< /m,
40
+ /^=======/m,
41
+ /^>>>>>>> /m,
42
+ /^\|\|\|\|\|\|\| merged common ancestors/m,
43
+ ];
44
+
45
+ // Configuration
46
+ const EXCLUDE_PATTERNS = [
47
+ 'node_modules',
48
+ '.git',
49
+ 'dist',
50
+ 'build',
51
+ 'coverage',
52
+ '/backups/',
53
+ '.min.js',
54
+ '.bundle.js',
55
+ ];
56
+
57
+ // File extensions to scan
58
+ const SCAN_EXTENSIONS = ['.md', '.js', '.ts', '.jsx', '.tsx', '.json', '.yaml', '.yml'];
59
+
60
+ // Results
61
+ const results = {
62
+ totalFiles: 0,
63
+ scannedFiles: 0,
64
+ issues: [],
65
+ summary: {
66
+ markers: {},
67
+ placeholders: 0,
68
+ conflicts: 0,
69
+ },
70
+ };
71
+
72
+ /**
73
+ * Should scan this file?
74
+ */
75
+ function shouldScan(filePath) {
76
+ // Check exclusions
77
+ if (EXCLUDE_PATTERNS.some(pattern => filePath.includes(pattern))) {
78
+ return false;
79
+ }
80
+
81
+ // Check extension
82
+ const ext = path.extname(filePath);
83
+ return SCAN_EXTENSIONS.includes(ext);
84
+ }
85
+
86
+ /**
87
+ * Check if line is inside code block (markdown)
88
+ */
89
+ function isInCodeBlock(lines, lineIndex) {
90
+ let inCodeBlock = false;
91
+ for (let i = 0; i < lineIndex; i++) {
92
+ if (lines[i].trim().startsWith('```')) {
93
+ inCodeBlock = !inCodeBlock;
94
+ }
95
+ }
96
+ return inCodeBlock;
97
+ }
98
+
99
+ /**
100
+ * Scan single file
101
+ */
102
+ function scanFile(filePath) {
103
+ results.totalFiles++;
104
+
105
+ if (!shouldScan(filePath)) {
106
+ return;
107
+ }
108
+
109
+ try {
110
+ const content = fs.readFileSync(filePath, 'utf-8');
111
+ const lines = content.split('\n');
112
+ const isMarkdown = filePath.endsWith('.md');
113
+
114
+ results.scannedFiles++;
115
+
116
+ lines.forEach((line, index) => {
117
+ const lineNum = index + 1;
118
+
119
+ // Skip code blocks in markdown (intentional examples)
120
+ if (isMarkdown && isInCodeBlock(lines, index)) {
121
+ return;
122
+ }
123
+
124
+ // Check for git conflict markers (CRITICAL)
125
+ CONFLICT_MARKERS.forEach(pattern => {
126
+ if (pattern.test(line)) {
127
+ results.issues.push({
128
+ file: filePath,
129
+ line: lineNum,
130
+ type: 'conflict_marker',
131
+ severity: 'critical',
132
+ content: line.trim(),
133
+ message: 'Unresolved git merge conflict marker',
134
+ });
135
+ results.summary.conflicts++;
136
+ }
137
+ });
138
+
139
+ // Check for TODO/FIXME markers
140
+ Object.entries(MARKERS).forEach(([type, pattern]) => {
141
+ const match = line.match(pattern);
142
+ if (match) {
143
+ results.issues.push({
144
+ file: filePath,
145
+ line: lineNum,
146
+ type: `marker_${type}`,
147
+ severity: 'warning',
148
+ content: line.trim(),
149
+ message: `${type.toUpperCase()} marker found`,
150
+ });
151
+ results.summary.markers[type] = (results.summary.markers[type] || 0) + 1;
152
+ }
153
+ });
154
+
155
+ // Check for placeholder text
156
+ PLACEHOLDER_PATTERNS.forEach(pattern => {
157
+ const match = line.match(pattern);
158
+ if (match) {
159
+ results.issues.push({
160
+ file: filePath,
161
+ line: lineNum,
162
+ type: 'placeholder',
163
+ severity: 'warning',
164
+ content: line.trim(),
165
+ message: `Placeholder text: "${match[0]}"`,
166
+ });
167
+ results.summary.placeholders++;
168
+ }
169
+ });
170
+ });
171
+
172
+ } catch (err) {
173
+ console.error(`Error scanning ${filePath}: ${err.message}`);
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Recursively scan directory
179
+ */
180
+ function scanDirectory(dir) {
181
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
182
+
183
+ for (const entry of entries) {
184
+ const fullPath = path.join(dir, entry.name);
185
+
186
+ if (entry.isDirectory()) {
187
+ scanDirectory(fullPath);
188
+ } else if (entry.isFile()) {
189
+ scanFile(fullPath);
190
+ }
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Generate report
196
+ */
197
+ function generateReport() {
198
+ console.log('\n=== TODO/FIXME/Placeholder Detection Report ===\n');
199
+
200
+ console.log(`Total files: ${results.totalFiles}`);
201
+ console.log(`Scanned: ${results.scannedFiles}`);
202
+ console.log(`Issues found: ${results.issues.length}\n`);
203
+
204
+ if (results.issues.length === 0) {
205
+ console.log('✅ No markers or placeholders found!\n');
206
+ return 0;
207
+ }
208
+
209
+ // Group by severity
210
+ const critical = results.issues.filter(i => i.severity === 'critical');
211
+ const warnings = results.issues.filter(i => i.severity === 'warning');
212
+
213
+ // Show critical first
214
+ if (critical.length > 0) {
215
+ console.log(`🔴 CRITICAL (${critical.length}):\n`);
216
+ critical.forEach(issue => {
217
+ console.log(` ${issue.file}:${issue.line}`);
218
+ console.log(` ${issue.message}`);
219
+ console.log(` Content: ${issue.content}`);
220
+ console.log('');
221
+ });
222
+ }
223
+
224
+ // Show warnings
225
+ if (warnings.length > 0) {
226
+ console.log(`⚠️ WARNINGS (${warnings.length}):\n`);
227
+
228
+ // Group by type for cleaner output
229
+ const byType = {};
230
+ warnings.forEach(issue => {
231
+ if (!byType[issue.type]) byType[issue.type] = [];
232
+ byType[issue.type].push(issue);
233
+ });
234
+
235
+ Object.entries(byType).forEach(([type, issues]) => {
236
+ console.log(` ${type.toUpperCase()} (${issues.length}):`);
237
+ issues.forEach(issue => {
238
+ console.log(` ${issue.file}:${issue.line} - ${issue.content.substring(0, 80)}`);
239
+ });
240
+ console.log('');
241
+ });
242
+ }
243
+
244
+ // Summary
245
+ console.log('\n=== Summary ===\n');
246
+
247
+ if (results.summary.conflicts > 0) {
248
+ console.log(` 🔴 Conflict markers: ${results.summary.conflicts} (CRITICAL - FIX IMMEDIATELY)`);
249
+ }
250
+
251
+ const totalMarkers = Object.values(results.summary.markers).reduce((a, b) => a + b, 0);
252
+ if (totalMarkers > 0) {
253
+ console.log(` ⚠️ TODO/FIXME markers: ${totalMarkers}`);
254
+ Object.entries(results.summary.markers).forEach(([type, count]) => {
255
+ console.log(` ${type.toUpperCase()}: ${count}`);
256
+ });
257
+ }
258
+
259
+ if (results.summary.placeholders > 0) {
260
+ console.log(` ⚠️ Placeholder text: ${results.summary.placeholders}`);
261
+ }
262
+
263
+ console.log('');
264
+
265
+ // Exit code: 1 if critical issues found, 0 otherwise
266
+ return critical.length > 0 ? 1 : 0;
267
+ }
268
+
269
+ /**
270
+ * Main
271
+ */
272
+ function main() {
273
+ const targetPath = process.argv[2] || '.';
274
+
275
+ if (!fs.existsSync(targetPath)) {
276
+ console.error(`Error: Path not found: ${targetPath}`);
277
+ process.exit(1);
278
+ }
279
+
280
+ console.log(`Scanning: ${targetPath}\n`);
281
+
282
+ const stat = fs.statSync(targetPath);
283
+ if (stat.isDirectory()) {
284
+ scanDirectory(targetPath);
285
+ } else {
286
+ scanFile(targetPath);
287
+ }
288
+
289
+ const exitCode = generateReport();
290
+ process.exit(exitCode);
291
+ }
292
+
293
+ main();
@@ -0,0 +1,267 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * TODO/FIXME Marker Detection
5
+ *
6
+ * Scans markdown files for incomplete work markers:
7
+ * - TODO, FIXME, XXX, HACK, TBD, WIP
8
+ * - "Coming soon", placeholder text
9
+ * - Git merge conflict markers
10
+ *
11
+ * Usage:
12
+ * node detect-todos.js [path]
13
+ * (defaults to .genie/ if no path provided)
14
+ */
15
+
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+
19
+ // Marker patterns (case-insensitive)
20
+ const MARKERS = {
21
+ todo: /\bTODO:?/i,
22
+ fixme: /\bFIXME:?/i,
23
+ xxx: /\bXXX:?/i,
24
+ hack: /\bHACK:?/i,
25
+ tbd: /\bTBD:?/i,
26
+ wip: /\bWIP:?/i,
27
+ };
28
+
29
+ const PLACEHOLDER_PATTERNS = [
30
+ /\bcoming soon\b/i,
31
+ /\bto be documented\b/i,
32
+ /\bfill this in later\b/i,
33
+ /\[placeholder\]/i,
34
+ /\blorem ipsum\b/i,
35
+ /\bTODO:\s*write this section\b/i,
36
+ ];
37
+
38
+ const CONFLICT_MARKERS = [
39
+ /^<<<<<<< /m,
40
+ /^=======$/m,
41
+ /^>>>>>>> /m,
42
+ /^\|\|\|\|\|\|\| /m,
43
+ ];
44
+
45
+ // Results tracking
46
+ const results = {
47
+ totalFiles: 0,
48
+ scannedFiles: 0,
49
+ issues: [],
50
+ skipped: [],
51
+ };
52
+
53
+ /**
54
+ * Check if file should be scanned
55
+ */
56
+ function shouldScan(filePath) {
57
+ const excludePatterns = [
58
+ 'node_modules',
59
+ '.git',
60
+ 'dist',
61
+ 'build',
62
+ 'coverage',
63
+ '/backups/',
64
+ 'detect-todos.js', // Don't scan self
65
+ 'GARBAGE-DETECTION-IDEAS.md', // Ideas doc has intentional TODOs
66
+ ];
67
+
68
+ return !excludePatterns.some(pattern => filePath.includes(pattern));
69
+ }
70
+
71
+ /**
72
+ * Check if line is inside code block
73
+ */
74
+ function isInCodeBlock(lines, lineIndex) {
75
+ let inCodeBlock = false;
76
+ for (let i = 0; i < lineIndex; i++) {
77
+ if (lines[i].trim().startsWith('```')) {
78
+ inCodeBlock = !inCodeBlock;
79
+ }
80
+ }
81
+ return inCodeBlock;
82
+ }
83
+
84
+ /**
85
+ * Scan file for markers
86
+ */
87
+ function scanFile(filePath) {
88
+ results.totalFiles++;
89
+
90
+ if (!shouldScan(filePath)) {
91
+ results.skipped.push({ file: filePath, reason: 'Excluded path' });
92
+ return;
93
+ }
94
+
95
+ try {
96
+ const content = fs.readFileSync(filePath, 'utf-8');
97
+ const lines = content.split('\n');
98
+
99
+ results.scannedFiles++;
100
+
101
+ lines.forEach((line, index) => {
102
+ const lineNum = index + 1;
103
+ const inCodeBlock = isInCodeBlock(lines, index);
104
+
105
+ // Skip code blocks for markers (but not conflict markers)
106
+ if (!inCodeBlock) {
107
+ // Check TODO/FIXME/etc markers
108
+ for (const [type, pattern] of Object.entries(MARKERS)) {
109
+ if (pattern.test(line)) {
110
+ results.issues.push({
111
+ file: filePath,
112
+ line: lineNum,
113
+ type: `marker_${type}`,
114
+ severity: 'warning',
115
+ content: line.trim(),
116
+ message: `${type.toUpperCase()} marker found`,
117
+ suggestion: 'Complete the work or remove the marker',
118
+ });
119
+ }
120
+ }
121
+
122
+ // Check placeholder patterns
123
+ for (const pattern of PLACEHOLDER_PATTERNS) {
124
+ if (pattern.test(line)) {
125
+ results.issues.push({
126
+ file: filePath,
127
+ line: lineNum,
128
+ type: 'placeholder_text',
129
+ severity: 'warning',
130
+ content: line.trim(),
131
+ message: 'Placeholder text found',
132
+ suggestion: 'Complete the content or remove the placeholder',
133
+ });
134
+ break; // Only report first match per line
135
+ }
136
+ }
137
+ }
138
+
139
+ // Check conflict markers (even in code blocks)
140
+ for (const pattern of CONFLICT_MARKERS) {
141
+ if (pattern.test(line)) {
142
+ results.issues.push({
143
+ file: filePath,
144
+ line: lineNum,
145
+ type: 'merge_conflict',
146
+ severity: 'error',
147
+ content: line.trim(),
148
+ message: 'Git merge conflict marker found',
149
+ suggestion: 'Resolve the conflict immediately',
150
+ });
151
+ break;
152
+ }
153
+ }
154
+ });
155
+
156
+ } catch (err) {
157
+ results.issues.push({
158
+ file: filePath,
159
+ type: 'read_error',
160
+ message: `Failed to read file: ${err.message}`,
161
+ severity: 'error',
162
+ });
163
+ }
164
+ }
165
+
166
+ /**
167
+ * Recursively scan directory
168
+ */
169
+ function scanDirectory(dir) {
170
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
171
+
172
+ for (const entry of entries) {
173
+ const fullPath = path.join(dir, entry.name);
174
+
175
+ if (entry.isDirectory()) {
176
+ scanDirectory(fullPath);
177
+ } else if (entry.isFile() && entry.name.endsWith('.md')) {
178
+ scanFile(fullPath);
179
+ }
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Generate report
185
+ */
186
+ function generateReport() {
187
+ console.log('\n=== TODO/FIXME Detection Report ===\n');
188
+
189
+ console.log(`Total files: ${results.totalFiles}`);
190
+ console.log(`Scanned: ${results.scannedFiles}`);
191
+ console.log(`Issues found: ${results.issues.length}`);
192
+ console.log(`Skipped: ${results.skipped.length}\n`);
193
+
194
+ if (results.issues.length === 0) {
195
+ console.log('✅ No TODO/FIXME markers found!\n');
196
+ return 0;
197
+ }
198
+
199
+ // Group by severity
200
+ const errors = results.issues.filter(i => i.severity === 'error');
201
+ const warnings = results.issues.filter(i => i.severity === 'warning');
202
+
203
+ if (errors.length > 0) {
204
+ console.log(`🔴 ERRORS (${errors.length}):\n`);
205
+ errors.forEach(issue => {
206
+ console.log(` ${issue.file}:${issue.line || '?'}`);
207
+ console.log(` Type: ${issue.type}`);
208
+ console.log(` Message: ${issue.message}`);
209
+ console.log(` Content: ${issue.content}`);
210
+ console.log(` Suggestion: ${issue.suggestion}`);
211
+ console.log('');
212
+ });
213
+ }
214
+
215
+ if (warnings.length > 0) {
216
+ console.log(`⚠️ WARNINGS (${warnings.length}):\n`);
217
+ warnings.forEach(issue => {
218
+ console.log(` ${issue.file}:${issue.line || '?'}`);
219
+ console.log(` Type: ${issue.type}`);
220
+ console.log(` Content: ${issue.content}`);
221
+ console.log('');
222
+ });
223
+ }
224
+
225
+ // Summary by type
226
+ console.log('\n=== Summary by Type ===\n');
227
+ const byType = {};
228
+ results.issues.forEach(issue => {
229
+ byType[issue.type] = (byType[issue.type] || 0) + 1;
230
+ });
231
+
232
+ Object.entries(byType).forEach(([type, count]) => {
233
+ console.log(` ${type}: ${count}`);
234
+ });
235
+
236
+ console.log('');
237
+ return errors.length > 0 ? 1 : 0;
238
+ }
239
+
240
+ /**
241
+ * Main
242
+ */
243
+ function main() {
244
+ const targetPath = process.argv[2] || '.genie';
245
+
246
+ if (!fs.existsSync(targetPath)) {
247
+ console.error(`Error: Path not found: ${targetPath}`);
248
+ process.exit(1);
249
+ }
250
+
251
+ console.log(`Scanning: ${targetPath}\n`);
252
+
253
+ const stat = fs.statSync(targetPath);
254
+ if (stat.isDirectory()) {
255
+ scanDirectory(targetPath);
256
+ } else if (targetPath.endsWith('.md')) {
257
+ scanFile(targetPath);
258
+ } else {
259
+ console.error('Error: Target must be a directory or .md file');
260
+ process.exit(1);
261
+ }
262
+
263
+ const exitCode = generateReport();
264
+ process.exit(exitCode);
265
+ }
266
+
267
+ main();
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Detect Unlabeled Code Blocks Helper
5
+ *
6
+ * Find fenced code blocks without language identifiers.
7
+ * Detects ``` without language specification (should be ```bash, ```typescript, etc.)
8
+ *
9
+ * Usage:
10
+ * node detect-unlabeled-blocks.js <file-path> # Check single file
11
+ * node detect-unlabeled-blocks.js <directory> # Check all .md files recursively
12
+ *
13
+ * Output:
14
+ * <file>:<line>: Unlabeled code block (missing language identifier)
15
+ */
16
+
17
+ const fs = require('fs');
18
+ const path = require('path');
19
+
20
+ /**
21
+ * Detect unlabeled code blocks in file content
22
+ * Returns: [{ line, content }]
23
+ */
24
+ function detectUnlabeledBlocks(content) {
25
+ const lines = content.split('\n');
26
+ const issues = [];
27
+
28
+ lines.forEach((line, idx) => {
29
+ // Match ``` at start of line with optional whitespace
30
+ // But NOT ```language or ``` followed by text on same line
31
+ if (/^```\s*$/.test(line.trim())) {
32
+ issues.push({
33
+ line: idx + 1,
34
+ content: line.trim(),
35
+ });
36
+ }
37
+ });
38
+
39
+ return issues;
40
+ }
41
+
42
+ /**
43
+ * Check single file
44
+ */
45
+ function checkFile(filePath) {
46
+ try {
47
+ const content = fs.readFileSync(filePath, 'utf-8');
48
+ const issues = detectUnlabeledBlocks(content);
49
+
50
+ return issues.map(issue => ({
51
+ file: filePath,
52
+ line: issue.line,
53
+ content: issue.content,
54
+ }));
55
+ } catch (err) {
56
+ return [{ file: filePath, error: `Failed to read file: ${err.message}` }];
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Check all .md files in directory
62
+ */
63
+ function checkDirectory(dirPath) {
64
+ const allIssues = [];
65
+
66
+ function scanDir(dir) {
67
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
68
+
69
+ entries.forEach(entry => {
70
+ const fullPath = path.join(dir, entry.name);
71
+
72
+ if (entry.isDirectory() && !entry.name.startsWith('.')) {
73
+ scanDir(fullPath);
74
+ } else if (entry.isFile() && entry.name.endsWith('.md')) {
75
+ const issues = checkFile(fullPath);
76
+ allIssues.push(...issues);
77
+ }
78
+ });
79
+ }
80
+
81
+ scanDir(dirPath);
82
+ return allIssues;
83
+ }
84
+
85
+ /**
86
+ * Main
87
+ */
88
+ function main() {
89
+ const args = process.argv.slice(2);
90
+
91
+ if (args.length === 0) {
92
+ console.error(`
93
+ Usage:
94
+ node detect-unlabeled-blocks.js <file-path> # Check single file
95
+ node detect-unlabeled-blocks.js <directory> # Check all .md files recursively
96
+
97
+ Output:
98
+ <file>:<line>: Unlabeled code block (missing language identifier)
99
+
100
+ Exit code:
101
+ 0 = All code blocks labeled
102
+ 1 = Unlabeled blocks found
103
+ `);
104
+ process.exit(1);
105
+ }
106
+
107
+ const target = args[0];
108
+
109
+ if (!fs.existsSync(target)) {
110
+ console.error(`Error: Path not found: ${target}`);
111
+ process.exit(1);
112
+ }
113
+
114
+ const stat = fs.statSync(target);
115
+ const issues = stat.isDirectory()
116
+ ? checkDirectory(target)
117
+ : checkFile(target);
118
+
119
+ if (issues.length === 0) {
120
+ console.log('All code blocks properly labeled');
121
+ process.exit(0);
122
+ }
123
+
124
+ issues.forEach(issue => {
125
+ if (issue.line) {
126
+ console.log(`${issue.file}:${issue.line}: Unlabeled code block (missing language identifier)`);
127
+ } else {
128
+ console.log(`${issue.file}: ${issue.error}`);
129
+ }
130
+ });
131
+
132
+ process.exit(1);
133
+ }
134
+
135
+ main();