@tablation/crew 0.151.0 → 0.151.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +79 -171
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -27296,7 +27296,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
27296
27296
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
27297
27297
  import { join as join58 } from "path";
27298
27298
  function builtVersion() {
27299
- return true ? "0.151.0" : null;
27299
+ return true ? "0.151.1" : null;
27300
27300
  }
27301
27301
  var REBUILD_HINT = "rebuild with npm run build";
27302
27302
  function newestMtime(path) {
@@ -29776,11 +29776,10 @@ if (command === "passenger-sync-daemon") {
29776
29776
  return process.exit(code);
29777
29777
  }, requireArmed = function(what) {
29778
29778
  if (dryRun || route2.enabled) return;
29779
- process.stderr.write(
29780
- `crew: route "${route2.route}" is not enabled in ${cfg.configFile} \u2014 refusing to ${what}.
29781
- Add --dry-run to see what it would do.
29782
- `
29783
- );
29779
+ emit.warn(withFix(
29780
+ `crew: route "${route2.route}" is not enabled in ${cfg.configFile} \u2014 refusing to ${what}`,
29781
+ "add --dry-run to see what it would do, or set `enabled: true` on the route"
29782
+ ));
29784
29783
  process.exit(0);
29785
29784
  }, parseTicketNumber = function(input) {
29786
29785
  const m = /^(?:[A-Za-z]+-)?(\d+)$/.exec(input.trim());
@@ -31898,8 +31897,7 @@ ${f.tail.trimEnd()}
31898
31897
  if (daemonSub === "start" || daemonSub === "stop" || daemonSub === "status" || daemonSub === "restart") {
31899
31898
  const host = hostPlatform();
31900
31899
  if (host === "windows") {
31901
- process.stderr.write("crew daemon: no scheduler support yet for Windows (Task Scheduler is planned, not built)\n");
31902
- process.exit(2);
31900
+ die("crew daemon", "no scheduler support yet for Windows (Task Scheduler is planned, not built)", "`crew run <route>` from your own scheduler");
31903
31901
  }
31904
31902
  const control = planDaemonControl(CREW_HOME, host, detectSystemd());
31905
31903
  if (!control.startCommand && !control.stopCommand && !control.statusCommand) {
@@ -31958,8 +31956,7 @@ ${f.tail.trimEnd()}
31958
31956
  if (res2.stdout) process.stdout.write(res2.stdout);
31959
31957
  if (res2.stderr) process.stderr.write(res2.stderr);
31960
31958
  if (cmd2 === control.startCommand && (res2.error || res2.status !== 0)) {
31961
- process.stderr.write(`crew daemon restart: ${cmd2.join(" ")} exited ${res2.status ?? "error"}
31962
- `);
31959
+ emit.error(withFix(`crew daemon restart: ${cmd2.join(" ")} exited ${res2.status ?? "error"}`, "`crew doctor`"));
31963
31960
  failed = true;
31964
31961
  }
31965
31962
  }
@@ -31976,8 +31973,7 @@ ${f.tail.trimEnd()}
31976
31973
  if (res.stdout) process.stdout.write(res.stdout);
31977
31974
  if (res.stderr) process.stderr.write(res.stderr);
31978
31975
  if (daemonSub !== "status" && (res.error || res.status !== 0)) {
31979
- process.stderr.write(`crew daemon ${daemonSub}: ${cmd.join(" ")} exited ${res.status ?? "error"}
31980
- `);
31976
+ emit.error(withFix(`crew daemon ${daemonSub}: ${cmd.join(" ")} exited ${res.status ?? "error"}`, "`crew doctor`"));
31981
31977
  process.exitCode = 1;
31982
31978
  } else {
31983
31979
  process.exitCode = res.status ?? 0;
@@ -31985,13 +31981,11 @@ ${f.tail.trimEnd()}
31985
31981
  break;
31986
31982
  }
31987
31983
  if (dryRun) {
31988
- process.stderr.write("crew: daemon does not support --dry-run \u2014 it only ever performs real cycles.\n");
31989
- process.exit(2);
31984
+ die("crew", "daemon does not support --dry-run \u2014 it only ever performs real cycles", "run `crew daemon` without --dry-run, or `crew poll --dry-run` to preview a cycle");
31990
31985
  }
31991
31986
  if (!fleetWide && !route2.enabled) {
31992
31987
  const reason = `route "${route2.route}" is not enabled in ${cfg.configFile} \u2014 refusing to run the daemon loop`;
31993
- process.stderr.write(`crew: ${reason}.
31994
- `);
31988
+ emit.error(withFix(`crew: ${reason}`, `set \`enabled: true\` on route "${route2.route}" in crew.yaml`));
31995
31989
  await failDaemonStart({
31996
31990
  stateDir: cfg.ship.stateDir,
31997
31991
  reason,
@@ -32283,17 +32277,11 @@ ${f.tail.trimEnd()}
32283
32277
  try {
32284
32278
  promptTarget = positional[3] ? findRoute(cfg, positional[3]) : routeForDir(cfg, process.cwd()) ?? findRoute(cfg, void 0);
32285
32279
  } catch (e) {
32286
- if (e instanceof ConfigError) {
32287
- process.stderr.write(`crew: ${e.message}
32288
- `);
32289
- process.exit(2);
32290
- }
32280
+ if (e instanceof ConfigError) die("crew", e.message, "`crew doctor`");
32291
32281
  throw e;
32292
32282
  }
32293
32283
  if (!promptTarget.resolved) {
32294
- process.stderr.write(`crew agents prompt: route "${promptTarget.route}" has no resolved ids \u2014 run \`crew connect\` first
32295
- `);
32296
- process.exit(2);
32284
+ die("crew agents prompt", `route "${promptTarget.route}" has no resolved ids`, "`crew connect`");
32297
32285
  }
32298
32286
  try {
32299
32287
  const prompt = await currentPersonaPrompt(promptTarget, role, { userAgent: cfg.ship.userAgent });
@@ -32575,8 +32563,7 @@ ${f.tail.trimEnd()}
32575
32563
  for (const n of agent.notes) process.stdout.write(`note: ${n}
32576
32564
  `);
32577
32565
  }
32578
- if (agentError) process.stderr.write(`crew repos: --agent failed (${agentError.reason}): ${agentError.message}
32579
- `);
32566
+ if (agentError) emit.warn(withFix(`crew repos: --agent failed (${agentError.reason}): ${agentError.message}`, "`crew repos hooks --suggest` for the deterministic suggestion"));
32580
32567
  if (cleared) process.stdout.write(cleared.removed.length ? `removed route hooks ${cleared.removed.join(", ")} from ${cleared.file}
32581
32568
  ` : "no route hooks to remove\n");
32582
32569
  if (written) {
@@ -32715,8 +32702,7 @@ ${f.tail.trimEnd()}
32715
32702
  crew.yaml was not changed`);
32716
32703
  }
32717
32704
  writeFileSync44(cfg.configFile, plan2.text);
32718
- if (plan2.droppedDir) process.stderr.write(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:
32719
- `);
32705
+ if (plan2.droppedDir) emit.warn(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:`);
32720
32706
  say("attached", { route: routeName, name: plan2.name, dir: plan2.target, mode: plan2.mode }, `cloned and attached ${plan2.target} to ${routeName} as ${plan2.mode === "dir" ? "dir" : `repos.${plan2.name}`} in ${cfg.configFile}`);
32721
32707
  break;
32722
32708
  }
@@ -32735,8 +32721,7 @@ ${f.tail.trimEnd()}
32735
32721
  nameForExisting: (d) => matchRepoName(originOf(d), resolvedRemotes),
32736
32722
  isCheckout
32737
32723
  });
32738
- if (plan.droppedDir) process.stderr.write(`crew repos: dropped dir: ${plan.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:
32739
- `);
32724
+ if (plan.droppedDir) emit.warn(`crew repos: dropped dir: ${plan.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:`);
32740
32725
  let rowTracker;
32741
32726
  let rowPayload;
32742
32727
  if (plan.unmatched && origin && !flag("no-create")) {
@@ -32759,8 +32744,7 @@ ${f.tail.trimEnd()}
32759
32744
  }
32760
32745
  rowPayload = planRepoRow({ name: plan.name, origin, spec, projectId });
32761
32746
  } else if (plan.warning) {
32762
- process.stderr.write(`crew repos: warning \u2014 ${plan.warning}
32763
- `);
32747
+ emit.warn(`crew repos: warning \u2014 ${plan.warning}`);
32764
32748
  }
32765
32749
  if (dryRun) {
32766
32750
  process.stdout.write(`${plan.block}
@@ -32810,11 +32794,7 @@ ${f.tail.trimEnd()}
32810
32794
  try {
32811
32795
  target = findRoute(cfg, routeArg);
32812
32796
  } catch (e) {
32813
- if (e instanceof ConfigError) {
32814
- process.stderr.write(`crew: ${e.message}
32815
- `);
32816
- process.exit(2);
32817
- }
32797
+ if (e instanceof ConfigError) die("crew", e.message, "`crew doctor`");
32818
32798
  throw e;
32819
32799
  }
32820
32800
  try {
@@ -32905,10 +32885,7 @@ ${reconstruction.prompt}
32905
32885
  const canAsk = !!(process.stdin.isTTY && process.stdout.isTTY) && !connectEvents.json;
32906
32886
  const stopForChoice = (key, message, options) => {
32907
32887
  connectEvents.emit("choice", message, choiceData(key, options));
32908
- process.stderr.write(`crew connect: ${message}
32909
- Re-run with --choose ${key}=<${options.map((o) => o.value).join("|")}>
32910
- `);
32911
- return process.exit(CHOICE_EXIT_CODE);
32888
+ return die("crew connect", message, `re-run with --choose ${key}=<${options.map((o) => o.value).join("|")}>`, CHOICE_EXIT_CODE);
32912
32889
  };
32913
32890
  const stopWithProblem = (message, stage) => {
32914
32891
  connectEvents.emit("problem", message, { stage });
@@ -33017,16 +32994,11 @@ Waiting for approval`
33017
32994
  } catch (e) {
33018
32995
  process.stderr.write("\n");
33019
32996
  const why = e instanceof DeviceLoginError ? e.message : `device authorization failed \u2014 ${e.message}`;
33020
- process.stderr.write(`crew connect: ${why}
33021
- `);
33022
32997
  connectEvents.emit("problem", why, { stage: "device_login" });
33023
- process.exit(2);
32998
+ die("crew connect", why, "`crew connect` again, or pass --key");
33024
32999
  }
33025
- process.stderr.write(
33026
- `
33027
- Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${result.workspace.name}".
33028
- `
33029
- );
33000
+ process.stderr.write("\n");
33001
+ emit.note(`Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${result.workspace.name}".`);
33030
33002
  apiKey = result.apiKey.key;
33031
33003
  mintedFromDevice = true;
33032
33004
  const deviceWorkspace = "path" in result.workspace && typeof result.workspace.path === "string" ? result.workspace.path : result.workspace.slug;
@@ -33042,18 +33014,15 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33042
33014
  keychainBacked = true;
33043
33015
  sessionAddress = deviceWorkspace;
33044
33016
  rememberSession(cfg.ship.stateDir, hostFromUrl4(baseUrl), deviceWorkspace);
33045
- process.stderr.write(
33046
- `API key stored in the OS keychain for ${hostFromUrl4(baseUrl)}/${deviceWorkspace}.
33047
- `
33048
- );
33017
+ emit.note(`API key stored in the OS keychain for ${hostFromUrl4(baseUrl)}/${deviceWorkspace}.`);
33049
33018
  } catch (e) {
33050
- process.stderr.write(
33051
- `(could not store the key in the OS keychain \u2014 ${e.message} \u2014 falling back to a key file)
33052
- `
33053
- );
33019
+ emit.warn(withFix(
33020
+ `could not store the key in the OS keychain \u2014 ${e.message} \u2014 falling back to a key file`,
33021
+ "`crew doctor`"
33022
+ ));
33054
33023
  }
33055
33024
  } else {
33056
- process.stderr.write("(no OS keychain support on this platform \u2014 falling back to a key file)\n");
33025
+ emit.warn("no OS keychain support on this platform \u2014 falling back to a key file");
33057
33026
  }
33058
33027
  }
33059
33028
  const authOpts = { baseUrl, apiKey, userAgent: cfg.ship.userAgent };
@@ -33063,16 +33032,14 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33063
33032
  try {
33064
33033
  sshPublicKey = ensureShipSshKeypair(cfg.ship.stateDir).publicKey;
33065
33034
  } catch (e) {
33066
- process.stderr.write(`(no SSH keypair synced \u2014 ${e.message})
33067
- `);
33035
+ emit.warn(`no SSH keypair synced \u2014 ${e.message}`);
33068
33036
  }
33069
33037
  }
33070
33038
  let machineId;
33071
33039
  try {
33072
33040
  machineId = ensureMachineId(cfg.ship.stateDir, { override: value("machine-id") });
33073
33041
  } catch (e) {
33074
- process.stderr.write(`(no machine id \u2014 ${e.message})
33075
- `);
33042
+ emit.warn(`no machine id \u2014 ${e.message}`);
33076
33043
  }
33077
33044
  const ship = {
33078
33045
  name: cfg.ship.name,
@@ -33140,14 +33107,9 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33140
33107
  }
33141
33108
  }
33142
33109
  if (!found.projectId) {
33143
- process.stderr.write(`crew connect ${ws}: unresolved \u2014
33144
- `);
33145
- for (const p of found.problems) {
33146
- process.stderr.write(` - ${p}
33147
- `);
33148
- connectEvents.emit("problem", p, { stage: "discover" });
33149
- }
33150
- process.exit(2);
33110
+ for (const p of found.problems) connectEvents.emit("problem", p, { stage: "discover" });
33111
+ die(`crew connect ${ws}`, `unresolved \u2014
33112
+ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, then run `crew connect` again");
33151
33113
  }
33152
33114
  if (found.shipNameAdopted && !dryRun) {
33153
33115
  writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), found.shipNameAdopted));
@@ -33173,11 +33135,9 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33173
33135
  const repoNames = [...Object.values(found.repoNames ?? {}), ...configured2 ? reposOf(configured2).map((t) => t.name) : []].filter((n) => !!n);
33174
33136
  try {
33175
33137
  const made = await provisionReleaseLocks(authOpts, found.locksModelId, route3, repoNames);
33176
- for (const sc of made) process.stderr.write(`created release lock row ${sc}
33177
- `);
33138
+ for (const sc of made) emit.note(`created release lock row ${sc}`);
33178
33139
  } catch (e) {
33179
- process.stderr.write(`(could not provision release lock rows \u2014 ${e.message})
33180
- `);
33140
+ emit.warn(withFix(`could not provision release lock rows \u2014 ${e.message}`, "`crew doctor`"));
33181
33141
  }
33182
33142
  }
33183
33143
  let operator = found.operator;
@@ -33224,8 +33184,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33224
33184
  }
33225
33185
  }
33226
33186
  if (!operator && found.operatorCompared && found.operatorAction !== "would-create") {
33227
- process.stderr.write(`crew connect: no Crew row matched you \u2014 ${found.operatorCompared}
33228
- `);
33187
+ emit.warn(`crew connect: no Crew row matched you \u2014 ${found.operatorCompared}`);
33229
33188
  connectEvents.emit("operator_row", "no Crew row matched you", { action: "unmatched", compared: found.operatorCompared });
33230
33189
  }
33231
33190
  if (operator) {
@@ -33247,12 +33206,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33247
33206
  });
33248
33207
  }
33249
33208
  if (!operator && !hadPreviousFile && !operatorWouldBeCreated) {
33250
- process.stderr.write(
33251
- `crew connect ${route3}: cannot determine the operator \u2014 ${found.candidates.length} Crew row(s) could be it, none matching this key's own email, and there's no terminal to ask.
33252
- Re-run from a real terminal to pick one, or pass --key for a key whose own
33253
- identity email matches exactly one Crew row.
33254
- `
33255
- );
33209
+ emit.error(withFix(
33210
+ `crew connect ${route3}: cannot determine the operator \u2014 ${found.candidates.length} Crew row(s) could be it, none matching this key's own email, and there's no terminal to ask`,
33211
+ "run `crew connect` from a real terminal to pick one, or pass --key for a key whose own identity email matches exactly one Crew row"
33212
+ ));
33256
33213
  stopWithProblem(`cannot determine the operator \u2014 ${found.candidates.length} Crew row(s) could be it`, "operator");
33257
33214
  }
33258
33215
  const alreadyReviewed = new Set(previous?.reviewedStatuses ?? []);
@@ -33333,22 +33290,18 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33333
33290
  writeFileSync44(tmpPath, `${JSON.stringify(resolved, null, 2)}
33334
33291
  `);
33335
33292
  renameSync10(tmpPath, resolvedPath);
33336
- process.stderr.write(`Resolved ids written to ${resolvedPath}
33337
- `);
33293
+ emit.note(`Resolved ids written to ${resolvedPath}`);
33338
33294
  }
33339
33295
  let mintOutcomes = [];
33340
33296
  if (!dryRun && previous?.agentPersonas && existingRoute?.resolved) {
33341
33297
  try {
33342
33298
  mintOutcomes = await mintMissingSeatKeys(withFoundSeats(existingRoute, found, previous.releaseAgentId), { userAgent: cfg.ship.userAgent, shipName: cfg.ship.name });
33343
- for (const o of mintOutcomes) process.stderr.write(`${describeMintOutcome(o)}
33344
- `);
33299
+ for (const o of mintOutcomes) emit.note(describeMintOutcome(o));
33345
33300
  for (const p of await probeSeatReads({ ...existingRoute, resolved: { ...existingRoute.resolved, seats: found.seats } }, { userAgent: cfg.ship.userAgent })) {
33346
- if (p.state === "forbidden") process.stderr.write(`${describeSeatForbidden(p.role, p.tables)}
33347
- `);
33301
+ if (p.state === "forbidden") emit.warn(describeSeatForbidden(p.role, p.tables));
33348
33302
  }
33349
33303
  } catch (e) {
33350
- process.stderr.write(`seat keys: skipped (${e.message})
33351
- `);
33304
+ emit.warn(withFix(`seat keys: skipped (${e.message})`, "`crew agents sync`"));
33352
33305
  }
33353
33306
  }
33354
33307
  for (const sr of found.seatRows ?? []) {
@@ -33366,8 +33319,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33366
33319
  const apiKeyVar = "CREW_API_KEY";
33367
33320
  if (firstRunFromFlags && agentBinSearched && !dryRun && !isManagedShipKind(value("ship-kind"))) {
33368
33321
  const msg = `no agent binary: "claude" was not found on PATH or in ${agentBinSearched.join(", ")} \u2014 pass --agent-bin /absolute/path`;
33369
- process.stderr.write(`crew connect: ${msg}
33370
- `);
33322
+ emit.error(`crew connect: ${msg}`);
33371
33323
  stopWithProblem(msg, "wizard");
33372
33324
  }
33373
33325
  if ((mintedFromDevice || firstRunFromFlags) && !keychainBacked) {
@@ -33401,8 +33353,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33401
33353
  let wroteConfig = false;
33402
33354
  if (writeFirstRun) {
33403
33355
  wroteConfig = writeNewConfig(wizard.configPath, renderFullConfig(wizard.answers, routeBlock));
33404
- if (!wroteConfig) process.stderr.write(`(${wizard.configPath} appeared while connecting \u2014 leaving it alone)
33405
- `);
33356
+ if (!wroteConfig) emit.warn(`${wizard.configPath} appeared while connecting \u2014 leaving it alone`);
33406
33357
  }
33407
33358
  if (!dryRun) {
33408
33359
  if (wroteConfig) {
@@ -33437,33 +33388,22 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33437
33388
  }
33438
33389
  }
33439
33390
  if (found.holds.length) {
33440
- process.stderr.write(
33441
- `
33442
- Holds resolved (${found.holds.length}): ${found.holds.map((h) => `${h.name || h.id}${h.id === operator ? " [operator]" : ""}`).join(", ")}
33443
- `
33391
+ emit.note(
33392
+ `Holds resolved (${found.holds.length}): ${found.holds.map((h) => `${h.name || h.id}${h.id === operator ? " [operator]" : ""}`).join(", ")}`
33444
33393
  );
33445
33394
  }
33446
33395
  if (found.provisioning.length) {
33447
- process.stderr.write(`
33448
- Provisioned for this machine (${ship.name}):
33449
- `);
33450
- for (const p of found.provisioning) process.stderr.write(` - ${p}
33451
- `);
33396
+ emit.note(`Provisioned for this machine (${ship.name}):`);
33397
+ for (const p of found.provisioning) emit.note(` - ${p}`);
33452
33398
  }
33453
33399
  if (found.problems.length) {
33454
- process.stderr.write("\n Unresolved \u2014 fix these before arming it:\n");
33455
- for (const p of found.problems) {
33456
- process.stderr.write(` - ${p}
33457
- `);
33458
- connectEvents.emit("problem", p, { stage: "discover" });
33459
- }
33400
+ emit.warn(`Unresolved \u2014 fix these before arming it:
33401
+ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
33402
+ for (const p of found.problems) connectEvents.emit("problem", p, { stage: "discover" });
33460
33403
  }
33461
33404
  if (!canPrompt && !jsonClassified && stillUnrecognized.length > 0) {
33462
- process.stderr.write(
33463
- `
33464
- ${stillUnrecognized.length} status value(s) this workspace has that the default contract
33465
- doesn't know the meaning of (${stillUnrecognized.map((s) => s.value).join(", ")}) \u2014 re-run from a terminal to classify them, or edit ${resolvedPath} by hand.
33466
- `
33405
+ emit.warn(
33406
+ `${stillUnrecognized.length} status value(s) this workspace has that the default contract doesn't know the meaning of (${stillUnrecognized.map((s) => s.value).join(", ")}) \u2014 re-run from a terminal to classify them, or edit ${resolvedPath} by hand.`
33467
33407
  );
33468
33408
  }
33469
33409
  if (wroteConfig) {
@@ -33491,9 +33431,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33491
33431
  }
33492
33432
  if (!dryRun && !flag("no-agents-sync")) {
33493
33433
  const skip = (why) => {
33494
- process.stderr.write(`
33495
- agents sync: skipped (${why})
33496
- `);
33434
+ emit.warn(`agents sync: skipped (${why})`);
33497
33435
  connectEvents.emit("agents_synced", `agents sync skipped: ${why}`, { route: route3, skipped: why });
33498
33436
  };
33499
33437
  let syncRoute;
@@ -33506,25 +33444,21 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33506
33444
  }
33507
33445
  if (syncRoute?.resolved) {
33508
33446
  try {
33509
- process.stderr.write("\n");
33510
33447
  const run4 = await runAgentsSync(syncRoute, {
33511
33448
  userAgent: cfg.ship.userAgent,
33512
33449
  stateDir: cfg.ship.stateDir,
33513
- say: (l) => process.stderr.write(` ${l}
33514
- `),
33515
- warn: (l) => process.stderr.write(` agents sync: ${l}
33516
- `)
33450
+ say: (l) => emit.note(l),
33451
+ warn: (l) => emit.warn(`agents sync: ${l}`)
33517
33452
  });
33518
33453
  const minted = await mintMissingSeatKeys(syncRoute, { userAgent: cfg.ship.userAgent, shipName: cfg.ship.name });
33519
- for (const m of minted) process.stderr.write(` ${describeMintOutcome(m)}
33520
- `);
33454
+ for (const m of minted) emit.note(describeMintOutcome(m));
33521
33455
  for (const p of await probeSeatReads(syncRoute, { userAgent: cfg.ship.userAgent })) {
33522
- if (p.state === "forbidden") process.stderr.write(` ${describeSeatForbidden(p.role, p.tables)}
33523
- `);
33456
+ if (p.state === "forbidden") emit.warn(describeSeatForbidden(p.role, p.tables));
33524
33457
  }
33525
33458
  if (run4.readOnly) {
33526
33459
  const missing = run4.personaResult.outcomes.some((p) => p.action === "missing");
33527
- process.stderr.write(missing ? " A workspace admin has to open the Crew app or run `crew agents sync` once before this ship's seats can run.\n" : " Seats are linked to the workspace's existing personas.\n");
33460
+ if (missing) emit.warn("A workspace admin has to open the Crew app or run `crew agents sync` once before this ship's seats can run.");
33461
+ else emit.note("Seats are linked to the workspace's existing personas.");
33528
33462
  }
33529
33463
  connectEvents.emit("agents_synced", run4.readOnly ? "agents linked (read-only key)" : "agents synced", {
33530
33464
  route: route3,
@@ -33595,12 +33529,8 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33595
33529
  workspaces.map((w) => ({ value: w.slug, label: `${w.name} (${w.role})` }))
33596
33530
  );
33597
33531
  }
33598
- process.stderr.write(
33599
- `${workspaces.length} workspaces reachable by this key \u2014 name one:
33600
- ` + workspaces.map((w) => ` ${w.slug.padEnd(24)} ${w.name} (${w.role})
33601
- `).join("")
33602
- );
33603
- process.exit(2);
33532
+ die("crew connect", `${workspaces.length} workspaces reachable by this key \u2014 name one:
33533
+ ` + workspaces.map((w) => ` ${w.slug.padEnd(24)} ${w.name} (${w.role})`).join("\n"), "run `crew connect <workspace>` with one of the slugs above");
33604
33534
  }
33605
33535
  } else {
33606
33536
  await runConnect(workspace, project);
@@ -33636,20 +33566,16 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33636
33566
  );
33637
33567
  }
33638
33568
  if (ambiguous) {
33639
- process.stderr.write(
33640
- `
33641
- WARNING: "${who2}" resolved to different people on different workspaces.
33642
- A name is a per-workspace label, not an identity \u2014 this queue is a mixture.
33643
- Use an email address to match exactly.
33644
- `
33645
- );
33569
+ emit.warn(withFix(
33570
+ `"${who2}" resolved to different people on different workspaces. A name is a per-workspace label, not an identity \u2014 this queue is a mixture`,
33571
+ "pass an email address to --member to match exactly"
33572
+ ));
33646
33573
  }
33647
33574
  process.stdout.write("\n");
33648
33575
  }
33649
33576
  const subject = who2 ? [...new Set(resolved.flatMap((r) => r.names))].join(", ") || `"${who2}"` : void 0;
33650
33577
  process.stdout.write(renderInbox(items, flag("by-route"), subject));
33651
- for (const e of errors) process.stderr.write(` (${e.route} unreachable: ${e.error})
33652
- `);
33578
+ for (const e of errors) emit.warn(withFix(`${e.route} unreachable: ${e.error}`, `\`crew doctor ${e.route}\``));
33653
33579
  break;
33654
33580
  }
33655
33581
  case "ports": {
@@ -33701,11 +33627,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33701
33627
  try {
33702
33628
  routesS = value("route") ? [findRoute(cfg, value("route"))] : cfg.routes.filter((r) => r.enabled);
33703
33629
  } catch (e) {
33704
- if (e instanceof ConfigError) {
33705
- process.stderr.write(`crew: ${e.message}
33706
- `);
33707
- process.exit(2);
33708
- }
33630
+ if (e instanceof ConfigError) die("crew", e.message, "`crew doctor`");
33709
33631
  throw e;
33710
33632
  }
33711
33633
  const declared = withShipSandbox(await sandboxReposOf(routesS));
@@ -33735,9 +33657,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33735
33657
  const only = positional[2];
33736
33658
  const targets = only ? declared.filter((r) => r.name === only) : declared;
33737
33659
  if (targets.length === 0) {
33738
- process.stderr.write(only ? `crew: no repository "${only}" declares a sandbox: section (${SHIP_SANDBOX_KEY} is the ship's crew layer, built only on a ship.runner: sandbox ship)
33739
- ` : "crew: this ship is not a sandbox ship and no repository declares a sandbox: section in its .crew.yaml\n");
33740
- process.exit(2);
33660
+ die("crew", only ? `no repository "${only}" declares a sandbox: section (${SHIP_SANDBOX_KEY} is the ship's crew layer, built only on a ship.runner: sandbox ship)` : "this ship is not a sandbox ship and no repository declares a sandbox: section in its .crew.yaml", "add a sandbox: section to the repository's .crew.yaml, or run `crew sandbox images` to list what is declared");
33741
33661
  }
33742
33662
  const emitS = new Emitter({ route: routesS[0].route, eventFile: eventFileFor(cfg.ship.stateDir), rotateBytes: cfg.ship.eventsRotateBytes, logFile: cfg.ship.logFile, console: (l) => process.stderr.write(`${l}
33743
33663
  `) });
@@ -33756,10 +33676,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33756
33676
  }
33757
33677
  case "cache": {
33758
33678
  const settings = cacheSettingsOf(cfg.ship.sandbox);
33759
- if (!settings) {
33760
- process.stderr.write("crew sandbox cache: ship.sandbox.cacheVolume is not set, so there is no cache volume\n");
33761
- process.exit(2);
33762
- }
33679
+ if (!settings) die("crew sandbox cache", "ship.sandbox.cacheVolume is not set, so there is no cache volume", "set ship.sandbox.cacheVolume in crew.yaml");
33763
33680
  const cache = new SandboxCache(settings);
33764
33681
  const served = cfg.routes.flatMap((r) => sandboxCacheRepos(r, cfg.ship));
33765
33682
  try {
@@ -33804,8 +33721,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33804
33721
  }
33805
33722
  if (refreshFailed) process.exitCode = 1;
33806
33723
  } catch (e) {
33807
- process.stderr.write(`crew sandbox cache: ${e instanceof Error ? e.message : String(e)}
33808
- `);
33724
+ emit.error(withFix(`crew sandbox cache: ${e instanceof Error ? e.message : String(e)}`, "`crew doctor`"));
33809
33725
  process.exitCode = 1;
33810
33726
  }
33811
33727
  break;
@@ -34498,14 +34414,12 @@ ${where.join("\n")}`);
34498
34414
  const opener = openerFor(process.platform);
34499
34415
  if (opener && shouldOpen({ open: flag("open"), noOpen: flag("no-open"), json: jsonP, terminal })) {
34500
34416
  const r = spawnSync14(opener, [res.url], { stdio: "ignore" });
34501
- if (r.error || r.status !== 0) process.stderr.write(`crew periscope: could not open ${res.url} with ${opener}
34502
- `);
34417
+ if (r.error || r.status !== 0) emit.warn(withFix(`crew periscope: could not open ${res.url} with ${opener}`, `open ${res.url} yourself`));
34503
34418
  }
34504
34419
  }
34505
34420
  } catch (e) {
34506
34421
  if (e instanceof PeriscopeError || e instanceof ConfigError) {
34507
- process.stderr.write(`crew periscope: ${e.message}
34508
- `);
34422
+ emit.error(withFix(`crew periscope: ${e.message}`, "`crew periscope list`"));
34509
34423
  if (e instanceof LivePeriscopeError && jsonP) process.stdout.write(`${JSON.stringify(e.data)}
34510
34424
  `);
34511
34425
  process.exit(1);
@@ -34643,14 +34557,12 @@ ${where.join("\n")}`);
34643
34557
  if (!dryRun) {
34644
34558
  for (const r of cfg.routes.filter((x) => x.resolved?.shipsModelId)) {
34645
34559
  await new Tracker(r, cfg.ship).updateRelayUrl(cfg.ship.name, null).catch((e) => {
34646
- process.stderr.write(`could not clear relay_url for ${r.route}: ${e.message}
34647
- `);
34560
+ emit.warn(withFix(`could not clear relay_url for ${r.route}: ${e.message}`, "`crew doctor`"));
34648
34561
  });
34649
34562
  }
34650
34563
  }
34651
34564
  if (!flag("reset") && !deprovisioning) {
34652
- for (const line of removePairEntries(url, dryRun)) process.stderr.write(`${line}
34653
- `);
34565
+ for (const line of removePairEntries(url, dryRun)) emit.note(line);
34654
34566
  break;
34655
34567
  }
34656
34568
  const host = hostPlatform();
@@ -34757,8 +34669,7 @@ ${where.join("\n")}`);
34757
34669
  if (!unitRunning && control?.mechanism === "systemd" && control.startCommand) {
34758
34670
  const res = spawnSync14(control.startCommand[0], control.startCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
34759
34671
  if (res.error || res.status !== 0) {
34760
- process.stderr.write(`crew reload: ${control.startCommand.join(" ")} exited ${res.status ?? "error"}
34761
- `);
34672
+ emit.error(withFix(`crew reload: ${control.startCommand.join(" ")} exited ${res.status ?? "error"}`, "`crew doctor`"));
34762
34673
  process.exitCode = 1;
34763
34674
  } else {
34764
34675
  process.stdout.write("crew reload: the daemon unit was not running \u2014 started it, so it reads crew.yaml fresh\n");
@@ -34779,8 +34690,7 @@ ${where.join("\n")}`);
34779
34690
  for (const cmd of [control.stopCommand, control.startCommand]) {
34780
34691
  const res = spawnSync14(cmd[0], cmd.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
34781
34692
  if (cmd === control.startCommand && (res.error || res.status !== 0)) {
34782
- process.stderr.write(`crew reload: ${cmd.join(" ")} exited ${res.status ?? "error"}
34783
- `);
34693
+ emit.error(withFix(`crew reload: ${cmd.join(" ")} exited ${res.status ?? "error"}`, "`crew doctor`"));
34784
34694
  process.exitCode = 1;
34785
34695
  }
34786
34696
  }
@@ -34963,9 +34873,7 @@ ${where.join("\n")}`);
34963
34873
  const all = shipToolchains(cfg.ship);
34964
34874
  const chosen = wanted ? all.filter((t) => t.name === wanted) : all;
34965
34875
  if (chosen.length === 0) {
34966
- process.stderr.write(`crew selftest: no toolchain "${wanted}" (have: ${all.map((t) => t.name).join(", ")})
34967
- `);
34968
- process.exit(2);
34876
+ die("crew selftest", `no toolchain "${wanted}" (have: ${all.map((t) => t.name).join(", ")})`, "name one of those, or omit it to test them all");
34969
34877
  }
34970
34878
  if (!route2.resolved) {
34971
34879
  die("crew selftest", `route ${route2.route} is not connected`, "`crew connect`");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.151.0",
3
+ "version": "0.151.1",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",