@planu/cli 5.7.12 → 5.7.13

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 (43) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/.planu-build.json +1 -1
  3. package/dist/cli/commands/doctor.d.ts +2 -1
  4. package/dist/cli/commands/doctor.js +51 -1
  5. package/dist/cli/commands/install.js +14 -0
  6. package/dist/config/registries/strict-audit-scripts.json +4 -0
  7. package/dist/engine/doctor/npm-cache-check.d.ts +10 -0
  8. package/dist/engine/doctor/npm-cache-check.js +109 -0
  9. package/dist/engine/ears-gate.d.ts +1 -0
  10. package/dist/engine/ears-gate.js +64 -2
  11. package/dist/engine/framework-detector.d.ts +1 -0
  12. package/dist/engine/framework-detector.js +1 -1
  13. package/dist/engine/handoff-artifacts/schemas.d.ts +2 -0
  14. package/dist/engine/handoff-artifacts/schemas.js +1 -1
  15. package/dist/engine/spec-grounding/contract.js +3 -1
  16. package/dist/engine/spec-grounding/grounding-entry-parser.js +1 -0
  17. package/dist/engine/validator/blast-radius-gate.js +95 -9
  18. package/dist/engine/validator/spec-compliance-runner.d.ts +1 -0
  19. package/dist/engine/validator/spec-compliance-runner.js +75 -25
  20. package/dist/engine/validator/strict-audits-gate.d.ts +3 -0
  21. package/dist/engine/validator/strict-audits-gate.js +74 -0
  22. package/dist/engine/validator/validation-report-writer.js +4 -2
  23. package/dist/tools/challenge-spec/scenarios-data.js +4 -3
  24. package/dist/tools/challenge-spec/scenarios-utils.d.ts +1 -2
  25. package/dist/tools/challenge-spec/scenarios-utils.js +13 -2
  26. package/dist/tools/register-spec-tools/core-spec-tools.js +5 -0
  27. package/dist/tools/update-status/batch.js +1 -0
  28. package/dist/tools/update-status/file-sync.d.ts +1 -1
  29. package/dist/tools/update-status/file-sync.js +4 -2
  30. package/dist/tools/update-status/index.js +4 -1
  31. package/dist/tools/update-status/transition-guard.d.ts +0 -1
  32. package/dist/tools/update-status/transition-guard.js +9 -5
  33. package/dist/tools/validate.js +67 -2
  34. package/dist/types/handoff-artifacts.d.ts +1 -1
  35. package/dist/types/installation.d.ts +10 -0
  36. package/dist/types/spec-format.d.ts +1 -0
  37. package/dist/types/spec-grounding.d.ts +1 -1
  38. package/dist/types/validation-evidence.d.ts +30 -1
  39. package/package.json +1 -1
  40. package/planu-plugin.json +1 -1
  41. package/src/i18n/messages/en.json +1 -1
  42. package/src/i18n/messages/es.json +1 -1
  43. package/src/i18n/messages/pt.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [5.7.13] - 2026-09-03
2
+
3
+ ### Features
4
+ - feat(cli): diagnose root-owned npm cache in doctor and install (SPEC-1733)
5
+
6
+ ### Bug Fixes
7
+ - fix(spec-grounding): accept review_evidence as contract grounding source
8
+ - fix(validator): return indeterminate verdicts when vitest runner fails (SPEC-1734)
9
+ - fix(challenge): exclude package-manager cache clauses from stale-cache scenario (SPEC-1778)
10
+ - fix(validate): run strict audit scripts as a validate gate (SPEC-1775)
11
+ - fix(update-status): allow done to discarded with an audited reason (SPEC-1708)
12
+ - fix(update-status): forward reason through update_status_batch (SPEC-1728)
13
+ - fix(validate): run integration importers in the blast-radius gate (SPEC-1777)
14
+ - fix(ears): mask quoted literals before the vague-verb scan (SPEC-1632)
15
+
16
+
1
17
  ## [5.7.12] - 2026-09-03
2
18
 
3
19
  ### Features
@@ -1 +1 @@
1
- {"schemaVersion":1,"commit":"088e6b8cc7a4e82395e945609d0c575d31895578"}
1
+ {"schemaVersion":1,"commit":"ee3c4024cb57c413795f82e3c5049899d22e2b3f"}
@@ -27,8 +27,9 @@ declare function checkRuntimeDatabase(): DeepCheckResult;
27
27
  declare function checkLocaleResolution(): DeepCheckResult;
