@tablation/crew 0.149.4 → 0.149.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +47 -108
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -26855,7 +26855,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
26855
26855
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
26856
26856
  import { join as join58 } from "path";
26857
26857
  function builtVersion() {
26858
- return true ? "0.149.4" : null;
26858
+ return true ? "0.149.5" : null;
26859
26859
  }
26860
26860
  var REBUILD_HINT = "rebuild with npm run build";
26861
26861
  function newestMtime(path) {
@@ -29249,7 +29249,10 @@ if (command === "passenger-sync-daemon") {
29249
29249
  }
29250
29250
  await runBridge(stateDir, bridgeRoute, bridgeTicket);
29251
29251
  } else {
29252
- let die = function(command2, message, fix, code = 2) {
29252
+ let routineLine = function(line) {
29253
+ if (flag("verbose")) process.stderr.write(`${line}
29254
+ `);
29255
+ }, die = function(command2, message, fix, code = 2) {
29253
29256
  emit.error(withFix(`${command2}: ${message}`, fix));
29254
29257
  return process.exit(code);
29255
29258
  }, requireArmed = function(what) {
@@ -29451,7 +29454,7 @@ if (command === "passenger-sync-daemon") {
29451
29454
  }
29452
29455
  };
29453
29456
  };
29454
- die2 = die, requireArmed2 = requireArmed, parseTicketNumber2 = parseTicketNumber, routeRelayUrl2 = routeRelayUrl, previewRelayFor2 = previewRelayFor, passengerApiKeys2 = passengerApiKeys, endpointApiFor2 = endpointApiFor, periscopeEndpointDeps2 = periscopeEndpointDeps, periscopeMcpDeps2 = periscopeMcpDeps, endpointReconcileDeps2 = endpointReconcileDeps, releaseRefused2 = releaseRefused, doctorMachineId2 = doctorMachineId, baseHealth2 = baseHealth, sandboxCacheRepos2 = sandboxCacheRepos, buildSandboxCachePass2 = buildSandboxCachePass, sandboxTickDeps2 = sandboxTickDeps;
29457
+ routineLine2 = routineLine, die2 = die, requireArmed2 = requireArmed, parseTicketNumber2 = parseTicketNumber, routeRelayUrl2 = routeRelayUrl, previewRelayFor2 = previewRelayFor, passengerApiKeys2 = passengerApiKeys, endpointApiFor2 = endpointApiFor, periscopeEndpointDeps2 = periscopeEndpointDeps, periscopeMcpDeps2 = periscopeMcpDeps, endpointReconcileDeps2 = endpointReconcileDeps, releaseRefused2 = releaseRefused, doctorMachineId2 = doctorMachineId, baseHealth2 = baseHealth, sandboxCacheRepos2 = sandboxCacheRepos, buildSandboxCachePass2 = buildSandboxCachePass, sandboxTickDeps2 = sandboxTickDeps;
29455
29458
  async function failDaemonStart(o) {
29456
29459
  const failEmit = new Emitter({
29457
29460
  route: "",
@@ -29823,11 +29826,7 @@ if (command === "passenger-sync-daemon") {
29823
29826
  const targets = reposOf(route2);
29824
29827
  const chosen = only ? targets.filter((t) => t.name === only) : targets;
29825
29828
  if (only && chosen.length === 0) {
29826
- process.stderr.write(
29827
- `crew: no repo named "${only}" on route "${route2.route}" (have: ${targets.map((t) => t.name).join(", ")})
29828
- `
29829
- );
29830
- process.exit(2);
29829
+ die("crew", `no repo named "${only}" on route "${route2.route}" (have: ${targets.map((t) => t.name).join(", ")})`, `\`crew repos\` to list or add one`);
29831
29830
  }
29832
29831
  const summaries = [];
29833
29832
  if (!dryRun) state.releaseHeartbeat().touch();
@@ -30824,10 +30823,7 @@ ${f.tail.trimEnd()}
30824
30823
  if (EXCLUSIVE[command] && !dryRun) {
30825
30824
  const got = state.acquire(EXCLUSIVE[command]);
30826
30825
  if (!got.ok) {
30827
- process.stderr.write(
30828
- `crew: a previous ${command} (pid ${got.heldBy}) is still running \u2014 skipping this cycle
30829
- `
30830
- );
30826
+ emit.note(`a previous ${command} (pid ${got.heldBy}) is still running \u2014 skipping this cycle`);
30831
30827
  process.exit(0);
30832
30828
  }
30833
30829
  lock = got;
@@ -31743,9 +31739,7 @@ ${f.tail.trimEnd()}
31743
31739
  process.stdout.write(prompt + (role === "pair" ? harnessPromptNote(value("harness")) : ""));
31744
31740
  } catch (e) {
31745
31741
  if (e instanceof AgentsSyncError) {
31746
- process.stderr.write(`crew agents prompt: ${e.message}
31747
- `);
31748
- process.exit(2);
31742
+ die("crew agents prompt", e.message, "`crew doctor`", 2);
31749
31743
  }
31750
31744
  throw e;
31751
31745
  }
@@ -31852,9 +31846,7 @@ ${f.tail.trimEnd()}
31852
31846
  newName = validateShipName(positional[2]);
31853
31847
  } catch (e) {
31854
31848
  if (e instanceof ShipNameError) {
31855
- process.stderr.write(`crew ship: ${e.message}
31856
- `);
31857
- process.exit(2);
31849
+ die("crew ship", e.message, "`crew doctor`", 2);
31858
31850
  }
31859
31851
  throw e;
31860
31852
  }
@@ -31926,9 +31918,7 @@ ${f.tail.trimEnd()}
31926
31918
  });
31927
31919
  } catch (e) {
31928
31920
  if (e instanceof ReposError) {
31929
- process.stderr.write(`crew repos: ${e.message}
31930
- `);
31931
- process.exit(2);
31921
+ die("crew repos", e.message, "`crew doctor`", 2);
31932
31922
  }
31933
31923
  throw e;
31934
31924
  }
@@ -32043,9 +32033,7 @@ ${f.tail.trimEnd()}
32043
32033
  if (agentError) process.exitCode = 1;
32044
32034
  } catch (e) {
32045
32035
  if (e instanceof ReposError) {
32046
- process.stderr.write(`crew repos: ${e.message}
32047
- `);
32048
- process.exit(2);
32036
+ die("crew repos", e.message, "`crew doctor`", 2);
32049
32037
  }
32050
32038
  throw e;
32051
32039
  }
