@theholocron/cli 5.0.0-alpha.566 → 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/README.md +3 -1
- package/dist/cli.mjs +1310 -680
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-DsyeF_Sy.mjs → config-system-jSUaJQA4.mjs} +18 -5
- package/dist/{index-DUmkzXYB.d.mts → index-ms_9es37.d.mts} +8 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/plugin/capabilities.d.mts +1 -1
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +9 -9
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";
|
|
@@ -110,6 +110,7 @@ const COMMAND_CONTEXTS = {
|
|
|
110
110
|
"rotate tokens": "workspace",
|
|
111
111
|
"doctor all": "workspace",
|
|
112
112
|
"doctor notifications": "workspace",
|
|
113
|
+
"doctor agent": "workspace",
|
|
113
114
|
"doctor environments": "workspace",
|
|
114
115
|
"doctor project": "workspace",
|
|
115
116
|
"doctor logs": "workspace",
|
|
@@ -150,6 +151,7 @@ const COMMAND_CONTEXTS = {
|
|
|
150
151
|
"new work": "workspace",
|
|
151
152
|
"update issue": "workspace",
|
|
152
153
|
"start work": "workspace",
|
|
154
|
+
"start agent": "workspace",
|
|
153
155
|
"update work": "workspace",
|
|
154
156
|
"close work": "workspace",
|
|
155
157
|
"new incident": "workspace",
|
|
@@ -455,6 +457,14 @@ const doctorAllEntry = {
|
|
|
455
457
|
supportsDryRun: false,
|
|
456
458
|
spawnArgs: ["doctor", "--all"]
|
|
457
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
|
+
};
|
|
458
468
|
// src/commands/doctor-ci/doctor-ci.entry.ts
|
|
459
469
|
const doctorCiEntry = {
|
|
460
470
|
name: "doctor ci",
|
|
@@ -1995,6 +2005,15 @@ const specsSyncEntry = {
|
|
|
1995
2005
|
],
|
|
1996
2006
|
supportsDryRun: true
|
|
1997
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
|
+
};
|
|
1998
2017
|
// src/commands/start-work/start-work.entry.ts
|
|
1999
2018
|
const startWorkEntry = {
|
|
2000
2019
|
name: "start work",
|
|
@@ -2358,6 +2377,7 @@ const registry = createCommandRegistry([
|
|
|
2358
2377
|
notificationsChannelAddEntry,
|
|
2359
2378
|
doctorMonitoringEntry,
|
|
2360
2379
|
doctorNotificationsEntry,
|
|
2380
|
+
doctorAgentEntry,
|
|
2361
2381
|
doctorEnvironmentsEntry,
|
|
2362
2382
|
doctorProjectEntry,
|
|
2363
2383
|
doctorGitHubAppEntry,
|
|
@@ -2404,6 +2424,7 @@ const registry = createCommandRegistry([
|
|
|
2404
2424
|
newWorkEntry,
|
|
2405
2425
|
issueUpdateEntry,
|
|
2406
2426
|
startWorkEntry,
|
|
2427
|
+
startAgentEntry,
|
|
2407
2428
|
updateWorkEntry,
|
|
2408
2429
|
closeWorkEntry,
|
|
2409
2430
|
newIncidentEntry,
|
|
@@ -2865,7 +2886,7 @@ var MissingTokenError = class extends Error {
|
|
|
2865
2886
|
name = "MissingTokenError";
|
|
2866
2887
|
};
|
|
2867
2888
|
// src/config/split-agent/split-agent.ts
|
|
2868
|
-
const AGENT_OPTIONS = ["dcg"];
|
|
2889
|
+
const AGENT_OPTIONS = ["dcg", "denyRead"];
|
|
2869
2890
|
/**
|
|
2870
2891
|
* Reads `agent` in either form, a name (`"claude"`) or a name with options (`["claude", { dcg: true }]`), the form a
|
|
2871
2892
|
* provider takes. The name keeps its place in the resolved config, so everything that installs skills reads it as before;
|
|
@@ -2882,6 +2903,11 @@ function splitAgent(raw) {
|
|
|
2882
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(", ")})`);
|
|
2883
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`);
|
|
2884
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
|
+
}
|
|
2885
2911
|
return {
|
|
2886
2912
|
agent,
|
|
2887
2913
|
agentOptions: options
|
|
@@ -2894,7 +2920,8 @@ const ENVIRONMENT_LAYERS = [
|
|
|
2894
2920
|
"dev",
|
|
2895
2921
|
"ci",
|
|
2896
2922
|
"prod",
|
|
2897
|
-
"preview"
|
|
2923
|
+
"preview",
|
|
2924
|
+
"agent"
|
|
2898
2925
|
];
|
|
2899
2926
|
/** Whether `value` is exactly one of the layer words (case-sensitive: `Prod` is a literal Environment name). */
|
|
2900
2927
|
function isEnvironmentLayer(value) {
|
|
@@ -2958,7 +2985,7 @@ const COMMIT_TYPES = [
|
|
|
2958
2985
|
"style",
|
|
2959
2986
|
"revert"
|
|
2960
2987
|
];
|
|
2961
|
-
const isObject$
|
|
2988
|
+
const isObject$5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2962
2989
|
const KEYS$2 = [
|
|
2963
2990
|
"name",
|
|
2964
2991
|
"description",
|
|
@@ -2978,7 +3005,7 @@ function validateIssueTypes(value, at = "issueTypes") {
|
|
|
2978
3005
|
const seen = /* @__PURE__ */ new Set();
|
|
2979
3006
|
return value.map((entry, index) => {
|
|
2980
3007
|
const where = `${at}[${index}]`;
|
|
2981
|
-
if (!isObject$
|
|
3008
|
+
if (!isObject$5(entry)) throw new ConfigError$1(`${where} must be an object with a "name"`);
|
|
2982
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(", ")}`);
|
|
2983
3010
|
const { name, description, color, enabled, label, commit } = entry;
|
|
2984
3011
|
if (typeof name !== "string" || name.trim() === "") throw new ConfigError$1(`${where}: "name" must be a non-empty string`);
|
|
@@ -3008,10 +3035,10 @@ const KEYS$1 = /* @__PURE__ */ new Set([
|
|
|
3008
3035
|
"preventSelfReview"
|
|
3009
3036
|
]);
|
|
3010
3037
|
const REVIEWER_KEYS = /* @__PURE__ */ new Set(["type", "id"]);
|
|
3011
|
-
const isObject$
|
|
3038
|
+
const isObject$4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3012
3039
|
/** Checks one reviewer of the Environment spelled `named`, and records it in `seen` so none is listed twice. */
|
|
3013
3040
|
function validateReviewer(raw, named, seen) {
|
|
3014
|
-
if (!isObject$
|
|
3041
|
+
if (!isObject$4(raw)) throw new ConfigError$1(`${named}: a reviewer must be an object`);
|
|
3015
3042
|
const extra = Object.keys(raw).find((key) => !REVIEWER_KEYS.has(key));
|
|
3016
3043
|
if (extra !== void 0) throw new ConfigError$1(`${named}: a reviewer has no \`${extra}\` (a numeric \`id\`, not a login)`);
|
|
3017
3044
|
const { type, id } = raw;
|
|
@@ -3024,7 +3051,7 @@ function validateReviewer(raw, named, seen) {
|
|
|
3024
3051
|
/** Checks one entry of `repo.environments`, which is at position `index` and whose name is not yet in `seen`. */
|
|
3025
3052
|
function validateEntry(raw, index, seen) {
|
|
3026
3053
|
const at = `\`repo.environments[${index}]\``;
|
|
3027
|
-
if (!isObject$
|
|
3054
|
+
if (!isObject$4(raw)) throw new ConfigError$1(`${at} must be an object`);
|
|
3028
3055
|
const unknown = Object.keys(raw).find((key) => !KEYS$1.has(key));
|
|
3029
3056
|
if (unknown !== void 0) throw new ConfigError$1(`${at} has no \`${unknown}\` (use ${[...KEYS$1].map((k) => `\`${k}\``).join(", ")})`);
|
|
3030
3057
|
const { name, waitTimer, preventSelfReview, reviewers } = raw;
|
|
@@ -3149,8 +3176,15 @@ async function repoSlug(cwd, exec) {
|
|
|
3149
3176
|
return remote.slug;
|
|
3150
3177
|
}
|
|
3151
3178
|
// src/credentials-environments/unsynced-layer/unsynced-layer.ts
|
|
3152
|
-
/**
|
|
3153
|
-
|
|
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
|
+
];
|
|
3154
3188
|
/** Whether `layer` is one of {@link UNSYNCED_LAYERS}. */
|
|
3155
3189
|
function isUnsyncedLayer(layer) {
|
|
3156
3190
|
return isEnvironmentLayer(layer) && UNSYNCED_LAYERS.includes(layer);
|
|
@@ -3162,7 +3196,7 @@ function isUnsyncedLayer(layer) {
|
|
|
3162
3196
|
* @param layer - The unsynced layer.
|
|
3163
3197
|
*/
|
|
3164
3198
|
function unsyncedLayerMessage(what, layer) {
|
|
3165
|
-
return `${what} names the \`${layer}\` layer: \`local\` and \`
|
|
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`;
|
|
3166
3200
|
}
|
|
3167
3201
|
/**
|
|
3168
3202
|
* Refuse a sync of an unsynced layer, before anything is read. The argument is a layer word, or the literal name of a
|
|
@@ -3680,21 +3714,21 @@ const ORG_OPTIONS = {
|
|
|
3680
3714
|
checkly: ["accountId"],
|
|
3681
3715
|
sentry: ["org"]
|
|
3682
3716
|
};
|
|
3683
|
-
const isObject$
|
|
3684
|
-
const isTuple = (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && isObject$
|
|
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]);
|
|
3685
3719
|
/**
|
|
3686
3720
|
* Check the shape of the area file: the top-level `domain` (a non-empty string), then a closed list of providers,
|
|
3687
3721
|
* each with a closed list of string options.
|
|
3688
3722
|
*/
|
|
3689
3723
|
function validate(area) {
|
|
3690
|
-
if (!isObject$
|
|
3724
|
+
if (!isObject$3(area.value)) throw new ConfigError$1(`${area.path} must export the org settings as an object`);
|
|
3691
3725
|
const { domain, issueTypes, ...rest } = area.value;
|
|
3692
3726
|
if (domain !== void 0 && (typeof domain !== "string" || domain === "")) throw new ConfigError$1(`${area.path}: "domain" must be a non-empty string`);
|
|
3693
3727
|
const types = issueTypes === void 0 ? void 0 : validateIssueTypes(issueTypes, `${area.path}: issueTypes`);
|
|
3694
3728
|
for (const [provider, options] of Object.entries(rest)) {
|
|
3695
3729
|
const allowed = ORG_OPTIONS[provider];
|
|
3696
3730
|
if (allowed === void 0) throw new ConfigError$1(`${area.path} has an unknown provider "${provider}". Known: ${Object.keys(ORG_OPTIONS).join(", ")}`);
|
|
3697
|
-
if (!isObject$
|
|
3731
|
+
if (!isObject$3(options)) throw new ConfigError$1(`${area.path}: "${provider}" must be an object of options`);
|
|
3698
3732
|
for (const [option, value] of Object.entries(options)) {
|
|
3699
3733
|
if (!allowed.includes(option)) throw new ConfigError$1(`${area.path}: "${provider}.${option}" is not an org option. Known: ${allowed.join(", ")}`);
|
|
3700
3734
|
if (typeof value !== "string" || value === "") throw new ConfigError$1(`${area.path}: "${provider}.${option}" must be a non-empty string`);
|
|
@@ -3822,13 +3856,16 @@ const SUFFIX = {
|
|
|
3822
3856
|
local: "local",
|
|
3823
3857
|
development: "dev",
|
|
3824
3858
|
ci: "ci",
|
|
3825
|
-
production: "prod"
|
|
3859
|
+
production: "prod",
|
|
3860
|
+
agent: "agent"
|
|
3826
3861
|
};
|
|
3827
3862
|
/**
|
|
3828
3863
|
* The Environments a layer reads, in the order they are tried (#2063, #2058). A machine (`local`) reads
|
|
3829
3864
|
* `<slug> - local` and then `<slug> - dev`: that is the only fallback there is. `development` reads `- dev`, `ci`
|
|
3830
|
-
* reads `- ci` and `production` reads `- prod`; a missing name is a missing name. `
|
|
3831
|
-
*
|
|
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.
|
|
3832
3869
|
*/
|
|
3833
3870
|
function environmentLayers(slug, layer) {
|
|
3834
3871
|
if (layer === "test" || layer === "preview") return [];
|
|
@@ -4371,7 +4408,7 @@ function planIssueTypes(declared, existing, update) {
|
|
|
4371
4408
|
}
|
|
4372
4409
|
const WRITE_PERMISSION = "creating or changing issue Types needs an organization admin and the organization permission Issue types: write (HOLOCRON_ORG_TOKEN)";
|
|
4373
4410
|
const READ_PERMISSION = "reading the organization's issue Types needs the organization permission Issue types: read (HOLOCRON_ORG_TOKEN)";
|
|
4374
|
-
const row$
|
|
4411
|
+
const row$40 = (id, title, status, detail, problems = []) => ({
|
|
4375
4412
|
id: `issue-types:${id}`,
|
|
4376
4413
|
title,
|
|
4377
4414
|
status,
|
|
@@ -4391,7 +4428,7 @@ async function ensureIssueTypes(input) {
|
|
|
4391
4428
|
const refused = input.caller === "setup" ? "skip" : "fail";
|
|
4392
4429
|
const stop = (status, detail, problems = []) => ({
|
|
4393
4430
|
status,
|
|
4394
|
-
rows: [row$
|
|
4431
|
+
rows: [row$40("types", "issue types", status, detail, problems)],
|
|
4395
4432
|
created,
|
|
4396
4433
|
updated
|
|
4397
4434
|
});
|
|
@@ -4431,7 +4468,7 @@ async function ensureIssueTypes(input) {
|
|
|
4431
4468
|
default: false
|
|
4432
4469
|
})))(`Change the organization's issue Types?\n${todo.map((a) => ` ${describeAction(a).detail} ${a.declared.name}`).join("\n")}`)) return {
|
|
4433
4470
|
status: "cancelled",
|
|
4434
|
-
rows: [row$
|
|
4471
|
+
rows: [row$40("types", "issue types", "skip", "cancelled; nothing was changed")],
|
|
4435
4472
|
created,
|
|
4436
4473
|
updated
|
|
4437
4474
|
};
|
|
@@ -4446,34 +4483,34 @@ async function ensureIssueTypes(input) {
|
|
|
4446
4483
|
continue;
|
|
4447
4484
|
}
|
|
4448
4485
|
if (limited) {
|
|
4449
|
-
rows.push(row$
|
|
4486
|
+
rows.push(row$40(name, name, "skip", "left: stopped at a rate limit"));
|
|
4450
4487
|
continue;
|
|
4451
4488
|
}
|
|
4452
4489
|
if (refusedOnce) {
|
|
4453
|
-
rows.push(row$
|
|
4490
|
+
rows.push(row$40(name, name, refused, "not written: the token was refused"));
|
|
4454
4491
|
continue;
|
|
4455
4492
|
}
|
|
4456
4493
|
try {
|
|
4457
4494
|
if (action.kind === "create") {
|
|
4458
4495
|
await issues.createType(toDeclaration(action.declared));
|
|
4459
4496
|
created.push(name);
|
|
4460
|
-
rows.push(row$
|
|
4497
|
+
rows.push(row$40(name, name, "ok", "created"));
|
|
4461
4498
|
} else {
|
|
4462
4499
|
const patch = Object.fromEntries(action.changes.map((c) => [c.field, c.to]));
|
|
4463
4500
|
await issues.updateType?.(action.existing.id, patch);
|
|
4464
4501
|
updated.push(name);
|
|
4465
|
-
rows.push(row$
|
|
4502
|
+
rows.push(row$40(name, name, "ok", `updated ${action.changes.map((c) => c.field).join(", ")}`));
|
|
4466
4503
|
}
|
|
4467
4504
|
} catch (err) {
|
|
4468
4505
|
const kind = classifyTypeError(err);
|
|
4469
4506
|
if (kind === "rate-limit") {
|
|
4470
4507
|
limited = true;
|
|
4471
|
-
rows.push(row$
|
|
4508
|
+
rows.push(row$40(name, name, "fail", "rate limited: stopped; run it again to finish"));
|
|
4472
4509
|
} else if (kind === "refused") {
|
|
4473
4510
|
refusedOnce = true;
|
|
4474
|
-
rows.push(row$
|
|
4475
|
-
} else if (kind === "conflict" && action.kind === "create" && await nowExists(issues, name)) rows.push(row$
|
|
4476
|
-
else rows.push(row$
|
|
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)));
|
|
4477
4514
|
}
|
|
4478
4515
|
}
|
|
4479
4516
|
return {
|
|
@@ -4494,12 +4531,12 @@ async function nowExists(issues, name) {
|
|
|
4494
4531
|
/** The row of an action that is not carried out (a dry run, or the list shown before asking), or that needs none. */
|
|
4495
4532
|
function describeAction(action) {
|
|
4496
4533
|
const name = action.declared.name;
|
|
4497
|
-
if (action.kind === "create") return row$
|
|
4534
|
+
if (action.kind === "create") return row$40(name, name, "skip", "would create");
|
|
4498
4535
|
if (action.kind === "update") {
|
|
4499
4536
|
const fields = action.changes.map((c) => c.field).join(", ");
|
|
4500
|
-
return row$
|
|
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)}`));
|
|
4501
4538
|
}
|
|
4502
|
-
return row$
|
|
4539
|
+
return row$40(name, name, "ok", action.existing.enabled ? "exists" : "exists (turned off in the organization)");
|
|
4503
4540
|
}
|
|
4504
4541
|
// src/commands/notifications-channel-add/private-host.ts
|
|
4505
4542
|
/**
|
|
@@ -7247,7 +7284,7 @@ async function openBoardContext(input) {
|
|
|
7247
7284
|
};
|
|
7248
7285
|
}
|
|
7249
7286
|
// src/commands/issue-fields/add-issue-to-board/add-issue-to-board.ts
|
|
7250
|
-
const row$
|
|
7287
|
+
const row$39 = (board, status, detail) => ({
|
|
7251
7288
|
id: `board ${board}`,
|
|
7252
7289
|
title: `board ${board}`,
|
|
7253
7290
|
status,
|
|
@@ -7269,27 +7306,27 @@ async function addIssueToBoard(input) {
|
|
|
7269
7306
|
loader: input.loader,
|
|
7270
7307
|
...input.io ? { io: input.io } : {}
|
|
7271
7308
|
});
|
|
7272
|
-
if (!opened.ok) return row$
|
|
7309
|
+
if (!opened.ok) return row$39(board, opened.kind === "skip" ? "skip" : "fail", [opened.reason, ...opened.problems].join("; "));
|
|
7273
7310
|
const { projects, owner, boards, templates } = opened.context;
|
|
7274
|
-
if (!projects.addItems) return row$
|
|
7311
|
+
if (!projects.addItems) return row$39(board, "skip", `the \`${projects.providerName}\` provider cannot add items to a board`);
|
|
7275
7312
|
const declared = boards.find((b) => b.name.toLowerCase() === board.toLowerCase());
|
|
7276
7313
|
if (!declared) {
|
|
7277
7314
|
const names = boards.map((b) => b.name).join(", ");
|
|
7278
|
-
return row$
|
|
7315
|
+
return row$39(board, "fail", `no board named "${board}" is declared in providers.projects${names ? ` (declared: ${names})` : ""}`);
|
|
7279
7316
|
}
|
|
7280
7317
|
const template = templates[declared.template];
|
|
7281
|
-
if (!template) return row$
|
|
7318
|
+
if (!template) return row$39(board, "fail", `the template "${declared.template}" of "${declared.name}" is not available`);
|
|
7282
7319
|
const found = await projects.find(owner, declared.name);
|
|
7283
|
-
if (!found) return row$
|
|
7284
|
-
if (input.dryRun) return row$
|
|
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}"`);
|
|
7285
7322
|
const [added] = await projects.addItems(owner, found, [{
|
|
7286
7323
|
key,
|
|
7287
7324
|
...input.priority ? { priority: input.priority } : {}
|
|
7288
7325
|
}], template);
|
|
7289
7326
|
const dropped = added?.dropped ?? [];
|
|
7290
|
-
return row$
|
|
7327
|
+
return row$39(board, dropped.length > 0 ? "skip" : "ok", `${added?.added ? "added" : "already on"} "${declared.name}"${dropped.length > 0 ? `; not set: ${dropped.join(", ")}` : ""}`);
|
|
7291
7328
|
} catch (err) {
|
|
7292
|
-
return row$
|
|
7329
|
+
return row$39(board, "fail", `could not add ${key} to the board: ${describeError(err)}`);
|
|
7293
7330
|
}
|
|
7294
7331
|
}
|
|
7295
7332
|
// src/commands/issue-fields/describe-issue-fields/describe-issue-fields.ts
|
|
@@ -7396,7 +7433,7 @@ function prepareIssueFields(input, areas) {
|
|
|
7396
7433
|
* asks first unless `--dry-run` or `--yes` (without a terminal it refuses instead). `update work` is another command,
|
|
7397
7434
|
* which spans the pull request and the board.
|
|
7398
7435
|
*/
|
|
7399
|
-
const row$
|
|
7436
|
+
const row$38 = (id, status, detail) => ({
|
|
7400
7437
|
id,
|
|
7401
7438
|
title: id,
|
|
7402
7439
|
status,
|
|
@@ -7422,7 +7459,7 @@ async function runIssueUpdate(input) {
|
|
|
7422
7459
|
print(style.header(`Holocron update issue${dryRun ? " (dry-run)" : ""}`));
|
|
7423
7460
|
print("");
|
|
7424
7461
|
const key = input.key.trim();
|
|
7425
|
-
if (!key) return finish([row$
|
|
7462
|
+
if (!key) return finish([row$38("key", "fail", "the issue key is empty")]);
|
|
7426
7463
|
const prepared = prepareIssueFields(input, input.loaded.resolved.repo?.labels?.areas);
|
|
7427
7464
|
const problems = prepared.ok ? [] : [...prepared.problems];
|
|
7428
7465
|
const clear = [...new Set(input.clear ?? [])];
|
|
@@ -7449,7 +7486,7 @@ async function runIssueUpdate(input) {
|
|
|
7449
7486
|
for (const label of addLabels) if (removeLabels.some((r) => r.toLowerCase() === label.toLowerCase())) problems.push(`the label "${label}" is both added and removed`);
|
|
7450
7487
|
const blockers = prepared.ok ? prepared.fields.blockedBy ?? [] : [];
|
|
7451
7488
|
for (const k of unblock) if (blockers.includes(k)) problems.push(`${k} is both added and removed as a blocker`);
|
|
7452
|
-
if (problems.length > 0 || !prepared.ok) return finish(problems.map((p) => row$
|
|
7489
|
+
if (problems.length > 0 || !prepared.ok) return finish(problems.map((p) => row$38(key, "fail", p)));
|
|
7453
7490
|
const patch = {
|
|
7454
7491
|
...prepared.fields,
|
|
7455
7492
|
...title ? { title } : {},
|
|
@@ -7475,10 +7512,10 @@ async function runIssueUpdate(input) {
|
|
|
7475
7512
|
...unblock.length > 0 ? [`unblock: ${unblock.join(", ")}`] : [],
|
|
7476
7513
|
...clear.length > 0 ? [`clear: ${clear.join(", ")}`] : []
|
|
7477
7514
|
];
|
|
7478
|
-
if (details.length === 0) return finish([row$
|
|
7515
|
+
if (details.length === 0) return finish([row$38(key, "fail", "nothing to change; name a field to set, or `--clear` one")]);
|
|
7479
7516
|
const summary = ` (${details.join("; ")})`;
|
|
7480
7517
|
const entry = input.loaded.resolved.providers.issues;
|
|
7481
|
-
if (!entry) return finish([row$
|
|
7518
|
+
if (!entry) return finish([row$38(key, "fail", "the config has no `issues` provider to update the issue with")]);
|
|
7482
7519
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
7483
7520
|
const projects = prepared.project ? input.loaded.resolved.providers.projects : void 0;
|
|
7484
7521
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
@@ -7495,10 +7532,10 @@ async function runIssueUpdate(input) {
|
|
|
7495
7532
|
assertPluginsResolvable(loader, "update issue");
|
|
7496
7533
|
if (!loader.has("issues")) {
|
|
7497
7534
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
7498
|
-
return finish([row$
|
|
7535
|
+
return finish([row$38(key, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
7499
7536
|
}
|
|
7500
7537
|
const issues = loader.get("issues");
|
|
7501
|
-
if (!issues.update) return finish([row$
|
|
7538
|
+
if (!issues.update) return finish([row$38(key, "fail", `the \`${issues.providerName}\` provider does not support \`update issue\``)]);
|
|
7502
7539
|
if (dryRun) {
|
|
7503
7540
|
const board = prepared.project ? await addIssueToBoard({
|
|
7504
7541
|
loaded: input.loaded,
|
|
@@ -7508,7 +7545,7 @@ async function runIssueUpdate(input) {
|
|
|
7508
7545
|
key,
|
|
7509
7546
|
dryRun: true
|
|
7510
7547
|
}) : void 0;
|
|
7511
|
-
return finish([row$
|
|
7548
|
+
return finish([row$38(key, "skip", `would update the issue${summary}`), ...board ? [board] : []]);
|
|
7512
7549
|
}
|
|
7513
7550
|
if (!input.yes) {
|
|
7514
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");
|
|
@@ -7534,12 +7571,12 @@ async function runIssueUpdate(input) {
|
|
|
7534
7571
|
...prepared.fields.priority ? { priority: prepared.fields.priority } : {}
|
|
7535
7572
|
}) : void 0;
|
|
7536
7573
|
return finish([
|
|
7537
|
-
row$
|
|
7538
|
-
...(result.dropped ?? []).map((line) => row$
|
|
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)),
|
|
7539
7576
|
...board ? [board] : []
|
|
7540
7577
|
], result.changed);
|
|
7541
7578
|
} catch (err) {
|
|
7542
|
-
return finish([row$
|
|
7579
|
+
return finish([row$38(key, "fail", `could not update the issue: ${describeError(err)}`)]);
|
|
7543
7580
|
}
|
|
7544
7581
|
}
|
|
7545
7582
|
// src/commands/start-work/find-worktree/find-worktree.ts
|
|
@@ -7579,7 +7616,7 @@ function unpushedCommits(git, cwd, branch) {
|
|
|
7579
7616
|
], cwd)) || 0;
|
|
7580
7617
|
}
|
|
7581
7618
|
// src/commands/close-work/clean-up-work/clean-up-work.ts
|
|
7582
|
-
const row$
|
|
7619
|
+
const row$37 = (id, status, detail) => ({
|
|
7583
7620
|
id,
|
|
7584
7621
|
title: id,
|
|
7585
7622
|
status,
|
|
@@ -7608,51 +7645,51 @@ function cleanUpWork(input) {
|
|
|
7608
7645
|
let keepBranch;
|
|
7609
7646
|
try {
|
|
7610
7647
|
const path = findWorktree(git, repoRoot, branch);
|
|
7611
|
-
if (!path) rows.push(row$
|
|
7648
|
+
if (!path) rows.push(row$37("worktree", "skip", `none holds ${branch}`));
|
|
7612
7649
|
else if (input.keepWorktree) {
|
|
7613
|
-
rows.push(row$
|
|
7650
|
+
rows.push(row$37("worktree", "skip", `kept at ${path} (--keep-worktree)`));
|
|
7614
7651
|
keepBranch = "its worktree is kept";
|
|
7615
7652
|
} else if (resolve(path) === mainWorktree(input)) {
|
|
7616
|
-
rows.push(row$
|
|
7653
|
+
rows.push(row$37("worktree", "skip", `${branch} is checked out in the main checkout; switch it to another branch first`));
|
|
7617
7654
|
keepBranch = "it is checked out in the main checkout";
|
|
7618
7655
|
} else if (resolve(repoRoot) === resolve(path) || resolve(repoRoot).startsWith(resolve(path) + sep)) {
|
|
7619
|
-
rows.push(row$
|
|
7656
|
+
rows.push(row$37("worktree", "skip", `${path} is where this command is running; run it from another checkout`));
|
|
7620
7657
|
keepBranch = "its worktree is where this command is running";
|
|
7621
7658
|
} else if (git(["status", "--porcelain"], path)) {
|
|
7622
|
-
rows.push(row$
|
|
7659
|
+
rows.push(row$37("worktree", "fail", `${path} has uncommitted changes; commit or discard them, nothing was removed`));
|
|
7623
7660
|
keepBranch = "its worktree has uncommitted changes";
|
|
7624
|
-
} else if (dryRun) rows.push(row$
|
|
7661
|
+
} else if (dryRun) rows.push(row$37("worktree", "skip", `would remove ${path}`));
|
|
7625
7662
|
else {
|
|
7626
7663
|
git([
|
|
7627
7664
|
"worktree",
|
|
7628
7665
|
"remove",
|
|
7629
7666
|
path
|
|
7630
7667
|
], repoRoot);
|
|
7631
|
-
rows.push(row$
|
|
7668
|
+
rows.push(row$37("worktree", "ok", `removed ${path}`));
|
|
7632
7669
|
}
|
|
7633
7670
|
} catch (err) {
|
|
7634
|
-
rows.push(row$
|
|
7671
|
+
rows.push(row$37("worktree", "fail", `could not remove the worktree: ${describeError(err)}`));
|
|
7635
7672
|
keepBranch = "its worktree could not be removed";
|
|
7636
7673
|
}
|
|
7637
7674
|
try {
|
|
7638
7675
|
const unpushed = unpushedCommits(git, repoRoot, branch);
|
|
7639
|
-
if (unpushed === void 0) rows.push(row$
|
|
7640
|
-
else if (keepBranch) rows.push(row$
|
|
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}`));
|
|
7641
7678
|
else {
|
|
7642
7679
|
const tip = git(["rev-parse", `refs/heads/${branch}`], repoRoot);
|
|
7643
|
-
if (!(input.mode === "abandoned" || unpushed === 0 || input.headSha && tip === input.headSha)) rows.push(row$
|
|
7644
|
-
else if (dryRun) rows.push(row$
|
|
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}`));
|
|
7645
7682
|
else {
|
|
7646
7683
|
git([
|
|
7647
7684
|
"branch",
|
|
7648
7685
|
"-D",
|
|
7649
7686
|
branch
|
|
7650
7687
|
], repoRoot);
|
|
7651
|
-
rows.push(row$
|
|
7688
|
+
rows.push(row$37("local branch", "ok", `deleted ${branch}`));
|
|
7652
7689
|
}
|
|
7653
7690
|
}
|
|
7654
7691
|
} catch (err) {
|
|
7655
|
-
rows.push(row$
|
|
7692
|
+
rows.push(row$37("local branch", "fail", `could not delete ${branch}: ${describeError(err)}`));
|
|
7656
7693
|
}
|
|
7657
7694
|
try {
|
|
7658
7695
|
const remote = git([
|
|
@@ -7661,9 +7698,9 @@ function cleanUpWork(input) {
|
|
|
7661
7698
|
"origin",
|
|
7662
7699
|
`refs/heads/${branch}`
|
|
7663
7700
|
], repoRoot);
|
|
7664
|
-
rows.push(remote ? row$
|
|
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`));
|
|
7665
7702
|
} catch (err) {
|
|
7666
|
-
rows.push(row$
|
|
7703
|
+
rows.push(row$37("remote branch", "skip", `could not ask origin: ${describeError(err)}`));
|
|
7667
7704
|
}
|
|
7668
7705
|
return rows;
|
|
7669
7706
|
}
|
|
@@ -7707,7 +7744,7 @@ function findWorkBranches(git, cwd, issue) {
|
|
|
7707
7744
|
});
|
|
7708
7745
|
}
|
|
7709
7746
|
// src/commands/close-work/abandon-work/abandon-work.ts
|
|
7710
|
-
const row$
|
|
7747
|
+
const row$36 = (id, status, detail) => ({
|
|
7711
7748
|
id,
|
|
7712
7749
|
title: id,
|
|
7713
7750
|
status,
|
|
@@ -7732,9 +7769,9 @@ async function abandonWork(a) {
|
|
|
7732
7769
|
try {
|
|
7733
7770
|
found = findWorkBranches(git, repoRoot, key);
|
|
7734
7771
|
} catch (err) {
|
|
7735
|
-
return { rows: [row$
|
|
7772
|
+
return { rows: [row$36("local branch", "fail", `could not list the branches: ${describeError(err)}`)] };
|
|
7736
7773
|
}
|
|
7737
|
-
if (found.length > 1) return { rows: [row$
|
|
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`)] };
|
|
7738
7775
|
branch = found[0];
|
|
7739
7776
|
}
|
|
7740
7777
|
if (branch) {
|
|
@@ -7742,9 +7779,9 @@ async function abandonWork(a) {
|
|
|
7742
7779
|
try {
|
|
7743
7780
|
unpushed = unpushedCommits(git, repoRoot, branch);
|
|
7744
7781
|
} catch (err) {
|
|
7745
|
-
return { rows: [row$
|
|
7782
|
+
return { rows: [row$36("unpushed commits", "fail", `could not read ${branch}: ${describeError(err)}`)] };
|
|
7746
7783
|
}
|
|
7747
|
-
if (unpushed !== void 0 && unpushed > 0) return { rows: [row$
|
|
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`)] };
|
|
7748
7785
|
}
|
|
7749
7786
|
if (!dryRun && !input.yes) {
|
|
7750
7787
|
const what = [
|
|
@@ -7758,31 +7795,31 @@ async function abandonWork(a) {
|
|
|
7758
7795
|
};
|
|
7759
7796
|
}
|
|
7760
7797
|
let specFiles = [];
|
|
7761
|
-
if (!pr) rows.push(row$
|
|
7798
|
+
if (!pr) rows.push(row$36("pull request", "skip", `no open pull request for ${key}`));
|
|
7762
7799
|
else {
|
|
7763
7800
|
try {
|
|
7764
7801
|
specFiles = source.listPullRequestFiles ? findSpecFiles(await source.listPullRequestFiles(pr.number)) : [];
|
|
7765
7802
|
} catch (err) {
|
|
7766
|
-
rows.push(row$
|
|
7803
|
+
rows.push(row$36("spec", "fail", `could not read the pull request's files: ${describeError(err)}`));
|
|
7767
7804
|
}
|
|
7768
|
-
if (pr.state !== "open") rows.push(row$
|
|
7769
|
-
else if (!source.updatePullRequest) rows.push(row$
|
|
7770
|
-
else if (dryRun) rows.push(row$
|
|
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}`));
|
|
7771
7808
|
else try {
|
|
7772
7809
|
await source.updatePullRequest(pr.number, { state: "closed" });
|
|
7773
|
-
rows.push(row$
|
|
7810
|
+
rows.push(row$36("pull request", "ok", `closed #${pr.number}`));
|
|
7774
7811
|
} catch (err) {
|
|
7775
|
-
rows.push(row$
|
|
7812
|
+
rows.push(row$36("pull request", "fail", `could not close #${pr.number}: ${describeError(err)}`));
|
|
7776
7813
|
}
|
|
7777
7814
|
}
|
|
7778
7815
|
if (pr && !rows.some((r) => r.id === "spec")) {
|
|
7779
|
-
if (specFiles.length === 0) rows.push(row$
|
|
7780
|
-
else if (!input.withdrawSpecs) rows.push(row$
|
|
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"));
|
|
7781
7818
|
else try {
|
|
7782
7819
|
const result = await input.withdrawSpecs(specFiles);
|
|
7783
|
-
rows.push(row$
|
|
7820
|
+
rows.push(row$36("spec", result.ok ? "ok" : "fail", `${specFiles.join(", ")}: ${result.detail}`));
|
|
7784
7821
|
} catch (err) {
|
|
7785
|
-
rows.push(row$
|
|
7822
|
+
rows.push(row$36("spec", "fail", `could not withdraw the post: ${describeError(err)}`));
|
|
7786
7823
|
}
|
|
7787
7824
|
}
|
|
7788
7825
|
if (branch) rows.push(...cleanUpWork({
|
|
@@ -7793,9 +7830,9 @@ async function abandonWork(a) {
|
|
|
7793
7830
|
mode: "abandoned",
|
|
7794
7831
|
...input.keepWorktree ? { keepWorktree: true } : {}
|
|
7795
7832
|
}));
|
|
7796
|
-
else rows.push(row$
|
|
7797
|
-
if (dryRun) rows.push(row$
|
|
7798
|
-
else if (input.yes) rows.push(row$
|
|
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`));
|
|
7799
7836
|
else if (await a.ask(`Close ${key} as not planned?`)) {
|
|
7800
7837
|
const close = await (input.updateIssue ?? runIssueUpdate)({
|
|
7801
7838
|
key,
|
|
@@ -7812,7 +7849,7 @@ async function abandonWork(a) {
|
|
|
7812
7849
|
id: `issue: ${r.id}`,
|
|
7813
7850
|
title: `issue: ${r.title}`
|
|
7814
7851
|
});
|
|
7815
|
-
} else rows.push(row$
|
|
7852
|
+
} else rows.push(row$36("issue", "skip", `${key} left open`));
|
|
7816
7853
|
return { rows };
|
|
7817
7854
|
}
|
|
7818
7855
|
// src/commands/update-work/find-work-pull-request/find-work-pull-request.ts
|
|
@@ -8297,7 +8334,7 @@ function workTitle(input) {
|
|
|
8297
8334
|
const MAX_TITLE = 100;
|
|
8298
8335
|
const DEFAULT_BASE = "alpha";
|
|
8299
8336
|
const WORKTREES = ".claude/worktrees";
|
|
8300
|
-
const row$
|
|
8337
|
+
const row$35 = (id, status, detail) => ({
|
|
8301
8338
|
id,
|
|
8302
8339
|
title: id,
|
|
8303
8340
|
status,
|
|
@@ -8333,7 +8370,7 @@ async function runStartWork(input) {
|
|
|
8333
8370
|
};
|
|
8334
8371
|
};
|
|
8335
8372
|
const fail = (id, detail) => {
|
|
8336
|
-
rows.push(row$
|
|
8373
|
+
rows.push(row$35(id, "fail", detail));
|
|
8337
8374
|
return finish();
|
|
8338
8375
|
};
|
|
8339
8376
|
print(style.header(`Holocron start work${dryRun ? " (dry-run)" : ""}`));
|
|
@@ -8389,7 +8426,7 @@ async function runStartWork(input) {
|
|
|
8389
8426
|
} catch (err) {
|
|
8390
8427
|
return fail(key, `could not read the issue: ${describeError(err)}`);
|
|
8391
8428
|
}
|
|
8392
|
-
rows.push(row$
|
|
8429
|
+
rows.push(row$35(key, "ok", `${issue.summary} (${issue.status})`));
|
|
8393
8430
|
const named = workTitle({
|
|
8394
8431
|
issueTitle: issue.summary,
|
|
8395
8432
|
...input.kind ? {
|
|
@@ -8432,14 +8469,14 @@ async function runStartWork(input) {
|
|
|
8432
8469
|
...source ? [`draft pull request "${title}" (${link.keyword} ${key})`] : ["no pull request"]
|
|
8433
8470
|
].join("; ");
|
|
8434
8471
|
if (dryRun) {
|
|
8435
|
-
rows.push(row$
|
|
8436
|
-
rows.push(row$
|
|
8437
|
-
rows.push(row$
|
|
8438
|
-
if (useWorktree) rows.push(row$
|
|
8439
|
-
rows.push(row$
|
|
8440
|
-
rows.push(row$
|
|
8441
|
-
if (source) rows.push(row$
|
|
8442
|
-
rows.push(row$
|
|
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"));
|
|
8443
8480
|
return finish();
|
|
8444
8481
|
}
|
|
8445
8482
|
if (!input.yes) {
|
|
@@ -8455,18 +8492,18 @@ async function runStartWork(input) {
|
|
|
8455
8492
|
};
|
|
8456
8493
|
}
|
|
8457
8494
|
}
|
|
8458
|
-
rows.push(row$
|
|
8459
|
-
if (branchExists) rows.push(row$
|
|
8460
|
-
else if (!issues.update) rows.push(row$
|
|
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`));
|
|
8461
8498
|
else try {
|
|
8462
8499
|
const result = await issues.update(key, {
|
|
8463
8500
|
startDate: io.today(),
|
|
8464
8501
|
...input.effort ? { effort: input.effort } : {}
|
|
8465
8502
|
});
|
|
8466
|
-
rows.push(row$
|
|
8467
|
-
for (const line of result.dropped ?? []) rows.push(row$
|
|
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));
|
|
8468
8505
|
} catch (err) {
|
|
8469
|
-
rows.push(row$
|
|
8506
|
+
rows.push(row$35("start date", "fail", `could not update the issue: ${describeError(err)}`));
|
|
8470
8507
|
}
|
|
8471
8508
|
let dir = root;
|
|
8472
8509
|
try {
|
|
@@ -8495,7 +8532,7 @@ async function runStartWork(input) {
|
|
|
8495
8532
|
"--abbrev-ref",
|
|
8496
8533
|
"HEAD"
|
|
8497
8534
|
], root) !== branch && dir === root) io.git(["switch", branch], root);
|
|
8498
|
-
rows.push(row$
|
|
8535
|
+
rows.push(row$35("branch", "ok", `${branch} already exists; reused`));
|
|
8499
8536
|
} else if (useWorktree) {
|
|
8500
8537
|
io.git([
|
|
8501
8538
|
"worktree",
|
|
@@ -8507,7 +8544,7 @@ async function runStartWork(input) {
|
|
|
8507
8544
|
start
|
|
8508
8545
|
], root);
|
|
8509
8546
|
dir = wtPath;
|
|
8510
|
-
rows.push(row$
|
|
8547
|
+
rows.push(row$35("branch", "ok", `made ${branch} from ${start}`));
|
|
8511
8548
|
} else {
|
|
8512
8549
|
io.git([
|
|
8513
8550
|
"switch",
|
|
@@ -8516,19 +8553,19 @@ async function runStartWork(input) {
|
|
|
8516
8553
|
branch,
|
|
8517
8554
|
start
|
|
8518
8555
|
], root);
|
|
8519
|
-
rows.push(row$
|
|
8556
|
+
rows.push(row$35("branch", "ok", `made ${branch} from ${start} and switched to it`));
|
|
8520
8557
|
}
|
|
8521
8558
|
report = {
|
|
8522
8559
|
...report,
|
|
8523
8560
|
directory: dir
|
|
8524
8561
|
};
|
|
8525
|
-
if (useWorktree) rows.push(row$
|
|
8562
|
+
if (useWorktree) rows.push(row$35("worktree", "ok", dir));
|
|
8526
8563
|
const ahead = Number(git([
|
|
8527
8564
|
"rev-list",
|
|
8528
8565
|
"--count",
|
|
8529
8566
|
`${start}..${branch}`
|
|
8530
8567
|
]) || "0");
|
|
8531
|
-
if (ahead > 0) rows.push(row$
|
|
8568
|
+
if (ahead > 0) rows.push(row$35("first commit", "skip", `${branch} already has ${ahead} commit${ahead === 1 ? "" : "s"}`));
|
|
8532
8569
|
else {
|
|
8533
8570
|
const trailer = `Refs ${workReference(key)}`;
|
|
8534
8571
|
if (spec) {
|
|
@@ -8539,7 +8576,7 @@ async function runStartWork(input) {
|
|
|
8539
8576
|
spec.rel
|
|
8540
8577
|
], dir);
|
|
8541
8578
|
const status = /^status:\s*(\S+)/m.exec(io.read(spec.abs))?.[1];
|
|
8542
|
-
if (status && status !== "draft") rows.push(row$
|
|
8579
|
+
if (status && status !== "draft") rows.push(row$35("spec", "skip", `the spec's status is ${status}, not draft`));
|
|
8543
8580
|
}
|
|
8544
8581
|
io.git([
|
|
8545
8582
|
"commit",
|
|
@@ -8550,7 +8587,7 @@ async function runStartWork(input) {
|
|
|
8550
8587
|
"-m",
|
|
8551
8588
|
trailer
|
|
8552
8589
|
], dir);
|
|
8553
|
-
rows.push(row$
|
|
8590
|
+
rows.push(row$35("first commit", "ok", `${io.git([
|
|
8554
8591
|
"rev-parse",
|
|
8555
8592
|
"--short",
|
|
8556
8593
|
"HEAD"
|
|
@@ -8562,9 +8599,9 @@ async function runStartWork(input) {
|
|
|
8562
8599
|
"origin",
|
|
8563
8600
|
branch
|
|
8564
8601
|
], dir);
|
|
8565
|
-
rows.push(row$
|
|
8602
|
+
rows.push(row$35("push", "ok", `${branch} is on origin`));
|
|
8566
8603
|
} catch (err) {
|
|
8567
|
-
rows.push(row$
|
|
8604
|
+
rows.push(row$35("git", "fail", `${describeError(err)}; nothing was deleted, run the command again to carry on`));
|
|
8568
8605
|
return finish();
|
|
8569
8606
|
}
|
|
8570
8607
|
if (source) try {
|
|
@@ -8580,7 +8617,7 @@ async function runStartWork(input) {
|
|
|
8580
8617
|
...input.templatesIo ? { templatesIo: input.templatesIo } : {}
|
|
8581
8618
|
});
|
|
8582
8619
|
issueBoards = read.boards;
|
|
8583
|
-
if (read.problem) rows.push(row$
|
|
8620
|
+
if (read.problem) rows.push(row$35("boards", "skip", `the pull request is not put on the issue's boards: ${read.problem}`));
|
|
8584
8621
|
}
|
|
8585
8622
|
const projects = [.../* @__PURE__ */ new Set([...issueBoards, ...input.project ? [input.project] : []])];
|
|
8586
8623
|
const mirrored = {
|
|
@@ -8612,12 +8649,12 @@ async function runStartWork(input) {
|
|
|
8612
8649
|
created: result.created
|
|
8613
8650
|
}
|
|
8614
8651
|
};
|
|
8615
|
-
rows.push(row$
|
|
8616
|
-
for (const line of result.dropped) rows.push(row$
|
|
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));
|
|
8617
8654
|
} catch (err) {
|
|
8618
|
-
rows.push(row$
|
|
8655
|
+
rows.push(row$35("pull request", "fail", `could not open the pull request: ${describeError(err)}; run the command again to open it`));
|
|
8619
8656
|
}
|
|
8620
|
-
rows.push(row$
|
|
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"));
|
|
8621
8658
|
return finish();
|
|
8622
8659
|
}
|
|
8623
8660
|
// src/commands/update-work/guard-work-status/guard-work-status.ts
|
|
@@ -8665,7 +8702,7 @@ function guardWorkStatus(status, force) {
|
|
|
8665
8702
|
* terminal it refuses). `--dry-run` runs the reads and writes nothing. A run with nothing to change still syncs the
|
|
8666
8703
|
* area labels.
|
|
8667
8704
|
*/
|
|
8668
|
-
const row$
|
|
8705
|
+
const row$34 = (id, status, detail) => ({
|
|
8669
8706
|
id,
|
|
8670
8707
|
title: id,
|
|
8671
8708
|
status,
|
|
@@ -8699,7 +8736,7 @@ async function runUpdateWork(input) {
|
|
|
8699
8736
|
};
|
|
8700
8737
|
};
|
|
8701
8738
|
const fail = (id, detail) => {
|
|
8702
|
-
rows.push(row$
|
|
8739
|
+
rows.push(row$34(id, "fail", detail));
|
|
8703
8740
|
return finish();
|
|
8704
8741
|
};
|
|
8705
8742
|
print(style.header(`Holocron update work${dryRun ? " (dry-run)" : ""}`));
|
|
@@ -8788,7 +8825,7 @@ async function runUpdateWork(input) {
|
|
|
8788
8825
|
title: `start: ${r.title}`
|
|
8789
8826
|
});
|
|
8790
8827
|
if (started.status === "fail") {
|
|
8791
|
-
rows.push(row$
|
|
8828
|
+
rows.push(row$34("update work", "skip", "start work failed, so nothing after it was run"));
|
|
8792
8829
|
return finish();
|
|
8793
8830
|
}
|
|
8794
8831
|
}
|
|
@@ -8800,10 +8837,10 @@ async function runUpdateWork(input) {
|
|
|
8800
8837
|
} else if (source.listPullRequests) {
|
|
8801
8838
|
const found = findWorkPullRequests(await source.listPullRequests("open"), key);
|
|
8802
8839
|
pr = found[0];
|
|
8803
|
-
if (found.length > 1) rows.push(row$
|
|
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)`));
|
|
8804
8841
|
}
|
|
8805
8842
|
} catch (err) {
|
|
8806
|
-
rows.push(row$
|
|
8843
|
+
rows.push(row$34("pull request", "fail", `could not find the pull request: ${describeError(err)}`));
|
|
8807
8844
|
return finish();
|
|
8808
8845
|
}
|
|
8809
8846
|
if (pr) {
|
|
@@ -8814,24 +8851,24 @@ async function runUpdateWork(input) {
|
|
|
8814
8851
|
url: pr.url
|
|
8815
8852
|
}
|
|
8816
8853
|
};
|
|
8817
|
-
rows.push(row$
|
|
8854
|
+
rows.push(row$34("pull request", "ok", `#${pr.number} ${pr.title}`));
|
|
8818
8855
|
} else {
|
|
8819
8856
|
const detail = `no open pull request for ${key} (its branch is <type>/<issue>-<slug>; --pr names one, --start makes one)`;
|
|
8820
|
-
rows.push(row$
|
|
8857
|
+
rows.push(row$34("pull request", title ? "fail" : "skip", title ? `${detail}; --title needs one` : detail));
|
|
8821
8858
|
}
|
|
8822
8859
|
let derived = [];
|
|
8823
|
-
if (!pr) rows.push(row$
|
|
8824
|
-
else if (!areas || Object.keys(areas).length === 0) rows.push(row$
|
|
8825
|
-
else if (!source.listPullRequestFiles) rows.push(row$
|
|
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`));
|
|
8826
8863
|
else try {
|
|
8827
8864
|
derived = areaLabelsForFiles(await source.listPullRequestFiles(pr.number), areas);
|
|
8828
8865
|
report = {
|
|
8829
8866
|
...report,
|
|
8830
8867
|
areaLabels: derived
|
|
8831
8868
|
};
|
|
8832
|
-
rows.push(row$
|
|
8869
|
+
rows.push(row$34("area labels", derived.length > 0 ? "ok" : "skip", derived.length > 0 ? derived.join(", ") : "the changed folders are in no area"));
|
|
8833
8870
|
} catch (err) {
|
|
8834
|
-
rows.push(row$
|
|
8871
|
+
rows.push(row$34("area labels", "fail", `could not read the changed files: ${describeError(err)}`));
|
|
8835
8872
|
}
|
|
8836
8873
|
let missingOnIssue = derived;
|
|
8837
8874
|
if (derived.length > 0 && issues.export) try {
|
|
@@ -8868,7 +8905,7 @@ async function runUpdateWork(input) {
|
|
|
8868
8905
|
id: `issue: ${r.id}`,
|
|
8869
8906
|
title: `issue: ${r.title}`
|
|
8870
8907
|
});
|
|
8871
|
-
} else rows.push(row$
|
|
8908
|
+
} else rows.push(row$34("issue", "skip", "no issue field to change"));
|
|
8872
8909
|
if (pr) {
|
|
8873
8910
|
const prLabels = unique([...addLabels, ...derived]);
|
|
8874
8911
|
const patch = {
|
|
@@ -8887,15 +8924,15 @@ async function runUpdateWork(input) {
|
|
|
8887
8924
|
...milestone ? [`milestone ${milestone}`] : [],
|
|
8888
8925
|
...input.project ? [`board ${input.project}`] : []
|
|
8889
8926
|
];
|
|
8890
|
-
if (parts.length === 0) rows.push(row$
|
|
8891
|
-
else if (!source.updatePullRequest) rows.push(row$
|
|
8892
|
-
else if (dryRun) rows.push(row$
|
|
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("; ")}`));
|
|
8893
8930
|
else try {
|
|
8894
8931
|
const result = await source.updatePullRequest(pr.number, patch);
|
|
8895
|
-
rows.push(row$
|
|
8896
|
-
for (const line of result.dropped) rows.push(row$
|
|
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));
|
|
8897
8934
|
} catch (err) {
|
|
8898
|
-
rows.push(row$
|
|
8935
|
+
rows.push(row$34(`pull request #${pr.number}`, "fail", `could not update the pull request: ${describeError(err)}`));
|
|
8899
8936
|
}
|
|
8900
8937
|
}
|
|
8901
8938
|
if (status) {
|
|
@@ -8911,11 +8948,11 @@ async function runUpdateWork(input) {
|
|
|
8911
8948
|
...input.board ? { board: input.board } : {}
|
|
8912
8949
|
});
|
|
8913
8950
|
const change = set.key && set.to ? `${set.key} ${set.from ?? "no status"} → ${set.to}` : `${key} → ${status}`;
|
|
8914
|
-
rows.push(set.status === "ok" ? row$
|
|
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"));
|
|
8915
8952
|
} catch (err) {
|
|
8916
|
-
rows.push(row$
|
|
8953
|
+
rows.push(row$34("board status", "fail", describeError(err)));
|
|
8917
8954
|
}
|
|
8918
|
-
rows.push(row$
|
|
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)"));
|
|
8919
8956
|
}
|
|
8920
8957
|
return finish();
|
|
8921
8958
|
}
|
|
@@ -8934,7 +8971,7 @@ function findClosedWorkPullRequests(prs, issue) {
|
|
|
8934
8971
|
return [...matching.filter((pr) => pr.merged), ...matching.filter((pr) => !pr.merged)];
|
|
8935
8972
|
}
|
|
8936
8973
|
// src/commands/close-work/release-closed-blockers/release-closed-blockers.ts
|
|
8937
|
-
const row$
|
|
8974
|
+
const row$33 = (id, status, detail) => ({
|
|
8938
8975
|
id,
|
|
8939
8976
|
title: id,
|
|
8940
8977
|
status,
|
|
@@ -8948,16 +8985,16 @@ const row$31 = (id, status, detail) => ({
|
|
|
8948
8985
|
*/
|
|
8949
8986
|
async function releaseClosedBlockers(input) {
|
|
8950
8987
|
const { issues, key } = input;
|
|
8951
|
-
if (!issues.export) return [row$
|
|
8988
|
+
if (!issues.export) return [row$33("relations", "skip", `the \`${issues.providerName}\` provider cannot read blockers`)];
|
|
8952
8989
|
try {
|
|
8953
8990
|
const blockers = (await issues.export({ keys: [key] }))[0]?.blockedBy ?? [];
|
|
8954
|
-
if (blockers.length === 0) return [row$
|
|
8991
|
+
if (blockers.length === 0) return [row$33("relations", "skip", `${key} has no blockers`)];
|
|
8955
8992
|
const closed = (await issues.export({ keys: blockers })).filter((r) => r.closed).map((r) => r.key);
|
|
8956
|
-
if (closed.length === 0) return [row$
|
|
8993
|
+
if (closed.length === 0) return [row$33("relations", "skip", `${blockers.length} blocker${blockers.length === 1 ? "" : "s"} still open: ${blockers.join(", ")}`)];
|
|
8957
8994
|
const done = await input.unblock(closed);
|
|
8958
|
-
return [row$
|
|
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")];
|
|
8959
8996
|
} catch (err) {
|
|
8960
|
-
return [row$
|
|
8997
|
+
return [row$33("relations", "fail", `could not update the blockers: ${describeError(err)}`)];
|
|
8961
8998
|
}
|
|
8962
8999
|
}
|
|
8963
9000
|
// src/commands/close-work/wait-for-checks/wait-for-checks.ts
|
|
@@ -9495,7 +9532,7 @@ const DEFAULT_TIMEOUT_MINUTES = 30;
|
|
|
9495
9532
|
const DEFAULT_INTERVAL_MS = 3e4;
|
|
9496
9533
|
/** How many failing checks a row names. */
|
|
9497
9534
|
const MAX_NAMED$1 = 8;
|
|
9498
|
-
const row$
|
|
9535
|
+
const row$32 = (id, status, detail) => ({
|
|
9499
9536
|
id,
|
|
9500
9537
|
title: id,
|
|
9501
9538
|
status,
|
|
@@ -9520,7 +9557,7 @@ async function runCloseWork(input) {
|
|
|
9520
9557
|
};
|
|
9521
9558
|
};
|
|
9522
9559
|
const fail = (id, detail) => {
|
|
9523
|
-
rows.push(row$
|
|
9560
|
+
rows.push(row$32(id, "fail", detail));
|
|
9524
9561
|
return finish();
|
|
9525
9562
|
};
|
|
9526
9563
|
print(style.header(`Holocron close work${input.abandon ? " --abandon" : ""}${dryRun ? " (dry-run)" : ""}`));
|
|
@@ -9568,7 +9605,7 @@ async function runCloseWork(input) {
|
|
|
9568
9605
|
if (!source.listPullRequests) throw new Error(`the \`${source.providerName}\` provider cannot list pull requests`);
|
|
9569
9606
|
const open = findWorkPullRequests(await source.listPullRequests("open"), key);
|
|
9570
9607
|
pr = open[0];
|
|
9571
|
-
if (open.length > 1) rows.push(row$
|
|
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)`));
|
|
9572
9609
|
if (!pr && !input.abandon) pr = findClosedWorkPullRequests(await source.listPullRequests("closed"), key)[0];
|
|
9573
9610
|
}
|
|
9574
9611
|
} catch (err) {
|
|
@@ -9606,10 +9643,10 @@ async function runCloseWork(input) {
|
|
|
9606
9643
|
const repoRoot = input.context.repoRoot;
|
|
9607
9644
|
if (pr.state === "closed") {
|
|
9608
9645
|
if (!pr.merged) {
|
|
9609
|
-
rows.push(row$
|
|
9646
|
+
rows.push(row$32("pull request", "skip", `#${pr.number} was closed without merging; \`close work ${key} --abandon\` tidies its branch and spec`));
|
|
9610
9647
|
return finish();
|
|
9611
9648
|
}
|
|
9612
|
-
rows.push(row$
|
|
9649
|
+
rows.push(row$32("pull request", "ok", `#${pr.number} merged: ${pr.title}`));
|
|
9613
9650
|
if (!dryRun && !input.yes && !await ask(`Remove the worktree and local branch of ${pr.branch}?`)) {
|
|
9614
9651
|
print(` ${style.skip("cancelled; nothing was changed")}`);
|
|
9615
9652
|
return {
|
|
@@ -9628,7 +9665,7 @@ async function runCloseWork(input) {
|
|
|
9628
9665
|
}));
|
|
9629
9666
|
return finish();
|
|
9630
9667
|
}
|
|
9631
|
-
rows.push(row$
|
|
9668
|
+
rows.push(row$32("pull request", "ok", `#${pr.number} ${pr.title}`));
|
|
9632
9669
|
if (!source.getPullRequestChecks) return fail("ci / Required checks", `the \`${source.providerName}\` provider cannot read a pull request's checks`);
|
|
9633
9670
|
const readChecks = source.getPullRequestChecks.bind(source);
|
|
9634
9671
|
const number = pr.number;
|
|
@@ -9654,7 +9691,7 @@ async function runCloseWork(input) {
|
|
|
9654
9691
|
const named = failing.length > 0 ? `: ${failing.join(", ")}${more > 0 ? `, and ${more} more` : ""}` : "";
|
|
9655
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`);
|
|
9656
9693
|
}
|
|
9657
|
-
rows.push(row$
|
|
9694
|
+
rows.push(row$32("ci / Required checks", "ok", `green${checks.sha ? ` on ${checks.sha.slice(0, 7)}` : ""}`));
|
|
9658
9695
|
if (!dryRun && !input.yes) {
|
|
9659
9696
|
if (!await ask(`${key} is green. ${`Mark #${number} ready, update the area labels and take closed blockers off ${key}`}?`)) {
|
|
9660
9697
|
print(` ${style.skip("cancelled; nothing was changed")}`);
|
|
@@ -9664,13 +9701,13 @@ async function runCloseWork(input) {
|
|
|
9664
9701
|
};
|
|
9665
9702
|
}
|
|
9666
9703
|
}
|
|
9667
|
-
if (!source.markReady) rows.push(row$
|
|
9668
|
-
else if (dryRun) rows.push(row$
|
|
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`));
|
|
9669
9706
|
else try {
|
|
9670
9707
|
const changed = await source.markReady(number);
|
|
9671
|
-
rows.push(row$
|
|
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`));
|
|
9672
9709
|
} catch (err) {
|
|
9673
|
-
rows.push(row$
|
|
9710
|
+
rows.push(row$32("ready", "fail", `could not mark #${number} ready: ${describeError(err)}`));
|
|
9674
9711
|
}
|
|
9675
9712
|
try {
|
|
9676
9713
|
const updated = await (input.updateWork ?? runUpdateWork)({
|
|
@@ -9688,7 +9725,7 @@ async function runCloseWork(input) {
|
|
|
9688
9725
|
title: `labels: ${r.title}`
|
|
9689
9726
|
});
|
|
9690
9727
|
} catch (err) {
|
|
9691
|
-
rows.push(row$
|
|
9728
|
+
rows.push(row$32("labels", "fail", `could not update the area labels: ${describeError(err)}`));
|
|
9692
9729
|
}
|
|
9693
9730
|
rows.push(...await releaseClosedBlockers({
|
|
9694
9731
|
issues,
|
|
@@ -11299,7 +11336,7 @@ function installationSettingsUrl(account, id) {
|
|
|
11299
11336
|
return `https://github.com/settings/installations/${id}`;
|
|
11300
11337
|
}
|
|
11301
11338
|
// src/commands/doctor-github-app/app-rows.ts
|
|
11302
|
-
const row$
|
|
11339
|
+
const row$31 = (name, what, problems, ok) => ({
|
|
11303
11340
|
id: `${name}:${what}`,
|
|
11304
11341
|
title: `${name}: ${what}`,
|
|
11305
11342
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -11344,9 +11381,9 @@ function appRows(name, manifest, app, installations) {
|
|
|
11344
11381
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
11345
11382
|
});
|
|
11346
11383
|
return [
|
|
11347
|
-
row$
|
|
11348
|
-
row$
|
|
11349
|
-
row$
|
|
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`),
|
|
11350
11387
|
statusRow(name, installations)
|
|
11351
11388
|
];
|
|
11352
11389
|
}
|
|
@@ -11512,7 +11549,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
11512
11549
|
assertPluginsResolvable(loader, "doctor github-app");
|
|
11513
11550
|
}
|
|
11514
11551
|
const rows = [];
|
|
11515
|
-
if (instances.length === 0) rows.push(row$
|
|
11552
|
+
if (instances.length === 0) rows.push(row$30("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
11516
11553
|
const checked = [];
|
|
11517
11554
|
for (const instance of instances) {
|
|
11518
11555
|
const instanceRows = await checkInstance(instance, loader, input);
|
|
@@ -11559,7 +11596,7 @@ function printGrouped(checked, print) {
|
|
|
11559
11596
|
}
|
|
11560
11597
|
}
|
|
11561
11598
|
}
|
|
11562
|
-
function row$
|
|
11599
|
+
function row$30(name, what, status, detail) {
|
|
11563
11600
|
return {
|
|
11564
11601
|
id: `${name}:${what}`,
|
|
11565
11602
|
title: `${name}: ${what}`,
|
|
@@ -11575,10 +11612,10 @@ async function checkInstance(instance, loader, input) {
|
|
|
11575
11612
|
try {
|
|
11576
11613
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
11577
11614
|
} catch (err) {
|
|
11578
|
-
return [row$
|
|
11615
|
+
return [row$30(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
11579
11616
|
}
|
|
11580
11617
|
const read = await readAppCredentials(instance, loader);
|
|
11581
|
-
if ("reason" in read) return [row$
|
|
11618
|
+
if ("reason" in read) return [row$30(name, "reachable", "skip", read.reason)];
|
|
11582
11619
|
const api = input.api ?? defaultApi$1;
|
|
11583
11620
|
const secrets = [read.creds.privateKey];
|
|
11584
11621
|
try {
|
|
@@ -11586,12 +11623,12 @@ async function checkInstance(instance, loader, input) {
|
|
|
11586
11623
|
const installations = await api.listAppInstallations(read.creds);
|
|
11587
11624
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
11588
11625
|
return [
|
|
11589
|
-
row$
|
|
11626
|
+
row$30(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`),
|
|
11590
11627
|
...appRows(name, manifest, app, installations),
|
|
11591
11628
|
await deliveryRow(name, read.creds, api, (input.now ?? Date.now)(), secrets)
|
|
11592
11629
|
];
|
|
11593
11630
|
} catch (err) {
|
|
11594
|
-
return [row$
|
|
11631
|
+
return [row$30(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
|
|
11595
11632
|
}
|
|
11596
11633
|
}
|
|
11597
11634
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -12036,6 +12073,613 @@ const devCommand = {
|
|
|
12036
12073
|
})).status === "fail") process.exitCode = 1;
|
|
12037
12074
|
}
|
|
12038
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
|
+
};
|
|
12039
12683
|
// src/commands/doctor-ci/problem-row.ts
|
|
12040
12684
|
/** A row that fails with its problems, or passes with `okDetail` when there are none. */
|
|
12041
12685
|
function problemRow(id, title, problems, okDetail) {
|
|
@@ -12868,7 +13512,7 @@ async function runDoctorDns(input) {
|
|
|
12868
13512
|
});
|
|
12869
13513
|
else if (!loader.has("dns")) {
|
|
12870
13514
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
12871
|
-
for (const zone of zones) rows.push(row$
|
|
13515
|
+
for (const zone of zones) rows.push(row$28(zone, "skip", why));
|
|
12872
13516
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
12873
13517
|
} else {
|
|
12874
13518
|
const dns = loader.get("dns");
|
|
@@ -12890,7 +13534,7 @@ async function runDoctorDns(input) {
|
|
|
12890
13534
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
12891
13535
|
};
|
|
12892
13536
|
}
|
|
12893
|
-
function row$
|
|
13537
|
+
function row$28(zone, status, detail, problems = []) {
|
|
12894
13538
|
return {
|
|
12895
13539
|
id: `dns-${zone}`,
|
|
12896
13540
|
title: `${zone} records exist`,
|
|
@@ -12919,7 +13563,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
12919
13563
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
12920
13564
|
}
|
|
12921
13565
|
}
|
|
12922
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
13566
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$28(zone, ...args)) {
|
|
12923
13567
|
try {
|
|
12924
13568
|
const have = await dns.listRecords(zone);
|
|
12925
13569
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -13086,7 +13730,7 @@ function declaredProjects$1(layouts) {
|
|
|
13086
13730
|
return [...new Set(layouts.flatMap((layout) => layout.relay?.errors?.projects ?? []))];
|
|
13087
13731
|
}
|
|
13088
13732
|
// src/commands/doctor-errors/errors-rows.ts
|
|
13089
|
-
const row$
|
|
13733
|
+
const row$27 = (id, title, status, detail, problems = []) => ({
|
|
13090
13734
|
id,
|
|
13091
13735
|
title,
|
|
13092
13736
|
status,
|
|
@@ -13103,27 +13747,27 @@ function errorsRows(found, providerName) {
|
|
|
13103
13747
|
const orgSlug = found.org.slug;
|
|
13104
13748
|
if (!found.org.exists) {
|
|
13105
13749
|
const problem = `${providerName} has no organization named ${orgSlug}; check the \`org\` option of the \`errors\` provider`;
|
|
13106
|
-
const rows = [row$
|
|
13107
|
-
for (const project of found.projects) rows.push(row$
|
|
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"));
|
|
13108
13752
|
return rows;
|
|
13109
13753
|
}
|
|
13110
|
-
const rows = [row$
|
|
13754
|
+
const rows = [row$27("errors:org", "organization exists", "ok", `${orgSlug} (${found.org.name ?? orgSlug})`)];
|
|
13111
13755
|
if (found.projects.length === 0) {
|
|
13112
|
-
rows.push(row$
|
|
13756
|
+
rows.push(row$27("errors:projects", "declared projects", "skip", "none declared: no `relay.errors.projects` in a layout"));
|
|
13113
13757
|
return rows;
|
|
13114
13758
|
}
|
|
13115
13759
|
for (const project of found.projects) {
|
|
13116
13760
|
const slug = project.slug;
|
|
13117
13761
|
if (!project.exists) {
|
|
13118
13762
|
const problem = `no project ${slug} in ${found.org.slug}; create it in ${providerName}`;
|
|
13119
|
-
rows.push(row$
|
|
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"));
|
|
13120
13764
|
continue;
|
|
13121
13765
|
}
|
|
13122
|
-
rows.push(row$
|
|
13123
|
-
rows.push(project.hasDsn ? row$
|
|
13124
|
-
if (project.alertRules === void 0) rows.push(row$
|
|
13125
|
-
else if (project.alertRules === 0) rows.push(row$
|
|
13126
|
-
else rows.push(row$
|
|
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)`));
|
|
13127
13771
|
}
|
|
13128
13772
|
return rows;
|
|
13129
13773
|
}
|
|
@@ -13246,7 +13890,7 @@ function datasetTargets(config) {
|
|
|
13246
13890
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
13247
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.
|
|
13248
13892
|
*/
|
|
13249
|
-
const row$
|
|
13893
|
+
const row$26 = (id, title, status, detail, problems = []) => ({
|
|
13250
13894
|
id,
|
|
13251
13895
|
title,
|
|
13252
13896
|
status,
|
|
@@ -13263,7 +13907,7 @@ async function runDoctorLogs(input) {
|
|
|
13263
13907
|
if (!loader.has("logs")) {
|
|
13264
13908
|
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
13265
13909
|
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
13266
|
-
rows.push(row$
|
|
13910
|
+
rows.push(row$26("logs", "logs", "skip", why));
|
|
13267
13911
|
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
13268
13912
|
printCheckRows(rows, print);
|
|
13269
13913
|
const summary = summariseChecks(rows);
|
|
@@ -13287,38 +13931,38 @@ async function checkLogs(logs, targets) {
|
|
|
13287
13931
|
for (const target of targets) {
|
|
13288
13932
|
const id = `logs:dataset:${target.id}`;
|
|
13289
13933
|
const title = `dataset for ${target.label}`;
|
|
13290
|
-
if (!target.name) rows.push(row$
|
|
13291
|
-
else if (!token.usable) rows.push(row$
|
|
13292
|
-
else if (!logs.readDataset) rows.push(row$
|
|
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`));
|
|
13293
13937
|
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
13294
13938
|
}
|
|
13295
13939
|
const org = resolveValue$1(["AXIOM_ORG"], void 0, { prefix: PREFIX$1 });
|
|
13296
|
-
rows.push(org ? row$
|
|
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`));
|
|
13297
13941
|
return rows;
|
|
13298
13942
|
}
|
|
13299
13943
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
13300
13944
|
async function checkToken$1(logs, dataset) {
|
|
13301
13945
|
const title = "token is accepted";
|
|
13302
13946
|
if (!logs.checkToken) return {
|
|
13303
|
-
row: row$
|
|
13947
|
+
row: row$26("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
13304
13948
|
usable: true
|
|
13305
13949
|
};
|
|
13306
13950
|
try {
|
|
13307
13951
|
const result = await logs.checkToken(dataset);
|
|
13308
13952
|
if (result.ok) return {
|
|
13309
|
-
row: row$
|
|
13953
|
+
row: row$26("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
13310
13954
|
usable: true
|
|
13311
13955
|
};
|
|
13312
13956
|
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
13313
13957
|
return {
|
|
13314
|
-
row: row$
|
|
13958
|
+
row: row$26("logs:token", title, "fail", reason, [reason]),
|
|
13315
13959
|
usable: false
|
|
13316
13960
|
};
|
|
13317
13961
|
} catch (err) {
|
|
13318
13962
|
const noToken = missingTokenReason(err);
|
|
13319
13963
|
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
13320
13964
|
return {
|
|
13321
|
-
row: row$
|
|
13965
|
+
row: row$26("logs:token", title, "skip", detail),
|
|
13322
13966
|
usable: noToken === void 0
|
|
13323
13967
|
};
|
|
13324
13968
|
}
|
|
@@ -13328,17 +13972,17 @@ async function checkDataset(logs, target, name, id, title) {
|
|
|
13328
13972
|
const found = await logs.readDataset(name);
|
|
13329
13973
|
if (found.forbidden) {
|
|
13330
13974
|
const why = `${name}: not visible to this token (${logs.providerName} refused the read; it may also not exist)`;
|
|
13331
|
-
return [row$
|
|
13975
|
+
return [row$26(id, title, "skip", why)];
|
|
13332
13976
|
}
|
|
13333
13977
|
if (!found.exists) {
|
|
13334
13978
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
13335
|
-
return [row$
|
|
13979
|
+
return [row$26(id, title, "fail", `${name} does not exist`, [problem])];
|
|
13336
13980
|
}
|
|
13337
13981
|
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
13338
|
-
return [row$
|
|
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)`)];
|
|
13339
13983
|
} catch (err) {
|
|
13340
13984
|
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
13341
|
-
return [row$
|
|
13985
|
+
return [row$26(id, title, "skip", detail)];
|
|
13342
13986
|
}
|
|
13343
13987
|
}
|
|
13344
13988
|
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
@@ -14391,11 +15035,6 @@ function relaySourcesProblem(layout, errorsSource) {
|
|
|
14391
15035
|
}
|
|
14392
15036
|
}
|
|
14393
15037
|
}
|
|
14394
|
-
// src/commands/provider-tuples/provider-tuples.ts
|
|
14395
|
-
/** The providers a config names, in the order it names them: one tuple per capability entry, so a provider named twice appears twice. */
|
|
14396
|
-
function providerTuples(providers) {
|
|
14397
|
-
return Object.values(providers).flatMap((entry) => entry.cardinality === "single" ? [entry.tuple] : entry.tuples);
|
|
14398
|
-
}
|
|
14399
15038
|
// src/commands/workspace-providers/workspace-providers.ts
|
|
14400
15039
|
/**
|
|
14401
15040
|
* The providers the configs of the workspace's packages name (`apps/sentinel` names `vercel` for its `deployment`) that
|
|
@@ -16933,7 +17572,7 @@ const info = (id, title, noun, extras) => ({
|
|
|
16933
17572
|
detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
|
|
16934
17573
|
problems: extras
|
|
16935
17574
|
});
|
|
16936
|
-
const row$
|
|
17575
|
+
const row$25 = (id, title, problems, ok) => ({
|
|
16937
17576
|
id,
|
|
16938
17577
|
title,
|
|
16939
17578
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -16969,19 +17608,19 @@ function viewProblems(want, found) {
|
|
|
16969
17608
|
function boardRows(boardName, template, state) {
|
|
16970
17609
|
const id = `project:${boardName}`;
|
|
16971
17610
|
const rows = [];
|
|
16972
|
-
rows.push(row$
|
|
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`));
|
|
16973
17612
|
const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
|
|
16974
17613
|
if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
|
|
16975
|
-
for (const want of template.fields) rows.push(row$
|
|
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));
|
|
16976
17615
|
const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
|
|
16977
17616
|
if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
|
|
16978
|
-
for (const want of template.views) rows.push(row$
|
|
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}` : ""}`));
|
|
16979
17618
|
const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
|
|
16980
17619
|
if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
|
|
16981
17620
|
for (const name of template.rules ?? []) {
|
|
16982
17621
|
const found = state.rules.find((r) => r.name === name);
|
|
16983
17622
|
const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
|
|
16984
|
-
rows.push(row$
|
|
17623
|
+
rows.push(row$25(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
|
|
16985
17624
|
}
|
|
16986
17625
|
return rows;
|
|
16987
17626
|
}
|
|
@@ -17041,7 +17680,7 @@ function itemRows(boardName, items) {
|
|
|
17041
17680
|
* never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
|
|
17042
17681
|
* failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
|
|
17043
17682
|
*/
|
|
17044
|
-
const row$
|
|
17683
|
+
const row$24 = (id, title, status, detail, problems = []) => ({
|
|
17045
17684
|
id,
|
|
17046
17685
|
title,
|
|
17047
17686
|
status,
|
|
@@ -17095,14 +17734,14 @@ async function checkBoards(input, loader) {
|
|
|
17095
17734
|
loader,
|
|
17096
17735
|
...input.io ? { io: input.io } : {}
|
|
17097
17736
|
});
|
|
17098
|
-
if (!opened.ok) return [row$
|
|
17737
|
+
if (!opened.ok) return [row$24("project", "project", opened.kind, opened.reason, opened.problems)];
|
|
17099
17738
|
const { projects, owner, boards, templates, templateProblems } = opened.context;
|
|
17100
17739
|
const rows = templateProblems.map((problem) => {
|
|
17101
17740
|
/* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
|
|
17102
17741
|
const file = problem.split(": ")[0] ?? problem;
|
|
17103
|
-
return row$
|
|
17742
|
+
return row$24(`project:template:${file}`, `template file ${file}`, "fail", problem);
|
|
17104
17743
|
});
|
|
17105
|
-
if (boards.length === 0) return [...rows, row$
|
|
17744
|
+
if (boards.length === 0) return [...rows, row$24("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
|
|
17106
17745
|
for (const declared of boards) {
|
|
17107
17746
|
const template = templates[declared.template];
|
|
17108
17747
|
const title = `${declared.name}: board exists and is open`;
|
|
@@ -17110,18 +17749,18 @@ async function checkBoards(input, loader) {
|
|
|
17110
17749
|
const board = await projects.find(owner, declared.name);
|
|
17111
17750
|
if (!board) {
|
|
17112
17751
|
const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
|
|
17113
|
-
rows.push(row$
|
|
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`"]));
|
|
17114
17753
|
continue;
|
|
17115
17754
|
}
|
|
17116
|
-
rows.push(row$
|
|
17755
|
+
rows.push(row$24(`project:${declared.name}`, title, "ok", board.url));
|
|
17117
17756
|
if (!template) {
|
|
17118
|
-
rows.push(row$
|
|
17757
|
+
rows.push(row$24(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
|
|
17119
17758
|
continue;
|
|
17120
17759
|
}
|
|
17121
17760
|
rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
|
|
17122
|
-
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$
|
|
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")]);
|
|
17123
17762
|
} catch (err) {
|
|
17124
|
-
rows.push(row$
|
|
17763
|
+
rows.push(row$24(`project:${declared.name}`, title, "fail", describeError(err)));
|
|
17125
17764
|
}
|
|
17126
17765
|
}
|
|
17127
17766
|
return rows;
|
|
@@ -18221,19 +18860,19 @@ async function runDoctorRepo(input) {
|
|
|
18221
18860
|
const rows = [];
|
|
18222
18861
|
if (!loader.has("source")) {
|
|
18223
18862
|
const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
|
|
18224
|
-
for (const check of checks) rows.push(row$
|
|
18863
|
+
for (const check of checks) rows.push(row$23(check, { skip: why }));
|
|
18225
18864
|
} else {
|
|
18226
18865
|
const source = loader.get("source");
|
|
18227
18866
|
for (const check of checks) {
|
|
18228
18867
|
if (typeof source[check.needs] !== "function") {
|
|
18229
|
-
rows.push(row$
|
|
18868
|
+
rows.push(row$23(check, { skip: `provider does not implement ${check.needs}` }));
|
|
18230
18869
|
continue;
|
|
18231
18870
|
}
|
|
18232
18871
|
try {
|
|
18233
|
-
rows.push(row$
|
|
18872
|
+
rows.push(row$23(check, await check.run(source)));
|
|
18234
18873
|
} catch (err) {
|
|
18235
18874
|
const noToken = missingTokenReason(err);
|
|
18236
|
-
if (noToken !== void 0) rows.push(row$
|
|
18875
|
+
if (noToken !== void 0) rows.push(row$23(check, { skip: noToken }));
|
|
18237
18876
|
else rows.push({
|
|
18238
18877
|
id: check.id,
|
|
18239
18878
|
title: check.title,
|
|
@@ -18260,7 +18899,7 @@ async function runDoctorRepo(input) {
|
|
|
18260
18899
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
18261
18900
|
};
|
|
18262
18901
|
}
|
|
18263
|
-
function row$
|
|
18902
|
+
function row$23(check, result) {
|
|
18264
18903
|
const { id, title } = check;
|
|
18265
18904
|
if ("skip" in result) return {
|
|
18266
18905
|
id,
|
|
@@ -18784,7 +19423,7 @@ function providerGroup(providerName) {
|
|
|
18784
19423
|
}
|
|
18785
19424
|
// src/commands/doctor-secrets/credentials-rows.ts
|
|
18786
19425
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
18787
|
-
function row$
|
|
19426
|
+
function row$22(provider, status, detail, name) {
|
|
18788
19427
|
return name === void 0 ? {
|
|
18789
19428
|
id: provider,
|
|
18790
19429
|
title: provider,
|
|
@@ -18809,10 +19448,10 @@ async function credentialsRows(input) {
|
|
|
18809
19448
|
const { loader } = input;
|
|
18810
19449
|
const { resolved } = input.loaded;
|
|
18811
19450
|
if (!resolved.providers.credentials) return {
|
|
18812
|
-
rows: input.asked ? [row$
|
|
19451
|
+
rows: input.asked ? [row$22("credentials", "skip", "no `credentials` provider is configured")] : [],
|
|
18813
19452
|
places: []
|
|
18814
19453
|
};
|
|
18815
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
19454
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$22(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
18816
19455
|
const places = [];
|
|
18817
19456
|
if (!loader.has("credentials")) return {
|
|
18818
19457
|
rows,
|
|
@@ -18824,7 +19463,7 @@ async function credentialsRows(input) {
|
|
|
18824
19463
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
18825
19464
|
const explicit = tuple && credentialsEnvironment(tuple, resolved);
|
|
18826
19465
|
if (!explicit && !derivesEnvironment(impl.providerName)) {
|
|
18827
|
-
rows.push(row$
|
|
19466
|
+
rows.push(row$22(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
|
|
18828
19467
|
continue;
|
|
18829
19468
|
}
|
|
18830
19469
|
try {
|
|
@@ -18836,7 +19475,7 @@ async function credentialsRows(input) {
|
|
|
18836
19475
|
rows.push(...checked.rows);
|
|
18837
19476
|
places.push(...checked.places);
|
|
18838
19477
|
} catch (err) {
|
|
18839
|
-
rows.push(row$
|
|
19478
|
+
rows.push(row$22(impl.providerName, "fail", errorMessage(err)));
|
|
18840
19479
|
}
|
|
18841
19480
|
}
|
|
18842
19481
|
return {
|
|
@@ -18852,17 +19491,17 @@ async function credentialsRows(input) {
|
|
|
18852
19491
|
async function checkProvider(impl, candidates, expected, synced) {
|
|
18853
19492
|
const provider = impl.providerName;
|
|
18854
19493
|
if (!impl.inspect) return {
|
|
18855
|
-
rows: [row$
|
|
19494
|
+
rows: [row$22(provider, "skip", "cannot list the variables without reading their values")],
|
|
18856
19495
|
places: []
|
|
18857
19496
|
};
|
|
18858
19497
|
if (expected.length === 0) return {
|
|
18859
|
-
rows: [row$
|
|
19498
|
+
rows: [row$22(provider, "skip", "no configured plugin lists the tokens it takes")],
|
|
18860
19499
|
places: []
|
|
18861
19500
|
};
|
|
18862
19501
|
const inspect = impl.inspect.bind(impl);
|
|
18863
19502
|
try {
|
|
18864
19503
|
const { found, missing } = await tryEnvironments(candidates, inspect);
|
|
18865
|
-
const rows = missing.map((name) => row$
|
|
19504
|
+
const rows = missing.map((name) => row$22(provider, "fail", `${provider} has no Environment named "${name}"`));
|
|
18866
19505
|
const group = providerGroup(provider);
|
|
18867
19506
|
const unreadPlaces = missing.map((name) => ({
|
|
18868
19507
|
column: {
|
|
@@ -18885,9 +19524,9 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
18885
19524
|
const have = (name) => found.some((f) => f.result.names.includes(name));
|
|
18886
19525
|
let present = 0;
|
|
18887
19526
|
for (const { name, optional } of expected) if (have(name)) present++;
|
|
18888
|
-
else if (optional) rows.push(row$
|
|
18889
|
-
else rows.push(row$
|
|
18890
|
-
if (present > 0) rows.push(row$
|
|
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"));
|
|
18891
19530
|
const names = new Set(expected.map((e) => e.name));
|
|
18892
19531
|
const places = [];
|
|
18893
19532
|
const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
|
|
@@ -18926,7 +19565,7 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
18926
19565
|
};
|
|
18927
19566
|
} catch (err) {
|
|
18928
19567
|
return {
|
|
18929
|
-
rows: [row$
|
|
19568
|
+
rows: [row$22(provider, "fail", errorMessage(err))],
|
|
18930
19569
|
places: []
|
|
18931
19570
|
};
|
|
18932
19571
|
}
|
|
@@ -19017,13 +19656,21 @@ async function deployKeyRows(entries, vault) {
|
|
|
19017
19656
|
return rows;
|
|
19018
19657
|
}
|
|
19019
19658
|
// src/commands/doctor-secrets/environment-skip-row.ts
|
|
19020
|
-
/**
|
|
19021
|
-
|
|
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
|
+
};
|
|
19022
19669
|
/**
|
|
19023
19670
|
* The skipped row for an environment `doctor secrets` does not compare, naming the environment and the reason.
|
|
19024
19671
|
*
|
|
19025
19672
|
* @param env - The environment asked for with `--env`.
|
|
19026
|
-
* @returns The row, or `undefined` for
|
|
19673
|
+
* @returns The row, or `undefined` for the environments that have rows of their own (`local`, `dev`, `ci`, `prod`).
|
|
19027
19674
|
*/
|
|
19028
19675
|
function environmentSkipRow(env) {
|
|
19029
19676
|
const reason = NOT_CHECKED[env];
|
|
@@ -19572,7 +20219,7 @@ async function readLayers(vault, slug, layers = ENVIRONMENT_LAYERS) {
|
|
|
19572
20219
|
blind = true;
|
|
19573
20220
|
}
|
|
19574
20221
|
} catch (err) {
|
|
19575
|
-
if (layer === "local" || layer === "preview") continue;
|
|
20222
|
+
if (layer === "local" || layer === "preview" || layer === "agent") continue;
|
|
19576
20223
|
rows.push({
|
|
19577
20224
|
id: `skip:${layer}`,
|
|
19578
20225
|
title: `Environment "${environment}"`,
|
|
@@ -19800,7 +20447,7 @@ async function variableRows(loader, config, org) {
|
|
|
19800
20447
|
if (!loader.has("source")) {
|
|
19801
20448
|
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
19802
20449
|
for (const check of checks) {
|
|
19803
|
-
rows.push(row$
|
|
20450
|
+
rows.push(row$21(check, { skip: why }));
|
|
19804
20451
|
observations.push({
|
|
19805
20452
|
scope: check.scope,
|
|
19806
20453
|
unread: why
|
|
@@ -19810,7 +20457,7 @@ async function variableRows(loader, config, org) {
|
|
|
19810
20457
|
const source = loader.get("source");
|
|
19811
20458
|
for (const check of checks) try {
|
|
19812
20459
|
const result = await check.run(source);
|
|
19813
|
-
rows.push(row$
|
|
20460
|
+
rows.push(row$21(check, result));
|
|
19814
20461
|
observations.push("skip" in result ? {
|
|
19815
20462
|
scope: check.scope,
|
|
19816
20463
|
unread: result.skip
|
|
@@ -19821,7 +20468,7 @@ async function variableRows(loader, config, org) {
|
|
|
19821
20468
|
} catch (err) {
|
|
19822
20469
|
const noToken = missingTokenReason(err);
|
|
19823
20470
|
if (noToken !== void 0) {
|
|
19824
|
-
rows.push(row$
|
|
20471
|
+
rows.push(row$21(check, { skip: noToken }));
|
|
19825
20472
|
observations.push({
|
|
19826
20473
|
scope: check.scope,
|
|
19827
20474
|
unread: noToken
|
|
@@ -19847,7 +20494,7 @@ async function variableRows(loader, config, org) {
|
|
|
19847
20494
|
observations
|
|
19848
20495
|
};
|
|
19849
20496
|
}
|
|
19850
|
-
function row$
|
|
20497
|
+
function row$21(check, result) {
|
|
19851
20498
|
const { id, title } = check;
|
|
19852
20499
|
if ("skip" in result) return {
|
|
19853
20500
|
id,
|
|
@@ -19937,7 +20584,7 @@ function describeExpiry(expiresAt, now) {
|
|
|
19937
20584
|
*
|
|
19938
20585
|
* What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
|
|
19939
20586
|
*/
|
|
19940
|
-
function row$
|
|
20587
|
+
function row$20(id, status, detail) {
|
|
19941
20588
|
return {
|
|
19942
20589
|
id: `verify:${id}`,
|
|
19943
20590
|
title: `verify ${id}`,
|
|
@@ -19965,12 +20612,12 @@ async function verifyRows(input) {
|
|
|
19965
20612
|
try {
|
|
19966
20613
|
module = await importer(pkg);
|
|
19967
20614
|
} catch (err) {
|
|
19968
|
-
rows.push(row$
|
|
20615
|
+
rows.push(row$20(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
19969
20616
|
continue;
|
|
19970
20617
|
}
|
|
19971
20618
|
for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
|
|
19972
20619
|
}
|
|
19973
|
-
if (rows.length === 0) rows.push(row$
|
|
20620
|
+
if (rows.length === 0) rows.push(row$20("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
19974
20621
|
return rows;
|
|
19975
20622
|
}
|
|
19976
20623
|
/**
|
|
@@ -19983,30 +20630,30 @@ async function loadCredentials(input) {
|
|
|
19983
20630
|
try {
|
|
19984
20631
|
await input.loader.load();
|
|
19985
20632
|
} catch (err) {
|
|
19986
|
-
return [row$
|
|
20633
|
+
return [row$20("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
19987
20634
|
}
|
|
19988
|
-
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
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)}`));
|
|
19989
20636
|
}
|
|
19990
20637
|
async function checkToken(token, module, env, readToken, now) {
|
|
19991
20638
|
const { keyringKey, envName, vendorEnvName } = token;
|
|
19992
20639
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
19993
20640
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
19994
20641
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
19995
|
-
if (!value) return row$
|
|
20642
|
+
if (!value) return row$20(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
|
|
19996
20643
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
19997
|
-
if (!verify) return row$
|
|
20644
|
+
if (!verify) return row$20(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
19998
20645
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
19999
20646
|
try {
|
|
20000
20647
|
const verified = await verify(value);
|
|
20001
|
-
if (!verified.ok) return row$
|
|
20648
|
+
if (!verified.ok) return row$20(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
20002
20649
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
20003
|
-
if (!expiry) return row$
|
|
20650
|
+
if (!expiry) return row$20(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
20004
20651
|
return expiry.soon ? {
|
|
20005
|
-
...row$
|
|
20652
|
+
...row$20(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
20006
20653
|
problems: [`${expiry.text}: renew it`]
|
|
20007
|
-
} : row$
|
|
20654
|
+
} : row$20(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
20008
20655
|
} catch (err) {
|
|
20009
|
-
return row$
|
|
20656
|
+
return row$20(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
20010
20657
|
}
|
|
20011
20658
|
}
|
|
20012
20659
|
// src/commands/doctor-secrets/doctor-secrets.ts
|
|
@@ -20094,6 +20741,7 @@ async function runDoctorSecrets(input) {
|
|
|
20094
20741
|
wants
|
|
20095
20742
|
}));
|
|
20096
20743
|
} else rows.push(...skipRow("test"));
|
|
20744
|
+
if (!input.shared) rows.push(...skipRow("preview"), ...skipRow("agent"));
|
|
20097
20745
|
if (input.verify) {
|
|
20098
20746
|
ran = true;
|
|
20099
20747
|
try {
|
|
@@ -20122,12 +20770,12 @@ async function runDoctorSecrets(input) {
|
|
|
20122
20770
|
}
|
|
20123
20771
|
if (input.shared) {
|
|
20124
20772
|
ran = true;
|
|
20125
|
-
const layers = ENVIRONMENT_LAYERS.filter((layer) =>
|
|
20773
|
+
const layers = ENVIRONMENT_LAYERS.filter((layer) => wants(layer));
|
|
20126
20774
|
if (layers.length < 2) rows.push({
|
|
20127
20775
|
id: "shared:layers",
|
|
20128
20776
|
title: "compare the layers",
|
|
20129
20777
|
status: "skip",
|
|
20130
|
-
detail: "--shared needs two or more of local, dev, ci and
|
|
20778
|
+
detail: "--shared needs two or more of local, dev, ci, prod, preview and agent in --env",
|
|
20131
20779
|
problems: []
|
|
20132
20780
|
});
|
|
20133
20781
|
else {
|
|
@@ -20192,7 +20840,9 @@ const DOCTOR_ENVIRONMENTS = [
|
|
|
20192
20840
|
"dev",
|
|
20193
20841
|
"ci",
|
|
20194
20842
|
"test",
|
|
20195
|
-
"prod"
|
|
20843
|
+
"prod",
|
|
20844
|
+
"preview",
|
|
20845
|
+
"agent"
|
|
20196
20846
|
];
|
|
20197
20847
|
/**
|
|
20198
20848
|
* Turns the `--env` values into the environments to check. Each value may itself be a comma-separated list, so
|
|
@@ -20296,169 +20946,6 @@ function ownerEnvironments(config) {
|
|
|
20296
20946
|
instances
|
|
20297
20947
|
};
|
|
20298
20948
|
}
|
|
20299
|
-
// src/commands/probe/probe-token/choose-token.ts
|
|
20300
|
-
/**
|
|
20301
|
-
* Asks which token a probe that accepts one should check: the configured one, one from an Environment, or one typed in
|
|
20302
|
-
* (hidden as it is typed). Only called on a terminal when neither `--token` nor `--environment` was given.
|
|
20303
|
-
*/
|
|
20304
|
-
async function chooseToken(provider) {
|
|
20305
|
-
const how = await select({
|
|
20306
|
-
message: `Which ${provider} token should it check?`,
|
|
20307
|
-
choices: [
|
|
20308
|
-
{
|
|
20309
|
-
name: "The one this repo is configured to use",
|
|
20310
|
-
value: "configured"
|
|
20311
|
-
},
|
|
20312
|
-
{
|
|
20313
|
-
name: "One from a vault Environment (a layer such as ci or dev, or a name)",
|
|
20314
|
-
value: "environment"
|
|
20315
|
-
},
|
|
20316
|
-
{
|
|
20317
|
-
name: "Type or paste a token",
|
|
20318
|
-
value: "paste"
|
|
20319
|
-
}
|
|
20320
|
-
]
|
|
20321
|
-
});
|
|
20322
|
-
if (how === "environment") return { environment: (await input({
|
|
20323
|
-
message: "Environment (layer or name):",
|
|
20324
|
-
default: "ci"
|
|
20325
|
-
})).trim() };
|
|
20326
|
-
if (how === "paste") return { token: (await password({
|
|
20327
|
-
message: `${provider} token:`,
|
|
20328
|
-
mask: "*"
|
|
20329
|
-
})).trim() };
|
|
20330
|
-
}
|
|
20331
|
-
// src/commands/probe/probe-token/default-provider-tokens.ts
|
|
20332
|
-
/**
|
|
20333
|
-
* Reads the tokens a provider's plugin lists (its module-level `tokens`), resolving the plugin package from the
|
|
20334
|
-
* directory of the config that was loaded so a `--cwd` run finds the plugins installed there.
|
|
20335
|
-
*/
|
|
20336
|
-
function defaultProviderTokens(loaded, importer = createDefaultImporter(dirname(loaded.filepath))) {
|
|
20337
|
-
return async (provider) => (await importer(resolvePluginPackage(provider))).tokens ?? [];
|
|
20338
|
-
}
|
|
20339
|
-
// src/commands/secrets-sync/resolve-environment-id/resolve-environment-id.ts
|
|
20340
|
-
/**
|
|
20341
|
-
* The vault Environment `holocron sync secrets --env <environment>` reads. A layer word (`local`, `dev`, `ci`, `prod`) is the
|
|
20342
|
-
* Environment of that layer of this repository, `<org/repo> - <layer>`; any other text is a literal Environment name.
|
|
20343
|
-
* A literal name wins only when it is not exactly a layer word, so an Environment that is itself called `prod` cannot be
|
|
20344
|
-
* addressed by that name (spec `tech-environment-layers`, #2069).
|
|
20345
|
-
*
|
|
20346
|
-
* @param id - The `--env` value the user gave.
|
|
20347
|
-
* @param input - Where the repository is (its `origin` remote is read there), and optionally how to read it.
|
|
20348
|
-
* @throws {ConfigError} For a layer word when the remote cannot be read (the message names the `environment` option).
|
|
20349
|
-
*/
|
|
20350
|
-
async function resolveEnvironmentId(id, input) {
|
|
20351
|
-
if (!isEnvironmentLayer(id)) return id;
|
|
20352
|
-
return layerEnvironment(await repoSlug(input.repoRoot, input.gitExec), id);
|
|
20353
|
-
}
|
|
20354
|
-
// src/commands/probe/probe-token/holds-no-token-error.ts
|
|
20355
|
-
/** An Environment that holds none of the tokens a plugin lists. Its message names the variables looked for, never a value. */
|
|
20356
|
-
var HoldsNoTokenError = class extends Error {
|
|
20357
|
-
name = "HoldsNoTokenError";
|
|
20358
|
-
};
|
|
20359
|
-
// src/commands/probe/probe-token/environment-tokens.ts
|
|
20360
|
-
/**
|
|
20361
|
-
* Every token the provider declares that one vault Environment holds, read in memory. Only an Environment this repo uses is
|
|
20362
|
-
* read: a layer word (`local`, `dev`, `ci`, `prod`) is this repo's `<org/repo> - <layer>`, and any other text must be a
|
|
20363
|
-
* name the config already names (`configured`), so a probe cannot be pointed at an Environment the repo has nothing to
|
|
20364
|
-
* do with. `local` reads the way the CLI does, `- local` over `- dev`, and `- local` may be absent.
|
|
20365
|
-
*
|
|
20366
|
-
* Each token the provider's plugin lists is looked for under its own variable (`HOLOCRON_SENTRY_TOKEN`), then the
|
|
20367
|
-
* vendor's (`vendorEnvName`); the first that holds a value is that token's. A token the Environment does not hold is in
|
|
20368
|
-
* `missing`, so the caller can report it by name. The Environment's other visible (not concealed) values come back as
|
|
20369
|
-
* `plain`, for the plugin's own settings (a dataset, an account id); a vault that cannot say which are visible gives none.
|
|
20370
|
-
*
|
|
20371
|
-
* @throws {Error} When the name is not one of this repo's, no vault that reads an Environment is configured, the plugin
|
|
20372
|
-
* lists no token, or the Environment holds none of them.
|
|
20373
|
-
*/
|
|
20374
|
-
async function environmentTokens(input) {
|
|
20375
|
-
if (!isEnvironmentLayer(input.environment) && !input.configured.includes(input.environment)) {
|
|
20376
|
-
const known = [...ENVIRONMENT_LAYERS, ...input.configured];
|
|
20377
|
-
throw new Error(`${input.environment} is not an Environment this repo's config names; use one of: ${known.join(", ")}`);
|
|
20378
|
-
}
|
|
20379
|
-
const read = input.vault?.readEnvironment?.bind(input.vault);
|
|
20380
|
-
if (!read) throw new Error("--environment needs a vault provider that can read an Environment (1Password); none is configured");
|
|
20381
|
-
const at = {
|
|
20382
|
-
repoRoot: input.repoRoot,
|
|
20383
|
-
gitExec: input.gitExec
|
|
20384
|
-
};
|
|
20385
|
-
const environment = await resolveEnvironmentId(input.environment, at);
|
|
20386
|
-
const readEntries = input.vault?.readEnvironmentEntries?.bind(input.vault);
|
|
20387
|
-
const readOne = async (id) => {
|
|
20388
|
-
if (!readEntries) return {
|
|
20389
|
-
values: await read(id),
|
|
20390
|
-
plain: {}
|
|
20391
|
-
};
|
|
20392
|
-
const entries = await readEntries(id);
|
|
20393
|
-
return {
|
|
20394
|
-
values: Object.fromEntries(entries.map((e) => [e.name, e.value])),
|
|
20395
|
-
plain: Object.fromEntries(entries.filter((e) => !e.concealed).map((e) => [e.name, e.value]))
|
|
20396
|
-
};
|
|
20397
|
-
};
|
|
20398
|
-
let values;
|
|
20399
|
-
let plain;
|
|
20400
|
-
if (input.environment === "local") {
|
|
20401
|
-
const dev = await readOne(await resolveEnvironmentId("dev", at));
|
|
20402
|
-
const local = await readOne(environment).catch(() => ({
|
|
20403
|
-
values: {},
|
|
20404
|
-
plain: {}
|
|
20405
|
-
}));
|
|
20406
|
-
values = {
|
|
20407
|
-
...dev.values,
|
|
20408
|
-
...local.values
|
|
20409
|
-
};
|
|
20410
|
-
plain = {
|
|
20411
|
-
...dev.plain,
|
|
20412
|
-
...local.plain
|
|
20413
|
-
};
|
|
20414
|
-
} else ({values, plain} = await readOne(environment));
|
|
20415
|
-
if (input.tokens.length === 0) throw new Error(`the ${input.provider} plugin lists no token to look for`);
|
|
20416
|
-
const held = [];
|
|
20417
|
-
const missing = [];
|
|
20418
|
-
for (const declared of input.tokens) {
|
|
20419
|
-
const variable = [declared.envName, ...declared.vendorEnvName ? [declared.vendorEnvName] : []].find((v) => values[v]);
|
|
20420
|
-
if (variable) held.push({
|
|
20421
|
-
token: values[variable],
|
|
20422
|
-
variable,
|
|
20423
|
-
envName: declared.envName
|
|
20424
|
-
});
|
|
20425
|
-
else missing.push(declared.envName);
|
|
20426
|
-
}
|
|
20427
|
-
if (held.length === 0) throw new HoldsNoTokenError(`${environment} holds none of ${input.tokens.flatMap((t) => [t.envName, ...t.vendorEnvName ? [t.vendorEnvName] : []]).join(", ")}`);
|
|
20428
|
-
for (const declared of input.tokens) {
|
|
20429
|
-
delete plain[declared.envName];
|
|
20430
|
-
if (declared.vendorEnvName) delete plain[declared.vendorEnvName];
|
|
20431
|
-
}
|
|
20432
|
-
return {
|
|
20433
|
-
environment,
|
|
20434
|
-
held,
|
|
20435
|
-
missing,
|
|
20436
|
-
plain
|
|
20437
|
-
};
|
|
20438
|
-
}
|
|
20439
|
-
// src/commands/probe/probe-token/with-environment-values/with-environment-values.ts
|
|
20440
|
-
/**
|
|
20441
|
-
* Runs `run` with `values` set in `process.env`, then puts every name back as it was (set again, or removed), even when
|
|
20442
|
-
* `run` throws. It is how a probe that reads another Environment sees that Environment's plain values ahead of the
|
|
20443
|
-
* machine's own: a plugin reads them through the usual chain, which looks at the process environment first, and the
|
|
20444
|
-
* overlay lives only for the one run. Nothing is written anywhere and the values are never printed.
|
|
20445
|
-
*
|
|
20446
|
-
* @param values - The variables to set for the run; none means `run` is called as it is.
|
|
20447
|
-
* @param run - The work that should see them.
|
|
20448
|
-
* @returns What `run` returns.
|
|
20449
|
-
*/
|
|
20450
|
-
async function withEnvironmentValues(values, run) {
|
|
20451
|
-
const names = Object.keys(values ?? {});
|
|
20452
|
-
if (!values || names.length === 0) return run();
|
|
20453
|
-
const before = new Map(names.map((name) => [name, process.env[name]]));
|
|
20454
|
-
for (const name of names) process.env[name] = values[name];
|
|
20455
|
-
try {
|
|
20456
|
-
return await run();
|
|
20457
|
-
} finally {
|
|
20458
|
-
for (const [name, previous] of before) if (previous === void 0) delete process.env[name];
|
|
20459
|
-
else process.env[name] = previous;
|
|
20460
|
-
}
|
|
20461
|
-
}
|
|
20462
20949
|
// src/commands/probe/scrub.ts
|
|
20463
20950
|
const HIDDEN = "«hidden»";
|
|
20464
20951
|
/** Shapes that are credentials wherever they appear: a Discord webhook URL, a bearer header, a Sentry token. */
|
|
@@ -20598,49 +21085,6 @@ async function runProbe(input) {
|
|
|
20598
21085
|
rows
|
|
20599
21086
|
};
|
|
20600
21087
|
}
|
|
20601
|
-
// src/commands/token-rotation/token-rotation.ts
|
|
20602
|
-
/** The rotation policy of a token that declares none: a token is due after 90 days, and an expiry is flagged 14 days ahead. */
|
|
20603
|
-
const DEFAULT_TOKEN_ROTATION = {
|
|
20604
|
-
maxAgeDays: 90,
|
|
20605
|
-
warnDays: 14
|
|
20606
|
-
};
|
|
20607
|
-
/**
|
|
20608
|
-
* The labels of the rows that fail for a token that is due (`expired on ...`, `expires on ... (N days left)` inside the
|
|
20609
|
-
* warning window, `N days old`): what `rotate tokens` looks for in a `doctor tokens` problem to tell a token that is due
|
|
20610
|
-
* from one that only lacks a permission.
|
|
20611
|
-
*/
|
|
20612
|
-
const ROTATION_LABELS = ["expiry", "age"];
|
|
20613
|
-
// src/commands/token-expectations/token-expectations.ts
|
|
20614
|
-
/**
|
|
20615
|
-
* Reads what a plugin's tokens declare (`PluginToken.expect`) as one entry per token and layer that holds it, in the
|
|
20616
|
-
* order of `ENVIRONMENT_LAYERS`. The one reader the token probes, the doctor and the docs check share, so none of them
|
|
20617
|
-
* walks the declaration itself. A token with no `expect` yields nothing; a layer no token holds is never listed.
|
|
20618
|
-
*/
|
|
20619
|
-
function tokenExpectations(tokens, filter = {}) {
|
|
20620
|
-
const found = [];
|
|
20621
|
-
for (const token of tokens) {
|
|
20622
|
-
if (!token.expect || filter.envName !== void 0 && token.envName !== filter.envName) continue;
|
|
20623
|
-
const { layers = [], permissions = {} } = token.expect;
|
|
20624
|
-
for (const layer of ENVIRONMENT_LAYERS) {
|
|
20625
|
-
if (filter.layer !== void 0 && filter.layer !== layer) continue;
|
|
20626
|
-
const rules = permissions[layer];
|
|
20627
|
-
if (!rules && !layers.includes(layer)) continue;
|
|
20628
|
-
const entries = Object.entries(rules ?? {});
|
|
20629
|
-
found.push({
|
|
20630
|
-
envName: token.envName,
|
|
20631
|
-
layer,
|
|
20632
|
-
rules: rules ?? {},
|
|
20633
|
-
required: entries.filter(([, rule]) => rule === "required").map(([name]) => name),
|
|
20634
|
-
absent: entries.filter(([, rule]) => rule === "absent").map(([name]) => name),
|
|
20635
|
-
rotation: {
|
|
20636
|
-
...DEFAULT_TOKEN_ROTATION,
|
|
20637
|
-
...token.expect.rotation
|
|
20638
|
-
}
|
|
20639
|
-
});
|
|
20640
|
-
}
|
|
20641
|
-
}
|
|
20642
|
-
return found;
|
|
20643
|
-
}
|
|
20644
21088
|
// src/commands/doctor-tokens/summarise-probe-rows.ts
|
|
20645
21089
|
/**
|
|
20646
21090
|
* Folds what one token probe reported into the one row the doctor shows for that token in that layer. A failing probe row
|
|
@@ -20694,7 +21138,7 @@ function summariseProbeRows(id, title, rows) {
|
|
|
20694
21138
|
* provider with no `token` probe, no declared layer, or one that cannot be read is a skip with the reason.
|
|
20695
21139
|
*/
|
|
20696
21140
|
const PROBE = "token";
|
|
20697
|
-
const row$
|
|
21141
|
+
const row$19 = (id, title, status, detail, problems = []) => ({
|
|
20698
21142
|
id,
|
|
20699
21143
|
title,
|
|
20700
21144
|
status,
|
|
@@ -20719,12 +21163,12 @@ async function runDoctorTokens(input) {
|
|
|
20719
21163
|
try {
|
|
20720
21164
|
tokens = await providerTokens(provider);
|
|
20721
21165
|
} catch (err) {
|
|
20722
|
-
rows.push(row$
|
|
21166
|
+
rows.push(row$19(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
|
|
20723
21167
|
continue;
|
|
20724
21168
|
}
|
|
20725
21169
|
const expectations = tokenExpectations(tokens);
|
|
20726
|
-
if (expectations.length === 0) rows.push(row$
|
|
20727
|
-
else if (!usableProbe(probes.get(provider))) rows.push(row$
|
|
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`));
|
|
20728
21172
|
else declared.push({
|
|
20729
21173
|
provider,
|
|
20730
21174
|
tokens,
|
|
@@ -20786,14 +21230,14 @@ async function checkLayer(c) {
|
|
|
20786
21230
|
tokens
|
|
20787
21231
|
});
|
|
20788
21232
|
} catch (err) {
|
|
20789
|
-
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$
|
|
20790
|
-
return c.wanted.map((e) => row$
|
|
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)}`));
|
|
20791
21235
|
}
|
|
20792
21236
|
const rows = [];
|
|
20793
21237
|
for (const e of c.wanted) {
|
|
20794
21238
|
const token = held.held.find((h) => h.envName === e.envName);
|
|
20795
21239
|
if (!token) {
|
|
20796
|
-
rows.push(row$
|
|
21240
|
+
rows.push(row$19(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
|
|
20797
21241
|
continue;
|
|
20798
21242
|
}
|
|
20799
21243
|
rows.push(summariseProbeRows(id(e), title(e), await probeToken(c, e, token.token, held.plain)));
|
|
@@ -20866,7 +21310,7 @@ const doctorTokensCommand = {
|
|
|
20866
21310
|
}
|
|
20867
21311
|
};
|
|
20868
21312
|
// src/commands/doctor-wiki/wiki-rows.ts
|
|
20869
|
-
const row$
|
|
21313
|
+
const row$18 = (id, title, status, detail, problems = []) => ({
|
|
20870
21314
|
id,
|
|
20871
21315
|
title,
|
|
20872
21316
|
status,
|
|
@@ -20882,11 +21326,11 @@ const names = (paths) => paths.length > LISTED ? `${paths.slice(0, LISTED).join(
|
|
|
20882
21326
|
* skip, since a machine with no network says nothing about the site.
|
|
20883
21327
|
*/
|
|
20884
21328
|
function siteRow(id, title, probe, notFoundHint) {
|
|
20885
|
-
if (probe.status === void 0) return row$
|
|
20886
|
-
if (probe.status < 400) return row$
|
|
20887
|
-
if (probe.status === 401 || probe.status === 403) return row$
|
|
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)`);
|
|
20888
21332
|
const problem = probe.status === 404 ? `${probe.url} answers 404; ${notFoundHint}` : `${probe.url} answers ${probe.status}, expected a page`;
|
|
20889
|
-
return row$
|
|
21333
|
+
return row$18(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
|
|
20890
21334
|
}
|
|
20891
21335
|
/**
|
|
20892
21336
|
* The rows `holocron doctor wiki` prints for one {@link WikiInspection}: organization, docs instance, the site and its
|
|
@@ -20898,42 +21342,42 @@ function wikiRows(found, providerName) {
|
|
|
20898
21342
|
const { declared, found: foundOrg } = found.organization;
|
|
20899
21343
|
if (foundOrg === null) {
|
|
20900
21344
|
const problem = `fern/fern.config.json has no organization; \`holocron setup\` writes it`;
|
|
20901
|
-
rows.push(row$
|
|
21345
|
+
rows.push(row$18("wiki:organization", "organization is set", "fail", problem, [problem]));
|
|
20902
21346
|
} else if (foundOrg !== declared) {
|
|
20903
21347
|
const problem = `fern/fern.config.json names ${foundOrg}, the config declares ${declared}; run \`holocron setup\``;
|
|
20904
|
-
rows.push(row$
|
|
20905
|
-
} else rows.push(row$
|
|
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`));
|
|
20906
21350
|
const instance = found.instance;
|
|
20907
21351
|
if (instance === null) {
|
|
20908
21352
|
const problem = "fern/docs.yml does not exist; `holocron setup` writes it";
|
|
20909
|
-
rows.push(row$
|
|
21353
|
+
rows.push(row$18("wiki:instance", "docs site is declared", "fail", problem, [problem]));
|
|
20910
21354
|
} else {
|
|
20911
21355
|
const problems = [];
|
|
20912
21356
|
if (instance.foundUrl !== instance.expectedUrl) problems.push(`instance url is ${instance.foundUrl ?? "not set"}, expected ${instance.expectedUrl}`);
|
|
20913
21357
|
if (instance.expectedDomain !== void 0 && instance.foundDomain !== instance.expectedDomain) problems.push(`custom-domain is ${instance.foundDomain ?? "not set"}, expected ${instance.expectedDomain}`);
|
|
20914
|
-
rows.push(problems.length > 0 ? row$
|
|
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`));
|
|
20915
21359
|
}
|
|
20916
21360
|
const [site, domain] = found.site;
|
|
20917
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\`)`));
|
|
20918
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`));
|
|
20919
|
-
if (found.navigation === null) rows.push(row$
|
|
21363
|
+
if (found.navigation === null) rows.push(row$18("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
|
|
20920
21364
|
else if (found.navigation.missing.length > 0) {
|
|
20921
21365
|
const problems = found.navigation.missing.map((p) => `${p} is listed in fern/docs.yml but is not on disk`);
|
|
20922
|
-
rows.push(row$
|
|
21366
|
+
rows.push(row$18("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
|
|
20923
21367
|
} else {
|
|
20924
|
-
rows.push(row$
|
|
20925
|
-
if (found.navigation.unlisted.length > 0) rows.push(row$
|
|
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`));
|
|
20926
21370
|
}
|
|
20927
21371
|
const published = found.published;
|
|
20928
21372
|
const listed = found.navigation?.listed;
|
|
20929
|
-
if (!published) rows.push(row$
|
|
21373
|
+
if (!published) rows.push(row$18("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
|
|
20930
21374
|
else if (published.pages === void 0) {
|
|
20931
21375
|
const why = published.status === void 0 ? published.error ?? "no answer" : `answered ${published.status}`;
|
|
20932
|
-
rows.push(row$
|
|
21376
|
+
rows.push(row$18("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
|
|
20933
21377
|
} else if (listed !== void 0 && published.pages < listed) {
|
|
20934
21378
|
const problem = `${published.url} lists ${published.pages} page(s), the navigation lists ${listed}; the last publish is behind (run the wiki workflow)`;
|
|
20935
|
-
rows.push(row$
|
|
20936
|
-
} else rows.push(row$
|
|
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`));
|
|
20937
21381
|
return rows;
|
|
20938
21382
|
}
|
|
20939
21383
|
// src/commands/doctor-wiki/doctor-wiki.ts
|
|
@@ -21039,7 +21483,7 @@ function readFailureRow(id, title, err) {
|
|
|
21039
21483
|
};
|
|
21040
21484
|
}
|
|
21041
21485
|
// src/commands/doctor-workers/check-project.ts
|
|
21042
|
-
const row$
|
|
21486
|
+
const row$17 = (id, title, status, detail, problems = []) => ({
|
|
21043
21487
|
id,
|
|
21044
21488
|
title,
|
|
21045
21489
|
status,
|
|
@@ -21068,30 +21512,30 @@ async function checkProject(deploy, declared) {
|
|
|
21068
21512
|
let exists = false;
|
|
21069
21513
|
try {
|
|
21070
21514
|
exists = (await deploy.listProjects()).some((p) => same$1(p.name, project) || p.id === project);
|
|
21071
|
-
rows.push(exists ? row$
|
|
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`]));
|
|
21072
21516
|
} catch (err) {
|
|
21073
21517
|
rows.push(readFailureRow(ids.exists, titles.exists, err));
|
|
21074
21518
|
}
|
|
21075
21519
|
const notChecked = (reason) => `not checked: ${reason}`;
|
|
21076
21520
|
const gone = exists ? void 0 : "the project is not readable or not there";
|
|
21077
|
-
if (declared.hostname === void 0) {} else if (gone) rows.push(row$
|
|
21078
|
-
else if (!deploy.listDomains) rows.push(row$
|
|
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`));
|
|
21079
21523
|
else try {
|
|
21080
21524
|
const attached = await deploy.listDomains(project);
|
|
21081
|
-
rows.push(attached.some((d) => same$1(d, declared.hostname)) ? row$
|
|
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`]));
|
|
21082
21526
|
} catch (err) {
|
|
21083
21527
|
rows.push(readFailureRow(ids.domain, titles.domain, err));
|
|
21084
21528
|
}
|
|
21085
|
-
if (gone) rows.push(row$
|
|
21086
|
-
else if (!deploy.latestDeployment) rows.push(row$
|
|
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`));
|
|
21087
21531
|
else try {
|
|
21088
21532
|
const latest = await deploy.latestDeployment(project);
|
|
21089
|
-
if (!latest) rows.push(row$
|
|
21090
|
-
else if (latest.status === "ready") rows.push(row$
|
|
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"));
|
|
21091
21535
|
else if (latest.status === "error") {
|
|
21092
21536
|
const why = latest.errorMessage ? `: ${latest.errorMessage}` : "";
|
|
21093
|
-
rows.push(row$
|
|
21094
|
-
} else rows.push(row$
|
|
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}`));
|
|
21095
21539
|
} catch (err) {
|
|
21096
21540
|
rows.push(readFailureRow(ids.deploy, titles.deploy, err));
|
|
21097
21541
|
}
|
|
@@ -21099,7 +21543,7 @@ async function checkProject(deploy, declared) {
|
|
|
21099
21543
|
}
|
|
21100
21544
|
// src/commands/doctor-workers/check-worker.ts
|
|
21101
21545
|
const same = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
21102
|
-
const row$
|
|
21546
|
+
const row$16 = (id, title, status, detail, problems = []) => ({
|
|
21103
21547
|
id,
|
|
21104
21548
|
title,
|
|
21105
21549
|
status,
|
|
@@ -21124,9 +21568,9 @@ async function checkWorker(workers, worker) {
|
|
|
21124
21568
|
deploy: `${name} Worker's latest deployment is healthy`
|
|
21125
21569
|
};
|
|
21126
21570
|
const skipAll = (reason) => [
|
|
21127
|
-
row$
|
|
21128
|
-
row$
|
|
21129
|
-
row$
|
|
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)
|
|
21130
21574
|
];
|
|
21131
21575
|
if (worker.script === void 0) return skipAll(`${workers.providerName} does not say how it names this Worker`);
|
|
21132
21576
|
const script = worker.script;
|
|
@@ -21139,29 +21583,29 @@ async function checkWorker(workers, worker) {
|
|
|
21139
21583
|
exists = state.exists;
|
|
21140
21584
|
if (!state.exists) {
|
|
21141
21585
|
const problem = `no Worker named ${script}; \`holocron setup\` deploys it`;
|
|
21142
|
-
rows.push(row$
|
|
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}`));
|
|
21143
21587
|
} else {
|
|
21144
|
-
rows.push(state.routes.some((r) => same(r, route)) ? row$
|
|
21145
|
-
if (worker.bindings.length === 0) rows.push(row$
|
|
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"));
|
|
21146
21590
|
else {
|
|
21147
21591
|
const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
|
|
21148
21592
|
const missing = worker.bindings.filter((n) => !bound.has(n.toUpperCase()));
|
|
21149
|
-
rows.push(missing.length === 0 ? row$
|
|
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`)));
|
|
21150
21594
|
}
|
|
21151
21595
|
}
|
|
21152
21596
|
} catch (err) {
|
|
21153
21597
|
const failure = readFailureRow(ids.deployed, titles.deployed, err);
|
|
21154
|
-
rows.push(failure, row$
|
|
21598
|
+
rows.push(failure, row$16(ids.bindings, titles.bindings, "skip", "not checked: could not read the Worker"));
|
|
21155
21599
|
}
|
|
21156
|
-
if (!exists) rows.push(row$
|
|
21157
|
-
else if (!workers.latestDeployment) rows.push(row$
|
|
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`));
|
|
21158
21602
|
else try {
|
|
21159
21603
|
const latest = await workers.latestDeployment(script);
|
|
21160
|
-
if (!latest) rows.push(row$
|
|
21604
|
+
if (!latest) rows.push(row$16(ids.deploy, titles.deploy, "skip", `${script} has no recorded deployment`));
|
|
21161
21605
|
else if (!latest.active) {
|
|
21162
21606
|
const problem = `the newest deployment of ${script} does not serve all traffic`;
|
|
21163
|
-
rows.push(row$
|
|
21164
|
-
} else rows.push(row$
|
|
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"));
|
|
21165
21609
|
} catch (err) {
|
|
21166
21610
|
rows.push(readFailureRow(ids.deploy, titles.deploy, err));
|
|
21167
21611
|
}
|
|
@@ -21225,7 +21669,7 @@ function declaredWorkers(input) {
|
|
|
21225
21669
|
* custom domain is attached, and the newest production deployment is ready. Only what the provider proves wrong
|
|
21226
21670
|
* fails; a missing token, a 401 or 403, or a provider that cannot read it is a skip with the reason.
|
|
21227
21671
|
*/
|
|
21228
|
-
const row$
|
|
21672
|
+
const row$15 = (id, title, status, detail) => ({
|
|
21229
21673
|
id,
|
|
21230
21674
|
title,
|
|
21231
21675
|
status,
|
|
@@ -21251,12 +21695,12 @@ async function runDoctorWorkers(input) {
|
|
|
21251
21695
|
...loader.has("wiki") ? { wiki: loader.get("wiki") } : {},
|
|
21252
21696
|
...workers ? { workers } : {}
|
|
21253
21697
|
});
|
|
21254
|
-
if (declared.length === 0) rows.push(row$
|
|
21698
|
+
if (declared.length === 0) rows.push(row$15("workers", "declared Workers", "ok", "none declared"));
|
|
21255
21699
|
else if (!workers) {
|
|
21256
21700
|
const why = whyNone(loader, "workers", "no `workers` provider is configured in holocron.config.ts");
|
|
21257
|
-
for (const worker of declared) rows.push(row$
|
|
21701
|
+
for (const worker of declared) rows.push(row$15(`workers:${worker.label}`, `${worker.label} Worker`, "skip", why));
|
|
21258
21702
|
} else for (const worker of declared) rows.push(...await checkWorker(workers, worker));
|
|
21259
|
-
if (!loader.has("deployment")) rows.push(row$
|
|
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")));
|
|
21260
21704
|
else {
|
|
21261
21705
|
const deploy = loader.get("deployment");
|
|
21262
21706
|
for (const project of declaredProjects(input.loaded.resolved, deploy)) rows.push(...await checkProject(deploy, project));
|
|
@@ -21310,6 +21754,19 @@ const DEEP_CHECKS = [
|
|
|
21310
21754
|
};
|
|
21311
21755
|
}
|
|
21312
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
|
+
},
|
|
21313
21770
|
{
|
|
21314
21771
|
name: "environments",
|
|
21315
21772
|
capability: "environments",
|
|
@@ -22240,7 +22697,7 @@ function resolveExportDir(input) {
|
|
|
22240
22697
|
* listed under the provider's row and does not fail the run. It writes files, so it asks first unless `--dry-run` (the
|
|
22241
22698
|
* files are converted and listed, nothing is written) or `--yes` (without a terminal it refuses instead).
|
|
22242
22699
|
*/
|
|
22243
|
-
const row$
|
|
22700
|
+
const row$14 = (id, status, detail, problems = []) => ({
|
|
22244
22701
|
id,
|
|
22245
22702
|
title: id,
|
|
22246
22703
|
status,
|
|
@@ -22282,9 +22739,9 @@ async function runRequestsExport(input) {
|
|
|
22282
22739
|
print("");
|
|
22283
22740
|
const entry = input.loaded.resolved.providers.tooling;
|
|
22284
22741
|
const tuples = entry?.cardinality === "many" ? entry.tuples : [];
|
|
22285
|
-
if (tuples.length === 0) return finish([row$
|
|
22742
|
+
if (tuples.length === 0) return finish([row$14("tooling", "fail", "the config has no `tooling` provider to export for")]);
|
|
22286
22743
|
const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
|
|
22287
|
-
if (chosen.length === 0) return finish([row$
|
|
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(", ")})`)]);
|
|
22288
22745
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
22289
22746
|
const loader = input.loader ?? new PluginLoader({
|
|
22290
22747
|
...input.loaded.resolved,
|
|
@@ -22304,17 +22761,17 @@ async function runRequestsExport(input) {
|
|
|
22304
22761
|
const tool = loaded.find((t) => t.providerName === id);
|
|
22305
22762
|
if (!tool) {
|
|
22306
22763
|
const failure = loader.loadFailures().find((f) => f.key === "tooling" && f.provider === id);
|
|
22307
|
-
rows.push(row$
|
|
22764
|
+
rows.push(row$14(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
|
|
22308
22765
|
continue;
|
|
22309
22766
|
}
|
|
22310
22767
|
if (!tool.export) {
|
|
22311
|
-
rows.push(row$
|
|
22768
|
+
rows.push(row$14(id, "skip", "has no export: it reads the repo's files as they are"));
|
|
22312
22769
|
continue;
|
|
22313
22770
|
}
|
|
22314
22771
|
const collectionFiles = fileList$1(tuple.options.collectionFiles);
|
|
22315
22772
|
const envFiles = fileList$1(tuple.options.envFiles);
|
|
22316
22773
|
if (collectionFiles.length === 0) {
|
|
22317
|
-
rows.push(row$
|
|
22774
|
+
rows.push(row$14(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
|
|
22318
22775
|
continue;
|
|
22319
22776
|
}
|
|
22320
22777
|
const groups = input.out === void 0 ? groupByFolder(collectionFiles) : [collectionFiles];
|
|
@@ -22328,7 +22785,7 @@ async function runRequestsExport(input) {
|
|
|
22328
22785
|
...input.out !== void 0 ? { out: input.out } : {}
|
|
22329
22786
|
});
|
|
22330
22787
|
if (!dir.ok) {
|
|
22331
|
-
rows.push(row$
|
|
22788
|
+
rows.push(row$14(label, "fail", dir.message));
|
|
22332
22789
|
continue;
|
|
22333
22790
|
}
|
|
22334
22791
|
targets.push({
|
|
@@ -22367,9 +22824,9 @@ async function runRequestsExport(input) {
|
|
|
22367
22824
|
const where = relative(repoRoot, outDir);
|
|
22368
22825
|
const files = result.files.length > 0 ? ` (${result.files.join(", ")})` : "";
|
|
22369
22826
|
paths.push(...result.files.map((file) => resolve(outDir, file)));
|
|
22370
|
-
rows.push(row$
|
|
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}`)));
|
|
22371
22828
|
} catch (err) {
|
|
22372
|
-
rows.push(row$
|
|
22829
|
+
rows.push(row$14(label, "fail", describeError(err)));
|
|
22373
22830
|
}
|
|
22374
22831
|
const report = finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
22375
22832
|
if (paths.length > 0) {
|
|
@@ -22884,10 +23341,10 @@ async function agentsFile(root) {
|
|
|
22884
23341
|
for (const name of ["AGENTS.md", "CLAUDE.md"]) if ((await lstat(join(root, name)).catch(() => null))?.isFile()) return name;
|
|
22885
23342
|
return null;
|
|
22886
23343
|
}
|
|
22887
|
-
const isObject$
|
|
23344
|
+
const isObject$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22888
23345
|
/** Whether a hook entry already runs `dcg`, with or without arguments (`dcg`, `dcg --strict`, a path ending in `/dcg`). */
|
|
22889
23346
|
function runsDcg(hook) {
|
|
22890
|
-
if (!isObject$
|
|
23347
|
+
if (!isObject$2(hook) || typeof hook.command !== "string") return false;
|
|
22891
23348
|
const program = hook.command.trim().split(/\s+/)[0];
|
|
22892
23349
|
return program === "dcg" || program.endsWith(`/dcg`);
|
|
22893
23350
|
}
|
|
@@ -22898,13 +23355,13 @@ function runsDcg(hook) {
|
|
|
22898
23355
|
* that is not an object or a list), so a hand-edited file is never silently replaced.
|
|
22899
23356
|
*/
|
|
22900
23357
|
function withDcgHook(settings) {
|
|
22901
|
-
if (!isObject$
|
|
23358
|
+
if (!isObject$2(settings)) throw new Error("the settings file is not a JSON object");
|
|
22902
23359
|
const hooks = settings.hooks ?? {};
|
|
22903
|
-
if (!isObject$
|
|
23360
|
+
if (!isObject$2(hooks)) throw new Error("`hooks` in the settings file is not an object");
|
|
22904
23361
|
const listed = hooks.PreToolUse ?? [];
|
|
22905
23362
|
if (!Array.isArray(listed)) throw new Error("`hooks.PreToolUse` in the settings file is not a list");
|
|
22906
23363
|
const preToolUse = listed;
|
|
22907
|
-
if (preToolUse.some((entry) => isObject$
|
|
23364
|
+
if (preToolUse.some((entry) => isObject$2(entry) && entry.matcher === "Bash" && Array.isArray(entry.hooks) && entry.hooks.some(runsDcg))) return settings;
|
|
22908
23365
|
return {
|
|
22909
23366
|
...settings,
|
|
22910
23367
|
hooks: {
|
|
@@ -22919,17 +23376,52 @@ function withDcgHook(settings) {
|
|
|
22919
23376
|
}
|
|
22920
23377
|
};
|
|
22921
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
|
+
}
|
|
22922
23409
|
// src/commands/repo-files/generate-claude-files.ts
|
|
22923
23410
|
const CLAUDE_SETTINGS_FILE = ".claude/settings.json";
|
|
22924
23411
|
/**
|
|
22925
|
-
* `.claude/settings.json`
|
|
22926
|
-
*
|
|
22927
|
-
* `
|
|
22928
|
-
*
|
|
22929
|
-
*
|
|
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.
|
|
22930
23419
|
*/
|
|
22931
23420
|
async function generateClaudeFiles(input) {
|
|
22932
|
-
|
|
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 [];
|
|
22933
23425
|
const step = `write ${CLAUDE_SETTINGS_FILE}`;
|
|
22934
23426
|
const text = await readFile(join(input.repoRoot, CLAUDE_SETTINGS_FILE), "utf8").catch(() => void 0);
|
|
22935
23427
|
let existing = {};
|
|
@@ -22944,14 +23436,16 @@ async function generateClaudeFiles(input) {
|
|
|
22944
23436
|
}];
|
|
22945
23437
|
}
|
|
22946
23438
|
try {
|
|
22947
|
-
const
|
|
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(", ");
|
|
22948
23442
|
return [{
|
|
22949
23443
|
kind: "file",
|
|
22950
23444
|
path: CLAUDE_SETTINGS_FILE,
|
|
22951
23445
|
content,
|
|
22952
23446
|
step,
|
|
22953
23447
|
syncStep: step,
|
|
22954
|
-
note
|
|
23448
|
+
note
|
|
22955
23449
|
}];
|
|
22956
23450
|
} catch (err) {
|
|
22957
23451
|
return [{
|
|
@@ -26665,7 +27159,7 @@ function specName(title, name) {
|
|
|
26665
27159
|
*/
|
|
26666
27160
|
/** How many lines of the spec a dry run shows. */
|
|
26667
27161
|
const PREVIEW_LINES$1 = 12;
|
|
26668
|
-
const row$
|
|
27162
|
+
const row$13 = (id, status, detail) => ({
|
|
26669
27163
|
id,
|
|
26670
27164
|
title: id,
|
|
26671
27165
|
status,
|
|
@@ -26695,7 +27189,7 @@ async function runIdeasPromote(input) {
|
|
|
26695
27189
|
print(style.header(`Holocron new spec${dryRun ? " (dry-run)" : ""}`));
|
|
26696
27190
|
print("");
|
|
26697
27191
|
const entry = input.loaded.resolved.providers.issues;
|
|
26698
|
-
if (!entry) return finish([row$
|
|
27192
|
+
if (!entry) return finish([row$13(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
|
|
26699
27193
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
26700
27194
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
26701
27195
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -26710,18 +27204,18 @@ async function runIdeasPromote(input) {
|
|
|
26710
27204
|
assertPluginsResolvable(loader, "new spec");
|
|
26711
27205
|
if (!loader.has("issues")) {
|
|
26712
27206
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
26713
|
-
return finish([row$
|
|
27207
|
+
return finish([row$13(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
26714
27208
|
}
|
|
26715
27209
|
let issue;
|
|
26716
27210
|
try {
|
|
26717
27211
|
issue = await loader.get("issues").get(input.issue);
|
|
26718
27212
|
} catch (err) {
|
|
26719
|
-
return finish([row$
|
|
27213
|
+
return finish([row$13(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
|
|
26720
27214
|
}
|
|
26721
27215
|
const name = specName(issue.summary, input.name);
|
|
26722
|
-
if (!name) return finish([row$
|
|
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`)]);
|
|
26723
27217
|
const relative = join(".notes", `${name}.spec.md`);
|
|
26724
|
-
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$
|
|
27218
|
+
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$13(relative, "fail", "the spec already exists; it is never overwritten")], relative);
|
|
26725
27219
|
const { org, name: repoName } = input.loaded.resolved;
|
|
26726
27220
|
const ref = githubRef(issue.url) ?? (issue.key.startsWith("#") ? `${org}/${repoName}${issue.key}` : issue.key);
|
|
26727
27221
|
const { content, fromIdea } = buildSpec({
|
|
@@ -26734,7 +27228,7 @@ async function runIdeasPromote(input) {
|
|
|
26734
27228
|
print(` ${relative}`);
|
|
26735
27229
|
for (const line of content.split("\n").slice(0, PREVIEW_LINES$1)) print(` ${style.skip(line)}`);
|
|
26736
27230
|
print("");
|
|
26737
|
-
return finish([row$
|
|
27231
|
+
return finish([row$13(relative, "skip", `would write the spec ${origin}`)], relative);
|
|
26738
27232
|
}
|
|
26739
27233
|
if (!input.yes) {
|
|
26740
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`);
|
|
@@ -26753,9 +27247,9 @@ async function runIdeasPromote(input) {
|
|
|
26753
27247
|
try {
|
|
26754
27248
|
io.write(join(input.context.repoRoot, relative), content);
|
|
26755
27249
|
} catch (err) {
|
|
26756
|
-
return finish([row$
|
|
27250
|
+
return finish([row$13(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
|
|
26757
27251
|
}
|
|
26758
|
-
return finish([row$
|
|
27252
|
+
return finish([row$13(relative, "ok", `wrote the spec ${origin}`)], relative);
|
|
26759
27253
|
}
|
|
26760
27254
|
// src/commands/ideas-promote/ideas-promote.command.ts
|
|
26761
27255
|
const ideasPromoteCommand = {
|
|
@@ -26831,7 +27325,7 @@ function readIssueBody(file, cwd, read = (p) => readFileSync(p, "utf8")) {
|
|
|
26831
27325
|
*/
|
|
26832
27326
|
/** How many lines of the body a dry run shows. */
|
|
26833
27327
|
const PREVIEW_LINES = 8;
|
|
26834
|
-
const row$
|
|
27328
|
+
const row$12 = (id, status, detail) => ({
|
|
26835
27329
|
id,
|
|
26836
27330
|
title: id,
|
|
26837
27331
|
status,
|
|
@@ -26855,11 +27349,11 @@ async function runIssueCreate(input) {
|
|
|
26855
27349
|
print(style.header(`Holocron new issue${dryRun ? " (dry-run)" : ""}`));
|
|
26856
27350
|
print("");
|
|
26857
27351
|
const title = input.title.trim();
|
|
26858
|
-
if (!title) return finish([row$
|
|
27352
|
+
if (!title) return finish([row$12("title", "fail", "the title is empty")]);
|
|
26859
27353
|
const prepared = prepareIssueFields(input, input.loaded.resolved.repo?.labels?.areas);
|
|
26860
|
-
if (!prepared.ok) return finish(prepared.problems.map((p) => row$
|
|
27354
|
+
if (!prepared.ok) return finish(prepared.problems.map((p) => row$12(title, "fail", p)));
|
|
26861
27355
|
const entry = input.loaded.resolved.providers.issues;
|
|
26862
|
-
if (!entry) return finish([row$
|
|
27356
|
+
if (!entry) return finish([row$12(title, "fail", "the config has no `issues` provider to file the issue with")]);
|
|
26863
27357
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
26864
27358
|
const projects = prepared.project ? input.loaded.resolved.providers.projects : void 0;
|
|
26865
27359
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
@@ -26876,7 +27370,7 @@ async function runIssueCreate(input) {
|
|
|
26876
27370
|
assertPluginsResolvable(loader, "new issue");
|
|
26877
27371
|
if (!loader.has("issues")) {
|
|
26878
27372
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
26879
|
-
return finish([row$
|
|
27373
|
+
return finish([row$12(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
26880
27374
|
}
|
|
26881
27375
|
const labels = [.../* @__PURE__ */ new Set([...(input.labels ?? []).map((l) => l.trim()).filter(Boolean), ...prepared.areaLabels])];
|
|
26882
27376
|
const body = input.body?.trim() ? input.body : void 0;
|
|
@@ -26893,7 +27387,7 @@ async function runIssueCreate(input) {
|
|
|
26893
27387
|
print(` ${title}`);
|
|
26894
27388
|
for (const line of body ? body.split("\n").slice(0, PREVIEW_LINES) : []) print(` ${style.skip(line)}`);
|
|
26895
27389
|
print("");
|
|
26896
|
-
return finish([row$
|
|
27390
|
+
return finish([row$12(title, "skip", `would file the issue${summary}`)]);
|
|
26897
27391
|
}
|
|
26898
27392
|
if (!input.yes) {
|
|
26899
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");
|
|
@@ -26926,12 +27420,12 @@ async function runIssueCreate(input) {
|
|
|
26926
27420
|
...prepared.fields.priority ? { priority: prepared.fields.priority } : {}
|
|
26927
27421
|
}) : void 0;
|
|
26928
27422
|
return finish([
|
|
26929
|
-
row$
|
|
26930
|
-
...(dropped ?? []).map((line) => row$
|
|
27423
|
+
row$12(title, "ok", `filed ${key}`),
|
|
27424
|
+
...(dropped ?? []).map((line) => row$12("not carried across", "skip", line)),
|
|
26931
27425
|
...board ? [board] : []
|
|
26932
27426
|
], key);
|
|
26933
27427
|
} catch (err) {
|
|
26934
|
-
return finish([row$
|
|
27428
|
+
return finish([row$12(title, "fail", `could not file the issue: ${describeError(err)}`)]);
|
|
26935
27429
|
}
|
|
26936
27430
|
}
|
|
26937
27431
|
// src/commands/issue-create/issue-create.command.ts
|
|
@@ -28567,7 +29061,7 @@ async function ensureProjectSeam(context, setup, dryRun, deps = {}) {
|
|
|
28567
29061
|
* Windows, deleted once the import is done). The values go only to that file: nothing here prints, logs or returns one.
|
|
28568
29062
|
*/
|
|
28569
29063
|
/** A name a dotenv file can carry and a shell can export. */
|
|
28570
|
-
const NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
29064
|
+
const NAME$1 = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
28571
29065
|
async function handOffSecrets(input) {
|
|
28572
29066
|
const { print, entries } = input;
|
|
28573
29067
|
const fail = (reason, ...message) => {
|
|
@@ -28583,7 +29077,7 @@ async function handOffSecrets(input) {
|
|
|
28583
29077
|
const names = [];
|
|
28584
29078
|
const blank = [];
|
|
28585
29079
|
for (const { name, value } of entries) {
|
|
28586
|
-
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`);
|
|
28587
29081
|
if (names.includes(name)) return fail("duplicate", `${name} is listed twice: a name is handed over once`);
|
|
28588
29082
|
const line = dotenvLine(name, value);
|
|
28589
29083
|
if (line === null) return fail("unsupported", `${name}: its value is not one a dotenv file can carry`);
|
|
@@ -28884,38 +29378,6 @@ function instanceInputs(input) {
|
|
|
28884
29378
|
}));
|
|
28885
29379
|
return [...found, ...rest];
|
|
28886
29380
|
}
|
|
28887
|
-
// src/commands/instance-token-guide/instance-token-guide.ts
|
|
28888
|
-
/**
|
|
28889
|
-
* For each name only a person can make, where to make it and what it needs: the plugin's own declaration of the token
|
|
28890
|
-
* (`PluginToken`: the vendor page, and the permissions its layer's token must and must not carry, read through
|
|
28891
|
-
* `tokenExpectations()`). A layer a token has no rules for yet (`preview` is new) reads `prod`'s, and `from` says so. A
|
|
28892
|
-
* name no plugin declares is listed with nothing more, because inventing a vendor page would be worse than none.
|
|
28893
|
-
*
|
|
28894
|
-
* @param names - The `person` names of `instanceInputs()`.
|
|
28895
|
-
* @param tokens - Every token the loaded plugins declare.
|
|
28896
|
-
* @param layer - The instance's layer (`preview`).
|
|
28897
|
-
*/
|
|
28898
|
-
function instanceTokenGuide(names, tokens, layer) {
|
|
28899
|
-
return names.map((name) => {
|
|
28900
|
-
const token = tokens.find((candidate) => candidate.envName === name || candidate.vendorEnvName === name);
|
|
28901
|
-
if (!token) return {
|
|
28902
|
-
name,
|
|
28903
|
-
declared: false,
|
|
28904
|
-
required: [],
|
|
28905
|
-
absent: []
|
|
28906
|
-
};
|
|
28907
|
-
const rules = tokenExpectations([token]);
|
|
28908
|
-
const own = rules.find((rule) => rule.layer === layer) ?? rules.find((rule) => rule.layer === "prod");
|
|
28909
|
-
return {
|
|
28910
|
-
name,
|
|
28911
|
-
declared: true,
|
|
28912
|
-
...token.page ? { page: token.page } : {},
|
|
28913
|
-
required: own ? [...own.required] : [],
|
|
28914
|
-
absent: own ? [...own.absent] : [],
|
|
28915
|
-
...own ? { from: own.layer } : {}
|
|
28916
|
-
};
|
|
28917
|
-
});
|
|
28918
|
-
}
|
|
28919
29381
|
// src/commands/new-instance/resolve-copies/resolve-copies.ts
|
|
28920
29382
|
/**
|
|
28921
29383
|
* Settles which `copy` names can be copied. A name already in the instance's Environment is left as it is (a value is
|
|
@@ -28935,7 +29397,7 @@ function resolveCopies(inputs, read, has, from) {
|
|
|
28935
29397
|
return {
|
|
28936
29398
|
inputs: inputs.map((input) => {
|
|
28937
29399
|
if (input.source !== "copy" || has(input.name)) return input;
|
|
28938
|
-
const why = whyNot(input.name, read, from);
|
|
29400
|
+
const why = whyNot$1(input.name, read, from);
|
|
28939
29401
|
if (typeof why === "string") {
|
|
28940
29402
|
demoted.push({
|
|
28941
29403
|
name: input.name,
|
|
@@ -28954,7 +29416,7 @@ function resolveCopies(inputs, read, has, from) {
|
|
|
28954
29416
|
};
|
|
28955
29417
|
}
|
|
28956
29418
|
/** The reason a name cannot be copied, or its value. */
|
|
28957
|
-
function whyNot(name, read, from) {
|
|
29419
|
+
function whyNot$1(name, read, from) {
|
|
28958
29420
|
if (!read || read.status === "unreadable") return `${from} could not be read${read ? `: ${read.reason}` : ""}`;
|
|
28959
29421
|
if (read.status === "missing") return `${from} does not exist`;
|
|
28960
29422
|
const entry = read.entries[name];
|
|
@@ -28979,20 +29441,6 @@ function stepRow(step) {
|
|
|
28979
29441
|
problems: []
|
|
28980
29442
|
};
|
|
28981
29443
|
}
|
|
28982
|
-
// src/commands/new-instance/token-problem/token-problem.ts
|
|
28983
|
-
/**
|
|
28984
|
-
* 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
|
|
28985
|
-
* it must not, and which layer's rules those are. A token no plugin declares says so, because nothing more is known.
|
|
28986
|
-
* Names and addresses only.
|
|
28987
|
-
*/
|
|
28988
|
-
function tokenProblem(guide) {
|
|
28989
|
-
if (!guide.declared) return `${guide.name}: no plugin declares it, so make it where it comes from`;
|
|
28990
|
-
const where = guide.page ? `make it at ${guide.page}` : "its plugin names no page to make it at";
|
|
28991
|
-
const needs = guide.required.length > 0 ? `; it needs ${guide.required.join(", ")}` : "";
|
|
28992
|
-
const avoids = guide.absent.length > 0 ? `; it must not have ${guide.absent.join(", ")}` : "";
|
|
28993
|
-
const from = guide.from ? ` (the ${guide.from} layer's rules)` : "";
|
|
28994
|
-
return `${guide.name}: ${where}${needs}${avoids}${from}`;
|
|
28995
|
-
}
|
|
28996
29444
|
// src/commands/new-instance/run-new-instance/run-new-instance.ts
|
|
28997
29445
|
/** The steps in order, which is also how a stop says what is left: the step that stopped it and every one after. */
|
|
28998
29446
|
const STEPS = [
|
|
@@ -29297,7 +29745,7 @@ function readGitConfig(cwd, key, run = runGit) {
|
|
|
29297
29745
|
* identity; Effort is asked on a terminal when it was not given (the CLI never chooses it). The issue's key is printed
|
|
29298
29746
|
* by the first row, before anything else is done, so a failed spec leaves the issue as the anchor to resume from.
|
|
29299
29747
|
*/
|
|
29300
|
-
const row$
|
|
29748
|
+
const row$11 = (id, status, detail) => ({
|
|
29301
29749
|
id,
|
|
29302
29750
|
title: id,
|
|
29303
29751
|
status,
|
|
@@ -29316,7 +29764,7 @@ async function runNewWork(input) {
|
|
|
29316
29764
|
const name = specName(input.title, input.specName);
|
|
29317
29765
|
if (!name) {
|
|
29318
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`;
|
|
29319
|
-
const rows = [row$
|
|
29767
|
+
const rows = [row$11("spec", "fail", detail)];
|
|
29320
29768
|
printCheckRows(rows, print);
|
|
29321
29769
|
return {
|
|
29322
29770
|
status: "fail",
|
|
@@ -29325,7 +29773,7 @@ async function runNewWork(input) {
|
|
|
29325
29773
|
}
|
|
29326
29774
|
specPath = join(".notes", `${name}.spec.md`);
|
|
29327
29775
|
if (io.exists(join(root, specPath))) {
|
|
29328
|
-
const rows = [row$
|
|
29776
|
+
const rows = [row$11(specPath, "fail", "the spec already exists; it is never overwritten")];
|
|
29329
29777
|
printCheckRows(rows, print);
|
|
29330
29778
|
return {
|
|
29331
29779
|
status: "fail",
|
|
@@ -29335,7 +29783,7 @@ async function runNewWork(input) {
|
|
|
29335
29783
|
}
|
|
29336
29784
|
}
|
|
29337
29785
|
const assignees = input.assignees && input.assignees.length > 0 ? input.assignees : [gitAssignee(input.gitConfig ?? ((key) => readGitConfig(root, key)))].filter((a) => Boolean(a));
|
|
29338
|
-
if (!input.assignees?.length && assignees.length === 0) extra.push(row$
|
|
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"));
|
|
29339
29787
|
let effort = input.effort;
|
|
29340
29788
|
const interactive = input.interactive ?? Boolean(process.stdin.isTTY);
|
|
29341
29789
|
if (!effort && !input.yes && !dryRun && interactive) effort = await (input.askEffort ?? promptEffort)();
|
|
@@ -32325,7 +32773,7 @@ const MARKER = "# written by `holocron open requests` for one session and remove
|
|
|
32325
32773
|
const SECRETS_FILE = `${PRIVATE_DIR}/requests.env`;
|
|
32326
32774
|
/** The lock a launch holds, in the private directory. */
|
|
32327
32775
|
const LOCK_FILE = `${PRIVATE_DIR}/open-requests.lock`;
|
|
32328
|
-
const row$
|
|
32776
|
+
const row$10 = (id, status, detail, problems = []) => ({
|
|
32329
32777
|
id,
|
|
32330
32778
|
title: id,
|
|
32331
32779
|
status,
|
|
@@ -32366,7 +32814,7 @@ async function runOpenRequests(input) {
|
|
|
32366
32814
|
const tuples = entry?.cardinality === "many" ? entry.tuples : [];
|
|
32367
32815
|
const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
|
|
32368
32816
|
if (chosen.length === 0) {
|
|
32369
|
-
say(row$
|
|
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(", ")})`));
|
|
32370
32818
|
return finish();
|
|
32371
32819
|
}
|
|
32372
32820
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
@@ -32376,7 +32824,7 @@ async function runOpenRequests(input) {
|
|
|
32376
32824
|
assertPluginsResolvable(loader, "open requests");
|
|
32377
32825
|
const openable = (loader.has("tooling") ? loader.get("tooling") : []).filter((t) => chosen.some((tuple) => tuple.provider === t.providerName)).filter((t) => t.open !== void 0);
|
|
32378
32826
|
if (openable.length !== 1) {
|
|
32379
|
-
say(row$
|
|
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`));
|
|
32380
32828
|
return finish();
|
|
32381
32829
|
}
|
|
32382
32830
|
const tool = openable[0];
|
|
@@ -32390,34 +32838,34 @@ async function runOpenRequests(input) {
|
|
|
32390
32838
|
repoRoot
|
|
32391
32839
|
});
|
|
32392
32840
|
} catch (err) {
|
|
32393
|
-
say(row$
|
|
32841
|
+
say(row$10(tool.providerName, "fail", describeError(err)));
|
|
32394
32842
|
return finish();
|
|
32395
32843
|
}
|
|
32396
32844
|
const loaded = plan.wants.filter((want) => layers.includes(want.layer));
|
|
32397
32845
|
const notLoaded = plan.wants.filter((want) => !layers.includes(want.layer));
|
|
32398
32846
|
const names = [...new Set(loaded.map((want) => want.name))].sort();
|
|
32399
|
-
if (plan.unfilled.length > 0) say(row$
|
|
32400
|
-
say(row$
|
|
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`)));
|
|
32401
32849
|
if (dryRun) {
|
|
32402
|
-
for (const want of loaded) say(row$
|
|
32403
|
-
if (names.length === 0) say(row$
|
|
32404
|
-
else say(row$
|
|
32405
|
-
say(row$
|
|
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`));
|
|
32406
32854
|
return finish();
|
|
32407
32855
|
}
|
|
32408
32856
|
if (deps.platform === "win32" && names.length > 0) {
|
|
32409
|
-
say(row$
|
|
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"));
|
|
32410
32858
|
return finish();
|
|
32411
32859
|
}
|
|
32412
32860
|
let running;
|
|
32413
32861
|
try {
|
|
32414
32862
|
running = await deps.processes();
|
|
32415
32863
|
} catch (err) {
|
|
32416
|
-
say(row$
|
|
32864
|
+
say(row$10(plan.app, "fail", `could not tell whether ${plan.app} is running: ${describeError(err)}`));
|
|
32417
32865
|
return finish();
|
|
32418
32866
|
}
|
|
32419
32867
|
if (running.split("\n").some((line) => line.includes(plan.running))) {
|
|
32420
|
-
say(row$
|
|
32868
|
+
say(row$10(plan.app, "fail", `${plan.app} is already running; quit it and run this again (it would not see the values)`));
|
|
32421
32869
|
return finish();
|
|
32422
32870
|
}
|
|
32423
32871
|
if (!input.yes) {
|
|
@@ -32434,7 +32882,7 @@ async function runOpenRequests(input) {
|
|
|
32434
32882
|
if (names.length > 0) {
|
|
32435
32883
|
const vault = loader.has("vault") ? loader.get("vault") : void 0;
|
|
32436
32884
|
if (!vault?.readEnvironmentEntries) {
|
|
32437
|
-
say(row$
|
|
32885
|
+
say(row$10("vault", "fail", vault ? `${vault.providerName} cannot read an Environment's entries` : "needs a `vault` provider in holocron.config.ts (1password)"));
|
|
32438
32886
|
return finish();
|
|
32439
32887
|
}
|
|
32440
32888
|
let failed = false;
|
|
@@ -32451,17 +32899,17 @@ async function runOpenRequests(input) {
|
|
|
32451
32899
|
names: [...new Set(wanted.map((want) => want.entry))].sort()
|
|
32452
32900
|
});
|
|
32453
32901
|
} catch (err) {
|
|
32454
|
-
say(row$
|
|
32902
|
+
say(row$10(`vault ${layer}`, "fail", describeError(err)));
|
|
32455
32903
|
failed = true;
|
|
32456
32904
|
continue;
|
|
32457
32905
|
}
|
|
32458
32906
|
for (const entry of read.missing) {
|
|
32459
|
-
say(row$
|
|
32907
|
+
say(row$10(`${layer} ${entry}`, "fail", `${read.environmentId} holds no value for ${entry}`));
|
|
32460
32908
|
failed = true;
|
|
32461
32909
|
}
|
|
32462
32910
|
if (read.missing.length > 0) continue;
|
|
32463
32911
|
for (const want of wanted) values.set(want.name, read.values.get(want.entry));
|
|
32464
|
-
say(row$
|
|
32912
|
+
say(row$10(`vault ${read.environmentId}`, "ok", `${wanted.length} value(s) read: ${[...new Set(wanted.map((want) => want.name))].join(", ")}`));
|
|
32465
32913
|
}
|
|
32466
32914
|
if (failed) return finish();
|
|
32467
32915
|
}
|
|
@@ -32481,7 +32929,7 @@ async function runOpenRequests(input) {
|
|
|
32481
32929
|
};
|
|
32482
32930
|
deps.makeDir(dirname(secrets));
|
|
32483
32931
|
if (!deps.takeLock(lock, deps.pid)) {
|
|
32484
|
-
say(row$
|
|
32932
|
+
say(row$10(plan.app, "fail", `another \`open requests\` is starting ${plan.app} (${LOCK_FILE} is held); try again when it has`));
|
|
32485
32933
|
return finish();
|
|
32486
32934
|
}
|
|
32487
32935
|
const stop = deps.onTerminate(cleanup);
|
|
@@ -32489,18 +32937,18 @@ async function runOpenRequests(input) {
|
|
|
32489
32937
|
if (names.length > 0) {
|
|
32490
32938
|
const ignored = deps.isIgnored(secrets);
|
|
32491
32939
|
if (ignored === "tracked" || ignored === "unknown") {
|
|
32492
|
-
say(row$
|
|
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, "")]));
|
|
32493
32941
|
return finish();
|
|
32494
32942
|
}
|
|
32495
32943
|
const stale = deps.inspect(secrets);
|
|
32496
32944
|
if (stale.kind !== "none" && !(stale.kind === "file" && stale.firstLine === "# written by `holocron open requests` for one session and removed when it ends")) {
|
|
32497
|
-
say(row$
|
|
32945
|
+
say(row$10("values file", "fail", `${SECRETS_FILE} is not this command's (no marker line); move it away`));
|
|
32498
32946
|
return finish();
|
|
32499
32947
|
}
|
|
32500
32948
|
for (const link of plan.targets) {
|
|
32501
32949
|
const state = deps.inspect(link);
|
|
32502
32950
|
if (state.kind !== "none" && !isOurs(state, link, secrets)) {
|
|
32503
|
-
say(row$
|
|
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`));
|
|
32504
32952
|
return finish();
|
|
32505
32953
|
}
|
|
32506
32954
|
}
|
|
@@ -32508,7 +32956,7 @@ async function runOpenRequests(input) {
|
|
|
32508
32956
|
for (const [name, value] of values) {
|
|
32509
32957
|
const line = dotenvLine(name, value);
|
|
32510
32958
|
if (line === null) {
|
|
32511
|
-
say(row$
|
|
32959
|
+
say(row$10(name, "fail", `the value of ${name} cannot be written to a .env file as it is; it was not written`));
|
|
32512
32960
|
return finish();
|
|
32513
32961
|
}
|
|
32514
32962
|
lines.push(line);
|
|
@@ -32521,7 +32969,7 @@ async function runOpenRequests(input) {
|
|
|
32521
32969
|
deps.symlink(relative(dirname(link), secrets), link);
|
|
32522
32970
|
created.push(link);
|
|
32523
32971
|
}
|
|
32524
|
-
say(row$
|
|
32972
|
+
say(row$10("values file", "ok", `${SECRETS_FILE} (mode 0600, git-ignored) linked from ${plan.targets.map((t) => relative(repoRoot, t)).join(", ")}`));
|
|
32525
32973
|
}
|
|
32526
32974
|
print("");
|
|
32527
32975
|
print(`starting ${plan.app}${names.length > 0 ? `; the values are removed when it quits (Ctrl-C ends it too)` : ""}`);
|
|
@@ -32529,10 +32977,10 @@ async function runOpenRequests(input) {
|
|
|
32529
32977
|
try {
|
|
32530
32978
|
exitCode = await deps.run(plan.launch);
|
|
32531
32979
|
} catch (err) {
|
|
32532
|
-
say(row$
|
|
32980
|
+
say(row$10(plan.app, "fail", describeError(err)));
|
|
32533
32981
|
return finish();
|
|
32534
32982
|
}
|
|
32535
|
-
say(row$
|
|
32983
|
+
say(row$10(plan.app, exitCode === 0 ? "ok" : "fail", `ended with ${exitCode}`));
|
|
32536
32984
|
return finish();
|
|
32537
32985
|
} finally {
|
|
32538
32986
|
stop();
|
|
@@ -34756,7 +35204,7 @@ const projectCommand = {
|
|
|
34756
35204
|
*/
|
|
34757
35205
|
/** A vendor's token id: letters, digits and `._:-`, so it is one path segment and nothing that could change a request. */
|
|
34758
35206
|
const TOKEN_ID = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
34759
|
-
const row$
|
|
35207
|
+
const row$9 = (id, title, status, detail, problems = []) => ({
|
|
34760
35208
|
id: `provider-revoke:${id}`,
|
|
34761
35209
|
title,
|
|
34762
35210
|
status,
|
|
@@ -34789,7 +35237,7 @@ async function runProviderRevoke(input) {
|
|
|
34789
35237
|
};
|
|
34790
35238
|
};
|
|
34791
35239
|
print(`Holocron provider ${provider} revoke${dryRun ? " (dry-run)" : ""}`);
|
|
34792
|
-
if (!TOKEN_ID.test(id)) return finish("fail", [row$
|
|
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"])]);
|
|
34793
35241
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
34794
35242
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
34795
35243
|
await loader.load();
|
|
@@ -34799,10 +35247,10 @@ async function runProviderRevoke(input) {
|
|
|
34799
35247
|
revoke = await loader.loadRevokeToken(provider, input.options ?? {});
|
|
34800
35248
|
} catch (err) {
|
|
34801
35249
|
if (err instanceof WorkspaceContextError) throw err;
|
|
34802
|
-
return finish("fail", [row$
|
|
35250
|
+
return finish("fail", [row$9("provider", provider, "fail", `\`${provider}\` did not load`, [describeError(err)])]);
|
|
34803
35251
|
}
|
|
34804
|
-
if (!revoke) return finish("fail", [row$
|
|
34805
|
-
if (dryRun) return finish("dry-run", [row$
|
|
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`)]);
|
|
34806
35254
|
if (!input.yes) {
|
|
34807
35255
|
if (!input.confirm) throw new NonInteractiveError("pass --yes to revoke a token without a terminal");
|
|
34808
35256
|
if (!await input.confirm(`Delete token ${id} at ${provider}? This cannot be undone.`)) {
|
|
@@ -34817,9 +35265,9 @@ async function runProviderRevoke(input) {
|
|
|
34817
35265
|
try {
|
|
34818
35266
|
done = await revoke({ id });
|
|
34819
35267
|
} catch (err) {
|
|
34820
|
-
return finish("fail", [row$
|
|
35268
|
+
return finish("fail", [row$9("revoke", id, "fail", `${provider} did not delete the token`, [describeError(err)])]);
|
|
34821
35269
|
}
|
|
34822
|
-
return finish("ok", [row$
|
|
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))]);
|
|
34823
35271
|
}
|
|
34824
35272
|
// src/commands/provider/provider-token/provider-token.ts
|
|
34825
35273
|
/**
|
|
@@ -34830,7 +35278,7 @@ async function runProviderRevoke(input) {
|
|
|
34830
35278
|
* once imported); no row, log or return value carries it, and the output is scrubbed of it as well. The old token is
|
|
34831
35279
|
* never revoked here.
|
|
34832
35280
|
*/
|
|
34833
|
-
const row$
|
|
35281
|
+
const row$8 = (id, title, status, detail, problems = []) => ({
|
|
34834
35282
|
id: `provider-token:${id}`,
|
|
34835
35283
|
title,
|
|
34836
35284
|
status,
|
|
@@ -34866,7 +35314,7 @@ async function runProviderToken(input) {
|
|
|
34866
35314
|
};
|
|
34867
35315
|
};
|
|
34868
35316
|
print(`Holocron provider ${provider} token (${layer})${dryRun ? " (dry-run)" : ""}`);
|
|
34869
|
-
if (!ENVIRONMENT_LAYERS.includes(layer)) return finish("fail", [row$
|
|
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(", ")}`])]);
|
|
34870
35318
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
34871
35319
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
34872
35320
|
await loader.load();
|
|
@@ -34876,12 +35324,12 @@ async function runProviderToken(input) {
|
|
|
34876
35324
|
mint = await loader.loadMintToken(provider, input.options ?? {});
|
|
34877
35325
|
} catch (err) {
|
|
34878
35326
|
if (err instanceof WorkspaceContextError) throw err;
|
|
34879
|
-
return finish("fail", [row$
|
|
35327
|
+
return finish("fail", [row$8("provider", `${provider}`, "fail", `\`${provider}\` did not load`, [describeError(err)])]);
|
|
34880
35328
|
}
|
|
34881
|
-
if (!mint) return finish("fail", [row$
|
|
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>\``])]);
|
|
34882
35330
|
const now = input.now ?? (() => /* @__PURE__ */ new Date());
|
|
34883
35331
|
const name = input.name ?? `holocron-${provider}-${layer}-${stamp(now())}`;
|
|
34884
|
-
if (dryRun) return finish("dry-run", [row$
|
|
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`)]);
|
|
34885
35333
|
if (!input.yes) {
|
|
34886
35334
|
if (!input.confirm) throw new NonInteractiveError("pass --yes to make a token without a terminal");
|
|
34887
35335
|
if (!await input.confirm(`Make a new ${layer} token named ${name} through ${provider}'s API?`)) {
|
|
@@ -34901,9 +35349,9 @@ async function runProviderToken(input) {
|
|
|
34901
35349
|
now
|
|
34902
35350
|
});
|
|
34903
35351
|
} catch (err) {
|
|
34904
|
-
return finish("fail", [row$
|
|
35352
|
+
return finish("fail", [row$8("mint", name, "fail", `${provider} did not make the token`, [describeError(err)])]);
|
|
34905
35353
|
}
|
|
34906
|
-
const rows = [row$
|
|
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))];
|
|
34907
35355
|
const environment = await (input.resolveEnvironment ?? ((l, repoRoot) => resolveEnvironmentId(l, { repoRoot })))(layer, input.context.repoRoot);
|
|
34908
35356
|
const handed = await (input.handOff ?? handOffSecret)({
|
|
34909
35357
|
name: made.envName,
|
|
@@ -34914,10 +35362,10 @@ async function runProviderToken(input) {
|
|
|
34914
35362
|
...input.interactive === void 0 ? {} : { interactive: input.interactive }
|
|
34915
35363
|
});
|
|
34916
35364
|
if (handed.status === "fail") {
|
|
34917
|
-
rows.push(row$
|
|
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`]));
|
|
34918
35366
|
return finish("fail", rows, [made.value]);
|
|
34919
35367
|
}
|
|
34920
|
-
rows.push(row$
|
|
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}`));
|
|
34921
35369
|
return finish("ok", rows, [made.value]);
|
|
34922
35370
|
}
|
|
34923
35371
|
// src/commands/provider/provider.ts
|
|
@@ -36709,7 +37157,7 @@ const projectReconcileCommand = {
|
|
|
36709
37157
|
* it would do and posts nothing.
|
|
36710
37158
|
*/
|
|
36711
37159
|
const DEFAULT_MAX_AGE_MINUTES = 10;
|
|
36712
|
-
const row$
|
|
37160
|
+
const row$7 = (id, status, detail) => ({
|
|
36713
37161
|
id,
|
|
36714
37162
|
title: id,
|
|
36715
37163
|
status,
|
|
@@ -36748,7 +37196,7 @@ async function runReconcileCi(input) {
|
|
|
36748
37196
|
};
|
|
36749
37197
|
};
|
|
36750
37198
|
const fail = (id, detail) => {
|
|
36751
|
-
rows.push(row$
|
|
37199
|
+
rows.push(row$7(id, "fail", detail));
|
|
36752
37200
|
return finish();
|
|
36753
37201
|
};
|
|
36754
37202
|
print(style.header(`Holocron reconcile ci${dryRun ? " (dry-run)" : ""}`));
|
|
@@ -36756,7 +37204,7 @@ async function runReconcileCi(input) {
|
|
|
36756
37204
|
if (input.maxAgeMinutes !== void 0 && !(input.maxAgeMinutes > 0)) return fail("max-age", "--max-age is a number of minutes above zero");
|
|
36757
37205
|
const poster = aggregatePoster({ ci: input.loaded.resolved.ci });
|
|
36758
37206
|
if (!input.shadow && poster !== "sentinel") {
|
|
36759
|
-
rows.push(row$
|
|
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`));
|
|
36760
37208
|
return finish();
|
|
36761
37209
|
}
|
|
36762
37210
|
const providers = input.loaded.resolved.providers;
|
|
@@ -36796,7 +37244,7 @@ async function runReconcileCi(input) {
|
|
|
36796
37244
|
return fail("pull requests", describeError(error));
|
|
36797
37245
|
}
|
|
36798
37246
|
if (pullRequests.length === 0) {
|
|
36799
|
-
rows.push(row$
|
|
37247
|
+
rows.push(row$7("pull requests", "skip", "no open pull requests"));
|
|
36800
37248
|
return finish();
|
|
36801
37249
|
}
|
|
36802
37250
|
const api = {
|
|
@@ -36809,7 +37257,7 @@ async function runReconcileCi(input) {
|
|
|
36809
37257
|
for (const pr of pullRequests) {
|
|
36810
37258
|
const id = `#${pr.number}`;
|
|
36811
37259
|
if (pr.headSha === void 0) {
|
|
36812
|
-
rows.push(row$
|
|
37260
|
+
rows.push(row$7(id, "skip", "the provider gave no head commit"));
|
|
36813
37261
|
continue;
|
|
36814
37262
|
}
|
|
36815
37263
|
try {
|
|
@@ -36824,17 +37272,17 @@ async function runReconcileCi(input) {
|
|
|
36824
37272
|
name: input.shadow ? AGGREGATE_SHADOW_CHECK_NAME : AGGREGATE_CHECK_NAME
|
|
36825
37273
|
});
|
|
36826
37274
|
const verdict = out.result.conclusion;
|
|
36827
|
-
if (out.action === "foreign") rows.push(row$
|
|
36828
|
-
else if (out.action === "unchanged") rows.push(row$
|
|
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})`));
|
|
36829
37277
|
else if (out.stale) {
|
|
36830
37278
|
const what = dryRun ? "would repair" : "repaired";
|
|
36831
|
-
rows.push(row$
|
|
37279
|
+
rows.push(row$7(id, "fail", `${what}: the check was missing or wrong (now ${verdict}); a delivery was missed`));
|
|
36832
37280
|
} else {
|
|
36833
37281
|
const what = dryRun ? "would post" : "posted";
|
|
36834
|
-
rows.push(row$
|
|
37282
|
+
rows.push(row$7(id, "ok", `${what} ${verdict} (still in flight)`));
|
|
36835
37283
|
}
|
|
36836
37284
|
} catch (error) {
|
|
36837
|
-
rows.push(row$
|
|
37285
|
+
rows.push(row$7(id, "fail", describeError(error)));
|
|
36838
37286
|
}
|
|
36839
37287
|
}
|
|
36840
37288
|
return finish();
|
|
@@ -36917,7 +37365,7 @@ const defaultApi = {
|
|
|
36917
37365
|
listAppDeliveries,
|
|
36918
37366
|
redeliverAppDelivery
|
|
36919
37367
|
};
|
|
36920
|
-
const row$
|
|
37368
|
+
const row$6 = (id, status, detail) => ({
|
|
36921
37369
|
id,
|
|
36922
37370
|
title: id,
|
|
36923
37371
|
status,
|
|
@@ -36948,7 +37396,7 @@ async function runRedeliverWebhooks(input) {
|
|
|
36948
37396
|
};
|
|
36949
37397
|
};
|
|
36950
37398
|
const fail = (id, detail) => {
|
|
36951
|
-
rows.push(row$
|
|
37399
|
+
rows.push(row$6(id, "fail", detail));
|
|
36952
37400
|
return finish();
|
|
36953
37401
|
};
|
|
36954
37402
|
print(style.header(`Holocron redeliver webhooks${dryRun ? " (dry-run)" : ""}`));
|
|
@@ -36961,7 +37409,7 @@ async function runRedeliverWebhooks(input) {
|
|
|
36961
37409
|
}
|
|
36962
37410
|
const all = input.loaded.resolved.githubApps ?? [];
|
|
36963
37411
|
if (all.length === 0) {
|
|
36964
|
-
rows.push(row$
|
|
37412
|
+
rows.push(row$6("github-app", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
36965
37413
|
return finish();
|
|
36966
37414
|
}
|
|
36967
37415
|
const instances = input.app === void 0 ? all : all.filter((instance) => instance.name === input.app);
|
|
@@ -36975,19 +37423,19 @@ async function runRedeliverWebhooks(input) {
|
|
|
36975
37423
|
for (const instance of instances) {
|
|
36976
37424
|
const read = await readAppCredentials(instance, loader);
|
|
36977
37425
|
if ("reason" in read) {
|
|
36978
|
-
rows.push(row$
|
|
37426
|
+
rows.push(row$6(`${instance.name}`, "skip", read.reason));
|
|
36979
37427
|
continue;
|
|
36980
37428
|
}
|
|
36981
37429
|
try {
|
|
36982
37430
|
const failed = failedDeliveries(await api.listAppDeliveries(read.creds, { since }));
|
|
36983
|
-
if (failed.length === 0) rows.push(row$
|
|
37431
|
+
if (failed.length === 0) rows.push(row$6(instance.name, "ok", `no failed deliveries since ${since}`));
|
|
36984
37432
|
for (const delivery of failed) pending.push({
|
|
36985
37433
|
app: instance.name,
|
|
36986
37434
|
creds: read.creds,
|
|
36987
37435
|
delivery
|
|
36988
37436
|
});
|
|
36989
37437
|
} catch (error) {
|
|
36990
|
-
rows.push(row$
|
|
37438
|
+
rows.push(row$6(instance.name, "fail", `cannot read the delivery log: ${scrubbed$1(error, [read.creds.privateKey])}`));
|
|
36991
37439
|
}
|
|
36992
37440
|
}
|
|
36993
37441
|
if (pending.length === 0) return finish();
|
|
@@ -36999,7 +37447,7 @@ async function runRedeliverWebhooks(input) {
|
|
|
36999
37447
|
};
|
|
37000
37448
|
};
|
|
37001
37449
|
if (dryRun) {
|
|
37002
|
-
for (const item of pending) rows.push(row$
|
|
37450
|
+
for (const item of pending) rows.push(row$6(label(item).id, "skip", `would redeliver ${label(item).text}`));
|
|
37003
37451
|
return finish();
|
|
37004
37452
|
}
|
|
37005
37453
|
/* v8 ignore next -- the terminal is only asked outside tests, which inject `interactive` */
|
|
@@ -37011,16 +37459,16 @@ async function runRedeliverWebhooks(input) {
|
|
|
37011
37459
|
default: false
|
|
37012
37460
|
}));
|
|
37013
37461
|
if (!input.yes && !await ask(`Redeliver ${pending.length} failed webhook deliver${pending.length === 1 ? "y" : "ies"}?`)) {
|
|
37014
|
-
rows.push(row$
|
|
37462
|
+
rows.push(row$6("redeliver", "skip", "not confirmed; nothing was redelivered"));
|
|
37015
37463
|
return finish();
|
|
37016
37464
|
}
|
|
37017
37465
|
for (const item of pending) {
|
|
37018
37466
|
const { id, text } = label(item);
|
|
37019
37467
|
try {
|
|
37020
37468
|
await api.redeliverAppDelivery(item.creds, item.delivery.id);
|
|
37021
|
-
rows.push(row$
|
|
37469
|
+
rows.push(row$6(id, "ok", `redelivered ${text}`));
|
|
37022
37470
|
} catch (error) {
|
|
37023
|
-
rows.push(row$
|
|
37471
|
+
rows.push(row$6(id, "fail", scrubbed$1(error, [item.creds.privateKey])));
|
|
37024
37472
|
}
|
|
37025
37473
|
}
|
|
37026
37474
|
return finish();
|
|
@@ -37179,7 +37627,7 @@ function dueTokens(rows, layers) {
|
|
|
37179
37627
|
* so it cannot know the import and the sync happened. It ends with the order of what is left for each replaced token.
|
|
37180
37628
|
* No token value is printed, logged or returned.
|
|
37181
37629
|
*/
|
|
37182
|
-
const row$
|
|
37630
|
+
const row$5 = (id, title, status, detail, problems = []) => ({
|
|
37183
37631
|
id: `rotate:${id}`,
|
|
37184
37632
|
title,
|
|
37185
37633
|
status,
|
|
@@ -37212,7 +37660,7 @@ async function runRotateTokens(input) {
|
|
|
37212
37660
|
const layers = input.layers ?? [];
|
|
37213
37661
|
const unknown = layers.find((l) => !ENVIRONMENT_LAYERS.includes(l));
|
|
37214
37662
|
if (unknown !== void 0) {
|
|
37215
|
-
show([row$
|
|
37663
|
+
show([row$5("layer", "layer", "fail", `\`${unknown}\` is not a layer`, [`use one of: ${ENVIRONMENT_LAYERS.join(", ")}`])]);
|
|
37216
37664
|
return finish("fail");
|
|
37217
37665
|
}
|
|
37218
37666
|
const due = dueTokens((await (input.doctor ?? runDoctorTokens)({
|
|
@@ -37221,7 +37669,7 @@ async function runRotateTokens(input) {
|
|
|
37221
37669
|
print: () => {}
|
|
37222
37670
|
})).rows, layers);
|
|
37223
37671
|
if (due.length === 0) {
|
|
37224
|
-
show([row$
|
|
37672
|
+
show([row$5("none", "tokens", "ok", "no token is due")]);
|
|
37225
37673
|
return finish("ok");
|
|
37226
37674
|
}
|
|
37227
37675
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
@@ -37234,7 +37682,7 @@ async function runRotateTokens(input) {
|
|
|
37234
37682
|
canMint.push(mint !== void 0);
|
|
37235
37683
|
}
|
|
37236
37684
|
const replaceable = due.filter((_, i) => canMint[i]);
|
|
37237
|
-
show(due.map((d, i) => canMint[i] ? row$
|
|
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>\``])));
|
|
37238
37686
|
if (dryRun || replaceable.length === 0) return finish(dryRun ? "dry-run" : "ok");
|
|
37239
37687
|
if (!input.yes) {
|
|
37240
37688
|
if (!input.confirm) throw new NonInteractiveError("pass --yes to replace tokens without a terminal");
|
|
@@ -37260,8 +37708,8 @@ async function runRotateTokens(input) {
|
|
|
37260
37708
|
print
|
|
37261
37709
|
});
|
|
37262
37710
|
const id = `${d.layer}:${d.provider}:${d.envName}`;
|
|
37263
|
-
if (made.status === "ok") show([row$
|
|
37264
|
-
else show([row$
|
|
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))]);
|
|
37265
37713
|
}
|
|
37266
37714
|
return finish("ok");
|
|
37267
37715
|
}
|
|
@@ -37580,6 +38028,188 @@ const showCommand = {
|
|
|
37580
38028
|
builder: (y) => y.command(configShowCommand).command(groupMenu("show")),
|
|
37581
38029
|
handler: () => {}
|
|
37582
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
|
+
};
|
|
37583
38213
|
// src/commands/start-work/start-work.command.ts
|
|
37584
38214
|
const startWorkCommand = {
|
|
37585
38215
|
command: "work <issue>",
|
|
@@ -37675,8 +38305,8 @@ const startWorkCommand = {
|
|
|
37675
38305
|
// src/commands/start/start.command.ts
|
|
37676
38306
|
const startCommand = {
|
|
37677
38307
|
command: "start",
|
|
37678
|
-
describe: "Start a piece of work
|
|
37679
|
-
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")),
|
|
37680
38310
|
handler: () => {}
|
|
37681
38311
|
};
|
|
37682
38312
|
// src/commands/ideas-sync/resolve-ideas-provider/resolve-ideas-provider.ts
|