@tablation/crew 0.143.4 → 0.144.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 (2) hide show
  1. package/dist/cli.js +408 -307
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -6936,7 +6936,7 @@ import { promisify as promisify2 } from "util";
6936
6936
 
6937
6937
  // src/deprovision-host.ts
6938
6938
  import { spawnSync as spawnSync7 } from "child_process";
6939
- import { existsSync as existsSync32, readdirSync as readdirSync12 } from "fs";
6939
+ import { existsSync as existsSync33, readdirSync as readdirSync13 } from "fs";
6940
6940
 
6941
6941
  // src/repo-env.ts
6942
6942
  import { existsSync as existsSync19, mkdirSync as mkdirSync14, readFileSync as readFileSync20, renameSync as renameSync3, rmSync as rmSync10, writeFileSync as writeFileSync15 } from "fs";
@@ -14403,15 +14403,103 @@ async function reconcileRuns(o) {
14403
14403
  }
14404
14404
 
14405
14405
  // src/live-runs.ts
14406
- import { existsSync as existsSync31, readdirSync as readdirSync11, statSync as statSync10 } from "fs";
14406
+ import { existsSync as existsSync32, readdirSync as readdirSync12, statSync as statSync11 } from "fs";
14407
+ import { join as join35 } from "path";
14408
+
14409
+ // src/run-snapshot.ts
14410
+ import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync32 } from "fs";
14407
14411
  import { join as join34 } from "path";
