muse-crew 0.1.0 → 0.2.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/AGENTS.md +1 -1
- package/API.md +24 -2
- package/README.md +5 -5
- package/docs/guide.md +16 -19
- package/lib/crew-release.sh +37 -0
- package/lib/orphan-sweep.sh +8 -9
- package/lib/worktree-lifecycle.sh +8 -0
- package/package.json +1 -1
- package/seed/workflows/bugfix.md +6 -3
- package/seed/workflows/chore.md +5 -3
- package/seed/workflows/standard.md +6 -3
- package/workflows/AGENTS.md +1 -1
- package/workflows/bugfix.js +160 -45
- package/workflows/chore.js +134 -31
- package/workflows/crew-dispatch.js +4 -2
- package/workflows/crew-init.js +1 -1
- package/workflows/docs.js +47 -2
- package/workflows/standard.js +164 -51
package/workflows/bugfix.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const meta = {
|
|
2
2
|
name: "crew-bugfix",
|
|
3
|
-
description: "Bugfix workflow: Triage → Reproduce → Map → Build → Review → Integrate →
|
|
4
|
-
phases: ["Triage", "Reproduce", "Map", "Build", "Review", "Integrate", "
|
|
3
|
+
description: "Bugfix workflow: Triage → Reproduce → Map → Build → Review → Integrate → Publish → QA",
|
|
4
|
+
phases: ["Triage", "Reproduce", "Map", "Build", "Review", "Integrate", "Publish", "QA"],
|
|
5
5
|
steps: [
|
|
6
6
|
{ name: "Triage", identity: "sage" },
|
|
7
7
|
{ name: "Reproduce", identity: "hazel" },
|
|
@@ -9,7 +9,7 @@ export const meta = {
|
|
|
9
9
|
{ name: "Build", identity: "wren" },
|
|
10
10
|
{ name: "Review", identity: "cass" },
|
|
11
11
|
{ name: "Integrate", identity: "wren" },
|
|
12
|
-
{ name: "
|
|
12
|
+
{ name: "Publish", identity: "wren" },
|
|
13
13
|
{ name: "QA", identity: "hazel" }
|
|
14
14
|
],
|
|
15
15
|
reworkTarget: "Build"
|
|
@@ -32,12 +32,17 @@ const MERGE_LOCK_SRC = crewHome + "/lib/merge-lock.sh";
|
|
|
32
32
|
const RUN_LIB = "/tmp/crew-lib-" + taskId;
|
|
33
33
|
const LIFECYCLE = RUN_LIB + "/worktree-lifecycle.sh";
|
|
34
34
|
const MERGE_LOCK = RUN_LIB + "/merge-lock.sh";
|
|
35
|
+
const ORPHAN_SWEEP_SRC = crewHome + "/lib/orphan-sweep.sh";
|
|
36
|
+
const ORPHAN_SWEEP = RUN_LIB + "/orphan-sweep.sh";
|
|
35
37
|
|
|
36
38
|
// Project config — passed by dispatcher, falls back to dashboard defaults
|
|
37
39
|
const projectConfig = inputs.project_config || {};
|
|
40
|
+
// Project this run was dispatched for — the mid-run project-change guard
|
|
41
|
+
// compares the task's live project against this on every phase boundary.
|
|
42
|
+
const LAUNCH_PROJECT_ID = inputs.project_id || "";
|
|
38
43
|
const REPO_PATH = projectConfig.repo_path || "~/workspace/ts-spaces/orchestra-dashboard";
|
|
39
|
-
const
|
|
40
|
-
const
|
|
44
|
+
const PUBLISH_TYPE = projectConfig.deploy_type || "";
|
|
45
|
+
const PUBLISH_SLUG = projectConfig.deploy_slug || DASHBOARD_SLUG;
|
|
41
46
|
const PROJECT_DESC = projectConfig.description || "React + TypeScript web dashboard (client/src/, server/src/, drizzle/)";
|
|
42
47
|
const RELEASE_SCRIPT = crewHome + "/crew-release.sh";
|
|
43
48
|
|
|
@@ -61,13 +66,16 @@ const STEPS = [
|
|
|
61
66
|
{ name: "Build", identity: "wren" },
|
|
62
67
|
{ name: "Review", identity: "cass" },
|
|
63
68
|
{ name: "Integrate", identity: "wren" },
|
|
64
|
-
{ name: "
|
|
69
|
+
{ name: "Publish", identity: "wren" },
|
|
65
70
|
{ name: "QA", identity: "hazel" }
|
|
66
71
|
];
|
|
67
72
|
const BUILD_INDEX = STEPS.findIndex(s => s.name === 'Build');
|
|
68
73
|
if (BUILD_INDEX < 0) throw new Error("STEPS missing 'Build' step");
|
|
69
|
-
const
|
|
70
|
-
|
|
74
|
+
const REWORK_STEP = STEPS[BUILD_INDEX].name;
|
|
75
|
+
// Shared rework budget: Review and QA rejections draw from the SAME pool of 2.
|
|
76
|
+
// E.g. 2 Review bounces + 1 QA bounce = 3 total > budget -> task blocks.
|
|
77
|
+
const MAX_TOTAL_REWORK = 2;
|
|
78
|
+
let totalReworkCount = 0;
|
|
71
79
|
let rejectionNotes = inputs.rejection_notes || "";
|
|
72
80
|
let mapperSpec = "";
|
|
73
81
|
let i = startStepIndex;
|
|
@@ -75,17 +83,73 @@ let i = startStepIndex;
|
|
|
75
83
|
// Pin lifecycle scripts
|
|
76
84
|
await agent(
|
|
77
85
|
"Snapshot lifecycle scripts for version pinning.\n" +
|
|
78
|
-
"Run: mkdir -p " + RUN_LIB + " && cp " + LIFECYCLE_SRC + " " + LIFECYCLE + " && cp " + MERGE_LOCK_SRC + " " + MERGE_LOCK + " && chmod +x " + LIFECYCLE + " " + MERGE_LOCK,
|
|
86
|
+
"Run: mkdir -p " + RUN_LIB + " && cp " + LIFECYCLE_SRC + " " + LIFECYCLE + " && cp " + MERGE_LOCK_SRC + " " + MERGE_LOCK + " && cp " + ORPHAN_SWEEP_SRC + " " + ORPHAN_SWEEP + " && chmod +x " + LIFECYCLE + " " + MERGE_LOCK + " " + ORPHAN_SWEEP,
|
|
79
87
|
{ key: "pin-lifecycle", label: "Pinning lifecycle scripts", schema: { type: "object" } }
|
|
80
88
|
);
|
|
81
89
|
|
|
82
90
|
while (i < STEPS.length) {
|
|
83
91
|
const step = STEPS[i];
|
|
84
|
-
const isFirstClaim = (i === startStepIndex &&
|
|
92
|
+
const isFirstClaim = (i === startStepIndex && totalReworkCount === 0);
|
|
85
93
|
|
|
86
94
|
phase(step.name);
|
|
87
95
|
log(step.name + " step (" + step.identity + ") for task " + taskId);
|
|
88
96
|
|
|
97
|
+
// ── Project-change guard ───────────────────────────────────────────
|
|
98
|
+
// A task moved to another project mid-run must not keep working in the
|
|
99
|
+
// old project's repo. Re-read the task's project at every phase
|
|
100
|
+
// boundary: if it differs from the project this run was dispatched for,
|
|
101
|
+
// abort the stale run (failed at the rework target) so the dispatcher
|
|
102
|
+
// re-launches the step with the new project's config.
|
|
103
|
+
if (LAUNCH_PROJECT_ID) {
|
|
104
|
+
const projectCheck = await agent(
|
|
105
|
+
"Read this task's current project from the dashboard.\n" +
|
|
106
|
+
"Call artifact_invoke_action on slug \"" + DASHBOARD_SLUG + "\", action \"getstate\", args: { \"events_limit\": 1 }.\n" +
|
|
107
|
+
"Find the task with id \"" + taskId + "\" in the returned tasks array.\n" +
|
|
108
|
+
"Return exactly { \"project\": \"<the task's project field, or empty string if absent>\" } and nothing else.",
|
|
109
|
+
{
|
|
110
|
+
key: "project-check-" + step.name + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""),
|
|
111
|
+
label: "Checking project before " + step.name,
|
|
112
|
+
schema: { type: "object", properties: { project: { type: "string" } }, required: ["project"] }
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
const currentProject = (projectCheck && projectCheck.project) ? projectCheck.project : LAUNCH_PROJECT_ID;
|
|
116
|
+
if (currentProject !== LAUNCH_PROJECT_ID) {
|
|
117
|
+
const abortMessage = "Task project changed mid-run from '" + LAUNCH_PROJECT_ID + "' to '" + currentProject + "' — aborting stale run. The dispatcher will re-launch from " + REWORK_STEP + " with the new project context.";
|
|
118
|
+
log(abortMessage);
|
|
119
|
+
const abortSessionPatch = (isFirstClaim && firstSessionId) ? "\"id\": \"" + firstSessionId + "\", " : "";
|
|
120
|
+
await agent(
|
|
121
|
+
"Abort the stale run and remove its worktree from the old project's repo.\n" +
|
|
122
|
+
"Call artifact_invoke_action on slug \"" + DASHBOARD_SLUG + "\", action \"upsertagentsession\", args:\n" +
|
|
123
|
+
"{ \"task_id\": \"" + taskId + "\", " + abortSessionPatch + "\"identity\": \"" + step.identity + "\", \"step\": \"" + REWORK_STEP + "\", \"status\": \"failed\", " +
|
|
124
|
+
"\"notes\": " + JSON.stringify(abortMessage + " Rebuild from the Map session notes in the task's event history.") + " }.\n" +
|
|
125
|
+
"Then call artifact_invoke_action on slug \"" + DASHBOARD_SLUG + "\", action \"logevent\", args:\n" +
|
|
126
|
+
"{ \"task_id\": \"" + taskId + "\", \"type\": \"failed\", \"identity\": \"" + step.identity + "\", \"message\": " + JSON.stringify(abortMessage) + " }.\n" +
|
|
127
|
+
"Then run: CREW_REPO=" + REPO_PATH + " " + LIFECYCLE + " cleanup " + taskId + "\n" +
|
|
128
|
+
"The cleanup output should contain CLEANUP.",
|
|
129
|
+
{ key: "abort-project-change", label: "Aborting stale run (project changed)", schema: { type: "object" } }
|
|
130
|
+
);
|
|
131
|
+
return { status: "failed", task_id: taskId, reason: abortMessage };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Publish is optional and target-based. Empty target = prototyping project: skip the phase.
|
|
136
|
+
// Unknown target (incl. legacy "repo") = config error: block.
|
|
137
|
+
if (step.name === "Publish" && !PUBLISH_TYPE) {
|
|
138
|
+
log("Publish skipped for task " + taskId + " — no publish target configured (deploy_type empty)");
|
|
139
|
+
await agent(
|
|
140
|
+
"Release the merge lock and clean up without publishing.\n" +
|
|
141
|
+
"Run: CREW_REPO=" + REPO_PATH + " " + LIFECYCLE + " post-deploy " + taskId + "\n" +
|
|
142
|
+
"If the output contains DEPLOYED, the lock is released and the worktree is cleaned up.",
|
|
143
|
+
{ key: "publish-skip-cleanup", label: "Skipping Publish (no target)", schema: { type: "object" } }
|
|
144
|
+
);
|
|
145
|
+
i++;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (step.name === "Publish" && PUBLISH_TYPE !== "npm" && PUBLISH_TYPE !== "artifact" && PUBLISH_TYPE !== "vercel") {
|
|
149
|
+
log("Unknown publish target for task " + taskId + ": " + PUBLISH_TYPE);
|
|
150
|
+
return { status: "blocked", task_id: taskId, reason: "Unknown publish target '" + PUBLISH_TYPE + "' — expected 'npm', 'artifact', 'vercel', or empty (skip publish)." };
|
|
151
|
+
}
|
|
152
|
+
|
|
89
153
|
// Claim session
|
|
90
154
|
let activeSessionId;
|
|
91
155
|
if (isFirstClaim && firstSessionId) {
|
|
@@ -94,10 +158,10 @@ while (i < STEPS.length) {
|
|
|
94
158
|
const claimResult = await agent(
|
|
95
159
|
"Claim a session for this task step.\n" +
|
|
96
160
|
"Call artifact_invoke_action on slug \"" + DASHBOARD_SLUG + "\", action \"claimtask\", args:\n" +
|
|
97
|
-
"{ \"task_id\": \"" + taskId + "\", \"identity\": \"" + step.identity + "\", \"step\": \"" + step.name + "\", \"notes\": \"" + step.name + " step started" + (
|
|
161
|
+
"{ \"task_id\": \"" + taskId + "\", \"identity\": \"" + step.identity + "\", \"step\": \"" + step.name + "\", \"notes\": \"" + step.name + " step started" + (totalReworkCount > 0 ? " (rework #" + totalReworkCount + ")" : "") + "\" }.\n" +
|
|
98
162
|
"Return the session_id from the response.",
|
|
99
163
|
{
|
|
100
|
-
key: "claim-" + step.name + (
|
|
164
|
+
key: "claim-" + step.name + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""),
|
|
101
165
|
label: "Claiming " + step.name,
|
|
102
166
|
schema: {
|
|
103
167
|
type: "object",
|
|
@@ -137,8 +201,10 @@ while (i < STEPS.length) {
|
|
|
137
201
|
(mapperSpec ? "MAPPER'S SPEC (implement exactly this):\n" + mapperSpec + "\n\n" : "") +
|
|
138
202
|
"Your working directory: " + REPO_PATH + "/.worktrees/" + taskId + "/\n" +
|
|
139
203
|
"This is the project source: " + PROJECT_DESC + "\n" +
|
|
140
|
-
"Edit the TypeScript source files directly. Do NOT use artifact_edit — that happens in the
|
|
141
|
-
"Do not add unrequested features. Build exactly what the spec calls for.\n
|
|
204
|
+
"Edit the TypeScript source files directly. Do NOT use artifact_edit — that happens in the Publish phase.\n" +
|
|
205
|
+
"Do not add unrequested features. Build exactly what the spec calls for.\n" +
|
|
206
|
+
"PUBLIC DOCS: If your change is public-affecting (it alters anything a user or consumer can observe: API actions, parameters, behavior, or errors), update the public docs in the same commit — API.md for API changes. Documentation and implementation ship together.\n\n" +
|
|
207
|
+
(PUBLISH_TYPE === "npm" ? "PACKAGE VERSION: this project publishes to the npm registry, so you choose the package version. If this change warrants a published release (anything a consumer can observe: workflow behavior, phase lists, identities, published docs, API), bump the version in package.json with semver (patch for fixes, minor for new behavior, major for breaking changes) and state the chosen version and why in your summary. If the change is internal-only, leave the version unchanged and say so. Check the registry first — npm view muse-crew version — and never re-publish an existing version.\n\n" : "") +
|
|
142
208
|
"STEP 3: Commit your changes.\n" +
|
|
143
209
|
"cd " + REPO_PATH + "/.worktrees/" + taskId + "\n" +
|
|
144
210
|
"git add -A\n" +
|
|
@@ -151,9 +217,12 @@ while (i < STEPS.length) {
|
|
|
151
217
|
(mapperSpec ? "MAPPER'S SPEC (the builder was asked to implement exactly this):\n" + mapperSpec + "\n\n" : "Read the spec (from the task description or spec files under " + crewHome + "/).\n\n") +
|
|
152
218
|
"Examine the code changes by running:\n" +
|
|
153
219
|
"CREW_REPO=" + REPO_PATH + " " + LIFECYCLE + " inspect " + taskId + "\n\n" +
|
|
220
|
+
"The inspect output is authoritative: it prints the task branch's actual tip commit (TIP) and every commit ahead of main. Base your review ONLY on this output — do NOT run git log yourself to pick commits, and do NOT discuss commit hashes from any other source (they may come from stale rework rounds or a different repo).\n\n" +
|
|
154
221
|
"You can also read specific files in the worktree at:\n" +
|
|
155
222
|
REPO_PATH + "/.worktrees/" + taskId + "/\n\n" +
|
|
156
223
|
"Check quality, correctness, and spec compliance.\n" +
|
|
224
|
+
"Check that public-affecting changes have matching public doc updates (API.md or the published API contract). If the docs are missing or inaccurate, reject with notes on what is stale.\n" +
|
|
225
|
+
(PUBLISH_TYPE === "npm" ? "PACKAGE VERSION: this project publishes to the npm registry. Validate the builder's version choice: package.json must hold valid semver; if the version was bumped it must be greater than the registry version (npm view muse-crew version), the bump scope (patch/minor/major) must fit the change, and exactly one version field may change. If the version is invalid, already published, or mis-scoped, reject with notes.\n" : "") +
|
|
157
226
|
"If the work passes review, your final response MUST be valid JSON and nothing else: { \"passed\": true, \"summary\": \"approval notes\" }.\n" +
|
|
158
227
|
"If the work fails review, your final response MUST be valid JSON and nothing else: { \"passed\": false, \"summary\": \"rejection notes explaining what needs to change\" }.\n" +
|
|
159
228
|
"No prose, no markdown, just the JSON object.";
|
|
@@ -163,45 +232,82 @@ while (i < STEPS.length) {
|
|
|
163
232
|
"Run: CREW_REPO=" + REPO_PATH + " " + LIFECYCLE + " integrate " + taskId + " \"merge: fix: " + safeTitle + "\"\n\n" +
|
|
164
233
|
"Read the output:\n" +
|
|
165
234
|
"- If it contains MERGED, integration succeeded. Report the merged commit hash.\n" +
|
|
166
|
-
"- If it contains LOCK_HELD, another task
|
|
235
|
+
"- If it contains LOCK_HELD, another task holds the merge lock (mid Integrate/Publish). Set passed to false.\n" +
|
|
167
236
|
"- If it contains CONFLICT, a merge conflict occurred. Set passed to false with details.\n" +
|
|
168
237
|
"- If it contains ERROR, something else failed. Set passed to false.\n\n" +
|
|
238
|
+
"\n" +
|
|
239
|
+
"STEP 2: Push the merged main to the remote repository.\n" +
|
|
240
|
+
"Run: cd " + REPO_PATH + " && git push origin main\n" +
|
|
241
|
+
"- If the push succeeds, report the merged commit hash.\n" +
|
|
242
|
+
"- If the push is rejected as non-fast-forward (the remote has commits not present locally),\n" +
|
|
243
|
+
" NEVER force-push. Do not run any --force variant. Set passed to false with summary:\n" +
|
|
244
|
+
" 'git push origin main rejected as non-fast-forward — remote main has diverged; manual resolution required'.\n\n" +
|
|
169
245
|
"Your final response MUST be valid JSON and nothing else: { \"summary\": \"result\", \"passed\": true/false }. No prose, no markdown, just the JSON object.";
|
|
170
246
|
|
|
171
|
-
} else if (step.name === "
|
|
172
|
-
if (
|
|
173
|
-
//
|
|
174
|
-
instructions = "
|
|
175
|
-
"
|
|
247
|
+
} else if (step.name === "Publish") {
|
|
248
|
+
if (PUBLISH_TYPE === "npm") {
|
|
249
|
+
// npm packages: immutable release + pack + publish to the registry (push is universal in Integrate)
|
|
250
|
+
instructions = "Publish the npm package to the registry.\n\n" +
|
|
251
|
+
"The repo push already happened in Integrate — do NOT push to git in this phase, and NEVER force-push.\n" +
|
|
252
|
+
"Version discipline: publish ships the exact version merged in Integrate (Build applied it, Review validated it). Do not bump the version here.\n\n" +
|
|
253
|
+
"STEP 0: Refresh the merge lock to prevent stale-lock breaking during publish.\n" +
|
|
176
254
|
"Run: CREW_REPO=" + REPO_PATH + " " + LIFECYCLE + " refresh-lock " + taskId + "\n\n" +
|
|
177
|
-
"STEP 1: Install and activate the
|
|
255
|
+
"STEP 1: Install and activate the immutable release.\n" +
|
|
178
256
|
"Run: " + RELEASE_SCRIPT + " deploy " + REPO_PATH + "\n" +
|
|
179
257
|
"Verify the output contains INSTALLED and ACTIVATED (or EXISTS and ACTIVATED if unchanged).\n\n" +
|
|
180
|
-
"STEP 2:
|
|
258
|
+
"STEP 2: Check whether the package version needs publishing.\n" +
|
|
259
|
+
"Read the version from: cd " + REPO_PATH + " && node -p \"require('./package.json').version\"\n" +
|
|
260
|
+
"Check the registry: npm view muse-crew version 2>/dev/null || echo NOT_FOUND\n" +
|
|
261
|
+
"If the local version matches the registry version, the version is already live — skip to STEP 5.\n\n" +
|
|
262
|
+
"STEP 3: Pack and publish.\n" +
|
|
263
|
+
"Run: cd " + REPO_PATH + " && npm pack\n" +
|
|
264
|
+
"Then publish: python3 ~/workspace/skills/npm/bin/npm-publish.py " + REPO_PATH + "/muse-crew-$(node -p \"require('" + REPO_PATH + "/package.json').version\").tgz\n" +
|
|
265
|
+
"If publish fails with 'You cannot publish over the previously published versions', the version is already live — continue to STEP 4.\n\n" +
|
|
266
|
+
"STEP 4: Verify.\n" +
|
|
267
|
+
"Run: npm view muse-crew version\n" +
|
|
268
|
+
"Confirm it matches the local package.json version.\n\n" +
|
|
269
|
+
"STEP 5: Finalize.\n" +
|
|
181
270
|
"Run: CREW_REPO=" + REPO_PATH + " " + LIFECYCLE + " post-deploy " + taskId + "\n" +
|
|
182
271
|
"If the output contains DEPLOYED, finalization is complete.\n\n" +
|
|
183
|
-
"Your final response MUST be valid JSON and nothing else: { \"summary\": \"
|
|
272
|
+
"Your final response MUST be valid JSON and nothing else: { \"summary\": \"result\", \"passed\": true }.\n" +
|
|
184
273
|
"No prose, no markdown, just the JSON object.";
|
|
185
|
-
} else {
|
|
186
|
-
|
|
187
|
-
|
|
274
|
+
} else if (PUBLISH_TYPE === "artifact") {
|
|
275
|
+
// Artifact projects: rebuild the live artifact via artifact_edit, then finalize
|
|
276
|
+
instructions = "Publish the merged code to the live artifact.\n\n" +
|
|
277
|
+
"POLICY: The live artifact is rebuilt only in this phase, from the repo. Never use artifact_edit to change the artifact directly — fixes go through the repo and the loop. A source fix is not done until the artifact is rebuilt from it here.\n\n" +
|
|
278
|
+
"The repo push already happened in Integrate — do NOT push to git in this phase.\n\n" +
|
|
279
|
+
"STEP 0: Refresh the merge lock to prevent stale-lock breaking during publish.\n" +
|
|
188
280
|
"Run: CREW_REPO=" + REPO_PATH + " " + LIFECYCLE + " refresh-lock " + taskId + "\n\n" +
|
|
189
|
-
"STEP 1:
|
|
281
|
+
"STEP 1: Publish to the live artifact.\n" +
|
|
190
282
|
"Get the change summary: cd " + REPO_PATH + " && git log -1 --stat\n" +
|
|
191
|
-
"Then call artifact_edit with slug \"" +
|
|
283
|
+
"Then call artifact_edit with slug \"" + PUBLISH_SLUG + "\" and verbatim_request:\n" +
|
|
192
284
|
"'Rebuild the application from current source. Do not modify any source files — just rebuild and deploy what is on disk.'\n" +
|
|
193
285
|
"Wait for the build to complete by polling artifact_status until it is no longer running.\n\n" +
|
|
286
|
+
"STEP 1B: Stamp publication provenance.\n" +
|
|
287
|
+
"Run: cd " + REPO_PATH + " && git rev-parse HEAD\n" +
|
|
288
|
+
"Run: basename $(readlink " + crewHome + "/current)\n" +
|
|
289
|
+
"Run: date -u +%Y-%m-%dT%H:%M:%SZ\n" +
|
|
290
|
+
"Call artifact_invoke_action on slug \"" + PUBLISH_SLUG + "\", action \"setprovenance\", args:\n" +
|
|
291
|
+
"{ \"source_commit\": \"<rev-parse output>\", \"crew_release\": \"<basename output>\", \"published_at\": \"<date output>\", \"task_id\": \"" + taskId + "\" }.\n" +
|
|
292
|
+
"Confirm the response contains ok: true. If setprovenance fails, report it in your summary but still run post-deploy to release the lock.\n\n" +
|
|
194
293
|
"STEP 2: Finalize.\n" +
|
|
195
294
|
"Run: CREW_REPO=" + REPO_PATH + " " + LIFECYCLE + " post-deploy " + taskId + "\n" +
|
|
196
|
-
"If the output contains DEPLOYED,
|
|
295
|
+
"If the output contains DEPLOYED, publishing is complete.\n\n" +
|
|
197
296
|
"If artifact_edit failed, still run post-deploy to release the merge lock and clean up.\n" +
|
|
198
|
-
"Report the failure: { \"passed\": false, \"summary\": \"artifact
|
|
199
|
-
"Your final response MUST be valid JSON and nothing else: { \"summary\": \"
|
|
297
|
+
"Report the failure: { \"passed\": false, \"summary\": \"artifact publish failed: [details]\" }.\n\n" +
|
|
298
|
+
"Your final response MUST be valid JSON and nothing else: { \"summary\": \"published changes\", \"passed\": true }.\n" +
|
|
299
|
+
"No prose, no markdown, just the JSON object.";
|
|
300
|
+
} else if (PUBLISH_TYPE === "vercel") {
|
|
301
|
+
// vercel publish is not yet implemented — block without inventing behavior
|
|
302
|
+
instructions = "The project's publish target is \"vercel\", which is not yet implemented.\n" +
|
|
303
|
+
"Do NOT invent publish behavior — do not guess CLI commands, APIs, or deployment steps.\n" +
|
|
304
|
+
"Your final response MUST be valid JSON and nothing else: { \"passed\": false, \"summary\": \"vercel publish not yet implemented\" }.\n" +
|
|
200
305
|
"No prose, no markdown, just the JSON object.";
|
|
201
306
|
}
|
|
202
|
-
|
|
203
307
|
} else if (step.name === "QA") {
|
|
204
308
|
instructions = "Final QA testing. You are CODE-BLIND — do NOT read source code.\n" +
|
|
309
|
+
"Public docs (API.md, README, published action schemas) are NOT source code — read them freely, exactly as a user would.\n" +
|
|
310
|
+
"DOCS GATE: If the fix is public-affecting (it alters anything a user or consumer can observe: API actions, parameters, behavior, or errors), verify the public docs describe it. If public docs are missing or stale, FAIL with { \"passed\": false, \"summary\": \"public docs missing/stale for [the change]\" }. QA always fails when public-affecting changes lack public docs. Guide/tutorial gaps are lower priority — file a follow-up task for those instead of failing.\n" +
|
|
205
311
|
"To test, use artifact_invoke_action on slug \"" + DASHBOARD_SLUG + "\" with action \"getstate\" (args {}) to read current sessions, events, and tasks.\n" +
|
|
206
312
|
"Verify the fix by checking that session notes in the returned data now handle newlines correctly.\n" +
|
|
207
313
|
"You can also check specific data with the getevents action.\n" +
|
|
@@ -210,14 +316,23 @@ while (i < STEPS.length) {
|
|
|
210
316
|
"If testing passes, your final response MUST be valid JSON and nothing else: { \"passed\": true, \"summary\": \"test results\" }.\n" +
|
|
211
317
|
"If testing fails, your final response MUST be valid JSON and nothing else: { \"passed\": false, \"summary\": \"failure details\" }.\n" +
|
|
212
318
|
"No prose, no markdown, just the JSON object.";
|
|
319
|
+
if (PUBLISH_TYPE === "artifact") {
|
|
320
|
+
instructions = "PROVENANCE CHECK (this project publishes to a dashboard artifact).\n" +
|
|
321
|
+
"Call artifact_invoke_action on slug \"" + PUBLISH_SLUG + "\", action \"getprovenance\", args: {}.\n" +
|
|
322
|
+
"If provenance is null, FAIL: { \"passed\": false, \"summary\": \"provenance missing — publish did not stamp\" }.\n" +
|
|
323
|
+
"Run: cd " + REPO_PATH + " && git rev-parse HEAD\n" +
|
|
324
|
+
"Run: basename $(readlink " + crewHome + "/current)\n" +
|
|
325
|
+
"If either hash mismatches, FAIL: { \"passed\": false, \"summary\": \"provenance mismatch: [details]\" }.\n\n" +
|
|
326
|
+
instructions;
|
|
327
|
+
}
|
|
213
328
|
}
|
|
214
329
|
|
|
215
330
|
// Task event history — all phases except Review see the comment log
|
|
216
331
|
var eventPreamble = "";
|
|
217
332
|
if (step.name !== "Review") {
|
|
218
333
|
eventPreamble = "CONTEXT: First, fetch this task's event history for background.\n" +
|
|
219
|
-
"Call artifact_invoke_action on slug \"" + DASHBOARD_SLUG + "\", action \"getevents\", args: { \"
|
|
220
|
-
"
|
|
334
|
+
"Call artifact_invoke_action on slug \"" + DASHBOARD_SLUG + "\", action \"getevents\", args: { \"task_id\": \"" + taskId + "\" }.\n" +
|
|
335
|
+
"The returned events are filtered to this task. They contain notes and decisions from prior phases.\n\n";
|
|
221
336
|
}
|
|
222
337
|
|
|
223
338
|
var stepResult;
|
|
@@ -234,7 +349,7 @@ while (i < STEPS.length) {
|
|
|
234
349
|
"CONSTRAINT: Do NOT call logevent or upsertagentsession — the workflow handles all phase tracking after your step completes.\n\n" +
|
|
235
350
|
"Stay in character. Do the work thoroughly.",
|
|
236
351
|
{
|
|
237
|
-
key: "work-" + step.name + (
|
|
352
|
+
key: "work-" + step.name + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""),
|
|
238
353
|
label: step.identity + ": " + step.name + " on \"" + taskTitle + "\"",
|
|
239
354
|
timeoutMs: 3600000,
|
|
240
355
|
schema: WORK_SCHEMA
|
|
@@ -282,7 +397,7 @@ while (i < STEPS.length) {
|
|
|
282
397
|
"Then call artifact_invoke_action on slug \"" + DASHBOARD_SLUG + "\", action \"logevent\", args:\n" +
|
|
283
398
|
"{ \"task_id\": \"" + taskId + "\", \"type\": \"" + status + "\", \"identity\": \"" + step.identity + "\", \"message\": \"" + step.name + " " + status + " by " + step.identity + "\" }.",
|
|
284
399
|
{
|
|
285
|
-
key: "record-" + step.name + (
|
|
400
|
+
key: "record-" + step.name + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""),
|
|
286
401
|
label: "Recording " + step.name + " result",
|
|
287
402
|
schema: { type: "object" }
|
|
288
403
|
}
|
|
@@ -302,14 +417,14 @@ while (i < STEPS.length) {
|
|
|
302
417
|
|
|
303
418
|
// Review/QA rejection bounces to Build
|
|
304
419
|
if (!passed && (step.name === "Review" || step.name === "QA")) {
|
|
305
|
-
|
|
306
|
-
if (
|
|
307
|
-
log("
|
|
308
|
-
return { status: "blocked", task_id: taskId, reason: "Exceeded " +
|
|
420
|
+
totalReworkCount++;
|
|
421
|
+
if (totalReworkCount > MAX_TOTAL_REWORK) {
|
|
422
|
+
log("Shared rework budget exhausted for task " + taskId + " — worktree preserved at .worktrees/" + taskId + " for manual inspection");
|
|
423
|
+
return { status: "blocked", task_id: taskId, reason: "Exceeded shared rework budget (" + MAX_TOTAL_REWORK + " total rework attempts across Review and QA) after " + step.name + " rejection. Worktree preserved." };
|
|
309
424
|
}
|
|
310
425
|
rejectionNotes = summary;
|
|
311
426
|
i = BUILD_INDEX;
|
|
312
|
-
log(step.name + " rejected — bouncing to Build (rework #" +
|
|
427
|
+
log(step.name + " rejected — bouncing to Build (rework #" + totalReworkCount + " of " + MAX_TOTAL_REWORK + ")");
|
|
313
428
|
continue;
|
|
314
429
|
}
|
|
315
430
|
|
|
@@ -319,10 +434,10 @@ while (i < STEPS.length) {
|
|
|
319
434
|
return { status: "blocked", task_id: taskId, reason: "Integration failed: " + summary };
|
|
320
435
|
}
|
|
321
436
|
|
|
322
|
-
//
|
|
323
|
-
if (!passed && step.name === "
|
|
324
|
-
log("
|
|
325
|
-
return { status: "blocked", task_id: taskId, reason: "
|
|
437
|
+
// Publish failure blocks the task
|
|
438
|
+
if (!passed && step.name === "Publish") {
|
|
439
|
+
log("Publish failed for task " + taskId + ": " + summary);
|
|
440
|
+
return { status: "blocked", task_id: taskId, reason: "Publish failed: " + summary };
|
|
326
441
|
}
|
|
327
442
|
|
|
328
443
|
i++;
|