@@ -32063,9 +32051,7 @@ ${f.tail.trimEnd()}
32063
32051
  addName = a.name;
32064
32052
  } catch (e) {
32065
32053
  if (e instanceof ReposError) {
32066
- process.stderr.write(`crew repos: ${e.message}
32067
- `);
32068
- process.exit(2);
32054
+ die("crew repos", e.message, "`crew doctor`", 2);
32069
32055
  }
32070
32056
  throw e;
32071
32057
  }
@@ -32077,9 +32063,7 @@ ${f.tail.trimEnd()}
32077
32063
  addName = a.name;
32078
32064
  } catch (e) {
32079
32065
  if (e instanceof ReposError) {
32080
- process.stderr.write(`crew repos: ${e.message}
32081
- `);
32082
- process.exit(2);
32066
+ die("crew repos", e.message, "`crew doctor`", 2);
32083
32067
  }
32084
32068
  throw e;
32085
32069
  }
@@ -32241,9 +32225,7 @@ ${f.tail.trimEnd()}
32241
32225
  `);
32242
32226
  } catch (e) {
32243
32227
  if (e instanceof ReposError) {
32244
- process.stderr.write(`crew repos: ${e.message}
32245
- `);
32246
- process.exit(2);
32228
+ die("crew repos", e.message, "`crew doctor`", 2);
32247
32229
  }
32248
32230
  throw e;
32249
32231
  }
@@ -32328,9 +32310,7 @@ ${reconstruction.prompt}
32328
32310
  }
32329
32311
  } catch (e) {
32330
32312
  if (e instanceof LogbookError) {
32331
- process.stderr.write(`crew logbook: ${e.message}
32332
- `);
32333
- process.exit(2);
32313
+ die("crew logbook", e.message, "`crew doctor`", 2);
32334
32314
  }
32335
32315
  throw e;
32336
32316
  }
@@ -32402,8 +32382,7 @@ ${reconstruction.prompt}
32402
32382
  apiKey = existing.apiKey;
32403
32383
  keychainBacked = true;
32404
32384
  sessionAddress = found;
32405
- process.stderr.write(`Reusing the existing keychain session for ${hostFromUrl4(baseUrl)}/${workspace}.
32406
- `);
32385
+ routineLine(`Reusing the existing keychain session for ${hostFromUrl4(baseUrl)}/${workspace}.`);
32407
32386
  }
32408
32387
  } catch {
32409
32388
  }
@@ -32437,8 +32416,7 @@ ${reconstruction.prompt}
32437
32416
  keychainBacked = true;
32438
32417
  sessionAddress = resumed.workspace;
32439
32418
  signInSource = "keychain";
32440
- process.stderr.write(`Reusing the existing keychain session for ${hostFromUrl4(baseUrl)}/${workspace}.
32441
- `);
32419
+ routineLine(`Reusing the existing keychain session for ${hostFromUrl4(baseUrl)}/${workspace}.`);
32442
32420
  }
32443
32421
  }
32444
32422
  let mintedFromDevice = false;
@@ -32839,8 +32817,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32839
32817
  mkdirSync43(dirname37(apiKeyFile), { recursive: true });
32840
32818
  writeFileSync44(apiKeyFile, `${apiKeyVar}=${apiKey}