14408
- function liveRuns(stateDir, isAlive = runIsAlive) {
14412
+ var TAIL_BYTES = 256 * 1024;
14413
+ var EXCERPT_CHARS = 280;
14414
+ function lastStreamEvent(streamPath) {
14415
+ let fd;
14416
+ try {
14417
+ fd = openSync5(streamPath, "r");
14418
+ } catch {
14419
+ return null;
14420
+ }
14421
+ try {
14422
+ const st = fstatSync(fd);
14423
+ const start = Math.max(0, st.size - TAIL_BYTES);
14424
+ const buf = Buffer.alloc(st.size - start);
14425
+ readSync2(fd, buf, 0, buf.length, start);
14426
+ const lines2 = buf.toString("utf8").split("\n");
14427
+ if (start > 0) lines2.shift();
14428
+ for (let i = lines2.length - 1; i >= 0; i--) {
14429
+ const line = lines2[i].trim();
14430
+ if (!line.startsWith("{")) continue;
14431
+ let parsed;
14432
+ try {
14433
+ parsed = JSON.parse(line);
14434
+ } catch {
14435
+ continue;
14436
+ }
14437
+ if (parsed.type !== "assistant" || !Array.isArray(parsed.message?.content)) continue;
14438
+ const blocks = parsed.message.content;
14439
+ for (let j = blocks.length - 1; j >= 0; j--) {
14440
+ const b = blocks[j];
14441
+ if (b.type !== "text" || !b.text?.trim()) continue;
14442
+ const text2 = b.text.replace(/\s+/g, " ").trim();
14443
+ return {
14444
+ text: text2.length > EXCERPT_CHARS ? `${text2.slice(0, EXCERPT_CHARS - 1)}\u2026` : text2,
14445
+ at: new Date(st.mtimeMs).toISOString()
14446
+ };
14447
+ }
14448
+ }
14449
+ return null;
14450
+ } catch {
14451
+ return null;
14452
+ } finally {
14453
+ closeSync5(fd);
14454
+ }
14455
+ }
14456
+ function outcomeOf(m) {
14457
+ if (m.interrupted) return "interrupted";
14458
+ return m.exitCode === void 0 || m.exitCode === null || m.exitCode === 0 ? "ok" : "failed";
14459
+ }
14460
+ function lastRunsBySeat(stateDir) {
14409
14461
  const dir = join34(stateDir, "streams");
14410
- if (!existsSync31(dir)) return [];
14411
- const out = [];
14462
+ const out = /* @__PURE__ */ new Map();
14463
+ if (!existsSync31(dir)) return out;
14412
14464
  for (const name of readdirSync11(dir)) {
14413
14465
  if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
14414
14466
  const streamPath = join34(dir, name);
14467
+ if (!runFinished(streamPath)) continue;
14468
+ const metaPath = `${streamPath}.meta.json`;
14469
+ let meta;
14470
+ let mtimeMs;
14471
+ try {
14472
+ meta = JSON.parse(readFileSync32(metaPath, "utf8"));
14473
+ mtimeMs = statSync10(metaPath).mtimeMs;
14474
+ } catch {
14475
+ continue;
14476
+ }
14477
+ if (!meta.route || !meta.role) continue;
14478
+ const key = `${meta.route}/${meta.role}`;
14479
+ const finishedAt = new Date(mtimeMs).toISOString();
14480
+ const have = out.get(key);
14481
+ if (have && have.finishedAt >= finishedAt) continue;
14482
+ out.set(key, {
14483
+ ticket: meta.ticket ?? null,
14484
+ startedAt: meta.startedAt ?? null,
14485
+ finishedAt,
14486
+ outcome: outcomeOf(meta),
14487
+ exitCode: meta.exitCode ?? null,
14488
+ route: meta.route,
14489
+ role: meta.role
14490
+ });
14491
+ }
14492
+ return out;
14493
+ }
14494
+
14495
+ // src/live-runs.ts
14496
+ function liveRuns(stateDir, isAlive = runIsAlive) {
14497
+ const dir = join35(stateDir, "streams");
14498
+ if (!existsSync32(dir)) return [];
14499
+ const out = [];
14500
+ for (const name of readdirSync12(dir)) {
14501
+ if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
14502
+ const streamPath = join35(dir, name);
14415
14503
  if (runFinished(streamPath)) continue;
14416
14504
  const sidecar = readRunSidecar(streamPath);
14417
14505
  if (!sidecar || !isAlive(sidecar)) continue;
@@ -14421,15 +14509,15 @@ function liveRuns(stateDir, isAlive = runIsAlive) {
14421
14509
  }
14422
14510
  function runActivity(stateDir, isAlive = runIsAlive) {
14423
14511
  const activeRuns = liveRuns(stateDir, isAlive).length;
14424
- const dir = join34(stateDir, "streams");
14512
+ const dir = join35(stateDir, "streams");
14425
14513
  let newest = 0;
14426
- if (existsSync31(dir)) {
14427
- for (const name of readdirSync11(dir)) {
14514
+ if (existsSync32(dir)) {
14515
+ for (const name of readdirSync12(dir)) {
14428
14516
  if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
14429
- const streamPath = join34(dir, name);
14517
+ const streamPath = join35(dir, name);
14430
14518
  if (!runFinished(streamPath)) continue;
14431
14519
  try {
14432
- newest = Math.max(newest, statSync10(`${streamPath}.meta.json`).mtimeMs);
14520
+ newest = Math.max(newest, statSync11(`${streamPath}.meta.json`).mtimeMs);
14433
14521
  } catch {
14434
14522
  }
14435
14523
  }
@@ -14479,7 +14567,7 @@ function describeRun(run4, route2, seatIds, worktreeOf = (d, n) => {
14479
14567
  } catch {
14480
14568
  return null;
14481
14569
  }
14482
- }) {
14570
+ }, o = {}) {
14483
14571
  const ownRoute = run4.route === routeSlug(route2.route);
14484
14572
  const repoDir = run4.repo ? reposOf(route2).find((t) => t.name === run4.repo)?.dir : void 0;
14485
14573
  const num2 = run4.ticket?.replace(/^\D+/, "") ?? "";
@@ -14496,7 +14584,14 @@ function describeRun(run4, route2, seatIds, worktreeOf = (d, n) => {
14496
14584
  deadline: run4.deadline ?? null,
14497
14585
  // CREW-3119: the harness still reads notes, and the process holding its stdin is alive.
14498
14586
  acceptsInput: !!run4.acceptsInput && pidAlive2(run4.ownerPid),
14499
- agentLogId: run4.agentLogRowId ?? null
14587
+ agentLogId: run4.agentLogRowId ?? null,
14588
+ // CREW-3247: the ticket's title, from the board (null when it could not be read).
14589
+ ticketTitle: run4.ticketRecordId ? o.titles?.get(run4.ticketRecordId) ?? null : null,
14590
+ // CREW-3247: this run's own latest text turn, so two runs of one role each have an excerpt.
14591
+ lastEvent: lastStreamEvent(run4.streamPath),
14592
+ // CREW-3247: a live run needs attention when it has outlived its wall-clock limit. A run that
14593
+ // failed is finished and reported on its seat's `lastRun` instead.
14594
+ attention: run4.deadline && Date.parse(run4.deadline) < (o.now ?? Date.now()) ? "past_deadline" : null
14500
14595
  };
14501
14596
  }
14502
14597
 
@@ -14532,7 +14627,7 @@ function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
14532
14627
  if (host === "windows") return [];
14533
14628
  const ctx = installContext();
14534
14629
  const systemd = detectSystemd();
14535
- return ["run", "release", "passengers"].flatMap((job) => planInstall(cfg.ship, crewHome, host, systemd, job, ctx).unitPaths).filter((p) => existsSync32(p));
14630
+ return ["run", "release", "passengers"].flatMap((job) => planInstall(cfg.ship, crewHome, host, systemd, job, ctx).unitPaths).filter((p) => existsSync33(p));
14536
14631
  };
14537
14632
  return {
14538
14633
  liveRuns: () => liveRuns(stateDir).map((r) => ({ role: r.role, route: r.route, pid: r.pid, ticketRecordId: r.ticketRecordId ?? void 0, streamPath: r.streamPath })),
@@ -14600,11 +14695,11 @@ function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
14600
14695
  },
14601
14696
  remaining() {
14602
14697
  const left = [];
14603
- if (existsSync32(cfg.configFile)) left.push(`config ${cfg.configFile}`);
14698
+ if (existsSync33(cfg.configFile)) left.push(`config ${cfg.configFile}`);
14604
14699
  for (const h of forgeHosts()) if (hasForgeToken(cfg.ship.forges, h, stateDir)) left.push(`forge token for ${h}`);
14605
14700
  if (hasRepositoryEnv(stateDir)) left.push("repository environment");
14606
14701
  try {
14607
- for (const k of readdirSync12(keysDir(stateDir))) left.push(`seat key ${k}`);
14702
+ for (const k of readdirSync13(keysDir(stateDir))) left.push(`seat key ${k}`);
14608
14703
  } catch {
14609
14704
  }
14610
14705
  for (const s of sandboxes()) left.push(`sandbox ${s}`);
@@ -15425,9 +15520,9 @@ function managedGitIdentityWarnings(kind, identity) {
15425
15520
 
15426
15521
  // src/selftest.ts
15427
15522
  import { spawn as spawn7 } from "child_process";
15428
- import { existsSync as existsSync33, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync2, readFileSync as readFileSync32, rmSync as rmSync17, writeFileSync as writeFileSync23 } from "fs";
15523
+ import { existsSync as existsSync34, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync2, readFileSync as readFileSync33, rmSync as rmSync17, writeFileSync as writeFileSync23 } from "fs";
15429
15524
  import { tmpdir as tmpdir5 } from "os";
15430
- import { join as join35 } from "path";
15525
+ import { join as join36 } from "path";
15431
15526
  var SELFTEST_TIMEOUT_MS = 12e4;
15432
15527
  var KEY_VAR = "CREW_API_KEY";
15433
15528
  var SELFTEST_PROMPT = "This is a read-only connectivity check. Use the tracker MCP tool to read this workspace (the workspaces find-one tool, using the workspace id below) and reply with the workspace's name alone, on one line. Do not write anything, do not create files, and do not use any other tool.\n\nWorkspace id: ";
@@ -15593,7 +15688,7 @@ async function runSelftest(i, deps = realDeps) {
15593
15688
  ...adapter.runEnv(spec),
15594
15689
  [KEY_VAR]: i.apiKey
15595
15690
  };
15596
- const cwd = mkdtempSync2(join35(tmpdir5(), "crew-selftest-"));
15691
+ const cwd = mkdtempSync2(join36(tmpdir5(), "crew-selftest-"));
15597
15692
  try {
15598
15693
  const run4 = await deps.run({
15599
15694
  bin: invocation.bin,
@@ -15626,11 +15721,11 @@ function formatResult(r) {
15626
15721
  const secs = `${(r.ms / 1e3).toFixed(1)}s`;
15627
15722
  return r.ok ? `${r.toolchain}: PASS ${r.detail} (${secs}${tok})` : `${r.toolchain}: FAIL ${r.failure} \u2014 ${r.detail} (${secs})`;
15628
15723
  }
15629
- var fileFor2 = (stateDir) => join35(stateDir, "selftest.json");
15724
+ var fileFor2 = (stateDir) => join36(stateDir, "selftest.json");
15630
15725
  function readSelftest(stateDir) {
15631
15726
  try {
15632
15727
  const p = fileFor2(stateDir);
15633
- return existsSync33(p) ? JSON.parse(readFileSync32(p, "utf8")) : {};
15728
+ return existsSync34(p) ? JSON.parse(readFileSync33(p, "utf8")) : {};
15634
15729
  } catch {
15635
15730
  return {};
15636
15731
  }
@@ -15651,7 +15746,7 @@ function doctorSelftestLines(stored, toolchains) {
15651
15746
  }
15652
15747
 
15653
15748
  // src/cli.ts
15654
- import { resolve as resolve7, dirname as dirname37, join as join62, basename as basename17 } from "path";
15749
+ import { resolve as resolve7, dirname as dirname37, join as join63, basename as basename17 } from "path";
15655
15750
  import { fileURLToPath as fileURLToPath2 } from "url";
15656
15751
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
15657
15752
  import { spawnSync as spawnSync14 } from "child_process";
@@ -15860,14 +15955,14 @@ function rosterMarkdown(roster, meId) {
15860
15955
  }
15861
15956
 
15862
15957
  // src/connect-resume.ts
15863
- import { mkdirSync as mkdirSync23, readFileSync as readFileSync33, rmSync as rmSync18, writeFileSync as writeFileSync24 } from "fs";
15864
- import { dirname as dirname17, join as join36 } from "path";
15958
+ import { mkdirSync as mkdirSync23, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync24 } from "fs";
15959
+ import { dirname as dirname17, join as join37 } from "path";
15865
15960
  function lastSessionFile(stateDir) {
15866
- return join36(stateDir, "connect-session.json");
15961
+ return join37(stateDir, "connect-session.json");
15867
15962
  }
15868
15963
  function readPointers(stateDir) {
15869
15964
  try {
15870
- const parsed = JSON.parse(readFileSync33(lastSessionFile(stateDir), "utf8"));
15965
+ const parsed = JSON.parse(readFileSync34(lastSessionFile(stateDir), "utf8"));
15871
15966
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
15872
15967
  const out = {};
15873
15968
  for (const [host, v] of Object.entries(parsed)) {
@@ -15967,15 +16062,15 @@ async function signOutSessions(o) {
15967
16062
  }
15968
16063
 
15969
16064
  // src/reset.ts
15970
- import { existsSync as existsSync34, mkdirSync as mkdirSync24, readFileSync as readFileSync34, readdirSync as readdirSync13, rmSync as rmSync19, statSync as statSync11, writeFileSync as writeFileSync25 } from "fs";
15971
- import { dirname as dirname18, join as join37 } from "path";
16065
+ import { existsSync as existsSync35, mkdirSync as mkdirSync24, readFileSync as readFileSync35, readdirSync as readdirSync14, rmSync as rmSync19, statSync as statSync12, writeFileSync as writeFileSync25 } from "fs";
16066
+ import { dirname as dirname18, join as join38 } from "path";
15972
16067
  import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
15973
16068
  function clonedCheckoutsFile(stateDir) {
15974
- return join37(stateDir, "cloned-checkouts.json");
16069
+ return join38(stateDir, "cloned-checkouts.json");
15975
16070
  }
15976
16071
  function readClonedCheckouts(stateDir) {
15977
16072
  try {
15978
- const parsed = JSON.parse(readFileSync34(clonedCheckoutsFile(stateDir), "utf8"));
16073
+ const parsed = JSON.parse(readFileSync35(clonedCheckoutsFile(stateDir), "utf8"));
15979
16074
  return Array.isArray(parsed) ? parsed.filter((d) => typeof d === "string") : [];
15980
16075
  } catch {
15981
16076
  return [];
@@ -16040,7 +16135,7 @@ async function runReset(o, fx) {
16040
16135
  }
16041
16136
  if (o.beforeState) steps.push(...await o.beforeState());
16042
16137
  steps.push(...o.wipeState ? wipeStateDir(o.stateDir, o.dryRun) : removeState(o.stateDir, o.dryRun));
16043
- if (existsSync34(o.configFile)) {
16138
+ if (existsSync35(o.configFile)) {
16044
16139
  if (!o.dryRun) rmSync19(o.configFile, { force: true });
16045
16140
  steps.push({ step: "config", target: o.configFile, action: mark(o.dryRun) });
16046
16141
  } else {
@@ -16049,7 +16144,7 @@ async function runReset(o, fx) {
16049
16144
  return steps;
16050
16145
  }
16051
16146
  function removeCheckout(dir, dryRun, fx) {
16052
- if (!existsSync34(dir)) return { step: "checkout", target: dir, action: "absent", detail: "already gone" };
16147
+ if (!existsSync35(dir)) return { step: "checkout", target: dir, action: "absent", detail: "already gone" };
16053
16148
  const { dirty, linkedWorktrees } = fx.inspectCheckout(dir);
16054
16149
  if (dirty.length) {
16055
16150
  return { step: "checkout", target: dir, action: "kept", detail: `has uncommitted changes (${dirty.length} path${dirty.length === 1 ? "" : "s"}: ${dirty.slice(0, 5).join(", ")}${dirty.length > 5 ? ", \u2026" : ""})` };
@@ -16062,15 +16157,15 @@ function removeCheckout(dir, dryRun, fx) {
16062
16157
  }
16063
16158
  function removeState(stateDir, dryRun) {
16064
16159
  const out = [];
16065
- const targets = [join37(stateDir, "resolved"), join37(stateDir, "keys"), clonedCheckoutsFile(stateDir), join37(stateDir, "connect-session.json"), join37(stateDir, "reload-requested"), join37(stateDir, "daemon.started")];
16160
+ const targets = [join38(stateDir, "resolved"), join38(stateDir, "keys"), clonedCheckoutsFile(stateDir), join38(stateDir, "connect-session.json"), join38(stateDir, "reload-requested"), join38(stateDir, "daemon.started")];
16066
16161
  try {
16067
- for (const name of readdirSync13(stateDir)) {
16068
- if (name.startsWith(".") && statSync11(join37(stateDir, name)).isFile()) targets.push(join37(stateDir, name));
16162
+ for (const name of readdirSync14(stateDir)) {
16163
+ if (name.startsWith(".") && statSync12(join38(stateDir, name)).isFile()) targets.push(join38(stateDir, name));
16069
16164
  }
16070
16165
  } catch {
16071
16166
  }
16072
16167
  for (const t of targets) {
16073
- if (!existsSync34(t)) continue;
16168
+ if (!existsSync35(t)) continue;
16074
16169
  if (!dryRun) rmSync19(t, { recursive: true, force: true });
16075
16170
  out.push({ step: "state", target: t, action: mark(dryRun) });
16076
16171
  }
@@ -16080,12 +16175,12 @@ function removeState(stateDir, dryRun) {
16080
16175
  function wipeStateDir(stateDir, dryRun) {
16081
16176
  let names;
16082
16177
  try {
16083
- names = readdirSync13(stateDir);
16178
+ names = readdirSync14(stateDir);
16084
16179
  } catch {
16085
16180
  return [{ step: "state", target: stateDir, action: "absent", detail: "no state directory" }];
16086
16181
  }
16087
16182
  if (!names.length) return [{ step: "state", target: stateDir, action: "absent", detail: "already empty" }];
16088
- if (!dryRun) for (const n of names) rmSync19(join37(stateDir, n), { recursive: true, force: true });
16183
+ if (!dryRun) for (const n of names) rmSync19(join38(stateDir, n), { recursive: true, force: true });
16089
16184
  return [{ step: "state", target: stateDir, action: mark(dryRun), detail: `${names.length} entr${names.length === 1 ? "y" : "ies"}` }];
16090
16185
  }
16091
16186
  function describeResetStep(s) {
@@ -16167,9 +16262,9 @@ async function runDeprovision(o, fx, deps) {
16167
16262
  }
16168
16263
 
16169
16264
  // src/pool-member.ts
16170
- import { mkdirSync as mkdirSync25, readFileSync as readFileSync35, renameSync as renameSync5, writeFileSync as writeFileSync26 } from "fs";
16265
+ import { mkdirSync as mkdirSync25, readFileSync as readFileSync36, renameSync as renameSync5, writeFileSync as writeFileSync26 } from "fs";
16171
16266
  import { homedir as homedir8 } from "os";
16172
- import { dirname as dirname19, join as join38 } from "path";
16267
+ import { dirname as dirname19, join as join39 } from "path";
16173
16268
  var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
16174
16269
  function backoffMs(attempt) {
16175
16270
  return Math.min(6e4, 5e3 * 2 ** Math.max(0, attempt));
@@ -16411,14 +16506,14 @@ async function runPoolMember(deps) {
16411
16506
  }
16412
16507
  }
16413
16508
  function defaultMemberDir(env = process.env) {
16414
- return env.CREW_POOL_DIR ?? join38(env.XDG_STATE_HOME ?? join38(homedir8(), ".local", "state"), "crew-pool-member");
16509
+ return env.CREW_POOL_DIR ?? join39(env.XDG_STATE_HOME ?? join39(homedir8(), ".local", "state"), "crew-pool-member");
16415
16510
  }
16416
16511
  function fileMemberStore(dir) {
16417
- const file = join38(dir, "member.json");
16512
+ const file = join39(dir, "member.json");
16418
16513
  return {
16419
16514
  read() {
16420
16515
  try {
16421
- return JSON.parse(readFileSync35(file, "utf8"));
16516
+ return JSON.parse(readFileSync36(file, "utf8"));
16422
16517
  } catch {
16423
16518
  return {};
16424
16519
  }
@@ -16478,16 +16573,16 @@ function hostArchitecture(arch = process.arch) {
16478
16573
 
16479
16574
  // src/pool-member-host.ts
16480
16575
  import "child_process";
16481
- import { existsSync as existsSync37 } from "fs";
16576
+ import { existsSync as existsSync38 } from "fs";
16482
16577
  import { hostname as hostname3 } from "os";
16483
16578
 
16484
16579
  // src/machine-id.ts
16485
16580
  import { execFileSync as execFileSync12 } from "child_process";
16486
16581
  import { createHash as createHash8 } from "crypto";
16487
- import { existsSync as existsSync35, mkdirSync as mkdirSync26, readFileSync as readFileSync36, writeFileSync as writeFileSync27 } from "fs";
16488
- import { dirname as dirname20, join as join39 } from "path";
16582
+ import { existsSync as existsSync36, mkdirSync as mkdirSync26, readFileSync as readFileSync37, writeFileSync as writeFileSync27 } from "fs";
16583
+ import { dirname as dirname20, join as join40 } from "path";
16489
16584
  function machineIdPathFor(stateDir) {
16490
- return join39(stateDir, "machine-id");
16585
+ return join40(stateDir, "machine-id");
16491
16586
  }
16492
16587
  var sha256 = (s) => createHash8("sha256").update(s).digest("hex");
16493
16588
  function readRawMachineId(platform2 = process.platform) {
@@ -16500,8 +16595,8 @@ function readRawMachineId(platform2 = process.platform) {
16500
16595
  return /"IOPlatformUUID"\s*=\s*"([^"]+)"/.exec(out)?.[1];
16501
16596
  }
16502
16597
  for (const p of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
16503
- if (existsSync35(p)) {
16504
- const id = readFileSync36(p, "utf8").trim();
16598
+ if (existsSync36(p)) {
16599
+ const id = readFileSync37(p, "utf8").trim();
16505
16600
  if (id) return id;
16506
16601
  }
16507
16602
  }
@@ -16512,8 +16607,8 @@ function readRawMachineId(platform2 = process.platform) {
16512
16607
  function ensureMachineId(stateDir, opts = {}) {
16513
16608
  if (opts.override?.trim()) return sha256(opts.override.trim());
16514
16609
  const path = machineIdPathFor(stateDir);
16515
- if (existsSync35(path)) {
16516
- const cached = readFileSync36(path, "utf8").trim();
16610
+ if (existsSync36(path)) {
16611
+ const cached = readFileSync37(path, "utf8").trim();
16517
16612
  if (/^[0-9a-f]{64}$/.test(cached)) return cached;
16518
16613
  }
16519
16614
  const raw = (opts.read ?? readRawMachineId)();
@@ -16533,7 +16628,7 @@ function matchShipRows(ships, shipName2, machineId) {
16533
16628
 
16534
16629
  // src/provision.ts
16535
16630
  import { spawnSync as spawnSync9 } from "child_process";
16536
- import { existsSync as existsSync36, readFileSync as readFileSync37, writeFileSync as writeFileSync28 } from "fs";
16631
+ import { existsSync as existsSync37, readFileSync as readFileSync38, writeFileSync as writeFileSync28 } from "fs";
16537
16632
  import { hostname as hostname2 } from "os";
16538
16633
  import { parseDocument as parseDocument3, isMap as isMap2, isScalar } from "yaml";
16539
16634
 
@@ -16542,7 +16637,7 @@ import { parseDocument as parseDocument2 } from "yaml";
16542
16637
 
16543
16638
  // src/repos-cmd.ts
16544
16639
  import { homedir as homedir9 } from "os";
16545
- import { basename as basename10, join as join40, resolve as resolve4 } from "path";
16640
+ import { basename as basename10, join as join41, resolve as resolve4 } from "path";
16546
16641
  import { isMap, isSeq, parseDocument, stringify as stringify2 } from "yaml";
16547
16642
  var ReposError = class extends Error {
16548
16643
  };
@@ -16820,7 +16915,7 @@ function planRepoClone(i) {
16820
16915
  }
16821
16916
  const ship = doc.get("ship", true);
16822
16917
  const basePath = String(m.get("reposBasePath") ?? (isMap(ship) ? ship.get("reposBasePath") : void 0) ?? "~/Crew");
16823
- const target = i.dir ? expandDir(i.dir, i.base) : join40(expandDir(basePath, i.base), i.route.split("/")[0], name);
16918
+ const target = i.dir ? expandDir(i.dir, i.base) : join41(expandDir(basePath, i.base), i.route.split("/")[0], name);
16824
16919
  const add = planRepoAdd({ text: i.text, base: i.base, route: i.route, path: target, origin: remote, resolved: i.resolved, name, isCheckout: i.isCheckout });
16825
16920
  const forgeHost = i.resolved?.repoForgeHosts?.[id];
16826
16921
  return { ...add, remote, target, ...forgeHost ? { forgeHost } : {} };
@@ -17151,7 +17246,7 @@ function realProvisionDeps(crewHome) {
17151
17246
  };
17152
17247
  const configFile = () => {
17153
17248
  const f = findConfigFile(crewHome);
17154
- return existsSync36(f) ? f : null;
17249
+ return existsSync37(f) ? f : null;
17155
17250
  };
17156
17251
  return {
17157
17252
  crew: spawnCrew,
@@ -17159,7 +17254,7 @@ function realProvisionDeps(crewHome) {
17159
17254
  enableRoute(route2) {
17160
17255
  const file = configFile();
17161
17256
  if (!file) return false;
17162
- const text2 = readFileSync37(file, "utf8");
17257
+ const text2 = readFileSync38(file, "utf8");
17163
17258
  const doc = parseDocument3(text2);
17164
17259
  const routes = doc.get("routes");
17165
17260
  const entry = routes?.items?.find((r) => r.get("route") === route2);
@@ -17185,14 +17280,14 @@ function realProvisionDeps(crewHome) {
17185
17280
  continue;
17186
17281
  }
17187
17282
  for (const p of plan.unitPaths) {
17188
- if (!existsSync36(p) || readFileSync37(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
17283
+ if (!existsSync37(p) || readFileSync38(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
17189
17284
  }
17190
17285
  }
17191
17286
  const label = labelFor(crewHome, "run");
17192
17287
  let running = false;
17193
17288
  let lingering = true;
17194
17289
  if (mechanism === "systemd") {
17195
- const system = ctx.root || existsSync36(systemUnitPathFor(label));
17290
+ const system = ctx.root || existsSync37(systemUnitPathFor(label));
17196
17291
  const ctl = system ? ["systemctl"] : ["systemctl", "--user"];
17197
17292
  running = spawnSync9(ctl[0], [...ctl.slice(1), "is-active", "--quiet", `${label}.service`], { env: withUserBusEnv() }).status === 0;
17198
17293
  if (!system) {
@@ -17209,7 +17304,7 @@ function realProvisionDeps(crewHome) {
17209
17304
  setShipSetting(key, value2) {
17210
17305
  const file = configFile();
17211
17306
  if (!file) return false;
17212
- const doc = parseDocument3(readFileSync37(file, "utf8"));
17307
+ const doc = parseDocument3(readFileSync38(file, "utf8"));
17213
17308
  if (doc.getIn(["ship", key]) === value2) return false;
17214
17309
  doc.setIn(["ship", key], value2);
17215
17310
  writeFileSync28(file, doc.toString());
@@ -17218,7 +17313,7 @@ function realProvisionDeps(crewHome) {
17218
17313
  applyManagedDefaults() {
17219
17314
  const file = configFile();
17220
17315
  if (!file) return [];
17221
- const doc = parseDocument3(readFileSync37(file, "utf8"));
17316
+ const doc = parseDocument3(readFileSync38(file, "utf8"));
17222
17317
  const wrote = applyManagedDefaultsToDoc(doc);
17223
17318
  if (wrote.length) writeFileSync28(file, doc.toString());
17224
17319
  return wrote;
@@ -17270,7 +17365,7 @@ function realPoolMemberDeps(o) {
17270
17365
  crewVersion: crewVersion(o.crewHome),
17271
17366
  hostname: hostname3()
17272
17367
  },
17273
- hasShipConfig: () => existsSync37(findConfigFile(o.crewHome)),
17368
+ hasShipConfig: () => existsSync38(findConfigFile(o.crewHome)),
17274
17369
  async provision(lease, instanceClass, shipKind) {
17275
17370
  const hosts = lease.forges.map((f) => f.host.toLowerCase());
17276
17371
  const lines2 = [];
@@ -18194,7 +18289,7 @@ ${waiting.map((t) => `| ${displayKey2(t)} | ${t.status} | ${blockers(t, i)} |`).
18194
18289
 
18195
18290
  // src/sandbox-hygiene.ts
18196
18291
  import { execFile as execFile3 } from "child_process";
18197
- import { existsSync as existsSync38, statfsSync as statfsSync2 } from "fs";
18292
+ import { existsSync as existsSync39, statfsSync as statfsSync2 } from "fs";
18198
18293
  import { promisify as promisify3 } from "util";
18199
18294
  var execFileP3 = promisify3(execFile3);
18200
18295
  var REAP_MIN_AGE_MS = 5 * 6e4;
@@ -18337,7 +18432,7 @@ async function realDiskReadings(ship) {
18337
18432
  const paths = ["/"];
18338
18433
  try {
18339
18434
  const root = (await run3(ship.sandbox?.engine ?? DEFAULT_CACHE_SETTINGS.engine, ["info", "--format", "{{.DockerRootDir}}"])).trim();
18340
- if (root && existsSync38(root)) paths.push(root);
18435
+ if (root && existsSync39(root)) paths.push(root);
18341
18436
  } catch {
18342
18437
  }
18343
18438
  return paths.flatMap((path) => {
@@ -18379,7 +18474,7 @@ function diskFullStop(state) {
18379
18474
 
18380
18475
  // src/poll.ts
18381
18476
  import { writeFileSync as writeFileSync29 } from "fs";
18382
- import { join as join41 } from "path";
18477
+ import { join as join42 } from "path";
18383
18478
 
18384
18479
  // src/stalled.ts
18385
18480
  var STALLED_AFTER_CYCLES = 30;
@@ -18695,7 +18790,7 @@ async function decideCycle(o) {
18695
18790
  }
18696
18791
  return decision;
18697
18792
  }
18698
- var digestPath = (stateDir, route2, role, runId) => join41(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
18793
+ var digestPath = (stateDir, route2, role, runId) => join42(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
18699
18794
  function otherRunsRemoved(tickets, own) {
18700
18795
  if (!own) return tickets;
18701
18796
  return tickets.filter((t) => t.id === own.ticket.id || !own.inFlight(t.id));
@@ -18904,7 +18999,7 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
18904
18999
  }
18905
19000
 
18906
19001
  // src/repo-refresh.ts
18907
- import { existsSync as existsSync39, mkdirSync as mkdirSync27, readFileSync as readFileSync38, writeFileSync as writeFileSync30 } from "fs";
19002
+ import { existsSync as existsSync40, mkdirSync as mkdirSync27, readFileSync as readFileSync39, writeFileSync as writeFileSync30 } from "fs";
18908
19003
  import { dirname as dirname22 } from "path";
18909
19004
  var REFRESH_COOLDOWN_MS = 2 * 6e4;
18910
19005
  var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
@@ -18934,8 +19029,8 @@ function applyRepoRows(resolved, rows) {
18934
19029
  }
18935
19030
  function persistRepoRows(stateDir, routeName, rows) {
18936
19031
  const path = resolvedPathFor(stateDir, routeName);
18937
- if (!existsSync39(path)) return;
18938
- const raw = JSON.parse(readFileSync38(path, "utf8"));
19032
+ if (!existsSync40(path)) return;
19033
+ const raw = JSON.parse(readFileSync39(path, "utf8"));
18939
19034
  applyRepoRows(raw, rows);
18940
19035
  mkdirSync27(dirname22(path), { recursive: true });
18941
19036
  writeFileSync30(path, `${JSON.stringify(raw, null, 2)}
@@ -19414,7 +19509,7 @@ Ship ${shipName2} found: ${problem}. The release refuses to squash a ref nobody
19414
19509
  var localRefSkipReported = (ticket, problem, events) => events.some((e) => e.record_id === ticket.id && e.event_type === "local_ref_skip" && (e.message ?? "").includes(problem));
19415
19510
 
19416
19511
  // src/platform-gate.ts
19417
- import { join as join42 } from "path";
19512
+ import { join as join43 } from "path";
19418
19513
  function platformAdmitters(dir, baseRef, ship, tickets, locate) {
19419
19514
  const out = [];
19420
19515
  for (const t of tickets) {
@@ -19426,7 +19521,7 @@ function platformAdmitters(dir, baseRef, ship, tickets, locate) {
19426
19521
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
19427
19522
  if (text2 === null) continue;
19428
19523
  try {
19429
- const { platform: platform2 } = parseRepoConfig(text2, join42(dir, file));
19524
+ const { platform: platform2 } = parseRepoConfig(text2, join43(dir, file));
19430
19525
  if (satisfies(ship, platform2)) out.push({ issueId: t.issue_id, branch, platform: platform2 });
19431
19526
  } catch (e) {
19432
19527
  if (e instanceof RepoConfigError) continue;
@@ -19442,13 +19537,13 @@ function platformStuckNote(repo, required, ship, issueIds) {
19442
19537
  }
19443
19538
 
19444
19539
  // src/connect-wizard.ts
19445
- import { delimiter, dirname as dirname23, join as join43 } from "path";
19446
- import { accessSync as accessSync3, constants as constants3, existsSync as existsSync40, mkdirSync as mkdirSync28, writeFileSync as writeFileSync31 } from "fs";
19540
+ import { delimiter, dirname as dirname23, join as join44 } from "path";
19541
+ import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync28, writeFileSync as writeFileSync31 } from "fs";
19447
19542
  import { stringify as stringify3 } from "yaml";
19448
19543
  var HOST_PASSENGERS_DOCS_URL = "https://crew.tablation.dev/host-passengers";
19449
19544
  function shouldRunWizard(opts) {
19450
19545
  if (!opts.isTTY) return false;
19451
- const exists = opts.configExists ?? existsSync40;
19546
+ const exists = opts.configExists ?? existsSync41;
19452
19547
  return !configSearchPath(opts.crewHome).some((p) => exists(p));
19453
19548
  }
19454
19549
  function firstRunConfigPath() {
@@ -19465,7 +19560,7 @@ function defaultIsExecutable(p) {
19465
19560
  function findOnPath2(name, pathEnv, isExecutable = defaultIsExecutable) {
19466
19561
  for (const dir of pathEnv.split(delimiter)) {
19467
19562
  if (!dir) continue;
19468
- const candidate = join43(dir, name);
19563
+ const candidate = join44(dir, name);
19469
19564
  if (isExecutable(candidate)) return candidate;
19470
19565
  }
19471
19566
  return void 0;
@@ -19562,7 +19657,7 @@ Wrote ${o.configPath}.
19562
19657
  // src/connect-json.ts
19563
19658
  import { accessSync as accessSync4, constants as constants4 } from "fs";
19564
19659
  import { homedir as homedir10 } from "os";
19565
- import { dirname as dirname24, join as join44 } from "path";
19660
+ import { dirname as dirname24, join as join45 } from "path";
19566
19661
  import { delimiter as delimiter2 } from "path";
19567
19662
  var CHOICE_EXIT_CODE = 3;
19568
19663
  function createEmitter(json2, write) {
@@ -19601,12 +19696,12 @@ function agentBinSearchDirs(home, pathEnv, extraPath) {
19601
19696
  const dirs = [
19602
19697
  ...pathEnv.split(delimiter2),
19603
19698
  ...(extraPath ?? "").split(delimiter2),
19604
- join44(home, ".local/bin"),
19605
- join44(home, ".claude/local"),
19699
+ join45(home, ".local/bin"),
19700
+ join45(home, ".claude/local"),
19606
19701
  "/opt/homebrew/bin",
19607
19702
  "/usr/local/bin",
19608
- join44(home, ".npm-global/bin"),
19609
- join44(home, ".volta/bin")
19703
+ join45(home, ".npm-global/bin"),
19704
+ join45(home, ".volta/bin")
19610
19705
  ];
19611
19706
  return [...new Set(dirs.filter(Boolean))];
19612
19707
  }
@@ -19727,8 +19822,8 @@ async function collectDiagnostics(d) {
19727
19822
  }
19728
19823
 
19729
19824
  // src/release-run.ts
19730
- import { readFileSync as readFileSync39, writeFileSync as writeFileSync32, existsSync as existsSync41, copyFileSync, mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync3, rmSync as rmSync20 } from "fs";
19731
- import { dirname as dirname25, join as join45 } from "path";
19825
+ import { readFileSync as readFileSync40, writeFileSync as writeFileSync32, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync3, rmSync as rmSync20 } from "fs";
19826
+ import { dirname as dirname25, join as join46 } from "path";
19732
19827
  import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
19733
19828
 
19734
19829
  // src/release.ts
@@ -20518,13 +20613,13 @@ async function bump(o, size) {
20518
20613
  }
20519
20614
  return printed;
20520
20615
  }
20521
- const files = o.repo.release.versionFiles.map((f) => join45(o.cwd, f));
20616
+ const files = o.repo.release.versionFiles.map((f) => join46(o.cwd, f));
20522
20617
  const first = files[0];
20523
- if (!existsAt(first, existsSync41)) {
20618
+ if (!existsAt(first, existsSync42)) {
20524
20619
  o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
20525
20620
  return null;
20526
20621
  }
20527
- const firstText = readTextAt(first, (p) => readFileSync39(p, "utf8"));
20622
+ const firstText = readTextAt(first, (p) => readFileSync40(p, "utf8"));
20528
20623
  const problem = versionFileProblem(o.repo.release.versionFiles[0], firstText);
20529
20624
  if (problem) {
20530
20625
  o.emit.error(problem);
@@ -20543,7 +20638,7 @@ async function bump(o, size) {
20543
20638
  return version;
20544
20639
  }
20545
20640
  for (const f of files) {
20546
- const src = readTextAt(f, (p) => readFileSync39(p, "utf8"));
20641
+ const src = readTextAt(f, (p) => readFileSync40(p, "utf8"));
20547
20642
  const out = src.replace(/("version"\s*:\s*")[^"]*(")/, `$1${version}$2`);
20548
20643
  if (out === src) {
20549
20644
  o.emit.error(`no version field in ${f}`);
@@ -20556,13 +20651,13 @@ async function bump(o, size) {
20556
20651
  function writeChangelog(o, version, entries) {
20557
20652
  const file = o.repo.release.changelog;
20558
20653
  if (!file || entries.length === 0) return;
20559
- const path = join45(o.cwd, file);
20654
+ const path = join46(o.cwd, file);
20560
20655
  const section = renderChangelogSection(version, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), entries);
20561
20656
  if (o.dryRun) {
20562
20657
  o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
20563
20658
  return;
20564
20659
  }
20565
- const existing = existsAt(path, existsSync41) ? readTextAt(path, (p) => readFileSync39(p, "utf8")) : "# Changelog\n";
20660
+ const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) => readFileSync40(p, "utf8")) : "# Changelog\n";
20566
20661
  writeTextAt(path, insertChangelogSection(existing, section), writeFileSync32);
20567
20662
  }
20568
20663
  async function confirm(o, expected) {
@@ -20656,8 +20751,8 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
20656
20751
  function openReleaseCheckout(o) {
20657
20752
  const { remote, base } = o.repo.branch;
20658
20753
  const branch = `crew/release-${Date.now()}`;
20659
- const root = mkdtempSync3(join45(tmpdir6(), "crew-release-"));
20660
- const dir = join45(root, "checkout");
20754
+ const root = mkdtempSync3(join46(tmpdir6(), "crew-release-"));
20755
+ const dir = join46(root, "checkout");
20661
20756
  o.emit.emit(`release checkout: ${dir}`, { step: "release" });
20662
20757
  const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
20663
20758
  try {
@@ -20667,10 +20762,10 @@ function openReleaseCheckout(o) {
20667
20762
  throw e;
20668
20763
  }
20669
20764
  for (const f of o.repo.worktrees.copy) {
20670
- const src = join45(o.cwd, f);
20671
- if (!existsSync41(src)) continue;
20672
- mkdirSync29(dirname25(join45(dir, f)), { recursive: true });
20673
- copyFileSync(src, join45(dir, f));
20765
+ const src = join46(o.cwd, f);
20766
+ if (!existsSync42(src)) continue;
20767
+ mkdirSync29(dirname25(join46(dir, f)), { recursive: true });
20768
+ copyFileSync(src, join46(dir, f));
20674
20769
  }
20675
20770
  return { dir, branch, close };
20676
20771
  }
@@ -21489,15 +21584,15 @@ async function runCommentDeliveryPass(deps) {
21489
21584
  }
21490
21585
 
21491
21586
  // src/launchd-start.ts
21492
- import { readFileSync as readFileSync46 } from "fs";
21587
+ import { readFileSync as readFileSync47 } from "fs";
21493
21588
  import { spawnSync as spawnSync12 } from "child_process";
21494
21589
 
21495
21590
  // src/daemon-liveness.ts
21496
- import { existsSync as existsSync48, readFileSync as readFileSync45 } from "fs";
21591
+ import { existsSync as existsSync49, readFileSync as readFileSync46 } from "fs";
21497
21592
 
21498
21593
  // src/daemon.ts
21499
- import { existsSync as existsSync47, mkdirSync as mkdirSync35, readFileSync as readFileSync44, readdirSync as readdirSync14, rmSync as rmSync22, statSync as statSync13, writeFileSync as writeFileSync36 } from "fs";
21500
- import { join as join50 } from "path";
21594
+ import { existsSync as existsSync48, mkdirSync as mkdirSync35, readFileSync as readFileSync45, readdirSync as readdirSync15, rmSync as rmSync22, statSync as statSync14, writeFileSync as writeFileSync36 } from "fs";
21595
+ import { join as join51 } from "path";
21501
21596
  import { randomBytes } from "crypto";
21502
21597
 
21503
21598
  // src/fleet.ts
@@ -21587,16 +21682,16 @@ function nextRoles(decision, ran) {
21587
21682
  }
21588
21683
 
21589
21684
  // src/noop-runs.ts
21590
- import { existsSync as existsSync42, mkdirSync as mkdirSync30, readFileSync as readFileSync40, renameSync as renameSync6, writeFileSync as writeFileSync33 } from "fs";
21591
- import { join as join46 } from "path";
21685
+ import { existsSync as existsSync43, mkdirSync as mkdirSync30, readFileSync as readFileSync41, renameSync as renameSync6, writeFileSync as writeFileSync33 } from "fs";
21686
+ import { join as join47 } from "path";
21592
21687
  var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
21593
21688
  var DEFAULT_NOOP_REPEATS = 3;
21594
21689
  var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
21595
- var noopRunsPath = (stateDir) => join46(stateDir, "noop-runs.json");
21690
+ var noopRunsPath = (stateDir) => join47(stateDir, "noop-runs.json");
21596
21691
  var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
21597
21692
  function readNoopRuns(stateDir) {
21598
21693
  try {
21599
- const v = JSON.parse(readFileSync40(noopRunsPath(stateDir), "utf8"));
21694
+ const v = JSON.parse(readFileSync41(noopRunsPath(stateDir), "utf8"));
21600
21695
  return v && typeof v === "object" && !Array.isArray(v) ? v : {};
21601
21696
  } catch {
21602
21697
  return {};
@@ -21622,7 +21717,7 @@ function recordNoopRun(stateDir, recordId, repeats, now = Date.now()) {
21622
21717
  return { count, nextAt, bounce: count >= repeats };
21623
21718
  }
21624
21719
  function clearNoopRuns(stateDir, recordId) {
21625
- if (!existsSync42(noopRunsPath(stateDir))) return;
21720
+ if (!existsSync43(noopRunsPath(stateDir))) return;
21626
21721
  const state = readNoopRuns(stateDir);
21627
21722
  if (!(recordId in state)) return;
21628
21723
  delete state[recordId];
@@ -21682,7 +21777,7 @@ async function settleNoopRun(o) {
21682
21777
  }
21683
21778
 
21684
21779
  // src/ship-name.ts
21685
- import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync41, renameSync as renameSync7, writeFileSync as writeFileSync34 } from "fs";
21780
+ import { existsSync as existsSync44, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync7, writeFileSync as writeFileSync34 } from "fs";
21686
21781
  import { dirname as dirname26 } from "path";
21687
21782
  import { parseDocument as parseDocument4 } from "yaml";
21688
21783
  var ShipNameError = class extends Error {
@@ -21744,19 +21839,19 @@ async function syncRouteName(i) {
21744
21839
  return { status: "ok", ...base, action, name: i.local };
21745
21840
  }
21746
21841
  function readSyncedName(resolvedFile) {
21747
- if (!existsSync43(resolvedFile)) return void 0;
21842
+ if (!existsSync44(resolvedFile)) return void 0;
21748
21843
  try {
21749
- const v = JSON.parse(readFileSync41(resolvedFile, "utf8")).shipName;
21844
+ const v = JSON.parse(readFileSync42(resolvedFile, "utf8")).shipName;
21750
21845
  return typeof v === "string" ? v : void 0;
21751
21846
  } catch {
21752
21847
  return void 0;
21753
21848
  }
21754
21849
  }
21755
21850
  function writeSyncedName(resolvedFile, name) {
21756
- if (!existsSync43(resolvedFile)) return;
21851
+ if (!existsSync44(resolvedFile)) return;
21757
21852
  let raw;
21758
21853
  try {
21759
- raw = JSON.parse(readFileSync41(resolvedFile, "utf8"));
21854
+ raw = JSON.parse(readFileSync42(resolvedFile, "utf8"));
21760
21855
  } catch {
21761
21856
  return;
21762
21857
  }
@@ -21771,7 +21866,7 @@ function writeSyncedName(resolvedFile, name) {
21771
21866
  async function reconcileShipName(i) {
21772
21867
  let local = i.ship.name;
21773
21868
  try {
21774
- local = shipNameOfYaml(readFileSync41(i.configFile, "utf8")) ?? local;
21869
+ local = shipNameOfYaml(readFileSync42(i.configFile, "utf8")) ?? local;
21775
21870
  } catch {
21776
21871
  }
21777
21872
  const resolvedFile = resolvedPathFor(i.stateDir, i.route);
@@ -21795,7 +21890,7 @@ async function reconcileShipName(i) {
21795
21890
  }
21796
21891
  if (result.status !== "ok") return result;
21797
21892
  if (result.action === "adopt" || result.action === "row-wins") {
21798
- const text2 = readFileSync41(i.configFile, "utf8");
21893
+ const text2 = readFileSync42(i.configFile, "utf8");
21799
21894
  writeFileSync34(i.configFile, setShipNameInYaml(text2, result.name));
21800
21895
  i.ship.name = result.name;
21801
21896
  if (result.action === "row-wins") {
@@ -21841,7 +21936,7 @@ async function reconcileRouteShipName(o) {
21841
21936
  }
21842
21937
 
21843
21938
  // src/mirror-contract.ts
21844
- import { existsSync as existsSync44 } from "fs";
21939
+ import { existsSync as existsSync45 } from "fs";
21845
21940
 
21846
21941
  // src/passenger-mirror.ts
21847
21942
  import { mkdirSync as mkdirSync32 } from "fs";
@@ -21882,7 +21977,7 @@ function mirrorOutcome(m) {
21882
21977
 
21883
21978
  // src/mirror-contract.ts
21884
21979
  function lacksCheckout(ship, dir) {
21885
- return ship.runner === "sandbox" && !existsSync44(dir) && !remoteOf(dir);
21980
+ return ship.runner === "sandbox" && !existsSync45(dir) && !remoteOf(dir);
21886
21981
  }
21887
21982
  function skipsHostCheckout(ship) {
21888
21983
  return ship.runner === "sandbox";
@@ -21963,17 +22058,17 @@ function explainRefusal(readable, unreadable) {
21963
22058
 
21964
22059
  // src/ssh-keys.ts
21965
22060
  import { execFileSync as execFileSync13 } from "child_process";
21966
- import { existsSync as existsSync45, mkdirSync as mkdirSync33, readFileSync as readFileSync42, chmodSync as chmodSync3 } from "fs";
21967
- import { dirname as dirname28, join as join47 } from "path";
22061
+ import { existsSync as existsSync46, mkdirSync as mkdirSync33, readFileSync as readFileSync43, chmodSync as chmodSync3 } from "fs";
22062
+ import { dirname as dirname28, join as join48 } from "path";
21968
22063
  var SshKeyError = class extends Error {
21969
22064
  };
21970
22065
  function shipSshKeyPathFor(stateDir) {
21971
- return join47(stateDir, "ssh", "id_ed25519");
22066
+ return join48(stateDir, "ssh", "id_ed25519");
21972
22067
  }
21973
22068
  function ensureShipSshKeypair(stateDir) {
21974
22069
  const privateKeyPath = shipSshKeyPathFor(stateDir);
21975
22070
  const publicKeyPath = `${privateKeyPath}.pub`;
21976
- if (!existsSync45(privateKeyPath)) {
22071
+ if (!existsSync46(privateKeyPath)) {
21977
22072
  mkdirSync33(dirname28(privateKeyPath), { recursive: true });
21978
22073
  try {
21979
22074
  execFileSync13("ssh-keygen", [
@@ -21994,10 +22089,10 @@ function ensureShipSshKeypair(stateDir) {
21994
22089
  }
21995
22090
  chmodSync3(privateKeyPath, 384);
21996
22091
  }
21997
- if (!existsSync45(publicKeyPath)) {
22092
+ if (!existsSync46(publicKeyPath)) {
21998
22093
  throw new SshKeyError(`${privateKeyPath} exists but ${publicKeyPath} does not \u2014 regenerate or restore it`);
21999
22094
  }
22000
- const publicKey = readFileSync42(publicKeyPath, "utf8").trim();
22095
+ const publicKey = readFileSync43(publicKeyPath, "utf8").trim();
22001
22096
  return { privateKeyPath, publicKeyPath, publicKey };
22002
22097
  }
22003
22098
  function sshKeygenAvailable() {
@@ -22011,8 +22106,8 @@ function sshKeygenAvailable() {
22011
22106
 
22012
22107
  // src/periscope-idle.ts
22013
22108
  import { execFileSync as execFileSync14 } from "child_process";
22014
- import { statSync as statSync12 } from "fs";
22015
- import { join as join48 } from "path";
22109
+ import { statSync as statSync13 } from "fs";
22110
+ import { join as join49 } from "path";
22016
22111
  var MAX_SCANNED_FILES = 2e4;
22017
22112
  function newestWorktreeMtime(root) {
22018
22113
  const a = newestTrackedMtime(root);
@@ -22037,7 +22132,7 @@ function newestTrackedMtime(root) {
22037
22132
  if (!rel) continue;
22038
22133
  if (++scanned > MAX_SCANNED_FILES) break;
22039
22134
  try {
22040
- const m = statSync12(join48(root, rel)).mtimeMs;
22135
+ const m = statSync13(join49(root, rel)).mtimeMs;
22041
22136
  if (newest === null || m > newest) newest = m;
22042
22137
  } catch {
22043
22138
  }
@@ -22111,8 +22206,8 @@ async function runPeriscopeIdlePass(d) {
22111
22206
  }
22112
22207
 
22113
22208
  // src/periscope-cmd.ts
22114
- import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync43, rmSync as rmSync21, writeFileSync as writeFileSync35 } from "fs";
22115
- import { join as join49 } from "path";
22209
+ import { existsSync as existsSync47, mkdirSync as mkdirSync34, readFileSync as readFileSync44, rmSync as rmSync21, writeFileSync as writeFileSync35 } from "fs";
22210
+ import { join as join50 } from "path";
22116
22211
  var PeriscopeError = class extends Error {
22117
22212
  };
22118
22213
  var LivePeriscopeError = class extends PeriscopeError {
@@ -22122,8 +22217,8 @@ var LivePeriscopeError = class extends PeriscopeError {
22122
22217
  this.data = { refused: "live_periscope_exists", ...live2 };
22123
22218
  }
22124
22219
  };
22125
- var priorDir = (stateDir) => join49(stateDir, "periscope-priors");
22126
- var priorPath = (stateDir, ticketRecordId) => join49(priorDir(stateDir), `${ticketRecordId}.json`);
22220
+ var priorDir = (stateDir) => join50(stateDir, "periscope-priors");
22221
+ var priorPath = (stateDir, ticketRecordId) => join50(priorDir(stateDir), `${ticketRecordId}.json`);
22127
22222
  function removePeriscopePrior(stateDir, ticketRecordId) {
22128
22223
  rmSync21(priorPath(stateDir, ticketRecordId), { force: true });
22129
22224
  }
@@ -22137,7 +22232,7 @@ function writePeriscopePrior(stateDir, ticketRecordId, prior) {
22137
22232
  function readPeriscopePrior(stateDir, ticketRecordId) {
22138
22233
  try {
22139
22234
  const p = priorPath(stateDir, ticketRecordId);
22140
- return existsSync46(p) ? JSON.parse(readFileSync43(p, "utf8")) : void 0;
22235
+ return existsSync47(p) ? JSON.parse(readFileSync44(p, "utf8")) : void 0;
22141
22236
  } catch {
22142
22237
  return void 0;
22143
22238
  }
@@ -22699,15 +22794,15 @@ async function runDaemonLoop(o) {
22699
22794
  function latestMtime(path) {
22700
22795
  let stat2;
22701
22796
  try {
22702
- stat2 = statSync13(path);
22797
+ stat2 = statSync14(path);
22703
22798
  } catch {
22704
22799
  return 0;
22705
22800
  }
22706
22801
  if (stat2.isFile()) return stat2.mtimeMs;
22707
22802
  if (!stat2.isDirectory()) return 0;
22708
22803
  let latest = stat2.mtimeMs;
22709
- for (const entry of readdirSync14(path, { withFileTypes: true })) {
22710
- latest = Math.max(latest, latestMtime(join50(path, entry.name)));
22804
+ for (const entry of readdirSync15(path, { withFileTypes: true })) {
22805
+ latest = Math.max(latest, latestMtime(join51(path, entry.name)));
22711
22806
  }
22712
22807
  return latest;
22713
22808
  }
@@ -22716,20 +22811,20 @@ function computeTreeSignature(paths) {
22716
22811
  }
22717
22812
  function makeStaleChecker(paths, opts = {}) {
22718
22813
  const initial = computeTreeSignature(paths);
22719
- return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync47(opts.reloadSentinel);
22814
+ return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync48(opts.reloadSentinel);
22720
22815
  }
22721
22816
  function reloadSentinelFor(stateDir) {
22722
- return join50(stateDir, "reload-requested");
22817
+ return join51(stateDir, "reload-requested");
22723
22818
  }
22724
22819
  function readReloadRequestedAt(stateDir) {
22725
22820
  try {
22726
- return statSync13(reloadSentinelFor(stateDir)).mtimeMs;
22821
+ return statSync14(reloadSentinelFor(stateDir)).mtimeMs;
22727
22822
  } catch {
22728
22823
  return null;
22729
22824
  }
22730
22825
  }
22731
22826
  function daemonStampFor(stateDir) {
22732
- return join50(stateDir, "daemon.started");
22827
+ return join51(stateDir, "daemon.started");
22733
22828
  }
22734
22829
  function noteDaemonStarted(stateDir, now = Date.now()) {
22735
22830
  mkdirSync35(stateDir, { recursive: true });
@@ -22739,7 +22834,7 @@ function noteDaemonStarted(stateDir, now = Date.now()) {
22739
22834
  }
22740
22835
  function readDaemonStarted(stateDir) {
22741
22836
  try {
22742
- const v = JSON.parse(readFileSync44(daemonStampFor(stateDir), "utf8")).startedAt;
22837
+ const v = JSON.parse(readFileSync45(daemonStampFor(stateDir), "utf8")).startedAt;
22743
22838
  return typeof v === "number" ? v : null;
22744
22839
  } catch {
22745
22840
  return null;
@@ -22748,7 +22843,7 @@ function readDaemonStarted(stateDir) {
22748
22843
  function configChangedAfter(files, startedAt) {
22749
22844
  for (const f of files) {
22750
22845
  try {
22751
- if (statSync13(f).mtimeMs > startedAt) return f;
22846
+ if (statSync14(f).mtimeMs > startedAt) return f;
22752
22847
  } catch {
22753
22848
  }
22754
22849
  }
@@ -23596,7 +23691,7 @@ function parseSystemctlShow(text2) {
23596
23691
  }
23597
23692
  function lastLogLine(path, read = (p) => {
23598
23693
  try {
23599
- return readFileSync45(p, "utf8");
23694
+ return readFileSync46(p, "utf8");
23600
23695
  } catch {
23601
23696
  return null;
23602
23697
  }
@@ -23623,7 +23718,7 @@ function probeDaemonUnit(o) {
23623
23718
  const r = spawnSync11(cmd[0], cmd.slice(1), { encoding: "utf8" });
23624
23719
  return r.error ? null : { status: r.status, stdout: r.stdout ?? "" };
23625
23720
  });
23626
- const installed = o.plan.unitPaths.some((p) => existsSync48(p));
23721
+ const installed = o.plan.unitPaths.some((p) => existsSync49(p));
23627
23722
  let reading = null;
23628
23723
  if (installed && o.plan.mechanism === "launchd") {
23629
23724
  const r = run4(["launchctl", "print", `gui/${o.uid}/${o.label}`]);
@@ -23673,7 +23768,7 @@ function daemonProblem(d, route2) {
23673
23768
  }
23674
23769
  function readDaemonStamp(stateDir) {
23675
23770
  try {
23676
- const v = JSON.parse(readFileSync45(daemonStampFor(stateDir), "utf8"));
23771
+ const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8"));
23677
23772
  if (typeof v.startedAt !== "number") return null;
23678
23773
  return typeof v.pid === "number" ? { pid: v.pid, startedAt: v.startedAt } : { startedAt: v.startedAt };
23679
23774
  } catch {
@@ -23702,7 +23797,7 @@ function defaultSleep2(ms3) {
23702
23797
  }
23703
23798
  function defaultReadLog(path) {
23704
23799
  try {
23705
- return readFileSync46(path, "utf8");
23800
+ return readFileSync47(path, "utf8");
23706
23801
  } catch {
23707
23802
  return null;
23708
23803
  }
@@ -23769,15 +23864,15 @@ function startLaunchdDaemon(o) {
23769
23864
  }
23770
23865
 
23771
23866
  // src/daemon-start-failure.ts
23772
- import { existsSync as existsSync49, mkdirSync as mkdirSync36, readFileSync as readFileSync47, unlinkSync as unlinkSync4, writeFileSync as writeFileSync37 } from "fs";
23773
- import { dirname as dirname29, join as join51 } from "path";
23867
+ import { existsSync as existsSync50, mkdirSync as mkdirSync36, readFileSync as readFileSync48, unlinkSync as unlinkSync4, writeFileSync as writeFileSync37 } from "fs";
23868
+ import { dirname as dirname29, join as join52 } from "path";
23774
23869
  var DAEMON_START_FAILED_KEY = "daemon_start_failed";
23775
23870
  var START_FAILURE_BACKOFF_MS = 6e4;
23776
23871
  var BACKOFF_AFTER_FAILURES = 2;
23777
- var fileFor3 = (stateDir) => join51(stateDir, ".daemon-start-failure.json");
23872
+ var fileFor3 = (stateDir) => join52(stateDir, ".daemon-start-failure.json");
23778
23873
  function readStartFailure(stateDir) {
23779
23874
  try {
23780
- const parsed = JSON.parse(readFileSync47(fileFor3(stateDir), "utf8"));
23875
+ const parsed = JSON.parse(readFileSync48(fileFor3(stateDir), "utf8"));
23781
23876
  return typeof parsed.reason === "string" && typeof parsed.count === "number" ? { reason: parsed.reason, count: parsed.count, firstAt: String(parsed.firstAt), lastAt: String(parsed.lastAt) } : null;
23782
23877
  } catch {
23783
23878
  return null;
@@ -23808,7 +23903,7 @@ function startFailureItem(record, o = {}) {
23808
23903
  return { kind: "daemon_start_failed", key: DAEMON_START_FAILED_KEY, message: parts.join(". ").replace(/\.\./g, "."), since: record.firstAt };
23809
23904
  }
23810
23905
  function clearStartFailure(state, stateDir) {
23811
- if (existsSync49(fileFor3(stateDir))) {
23906
+ if (existsSync50(fileFor3(stateDir))) {
23812
23907
  try {
23813
23908
  unlinkSync4(fileFor3(stateDir));
23814
23909
  } catch {
@@ -23835,7 +23930,7 @@ async function reportStartFailure(o) {
23835
23930
  return delay;
23836
23931
  }
23837
23932
  function fallbackStateDir(configFile) {
23838
- return join51(dirname29(configFile), "state");
23933
+ return join52(dirname29(configFile), "state");
23839
23934
  }
23840
23935
 
23841
23936
  // src/projects-cmd.ts
@@ -24163,7 +24258,7 @@ function missingReleaserWarning(repo, release, ships, now = Date.now()) {
24163
24258
  }
24164
24259
 
24165
24260
  // src/watch.ts
24166
- import { watch as watchFile, existsSync as existsSync50, statSync as statSync14, openSync as openSync5, readSync as readSync2, closeSync as closeSync5 } from "fs";
24261
+ import { watch as watchFile, existsSync as existsSync51, statSync as statSync15, openSync as openSync6, readSync as readSync3, closeSync as closeSync6 } from "fs";
24167
24262
  var E = "\x1B[";
24168
24263
  var dim = (s) => `${E}2m${s}${E}0m`;
24169
24264
  var bold = (s) => `${E}1m${s}${E}0m`;
@@ -24264,14 +24359,14 @@ function renderHeaders(states, now = Date.now()) {
24264
24359
  return states.map((s) => renderHeader(s, now)).join("");
24265
24360
  }
24266
24361
  function readFrom(file, from) {
24267
- if (!existsSync50(file)) return { events: [], offset: from };
24268
- const size = statSync14(file).size;
24362
+ if (!existsSync51(file)) return { events: [], offset: from };
24363
+ const size = statSync15(file).size;
24269
24364
  if (size < from) return readFrom(file, 0);
24270
24365
  if (size === from) return { events: [], offset: from };
24271
- const fd = openSync5(file, "r");
24366
+ const fd = openSync6(file, "r");
24272
24367
  const buf = Buffer.alloc(size - from);
24273
- readSync2(fd, buf, 0, buf.length, from);
24274
- closeSync5(fd);
24368
+ readSync3(fd, buf, 0, buf.length, from);
24369
+ closeSync6(fd);
24275
24370
  const text2 = buf.toString("utf8");
24276
24371
  const lastNewline = text2.lastIndexOf("\n");
24277
24372
  if (lastNewline === -1) return { events: [], offset: from };
@@ -25081,14 +25176,14 @@ function describeCapability(i) {
25081
25176
  }
25082
25177
 
25083
25178
  // src/persona-avatars.ts
25084
- import { existsSync as existsSync51, readFileSync as readFileSync48 } from "fs";
25085
- import { join as join52 } from "path";
25179
+ import { existsSync as existsSync52, readFileSync as readFileSync49 } from "fs";
25180
+ import { join as join53 } from "path";
25086
25181
  var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
25087
25182
  function personaAvatarFile(promptsDir, role) {
25088
25183
  for (const ext of ["png", "svg"]) {
25089
25184
  const name = `lane-${role}.${ext}`;
25090
- const path = join52(promptsDir, "personas", name);
25091
- if (existsSync51(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
25185
+ const path = join53(promptsDir, "personas", name);
25186
+ if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
25092
25187
  }
25093
25188
  return void 0;
25094
25189
  }
@@ -25102,7 +25197,7 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
25102
25197
  if (!file || !agentId) continue;
25103
25198
  try {
25104
25199
  const form = new FormData();
25105
- form.append("file", new Blob([readFileSync48(file.path)], { type: file.mimeType }), file.name);
25200
+ form.append("file", new Blob([readFileSync49(file.path)], { type: file.mimeType }), file.name);
25106
25201
  const res = await fetch(`${base}/${agentId}/avatar`, {
25107
25202
  method: "PUT",
25108
25203
  headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
@@ -25143,14 +25238,14 @@ function avatarFailures(raw) {
25143
25238
  }
25144
25239
  function routeAvatarFailures(stateDir, route2) {
25145
25240
  try {
25146
- return avatarFailures(JSON.parse(readFileSync48(resolvedPathFor(stateDir, route2), "utf8")));
25241
+ return avatarFailures(JSON.parse(readFileSync49(resolvedPathFor(stateDir, route2), "utf8")));
25147
25242
  } catch {
25148
25243
  return [];
25149
25244
  }
25150
25245
  }
25151
25246
 
25152
25247
  // src/agents-sync-run.ts
25153
- import { existsSync as existsSync52, mkdirSync as mkdirSync38, readFileSync as readFileSync49, writeFileSync as writeFileSync39 } from "fs";
25248
+ import { existsSync as existsSync53, mkdirSync as mkdirSync38, readFileSync as readFileSync50, writeFileSync as writeFileSync39 } from "fs";
25154
25249
  import { dirname as dirname31 } from "path";
25155
25250
  async function runAgentsSync(target, o) {
25156
25251
  const dryRun = o.dryRun ?? false;
@@ -25196,7 +25291,7 @@ async function runAgentsSync(target, o) {
25196
25291
  }
25197
25292
  if (!dryRun) {
25198
25293
  const resolvedPath = resolvedPathFor(o.stateDir, target.route);
25199
- const raw = existsSync52(resolvedPath) ? JSON.parse(readFileSync49(resolvedPath, "utf8")) : {};
25294
+ const raw = existsSync53(resolvedPath) ? JSON.parse(readFileSync50(resolvedPath, "utf8")) : {};
25200
25295
  raw.agentPersonas = personaResult.agentPersonas;
25201
25296
  if (skillResult) raw.agentSkills = skillResult.agentSkills;
25202
25297
  if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
@@ -25339,7 +25434,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
25339
25434
 
25340
25435
  // src/repos-check.ts
25341
25436
  import { spawnSync as spawnSync13 } from "child_process";
25342
- import { readFileSync as readFileSync50 } from "fs";
25437
+ import { readFileSync as readFileSync51 } from "fs";
25343
25438
  import { basename as basename12 } from "path";
25344
25439
  var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
25345
25440
  function checkHookSyntax(script, shell) {
@@ -25380,7 +25475,7 @@ function checkRepoSpec(dir, opts = {}) {
25380
25475
  }
25381
25476
  let parsed;
25382
25477
  try {
25383
- parsed = parseRepoConfig(readFileSync50(file, "utf8"), file);
25478
+ parsed = parseRepoConfig(readFileSync51(file, "utf8"), file);
25384
25479
  } catch (e) {
25385
25480
  if (!(e instanceof RepoConfigError)) throw e;
25386
25481
  return { ...empty, file, error: e.message, exitCode: 1 };
@@ -25844,7 +25939,7 @@ ${run4.err}` });
25844
25939
  }
25845
25940
 
25846
25941
  // src/sample-ticket.ts
25847
- import { basename as basename13, dirname as dirname32, join as join53 } from "path";
25942
+ import { basename as basename13, dirname as dirname32, join as join54 } from "path";
25848
25943
  var SAMPLE_REPO = "crew-sample";
25849
25944
  var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
25850
25945
  var SAMPLE_MARKER = "sample: true";
@@ -25867,8 +25962,8 @@ has something safe to work on: its test and build hooks always pass, it has no
25867
25962
  remote, and \`crew sample-ticket --remove\` deletes it.
25868
25963
  `;
25869
25964
  function sampleDir(existing, reposBase, workspace) {
25870
- if (existing.length > 0) return join53(dirname32(existing[0]), SAMPLE_REPO);
25871
- return join53(reposBase, workspace, SAMPLE_REPO);
25965
+ if (existing.length > 0) return join54(dirname32(existing[0]), SAMPLE_REPO);
25966
+ return join54(reposBase, workspace, SAMPLE_REPO);
25872
25967
  }
25873
25968
  var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
25874
25969
  function sampleDescription() {
@@ -25912,8 +26007,8 @@ function planSampleTicket(i) {
25912
26007
  }
25913
26008
 
25914
26009
  // src/worktree-sweep.ts
25915
- import { existsSync as existsSync53, readFileSync as readFileSync51, readdirSync as readdirSync15 } from "fs";
25916
- import { basename as basename14, dirname as dirname33, join as join54, resolve as resolve5 } from "path";
26010
+ import { existsSync as existsSync54, readFileSync as readFileSync52, readdirSync as readdirSync16 } from "fs";
26011
+ import { basename as basename14, dirname as dirname33, join as join55, resolve as resolve5 } from "path";
25917
26012
  function planWorktreeSweep(target, tickets, contract) {
25918
26013
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
25919
26014
  const verified = contract.statuses.verified;
@@ -25982,7 +26077,7 @@ function siblingWorktreeDirs(target) {
25982
26077
  const registered = new Set(worktrees(target.dir).map((w) => resolve5(w.path)));
25983
26078
  let names;
25984
26079
  try {
25985
- names = readdirSync15(parent);
26080
+ names = readdirSync16(parent);
25986
26081
  } catch {
25987
26082
  return [];
25988
26083
  }
@@ -25990,7 +26085,7 @@ function siblingWorktreeDirs(target) {
25990
26085
  for (const name of names) {
25991
26086
  if (!name.startsWith(stem)) continue;
25992
26087
  const m = DIR_NUMBER_SUFFIXED.exec(name);
25993
- const path = join54(parent, name);
26088
+ const path = join55(parent, name);
25994
26089
  if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
25995
26090
  }
25996
26091
  return out;
@@ -26025,7 +26120,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26025
26120
  let removed = 0;
26026
26121
  let keptBranches = 0;
26027
26122
  for (const a of actions) {
26028
- if (!dryRun && base && !a.keepBranch && existsSync53(a.path) && isHandBackMerge(a.path, base)) {
26123
+ if (!dryRun && base && !a.keepBranch && existsSync54(a.path) && isHandBackMerge(a.path, base)) {
26029
26124
  if (gitOk(a.path, ["merge", "--abort"]) !== null) {
26030
26125
  log.emit(
26031
26126
  `abandoned the hand-back merge of ${base} in ${a.path}: ${a.ticket.issue_id} deployed without it`,
@@ -26042,11 +26137,11 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26042
26137
  { ticket: a.ticket.issue_id, step: "worktree" }
26043
26138
  );
26044
26139
  };
26045
- if (!dryRun && liveRun && existsSync53(a.path)) {
26140
+ if (!dryRun && liveRun && existsSync54(a.path)) {
26046
26141
  defer();
26047
26142
  continue;
26048
26143
  }
26049
- if (!dryRun && existsSync53(a.path)) {
26144
+ if (!dryRun && existsSync54(a.path)) {
26050
26145
  let dirty = false;
26051
26146
  try {
26052
26147
  dirty = status(a.path).length > 0;
@@ -26061,7 +26156,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26061
26156
  continue;
26062
26157
  }
26063
26158
  }
26064
- if (!dryRun && a.requirePushed && a.branch && existsSync53(a.path) && remoteConfigured(cwd, remote) && worktreeHoldsUnpushed(a.path, remote)) {
26159
+ if (!dryRun && a.requirePushed && a.branch && existsSync54(a.path) && remoteConfigured(cwd, remote) && worktreeHoldsUnpushed(a.path, remote)) {
26065
26160
  if (pids.length) {
26066
26161
  defer();
26067
26162
  continue;
@@ -26112,7 +26207,7 @@ function isHandBackMerge(path, base) {
26112
26207
  if (!msgPath) return false;
26113
26208
  let first;
26114
26209
  try {
26115
- first = readFileSync51(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
26210
+ first = readFileSync52(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
26116
26211
  } catch {
26117
26212
  return false;
26118
26213
  }
@@ -26217,16 +26312,16 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
26217
26312
  }
26218
26313
 
26219
26314
  // src/stream-sweep.ts
26220
- import { existsSync as existsSync54, readdirSync as readdirSync16, rmSync as rmSync23, statSync as statSync15 } from "fs";
26221
- import { join as join55 } from "path";
26315
+ import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync23, statSync as statSync16 } from "fs";
26316
+ import { join as join56 } from "path";
26222
26317
  var DAY_MS2 = 24 * 60 * 60 * 1e3;
26223
26318
  function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
26224
- const dir = join55(stateDir, "streams");
26225
- if (!existsSync54(dir)) return [];
26319
+ const dir = join56(stateDir, "streams");
26320
+ if (!existsSync55(dir)) return [];
26226
26321
  const cutoff = now - retentionDays * DAY_MS2;
26227
- return readdirSync16(dir).map((name) => join55(dir, name)).filter((path) => {
26322
+ return readdirSync17(dir).map((name) => join56(dir, name)).filter((path) => {
26228
26323
  try {
26229
- return statSync15(path).mtimeMs < cutoff;
26324
+ return statSync16(path).mtimeMs < cutoff;
26230
26325
  } catch {
26231
26326
  return false;
26232
26327
  }
@@ -26250,11 +26345,11 @@ function applyStreamSweep(paths, dryRun, log) {
26250
26345
  return removed;
26251
26346
  }
26252
26347
  function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
26253
- if (!existsSync54(stateDir)) return [];
26348
+ if (!existsSync55(stateDir)) return [];
26254
26349
  const cutoff = now - retentionDays * DAY_MS2;
26255
- return readdirSync16(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join55(stateDir, name)).filter((path) => {
26350
+ return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join56(stateDir, name)).filter((path) => {
26256
26351
  try {
26257
- return statSync15(path).mtimeMs < cutoff;
26352
+ return statSync16(path).mtimeMs < cutoff;
26258
26353
  } catch {
26259
26354
  return false;
26260
26355
  }
@@ -26262,7 +26357,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
26262
26357
  }
26263
26358
 
26264
26359
  // src/cli.ts
26265
- import { realpathSync as realpathSync3, readFileSync as readFileSync54, existsSync as existsSync59, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync18, readdirSync as readdirSync21 } from "fs";
26360
+ import { realpathSync as realpathSync3, readFileSync as readFileSync55, existsSync as existsSync60, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
26266
26361
  import { createInterface } from "readline/promises";
26267
26362
 
26268
26363
  // src/periscope-resume.ts
@@ -26338,33 +26433,33 @@ ${tail2(preview.output)}`);
26338
26433
  import { dirname as dirOf2, resolve as resolvePath } from "path";
26339
26434
 
26340
26435
  // src/bundle-staleness.ts
26341
- import { existsSync as existsSync55, readdirSync as readdirSync17, statSync as statSync16 } from "fs";
26342
- import { join as join56 } from "path";
26436
+ import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
26437
+ import { join as join57 } from "path";
26343
26438
  function builtVersion() {
26344
- return true ? "0.143.4" : null;
26439
+ return true ? "0.144.0" : null;
26345
26440
  }
26346
26441
  var REBUILD_HINT = "rebuild with npm run build";
26347
26442
  function newestMtime(path) {
26348
26443
  let stat2;
26349
26444
  try {
26350
- stat2 = statSync16(path);
26445
+ stat2 = statSync17(path);
26351
26446
  } catch {
26352
26447
  return 0;
26353
26448
  }
26354
26449
  if (stat2.isFile()) return stat2.mtimeMs;
26355
26450
  if (!stat2.isDirectory()) return 0;
26356
26451
  let latest = stat2.mtimeMs;
26357
- for (const e of readdirSync17(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join56(path, e.name)));
26452
+ for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join57(path, e.name)));
26358
26453
  return latest;
26359
26454
  }
26360
26455
  function bundleStaleness(i) {
26361
26456
  if (i.built === null || i.compiled) return null;
26362
- const src = join56(i.home, "src");
26363
- if (!existsSync55(src)) return null;
26457
+ const src = join57(i.home, "src");
26458
+ if (!existsSync56(src)) return null;
26364
26459
  if (i.built !== i.current) {
26365
26460
  return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
26366
26461
  }
26367
- const bundle = statSafe(join56(i.home, "dist", "cli.js"));
26462
+ const bundle = statSafe(join57(i.home, "dist", "cli.js"));
26368
26463
  if (bundle === null) return null;
26369
26464
  if (newestMtime(src) > bundle) {
26370
26465
  return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
@@ -26373,7 +26468,7 @@ function bundleStaleness(i) {
26373
26468
  }
26374
26469
  function statSafe(p) {
26375
26470
  try {
26376
- return statSync16(p).mtimeMs;
26471
+ return statSync17(p).mtimeMs;
26377
26472
  } catch {
26378
26473
  return null;
26379
26474
  }
@@ -26531,8 +26626,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
26531
26626
  import { createServer as createHttpServer } from "http";
26532
26627
  import { spawn as spawn9 } from "child_process";
26533
26628
  import { randomBytes as randomBytes2 } from "crypto";
26534
- import { existsSync as existsSync56, mkdirSync as mkdirSync39, readFileSync as readFileSync52, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync18 } from "fs";
26535
- import { join as join57 } from "path";
26629
+ import { existsSync as existsSync57, mkdirSync as mkdirSync39, readFileSync as readFileSync53, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
26630
+ import { join as join58 } from "path";
26536
26631
 
26537
26632
  // src/secret-compare.ts
26538
26633
  import { timingSafeEqual } from "crypto";
@@ -26625,20 +26720,20 @@ var defaultSpawn2 = (cmd, args, env) => {
26625
26720
  return child;
26626
26721
  };
26627
26722
  function syncDaemonStatePath(stateDir, workspaceId) {
26628
- return join57(stateDir, "passengers", `${workspaceId}-sync.json`);
26723
+ return join58(stateDir, "passengers", `${workspaceId}-sync.json`);
26629
26724
  }
26630
26725
  function readPersistedSyncDaemon(stateDir, workspaceId) {
26631
26726
  const path = syncDaemonStatePath(stateDir, workspaceId);
26632
- if (!existsSync56(path)) return void 0;
26727
+ if (!existsSync57(path)) return void 0;
26633
26728
  try {
26634
- return JSON.parse(readFileSync52(path, "utf8"));
26729
+ return JSON.parse(readFileSync53(path, "utf8"));
26635
26730
  } catch {
26636
26731
  return void 0;
26637
26732
  }
26638
26733
  }
26639
26734
  function writePersistedSyncDaemon(stateDir, state) {
26640
26735
  const path = syncDaemonStatePath(stateDir, state.workspaceId);
26641
- mkdirSync39(join57(stateDir, "passengers"), { recursive: true });
26736
+ mkdirSync39(join58(stateDir, "passengers"), { recursive: true });
26642
26737
  writeFileSync40(path, `${JSON.stringify(state, null, 2)}
26643
26738
  `);
26644
26739
  }
@@ -26659,10 +26754,10 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
26659
26754
  }
26660
26755
  }
26661
26756
  function readAllPersistedSyncWorkspaceIds(stateDir) {
26662
- const dir = join57(stateDir, "passengers");
26663
- if (!existsSync56(dir)) return [];
26757
+ const dir = join58(stateDir, "passengers");
26758
+ if (!existsSync57(dir)) return [];
26664
26759
  const suffix = "-sync.json";
26665
- return readdirSync18(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
26760
+ return readdirSync19(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
26666
26761
  }
26667
26762
  function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
26668
26763
  const alive = deps.isPidAlive ?? isPidAlive;
@@ -27126,7 +27221,7 @@ async function startWorktreeIntel(d) {
27126
27221
  }
27127
27222
 
27128
27223
  // src/contract-refusal.ts
27129
- import { join as join58 } from "path";
27224
+ import { join as join59 } from "path";
27130
27225
  function contractFixers(dir, baseRef, tickets, locate) {
27131
27226
  const out = [];
27132
27227
  for (const t of tickets) {
@@ -27138,7 +27233,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
27138
27233
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
27139
27234
  if (text2 === null) continue;
27140
27235
  try {
27141
- parseRepoConfig(text2, join58(dir, file));
27236
+ parseRepoConfig(text2, join59(dir, file));
27142
27237
  } catch (e) {
27143
27238
  if (e instanceof RepoConfigError) continue;
27144
27239
  throw e;
@@ -27152,19 +27247,19 @@ function contractFixers(dir, baseRef, tickets, locate) {
27152
27247
  import { createHash as createHash11 } from "crypto";
27153
27248
  import {
27154
27249
  chmodSync as chmodSync4,
27155
- closeSync as closeSync6,
27156
- existsSync as existsSync57,
27157
- fstatSync,
27158
- openSync as openSync6,
27159
- readSync as readSync3,
27160
- readdirSync as readdirSync19,
27250
+ closeSync as closeSync7,
27251
+ existsSync as existsSync58,
27252
+ fstatSync as fstatSync2,
27253
+ openSync as openSync7,
27254
+ readSync as readSync4,
27255
+ readdirSync as readdirSync20,
27161
27256
  rmSync as rmSync24,
27162
- statSync as statSync17,
27257
+ statSync as statSync18,
27163
27258
  watch
27164
27259
  } from "fs";
27165
27260
  import { createConnection } from "net";
27166
27261
  import { createServer as createServer2 } from "http";
27167
- import { basename as basename15, dirname as dirname35, join as join59 } from "path";
27262
+ import { basename as basename15, dirname as dirname35, join as join60 } from "path";
27168
27263
  import { execFile as execFile6, spawn as spawn12 } from "child_process";
27169
27264
 
27170
27265
  // src/periscope-control.ts
@@ -27401,7 +27496,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
27401
27496
  // src/control-api.ts
27402
27497
  var PAUSABLE = ["dev", "design", "qa"];
27403
27498
  var CONTROL_SOCKET_NAME = "control.sock";
27404
- var controlSocketFor = (stateDir) => join59(stateDir, CONTROL_SOCKET_NAME);
27499
+ var controlSocketFor = (stateDir) => join60(stateDir, CONTROL_SOCKET_NAME);
27405
27500
  var MAX_SOCKET_PATH = 100;
27406
27501
  var MAX_TAIL_BYTES = 1024 * 1024;
27407
27502
  var MAX_WAIT_SECONDS = 30;
@@ -27488,30 +27583,30 @@ function candidates(live2, rotated) {
27488
27583
  const out = [live2];
27489
27584
  if (!rotated) return out;
27490
27585
  try {
27491
- for (const n of readdirSync19(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join59(dirname35(live2), n));
27586
+ for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join60(dirname35(live2), n));
27492
27587
  } catch {
27493
27588
  }
27494
27589
  return out;
27495
27590
  }
27496
27591
  function readRange(path, from, max) {
27497
- const fd = openSync6(path, "r");
27592
+ const fd = openSync7(path, "r");
27498
27593
  try {
27499
- const size = fstatSync(fd).size;
27594
+ const size = fstatSync2(fd).size;
27500
27595
  const len = Math.max(0, Math.min(size - from, max));
27501
27596
  const buf = Buffer.alloc(len);
27502
27597
  let got = 0;
27503
27598
  while (got < len) {
27504
- const n = readSync3(fd, buf, got, len - got, from + got);
27599
+ const n = readSync4(fd, buf, got, len - got, from + got);
27505
27600
  if (n <= 0) break;
27506
27601
  got += n;
27507
27602
  }
27508
27603
  return { text: buf.subarray(0, got).toString("utf8"), size };
27509
27604
  } finally {
27510
- closeSync6(fd);
27605
+ closeSync7(fd);
27511
27606
  }
27512
27607
  }
27513
27608
  function lastLines2(path, n) {
27514
- const st = statSync17(path);
27609
+ const st = statSync18(path);
27515
27610
  const cursorAt = (off) => encodeCursor({ dev: st.dev, ino: st.ino, off });
27516
27611
  if (n <= 0 || st.size === 0) return { lines: [], cursor: cursorAt(st.size), reset: false };
27517
27612
  let start = st.size;
@@ -27532,7 +27627,7 @@ function lastLines2(path, n) {
27532
27627
  }
27533
27628
  function readTail(live2, opts) {
27534
27629
  const max = opts.maxBytes ?? MAX_TAIL_BYTES;
27535
- if (!existsSync57(live2)) {
27630
+ if (!existsSync58(live2)) {
27536
27631
  return { lines: [], cursor: opts.after ?? encodeCursor({ dev: 0, ino: 0, off: 0 }), reset: false };
27537
27632
  }
27538
27633
  const cur = opts.after ? decodeCursor(opts.after) : null;
@@ -27545,7 +27640,7 @@ function readTail(live2, opts) {
27545
27640
  } else {
27546
27641
  const found = candidates(live2, opts.rotated ?? false).find((p) => {
27547
27642
  try {
27548
- const s = statSync17(p);
27643
+ const s = statSync18(p);
27549
27644
  return s.ino === cur.ino && s.dev === cur.dev;
27550
27645
  } catch {
27551
27646
  return false;
@@ -27556,7 +27651,7 @@ function readTail(live2, opts) {
27556
27651
  off = cur.off;
27557
27652
  } else reset = true;
27558
27653
  }
27559
- let size = statSync17(path).size;
27654
+ let size = statSync18(path).size;
27560
27655
  if (off > size) {
27561
27656
  off = 0;
27562
27657
  reset = true;
@@ -27564,12 +27659,12 @@ function readTail(live2, opts) {
27564
27659
  if (off >= size && path !== live2) {
27565
27660
  path = live2;
27566
27661
  off = 0;
27567
- size = statSync17(path).size;
27662
+ size = statSync18(path).size;
27568
27663
  }
27569
27664
  const { text: text2 } = readRange(path, off, max);
27570
27665
  const cut = text2.lastIndexOf("\n");
27571
27666
  const whole = cut < 0 ? "" : text2.slice(0, cut + 1);
27572
- const st = statSync17(path);
27667
+ const st = statSync18(path);
27573
27668
  return {
27574
27669
  lines: whole.split("\n").filter((l) => l.length),
27575
27670
  cursor: encodeCursor({ dev: st.dev, ino: st.ino, off: off + Buffer.byteLength(whole) }),
@@ -27711,8 +27806,8 @@ async function route(deps, method, url, req, abort) {
27711
27806
  if (p.startsWith("/streams/") && get2) {
27712
27807
  const run4 = decodeURIComponent(p.slice("/streams/".length));
27713
27808
  if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
27714
- const file = join59(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
27715
- if (!existsSync57(file)) return err2(404, "no such run");
27809
+ const file = join60(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
27810
+ if (!existsSync58(file)) return err2(404, "no such run");
27716
27811
  return tailReply(file, url.searchParams, false, abort);
27717
27812
  }
27718
27813
  const note = /^\/streams\/([^/]+)\/messages$/.exec(p);
@@ -27759,7 +27854,7 @@ function send2(res, r) {
27759
27854
  res.end(body);
27760
27855
  }
27761
27856
  async function socketIsStale(path) {
27762
- if (!existsSync57(path)) return false;
27857
+ if (!existsSync58(path)) return false;
27763
27858
  return new Promise((resolve8) => {
27764
27859
  const c = createConnection(path);
27765
27860
  c.once("connect", () => {
@@ -27778,7 +27873,7 @@ async function startControlServer(deps) {
27778
27873
  return null;
27779
27874
  }
27780
27875
  if (await socketIsStale(path)) rmSync24(path, { force: true });
27781
- else if (existsSync57(path)) {
27876
+ else if (existsSync58(path)) {
27782
27877
  log(`control API not started: ${path} is in use by another process`);
27783
27878
  return null;
27784
27879
  }
@@ -27864,19 +27959,19 @@ function crewJson(args, timeoutMs = 6e4) {
27864
27959
 
27865
27960
  // src/periscope-mcp.ts
27866
27961
  import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
27867
- import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join61, relative as relative2, resolve as resolve6, sep } from "path";
27962
+ import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join62, relative as relative2, resolve as resolve6, sep } from "path";
27868
27963
  import { z } from "zod";
27869
27964
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
27870
27965
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
27871
27966
 
27872
27967
  // src/periscope-endpoints.ts
27873
27968
  import { randomBytes as randomBytes3 } from "crypto";
27874
- import { chmodSync as chmodSync5, existsSync as existsSync58, mkdirSync as mkdirSync41, readdirSync as readdirSync20, readFileSync as readFileSync53, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
27875
- import { join as join60 } from "path";
27876
- var secretDir = (stateDir) => join60(stateDir, "periscope-mcp");
27877
- var secretFile = (stateDir, id) => join60(secretDir(stateDir), `${id}.json`);
27878
- var endpointDir = (stateDir) => join60(stateDir, "periscope-endpoints");
27879
- var endpointFile = (stateDir, id) => join60(endpointDir(stateDir), `${id}.json`);
27969
+ import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync41, readdirSync as readdirSync21, readFileSync as readFileSync54, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
27970
+ import { join as join61 } from "path";
27971
+ var secretDir = (stateDir) => join61(stateDir, "periscope-mcp");
27972
+ var secretFile = (stateDir, id) => join61(secretDir(stateDir), `${id}.json`);
27973
+ var endpointDir = (stateDir) => join61(stateDir, "periscope-endpoints");
27974
+ var endpointFile = (stateDir, id) => join61(endpointDir(stateDir), `${id}.json`);
27880
27975
  function mintPeriscopeSecret(stateDir, ticketRecordId) {
27881
27976
  mkdirSync41(secretDir(stateDir), { recursive: true, mode: 448 });
27882
27977
  const secret = randomBytes3(32).toString("base64url");
@@ -27888,7 +27983,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
27888
27983
  }
27889
27984
  function readPeriscopeSecret(stateDir, ticketRecordId) {
27890
27985
  try {
27891
- const v = JSON.parse(readFileSync53(secretFile(stateDir, ticketRecordId), "utf8"));
27986
+ const v = JSON.parse(readFileSync54(secretFile(stateDir, ticketRecordId), "utf8"));
27892
27987
  return typeof v.secret === "string" && v.secret ? v.secret : void 0;
27893
27988
  } catch {
27894
27989
  return void 0;
@@ -27899,7 +27994,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
27899
27994
  }
27900
27995
  function readPeriscopeEndpoint(stateDir, ticketRecordId) {
27901
27996
  try {
27902
- return JSON.parse(readFileSync53(endpointFile(stateDir, ticketRecordId), "utf8"));
27997
+ return JSON.parse(readFileSync54(endpointFile(stateDir, ticketRecordId), "utf8"));
27903
27998
  } catch {
27904
27999
  return void 0;
27905
28000
  }
@@ -27914,9 +28009,9 @@ function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
27914
28009
  }
27915
28010
  function listPeriscopeEndpoints(stateDir) {
27916
28011
  const dir = endpointDir(stateDir);
27917
- if (!existsSync58(dir)) return [];
28012
+ if (!existsSync59(dir)) return [];
27918
28013
  const out = [];
27919
- for (const name of readdirSync20(dir)) {
28014
+ for (const name of readdirSync21(dir)) {
27920
28015
  if (!name.endsWith(".json")) continue;
27921
28016
  const rec = readPeriscopeEndpoint(stateDir, name.slice(0, -".json".length));
27922
28017
  if (rec && typeof rec.endpointId === "string") out.push(rec);
@@ -28017,13 +28112,13 @@ async function resolveInWorktree(root, requested) {
28017
28112
  let abs;
28018
28113
  if (isAbsolute5(requested)) {
28019
28114
  abs = resolve6(requested);
28020
- if (isInside(root, abs)) abs = join61(realRoot, relative2(root, abs));
28115
+ if (isInside(root, abs)) abs = join62(realRoot, relative2(root, abs));
28021
28116
  } else {
28022
28117
  abs = resolve6(realRoot, requested);
28023
28118
  }
28024
28119
  if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
28025
28120
  const { real, rest } = await realAncestor(abs);
28026
- const final = rest ? join61(real, rest) : real;
28121
+ const final = rest ? join62(real, rest) : real;
28027
28122
  if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
28028
28123
  if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
28029
28124
  return final;
@@ -28091,7 +28186,7 @@ function createPeriscopeMcpServer(d, sc) {
28091
28186
  const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
28092
28187
  const lines2 = await Promise.all(entries.map(async (e) => {
28093
28188
  if (e.isDirectory()) return `[DIR] ${e.name}`;
28094
- const size = (await lstat(join61(abs, e.name))).size;
28189
+ const size = (await lstat(join62(abs, e.name))).size;
28095
28190
  return `[FILE] ${e.name} (${size} bytes)`;
28096
28191
  }));
28097
28192
  return text(lines2.join("\n") || "(empty)");
@@ -28157,7 +28252,7 @@ function createPeriscopeMcpServer(d, sc) {
28157
28252
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
28158
28253
  }, async ({ path }) => {
28159
28254
  const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
28160
- const abs = join61(parent, basename16(path));
28255
+ const abs = join62(parent, basename16(path));
28161
28256
  if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
28162
28257
  const st = await lstat(abs).catch(() => void 0);
28163
28258
  if (!st) return text(`${path} does not exist`, true);
@@ -28652,7 +28747,7 @@ if (command === "provision") {
28652
28747
  process.exit(outcome.code);
28653
28748
  }
28654
28749
  if (command === "pool-member") {
28655
- const pool = poolConfigFrom(argv, process.env, () => readFileSync54(0, "utf8"));
28750
+ const pool = poolConfigFrom(argv, process.env, () => readFileSync55(0, "utf8"));
28656
28751
  if (typeof pool === "string") {
28657
28752
  process.stderr.write(`crew pool-member: ${pool}
28658
28753
  `);
@@ -28973,7 +29068,7 @@ if (command === "passenger-sync-daemon") {
28973
29068
  } else {
28974
29069
  const toleratesNoRoutes = command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
28975
29070
  const configless = command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
28976
- if (configless && !existsSync59(findConfigFile(CREW_HOME))) {
29071
+ if (configless && !existsSync60(findConfigFile(CREW_HOME))) {
28977
29072
  cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
28978
29073
  } else {
28979
29074
  cfg = loadConfig(CREW_HOME, void 0, toleratesNoRoutes ? { allowNoRoutes: true } : {});
@@ -28996,7 +29091,7 @@ if (command === "passenger-sync-daemon") {
28996
29091
  throw e;
28997
29092
  }
28998
29093
  if (command === "credential") {
28999
- const r = runCredential(positional[1], readFileSync54(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
29094
+ const r = runCredential(positional[1], readFileSync55(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
29000
29095
  process.stdout.write(r.out);
29001
29096
  process.stderr.write(r.err);
29002
29097
  process.exit(r.code);
@@ -29008,9 +29103,9 @@ if (command === "passenger-sync-daemon") {
29008
29103
  forges: cfg.ship.forges,
29009
29104
  stateDir: cfg.ship.stateDir,
29010
29105
  configFile: cfg.configFile,
29011
- readFile: (p) => readFileSync54(p, "utf8"),
29106
+ readFile: (p) => readFileSync55(p, "utf8"),
29012
29107
  writeFile: (p, t) => writeFileSync42(p, t),
29013
- stdin: () => readFileSync54(0, "utf8"),
29108
+ stdin: () => readFileSync55(0, "utf8"),
29014
29109
  env: process.env
29015
29110
  }
29016
29111
  );
@@ -29349,8 +29444,8 @@ if (command === "passenger-sync-daemon") {
29349
29444
  }
29350
29445
  if (host === "linux" && hasSystemd) {
29351
29446
  const label = labelFor(CREW_HOME, "run");
29352
- const staleTimer = join62(homedir11(), ".config", "systemd", "user", `${label}.timer`);
29353
- if (existsSync59(staleTimer)) {
29447
+ const staleTimer = join63(homedir11(), ".config", "systemd", "user", `${label}.timer`);
29448
+ if (existsSync60(staleTimer)) {
29354
29449
  process.stdout.write(
29355
29450
  `removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
29356
29451
  `
@@ -29379,7 +29474,7 @@ if (command === "passenger-sync-daemon") {
29379
29474
  const { settled: doctorRepos, errors: refusedRepos } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
29380
29475
  for (const e of refusedRepos) problems.push(`repo ${e.repo}: ${e.detail}`);
29381
29476
  for (const r of doctorRepos) {
29382
- if (!existsSync59(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
29477
+ if (!existsSync60(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
29383
29478
  if (!satisfies(host, r.config.platform)) problems.push(`repo ${r.name}: requires ${r.config.platform}, this host is ${host}`);
29384
29479
  readiness.push(...validateEffective(r.config).map((p) => `repo ${r.name}: ${p}`));
29385
29480
  }
@@ -29415,7 +29510,7 @@ if (command === "passenger-sync-daemon") {
29415
29510
  }
29416
29511
  async function doctorFix(o) {
29417
29512
  const routes = await Promise.all(routesInScope(cfg.routes, named).map((c) => gatherHealth({ route: c.route, enabled: c.enabled, hasRepos: reposOf(c).length > 0 }, () => routeProblems(c))));
29418
- const unitExists = (p) => existsSync59(p);
29513
+ const unitExists = (p) => existsSync60(p);
29419
29514
  const crontab = o.host === "linux" ? spawnSync14("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
29420
29515
  const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
29421
29516
  const plan = planFix({ routes, schedulerAbsent, host: o.host });
@@ -29432,7 +29527,7 @@ if (command === "passenger-sync-daemon") {
29432
29527
  for (const a of plan.actions) {
29433
29528
  if (a.kind === "enable") {
29434
29529
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
29435
- writeFileSync42(cfg.configFile, planEnable(readFileSync54(cfg.configFile, "utf8"), a.route));
29530
+ writeFileSync42(cfg.configFile, planEnable(readFileSync55(cfg.configFile, "utf8"), a.route));
29436
29531
  enabledSound.add(a.route);
29437
29532
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
29438
29533
  } else {
@@ -29661,7 +29756,7 @@ ${changed2.map((c) => ` - ${c}
29661
29756
  harnessBin: "claude",
29662
29757
  ...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
29663
29758
  },
29664
- policyFile: join62(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
29759
+ policyFile: join63(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
29665
29760
  repo: mirror,
29666
29761
  origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
29667
29762
  base: effective.branch.base,
@@ -30928,7 +31023,7 @@ ${f.tail.trimEnd()}
30928
31023
  logFile: cfg.ship.logFile
30929
31024
  });
30930
31025
  }
30931
- const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join62(CREW_HOME, "src"), join62(CREW_HOME, "dist"), join62(CREW_HOME, "bin")];
31026
+ const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join63(CREW_HOME, "src"), join63(CREW_HOME, "dist"), join63(CREW_HOME, "bin")];
30932
31027
  const configPaths = daemonConfigPaths(cfg);
30933
31028
  watchPaths.push(...configPaths);
30934
31029
  noteDaemonStarted(cfg.ship.stateDir);
@@ -31266,7 +31361,7 @@ ${f.tail.trimEnd()}
31266
31361
  `);
31267
31362
  if (!dryRun) {
31268
31363
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
31269
- const raw = existsSync59(resolvedPath) ? JSON.parse(readFileSync54(resolvedPath, "utf8")) : {};
31364
+ const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync55(resolvedPath, "utf8")) : {};
31270
31365
  raw.agentSkills = result.agentSkills;
31271
31366
  mkdirSync42(dirOf2(resolvedPath), { recursive: true });
31272
31367
  writeFileSync42(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -31292,7 +31387,7 @@ ${f.tail.trimEnd()}
31292
31387
  throw e;
31293
31388
  }
31294
31389
  const oldName = cfg.ship.name;
31295
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync54(cfg.configFile, "utf8"), newName));
31390
+ writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync55(cfg.configFile, "utf8"), newName));
31296
31391
  cfg.ship.name = newName;
31297
31392
  let renameMachineId;
31298
31393
  try {
@@ -31339,7 +31434,7 @@ ${f.tail.trimEnd()}
31339
31434
  process.exit(2);
31340
31435
  };
31341
31436
  if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
31342
- const configText = readFileSync54(cfg.configFile, "utf8");
31437
+ const configText = readFileSync55(cfg.configFile, "utf8");
31343
31438
  if (sub === "check") {
31344
31439
  try {
31345
31440
  const routeArg = value("route") ?? positional[2];
@@ -31371,16 +31466,16 @@ ${f.tail.trimEnd()}
31371
31466
  try {
31372
31467
  const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
31373
31468
  const dir = repoDirOf(configText, dirname37(cfg.configFile), a.route, a.name);
31374
- if (!existsSync59(dir)) throw new ReposError(`${dir} does not exist on disk`);
31375
- const files = { exists: (r) => existsSync59(resolvePath(dir, r)), list: (r) => {
31469
+ if (!existsSync60(dir)) throw new ReposError(`${dir} does not exist on disk`);
31470
+ const files = { exists: (r) => existsSync60(resolvePath(dir, r)), list: (r) => {
31376
31471
  try {
31377
- return readdirSync21(resolvePath(dir, r));
31472
+ return readdirSync22(resolvePath(dir, r));
31378
31473
  } catch {
31379
31474
  return [];
31380
31475
  }
31381
31476
  }, read: (r) => {
31382
31477
  try {
31383
- return readFileSync54(resolvePath(dir, r), "utf8");
31478
+ return readFileSync55(resolvePath(dir, r), "utf8");
31384
31479
  } catch {
31385
31480
  return void 0;
31386
31481
  }
@@ -31490,7 +31585,7 @@ ${f.tail.trimEnd()}
31490
31585
  if (sub === "list" && !routeName) usage2();
31491
31586
  if (sub === "add") {
31492
31587
  try {
31493
- const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync59(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
31588
+ const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync60(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
31494
31589
  routeName = a.route;
31495
31590
  addPath = a.path;
31496
31591
  addName = a.name;
@@ -31520,7 +31615,7 @@ ${f.tail.trimEnd()}
31520
31615
  const resolvedFile = resolvedPathFor(cfg.ship.stateDir, routeName);
31521
31616
  if (sub === "list" || sub === "add") {
31522
31617
  const liveRoute = cfg.routes.find((r) => r.route === routeName);
31523
- if (liveRoute?.resolved?.reposModelId && existsSync59(resolvedFile) && !dryRun) {
31618
+ if (liveRoute?.resolved?.reposModelId && existsSync60(resolvedFile) && !dryRun) {
31524
31619
  try {
31525
31620
  await hydrateApiKeys([liveRoute]);
31526
31621
  persistRepoRows(cfg.ship.stateDir, liveRoute.route, await new Tracker(liveRoute, cfg.ship).repoRowsForMap());
@@ -31529,16 +31624,16 @@ ${f.tail.trimEnd()}
31529
31624
  }
31530
31625
  }
31531
31626
  let resolvedRemotes;
31532
- if (existsSync59(resolvedFile)) {
31627
+ if (existsSync60(resolvedFile)) {
31533
31628
  try {
31534
- resolvedRemotes = JSON.parse(readFileSync54(resolvedFile, "utf8"));
31629
+ resolvedRemotes = JSON.parse(readFileSync55(resolvedFile, "utf8"));
31535
31630
  } catch {
31536
31631
  }
31537
31632
  }
31538
31633
  const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
31539
31634
  const text2 = configText;
31540
31635
  const base = dirname37(cfg.configFile);
31541
- const isCheckout = (d) => existsSync59(`${d}/.git`);
31636
+ const isCheckout = (d) => existsSync60(`${d}/.git`);
31542
31637
  try {
31543
31638
  if (sub === "list") {
31544
31639
  if (flag("json")) {
@@ -31548,12 +31643,12 @@ ${f.tail.trimEnd()}
31548
31643
  base,
31549
31644
  resolved: resolvedRemotes,
31550
31645
  originOf,
31551
- exists: (d) => existsSync59(d),
31646
+ exists: (d) => existsSync60(d),
31552
31647
  isCheckout,
31553
31648
  repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
31554
31649
  try {
31555
31650
  const path = resolvePath(d, f);
31556
- return Object.keys(parseRepoConfig(readFileSync54(path, "utf8"), path).hooks).length > 0;
31651
+ return Object.keys(parseRepoConfig(readFileSync55(path, "utf8"), path).hooks).length > 0;
31557
31652
  } catch {
31558
31653
  return false;
31559
31654
  }
@@ -31570,7 +31665,7 @@ ${f.tail.trimEnd()}
31570
31665
  for (const r of repos) {
31571
31666
  const origin2 = originOf(r.dir);
31572
31667
  const row = matchRepoName(origin2, resolvedRemotes);
31573
- const note = !existsSync59(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
31668
+ const note = !existsSync60(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
31574
31669
  process.stdout.write(`${r.name} ${r.dir} ${note}
31575
31670
  `);
31576
31671
  }
@@ -31582,9 +31677,9 @@ ${f.tail.trimEnd()}
31582
31677
  ` : `${human}
31583
31678
  `);
31584
31679
  const plan2 = planRepoClone({ text: text2, base, route: routeName, name: addName, resolved: resolvedRemotes, dir: value("dir"), isCheckout });
31585
- if (existsSync59(plan2.target) && (existsSync59(`${plan2.target}/.git`) || readdirSync21(plan2.target).length > 0)) {
31680
+ if (existsSync60(plan2.target) && (existsSync60(`${plan2.target}/.git`) || readdirSync22(plan2.target).length > 0)) {
31586
31681
  throw new ReposError(
31587
- existsSync59(`${plan2.target}/.git`) ? `${plan2.target} is already a checkout \u2014 attach it with \`crew repos add ${routeName} ${plan2.name} ${plan2.target}\`` : `${plan2.target} exists and is not empty \u2014 pass --dir to clone somewhere else`
31682
+ existsSync60(`${plan2.target}/.git`) ? `${plan2.target} is already a checkout \u2014 attach it with \`crew repos add ${routeName} ${plan2.name} ${plan2.target}\`` : `${plan2.target} exists and is not empty \u2014 pass --dir to clone somewhere else`
31588
31683
  );
31589
31684
  }
31590
31685
  if (dryRun) {
@@ -31609,7 +31704,7 @@ ${f.tail.trimEnd()}
31609
31704
  break;
31610
31705
  }
31611
31706
  const target = resolvePath(addPath.replace(/^~(?=\/|$)/, homedir11()));
31612
- const top = existsSync59(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
31707
+ const top = existsSync60(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
31613
31708
  if (!top) throw new ReposError(`${target} is not a git checkout`);
31614
31709
  const origin = originOf(top);
31615
31710
  const plan = planRepoAdd({
@@ -31661,8 +31756,8 @@ ${f.tail.trimEnd()}
31661
31756
  const created = await rowTracker.createRepoRow(rowPayload);
31662
31757
  process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
31663
31758
  `);
31664
- if (existsSync59(resolvedFile)) {
31665
- const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
31759
+ if (existsSync60(resolvedFile)) {
31760
+ const raw = JSON.parse(readFileSync55(resolvedFile, "utf8"));
31666
31761
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
31667
31762
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
31668
31763
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -32044,7 +32139,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32044
32139
  process.exit(2);
32045
32140
  }
32046
32141
  if (found.shipNameAdopted && !dryRun) {
32047
- writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync54(cfg.configFile, "utf8"), found.shipNameAdopted));
32142
+ writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync55(cfg.configFile, "utf8"), found.shipNameAdopted));
32048
32143
  cfg.ship.name = found.shipNameAdopted;
32049
32144
  }
32050
32145
  if (found.shipRow) {
@@ -32087,10 +32182,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32087
32182
  }
32088
32183
  }
32089
32184
  let previous;
32090
- const hadPreviousFile = existsSync59(resolvedPath);
32185
+ const hadPreviousFile = existsSync60(resolvedPath);
32091
32186
  if (hadPreviousFile) {
32092
32187
  try {
32093
- previous = JSON.parse(readFileSync54(resolvedPath, "utf8"));
32188
+ previous = JSON.parse(readFileSync55(resolvedPath, "utf8"));
32094
32189
  } catch {
32095
32190
  }
32096
32191
  }
@@ -32985,10 +33080,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32985
33080
  startupSeconds: cfg.ship.intelStartupSeconds,
32986
33081
  prepare: async (path) => {
32987
33082
  for (const f of repoWt.config.worktrees.copy) {
32988
- const src = join62(repoWt.dir, f);
32989
- if (!existsSync59(src) || existsSync59(join62(path, f))) continue;
32990
- mkdirSync42(dirOf2(join62(path, f)), { recursive: true });
32991
- copyFileSync2(src, join62(path, f));
33083
+ const src = join63(repoWt.dir, f);
33084
+ if (!existsSync60(src) || existsSync60(join63(path, f))) continue;
33085
+ mkdirSync42(dirOf2(join63(path, f)), { recursive: true });
33086
+ copyFileSync2(src, join63(path, f));
32992
33087
  }
32993
33088
  const setup = repoWt.config.hooks.setup;
32994
33089
  return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
@@ -33214,7 +33309,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33214
33309
  const shellR = hit && resolveShell(hit.repo.config.shell ?? cfg.ship.shell);
33215
33310
  const resumed = await runPeriscopeResume({
33216
33311
  find: async () => hit && { row: hit.row, tag: hit.tag },
33217
- worktreeExists: (p) => existsSync59(p),
33312
+ worktreeExists: (p) => existsSync60(p),
33218
33313
  prepareDropFile,
33219
33314
  startProxy: (wt, url, n) => launchProxy(crewInvocation(CREW_HOME), wt, url, Number(n), { host: hit.row.host || "localhost", inject: hit.repo.config.periscope?.inspector !== "repo" }),
33220
33315
  relay: hit && previewRelayFor(hit.route) && {
@@ -33317,10 +33412,10 @@ ${where.join("\n")}`);
33317
33412
  },
33318
33413
  prepare: async (path) => {
33319
33414
  for (const f of repoP.config.worktrees.copy) {
33320
- const src = join62(repoP.dir, f);
33321
- if (!existsSync59(src)) continue;
33322
- mkdirSync42(dirOf2(join62(path, f)), { recursive: true });
33323
- copyFileSync2(src, join62(path, f));
33415
+ const src = join63(repoP.dir, f);
33416
+ if (!existsSync60(src)) continue;
33417
+ mkdirSync42(dirOf2(join63(path, f)), { recursive: true });
33418
+ copyFileSync2(src, join63(path, f));
33324
33419
  }
33325
33420
  const setup = repoP.config.hooks.setup;
33326
33421
  return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
@@ -33632,7 +33727,7 @@ ${where.join("\n")}`);
33632
33727
  };
33633
33728
  const droppedRoutes = [];
33634
33729
  try {
33635
- const rawCfg = parseYaml3(readFileSync54(cfg.configFile, "utf8"));
33730
+ const rawCfg = parseYaml3(readFileSync55(cfg.configFile, "utf8"));
33636
33731
  for (const r of rawCfg?.routes ?? []) {
33637
33732
  if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
33638
33733
  try {
@@ -33762,7 +33857,7 @@ ${where.join("\n")}`);
33762
33857
  }
33763
33858
  case "log": {
33764
33859
  try {
33765
- const text2 = readFileSync54(cfg.ship.logFile, "utf8").split("\n");
33860
+ const text2 = readFileSync55(cfg.ship.logFile, "utf8").split("\n");
33766
33861
  process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
33767
33862
  `);
33768
33863
  } catch {
@@ -33785,7 +33880,7 @@ ${where.join("\n")}`);
33785
33880
  };
33786
33881
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
33787
33882
  const tracker = new Tracker(route2, cfg.ship);
33788
- const configText = readFileSync54(cfg.configFile, "utf8");
33883
+ const configText = readFileSync55(cfg.configFile, "utf8");
33789
33884
  const cfgBase = dirname37(cfg.configFile);
33790
33885
  const configured2 = configuredRepos(configText, route2.route, cfgBase);
33791
33886
  const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
@@ -33822,29 +33917,29 @@ ${where.join("\n")}`);
33822
33917
  }
33823
33918
  if (row) {
33824
33919
  await tracker.deleteRepoRow(row.id);
33825
- if (existsSync59(resolvedFile)) {
33826
- const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
33920
+ if (existsSync60(resolvedFile)) {
33921
+ const raw = JSON.parse(readFileSync55(resolvedFile, "utf8"));
33827
33922
  if (raw.repoNames) delete raw.repoNames[row.id];
33828
33923
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
33829
33924
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
33830
33925
  `);
33831
33926
  }
33832
33927
  }
33833
- if (existsSync59(join62(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
33928
+ if (existsSync60(join63(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
33834
33929
  say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
33835
33930
  break;
33836
33931
  }
33837
33932
  const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
33838
- const fresh = !existsSync59(join62(dir, ".git"));
33839
- if (existsSync59(dir) && fresh && readdirSync21(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
33933
+ const fresh = !existsSync60(join63(dir, ".git"));
33934
+ if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
33840
33935
  if (dryRun) {
33841
33936
  say("dry-run", { dir, newCheckout: fresh, repoRow: row?.id ?? null }, `would ${fresh ? "create" : "reuse"} ${dir}${row ? "" : ", create the Repos row"}, and file one ${tracker.contract.statuses.approved} ticket`);
33842
33937
  break;
33843
33938
  }
33844
33939
  if (fresh) {
33845
33940
  mkdirSync42(dir, { recursive: true });
33846
- writeFileSync42(join62(dir, "README.md"), SAMPLE_README);
33847
- writeFileSync42(join62(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
33941
+ writeFileSync42(join63(dir, "README.md"), SAMPLE_README);
33942
+ writeFileSync42(join63(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
33848
33943
  const g = (...a) => {
33849
33944
  const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
33850
33945
  if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
@@ -33862,8 +33957,8 @@ ${where.join("\n")}`);
33862
33957
  spec: { platform: "unix", releaseMode: "integrate", ciProvider: "none" }
33863
33958
  });
33864
33959
  repoId = (await tracker.createRepoRow(payload)).id;
33865
- if (existsSync59(resolvedFile)) {
33866
- const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
33960
+ if (existsSync60(resolvedFile)) {
33961
+ const raw = JSON.parse(readFileSync55(resolvedFile, "utf8"));
33867
33962
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
33868
33963
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
33869
33964
  writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -34017,6 +34112,10 @@ ${where.join("\n")}`);
34017
34112
  const projects = projectModeLabels(await statusTracker.projectRowsWithModes().catch(() => []));
34018
34113
  const crewMinVersion = await readCrewFloor(route2, cfg.ship) ?? null;
34019
34114
  const runs = liveRuns(cfg.ship.stateDir);
34115
+ const runTitles = new Map(
34116
+ (await statusTracker.ticketsByIds([...new Set(runs.map((x) => x.ticketRecordId).filter((id) => !!id))]).catch(() => [])).map((t) => [t.id, t.title ?? null])
34117
+ );
34118
+ const lastRuns = lastRunsBySeat(cfg.ship.stateDir);
34020
34119
  const periscopes = await periscopesForStatus(cfg.ship.stateDir);
34021
34120
  if (flag("json")) {
34022
34121
  const nameSync = await reconcileRouteShipName({ route: route2, ship: cfg.ship, configFile: cfg.configFile, readOnly: true });
@@ -34037,7 +34136,9 @@ ${where.join("\n")}`);
34037
34136
  name: crewRow?.name ?? null,
34038
34137
  personaName,
34039
34138
  // Additive (CREW-2822): how many runs this seat has live right now.
34040
- running: runs.filter((x) => x.role === r && x.route === routeSlug(route2.route)).length
34139
+ running: runs.filter((x) => x.role === r && x.route === routeSlug(route2.route)).length,
34140
+ // Additive (CREW-3247): this seat's newest finished run on this ship, or null.
34141
+ lastRun: ((l) => l ? { ticket: l.ticket, startedAt: l.startedAt, finishedAt: l.finishedAt, outcome: l.outcome, exitCode: l.exitCode } : null)(lastRuns.get(`${routeSlug(route2.route)}/${r}`))
34041
34142
  };
34042
34143
  });
34043
34144
  process.stdout.write(`${JSON.stringify({
@@ -34087,7 +34188,7 @@ ${where.join("\n")}`);
34087
34188
  seats: seats2
34088
34189
  },
34089
34190
  // Additive (CREW-2822): every live run on this ship. `version` stays 1.
34090
- runs: runs.map((x) => describeRun(x, route2, seatIds)),
34191
+ runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles })),
34091
34192
  // Additive (CREW-2857): every live periscope on this ship, from its local record. `version` stays 1.
34092
34193
  periscopes,
34093
34194
  watermark: state.watermark(routeSlug(route2.route)),
@@ -34241,7 +34342,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34241
34342
  plan,
34242
34343
  label,
34243
34344
  uid: process.getuid?.() ?? 0,
34244
- system: plan.mechanism === "systemd" && existsSync59(systemUnitPathFor(label)),
34345
+ system: plan.mechanism === "systemd" && existsSync60(systemUnitPathFor(label)),
34245
34346
  stamp: readDaemonStamp(cfg.ship.stateDir)
34246
34347
  });
34247
34348
  })();
@@ -34257,7 +34358,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34257
34358
  }
34258
34359
  for (const r of repos) {
34259
34360
  const remote = r.config.branch.remote;
34260
- if (existsSync59(r.dir)) {
34361
+ if (existsSync60(r.dir)) {
34261
34362
  pushAuth.push({
34262
34363
  route: c.route,
34263
34364
  repo: r.name,
@@ -34341,7 +34442,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
34341
34442
  else passed++;
34342
34443
  }
34343
34444
  if (staleBundle) problems.push({ severity: "blocker", kind: "stale_bundle", message: staleBundle.message, remedy: "npm run build" });
34344
- const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync59, userInfo2().username);
34445
+ const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync60, userInfo2().username);
34345
34446
  if (runtimeDir) problems.push({ severity: "attention", kind: "runtime_dir_missing", message: runtimeDir });
34346
34447
  if (!flag("offline")) {
34347
34448
  const shipKind = await doctorShipKind(route2, cfg.ship);
@@ -34413,7 +34514,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34413
34514
  }
34414
34515
  try {
34415
34516
  const evFile = eventFileFor(cfg.ship.stateDir);
34416
- const evSize = existsSync59(evFile) ? statSync18(evFile).size : 0;
34517
+ const evSize = existsSync60(evFile) ? statSync19(evFile).size : 0;
34417
34518
  process.stdout.write(
34418
34519
  evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
34419
34520
  ` : "events log: ok\n"
@@ -34424,7 +34525,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34424
34525
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
34425
34526
  const abandons = unitAbandonsAgents(unitPlan, (p) => {
34426
34527
  try {
34427
- return readFileSync54(p, "utf8");
34528
+ return readFileSync55(p, "utf8");
34428
34529
  } catch {
34429
34530
  return null;
34430
34531
  }
@@ -34439,7 +34540,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34439
34540
  const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
34440
34541
  const keeps = unitAbandonsAgents(pPlan, (p) => {
34441
34542
  try {
34442
- return readFileSync54(p, "utf8");
34543
+ return readFileSync55(p, "utf8");
34443
34544
  } catch {
34444
34545
  return null;
34445
34546
  }
@@ -34453,7 +34554,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34453
34554
  if (host === "linux" && detectSystemd()) {
34454
34555
  const ctl = planDaemonControl(CREW_HOME, host, true);
34455
34556
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, true, "run", installContext());
34456
- if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync59(p))) {
34557
+ if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync60(p))) {
34457
34558
  const st = spawnSync14(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
34458
34559
  if (!st.error && st.status !== 0) {
34459
34560
  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");
@@ -34478,8 +34579,8 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34478
34579
  const changed2 = configChangedAfter(daemonConfigPaths(cfg), daemonStartedAt);
34479
34580
  if (changed2) {
34480
34581
  process.stdout.write(
34481
- daemonDead ? `daemon config: WARN ${changed2} changed at ${new Date(statSync18(changed2).mtimeMs).toISOString()} \u2014 no daemon is running; the new config applies when it starts
34482
- ` : `daemon config: WARN ${changed2} changed at ${new Date(statSync18(changed2).mtimeMs).toISOString()} but the daemon started at ${new Date(daemonStartedAt).toISOString()} \u2014 run \`crew reload\`
34582
+ 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
34583
+ ` : `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\`
34483
34584
  `
34484
34585
  );
34485
34586
  }