@tablation/crew 0.149.5 → 0.150.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +591 -213
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -15993,6 +15993,56 @@ function doctorSelftestLines(stored, toolchains) {
15993
15993
  });
15994
15994
  }
15995
15995
 
15996
+ // src/self-launch-check.ts
15997
+ import { spawn as spawn8 } from "child_process";
15998
+ var SELF_LAUNCH_TIMEOUT_MS = 15e3;
15999
+ function selfLaunchVerdict(child, own) {
16000
+ const printed = `${child.stdout}${child.stderr}`.trim();
16001
+ const fail2 = (why) => ({ ok: false, message: `self-launch failed: ${why}${printed ? `
16002
+ child printed:
16003
+ ${printed}` : ""}` });
16004
+ if (child.timedOut) return fail2("the child did not finish in time");
16005
+ if (child.code !== 0) return fail2(`the child exited ${child.code === null ? "on a signal" : child.code}`);
16006
+ let parsed;
16007
+ try {
16008
+ parsed = JSON.parse(child.stdout);
16009
+ } catch {
16010
+ return fail2("the child did not print a JSON object");
16011
+ }
16012
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return fail2("the child did not print a JSON object");
16013
+ const obj = parsed;
16014
+ if (obj.version !== own.version) return fail2(`the child reports version ${JSON.stringify(obj.version)}, this process is ${own.version}`);
16015
+ if (obj.compiled !== own.compiled) return fail2(`the child reports compiled ${JSON.stringify(obj.compiled)}, this process is ${own.compiled}`);
16016
+ return { ok: true, message: `self-launch ok: ${own.version}${own.compiled ? " (compiled)" : ""}` };
16017
+ }
16018
+ var spawnChild = (launch, args, timeoutMs) => new Promise((resolve8) => {
16019
+ const child = spawn8(launch.command, [...launch.args, ...args], { stdio: ["ignore", "pipe", "pipe"] });
16020
+ let stdout = "";
16021
+ let stderr = "";
16022
+ let timedOut = false;
16023
+ const timer = setTimeout(() => {
16024
+ timedOut = true;
16025
+ child.kill("SIGKILL");
16026
+ }, timeoutMs);
16027
+ child.stdout.on("data", (d) => {
16028
+ stdout += d.toString("utf8");
16029
+ });
16030
+ child.stderr.on("data", (d) => {
16031
+ stderr += d.toString("utf8");
16032
+ });
16033
+ child.on("error", (e) => {
16034
+ clearTimeout(timer);
16035
+ resolve8({ code: null, stdout, stderr: `${stderr}${e.message}`, timedOut });
16036
+ });
16037
+ child.on("close", (code) => {
16038
+ clearTimeout(timer);
16039
+ resolve8({ code, stdout, stderr, timedOut });
16040
+ });
16041
+ });
16042
+ async function runSelfLaunchCheck(own, spawnFn = spawnChild, launch = selfLaunch(), timeoutMs = SELF_LAUNCH_TIMEOUT_MS) {
16043
+ return selfLaunchVerdict(await spawnFn(launch, ["--version", "--json"], timeoutMs), own);
16044
+ }
16045
+
15996
16046
  // src/cli.ts
15997
16047
  import { resolve as resolve7, dirname as dirname37, join as join64, basename as basename17 } from "path";
15998
16048
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -23504,7 +23554,7 @@ async function runFleetPass(o) {
23504
23554
  }
23505
23555
  }
23506
23556
  async function fillSlots(o, routes, first) {
23507
- const spawn13 = o.spawnRoleAgent ?? runRoleAgent;
23557
+ const spawn14 = o.spawnRoleAgent ?? runRoleAgent;
23508
23558
  const breaker = o.spawnBreaker ?? new SpawnBreaker();
23509
23559
  const fleet = routes.length > 1;
23510
23560
  const rankOf = (c) => c.decision.selection.ranks[c.role] ?? Number.POSITIVE_INFINITY;
@@ -23548,7 +23598,7 @@ async function fillSlots(o, routes, first) {
23548
23598
  settle = resolve8;
23549
23599
  });
23550
23600
  const ready = (tookTicket2) => settle(tookTicket2);
