@tablation/crew 0.165.0 → 0.165.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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}**
11632
11713
 
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}
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}
11634
11715
 
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.
11716
+ ${outsideNote(b)}${first} Push as a plain fast-forward and hand back to QA as usual.
11717
+
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) {
@@ -21937,9 +22022,29 @@ async function applyMergeStamp(tracker, merged, tickets, emit, dryRun, cwd) {
21937
22022
  }
21938
22023
  return stamped;
21939
22024
  }
21940
- async function applyStamp(tracker, plan, version, contract, emit, dryRun, cwd) {
22025
+ var RELEASE_CLAIMED_EVENT = "release_claimed";
22026
+ async function priorAssignees(tracker, plan, seat, contract, emit) {
22027
+ const out = /* @__PURE__ */ new Map();
22028
+ if (!plan.length) return out;
22029
+ try {
22030
+ const fresh = await tracker.ticketsByIds(plan.map((p) => p.ticket.id));
22031
+ const held = fresh.filter((t) => t[contract.columns.assignee] === seat);
22032
+ if (!held.length) return out;
22033
+ const events = await tracker.events(RELEASE_CLAIMED_EVENT);
22034
+ for (const t of held) {
22035
+ const e = events.find((x) => x.record_id === t.id);
22036
+ const prior = e?.metadata?.prior_assignee;
22037
+ out.set(t.id, typeof prior === "string" && prior !== seat ? prior : null);
22038
+ }
22039
+ } catch (e) {
22040
+ emit.warn(`could not read who held the tickets before the release: ${e.message}`);
22041
+ }
22042
+ return out;
22043
+ }
22044
+ async function applyStamp(tracker, plan, version, contract, emit, dryRun, cwd, seat) {
21941
22045
  let stamped = 0;
21942
22046
  const at = (/* @__PURE__ */ new Date()).toISOString();
22047
+ const priorAssignee = !dryRun && seat ? await priorAssignees(tracker, plan, seat, contract, emit) : /* @__PURE__ */ new Map();
21943
22048
  for (const { ticket, sha } of plan) {
21944
22049
  const shaNote = sha ? `, commit_sha ${sha.slice(0, 8)}` : "";
21945
22050
  if (dryRun) {
@@ -21953,6 +22058,7 @@ async function applyStamp(tracker, plan, version, contract, emit, dryRun, cwd) {
21953
22058
  try {
21954
22059
  await tracker.updateTicket(ticket.id, {
21955
22060
  status: contract.statuses.deployed,
22061
+ ...priorAssignee.has(ticket.id) ? { [contract.columns.assignee]: priorAssignee.get(ticket.id) ?? null } : {},
21956
22062
  // `released_at` is always a real release moment here; only the version is optional (versioning: none).
21957
22063
  released_at: at,
21958
22064
  ...version ? { released_version: version } : {},
@@ -22606,7 +22712,7 @@ async function bump(o, size) {
22606
22712
  }
22607
22713
  return printed;
22608
22714
  }
22609
- const files = o.repo.release.versionFiles.map((f2) => join48(o.cwd, f2));
22715
+ const files = o.repo.release.versionFiles.map((f2) => join49(o.cwd, f2));
22610
22716
  const first = files[0];
22611
22717
  if (!existsAt(first, existsSync42)) {
22612
22718
  o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
@@ -22637,21 +22743,21 @@ async function bump(o, size) {
22637
22743
  o.emit.error(`no version field in ${f2}`);
22638
22744
  return null;
22639
22745
  }
22640
- writeTextAt(f2, out, writeFileSync34);
22746
+ writeTextAt(f2, out, writeFileSync35);
22641
22747
  }
22642
22748
  return version;
22643
22749
  }
22644
22750
  function writeChangelog(o, version, entries) {
22645
22751
  const file = o.repo.release.changelog;
22646
22752
  if (!file || entries.length === 0) return;
22647
- const path = join48(o.cwd, file);
22753
+ const path = join49(o.cwd, file);
22648
22754
  const section = renderChangelogSection(version, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), entries);
22649
22755
  if (o.dryRun) {
22650
22756
  o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
22651
22757
  return;
22652
22758
  }
22653
22759
  const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) => readFileSync41(p, "utf8")) : "# Changelog\n";
22654
- writeTextAt(path, insertChangelogSection(existing, section), writeFileSync34);
22760
+ writeTextAt(path, insertChangelogSection(existing, section), writeFileSync35);
22655
22761
  }
22656
22762
  async function confirm(o, expected, ci) {
22657
22763
  if (!o.repo.hooks.released) return void 0;
@@ -22804,8 +22910,8 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
22804
22910
  function openReleaseCheckout(o) {
22805
22911
  const { remote, base } = o.repo.branch;
22806
22912
  const branch = `crew/release-${Date.now()}`;
22807
- const root = mkdtempSync3(join48(tmpdir6(), "crew-release-"));
22808
- const dir = join48(root, "checkout");
22913
+ const root = mkdtempSync3(join49(tmpdir7(), "crew-release-"));
22914
+ const dir = join49(root, "checkout");
22809
22915
  o.emit.note(`release checkout: ${dir}`, { step: "release" });
22810
22916
  const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
22811
22917
  try {
@@ -22815,10 +22921,10 @@ function openReleaseCheckout(o) {
22815
22921
  throw e;
22816
22922
  }
22817
22923
  for (const f2 of o.repo.worktrees.copy) {
22818
- const src = join48(o.cwd, f2);
22924
+ const src = join49(o.cwd, f2);
22819
22925
  if (!existsSync42(src)) continue;
22820
- mkdirSync30(dirname26(join48(dir, f2)), { recursive: true });
22821
- copyFileSync(src, join48(dir, f2));
22926
+ mkdirSync31(dirname26(join49(dir, f2)), { recursive: true });
22927
+ copyFileSync(src, join49(dir, f2));
22822
22928
  }
22823
22929
  return { dir, branch, close };
22824
22930
  }
@@ -23006,7 +23112,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
23006
23112
  let checkout;
23007
23113
  const stranded = recoverStrandedReleaseCheckouts(o.cwd);
23008
23114
  if (stranded.length > 0) o.emit.warn(scoped(`dropped release checkout(s) stranded by a crash: ${stranded.join(", ")}`));
23009
- const swept = sweepStaleReleaseRoots(tmpdir6());
23115
+ const swept = sweepStaleReleaseRoots(tmpdir7());
23010
23116
  if (swept.length > 0) o.emit.emit(scoped(`removed ${swept.length} stale crew-release-* temp dir(s)`), { step: "release" });
23011
23117
  try {
23012
23118
  checkout = openReleaseCheckout(o);
@@ -23096,11 +23202,11 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23096
23202
  const byFile = culpritByFiles(withFiles, failingPaths(output, o.cwd));
23097
23203
  if (byFile) {
23098
23204
  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) });
23205
+ culprits.push({ c: byFile.c, how: "files", output, paths: failingPaths(output, o.cwd) });
23100
23206
  } else if (applied.length === 1) {
23101
23207
  const only = applied[0];
23102
23208
  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) });
23209
+ culprits.push({ c: only, how: "solo", output, paths: failingPaths(output, o.cwd) });
23104
23210
  } else if (applied.length > cap) {
23105
23211
  o.emit.warn(`${name} failed with ${applied.length} branches merged, over release.isolateFailures.maxCandidates (${cap}) \u2014 not isolating`);
23106
23212
  return { tried: `Isolation was skipped: ${applied.length} branches were merged, over release.isolateFailures.maxCandidates (${cap}).` };
@@ -23113,7 +23219,7 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23113
23219
  const r = await hook(o, name);
23114
23220
  if (r && r.code !== 0) {
23115
23221
  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) });
23222
+ culprits.push({ c, how: "solo", output: r.output, paths: failingPaths(r.output, o.cwd) });
23117
23223
  }
23118
23224
  }
23119
23225
  if (culprits.length === 0) {
@@ -23126,13 +23232,13 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23126
23232
  const r = await hook(o, name);
23127
23233
  if (r && r.code !== 0) {
23128
23234
  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) });
