@tekyzinc/gsd-t 3.29.11 → 4.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/bin/gsd-t-parallel.cjs +64 -13
  3. package/bin/gsd-t.js +48 -376
  4. package/bin/journey-coverage.cjs +6 -3
  5. package/bin/parallel-cli.cjs +13 -1
  6. package/commands/gsd-t-complete-milestone.md +6 -12
  7. package/commands/gsd-t-debug.md +47 -533
  8. package/commands/gsd-t-design-decompose.md +24 -497
  9. package/commands/gsd-t-doc-ripple.md +23 -139
  10. package/commands/gsd-t-execute.md +41 -958
  11. package/commands/gsd-t-feature.md +2 -6
  12. package/commands/gsd-t-gap-analysis.md +3 -6
  13. package/commands/gsd-t-help.md +2 -4
  14. package/commands/gsd-t-impact.md +26 -295
  15. package/commands/gsd-t-init-scan-setup.md +7 -7
  16. package/commands/gsd-t-integrate.md +44 -369
  17. package/commands/gsd-t-milestone.md +25 -124
  18. package/commands/gsd-t-partition.md +28 -539
  19. package/commands/gsd-t-plan.md +26 -472
  20. package/commands/gsd-t-prd.md +25 -311
  21. package/commands/gsd-t-quick.md +1 -1
  22. package/commands/gsd-t-resume.md +0 -33
  23. package/commands/gsd-t-scan.md +45 -652
  24. package/commands/gsd-t-verify.md +52 -569
  25. package/commands/gsd-t-wave.md +41 -430
  26. package/package.json +1 -1
  27. package/scripts/gsd-t-calibration-hook.js +3 -1
  28. package/scripts/hooks/pre-commit-journey-coverage +0 -2
  29. package/scripts/hooks/pre-commit-playwright-gate +0 -2
  30. package/templates/CLAUDE-global.md +44 -173
  31. package/templates/CLAUDE-project.md +118 -104
  32. package/templates/prompts/design-verify-subagent.md +3 -0
  33. package/templates/prompts/qa-subagent.md +3 -0
  34. package/templates/prompts/red-team-subagent.md +5 -2
  35. package/templates/workflows/_lib.js +176 -0
  36. package/templates/workflows/gsd-t-debug.workflow.js +86 -0
  37. package/templates/workflows/gsd-t-execute.workflow.js +206 -0
  38. package/templates/workflows/gsd-t-integrate.workflow.js +71 -0
  39. package/templates/workflows/gsd-t-phase.workflow.js +94 -0
  40. package/templates/workflows/gsd-t-quick.workflow.js +72 -0
  41. package/templates/workflows/gsd-t-scan.workflow.js +711 -0
  42. package/templates/workflows/gsd-t-verify.workflow.js +348 -0
  43. package/templates/workflows/gsd-t-wave.workflow.js +43 -0
  44. package/bin/check-headless-sessions.js +0 -140
  45. package/bin/context-budget-audit.cjs +0 -447
  46. package/bin/context-meter-config.cjs +0 -101
  47. package/bin/context-meter-config.test.cjs +0 -101
  48. package/bin/event-stream.cjs +0 -205
  49. package/bin/gsd-t-benchmark-orchestrator.js +0 -437
  50. package/bin/gsd-t-capture-lint.cjs +0 -440
  51. package/bin/gsd-t-economics.cjs +0 -315
  52. package/bin/gsd-t-in-session-usage.cjs +0 -213
  53. package/bin/gsd-t-orchestrator-config.cjs +0 -161
  54. package/bin/gsd-t-orchestrator-queue.cjs +0 -180
  55. package/bin/gsd-t-orchestrator-recover.cjs +0 -231
  56. package/bin/gsd-t-orchestrator-worker.cjs +0 -219
  57. package/bin/gsd-t-orchestrator.js +0 -535
  58. package/bin/gsd-t-parallel-probe.cjs +0 -132
  59. package/bin/gsd-t-ratelimit-probe-worker.cjs +0 -237
  60. package/bin/gsd-t-ratelimit-probe.cjs +0 -648
  61. package/bin/gsd-t-report-tokens.cjs +0 -549
  62. package/bin/gsd-t-stream-feed-client.cjs +0 -151
  63. package/bin/gsd-t-token-backfill.cjs +0 -366
  64. package/bin/gsd-t-token-capture.cjs +0 -321
  65. package/bin/gsd-t-token-dashboard.cjs +0 -353
  66. package/bin/gsd-t-token-regenerate-log.cjs +0 -129
  67. package/bin/gsd-t-tool-attribution.cjs +0 -377
  68. package/bin/gsd-t-tool-cost.cjs +0 -195
  69. package/bin/gsd-t-transcript-tee.cjs +0 -246
  70. package/bin/gsd-t-unattended-heartbeat.cjs +0 -188
  71. package/bin/gsd-t-unattended-platform.cjs +0 -551
  72. package/bin/gsd-t-unattended-platform.js +0 -381
  73. package/bin/gsd-t-unattended-safety.cjs +0 -773
  74. package/bin/gsd-t-unattended-safety.js +0 -788
  75. package/bin/gsd-t-unattended.cjs +0 -2109
  76. package/bin/gsd-t-unattended.js +0 -1367
  77. package/bin/gsd-t-worker-dispatch.cjs +0 -211
  78. package/bin/handoff-lock.cjs +0 -249
  79. package/bin/handoff-lock.js +0 -249
  80. package/bin/headless-auto-spawn.cjs +0 -711
  81. package/bin/headless-auto-spawn.js +0 -373
  82. package/bin/headless-exit-codes.cjs +0 -67
  83. package/bin/live-activity-report.cjs +0 -615
  84. package/bin/log-tail.cjs +0 -81
  85. package/bin/m44-proof-measure.cjs +0 -285
  86. package/bin/m46-iter-proof.cjs +0 -149
  87. package/bin/m46-worker-proof.cjs +0 -201
  88. package/bin/m55-substrate-proof.cjs +0 -134
  89. package/bin/metrics-rollup.js +0 -200
  90. package/bin/model-windows.cjs +0 -99
  91. package/bin/model-windows.test.cjs +0 -75
  92. package/bin/parallelism-report.cjs +0 -535
  93. package/bin/runway-estimator.cjs +0 -242
  94. package/bin/spawn-plan-derive.cjs +0 -163
  95. package/bin/spawn-plan-status-updater.cjs +0 -292
  96. package/bin/spawn-plan-writer.cjs +0 -204
  97. package/bin/supervisor-pid-fingerprint.cjs +0 -126
  98. package/bin/token-budget.cjs +0 -265
  99. package/bin/unattended-watch-format.cjs +0 -178
  100. package/bin/watch-progress.js +0 -155
  101. package/commands/gsd-t-unattended-stop.md +0 -85
  102. package/commands/gsd-t-unattended-watch.md +0 -465
  103. package/commands/gsd-t-unattended.md +0 -476
  104. package/commands/gsd-t-visualize.md +0 -116
  105. package/scripts/gsd-t-context-meter.e2e.test.js +0 -364
  106. package/scripts/gsd-t-context-meter.js +0 -341
  107. package/scripts/gsd-t-context-meter.test.js +0 -471
  108. package/scripts/gsd-t-dashboard-server.js +0 -1203
  109. package/scripts/gsd-t-post-commit-spawn-plan.sh +0 -86
  110. package/scripts/gsd-t-transcript.html +0 -1821
  111. package/scripts/hooks/gsd-t-conversation-capture.js +0 -439
  112. package/scripts/hooks/gsd-t-in-session-usage-hook.js +0 -84
  113. package/scripts/spawn-plan-fmt-tokens.cjs +0 -80
  114. package/templates/hooks/post-commit-spawn-plan.sh +0 -85
