@tablation/crew 0.150.2 → 0.151.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/README.md +1 -1
- package/dist/cli.js +123 -71
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -243,7 +243,7 @@ now on disk. `crew daemon restart` forces this immediately, for a manual
|
|
|
243
243
|
## Commands
|
|
244
244
|
|
|
245
245
|
```
|
|
246
|
-
crew poll [route]
|
|
246
|
+
crew poll [route] [--verbose] decide a cycle and report it; writes nothing; --verbose adds counts and timestamps
|
|
247
247
|
crew run [route] [--role R] run the winning role's session, then release
|
|
248
248
|
crew daemon [route] run the persistent supervisor loop in the foreground (every enabled route when none is named)
|
|
249
249
|
crew daemon start|stop|status control the installed `run` service directly
|
package/dist/cli.js
CHANGED
|
@@ -1285,7 +1285,7 @@ var Emitter = class _Emitter {
|
|
|
1285
1285
|
`);
|
|
1286
1286
|
} catch {
|
|
1287
1287
|
}
|
|
1288
|
-
if (!e.routine || this.opts.verbose) {
|
|
1288
|
+
if (!e.routine || this.opts.verbose || !this.opts.plain) {
|
|
1289
1289
|
try {
|
|
1290
1290
|
(this.opts.console ?? ((l) => process.stderr.write(`${l}
|
|
1291
1291
|
`)))(this.opts.plain ? renderPlain(e) : line);
|
|
@@ -1294,6 +1294,28 @@ var Emitter = class _Emitter {
|
|
|
1294
1294
|
}
|
|
1295
1295
|
return e;
|
|
1296
1296
|
}
|
|
1297
|
+
/**
|
|
1298
|
+
* A line for a person at the terminal that is not an event (CREW-3285): the
|
|
1299
|
+
* closing count of a roll-up. Console only, never the event stream or log,
|
|
1300
|
+
* and hidden from a non-terminal console, which has the events it summarizes.
|
|
1301
|
+
*/
|
|
1302
|
+
echo(message) {
|
|
1303
|
+
if (!this.opts.plain) return;
|
|
1304
|
+
try {
|
|
1305
|
+
(this.opts.console ?? ((l) => process.stderr.write(`${l}
|
|
1306
|
+
`)))(message);
|
|
1307
|
+
} catch {
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Show lines already emitted as routine that a failure now makes relevant
|
|
1312
|
+
* (CREW-3285: a failed hook's output). Console only; nothing when the
|
|
1313
|
+
* console already showed them (`--verbose`) or is not a terminal.
|
|
1314
|
+
*/
|
|
1315
|
+
replay(lines2) {
|
|
1316
|
+
if (!this.opts.plain || this.opts.verbose) return;
|
|
1317
|
+
for (const l of lines2) this.echo(l);
|
|
1318
|
+
}
|
|
1297
1319
|
/** Routine progress: logged, but shown on the console only under `--verbose`. */
|
|
1298
1320
|
note(message, extra = {}) {
|
|
1299
1321
|
return this.emit(message, { ...extra, routine: true });
|
|
@@ -14150,7 +14172,7 @@ async function finishRun(id, obs, emit, startedAt, end, agentLogKey, hintMoved)
|
|
|
14150
14172
|
} catch {
|
|
14151
14173
|
}
|
|
14152
14174
|
const ms3 = Date.now() - Date.parse(startedAt);
|
|
14153
|
-
emit.
|
|
14175
|
+
emit.note(end.interrupted ? "agent run interrupted" : `agent run finished (${pending ? "hand-off pending" : `exit ${end.code ?? "unknown"}`})`, {
|
|
14154
14176
|
data: {
|
|
14155
14177
|
ms: ms3,
|
|
14156
14178
|
code: end.code,
|
|
@@ -18917,7 +18939,7 @@ async function decideCycle(o) {
|
|
|
18917
18939
|
]);
|
|
18918
18940
|
const directionEvents = (await Promise.all([...DIRECTION_EVENT_TYPES, ...STATUS_EVENT_TYPES, "pushed"].map((t) => tracker.events(t)))).flat();
|
|
18919
18941
|
const statusChanges = await tracker.statusChanges();
|
|
18920
|
-
emit.
|
|
18942
|
+
emit.note(`${tickets.length} open ticket(s), ${comments.length} comment(s)`, {
|
|
18921
18943
|
data: { tickets: tickets.length, comments: comments.length }
|
|
18922
18944
|
});
|
|
18923
18945
|
const epicColumn = tracker.contract.columns.epic;
|
|
@@ -18962,14 +18984,14 @@ async function decideCycle(o) {
|
|
|
18962
18984
|
const stalled = planStalled(tickets, comments, ships, tracker.contract, holds2, Date.now(), workModes, stalledEvents);
|
|
18963
18985
|
const skipped = skippedByMode(tickets, workModes);
|
|
18964
18986
|
if (skipped.manual || skipped.hybrid) {
|
|
18965
|
-
emit.
|
|
18987
|
+
emit.note(`sweeps skipped ${skipped.manual} manual/project-less and ${skipped.hybrid} unassigned hybrid ticket(s)`, {
|
|
18966
18988
|
data: { sweepSkipped: skipped }
|
|
18967
18989
|
});
|
|
18968
18990
|
}
|
|
18969
18991
|
const blockedIssues = tickets.filter((t) => blocked.has(t.id)).map((t) => t.issue_id);
|
|
18970
|
-
emit.
|
|
18992
|
+
emit.note(`${blockedIssues.length} ticket(s) parked as blocked`, { data: { blocked: blockedIssues } });
|
|
18971
18993
|
const qaHeld = tickets.filter((t) => t.status === tracker.contract.statuses.verifying).map((t) => t.issue_id);
|
|
18972
|
-
emit.
|
|
18994
|
+
emit.note(`${qaHeld.length} ticket(s) held in QA`, { data: { qaHeld } });
|
|
18973
18995
|
const stranded = strandedNeedsInfo(tickets, blocked, holds2);
|
|
18974
18996
|
for (const t of stranded) {
|
|
18975
18997
|
emit.emit("needs_info with all blockers resolved \u2014 the operator's call, not the crew's", {
|
|
@@ -18982,7 +19004,7 @@ async function decideCycle(o) {
|
|
|
18982
19004
|
};
|
|
18983
19005
|
for (const r of rollUpParents(tickets, void 0, coordinating)) {
|
|
18984
19006
|
if (r.complete) {
|
|
18985
|
-
emit.
|
|
19007
|
+
emit.note(`every child is done \u2014 this coordinating ticket is too`, { ticket: r.parent.issue_id });
|
|
18986
19008
|
}
|
|
18987
19009
|
}
|
|
18988
19010
|
const unroutableTickets = filingErrors(tickets, {
|
|
@@ -19002,9 +19024,10 @@ async function decideCycle(o) {
|
|
|
19002
19024
|
{ ticket: t.issue_id }
|
|
19003
19025
|
);
|
|
19004
19026
|
}
|
|
19005
|
-
for (const t of gained) emit.
|
|
19027
|
+
for (const t of gained) emit.note("now has a repository \u2014 no longer unroutable", { ticket: t.issue_id });
|
|
19006
19028
|
if (unroutableTickets.length) {
|
|
19007
|
-
emit.emit(
|
|
19029
|
+
(added.length ? emit.emit : emit.note).call(
|
|
19030
|
+
emit,
|
|
19008
19031
|
`${unroutableTickets.length} open ticket(s) have no repository and are not routable (${added.length} new since last cycle)`,
|
|
19009
19032
|
{ step: "sweep", data: { unroutable: unroutableTickets.map((t) => t.issue_id), newUnroutable: added.map((a) => a.ticket.issue_id) } }
|
|
19010
19033
|
);
|
|
@@ -19088,7 +19111,7 @@ async function decideCycle(o) {
|
|
|
19088
19111
|
};
|
|
19089
19112
|
const advanced = state.advanceWatermark([...comments, ...tickets], routeSlug(route2.route));
|
|
19090
19113
|
if (advanced !== watermark) {
|
|
19091
|
-
emit.
|
|
19114
|
+
emit.note(`watermark ${watermark.slice(0, 19)} -> ${advanced.slice(0, 19)}`, {
|
|
19092
19115
|
step: "poll",
|
|
19093
19116
|
data: { from: watermark, to: advanced }
|
|
19094
19117
|
});
|
|
@@ -19192,7 +19215,7 @@ function writeDigest(o, d, role, stateDir, runId, own) {
|
|
|
19192
19215
|
${body}` : body;
|
|
19193
19216
|
const path = digestPath(stateDir, routeSlug(o.route.route), role, runId);
|
|
19194
19217
|
writeFileSync31(path, text2);
|
|
19195
|
-
o.emit.
|
|
19218
|
+
o.emit.note(`queue digest written for ${role} (${Buffer.byteLength(text2)} bytes)`, {
|
|
19196
19219
|
data: { role, bytes: Buffer.byteLength(text2) }
|
|
19197
19220
|
});
|
|
19198
19221
|
return true;
|
|
@@ -20792,6 +20815,56 @@ ${h.prFailure.tail}
|
|
|
20792
20815
|
}
|
|
20793
20816
|
}
|
|
20794
20817
|
|
|
20818
|
+
// src/cli-output.ts
|
|
20819
|
+
function summarizeOutcomes(outcomes, describe2, isRoutine, noun, verbose) {
|
|
20820
|
+
if (verbose) return outcomes.map(describe2);
|
|
20821
|
+
const lines2 = outcomes.filter((o) => !isRoutine(o)).map(describe2);
|
|
20822
|
+
const routine = outcomes.length - lines2.length;
|
|
20823
|
+
if (routine > 0) lines2.push(`${routine} ${noun}${routine === 1 ? "" : "s"} already in sync`);
|
|
20824
|
+
return lines2;
|
|
20825
|
+
}
|
|
20826
|
+
function withFix(message, fix) {
|
|
20827
|
+
return `${message.replace(/[.\s]+$/, "")} \u2014 try: ${fix}`;
|
|
20828
|
+
}
|
|
20829
|
+
function summarizeJobs(results, o) {
|
|
20830
|
+
const state = o.uninstall ? "not installed" : "installed";
|
|
20831
|
+
const mark3 = o.dryRun ? " (dry run, not applied)" : "";
|
|
20832
|
+
const line = (r) => {
|
|
20833
|
+
if (o.dryRun) return `would ${o.uninstall ? "remove" : "install"} ${r.job} via ${r.mechanism} for ${o.host}${mark3}`;
|
|
20834
|
+
if (r.action === "unchanged") return `${r.job} already ${state} (${r.mechanism})`;
|
|
20835
|
+
return `${r.action} ${r.job} via ${r.mechanism} for ${o.host}`;
|
|
20836
|
+
};
|
|
20837
|
+
if (o.dryRun || o.verbose) return results.map(line);
|
|
20838
|
+
const lines2 = results.filter((r) => r.action !== "unchanged").map(line);
|
|
20839
|
+
const same2 = results.filter((r) => r.action === "unchanged");
|
|
20840
|
+
if (same2.length > 0) {
|
|
20841
|
+
const names = same2.map((r) => r.job).join(", ");
|
|
20842
|
+
lines2.push(same2.length === results.length ? `all ${same2.length} jobs already ${state} (${names})` : `${same2.length} job${same2.length === 1 ? "" : "s"} already ${state} (${names})`);
|
|
20843
|
+
}
|
|
20844
|
+
return lines2;
|
|
20845
|
+
}
|
|
20846
|
+
function describeRunOutcome(o) {
|
|
20847
|
+
const who2 = `${o.role}${o.ticket ? ` on ${o.ticket}` : ""}`;
|
|
20848
|
+
const status2 = `crew status ${o.route}`;
|
|
20849
|
+
if (o.run.killed) return withFix(`${who2}: run stopped at its ${o.run.killed.limitMinutes} min limit`, `\`${status2}\``);
|
|
20850
|
+
if (o.run.code !== 0) return withFix(`${who2}: run failed (exit ${o.run.code})`, `\`${status2}\` and the run's stream under the state directory`);
|
|
20851
|
+
if (o.run.handoffPending) return `${who2}: finished; the hand-off write is pending and replays next cycle`;
|
|
20852
|
+
const h = o.handoff;
|
|
20853
|
+
if (!h) return `${who2}: finished`;
|
|
20854
|
+
switch (h.kind) {
|
|
20855
|
+
case "pushed":
|
|
20856
|
+
return `${who2}: handed off`;
|
|
20857
|
+
case "bounced":
|
|
20858
|
+
return `${who2}: hand-off bounced, set back to in_progress`;
|
|
20859
|
+
case "unverified":
|
|
20860
|
+
return `${who2}: parked, ${h.why ?? "hand-off not verified"}`;
|
|
20861
|
+
case "failed":
|
|
20862
|
+
return withFix(`${who2}: hand-off failed, ${h.why ?? "unknown reason"}`, `\`${status2}\``);
|
|
20863
|
+
default:
|
|
20864
|
+
return `${who2}: finished without a hand-off`;
|
|
20865
|
+
}
|
|
20866
|
+
}
|
|
20867
|
+
|
|
20795
20868
|
// src/release-run.ts
|
|
20796
20869
|
function emitReleaseSummary(emit, summaries) {
|
|
20797
20870
|
if (summaries.length <= 1) return;
|
|
@@ -20800,13 +20873,16 @@ function emitReleaseSummary(emit, summaries) {
|
|
|
20800
20873
|
const rows = summaries.filter((s) => s.route === route2);
|
|
20801
20874
|
const remit = emit.forRoute(route2);
|
|
20802
20875
|
remit.enter("release");
|
|
20803
|
-
remit.
|
|
20876
|
+
remit.note(`release summary \u2014 ${rows.length} repo(s):`);
|
|
20804
20877
|
for (const s of rows) {
|
|
20805
20878
|
const testLabel = s.tests === "pass" ? "tests passed" : s.tests === "fail" ? "tests FAILED" : "tests skipped";
|
|
20806
|
-
|
|
20807
|
-
|
|
20808
|
-
|
|
20879
|
+
const failed = s.outcome === "error" || s.tests === "fail";
|
|
20880
|
+
const line = ` ${s.scope}: ${testLabel}, ${s.outcome} \u2014 ${s.detail}`;
|
|
20881
|
+
if (s.outcome === "nothing" && !failed) remit.note(line);
|
|
20882
|
+
else remit.emit(line, { level: failed ? "warn" : "info" });
|
|
20809
20883
|
}
|
|
20884
|
+
const idle = rows.filter((s) => s.outcome === "nothing" && s.tests !== "fail").length;
|
|
20885
|
+
if (idle > 0) remit.echo(`${idle} of ${rows.length} repo(s) had nothing to release`);
|
|
20810
20886
|
}
|
|
20811
20887
|
}
|
|
20812
20888
|
function summarizeOutcome(o, scope, hadTestHook) {
|
|
@@ -20863,14 +20939,19 @@ async function rerunOnce(o, name, first) {
|
|
|
20863
20939
|
var hook = async (o, name, env = {}) => {
|
|
20864
20940
|
const script = o.repo.hooks[name];
|
|
20865
20941
|
if (!script) return null;
|
|
20942
|
+
const lines2 = [];
|
|
20866
20943
|
const result = await runScript(script, {
|
|
20867
20944
|
cwd: o.cwd,
|
|
20868
20945
|
env,
|
|
20869
20946
|
shell: resolveShell(o.repo.shell ?? o.shell),
|
|
20870
20947
|
onLine: (l) => {
|
|
20871
|
-
if (l.trim())
|
|
20948
|
+
if (l.trim()) {
|
|
20949
|
+
lines2.push(l.trim());
|
|
20950
|
+
o.emit.note(l.trim(), { data: { hook: name } });
|
|
20951
|
+
}
|
|
20872
20952
|
}
|
|
20873
20953
|
});
|
|
20954
|
+
if (result.code !== 0) o.emit.replay(lastLines(lines2.join("\n"), HOOK_FAILURE_TAIL_LINES).split("\n"));
|
|
20874
20955
|
if (o.attention && !o.dryRun) {
|
|
20875
20956
|
const key = `hook_missing:${o.scope ?? "release"}/${name}`;
|
|
20876
20957
|
if (result.code === 127) {
|
|
@@ -20893,7 +20974,7 @@ async function detectExternalClosures(o, candidates2) {
|
|
|
20893
20974
|
env,
|
|
20894
20975
|
shell: resolveShell(o.repo.shell ?? o.shell),
|
|
20895
20976
|
onLine: (l) => {
|
|
20896
|
-
if (l.trim()) o.emit.
|
|
20977
|
+
if (l.trim()) o.emit.note(l.trim(), { data: { hook: "merged" } });
|
|
20897
20978
|
}
|
|
20898
20979
|
})).code : void 0;
|
|
20899
20980
|
const out = [];
|
|
@@ -21035,7 +21116,7 @@ ${BRANCH_TIP_TRAILER}: ${tip}` : "";
|
|
|
21035
21116
|
|
|
21036
21117
|
Closes ${c.ticket.issue_id}.${trailer}`]);
|
|
21037
21118
|
const sha = headSha(o.cwd);
|
|
21038
|
-
o.emit.
|
|
21119
|
+
o.emit.note(`merged ${c.branch}`, { ticket: c.ticket.issue_id });
|
|
21039
21120
|
clearFailure();
|
|
21040
21121
|
return { applied: true, sha };
|
|
21041
21122
|
} catch (e) {
|
|
@@ -21216,7 +21297,7 @@ function openReleaseCheckout(o) {
|
|
|
21216
21297
|
const branch = `crew/release-${Date.now()}`;
|
|
21217
21298
|
const root = mkdtempSync3(join47(tmpdir6(), "crew-release-"));
|
|
21218
21299
|
const dir = join47(root, "checkout");
|
|
21219
|
-
o.emit.
|
|
21300
|
+
o.emit.note(`release checkout: ${dir}`, { step: "release" });
|
|
21220
21301
|
const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
|
|
21221
21302
|
try {
|
|
21222
21303
|
git(o.cwd, ["worktree", "add", "-q", "--no-track", "-b", branch, dir, `${remote}/${base}`]);
|
|
@@ -21369,7 +21450,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
|
|
|
21369
21450
|
if (remoteOf(o.cwd)) {
|
|
21370
21451
|
const releaseBranch = `crew/release-${Date.now()}`;
|
|
21371
21452
|
git(o.cwd, ["checkout", "-q", "--no-track", "-b", releaseBranch, remoteRef]);
|
|
21372
|
-
o.emit.
|
|
21453
|
+
o.emit.note("release checkout: the release sandbox clone", { step: "release" });
|
|
21373
21454
|
return mergeAndRelease(o, decision, fresh, releaseBranch);
|
|
21374
21455
|
}
|
|
21375
21456
|
const primary = checkGuards(o.cwd, base);
|
|
@@ -21611,7 +21692,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21611
21692
|
decision
|
|
21612
21693
|
};
|
|
21613
21694
|
}
|
|
21614
|
-
o.emit.
|
|
21695
|
+
o.emit.note("nothing to release");
|
|
21615
21696
|
return { merged, conflicts, unbuildable, deployed: false, stopped: "nothing to release", decision };
|
|
21616
21697
|
}
|
|
21617
21698
|
const waiting = decision.merges.some((c) => c.skipReason === "already-merged" && c.mergedSha);
|
|
@@ -21657,7 +21738,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21657
21738
|
else {
|
|
21658
21739
|
const r = await hook(o, "setup");
|
|
21659
21740
|
if (r && r.code !== 0) {
|
|
21660
|
-
o.emit.error(`setup FAILED (exit ${r.code}) \u2014 not testing or deploying; the target stays on the previous release`);
|
|
21741
|
+
o.emit.error(withFix(`setup FAILED (exit ${r.code}) \u2014 not testing or deploying; the target stays on the previous release`, "`crew doctor`"));
|
|
21661
21742
|
return { merged, conflicts, unbuildable, deployed: false, stopped: "setup failed", decision, hookFailure: hookFailure(o, "setup", r.output) };
|
|
21662
21743
|
}
|
|
21663
21744
|
}
|
|
@@ -21673,7 +21754,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21673
21754
|
else if (out) return out;
|
|
21674
21755
|
}
|
|
21675
21756
|
if (r && r.code !== 0) {
|
|
21676
|
-
o.emit.error(
|
|
21757
|
+
o.emit.error(withFix("test gate FAILED \u2014 not deploying; the target stays on the previous release", "`crew doctor`, then fix the failing tests on the branch"));
|
|
21677
21758
|
const sha = headSha(o.cwd);
|
|
21678
21759
|
const count = o.state?.noteTestGateFailed?.(sha) ?? 1;
|
|
21679
21760
|
const gateRed = count >= GATE_RED_AFTER && !o.state?.testGateReported?.(sha) ? { sha, count, hook: hookLabel(o.repo, "test"), tail: lastLines(r.output, 15) } : void 0;
|
|
@@ -21731,7 +21812,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21731
21812
|
else if (out) return out;
|
|
21732
21813
|
}
|
|
21733
21814
|
if (r && r.code !== 0) {
|
|
21734
|
-
o.emit.error("build failed \u2014 not deploying");
|
|
21815
|
+
o.emit.error(withFix("build failed \u2014 not deploying", "`crew doctor`, then run the repo's build hook in the release checkout"));
|
|
21735
21816
|
if (version && !o.dryRun && headSha(o.cwd) !== preBump) {
|
|
21736
21817
|
git(o.cwd, ["reset", "--hard", preBump]);
|
|
21737
21818
|
o.emit.warn(`dropped the unreleased version commit for ${version} (reset ${o.repo.branch.base} to ${preBump.slice(0, 8)}) so a retry starts clean`);
|
|
@@ -21756,7 +21837,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21756
21837
|
} else {
|
|
21757
21838
|
try {
|
|
21758
21839
|
pushBranch(o.cwd, o.repo.branch.remote, releaseBranch ?? o.repo.branch.base, o.repo.branch.base);
|
|
21759
|
-
o.emit.
|
|
21840
|
+
o.emit.note(`pushed ${o.repo.branch.base} to ${o.repo.branch.remote}`);
|
|
21760
21841
|
} catch (e) {
|
|
21761
21842
|
o.emit.error(
|
|
21762
21843
|
`failed to push ${o.repo.branch.base} to ${o.repo.branch.remote} \u2014 ${e.message}; not deploying`
|
|
@@ -21817,7 +21898,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21817
21898
|
else if (tagExists(o.cwd, tag)) o.emit.warn(`tag ${tag} already exists \u2014 not retagging`);
|
|
21818
21899
|
else {
|
|
21819
21900
|
createReleaseTag(o.cwd, tag, at, `Release ${tag}`);
|
|
21820
|
-
o.emit.
|
|
21901
|
+
o.emit.note(`tagged ${tag}`);
|
|
21821
21902
|
}
|
|
21822
21903
|
}
|
|
21823
21904
|
const tagIsCiTrigger = o.repo.release.mode === "ci_manual" || o.repo.release.mode === "ci_auto";
|
|
@@ -21827,7 +21908,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21827
21908
|
} else {
|
|
21828
21909
|
try {
|
|
21829
21910
|
pushTag(o.cwd, o.repo.branch.remote, tag);
|
|
21830
|
-
o.emit.
|
|
21911
|
+
o.emit.note(`pushed tag ${tag} to ${o.repo.branch.remote}`);
|
|
21831
21912
|
} catch (e) {
|
|
21832
21913
|
const msg = `failed to push tag ${tag} to ${o.repo.branch.remote} \u2014 ${e.message}`;
|
|
21833
21914
|
if (tagIsCiTrigger) {
|
|
@@ -25798,37 +25879,6 @@ function routeAvatarFailures(stateDir, route2) {
|
|
|
25798
25879
|
// src/agents-sync-run.ts
|
|
25799
25880
|
import { existsSync as existsSync53, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync41 } from "fs";
|
|
25800
25881
|
import { dirname as dirname31 } from "path";
|
|
25801
|
-
|
|
25802
|
-
// src/cli-output.ts
|
|
25803
|
-
function summarizeOutcomes(outcomes, describe2, isRoutine, noun, verbose) {
|
|
25804
|
-
if (verbose) return outcomes.map(describe2);
|
|
25805
|
-
const lines2 = outcomes.filter((o) => !isRoutine(o)).map(describe2);
|
|
25806
|
-
const routine = outcomes.length - lines2.length;
|
|
25807
|
-
if (routine > 0) lines2.push(`${routine} ${noun}${routine === 1 ? "" : "s"} already in sync`);
|
|
25808
|
-
return lines2;
|
|
25809
|
-
}
|
|
25810
|
-
function withFix(message, fix) {
|
|
25811
|
-
return `${message.replace(/[.\s]+$/, "")} \u2014 try: ${fix}`;
|
|
25812
|
-
}
|
|
25813
|
-
function summarizeJobs(results, o) {
|
|
25814
|
-
const state = o.uninstall ? "not installed" : "installed";
|
|
25815
|
-
const mark3 = o.dryRun ? " (dry run, not applied)" : "";
|
|
25816
|
-
const line = (r) => {
|
|
25817
|
-
if (o.dryRun) return `would ${o.uninstall ? "remove" : "install"} ${r.job} via ${r.mechanism} for ${o.host}${mark3}`;
|
|
25818
|
-
if (r.action === "unchanged") return `${r.job} already ${state} (${r.mechanism})`;
|
|
25819
|
-
return `${r.action} ${r.job} via ${r.mechanism} for ${o.host}`;
|
|
25820
|
-
};
|
|
25821
|
-
if (o.dryRun || o.verbose) return results.map(line);
|
|
25822
|
-
const lines2 = results.filter((r) => r.action !== "unchanged").map(line);
|
|
25823
|
-
const same2 = results.filter((r) => r.action === "unchanged");
|
|
25824
|
-
if (same2.length > 0) {
|
|
25825
|
-
const names = same2.map((r) => r.job).join(", ");
|
|
25826
|
-
lines2.push(same2.length === results.length ? `all ${same2.length} jobs already ${state} (${names})` : `${same2.length} job${same2.length === 1 ? "" : "s"} already ${state} (${names})`);
|
|
25827
|
-
}
|
|
25828
|
-
return lines2;
|
|
25829
|
-
}
|
|
25830
|
-
|
|
25831
|
-
// src/agents-sync-run.ts
|
|
25832
25882
|
async function runAgentsSync(target, o) {
|
|
25833
25883
|
const dryRun = o.dryRun ?? false;
|
|
25834
25884
|
const force = o.force ?? false;
|
|
@@ -27246,7 +27296,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
27246
27296
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
27247
27297
|
import { join as join58 } from "path";
|
|
27248
27298
|
function builtVersion() {
|
|
27249
|
-
return true ? "0.
|
|
27299
|
+
return true ? "0.151.0" : null;
|
|
27250
27300
|
}
|
|
27251
27301
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
27252
27302
|
function newestMtime(path) {
|
|
@@ -29437,7 +29487,7 @@ No project here has what a route needs. Install the "${template.name}" library t
|
|
|
29437
29487
|
function usage(problem, requested = false) {
|
|
29438
29488
|
const text2 = `crew \u2014 a standing team of headless agents
|
|
29439
29489
|
|
|
29440
|
-
crew poll [route]
|
|
29490
|
+
crew poll [route] [--verbose] decide a cycle and report it; writes nothing; --verbose adds counts and timestamps
|
|
29441
29491
|
crew run [route] [--role R] run the winning role's session
|
|
29442
29492
|
crew release [route] merge what QA verified, version it, ship it
|
|
29443
29493
|
crew merge [route] merge verified branches and stop
|
|
@@ -31482,7 +31532,7 @@ ${f.tail.trimEnd()}
|
|
|
31482
31532
|
} };
|
|
31483
31533
|
}
|
|
31484
31534
|
if (result.contended.length) {
|
|
31485
|
-
wemit.
|
|
31535
|
+
wemit.note(`claim contended for ${result.contended.join(", ")} \u2014 moved to the next candidate`, {
|
|
31486
31536
|
step: "select",
|
|
31487
31537
|
role: w.role
|
|
31488
31538
|
});
|
|
@@ -31524,7 +31574,7 @@ ${f.tail.trimEnd()}
|
|
|
31524
31574
|
fleetTicketRepo = target?.name;
|
|
31525
31575
|
try {
|
|
31526
31576
|
if (target && !skipsHostCheckout(cfg.ship) && ensureRepoCheckout(target.dir, target.remote, { scheme: cfg.ship.cloneScheme, host: target.forgeHost })) {
|
|
31527
|
-
wemit.
|
|
31577
|
+
wemit.note(`cloned ${target.name} into ${target.dir}`, { step: "select", role: w.role });
|
|
31528
31578
|
}
|
|
31529
31579
|
} catch (e) {
|
|
31530
31580
|
wemit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`);
|
|
@@ -31551,7 +31601,7 @@ ${f.tail.trimEnd()}
|
|
|
31551
31601
|
resolvedAgentId: await resolveAgentId(w.route, w.role, { userAgent: cfg.ship.userAgent })
|
|
31552
31602
|
});
|
|
31553
31603
|
wemit.enter("agent", w.role);
|
|
31554
|
-
wemit.
|
|
31604
|
+
wemit.note(`starting agent run for ${w.route.route}`);
|
|
31555
31605
|
const fleetMemberId = w.route.resolved?.seats[w.role];
|
|
31556
31606
|
if (fleetMemberId) {
|
|
31557
31607
|
try {
|
|
@@ -31568,8 +31618,9 @@ ${f.tail.trimEnd()}
|
|
|
31568
31618
|
try {
|
|
31569
31619
|
const runStart = (/* @__PURE__ */ new Date()).toISOString();
|
|
31570
31620
|
await markCrewAssistedAtLaunch(fleetTracker, w.route, w.role, fleetWorkingId ?? null, void 0, (m) => wemit.warn(m, { step: "agent" }));
|
|
31571
|
-
await spawnAgent(fleetPlan, wemit);
|
|
31572
|
-
await guardRunHandoff(w.route, cfg.ship, fleetTracker, w.role, fleetWorkingId, wemit, runStart);
|
|
31621
|
+
const fleetRun = await spawnAgent(fleetPlan, wemit);
|
|
31622
|
+
const fleetHandoff = await guardRunHandoff(w.route, cfg.ship, fleetTracker, w.role, fleetWorkingId, wemit, runStart);
|
|
31623
|
+
wemit.echo(describeRunOutcome({ role: w.role, route: w.route.route, ticket: fleetTicketHint, run: fleetRun, handoff: fleetHandoff }));
|
|
31573
31624
|
} finally {
|
|
31574
31625
|
dropLock();
|
|
31575
31626
|
await settleRunEnd({
|
|
@@ -31612,7 +31663,7 @@ ${f.tail.trimEnd()}
|
|
|
31612
31663
|
} else {
|
|
31613
31664
|
const seat = route2.resolved?.seats.qa ?? route2.resolved?.seats.dev;
|
|
31614
31665
|
const r = await applySweep(new Tracker(route2, cfg.ship), decision.sweep, seat ?? "", emit);
|
|
31615
|
-
emit.
|
|
31666
|
+
emit.note(
|
|
31616
31667
|
`swept ${r.parked} parked, ${r.restored} restored${r.failed ? `, ${r.failed} failed` : ""}${r.contended ? `, ${r.contended} contended` : ""}`,
|
|
31617
31668
|
{ step: "sweep", data: r }
|
|
31618
31669
|
);
|
|
@@ -31697,7 +31748,7 @@ ${f.tail.trimEnd()}
|
|
|
31697
31748
|
} };
|
|
31698
31749
|
}
|
|
31699
31750
|
if (result.contended.length) {
|
|
31700
|
-
emit.
|
|
31751
|
+
emit.note(`claim contended for ${result.contended.join(", ")} \u2014 moved to the next candidate`, {
|
|
31701
31752
|
step: "select",
|
|
31702
31753
|
role: current
|
|
31703
31754
|
});
|
|
@@ -31745,7 +31796,7 @@ ${f.tail.trimEnd()}
|
|
|
31745
31796
|
ticketRepo = target?.name;
|
|
31746
31797
|
try {
|
|
31747
31798
|
if (target && !skipsHostCheckout(cfg.ship) && ensureRepoCheckout(target.dir, target.remote, { scheme: cfg.ship.cloneScheme, host: target.forgeHost })) {
|
|
31748
|
-
emit.
|
|
31799
|
+
emit.note(`cloned ${target.name} into ${target.dir}`, { step: "select", role: current });
|
|
31749
31800
|
}
|
|
31750
31801
|
} catch (e) {
|
|
31751
31802
|
emit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`);
|
|
@@ -31794,7 +31845,7 @@ ${f.tail.trimEnd()}
|
|
|
31794
31845
|
}
|
|
31795
31846
|
const before = snapshot(await tracker2.openTickets());
|
|
31796
31847
|
emit.enter("agent", current);
|
|
31797
|
-
emit.
|
|
31848
|
+
emit.note("starting agent run");
|
|
31798
31849
|
const memberId = route2.resolved?.seats[current];
|
|
31799
31850
|
if (memberId) {
|
|
31800
31851
|
try {
|
|
@@ -31811,8 +31862,9 @@ ${f.tail.trimEnd()}
|
|
|
31811
31862
|
try {
|
|
31812
31863
|
const runStart = (/* @__PURE__ */ new Date()).toISOString();
|
|
31813
31864
|
await markCrewAssistedAtLaunch(tracker2, route2, current, workingId ?? null, void 0, (m) => emit.warn(m, { step: "agent" }));
|
|
31814
|
-
await spawnAgent(plan, emit);
|
|
31815
|
-
await guardRunHandoff(route2, cfg.ship, tracker2, current, workingId, emit, runStart);
|
|
31865
|
+
const agentRun = await spawnAgent(plan, emit);
|
|
31866
|
+
const handoff = await guardRunHandoff(route2, cfg.ship, tracker2, current, workingId, emit, runStart);
|
|
31867
|
+
emit.echo(describeRunOutcome({ role: current, route: route2.route, ticket: ticketHint, run: agentRun, handoff }));
|
|
31816
31868
|
} finally {
|
|
31817
31869
|
dropLock();
|
|
31818
31870
|
await settleRunEnd({
|
package/package.json
CHANGED