pi-spine 2.6.0 → 2.7.0
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/bin/spine-plan.mjs +2 -1
- package/bin/spine-tasks.mjs +2 -1
- package/package.json +1 -1
- package/src/batch/evidence-command.mjs +120 -16
- package/src/config/missing-config-hint.mjs +19 -0
- package/src/config/preflight/discovery.mjs +6 -4
- package/src/config/spine-config-load.mjs +4 -2
- package/src/config/spine-init-constants.mjs +7 -3
- package/templates/spine-config.json +2 -2
package/bin/spine-plan.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import path from 'node:path';
|
|
|
11
11
|
import { isCliEntrypoint } from './spine-cli/shared.mjs';
|
|
12
12
|
import { loadSpineConfig } from './spine-config.mjs';
|
|
13
13
|
import { resolveTasksRootPath } from '../src/config/env-overrides.mjs';
|
|
14
|
+
import { missingConfigHint } from '../src/config/missing-config-hint.mjs';
|
|
14
15
|
import { buildPlan } from '../src/planner/index.mjs';
|
|
15
16
|
import { formatPlanHuman } from '../src/planner/format-plan.mjs';
|
|
16
17
|
|
|
@@ -79,7 +80,7 @@ export async function runSpinePlan({
|
|
|
79
80
|
const tasksRoot = resolveTasksRootPath(projectRoot, config);
|
|
80
81
|
if (!tasksRoot) {
|
|
81
82
|
const err = new Error('Cannot build plan: tasksRoot not configured');
|
|
82
|
-
err.suggestedCommand =
|
|
83
|
+
err.suggestedCommand = missingConfigHint(projectRoot).suggestedCommand;
|
|
83
84
|
throw err;
|
|
84
85
|
}
|
|
85
86
|
|
package/bin/spine-tasks.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import path from 'node:path';
|
|
|
9
9
|
import { c, isCliEntrypoint, writeCommandResult } from './spine-cli/shared.mjs';
|
|
10
10
|
import { loadSpineConfig } from './spine-config.mjs';
|
|
11
11
|
import { resolveTasksRootPath } from '../src/config/env-overrides.mjs';
|
|
12
|
+
import { missingConfigHint } from '../src/config/missing-config-hint.mjs';
|
|
12
13
|
import { analyzeTasksScope } from '../src/tasks/analyze/index.mjs';
|
|
13
14
|
import {
|
|
14
15
|
collectPromptValidationFailure,
|
|
@@ -188,7 +189,7 @@ export async function runSpineTasksValidate({
|
|
|
188
189
|
const tasksRoot = resolveTasksRootPath(projectRoot, config);
|
|
189
190
|
if (!tasksRoot) {
|
|
190
191
|
throwTasksValidateError('Cannot validate tasks: tasksRoot not configured', {
|
|
191
|
-
suggestedCommand:
|
|
192
|
+
suggestedCommand: missingConfigHint(projectRoot).suggestedCommand,
|
|
192
193
|
});
|
|
193
194
|
}
|
|
194
195
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Safe argv execution for config-derived integrate-gate evidence commands.
|
|
3
3
|
* Allowlisted executables only; rejects shell metacharacters (no shell: true).
|
|
4
|
+
* Phase B: allowlisted package-manager segments may be joined with `&&` only.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
import path from "node:path";
|
|
@@ -28,6 +29,10 @@ const PROJECT_LOCAL_VENV_PREFIXES = [".venv/", "venv/"];
|
|
|
28
29
|
/** Relative prefix for validated gate-evidence scripts (posix-normalized). */
|
|
29
30
|
const EVIDENCE_SCRIPTS_PREFIX = "scripts/";
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Forbidden shell metacharacters. Checked after stripping allowlisted `&&`
|
|
34
|
+
* chain separators so a lone `&` still fails closed.
|
|
35
|
+
*/
|
|
31
36
|
const SHELL_METACHAR_PATTERN = /[;|&`<>]|>>|\$\(|\$\{/;
|
|
32
37
|
|
|
33
38
|
export class EvidenceCommandError extends Error {
|
|
@@ -52,22 +57,113 @@ export function assertSafeEvidenceCommand(command) {
|
|
|
52
57
|
if (/[\r\n]/.test(trimmed)) {
|
|
53
58
|
throw new EvidenceCommandError("evidence command contains newlines");
|
|
54
59
|
}
|
|
55
|
-
|
|
60
|
+
|
|
61
|
+
// Allow `&&` as the only chain operator; strip it before metachar / `$` scans.
|
|
62
|
+
const withoutChains = trimmed.replaceAll("&&", " ");
|
|
63
|
+
if (SHELL_METACHAR_PATTERN.test(withoutChains)) {
|
|
56
64
|
throw new EvidenceCommandError("evidence command contains shell metacharacters");
|
|
57
65
|
}
|
|
58
|
-
if (/\$/.test(
|
|
66
|
+
if (/\$/.test(withoutChains)) {
|
|
59
67
|
throw new EvidenceCommandError("evidence command contains shell variable expansion");
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Split an evidence command on `&&` outside quotes (Phase B chain grammar).
|
|
73
|
+
* @param {string} line
|
|
74
|
+
* @returns {string[]}
|
|
75
|
+
*/
|
|
76
|
+
function splitEvidenceChainSegments(line) {
|
|
77
|
+
/** @type {string[]} */
|
|
78
|
+
const segments = [];
|
|
79
|
+
let current = "";
|
|
80
|
+
/** @type {"'" | '"' | null} */
|
|
81
|
+
let quote = null;
|
|
82
|
+
|
|
83
|
+
for (let i = 0; i < line.length; i++) {
|
|
84
|
+
const ch = line[i];
|
|
85
|
+
if (quote) {
|
|
86
|
+
// Preserve escapes so tokenizeCommandLine can re-parse the segment.
|
|
87
|
+
if (ch === "\\" && quote === '"' && i + 1 < line.length) {
|
|
88
|
+
current += ch;
|
|
89
|
+
i += 1;
|
|
90
|
+
current += line[i];
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
current += ch;
|
|
94
|
+
if (ch === quote) {
|
|
95
|
+
quote = null;
|
|
96
|
+
}
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (ch === "'" || ch === '"') {
|
|
101
|
+
quote = ch;
|
|
102
|
+
current += ch;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (ch === "&" && line[i + 1] === "&") {
|
|
107
|
+
segments.push(current.trim());
|
|
108
|
+
current = "";
|
|
109
|
+
i += 1;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
current += ch;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (quote) {
|
|
117
|
+
throw new EvidenceCommandError("unclosed quote in evidence command");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
segments.push(current.trim());
|
|
121
|
+
return segments;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Parse a config testing command into one or more argv arrays without a shell.
|
|
126
|
+
* Multi-segment results are allowlisted `&&` chains (Phase B).
|
|
127
|
+
* @param {string} command
|
|
128
|
+
* @returns {string[][]}
|
|
129
|
+
*/
|
|
130
|
+
export function parseEvidenceCommandChain(command) {
|
|
131
|
+
assertSafeEvidenceCommand(command);
|
|
132
|
+
const segments = splitEvidenceChainSegments(command.trim());
|
|
133
|
+
if (segments.length === 0) {
|
|
134
|
+
throw new EvidenceCommandError("empty evidence command");
|
|
135
|
+
}
|
|
136
|
+
if (segments.some((segment) => !segment)) {
|
|
137
|
+
throw new EvidenceCommandError("empty evidence command chain segment");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const chainMode = segments.length > 1;
|
|
141
|
+
return segments.map((segment) => parseEvidenceSegmentArgv(segment, chainMode));
|
|
142
|
+
}
|
|
143
|
+
|
|
63
144
|
/**
|
|
64
145
|
* Parse a config testing command into argv without invoking a shell.
|
|
146
|
+
* Single-segment only; use {@link parseEvidenceCommandChain} for `&&` chains.
|
|
65
147
|
* @param {string} command
|
|
66
148
|
* @returns {string[]}
|
|
67
149
|
*/
|
|
68
150
|
export function parseEvidenceCommandArgv(command) {
|
|
69
|
-
|
|
70
|
-
|
|
151
|
+
const chain = parseEvidenceCommandChain(command);
|
|
152
|
+
if (chain.length !== 1) {
|
|
153
|
+
throw new EvidenceCommandError(
|
|
154
|
+
"evidence command && chains must use parseEvidenceCommandChain or runEvidenceCommand",
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
return chain[0];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @param {string} segment
|
|
162
|
+
* @param {boolean} chainMode
|
|
163
|
+
* @returns {string[]}
|
|
164
|
+
*/
|
|
165
|
+
function parseEvidenceSegmentArgv(segment, chainMode) {
|
|
166
|
+
const argv = tokenizeCommandLine(segment);
|
|
71
167
|
if (argv.length === 0) {
|
|
72
168
|
throw new EvidenceCommandError("empty evidence command");
|
|
73
169
|
}
|
|
@@ -76,10 +172,13 @@ export function parseEvidenceCommandArgv(command) {
|
|
|
76
172
|
if (ALLOWED_EVIDENCE_EXECUTABLES.has(executable)) {
|
|
77
173
|
return argv;
|
|
78
174
|
}
|
|
79
|
-
|
|
175
|
+
|
|
176
|
+
// Phase A single-segment paths stay available; multi-segment chains are
|
|
177
|
+
// package-manager / node allowlist only (FR-REL270-05).
|
|
178
|
+
if (!chainMode && isAllowedProjectLocalInterpreter(argv[0])) {
|
|
80
179
|
return argv;
|
|
81
180
|
}
|
|
82
|
-
if (isAllowedEvidenceScriptsPath(argv[0])) {
|
|
181
|
+
if (!chainMode && isAllowedEvidenceScriptsPath(argv[0])) {
|
|
83
182
|
return argv;
|
|
84
183
|
}
|
|
85
184
|
|
|
@@ -247,16 +346,21 @@ export function runEvidenceCommand(projectRoot, command, maxBytes = 256 * 1024)
|
|
|
247
346
|
if (!command) return { ok: false, skipped: true, output: "" };
|
|
248
347
|
|
|
249
348
|
try {
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
349
|
+
const chain = parseEvidenceCommandChain(command);
|
|
350
|
+
/** @type {string[]} */
|
|
351
|
+
const outputs = [];
|
|
352
|
+
for (const argv of chain) {
|
|
353
|
+
const execArgv = resolveEvidenceScriptsArgv(projectRoot, argv);
|
|
354
|
+
const output = execFileSync(execArgv[0], execArgv.slice(1), {
|
|
355
|
+
cwd: projectRoot,
|
|
356
|
+
encoding: "utf-8",
|
|
357
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
358
|
+
timeout: 10 * 60 * 1000,
|
|
359
|
+
maxBuffer: maxBytes,
|
|
360
|
+
});
|
|
361
|
+
outputs.push(String(output ?? ""));
|
|
362
|
+
}
|
|
363
|
+
return { ok: true, skipped: false, output: outputs.join("") };
|
|
260
364
|
} catch (err) {
|
|
261
365
|
if (err instanceof EvidenceCommandError) {
|
|
262
366
|
return {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Honest missing-config / wrong-cwd hint (FR-REL270-01 / FR-REL270-02 / #202).
|
|
6
|
+
* Single source of truth for message + suggestedCommand when `.spine/spine-config.json`
|
|
7
|
+
* is absent under the resolved project root.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} projectRoot
|
|
10
|
+
* @returns {{ resolvedRoot: string, message: string, suggestedCommand: string }}
|
|
11
|
+
*/
|
|
12
|
+
export function missingConfigHint(projectRoot) {
|
|
13
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
14
|
+
return {
|
|
15
|
+
resolvedRoot,
|
|
16
|
+
message: `.spine/spine-config.json not found under ${resolvedRoot} (cwd/$PWD). Change to your project root, or run spine init here if this directory should be initialized.`,
|
|
17
|
+
suggestedCommand: `cd ${resolvedRoot} # if wrong directory — or run: spine init`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -3,6 +3,7 @@ import fs from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
import { loadSpineConfig } from "../spine-config-load.mjs";
|
|
6
|
+
import { missingConfigHint } from "../missing-config-hint.mjs";
|
|
6
7
|
import { resolveTasksRootPath } from "../env-overrides.mjs";
|
|
7
8
|
import { validateWorktreeSetupHookConfig } from "../worktree-setup-hook.mjs";
|
|
8
9
|
import { discoverTasks } from "../../tasks/packet/discover.mjs";
|
|
@@ -61,7 +62,7 @@ export function checkTasksRoot(ctx) {
|
|
|
61
62
|
|
|
62
63
|
if (!tasksRootPath) {
|
|
63
64
|
return makeCheck("tasks-root", false, "tasks root not configured", {
|
|
64
|
-
suggestedCommand:
|
|
65
|
+
suggestedCommand: missingConfigHint(ctx.projectRoot).suggestedCommand,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -108,7 +109,7 @@ export function checkDependenciesJson(ctx) {
|
|
|
108
109
|
|
|
109
110
|
if (!tasksRootPath) {
|
|
110
111
|
return makeCheck("dependencies-json", false, "tasks root not configured", {
|
|
111
|
-
suggestedCommand:
|
|
112
|
+
suggestedCommand: missingConfigHint(ctx.projectRoot).suggestedCommand,
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
115
|
|
|
@@ -255,15 +256,16 @@ export function checkTasksValidate(ctx) {
|
|
|
255
256
|
const config = configResult?.config;
|
|
256
257
|
|
|
257
258
|
if (!config || configResult?.error) {
|
|
259
|
+
const hint = missingConfigHint(projectRoot);
|
|
258
260
|
return makeCheck("tasks-validate", false, "cannot validate tasks without spine config", {
|
|
259
|
-
suggestedCommand:
|
|
261
|
+
suggestedCommand: hint.suggestedCommand,
|
|
260
262
|
});
|
|
261
263
|
}
|
|
262
264
|
|
|
263
265
|
const tasksRootPath = resolveTasksRoot(projectRoot, configResult);
|
|
264
266
|
if (!tasksRootPath) {
|
|
265
267
|
return makeCheck("tasks-validate", false, "tasks root not configured", {
|
|
266
|
-
suggestedCommand:
|
|
268
|
+
suggestedCommand: missingConfigHint(projectRoot).suggestedCommand,
|
|
267
269
|
});
|
|
268
270
|
}
|
|
269
271
|
|
|
@@ -11,6 +11,7 @@ import { validateWorkerContextConfig } from "./worker-context.mjs";
|
|
|
11
11
|
import { validateWorkerLaunchScriptConfig } from "./worker-launch-script.mjs";
|
|
12
12
|
import { validateWorktreeSetupHookConfig } from "./worktree-setup-hook.mjs";
|
|
13
13
|
import { validateOrchestratorConfig } from "./spine-config-schema.mjs";
|
|
14
|
+
import { missingConfigHint } from "./missing-config-hint.mjs";
|
|
14
15
|
|
|
15
16
|
export { resolveGatePostureConfig } from "./gate-posture-config.mjs";
|
|
16
17
|
|
|
@@ -58,13 +59,14 @@ export function loadSpineConfigFile(projectRoot) {
|
|
|
58
59
|
const configPath = path.join(projectRoot, ".spine", "spine-config.json");
|
|
59
60
|
|
|
60
61
|
if (!fs.existsSync(configPath)) {
|
|
62
|
+
const hint = missingConfigHint(projectRoot);
|
|
61
63
|
return {
|
|
62
64
|
configPath,
|
|
63
65
|
config: null,
|
|
64
66
|
error: {
|
|
65
67
|
code: "CONFIG_MISSING",
|
|
66
|
-
message:
|
|
67
|
-
suggestedCommand:
|
|
68
|
+
message: hint.message,
|
|
69
|
+
suggestedCommand: hint.suggestedCommand,
|
|
68
70
|
},
|
|
69
71
|
};
|
|
70
72
|
}
|
|
@@ -43,8 +43,12 @@ export const TASKPLANE_COMPAT_TASKS_ROOT = "taskplane-tasks";
|
|
|
43
43
|
export const TASKPLANE_COMPAT_PRESET = "taskplane-compat";
|
|
44
44
|
export const LEGACY_TASKPLANE_PRESET_ALIASES = [TASKPLANE_COMPAT_PRESET];
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
/** Phase-A-safe evidence argv (no shell metacharacters); matches templates/spine-config.json. */
|
|
47
|
+
export const SPINE_INIT_BUILD_COMMAND = "npm run typecheck";
|
|
48
|
+
export const SPINE_INIT_TEST_COMMAND = "npm test";
|
|
47
49
|
export const SPINE_INIT_COVERAGE_COMMAND = "npm run coverage:check";
|
|
50
|
+
/** @deprecated Prefer SPINE_INIT_BUILD_COMMAND / SPINE_INIT_TEST_COMMAND. */
|
|
51
|
+
export const SPINE_INIT_TESTING_COMMAND = SPINE_INIT_TEST_COMMAND;
|
|
48
52
|
|
|
49
53
|
export const SPINE_GITIGNORE_ENTRIES = [
|
|
50
54
|
".pi/",
|
|
@@ -166,8 +170,8 @@ export function parseInitArgs(args) {
|
|
|
166
170
|
|
|
167
171
|
/** Apply production-ready defaults for every greenfield init. */
|
|
168
172
|
export function applySpineInitDefaults(config) {
|
|
169
|
-
config.testing.build =
|
|
170
|
-
config.testing.test =
|
|
173
|
+
config.testing.build = SPINE_INIT_BUILD_COMMAND;
|
|
174
|
+
config.testing.test = SPINE_INIT_TEST_COMMAND;
|
|
171
175
|
config.testing.testWithCoverage = SPINE_INIT_COVERAGE_COMMAND;
|
|
172
176
|
config.dashboard = { ...(config.dashboard ?? {}), port: 8109 };
|
|
173
177
|
config.gates = {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"baseBranch": "main",
|
|
11
11
|
"testing": {
|
|
12
|
-
"build": "npm run typecheck
|
|
13
|
-
"test": "npm
|
|
12
|
+
"build": "npm run typecheck",
|
|
13
|
+
"test": "npm test",
|
|
14
14
|
"testWithCoverage": "npm run coverage:check"
|
|
15
15
|
},
|
|
16
16
|
"agents": {
|