@theholocron/cli 5.0.0-alpha.565 → 5.0.0-alpha.567

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
- import { homedir, tmpdir } from "node:os";
3
+ import { constants, homedir, tmpdir } from "node:os";
4
4
  import path, { basename, dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
5
5
  import { PREFIX as PREFIX$1, createEnvLookup, detectEnvironment, environment, firstEnv, holocronEnv } from "@theholocron/env-utils/lookup";
6
6
  import { ProviderApiError, ProviderApiError as ProviderApiError$1, createRestClient, onRetry } from "@theholocron/http-client";
@@ -107,8 +107,10 @@ const COMMAND_CONTEXTS = {
107
107
  "reconcile ci": "workspace",
108
108
  "reconcile project": "workspace",
109
109
  "redeliver webhooks": "workspace",
110
+ "rotate tokens": "workspace",
110
111
  "doctor all": "workspace",
111
112
  "doctor notifications": "workspace",
113
+ "doctor agent": "workspace",
112
114
  "doctor environments": "workspace",
113
115
  "doctor project": "workspace",
114
116
  "doctor logs": "workspace",
@@ -149,6 +151,7 @@ const COMMAND_CONTEXTS = {
149
151
  "new work": "workspace",
150
152
  "update issue": "workspace",
151
153
  "start work": "workspace",
154
+ "start agent": "workspace",
152
155
  "update work": "workspace",
153
156
  "close work": "workspace",
154
157
  "new incident": "workspace",
@@ -454,6 +457,14 @@ const doctorAllEntry = {
454
457
  supportsDryRun: false,
455
458
  spawnArgs: ["doctor", "--all"]
456
459
  };
460
+ // src/commands/doctor-agent/doctor-agent.entry.ts
461
+ const doctorAgentEntry = {
462
+ name: "doctor agent",
463
+ description: "Check the agent setup: the Service Account's token file, that it reads the agent Environment and no other, and the agent tokens still to make (read-only)",
464
+ positionals: [],
465
+ skipOptions: ["all", "repo"],
466
+ supportsDryRun: false
467
+ };
457
468
  // src/commands/doctor-ci/doctor-ci.entry.ts
458
469
  const doctorCiEntry = {
459
470
  name: "doctor ci",
@@ -1602,7 +1613,7 @@ const projectReconcileEntry = {
1602
1613
  // src/commands/provider/provider.entry.ts
1603
1614
  const providerEntry = {
1604
1615
  name: "provider",
1605
- description: "List the providers that have their own setup, doctor, whoami or token (`provider <name> setup|doctor|whoami|token` runs one)",
1616
+ description: "List the providers that have their own setup, doctor, whoami, token or revoke (`provider <name> setup|doctor|whoami|token|revoke` runs one)",
1606
1617
  positionals: [],
1607
1618
  skipOptions: [
1608
1619
  "yes",
@@ -1764,6 +1775,20 @@ const requestsExportEntry = {
1764
1775
  ],
1765
1776
  supportsDryRun: true
1766
1777
  };
1778
+ // src/commands/rotate-tokens/rotate-tokens.entry.ts
1779
+ const rotateTokensEntry = {
1780
+ name: "rotate tokens",
1781
+ description: "Replace the tokens `doctor tokens` reports as due, for the providers that can make one",
1782
+ positionals: [],
1783
+ options: [{
1784
+ key: "env",
1785
+ flag: "--env",
1786
+ type: "input",
1787
+ message: "Only this layer (local, dev, ci, prod or preview; blank for all):"
1788
+ }],
1789
+ skipOptions: ["yes"],
1790
+ supportsDryRun: true
1791
+ };
1767
1792
  // src/commands/run/run-ci.entry.ts
1768
1793
  /** The options of `run` that the menu does not offer; the entries it builds for each task share this (`run ci` also offers `--all`). */
1769
1794
  const RUN_SKIP_OPTIONS = [
@@ -1980,6 +2005,15 @@ const specsSyncEntry = {
1980
2005
  ],
1981
2006
  supportsDryRun: true
1982
2007
  };
2008
+ // src/commands/start-agent/start-agent.entry.ts
2009
+ const startAgentEntry = {
2010
+ name: "start agent",
2011
+ description: "Start an agent's program with the credentials of the `agent` Environment and nothing else (the program follows `--`)",
2012
+ positionals: [],
2013
+ options: [],
2014
+ skipOptions: [],
2015
+ supportsDryRun: true
2016
+ };
1983
2017
  // src/commands/start-work/start-work.entry.ts
1984
2018
  const startWorkEntry = {
1985
2019
  name: "start work",
@@ -2343,6 +2377,7 @@ const registry = createCommandRegistry([
2343
2377
  notificationsChannelAddEntry,
2344
2378
  doctorMonitoringEntry,
2345
2379
  doctorNotificationsEntry,
2380
+ doctorAgentEntry,
2346
2381
  doctorEnvironmentsEntry,
2347
2382
  doctorProjectEntry,
2348
2383
  doctorGitHubAppEntry,
@@ -2389,6 +2424,7 @@ const registry = createCommandRegistry([
2389
2424
  newWorkEntry,
2390
2425
  issueUpdateEntry,
2391
2426
  startWorkEntry,
2427
+ startAgentEntry,
2392
2428
  updateWorkEntry,
2393
2429
  closeWorkEntry,
2394
2430
  newIncidentEntry,
@@ -2459,7 +2495,8 @@ const registry = createCommandRegistry([
2459
2495
  projectStatusEntry,
2460
2496
  projectReconcileEntry,
2461
2497
  reconcileCiEntry,
2462
- redeliverWebhooksEntry
2498
+ redeliverWebhooksEntry,
2499
+ rotateTokensEntry
2463
2500
  ], "interactive-menu");
2464
2501
  /** Every Holocron command, in menu order: what {@link launchMenu} lists and what a leaf handler's prompt reads. */
2465
2502
  const COMMAND_REGISTRY = registry.entries;
@@ -2849,7 +2886,7 @@ var MissingTokenError = class extends Error {
2849
2886
  name = "MissingTokenError";
2850
2887
  };
2851
2888
  // src/config/split-agent/split-agent.ts
2852
- const AGENT_OPTIONS = ["dcg"];
2889
+ const AGENT_OPTIONS = ["dcg", "denyRead"];
2853
2890
  /**
2854
2891
  * Reads `agent` in either form, a name (`"claude"`) or a name with options (`["claude", { dcg: true }]`), the form a
2855
2892
  * provider takes. The name keeps its place in the resolved config, so everything that installs skills reads it as before;
@@ -2866,6 +2903,11 @@ function splitAgent(raw) {
2866
2903
  for (const key of Object.keys(options)) if (!AGENT_OPTIONS.includes(key)) throw new ConfigError$1(`the \`${agent}\` agent has no option \`${key}\` (the options are: ${AGENT_OPTIONS.join(", ")})`);
2867
2904
  if (options.dcg !== void 0 && typeof options.dcg !== "boolean") throw new ConfigError$1(`the \`dcg\` option of the \`${agent}\` agent must be true or false`);
2868
2905
  if (options.dcg === true && agent !== "claude") throw new ConfigError$1(`\`dcg\` wires a hook into .claude/settings.json, so it is an option of "claude", not "${agent}"`);
2906
+ if (options.denyRead !== void 0) {
2907
+ const paths = options.denyRead;
2908
+ if (!Array.isArray(paths) || paths.some((path) => typeof path !== "string" || path === "")) throw new ConfigError$1(`the \`denyRead\` option of the \`${agent}\` agent must be a list of paths`);
2909
+ if (paths.length > 0 && agent !== "claude") throw new ConfigError$1(`\`denyRead\` writes permission rules into .claude/settings.json, so it is an option of "claude", not "${agent}"`);
2910
+ }
2869
2911
  return {
2870
2912
  agent,
2871
2913
  agentOptions: options
@@ -2878,7 +2920,8 @@ const ENVIRONMENT_LAYERS = [
2878
2920
  "dev",
2879
2921
  "ci",
2880
2922
  "prod",
2881
- "preview"
2923
+ "preview",
2924
+ "agent"
2882
2925
  ];
2883
2926
  /** Whether `value` is exactly one of the layer words (case-sensitive: `Prod` is a literal Environment name). */
2884
2927
  function isEnvironmentLayer(value) {
@@ -2942,7 +2985,7 @@ const COMMIT_TYPES = [
2942
2985
  "style",
2943
2986
  "revert"
2944
2987
  ];
2945
- const isObject$4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2988
+ const isObject$5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2946
2989
  const KEYS$2 = [
2947
2990
  "name",
2948
2991
  "description",
@@ -2962,7 +3005,7 @@ function validateIssueTypes(value, at = "issueTypes") {
2962
3005
  const seen = /* @__PURE__ */ new Set();
2963
3006
  return value.map((entry, index) => {
2964
3007
  const where = `${at}[${index}]`;
2965
- if (!isObject$4(entry)) throw new ConfigError$1(`${where} must be an object with a "name"`);
3008
+ if (!isObject$5(entry)) throw new ConfigError$1(`${where} must be an object with a "name"`);
2966
3009
  for (const key of Object.keys(entry)) if (!KEYS$2.includes(key)) throw new ConfigError$1(`${where}: "${key}" is not an issue Type option. Known: ${KEYS$2.join(", ")}`);
2967
3010
  const { name, description, color, enabled, label, commit } = entry;
2968
3011
  if (typeof name !== "string" || name.trim() === "") throw new ConfigError$1(`${where}: "name" must be a non-empty string`);
@@ -2992,10 +3035,10 @@ const KEYS$1 = /* @__PURE__ */ new Set([
2992
3035
  "preventSelfReview"
2993
3036
  ]);
2994
3037
  const REVIEWER_KEYS = /* @__PURE__ */ new Set(["type", "id"]);
2995
- const isObject$3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3038
+ const isObject$4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2996
3039
  /** Checks one reviewer of the Environment spelled `named`, and records it in `seen` so none is listed twice. */
2997
3040
  function validateReviewer(raw, named, seen) {
2998
- if (!isObject$3(raw)) throw new ConfigError$1(`${named}: a reviewer must be an object`);
3041
+ if (!isObject$4(raw)) throw new ConfigError$1(`${named}: a reviewer must be an object`);
2999
3042
  const extra = Object.keys(raw).find((key) => !REVIEWER_KEYS.has(key));
3000
3043
  if (extra !== void 0) throw new ConfigError$1(`${named}: a reviewer has no \`${extra}\` (a numeric \`id\`, not a login)`);
3001
3044
  const { type, id } = raw;
@@ -3008,7 +3051,7 @@ function validateReviewer(raw, named, seen) {
3008
3051
  /** Checks one entry of `repo.environments`, which is at position `index` and whose name is not yet in `seen`. */
3009
3052
  function validateEntry(raw, index, seen) {
3010
3053
  const at = `\`repo.environments[${index}]\``;
3011
- if (!isObject$3(raw)) throw new ConfigError$1(`${at} must be an object`);
3054
+ if (!isObject$4(raw)) throw new ConfigError$1(`${at} must be an object`);
3012
3055
  const unknown = Object.keys(raw).find((key) => !KEYS$1.has(key));
3013
3056
  if (unknown !== void 0) throw new ConfigError$1(`${at} has no \`${unknown}\` (use ${[...KEYS$1].map((k) => `\`${k}\``).join(", ")})`);
3014
3057
  const { name, waitTimer, preventSelfReview, reviewers } = raw;
@@ -3133,8 +3176,15 @@ async function repoSlug(cwd, exec) {
3133
3176
  return remote.slug;
3134
3177
  }
3135
3178
  // src/credentials-environments/unsynced-layer/unsynced-layer.ts
3136
- /** The layers this machine reads for itself. They are never synced to GitHub, a deployment or a Worker (#2104). */
3137
- const UNSYNCED_LAYERS = ["local", "dev"];
3179
+ /**
3180
+ * The layers this machine reads for itself (`agent` is the one an agent's process reads, spec `tech-agent-secrets`). They
3181
+ * are never synced to GitHub, a deployment or a Worker (#2104).
3182
+ */
3183
+ const UNSYNCED_LAYERS = [
3184
+ "local",
3185
+ "dev",
3186
+ "agent"
3187
+ ];
3138
3188
  /** Whether `layer` is one of {@link UNSYNCED_LAYERS}. */
3139
3189
  function isUnsyncedLayer(layer) {
3140
3190
  return isEnvironmentLayer(layer) && UNSYNCED_LAYERS.includes(layer);
@@ -3146,7 +3196,7 @@ function isUnsyncedLayer(layer) {
3146
3196
  * @param layer - The unsynced layer.
3147
3197
  */
3148
3198
  function unsyncedLayerMessage(what, layer) {
3149
- return `${what} names the \`${layer}\` layer: \`local\` and \`dev\` are read by this machine and are never synced. Only ${ENVIRONMENT_LAYERS.filter((l) => !isUnsyncedLayer(l)).map((l) => `\`${String(l)}\``).join(" and ")} can be synced`;
3199
+ return `${what} names the \`${layer}\` layer: \`local\`, \`dev\` and \`agent\` are read by this machine and are never synced. Only ${ENVIRONMENT_LAYERS.filter((l) => !isUnsyncedLayer(l)).map((l) => `\`${String(l)}\``).join(" and ")} can be synced`;
3150
3200
  }
3151
3201
  /**
3152
3202
  * Refuse a sync of an unsynced layer, before anything is read. The argument is a layer word, or the literal name of a
@@ -3664,21 +3714,21 @@ const ORG_OPTIONS = {
3664
3714
  checkly: ["accountId"],
3665
3715
  sentry: ["org"]
3666
3716
  };
3667
- const isObject$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3668
- const isTuple = (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && isObject$2(entry[1]);
3717
+ const isObject$3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3718
+ const isTuple = (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && isObject$3(entry[1]);
3669
3719
  /**
3670
3720
  * Check the shape of the area file: the top-level `domain` (a non-empty string), then a closed list of providers,
3671
3721
  * each with a closed list of string options.
3672
3722
  */
3673
3723
  function validate(area) {
3674
- if (!isObject$2(area.value)) throw new ConfigError$1(`${area.path} must export the org settings as an object`);
3724
+ if (!isObject$3(area.value)) throw new ConfigError$1(`${area.path} must export the org settings as an object`);
3675
3725
  const { domain, issueTypes, ...rest } = area.value;
3676
3726
  if (domain !== void 0 && (typeof domain !== "string" || domain === "")) throw new ConfigError$1(`${area.path}: "domain" must be a non-empty string`);
3677
3727
  const types = issueTypes === void 0 ? void 0 : validateIssueTypes(issueTypes, `${area.path}: issueTypes`);
3678
3728
  for (const [provider, options] of Object.entries(rest)) {
3679
3729
  const allowed = ORG_OPTIONS[provider];
3680
3730
  if (allowed === void 0) throw new ConfigError$1(`${area.path} has an unknown provider "${provider}". Known: ${Object.keys(ORG_OPTIONS).join(", ")}`);
3681
- if (!isObject$2(options)) throw new ConfigError$1(`${area.path}: "${provider}" must be an object of options`);
3731
+ if (!isObject$3(options)) throw new ConfigError$1(`${area.path}: "${provider}" must be an object of options`);
3682
3732
  for (const [option, value] of Object.entries(options)) {
3683
3733
  if (!allowed.includes(option)) throw new ConfigError$1(`${area.path}: "${provider}.${option}" is not an org option. Known: ${allowed.join(", ")}`);
3684
3734
  if (typeof value !== "string" || value === "") throw new ConfigError$1(`${area.path}: "${provider}.${option}" must be a non-empty string`);
@@ -3806,13 +3856,16 @@ const SUFFIX = {
3806
3856
  local: "local",
3807
3857
  development: "dev",
3808
3858
  ci: "ci",
3809
- production: "prod"
3859
+ production: "prod",
3860
+ agent: "agent"
3810
3861
  };
3811
3862
  /**
3812
3863
  * The Environments a layer reads, in the order they are tried (#2063, #2058). A machine (`local`) reads
3813
3864
  * `<slug> - local` and then `<slug> - dev`: that is the only fallback there is. `development` reads `- dev`, `ci`
3814
- * reads `- ci` and `production` reads `- prod`; a missing name is a missing name. `test` and `preview` read none (a preview deployment gets its values from the deployment, not from a vault). Only `- local`
3815
- * is optional.
3865
+ * reads `- ci` and `production` reads `- prod`; a missing name is a missing name. `agent` (an agent's process, spec
3866
+ * `tech-agent-secrets`) reads `- agent` and nothing else, not `- local` or `- dev`, so an agent never sees a value that
3867
+ * belongs to a person's layer. `test` and `preview` read none (a preview deployment gets its values from the
3868
+ * deployment, not from a vault). Only `- local` is optional.
3816
3869
  */
3817
3870
  function environmentLayers(slug, layer) {
3818
3871
  if (layer === "test" || layer === "preview") return [];
@@ -4208,6 +4261,30 @@ var PluginLoader = class extends system.PluginLoader {
4208
4261
  for (const [provider, plugin] of this.plugins()) if (plugin.mintToken) found.set(provider, plugin.mintToken);
4209
4262
  return found;
4210
4263
  }
4264
+ /** The `revokeToken` each loaded provider offers, by provider name. A provider that cannot delete a token is left out. */
4265
+ revokeTokens() {
4266
+ const found = /* @__PURE__ */ new Map();
4267
+ for (const [provider, plugin] of this.plugins()) if (plugin.revokeToken) found.set(provider, plugin.revokeToken);
4268
+ return found;
4269
+ }
4270
+ /**
4271
+ * Loads one provider by name with the given options, whether or not `holocron.config` names it under a capability,
4272
+ * and returns its `revokeToken` (`undefined` when it cannot delete one), leaving the capability registry alone.
4273
+ * Throws {@link WorkspaceContextError} when the provider's package cannot be imported here.
4274
+ */
4275
+ async loadRevokeToken(provider, options) {
4276
+ const packageName = system.resolvePackage(provider);
4277
+ try {
4278
+ return (await this.loadProvider({
4279
+ provider,
4280
+ packageName,
4281
+ options
4282
+ })).revokeToken;
4283
+ } catch (err) {
4284
+ if (err instanceof LoaderError && err.message.startsWith("failed to import")) throw new WorkspaceContextError("provider", [packageName]);
4285
+ throw err;
4286
+ }
4287
+ }
4211
4288
  /**
4212
4289
  * Loads one provider by name with the given options, whether or not `holocron.config` names it under a capability,
4213
4290
  * and returns its `mintToken` (`undefined` when it cannot make one), leaving the capability registry alone. Throws
@@ -4331,7 +4408,7 @@ function planIssueTypes(declared, existing, update) {
4331
4408
  }
4332
4409
  const WRITE_PERMISSION = "creating or changing issue Types needs an organization admin and the organization permission Issue types: write (HOLOCRON_ORG_TOKEN)";
4333
4410
  const READ_PERMISSION = "reading the organization's issue Types needs the organization permission Issue types: read (HOLOCRON_ORG_TOKEN)";
4334
- const row$36 = (id, title, status, detail, problems = []) => ({
4411
+ const row$40 = (id, title, status, detail, problems = []) => ({
4335
4412
  id: `issue-types:${id}`,
4336
4413
  title,
4337
4414
  status,
@@ -4351,7 +4428,7 @@ async function ensureIssueTypes(input) {
4351
4428
  const refused = input.caller === "setup" ? "skip" : "fail";
4352
4429
  const stop = (status, detail, problems = []) => ({
4353
4430
  status,
4354
- rows: [row$36("types", "issue types", status, detail, problems)],
4431
+ rows: [row$40("types", "issue types", status, detail, problems)],
4355
4432
  created,
4356
4433
  updated
4357
4434
  });
@@ -4391,7 +4468,7 @@ async function ensureIssueTypes(input) {
4391
4468
  default: false
4392
4469
  })))(`Change the organization's issue Types?\n${todo.map((a) => ` ${describeAction(a).detail} ${a.declared.name}`).join("\n")}`)) return {
4393
4470
  status: "cancelled",
4394
- rows: [row$36("types", "issue types", "skip", "cancelled; nothing was changed")],
4471
+ rows: [row$40("types", "issue types", "skip", "cancelled; nothing was changed")],
4395
4472
  created,
4396
4473
  updated
4397
4474
  };
@@ -4406,34 +4483,34 @@ async function ensureIssueTypes(input) {
4406
4483
  continue;
4407
4484
  }
4408
4485
  if (limited) {
4409
- rows.push(row$36(name, name, "skip", "left: stopped at a rate limit"));
4486
+ rows.push(row$40(name, name, "skip", "left: stopped at a rate limit"));
4410
4487
  continue;
4411
4488
  }
4412
4489
  if (refusedOnce) {
4413
- rows.push(row$36(name, name, refused, "not written: the token was refused"));
4490
+ rows.push(row$40(name, name, refused, "not written: the token was refused"));
4414
4491
  continue;
4415
4492
  }
4416
4493
  try {
4417
4494
  if (action.kind === "create") {
4418
4495
  await issues.createType(toDeclaration(action.declared));
4419
4496
  created.push(name);
4420
- rows.push(row$36(name, name, "ok", "created"));
4497
+ rows.push(row$40(name, name, "ok", "created"));
4421
4498
  } else {
4422
4499
  const patch = Object.fromEntries(action.changes.map((c) => [c.field, c.to]));
4423
4500
  await issues.updateType?.(action.existing.id, patch);
4424
4501
  updated.push(name);
4425
- rows.push(row$36(name, name, "ok", `updated ${action.changes.map((c) => c.field).join(", ")}`));
4502
+ rows.push(row$40(name, name, "ok", `updated ${action.changes.map((c) => c.field).join(", ")}`));
4426
4503
  }
4427
4504
  } catch (err) {
4428
4505
  const kind = classifyTypeError(err);
4429
4506
  if (kind === "rate-limit") {
4430
4507
  limited = true;
4431
- rows.push(row$36(name, name, "fail", "rate limited: stopped; run it again to finish"));
4508
+ rows.push(row$40(name, name, "fail", "rate limited: stopped; run it again to finish"));
4432
4509
  } else if (kind === "refused") {
4433
4510
  refusedOnce = true;
4434
- rows.push(row$36(name, name, refused, WRITE_PERMISSION));
4435
- } else if (kind === "conflict" && action.kind === "create" && await nowExists(issues, name)) rows.push(row$36(name, name, "ok", "exists (made in the meantime)"));
4436
- else rows.push(row$36(name, name, "fail", describeError(err)));
4511
+ rows.push(row$40(name, name, refused, WRITE_PERMISSION));
4512
+ } else if (kind === "conflict" && action.kind === "create" && await nowExists(issues, name)) rows.push(row$40(name, name, "ok", "exists (made in the meantime)"));
4513
+ else rows.push(row$40(name, name, "fail", describeError(err)));
4437
4514
  }
4438
4515
  }
4439
4516
  return {
@@ -4454,12 +4531,12 @@ async function nowExists(issues, name) {
4454
4531
  /** The row of an action that is not carried out (a dry run, or the list shown before asking), or that needs none. */
4455
4532
  function describeAction(action) {
4456
4533
  const name = action.declared.name;
4457
- if (action.kind === "create") return row$36(name, name, "skip", "would create");
4534
+ if (action.kind === "create") return row$40(name, name, "skip", "would create");
4458
4535
  if (action.kind === "update") {
4459
4536
  const fields = action.changes.map((c) => c.field).join(", ");
4460
- return row$36(name, name, "skip", `would update ${fields}`, action.changes.map((c) => `${c.field}: was ${JSON.stringify(c.was)}, to ${JSON.stringify(c.to)}`));
4537
+ return row$40(name, name, "skip", `would update ${fields}`, action.changes.map((c) => `${c.field}: was ${JSON.stringify(c.was)}, to ${JSON.stringify(c.to)}`));
4461
4538
  }
4462
- return row$36(name, name, "ok", action.existing.enabled ? "exists" : "exists (turned off in the organization)");
4539
+ return row$40(name, name, "ok", action.existing.enabled ? "exists" : "exists (turned off in the organization)");
4463
4540
  }
4464
4541
  // src/commands/notifications-channel-add/private-host.ts
4465
4542
  /**
@@ -7207,7 +7284,7 @@ async function openBoardContext(input) {
7207
7284
  };
7208
7285
  }
7209
7286
  // src/commands/issue-fields/add-issue-to-board/add-issue-to-board.ts
7210
- const row$35 = (board, status, detail) => ({
7287
+ const row$39 = (board, status, detail) => ({
7211
7288
  id: `board ${board}`,
7212
7289
  title: `board ${board}`,
7213
7290
  status,
@@ -7229,27 +7306,27 @@ async function addIssueToBoard(input) {
7229
7306
  loader: input.loader,
7230
7307
  ...input.io ? { io: input.io } : {}
7231
7308
  });
7232
- if (!opened.ok) return row$35(board, opened.kind === "skip" ? "skip" : "fail", [opened.reason, ...opened.problems].join("; "));
7309
+ if (!opened.ok) return row$39(board, opened.kind === "skip" ? "skip" : "fail", [opened.reason, ...opened.problems].join("; "));
7233
7310
  const { projects, owner, boards, templates } = opened.context;
7234
- if (!projects.addItems) return row$35(board, "skip", `the \`${projects.providerName}\` provider cannot add items to a board`);
7311
+ if (!projects.addItems) return row$39(board, "skip", `the \`${projects.providerName}\` provider cannot add items to a board`);
7235
7312
  const declared = boards.find((b) => b.name.toLowerCase() === board.toLowerCase());
7236
7313
  if (!declared) {
7237
7314
  const names = boards.map((b) => b.name).join(", ");
7238
- return row$35(board, "fail", `no board named "${board}" is declared in providers.projects${names ? ` (declared: ${names})` : ""}`);
7315
+ return row$39(board, "fail", `no board named "${board}" is declared in providers.projects${names ? ` (declared: ${names})` : ""}`);
7239
7316
  }
7240
7317
  const template = templates[declared.template];
7241
- if (!template) return row$35(board, "fail", `the template "${declared.template}" of "${declared.name}" is not available`);
7318
+ if (!template) return row$39(board, "fail", `the template "${declared.template}" of "${declared.name}" is not available`);
7242
7319
  const found = await projects.find(owner, declared.name);
7243
- if (!found) return row$35(board, "fail", `the board "${declared.name}" does not exist yet; \`holocron setup project\` makes it`);
7244
- if (input.dryRun) return row$35(board, "skip", `would add ${key} to "${declared.name}"`);
7320
+ if (!found) return row$39(board, "fail", `the board "${declared.name}" does not exist yet; \`holocron setup project\` makes it`);
7321
+ if (input.dryRun) return row$39(board, "skip", `would add ${key} to "${declared.name}"`);
7245
7322
  const [added] = await projects.addItems(owner, found, [{
7246
7323
  key,
7247
7324
  ...input.priority ? { priority: input.priority } : {}
7248
7325
  }], template);
7249
7326
  const dropped = added?.dropped ?? [];
7250
- return row$35(board, dropped.length > 0 ? "skip" : "ok", `${added?.added ? "added" : "already on"} "${declared.name}"${dropped.length > 0 ? `; not set: ${dropped.join(", ")}` : ""}`);
7327
+ return row$39(board, dropped.length > 0 ? "skip" : "ok", `${added?.added ? "added" : "already on"} "${declared.name}"${dropped.length > 0 ? `; not set: ${dropped.join(", ")}` : ""}`);
7251
7328
  } catch (err) {
7252
- return row$35(board, "fail", `could not add ${key} to the board: ${describeError(err)}`);
7329
+ return row$39(board, "fail", `could not add ${key} to the board: ${describeError(err)}`);
7253
7330
  }
7254
7331
  }
7255
7332
  // src/commands/issue-fields/describe-issue-fields/describe-issue-fields.ts
@@ -7356,7 +7433,7 @@ function prepareIssueFields(input, areas) {
7356
7433
  * asks first unless `--dry-run` or `--yes` (without a terminal it refuses instead). `update work` is another command,
7357
7434
  * which spans the pull request and the board.
7358
7435
  */
7359
- const row$34 = (id, status, detail) => ({
7436
+ const row$38 = (id, status, detail) => ({
7360
7437
  id,
7361
7438
  title: id,
7362
7439
  status,
@@ -7382,7 +7459,7 @@ async function runIssueUpdate(input) {
7382
7459
  print(style.header(`Holocron update issue${dryRun ? " (dry-run)" : ""}`));
7383
7460
  print("");
7384
7461
  const key = input.key.trim();
7385
- if (!key) return finish([row$34("key", "fail", "the issue key is empty")]);
7462
+ if (!key) return finish([row$38("key", "fail", "the issue key is empty")]);
7386
7463
  const prepared = prepareIssueFields(input, input.loaded.resolved.repo?.labels?.areas);
7387
7464
  const problems = prepared.ok ? [] : [...prepared.problems];
7388
7465
  const clear = [...new Set(input.clear ?? [])];
@@ -7409,7 +7486,7 @@ async function runIssueUpdate(input) {
7409
7486
  for (const label of addLabels) if (removeLabels.some((r) => r.toLowerCase() === label.toLowerCase())) problems.push(`the label "${label}" is both added and removed`);
7410
7487
  const blockers = prepared.ok ? prepared.fields.blockedBy ?? [] : [];
7411
7488
  for (const k of unblock) if (blockers.includes(k)) problems.push(`${k} is both added and removed as a blocker`);
7412
- if (problems.length > 0 || !prepared.ok) return finish(problems.map((p) => row$34(key, "fail", p)));
7489
+ if (problems.length > 0 || !prepared.ok) return finish(problems.map((p) => row$38(key, "fail", p)));
7413
7490
  const patch = {
7414
7491
  ...prepared.fields,
7415
7492
  ...title ? { title } : {},
@@ -7435,10 +7512,10 @@ async function runIssueUpdate(input) {
7435
7512
  ...unblock.length > 0 ? [`unblock: ${unblock.join(", ")}`] : [],
7436
7513
  ...clear.length > 0 ? [`clear: ${clear.join(", ")}`] : []
7437
7514
  ];
7438
- if (details.length === 0) return finish([row$34(key, "fail", "nothing to change; name a field to set, or `--clear` one")]);
7515
+ if (details.length === 0) return finish([row$38(key, "fail", "nothing to change; name a field to set, or `--clear` one")]);
7439
7516
  const summary = ` (${details.join("; ")})`;
7440
7517
  const entry = input.loaded.resolved.providers.issues;
7441
- if (!entry) return finish([row$34(key, "fail", "the config has no `issues` provider to update the issue with")]);
7518
+ if (!entry) return finish([row$38(key, "fail", "the config has no `issues` provider to update the issue with")]);
7442
7519
  const credentials = input.loaded.resolved.providers.credentials;
7443
7520
  const projects = prepared.project ? input.loaded.resolved.providers.projects : void 0;
7444
7521
  /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
@@ -7455,10 +7532,10 @@ async function runIssueUpdate(input) {
7455
7532
  assertPluginsResolvable(loader, "update issue");
7456
7533
  if (!loader.has("issues")) {
7457
7534
  const failure = loader.loadFailures().find((f) => f.key === "issues");
7458
- return finish([row$34(key, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
7535
+ return finish([row$38(key, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
7459
7536
  }
7460
7537
  const issues = loader.get("issues");
7461
- if (!issues.update) return finish([row$34(key, "fail", `the \`${issues.providerName}\` provider does not support \`update issue\``)]);
7538
+ if (!issues.update) return finish([row$38(key, "fail", `the \`${issues.providerName}\` provider does not support \`update issue\``)]);
7462
7539
  if (dryRun) {
7463
7540
  const board = prepared.project ? await addIssueToBoard({
7464
7541
  loaded: input.loaded,
@@ -7468,7 +7545,7 @@ async function runIssueUpdate(input) {
7468
7545
  key,
7469
7546
  dryRun: true
7470
7547
  }) : void 0;
7471
- return finish([row$34(key, "skip", `would update the issue${summary}`), ...board ? [board] : []]);
7548
+ return finish([row$38(key, "skip", `would update the issue${summary}`), ...board ? [board] : []]);
7472
7549
  }
7473
7550
  if (!input.yes) {
7474
7551
  if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError("`update issue` changes an issue; pass --yes to run it without asking, or --dry-run to preview");
@@ -7494,12 +7571,12 @@ async function runIssueUpdate(input) {
7494
7571
  ...prepared.fields.priority ? { priority: prepared.fields.priority } : {}
7495
7572
  }) : void 0;
7496
7573
  return finish([
7497
- row$34(result.key, "ok", result.changed.length > 0 ? `updated: ${result.changed.join("; ")}` : "already as asked; nothing changed"),
7498
- ...(result.dropped ?? []).map((line) => row$34("not carried across", "skip", line)),
7574
+ row$38(result.key, "ok", result.changed.length > 0 ? `updated: ${result.changed.join("; ")}` : "already as asked; nothing changed"),
7575
+ ...(result.dropped ?? []).map((line) => row$38("not carried across", "skip", line)),
7499
7576
  ...board ? [board] : []
7500
7577
  ], result.changed);
7501
7578
  } catch (err) {
7502
- return finish([row$34(key, "fail", `could not update the issue: ${describeError(err)}`)]);
7579
+ return finish([row$38(key, "fail", `could not update the issue: ${describeError(err)}`)]);
7503
7580
  }
7504
7581
  }
7505
7582
  // src/commands/start-work/find-worktree/find-worktree.ts
@@ -7539,7 +7616,7 @@ function unpushedCommits(git, cwd, branch) {
7539
7616
  ], cwd)) || 0;
7540
7617
  }
7541
7618
  // src/commands/close-work/clean-up-work/clean-up-work.ts
7542
- const row$33 = (id, status, detail) => ({
7619
+ const row$37 = (id, status, detail) => ({
7543
7620
  id,
7544
7621
  title: id,
7545
7622
  status,
@@ -7568,51 +7645,51 @@ function cleanUpWork(input) {
7568
7645
  let keepBranch;
7569
7646
  try {
7570
7647
  const path = findWorktree(git, repoRoot, branch);
7571
- if (!path) rows.push(row$33("worktree", "skip", `none holds ${branch}`));
7648
+ if (!path) rows.push(row$37("worktree", "skip", `none holds ${branch}`));
7572
7649
  else if (input.keepWorktree) {
7573
- rows.push(row$33("worktree", "skip", `kept at ${path} (--keep-worktree)`));
7650
+ rows.push(row$37("worktree", "skip", `kept at ${path} (--keep-worktree)`));
7574
7651
  keepBranch = "its worktree is kept";
7575
7652
  } else if (resolve(path) === mainWorktree(input)) {
7576
- rows.push(row$33("worktree", "skip", `${branch} is checked out in the main checkout; switch it to another branch first`));
7653
+ rows.push(row$37("worktree", "skip", `${branch} is checked out in the main checkout; switch it to another branch first`));
7577
7654
  keepBranch = "it is checked out in the main checkout";
7578
7655
  } else if (resolve(repoRoot) === resolve(path) || resolve(repoRoot).startsWith(resolve(path) + sep)) {
7579
- rows.push(row$33("worktree", "skip", `${path} is where this command is running; run it from another checkout`));
7656
+ rows.push(row$37("worktree", "skip", `${path} is where this command is running; run it from another checkout`));
7580
7657
  keepBranch = "its worktree is where this command is running";
7581
7658
  } else if (git(["status", "--porcelain"], path)) {
7582
- rows.push(row$33("worktree", "fail", `${path} has uncommitted changes; commit or discard them, nothing was removed`));
7659
+ rows.push(row$37("worktree", "fail", `${path} has uncommitted changes; commit or discard them, nothing was removed`));
7583
7660
  keepBranch = "its worktree has uncommitted changes";
7584
- } else if (dryRun) rows.push(row$33("worktree", "skip", `would remove ${path}`));
7661
+ } else if (dryRun) rows.push(row$37("worktree", "skip", `would remove ${path}`));
7585
7662
  else {
7586
7663
  git([
7587
7664
  "worktree",
7588
7665
  "remove",
7589
7666
  path
7590
7667
  ], repoRoot);
7591
- rows.push(row$33("worktree", "ok", `removed ${path}`));
7668
+ rows.push(row$37("worktree", "ok", `removed ${path}`));
7592
7669
  }
7593
7670
  } catch (err) {
7594
- rows.push(row$33("worktree", "fail", `could not remove the worktree: ${describeError(err)}`));
7671
+ rows.push(row$37("worktree", "fail", `could not remove the worktree: ${describeError(err)}`));
7595
7672
  keepBranch = "its worktree could not be removed";
7596
7673
  }
7597
7674
  try {
7598
7675
  const unpushed = unpushedCommits(git, repoRoot, branch);
7599
- if (unpushed === void 0) rows.push(row$33("local branch", "skip", `${branch} is not in this checkout`));
7600
- else if (keepBranch) rows.push(row$33("local branch", "skip", `${branch} stays: ${keepBranch}`));
7676
+ if (unpushed === void 0) rows.push(row$37("local branch", "skip", `${branch} is not in this checkout`));
7677
+ else if (keepBranch) rows.push(row$37("local branch", "skip", `${branch} stays: ${keepBranch}`));
7601
7678
  else {
7602
7679
  const tip = git(["rev-parse", `refs/heads/${branch}`], repoRoot);
7603
- if (!(input.mode === "abandoned" || unpushed === 0 || input.headSha && tip === input.headSha)) rows.push(row$33("local branch", "fail", `${branch} holds commits the pull request does not (tip ${tip.slice(0, 7)}); not deleted`));
7604
- else if (dryRun) rows.push(row$33("local branch", "skip", `would delete ${branch}`));
7680
+ if (!(input.mode === "abandoned" || unpushed === 0 || input.headSha && tip === input.headSha)) rows.push(row$37("local branch", "fail", `${branch} holds commits the pull request does not (tip ${tip.slice(0, 7)}); not deleted`));
7681
+ else if (dryRun) rows.push(row$37("local branch", "skip", `would delete ${branch}`));
7605
7682
  else {
7606
7683
  git([
7607
7684
  "branch",
7608
7685
  "-D",
7609
7686
  branch
7610
7687
  ], repoRoot);
7611
- rows.push(row$33("local branch", "ok", `deleted ${branch}`));
7688
+ rows.push(row$37("local branch", "ok", `deleted ${branch}`));
7612
7689
  }
7613
7690
  }
7614
7691
  } catch (err) {
7615
- rows.push(row$33("local branch", "fail", `could not delete ${branch}: ${describeError(err)}`));
7692
+ rows.push(row$37("local branch", "fail", `could not delete ${branch}: ${describeError(err)}`));
7616
7693
  }
7617
7694
  try {
7618
7695
  const remote = git([
@@ -7621,9 +7698,9 @@ function cleanUpWork(input) {
7621
7698
  "origin",
7622
7699
  `refs/heads/${branch}`
7623
7700
  ], repoRoot);
7624
- rows.push(remote ? row$33("remote branch", "skip", `${branch} is still on origin; GitHub deletes it on merge (the repo setting), or run: git push origin --delete ${branch}`) : row$33("remote branch", "ok", `${branch} is gone from origin`));
7701
+ rows.push(remote ? row$37("remote branch", "skip", `${branch} is still on origin; GitHub deletes it on merge (the repo setting), or run: git push origin --delete ${branch}`) : row$37("remote branch", "ok", `${branch} is gone from origin`));
7625
7702
  } catch (err) {
7626
- rows.push(row$33("remote branch", "skip", `could not ask origin: ${describeError(err)}`));
7703
+ rows.push(row$37("remote branch", "skip", `could not ask origin: ${describeError(err)}`));
7627
7704
  }
7628
7705
  return rows;
7629
7706
  }
@@ -7667,7 +7744,7 @@ function findWorkBranches(git, cwd, issue) {
7667
7744
  });
7668
7745
  }
7669
7746
  // src/commands/close-work/abandon-work/abandon-work.ts
7670
- const row$32 = (id, status, detail) => ({
7747
+ const row$36 = (id, status, detail) => ({
7671
7748
  id,
7672
7749
  title: id,
7673
7750
  status,
@@ -7692,9 +7769,9 @@ async function abandonWork(a) {
7692
7769
  try {
7693
7770
  found = findWorkBranches(git, repoRoot, key);
7694
7771
  } catch (err) {
7695
- return { rows: [row$32("local branch", "fail", `could not list the branches: ${describeError(err)}`)] };
7772
+ return { rows: [row$36("local branch", "fail", `could not list the branches: ${describeError(err)}`)] };
7696
7773
  }
7697
- if (found.length > 1) return { rows: [row$32("local branch", "fail", `${found.length} branches are named for ${key} (${found.join(", ")}); --pr names the pull request whose branch to remove`)] };
7774
+ if (found.length > 1) return { rows: [row$36("local branch", "fail", `${found.length} branches are named for ${key} (${found.join(", ")}); --pr names the pull request whose branch to remove`)] };
7698
7775
  branch = found[0];
7699
7776
  }
7700
7777
  if (branch) {
@@ -7702,9 +7779,9 @@ async function abandonWork(a) {
7702
7779
  try {
7703
7780
  unpushed = unpushedCommits(git, repoRoot, branch);
7704
7781
  } catch (err) {
7705
- return { rows: [row$32("unpushed commits", "fail", `could not read ${branch}: ${describeError(err)}`)] };
7782
+ return { rows: [row$36("unpushed commits", "fail", `could not read ${branch}: ${describeError(err)}`)] };
7706
7783
  }
7707
- if (unpushed !== void 0 && unpushed > 0) return { rows: [row$32("unpushed commits", "fail", `${branch} holds ${unpushed} commit${unpushed === 1 ? "" : "s"} no remote branch has; push ${unpushed === 1 ? "it" : "them"} or delete the branch by hand. Nothing was changed`)] };
7784
+ if (unpushed !== void 0 && unpushed > 0) return { rows: [row$36("unpushed commits", "fail", `${branch} holds ${unpushed} commit${unpushed === 1 ? "" : "s"} no remote branch has; push ${unpushed === 1 ? "it" : "them"} or delete the branch by hand. Nothing was changed`)] };
7708
7785
  }
7709
7786
  if (!dryRun && !input.yes) {
7710
7787
  const what = [
@@ -7718,31 +7795,31 @@ async function abandonWork(a) {
7718
7795
  };
7719
7796
  }
7720
7797
  let specFiles = [];
7721
- if (!pr) rows.push(row$32("pull request", "skip", `no open pull request for ${key}`));
7798
+ if (!pr) rows.push(row$36("pull request", "skip", `no open pull request for ${key}`));
7722
7799
  else {
7723
7800
  try {
7724
7801
  specFiles = source.listPullRequestFiles ? findSpecFiles(await source.listPullRequestFiles(pr.number)) : [];
7725
7802
  } catch (err) {
7726
- rows.push(row$32("spec", "fail", `could not read the pull request's files: ${describeError(err)}`));
7803
+ rows.push(row$36("spec", "fail", `could not read the pull request's files: ${describeError(err)}`));
7727
7804
  }
7728
- if (pr.state !== "open") rows.push(row$32("pull request", "skip", `#${pr.number} is already closed`));
7729
- else if (!source.updatePullRequest) rows.push(row$32("pull request", "fail", `the \`${source.providerName}\` provider cannot close a pull request`));
7730
- else if (dryRun) rows.push(row$32("pull request", "skip", `would close #${pr.number}`));
7805
+ if (pr.state !== "open") rows.push(row$36("pull request", "skip", `#${pr.number} is already closed`));
7806
+ else if (!source.updatePullRequest) rows.push(row$36("pull request", "fail", `the \`${source.providerName}\` provider cannot close a pull request`));
7807
+ else if (dryRun) rows.push(row$36("pull request", "skip", `would close #${pr.number}`));
7731
7808
  else try {
7732
7809
  await source.updatePullRequest(pr.number, { state: "closed" });
7733
- rows.push(row$32("pull request", "ok", `closed #${pr.number}`));
7810
+ rows.push(row$36("pull request", "ok", `closed #${pr.number}`));
7734
7811
  } catch (err) {
7735
- rows.push(row$32("pull request", "fail", `could not close #${pr.number}: ${describeError(err)}`));
7812
+ rows.push(row$36("pull request", "fail", `could not close #${pr.number}: ${describeError(err)}`));
7736
7813
  }
7737
7814
  }
7738
7815
  if (pr && !rows.some((r) => r.id === "spec")) {
7739
- if (specFiles.length === 0) rows.push(row$32("spec", "skip", "the pull request holds no spec or ADR, so no post to withdraw"));
7740
- else if (!input.withdrawSpecs) rows.push(row$32("spec", "fail", "no way to withdraw the post was given"));
7816
+ if (specFiles.length === 0) rows.push(row$36("spec", "skip", "the pull request holds no spec or ADR, so no post to withdraw"));
7817
+ else if (!input.withdrawSpecs) rows.push(row$36("spec", "fail", "no way to withdraw the post was given"));
7741
7818
  else try {
7742
7819
  const result = await input.withdrawSpecs(specFiles);
7743
- rows.push(row$32("spec", result.ok ? "ok" : "fail", `${specFiles.join(", ")}: ${result.detail}`));
7820
+ rows.push(row$36("spec", result.ok ? "ok" : "fail", `${specFiles.join(", ")}: ${result.detail}`));
7744
7821
  } catch (err) {
7745
- rows.push(row$32("spec", "fail", `could not withdraw the post: ${describeError(err)}`));
7822
+ rows.push(row$36("spec", "fail", `could not withdraw the post: ${describeError(err)}`));
7746
7823
  }
7747
7824
  }
7748
7825
  if (branch) rows.push(...cleanUpWork({
@@ -7753,9 +7830,9 @@ async function abandonWork(a) {
7753
7830
  mode: "abandoned",
7754
7831
  ...input.keepWorktree ? { keepWorktree: true } : {}
7755
7832
  }));
7756
- else rows.push(row$32("local branch", "skip", `no local branch is named for ${key}`));
7757
- if (dryRun) rows.push(row$32("issue", "skip", `would ask whether to close ${key} as not planned`));
7758
- else if (input.yes) rows.push(row$32("issue", "skip", `${key} left open: --yes does not close an issue; run \`holocron update issue ${key} --state closed --state-reason not_planned\` to close it as not planned`));
7833
+ else rows.push(row$36("local branch", "skip", `no local branch is named for ${key}`));
7834
+ if (dryRun) rows.push(row$36("issue", "skip", `would ask whether to close ${key} as not planned`));
7835
+ else if (input.yes) rows.push(row$36("issue", "skip", `${key} left open: --yes does not close an issue; run \`holocron update issue ${key} --state closed --state-reason not_planned\` to close it as not planned`));
7759
7836
  else if (await a.ask(`Close ${key} as not planned?`)) {
7760
7837
  const close = await (input.updateIssue ?? runIssueUpdate)({
7761
7838
  key,
@@ -7772,7 +7849,7 @@ async function abandonWork(a) {
7772
7849
  id: `issue: ${r.id}`,
7773
7850
  title: `issue: ${r.title}`
7774
7851
  });
7775
- } else rows.push(row$32("issue", "skip", `${key} left open`));
7852
+ } else rows.push(row$36("issue", "skip", `${key} left open`));
7776
7853
  return { rows };
7777
7854
  }
7778
7855
  // src/commands/update-work/find-work-pull-request/find-work-pull-request.ts
@@ -8257,7 +8334,7 @@ function workTitle(input) {
8257
8334
  const MAX_TITLE = 100;
8258
8335
  const DEFAULT_BASE = "alpha";
8259
8336
  const WORKTREES = ".claude/worktrees";
8260
- const row$31 = (id, status, detail) => ({
8337
+ const row$35 = (id, status, detail) => ({
8261
8338
  id,
8262
8339
  title: id,
8263
8340
  status,
@@ -8293,7 +8370,7 @@ async function runStartWork(input) {
8293
8370
  };
8294
8371
  };
8295
8372
  const fail = (id, detail) => {
8296
- rows.push(row$31(id, "fail", detail));
8373
+ rows.push(row$35(id, "fail", detail));
8297
8374
  return finish();
8298
8375
  };
8299
8376
  print(style.header(`Holocron start work${dryRun ? " (dry-run)" : ""}`));
@@ -8349,7 +8426,7 @@ async function runStartWork(input) {
8349
8426
  } catch (err) {
8350
8427
  return fail(key, `could not read the issue: ${describeError(err)}`);
8351
8428
  }
8352
- rows.push(row$31(key, "ok", `${issue.summary} (${issue.status})`));
8429
+ rows.push(row$35(key, "ok", `${issue.summary} (${issue.status})`));
8353
8430
  const named = workTitle({
8354
8431
  issueTitle: issue.summary,
8355
8432
  ...input.kind ? {
@@ -8392,14 +8469,14 @@ async function runStartWork(input) {
8392
8469
  ...source ? [`draft pull request "${title}" (${link.keyword} ${key})`] : ["no pull request"]
8393
8470
  ].join("; ");
8394
8471
  if (dryRun) {
8395
- rows.push(row$31("title", "skip", `${title} (${named.reason}${releaseNote})`));
8396
- rows.push(row$31("start date", "skip", `would set the start date${input.effort ? ` and Effort ${input.effort}` : ""}${branchExists ? " (not again: the branch exists)" : ""}`));
8397
- rows.push(row$31("branch", "skip", `would ${branchExists ? "reuse" : "make"} ${branch} from origin/${base}`));
8398
- if (useWorktree) rows.push(row$31("worktree", "skip", `would use ${wtPath}`));
8399
- rows.push(row$31("first commit", "skip", `would commit${spec ? ` ${spec.rel}` : " empty"} as "${commitSubject}"`));
8400
- rows.push(row$31("push", "skip", `would push ${branch} to origin`));
8401
- if (source) rows.push(row$31("pull request", "skip", `would open a draft pull request against ${base}, ${link.keyword} ${key}`));
8402
- rows.push(row$31("board status", "skip", "the open pull request moves the issue to In Progress"));
8472
+ rows.push(row$35("title", "skip", `${title} (${named.reason}${releaseNote})`));
8473
+ rows.push(row$35("start date", "skip", `would set the start date${input.effort ? ` and Effort ${input.effort}` : ""}${branchExists ? " (not again: the branch exists)" : ""}`));
8474
+ rows.push(row$35("branch", "skip", `would ${branchExists ? "reuse" : "make"} ${branch} from origin/${base}`));
8475
+ if (useWorktree) rows.push(row$35("worktree", "skip", `would use ${wtPath}`));
8476
+ rows.push(row$35("first commit", "skip", `would commit${spec ? ` ${spec.rel}` : " empty"} as "${commitSubject}"`));
8477
+ rows.push(row$35("push", "skip", `would push ${branch} to origin`));
8478
+ if (source) rows.push(row$35("pull request", "skip", `would open a draft pull request against ${base}, ${link.keyword} ${key}`));
8479
+ rows.push(row$35("board status", "skip", "the open pull request moves the issue to In Progress"));
8403
8480
  return finish();
8404
8481
  }
8405
8482
  if (!input.yes) {
@@ -8415,18 +8492,18 @@ async function runStartWork(input) {
8415
8492
  };
8416
8493
  }
8417
8494
  }
8418
- rows.push(row$31("title", "ok", `${title} (${named.reason}${releaseNote})`));
8419
- if (branchExists) rows.push(row$31("start date", "skip", "the branch exists, so the work started before; the start date is left as it is"));
8420
- else if (!issues.update) rows.push(row$31("start date", "skip", `the \`${issues.providerName}\` provider cannot update an issue`));
8495
+ rows.push(row$35("title", "ok", `${title} (${named.reason}${releaseNote})`));
8496
+ if (branchExists) rows.push(row$35("start date", "skip", "the branch exists, so the work started before; the start date is left as it is"));
8497
+ else if (!issues.update) rows.push(row$35("start date", "skip", `the \`${issues.providerName}\` provider cannot update an issue`));
8421
8498
  else try {
8422
8499
  const result = await issues.update(key, {
8423
8500
  startDate: io.today(),
8424
8501
  ...input.effort ? { effort: input.effort } : {}
8425
8502
  });
8426
- rows.push(row$31("start date", "ok", result.changed.length > 0 ? result.changed.join(", ") : "already as asked"));
8427
- for (const line of result.dropped ?? []) rows.push(row$31("not carried across", "skip", line));
8503
+ rows.push(row$35("start date", "ok", result.changed.length > 0 ? result.changed.join(", ") : "already as asked"));
8504
+ for (const line of result.dropped ?? []) rows.push(row$35("not carried across", "skip", line));
8428
8505
  } catch (err) {
8429
- rows.push(row$31("start date", "fail", `could not update the issue: ${describeError(err)}`));
8506
+ rows.push(row$35("start date", "fail", `could not update the issue: ${describeError(err)}`));
8430
8507
  }
8431
8508
  let dir = root;
8432
8509
  try {
@@ -8455,7 +8532,7 @@ async function runStartWork(input) {
8455
8532
  "--abbrev-ref",
8456
8533
  "HEAD"
8457
8534
  ], root) !== branch && dir === root) io.git(["switch", branch], root);
8458
- rows.push(row$31("branch", "ok", `${branch} already exists; reused`));
8535
+ rows.push(row$35("branch", "ok", `${branch} already exists; reused`));
8459
8536
  } else if (useWorktree) {
8460
8537
  io.git([
8461
8538
  "worktree",
@@ -8467,7 +8544,7 @@ async function runStartWork(input) {
8467
8544
  start
8468
8545
  ], root);
8469
8546
  dir = wtPath;
8470
- rows.push(row$31("branch", "ok", `made ${branch} from ${start}`));
8547
+ rows.push(row$35("branch", "ok", `made ${branch} from ${start}`));
8471
8548
  } else {
8472
8549
  io.git([
8473
8550
  "switch",
@@ -8476,19 +8553,19 @@ async function runStartWork(input) {
8476
8553
  branch,
8477
8554
  start
8478
8555
  ], root);
8479
- rows.push(row$31("branch", "ok", `made ${branch} from ${start} and switched to it`));
8556
+ rows.push(row$35("branch", "ok", `made ${branch} from ${start} and switched to it`));
8480
8557
  }
8481
8558
  report = {
8482
8559
  ...report,
8483
8560
  directory: dir
8484
8561
  };
8485
- if (useWorktree) rows.push(row$31("worktree", "ok", dir));
8562
+ if (useWorktree) rows.push(row$35("worktree", "ok", dir));
8486
8563
  const ahead = Number(git([
8487
8564
  "rev-list",
8488
8565
  "--count",
8489
8566
  `${start}..${branch}`
8490
8567
  ]) || "0");
8491
- if (ahead > 0) rows.push(row$31("first commit", "skip", `${branch} already has ${ahead} commit${ahead === 1 ? "" : "s"}`));
8568
+ if (ahead > 0) rows.push(row$35("first commit", "skip", `${branch} already has ${ahead} commit${ahead === 1 ? "" : "s"}`));
8492
8569
  else {
8493
8570
  const trailer = `Refs ${workReference(key)}`;
8494
8571
  if (spec) {
@@ -8499,7 +8576,7 @@ async function runStartWork(input) {
8499
8576
  spec.rel
8500
8577
  ], dir);
8501
8578
  const status = /^status:\s*(\S+)/m.exec(io.read(spec.abs))?.[1];
8502
- if (status && status !== "draft") rows.push(row$31("spec", "skip", `the spec's status is ${status}, not draft`));
8579
+ if (status && status !== "draft") rows.push(row$35("spec", "skip", `the spec's status is ${status}, not draft`));
8503
8580
  }
8504
8581
  io.git([
8505
8582
  "commit",
@@ -8510,7 +8587,7 @@ async function runStartWork(input) {
8510
8587
  "-m",
8511
8588
  trailer
8512
8589
  ], dir);
8513
- rows.push(row$31("first commit", "ok", `${io.git([
8590
+ rows.push(row$35("first commit", "ok", `${io.git([
8514
8591
  "rev-parse",
8515
8592
  "--short",
8516
8593
  "HEAD"
@@ -8522,9 +8599,9 @@ async function runStartWork(input) {
8522
8599
  "origin",
8523
8600
  branch
8524
8601
  ], dir);
8525
- rows.push(row$31("push", "ok", `${branch} is on origin`));
8602
+ rows.push(row$35("push", "ok", `${branch} is on origin`));
8526
8603
  } catch (err) {
8527
- rows.push(row$31("git", "fail", `${describeError(err)}; nothing was deleted, run the command again to carry on`));
8604
+ rows.push(row$35("git", "fail", `${describeError(err)}; nothing was deleted, run the command again to carry on`));
8528
8605
  return finish();
8529
8606
  }
8530
8607
  if (source) try {
@@ -8540,7 +8617,7 @@ async function runStartWork(input) {
8540
8617
  ...input.templatesIo ? { templatesIo: input.templatesIo } : {}
8541
8618
  });
8542
8619
  issueBoards = read.boards;
8543
- if (read.problem) rows.push(row$31("boards", "skip", `the pull request is not put on the issue's boards: ${read.problem}`));
8620
+ if (read.problem) rows.push(row$35("boards", "skip", `the pull request is not put on the issue's boards: ${read.problem}`));
8544
8621
  }
8545
8622
  const projects = [.../* @__PURE__ */ new Set([...issueBoards, ...input.project ? [input.project] : []])];
8546
8623
  const mirrored = {
@@ -8572,12 +8649,12 @@ async function runStartWork(input) {
8572
8649
  created: result.created
8573
8650
  }
8574
8651
  };
8575
- rows.push(row$31("pull request", "ok", `${result.created ? "opened" : "already open:"} #${pr.number}${result.draft ? " (draft)" : ""} ${pr.url}`));
8576
- for (const line of result.dropped) rows.push(row$31("not carried across", "skip", line));
8652
+ rows.push(row$35("pull request", "ok", `${result.created ? "opened" : "already open:"} #${pr.number}${result.draft ? " (draft)" : ""} ${pr.url}`));
8653
+ for (const line of result.dropped) rows.push(row$35("not carried across", "skip", line));
8577
8654
  } catch (err) {
8578
- rows.push(row$31("pull request", "fail", `could not open the pull request: ${describeError(err)}; run the command again to open it`));
8655
+ rows.push(row$35("pull request", "fail", `could not open the pull request: ${describeError(err)}; run the command again to open it`));
8579
8656
  }
8580
- rows.push(row$31("board status", "skip", "not set: the open pull request moves the issue to In Progress; `update work --status` sets it by hand while the automation is down"));
8657
+ rows.push(row$35("board status", "skip", "not set: the open pull request moves the issue to In Progress; `update work --status` sets it by hand while the automation is down"));
8581
8658
  return finish();
8582
8659
  }
8583
8660
  // src/commands/update-work/guard-work-status/guard-work-status.ts
@@ -8625,7 +8702,7 @@ function guardWorkStatus(status, force) {
8625
8702
  * terminal it refuses). `--dry-run` runs the reads and writes nothing. A run with nothing to change still syncs the
8626
8703
  * area labels.
8627
8704
  */
8628
- const row$30 = (id, status, detail) => ({
8705
+ const row$34 = (id, status, detail) => ({
8629
8706
  id,
8630
8707
  title: id,
8631
8708
  status,
@@ -8659,7 +8736,7 @@ async function runUpdateWork(input) {
8659
8736
  };
8660
8737
  };
8661
8738
  const fail = (id, detail) => {
8662
- rows.push(row$30(id, "fail", detail));
8739
+ rows.push(row$34(id, "fail", detail));
8663
8740
  return finish();
8664
8741
  };
8665
8742
  print(style.header(`Holocron update work${dryRun ? " (dry-run)" : ""}`));
@@ -8748,7 +8825,7 @@ async function runUpdateWork(input) {
8748
8825
  title: `start: ${r.title}`
8749
8826
  });
8750
8827
  if (started.status === "fail") {
8751
- rows.push(row$30("update work", "skip", "start work failed, so nothing after it was run"));
8828
+ rows.push(row$34("update work", "skip", "start work failed, so nothing after it was run"));
8752
8829
  return finish();
8753
8830
  }
8754
8831
  }
@@ -8760,10 +8837,10 @@ async function runUpdateWork(input) {
8760
8837
  } else if (source.listPullRequests) {
8761
8838
  const found = findWorkPullRequests(await source.listPullRequests("open"), key);
8762
8839
  pr = found[0];
8763
- if (found.length > 1) rows.push(row$30("pull request", "skip", `${found.length} open pull requests match ${key}; using #${pr?.number} (--pr names another)`));
8840
+ if (found.length > 1) rows.push(row$34("pull request", "skip", `${found.length} open pull requests match ${key}; using #${pr?.number} (--pr names another)`));
8764
8841
  }
8765
8842
  } catch (err) {
8766
- rows.push(row$30("pull request", "fail", `could not find the pull request: ${describeError(err)}`));
8843
+ rows.push(row$34("pull request", "fail", `could not find the pull request: ${describeError(err)}`));
8767
8844
  return finish();
8768
8845
  }
8769
8846
  if (pr) {
@@ -8774,24 +8851,24 @@ async function runUpdateWork(input) {
8774
8851
  url: pr.url
8775
8852
  }
8776
8853
  };
8777
- rows.push(row$30("pull request", "ok", `#${pr.number} ${pr.title}`));
8854
+ rows.push(row$34("pull request", "ok", `#${pr.number} ${pr.title}`));
8778
8855
  } else {
8779
8856
  const detail = `no open pull request for ${key} (its branch is <type>/<issue>-<slug>; --pr names one, --start makes one)`;
8780
- rows.push(row$30("pull request", title ? "fail" : "skip", title ? `${detail}; --title needs one` : detail));
8857
+ rows.push(row$34("pull request", title ? "fail" : "skip", title ? `${detail}; --title needs one` : detail));
8781
8858
  }
8782
8859
  let derived = [];
8783
- if (!pr) rows.push(row$30("area labels", "skip", "no pull request to read the changed folders of"));
8784
- else if (!areas || Object.keys(areas).length === 0) rows.push(row$30("area labels", "skip", "the repo declares no `repo.labels.areas`"));
8785
- else if (!source.listPullRequestFiles) rows.push(row$30("area labels", "skip", `the \`${source.providerName}\` provider cannot list a pull request's files`));
8860
+ if (!pr) rows.push(row$34("area labels", "skip", "no pull request to read the changed folders of"));
8861
+ else if (!areas || Object.keys(areas).length === 0) rows.push(row$34("area labels", "skip", "the repo declares no `repo.labels.areas`"));
8862
+ else if (!source.listPullRequestFiles) rows.push(row$34("area labels", "skip", `the \`${source.providerName}\` provider cannot list a pull request's files`));
8786
8863
  else try {
8787
8864
  derived = areaLabelsForFiles(await source.listPullRequestFiles(pr.number), areas);
8788
8865
  report = {
8789
8866
  ...report,
8790
8867
  areaLabels: derived
8791
8868
  };
8792
- rows.push(row$30("area labels", derived.length > 0 ? "ok" : "skip", derived.length > 0 ? derived.join(", ") : "the changed folders are in no area"));
8869
+ rows.push(row$34("area labels", derived.length > 0 ? "ok" : "skip", derived.length > 0 ? derived.join(", ") : "the changed folders are in no area"));
8793
8870
  } catch (err) {
8794
- rows.push(row$30("area labels", "fail", `could not read the changed files: ${describeError(err)}`));
8871
+ rows.push(row$34("area labels", "fail", `could not read the changed files: ${describeError(err)}`));
8795
8872
  }
8796
8873
  let missingOnIssue = derived;
8797
8874
  if (derived.length > 0 && issues.export) try {
@@ -8828,7 +8905,7 @@ async function runUpdateWork(input) {
8828
8905
  id: `issue: ${r.id}`,
8829
8906
  title: `issue: ${r.title}`
8830
8907
  });
8831
- } else rows.push(row$30("issue", "skip", "no issue field to change"));
8908
+ } else rows.push(row$34("issue", "skip", "no issue field to change"));
8832
8909
  if (pr) {
8833
8910
  const prLabels = unique([...addLabels, ...derived]);
8834
8911
  const patch = {
@@ -8847,15 +8924,15 @@ async function runUpdateWork(input) {
8847
8924
  ...milestone ? [`milestone ${milestone}`] : [],
8848
8925
  ...input.project ? [`board ${input.project}`] : []
8849
8926
  ];
8850
- if (parts.length === 0) rows.push(row$30(`pull request #${pr.number}`, "skip", "no field to change"));
8851
- else if (!source.updatePullRequest) rows.push(row$30(`pull request #${pr.number}`, "fail", `the \`${source.providerName}\` provider cannot update a pull request`));
8852
- else if (dryRun) rows.push(row$30(`pull request #${pr.number}`, "skip", `would update ${parts.join("; ")}`));
8927
+ if (parts.length === 0) rows.push(row$34(`pull request #${pr.number}`, "skip", "no field to change"));
8928
+ else if (!source.updatePullRequest) rows.push(row$34(`pull request #${pr.number}`, "fail", `the \`${source.providerName}\` provider cannot update a pull request`));
8929
+ else if (dryRun) rows.push(row$34(`pull request #${pr.number}`, "skip", `would update ${parts.join("; ")}`));
8853
8930
  else try {
8854
8931
  const result = await source.updatePullRequest(pr.number, patch);
8855
- rows.push(row$30(`pull request #${pr.number}`, "ok", `updated ${parts.join("; ")}`));
8856
- for (const line of result.dropped) rows.push(row$30("not carried across", "skip", line));
8932
+ rows.push(row$34(`pull request #${pr.number}`, "ok", `updated ${parts.join("; ")}`));
8933
+ for (const line of result.dropped) rows.push(row$34("not carried across", "skip", line));
8857
8934
  } catch (err) {
8858
- rows.push(row$30(`pull request #${pr.number}`, "fail", `could not update the pull request: ${describeError(err)}`));
8935
+ rows.push(row$34(`pull request #${pr.number}`, "fail", `could not update the pull request: ${describeError(err)}`));
8859
8936
  }
8860
8937
  }
8861
8938
  if (status) {
@@ -8871,11 +8948,11 @@ async function runUpdateWork(input) {
8871
8948
  ...input.board ? { board: input.board } : {}
8872
8949
  });
8873
8950
  const change = set.key && set.to ? `${set.key} ${set.from ?? "no status"} → ${set.to}` : `${key} → ${status}`;
8874
- rows.push(set.status === "ok" ? row$30("board status", dryRun ? "skip" : "ok", dryRun ? `would set ${change}` : change) : row$30("board status", "fail", sub.lines.map((l) => l.trim()).filter(Boolean).join("; ") || "could not set the status"));
8951
+ rows.push(set.status === "ok" ? row$34("board status", dryRun ? "skip" : "ok", dryRun ? `would set ${change}` : change) : row$34("board status", "fail", sub.lines.map((l) => l.trim()).filter(Boolean).join("; ") || "could not set the status"));
8875
8952
  } catch (err) {
8876
- rows.push(row$30("board status", "fail", describeError(err)));
8953
+ rows.push(row$34("board status", "fail", describeError(err)));
8877
8954
  }
8878
- rows.push(row$30("board status is temporary", "skip", guard?.ok && guard.forced ? "forced: the automation owns this status and overwrites it once it runs again (#2388)" : "the board's rules overwrite a hand-set status once the pull request moves it (#2388)"));
8955
+ rows.push(row$34("board status is temporary", "skip", guard?.ok && guard.forced ? "forced: the automation owns this status and overwrites it once it runs again (#2388)" : "the board's rules overwrite a hand-set status once the pull request moves it (#2388)"));
8879
8956
  }
8880
8957
  return finish();
8881
8958
  }
@@ -8894,7 +8971,7 @@ function findClosedWorkPullRequests(prs, issue) {
8894
8971
  return [...matching.filter((pr) => pr.merged), ...matching.filter((pr) => !pr.merged)];
8895
8972
  }
8896
8973
  // src/commands/close-work/release-closed-blockers/release-closed-blockers.ts
8897
- const row$29 = (id, status, detail) => ({
8974
+ const row$33 = (id, status, detail) => ({
8898
8975
  id,
8899
8976
  title: id,
8900
8977
  status,
@@ -8908,16 +8985,16 @@ const row$29 = (id, status, detail) => ({
8908
8985
  */
8909
8986
  async function releaseClosedBlockers(input) {
8910
8987
  const { issues, key } = input;
8911
- if (!issues.export) return [row$29("relations", "skip", `the \`${issues.providerName}\` provider cannot read blockers`)];
8988
+ if (!issues.export) return [row$33("relations", "skip", `the \`${issues.providerName}\` provider cannot read blockers`)];
8912
8989
  try {
8913
8990
  const blockers = (await issues.export({ keys: [key] }))[0]?.blockedBy ?? [];
8914
- if (blockers.length === 0) return [row$29("relations", "skip", `${key} has no blockers`)];
8991
+ if (blockers.length === 0) return [row$33("relations", "skip", `${key} has no blockers`)];
8915
8992
  const closed = (await issues.export({ keys: blockers })).filter((r) => r.closed).map((r) => r.key);
8916
- if (closed.length === 0) return [row$29("relations", "skip", `${blockers.length} blocker${blockers.length === 1 ? "" : "s"} still open: ${blockers.join(", ")}`)];
8993
+ if (closed.length === 0) return [row$33("relations", "skip", `${blockers.length} blocker${blockers.length === 1 ? "" : "s"} still open: ${blockers.join(", ")}`)];
8917
8994
  const done = await input.unblock(closed);
8918
- return [row$29("relations", done.status === "fail" ? "fail" : "ok", `closed ${closed.length === 1 ? "blocker" : "blockers"} ${closed.join(", ")} taken off ${key}`), ...done.rows.filter((r) => r.status === "fail")];
8995
+ return [row$33("relations", done.status === "fail" ? "fail" : "ok", `closed ${closed.length === 1 ? "blocker" : "blockers"} ${closed.join(", ")} taken off ${key}`), ...done.rows.filter((r) => r.status === "fail")];
8919
8996
  } catch (err) {
8920
- return [row$29("relations", "fail", `could not update the blockers: ${describeError(err)}`)];
8997
+ return [row$33("relations", "fail", `could not update the blockers: ${describeError(err)}`)];
8921
8998
  }
8922
8999
  }
8923
9000
  // src/commands/close-work/wait-for-checks/wait-for-checks.ts
@@ -9455,7 +9532,7 @@ const DEFAULT_TIMEOUT_MINUTES = 30;
9455
9532
  const DEFAULT_INTERVAL_MS = 3e4;
9456
9533
  /** How many failing checks a row names. */
9457
9534
  const MAX_NAMED$1 = 8;
9458
- const row$28 = (id, status, detail) => ({
9535
+ const row$32 = (id, status, detail) => ({
9459
9536
  id,
9460
9537
  title: id,
9461
9538
  status,
@@ -9480,7 +9557,7 @@ async function runCloseWork(input) {
9480
9557
  };
9481
9558
  };
9482
9559
  const fail = (id, detail) => {
9483
- rows.push(row$28(id, "fail", detail));
9560
+ rows.push(row$32(id, "fail", detail));
9484
9561
  return finish();
9485
9562
  };
9486
9563
  print(style.header(`Holocron close work${input.abandon ? " --abandon" : ""}${dryRun ? " (dry-run)" : ""}`));
@@ -9528,7 +9605,7 @@ async function runCloseWork(input) {
9528
9605
  if (!source.listPullRequests) throw new Error(`the \`${source.providerName}\` provider cannot list pull requests`);
9529
9606
  const open = findWorkPullRequests(await source.listPullRequests("open"), key);
9530
9607
  pr = open[0];
9531
- if (open.length > 1) rows.push(row$28("pull request", "skip", `${open.length} open pull requests match ${key}; using #${pr?.number} (--pr names another)`));
9608
+ if (open.length > 1) rows.push(row$32("pull request", "skip", `${open.length} open pull requests match ${key}; using #${pr?.number} (--pr names another)`));
9532
9609
  if (!pr && !input.abandon) pr = findClosedWorkPullRequests(await source.listPullRequests("closed"), key)[0];
9533
9610
  }
9534
9611
  } catch (err) {
@@ -9566,10 +9643,10 @@ async function runCloseWork(input) {
9566
9643
  const repoRoot = input.context.repoRoot;
9567
9644
  if (pr.state === "closed") {
9568
9645
  if (!pr.merged) {
9569
- rows.push(row$28("pull request", "skip", `#${pr.number} was closed without merging; \`close work ${key} --abandon\` tidies its branch and spec`));
9646
+ rows.push(row$32("pull request", "skip", `#${pr.number} was closed without merging; \`close work ${key} --abandon\` tidies its branch and spec`));
9570
9647
  return finish();
9571
9648
  }
9572
- rows.push(row$28("pull request", "ok", `#${pr.number} merged: ${pr.title}`));
9649
+ rows.push(row$32("pull request", "ok", `#${pr.number} merged: ${pr.title}`));
9573
9650
  if (!dryRun && !input.yes && !await ask(`Remove the worktree and local branch of ${pr.branch}?`)) {
9574
9651
  print(` ${style.skip("cancelled; nothing was changed")}`);
9575
9652
  return {
@@ -9588,7 +9665,7 @@ async function runCloseWork(input) {
9588
9665
  }));
9589
9666
  return finish();
9590
9667
  }
9591
- rows.push(row$28("pull request", "ok", `#${pr.number} ${pr.title}`));
9668
+ rows.push(row$32("pull request", "ok", `#${pr.number} ${pr.title}`));
9592
9669
  if (!source.getPullRequestChecks) return fail("ci / Required checks", `the \`${source.providerName}\` provider cannot read a pull request's checks`);
9593
9670
  const readChecks = source.getPullRequestChecks.bind(source);
9594
9671
  const number = pr.number;
@@ -9614,7 +9691,7 @@ async function runCloseWork(input) {
9614
9691
  const named = failing.length > 0 ? `: ${failing.join(", ")}${more > 0 ? `, and ${more} more` : ""}` : "";
9615
9692
  return fail("ci / Required checks", `${checks.state === "failure" ? `is red${named}` : result.timedOut ? `is still ${checks.state} after ${minutes} minute${minutes === 1 ? "" : "s"}` : `is ${checks.state === "none" ? "not posted yet" : "still running"}; --wait polls until it is green`}. #${number} was not marked ready; run \`close work ${key}\` again once it is green`);
9616
9693
  }
9617
- rows.push(row$28("ci / Required checks", "ok", `green${checks.sha ? ` on ${checks.sha.slice(0, 7)}` : ""}`));
9694
+ rows.push(row$32("ci / Required checks", "ok", `green${checks.sha ? ` on ${checks.sha.slice(0, 7)}` : ""}`));
9618
9695
  if (!dryRun && !input.yes) {
9619
9696
  if (!await ask(`${key} is green. ${`Mark #${number} ready, update the area labels and take closed blockers off ${key}`}?`)) {
9620
9697
  print(` ${style.skip("cancelled; nothing was changed")}`);
@@ -9624,13 +9701,13 @@ async function runCloseWork(input) {
9624
9701
  };
9625
9702
  }
9626
9703
  }
9627
- if (!source.markReady) rows.push(row$28("ready", "fail", `the \`${source.providerName}\` provider cannot mark a pull request ready`));
9628
- else if (dryRun) rows.push(row$28("ready", "skip", `would mark #${number} ready if it is a draft`));
9704
+ if (!source.markReady) rows.push(row$32("ready", "fail", `the \`${source.providerName}\` provider cannot mark a pull request ready`));
9705
+ else if (dryRun) rows.push(row$32("ready", "skip", `would mark #${number} ready if it is a draft`));
9629
9706
  else try {
9630
9707
  const changed = await source.markReady(number);
9631
- rows.push(row$28("ready", "ok", changed ? `#${number} is ready for review; the board moves to In Review by itself. The maintainer merges, \`close work ${key}\` again after that clears the checkout` : `#${number} was already ready; the maintainer merges`));
9708
+ rows.push(row$32("ready", "ok", changed ? `#${number} is ready for review; the board moves to In Review by itself. The maintainer merges, \`close work ${key}\` again after that clears the checkout` : `#${number} was already ready; the maintainer merges`));
9632
9709
  } catch (err) {
9633
- rows.push(row$28("ready", "fail", `could not mark #${number} ready: ${describeError(err)}`));
9710
+ rows.push(row$32("ready", "fail", `could not mark #${number} ready: ${describeError(err)}`));
9634
9711
  }
9635
9712
  try {
9636
9713
  const updated = await (input.updateWork ?? runUpdateWork)({
@@ -9648,7 +9725,7 @@ async function runCloseWork(input) {
9648
9725
  title: `labels: ${r.title}`
9649
9726
  });
9650
9727
  } catch (err) {
9651
- rows.push(row$28("labels", "fail", `could not update the area labels: ${describeError(err)}`));
9728
+ rows.push(row$32("labels", "fail", `could not update the area labels: ${describeError(err)}`));
9652
9729
  }
9653
9730
  rows.push(...await releaseClosedBlockers({
9654
9731
  issues,
@@ -11259,7 +11336,7 @@ function installationSettingsUrl(account, id) {
11259
11336
  return `https://github.com/settings/installations/${id}`;
11260
11337
  }
11261
11338
  // src/commands/doctor-github-app/app-rows.ts
11262
- const row$27 = (name, what, problems, ok) => ({
11339
+ const row$31 = (name, what, problems, ok) => ({
11263
11340
  id: `${name}:${what}`,
11264
11341
  title: `${name}: ${what}`,
11265
11342
  status: problems.length > 0 ? "fail" : "ok",
@@ -11304,9 +11381,9 @@ function appRows(name, manifest, app, installations) {
11304
11381
  return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
11305
11382
  });
11306
11383
  return [
11307
- row$27(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
11308
- row$27(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
11309
- row$27(name, "installations", installationProblems, `${installations.length} installation(s) up to date`),
11384
+ row$31(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
11385
+ row$31(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
11386
+ row$31(name, "installations", installationProblems, `${installations.length} installation(s) up to date`),
11310
11387
  statusRow(name, installations)
11311
11388
  ];
11312
11389
  }
@@ -11472,7 +11549,7 @@ async function runDoctorGitHubApp(input) {
11472
11549
  assertPluginsResolvable(loader, "doctor github-app");
11473
11550
  }
11474
11551
  const rows = [];
11475
- if (instances.length === 0) rows.push(row$26("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
11552
+ if (instances.length === 0) rows.push(row$30("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
11476
11553
  const checked = [];
11477
11554
  for (const instance of instances) {
11478
11555
  const instanceRows = await checkInstance(instance, loader, input);
@@ -11519,7 +11596,7 @@ function printGrouped(checked, print) {
11519
11596
  }
11520
11597
  }
11521
11598
  }
11522
- function row$26(name, what, status, detail) {
11599
+ function row$30(name, what, status, detail) {
11523
11600
  return {
11524
11601
  id: `${name}:${what}`,
11525
11602
  title: `${name}: ${what}`,
@@ -11535,10 +11612,10 @@ async function checkInstance(instance, loader, input) {
11535
11612
  try {
11536
11613
  manifest = parseManifest(readManifest(instance.manifest));
11537
11614
  } catch (err) {
11538
- return [row$26(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
11615
+ return [row$30(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
11539
11616
  }
11540
11617
  const read = await readAppCredentials(instance, loader);
11541
- if ("reason" in read) return [row$26(name, "reachable", "skip", read.reason)];
11618
+ if ("reason" in read) return [row$30(name, "reachable", "skip", read.reason)];
11542
11619
  const api = input.api ?? defaultApi$1;
11543
11620
  const secrets = [read.creds.privateKey];
11544
11621
  try {
@@ -11546,12 +11623,12 @@ async function checkInstance(instance, loader, input) {
11546
11623
  const installations = await api.listAppInstallations(read.creds);
11547
11624
  const owner = app.owner ? `, owned by ${app.owner.login}` : "";
11548
11625
  return [
11549
- row$26(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`),
11626
+ row$30(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`),
11550
11627
  ...appRows(name, manifest, app, installations),
11551
11628
  await deliveryRow(name, read.creds, api, (input.now ?? Date.now)(), secrets)
11552
11629
  ];
11553
11630
  } catch (err) {
11554
- return [row$26(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
11631
+ return [row$30(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
11555
11632
  }
11556
11633
  }
11557
11634
  // src/commands/doctor-github-app/doctor-github-app.command.ts
@@ -11996,6 +12073,613 @@ const devCommand = {
11996
12073
  })).status === "fail") process.exitCode = 1;
11997
12074
  }
11998
12075
  };
12076
+ // src/commands/token-rotation/token-rotation.ts
12077
+ /** The rotation policy of a token that declares none: a token is due after 90 days, and an expiry is flagged 14 days ahead. */
12078
+ const DEFAULT_TOKEN_ROTATION = {
12079
+ maxAgeDays: 90,
12080
+ warnDays: 14
12081
+ };
12082
+ /**
12083
+ * The labels of the rows that fail for a token that is due (`expired on ...`, `expires on ... (N days left)` inside the
12084
+ * warning window, `N days old`): what `rotate tokens` looks for in a `doctor tokens` problem to tell a token that is due
12085
+ * from one that only lacks a permission.
12086
+ */
12087
+ const ROTATION_LABELS = ["expiry", "age"];
12088
+ // src/commands/token-expectations/token-expectations.ts
12089
+ /**
12090
+ * Reads what a plugin's tokens declare (`PluginToken.expect`) as one entry per token and layer that holds it, in the
12091
+ * order of `ENVIRONMENT_LAYERS`. The one reader the token probes, the doctor and the docs check share, so none of them
12092
+ * walks the declaration itself. A token with no `expect` yields nothing; a layer no token holds is never listed.
12093
+ */
12094
+ function tokenExpectations(tokens, filter = {}) {
12095
+ const found = [];
12096
+ for (const token of tokens) {
12097
+ if (!token.expect || filter.envName !== void 0 && token.envName !== filter.envName) continue;
12098
+ const { layers = [], permissions = {} } = token.expect;
12099
+ for (const layer of ENVIRONMENT_LAYERS) {
12100
+ if (filter.layer !== void 0 && filter.layer !== layer) continue;
12101
+ const rules = permissions[layer];
12102
+ if (!rules && !layers.includes(layer)) continue;
12103
+ const entries = Object.entries(rules ?? {});
12104
+ found.push({
12105
+ envName: token.envName,
12106
+ layer,
12107
+ rules: rules ?? {},
12108
+ required: entries.filter(([, rule]) => rule === "required").map(([name]) => name),
12109
+ absent: entries.filter(([, rule]) => rule === "absent").map(([name]) => name),
12110
+ rotation: {
12111
+ ...DEFAULT_TOKEN_ROTATION,
12112
+ ...token.expect.rotation
12113
+ }
12114
+ });
12115
+ }
12116
+ }
12117
+ return found;
12118
+ }
12119
+ // src/commands/instance-token-guide/instance-token-guide.ts
12120
+ /**
12121
+ * For each name only a person can make, where to make it and what it needs: the plugin's own declaration of the token
12122
+ * (`PluginToken`: the vendor page, and the permissions its layer's token must and must not carry, read through
12123
+ * `tokenExpectations()`). A layer a token has no rules for yet (`preview` is new) reads `prod`'s, and `from` says so. A
12124
+ * name no plugin declares is listed with nothing more, because inventing a vendor page would be worse than none.
12125
+ *
12126
+ * @param names - The `person` names of `instanceInputs()`.
12127
+ * @param tokens - Every token the loaded plugins declare.
12128
+ * @param layer - The instance's layer (`preview`).
12129
+ */
12130
+ function instanceTokenGuide(names, tokens, layer) {
12131
+ return names.map((name) => {
12132
+ const token = tokens.find((candidate) => candidate.envName === name || candidate.vendorEnvName === name);
12133
+ if (!token) return {
12134
+ name,
12135
+ declared: false,
12136
+ required: [],
12137
+ absent: []
12138
+ };
12139
+ const rules = tokenExpectations([token]);
12140
+ const own = rules.find((rule) => rule.layer === layer) ?? rules.find((rule) => rule.layer === "prod");
12141
+ return {
12142
+ name,
12143
+ declared: true,
12144
+ ...token.page ? { page: token.page } : {},
12145
+ required: own ? [...own.required] : [],
12146
+ absent: own ? [...own.absent] : [],
12147
+ ...own ? { from: own.layer } : {}
12148
+ };
12149
+ });
12150
+ }
12151
+ // src/commands/new-instance/token-problem/token-problem.ts
12152
+ /**
12153
+ * One line a person can act on for a token they have to make: the variable, where it is made, what it must have and what
12154
+ * it must not, and which layer's rules those are. A token no plugin declares says so, because nothing more is known.
12155
+ * Names and addresses only.
12156
+ */
12157
+ function tokenProblem(guide) {
12158
+ if (!guide.declared) return `${guide.name}: no plugin declares it, so make it where it comes from`;
12159
+ const where = guide.page ? `make it at ${guide.page}` : "its plugin names no page to make it at";
12160
+ const needs = guide.required.length > 0 ? `; it needs ${guide.required.join(", ")}` : "";
12161
+ const avoids = guide.absent.length > 0 ? `; it must not have ${guide.absent.join(", ")}` : "";
12162
+ const from = guide.from ? ` (the ${guide.from} layer's rules)` : "";
12163
+ return `${guide.name}: ${where}${needs}${avoids}${from}`;
12164
+ }
12165
+ // src/commands/start-agent/agent-token-file/agent-token-file.ts
12166
+ /** Where the Service Account's token is kept when `HOLOCRON_AGENT_TOKEN_FILE` does not say, under the home directory. */
12167
+ const DEFAULT_PATH = join(".config", "holocron", "agent.token");
12168
+ /**
12169
+ * The path of the agent's Service Account token file: `HOLOCRON_AGENT_TOKEN_FILE` when it is set, else
12170
+ * `~/.config/holocron/agent.token` (spec `tech-agent-secrets`). A path outside every repository, so git never sees it.
12171
+ *
12172
+ * @param env - The process environment.
12173
+ * @param home - The user's home directory.
12174
+ */
12175
+ function agentTokenPath(env, home) {
12176
+ const named = env["HOLOCRON_AGENT_TOKEN_FILE"];
12177
+ return named !== void 0 && named !== "" ? named : join(home, DEFAULT_PATH);
12178
+ }
12179
+ /** Whether anyone but the owner may read, write or run it. */
12180
+ function openToOthers(mode) {
12181
+ return (mode & 63) !== 0;
12182
+ }
12183
+ function octal(mode) {
12184
+ return (mode & 511).toString(8).padStart(3, "0");
12185
+ }
12186
+ /**
12187
+ * Reads the Service Account's token from its file, after refusing a file anyone else could read or have written: it must
12188
+ * be the file itself (no link), owned by the running user, mode 0600, in a directory only that user may use. The token is
12189
+ * the one secret that cannot be in 1Password, so the file is held to the protections of the other hand-offs and nothing
12190
+ * here prints, logs or returns it except in the `ok` result the caller hands straight to the one read that needs it. The
12191
+ * reasons name paths and modes, never the token.
12192
+ *
12193
+ * @param path - From {@link agentTokenPath}.
12194
+ * @param fs - The file system and the user, replaceable in a test.
12195
+ */
12196
+ function readAgentToken(path, fs) {
12197
+ const fail = (reason) => ({
12198
+ status: "fail",
12199
+ path,
12200
+ reason
12201
+ });
12202
+ if (fs.platform === "win32") return fail("cannot make a file private on Windows: its mode bits are not enforced");
12203
+ const file = fs.lstat(path);
12204
+ if (!file) return {
12205
+ status: "fail",
12206
+ path,
12207
+ reason: `no token file at ${path}: make the Service Account's token and save it there (mode 0600), or set HOLOCRON_AGENT_TOKEN_FILE`,
12208
+ missing: true
12209
+ };
12210
+ if (file.isSymbolicLink()) return fail("it is a link: it must be the file itself, so nothing can swap what it points at");
12211
+ if (!file.isFile()) return fail("it is not a regular file");
12212
+ if (fs.uid !== void 0 && file.uid !== fs.uid) return fail("it is not owned by the user running this command");
12213
+ if (openToOthers(file.mode)) return fail(`its mode is ${octal(file.mode)}: it must be 600, with no access for the group or anyone else`);
12214
+ const directory = fs.lstat(dirname(path));
12215
+ if (!directory || !directory.isDirectory()) return fail("its directory is not a directory");
12216
+ if (fs.uid !== void 0 && directory.uid !== fs.uid) return fail("its directory is not owned by the user running this command");
12217
+ if (openToOthers(directory.mode)) return fail(`its directory's mode is ${octal(directory.mode)}: it must be 700, so no one else can replace the file`);
12218
+ const token = fs.readFile(path).trim();
12219
+ if (token === "") return fail("it is empty");
12220
+ return {
12221
+ status: "ok",
12222
+ path,
12223
+ token
12224
+ };
12225
+ }
12226
+ // src/commands/probe/probe-token/choose-token.ts
12227
+ /**
12228
+ * Asks which token a probe that accepts one should check: the configured one, one from an Environment, or one typed in
12229
+ * (hidden as it is typed). Only called on a terminal when neither `--token` nor `--environment` was given.
12230
+ */
12231
+ async function chooseToken(provider) {
12232
+ const how = await select({
12233
+ message: `Which ${provider} token should it check?`,
12234
+ choices: [
12235
+ {
12236
+ name: "The one this repo is configured to use",
12237
+ value: "configured"
12238
+ },
12239
+ {
12240
+ name: "One from a vault Environment (a layer such as ci or dev, or a name)",
12241
+ value: "environment"
12242
+ },
12243
+ {
12244
+ name: "Type or paste a token",
12245
+ value: "paste"
12246
+ }
12247
+ ]
12248
+ });
12249
+ if (how === "environment") return { environment: (await input({
12250
+ message: "Environment (layer or name):",
12251
+ default: "ci"
12252
+ })).trim() };
12253
+ if (how === "paste") return { token: (await password({
12254
+ message: `${provider} token:`,
12255
+ mask: "*"
12256
+ })).trim() };
12257
+ }
12258
+ // src/commands/probe/probe-token/default-provider-tokens.ts
12259
+ /**
12260
+ * Reads the tokens a provider's plugin lists (its module-level `tokens`), resolving the plugin package from the
12261
+ * directory of the config that was loaded so a `--cwd` run finds the plugins installed there.
12262
+ */
12263
+ function defaultProviderTokens(loaded, importer = createDefaultImporter(dirname(loaded.filepath))) {
12264
+ return async (provider) => (await importer(resolvePluginPackage(provider))).tokens ?? [];
12265
+ }
12266
+ // src/commands/secrets-sync/resolve-environment-id/resolve-environment-id.ts
12267
+ /**
12268
+ * The vault Environment `holocron sync secrets --env <environment>` reads. A layer word (`local`, `dev`, `ci`, `prod`) is the
12269
+ * Environment of that layer of this repository, `<org/repo> - <layer>`; any other text is a literal Environment name.
12270
+ * A literal name wins only when it is not exactly a layer word, so an Environment that is itself called `prod` cannot be
12271
+ * addressed by that name (spec `tech-environment-layers`, #2069).
12272
+ *
12273
+ * @param id - The `--env` value the user gave.
12274
+ * @param input - Where the repository is (its `origin` remote is read there), and optionally how to read it.
12275
+ * @throws {ConfigError} For a layer word when the remote cannot be read (the message names the `environment` option).
12276
+ */
12277
+ async function resolveEnvironmentId(id, input) {
12278
+ if (!isEnvironmentLayer(id)) return id;
12279
+ return layerEnvironment(await repoSlug(input.repoRoot, input.gitExec), id);
12280
+ }
12281
+ // src/commands/probe/probe-token/holds-no-token-error.ts
12282
+ /** An Environment that holds none of the tokens a plugin lists. Its message names the variables looked for, never a value. */
12283
+ var HoldsNoTokenError = class extends Error {
12284
+ name = "HoldsNoTokenError";
12285
+ };
12286
+ // src/commands/probe/probe-token/environment-tokens.ts
12287
+ /**
12288
+ * Every token the provider declares that one vault Environment holds, read in memory. Only an Environment this repo uses is
12289
+ * read: a layer word (`local`, `dev`, `ci`, `prod`) is this repo's `<org/repo> - <layer>`, and any other text must be a
12290
+ * name the config already names (`configured`), so a probe cannot be pointed at an Environment the repo has nothing to
12291
+ * do with. `local` reads the way the CLI does, `- local` over `- dev`, and `- local` may be absent.
12292
+ *
12293
+ * Each token the provider's plugin lists is looked for under its own variable (`HOLOCRON_SENTRY_TOKEN`), then the
12294
+ * vendor's (`vendorEnvName`); the first that holds a value is that token's. A token the Environment does not hold is in
12295
+ * `missing`, so the caller can report it by name. The Environment's other visible (not concealed) values come back as
12296
+ * `plain`, for the plugin's own settings (a dataset, an account id); a vault that cannot say which are visible gives none.
12297
+ *
12298
+ * @throws {Error} When the name is not one of this repo's, no vault that reads an Environment is configured, the plugin
12299
+ * lists no token, or the Environment holds none of them.
12300
+ */
12301
+ async function environmentTokens(input) {
12302
+ if (!isEnvironmentLayer(input.environment) && !input.configured.includes(input.environment)) {
12303
+ const known = [...ENVIRONMENT_LAYERS, ...input.configured];
12304
+ throw new Error(`${input.environment} is not an Environment this repo's config names; use one of: ${known.join(", ")}`);
12305
+ }
12306
+ const read = input.vault?.readEnvironment?.bind(input.vault);
12307
+ if (!read) throw new Error("--environment needs a vault provider that can read an Environment (1Password); none is configured");
12308
+ const at = {
12309
+ repoRoot: input.repoRoot,
12310
+ gitExec: input.gitExec
12311
+ };
12312
+ const environment = await resolveEnvironmentId(input.environment, at);
12313
+ const readEntries = input.vault?.readEnvironmentEntries?.bind(input.vault);
12314
+ const readOne = async (id) => {
12315
+ if (!readEntries) return {
12316
+ values: await read(id),
12317
+ plain: {}
12318
+ };
12319
+ const entries = await readEntries(id);
12320
+ return {
12321
+ values: Object.fromEntries(entries.map((e) => [e.name, e.value])),
12322
+ plain: Object.fromEntries(entries.filter((e) => !e.concealed).map((e) => [e.name, e.value]))
12323
+ };
12324
+ };
12325
+ let values;
12326
+ let plain;
12327
+ if (input.environment === "local") {
12328
+ const dev = await readOne(await resolveEnvironmentId("dev", at));
12329
+ const local = await readOne(environment).catch(() => ({
12330
+ values: {},
12331
+ plain: {}
12332
+ }));
12333
+ values = {
12334
+ ...dev.values,
12335
+ ...local.values
12336
+ };
12337
+ plain = {
12338
+ ...dev.plain,
12339
+ ...local.plain
12340
+ };
12341
+ } else ({values, plain} = await readOne(environment));
12342
+ if (input.tokens.length === 0) throw new Error(`the ${input.provider} plugin lists no token to look for`);
12343
+ const held = [];
12344
+ const missing = [];
12345
+ for (const declared of input.tokens) {
12346
+ const variable = [declared.envName, ...declared.vendorEnvName ? [declared.vendorEnvName] : []].find((v) => values[v]);
12347
+ if (variable) held.push({
12348
+ token: values[variable],
12349
+ variable,
12350
+ envName: declared.envName
12351
+ });
12352
+ else missing.push(declared.envName);
12353
+ }
12354
+ if (held.length === 0) throw new HoldsNoTokenError(`${environment} holds none of ${input.tokens.flatMap((t) => [t.envName, ...t.vendorEnvName ? [t.vendorEnvName] : []]).join(", ")}`);
12355
+ for (const declared of input.tokens) {
12356
+ delete plain[declared.envName];
12357
+ if (declared.vendorEnvName) delete plain[declared.vendorEnvName];
12358
+ }
12359
+ return {
12360
+ environment,
12361
+ held,
12362
+ missing,
12363
+ plain
12364
+ };
12365
+ }
12366
+ // src/commands/probe/probe-token/with-environment-values/with-environment-values.ts
12367
+ /**
12368
+ * Runs `run` with `values` set in `process.env`, then puts every name back as it was (set again, or removed), even when
12369
+ * `run` throws. It is how a probe that reads another Environment sees that Environment's plain values ahead of the
12370
+ * machine's own: a plugin reads them through the usual chain, which looks at the process environment first, and the
12371
+ * overlay lives only for the one run. Nothing is written anywhere and the values are never printed.
12372
+ *
12373
+ * @param values - The variables to set for the run; none means `run` is called as it is.
12374
+ * @param run - The work that should see them.
12375
+ * @returns What `run` returns.
12376
+ */
12377
+ async function withEnvironmentValues(values, run) {
12378
+ const names = Object.keys(values ?? {});
12379
+ if (!values || names.length === 0) return run();
12380
+ const before = new Map(names.map((name) => [name, process.env[name]]));
12381
+ for (const name of names) process.env[name] = values[name];
12382
+ try {
12383
+ return await run();
12384
+ } finally {
12385
+ for (const [name, previous] of before) if (previous === void 0) delete process.env[name];
12386
+ else process.env[name] = previous;
12387
+ }
12388
+ }
12389
+ // src/commands/provider-tuples/provider-tuples.ts
12390
+ /** The providers a config names, in the order it names them: one tuple per capability entry, so a provider named twice appears twice. */
12391
+ function providerTuples(providers) {
12392
+ return Object.values(providers).flatMap((entry) => entry.cardinality === "single" ? [entry.tuple] : entry.tuples);
12393
+ }
12394
+ // src/commands/start-agent/read-agent-entries/read-agent-entries.ts
12395
+ /** The variables set for one read and put back after it. */
12396
+ const SET_FOR_THE_READ = [
12397
+ "OP_SERVICE_ACCOUNT_TOKEN",
12398
+ "HOLOCRON_ENVIRONMENT",
12399
+ "ENVIRONMENT"
12400
+ ];
12401
+ /**
12402
+ * Reads the `agent` Environment's entries, in memory, with the Service Account's token (spec `tech-agent-secrets`).
12403
+ *
12404
+ * `OP_SERVICE_ACCOUNT_TOKEN` is in the process environment only while this runs, which is how the `op` the vault plugin
12405
+ * starts finds it (never an argument), and `HOLOCRON_ENVIRONMENT=agent` is set with it so the credentials chain this
12406
+ * process loads reads `- agent` and nothing of a person's. Both are put back, or removed, in a `finally`, so a throw
12407
+ * cannot leave the token behind, and the agent's process is started afterwards with an environment built apart from this
12408
+ * one. Nothing read is printed or logged.
12409
+ *
12410
+ * @param input - The Environment, the token and where the command ran.
12411
+ * @param deps - The process environment, the config and the plugin loader, replaceable in a test.
12412
+ * @returns The entries, each with whether the vault says its value is concealed.
12413
+ * @throws {Error} When no `vault` provider can list an Environment, or when the read itself does not work.
12414
+ */
12415
+ async function readAgentEntries(input, deps) {
12416
+ const before = Object.fromEntries(SET_FOR_THE_READ.map((name) => [name, deps.env[name]]));
12417
+ deps.env["OP_SERVICE_ACCOUNT_TOKEN"] = input.token;
12418
+ deps.env["HOLOCRON_ENVIRONMENT"] = "agent";
12419
+ deps.env["ENVIRONMENT"] = "agent";
12420
+ try {
12421
+ const loaded = await deps.loadConfig(input.cwd);
12422
+ deps.applyResolvedConfig({ ...input.org ? { org: input.org } : {} }, loaded.resolved);
12423
+ const loader = deps.makeLoader(loaded.resolved, {
12424
+ repoRoot: input.cwd,
12425
+ dryRun: false,
12426
+ ...input.tokens,
12427
+ ...input.org ? { org: input.org } : {}
12428
+ });
12429
+ await loader.load();
12430
+ const vault = loader.has("vault") ? loader.get("vault") : void 0;
12431
+ if (!vault) throw new Error("no `vault` provider is configured, so there is nothing to read the agent Environment with");
12432
+ if (!vault.readEnvironmentEntries) throw new Error(`the \`${vault.providerName}\` vault cannot list an Environment's entries`);
12433
+ return await vault.readEnvironmentEntries(input.environment);
12434
+ } finally {
12435
+ for (const name of SET_FOR_THE_READ) {
12436
+ const value = before[name];
12437
+ if (value === void 0) delete deps.env[name];
12438
+ else deps.env[name] = value;
12439
+ }
12440
+ }
12441
+ }
12442
+ // src/commands/start-agent/spawn-foreground/spawn-foreground.ts
12443
+ /** The signals a person sends the terminal's foreground program: the agent gets them too, so Ctrl-C stops it. */
12444
+ const FORWARDED = [
12445
+ "SIGINT",
12446
+ "SIGTERM",
12447
+ "SIGHUP"
12448
+ ];
12449
+ /**
12450
+ * Runs a program in the foreground with exactly the environment it is given (not this process's), shares the terminal,
12451
+ * passes `SIGINT`, `SIGTERM` and `SIGHUP` on to it, and resolves with how it ended: its exit code, or 128 plus the
12452
+ * signal's number when a signal ended it, the way a shell reports it.
12453
+ *
12454
+ * @param command - The program.
12455
+ * @param args - Its arguments.
12456
+ * @param env - Its whole environment.
12457
+ * @returns The exit code.
12458
+ * @throws {Error} When the program cannot be started (not found, not executable).
12459
+ */
12460
+ function spawnForeground(command, args, env) {
12461
+ return new Promise((resolve, reject) => {
12462
+ const child = spawn(command, [...args], {
12463
+ stdio: "inherit",
12464
+ env
12465
+ });
12466
+ const handlers = FORWARDED.map((signal) => [signal, () => child.kill(signal)]);
12467
+ for (const [signal, handler] of handlers) process.on(signal, handler);
12468
+ const stopForwarding = () => {
12469
+ for (const [signal, handler] of handlers) process.off(signal, handler);
12470
+ };
12471
+ child.on("error", (err) => {
12472
+ stopForwarding();
12473
+ reject(err);
12474
+ });
12475
+ child.on("close", (code, signal) => {
12476
+ stopForwarding();
12477
+ resolve(code !== null ? code : 128 + constants.signals[signal]);
12478
+ });
12479
+ });
12480
+ }
12481
+ // src/commands/start-agent/start-agent-ports/start-agent-ports.ts
12482
+ /** The real file system. A path that cannot be examined (missing, or no right to look) is treated as not there. */
12483
+ function realFs() {
12484
+ return {
12485
+ platform: process.platform,
12486
+ uid: process.getuid?.(),
12487
+ lstat: (path) => {
12488
+ try {
12489
+ return lstatSync(path);
12490
+ } catch {
12491
+ return;
12492
+ }
12493
+ },
12494
+ readFile: (path) => readFileSync(path, "utf8")
12495
+ };
12496
+ }
12497
+ /** The real config, plugin loader and process environment the read of the `agent` Environment runs over. */
12498
+ function realReadDeps(env) {
12499
+ return {
12500
+ env,
12501
+ loadConfig,
12502
+ applyResolvedConfig,
12503
+ makeLoader: (resolved, context) => new PluginLoader(resolved, context)
12504
+ };
12505
+ }
12506
+ /**
12507
+ * The real ports of `holocron start agent` (spec `tech-agent-secrets`): this machine's file system, environment and home
12508
+ * directory, the repository's own `agent` Environment name, the vault read, and the foreground start.
12509
+ *
12510
+ * @param context - Where the command ran, and the `--token` and `--org` values.
12511
+ * @param machine - Parts of the machine to replace, for a test.
12512
+ */
12513
+ function createStartAgentPorts(context, machine = {}) {
12514
+ const env = machine.env ?? process.env;
12515
+ const environmentFor = machine.environmentFor ?? ((layer, cwd) => resolveEnvironmentId(layer, { repoRoot: cwd }));
12516
+ return {
12517
+ env,
12518
+ home: machine.home ?? homedir(),
12519
+ fs: machine.fs ?? realFs(),
12520
+ environmentName: () => environmentFor("agent", context.cwd),
12521
+ readEntries: (environment, token) => readAgentEntries({
12522
+ environment,
12523
+ token,
12524
+ cwd: context.cwd,
12525
+ ...context.org ? { org: context.org } : {},
12526
+ tokens: context.tokens
12527
+ }, machine.readDeps ?? realReadDeps(env)),
12528
+ spawn: spawnForeground
12529
+ };
12530
+ }
12531
+ // src/commands/doctor-agent/doctor-agent-ports/doctor-agent-ports.ts
12532
+ /** Whether `op` runs here. The real check; a test supplies its own. */
12533
+ function opRuns() {
12534
+ const result = spawnSync("op", ["--version"], { stdio: "ignore" });
12535
+ return !result.error && result.status === 0;
12536
+ }
12537
+ /**
12538
+ * The real ports of `holocron doctor agent`: the launcher's own (the file system, the home directory, the `agent`
12539
+ * Environment's name and the read with the Service Account's token, from `createStartAgentPorts()`), whether `op` runs,
12540
+ * and every token the configured plugins declare.
12541
+ *
12542
+ * @param input - The loaded config and the context the command ran with.
12543
+ */
12544
+ function createDoctorAgentPorts(input) {
12545
+ const { context, loaded } = input;
12546
+ const { env, home, fs, environmentName, readEntries } = createStartAgentPorts({
12547
+ cwd: context.repoRoot,
12548
+ tokens: {
12549
+ ...context.cliToken ? { cliToken: context.cliToken } : {},
12550
+ ...context.cliTokens ? { cliTokens: context.cliTokens } : {}
12551
+ },
12552
+ ...context.org ? { org: context.org } : {}
12553
+ });
12554
+ const tokensOf = defaultProviderTokens(loaded);
12555
+ return {
12556
+ env,
12557
+ home,
12558
+ fs,
12559
+ environmentName,
12560
+ readEntries,
12561
+ opInstalled: opRuns,
12562
+ declaredTokens: async () => {
12563
+ const providers = [...new Set(providerTuples(loaded.resolved.providers).map((tuple) => tuple.provider))];
12564
+ return (await Promise.all(providers.map((provider) => tokensOf(provider).catch(() => [])))).flat();
12565
+ }
12566
+ };
12567
+ }
12568
+ // src/commands/doctor-agent/doctor-agent.ts
12569
+ const row$29 = (id, title, status, detail, problems = []) => ({
12570
+ id,
12571
+ title,
12572
+ status,
12573
+ detail,
12574
+ problems
12575
+ });
12576
+ /**
12577
+ * `holocron doctor agent` (spec `tech-agent-secrets`): is the agent setup safe and complete? Read-only; it makes and
12578
+ * changes nothing, and prints names, modes and counts, never a value.
12579
+ *
12580
+ * It checks, in order: the Service Account's token file (private, the user's, in a private directory; a file that is not
12581
+ * there is a skip, because a machine with no agent is not broken); that `op` is installed; that the token reads the `agent`
12582
+ * Environment; that it **cannot** read any other layer's Environment (the check that the account is as narrow as it is meant
12583
+ * to be: a read that works is a failure naming the Environment); and which agent tokens the plugins declare that the
12584
+ * Environment does not hold yet, with where each is made and what it needs, so the list of tokens to create is always
12585
+ * current. A step that depends on an earlier one that did not work is not run.
12586
+ *
12587
+ * @param input - The loaded config, the context and, in a test, the ports.
12588
+ */
12589
+ async function runDoctorAgent(input) {
12590
+ const print = input.print ?? ((line) => console.log(line));
12591
+ const logger = input.logger ?? getLogger();
12592
+ const ports = input.ports ?? createDoctorAgentPorts(input);
12593
+ const rows = [];
12594
+ const finish = () => {
12595
+ printCheckRows(rows, print);
12596
+ const summary = summariseChecks(rows);
12597
+ printCheckSummary(summary, print);
12598
+ const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
12599
+ const first = rows.find((r) => r.status === "skip");
12600
+ logger.info({
12601
+ ...summary,
12602
+ status
12603
+ }, "doctor agent");
12604
+ return {
12605
+ status,
12606
+ rows,
12607
+ summary,
12608
+ ...status === "skip" && first ? { reason: first.detail } : {}
12609
+ };
12610
+ };
12611
+ const path = agentTokenPath(ports.env, ports.home);
12612
+ const file = readAgentToken(path, ports.fs);
12613
+ if (file.status === "fail") {
12614
+ rows.push(row$29("agent-token-file", "the Service Account's token file", file.missing ? "skip" : "fail", file.missing ? `${path}: not there, so this machine has no agent set up (${file.reason})` : `${path}: ${file.reason}`));
12615
+ return finish();
12616
+ }
12617
+ rows.push(row$29("agent-token-file", "the Service Account's token file", "ok", `${path} (mode 600, in a private directory)`));
12618
+ if (!ports.opInstalled()) {
12619
+ rows.push(row$29("agent-op", "the 1Password CLI", "fail", "`op` is not installed: brew install 1password-cli"));
12620
+ return finish();
12621
+ }
12622
+ rows.push(row$29("agent-op", "the 1Password CLI", "ok", "`op` is installed"));
12623
+ const scrub = (err) => errorMessage(err).split(file.token).join("[redacted]");
12624
+ let environment;
12625
+ try {
12626
+ environment = await ports.environmentName();
12627
+ } catch (err) {
12628
+ rows.push(row$29("agent-environment", "the agent Environment", "fail", `cannot name it: ${scrub(err)}`));
12629
+ return finish();
12630
+ }
12631
+ let entries;
12632
+ try {
12633
+ entries = await ports.readEntries(environment, file.token);
12634
+ } catch (err) {
12635
+ rows.push(row$29("agent-environment", "the agent Environment", "fail", `could not read "${environment}": ${scrub(err)}`));
12636
+ return finish();
12637
+ }
12638
+ rows.push(row$29("agent-environment", "the agent Environment", "ok", `"${environment}" is readable: ${entries.length} variable(s)`));
12639
+ const others = ENVIRONMENT_LAYERS.filter((layer) => layer !== "agent");
12640
+ const readable = [];
12641
+ for (const layer of others) {
12642
+ const name = environment.replace(/ - agent$/, ` - ${layer}`);
12643
+ try {
12644
+ await ports.readEntries(name, file.token);
12645
+ readable.push(name);
12646
+ } catch {}
12647
+ }
12648
+ rows.push(readable.length > 0 ? row$29("agent-narrow", "the Service Account reaches only the agent Environment", "fail", `it can read ${readable.length} other Environment(s): remove its access to them, or make a new Service Account`, readable.map((name) => `can read "${name}"`)) : row$29("agent-narrow", "the Service Account reaches only the agent Environment", "ok", `it cannot read ${others.join(", ")} (refused or not there)`));
12649
+ let tokens;
12650
+ try {
12651
+ tokens = await ports.declaredTokens();
12652
+ } catch (err) {
12653
+ rows.push(row$29("agent-tokens", "the agent tokens", "skip", `could not read the plugins' declared tokens: ${scrub(err)}`));
12654
+ return finish();
12655
+ }
12656
+ const expected = tokenExpectations(tokens, { layer: "agent" }).map((e) => e.envName);
12657
+ const held = new Set(entries.filter((e) => e.value !== "").map((e) => e.name));
12658
+ const missing = expected.filter((name) => !held.has(name));
12659
+ rows.push(missing.length > 0 ? row$29("agent-tokens", "the agent tokens", "skip", `${missing.length} of ${expected.length} agent token(s) still to make`, instanceTokenGuide(missing, tokens, "agent").map(tokenProblem)) : row$29("agent-tokens", "the agent tokens", "ok", `all ${expected.length} declared agent token(s) are there`));
12660
+ const others2 = entries.map((e) => e.name).filter((name) => !expected.includes(name));
12661
+ if (others2.length > 0) rows.push(row$29("agent-extras", "other variables the agent is given", "skip", `info: ${others2.length} variable(s) the plugins do not declare for the agent layer: ${others2.join(", ")}`));
12662
+ return finish();
12663
+ }
12664
+ // src/commands/doctor-agent/doctor-agent.command.ts
12665
+ const doctorAgentCommand = {
12666
+ command: "agent",
12667
+ describe: "Check the agent setup: the Service Account's token file, that it reads the agent Environment and no other, and the agent tokens still to make (read-only)",
12668
+ handler: async (argv) => {
12669
+ const tokens = tokenContext(argv.token);
12670
+ if (!tokens) return;
12671
+ const loaded = await loadConfig(argv.cwd);
12672
+ applyResolvedConfig(argv, loaded.resolved);
12673
+ if ((await runDoctorAgent({
12674
+ loaded,
12675
+ context: {
12676
+ repoRoot: argv.cwd,
12677
+ ...tokens,
12678
+ org: resolveOrg(argv, loaded.resolved)
12679
+ }
12680
+ })).status === "fail") process.exitCode = 1;
12681
+ }
12682
+ };
11999
12683
  // src/commands/doctor-ci/problem-row.ts
12000
12684
  /** A row that fails with its problems, or passes with `okDetail` when there are none. */
12001
12685
  function problemRow(id, title, problems, okDetail) {
@@ -12828,7 +13512,7 @@ async function runDoctorDns(input) {
12828
13512
  });
12829
13513
  else if (!loader.has("dns")) {
12830
13514
  const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
12831
- for (const zone of zones) rows.push(row$25(zone, "skip", why));
13515
+ for (const zone of zones) rows.push(row$28(zone, "skip", why));
12832
13516
  for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
12833
13517
  } else {
12834
13518
  const dns = loader.get("dns");
@@ -12850,7 +13534,7 @@ async function runDoctorDns(input) {
12850
13534
  ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
12851
13535
  };
12852
13536
  }
12853
- function row$25(zone, status, detail, problems = []) {
13537
+ function row$28(zone, status, detail, problems = []) {
12854
13538
  return {
12855
13539
  id: `dns-${zone}`,
12856
13540
  title: `${zone} records exist`,
@@ -12879,7 +13563,7 @@ async function checkDomain(dns, deploy, project, hostname) {
12879
13563
  return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
12880
13564
  }
12881
13565
  }
12882
- async function checkZone(dns, zone, wanted, rowOf = (...args) => row$25(zone, ...args)) {
13566
+ async function checkZone(dns, zone, wanted, rowOf = (...args) => row$28(zone, ...args)) {
12883
13567
  try {
12884
13568
  const have = await dns.listRecords(zone);
12885
13569
  const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
@@ -13046,7 +13730,7 @@ function declaredProjects$1(layouts) {
13046
13730
  return [...new Set(layouts.flatMap((layout) => layout.relay?.errors?.projects ?? []))];
13047
13731
  }
13048
13732
  // src/commands/doctor-errors/errors-rows.ts
13049
- const row$24 = (id, title, status, detail, problems = []) => ({
13733
+ const row$27 = (id, title, status, detail, problems = []) => ({
13050
13734
  id,
13051
13735
  title,
13052
13736
  status,
@@ -13063,27 +13747,27 @@ function errorsRows(found, providerName) {
13063
13747
  const orgSlug = found.org.slug;
13064
13748
  if (!found.org.exists) {
13065
13749
  const problem = `${providerName} has no organization named ${orgSlug}; check the \`org\` option of the \`errors\` provider`;
13066
- const rows = [row$24("errors:org", "organization exists", "fail", `${orgSlug} not found`, [problem])];
13067
- for (const project of found.projects) rows.push(row$24(`errors:project:${project.slug}`, `project ${project.slug} exists`, "skip", "not checked: no organization"));
13750
+ const rows = [row$27("errors:org", "organization exists", "fail", `${orgSlug} not found`, [problem])];
13751
+ for (const project of found.projects) rows.push(row$27(`errors:project:${project.slug}`, `project ${project.slug} exists`, "skip", "not checked: no organization"));
13068
13752
  return rows;
13069
13753
  }
13070
- const rows = [row$24("errors:org", "organization exists", "ok", `${orgSlug} (${found.org.name ?? orgSlug})`)];
13754
+ const rows = [row$27("errors:org", "organization exists", "ok", `${orgSlug} (${found.org.name ?? orgSlug})`)];
13071
13755
  if (found.projects.length === 0) {
13072
- rows.push(row$24("errors:projects", "declared projects", "skip", "none declared: no `relay.errors.projects` in a layout"));
13756
+ rows.push(row$27("errors:projects", "declared projects", "skip", "none declared: no `relay.errors.projects` in a layout"));
13073
13757
  return rows;
13074
13758
  }
13075
13759
  for (const project of found.projects) {
13076
13760
  const slug = project.slug;
13077
13761
  if (!project.exists) {
13078
13762
  const problem = `no project ${slug} in ${found.org.slug}; create it in ${providerName}`;
13079
- rows.push(row$24(`errors:project:${slug}`, `project ${slug} exists`, "fail", "not found", [problem]), row$24(`errors:dsn:${slug}`, `project ${slug} has a key`, "skip", "not checked: no project"), row$24(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", "not checked: no project"));
13763
+ rows.push(row$27(`errors:project:${slug}`, `project ${slug} exists`, "fail", "not found", [problem]), row$27(`errors:dsn:${slug}`, `project ${slug} has a key`, "skip", "not checked: no project"), row$27(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", "not checked: no project"));
13080
13764
  continue;
13081
13765
  }
13082
- rows.push(row$24(`errors:project:${slug}`, `project ${slug} exists`, "ok", slug));
13083
- rows.push(project.hasDsn ? row$24(`errors:dsn:${slug}`, `project ${slug} has a key`, "ok", "a client key (DSN) exists") : row$24(`errors:dsn:${slug}`, `project ${slug} has a key`, "fail", "no client key", [`${slug} has no client key, so an SDK has no DSN to send to; add one in ${providerName}`]));
13084
- if (project.alertRules === void 0) rows.push(row$24(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", found.alertsUnreadable ? `could not read the alert rules: ${found.alertsUnreadable}` : "not read"));
13085
- else if (project.alertRules === 0) rows.push(row$24(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "fail", "no enabled rule", [`no enabled alert rule watches ${slug}, so its errors reach no one`]));
13086
- else rows.push(row$24(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "ok", `${project.alertRules} enabled rule(s)`));
13766
+ rows.push(row$27(`errors:project:${slug}`, `project ${slug} exists`, "ok", slug));
13767
+ rows.push(project.hasDsn ? row$27(`errors:dsn:${slug}`, `project ${slug} has a key`, "ok", "a client key (DSN) exists") : row$27(`errors:dsn:${slug}`, `project ${slug} has a key`, "fail", "no client key", [`${slug} has no client key, so an SDK has no DSN to send to; add one in ${providerName}`]));
13768
+ if (project.alertRules === void 0) rows.push(row$27(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", found.alertsUnreadable ? `could not read the alert rules: ${found.alertsUnreadable}` : "not read"));
13769
+ else if (project.alertRules === 0) rows.push(row$27(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "fail", "no enabled rule", [`no enabled alert rule watches ${slug}, so its errors reach no one`]));
13770
+ else rows.push(row$27(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "ok", `${project.alertRules} enabled rule(s)`));
13087
13771
  }
13088
13772
  return rows;
13089
13773
  }
@@ -13206,7 +13890,7 @@ function datasetTargets(config) {
13206
13890
  * dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
13207
13891
  * a dataset the token may not see (403), a name, a token or a response that cannot be read is a skip with the reason.
13208
13892
  */
13209
- const row$23 = (id, title, status, detail, problems = []) => ({
13893
+ const row$26 = (id, title, status, detail, problems = []) => ({
13210
13894
  id,
13211
13895
  title,
13212
13896
  status,
@@ -13223,7 +13907,7 @@ async function runDoctorLogs(input) {
13223
13907
  if (!loader.has("logs")) {
13224
13908
  const failure = loader.loadFailures().find((f) => f.key === "logs");
13225
13909
  const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
13226
- rows.push(row$23("logs", "logs", "skip", why));
13910
+ rows.push(row$26("logs", "logs", "skip", why));
13227
13911
  } else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
13228
13912
  printCheckRows(rows, print);
13229
13913
  const summary = summariseChecks(rows);
@@ -13247,38 +13931,38 @@ async function checkLogs(logs, targets) {
13247
13931
  for (const target of targets) {
13248
13932
  const id = `logs:dataset:${target.id}`;
13249
13933
  const title = `dataset for ${target.label}`;
13250
- if (!target.name) rows.push(row$23(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
13251
- else if (!token.usable) rows.push(row$23(id, title, "skip", `${target.name}: not checked, the token is not usable`));
13252
- else if (!logs.readDataset) rows.push(row$23(id, title, "skip", `${logs.providerName} cannot read a dataset`));
13934
+ if (!target.name) rows.push(row$26(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
13935
+ else if (!token.usable) rows.push(row$26(id, title, "skip", `${target.name}: not checked, the token is not usable`));
13936
+ else if (!logs.readDataset) rows.push(row$26(id, title, "skip", `${logs.providerName} cannot read a dataset`));
13253
13937
  else rows.push(...await checkDataset(logs, target, target.name, id, title));
13254
13938
  }
13255
13939
  const org = resolveValue$1(["AXIOM_ORG"], void 0, { prefix: PREFIX$1 });
13256
- rows.push(org ? row$23("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$23("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links need it`));
13940
+ rows.push(org ? row$26("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$26("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links need it`));
13257
13941
  return rows;
13258
13942
  }
13259
13943
  /** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
13260
13944
  async function checkToken$1(logs, dataset) {
13261
13945
  const title = "token is accepted";
13262
13946
  if (!logs.checkToken) return {
13263
- row: row$23("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
13947
+ row: row$26("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
13264
13948
  usable: true
13265
13949
  };
13266
13950
  try {
13267
13951
  const result = await logs.checkToken(dataset);
13268
13952
  if (result.ok) return {
13269
- row: row$23("logs:token", title, "ok", `${logs.providerName} accepts the token`),
13953
+ row: row$26("logs:token", title, "ok", `${logs.providerName} accepts the token`),
13270
13954
  usable: true
13271
13955
  };
13272
13956
  const reason = result.reason ?? `${logs.providerName} refused the token`;
13273
13957
  return {
13274
- row: row$23("logs:token", title, "fail", reason, [reason]),
13958
+ row: row$26("logs:token", title, "fail", reason, [reason]),
13275
13959
  usable: false
13276
13960
  };
13277
13961
  } catch (err) {
13278
13962
  const noToken = missingTokenReason(err);
13279
13963
  const detail = noToken ?? `could not check the token: ${describeError(err)}`;
13280
13964
  return {
13281
- row: row$23("logs:token", title, "skip", detail),
13965
+ row: row$26("logs:token", title, "skip", detail),
13282
13966
  usable: noToken === void 0
13283
13967
  };
13284
13968
  }
@@ -13288,17 +13972,17 @@ async function checkDataset(logs, target, name, id, title) {
13288
13972
  const found = await logs.readDataset(name);
13289
13973
  if (found.forbidden) {
13290
13974
  const why = `${name}: not visible to this token (${logs.providerName} refused the read; it may also not exist)`;
13291
- return [row$23(id, title, "skip", why)];
13975
+ return [row$26(id, title, "skip", why)];
13292
13976
  }
13293
13977
  if (!found.exists) {
13294
13978
  const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
13295
- return [row$23(id, title, "fail", `${name} does not exist`, [problem])];
13979
+ return [row$26(id, title, "fail", `${name} does not exist`, [problem])];
13296
13980
  }
13297
13981
  const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
13298
- return [row$23(id, title, "ok", `${name} exists`), row$23(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
13982
+ return [row$26(id, title, "ok", `${name} exists`), row$26(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
13299
13983
  } catch (err) {
13300
13984
  const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
13301
- return [row$23(id, title, "skip", detail)];
13985
+ return [row$26(id, title, "skip", detail)];
13302
13986
  }
13303
13987
  }
13304
13988
  // src/commands/doctor-logs/doctor-logs.command.ts
@@ -14351,11 +15035,6 @@ function relaySourcesProblem(layout, errorsSource) {
14351
15035
  }
14352
15036
  }
14353
15037
  }
14354
- // src/commands/provider-tuples/provider-tuples.ts
14355
- /** The providers a config names, in the order it names them: one tuple per capability entry, so a provider named twice appears twice. */
14356
- function providerTuples(providers) {
14357
- return Object.values(providers).flatMap((entry) => entry.cardinality === "single" ? [entry.tuple] : entry.tuples);
14358
- }
14359
15038
  // src/commands/workspace-providers/workspace-providers.ts
14360
15039
  /**
14361
15040
  * The providers the configs of the workspace's packages name (`apps/sentinel` names `vercel` for its `deployment`) that
@@ -16893,7 +17572,7 @@ const info = (id, title, noun, extras) => ({
16893
17572
  detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
16894
17573
  problems: extras
16895
17574
  });
16896
- const row$22 = (id, title, problems, ok) => ({
17575
+ const row$25 = (id, title, problems, ok) => ({
16897
17576
  id,
16898
17577
  title,
16899
17578
  status: problems.length > 0 ? "fail" : "ok",
@@ -16929,19 +17608,19 @@ function viewProblems(want, found) {
16929
17608
  function boardRows(boardName, template, state) {
16930
17609
  const id = `project:${boardName}`;
16931
17610
  const rows = [];
16932
- rows.push(row$22(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
17611
+ rows.push(row$25(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
16933
17612
  const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
16934
17613
  if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
16935
- for (const want of template.fields) rows.push(row$22(`${id}:field:${want.name}`, `${boardName}: field ${want.name}`, fieldProblems(want, state.fields.find((f) => f.name === want.name)), want.options ? `${want.options.length} options in order` : want.type));
17614
+ for (const want of template.fields) rows.push(row$25(`${id}:field:${want.name}`, `${boardName}: field ${want.name}`, fieldProblems(want, state.fields.find((f) => f.name === want.name)), want.options ? `${want.options.length} options in order` : want.type));
16936
17615
  const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
16937
17616
  if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
16938
- for (const want of template.views) rows.push(row$22(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
17617
+ for (const want of template.views) rows.push(row$25(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
16939
17618
  const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
16940
17619
  if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
16941
17620
  for (const name of template.rules ?? []) {
16942
17621
  const found = state.rules.find((r) => r.name === name);
16943
17622
  const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
16944
- rows.push(row$22(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
17623
+ rows.push(row$25(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
16945
17624
  }
16946
17625
  return rows;
16947
17626
  }
@@ -17001,7 +17680,7 @@ function itemRows(boardName, items) {
17001
17680
  * never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
17002
17681
  * failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
17003
17682
  */
17004
- const row$21 = (id, title, status, detail, problems = []) => ({
17683
+ const row$24 = (id, title, status, detail, problems = []) => ({
17005
17684
  id,
17006
17685
  title,
17007
17686
  status,
@@ -17055,14 +17734,14 @@ async function checkBoards(input, loader) {
17055
17734
  loader,
17056
17735
  ...input.io ? { io: input.io } : {}
17057
17736
  });
17058
- if (!opened.ok) return [row$21("project", "project", opened.kind, opened.reason, opened.problems)];
17737
+ if (!opened.ok) return [row$24("project", "project", opened.kind, opened.reason, opened.problems)];
17059
17738
  const { projects, owner, boards, templates, templateProblems } = opened.context;
17060
17739
  const rows = templateProblems.map((problem) => {
17061
17740
  /* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
17062
17741
  const file = problem.split(": ")[0] ?? problem;
17063
- return row$21(`project:template:${file}`, `template file ${file}`, "fail", problem);
17742
+ return row$24(`project:template:${file}`, `template file ${file}`, "fail", problem);
17064
17743
  });
17065
- if (boards.length === 0) return [...rows, row$21("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
17744
+ if (boards.length === 0) return [...rows, row$24("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
17066
17745
  for (const declared of boards) {
17067
17746
  const template = templates[declared.template];
17068
17747
  const title = `${declared.name}: board exists and is open`;
@@ -17070,18 +17749,18 @@ async function checkBoards(input, loader) {
17070
17749
  const board = await projects.find(owner, declared.name);
17071
17750
  if (!board) {
17072
17751
  const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
17073
- rows.push(row$21(`project:${declared.name}`, title, "fail", closed ? "the board is closed" : "no open board has this name", [closed ? "reopen it, or run `holocron setup project` to make a new one" : "run `holocron setup project`"]));
17752
+ rows.push(row$24(`project:${declared.name}`, title, "fail", closed ? "the board is closed" : "no open board has this name", [closed ? "reopen it, or run `holocron setup project` to make a new one" : "run `holocron setup project`"]));
17074
17753
  continue;
17075
17754
  }
17076
- rows.push(row$21(`project:${declared.name}`, title, "ok", board.url));
17755
+ rows.push(row$24(`project:${declared.name}`, title, "ok", board.url));
17077
17756
  if (!template) {
17078
- rows.push(row$21(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
17757
+ rows.push(row$24(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
17079
17758
  continue;
17080
17759
  }
17081
17760
  rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
17082
- rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$21(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
17761
+ rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$24(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
17083
17762
  } catch (err) {
17084
- rows.push(row$21(`project:${declared.name}`, title, "fail", describeError(err)));
17763
+ rows.push(row$24(`project:${declared.name}`, title, "fail", describeError(err)));
17085
17764
  }
17086
17765
  }
17087
17766
  return rows;
@@ -18181,19 +18860,19 @@ async function runDoctorRepo(input) {
18181
18860
  const rows = [];
18182
18861
  if (!loader.has("source")) {
18183
18862
  const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
18184
- for (const check of checks) rows.push(row$20(check, { skip: why }));
18863
+ for (const check of checks) rows.push(row$23(check, { skip: why }));
18185
18864
  } else {
18186
18865
  const source = loader.get("source");
18187
18866
  for (const check of checks) {
18188
18867
  if (typeof source[check.needs] !== "function") {
18189
- rows.push(row$20(check, { skip: `provider does not implement ${check.needs}` }));
18868
+ rows.push(row$23(check, { skip: `provider does not implement ${check.needs}` }));
18190
18869
  continue;
18191
18870
  }
18192
18871
  try {
18193
- rows.push(row$20(check, await check.run(source)));
18872
+ rows.push(row$23(check, await check.run(source)));
18194
18873
  } catch (err) {
18195
18874
  const noToken = missingTokenReason(err);
18196
- if (noToken !== void 0) rows.push(row$20(check, { skip: noToken }));
18875
+ if (noToken !== void 0) rows.push(row$23(check, { skip: noToken }));
18197
18876
  else rows.push({
18198
18877
  id: check.id,
18199
18878
  title: check.title,
@@ -18220,7 +18899,7 @@ async function runDoctorRepo(input) {
18220
18899
  ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
18221
18900
  };
18222
18901
  }
18223
- function row$20(check, result) {
18902
+ function row$23(check, result) {
18224
18903
  const { id, title } = check;
18225
18904
  if ("skip" in result) return {
18226
18905
  id,
@@ -18744,7 +19423,7 @@ function providerGroup(providerName) {
18744
19423
  }
18745
19424
  // src/commands/doctor-secrets/credentials-rows.ts
18746
19425
  /** A row for the provider as a whole, or for one of its variables when `name` is given. */
18747
- function row$19(provider, status, detail, name) {
19426
+ function row$22(provider, status, detail, name) {
18748
19427
  return name === void 0 ? {
18749
19428
  id: provider,
18750
19429
  title: provider,
@@ -18769,10 +19448,10 @@ async function credentialsRows(input) {
18769
19448
  const { loader } = input;
18770
19449
  const { resolved } = input.loaded;
18771
19450
  if (!resolved.providers.credentials) return {
18772
- rows: input.asked ? [row$19("credentials", "skip", "no `credentials` provider is configured")] : [],
19451
+ rows: input.asked ? [row$22("credentials", "skip", "no `credentials` provider is configured")] : [],
18773
19452
  places: []
18774
19453
  };
18775
- const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$19(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
19454
+ const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$22(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
18776
19455
  const places = [];
18777
19456
  if (!loader.has("credentials")) return {
18778
19457
  rows,
@@ -18784,7 +19463,7 @@ async function credentialsRows(input) {
18784
19463
  const tuple = tuples.find((t) => t.provider === impl.providerName);
18785
19464
  const explicit = tuple && credentialsEnvironment(tuple, resolved);
18786
19465
  if (!explicit && !derivesEnvironment(impl.providerName)) {
18787
- rows.push(row$19(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
19466
+ rows.push(row$22(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
18788
19467
  continue;
18789
19468
  }
18790
19469
  try {
@@ -18796,7 +19475,7 @@ async function credentialsRows(input) {
18796
19475
  rows.push(...checked.rows);
18797
19476
  places.push(...checked.places);
18798
19477
  } catch (err) {
18799
- rows.push(row$19(impl.providerName, "fail", errorMessage(err)));
19478
+ rows.push(row$22(impl.providerName, "fail", errorMessage(err)));
18800
19479
  }
18801
19480
  }
18802
19481
  return {
@@ -18812,17 +19491,17 @@ async function credentialsRows(input) {
18812
19491
  async function checkProvider(impl, candidates, expected, synced) {
18813
19492
  const provider = impl.providerName;
18814
19493
  if (!impl.inspect) return {
18815
- rows: [row$19(provider, "skip", "cannot list the variables without reading their values")],
19494
+ rows: [row$22(provider, "skip", "cannot list the variables without reading their values")],
18816
19495
  places: []
18817
19496
  };
18818
19497
  if (expected.length === 0) return {
18819
- rows: [row$19(provider, "skip", "no configured plugin lists the tokens it takes")],
19498
+ rows: [row$22(provider, "skip", "no configured plugin lists the tokens it takes")],
18820
19499
  places: []
18821
19500
  };
18822
19501
  const inspect = impl.inspect.bind(impl);
18823
19502
  try {
18824
19503
  const { found, missing } = await tryEnvironments(candidates, inspect);
18825
- const rows = missing.map((name) => row$19(provider, "fail", `${provider} has no Environment named "${name}"`));
19504
+ const rows = missing.map((name) => row$22(provider, "fail", `${provider} has no Environment named "${name}"`));
18826
19505
  const group = providerGroup(provider);
18827
19506
  const unreadPlaces = missing.map((name) => ({
18828
19507
  column: {
@@ -18845,9 +19524,9 @@ async function checkProvider(impl, candidates, expected, synced) {
18845
19524
  const have = (name) => found.some((f) => f.result.names.includes(name));
18846
19525
  let present = 0;
18847
19526
  for (const { name, optional } of expected) if (have(name)) present++;
18848
- else if (optional) rows.push(row$19(provider, "skip", `optional, not set in ${where}`, name));
18849
- else rows.push(row$19(provider, "fail", `missing from ${where}`, name));
18850
- if (present > 0) rows.push(row$19(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
19527
+ else if (optional) rows.push(row$22(provider, "skip", `optional, not set in ${where}`, name));
19528
+ else rows.push(row$22(provider, "fail", `missing from ${where}`, name));
19529
+ if (present > 0) rows.push(row$22(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
18851
19530
  const names = new Set(expected.map((e) => e.name));
18852
19531
  const places = [];
18853
19532
  const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
@@ -18886,7 +19565,7 @@ async function checkProvider(impl, candidates, expected, synced) {
18886
19565
  };
18887
19566
  } catch (err) {
18888
19567
  return {
18889
- rows: [row$19(provider, "fail", errorMessage(err))],
19568
+ rows: [row$22(provider, "fail", errorMessage(err))],
18890
19569
  places: []
18891
19570
  };
18892
19571
  }
@@ -18977,13 +19656,21 @@ async function deployKeyRows(entries, vault) {
18977
19656
  return rows;
18978
19657
  }
18979
19658
  // src/commands/doctor-secrets/environment-skip-row.ts
18980
- /** Why `doctor secrets` has nothing to compare for an environment, in one place. `test` has no layer. */
18981
- const NOT_CHECKED = { test: "has no layer (tests use fakes and read none)" };
19659
+ /**
19660
+ * Why `doctor secrets` has nothing to compare for an environment, in one place. `test` has no layer; `preview` and
19661
+ * `agent` are compared with the other layers by `--shared` (no secret may be a copy of another layer's) and have no
19662
+ * names matrix of their own (`holocron doctor agent` checks the agent layer, spec `tech-agent-secrets`).
19663
+ */
19664
+ const NOT_CHECKED = {
19665
+ test: "has no layer (tests use fakes and read none)",
19666
+ preview: "is compared with the other layers by --shared, and has no names matrix of its own",
19667
+ agent: "is compared with the other layers by --shared, and checked by `holocron doctor agent`"
19668
+ };
18982
19669
  /**
18983
19670
  * The skipped row for an environment `doctor secrets` does not compare, naming the environment and the reason.
18984
19671
  *
18985
19672
  * @param env - The environment asked for with `--env`.
18986
- * @returns The row, or `undefined` for every environment but `test`, which have rows of their own.
19673
+ * @returns The row, or `undefined` for the environments that have rows of their own (`local`, `dev`, `ci`, `prod`).
18987
19674
  */
18988
19675
  function environmentSkipRow(env) {
18989
19676
  const reason = NOT_CHECKED[env];
@@ -19532,7 +20219,7 @@ async function readLayers(vault, slug, layers = ENVIRONMENT_LAYERS) {
19532
20219
  blind = true;
19533
20220
  }
19534
20221
  } catch (err) {
19535
- if (layer === "local" || layer === "preview") continue;
20222
+ if (layer === "local" || layer === "preview" || layer === "agent") continue;
19536
20223
  rows.push({
19537
20224
  id: `skip:${layer}`,
19538
20225
  title: `Environment "${environment}"`,
@@ -19760,7 +20447,7 @@ async function variableRows(loader, config, org) {
19760
20447
  if (!loader.has("source")) {
19761
20448
  const why = whyMissing(loader, "source", "no `source` provider to read them with");
19762
20449
  for (const check of checks) {
19763
- rows.push(row$18(check, { skip: why }));
20450
+ rows.push(row$21(check, { skip: why }));
19764
20451
  observations.push({
19765
20452
  scope: check.scope,
19766
20453
  unread: why
@@ -19770,7 +20457,7 @@ async function variableRows(loader, config, org) {
19770
20457
  const source = loader.get("source");
19771
20458
  for (const check of checks) try {
19772
20459
  const result = await check.run(source);
19773
- rows.push(row$18(check, result));
20460
+ rows.push(row$21(check, result));
19774
20461
  observations.push("skip" in result ? {
19775
20462
  scope: check.scope,
19776
20463
  unread: result.skip
@@ -19781,7 +20468,7 @@ async function variableRows(loader, config, org) {
19781
20468
  } catch (err) {
19782
20469
  const noToken = missingTokenReason(err);
19783
20470
  if (noToken !== void 0) {
19784
- rows.push(row$18(check, { skip: noToken }));
20471
+ rows.push(row$21(check, { skip: noToken }));
19785
20472
  observations.push({
19786
20473
  scope: check.scope,
19787
20474
  unread: noToken
@@ -19807,7 +20494,7 @@ async function variableRows(loader, config, org) {
19807
20494
  observations
19808
20495
  };
19809
20496
  }
19810
- function row$18(check, result) {
20497
+ function row$21(check, result) {
19811
20498
  const { id, title } = check;
19812
20499
  if ("skip" in result) return {
19813
20500
  id,
@@ -19897,7 +20584,7 @@ function describeExpiry(expiresAt, now) {
19897
20584
  *
19898
20585
  * What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
19899
20586
  */
19900
- function row$17(id, status, detail) {
20587
+ function row$20(id, status, detail) {
19901
20588
  return {
19902
20589
  id: `verify:${id}`,
19903
20590
  title: `verify ${id}`,
@@ -19925,12 +20612,12 @@ async function verifyRows(input) {
19925
20612
  try {
19926
20613
  module = await importer(pkg);
19927
20614
  } catch (err) {
19928
- rows.push(row$17(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
20615
+ rows.push(row$20(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
19929
20616
  continue;
19930
20617
  }
19931
20618
  for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
19932
20619
  }
19933
- if (rows.length === 0) rows.push(row$17("tokens", "skip", "no configured plugin lists the tokens it takes"));
20620
+ if (rows.length === 0) rows.push(row$20("tokens", "skip", "no configured plugin lists the tokens it takes"));
19934
20621
  return rows;
19935
20622
  }
19936
20623
  /**
@@ -19943,30 +20630,30 @@ async function loadCredentials(input) {
19943
20630
  try {
19944
20631
  await input.loader.load();
19945
20632
  } catch (err) {
19946
- return [row$17("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
20633
+ return [row$20("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
19947
20634
  }
19948
- return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$17(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
20635
+ return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$20(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
19949
20636
  }
19950
20637
  async function checkToken(token, module, env, readToken, now) {
19951
20638
  const { keyringKey, envName, vendorEnvName } = token;
19952
20639
  const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
19953
20640
  const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
19954
20641
  const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
19955
- if (!value) return row$17(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
20642
+ if (!value) return row$20(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
19956
20643
  const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
19957
- if (!verify) return row$17(keyringKey, "skip", "set, but its plugin cannot verify it");
20644
+ if (!verify) return row$20(keyringKey, "skip", "set, but its plugin cannot verify it");
19958
20645
  const from = fromEnv ?? stored?.source ?? "keyring";
19959
20646
  try {
19960
20647
  const verified = await verify(value);
19961
- if (!verified.ok) return row$17(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
20648
+ if (!verified.ok) return row$20(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
19962
20649
  const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
19963
- if (!expiry) return row$17(keyringKey, "ok", `${verified.subject} (${from})`);
20650
+ if (!expiry) return row$20(keyringKey, "ok", `${verified.subject} (${from})`);
19964
20651
  return expiry.soon ? {
19965
- ...row$17(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
20652
+ ...row$20(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
19966
20653
  problems: [`${expiry.text}: renew it`]
19967
- } : row$17(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
20654
+ } : row$20(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
19968
20655
  } catch (err) {
19969
- return row$17(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
20656
+ return row$20(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
19970
20657
  }
19971
20658
  }
19972
20659
  // src/commands/doctor-secrets/doctor-secrets.ts
@@ -20054,6 +20741,7 @@ async function runDoctorSecrets(input) {
20054
20741
  wants
20055
20742
  }));
20056
20743
  } else rows.push(...skipRow("test"));
20744
+ if (!input.shared) rows.push(...skipRow("preview"), ...skipRow("agent"));
20057
20745
  if (input.verify) {
20058
20746
  ran = true;
20059
20747
  try {
@@ -20082,12 +20770,12 @@ async function runDoctorSecrets(input) {
20082
20770
  }
20083
20771
  if (input.shared) {
20084
20772
  ran = true;
20085
- const layers = ENVIRONMENT_LAYERS.filter((layer) => layer !== "preview" && wants(layer));
20773
+ const layers = ENVIRONMENT_LAYERS.filter((layer) => wants(layer));
20086
20774
  if (layers.length < 2) rows.push({
20087
20775
  id: "shared:layers",
20088
20776
  title: "compare the layers",
20089
20777
  status: "skip",
20090
- detail: "--shared needs two or more of local, dev, ci and prod in --env",
20778
+ detail: "--shared needs two or more of local, dev, ci, prod, preview and agent in --env",
20091
20779
  problems: []
20092
20780
  });
20093
20781
  else {
@@ -20152,7 +20840,9 @@ const DOCTOR_ENVIRONMENTS = [
20152
20840
  "dev",
20153
20841
  "ci",
20154
20842
  "test",
20155
- "prod"
20843
+ "prod",
20844
+ "preview",
20845
+ "agent"
20156
20846
  ];
20157
20847
  /**
20158
20848
  * Turns the `--env` values into the environments to check. Each value may itself be a comma-separated list, so
@@ -20256,169 +20946,6 @@ function ownerEnvironments(config) {
20256
20946
  instances
20257
20947
  };
20258
20948
  }
20259
- // src/commands/probe/probe-token/choose-token.ts
20260
- /**
20261
- * Asks which token a probe that accepts one should check: the configured one, one from an Environment, or one typed in
20262
- * (hidden as it is typed). Only called on a terminal when neither `--token` nor `--environment` was given.
20263
- */
20264
- async function chooseToken(provider) {
20265
- const how = await select({
20266
- message: `Which ${provider} token should it check?`,
20267
- choices: [
20268
- {
20269
- name: "The one this repo is configured to use",
20270
- value: "configured"
20271
- },
20272
- {
20273
- name: "One from a vault Environment (a layer such as ci or dev, or a name)",
20274
- value: "environment"
20275
- },
20276
- {
20277
- name: "Type or paste a token",
20278
- value: "paste"
20279
- }
20280
- ]
20281
- });
20282
- if (how === "environment") return { environment: (await input({
20283
- message: "Environment (layer or name):",
20284
- default: "ci"
20285
- })).trim() };
20286
- if (how === "paste") return { token: (await password({
20287
- message: `${provider} token:`,
20288
- mask: "*"
20289
- })).trim() };
20290
- }
20291
- // src/commands/probe/probe-token/default-provider-tokens.ts
20292
- /**
20293
- * Reads the tokens a provider's plugin lists (its module-level `tokens`), resolving the plugin package from the
20294
- * directory of the config that was loaded so a `--cwd` run finds the plugins installed there.
20295
- */
20296
- function defaultProviderTokens(loaded, importer = createDefaultImporter(dirname(loaded.filepath))) {
20297
- return async (provider) => (await importer(resolvePluginPackage(provider))).tokens ?? [];
20298
- }
20299
- // src/commands/secrets-sync/resolve-environment-id/resolve-environment-id.ts
20300
- /**
20301
- * The vault Environment `holocron sync secrets --env <environment>` reads. A layer word (`local`, `dev`, `ci`, `prod`) is the
20302
- * Environment of that layer of this repository, `<org/repo> - <layer>`; any other text is a literal Environment name.
20303
- * A literal name wins only when it is not exactly a layer word, so an Environment that is itself called `prod` cannot be
20304
- * addressed by that name (spec `tech-environment-layers`, #2069).
20305
- *
20306
- * @param id - The `--env` value the user gave.
20307
- * @param input - Where the repository is (its `origin` remote is read there), and optionally how to read it.
20308
- * @throws {ConfigError} For a layer word when the remote cannot be read (the message names the `environment` option).
20309
- */
20310
- async function resolveEnvironmentId(id, input) {
20311
- if (!isEnvironmentLayer(id)) return id;
20312
- return layerEnvironment(await repoSlug(input.repoRoot, input.gitExec), id);
20313
- }
20314
- // src/commands/probe/probe-token/holds-no-token-error.ts
20315
- /** An Environment that holds none of the tokens a plugin lists. Its message names the variables looked for, never a value. */
20316
- var HoldsNoTokenError = class extends Error {
20317
- name = "HoldsNoTokenError";
20318
- };
20319
- // src/commands/probe/probe-token/environment-tokens.ts
20320
- /**
20321
- * Every token the provider declares that one vault Environment holds, read in memory. Only an Environment this repo uses is
20322
- * read: a layer word (`local`, `dev`, `ci`, `prod`) is this repo's `<org/repo> - <layer>`, and any other text must be a
20323
- * name the config already names (`configured`), so a probe cannot be pointed at an Environment the repo has nothing to
20324
- * do with. `local` reads the way the CLI does, `- local` over `- dev`, and `- local` may be absent.
20325
- *
20326
- * Each token the provider's plugin lists is looked for under its own variable (`HOLOCRON_SENTRY_TOKEN`), then the
20327
- * vendor's (`vendorEnvName`); the first that holds a value is that token's. A token the Environment does not hold is in
20328
- * `missing`, so the caller can report it by name. The Environment's other visible (not concealed) values come back as
20329
- * `plain`, for the plugin's own settings (a dataset, an account id); a vault that cannot say which are visible gives none.
20330
- *
20331
- * @throws {Error} When the name is not one of this repo's, no vault that reads an Environment is configured, the plugin
20332
- * lists no token, or the Environment holds none of them.
20333
- */
20334
- async function environmentTokens(input) {
20335
- if (!isEnvironmentLayer(input.environment) && !input.configured.includes(input.environment)) {
20336
- const known = [...ENVIRONMENT_LAYERS, ...input.configured];
20337
- throw new Error(`${input.environment} is not an Environment this repo's config names; use one of: ${known.join(", ")}`);
20338
- }
20339
- const read = input.vault?.readEnvironment?.bind(input.vault);
20340
- if (!read) throw new Error("--environment needs a vault provider that can read an Environment (1Password); none is configured");
20341
- const at = {
20342
- repoRoot: input.repoRoot,
20343
- gitExec: input.gitExec
20344
- };
20345
- const environment = await resolveEnvironmentId(input.environment, at);
20346
- const readEntries = input.vault?.readEnvironmentEntries?.bind(input.vault);
20347
- const readOne = async (id) => {
20348
- if (!readEntries) return {
20349
- values: await read(id),
20350
- plain: {}
20351
- };
20352
- const entries = await readEntries(id);
20353
- return {
20354
- values: Object.fromEntries(entries.map((e) => [e.name, e.value])),
20355
- plain: Object.fromEntries(entries.filter((e) => !e.concealed).map((e) => [e.name, e.value]))
20356
- };
20357
- };
20358
- let values;
20359
- let plain;
20360
- if (input.environment === "local") {
20361
- const dev = await readOne(await resolveEnvironmentId("dev", at));
20362
- const local = await readOne(environment).catch(() => ({
20363
- values: {},
20364
- plain: {}
20365
- }));
20366
- values = {
20367
- ...dev.values,
20368
- ...local.values
20369
- };
20370
- plain = {
20371
- ...dev.plain,
20372
- ...local.plain
20373
- };
20374
- } else ({values, plain} = await readOne(environment));
20375
- if (input.tokens.length === 0) throw new Error(`the ${input.provider} plugin lists no token to look for`);
20376
- const held = [];
20377
- const missing = [];
20378
- for (const declared of input.tokens) {
20379
- const variable = [declared.envName, ...declared.vendorEnvName ? [declared.vendorEnvName] : []].find((v) => values[v]);
20380
- if (variable) held.push({
20381
- token: values[variable],
20382
- variable,
20383
- envName: declared.envName
20384
- });
20385
- else missing.push(declared.envName);
20386
- }
20387
- if (held.length === 0) throw new HoldsNoTokenError(`${environment} holds none of ${input.tokens.flatMap((t) => [t.envName, ...t.vendorEnvName ? [t.vendorEnvName] : []]).join(", ")}`);
20388
- for (const declared of input.tokens) {
20389
- delete plain[declared.envName];
20390
- if (declared.vendorEnvName) delete plain[declared.vendorEnvName];
20391
- }
20392
- return {
20393
- environment,
20394
- held,
20395
- missing,
20396
- plain
20397
- };
20398
- }
20399
- // src/commands/probe/probe-token/with-environment-values/with-environment-values.ts
20400
- /**
20401
- * Runs `run` with `values` set in `process.env`, then puts every name back as it was (set again, or removed), even when
20402
- * `run` throws. It is how a probe that reads another Environment sees that Environment's plain values ahead of the
20403
- * machine's own: a plugin reads them through the usual chain, which looks at the process environment first, and the
20404
- * overlay lives only for the one run. Nothing is written anywhere and the values are never printed.
20405
- *
20406
- * @param values - The variables to set for the run; none means `run` is called as it is.
20407
- * @param run - The work that should see them.
20408
- * @returns What `run` returns.
20409
- */
20410
- async function withEnvironmentValues(values, run) {
20411
- const names = Object.keys(values ?? {});
20412
- if (!values || names.length === 0) return run();
20413
- const before = new Map(names.map((name) => [name, process.env[name]]));
20414
- for (const name of names) process.env[name] = values[name];
20415
- try {
20416
- return await run();
20417
- } finally {
20418
- for (const [name, previous] of before) if (previous === void 0) delete process.env[name];
20419
- else process.env[name] = previous;
20420
- }
20421
- }
20422
20949
  // src/commands/probe/scrub.ts
20423
20950
  const HIDDEN = "«hidden»";
20424
20951
  /** Shapes that are credentials wherever they appear: a Discord webhook URL, a bearer header, a Sentry token. */
@@ -20558,43 +21085,6 @@ async function runProbe(input) {
20558
21085
  rows
20559
21086
  };
20560
21087
  }
20561
- // src/commands/token-rotation/token-rotation.ts
20562
- /** The rotation policy of a token that declares none: a token is due after 90 days, and an expiry is flagged 14 days ahead. */
20563
- const DEFAULT_TOKEN_ROTATION = {
20564
- maxAgeDays: 90,
20565
- warnDays: 14
20566
- };
20567
- // src/commands/token-expectations/token-expectations.ts
20568
- /**
20569
- * Reads what a plugin's tokens declare (`PluginToken.expect`) as one entry per token and layer that holds it, in the
20570
- * order of `ENVIRONMENT_LAYERS`. The one reader the token probes, the doctor and the docs check share, so none of them
20571
- * walks the declaration itself. A token with no `expect` yields nothing; a layer no token holds is never listed.
20572
- */
20573
- function tokenExpectations(tokens, filter = {}) {
20574
- const found = [];
20575
- for (const token of tokens) {
20576
- if (!token.expect || filter.envName !== void 0 && token.envName !== filter.envName) continue;
20577
- const { layers = [], permissions = {} } = token.expect;
20578
- for (const layer of ENVIRONMENT_LAYERS) {
20579
- if (filter.layer !== void 0 && filter.layer !== layer) continue;
20580
- const rules = permissions[layer];
20581
- if (!rules && !layers.includes(layer)) continue;
20582
- const entries = Object.entries(rules ?? {});
20583
- found.push({
20584
- envName: token.envName,
20585
- layer,
20586
- rules: rules ?? {},
20587
- required: entries.filter(([, rule]) => rule === "required").map(([name]) => name),
20588
- absent: entries.filter(([, rule]) => rule === "absent").map(([name]) => name),
20589
- rotation: {
20590
- ...DEFAULT_TOKEN_ROTATION,
20591
- ...token.expect.rotation
20592
- }
20593
- });
20594
- }
20595
- }
20596
- return found;
20597
- }
20598
21088
  // src/commands/doctor-tokens/summarise-probe-rows.ts
20599
21089
  /**
20600
21090
  * Folds what one token probe reported into the one row the doctor shows for that token in that layer. A failing probe row
@@ -20648,7 +21138,7 @@ function summariseProbeRows(id, title, rows) {
20648
21138
  * provider with no `token` probe, no declared layer, or one that cannot be read is a skip with the reason.
20649
21139
  */
20650
21140
  const PROBE = "token";
20651
- const row$16 = (id, title, status, detail, problems = []) => ({
21141
+ const row$19 = (id, title, status, detail, problems = []) => ({
20652
21142
  id,
20653
21143
  title,
20654
21144
  status,
@@ -20673,12 +21163,12 @@ async function runDoctorTokens(input) {
20673
21163
  try {
20674
21164
  tokens = await providerTokens(provider);
20675
21165
  } catch (err) {
20676
- rows.push(row$16(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
21166
+ rows.push(row$19(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
20677
21167
  continue;
20678
21168
  }
20679
21169
  const expectations = tokenExpectations(tokens);
20680
- if (expectations.length === 0) rows.push(row$16(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
20681
- else if (!usableProbe(probes.get(provider))) rows.push(row$16(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
21170
+ if (expectations.length === 0) rows.push(row$19(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
21171
+ else if (!usableProbe(probes.get(provider))) rows.push(row$19(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
20682
21172
  else declared.push({
20683
21173
  provider,
20684
21174
  tokens,
@@ -20740,14 +21230,14 @@ async function checkLayer(c) {
20740
21230
  tokens
20741
21231
  });
20742
21232
  } catch (err) {
20743
- if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$16(id(e), title(e), "fail", "not held in this layer", [err.message]));
20744
- return c.wanted.map((e) => row$16(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
21233
+ if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$19(id(e), title(e), "fail", "not held in this layer", [err.message]));
21234
+ return c.wanted.map((e) => row$19(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
20745
21235
  }
20746
21236
  const rows = [];
20747
21237
  for (const e of c.wanted) {
20748
21238
  const token = held.held.find((h) => h.envName === e.envName);
20749
21239
  if (!token) {
20750
- rows.push(row$16(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
21240
+ rows.push(row$19(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
20751
21241
  continue;
20752
21242
  }
20753
21243
  rows.push(summariseProbeRows(id(e), title(e), await probeToken(c, e, token.token, held.plain)));
@@ -20820,7 +21310,7 @@ const doctorTokensCommand = {
20820
21310
  }
20821
21311
  };
20822
21312
  // src/commands/doctor-wiki/wiki-rows.ts
20823
- const row$15 = (id, title, status, detail, problems = []) => ({
21313
+ const row$18 = (id, title, status, detail, problems = []) => ({
20824
21314
  id,
20825
21315
  title,
20826
21316
  status,
@@ -20836,11 +21326,11 @@ const names = (paths) => paths.length > LISTED ? `${paths.slice(0, LISTED).join(
20836
21326
  * skip, since a machine with no network says nothing about the site.
20837
21327
  */
20838
21328
  function siteRow(id, title, probe, notFoundHint) {
20839
- if (probe.status === void 0) return row$15(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
20840
- if (probe.status < 400) return row$15(id, title, "ok", `${probe.url} answers ${probe.status}`);
20841
- if (probe.status === 401 || probe.status === 403) return row$15(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
21329
+ if (probe.status === void 0) return row$18(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
21330
+ if (probe.status < 400) return row$18(id, title, "ok", `${probe.url} answers ${probe.status}`);
21331
+ if (probe.status === 401 || probe.status === 403) return row$18(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
20842
21332
  const problem = probe.status === 404 ? `${probe.url} answers 404; ${notFoundHint}` : `${probe.url} answers ${probe.status}, expected a page`;
20843
- return row$15(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
21333
+ return row$18(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
20844
21334
  }
20845
21335
  /**
20846
21336
  * The rows `holocron doctor wiki` prints for one {@link WikiInspection}: organization, docs instance, the site and its
@@ -20852,42 +21342,42 @@ function wikiRows(found, providerName) {
20852
21342
  const { declared, found: foundOrg } = found.organization;
20853
21343
  if (foundOrg === null) {
20854
21344
  const problem = `fern/fern.config.json has no organization; \`holocron setup\` writes it`;
20855
- rows.push(row$15("wiki:organization", "organization is set", "fail", problem, [problem]));
21345
+ rows.push(row$18("wiki:organization", "organization is set", "fail", problem, [problem]));
20856
21346
  } else if (foundOrg !== declared) {
20857
21347
  const problem = `fern/fern.config.json names ${foundOrg}, the config declares ${declared}; run \`holocron setup\``;
20858
- rows.push(row$15("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
20859
- } else rows.push(row$15("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
21348
+ rows.push(row$18("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
21349
+ } else rows.push(row$18("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
20860
21350
  const instance = found.instance;
20861
21351
  if (instance === null) {
20862
21352
  const problem = "fern/docs.yml does not exist; `holocron setup` writes it";
20863
- rows.push(row$15("wiki:instance", "docs site is declared", "fail", problem, [problem]));
21353
+ rows.push(row$18("wiki:instance", "docs site is declared", "fail", problem, [problem]));
20864
21354
  } else {
20865
21355
  const problems = [];
20866
21356
  if (instance.foundUrl !== instance.expectedUrl) problems.push(`instance url is ${instance.foundUrl ?? "not set"}, expected ${instance.expectedUrl}`);
20867
21357
  if (instance.expectedDomain !== void 0 && instance.foundDomain !== instance.expectedDomain) problems.push(`custom-domain is ${instance.foundDomain ?? "not set"}, expected ${instance.expectedDomain}`);
20868
- rows.push(problems.length > 0 ? row$15("wiki:instance", "docs site is declared", "fail", `${problems.length} problem(s)`, [...problems.map((p) => `fern/docs.yml: ${p}`)]) : row$15("wiki:instance", "docs site is declared", "ok", `${instance.expectedUrl} in fern/docs.yml`));
21358
+ rows.push(problems.length > 0 ? row$18("wiki:instance", "docs site is declared", "fail", `${problems.length} problem(s)`, [...problems.map((p) => `fern/docs.yml: ${p}`)]) : row$18("wiki:instance", "docs site is declared", "ok", `${instance.expectedUrl} in fern/docs.yml`));
20869
21359
  }
20870
21360
  const [site, domain] = found.site;
20871
21361
  if (site) rows.push(siteRow("wiki:site", "docs site answers", site, `the organization or its docs are not published; run the wiki workflow (\`fern generate --docs\`)`));
20872
21362
  if (domain) rows.push(siteRow("wiki:domain", "custom domain answers", domain, `check the ${providerName} dashboard for the domain and \`holocron doctor dns\` for its record`));
20873
- if (found.navigation === null) rows.push(row$15("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
21363
+ if (found.navigation === null) rows.push(row$18("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
20874
21364
  else if (found.navigation.missing.length > 0) {
20875
21365
  const problems = found.navigation.missing.map((p) => `${p} is listed in fern/docs.yml but is not on disk`);
20876
- rows.push(row$15("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
21366
+ rows.push(row$18("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
20877
21367
  } else {
20878
- rows.push(row$15("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
20879
- if (found.navigation.unlisted.length > 0) rows.push(row$15("wiki:unlisted", "pages under docs/wiki are listed", "skip", `info: ${found.navigation.unlisted.length} not in the navigation (${names(found.navigation.unlisted)}); they are not published`));
21368
+ rows.push(row$18("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
21369
+ if (found.navigation.unlisted.length > 0) rows.push(row$18("wiki:unlisted", "pages under docs/wiki are listed", "skip", `info: ${found.navigation.unlisted.length} not in the navigation (${names(found.navigation.unlisted)}); they are not published`));
20880
21370
  }
20881
21371
  const published = found.published;
20882
21372
  const listed = found.navigation?.listed;
20883
- if (!published) rows.push(row$15("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
21373
+ if (!published) rows.push(row$18("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
20884
21374
  else if (published.pages === void 0) {
20885
21375
  const why = published.status === void 0 ? published.error ?? "no answer" : `answered ${published.status}`;
20886
- rows.push(row$15("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
21376
+ rows.push(row$18("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
20887
21377
  } else if (listed !== void 0 && published.pages < listed) {
20888
21378
  const problem = `${published.url} lists ${published.pages} page(s), the navigation lists ${listed}; the last publish is behind (run the wiki workflow)`;
20889
- rows.push(row$15("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
20890
- } else rows.push(row$15("wiki:published", "published pages", "ok", listed === void 0 ? `${published.pages} page(s) in ${published.url}` : `${published.pages} page(s) published for ${listed} listed`));
21379
+ rows.push(row$18("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
21380
+ } else rows.push(row$18("wiki:published", "published pages", "ok", listed === void 0 ? `${published.pages} page(s) in ${published.url}` : `${published.pages} page(s) published for ${listed} listed`));
20891
21381
  return rows;
20892
21382
  }
20893
21383
  // src/commands/doctor-wiki/doctor-wiki.ts
@@ -20993,7 +21483,7 @@ function readFailureRow(id, title, err) {
20993
21483
  };
20994
21484
  }
20995
21485
  // src/commands/doctor-workers/check-project.ts
20996
- const row$14 = (id, title, status, detail, problems = []) => ({
21486
+ const row$17 = (id, title, status, detail, problems = []) => ({
20997
21487
  id,
20998
21488
  title,
20999
21489
  status,
@@ -21022,30 +21512,30 @@ async function checkProject(deploy, declared) {
21022
21512
  let exists = false;
21023
21513
  try {
21024
21514
  exists = (await deploy.listProjects()).some((p) => same$1(p.name, project) || p.id === project);
21025
- rows.push(exists ? row$14(ids.exists, titles.exists, "ok", `${project} on ${deploy.providerName}`) : row$14(ids.exists, titles.exists, "fail", "not found", [`no project ${project} on ${deploy.providerName}; \`holocron setup\` makes it`]));
21515
+ rows.push(exists ? row$17(ids.exists, titles.exists, "ok", `${project} on ${deploy.providerName}`) : row$17(ids.exists, titles.exists, "fail", "not found", [`no project ${project} on ${deploy.providerName}; \`holocron setup\` makes it`]));
21026
21516
  } catch (err) {
21027
21517
  rows.push(readFailureRow(ids.exists, titles.exists, err));
21028
21518
  }
21029
21519
  const notChecked = (reason) => `not checked: ${reason}`;
21030
21520
  const gone = exists ? void 0 : "the project is not readable or not there";
21031
- if (declared.hostname === void 0) {} else if (gone) rows.push(row$14(ids.domain, titles.domain, "skip", notChecked(gone)));
21032
- else if (!deploy.listDomains) rows.push(row$14(ids.domain, titles.domain, "skip", `the \`${deploy.providerName}\` provider cannot list domains`));
21521
+ if (declared.hostname === void 0) {} else if (gone) rows.push(row$17(ids.domain, titles.domain, "skip", notChecked(gone)));
21522
+ else if (!deploy.listDomains) rows.push(row$17(ids.domain, titles.domain, "skip", `the \`${deploy.providerName}\` provider cannot list domains`));
21033
21523
  else try {
21034
21524
  const attached = await deploy.listDomains(project);
21035
- rows.push(attached.some((d) => same$1(d, declared.hostname)) ? row$14(ids.domain, titles.domain, "ok", `${declared.hostname} attached`) : row$14(ids.domain, titles.domain, "fail", `${declared.hostname} not attached`, [`${declared.hostname} is not a domain of ${project}; \`holocron setup\` attaches it`]));
21525
+ rows.push(attached.some((d) => same$1(d, declared.hostname)) ? row$17(ids.domain, titles.domain, "ok", `${declared.hostname} attached`) : row$17(ids.domain, titles.domain, "fail", `${declared.hostname} not attached`, [`${declared.hostname} is not a domain of ${project}; \`holocron setup\` attaches it`]));
21036
21526
  } catch (err) {
21037
21527
  rows.push(readFailureRow(ids.domain, titles.domain, err));
21038
21528
  }
21039
- if (gone) rows.push(row$14(ids.deploy, titles.deploy, "skip", notChecked(gone)));
21040
- else if (!deploy.latestDeployment) rows.push(row$14(ids.deploy, titles.deploy, "skip", `the \`${deploy.providerName}\` provider cannot list deployments`));
21529
+ if (gone) rows.push(row$17(ids.deploy, titles.deploy, "skip", notChecked(gone)));
21530
+ else if (!deploy.latestDeployment) rows.push(row$17(ids.deploy, titles.deploy, "skip", `the \`${deploy.providerName}\` provider cannot list deployments`));
21041
21531
  else try {
21042
21532
  const latest = await deploy.latestDeployment(project);
21043
- if (!latest) rows.push(row$14(ids.deploy, titles.deploy, "skip", "no production deployment yet"));
21044
- else if (latest.status === "ready") rows.push(row$14(ids.deploy, titles.deploy, "ok", latest.createdAt ? `ready, ${latest.createdAt}` : "ready"));
21533
+ if (!latest) rows.push(row$17(ids.deploy, titles.deploy, "skip", "no production deployment yet"));
21534
+ else if (latest.status === "ready") rows.push(row$17(ids.deploy, titles.deploy, "ok", latest.createdAt ? `ready, ${latest.createdAt}` : "ready"));
21045
21535
  else if (latest.status === "error") {
21046
21536
  const why = latest.errorMessage ? `: ${latest.errorMessage}` : "";
21047
- rows.push(row$14(ids.deploy, titles.deploy, "fail", "the newest deployment errored", [`the newest production deployment of ${project} failed${why}`]));
21048
- } else rows.push(row$14(ids.deploy, titles.deploy, "skip", `info: the newest deployment is ${latest.status}`));
21537
+ rows.push(row$17(ids.deploy, titles.deploy, "fail", "the newest deployment errored", [`the newest production deployment of ${project} failed${why}`]));
21538
+ } else rows.push(row$17(ids.deploy, titles.deploy, "skip", `info: the newest deployment is ${latest.status}`));
21049
21539
  } catch (err) {
21050
21540
  rows.push(readFailureRow(ids.deploy, titles.deploy, err));
21051
21541
  }
@@ -21053,7 +21543,7 @@ async function checkProject(deploy, declared) {
21053
21543
  }
21054
21544
  // src/commands/doctor-workers/check-worker.ts
21055
21545
  const same = (a, b) => a.toLowerCase() === b.toLowerCase();
21056
- const row$13 = (id, title, status, detail, problems = []) => ({
21546
+ const row$16 = (id, title, status, detail, problems = []) => ({
21057
21547
  id,
21058
21548
  title,
21059
21549
  status,
@@ -21078,9 +21568,9 @@ async function checkWorker(workers, worker) {
21078
21568
  deploy: `${name} Worker's latest deployment is healthy`
21079
21569
  };
21080
21570
  const skipAll = (reason) => [
21081
- row$13(ids.deployed, titles.deployed, "skip", reason),
21082
- row$13(ids.bindings, titles.bindings, "skip", reason),
21083
- row$13(ids.deploy, titles.deploy, "skip", reason)
21571
+ row$16(ids.deployed, titles.deployed, "skip", reason),
21572
+ row$16(ids.bindings, titles.bindings, "skip", reason),
21573
+ row$16(ids.deploy, titles.deploy, "skip", reason)
21084
21574
  ];
21085
21575
  if (worker.script === void 0) return skipAll(`${workers.providerName} does not say how it names this Worker`);
21086
21576
  const script = worker.script;
@@ -21093,29 +21583,29 @@ async function checkWorker(workers, worker) {
21093
21583
  exists = state.exists;
21094
21584
  if (!state.exists) {
21095
21585
  const problem = `no Worker named ${script}; \`holocron setup\` deploys it`;
21096
- rows.push(row$13(ids.deployed, titles.deployed, "fail", `${script} not deployed`, [problem]), row$13(ids.bindings, titles.bindings, "skip", `not checked: no Worker named ${script}`));
21586
+ rows.push(row$16(ids.deployed, titles.deployed, "fail", `${script} not deployed`, [problem]), row$16(ids.bindings, titles.bindings, "skip", `not checked: no Worker named ${script}`));
21097
21587
  } else {
21098
- rows.push(state.routes.some((r) => same(r, route)) ? row$13(ids.deployed, titles.deployed, "ok", `${script} serves ${route}`) : row$13(ids.deployed, titles.deployed, "fail", `no route ${route}`, [`${script} has no route ${route}`]));
21099
- if (worker.bindings.length === 0) rows.push(row$13(ids.bindings, titles.bindings, "ok", "none declared"));
21588
+ rows.push(state.routes.some((r) => same(r, route)) ? row$16(ids.deployed, titles.deployed, "ok", `${script} serves ${route}`) : row$16(ids.deployed, titles.deployed, "fail", `no route ${route}`, [`${script} has no route ${route}`]));
21589
+ if (worker.bindings.length === 0) rows.push(row$16(ids.bindings, titles.bindings, "ok", "none declared"));
21100
21590
  else {
21101
21591
  const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
21102
21592
  const missing = worker.bindings.filter((n) => !bound.has(n.toUpperCase()));
21103
- rows.push(missing.length === 0 ? row$13(ids.bindings, titles.bindings, "ok", `${worker.bindings.length} of ${worker.bindings.length} bound`) : row$13(ids.bindings, titles.bindings, "fail", `${missing.length} not bound`, missing.map((n) => `${n}: not bound`)));
21593
+ rows.push(missing.length === 0 ? row$16(ids.bindings, titles.bindings, "ok", `${worker.bindings.length} of ${worker.bindings.length} bound`) : row$16(ids.bindings, titles.bindings, "fail", `${missing.length} not bound`, missing.map((n) => `${n}: not bound`)));
21104
21594
  }
21105
21595
  }
21106
21596
  } catch (err) {
21107
21597
  const failure = readFailureRow(ids.deployed, titles.deployed, err);
21108
- rows.push(failure, row$13(ids.bindings, titles.bindings, "skip", "not checked: could not read the Worker"));
21598
+ rows.push(failure, row$16(ids.bindings, titles.bindings, "skip", "not checked: could not read the Worker"));
21109
21599
  }
21110
- if (!exists) rows.push(row$13(ids.deploy, titles.deploy, "skip", "not checked: the Worker is not readable or not there"));
21111
- else if (!workers.latestDeployment) rows.push(row$13(ids.deploy, titles.deploy, "skip", `the \`${workers.providerName}\` provider cannot list deployments`));
21600
+ if (!exists) rows.push(row$16(ids.deploy, titles.deploy, "skip", "not checked: the Worker is not readable or not there"));
21601
+ else if (!workers.latestDeployment) rows.push(row$16(ids.deploy, titles.deploy, "skip", `the \`${workers.providerName}\` provider cannot list deployments`));
21112
21602
  else try {
21113
21603
  const latest = await workers.latestDeployment(script);
21114
- if (!latest) rows.push(row$13(ids.deploy, titles.deploy, "skip", `${script} has no recorded deployment`));
21604
+ if (!latest) rows.push(row$16(ids.deploy, titles.deploy, "skip", `${script} has no recorded deployment`));
21115
21605
  else if (!latest.active) {
21116
21606
  const problem = `the newest deployment of ${script} does not serve all traffic`;
21117
- rows.push(row$13(ids.deploy, titles.deploy, "fail", "not serving all traffic", [problem]));
21118
- } else rows.push(row$13(ids.deploy, titles.deploy, "ok", latest.createdAt ? `deployed ${latest.createdAt}` : "serving all traffic"));
21607
+ rows.push(row$16(ids.deploy, titles.deploy, "fail", "not serving all traffic", [problem]));
21608
+ } else rows.push(row$16(ids.deploy, titles.deploy, "ok", latest.createdAt ? `deployed ${latest.createdAt}` : "serving all traffic"));
21119
21609
  } catch (err) {
21120
21610
  rows.push(readFailureRow(ids.deploy, titles.deploy, err));
21121
21611
  }
@@ -21179,7 +21669,7 @@ function declaredWorkers(input) {
21179
21669
  * custom domain is attached, and the newest production deployment is ready. Only what the provider proves wrong
21180
21670
  * fails; a missing token, a 401 or 403, or a provider that cannot read it is a skip with the reason.
21181
21671
  */
21182
- const row$12 = (id, title, status, detail) => ({
21672
+ const row$15 = (id, title, status, detail) => ({
21183
21673
  id,
21184
21674
  title,
21185
21675
  status,
@@ -21205,12 +21695,12 @@ async function runDoctorWorkers(input) {
21205
21695
  ...loader.has("wiki") ? { wiki: loader.get("wiki") } : {},
21206
21696
  ...workers ? { workers } : {}
21207
21697
  });
21208
- if (declared.length === 0) rows.push(row$12("workers", "declared Workers", "ok", "none declared"));
21698
+ if (declared.length === 0) rows.push(row$15("workers", "declared Workers", "ok", "none declared"));
21209
21699
  else if (!workers) {
21210
21700
  const why = whyNone(loader, "workers", "no `workers` provider is configured in holocron.config.ts");
21211
- for (const worker of declared) rows.push(row$12(`workers:${worker.label}`, `${worker.label} Worker`, "skip", why));
21701
+ for (const worker of declared) rows.push(row$15(`workers:${worker.label}`, `${worker.label} Worker`, "skip", why));
21212
21702
  } else for (const worker of declared) rows.push(...await checkWorker(workers, worker));
21213
- if (!loader.has("deployment")) rows.push(row$12("deployment", "deployment project", "skip", whyNone(loader, "deployment", "no `deployment` provider is configured in holocron.config.ts")));
21703
+ if (!loader.has("deployment")) rows.push(row$15("deployment", "deployment project", "skip", whyNone(loader, "deployment", "no `deployment` provider is configured in holocron.config.ts")));
21214
21704
  else {
21215
21705
  const deploy = loader.get("deployment");
21216
21706
  for (const project of declaredProjects(input.loaded.resolved, deploy)) rows.push(...await checkProject(deploy, project));
@@ -21264,6 +21754,19 @@ const DEEP_CHECKS = [
21264
21754
  };
21265
21755
  }
21266
21756
  },
21757
+ {
21758
+ name: "agent",
21759
+ capability: "vault",
21760
+ command: doctorAgentCommand,
21761
+ async run(input) {
21762
+ const report = await runDoctorAgent(input);
21763
+ return {
21764
+ status: report.status,
21765
+ summary: report.summary,
21766
+ ...report.reason ? { reason: report.reason } : {}
21767
+ };
21768
+ }
21769
+ },
21267
21770
  {
21268
21771
  name: "environments",
21269
21772
  capability: "environments",
@@ -22194,7 +22697,7 @@ function resolveExportDir(input) {
22194
22697
  * listed under the provider's row and does not fail the run. It writes files, so it asks first unless `--dry-run` (the
22195
22698
  * files are converted and listed, nothing is written) or `--yes` (without a terminal it refuses instead).
22196
22699
  */
22197
- const row$11 = (id, status, detail, problems = []) => ({
22700
+ const row$14 = (id, status, detail, problems = []) => ({
22198
22701
  id,
22199
22702
  title: id,
22200
22703
  status,
@@ -22236,9 +22739,9 @@ async function runRequestsExport(input) {
22236
22739
  print("");
22237
22740
  const entry = input.loaded.resolved.providers.tooling;
22238
22741
  const tuples = entry?.cardinality === "many" ? entry.tuples : [];
22239
- if (tuples.length === 0) return finish([row$11("tooling", "fail", "the config has no `tooling` provider to export for")]);
22742
+ if (tuples.length === 0) return finish([row$14("tooling", "fail", "the config has no `tooling` provider to export for")]);
22240
22743
  const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
22241
- if (chosen.length === 0) return finish([row$11(input.to, "fail", `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`)]);
22744
+ if (chosen.length === 0) return finish([row$14(input.to, "fail", `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`)]);
22242
22745
  /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
22243
22746
  const loader = input.loader ?? new PluginLoader({
22244
22747
  ...input.loaded.resolved,
@@ -22258,17 +22761,17 @@ async function runRequestsExport(input) {
22258
22761
  const tool = loaded.find((t) => t.providerName === id);
22259
22762
  if (!tool) {
22260
22763
  const failure = loader.loadFailures().find((f) => f.key === "tooling" && f.provider === id);
22261
- rows.push(row$11(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
22764
+ rows.push(row$14(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
22262
22765
  continue;
22263
22766
  }
22264
22767
  if (!tool.export) {
22265
- rows.push(row$11(id, "skip", "has no export: it reads the repo's files as they are"));
22768
+ rows.push(row$14(id, "skip", "has no export: it reads the repo's files as they are"));
22266
22769
  continue;
22267
22770
  }
22268
22771
  const collectionFiles = fileList$1(tuple.options.collectionFiles);
22269
22772
  const envFiles = fileList$1(tuple.options.envFiles);
22270
22773
  if (collectionFiles.length === 0) {
22271
- rows.push(row$11(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
22774
+ rows.push(row$14(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
22272
22775
  continue;
22273
22776
  }
22274
22777
  const groups = input.out === void 0 ? groupByFolder(collectionFiles) : [collectionFiles];
@@ -22282,7 +22785,7 @@ async function runRequestsExport(input) {
22282
22785
  ...input.out !== void 0 ? { out: input.out } : {}
22283
22786
  });
22284
22787
  if (!dir.ok) {
22285
- rows.push(row$11(label, "fail", dir.message));
22788
+ rows.push(row$14(label, "fail", dir.message));
22286
22789
  continue;
22287
22790
  }
22288
22791
  targets.push({
@@ -22321,9 +22824,9 @@ async function runRequestsExport(input) {
22321
22824
  const where = relative(repoRoot, outDir);
22322
22825
  const files = result.files.length > 0 ? ` (${result.files.join(", ")})` : "";
22323
22826
  paths.push(...result.files.map((file) => resolve(outDir, file)));
22324
- rows.push(row$11(label, "ok", `${dryRun ? "would write" : "wrote"} ${result.files.length} file(s) to ${where}${files}`, result.issues.map((issue) => `issue in ${issue.file}: ${issue.message}`)));
22827
+ rows.push(row$14(label, "ok", `${dryRun ? "would write" : "wrote"} ${result.files.length} file(s) to ${where}${files}`, result.issues.map((issue) => `issue in ${issue.file}: ${issue.message}`)));
22325
22828
  } catch (err) {
22326
- rows.push(row$11(label, "fail", describeError(err)));
22829
+ rows.push(row$14(label, "fail", describeError(err)));
22327
22830
  }
22328
22831
  const report = finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
22329
22832
  if (paths.length > 0) {
@@ -22838,10 +23341,10 @@ async function agentsFile(root) {
22838
23341
  for (const name of ["AGENTS.md", "CLAUDE.md"]) if ((await lstat(join(root, name)).catch(() => null))?.isFile()) return name;
22839
23342
  return null;
22840
23343
  }
22841
- const isObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
23344
+ const isObject$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
22842
23345
  /** Whether a hook entry already runs `dcg`, with or without arguments (`dcg`, `dcg --strict`, a path ending in `/dcg`). */
22843
23346
  function runsDcg(hook) {
22844
- if (!isObject$1(hook) || typeof hook.command !== "string") return false;
23347
+ if (!isObject$2(hook) || typeof hook.command !== "string") return false;
22845
23348
  const program = hook.command.trim().split(/\s+/)[0];
22846
23349
  return program === "dcg" || program.endsWith(`/dcg`);
22847
23350
  }
@@ -22852,13 +23355,13 @@ function runsDcg(hook) {
22852
23355
  * that is not an object or a list), so a hand-edited file is never silently replaced.
22853
23356
  */
22854
23357
  function withDcgHook(settings) {
22855
- if (!isObject$1(settings)) throw new Error("the settings file is not a JSON object");
23358
+ if (!isObject$2(settings)) throw new Error("the settings file is not a JSON object");
22856
23359
  const hooks = settings.hooks ?? {};
22857
- if (!isObject$1(hooks)) throw new Error("`hooks` in the settings file is not an object");
23360
+ if (!isObject$2(hooks)) throw new Error("`hooks` in the settings file is not an object");
22858
23361
  const listed = hooks.PreToolUse ?? [];
22859
23362
  if (!Array.isArray(listed)) throw new Error("`hooks.PreToolUse` in the settings file is not a list");
22860
23363
  const preToolUse = listed;
22861
- if (preToolUse.some((entry) => isObject$1(entry) && entry.matcher === "Bash" && Array.isArray(entry.hooks) && entry.hooks.some(runsDcg))) return settings;
23364
+ if (preToolUse.some((entry) => isObject$2(entry) && entry.matcher === "Bash" && Array.isArray(entry.hooks) && entry.hooks.some(runsDcg))) return settings;
22862
23365
  return {
22863
23366
  ...settings,
22864
23367
  hooks: {
@@ -22873,17 +23376,52 @@ function withDcgHook(settings) {
22873
23376
  }
22874
23377
  };
22875
23378
  }
23379
+ // src/commands/repo-files/with-deny-read.ts
23380
+ const isObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
23381
+ /** The permission rule that refuses Claude's read tool a path. */
23382
+ const denyReadRule = (path) => `Read(${path})`;
23383
+ /**
23384
+ * `settings` with a `Read(<path>)` rule in `permissions.deny` for each path (spec `tech-agent-secrets`), and everything
23385
+ * else in it exactly as it was, the rules already there included. A rule that is already listed is not added again, so a
23386
+ * second run changes nothing. Throws on a file whose shape cannot hold the rules (`permissions` that is not an object,
23387
+ * `permissions.deny` that is not a list), so a hand-edited file is never silently replaced.
23388
+ *
23389
+ * @param settings - The parsed `.claude/settings.json`.
23390
+ * @param paths - The paths an agent may not read, such as `~/.config/holocron/**`.
23391
+ */
23392
+ function withDenyRead(settings, paths) {
23393
+ if (!isObject$1(settings)) throw new Error("the settings file is not a JSON object");
23394
+ const permissions = settings.permissions ?? {};
23395
+ if (!isObject$1(permissions)) throw new Error("`permissions` in the settings file is not an object");
23396
+ const listed = permissions.deny ?? [];
23397
+ if (!Array.isArray(listed)) throw new Error("`permissions.deny` in the settings file is not a list");
23398
+ const deny = listed;
23399
+ const missing = paths.map(denyReadRule).filter((rule) => !deny.includes(rule));
23400
+ if (missing.length === 0) return settings;
23401
+ return {
23402
+ ...settings,
23403
+ permissions: {
23404
+ ...permissions,
23405
+ deny: [...deny, ...missing]
23406
+ }
23407
+ };
23408
+ }
22876
23409
  // src/commands/repo-files/generate-claude-files.ts
22877
23410
  const CLAUDE_SETTINGS_FILE = ".claude/settings.json";
22878
23411
  /**
22879
- * `.claude/settings.json` with the `dcg` `PreToolUse` hook, for a repo whose config opts in with `agent: ["claude", { dcg: true }]`. The file
22880
- * already on disk is merged, so a repo's own `permissions` and hooks are kept; the same bytes come out of `setup` and
22881
- * `sync`, and `probe generated check` fails when the hook is missing. A repo that does not opt in gets nothing (no
22882
- * step, no file), so the repos that never used it are unchanged. A file that is not valid JSON, or has a shape that
22883
- * cannot hold the hook, is a failed step naming the file; it is never overwritten.
23412
+ * `.claude/settings.json` for a repo whose config opts in with `agent: ["claude", { dcg: true }]` (the `dcg` `PreToolUse`
23413
+ * hook on Bash calls), `denyRead: [...]` (a `Read(<path>)` rule in `permissions.deny` for each path, spec
23414
+ * `tech-agent-secrets`) or both. The file already on disk is merged, so a repo's own `permissions` and hooks are kept; the
23415
+ * same bytes come out of `setup` and `sync`, and `probe generated check` fails when the hook or a rule is missing. A repo
23416
+ * that opts in to neither gets nothing (no step, no file), so the repos that never used it are unchanged. A file that is
23417
+ * not valid JSON, or has a shape that cannot hold what is asked, is a failed step naming the file; it is never
23418
+ * overwritten.
22884
23419
  */
22885
23420
  async function generateClaudeFiles(input) {
22886
- if (input.loaded.resolved.agentOptions?.dcg !== true) return [];
23421
+ const options = input.loaded.resolved.agentOptions;
23422
+ const dcg = options?.dcg === true;
23423
+ const denyRead = options?.denyRead ?? [];
23424
+ if (!dcg && denyRead.length === 0) return [];
22887
23425
  const step = `write ${CLAUDE_SETTINGS_FILE}`;
22888
23426
  const text = await readFile(join(input.repoRoot, CLAUDE_SETTINGS_FILE), "utf8").catch(() => void 0);
22889
23427
  let existing = {};
@@ -22898,14 +23436,16 @@ async function generateClaudeFiles(input) {
22898
23436
  }];
22899
23437
  }
22900
23438
  try {
22901
- const content = formatJson(withDcgHook(existing));
23439
+ const withHook = dcg ? withDcgHook(existing) : existing;
23440
+ const content = formatJson(denyRead.length > 0 ? withDenyRead(withHook, denyRead) : withHook);
23441
+ const note = [dcg ? "dcg PreToolUse hook" : void 0, denyRead.length > 0 ? "read deny rules" : void 0].filter(Boolean).join(", ");
22902
23442
  return [{
22903
23443
  kind: "file",
22904
23444
  path: CLAUDE_SETTINGS_FILE,
22905
23445
  content,
22906
23446
  step,
22907
23447
  syncStep: step,
22908
- note: "dcg PreToolUse hook"
23448
+ note
22909
23449
  }];
22910
23450
  } catch (err) {
22911
23451
  return [{
@@ -26619,7 +27159,7 @@ function specName(title, name) {
26619
27159
  */
26620
27160
  /** How many lines of the spec a dry run shows. */
26621
27161
  const PREVIEW_LINES$1 = 12;
26622
- const row$10 = (id, status, detail) => ({
27162
+ const row$13 = (id, status, detail) => ({
26623
27163
  id,
26624
27164
  title: id,
26625
27165
  status,
@@ -26649,7 +27189,7 @@ async function runIdeasPromote(input) {
26649
27189
  print(style.header(`Holocron new spec${dryRun ? " (dry-run)" : ""}`));
26650
27190
  print("");
26651
27191
  const entry = input.loaded.resolved.providers.issues;
26652
- if (!entry) return finish([row$10(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
27192
+ if (!entry) return finish([row$13(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
26653
27193
  const credentials = input.loaded.resolved.providers.credentials;
26654
27194
  /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
26655
27195
  const loader = input.loader ?? new PluginLoader({
@@ -26664,18 +27204,18 @@ async function runIdeasPromote(input) {
26664
27204
  assertPluginsResolvable(loader, "new spec");
26665
27205
  if (!loader.has("issues")) {
26666
27206
  const failure = loader.loadFailures().find((f) => f.key === "issues");
26667
- return finish([row$10(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
27207
+ return finish([row$13(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
26668
27208
  }
26669
27209
  let issue;
26670
27210
  try {
26671
27211
  issue = await loader.get("issues").get(input.issue);
26672
27212
  } catch (err) {
26673
- return finish([row$10(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
27213
+ return finish([row$13(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
26674
27214
  }
26675
27215
  const name = specName(issue.summary, input.name);
26676
- if (!name) return finish([row$10(issue.key, "fail", input.name === void 0 ? "no spec name can be made from the title; pass --name" : `"${input.name}" is not a spec name: use lower-case words joined by hyphens, such as tech-my-topic`)]);
27216
+ if (!name) return finish([row$13(issue.key, "fail", input.name === void 0 ? "no spec name can be made from the title; pass --name" : `"${input.name}" is not a spec name: use lower-case words joined by hyphens, such as tech-my-topic`)]);
26677
27217
  const relative = join(".notes", `${name}.spec.md`);
26678
- if (io.exists(join(input.context.repoRoot, relative))) return finish([row$10(relative, "fail", "the spec already exists; it is never overwritten")], relative);
27218
+ if (io.exists(join(input.context.repoRoot, relative))) return finish([row$13(relative, "fail", "the spec already exists; it is never overwritten")], relative);
26679
27219
  const { org, name: repoName } = input.loaded.resolved;
26680
27220
  const ref = githubRef(issue.url) ?? (issue.key.startsWith("#") ? `${org}/${repoName}${issue.key}` : issue.key);
26681
27221
  const { content, fromIdea } = buildSpec({
@@ -26688,7 +27228,7 @@ async function runIdeasPromote(input) {
26688
27228
  print(` ${relative}`);
26689
27229
  for (const line of content.split("\n").slice(0, PREVIEW_LINES$1)) print(` ${style.skip(line)}`);
26690
27230
  print("");
26691
- return finish([row$10(relative, "skip", `would write the spec ${origin}`)], relative);
27231
+ return finish([row$13(relative, "skip", `would write the spec ${origin}`)], relative);
26692
27232
  }
26693
27233
  if (!input.yes) {
26694
27234
  if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`new spec\` writes ${relative}; pass --yes to run it without asking, or --dry-run to preview`);
@@ -26707,9 +27247,9 @@ async function runIdeasPromote(input) {
26707
27247
  try {
26708
27248
  io.write(join(input.context.repoRoot, relative), content);
26709
27249
  } catch (err) {
26710
- return finish([row$10(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
27250
+ return finish([row$13(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
26711
27251
  }
26712
- return finish([row$10(relative, "ok", `wrote the spec ${origin}`)], relative);
27252
+ return finish([row$13(relative, "ok", `wrote the spec ${origin}`)], relative);
26713
27253
  }
26714
27254
  // src/commands/ideas-promote/ideas-promote.command.ts
26715
27255
  const ideasPromoteCommand = {
@@ -26785,7 +27325,7 @@ function readIssueBody(file, cwd, read = (p) => readFileSync(p, "utf8")) {
26785
27325
  */
26786
27326
  /** How many lines of the body a dry run shows. */
26787
27327
  const PREVIEW_LINES = 8;
26788
- const row$9 = (id, status, detail) => ({
27328
+ const row$12 = (id, status, detail) => ({
26789
27329
  id,
26790
27330
  title: id,
26791
27331
  status,
@@ -26809,11 +27349,11 @@ async function runIssueCreate(input) {
26809
27349
  print(style.header(`Holocron new issue${dryRun ? " (dry-run)" : ""}`));
26810
27350
  print("");
26811
27351
  const title = input.title.trim();
26812
- if (!title) return finish([row$9("title", "fail", "the title is empty")]);
27352
+ if (!title) return finish([row$12("title", "fail", "the title is empty")]);
26813
27353
  const prepared = prepareIssueFields(input, input.loaded.resolved.repo?.labels?.areas);
26814
- if (!prepared.ok) return finish(prepared.problems.map((p) => row$9(title, "fail", p)));
27354
+ if (!prepared.ok) return finish(prepared.problems.map((p) => row$12(title, "fail", p)));
26815
27355
  const entry = input.loaded.resolved.providers.issues;
26816
- if (!entry) return finish([row$9(title, "fail", "the config has no `issues` provider to file the issue with")]);
27356
+ if (!entry) return finish([row$12(title, "fail", "the config has no `issues` provider to file the issue with")]);
26817
27357
  const credentials = input.loaded.resolved.providers.credentials;
26818
27358
  const projects = prepared.project ? input.loaded.resolved.providers.projects : void 0;
26819
27359
  /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
@@ -26830,7 +27370,7 @@ async function runIssueCreate(input) {
26830
27370
  assertPluginsResolvable(loader, "new issue");
26831
27371
  if (!loader.has("issues")) {
26832
27372
  const failure = loader.loadFailures().find((f) => f.key === "issues");
26833
- return finish([row$9(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
27373
+ return finish([row$12(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
26834
27374
  }
26835
27375
  const labels = [.../* @__PURE__ */ new Set([...(input.labels ?? []).map((l) => l.trim()).filter(Boolean), ...prepared.areaLabels])];
26836
27376
  const body = input.body?.trim() ? input.body : void 0;
@@ -26847,7 +27387,7 @@ async function runIssueCreate(input) {
26847
27387
  print(` ${title}`);
26848
27388
  for (const line of body ? body.split("\n").slice(0, PREVIEW_LINES) : []) print(` ${style.skip(line)}`);
26849
27389
  print("");
26850
- return finish([row$9(title, "skip", `would file the issue${summary}`)]);
27390
+ return finish([row$12(title, "skip", `would file the issue${summary}`)]);
26851
27391
  }
26852
27392
  if (!input.yes) {
26853
27393
  if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError("`new issue` files an issue; pass --yes to run it without asking, or --dry-run to preview");
@@ -26880,12 +27420,12 @@ async function runIssueCreate(input) {
26880
27420
  ...prepared.fields.priority ? { priority: prepared.fields.priority } : {}
26881
27421
  }) : void 0;
26882
27422
  return finish([
26883
- row$9(title, "ok", `filed ${key}`),
26884
- ...(dropped ?? []).map((line) => row$9("not carried across", "skip", line)),
27423
+ row$12(title, "ok", `filed ${key}`),
27424
+ ...(dropped ?? []).map((line) => row$12("not carried across", "skip", line)),
26885
27425
  ...board ? [board] : []
26886
27426
  ], key);
26887
27427
  } catch (err) {
26888
- return finish([row$9(title, "fail", `could not file the issue: ${describeError(err)}`)]);
27428
+ return finish([row$12(title, "fail", `could not file the issue: ${describeError(err)}`)]);
26889
27429
  }
26890
27430
  }
26891
27431
  // src/commands/issue-create/issue-create.command.ts
@@ -28521,7 +29061,7 @@ async function ensureProjectSeam(context, setup, dryRun, deps = {}) {
28521
29061
  * Windows, deleted once the import is done). The values go only to that file: nothing here prints, logs or returns one.
28522
29062
  */
28523
29063
  /** A name a dotenv file can carry and a shell can export. */
28524
- const NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
29064
+ const NAME$1 = /^[A-Za-z_][A-Za-z0-9_]*$/;
28525
29065
  async function handOffSecrets(input) {
28526
29066
  const { print, entries } = input;
28527
29067
  const fail = (reason, ...message) => {
@@ -28537,7 +29077,7 @@ async function handOffSecrets(input) {
28537
29077
  const names = [];
28538
29078
  const blank = [];
28539
29079
  for (const { name, value } of entries) {
28540
- if (!NAME.test(name)) return fail("name", `"${name}" is not a name a variable can carry`);
29080
+ if (!NAME$1.test(name)) return fail("name", `"${name}" is not a name a variable can carry`);
28541
29081
  if (names.includes(name)) return fail("duplicate", `${name} is listed twice: a name is handed over once`);
28542
29082
  const line = dotenvLine(name, value);
28543
29083
  if (line === null) return fail("unsupported", `${name}: its value is not one a dotenv file can carry`);
@@ -28838,38 +29378,6 @@ function instanceInputs(input) {
28838
29378
  }));
28839
29379
  return [...found, ...rest];
28840
29380
  }
28841
- // src/commands/instance-token-guide/instance-token-guide.ts
28842
- /**
28843
- * For each name only a person can make, where to make it and what it needs: the plugin's own declaration of the token
28844
- * (`PluginToken`: the vendor page, and the permissions its layer's token must and must not carry, read through
28845
- * `tokenExpectations()`). A layer a token has no rules for yet (`preview` is new) reads `prod`'s, and `from` says so. A
28846
- * name no plugin declares is listed with nothing more, because inventing a vendor page would be worse than none.
28847
- *
28848
- * @param names - The `person` names of `instanceInputs()`.
28849
- * @param tokens - Every token the loaded plugins declare.
28850
- * @param layer - The instance's layer (`preview`).
28851
- */
28852
- function instanceTokenGuide(names, tokens, layer) {
28853
- return names.map((name) => {
28854
- const token = tokens.find((candidate) => candidate.envName === name || candidate.vendorEnvName === name);
28855
- if (!token) return {
28856
- name,
28857
- declared: false,
28858
- required: [],
28859
- absent: []
28860
- };
28861
- const rules = tokenExpectations([token]);
28862
- const own = rules.find((rule) => rule.layer === layer) ?? rules.find((rule) => rule.layer === "prod");
28863
- return {
28864
- name,
28865
- declared: true,
28866
- ...token.page ? { page: token.page } : {},
28867
- required: own ? [...own.required] : [],
28868
- absent: own ? [...own.absent] : [],
28869
- ...own ? { from: own.layer } : {}
28870
- };
28871
- });
28872
- }
28873
29381
  // src/commands/new-instance/resolve-copies/resolve-copies.ts
28874
29382
  /**
28875
29383
  * Settles which `copy` names can be copied. A name already in the instance's Environment is left as it is (a value is
@@ -28889,7 +29397,7 @@ function resolveCopies(inputs, read, has, from) {
28889
29397
  return {
28890
29398
  inputs: inputs.map((input) => {
28891
29399
  if (input.source !== "copy" || has(input.name)) return input;
28892
- const why = whyNot(input.name, read, from);
29400
+ const why = whyNot$1(input.name, read, from);
28893
29401
  if (typeof why === "string") {
28894
29402
  demoted.push({
28895
29403
  name: input.name,
@@ -28908,7 +29416,7 @@ function resolveCopies(inputs, read, has, from) {
28908
29416
  };
28909
29417
  }
28910
29418
  /** The reason a name cannot be copied, or its value. */
28911
- function whyNot(name, read, from) {
29419
+ function whyNot$1(name, read, from) {
28912
29420
  if (!read || read.status === "unreadable") return `${from} could not be read${read ? `: ${read.reason}` : ""}`;
28913
29421
  if (read.status === "missing") return `${from} does not exist`;
28914
29422
  const entry = read.entries[name];
@@ -28933,20 +29441,6 @@ function stepRow(step) {
28933
29441
  problems: []
28934
29442
  };
28935
29443
  }
28936
- // src/commands/new-instance/token-problem/token-problem.ts
28937
- /**
28938
- * One line a person can act on for a token they have to make: the variable, where it is made, what it must have and what
28939
- * it must not, and which layer's rules those are. A token no plugin declares says so, because nothing more is known.
28940
- * Names and addresses only.
28941
- */
28942
- function tokenProblem(guide) {
28943
- if (!guide.declared) return `${guide.name}: no plugin declares it, so make it where it comes from`;
28944
- const where = guide.page ? `make it at ${guide.page}` : "its plugin names no page to make it at";
28945
- const needs = guide.required.length > 0 ? `; it needs ${guide.required.join(", ")}` : "";
28946
- const avoids = guide.absent.length > 0 ? `; it must not have ${guide.absent.join(", ")}` : "";
28947
- const from = guide.from ? ` (the ${guide.from} layer's rules)` : "";
28948
- return `${guide.name}: ${where}${needs}${avoids}${from}`;
28949
- }
28950
29444
  // src/commands/new-instance/run-new-instance/run-new-instance.ts
28951
29445
  /** The steps in order, which is also how a stop says what is left: the step that stopped it and every one after. */
28952
29446
  const STEPS = [
@@ -29251,7 +29745,7 @@ function readGitConfig(cwd, key, run = runGit) {
29251
29745
  * identity; Effort is asked on a terminal when it was not given (the CLI never chooses it). The issue's key is printed
29252
29746
  * by the first row, before anything else is done, so a failed spec leaves the issue as the anchor to resume from.
29253
29747
  */
29254
- const row$8 = (id, status, detail) => ({
29748
+ const row$11 = (id, status, detail) => ({
29255
29749
  id,
29256
29750
  title: id,
29257
29751
  status,
@@ -29270,7 +29764,7 @@ async function runNewWork(input) {
29270
29764
  const name = specName(input.title, input.specName);
29271
29765
  if (!name) {
29272
29766
  const detail = input.specName === void 0 ? "no spec name can be made from the title; pass --spec <name>" : `"${input.specName}" is not a spec name: use lower-case words joined by hyphens, such as tech-my-topic`;
29273
- const rows = [row$8("spec", "fail", detail)];
29767
+ const rows = [row$11("spec", "fail", detail)];
29274
29768
  printCheckRows(rows, print);
29275
29769
  return {
29276
29770
  status: "fail",
@@ -29279,7 +29773,7 @@ async function runNewWork(input) {
29279
29773
  }
29280
29774
  specPath = join(".notes", `${name}.spec.md`);
29281
29775
  if (io.exists(join(root, specPath))) {
29282
- const rows = [row$8(specPath, "fail", "the spec already exists; it is never overwritten")];
29776
+ const rows = [row$11(specPath, "fail", "the spec already exists; it is never overwritten")];
29283
29777
  printCheckRows(rows, print);
29284
29778
  return {
29285
29779
  status: "fail",
@@ -29289,7 +29783,7 @@ async function runNewWork(input) {
29289
29783
  }
29290
29784
  }
29291
29785
  const assignees = input.assignees && input.assignees.length > 0 ? input.assignees : [gitAssignee(input.gitConfig ?? ((key) => readGitConfig(root, key)))].filter((a) => Boolean(a));
29292
- if (!input.assignees?.length && assignees.length === 0) extra.push(row$8("assignee", "skip", "git config has no GitHub login (`github.user`); pass --assignee to assign the issue"));
29786
+ if (!input.assignees?.length && assignees.length === 0) extra.push(row$11("assignee", "skip", "git config has no GitHub login (`github.user`); pass --assignee to assign the issue"));
29293
29787
  let effort = input.effort;
29294
29788
  const interactive = input.interactive ?? Boolean(process.stdin.isTTY);
29295
29789
  if (!effort && !input.yes && !dryRun && interactive) effort = await (input.askEffort ?? promptEffort)();
@@ -32279,7 +32773,7 @@ const MARKER = "# written by `holocron open requests` for one session and remove
32279
32773
  const SECRETS_FILE = `${PRIVATE_DIR}/requests.env`;
32280
32774
  /** The lock a launch holds, in the private directory. */
32281
32775
  const LOCK_FILE = `${PRIVATE_DIR}/open-requests.lock`;
32282
- const row$7 = (id, status, detail, problems = []) => ({
32776
+ const row$10 = (id, status, detail, problems = []) => ({
32283
32777
  id,
32284
32778
  title: id,
32285
32779
  status,
@@ -32320,7 +32814,7 @@ async function runOpenRequests(input) {
32320
32814
  const tuples = entry?.cardinality === "many" ? entry.tuples : [];
32321
32815
  const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
32322
32816
  if (chosen.length === 0) {
32323
- say(row$7(input.to ?? "tooling", "fail", input.to === void 0 ? "the config has no `tooling` provider to open" : `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`));
32817
+ say(row$10(input.to ?? "tooling", "fail", input.to === void 0 ? "the config has no `tooling` provider to open" : `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`));
32324
32818
  return finish();
32325
32819
  }
32326
32820
  /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
@@ -32330,7 +32824,7 @@ async function runOpenRequests(input) {
32330
32824
  assertPluginsResolvable(loader, "open requests");
32331
32825
  const openable = (loader.has("tooling") ? loader.get("tooling") : []).filter((t) => chosen.some((tuple) => tuple.provider === t.providerName)).filter((t) => t.open !== void 0);
32332
32826
  if (openable.length !== 1) {
32333
- say(row$7("tooling", "fail", openable.length === 0 ? "no `tooling` provider can open its workspace" : `more than one \`tooling\` provider can open its workspace (${openable.map((t) => t.providerName).join(", ")}); name one with --to`));
32827
+ say(row$10("tooling", "fail", openable.length === 0 ? "no `tooling` provider can open its workspace" : `more than one \`tooling\` provider can open its workspace (${openable.map((t) => t.providerName).join(", ")}); name one with --to`));
32334
32828
  return finish();
32335
32829
  }
32336
32830
  const tool = openable[0];
@@ -32344,34 +32838,34 @@ async function runOpenRequests(input) {
32344
32838
  repoRoot
32345
32839
  });
32346
32840
  } catch (err) {
32347
- say(row$7(tool.providerName, "fail", describeError(err)));
32841
+ say(row$10(tool.providerName, "fail", describeError(err)));
32348
32842
  return finish();
32349
32843
  }
32350
32844
  const loaded = plan.wants.filter((want) => layers.includes(want.layer));
32351
32845
  const notLoaded = plan.wants.filter((want) => !layers.includes(want.layer));
32352
32846
  const names = [...new Set(loaded.map((want) => want.name))].sort();
32353
- if (plan.unfilled.length > 0) say(row$7("unfilled", "skip", `${plan.unfilled.length} secret variable(s) refer to no entry, so nobody fills them`, plan.unfilled));
32354
- say(row$7("layers", notLoaded.length > 0 ? "skip" : "ok", `loaded: ${layers.join(", ")}; not loaded: ${OPEN_LAYERS.filter((layer) => !layers.includes(layer)).join(", ") || "none"}`, notLoaded.map((want) => `${want.collection}: ${want.variable} is a ${want.layer} secret (${want.name}); start with --environment ${want.layer} to load it`)));
32847
+ if (plan.unfilled.length > 0) say(row$10("unfilled", "skip", `${plan.unfilled.length} secret variable(s) refer to no entry, so nobody fills them`, plan.unfilled));
32848
+ say(row$10("layers", notLoaded.length > 0 ? "skip" : "ok", `loaded: ${layers.join(", ")}; not loaded: ${OPEN_LAYERS.filter((layer) => !layers.includes(layer)).join(", ") || "none"}`, notLoaded.map((want) => `${want.collection}: ${want.variable} is a ${want.layer} secret (${want.name}); start with --environment ${want.layer} to load it`)));
32355
32849
  if (dryRun) {
32356
- for (const want of loaded) say(row$7(want.variable, "ok", `would fill ${want.collection}'s ${want.variable} from ${want.entry} of ${want.layer} as ${want.name}`));
32357
- if (names.length === 0) say(row$7("secrets", "ok", "nothing to fill: no variable refers to an entry"));
32358
- else say(row$7("secrets", "ok", `would write ${names.length} value(s) to ${SECRETS_FILE} and link it from ${plan.targets.length} collection(s)`));
32359
- say(row$7(plan.app, "ok", `would start ${plan.launch.command} in the foreground`));
32850
+ for (const want of loaded) say(row$10(want.variable, "ok", `would fill ${want.collection}'s ${want.variable} from ${want.entry} of ${want.layer} as ${want.name}`));
32851
+ if (names.length === 0) say(row$10("secrets", "ok", "nothing to fill: no variable refers to an entry"));
32852
+ else say(row$10("secrets", "ok", `would write ${names.length} value(s) to ${SECRETS_FILE} and link it from ${plan.targets.length} collection(s)`));
32853
+ say(row$10(plan.app, "ok", `would start ${plan.launch.command} in the foreground`));
32360
32854
  return finish();
32361
32855
  }
32362
32856
  if (deps.platform === "win32" && names.length > 0) {
32363
- say(row$7(plan.app, "fail", "cannot make the values file private on Windows: its mode bits are not enforced, and a link needs rights it may lack"));
32857
+ say(row$10(plan.app, "fail", "cannot make the values file private on Windows: its mode bits are not enforced, and a link needs rights it may lack"));
32364
32858
  return finish();
32365
32859
  }
32366
32860
  let running;
32367
32861
  try {
32368
32862
  running = await deps.processes();
32369
32863
  } catch (err) {
32370
- say(row$7(plan.app, "fail", `could not tell whether ${plan.app} is running: ${describeError(err)}`));
32864
+ say(row$10(plan.app, "fail", `could not tell whether ${plan.app} is running: ${describeError(err)}`));
32371
32865
  return finish();
32372
32866
  }
32373
32867
  if (running.split("\n").some((line) => line.includes(plan.running))) {
32374
- say(row$7(plan.app, "fail", `${plan.app} is already running; quit it and run this again (it would not see the values)`));
32868
+ say(row$10(plan.app, "fail", `${plan.app} is already running; quit it and run this again (it would not see the values)`));
32375
32869
  return finish();
32376
32870
  }
32377
32871
  if (!input.yes) {
@@ -32388,7 +32882,7 @@ async function runOpenRequests(input) {
32388
32882
  if (names.length > 0) {
32389
32883
  const vault = loader.has("vault") ? loader.get("vault") : void 0;
32390
32884
  if (!vault?.readEnvironmentEntries) {
32391
- say(row$7("vault", "fail", vault ? `${vault.providerName} cannot read an Environment's entries` : "needs a `vault` provider in holocron.config.ts (1password)"));
32885
+ say(row$10("vault", "fail", vault ? `${vault.providerName} cannot read an Environment's entries` : "needs a `vault` provider in holocron.config.ts (1password)"));
32392
32886
  return finish();
32393
32887
  }
32394
32888
  let failed = false;
@@ -32405,17 +32899,17 @@ async function runOpenRequests(input) {
32405
32899
  names: [...new Set(wanted.map((want) => want.entry))].sort()
32406
32900
  });
32407
32901
  } catch (err) {
32408
- say(row$7(`vault ${layer}`, "fail", describeError(err)));
32902
+ say(row$10(`vault ${layer}`, "fail", describeError(err)));
32409
32903
  failed = true;
32410
32904
  continue;
32411
32905
  }
32412
32906
  for (const entry of read.missing) {
32413
- say(row$7(`${layer} ${entry}`, "fail", `${read.environmentId} holds no value for ${entry}`));
32907
+ say(row$10(`${layer} ${entry}`, "fail", `${read.environmentId} holds no value for ${entry}`));
32414
32908
  failed = true;
32415
32909
  }
32416
32910
  if (read.missing.length > 0) continue;
32417
32911
  for (const want of wanted) values.set(want.name, read.values.get(want.entry));
32418
- say(row$7(`vault ${read.environmentId}`, "ok", `${wanted.length} value(s) read: ${[...new Set(wanted.map((want) => want.name))].join(", ")}`));
32912
+ say(row$10(`vault ${read.environmentId}`, "ok", `${wanted.length} value(s) read: ${[...new Set(wanted.map((want) => want.name))].join(", ")}`));
32419
32913
  }
32420
32914
  if (failed) return finish();
32421
32915
  }
@@ -32435,7 +32929,7 @@ async function runOpenRequests(input) {
32435
32929
  };
32436
32930
  deps.makeDir(dirname(secrets));
32437
32931
  if (!deps.takeLock(lock, deps.pid)) {
32438
- say(row$7(plan.app, "fail", `another \`open requests\` is starting ${plan.app} (${LOCK_FILE} is held); try again when it has`));
32932
+ say(row$10(plan.app, "fail", `another \`open requests\` is starting ${plan.app} (${LOCK_FILE} is held); try again when it has`));
32439
32933
  return finish();
32440
32934
  }
32441
32935
  const stop = deps.onTerminate(cleanup);
@@ -32443,18 +32937,18 @@ async function runOpenRequests(input) {
32443
32937
  if (names.length > 0) {
32444
32938
  const ignored = deps.isIgnored(secrets);
32445
32939
  if (ignored === "tracked" || ignored === "unknown") {
32446
- say(row$7("values file", "fail", `refusing to write ${SECRETS_FILE}: git ${ignored === "tracked" ? "does not ignore it, so it could be committed" : "could not say whether it ignores it"}`, [ignoreAdvice(true, "")]));
32940
+ say(row$10("values file", "fail", `refusing to write ${SECRETS_FILE}: git ${ignored === "tracked" ? "does not ignore it, so it could be committed" : "could not say whether it ignores it"}`, [ignoreAdvice(true, "")]));
32447
32941
  return finish();
32448
32942
  }
32449
32943
  const stale = deps.inspect(secrets);
32450
32944
  if (stale.kind !== "none" && !(stale.kind === "file" && stale.firstLine === "# written by `holocron open requests` for one session and removed when it ends")) {
32451
- say(row$7("values file", "fail", `${SECRETS_FILE} is not this command's (no marker line); move it away`));
32945
+ say(row$10("values file", "fail", `${SECRETS_FILE} is not this command's (no marker line); move it away`));
32452
32946
  return finish();
32453
32947
  }
32454
32948
  for (const link of plan.targets) {
32455
32949
  const state = deps.inspect(link);
32456
32950
  if (state.kind !== "none" && !isOurs(state, link, secrets)) {
32457
- say(row$7("link", "fail", `${relative(repoRoot, link)} exists and is not this command's (it is not a link to ${SECRETS_FILE}, and has no marker line); move it away`));
32951
+ say(row$10("link", "fail", `${relative(repoRoot, link)} exists and is not this command's (it is not a link to ${SECRETS_FILE}, and has no marker line); move it away`));
32458
32952
  return finish();
32459
32953
  }
32460
32954
  }
@@ -32462,7 +32956,7 @@ async function runOpenRequests(input) {
32462
32956
  for (const [name, value] of values) {
32463
32957
  const line = dotenvLine(name, value);
32464
32958
  if (line === null) {
32465
- say(row$7(name, "fail", `the value of ${name} cannot be written to a .env file as it is; it was not written`));
32959
+ say(row$10(name, "fail", `the value of ${name} cannot be written to a .env file as it is; it was not written`));
32466
32960
  return finish();
32467
32961
  }
32468
32962
  lines.push(line);
@@ -32475,7 +32969,7 @@ async function runOpenRequests(input) {
32475
32969
  deps.symlink(relative(dirname(link), secrets), link);
32476
32970
  created.push(link);
32477
32971
  }
32478
- say(row$7("values file", "ok", `${SECRETS_FILE} (mode 0600, git-ignored) linked from ${plan.targets.map((t) => relative(repoRoot, t)).join(", ")}`));
32972
+ say(row$10("values file", "ok", `${SECRETS_FILE} (mode 0600, git-ignored) linked from ${plan.targets.map((t) => relative(repoRoot, t)).join(", ")}`));
32479
32973
  }
32480
32974
  print("");
32481
32975
  print(`starting ${plan.app}${names.length > 0 ? `; the values are removed when it quits (Ctrl-C ends it too)` : ""}`);
@@ -32483,10 +32977,10 @@ async function runOpenRequests(input) {
32483
32977
  try {
32484
32978
  exitCode = await deps.run(plan.launch);
32485
32979
  } catch (err) {
32486
- say(row$7(plan.app, "fail", describeError(err)));
32980
+ say(row$10(plan.app, "fail", describeError(err)));
32487
32981
  return finish();
32488
32982
  }
32489
- say(row$7(plan.app, exitCode === 0 ? "ok" : "fail", `ended with ${exitCode}`));
32983
+ say(row$10(plan.app, exitCode === 0 ? "ok" : "fail", `ended with ${exitCode}`));
32490
32984
  return finish();
32491
32985
  } finally {
32492
32986
  stop();
@@ -34699,6 +35193,82 @@ const projectCommand = {
34699
35193
  builder: (y) => y.command(projectStatusCommand).command(groupMenu("project")),
34700
35194
  handler: () => {}
34701
35195
  };
35196
+ // src/commands/provider/provider-revoke/provider-revoke.ts
35197
+ /**
35198
+ * `holocron provider <name> revoke <id>`: delete a token through the provider's own API, the step after minting and
35199
+ * importing its replacement (#2682, spec `tech-token-minting`). It takes the vendor's id for the token (what minting and
35200
+ * `whoami` print), never a value, and refuses anything that is not a plain id before a provider is loaded, so an id can
35201
+ * never reach a request path as anything but one segment. Deleting is irreversible, so it always asks (`--yes` skips the
35202
+ * question, `--dry-run` calls nothing, no terminal without `--yes` is a `NonInteractiveError`). A token the vendor no
35203
+ * longer has is a success that says so, and a plugin refuses the token the call itself is made with.
35204
+ */
35205
+ /** A vendor's token id: letters, digits and `._:-`, so it is one path segment and nothing that could change a request. */
35206
+ const TOKEN_ID = /^[A-Za-z0-9._:-]{1,128}$/;
35207
+ const row$9 = (id, title, status, detail, problems = []) => ({
35208
+ id: `provider-revoke:${id}`,
35209
+ title,
35210
+ status,
35211
+ detail,
35212
+ problems
35213
+ });
35214
+ async function runProviderRevoke(input) {
35215
+ const print = input.print ?? ((line) => console.log(line));
35216
+ const dryRun = input.context.dryRun ?? false;
35217
+ const { provider, id } = input;
35218
+ const scrub = createScrubber([input.context.cliToken, ...Object.values(input.context.cliTokens ?? {})].filter((t) => typeof t === "string"));
35219
+ const finish = (status, rows) => {
35220
+ const clean = rows.map((r) => ({
35221
+ ...r,
35222
+ title: scrub(r.title),
35223
+ detail: scrub(r.detail),
35224
+ problems: r.problems.map(scrub)
35225
+ }));
35226
+ printCheckRows(clean, print);
35227
+ const summary = summariseChecks(clean);
35228
+ printCheckSummary(summary, print);
35229
+ getLogger().info({
35230
+ ...summary,
35231
+ provider,
35232
+ status
35233
+ }, `provider ${provider} revoke`);
35234
+ return {
35235
+ status,
35236
+ rows: clean
35237
+ };
35238
+ };
35239
+ print(`Holocron provider ${provider} revoke${dryRun ? " (dry-run)" : ""}`);
35240
+ if (!TOKEN_ID.test(id)) return finish("fail", [row$9("id", "token id", "fail", "that is not a token id", ["give the id minting or `whoami` printed (letters, digits and . _ : -), never the token's value"])]);
35241
+ /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
35242
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
35243
+ await loader.load();
35244
+ assertPluginsResolvable(loader, "provider");
35245
+ let revoke = loader.revokeTokens().get(provider);
35246
+ if (!revoke) try {
35247
+ revoke = await loader.loadRevokeToken(provider, input.options ?? {});
35248
+ } catch (err) {
35249
+ if (err instanceof WorkspaceContextError) throw err;
35250
+ return finish("fail", [row$9("provider", provider, "fail", `\`${provider}\` did not load`, [describeError(err)])]);
35251
+ }
35252
+ if (!revoke) return finish("fail", [row$9("provider", provider, "fail", `\`${provider}\` cannot delete a token through its API`, ["delete it in the vendor's dashboard"])]);
35253
+ if (dryRun) return finish("dry-run", [row$9("plan", id, "ok", `would delete token ${id} at ${provider} through its API; it cannot be undone; nothing was called`)]);
35254
+ if (!input.yes) {
35255
+ if (!input.confirm) throw new NonInteractiveError("pass --yes to revoke a token without a terminal");
35256
+ if (!await input.confirm(`Delete token ${id} at ${provider}? This cannot be undone.`)) {
35257
+ print(" cancelled; nothing was deleted");
35258
+ return {
35259
+ status: "cancelled",
35260
+ rows: []
35261
+ };
35262
+ }
35263
+ }
35264
+ let done;
35265
+ try {
35266
+ done = await revoke({ id });
35267
+ } catch (err) {
35268
+ return finish("fail", [row$9("revoke", id, "fail", `${provider} did not delete the token`, [describeError(err)])]);
35269
+ }
35270
+ return finish("ok", [row$9("revoked", id, "ok", done.revoked ? `deleted at ${provider}` : `${provider} no longer has it; nothing to delete`), ...done.notes.map((note, i) => row$9(`note-${i + 1}`, "note", "skip", note))]);
35271
+ }
34702
35272
  // src/commands/provider/provider-token/provider-token.ts
34703
35273
  /**
34704
35274
  * `holocron provider <name> token --env <layer>`: make a token through the provider's own API and hand it to the
@@ -34708,7 +35278,7 @@ const projectCommand = {
34708
35278
  * once imported); no row, log or return value carries it, and the output is scrubbed of it as well. The old token is
34709
35279
  * never revoked here.
34710
35280
  */
34711
- const row$6 = (id, title, status, detail, problems = []) => ({
35281
+ const row$8 = (id, title, status, detail, problems = []) => ({
34712
35282
  id: `provider-token:${id}`,
34713
35283
  title,
34714
35284
  status,
@@ -34744,7 +35314,7 @@ async function runProviderToken(input) {
34744
35314
  };
34745
35315
  };
34746
35316
  print(`Holocron provider ${provider} token (${layer})${dryRun ? " (dry-run)" : ""}`);
34747
- if (!ENVIRONMENT_LAYERS.includes(layer)) return finish("fail", [row$6("layer", "layer", "fail", `\`${layer}\` is not a layer`, [`use one of: ${ENVIRONMENT_LAYERS.join(", ")}`])]);
35317
+ if (!ENVIRONMENT_LAYERS.includes(layer)) return finish("fail", [row$8("layer", "layer", "fail", `\`${layer}\` is not a layer`, [`use one of: ${ENVIRONMENT_LAYERS.join(", ")}`])]);
34748
35318
  /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
34749
35319
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
34750
35320
  await loader.load();
@@ -34754,12 +35324,12 @@ async function runProviderToken(input) {
34754
35324
  mint = await loader.loadMintToken(provider, input.options ?? {});
34755
35325
  } catch (err) {
34756
35326
  if (err instanceof WorkspaceContextError) throw err;
34757
- return finish("fail", [row$6("provider", `${provider}`, "fail", `\`${provider}\` did not load`, [describeError(err)])]);
35327
+ return finish("fail", [row$8("provider", `${provider}`, "fail", `\`${provider}\` did not load`, [describeError(err)])]);
34758
35328
  }
34759
- if (!mint) return finish("fail", [row$6("provider", provider, "fail", `\`${provider}\` cannot make a token through its API`, [`make one by hand, then store it with \`holocron new token ${provider} <token>\``])]);
35329
+ if (!mint) return finish("fail", [row$8("provider", provider, "fail", `\`${provider}\` cannot make a token through its API`, [`make one by hand, then store it with \`holocron new token ${provider} <token>\``])]);
34760
35330
  const now = input.now ?? (() => /* @__PURE__ */ new Date());
34761
35331
  const name = input.name ?? `holocron-${provider}-${layer}-${stamp(now())}`;
34762
- if (dryRun) return finish("dry-run", [row$6("plan", name, "ok", `would make a ${layer} token named ${name} through ${provider}'s API and hand it to the private import file; nothing was called`)]);
35332
+ if (dryRun) return finish("dry-run", [row$8("plan", name, "ok", `would make a ${layer} token named ${name} through ${provider}'s API and hand it to the private import file; nothing was called`)]);
34763
35333
  if (!input.yes) {
34764
35334
  if (!input.confirm) throw new NonInteractiveError("pass --yes to make a token without a terminal");
34765
35335
  if (!await input.confirm(`Make a new ${layer} token named ${name} through ${provider}'s API?`)) {
@@ -34779,9 +35349,9 @@ async function runProviderToken(input) {
34779
35349
  now
34780
35350
  });
34781
35351
  } catch (err) {
34782
- return finish("fail", [row$6("mint", name, "fail", `${provider} did not make the token`, [describeError(err)])]);
35352
+ return finish("fail", [row$8("mint", name, "fail", `${provider} did not make the token`, [describeError(err)])]);
34783
35353
  }
34784
- const rows = [row$6("minted", name, "ok", [made.id ? `id ${made.id}` : "", made.expiresAt ? `expires ${made.expiresAt.slice(0, 10)}` : "no expiry"].filter(Boolean).join(", ")), ...made.notes.map((note, i) => row$6(`note-${i + 1}`, "note", "skip", note))];
35354
+ const rows = [row$8("minted", name, "ok", [made.id ? `id ${made.id}` : "", made.expiresAt ? `expires ${made.expiresAt.slice(0, 10)}` : "no expiry"].filter(Boolean).join(", ")), ...made.notes.map((note, i) => row$8(`note-${i + 1}`, "note", "skip", note))];
34785
35355
  const environment = await (input.resolveEnvironment ?? ((l, repoRoot) => resolveEnvironmentId(l, { repoRoot })))(layer, input.context.repoRoot);
34786
35356
  const handed = await (input.handOff ?? handOffSecret)({
34787
35357
  name: made.envName,
@@ -34792,10 +35362,10 @@ async function runProviderToken(input) {
34792
35362
  ...input.interactive === void 0 ? {} : { interactive: input.interactive }
34793
35363
  });
34794
35364
  if (handed.status === "fail") {
34795
- rows.push(row$6("hand-off", made.envName, "fail", `the value of ${made.envName} could not be handed over (${handed.reason ?? "failed"})`, [`the token exists at ${provider}${made.id ? ` (id ${made.id})` : ""} and its value cannot be shown again: delete it there and run the command again`]));
35365
+ rows.push(row$8("hand-off", made.envName, "fail", `the value of ${made.envName} could not be handed over (${handed.reason ?? "failed"})`, [`the token exists at ${provider}${made.id ? ` (id ${made.id})` : ""} and its value cannot be shown again: delete it there and run the command again`]));
34796
35366
  return finish("fail", rows, [made.value]);
34797
35367
  }
34798
- rows.push(row$6("hand-off", made.envName, "ok", `handed to the private import file for the \`${environment}\` Environment`), row$6("next", "next", "skip", `send it where it runs with \`holocron sync secrets --env ${layer}\` (or \`holocron sync <app> --env ${layer}\`), then revoke the token it replaces at ${provider}`));
35368
+ rows.push(row$8("hand-off", made.envName, "ok", `handed to the private import file for the \`${environment}\` Environment`), row$8("next", "next", "skip", `send it where it runs with \`holocron sync secrets --env ${layer}\` (or \`holocron sync <app> --env ${layer}\`), then revoke the token it replaces at ${provider}`));
34799
35369
  return finish("ok", rows, [made.value]);
34800
35370
  }
34801
35371
  // src/commands/provider/provider.ts
@@ -34807,7 +35377,7 @@ async function runProviderToken(input) {
34807
35377
  * change, and without `--dry-run` or `--yes` it asks first (and refuses to run without a terminal). A step that fails is
34808
35378
  * a row, not the end of the run. Whatever the provider prints is scrubbed of the tokens the run was given.
34809
35379
  */
34810
- /** What a plugin returns from `createPlugin`; `token` is its `mintToken`, which `runProviderToken()` runs. */
35380
+ /** What a plugin returns from `createPlugin`; `token` and `revoke` are its `mintToken` and `revokeToken`, which `runProviderToken()` and `runProviderRevoke()` run. */
34811
35381
  const ACTIONS = [
34812
35382
  "setup",
34813
35383
  "doctor",
@@ -34820,10 +35390,10 @@ const fail = (print, ...text) => {
34820
35390
  rows: []
34821
35391
  };
34822
35392
  };
34823
- /** `linear: setup, doctor` lines for the providers given, sorted by name; `token` is added for one that can mint. */
34824
- function listing(groups, minters) {
35393
+ /** `linear: setup, doctor` lines for the providers given, sorted by name; `extras` adds `token` and `revoke` where offered. */
35394
+ function listing(groups, extras) {
34825
35395
  const width = Math.max(0, ...[...groups.keys()].map((name) => name.length));
34826
- return [...groups].sort(([a], [b]) => a.localeCompare(b)).map(([name, actions]) => ` ${name.padEnd(width)} ${[...ACTIONS.filter((a) => actions[a]), ...minters.has(name) ? ["token"] : []].join(", ")}`);
35396
+ return [...groups].sort(([a], [b]) => a.localeCompare(b)).map(([name, actions]) => ` ${name.padEnd(width)} ${[...ACTIONS.filter((a) => actions[a]), ...extras.get(name) ?? []].join(", ")}`);
34827
35397
  }
34828
35398
  /** The options of the first config entry that names `provider`, whichever capability it sits under. */
34829
35399
  function configOptions(providers, provider) {
@@ -34857,7 +35427,9 @@ async function runProvider(input) {
34857
35427
  await loader.load();
34858
35428
  assertPluginsResolvable(loader, "provider");
34859
35429
  const groups = new Map(loader.providerActions());
34860
- const minters = new Set(loader.mintTokens().keys());
35430
+ const extras = /* @__PURE__ */ new Map();
35431
+ for (const name of loader.mintTokens().keys()) extras.set(name, ["token"]);
35432
+ for (const name of loader.revokeTokens().keys()) extras.set(name, [...extras.get(name) ?? [], "revoke"]);
34861
35433
  /* v8 ignore start -- reads the workspace's package configs from disk, which tests replace with `workspaceProviders` */
34862
35434
  const workspaceTuples = async () => input.workspaceProviders ?? await workspaceProviders(input.context.repoRoot, input.loaded.resolved);
34863
35435
  /* v8 ignore stop */
@@ -34867,7 +35439,7 @@ async function runProvider(input) {
34867
35439
  if (groups.size === 0) print(" no configured provider offers `setup`, `doctor` or `whoami`");
34868
35440
  else {
34869
35441
  print(style.header("Providers with their own setup and doctor"));
34870
- for (const line of listing(groups, minters)) print(line);
35442
+ for (const line of listing(groups, extras)) print(line);
34871
35443
  }
34872
35444
  return {
34873
35445
  status: "listed",
@@ -34902,6 +35474,31 @@ async function runProvider(input) {
34902
35474
  rows: report.rows
34903
35475
  };
34904
35476
  }
35477
+ if (input.action === "revoke") {
35478
+ if (!input.tokenId) return fail(print, `\`provider ${input.provider} revoke\` needs the token's id`, "the id minting or `whoami` printed, never the token's value");
35479
+ const interactive = input.interactive ?? Boolean(process.stdin.isTTY);
35480
+ const report = await runProviderRevoke({
35481
+ loaded: input.loaded,
35482
+ context: input.context,
35483
+ provider: input.provider,
35484
+ id: input.tokenId,
35485
+ options: {
35486
+ ...configOptions(input.loaded.resolved.providers, input.provider),
35487
+ ...input.options
35488
+ },
35489
+ ...input.yes === void 0 ? {} : { yes: input.yes },
35490
+ loader,
35491
+ print,
35492
+ ...interactive ? { confirm: input.confirm ?? ((message) => confirm({
35493
+ message,
35494
+ default: false
35495
+ })) } : {}
35496
+ });
35497
+ return {
35498
+ status: report.status === "dry-run" ? "ok" : report.status,
35499
+ rows: report.rows
35500
+ };
35501
+ }
34905
35502
  let actions;
34906
35503
  if (input.options) {
34907
35504
  try {
@@ -34920,7 +35517,7 @@ async function runProvider(input) {
34920
35517
  }
34921
35518
  if (!actions) return fail(print, `no configured provider \`${input.provider}\` offers \`setup\`, \`doctor\` or \`whoami\``, groups.size > 0 ? `try: ${[...groups.keys()].sort().join(", ")}` : "none does");
34922
35519
  if (!input.action) {
34923
- for (const line of listing(/* @__PURE__ */ new Map([[input.provider, actions]]), minters)) print(line);
35520
+ for (const line of listing(/* @__PURE__ */ new Map([[input.provider, actions]]), extras)) print(line);
34924
35521
  return {
34925
35522
  status: "listed",
34926
35523
  rows: []
@@ -34928,7 +35525,7 @@ async function runProvider(input) {
34928
35525
  }
34929
35526
  const name = ACTIONS.find((a) => a === input.action);
34930
35527
  const run = name && actions[name];
34931
- if (!name || !run) return fail(print, `\`${input.provider}\` has no \`${input.action}\``, `try: ${[...ACTIONS.filter((a) => actions[a]), ...minters.has(input.provider) ? ["token"] : []].join(", ")}`);
35528
+ if (!name || !run) return fail(print, `\`${input.provider}\` has no \`${input.action}\``, `try: ${[...ACTIONS.filter((a) => actions[a]), ...extras.get(input.provider) ?? []].join(", ")}`);
34932
35529
  const dryRun = input.context.dryRun ?? false;
34933
35530
  if (name === "setup" && !dryRun && !input.yes) {
34934
35531
  if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`provider ${input.provider} setup\` changes things on ${input.provider}; pass --yes to run it without asking, or --dry-run to preview`);
@@ -35026,7 +35623,10 @@ const providerArgs = (y) => y.positional("provider", {
35026
35623
  describe: "Which provider (omit to list the ones that offer setup, doctor or whoami)"
35027
35624
  }).positional("action", {
35028
35625
  type: "string",
35029
- describe: "`setup`, `doctor`, `whoami` or `token` (omit to list the provider's)"
35626
+ describe: "`setup`, `doctor`, `whoami`, `token` or `revoke` (omit to list the provider's)"
35627
+ }).positional("id", {
35628
+ type: "string",
35629
+ describe: "`revoke`: the vendor's id for the token to delete (what minting and `whoami` print), never its value"
35030
35630
  }).option("with", {
35031
35631
  type: "string",
35032
35632
  array: true,
@@ -35043,10 +35643,10 @@ const providerArgs = (y) => y.positional("provider", {
35043
35643
  }).option("yes", {
35044
35644
  type: "boolean",
35045
35645
  default: false,
35046
- describe: "Run `setup` or `token` without asking first (required without a terminal)"
35646
+ describe: "Run `setup`, `token` or `revoke` without asking first (required without a terminal)"
35047
35647
  });
35048
35648
  const providerCommand = {
35049
- command: "provider [provider] [action]",
35649
+ command: "provider [provider] [action] [id]",
35050
35650
  describe: "Set up or check what only one provider has, from its block of holocron.config or --with",
35051
35651
  builder: providerArgs,
35052
35652
  handler: async (argv) => {
@@ -35065,6 +35665,7 @@ const providerCommand = {
35065
35665
  },
35066
35666
  ...argv.provider ? { provider: argv.provider } : {},
35067
35667
  ...argv.action ? { action: argv.action } : {},
35668
+ ...argv.id ? { tokenId: argv.id } : {},
35068
35669
  ...options ? { options } : {},
35069
35670
  ...argv.env ? { env: argv.env } : {},
35070
35671
  ...argv.name ? { name: argv.name } : {},
@@ -36556,7 +37157,7 @@ const projectReconcileCommand = {
36556
37157
  * it would do and posts nothing.
36557
37158
  */
36558
37159
  const DEFAULT_MAX_AGE_MINUTES = 10;
36559
- const row$5 = (id, status, detail) => ({
37160
+ const row$7 = (id, status, detail) => ({
36560
37161
  id,
36561
37162
  title: id,
36562
37163
  status,
@@ -36595,7 +37196,7 @@ async function runReconcileCi(input) {
36595
37196
  };
36596
37197
  };
36597
37198
  const fail = (id, detail) => {
36598
- rows.push(row$5(id, "fail", detail));
37199
+ rows.push(row$7(id, "fail", detail));
36599
37200
  return finish();
36600
37201
  };
36601
37202
  print(style.header(`Holocron reconcile ci${dryRun ? " (dry-run)" : ""}`));
@@ -36603,7 +37204,7 @@ async function runReconcileCi(input) {
36603
37204
  if (input.maxAgeMinutes !== void 0 && !(input.maxAgeMinutes > 0)) return fail("max-age", "--max-age is a number of minutes above zero");
36604
37205
  const poster = aggregatePoster({ ci: input.loaded.resolved.ci });
36605
37206
  if (!input.shadow && poster !== "sentinel") {
36606
- rows.push(row$5("ci.aggregate", "skip", poster === "none" ? `ci.aggregate is none here, so there is no ${AGGREGATE_CHECK_NAME} to post; --shadow repairs Sentinel's shadow check` : `ci.aggregate is actions here, so the Actions job posts ${AGGREGATE_CHECK_NAME} and nothing is posted; --shadow repairs Sentinel's shadow check`));
37207
+ rows.push(row$7("ci.aggregate", "skip", poster === "none" ? `ci.aggregate is none here, so there is no ${AGGREGATE_CHECK_NAME} to post; --shadow repairs Sentinel's shadow check` : `ci.aggregate is actions here, so the Actions job posts ${AGGREGATE_CHECK_NAME} and nothing is posted; --shadow repairs Sentinel's shadow check`));
36607
37208
  return finish();
36608
37209
  }
36609
37210
  const providers = input.loaded.resolved.providers;
@@ -36643,7 +37244,7 @@ async function runReconcileCi(input) {
36643
37244
  return fail("pull requests", describeError(error));
36644
37245
  }
36645
37246
  if (pullRequests.length === 0) {
36646
- rows.push(row$5("pull requests", "skip", "no open pull requests"));
37247
+ rows.push(row$7("pull requests", "skip", "no open pull requests"));
36647
37248
  return finish();
36648
37249
  }
36649
37250
  const api = {
@@ -36656,7 +37257,7 @@ async function runReconcileCi(input) {
36656
37257
  for (const pr of pullRequests) {
36657
37258
  const id = `#${pr.number}`;
36658
37259
  if (pr.headSha === void 0) {
36659
- rows.push(row$5(id, "skip", "the provider gave no head commit"));
37260
+ rows.push(row$7(id, "skip", "the provider gave no head commit"));
36660
37261
  continue;
36661
37262
  }
36662
37263
  try {
@@ -36671,17 +37272,17 @@ async function runReconcileCi(input) {
36671
37272
  name: input.shadow ? AGGREGATE_SHADOW_CHECK_NAME : AGGREGATE_CHECK_NAME
36672
37273
  });
36673
37274
  const verdict = out.result.conclusion;
36674
- if (out.action === "foreign") rows.push(row$5(id, "skip", "another app (the Actions job) already posts this check on the commit; left alone"));
36675
- else if (out.action === "unchanged") rows.push(row$5(id, "ok", `up to date (${verdict})`));
37275
+ if (out.action === "foreign") rows.push(row$7(id, "skip", "another app (the Actions job) already posts this check on the commit; left alone"));
37276
+ else if (out.action === "unchanged") rows.push(row$7(id, "ok", `up to date (${verdict})`));
36676
37277
  else if (out.stale) {
36677
37278
  const what = dryRun ? "would repair" : "repaired";
36678
- rows.push(row$5(id, "fail", `${what}: the check was missing or wrong (now ${verdict}); a delivery was missed`));
37279
+ rows.push(row$7(id, "fail", `${what}: the check was missing or wrong (now ${verdict}); a delivery was missed`));
36679
37280
  } else {
36680
37281
  const what = dryRun ? "would post" : "posted";
36681
- rows.push(row$5(id, "ok", `${what} ${verdict} (still in flight)`));
37282
+ rows.push(row$7(id, "ok", `${what} ${verdict} (still in flight)`));
36682
37283
  }
36683
37284
  } catch (error) {
36684
- rows.push(row$5(id, "fail", describeError(error)));
37285
+ rows.push(row$7(id, "fail", describeError(error)));
36685
37286
  }
36686
37287
  }
36687
37288
  return finish();
@@ -36764,7 +37365,7 @@ const defaultApi = {
36764
37365
  listAppDeliveries,
36765
37366
  redeliverAppDelivery
36766
37367
  };
36767
- const row$4 = (id, status, detail) => ({
37368
+ const row$6 = (id, status, detail) => ({
36768
37369
  id,
36769
37370
  title: id,
36770
37371
  status,
@@ -36795,7 +37396,7 @@ async function runRedeliverWebhooks(input) {
36795
37396
  };
36796
37397
  };
36797
37398
  const fail = (id, detail) => {
36798
- rows.push(row$4(id, "fail", detail));
37399
+ rows.push(row$6(id, "fail", detail));
36799
37400
  return finish();
36800
37401
  };
36801
37402
  print(style.header(`Holocron redeliver webhooks${dryRun ? " (dry-run)" : ""}`));
@@ -36808,7 +37409,7 @@ async function runRedeliverWebhooks(input) {
36808
37409
  }
36809
37410
  const all = input.loaded.resolved.githubApps ?? [];
36810
37411
  if (all.length === 0) {
36811
- rows.push(row$4("github-app", "skip", "no `githubApps` are declared in holocron.config.ts"));
37412
+ rows.push(row$6("github-app", "skip", "no `githubApps` are declared in holocron.config.ts"));
36812
37413
  return finish();
36813
37414
  }
36814
37415
  const instances = input.app === void 0 ? all : all.filter((instance) => instance.name === input.app);
@@ -36822,19 +37423,19 @@ async function runRedeliverWebhooks(input) {
36822
37423
  for (const instance of instances) {
36823
37424
  const read = await readAppCredentials(instance, loader);
36824
37425
  if ("reason" in read) {
36825
- rows.push(row$4(`${instance.name}`, "skip", read.reason));
37426
+ rows.push(row$6(`${instance.name}`, "skip", read.reason));
36826
37427
  continue;
36827
37428
  }
36828
37429
  try {
36829
37430
  const failed = failedDeliveries(await api.listAppDeliveries(read.creds, { since }));
36830
- if (failed.length === 0) rows.push(row$4(instance.name, "ok", `no failed deliveries since ${since}`));
37431
+ if (failed.length === 0) rows.push(row$6(instance.name, "ok", `no failed deliveries since ${since}`));
36831
37432
  for (const delivery of failed) pending.push({
36832
37433
  app: instance.name,
36833
37434
  creds: read.creds,
36834
37435
  delivery
36835
37436
  });
36836
37437
  } catch (error) {
36837
- rows.push(row$4(instance.name, "fail", `cannot read the delivery log: ${scrubbed$1(error, [read.creds.privateKey])}`));
37438
+ rows.push(row$6(instance.name, "fail", `cannot read the delivery log: ${scrubbed$1(error, [read.creds.privateKey])}`));
36838
37439
  }
36839
37440
  }
36840
37441
  if (pending.length === 0) return finish();
@@ -36846,7 +37447,7 @@ async function runRedeliverWebhooks(input) {
36846
37447
  };
36847
37448
  };
36848
37449
  if (dryRun) {
36849
- for (const item of pending) rows.push(row$4(label(item).id, "skip", `would redeliver ${label(item).text}`));
37450
+ for (const item of pending) rows.push(row$6(label(item).id, "skip", `would redeliver ${label(item).text}`));
36850
37451
  return finish();
36851
37452
  }
36852
37453
  /* v8 ignore next -- the terminal is only asked outside tests, which inject `interactive` */
@@ -36858,16 +37459,16 @@ async function runRedeliverWebhooks(input) {
36858
37459
  default: false
36859
37460
  }));
36860
37461
  if (!input.yes && !await ask(`Redeliver ${pending.length} failed webhook deliver${pending.length === 1 ? "y" : "ies"}?`)) {
36861
- rows.push(row$4("redeliver", "skip", "not confirmed; nothing was redelivered"));
37462
+ rows.push(row$6("redeliver", "skip", "not confirmed; nothing was redelivered"));
36862
37463
  return finish();
36863
37464
  }
36864
37465
  for (const item of pending) {
36865
37466
  const { id, text } = label(item);
36866
37467
  try {
36867
37468
  await api.redeliverAppDelivery(item.creds, item.delivery.id);
36868
- rows.push(row$4(id, "ok", `redelivered ${text}`));
37469
+ rows.push(row$6(id, "ok", `redelivered ${text}`));
36869
37470
  } catch (error) {
36870
- rows.push(row$4(id, "fail", scrubbed$1(error, [item.creds.privateKey])));
37471
+ rows.push(row$6(id, "fail", scrubbed$1(error, [item.creds.privateKey])));
36871
37472
  }
36872
37473
  }
36873
37474
  return finish();
@@ -36989,6 +37590,171 @@ const resolveCommand = {
36989
37590
  builder: (y) => y.command(monitoringResolveChecksCommand).command(groupMenu("resolve")),
36990
37591
  handler: () => {}
36991
37592
  };
37593
+ // src/commands/due-tokens/due-tokens.ts
37594
+ /** `tokens:<layer>:<provider>:<envName>`, the id `doctor tokens` gives each token's row. */
37595
+ const ROW_ID = /^tokens:([^:]+):([^:]+):(.+)$/;
37596
+ /**
37597
+ * The tokens `holocron doctor tokens` reports as due, found from its rows: a failing row with a problem that starts
37598
+ * with a rotation label (`expiry:` or `age:`, the labels `tokenRotationRows()` writes). A token that fails only for a
37599
+ * permission it must not have, or lacks, is not due, and a token the layer does not hold has no rotation problem.
37600
+ *
37601
+ * @param rows - The rows `runDoctorTokens()` returned.
37602
+ * @param layers - Only the tokens held in these layers; left out, every layer.
37603
+ */
37604
+ function dueTokens(rows, layers) {
37605
+ const due = [];
37606
+ for (const row of rows) {
37607
+ const match = ROW_ID.exec(row.id);
37608
+ if (row.status !== "fail" || !match) continue;
37609
+ const [, layer, provider, envName] = match;
37610
+ if (layers && layers.length > 0 && !layers.includes(layer)) continue;
37611
+ const problems = row.problems.filter((p) => ROTATION_LABELS.some((label) => p.startsWith(`${label}:`)));
37612
+ if (problems.length > 0) due.push({
37613
+ layer,
37614
+ provider,
37615
+ envName,
37616
+ problems
37617
+ });
37618
+ }
37619
+ return due;
37620
+ }
37621
+ // src/commands/rotate-tokens/rotate-tokens.ts
37622
+ /**
37623
+ * `holocron rotate tokens`: replace the tokens `holocron doctor tokens` reports as due (#2717, spec
37624
+ * `tech-token-rotation`). It reads the same rows the doctor does, so the two cannot disagree, lists each token that is
37625
+ * past its declared rotation or near its expiry, and for a provider that can make a token runs `provider <name> token`
37626
+ * once per token after one question. It revokes nothing and syncs nothing: the CLI cannot write a 1Password Environment,
37627
+ * so it cannot know the import and the sync happened. It ends with the order of what is left for each replaced token.
37628
+ * No token value is printed, logged or returned.
37629
+ */
37630
+ const row$5 = (id, title, status, detail, problems = []) => ({
37631
+ id: `rotate:${id}`,
37632
+ title,
37633
+ status,
37634
+ detail,
37635
+ problems
37636
+ });
37637
+ const label = (d) => `${d.provider} ${d.envName} (${d.layer})`;
37638
+ async function runRotateTokens(input) {
37639
+ const print = input.print ?? ((line) => console.log(line));
37640
+ const dryRun = input.context.dryRun ?? false;
37641
+ const shown = [];
37642
+ const show = (rows) => {
37643
+ shown.push(...rows);
37644
+ printCheckRows(rows, print);
37645
+ };
37646
+ const finish = (base) => {
37647
+ const summary = summariseChecks(shown);
37648
+ printCheckSummary(summary, print);
37649
+ const status = summary.fail > 0 ? "fail" : base;
37650
+ getLogger().info({
37651
+ ...summary,
37652
+ status
37653
+ }, "rotate tokens");
37654
+ return {
37655
+ status,
37656
+ rows: shown
37657
+ };
37658
+ };
37659
+ print(`Holocron rotate tokens${dryRun ? " (dry-run)" : ""}`);
37660
+ const layers = input.layers ?? [];
37661
+ const unknown = layers.find((l) => !ENVIRONMENT_LAYERS.includes(l));
37662
+ if (unknown !== void 0) {
37663
+ show([row$5("layer", "layer", "fail", `\`${unknown}\` is not a layer`, [`use one of: ${ENVIRONMENT_LAYERS.join(", ")}`])]);
37664
+ return finish("fail");
37665
+ }
37666
+ const due = dueTokens((await (input.doctor ?? runDoctorTokens)({
37667
+ loaded: input.loaded,
37668
+ context: input.context,
37669
+ print: () => {}
37670
+ })).rows, layers);
37671
+ if (due.length === 0) {
37672
+ show([row$5("none", "tokens", "ok", "no token is due")]);
37673
+ return finish("ok");
37674
+ }
37675
+ /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
37676
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
37677
+ await loader.load();
37678
+ assertPluginsResolvable(loader, "rotate tokens");
37679
+ const canMint = [];
37680
+ for (const d of due) {
37681
+ const mint = loader.mintTokens().get(d.provider) ?? await loader.loadMintToken(d.provider, {}).catch(() => void 0);
37682
+ canMint.push(mint !== void 0);
37683
+ }
37684
+ const replaceable = due.filter((_, i) => canMint[i]);
37685
+ show(due.map((d, i) => canMint[i] ? row$5(`${d.layer}:${d.provider}:${d.envName}`, label(d), "ok", `due (${d.problems.join("; ")}); will be replaced through ${d.provider}'s API`) : row$5(`${d.layer}:${d.provider}:${d.envName}`, label(d), "fail", `due (${d.problems.join("; ")})`, [`${d.provider} cannot make a token through its API: make one in its dashboard and store it with \`holocron new token ${d.provider} <token>\``])));
37686
+ if (dryRun || replaceable.length === 0) return finish(dryRun ? "dry-run" : "ok");
37687
+ if (!input.yes) {
37688
+ if (!input.confirm) throw new NonInteractiveError("pass --yes to replace tokens without a terminal");
37689
+ const names = replaceable.map(label).join(", ");
37690
+ if (!await input.confirm(`Replace ${replaceable.length} token${replaceable.length === 1 ? "" : "s"}: ${names}?`)) {
37691
+ print(" cancelled; nothing was replaced");
37692
+ return {
37693
+ status: "cancelled",
37694
+ rows: []
37695
+ };
37696
+ }
37697
+ }
37698
+ /* v8 ignore next -- the real mint calls a provider's API, which tests replace with `mint` */
37699
+ const mint = input.mint ?? runProviderToken;
37700
+ for (const d of replaceable) {
37701
+ const made = await mint({
37702
+ loaded: input.loaded,
37703
+ context: input.context,
37704
+ provider: d.provider,
37705
+ layer: d.layer,
37706
+ yes: true,
37707
+ loader,
37708
+ print
37709
+ });
37710
+ const id = `${d.layer}:${d.provider}:${d.envName}`;
37711
+ if (made.status === "ok") show([row$5(id, label(d), "ok", "a new token was made and handed to the private import file; the old one still works"), row$5(`next:${id}`, "next", "skip", `after the import: \`holocron sync secrets --env ${d.layer}\`, then delete the one it replaces with \`holocron provider ${d.provider} revoke <old-id>\` (the id is on ${d.provider}'s token page)`)]);
37712
+ else show([row$5(id, label(d), "fail", "the replacement was not made", made.rows.filter((r) => r.status === "fail").map((r) => r.detail))]);
37713
+ }
37714
+ return finish("ok");
37715
+ }
37716
+ // src/commands/rotate-tokens/rotate-tokens.command.ts
37717
+ const rotateTokensCommand = {
37718
+ command: "tokens",
37719
+ describe: "Replace the tokens `doctor tokens` reports as due, for the providers that can make one",
37720
+ builder: (y) => y.option("env", {
37721
+ type: "string",
37722
+ array: true,
37723
+ describe: "Only the tokens held in this layer (local, dev, ci, prod, preview); repeat for more"
37724
+ }).option("yes", {
37725
+ type: "boolean",
37726
+ default: false,
37727
+ describe: "Replace without asking (required without a terminal)"
37728
+ }),
37729
+ handler: async (argv) => {
37730
+ const tokens = tokenContext(argv.token);
37731
+ if (!tokens) return;
37732
+ const loaded = await loadConfig(argv.cwd);
37733
+ applyResolvedConfig(argv, loaded.resolved);
37734
+ if ((await runRotateTokens({
37735
+ loaded,
37736
+ context: {
37737
+ repoRoot: argv.cwd,
37738
+ dryRun: argv.dryRun,
37739
+ ...tokens,
37740
+ org: resolveOrg(argv, loaded.resolved)
37741
+ },
37742
+ ...argv.env && argv.env.length > 0 ? { layers: argv.env } : {},
37743
+ yes: argv.yes,
37744
+ ...process.stdin.isTTY === true ? { confirm: (message) => confirm({
37745
+ message,
37746
+ default: false
37747
+ }) } : {}
37748
+ })).status === "fail") process.exitCode = 1;
37749
+ }
37750
+ };
37751
+ // src/commands/rotate/rotate.command.ts
37752
+ const rotateCommand = {
37753
+ command: "rotate",
37754
+ describe: "Replace what is due: the tokens `doctor tokens` reports as past their rotation",
37755
+ builder: (y) => y.command(rotateTokensCommand).command(groupMenu("rotate")),
37756
+ handler: () => {}
37757
+ };
36992
37758
  // src/commands/run/run.args.ts
36993
37759
  const runArgs = (y) => y.positional("task", {
36994
37760
  type: "string",
@@ -37262,6 +38028,188 @@ const showCommand = {
37262
38028
  builder: (y) => y.command(configShowCommand).command(groupMenu("show")),
37263
38029
  handler: () => {}
37264
38030
  };
38031
+ // src/commands/start-agent/agent-child-env/agent-child-env.ts
38032
+ /**
38033
+ * Names an Environment must not be able to set in an agent's process: the ones that decide which program runs, where it
38034
+ * looks for code or whose home it is. A variable of the `agent` Environment is a credential for a service; none of these
38035
+ * is, and one of them there would be a way to run something else.
38036
+ */
38037
+ const PROTECTED = /* @__PURE__ */ new Set([
38038
+ "PATH",
38039
+ "HOME",
38040
+ "USER",
38041
+ "LOGNAME",
38042
+ "SHELL",
38043
+ "PWD",
38044
+ "TMPDIR",
38045
+ "IFS",
38046
+ "ENV",
38047
+ "BASH_ENV",
38048
+ "NODE_OPTIONS",
38049
+ "NODE_PATH",
38050
+ "LD_PRELOAD",
38051
+ "LD_LIBRARY_PATH",
38052
+ "HOLOCRON_ENVIRONMENT",
38053
+ "ENVIRONMENT"
38054
+ ]);
38055
+ const NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
38056
+ function whyNot(name, value) {
38057
+ if (!NAME.test(name)) return "not a name a process environment can carry";
38058
+ if (name.startsWith("OP_")) return "a 1Password name: the agent is never given a way to sign in";
38059
+ if (PROTECTED.has(name) || name.startsWith("DYLD_")) return "decides what runs, so an Environment may not set it";
38060
+ if (value === "") return "blank: a slot nobody has filled in yet";
38061
+ }
38062
+ /**
38063
+ * The environment an agent's process starts with (spec `tech-agent-secrets`): this machine's own, less every `OP_*` name
38064
+ * (so it can never sign in to 1Password itself), `HOLOCRON_ENVIRONMENT=agent` so the `holocron` CLI inside it reads the
38065
+ * `agent` layer and no other, and the variables of the `agent` Environment. A name that could change which program runs,
38066
+ * one that is blank and one a process cannot carry are left out and named with the reason; a value is never part of one.
38067
+ *
38068
+ * @param base - This machine's environment (`process.env`).
38069
+ * @param entries - The `agent` Environment's entries, read in memory.
38070
+ */
38071
+ function agentChildEnv(base, entries) {
38072
+ const env = {};
38073
+ for (const [name, value] of Object.entries(base)) {
38074
+ if (value === void 0 || name.startsWith("OP_") || name === "HOLOCRON_AGENT_TOKEN_FILE") continue;
38075
+ env[name] = value;
38076
+ }
38077
+ env["HOLOCRON_ENVIRONMENT"] = "agent";
38078
+ env["ENVIRONMENT"] = "agent";
38079
+ const given = [];
38080
+ const skipped = [];
38081
+ for (const { name, value } of entries) {
38082
+ const reason = whyNot(name, value);
38083
+ if (reason !== void 0) {
38084
+ skipped.push({
38085
+ name,
38086
+ reason
38087
+ });
38088
+ continue;
38089
+ }
38090
+ env[name] = value;
38091
+ given.push(name);
38092
+ }
38093
+ return {
38094
+ env,
38095
+ given,
38096
+ skipped
38097
+ };
38098
+ }
38099
+ // src/commands/start-agent/run-start-agent/run-start-agent.ts
38100
+ const row$4 = (id, title, status, detail, problems = []) => ({
38101
+ id,
38102
+ title,
38103
+ status,
38104
+ detail,
38105
+ problems
38106
+ });
38107
+ /**
38108
+ * `holocron start agent -- <command>` (spec `tech-agent-secrets`): starts an agent's process with the credentials of the
38109
+ * `agent` Environment and nothing else.
38110
+ *
38111
+ * It refuses a missing, linked, shared or empty token file; reads the Environment in memory with the Service Account's
38112
+ * token; builds the child's environment apart from the token's (every `OP_*` name left out, `HOLOCRON_ENVIRONMENT=agent`
38113
+ * set, the Environment's variables added, a name that could change what runs refused); and runs the program in the
38114
+ * foreground. The token is read for that one call and is never in the child. Rows name paths, counts and variable
38115
+ * names, never a value, and the token is taken out of an error's text before it is shown.
38116
+ *
38117
+ * @param input - The command, the ports and whether to start anything.
38118
+ */
38119
+ async function runStartAgent(input) {
38120
+ const print = input.print ?? ((line) => console.log(line));
38121
+ const { ports } = input;
38122
+ const rows = [];
38123
+ const end = (status, exitCode) => {
38124
+ printCheckRows(rows, print);
38125
+ printCheckSummary(summariseChecks(rows), print);
38126
+ return {
38127
+ status,
38128
+ exitCode,
38129
+ rows
38130
+ };
38131
+ };
38132
+ const fail = (r) => {
38133
+ rows.push(r);
38134
+ return end("fail", 1);
38135
+ };
38136
+ const [program, ...args] = input.command;
38137
+ if (program === void 0) return fail(row$4("command", "the program", "fail", "name the program to run after `--`: holocron start agent -- claude"));
38138
+ const path = agentTokenPath(ports.env, ports.home);
38139
+ const file = readAgentToken(path, ports.fs);
38140
+ if (file.status === "fail") return fail(row$4("token-file", "the Service Account's token file", "fail", `${path}: ${file.reason}`));
38141
+ rows.push(row$4("token-file", "the Service Account's token file", "ok", `${path} (mode 600, in a private directory)`));
38142
+ let environment;
38143
+ try {
38144
+ environment = await ports.environmentName();
38145
+ } catch (err) {
38146
+ return fail(row$4("environment", "the agent Environment", "fail", `cannot name it: ${errorMessage(err)}`));
38147
+ }
38148
+ let entries;
38149
+ try {
38150
+ entries = await ports.readEntries(environment, file.token);
38151
+ } catch (err) {
38152
+ const text = errorMessage(err).split(file.token).join("[redacted]");
38153
+ return fail(row$4("environment", "the agent Environment", "fail", `could not read "${environment}": ${text}`));
38154
+ }
38155
+ const child = agentChildEnv(ports.env, entries);
38156
+ if (child.given.length === 0) return fail(row$4("environment", "the agent Environment", "fail", `"${environment}" holds no variable the agent can be given: make its tokens and import them (docs: tokens, the agent layer)`));
38157
+ rows.push(row$4("environment", "the agent Environment", "ok", `"${environment}": ${child.given.length} variable(s) for the agent: ${child.given.join(", ")}`));
38158
+ if (child.skipped.length > 0) rows.push(row$4("skipped", "names not given to the agent", "skip", `${child.skipped.length} name(s) left out`, child.skipped.map((s) => `${s.name}: ${s.reason}`)));
38159
+ if (input.dryRun) {
38160
+ rows.push(row$4("start", "the agent", "skip", `dry run: would start \`${program}\` with those variables and no Service Account token`));
38161
+ return end("ok", 0);
38162
+ }
38163
+ rows.push(row$4("start", "the agent", "ok", `starting \`${program}\` with those variables and no Service Account token`));
38164
+ printCheckRows(rows, print);
38165
+ printCheckSummary(summariseChecks(rows), print);
38166
+ try {
38167
+ return {
38168
+ status: "ok",
38169
+ exitCode: await ports.spawn(program, args, child.env),
38170
+ rows
38171
+ };
38172
+ } catch (err) {
38173
+ print(`could not start \`${program}\`: ${errorMessage(err)}`);
38174
+ return {
38175
+ status: "fail",
38176
+ exitCode: 1,
38177
+ rows
38178
+ };
38179
+ }
38180
+ }
38181
+ // src/commands/start-agent/start-agent.ts
38182
+ /**
38183
+ * `holocron start agent -- <command>` (spec `tech-agent-secrets`): reads the arguments, builds the real ports and hands
38184
+ * them to `runStartAgent()`, which prints its own rows. The program after `--` runs in the foreground, and the exit code
38185
+ * is its own; a check that stopped the launch is 1.
38186
+ *
38187
+ * @param argv - The parsed arguments, with everything after `--` in `argv["--"]`.
38188
+ * @param io - Builds the ports, and the launcher when a test supplies another.
38189
+ */
38190
+ async function startAgent(argv, io = {}) {
38191
+ const tokens = tokenContext(argv.token);
38192
+ if (!tokens) return;
38193
+ const command = argv["--"] ?? [];
38194
+ const ports = (io.createPorts ?? createStartAgentPorts)({
38195
+ cwd: argv.cwd,
38196
+ tokens,
38197
+ ...argv.org ? { org: argv.org } : {}
38198
+ });
38199
+ const result = await (io.run ?? runStartAgent)({
38200
+ command,
38201
+ ports,
38202
+ ...argv.dryRun ? { dryRun: true } : {}
38203
+ });
38204
+ if (result.exitCode !== 0) process.exitCode = result.exitCode;
38205
+ }
38206
+ // src/commands/start-agent/start-agent.command.ts
38207
+ const startAgentCommand = {
38208
+ command: "agent",
38209
+ describe: "Start an agent's program with the credentials of the `agent` Environment and nothing else: holocron start agent -- <command>",
38210
+ builder: (y) => y,
38211
+ handler: async (argv) => startAgent(argv)
38212
+ };
37265
38213
  // src/commands/start-work/start-work.command.ts
37266
38214
  const startWorkCommand = {
37267
38215
  command: "work <issue>",
@@ -37357,8 +38305,8 @@ const startWorkCommand = {
37357
38305
  // src/commands/start/start.command.ts
37358
38306
  const startCommand = {
37359
38307
  command: "start",
37360
- describe: "Start a piece of work: its branch, worktree, first commit and draft pull request",
37361
- builder: (y) => y.command(startWorkCommand).command(groupMenu("start")),
38308
+ describe: "Start a piece of work (its branch, worktree, first commit and draft pull request), or an agent's program with its own credentials",
38309
+ builder: (y) => y.command(startWorkCommand).command(startAgentCommand).command(groupMenu("start")),
37362
38310
  handler: () => {}
37363
38311
  };
37364
38312
  // src/commands/ideas-sync/resolve-ideas-provider/resolve-ideas-provider.ts
@@ -41038,6 +41986,7 @@ const COMMAND_MODULES = [
41038
41986
  resolveCommand,
41039
41987
  reconcileCommand,
41040
41988
  redeliverCommand,
41989
+ rotateCommand,
41041
41990
  projectCommand
41042
41991
  ];
41043
41992
  // src/cli/own-package-json.ts