@tablation/crew 0.165.0 → 0.165.1

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 +402 -309
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7349,14 +7349,14 @@ function envForRepository(entries, repo) {
7349
7349
 
7350
7350
  // src/interrupted.ts
7351
7351
  import { existsSync as existsSync30, readdirSync as readdirSync10, readFileSync as readFileSync32 } from "fs";
7352
- import { join as join35 } from "path";
7352
+ import { join as join36 } from "path";
7353
7353
 
7354
7354
  // src/agent.ts
7355
7355
  import { spawnSync as spawnSync6 } from "child_process";
7356
- import { readFileSync as readFileSync31, existsSync as existsSync29, statSync as statSync9, mkdirSync as mkdirSync22, writeFileSync as writeFileSync23, createWriteStream, openSync as openSync4, closeSync as closeSync4, readSync } from "fs";
7356
+ import { readFileSync as readFileSync31, existsSync as existsSync29, statSync as statSync9, mkdirSync as mkdirSync23, writeFileSync as writeFileSync24, createWriteStream, openSync as openSync4, closeSync as closeSync4, readSync } from "fs";
7357
7357
  import { StringDecoder } from "string_decoder";
7358
7358
  import { finished } from "stream/promises";
7359
- import { join as join34, dirname as dirname17, basename as basename9 } from "path";
7359
+ import { join as join35, dirname as dirname17, basename as basename9 } from "path";
7360
7360
  import { createHash as createHash7, randomUUID as randomUUID2 } from "crypto";
7361
7361
 
7362
7362
  // src/state.ts
@@ -9505,8 +9505,8 @@ var unregisterRunInput = (run4) => {
9505
9505
  var runInputFor = (run4) => live.get(run4);
9506
9506
 
9507
9507
  // src/agent-log.ts
9508
- import { existsSync as existsSync25, mkdirSync as mkdirSync18, readdirSync as readdirSync8, readFileSync as readFileSync25, rmSync as rmSync14, writeFileSync as writeFileSync19 } from "fs";
9509
- import { join as join28 } from "path";
9508
+ import { existsSync as existsSync25, mkdirSync as mkdirSync19, readdirSync as readdirSync8, readFileSync as readFileSync25, rmSync as rmSync14, writeFileSync as writeFileSync20 } from "fs";
9509
+ import { join as join29 } from "path";
9510
9510
 
9511
9511
  // src/pending-backoff.ts
9512
9512
  var sleepBackoff = (attempts) => Math.min(6e4 * 2 ** Math.max(0, attempts - 1), 30 * 6e4);
@@ -9514,7 +9514,7 @@ var sleepBackoff = (attempts) => Math.min(6e4 * 2 ** Math.max(0, attempts - 1),
9514
9514
  // src/handoff-guard.ts
9515
9515
  import { createHash as createHash4 } from "crypto";
9516
9516
  import { existsSync as existsSync24, realpathSync as realpathSync2 } from "fs";
9517
- import { dirname as dirname14, join as join27 } from "path";
9517
+ import { dirname as dirname14, join as join28 } from "path";
9518
9518
 
9519
9519
  // src/ticket-branch.ts
9520
9520
  import { basename as basename7 } from "path";
@@ -11391,6 +11391,9 @@ async function finishRunWorktree(dir, cfg, branch) {
11391
11391
  }
11392
11392
 
11393
11393
  // src/build-failure.ts
11394
+ import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync19 } from "fs";
11395
+ import { tmpdir as tmpdir3 } from "os";
11396
+ import { join as join27 } from "path";
11394
11397
  import { StaleWriteError as StaleWriteError3 } from "@tablation/client";
11395
11398
 
11396
11399
  // src/conflict.ts
@@ -11614,6 +11617,73 @@ function culpritByFiles(candidates2, paths) {
11614
11617
  const hits = candidates2.filter((c) => paths.some((p) => c.changed.has(p)));
11615
11618
  return hits.length === 1 ? hits[0] : null;
11616
11619
  }
11620
+ var EXCERPT_CONTEXT = 3;
11621
+ var EXCERPT_MATCHES = 3;
11622
+ var EXCERPT_CLOSING = 5;
11623
+ var STEP_MARKER = /^\s*(?:---+\s|===+\s|##\s)\S/;
11624
+ var stripAnsi = (s) => s.replace(/\u001b\[[0-9;]*m/g, "");
11625
+ function failureExcerpt(output, paths, tailLines) {
11626
+ const lines2 = stripAnsi(output).trimEnd().split("\n");
11627
+ const tail3 = lines2.slice(-tailLines).join("\n");
11628
+ const hits = [];
11629
+ if (paths.length) lines2.forEach((l, i) => {
11630
+ if (paths.some((p) => l.includes(p))) hits.push(i);
11631
+ });
11632
+ if (!hits.length) return { text: tail3, pathCentered: false };
11633
+ const shown = hits.slice(0, EXCERPT_MATCHES);
11634
+ const keep = /* @__PURE__ */ new Set();
11635
+ for (const i of shown) {
11636
+ for (let k = Math.max(0, i - EXCERPT_CONTEXT); k <= Math.min(lines2.length - 1, i + EXCERPT_CONTEXT); k++) keep.add(k);
11637
+ for (let k = i; k >= 0; k--) {
11638
+ if (STEP_MARKER.test(lines2[k])) {
11639
+ keep.add(k);
11640
+ break;
11641
+ }
11642
+ }
11643
+ }
11644
+ const out = [];
11645
+ let prev = -2;
11646
+ for (const k of [...keep].sort((a, b) => a - b)) {
11647
+ if (k !== prev + 1 && out.length) out.push("\u2026");
11648
+ out.push(lines2[k]);
11649
+ prev = k;
11650
+ }
11651
+ const more = hits.length - shown.length;
11652
+ if (more > 0) out.push(`\u2026 and ${more} more line${more === 1 ? "" : "s"} naming these files`);
11653
+ const closing = lines2.slice(-Math.min(EXCERPT_CLOSING, tailLines));
11654
+ const last = Math.max(...keep);
11655
+ if (last < lines2.length - closing.length) out.push("\u2026 end of the output:", ...closing);
11656
+ return { text: out.join("\n"), pathCentered: true };
11657
+ }
11658
+ function saveGateOutput(ticketKey, hook2, output) {
11659
+ try {
11660
+ const dir = join27(tmpdir3(), "crew-gate-output");
11661
+ mkdirSync18(dir, { recursive: true });
11662
+ const path = join27(dir, `${ticketKey.replace(/[^\w.-]/g, "_")}-${hook2}-${Date.now()}.log`);
11663
+ writeFileSync19(path, stripAnsi(output));
11664
+ return path;
11665
+ } catch {
11666
+ return null;
11667
+ }
11668
+ }
11669
+ var RECORD_RE = /<!-- crew-gate-failure (\{.*?\}) -->/;
11670
+ var recordLine = (b, repeat) => `<!-- crew-gate-failure ${JSON.stringify({ paths: b.failingFiles ?? [], ...b.tip ? { tip: b.tip } : {}, ...repeat ? { repeat: true } : {} })} -->`;
11671
+ function recordedFailure(note, cwd) {
11672
+ if (!note) return void 0;
11673
+ const m = RECORD_RE.exec(note);
11674
+ if (m) {
11675
+ try {
11676
+ return JSON.parse(m[1]);
11677
+ } catch {
11678
+ }
11679
+ }
11680
+ return { paths: failingPaths(note, cwd ?? "/\0") };
11681
+ }
11682
+ function isUnseenRepeat(b, previousNote) {
11683
+ const prev = recordedFailure(previousNote, b.cwd);
11684
+ if (!prev || prev.repeat || !prev.tip || !b.tip || prev.tip !== b.tip) return false;
11685
+ return (b.failingFiles ?? []).some((f2) => prev.paths.includes(f2));
11686
+ }
11617
11687
  function planBuildFailureBounce(cwd, c, base, remote) {
11618
11688
  return { ...c, base, remote, worktree: worktreeForBranch(cwd, c.branch) };
11619
11689
  }
@@ -11624,21 +11694,35 @@ function outsideNote(b) {
11624
11694
 
11625
11695
  `;
11626
11696
  }
11627
- function buildFailureComment(b) {
11628
- const how = b.how === "pair" && b.sibling ? `Each branch passes the hook alone; \`${b.branch}\` together with ${b.sibling.key} (\`${b.sibling.branch}\`) fails it. ${b.sibling.key} was verified first, so the fix belongs on this branch: \`git merge ${b.remote}/${b.sibling.branch}\` first, then fix what disagrees. Fix it on this branch, never a fresh one.` : b.how === "files" ? `The failing output names files that only \`${b.branch}\` changed among the branches in that release.` : `Built alone on the previous \`${b.base}\`, \`${b.branch}\` fails the same hook.`;
11697
+ function excerptNote(b) {
11698
+ const where = b.outputPath ? ` The whole output is at \`${b.outputPath}\` on the ship that ran the gate.` : "";
11699
+ return b.pathCentered ? `The excerpt below is built around the output lines that name the failing files.${where}` : `No failing file could be read from the output, so this is its closing lines; **the failing step may be earlier than what is quoted.**${where}`;
11700
+ }
11701
+ function buildFailureComment(b, repeat = false) {
11702
+ const names = (b.failingFiles ?? []).slice(0, 5).map((f2) => `\`${f2}\``).join(", ");
11703
+ const byFiles = b.how === "files";
11704
+ const how = b.how === "pair" && b.sibling ? `Each branch passes the hook alone; \`${b.branch}\` together with ${b.sibling.key} (\`${b.sibling.branch}\`) fails it. ${b.sibling.key} was verified first, so the fix belongs on this branch: \`git merge ${b.remote}/${b.sibling.branch}\` first, then fix what disagrees. Fix it on this branch, never a fresh one.` : byFiles ? `The failing output names files this branch changed${names ? ` (${names})` : ""}. Nothing here shows whether the branch passes the hook on its own.` : `Built alone on the previous \`${b.base}\`, \`${b.branch}\` fails the same hook.`;
11705
+ const first = byFiles ? `First step: run the failing step on \`${b.branch}\` itself${b.worktree ? ` in \`${b.worktree}\`` : ""} and fix what it reports in the files above. Merge \`${b.remote}/${b.base}\` in only if it passes there.` : `First step: \`git merge ${b.remote}/${b.base}\` in ${b.worktree ? `\`${b.worktree}\`` : "the branch's worktree"}, rebuild, and fix what disagrees \u2014 the merge is clean at the text level, so this is a semantic conflict (a duplicate identifier, a changed signature) with work that landed on \`${b.base}\` after this branch was cut.`;
11706
+ const heading = byFiles ? `Back with the dev lane \u2014 the release gate failed in files this branch changed.` : `Back with the dev lane \u2014 this branch builds on its own but not on current \`${b.base}\`.`;
11707
+ const again = repeat ? `**Second hand-back for the same failure on the same commit.** The first note did not show enough to act on, so this one quotes the lines that name the file.
11708
+
11709
+ ` : "";
11629
11710
  return `${BUILD_FAILURE_MARKER}
11630
11711
 
11631
- **Back with the dev lane \u2014 this branch builds on its own but not on current \`${b.base}\`.**
11712
+ **${heading}**
11713
+
11714
+ ${again}\`${b.branch}\` was verified, but the release's \`${b.hook}\` hook failed once it was merged with the other branches in the same release. ${how}
11632
11715
 
11633
- \`${b.branch}\` was verified, but the release's \`${b.hook}\` hook failed once it was merged with the other branches in the same release. ${how}
11716
+ ${outsideNote(b)}${first} Push as a plain fast-forward and hand back to QA as usual.
11634
11717
 
11635
- ${outsideNote(b)}First step: \`git merge ${b.remote}/${b.base}\` in ${b.worktree ? `\`${b.worktree}\`` : "the branch's worktree"}, rebuild, and fix what disagrees \u2014 the merge is clean at the text level, so this is a semantic conflict (a duplicate identifier, a changed signature) with work that landed on \`${b.base}\` after this branch was cut. Push as a plain fast-forward and hand back to QA as usual.
11718
+ ${excerptNote(b)}
11636
11719
 
11637
11720
  \`\`\`
11638
11721
  ${b.tail.trimEnd()}
11639
11722
  \`\`\`
11640
11723
 
11641
- Nothing was written to \`${b.base}\` for this ticket; the rest of the release shipped without it.`;
11724
+ Nothing was written to \`${b.base}\` for this ticket; the rest of the release shipped without it.
11725
+ ${recordLine(b, repeat)}`;
11642
11726
  }
11643
11727
  function priorBuildFailures(ticket, events) {
11644
11728
  const stamp2 = (e) => e.occurred_at ?? e.created_at ?? "";
@@ -11652,7 +11736,7 @@ function priorFailureNote(ticket, events) {
11652
11736
  }
11653
11737
  function failureComparison(b, previousNote) {
11654
11738
  const now = b.failingFiles ?? failingPaths(b.tail, b.cwd ?? "/\0");
11655
- const before = previousNote ? failingPaths(previousNote, b.cwd ?? "/\0") : [];
11739
+ const before = recordedFailure(previousNote, b.cwd)?.paths ?? [];
11656
11740
  const lines2 = [];
11657
11741
  if (!before.length || !now.length) {
11658
11742
  lines2.push("- Same failure both times? Unknown: the output of at least one run names no file.");
@@ -11678,7 +11762,8 @@ ${b.tail.trimEnd()}
11678
11762
  }
11679
11763
  async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRun, prior = { count: 0 }) {
11680
11764
  const t = { ticket: b.ticket.issue_id, step: "release" };
11681
- if (prior.count > 0) {
11765
+ const repeat = prior.count > 0 && isUnseenRepeat(b, prior.previousNote);
11766
+ if (prior.count > 0 && !repeat) {
11682
11767
  if (dryRun) {
11683
11768
  log.emit(`would escalate to ${contract.statuses.needsHuman} \u2014 handed back for the ${b.hook} hook before`, t);
11684
11769
  return { kind: "escalated" };
@@ -11709,7 +11794,7 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
11709
11794
  { status: contract.statuses.building, assignee_id: null },
11710
11795
  b.ticket.updated_at
11711
11796
  );
11712
- await writer.postEvent(b.ticket.id, buildFailureComment(b), memberId, "build_failed").catch(() => {
11797
+ await writer.postEvent(b.ticket.id, buildFailureComment(b, repeat), memberId, "build_failed").catch(() => {
11713
11798
  log.warn("handed back, but the note failed to post", t);
11714
11799
  });
11715
11800
  await writer.postEvent(
@@ -11865,7 +11950,7 @@ var sameDir = (a, b) => {
11865
11950
  function repairMisnamedBranch(dir, cfg, ticket, role) {
11866
11951
  const expected = branchCandidatesForTicket(cfg, ticket, role).find((c) => !c.endsWith("*"));
11867
11952
  if (!expected) return { kind: "none" };
11868
- const wtPath = join27(dirname14(dir), worktreeForTicket(dir, cfg, ticket, role));
11953
+ const wtPath = join28(dirname14(dir), worktreeForTicket(dir, cfg, ticket, role));
11869
11954
  const wt = worktrees(dir).find((w) => !w.prunable && sameDir(w.path, wtPath));
11870
11955
  const from = wt?.branch;
11871
11956
  if (!wt || !from || from === cfg.branch.base) return { kind: "none" };
@@ -13002,17 +13087,17 @@ async function addRunToTicket(target, t, recordId, run4) {
13002
13087
  };
13003
13088
  }
13004
13089
  }
13005
- var queueDir = (stateDir) => join28(stateDir, "pending-agent-logs");
13090
+ var queueDir = (stateDir) => join29(stateDir, "pending-agent-logs");
13006
13091
  function queueAgentRun(stateDir, name, q2) {
13007
- mkdirSync18(queueDir(stateDir), { recursive: true });
13008
- writeFileSync19(join28(queueDir(stateDir), `${name}.json`), JSON.stringify(q2));
13092
+ mkdirSync19(queueDir(stateDir), { recursive: true });
13093
+ writeFileSync20(join29(queueDir(stateDir), `${name}.json`), JSON.stringify(q2));
13009
13094
  }
13010
13095
  async function replayQueuedAgentRuns(stateDir, route2, keyFor, log, now = /* @__PURE__ */ new Date()) {
13011
13096
  const dir = queueDir(stateDir);
13012
13097
  if (!existsSync25(dir)) return 0;
13013
13098
  let sent = 0;
13014
13099
  for (const f2 of readdirSync8(dir).filter((n) => n.endsWith(".json")).sort()) {
13015
- const path = join28(dir, f2);
13100
+ const path = join29(dir, f2);
13016
13101
  let q2;
13017
13102
  try {
13018
13103
  q2 = JSON.parse(readFileSync25(path, "utf8"));
@@ -13044,7 +13129,7 @@ async function replayQueuedAgentRuns(stateDir, route2, keyFor, log, now = /* @__
13044
13129
  continue;
13045
13130
  }
13046
13131
  const attempts = q2.attempts + 1;
13047
- writeFileSync19(path, JSON.stringify({
13132
+ writeFileSync20(path, JSON.stringify({
13048
13133
  ...q2,
13049
13134
  attempts,
13050
13135
  warned: true,
@@ -13055,17 +13140,17 @@ async function replayQueuedAgentRuns(stateDir, route2, keyFor, log, now = /* @__
13055
13140
  }
13056
13141
  return sent;
13057
13142
  }
13058
- var countersDir = (stateDir) => join28(stateDir, "pending-ticket-counters");
13143
+ var countersDir = (stateDir) => join29(stateDir, "pending-ticket-counters");
13059
13144
  function queueTicketCounters(stateDir, name, q2) {
13060
- mkdirSync18(countersDir(stateDir), { recursive: true });
13061
- writeFileSync19(join28(countersDir(stateDir), `${name}.json`), JSON.stringify(q2));
13145
+ mkdirSync19(countersDir(stateDir), { recursive: true });
13146
+ writeFileSync20(join29(countersDir(stateDir), `${name}.json`), JSON.stringify(q2));
13062
13147
  }
13063
13148
  async function replayQueuedTicketCounters(stateDir, route2, keyFor, log, now = /* @__PURE__ */ new Date()) {
13064
13149
  const dir = countersDir(stateDir);
13065
13150
  if (!existsSync25(dir)) return 0;
13066
13151
  let sent = 0;
13067
13152
  for (const f2 of readdirSync8(dir).filter((n) => n.endsWith(".json")).sort()) {
13068
- const path = join28(dir, f2);
13153
+ const path = join29(dir, f2);
13069
13154
  let q2;
13070
13155
  try {
13071
13156
  q2 = JSON.parse(readFileSync25(path, "utf8"));
@@ -13087,7 +13172,7 @@ async function replayQueuedTicketCounters(stateDir, route2, keyFor, log, now = /
13087
13172
  continue;
13088
13173
  }
13089
13174
  const attempts = q2.attempts + 1;
13090
- writeFileSync19(path, JSON.stringify({
13175
+ writeFileSync20(path, JSON.stringify({
13091
13176
  ...q2,
13092
13177
  attempts,
13093
13178
  warned: true,
@@ -13327,10 +13412,10 @@ var HandoffTranscriptTracker = class {
13327
13412
  };
13328
13413
 
13329
13414
  // src/seat-notes.ts
13330
- import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync19, readFileSync as readFileSync26, renameSync as renameSync4, rmSync as rmSync15, writeFileSync as writeFileSync20 } from "fs";
13415
+ import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync20, readFileSync as readFileSync26, renameSync as renameSync4, rmSync as rmSync15, writeFileSync as writeFileSync21 } from "fs";
13331
13416
  import { randomUUID } from "crypto";
13332
- import { join as join29 } from "path";
13333
- var fileFor2 = (stateDir, role) => join29(stateDir, "seat-notes", `${role}.jsonl`);
13417
+ import { join as join30 } from "path";
13418
+ var fileFor2 = (stateDir, role) => join30(stateDir, "seat-notes", `${role}.jsonl`);
13334
13419
  var sameTicket = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
13335
13420
  function readAll(stateDir, role) {
13336
13421
  let raw;
@@ -13351,7 +13436,7 @@ function readAll(stateDir, role) {
13351
13436
  }
13352
13437
  function addSeatNote(stateDir, note, now = /* @__PURE__ */ new Date()) {
13353
13438
  const full = { id: randomUUID(), createdAt: now.toISOString(), ...note };
13354
- mkdirSync19(join29(stateDir, "seat-notes"), { recursive: true });
13439
+ mkdirSync20(join30(stateDir, "seat-notes"), { recursive: true });
13355
13440
  appendFileSync3(fileFor2(stateDir, note.role), `${JSON.stringify(full)}
13356
13441
  `);
13357
13442
  return full;
@@ -13369,7 +13454,7 @@ function consumeSeatNotes(stateDir, role, taken) {
13369
13454
  return;
13370
13455
  }
13371
13456
  const tmp = `${file}.${process.pid}.tmp`;
13372
- writeFileSync20(tmp, keep.map((n) => `${JSON.stringify(n)}
13457
+ writeFileSync21(tmp, keep.map((n) => `${JSON.stringify(n)}
13373
13458
  `).join(""));
13374
13459
  renameSync4(tmp, file);
13375
13460
  }
@@ -13389,10 +13474,10 @@ function seatNotesSection(notes) {
13389
13474
  import { createHash as createHash5 } from "crypto";
13390
13475
  import { spawn as spawn4 } from "child_process";
13391
13476
  import { execFileSync as execFileSync8 } from "child_process";
13392
- import { existsSync as existsSync26, mkdirSync as mkdirSync20, readFileSync as readFileSync27, renameSync as renameSync5, writeFileSync as writeFileSync21, rmSync as rmSync16, statSync as statSync8 } from "fs";
13393
- import { dirname as dirname15, join as join30 } from "path";
13477
+ import { existsSync as existsSync26, mkdirSync as mkdirSync21, readFileSync as readFileSync27, renameSync as renameSync5, writeFileSync as writeFileSync22, rmSync as rmSync16, statSync as statSync8 } from "fs";
13478
+ import { dirname as dirname15, join as join31 } from "path";
13394
13479
  import { fileURLToPath } from "url";
13395
- import { tmpdir as tmpdir3 } from "os";
13480
+ import { tmpdir as tmpdir4 } from "os";
13396
13481
  var SANDBOX_BASE_IMAGE = "nvcr.io/nvidia/base/ubuntu:24.04";
13397
13482
  var SANDBOX_OPENSHELL_VERSION = "0.1.6";
13398
13483
  var SANDBOX_CLAUDE_VERSION = "2.1.309";
@@ -13406,7 +13491,7 @@ var CREW_PREFIX = "/opt/crew";
13406
13491
  var SANDBOX_BRIDGE_PATH = `${CREW_PREFIX}/bin/intel-bridge`;
13407
13492
  function readBridgeBundle() {
13408
13493
  const here = dirname15(fileURLToPath(import.meta.url));
13409
- for (const p of [join30(here, "sandbox-intel-bridge.cjs"), join30(here, "..", "dist", "sandbox-intel-bridge.cjs")]) {
13494
+ for (const p of [join31(here, "sandbox-intel-bridge.cjs"), join31(here, "..", "dist", "sandbox-intel-bridge.cjs")]) {
13410
13495
  if (existsSync26(p)) return readFileSync27(p, "utf8");
13411
13496
  }
13412
13497
  return void 0;
@@ -13582,7 +13667,7 @@ function planSandbox(repo, decl, warm = {}, bridge) {
13582
13667
  }
13583
13668
  var SHIP_SANDBOX_KEY = "@ship";
13584
13669
  var shipSandboxRef = () => ({ name: SHIP_SANDBOX_KEY, decl: { packages: [], setup: [] } });
13585
- var sandboxStatePath = (stateDir) => join30(stateDir, "sandbox-images.json");
13670
+ var sandboxStatePath = (stateDir) => join31(stateDir, "sandbox-images.json");
13586
13671
  function readSandboxState(stateDir) {
13587
13672
  try {
13588
13673
  const v = JSON.parse(readFileSync27(sandboxStatePath(stateDir), "utf8"));
@@ -13592,9 +13677,9 @@ function readSandboxState(stateDir) {
13592
13677
  }
13593
13678
  }
13594
13679
  function writeSandboxState(stateDir, state) {
13595
- mkdirSync20(stateDir, { recursive: true });
13680
+ mkdirSync21(stateDir, { recursive: true });
13596
13681
  const file = sandboxStatePath(stateDir);
13597
- writeFileSync21(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
13682
+ writeFileSync22(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
13598
13683
  `);
13599
13684
  renameSync5(`${file}.tmp`, file);
13600
13685
  }
@@ -13632,7 +13717,7 @@ var spawnBuildRunner = (engine = "docker") => (args, logPath) => new Promise((re
13632
13717
  child.stdout.on("data", (d) => chunks.push(d));
13633
13718
  child.stderr.on("data", (d) => chunks.push(d));
13634
13719
  const done = (code, extra = "") => {
13635
- writeFileSync21(logPath, `$ ${engine} ${args.join(" ")}
13720
+ writeFileSync22(logPath, `$ ${engine} ${args.join(" ")}
13636
13721
  ${Buffer.concat(chunks).toString("utf8")}${extra}`, { flag: "a" });
13637
13722
  resolve8(code);
13638
13723
  };
@@ -13654,7 +13739,7 @@ var engineRemoveImage = (engine = "docker", exec = realExec) => (tag) => {
13654
13739
  } catch {
13655
13740
  }
13656
13741
  };
13657
- var sandboxLogDir = (stateDir) => join30(stateDir, "sandbox-logs");
13742
+ var sandboxLogDir = (stateDir) => join31(stateDir, "sandbox-logs");
13658
13743
  async function buildSandboxImage(plan, deps) {
13659
13744
  const now = deps.now ?? (() => /* @__PURE__ */ new Date());
13660
13745
  const state = readSandboxState(deps.stateDir);
@@ -13663,21 +13748,21 @@ async function buildSandboxImage(plan, deps) {
13663
13748
  return { kind: "reused", tag: plan.tag };
13664
13749
  }
13665
13750
  const logDir = sandboxLogDir(deps.stateDir);
13666
- mkdirSync20(logDir, { recursive: true });
13667
- const logPath = join30(logDir, `${slug(plan.repo)}-${now().toISOString().replace(/[:.]/g, "-")}.log`);
13751
+ mkdirSync21(logDir, { recursive: true });
13752
+ const logPath = join31(logDir, `${slug(plan.repo)}-${now().toISOString().replace(/[:.]/g, "-")}.log`);
13668
13753
  const builtLayers = [];
13669
13754
  for (const layer of plan.layers) {
13670
13755
  if (deps.hasImage(layer.tag)) continue;
13671
- const ctx = join30(tmpdir3(), `crew-sandbox-${hash([layer.tag, process.pid, Date.now()])}`);
13672
- mkdirSync20(ctx, { recursive: true });
13756
+ const ctx = join31(tmpdir4(), `crew-sandbox-${hash([layer.tag, process.pid, Date.now()])}`);
13757
+ mkdirSync21(ctx, { recursive: true });
13673
13758
  try {
13674
- writeFileSync21(join30(ctx, "Dockerfile"), layer.dockerfile);
13759
+ writeFileSync22(join31(ctx, "Dockerfile"), layer.dockerfile);
13675
13760
  for (const [name, content] of Object.entries(layer.files)) {
13676
- mkdirSync20(dirname15(join30(ctx, name)), { recursive: true });
13677
- writeFileSync21(join30(ctx, name), content);
13761
+ mkdirSync21(dirname15(join31(ctx, name)), { recursive: true });
13762
+ writeFileSync22(join31(ctx, name), content);
13678
13763
  }
13679
- if (layer.caBundleFile) writeFileSync21(join30(ctx, layer.caBundleFile), (deps.caBundle ?? readHostCaBundle)());
13680
- const code = await deps.run(["build", "--tag", layer.tag, "--file", join30(ctx, "Dockerfile"), ctx], logPath);
13764
+ if (layer.caBundleFile) writeFileSync22(join31(ctx, layer.caBundleFile), (deps.caBundle ?? readHostCaBundle)());
13765
+ const code = await deps.run(["build", "--tag", layer.tag, "--file", join31(ctx, "Dockerfile"), ctx], logPath);
13681
13766
  if (code === BUILD_INTERRUPTED) return { kind: "interrupted", tag: plan.tag };
13682
13767
  if (code !== 0) {
13683
13768
  state[plan.repo] = { ...entry, failure: { tag: plan.tag, at: now().toISOString(), logPath } };
@@ -13796,7 +13881,7 @@ function expandSkillMarkers(text2, lookup2, opts = {}) {
13796
13881
 
13797
13882
  // src/skills.ts
13798
13883
  import { readFileSync as readFileSync30, readdirSync as readdirSync9, existsSync as existsSync28 } from "fs";
13799
- import { join as join32 } from "path";
13884
+ import { join as join33 } from "path";
13800
13885
  import { parse as parseYaml2 } from "yaml";
13801
13886
  import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError5, TablationApiError as TablationApiError3 } from "@tablation/client";
13802
13887
 
@@ -13829,7 +13914,7 @@ function readPersonaFile(path) {
13829
13914
 
13830
13915
  // src/agents.ts
13831
13916
  import { readFileSync as readFileSync29, existsSync as existsSync27 } from "fs";
13832
- import { join as join31 } from "path";
13917
+ import { join as join32 } from "path";
13833
13918
  import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError4, TablationApiError as TablationApiError2 } from "@tablation/client";
13834
13919
  var PERSONA_NAME = {
13835
13920
  dev: "Developer",
@@ -13843,16 +13928,16 @@ var CREW_AGENT_COLUMN = "agent_id";
13843
13928
  var AgentsSyncError = class extends Error {
13844
13929
  };
13845
13930
  function personaDefaultPrompt(promptsDir, role) {
13846
- const briefPath = join31(promptsDir, "personas", `lane-${role}.md`);
13931
+ const briefPath = join32(promptsDir, "personas", `lane-${role}.md`);
13847
13932
  if (!existsSync27(briefPath)) throw new AgentsSyncError(`no brief at ${briefPath}`);
13848
13933
  const brief = readPersonaFile(briefPath).body;
13849
13934
  if (SELF_CONTAINED_ROLES.has(role)) return brief;
13850
- const commonPath = join31(promptsDir, "personas", "common.md");
13935
+ const commonPath = join32(promptsDir, "personas", "common.md");
13851
13936
  if (!existsSync27(commonPath)) return brief;
13852
13937
  return `${readFileSync29(commonPath, "utf8")}${brief}`;
13853
13938
  }
13854
13939
  function personaChatEnabled(promptsDir, role) {
13855
- const briefPath = join31(promptsDir, "personas", `lane-${role}.md`);
13940
+ const briefPath = join32(promptsDir, "personas", `lane-${role}.md`);
13856
13941
  return existsSync27(briefPath) ? readPersonaFile(briefPath).chatEnabled : void 0;
13857
13942
  }
13858
13943
  async function resolveAgentId(route2, role, opts) {
@@ -14366,9 +14451,9 @@ function parseSkillFile(path) {
14366
14451
  };
14367
14452
  }
14368
14453
  function listLocalSkills(promptsDir) {
14369
- const dir = join32(promptsDir, "skills");
14454
+ const dir = join33(promptsDir, "skills");
14370
14455
  if (!existsSync28(dir)) return [];
14371
- return readdirSync9(dir).filter((f2) => f2.endsWith(".md")).map((f2) => parseSkillFile(join32(dir, f2)));
14456
+ return readdirSync9(dir).filter((f2) => f2.endsWith(".md")).map((f2) => parseSkillFile(join33(dir, f2)));
14372
14457
  }
14373
14458
  function personaColumn(model) {
14374
14459
  for (const c of ["persona_id", "persona"]) if (model.fields?.some((f2) => f2.columnName === c)) return c;
@@ -14602,10 +14687,10 @@ function skillMarkerWarnings(promptsDir, personaPrompts) {
14602
14687
 
14603
14688
  // src/runner.ts
14604
14689
  import { spawn as spawn5, execFile, execFileSync as execFileSync9 } from "child_process";
14605
- import { mkdtempSync, mkdirSync as mkdirSync21, writeFileSync as writeFileSync22, rmSync as rmSync17 } from "fs";
14690
+ import { mkdtempSync, mkdirSync as mkdirSync22, writeFileSync as writeFileSync23, rmSync as rmSync17 } from "fs";
14606
14691
  import { createHash as createHash6 } from "crypto";
14607
- import { tmpdir as tmpdir4 } from "os";
14608
- import { basename as basename8, dirname as dirname16, join as join33 } from "path";
14692
+ import { tmpdir as tmpdir5 } from "os";
14693
+ import { basename as basename8, dirname as dirname16, join as join34 } from "path";
14609
14694
  import { promisify } from "util";
14610
14695
 
14611
14696
  // src/run-limit.ts
@@ -14756,8 +14841,8 @@ var SandboxRunner = class {
14756
14841
  throw new Error(`cannot generate the sandbox policy: ${e.message}`);
14757
14842
  }
14758
14843
  policyFile = policyPathFor(plan.streamPath);
14759
- mkdirSync21(dirname16(policyFile), { recursive: true });
14760
- writeFileSync22(policyFile, generated.yaml, { mode: 384 });
14844
+ mkdirSync22(dirname16(policyFile), { recursive: true });
14845
+ writeFileSync23(policyFile, generated.yaml, { mode: 384 });
14761
14846
  }
14762
14847
  const create2 = ["sandbox", "create", "--name", name, "--detach"];
14763
14848
  if (policyFile) create2.push("--policy", policyFile);
@@ -14806,10 +14891,10 @@ var SandboxRunner = class {
14806
14891
  const harness = cfg.agentBin ?? basename8(plan.bin);
14807
14892
  const viaUpload = Buffer.byteLength(plan.prompt) > SANDBOX_STDIN_LIMIT;
14808
14893
  if (viaUpload) {
14809
- const tmp = mkdtempSync(join33(tmpdir4(), "crew-prompt-"));
14894
+ const tmp = mkdtempSync(join34(tmpdir5(), "crew-prompt-"));
14810
14895
  try {
14811
- const file = join33(tmp, "prompt.txt");
14812
- writeFileSync22(file, plan.prompt, { mode: 384 });
14896
+ const file = join34(tmp, "prompt.txt");
14897
+ writeFileSync23(file, plan.prompt, { mode: 384 });
14813
14898
  await this.os(["sandbox", "upload", name, file, SANDBOX_PROMPT_PATH]);
14814
14899
  } finally {
14815
14900
  rmSync17(tmp, { recursive: true, force: true });
@@ -15030,7 +15115,7 @@ function streamShowsAllowanceRefusal(streamPath) {
15030
15115
  }
15031
15116
  return false;
15032
15117
  }
15033
- var digestPathFor = (stateDir, routeLabel2, role, runId) => join34(stateDir, `digest-${routeLabel2}-${role}${runId ? `-${runId}` : ""}.md`);
15118
+ var digestPathFor = (stateDir, routeLabel2, role, runId) => join35(stateDir, `digest-${routeLabel2}-${role}${runId ? `-${runId}` : ""}.md`);
15034
15119
  function codeBridgeFor(o, harness) {
15035
15120
  if (!o.ticket) return void 0;
15036
15121
  const number = /(\d+)$/.exec(o.ticket)?.[1];
@@ -15071,20 +15156,20 @@ function codeBridgeFor(o, harness) {
15071
15156
  bridge.settingsFile = `${SANDBOX_INTEL_DIR}/gemini-settings.json`;
15072
15157
  bridge.files = [{ path: bridge.settingsFile, content: text2 }];
15073
15158
  } else {
15074
- const file = join34(intelDir(o.stateDir, o.route.route, number), "gemini-settings.json");
15075
- mkdirSync22(dirname17(file), { recursive: true });
15076
- writeFileSync23(file, text2);
15159
+ const file = join35(intelDir(o.stateDir, o.route.route, number), "gemini-settings.json");
15160
+ mkdirSync23(dirname17(file), { recursive: true });
15161
+ writeFileSync24(file, text2);
15077
15162
  bridge.settingsFile = file;
15078
15163
  }
15079
15164
  }
15080
15165
  return bridge;
15081
15166
  }
15082
15167
  function planAgentRun(o) {
15083
- const briefPath = join34(o.route.promptsDir, "personas", `lane-${o.role}.md`);
15168
+ const briefPath = join35(o.route.promptsDir, "personas", `lane-${o.role}.md`);
15084
15169
  if (!existsSync29(briefPath)) {
15085
15170
  throw new AgentError(`no brief at ${briefPath} \u2014 refusing to run an unscoped session`);
15086
15171
  }
15087
- const commonPath = join34(o.route.promptsDir, "personas", "common.md");
15172
+ const commonPath = join35(o.route.promptsDir, "personas", "common.md");
15088
15173
  const usesCommon = !SELF_CONTAINED_ROLES.has(o.role) && existsSync29(commonPath);
15089
15174
  const now = o.now ?? (() => Date.now());
15090
15175
  const routeLabel2 = routeSlug(o.route.route);
@@ -15120,7 +15205,7 @@ function planAgentRun(o) {
15120
15205
  digest
15121
15206
  });
15122
15207
  const promptSha = createHash7("sha256").update(expanded.text).digest("hex");
15123
- const streamsDir = join34(o.stateDir, "streams");
15208
+ const streamsDir = join35(o.stateDir, "streams");
15124
15209
  const base = `${routeLabel2}-${o.role}-${o.cycle}${o.runId ? `-${o.runId}` : ""}`;
15125
15210
  const seat = resolveSeat(o.ship, o.route, o.role, o.agentPersona ?? (o.agentModel ? { model: o.agentModel } : {}), o.repo);
15126
15211
  const { model } = seat;
@@ -15231,8 +15316,8 @@ function planAgentRun(o) {
15231
15316
  digestAttached: digest !== void 0,
15232
15317
  digestAgeSeconds: ageSeconds,
15233
15318
  model,
15234
- streamPath: join34(streamsDir, `${base}.jsonl`),
15235
- eventsPath: join34(streamsDir, `${base}.events.jsonl`),
15319
+ streamPath: join35(streamsDir, `${base}.jsonl`),
15320
+ eventsPath: join35(streamsDir, `${base}.events.jsonl`),
15236
15321
  ticket: o.ticket,
15237
15322
  ticketRecordId: o.ticketRecordId ?? null,
15238
15323
  repo: o.repo ?? null,
@@ -15265,7 +15350,7 @@ function updateSidecar(streamPath, patch2) {
15265
15350
  const sc = readRunSidecar(streamPath);
15266
15351
  if (!sc) return;
15267
15352
  try {
15268
- writeFileSync23(pidPathFor(streamPath), JSON.stringify({ ...sc, ...patch2 }));
15353
+ writeFileSync24(pidPathFor(streamPath), JSON.stringify({ ...sc, ...patch2 }));
15269
15354
  } catch {
15270
15355
  }
15271
15356
  }
@@ -15320,7 +15405,7 @@ async function killForDeadline(kill, pid, emit, role, ticket, spawnedAt, limitMi
15320
15405
  var withoutKey = ({ apiKey: _apiKey, ...rest }) => rest;
15321
15406
  function openSink(path) {
15322
15407
  try {
15323
- mkdirSync22(dirname17(path), { recursive: true });
15408
+ mkdirSync23(dirname17(path), { recursive: true });
15324
15409
  return createWriteStream(path, { flags: "a" });
15325
15410
  } catch {
15326
15411
  return void 0;
@@ -15521,7 +15606,7 @@ var RunObserver = class {
15521
15606
  };
15522
15607
  function writeRunMeta(id, startedAt, liveTicket, extra) {
15523
15608
  try {
15524
- writeFileSync23(`${id.streamPath}.meta.json`, JSON.stringify({
15609
+ writeFileSync24(`${id.streamPath}.meta.json`, JSON.stringify({
15525
15610
  route: id.route,
15526
15611
  role: id.role,
15527
15612
  hint: id.ticket,
@@ -15759,7 +15844,7 @@ function spawnPlanned(plan, emit, hintMoved) {
15759
15844
  const id = identityOf(plan, adapter.harness);
15760
15845
  let streamFd;
15761
15846
  try {
15762
- mkdirSync22(dirname17(plan.streamPath), { recursive: true });
15847
+ mkdirSync23(dirname17(plan.streamPath), { recursive: true });
15763
15848
  streamFd = openSync4(plan.streamPath, "a");
15764
15849
  } catch (e) {
15765
15850
  void endSink(eventsSink);
@@ -15819,7 +15904,7 @@ function spawnPlanned(plan, emit, hintMoved) {
15819
15904
  ...streamsInput(plan) && !promptDelivered && adapter.userMessageLine ? { acceptsInput: true } : {}
15820
15905
  };
15821
15906
  try {
15822
- writeFileSync23(pidPathFor(plan.streamPath), JSON.stringify(sidecar));
15907
+ writeFileSync24(pidPathFor(plan.streamPath), JSON.stringify(sidecar));
15823
15908
  } catch {
15824
15909
  }
15825
15910
  }
@@ -16024,13 +16109,13 @@ function runFinished(streamPath) {
16024
16109
  }
16025
16110
  }
16026
16111
  function orphanedStreams(o) {
16027
- const dir = join35(o.stateDir, "streams");
16112
+ const dir = join36(o.stateDir, "streams");
16028
16113
  if (!existsSync30(dir)) return [];
16029
16114
  const ownerAlive = o.isOwnerAlive ?? pidAlive;
16030
16115
  const out = [];
16031
16116
  for (const name of readdirSync10(dir)) {
16032
16117
  if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
16033
- const streamPath = join35(dir, name);
16118
+ const streamPath = join36(dir, name);
16034
16119
  if (runFinished(streamPath)) continue;
16035
16120
  const sidecar = readRunSidecar(streamPath);
16036
16121
  if (!sidecar || sidecar.route !== o.routeLabel) continue;
@@ -16084,11 +16169,11 @@ async function reconcileRuns(o) {
16084
16169
 
16085
16170
  // src/live-runs.ts
16086
16171
  import { existsSync as existsSync32, readdirSync as readdirSync12, statSync as statSync11 } from "fs";
16087
- import { join as join37 } from "path";
16172
+ import { join as join38 } from "path";
16088
16173
 
16089
16174
  // src/run-snapshot.ts
16090
- import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync33, writeFileSync as writeFileSync24, renameSync as renameSync6 } from "fs";
16091
- import { join as join36 } from "path";
16175
+ import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync33, writeFileSync as writeFileSync25, renameSync as renameSync6 } from "fs";
16176
+ import { join as join37 } from "path";
16092
16177
  var TAIL_BYTES = 256 * 1024;
16093
16178
  var EXCERPT_CHARS = 280;
16094
16179
  function endsWithQuestion(text2) {
@@ -16142,12 +16227,12 @@ function outcomeOf(m) {
16142
16227
  return m.exitCode === void 0 || m.exitCode === null || m.exitCode === 0 ? "ok" : "failed";
16143
16228
  }
16144
16229
  function lastRunsBySeat(stateDir) {
16145
- const dir = join36(stateDir, "streams");
16230
+ const dir = join37(stateDir, "streams");
16146
16231
  const out = /* @__PURE__ */ new Map();
16147
16232
  if (!existsSync31(dir)) return out;
16148
16233
  for (const name of readdirSync11(dir)) {
16149
16234
  if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
16150
- const streamPath = join36(dir, name);
16235
+ const streamPath = join37(dir, name);
16151
16236
  if (!runFinished(streamPath)) continue;
16152
16237
  const metaPath = `${streamPath}.meta.json`;
16153
16238
  let meta;
@@ -16188,7 +16273,7 @@ function appendRunNote(streamPath, note) {
16188
16273
  try {
16189
16274
  const path = notesPathFor(streamPath);
16190
16275
  const tmp = `${path}.${process.pid}.tmp`;
16191
- writeFileSync24(tmp, JSON.stringify([...readRunNotes(streamPath), note]));
16276
+ writeFileSync25(tmp, JSON.stringify([...readRunNotes(streamPath), note]));
16192
16277
  renameSync6(tmp, path);
16193
16278
  } catch {
16194
16279
  }
@@ -16196,12 +16281,12 @@ function appendRunNote(streamPath, note) {
16196
16281
 
16197
16282
  // src/live-runs.ts
16198
16283
  function liveRuns(stateDir, isAlive = runIsAlive) {
16199
- const dir = join37(stateDir, "streams");
16284
+ const dir = join38(stateDir, "streams");
16200
16285
  if (!existsSync32(dir)) return [];
16201
16286
  const out = [];
16202
16287
  for (const name of readdirSync12(dir)) {
16203
16288
  if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
16204
- const streamPath = join37(dir, name);
16289
+ const streamPath = join38(dir, name);
16205
16290
  if (runFinished(streamPath)) continue;
16206
16291
  const sidecar = readRunSidecar(streamPath);
16207
16292
  if (!sidecar || !isAlive(sidecar)) continue;
@@ -16211,12 +16296,12 @@ function liveRuns(stateDir, isAlive = runIsAlive) {
16211
16296
  }
16212
16297
  function runActivity(stateDir, isAlive = runIsAlive) {
16213
16298
  const activeRuns = liveRuns(stateDir, isAlive).length;
16214
- const dir = join37(stateDir, "streams");
16299
+ const dir = join38(stateDir, "streams");
16215
16300
  let newest = 0;
16216
16301
  if (existsSync32(dir)) {
16217
16302
  for (const name of readdirSync12(dir)) {
16218
16303
  if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
16219
- const streamPath = join37(dir, name);
16304
+ const streamPath = join38(dir, name);
16220
16305
  if (!runFinished(streamPath)) continue;
16221
16306
  try {
16222
16307
  newest = Math.max(newest, statSync11(`${streamPath}.meta.json`).mtimeMs);
@@ -17248,9 +17333,9 @@ function managedGitIdentityWarnings(kind, identity) {
17248
17333
 
17249
17334
  // src/selftest.ts
17250
17335
  import { spawn as spawn7 } from "child_process";
17251
- import { existsSync as existsSync34, mkdirSync as mkdirSync23, mkdtempSync as mkdtempSync2, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync25 } from "fs";
17252
- import { tmpdir as tmpdir5 } from "os";
17253
- import { join as join38 } from "path";
17336
+ import { existsSync as existsSync34, mkdirSync as mkdirSync24, mkdtempSync as mkdtempSync2, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync26 } from "fs";
17337
+ import { tmpdir as tmpdir6 } from "os";
17338
+ import { join as join39 } from "path";
17254
17339
  var SELFTEST_TIMEOUT_MS = 12e4;
17255
17340
  var KEY_VAR = "CREW_API_KEY";
17256
17341
  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: ";
@@ -17416,7 +17501,7 @@ async function runSelftest(i, deps = realDeps) {
17416
17501
  ...adapter.runEnv(spec),
17417
17502
  [KEY_VAR]: i.apiKey
17418
17503
  };
17419
- const cwd = mkdtempSync2(join38(tmpdir5(), "crew-selftest-"));
17504
+ const cwd = mkdtempSync2(join39(tmpdir6(), "crew-selftest-"));
17420
17505
  try {
17421
17506
  const run4 = await deps.run({
17422
17507
  bin: invocation.bin,
@@ -17449,7 +17534,7 @@ function formatResult(r) {
17449
17534
  const secs = `${(r.ms / 1e3).toFixed(1)}s`;
17450
17535
  return r.ok ? `${r.toolchain}: PASS ${r.detail} (${secs}${tok})` : `${r.toolchain}: FAIL ${r.failure} \u2014 ${r.detail} (${secs})`;
17451
17536
  }
17452
- var fileFor3 = (stateDir) => join38(stateDir, "selftest.json");
17537
+ var fileFor3 = (stateDir) => join39(stateDir, "selftest.json");
17453
17538
  function readSelftest(stateDir) {
17454
17539
  try {
17455
17540
  const p = fileFor3(stateDir);
@@ -17461,8 +17546,8 @@ function readSelftest(stateDir) {
17461
17546
  function recordSelftest(stateDir, results) {
17462
17547
  const all = readSelftest(stateDir);
17463
17548
  for (const r of results) all[r.toolchain] = r;
17464
- mkdirSync23(stateDir, { recursive: true });
17465
- writeFileSync25(fileFor3(stateDir), `${JSON.stringify(all, null, 2)}
17549
+ mkdirSync24(stateDir, { recursive: true });
17550
+ writeFileSync26(fileFor3(stateDir), `${JSON.stringify(all, null, 2)}
17466
17551
  `);
17467
17552
  }
17468
17553
  function doctorSelftestLines(stored, toolchains) {
@@ -17524,7 +17609,7 @@ async function runSelfLaunchCheck(own, spawnFn = spawnChild, launch = selfLaunch
17524
17609
  }
17525
17610
 
17526
17611
  // src/cli.ts
17527
- import { resolve as resolve7, dirname as dirname38, join as join66, basename as basename17 } from "path";
17612
+ import { resolve as resolve7, dirname as dirname38, join as join67, basename as basename17 } from "path";
17528
17613
  import { fileURLToPath as fileURLToPath2 } from "url";
17529
17614
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
17530
17615
  import { spawnSync as spawnSync14 } from "child_process";
@@ -17747,10 +17832,10 @@ function rosterMarkdown(roster, meId) {
17747
17832
  }
17748
17833
 
17749
17834
  // src/connect-resume.ts
17750
- import { mkdirSync as mkdirSync24, readFileSync as readFileSync35, rmSync as rmSync19, writeFileSync as writeFileSync26 } from "fs";
17751
- import { dirname as dirname18, join as join39 } from "path";
17835
+ import { mkdirSync as mkdirSync25, readFileSync as readFileSync35, rmSync as rmSync19, writeFileSync as writeFileSync27 } from "fs";
17836
+ import { dirname as dirname18, join as join40 } from "path";
17752
17837
  function lastSessionFile(stateDir) {
17753
- return join39(stateDir, "connect-session.json");
17838
+ return join40(stateDir, "connect-session.json");
17754
17839
  }
17755
17840
  function readPointers(stateDir) {
17756
17841
  try {
@@ -17768,8 +17853,8 @@ function readPointers(stateDir) {
17768
17853
  }
17769
17854
  function writePointers(stateDir, pointers) {
17770
17855
  const file = lastSessionFile(stateDir);
17771
- mkdirSync24(dirname18(file), { recursive: true });
17772
- writeFileSync26(file, `${JSON.stringify(pointers, null, 2)}
17856
+ mkdirSync25(dirname18(file), { recursive: true });
17857
+ writeFileSync27(file, `${JSON.stringify(pointers, null, 2)}
17773
17858
  `, { mode: 384 });
17774
17859
  }
17775
17860
  function rememberSession(stateDir, host, workspaceSlug) {
@@ -17854,11 +17939,11 @@ async function signOutSessions(o) {
17854
17939
  }
17855
17940
 
17856
17941
  // src/reset.ts
17857
- import { existsSync as existsSync35, mkdirSync as mkdirSync25, readFileSync as readFileSync36, readdirSync as readdirSync14, rmSync as rmSync20, statSync as statSync12, writeFileSync as writeFileSync27 } from "fs";
17858
- import { dirname as dirname19, join as join40 } from "path";
17942
+ import { existsSync as existsSync35, mkdirSync as mkdirSync26, readFileSync as readFileSync36, readdirSync as readdirSync14, rmSync as rmSync20, statSync as statSync12, writeFileSync as writeFileSync28 } from "fs";
17943
+ import { dirname as dirname19, join as join41 } from "path";
17859
17944
  import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
17860
17945
  function clonedCheckoutsFile(stateDir) {
17861
- return join40(stateDir, "cloned-checkouts.json");
17946
+ return join41(stateDir, "cloned-checkouts.json");
17862
17947
  }
17863
17948
  function readClonedCheckouts(stateDir) {
17864
17949
  try {
@@ -17872,8 +17957,8 @@ function recordClonedCheckout(stateDir, dir) {
17872
17957
  const known = readClonedCheckouts(stateDir);
17873
17958
  if (known.includes(dir)) return;
17874
17959
  const file = clonedCheckoutsFile(stateDir);
17875
- mkdirSync25(dirname19(file), { recursive: true });
17876
- writeFileSync27(file, `${JSON.stringify([...known, dir], null, 2)}
17960
+ mkdirSync26(dirname19(file), { recursive: true });
17961
+ writeFileSync28(file, `${JSON.stringify([...known, dir], null, 2)}
17877
17962
  `);
17878
17963
  }
17879
17964
  var mark = (dryRun) => dryRun ? "would-remove" : "removed";
@@ -17949,10 +18034,10 @@ function removeCheckout(dir, dryRun, fx) {
17949
18034
  }
17950
18035
  function removeState(stateDir, dryRun) {
17951
18036
  const out = [];
17952
- const targets = [join40(stateDir, "resolved"), join40(stateDir, "keys"), clonedCheckoutsFile(stateDir), join40(stateDir, "connect-session.json"), join40(stateDir, "reload-requested"), join40(stateDir, "daemon.started")];
18037
+ const targets = [join41(stateDir, "resolved"), join41(stateDir, "keys"), clonedCheckoutsFile(stateDir), join41(stateDir, "connect-session.json"), join41(stateDir, "reload-requested"), join41(stateDir, "daemon.started")];
17953
18038
  try {
17954
18039
  for (const name of readdirSync14(stateDir)) {
17955
- if (name.startsWith(".") && statSync12(join40(stateDir, name)).isFile()) targets.push(join40(stateDir, name));
18040
+ if (name.startsWith(".") && statSync12(join41(stateDir, name)).isFile()) targets.push(join41(stateDir, name));
17956
18041
  }
17957
18042
  } catch {
17958
18043
  }
@@ -17972,7 +18057,7 @@ function wipeStateDir(stateDir, dryRun) {
17972
18057
  return [{ step: "state", target: stateDir, action: "absent", detail: "no state directory" }];
17973
18058
  }
17974
18059
  if (!names.length) return [{ step: "state", target: stateDir, action: "absent", detail: "already empty" }];
17975
- if (!dryRun) for (const n of names) rmSync20(join40(stateDir, n), { recursive: true, force: true });
18060
+ if (!dryRun) for (const n of names) rmSync20(join41(stateDir, n), { recursive: true, force: true });
17976
18061
  return [{ step: "state", target: stateDir, action: mark(dryRun), detail: `${names.length} entr${names.length === 1 ? "y" : "ies"}` }];
17977
18062
  }
17978
18063
  function describeResetStep(s) {
@@ -18054,9 +18139,9 @@ async function runDeprovision(o, fx, deps) {
18054
18139
  }
18055
18140
 
18056
18141
  // src/pool-member.ts
18057
- import { mkdirSync as mkdirSync26, readFileSync as readFileSync37, renameSync as renameSync7, writeFileSync as writeFileSync28 } from "fs";
18142
+ import { mkdirSync as mkdirSync27, readFileSync as readFileSync37, renameSync as renameSync7, writeFileSync as writeFileSync29 } from "fs";
18058
18143
  import { homedir as homedir8 } from "os";
18059
- import { dirname as dirname20, join as join41 } from "path";
18144
+ import { dirname as dirname20, join as join42 } from "path";
18060
18145
  var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
18061
18146
  function backoffMs(attempt) {
18062
18147
  return Math.min(6e4, 5e3 * 2 ** Math.max(0, attempt));
@@ -18298,10 +18383,10 @@ async function runPoolMember(deps) {
18298
18383
  }
18299
18384
  }
18300
18385
  function defaultMemberDir(env = process.env) {
18301
- return env.CREW_POOL_DIR ?? join41(env.XDG_STATE_HOME ?? join41(homedir8(), ".local", "state"), "crew-pool-member");
18386
+ return env.CREW_POOL_DIR ?? join42(env.XDG_STATE_HOME ?? join42(homedir8(), ".local", "state"), "crew-pool-member");
18302
18387
  }
18303
18388
  function fileMemberStore(dir) {
18304
- const file = join41(dir, "member.json");
18389
+ const file = join42(dir, "member.json");
18305
18390
  return {
18306
18391
  read() {
18307
18392
  try {
@@ -18311,9 +18396,9 @@ function fileMemberStore(dir) {
18311
18396
  }
18312
18397
  },
18313
18398
  write(f2) {
18314
- mkdirSync26(dirname20(file), { recursive: true, mode: 448 });
18399
+ mkdirSync27(dirname20(file), { recursive: true, mode: 448 });
18315
18400
  const tmp = `${file}.tmp`;
18316
- writeFileSync28(tmp, `${JSON.stringify(f2)}
18401
+ writeFileSync29(tmp, `${JSON.stringify(f2)}
18317
18402
  `, { mode: 384 });
18318
18403
  renameSync7(tmp, file);
18319
18404
  }
@@ -18371,10 +18456,10 @@ import { hostname as hostname3 } from "os";
18371
18456
  // src/machine-id.ts
18372
18457
  import { execFileSync as execFileSync12 } from "child_process";
18373
18458
  import { createHash as createHash9 } from "crypto";
18374
- import { existsSync as existsSync36, mkdirSync as mkdirSync27, readFileSync as readFileSync38, writeFileSync as writeFileSync29 } from "fs";
18375
- import { dirname as dirname21, join as join42 } from "path";
18459
+ import { existsSync as existsSync36, mkdirSync as mkdirSync28, readFileSync as readFileSync38, writeFileSync as writeFileSync30 } from "fs";
18460
+ import { dirname as dirname21, join as join43 } from "path";
18376
18461
  function machineIdPathFor(stateDir) {
18377
- return join42(stateDir, "machine-id");
18462
+ return join43(stateDir, "machine-id");
18378
18463
  }
18379
18464
  var sha256 = (s) => createHash9("sha256").update(s).digest("hex");
18380
18465
  function readRawMachineId(platform2 = process.platform) {
@@ -18406,8 +18491,8 @@ function ensureMachineId(stateDir, opts = {}) {
18406
18491
  const raw = (opts.read ?? readRawMachineId)();
18407
18492
  if (!raw) return void 0;
18408
18493
  const hashed = sha256(raw);
18409
- mkdirSync27(dirname21(path), { recursive: true });
18410
- writeFileSync29(path, `${hashed}
18494
+ mkdirSync28(dirname21(path), { recursive: true });
18495
+ writeFileSync30(path, `${hashed}
18411
18496
  `, { mode: 384 });
18412
18497
  return hashed;
18413
18498
  }
@@ -18420,7 +18505,7 @@ function matchShipRows(ships, shipName2, machineId) {
18420
18505
 
18421
18506
  // src/provision.ts
18422
18507
  import { spawnSync as spawnSync9 } from "child_process";
18423
- import { existsSync as existsSync37, readFileSync as readFileSync39, writeFileSync as writeFileSync30 } from "fs";
18508
+ import { existsSync as existsSync37, readFileSync as readFileSync39, writeFileSync as writeFileSync31 } from "fs";
18424
18509
  import { hostname as hostname2 } from "os";
18425
18510
  import { parseDocument as parseDocument3, isMap as isMap2, isScalar } from "yaml";
18426
18511
 
@@ -18429,7 +18514,7 @@ import { parseDocument as parseDocument2 } from "yaml";
18429
18514
 
18430
18515
  // src/repos-cmd.ts
18431
18516
  import { homedir as homedir9 } from "os";
18432
- import { basename as basename10, join as join43, resolve as resolve4 } from "path";
18517
+ import { basename as basename10, join as join44, resolve as resolve4 } from "path";
18433
18518
  import { isMap, isSeq, parseDocument, stringify as stringify2 } from "yaml";
18434
18519
  var ReposError = class extends Error {
18435
18520
  /** A stable reason for a `--json` reader, when the failure has one (CREW-3359). */
@@ -18720,7 +18805,7 @@ function planRepoClone(i) {
18720
18805
  }
18721
18806
  const ship = doc.get("ship", true);
18722
18807
  const basePath = String(m.get("reposBasePath") ?? (isMap(ship) ? ship.get("reposBasePath") : void 0) ?? "~/Crew");
18723
- const target = i.dir ? expandDir(i.dir, i.base) : join43(expandDir(basePath, i.base), i.route.split("/")[0], name);
18808
+ const target = i.dir ? expandDir(i.dir, i.base) : join44(expandDir(basePath, i.base), i.route.split("/")[0], name);
18724
18809
  const add = planRepoAdd({ text: i.text, base: i.base, route: i.route, path: target, origin: remote, resolved: i.resolved, name, isCheckout: i.isCheckout });
18725
18810
  const forgeHost = i.resolved?.repoForgeHosts?.[id];
18726
18811
  return { ...add, remote, target, ...forgeHost ? { forgeHost } : {} };
@@ -19072,7 +19157,7 @@ function realProvisionDeps(crewHome) {
19072
19157
  const entry = routes?.items?.find((r) => r.get("route") === route2);
19073
19158
  if (!entry) throw new Error(`route ${route2} is not in ${file}`);
19074
19159
  if (entry.get("enabled") === true) return false;
19075
- writeFileSync30(file, planEnable(text2, route2));
19160
+ writeFileSync31(file, planEnable(text2, route2));
19076
19161
  return true;
19077
19162
  },
19078
19163
  installState() {
@@ -19119,7 +19204,7 @@ function realProvisionDeps(crewHome) {
19119
19204
  const doc = parseDocument3(readFileSync39(file, "utf8"));
19120
19205
  if (doc.getIn(["ship", key]) === value2) return false;
19121
19206
  doc.setIn(["ship", key], value2);
19122
- writeFileSync30(file, doc.toString());
19207
+ writeFileSync31(file, doc.toString());
19123
19208
  return true;
19124
19209
  },
19125
19210
  applyManagedDefaults() {
@@ -19127,7 +19212,7 @@ function realProvisionDeps(crewHome) {
19127
19212
  if (!file) return [];
19128
19213
  const doc = parseDocument3(readFileSync39(file, "utf8"));
19129
19214
  const wrote = applyManagedDefaultsToDoc(doc);
19130
- if (wrote.length) writeFileSync30(file, doc.toString());
19215
+ if (wrote.length) writeFileSync31(file, doc.toString());
19131
19216
  return wrote;
19132
19217
  },
19133
19218
  ensureGitIdentity(name, email) {
@@ -20442,8 +20527,8 @@ function diskFullStop(state) {
20442
20527
  }
20443
20528
 
20444
20529
  // src/poll.ts
20445
- import { writeFileSync as writeFileSync31 } from "fs";
20446
- import { join as join44 } from "path";
20530
+ import { writeFileSync as writeFileSync32 } from "fs";
20531
+ import { join as join45 } from "path";
20447
20532
 
20448
20533
  // src/stalled.ts
20449
20534
  var STALLED_AFTER_CYCLES = 30;
@@ -20776,7 +20861,7 @@ async function decideCycle(o) {
20776
20861
  }
20777
20862
  return decision;
20778
20863
  }
20779
- var digestPath = (stateDir, route2, role, runId) => join44(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
20864
+ var digestPath = (stateDir, route2, role, runId) => join45(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
20780
20865
  function otherRunsRemoved(tickets, own) {
20781
20866
  if (!own) return tickets;
20782
20867
  return tickets.filter((t) => t.id === own.ticket.id || !own.inFlight(t.id));
@@ -20869,7 +20954,7 @@ ${footprintDigestSection(recorded)}`;
20869
20954
 
20870
20955
  ${body}` : body;
20871
20956
  const path = digestPath(stateDir, routeSlug(o.route.route), role, runId);
20872
- writeFileSync31(path, text2);
20957
+ writeFileSync32(path, text2);
20873
20958
  o.emit.note(`queue digest written for ${role} (${Buffer.byteLength(text2)} bytes)`, {
20874
20959
  data: { role, bytes: Buffer.byteLength(text2) }
20875
20960
  });
@@ -21044,7 +21129,7 @@ async function markCrewAssistedAtLaunch(tracker, route2, role, ticketId, ticket,
21044
21129
  }
21045
21130
 
21046
21131
  // src/repo-refresh.ts
21047
- import { existsSync as existsSync40, mkdirSync as mkdirSync28, readFileSync as readFileSync40, writeFileSync as writeFileSync32 } from "fs";
21132
+ import { existsSync as existsSync40, mkdirSync as mkdirSync29, readFileSync as readFileSync40, writeFileSync as writeFileSync33 } from "fs";
21048
21133
  import { dirname as dirname23 } from "path";
21049
21134
  var REFRESH_COOLDOWN_MS = 2 * 6e4;
21050
21135
  var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
@@ -21077,8 +21162,8 @@ function persistRepoRows(stateDir, routeName, rows) {
21077
21162
  if (!existsSync40(path)) return;
21078
21163
  const raw = JSON.parse(readFileSync40(path, "utf8"));
21079
21164
  applyRepoRows(raw, rows);
21080
- mkdirSync28(dirname23(path), { recursive: true });
21081
- writeFileSync32(path, `${JSON.stringify(raw, null, 2)}
21165
+ mkdirSync29(dirname23(path), { recursive: true });
21166
+ writeFileSync33(path, `${JSON.stringify(raw, null, 2)}
21082
21167
  `);
21083
21168
  }
21084
21169
  async function refreshUnknownRepos(o) {
@@ -21340,7 +21425,7 @@ Ship ${shipName2} found: ${problem}. The release refuses to squash a ref nobody
21340
21425
  var localRefSkipReported = (ticket, problem, events) => events.some((e) => e.record_id === ticket.id && e.event_type === "local_ref_skip" && (e.message ?? "").includes(problem));
21341
21426
 
21342
21427
  // src/platform-gate.ts
21343
- import { join as join45 } from "path";
21428
+ import { join as join46 } from "path";
21344
21429
  function platformAdmitters(dir, baseRef, ship, tickets, locate) {
21345
21430
  const out = [];
21346
21431
  for (const t of tickets) {
@@ -21352,7 +21437,7 @@ function platformAdmitters(dir, baseRef, ship, tickets, locate) {
21352
21437
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
21353
21438
  if (text2 === null) continue;
21354
21439
  try {
21355
- const { platform: platform2 } = parseRepoConfig(text2, join45(dir, file));
21440
+ const { platform: platform2 } = parseRepoConfig(text2, join46(dir, file));
21356
21441
  if (satisfies(ship, platform2)) out.push({ issueId: t.issue_id, tag: displayKey(t), branch, platform: platform2 });
21357
21442
  } catch (e) {
21358
21443
  if (e instanceof RepoConfigError) continue;
@@ -21368,8 +21453,8 @@ function platformStuckNote(repo, required, ship, issueIds) {
21368
21453
  }
21369
21454
 
21370
21455
  // src/connect-wizard.ts
21371
- import { delimiter, dirname as dirname24, join as join46 } from "path";
21372
- import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync29, writeFileSync as writeFileSync33 } from "fs";
21456
+ import { delimiter, dirname as dirname24, join as join47 } from "path";
21457
+ import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync30, writeFileSync as writeFileSync34 } from "fs";
21373
21458
  import { stringify as stringify3 } from "yaml";
21374
21459
  var HOST_PASSENGERS_DOCS_URL = "https://crew.tablation.dev/host-passengers";
21375
21460
  function shouldRunWizard(opts) {
@@ -21391,7 +21476,7 @@ function defaultIsExecutable(p) {
21391
21476
  function findOnPath2(name, pathEnv, isExecutable = defaultIsExecutable) {
21392
21477
  for (const dir of pathEnv.split(delimiter)) {
21393
21478
  if (!dir) continue;
21394
- const candidate = join46(dir, name);
21479
+ const candidate = join47(dir, name);
21395
21480
  if (isExecutable(candidate)) return candidate;
21396
21481
  }
21397
21482
  return void 0;
@@ -21452,9 +21537,9 @@ routes:
21452
21537
  ${routeBlock}`;
21453
21538
  }
21454
21539
  function writeNewConfig(path, text2) {
21455
- mkdirSync29(dirname24(path), { recursive: true });
21540
+ mkdirSync30(dirname24(path), { recursive: true });
21456
21541
  try {
21457
- writeFileSync33(path, text2, { mode: 384, flag: "wx" });
21542
+ writeFileSync34(path, text2, { mode: 384, flag: "wx" });
21458
21543
  return true;
21459
21544
  } catch (e) {
21460
21545
  if (e.code === "EEXIST") return false;
@@ -21488,7 +21573,7 @@ Wrote ${o.configPath}.
21488
21573
  // src/connect-json.ts
21489
21574
  import { accessSync as accessSync4, constants as constants4 } from "fs";
21490
21575
  import { homedir as homedir10 } from "os";
21491
- import { dirname as dirname25, join as join47 } from "path";
21576
+ import { dirname as dirname25, join as join48 } from "path";
21492
21577
  import { delimiter as delimiter2 } from "path";
21493
21578
  var CHOICE_EXIT_CODE = 3;
21494
21579
  function createEmitter(json2, write) {
@@ -21527,12 +21612,12 @@ function agentBinSearchDirs(home, pathEnv, extraPath) {
21527
21612
  const dirs = [
21528
21613
  ...pathEnv.split(delimiter2),
21529
21614
  ...(extraPath ?? "").split(delimiter2),
21530
- join47(home, ".local/bin"),
21531
- join47(home, ".claude/local"),
21615
+ join48(home, ".local/bin"),
21616
+ join48(home, ".claude/local"),
21532
21617
  "/opt/homebrew/bin",
21533
21618
  "/usr/local/bin",
21534
- join47(home, ".npm-global/bin"),
21535
- join47(home, ".volta/bin")
21619
+ join48(home, ".npm-global/bin"),
21620
+ join48(home, ".volta/bin")
21536
21621
  ];
21537
21622
  return [...new Set(dirs.filter(Boolean))];
21538
21623
  }
@@ -21653,9 +21738,9 @@ async function collectDiagnostics(d) {
21653
21738
  }
21654
21739
 
21655
21740
  // src/release-run.ts
21656
- import { readFileSync as readFileSync41, writeFileSync as writeFileSync34, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync30, mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "fs";
21657
- import { dirname as dirname26, join as join48 } from "path";
21658
- import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
21741
+ import { readFileSync as readFileSync41, writeFileSync as writeFileSync35, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync31, mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "fs";
21742
+ import { dirname as dirname26, join as join49 } from "path";
21743
+ import { tmpdir as tmpdir7, hostname as hostname4 } from "os";
21659
21744
 
21660
21745
  // src/release.ts
21661
21746
  function describeUnplaceable(unplaceable, verifiedStatus) {
@@ -22606,7 +22691,7 @@ async function bump(o, size) {
22606
22691
  }
22607
22692
  return printed;
22608
22693
  }
22609
- const files = o.repo.release.versionFiles.map((f2) => join48(o.cwd, f2));
22694
+ const files = o.repo.release.versionFiles.map((f2) => join49(o.cwd, f2));
22610
22695
  const first = files[0];
22611
22696
  if (!existsAt(first, existsSync42)) {
22612
22697
  o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
@@ -22637,21 +22722,21 @@ async function bump(o, size) {
22637
22722
  o.emit.error(`no version field in ${f2}`);
22638
22723
  return null;
22639
22724
  }
22640
- writeTextAt(f2, out, writeFileSync34);
22725
+ writeTextAt(f2, out, writeFileSync35);
22641
22726
  }
22642
22727
  return version;
22643
22728
  }
22644
22729
  function writeChangelog(o, version, entries) {
22645
22730
  const file = o.repo.release.changelog;
22646
22731
  if (!file || entries.length === 0) return;
22647
- const path = join48(o.cwd, file);
22732
+ const path = join49(o.cwd, file);
22648
22733
  const section = renderChangelogSection(version, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), entries);
22649
22734
  if (o.dryRun) {
22650
22735
  o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
22651
22736
  return;
22652
22737
  }
22653
22738
  const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) => readFileSync41(p, "utf8")) : "# Changelog\n";
22654
- writeTextAt(path, insertChangelogSection(existing, section), writeFileSync34);
22739
+ writeTextAt(path, insertChangelogSection(existing, section), writeFileSync35);
22655
22740
  }
22656
22741
  async function confirm(o, expected, ci) {
22657
22742
  if (!o.repo.hooks.released) return void 0;
@@ -22804,8 +22889,8 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
22804
22889
  function openReleaseCheckout(o) {
22805
22890
  const { remote, base } = o.repo.branch;
22806
22891
  const branch = `crew/release-${Date.now()}`;
22807
- const root = mkdtempSync3(join48(tmpdir6(), "crew-release-"));
22808
- const dir = join48(root, "checkout");
22892
+ const root = mkdtempSync3(join49(tmpdir7(), "crew-release-"));
22893
+ const dir = join49(root, "checkout");
22809
22894
  o.emit.note(`release checkout: ${dir}`, { step: "release" });
22810
22895
  const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
22811
22896
  try {
@@ -22815,10 +22900,10 @@ function openReleaseCheckout(o) {
22815
22900
  throw e;
22816
22901
  }
22817
22902
  for (const f2 of o.repo.worktrees.copy) {
22818
- const src = join48(o.cwd, f2);
22903
+ const src = join49(o.cwd, f2);
22819
22904
  if (!existsSync42(src)) continue;
22820
- mkdirSync30(dirname26(join48(dir, f2)), { recursive: true });
22821
- copyFileSync(src, join48(dir, f2));
22905
+ mkdirSync31(dirname26(join49(dir, f2)), { recursive: true });
22906
+ copyFileSync(src, join49(dir, f2));
22822
22907
  }
22823
22908
  return { dir, branch, close };
22824
22909
  }
@@ -23006,7 +23091,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
23006
23091
  let checkout;
23007
23092
  const stranded = recoverStrandedReleaseCheckouts(o.cwd);
23008
23093
  if (stranded.length > 0) o.emit.warn(scoped(`dropped release checkout(s) stranded by a crash: ${stranded.join(", ")}`));
23009
- const swept = sweepStaleReleaseRoots(tmpdir6());
23094
+ const swept = sweepStaleReleaseRoots(tmpdir7());
23010
23095
  if (swept.length > 0) o.emit.emit(scoped(`removed ${swept.length} stale crew-release-* temp dir(s)`), { step: "release" });
23011
23096
  try {
23012
23097
  checkout = openReleaseCheckout(o);
@@ -23096,11 +23181,11 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23096
23181
  const byFile = culpritByFiles(withFiles, failingPaths(output, o.cwd));
23097
23182
  if (byFile) {
23098
23183
  o.emit.warn(`${name} failed; its output names files only ${byFile.c.branch} changed \u2014 treating it as the culprit`, { ticket: byFile.c.ticket.issue_id });
23099
- culprits.push({ c: byFile.c, how: "files", tail: lastLines(output, HOOK_FAILURE_TAIL_LINES), paths: failingPaths(output, o.cwd) });
23184
+ culprits.push({ c: byFile.c, how: "files", output, paths: failingPaths(output, o.cwd) });
23100
23185
  } else if (applied.length === 1) {
23101
23186
  const only = applied[0];
23102
23187
  o.emit.warn(`${name} failed with only ${only.branch} merged and passes without it \u2014 treating it as the culprit`, { ticket: only.ticket.issue_id });
23103
- culprits.push({ c: only, how: "solo", tail: lastLines(output, HOOK_FAILURE_TAIL_LINES), paths: failingPaths(output, o.cwd) });
23188
+ culprits.push({ c: only, how: "solo", output, paths: failingPaths(output, o.cwd) });
23104
23189
  } else if (applied.length > cap) {
23105
23190
  o.emit.warn(`${name} failed with ${applied.length} branches merged, over release.isolateFailures.maxCandidates (${cap}) \u2014 not isolating`);
23106
23191
  return { tried: `Isolation was skipped: ${applied.length} branches were merged, over release.isolateFailures.maxCandidates (${cap}).` };
@@ -23113,7 +23198,7 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23113
23198
  const r = await hook(o, name);
23114
23199
  if (r && r.code !== 0) {
23115
23200
  o.emit.warn(`${c.branch} fails the ${name} hook on its own`, { ticket: c.ticket.issue_id });
23116
- culprits.push({ c, how: "solo", tail: lastLines(r.output, HOOK_FAILURE_TAIL_LINES), paths: failingPaths(r.output, o.cwd) });
23201
+ culprits.push({ c, how: "solo", output: r.output, paths: failingPaths(r.output, o.cwd) });
23117
23202
  }
23118
23203
  }
23119
23204
  if (culprits.length === 0) {
@@ -23126,13 +23211,13 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23126
23211
  const r = await hook(o, name);
23127
23212
  if (r && r.code !== 0) {
23128
23213
  o.emit.warn(`${applied[j].branch} fails the ${name} hook together with ${applied[i].branch}`, { ticket: applied[j].ticket.issue_id });
23129
- culprits.push({ c: applied[j], how: "pair", sibling: applied[i], tail: lastLines(r.output, HOOK_FAILURE_TAIL_LINES), paths: failingPaths(r.output, o.cwd) });
23214
+ culprits.push({ c: applied[j], how: "pair", sibling: applied[i], output: r.output, paths: failingPaths(r.output, o.cwd) });
23130
23215
  break;
23131
23216
  }
23132
23217
  }
23133
23218
  if (culprits.length === 0 && truncated) {
23134
23219
  let lo = 2, hi = applied.length;
23135
- let tail3 = lastLines(output, HOOK_FAILURE_TAIL_LINES);
23220
+ let tailOut = output;
23136
23221
  let paths = failingPaths(output, o.cwd);
23137
23222
  while (lo < hi) {
23138
23223
  const mid = Math.floor((lo + hi) / 2);
@@ -23148,13 +23233,13 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23148
23233
  const r = clean ? await hook(o, name) : null;
23149
23234
  if (r && r.code !== 0) {
23150
23235
  hi = mid;
23151
- tail3 = lastLines(r.output, HOOK_FAILURE_TAIL_LINES);
23236
+ tailOut = r.output;
23152
23237
  paths = failingPaths(r.output, o.cwd);
23153
23238
  } else lo = mid + 1;
23154
23239
  }
23155
23240
  const owner = applied[hi - 1];
23156
23241
  o.emit.warn(`${owner.branch} is the first branch whose prefix fails the ${name} hook (bisected over ${applied.length})`, { ticket: owner.ticket.issue_id });
23157
- culprits.push({ c: owner, how: "pair", sibling: applied[hi - 2], tail: tail3, paths });
23242
+ culprits.push({ c: owner, how: "pair", sibling: applied[hi - 2], output: tailOut, paths });
23158
23243
  }
23159
23244
  }
23160
23245
  }
@@ -23169,17 +23254,25 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23169
23254
  const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch, true);
23170
23255
  return {
23171
23256
  ...retried,
23172
- buildCulprits: culprits.map((x) => ({
23173
- ticket: x.c.ticket,
23174
- branch: x.c.branch,
23175
- hook: name,
23176
- tail: x.tail,
23177
- how: x.how,
23178
- cwd: o.cwd,
23179
- failingFiles: x.paths,
23180
- inBranch: x.paths.length === 0 ? null : x.paths.some((p) => withFiles.find((w) => w.c === x.c)?.changed.has(p) ?? false),
23181
- ...x.sibling ? { sibling: { key: x.sibling.ticket.issue_tag ?? x.sibling.ticket.issue_id, branch: x.sibling.branch } } : {}
23182
- }))
23257
+ buildCulprits: culprits.map((x) => {
23258
+ const ex = failureExcerpt(x.output, x.paths, HOOK_FAILURE_TAIL_LINES);
23259
+ const tip = gitOk(o.cwd, ["rev-parse", x.c.branch])?.trim();
23260
+ const logPath = saveGateOutput(x.c.ticket.issue_tag ?? x.c.ticket.issue_id, name, x.output);
23261
+ return {
23262
+ ticket: x.c.ticket,
23263
+ branch: x.c.branch,
23264
+ hook: name,
23265
+ tail: ex.text,
23266
+ how: x.how,
23267
+ cwd: o.cwd,
23268
+ pathCentered: ex.pathCentered,
23269
+ ...logPath ? { outputPath: logPath } : {},
23270
+ ...tip ? { tip } : {},
23271
+ failingFiles: x.paths,
23272
+ inBranch: x.paths.length === 0 ? null : x.paths.some((p) => withFiles.find((w) => w.c === x.c)?.changed.has(p) ?? false),
23273
+ ...x.sibling ? { sibling: { key: x.sibling.ticket.issue_tag ?? x.sibling.ticket.issue_id, branch: x.sibling.branch } } : {}
23274
+ };
23275
+ })
23183
23276
  };
23184
23277
  }
23185
23278
  async function mergeAndRelease(o, decision, fresh, releaseBranch, isolated = false) {
@@ -23757,8 +23850,8 @@ import { spawnSync as spawnSync12 } from "child_process";
23757
23850
  import { existsSync as existsSync49, readFileSync as readFileSync47 } from "fs";
23758
23851
 
23759
23852
  // src/daemon.ts
23760
- import { existsSync as existsSync48, mkdirSync as mkdirSync36, readFileSync as readFileSync46, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync38 } from "fs";
23761
- import { join as join53 } from "path";
23853
+ import { existsSync as existsSync48, mkdirSync as mkdirSync37, readFileSync as readFileSync46, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync39 } from "fs";
23854
+ import { join as join54 } from "path";
23762
23855
  import { randomBytes } from "crypto";
23763
23856
 
23764
23857
  // src/map-brief.ts
@@ -24044,12 +24137,12 @@ function nextRoles(decision, ran) {
24044
24137
  }
24045
24138
 
24046
24139
  // src/noop-runs.ts
24047
- import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync35 } from "fs";
24048
- import { join as join49 } from "path";
24140
+ import { existsSync as existsSync43, mkdirSync as mkdirSync32, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync36 } from "fs";
24141
+ import { join as join50 } from "path";
24049
24142
  var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
24050
24143
  var DEFAULT_NOOP_REPEATS = 3;
24051
24144
  var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
24052
- var noopRunsPath = (stateDir) => join49(stateDir, "noop-runs.json");
24145
+ var noopRunsPath = (stateDir) => join50(stateDir, "noop-runs.json");
24053
24146
  var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
24054
24147
  function readNoopRuns(stateDir) {
24055
24148
  try {
@@ -24060,9 +24153,9 @@ function readNoopRuns(stateDir) {
24060
24153
  }
24061
24154
  }
24062
24155
  function writeNoopRuns(stateDir, state) {
24063
- mkdirSync31(stateDir, { recursive: true });
24156
+ mkdirSync32(stateDir, { recursive: true });
24064
24157
  const file = noopRunsPath(stateDir);
24065
- writeFileSync35(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
24158
+ writeFileSync36(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
24066
24159
  `);
24067
24160
  renameSync8(`${file}.tmp`, file);
24068
24161
  }
@@ -24144,7 +24237,7 @@ async function settleNoopRun(o) {
24144
24237
  }
24145
24238
 
24146
24239
  // src/ship-name.ts
24147
- import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync36 } from "fs";
24240
+ import { existsSync as existsSync44, mkdirSync as mkdirSync33, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync37 } from "fs";
24148
24241
  import { dirname as dirname27 } from "path";
24149
24242
  import { parseDocument as parseDocument4 } from "yaml";
24150
24243
  var ShipNameError = class extends Error {
@@ -24224,9 +24317,9 @@ function writeSyncedName(resolvedFile, name) {
24224
24317
  }
24225
24318
  if (raw.shipName === name) return;
24226
24319
  raw.shipName = name;
24227
- mkdirSync32(dirname27(resolvedFile), { recursive: true });
24320
+ mkdirSync33(dirname27(resolvedFile), { recursive: true });
24228
24321
  const tmp = `${resolvedFile}.tmp${process.pid}`;
24229
- writeFileSync36(tmp, `${JSON.stringify(raw, null, 2)}
24322
+ writeFileSync37(tmp, `${JSON.stringify(raw, null, 2)}
24230
24323
  `);
24231
24324
  renameSync9(tmp, resolvedFile);
24232
24325
  }
@@ -24258,7 +24351,7 @@ async function reconcileShipName(i) {
24258
24351
  if (result.status !== "ok") return result;
24259
24352
  if (result.action === "adopt" || result.action === "row-wins") {
24260
24353
  const text2 = readFileSync43(i.configFile, "utf8");
24261
- writeFileSync36(i.configFile, setShipNameInYaml(text2, result.name));
24354
+ writeFileSync37(i.configFile, setShipNameInYaml(text2, result.name));
24262
24355
  i.ship.name = result.name;
24263
24356
  if (result.action === "row-wins") {
24264
24357
  i.emit?.warn(
@@ -24306,7 +24399,7 @@ async function reconcileRouteShipName(o) {
24306
24399
  import { existsSync as existsSync45 } from "fs";
24307
24400
 
24308
24401
  // src/passenger-mirror.ts
24309
- import { mkdirSync as mkdirSync33 } from "fs";
24402
+ import { mkdirSync as mkdirSync34 } from "fs";
24310
24403
  import { dirname as dirname28 } from "path";
24311
24404
  function mirrorRepoOf(spec) {
24312
24405
  const fromOrigin = spec.originUrl ? parseRemote(spec.originUrl) : null;
@@ -24326,8 +24419,8 @@ async function materializeMirrorCheckouts(specs, cacheFor = (s) => new SandboxCa
24326
24419
  }
24327
24420
  try {
24328
24421
  const parent = dirname28(spec.dir);
24329
- mkdirSync33(parent, { recursive: true });
24330
- mkdirSync33(spec.dir, { recursive: true });
24422
+ mkdirSync34(parent, { recursive: true });
24423
+ mkdirSync34(spec.dir, { recursive: true });
24331
24424
  const r = await cacheFor(spec).materialize(repo, spec.base, parent, spec.name);
24332
24425
  out.push({ ...base, action: r.changed ? "updated" : "unchanged", detail: r.tip });
24333
24426
  } catch (e) {
@@ -24479,18 +24572,18 @@ function seatMissingProblems(route2, probes) {
24479
24572
 
24480
24573
  // src/ssh-keys.ts
24481
24574
  import { execFileSync as execFileSync13 } from "child_process";
24482
- import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
24483
- import { dirname as dirname29, join as join50 } from "path";
24575
+ import { existsSync as existsSync46, mkdirSync as mkdirSync35, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
24576
+ import { dirname as dirname29, join as join51 } from "path";
24484
24577
  var SshKeyError = class extends Error {
24485
24578
  };
24486
24579
  function shipSshKeyPathFor(stateDir) {
24487
- return join50(stateDir, "ssh", "id_ed25519");
24580
+ return join51(stateDir, "ssh", "id_ed25519");
24488
24581
  }
24489
24582
  function ensureShipSshKeypair(stateDir) {
24490
24583
  const privateKeyPath = shipSshKeyPathFor(stateDir);
24491
24584
  const publicKeyPath = `${privateKeyPath}.pub`;
24492
24585
  if (!existsSync46(privateKeyPath)) {
24493
- mkdirSync34(dirname29(privateKeyPath), { recursive: true });
24586
+ mkdirSync35(dirname29(privateKeyPath), { recursive: true });
24494
24587
  try {
24495
24588
  execFileSync13("ssh-keygen", [
24496
24589
  "-t",
@@ -24528,7 +24621,7 @@ function sshKeygenAvailable() {
24528
24621
  // src/periscope-idle.ts
24529
24622
  import { execFileSync as execFileSync14 } from "child_process";
24530
24623
  import { statSync as statSync13 } from "fs";
24531
- import { join as join51 } from "path";
24624
+ import { join as join52 } from "path";
24532
24625
  var MAX_SCANNED_FILES = 2e4;
24533
24626
  function newestWorktreeMtime(root) {
24534
24627
  const a = newestTrackedMtime(root);
@@ -24553,7 +24646,7 @@ function newestTrackedMtime(root) {
24553
24646
  if (!rel) continue;
24554
24647
  if (++scanned > MAX_SCANNED_FILES) break;
24555
24648
  try {
24556
- const m = statSync13(join51(root, rel)).mtimeMs;
24649
+ const m = statSync13(join52(root, rel)).mtimeMs;
24557
24650
  if (newest === null || m > newest) newest = m;
24558
24651
  } catch {
24559
24652
  }
@@ -24627,8 +24720,8 @@ async function runPeriscopeIdlePass(d) {
24627
24720
  }
24628
24721
 
24629
24722
  // src/periscope-cmd.ts
24630
- import { existsSync as existsSync47, mkdirSync as mkdirSync35, readFileSync as readFileSync45, rmSync as rmSync22, writeFileSync as writeFileSync37 } from "fs";
24631
- import { join as join52 } from "path";
24723
+ import { existsSync as existsSync47, mkdirSync as mkdirSync36, readFileSync as readFileSync45, rmSync as rmSync22, writeFileSync as writeFileSync38 } from "fs";
24724
+ import { join as join53 } from "path";
24632
24725
  var PeriscopeError = class extends Error {
24633
24726
  };
24634
24727
  var LivePeriscopeError = class extends PeriscopeError {
@@ -24638,15 +24731,15 @@ var LivePeriscopeError = class extends PeriscopeError {
24638
24731
  this.data = { refused: "live_periscope_exists", ...live2 };
24639
24732
  }
24640
24733
  };
24641
- var priorDir = (stateDir) => join52(stateDir, "periscope-priors");
24642
- var priorPath = (stateDir, ticketRecordId) => join52(priorDir(stateDir), `${ticketRecordId}.json`);
24734
+ var priorDir = (stateDir) => join53(stateDir, "periscope-priors");
24735
+ var priorPath = (stateDir, ticketRecordId) => join53(priorDir(stateDir), `${ticketRecordId}.json`);
24643
24736
  function removePeriscopePrior(stateDir, ticketRecordId) {
24644
24737
  rmSync22(priorPath(stateDir, ticketRecordId), { force: true });
24645
24738
  }
24646
24739
  function writePeriscopePrior(stateDir, ticketRecordId, prior) {
24647
24740
  try {
24648
- mkdirSync35(priorDir(stateDir), { recursive: true });
24649
- writeFileSync37(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
24741
+ mkdirSync36(priorDir(stateDir), { recursive: true });
24742
+ writeFileSync38(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
24650
24743
  } catch {
24651
24744
  }
24652
24745
  }
@@ -25192,7 +25285,7 @@ function latestMtime(path) {
25192
25285
  if (!stat2.isDirectory()) return 0;
25193
25286
  let latest = stat2.mtimeMs;
25194
25287
  for (const entry of readdirSync15(path, { withFileTypes: true })) {
25195
- latest = Math.max(latest, latestMtime(join53(path, entry.name)));
25288
+ latest = Math.max(latest, latestMtime(join54(path, entry.name)));
25196
25289
  }
25197
25290
  return latest;
25198
25291
  }
@@ -25204,7 +25297,7 @@ function makeStaleChecker(paths, opts = {}) {
25204
25297
  return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync48(opts.reloadSentinel);
25205
25298
  }
25206
25299
  function reloadSentinelFor(stateDir) {
25207
- return join53(stateDir, "reload-requested");
25300
+ return join54(stateDir, "reload-requested");
25208
25301
  }
25209
25302
  function readReloadRequestedAt(stateDir) {
25210
25303
  try {
@@ -25214,12 +25307,12 @@ function readReloadRequestedAt(stateDir) {
25214
25307
  }
25215
25308
  }
25216
25309
  function daemonStampFor(stateDir) {
25217
- return join53(stateDir, "daemon.started");
25310
+ return join54(stateDir, "daemon.started");
25218
25311
  }
25219
25312
  function noteDaemonStarted(stateDir, now = Date.now()) {
25220
- mkdirSync36(stateDir, { recursive: true });
25313
+ mkdirSync37(stateDir, { recursive: true });
25221
25314
  rmSync23(reloadSentinelFor(stateDir), { force: true });
25222
- writeFileSync38(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
25315
+ writeFileSync39(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
25223
25316
  `);
25224
25317
  }
25225
25318
  function readDaemonStarted(stateDir) {
@@ -26286,12 +26379,12 @@ function startLaunchdDaemon(o) {
26286
26379
  }
26287
26380
 
26288
26381
  // src/daemon-start-failure.ts
26289
- import { existsSync as existsSync50, mkdirSync as mkdirSync37, readFileSync as readFileSync49, unlinkSync as unlinkSync4, writeFileSync as writeFileSync39 } from "fs";
26290
- import { dirname as dirname30, join as join54 } from "path";
26382
+ import { existsSync as existsSync50, mkdirSync as mkdirSync38, readFileSync as readFileSync49, unlinkSync as unlinkSync4, writeFileSync as writeFileSync40 } from "fs";
26383
+ import { dirname as dirname30, join as join55 } from "path";
26291
26384
  var DAEMON_START_FAILED_KEY = "daemon_start_failed";
26292
26385
  var START_FAILURE_BACKOFF_MS = 6e4;
26293
26386
  var BACKOFF_AFTER_FAILURES = 2;
26294
- var fileFor4 = (stateDir) => join54(stateDir, ".daemon-start-failure.json");
26387
+ var fileFor4 = (stateDir) => join55(stateDir, ".daemon-start-failure.json");
26295
26388
  function readStartFailure(stateDir) {
26296
26389
  try {
26297
26390
  const parsed = JSON.parse(readFileSync49(fileFor4(stateDir), "utf8"));
@@ -26310,8 +26403,8 @@ function noteStartFailure(stateDir, reason, nowMs = Date.now()) {
26310
26403
  firstAt: same2 ? previous.firstAt : nowIso,
26311
26404
  lastAt: nowIso
26312
26405
  };
26313
- mkdirSync37(stateDir, { recursive: true });
26314
- writeFileSync39(fileFor4(stateDir), JSON.stringify(record));
26406
+ mkdirSync38(stateDir, { recursive: true });
26407
+ writeFileSync40(fileFor4(stateDir), JSON.stringify(record));
26315
26408
  return record;
26316
26409
  }
26317
26410
  function startFailureDelayMs(count) {
@@ -26352,7 +26445,7 @@ async function reportStartFailure(o) {
26352
26445
  return delay;
26353
26446
  }
26354
26447
  function fallbackStateDir(configFile) {
26355
- return join54(dirname30(configFile), "state");
26448
+ return join55(dirname30(configFile), "state");
26356
26449
  }
26357
26450
 
26358
26451
  // src/projects-cmd.ts
@@ -26545,7 +26638,7 @@ function runForge(a, io) {
26545
26638
 
26546
26639
  // src/release-sandbox.ts
26547
26640
  import { execFile as execFile5 } from "child_process";
26548
- import { mkdirSync as mkdirSync38, writeFileSync as writeFileSync40 } from "fs";
26641
+ import { mkdirSync as mkdirSync39, writeFileSync as writeFileSync41 } from "fs";
26549
26642
  import { dirname as dirname31 } from "path";
26550
26643
  import { promisify as promisify4 } from "util";
26551
26644
  var execFileP4 = promisify4(execFile5);
@@ -26592,8 +26685,8 @@ async function openReleaseSandbox(o) {
26592
26685
  if (!policyFile) {
26593
26686
  generated = generateSandboxPolicy({ mirrorDir: cfg.mirrorDir, workDir: cfg.workDir, ...o.policy });
26594
26687
  policyFile = o.policyFile;
26595
- mkdirSync38(dirname31(policyFile), { recursive: true });
26596
- writeFileSync40(policyFile, generated.yaml, { mode: 384 });
26688
+ mkdirSync39(dirname31(policyFile), { recursive: true });
26689
+ writeFileSync41(policyFile, generated.yaml, { mode: 384 });
26597
26690
  }
26598
26691
  const secrets = { ...process.env };
26599
26692
  const secretKeys = [];
@@ -27927,12 +28020,12 @@ function describeCapability(i) {
27927
28020
 
27928
28021
  // src/persona-avatars.ts
27929
28022
  import { existsSync as existsSync52, readFileSync as readFileSync50 } from "fs";
27930
- import { join as join55 } from "path";
28023
+ import { join as join56 } from "path";
27931
28024
  var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
27932
28025
  function personaAvatarFile(promptsDir, role) {
27933
28026
  for (const ext of ["png", "svg"]) {
27934
28027
  const name = `lane-${role}.${ext}`;
27935
- const path = join55(promptsDir, "personas", name);
28028
+ const path = join56(promptsDir, "personas", name);
27936
28029
  if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
27937
28030
  }
27938
28031
  return void 0;
@@ -27995,7 +28088,7 @@ function routeAvatarFailures(stateDir, route2) {
27995
28088
  }
27996
28089
 
27997
28090
  // src/agents-sync-run.ts
27998
- import { existsSync as existsSync53, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync41 } from "fs";
28091
+ import { existsSync as existsSync53, mkdirSync as mkdirSync40, readFileSync as readFileSync51, writeFileSync as writeFileSync42 } from "fs";
27999
28092
  import { dirname as dirname32 } from "path";
28000
28093
  async function runAgentsSync(target, o) {
28001
28094
  const dryRun = o.dryRun ?? false;
@@ -28046,8 +28139,8 @@ async function runAgentsSync(target, o) {
28046
28139
  if (skillResult) raw.agentSkills = skillResult.agentSkills;
28047
28140
  if (!readOnly2) raw.avatarSyncFailures = avatarFailures2;
28048
28141
  if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
28049
- mkdirSync39(dirname32(resolvedPath), { recursive: true });
28050
- writeFileSync41(resolvedPath, `${JSON.stringify(raw, null, 2)}
28142
+ mkdirSync40(dirname32(resolvedPath), { recursive: true });
28143
+ writeFileSync42(resolvedPath, `${JSON.stringify(raw, null, 2)}
28051
28144
  `);
28052
28145
  if (target.resolved) {
28053
28146
  target.resolved.agentPersonas = personaResult.agentPersonas;
@@ -28184,10 +28277,10 @@ async function showLogEntry(route2, entryId, opts = {}) {
28184
28277
 
28185
28278
  // src/repo-setup-prompt.ts
28186
28279
  import { readFileSync as readFileSync52 } from "fs";
28187
- import { join as join56 } from "path";
28188
- var REPO_SETUP_PROMPT_PATH = join56("docs", "repo-setup-prompt.md");
28280
+ import { join as join57 } from "path";
28281
+ var REPO_SETUP_PROMPT_PATH = join57("docs", "repo-setup-prompt.md");
28189
28282
  function readRepoSetupPrompt(crewHome) {
28190
- return readFileSync52(join56(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
28283
+ return readFileSync52(join57(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
28191
28284
  }
28192
28285
 
28193
28286
  // src/repos-check.ts
@@ -28697,7 +28790,7 @@ ${run4.err}` });
28697
28790
  }
28698
28791
 
28699
28792
  // src/sample-ticket.ts
28700
- import { basename as basename13, dirname as dirname33, join as join57 } from "path";
28793
+ import { basename as basename13, dirname as dirname33, join as join58 } from "path";
28701
28794
  var SAMPLE_REPO = "crew-sample";
28702
28795
  var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
28703
28796
  var SAMPLE_MARKER = "sample: true";
@@ -28720,8 +28813,8 @@ has something safe to work on: its test and build hooks always pass, it has no
28720
28813
  remote, and \`crew sample-ticket --remove\` deletes it.
28721
28814
  `;
28722
28815
  function sampleDir(existing, reposBase, workspace) {
28723
- if (existing.length > 0) return join57(dirname33(existing[0]), SAMPLE_REPO);
28724
- return join57(reposBase, workspace, SAMPLE_REPO);
28816
+ if (existing.length > 0) return join58(dirname33(existing[0]), SAMPLE_REPO);
28817
+ return join58(reposBase, workspace, SAMPLE_REPO);
28725
28818
  }
28726
28819
  var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
28727
28820
  function sampleDescription() {
@@ -28990,7 +29083,7 @@ function fixPhaseNothingToOffer(o) {
28990
29083
 
28991
29084
  // src/worktree-sweep.ts
28992
29085
  import { existsSync as existsSync54, readFileSync as readFileSync54, readdirSync as readdirSync16 } from "fs";
28993
- import { basename as basename14, dirname as dirname34, join as join58, resolve as resolve5 } from "path";
29086
+ import { basename as basename14, dirname as dirname34, join as join59, resolve as resolve5 } from "path";
28994
29087
  function planWorktreeSweep(target, tickets, contract) {
28995
29088
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
28996
29089
  const verified = contract.statuses.verified;
@@ -29067,7 +29160,7 @@ function siblingWorktreeDirs(target) {
29067
29160
  for (const name of names) {
29068
29161
  if (!name.startsWith(stem)) continue;
29069
29162
  const m = DIR_NUMBER_SUFFIXED.exec(name);
29070
- const path = join58(parent, name);
29163
+ const path = join59(parent, name);
29071
29164
  if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
29072
29165
  }
29073
29166
  return out;
@@ -29300,13 +29393,13 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
29300
29393
 
29301
29394
  // src/stream-sweep.ts
29302
29395
  import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync16 } from "fs";
29303
- import { join as join59 } from "path";
29396
+ import { join as join60 } from "path";
29304
29397
  var DAY_MS2 = 24 * 60 * 60 * 1e3;
29305
29398
  function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
29306
- const dir = join59(stateDir, "streams");
29399
+ const dir = join60(stateDir, "streams");
29307
29400
  if (!existsSync55(dir)) return [];
29308
29401
  const cutoff = now - retentionDays * DAY_MS2;
29309
- return readdirSync17(dir).map((name) => join59(dir, name)).filter((path) => {
29402
+ return readdirSync17(dir).map((name) => join60(dir, name)).filter((path) => {
29310
29403
  try {
29311
29404
  return statSync16(path).mtimeMs < cutoff;
29312
29405
  } catch {
@@ -29334,7 +29427,7 @@ function applyStreamSweep(paths, dryRun, log) {
29334
29427
  function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
29335
29428
  if (!existsSync55(stateDir)) return [];
29336
29429
  const cutoff = now - retentionDays * DAY_MS2;
29337
- return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join59(stateDir, name)).filter((path) => {
29430
+ return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join60(stateDir, name)).filter((path) => {
29338
29431
  try {
29339
29432
  return statSync16(path).mtimeMs < cutoff;
29340
29433
  } catch {
@@ -29348,7 +29441,7 @@ function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
29348
29441
  if (!existsSync55(dir)) return;
29349
29442
  for (const name of readdirSync17(dir)) {
29350
29443
  if (!keep(name)) continue;
29351
- const path = join59(dir, name);
29444
+ const path = join60(dir, name);
29352
29445
  try {
29353
29446
  const st = statSync16(path);
29354
29447
  if (st.isFile()) files.push({ path, mtime: st.mtimeMs, size: st.size });
@@ -29356,7 +29449,7 @@ function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
29356
29449
  }
29357
29450
  }
29358
29451
  };
29359
- add(join59(stateDir, "streams"), () => true);
29452
+ add(join60(stateDir, "streams"), () => true);
29360
29453
  add(stateDir, (name) => ROTATED_EVENTS_RE.test(name));
29361
29454
  let total = files.reduce((n, f2) => n + f2.size, 0);
29362
29455
  const out = [];
@@ -29376,7 +29469,7 @@ function planStateSweep(stateDir, retentionDays, maxBytes, now = Date.now()) {
29376
29469
  }
29377
29470
 
29378
29471
  // src/cli.ts
29379
- import { realpathSync as realpathSync4, readFileSync as readFileSync57, existsSync as existsSync60, mkdirSync as mkdirSync43, writeFileSync as writeFileSync44, rmSync as rmSync27, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync10, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
29472
+ import { realpathSync as realpathSync4, readFileSync as readFileSync57, existsSync as existsSync60, mkdirSync as mkdirSync44, writeFileSync as writeFileSync45, rmSync as rmSync27, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync10, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
29380
29473
  import { createInterface } from "readline/promises";
29381
29474
 
29382
29475
  // src/periscope-resume.ts
@@ -29453,9 +29546,9 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29453
29546
 
29454
29547
  // src/bundle-staleness.ts
29455
29548
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29456
- import { join as join60 } from "path";
29549
+ import { join as join61 } from "path";
29457
29550
  function builtVersion() {
29458
- return true ? "0.165.0" : null;
29551
+ return true ? "0.165.1" : null;
29459
29552
  }
29460
29553
  var REBUILD_HINT = "rebuild with npm run build";
29461
29554
  function newestMtime(path) {
@@ -29468,17 +29561,17 @@ function newestMtime(path) {
29468
29561
  if (stat2.isFile()) return stat2.mtimeMs;
29469
29562
  if (!stat2.isDirectory()) return 0;
29470
29563
  let latest = stat2.mtimeMs;
29471
- for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join60(path, e.name)));
29564
+ for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join61(path, e.name)));
29472
29565
  return latest;
29473
29566
  }
29474
29567
  function bundleStaleness(i) {
29475
29568
  if (i.built === null || i.compiled) return null;
29476
- const src = join60(i.home, "src");
29569
+ const src = join61(i.home, "src");
29477
29570
  if (!existsSync56(src)) return null;
29478
29571
  if (i.built !== i.current) {
29479
29572
  return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
29480
29573
  }
29481
- const bundle = statSafe(join60(i.home, "dist", "cli.js"));
29574
+ const bundle = statSafe(join61(i.home, "dist", "cli.js"));
29482
29575
  if (bundle === null) return null;
29483
29576
  if (newestMtime(src) > bundle) {
29484
29577
  return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
@@ -29696,8 +29789,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
29696
29789
  import { createServer as createHttpServer } from "http";
29697
29790
  import { spawn as spawn10 } from "child_process";
29698
29791
  import { randomBytes as randomBytes2 } from "crypto";
29699
- import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync55, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
29700
- import { join as join61 } from "path";
29792
+ import { existsSync as existsSync57, mkdirSync as mkdirSync41, readFileSync as readFileSync55, writeFileSync as writeFileSync43, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
29793
+ import { join as join62 } from "path";
29701
29794
 
29702
29795
  // src/secret-compare.ts
29703
29796
  import { timingSafeEqual } from "crypto";
@@ -29790,7 +29883,7 @@ var defaultSpawn2 = (cmd, args, env) => {
29790
29883
  return child;
29791
29884
  };
29792
29885
  function syncDaemonStatePath(stateDir, workspaceId) {
29793
- return join61(stateDir, "passengers", `${workspaceId}-sync.json`);
29886
+ return join62(stateDir, "passengers", `${workspaceId}-sync.json`);
29794
29887
  }
29795
29888
  function readPersistedSyncDaemon(stateDir, workspaceId) {
29796
29889
  const path = syncDaemonStatePath(stateDir, workspaceId);
@@ -29803,8 +29896,8 @@ function readPersistedSyncDaemon(stateDir, workspaceId) {
29803
29896
  }
29804
29897
  function writePersistedSyncDaemon(stateDir, state) {
29805
29898
  const path = syncDaemonStatePath(stateDir, state.workspaceId);
29806
- mkdirSync40(join61(stateDir, "passengers"), { recursive: true });
29807
- writeFileSync42(path, `${JSON.stringify(state, null, 2)}
29899
+ mkdirSync41(join62(stateDir, "passengers"), { recursive: true });
29900
+ writeFileSync43(path, `${JSON.stringify(state, null, 2)}
29808
29901
  `);
29809
29902
  }
29810
29903
  function removePersistedSyncDaemon(stateDir, workspaceId) {
@@ -29824,7 +29917,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
29824
29917
  }
29825
29918
  }
29826
29919
  function readAllPersistedSyncWorkspaceIds(stateDir) {
29827
- const dir = join61(stateDir, "passengers");
29920
+ const dir = join62(stateDir, "passengers");
29828
29921
  if (!existsSync57(dir)) return [];
29829
29922
  const suffix = "-sync.json";
29830
29923
  return readdirSync19(dir).filter((f2) => f2.endsWith(suffix)).map((f2) => f2.slice(0, -suffix.length));
@@ -29884,7 +29977,7 @@ function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
29884
29977
 
29885
29978
  // src/periscope-proxy.ts
29886
29979
  import { spawn as spawn11 } from "child_process";
29887
- import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "fs";
29980
+ import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync42 } from "fs";
29888
29981
  import { createServer, request as httpRequest } from "http";
29889
29982
  import { request as httpsRequest } from "https";
29890
29983
  import { connect as netConnect } from "net";
@@ -30003,7 +30096,7 @@ function parsePointedBody(raw) {
30003
30096
  return entry;
30004
30097
  }
30005
30098
  function appendPointed(file, entry, now = /* @__PURE__ */ new Date()) {
30006
- mkdirSync41(dirname35(file), { recursive: true });
30099
+ mkdirSync42(dirname35(file), { recursive: true });
30007
30100
  appendFileSync4(file, `${JSON.stringify({ ...entry, at: now.toISOString() })}
30008
30101
  `);
30009
30102
  }
@@ -30292,7 +30385,7 @@ async function startWorktreeIntel(d) {
30292
30385
  }
30293
30386
 
30294
30387
  // src/contract-refusal.ts
30295
- import { join as join62 } from "path";
30388
+ import { join as join63 } from "path";
30296
30389
  function contractFixers(dir, baseRef, tickets, locate) {
30297
30390
  const out = [];
30298
30391
  for (const t of tickets) {
@@ -30304,7 +30397,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
30304
30397
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
30305
30398
  if (text2 === null) continue;
30306
30399
  try {
30307
- parseRepoConfig(text2, join62(dir, file));
30400
+ parseRepoConfig(text2, join63(dir, file));
30308
30401
  } catch (e) {
30309
30402
  if (e instanceof RepoConfigError) continue;
30310
30403
  throw e;
@@ -30330,7 +30423,7 @@ import {
30330
30423
  } from "fs";
30331
30424
  import { createConnection } from "net";
30332
30425
  import { createServer as createServer2 } from "http";
30333
- import { basename as basename15, dirname as dirname36, join as join63 } from "path";
30426
+ import { basename as basename15, dirname as dirname36, join as join64 } from "path";
30334
30427
  import { execFile as execFile6, spawn as spawn13 } from "child_process";
30335
30428
 
30336
30429
  // src/periscope-control.ts
@@ -30568,7 +30661,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
30568
30661
  // src/control-api.ts
30569
30662
  var PAUSABLE = ["dev", "design", "qa"];
30570
30663
  var CONTROL_SOCKET_NAME = "control.sock";
30571
- var controlSocketFor = (stateDir) => join63(stateDir, CONTROL_SOCKET_NAME);
30664
+ var controlSocketFor = (stateDir) => join64(stateDir, CONTROL_SOCKET_NAME);
30572
30665
  var MAX_SOCKET_PATH = 100;
30573
30666
  var MAX_TAIL_BYTES = 1024 * 1024;
30574
30667
  var MAX_WAIT_SECONDS = 30;
@@ -30655,7 +30748,7 @@ function candidates(live2, rotated) {
30655
30748
  const out = [live2];
30656
30749
  if (!rotated) return out;
30657
30750
  try {
30658
- for (const n of readdirSync20(dirname36(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join63(dirname36(live2), n));
30751
+ for (const n of readdirSync20(dirname36(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join64(dirname36(live2), n));
30659
30752
  } catch {
30660
30753
  }
30661
30754
  return out;
@@ -30914,7 +31007,7 @@ async function route(deps, method, url, req, abort) {
30914
31007
  if (p.startsWith("/streams/") && get2) {
30915
31008
  const run4 = decodeURIComponent(p.slice("/streams/".length));
30916
31009
  if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
30917
- const file = join63(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
31010
+ const file = join64(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
30918
31011
  if (!existsSync58(file)) return err2(404, "no such run");
30919
31012
  return tailReply(file, url.searchParams, false, abort);
30920
31013
  }
@@ -31082,24 +31175,24 @@ function crewJson(args, timeoutMs = CREW_JSON_TIMEOUT_MS) {
31082
31175
 
31083
31176
  // src/periscope-mcp.ts
31084
31177
  import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
31085
- import { basename as basename16, dirname as dirname37, isAbsolute as isAbsolute5, join as join65, relative as relative2, resolve as resolve6, sep } from "path";
31178
+ import { basename as basename16, dirname as dirname37, isAbsolute as isAbsolute5, join as join66, relative as relative2, resolve as resolve6, sep } from "path";
31086
31179
  import { z } from "zod";
31087
31180
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
31088
31181
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
31089
31182
 
31090
31183
  // src/periscope-endpoints.ts
31091
31184
  import { randomBytes as randomBytes3 } from "crypto";
31092
- import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync42, readdirSync as readdirSync21, readFileSync as readFileSync56, rmSync as rmSync26, writeFileSync as writeFileSync43 } from "fs";
31093
- import { join as join64 } from "path";
31094
- var secretDir = (stateDir) => join64(stateDir, "periscope-mcp");
31095
- var secretFile = (stateDir, id) => join64(secretDir(stateDir), `${id}.json`);
31096
- var endpointDir = (stateDir) => join64(stateDir, "periscope-endpoints");
31097
- var endpointFile = (stateDir, id) => join64(endpointDir(stateDir), `${id}.json`);
31185
+ import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync43, readdirSync as readdirSync21, readFileSync as readFileSync56, rmSync as rmSync26, writeFileSync as writeFileSync44 } from "fs";
31186
+ import { join as join65 } from "path";
31187
+ var secretDir = (stateDir) => join65(stateDir, "periscope-mcp");
31188
+ var secretFile = (stateDir, id) => join65(secretDir(stateDir), `${id}.json`);
31189
+ var endpointDir = (stateDir) => join65(stateDir, "periscope-endpoints");
31190
+ var endpointFile = (stateDir, id) => join65(endpointDir(stateDir), `${id}.json`);
31098
31191
  function mintPeriscopeSecret(stateDir, ticketRecordId) {
31099
- mkdirSync42(secretDir(stateDir), { recursive: true, mode: 448 });
31192
+ mkdirSync43(secretDir(stateDir), { recursive: true, mode: 448 });
31100
31193
  const secret = randomBytes3(32).toString("base64url");
31101
31194
  const file = secretFile(stateDir, ticketRecordId);
31102
- writeFileSync43(file, `${JSON.stringify({ secret })}
31195
+ writeFileSync44(file, `${JSON.stringify({ secret })}
31103
31196
  `, { mode: 384 });
31104
31197
  chmodSync5(file, 384);
31105
31198
  return secret;
@@ -31123,8 +31216,8 @@ function readPeriscopeEndpoint(stateDir, ticketRecordId) {
31123
31216
  }
31124
31217
  }
31125
31218
  function writePeriscopeEndpoint(stateDir, rec) {
31126
- mkdirSync42(endpointDir(stateDir), { recursive: true });
31127
- writeFileSync43(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
31219
+ mkdirSync43(endpointDir(stateDir), { recursive: true });
31220
+ writeFileSync44(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
31128
31221
  `);
31129
31222
  }
31130
31223
  function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
@@ -31235,13 +31328,13 @@ async function resolveInWorktree(root, requested) {
31235
31328
  let abs;
31236
31329
  if (isAbsolute5(requested)) {
31237
31330
  abs = resolve6(requested);
31238
- if (isInside(root, abs)) abs = join65(realRoot, relative2(root, abs));
31331
+ if (isInside(root, abs)) abs = join66(realRoot, relative2(root, abs));
31239
31332
  } else {
31240
31333
  abs = resolve6(realRoot, requested);
31241
31334
  }
31242
31335
  if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
31243
31336
  const { real, rest } = await realAncestor(abs);
31244
- const final = rest ? join65(real, rest) : real;
31337
+ const final = rest ? join66(real, rest) : real;
31245
31338
  if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
31246
31339
  if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
31247
31340
  return final;
@@ -31309,7 +31402,7 @@ function createPeriscopeMcpServer(d, sc) {
31309
31402
  const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
31310
31403
  const lines2 = await Promise.all(entries.map(async (e) => {
31311
31404
  if (e.isDirectory()) return `[DIR] ${e.name}`;
31312
- const size = (await lstat(join65(abs, e.name))).size;
31405
+ const size = (await lstat(join66(abs, e.name))).size;
31313
31406
  return `[FILE] ${e.name} (${size} bytes)`;
31314
31407
  }));
31315
31408
  return text(lines2.join("\n") || "(empty)");
@@ -31375,7 +31468,7 @@ function createPeriscopeMcpServer(d, sc) {
31375
31468
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
31376
31469
  }, async ({ path }) => {
31377
31470
  const parent = await inTree(dirname37(path) === "" ? "." : dirname37(path));
31378
- const abs = join65(parent, basename16(path));
31471
+ const abs = join66(parent, basename16(path));
31379
31472
  if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
31380
31473
  const st = await lstat(abs).catch(() => void 0);
31381
31474
  if (!st) return text(`${path} does not exist`, true);
@@ -32279,7 +32372,7 @@ if (command === "passenger-sync-daemon") {
32279
32372
  stateDir: cfg.ship.stateDir,
32280
32373
  configFile: cfg.configFile,
32281
32374
  readFile: (p) => readFileSync57(p, "utf8"),
32282
- writeFile: (p, t) => writeFileSync44(p, t),
32375
+ writeFile: (p, t) => writeFileSync45(p, t),
32283
32376
  stdin: () => readFileSync57(0, "utf8"),
32284
32377
  env: process.env
32285
32378
  }
@@ -32612,7 +32705,7 @@ if (command === "passenger-sync-daemon") {
32612
32705
  for (const l of summarizeJobs(results, { dryRun, verbose: flag("verbose"), host })) emit.emit(l);
32613
32706
  if (host === "linux" && hasSystemd) {
32614
32707
  const label = labelFor(CREW_HOME, "run");
32615
- const staleTimer = join66(homedir11(), ".config", "systemd", "user", `${label}.timer`);
32708
+ const staleTimer = join67(homedir11(), ".config", "systemd", "user", `${label}.timer`);
32616
32709
  if (existsSync60(staleTimer)) {
32617
32710
  emit.emit(
32618
32711
  `removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run, not applied)" : ""}`
@@ -32732,7 +32825,7 @@ if (command === "passenger-sync-daemon") {
32732
32825
  changed2.push(`refreshed the connect snapshot for ${a.route} (\`crew connect\`)${rel.status === 0 ? " and reloaded the daemon" : "; `crew reload` failed \u2014 run it by hand"}`);
32733
32826
  } else if (a.kind === "enable") {
32734
32827
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
32735
- writeFileSync44(cfg.configFile, planEnable(readFileSync57(cfg.configFile, "utf8"), a.route));
32828
+ writeFileSync45(cfg.configFile, planEnable(readFileSync57(cfg.configFile, "utf8"), a.route));
32736
32829
  enabledSound.add(a.route);
32737
32830
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
32738
32831
  } else {
@@ -32977,7 +33070,7 @@ ${changed2.map((c) => ` - ${c}
32977
33070
  harnessBin: "claude",
32978
33071
  ...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
32979
33072
  },
32980
- policyFile: join66(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
33073
+ policyFile: join67(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
32981
33074
  repo: mirror,
32982
33075
  origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
32983
33076
  base: effective.branch.base,
@@ -34344,7 +34437,7 @@ ${f2.tail.trimEnd()}
34344
34437
  logFile: cfg.ship.logFile
34345
34438
  });
34346
34439
  }
34347
- const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join66(CREW_HOME, "src"), join66(CREW_HOME, "dist"), join66(CREW_HOME, "bin")];
34440
+ const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join67(CREW_HOME, "src"), join67(CREW_HOME, "dist"), join67(CREW_HOME, "bin")];
34348
34441
  const configPaths = daemonConfigPaths(cfg);
34349
34442
  watchPaths.push(...configPaths);
34350
34443
  noteDaemonStarted(cfg.ship.stateDir);
@@ -34655,8 +34748,8 @@ ${f2.tail.trimEnd()}
34655
34748
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
34656
34749
  const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync57(resolvedPath, "utf8")) : {};
34657
34750
  raw.agentSkills = result.agentSkills;
34658
- mkdirSync43(dirOf2(resolvedPath), { recursive: true });
34659
- writeFileSync44(resolvedPath, `${JSON.stringify(raw, null, 2)}
34751
+ mkdirSync44(dirOf2(resolvedPath), { recursive: true });
34752
+ writeFileSync45(resolvedPath, `${JSON.stringify(raw, null, 2)}
34660
34753
  `);
34661
34754
  }
34662
34755
  if (result.outcomes.some((o) => o.action === "diverged")) process.exitCode = 1;
@@ -34677,7 +34770,7 @@ ${f2.tail.trimEnd()}
34677
34770
  throw e;
34678
34771
  }
34679
34772
  const oldName = cfg.ship.name;
34680
- writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), newName));
34773
+ writeFileSync45(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), newName));
34681
34774
  cfg.ship.name = newName;
34682
34775
  let renameMachineId;
34683
34776
  try {
@@ -34805,19 +34898,19 @@ ${f2.tail.trimEnd()}
34805
34898
  let cleared;
34806
34899
  if (clear2) {
34807
34900
  const plan = clearRouteHooks(configText, a.route, a.name);
34808
- if (plan.removed.length > 0) writeFileSync44(cfg.configFile, plan.text);
34901
+ if (plan.removed.length > 0) writeFileSync45(cfg.configFile, plan.text);
34809
34902
  cleared = { file: cfg.configFile, removed: plan.removed };
34810
34903
  }
34811
34904
  if (write && suggestion.source === null && recipeIds.length === 0 && hookSpecs.length === 0) throw new ReposError(`nothing to write: ${suggestion.notes[0]}`);
34812
34905
  if (write === "route") {
34813
34906
  const plan = planRouteHooks(configText, a.route, a.name, picked.hooks, { replace: flag("replace") });
34814
- writeFileSync44(cfg.configFile, plan.text);
34907
+ writeFileSync45(cfg.configFile, plan.text);
34815
34908
  written = { target: "route", file: cfg.configFile, hooks: plan.written, kept: plan.kept, replaced: plan.replaced };
34816
34909
  } else if (write === "repo") {
34817
34910
  const have = existingRepoConfig(files);
34818
34911
  if (have) throw new ReposError(`${resolvePath(dir, have)} already exists; not overwriting it`);
34819
34912
  const file = resolvePath(dir, ".crew.yaml");
34820
- writeFileSync44(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
34913
+ writeFileSync45(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
34821
34914
  written = { target: "repo", file, hooks: Object.keys(picked.hooks), kept: [], replaced: [] };
34822
34915
  }
34823
34916
  if (flag("json")) {
@@ -34978,7 +35071,7 @@ ${f2.tail.trimEnd()}
34978
35071
  throw new ReposError(`${e.message}${authHint}
34979
35072
  crew.yaml was not changed`);
34980
35073
  }
34981
- writeFileSync44(cfg.configFile, plan2.text);
35074
+ writeFileSync45(cfg.configFile, plan2.text);
34982
35075
  if (plan2.droppedDir) emit.warn(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:`);
34983
35076
  say("attached", { route: routeName, name: plan2.name, dir: plan2.target, mode: plan2.mode }, `cloned and attached ${plan2.target} to ${routeName} as ${plan2.mode === "dir" ? "dir" : `repos.${plan2.name}`} in ${cfg.configFile}`);
34984
35077
  break;
@@ -35072,11 +35165,11 @@ would need a project first: the tracker has none (\`crew projects add NAME --pre
35072
35165
  const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
35073
35166
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
35074
35167
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
35075
- writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
35168
+ writeFileSync45(resolvedFile, `${JSON.stringify(raw, null, 2)}
35076
35169
  `);
35077
35170
  }
35078
35171
  }
35079
- writeFileSync44(cfg.configFile, plan.text);
35172
+ writeFileSync45(cfg.configFile, plan.text);
35080
35173
  process.stdout.write(`added ${top} to ${routeName} as ${plan.mode === "dir" ? "dir" : `repos.${plan.name}`} in ${cfg.configFile}
35081
35174
  `);
35082
35175
  } catch (e) {
@@ -35428,7 +35521,7 @@ Waiting for approval`
35428
35521
  ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, then run `crew connect` again");
35429
35522
  }
35430
35523
  if (found.shipNameAdopted && !dryRun) {
35431
- writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), found.shipNameAdopted));
35524
+ writeFileSync45(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), found.shipNameAdopted));
35432
35525
  cfg.ship.name = found.shipNameAdopted;
35433
35526
  }
35434
35527
  if (found.shipRow) {
@@ -35618,10 +35711,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
35618
35711
  process.stderr.write(`(dry run) would write resolved ids to ${resolvedPath}
35619
35712
  `);
35620
35713
  } else {
35621
- mkdirSync43(dirname38(resolvedPath), { recursive: true });
35714
+ mkdirSync44(dirname38(resolvedPath), { recursive: true });
35622
35715
  if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
35623
35716
  const tmpPath = `${resolvedPath}.tmp${process.pid}`;
35624
- writeFileSync44(tmpPath, `${JSON.stringify(resolved, null, 2)}
35717
+ writeFileSync45(tmpPath, `${JSON.stringify(resolved, null, 2)}
35625
35718
  `);
35626
35719
  renameSync10(tmpPath, resolvedPath);
35627
35720
  emit.note(`Resolved ids written to ${resolvedPath}`);
@@ -35688,8 +35781,8 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
35688
35781
  process.stderr.write(`(dry run) would write the API key to ${apiKeyFile}
35689
35782
  `);
35690
35783
  } else {
35691
- mkdirSync43(dirname38(apiKeyFile), { recursive: true });
35692
- writeFileSync44(apiKeyFile, `${apiKeyVar}=${apiKey}
35784
+ mkdirSync44(dirname38(apiKeyFile), { recursive: true });
35785
+ writeFileSync45(apiKeyFile, `${apiKeyVar}=${apiKey}
35693
35786
  `, { mode: 384 });
35694
35787
  routineLine(`API key written to ${apiKeyFile}`);
35695
35788
  }
@@ -36340,10 +36433,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
36340
36433
  startupSeconds: cfg.ship.intelStartupSeconds,
36341
36434
  prepare: async (path) => {
36342
36435
  for (const f2 of repoWt.config.worktrees.copy) {
36343
- const src = join66(repoWt.dir, f2);
36344
- if (!existsSync60(src) || existsSync60(join66(path, f2))) continue;
36345
- mkdirSync43(dirOf2(join66(path, f2)), { recursive: true });
36346
- copyFileSync2(src, join66(path, f2));
36436
+ const src = join67(repoWt.dir, f2);
36437
+ if (!existsSync60(src) || existsSync60(join67(path, f2))) continue;
36438
+ mkdirSync44(dirOf2(join67(path, f2)), { recursive: true });
36439
+ copyFileSync2(src, join67(path, f2));
36347
36440
  }
36348
36441
  const setup = repoWt.config.hooks.setup;
36349
36442
  return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
@@ -36670,10 +36763,10 @@ ${where.join("\n")}`);
36670
36763
  },
36671
36764
  prepare: async (path) => {
36672
36765
  for (const f2 of repoP.config.worktrees.copy) {
36673
- const src = join66(repoP.dir, f2);
36766
+ const src = join67(repoP.dir, f2);
36674
36767
  if (!existsSync60(src)) continue;
36675
- mkdirSync43(dirOf2(join66(path, f2)), { recursive: true });
36676
- copyFileSync2(src, join66(path, f2));
36768
+ mkdirSync44(dirOf2(join67(path, f2)), { recursive: true });
36769
+ copyFileSync2(src, join67(path, f2));
36677
36770
  }
36678
36771
  const setup = repoP.config.hooks.setup;
36679
36772
  return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
@@ -37141,8 +37234,8 @@ ${where.join("\n")}`);
37141
37234
  process.stdout.write("crew reload: no daemon unit is running \u2014 nothing to reload (the next run reads crew.yaml fresh)\n");
37142
37235
  break;
37143
37236
  }
37144
- mkdirSync43(cfg.ship.stateDir, { recursive: true });
37145
- writeFileSync44(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
37237
+ mkdirSync44(cfg.ship.stateDir, { recursive: true });
37238
+ writeFileSync45(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
37146
37239
  `);
37147
37240
  process.stdout.write(
37148
37241
  "crew reload: requested \u2014 the daemon relaunches with the new config once its running agents end (it starts no new work meanwhile); if it is busy, `crew reload --now` forces the relaunch and interrupts them\n"
@@ -37257,7 +37350,7 @@ ${where.join("\n")}`);
37257
37350
  }
37258
37351
  if (configured2.some((r) => r.dir === dir)) {
37259
37352
  try {
37260
- writeFileSync44(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
37353
+ writeFileSync45(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
37261
37354
  } catch (e) {
37262
37355
  if (e instanceof ReposError) fail2(e.message);
37263
37356
  throw e;
@@ -37269,25 +37362,25 @@ ${where.join("\n")}`);
37269
37362
  const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
37270
37363
  if (raw.repoNames) delete raw.repoNames[row.id];
37271
37364
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
37272
- writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
37365
+ writeFileSync45(resolvedFile, `${JSON.stringify(raw, null, 2)}
37273
37366
  `);
37274
37367
  }
37275
37368
  }
37276
- if (existsSync60(join66(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
37369
+ if (existsSync60(join67(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
37277
37370
  say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
37278
37371
  break;
37279
37372
  }
37280
37373
  const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
37281
- const fresh = !existsSync60(join66(dir, ".git"));
37374
+ const fresh = !existsSync60(join67(dir, ".git"));
37282
37375
  if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
37283
37376
  if (dryRun) {
37284
37377
  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`);
37285
37378
  break;
37286
37379
  }
37287
37380
  if (fresh) {
37288
- mkdirSync43(dir, { recursive: true });
37289
- writeFileSync44(join66(dir, "README.md"), SAMPLE_README);
37290
- writeFileSync44(join66(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
37381
+ mkdirSync44(dir, { recursive: true });
37382
+ writeFileSync45(join67(dir, "README.md"), SAMPLE_README);
37383
+ writeFileSync45(join67(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
37291
37384
  const g = (...a) => {
37292
37385
  const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
37293
37386
  if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
@@ -37309,13 +37402,13 @@ ${where.join("\n")}`);
37309
37402
  const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
37310
37403
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
37311
37404
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
37312
- writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
37405
+ writeFileSync45(resolvedFile, `${JSON.stringify(raw, null, 2)}
37313
37406
  `);
37314
37407
  }
37315
37408
  }
37316
37409
  if (!configured2.some((r) => r.dir === dir)) {
37317
37410
  try {
37318
- writeFileSync44(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
37411
+ writeFileSync45(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
37319
37412
  } catch (e) {
37320
37413
  if (e instanceof ReposError) fail2(e.message);
37321
37414
  throw e;