@theholocron/cli 5.0.0-alpha.481 → 5.0.0-alpha.482

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
@@ -10,10 +10,10 @@ import { NonInteractiveError, commandFailureMessage, createProgress, createRetry
10
10
  import { LOG_LEVELS } from "@theholocron/observability/core";
11
11
  import yargs from "yargs";
12
12
  import { hideBin } from "yargs/helpers";
13
- import { appendFileSync, copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
13
+ import { appendFileSync, closeSync, copyFileSync, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync, writeSync } from "node:fs";
14
14
  import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
15
15
  import { Entry, findCredentials } from "@napi-rs/keyring";
16
- import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
16
+ import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, createPrivateFile, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
17
17
  import { DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, packageLocation, readWorkspacePackages, recordDeploys, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
18
18
  import { loadTasksConfig, releaseGroups } from "@theholocron/astromech/config";
19
19
  import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
@@ -29,12 +29,13 @@ import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
29
29
  import { promptForPositionals } from "@theholocron/kyber/prompts";
30
30
  import { fileURLToPath, pathToFileURL } from "node:url";
31
31
  import { errorMessage } from "@theholocron/misc-utils";
32
- import { execFileSync, spawn, spawnSync } from "node:child_process";
32
+ import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
33
33
  import { stringifyJson } from "@theholocron/json-utils";
34
34
  import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
35
35
  import { appManifestPage, buildAppManifest, convertAppManifest, serveAppManifest, serveHandler, superviseProcesses } from "@theholocron/dagobah";
36
36
  import { createGitHubClient, getApp, listAppInstallations } from "@theholocron/github-client";
37
37
  import { createServer } from "node:http";
38
+ import { promisify } from "node:util";
38
39
  import { ADR_DIR, ADR_STATUSES, CLOSED_STATUSES, SPEC_DIRS, SPEC_STATUSES, WITHDRAWN_STATE, assignSpecIds, checkSpecs, classifySpecPath, discussionBody, discussionIdLine, discussionPrLine, discussionTitle, evaluateDocsPresence, isAddedDocComment, isFeat, packageOf, parseFrontmatter, parseSkipDocs, reconcileSpecStatus, specSummary, specTitle, updateFrontmatter } from "@theholocron/astromech/repo-validation";
39
40
  import { loadConfigPath } from "@theholocron/datapad";
40
41
  import { moveMajorTag } from "@theholocron/kyber/git";
@@ -63,6 +64,7 @@ const COMMAND_CONTEXTS = {
63
64
  "list tokens": "global",
64
65
  "export tokens": "workspace",
65
66
  "export requests": "workspace",
67
+ "open requests": "workspace",
66
68
  "upload coverage": "workspace",
67
69
  "new github-app": "global",
68
70
  "check token": "global",
@@ -1001,6 +1003,18 @@ const npmBumpVersionsEntry = {
1001
1003
  ],
1002
1004
  supportsDryRun: true
1003
1005
  };
1006
+ // src/commands/open-requests/open-requests.entry.ts
1007
+ const openRequestsEntry = {
1008
+ name: "open requests",
1009
+ description: "Open the request tool's workspace with its secrets filled in from the layer's vault Environment",
1010
+ positionals: [],
1011
+ skipOptions: [
1012
+ "yes",
1013
+ "to",
1014
+ "environment"
1015
+ ],
1016
+ supportsDryRun: true
1017
+ };
1004
1018
  // src/commands/plugin-create/plugin-create.entry.ts
1005
1019
  const pluginCreateEntry = {
1006
1020
  name: "new plugin",
@@ -1588,6 +1602,7 @@ const registry = createCommandRegistry([
1588
1602
  authListEntry,
1589
1603
  authExportEntry,
1590
1604
  requestsExportEntry,
1605
+ openRequestsEntry,
1591
1606
  {
1592
1607
  name: "upload coverage",
1593
1608
  description: "Upload the repo's coverage reports, one flag per group, through the coverage provider",
@@ -7420,7 +7435,7 @@ async function runDoctorDns(input) {
7420
7435
  });
7421
7436
  else if (!loader.has("dns")) {
7422
7437
  const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
7423
- for (const zone of zones) rows.push(row$18(zone, "skip", why));
7438
+ for (const zone of zones) rows.push(row$19(zone, "skip", why));
7424
7439
  for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
7425
7440
  } else {
7426
7441
  const dns = loader.get("dns");
@@ -7442,7 +7457,7 @@ async function runDoctorDns(input) {
7442
7457
  ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
7443
7458
  };
7444
7459
  }
7445
- function row$18(zone, status, detail, problems = []) {
7460
+ function row$19(zone, status, detail, problems = []) {
7446
7461
  return {
7447
7462
  id: `dns-${zone}`,
7448
7463
  title: `${zone} records exist`,
@@ -7471,7 +7486,7 @@ async function checkDomain(dns, deploy, project, hostname) {
7471
7486
  return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
7472
7487
  }
7473
7488
  }
7474
- async function checkZone(dns, zone, wanted, rowOf = (...args) => row$18(zone, ...args)) {
7489
+ async function checkZone(dns, zone, wanted, rowOf = (...args) => row$19(zone, ...args)) {
7475
7490
  try {
7476
7491
  const have = await dns.listRecords(zone);
7477
7492
  const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
@@ -7606,7 +7621,7 @@ function installationSettingsUrl(account, id) {
7606
7621
  return `https://github.com/settings/installations/${id}`;
7607
7622
  }
7608
7623
  // src/commands/doctor-github-app/app-rows.ts
7609
- const row$17 = (name, what, problems, ok) => ({
7624
+ const row$18 = (name, what, problems, ok) => ({
7610
7625
  id: `${name}:${what}`,
7611
7626
  title: `${name}: ${what}`,
7612
7627
  status: problems.length > 0 ? "fail" : "ok",
@@ -7633,9 +7648,9 @@ function appRows(name, manifest, app, installations) {
7633
7648
  return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
7634
7649
  });
7635
7650
  return [
7636
- row$17(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
7637
- row$17(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
7638
- row$17(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
7651
+ row$18(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
7652
+ row$18(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
7653
+ row$18(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
7639
7654
  ];
7640
7655
  }
7641
7656
  // src/commands/doctor-github-app/parse-manifest.ts
@@ -7693,7 +7708,7 @@ async function runDoctorGitHubApp(input) {
7693
7708
  assertPluginsResolvable(loader, "doctor github-app");
7694
7709
  }
7695
7710
  const rows = [];
7696
- if (instances.length === 0) rows.push(row$16("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
7711
+ if (instances.length === 0) rows.push(row$17("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
7697
7712
  for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
7698
7713
  printCheckRows(rows, print);
7699
7714
  const summary = summariseChecks(rows);
@@ -7710,7 +7725,7 @@ async function runDoctorGitHubApp(input) {
7710
7725
  ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
7711
7726
  };
7712
7727
  }
7713
- function row$16(name, what, status, detail) {
7728
+ function row$17(name, what, status, detail) {
7714
7729
  return {
7715
7730
  id: `${name}:${what}`,
7716
7731
  title: `${name}: ${what}`,
@@ -7751,19 +7766,19 @@ async function checkInstance(instance, loader, input) {
7751
7766
  try {
7752
7767
  manifest = parseManifest(readManifest(instance.manifest));
7753
7768
  } catch (err) {
7754
- return [row$16(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
7769
+ return [row$17(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
7755
7770
  }
7756
7771
  const read = await readCredentials(instance, loader);
7757
- if ("reason" in read) return [row$16(name, "reachable", "skip", read.reason)];
7772
+ if ("reason" in read) return [row$17(name, "reachable", "skip", read.reason)];
7758
7773
  const api = input.api ?? defaultApi;
7759
7774
  const secrets = [read.creds.privateKey];
7760
7775
  try {
7761
7776
  const app = await api.getApp(read.creds);
7762
7777
  const installations = await api.listAppInstallations(read.creds);
7763
7778
  const owner = app.owner ? `, owned by ${app.owner.login}` : "";
7764
- return [row$16(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
7779
+ return [row$17(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
7765
7780
  } catch (err) {
7766
- return [row$16(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
7781
+ return [row$17(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
7767
7782
  }
7768
7783
  }
7769
7784
  // src/commands/doctor-github-app/doctor-github-app.command.ts
@@ -7830,7 +7845,7 @@ function datasetTargets(config) {
7830
7845
  * dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
7831
7846
  * 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.
7832
7847
  */
7833
- const row$15 = (id, title, status, detail, problems = []) => ({
7848
+ const row$16 = (id, title, status, detail, problems = []) => ({
7834
7849
  id,
7835
7850
  title,
7836
7851
  status,
@@ -7847,7 +7862,7 @@ async function runDoctorLogs(input) {
7847
7862
  if (!loader.has("logs")) {
7848
7863
  const failure = loader.loadFailures().find((f) => f.key === "logs");
7849
7864
  const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
7850
- rows.push(row$15("logs", "logs", "skip", why));
7865
+ rows.push(row$16("logs", "logs", "skip", why));
7851
7866
  } else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
7852
7867
  printCheckRows(rows, print);
7853
7868
  const summary = summariseChecks(rows);
@@ -7871,38 +7886,38 @@ async function checkLogs(logs, targets) {
7871
7886
  for (const target of targets) {
7872
7887
  const id = `logs:dataset:${target.id}`;
7873
7888
  const title = `dataset for ${target.label}`;
7874
- if (!target.name) rows.push(row$15(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
7875
- else if (!token.usable) rows.push(row$15(id, title, "skip", `${target.name}: not checked, the token is not usable`));
7876
- else if (!logs.readDataset) rows.push(row$15(id, title, "skip", `${logs.providerName} cannot read a dataset`));
7889
+ if (!target.name) rows.push(row$16(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
7890
+ else if (!token.usable) rows.push(row$16(id, title, "skip", `${target.name}: not checked, the token is not usable`));
7891
+ else if (!logs.readDataset) rows.push(row$16(id, title, "skip", `${logs.providerName} cannot read a dataset`));
7877
7892
  else rows.push(...await checkDataset(logs, target, target.name, id, title));
7878
7893
  }
7879
7894
  const org = resolveValue$1(["AXIOM_ORG"], void 0, { prefix: PREFIX$1 });
7880
- rows.push(org ? row$15("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$15("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links need it`));
7895
+ rows.push(org ? row$16("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$16("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links need it`));
7881
7896
  return rows;
7882
7897
  }
7883
7898
  /** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
7884
7899
  async function checkToken$1(logs, dataset) {
7885
7900
  const title = "token is accepted";
7886
7901
  if (!logs.checkToken) return {
7887
- row: row$15("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
7902
+ row: row$16("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
7888
7903
  usable: true
7889
7904
  };
7890
7905
  try {
7891
7906
  const result = await logs.checkToken(dataset);
7892
7907
  if (result.ok) return {
7893
- row: row$15("logs:token", title, "ok", `${logs.providerName} accepts the token`),
7908
+ row: row$16("logs:token", title, "ok", `${logs.providerName} accepts the token`),
7894
7909
  usable: true
7895
7910
  };
7896
7911
  const reason = result.reason ?? `${logs.providerName} refused the token`;
7897
7912
  return {
7898
- row: row$15("logs:token", title, "fail", reason, [reason]),
7913
+ row: row$16("logs:token", title, "fail", reason, [reason]),
7899
7914
  usable: false
7900
7915
  };
7901
7916
  } catch (err) {
7902
7917
  const noToken = missingTokenReason(err);
7903
7918
  const detail = noToken ?? `could not check the token: ${describeError(err)}`;
7904
7919
  return {
7905
- row: row$15("logs:token", title, "skip", detail),
7920
+ row: row$16("logs:token", title, "skip", detail),
7906
7921
  usable: noToken === void 0
7907
7922
  };
7908
7923
  }
@@ -7912,17 +7927,17 @@ async function checkDataset(logs, target, name, id, title) {
7912
7927
  const found = await logs.readDataset(name);
7913
7928
  if (found.forbidden) {
7914
7929
  const why = `${name}: not visible to this token (${logs.providerName} refused the read; it may also not exist)`;
7915
- return [row$15(id, title, "skip", why)];
7930
+ return [row$16(id, title, "skip", why)];
7916
7931
  }
7917
7932
  if (!found.exists) {
7918
7933
  const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
7919
- return [row$15(id, title, "fail", `${name} does not exist`, [problem])];
7934
+ return [row$16(id, title, "fail", `${name} does not exist`, [problem])];
7920
7935
  }
7921
7936
  const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
7922
- return [row$15(id, title, "ok", `${name} exists`), row$15(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
7937
+ return [row$16(id, title, "ok", `${name} exists`), row$16(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
7923
7938
  } catch (err) {
7924
7939
  const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
7925
- return [row$15(id, title, "skip", detail)];
7940
+ return [row$16(id, title, "skip", detail)];
7926
7941
  }
7927
7942
  }
7928
7943
  // src/commands/doctor-logs/doctor-logs.command.ts
@@ -11126,7 +11141,7 @@ const info = (id, title, noun, extras) => ({
11126
11141
  detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
11127
11142
  problems: extras
11128
11143
  });
11129
- const row$14 = (id, title, problems, ok) => ({
11144
+ const row$15 = (id, title, problems, ok) => ({
11130
11145
  id,
11131
11146
  title,
11132
11147
  status: problems.length > 0 ? "fail" : "ok",
@@ -11162,19 +11177,19 @@ function viewProblems(want, found) {
11162
11177
  function boardRows(boardName, template, state) {
11163
11178
  const id = `project:${boardName}`;
11164
11179
  const rows = [];
11165
- rows.push(row$14(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
11180
+ rows.push(row$15(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
11166
11181
  const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
11167
11182
  if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
11168
- for (const want of template.fields) rows.push(row$14(`${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));
11183
+ for (const want of template.fields) rows.push(row$15(`${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));
11169
11184
  const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
11170
11185
  if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
11171
- for (const want of template.views) rows.push(row$14(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
11186
+ for (const want of template.views) rows.push(row$15(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
11172
11187
  const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
11173
11188
  if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
11174
11189
  for (const name of template.rules ?? []) {
11175
11190
  const found = state.rules.find((r) => r.name === name);
11176
11191
  const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
11177
- rows.push(row$14(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
11192
+ rows.push(row$15(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
11178
11193
  }
11179
11194
  return rows;
11180
11195
  }
@@ -11234,7 +11249,7 @@ function itemRows(boardName, items) {
11234
11249
  * never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
11235
11250
  * failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
11236
11251
  */
11237
- const row$13 = (id, title, status, detail, problems = []) => ({
11252
+ const row$14 = (id, title, status, detail, problems = []) => ({
11238
11253
  id,
11239
11254
  title,
11240
11255
  status,
@@ -11288,14 +11303,14 @@ async function checkBoards(input, loader) {
11288
11303
  loader,
11289
11304
  ...input.io ? { io: input.io } : {}
11290
11305
  });
11291
- if (!opened.ok) return [row$13("project", "project", opened.kind, opened.reason, opened.problems)];
11306
+ if (!opened.ok) return [row$14("project", "project", opened.kind, opened.reason, opened.problems)];
11292
11307
  const { projects, owner, boards, templates, templateProblems } = opened.context;
11293
11308
  const rows = templateProblems.map((problem) => {
11294
11309
  /* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
11295
11310
  const file = problem.split(": ")[0] ?? problem;
11296
- return row$13(`project:template:${file}`, `template file ${file}`, "fail", problem);
11311
+ return row$14(`project:template:${file}`, `template file ${file}`, "fail", problem);
11297
11312
  });
11298
- if (boards.length === 0) return [...rows, row$13("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
11313
+ if (boards.length === 0) return [...rows, row$14("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
11299
11314
  for (const declared of boards) {
11300
11315
  const template = templates[declared.template];
11301
11316
  const title = `${declared.name}: board exists and is open`;
@@ -11303,18 +11318,18 @@ async function checkBoards(input, loader) {
11303
11318
  const board = await projects.find(owner, declared.name);
11304
11319
  if (!board) {
11305
11320
  const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
11306
- rows.push(row$13(`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`"]));
11321
+ rows.push(row$14(`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`"]));
11307
11322
  continue;
11308
11323
  }
11309
- rows.push(row$13(`project:${declared.name}`, title, "ok", board.url));
11324
+ rows.push(row$14(`project:${declared.name}`, title, "ok", board.url));
11310
11325
  if (!template) {
11311
- rows.push(row$13(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
11326
+ rows.push(row$14(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
11312
11327
  continue;
11313
11328
  }
11314
11329
  rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
11315
- rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$13(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
11330
+ rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$14(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
11316
11331
  } catch (err) {
11317
- rows.push(row$13(`project:${declared.name}`, title, "fail", describeError(err)));
11332
+ rows.push(row$14(`project:${declared.name}`, title, "fail", describeError(err)));
11318
11333
  }
11319
11334
  }
11320
11335
  return rows;
@@ -11404,14 +11419,14 @@ function parseTagList(output) {
11404
11419
  }];
11405
11420
  });
11406
11421
  }
11407
- const defaultDeps = {
11422
+ const defaultDeps$1 = {
11408
11423
  spawn: (command, args, options) => spawnSync(command, args, options),
11409
11424
  fetch: (url) => fetch(url),
11410
11425
  discover: discoverPublicPackages,
11411
11426
  nowMs: () => Date.now()
11412
11427
  };
11413
11428
  /** `doctor releases`' inputs from the real git checkout under `repoRoot`, the npm registry and the workspace. */
11414
- function realReleasesIo(repoRoot, deps = defaultDeps) {
11429
+ function realReleasesIo(repoRoot, deps = defaultDeps$1) {
11415
11430
  return {
11416
11431
  tags: () => {
11417
11432
  const result = deps.spawn("git", [
@@ -12234,19 +12249,19 @@ async function runDoctorRepo(input) {
12234
12249
  const rows = [];
12235
12250
  if (!loader.has("source")) {
12236
12251
  const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
12237
- for (const check of checks) rows.push(row$12(check, { skip: why }));
12252
+ for (const check of checks) rows.push(row$13(check, { skip: why }));
12238
12253
  } else {
12239
12254
  const source = loader.get("source");
12240
12255
  for (const check of checks) {
12241
12256
  if (typeof source[check.needs] !== "function") {
12242
- rows.push(row$12(check, { skip: `provider does not implement ${check.needs}` }));
12257
+ rows.push(row$13(check, { skip: `provider does not implement ${check.needs}` }));
12243
12258
  continue;
12244
12259
  }
12245
12260
  try {
12246
- rows.push(row$12(check, await check.run(source)));
12261
+ rows.push(row$13(check, await check.run(source)));
12247
12262
  } catch (err) {
12248
12263
  const noToken = missingTokenReason(err);
12249
- if (noToken !== void 0) rows.push(row$12(check, { skip: noToken }));
12264
+ if (noToken !== void 0) rows.push(row$13(check, { skip: noToken }));
12250
12265
  else rows.push({
12251
12266
  id: check.id,
12252
12267
  title: check.title,
@@ -12272,7 +12287,7 @@ async function runDoctorRepo(input) {
12272
12287
  ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
12273
12288
  };
12274
12289
  }
12275
- function row$12(check, result) {
12290
+ function row$13(check, result) {
12276
12291
  const { id, title } = check;
12277
12292
  if ("skip" in result) return {
12278
12293
  id,
@@ -12795,7 +12810,7 @@ function providerGroup(providerName) {
12795
12810
  }
12796
12811
  // src/commands/doctor-secrets/credentials-rows.ts
12797
12812
  /** A row for the provider as a whole, or for one of its variables when `name` is given. */
12798
- function row$11(provider, status, detail, name) {
12813
+ function row$12(provider, status, detail, name) {
12799
12814
  return name === void 0 ? {
12800
12815
  id: provider,
12801
12816
  title: provider,
@@ -12820,10 +12835,10 @@ async function credentialsRows(input) {
12820
12835
  const { loader } = input;
12821
12836
  const { resolved } = input.loaded;
12822
12837
  if (!resolved.providers.credentials) return {
12823
- rows: input.asked ? [row$11("credentials", "skip", "no `credentials` provider is configured")] : [],
12838
+ rows: input.asked ? [row$12("credentials", "skip", "no `credentials` provider is configured")] : [],
12824
12839
  places: []
12825
12840
  };
12826
- const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$11(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
12841
+ const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$12(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
12827
12842
  const places = [];
12828
12843
  if (!loader.has("credentials")) return {
12829
12844
  rows,
@@ -12835,7 +12850,7 @@ async function credentialsRows(input) {
12835
12850
  const tuple = tuples.find((t) => t.provider === impl.providerName);
12836
12851
  const explicit = tuple && credentialsEnvironment(tuple, resolved);
12837
12852
  if (!explicit && !derivesEnvironment(impl.providerName)) {
12838
- rows.push(row$11(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
12853
+ rows.push(row$12(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
12839
12854
  continue;
12840
12855
  }
12841
12856
  try {
@@ -12847,7 +12862,7 @@ async function credentialsRows(input) {
12847
12862
  rows.push(...checked.rows);
12848
12863
  places.push(...checked.places);
12849
12864
  } catch (err) {
12850
- rows.push(row$11(impl.providerName, "fail", errorMessage(err)));
12865
+ rows.push(row$12(impl.providerName, "fail", errorMessage(err)));
12851
12866
  }
12852
12867
  }
12853
12868
  return {
@@ -12863,17 +12878,17 @@ async function credentialsRows(input) {
12863
12878
  async function checkProvider(impl, candidates, expected, synced) {
12864
12879
  const provider = impl.providerName;
12865
12880
  if (!impl.inspect) return {
12866
- rows: [row$11(provider, "skip", "cannot list the variables without reading their values")],
12881
+ rows: [row$12(provider, "skip", "cannot list the variables without reading their values")],
12867
12882
  places: []
12868
12883
  };
12869
12884
  if (expected.length === 0) return {
12870
- rows: [row$11(provider, "skip", "no configured plugin lists the tokens it takes")],
12885
+ rows: [row$12(provider, "skip", "no configured plugin lists the tokens it takes")],
12871
12886
  places: []
12872
12887
  };
12873
12888
  const inspect = impl.inspect.bind(impl);
12874
12889
  try {
12875
12890
  const { found, missing } = await tryEnvironments(candidates, inspect);
12876
- const rows = missing.map((name) => row$11(provider, "fail", `${provider} has no Environment named "${name}"`));
12891
+ const rows = missing.map((name) => row$12(provider, "fail", `${provider} has no Environment named "${name}"`));
12877
12892
  const group = providerGroup(provider);
12878
12893
  const unreadPlaces = missing.map((name) => ({
12879
12894
  column: {
@@ -12896,9 +12911,9 @@ async function checkProvider(impl, candidates, expected, synced) {
12896
12911
  const have = (name) => found.some((f) => f.result.names.includes(name));
12897
12912
  let present = 0;
12898
12913
  for (const { name, optional } of expected) if (have(name)) present++;
12899
- else if (optional) rows.push(row$11(provider, "skip", `optional, not set in ${where}`, name));
12900
- else rows.push(row$11(provider, "fail", `missing from ${where}`, name));
12901
- if (present > 0) rows.push(row$11(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
12914
+ else if (optional) rows.push(row$12(provider, "skip", `optional, not set in ${where}`, name));
12915
+ else rows.push(row$12(provider, "fail", `missing from ${where}`, name));
12916
+ if (present > 0) rows.push(row$12(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
12902
12917
  const names = new Set(expected.map((e) => e.name));
12903
12918
  const places = [];
12904
12919
  const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
@@ -12937,7 +12952,7 @@ async function checkProvider(impl, candidates, expected, synced) {
12937
12952
  };
12938
12953
  } catch (err) {
12939
12954
  return {
12940
- rows: [row$11(provider, "fail", errorMessage(err))],
12955
+ rows: [row$12(provider, "fail", errorMessage(err))],
12941
12956
  places: []
12942
12957
  };
12943
12958
  }
@@ -13811,7 +13826,7 @@ async function variableRows(loader, config, org) {
13811
13826
  if (!loader.has("source")) {
13812
13827
  const why = whyMissing(loader, "source", "no `source` provider to read them with");
13813
13828
  for (const check of checks) {
13814
- rows.push(row$10(check, { skip: why }));
13829
+ rows.push(row$11(check, { skip: why }));
13815
13830
  observations.push({
13816
13831
  scope: check.scope,
13817
13832
  unread: why
@@ -13821,7 +13836,7 @@ async function variableRows(loader, config, org) {
13821
13836
  const source = loader.get("source");
13822
13837
  for (const check of checks) try {
13823
13838
  const result = await check.run(source);
13824
- rows.push(row$10(check, result));
13839
+ rows.push(row$11(check, result));
13825
13840
  observations.push("skip" in result ? {
13826
13841
  scope: check.scope,
13827
13842
  unread: result.skip
@@ -13832,7 +13847,7 @@ async function variableRows(loader, config, org) {
13832
13847
  } catch (err) {
13833
13848
  const noToken = missingTokenReason(err);
13834
13849
  if (noToken !== void 0) {
13835
- rows.push(row$10(check, { skip: noToken }));
13850
+ rows.push(row$11(check, { skip: noToken }));
13836
13851
  observations.push({
13837
13852
  scope: check.scope,
13838
13853
  unread: noToken
@@ -13858,7 +13873,7 @@ async function variableRows(loader, config, org) {
13858
13873
  observations
13859
13874
  };
13860
13875
  }
13861
- function row$10(check, result) {
13876
+ function row$11(check, result) {
13862
13877
  const { id, title } = check;
13863
13878
  if ("skip" in result) return {
13864
13879
  id,
@@ -13948,7 +13963,7 @@ function describeExpiry(expiresAt, now) {
13948
13963
  *
13949
13964
  * What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
13950
13965
  */
13951
- function row$9(id, status, detail) {
13966
+ function row$10(id, status, detail) {
13952
13967
  return {
13953
13968
  id: `verify:${id}`,
13954
13969
  title: `verify ${id}`,
@@ -13976,12 +13991,12 @@ async function verifyRows(input) {
13976
13991
  try {
13977
13992
  module = await importer(pkg);
13978
13993
  } catch (err) {
13979
- rows.push(row$9(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
13994
+ rows.push(row$10(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
13980
13995
  continue;
13981
13996
  }
13982
13997
  for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
13983
13998
  }
13984
- if (rows.length === 0) rows.push(row$9("tokens", "skip", "no configured plugin lists the tokens it takes"));
13999
+ if (rows.length === 0) rows.push(row$10("tokens", "skip", "no configured plugin lists the tokens it takes"));
13985
14000
  return rows;
13986
14001
  }
13987
14002
  /**
@@ -13994,30 +14009,30 @@ async function loadCredentials(input) {
13994
14009
  try {
13995
14010
  await input.loader.load();
13996
14011
  } catch (err) {
13997
- return [row$9("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
14012
+ return [row$10("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
13998
14013
  }
13999
- return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$9(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
14014
+ return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$10(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
14000
14015
  }
14001
14016
  async function checkToken(token, module, env, readToken, now) {
14002
14017
  const { keyringKey, envName, vendorEnvName } = token;
14003
14018
  const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
14004
14019
  const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
14005
14020
  const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
14006
- if (!value) return row$9(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
14021
+ if (!value) return row$10(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
14007
14022
  const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
14008
- if (!verify) return row$9(keyringKey, "skip", "set, but its plugin cannot verify it");
14023
+ if (!verify) return row$10(keyringKey, "skip", "set, but its plugin cannot verify it");
14009
14024
  const from = fromEnv ?? stored?.source ?? "keyring";
14010
14025
  try {
14011
14026
  const verified = await verify(value);
14012
- if (!verified.ok) return row$9(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
14027
+ if (!verified.ok) return row$10(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
14013
14028
  const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
14014
- if (!expiry) return row$9(keyringKey, "ok", `${verified.subject} (${from})`);
14029
+ if (!expiry) return row$10(keyringKey, "ok", `${verified.subject} (${from})`);
14015
14030
  return expiry.soon ? {
14016
- ...row$9(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
14031
+ ...row$10(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
14017
14032
  problems: [`${expiry.text}: renew it`]
14018
- } : row$9(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
14033
+ } : row$10(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
14019
14034
  } catch (err) {
14020
- return row$9(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
14035
+ return row$10(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
14021
14036
  }
14022
14037
  }
14023
14038
  // src/commands/doctor-secrets/doctor-secrets.ts
@@ -14744,7 +14759,7 @@ function summariseProbeRows(id, title, rows) {
14744
14759
  * provider with no `token` probe, no declared layer, or one that cannot be read is a skip with the reason.
14745
14760
  */
14746
14761
  const PROBE = "token";
14747
- const row$8 = (id, title, status, detail, problems = []) => ({
14762
+ const row$9 = (id, title, status, detail, problems = []) => ({
14748
14763
  id,
14749
14764
  title,
14750
14765
  status,
@@ -14769,12 +14784,12 @@ async function runDoctorTokens(input) {
14769
14784
  try {
14770
14785
  tokens = await providerTokens(provider);
14771
14786
  } catch (err) {
14772
- rows.push(row$8(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
14787
+ rows.push(row$9(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
14773
14788
  continue;
14774
14789
  }
14775
14790
  const expectations = tokenExpectations(tokens);
14776
- if (expectations.length === 0) rows.push(row$8(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
14777
- else if (!usableProbe(probes.get(provider))) rows.push(row$8(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
14791
+ if (expectations.length === 0) rows.push(row$9(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
14792
+ else if (!usableProbe(probes.get(provider))) rows.push(row$9(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
14778
14793
  else declared.push({
14779
14794
  provider,
14780
14795
  tokens,
@@ -14836,14 +14851,14 @@ async function checkLayer(c) {
14836
14851
  tokens
14837
14852
  });
14838
14853
  } catch (err) {
14839
- if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$8(id(e), title(e), "fail", "not held in this layer", [err.message]));
14840
- return c.wanted.map((e) => row$8(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
14854
+ if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$9(id(e), title(e), "fail", "not held in this layer", [err.message]));
14855
+ return c.wanted.map((e) => row$9(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
14841
14856
  }
14842
14857
  const rows = [];
14843
14858
  for (const e of c.wanted) {
14844
14859
  const token = held.held.find((h) => h.envName === e.envName);
14845
14860
  if (!token) {
14846
- rows.push(row$8(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
14861
+ rows.push(row$9(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
14847
14862
  continue;
14848
14863
  }
14849
14864
  rows.push(summariseProbeRows(id(e), title(e), await probeToken(c, e, token.token, held.plain)));
@@ -14916,7 +14931,7 @@ const doctorTokensCommand = {
14916
14931
  }
14917
14932
  };
14918
14933
  // src/commands/doctor-wiki/wiki-rows.ts
14919
- const row$7 = (id, title, status, detail, problems = []) => ({
14934
+ const row$8 = (id, title, status, detail, problems = []) => ({
14920
14935
  id,
14921
14936
  title,
14922
14937
  status,
@@ -14932,11 +14947,11 @@ const names = (paths) => paths.length > LISTED ? `${paths.slice(0, LISTED).join(
14932
14947
  * skip, since a machine with no network says nothing about the site.
14933
14948
  */
14934
14949
  function siteRow(id, title, probe, notFoundHint) {
14935
- if (probe.status === void 0) return row$7(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
14936
- if (probe.status < 400) return row$7(id, title, "ok", `${probe.url} answers ${probe.status}`);
14937
- if (probe.status === 401 || probe.status === 403) return row$7(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
14950
+ if (probe.status === void 0) return row$8(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
14951
+ if (probe.status < 400) return row$8(id, title, "ok", `${probe.url} answers ${probe.status}`);
14952
+ if (probe.status === 401 || probe.status === 403) return row$8(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
14938
14953
  const problem = probe.status === 404 ? `${probe.url} answers 404; ${notFoundHint}` : `${probe.url} answers ${probe.status}, expected a page`;
14939
- return row$7(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
14954
+ return row$8(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
14940
14955
  }
14941
14956
  /**
14942
14957
  * The rows `holocron doctor wiki` prints for one {@link WikiInspection}: organization, docs instance, the site and its
@@ -14948,42 +14963,42 @@ function wikiRows(found, providerName) {
14948
14963
  const { declared, found: foundOrg } = found.organization;
14949
14964
  if (foundOrg === null) {
14950
14965
  const problem = `fern/fern.config.json has no organization; \`holocron setup\` writes it`;
14951
- rows.push(row$7("wiki:organization", "organization is set", "fail", problem, [problem]));
14966
+ rows.push(row$8("wiki:organization", "organization is set", "fail", problem, [problem]));
14952
14967
  } else if (foundOrg !== declared) {
14953
14968
  const problem = `fern/fern.config.json names ${foundOrg}, the config declares ${declared}; run \`holocron setup\``;
14954
- rows.push(row$7("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
14955
- } else rows.push(row$7("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
14969
+ rows.push(row$8("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
14970
+ } else rows.push(row$8("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
14956
14971
  const instance = found.instance;
14957
14972
  if (instance === null) {
14958
14973
  const problem = "fern/docs.yml does not exist; `holocron setup` writes it";
14959
- rows.push(row$7("wiki:instance", "docs site is declared", "fail", problem, [problem]));
14974
+ rows.push(row$8("wiki:instance", "docs site is declared", "fail", problem, [problem]));
14960
14975
  } else {
14961
14976
  const problems = [];
14962
14977
  if (instance.foundUrl !== instance.expectedUrl) problems.push(`instance url is ${instance.foundUrl ?? "not set"}, expected ${instance.expectedUrl}`);
14963
14978
  if (instance.expectedDomain !== void 0 && instance.foundDomain !== instance.expectedDomain) problems.push(`custom-domain is ${instance.foundDomain ?? "not set"}, expected ${instance.expectedDomain}`);
14964
- rows.push(problems.length > 0 ? row$7("wiki:instance", "docs site is declared", "fail", `${problems.length} problem(s)`, [...problems.map((p) => `fern/docs.yml: ${p}`)]) : row$7("wiki:instance", "docs site is declared", "ok", `${instance.expectedUrl} in fern/docs.yml`));
14979
+ rows.push(problems.length > 0 ? row$8("wiki:instance", "docs site is declared", "fail", `${problems.length} problem(s)`, [...problems.map((p) => `fern/docs.yml: ${p}`)]) : row$8("wiki:instance", "docs site is declared", "ok", `${instance.expectedUrl} in fern/docs.yml`));
14965
14980
  }
14966
14981
  const [site, domain] = found.site;
14967
14982
  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\`)`));
14968
14983
  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`));
14969
- if (found.navigation === null) rows.push(row$7("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
14984
+ if (found.navigation === null) rows.push(row$8("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
14970
14985
  else if (found.navigation.missing.length > 0) {
14971
14986
  const problems = found.navigation.missing.map((p) => `${p} is listed in fern/docs.yml but is not on disk`);
14972
- rows.push(row$7("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
14987
+ rows.push(row$8("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
14973
14988
  } else {
14974
- rows.push(row$7("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
14975
- if (found.navigation.unlisted.length > 0) rows.push(row$7("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`));
14989
+ rows.push(row$8("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
14990
+ if (found.navigation.unlisted.length > 0) rows.push(row$8("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`));
14976
14991
  }
14977
14992
  const published = found.published;
14978
14993
  const listed = found.navigation?.listed;
14979
- if (!published) rows.push(row$7("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
14994
+ if (!published) rows.push(row$8("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
14980
14995
  else if (published.pages === void 0) {
14981
14996
  const why = published.status === void 0 ? published.error ?? "no answer" : `answered ${published.status}`;
14982
- rows.push(row$7("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
14997
+ rows.push(row$8("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
14983
14998
  } else if (listed !== void 0 && published.pages < listed) {
14984
14999
  const problem = `${published.url} lists ${published.pages} page(s), the navigation lists ${listed}; the last publish is behind (run the wiki workflow)`;
14985
- rows.push(row$7("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
14986
- } else rows.push(row$7("wiki:published", "published pages", "ok", listed === void 0 ? `${published.pages} page(s) in ${published.url}` : `${published.pages} page(s) published for ${listed} listed`));
15000
+ rows.push(row$8("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
15001
+ } else rows.push(row$8("wiki:published", "published pages", "ok", listed === void 0 ? `${published.pages} page(s) in ${published.url}` : `${published.pages} page(s) published for ${listed} listed`));
14987
15002
  return rows;
14988
15003
  }
14989
15004
  // src/commands/doctor-wiki/doctor-wiki.ts
@@ -15975,7 +15990,7 @@ function resolveExportDir(input) {
15975
15990
  * listed under the provider's row and does not fail the run. It writes files, so it asks first unless `--dry-run` (the
15976
15991
  * files are converted and listed, nothing is written) or `--yes` (without a terminal it refuses instead).
15977
15992
  */
15978
- const row$6 = (id, status, detail, problems = []) => ({
15993
+ const row$7 = (id, status, detail, problems = []) => ({
15979
15994
  id,
15980
15995
  title: id,
15981
15996
  status,
@@ -16017,9 +16032,9 @@ async function runRequestsExport(input) {
16017
16032
  print("");
16018
16033
  const entry = input.loaded.resolved.providers.tooling;
16019
16034
  const tuples = entry?.cardinality === "many" ? entry.tuples : [];
16020
- if (tuples.length === 0) return finish([row$6("tooling", "fail", "the config has no `tooling` provider to export for")]);
16035
+ if (tuples.length === 0) return finish([row$7("tooling", "fail", "the config has no `tooling` provider to export for")]);
16021
16036
  const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
16022
- if (chosen.length === 0) return finish([row$6(input.to, "fail", `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`)]);
16037
+ if (chosen.length === 0) return finish([row$7(input.to, "fail", `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`)]);
16023
16038
  /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
16024
16039
  const loader = input.loader ?? new PluginLoader({
16025
16040
  ...input.loaded.resolved,
@@ -16039,17 +16054,17 @@ async function runRequestsExport(input) {
16039
16054
  const tool = loaded.find((t) => t.providerName === id);
16040
16055
  if (!tool) {
16041
16056
  const failure = loader.loadFailures().find((f) => f.key === "tooling" && f.provider === id);
16042
- rows.push(row$6(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
16057
+ rows.push(row$7(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
16043
16058
  continue;
16044
16059
  }
16045
16060
  if (!tool.export) {
16046
- rows.push(row$6(id, "skip", "has no export: it reads the repo's files as they are"));
16061
+ rows.push(row$7(id, "skip", "has no export: it reads the repo's files as they are"));
16047
16062
  continue;
16048
16063
  }
16049
16064
  const collectionFiles = fileList$1(tuple.options.collectionFiles);
16050
16065
  const envFiles = fileList$1(tuple.options.envFiles);
16051
16066
  if (collectionFiles.length === 0) {
16052
- rows.push(row$6(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
16067
+ rows.push(row$7(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
16053
16068
  continue;
16054
16069
  }
16055
16070
  const groups = input.out === void 0 ? groupByFolder(collectionFiles) : [collectionFiles];
@@ -16063,7 +16078,7 @@ async function runRequestsExport(input) {
16063
16078
  ...input.out !== void 0 ? { out: input.out } : {}
16064
16079
  });
16065
16080
  if (!dir.ok) {
16066
- rows.push(row$6(label, "fail", dir.message));
16081
+ rows.push(row$7(label, "fail", dir.message));
16067
16082
  continue;
16068
16083
  }
16069
16084
  targets.push({
@@ -16102,9 +16117,9 @@ async function runRequestsExport(input) {
16102
16117
  const where = relative(repoRoot, outDir);
16103
16118
  const files = result.files.length > 0 ? ` (${result.files.join(", ")})` : "";
16104
16119
  paths.push(...result.files.map((file) => resolve(outDir, file)));
16105
- rows.push(row$6(label, "ok", `${dryRun ? "would write" : "wrote"} ${result.files.length} file(s) to ${where}${files}`, result.issues.map((issue) => `issue in ${issue.file}: ${issue.message}`)));
16120
+ rows.push(row$7(label, "ok", `${dryRun ? "would write" : "wrote"} ${result.files.length} file(s) to ${where}${files}`, result.issues.map((issue) => `issue in ${issue.file}: ${issue.message}`)));
16106
16121
  } catch (err) {
16107
- rows.push(row$6(label, "fail", describeError(err)));
16122
+ rows.push(row$7(label, "fail", describeError(err)));
16108
16123
  }
16109
16124
  const report = finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
16110
16125
  if (paths.length > 0) {
@@ -19878,7 +19893,7 @@ const githubAppCreateCommand = {
19878
19893
  };
19879
19894
  // src/commands/ideas-promote/build-spec/build-spec.ts
19880
19895
  const FILED_FROM = /^Filed from idea:.*$/;
19881
- const MARKER = /^<!-- holocron:idea [^>]*-->$/;
19896
+ const MARKER$1 = /^<!-- holocron:idea [^>]*-->$/;
19882
19897
  /**
19883
19898
  * A draft spec from an issue: frontmatter (`status: draft`, the `issue`, no `blocked-by`, and no `id`, which
19884
19899
  * `sync specs` assigns), the title as the heading, and a `Problem` section holding the issue's text. The `Filed from
@@ -19890,7 +19905,7 @@ function buildSpec(input) {
19890
19905
  let fromIdea = false;
19891
19906
  const kept = lines.filter((line) => {
19892
19907
  const trimmed = line.trim();
19893
- if (FILED_FROM.test(trimmed) || MARKER.test(trimmed)) {
19908
+ if (FILED_FROM.test(trimmed) || MARKER$1.test(trimmed)) {
19894
19909
  fromIdea = true;
19895
19910
  return false;
19896
19911
  }
@@ -19969,7 +19984,7 @@ function specName(title, name) {
19969
19984
  */
19970
19985
  /** How many lines of the spec a dry run shows. */
19971
19986
  const PREVIEW_LINES$1 = 12;
19972
- const row$5 = (id, status, detail) => ({
19987
+ const row$6 = (id, status, detail) => ({
19973
19988
  id,
19974
19989
  title: id,
19975
19990
  status,
@@ -19999,7 +20014,7 @@ async function runIdeasPromote(input) {
19999
20014
  print(style.header(`Holocron new spec${dryRun ? " (dry-run)" : ""}`));
20000
20015
  print("");
20001
20016
  const entry = input.loaded.resolved.providers.issues;
20002
- if (!entry) return finish([row$5(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
20017
+ if (!entry) return finish([row$6(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
20003
20018
  const credentials = input.loaded.resolved.providers.credentials;
20004
20019
  /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
20005
20020
  const loader = input.loader ?? new PluginLoader({
@@ -20014,18 +20029,18 @@ async function runIdeasPromote(input) {
20014
20029
  assertPluginsResolvable(loader, "new spec");
20015
20030
  if (!loader.has("issues")) {
20016
20031
  const failure = loader.loadFailures().find((f) => f.key === "issues");
20017
- return finish([row$5(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
20032
+ return finish([row$6(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
20018
20033
  }
20019
20034
  let issue;
20020
20035
  try {
20021
20036
  issue = await loader.get("issues").get(input.issue);
20022
20037
  } catch (err) {
20023
- return finish([row$5(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
20038
+ return finish([row$6(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
20024
20039
  }
20025
20040
  const name = specName(issue.summary, input.name);
20026
- if (!name) return finish([row$5(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`)]);
20041
+ if (!name) return finish([row$6(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`)]);
20027
20042
  const relative = join(".notes", `${name}.spec.md`);
20028
- if (io.exists(join(input.context.repoRoot, relative))) return finish([row$5(relative, "fail", "the spec already exists; it is never overwritten")], relative);
20043
+ if (io.exists(join(input.context.repoRoot, relative))) return finish([row$6(relative, "fail", "the spec already exists; it is never overwritten")], relative);
20029
20044
  const { org, name: repoName } = input.loaded.resolved;
20030
20045
  const ref = githubRef(issue.url) ?? (issue.key.startsWith("#") ? `${org}/${repoName}${issue.key}` : issue.key);
20031
20046
  const { content, fromIdea } = buildSpec({
@@ -20038,7 +20053,7 @@ async function runIdeasPromote(input) {
20038
20053
  print(` ${relative}`);
20039
20054
  for (const line of content.split("\n").slice(0, PREVIEW_LINES$1)) print(` ${style.skip(line)}`);
20040
20055
  print("");
20041
- return finish([row$5(relative, "skip", `would write the spec ${origin}`)], relative);
20056
+ return finish([row$6(relative, "skip", `would write the spec ${origin}`)], relative);
20042
20057
  }
20043
20058
  if (!input.yes) {
20044
20059
  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`);
@@ -20057,9 +20072,9 @@ async function runIdeasPromote(input) {
20057
20072
  try {
20058
20073
  io.write(join(input.context.repoRoot, relative), content);
20059
20074
  } catch (err) {
20060
- return finish([row$5(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
20075
+ return finish([row$6(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
20061
20076
  }
20062
- return finish([row$5(relative, "ok", `wrote the spec ${origin}`)], relative);
20077
+ return finish([row$6(relative, "ok", `wrote the spec ${origin}`)], relative);
20063
20078
  }
20064
20079
  // src/commands/ideas-promote/ideas-promote.command.ts
20065
20080
  const ideasPromoteCommand = {
@@ -20113,7 +20128,7 @@ function readIssueBody(file, cwd, read = (p) => readFileSync(p, "utf8")) {
20113
20128
  */
20114
20129
  /** How many lines of the body a dry run shows. */
20115
20130
  const PREVIEW_LINES = 8;
20116
- const row$4 = (id, status, detail) => ({
20131
+ const row$5 = (id, status, detail) => ({
20117
20132
  id,
20118
20133
  title: id,
20119
20134
  status,
@@ -20137,9 +20152,9 @@ async function runIssueCreate(input) {
20137
20152
  print(style.header(`Holocron new issue${dryRun ? " (dry-run)" : ""}`));
20138
20153
  print("");
20139
20154
  const title = input.title.trim();
20140
- if (!title) return finish([row$4("title", "fail", "the title is empty")]);
20155
+ if (!title) return finish([row$5("title", "fail", "the title is empty")]);
20141
20156
  const entry = input.loaded.resolved.providers.issues;
20142
- if (!entry) return finish([row$4(title, "fail", "the config has no `issues` provider to file the issue with")]);
20157
+ if (!entry) return finish([row$5(title, "fail", "the config has no `issues` provider to file the issue with")]);
20143
20158
  const credentials = input.loaded.resolved.providers.credentials;
20144
20159
  /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
20145
20160
  const loader = input.loader ?? new PluginLoader({
@@ -20154,7 +20169,7 @@ async function runIssueCreate(input) {
20154
20169
  assertPluginsResolvable(loader, "new issue");
20155
20170
  if (!loader.has("issues")) {
20156
20171
  const failure = loader.loadFailures().find((f) => f.key === "issues");
20157
- return finish([row$4(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
20172
+ return finish([row$5(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
20158
20173
  }
20159
20174
  const labels = [...new Set((input.labels ?? []).map((l) => l.trim()).filter(Boolean))];
20160
20175
  const body = input.body?.trim() ? input.body : void 0;
@@ -20170,7 +20185,7 @@ async function runIssueCreate(input) {
20170
20185
  print(` ${title}`);
20171
20186
  for (const line of (body ?? "").split("\n").slice(0, PREVIEW_LINES)) print(` ${style.skip(line)}`);
20172
20187
  print("");
20173
- return finish([row$4(title, "skip", `would file the issue${summary}`)]);
20188
+ return finish([row$5(title, "skip", `would file the issue${summary}`)]);
20174
20189
  }
20175
20190
  if (!input.yes) {
20176
20191
  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");
@@ -20193,9 +20208,9 @@ async function runIssueCreate(input) {
20193
20208
  ...milestone ? { milestone } : {},
20194
20209
  ...assignees.length > 0 ? { assignees } : {}
20195
20210
  });
20196
- return finish([row$4(title, "ok", `filed ${key}`), ...(dropped ?? []).map((line) => row$4("not carried across", "skip", line))], key);
20211
+ return finish([row$5(title, "ok", `filed ${key}`), ...(dropped ?? []).map((line) => row$5("not carried across", "skip", line))], key);
20197
20212
  } catch (err) {
20198
- return finish([row$4(title, "fail", `could not file the issue: ${describeError(err)}`)]);
20213
+ return finish([row$5(title, "fail", `could not file the issue: ${describeError(err)}`)]);
20199
20214
  }
20200
20215
  }
20201
20216
  // src/commands/issue-create/issue-create.command.ts
@@ -22855,6 +22870,403 @@ const newCommand = {
22855
22870
  builder: (y) => y.command(newRepoCommand).command(pluginCreateCommand).command(notificationsChannelAddCommand).command(githubAppCreateCommand).command(projectCreateCommand).command(secretSetCommand).command(notificationsCreateServerCommand).command(ideasPromoteCommand).command(issueCreateCommand).command(authSetCommand).command(tunnelUpCommand).command(newDomainCommand).command(groupMenu("new")),
22856
22871
  handler: () => {}
22857
22872
  };
22873
+ // src/commands/open-requests/read-entry-values/read-entry-values.ts
22874
+ /**
22875
+ * The values of the named entries of one vault Environment, read in memory. Only an Environment this repo uses is read:
22876
+ * a layer word (`local`, `dev`, `ci`, `prod`) is this repo's `<org/repo> - <layer>`, and any other text must be a name
22877
+ * the config already names, as `probe --environment` requires. `local` reads the way the CLI does, `- local` over
22878
+ * `- dev`, and `- local` may be absent.
22879
+ *
22880
+ * This is the one place a concealed value is read on purpose (see `AGENTS.md`, "Concealed values"): only the names the
22881
+ * collection's references list are taken, every other entry is dropped before this returns, and a value is never
22882
+ * logged or put in an error. A name the Environment lacks, or holds blank, is in `missing`.
22883
+ *
22884
+ * @throws {Error} When the Environment is not one of this repo's or the vault cannot read entries.
22885
+ */
22886
+ async function readEntryValues(input) {
22887
+ if (!isEnvironmentLayer(input.environment) && !input.configured.includes(input.environment)) {
22888
+ const known = [...ENVIRONMENT_LAYERS, ...input.configured];
22889
+ throw new Error(`${input.environment} is not an Environment this repo's config names; use one of: ${known.join(", ")}`);
22890
+ }
22891
+ const read = (id) => input.vault.readEnvironmentEntries(id);
22892
+ const at = {
22893
+ repoRoot: input.repoRoot,
22894
+ gitExec: input.gitExec
22895
+ };
22896
+ const environmentId = await resolveEnvironmentId(input.environment, at);
22897
+ let entries;
22898
+ if (input.environment === "local") {
22899
+ const dev = await read(await resolveEnvironmentId("dev", at));
22900
+ const local = await read(environmentId).catch(() => []);
22901
+ entries = [...dev, ...local];
22902
+ } else entries = await read(environmentId);
22903
+ const held = new Map(entries.map((entry) => [entry.name, entry.value]));
22904
+ const values = /* @__PURE__ */ new Map();
22905
+ const missing = [];
22906
+ for (const name of input.names) {
22907
+ const value = held.get(name);
22908
+ if (value) values.set(name, value);
22909
+ else missing.push(name);
22910
+ }
22911
+ return {
22912
+ environmentId,
22913
+ values,
22914
+ missing
22915
+ };
22916
+ }
22917
+ // src/commands/open-requests/run-open-requests/default-deps/default-deps.ts
22918
+ const run = promisify(execFile);
22919
+ /** What is at `path`, without following a symlink. */
22920
+ function inspect(path) {
22921
+ let stat;
22922
+ try {
22923
+ stat = lstatSync(path);
22924
+ } catch (err) {
22925
+ if (err.code === "ENOENT") return { kind: "none" };
22926
+ throw err;
22927
+ }
22928
+ if (stat.isSymbolicLink()) return {
22929
+ kind: "symlink",
22930
+ to: readlinkSync(path)
22931
+ };
22932
+ if (!stat.isFile()) return { kind: "other" };
22933
+ return {
22934
+ kind: "file",
22935
+ firstLine: readFileSync(path, "utf8").split("\n")[0]
22936
+ };
22937
+ }
22938
+ /** Whether a process with this id is running. */
22939
+ function alive(pid) {
22940
+ try {
22941
+ process.kill(pid, 0);
22942
+ return true;
22943
+ } catch (err) {
22944
+ return err.code === "EPERM";
22945
+ }
22946
+ }
22947
+ /** Makes the lock file holding `pid`, or says it is held by a process that still runs; a lock of a dead one is replaced. */
22948
+ function takeLock(path, pid) {
22949
+ for (let attempt = 0; attempt < 2; attempt += 1) try {
22950
+ const fd = openSync(path, "wx", 384);
22951
+ writeSync(fd, String(pid));
22952
+ closeSync(fd);
22953
+ return true;
22954
+ } catch (err) {
22955
+ if (err.code !== "EEXIST") throw err;
22956
+ const holder = Number.parseInt(readFileSync(path, "utf8"), 10);
22957
+ if (Number.isInteger(holder) && alive(holder)) return false;
22958
+ rmSync(path, { force: true });
22959
+ }
22960
+ /* v8 ignore next -- only when another run takes the lock between the check and the retry */
22961
+ return false;
22962
+ }
22963
+ /** The real collaborators of `open requests`. */
22964
+ function defaultDeps() {
22965
+ return {
22966
+ isIgnored: isGitIgnored,
22967
+ makeDir: (dir) => void mkdirSync(dir, {
22968
+ recursive: true,
22969
+ mode: 448
22970
+ }),
22971
+ createPrivateFile: (path, text) => closeSync(createPrivateFile(path, text).fd),
22972
+ inspect,
22973
+ symlink: (to, link) => symlinkSync(to, link),
22974
+ remove: (path) => rmSync(path, { force: true }),
22975
+ takeLock,
22976
+ /* v8 ignore start -- the process list, the program and the signals are only real outside tests, which inject them */
22977
+ processes: async () => (await run("ps", ["-axo", "command"], { maxBuffer: 16777216 })).stdout,
22978
+ run: (launch) => new Promise((resolve, reject) => {
22979
+ const child = spawn(launch.command, launch.args, { stdio: "inherit" });
22980
+ const stop = () => child.kill("SIGTERM");
22981
+ process.once("SIGTERM", stop);
22982
+ child.once("error", (err) => {
22983
+ process.off("SIGTERM", stop);
22984
+ reject(err);
22985
+ });
22986
+ child.once("exit", (code) => {
22987
+ process.off("SIGTERM", stop);
22988
+ resolve(code ?? 0);
22989
+ });
22990
+ }),
22991
+ onTerminate: (handler) => {
22992
+ const events = [
22993
+ "SIGINT",
22994
+ "SIGTERM",
22995
+ "SIGHUP",
22996
+ "exit"
22997
+ ];
22998
+ for (const event of events) process.once(event, handler);
22999
+ return () => {
23000
+ for (const event of events) process.off(event, handler);
23001
+ };
23002
+ },
23003
+ pid: process.pid,
23004
+ platform: process.platform
23005
+ };
23006
+ }
23007
+ // src/commands/open-requests/run-open-requests/run-open-requests.ts
23008
+ /**
23009
+ * `holocron open requests` — opens the request tool's workspace with its secrets filled in from the layer's vault
23010
+ * Environment, so nobody pastes a signing secret by hand.
23011
+ *
23012
+ * The `tooling` provider (Bruno's) says which values the workspace reads (`Tooling.open`: each secret variable is a
23013
+ * reference to a named entry, written by `sync requests`) and how to start the tool. This command takes exactly those
23014
+ * entries from the Environment, in memory, writes them to a private file in `.holocron/.private/` (mode 0600, git-ignored,
23015
+ * never printed), links the file to where the tool reads it (`<collection>/.env`) and runs the tool in the foreground.
23016
+ * The file, the links and the lock are removed when the tool quits, on an error, and on SIGINT, SIGTERM, SIGHUP and exit;
23017
+ * nothing can run on SIGKILL or a crash, so the file starts with a marker line and a later run removes its own leftover
23018
+ * and refuses anything without the marker. A tool that is already running is never touched: it would not see the values.
23019
+ * Names and paths are printed, never a value. `--dry-run` lists them and starts nothing.
23020
+ */
23021
+ /** The first line of the file this command writes; a file that starts with it is this command's own leftover. */
23022
+ const MARKER = "# written by `holocron open requests` for one session and removed when it ends";
23023
+ /** The file the values go to, in the private directory. */
23024
+ const SECRETS_FILE = `${PRIVATE_DIR}/requests.env`;
23025
+ /** The lock a launch holds, in the private directory. */
23026
+ const LOCK_FILE = `${PRIVATE_DIR}/open-requests.lock`;
23027
+ const row$4 = (id, status, detail, problems = []) => ({
23028
+ id,
23029
+ title: id,
23030
+ status,
23031
+ detail,
23032
+ problems
23033
+ });
23034
+ /** Whether a link or file at `link` is something this command wrote: a link to the values file, or a marked file. */
23035
+ function isOurs(state, link, secrets) {
23036
+ if (state.kind === "symlink") return resolve(dirname(link), state.to) === secrets;
23037
+ return state.kind === "file" && state.firstLine === "# written by `holocron open requests` for one session and removed when it ends";
23038
+ }
23039
+ async function runOpenRequests(input) {
23040
+ /* v8 ignore next -- the console is only used outside tests, which inject `print` */
23041
+ const print = input.print ?? ((line) => console.log(line));
23042
+ const deps = {
23043
+ ...defaultDeps(),
23044
+ ...input.deps
23045
+ };
23046
+ const dryRun = Boolean(input.context.dryRun);
23047
+ const environment = input.environment ?? "dev";
23048
+ const { repoRoot } = input.context;
23049
+ const rows = [];
23050
+ const say = (next) => {
23051
+ rows.push(next);
23052
+ printCheckRows([next], print);
23053
+ };
23054
+ const finish = (status) => {
23055
+ const summary = summariseChecks(rows);
23056
+ printCheckSummary(summary, print);
23057
+ return {
23058
+ status: status ?? (summary.fail > 0 ? "fail" : "ok"),
23059
+ rows
23060
+ };
23061
+ };
23062
+ print(style.header(`Holocron open requests${dryRun ? " (dry-run)" : ""}`));
23063
+ print("");
23064
+ const entry = input.loaded.resolved.providers.tooling;
23065
+ const tuples = entry?.cardinality === "many" ? entry.tuples : [];
23066
+ const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
23067
+ if (chosen.length === 0) {
23068
+ say(row$4(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(", ")})`));
23069
+ return finish();
23070
+ }
23071
+ /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
23072
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
23073
+ /* v8 ignore stop */
23074
+ await loader.load();
23075
+ assertPluginsResolvable(loader, "open requests");
23076
+ const openable = (loader.has("tooling") ? loader.get("tooling") : []).filter((t) => chosen.some((tuple) => tuple.provider === t.providerName)).filter((t) => t.open !== void 0);
23077
+ if (openable.length !== 1) {
23078
+ say(row$4("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`));
23079
+ return finish();
23080
+ }
23081
+ const tool = openable[0];
23082
+ const tuple = chosen.find((t) => t.provider === tool.providerName);
23083
+ const list = (value) => Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
23084
+ let plan;
23085
+ try {
23086
+ plan = await tool.open({
23087
+ collectionFiles: list(tuple.options.collectionFiles),
23088
+ envFiles: list(tuple.options.envFiles),
23089
+ repoRoot
23090
+ });
23091
+ } catch (err) {
23092
+ say(row$4(tool.providerName, "fail", describeError(err)));
23093
+ return finish();
23094
+ }
23095
+ const names = [...new Set(plan.wants.map((w) => w.entry))].sort();
23096
+ if (plan.unfilled.length > 0) say(row$4("unfilled", "skip", `${plan.unfilled.length} secret variable(s) refer to no entry, so nobody fills them`, plan.unfilled));
23097
+ if (dryRun) {
23098
+ for (const want of plan.wants) say(row$4(want.variable, "ok", `would fill ${want.collection}'s ${want.variable} from ${want.entry} of ${environment}`));
23099
+ if (names.length === 0) say(row$4("secrets", "ok", "nothing to fill: no variable refers to an entry"));
23100
+ else say(row$4("secrets", "ok", `would write ${names.length} value(s) to ${SECRETS_FILE} and link it from ${plan.targets.length} collection(s)`));
23101
+ say(row$4(plan.app, "ok", `would start ${plan.launch.command} in the foreground`));
23102
+ return finish();
23103
+ }
23104
+ if (deps.platform === "win32" && names.length > 0) {
23105
+ say(row$4(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"));
23106
+ return finish();
23107
+ }
23108
+ let running;
23109
+ try {
23110
+ running = await deps.processes();
23111
+ } catch (err) {
23112
+ say(row$4(plan.app, "fail", `could not tell whether ${plan.app} is running: ${describeError(err)}`));
23113
+ return finish();
23114
+ }
23115
+ if (running.split("\n").some((line) => line.includes(plan.running))) {
23116
+ say(row$4(plan.app, "fail", `${plan.app} is already running; quit it and run this again (it would not see the values)`));
23117
+ return finish();
23118
+ }
23119
+ if (!input.yes) {
23120
+ if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`open requests\` writes ${names.length} secret value(s) to a private file and starts ${plan.app}; pass --yes to run it without asking, or --dry-run to preview`);
23121
+ if (!await (input.confirm ?? ((message) => confirm({
23122
+ message,
23123
+ default: false
23124
+ })))(names.length === 0 ? `Start ${plan.app} (nothing to fill)?` : `Read ${names.length} value(s) from ${environment} and start ${plan.app} with them?`)) {
23125
+ print(` ${style.skip("cancelled; nothing was read or written")}`);
23126
+ return finish("cancelled");
23127
+ }
23128
+ }
23129
+ let values = /* @__PURE__ */ new Map();
23130
+ if (names.length > 0) {
23131
+ const vault = loader.has("vault") ? loader.get("vault") : void 0;
23132
+ if (!vault?.readEnvironmentEntries) {
23133
+ say(row$4("vault", "fail", vault ? `${vault.providerName} cannot read an Environment's entries` : "needs a `vault` provider in holocron.config.ts (1password)"));
23134
+ return finish();
23135
+ }
23136
+ let read;
23137
+ try {
23138
+ read = await readEntryValues({
23139
+ vault,
23140
+ environment,
23141
+ configured: ownerEnvironments(input.loaded.resolved).names,
23142
+ repoRoot,
23143
+ names
23144
+ });
23145
+ } catch (err) {
23146
+ say(row$4(`vault ${environment}`, "fail", describeError(err)));
23147
+ return finish();
23148
+ }
23149
+ for (const name of read.missing) say(row$4(name, "fail", `${read.environmentId} holds no value for ${name}`));
23150
+ if (read.missing.length > 0) return finish();
23151
+ values = read.values;
23152
+ say(row$4(`vault ${read.environmentId}`, "ok", `${names.length} value(s) read: ${names.join(", ")}`));
23153
+ }
23154
+ const secrets = resolve(repoRoot, SECRETS_FILE);
23155
+ const lock = resolve(repoRoot, LOCK_FILE);
23156
+ const created = [];
23157
+ let cleaned = false;
23158
+ const cleanup = () => {
23159
+ if (cleaned) return;
23160
+ cleaned = true;
23161
+ for (const link of plan.targets) {
23162
+ const state = deps.inspect(link);
23163
+ if (created.includes(link) && isOurs(state, link, secrets)) deps.remove(link);
23164
+ }
23165
+ if (created.includes(secrets)) deps.remove(secrets);
23166
+ deps.remove(lock);
23167
+ };
23168
+ deps.makeDir(dirname(secrets));
23169
+ if (!deps.takeLock(lock, deps.pid)) {
23170
+ say(row$4(plan.app, "fail", `another \`open requests\` is starting ${plan.app} (${LOCK_FILE} is held); try again when it has`));
23171
+ return finish();
23172
+ }
23173
+ const stop = deps.onTerminate(cleanup);
23174
+ try {
23175
+ if (names.length > 0) {
23176
+ const ignored = deps.isIgnored(secrets);
23177
+ if (ignored === "tracked" || ignored === "unknown") {
23178
+ say(row$4("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, "")]));
23179
+ return finish();
23180
+ }
23181
+ const stale = deps.inspect(secrets);
23182
+ if (stale.kind !== "none" && !(stale.kind === "file" && stale.firstLine === "# written by `holocron open requests` for one session and removed when it ends")) {
23183
+ say(row$4("values file", "fail", `${SECRETS_FILE} is not this command's (no marker line); move it away`));
23184
+ return finish();
23185
+ }
23186
+ for (const link of plan.targets) {
23187
+ const state = deps.inspect(link);
23188
+ if (state.kind !== "none" && !isOurs(state, link, secrets)) {
23189
+ say(row$4("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`));
23190
+ return finish();
23191
+ }
23192
+ }
23193
+ const lines = [MARKER];
23194
+ for (const [name, value] of values) {
23195
+ const line = dotenvLine(name, value);
23196
+ if (line === null) {
23197
+ say(row$4(name, "fail", `the value of ${name} cannot be written to a .env file as it is; it was not written`));
23198
+ return finish();
23199
+ }
23200
+ lines.push(line);
23201
+ }
23202
+ for (const link of plan.targets) deps.remove(link);
23203
+ deps.remove(secrets);
23204
+ deps.createPrivateFile(secrets, `${lines.join("\n")}\n`);
23205
+ created.push(secrets);
23206
+ for (const link of plan.targets) {
23207
+ deps.symlink(relative(dirname(link), secrets), link);
23208
+ created.push(link);
23209
+ }
23210
+ say(row$4("values file", "ok", `${SECRETS_FILE} (mode 0600, git-ignored) linked from ${plan.targets.map((t) => relative(repoRoot, t)).join(", ")}`));
23211
+ }
23212
+ print("");
23213
+ print(`starting ${plan.app}${names.length > 0 ? `; the values are removed when it quits (Ctrl-C ends it too)` : ""}`);
23214
+ let exitCode;
23215
+ try {
23216
+ exitCode = await deps.run(plan.launch);
23217
+ } catch (err) {
23218
+ say(row$4(plan.app, "fail", describeError(err)));
23219
+ return finish();
23220
+ }
23221
+ say(row$4(plan.app, exitCode === 0 ? "ok" : "fail", `ended with ${exitCode}`));
23222
+ return finish();
23223
+ } finally {
23224
+ stop();
23225
+ const wrote = created.includes(secrets);
23226
+ cleanup();
23227
+ if (wrote) print(style.dim(` removed ${SECRETS_FILE} and its links`));
23228
+ }
23229
+ }
23230
+ // src/commands/open-requests/open-requests.command.ts
23231
+ const openRequestsCommand = {
23232
+ command: "requests",
23233
+ describe: "Open the request tool's workspace with its secrets filled in from the layer's vault Environment",
23234
+ builder: (y) => y.option("environment", {
23235
+ type: "string",
23236
+ describe: "The layer (`local`, `dev`, `ci`, `prod`) or Environment to read the secrets from (default: `dev`)"
23237
+ }).option("to", {
23238
+ type: "string",
23239
+ describe: "Open only for this tooling provider (needed when more than one can open its workspace)"
23240
+ }).option("yes", {
23241
+ type: "boolean",
23242
+ describe: "Go ahead without asking (required without a terminal)"
23243
+ }),
23244
+ handler: async (argv) => {
23245
+ const tokens = tokenContext(argv.token);
23246
+ if (!tokens) return;
23247
+ const loaded = await loadConfig(argv.cwd);
23248
+ applyResolvedConfig(argv, loaded.resolved);
23249
+ if ((await runOpenRequests({
23250
+ loaded,
23251
+ context: {
23252
+ repoRoot: argv.cwd,
23253
+ dryRun: argv.dryRun,
23254
+ ...tokens,
23255
+ org: resolveOrg(argv, loaded.resolved)
23256
+ },
23257
+ ...argv.environment ? { environment: argv.environment } : {},
23258
+ ...argv.to ? { to: argv.to } : {},
23259
+ ...argv.yes ? { yes: true } : {}
23260
+ })).status === "fail") process.exitCode = 1;
23261
+ }
23262
+ };
23263
+ // src/commands/open/open.command.ts
23264
+ const openCommand = {
23265
+ command: "open",
23266
+ describe: "Open a tool with what it needs filled in from the vault",
23267
+ builder: (y) => y.command(openRequestsCommand).command(groupMenu("open")),
23268
+ handler: () => {}
23269
+ };
22858
23270
  // src/commands/probe/probe.args.ts
22859
23271
  /**
22860
23272
  * Shown in `holocron probe --help`: how a probe about a token (`cloudflare token`) picks the token it checks, so the
@@ -30890,6 +31302,7 @@ const COMMAND_MODULES = [
30890
31302
  cleanupCommand,
30891
31303
  applyCommand,
30892
31304
  newCommand,
31305
+ openCommand,
30893
31306
  listCommand,
30894
31307
  removeCommand,
30895
31308
  probeCommand,