@tablation/crew 0.151.4 → 0.152.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3422,6 +3422,7 @@ var TOP_LEVEL = /* @__PURE__ */ new Set([
3422
3422
  "sandbox",
3423
3423
  "periscope"
3424
3424
  ]);
3425
+ var SANDBOX_KEYS = /* @__PURE__ */ new Set(["image", "packages", "setup", "warm", "hosts", "toolchains"]);
3425
3426
  var BRANCH_KEYS = /* @__PURE__ */ new Set(["base", "name", "push", "remote", "lowercase"]);
3426
3427
  var PLACEHOLDER = /\{(key|number|slug|role|prefix|tag|issue)\}/g;
3427
3428
  var WORKTREE_PLACEHOLDERS = ["dir", "issue", "number", "key", "slug", "role", "prefix", "tag"];
@@ -3543,7 +3544,7 @@ function parseRepoConfig(text2, file) {
3543
3544
  rejectUnknown(raw.worktrees, /* @__PURE__ */ new Set(["copy", "prefix", "name"]), "worktrees", file);
3544
3545
  rejectUnknown(raw.periscope, /* @__PURE__ */ new Set(["inspector"]), "periscope", file);
3545
3546
  rejectUnknown(raw.docs, /* @__PURE__ */ new Set(["triagePolicy", "designGuide"]), "docs", file);
3546
- rejectUnknown(raw.sandbox, /* @__PURE__ */ new Set(["image", "packages", "setup", "warm", "hosts", "toolchains"]), "sandbox", file);
3547
+ rejectUnknown(raw.sandbox, SANDBOX_KEYS, "sandbox", file);
3547
3548
  const sandboxNetwork = parseSandboxNetwork(raw.sandbox, file, (m) => new RepoConfigError(m));
3548
3549
  if (raw.version === void 0) throw new RepoConfigError(`${file}: version is required`);
3549
3550
  if (raw.version !== SPEC_VERSION) {
@@ -4079,7 +4080,7 @@ function parseShipRunner(v) {
4079
4080
  if (v === "host" || v === "sandbox") return v;
4080
4081
  throw new ConfigError(`ship.runner must be "host" or "sandbox", got ${JSON.stringify(v)}`);
4081
4082
  }
4082
- var SANDBOX_KEYS = [
4083
+ var SANDBOX_KEYS2 = [
4083
4084
  "bin",
4084
4085
  "image",
4085
4086
  "policy",
@@ -4100,7 +4101,7 @@ function parseShipSandbox(v) {
4100
4101
  if (typeof v !== "object" || Array.isArray(v)) throw new ConfigError("ship.sandbox must be a map of settings");
4101
4102
  const out = {};
4102
4103
  for (const [k, val] of Object.entries(v)) {
4103
- if (!SANDBOX_KEYS.includes(k)) throw new ConfigError(`ship.sandbox: unknown setting "${k}" (known: ${SANDBOX_KEYS.join(", ")})`);
4104
+ if (!SANDBOX_KEYS2.includes(k)) throw new ConfigError(`ship.sandbox: unknown setting "${k}" (known: ${SANDBOX_KEYS2.join(", ")})`);
4104
4105
  if (typeof val !== "string" || !val) throw new ConfigError(`ship.sandbox.${k} must be a non-empty string`);
4105
4106
  out[k] = val;
4106
4107
  }
@@ -9402,6 +9403,14 @@ var Tracker = class {
9402
9403
  limit: 500
9403
9404
  });
9404
9405
  }
9406
+ /** Tickets by `issue_id` (CREW-3323: resolving a run's key to its display tag). */
9407
+ async ticketsByKeys(keys) {
9408
+ if (keys.length === 0) return [];
9409
+ return this.client.records.list(this.models.issues, {
9410
+ filters: encodeFilters([{ columnName: this.contract.columns.key, operator: "IN", value: keys }]),
9411
+ limit: 500
9412
+ });
9413
+ }
9405
9414
  async ticket(id) {
9406
9415
  return this.client.records.get(this.models.issues, id);
9407
9416
  }
@@ -14919,7 +14928,8 @@ function describeRun(run4, route2, seatIds, worktreeOf = (d, n) => {
14919
14928
  return {
14920
14929
  role: run4.role,
14921
14930
  seat: ownRoute ? seatIds[run4.role] ?? null : null,
14922
- ticket: run4.ticket,
14931
+ // CREW-3323: the display tag when the board knows one; `num` and matching stay on the key the run carries.
14932
+ ticket: run4.ticket ? o.tags?.get(run4.ticket) ?? run4.ticket : run4.ticket,
14923
14933
  ticketRecordId: run4.ticketRecordId,
14924
14934
  repo: run4.repo ?? null,
14925
14935
  worktree: repoDir && num2 ? worktreeOf(repoDir, num2) : null,
@@ -16145,7 +16155,7 @@ async function runSelfLaunchCheck(own, spawnFn = spawnChild, launch = selfLaunch
16145
16155
  }
16146
16156
 
16147
16157
  // src/cli.ts
16148
- import { resolve as resolve7, dirname as dirname37, join as join64, basename as basename17 } from "path";
16158
+ import { resolve as resolve7, dirname as dirname37, join as join65, basename as basename17 } from "path";
16149
16159
  import { fileURLToPath as fileURLToPath2 } from "url";
16150
16160
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
16151
16161
  import { spawnSync as spawnSync14 } from "child_process";
@@ -26133,9 +26143,17 @@ async function showLogEntry(route2, entryId, opts = {}) {
26133
26143
  };
26134
26144
  }
26135
26145
 
26146
+ // src/repo-setup-prompt.ts
26147
+ import { readFileSync as readFileSync52 } from "fs";
26148
+ import { join as join55 } from "path";
26149
+ var REPO_SETUP_PROMPT_PATH = join55("docs", "repo-setup-prompt.md");
26150
+ function readRepoSetupPrompt(crewHome) {
26151
+ return readFileSync52(join55(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
26152
+ }
26153
+
26136
26154
  // src/repos-check.ts
26137
26155
  import { spawnSync as spawnSync13 } from "child_process";
26138
- import { readFileSync as readFileSync52 } from "fs";
26156
+ import { readFileSync as readFileSync53 } from "fs";
26139
26157
  import { basename as basename12 } from "path";
26140
26158
  var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
26141
26159
  function checkHookSyntax(script, shell) {
@@ -26176,7 +26194,7 @@ function checkRepoSpec(dir, opts = {}) {
26176
26194
  }
26177
26195
  let parsed;
26178
26196
  try {
26179
- parsed = parseRepoConfig(readFileSync52(file, "utf8"), file);
26197
+ parsed = parseRepoConfig(readFileSync53(file, "utf8"), file);
26180
26198
  } catch (e) {
26181
26199
  if (!(e instanceof RepoConfigError)) throw e;
26182
26200
  return { ...empty, file, error: e.message, exitCode: 1 };
@@ -26640,7 +26658,7 @@ ${run4.err}` });
26640
26658
  }
26641
26659
 
26642
26660
  // src/sample-ticket.ts
26643
- import { basename as basename13, dirname as dirname32, join as join55 } from "path";
26661
+ import { basename as basename13, dirname as dirname32, join as join56 } from "path";
26644
26662
  var SAMPLE_REPO = "crew-sample";
26645
26663
  var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
26646
26664
  var SAMPLE_MARKER = "sample: true";
@@ -26663,8 +26681,8 @@ has something safe to work on: its test and build hooks always pass, it has no
26663
26681
  remote, and \`crew sample-ticket --remove\` deletes it.
26664
26682
  `;
26665
26683
  function sampleDir(existing, reposBase, workspace) {
26666
- if (existing.length > 0) return join55(dirname32(existing[0]), SAMPLE_REPO);
26667
- return join55(reposBase, workspace, SAMPLE_REPO);
26684
+ if (existing.length > 0) return join56(dirname32(existing[0]), SAMPLE_REPO);
26685
+ return join56(reposBase, workspace, SAMPLE_REPO);
26668
26686
  }
26669
26687
  var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
26670
26688
  function sampleDescription() {
@@ -26931,8 +26949,8 @@ function fixPhaseNothingToOffer(o) {
26931
26949
  }
26932
26950
 
26933
26951
  // src/worktree-sweep.ts
26934
- import { existsSync as existsSync54, readFileSync as readFileSync53, readdirSync as readdirSync16 } from "fs";
26935
- import { basename as basename14, dirname as dirname33, join as join56, resolve as resolve5 } from "path";
26952
+ import { existsSync as existsSync54, readFileSync as readFileSync54, readdirSync as readdirSync16 } from "fs";
26953
+ import { basename as basename14, dirname as dirname33, join as join57, resolve as resolve5 } from "path";
26936
26954
  function planWorktreeSweep(target, tickets, contract) {
26937
26955
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
26938
26956
  const verified = contract.statuses.verified;
@@ -27009,7 +27027,7 @@ function siblingWorktreeDirs(target) {
27009
27027
  for (const name of names) {
27010
27028
  if (!name.startsWith(stem)) continue;
27011
27029
  const m = DIR_NUMBER_SUFFIXED.exec(name);
27012
- const path = join56(parent, name);
27030
+ const path = join57(parent, name);
27013
27031
  if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
27014
27032
  }
27015
27033
  return out;
@@ -27136,7 +27154,7 @@ function isHandBackMerge(path, base) {
27136
27154
  if (!msgPath) return false;
27137
27155
  let first;
27138
27156
  try {
27139
- first = readFileSync53(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
27157
+ first = readFileSync54(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
27140
27158
  } catch {
27141
27159
  return false;
27142
27160
  }
@@ -27242,13 +27260,13 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
27242
27260
 
27243
27261
  // src/stream-sweep.ts
27244
27262
  import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync16 } from "fs";
27245
- import { join as join57 } from "path";
27263
+ import { join as join58 } from "path";
27246
27264
  var DAY_MS2 = 24 * 60 * 60 * 1e3;
27247
27265
  function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
27248
- const dir = join57(stateDir, "streams");
27266
+ const dir = join58(stateDir, "streams");
27249
27267
  if (!existsSync55(dir)) return [];
27250
27268
  const cutoff = now - retentionDays * DAY_MS2;
27251
- return readdirSync17(dir).map((name) => join57(dir, name)).filter((path) => {
27269
+ return readdirSync17(dir).map((name) => join58(dir, name)).filter((path) => {
27252
27270
  try {
27253
27271
  return statSync16(path).mtimeMs < cutoff;
27254
27272
  } catch {
@@ -27276,7 +27294,7 @@ function applyStreamSweep(paths, dryRun, log) {
27276
27294
  function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
27277
27295
  if (!existsSync55(stateDir)) return [];
27278
27296
  const cutoff = now - retentionDays * DAY_MS2;
27279
- return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join57(stateDir, name)).filter((path) => {
27297
+ return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join58(stateDir, name)).filter((path) => {
27280
27298
  try {
27281
27299
  return statSync16(path).mtimeMs < cutoff;
27282
27300
  } catch {
@@ -27286,7 +27304,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
27286
27304
  }
27287
27305
 
27288
27306
  // src/cli.ts
27289
- import { realpathSync as realpathSync3, readFileSync as readFileSync56, 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";
27307
+ import { realpathSync as realpathSync3, 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";
27290
27308
  import { createInterface } from "readline/promises";
27291
27309
 
27292
27310
  // src/periscope-resume.ts
@@ -27363,9 +27381,9 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
27363
27381
 
27364
27382
  // src/bundle-staleness.ts
27365
27383
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
27366
- import { join as join58 } from "path";
27384
+ import { join as join59 } from "path";
27367
27385
  function builtVersion() {
27368
- return true ? "0.151.4" : null;
27386
+ return true ? "0.152.1" : null;
27369
27387
  }
27370
27388
  var REBUILD_HINT = "rebuild with npm run build";
27371
27389
  function newestMtime(path) {
@@ -27378,17 +27396,17 @@ function newestMtime(path) {
27378
27396
  if (stat2.isFile()) return stat2.mtimeMs;
27379
27397
  if (!stat2.isDirectory()) return 0;
27380
27398
  let latest = stat2.mtimeMs;
27381
- for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join58(path, e.name)));
27399
+ for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join59(path, e.name)));
27382
27400
  return latest;
27383
27401
  }
27384
27402
  function bundleStaleness(i) {
27385
27403
  if (i.built === null || i.compiled) return null;
27386
- const src = join58(i.home, "src");
27404
+ const src = join59(i.home, "src");
27387
27405
  if (!existsSync56(src)) return null;
27388
27406
  if (i.built !== i.current) {
27389
27407
  return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
27390
27408
  }
27391
- const bundle = statSafe(join58(i.home, "dist", "cli.js"));
27409
+ const bundle = statSafe(join59(i.home, "dist", "cli.js"));
27392
27410
  if (bundle === null) return null;
27393
27411
  if (newestMtime(src) > bundle) {
27394
27412
  return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
@@ -27606,8 +27624,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
27606
27624
  import { createServer as createHttpServer } from "http";
27607
27625
  import { spawn as spawn10 } from "child_process";
27608
27626
  import { randomBytes as randomBytes2 } from "crypto";
27609
- import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync54, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
27610
- import { join as join59 } from "path";
27627
+ import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync55, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
27628
+ import { join as join60 } from "path";
27611
27629
 
27612
27630
  // src/secret-compare.ts
27613
27631
  import { timingSafeEqual } from "crypto";
@@ -27700,20 +27718,20 @@ var defaultSpawn2 = (cmd, args, env) => {
27700
27718
  return child;
27701
27719
  };
27702
27720
  function syncDaemonStatePath(stateDir, workspaceId) {
27703
- return join59(stateDir, "passengers", `${workspaceId}-sync.json`);
27721
+ return join60(stateDir, "passengers", `${workspaceId}-sync.json`);
27704
27722
  }
27705
27723
  function readPersistedSyncDaemon(stateDir, workspaceId) {
27706
27724
  const path = syncDaemonStatePath(stateDir, workspaceId);
27707
27725
  if (!existsSync57(path)) return void 0;
27708
27726
  try {
27709
- return JSON.parse(readFileSync54(path, "utf8"));
27727
+ return JSON.parse(readFileSync55(path, "utf8"));
27710
27728
  } catch {
27711
27729
  return void 0;
27712
27730
  }
27713
27731
  }
27714
27732
  function writePersistedSyncDaemon(stateDir, state) {
27715
27733
  const path = syncDaemonStatePath(stateDir, state.workspaceId);
27716
- mkdirSync40(join59(stateDir, "passengers"), { recursive: true });
27734
+ mkdirSync40(join60(stateDir, "passengers"), { recursive: true });
27717
27735
  writeFileSync42(path, `${JSON.stringify(state, null, 2)}
27718
27736
  `);
27719
27737
  }
@@ -27734,7 +27752,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
27734
27752
  }
27735
27753
  }
27736
27754
  function readAllPersistedSyncWorkspaceIds(stateDir) {
27737
- const dir = join59(stateDir, "passengers");
27755
+ const dir = join60(stateDir, "passengers");
27738
27756
  if (!existsSync57(dir)) return [];
27739
27757
  const suffix = "-sync.json";
27740
27758
  return readdirSync19(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
@@ -28202,7 +28220,7 @@ async function startWorktreeIntel(d) {
28202
28220
  }
28203
28221
 
28204
28222
  // src/contract-refusal.ts
28205
- import { join as join60 } from "path";
28223
+ import { join as join61 } from "path";
28206
28224
  function contractFixers(dir, baseRef, tickets, locate) {
28207
28225
  const out = [];
28208
28226
  for (const t of tickets) {
@@ -28214,7 +28232,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
28214
28232
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
28215
28233
  if (text2 === null) continue;
28216
28234
  try {
28217
- parseRepoConfig(text2, join60(dir, file));
28235
+ parseRepoConfig(text2, join61(dir, file));
28218
28236
  } catch (e) {
28219
28237
  if (e instanceof RepoConfigError) continue;
28220
28238
  throw e;
@@ -28240,7 +28258,7 @@ import {
28240
28258
  } from "fs";
28241
28259
  import { createConnection } from "net";
28242
28260
  import { createServer as createServer2 } from "http";
28243
- import { basename as basename15, dirname as dirname35, join as join61 } from "path";
28261
+ import { basename as basename15, dirname as dirname35, join as join62 } from "path";
28244
28262
  import { execFile as execFile6, spawn as spawn13 } from "child_process";
28245
28263
 
28246
28264
  // src/periscope-control.ts
@@ -28478,7 +28496,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
28478
28496
  // src/control-api.ts
28479
28497
  var PAUSABLE = ["dev", "design", "qa"];
28480
28498
  var CONTROL_SOCKET_NAME = "control.sock";
28481
- var controlSocketFor = (stateDir) => join61(stateDir, CONTROL_SOCKET_NAME);
28499
+ var controlSocketFor = (stateDir) => join62(stateDir, CONTROL_SOCKET_NAME);
28482
28500
  var MAX_SOCKET_PATH = 100;
28483
28501
  var MAX_TAIL_BYTES = 1024 * 1024;
28484
28502
  var MAX_WAIT_SECONDS = 30;
@@ -28565,7 +28583,7 @@ function candidates(live2, rotated) {
28565
28583
  const out = [live2];
28566
28584
  if (!rotated) return out;
28567
28585
  try {
28568
- for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join61(dirname35(live2), n));
28586
+ for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join62(dirname35(live2), n));
28569
28587
  } catch {
28570
28588
  }
28571
28589
  return out;
@@ -28824,7 +28842,7 @@ async function route(deps, method, url, req, abort) {
28824
28842
  if (p.startsWith("/streams/") && get2) {
28825
28843
  const run4 = decodeURIComponent(p.slice("/streams/".length));
28826
28844
  if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
28827
- const file = join61(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
28845
+ const file = join62(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
28828
28846
  if (!existsSync58(file)) return err2(404, "no such run");
28829
28847
  return tailReply(file, url.searchParams, false, abort);
28830
28848
  }
@@ -28992,19 +29010,19 @@ function crewJson(args, timeoutMs = CREW_JSON_TIMEOUT_MS) {
28992
29010
 
28993
29011
  // src/periscope-mcp.ts
28994
29012
  import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
28995
- import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join63, relative as relative2, resolve as resolve6, sep } from "path";
29013
+ import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join64, relative as relative2, resolve as resolve6, sep } from "path";
28996
29014
  import { z } from "zod";
28997
29015
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
28998
29016
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
28999
29017
 
29000
29018
  // src/periscope-endpoints.ts
29001
29019
  import { randomBytes as randomBytes3 } from "crypto";
29002
- import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync42, readdirSync as readdirSync21, readFileSync as readFileSync55, rmSync as rmSync26, writeFileSync as writeFileSync43 } from "fs";
29003
- import { join as join62 } from "path";
29004
- var secretDir = (stateDir) => join62(stateDir, "periscope-mcp");
29005
- var secretFile = (stateDir, id) => join62(secretDir(stateDir), `${id}.json`);
29006
- var endpointDir = (stateDir) => join62(stateDir, "periscope-endpoints");
29007
- var endpointFile = (stateDir, id) => join62(endpointDir(stateDir), `${id}.json`);
29020
+ import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync42, readdirSync as readdirSync21, readFileSync as readFileSync56, rmSync as rmSync26, writeFileSync as writeFileSync43 } from "fs";
29021
+ import { join as join63 } from "path";
29022
+ var secretDir = (stateDir) => join63(stateDir, "periscope-mcp");
29023
+ var secretFile = (stateDir, id) => join63(secretDir(stateDir), `${id}.json`);
29024
+ var endpointDir = (stateDir) => join63(stateDir, "periscope-endpoints");
29025
+ var endpointFile = (stateDir, id) => join63(endpointDir(stateDir), `${id}.json`);
29008
29026
  function mintPeriscopeSecret(stateDir, ticketRecordId) {
29009
29027
  mkdirSync42(secretDir(stateDir), { recursive: true, mode: 448 });
29010
29028
  const secret = randomBytes3(32).toString("base64url");
@@ -29016,7 +29034,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
29016
29034
  }
29017
29035
  function readPeriscopeSecret(stateDir, ticketRecordId) {
29018
29036
  try {
29019
- const v = JSON.parse(readFileSync55(secretFile(stateDir, ticketRecordId), "utf8"));
29037
+ const v = JSON.parse(readFileSync56(secretFile(stateDir, ticketRecordId), "utf8"));
29020
29038
  return typeof v.secret === "string" && v.secret ? v.secret : void 0;
29021
29039
  } catch {
29022
29040
  return void 0;
@@ -29027,7 +29045,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
29027
29045
  }
29028
29046
  function readPeriscopeEndpoint(stateDir, ticketRecordId) {
29029
29047
  try {
29030
- return JSON.parse(readFileSync55(endpointFile(stateDir, ticketRecordId), "utf8"));
29048
+ return JSON.parse(readFileSync56(endpointFile(stateDir, ticketRecordId), "utf8"));
29031
29049
  } catch {
29032
29050
  return void 0;
29033
29051
  }
@@ -29145,13 +29163,13 @@ async function resolveInWorktree(root, requested) {
29145
29163
  let abs;
29146
29164
  if (isAbsolute5(requested)) {
29147
29165
  abs = resolve6(requested);
29148
- if (isInside(root, abs)) abs = join63(realRoot, relative2(root, abs));
29166
+ if (isInside(root, abs)) abs = join64(realRoot, relative2(root, abs));
29149
29167
  } else {
29150
29168
  abs = resolve6(realRoot, requested);
29151
29169
  }
29152
29170
  if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
29153
29171
  const { real, rest } = await realAncestor(abs);
29154
- const final = rest ? join63(real, rest) : real;
29172
+ const final = rest ? join64(real, rest) : real;
29155
29173
  if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
29156
29174
  if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
29157
29175
  return final;
@@ -29219,7 +29237,7 @@ function createPeriscopeMcpServer(d, sc) {
29219
29237
  const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
29220
29238
  const lines2 = await Promise.all(entries.map(async (e) => {
29221
29239
  if (e.isDirectory()) return `[DIR] ${e.name}`;
29222
- const size = (await lstat(join63(abs, e.name))).size;
29240
+ const size = (await lstat(join64(abs, e.name))).size;
29223
29241
  return `[FILE] ${e.name} (${size} bytes)`;
29224
29242
  }));
29225
29243
  return text(lines2.join("\n") || "(empty)");
@@ -29285,7 +29303,7 @@ function createPeriscopeMcpServer(d, sc) {
29285
29303
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
29286
29304
  }, async ({ path }) => {
29287
29305
  const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
29288
- const abs = join63(parent, basename16(path));
29306
+ const abs = join64(parent, basename16(path));
29289
29307
  if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
29290
29308
  const st = await lstat(abs).catch(() => void 0);
29291
29309
  if (!st) return text(`${path} does not exist`, true);
@@ -29612,6 +29630,7 @@ function usage(problem, requested = false) {
29612
29630
  crew repos check [PATH] validate a checkout's .crew.yaml without attaching it (--route ROUTE, --strict, --json)
29613
29631
  crew repos clone [ROUTE] NAME clone a Repos row's remote into the route directory and attach it (--dir PATH, --dry-run, --json)
29614
29632
  crew repos hooks [ROUTE] NAME suggest test/build hooks for a checkout (--agent, --write route|repo, --recipes, --json)
29633
+ crew repos prompt [--json] print the repository setup prompt: give it to a coding agent at the root of a repository to write its .crew.yaml
29615
29634
  crew repos list ROUTE the checkouts a route has, with the tracker's Repos row each matches (--json: every Repos row too)
29616
29635
  crew logbook list [route] recent Agent Log entries, filterable by --role/--ticket; --before-edit sorts by searches before the first edit, --bounces by acceptance bounces
29617
29636
  crew logbook show [route] ID [--prompt] one entry; --prompt reconstructs and verifies its prompt
@@ -29749,6 +29768,12 @@ function runReposCheck(dir, ship) {
29749
29768
  }
29750
29769
  process.exitCode = report.exitCode;
29751
29770
  }
29771
+ if (command === "repos" && positional[1] === "prompt") {
29772
+ const prompt = readRepoSetupPrompt(CREW_HOME);
29773
+ process.stdout.write(flag("json") ? `${JSON.stringify({ prompt, version: crewVersion(CREW_HOME) })}
29774
+ ` : prompt);
29775
+ process.exit(0);
29776
+ }
29752
29777
  var reposCheckBare = command === "repos" && positional[1] === "check" && !value("route") && positional.length < 4;
29753
29778
  if (reposCheckBare) {
29754
29779
  runReposCheck(resolvePath(positional[2] ?? "."));
@@ -29794,7 +29819,7 @@ if (command === "provision") {
29794
29819
  process.exit(outcome.code);
29795
29820
  }
29796
29821
  if (command === "pool-member") {
29797
- const pool = poolConfigFrom(argv, process.env, () => readFileSync56(0, "utf8"));
29822
+ const pool = poolConfigFrom(argv, process.env, () => readFileSync57(0, "utf8"));
29798
29823
  if (typeof pool === "string") {
29799
29824
  process.stderr.write(`crew pool-member: ${pool}
29800
29825
  `);
@@ -30148,7 +30173,7 @@ if (command === "passenger-sync-daemon") {
30148
30173
  throw e;
30149
30174
  }
30150
30175
  if (command === "credential") {
30151
- const r = runCredential(positional[1], readFileSync56(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
30176
+ const r = runCredential(positional[1], readFileSync57(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
30152
30177
  process.stdout.write(r.out);
30153
30178
  process.stderr.write(r.err);
30154
30179
  process.exit(r.code);
@@ -30160,9 +30185,9 @@ if (command === "passenger-sync-daemon") {
30160
30185
  forges: cfg.ship.forges,
30161
30186
  stateDir: cfg.ship.stateDir,
30162
30187
  configFile: cfg.configFile,
30163
- readFile: (p) => readFileSync56(p, "utf8"),
30188
+ readFile: (p) => readFileSync57(p, "utf8"),
30164
30189
  writeFile: (p, t) => writeFileSync44(p, t),
30165
- stdin: () => readFileSync56(0, "utf8"),
30190
+ stdin: () => readFileSync57(0, "utf8"),
30166
30191
  env: process.env
30167
30192
  }
30168
30193
  );
@@ -30505,7 +30530,7 @@ if (command === "passenger-sync-daemon") {
30505
30530
  for (const l of summarizeJobs(results, { dryRun, verbose: flag("verbose"), host })) emit.emit(l);
30506
30531
  if (host === "linux" && hasSystemd) {
30507
30532
  const label = labelFor(CREW_HOME, "run");
30508
- const staleTimer = join64(homedir11(), ".config", "systemd", "user", `${label}.timer`);
30533
+ const staleTimer = join65(homedir11(), ".config", "systemd", "user", `${label}.timer`);
30509
30534
  if (existsSync60(staleTimer)) {
30510
30535
  emit.emit(
30511
30536
  `removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run, not applied)" : ""}`
@@ -30622,7 +30647,7 @@ if (command === "passenger-sync-daemon") {
30622
30647
  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"}`);
30623
30648
  } else if (a.kind === "enable") {
30624
30649
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
30625
- writeFileSync44(cfg.configFile, planEnable(readFileSync56(cfg.configFile, "utf8"), a.route));
30650
+ writeFileSync44(cfg.configFile, planEnable(readFileSync57(cfg.configFile, "utf8"), a.route));
30626
30651
  enabledSound.add(a.route);
30627
30652
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
30628
30653
  } else {
@@ -30867,7 +30892,7 @@ ${changed2.map((c) => ` - ${c}
30867
30892
  harnessBin: "claude",
30868
30893
  ...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
30869
30894
  },
30870
- policyFile: join64(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
30895
+ policyFile: join65(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
30871
30896
  repo: mirror,
30872
30897
  origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
30873
30898
  base: effective.branch.base,
@@ -32136,7 +32161,7 @@ ${f.tail.trimEnd()}
32136
32161
  logFile: cfg.ship.logFile
32137
32162
  });
32138
32163
  }
32139
- const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join64(CREW_HOME, "src"), join64(CREW_HOME, "dist"), join64(CREW_HOME, "bin")];
32164
+ const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join65(CREW_HOME, "src"), join65(CREW_HOME, "dist"), join65(CREW_HOME, "bin")];
32140
32165
  const configPaths = daemonConfigPaths(cfg);
32141
32166
  watchPaths.push(...configPaths);
32142
32167
  noteDaemonStarted(cfg.ship.stateDir);
@@ -32445,7 +32470,7 @@ ${f.tail.trimEnd()}
32445
32470
  for (const w of result.warnings) emit.warn(w);
32446
32471
  if (!dryRun) {
32447
32472
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
32448
- const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync56(resolvedPath, "utf8")) : {};
32473
+ const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync57(resolvedPath, "utf8")) : {};
32449
32474
  raw.agentSkills = result.agentSkills;
32450
32475
  mkdirSync43(dirOf2(resolvedPath), { recursive: true });
32451
32476
  writeFileSync44(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -32469,7 +32494,7 @@ ${f.tail.trimEnd()}
32469
32494
  throw e;
32470
32495
  }
32471
32496
  const oldName = cfg.ship.name;
32472
- writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), newName));
32497
+ writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), newName));
32473
32498
  cfg.ship.name = newName;
32474
32499
  let renameMachineId;
32475
32500
  try {
@@ -32512,11 +32537,11 @@ ${f.tail.trimEnd()}
32512
32537
  case "repos": {
32513
32538
  const sub = positional[1];
32514
32539
  const usage2 = () => {
32515
- process.stderr.write("crew repos add [workspace/project] [name] [path] [--name N] [--project P] [--dry-run] [--no-create]\ncrew repos clone [workspace/project] <name> [--dir PATH] [--dry-run] [--json]\ncrew repos list <workspace/project> [--json]\ncrew repos check [PATH | --route ROUTE [PATH] | ROUTE NAME] [--strict] [--json]\ncrew repos hooks [workspace/project] <name> [--suggest] [--agent] [--write route|repo [--replace]] [--clear route] [--recipes ID,ID] [--hook KEY=CMD ...] [--json]\n");
32540
+ process.stderr.write("crew repos add [workspace/project] [name] [path] [--name N] [--project P] [--dry-run] [--no-create]\ncrew repos clone [workspace/project] <name> [--dir PATH] [--dry-run] [--json]\ncrew repos list <workspace/project> [--json]\ncrew repos check [PATH | --route ROUTE [PATH] | ROUTE NAME] [--strict] [--json]\ncrew repos prompt [--json]\ncrew repos hooks [workspace/project] <name> [--suggest] [--agent] [--write route|repo [--replace]] [--clear route] [--recipes ID,ID] [--hook KEY=CMD ...] [--json]\n");
32516
32541
  process.exit(2);
32517
32542
  };
32518
32543
  if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
32519
- const configText = readFileSync56(cfg.configFile, "utf8");
32544
+ const configText = readFileSync57(cfg.configFile, "utf8");
32520
32545
  if (sub === "check") {
32521
32546
  try {
32522
32547
  const routeArg = value("route") ?? positional[2];
@@ -32555,7 +32580,7 @@ ${f.tail.trimEnd()}
32555
32580
  }
32556
32581
  }, read: (r) => {
32557
32582
  try {
32558
- return readFileSync56(resolvePath(dir, r), "utf8");
32583
+ return readFileSync57(resolvePath(dir, r), "utf8");
32559
32584
  } catch {
32560
32585
  return void 0;
32561
32586
  }
@@ -32699,7 +32724,7 @@ ${f.tail.trimEnd()}
32699
32724
  let resolvedRemotes;
32700
32725
  if (existsSync60(resolvedFile)) {
32701
32726
  try {
32702
- resolvedRemotes = JSON.parse(readFileSync56(resolvedFile, "utf8"));
32727
+ resolvedRemotes = JSON.parse(readFileSync57(resolvedFile, "utf8"));
32703
32728
  } catch {
32704
32729
  }
32705
32730
  }
@@ -32721,7 +32746,7 @@ ${f.tail.trimEnd()}
32721
32746
  repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
32722
32747
  try {
32723
32748
  const path = resolvePath(d, f);
32724
- return Object.keys(parseRepoConfig(readFileSync56(path, "utf8"), path).hooks).length > 0;
32749
+ return Object.keys(parseRepoConfig(readFileSync57(path, "utf8"), path).hooks).length > 0;
32725
32750
  } catch {
32726
32751
  return false;
32727
32752
  }
@@ -32827,7 +32852,7 @@ ${f.tail.trimEnd()}
32827
32852
  process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
32828
32853
  `);
32829
32854
  if (existsSync60(resolvedFile)) {
32830
- const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
32855
+ const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
32831
32856
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
32832
32857
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
32833
32858
  writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -33181,7 +33206,7 @@ Waiting for approval`
33181
33206
  ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, then run `crew connect` again");
33182
33207
  }
33183
33208
  if (found.shipNameAdopted && !dryRun) {
33184
- writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), found.shipNameAdopted));
33209
+ writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), found.shipNameAdopted));
33185
33210
  cfg.ship.name = found.shipNameAdopted;
33186
33211
  }
33187
33212
  if (found.shipRow) {
@@ -33225,7 +33250,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
33225
33250
  const hadPreviousFile = existsSync60(resolvedPath);
33226
33251
  if (hadPreviousFile) {
33227
33252
  try {
33228
- previous = JSON.parse(readFileSync56(resolvedPath, "utf8"));
33253
+ previous = JSON.parse(readFileSync57(resolvedPath, "utf8"));
33229
33254
  } catch {
33230
33255
  }
33231
33256
  }
@@ -34038,10 +34063,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
34038
34063
  startupSeconds: cfg.ship.intelStartupSeconds,
34039
34064
  prepare: async (path) => {
34040
34065
  for (const f of repoWt.config.worktrees.copy) {
34041
- const src = join64(repoWt.dir, f);
34042
- if (!existsSync60(src) || existsSync60(join64(path, f))) continue;
34043
- mkdirSync43(dirOf2(join64(path, f)), { recursive: true });
34044
- copyFileSync2(src, join64(path, f));
34066
+ const src = join65(repoWt.dir, f);
34067
+ if (!existsSync60(src) || existsSync60(join65(path, f))) continue;
34068
+ mkdirSync43(dirOf2(join65(path, f)), { recursive: true });
34069
+ copyFileSync2(src, join65(path, f));
34045
34070
  }
34046
34071
  const setup = repoWt.config.hooks.setup;
34047
34072
  return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
@@ -34368,10 +34393,10 @@ ${where.join("\n")}`);
34368
34393
  },
34369
34394
  prepare: async (path) => {
34370
34395
  for (const f of repoP.config.worktrees.copy) {
34371
- const src = join64(repoP.dir, f);
34396
+ const src = join65(repoP.dir, f);
34372
34397
  if (!existsSync60(src)) continue;
34373
- mkdirSync43(dirOf2(join64(path, f)), { recursive: true });
34374
- copyFileSync2(src, join64(path, f));
34398
+ mkdirSync43(dirOf2(join65(path, f)), { recursive: true });
34399
+ copyFileSync2(src, join65(path, f));
34375
34400
  }
34376
34401
  const setup = repoP.config.hooks.setup;
34377
34402
  return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
@@ -34686,7 +34711,7 @@ ${where.join("\n")}`);
34686
34711
  };
34687
34712
  const droppedRoutes = [];
34688
34713
  try {
34689
- const rawCfg = parseYaml3(readFileSync56(cfg.configFile, "utf8"));
34714
+ const rawCfg = parseYaml3(readFileSync57(cfg.configFile, "utf8"));
34690
34715
  for (const r of rawCfg?.routes ?? []) {
34691
34716
  if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
34692
34717
  try {
@@ -34812,7 +34837,7 @@ ${where.join("\n")}`);
34812
34837
  }
34813
34838
  case "log": {
34814
34839
  try {
34815
- const text2 = readFileSync56(cfg.ship.logFile, "utf8").split("\n");
34840
+ const text2 = readFileSync57(cfg.ship.logFile, "utf8").split("\n");
34816
34841
  process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
34817
34842
  `);
34818
34843
  } catch {
@@ -34836,7 +34861,7 @@ ${where.join("\n")}`);
34836
34861
  };
34837
34862
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
34838
34863
  const tracker = new Tracker(route2, cfg.ship);
34839
- const configText = readFileSync56(cfg.configFile, "utf8");
34864
+ const configText = readFileSync57(cfg.configFile, "utf8");
34840
34865
  const cfgBase = dirname37(cfg.configFile);
34841
34866
  const configured2 = configuredRepos(configText, route2.route, cfgBase);
34842
34867
  const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
@@ -34874,19 +34899,19 @@ ${where.join("\n")}`);
34874
34899
  if (row) {
34875
34900
  await tracker.deleteRepoRow(row.id);
34876
34901
  if (existsSync60(resolvedFile)) {
34877
- const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
34902
+ const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
34878
34903
  if (raw.repoNames) delete raw.repoNames[row.id];
34879
34904
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
34880
34905
  writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
34881
34906
  `);
34882
34907
  }
34883
34908
  }
34884
- if (existsSync60(join64(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
34909
+ if (existsSync60(join65(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
34885
34910
  say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
34886
34911
  break;
34887
34912
  }
34888
34913
  const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
34889
- const fresh = !existsSync60(join64(dir, ".git"));
34914
+ const fresh = !existsSync60(join65(dir, ".git"));
34890
34915
  if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
34891
34916
  if (dryRun) {
34892
34917
  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`);
@@ -34894,8 +34919,8 @@ ${where.join("\n")}`);
34894
34919
  }
34895
34920
  if (fresh) {
34896
34921
  mkdirSync43(dir, { recursive: true });
34897
- writeFileSync44(join64(dir, "README.md"), SAMPLE_README);
34898
- writeFileSync44(join64(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
34922
+ writeFileSync44(join65(dir, "README.md"), SAMPLE_README);
34923
+ writeFileSync44(join65(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
34899
34924
  const g = (...a) => {
34900
34925
  const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
34901
34926
  if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
@@ -34914,7 +34939,7 @@ ${where.join("\n")}`);
34914
34939
  });
34915
34940
  repoId = (await tracker.createRepoRow(payload)).id;
34916
34941
  if (existsSync60(resolvedFile)) {
34917
- const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
34942
+ const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
34918
34943
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
34919
34944
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
34920
34945
  writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -35055,7 +35080,7 @@ ${where.join("\n")}`);
35055
35080
  const shipRows = await statusTracker.shipRows();
35056
35081
  const engagedTicketIds = shipRows.map((s) => s.engaged_ticket_id).filter((id) => !!id);
35057
35082
  const engagedTickets = engagedTicketIds.length ? await statusTracker.ticketsByIds(engagedTicketIds) : [];
35058
- const issueLabelById = new Map(engagedTickets.map((t) => [t.id, t.issue_id]));
35083
+ const issueLabelById = new Map(engagedTickets.map((t) => [t.id, displayKey(t)]));
35059
35084
  const todo = await statusTracker.openTickets().then((open) => operatorTodo(open, statusTracker.contract, route2.resolved?.operator ?? "")).catch(() => []);
35060
35085
  const projects = projectModeLabels(await statusTracker.projectRowsWithModes().catch(() => []));
35061
35086
  const crewMinVersion = await readCrewFloor(route2, cfg.ship) ?? null;
@@ -35064,6 +35089,13 @@ ${where.join("\n")}`);
35064
35089
  (await statusTracker.ticketsByIds([...new Set(runs.map((x) => x.ticketRecordId).filter((id) => !!id))]).catch(() => [])).map((t) => [t.id, t.title ?? null])
35065
35090
  );
35066
35091
  const lastRuns = lastRunsBySeat(cfg.ship.stateDir);
35092
+ const wantedKeys = [...new Set([...runs.map((x) => x.ticket), ...[...lastRuns.values()].map((l) => l.ticket)].filter((k) => !!k))];
35093
+ const tagByKey = /* @__PURE__ */ new Map();
35094
+ for (const t of [
35095
+ ...await statusTracker.ticketsByIds([...new Set(runs.map((x) => x.ticketRecordId).filter((id) => !!id))]).catch(() => []),
35096
+ ...await statusTracker.ticketsByKeys(wantedKeys).catch(() => [])
35097
+ ]) tagByKey.set(t.issue_id, displayKey(t));
35098
+ const tagOf = (k) => k ? tagByKey.get(k) ?? k : null;
35067
35099
  const periscopes = await periscopesForStatus(cfg.ship.stateDir);
35068
35100
  const runPreviews = new Map(periscopes.filter((p) => p.serving).map((p) => [p.ticketRecordId, p.url]));
35069
35101
  if (flag("json")) {
@@ -35087,7 +35119,7 @@ ${where.join("\n")}`);
35087
35119
  // Additive (CREW-2822): how many runs this seat has live right now.
35088
35120
  running: runs.filter((x) => x.role === r && x.route === routeSlug(route2.route)).length,
35089
35121
  // Additive (CREW-3247): this seat's newest finished run on this ship, or null.
35090
- lastRun: ((l) => l ? { ticket: l.ticket, startedAt: l.startedAt, finishedAt: l.finishedAt, outcome: l.outcome, exitCode: l.exitCode } : null)(lastRuns.get(`${routeSlug(route2.route)}/${r}`))
35122
+ lastRun: ((l) => l ? { ticket: tagOf(l.ticket), startedAt: l.startedAt, finishedAt: l.finishedAt, outcome: l.outcome, exitCode: l.exitCode } : null)(lastRuns.get(`${routeSlug(route2.route)}/${r}`))
35091
35123
  };
35092
35124
  });
35093
35125
  process.stdout.write(`${JSON.stringify({
@@ -35137,7 +35169,7 @@ ${where.join("\n")}`);
35137
35169
  seats: seats2
35138
35170
  },
35139
35171
  // Additive (CREW-2822): every live run on this ship. `version` stays 1.
35140
- runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles, previews: runPreviews })),
35172
+ runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles, previews: runPreviews, tags: tagByKey })),
35141
35173
  // Additive (CREW-2857): every live periscope on this ship, from its local record. `version` stays 1.
35142
35174
  periscopes,
35143
35175
  watermark: state.watermark(routeSlug(route2.route)),
@@ -35224,7 +35256,7 @@ ${where.join("\n")}`);
35224
35256
  });
35225
35257
  }
35226
35258
  const reloadWaitingAt = readReloadRequestedAt(cfg.ship.stateDir);
35227
- const lastRunView = [...lastRuns.values()].filter((l) => l.route === routeSlug(route2.route)).map((l) => ({ role: l.role, ticket: l.ticket, finishedAt: l.finishedAt, outcome: l.outcome }));
35259
+ const lastRunView = [...lastRuns.values()].filter((l) => l.route === routeSlug(route2.route)).map((l) => ({ role: l.role, ticket: tagOf(l.ticket), finishedAt: l.finishedAt, outcome: l.outcome }));
35228
35260
  for (const line of renderStatus({
35229
35261
  ship: { name: cfg.ship.name, platform: cfg.ship.platform },
35230
35262
  route: { name: route2.route, dir: route2.dir, enabled: route2.enabled },
@@ -35239,7 +35271,7 @@ ${where.join("\n")}`);
35239
35271
  watermark: String(state.watermark(routeSlug(route2.route))),
35240
35272
  projects: projects.map((p) => p.label),
35241
35273
  reloadRequestedSecondsAgo: reloadWaitingAt === null ? null : Math.max(0, Math.round((Date.now() - reloadWaitingAt) / 1e3)),
35242
- runs: runs.map((x) => ({ role: x.role, ticket: x.ticket, repo: x.repo, pid: x.pid, spawnedAt: x.spawnedAt, deadline: x.deadline })),
35274
+ runs: runs.map((x) => ({ role: x.role, ticket: tagOf(x.ticket), repo: x.repo, pid: x.pid, spawnedAt: x.spawnedAt, deadline: x.deadline })),
35243
35275
  lastRuns: lastRunView,
35244
35276
  attention: shipAttention.map((i) => ({ kind: i.kind, message: i.message, since: i.since })),
35245
35277
  waiting: todo.map((i) => ({
@@ -35474,7 +35506,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
35474
35506
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
35475
35507
  const abandons = unitAbandonsAgents(unitPlan, (p) => {
35476
35508
  try {
35477
- return readFileSync56(p, "utf8");
35509
+ return readFileSync57(p, "utf8");
35478
35510
  } catch {
35479
35511
  return null;
35480
35512
  }
@@ -35489,7 +35521,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
35489
35521
  const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
35490
35522
  const keeps = unitAbandonsAgents(pPlan, (p) => {
35491
35523
  try {
35492
- return readFileSync56(p, "utf8");
35524
+ return readFileSync57(p, "utf8");
35493
35525
  } catch {
35494
35526
  return null;
35495
35527
  }
@@ -24769,6 +24769,7 @@ var TOP_LEVEL = /* @__PURE__ */ new Set([
24769
24769
  "sandbox",
24770
24770
  "periscope"
24771
24771
  ]);
24772
+ var SANDBOX_KEYS = /* @__PURE__ */ new Set(["image", "packages", "setup", "warm", "hosts", "toolchains"]);
24772
24773
  var BRANCH_KEYS = /* @__PURE__ */ new Set(["base", "name", "push", "remote", "lowercase"]);
24773
24774
  var PLACEHOLDER = /\{(key|number|slug|role|prefix|tag|issue)\}/g;
24774
24775
  var WORKTREE_PLACEHOLDERS = ["dir", "issue", "number", "key", "slug", "role", "prefix", "tag"];
@@ -24889,7 +24890,7 @@ function parseRepoConfig(text, file) {
24889
24890
  rejectUnknown(raw.worktrees, /* @__PURE__ */ new Set(["copy", "prefix", "name"]), "worktrees", file);
24890
24891
  rejectUnknown(raw.periscope, /* @__PURE__ */ new Set(["inspector"]), "periscope", file);
24891
24892
  rejectUnknown(raw.docs, /* @__PURE__ */ new Set(["triagePolicy", "designGuide"]), "docs", file);
24892
- rejectUnknown(raw.sandbox, /* @__PURE__ */ new Set(["image", "packages", "setup", "warm", "hosts", "toolchains"]), "sandbox", file);
24893
+ rejectUnknown(raw.sandbox, SANDBOX_KEYS, "sandbox", file);
24893
24894
  const sandboxNetwork = parseSandboxNetwork(raw.sandbox, file, (m) => new RepoConfigError(m));
24894
24895
  if (raw.version === void 0) throw new RepoConfigError(`${file}: version is required`);
24895
24896
  if (raw.version !== SPEC_VERSION) {
@@ -0,0 +1,274 @@
1
+ Set this repository up to be worked by Crew. The result is one file at the repository root, `.crew.yaml`, that you write, test and leave uncommitted for me to review.
2
+
3
+ ## What you are configuring
4
+
5
+ Crew is a runtime that works tickets from a tracker with headless coding agents. For each ticket it cuts a fresh git worktree beside the checkout, runs an agent in it with nobody watching, has a second agent verify the branch, and then releases it. Several worktrees of the same repository are often live on one machine at once.
6
+
7
+ Crew knows nothing about this repository except what `.crew.yaml` says. The file names the commands ("hooks") that install, test, build, version and release the project, and a few facts about branches and releases. Crew never parses a hook: it hands the text to a shell at the repository root and reads the exit status, and for some hooks the output.
8
+
9
+ That makes three things matter more than they would in a README:
10
+
11
+ - A hook must work in a **fresh worktree**, where nothing gitignored exists yet: no installed dependencies, no `.env`, no generated code.
12
+ - A hook must work **unattended**: no prompts, no watch mode, no pager, no browser window, and a non-zero exit when something failed.
13
+ - A wrong release setting is worse than a missing one. A deploy hook that exits zero without deploying makes Crew record a release that never happened, so anything about releases that the repository does not prove is a question for me, not a guess.
14
+
15
+ The full specification is at https://crew.tablation.dev/repo-spec. Read it if you can reach it; where it and this prompt disagree, it wins. The reference at the end of this prompt is enough to do the job if you cannot.
16
+
17
+ ## Ground rules
18
+
19
+ - Write `.crew.yaml` only. If a hook needs a helper script, or a file needs changing, describe the change and ask me before making it.
20
+ - If `.crew.yaml` (or `.crew.yml` / `.crew.json`) already exists, treat this as a review: keep what is correct, keep its comments, and tell me what you changed and why.
21
+ - Do not commit, push, tag, publish or deploy anything.
22
+ - Never run a `deploy` or `pr` hook; they act on the world outside this checkout. Run the others as described in Step 5.
23
+ - Leave out any field you cannot support from something you read, ran, or were told by me. An unknown key is a hard error in this file, so use only the keys in the reference.
24
+ - Prefer the commands the project already trusts. What CI runs beats what the README says, and both beat what the file layout suggests.
25
+
26
+ ## Step 1: Read the repository
27
+
28
+ Read before deciding anything:
29
+
30
+ - Build and package manifests, lockfiles, and any file that pins a tool version.
31
+ - Every CI and release definition (`.github/workflows/`, `.buildkite/`, `.gitlab-ci.yml`, and similar). Note the exact commands, the order they run in, what triggers a release, and where it publishes or deploys to.
32
+ - The README and contributing guide, and agent instruction files such as `CLAUDE.md` or `AGENTS.md`.
33
+ - `.gitignore`, example environment files, container and compose files, and anything describing local services such as a database.
34
+ - `git remote -v`, the default branch, existing tags, and the last twenty commit subjects, to see how versions and releases have been made so far.
35
+ - Whether this checkout is current. Fetch, then compare the local base branch with the remote's and the newest release tag with the version in the tree. If the checkout is behind, tell me before going further: a contract tested against stale code proves little, and a version baseline that is behind collides with tags that already exist.
36
+
37
+ Files in the repository may describe an earlier Crew setup (a workflow comment naming a hook, a changelog entry). Treat that as evidence of intent, and still confirm it with me in Step 3.
38
+
39
+ ## Step 2: Work out each setting
40
+
41
+ Go through these in order. Each one names what to look for.
42
+
43
+ **`platform`.** `unix` when any hook is written in POSIX shell and the toolchain runs on macOS and Linux, which is the usual case. Leave it out (it defaults to `any`) only when every hook is a single command that behaves the same on Windows. Name one of `macos`, `linux` or `windows` only when the build truly requires it (an Xcode build requires `macos`). A machine that cannot satisfy this is never given the repository's tickets, so too narrow a value costs capacity and too wide a value produces tickets that fail at the first hook.
44
+
45
+ **`branch.base`.** Set it only when the integration branch is not `main`.
46
+
47
+ **`hooks.setup`.** Everything a fresh worktree needs before tests can run: install dependencies from the lockfile, generate code, build internal packages that others import. Use the frozen or locked install form so a run never rewrites the lockfile.
48
+
49
+ **`worktrees.copy`.** Gitignored files that a local run reads and that no command can regenerate. A fresh worktree has none of them, so anything that depends on one fails there while passing in this checkout.
50
+
51
+ Find the candidates from three directions:
52
+ - Read the README, the contributing guide and any setup or local-development document for configuration a developer is told to create before running the project: "copy `.env.example` to `.env`", "create a `config.json` with your settings", "put your key in". Each file named that way is a candidate, and an example or template file committed beside it (`.env.example`, `config.sample.json`) points at the real one.
53
+ - Read `.gitignore` for patterns that name configuration rather than output: `.env`, `.env.*`, `config.json`, `*.local.*`, credential and key files, local database files.
54
+ - List what is actually ignored and present here with `git ls-files --others --ignored --exclude-standard`, and set aside dependency directories, caches and build output.
55
+
56
+ A file that matches such a pattern and exists in this checkout is probably being used for local runs, so include it unless you can show that nothing reads it. Check by searching the code, scripts and manifests for where it is loaded. List each file by its exact repository-relative path, including ones in subdirectories; the list takes paths, not patterns. Name these files in comments and in your report, but never quote their contents, since they often hold secrets.
57
+
58
+ When the documentation calls for a file, or `.gitignore` has such a pattern and the code clearly reads a matching file, and none exists here, raise it in Step 3: I may keep it somewhere else or have never created it. A documented file that is not gitignored is also worth raising, because it is either committed, and needs no copying, or about to be committed by accident.
59
+
60
+ **`hooks.test`.** The whole gate CI applies before a merge: lint, type check and test suites, in one script. When there are several steps, run them all and exit non-zero if any failed, so one run reports every problem:
61
+
62
+ ```yaml
63
+ test: |
64
+ ok=0
65
+ <lint command> || ok=1
66
+ <unit test command> || ok=1
67
+ exit "$ok"
68
+ ```
69
+
70
+ Use the non-interactive form of each command. Leave out suites that need credentials or services a headless run will not have, and say so in a comment.
71
+
72
+ **`hooks.build`.** The command that proves the project compiles or bundles. If the project has no build step, use the cheapest real check there is (a type check or a syntax check), never a command that cannot fail.
73
+
74
+ **Version.** Find where the version lives.
75
+ - Only in the `version` field of one or more JSON files such as `package.json`: set `release.versionFiles` to those files and write no version hooks.
76
+ - Anywhere else, or in more than one kind of place (Cargo, pyproject, a plist, a plain VERSION file, git tags, or a manifest plus a lockfile that records the same version): write `hooks.version` (prints the current version on one line) and `hooks.bump` (reads `CREW_BUMP`, which is `major`, `minor` or `patch`, writes the new version everywhere it lives, and prints it on one line). Prefer the package manager's own version command, told not to commit or tag, because it keeps a lockfile in step. Do not also set `versionFiles`.
77
+ - No version anywhere, or a version another tool owns: `release.versioning: none`.
78
+
79
+ Crew writes `CHANGELOG.md` by default. Set `release.changelog: false` when the repository keeps no changelog, and give the path when it keeps one under another name.
80
+
81
+ **Parallel worktrees.** Decide whether two worktrees running at once would collide.
82
+ - If anything listens on a fixed port (dev server, API, test server), a `hooks.ports` script should print `KEY=value` lines assigning ports that differ per worktree, usually derived from the worktree's directory name. The project's servers must read those variables.
83
+ - If tests or the dev server use a database or other shared state, a `hooks.isolate` script should print `KEY=value` overrides pointing this worktree at state of its own (it receives `CREW_TICKET` and `CREW_BRANCH`). Without it, an agent changing a schema migrates whatever database the local environment file points at, which is usually the developer's own.
84
+
85
+ Both usually need a small script in the repository and sometimes a change to how ports are read. Propose them; do not write them without my agreement. If nothing listens and nothing is shared, omit both.
86
+
87
+ **`hooks.preview`.** For anything a person would look at in a browser. It starts a server detached so it outlives the hook, bound to `${CREW_PREVIEW_HOST:-localhost}`, and prints the URL as its last line of output. A project with a dev server uses it, on the port from `ports`. A static site needs no script: serve the built directory with a file server the machine already has, on a port computed from the ticket number so worktrees do not collide:
88
+
89
+ ```yaml
90
+ preview: |
91
+ port=$((30000 + ${CREW_TICKET##*-}))
92
+ nohup <static file server> "$port" >/dev/null 2>&1 &
93
+ echo "http://${CREW_PREVIEW_HOST:-localhost}:$port"
94
+ ```
95
+
96
+ **`hooks.handoff`.** Only when someone opening a freshly built worktree would be locked out without it, for example an app that needs a seeded login. It makes that possible and prints how to get in.
97
+
98
+ **`hooks.map`.** If the repository already has a short document describing its layout, set this to that file's relative path (it must end in `.md`). Do not write one for this task.
99
+
100
+ **Forge hooks.** When the remote is on GitHub and the `gh` CLI is what the project uses:
101
+ - `hooks.ci_status` (exit 0 when CI is green for `$CREW_BRANCH`) is worth adding when CI runs on pushed branches.
102
+ - `hooks.merged` and `hooks.pr` belong to the `external` release mode below.
103
+
104
+ ## Step 3: Ask me what the repository cannot tell you
105
+
106
+ Ask once, in a single message, with your best reading of the evidence beside each question so that confirming it takes me a word. Always ask the release question, even when the evidence looks conclusive; ask the others only where the answer is not already clear. If a clean install for Step 5 will be slow or large, say so here too.
107
+
108
+ 1. **How does a change reach users after it merges?** Offer the mode you believe applies and what you saw that suggests it:
109
+ - `integrate`: merging to the base branch is the release. Crew merges, versions, writes the changelog and tags. Right for a library or tool with nothing to deploy.
110
+ - `ci_auto`: pushing the base branch or a tag makes CI publish or deploy. Crew merges, versions, tags and pushes, then watches. Needs `hooks.released`.
111
+ - `ci_manual`: Crew triggers CI and waits for it. Needs `hooks.released`.
112
+ - `local`: Crew runs a deploy command itself after merging and pushing, and the command's exit status is the result. Needs `hooks.deploy`. Right when a person ships by running a command today, including one that dispatches a pipeline and waits for it.
113
+ - `external`: Crew does not merge at all. A person or another tool merges pull requests. Needs `hooks.merged`; `hooks.pr` opens the pull request.
114
+ For `local`, also confirm the exact command I run to ship.
115
+ 2. **What single command prints what is live right now**, as a version or a commit sha? A registry query and a health endpoint are the usual answers. The `ci_*` modes cannot work without it, so ask whenever one of them is likely; for the other modes it is optional and not worth a question. It becomes `hooks.released`, with `release.verify.match` set to `version` or `commit` to match, and `release.verify.timeoutSeconds` sized to how long the release pipeline takes.
116
+ 3. **Should Crew set versions**, if the evidence was mixed? If a lockfile or second file records the version, confirm it has to stay in step.
117
+ 4. Anything from Step 2 you proposed and need agreement on: a ports or isolate script, a preview, the gitignored files to copy into worktrees (list them by name so I can strike any that should not travel), a narrower `platform`.
118
+ 6. **Code navigation.** `hooks.intel` gives agents symbol lookup. Offer `typescript-lsp` for a TypeScript or JavaScript project (it uses `typescript-language-server` from the project's own dev dependencies, or from the machine's PATH when the project does not have it) or `serena` for other languages (needs a one-time install on each machine). Leave it out unless I say yes.
119
+
120
+ Wait for my answers before writing the file. If I tell you to go ahead without them, write only what the repository proves. For the release, use `integrate` when nothing in the repository publishes or deploys; otherwise leave the `release` section out and say in your report that the file is not ready to release from.
121
+
122
+ ## Step 4: Write `.crew.yaml`
123
+
124
+ Start with `version: 1`. Order the file `platform`, `branch`, `worktrees`, `hooks`, `labels`, `release`. Always write `release.mode`, even when it is the default, because it is the setting a reader most needs to see. Leave other settings out when the default is what you want. Above every choice that is not obvious, write a short comment saying what justified it, such as the workflow file that publishes on a tag, or the reason a test suite is left out. Someone should be able to audit the file without redoing your investigation. Put the specification URL in a comment on the first line.
125
+
126
+ Use a YAML block scalar (`|`) for any hook longer than one command. Add a `labels` entry for a hook whose script is more than one line, so logs show a readable name.
127
+
128
+ ## Step 5: Prove the hooks work
129
+
130
+ Test them the way Crew will run them, in a clean worktree, not in this checkout where dependencies are already installed:
131
+
132
+ 1. Cut a scratch worktree from the current commit in a temporary directory outside the repository.
133
+ 2. Copy in the files listed under `worktrees.copy`.
134
+ 3. From the worktree root, run each hook you wrote with `bash -c` (or the `shell` you set), in this order: `setup`, then `ports` and `isolate` (export what they print), then `test`, `build` and `version`. Run `released` and `ci_status` too; they only read.
135
+ 4. Run `bump` last, with `CREW_BUMP=patch`. Check that it printed the new version and nothing else, that `version` now prints the same, and that `git status` shows every file that records the version changed. The worktree is about to be discarded, so this costs nothing.
136
+ 5. Remove the worktree and its branch when you are done, even if a hook failed.
137
+
138
+ Judge each hook by its exit status. When one fails, work out whether the hook is wrong (fix it and run again) or the project is broken at this commit (leave the hook, and report the failure with its output). Never weaken a hook to make it pass.
139
+
140
+ Note every program the hooks call and where your shell found it. Crew starts hooks from a background scheduler whose PATH is shorter than a terminal's, so a tool that a shell profile or a version manager adds is a common first-run failure.
141
+
142
+ ## Step 6: Validate the file
143
+
144
+ If `crew` is on the PATH, run `crew repos check --strict` from the repository root and fix everything it reports until it exits 0. It executes nothing, so it does not replace Step 5.
145
+
146
+ If `crew` is not installed but Node 22 or newer is, `npx --yes @tablation/crew repos check --strict` runs the same check. Failing both, check by hand: the file parses as YAML, every key appears in the reference below, each hook passes the shell's syntax check (`bash -n`), and none of the combinations listed under "Combinations that are refused" is present.
147
+
148
+ ## Step 7: Report
149
+
150
+ Finish with a short report:
151
+
152
+ - The file's settings in a few lines, and the release mode in one sentence of plain language.
153
+ - Each hook with how it fared: passed in a clean worktree, failed (with the reason), or not run (with the reason). `deploy` and `pr` are always in the last group; say which parts of them you could check by reading.
154
+ - The programs the hooks need on the machine's PATH, with the versions the repository pins, and any sign-in they need (a forge CLI, a registry).
155
+ - Anything you left out on purpose and what would be needed to add it.
156
+ - Changes outside `.crew.yaml` that you recommend but did not make.
157
+ - What I do next: review and commit the file, then attach the checkout to a route with `crew repos add`, or add the repository from the Crew app.
158
+
159
+ ## Reference
160
+
161
+ Top-level keys: `version`, `platform`, `shell`, `branch`, `worktrees`, `docs`, `hooks`, `labels`, `release`, `sandbox`, `periscope`. Nothing else is accepted. The tables list the settings this task can need. The specification has the rest (branch and worktree naming, `shell`, `periscope`, `sandbox`, per-machine release settings); leave those unset unless I ask for them.
162
+
163
+ | Key | Values and meaning |
164
+ | --- | --- |
165
+ | `version` | Required. `1`. |
166
+ | `platform` | `any` (default), `unix`, `macos`, `linux`, `windows`. |
167
+ | `branch.base` | Integration branch. Default `main`. |
168
+ | `worktrees.copy` | List of gitignored, repository-relative paths copied from the main checkout into a new worktree before `setup`. Exact paths; absolute paths and `..` are refused. |
169
+ | `docs.triagePolicy`, `docs.designGuide` | Paths to a triage policy or design guide, if the repository has one. |
170
+ | `labels.<hook>` | Readable name for a hook, used in logs. |
171
+
172
+ Hooks (keys under `hooks`; no others are accepted):
173
+
174
+ | Hook | Contract |
175
+ | --- | --- |
176
+ | `setup` | Runs once in a fresh worktree before anything else. |
177
+ | `test` | The merge gate. Non-zero blocks a release. Needed for Crew to build the repository. |
178
+ | `build` | Build or compile check. Needed for Crew to build the repository. |
179
+ | `ports` | Prints `KEY=value` lines assigning this worktree's ports. |
180
+ | `isolate` | Prints `KEY=value` lines pointing this worktree at its own state. Gets `CREW_TICKET`, `CREW_BRANCH`. |
181
+ | `handoff` | Makes the built worktree usable by a person and prints how. Gets `CREW_TICKET`, `CREW_BRANCH`, and what `isolate` printed. |
182
+ | `preview` | Starts the dev server detached; last output line is its URL. Gets the `ports` output, `CREW_PREVIEW_HOST`, `CREW_TICKET`, `CREW_BRANCH`. |
183
+ | `intel` | `typescript-lsp`, `serena`, or a command that starts a symbol service and prints its URL. |
184
+ | `map` | A relative path ending in `.md`, or a command that prints an outline of the repository. |
185
+ | `ci_status` | Exit 0 when CI is green for the pushed branch. Gets `CREW_TICKET`, `CREW_BRANCH`. |
186
+ | `version` | Prints the current version on one line. |
187
+ | `bump` | Applies `CREW_BUMP` (`major`, `minor`, `patch`) and prints the new version on one line. |
188
+ | `deploy` | Ships the release. Only for `release.mode: local`. Runs in the release checkout after the version commit and tag are pushed to the base branch, with no extra variables. Its exit status is the release's result, so it must wait for the outcome and fail when the deployment fails. |
189
+ | `pr` | Opens a pull request and prints its URL or number. Gets `CREW_TICKET`, `CREW_BRANCH`, `CREW_BASE`, `CREW_TITLE`. |
190
+ | `merged` | Exit 0 when this ticket's branch has landed on the base branch. Gets `CREW_TICKET`, `CREW_BRANCH`, `CREW_BASE`. |
191
+ | `released` | Prints what is live now, a version or commit sha, on one line. Prints nothing when it does not know. |
192
+
193
+ Release (keys under `release`):
194
+
195
+ | Key | Values and meaning |
196
+ | --- | --- |
197
+ | `mode` | `local` (default), `integrate`, `ci_manual`, `ci_auto`, `external`. |
198
+ | `versioning` | `auto` (default) or `none`. |
199
+ | `versionFiles` | JSON files with a string `version` field that Crew rewrites. Default `[package.json]`. A plain-text file is refused. |
200
+ | `changelog` | Path of the changelog Crew writes. Default `CHANGELOG.md`. `false` for none. |
201
+ | `tag`, `tagPattern` | Tag template (default `v{version}`) and the glob that finds the last release tag (default `v*`). Set both if existing tags are named differently. `tag: false` for no tag. |
202
+ | `ci.provider`, `ci.ref` | `github`, `buildkite`, `other` or `none`, and the workflow file or pipeline. For `ci_*` modes. |
203
+ | `verify.match` | `commit` (default; `released` prints a sha) or `version`. |
204
+ | `verify.timeoutSeconds`, `verify.intervalSeconds` | How long to wait for `released` to match, and how often to ask. Defaults 600 and 15. |
205
+
206
+ ### Combinations that are refused
207
+
208
+ - `ci_manual` or `ci_auto` without `hooks.released`, or without a `release.ci.provider`.
209
+ - `external` without `hooks.merged`.
210
+ - `integrate` together with `hooks.deploy`.
211
+ - `local` without `hooks.deploy` (reported as not ready to release).
212
+ - `hooks.bump` together with `release.versionFiles`.
213
+ - `release.versioning: none` together with `hooks.bump` or `release.versionFiles`.
214
+ - `ci_auto` together with a `deploy` hook that also ships, which releases twice.
215
+
216
+ ### A deploy hook that dispatches a pipeline
217
+
218
+ A command that starts a pipeline usually returns before the run exists and does not say which run it started. A `deploy` hook built on one has to find the new run and wait for its result, or it reports success for a deployment nobody watched. With GitHub Actions and a workflow that has a `workflow_dispatch` trigger:
219
+
220
+ ```yaml
221
+ deploy: |
222
+ set -e
223
+ wf=<workflow file>
224
+ before="$(gh run list --workflow "$wf" --limit 1 --json databaseId --jq '.[0].databaseId // 0')"
225
+ gh workflow run "$wf" --ref <base branch>
226
+ run=""
227
+ for _ in $(seq 1 30); do
228
+ run="$(gh run list --workflow "$wf" --limit 1 --json databaseId --jq '.[0].databaseId // 0')"
229
+ [ "$run" -gt "$before" ] && break
230
+ run=""
231
+ sleep 2
232
+ done
233
+ [ -n "$run" ] || { echo "deploy: the $wf run never appeared" >&2; exit 1; }
234
+ gh run watch "$run" --exit-status
235
+ ```
236
+
237
+ ### A small complete example
238
+
239
+ ```yaml
240
+ # Crew's contract for this repository: https://crew.tablation.dev/repo-spec
241
+ version: 1
242
+
243
+ # POSIX-shell hooks; nothing here is specific to one operating system.
244
+ platform: unix
245
+
246
+ worktrees:
247
+ # The test suite reads its settings from this file, which is gitignored.
248
+ copy: [.env.test]
249
+
250
+ hooks:
251
+ setup: npm ci
252
+ # The same three steps .github/workflows/ci.yml runs on every pull request.
253
+ test: |
254
+ ok=0
255
+ npm run lint || ok=1
256
+ npm run typecheck || ok=1
257
+ npm test || ok=1
258
+ exit "$ok"
259
+ build: npm run build
260
+ # What the registry serves, matched against the version just released.
261
+ released: npm view example-package version
262
+
263
+ labels:
264
+ test: lint, typecheck, unit tests
265
+
266
+ release:
267
+ # .github/workflows/publish.yml publishes when a v* tag is pushed.
268
+ mode: ci_auto
269
+ ci: { provider: github, ref: .github/workflows/publish.yml }
270
+ versionFiles: [package.json]
271
+ changelog: CHANGELOG.md
272
+ verify:
273
+ match: version
274
+ timeoutSeconds: 900
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.151.4",
3
+ "version": "0.152.1",
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",
@@ -25,6 +25,7 @@
25
25
  "dist",
26
26
  "bin",
27
27
  "prompts",
28
+ "docs/repo-setup-prompt.md",
28
29
  "crew.example.yaml",
29
30
  "README.md",
30
31
  "LICENSE"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: Adopt Repository Contract
3
- description: How the dev seat writes a repository's `.crew.yaml` from its checkout (hooks, release mode, sandbox section) and how QA verifies it by running the hooks and `crew repos check --strict`. Fetch when a ticket asks the crew to write or adopt a repository's contract.
3
+ description: How the dev seat writes a repository's `.crew.yaml` from its checkout (hooks, release mode) and how QA verifies it by running the hooks and `crew repos check --strict`. Fetch when a ticket asks the crew to write or adopt a repository's contract.
4
4
  ---
5
5
  # Adopting a repository: writing its `.crew.yaml`
6
6
 
@@ -8,58 +8,33 @@ A repository added from the app arrives with a setup ticket asking the crew to
8
8
  write its contract: a `.crew.yaml` at the checkout root. The file is the only
9
9
  thing that knows how this repository tests, builds and releases, so write it
10
10
  from what the checkout shows, never from habit. The repo spec that ships with crew is the field
11
- reference (`crew repos check` prints what it parsed); this skill is the procedure.
11
+ reference (`crew repos check` prints what it parsed); `crew repos prompt` is the
12
+ procedure; this skill is what a ticket adds to it.
12
13
 
13
14
  ## Dev: write the file
14
15
 
15
- 1. **Read the checkout first.** Package manifests (`package.json`,
16
- `Package.swift`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `Makefile`), the
17
- README's build and test section, and every CI workflow
18
- (`.github/workflows/`, `.buildkite/`, and the like). Note which commands CI
19
- runs: those are the hooks, because they are what the maintainers already trust.
20
- 2. **Ask the tool for a baseline.** Run `crew repos hooks --json` against the
21
- checkout (the file-sniff proposal plus detected `recipes`), and `crew repos
22
- hooks --agent` where the harness allows it (it needs a signed-in toolchain; a
23
- `reason` such as `not_signed_in` or `unsupported_harness` is not a failure of
24
- the ticket, so carry on from the sniff and say so). Treat both as a draft:
25
- where the sniff and CI disagree, CI wins. Never use `--write` on a route for
26
- this ticket; the contract belongs in the repository, committed on the branch.
27
- 3. **Choose `release.mode` from what the repository shows.**
28
- - A release workflow (a tag or merge triggers CI that publishes or deploys):
29
- `release.mode: ci_auto`, with a `hooks.released` that prints what is live
30
- (a commit sha or version) and `release.verify.match` to suit. Do not also
31
- write a `deploy` hook, or the release happens twice.
32
- - Otherwise: `release.mode: integrate` (the crew merges and tags, nothing is deployed).
33
- - Do not pick `local` unless the repository has a deploy script a person runs
34
- today, and then `hooks.deploy` is required. Do not pick `external` or
35
- `ci_manual` without evidence in the checkout.
36
- - If `ci_auto` is the right mode but `released` cannot be derived from the
37
- checkout (no health endpoint, no registry name), that is a question for the
38
- operator, not a guess (see "Nothing to detect").
39
- 4. **Versioning.** If the repository keeps a version, point `version`/`bump` or
40
- `release.versionFiles` at where it lives. If it keeps none, set
41
- `release.versioning: none`. If it keeps no changelog, `release.changelog: false`.
42
- 5. **Add a `sandbox:` section only when needed.** The base sandbox image has git,
43
- curl and the agent toolchain. If the hooks need a runtime or system package
44
- beyond that (a language toolchain, a database client, a compiler), declare it
45
- under `sandbox.packages` (apt names), allow run-time downloads the tests
46
- really make through `sandbox.toolchains`/`sandbox.hosts`, and keep baked
47
- steps in `sandbox.setup`. A repository whose hooks need nothing extra gets no
48
- `sandbox:` section.
49
- 6. **Run every hook once before committing**, from the checkout (or the ticket's
50
- worktree), in the order `setup`, `test`, `build`, then any `ports`,
51
- `isolate`, `version` that you wrote. Judge by exit code. A hook that fails
52
- because the repository itself is broken is not yours to fix on this ticket:
53
- record it in the file's comment and file it as its own ticket. A hook you
54
- could not run (a tool missing on this machine) is stated in your comment, not
55
- assumed to work.
56
- 7. **Write the file with comments.** Each non-obvious choice gets a one-line
57
- comment saying what in the checkout justified it ("mode is ci_auto: .github/workflows/release.yml
58
- publishes on tag"). A reader should be able to audit the file without
59
- re-deriving it.
60
- 8. **Check it.** Run `crew repos check --strict` from the checkout and fix
61
- everything it prints until it exits 0. Quote the summary in your hand-off.
62
- 9. Commit only `.crew.yaml` (and anything the ticket names). Hand off as usual.
16
+ The procedure for working out and testing the file is a standalone prompt that
17
+ ships with crew, shared with people who set a repository up by hand. Run
18
+ `crew repos prompt` and follow it. Where it says "me", the ticket's operator
19
+ stands in: a question it tells you to ask goes through the lane's person-stop
20
+ rule (see "Nothing to detect"), not into a chat.
21
+
22
+ What the ticket adds to that procedure:
23
+
24
+ 1. **The output is committed, not left for review.** The prompt ends with an
25
+ uncommitted file; here you commit only `.crew.yaml` (and anything the ticket
26
+ names) on the ticket's branch and hand off as usual. Never write hooks to a
27
+ route (`--write route`): the contract belongs in the repository.
28
+ 2. **Hook suggestions are a draft.** `crew repos hooks --json` (and `--agent`
29
+ where the harness allows it) may help as a baseline. A `reason` such as
30
+ `not_signed_in` or `unsupported_harness` is not a failure of the ticket:
31
+ carry on from the checkout and say so. Where a suggestion and the repository's
32
+ CI disagree, CI wins.
33
+ 3. **A hook that fails because the repository itself is broken** is not yours to
34
+ fix on this ticket: record it in the file's comment and file it as its own
35
+ ticket. A hook you could not run (a tool missing on this machine) is stated
36
+ in your comment, not assumed to work.
37
+ 4. **Quote the `crew repos check --strict` summary** (exit 0) in your hand-off.
63
38
 
64
39
  ## Nothing to detect
65
40
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: Adopt Repository Contract
3
- description: How the dev seat writes a repository's `.crew.yaml` from its checkout (hooks, release mode, sandbox section) and how QA verifies it by running the hooks and `crew repos check --strict`. Fetch when a ticket asks the crew to write or adopt a repository's contract.
3
+ description: How the dev seat writes a repository's `.crew.yaml` from its checkout (hooks, release mode) and how QA verifies it by running the hooks and `crew repos check --strict`. Fetch when a ticket asks the crew to write or adopt a repository's contract.
4
4
  ---
5
5
  # Adopting a repository: writing its `.crew.yaml`
6
6
 
@@ -8,58 +8,33 @@ A repository added from the app arrives with a setup ticket asking the crew to
8
8
  write its contract: a `.crew.yaml` at the checkout root. The file is the only
9
9
  thing that knows how this repository tests, builds and releases, so write it
10
10
  from what the checkout shows, never from habit. The repo spec that ships with crew is the field
11
- reference (`crew repos check` prints what it parsed); this skill is the procedure.
11
+ reference (`crew repos check` prints what it parsed); `crew repos prompt` is the
12
+ procedure; this skill is what a ticket adds to it.
12
13
 
13
14
  ## Dev: write the file
14
15
 
15
- 1. **Read the checkout first.** Package manifests (`package.json`,
16
- `Package.swift`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `Makefile`), the
17
- README's build and test section, and every CI workflow
18
- (`.github/workflows/`, `.buildkite/`, and the like). Note which commands CI
19
- runs: those are the hooks, because they are what the maintainers already trust.
20
- 2. **Ask the tool for a baseline.** Run `crew repos hooks --json` against the
21
- checkout (the file-sniff proposal plus detected `recipes`), and `crew repos
22
- hooks --agent` where the harness allows it (it needs a signed-in toolchain; a
23
- `reason` such as `not_signed_in` or `unsupported_harness` is not a failure of
24
- the ticket, so carry on from the sniff and say so). Treat both as a draft:
25
- where the sniff and CI disagree, CI wins. Never use `--write` on a route for
26
- this ticket; the contract belongs in the repository, committed on the branch.
27
- 3. **Choose `release.mode` from what the repository shows.**
28
- - A release workflow (a tag or merge triggers CI that publishes or deploys):
29
- `release.mode: ci_auto`, with a `hooks.released` that prints what is live
30
- (a commit sha or version) and `release.verify.match` to suit. Do not also
31
- write a `deploy` hook, or the release happens twice.
32
- - Otherwise: `release.mode: integrate` (the crew merges and tags, nothing is deployed).
33
- - Do not pick `local` unless the repository has a deploy script a person runs
34
- today, and then `hooks.deploy` is required. Do not pick `external` or
35
- `ci_manual` without evidence in the checkout.
36
- - If `ci_auto` is the right mode but `released` cannot be derived from the
37
- checkout (no health endpoint, no registry name), that is a question for the
38
- operator, not a guess (see "Nothing to detect").
39
- 4. **Versioning.** If the repository keeps a version, point `version`/`bump` or
40
- `release.versionFiles` at where it lives. If it keeps none, set
41
- `release.versioning: none`. If it keeps no changelog, `release.changelog: false`.
42
- 5. **Add a `sandbox:` section only when needed.** The base sandbox image has git,
43
- curl and the agent toolchain. If the hooks need a runtime or system package
44
- beyond that (a language toolchain, a database client, a compiler), declare it
45
- under `sandbox.packages` (apt names), allow run-time downloads the tests
46
- really make through `sandbox.toolchains`/`sandbox.hosts`, and keep baked
47
- steps in `sandbox.setup`. A repository whose hooks need nothing extra gets no
48
- `sandbox:` section.
49
- 6. **Run every hook once before committing**, from the checkout (or the ticket's
50
- worktree), in the order `setup`, `test`, `build`, then any `ports`,
51
- `isolate`, `version` that you wrote. Judge by exit code. A hook that fails
52
- because the repository itself is broken is not yours to fix on this ticket:
53
- record it in the file's comment and file it as its own ticket. A hook you
54
- could not run (a tool missing on this machine) is stated in your comment, not
55
- assumed to work.
56
- 7. **Write the file with comments.** Each non-obvious choice gets a one-line
57
- comment saying what in the checkout justified it ("mode is ci_auto: .github/workflows/release.yml
58
- publishes on tag"). A reader should be able to audit the file without
59
- re-deriving it.
60
- 8. **Check it.** Run `crew repos check --strict` from the checkout and fix
61
- everything it prints until it exits 0. Quote the summary in your hand-off.
62
- 9. Commit only `.crew.yaml` (and anything the ticket names). Hand off as usual.
16
+ The procedure for working out and testing the file is a standalone prompt that
17
+ ships with crew, shared with people who set a repository up by hand. Run
18
+ `crew repos prompt` and follow it. Where it says "me", the ticket's operator
19
+ stands in: a question it tells you to ask goes through the lane's person-stop
20
+ rule (see "Nothing to detect"), not into a chat.
21
+
22
+ What the ticket adds to that procedure:
23
+
24
+ 1. **The output is committed, not left for review.** The prompt ends with an
25
+ uncommitted file; here you commit only `.crew.yaml` (and anything the ticket
26
+ names) on the ticket's branch and hand off as usual. Never write hooks to a
27
+ route (`--write route`): the contract belongs in the repository.
28
+ 2. **Hook suggestions are a draft.** `crew repos hooks --json` (and `--agent`
29
+ where the harness allows it) may help as a baseline. A `reason` such as
30
+ `not_signed_in` or `unsupported_harness` is not a failure of the ticket:
31
+ carry on from the checkout and say so. Where a suggestion and the repository's
32
+ CI disagree, CI wins.
33
+ 3. **A hook that fails because the repository itself is broken** is not yours to
34
+ fix on this ticket: record it in the file's comment and file it as its own
35
+ ticket. A hook you could not run (a tool missing on this machine) is stated
36
+ in your comment, not assumed to work.
37
+ 4. **Quote the `crew repos check --strict` summary** (exit 0) in your hand-off.
63
38
 
64
39
  ## Nothing to detect
65
40