@tablation/crew 0.150.1 → 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 +247 -86
- 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
|
@@ -71,12 +71,12 @@ function routePeriscopeProblems(o) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
if (o.tablePresent === false) {
|
|
74
|
+
if (o.tablePresent === false && !o.snapshotStale) {
|
|
75
75
|
out.push({
|
|
76
76
|
severity: "blocker",
|
|
77
77
|
kind: "periscopes_table_missing",
|
|
78
78
|
route: o.route,
|
|
79
|
-
message: `${o.route}: hostPeriscopes is on but this workspace has no Periscopes table \u2014
|
|
79
|
+
message: `${o.route}: hostPeriscopes is on but this workspace has no Periscopes table (confirmed against the workspace) \u2014 a workspace admin updates the Issues app to add it, then run \`crew connect\``
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
return out;
|
|
@@ -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 });
|
|
@@ -4418,6 +4440,7 @@ function parseResolved(raw, m, where) {
|
|
|
4418
4440
|
holds: holds2,
|
|
4419
4441
|
contract: raw.contract ?? void 0,
|
|
4420
4442
|
...typeof raw.releaseSeat === "string" && raw.releaseSeat ? { releaseSeat: raw.releaseSeat } : {},
|
|
4443
|
+
...typeof raw.connectedAt === "string" && raw.connectedAt ? { connectedAt: raw.connectedAt } : {},
|
|
4421
4444
|
...typeof raw.releaseAgentId === "string" && raw.releaseAgentId ? { releaseAgentId: raw.releaseAgentId } : {},
|
|
4422
4445
|
...typeof raw.role === "string" && raw.role ? { role: raw.role } : {},
|
|
4423
4446
|
...Array.isArray(raw.capabilityMisses) && raw.capabilityMisses.length > 0 ? { capabilityMisses: raw.capabilityMisses.filter((x) => typeof x === "string") } : {},
|
|
@@ -14149,7 +14172,7 @@ async function finishRun(id, obs, emit, startedAt, end, agentLogKey, hintMoved)
|
|
|
14149
14172
|
} catch {
|
|
14150
14173
|
}
|
|
14151
14174
|
const ms3 = Date.now() - Date.parse(startedAt);
|
|
14152
|
-
emit.
|
|
14175
|
+
emit.note(end.interrupted ? "agent run interrupted" : `agent run finished (${pending ? "hand-off pending" : `exit ${end.code ?? "unknown"}`})`, {
|
|
14153
14176
|
data: {
|
|
14154
14177
|
ms: ms3,
|
|
14155
14178
|
code: end.code,
|
|
@@ -17233,6 +17256,9 @@ var sound = (r) => r.hasRepos && r.problems.length === 0;
|
|
|
17233
17256
|
function planFix(f) {
|
|
17234
17257
|
const actions = [];
|
|
17235
17258
|
const notes = [];
|
|
17259
|
+
for (const r of f.routes) {
|
|
17260
|
+
if (r.snapshotStale) actions.push({ kind: "refresh-snapshot", route: r.route });
|
|
17261
|
+
}
|
|
17236
17262
|
for (const r of f.routes) {
|
|
17237
17263
|
if (!r.enabled && sound(r)) {
|
|
17238
17264
|
actions.push({ kind: "enable", route: r.route });
|
|
@@ -17253,14 +17279,18 @@ function planFix(f) {
|
|
|
17253
17279
|
async function gatherHealth(c, check) {
|
|
17254
17280
|
let problems;
|
|
17255
17281
|
let readiness = [];
|
|
17282
|
+
let snapshotStale = false;
|
|
17256
17283
|
try {
|
|
17257
17284
|
const r = await check();
|
|
17258
17285
|
if (Array.isArray(r)) problems = r;
|
|
17259
|
-
else
|
|
17286
|
+
else {
|
|
17287
|
+
({ problems, readiness } = r);
|
|
17288
|
+
snapshotStale = r.snapshotStale === true;
|
|
17289
|
+
}
|
|
17260
17290
|
} catch (e) {
|
|
17261
17291
|
problems = [`checks could not run: ${e instanceof Error ? e.message : String(e)}`];
|
|
17262
17292
|
}
|
|
17263
|
-
return { route: c.route, enabled: c.enabled, hasRepos: c.hasRepos, problems, readiness };
|
|
17293
|
+
return { route: c.route, enabled: c.enabled, hasRepos: c.hasRepos, problems, readiness, ...snapshotStale ? { snapshotStale } : {} };
|
|
17264
17294
|
}
|
|
17265
17295
|
function routesInScope(routes, named) {
|
|
17266
17296
|
return named ? routes.filter((r) => r.route === named) : routes;
|
|
@@ -18909,7 +18939,7 @@ async function decideCycle(o) {
|
|
|
18909
18939
|
]);
|
|
18910
18940
|
const directionEvents = (await Promise.all([...DIRECTION_EVENT_TYPES, ...STATUS_EVENT_TYPES, "pushed"].map((t) => tracker.events(t)))).flat();
|
|
18911
18941
|
const statusChanges = await tracker.statusChanges();
|
|
18912
|
-
emit.
|
|
18942
|
+
emit.note(`${tickets.length} open ticket(s), ${comments.length} comment(s)`, {
|
|
18913
18943
|
data: { tickets: tickets.length, comments: comments.length }
|
|
18914
18944
|
});
|
|
18915
18945
|
const epicColumn = tracker.contract.columns.epic;
|
|
@@ -18954,14 +18984,14 @@ async function decideCycle(o) {
|
|
|
18954
18984
|
const stalled = planStalled(tickets, comments, ships, tracker.contract, holds2, Date.now(), workModes, stalledEvents);
|
|
18955
18985
|
const skipped = skippedByMode(tickets, workModes);
|
|
18956
18986
|
if (skipped.manual || skipped.hybrid) {
|
|
18957
|
-
emit.
|
|
18987
|
+
emit.note(`sweeps skipped ${skipped.manual} manual/project-less and ${skipped.hybrid} unassigned hybrid ticket(s)`, {
|
|
18958
18988
|
data: { sweepSkipped: skipped }
|
|
18959
18989
|
});
|
|
18960
18990
|
}
|
|
18961
18991
|
const blockedIssues = tickets.filter((t) => blocked.has(t.id)).map((t) => t.issue_id);
|
|
18962
|
-
emit.
|
|
18992
|
+
emit.note(`${blockedIssues.length} ticket(s) parked as blocked`, { data: { blocked: blockedIssues } });
|
|
18963
18993
|
const qaHeld = tickets.filter((t) => t.status === tracker.contract.statuses.verifying).map((t) => t.issue_id);
|
|
18964
|
-
emit.
|
|
18994
|
+
emit.note(`${qaHeld.length} ticket(s) held in QA`, { data: { qaHeld } });
|
|
18965
18995
|
const stranded = strandedNeedsInfo(tickets, blocked, holds2);
|
|
18966
18996
|
for (const t of stranded) {
|
|
18967
18997
|
emit.emit("needs_info with all blockers resolved \u2014 the operator's call, not the crew's", {
|
|
@@ -18974,7 +19004,7 @@ async function decideCycle(o) {
|
|
|
18974
19004
|
};
|
|
18975
19005
|
for (const r of rollUpParents(tickets, void 0, coordinating)) {
|
|
18976
19006
|
if (r.complete) {
|
|
18977
|
-
emit.
|
|
19007
|
+
emit.note(`every child is done \u2014 this coordinating ticket is too`, { ticket: r.parent.issue_id });
|
|
18978
19008
|
}
|
|
18979
19009
|
}
|
|
18980
19010
|
const unroutableTickets = filingErrors(tickets, {
|
|
@@ -18994,9 +19024,10 @@ async function decideCycle(o) {
|
|
|
18994
19024
|
{ ticket: t.issue_id }
|
|
18995
19025
|
);
|
|
18996
19026
|
}
|
|
18997
|
-
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 });
|
|
18998
19028
|
if (unroutableTickets.length) {
|
|
18999
|
-
emit.emit(
|
|
19029
|
+
(added.length ? emit.emit : emit.note).call(
|
|
19030
|
+
emit,
|
|
19000
19031
|
`${unroutableTickets.length} open ticket(s) have no repository and are not routable (${added.length} new since last cycle)`,
|
|
19001
19032
|
{ step: "sweep", data: { unroutable: unroutableTickets.map((t) => t.issue_id), newUnroutable: added.map((a) => a.ticket.issue_id) } }
|
|
19002
19033
|
);
|
|
@@ -19080,7 +19111,7 @@ async function decideCycle(o) {
|
|
|
19080
19111
|
};
|
|
19081
19112
|
const advanced = state.advanceWatermark([...comments, ...tickets], routeSlug(route2.route));
|
|
19082
19113
|
if (advanced !== watermark) {
|
|
19083
|
-
emit.
|
|
19114
|
+
emit.note(`watermark ${watermark.slice(0, 19)} -> ${advanced.slice(0, 19)}`, {
|
|
19084
19115
|
step: "poll",
|
|
19085
19116
|
data: { from: watermark, to: advanced }
|
|
19086
19117
|
});
|
|
@@ -19184,7 +19215,7 @@ function writeDigest(o, d, role, stateDir, runId, own) {
|
|
|
19184
19215
|
${body}` : body;
|
|
19185
19216
|
const path = digestPath(stateDir, routeSlug(o.route.route), role, runId);
|
|
19186
19217
|
writeFileSync31(path, text2);
|
|
19187
|
-
o.emit.
|
|
19218
|
+
o.emit.note(`queue digest written for ${role} (${Buffer.byteLength(text2)} bytes)`, {
|
|
19188
19219
|
data: { role, bytes: Buffer.byteLength(text2) }
|
|
19189
19220
|
});
|
|
19190
19221
|
return true;
|
|
@@ -19676,8 +19707,8 @@ function failureComparison(b, previousNote) {
|
|
|
19676
19707
|
if (!before.length || !now.length) {
|
|
19677
19708
|
lines2.push("- Same failure both times? Unknown: the output of at least one run names no file.");
|
|
19678
19709
|
} else {
|
|
19679
|
-
const
|
|
19680
|
-
lines2.push(
|
|
19710
|
+
const same2 = now.filter((f) => before.includes(f));
|
|
19711
|
+
lines2.push(same2.length ? `- Same failure both times: yes, ${same2.map((f) => `\`${f}\``).join(", ")} fails in both.` : `- Same failure both times: **no**. First ${before.slice(0, 3).map((f) => `\`${f}\``).join(", ")}, now ${now.slice(0, 3).map((f) => `\`${f}\``).join(", ")}. Two different failures look like a flake, not a branch that keeps breaking.`);
|
|
19681
19712
|
}
|
|
19682
19713
|
lines2.push(b.inBranch == null ? "- Failing files among the branch's changes? Unknown: the failure names no file." : b.inBranch ? "- Failing files among the branch's changes: yes." : "- Failing files among the branch's changes: **no**, none of them. Not proof, but the branch probably did not break it.");
|
|
19683
19714
|
return lines2.join("\n");
|
|
@@ -20784,6 +20815,56 @@ ${h.prFailure.tail}
|
|
|
20784
20815
|
}
|
|
20785
20816
|
}
|
|
20786
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
|
+
|
|
20787
20868
|
// src/release-run.ts
|
|
20788
20869
|
function emitReleaseSummary(emit, summaries) {
|
|
20789
20870
|
if (summaries.length <= 1) return;
|
|
@@ -20792,13 +20873,16 @@ function emitReleaseSummary(emit, summaries) {
|
|
|
20792
20873
|
const rows = summaries.filter((s) => s.route === route2);
|
|
20793
20874
|
const remit = emit.forRoute(route2);
|
|
20794
20875
|
remit.enter("release");
|
|
20795
|
-
remit.
|
|
20876
|
+
remit.note(`release summary \u2014 ${rows.length} repo(s):`);
|
|
20796
20877
|
for (const s of rows) {
|
|
20797
20878
|
const testLabel = s.tests === "pass" ? "tests passed" : s.tests === "fail" ? "tests FAILED" : "tests skipped";
|
|
20798
|
-
|
|
20799
|
-
|
|
20800
|
-
|
|
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" });
|
|
20801
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`);
|
|
20802
20886
|
}
|
|
20803
20887
|
}
|
|
20804
20888
|
function summarizeOutcome(o, scope, hadTestHook) {
|
|
@@ -20855,14 +20939,19 @@ async function rerunOnce(o, name, first) {
|
|
|
20855
20939
|
var hook = async (o, name, env = {}) => {
|
|
20856
20940
|
const script = o.repo.hooks[name];
|
|
20857
20941
|
if (!script) return null;
|
|
20942
|
+
const lines2 = [];
|
|
20858
20943
|
const result = await runScript(script, {
|
|
20859
20944
|
cwd: o.cwd,
|
|
20860
20945
|
env,
|
|
20861
20946
|
shell: resolveShell(o.repo.shell ?? o.shell),
|
|
20862
20947
|
onLine: (l) => {
|
|
20863
|
-
if (l.trim())
|
|
20948
|
+
if (l.trim()) {
|
|
20949
|
+
lines2.push(l.trim());
|
|
20950
|
+
o.emit.note(l.trim(), { data: { hook: name } });
|
|
20951
|
+
}
|
|
20864
20952
|
}
|
|
20865
20953
|
});
|
|
20954
|
+
if (result.code !== 0) o.emit.replay(lastLines(lines2.join("\n"), HOOK_FAILURE_TAIL_LINES).split("\n"));
|
|
20866
20955
|
if (o.attention && !o.dryRun) {
|
|
20867
20956
|
const key = `hook_missing:${o.scope ?? "release"}/${name}`;
|
|
20868
20957
|
if (result.code === 127) {
|
|
@@ -20885,7 +20974,7 @@ async function detectExternalClosures(o, candidates2) {
|
|
|
20885
20974
|
env,
|
|
20886
20975
|
shell: resolveShell(o.repo.shell ?? o.shell),
|
|
20887
20976
|
onLine: (l) => {
|
|
20888
|
-
if (l.trim()) o.emit.
|
|
20977
|
+
if (l.trim()) o.emit.note(l.trim(), { data: { hook: "merged" } });
|
|
20889
20978
|
}
|
|
20890
20979
|
})).code : void 0;
|
|
20891
20980
|
const out = [];
|
|
@@ -21027,7 +21116,7 @@ ${BRANCH_TIP_TRAILER}: ${tip}` : "";
|
|
|
21027
21116
|
|
|
21028
21117
|
Closes ${c.ticket.issue_id}.${trailer}`]);
|
|
21029
21118
|
const sha = headSha(o.cwd);
|
|
21030
|
-
o.emit.
|
|
21119
|
+
o.emit.note(`merged ${c.branch}`, { ticket: c.ticket.issue_id });
|
|
21031
21120
|
clearFailure();
|
|
21032
21121
|
return { applied: true, sha };
|
|
21033
21122
|
} catch (e) {
|
|
@@ -21208,7 +21297,7 @@ function openReleaseCheckout(o) {
|
|
|
21208
21297
|
const branch = `crew/release-${Date.now()}`;
|
|
21209
21298
|
const root = mkdtempSync3(join47(tmpdir6(), "crew-release-"));
|
|
21210
21299
|
const dir = join47(root, "checkout");
|
|
21211
|
-
o.emit.
|
|
21300
|
+
o.emit.note(`release checkout: ${dir}`, { step: "release" });
|
|
21212
21301
|
const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
|
|
21213
21302
|
try {
|
|
21214
21303
|
git(o.cwd, ["worktree", "add", "-q", "--no-track", "-b", branch, dir, `${remote}/${base}`]);
|
|
@@ -21361,7 +21450,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
|
|
|
21361
21450
|
if (remoteOf(o.cwd)) {
|
|
21362
21451
|
const releaseBranch = `crew/release-${Date.now()}`;
|
|
21363
21452
|
git(o.cwd, ["checkout", "-q", "--no-track", "-b", releaseBranch, remoteRef]);
|
|
21364
|
-
o.emit.
|
|
21453
|
+
o.emit.note("release checkout: the release sandbox clone", { step: "release" });
|
|
21365
21454
|
return mergeAndRelease(o, decision, fresh, releaseBranch);
|
|
21366
21455
|
}
|
|
21367
21456
|
const primary = checkGuards(o.cwd, base);
|
|
@@ -21603,7 +21692,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21603
21692
|
decision
|
|
21604
21693
|
};
|
|
21605
21694
|
}
|
|
21606
|
-
o.emit.
|
|
21695
|
+
o.emit.note("nothing to release");
|
|
21607
21696
|
return { merged, conflicts, unbuildable, deployed: false, stopped: "nothing to release", decision };
|
|
21608
21697
|
}
|
|
21609
21698
|
const waiting = decision.merges.some((c) => c.skipReason === "already-merged" && c.mergedSha);
|
|
@@ -21649,7 +21738,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21649
21738
|
else {
|
|
21650
21739
|
const r = await hook(o, "setup");
|
|
21651
21740
|
if (r && r.code !== 0) {
|
|
21652
|
-
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`"));
|
|
21653
21742
|
return { merged, conflicts, unbuildable, deployed: false, stopped: "setup failed", decision, hookFailure: hookFailure(o, "setup", r.output) };
|
|
21654
21743
|
}
|
|
21655
21744
|
}
|
|
@@ -21665,7 +21754,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21665
21754
|
else if (out) return out;
|
|
21666
21755
|
}
|
|
21667
21756
|
if (r && r.code !== 0) {
|
|
21668
|
-
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"));
|
|
21669
21758
|
const sha = headSha(o.cwd);
|
|
21670
21759
|
const count = o.state?.noteTestGateFailed?.(sha) ?? 1;
|
|
21671
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;
|
|
@@ -21723,7 +21812,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21723
21812
|
else if (out) return out;
|
|
21724
21813
|
}
|
|
21725
21814
|
if (r && r.code !== 0) {
|
|
21726
|
-
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"));
|
|
21727
21816
|
if (version && !o.dryRun && headSha(o.cwd) !== preBump) {
|
|
21728
21817
|
git(o.cwd, ["reset", "--hard", preBump]);
|
|
21729
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`);
|
|
@@ -21748,7 +21837,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21748
21837
|
} else {
|
|
21749
21838
|
try {
|
|
21750
21839
|
pushBranch(o.cwd, o.repo.branch.remote, releaseBranch ?? o.repo.branch.base, o.repo.branch.base);
|
|
21751
|
-
o.emit.
|
|
21840
|
+
o.emit.note(`pushed ${o.repo.branch.base} to ${o.repo.branch.remote}`);
|
|
21752
21841
|
} catch (e) {
|
|
21753
21842
|
o.emit.error(
|
|
21754
21843
|
`failed to push ${o.repo.branch.base} to ${o.repo.branch.remote} \u2014 ${e.message}; not deploying`
|
|
@@ -21809,7 +21898,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21809
21898
|
else if (tagExists(o.cwd, tag)) o.emit.warn(`tag ${tag} already exists \u2014 not retagging`);
|
|
21810
21899
|
else {
|
|
21811
21900
|
createReleaseTag(o.cwd, tag, at, `Release ${tag}`);
|
|
21812
|
-
o.emit.
|
|
21901
|
+
o.emit.note(`tagged ${tag}`);
|
|
21813
21902
|
}
|
|
21814
21903
|
}
|
|
21815
21904
|
const tagIsCiTrigger = o.repo.release.mode === "ci_manual" || o.repo.release.mode === "ci_auto";
|
|
@@ -21819,7 +21908,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
21819
21908
|
} else {
|
|
21820
21909
|
try {
|
|
21821
21910
|
pushTag(o.cwd, o.repo.branch.remote, tag);
|
|
21822
|
-
o.emit.
|
|
21911
|
+
o.emit.note(`pushed tag ${tag} to ${o.repo.branch.remote}`);
|
|
21823
21912
|
} catch (e) {
|
|
21824
21913
|
const msg = `failed to push tag ${tag} to ${o.repo.branch.remote} \u2014 ${e.message}`;
|
|
21825
21914
|
if (tagIsCiTrigger) {
|
|
@@ -24340,11 +24429,11 @@ function readStartFailure(stateDir) {
|
|
|
24340
24429
|
function noteStartFailure(stateDir, reason, nowMs = Date.now()) {
|
|
24341
24430
|
const previous = readStartFailure(stateDir);
|
|
24342
24431
|
const nowIso = new Date(nowMs).toISOString();
|
|
24343
|
-
const
|
|
24432
|
+
const same2 = previous?.reason === reason;
|
|
24344
24433
|
const record = {
|
|
24345
24434
|
reason,
|
|
24346
|
-
count:
|
|
24347
|
-
firstAt:
|
|
24435
|
+
count: same2 ? previous.count + 1 : 1,
|
|
24436
|
+
firstAt: same2 ? previous.firstAt : nowIso,
|
|
24348
24437
|
lastAt: nowIso
|
|
24349
24438
|
};
|
|
24350
24439
|
mkdirSync37(stateDir, { recursive: true });
|
|
@@ -25790,37 +25879,6 @@ function routeAvatarFailures(stateDir, route2) {
|
|
|
25790
25879
|
// src/agents-sync-run.ts
|
|
25791
25880
|
import { existsSync as existsSync53, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync41 } from "fs";
|
|
25792
25881
|
import { dirname as dirname31 } from "path";
|
|
25793
|
-
|
|
25794
|
-
// src/cli-output.ts
|
|
25795
|
-
function summarizeOutcomes(outcomes, describe2, isRoutine, noun, verbose) {
|
|
25796
|
-
if (verbose) return outcomes.map(describe2);
|
|
25797
|
-
const lines2 = outcomes.filter((o) => !isRoutine(o)).map(describe2);
|
|
25798
|
-
const routine = outcomes.length - lines2.length;
|
|
25799
|
-
if (routine > 0) lines2.push(`${routine} ${noun}${routine === 1 ? "" : "s"} already in sync`);
|
|
25800
|
-
return lines2;
|
|
25801
|
-
}
|
|
25802
|
-
function withFix(message, fix) {
|
|
25803
|
-
return `${message.replace(/[.\s]+$/, "")} \u2014 try: ${fix}`;
|
|
25804
|
-
}
|
|
25805
|
-
function summarizeJobs(results, o) {
|
|
25806
|
-
const state = o.uninstall ? "not installed" : "installed";
|
|
25807
|
-
const mark3 = o.dryRun ? " (dry run, not applied)" : "";
|
|
25808
|
-
const line = (r) => {
|
|
25809
|
-
if (o.dryRun) return `would ${o.uninstall ? "remove" : "install"} ${r.job} via ${r.mechanism} for ${o.host}${mark3}`;
|
|
25810
|
-
if (r.action === "unchanged") return `${r.job} already ${state} (${r.mechanism})`;
|
|
25811
|
-
return `${r.action} ${r.job} via ${r.mechanism} for ${o.host}`;
|
|
25812
|
-
};
|
|
25813
|
-
if (o.dryRun || o.verbose) return results.map(line);
|
|
25814
|
-
const lines2 = results.filter((r) => r.action !== "unchanged").map(line);
|
|
25815
|
-
const same = results.filter((r) => r.action === "unchanged");
|
|
25816
|
-
if (same.length > 0) {
|
|
25817
|
-
const names = same.map((r) => r.job).join(", ");
|
|
25818
|
-
lines2.push(same.length === results.length ? `all ${same.length} jobs already ${state} (${names})` : `${same.length} job${same.length === 1 ? "" : "s"} already ${state} (${names})`);
|
|
25819
|
-
}
|
|
25820
|
-
return lines2;
|
|
25821
|
-
}
|
|
25822
|
-
|
|
25823
|
-
// src/agents-sync-run.ts
|
|
25824
25882
|
async function runAgentsSync(target, o) {
|
|
25825
25883
|
const dryRun = o.dryRun ?? false;
|
|
25826
25884
|
const force = o.force ?? false;
|
|
@@ -26580,6 +26638,59 @@ function planSampleTicket(i) {
|
|
|
26580
26638
|
};
|
|
26581
26639
|
}
|
|
26582
26640
|
|
|
26641
|
+
// src/snapshot-staleness.ts
|
|
26642
|
+
var SNAPSHOT_TABLES = [
|
|
26643
|
+
{ key: "periscopesModelId", name: "Periscopes" },
|
|
26644
|
+
{ key: "shipsModelId", name: "Ships" },
|
|
26645
|
+
{ key: "epicsModelId", name: "Epics" },
|
|
26646
|
+
{ key: "locksModelId", name: "Locks" },
|
|
26647
|
+
{ key: "reposModelId", name: "Repos" },
|
|
26648
|
+
{ key: "areaModelId", name: "Projects" }
|
|
26649
|
+
];
|
|
26650
|
+
var same = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
26651
|
+
function liveReleaseSeat(crew, shipRowId) {
|
|
26652
|
+
if (!shipRowId) return void 0;
|
|
26653
|
+
const idOf = (v) => typeof v === "string" ? v : v && typeof v === "object" ? v.id : void 0;
|
|
26654
|
+
return crew.find((r) => idOf(r.ship_id) === shipRowId && (r.name ?? "").toLowerCase().includes("release"))?.id;
|
|
26655
|
+
}
|
|
26656
|
+
function compareSnapshot(resolved, live2) {
|
|
26657
|
+
const added = [];
|
|
26658
|
+
const removed = [];
|
|
26659
|
+
for (const t of SNAPSHOT_TABLES) {
|
|
26660
|
+
const have = resolved[t.key];
|
|
26661
|
+
const now = live2.models.find((m) => same(m.name, t.name))?.id;
|
|
26662
|
+
if (now && !have) added.push(t.name);
|
|
26663
|
+
else if (have && now !== have) removed.push(t.name);
|
|
26664
|
+
}
|
|
26665
|
+
return {
|
|
26666
|
+
added,
|
|
26667
|
+
removed,
|
|
26668
|
+
releaseSeatNew: !resolved.releaseSeat && !!live2.releaseSeat,
|
|
26669
|
+
shipRowLacksMachineId: live2.shipRowHasMachineId === false
|
|
26670
|
+
};
|
|
26671
|
+
}
|
|
26672
|
+
var isStale = (d) => d.added.length > 0 || d.removed.length > 0 || d.releaseSeatNew || d.shipRowLacksMachineId;
|
|
26673
|
+
function snapshotAge(connectedAt, now = /* @__PURE__ */ new Date()) {
|
|
26674
|
+
if (!connectedAt) return "unknown (connected before connectedAt was recorded)";
|
|
26675
|
+
const ms3 = now.getTime() - Date.parse(connectedAt);
|
|
26676
|
+
if (!Number.isFinite(ms3) || ms3 < 0) return "unknown";
|
|
26677
|
+
const units = [["day", 864e5], ["hour", 36e5], ["minute", 6e4]];
|
|
26678
|
+
for (const [u, size] of units) {
|
|
26679
|
+
const n = Math.floor(ms3 / size);
|
|
26680
|
+
if (n >= 1) return `${n} ${u}${n === 1 ? "" : "s"}`;
|
|
26681
|
+
}
|
|
26682
|
+
return "just now";
|
|
26683
|
+
}
|
|
26684
|
+
function staleSnapshotMessage(route2, d) {
|
|
26685
|
+
if (!isStale(d)) return void 0;
|
|
26686
|
+
const parts = [];
|
|
26687
|
+
if (d.added.length) parts.push(`new in the workspace: ${d.added.join(", ")}`);
|
|
26688
|
+
if (d.removed.length) parts.push(`no longer in the workspace: ${d.removed.join(", ")}`);
|
|
26689
|
+
if (d.releaseSeatNew) parts.push("this ship's Release seat row exists");
|
|
26690
|
+
if (d.shipRowLacksMachineId) parts.push("the Ships row has no machine_id (it predates machine ids; connect writes it)");
|
|
26691
|
+
return `${route2}: the connect snapshot for this route is out of date (${parts.join("; ")}) \u2014 run \`crew connect ${route2}\` then \`crew reload\` (or \`crew doctor ${route2} --fix\`)`;
|
|
26692
|
+
}
|
|
26693
|
+
|
|
26583
26694
|
// src/doctor-report.ts
|
|
26584
26695
|
var DOCTOR_SECTIONS = [
|
|
26585
26696
|
{ id: "ship", title: "Ship" },
|
|
@@ -27185,7 +27296,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
27185
27296
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
27186
27297
|
import { join as join58 } from "path";
|
|
27187
27298
|
function builtVersion() {
|
|
27188
|
-
return true ? "0.
|
|
27299
|
+
return true ? "0.151.0" : null;
|
|
27189
27300
|
}
|
|
27190
27301
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
27191
27302
|
function newestMtime(path) {
|
|
@@ -29376,7 +29487,7 @@ No project here has what a route needs. Install the "${template.name}" library t
|
|
|
29376
29487
|
function usage(problem, requested = false) {
|
|
29377
29488
|
const text2 = `crew \u2014 a standing team of headless agents
|
|
29378
29489
|
|
|
29379
|
-
crew poll [route]
|
|
29490
|
+
crew poll [route] [--verbose] decide a cycle and report it; writes nothing; --verbose adds counts and timestamps
|
|
29380
29491
|
crew run [route] [--role R] run the winning role's session
|
|
29381
29492
|
crew release [route] merge what QA verified, version it, ship it
|
|
29382
29493
|
crew merge [route] merge verified branches and stop
|
|
@@ -30342,6 +30453,27 @@ if (command === "passenger-sync-daemon") {
|
|
|
30342
30453
|
}
|
|
30343
30454
|
return true;
|
|
30344
30455
|
}
|
|
30456
|
+
async function snapshotDiffFor(c) {
|
|
30457
|
+
const r = c.resolved;
|
|
30458
|
+
if (!r?.projectId || flag("offline")) return void 0;
|
|
30459
|
+
try {
|
|
30460
|
+
const models = await get(
|
|
30461
|
+
{ baseUrl: c.baseUrl, apiKey: resolveApiKey(c), userAgent: cfg.ship.userAgent },
|
|
30462
|
+
`/data-models?projectId=${r.projectId}`
|
|
30463
|
+
);
|
|
30464
|
+
const tracker = new Tracker(c, cfg.ship);
|
|
30465
|
+
const [ships, crew] = await Promise.all([tracker.shipRows(), tracker.crewRows()]);
|
|
30466
|
+
const matched = matchShipRows(ships, cfg.ship.name, doctorMachineId(cfg.ship.stateDir));
|
|
30467
|
+
const row = matched.rows.length === 1 ? matched.rows[0] : void 0;
|
|
30468
|
+
return compareSnapshot(r, {
|
|
30469
|
+
models,
|
|
30470
|
+
releaseSeat: liveReleaseSeat(crew, row?.id),
|
|
30471
|
+
shipRowHasMachineId: row && matched.hasColumn ? matched.by === "machine_id" : void 0
|
|
30472
|
+
});
|
|
30473
|
+
} catch {
|
|
30474
|
+
return void 0;
|
|
30475
|
+
}
|
|
30476
|
+
}
|
|
30345
30477
|
async function routeProblems(c) {
|
|
30346
30478
|
const host = hostPlatform();
|
|
30347
30479
|
const problems = [];
|
|
@@ -30378,7 +30510,8 @@ if (command === "passenger-sync-daemon") {
|
|
|
30378
30510
|
problems.push(`tracker unreachable: ${e instanceof Error ? e.message : String(e)}`);
|
|
30379
30511
|
}
|
|
30380
30512
|
if (await tracker.eventLogTracksStatus() === false) problems.push(EVENT_LOG_STATUS_UNTRACKED(tracker.contract.columns.status));
|
|
30381
|
-
|
|
30513
|
+
const diff = await snapshotDiffFor(c);
|
|
30514
|
+
return { problems, readiness, snapshotStale: !!diff && isStale(diff) };
|
|
30382
30515
|
}
|
|
30383
30516
|
async function doctorShipKind(route3, ship) {
|
|
30384
30517
|
try {
|
|
@@ -30407,7 +30540,19 @@ if (command === "passenger-sync-daemon") {
|
|
|
30407
30540
|
const enabledSound = new Set(routes.filter((r) => r.enabled && r.hasRepos && r.problems.length === 0).map((r) => r.route));
|
|
30408
30541
|
try {
|
|
30409
30542
|
for (const a of plan.actions) {
|
|
30410
|
-
if (a.kind === "
|
|
30543
|
+
if (a.kind === "refresh-snapshot") {
|
|
30544
|
+
if (prompter && !await prompter.confirm(`${a.route}: the connect snapshot is out of date \u2014 run \`crew connect ${a.route}\` and reload the daemon?`, true)) continue;
|
|
30545
|
+
const self = selfLaunch();
|
|
30546
|
+
const run4 = (args) => spawnSync14(self.command, [...self.args, ...args], { stdio: "inherit", cwd: process.cwd(), env: process.env });
|
|
30547
|
+
const conn = run4(["connect", a.route]);
|
|
30548
|
+
if (conn.status !== 0) {
|
|
30549
|
+
process.stdout.write(`fix: crew connect ${a.route} exited ${conn.status ?? "abnormally"} \u2014 snapshot not refreshed
|
|
30550
|
+
`);
|
|
30551
|
+
continue;
|
|
30552
|
+
}
|
|
30553
|
+
const rel = run4(["reload"]);
|
|
30554
|
+
changed2.push(`refreshed the connect snapshot for ${a.route} (\`crew connect\`)${rel.status === 0 ? " and reloaded the daemon" : "; `crew reload` failed \u2014 run it by hand"}`);
|
|
30555
|
+
} else if (a.kind === "enable") {
|
|
30411
30556
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
30412
30557
|
writeFileSync44(cfg.configFile, planEnable(readFileSync56(cfg.configFile, "utf8"), a.route));
|
|
30413
30558
|
enabledSound.add(a.route);
|
|
@@ -31387,7 +31532,7 @@ ${f.tail.trimEnd()}
|
|
|
31387
31532
|
} };
|
|
31388
31533
|
}
|
|
31389
31534
|
if (result.contended.length) {
|
|
31390
|
-
wemit.
|
|
31535
|
+
wemit.note(`claim contended for ${result.contended.join(", ")} \u2014 moved to the next candidate`, {
|
|
31391
31536
|
step: "select",
|
|
31392
31537
|
role: w.role
|
|
31393
31538
|
});
|
|
@@ -31429,7 +31574,7 @@ ${f.tail.trimEnd()}
|
|
|
31429
31574
|
fleetTicketRepo = target?.name;
|
|
31430
31575
|
try {
|
|
31431
31576
|
if (target && !skipsHostCheckout(cfg.ship) && ensureRepoCheckout(target.dir, target.remote, { scheme: cfg.ship.cloneScheme, host: target.forgeHost })) {
|
|
31432
|
-
wemit.
|
|
31577
|
+
wemit.note(`cloned ${target.name} into ${target.dir}`, { step: "select", role: w.role });
|
|
31433
31578
|
}
|
|
31434
31579
|
} catch (e) {
|
|
31435
31580
|
wemit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`);
|
|
@@ -31456,7 +31601,7 @@ ${f.tail.trimEnd()}
|
|
|
31456
31601
|
resolvedAgentId: await resolveAgentId(w.route, w.role, { userAgent: cfg.ship.userAgent })
|
|
31457
31602
|
});
|
|
31458
31603
|
wemit.enter("agent", w.role);
|
|
31459
|
-
wemit.
|
|
31604
|
+
wemit.note(`starting agent run for ${w.route.route}`);
|
|
31460
31605
|
const fleetMemberId = w.route.resolved?.seats[w.role];
|
|
31461
31606
|
if (fleetMemberId) {
|
|
31462
31607
|
try {
|
|
@@ -31473,8 +31618,9 @@ ${f.tail.trimEnd()}
|
|
|
31473
31618
|
try {
|
|
31474
31619
|
const runStart = (/* @__PURE__ */ new Date()).toISOString();
|
|
31475
31620
|
await markCrewAssistedAtLaunch(fleetTracker, w.route, w.role, fleetWorkingId ?? null, void 0, (m) => wemit.warn(m, { step: "agent" }));
|
|
31476
|
-
await spawnAgent(fleetPlan, wemit);
|
|
31477
|
-
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 }));
|
|
31478
31624
|
} finally {
|
|
31479
31625
|
dropLock();
|
|
31480
31626
|
await settleRunEnd({
|
|
@@ -31517,7 +31663,7 @@ ${f.tail.trimEnd()}
|
|
|
31517
31663
|
} else {
|
|
31518
31664
|
const seat = route2.resolved?.seats.qa ?? route2.resolved?.seats.dev;
|
|
31519
31665
|
const r = await applySweep(new Tracker(route2, cfg.ship), decision.sweep, seat ?? "", emit);
|
|
31520
|
-
emit.
|
|
31666
|
+
emit.note(
|
|
31521
31667
|
`swept ${r.parked} parked, ${r.restored} restored${r.failed ? `, ${r.failed} failed` : ""}${r.contended ? `, ${r.contended} contended` : ""}`,
|
|
31522
31668
|
{ step: "sweep", data: r }
|
|
31523
31669
|
);
|
|
@@ -31602,7 +31748,7 @@ ${f.tail.trimEnd()}
|
|
|
31602
31748
|
} };
|
|
31603
31749
|
}
|
|
31604
31750
|
if (result.contended.length) {
|
|
31605
|
-
emit.
|
|
31751
|
+
emit.note(`claim contended for ${result.contended.join(", ")} \u2014 moved to the next candidate`, {
|
|
31606
31752
|
step: "select",
|
|
31607
31753
|
role: current
|
|
31608
31754
|
});
|
|
@@ -31650,7 +31796,7 @@ ${f.tail.trimEnd()}
|
|
|
31650
31796
|
ticketRepo = target?.name;
|
|
31651
31797
|
try {
|
|
31652
31798
|
if (target && !skipsHostCheckout(cfg.ship) && ensureRepoCheckout(target.dir, target.remote, { scheme: cfg.ship.cloneScheme, host: target.forgeHost })) {
|
|
31653
|
-
emit.
|
|
31799
|
+
emit.note(`cloned ${target.name} into ${target.dir}`, { step: "select", role: current });
|
|
31654
31800
|
}
|
|
31655
31801
|
} catch (e) {
|
|
31656
31802
|
emit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`);
|
|
@@ -31699,7 +31845,7 @@ ${f.tail.trimEnd()}
|
|
|
31699
31845
|
}
|
|
31700
31846
|
const before = snapshot(await tracker2.openTickets());
|
|
31701
31847
|
emit.enter("agent", current);
|
|
31702
|
-
emit.
|
|
31848
|
+
emit.note("starting agent run");
|
|
31703
31849
|
const memberId = route2.resolved?.seats[current];
|
|
31704
31850
|
if (memberId) {
|
|
31705
31851
|
try {
|
|
@@ -31716,8 +31862,9 @@ ${f.tail.trimEnd()}
|
|
|
31716
31862
|
try {
|
|
31717
31863
|
const runStart = (/* @__PURE__ */ new Date()).toISOString();
|
|
31718
31864
|
await markCrewAssistedAtLaunch(tracker2, route2, current, workingId ?? null, void 0, (m) => emit.warn(m, { step: "agent" }));
|
|
31719
|
-
await spawnAgent(plan, emit);
|
|
31720
|
-
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 }));
|
|
31721
31868
|
} finally {
|
|
31722
31869
|
dropLock();
|
|
31723
31870
|
await settleRunEnd({
|
|
@@ -33157,6 +33304,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
33157
33304
|
seats: found.seats,
|
|
33158
33305
|
holds: found.holds.map((h) => ({ id: h.id, role: h.name })),
|
|
33159
33306
|
...found.releaseSeat ? { releaseSeat: found.releaseSeat } : {},
|
|
33307
|
+
connectedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
33160
33308
|
...found.role ?? previous?.role ? { role: found.role ?? previous?.role } : {},
|
|
33161
33309
|
...capabilityMisses.length > 0 ? { capabilityMisses } : {},
|
|
33162
33310
|
...operator ? { operator } : {},
|
|
@@ -35280,10 +35428,13 @@ ${where.join("\n")}`);
|
|
|
35280
35428
|
}
|
|
35281
35429
|
const previewProblem2 = await previewHostProblem(cfg);
|
|
35282
35430
|
if (previewProblem2) problems.push(previewHostFinding(previewProblem2));
|
|
35431
|
+
const jsonDiff = await snapshotDiffFor(route2);
|
|
35432
|
+
const jsonStale = jsonDiff ? staleSnapshotMessage(route2.route, jsonDiff) : void 0;
|
|
35433
|
+
if (jsonStale) problems.push({ severity: "attention", kind: "connect_snapshot_stale", route: route2.route, message: jsonStale, remedy: `crew connect ${route2.route} && crew reload` });
|
|
35283
35434
|
if (cfg.routes.some((x) => x.route === route2.route && x.enabled && x.hostPeriscopes)) {
|
|
35284
35435
|
const { settled } = await settleRepos(reposOf(route2), (t) => t.name, (t) => resolveOneRepo(route2, t));
|
|
35285
35436
|
const tablePresent = flag("offline") ? void 0 : (await new Tracker(route2, cfg.ship).periscopesStatus().catch(() => ({ present: true }))).present;
|
|
35286
|
-
problems.push(...routePeriscopeProblems({ route: route2.route, hosts: true, repos: settled.map((r) => ({ name: r.name, hasPreviewHook: !!r.config.hooks.preview })), tablePresent }));
|
|
35437
|
+
problems.push(...routePeriscopeProblems({ route: route2.route, hosts: true, repos: settled.map((r) => ({ name: r.name, hasPreviewHook: !!r.config.hooks.preview })), tablePresent, snapshotStale: !!jsonDiff && isStale(jsonDiff) }));
|
|
35287
35438
|
if (!flag("offline")) problems.push(...await duplicateLivePeriscopeProblems(route2, cfg.ship));
|
|
35288
35439
|
}
|
|
35289
35440
|
problems.push(...attentionProblems(openShipAttention(state), problems));
|
|
@@ -35495,12 +35646,20 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
35495
35646
|
`
|
|
35496
35647
|
);
|
|
35497
35648
|
const periscopes = await tracker.periscopesStatus();
|
|
35649
|
+
const snapDiff = await snapshotDiffFor(route2);
|
|
35650
|
+
const snapStale = !!snapDiff && isStale(snapDiff);
|
|
35651
|
+
const offlineNote = flag("offline") ? " (from the last connect; not checked against the workspace under --offline)" : "";
|
|
35652
|
+
if (flag("verbose")) R.line(`connect snapshot: taken ${snapshotAge(route2.resolved?.connectedAt)} ago${offlineNote}
|
|
35653
|
+
`);
|
|
35654
|
+
if (snapDiff && snapStale) R.line(`connect snapshot: WARN ${staleSnapshotMessage(route2.route, snapDiff)}
|
|
35655
|
+
`);
|
|
35498
35656
|
if (cfg.routes.some((x) => x.route === route2.route && x.enabled && x.hostPeriscopes)) {
|
|
35499
35657
|
const { settled } = await settleRepos(reposOf(route2), (t) => t.name, (t) => resolveOneRepo(route2, t));
|
|
35500
35658
|
for (const f of routePeriscopeProblems({
|
|
35501
35659
|
route: route2.route,
|
|
35502
35660
|
hosts: true,
|
|
35503
|
-
tablePresent: periscopes.present,
|
|
35661
|
+
tablePresent: flag("offline") ? void 0 : periscopes.present,
|
|
35662
|
+
snapshotStale: snapStale,
|
|
35504
35663
|
repos: settled.map((r) => ({ name: r.name, hasPreviewHook: !!r.config.hooks.preview }))
|
|
35505
35664
|
})) {
|
|
35506
35665
|
R.line(`periscopes: ${f.severity.toUpperCase()} ${f.message}
|
|
@@ -35514,12 +35673,14 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
35514
35673
|
}
|
|
35515
35674
|
}
|
|
35516
35675
|
R.line(
|
|
35517
|
-
|
|
35676
|
+
snapStale && snapDiff.added.includes("Periscopes") ? "periscopes: Periscopes table is in the workspace but not in the connect snapshot \u2014 see the connect snapshot line above\n" : !periscopes.present ? `periscopes: ${flag("offline") ? `no Periscopes table in the snapshot${offlineNote}` : "Periscopes table absent \u2014 this workspace cannot host periscopes"}
|
|
35677
|
+
` : periscopes.missing.length === 0 ? `periscopes: Periscopes table present (${periscopes.modelId})
|
|
35518
35678
|
` : `periscopes: Periscopes table present (${periscopes.modelId}) but missing ${periscopes.missing.join(", ")} \u2014 update the Issues template
|
|
35519
35679
|
`
|
|
35520
35680
|
);
|
|
35521
35681
|
R.line(
|
|
35522
|
-
route2.resolved?.releaseSeat ? "release seat: this ship has its own Release Crew row\n" : "release seat:
|
|
35682
|
+
route2.resolved?.releaseSeat ? "release seat: this ship has its own Release Crew row\n" : snapDiff?.releaseSeatNew ? "release seat: the workspace has this ship's Release row but the connect snapshot does not \u2014 see the connect snapshot line above\n" : flag("offline") ? `release seat: none in the snapshot${offlineNote}
|
|
35683
|
+
` : "release seat: none \u2014 release comments are credited to the dev seat; run `crew connect` once the Crew table has this ship's row\n"
|
|
35523
35684
|
);
|
|
35524
35685
|
const keyRole = route2.resolved?.role ?? await fetchKeyRole(route2, cfg.ship.userAgent);
|
|
35525
35686
|
const roleRoute = route2.resolved && keyRole ? { ...route2, resolved: { ...route2.resolved, role: keyRole } } : route2;
|
package/package.json
CHANGED