32841
32819
  `, { mode: 384 });
32842
- process.stderr.write(`API key written to ${apiKeyFile}
32843
- `);
32820
+ routineLine(`API key written to ${apiKeyFile}`);
32844
32821
  }
32845
32822
  }
32846
32823
  const keyPersisted = keychainBacked || apiKeyFile !== void 0;
@@ -32889,14 +32866,12 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
32889
32866
  const mcpOpts = { bin: tc.bin, url: mcpUrl, key: apiKey, replace, dryRun, stateDir: cfg.ship.stateDir };
32890
32867
  const { line, action } = adapter.ensureMcpResult ? adapter.ensureMcpResult(mcpOpts) : { line: adapter.ensureMcp(mcpOpts), action: void 0 };
32891
32868
  connectEvents.emit("mcp_registered", line, { harness: tc.harness, bin: tc.bin, url: mcpUrl, ...action ? { action } : {} });
32892
- process.stderr.write(`${line}
32893
- `);
32869
+ routineLine(line);
32894
32870
  }
32895
32871
  for (const h of shipPair(cfg.ship).filter((x) => x !== "claude")) {
32896
32872
  const line = pairInstallerFor(h).installPair({ url: mcpUrlFor(baseUrl), replace, dryRun });
32897
32873
  connectEvents.emit("pair_installed", line, { harness: h });
32898
- process.stderr.write(`${line}
32899
- `);
32874
+ routineLine(line);
32900
32875
  }
32901
32876
  }
32902
32877
  if (found.holds.length) {
@@ -33046,8 +33021,8 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33046
33021
  if (defaulted) {
33047
33022
  await runConnect(defaulted.slug, project);
33048
33023
  } else if (workspaces.length === 0) {
33049
- process.stderr.write("crew connect: this key's identity has no workspace memberships.\n");
33050
- stopWithProblem("this key's identity has no workspace memberships", "workspace");
33024
+ connectEvents.emit("problem", "this key's identity has no workspace memberships", { stage: "workspace" });
33025
+ die("crew connect", "this key's identity has no workspace memberships", "mint a key inside a workspace and re-run with `--key K`");
33051
33026
  } else if (workspaces.length === 1) {
33052
33027
  await runConnect(workspaces[0].slug, project);
33053
33028
  } else {
@@ -33072,18 +33047,13 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33072
33047
  if (e instanceof ConnectHttpError) {
33073
33048
  connectEvents.emit("problem", e.message, { stage: "http", status: e.status, path: e.path });
33074
33049
  if (e.status === 401 || e.status === 403) {
33075
- process.stderr.write(
33076
- `crew connect: ${e.path} \u2014 ${e.status} ${e.status === 401 ? "(bad or expired key)" : "(this key is not a member of that workspace)"}
33077
- A key only sees the workspace it was minted in, whatever role it holds there
33078
- (platform admin included) \u2014 pass one minted inside the target workspace: --key K
33079
- (or CREW_CONNECT_KEY).
33080
- `
33050
+ die(
33051
+ "crew connect",
33052
+ `${e.path} \u2014 ${e.status} ${e.status === 401 ? "(bad or expired key)" : "(this key is not a member of that workspace)"}. A key only sees the workspace it was minted in, whatever role it holds there (platform admin included)`,
33053
+ "pass a key minted inside the target workspace: `--key K` (or CREW_CONNECT_KEY)"
33081
33054
  );
33082
- } else {
33083
- process.stderr.write(`crew connect: ${e.message}
33084
- `);
33085
33055
  }
33086
- process.exit(2);
33056
+ die("crew connect", e.message, "`crew doctor`");
33087
33057
  }
33088
33058
  throw e;
33089
33059
  }
@@ -33142,15 +33112,11 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33142
33112
  const only = value("route");
33143
33113
  const wanted = only ? cfg.routes.filter((r2) => r2.route === only) : cfg.routes;
33144
33114
  if (wanted.length !== 1) {
33145
- process.stderr.write(`crew sandbox policy: ${only ? `no route "${only}"` : "name the route with --route"} (have: ${cfg.routes.map((r2) => r2.route).join(", ")})
33146
- `);
33147
- process.exit(2);
33115
+ die("crew sandbox policy", `${only ? `no route "${only}"` : "no route given"} (have: ${cfg.routes.map((r2) => r2.route).join(", ")})`, "`--route ROUTE`");
33148
33116
  }
33149
33117
  const role = value("role") ?? "dev";
33150
33118
  if (!ROLE_NAMES.includes(role)) {
33151
- process.stderr.write(`crew sandbox policy: --role must be one of ${ROLE_NAMES.join(", ")}
33152
- `);
33153
- process.exit(2);
33119
+ die("crew sandbox policy", `--role must be one of ${ROLE_NAMES.join(", ")}`, `\`--role ${ROLE_NAMES[0]}\``);
33154
33120
  }