23551
- const run4 = spawn13(role, decision, ctx, { ready }).then(() => {
23601
+ const run4 = spawn14(role, decision, ctx, { ready }).then(() => {
23552
23602
  breaker.recordSuccess(role);
23553
23603
  clearShipAttention(state, `role_parked:${role}`);
23554
23604
  clearShipAttention(state, workspaceAuthKey(role));
@@ -24915,6 +24965,90 @@ function renderInbox(items, byConnection = false, subject) {
24915
24965
  return out.join("\n");
24916
24966
  }
24917
24967
 
24968
+ // src/status-render.ts
24969
+ var WAITING_SHOWN = 5;
24970
+ var plural = (n, w, many = `${w}s`) => `${n} ${n === 1 ? w : many}`;
24971
+ function stateWord(v) {
24972
+ const bits = [];
24973
+ if (v.crewPaused) bits.push("crew paused");
24974
+ else if (v.releasePaused) bits.push("release paused");
24975
+ for (const r of v.pausedRoles) bits.push(`${r} paused`);
24976
+ if (!v.route.enabled) bits.push("route disabled");
24977
+ return bits.length ? bits.join(", ") : "active";
24978
+ }
24979
+ var byRecent = (items, at) => [...items].sort((a, b) => Date.parse(at(b) ?? "") - Date.parse(at(a) ?? "") || 0);
24980
+ function waitingReasonCounts(w) {
24981
+ const counts = /* @__PURE__ */ new Map();
24982
+ for (const t of w) for (const r of t.reasons) counts.set(r, (counts.get(r) ?? 0) + 1);
24983
+ return [...counts].map(([r, n]) => `${r} ${n}`).join(", ");
24984
+ }
24985
+ var waitingLine = (t) => `${t.key} \u2014 ${t.reasons.join(", ")}${t.title ? ` \u2014 ${t.title}` : ""}`;
24986
+ function renderStatus(v, opts) {
24987
+ const now = opts.now ?? Date.now();
24988
+ const out = [];
24989
+ const verbose = opts.verbose;
24990
+ out.push(`${v.ship.name} \xB7 ${v.route.name} \xB7 ${stateWord(v)}`);
24991
+ if (v.runs.length) {
24992
+ for (const x of v.runs) {
24993
+ out.push(`running: ${x.role} \u2014 ${x.ticket ?? "(no ticket)"}${x.repo ? ` in ${x.repo}` : ""} for ${since(x.spawnedAt, now)}` + (verbose ? ` (pid ${x.pid}, since ${x.spawnedAt}${x.deadline ? `, deadline ${x.deadline}` : ""})` : ""));
24994
+ }
24995
+ } else {
24996
+ const last = byRecent(v.lastRuns, (l) => l.finishedAt)[0];
24997
+ out.push(last ? `running: nothing (last run ${since(last.finishedAt, now)} ago)` : "running: nothing");
24998
+ }
24999
+ if (v.reloadRequestedSecondsAgo !== null) {
25000
+ out.push(`reload: requested ${v.reloadRequestedSecondsAgo}s ago, not yet honored \u2014 \`crew reload --now\` forces it`);
25001
+ }
25002
+ const own = byRecent(v.attention, (a) => a.since);
25003
+ const others = v.ships.filter((s) => s.name !== v.ship.name && s.attention.length);
25004
+ const unsafe = v.repos.filter((r) => r.unsafeDetail);
25005
+ if (own.length || others.length || unsafe.length || v.heldReleases.length || v.starved) {
25006
+ out.push("needs attention:");
25007
+ for (const i of own) out.push(` ${i.kind} \u2014 ${i.message}`);
25008
+ for (const r of unsafe) out.push(` base ${r.name} \u2014 UNSAFE, no worktree cuts or releases: ${r.unsafeDetail}`);
25009
+ for (const l of v.heldReleases) out.push(` release: ${l}`);
25010
+ if (v.starved) {
25011
+ out.push(` waiting: ${v.starved.ticket} for ${since(v.starved.since, now)} (passed over ${plural(v.starved.streak, "cycle")} running)`);
25012
+ }
25013
+ for (const s of others) {
25014
+ if (verbose) for (const i of s.attention) out.push(` ship ${s.name}: ${i.kind} \u2014 ${i.message}`);
25015
+ else out.push(` ship ${s.name}: ${plural(s.attention.length, "item")} (\`crew status --verbose\` lists them)`);
25016
+ }
25017
+ }
25018
+ if (v.waiting.length) {
25019
+ const sorted2 = byRecent(v.waiting, (t) => t.updatedAt);
25020
+ out.push(`waiting on you: ${v.waiting.length} (${waitingReasonCounts(v.waiting)})`);
25021
+ const shown = verbose ? sorted2 : sorted2.slice(0, WAITING_SHOWN);
25022
+ for (const t of shown) out.push(` ${waitingLine(t)}`);
25023
+ if (shown.length < sorted2.length) out.push(` \u2026 ${sorted2.length - shown.length} more (\`crew status --verbose\` lists all)`);
25024
+ }
25025
+ const notable = v.repos.filter((r) => verbose || r.notable);
25026
+ for (const r of notable) out.push(`releaser: ${r.name} \u2014 ${r.releaser}`);
25027
+ const rest = v.repos.length - notable.length;
25028
+ if (rest > 0) out.push(`releases: ${plural(rest, "repository", "repositories")} idle, no lock held`);
25029
+ for (const s of v.ships.filter((x) => x.name !== v.ship.name)) out.push(`other ship: ${s.line}`);
25030
+ if (verbose) {
25031
+ out.push("");
25032
+ out.push(`ship: ${v.ship.name} (${v.ship.platform})`);
25033
+ out.push(`route: ${v.route.name} -> ${v.route.dir}`);
25034
+ out.push(`enabled: ${v.route.enabled}`);
25035
+ out.push(`crew: ${v.crewPaused ? "paused" : "active"}`);
25036
+ out.push(`release: ${v.releasePaused ? "paused" : "active"}`);
25037
+ for (const r of v.pausedRoles) out.push(`role ${r}: paused`);
25038
+ out.push(`periscopes: ${v.periscopes.summary}`);
25039
+ if (v.periscopes.relayUrl) out.push(`relay: ${v.periscopes.relayUrl}`);
25040
+ for (const p of v.periscopes.live) out.push(`periscope: ${p}`);
25041
+ out.push(`watermark: ${v.watermark}`);
25042
+ if (v.projects.length) out.push(`projects: ${v.projects.join(", ")}`);
25043
+ for (const l of byRecent(v.lastRuns, (x) => x.finishedAt)) {
25044
+ out.push(`last run: ${l.role} \u2014 ${l.ticket ?? "(no ticket)"} ${l.outcome}, ${since(l.finishedAt, now)} ago`);
25045
+ }
25046
+ const self = v.ships.find((s) => s.name === v.ship.name);
25047
+ if (self) out.push(`ship row: ${self.line}`);
25048
+ }
25049
+ return out;
25050
+ }
25051
+
24918
25052
  // src/connect.ts
24919
25053
  var ConnectHttpError = class extends Error {
24920
25054
  status;
@@ -26181,7 +26315,7 @@ function existingRepoConfig(f) {
26181
26315
  }
26182
26316
 
26183
26317
  // src/repos-hooks-agent.ts
26184
- import { spawn as spawn8, execFileSync as execFileSync15 } from "child_process";
26318
+ import { spawn as spawn9, execFileSync as execFileSync15 } from "child_process";
26185
26319
  import { realpathSync as realpathSync2 } from "fs";
26186
26320
  import { isAbsolute as isAbsolute3, relative } from "path";
26187
26321
  var AgentSuggestError = class extends Error {
@@ -26302,7 +26436,7 @@ async function runAgentSuggest(o) {
26302
26436
  const run4 = await new Promise((resolve8) => {
26303
26437
  let out = "";
26304
26438
  let err3 = "";
26305
- const child = spawn8(bin, args, { cwd: o.dir, env, detached: true, stdio: ["pipe", "pipe", "pipe"] });
26439
+ const child = spawn9(bin, args, { cwd: o.dir, env, detached: true, stdio: ["pipe", "pipe", "pipe"] });
26306
26440
  let settled = false;
26307
26441
  const settle = (r) => {
26308
26442
  if (settled) return;
@@ -26420,6 +26554,176 @@ function planSampleTicket(i) {
26420
26554
  };
26421
26555
  }
26422
26556
 
26557
+ // src/doctor-report.ts
26558
+ var DOCTOR_SECTIONS = [
26559
+ { id: "ship", title: "Ship" },
26560
+ { id: "tracker", title: "Tracker" },
26561
+ { id: "repositories", title: "Repositories" },
26562
+ { id: "seats", title: "Seats" },
26563
+ { id: "tools", title: "Tools" },
26564
+ { id: "passengers", title: "Periscopes, passengers and sandbox" }
26565
+ ];
26566
+ var RANK = { ok: 0, info: 1, note: 2, warning: 3, blocker: 4 };
26567
+ var worse = (a, b) => RANK[b] > RANK[a] ? b : a;
26568
+ function classifySeverity(label, text2) {
26569
+ const s = `${label} ${text2}`;
26570
+ if (/\b(BLOCKER|ERROR)\b/.test(s)) return "blocker";
26571
+ if (/^attention$/i.test(label)) return "warning";
26572
+ if (/\b(WARN|WARNING|ATTENTION|DEAD|NOT FOUND|NOT READY|NOT AVAILABLE|NOT installed|NO row|MISMATCH|STALE|FAILED)\b|\(missing\)|\bMISSING\b|\bnot registered\b|\b\d{3} —/.test(s)) return "warning";
26573
+ if (/\bNOTE\b|cannot enforce|\bnot run\b|release readiness|\babsent\b|\bmissing\b|^none\b|\bnot minted\b|could not (be )?check|\bunknown\b|no operator|\bwithout\b|discovery unavailable/.test(s)) return "note";
26574
+ return "ok";
26575
+ }
26576
+ var SECTION_BY_LABEL = [
26577
+ ["seats", /^(seat |operator identity|api key role|can mint|capability)/],
26578
+ ["passengers", /^(periscopes?\b|periscope mcp|host passengers|docker|ssh-keygen|image|relay (host|control|tunnel)|sandbox|attention|foreign launchd)/],
26579
+ ["tracker", /^(contract|authorship|runtime columns|link columns|public replies|crew assisted|release seat|ship (record|row|holds)|crew manifest|branch\/pull|pull request|branch links)/],
26580
+ ["tools", /^(agent binary|toolchain|git\b|mcp|pair\b|auth\b|credential helper|hook |repo toolchain|push auth|gh\b|node\b|docker\b)/],
26581
+ ["ship", /^(ship|routes?|bundle|role concurrency|persona avatar|key store|events log|scheduler unit|passengers unit|daemon|reload request|crew version)/]
26582
+ ];
26583
+ function sectionOf(label) {
26584
+ for (const [id, re] of SECTION_BY_LABEL) if (re.test(label)) return id;
26585
+ return void 0;
26586
+ }
26587
+ var LABEL_RE = /^([A-Za-z][\w.\-/ ]{0,38}?):\s+(\S.*)$/;
26588
+ var MARKER_RE = /^(WARNING|WARN|ERROR|BLOCKER|ATTENTION|NOTE|MISSING|NOT)\b/;
26589
+ var DoctorReport = class {
26590
+ findings = [];
26591
+ /** Set while a repository's block is being written; lines are filed under it and grouped across repositories. */
26592
+ repo;
26593
+ /** Repository names of the route; a line outside a repo block that names exactly one is grouped with the same line for the others. */
26594
+ repoNames = [];
26595
+ last;
26596
+ mentionedRepo(text2) {
26597
+ const hits = this.repoNames.filter((n) => text2.split("\n").some((l) => l.includes(`${n}:`) && new RegExp(`(?:^|[\\s/])${n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}:`).test(l)));
26598
+ return hits.length === 1 ? hits[0] : void 0;
26599
+ }
26600
+ /** Take one check's output (one or more lines, as it would have been printed). */
26601
+ line(raw, ctx = {}) {
26602
+ const repo = ctx.repo ?? this.repo;
26603
+ for (const physical of raw.split("\n")) {
26604
+ if (physical.trim() === "") continue;
26605
+ const continuation = /^\s{2,}/.test(physical);
26606
+ const body = physical.trim().replace(/^-\s+/, "");
26607
+ const m = MARKER_RE.test(body) ? null : /^(repo \S+?):(\/\S.*)$/.exec(body) ?? LABEL_RE.exec(body);
26608
+ if (continuation && this.last && !m && !MARKER_RE.test(body)) {
26609
+ this.last.text += `
26610
+ ${body}`;
26611
+ this.last.severity = worse(this.last.severity, classifySeverity("", body));
26612
+ continue;
26613
+ }
26614
+ const label = m ? m[1].trim() : "";
26615
+ const text2 = m ? m[2].trim() : body;
26616
+ const parent = continuation ? this.last : void 0;
26617
+ const section = repo ? "repositories" : sectionOf(label) ?? parent?.section ?? this.last?.section ?? "ship";
26618
+ const f = { severity: classifySeverity(label, text2), section, label, text: text2, ...repo ? { repo } : {} };
26619
+ if (!repo) {
26620
+ const mentions = this.mentionedRepo(text2);
26621
+ if (mentions) f.mentions = mentions;
26622
+ }
26623
+ this.findings.push(f);
26624
+ this.last = f;
26625
+ }
26626
+ }
26627
+ counts() {
26628
+ const merged = groupFindings(this.findings.filter((f) => RANK[f.severity] >= RANK.note));
26629
+ const c = { blocker: 0, warning: 0, note: 0, passed: 0 };
26630
+ for (const g of merged) c[g.severity]++;
26631
+ c.passed = this.findings.filter((f) => RANK[f.severity] < RANK.note).length;
26632
+ return c;
26633
+ }
26634
+ };
26635
+ function groupFindings(findings) {
26636
+ const out = [];
26637
+ const byKey = /* @__PURE__ */ new Map();
26638
+ for (const f of findings) {
26639
+ const repo = f.repo ?? f.mentions;
26640
+ if (!repo) {
26641
+ out.push({ ...f, repos: [] });
26642
+ continue;
26643
+ }
26644
+ const norm = (s) => s.split(repo).join("<repo>");
26645
+ const key = [f.severity, f.section, norm(f.label), norm(f.text)].join("\0");
26646
+ const hit = byKey.get(key);
26647
+ if (hit) {
26648
+ if (!hit.repos.includes(repo)) hit.repos.push(repo);
26649
+ continue;
26650
+ }
26651
+ const g = { ...f, repos: [repo] };
26652
+ byKey.set(key, g);
26653
+ out.push(g);
26654
+ }
26655
+ return out;
26656
+ }
26657
+ var plural2 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
26658
+ function reposPhrase(repos) {
26659
+ return repos.length <= 5 ? `repositories ${repos.join(", ")}` : `${repos.length} repositories (${repos.slice(0, 3).join(", ")}, \u2026)`;
26660
+ }
26661
+ var SEVERITY_WORD = { blocker: "BLOCKER", warning: "WARNING", note: "NOTE " };
26662
+ function verdictLine(c) {
26663
+ const parts = [];
26664
+ if (c.blocker) parts.push(plural2(c.blocker, "blocker"));
26665
+ if (c.warning) parts.push(plural2(c.warning, "warning"));
26666
+ if (c.note) parts.push(plural2(c.note, "note"));
26667
+ if (parts.length === 0) return `verdict: all clear \u2014 ${plural2(c.passed, "check")} passed`;
26668
+ const lead = c.blocker ? "needs action" : c.warning ? "usable, with warnings" : "ok, with notes";
26669
+ return `verdict: ${lead} \u2014 ${parts.join(", ")}; ${plural2(c.passed, "check")} passed`;
26670
+ }
26671
+ function indentContinuation(text2, pad) {
26672
+ return text2.split("\n").map((l, i) => i === 0 ? l : `${" ".repeat(pad)}${l}`).join("\n");
26673
+ }
26674
+ function renderDoctor(report, header, verbose) {
26675
+ const c = report.counts();
26676
+ const out = [...header];
26677
+ if (!verbose) {
26678
+ const shown = groupFindings(report.findings.filter((f) => RANK[f.severity] >= RANK.note)).sort((a, b) => RANK[b.severity] - RANK[a.severity]);
26679
+ for (const g of shown) {
26680
+ const sev = SEVERITY_WORD[g.severity];
26681
+ const where = g.repos.length ? ` [${reposPhrase(g.repos)}]` : "";
26682
+ const head = `${sev} ${g.label ? `${g.label}: ` : ""}`;
26683
+ let text2 = g.text.replace(/^(WARNING|WARN|NOTE|BLOCKER|ERROR|ATTENTION)\s+/, "");
26684
+ if (g.repos.length > 1) for (const r of g.repos) text2 = text2.split(r).join("<repo>");
26685
+ out.push(`${head}${indentContinuation(text2, 4)}${where}`);
26686
+ }
26687
+ if (shown.length) out.push("");
26688
+ if (c.passed) out.push(`${plural2(c.passed, "check")} passed (\`crew doctor --verbose\` lists them)`);
26689
+ out.push(verdictLine(c));
26690
+ return `${out.join("\n")}
26691
+ `;
26692
+ }
26693
+ for (const s of DOCTOR_SECTIONS) {
26694
+ const inSection = report.findings.filter((f) => f.section === s.id);
26695
+ if (inSection.length === 0) continue;
26696
+ out.push("", s.title, "-".repeat(s.title.length));
26697
+ const block = (items, indent, strip) => {
26698
+ const labelOf2 = (f) => strip && f.label === `repo ${strip}` ? "path" : f.label;
26699
+ const width = Math.min(26, Math.max(...items.map((f) => labelOf2(f) ? labelOf2(f).length + 1 : 0))) + 1;
26700
+ for (const f of items) {
26701
+ const l = labelOf2(f);
26702
+ const lab = l ? `${l}:` : "";
26703
+ const col = lab.length >= width ? `${lab} ` : lab.padEnd(width);
26704
+ out.push(`${" ".repeat(indent)}${col}${indentContinuation(f.text, indent + col.length)}`);
26705
+ }
26706
+ };
26707
+ if (s.id === "repositories") {
26708
+ const names = [...new Set(inSection.map((f) => f.repo ?? ""))];
26709
+ for (const n of names) {
26710
+ out.push(n ? ` ${n}` : "");
26711
+ block(inSection.filter((f) => (f.repo ?? "") === n), 4, n);
26712
+ }
26713
+ } else block(inSection, 0);
26714
+ }
26715
+ out.push("", verdictLine(c));
26716
+ return `${out.join("\n")}
26717
+ `;
26718
+ }
26719
+ function fixPhaseNothingToOffer(o) {
26720
+ const lines2 = o.notes.map((n) => `fix: ${n}`);
26721
+ if (!o.fixFlag) return lines2;
26722
+ const outstanding = o.blockers + o.warnings;
26723
+ lines2.push(outstanding ? `fix: no automatic fix applies; the ${plural2(outstanding, "finding")} above ${outstanding === 1 ? "needs" : "need"} action` : "fix: no automatic fix applies, and nothing needs one");
26724
+ return lines2;
26725
+ }
26726
+
26423
26727
  // src/worktree-sweep.ts
26424
26728
  import { existsSync as existsSync54, readFileSync as readFileSync53, readdirSync as readdirSync16 } from "fs";
26425
26729
  import { basename as basename14, dirname as dirname33, join as join56, resolve as resolve5 } from "path";
@@ -26855,7 +27159,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
26855
27159
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
26856
27160
  import { join as join58 } from "path";
26857
27161
  function builtVersion() {
26858
- return true ? "0.149.5" : null;
27162
+ return true ? "0.150.0" : null;
26859
27163
  }
26860
27164
  var REBUILD_HINT = "rebuild with npm run build";
26861
27165
  function newestMtime(path) {
@@ -26894,23 +27198,74 @@ function statSafe(p) {
26894
27198
  }
26895
27199
 
26896
27200
  // src/relay-probe.ts
26897
- async function probeRelayControl(relayUrl, apiKey, userAgent, fetchFn = fetch, timeoutMs = 1e4) {
26898
- const started = Date.now();
27201
+ var LIVENESS_TIMEOUT_MS = 1e4;
27202
+ var STATUS_TIMEOUT_MS = 75e3;
27203
+ var BODY_LIMIT = 4096;
27204
+ async function boundedText(res) {
26899
27205
  try {
26900
- const res = await fetchFn(`${relayUrl.replace(/\/+$/, "")}/control/status`, {
26901
- headers: { Authorization: `Bearer ${apiKey}`, "User-Agent": userAgent },
26902
- signal: AbortSignal.timeout(timeoutMs)
26903
- });
26904
- const latencyMs = Date.now() - started;
26905
- await res.arrayBuffer().catch(() => void 0);
26906
- if (res.ok) return { ok: true, status: res.status, latencyMs };
26907
- return { ok: false, status: res.status, error: `HTTP ${res.status}` };
26908
- } catch (e) {
26909
- return { ok: false, error: e.message };
27206
+ return (await res.text()).slice(0, BODY_LIMIT);
27207
+ } catch {
27208
+ return "";
27209
+ }
27210
+ }
27211
+ function parseObject(text2) {
27212
+ try {
27213
+ const v = JSON.parse(text2);
27214
+ return v && typeof v === "object" && !Array.isArray(v) ? v : null;
27215
+ } catch {
27216
+ return null;
26910
27217
  }
26911
27218
  }
27219
+ var oneLine2 = (s, max = 200) => s.replace(/\s+/g, " ").trim().slice(0, max);
27220
+ function classify2(res, text2, step) {
27221
+ const status2 = res.status;
27222
+ if (status2 === 401 || status2 === 403) {
27223
+ return { ok: false, kind: "key_refused", status: status2, error: `the ship's control API refused this route's key (HTTP ${status2})`, remedy: "run `crew connect <route>` to mint and store a key the ship accepts" };
27224
+ }
27225
+ const body = parseObject(text2);
27226
+ if (body && typeof body.reason === "string") {
27227
+ const detail = typeof body.detail === "string" ? `: ${oneLine2(body.detail, 400)}` : "";
27228
+ return { ok: false, kind: "status_failed", status: status2, error: `the ship could not build its status document (${body.reason}${detail})`, remedy: "run `crew status <route> --json` on the ship to see the error" };
27229
+ }
27230
+ if (status2 >= 500 && !body) {
27231
+ const said = oneLine2(text2, 80);
27232
+ return { ok: false, kind: "tunnel_down", status: status2, error: `the relay could not reach the ship's tunnel (HTTP ${status2}${said ? `, "${said}"` : ""})`, remedy: "run `crew passengers` and check the tunnel state doctor prints above" };
27233
+ }
27234
+ return { ok: false, kind: "http", status: status2, error: `HTTP ${status2}${step === "status" ? " from /control/status" : ""}` };
27235
+ }
27236
+ async function probeRelayControl(relayUrl, apiKey, userAgent, fetchFn = fetch, livenessTimeoutMs = LIVENESS_TIMEOUT_MS, statusTimeoutMs = STATUS_TIMEOUT_MS) {
27237
+ const base = relayUrl.replace(/\/+$/, "");
27238
+ const headers = { Authorization: `Bearer ${apiKey}`, "User-Agent": userAgent };
27239
+ const step = async (path, timeoutMs, which) => {
27240
+ const started = Date.now();
27241
+ try {
27242
+ const res = await fetchFn(`${base}${path}`, { headers, signal: AbortSignal.timeout(timeoutMs) });
27243
+ const text2 = await boundedText(res);
27244
+ const latencyMs = Date.now() - started;
27245
+ if (res.ok) {
27246
+ const route2 = parseObject(text2)?.route;
27247
+ return { ok: true, status: res.status, latencyMs, route: typeof route2 === "string" ? route2 : void 0 };
27248
+ }
27249
+ return classify2(res, text2, which);
27250
+ } catch (e) {
27251
+ const name = e.name;
27252
+ if (name === "TimeoutError" || name === "AbortError") {
27253
+ return { ok: false, kind: "timed_out", error: `no answer from ${path} after ${Math.round((Date.now() - started) / 1e3)}s` };
27254
+ }
27255
+ return { ok: false, kind: "network", error: e.message };
27256
+ }
27257
+ };
27258
+ const live2 = await step("/control/streams", livenessTimeoutMs, "liveness");
27259
+ if (!live2.ok) return live2;
27260
+ const status2 = await step("/control/status", statusTimeoutMs, "status");
27261
+ return status2.ok ? { ...status2, latencyMs: live2.latencyMs + status2.latencyMs } : status2;
27262
+ }
26912
27263
  function describeRelayProbe(url, p) {
26913
- return p.ok ? `relay control: OK ${url}/control/status (${p.status}, ${p.latencyMs} ms)` : `relay control: FAILED ${url}/control/status \u2014 ${p.error}`;
27264
+ if (p.ok) {
27265
+ return `relay control: OK ${url}/control/status (${p.status}, ${p.latencyMs} ms${p.route ? `, route ${p.route}` : ""})`;
27266
+ }
27267
+ return `relay control: FAILED ${url}/control/status \u2014 ${p.error}${p.remedy ? `
27268
+ fix: ${p.remedy}` : ""}`;
26914
27269
  }
26915
27270
 
26916
27271
  // src/ship-status.ts
@@ -27043,7 +27398,7 @@ async function unregisterEndpoint(workspaceId, info, d) {
27043
27398
 
27044
27399
  // src/passenger-sync-daemon.ts
27045
27400
  import { createServer as createHttpServer } from "http";
27046
- import { spawn as spawn9 } from "child_process";
27401
+ import { spawn as spawn10 } from "child_process";
27047
27402
  import { randomBytes as randomBytes2 } from "crypto";
27048
27403
  import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync54, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
27049
27404
  import { join as join59 } from "path";
@@ -27134,7 +27489,7 @@ function runSyncDaemonFromEnv(env = process.env) {
27134
27489
  return server;
27135
27490
  }
27136
27491
  var defaultSpawn2 = (cmd, args, env) => {
27137
- const child = spawn9(cmd, args, { detached: true, stdio: "ignore", env });
27492
+ const child = spawn10(cmd, args, { detached: true, stdio: "ignore", env });
27138
27493
  child.unref();
27139
27494
  return child;
27140
27495
  };
@@ -27232,7 +27587,7 @@ function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
27232
27587
  }
27233
27588
 
27234
27589
  // src/periscope-proxy.ts
27235
- import { spawn as spawn10 } from "child_process";
27590
+ import { spawn as spawn11 } from "child_process";
27236
27591
  import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "fs";
27237
27592
  import { createServer, request as httpRequest } from "http";
27238
27593
  import { request as httpsRequest } from "https";
@@ -27587,7 +27942,7 @@ async function launchProxy(invocation, worktree, previewUrl, number, o) {
27587
27942
  if (stale.length) await killGently(stale);
27588
27943
  const launch = { worktree, target: previewUrl, host: o.host, port, inject: o.inject };
27589
27944
  const [cmd, ...args] = invocation;
27590
- const child = spawn10(cmd, [...args, "periscope-proxy", pointedAtFile(worktree)], {
27945
+ const child = spawn11(cmd, [...args, "periscope-proxy", pointedAtFile(worktree)], {
27591
27946
  detached: true,
27592
27947
  stdio: "ignore",
27593
27948
  cwd: worktree,
@@ -27680,10 +28035,10 @@ import {
27680
28035
  import { createConnection } from "net";
27681
28036
  import { createServer as createServer2 } from "http";
27682
28037
  import { basename as basename15, dirname as dirname35, join as join61 } from "path";
27683
- import { execFile as execFile6, spawn as spawn12 } from "child_process";
28038
+ import { execFile as execFile6, spawn as spawn13 } from "child_process";
27684
28039
 
27685
28040
  // src/periscope-control.ts
27686
- import { spawn as spawn11 } from "child_process";
28041
+ import { spawn as spawn12 } from "child_process";
27687
28042
  var reply = (status2, body) => ({ status: status2, body });
27688
28043
  var err = (status2, message) => reply(status2, { error: message });
27689
28044
  var TICKET_RE = /^(?:[A-Za-z]+-)?\d+$/;
@@ -27883,7 +28238,7 @@ async function handlePeriscopes(h, q2) {
27883
28238
  function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
27884
28239
  return new Promise((resolve8) => {
27885
28240
  const self = selfLaunch();
27886
- const child = spawn11(self.command, [...self.args, ...args], { stdio: ["ignore", "pipe", "pipe"] });
28241
+ const child = spawn12(self.command, [...self.args, ...args], { stdio: ["ignore", "pipe", "pipe"] });
27887
28242
  let stdout = "";
27888
28243
  let stderr = "";
27889
28244
  let pending = "";
@@ -28118,6 +28473,14 @@ function waitForChange(dir, ms3, signal) {
28118
28473
  }
28119
28474
  var reply2 = (status2, body) => ({ status: status2, body });
28120
28475
  var err2 = (status2, message) => reply2(status2, { error: message });
28476
+ function failureReply(what, f, log) {
28477
+ log?.(`control API: could not produce the ${what} document: ${f.reason}: ${f.detail}`);
28478
+ return reply2(502, {
28479
+ error: `could not produce the ${what === "status" ? "status document" : "doctor report"}`,
28480
+ reason: f.reason,
28481
+ detail: f.detail
28482
+ });
28483
+ }
28121
28484
  function pauseDoc(state) {
28122
28485
  return {
28123
28486
  crew: state.isPaused(),
@@ -28236,10 +28599,11 @@ async function route(deps, method, url, req, abort) {
28236
28599
  });
28237
28600
  }
28238
28601
  if (p === "/status" && get2) {
28239
- const doc = await deps.status();
28240
- if (!doc) return err2(502, "could not produce the status document");
28602
+ const out = await deps.status();
28603
+ if (!out.ok) return failureReply("status", out, deps.log);
28241
28604
  return reply2(200, {
28242
- ...doc,
28605
+ ...out.doc,
28606
+ ...deps.route ? { route: deps.route } : {},
28243
28607
  daemon: {
28244
28608
  alive: true,
28245
28609
  pid: process.pid,
@@ -28281,8 +28645,8 @@ async function route(deps, method, url, req, abort) {
28281
28645
  return r.accepted ? reply2(202, { accepted: true, detail: r.detail }) : err2(409, r.detail);
28282
28646
  }
28283
28647
  if (p === "/doctor" && get2) {
28284
- const doc = await deps.doctor();
28285
- return doc ? reply2(200, doc) : err2(502, "could not produce the doctor report");
28648
+ const out = await deps.doctor();
28649
+ return out.ok ? reply2(200, out.doc) : failureReply("doctor", out, deps.log);
28286
28650
  }
28287
28651
  if (p === "/diagnostics" && get2 && deps.diagnostics) return reply2(200, await deps.diagnostics());
28288
28652
  const known = ["/status", "/events", "/streams", "/pause", "/resume", "/release/pause", "/release/resume", "/doctor", ...deps.diagnostics ? ["/diagnostics"] : []];
@@ -28378,7 +28742,7 @@ async function startControlServer(deps) {
28378
28742
  });
28379
28743
  }
28380
28744
  var shq2 = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
28381
- function runDetached(commands, spawnFn = spawn12) {
28745
+ function runDetached(commands, spawnFn = spawn13) {
28382
28746
  const script = `sleep 1; ${commands.map((c) => c.map(shq2).join(" ")).join("; ")}`;
28383
28747
  const child = spawnFn("/bin/sh", ["-c", script], { detached: true, stdio: "ignore" });
28384
28748
  child.on("error", () => {
@@ -28394,16 +28758,28 @@ function schedulerHandler(control, run4 = runDetached) {
28394
28758
  return { accepted: true, detail: `${action} requested` };
28395
28759
  };
28396
28760
  }
28397
- function crewJson(args, timeoutMs = 6e4) {
28761
+ var CREW_JSON_TIMEOUT_MS = 6e4;
28762
+ function stderrTail(stderr, lines2 = 5, maxChars = 600) {
28763
+ const tail3 = stderr.trim().split("\n").slice(-lines2).join("\n").replace(/\bsk_[A-Za-z0-9_-]+/g, "sk_***").replace(/(Bearer\s+)\S+/gi, "$1***");
28764
+ return tail3.length > maxChars ? `\u2026${tail3.slice(-maxChars)}` : tail3;
28765
+ }
28766
+ function crewJson(args, timeoutMs = CREW_JSON_TIMEOUT_MS) {
28398
28767
  return new Promise((resolve8) => {
28399
28768
  const self = selfLaunch();
28400
- execFile6(self.command, [...self.args, ...args], { timeout: timeoutMs, maxBuffer: 16 * 1024 * 1024 }, (_e, stdout) => {
28769
+ execFile6(self.command, [...self.args, ...args], { timeout: timeoutMs, maxBuffer: 16 * 1024 * 1024 }, (e, stdout, stderr) => {
28401
28770
  try {
28402
28771
  const v = JSON.parse(String(stdout));
28403
- resolve8(v && typeof v === "object" && !Array.isArray(v) ? v : null);
28772
+ if (v && typeof v === "object" && !Array.isArray(v)) return resolve8({ ok: true, doc: v });
28404
28773
  } catch {
28405
- resolve8(null);
28406
28774
  }
28775
+ const ex = e;
28776
+ const tail3 = stderrTail(String(stderr ?? ""));
28777
+ if (ex?.killed || ex?.code === "ETIMEDOUT") return resolve8({ ok: false, reason: "timed_out", detail: `no JSON within ${Math.round(timeoutMs / 1e3)}s${tail3 ? `; stderr: ${tail3}` : ""}` });
28778
+ if (ex) {
28779
+ const how = typeof ex.code === "number" ? `exit code ${ex.code}` : ex.signal ? `signal ${ex.signal}` : `error ${String(ex.code ?? ex.message)}`;
28780
+ return resolve8({ ok: false, reason: "exited", detail: `${how}${tail3 ? `; stderr: ${tail3}` : ""}` });
28781
+ }
28782
+ resolve8({ ok: false, reason: "bad_output", detail: `exit 0 but stdout is not a JSON object (${String(stdout).length} bytes)${tail3 ? `; stderr: ${tail3}` : ""}` });
28407
28783
  });
28408
28784
  });
28409
28785
  }
@@ -28981,7 +29357,7 @@ function usage(problem, requested = false) {
28981
29357
  crew deploy [route] release now, even with nothing new to merge
28982
29358
  crew watch [route] live view of what the crew is doing
28983
29359
  crew --version [--json] print the crew version on one line (also: crew version); --json adds home and compiled
28984
- crew status [route] [--json] paused/running state; --json for a machine reader
29360
+ crew status [route] [--json] [--verbose] what is running and what needs a person; --verbose adds configuration and full lists; --json for a machine reader
28985
29361
  crew projects [--route R] [--json] the Projects rows each route can read (id, name, prefix, work mode)
28986
29362
  crew provision --key K --route WS[/PROJECT] [--forge-host H] [--ship-name N] [--json] one non-interactive run: connect, forge tokens,
28987
29363
  enable routes, install units with lingering, start the daemon; safe to re-run (CREW_CONNECT_KEY,
@@ -28994,7 +29370,7 @@ function usage(problem, requested = false) {
28994
29370
  crew credential get|store|erase git credential helper answering from ship.forges (git runs it; not for hand use)
28995
29371
  crew whoami [route] [--json] the signed-in identity, key role, operator Crew row and credential source per route
28996
29372
  crew reload make the running daemon re-read crew.yaml (--now: restart it immediately)
28997
- crew doctor [route] [--fix] [--offline] [--json] preflight; --fix enables clean routes and offers crew install;
29373
+ crew doctor [route] [--fix] [--offline] [--verbose] [--json] preflight: findings first, then a verdict; --verbose lists every check; --fix enables clean routes and offers crew install;
28998
29374
  --offline skips push probes; --json prints push-auth and tool checks only
28999
29375
  crew selftest [route] [--toolchain NAME] [--json] launch each toolchain as a run would and prove it reaches the tracker
29000
29376
  crew sample-ticket [route] [--remove] [--dry-run] [--json] file one ticket on a throwaway repo that walks the dev, QA and release loop
@@ -29076,6 +29452,12 @@ if (versionReq) {
29076
29452
  `);
29077
29453
  process.exit(0);
29078
29454
  }
29455
+ if (argv[0] === "self-launch-check") {
29456
+ const verdict = await runSelfLaunchCheck({ version: crewVersion(CREW_HOME), compiled: isCompiledBinary(import.meta.url) });
29457
+ (verdict.ok ? process.stdout : process.stderr).write(`${verdict.message}
29458
+ `);
29459
+ process.exit(verdict.ok ? 0 : 1);
29460
+ }
29079
29461
  var staleBundle = bundleStaleness({ built: builtVersion(), current: crewVersion(CREW_HOME), home: CREW_HOME, compiled: isCompiledBinary(import.meta.url) });
29080
29462
  if (staleBundle) process.stderr.write(`crew: warning: ${staleBundle.message}
29081
29463
  `);
@@ -29987,12 +30369,13 @@ if (command === "passenger-sync-daemon") {
29987
30369
  const crontab = o.host === "linux" ? spawnSync14("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
29988
30370
  const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
29989
30371
  const plan = planFix({ routes, schedulerAbsent, host: o.host });
29990
- for (const n of plan.notes) process.stdout.write(`fix: ${n}
29991
- `);
29992
30372
  if (plan.actions.length === 0) {
29993
- process.stdout.write("fix: nothing to change\n");
30373
+ for (const l of fixPhaseNothingToOffer({ notes: plan.notes, fixFlag: o.fixFlag, blockers: o.blockers, warnings: o.warnings })) process.stdout.write(`${l}
30374
+ `);
29994
30375
  return;
29995
30376
  }
30377
+ for (const n of plan.notes) process.stdout.write(`fix: ${n}
30378
+ `);
29996
30379
  const prompter = o.prompt ? terminalPrompter() : void 0;
29997
30380
  const changed2 = [];
29998
30381
  const enabledSound = new Set(routes.filter((r) => r.enabled && r.hasRepos && r.problems.length === 0).map((r) => r.route));
@@ -30166,13 +30549,14 @@ ${changed2.map((c) => ` - ${c}
30166
30549
  async function releaserLine(tracker, routeName, repo, release) {
30167
30550
  const who2 = release.ship ? `released by ${release.ship}` : "any ship may release";
30168
30551
  let lock2;
30552
+ let lockHeld = false;
30169
30553
  try {
30170
30554
  const st = await tracker.lockState(releaseLockScope(routeName, repo));
30171
- lock2 = st === void 0 ? "no Locks table" : !st.exists ? "lock row MISSING (run crew connect)" : st.holder ? `lock held by ${st.holder}` : "lock row free";
30555
+ lock2 = st === void 0 ? "no Locks table" : !st.exists ? "lock row MISSING (run crew connect)" : st.holder ? (lockHeld = true, `lock held by ${st.holder}`) : "lock row free";
30172
30556
  } catch (e) {
30173
30557
  lock2 = `lock unreadable (${e.message})`;
30174
30558
  }
30175
- return `${who2}; ${lock2}`;
30559
+ return { line: `${who2}; ${lock2}`, lockHeld };
30176
30560
  }
30177
30561
  async function sweepClosedTickets(c, target, branch, tracker, dryRun2, remit, idle = false) {
30178
30562
  if (remoteOf(target.dir)) return;
@@ -31576,6 +31960,7 @@ ${f.tail.trimEnd()}
31576
31960
  }
31577
31961
  },
31578
31962
  periscopeMcp: controlRoutes.some((r) => r.enabled && r.hostPeriscopes) ? (req, res, ticket) => handlePeriscopeMcp(periscopeMcpDeps(), req, res, ticket) : void 0,
31963
+ route: primary.route,
31579
31964
  status: () => crewJson(["status", primary.route, "--json"]),
31580
31965
  doctor: () => crewJson(["doctor", primary.route, "--json", "--offline"]),
31581
31966
  diagnostics: () => collectDiagnostics({
@@ -31584,7 +31969,10 @@ ${f.tail.trimEnd()}
31584
31969
  runner: cfg.ship.runner ?? "host",
31585
31970
  unitStems: detectSystemd() ? ["run", "release", "passengers"].map((j) => labelFor(CREW_HOME, j)) : [],
31586
31971
  userScope: process.getuid?.() !== 0,
31587
- doctor: () => crewJson(["doctor", primary.route, "--json", "--offline"])
31972
+ doctor: async () => {
31973
+ const o = await crewJson(["doctor", primary.route, "--json", "--offline"]);
31974
+ return o.ok ? o.doc : null;
31975
+ }
31588
31976
  }),
31589
31977
  scheduler: schedulerHandler(planDaemonControl(CREW_HOME, hostPlatform(), detectSystemd())),
31590
31978
  log: (m) => emit.warn(m)
@@ -34664,81 +35052,63 @@ ${where.join("\n")}`);
34664
35052
  `);
34665
35053
  break;
34666
35054
  }
34667
- const owed = [
34668
- ...todo.map((i) => `${displayKey(i.ticket)} \u2014 ${i.reasons.join(", ")}${i.ticket.title ? ` \u2014 ${i.ticket.title}` : ""}`),
34669
- ...openShipAttention(state).map((i) => `ship ${cfg.ship.name}: ${i.kind} \u2014 ${i.message}`),
34670
- ...shipRows.filter((s) => s.name !== cfg.ship.name).flatMap((s) => (s.attention ?? []).map((i) => `ship ${s.name}: ${i.kind} \u2014 ${i.message}`))
34671
- ];
34672
- if (owed.length) process.stdout.write(`to do (${owed.length}):
34673
- ${owed.map((l) => ` ${l}
34674
- `).join("")}
34675
- `);
34676
- process.stdout.write(
34677
- `ship: ${cfg.ship.name} (${cfg.ship.platform})
34678
- route: ${route2.route} -> ${route2.dir}
34679
- enabled: ${route2.enabled}
34680
- periscopes: ${periscopeSummary(cfg)}
34681
- ` + (routeRelayUrl(route2) ? `relay: ${routeRelayUrl(route2)}
34682
- ` : "") + periscopes.map((p) => `periscope: ${p.ticket} ${p.repo} ${p.url} ${p.state}${p.serving ? "" : " (not serving)"} expires ${p.expiresAt}
34683
- `).join("") + `crew: ${state.isPaused() ? "paused" : "active"}
34684
- release: ${state.releaseSkipReason() ? "paused" : "active"}
34685
- watermark: ${state.watermark(routeSlug(route2.route))}
34686
- `
34687
- );
34688
- for (const r of ["dev", "design", "qa"]) {
34689
- if (state.isRolePaused(r)) process.stdout.write(`role ${r}: paused
34690
- `);
34691
- }
34692
- const reloadWaitingAt = readReloadRequestedAt(cfg.ship.stateDir);
34693
- if (reloadWaitingAt !== null) {
34694
- process.stdout.write(`reload: requested ${Math.max(0, Math.round((Date.now() - reloadWaitingAt) / 1e3))}s ago, not yet honored \u2014 \`crew reload --now\` forces it
34695
- `);
34696
- }
34697
- if (projects.length) process.stdout.write(`projects: ${projects.map((p) => p.label).join(", ")}
34698
- `);
34699
- for (const i of openShipAttention(state)) {
34700
- process.stdout.write(`attention: ${i.kind} \u2014 ${i.message}
34701
- `);
34702
- }
34703
- for (const r of await resolvedRepos(route2)) {
34704
- const bh = baseHealth(r);
34705
- if (bh.unsafe) process.stdout.write(`base: ${r.name} \u2014 UNSAFE, no worktree cuts or releases: ${bh.detail}
34706
- `);
34707
- process.stdout.write(`releaser: ${r.name} \u2014 ${await releaserLine(statusTracker, route2.route, r.name, r.config.release)}
34708
- `);
34709
- }
35055
+ const shipAttention = openShipAttention(state);
35056
+ let heldReleases = [];
34710
35057
  try {
34711
35058
  const open = await statusTracker.openTickets();
34712
- const held = heldByBlockers(
35059
+ heldReleases = describeHeld(heldByBlockers(
34713
35060
  open,
34714
35061
  statusTracker.contract.statuses.verified,
34715
35062
  blockerInfoMap(open, await statusTracker.ticketsByIds(missingBlockerIds(open)))
34716
- );
34717
- for (const line of describeHeld(held)) process.stdout.write(`release: ${line}
34718
- `);
35063
+ ));
34719
35064
  } catch {
34720
35065
  }
34721
- if (waiting) {
34722
- process.stdout.write(
34723
- `waiting: ${waiting.ticket} for ${since(waiting.since)} (passed over ${fairness.streak()} cycle${fairness.streak() === 1 ? "" : "s"} running)
34724
- `
34725
- );
34726
- }
34727
- for (const x of runs) {
34728
- process.stdout.write(`running: ${x.role} \u2014 ${x.ticket ?? "(no ticket)"}${x.repo ? ` in ${x.repo}` : ""} (pid ${x.pid}, since ${x.spawnedAt}${x.deadline ? `, deadline ${x.deadline}` : ""})
34729
- `);
35066
+ const repoViews = [];
35067
+ for (const r of await resolvedRepos(route2)) {
35068
+ const bh = baseHealth(r);
35069
+ const rel = await releaserLine(statusTracker, route2.route, r.name, r.config.release);
35070
+ repoViews.push({
35071
+ name: r.name,
35072
+ unsafeDetail: bh.unsafe ? bh.detail : void 0,
35073
+ releaser: rel.line,
35074
+ notable: rel.lockHeld || !!r.config.release.ship && r.config.release.ship !== cfg.ship.name
35075
+ });
34730
35076
  }
34731
- if (shipRows.length) {
34732
- process.stdout.write("ships:\n");
34733
- for (const s of shipRows) {
34734
- process.stdout.write(` ${renderShipLine(s, issueLabelById)}
34735
- `);
34736
- if (s.name !== cfg.ship.name) {
34737
- for (const i of s.attention ?? []) process.stdout.write(` attention: ${i.kind} \u2014 ${i.message}
35077
+ const reloadWaitingAt = readReloadRequestedAt(cfg.ship.stateDir);
35078
+ const lastRunView = [...lastRuns.values()].filter((l) => l.route === routeSlug(route2.route)).map((l) => ({ role: l.role, ticket: l.ticket, finishedAt: l.finishedAt, outcome: l.outcome }));
35079
+ for (const line of renderStatus({
35080
+ ship: { name: cfg.ship.name, platform: cfg.ship.platform },
35081
+ route: { name: route2.route, dir: route2.dir, enabled: route2.enabled },
35082
+ crewPaused: state.isPaused(),
35083
+ releasePaused: state.releaseSkipReason() !== null,
35084
+ pausedRoles: ["dev", "design", "qa"].filter((r) => state.isRolePaused(r)),
35085
+ periscopes: {
35086
+ summary: periscopeSummary(cfg),
35087
+ relayUrl: routeRelayUrl(route2) || void 0,
35088
+ live: periscopes.map((p) => `${p.ticket} ${p.repo} ${p.url} ${p.state}${p.serving ? "" : " (not serving)"} expires ${p.expiresAt}`)
35089
+ },
35090
+ watermark: String(state.watermark(routeSlug(route2.route))),
35091
+ projects: projects.map((p) => p.label),
35092
+ reloadRequestedSecondsAgo: reloadWaitingAt === null ? null : Math.max(0, Math.round((Date.now() - reloadWaitingAt) / 1e3)),
35093
+ runs: runs.map((x) => ({ role: x.role, ticket: x.ticket, repo: x.repo, pid: x.pid, spawnedAt: x.spawnedAt, deadline: x.deadline })),
35094
+ lastRuns: lastRunView,
35095
+ attention: shipAttention.map((i) => ({ kind: i.kind, message: i.message, since: i.since })),
35096
+ waiting: todo.map((i) => ({
35097
+ key: displayKey(i.ticket),
35098
+ title: i.ticket.title,
35099
+ reasons: i.reasons,
35100
+ updatedAt: i.ticket.updated_at
35101
+ })),
35102
+ repos: repoViews,
35103
+ heldReleases,
35104
+ starved: waiting ? { ticket: waiting.ticket, since: waiting.since, streak: fairness.streak() } : void 0,
35105
+ ships: shipRows.map((s) => ({
35106
+ name: s.name ?? "(unnamed)",
35107
+ line: renderShipLine(s, issueLabelById),
35108
+ attention: (s.attention ?? []).map((i) => ({ kind: i.kind, message: i.message }))
35109
+ }))
35110
+ }, { verbose: flag("verbose") })) process.stdout.write(`${line}
34738
35111
  `);
34739
- }
34740
- }
34741
- }
34742
35112
  break;
34743
35113
  }
34744
35114
  case "doctor": {
@@ -34898,50 +35268,51 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34898
35268
  `);
34899
35269
  break;
34900
35270
  }
34901
- process.stdout.write(
35271
+ const R = new DoctorReport();
35272
+ R.line(
34902
35273
  `ship: ${cfg.ship.name} (${host})
34903
35274
  routes: ${cfg.routes.map((c) => c.route).join(", ")}
34904
35275
  `
34905
35276
  );
34906
35277
  if (staleBundle) {
34907
- process.stdout.write(`bundle: BLOCKER ${staleBundle.message}
35278
+ R.line(`bundle: BLOCKER ${staleBundle.message}
34908
35279
  `);
34909
35280
  process.exitCode = 1;
34910
35281
  }
34911
35282
  const dockerFinding = dockerDaemonFinding({ needed: await shipNeedsDocker(), up: dockerAvailable() });
34912
35283
  const dockerNote = dockerFinding ? " (consequence of the Docker finding above)" : "";
34913
35284
  if (dockerFinding) {
34914
- process.stdout.write(`docker: BLOCKER ${dockerFinding.message} \u2014 ${dockerFinding.remedy}
35285
+ R.line(`docker: BLOCKER ${dockerFinding.message} \u2014 ${dockerFinding.remedy}
34915
35286
  `);
34916
35287
  process.exitCode = 1;
34917
35288
  }
34918
35289
  for (const f of deadTunnelFindings(deadTunnels(cfg.ship.stateDir), Boolean(dockerFinding))) {
34919
- process.stdout.write(`tunnel: DEAD ${f.message} \u2014 ${f.remedy}
35290
+ R.line(`tunnel: DEAD ${f.message} \u2014 ${f.remedy}
34920
35291
  `);
34921
35292
  }
34922
- for (const w of roleCapWarnings(cfg.ship)) process.stdout.write(`role concurrency: WARN ${w}
35293
+ for (const w of roleCapWarnings(cfg.ship)) R.line(`role concurrency: WARN ${w}
34923
35294
  `);
34924
- for (const r of cfg.routes) for (const f of routeAvatarFailures(cfg.ship.stateDir, r.route)) process.stdout.write(`persona avatar: WARN ${r.route}: ${f.role} avatar failed to upload (${f.detail}); run \`crew agents sync\` again
35295
+ for (const r of cfg.routes) for (const f of routeAvatarFailures(cfg.ship.stateDir, r.route)) R.line(`persona avatar: WARN ${r.route}: ${f.role} avatar failed to upload (${f.detail}); run \`crew agents sync\` again
34925
35296
  `);
34926
- for (const t of rejectedTunnels(cfg.ship.stateDir)) process.stdout.write(`relay tunnel: ATTENTION ${tunnelRejectedMessage(t.workspaceId, t.quickExits)}
35297
+ for (const t of rejectedTunnels(cfg.ship.stateDir)) R.line(`relay tunnel: ATTENTION ${tunnelRejectedMessage(t.workspaceId, t.quickExits)}
34927
35298
  `);
34928
- for (const workspaceId of controlRefusedTunnels(cfg.ship.stateDir)) process.stdout.write(`relay tunnel: ATTENTION ${relayControlUnsupportedMessage(workspaceId)}
35299
+ for (const workspaceId of controlRefusedTunnels(cfg.ship.stateDir)) R.line(`relay tunnel: ATTENTION ${relayControlUnsupportedMessage(workspaceId)}
34929
35300
  `);
34930
- process.stdout.write(`periscopes: ${periscopeSummary(cfg)}
35301
+ R.line(`periscopes: ${periscopeSummary(cfg)}
34931
35302
  `);
34932
- process.stdout.write(`key store: ${describeKeyStore(cfg.ship)}
35303
+ R.line(`key store: ${describeKeyStore(cfg.ship)}
34933
35304
  `);
34934
35305
  const previewProblem = await previewHostProblem(cfg);
34935
35306
  if (previewProblem) {
34936
35307
  const blocks = previewHostFinding(previewProblem).severity === "blocker";
34937
- process.stdout.write(` ${blocks ? "BLOCKER" : "ATTENTION"} ${previewProblem}
35308
+ R.line(` ${blocks ? "BLOCKER" : "ATTENTION"} ${previewProblem}
34938
35309
  `);
34939
35310
  if (blocks) process.exitCode = 1;
34940
35311
  }
34941
35312
  try {
34942
35313
  const evFile = eventFileFor(cfg.ship.stateDir);
34943
35314
  const evSize = existsSync60(evFile) ? statSync19(evFile).size : 0;
34944
- process.stdout.write(
35315
+ R.line(
34945
35316
  evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
34946
35317
  ` : "events log: ok\n"
34947
35318
  );
@@ -34957,7 +35328,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34957
35328
  }
34958
35329
  });
34959
35330
  if (abandons === false) {
34960
- process.stdout.write(
35331
+ R.line(
34961
35332
  "scheduler unit: WARN the installed unit does not leave agent runs alone when the daemon restarts (no AbandonProcessGroup / KillMode=process) \u2014 a daemon crash or relaunch kills the run in flight; run `crew install`\n"
34962
35333
  );
34963
35334
  }
@@ -34972,7 +35343,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34972
35343
  }
34973
35344
  });
34974
35345
  if (keeps === false) {
34975
- process.stdout.write(
35346
+ R.line(
34976
35347
  "passengers unit: WARN the installed unit lacks KillMode=process, so systemd kills the relay tunnel each time the sync exits (tunnel never reaches connected); run `crew install`\n"
34977
35348
  );
34978
35349
  }
@@ -34983,19 +35354,19 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34983
35354
  if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync60(p))) {
34984
35355
  const st = spawnSync14(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
34985
35356
  if (!st.error && st.status !== 0) {
34986
- process.stdout.write("daemon unit: WARN installed but not running \u2014 no work is picked up; run `crew reload` (or `crew daemon start`), and `crew install` if the unit still says Restart=on-failure\n");
35357
+ R.line("daemon unit: WARN installed but not running \u2014 no work is picked up; run `crew reload` (or `crew daemon start`), and `crew install` if the unit still says Restart=on-failure\n");
34987
35358
  }
34988
35359
  }
34989
35360
  }
34990
35361
  if (daemonLiveness) {
34991
- process.stdout.write(`daemon: ${daemonLineText(daemonLiveness)}
35362
+ R.line(`daemon: ${daemonLineText(daemonLiveness)}
34992
35363
  `);
34993
35364
  if (daemonLiveness.state === "exited") process.exitCode = 1;
34994
35365
  }
34995
35366
  const daemonDead = daemonKnownDead(daemonLiveness);
34996
35367
  const reloadAt = readReloadRequestedAt(cfg.ship.stateDir);
34997
35368
  if (reloadAt !== null) {
34998
- process.stdout.write(
35369
+ R.line(
34999
35370
  `reload request: ${reloadRequestText(Math.max(0, Math.round((Date.now() - reloadAt) / 1e3)), daemonLiveness, liveRuns(cfg.ship.stateDir).length)}
35000
35371
  `
35001
35372
  );
@@ -35004,7 +35375,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
35004
35375
  if (daemonStartedAt !== null) {
35005
35376
  const changed2 = configChangedAfter(daemonConfigPaths(cfg), daemonStartedAt);
35006
35377
  if (changed2) {
35007
- process.stdout.write(
35378
+ R.line(
35008
35379
  daemonDead ? `daemon config: WARN ${changed2} changed at ${new Date(statSync19(changed2).mtimeMs).toISOString()} \u2014 no daemon is running; the new config applies when it starts
35009
35380
  ` : `daemon config: WARN ${changed2} changed at ${new Date(statSync19(changed2).mtimeMs).toISOString()} but the daemon started at ${new Date(daemonStartedAt).toISOString()} \u2014 run \`crew reload\`
35010
35381
  `
@@ -35016,82 +35387,85 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
35016
35387
  const have = sentVersion(cfg.ship);
35017
35388
  const floor = await readCrewFloor(route2, cfg.ship);
35018
35389
  if (have && floor) {
35019
- process.stdout.write(
35390
+ R.line(
35020
35391
  `crew version: ${belowFloor(have, floor) ? "WARN " : ""}${have} (workspace requires ${floor})${belowFloor(have, floor) ? " \u2014 update crew (the Crew app, or `npm install -g @tablation/crew`)" : ""}
35021
35392
  `
35022
35393
  );
35023
35394
  } else if (have) {
35024
- process.stdout.write(`crew version: ${have}${floor === null ? " (workspace sets no minimum)" : ""}
35395
+ R.line(`crew version: ${have}${floor === null ? " (workspace sets no minimum)" : ""}
35025
35396
  `);
35026
35397
  }
35027
35398
  }
35028
35399
  const contractProblems = validateContract(tracker.contract);
35029
- process.stdout.write(
35400
+ R.line(
35030
35401
  contractProblems.length ? `contract: ${contractProblems.length} problem(s)
35031
35402
  ` + contractProblems.map((p) => ` - ${p}
35032
35403
  `).join("") : "contract: consistent\n"
35033
35404
  );
35405
+ R.repoNames = reposOf(route2).map((t) => t.name);
35034
35406
  for (const r of await resolvedRepos(route2)) {
35035
35407
  const { config } = r;
35408
+ R.repo = r.name;
35036
35409
  const worktreePattern = config.worktrees.name ?? (config.provenance["worktrees.prefix"] !== "default" ? `${config.worktrees.prefix}<number>` : `${basename17(r.dir.replace(/[/\\]+$/, ""))}-${effectiveBranchTemplate(config, void 0)}`);
35037
- process.stdout.write(
35410
+ R.line(
35038
35411
  `${`repo ${r.name}:`.padEnd(19)}${r.dir}
35039
35412
  worktrees at ../${worktreePattern} (${config.provenance["worktrees.name"] ?? config.provenance["worktrees.prefix"] ?? "default"}), branch ${config.branch.name}
35040
35413
  requires ${config.platform} \u2014 ${satisfies(host, config.platform) ? "OK" : "MISMATCH"}
35041
35414
  `
35042
35415
  );
35043
35416
  if (config.shadowed.length) {
35044
- process.stdout.write(
35417
+ R.line(
35045
35418
  ` this ship declares ${config.shadowed.join(", ")}, and ${r.name} overrides it \u2014 the repo wins
35046
35419
  `
35047
35420
  );
35048
35421
  }
35049
35422
  for (const p2 of validateEffective(config)) {
35050
- process.stdout.write(` - release readiness: ${p2}
35423
+ R.line(` - release readiness: ${p2}
35051
35424
  `);
35052
35425
  }
35053
- process.stdout.write(` release self-repair: ${selfRepairLine(config.release.isolateFailures?.maxCandidates)}
35426
+ R.line(` release self-repair: ${selfRepairLine(config.release.isolateFailures?.maxCandidates)}
35054
35427
  `);
35055
35428
  const dh = doctorBaseReport(r, config.branch.base, baseHealth);
35056
- process.stdout.write(dh.text);
35429
+ R.line(dh.text);
35057
35430
  if (dh.failed) process.exitCode = 1;
35058
35431
  if (dh.skipRest) continue;
35059
35432
  if (config.release.ship) {
35060
- process.stdout.write(` release.ship ${config.release.ship}${config.release.ship === cfg.ship.name ? " (this ship)" : ""}
35433
+ R.line(` release.ship ${config.release.ship}${config.release.ship === cfg.ship.name ? " (this ship)" : ""}
35061
35434
  `);
35062
35435
  } else {
35063
35436
  const warn = missingReleaserWarning(r.name, config.release, await tracker.shipRows().catch(() => []));
35064
- if (warn) process.stdout.write(` WARNING ${warn}
35437
+ if (warn) R.line(` WARNING ${warn}
35065
35438
  `);
35066
35439
  }
35067
35440
  const scope = releaseLockScope(route2.route, r.name);
35068
35441
  const lock2 = await tracker.lockState(scope).catch(() => void 0);
35069
35442
  if (lock2?.holder && staleOwnLockClaim(lock2.holder, cfg.ship.name)) {
35070
- process.stdout.write(` ${formatStaleOwnLock(scope, lock2.holder)}`);
35443
+ R.line(` ${formatStaleOwnLock(scope, lock2.holder)}`);
35071
35444
  }
35072
35445
  }
35446
+ R.repo = void 0;
35073
35447
  const missingAuthorship = await tracker.missingAuthorshipColumns();
35074
- process.stdout.write(
35448
+ R.line(
35075
35449
  missingAuthorship.length === 0 ? "authorship: filed_by_id, ship_id present\n" : `authorship: missing ${missingAuthorship.join(", ")} \u2014 update the Issues template
35076
35450
  `
35077
35451
  );
35078
35452
  const missingRuntime = await tracker.missingRuntimeColumns();
35079
- process.stdout.write(
35453
+ R.line(
35080
35454
  missingRuntime.length === 0 ? "runtime columns: forge_host, kind, instance_class, relay_url present\n" : `runtime columns: missing ${missingRuntime.join(", ")} \u2014 read as their defaults; update the Issues template
35081
35455
  `
35082
35456
  );
35083
35457
  {
35084
35458
  const have = await tracker.linkColumns();
35085
35459
  const lines2 = linkDoctorLines(have, reposOf(route2).map((t) => ({ name: t.name, host: t.forgeHost })), cfg.ship.forges, cfg.ship.stateDir);
35086
- process.stdout.write(`${lines2.join("\n")}
35460
+ R.line(`${lines2.join("\n")}
35087
35461
  `);
35088
35462
  }
35089
- process.stdout.write(
35463
+ R.line(
35090
35464
  await tracker.hasPublicReplyColumn() ? `public replies: Comments.${tracker.contract.comments.publicReply} present \u2014 public reporters are labelled in the digest
35091
35465
  ` : `public replies: Comments.${tracker.contract.comments.publicReply} absent \u2014 no public intake form, nothing to guard
35092
35466
  `
35093
35467
  );
35094
- process.stdout.write(
35468
+ R.line(
35095
35469
  await tracker.hasCrewAssistedColumn() ? `crew assisted: Issues.${tracker.contract.columns.crewAssisted} present \u2014 Dev/QA runs mark the ticket
35096
35470
  ` : `crew assisted: Issues.${tracker.contract.columns.crewAssisted} absent \u2014 tickets are not marked; update the Issues template to adopt it
35097
35471
  `
@@ -35105,44 +35479,44 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
35105
35479
  tablePresent: periscopes.present,
35106
35480
  repos: settled.map((r) => ({ name: r.name, hasPreviewHook: !!r.config.hooks.preview }))
35107
35481
  })) {
35108
- process.stdout.write(`periscopes: ${f.severity.toUpperCase()} ${f.message}
35482
+ R.line(`periscopes: ${f.severity.toUpperCase()} ${f.message}
35109
35483
  `);
35110
35484
  }
35111
35485
  if (!flag("offline")) {
35112
35486
  for (const f of await duplicateLivePeriscopeProblems(route2, cfg.ship)) {
35113
- process.stdout.write(`periscopes: ${f.severity.toUpperCase()} ${f.message}
35487
+ R.line(`periscopes: ${f.severity.toUpperCase()} ${f.message}
35114
35488
  `);
35115
35489
  }
35116
35490
  }
35117
35491
  }
35118
- process.stdout.write(
35492
+ R.line(
35119
35493
  !periscopes.present ? "periscopes: Periscopes table absent \u2014 this workspace cannot host periscopes\n" : periscopes.missing.length === 0 ? `periscopes: Periscopes table present (${periscopes.modelId})
35120
35494
  ` : `periscopes: Periscopes table present (${periscopes.modelId}) but missing ${periscopes.missing.join(", ")} \u2014 update the Issues template
35121
35495
  `
35122
35496
  );
35123
- process.stdout.write(
35497
+ R.line(
35124
35498
  route2.resolved?.releaseSeat ? "release seat: this ship has its own Release Crew row\n" : "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"
35125
35499
  );
35126
35500
  const keyRole = route2.resolved?.role ?? await fetchKeyRole(route2, cfg.ship.userAgent);
35127
35501
  const roleRoute = route2.resolved && keyRole ? { ...route2, resolved: { ...route2.resolved, role: keyRole } } : route2;
35128
- process.stdout.write(`api key role: ${keyRole ?? "unknown"}
35502
+ R.line(`api key role: ${keyRole ?? "unknown"}
35129
35503
  `);
35130
- for (const m of route2.resolved?.capabilityMisses ?? []) process.stdout.write(`capability: MISSING ${m} (re-run \`crew connect\` once granted)
35504
+ for (const m of route2.resolved?.capabilityMisses ?? []) R.line(`capability: MISSING ${m} (re-run \`crew connect\` once granted)
35131
35505
  `);
35132
35506
  const canMint = await canMintAgentKeys(roleRoute, { userAgent: cfg.ship.userAgent });
35133
- process.stdout.write(`can mint agent keys: ${canMint === void 0 ? "unknown" : canMint ? "yes" : "no"}
35507
+ R.line(`can mint agent keys: ${canMint === void 0 ? "unknown" : canMint ? "yes" : "no"}
35134
35508
  `);
35135
35509
  for (const role of SEAT_KEY_ROLES) {
35136
35510
  if (!route2.resolved?.seats[role]) continue;
35137
35511
  const id = await resolveSeatKey(roleRoute, role);
35138
- process.stdout.write(
35512
+ R.line(
35139
35513
  `seat identity: ${role} writes as ${id.kind === "agent" ? `its own agent (${id.agentId})` : `the ship (${id.reason})`}
35140
35514
  `
35141
35515
  );
35142
35516
  }
35143
35517
  if (route2.resolved?.releaseSeat) {
35144
35518
  const id = await resolveReleaseKey(roleRoute);
35145
- process.stdout.write(
35519
+ R.line(
35146
35520
  `seat identity: release writes as ${id.kind === "agent" ? `its own agent (${id.agentId})` : `the ship (${id.reason})`}
35147
35521
  `
35148
35522
  );
@@ -35150,54 +35524,54 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
35150
35524
  if (!flag("offline")) {
35151
35525
  for (const p of await probeSeatReads(roleRoute, { userAgent: cfg.ship.userAgent })) {
35152
35526
  if (p.state === "forbidden") {
35153
- process.stdout.write(`${describeSeatForbidden(p.role, p.tables)}
35527
+ R.line(`${describeSeatForbidden(p.role, p.tables)}
35154
35528
  `);
35155
35529
  process.exitCode = 1;
35156
35530
  } else {
35157
- process.stdout.write(p.state === "ok" ? `${describeSeatTables(p.role, p.tables)}
35531
+ R.line(p.state === "ok" ? `${describeSeatTables(p.role, p.tables)}
35158
35532
  ` : `seat read: ${p.role} could not be checked (${p.detail})
35159
35533
  `);
35160
35534
  }
35161
35535
  }
35162
35536
  for (const w of await probeSeatWrites(roleRoute, { userAgent: cfg.ship.userAgent })) {
35163
35537
  if (w.state === "forbidden") {
35164
- process.stdout.write(`seat write: ERROR ${seatCannotWriteMessage(w.role, w.tables)} (READ only) \u2014 ${SEAT_NO_WRITE_REMEDY}
35538
+ R.line(`seat write: ERROR ${seatCannotWriteMessage(w.role, w.tables)} (READ only) \u2014 ${SEAT_NO_WRITE_REMEDY}
35165
35539
  `);
35166
35540
  process.exitCode = 1;
35167
- } else if (w.state === "ok") process.stdout.write(`seat write: ${w.role}: ok
35541
+ } else if (w.state === "ok") R.line(`seat write: ${w.role}: ok
35168
35542
  `);
35169
35543
  }
35170
35544
  }
35171
35545
  const [ships, crewRows] = await Promise.all([tracker.shipRows(), tracker.crewRows()]);
35172
35546
  if (ships.length === 0) {
35173
- process.stdout.write("ship record: this workspace has no Ships table (fine)\n");
35547
+ R.line("ship record: this workspace has no Ships table (fine)\n");
35174
35548
  } else {
35175
35549
  const matched = matchShipRows(ships, cfg.ship.name, doctorMachineId(cfg.ship.stateDir));
35176
35550
  const mine = matched.rows;
35177
- process.stdout.write(
35551
+ R.line(
35178
35552
  matched.hasColumn ? `ship row: ${mine.length === 1 ? `matched by ${matched.by === "machine_id" ? "machine id" : "name"}` : "not matched"}
35179
35553
  ` : "ship row: matched by name only \u2014 the Ships table has no machine_id column (update the Issues template)\n"
35180
35554
  );
35181
35555
  if (mine.length === 0) {
35182
- process.stdout.write(
35556
+ R.line(
35183
35557
  `ship record: NO row named "${cfg.ship.name}" \u2014 have: ${ships.map((s2) => s2.name).join(", ")}
35184
35558
  `
35185
35559
  );
35186
35560
  } else if (mine.length > 1) {
35187
- process.stdout.write(`ship record: ${mine.length} rows named "${cfg.ship.name}" \u2014 ambiguous
35561
+ R.line(`ship record: ${mine.length} rows named "${cfg.ship.name}" \u2014 ambiguous
35188
35562
  `);
35189
35563
  } else {
35190
35564
  const row = mine[0];
35191
35565
  const seats2 = crewRows.filter((c) => c.ship_id === row.id);
35192
35566
  const declared = row.platform;
35193
- process.stdout.write(
35567
+ R.line(
35194
35568
  `ship record: ${row.name} (${declared ?? "no platform"})${declared && declared !== host ? ` \u2014 MISMATCH, this host is ${host}` : ""}
35195
35569
  crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "none"}
35196
35570
  `
35197
35571
  );
35198
- for (const w of managedRuntimeWarnings(row.kind, cfg.ship)) process.stdout.write(`managed runtime: WARN ${w}
35572
+ for (const w of managedRuntimeWarnings(row.kind, cfg.ship)) R.line(`managed runtime: WARN ${w}
35199
35573
  `);
35200
- for (const w of managedGitIdentityWarnings(row.kind, readGlobalGitIdentity())) process.stdout.write(`managed git: WARN ${w}
35574
+ for (const w of managedGitIdentityWarnings(row.kind, readGlobalGitIdentity())) R.line(`managed git: WARN ${w}
35201
35575
  `);
35202
35576
  }
35203
35577
  }
@@ -35205,20 +35579,20 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35205
35579
  const op = route2.resolved?.operator;
35206
35580
  const row = op ? crewRows.find((c) => c.id === op) : void 0;
35207
35581
  if (!op) {
35208
- process.stdout.write("operator identity: no operator on this route \u2014 run `crew connect`\n");
35582
+ R.line("operator identity: no operator on this route \u2014 run `crew connect`\n");
35209
35583
  } else if (!row) {
35210
- process.stdout.write(`operator identity: ERROR operator ${op} is not a row of the Crew table
35584
+ R.line(`operator identity: ERROR operator ${op} is not a row of the Crew table
35211
35585
  `);
35212
35586
  process.exitCode = 1;
35213
35587
  } else if (!row.user_id) {
35214
- process.stdout.write(
35588
+ R.line(
35215
35589
  `operator identity: ERROR Crew row "${row.name ?? op}" has no user_id \u2014 their UI comments will read "(no identity)"; re-run \`crew connect\` to link it
35216
35590
  `
35217
35591
  );
35218
35592
  process.exitCode = 1;
35219
35593
  } else {
35220
35594
  const resolves = memberByIdentity(buildRoster(configuredMembers(route2), crewRows), row.user_id);
35221
- process.stdout.write(
35595
+ R.line(
35222
35596
  resolves ? `operator identity: comments from ${row.name ?? op} resolve to ${crewLabel(resolves)}
35223
35597
  ` : `operator identity: ERROR user_id ${row.user_id} does not resolve through the roster
35224
35598
  `
@@ -35230,12 +35604,12 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35230
35604
  try {
35231
35605
  const humanHolds = new Set(holdIds(buildRoster(configuredMembers(route2), crewRows)));
35232
35606
  const warnings = holdWarnings(await tracker.openTickets(), ships, tracker.contract, humanHolds);
35233
- process.stdout.write(
35607
+ R.line(
35234
35608
  warnings.length === 0 ? "ship holds: every in-flight ticket is held by a live ship\n" : warnings.map((w) => `ship holds: WARNING ${w}
35235
35609
  `).join("")
35236
35610
  );
35237
35611
  } catch (e) {
35238
- process.stdout.write(`ship holds: could not check \u2014 ${e.message}
35612
+ R.line(`ship holds: could not check \u2014 ${e.message}
35239
35613
  `);
35240
35614
  }
35241
35615
  }
@@ -35249,16 +35623,16 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35249
35623
  const binPath = findOnPath(runBin, schedulerPath);
35250
35624
  if (!binPath) allBinsFound = false;
35251
35625
  const label = tc.name === defaultToolchain ? "agent binary: " : `toolchain ${tc.name}:`.padEnd(18);
35252
- process.stdout.write(
35626
+ R.line(
35253
35627
  `${label} ${runBin} \u2014 ${binPath ? `OK (${binPath})` : "NOT FOUND on the scheduler PATH"}${tc.name === defaultToolchain ? "" : ` [${adapter.displayName}]`}
35254
35628
  `
35255
35629
  );
35256
- for (const limit of adapter.limitations) process.stdout.write(` cannot enforce: ${limit}
35630
+ for (const limit of adapter.limitations) R.line(` cannot enforce: ${limit}
35257
35631
  `);
35258
35632
  if (isOmlxLauncher(tc)) {
35259
35633
  const s = readOmlxSettings();
35260
35634
  if (!s) {
35261
- process.stdout.write(` omlx: ~/.omlx/settings.json not found or has no server.port \u2014 cannot check the server
35635
+ R.line(` omlx: ~/.omlx/settings.json not found or has no server.port \u2014 cannot check the server
35262
35636
  `);
35263
35637
  } else {
35264
35638
  let status2;
@@ -35268,32 +35642,32 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35268
35642
  status2 = void 0;
35269
35643
  }
35270
35644
  const probe = interpretOmlxProbe(status2);
35271
- process.stdout.write(` omlx server: ${s.host}:${s.port} \u2014 ${probe.detail}${probe.up ? "" : " (start oMLX)"}
35645
+ R.line(` omlx server: ${s.host}:${s.port} \u2014 ${probe.detail}${probe.up ? "" : " (start oMLX)"}
35272
35646
  `);
35273
- process.stdout.write(
35647
+ R.line(
35274
35648
  ` omlx model: ${tc.model} \u2014 ${omlxModelPresent(tc.model, s.modelDirs) ? "present" : `NOT FOUND in ${s.modelDirs.join(", ") || "any model dir"}`}
35275
35649
  `
35276
35650
  );
35277
35651
  }
35278
- process.stdout.write(` local model: tool-call reliability and prefill speed vary by model
35652
+ R.line(` local model: tool-call reliability and prefill speed vary by model
35279
35653
  `);
35280
35654
  }
35281
35655
  if (isOriLauncher(tc)) {
35282
- process.stdout.write(` ori: headless auth under the scheduler is unverified \u2014 run \`ori login\` as the scheduler user, then confirm a run records provider openrouter (see docs/toolchains.md)
35656
+ R.line(` ori: headless auth under the scheduler is unverified \u2014 run \`ori login\` as the scheduler user, then confirm a run records provider openrouter (see docs/toolchains.md)
35283
35657
  `);
35284
35658
  }
35285
35659
  }
35286
35660
  for (const [repoName, ov] of Object.entries(route2.repoOverrides)) {
35287
- if (ov.toolchain) process.stdout.write(`repo toolchain: ${repoName} \u2192 ${ov.toolchain} (binary and MCP checked above, as for every ship toolchain)
35661
+ if (ov.toolchain) R.line(`repo toolchain: ${repoName} \u2192 ${ov.toolchain} (binary and MCP checked above, as for every ship toolchain)
35288
35662
  `);
35289
35663
  }
35290
- if (cfg.ship.forges) process.stdout.write(formatPushAuth("credential helper", probeCredentialHelper(crewCommandLine())).replace("push auth credential helper:", "credential helper:".padEnd(19)));
35291
- for (const p of pushAuth) process.stdout.write(formatPushAuth(`${p.repo}`, p.result));
35292
- for (const t of toolRows) process.stdout.write(formatToolCheck(t));
35293
- process.stdout.write(`git: ${gitPath ? `OK (${gitPath})` : "NOT FOUND on the scheduler PATH"}
35664
+ if (cfg.ship.forges) R.line(formatPushAuth("credential helper", probeCredentialHelper(crewCommandLine())).replace("push auth credential helper:", "credential helper:".padEnd(19)));
35665
+ for (const p of pushAuth) R.line(formatPushAuth(`${p.repo}`, p.result), { repo: p.repo });
35666
+ for (const t of toolRows) R.line(formatToolCheck(t));
35667
+ R.line(`git: ${gitPath ? `OK (${gitPath})` : "NOT FOUND on the scheduler PATH"}
35294
35668
  `);
35295
35669
  if (!allBinsFound || !gitPath) {
35296
- process.stdout.write(
35670
+ R.line(
35297
35671
  ` scheduler PATH is ${schedulerPath} \u2014 add the directory holding the missing binary to ship.extraPath in crew.yaml, then re-run \`crew doctor\`.
35298
35672
  `
35299
35673
  );
@@ -35307,7 +35681,7 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35307
35681
  seenMcp.add(id);
35308
35682
  const adapter = adapterFor(tc.harness);
35309
35683
  const m = adapter.inspectMcp({ bin: tc.bin, url: mcpUrl, key: route2.apiKey });
35310
- process.stdout.write(
35684
+ R.line(
35311
35685
  m.state === "registered" ? `mcp: tablation registered (user scope) \u2192 ${m.url}
35312
35686
  ` : m.state === "no-binary" ? `mcp: ${tc.bin} not found \u2014 ${adapter.displayName} was not checked
35313
35687
  ` : m.state === "different" ? `mcp: tablation registered but not for this route \u2014 ${m.detail}
@@ -35319,11 +35693,11 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35319
35693
  for (const h of shipPair(cfg.ship).filter((x) => x !== "claude")) {
35320
35694
  const inst = pairInstallerFor(h);
35321
35695
  const v = inst.verifyPair({ url: mcpUrlFor(route2.baseUrl) });
35322
- process.stdout.write(`pair ${h}:`.padEnd(19) + (v.ok ? ` installed (${v.detail})
35696
+ R.line(`pair ${h}:`.padEnd(19) + (v.ok ? ` installed (${v.detail})
35323
35697
  ` : ` NOT installed \u2014 ${v.detail}; run crew connect
35324
35698
  `));
35325
35699
  const envWarn = inst.envWarning?.({ url: mcpUrlFor(route2.baseUrl) });
35326
- if (envWarn) process.stdout.write(`pair ${h} env:`.padEnd(19) + ` WARN \u2014 ${envWarn}
35700
+ if (envWarn) R.line(`pair ${h} env:`.padEnd(19) + ` WARN \u2014 ${envWarn}
35327
35701
  `);
35328
35702
  }
35329
35703
  const shipVendors = new Set(shipToolchains(cfg.ship).map(toolchainVendor));
@@ -35333,11 +35707,11 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35333
35707
  const persona = await fetchSeatPersona(route2, role, { userAgent: cfg.ship.userAgent });
35334
35708
  if (persona?.vendor && !shipVendors.has(persona.vendor)) {
35335
35709
  flagged++;
35336
- process.stdout.write(`seat vendor: ${role} persona wants "${persona.vendor}" \u2014 no toolchain on this ship serves it (have: ${[...shipVendors].join(", ")}); it will run ${resolveSeat(cfg.ship, route2, role).toolchain.name} with a warning
35710
+ R.line(`seat vendor: ${role} persona wants "${persona.vendor}" \u2014 no toolchain on this ship serves it (have: ${[...shipVendors].join(", ")}); it will run ${resolveSeat(cfg.ship, route2, role).toolchain.name} with a warning
35337
35711
  `);
35338
35712
  }
35339
35713
  }
35340
- if (flagged === 0) process.stdout.write("seat vendor: OK (every persona vendor has a toolchain on this ship)\n");
35714
+ if (flagged === 0) R.line("seat vendor: OK (every persona vendor has a toolchain on this ship)\n");
35341
35715
  }
35342
35716
  for (const c of cfg.routes.filter((r) => r.enabled)) {
35343
35717
  let repos;
@@ -35366,8 +35740,8 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35366
35740
  clearShipAttention(state, key);
35367
35741
  continue;
35368
35742
  }
35369
- process.stdout.write(`hook ${c.route}/${r.name} ${name}: \`${cmd}\` NOT FOUND in the sandbox image
35370
- `);
35743
+ R.line(`hook ${c.route}/${r.name} ${name}: \`${cmd}\` NOT FOUND in the sandbox image
35744
+ `, { repo: r.name });
35371
35745
  await raiseShipAttention({ state, emit, route: c, ship: cfg.ship }, { kind: "hook_missing", key, message: gap.message, since: (/* @__PURE__ */ new Date()).toISOString() });
35372
35746
  continue;
35373
35747
  }
@@ -35375,8 +35749,8 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35375
35749
  clearShipAttention(state, key);
35376
35750
  continue;
35377
35751
  }
35378
- process.stdout.write(`hook ${c.route}/${r.name} ${name}: \`${cmd}\` NOT FOUND on the scheduler PATH
35379
- `);
35752
+ R.line(`hook ${c.route}/${r.name} ${name}: \`${cmd}\` NOT FOUND on the scheduler PATH
35753
+ `, { repo: r.name });
35380
35754
  await raiseShipAttention({ state, emit, route: c, ship: cfg.ship }, {
35381
35755
  kind: "hook_missing",
35382
35756
  key,
@@ -35387,33 +35761,33 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
35387
35761
  }
35388
35762
  }
35389
35763
  for (const i of visibleAttention(openShipAttention(state), Boolean(dockerFinding))) {
35390
- process.stdout.write(`attention: ${i.kind} \u2014 ${i.message} (since ${i.since})
35764
+ R.line(`attention: ${i.kind} \u2014 ${i.message} (since ${i.since})
35391
35765
  `);
35392
35766
  }
35393
35767
  if (host === "macos") {
35394
35768
  const foreign = describeForeignLaunchdUnits(CREW_HOME);
35395
35769
  if (foreign.length > 0) {
35396
- process.stdout.write(`foreign launchd units (not this checkout's \u2014 \`crew install\` or \`crew uninstall --all\` clears them):
35397
- ${foreign.join("\n")}
35770
+ R.line(`foreign launchd units: not this checkout's \u2014 \`crew install\` or \`crew uninstall --all\` clears them
35771
+ ${foreign.map((f) => ` ${f.trim()}`).join("\n")}
35398
35772
  `);
35399
35773
  }
35400
35774
  }
35401
35775
  if (cfg.ship.runner === "sandbox") {
35402
35776
  const sb = checkSandboxRunner(cfg.ship.sandbox);
35403
- process.stdout.write(`sandbox runner: ${sb.ok ? `OK (${sb.detail})` : `NOT READY \u2014 ${sb.detail}`}
35777
+ R.line(`sandbox runner: ${sb.ok ? `OK (${sb.detail})` : `NOT READY \u2014 ${sb.detail}`}
35404
35778
  `);
35405
35779
  } else {
35406
- process.stdout.write("sandbox runner: off (ship.runner is host)\n");
35780
+ R.line("sandbox runner: off (ship.runner is host)\n");
35407
35781
  }
35408
35782
  const passengerRoutes = cfg.routes.filter((r) => r.enabled && r.hostPassengers);
35409
35783
  if (passengerRoutes.length === 0) {
35410
- process.stdout.write("host passengers: off (no enabled route sets hostPassengers: true)\n");
35784
+ R.line("host passengers: off (no enabled route sets hostPassengers: true)\n");
35411
35785
  } else {
35412
35786
  const dockerOk = dockerAvailable();
35413
35787
  const dockerPathIssue = dockerPathProblem(cfg.ship);
35414
35788
  const dockerKey = "docker_missing";
35415
35789
  if (dockerPathIssue) {
35416
- process.stdout.write(`docker on scheduler PATH: NOT FOUND \u2014 ${dockerPathIssue}
35790
+ R.line(`docker on scheduler PATH: NOT FOUND \u2014 ${dockerPathIssue}
35417
35791
  `);
35418
35792
  await raiseShipAttention({ state, emit, route: passengerRoutes[0], ship: cfg.ship }, {
35419
35793
  kind: "docker_missing",
@@ -35427,7 +35801,7 @@ ${foreign.join("\n")}
35427
35801
  const keygenOk = sshKeygenAvailable();
35428
35802
  const image = passengerImageRef(cfg);
35429
35803
  const imageOk = dockerOk && imagePresent(image);
35430
- process.stdout.write(
35804
+ R.line(
35431
35805
  `host passengers: ON for ${passengerRoutes.map((r) => r.route).join(", ")}
35432
35806
  docker: ${dockerOk ? "OK" : `NOT AVAILABLE${dockerNote}`}
35433
35807
  ssh-keygen: ${keygenOk ? "OK" : "NOT AVAILABLE"}
@@ -35436,12 +35810,12 @@ ${foreign.join("\n")}
35436
35810
  `
35437
35811
  );
35438
35812
  if (!dockerOk) {
35439
- process.stdout.write(
35813
+ R.line(
35440
35814
  " Docker Desktop (or another Docker daemon) is required for Host Passengers \u2014 install/start it, then re-run `crew doctor`. The toggle stays armed in crew.yaml but nothing will start until Docker answers `docker info`.\n"
35441
35815
  );
35442
35816
  }
35443
35817
  if (!keygenOk) {
35444
- process.stdout.write(
35818
+ R.line(
35445
35819
  " `ssh-keygen` is required to mint this ship's tunnel identity \u2014 install OpenSSH, then re-run `crew connect` to sync a key onto this workspace's Ships row.\n"
35446
35820
  );
35447
35821
  }
@@ -35450,24 +35824,24 @@ ${foreign.join("\n")}
35450
35824
  const ws = r.resolved?.workspaceId;
35451
35825
  const slug2 = ws ? readPersistedTunnel(cfg.ship.stateDir, ws)?.slug : void 0;
35452
35826
  if (!ws) continue;
35453
- process.stdout.write(
35827
+ R.line(
35454
35828
  ` ${r.route} url: ${slug2 ? publicUrlFor(slug2, cfg.ship.relayHost, cfg.ship.relayHttpPort, cfg.ship.relayPublicDomain) : "not minted yet (first tunnel cycle creates it)"}
35455
35829
  `
35456
35830
  );
35457
35831
  const controlUrl = slug2 && readPersistedTunnel(cfg.ship.stateDir, ws)?.controlSocket ? `${relayBaseUrlFor(slug2, cfg.ship.relayHost, cfg.ship.relayHttpPort, cfg.ship.relayPublicDomain)}/control` : void 0;
35458
- process.stdout.write(` ${r.route} control url: ${controlUrl ?? "none (the tunnel carries passengers only)"}
35832
+ R.line(` ${r.route} control url: ${controlUrl ?? "none (the tunnel carries passengers only)"}
35459
35833
  `);
35460
35834
  const api = endpointApiFor([r])(ws);
35461
35835
  if (!api) continue;
35462
35836
  const probe = await probeEndpointAccess(api, ws);
35463
- process.stdout.write(
35837
+ R.line(
35464
35838
  ` ${r.route} mcp endpoints: ` + (probe === "ok" ? "OK (key may register its endpoint)" : probe === "forbidden" ? `403 \u2014 ${REGISTER_MCP_ENDPOINTS_HINT}` : `could not check (${probe.error})`) + "\n"
35465
35839
  );
35466
35840
  }
35467
35841
  }
35468
35842
  for (const r of passengerRoutes) {
35469
35843
  const included = passengerRepoTargets(r);
35470
- process.stdout.write(
35844
+ R.line(
35471
35845
  ` ${r.route}: ${included.length ? included.map((t) => t.name).join(", ") : "(no repos included)"}
35472
35846
  `
35473
35847
  );
@@ -35478,19 +35852,19 @@ ${foreign.join("\n")}
35478
35852
  const stateS = readSandboxState(cfg.ship.stateDir);
35479
35853
  for (const r of declaredS) {
35480
35854
  const st = sandboxImageStatus(stateS, planSandbox(r.name, r.decl, r.warm, r.bridge));
35481
- process.stdout.write(`sandbox image: ${r.name}: ${st.status.toUpperCase()} \u2014 ${st.detail}${st.status === "ok" ? "" : dockerNote}
35855
+ R.line(`sandbox image: ${r.name}: ${st.status.toUpperCase()} \u2014 ${st.detail}${st.status === "ok" ? "" : dockerNote}
35482
35856
  `);
35483
35857
  }
35484
35858
  }
35485
35859
  for (const e of listPeriscopeEndpoints(cfg.ship.stateDir)) {
35486
35860
  const secret = readPeriscopeSecret(cfg.ship.stateDir, e.ticketRecordId) ? "live" : "ended, awaiting removal";
35487
- process.stdout.write(`periscope mcp: ${e.ticket} ${e.route} ${e.url} (${secret}, attached only)
35861
+ R.line(`periscope mcp: ${e.ticket} ${e.route} ${e.url} (${secret}, attached only)
35488
35862
  `);
35489
35863
  }
35490
35864
  if (cfg.ship.relayHost && !flag("offline")) {
35491
35865
  const relayUrl = routeRelayUrl(route2);
35492
35866
  if (!relayUrl) {
35493
- process.stdout.write("relay control: no tunnel URL yet (the first `crew passengers` cycle opens it)\n");
35867
+ R.line("relay control: no tunnel URL yet (the first `crew passengers` cycle opens it)\n");
35494
35868
  } else {
35495
35869
  let key;
35496
35870
  try {
@@ -35499,29 +35873,33 @@ ${foreign.join("\n")}
35499
35873
  key = void 0;
35500
35874
  }
35501
35875
  const relayLine = key ? describeRelayProbe(relayUrl, await probeRelayControl(relayUrl, key, cfg.ship.userAgent)) : "relay control: could not check (no API key for this route)";
35502
- process.stdout.write(`${relayLine}${/FAILED/.test(relayLine) ? dockerNote : ""}
35876
+ R.line(`${relayLine}${/FAILED/.test(relayLine) ? dockerNote : ""}
35503
35877
  `);
35504
35878
  }
35505
35879
  }
35506
35880
  for (const l of doctorSelftestLines(readSelftest(cfg.ship.stateDir), shipToolchains(cfg.ship).map((t) => t.name))) {
35507
- process.stdout.write(`${l}
35881
+ R.line(`${l}
35508
35882
  `);
35509
35883
  }
35510
35884
  for (const t of shipToolchains(cfg.ship).filter((t2) => t2.harness === "claude")) {
35511
35885
  if (t.auth === "workspace") {
35512
35886
  for (const r of cfg.routes.filter((r2) => r2.enabled)) {
35513
35887
  const inference = r.resolved ? { baseUrl: inferenceBaseUrl(r.baseUrl, r.resolved.workspaceId), token: "" } : void 0;
35514
- process.stdout.write(`auth: ${t.name}: ${r.route}: ${describeClaudeAuth({ ...t, inference })}
35888
+ R.line(`auth: ${t.name}: ${r.route}: ${describeClaudeAuth({ ...t, inference })}
35515
35889
  `);
35516
35890
  }
35517
35891
  continue;
35518
35892
  }
35519
- process.stdout.write(`auth: ${t.name}: ${describeClaudeAuth(t)}
35893
+ R.line(`auth: ${t.name}: ${describeClaudeAuth(t)}
35520
35894
  `);
35521
35895
  }
35522
35896
  const interactive = !!(process.stdin.isTTY && process.stdout.isTTY);
35897
+ const counts = R.counts();
35898
+ process.stdout.write(renderDoctor(R, [
35899
+ `ship ${cfg.ship.name} (${host}) \xB7 route ${route2.route} \xB7 crew ${sentVersion(cfg.ship) ?? "unknown version"}${daemonLiveness ? ` \xB7 daemon ${daemonLineText(daemonLiveness)}` : ""}`
35900
+ ], flag("verbose")));
35523
35901
  if (flag("fix") || interactive) {
35524
- await doctorFix({ prompt: !flag("fix") || interactive, host });
35902
+ await doctorFix({ prompt: !flag("fix") || interactive, host, fixFlag: flag("fix"), blockers: counts.blocker, warnings: counts.warning });
35525
35903
  }
35526
35904
  break;
35527
35905
  }