@planu/cli 5.7.13 → 5.7.15
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.
- package/CHANGELOG.md +26 -0
- package/README.md +3 -6
- package/dist/.planu-build.json +1 -1
- package/dist/config/negative-predicate-phrases.json +33 -0
- package/dist/config/runtime-policy.json +1 -1
- package/dist/engine/mcp-config/mcp-config-writer.d.ts +1 -0
- package/dist/engine/mcp-config/mcp-config-writer.js +11 -0
- package/dist/engine/spec-format/bdd-parser.d.ts +2 -0
- package/dist/engine/spec-format/bdd-parser.js +70 -4
- package/dist/engine/validator/analyzer.d.ts +0 -9
- package/dist/engine/validator/analyzer.js +33 -9
- package/dist/engine/validator/blast-radius-gate.js +86 -1
- package/dist/engine/validator/deep-code-checker.js +2 -5
- package/dist/engine/validator/negative-predicate.d.ts +18 -0
- package/dist/engine/validator/negative-predicate.js +240 -0
- package/dist/engine/validator/spec-compliance-runner.js +17 -2
- package/dist/storage/runtime-db.d.ts +1 -1
- package/dist/storage/runtime-db.js +15 -2
- package/dist/tools/create-spec.js +10 -0
- package/dist/tools/init-project/handler.js +3 -1
- package/dist/tools/jobs/handlers.d.ts +2 -1
- package/dist/tools/jobs/handlers.js +17 -3
- package/dist/tools/tool-registry/core-tools.js +28 -2
- package/dist/tools/update-status/evidence-gate.js +13 -1
- package/dist/tools/update-status/transition-guard.js +33 -9
- package/dist/tools/validate.js +14 -2
- package/dist/types/analysis.d.ts +20 -0
- package/dist/types/errors/structured-error.d.ts +1 -1
- package/dist/types/plugin-configs.d.ts +4 -0
- package/dist/types/spec/inputs.d.ts +14 -0
- package/dist/types/validation-evidence.d.ts +3 -1
- package/package.json +2 -1
- package/planu-plugin.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## [5.7.15] - 2026-09-03
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
- fix(docker): build from the Node toolchain only and drop orphaned native metadata (SPEC-1784)
|
|
5
|
+
- fix(validate): give the blast-radius integration pass a 600 s budget (SPEC-1782)
|
|
6
|
+
- fix(release): never republish an acknowledged version and accept the already-published 403 (SPEC-1782)
|
|
7
|
+
- fix(init-project): pin legacy npx @latest MCP entry on init (SPEC-1783)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [5.7.14] - 2026-09-03
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
- feat(validator): credit negative and deletion criteria via fail-closed absence scan (SPEC-1579)
|
|
14
|
+
- feat(gates): carry executable next actions and external blockage state (SPEC-1691)
|
|
15
|
+
- feat(jobs): accept projectPath in get_job and restart_job (SPEC-1392)
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
- fix(types): import ToolResult from primitives to break the structured-error barrel cycle (SPEC-1691)
|
|
19
|
+
- fix(validate): rebuild stale dist once before the blast-radius importer run (SPEC-1781)
|
|
20
|
+
- fix(gates): prefer projectPath by undefined check and drop comments (SPEC-1691)
|
|
21
|
+
- fix(bdd-parser): tolerate list markers and split single-line GWT criteria (SPEC-1720)
|
|
22
|
+
|
|
23
|
+
### Refactoring
|
|
24
|
+
- refactor(gates): move GateUnavailableIdentity to types and compact blocked text (SPEC-1691)
|
|
25
|
+
|
|
26
|
+
|
|
1
27
|
## [5.7.13] - 2026-09-03
|
|
2
28
|
|
|
3
29
|
### Features
|
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@planu/cli)
|
|
6
6
|

|
|
7
|
-

|
|
8
7
|