33155
33121
  const r = wanted[0];
33156
33122
  const repoName = value("repo");
@@ -33161,9 +33127,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33161
33127
  process.stdout.write(flag("json") ? `${JSON.stringify({ route: r.route, role, input, groups: policy.groups, yaml: policy.yaml }, null, 2)}
33162
33128
  ` : policy.yaml);
33163
33129
  } catch (e) {
33164
- process.stderr.write(`crew sandbox policy: ${e.message}
33165
- `);
33166
- process.exit(1);
33130
+ die("crew sandbox policy", e.message, "`crew doctor`", 1);
33167
33131
  }
33168
33132
  break;
33169
33133
  }
@@ -33369,18 +33333,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33369
33333
  const repos = await resolvedRepos(route2);
33370
33334
  const candidates2 = repos.map((r) => ({ repo: r, found: worktreeForNumber(r.dir, n) })).filter((c) => c.found !== null);
33371
33335
  if (candidates2.length === 0) {
33372
- process.stderr.write(
33373
- `drop: no worktree for ISSUE-${n} in any of this route's repositories (looked in: ${repos.map((r) => r.dir).join(", ")})
33374
- `
33375
- );
33376
- process.exit(2);
33336
+ die("crew drop", `no worktree for ISSUE-${n} in any of this route's repositories (looked in: ${repos.map((r) => r.dir).join(", ")})`, "`git worktree list` in the repository");
33377
33337
  }
33378
33338
  if (candidates2.length > 1) {
33379
- process.stderr.write(
33380
- `drop: ISSUE-${n} has a worktree in more than one repository (${candidates2.map((c) => c.repo.name).join(", ")}) \u2014 remove them one at a time by path
33381
- `
33382
- );
33383
- process.exit(2);
33339
+ die("crew drop", `ISSUE-${n} has a worktree in more than one repository (${candidates2.map((c) => c.repo.name).join(", ")})`, "remove them one at a time by path");
33384
33340
  }
33385
33341
  const { repo: target, found } = candidates2[0];
33386
33342
  const wt = found.path;
@@ -33388,9 +33344,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33388
33344
  const trD = new Tracker(route2, cfg.ship);
33389
33345
  const tD = (await trD.ticketsByNumbers([n])).find((t) => t.issue_id.replace(/^\D+/, "") === String(num2));
33390
33346
  if (tD && tD[trD.contract.columns.status] === trD.contract.statuses.draft) {
33391
- process.stderr.write(`drop: ${tD.issue_tag ?? tD.issue_id} is a draft ticket \u2014 its worktree belongs to a periscope; end it with \`crew periscope down ${num2} --keep\` or \`--discard\`
33392
- `);
33393
- process.exit(2);
33347
+ die("crew drop", `${tD.issue_tag ?? tD.issue_id} is a draft ticket \u2014 its worktree belongs to a periscope`, `\`crew periscope down ${num2} --keep\` or \`--discard\``);
33394
33348
  }
33395
33349
  } catch {
33396
33350
  }