23235
+ culprits.push({ c: applied[j], how: "pair", sibling: applied[i], output: r.output, paths: failingPaths(r.output, o.cwd) });
23130
23236
  break;
23131
23237
  }
23132
23238
  }
23133
23239
  if (culprits.length === 0 && truncated) {
23134
23240
  let lo = 2, hi = applied.length;
23135
- let tail3 = lastLines(output, HOOK_FAILURE_TAIL_LINES);
23241
+ let tailOut = output;
23136
23242
  let paths = failingPaths(output, o.cwd);
23137
23243
  while (lo < hi) {
23138
23244
  const mid = Math.floor((lo + hi) / 2);
@@ -23148,13 +23254,13 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23148
23254
  const r = clean ? await hook(o, name) : null;
23149
23255
  if (r && r.code !== 0) {
23150
23256
  hi = mid;
23151
- tail3 = lastLines(r.output, HOOK_FAILURE_TAIL_LINES);
23257
+ tailOut = r.output;
23152
23258
  paths = failingPaths(r.output, o.cwd);
23153
23259
  } else lo = mid + 1;
23154
23260
  }
23155
23261
  const owner = applied[hi - 1];
23156
23262
  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 });
23263
+ culprits.push({ c: owner, how: "pair", sibling: applied[hi - 2], output: tailOut, paths });
23158
23264
  }
23159
23265
  }
23160
23266
  }
@@ -23169,17 +23275,25 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23169
23275
  const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch, true);
23170
23276
  return {
23171
23277
  ...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
- }))
23278
+ buildCulprits: culprits.map((x) => {
23279
+ const ex = failureExcerpt(x.output, x.paths, HOOK_FAILURE_TAIL_LINES);
23280
+ const tip = gitOk(o.cwd, ["rev-parse", x.c.branch])?.trim();
23281
+ const logPath = saveGateOutput(x.c.ticket.issue_tag ?? x.c.ticket.issue_id, name, x.output);
23282
+ return {
23283
+ ticket: x.c.ticket,
23284
+ branch: x.c.branch,
23285
+ hook: name,
23286
+ tail: ex.text,
23287
+ how: x.how,
23288
+ cwd: o.cwd,
23289
+ pathCentered: ex.pathCentered,
23290
+ ...logPath ? { outputPath: logPath } : {},
23291
+ ...tip ? { tip } : {},
23292
+ failingFiles: x.paths,
23293
+ inBranch: x.paths.length === 0 ? null : x.paths.some((p) => withFiles.find((w) => w.c === x.c)?.changed.has(p) ?? false),
23294
+ ...x.sibling ? { sibling: { key: x.sibling.ticket.issue_tag ?? x.sibling.ticket.issue_id, branch: x.sibling.branch } } : {}
23295
+ };
23296
+ })
23183
23297
  };
23184
23298
  }
23185
23299
  async function mergeAndRelease(o, decision, fresh, releaseBranch, isolated = false) {
@@ -23215,7 +23329,21 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
23215
23329
  }
23216
23330
  continue;
23217
23331
  }
23332
+ if (o.onClaim && !o.dryRun) {
23333
+ try {
23334
+ await o.onClaim(c.ticket);
23335
+ } catch (e) {
23336
+ o.emit.warn(`could not assign the ticket to the release seat: ${e.message}`, { ticket: c.ticket.issue_id });
23337
+ }
23338
+ }
23218
23339
  const r = mergeOne(o, c);
