@tablation/crew 0.164.1 → 0.164.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
@@ -7275,7 +7275,7 @@ function noProjectsFinding(route2, projectCount) {
7275
7275
 
7276
7276
  // src/passenger-containers.ts
7277
7277
  import { execFileSync as execFileSync10 } from "child_process";
7278
- import { createHash as createHash7 } from "crypto";
7278
+ import { createHash as createHash8 } from "crypto";
7279
7279
 
7280
7280
  // src/sandbox-cache.ts
7281
7281
  import { execFile as execFile2 } from "child_process";
@@ -7357,7 +7357,7 @@ import { readFileSync as readFileSync31, existsSync as existsSync29, statSync as
7357
7357
  import { StringDecoder } from "string_decoder";
7358
7358
  import { finished } from "stream/promises";
7359
7359
  import { join as join34, dirname as dirname17, basename as basename9 } from "path";
7360
- import { createHash as createHash6, randomUUID as randomUUID2 } from "crypto";
7360
+ import { createHash as createHash7, randomUUID as randomUUID2 } from "crypto";
7361
7361
 
7362
7362
  // src/state.ts
7363
7363
  import { readFileSync as readFileSync21, writeFileSync as writeFileSync16, existsSync as existsSync20, mkdirSync as mkdirSync15, rmSync as rmSync11, statSync as statSync7, readdirSync as readdirSync6 } from "fs";
@@ -9512,6 +9512,7 @@ import { join as join28 } from "path";
9512
9512
  var sleepBackoff = (attempts) => Math.min(6e4 * 2 ** Math.max(0, attempts - 1), 30 * 6e4);
9513
9513
 
9514
9514
  // src/handoff-guard.ts
9515
+ import { createHash as createHash4 } from "crypto";
9515
9516
  import { existsSync as existsSync24, realpathSync as realpathSync2 } from "fs";
9516
9517
  import { dirname as dirname14, join as join27 } from "path";
9517
9518
 
@@ -11503,27 +11504,69 @@ function repairMisnamedBranch(dir, cfg, ticket, role) {
11503
11504
  const base = [`${cfg.branch.remote}/${cfg.branch.base}`, cfg.branch.base].find((b) => gitOk(dir, ["rev-parse", "--verify", "-q", b]) !== null);
11504
11505
  const ahead = base ? Number(gitOk(dir, ["rev-list", "--count", `${base}..${from}`]) ?? "1") : 1;
11505
11506
  if (ahead === 0) return { kind: "none" };
11506
- if (existing) {
11507
+ if (existing) return repairBehindContractBranch(dir, wt.path, from, existing, expected, cfg.branch.remote);
11508
+ try {
11509
+ git(dir, ["branch", "-m", from, expected]);
11510
+ } catch (e) {
11507
11511
  return {
11508
11512
  kind: "refused",
11509
11513
  from,
11510
- to: existing,
11514
+ to: expected,
11511
11515
  local: headSha(wt.path),
11512
- reason: `the ticket's worktree is on \`${from}\`, but the contract branch \`${existing}\` already exists and the runner will not overwrite it, so \`${from}\` was left as it is (expected name: \`${expected}\`)`
11516
+ reason: `the ticket's worktree is on \`${from}\`, not the expected \`${expected}\`, and renaming it failed: ${e.message}`
11517
+ };
11518
+ }
11519
+ return { kind: "renamed", from, to: expected };
11520
+ }
11521
+ function repairBehindContractBranch(dir, wtPath, from, to, expected, remote) {
11522
+ const head = headSha(wtPath);
11523
+ const toTip = gitOk(dir, ["rev-parse", "--verify", "-q", `refs/heads/${to}`]);
11524
+ const elsewhere = worktrees(dir).find((w) => w.branch === to && !w.prunable && !sameDir(w.path, wtPath));
11525
+ const named = to !== expected ? ` (expected name: \`${expected}\`)` : "";
11526
+ if (elsewhere) {
11527
+ return {
11528
+ kind: "refused",
11529
+ from,
11530
+ to,
11531
+ local: head,
11532
+ toTip,
11533
+ worktree: wtPath,
11534
+ reason: `the ticket's worktree is on \`${from}\` (at \`${head}\`), but the contract branch \`${to}\` is checked out in another worktree, \`${elsewhere.path}\`, so the runner cannot move it${named}`,
11535
+ fix: `git -C ${elsewhere.path} switch --detach # or: git worktree remove ${elsewhere.path}`
11536
+ };
11537
+ }
11538
+ if (!head || !toTip || !isAncestor(dir, toTip, head)) {
11539
+ const counts = toTip && head ? gitOk(dir, ["rev-list", "--left-right", "--count", `${to}...${head}`])?.split(/\s+/).map(Number) : void 0;
11540
+ const sides = counts && counts.length === 2 ? `\`${to}\` holds ${counts[0]} commit${counts[0] === 1 ? "" : "s"} the worktree's HEAD lacks, and HEAD holds ${counts[1]} that \`${to}\` lacks` : `the two could not be compared`;
11541
+ return {
11542
+ kind: "refused",
11543
+ from,
11544
+ to,
11545
+ local: head,
11546
+ toTip,
11547
+ worktree: wtPath,
11548
+ reason: `the ticket's worktree is on \`${from}\` at \`${head}\` and the contract branch \`${to}\` is at \`${toTip}\`: ${sides}. Nothing was moved or deleted${named}`,
11549
+ fix: `git -C ${wtPath} merge ${to} # resolve any conflict, commit, run the suite`
11513
11550
  };
11514
11551
  }
11515
11552
  try {
11516
- git(dir, ["branch", "-m", from, expected]);
11553
+ git(dir, ["branch", "-f", to, head]);
11554
+ git(wtPath, ["switch", to]);
11517
11555
  } catch (e) {
11518
11556
  return {
11519
11557
  kind: "refused",
11520
11558
  from,
11521
- to: expected,
11522
- local: headSha(wt.path),
11523
- reason: `the ticket's worktree is on \`${from}\`, not the expected \`${expected}\`, and renaming it failed: ${e.message}`
11559
+ to,
11560
+ local: head,
11561
+ toTip,
11562
+ reason: `the ticket's worktree is on \`${from}\` at \`${head}\`; \`${to}\` is only behind it, but moving the worktree onto it failed: ${e.message}`,
11563
+ fix: `git -C ${wtPath} switch ${to}`,
11564
+ worktree: wtPath
11524
11565
  };
11525
11566
  }
11526
- return { kind: "renamed", from, to: expected };
11567
+ gitOk(wtPath, ["branch", "--set-upstream-to", `${remote}/${to}`, to]);
11568
+ gitOk(dir, ["branch", "-D", from]);
11569
+ return { kind: "renamed", from, to };
11527
11570
  }
11528
11571
  async function announceRename(i, ticketId, r, sha, remote, log) {
11529
11572
  let remoteNote;
@@ -11553,9 +11596,26 @@ function describeHandoffPush(dir, cfg, ticket, role) {
11553
11596
  const v = inspectHandoff(dir, cfg, ticket, role);
11554
11597
  return v.kind === "bounce" && pushableBounce(dir, v) ? `would push ${v.branch} to ${v.remote}` : null;
11555
11598
  }
11556
- function bounceComment(v, shipName2, pushError) {
11557
- return `${HANDOFF_BOUNCED_MARKER}
11599
+ function bounceSignature(...parts) {
11600
+ return createHash4("sha256").update(parts.map((p) => p ?? "").join("\n")).digest("hex").slice(0, 12);
11601
+ }
11602
+ var SIGNATURE_RE = /Bounce signature: `([0-9a-f]{12})`/;
11603
+ var signatureLine = (sig) => `Bounce signature: \`${sig}\``;
11604
+ function repeatParagraph(what, change) {
11605
+ return `**This is the second bounce for exactly the same state.** The run since the last note changed nothing the guard checks: ${what}. Repeating the same hand-off will bounce again, and a third identical bounce parks this ticket for a person. ${change}
11558
11606
 
11607
+ `;
11608
+ }
11609
+ function bounceComment(v, shipName2, pushError, repeat) {
11610
+ const again = repeat?.second ? repeatParagraph(
11611
+ `the local HEAD is still ${v.local ? `\`${v.local}\`` : "(no local branch)"} and \`${v.remote}\` is still ${v.origin ? `\`${v.origin}\`` : "(without the branch)"}`,
11612
+ `Change it: run \`git rev-parse HEAD\` and \`git ls-remote ${v.remote} ${v.branch ?? "<branch>"}\` in the worktree, push the commit that is missing, and if git refuses the push, set \`needs_info\` quoting its error instead of handing off again.`
11613
+ ) : "";
11614
+ return `${HANDOFF_BOUNCED_MARKER}
11615
+ ${repeat ? `
11616
+ ${signatureLine(repeat.sig)}
11617
+ ` : ""}
11618
+ ${again}
11559
11619
  **Hand-off bounced: the branch is not on \`${v.remote}\` at the tip this ticket was built to.**
11560
11620
 
11561
11621
  ${shipName2 ? `Ship: ${shipName2}
@@ -11564,6 +11624,43 @@ ${shipName2 ? `Ship: ${shipName2}
11564
11624
 
11565
11625
  ${v.reason[0].toUpperCase()}${v.reason.slice(1)}. ${pushError ? ` The runner tried a plain push and git refused it: \`${pushError}\`.` : ""} Set back to \`in_progress\`, still held by this ship; push with a plain \`git push --set-upstream ${v.remote} <branch>\` (never \`--force\`) and set \`fixed\` again. Your brief authorizes this push: it is the hand-off, not a release, so do it now rather than asking for permission.`;
11566
11626
  }
11627
+ function refusalComment(r, remote, remoteContractTip, shipName2, repeat) {
11628
+ const remoteLine = remoteContractTip === null ? "(could not be asked)" : remoteContractTip ? `\`${remoteContractTip}\`` : "(no such branch)";
11629
+ const again = repeat.second ? repeatParagraph(
11630
+ `the worktree is still on \`${r.from}\` at ${r.local ? `\`${r.local}\`` : "(unknown)"} and \`${r.to}\` is still at ${r.toTip ? `\`${r.toTip}\`` : "(not local)"}`,
11631
+ `Run the commands below; handing off again without them leaves this exactly as it is.`
11632
+ ) : "";
11633
+ return `${HANDOFF_BOUNCED_MARKER}
11634
+
11635
+ ${signatureLine(repeat.sig)}
11636
+
11637
+ **Hand-off bounced: the ticket's worktree is on \`${r.from}\`, not on the contract branch \`${r.to}\`, and the runner could not rename it safely.**
11638
+
11639
+ ${shipName2 ? `Ship: ${shipName2}
11640
+ ` : ""}Worktree branch \`${r.from}\`: ${r.local ? `\`${r.local}\`` : "(unknown)"}
11641
+ Contract branch \`${r.to}\` (local): ${r.toTip ? `\`${r.toTip}\`` : "(not a local branch)"}
11642
+ \`${remote}/${r.to}\`: ${remoteLine}
11643
+
11644
+ ${again}${r.reason[0].toUpperCase()}${r.reason.slice(1)}.${r.fix ? `
11645
+
11646
+ Resolve it with:
11647
+
11648
+ \`\`\`
11649
+ ${r.fix}
11650
+ \`\`\`
11651
+
11652
+ then set \`fixed\` again: the runner moves \`${r.to}\` to the worktree's HEAD, switches the worktree onto it and pushes it as a plain fast-forward.` : ""} Nothing was forced and no commit was discarded. Set back to \`in_progress\`, still held by this ship.`;
11653
+ }
11654
+ async function identicalBounces(i, ticketRow, sig) {
11655
+ if (!i.writer.events) return 0;
11656
+ const evs = (await i.writer.events("bounced").catch(() => [])).filter((e) => e.record_id === ticketRow).sort((a, b) => (b.occurred_at ?? b.created_at ?? "").localeCompare(a.occurred_at ?? a.created_at ?? ""));
11657
+ let n = 0;
11658
+ for (const e of evs) {
11659
+ if (SIGNATURE_RE.exec(e.message ?? "")?.[1] !== sig) break;
11660
+ n++;
11661
+ }
11662
+ return n;
11663
+ }
11567
11664
  var NOTE_BUDGET = 4800;
