@tablation/crew 0.151.4 → 0.152.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
  }
@@ -16145,7 +16146,7 @@ async function runSelfLaunchCheck(own, spawnFn = spawnChild, launch = selfLaunch
16145
16146
  }
16146
16147
 
16147
16148
  // src/cli.ts
16148
- import { resolve as resolve7, dirname as dirname37, join as join64, basename as basename17 } from "path";
16149
+ import { resolve as resolve7, dirname as dirname37, join as join65, basename as basename17 } from "path";
16149
16150
  import { fileURLToPath as fileURLToPath2 } from "url";
16150
16151
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
16151
16152
  import { spawnSync as spawnSync14 } from "child_process";
@@ -26133,9 +26134,17 @@ async function showLogEntry(route2, entryId, opts = {}) {
26133
26134
  };
26134
26135
  }
26135
26136
 
26137
+ // src/repo-setup-prompt.ts
26138
+ import { readFileSync as readFileSync52 } from "fs";
26139
+ import { join as join55 } from "path";
26140
+ var REPO_SETUP_PROMPT_PATH = join55("docs", "repo-setup-prompt.md");
26141
+ function readRepoSetupPrompt(crewHome) {
26142
+ return readFileSync52(join55(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
26143
+ }
26144
+
26136
26145
  // src/repos-check.ts
26137
26146
  import { spawnSync as spawnSync13 } from "child_process";
26138
- import { readFileSync as readFileSync52 } from "fs";
26147
+ import { readFileSync as readFileSync53 } from "fs";
26139
26148
  import { basename as basename12 } from "path";
26140
26149
  var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
26141
26150
  function checkHookSyntax(script, shell) {
@@ -26176,7 +26185,7 @@ function checkRepoSpec(dir, opts = {}) {
26176
26185
  }
26177
26186
  let parsed;
26178
26187
  try {
26179
- parsed = parseRepoConfig(readFileSync52(file, "utf8"), file);
26188
+ parsed = parseRepoConfig(readFileSync53(file, "utf8"), file);
26180
26189
  } catch (e) {
26181
26190
  if (!(e instanceof RepoConfigError)) throw e;
26182
26191
  return { ...empty, file, error: e.message, exitCode: 1 };
@@ -26640,7 +26649,7 @@ ${run4.err}` });
26640
26649
  }
26641
26650
 
26642
26651
  // src/sample-ticket.ts
26643
- import { basename as basename13, dirname as dirname32, join as join55 } from "path";
26652
+ import { basename as basename13, dirname as dirname32, join as join56 } from "path";
26644
26653
  var SAMPLE_REPO = "crew-sample";
26645
26654
  var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
26646
26655
  var SAMPLE_MARKER = "sample: true";
@@ -26663,8 +26672,8 @@ has something safe to work on: its test and build hooks always pass, it has no
26663
26672
  remote, and \`crew sample-ticket --remove\` deletes it.
26664
26673
  `;
26665
26674
  function sampleDir(existing, reposBase, workspace) {
26666
- if (existing.length > 0) return join55(dirname32(existing[0]), SAMPLE_REPO);
26667
- return join55(reposBase, workspace, SAMPLE_REPO);
26675
+ if (existing.length > 0) return join56(dirname32(existing[0]), SAMPLE_REPO);
26676
+ return join56(reposBase, workspace, SAMPLE_REPO);
26668
26677
  }
26669
26678
  var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
26670
26679
  function sampleDescription() {
@@ -26931,8 +26940,8 @@ function fixPhaseNothingToOffer(o) {
26931
26940
  }
26932
26941
 
26933
26942
  // 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";
26943
+ import { existsSync as existsSync54, readFileSync as readFileSync54, readdirSync as readdirSync16 } from "fs";
26944
+ import { basename as basename14, dirname as dirname33, join as join57, resolve as resolve5 } from "path";
26936
26945
  function planWorktreeSweep(target, tickets, contract) {
26937
26946
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
26938
26947
  const verified = contract.statuses.verified;
@@ -27009,7 +27018,7 @@ function siblingWorktreeDirs(target) {
27009
27018
  for (const name of names) {
27010
27019
  if (!name.startsWith(stem)) continue;
27011
27020
  const m = DIR_NUMBER_SUFFIXED.exec(name);
27012
- const path = join56(parent, name);
27021
+ const path = join57(parent, name);
27013
27022
  if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
27014
27023
  }
27015
27024
  return out;
@@ -27136,7 +27145,7 @@ function isHandBackMerge(path, base) {
27136
27145
  if (!msgPath) return false;
27137
27146
  let first;
27138
27147
  try {
27139
- first = readFileSync53(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
27148
+ first = readFileSync54(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
27140
27149
  } catch {
27141
27150
  return false;
27142
27151
  }
@@ -27242,13 +27251,13 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
27242
27251
 
27243
27252
  // src/stream-sweep.ts
27244
27253
  import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync16 } from "fs";
27245
- import { join as join57 } from "path";
27254
+ import { join as join58 } from "path";
27246
27255
  var DAY_MS2 = 24 * 60 * 60 * 1e3;
27247
27256
  function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
27248
- const dir = join57(stateDir, "streams");
27257
+ const dir = join58(stateDir, "streams");
27249
27258
  if (!existsSync55(dir)) return [];
27250
27259
  const cutoff = now - retentionDays * DAY_MS2;
27251
- return readdirSync17(dir).map((name) => join57(dir, name)).filter((path) => {
27260
+ return readdirSync17(dir).map((name) => join58(dir, name)).filter((path) => {
27252
27261
  try {
27253
27262
  return statSync16(path).mtimeMs < cutoff;
27254
27263
  } catch {
@@ -27276,7 +27285,7 @@ function applyStreamSweep(paths, dryRun, log) {
27276
27285
  function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
27277
27286
  if (!existsSync55(stateDir)) return [];
27278
27287
  const cutoff = now - retentionDays * DAY_MS2;
27279
- return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join57(stateDir, name)).filter((path) => {
27288
+ return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join58(stateDir, name)).filter((path) => {
27280
27289
  try {
27281
27290
  return statSync16(path).mtimeMs < cutoff;
27282
27291
  } catch {
@@ -27286,7 +27295,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
27286
27295
  }
27287
27296
 
27288
27297
  // 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";
27298
+ 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
27299
  import { createInterface } from "readline/promises";
27291
27300
 
27292
27301
  // src/periscope-resume.ts
@@ -27363,9 +27372,9 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
27363
27372
 
27364
27373
  // src/bundle-staleness.ts
27365
27374
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
27366
- import { join as join58 } from "path";
27375
+ import { join as join59 } from "path";
27367
27376
  function builtVersion() {
27368
- return true ? "0.151.4" : null;
27377
+ return true ? "0.152.0" : null;
27369
27378
  }
27370
27379
  var REBUILD_HINT = "rebuild with npm run build";
27371
27380
  function newestMtime(path) {
@@ -27378,17 +27387,17 @@ function newestMtime(path) {
27378
27387
  if (stat2.isFile()) return stat2.mtimeMs;
27379
27388
  if (!stat2.isDirectory()) return 0;
27380
27389
  let latest = stat2.mtimeMs;
27381
- for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join58(path, e.name)));
27390
+ for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join59(path, e.name)));
27382
27391
  return latest;
27383
27392
  }
27384
27393
  function bundleStaleness(i) {
27385
27394
  if (i.built === null || i.compiled) return null;
27386
- const src = join58(i.home, "src");
27395
+ const src = join59(i.home, "src");
27387
27396
  if (!existsSync56(src)) return null;
27388
27397
  if (i.built !== i.current) {
27389
27398
  return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
27390
27399
  }
27391
- const bundle = statSafe(join58(i.home, "dist", "cli.js"));
27400
+ const bundle = statSafe(join59(i.home, "dist", "cli.js"));
27392
27401
  if (bundle === null) return null;
27393
27402
  if (newestMtime(src) > bundle) {
27394
27403
  return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
@@ -27606,8 +27615,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
27606
27615
  import { createServer as createHttpServer } from "http";
27607
27616
  import { spawn as spawn10 } from "child_process";
27608
27617
  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";
27618
+ import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync55, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
27619
+ import { join as join60 } from "path";
27611
27620
 
27612
27621
  // src/secret-compare.ts
27613
27622
  import { timingSafeEqual } from "crypto";
@@ -27700,20 +27709,20 @@ var defaultSpawn2 = (cmd, args, env) => {
27700
27709
  return child;
27701
27710
  };
27702
27711
  function syncDaemonStatePath(stateDir, workspaceId) {
27703
- return join59(stateDir, "passengers", `${workspaceId}-sync.json`);
27712
+ return join60(stateDir, "passengers", `${workspaceId}-sync.json`);
27704
27713
  }
27705
27714
  function readPersistedSyncDaemon(stateDir, workspaceId) {
27706
27715
  const path = syncDaemonStatePath(stateDir, workspaceId);
27707
27716
  if (!existsSync57(path)) return void 0;
27708
27717
  try {
27709
- return JSON.parse(readFileSync54(path, "utf8"));
27718
+ return JSON.parse(readFileSync55(path, "utf8"));
27710
27719
  } catch {
27711
27720
  return void 0;
27712
27721
  }
27713
27722
  }
27714
27723
  function writePersistedSyncDaemon(stateDir, state) {
27715
27724
  const path = syncDaemonStatePath(stateDir, state.workspaceId);
27716
- mkdirSync40(join59(stateDir, "passengers"), { recursive: true });
27725
+ mkdirSync40(join60(stateDir, "passengers"), { recursive: true });
27717
27726
  writeFileSync42(path, `${JSON.stringify(state, null, 2)}
27718
27727
  `);
27719
27728
  }
@@ -27734,7 +27743,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
27734
27743
  }
27735
27744
  }
27736
27745
  function readAllPersistedSyncWorkspaceIds(stateDir) {
27737
- const dir = join59(stateDir, "passengers");
27746
+ const dir = join60(stateDir, "passengers");
27738
27747
  if (!existsSync57(dir)) return [];
27739
27748
  const suffix = "-sync.json";
27740
27749
  return readdirSync19(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
@@ -28202,7 +28211,7 @@ async function startWorktreeIntel(d) {
28202
28211
  }
28203
28212
 
28204
28213
  // src/contract-refusal.ts
28205
- import { join as join60 } from "path";
28214
+ import { join as join61 } from "path";
28206
28215
  function contractFixers(dir, baseRef, tickets, locate) {
28207
28216
  const out = [];
28208
28217
  for (const t of tickets) {
@@ -28214,7 +28223,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
28214
28223
  const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
28215
28224
  if (text2 === null) continue;
28216
28225
  try {
28217
- parseRepoConfig(text2, join60(dir, file));
28226
+ parseRepoConfig(text2, join61(dir, file));
28218
28227
  } catch (e) {
28219
28228
  if (e instanceof RepoConfigError) continue;
28220
28229
  throw e;
@@ -28240,7 +28249,7 @@ import {
28240
28249
  } from "fs";
28241
28250
  import { createConnection } from "net";
28242
28251
  import { createServer as createServer2 } from "http";
28243
- import { basename as basename15, dirname as dirname35, join as join61 } from "path";
28252
+ import { basename as basename15, dirname as dirname35, join as join62 } from "path";
28244
28253
  import { execFile as execFile6, spawn as spawn13 } from "child_process";
28245
28254
 
28246
28255
  // src/periscope-control.ts
@@ -28478,7 +28487,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
28478
28487
  // src/control-api.ts
28479
28488
  var PAUSABLE = ["dev", "design", "qa"];
28480
28489
  var CONTROL_SOCKET_NAME = "control.sock";
28481
- var controlSocketFor = (stateDir) => join61(stateDir, CONTROL_SOCKET_NAME);
28490
+ var controlSocketFor = (stateDir) => join62(stateDir, CONTROL_SOCKET_NAME);
28482
28491
  var MAX_SOCKET_PATH = 100;
28483
28492
  var MAX_TAIL_BYTES = 1024 * 1024;
28484
28493
  var MAX_WAIT_SECONDS = 30;
@@ -28565,7 +28574,7 @@ function candidates(live2, rotated) {
28565
28574
  const out = [live2];
28566
28575
  if (!rotated) return out;
28567
28576
  try {
28568
- for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join61(dirname35(live2), n));
28577
+ for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join62(dirname35(live2), n));
28569
28578
  } catch {
28570
28579
  }
28571
28580
  return out;
@@ -28824,7 +28833,7 @@ async function route(deps, method, url, req, abort) {
28824
28833
  if (p.startsWith("/streams/") && get2) {
28825
28834
  const run4 = decodeURIComponent(p.slice("/streams/".length));
28826
28835
  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`);
28836
+ const file = join62(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
28828
28837
  if (!existsSync58(file)) return err2(404, "no such run");
28829
28838
  return tailReply(file, url.searchParams, false, abort);
28830
28839
  }
@@ -28992,19 +29001,19 @@ function crewJson(args, timeoutMs = CREW_JSON_TIMEOUT_MS) {
28992
29001
 
28993
29002
  // src/periscope-mcp.ts
28994
29003
  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";
29004
+ import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join64, relative as relative2, resolve as resolve6, sep } from "path";
28996
29005
  import { z } from "zod";
28997
29006
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
28998
29007
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
28999
29008
 
29000
29009
  // src/periscope-endpoints.ts
29001
29010
  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`);
29011
+ import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync42, readdirSync as readdirSync21, readFileSync as readFileSync56, rmSync as rmSync26, writeFileSync as writeFileSync43 } from "fs";
29012
+ import { join as join63 } from "path";
29013
+ var secretDir = (stateDir) => join63(stateDir, "periscope-mcp");
29014
+ var secretFile = (stateDir, id) => join63(secretDir(stateDir), `${id}.json`);
29015
+ var endpointDir = (stateDir) => join63(stateDir, "periscope-endpoints");
29016
+ var endpointFile = (stateDir, id) => join63(endpointDir(stateDir), `${id}.json`);
29008
29017
  function mintPeriscopeSecret(stateDir, ticketRecordId) {
29009
29018
  mkdirSync42(secretDir(stateDir), { recursive: true, mode: 448 });
29010
29019
  const secret = randomBytes3(32).toString("base64url");
@@ -29016,7 +29025,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
29016
29025
  }
29017
29026
  function readPeriscopeSecret(stateDir, ticketRecordId) {
29018
29027
  try {
29019
- const v = JSON.parse(readFileSync55(secretFile(stateDir, ticketRecordId), "utf8"));
29028
+ const v = JSON.parse(readFileSync56(secretFile(stateDir, ticketRecordId), "utf8"));
29020
29029
  return typeof v.secret === "string" && v.secret ? v.secret : void 0;
29021
29030
  } catch {
29022
29031
  return void 0;
@@ -29027,7 +29036,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
29027
29036
  }
29028
29037
  function readPeriscopeEndpoint(stateDir, ticketRecordId) {
29029
29038
  try {
29030
- return JSON.parse(readFileSync55(endpointFile(stateDir, ticketRecordId), "utf8"));
29039
+ return JSON.parse(readFileSync56(endpointFile(stateDir, ticketRecordId), "utf8"));
29031
29040
  } catch {
29032
29041
  return void 0;
29033
29042
  }
@@ -29145,13 +29154,13 @@ async function resolveInWorktree(root, requested) {
29145
29154
  let abs;
29146
29155
  if (isAbsolute5(requested)) {
29147
29156
  abs = resolve6(requested);
29148
- if (isInside(root, abs)) abs = join63(realRoot, relative2(root, abs));
29157
+ if (isInside(root, abs)) abs = join64(realRoot, relative2(root, abs));
29149
29158
  } else {
29150
29159
  abs = resolve6(realRoot, requested);
29151
29160
  }
29152
29161
  if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
29153
29162
  const { real, rest } = await realAncestor(abs);
29154
- const final = rest ? join63(real, rest) : real;
29163
+ const final = rest ? join64(real, rest) : real;
29155
29164
  if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
29156
29165
  if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
29157
29166
  return final;
@@ -29219,7 +29228,7 @@ function createPeriscopeMcpServer(d, sc) {
29219
29228
  const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
29220
29229
  const lines2 = await Promise.all(entries.map(async (e) => {
29221
29230
  if (e.isDirectory()) return `[DIR] ${e.name}`;
29222
- const size = (await lstat(join63(abs, e.name))).size;
29231
+ const size = (await lstat(join64(abs, e.name))).size;
29223
29232
  return `[FILE] ${e.name} (${size} bytes)`;
29224
29233
  }));
29225
29234
  return text(lines2.join("\n") || "(empty)");
@@ -29285,7 +29294,7 @@ function createPeriscopeMcpServer(d, sc) {
29285
29294
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
29286
29295
  }, async ({ path }) => {
29287
29296
  const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
29288
- const abs = join63(parent, basename16(path));
29297
+ const abs = join64(parent, basename16(path));
29289
29298
  if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
29290
29299
  const st = await lstat(abs).catch(() => void 0);
29291
29300
  if (!st) return text(`${path} does not exist`, true);
@@ -29612,6 +29621,7 @@ function usage(problem, requested = false) {
29612
29621
  crew repos check [PATH] validate a checkout's .crew.yaml without attaching it (--route ROUTE, --strict, --json)
29613
29622
  crew repos clone [ROUTE] NAME clone a Repos row's remote into the route directory and attach it (--dir PATH, --dry-run, --json)
29614
29623
  crew repos hooks [ROUTE] NAME suggest test/build hooks for a checkout (--agent, --write route|repo, --recipes, --json)
29624
+ 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
29625
  crew repos list ROUTE the checkouts a route has, with the tracker's Repos row each matches (--json: every Repos row too)
29616
29626
  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
29627
  crew logbook show [route] ID [--prompt] one entry; --prompt reconstructs and verifies its prompt
@@ -29749,6 +29759,12 @@ function runReposCheck(dir, ship) {
29749
29759
  }
29750
29760
  process.exitCode = report.exitCode;
29751
29761
  }
29762
+ if (command === "repos" && positional[1] === "prompt") {
29763
+ const prompt = readRepoSetupPrompt(CREW_HOME);
29764
+ process.stdout.write(flag("json") ? `${JSON.stringify({ prompt, version: crewVersion(CREW_HOME) })}
29765
+ ` : prompt);
29766
+ process.exit(0);
29767
+ }
29752
29768
  var reposCheckBare = command === "repos" && positional[1] === "check" && !value("route") && positional.length < 4;
29753
29769
  if (reposCheckBare) {
29754
29770
  runReposCheck(resolvePath(positional[2] ?? "."));
@@ -29794,7 +29810,7 @@ if (command === "provision") {
29794
29810
  process.exit(outcome.code);
29795
29811
  }
29796
29812
  if (command === "pool-member") {
29797
- const pool = poolConfigFrom(argv, process.env, () => readFileSync56(0, "utf8"));
29813
+ const pool = poolConfigFrom(argv, process.env, () => readFileSync57(0, "utf8"));
29798
29814
  if (typeof pool === "string") {
29799
29815
  process.stderr.write(`crew pool-member: ${pool}
29800
29816
  `);
@@ -30148,7 +30164,7 @@ if (command === "passenger-sync-daemon") {
30148
30164
  throw e;
30149
30165
  }
30150
30166
  if (command === "credential") {
30151
- const r = runCredential(positional[1], readFileSync56(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
30167
+ const r = runCredential(positional[1], readFileSync57(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
30152
30168
  process.stdout.write(r.out);
30153
30169
  process.stderr.write(r.err);
30154
30170
  process.exit(r.code);
@@ -30160,9 +30176,9 @@ if (command === "passenger-sync-daemon") {
30160
30176
  forges: cfg.ship.forges,
30161
30177
  stateDir: cfg.ship.stateDir,
30162
30178
  configFile: cfg.configFile,
30163
- readFile: (p) => readFileSync56(p, "utf8"),
30179
+ readFile: (p) => readFileSync57(p, "utf8"),
30164
30180
  writeFile: (p, t) => writeFileSync44(p, t),
30165
- stdin: () => readFileSync56(0, "utf8"),
30181
+ stdin: () => readFileSync57(0, "utf8"),
30166
30182
  env: process.env
30167
30183
  }
30168
30184
  );
@@ -30505,7 +30521,7 @@ if (command === "passenger-sync-daemon") {
30505
30521
  for (const l of summarizeJobs(results, { dryRun, verbose: flag("verbose"), host })) emit.emit(l);
30506
30522
  if (host === "linux" && hasSystemd) {
30507
30523
  const label = labelFor(CREW_HOME, "run");
30508
- const staleTimer = join64(homedir11(), ".config", "systemd", "user", `${label}.timer`);
30524
+ const staleTimer = join65(homedir11(), ".config", "systemd", "user", `${label}.timer`);
30509
30525
  if (existsSync60(staleTimer)) {
30510
30526
  emit.emit(
30511
30527
  `removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run, not applied)" : ""}`
@@ -30622,7 +30638,7 @@ if (command === "passenger-sync-daemon") {
30622
30638
  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
30639
  } else if (a.kind === "enable") {
30624
30640
  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));
30641
+ writeFileSync44(cfg.configFile, planEnable(readFileSync57(cfg.configFile, "utf8"), a.route));
30626
30642
  enabledSound.add(a.route);
30627
30643
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
30628
30644
  } else {
@@ -30867,7 +30883,7 @@ ${changed2.map((c) => ` - ${c}
30867
30883
  harnessBin: "claude",
30868
30884
  ...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
30869
30885
  },
30870
- policyFile: join64(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
30886
+ policyFile: join65(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
30871
30887
  repo: mirror,
30872
30888
  origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
30873
30889
  base: effective.branch.base,
@@ -32136,7 +32152,7 @@ ${f.tail.trimEnd()}
32136
32152
  logFile: cfg.ship.logFile
32137
32153
  });
32138
32154
  }
32139
- const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join64(CREW_HOME, "src"), join64(CREW_HOME, "dist"), join64(CREW_HOME, "bin")];
32155
+ const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join65(CREW_HOME, "src"), join65(CREW_HOME, "dist"), join65(CREW_HOME, "bin")];
32140
32156
  const configPaths = daemonConfigPaths(cfg);
32141
32157
  watchPaths.push(...configPaths);
32142
32158
  noteDaemonStarted(cfg.ship.stateDir);
@@ -32445,7 +32461,7 @@ ${f.tail.trimEnd()}
32445
32461
  for (const w of result.warnings) emit.warn(w);
32446
32462
  if (!dryRun) {
32447
32463
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
32448
- const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync56(resolvedPath, "utf8")) : {};
32464
+ const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync57(resolvedPath, "utf8")) : {};
32449
32465
  raw.agentSkills = result.agentSkills;
32450
32466
  mkdirSync43(dirOf2(resolvedPath), { recursive: true });
32451
32467
  writeFileSync44(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -32469,7 +32485,7 @@ ${f.tail.trimEnd()}
32469
32485
  throw e;
32470
32486
  }
32471
32487
  const oldName = cfg.ship.name;
32472
- writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), newName));
32488
+ writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), newName));
32473
32489
  cfg.ship.name = newName;
32474
32490
  let renameMachineId;
32475
32491
  try {
@@ -32512,11 +32528,11 @@ ${f.tail.trimEnd()}
32512
32528
  case "repos": {
32513
32529
  const sub = positional[1];
32514
32530
  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");
32531
+ 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
32532
  process.exit(2);
32517
32533
  };
32518
32534
  if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
32519
- const configText = readFileSync56(cfg.configFile, "utf8");
32535
+ const configText = readFileSync57(cfg.configFile, "utf8");
32520
32536
  if (sub === "check") {
32521
32537
  try {
32522
32538
  const routeArg = value("route") ?? positional[2];
@@ -32555,7 +32571,7 @@ ${f.tail.trimEnd()}
32555
32571
  }
32556
32572
  }, read: (r) => {
32557
32573
  try {
32558
- return readFileSync56(resolvePath(dir, r), "utf8");
32574
+ return readFileSync57(resolvePath(dir, r), "utf8");
32559
32575
  } catch {
32560
32576
  return void 0;
32561
32577
  }
@@ -32699,7 +32715,7 @@ ${f.tail.trimEnd()}
32699
32715
  let resolvedRemotes;
32700
32716
  if (existsSync60(resolvedFile)) {
32701
32717
  try {
32702
- resolvedRemotes = JSON.parse(readFileSync56(resolvedFile, "utf8"));
32718
+ resolvedRemotes = JSON.parse(readFileSync57(resolvedFile, "utf8"));
32703
32719
  } catch {
32704
32720
  }
32705
32721
  }
@@ -32721,7 +32737,7 @@ ${f.tail.trimEnd()}
32721
32737
  repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
32722
32738
  try {
32723
32739
  const path = resolvePath(d, f);
32724
- return Object.keys(parseRepoConfig(readFileSync56(path, "utf8"), path).hooks).length > 0;
32740
+ return Object.keys(parseRepoConfig(readFileSync57(path, "utf8"), path).hooks).length > 0;
32725
32741
  } catch {
32726
32742
  return false;
32727
32743
  }
@@ -32827,7 +32843,7 @@ ${f.tail.trimEnd()}
32827
32843
  process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
32828
32844
  `);
32829
32845
  if (existsSync60(resolvedFile)) {
32830
- const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
32846
+ const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
32831
32847
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
32832
32848
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
32833
32849
  writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -33181,7 +33197,7 @@ Waiting for approval`
33181
33197
  ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, then run `crew connect` again");
33182
33198
  }
33183
33199
  if (found.shipNameAdopted && !dryRun) {
33184
- writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), found.shipNameAdopted));
33200
+ writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync57(cfg.configFile, "utf8"), found.shipNameAdopted));
33185
33201
  cfg.ship.name = found.shipNameAdopted;
33186
33202
  }
33187
33203
  if (found.shipRow) {
@@ -33225,7 +33241,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
33225
33241
  const hadPreviousFile = existsSync60(resolvedPath);
33226
33242
  if (hadPreviousFile) {
33227
33243
  try {
33228
- previous = JSON.parse(readFileSync56(resolvedPath, "utf8"));
33244
+ previous = JSON.parse(readFileSync57(resolvedPath, "utf8"));
33229
33245
  } catch {
33230
33246
  }
33231
33247
  }
@@ -34038,10 +34054,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
34038
34054
  startupSeconds: cfg.ship.intelStartupSeconds,
34039
34055
  prepare: async (path) => {
34040
34056
  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));
34057
+ const src = join65(repoWt.dir, f);
34058
+ if (!existsSync60(src) || existsSync60(join65(path, f))) continue;
34059
+ mkdirSync43(dirOf2(join65(path, f)), { recursive: true });
34060
+ copyFileSync2(src, join65(path, f));
34045
34061
  }
34046
34062
  const setup = repoWt.config.hooks.setup;
34047
34063
  return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
@@ -34368,10 +34384,10 @@ ${where.join("\n")}`);
34368
34384
  },
34369
34385
  prepare: async (path) => {
34370
34386
  for (const f of repoP.config.worktrees.copy) {
34371
- const src = join64(repoP.dir, f);
34387
+ const src = join65(repoP.dir, f);
34372
34388
  if (!existsSync60(src)) continue;
34373
- mkdirSync43(dirOf2(join64(path, f)), { recursive: true });
34374
- copyFileSync2(src, join64(path, f));
34389
+ mkdirSync43(dirOf2(join65(path, f)), { recursive: true });
34390
+ copyFileSync2(src, join65(path, f));
34375
34391
  }
34376
34392
  const setup = repoP.config.hooks.setup;
34377
34393
  return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
@@ -34686,7 +34702,7 @@ ${where.join("\n")}`);
34686
34702
  };
34687
34703
  const droppedRoutes = [];
34688
34704
  try {
34689
- const rawCfg = parseYaml3(readFileSync56(cfg.configFile, "utf8"));
34705
+ const rawCfg = parseYaml3(readFileSync57(cfg.configFile, "utf8"));
34690
34706
  for (const r of rawCfg?.routes ?? []) {
34691
34707
  if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
34692
34708
  try {
@@ -34812,7 +34828,7 @@ ${where.join("\n")}`);
34812
34828
  }
34813
34829
  case "log": {
34814
34830
  try {
34815
- const text2 = readFileSync56(cfg.ship.logFile, "utf8").split("\n");
34831
+ const text2 = readFileSync57(cfg.ship.logFile, "utf8").split("\n");
34816
34832
  process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
34817
34833
  `);
34818
34834
  } catch {
@@ -34836,7 +34852,7 @@ ${where.join("\n")}`);
34836
34852
  };
34837
34853
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
34838
34854
  const tracker = new Tracker(route2, cfg.ship);
34839
- const configText = readFileSync56(cfg.configFile, "utf8");
34855
+ const configText = readFileSync57(cfg.configFile, "utf8");
34840
34856
  const cfgBase = dirname37(cfg.configFile);
34841
34857
  const configured2 = configuredRepos(configText, route2.route, cfgBase);
34842
34858
  const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
@@ -34874,19 +34890,19 @@ ${where.join("\n")}`);
34874
34890
  if (row) {
34875
34891
  await tracker.deleteRepoRow(row.id);
34876
34892
  if (existsSync60(resolvedFile)) {
34877
- const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
34893
+ const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
34878
34894
  if (raw.repoNames) delete raw.repoNames[row.id];
34879
34895
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
34880
34896
  writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
34881
34897
  `);
34882
34898
  }
34883
34899
  }
34884
- if (existsSync60(join64(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
34900
+ if (existsSync60(join65(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
34885
34901
  say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
34886
34902
  break;
34887
34903
  }
34888
34904
  const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
34889
- const fresh = !existsSync60(join64(dir, ".git"));
34905
+ const fresh = !existsSync60(join65(dir, ".git"));
34890
34906
  if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
34891
34907
  if (dryRun) {
34892
34908
  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 +34910,8 @@ ${where.join("\n")}`);
34894
34910
  }
34895
34911
  if (fresh) {
34896
34912
  mkdirSync43(dir, { recursive: true });
34897
- writeFileSync44(join64(dir, "README.md"), SAMPLE_README);
34898
- writeFileSync44(join64(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
34913
+ writeFileSync44(join65(dir, "README.md"), SAMPLE_README);
34914
+ writeFileSync44(join65(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
34899
34915
  const g = (...a) => {
34900
34916
  const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
34901
34917
  if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
@@ -34914,7 +34930,7 @@ ${where.join("\n")}`);
34914
34930
  });
34915
34931
  repoId = (await tracker.createRepoRow(payload)).id;
34916
34932
  if (existsSync60(resolvedFile)) {
34917
- const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
34933
+ const raw = JSON.parse(readFileSync57(resolvedFile, "utf8"));
34918
34934
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
34919
34935
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
34920
34936
  writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -35474,7 +35490,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
35474
35490
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
35475
35491
  const abandons = unitAbandonsAgents(unitPlan, (p) => {
35476
35492
  try {
35477
- return readFileSync56(p, "utf8");
35493
+ return readFileSync57(p, "utf8");
35478
35494
  } catch {
35479
35495
  return null;
35480
35496
  }
@@ -35489,7 +35505,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
35489
35505
  const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
35490
35506
  const keeps = unitAbandonsAgents(pPlan, (p) => {
35491
35507
  try {
35492
- return readFileSync56(p, "utf8");
35508
+ return readFileSync57(p, "utf8");
35493
35509
  } catch {
35494
35510
  return null;
35495
35511
  }
@@ -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.0",
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