@@ -1,440 +0,0 @@
1
- 'use strict';
2
- /**
3
- * GSD-T Capture Lint (M41 D5)
4
- *
5
- * Scans files for bare subagent spawn patterns that bypass the
6
- * `bin/gsd-t-token-capture.cjs` wrapper. Flags:
7
- * - `Task(` without captureSpawn/recordSpawnRow within ±20 lines
8
- * - `claude -p` executable lines without wrapper
9
- * - `spawn('claude', ...)` / `spawn("claude", ...)` without wrapper
10
- *
11
- * Whitelisted:
12
- * - The wrapper module itself (bin/gsd-t-token-capture.cjs)
13
- * - The linter (bin/gsd-t-capture-lint.cjs) — meta-self
14
- * - Anything under test/
15
- * - Comment-only lines (//, #, <!--)
16
- * - Markdown prose lines (only matches inside ``` fences are executable)
17
- * - Any line carrying the literal `GSD-T-CAPTURE-LINT: skip` on the same
18
- * or adjacent line
19
- *
20
- * Zero external deps. `.cjs` for ESM/CJS compat.
21
- */
22
-
23
- const fs = require('fs');
24
- const path = require('path');
25
- const { execSync } = require('child_process');
26
-
27
- // Patterns match tool-invocation syntax, not prose. `Task(s)` in a markdown
28
- // table and `claude -p` inside a help-text string are false positives and
29
- // are excluded by the shape matchers below.
30
- const SPAWN_PATTERNS = [
31
- // Task({...}) or Task(\n — the Task subagent tool invocation shape.
32
- // Excludes Task(s), Task(X), Task(foo) plain-identifier calls which
33
- // are almost always docs/markdown.
34
- { name: 'Task(', re: /\bTask\(\s*(?:\{|$)/ },
35
- // spawn('claude', ...) / spawn("claude", ...)
36
- { name: "spawn('claude'", re: /\bspawn\(\s*['"]claude['"]\s*,/ },
37
- // `claude -p` as an actual shell command — not inside string literals
38
- // that describe it. Require it to appear outside quotes/backticks. This
39
- // is heuristic; the skip marker and comment-line guard catch the rest.
40
- { name: 'claude -p', re: /(?:^|\s|[;&|`$(])claude\s+-p\b/ },
41
- ];
42
-
43
- const WRAPPER_PATTERNS = /\bcaptureSpawn\s*\(|\brecordSpawnRow\s*\(/;
44
- const SKIP_MARKER = 'GSD-T-CAPTURE-LINT: skip';
45
- const CONTEXT_RADIUS = 20;
46
-
47
- function _isWhitelistedPath(relPath) {
48
- const norm = relPath.replace(/\\/g, '/');
49
- if (norm.endsWith('bin/gsd-t-token-capture.cjs')) return true;
50
- if (norm.endsWith('bin/gsd-t-capture-lint.cjs')) return true;
51
- // commands/gsd-t-help.md is a pure-prose help reference — every mention
52
- // of `claude -p` or `Task(...)` in it is documentation, not a live spawn.
53
- if (norm.endsWith('commands/gsd-t-help.md')) return true;
54
- if (norm.startsWith('test/') || norm.includes('/test/')) return true;
55
- return false;
56
- }
57
-
58
- function _isCommentOnlyLine(line) {
59
- const t = line.trim();
60
- if (!t) return true;
61
- if (t.startsWith('//')) return true;
62
- if (t.startsWith('#')) return true;
63
- if (t.startsWith('<!--')) return true;
64
- if (t.startsWith('*')) return true;
65
- return false;
66
- }
67
-
68
- /**
69
- * Check whether `match` starts inside a string literal (single, double, or
70
- * backtick-quoted) on `line`. Conservative: only flags balanced-quote cases.
71
- * This catches help-text strings like `log("... claude -p ...")` without
72
- * needing a full JS parser.
73
- */
74
- function _matchInsideStringLiteral(line, match) {
75
- const idx = line.indexOf(match);
76
- if (idx < 0) return false;
77
- const prefix = line.slice(0, idx);
78
- const countUnescaped = (ch) => {
79
- let n = 0;
80
- for (let i = 0; i < prefix.length; i++) {
81
- if (prefix[i] === ch && prefix[i - 1] !== '\\') n++;
82
- }
83
- return n;
84
- };
85
- // Odd count before the match → inside an open string
86
- if (countUnescaped('"') % 2 === 1) return true;
87
- if (countUnescaped("'") % 2 === 1) return true;
88
- if (countUnescaped('`') % 2 === 1) return true;
89
- return false;
90
- }
91
-
92
- /**
93
- * For markdown files, match patterns only inside ``` fenced code blocks.
94
- * For non-markdown files, all lines are "executable" (fence tracking is
95
- * a no-op).
96
- */
97
- function _buildFenceMap(lines, isMarkdown) {
98
- const inFence = new Array(lines.length).fill(!isMarkdown);
99
- if (!isMarkdown) return inFence;
100
- let open = false;
101
- for (let i = 0; i < lines.length; i++) {
102
- const t = lines[i].trim();
103
- if (t.startsWith('```')) {
104
- open = !open;
105
- inFence[i] = false;
106
- continue;
107
- }
108
- inFence[i] = open;
109
- }
110
- return inFence;
111
- }
112
-
113
- function _hasWrapperNearby(lines, idx) {
114
- const lo = Math.max(0, idx - CONTEXT_RADIUS);
115
- const hi = Math.min(lines.length - 1, idx + CONTEXT_RADIUS);
116
- for (let j = lo; j <= hi; j++) {
117
- if (WRAPPER_PATTERNS.test(lines[j])) return true;
118
- }
119
- return false;
120
- }
121
-
122
- function _hasSkipMarkerNearby(lines, idx) {
123
- const lo = Math.max(0, idx - 1);
124
- const hi = Math.min(lines.length - 1, idx + 1);
125
- for (let j = lo; j <= hi; j++) {
126
- if (lines[j].includes(SKIP_MARKER)) return true;
127
- }
128
- return false;
129
- }
130
-
131
- /**
132
- * Lint a single file. Returns an array of violation objects.
133
- * @param {string} absPath
134
- * @param {string} projectDir
135
- * @returns {Array<{file, line, pattern, message}>}
136
- */
137
- function lintFile(absPath, projectDir) {
138
- const relPath = path.relative(projectDir, absPath);
139
- if (_isWhitelistedPath(relPath)) return [];
140
-
141
- let src;
142
- try {
143
- src = fs.readFileSync(absPath, 'utf8');
144
- } catch (_) {
145
- return [];
146
- }
147
-
148
- const lines = src.split('\n');
149
- const isMarkdown = absPath.endsWith('.md');
150
- const executable = _buildFenceMap(lines, isMarkdown);
151
-
152
- const violations = [];
153
- for (let i = 0; i < lines.length; i++) {
154
- if (!executable[i]) continue;
155
- const line = lines[i];
156
- if (_isCommentOnlyLine(line)) continue;
157
- if (_hasSkipMarkerNearby(lines, i)) continue;
158
-
159
- for (const { name, re } of SPAWN_PATTERNS) {
160
- const m = line.match(re);
161
- if (m) {
162
- // Skip prose mentions inside string literals (help text, log strings).
163
- // Markdown files already gate via fence map; only apply the quote
164
- // heuristic to JS/CJS source where help-text strings live.
165
- if (!isMarkdown && _matchInsideStringLiteral(line, m[0])) break;
166
- if (!_hasWrapperNearby(lines, i)) {
167
- violations.push({
168
- file: relPath,
169
- line: i + 1,
170
- pattern: name,
171
- message: `bare ${name} spawn without captureSpawn/recordSpawnRow wrapper`,
172
- });
173
- }
174
- break;
175
- }
176
- }
177
- }
178
-
179
- return violations;
180
- }
181
-
182
- /**
183
- * Lint a list of paths.
184
- * @param {string[]} paths Absolute or relative to projectDir
185
- * @param {object} opts
186
- * @param {string} opts.projectDir
187
- * @returns {{violations: Array}}
188
- */
189
- function lintFiles(paths, opts) {
190
- const projectDir = (opts && opts.projectDir) || process.cwd();
191
- const all = [];
192
- for (const p of paths) {
193
- const abs = path.isAbsolute(p) ? p : path.join(projectDir, p);
194
- if (!fs.existsSync(abs)) continue;
195
- const st = fs.statSync(abs);
196
- if (!st.isFile()) continue;
197
- all.push(...lintFile(abs, projectDir));
198
- }
199
- return { violations: all };
200
- }
201
-
202
- function _listStaged(projectDir) {
203
- let out;
204
- try {
205
- out = execSync('git diff --name-only --cached', { cwd: projectDir, encoding: 'utf8' });
206
- } catch (_) {
207
- return [];
208
- }
209
- return out
210
- .split('\n')
211
- .map((l) => l.trim())
212
- .filter(Boolean)
213
- .filter((p) => /^(commands|bin|scripts)\//.test(p));
214
- }
215
-
216
- function _listAll(projectDir) {
217
- const results = [];
218
- const dirs = [
219
- { dir: 'commands', exts: ['.md'] },
220
- { dir: 'bin', exts: ['.js', '.cjs'] },
221
- { dir: 'scripts', exts: ['.js', '.cjs', '.html'] },
222
- ];
223
- for (const { dir, exts } of dirs) {
224
- const abs = path.join(projectDir, dir);
225
- if (!fs.existsSync(abs)) continue;
226
- const entries = fs.readdirSync(abs);
227
- for (const entry of entries) {
228
- const p = path.join(abs, entry);
229
- try {
230
- const st = fs.statSync(p);
231
- if (!st.isFile()) continue;
232
- } catch (_) { continue; }
233
- if (exts.some((e) => entry.endsWith(e))) {
234
- results.push(path.join(dir, entry));
235
- }
236
- }
237
- }
238
- return results;
239
- }
240
-
241
- /**
242
- * CLI entry point.
243
- * @param {object} opts
244
- * @param {string} opts.projectDir
245
- * @param {'staged'|'all'} opts.mode
246
- * @returns {{exitCode: number, violations: Array, files: string[]}}
247
- */
248
- function main(opts) {
249
- const projectDir = opts.projectDir || process.cwd();
250
- const mode = opts.mode || 'staged';
251
- let files;
252
- try {
253
- files = mode === 'all' ? _listAll(projectDir) : _listStaged(projectDir);
254
- } catch (e) {
255
- return { exitCode: 2, violations: [], files: [], error: e.message || String(e) };
256
- }
257
- const { violations } = lintFiles(files, { projectDir });
258
- return {
259
- exitCode: violations.length === 0 ? 0 : 1,
260
- violations,
261
- files,
262
- };
263
- }
264
-
265
- // ─── M56 D5: stream-json universality lint ─────────────────────────────────
266
- //
267
- // The token-capture lint above enforces "every Task(...) / claude -p / spawn('claude', ...)
268
- // goes through captureSpawn". This second lint enforces a different invariant:
269
- // every claude -p / spawn('claude', ...) invocation MUST pass the
270
- // `--output-format stream-json --verbose` flag pair so the orchestrator can
271
- // observe progress in real time. Allowlist sites that genuinely don't emit
272
- // user-watchable progress (probes measuring rate-limit envelope, single-word
273
- // cache-warm pings, internal debug-loop summarizers) declare themselves via
274
- // the `GSD-T-LINT: skip stream-json` marker comment with a reason.
275
- //
276
- // Contract: per memory feedback_claude_p_stream_json.md and the M56 partition
277
- // charter. Surface mirrors the M41 capture-lint surface (same patterns,
278
- // whitelist, skip-marker, fence-map, _matchInsideStringLiteral helpers).
279
-
280
- // Patterns: spawn shapes that need --output-format stream-json. Only flag
281
- // invocations that are actually `claude -p` runs — `claude --version`,
282
- // `claude mcp add`, `claude doctor` etc. don't produce streamable progress.
283
- // We require `-p` to appear in the spawn args (within ±15 lines for arg-array
284
- // spreads) before flagging, mirroring how the M41 capture-lint applies.
285
- const STREAM_JSON_SPAWN_PATTERNS = [
286
- // spawn('claude', ...) / spawn("claude", ...) — but only when -p is in the call
287
- { name: "spawn('claude') (no stream-json)", re: /\bspawn\(\s*['"]claude['"]\s*,/, requirePArg: true },
288
- // execFileSync('claude', ...) / execFile('claude', ...) — same -p requirement
289
- { name: "execFile('claude') (no stream-json)", re: /\bexec(?:File|FileSync)\(\s*['"]claude['"]\s*,/, requirePArg: true },
290
- // `claude -p` as an actual shell command — already requires -p in the regex
291
- { name: 'claude -p (no stream-json)', re: /(?:^|\s|[;&|`$(])claude\s+-p\b/, requirePArg: false },
292
- ];
293
-
294
- const P_ARG_RADIUS = 15;
295
- const P_ARG_RE = /['"`]-p['"`]/;
296
-
297
- function _hasPArgNearby(lines, idx) {
298
- const lo = Math.max(0, idx - P_ARG_RADIUS);
299
- const hi = Math.min(lines.length - 1, idx + P_ARG_RADIUS);
300
- for (let j = lo; j <= hi; j++) {
301
- if (P_ARG_RE.test(lines[j])) return true;
302
- }
303
- return false;
304
- }
305
-
306
- // We require BOTH `--output-format` and `stream-json` near the spawn site.
307
- // Looking ±20 lines (same window as wrapper detection) catches multi-line
308
- // arg-array spreads. Fence map already restricts markdown matching.
309
- const STREAM_JSON_FLAGS = /--output-format[\s\S]{0,80}stream-json|stream-json[\s\S]{0,80}--output-format/;
310
- const STREAM_JSON_SKIP_MARKER = 'GSD-T-LINT: skip stream-json';
311
- const STREAM_JSON_RADIUS = 20;
312
-
313
- function _hasStreamJsonFlagNearby(lines, idx) {
314
- const lo = Math.max(0, idx - STREAM_JSON_RADIUS);
315
- const hi = Math.min(lines.length - 1, idx + STREAM_JSON_RADIUS);
316
- // Strip comment-only lines so a comment that mentions `--output-format
317
- // stream-json` (e.g. "// Deliberately omits the flag pair") doesn't trick
318
- // the lint into thinking the flag is actually wired.
319
- const codeLines = [];
320
- for (let j = lo; j <= hi; j++) {
321
- if (!_isCommentOnlyLine(lines[j])) codeLines.push(lines[j]);
322
- }
323
- const window = codeLines.join('\n');
324
- return STREAM_JSON_FLAGS.test(window);
325
- }
326
-
327
- function _hasStreamJsonSkipMarkerNearby(lines, idx) {
328
- const lo = Math.max(0, idx - STREAM_JSON_RADIUS);
329
- const hi = Math.min(lines.length - 1, idx + STREAM_JSON_RADIUS);
330
- for (let j = lo; j <= hi; j++) {
331
- if (lines[j].includes(STREAM_JSON_SKIP_MARKER)) return true;
332
- }
333
- return false;
334
- }
335
-
336
- /**
337
- * Lint a single file for stream-json universality.
338
- * @param {string} absPath
339
- * @param {string} projectDir
340
- * @returns {Array<{file, line, pattern, message}>}
341
- */
342
- function streamJsonLintFile(absPath, projectDir) {
343
- const relPath = path.relative(projectDir, absPath);
344
- if (_isWhitelistedPath(relPath)) return [];
345
-
346
- let src;
347
- try {
348
- src = fs.readFileSync(absPath, 'utf8');
349
- } catch (_) {
350
- return [];
351
- }
352
-
353
- const lines = src.split('\n');
354
- const isMarkdown = absPath.endsWith('.md');
355
- const executable = _buildFenceMap(lines, isMarkdown);
356
-
357
- const violations = [];
358
- for (let i = 0; i < lines.length; i++) {
359
- if (!executable[i]) continue;
360
- const line = lines[i];
361
- if (_isCommentOnlyLine(line)) continue;
362
- if (_hasStreamJsonSkipMarkerNearby(lines, i)) continue;
363
-
364
- for (const { name, re, requirePArg } of STREAM_JSON_SPAWN_PATTERNS) {
365
- const m = line.match(re);
366
- if (m) {
367
- if (!isMarkdown && _matchInsideStringLiteral(line, m[0])) break;
368
- // Only flag if this is actually a `claude -p` invocation (not --version, mcp add, etc.)
369
- if (requirePArg && !_hasPArgNearby(lines, i)) break;
370
- if (!_hasStreamJsonFlagNearby(lines, i)) {
371
- violations.push({
372
- file: relPath,
373
- line: i + 1,
374
- pattern: name,
375
- message: `${name}: missing --output-format stream-json --verbose flag pair (or skip marker)`,
376
- });
377
- }
378
- break;
379
- }
380
- }
381
- }
382
-
383
- return violations;
384
- }
385
-
386
- /**
387
- * Lint a list of paths for stream-json universality.
388
- */
389
- function streamJsonLintFiles(paths, opts) {
390
- const projectDir = (opts && opts.projectDir) || process.cwd();
391
- const all = [];
392
- for (const p of paths) {
393
- const abs = path.isAbsolute(p) ? p : path.join(projectDir, p);
394
- if (!fs.existsSync(abs)) continue;
395
- const st = fs.statSync(abs);
396
- if (!st.isFile()) continue;
397
- all.push(...streamJsonLintFile(abs, projectDir));
398
- }
399
- return { violations: all };
400
- }
401
-
402
- /**
403
- * CLI entry point for stream-json mode. Exit 0 on clean, 4 on violation,
404
- * 2 on internal error.
405
- */
406
- function mainStreamJson(opts) {
407
- const projectDir = opts.projectDir || process.cwd();
408
- const mode = opts.mode || 'staged';
409
- let files;
410
- try {
411
- files = mode === 'all' ? _listAll(projectDir) : _listStaged(projectDir);
412
- } catch (e) {
413
- return { exitCode: 2, violations: [], files: [], error: e.message || String(e) };
414
- }
415
- const { violations } = streamJsonLintFiles(files, { projectDir });
416
- return {
417
- exitCode: violations.length === 0 ? 0 : 4,
418
- violations,
419
- files,
420
- };
421
- }
422
-
423
- module.exports = {
424
- lintFile,
425
- lintFiles,
426
- main,
427
- SPAWN_PATTERNS,
428
- _isWhitelistedPath,
429
- _isCommentOnlyLine,
430
- _buildFenceMap,
431
- _hasWrapperNearby,
432
- _hasSkipMarkerNearby,
433
- _matchInsideStringLiteral,
434
- // M56 D5
435
- streamJsonLintFile,
436
- streamJsonLintFiles,
437
- mainStreamJson,
438
- STREAM_JSON_SPAWN_PATTERNS,
439
- STREAM_JSON_SKIP_MARKER,
440
- };