@tablation/crew 0.151.0 → 0.151.2

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.
Files changed (2) hide show
  1. package/dist/cli.js +139 -231
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -10324,14 +10324,14 @@ async function replayPendingHandoffs(i) {
10324
10324
  const t = await i.writer.ticket(rec.ticketRecordId);
10325
10325
  const st = i.contract.statuses;
10326
10326
  if (!seatId || t.status !== st.building || rec.patch.status !== st.handoff) {
10327
- i.log.emit(`${t.issue_id}: pending hand-off no longer applies (ticket is at ${t.status}) \u2014 dropped`, at);
10327
+ i.log.emit(`${displayKey(t)}: pending hand-off no longer applies (ticket is at ${t.status}) \u2014 dropped`, at);
10328
10328
  removePendingHandoff(i.stateDir, rec.ticketRecordId);
10329
10329
  continue;
10330
10330
  }
10331
10331
  const co = i.checkout(t);
10332
10332
  const v = co ? inspectHandoff(co.dir, co.cfg, t, rec.role) : null;
10333
10333
  if (!v || v.kind === "bounce") {
10334
- i.log.warn(`${t.issue_id}: pending hand-off dropped \u2014 ${v ? v.reason : "this ship has no checkout of the ticket's repo"}`, at);
10334
+ i.log.warn(`${displayKey(t)}: pending hand-off dropped \u2014 ${v ? v.reason : "this ship has no checkout of the ticket's repo"}`, at);
10335
10335
  removePendingHandoff(i.stateDir, rec.ticketRecordId);
10336
10336
  continue;
10337
10337
  }
@@ -10349,7 +10349,7 @@ async function replayPendingHandoffs(i) {
10349
10349
  await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), seatId, "pushed");
10350
10350
  await i.writer.updateTicket(t.id, rec.patch);
10351
10351
  removePendingHandoff(i.stateDir, rec.ticketRecordId);
10352
- i.log.emit(`${t.issue_id}: replayed a pending hand-off at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, at);
10352
+ i.log.emit(`${displayKey(t)}: replayed a pending hand-off at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, at);
10353
10353
  landed.push(t.id);