11568
11665
  function boundNote(note, budget = NOTE_BUDGET) {
11569
11666
  if (note.length <= budget) return note;
@@ -11690,7 +11787,10 @@ async function enforceHandoff(i) {
11690
11787
  const repair = i.origin ? { kind: "none" } : repairMisnamedBranch(i.dir, i.cfg, t, i.role);
11691
11788
  const renamed = repair.kind === "renamed" ? repair : null;
11692
11789
  if (renamed) i.log.warn(`${displayKey(t)}: renamed the misnamed branch ${renamed.from} to ${renamed.to}`, log);
11693
- const v = repair.kind === "refused" ? { kind: "bounce", branch: null, remote: i.cfg.branch.remote, local: repair.local, origin: null, reason: repair.reason } : i.origin ? inspectRemoteHandoff(i.origin, i.cfg, t, i.role) : inspectHandoff(i.dir, i.cfg, t, i.role);
11790
+ const refusal = repair.kind === "refused" ? repair : null;
11791
+ const refusedTip = refusal && !i.origin ? remoteTip(i.dir, i.cfg.branch.remote, refusal.to) : null;
11792
+ const mismatch = refusal && refusedTip && refusedTip === refusal.local ? refusal : null;
11793
+ const v = mismatch ? { kind: "pushed", branch: mismatch.to, sha: refusedTip, remote: i.cfg.branch.remote } : refusal ? { kind: "bounce", branch: null, remote: i.cfg.branch.remote, local: refusal.local, origin: refusedTip || null, reason: refusal.reason } : i.origin ? inspectRemoteHandoff(i.origin, i.cfg, t, i.role) : inspectHandoff(i.dir, i.cfg, t, i.role);
11694
11794
  if (v.kind === "unverified") {
11695
11795
  i.log.warn(`${displayKey(t)} is at ${t.status} but the push was not checked: ${v.why}`, log);
11696
11796
  return { kind: "unverified", why: v.why };
@@ -11720,6 +11820,7 @@ async function enforceHandoff(i) {
11720
11820
  if (v.kind === "pushed") {
11721
11821
  await postPushed(i, t.id, v.sha, v.remote, v.branch, log);
11722
11822
  if (renamed) await announceRename(i, t.id, renamed, v.sha, v.remote, log);
11823
+ if (mismatch) await i.writer.postEvent(t.id, `The hand-off stands: \`${v.remote}/${mismatch.to}\` is at the worktree's HEAD (${v.sha}). Only the local branch name is off, and the runner left it alone: ${mismatch.reason}.${mismatch.fix ? ` To tidy it: \`${mismatch.fix}\`.` : ""}`, i.seatId, "branch_mismatch").catch((e) => i.log.warn(`the local branch mismatch note failed to post: ${e.message}`, log));
11723
11824
  i.log.emit(`${displayKey(t)} pushed at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, log);
11724
11825
  return { kind: "pushed", sha: v.sha };
11725
11826
  }
@@ -11771,7 +11872,30 @@ async function enforceHandoff(i) {
11771
11872
  } else pushError = done.error;
11772
11873
  if (pushError) i.log.warn(`${displayKey(t)}: the runner's own push failed: ${pushError}`, log);
11773
11874
  }
11774
- if (!await deliverNote(i, t.id, bounceComment(v, i.shipName, pushError), "bounced", log)) {
11875
+ const sig = refusal ? bounceSignature("refused", refusal.from, refusal.to, refusal.local, refusal.toTip, v.origin) : bounceSignature(v.reason, v.branch, v.local, v.origin);
11876
+ const earlier = await identicalBounces(i, t.id, sig);
11877
+ if (earlier >= 2) {
11878
+ const diagnosis = refusal ? `${refusal.reason}. ${refusal.fix ? `The commands that resolve it: \`${refusal.fix}\`.` : ""}` : `${v.reason}. Local HEAD ${v.local ? `\`${v.local}\`` : "(none)"}, \`${v.remote}\` ${v.origin ? `\`${v.origin}\`` : "(without the branch)"}${pushError ? `; the runner's own plain push failed: \`${pushError}\`` : ""}.`;
11879
+ const parked = `${HANDOFF_BOUNCED_MARKER}
11880
+
11881
+ **Parked: the same hand-off bounce happened ${earlier + 1} times in a row with nothing changing.**
11882
+
11883
+ ${diagnosis}
11884
+
11885
+ Needs a person to resolve the branch state above; set the status back to \`in_progress\` when done.`;
11886
+ if (await deliverNote(i, t.id, parked, "bounce_parked", log)) {
11887
+ await i.writer.updateTicket(t.id, {
11888
+ status: i.contract.statuses.needsHuman,
11889
+ assignee_id: i.parkTo ?? null,
11890
+ ...i.hold ? { [i.hold.column]: null } : {}
11891
+ });
11892
+ i.log.warn(`${displayKey(t)} parked for a person: the same hand-off bounce ${earlier + 1} times in a row`, log);
11893
+ return { kind: "bounced" };
11894
+ }
11895
+ }
11896
+ const repeat = { sig, second: earlier === 1 };
11897
+ const note = refusal ? refusalComment(refusal, v.remote, refusedTip, i.shipName, repeat) : bounceComment(v, i.shipName, pushError, repeat);
11898
+ if (!await deliverNote(i, t.id, note, "bounced", log)) {
11775
11899
  i.log.warn(`${displayKey(t)}: ${v.reason}, but the bounce note could not be delivered \u2014 left at ${t.status}, guard outcome unverified`, log);
11776
11900
  return { kind: "unverified", why: "the bounce note could not be posted" };
11777
11901
  }
@@ -11833,6 +11957,7 @@ async function guardRunHandoff(route2, ship, tracker, role, workingId, log, sinc
11833
11957
  cfg,
11834
11958
  seatId,
11835
11959
  shipName: ship.name,
11960
+ parkTo: route2.resolved?.operator,
11836
11961
  hold: affinity ? { column: affinity.column, shipId: affinity.shipId } : void 0,
11837
11962
  since: since2,
11838
11963
  log,
@@ -12887,7 +13012,7 @@ function seatNotesSection(notes) {
12887
13012
  }
12888
13013
 
12889
13014
  // src/sandbox-image.ts
12890
- import { createHash as createHash4 } from "crypto";
13015
+ import { createHash as createHash5 } from "crypto";
12891
13016
  import { spawn as spawn4 } from "child_process";
12892
13017
  import { execFileSync as execFileSync8 } from "child_process";
12893
13018
  import { existsSync as existsSync26, mkdirSync as mkdirSync20, readFileSync as readFileSync27, renameSync as renameSync5, writeFileSync as writeFileSync21, rmSync as rmSync16, statSync as statSync8 } from "fs";
@@ -12928,7 +13053,7 @@ echo "password=$CREW_FORGE_TOKEN"
12928
13053
  `;
12929
13054
  var MCP_CONFIG = `${JSON.stringify({ mcpServers: {} }, null, 2)}
12930
13055
  `;
12931
- var hash = (parts) => createHash4("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 12);
13056
+ var hash = (parts) => createHash5("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 12);
12932
13057
  var slug = (s) => s.toLowerCase().replace(/[^a-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
12933
13058
  var run2 = (cmd) => `RUN ["/bin/bash", "-c", ${JSON.stringify(`set -euo pipefail; ${cmd}`)}]`;
12934
13059
  var CREW_ENV = {
@@ -14104,7 +14229,7 @@ function skillMarkerWarnings(promptsDir, personaPrompts) {
14104
14229
  // src/runner.ts
14105
14230
  import { spawn as spawn5, execFile, execFileSync as execFileSync9 } from "child_process";
14106
14231
  import { mkdtempSync, mkdirSync as mkdirSync21, writeFileSync as writeFileSync22, rmSync as rmSync17 } from "fs";
14107
- import { createHash as createHash5 } from "crypto";
14232
+ import { createHash as createHash6 } from "crypto";
14108
14233
  import { tmpdir as tmpdir4 } from "os";
14109
14234
  import { basename as basename8, dirname as dirname16, join as join33 } from "path";
14110
14235
  import { promisify } from "util";
@@ -14200,7 +14325,7 @@ function shQuote2(s) {
14200
14325
  return `'${s.replace(/'/g, `'\\''`)}'`;