23340
+ if (o.onUnclaim && !o.dryRun && typeof r === "object" && ("conflict" in r || "error" in r)) {
23341
+ try {
23342
+ await o.onUnclaim(c.ticket);
23343
+ } catch (e) {
23344
+ o.emit.warn(`could not hand the ticket back from the release seat: ${e.message}`, { ticket: c.ticket.issue_id });
23345
+ }
23346
+ }
23219
23347
  if (typeof r === "object" && "conflict" in r) {
23220
23348
  conflicts.push(r.conflict);
23221
23349
  continue;
@@ -23757,8 +23885,8 @@ import { spawnSync as spawnSync12 } from "child_process";
23757
23885
  import { existsSync as existsSync49, readFileSync as readFileSync47 } from "fs";
23758
23886
 
23759
23887
  // 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";
23888
+ import { existsSync as existsSync48, mkdirSync as mkdirSync37, readFileSync as readFileSync46, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync39 } from "fs";
23889
+ import { join as join54 } from "path";
23762
23890
  import { randomBytes } from "crypto";
23763
23891
 
23764
23892
  // src/map-brief.ts
@@ -24044,12 +24172,12 @@ function nextRoles(decision, ran) {
24044
24172
  }
24045
24173
 
24046
24174
  // 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";
24175
+ import { existsSync as existsSync43, mkdirSync as mkdirSync32, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync36 } from "fs";
24176
+ import { join as join50 } from "path";
24049
24177
  var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
24050
24178
  var DEFAULT_NOOP_REPEATS = 3;
24051
24179
  var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
24052
- var noopRunsPath = (stateDir) => join49(stateDir, "noop-runs.json");
24180
+ var noopRunsPath = (stateDir) => join50(stateDir, "noop-runs.json");
24053
24181
  var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
24054
24182
  function readNoopRuns(stateDir) {
24055
24183
  try {
@@ -24060,9 +24188,9 @@ function readNoopRuns(stateDir) {
24060
24188
  }
24061
24189
  }
24062
24190
  function writeNoopRuns(stateDir, state) {
24063
- mkdirSync31(stateDir, { recursive: true });
24191
+ mkdirSync32(stateDir, { recursive: true });
24064
24192
  const file = noopRunsPath(stateDir);
24065
- writeFileSync35(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
24193
+ writeFileSync36(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
24066
24194
  `);
24067
24195
  renameSync8(`${file}.tmp`, file);
24068
24196
  }
@@ -24144,7 +24272,7 @@ async function settleNoopRun(o) {
24144
24272
  }
24145
24273
 
24146
24274
  // src/ship-name.ts
24147
- import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync36 } from "fs";
24275
+ import { existsSync as existsSync44, mkdirSync as mkdirSync33, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync37 } from "fs";
24148
24276
  import { dirname as dirname27 } from "path";
24149
24277
  import { parseDocument as parseDocument4 } from "yaml";
24150
24278
  var ShipNameError = class extends Error {
@@ -24224,9 +24352,9 @@ function writeSyncedName(resolvedFile, name) {
24224
24352
  }
24225
24353
  if (raw.shipName === name) return;
24226
24354
  raw.shipName = name;
24227
- mkdirSync32(dirname27(resolvedFile), { recursive: true });
24355
+ mkdirSync33(dirname27(resolvedFile), { recursive: true });
24228
24356
  const tmp = `${resolvedFile}.tmp${process.pid}`;
24229
- writeFileSync36(tmp, `${JSON.stringify(raw, null, 2)}
24357
+ writeFileSync37(tmp, `${JSON.stringify(raw, null, 2)}
24230
24358
  `);
24231
24359
  renameSync9(tmp, resolvedFile);
24232
24360
  }
@@ -24258,7 +24386,7 @@ async function reconcileShipName(i) {
24258
24386
  if (result.status !== "ok") return result;
24259
24387
  if (result.action === "adopt" || result.action === "row-wins") {
24260
24388
  const text2 = readFileSync43(i.configFile, "utf8");
24261
- writeFileSync36(i.configFile, setShipNameInYaml(text2, result.name));
24389
+ writeFileSync37(i.configFile, setShipNameInYaml(text2, result.name));
24262
24390
  i.ship.name = result.name;
24263
24391
  if (result.action === "row-wins") {
24264
24392
  i.emit?.warn(
@@ -24306,7 +24434,7 @@ async function reconcileRouteShipName(o) {
24306
24434
  import { existsSync as existsSync45 } from "fs";
24307
24435
 
24308
24436
  // src/passenger-mirror.ts
24309
- import { mkdirSync as mkdirSync33 } from "fs";
24437
+ import { mkdirSync as mkdirSync34 } from "fs";
24310
24438
  import { dirname as dirname28 } from "path";
24311
24439
  function mirrorRepoOf(spec) {
24312
24440
  const fromOrigin = spec.originUrl ? parseRemote(spec.originUrl) : null;
@@ -24326,8 +24454,8 @@ async function materializeMirrorCheckouts(specs, cacheFor = (s) => new SandboxCa
24326
24454
  }
24327
24455
  try {
24328
24456
  const parent = dirname28(spec.dir);
24329
- mkdirSync33(parent, { recursive: true });
24330
- mkdirSync33(spec.dir, { recursive: true });
24457
+ mkdirSync34(parent, { recursive: true });
24458
+ mkdirSync34(spec.dir, { recursive: true });
24331
24459
  const r = await cacheFor(spec).materialize(repo, spec.base, parent, spec.name);
24332
24460
  out.push({ ...base, action: r.changed ? "updated" : "unchanged", detail: r.tip });
24333
24461
  } catch (e) {
@@ -24479,18 +24607,18 @@ function seatMissingProblems(route2, probes) {
24479
24607
 
24480
24608
  // src/ssh-keys.ts
24481
24609
  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";
24610
+ import { existsSync as existsSync46, mkdirSync as mkdirSync35, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
24611
+ import { dirname as dirname29, join as join51 } from "path";
24484
24612
  var SshKeyError = class extends Error {
24485
24613
  };
24486
24614
  function shipSshKeyPathFor(stateDir) {
24487
- return join50(stateDir, "ssh", "id_ed25519");
24615
+ return join51(stateDir, "ssh", "id_ed25519");
24488
24616
  }
24489
24617
  function ensureShipSshKeypair(stateDir) {
24490
24618
  const privateKeyPath = shipSshKeyPathFor(stateDir);
24491
24619
  const publicKeyPath = `${privateKeyPath}.pub`;
24492
24620
  if (!existsSync46(privateKeyPath)) {
24493
- mkdirSync34(dirname29(privateKeyPath), { recursive: true });
24621
+ mkdirSync35(dirname29(privateKeyPath), { recursive: true });
24494
24622
  try {
24495
24623
  execFileSync13("ssh-keygen", [
24496
24624
  "-t",
@@ -24528,7 +24656,7 @@ function sshKeygenAvailable() {
24528
24656
  // src/periscope-idle.ts
24529
24657
  import { execFileSync as execFileSync14 } from "child_process";
24530
24658
  import { statSync as statSync13 } from "fs";
24531
- import { join as join51 } from "path";
24659
+ import { join as join52 } from "path";
24532
24660
  var MAX_SCANNED_FILES = 2e4;
24533
24661
  function newestWorktreeMtime(root) {
24534
24662
  const a = newestTrackedMtime(root);
@@ -24553,7 +24681,7 @@ function newestTrackedMtime(root) {
24553
24681
  if (!rel) continue;
24554
24682
  if (++scanned > MAX_SCANNED_FILES) break;
24555
24683
  try {
24556
- const m = statSync13(join51(root, rel)).mtimeMs;
24684
+ const m = statSync13(join52(root, rel)).mtimeMs;
24557
24685
  if (newest === null || m > newest) newest = m;
24558
24686
  } catch {
24559
24687
  }
@@ -24627,8 +24755,8 @@ async function runPeriscopeIdlePass(d) {
24627
24755
  }
24628
24756
 
24629
24757
  // 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";
24758
+ import { existsSync as existsSync47, mkdirSync as mkdirSync36, readFileSync as readFileSync45, rmSync as rmSync22, writeFileSync as writeFileSync38 } from "fs";
24759
+ import { join as join53 } from "path";
24632
24760
  var PeriscopeError = class extends Error {
24633
24761
  };
24634
24762
  var LivePeriscopeError = class extends PeriscopeError {
@@ -24638,15 +24766,15 @@ var LivePeriscopeError = class extends PeriscopeError {
24638
24766
  this.data = { refused: "live_periscope_exists", ...live2 };
24639
24767
  }
24640
24768
  };
24641
- var priorDir = (stateDir) => join52(stateDir, "periscope-priors");
24642
- var priorPath = (stateDir, ticketRecordId) => join52(priorDir(stateDir), `${ticketRecordId}.json`);
24769
+ var priorDir = (stateDir) => join53(stateDir, "periscope-priors");
24770
+ var priorPath = (stateDir, ticketRecordId) => join53(priorDir(stateDir), `${ticketRecordId}.json`);
24643
24771
  function removePeriscopePrior(stateDir, ticketRecordId) {
24644
24772
  rmSync22(priorPath(stateDir, ticketRecordId), { force: true });
24645
24773
  }
24646
24774
  function writePeriscopePrior(stateDir, ticketRecordId, prior) {
24647
24775
  try {
24648
- mkdirSync35(priorDir(stateDir), { recursive: true });
24649
- writeFileSync37(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
24776
+ mkdirSync36(priorDir(stateDir), { recursive: true });
24777
+ writeFileSync38(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
24650
24778
  } catch {
24651
24779
  }
24652
24780
  }
@@ -25192,7 +25320,7 @@ function latestMtime(path) {
25192
25320
  if (!stat2.isDirectory()) return 0;
25193
25321
  let latest = stat2.mtimeMs;
25194
25322
  for (const entry of readdirSync15(path, { withFileTypes: true })) {
25195
- latest = Math.max(latest, latestMtime(join53(path, entry.name)));
25323
+ latest = Math.max(latest, latestMtime(join54(path, entry.name)));
25196
25324
  }
25197
25325
  return latest;
25198
25326
  }
@@ -25204,7 +25332,7 @@ function makeStaleChecker(paths, opts = {}) {
25204
25332
  return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync48(opts.reloadSentinel);
25205
25333
  }
25206
25334
  function reloadSentinelFor(stateDir) {
25207
- return join53(stateDir, "reload-requested");
25335
+ return join54(stateDir, "reload-requested");
25208
25336
  }
25209
25337
  function readReloadRequestedAt(stateDir) {
25210
25338
  try {
@@ -25214,12 +25342,12 @@ function readReloadRequestedAt(stateDir) {
25214
25342
  }
25215
25343
  }
25216
25344
  function daemonStampFor(stateDir) {
25217
- return join53(stateDir, "daemon.started");
25345
+ return join54(stateDir, "daemon.started");
25218
25346
  }
25219
25347
  function noteDaemonStarted(stateDir, now = Date.now()) {
25220
- mkdirSync36(stateDir, { recursive: true });
25348
+ mkdirSync37(stateDir, { recursive: true });
25221
25349
  rmSync23(reloadSentinelFor(stateDir), { force: true });
25222
- writeFileSync38(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
25350
+ writeFileSync39(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
25223
25351
  `);
25224
25352
  }
25225
25353
  function readDaemonStarted(stateDir) {
@@ -26286,12 +26414,12 @@ function startLaunchdDaemon(o) {
26286
26414
  }
26287
26415
 
26288
26416
  // 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";
26417
+ import { existsSync as existsSync50, mkdirSync as mkdirSync38, readFileSync as readFileSync49, unlinkSync as unlinkSync4, writeFileSync as writeFileSync40 } from "fs";
26418
+ import { dirname as dirname30, join as join55 } from "path";
26291
26419
  var DAEMON_START_FAILED_KEY = "daemon_start_failed";
26292
26420
  var START_FAILURE_BACKOFF_MS = 6e4;
26293
26421
  var BACKOFF_AFTER_FAILURES = 2;
26294
- var fileFor4 = (stateDir) => join54(stateDir, ".daemon-start-failure.json");
26422
+ var fileFor4 = (stateDir) => join55(stateDir, ".daemon-start-failure.json");
26295
26423
  function readStartFailure(stateDir) {
26296
26424
  try {
26297
26425
  const parsed = JSON.parse(readFileSync49(fileFor4(stateDir), "utf8"));
@@ -26310,8 +26438,8 @@ function noteStartFailure(stateDir, reason, nowMs = Date.now()) {
26310
26438
  firstAt: same2 ? previous.firstAt : nowIso,
26311
26439
  lastAt: nowIso
26312
26440
  };
26313
- mkdirSync37(stateDir, { recursive: true });
26314
- writeFileSync39(fileFor4(stateDir), JSON.stringify(record));
26441
+ mkdirSync38(stateDir, { recursive: true });
26442
+ writeFileSync40(fileFor4(stateDir), JSON.stringify(record));
26315
26443
  return record;
26316
26444
  }
26317
26445
  function startFailureDelayMs(count) {
@@ -26352,7 +26480,7 @@ async function reportStartFailure(o) {
26352
26480
  return delay;
26353
26481
  }
26354
26482
  function fallbackStateDir(configFile) {
26355
- return join54(dirname30(configFile), "state");
26483
+ return join55(dirname30(configFile), "state");
26356
26484
  }
26357
26485
 
26358
26486
  // src/projects-cmd.ts
@@ -26545,7 +26673,7 @@ function runForge(a, io) {
26545
26673
 
26546
26674
  // src/release-sandbox.ts
26547
26675
  import { execFile as execFile5 } from "child_process";
26548
- import { mkdirSync as mkdirSync38, writeFileSync as writeFileSync40 } from "fs";
26676
+ import { mkdirSync as mkdirSync39, writeFileSync as writeFileSync41 } from "fs";
26549
26677
  import { dirname as dirname31 } from "path";
26550
26678
  import { promisify as promisify4 } from "util";
26551
26679
  var execFileP4 = promisify4(execFile5);
@@ -26592,8 +26720,8 @@ async function openReleaseSandbox(o) {
26592
26720
  if (!policyFile) {
26593
26721
  generated = generateSandboxPolicy({ mirrorDir: cfg.mirrorDir, workDir: cfg.workDir, ...o.policy });
26594
26722
  policyFile = o.policyFile;
26595
- mkdirSync38(dirname31(policyFile), { recursive: true });
26596
- writeFileSync40(policyFile, generated.yaml, { mode: 384 });
26723
+ mkdirSync39(dirname31(policyFile), { recursive: true });
26724
+ writeFileSync41(policyFile, generated.yaml, { mode: 384 });
26597
26725
  }
26598
26726
  const secrets = { ...process.env };
26599
26727
  const secretKeys = [];
@@ -27927,12 +28055,13 @@ function describeCapability(i) {
27927
28055
 
27928
28056
  // src/persona-avatars.ts
27929
28057
  import { existsSync as existsSync52, readFileSync as readFileSync50 } from "fs";
27930
- import { join as join55 } from "path";
28058
+ import { join as join56 } from "path";
27931
28059
  var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
27932
28060
  function personaAvatarFile(promptsDir, role) {
28061
+ const stem = role === "release" ? "release-agent" : `lane-${role}`;
27933
28062
  for (const ext of ["png", "svg"]) {
27934
- const name = `lane-${role}.${ext}`;
27935
- const path = join55(promptsDir, "personas", name);
28063
+ const name = `${stem}.${ext}`;
28064
+ const path = join56(promptsDir, "personas", name);
27936
28065
  if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
27937
28066
  }
27938
28067
  return void 0;
@@ -27941,9 +28070,12 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
27941
28070
  if (!route2.resolved) return [];
27942
28071
  const base = `${route2.baseUrl.replace(/\/+$/, "")}/api/workspaces/${route2.resolved.workspaceId}/agents/personas`;
27943
28072
  const outcomes = [];
27944
- for (const role of ROLE_NAMES) {
28073
+ const targets = [
28074
+ ...ROLE_NAMES.map((role) => ({ role, agentId: agentPersonas[role]?.agentId })),
28075
+ { role: "release", agentId: opts.releaseAgentId }
28076
+ ];
28077
+ for (const { role, agentId } of targets) {
27945
28078
  const file = personaAvatarFile(route2.promptsDir, role);
27946
- const agentId = agentPersonas[role]?.agentId;
27947
28079
  if (!file || !agentId) continue;
27948
28080
  try {
27949
28081
  const form = new FormData();
@@ -27995,7 +28127,7 @@ function routeAvatarFailures(stateDir, route2) {
27995
28127
  }
27996
28128
 
27997
28129
  // src/agents-sync-run.ts
27998
- import { existsSync as existsSync53, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync41 } from "fs";
28130
+ import { existsSync as existsSync53, mkdirSync as mkdirSync40, readFileSync as readFileSync51, writeFileSync as writeFileSync42 } from "fs";
27999
28131
  import { dirname as dirname32 } from "path";
28000
28132
  async function runAgentsSync(target, o) {
28001
28133
  const dryRun = o.dryRun ?? false;
@@ -28031,8 +28163,8 @@ async function runAgentsSync(target, o) {
28031
28163
  for (const w of skillResult?.warnings ?? []) o.warn(`warning: ${w}`);
28032
28164
  const avatarFailures2 = {};
28033
28165
  if (!readOnly2 && !dryRun) {
28034
- for (const a of await syncPersonaAvatars(target, personaResult.agentPersonas, { userAgent: o.userAgent })) {
28035
- const line = describeAvatarOutcome(a, PERSONA_NAME[a.role]);
28166
+ for (const a of await syncPersonaAvatars(target, personaResult.agentPersonas, { userAgent: o.userAgent, releaseAgentId: personaResult.releaseAgentId })) {
28167
+ const line = describeAvatarOutcome(a, a.role === "release" ? RELEASE_AGENT_NAME : PERSONA_NAME[a.role]);
28036
28168
  if (a.status === "failed") {
28037
28169
  o.warn(`warning: ${line}`);
28038
28170
  avatarFailures2[a.role] = a.detail ?? "unknown error";
@@ -28046,8 +28178,8 @@ async function runAgentsSync(target, o) {
28046
28178
  if (skillResult) raw.agentSkills = skillResult.agentSkills;
28047
28179
  if (!readOnly2) raw.avatarSyncFailures = avatarFailures2;
28048
28180
  if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
28049
- mkdirSync39(dirname32(resolvedPath), { recursive: true });
28050
- writeFileSync41(resolvedPath, `${JSON.stringify(raw, null, 2)}
28181
+ mkdirSync40(dirname32(resolvedPath), { recursive: true });
28182
+ writeFileSync42(resolvedPath, `${JSON.stringify(raw, null, 2)}
28051
28183
  `);
28052
28184
  if (target.resolved) {
28053
28185
  target.resolved.agentPersonas = personaResult.agentPersonas;
@@ -28184,10 +28316,10 @@ async function showLogEntry(route2, entryId, opts = {}) {
28184
28316
 
28185
28317
  // src/repo-setup-prompt.ts
28186
28318
  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");
28319
+ import { join as join57 } from "path";
28320
+ var REPO_SETUP_PROMPT_PATH = join57("docs", "repo-setup-prompt.md");
28189
28321
  function readRepoSetupPrompt(crewHome) {
28190
- return readFileSync52(join56(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
28322
+ return readFileSync52(join57(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
28191
28323
  }
28192
28324
 
28193
28325
  // src/repos-check.ts
@@ -28697,7 +28829,7 @@ ${run4.err}` });
28697
28829
  }
28698
28830
 
28699
28831
  // src/sample-ticket.ts
28700
- import { basename as basename13, dirname as dirname33, join as join57 } from "path";
28832
+ import { basename as basename13, dirname as dirname33, join as join58 } from "path";
28701
28833
  var SAMPLE_REPO = "crew-sample";
28702
28834
  var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
28703
28835
  var SAMPLE_MARKER = "sample: true";
@@ -28720,8 +28852,8 @@ has something safe to work on: its test and build hooks always pass, it has no
28720
28852
  remote, and \`crew sample-ticket --remove\` deletes it.
28721
28853
  `;
28722
28854
  function sampleDir(existing, reposBase, workspace) {
28723
- if (existing.length > 0) return join57(dirname33(existing[0]), SAMPLE_REPO);
28724
- return join57(reposBase, workspace, SAMPLE_REPO);
28855
+ if (existing.length > 0) return join58(dirname33(existing[0]), SAMPLE_REPO);
28856
+ return join58(reposBase, workspace, SAMPLE_REPO);
28725
28857
  }
28726
28858
  var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
28727
28859
  function sampleDescription() {
@@ -28990,7 +29122,7 @@ function fixPhaseNothingToOffer(o) {
28990
29122
 
28991
29123
  // src/worktree-sweep.ts
28992
29124
  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";
29125
+ import { basename as basename14, dirname as dirname34, join as join59, resolve as resolve5 } from "path";
28994
29126
  function planWorktreeSweep(target, tickets, contract) {
28995
29127
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
28996
29128
  const verified = contract.statuses.verified;
@@ -29067,7 +29199,7 @@ function siblingWorktreeDirs(target) {
29067
29199
  for (const name of names) {
29068
29200
  if (!name.startsWith(stem)) continue;
29069
29201
  const m = DIR_NUMBER_SUFFIXED.exec(name);
29070
- const path = join58(parent, name);
29202
+ const path = join59(parent, name);
29071
29203
  if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
29072
29204
  }
29073
29205
  return out;
@@ -29300,13 +29432,13 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
29300
29432
 
29301
29433
  // src/stream-sweep.ts
29302
29434
  import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync16 } from "fs";
29303
- import { join as join59 } from "path";
29435
+ import { join as join60 } from "path";
29304
29436
  var DAY_MS2 = 24 * 60 * 60 * 1e3;
29305
29437
  function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
29306
- const dir = join59(stateDir, "streams");
29438
+ const dir = join60(stateDir, "streams");
29307
29439
  if (!existsSync55(dir)) return [];
29308
29440
  const cutoff = now - retentionDays * DAY_MS2;
29309
- return readdirSync17(dir).map((name) => join59(dir, name)).filter((path) => {
29441
+ return readdirSync17(dir).map((name) => join60(dir, name)).filter((path) => {
29310
29442
  try {
29311
29443
  return statSync16(path).mtimeMs < cutoff;
29312
29444
  } catch {
@@ -29334,7 +29466,7 @@ function applyStreamSweep(paths, dryRun, log) {
29334
29466
  function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
29335
29467
  if (!existsSync55(stateDir)) return [];
29336
29468
  const cutoff = now - retentionDays * DAY_MS2;
29337
- return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join59(stateDir, name)).filter((path) => {
29469
+ return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join60(stateDir, name)).filter((path) => {
29338
29470
  try {
29339
29471
  return statSync16(path).mtimeMs < cutoff;
29340
29472
  } catch {
@@ -29348,7 +29480,7 @@ function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
29348
29480
  if (!existsSync55(dir)) return;
29349
29481
  for (const name of readdirSync17(dir)) {
29350
29482
  if (!keep(name)) continue;
29351
- const path = join59(dir, name);
29483
+ const path = join60(dir, name);
29352
29484
  try {
29353
29485
  const st = statSync16(path);
29354
29486
  if (st.isFile()) files.push({ path, mtime: st.mtimeMs, size: st.size });
@@ -29356,7 +29488,7 @@ function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
29356
29488
  }
29357
29489
  }
29358
29490
  };
29359
- add(join59(stateDir, "streams"), () => true);
29491
+ add(join60(stateDir, "streams"), () => true);
29360
29492
  add(stateDir, (name) => ROTATED_EVENTS_RE.test(name));
29361
29493
  let total = files.reduce((n, f2) => n + f2.size, 0);
29362
29494
  const out = [];
@@ -29376,7 +29508,7 @@ function planStateSweep(stateDir, retentionDays, maxBytes, now = Date.now()) {
29376
29508
  }
29377
29509
 
29378
29510
  // 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";
29511
+ 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
29512
  import { createInterface } from "readline/promises";
29381
29513
 
29382
29514
  // src/periscope-resume.ts
@@ -29453,9 +29585,9 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29453
29585
 
29454
29586
  // src/bundle-staleness.ts
29455
29587
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29456
- import { join as join60 } from "path";
29588
+ import { join as join61 } from "path";
29457
29589
  function builtVersion() {
29458
- return true ? "0.165.0" : null;
29590
+ return true ? "0.165.2" : null;
29459
29591
  }
29460
29592
  var REBUILD_HINT = "rebuild with npm run build";
29461
29593
  function newestMtime(path) {
@@ -29468,17 +29600,17 @@ function newestMtime(path) {
29468
29600
  if (stat2.isFile()) return stat2.mtimeMs;
29469
29601
  if (!stat2.isDirectory()) return 0;
29470
29602
  let latest = stat2.mtimeMs;
29471
- for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join60(path, e.name)));
29603
+ for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join61(path, e.name)));
29472
29604
  return latest;
29473
29605
  }
29474
29606
  function bundleStaleness(i) {
29475
29607
  if (i.built === null || i.compiled) return null;
29476
- const src = join60(i.home, "src");
29608
+ const src = join61(i.home, "src");
29477
29609
  if (!existsSync56(src)) return null;
29478
29610
  if (i.built !== i.current) {
29479
29611
  return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
29480
29612
  }
29481
- const bundle = statSafe(join60(i.home, "dist", "cli.js"));
29613
+ const bundle = statSafe(join61(i.home, "dist", "cli.js"));
29482
29614
  if (bundle === null) return null;
29483
29615
  if (newestMtime(src) > bundle) {
29484
29616
  return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
@@ -29696,8 +29828,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
29696
29828
  import { createServer as createHttpServer } from "http";
29697
29829
  import { spawn as spawn10 } from "child_process";
29698
29830
  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";
29831
+ import { existsSync as existsSync57, mkdirSync as mkdirSync41, readFileSync as readFileSync55, writeFileSync as writeFileSync43, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
29832
+ import { join as join62 } from "path";
29701
29833
 
29702
29834
  // src/secret-compare.ts
29703
29835
  import { timingSafeEqual } from "crypto";
@@ -29790,7 +29922,7 @@ var defaultSpawn2 = (cmd, args, env) => {
29790
29922
  return child;
29791
29923
  };
29792
29924
  function syncDaemonStatePath(stateDir, workspaceId) {
29793
- return join61(stateDir, "passengers", `${workspaceId}-sync.json`);
29925
+ return join62(stateDir, "passengers", `${workspaceId}-sync.json`);
29794
29926
  }
29795
29927
  function readPersistedSyncDaemon(stateDir, workspaceId) {
29796
29928
  const path = syncDaemonStatePath(stateDir, workspaceId);
@@ -29803,8 +29935,8 @@ function readPersistedSyncDaemon(stateDir, workspaceId) {
29803
29935
  }
29804
29936
  function writePersistedSyncDaemon(stateDir, state) {
29805
29937
  const path = syncDaemonStatePath(stateDir, state.workspaceId);
29806
- mkdirSync40(join61(stateDir, "passengers"), { recursive: true });
29807
- writeFileSync42(path, `${JSON.stringify(state, null, 2)}
29938
+ mkdirSync41(join62(stateDir, "passengers"), { recursive: true });
29939
+ writeFileSync43(path, `${JSON.stringify(state, null, 2)}
29808
29940
  `);
29809
29941
  }
29810
29942
  function removePersistedSyncDaemon(stateDir, workspaceId) {
@@ -29824,7 +29956,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
29824
29956
  }
29825
29957
  }
29826
29958
  function readAllPersistedSyncWorkspaceIds(stateDir) {
29827
- const dir = join61(stateDir, "passengers");
29959
+ const dir = join62(stateDir, "passengers");
29828
29960
  if (!existsSync57(dir)) return [];
29829
29961
  const suffix = "-sync.json";
29830
29962
  return readdirSync19(dir).filter((f2) => f2.endsWith(suffix)).map((f2) => f2.slice(0, -suffix.length));
@@ -29884,7 +30016,7 @@ function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
29884
30016
 
29885
30017
  // src/periscope-proxy.ts
29886
30018
  import { spawn as spawn11 } from "child_process";
29887
- import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "fs";
30019
+ import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync42 } from "fs";
29888
30020
  import { createServer, request as httpRequest } from "http";
29889
30021
  import { request as httpsRequest } from "https";
29890
30022
  import { connect as netConnect } from "net";
@@ -30003,7 +30135,7 @@ function parsePointedBody(raw) {
30003
30135
  return entry;
30004
30136
  }
30005
30137
  function appendPointed(file, entry, now = /* @__PURE__ */ new Date()) {
30006
- mkdirSync41(dirname35(file), { recursive: true });
30138
+ mkdirSync42(dirname35(file), { recursive: true });
30007
30139
  appendFileSync4(file, `${JSON.stringify({ ...entry, at: now.toISOString() })}
30008
30140
  `);
30009
30141
  }
@@ -30292,7 +30424,7 @@ async function startWorktreeIntel(d) {
30292
30424
  }
30293
30425
 
30294
30426
  // src/contract-refusal.ts
30295
- import { join as join62 } from "path";
30427
+ import { join as join63 } from "path";
30296
30428
  function contractFixers(dir, baseRef, tickets, locate) {
30297
30429
  const out = [];
30298
30430
  for (const t of tickets) {
@@ -30304,7 +30436,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
30304
30436
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
30305
30437
  if (text2 === null) continue;
30306
30438
  try {
30307
- parseRepoConfig(text2, join62(dir, file));
30439
+ parseRepoConfig(text2, join63(dir, file));
30308
30440
  } catch (e) {
30309
30441
  if (e instanceof RepoConfigError) continue;
30310
30442
  throw e;
@@ -30330,7 +30462,7 @@ import {
30330
30462
  } from "fs";
30331
30463
  import { createConnection } from "net";
30332
30464
  import { createServer as createServer2 } from "http";
30333
- import { basename as basename15, dirname as dirname36, join as join63 } from "path";
30465
+ import { basename as basename15, dirname as dirname36, join as join64 } from "path";
30334
30466
  import { execFile as execFile6, spawn as spawn13 } from "child_process";
30335
30467
 
30336
30468
  // src/periscope-control.ts
@@ -30568,7 +30700,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
30568
30700
  // src/control-api.ts
30569
30701
  var PAUSABLE = ["dev", "design", "qa"];
30570
30702
  var CONTROL_SOCKET_NAME = "control.sock";
30571
- var controlSocketFor = (stateDir) => join63(stateDir, CONTROL_SOCKET_NAME);
30703
+ var controlSocketFor = (stateDir) => join64(stateDir, CONTROL_SOCKET_NAME);
30572
30704
  var MAX_SOCKET_PATH = 100;
30573
30705
  var MAX_TAIL_BYTES = 1024 * 1024;
30574
30706
  var MAX_WAIT_SECONDS = 30;
@@ -30655,7 +30787,7 @@ function candidates(live2, rotated) {
30655
30787
  const out = [live2];
30656
30788
  if (!rotated) return out;
30657
30789
  try {
30658
- for (const n of readdirSync20(dirname36(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join63(dirname36(live2), n));
30790
+ for (const n of readdirSync20(dirname36(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join64(dirname36(live2), n));
30659
30791
  } catch {
30660
30792
  }
30661
30793
  return out;
@@ -30914,7 +31046,7 @@ async function route(deps, method, url, req, abort) {
30914
31046
  if (p.startsWith("/streams/") && get2) {
30915
31047
  const run4 = decodeURIComponent(p.slice("/streams/".length));
30916
31048
  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`);
31049
+ const file = join64(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
30918
31050
  if (!existsSync58(file)) return err2(404, "no such run");
30919
31051
  return tailReply(file, url.searchParams, false, abort);
30920
31052
  }
@@ -31082,24 +31214,24 @@ function crewJson(args, timeoutMs = CREW_JSON_TIMEOUT_MS) {
31082
31214
 
31083
31215
  // src/periscope-mcp.ts
31084
31216
  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";
31217
+ import { basename as basename16, dirname as dirname37, isAbsolute as isAbsolute5, join as join66, relative as relative2, resolve as resolve6, sep } from "path";
31086
31218
  import { z } from "zod";
31087
31219
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
31088
31220
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
31089
31221
 
31090
31222
  // src/periscope-endpoints.ts
31091
31223
  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`);
31224
+ import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync43, readdirSync as readdirSync21, readFileSync as readFileSync56, rmSync as rmSync26, writeFileSync as writeFileSync44 } from "fs";
31225
+ import { join as join65 } from "path";
31226
+ var secretDir = (stateDir) => join65(stateDir, "periscope-mcp");
31227
+ var secretFile = (stateDir, id) => join65(secretDir(stateDir), `${id}.json`);
31228
+ var endpointDir = (stateDir) => join65(stateDir, "periscope-endpoints");
31229
+ var endpointFile = (stateDir, id) => join65(endpointDir(stateDir), `${id}.json`);
31098
31230
  function mintPeriscopeSecret(stateDir, ticketRecordId) {
31099
- mkdirSync42(secretDir(stateDir), { recursive: true, mode: 448 });
31231
+ mkdirSync43(secretDir(stateDir), { recursive: true, mode: 448 });
31100
31232
  const secret = randomBytes3(32).toString("base64url");
31101
31233
  const file = secretFile(stateDir, ticketRecordId);
31102
- writeFileSync43(file, `${JSON.stringify({ secret })}
31234
+ writeFileSync44(file, `${JSON.stringify({ secret })}
31103
31235
  `, { mode: 384 });
31104
31236
  chmodSync5(file, 384);
31105
31237
  return secret;
@@ -31123,8 +31255,8 @@ function readPeriscopeEndpoint(stateDir, ticketRecordId) {
31123
31255
  }
31124
31256
  }
31125
31257
  function writePeriscopeEndpoint(stateDir, rec) {
31126
- mkdirSync42(endpointDir(stateDir), { recursive: true });
31127
- writeFileSync43(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
31258
+ mkdirSync43(endpointDir(stateDir), { recursive: true });
31259
+ writeFileSync44(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
31128
31260
  `);
31129
31261
  }
31130
31262
  function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
@@ -31235,13 +31367,13 @@ async function resolveInWorktree(root, requested) {
31235
31367
  let abs;
31236
31368
  if (isAbsolute5(requested)) {
31237
31369
  abs = resolve6(requested);
31238
- if (isInside(root, abs)) abs = join65(realRoot, relative2(root, abs));
31370
+ if (isInside(root, abs)) abs = join66(realRoot, relative2(root, abs));
31239
31371
  } else {
31240
31372
  abs = resolve6(realRoot, requested);
31241
31373
  }
31242
31374
  if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
31243
31375
  const { real, rest } = await realAncestor(abs);
31244
- const final = rest ? join65(real, rest) : real;
31376
+ const final = rest ? join66(real, rest) : real;
31245
31377
  if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
31246
31378
  if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
31247
31379
  return final;
@@ -31309,7 +31441,7 @@ function createPeriscopeMcpServer(d, sc) {
31309
31441
  const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
31310
31442
  const lines2 = await Promise.all(entries.map(async (e) => {
31311
31443
  if (e.isDirectory()) return `[DIR] ${e.name}`;
31312
- const size = (await lstat(join65(abs, e.name))).size;
31444
+ const size = (await lstat(join66(abs, e.name))).size;
31313
31445
  return `[FILE] ${e.name} (${size} bytes)`;
31314
31446
  }));
31315
31447
  return text(lines2.join("\n") || "(empty)");
@@ -31375,7 +31507,7 @@ function createPeriscopeMcpServer(d, sc) {
31375
31507
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
31376
31508
  }, async ({ path }) => {
31377
31509
  const parent = await inTree(dirname37(path) === "" ? "." : dirname37(path));
31378
- const abs = join65(parent, basename16(path));
31510
+ const abs = join66(parent, basename16(path));
31379
31511
  if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
31380
31512
  const st = await lstat(abs).catch(() => void 0);
31381
31513
  if (!st) return text(`${path} does not exist`, true);
@@ -32279,7 +32411,7 @@ if (command === "passenger-sync-daemon") {
32279
32411
  stateDir: cfg.ship.stateDir,
32280
32412
  configFile: cfg.configFile,
32281
32413
  readFile: (p) => readFileSync57(p, "utf8"),
32282
- writeFile: (p, t) => writeFileSync44(p, t),
32414
+ writeFile: (p, t) => writeFileSync45(p, t),
32283
32415
  stdin: () => readFileSync57(0, "utf8"),
32284
32416
  env: process.env
32285
32417
  }
@@ -32612,7 +32744,7 @@ if (command === "passenger-sync-daemon") {
32612
32744
  for (const l of summarizeJobs(results, { dryRun, verbose: flag("verbose"), host })) emit.emit(l);
32613
32745
  if (host === "linux" && hasSystemd) {
32614
32746
  const label = labelFor(CREW_HOME, "run");
32615
- const staleTimer = join66(homedir11(), ".config", "systemd", "user", `${label}.timer`);
32747
+ const staleTimer = join67(homedir11(), ".config", "systemd", "user", `${label}.timer`);
32616
32748
  if (existsSync60(staleTimer)) {
32617
32749
  emit.emit(
32618
32750
  `removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run, not applied)" : ""}`
@@ -32732,7 +32864,7 @@ if (command === "passenger-sync-daemon") {
32732
32864
  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
32865
  } else if (a.kind === "enable") {
32734
32866
  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));
32867
+ writeFileSync45(cfg.configFile, planEnable(readFileSync57(cfg.configFile, "utf8"), a.route));
32736
32868
  enabledSound.add(a.route);
32737
32869
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
32738
32870
  } else {
@@ -32977,7 +33109,7 @@ ${changed2.map((c) => ` - ${c}
32977
33109
  harnessBin: "claude",
32978
33110
  ...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
32979
33111
  },
32980
- policyFile: join66(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
33112
+ policyFile: join67(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
32981
33113
  repo: mirror,
32982
33114
  origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
32983
33115
  base: effective.branch.base,
@@ -33234,6 +33366,7 @@ ${changed2.map((c) => ` - ${c}
33234
33366
  remit.warn(`could not read hand-back events; not deferring any branch: ${e.message}`);
33235
33367
  }
33236
33368
  }
33369
+ const claimed = /* @__PURE__ */ new Map();
33237
33370
  const outcome = await runRelease({
33238
33371
  cwd: target.dir,
33239
33372
  repo,
@@ -33275,6 +33408,20 @@ ${changed2.map((c) => ` - ${c}
33275
33408
  mergeOnly: command === "merge",
33276
33409
  // ci_* modes: record the merge on the board when it lands on base,
33277
33410
  // not only once CI confirms the release live (CREW-2820).
33411
+ // CREW-3811: the release seat holds a ticket while it merges and ships it.
33412
+ onClaim: async (ticket) => {
33413
+ const seat = releaseSeat(c);
33414
+ if (!seat || ticket.assignee_id === seat) return;
33415
+ const prior = ticket.assignee_id ?? null;
33416
+ await tracker.postEvent(ticket.id, "release took the ticket while it merges and ships it", seat, RELEASE_CLAIMED_EVENT, { prior_assignee: prior });
33417
+ claimed.set(ticket.id, prior);
33418
+ await tracker.updateTicket(ticket.id, { [tracker.contract.columns.assignee]: seat });
33419
+ },
33420
+ onUnclaim: async (ticket) => {
33421
+ if (!claimed.has(ticket.id)) return;
33422
+ await tracker.updateTicket(ticket.id, { [tracker.contract.columns.assignee]: claimed.get(ticket.id) ?? null });
33423
+ claimed.delete(ticket.id);
33424
+ },
33278
33425
  onBasePushed: async (merged) => {
33279
33426
  remit.enter("reconcile");
33280
33427
  await applyMergeStamp(
@@ -33313,7 +33460,7 @@ ${changed2.map((c) => ` - ${c}
33313
33460
  ...outcome.merged.map((m) => [m.ticket.issue_id, m.sha])
33314
33461
  ])
33315
33462
  );
33316
- if (plan.length) await applyStamp(tracker, plan, outcome.version, tracker.contract, remit, dryRun, target.dir);
33463
+ if (plan.length) await applyStamp(tracker, plan, outcome.version, tracker.contract, remit, dryRun, target.dir, releaseSeat(c));
33317
33464
  } else if (outcome.stopped) {
33318
33465
  remit.emit(`nothing stamped \u2014 ${outcome.stopped}`);
33319
33466
  }
@@ -33329,7 +33476,8 @@ ${changed2.map((c) => ` - ${c}
33329
33476
  tracker.contract,
33330
33477
  remit,
33331
33478
  dryRun,
33332
- target.dir
33479
+ target.dir,
33480
+ releaseSeat(c)
33333
33481
  );
33334
33482
  }
33335
33483
  for (const r of planReleasedBranches(
@@ -33348,7 +33496,8 @@ ${changed2.map((c) => ` - ${c}
33348
33496
  tracker.contract,
33349
33497
  remit,
33350
33498
  dryRun,
33351
- target.dir
33499
+ target.dir,
33500
+ releaseSeat(c)
33352
33501
  );
33353
33502
  }
33354
33503
  if (outcome.gateRed && !dryRun) {
@@ -34344,7 +34493,7 @@ ${f2.tail.trimEnd()}
34344
34493
  logFile: cfg.ship.logFile
34345
34494
  });
34346
34495
  }
34347
- const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join66(CREW_HOME, "src"), join66(CREW_HOME, "dist"), join66(CREW_HOME, "bin")];
34496
+ const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join67(CREW_HOME, "src"), join67(CREW_HOME, "dist"), join67(CREW_HOME, "bin")];
34348
34497
  const configPaths = daemonConfigPaths(cfg);
34349
34498
  watchPaths.push(...configPaths);
34350
34499
  noteDaemonStarted(cfg.ship.stateDir);
@@ -34655,8 +34804,8 @@ ${f2.tail.trimEnd()}
34655
34804
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
34656
34805
  const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync57(resolvedPath, "utf8")) : {};
34657
34806
  raw.agentSkills = result.agentSkills;
34658
- mkdirSync43(dirOf2(resolvedPath), { recursive: true });
34659
- writeFileSync44(resolvedPath, `${JSON.stringify(raw, null, 2)}
34807
+ mkdirSync44(dirOf2(resolvedPath), { recursive: true });
34808
+ writeFileSync45(resolvedPath, `${JSON.stringify(raw, null, 2)}
34660
34809
  `);
34661
34810
  }
34662
34811
  if (result.outcomes.some((o) => o.action === "diverged")) process.exitCode = 1;
@@ -34677,7 +34826,7 @@ ${f2.tail.trimEnd()}
34677
34826
  throw e;
34678
34827
  }
34679
34828
  const oldName = cfg.ship.name;
34680
- writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), newName));
34829
+ writeFileSync45(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), newName));
34681
34830
  cfg.ship.name = newName;
34682
34831
  let renameMachineId;
34683
34832
  try {
@@ -34805,19 +34954,19 @@ ${f2.tail.trimEnd()}
34805
34954
  let cleared;
34806
34955
  if (clear2) {
34807
34956
  const plan = clearRouteHooks(configText, a.route, a.name);
34808
- if (plan.removed.length > 0) writeFileSync44(cfg.configFile, plan.text);
34957
+ if (plan.removed.length > 0) writeFileSync45(cfg.configFile, plan.text);
34809
34958
  cleared = { file: cfg.configFile, removed: plan.removed };
34810
34959
  }
34811
34960
  if (write && suggestion.source === null && recipeIds.length === 0 && hookSpecs.length === 0) throw new ReposError(`nothing to write: ${suggestion.notes[0]}`);
34812
34961
  if (write === "route") {
34813
34962
  const plan = planRouteHooks(configText, a.route, a.name, picked.hooks, { replace: flag("replace") });
34814
- writeFileSync44(cfg.configFile, plan.text);
34963
+ writeFileSync45(cfg.configFile, plan.text);
34815
34964
  written = { target: "route", file: cfg.configFile, hooks: plan.written, kept: plan.kept, replaced: plan.replaced };
34816
34965
  } else if (write === "repo") {
34817
34966
  const have = existingRepoConfig(files);
34818
34967
  if (have) throw new ReposError(`${resolvePath(dir, have)} already exists; not overwriting it`);
34819
34968
  const file = resolvePath(dir, ".crew.yaml");
34820
- writeFileSync44(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
34969
+ writeFileSync45(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
34821
34970
  written = { target: "repo", file, hooks: Object.keys(picked.hooks), kept: [], replaced: [] };
34822
34971
  }
34823
34972
  if (flag("json")) {
@@ -34978,7 +35127,7 @@ ${f2.tail.trimEnd()}
34978
35127
  throw new ReposError(`${e.message}${authHint}
34979
35128
  crew.yaml was not changed`);
34980
35129
  }
34981
- writeFileSync44(cfg.configFile, plan2.text);
35130
+ writeFileSync45(cfg.configFile, plan2.text);
34982
35131
  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
35132
  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
35133
  break;
@@ -35072,11 +35221,11 @@ would need a project first: the tracker has none (\`crew projects add NAME --pre
35072
35221
  const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
35073
35222
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
35074
35223
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
35075
- writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
35224
+ writeFileSync45(resolvedFile, `${JSON.stringify(raw, null, 2)}
35076
35225
  `);
35077
35226
  }
35078
35227
  }
35079
- writeFileSync44(cfg.configFile, plan.text);
35228
+ writeFileSync45(cfg.configFile, plan.text);
35080
35229
  process.stdout.write(`added ${top} to ${routeName} as ${plan.mode === "dir" ? "dir" : `repos.${plan.name}`} in ${cfg.configFile}
35081
35230
  `);
35082
35231
  } catch (e) {
@@ -35428,7 +35577,7 @@ Waiting for approval`
35428
35577
  ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, then run `crew connect` again");
35429
35578
  }
35430
35579
  if (found.shipNameAdopted && !dryRun) {
35431
- writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), found.shipNameAdopted));
35580
+ writeFileSync45(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), found.shipNameAdopted));
35432
35581
  cfg.ship.name = found.shipNameAdopted;
35433
35582
  }
35434
35583
  if (found.shipRow) {
@@ -35618,10 +35767,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
35618
35767
  process.stderr.write(`(dry run) would write resolved ids to ${resolvedPath}
35619
35768
  `);
35620
35769
  } else {
35621
- mkdirSync43(dirname38(resolvedPath), { recursive: true });
35770
+ mkdirSync44(dirname38(resolvedPath), { recursive: true });
35622
35771
  if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
35623
35772
  const tmpPath = `${resolvedPath}.tmp${process.pid}`;
35624
- writeFileSync44(tmpPath, `${JSON.stringify(resolved, null, 2)}
35773
+ writeFileSync45(tmpPath, `${JSON.stringify(resolved, null, 2)}
35625
35774
  `);
35626
35775
  renameSync10(tmpPath, resolvedPath);
35627
35776
  emit.note(`Resolved ids written to ${resolvedPath}`);
@@ -35688,8 +35837,8 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
35688
35837
  process.stderr.write(`(dry run) would write the API key to ${apiKeyFile}
35689
35838
  `);
35690
35839
  } else {
35691
- mkdirSync43(dirname38(apiKeyFile), { recursive: true });
35692
- writeFileSync44(apiKeyFile, `${apiKeyVar}=${apiKey}
35840
+ mkdirSync44(dirname38(apiKeyFile), { recursive: true });
35841
+ writeFileSync45(apiKeyFile, `${apiKeyVar}=${apiKey}
35693
35842
  `, { mode: 384 });
35694
35843
  routineLine(`API key written to ${apiKeyFile}`);
35695
35844
  }
@@ -36340,10 +36489,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
36340
36489
  startupSeconds: cfg.ship.intelStartupSeconds,
36341
36490
  prepare: async (path) => {
36342
36491
  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));
36492
+ const src = join67(repoWt.dir, f2);
36493
+ if (!existsSync60(src) || existsSync60(join67(path, f2))) continue;
36494
+ mkdirSync44(dirOf2(join67(path, f2)), { recursive: true });
36495
+ copyFileSync2(src, join67(path, f2));
36347
36496
  }
36348
36497
  const setup = repoWt.config.hooks.setup;
36349
36498
  return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
@@ -36670,10 +36819,10 @@ ${where.join("\n")}`);
36670
36819
  },
36671
36820
  prepare: async (path) => {
36672
36821
  for (const f2 of repoP.config.worktrees.copy) {
36673
- const src = join66(repoP.dir, f2);
36822
+ const src = join67(repoP.dir, f2);
36674
36823
  if (!existsSync60(src)) continue;
36675
- mkdirSync43(dirOf2(join66(path, f2)), { recursive: true });
36676
- copyFileSync2(src, join66(path, f2));
36824
+ mkdirSync44(dirOf2(join67(path, f2)), { recursive: true });
36825
+ copyFileSync2(src, join67(path, f2));
36677
36826
  }
36678
36827
  const setup = repoP.config.hooks.setup;
36679
36828
  return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
@@ -37141,8 +37290,8 @@ ${where.join("\n")}`);
37141
37290
  process.stdout.write("crew reload: no daemon unit is running \u2014 nothing to reload (the next run reads crew.yaml fresh)\n");
37142
37291
  break;
37143
37292
  }
37144
- mkdirSync43(cfg.ship.stateDir, { recursive: true });
37145
- writeFileSync44(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
37293
+ mkdirSync44(cfg.ship.stateDir, { recursive: true });
37294
+ writeFileSync45(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
37146
37295
  `);
37147
37296
  process.stdout.write(
37148
37297
  "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 +37406,7 @@ ${where.join("\n")}`);
37257
37406
  }
37258
37407
  if (configured2.some((r) => r.dir === dir)) {
37259
37408
  try {
37260
- writeFileSync44(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
37409
+ writeFileSync45(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
37261
37410
  } catch (e) {
37262
37411
  if (e instanceof ReposError) fail2(e.message);
37263
37412
  throw e;
@@ -37269,25 +37418,25 @@ ${where.join("\n")}`);
37269
37418
  const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
37270
37419
  if (raw.repoNames) delete raw.repoNames[row.id];
37271
37420
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
37272
- writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
37421
+ writeFileSync45(resolvedFile, `${JSON.stringify(raw, null, 2)}
37273
37422
  `);
37274
37423
  }
37275
37424
  }
37276
- if (existsSync60(join66(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
37425
+ if (existsSync60(join67(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
37277
37426
  say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
37278
37427
  break;
37279
37428
  }
37280
37429
  const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
37281
- const fresh = !existsSync60(join66(dir, ".git"));
37430
+ const fresh = !existsSync60(join67(dir, ".git"));
37282
37431
  if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
37283
37432
  if (dryRun) {
37284
37433
  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
37434
  break;
37286
37435
  }
37287
37436
  if (fresh) {
37288
- mkdirSync43(dir, { recursive: true });
37289
- writeFileSync44(join66(dir, "README.md"), SAMPLE_README);
37290
- writeFileSync44(join66(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
37437
+ mkdirSync44(dir, { recursive: true });
37438
+ writeFileSync45(join67(dir, "README.md"), SAMPLE_README);
37439
+ writeFileSync45(join67(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
37291
37440
  const g = (...a) => {
37292
37441
  const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
37293
37442
  if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
@@ -37309,13 +37458,13 @@ ${where.join("\n")}`);
37309
37458
  const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
37310
37459
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
37311
37460
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
37312
- writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
37461
+ writeFileSync45(resolvedFile, `${JSON.stringify(raw, null, 2)}
37313
37462
  `);
37314
37463
  }
37315
37464
  }
37316
37465
  if (!configured2.some((r) => r.dir === dir)) {
37317
37466
  try {
37318
- writeFileSync44(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
37467
+ writeFileSync45(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
37319
37468
  } catch (e) {
37320
37469
  if (e instanceof ReposError) fail2(e.message);
37321
37470
  throw e;