pi-spine 1.6.0 → 1.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-wait.mjs +12 -0
- package/package.json +2 -2
- package/skills/spine-release-operator/SKILL.md +37 -7
- package/src/batch/attached-runner.mjs +18 -7
- package/src/batch/contract-task-start.mjs +12 -7
- package/src/batch/contract-verify.mjs +25 -1
- package/src/batch/detached-spawn.mjs +78 -0
- package/src/batch/detached-start.mjs +25 -71
- package/src/batch/diagnosis.mjs +25 -2
- package/src/batch/evidence.mjs +30 -250
- package/src/batch/gate-evidence-collect.mjs +172 -0
- package/src/batch/gate-evidence-read.mjs +145 -0
- package/src/batch/gate.mjs +28 -38
- package/src/batch/lane-dirty-check.mjs +102 -0
- package/src/batch/lifecycle.mjs +6 -5
- package/src/batch/post-merge-limbo.mjs +1 -1
- package/src/batch/postmortem.mjs +1 -2
- package/src/batch/reconcile.mjs +1 -1
- package/src/batch/resume-common.mjs +7 -1
- package/src/batch/resume-multi-validate.mjs +25 -101
- package/src/batch/resume-validation.mjs +120 -0
- package/src/batch/sequence.mjs +11 -2
- package/src/batch/supervisor-spawn.mjs +379 -0
- package/src/cli/spine-wait.mjs +114 -0
- package/src/cli/wait.mjs +7 -43
- package/src/config/defaults.mjs +4 -1
- package/src/config/settings-fields.mjs +23 -0
- package/src/config/spine-config-load.mjs +6 -0
- package/src/config/spine-config-schema.mjs +121 -0
- package/src/config/spine-init-constants.mjs +19 -1
- package/src/config/worktree-setup-hook.mjs +221 -0
- package/src/doctor/agent-models.mjs +1 -0
- package/src/doctor/run-doctor-checks.mjs +14 -0
- package/src/doctor/supervisor.mjs +66 -0
- package/src/doctor/worktree-health.mjs +1 -1
- package/templates/agents/supervisor.md +27 -18
- package/templates/spine-config.json +16 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator poll interval schema and resolvers (SP-452, GitHub #98).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Default attached milestone reporter poll interval. */
|
|
6
|
+
export const DEFAULT_ATTACHED_MILESTONE_POLL_MS = 2_000;
|
|
7
|
+
|
|
8
|
+
/** Default sequence batch terminal wait poll interval. */
|
|
9
|
+
export const DEFAULT_SEQUENCE_POLL_MS = 5_000;
|
|
10
|
+
|
|
11
|
+
/** Default dashboard SSE poll interval (wired in SP-453). */
|
|
12
|
+
export const DEFAULT_DASHBOARD_POLL_MS = 2_000;
|
|
13
|
+
|
|
14
|
+
/** Lower bound for orchestrator poll intervals. */
|
|
15
|
+
export const MIN_ORCHESTRATOR_POLL_MS = 100;
|
|
16
|
+
|
|
17
|
+
/** Upper bound for orchestrator poll intervals. */
|
|
18
|
+
export const MAX_ORCHESTRATOR_POLL_MS = 60_000;
|
|
19
|
+
|
|
20
|
+
/** @type {Readonly<{ attachedMilestonePollMs: number; sequencePollMs: number; dashboardPollMs: number }>} */
|
|
21
|
+
export const ORCHESTRATOR_DEFAULTS = Object.freeze({
|
|
22
|
+
attachedMilestonePollMs: DEFAULT_ATTACHED_MILESTONE_POLL_MS,
|
|
23
|
+
sequencePollMs: DEFAULT_SEQUENCE_POLL_MS,
|
|
24
|
+
dashboardPollMs: DEFAULT_DASHBOARD_POLL_MS,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {unknown} value
|
|
29
|
+
* @param {string} fieldLabel
|
|
30
|
+
* @returns {{ ok: true, value: number } | { ok: false, code: string, message: string, suggestedCommand: string }}
|
|
31
|
+
*/
|
|
32
|
+
function validatePositivePollMs(value, fieldLabel) {
|
|
33
|
+
if (value == null) {
|
|
34
|
+
return { ok: true, value: 0 };
|
|
35
|
+
}
|
|
36
|
+
const parsed = Number(value);
|
|
37
|
+
if (!Number.isFinite(parsed) || !Number.isInteger(parsed) || parsed <= 0) {
|
|
38
|
+
return {
|
|
39
|
+
ok: false,
|
|
40
|
+
code: "CONFIG_ORCHESTRATOR_INVALID",
|
|
41
|
+
message: `${fieldLabel} must be a positive integer when set`,
|
|
42
|
+
suggestedCommand: "spine init --force",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (parsed < MIN_ORCHESTRATOR_POLL_MS || parsed > MAX_ORCHESTRATOR_POLL_MS) {
|
|
46
|
+
return {
|
|
47
|
+
ok: false,
|
|
48
|
+
code: "CONFIG_ORCHESTRATOR_INVALID",
|
|
49
|
+
message: `${fieldLabel} must be between ${MIN_ORCHESTRATOR_POLL_MS} and ${MAX_ORCHESTRATOR_POLL_MS}`,
|
|
50
|
+
suggestedCommand: "spine init --force",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return { ok: true, value: parsed };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {Record<string, any>} config
|
|
58
|
+
* @returns {null | { code: string; message: string; suggestedCommand: string }}
|
|
59
|
+
*/
|
|
60
|
+
export function validateOrchestratorConfig(config) {
|
|
61
|
+
const orchestrator = config.orchestrator;
|
|
62
|
+
if (orchestrator == null) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
if (typeof orchestrator !== "object" || Array.isArray(orchestrator)) {
|
|
66
|
+
return {
|
|
67
|
+
code: "CONFIG_ORCHESTRATOR_INVALID",
|
|
68
|
+
message: "orchestrator must be an object when set",
|
|
69
|
+
suggestedCommand: "spine init --force",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (const [key, label] of [
|
|
74
|
+
["attachedMilestonePollMs", "orchestrator.attachedMilestonePollMs"],
|
|
75
|
+
["sequencePollMs", "orchestrator.sequencePollMs"],
|
|
76
|
+
["dashboardPollMs", "orchestrator.dashboardPollMs"],
|
|
77
|
+
]) {
|
|
78
|
+
const result = validatePositivePollMs(orchestrator[key], label);
|
|
79
|
+
if (!result.ok) {
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {object} [params]
|
|
89
|
+
* @param {object} [params.config]
|
|
90
|
+
*/
|
|
91
|
+
export function resolveAttachedMilestonePollMs({ config = {} } = {}) {
|
|
92
|
+
const configured = Number(config.orchestrator?.attachedMilestonePollMs);
|
|
93
|
+
if (Number.isFinite(configured) && configured > 0) {
|
|
94
|
+
return Math.min(Math.max(configured, MIN_ORCHESTRATOR_POLL_MS), MAX_ORCHESTRATOR_POLL_MS);
|
|
95
|
+
}
|
|
96
|
+
return DEFAULT_ATTACHED_MILESTONE_POLL_MS;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param {object} [params]
|
|
101
|
+
* @param {object} [params.config]
|
|
102
|
+
*/
|
|
103
|
+
export function resolveSequencePollMs({ config = {} } = {}) {
|
|
104
|
+
const configured = Number(config.orchestrator?.sequencePollMs);
|
|
105
|
+
if (Number.isFinite(configured) && configured > 0) {
|
|
106
|
+
return Math.min(Math.max(configured, MIN_ORCHESTRATOR_POLL_MS), MAX_ORCHESTRATOR_POLL_MS);
|
|
107
|
+
}
|
|
108
|
+
return DEFAULT_SEQUENCE_POLL_MS;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {object} [params]
|
|
113
|
+
* @param {object} [params.config]
|
|
114
|
+
*/
|
|
115
|
+
export function resolveDashboardPollMs({ config = {} } = {}) {
|
|
116
|
+
const configured = Number(config.orchestrator?.dashboardPollMs);
|
|
117
|
+
if (Number.isFinite(configured) && configured > 0) {
|
|
118
|
+
return Math.min(Math.max(configured, MIN_ORCHESTRATOR_POLL_MS), MAX_ORCHESTRATOR_POLL_MS);
|
|
119
|
+
}
|
|
120
|
+
return DEFAULT_DASHBOARD_POLL_MS;
|
|
121
|
+
}
|
|
@@ -5,6 +5,11 @@ import { validateSpineConfig } from "./spine-config-load.mjs";
|
|
|
5
5
|
import { applyConfigDefaults } from "./merge-defaults.mjs";
|
|
6
6
|
import { discoverCursorRules } from "./cursor-rules/discover.mjs";
|
|
7
7
|
import { RULES_PROFILE_REL_PATH } from "./cursor-rules/profile.mjs";
|
|
8
|
+
import {
|
|
9
|
+
copyFlutterWorktreeSetupHookTemplate,
|
|
10
|
+
FLUTTER_WORKTREE_SETUP_HOOK_TEMPLATE,
|
|
11
|
+
stripTemplateOnlyKeys,
|
|
12
|
+
} from "./worktree-setup-hook.mjs";
|
|
8
13
|
|
|
9
14
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
15
|
const __dirname = path.dirname(__filename);
|
|
@@ -15,6 +20,7 @@ export const TEMPLATE_PATHS = {
|
|
|
15
20
|
rulesProfile: path.join(PACKAGE_ROOT, "templates", "rules-profile.json"),
|
|
16
21
|
tasksContext: path.join(PACKAGE_ROOT, "templates", "tasks", "CONTEXT.md"),
|
|
17
22
|
constitution: path.join(PACKAGE_ROOT, "templates", "docs", "constitution.md"),
|
|
23
|
+
flutterWorktreeSetupHook: FLUTTER_WORKTREE_SETUP_HOOK_TEMPLATE,
|
|
18
24
|
agents: {
|
|
19
25
|
worker: path.join(PACKAGE_ROOT, "templates", "agents", "worker.md"),
|
|
20
26
|
reviewer: path.join(PACKAGE_ROOT, "templates", "agents", "reviewer.md"),
|
|
@@ -56,6 +62,7 @@ export function getTemplatePaths() {
|
|
|
56
62
|
TEMPLATE_PATHS.rulesProfile,
|
|
57
63
|
TEMPLATE_PATHS.tasksContext,
|
|
58
64
|
TEMPLATE_PATHS.constitution,
|
|
65
|
+
TEMPLATE_PATHS.flutterWorktreeSetupHook,
|
|
59
66
|
...Object.values(TEMPLATE_PATHS.agents),
|
|
60
67
|
]) {
|
|
61
68
|
if (!fs.existsSync(templatePath)) {
|
|
@@ -183,7 +190,7 @@ export function applyTaskplaneCompatPreset(config) {
|
|
|
183
190
|
|
|
184
191
|
export function buildSpineConfig(projectRoot, tasksRoot, { preset } = {}) {
|
|
185
192
|
const template = loadSpineConfigTemplate();
|
|
186
|
-
const config = structuredClone(template);
|
|
193
|
+
const config = stripTemplateOnlyKeys(structuredClone(template));
|
|
187
194
|
config.project.name = path.basename(projectRoot);
|
|
188
195
|
config.paths.tasksRoot = tasksRoot;
|
|
189
196
|
applySpineInitDefaults(config);
|
|
@@ -366,6 +373,17 @@ export function runInit(projectRoot, args = []) {
|
|
|
366
373
|
});
|
|
367
374
|
}
|
|
368
375
|
|
|
376
|
+
const hookTemplateResult = copyFlutterWorktreeSetupHookTemplate(projectRoot, { force, dryRun });
|
|
377
|
+
if (hookTemplateResult.action === "create" || hookTemplateResult.action === "overwrite") {
|
|
378
|
+
actions.push({ action: hookTemplateResult.action, path: hookTemplateResult.path });
|
|
379
|
+
} else if (hookTemplateResult.action === "error") {
|
|
380
|
+
return {
|
|
381
|
+
ok: false,
|
|
382
|
+
error: hookTemplateResult.error,
|
|
383
|
+
exitCode: 1,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
369
387
|
const rulesDiscoverResult = runInitRulesDiscover(projectRoot, { dryRun, force });
|
|
370
388
|
if (!rulesDiscoverResult.ok) {
|
|
371
389
|
return {
|
|
@@ -1,9 +1,230 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sandbox validation for worktreeSetupHook (SP-102).
|
|
3
|
+
* Flutter gitignored-asset hook template and doctor helpers (SP-459, #80).
|
|
4
|
+
*
|
|
5
|
+
* worktreeSetupHook runs once per lane (cwd = lane worktree). The hook receives
|
|
6
|
+
* SPINE_PROJECT_ROOT (main checkout), SPINE_WORKTREE, SPINE_BATCH_ID, and
|
|
7
|
+
* SPINE_LANE_NUMBER. Symlink gitignored pubspec asset dirs from SPINE_PROJECT_ROOT
|
|
8
|
+
* into the lane worktree so flutter test can resolve pubspec.yaml paths.
|
|
3
9
|
*/
|
|
4
10
|
|
|
5
11
|
import fs from "node:fs";
|
|
6
12
|
import path from "node:path";
|
|
13
|
+
import { execFileSync } from "node:child_process";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = path.dirname(__filename);
|
|
18
|
+
const PACKAGE_ROOT = path.resolve(__dirname, "../..");
|
|
19
|
+
|
|
20
|
+
/** Relative hook path copied by spine init for Flutter pubspec assets (#80). */
|
|
21
|
+
export const FLUTTER_WORKTREE_SETUP_HOOK_REL = "scripts/spine-worktree-setup-flutter.sh";
|
|
22
|
+
|
|
23
|
+
/** Package template source for {@link FLUTTER_WORKTREE_SETUP_HOOK_REL}. */
|
|
24
|
+
export const FLUTTER_WORKTREE_SETUP_HOOK_TEMPLATE = path.join(
|
|
25
|
+
PACKAGE_ROOT,
|
|
26
|
+
"templates",
|
|
27
|
+
"spine-worktree-setup-flutter.sh",
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Remove template-only documentation keys before writing consumer config.
|
|
32
|
+
*
|
|
33
|
+
* @param {Record<string, unknown>} config
|
|
34
|
+
*/
|
|
35
|
+
export function stripTemplateOnlyKeys(config) {
|
|
36
|
+
const stripped = structuredClone(config);
|
|
37
|
+
delete stripped._examples;
|
|
38
|
+
return stripped;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Lightweight pubspec.yaml asset path extraction (no YAML dependency).
|
|
43
|
+
*
|
|
44
|
+
* @param {string} pubspecContent
|
|
45
|
+
* @returns {string[]}
|
|
46
|
+
*/
|
|
47
|
+
export function extractPubspecAssetPaths(pubspecContent) {
|
|
48
|
+
/** @type {string[]} */
|
|
49
|
+
const paths = [];
|
|
50
|
+
for (const line of pubspecContent.split(/\r?\n/)) {
|
|
51
|
+
const trimmed = line.trim();
|
|
52
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
53
|
+
const match = trimmed.match(/^-\s+(assets\/[^\s#]+)/);
|
|
54
|
+
if (!match) continue;
|
|
55
|
+
const assetPath = match[1].replace(/\/+$/, "");
|
|
56
|
+
paths.push(assetPath);
|
|
57
|
+
}
|
|
58
|
+
return [...new Set(paths)];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} projectRoot
|
|
63
|
+
* @param {string} relPath
|
|
64
|
+
*/
|
|
65
|
+
function isGitignoredPath(projectRoot, relPath) {
|
|
66
|
+
try {
|
|
67
|
+
execFileSync("git", ["check-ignore", "-q", relPath], {
|
|
68
|
+
cwd: projectRoot,
|
|
69
|
+
stdio: "ignore",
|
|
70
|
+
});
|
|
71
|
+
return true;
|
|
72
|
+
} catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Asset paths listed in pubspec.yaml that are gitignored and present on the main checkout.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} projectRoot
|
|
81
|
+
* @returns {string[]}
|
|
82
|
+
*/
|
|
83
|
+
export function findGitignoredPubspecAssetsOnMain(projectRoot) {
|
|
84
|
+
const pubspecPath = path.join(projectRoot, "pubspec.yaml");
|
|
85
|
+
if (!fs.existsSync(pubspecPath)) return [];
|
|
86
|
+
|
|
87
|
+
const assetPaths = extractPubspecAssetPaths(fs.readFileSync(pubspecPath, "utf-8"));
|
|
88
|
+
/** @type {string[]} */
|
|
89
|
+
const gitignoredOnMain = [];
|
|
90
|
+
|
|
91
|
+
for (const relPath of assetPaths) {
|
|
92
|
+
const absPath = path.join(projectRoot, relPath);
|
|
93
|
+
if (!fs.existsSync(absPath)) continue;
|
|
94
|
+
if (isGitignoredPath(projectRoot, relPath)) {
|
|
95
|
+
gitignoredOnMain.push(relPath);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return gitignoredOnMain;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} projectRoot
|
|
104
|
+
* @returns {string[]}
|
|
105
|
+
*/
|
|
106
|
+
function listLaneWorktreePaths(projectRoot) {
|
|
107
|
+
const worktreesRoot = path.join(projectRoot, ".worktrees");
|
|
108
|
+
if (!fs.existsSync(worktreesRoot)) return [];
|
|
109
|
+
|
|
110
|
+
/** @type {string[]} */
|
|
111
|
+
const lanePaths = [];
|
|
112
|
+
for (const batchEntry of fs.readdirSync(worktreesRoot, { withFileTypes: true })) {
|
|
113
|
+
if (!batchEntry.isDirectory()) continue;
|
|
114
|
+
const batchDir = path.join(worktreesRoot, batchEntry.name);
|
|
115
|
+
for (const laneEntry of fs.readdirSync(batchDir, { withFileTypes: true })) {
|
|
116
|
+
if (!laneEntry.isDirectory() || !laneEntry.name.startsWith("lane-")) continue;
|
|
117
|
+
lanePaths.push(path.join(batchDir, laneEntry.name));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return lanePaths;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param {string} lanePath
|
|
125
|
+
* @param {string[]} assetPaths
|
|
126
|
+
* @returns {string[]}
|
|
127
|
+
*/
|
|
128
|
+
function findMissingAssetsInLane(lanePath, assetPaths) {
|
|
129
|
+
/** @type {string[]} */
|
|
130
|
+
const missing = [];
|
|
131
|
+
for (const relPath of assetPaths) {
|
|
132
|
+
if (!fs.existsSync(path.join(lanePath, relPath))) {
|
|
133
|
+
missing.push(relPath);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return missing;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Doctor advisory when Flutter pubspec assets would be missing in lane worktrees (#80).
|
|
141
|
+
*
|
|
142
|
+
* @param {object} params
|
|
143
|
+
* @param {string} params.projectRoot
|
|
144
|
+
* @param {object} [params.config]
|
|
145
|
+
*/
|
|
146
|
+
export function buildGitignoredPubspecAssetsDoctorCheck({ projectRoot, config = {} }) {
|
|
147
|
+
const gitignoredAssets = findGitignoredPubspecAssetsOnMain(projectRoot);
|
|
148
|
+
if (gitignoredAssets.length === 0) {
|
|
149
|
+
return {
|
|
150
|
+
label: "flutter pubspec gitignored assets",
|
|
151
|
+
ok: true,
|
|
152
|
+
detail: "no gitignored pubspec assets on main checkout",
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const hookConfigured =
|
|
157
|
+
typeof config.worktreeSetupHook === "string" && config.worktreeSetupHook.trim().length > 0;
|
|
158
|
+
|
|
159
|
+
const lanePaths = listLaneWorktreePaths(projectRoot);
|
|
160
|
+
/** @type {string[]} */
|
|
161
|
+
const missingInLanes = [];
|
|
162
|
+
for (const lanePath of lanePaths) {
|
|
163
|
+
for (const relPath of findMissingAssetsInLane(lanePath, gitignoredAssets)) {
|
|
164
|
+
missingInLanes.push(`${path.relative(projectRoot, lanePath)}:${relPath}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!hookConfigured) {
|
|
169
|
+
return {
|
|
170
|
+
label: "flutter pubspec gitignored assets",
|
|
171
|
+
ok: true,
|
|
172
|
+
warning: true,
|
|
173
|
+
detail: `${gitignoredAssets.length} gitignored asset path(s) on main; worktreeSetupHook not configured`,
|
|
174
|
+
suggestion:
|
|
175
|
+
`copy ${FLUTTER_WORKTREE_SETUP_HOOK_REL}, set worktreeSetupHook, customize paths — docs/adoption/flutter-worktree-guide.md`,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (missingInLanes.length > 0) {
|
|
180
|
+
return {
|
|
181
|
+
label: "flutter pubspec gitignored assets",
|
|
182
|
+
ok: true,
|
|
183
|
+
warning: true,
|
|
184
|
+
detail: `missing in lane(s): ${missingInLanes.slice(0, 2).join(", ")}${missingInLanes.length > 2 ? "…" : ""}`,
|
|
185
|
+
suggestion: "verify worktreeSetupHook paths; re-run spine batch or spine doctor",
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
label: "flutter pubspec gitignored assets",
|
|
191
|
+
ok: true,
|
|
192
|
+
detail: `${gitignoredAssets.length} gitignored asset path(s); hook configured`,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Copy optional Flutter worktree setup hook template into consumer scripts/ on init.
|
|
198
|
+
*
|
|
199
|
+
* @param {string} projectRoot
|
|
200
|
+
* @param {{ force?: boolean, dryRun?: boolean }} [options]
|
|
201
|
+
*/
|
|
202
|
+
export function copyFlutterWorktreeSetupHookTemplate(projectRoot, { force = false, dryRun = false } = {}) {
|
|
203
|
+
const destRel = FLUTTER_WORKTREE_SETUP_HOOK_REL;
|
|
204
|
+
const destPath = path.join(projectRoot, destRel);
|
|
205
|
+
|
|
206
|
+
if (fs.existsSync(destPath) && !force) {
|
|
207
|
+
return { action: "skip", path: destRel };
|
|
208
|
+
}
|
|
209
|
+
if (!fs.existsSync(FLUTTER_WORKTREE_SETUP_HOOK_TEMPLATE)) {
|
|
210
|
+
return {
|
|
211
|
+
action: "error",
|
|
212
|
+
path: destRel,
|
|
213
|
+
error: `Missing init template: ${FLUTTER_WORKTREE_SETUP_HOOK_TEMPLATE}`,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!dryRun) {
|
|
218
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
219
|
+
fs.copyFileSync(FLUTTER_WORKTREE_SETUP_HOOK_TEMPLATE, destPath);
|
|
220
|
+
fs.chmodSync(destPath, 0o755);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
action: fs.existsSync(destPath) && force ? "overwrite" : "create",
|
|
225
|
+
path: destRel,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
7
228
|
|
|
8
229
|
/**
|
|
9
230
|
* @param {string} projectRoot
|
|
@@ -11,6 +11,7 @@ const MODEL_PATHS = Object.freeze([
|
|
|
11
11
|
{ path: "agents.reviewer.plan.model", get: (c) => c?.agents?.reviewer?.plan?.model },
|
|
12
12
|
{ path: "agents.reviewer.code.model", get: (c) => c?.agents?.reviewer?.code?.model },
|
|
13
13
|
{ path: "agents.reviewer.final.model", get: (c) => c?.agents?.reviewer?.final?.model },
|
|
14
|
+
{ path: "agents.supervisor.model", get: (c) => c?.agents?.supervisor?.model },
|
|
14
15
|
]);
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -23,12 +23,14 @@ import {
|
|
|
23
23
|
} from "./stall-config.mjs";
|
|
24
24
|
import { buildRulesManifestDoctorCheck } from "./rules-manifest.mjs";
|
|
25
25
|
import { buildWorktreeHealthDoctorCheck } from "./worktree-health.mjs";
|
|
26
|
+
import { buildGitignoredPubspecAssetsDoctorCheck } from "../config/worktree-setup-hook.mjs";
|
|
26
27
|
import { buildStaleWorktreesDoctorCheck } from "./stale-worktrees.mjs";
|
|
27
28
|
import { buildWorkerBackendDoctorCheck } from "../config/worker-backend.mjs";
|
|
28
29
|
import { buildAgentModelInheritDoctorCheck, buildReviewerPerTypePinsDoctorCheck } from "./agent-model-inherit.mjs";
|
|
29
30
|
import { buildInheritProviderAuthDoctorCheck } from "./agents-model-inherit.mjs";
|
|
30
31
|
import { buildAgentModelIdsDoctorCheck } from "./agent-models.mjs";
|
|
31
32
|
import { buildPiExtensionConflictDoctorCheck } from "./pi-extension-conflict.mjs";
|
|
33
|
+
import { buildSupervisorConfigDoctorCheck } from "./supervisor.mjs";
|
|
32
34
|
import { CURSOR_RULES_ROOT_REL } from "../config/cursor-rules/discover.mjs";
|
|
33
35
|
import { RULES_PROFILE_REL_PATH } from "../config/cursor-rules/profile.mjs";
|
|
34
36
|
import {
|
|
@@ -366,12 +368,24 @@ export function runDoctorChecks(projectRoot = process.cwd()) {
|
|
|
366
368
|
const modelIdsCheck = buildAgentModelIdsDoctorCheck({ config: configResult.config });
|
|
367
369
|
checks.push(modelIdsCheck);
|
|
368
370
|
if (!modelIdsCheck.ok) issueCount++;
|
|
371
|
+
const supervisorConfigCheck = buildSupervisorConfigDoctorCheck({
|
|
372
|
+
config: configResult.config,
|
|
373
|
+
projectRoot,
|
|
374
|
+
});
|
|
375
|
+
checks.push(supervisorConfigCheck);
|
|
376
|
+
if (!supervisorConfigCheck.ok) issueCount++;
|
|
369
377
|
const worktreeHealthCheck = buildWorktreeHealthDoctorCheck({
|
|
370
378
|
projectRoot,
|
|
371
379
|
config: configResult.config,
|
|
372
380
|
});
|
|
373
381
|
checks.push(worktreeHealthCheck);
|
|
374
382
|
if (!worktreeHealthCheck.ok) issueCount++;
|
|
383
|
+
const pubspecAssetsCheck = buildGitignoredPubspecAssetsDoctorCheck({
|
|
384
|
+
projectRoot,
|
|
385
|
+
config: configResult.config,
|
|
386
|
+
});
|
|
387
|
+
checks.push(pubspecAssetsCheck);
|
|
388
|
+
if (!pubspecAssetsCheck.ok) issueCount++;
|
|
375
389
|
const workerBackendCheck = buildWorkerBackendDoctorCheck(configResult.config);
|
|
376
390
|
checks.push(workerBackendCheck);
|
|
377
391
|
if (!workerBackendCheck.ok) issueCount++;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doctor checks for opt-in supervisor monitor (SP-444 / FR-SHIP-11).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
isSupervisorSpawnEnabled,
|
|
10
|
+
resolveSupervisorModel,
|
|
11
|
+
resolveSupervisorPollIntervalMs,
|
|
12
|
+
} from "../batch/supervisor-spawn.mjs";
|
|
13
|
+
import { validateModelIdFormat } from "../config/model-id.mjs";
|
|
14
|
+
|
|
15
|
+
const SUPERVISOR_AGENT_REL = ".spine/agents/supervisor.md";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {object} params
|
|
19
|
+
* @param {object} [params.config]
|
|
20
|
+
* @param {string} [params.projectRoot]
|
|
21
|
+
* @returns {{ label: string, ok: boolean, warning?: boolean, detail: string, suggestedCommand?: string }}
|
|
22
|
+
*/
|
|
23
|
+
export function buildSupervisorConfigDoctorCheck({
|
|
24
|
+
config = {},
|
|
25
|
+
projectRoot = process.cwd(),
|
|
26
|
+
} = {}) {
|
|
27
|
+
if (!isSupervisorSpawnEnabled(config)) {
|
|
28
|
+
return {
|
|
29
|
+
label: "agents.supervisor (opt-in monitor)",
|
|
30
|
+
ok: true,
|
|
31
|
+
detail: "disabled — no supervisor spawn on batch start",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const templatePath = path.join(projectRoot, SUPERVISOR_AGENT_REL);
|
|
36
|
+
if (!fs.existsSync(templatePath)) {
|
|
37
|
+
return {
|
|
38
|
+
label: "agents.supervisor (opt-in monitor)",
|
|
39
|
+
ok: false,
|
|
40
|
+
detail: "enabled but .spine/agents/supervisor.md missing — spawn will fail",
|
|
41
|
+
suggestedCommand: "spine init",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const model = resolveSupervisorModel(config);
|
|
46
|
+
if (model !== "inherit") {
|
|
47
|
+
const formatResult = validateModelIdFormat(model);
|
|
48
|
+
if (!formatResult.ok) {
|
|
49
|
+
return {
|
|
50
|
+
label: "agents.supervisor (opt-in monitor)",
|
|
51
|
+
ok: false,
|
|
52
|
+
detail: `enabled but agents.supervisor.model invalid: ${formatResult.error}`,
|
|
53
|
+
suggestedCommand: formatResult.canonical
|
|
54
|
+
? `spine settings set agents.supervisor.model ${formatResult.canonical}`
|
|
55
|
+
: "spine settings set agents.supervisor.model cursor/auto",
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const pollMs = resolveSupervisorPollIntervalMs(config);
|
|
61
|
+
return {
|
|
62
|
+
label: "agents.supervisor (opt-in monitor)",
|
|
63
|
+
ok: true,
|
|
64
|
+
detail: `enabled; model=${model}; pollIntervalMs=${pollMs}`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -48,7 +48,7 @@ export function buildWorktreeHealthDoctorCheck({ projectRoot, config = {} }) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const hook = config.
|
|
51
|
+
const hook = config.worktreeSetupHook;
|
|
52
52
|
const hookConfigured = typeof hook === "string" && hook.trim().length > 0;
|
|
53
53
|
if (!process.env.PI_SPINE_ROOT && hookConfigured) {
|
|
54
54
|
issues.push("PI_SPINE_ROOT unset with worktreeSetupHook configured");
|
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: supervisor
|
|
3
|
-
description: Batch supervisor — monitors orchestration,
|
|
4
|
-
tools: read,
|
|
3
|
+
description: Batch supervisor — monitors orchestration health, journals observations, nudges operators
|
|
4
|
+
tools: read,bash,grep,find,ls
|
|
5
5
|
# model:
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
You are the pi-spine **batch supervisor** — a read-only monitor that polls batch health and keeps the operator informed via the orchestration journal.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Standing orders (poll loop)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
When spawned by the batch engine (`agents.supervisor.enabled: true`), a detached monitor process runs this loop until the batch reaches a terminal phase:
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
1. **Poll** `reconcileBatch({ verbose: true })` every `agents.supervisor.pollIntervalMs` (default 30s).
|
|
15
|
+
2. **Journal** `supervisor.observation` with diagnosis, macro phase, running/pending task counts, and `suggestedCommand`.
|
|
16
|
+
3. **Nudge** on actionable diagnosis transitions — journal `supervisor.nudge` with headline + `suggestedCommand` when diagnosis moves to states like `needs_retry`, `engine_orphaned`, `needs_integrate`, `worker_orphaned`, or `state_drift`.
|
|
17
|
+
4. **Stop** when the batch is terminal (`completed`, `failed`, `aborted`, `merge_blocked`) or batch state is cleared — journal `supervisor.stopped`.
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
The engine journals `supervisor.started` (batchId, model, pid) when the monitor spawns on detached `spine batch start`.
|
|
20
|
+
|
|
21
|
+
**You do not** auto-approve gates, integrate, retry tasks, or dismiss batches unless a future explicit opt-in (`agents.supervisor.autoNudge`) is enabled.
|
|
22
|
+
|
|
23
|
+
## Operator tools (primary surfaces)
|
|
17
24
|
|
|
18
25
|
| Tool | Purpose |
|
|
19
26
|
|------|---------|
|
|
20
27
|
| `spine status --diagnose` | Primary signal — diagnosis, phase, lanes, suggested next command |
|
|
21
28
|
| `spine status` / `spine next` | Headline status and copy-paste `suggestedCommand` |
|
|
22
|
-
| `spine journal replay --batch <batchId>` | Audit trail
|
|
23
|
-
| `spine dashboard` | Local SSE UI
|
|
29
|
+
| `spine journal replay --batch <batchId>` | Audit trail including `supervisor.*` events |
|
|
30
|
+
| `spine dashboard` | Local SSE UI — diagnosis banner, lanes, gate, journal tail |
|
|
24
31
|
|
|
25
32
|
**Journal path:** `.spine/runtime/<batchId>/journal/events.jsonl`
|
|
26
33
|
|
|
27
|
-
**
|
|
28
|
-
|
|
29
|
-
**Diagnosis quick map** (run `spine status --diagnose` daily):
|
|
34
|
+
**Diagnosis quick map:**
|
|
30
35
|
|
|
31
36
|
| `diagnosis` | Typical next step |
|
|
32
37
|
|-------------|-------------------|
|
|
@@ -43,17 +48,21 @@ Full operator procedures: [operator runbook](../../docs/adoption/operator-runboo
|
|
|
43
48
|
|
|
44
49
|
In pi: `/spine-status` mirrors reconciliation; `/spine-dashboard` opens the dashboard.
|
|
45
50
|
|
|
46
|
-
##
|
|
51
|
+
## Config (opt-in)
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
| Field | Default | Purpose |
|
|
54
|
+
|-------|---------|---------|
|
|
55
|
+
| `agents.supervisor.enabled` | `false` | Opt-in spawn on detached batch start |
|
|
56
|
+
| `agents.supervisor.model` | `inherit` | Model pin when a Pi session is used |
|
|
57
|
+
| `agents.supervisor.pollIntervalMs` | `30000` | Reconcile poll interval |
|
|
58
|
+
| `agents.supervisor.autoNudge` | `false` | Future — automated recovery actions (deferred) |
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
## Project overrides
|
|
61
|
+
|
|
62
|
+
Edit `.spine/agents/supervisor.md` in your consumer repo for project-specific escalation notes. The batch engine loads this file when spawning a supervisor Pi session.
|
|
52
63
|
|
|
53
64
|
## Taskplane mutual exclusion
|
|
54
65
|
|
|
55
66
|
Do **not** run Taskplane `/orch` and `spine batch start` on the **same repo** concurrently. Only one orchestrator should own batch state at a time.
|
|
56
67
|
|
|
57
68
|
`spine doctor` and `spine preflight` inspect both `.spine/batch-state.json` (pi-spine) and `.pi/batch-state.json` (Taskplane). Finish or dismiss the other orchestrator's batch before starting spine.
|
|
58
|
-
|
|
59
|
-
Migrating from Taskplane: `spine migrate-from-taskplane`, run spine batches, then retire `/orch`. See runbook §8 (Taskplane coexistence).
|
|
@@ -20,7 +20,13 @@
|
|
|
20
20
|
"thinking": "medium",
|
|
21
21
|
"plan": { "model": "google/gemini-flash-latest", "thinking": "low" }
|
|
22
22
|
},
|
|
23
|
-
"supervisor": {
|
|
23
|
+
"supervisor": {
|
|
24
|
+
"enabled": false,
|
|
25
|
+
"model": "inherit",
|
|
26
|
+
"pollIntervalMs": 30000,
|
|
27
|
+
"autoNudge": false,
|
|
28
|
+
"thinking": "off"
|
|
29
|
+
}
|
|
24
30
|
},
|
|
25
31
|
"lanes": {
|
|
26
32
|
"maxParallel": 3,
|
|
@@ -42,6 +48,11 @@
|
|
|
42
48
|
"dashboard": {
|
|
43
49
|
"port": 8109
|
|
44
50
|
},
|
|
51
|
+
"orchestrator": {
|
|
52
|
+
"attachedMilestonePollMs": 2000,
|
|
53
|
+
"sequencePollMs": 5000,
|
|
54
|
+
"dashboardPollMs": 2000
|
|
55
|
+
},
|
|
45
56
|
"gates": {
|
|
46
57
|
"requireBeforeIntegrate": true,
|
|
47
58
|
"collectBuildEvidence": true,
|
|
@@ -67,6 +78,10 @@
|
|
|
67
78
|
"mode": "required",
|
|
68
79
|
"legacyTaskIdPrefixes": ["TP-"]
|
|
69
80
|
},
|
|
81
|
+
"_examples": {
|
|
82
|
+
"worktreeSetupHook": "scripts/spine-worktree-setup-flutter.sh",
|
|
83
|
+
"_worktreeSetupHookNote": "Optional Flutter: symlink gitignored pubspec assets from SPINE_PROJECT_ROOT into lane worktrees — see docs/adoption/flutter-worktree-guide.md"
|
|
84
|
+
},
|
|
70
85
|
"worktreeSetupHook": "",
|
|
71
86
|
"worktreeSetupIgnorePaths": [],
|
|
72
87
|
"referenceDocs": ["docs/constitution.md"],
|