10354
10354
  } catch (e) {
10355
10355
  const attempts = rec.attempts + 1;
@@ -10469,9 +10469,9 @@ function holdWarnings(tickets, ships, contract, humanHolds, now = Date.now()) {
10469
10469
  if (t.assignee_id && humanHolds.has(t.assignee_id)) continue;
10470
10470
  const holder = ticketHolderShipId(t, contract);
10471
10471
  if (!holder) {
10472
- out.push(`${t.issue_id} (${t.status}) has no ${contract.columns.heldBy} \u2014 any ship may take it`);
10472
+ out.push(`${displayKey(t)} (${t.status}) has no ${contract.columns.heldBy} \u2014 any ship may take it`);
10473
10473
  } else if (!shipIsAlive(ships.find((s) => s.id === holder), now)) {
10474
- out.push(`${t.issue_id} (${t.status}) is held by ${shipName(ships, holder)}, which has not been seen for ${SHIP_DEAD_AFTER_CYCLES}+ cycles`);
10474
+ out.push(`${displayKey(t)} (${t.status}) is held by ${shipName(ships, holder)}, which has not been seen for ${SHIP_DEAD_AFTER_CYCLES}+ cycles`);
10475
10475
  }
10476
10476
  }
10477
10477
  return out;
@@ -10794,12 +10794,12 @@ async function enforceHandoff(i) {
10794
10794
  const log = { ticket: t.issue_id, step: "handoff" };
10795
10795
  const claimed = [st.verifying, st.verified, st.deployed].some((s) => s && t.status === s);
10796
10796
  if (t.status !== st.handoff && !claimed) {
10797
- i.log.emit(`${t.issue_id} is at ${t.status}, not handed off \u2014 nothing to check`, log);
10797
+ i.log.emit(`${displayKey(t)} is at ${t.status}, not handed off \u2014 nothing to check`, log);
10798
10798
  return { kind: "not-handed-off" };
10799
10799
  }
10800
10800
  const v = i.origin ? inspectRemoteHandoff(i.origin, i.cfg, t, i.role) : inspectHandoff(i.dir, i.cfg, t, i.role);
10801
10801
  if (v.kind === "unverified") {
10802
- i.log.warn(`${t.issue_id} is at ${t.status} but the push was not checked: ${v.why}`, log);
10802
+ i.log.warn(`${displayKey(t)} is at ${t.status} but the push was not checked: ${v.why}`, log);
10803
10803
  return { kind: "unverified", why: v.why };
10804
10804
  }
10805
10805
  if (v.kind === "pushed" && !claimed) {
@@ -10807,7 +10807,7 @@ async function enforceHandoff(i) {
10807
10807
  if (gap) {
10808
10808
  const heldNow = i.hold ? t[i.hold.column] : void 0;
10809
10809
  if (i.hold && heldNow && heldNow !== i.hold.shipId || await takenOverSince(i, t.id)) {
10810
- i.log.warn(`${t.issue_id} is held by another ship now \u2014 the acceptance check is stale, left alone`, log);
10810
+ i.log.warn(`${displayKey(t)} is held by another ship now \u2014 the acceptance check is stale, left alone`, log);
10811
10811
  return { kind: "unverified", why: "ticket is held by another ship" };
10812
10812
  }
10813
10813
  await i.writer.updateTicket(t.id, {
@@ -10819,30 +10819,30 @@ async function enforceHandoff(i) {
10819
10819
  await i.writer.postEvent(t.id, acceptanceBounceComment(gap.missing, i.shipName, gap.judged, gap.all), i.seatId, "bounced").catch(() => {
10820
10820
  i.log.warn("bounced, but the note failed to post", log);
10821
10821
  });
10822
- i.log.warn(`${t.issue_id} bounced back to ${i.contract.statuses.building}: hand-off comment lacks the acceptance checklist`, log);
10822
+ i.log.warn(`${displayKey(t)} bounced back to ${i.contract.statuses.building}: hand-off comment lacks the acceptance checklist`, log);
10823
10823
  return { kind: "bounced" };
10824
10824
  }
10825
10825
  }
10826
10826
  if (v.kind === "pushed") {
10827
10827
  await postPushed(i, t.id, v.sha, v.remote, v.branch, log);
10828
- i.log.emit(`${t.issue_id} pushed at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, log);
10828
+ i.log.emit(`${displayKey(t)} pushed at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, log);
10829
10829
  return { kind: "pushed", sha: v.sha };
10830
10830
  }
10831
10831
  if (claimed) {
10832
- i.log.warn(`${t.issue_id} is at ${t.status} but its branch is not on the remote at HEAD: ${v.reason}`, log);
10832
+ i.log.warn(`${displayKey(t)} is at ${t.status} but its branch is not on the remote at HEAD: ${v.reason}`, log);
10833
10833
  return { kind: "failed", why: v.reason };
10834
10834
  }
10835
10835
  const heldBy = i.hold ? t[i.hold.column] : void 0;
10836
10836
  if (i.hold && heldBy && heldBy !== i.hold.shipId) {
10837
- i.log.warn(`${t.issue_id} is held by another ship now \u2014 this run's hand-off check is stale, left alone`, log);
10837
+ i.log.warn(`${displayKey(t)} is held by another ship now \u2014 this run's hand-off check is stale, left alone`, log);
10838
10838
  return { kind: "unverified", why: "ticket is held by another ship" };
10839
10839
  }
10840
10840
  if (await takenOverSince(i, t.id)) {
10841
- i.log.warn(`${t.issue_id} was taken over by another ship during this run \u2014 left alone`, log);
10841
+ i.log.warn(`${displayKey(t)} was taken over by another ship during this run \u2014 left alone`, log);
10842
10842
  return { kind: "unverified", why: "ticket was taken over during this run" };
10843
10843
  }
10844
10844
  if (!v.local && !i.origin) {
10845
- i.log.warn(`${t.issue_id} has no local branch on this ship, so it is not this ship's hand-off to bounce: ${v.reason}`, log);
10845
+ i.log.warn(`${displayKey(t)} has no local branch on this ship, so it is not this ship's hand-off to bounce: ${v.reason}`, log);
10846
10846
  return { kind: "unverified", why: "no local branch on this ship" };
10847
10847
  }
10848
10848
  let pushError;
@@ -10859,14 +10859,14 @@ async function enforceHandoff(i) {
10859
10859
  i.seatId,
10860
10860
  "pushed_by_runner"
10861
10861
  ).catch(() => i.log.warn("pushed, but the note failed to post", log));
10862
- i.log.emit(`${t.issue_id}: pushed ${again.branch} to ${again.remote} on the seat's behalf at ${again.sha.slice(0, 7)} \u2014 handed on to QA`, log);
10862
+ i.log.emit(`${displayKey(t)}: pushed ${again.branch} to ${again.remote} on the seat's behalf at ${again.sha.slice(0, 7)} \u2014 handed on to QA`, log);
10863
10863
  return { kind: "pushed", sha: again.sha };
10864
10864
  }
10865
10865
  pushError = `the push succeeded but ${again.kind === "bounce" ? again.reason : again.why}`;
10866
10866
  } catch (e) {
10867
10867
  pushError = e.message;
10868
10868
  }
10869
- i.log.warn(`${t.issue_id}: the runner's own push failed: ${pushError}`, log);
10869
+ i.log.warn(`${displayKey(t)}: the runner's own push failed: ${pushError}`, log);
10870
10870
  }
10871
10871
  await i.writer.updateTicket(t.id, {
10872
10872
  status: i.contract.statuses.building,
@@ -10876,7 +10876,7 @@ async function enforceHandoff(i) {
10876
10876
  await i.writer.postEvent(t.id, bounceComment(v, i.shipName, pushError), i.seatId, "bounced").catch(() => {
10877
10877
  i.log.warn("bounced, but the note failed to post", log);
10878
10878
  });
10879
- i.log.warn(`${t.issue_id} bounced back to ${i.contract.statuses.building}: ${v.reason}`, log);
10879
+ i.log.warn(`${displayKey(t)} bounced back to ${i.contract.statuses.building}: ${v.reason}`, log);
10880
10880
  return { kind: "bounced" };
10881
10881
  } catch (e) {
10882
10882
  const why = describeGuardError(e, i.dir);
@@ -10907,7 +10907,7 @@ async function guardRunHandoff(route2, ship, tracker, role, workingId, log, sinc
10907
10907
  checkoutDir = target.dir;
10908
10908
  const lost = lostTicketReason(t, tracker.contract, (await tracker.claimAffinity())?.shipId);
10909
10909
  if (lost && role !== "qa") {
10910
- log.warn(`${t.issue_id}: run ended without a push \u2014 ${lost}`, { ticket: t.issue_id, step: "handoff" });
10910
+ log.warn(`${displayKey(t)}: run ended without a push \u2014 ${lost}`, { ticket: t.issue_id, step: "handoff" });
10911
10911
  return { kind: "unverified", why: lost };
10912
10912
  }
10913
10913
  if (role === "qa") {
@@ -10917,7 +10917,7 @@ async function guardRunHandoff(route2, ship, tracker, role, workingId, log, sinc
10917
10917
  const affinity = await tracker.claimAffinity();
10918
10918
  const origin = ship.runner === "sandbox" ? sandboxOriginFor(route2, target.name) : void 0;
10919
10919
  if (ship.runner === "sandbox" && !origin) {
10920
- log.warn(`${t.issue_id}: the push was not checked: this ship cannot place the remote of ${target.name}`, { ticket: t.issue_id, step: "handoff" });
10920
+ log.warn(`${displayKey(t)}: the push was not checked: this ship cannot place the remote of ${target.name}`, { ticket: t.issue_id, step: "handoff" });
10921
10921
  return null;
10922
10922
  }
10923
10923
  const outcome = replayed.includes(workingId) ? { kind: "pushed", sha: "" } : await enforceHandoff({
@@ -10943,7 +10943,7 @@ async function guardRunHandoff(route2, ship, tracker, role, workingId, log, sinc
10943
10943
  else {
10944
10944
  const branch = existingBranchForTicket(target.dir, cfg, t, role);
10945
10945
  if (branch && dropEmptyRunBranch(target.dir, cfg, branch)) {
10946
- log.emit(`${t.issue_id}: dropped ${branch} \u2014 the run made no commits beyond ${cfg.branch.base}`, { ticket: t.issue_id, step: "handoff" });
10946
+ log.emit(`${displayKey(t)}: dropped ${branch} \u2014 the run made no commits beyond ${cfg.branch.base}`, { ticket: t.issue_id, step: "handoff" });
10947
10947
  }
10948
10948
  }
10949
10949
  if (since2 && !origin) await guardRunStrays(route2, ship, tracker, role, workingId, since2, log);
@@ -10967,12 +10967,12 @@ async function retireRunWorktree(tracker, dir, cfg, t, role, seatId, shipName2,
10967
10967
  if (!branch) return;
10968
10968
  const o = await finishRunWorktree(dir, cfg, branch);
10969
10969
  const at = { ticket: t.issue_id, step: "handoff" };
10970
- if (o.kind === "removed") log.emit(`${t.issue_id}: removed the run's worktree ${o.path} \u2014 the branch is on ${cfg.branch.remote}`, at);
10970
+ if (o.kind === "removed") log.emit(`${displayKey(t)}: removed the run's worktree ${o.path} \u2014 the branch is on ${cfg.branch.remote}`, at);
10971
10971
  else if (o.kind === "kept-handoff") {
10972
- log.emit(`${t.issue_id}: kept worktree ${o.path} \u2014 this repo's handoff hook serves from it`, at);
10972
+ log.emit(`${displayKey(t)}: kept worktree ${o.path} \u2014 this repo's handoff hook serves from it`, at);
10973
10973
  await tracker.postEvent(t.id, `worktree kept on ship ${shipName2} at \`${o.path}\`: the repo's \`handoff\` hook serves from it. QA on another ship cuts its own from \`${cfg.branch.remote}/${branch}\` instead.`, seatId, "worktree_kept");
10974
- } else if (o.kind === "kept-dirty") log.warn(`${t.issue_id}: left worktree ${o.path} \u2014 it has uncommitted changes`, at);
10975
- else if (o.kind === "kept-unpushed") log.warn(`${t.issue_id}: left worktree ${o.path} \u2014 its branch has commits that are not on ${cfg.branch.remote}`, at);
10974
+ } else if (o.kind === "kept-dirty") log.warn(`${displayKey(t)}: left worktree ${o.path} \u2014 it has uncommitted changes`, at);
10975
+ else if (o.kind === "kept-unpushed") log.warn(`${displayKey(t)}: left worktree ${o.path} \u2014 its branch has commits that are not on ${cfg.branch.remote}`, at);
10976
10976
  } catch (e) {
10977
10977
  log.warn(`could not retire the run's worktree: ${e.message}`, { step: "handoff" });
10978
10978
  }
@@ -11029,21 +11029,21 @@ ${i.shipName ? `${i.shipName}'s ` : "A "}${i.role} run set it to \`${st.handoff}
11029
11029
  i.seatId,
11030
11030
  "bounced"
11031
11031
  ).catch(() => i.log.warn("bounced, but the note failed to post", at));
11032
- i.log.warn(`${t.issue_id} was handed off by a run that did not claim it, while held by another ship \u2014 bounced to ${st.building}`, at);
11032
+ i.log.warn(`${displayKey(t)} was handed off by a run that did not claim it, while held by another ship \u2014 bounced to ${st.building}`, at);
11033
11033
  continue;
11034
11034
  }
11035
11035
  const co = i.checkout(t);
11036
11036
  if (!co || !existingBranchForTicket(co.dir, co.cfg, t, i.role)) {
11037
- i.log.warn(`${t.issue_id} moved to ${st.handoff} during a run that did not claim it; no local branch to verify, left alone`, at);
11037
+ i.log.warn(`${displayKey(t)} moved to ${st.handoff} during a run that did not claim it; no local branch to verify, left alone`, at);
11038
11038
  continue;
11039
11039
  }
11040
11040
  const v = inspectHandoff(co.dir, co.cfg, t, i.role);
11041
- i.log.warn(`${t.issue_id} was handed off by a run that did not claim it`, at);
11041
+ i.log.warn(`${displayKey(t)} was handed off by a run that did not claim it`, at);
11042
11042
  if (v.kind === "pushed") {
11043
11043
  await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), i.seatId, "pushed");
11044
11044
  } else if (v.kind === "bounce") {
11045
11045
  if (v.origin && v.local && !isAncestor(co.dir, v.origin, v.local)) {
11046
- i.log.warn(`${t.issue_id}: \`${v.remote}/${v.branch}\` is at ${v.origin.slice(0, 7)}, not a tip this checkout built \u2014 left alone`, at);
11046
+ i.log.warn(`${displayKey(t)}: \`${v.remote}/${v.branch}\` is at ${v.origin.slice(0, 7)}, not a tip this checkout built \u2014 left alone`, at);
11047
11047
  continue;
11048
11048
  }
11049
11049
  await i.writer.updateTicket(t.id, { status: st.building, assignee_id: i.seatId });
@@ -17930,13 +17930,13 @@ function sweepDiagnostics(tickets, info) {
17930
17930
  const selfBlocked = [];
17931
17931
  for (const t of tickets) {
17932
17932
  for (const id of t.blocked_by ?? []) {
17933
- if (info[id] === void 0) dangling.push(`${t.issue_id} -> ${id}`);
17934
- if (id === t.id) selfBlocked.push(t.issue_id);
17933
+ if (info[id] === void 0) dangling.push(`${displayKey(t)} -> ${id}`);
17934
+ if (id === t.id) selfBlocked.push(displayKey(t));
17935
17935
  }
17936
17936
  }
17937
17937
  return { dangling, selfBlocked: [...new Set(selfBlocked)] };
17938
17938
  }
17939
- var describeBlockers = (t, info) => (t.blocked_by ?? []).map((id) => `${info[id]?.issue_id ?? "?"} (${info[id]?.status ?? "unknown"})`).join(", ");
17939
+ var describeBlockers = (t, info) => (t.blocked_by ?? []).map((id) => `${info[id]?.issue_tag ?? info[id]?.issue_id ?? "?"} (${info[id]?.status ?? "unknown"})`).join(", ");
17940
17940
  function planSweep(tickets, info, blocked, wm) {
17941
17941
  const steps = [];
17942
17942
  for (const t of withinWorkMode(tickets, wm)) {
@@ -18858,7 +18858,7 @@ function stalledComment(s, ships, now = Date.now()) {
18858
18858
  const who2 = s.holderShipId ? `Held by ${shipName(ships, s.holderShipId)}, which is not engaged on it. That ship has an attention item open; the ticket is otherwise left as it is, and resumes the moment the ship picks it back up.` : `No ship holds it and none is engaged on it. It is waiting for the next ship that polls its lane; its status and assignee are left as they are.`;
18859
18859
  return `${STALLED_MARKER}
18860
18860
 
18861
- **Stalled \u2014 no activity on \`${s.ticket.issue_id}\` for ${mins} minutes (\`${s.ticket.status}\`).**
18861
+ **Stalled \u2014 no activity on \`${displayKey(s.ticket)}\` for ${mins} minutes (\`${s.ticket.status}\`).**
18862
18862
 
18863
18863
  ${who2}`;
18864
18864
  }
@@ -18870,7 +18870,7 @@ async function applyStalled(writer, stalled, ships, memberId, myShipId, log, dry
18870
18870
  r.attention.push({
18871
18871
  kind: "stalled",
18872
18872
  key: stalledKey(s.ticket.issue_id),
18873
- message: `${s.ticket.issue_id} is held by this ship but has been quiet for ${Math.round((now - s.lastActivityAt) / 6e4)} minutes with nothing engaged on it`,
18873
+ message: `${displayKey(s.ticket)} is held by this ship but has been quiet for ${Math.round((now - s.lastActivityAt) / 6e4)} minutes with nothing engaged on it`,
18874
18874
  since: new Date(s.lastActivityAt + STALLED_AFTER_MS).toISOString()
18875
18875
  });
18876
18876
  }
@@ -19330,9 +19330,9 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
19330
19330
  }
19331
19331
  const holder = affinity ? now[affinity.column] : null;
19332
19332
  if (affinity && typeof holder === "string" && holder && holder !== affinity.shipId) {
19333
- return `${t.issue_id} is held by another ship now`;
19333
+ return `${displayKey(t)} is held by another ship now`;
19334
19334
  }
19335
- if (now.status !== buildingStatus) return `${t.issue_id} is at ${now.status}, not ${buildingStatus}`;
19335
+ if (now.status !== buildingStatus) return `${displayKey(t)} is at ${now.status}, not ${buildingStatus}`;
19336
19336
  return null;
19337
19337
  }
19338
19338
 
@@ -19559,7 +19559,7 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19559
19559
  const t = { ticket: b.ticket.issue_id, step: "merge" };
19560
19560
  const absorbed = b.priorBounces > 0 && b.priorBounces < MAX_ABSORBED_HANDBACKS && !!b.priorBaseSha && isAncestor(b.worktree ?? b.cwd, b.priorBaseSha, b.branch);
19561
19561
  if (absorbed) {
19562
- log.emit(`${b.ticket.issue_id} conflicts again, but ${b.base} moved since the hand-back was answered \u2014 handing back again`, t);
19562
+ log.emit(`${displayKey(b.ticket)} conflicts again, but ${b.base} moved since the hand-back was answered \u2014 handing back again`, t);
19563
19563
  }
19564
19564
  if (b.priorBounces > 0 && !absorbed) {
19565
19565
  if (dryRun) {
@@ -19575,7 +19575,7 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19575
19575
  return { kind: "escalated" };
19576
19576
  } catch (e) {
19577
19577
  if (e instanceof StaleWriteError7) {
19578
- log.emit(`${b.ticket.issue_id} changed on the board since this run read it \u2014 not escalating over it`, t);
19578
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it \u2014 not escalating over it`, t);
19579
19579
  return { kind: "stale" };
19580
19580
  }
19581
19581
  return { kind: "failed", why: e.message };
@@ -19596,7 +19596,7 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19596
19596
  return { kind: "refreshed" };
19597
19597
  }
19598
19598
  if (r.behind) {
19599
- log.warn(`not handing ${b.ticket.issue_id} back: ${r.why}`, t);
19599
+ log.warn(`not handing ${displayKey(b.ticket)} back: ${r.why}`, t);
19600
19600
  return { kind: "failed", why: r.why ?? "branch behind its remote" };
19601
19601
  }
19602
19602
  merged = r.paths.length > 0;
@@ -19625,7 +19625,7 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19625
19625
  return { kind: "handed-back" };
19626
19626
  } catch (e) {
19627
19627
  if (e instanceof StaleWriteError7) {
19628
- log.emit(`${b.ticket.issue_id} changed on the board since this run read it \u2014 not handing it back over it`, t);
19628
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it \u2014 not handing it back over it`, t);
19629
19629
  return { kind: "stale" };
19630
19630
  }
19631
19631
  return { kind: "failed", why: e.message };
@@ -19750,7 +19750,7 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
19750
19750
  }
19751
19751
  }
19752
19752
  if (dryRun) {
19753
- log.emit(`would hand ${b.ticket.issue_id} back to ${contract.statuses.building} \u2014 its branch breaks the ${b.hook} hook`, t);
19753
+ log.emit(`would hand ${displayKey(b.ticket)} back to ${contract.statuses.building} \u2014 its branch breaks the ${b.hook} hook`, t);
19754
19754
  return { kind: "handed-back" };
19755
19755
  }
19756
19756
  try {
@@ -19773,7 +19773,7 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
19773
19773
  return { kind: "handed-back" };
19774
19774
  } catch (e) {
19775
19775
  if (e instanceof StaleWriteError8) {
19776
- log.emit(`${b.ticket.issue_id} changed on the board since this run read it \u2014 not handing it back over it`, t);
19776
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it \u2014 not handing it back over it`, t);
19777
19777
  return { kind: "stale" };
19778
19778
  }
19779
19779
  return { kind: "failed", why: e.message };
@@ -21129,7 +21129,7 @@ Closes ${c.ticket.issue_id}.${trailer}`]);
21129
21129
  void o.attention.raise({
21130
21130
  kind: "release_merge_failed",
21131
21131
  key: `release_merge_failed:${o.scope ?? "release"}`,
21132
- message: `${o.scope ?? "release"}: could not merge ${c.branch} (${c.ticket.issue_id}) \u2014 not a conflict, so the ticket stays verified and is retried: ${message.slice(0, 400)}`,
21132
+ message: `${o.scope ?? "release"}: could not merge ${c.branch} (${displayKey(c.ticket)}) \u2014 not a conflict, so the ticket stays verified and is retried: ${message.slice(0, 400)}`,
21133
21133
  since: (/* @__PURE__ */ new Date()).toISOString()
21134
21134
  });
21135
21135
  }
@@ -21347,8 +21347,8 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
21347
21347
  materializeBranchForTicket(o.cwd, o.repo, t, void 0, (problem) => {
21348
21348
  skipped.add(t.id);
21349
21349
  localRefSkips.push({ ticket: t, problem });
21350
- o.emit.error(`not releasing ${t.issue_id} this cycle: ${problem}`, { ticket: t.issue_id });
21351
- }, (note) => o.emit.emit(`${t.issue_id}: ${note}`, { ticket: t.issue_id }));
21350
+ o.emit.error(`not releasing ${displayKey(t)} this cycle: ${problem}`, { ticket: t.issue_id });
21351
+ }, (note) => o.emit.emit(`${displayKey(t)}: ${note}`, { ticket: t.issue_id }));
21352
21352
  }
21353
21353
  if (skipped.size) releasable = o.tickets.filter((t) => !skipped.has(t.id));
21354
21354
  }
@@ -21364,7 +21364,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
21364
21364
  const remoteTip2 = branch ? gitOk(o.cwd, ["rev-parse", "-q", "--verify", `refs/remotes/${o.repo.branch.remote}/${branch}^{commit}`]) : null;
21365
21365
  if (remoteTip2 && remoteTip2 !== moved.tip) {
21366
21366
  o.emit.error(
21367
- `not releasing ${t.issue_id}: local ${branch} at ${moved.tip.slice(0, 8)} is not on ${o.repo.branch.remote}/${branch} (${remoteTip2.slice(0, 8)}); not requeuing it`,
21367
+ `not releasing ${displayKey(t)}: local ${branch} at ${moved.tip.slice(0, 8)} is not on ${o.repo.branch.remote}/${branch} (${remoteTip2.slice(0, 8)}); not requeuing it`,
21368
21368
  { ticket: t.issue_id }
21369
21369
  );
21370
21370
  localRefSkips.push({
@@ -21375,7 +21375,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
21375
21375
  }
21376
21376
  movedPast2.push({ ticket: t, verified: moved.verified, head: moved.tip, branch: pushedBranchForTicket(o.repo, t) });
21377
21377
  o.emit.error(
21378
- `not releasing ${t.issue_id}: ${branch} is at ${moved.tip.slice(0, 8)}, past the ${moved.verified.slice(0, 8)} QA verified`,
21378
+ `not releasing ${displayKey(t)}: ${branch} is at ${moved.tip.slice(0, 8)}, past the ${moved.verified.slice(0, 8)} QA verified`,
21379
21379
  { ticket: t.issue_id }
21380
21380
  );
21381
21381
  }
@@ -24046,7 +24046,7 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
24046
24046
  }
24047
24047
  } catch (e) {
24048
24048
  emit.error(
24049
- `could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`
24049
+ `could not check out ${target?.name ?? "(unknown repo)"} for ${displayKey(result.ticket)}: ${e.message}`
24050
24050
  );
24051
24051
  return;
24052
24052
  }
@@ -26967,7 +26967,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26967
26967
  const when = held ? noteHeldWorktree(held.state, { repo: held.repo, path: a.path, ticket: a.ticket.issue_id, status: a.ticket.status, reason }) : "first";
26968
26968
  if (when) {
26969
26969
  log.warn(
26970
- `not removing worktree ${a.path} for ${a.ticket.issue_id} (${a.ticket.status}): ${detail}`,
26970
+ `not removing worktree ${a.path} for ${displayKey(a.ticket)} (${a.ticket.status}): ${detail}`,
26971
26971
  { ticket: a.ticket.issue_id, step: "worktree" }
26972
26972
  );
26973
26973
  }
@@ -26978,7 +26978,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26978
26978
  if (!dryRun && base && !a.keepBranch && existsSync54(a.path) && isHandBackMerge(a.path, base)) {
26979
26979
  if (gitOk(a.path, ["merge", "--abort"]) !== null) {
26980
26980
  log.emit(
26981
- `abandoned the hand-back merge of ${base} in ${a.path}: ${a.ticket.issue_id} deployed without it`,
26981
+ `abandoned the hand-back merge of ${base} in ${a.path}: ${displayKey(a.ticket)} deployed without it`,
26982
26982
  { ticket: a.ticket.issue_id, step: "worktree" }
26983
26983
  );
26984
26984
  }
@@ -26988,7 +26988,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26988
26988
  const liveRun = !!held && liveRuns(held.state.dir).some((r) => (r.ticket ?? "").replace(/^\D+/, "") === String(n));
26989
26989
  const defer = () => {
26990
26990
  log.emit(
26991
- `leaving ${a.path} for the next cycle: ${liveRun ? `${a.ticket.issue_id} has a run in progress on this ship` : `processes are still inside it (${pids.join(" ")})`}`,
26991
+ `leaving ${a.path} for the next cycle: ${liveRun ? `${displayKey(a.ticket)} has a run in progress on this ship` : `processes are still inside it (${pids.join(" ")})`}`,
26992
26992
  { ticket: a.ticket.issue_id, step: "worktree" }
26993
26993
  );
26994
26994
  };
@@ -27030,7 +27030,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
27030
27030
  if (a.keepBranch) keptBranches++;
27031
27031
  if (dryRun) {
27032
27032
  log.emit(
27033
- `would remove worktree ${a.path} for ${a.ticket.issue_id} (${a.ticket.status}); ${branchNote}`,
27033
+ `would remove worktree ${a.path} for ${displayKey(a.ticket)} (${a.ticket.status}); ${branchNote}`,
27034
27034
  { ticket: a.ticket.issue_id, step: "worktree" }
27035
27035
  );
27036
27036
  continue;
@@ -27053,7 +27053,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
27053
27053
  }
27054
27054
  }
27055
27055
  log.emit(
27056
- `removed worktree for ${a.ticket.issue_id} (${a.ticket.status}); ${branchNote}`,
27056
+ `removed worktree for ${displayKey(a.ticket)} (${a.ticket.status}); ${branchNote}`,
27057
27057
  { ticket: a.ticket.issue_id, step: "worktree" }
27058
27058
  );
27059
27059
  removed++;
@@ -27296,7 +27296,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
27296
27296
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
27297
27297
  import { join as join58 } from "path";
27298
27298
  function builtVersion() {
27299
- return true ? "0.151.0" : null;
27299
+ return true ? "0.151.2" : null;
27300
27300
  }
27301
27301
  var REBUILD_HINT = "rebuild with npm run build";
27302
27302
  function newestMtime(path) {
@@ -29776,11 +29776,10 @@ if (command === "passenger-sync-daemon") {
29776
29776
  return process.exit(code);
29777
29777
  }, requireArmed = function(what) {
29778
29778
  if (dryRun || route2.enabled) return;
29779
- process.stderr.write(
29780
- `crew: route "${route2.route}" is not enabled in ${cfg.configFile} \u2014 refusing to ${what}.
29781
- Add --dry-run to see what it would do.
29782
- `
29783
- );
29779
+ emit.warn(withFix(
29780
+ `crew: route "${route2.route}" is not enabled in ${cfg.configFile} \u2014 refusing to ${what}`,
29781
+ "add --dry-run to see what it would do, or set `enabled: true` on the route"
29782
+ ));
29784
29783
  process.exit(0);
29785
29784
  }, parseTicketNumber = function(input) {
29786
29785
  const m = /^(?:[A-Za-z]+-)?(\d+)$/.exec(input.trim());
@@ -31259,7 +31258,7 @@ ${changed2.map((c) => ` - ${c}
31259
31258
  { count: priorBuildFailures(cu.ticket, prior), operatorId: c.resolved?.operator, previousNote: priorFailureNote(cu.ticket, prior) }
31260
31259
  );
31261
31260
  if (r.kind === "failed") {
31262
- remit.warn(`could not hand back ${cu.ticket.issue_id}: ${r.why}`, { step: "release" });
31261
+ remit.warn(`could not hand back ${displayKey(cu.ticket)}: ${r.why}`, { step: "release" });
31263
31262
  }
31264
31263
  if (r.kind === "escalated" && !dryRun) {
31265
31264
  const key = cu.ticket.issue_tag ?? cu.ticket.issue_id;
@@ -31276,7 +31275,7 @@ ${cu.tail.trimEnd()}
31276
31275
  });
31277
31276
  }
31278
31277
  } catch (e) {
31279
- remit.warn(`could not hand back ${cu.ticket.issue_id}: ${e.message}`, { step: "release" });
31278
+ remit.warn(`could not hand back ${displayKey(cu.ticket)}: ${e.message}`, { step: "release" });
31280
31279
  }
31281
31280
  }
31282
31281
  }
@@ -31314,11 +31313,11 @@ ${f.tail.trimEnd()}
31314
31313
  );
31315
31314
  const r = await applyConflictBounce(tracker, bounce, tracker.contract, seat, remit, dryRun);
31316
31315
  if (r.kind === "failed") {
31317
- remit.warn(`could not hand back ${f.candidate.ticket.issue_id}: ${r.why}`, { step: "merge" });
31316
+ remit.warn(`could not hand back ${displayKey(f.candidate.ticket)}: ${r.why}`, { step: "merge" });
31318
31317
  }
31319
31318
  } catch (e) {
31320
31319
  remit.warn(
31321
- `could not hand back ${f.candidate.ticket.issue_id}: ${e.message}`,
31320
+ `could not hand back ${displayKey(f.candidate.ticket)}: ${e.message}`,
31322
31321
  { step: "merge" }
31323
31322
  );
31324
31323
  }
@@ -31336,10 +31335,10 @@ ${f.tail.trimEnd()}
31336
31335
  dryRun
31337
31336
  );
31338
31337
  if (r.kind === "failed") {
31339
- remit.warn(`could not flag ${cand.ticket.issue_id}: ${r.why}`, { step: "merge" });
31338
+ remit.warn(`could not flag ${displayKey(cand.ticket)}: ${r.why}`, { step: "merge" });
31340
31339
  }
31341
31340
  } catch (e) {
31342
- remit.warn(`could not flag ${cand.ticket.issue_id}: ${e.message}`, { step: "merge" });
31341
+ remit.warn(`could not flag ${displayKey(cand.ticket)}: ${e.message}`, { step: "merge" });
31343
31342
  }
31344
31343
  }
31345
31344
  }
@@ -31577,7 +31576,7 @@ ${f.tail.trimEnd()}
31577
31576
  wemit.note(`cloned ${target.name} into ${target.dir}`, { step: "select", role: w.role });
31578
31577
  }
31579
31578
  } catch (e) {
31580
- wemit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`);
31579
+ wemit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${displayKey(result.ticket)}: ${e.message}`);
31581
31580
  if (!skipInlineRelease) await releaseFleet();
31582
31581
  break;
31583
31582
  }
@@ -31799,7 +31798,7 @@ ${f.tail.trimEnd()}
31799
31798
  emit.note(`cloned ${target.name} into ${target.dir}`, { step: "select", role: current });
31800
31799
  }
31801
31800
  } catch (e) {
31802
- emit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`);
31801
+ emit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${displayKey(result.ticket)}: ${e.message}`);
31803
31802
  dropLock();
31804
31803
  if (explicitRole) {
31805
31804
  current = void 0;
@@ -31898,8 +31897,7 @@ ${f.tail.trimEnd()}
31898
31897
  if (daemonSub === "start" || daemonSub === "stop" || daemonSub === "status" || daemonSub === "restart") {
31899
31898
  const host = hostPlatform();
31900
31899
  if (host === "windows") {
31901
- process.stderr.write("crew daemon: no scheduler support yet for Windows (Task Scheduler is planned, not built)\n");
31902
- process.exit(2);
31900
+ die("crew daemon", "no scheduler support yet for Windows (Task Scheduler is planned, not built)", "`crew run <route>` from your own scheduler");
31903
31901
  }
31904
31902
  const control = planDaemonControl(CREW_HOME, host, detectSystemd());
31905
31903
  if (!control.startCommand && !control.stopCommand && !control.statusCommand) {
@@ -31958,8 +31956,7 @@ ${f.tail.trimEnd()}
31958
31956
  if (res2.stdout) process.stdout.write(res2.stdout);
31959
31957
  if (res2.stderr) process.stderr.write(res2.stderr);
31960
31958
  if (cmd2 === control.startCommand && (res2.error || res2.status !== 0)) {
31961
- process.stderr.write(`crew daemon restart: ${cmd2.join(" ")} exited ${res2.status ?? "error"}
31962
- `);
31959
+ emit.error(withFix(`crew daemon restart: ${cmd2.join(" ")} exited ${res2.status ?? "error"}`, "`crew doctor`"));
31963
31960
  failed = true;
31964
31961
  }
31965
31962
  }
@@ -31976,8 +31973,7 @@ ${f.tail.trimEnd()}
31976
31973
  if (res.stdout) process.stdout.write(res.stdout);
31977
31974
  if (res.stderr) process.stderr.write(res.stderr);
31978
31975
  if (daemonSub !== "status" && (res.error || res.status !== 0)) {
31979
- process.stderr.write(`crew daemon ${daemonSub}: ${cmd.join(" ")} exited ${res.status ?? "error"}
31980
- `);
31976
+ emit.error(withFix(`crew daemon ${daemonSub}: ${cmd.join(" ")} exited ${res.status ?? "error"}`, "`crew doctor`"));
31981
31977
  process.exitCode = 1;
31982
31978
  } else {
31983
31979
  process.exitCode = res.status ?? 0;
@@ -31985,13 +31981,11 @@ ${f.tail.trimEnd()}
31985
31981
  break;
31986
31982
  }
31987
31983
  if (dryRun) {
31988
- process.stderr.write("crew: daemon does not support --dry-run \u2014 it only ever performs real cycles.\n");
31989
- process.exit(2);
31984
+ die("crew", "daemon does not support --dry-run \u2014 it only ever performs real cycles", "run `crew daemon` without --dry-run, or `crew poll --dry-run` to preview a cycle");
31990
31985
  }
31991
31986
  if (!fleetWide && !route2.enabled) {
31992
31987
  const reason = `route "${route2.route}" is not enabled in ${cfg.configFile} \u2014 refusing to run the daemon loop`;
31993
- process.stderr.write(`crew: ${reason}.
31994
- `);
31988
+ emit.error(withFix(`crew: ${reason}`, `set \`enabled: true\` on route "${route2.route}" in crew.yaml`));
31995
31989
  await failDaemonStart({
31996
31990
  stateDir: cfg.ship.stateDir,
31997
31991
  reason,
@@ -32283,17 +32277,11 @@ ${f.tail.trimEnd()}
32283
32277
  try {
32284
32278
  promptTarget = positional[3] ? findRoute(cfg, positional[3]) : routeForDir(cfg, process.cwd()) ?? findRoute(cfg, void 0);
32285
32279
  } catch (e) {
32286
- if (e instanceof ConfigError) {
32287
- process.stderr.write(`crew: ${e.message}
32288
- `);
32289
- process.exit(2);
32290
- }
32280
+ if (e instanceof ConfigError) die("crew", e.message, "`crew doctor`");
32291
32281
  throw e;
32292
32282
  }
32293
32283
  if (!promptTarget.resolved) {
32294
- process.stderr.write(`crew agents prompt: route "${promptTarget.route}" has no resolved ids \u2014 run \`crew connect\` first
32295
- `);
32296
- process.exit(2);
32284
+ die("crew agents prompt", `route "${promptTarget.route}" has no resolved ids`, "`crew connect`");
32297
32285
  }
32298
32286
  try {
32299
32287
  const prompt = await currentPersonaPrompt(promptTarget, role, { userAgent: cfg.ship.userAgent });
@@ -32575,8 +32563,7 @@ ${f.tail.trimEnd()}
32575
32563
  for (const n of agent.notes) process.stdout.write(`note: ${n}
32576
32564
  `);
32577
32565
  }
32578
- if (agentError) process.stderr.write(`crew repos: --agent failed (${agentError.reason}): ${agentError.message}
32579
- `);
32566
+ if (agentError) emit.warn(withFix(`crew repos: --agent failed (${agentError.reason}): ${agentError.message}`, "`crew repos hooks --suggest` for the deterministic suggestion"));
32580
32567
  if (cleared) process.stdout.write(cleared.removed.length ? `removed route hooks ${cleared.removed.join(", ")} from ${cleared.file}
32581
32568
  ` : "no route hooks to remove\n");
32582
32569
  if (written) {
@@ -32715,8 +32702,7 @@ ${f.tail.trimEnd()}
32715
32702
  crew.yaml was not changed`);
32716
32703
  }
32717
32704
  writeFileSync44(cfg.configFile, plan2.text);
32718
- if (plan2.droppedDir) process.stderr.write(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:
32719
- `);
32705
+ if (plan2.droppedDir) emit.warn(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:`);
32720
32706
  say("attached", { route: routeName, name: plan2.name, dir: plan2.target, mode: plan2.mode }, `cloned and attached ${plan2.target} to ${routeName} as ${plan2.mode === "dir" ? "dir" : `repos.${plan2.name}`} in ${cfg.configFile}`);
32721
32707
  break;
32722
32708
  }
@@ -32735,8 +32721,7 @@ ${f.tail.trimEnd()}
32735
32721
  nameForExisting: (d) => matchRepoName(originOf(d), resolvedRemotes),
32736
32722
  isCheckout
32737
32723
  });
32738
- if (plan.droppedDir) process.stderr.write(`crew repos: dropped dir: ${plan.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:
32739
- `);
32724
+ if (plan.droppedDir) emit.warn(`crew repos: dropped dir: ${plan.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:`);
32740
32725
  let rowTracker;
32741
32726
  let rowPayload;
32742
32727
  if (plan.unmatched && origin && !flag("no-create")) {
@@ -32759,8 +32744,7 @@ ${f.tail.trimEnd()}
32759
32744
  }
32760
32745
  rowPayload = planRepoRow({ name: plan.name, origin, spec, projectId });
32761
32746
  } else if (plan.warning) {
32762
- process.stderr.write(`crew repos: warning \u2014 ${plan.warning}
32763
- `);
32747
+ emit.warn(`crew repos: warning \u2014 ${plan.warning}`);
32764
32748
  }
32765
32749
  if (dryRun) {
32766
32750
  process.stdout.write(`${plan.block}
@@ -32810,11 +32794,7 @@ ${f.tail.trimEnd()}
32810
32794
  try {
32811
32795
  target = findRoute(cfg, routeArg);
32812
32796
  } catch (e) {
32813
- if (e instanceof ConfigError) {
32814
- process.stderr.write(`crew: ${e.message}
32815
- `);
32816
- process.exit(2);
32817
- }
32797
+ if (e instanceof ConfigError) die("crew", e.message, "`crew doctor`");
32818
32798
  throw e;
32819
32799
  }
32820
32800
  try {
@@ -32905,10 +32885,7 @@ ${reconstruction.prompt}
32905
32885
  const canAsk = !!(process.stdin.isTTY && process.stdout.isTTY) && !connectEvents.json;
32906
32886
  const stopForChoice = (key, message, options) => {
32907
32887
  connectEvents.emit("choice", message, choiceData(key, options));
32908
- process.stderr.write(`crew connect: ${message}
32909
- Re-run with --choose ${key}=<${options.map((o) => o.value).join("|")}>
32910
- `);
32911
- return process.exit(CHOICE_EXIT_CODE);
32888
+ return die("crew connect", message, `re-run with --choose ${key}=<${options.map((o) => o.value).join("|")}>`, CHOICE_EXIT_CODE);
32912
32889
  };
32913
32890
  const stopWithProblem = (message, stage) => {
32914
32891
  connectEvents.emit("problem", message, { stage });
@@ -33017,16 +32994,11 @@ Waiting for approval`
33017
32994
  } catch (e) {
33018
32995
  process.stderr.write("\n");
33019
32996
  const why = e instanceof DeviceLoginError ? e.message : `device authorization failed \u2014 ${e.message}`;
33020
- process.stderr.write(`crew connect: ${why}
33021
- `);
33022
32997
  connectEvents.emit("problem", why, { stage: "device_login" });
33023
- process.exit(2);
32998
+ die("crew connect", why, "`crew connect` again, or pass --key");
33024
32999
  }
33025
- process.stderr.write(
33026
- `
33027
- Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${result.workspace.name}".
33028
- `
33029
- );
33000
+ process.stderr.write("\n");
33001
+ emit.note(`Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${result.workspace.name}".`);
33030
33002
  apiKey = result.apiKey.key;
33031
33003
  mintedFromDevice = true;
33032
33004
  const deviceWorkspace = "path" in result.workspace && typeof result.workspace.path === "string" ? result.workspace.path : result.workspace.slug;
@@ -33042,18 +33014,15 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33042
33014
  keychainBacked = true;
33043
33015
  sessionAddress = deviceWorkspace;
33044
33016
  rememberSession(cfg.ship.stateDir, hostFromUrl4(baseUrl), deviceWorkspace);
33045
- process.stderr.write(
33046
- `API key stored in the OS keychain for ${hostFromUrl4(baseUrl)}/${deviceWorkspace}.
33047
- `
33048
- );
33017
+ emit.note(`API key stored in the OS keychain for ${hostFromUrl4(baseUrl)}/${deviceWorkspace}.`);
33049
33018
  } catch (e) {
33050
- process.stderr.write(
33051
- `(could not store the key in the OS keychain \u2014 ${e.message} \u2014 falling back to a key file)
33052
- `
33053
- );
33019
+ emit.warn(withFix(
33020
+ `could not store the key in the OS keychain \u2014 ${e.message} \u2014 falling back to a key file`,
33021
+ "`crew doctor`"
33022
+ ));
33054
33023
  }
33055
33024
  } else {
33056
- process.stderr.write("(no OS keychain support on this platform \u2014 falling back to a key file)\n");
33025
+ emit.warn("no OS keychain support on this platform \u2014 falling back to a key file");
33057
33026
  }
33058
33027
  }
33059
33028
  const authOpts = { baseUrl, apiKey, userAgent: cfg.ship.userAgent };
@@ -33063,16 +33032,14 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33063
33032
  try {
33064
33033
  sshPublicKey = ensureShipSshKeypair(cfg.ship.stateDir).publicKey;
33065
33034
  } catch (e) {
33066
- process.stderr.write(`(no SSH keypair synced \u2014 ${e.message})
33067
- `);
33035
+ emit.warn(`no SSH keypair synced \u2014 ${e.message}`);
33068
33036
  }
33069
33037
  }
33070
33038
  let machineId;
33071
33039
  try {
33072
33040
  machineId = ensureMachineId(cfg.ship.stateDir, { override: value("machine-id") });
33073
33041
  } catch (e) {
33074
- process.stderr.write(`(no machine id \u2014 ${e.message})
33075
- `);
33042
+ emit.warn(`no machine id \u2014 ${e.message}`);
33076
33043
  }
33077
33044
  const ship = {
33078
33045
  name: cfg.ship.name,
@@ -33140,14 +33107,9 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33140
33107
  }
33141
33108
  }
33142
33109
  if (!found.projectId) {
33143
- process.stderr.write(`crew connect ${ws}: unresolved \u2014
33144
- `);
33145
- for (const p of found.problems) {
33146
- process.stderr.write(` - ${p}
33147
- `);
33148
- connectEvents.emit("problem", p, { stage: "discover" });
33149
- }
33150
- process.exit(2);
33110
+ for (const p of found.problems) connectEvents.emit("problem", p, { stage: "discover" });
33111
+ die(`crew connect ${ws}`, `unresolved \u2014
33112
+ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, then run `crew connect` again");
33151
33113
  }
33152
33114
  if (found.shipNameAdopted && !dryRun) {
33153
33115
  writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), found.shipNameAdopted));
@@ -33173,11 +33135,9 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33173
33135
  const repoNames = [...Object.values(found.repoNames ?? {}), ...configured2 ? reposOf(configured2).map((t) => t.name) : []].filter((n) => !!n);
33174
33136
  try {
33175
33137
  const made = await provisionReleaseLocks(authOpts, found.locksModelId, route3, repoNames);
33176
- for (const sc of made) process.stderr.write(`created release lock row ${sc}
33177
- `);
33138
+ for (const sc of made) emit.note(`created release lock row ${sc}`);
33178
33139
  } catch (e) {
33179
- process.stderr.write(`(could not provision release lock rows \u2014 ${e.message})
33180
- `);
33140
+ emit.warn(withFix(`could not provision release lock rows \u2014 ${e.message}`, "`crew doctor`"));
33181
33141
  }
33182
33142
  }
33183
33143
  let operator = found.operator;
@@ -33224,8 +33184,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33224
33184
  }
33225
33185
  }
33226
33186
  if (!operator && found.operatorCompared && found.operatorAction !== "would-create") {
33227
- process.stderr.write(`crew connect: no Crew row matched you \u2014 ${found.operatorCompared}
33228
- `);
33187
+ emit.warn(`crew connect: no Crew row matched you \u2014 ${found.operatorCompared}`);
33229
33188
  connectEvents.emit("operator_row", "no Crew row matched you", { action: "unmatched", compared: found.operatorCompared });
33230
33189
  }
33231
33190
  if (operator) {
@@ -33247,12 +33206,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33247
33206
  });
33248
33207
  }
33249
33208
  if (!operator && !hadPreviousFile && !operatorWouldBeCreated) {
33250
- process.stderr.write(
33251
- `crew connect ${route3}: cannot determine the operator \u2014 ${found.candidates.length} Crew row(s) could be it, none matching this key's own email, and there's no terminal to ask.
33252
- Re-run from a real terminal to pick one, or pass --key for a key whose own
33253
- identity email matches exactly one Crew row.
33254
- `
33255
- );
33209
+ emit.error(withFix(
33210
+ `crew connect ${route3}: cannot determine the operator \u2014 ${found.candidates.length} Crew row(s) could be it, none matching this key's own email, and there's no terminal to ask`,
33211
+ "run `crew connect` from a real terminal to pick one, or pass --key for a key whose own identity email matches exactly one Crew row"
33212
+ ));
33256
33213
  stopWithProblem(`cannot determine the operator \u2014 ${found.candidates.length} Crew row(s) could be it`, "operator");
33257
33214
  }
33258
33215
  const alreadyReviewed = new Set(previous?.reviewedStatuses ?? []);
@@ -33333,22 +33290,18 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33333
33290
  writeFileSync44(tmpPath, `${JSON.stringify(resolved, null, 2)}
33334
33291
  `);
33335
33292
  renameSync10(tmpPath, resolvedPath);
33336
- process.stderr.write(`Resolved ids written to ${resolvedPath}
33337
- `);
33293
+ emit.note(`Resolved ids written to ${resolvedPath}`);
33338
33294
  }
33339
33295
  let mintOutcomes = [];
33340
33296
  if (!dryRun && previous?.agentPersonas && existingRoute?.resolved) {
33341
33297
  try {
33342
33298
  mintOutcomes = await mintMissingSeatKeys(withFoundSeats(existingRoute, found, previous.releaseAgentId), { userAgent: cfg.ship.userAgent, shipName: cfg.ship.name });
33343
- for (const o of mintOutcomes) process.stderr.write(`${describeMintOutcome(o)}
33344
- `);
33299
+ for (const o of mintOutcomes) emit.note(describeMintOutcome(o));
33345
33300
  for (const p of await probeSeatReads({ ...existingRoute, resolved: { ...existingRoute.resolved, seats: found.seats } }, { userAgent: cfg.ship.userAgent })) {
33346
- if (p.state === "forbidden") process.stderr.write(`${describeSeatForbidden(p.role, p.tables)}
33347
- `);
33301
+ if (p.state === "forbidden") emit.warn(describeSeatForbidden(p.role, p.tables));
33348
33302
  }
33349
33303
  } catch (e) {
33350
- process.stderr.write(`seat keys: skipped (${e.message})
33351
- `);
33304
+ emit.warn(withFix(`seat keys: skipped (${e.message})`, "`crew agents sync`"));
33352
33305
  }
33353
33306
  }
33354
33307
  for (const sr of found.seatRows ?? []) {
@@ -33366,8 +33319,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33366
33319
  const apiKeyVar = "CREW_API_KEY";
33367
33320
  if (firstRunFromFlags && agentBinSearched && !dryRun && !isManagedShipKind(value("ship-kind"))) {
33368
33321
  const msg = `no agent binary: "claude" was not found on PATH or in ${agentBinSearched.join(", ")} \u2014 pass --agent-bin /absolute/path`;
33369
- process.stderr.write(`crew connect: ${msg}
33370
- `);
33322
+ emit.error(`crew connect: ${msg}`);
33371
33323
  stopWithProblem(msg, "wizard");
33372
33324
  }
33373
33325
  if ((mintedFromDevice || firstRunFromFlags) && !keychainBacked) {
@@ -33401,8 +33353,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33401
33353
  let wroteConfig = false;
33402
33354
  if (writeFirstRun) {
33403
33355
  wroteConfig = writeNewConfig(wizard.configPath, renderFullConfig(wizard.answers, routeBlock));
33404
- if (!wroteConfig) process.stderr.write(`(${wizard.configPath} appeared while connecting \u2014 leaving it alone)
33405
- `);
33356
+ if (!wroteConfig) emit.warn(`${wizard.configPath} appeared while connecting \u2014 leaving it alone`);
33406
33357
  }
33407
33358
  if (!dryRun) {
33408
33359
  if (wroteConfig) {
@@ -33437,33 +33388,22 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33437
33388
  }
33438
33389
  }
33439
33390
  if (found.holds.length) {
33440
- process.stderr.write(
33441
- `
33442
- Holds resolved (${found.holds.length}): ${found.holds.map((h) => `${h.name || h.id}${h.id === operator ? " [operator]" : ""}`).join(", ")}
33443
- `
33391
+ emit.note(
33392
+ `Holds resolved (${found.holds.length}): ${found.holds.map((h) => `${h.name || h.id}${h.id === operator ? " [operator]" : ""}`).join(", ")}`
33444
33393
  );
33445
33394
  }
33446
33395
  if (found.provisioning.length) {
33447
- process.stderr.write(`
33448
- Provisioned for this machine (${ship.name}):
33449
- `);
33450
- for (const p of found.provisioning) process.stderr.write(` - ${p}
33451
- `);
33396
+ emit.note(`Provisioned for this machine (${ship.name}):`);
33397
+ for (const p of found.provisioning) emit.note(` - ${p}`);
33452
33398
  }
33453
33399
  if (found.problems.length) {
33454
- process.stderr.write("\n Unresolved \u2014 fix these before arming it:\n");
33455
- for (const p of found.problems) {
33456
- process.stderr.write(` - ${p}
33457
- `);
33458
- connectEvents.emit("problem", p, { stage: "discover" });
33459
- }
33400
+ emit.warn(`Unresolved \u2014 fix these before arming it:
33401
+ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
33402
+ for (const p of found.problems) connectEvents.emit("problem", p, { stage: "discover" });
33460
33403
  }
33461
33404
  if (!canPrompt && !jsonClassified && stillUnrecognized.length > 0) {
33462
- process.stderr.write(
33463
- `
33464
- ${stillUnrecognized.length} status value(s) this workspace has that the default contract
33465
- doesn't know the meaning of (${stillUnrecognized.map((s) => s.value).join(", ")}) \u2014 re-run from a terminal to classify them, or edit ${resolvedPath} by hand.
33466
- `
33405
+ emit.warn(
33406
+ `${stillUnrecognized.length} status value(s) this workspace has that the default contract doesn't know the meaning of (${stillUnrecognized.map((s) => s.value).join(", ")}) \u2014 re-run from a terminal to classify them, or edit ${resolvedPath} by hand.`
33467
33407
  );
33468
33408
  }
33469
33409
  if (wroteConfig) {
@@ -33491,9 +33431,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33491
33431
  }
33492
33432
  if (!dryRun && !flag("no-agents-sync")) {
33493
33433
  const skip = (why) => {
33494
- process.stderr.write(`
33495
- agents sync: skipped (${why})
33496
- `);
33434
+ emit.warn(`agents sync: skipped (${why})`);
33497
33435
  connectEvents.emit("agents_synced", `agents sync skipped: ${why}`, { route: route3, skipped: why });
33498
33436
  };
33499
33437
  let syncRoute;
@@ -33506,25 +33444,21 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33506
33444
  }
33507
33445
  if (syncRoute?.resolved) {
33508
33446
  try {
33509
- process.stderr.write("\n");
33510
33447
  const run4 = await runAgentsSync(syncRoute, {
33511
33448
  userAgent: cfg.ship.userAgent,
33512
33449
  stateDir: cfg.ship.stateDir,
33513
- say: (l) => process.stderr.write(` ${l}
33514
- `),
33515
- warn: (l) => process.stderr.write(` agents sync: ${l}
33516
- `)
33450
+ say: (l) => emit.note(l),
33451
+ warn: (l) => emit.warn(`agents sync: ${l}`)
33517
33452
  });
33518
33453
  const minted = await mintMissingSeatKeys(syncRoute, { userAgent: cfg.ship.userAgent, shipName: cfg.ship.name });
33519
- for (const m of minted) process.stderr.write(` ${describeMintOutcome(m)}
33520
- `);
33454
+ for (const m of minted) emit.note(describeMintOutcome(m));
33521
33455
  for (const p of await probeSeatReads(syncRoute, { userAgent: cfg.ship.userAgent })) {
33522
- if (p.state === "forbidden") process.stderr.write(` ${describeSeatForbidden(p.role, p.tables)}
33523
- `);
33456
+ if (p.state === "forbidden") emit.warn(describeSeatForbidden(p.role, p.tables));
33524
33457
  }
33525
33458
  if (run4.readOnly) {
33526
33459
  const missing = run4.personaResult.outcomes.some((p) => p.action === "missing");
33527
- process.stderr.write(missing ? " A workspace admin has to open the Crew app or run `crew agents sync` once before this ship's seats can run.\n" : " Seats are linked to the workspace's existing personas.\n");
33460
+ if (missing) emit.warn("A workspace admin has to open the Crew app or run `crew agents sync` once before this ship's seats can run.");
33461
+ else emit.note("Seats are linked to the workspace's existing personas.");
33528
33462
  }
33529
33463
  connectEvents.emit("agents_synced", run4.readOnly ? "agents linked (read-only key)" : "agents synced", {
33530
33464
  route: route3,
@@ -33595,12 +33529,8 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33595
33529
  workspaces.map((w) => ({ value: w.slug, label: `${w.name} (${w.role})` }))
33596
33530
  );
33597
33531
  }
33598
- process.stderr.write(
33599
- `${workspaces.length} workspaces reachable by this key \u2014 name one:
33600
- ` + workspaces.map((w) => ` ${w.slug.padEnd(24)} ${w.name} (${w.role})
33601
- `).join("")
33602
- );
33603
- process.exit(2);
33532
+ die("crew connect", `${workspaces.length} workspaces reachable by this key \u2014 name one:
33533
+ ` + workspaces.map((w) => ` ${w.slug.padEnd(24)} ${w.name} (${w.role})`).join("\n"), "run `crew connect <workspace>` with one of the slugs above");
33604
33534
  }
33605
33535
  } else {
33606
33536
  await runConnect(workspace, project);
@@ -33636,20 +33566,16 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33636
33566
  );
33637
33567
  }
33638
33568
  if (ambiguous) {
33639
- process.stderr.write(
33640
- `
33641
- WARNING: "${who2}" resolved to different people on different workspaces.
33642
- A name is a per-workspace label, not an identity \u2014 this queue is a mixture.
33643
- Use an email address to match exactly.
33644
- `
33645
- );
33569
+ emit.warn(withFix(
33570
+ `"${who2}" resolved to different people on different workspaces. A name is a per-workspace label, not an identity \u2014 this queue is a mixture`,
33571
+ "pass an email address to --member to match exactly"
33572
+ ));
33646
33573
  }
33647
33574
  process.stdout.write("\n");
33648
33575
  }
33649
33576
  const subject = who2 ? [...new Set(resolved.flatMap((r) => r.names))].join(", ") || `"${who2}"` : void 0;
33650
33577
  process.stdout.write(renderInbox(items, flag("by-route"), subject));
33651
- for (const e of errors) process.stderr.write(` (${e.route} unreachable: ${e.error})
33652
- `);
33578
+ for (const e of errors) emit.warn(withFix(`${e.route} unreachable: ${e.error}`, `\`crew doctor ${e.route}\``));
33653
33579
  break;
33654
33580
  }
33655
33581
  case "ports": {
@@ -33701,11 +33627,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33701
33627
  try {
33702
33628
  routesS = value("route") ? [findRoute(cfg, value("route"))] : cfg.routes.filter((r) => r.enabled);
33703
33629
  } catch (e) {
33704
- if (e instanceof ConfigError) {
33705
- process.stderr.write(`crew: ${e.message}
33706
- `);
33707
- process.exit(2);
33708
- }
33630
+ if (e instanceof ConfigError) die("crew", e.message, "`crew doctor`");
33709
33631
  throw e;
33710
33632
  }
33711
33633
  const declared = withShipSandbox(await sandboxReposOf(routesS));
@@ -33735,9 +33657,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33735
33657
  const only = positional[2];
33736
33658
  const targets = only ? declared.filter((r) => r.name === only) : declared;
33737
33659
  if (targets.length === 0) {
33738
- process.stderr.write(only ? `crew: no repository "${only}" declares a sandbox: section (${SHIP_SANDBOX_KEY} is the ship's crew layer, built only on a ship.runner: sandbox ship)
33739
- ` : "crew: this ship is not a sandbox ship and no repository declares a sandbox: section in its .crew.yaml\n");
33740
- process.exit(2);
33660
+ die("crew", only ? `no repository "${only}" declares a sandbox: section (${SHIP_SANDBOX_KEY} is the ship's crew layer, built only on a ship.runner: sandbox ship)` : "this ship is not a sandbox ship and no repository declares a sandbox: section in its .crew.yaml", "add a sandbox: section to the repository's .crew.yaml, or run `crew sandbox images` to list what is declared");
33741
33661
  }
33742
33662
  const emitS = new Emitter({ route: routesS[0].route, eventFile: eventFileFor(cfg.ship.stateDir), rotateBytes: cfg.ship.eventsRotateBytes, logFile: cfg.ship.logFile, console: (l) => process.stderr.write(`${l}
33743
33663
  `) });
@@ -33756,10 +33676,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33756
33676
  }
33757
33677
  case "cache": {
33758
33678
  const settings = cacheSettingsOf(cfg.ship.sandbox);
33759
- if (!settings) {
33760
- process.stderr.write("crew sandbox cache: ship.sandbox.cacheVolume is not set, so there is no cache volume\n");
33761
- process.exit(2);
33762
- }
33679
+ if (!settings) die("crew sandbox cache", "ship.sandbox.cacheVolume is not set, so there is no cache volume", "set ship.sandbox.cacheVolume in crew.yaml");
33763
33680
  const cache = new SandboxCache(settings);
33764
33681
  const served = cfg.routes.flatMap((r) => sandboxCacheRepos(r, cfg.ship));
33765
33682
  try {
@@ -33804,8 +33721,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33804
33721
  }
33805
33722
  if (refreshFailed) process.exitCode = 1;
33806
33723
  } catch (e) {
33807
- process.stderr.write(`crew sandbox cache: ${e instanceof Error ? e.message : String(e)}
33808
- `);
33724
+ emit.error(withFix(`crew sandbox cache: ${e instanceof Error ? e.message : String(e)}`, "`crew doctor`"));
33809
33725
  process.exitCode = 1;
33810
33726
  }
33811
33727
  break;
@@ -34498,14 +34414,12 @@ ${where.join("\n")}`);
34498
34414
  const opener = openerFor(process.platform);
34499
34415
  if (opener && shouldOpen({ open: flag("open"), noOpen: flag("no-open"), json: jsonP, terminal })) {
34500
34416
  const r = spawnSync14(opener, [res.url], { stdio: "ignore" });
34501
- if (r.error || r.status !== 0) process.stderr.write(`crew periscope: could not open ${res.url} with ${opener}
34502
- `);
34417
+ if (r.error || r.status !== 0) emit.warn(withFix(`crew periscope: could not open ${res.url} with ${opener}`, `open ${res.url} yourself`));
34503
34418
  }
34504
34419
  }
34505
34420
  } catch (e) {
34506
34421
  if (e instanceof PeriscopeError || e instanceof ConfigError) {
34507
- process.stderr.write(`crew periscope: ${e.message}
34508
- `);
34422
+ emit.error(withFix(`crew periscope: ${e.message}`, "`crew periscope list`"));
34509
34423
  if (e instanceof LivePeriscopeError && jsonP) process.stdout.write(`${JSON.stringify(e.data)}
34510
34424
  `);
34511
34425
  process.exit(1);
@@ -34643,14 +34557,12 @@ ${where.join("\n")}`);
34643
34557
  if (!dryRun) {
34644
34558
  for (const r of cfg.routes.filter((x) => x.resolved?.shipsModelId)) {
34645
34559
  await new Tracker(r, cfg.ship).updateRelayUrl(cfg.ship.name, null).catch((e) => {
34646
- process.stderr.write(`could not clear relay_url for ${r.route}: ${e.message}
34647
- `);
34560
+ emit.warn(withFix(`could not clear relay_url for ${r.route}: ${e.message}`, "`crew doctor`"));
34648
34561
  });
34649
34562
  }
34650
34563
  }
34651
34564
  if (!flag("reset") && !deprovisioning) {
34652
- for (const line of removePairEntries(url, dryRun)) process.stderr.write(`${line}
34653
- `);
34565
+ for (const line of removePairEntries(url, dryRun)) emit.note(line);
34654
34566
  break;
34655
34567
  }
34656
34568
  const host = hostPlatform();
@@ -34757,8 +34669,7 @@ ${where.join("\n")}`);
34757
34669
  if (!unitRunning && control?.mechanism === "systemd" && control.startCommand) {
34758
34670
  const res = spawnSync14(control.startCommand[0], control.startCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
34759
34671
  if (res.error || res.status !== 0) {
34760
- process.stderr.write(`crew reload: ${control.startCommand.join(" ")} exited ${res.status ?? "error"}
34761
- `);
34672
+ emit.error(withFix(`crew reload: ${control.startCommand.join(" ")} exited ${res.status ?? "error"}`, "`crew doctor`"));
34762
34673
  process.exitCode = 1;
34763
34674
  } else {
34764
34675
  process.stdout.write("crew reload: the daemon unit was not running \u2014 started it, so it reads crew.yaml fresh\n");
@@ -34779,8 +34690,7 @@ ${where.join("\n")}`);
34779
34690
  for (const cmd of [control.stopCommand, control.startCommand]) {
34780
34691
  const res = spawnSync14(cmd[0], cmd.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
34781
34692
  if (cmd === control.startCommand && (res.error || res.status !== 0)) {
34782
- process.stderr.write(`crew reload: ${cmd.join(" ")} exited ${res.status ?? "error"}
34783
- `);
34693
+ emit.error(withFix(`crew reload: ${cmd.join(" ")} exited ${res.status ?? "error"}`, "`crew doctor`"));
34784
34694
  process.exitCode = 1;
34785
34695
  }
34786
34696
  }
@@ -34963,9 +34873,7 @@ ${where.join("\n")}`);
34963
34873
  const all = shipToolchains(cfg.ship);
34964
34874
  const chosen = wanted ? all.filter((t) => t.name === wanted) : all;
34965
34875
  if (chosen.length === 0) {
34966
- process.stderr.write(`crew selftest: no toolchain "${wanted}" (have: ${all.map((t) => t.name).join(", ")})
34967
- `);
34968
- process.exit(2);
34876
+ die("crew selftest", `no toolchain "${wanted}" (have: ${all.map((t) => t.name).join(", ")})`, "name one of those, or omit it to test them all");
34969
34877
  }
34970
34878
  if (!route2.resolved) {
34971
34879
  die("crew selftest", `route ${route2.route} is not connected`, "`crew connect`");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.151.0",
3
+ "version": "0.151.2",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",