14201
14326
  }
14202
14327
  function sandboxName(plan, now = Date.now()) {
14203
- const h = createHash5("sha256").update([plan.route, plan.role, plan.ticket ?? ""].join("\0")).digest();
14328
+ const h = createHash6("sha256").update([plan.route, plan.role, plan.ticket ?? ""].join("\0")).digest();
14204
14329
  const tag = (h.readUInt32BE(0) % 36 ** 6).toString(36).padStart(6, "0");
14205
14330
  return `crew-${tag}${now.toString(36).slice(-8).padStart(8, "0")}`;
14206
14331
  }
@@ -14620,7 +14745,7 @@ function planAgentRun(o) {
14620
14745
  brief: expanded.text,
14621
14746
  digest
14622
14747
  });
14623
- const promptSha = createHash6("sha256").update(expanded.text).digest("hex");
14748
+ const promptSha = createHash7("sha256").update(expanded.text).digest("hex");
14624
14749
  const streamsDir = join34(o.stateDir, "streams");
14625
14750
  const base = `${routeLabel2}-${o.role}-${o.cycle}${o.runId ? `-${o.runId}` : ""}`;
14626
14751
  const seat = resolveSeat(o.ship, o.route, o.role, o.agentPersona ?? (o.agentModel ? { model: o.agentModel } : {}), o.repo);
