@planu/cli 6.0.0 → 6.0.2

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 (79) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/.planu-build.json +1 -1
  3. package/dist/cli/commands/job.js +7 -1
  4. package/dist/cli/router.js +24 -5
  5. package/dist/config/official-sdd-tools.d.ts +0 -1
  6. package/dist/config/official-sdd-tools.js +0 -3
  7. package/dist/core/spec-validator.js +1 -1
  8. package/dist/engine/coach/i18n.d.ts +1 -1
  9. package/dist/engine/coach/i18n.js +2 -2
  10. package/dist/engine/code-scanner/layer-scanner.d.ts +3 -1
  11. package/dist/engine/code-scanner/layer-scanner.js +19 -3
  12. package/dist/engine/convention-scanner/codebase-scanner.js +140 -8
  13. package/dist/engine/conventions-ttl.d.ts +0 -2
  14. package/dist/engine/conventions-ttl.js +1 -1
  15. package/dist/engine/evidence-gates/artifact-reader.d.ts +0 -2
  16. package/dist/engine/evidence-gates/artifact-reader.js +0 -2
  17. package/dist/engine/execution/deadline-io.d.ts +1 -1
  18. package/dist/engine/execution/deadline-io.js +2 -2
  19. package/dist/engine/execution/package-handoff-job-executor.d.ts +1 -1
  20. package/dist/engine/execution/package-handoff-job-executor.js +42 -13
  21. package/dist/engine/execution/startup-recovery.d.ts +3 -0
  22. package/dist/engine/execution/startup-recovery.js +15 -0
  23. package/dist/engine/execution/validate-job-executor.d.ts +1 -1
  24. package/dist/engine/execution/validate-job-executor.js +23 -3
  25. package/dist/engine/handoff-packager.d.ts +2 -0
  26. package/dist/engine/handoff-packager.js +25 -9
  27. package/dist/engine/network-policy.js +31 -0
  28. package/dist/engine/test-selection/policy.js +1 -1
  29. package/dist/engine/validation-evidence-ledger.js +8 -37
  30. package/dist/engine/validation-impact-planner.d.ts +1 -3
  31. package/dist/engine/validation-impact-planner.js +2 -18
  32. package/dist/engine/validator/analyzer.js +0 -1
  33. package/dist/engine/validator/reliability-gate.js +6 -1
  34. package/dist/index.js +3 -11
  35. package/dist/security/adapters/local-file.js +8 -1
  36. package/dist/security/secret-provider.js +0 -2
  37. package/dist/storage/migrations/sdd-core-v6.js +101 -23
  38. package/dist/storage/project-identity.js +18 -2
  39. package/dist/tools/check-readiness.js +45 -35
  40. package/dist/tools/create-spec.js +18 -22
  41. package/dist/tools/init-project/agents-md-writer.js +0 -3
  42. package/dist/tools/package-handoff.js +19 -16
  43. package/dist/tools/update-status/approval-gates.d.ts +1 -1
  44. package/dist/tools/update-status/approval-gates.js +28 -5
  45. package/dist/tools/update-status/evidence-payload.d.ts +0 -2
  46. package/dist/tools/update-status/index.d.ts +1 -1
  47. package/dist/tools/update-status/index.js +25 -12
  48. package/dist/tools/update-status/transition-guard.d.ts +1 -1
  49. package/dist/tools/update-status/transition-guard.js +18 -2
  50. package/dist/tools/validate.js +29 -7
  51. package/dist/types/common/learning.d.ts +0 -17
  52. package/dist/types/durable-job.d.ts +15 -1
  53. package/dist/types/index.d.ts +0 -3
  54. package/dist/types/index.js +0 -3
  55. package/dist/types/living-spec/annotations.d.ts +0 -30
  56. package/dist/types/living-spec/annotations.js +14 -0
  57. package/dist/types/living-spec.d.ts +0 -1
  58. package/dist/types/living-spec.js +0 -1
  59. package/dist/types/project/core.d.ts +0 -2
  60. package/dist/types/project/planu-config.d.ts +0 -1
  61. package/dist/types/readiness.d.ts +2 -0
  62. package/dist/types/security.d.ts +1 -1
  63. package/dist/types/spec-quality.d.ts +0 -20
  64. package/dist/types/timing.d.ts +0 -6
  65. package/dist/types/validation-evidence.d.ts +2 -2
  66. package/dist/types/validation.d.ts +2 -0
  67. package/package.json +10 -9
  68. package/scripts/check-reliability-policies.mjs +504 -0
  69. package/dist/engine/timing/structured-log.d.ts +0 -10
  70. package/dist/engine/timing/structured-log.js +0 -36
  71. package/dist/types/analysis-detection.d.ts +0 -14
  72. package/dist/types/analysis-detection.js +0 -5
  73. package/dist/types/lessons.d.ts +0 -28
  74. package/dist/types/lessons.js +0 -3
  75. package/dist/types/living-spec/dashboard-and-sync.d.ts +0 -82
  76. package/dist/types/living-spec/dashboard-and-sync.js +0 -3
  77. package/dist/types/vector-store.d.ts +0 -46
  78. package/dist/types/vector-store.js +0 -21
  79. package/planu-plugin.json +0 -35