28
28
  /** Check (5): every package-owned runtime helper compiled CLI code imports is present. */
29
29
  declare function checkInstallationIntegrity(): DeepCheckResult;
30
+ declare function checkNpmCache(): DeepCheckResult;
30
31
  declare function runDeepChecks(): DeepCheckResult[];
31
- export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, runDeepChecks, };
32
+ export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, checkNpmCache, runDeepChecks, };
32
33
  export { checkTool };
33
34
  export declare const doctorCommand: CliCommand;
34
35
  //# sourceMappingURL=doctor.d.ts.map
@@ -10,6 +10,7 @@ import { readJsonFile, hasPlanuEntry } from './install.js';
10
10
  import { resolveStorageLayout } from '../../storage/storage-layout.js';
11
11
  import { RuntimeDatabase } from '../../storage/runtime-db.js';
12
12
  import { getLocale, t } from '../../i18n/index.js';
13
+ import { MAX_FOREIGN_ENTRIES, MAX_SCANNED_ENTRIES, currentUid, resolveNpmCacheDir, checkNpmCacheOwnership, } from '../../engine/doctor/npm-cache-check.js';
13
14
  // ---------------------------------------------------------------------------
14
15
  // Constants
15
16
  // ---------------------------------------------------------------------------
@@ -251,6 +252,54 @@ function checkInstallationIntegrity() {
251
252
  detail: `INCOMPLETE_INSTALLATION: ${packageName}@${version} is missing ${missing.join(', ')}. Reinstall with: npm install -g ${packageName}@${version}`,
252
253
  };
253
254
  }