@@ -33425,29 +33379,18 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33425
33379
  case "rotate-passenger-url": {
33426
33380
  emit.enter("passengers");
33427
33381
  if (!route2.hostPassengers) {
33428
- process.stderr.write(
33429
- `crew rotate-passenger-url: route "${route2.route}" does not have hostPassengers enabled
33430
- `
33431
- );
33432
- process.exit(2);
33382
+ die("crew rotate-passenger-url", `route "${route2.route}" does not have hostPassengers enabled`, `set hostPassengers on the route in ${cfg.configFile}`);
33433
33383
  }
33434
33384
  if (!cfg.ship.relayHost) {
33435
- process.stderr.write("crew rotate-passenger-url: this ship has no relayHost configured \u2014 nothing to rotate\n");
33436
- process.exit(2);
33385
+ die("crew rotate-passenger-url", "this ship has no relayHost configured \u2014 nothing to rotate", `set ship.relayHost in ${cfg.configFile}`);
33437
33386
  }
33438
33387
  const workspaceId = route2.resolved?.workspaceId;
33439
33388
  if (!workspaceId) {
33440
- process.stderr.write(`crew rotate-passenger-url: route "${route2.route}" has no resolved ids \u2014 run \`crew connect\`
33441
- `);
33442
- process.exit(2);
33389
+ die("crew rotate-passenger-url", `route "${route2.route}" has no resolved ids`, "`crew connect`");
33443
33390
  }
33444
33391
  const plans = planContainers(cfg).filter((p) => p.workspaceId === workspaceId);
33445
33392
  if (!plans.length) {
33446
- process.stderr.write(
33447
- `crew rotate-passenger-url: no Host Passengers container is planned for "${route2.route}" right now
33448
- `
33449
- );
33450
- process.exit(2);
33393
+ die("crew rotate-passenger-url", `no Host Passengers container is planned for "${route2.route}" right now`, "`crew doctor`");
33451
33394
  }
33452
33395
  const existing = readPersistedTunnel(cfg.ship.stateDir, workspaceId);
33453
33396
  const hasLiveTunnel = existing !== void 0 && isPidAlive(existing.pid);
@@ -33746,9 +33689,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33746
33689
  `);
33747
33690
  } catch (e) {
33748
33691
  if (e instanceof PeriscopeError || e instanceof ConfigError) {
33749
- process.stderr.write(`crew periscope: ${e.message}
33750
- `);
33751
- process.exit(1);
33692
+ die("crew periscope", e.message, "`crew doctor`", 1);
33752
33693
  }
33753
33694
  throw e;
33754
33695
  }
@@ -34024,9 +33965,7 @@ ${where.join("\n")}`);
34024
33965
  const open = await tracker3.openTickets();
34025
33966
  const ticket = open.find((t) => t[c.columns.key] === key);
34026
33967
  if (!ticket) {
34027
- process.stderr.write(`unassign: no open ticket ${key} on ${route2.route} (already resolved, or not this route's)
34028
- `);
34029
- process.exit(2);
33968
+ die("crew unassign", `no open ticket ${key} on ${route2.route} (already resolved, or not this route's)`, "`crew inbox` to list open tickets");
34030
33969
  }
34031
33970
  const label = displayKey(ticket);
34032
33971
  if (!ticket[c.columns.assignee]) {
@@ -34043,9 +33982,7 @@ ${where.join("\n")}`);
34043
33982
  emit.emit(`cleared assignee on ${label} \u2014 back up for grabs next cycle`);
34044
33983
  } catch (e) {
34045
33984
  if (e instanceof StaleWriteError9) {
34046
- process.stderr.write(`unassign: ${label} changed on the board since it was read \u2014 re-run to retry
34047
- `);
34048
- process.exit(2);
33985
+ die("crew unassign", `${label} changed on the board since it was read`, `\`crew unassign ${key}\` again`);
34049
33986
  }
34050
33987
  throw e;
34051
33988
  }
@@ -34351,11 +34288,12 @@ ${where.join("\n")}`);
34351
34288
  ` : `${human}
34352
34289
  `);
34353
34290
  const fail2 = (msg) => {
34354
- if (json2) process.stdout.write(`${JSON.stringify({ event: "error", message: msg })}
34355
- `);
34356
- else process.stderr.write(`crew sample-ticket: ${msg}
34291
+ if (json2) {
34292
+ process.stdout.write(`${JSON.stringify({ event: "error", message: msg })}
34357
34293
  `);
34358
- return process.exit(2);
34294
+ return process.exit(2);
34295
+ }
34296
+ return die("crew sample-ticket", msg, "`crew doctor`", 2);
34359
34297
  };
34360
34298
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
34361
34299
  const tracker = new Tracker(route2, cfg.ship);
@@ -35592,6 +35530,7 @@ ${foreign.join("\n")}
35592
35530
  }
35593
35531
  lock?.release();
35594
35532
  }
35533
+ var routineLine2;
35595
35534
  var die2;
35596
35535
  var requireArmed2;
35597
35536
  var parseTicketNumber2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.149.4",
3
+ "version": "0.149.5",
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",