@@ -0,0 +1,504 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFile, readdir, stat } from 'node:fs/promises';
4
+ import { extname, join, relative, resolve } from 'node:path';
5
+ let ts;
6
+ try {
7
+ ts = (await import('typescript')).default;
8
+ } catch {
9
+ ts = undefined;
10
+ }
11
+
12
+ const rootArgIndex = process.argv.indexOf('--root');
13
+ const ROOT = resolve(rootArgIndex >= 0 ? (process.argv[rootArgIndex + 1] ?? '') : process.cwd());
14
+ const JSON_MODE = process.argv.includes('--json');
15
+ const PROTECTED = [
16
+ // Persistence and lifecycle transitions are correctness boundaries in their
17
+ // entirety. Keeping directories here prevents new stores or transition gates
18
+ // from silently escaping the policy as the codebase evolves.
19
+ 'src/storage',
20
+ 'src/tools/update-status',
21
+ 'src/security',
22
+ 'src/engine/execution',
23
+ 'src/engine/validation',
24
+ 'src/engine/safety',
25
+ 'src/engine/core-bridge.ts',
26
+ ];
27
+ const RELEASE_SCRIPTS = [];
28
+ const CLASSIFICATION = /reliability-(?:optional|cleanup|compat):\s*[A-Z][A-Z0-9_-]{2,63}/u;
29
+ const violations = [];
30
+ const structuredViolations = [];
31
+
32
+ await stat(ROOT);
33
+
34
+ if (process.argv.includes('--print-protected-dirs')) {
35
+ process.stdout.write(`${JSON.stringify(PROTECTED)}\n`);
36
+ process.exit(0);
37
+ }
38
+
39
+ for (const root of PROTECTED) {
40
+ for (const path of await walk(join(ROOT, root))) {
41
+ if (!['.ts', '.tsx', '.js', '.mjs'].includes(extname(path))) continue;
42
+ inspectSource(path, await readFile(path, 'utf8'));
43
+ }
44
+ }
45
+ for (const path of RELEASE_SCRIPTS) {
46
+ inspectShell(join(ROOT, path), await readFile(join(ROOT, path), 'utf8'));
47
+ }
48
+
49
+ if (violations.length > 0) {
50
+ if (JSON_MODE) {
51
+ process.stdout.write(`${JSON.stringify(structuredViolations)}\n`);
52
+ } else {
53
+ process.stderr.write(
54
+ `Reliability policy violations (${violations.length}):\n${violations.join('\n')}\n`,
55
+ );
56
+ }
57
+ process.exit(1);
58
+ }
59
+ process.stdout.write(JSON_MODE ? '[]\n' : 'Reliability policies passed.\n');
60
+
61
+ function inspectSource(path, source) {
62
+ if (!ts) {
63
+ inspectSourceWithoutCompiler(path, source);
64
+ return;
65
+ }
66
+ const file = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true);
67
+ const visit = (node) => {
68
+ if (ts.isCatchClause(node)) {
69
+ const body = node.block;
70
+ const bodyText = source.slice(body.getStart(file), body.end);
71
+ if (body.statements.length === 0) {
72
+ report(path, file, node, 'empty catch is forbidden; add an explicit observable action');
73
+ } else if (
74
+ !hasThrow(body) &&
75
+ !hasTypedDegradation(body) &&
76
+ !isExplicitNotFoundBranch(bodyText) &&
77
+ !hasClassifiedReport(body)
78
+ ) {
79
+ report(
80
+ path,
81
+ file,
82
+ node,
83
+ 'catch must throw, return a typed failure, handle ENOENT explicitly, or classify and report degradation',
84
+ );
85
+ }
86
+ }
87
+ if (
88
+ ts.isCallExpression(node) &&
89
+ ts.isPropertyAccessExpression(node.expression) &&
90
+ node.expression.name.text === 'catch'
91
+ ) {
92
+ const handler = node.arguments[0];
93
+ if (!handler || (!ts.isArrowFunction(handler) && !ts.isFunctionExpression(handler))) {
94
+ report(path, file, node, 'Promise.catch must use an auditable inline handler');
95
+ } else if (!ts.isBlock(handler.body)) {
96
+ report(path, file, node, 'expression Promise.catch suppression is forbidden');
97
+ } else if (
98
+ !hasThrow(handler.body) &&
99
+ !hasTypedDegradation(handler.body) &&
100
+ !hasClassifiedReport(handler.body)
101
+ ) {
102
+ report(
103
+ path,
104
+ file,
105
+ node,
106
+ 'Promise.catch must throw, return typed failure, or classify and report',
107
+ );
108
+ }
109
+ }
110
+ ts.forEachChild(node, visit);
111
+ };
112
+ visit(file);
113
+ }
114
+
115
+ function inspectSourceWithoutCompiler(path, source) {
116
+ const structural = maskCommentsAndStrings(source);
117
+ for (const block of findCatchBlocks(structural)) {
118
+ const bodyText = source.slice(block.bodyStart, block.bodyEnd);
119
+ if (bodyText.trim().length === 0) {
120
+ reportOffset(
121
+ path,
122
+ source,
123
+ block.catchOffset,
124
+ 'empty catch is forbidden; add an explicit observable action',
125
+ );
126
+ continue;
127
+ }
128
+ if (!fallbackBodyIsObservable(bodyText)) {
129
+ reportOffset(
130
+ path,
131
+ source,
132
+ block.catchOffset,
133
+ 'catch must throw, return a typed failure, handle ENOENT explicitly, or classify and report degradation',
134
+ );
135
+ }
136
+ }
137
+ for (const handler of findPromiseCatchHandlers(structural)) {
138
+ if (handler.kind === 'non-inline') {
139
+ reportOffset(
140
+ path,
141
+ source,
142
+ handler.catchOffset,
143
+ 'Promise.catch must use an auditable inline handler',
144
+ );
145
+ continue;
146
+ }
147
+ if (handler.kind === 'expression') {
148
+ reportOffset(
149
+ path,
150
+ source,
151
+ handler.catchOffset,
152
+ 'expression Promise.catch suppression is forbidden',
153
+ );
154
+ continue;
155
+ }
156
+ const bodyText = source.slice(handler.bodyStart, handler.bodyEnd);
157
+ if (!fallbackBodyIsObservable(bodyText)) {
158
+ reportOffset(
159
+ path,
160
+ source,
161
+ handler.catchOffset,
162
+ 'Promise.catch must throw, return typed failure, or classify and report',
163
+ );
164
+ }
165
+ }
166
+ }
167
+
168
+ function maskCommentsAndStrings(source) {
169
+ const chars = source.split('');
170
+ let state = 'code';
171
+ const templateExpressionDepth = [];
172
+ let regexCharacterClass = false;
173
+ for (let index = 0; index < chars.length; index += 1) {
174
+ const char = chars[index];
175
+ const next = chars[index + 1];
176
+ if (state === 'code') {
177
+ if (char === '/' && next === '/') {
178
+ chars[index] = chars[index + 1] = ' ';
179
+ state = 'line-comment';
180
+ index += 1;
181
+ } else if (char === '/' && next === '*') {
182
+ chars[index] = chars[index + 1] = ' ';
183
+ state = 'block-comment';
184
+ index += 1;
185
+ } else if (char === '/' && isRegexLiteralStart(source, index)) {
186
+ chars[index] = ' ';
187
+ regexCharacterClass = false;
188
+ state = 'regex';
189
+ } else if (char === "'" || char === '"') {
190
+ chars[index] = ' ';
191
+ state = char;
192
+ } else if (char === '`') {
193
+ chars[index] = ' ';
194
+ state = 'template';
195
+ } else if (templateExpressionDepth.length > 0 && char === '{') {
196
+ templateExpressionDepth[templateExpressionDepth.length - 1] += 1;
197
+ } else if (templateExpressionDepth.length > 0 && char === '}') {
198
+ const last = templateExpressionDepth.length - 1;
199
+ templateExpressionDepth[last] -= 1;
200
+ if (templateExpressionDepth[last] === 0) {
201
+ templateExpressionDepth.pop();
202
+ chars[index] = ' ';
203
+ state = 'template';
204
+ }
205
+ }
206
+ } else if (state === 'line-comment') {
207
+ if (char === '\n') state = 'code';
208
+ else chars[index] = ' ';
209
+ } else if (state === 'block-comment') {
210
+ if (char === '*' && next === '/') {
211
+ chars[index] = chars[index + 1] = ' ';
212
+ state = 'code';
213
+ index += 1;
214
+ } else if (char !== '\n') chars[index] = ' ';
215
+ } else if (state === 'template') {
216
+ if (char === '\\') {
217
+ chars[index] = ' ';
218
+ if (next !== undefined && next !== '\n') {
219
+ chars[index + 1] = ' ';
220
+ index += 1;
221
+ }
222
+ } else if (char === '`') {
223
+ chars[index] = ' ';
224
+ state = 'code';
225
+ } else if (char === '$' && next === '{') {
226
+ chars[index] = chars[index + 1] = ' ';
227
+ templateExpressionDepth.push(1);
228
+ state = 'code';
229
+ index += 1;
230
+ } else if (char !== '\n') {
231
+ chars[index] = ' ';
232
+ }
233
+ } else if (state === 'regex') {
234
+ chars[index] = char === '\n' ? '\n' : ' ';
235
+ if (char === '\\' && next !== undefined && next !== '\n') {
236
+ chars[index + 1] = ' ';
237
+ index += 1;
238
+ } else if (char === '[') {
239
+ regexCharacterClass = true;
240
+ } else if (char === ']') {
241
+ regexCharacterClass = false;
242
+ } else if (char === '/' && !regexCharacterClass) {
243
+ while (/[A-Za-z]/u.test(source[index + 1] ?? '')) {
244
+ chars[index + 1] = ' ';
245
+ index += 1;
246
+ }
247
+ state = 'code';
248
+ }
249
+ } else if (char === '\\') {
250
+ chars[index] = ' ';
251
+ if (next !== undefined && next !== '\n') {
252
+ chars[index + 1] = ' ';
253
+ index += 1;
254
+ }
255
+ } else if (char === state) {
256
+ chars[index] = ' ';
257
+ state = 'code';
258
+ } else if (char !== '\n') {
259
+ chars[index] = ' ';
260
+ }
261
+ }
262
+ return chars.join('');
263
+ }
264
+
265
+ function isRegexLiteralStart(source, slashIndex) {
266
+ const before = source.slice(0, slashIndex);
267
+ const tokens = before.match(/\+\+|--|=>|[A-Za-z_$][\w$]*|\S/gu);
268
+ const token = tokens?.at(-1);
269
+ if (!token) return true;
270
+ if (token === '++' || token === '--') return false;
271
+ return (
272
+ /^[([{,:;=!?&|+*%^~<>-]$/u.test(token) ||
273
+ /^(?:return|case|throw|delete|void|typeof|instanceof|in|of|yield|await)$/u.test(token) ||
274
+ token === '=>'
275
+ );
276
+ }
277
+
278
+ function findCatchBlocks(source) {
279
+ const blocks = [];
280
+ const catchPattern = /\bcatch\s*(?:\([^)]*\))?\s*\{/gu;
281
+ for (const match of source.matchAll(catchPattern)) {
282
+ const open = match.index + match[0].lastIndexOf('{');
283
+ let depth = 1;
284
+ let cursor = open + 1;
285
+ for (; cursor < source.length && depth > 0; cursor += 1) {
286
+ if (source[cursor] === '{') depth += 1;
287
+ else if (source[cursor] === '}') depth -= 1;
288
+ }
289
+ if (depth === 0) {
290
+ blocks.push({ catchOffset: match.index, bodyStart: open + 1, bodyEnd: cursor - 1 });
291
+ }
292
+ }
293
+ return blocks;
294
+ }
295
+
296
+ function findPromiseCatchHandlers(source) {
297
+ const handlers = [];
298
+ const catchPattern = /\.catch\b/gu;
299
+ const callablePattern =
300
+ /^\(\s*(?:(?:async\s+)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>|function(?:\s+[A-Za-z_$][\w$]*)?\s*\([^)]*\))/u;
301
+ const blockPattern = new RegExp(`${callablePattern.source}\\s*\\{`, 'u');
302
+ for (const match of source.matchAll(catchPattern)) {
303
+ let callStart = match.index + match[0].length;
304
+ callStart = skipWhitespace(source, callStart);
305
+ if (source.startsWith('?.', callStart)) callStart = skipWhitespace(source, callStart + 2);
306
+ if (source[callStart] === '<') {
307
+ const typeArgumentsEnd = findBalancedTypeArgumentsEnd(source, callStart);
308
+ if (typeArgumentsEnd === null) continue;
309
+ callStart = skipWhitespace(source, typeArgumentsEnd + 1);
310
+ }
311
+ if (source[callStart] !== '(') continue;
312
+ const remainder = source.slice(callStart);
313
+ const blockHeader = blockPattern.exec(remainder);
314
+ if (!blockHeader) {
315
+ handlers.push({
316
+ catchOffset: match.index,
317
+ kind: callablePattern.test(remainder) ? 'expression' : 'non-inline',
318
+ });
319
+ continue;
320
+ }
321
+ const open = callStart + blockHeader[0].lastIndexOf('{');
322
+ const close = findBalancedBlockEnd(source, open);
323
+ if (close === null) {
324
+ handlers.push({ catchOffset: match.index, kind: 'non-inline' });
325
+ continue;
326
+ }
327
+ handlers.push({
328
+ bodyEnd: close,
329
+ bodyStart: open + 1,
330
+ catchOffset: match.index,
331
+ kind: 'block',
332
+ });
333
+ }
334
+ return handlers;
335
+ }
336
+
337
+ function skipWhitespace(source, start) {
338
+ let cursor = start;
339
+ while (/\s/u.test(source[cursor] ?? '')) cursor += 1;
340
+ return cursor;
341
+ }
342
+
343
+ function findBalancedTypeArgumentsEnd(source, open) {
344
+ let depth = 1;
345
+ for (let cursor = open + 1; cursor < source.length; cursor += 1) {
346
+ if (source[cursor] === '<') depth += 1;
347
+ else if (source[cursor] === '>' && source[cursor - 1] !== '=') depth -= 1;
348
+ if (depth === 0) return cursor;
349
+ }
350
+ return null;
351
+ }
352
+
353
+ function findBalancedBlockEnd(source, open) {
354
+ let depth = 1;
355
+ for (let cursor = open + 1; cursor < source.length; cursor += 1) {
356
+ if (source[cursor] === '{') depth += 1;
357
+ else if (source[cursor] === '}') depth -= 1;
358
+ if (depth === 0) return cursor;
359
+ }
360
+ return null;
361
+ }
362
+
363
+ function fallbackBodyIsObservable(bodyText) {
364
+ const structural = maskCommentsAndStrings(bodyText);
365
+ if (/\bthrow\b/u.test(structural)) return true;
366
+ if (/(?:ENOENT|ESRCH|isNotFound|notFound)/u.test(structural) && /\breturn\b/u.test(structural)) {
367
+ return true;
368
+ }
369
+ const classified =
370
+ /\b(?:reportClassifiedDegradation|emitClassifiedDegradation)\s*\(\s*['"][A-Z][A-Z0-9_-]{2,63}['"]/gu;
371
+ for (const match of bodyText.matchAll(classified)) {
372
+ if (
373
+ /^(?:reportClassifiedDegradation|emitClassifiedDegradation)\b/u.test(
374
+ structural.slice(match.index),
375
+ )
376
+ ) {
377
+ return true;
378
+ }
379
+ }
380
+ if (
381
+ /\breturn\s*\{[\s\S]*?(?:(?:ok|valid)\s*:\s*false|(?:blocked|isError)\s*:\s*true)/u.test(
382
+ structural,
383
+ )
384
+ ) {
385
+ return true;
386
+ }
387
+ const typedStatus = /\bstatus\s*:\s*['"](?:failed|degraded|invalid)['"]/gu;
388
+ for (const match of bodyText.matchAll(typedStatus)) {
389
+ if (/^status\s*:/u.test(structural.slice(match.index))) return true;
390
+ }
391
+ return false;
392
+ }
393
+
394
+ function hasThrow(node) {
395
+ let found = false;
396
+ const visit = (child) => {
397
+ if (ts.isThrowStatement(child)) {
398
+ found = true;
399
+ return;
400
+ }
401
+ ts.forEachChild(child, visit);
402
+ };
403
+ visit(node);
404
+ return found;
405
+ }
406
+
407
+ function hasClassifiedReport(node) {
408
+ let found = false;
409
+ const visit = (child) => {
410
+ if (
411
+ ts.isCallExpression(child) &&
412
+ ts.isIdentifier(child.expression) &&
413
+ ['reportClassifiedDegradation', 'emitClassifiedDegradation'].includes(
414
+ child.expression.text,
415
+ ) &&
416
+ child.arguments.length > 0 &&
417
+ ts.isStringLiteral(child.arguments[0]) &&
418
+ /^[A-Z][A-Z0-9_-]{2,63}$/u.test(child.arguments[0].text)
419
+ ) {
420
+ found = true;
421
+ return;
422
+ }
423
+ ts.forEachChild(child, visit);
424
+ };
425
+ visit(node);
426
+ return found;
427
+ }
428
+
429
+ function hasTypedDegradation(node) {
430
+ let found = false;
431
+ const visit = (child) => {
432
+ if (
433
+ ts.isReturnStatement(child) &&
434
+ child.expression &&
435
+ ts.isObjectLiteralExpression(child.expression)
436
+ ) {
437
+ found = child.expression.properties.some((property) => {
438
+ if (!ts.isPropertyAssignment(property)) return false;
439
+ const name = property.name.getText();
440
+ const value = property.initializer.getText();
441
+ return (
442
+ ((name === 'ok' || name === 'valid') && value === 'false') ||
443
+ ((name === 'blocked' || name === 'isError') && value === 'true') ||
444
+ (name === 'status' && /^['"](?:failed|degraded|invalid)['"]$/u.test(value))
445
+ );
446
+ });
447
+ if (found) return;
448
+ }
449
+ ts.forEachChild(child, visit);
450
+ };
451
+ visit(node);
452
+ return found;
453
+ }
454
+
455
+ function isExplicitNotFoundBranch(text) {
456
+ return /(?:ENOENT|ESRCH|isNotFound|notFound)/u.test(text) && /\breturn\b/u.test(text);
457
+ }
458
+
459
+ function inspectShell(path, source) {
460
+ const lines = source.split('\n');
461
+ lines.forEach((line, index) => {
462
+ if (!/\|\|\s*true/u.test(line)) return;
463
+ const context = `${lines[index - 1] ?? ''}\n${line}`;
464
+ if (!CLASSIFICATION.test(context)) {
465
+ const relPath = relative(ROOT, path);
466
+ const lineNumber = index + 1;
467
+ const rule = 'unclassified shell suppression';
468
+ violations.push(`${relPath}:${String(lineNumber)} ${rule}`);
469
+ structuredViolations.push({ file: relPath, line: lineNumber, rule });
470
+ }
471
+ });
472
+ }
473
+
474
+ function report(path, file, node, message) {
475
+ const position = file.getLineAndCharacterOfPosition(node.getStart(file));
476
+ const relPath = relative(ROOT, path);
477
+ const line = position.line + 1;
478
+ violations.push(`${relPath}:${String(line)} ${message}`);
479
+ structuredViolations.push({ file: relPath, line, rule: message });
480
+ }
481
+
482
+ function reportOffset(path, source, offset, message) {
483
+ const relPath = relative(ROOT, path);
484
+ const line = source.slice(0, offset).split('\n').length;
485
+ violations.push(`${relPath}:${String(line)} ${message}`);
486
+ structuredViolations.push({ file: relPath, line, rule: message });
487
+ }
488
+
489
+ async function walk(path) {
490
+ let metadata;
491
+ try {
492
+ metadata = await stat(path);
493
+ } catch (error) {
494
+ if (error?.code === 'ENOENT') return [];
495
+ throw error;
496
+ }
497
+ if (metadata.isFile()) return [path];
498
+ const paths = [];
499
+ for (const entry of await readdir(path, { withFileTypes: true })) {
500
+ if (entry.name === 'node_modules' || entry.name === 'dist') continue;
501
+ paths.push(...(await walk(join(path, entry.name))));
502
+ }
503
+ return paths;
504
+ }
@@ -1,10 +0,0 @@
1
- /**
2
- * Measure elapsed time for an async operation and emit a timing record.
3
- * The operation result is returned unchanged.
4
- * Only adds overhead when PLANU_TIMING=1.
5
- */
6
- export declare function measureStep<T>(step: string, fn: () => Promise<T>): Promise<T>;
7
- /**
8
- * Synchronous variant of measureStep.
9
- */
10
- //# sourceMappingURL=structured-log.d.ts.map
@@ -1,36 +0,0 @@
1
- // engine/timing/structured-log.ts — Structured timing log helper (SPEC-713)
2
- // Emits JSON {step, durationMs} entries to stderr for Phase 0 diagnostic.
3
- // Zero production overhead: only active when PLANU_TIMING=1 env var is set.
4
- const TIMING_ENABLED = process.env.PLANU_TIMING === '1';
5
- /**
6
- * Emit a single timing record to stderr in JSON format.
7
- * Only active when PLANU_TIMING=1.
8
- */
9
- function emitTiming(record) {
10
- if (!TIMING_ENABLED) {
11
- return;
12
- }
13
- process.stderr.write(JSON.stringify(record) + '\n');
14
- }
15
- /**
16
- * Measure elapsed time for an async operation and emit a timing record.
17
- * The operation result is returned unchanged.
18
- * Only adds overhead when PLANU_TIMING=1.
19
- */
20
- export async function measureStep(step, fn) {
21
- if (!TIMING_ENABLED) {
22
- return fn();
23
- }
24
- const start = performance.now();
25
- try {
26
- return await fn();
27
- }
28
- finally {
29
- const durationMs = Math.round(performance.now() - start);
30
- emitTiming({ step, durationMs, ts: new Date().toISOString() });
31
- }
32
- }
33
- /**
34
- * Synchronous variant of measureStep.
35
- */
36
- //# sourceMappingURL=structured-log.js.map
@@ -1,14 +0,0 @@
1
- type OtelSignal = 'traces' | 'metrics' | 'logs';
2
- type TelemetryBackend = 'jaeger' | 'grafana-tempo' | 'honeycomb' | 'datadog' | 'newrelic' | 'grafana-cloud' | 'local-collector';
3
- export interface OtelDetectionResult {
4
- isInstalled: boolean;
5
- signals: OtelSignal[];
6
- backend?: TelemetryBackend;
7
- hasSLOs: boolean;
8
- serviceNameConfigured: boolean;
9
- hasConsoleExporter: boolean;
10
- needsOtel: boolean;
11
- sdkLanguage: string | null;
12
- }
13
- export {};
14
- //# sourceMappingURL=analysis-detection.d.ts.map
@@ -1,5 +0,0 @@
1
- // Planu — Analysis detection result types (split from analysis.ts)
2
- // Covers: smart contract vulnerability, OpenTelemetry, config health, and DX scoring.
3
- export {};
4
- // === SPEC-042: Config Health Checker ===
5
- //# sourceMappingURL=analysis-detection.js.map
@@ -1,28 +0,0 @@
1
- type LessonSeverity = 'low' | 'medium' | 'high';
2
- type LessonCategory = 'estimation' | 'testing' | 'architecture' | 'security' | 'performance' | 'ux' | 'process' | 'other';
3
- export interface Lesson {
4
- id: string;
5
- projectId: string;
6
- specId?: string;
7
- category: LessonCategory;
8
- severity: LessonSeverity;
9
- title: string;
10
- description: string;
11
- prevention: string;
12
- tags: string[];
13
- createdAt: string;
14
- }
15
- export interface LessonFilters {
16
- category?: LessonCategory;
17
- severity?: LessonSeverity;
18
- specId?: string;
19
- tags?: string[];
20
- limit?: number;
21
- }
22
- /** Result entry from searchLessons — lesson paired with its Jaccard similarity score. SPEC-526 */
23
- export interface LessonSearchResult {
24
- lesson: Lesson;
25
- score: number;
26
- }
27
- export {};
28
- //# sourceMappingURL=lessons.d.ts.map
@@ -1,3 +0,0 @@
1
- // types/lessons.ts — SPEC-233: Lessons learned per-project domain types
2
- export {};
3
- //# sourceMappingURL=lessons.js.map
@@ -1,82 +0,0 @@
1
- /** Options for creating a drift watcher. */
2
- /** In-memory state of the drift watcher. */
3
- /** A single cached drift entry. */
4
- /** Drift watcher instance interface. */
5
- /** Minimal spec shape needed for dashboard collection. */
6
- /** A single spec entry for the living dashboard. */
7
- interface DashboardSpecEntry {
8
- specId: string;
9
- status: string;
10
- completion: number;
11
- driftDetected: boolean;
12
- changedFileCount: number;
13
- signatureChangeCount: number;
14
- lastCheckedAt: string;
15
- }
16
- /** Summary statistics for the dashboard. */
17
- interface DashboardSummary {
18
- totalSpecs: number;
19
- specsWithDrift: number;
20
- averageCompletion: number;
21
- healthScore: number;
22
- generatedAt: string;
23
- }
24
- /** A single trend data point. */
25
- interface DashboardTrendPoint {
26
- timestamp: string;
27
- specsWithDrift: number;
28
- averageCompletion: number;
29
- healthScore: number;
30
- }
31
- /** A row in the spec diff table. */
32
- /** Status of a criterion's test coverage. */
33
- /** Coverage information for a group of annotations. */
34
- /** Full test coverage report correlated with specs (living-spec). */
35
- /** Minimal shape of a Vitest JSON test result. */
36
- /** Minimal shape of a Vitest JSON test file. */
37
- /** Minimal shape of the full Vitest JSON report. */
38
- /** A single test case from JUnit XML. */
39
- /** A normalized test result for grouping. */
40
- /** Direction of synchronization. */
41
- type SyncDirection = 'spec-to-code' | 'code-to-spec';
42
- /** Criterion info for TODO generation. */
43
- /** A TODO comment to be generated in code. */
44
- /** A progress update to apply to a spec. */
45
- /** A conflict detected during sync. */
46
- export interface SyncConflict {
47
- id: string;
48
- specId: string;
49
- criterion: number;
50
- direction: SyncDirection;
51
- description: string;
52
- codeState: string;
53
- specState: string;
54
- detectedAt: string;
55
- resolved: boolean;
56
- resolution?: string;
57
- }
58
- /** An entry in the sync log. */
59
- export interface SyncLogEntry {
60
- timestamp: string;
61
- direction: SyncDirection;
62
- specId: string;
63
- action: string;
64
- details: string;
65
- }
66
- /** Result of a sync operation. */
67
- /** Input for the living_spec_watch tool. */
68
- /** Input for the living_spec_status tool. */
69
- /** Input for the spec_diff tool. */
70
- /** Input for the living_spec_coverage tool. */
71
- /** Input for the sync_spec_to_code tool. */
72
- /** Input for the sync_code_to_spec tool. */
73
- /** Input for the resolve_sync_conflict tool. */
74
- /** Dashboard data persisted to disk. */
75
- export interface LivingDashboardData {
76
- entries: DashboardSpecEntry[];
77
- summary: DashboardSummary;
78
- trends: DashboardTrendPoint[];
79
- updatedAt: string;
80
- }
81
- export {};
82
- //# sourceMappingURL=dashboard-and-sync.d.ts.map
@@ -1,3 +0,0 @@
1
- // Planu — Living Spec types: drift watcher, dashboard, coverage, sync (split from living-spec.ts)
2
- export {};
3
- //# sourceMappingURL=dashboard-and-sync.js.map