255
+ function checkNpmCache() {
256
+ const uid = currentUid();
257
+ if (uid === null) {
258
+ return {
259
+ name: 'npm cache',
260
+ status: 'ok',
261
+ detail: 'Ownership check does not apply on this platform.',
262
+ };
263
+ }
264
+ const cacheDir = resolveNpmCacheDir(process.env, homedir());
265
+ const finding = checkNpmCacheOwnership(cacheDir, uid);
266
+ if (finding.status === 'ok') {
267
+ if (!finding.truncated) {
268
+ return {
269
+ name: 'npm cache',
270
+ status: 'ok',
271
+ detail: `Checked ${String(finding.scanned)} entries under ${finding.cacheDir}; all owned by the current user.`,
272
+ };
273
+ }
274
+ return {
275
+ name: 'npm cache',
276
+ status: 'ok',
277
+ detail: `Checked the first ${String(MAX_SCANNED_ENTRIES)} entries under ${finding.cacheDir}; all owned by the current user.`,
278
+ };
279
+ }
280
+ if (finding.status === 'unreadable') {
281
+ return {
282
+ name: 'npm cache',
283
+ status: 'warn',
284
+ detail: `Cannot read ${finding.cacheDir}. Check permissions, then run: ${finding.fix}`,
285
+ };
286
+ }
287
+ const noun = finding.foreignCount === 1 ? 'entry' : 'entries';
288
+ const limits = [];
289
+ if (finding.foreignCount >= MAX_FOREIGN_ENTRIES) {
290
+ limits.push(`count capped at ${String(MAX_FOREIGN_ENTRIES)}`);
291
+ }
292
+ if (finding.truncated) {
293
+ limits.push(`scan stopped at ${String(MAX_SCANNED_ENTRIES)} entries`);
294
+ }
295
+ const suffix = limits.length > 0 ? ` (${limits.join('; ')})` : '';
296
+ return {
297
+ name: 'npm cache',
298
+ status: 'fail',
299
+ detail: `npm cache contains ${String(finding.foreignCount)} ${noun} not owned by the current user${suffix}` +
300
+ ` — npx cannot write to it and the MCP server fails to start. Run: ${finding.fix}`,
301
+ };
302
+ }
254
303
  function runDeepChecks() {
255
304
  return [
256
305
  checkNodeVersion(),
@@ -258,6 +307,7 @@ function runDeepChecks() {
258
307
  checkRuntimeDatabase(),
259
308
  checkLocaleResolution(),
260
309
  checkInstallationIntegrity(),
310
+ checkNpmCache(),
261
311
  ];
262
312
  }
263
313
  function deepCheckIcon(status) {
@@ -282,7 +332,7 @@ function printDeepChecks(results) {
282
332
  }
283
333
  }
284
334
  // Exported for tests
285
- export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, runDeepChecks, };
335
+ export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, checkNpmCache, runDeepChecks, };
286
336
  function statusIcon(status) {
287
337
  switch (status) {
288
338
  case 'ok':
@@ -8,6 +8,7 @@ import { planuVersion } from '../../config/version.js';
8
8
  import { confirm, select } from '../interactive.js';
9
9
  import { resolveStorageLayout } from '../../storage/storage-layout.js';
10
10
  import { removeCommercialState } from '../../engine/migrations/remove-commercial-state.js';
11
+ import { currentUid, resolveNpmCacheDir, checkNpmCacheOwnership, } from '../../engine/doctor/npm-cache-check.js';
11
12
  // ---------------------------------------------------------------------------
12
13
  // Constants
13
14
  // ---------------------------------------------------------------------------
@@ -299,6 +300,18 @@ function printDetectionResults(detected, notFound) {
299
300
  process.stdout.write(` ${dim('-')} ${tool.name} ${dim('(not found)')}\n`);
300
301
  }
301
302
  }
303
+ function printNpmCacheWarning() {
304
+ const uid = currentUid();
305
+ if (uid === null) {
306
+ return;
307
+ }
308
+ const cacheDir = resolveNpmCacheDir(process.env, homedir());
309
+ const finding = checkNpmCacheOwnership(cacheDir, uid);
310
+ if (finding.status !== 'foreign-owned') {
311
+ return;
312
+ }
313
+ process.stdout.write(`${yellow('⚠ npm cache has files owned by another user.')} Run: ${finding.fix}\n\n`);
314
+ }
302
315
  async function resolveScope(scopeArg) {
303
316
  if (scopeArg === 'user' || scopeArg === 'project') {
304
317
  return scopeArg;
@@ -417,6 +430,7 @@ export const installCommand = {
417
430
  }
418
431
  printDetectionResults(detected, notFound);
419
432
  process.stdout.write('\n');
433
+ printNpmCacheWarning();
420
434
  if (detected.length === 0) {
421
435
  const docsUrl = claudeCodeDocsUrl();
422
436
  process.stdout.write(`${yellow('⚠ No AI tools detected on this machine.')}\n\n` +
@@ -0,0 +1,4 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "scripts": ["audit:hardcodes", "check:public-privacy", "check:environment-schema", "audit:i18n"]
4
+ }
@@ -0,0 +1,10 @@
1
+ import type { NpmCacheFinding } from '../../types/index.js';
2
+ export declare const CACACHE_DIR = "_cacache";
3
+ export declare const NPM_CACHE_SUBDIRS: readonly ['content-v2', 'index-v5'];
4
+ export declare const MAX_FOREIGN_ENTRIES = 50;
5
+ export declare const MAX_SCANNED_ENTRIES = 2000;
6
+ export declare const MAX_SAMPLE_ENTRIES = 5;
7
+ export declare function currentUid(): number | null;
8
+ export declare function resolveNpmCacheDir(env: NodeJS.ProcessEnv, home: string): string;
9
+ export declare function checkNpmCacheOwnership(cacheDir: string, uid: number): NpmCacheFinding;
10
+ //# sourceMappingURL=npm-cache-check.d.ts.map
@@ -0,0 +1,109 @@
1
+ import { existsSync, readdirSync, lstatSync } from 'node:fs';
2
+ import { join, relative } from 'node:path';
3
+ export const CACACHE_DIR = '_cacache';
4
+ export const NPM_CACHE_SUBDIRS = ['content-v2', 'index-v5'];
5
+ export const MAX_FOREIGN_ENTRIES = 50;
6
+ export const MAX_SCANNED_ENTRIES = 2000;
7
+ export const MAX_SAMPLE_ENTRIES = 5;
8
+ export function currentUid() {
9
+ return process.getuid?.() ?? null;
10
+ }
11
+ export function resolveNpmCacheDir(env, home) {
12
+ const configured = env.npm_config_cache;
13
+ if (configured !== undefined && configured.trim() !== '') {
14
+ return configured;
15
+ }
16
+ return join(home, '.npm');
17
+ }
18
+ function readDirEntries(dir) {
19
+ try {
20
+ return readdirSync(dir, { withFileTypes: true });
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
26
+ function statEntry(entryPath) {
27
+ try {
28
+ return lstatSync(entryPath);
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ export function checkNpmCacheOwnership(cacheDir, uid) {
35
+ const fix = `sudo chown -R $USER ${cacheDir}`;
36
+ const emptyFinding = (status) => ({
37
+ status,
38
+ cacheDir,
39
+ foreignCount: 0,
40
+ scanned: 0,
41
+ truncated: false,
42
+ sampleEntries: [],
43
+ fix,
44
+ });
45
+ if (!existsSync(cacheDir)) {
46
+ return emptyFinding('ok');
47
+ }
48
+ if (readDirEntries(cacheDir) === null) {
49
+ return emptyFinding('unreadable');
50
+ }
51
+ const cacache = join(cacheDir, CACACHE_DIR);
52
+ if (!existsSync(cacache)) {
53
+ return emptyFinding('ok');
54
+ }
55
+ let foreignCount = 0;
56
+ let scanned = 0;
57
+ let truncated = false;
58
+ const sampleEntries = [];
59
+ const walkDir = (dir) => {
60
+ const entries = readDirEntries(dir);
61
+ if (entries === null) {
62
+ return false;
63
+ }
64
+ for (const entry of entries) {
65
+ if (scanned >= MAX_SCANNED_ENTRIES) {
66
+ truncated = true;
67
+ return true;
68
+ }
69
+ scanned += 1;
70
+ const entryPath = join(dir, entry.name);
71
+ const st = statEntry(entryPath);
72
+ if (st === null) {
73
+ continue;
74
+ }
75
+ if (st.uid !== uid) {
76
+ foreignCount += 1;
77
+ if (sampleEntries.length < MAX_SAMPLE_ENTRIES) {
78
+ sampleEntries.push(relative(cacheDir, entryPath));
79
+ }
80
+ if (foreignCount >= MAX_FOREIGN_ENTRIES) {
81
+ return true;
82
+ }
83
+ }
84
+ if (st.isDirectory() && walkDir(entryPath)) {
85
+ return true;
86
+ }
87
+ }
88
+ return false;
89
+ };
90
+ for (const name of NPM_CACHE_SUBDIRS) {
91
+ const root = join(cacache, name);
92
+ if (!existsSync(root)) {
93
+ continue;
94
+ }
95
+ if (walkDir(root)) {
96
+ break;
97
+ }
98
+ }
99
+ return {
100
+ status: foreignCount > 0 ? 'foreign-owned' : 'ok',
101
+ cacheDir,
102
+ foreignCount,
103
+ scanned,
104
+ truncated,
105
+ sampleEntries,
106
+ fix,
107
+ };
108
+ }
109
+ //# sourceMappingURL=npm-cache-check.js.map
@@ -9,6 +9,7 @@ export interface CopulaViolation {
9
9
  * Returns a CopulaViolation if found, or null if the text is clean.
10
10
  */
11
11
  export declare function checkCopulaViolation(scenarioText: string): CopulaViolation | null;
12
+ export declare function maskQuotedSpans(text: string): string;
12
13
  /**
13
14
  * SPEC-631: Scan acceptance criteria lines for vague modal verbs.
14
15
  * Returns formatted blocker strings (one per violation) with original line and GWT rewrite.
@@ -26,8 +26,70 @@ export function checkCopulaViolation(scenarioText) {
26
26
  function stripLeadingBullet(line) {
27
27
  return line.replace(/^-\s*(\[[ x]\]\s*)?/i, '').trim();
28
28
  }
29
+ const QUOTE_MASK_CHAR = '#';
30
+ const QUOTE_DELIMITERS = ["'", '"', '`'];
31
+ const WORD_CHARACTER = /[A-Za-z0-9]/;
32
+ function isSingleQuoteOpener(text, index) {
33
+ return index === 0 || !WORD_CHARACTER.test(text.charAt(index - 1));
34
+ }
35
+ function findClosingQuote(text, delimiter, openIndex) {
36
+ let cursor = openIndex + 1;
37
+ while (cursor < text.length) {
38
+ const candidate = text.indexOf(delimiter, cursor);
39
+ if (candidate === -1) {
40
+ return -1;
41
+ }
42
+ if (delimiter === "'" && WORD_CHARACTER.test(text.charAt(candidate + 1))) {
43
+ cursor = candidate + 1;
44
+ continue;
45
+ }
46
+ return candidate;
47
+ }
48
+ return -1;
49
+ }
50
+ export function maskQuotedSpans(text) {
51
+ let result = '';
52
+ let index = 0;
53
+ while (index < text.length) {
54
+ const char = text.charAt(index);
55
+ if (!QUOTE_DELIMITERS.includes(char)) {
56
+ result += char;
57
+ index += 1;
58
+ continue;
59
+ }
60
+ if (char === "'" && !isSingleQuoteOpener(text, index)) {
61
+ result += char;
62
+ index += 1;
63
+ continue;
64
+ }
65
+ const closeIndex = findClosingQuote(text, char, index);
66
+ if (closeIndex === -1) {
67
+ result += text.slice(index);
68
+ break;
69
+ }
70
+ const span = text.slice(index, closeIndex + 1);
71
+ result += span.replace(/\S/g, QUOTE_MASK_CHAR);
72
+ index = closeIndex + 1;
73
+ }
74
+ return result;
75
+ }
76
+ function stripVerbOutsideQuotes(text, verb) {
77
+ const masked = maskQuotedSpans(text);
78
+ const ranges = [];
79
+ for (const match of masked.matchAll(new RegExp(`\\b${verb}\\b\\s*`, 'gi'))) {
80
+ ranges.push([match.index, match.index + match[0].length]);
81
+ }
82
+ let result = '';
83
+ let cursor = 0;
84
+ for (const [start, end] of ranges) {
85
+ result += text.slice(cursor, start);
86
+ cursor = end;
87
+ }
88
+ result += text.slice(cursor);
89
+ return result.trim();
90
+ }
29
91
  function rewriteToGwt(text, vagueWord) {
30
- const withoutModal = text.replace(new RegExp(`\\b${vagueWord}\\s*`, 'gi'), '').trim();
92
+ const withoutModal = stripVerbOutsideQuotes(text, vagueWord);
31
93
  return `GIVEN <precondition> WHEN <trigger> THEN ${withoutModal}`;
32
94
  }
33
95
  /**
@@ -41,7 +103,7 @@ export function runEarsGate(criteriaLines) {
41
103
  if (line === 'bdd-scenario') {
42
104
  continue;
43
105
  }
44
- const lower = line.toLowerCase();
106
+ const lower = maskQuotedSpans(line).toLowerCase();
45
107
  const found = EARS_VAGUE_VERBS.filter((verb) => new RegExp(`\\b${verb}\\b`).test(lower));
46
108
  if (found.length === 0) {
47
109
  continue;
@@ -31,4 +31,5 @@ export declare function detectTestCommand(projectPath: string, packageManager: s
31
31
  * Detect lint command from project config files.
32
32
  */
33
33
  export declare function detectLintCommand(projectPath: string, packageManager: string | null): Promise<string | null>;
34
+ export declare function pmRunner(packageManager: string | null): string;
34
35
  //# sourceMappingURL=framework-detector.d.ts.map
@@ -253,7 +253,7 @@ export async function detectLintCommand(projectPath, packageManager) {
253
253
  }
254
254
  return null;
255
255
  }
256
- function pmRunner(packageManager) {
256
+ export function pmRunner(packageManager) {
257
257
  if (packageManager === 'pnpm') {
258
258
  return 'pnpm';
259
259
  }
@@ -116,6 +116,7 @@ export declare const ValidationReportV1Schema: z.ZodObject<{
116
116
  title: z.ZodString;
117
117
  verdict: z.ZodEnum<{
118
118
  fail: "fail";
119
+ indeterminate: "indeterminate";
119
120
  missing: "missing";
120
121
  pass: "pass";
121
122
  }>;
@@ -284,6 +285,7 @@ export declare const ARTIFACT_SCHEMAS: {
284
285
  title: z.ZodString;
285
286
  verdict: z.ZodEnum<{
286
287
  fail: "fail";
288
+ indeterminate: "indeterminate";
287
289
  missing: "missing";
288
290
  pass: "pass";
289
291
  }>;
@@ -88,7 +88,7 @@ export const ValidationReportV1Schema = z.object({
88
88
  command: z.string(),
89
89
  scenarios: z.array(z.object({
90
90
  title: z.string(),
91
- verdict: z.enum(['pass', 'fail', 'missing']),
91
+ verdict: z.enum(['pass', 'fail', 'missing', 'indeterminate']),
92
92
  evidence: z.array(z.string()),
93
93
  unverifiable: z.literal(true).optional(),
94
94
  })),
@@ -65,7 +65,9 @@ export function buildCriterionGroundingRecords(args) {
65
65
  });
66
66
  }
67
67
  export function getContractCriteria(records) {
68
- return records.filter((record) => record.source === 'user_input' || record.source === 'project_evidence');
68
+ return records.filter((record) => record.source === 'user_input' ||
69
+ record.source === 'project_evidence' ||
70
+ record.source === 'review_evidence');
69
71
  }
70
72
  export function getAdvisoryCriteria(records) {
71
73
  return records.filter((record) => record.source === 'documented_assumption' || record.source === 'ungrounded_advisory');
@@ -1,6 +1,7 @@
1
1
  const GROUNDING_SOURCES = [
2
2
  'user_input',
3
3
  'project_evidence',
4
+ 'review_evidence',
4
5
  'documented_assumption',
5
6
  'ungrounded_advisory',
6
7
  ];
@@ -4,8 +4,18 @@ import { isAbsolute, join, relative } from 'node:path';
4
4
  import { runAbortableProcess } from '../abortable-process-runner.js';
5
5
  import { technologyValue } from '../technology-registry.js';
6
6
  const IMPORTABLE_SOURCE_PATTERN = /\.(?:ts|tsx|js|jsx|mjs|cjs)$/u;
7
+ const INTEGRATION_ONLY_ENV = 'PLANU_INTEGRATION_TESTS_ONLY';
8
+ const EXCLUDE_INTEGRATION_ENV = 'PLANU_EXCLUDE_INTEGRATION_TESTS';
7
9
  function skippedResult(skipped) {
8
- return { skipped, selectedFiles: [], passed: true, timedOut: false, failures: [] };
10
+ return {
11
+ skipped,
12
+ selectedFiles: [],
13
+ passed: true,
14
+ timedOut: false,
15
+ failures: [],
16
+ integrationImporters: [],
17
+ warningReason: null,
18
+ };
9
19
  }
10
20
  function normalizeCandidate(projectPath, file) {
11
21
  const absolute = isAbsolute(file) ? file : join(projectPath, file);
@@ -54,6 +64,8 @@ function abortFailure(reportPath, signal, selectedFiles) {
54
64
  passed: false,
55
65
  timedOut: false,
56
66
  failures: [{ file: reportPath, message }],
67
+ integrationImporters: [],
68
+ warningReason: null,
57
69
  };
58
70
  }
59
71
  function exitStatusFailure(reportPath, status, selectedFiles) {
@@ -68,6 +80,8 @@ function exitStatusFailure(reportPath, status, selectedFiles) {
68
80
  message: `vitest related exited with status ${status} without parseable failures`,
69
81
  },
70
82
  ],
83
+ integrationImporters: [],
84
+ warningReason: null,
71
85
  };
72
86
  }
73
87
  function reportFailure(reportPath, selectedFiles, error) {
@@ -80,6 +94,69 @@ function reportFailure(reportPath, selectedFiles, error) {
80
94
  failures: [
81
95
  { file: reportPath, message: `blast radius report missing or unreadable: ${detail}` },
82
96
  ],
97
+ integrationImporters: [],
98
+ warningReason: null,
99
+ };
100
+ }
101
+ async function runIntegrationPass(args) {
102
+ const budgetMs = args.options.integrationTimeoutMs ?? 0;
103
+ if (budgetMs <= 0) {
104
+ return { outcome: 'skipped' };
105
+ }
106
+ const reportDir = mkdtempSync(join(tmpdir(), 'planu-blast-radius-integration-'));
107
+ const reportPath = join(reportDir, 'blast-radius-integration.json');
108
+ try {
109
+ const { [EXCLUDE_INTEGRATION_ENV]: _excluded, ...envWithoutExclusion } = process.env;
110
+ const integrationEnv = {
111
+ ...envWithoutExclusion,
112
+ [INTEGRATION_ONLY_ENV]: '1',
113
+ };
114
+ const result = await args.runProcess(args.vitestBin, [
115
+ 'related',
116
+ '--run',
117
+ '--maxWorkers=6',
118
+ '--reporter=json',
119
+ `--outputFile.json=${reportPath}`,
120
+ ...args.selectedFiles,
121
+ ], {
122
+ cwd: args.projectPath,
123
+ timeoutMs: budgetMs,
124
+ maxBufferBytes: 64 * 1024 * 1024,
125
+ signal: args.options.signal,
126
+ env: integrationEnv,
127
+ });
128
+ if (result.timedOut || result.aborted || result.signal !== null) {
129
+ return { outcome: 'skipped' };
130
+ }
131
+ let report;
132
+ try {
133
+ report = JSON.parse(readFileSync(reportPath, 'utf-8'));
134
+ }
135
+ catch {
136
+ return { outcome: 'skipped' };
137
+ }
138
+ const importers = [
139
+ ...new Set((report.testResults ?? []).map((entry) => relativeReportPath(args.projectPath, entry.testFilePath ?? entry.name ?? ''))),
140
+ ].filter((path) => path.length > 0);
141
+ const failures = parseVitestReport(args.projectPath, reportPath);
142
+ return { outcome: 'ran', importers, failures };
143
+ }
144
+ finally {
145
+ rmSync(reportDir, { recursive: true, force: true });
146
+ }
147
+ }
148
+ async function buildSuccessResult(args) {
149
+ const integration = await runIntegrationPass(args);
150
+ const integrationFailures = integration.outcome === 'ran' ? integration.failures : [];
151
+ const allFailures = [...args.firstPassFailures, ...integrationFailures];
152
+ return {
153
+ skipped: null,
154
+ selectedFiles: args.selectedFiles,
155
+ passed: allFailures.length === 0,
156
+ timedOut: false,
157
+ failures: allFailures,
158
+ integrationImporters: integration.outcome === 'ran' ? integration.importers : [],
159
+ warningReason: integration.outcome === 'skipped' ? 'integration-importers-skipped' : null,
83
160
  };
84
161
  }
85
162
  export async function runBlastRadiusGate(projectPath, candidateFiles, options) {
@@ -107,10 +184,18 @@ export async function runBlastRadiusGate(projectPath, candidateFiles, options) {
107
184
  timeoutMs: options.timeoutMs,
108
185
  maxBufferBytes: 64 * 1024 * 1024,
109
186
  signal: options.signal,
110
- env: { ...process.env, PLANU_EXCLUDE_INTEGRATION_TESTS: '1' },
187
+ env: { ...process.env, [EXCLUDE_INTEGRATION_ENV]: '1' },
111
188
  });
112
189
  if (result.timedOut) {
113
- return { skipped: null, selectedFiles, passed: false, timedOut: true, failures: [] };
190
+ return {
191
+ skipped: null,
192
+ selectedFiles,
193
+ passed: false,
194
+ timedOut: true,
195
+ failures: [],
196
+ integrationImporters: [],
197
+ warningReason: null,
198
+ };
114
199
  }
115
200
  if (result.aborted || result.signal !== null) {
116
201
  return abortFailure(reportPath, result.signal, selectedFiles);
@@ -120,13 +205,14 @@ export async function runBlastRadiusGate(projectPath, candidateFiles, options) {
120
205
  if (failures.length === 0 && result.status !== null && result.status !== 0) {
121
206
  return exitStatusFailure(reportPath, result.status, selectedFiles);
122
207
  }
123
- return {
124
- skipped: null,
208
+ return await buildSuccessResult({
209
+ projectPath,
210
+ vitestBin,
125
211
  selectedFiles,
126
- passed: failures.length === 0,
127
- timedOut: false,
128
- failures,
129
- };
212
+ options,
213
+ runProcess,
214
+ firstPassFailures: failures,
215
+ });
130
216
  }
131
217
  catch (error) {
132
218
  return reportFailure(reportPath, selectedFiles, error);
@@ -6,6 +6,7 @@ export declare class ComplianceCommandTerminalError extends Error {
6
6
  constructor(code: string);
7
7
  }
8
8
  export declare function parseFrontmatterScenarios(raw: string): FrontmatterScenario[];
9
+ export declare function parseJsonOutput(stdout: string): unknown;
9
10
  export declare function runSpecCompliance(spec: Spec, projectPath: string, signal?: AbortSignal, canonicalProjectId?: string): Promise<SpecComplianceResult>;
10
11
  export declare function findScenariosWithoutTests(raw: string): string[];
11
12
  export declare function collectDeclaredSpecFiles(raw: string): string[];