|
|
9
8
|
|
|
10
9
|
**[Documentation](https://planu.dev)** · **[Español (Latinoamérica)](https://planu.dev/es)** · **[Español (España)](https://planu.dev/es-ES)** · **[Português](https://planu.dev/pt)**
|
|
@@ -13,11 +12,10 @@
|
|
|
13
12
|
|
|
14
13
|
## What is Planu?
|
|
15
14
|
|
|
16
|
-
Planu is a Spec Driven Development stack for AI coding agents: an MCP server and local CLI that move work from a reviewed specification to validation evidence.
|
|
15
|
+
Planu is a Spec Driven Development stack for AI coding agents: an MCP server and local CLI that move work from a reviewed specification to validation evidence.
|
|
17
16
|
|
|
18
17
|
**Spec first, always.** No approved spec means no code. This eliminates vibe-coding debt at scale.
|
|
19
18
|
|
|
20
|
-
- **Native Rust Engine** — accelerates supported project scanning, hashing, and extraction paths.
|
|
21
19
|
- **Local change detection** — observes project changes without requiring a hosted configuration service.
|
|
22
20
|
- **Unified Spec Format** — Requirements and technical details in a single, context-efficient `spec.md`.
|
|
23
21
|
- **Atomic Integrity** — Indestructible writes and **Freeze-on-done** immutability (P0).
|
|
@@ -41,7 +39,7 @@ Add to your MCP client config (Claude Desktop: `~/Library/Application Support/Cl
|
|
|
41
39
|
}
|
|
42
40
|
```
|
|
43
41
|
|
|
44
|
-
**Requirements:** Node.js >= 22.13.
|
|
42
|
+
**Requirements:** Node.js >= 22.13.
|
|
45
43
|
|
|
46
44
|
**Upgrade safety:** stop every running Planu process before upgrading. Current releases use a single transactional SQLite lock authority with monotonic fencing; concurrent mixed-version execution is intentionally unsupported because older file-lock clients cannot participate in the same atomic protocol.
|
|
47
45
|
|
|
@@ -93,8 +91,7 @@ The external root follows the operating system's application-data convention and
|
|
|
93
91
|
|
|
94
92
|
```
|
|
95
93
|
src/
|
|
96
|
-
├── engine/ #
|
|
97
|
-
│ └── planu-core.node # High-performance native module
|
|
94
|
+
├── engine/ # Business logic: estimator, analyzer, validator
|
|
98
95
|
├── tools/ # Canonical SDD MCP tools + internal workflow handlers
|
|
99
96
|
├── storage/ # Atomic persistence layer
|
|
100
97
|
└── types/ # Strict TypeScript contracts
|
package/dist/.planu-build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":1,"commit":"
|
|
1
|
+
{"schemaVersion":1,"commit":"c98d593f0b05bdf5da7ae4ff737b7757c0a76b6c"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "deletion",
|
|
4
|
+
"phrases": [
|
|
5
|
+
"no longer exist",
|
|
6
|
+
"does not exist",
|
|
7
|
+
"do not exist",
|
|
8
|
+
"must not exist",
|
|
9
|
+
"is removed",
|
|
10
|
+
"are removed",
|
|
11
|
+
"has been removed",
|
|
12
|
+
"have been removed",
|
|
13
|
+
"is deleted",
|
|
14
|
+
"are deleted"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "import-absence",
|
|
19
|
+
"phrases": [
|
|
20
|
+
"nothing imports",
|
|
21
|
+
"no longer imports",
|
|
22
|
+
"must not import",
|
|
23
|
+
"does not import",
|
|
24
|
+
"no references to",
|
|
25
|
+
"no remaining references",
|
|
26
|
+
"with no"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "literal-absence",
|
|
31
|
+
"phrases": ["no hardcoded", "no literal", "no magic", "no raw", "remove all"]
|
|
32
|
+
}
|
|
33
|
+
]
|
|
@@ -17,6 +17,7 @@ export declare function isPlanuDirectlyConfigured(configPath: string, expectedVe
|
|
|
17
17
|
* Does not overwrite unrelated keys.
|
|
18
18
|
*/
|
|
19
19
|
export declare function injectDirectPlanuEntry(configPath: string, currentVersion: string, latestVersion: string): Promise<void>;
|
|
20
|
+
export declare function healLegacyLatestEntry(projectPath: string, version: string): Promise<boolean>;
|
|
20
21
|
/**
|
|
21
22
|
* Checks if a version gap exists and, if so, injects the direct Planu MCP entry.
|
|
22
23
|
* Returns a structured result for the tool response.
|
|
@@ -5,6 +5,7 @@ import { readFile, writeFile } from 'node:fs/promises';
|
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { homedir } from 'node:os';
|
|
7
7
|
import { buildPinnedEntry } from '../auto-updater/config-patcher.js';
|
|
8
|
+
import { detectInstallMethod } from '../auto-updater/config-detector.js';
|
|
8
9
|
import { fileExistsByRead } from '../../core/shared/fs.js';
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
10
11
|
// Constants
|
|
@@ -95,6 +96,16 @@ export async function injectDirectPlanuEntry(configPath, currentVersion, latestV
|
|
|
95
96
|
};
|
|
96
97
|
await writeFile(configPath, JSON.stringify(updated, null, 2) + '\n', 'utf-8');
|
|
97
98
|
}
|
|
99
|
+
export async function healLegacyLatestEntry(projectPath, version) {
|
|
100
|
+
const configPath = join(projectPath, '.mcp.json');
|
|
101
|
+
const config = await readJsonFile(configPath);
|
|
102
|
+
const planuEntry = config.mcpServers?.[PLANU_KEY];
|
|
103
|
+
if (planuEntry === undefined || detectInstallMethod(planuEntry) !== 'npx-latest') {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
await injectDirectPlanuEntry(configPath, version, version);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
98
109
|
// ---------------------------------------------------------------------------
|
|
99
110
|
// High-level orchestrator
|
|
100
111
|
// ---------------------------------------------------------------------------
|
|
@@ -20,5 +20,7 @@ export declare function renderBddScenariosYaml(scenarios: BddScenario[]): string
|
|
|
20
20
|
* Plain text criteria get a generic GIVEN (system context) and WHEN (action trigger)
|
|
21
21
|
* so scenarios are always structurally valid BDD.
|
|
22
22
|
*/
|
|
23
|
+
export declare const PLACEHOLDER_GIVEN_STEP_TEXT = "the system is in its default state";
|
|
24
|
+
export declare const PLACEHOLDER_WHEN_STEP_TEXT = "the described behavior is triggered";
|
|
23
25
|
export declare function convertCheckboxToBdd(criteria: LeanCriterion[]): BddScenario[];
|
|
24
26
|
//# sourceMappingURL=bdd-parser.d.ts.map
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
// engine/spec-format/bdd-parser.ts — BDD/Gherkin parser and emitter (SPEC-481)
|
|
2
2
|
import { consumePathRunPreservingCase } from './technical-md-populator.js';
|
|
3
3
|
const TEST_MARKER_RE = /\bTESTS?\s*:/gi;
|
|
4
|
+
const MARKER_BOUNDARY_RE = /\b(?:FILES?|FUNCTIONS?|OWNER|TESTS?)\s*:/i;
|
|
5
|
+
const PATH_SHAPED_TOKEN_RE = /(?:[\w.@-]+\/)+[\w.-]+\.[a-zA-Z0-9]+/g;
|
|
4
6
|
export function extractInlineTestPaths(text) {
|
|
5
7
|
const paths = [];
|
|
6
8
|
const seen = new Set();
|
|
7
9
|
for (const marker of text.matchAll(TEST_MARKER_RE)) {
|
|
8
10
|
const start = marker.index + marker[0].length;
|
|
9
|
-
|
|
11
|
+
const segment = text.slice(start).split(MARKER_BOUNDARY_RE)[0] ?? '';
|
|
12
|
+
const run = consumePathRunPreservingCase(segment);
|
|
13
|
+
const found = run.length > 0 ? run : (segment.match(PATH_SHAPED_TOKEN_RE) ?? []);
|
|
14
|
+
for (const path of found) {
|
|
10
15
|
if (!seen.has(path)) {
|
|
11
16
|
seen.add(path);
|
|
12
17
|
paths.push(path);
|
|
@@ -50,6 +55,58 @@ function opensHeaderlessScenario(rawKeyword, text, rawLine) {
|
|
|
50
55
|
function suffixedTitle(thenText, steps) {
|
|
51
56
|
return `${thenText} (given ${steps.find((step) => step.keyword === 'given')?.text ?? ''})`;
|
|
52
57
|
}
|
|
58
|
+
const LIST_MARKER_RE = /^(?:[-*+>]\s+|\d+[.)]\s+)/;
|
|
59
|
+
const MARKER_TAIL_RE = /\s*\b(?:FILES?|FUNCTIONS?|TESTS?|OWNER)\s*:[\s\S]*$/i;
|
|
60
|
+
const CODE_SPAN_RE = /`[^`]*`/g;
|
|
61
|
+
function stripMarkerTail(text) {
|
|
62
|
+
return text.replace(MARKER_TAIL_RE, '').trim();
|
|
63
|
+
}
|
|
64
|
+
function maskCodeSpans(text) {
|
|
65
|
+
return text.replace(CODE_SPAN_RE, (span) => ' '.repeat(span.length));
|
|
66
|
+
}
|
|
67
|
+
function splitSingleLineGwt(line) {
|
|
68
|
+
const masked = maskCodeSpans(line);
|
|
69
|
+
const given = /^GIVEN\b/.exec(masked);
|
|
70
|
+
if (given === null) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const when = /\bWHEN\b/.exec(masked.slice(given.index));
|
|
74
|
+
if (when === null) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const whenIndex = given.index + when.index;
|
|
78
|
+
const then = /\bTHEN\b/.exec(masked.slice(whenIndex));
|
|
79
|
+
if (then === null) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const thenIndex = whenIndex + then.index;
|
|
83
|
+
const givenText = line.slice(given.index + 'GIVEN'.length, whenIndex).trim();
|
|
84
|
+
const whenText = line.slice(whenIndex + 'WHEN'.length, thenIndex).trim();
|
|
85
|
+
const thenText = line.slice(thenIndex + 'THEN'.length).trim();
|
|
86
|
+
if (givenText === '' || whenText === '' || thenText === '') {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return [
|
|
90
|
+
{ keyword: 'given', text: givenText },
|
|
91
|
+
{ keyword: 'when', text: whenText },
|
|
92
|
+
{ keyword: 'then', text: stripMarkerTail(thenText) },
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
function buildSingleLineScenario(line, closedTitles) {
|
|
96
|
+
const singleLineSteps = splitSingleLineGwt(line);
|
|
97
|
+
if (singleLineSteps === null) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const thenText = singleLineSteps[singleLineSteps.length - 1]?.text ?? '';
|
|
101
|
+
const title = closedTitles.has(thenText) ? suffixedTitle(thenText, singleLineSteps) : thenText;
|
|
102
|
+
const tests = extractInlineTestPaths(line).map((path) => ({ path }));
|
|
103
|
+
return {
|
|
104
|
+
title,
|
|
105
|
+
steps: singleLineSteps,
|
|
106
|
+
done: false,
|
|
107
|
+
...(tests.length > 0 ? { tests } : {}),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
53
110
|
export function parseBddScenarios(markdown) {
|
|
54
111
|
const scenarios = [];
|
|
55
112
|
const lines = markdown.split('\n');
|
|
@@ -65,7 +122,7 @@ export function parseBddScenarios(markdown) {
|
|
|
65
122
|
currentIsHeaderless = false;
|
|
66
123
|
};
|
|
67
124
|
for (const raw of lines) {
|
|
68
|
-
const line = raw.trim();
|
|
125
|
+
const line = raw.trim().replace(LIST_MARKER_RE, '');
|
|
69
126
|
// Detect scenario header
|
|
70
127
|
const scenarioMatch = /^(?:#{1,6}\s*)?scenario(?:\s+\d+)?:\s*(.+)$/i.exec(line);
|
|
71
128
|
if (scenarioMatch) {
|
|
@@ -73,6 +130,13 @@ export function parseBddScenarios(markdown) {
|
|
|
73
130
|
current = { title: (scenarioMatch[1] ?? '').trim(), steps: [], done: false };
|
|
74
131
|
continue;
|
|
75
132
|
}
|
|
133
|
+
const singleLineScenario = buildSingleLineScenario(line, closedTitles);
|
|
134
|
+
if (singleLineScenario !== null) {
|
|
135
|
+
closeCurrent();
|
|
136
|
+
current = singleLineScenario;
|
|
137
|
+
closeCurrent();
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
76
140
|
// Detect step keywords
|
|
77
141
|
const stepMatch = /^(given|when|then|and|but)\s+(.+)$/i.exec(line);
|
|
78
142
|
if (!stepMatch) {
|
|
@@ -141,12 +205,14 @@ export function renderBddScenariosYaml(scenarios) {
|
|
|
141
205
|
* Plain text criteria get a generic GIVEN (system context) and WHEN (action trigger)
|
|
142
206
|
* so scenarios are always structurally valid BDD.
|
|
143
207
|
*/
|
|
208
|
+
export const PLACEHOLDER_GIVEN_STEP_TEXT = 'the system is in its default state';
|
|
209
|
+
export const PLACEHOLDER_WHEN_STEP_TEXT = 'the described behavior is triggered';
|
|
144
210
|
export function convertCheckboxToBdd(criteria) {
|
|
145
211
|
return criteria.map((criterion) => ({
|
|
146
212
|
title: criterion.text,
|
|
147
213
|
steps: [
|
|
148
|
-
{ keyword: 'given', text:
|
|
149
|
-
{ keyword: 'when', text:
|
|
214
|
+
{ keyword: 'given', text: PLACEHOLDER_GIVEN_STEP_TEXT },
|
|
215
|
+
{ keyword: 'when', text: PLACEHOLDER_WHEN_STEP_TEXT },
|
|
150
216
|
{ keyword: 'then', text: criterion.text },
|
|
151
217
|
],
|
|
152
218
|
done: criterion.done,
|
|
@@ -3,15 +3,6 @@ import type { Spec, AuditFinding, CodeState, VerifyBlock, CriterionEvidenceResul
|
|
|
3
3
|
* Scan the project directory to build a CodeState for the given spec.
|
|
4
4
|
*/
|
|
5
5
|
export declare function scanCodeForSpec(spec: Spec, projectPath: string): Promise<CodeState>;
|
|
6
|
-
/**
|
|
7
|
-
* Check whether a single criterion is satisfied in the given code state.
|
|
8
|
-
* When `verifyBlock` is provided it is forwarded to deepCheckCriterion,
|
|
9
|
-
* bypassing keyword-based classification (explicit beats inferred).
|
|
10
|
-
*
|
|
11
|
-
* Pass `sharedFileContents` (pre-built via buildBroadCache or
|
|
12
|
-
* buildFileContentsCache from criterion-matcher) to avoid a redundant
|
|
13
|
-
* glob+readFile pass when checking multiple criteria in the same call.
|
|
14
|
-
*/
|
|
15
6
|
export declare function checkCriterionEvidence(criterion: string, projectPath: string, codeState: CodeState, verifyBlock?: VerifyBlock, sharedFileContents?: Map<string, string>, declaredTestPaths?: string[], probeCache?: Map<string, {
|
|
16
7
|
passed: boolean;
|
|
17
8
|
evidence: string;
|
|
@@ -49,6 +49,7 @@ async function buildBroadCache(projectPath) {
|
|
|
49
49
|
return cache;
|
|
50
50
|
}
|
|
51
51
|
import { deepCheckCriterion } from './deep-code-checker.js';
|
|
52
|
+
import { classifyNegativePredicate, checkTokensAbsent } from './negative-predicate.js';
|
|
52
53
|
import { ConfigLoader } from '../config-loader.js';
|
|
53
54
|
import { filterValidatedTestPaths, groundNumericLiteral, createProbeCache, groundAgainstDeclaredTests, findBacktickIdentifierEvidence, } from './test-evidence-grounding.js';
|
|
54
55
|
// ---------------------------------------------------------------------------
|
|
@@ -209,6 +210,30 @@ async function checkComponentMatch(criterion, projectPath, codeState, sharedFile
|
|
|
209
210
|
* buildFileContentsCache from criterion-matcher) to avoid a redundant
|
|
210
211
|
* glob+readFile pass when checking multiple criteria in the same call.
|
|
211
212
|
*/
|
|
213
|
+
async function resolveNegativePredicateEvidence(criterion, projectPath) {
|
|
214
|
+
const negative = classifyNegativePredicate(criterion);
|
|
215
|
+
if (!negative.isNegative) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
const absence = await checkTokensAbsent(negative.tokens, projectPath);
|
|
219
|
+
if (absence.unverifiable) {
|
|
220
|
+
return { status: 'indeterminate', evidence: absence.evidence[0] };
|
|
221
|
+
}
|
|
222
|
+
return { status: absence.met ? 'proven' : 'missing', evidence: absence.evidence[0] };
|
|
223
|
+
}
|
|
224
|
+
async function resolveFileExistenceEvidence(criterion, projectPath) {
|
|
225
|
+
const fileMatch = /(?:create|add|implement)\s+(?:file\s+)?["']?([^\s"']+\.\w+)["']?/i.exec(criterion);
|
|
226
|
+
if (!fileMatch?.[1]) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
await stat(join(projectPath, fileMatch[1]));
|
|
231
|
+
return { status: 'proven' };
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return { status: 'missing' };
|
|
235
|
+
}
|
|
236
|
+
}
|
|
212
237
|
export async function checkCriterionEvidence(criterion, projectPath, codeState, verifyBlock, sharedFileContents, declaredTestPaths, probeCache) {
|
|
213
238
|
// SPEC-1367 review finding 1: validate declared test paths ONCE, up front —
|
|
214
239
|
// they reach both a readFile call and a spawnSync argv further down. Every
|
|
@@ -218,17 +243,16 @@ export async function checkCriterionEvidence(criterion, projectPath, codeState,
|
|
|
218
243
|
const safeTestPaths = declaredTestPaths && declaredTestPaths.length > 0
|
|
219
244
|
? await filterValidatedTestPaths(projectPath, declaredTestPaths)
|
|
220
245
|
: [];
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
await stat(join(projectPath, fileMatch[1]));
|
|
226
|
-
return { status: 'proven' };
|
|
227
|
-
}
|
|
228
|
-
catch {
|
|
229
|
-
return { status: 'missing' };
|
|
246
|
+
if (!verifyBlock) {
|
|
247
|
+
const negativeResult = await resolveNegativePredicateEvidence(criterion, projectPath);
|
|
248
|
+
if (negativeResult) {
|
|
249
|
+
return negativeResult;
|
|
230
250
|
}
|
|
231
251
|
}
|
|
252
|
+
const fileExistenceResult = await resolveFileExistenceEvidence(criterion, projectPath);
|
|
253
|
+
if (fileExistenceResult) {
|
|
254
|
+
return fileExistenceResult;
|
|
255
|
+
}
|
|
232
256
|
// Check for component/function existence in code (legacy + SPEC-1367 backtick forms)
|
|
233
257
|
const componentResult = await checkComponentMatch(criterion, projectPath, codeState, sharedFileContents, safeTestPaths);
|
|
234
258
|
if (componentResult) {
|
|
@@ -2,10 +2,15 @@ import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
|
2
2
|
import { tmpdir } from 'node:os';
|
|
3
3
|
import { isAbsolute, join, relative } from 'node:path';
|
|
4
4
|
import { runAbortableProcess } from '../abortable-process-runner.js';
|
|
5
|
+
import { assertLocalBuildFreshness } from '../build-freshness.js';
|
|
6
|
+
import { pmRunner } from '../framework-detector.js';
|
|
7
|
+
import { resolveProjectCommandPlan } from '../project-command-runtime.js';
|
|
5
8
|
import { technologyValue } from '../technology-registry.js';
|
|
6
9
|
const IMPORTABLE_SOURCE_PATTERN = /\.(?:ts|tsx|js|jsx|mjs|cjs)$/u;
|
|
7
10
|
const INTEGRATION_ONLY_ENV = 'PLANU_INTEGRATION_TESTS_ONLY';
|
|
8
11
|
const EXCLUDE_INTEGRATION_ENV = 'PLANU_EXCLUDE_INTEGRATION_TESTS';
|
|
12
|
+
const DIST_ROOT = 'dist';
|
|
13
|
+
const BUILD_SCRIPT_CANDIDATES = ['build:ts', 'build'];
|
|
9
14
|
function skippedResult(skipped) {
|
|
10
15
|
return {
|
|
11
16
|
skipped,
|
|
@@ -17,6 +22,82 @@ function skippedResult(skipped) {
|
|
|
17
22
|
warningReason: null,
|
|
18
23
|
};
|
|
19
24
|
}
|
|
25
|
+
function resolveBuildPlan(projectPath) {
|
|
26
|
+
let pkg;
|
|
27
|
+
try {
|
|
28
|
+
const raw = readFileSync(join(projectPath, 'package.json'), 'utf-8');
|
|
29
|
+
pkg = JSON.parse(raw);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const scripts = pkg.scripts ?? {};
|
|
35
|
+
const script = BUILD_SCRIPT_CANDIDATES.find((candidate) => typeof scripts[candidate] === 'string');
|
|
36
|
+
if (script === undefined) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const packageManagerName = typeof pkg.packageManager === 'string' ? (pkg.packageManager.split('@')[0] ?? null) : null;
|
|
40
|
+
const runner = pmRunner(packageManagerName);
|
|
41
|
+
const plan = resolveProjectCommandPlan(projectPath, `${runner} run ${script}`);
|
|
42
|
+
return { executable: plan.executable, args: plan.args, script };
|
|
43
|
+
}
|
|
44
|
+
function staleDistFailure(selectedFiles, reason, detail) {
|
|
45
|
+
return {
|
|
46
|
+
skipped: null,
|
|
47
|
+
selectedFiles,
|
|
48
|
+
passed: false,
|
|
49
|
+
timedOut: false,
|
|
50
|
+
failures: [
|
|
51
|
+
{ file: 'dist', message: `stale-dist: ${reason}; ${detail}; run pnpm build:ts and retry` },
|
|
52
|
+
],
|
|
53
|
+
integrationImporters: [],
|
|
54
|
+
warningReason: 'stale-dist',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async function ensureFreshDist(projectPath, selectedFiles, runProcess, options) {
|
|
58
|
+
const check = options.checkBuildFreshness ?? assertLocalBuildFreshness;
|
|
59
|
+
const distRoot = join(projectPath, DIST_ROOT);
|
|
60
|
+
const first = check(distRoot);
|
|
61
|
+
if (first.status !== 'stale') {
|
|
62
|
+
return { failure: null, remainingTimeoutMs: options.timeoutMs };
|
|
63
|
+
}
|
|
64
|
+
const plan = resolveBuildPlan(projectPath);
|
|
65
|
+
if (plan === null) {
|
|
66
|
+
return {
|
|
67
|
+
failure: staleDistFailure(selectedFiles, first.reason ?? 'stale build output', 'no build script found in package.json'),
|
|
68
|
+
remainingTimeoutMs: options.timeoutMs,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const startedAt = Date.now();
|
|
72
|
+
const build = await runProcess(plan.executable, plan.args, {
|
|
73
|
+
cwd: projectPath,
|
|
74
|
+
timeoutMs: options.timeoutMs,
|
|
75
|
+
maxBufferBytes: 16 * 1024 * 1024,
|
|
76
|
+
signal: options.signal,
|
|
77
|
+
env: process.env,
|
|
78
|
+
});
|
|
79
|
+
if (build.timedOut) {
|
|
80
|
+
return {
|
|
81
|
+
failure: staleDistFailure(selectedFiles, first.reason ?? 'stale build output', `${plan.script} timed out after ${options.timeoutMs} ms`),
|
|
82
|
+
remainingTimeoutMs: 0,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const second = check(distRoot);
|
|
86
|
+
const remainingTimeoutMs = Math.max(0, options.timeoutMs - (Date.now() - startedAt));
|
|
87
|
+
if (second.status === 'stale') {
|
|
88
|
+
return {
|
|
89
|
+
failure: staleDistFailure(selectedFiles, second.reason ?? 'stale build output', `${plan.script} did not refresh the build stamp`),
|
|
90
|
+
remainingTimeoutMs,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (remainingTimeoutMs === 0) {
|
|
94
|
+
return {
|
|
95
|
+
failure: staleDistFailure(selectedFiles, first.reason ?? 'stale build output', `${plan.script} consumed the ${options.timeoutMs} ms blast-radius budget`),
|
|
96
|
+
remainingTimeoutMs: 0,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return { failure: null, remainingTimeoutMs };
|
|
100
|
+
}
|
|
20
101
|
function normalizeCandidate(projectPath, file) {
|
|
21
102
|
const absolute = isAbsolute(file) ? file : join(projectPath, file);
|
|
22
103
|
const relativePath = relative(projectPath, absolute);
|
|
@@ -169,6 +250,10 @@ export async function runBlastRadiusGate(projectPath, candidateFiles, options) {
|
|
|
169
250
|
return skippedResult('vitest-not-installed');
|
|
170
251
|
}
|
|
171
252
|
const runProcess = options.runProcess ?? runAbortableProcess;
|
|
253
|
+
const preflight = await ensureFreshDist(projectPath, selectedFiles, runProcess, options);
|
|
254
|
+
if (preflight.failure !== null) {
|
|
255
|
+
return preflight.failure;
|
|
256
|
+
}
|
|
172
257
|
const reportDir = mkdtempSync(join(tmpdir(), 'planu-blast-radius-'));
|
|
173
258
|
const reportPath = join(reportDir, 'blast-radius.json');
|
|
174
259
|
try {
|
|
@@ -181,7 +266,7 @@ export async function runBlastRadiusGate(projectPath, candidateFiles, options) {
|
|
|
181
266
|
...selectedFiles,
|
|
182
267
|
], {
|
|
183
268
|
cwd: projectPath,
|
|
184
|
-
timeoutMs:
|
|
269
|
+
timeoutMs: preflight.remainingTimeoutMs,
|
|
185
270
|
maxBufferBytes: 64 * 1024 * 1024,
|
|
186
271
|
signal: options.signal,
|
|
187
272
|
env: { ...process.env, [EXCLUDE_INTEGRATION_ENV]: '1' },
|
|
@@ -4,6 +4,7 @@ import { readFile, stat } from 'node:fs/promises';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { glob } from 'glob';
|
|
6
6
|
import { escapeRegex } from '../../core/shared/strings.js';
|
|
7
|
+
import { matchesLegacyAbsentPhrase } from './negative-predicate.js';
|
|
7
8
|
const DEFAULT_IGNORE = ['node_modules/**', 'dist/**', 'build/**', '.git/**', 'coverage/**'];
|
|
8
9
|
// ─── Numeric literal normalization (SPEC-1367) ───────────────────────────────
|
|
9
10
|
// Grounds criteria whose THEN names an explicit numeric timeout (e.g. "45_000")
|
|
@@ -39,11 +40,7 @@ export function extractNumericLiterals(text) {
|
|
|
39
40
|
export function classifyCriterion(text) {
|
|
40
41
|
const lower = text.toLowerCase();
|
|
41
42
|
// grep_absent: look for patterns that MUST NOT exist
|
|
42
|
-
if (lower
|
|
43
|
-
lower.includes('no literal') ||
|
|
44
|
-
lower.includes('no magic') ||
|
|
45
|
-
lower.includes('no raw') ||
|
|
46
|
-
lower.includes('remove all')) {
|
|
43
|
+
if (matchesLegacyAbsentPhrase(lower)) {
|
|
47
44
|
return { type: 'grep_absent', config: buildAbsentConfig(text) };
|
|
48
45
|
}
|
|
49
46
|
// SPEC-1367 review: a global numeric_timeout bucket used to live here,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TokenAbsenceResult } from '../../types/index.js';
|
|
2
|
+
export declare function loadNegativePredicatePhrases(): readonly string[];
|
|
3
|
+
export declare function matchesNegativePhrase(text: string): boolean;
|
|
4
|
+
export declare function matchesLegacyAbsentPhrase(text: string): boolean;
|
|
5
|
+
export declare function extractNegativeTokens(text: string): string[];
|
|
6
|
+
export declare function isPathShaped(token: string): boolean;
|
|
7
|
+
export declare function classifyNegativePredicate(text: string): {
|
|
8
|
+
isNegative: boolean;
|
|
9
|
+
tokens: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare const NEGATIVE_TOKEN_SCOPE: readonly string[];
|
|
12
|
+
export declare const NEGATIVE_SCAN_IGNORE: readonly string[];
|
|
13
|
+
export declare const NEGATIVE_SCAN_FILE_LIMIT = 5000;
|
|
14
|
+
export declare function checkTokensAbsent(tokens: readonly string[], projectPath: string, options?: {
|
|
15
|
+
fileLimit?: number;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}): Promise<TokenAbsenceResult>;
|
|
18
|
+
//# sourceMappingURL=negative-predicate.d.ts.map
|