@@ -16344,12 +16469,12 @@ function containerNameFor(workspaceId) {
16344
16469
  return `crew-passenger-${workspaceId}`;
16345
16470
  }
16346
16471
  function portFor(workspaceId, base = 28765, span = 1e3) {
16347
- const digest = createHash7("sha256").update(workspaceId).digest();
16472
+ const digest = createHash8("sha256").update(workspaceId).digest();
16348
16473
  return base + digest.readUInt32BE(0) % span;
16349
16474
  }
16350
16475
  function mountsDigest(mounts, image) {
16351
16476
  const sorted2 = [...mounts].sort((a, b) => a.containerPath.localeCompare(b.containerPath));
16352
- return createHash7("sha256").update(JSON.stringify({ mounts: sorted2, image })).digest("hex").slice(0, 16);
16477
+ return createHash8("sha256").update(JSON.stringify({ mounts: sorted2, image })).digest("hex").slice(0, 16);
16353
16478
  }
16354
16479
  function planContainers(cfg) {
16355
16480
  const byWorkspace = /* @__PURE__ */ new Map();
@@ -17850,13 +17975,13 @@ import { hostname as hostname3 } from "os";
17850
17975
 
17851
17976
  // src/machine-id.ts
17852
17977
  import { execFileSync as execFileSync12 } from "child_process";
17853
- import { createHash as createHash8 } from "crypto";
17978
+ import { createHash as createHash9 } from "crypto";
17854
17979
  import { existsSync as existsSync36, mkdirSync as mkdirSync27, readFileSync as readFileSync38, writeFileSync as writeFileSync29 } from "fs";
17855
17980
  import { dirname as dirname21, join as join42 } from "path";
17856
17981
  function machineIdPathFor(stateDir) {
17857
17982
  return join42(stateDir, "machine-id");
17858
17983
  }
17859
- var sha256 = (s) => createHash8("sha256").update(s).digest("hex");
17984
+ var sha256 = (s) => createHash9("sha256").update(s).digest("hex");
17860
17985
  function readRawMachineId(platform2 = process.platform) {
17861
17986
  try {
17862
17987
  if (platform2 === "darwin") {
@@ -27812,7 +27937,7 @@ async function runAgentsSync(target, o) {
27812
27937
  }
27813
27938
 
27814
27939
  // src/logbook.ts
27815
- import { createHash as createHash9 } from "crypto";
27940
+ import { createHash as createHash10 } from "crypto";
27816
27941
  import { TablationClient as TablationClient4 } from "@tablation/client";
27817
27942
  var LogbookError = class extends Error {
27818
27943
  };
@@ -27917,7 +28042,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
27917
28042
  };
27918
28043
  }
27919
28044
  const prompt = appendAdditions(match.prompt ?? "", match.prompt_additions);
27920
- const actualSha = createHash9("sha256").update(prompt).digest("hex");
28045
+ const actualSha = createHash10("sha256").update(prompt).digest("hex");
27921
28046
  const exact = !!entry.prompt_sha && actualSha === entry.prompt_sha;
27922
28047
  return {
27923
28048
  entry,
@@ -29205,7 +29330,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29205
29330
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29206
29331
  import { join as join60 } from "path";
29207
29332
  function builtVersion() {
29208
- return true ? "0.164.1" : null;
29333
+ return true ? "0.164.2" : null;
29209
29334
  }
29210
29335
  var REBUILD_HINT = "rebuild with npm run build";
29211
29336
  function newestMtime(path) {
@@ -29325,7 +29450,7 @@ function shipIdentityJson(s) {
29325
29450
  }
29326
29451
 
29327
29452
  // src/mcp-endpoint-registry.ts
29328
- import { createHash as createHash10 } from "crypto";
29453
+ import { createHash as createHash11 } from "crypto";
29329
29454
  function endpointsUrl(api, workspaceId, id) {
29330
29455
  const base = `${api.baseUrl.replace(/\/+$/, "")}/api/workspaces/${workspaceId}/mcp-endpoints`;
29331
29456
  return id ? `${base}/${id}` : base;
@@ -29395,7 +29520,7 @@ async function probeEndpointAccess(api, workspaceId) {
29395
29520
  }
29396
29521
  var REGISTER_MCP_ENDPOINTS_HINT = "give this key's role the REGISTER_MCP_ENDPOINTS capability, e.g. via the group that holds the Crew project role";
29397
29522
  function registrationKey(url, mcpSecret, controlUrl) {
29398
- return createHash10("sha256").update(`${url}
29523
+ return createHash11("sha256").update(`${url}
29399
29524
  ${mcpSecret ?? ""}
29400
29525
  ${controlUrl ?? ""}`).digest("hex").slice(0, 16);
29401
29526
  }
@@ -30065,7 +30190,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
30065
30190
  }
30066
30191
 
30067
30192
  // src/control-api.ts
30068
- import { createHash as createHash11 } from "crypto";
30193
+ import { createHash as createHash12 } from "crypto";
30069
30194
  import {
30070
30195
  chmodSync as chmodSync4,
30071
30196
  closeSync as closeSync7,
@@ -30334,7 +30459,7 @@ var ControlAuth = class {
30334
30459
  if (!token) return "unauthorized";
30335
30460
  for (const k of this.o.shipKeys()) if (k && secretsMatch(token, k)) return "ok";
30336
30461
  const now = (this.o.now ?? Date.now)();
30337
- const id = createHash11("sha256").update(token).digest("hex");
30462
+ const id = createHash12("sha256").update(token).digest("hex");
30338
30463
  const hit = this.cache.get(id);
30339
30464
  if (hit && now - hit.at < (this.o.cacheMs ?? 6e4)) return hit.verdict;
30340
30465
  const verdict = await this.ask(token);
@@ -30355,7 +30480,7 @@ var ControlAuth = class {
30355
30480
  for (const k of this.o.shipKeys()) if (k && secretsMatch(token, k)) return "ok";
30356
30481
  for (const k of this.o.workspaceSecrets?.(workspaceId) ?? []) if (k && secretsMatch(token, k)) return "ok";
30357
30482
  const now = (this.o.now ?? Date.now)();
30358
- const id = `${workspaceId}:${createHash11("sha256").update(token).digest("hex")}`;
30483
+ const id = `${workspaceId}:${createHash12("sha256").update(token).digest("hex")}`;
30359
30484
  const hit = this.cache.get(id);
30360
30485
  if (hit && now - hit.at < (this.o.cacheMs ?? 6e4)) return hit.verdict;
30361
30486
  const verdict = await this.ask(token, [workspaceId]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.164.1",
3
+ "version": "0.164.2",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,6 +45,11 @@ person says so. **A missing worktree is never a reason to stop.**
45
45
  3. Otherwise `git worktree add <dir> -b <branch> <remote>/<base>` from the
46
46
  primary checkout, or `git worktree add <dir> <branch>` when
47
47
  `<remote>/<branch>` already exists (git creates the tracking branch).
48
+ When the branch already exists **locally** with no worktree (a QA run's
49
+ leftover, or an earlier run's), add the worktree on that branch and
50
+ fast-forward it to `<remote>/<branch>`; never create a branch under another
51
+ name for a ticket, because QA and the release phase find work by the
52
+ contract name only.
48
53
  The `-b <branch>` argument is required: omit it and git names the branch
49
54
  after the directory, which QA and the release phase cannot find. Before
50
55
  the first commit, check `git branch --show-current` against the digest's
@@ -45,6 +45,11 @@ person says so. **A missing worktree is never a reason to stop.**
45
45
  3. Otherwise `git worktree add <dir> -b <branch> <remote>/<base>` from the
46
46
  primary checkout, or `git worktree add <dir> <branch>` when
47
47
  `<remote>/<branch>` already exists (git creates the tracking branch).
48
+ When the branch already exists **locally** with no worktree (a QA run's
49
+ leftover, or an earlier run's), add the worktree on that branch and
50
+ fast-forward it to `<remote>/<branch>`; never create a branch under another
51
+ name for a ticket, because QA and the release phase find work by the
52
+ contract name only.
48
53
  The `-b <branch>` argument is required: omit it and git names the branch
49
54
  after the directory, which QA and the release phase cannot find. Before
50
55
  the first commit, check `git branch --show-current` against the digest's