@gadicc/loom 1.35.3 → 1.37.0
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 +66 -0
- package/THIRD_PARTY_NOTICES.md +12 -9
- package/esm/src/cli/externalSkills.d.ts.map +1 -1
- package/esm/src/cli/externalSkills.js +25 -20
- package/esm/src/cli/mod.d.ts +117 -1
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +1368 -44
- package/esm/src/cli/projectSkills.d.ts +10 -3
- package/esm/src/cli/projectSkills.d.ts.map +1 -1
- package/esm/src/cli/projectSkills.js +173 -49
- package/esm/src/cli/vercelBuildEnv.d.ts +28 -0
- package/esm/src/cli/vercelBuildEnv.d.ts.map +1 -1
- package/esm/src/cli/vercelBuildEnv.js +120 -30
- package/esm/src/next/secrets/mod.d.ts +108 -0
- package/esm/src/next/secrets/mod.d.ts.map +1 -0
- package/esm/src/next/secrets/mod.js +176 -0
- package/esm/src/secrets/encoding.d.ts +32 -0
- package/esm/src/secrets/encoding.d.ts.map +1 -0
- package/esm/src/secrets/encoding.js +87 -0
- package/esm/src/secrets/errors.d.ts +45 -0
- package/esm/src/secrets/errors.d.ts.map +1 -0
- package/esm/src/secrets/errors.js +39 -0
- package/esm/src/secrets/fingerprint.d.ts +43 -0
- package/esm/src/secrets/fingerprint.d.ts.map +1 -0
- package/esm/src/secrets/fingerprint.js +87 -0
- package/esm/src/secrets/frame.d.ts +34 -0
- package/esm/src/secrets/frame.d.ts.map +1 -0
- package/esm/src/secrets/frame.js +86 -0
- package/esm/src/secrets/keyring.d.ts +62 -0
- package/esm/src/secrets/keyring.d.ts.map +1 -0
- package/esm/src/secrets/keyring.js +160 -0
- package/esm/src/secrets/legacy.d.ts +60 -0
- package/esm/src/secrets/legacy.d.ts.map +1 -0
- package/esm/src/secrets/legacy.js +147 -0
- package/esm/src/secrets/maintenance.d.ts +173 -0
- package/esm/src/secrets/maintenance.d.ts.map +1 -0
- package/esm/src/secrets/maintenance.js +315 -0
- package/esm/src/secrets/mod.d.ts +6 -0
- package/esm/src/secrets/mod.d.ts.map +1 -0
- package/esm/src/secrets/mod.js +5 -0
- package/esm/src/secrets/secrets.d.ts +192 -0
- package/esm/src/secrets/secrets.d.ts.map +1 -0
- package/esm/src/secrets/secrets.js +528 -0
- package/package.json +50 -2
- package/script/src/cli/externalSkills.d.ts.map +1 -1
- package/script/src/cli/externalSkills.js +25 -20
- package/script/src/cli/mod.d.ts +117 -1
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +1372 -41
- package/script/src/cli/projectSkills.d.ts +10 -3
- package/script/src/cli/projectSkills.d.ts.map +1 -1
- package/script/src/cli/projectSkills.js +173 -49
- package/script/src/cli/vercelBuildEnv.d.ts +28 -0
- package/script/src/cli/vercelBuildEnv.d.ts.map +1 -1
- package/script/src/cli/vercelBuildEnv.js +121 -30
- package/script/src/next/secrets/mod.d.ts +108 -0
- package/script/src/next/secrets/mod.d.ts.map +1 -0
- package/script/src/next/secrets/mod.js +218 -0
- package/script/src/secrets/encoding.d.ts +32 -0
- package/script/src/secrets/encoding.d.ts.map +1 -0
- package/script/src/secrets/encoding.js +95 -0
- package/script/src/secrets/errors.d.ts +45 -0
- package/script/src/secrets/errors.d.ts.map +1 -0
- package/script/src/secrets/errors.js +45 -0
- package/script/src/secrets/fingerprint.d.ts +43 -0
- package/script/src/secrets/fingerprint.d.ts.map +1 -0
- package/script/src/secrets/fingerprint.js +92 -0
- package/script/src/secrets/frame.d.ts +34 -0
- package/script/src/secrets/frame.d.ts.map +1 -0
- package/script/src/secrets/frame.js +91 -0
- package/script/src/secrets/keyring.d.ts +62 -0
- package/script/src/secrets/keyring.d.ts.map +1 -0
- package/script/src/secrets/keyring.js +202 -0
- package/script/src/secrets/legacy.d.ts +60 -0
- package/script/src/secrets/legacy.d.ts.map +1 -0
- package/script/src/secrets/legacy.js +186 -0
- package/script/src/secrets/maintenance.d.ts +173 -0
- package/script/src/secrets/maintenance.d.ts.map +1 -0
- package/script/src/secrets/maintenance.js +323 -0
- package/script/src/secrets/mod.d.ts +6 -0
- package/script/src/secrets/mod.d.ts.map +1 -0
- package/script/src/secrets/mod.js +24 -0
- package/script/src/secrets/secrets.d.ts +192 -0
- package/script/src/secrets/secrets.d.ts.map +1 -0
- package/script/src/secrets/secrets.js +532 -0
- package/skills/loom/SKILL.md +79 -222
- package/skills/loom/references/dependency-upgrades.md +26 -0
- package/skills/loom/references/local-development.md +157 -0
- package/skills/loom/references/release-safety.md +118 -0
- package/skills/loom/references/release-trusted-sources.md +55 -0
- package/skills/loom/references/tools-and-skills.md +83 -0
- package/skills/loom-api-keys/SKILL.md +1 -1
- package/skills/loom-auth/SKILL.md +7 -60
- package/skills/loom-auth/references/secrets-and-rotation.md +61 -0
- package/skills/loom-db/SKILL.md +4 -79
- package/skills/loom-files/SKILL.md +4 -2
- package/skills/loom-files/references/provider-configuration.md +150 -0
- package/skills/loom-jobs/SKILL.md +9 -8
- package/skills/loom-lingui/SKILL.md +5 -3
- package/skills/loom-secrets/SKILL.md +266 -0
- package/skills/loom-torvalds-review/SKILL.md +9 -6
- package/skills/loom-torvalds-review/references/context-profiles.md +2 -1
- package/skills/upgrade-deps/SKILL.md +15 -7
package/script/src/cli/mod.js
CHANGED
|
@@ -63,12 +63,19 @@ exports.setupGithubMigrationCredential = setupGithubMigrationCredential;
|
|
|
63
63
|
exports.setupGithubVercelRelease = setupGithubVercelRelease;
|
|
64
64
|
exports.initProject = initProject;
|
|
65
65
|
exports.addFeature = addFeature;
|
|
66
|
+
exports.planSecretsKey = planSecretsKey;
|
|
67
|
+
exports.recordedSecretsKey = recordedSecretsKey;
|
|
68
|
+
exports.generateSecretsKey = generateSecretsKey;
|
|
69
|
+
exports.fingerprintSecretsKey = fingerprintSecretsKey;
|
|
70
|
+
exports.activateSecretsKey = activateSecretsKey;
|
|
71
|
+
exports.retireSecretsKey = retireSecretsKey;
|
|
66
72
|
exports.integrateApiKeysJobs = integrateApiKeysJobs;
|
|
67
73
|
exports.configureApiKeyRetention = configureApiKeyRetention;
|
|
68
74
|
exports.addSkills = addSkills;
|
|
69
75
|
exports.checkProject = checkProject;
|
|
70
76
|
exports.checkProjectNetwork = checkProjectNetwork;
|
|
71
77
|
exports.formatPlainNetworkCheckLines = formatPlainNetworkCheckLines;
|
|
78
|
+
exports.resolveOutsideChange = resolveOutsideChange;
|
|
72
79
|
exports.runEnvCommand = runEnvCommand;
|
|
73
80
|
exports.runCli = runCli;
|
|
74
81
|
const node_child_process_1 = require("node:child_process");
|
|
@@ -90,6 +97,10 @@ const managedFiles_js_1 = require("./managedFiles.js");
|
|
|
90
97
|
const legacyManagedOutputs_js_1 = require("./legacyManagedOutputs.js");
|
|
91
98
|
const betterAuth_js_1 = require("../apiKeys/betterAuth.js");
|
|
92
99
|
const retention_js_1 = require("../apiKeys/retention.js");
|
|
100
|
+
const mod_js_1 = require("../next/secrets/mod.js");
|
|
101
|
+
const encoding_js_1 = require("../secrets/encoding.js");
|
|
102
|
+
const fingerprint_js_1 = require("../secrets/fingerprint.js");
|
|
103
|
+
const keyring_js_1 = require("../secrets/keyring.js");
|
|
93
104
|
const projectSkills_js_1 = require("./projectSkills.js");
|
|
94
105
|
const migrationEnv_js_1 = require("./migrationEnv.js");
|
|
95
106
|
const vercelBuildEnv_js_1 = require("./vercelBuildEnv.js");
|
|
@@ -209,6 +220,12 @@ const managedSkills = [
|
|
|
209
220
|
relativePackagePath: "skills/loom-lingui",
|
|
210
221
|
skillName: "loom-lingui",
|
|
211
222
|
},
|
|
223
|
+
{
|
|
224
|
+
featureKey: "secrets",
|
|
225
|
+
label: "loom secrets skill",
|
|
226
|
+
relativePackagePath: "skills/loom-secrets",
|
|
227
|
+
skillName: "loom-secrets",
|
|
228
|
+
},
|
|
212
229
|
];
|
|
213
230
|
const featureDefinitions = [
|
|
214
231
|
{
|
|
@@ -243,6 +260,10 @@ const featureDefinitions = [
|
|
|
243
260
|
key: "pwa",
|
|
244
261
|
description: "Shared Serwist PWA worker, provider lifecycle, update prompts, and build wiring.",
|
|
245
262
|
},
|
|
263
|
+
{
|
|
264
|
+
key: "secrets",
|
|
265
|
+
description: "Reversible secrets at rest with versioned, fingerprint-verified keys.",
|
|
266
|
+
},
|
|
246
267
|
];
|
|
247
268
|
const DB_DEFAULT_DEPENDENCIES = {
|
|
248
269
|
"@neondatabase/serverless": "^1.1.0",
|
|
@@ -2141,6 +2162,31 @@ function mergeApiKeyAuditSchemaConfig(dbConfig, schemaConfig) {
|
|
|
2141
2162
|
hashManagedSchemaText(buildApiKeyAuditSchemaText(merged)),
|
|
2142
2163
|
};
|
|
2143
2164
|
}
|
|
2165
|
+
function getSecretsConfig(framework, featureConfig) {
|
|
2166
|
+
const moduleRoot = framework.srcDir ? "src/" : "";
|
|
2167
|
+
return {
|
|
2168
|
+
modules: {
|
|
2169
|
+
secretsModule: featureConfig?.modules?.secretsModule ??
|
|
2170
|
+
`${moduleRoot}secrets.ts`,
|
|
2171
|
+
locationsModule: featureConfig?.modules?.locationsModule ??
|
|
2172
|
+
`${moduleRoot}secretLocations.ts`,
|
|
2173
|
+
},
|
|
2174
|
+
env: {
|
|
2175
|
+
keyPrefix: featureConfig?.env?.keyPrefix ??
|
|
2176
|
+
keyring_js_1.DEFAULT_SECRETS_KEY_ENV_PREFIX,
|
|
2177
|
+
activeKeyName: featureConfig?.env?.activeKeyName ??
|
|
2178
|
+
keyring_js_1.DEFAULT_SECRETS_ACTIVE_KEY_ENV,
|
|
2179
|
+
},
|
|
2180
|
+
// Recorded by `loom secrets`; passed through unvalidated so `loom check`
|
|
2181
|
+
// can report a hand-edited list instead of this getter hiding it.
|
|
2182
|
+
keys: {
|
|
2183
|
+
production: featureConfig?.keys?.production ?? [],
|
|
2184
|
+
...(featureConfig?.keys?.preview !== undefined
|
|
2185
|
+
? { preview: featureConfig.keys.preview }
|
|
2186
|
+
: {}),
|
|
2187
|
+
},
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2144
2190
|
function getApiKeysConfig(framework, dbConfig, packageJson, featureConfig) {
|
|
2145
2191
|
const appRoot = framework.srcDir ? "src/app" : "app";
|
|
2146
2192
|
const apiKeysRoot = framework.srcDir
|
|
@@ -4585,7 +4631,16 @@ async function checkPnpm11Compatibility(cwd, packageJson, npmrcText) {
|
|
|
4585
4631
|
warnings: major === null || major < 11 ? findings : [],
|
|
4586
4632
|
};
|
|
4587
4633
|
}
|
|
4588
|
-
function getSkillsContext(packageJson, manifest) {
|
|
4634
|
+
async function getSkillsContext(cwd, packageJson, manifest) {
|
|
4635
|
+
const tooling = await (0, projectTooling_js_1.detectProjectTooling)(cwd, manifest?.project?.tooling);
|
|
4636
|
+
const dependencyConfig = tooling.dependencies.config;
|
|
4637
|
+
if (dependencyConfig !== "package.json") {
|
|
4638
|
+
const text = await readTextIfExists((0, node_path_1.join)(cwd, dependencyConfig));
|
|
4639
|
+
if (text === null) {
|
|
4640
|
+
throw new Error(`Missing dependency config: ${dependencyConfig}`);
|
|
4641
|
+
}
|
|
4642
|
+
packageJson = (0, projectTooling_js_1.denoConfigAsPackageJson)((0, projectTooling_js_1.parseJsonc)(text, dependencyConfig));
|
|
4643
|
+
}
|
|
4589
4644
|
return {
|
|
4590
4645
|
activeFeatureKeys: new Set(manifest
|
|
4591
4646
|
? Object.entries(manifest.features)
|
|
@@ -8007,16 +8062,29 @@ async function listVercelEnvironmentNames(cwd, commandRunner, env, vercelCommand
|
|
|
8007
8062
|
}
|
|
8008
8063
|
return result.stdout;
|
|
8009
8064
|
}
|
|
8010
|
-
|
|
8011
|
-
|
|
8065
|
+
/**
|
|
8066
|
+
* What a failed Vercel CLI call said. In an agent session the CLI reports
|
|
8067
|
+
* errors as JSON on stdout. Vercel does not echo a value it was given, but a
|
|
8068
|
+
* long one is masked anyway, in case a later version does.
|
|
8069
|
+
*/
|
|
8070
|
+
function vercelFailureDetail(result, value) {
|
|
8071
|
+
const detail = result.stderr.trim() || result.stdout.trim() ||
|
|
8072
|
+
`exit code ${result.code}`;
|
|
8073
|
+
return value.length >= 16 ? detail.split(value).join("[redacted]") : detail;
|
|
8074
|
+
}
|
|
8075
|
+
async function addVercelEnvValue(cwd, commandRunner, env, vercelCommand, name, value, environment, extraArgs = []) {
|
|
8076
|
+
// The value goes on stdin, never into the arguments, where the process
|
|
8077
|
+
// list and shell history would show it.
|
|
8078
|
+
const result = await commandRunner(vercelCommand, ["env", "add", name, environment, ...extraArgs], { cwd, env, input: `${value}\n`, stdio: "pipe" });
|
|
8012
8079
|
if (result.code !== 0) {
|
|
8013
|
-
throw new Error(`Could not add ${name} to Vercel ${environment}: ${result
|
|
8080
|
+
throw new Error(`Could not add ${name} to Vercel ${environment}: ${vercelFailureDetail(result, value)}`);
|
|
8014
8081
|
}
|
|
8015
8082
|
}
|
|
8016
8083
|
async function updateVercelEnvValue(cwd, commandRunner, env, vercelCommand, name, value, environment) {
|
|
8084
|
+
// No type flag: `env update` keeps the variable's existing type.
|
|
8017
8085
|
const result = await commandRunner(vercelCommand, ["env", "update", name, environment, "--yes"], { cwd, env, input: `${value}\n`, stdio: "pipe" });
|
|
8018
8086
|
if (result.code !== 0) {
|
|
8019
|
-
throw new Error(`Could not update ${name} in Vercel ${environment}: ${result
|
|
8087
|
+
throw new Error(`Could not update ${name} in Vercel ${environment}: ${vercelFailureDetail(result, value)}`);
|
|
8020
8088
|
}
|
|
8021
8089
|
}
|
|
8022
8090
|
async function promptForVercelSecret(cwd, commandRunner, env, vercelCommand, name, environment) {
|
|
@@ -8054,10 +8122,38 @@ function buildVercelFilesEnvListArgs(environment, project) {
|
|
|
8054
8122
|
}
|
|
8055
8123
|
function withoutInheritedVercelProject(env) {
|
|
8056
8124
|
const result = { ...env };
|
|
8057
|
-
|
|
8058
|
-
|
|
8125
|
+
// The Vercel CLI still honours the older NOW_* names too.
|
|
8126
|
+
for (const name of [
|
|
8127
|
+
"VERCEL_ORG_ID",
|
|
8128
|
+
"VERCEL_PROJECT_ID",
|
|
8129
|
+
"NOW_ORG_ID",
|
|
8130
|
+
"NOW_PROJECT_ID",
|
|
8131
|
+
]) {
|
|
8132
|
+
delete result[name];
|
|
8133
|
+
}
|
|
8059
8134
|
return result;
|
|
8060
8135
|
}
|
|
8136
|
+
/**
|
|
8137
|
+
* Which of `names` Vercel stores as Secrets for `environment`, or null when
|
|
8138
|
+
* the JSON listing is unavailable. A Secret reads back empty, so it looks like
|
|
8139
|
+
* drift, but `vercel env update` keeps a variable's type and cannot fix it.
|
|
8140
|
+
*/
|
|
8141
|
+
async function findVercelFilesValuesStoredAsSecrets(cwd, commandRunner, env, vercelCommand, environment, listArgs, names) {
|
|
8142
|
+
const result = await commandRunner(vercelCommand, [...listArgs, "--format", "json"], { cwd, env, stdio: "pipe" });
|
|
8143
|
+
if (result.code !== 0)
|
|
8144
|
+
return null;
|
|
8145
|
+
const variables = parseVercelEnvListing(result.stdout);
|
|
8146
|
+
if (!variables)
|
|
8147
|
+
return null;
|
|
8148
|
+
return names.filter((name) => variables.some((variable) => variable.key === name && variable.secret &&
|
|
8149
|
+
variable.targets.includes(environment)));
|
|
8150
|
+
}
|
|
8151
|
+
function filesSecretTypeProblem(environment, names) {
|
|
8152
|
+
return `Vercel ${environment} stores ${names.join(", ")} as Secrets, so their values cannot be read back, and \`vercel env update\` keeps a Secret a Secret.`;
|
|
8153
|
+
}
|
|
8154
|
+
function filesSecretTypeFix(environment) {
|
|
8155
|
+
return `Remove them from Vercel ${environment}, then run \`loom files r2 setup\` to add them back as readable values.`;
|
|
8156
|
+
}
|
|
8061
8157
|
async function readVercelFilesNonSecretValues(cwd, commandRunner, env, vercelCommand, environment) {
|
|
8062
8158
|
const link = await readVercelProjectLink(cwd);
|
|
8063
8159
|
if (!link.linked || !link.orgId || !link.projectId)
|
|
@@ -8135,13 +8231,16 @@ async function ensureMinioBucket(cwd, commandRunner, env, endpoint, bucket, acce
|
|
|
8135
8231
|
ok: false,
|
|
8136
8232
|
};
|
|
8137
8233
|
}
|
|
8138
|
-
|
|
8234
|
+
/**
|
|
8235
|
+
* Reads one line from the terminal, writing the question to stderr. A secret
|
|
8236
|
+
* is read in raw mode so it is never echoed. Refuses when stdin is not a
|
|
8237
|
+
* terminal, with the caller's explanation of what to do instead.
|
|
8238
|
+
*/
|
|
8239
|
+
async function promptForTerminalValue(question, secret, messages, options = {}) {
|
|
8139
8240
|
if (!node_process_1.default.stdin.isTTY) {
|
|
8140
|
-
throw new Error(
|
|
8141
|
-
? "MinIO admin credentials are required. Run interactively or set MINIO_ROOT_USER and MINIO_ROOT_PASSWORD in the command environment."
|
|
8142
|
-
: "PostgreSQL admin credentials are required. Run interactively or set LOOM_DB_LOCAL_ADMIN_PASSWORD in the command environment.");
|
|
8241
|
+
throw new Error(messages.notInteractive);
|
|
8143
8242
|
}
|
|
8144
|
-
if (!secret) {
|
|
8243
|
+
if (!secret && !options.rawEcho) {
|
|
8145
8244
|
const input = (0, promises_2.createInterface)({
|
|
8146
8245
|
input: node_process_1.default.stdin,
|
|
8147
8246
|
output: node_process_1.default.stderr,
|
|
@@ -8171,13 +8270,17 @@ async function promptForLocalFilesValue(question, secret = false, context = "Min
|
|
|
8171
8270
|
}
|
|
8172
8271
|
if (character === "\u0003") {
|
|
8173
8272
|
stdin.off("data", onData);
|
|
8174
|
-
rejectPromise(new Error(
|
|
8273
|
+
rejectPromise(new Error(messages.cancelled));
|
|
8175
8274
|
return;
|
|
8176
8275
|
}
|
|
8177
8276
|
if (character === "\u007f" || character === "\b") {
|
|
8277
|
+
if (options.rawEcho && value)
|
|
8278
|
+
node_process_1.default.stderr.write("\b \b");
|
|
8178
8279
|
value = value.slice(0, -1);
|
|
8179
8280
|
}
|
|
8180
8281
|
else {
|
|
8282
|
+
if (options.rawEcho)
|
|
8283
|
+
node_process_1.default.stderr.write(character);
|
|
8181
8284
|
value += character;
|
|
8182
8285
|
}
|
|
8183
8286
|
}
|
|
@@ -8190,6 +8293,14 @@ async function promptForLocalFilesValue(question, secret = false, context = "Min
|
|
|
8190
8293
|
stdin.pause();
|
|
8191
8294
|
}
|
|
8192
8295
|
}
|
|
8296
|
+
function promptForLocalFilesValue(question, secret = false, context = "MinIO") {
|
|
8297
|
+
return promptForTerminalValue(question, secret, {
|
|
8298
|
+
cancelled: `${context} setup was cancelled.`,
|
|
8299
|
+
notInteractive: context === "MinIO"
|
|
8300
|
+
? "MinIO admin credentials are required. Run interactively or set MINIO_ROOT_USER and MINIO_ROOT_PASSWORD in the command environment."
|
|
8301
|
+
: "PostgreSQL admin credentials are required. Run interactively or set LOOM_DB_LOCAL_ADMIN_PASSWORD in the command environment.",
|
|
8302
|
+
});
|
|
8303
|
+
}
|
|
8193
8304
|
function minioHostEnv(env, endpoint, accessKey, secretKey) {
|
|
8194
8305
|
const url = new URL(endpoint);
|
|
8195
8306
|
url.username = accessKey;
|
|
@@ -8847,6 +8958,12 @@ async function setupCloudflareR2(cwd, options = {}) {
|
|
|
8847
8958
|
throw new Error(`Could not inspect existing non-secret Files values in Vercel ${environment}.`);
|
|
8848
8959
|
}
|
|
8849
8960
|
const drift = existingNonSecretNames.filter((name) => actualValues[name] !== nonSecretValues[name]);
|
|
8961
|
+
const storedAsSecrets = drift.length
|
|
8962
|
+
? await findVercelFilesValuesStoredAsSecrets(cwd, commandRunner, providerEnv, vercelCli.command, environment, ["env", "ls", environment], drift)
|
|
8963
|
+
: null;
|
|
8964
|
+
if (storedAsSecrets?.length) {
|
|
8965
|
+
throw new Error(`${filesSecretTypeProblem(environment, storedAsSecrets)} ${filesSecretTypeFix(environment)}`);
|
|
8966
|
+
}
|
|
8850
8967
|
if (drift.length && !options.repair) {
|
|
8851
8968
|
throw new Error(`Vercel ${environment} non-secret Files values differ from the declared R2 policy: ${drift.join(", ")}. Review the drift and rerun with --repair; credentials will not be changed.`);
|
|
8852
8969
|
}
|
|
@@ -8856,7 +8973,11 @@ async function setupCloudflareR2(cwd, options = {}) {
|
|
|
8856
8973
|
}
|
|
8857
8974
|
for (const [name, value] of Object.entries(nonSecretValues)) {
|
|
8858
8975
|
if (!hasExactEnvName(listing, name)) {
|
|
8859
|
-
await addVercelEnvValue(cwd, commandRunner, providerEnv, vercelCli.command, name, value, environment
|
|
8976
|
+
await addVercelEnvValue(cwd, commandRunner, providerEnv, vercelCli.command, name, value, environment,
|
|
8977
|
+
// Vercel CLI stores a Production or Preview value read from
|
|
8978
|
+
// stdin as a Secret unless told otherwise, and the env-run probe
|
|
8979
|
+
// and release env policies must be able to read these back.
|
|
8980
|
+
["--no-sensitive", "--yes"]);
|
|
8860
8981
|
listing += `\n${name}`;
|
|
8861
8982
|
}
|
|
8862
8983
|
}
|
|
@@ -8964,6 +9085,9 @@ async function readVercelProjectLink(cwd) {
|
|
|
8964
9085
|
linked: true,
|
|
8965
9086
|
orgId,
|
|
8966
9087
|
projectId,
|
|
9088
|
+
projectName: typeof project.projectName === "string"
|
|
9089
|
+
? project.projectName
|
|
9090
|
+
: null,
|
|
8967
9091
|
relativePath,
|
|
8968
9092
|
};
|
|
8969
9093
|
}
|
|
@@ -9886,6 +10010,23 @@ function checkFilesNetworkFeature(context) {
|
|
|
9886
10010
|
FILES_S3_FORCE_PATH_STYLE: String(provider.forcePathStyle ?? false),
|
|
9887
10011
|
};
|
|
9888
10012
|
const drift = Object.entries(expectedValues).filter(([name, value]) => actualValues[name] !== value).map(([name]) => name);
|
|
10013
|
+
const storedAsSecrets = drift.length
|
|
10014
|
+
? await findVercelFilesValuesStoredAsSecrets(context.cwd, context.commandRunner, withoutInheritedVercelProject(context.env), state.vercelCommand, environment, buildVercelFilesEnvListArgs(environment, state.vercelProject), drift)
|
|
10015
|
+
: null;
|
|
10016
|
+
if (storedAsSecrets?.length) {
|
|
10017
|
+
const otherDrift = drift.filter((name) => !storedAsSecrets.includes(name));
|
|
10018
|
+
return networkCheckResult("issue", `Vercel ${environment} stores non-secret Files values as Secrets: ${storedAsSecrets.join(", ")}.`, {
|
|
10019
|
+
issues: [
|
|
10020
|
+
filesSecretTypeProblem(environment, storedAsSecrets),
|
|
10021
|
+
...(otherDrift.length
|
|
10022
|
+
? [
|
|
10023
|
+
`Vercel ${environment} has incompatible non-secret Files R2 values: ${otherDrift.join(", ")}.`,
|
|
10024
|
+
]
|
|
10025
|
+
: []),
|
|
10026
|
+
],
|
|
10027
|
+
suggestions: [filesSecretTypeFix(environment)],
|
|
10028
|
+
});
|
|
10029
|
+
}
|
|
9889
10030
|
return drift.length
|
|
9890
10031
|
? networkCheckResult("issue", `Vercel ${environment} Files values drift from loom.json: ${drift.join(", ")}.`, {
|
|
9891
10032
|
issues: [
|
|
@@ -10668,6 +10809,216 @@ async function applyAuthFeature(cwd, framework, manifest, activate) {
|
|
|
10668
10809
|
}
|
|
10669
10810
|
return { changedFiles, notes };
|
|
10670
10811
|
}
|
|
10812
|
+
/**
|
|
10813
|
+
* Whether a failed Git command failed because there is no repository, in
|
|
10814
|
+
* which case no file is tracked. The message is matched because Git uses the
|
|
10815
|
+
* same exit status (128) for failures that are not an answer at all.
|
|
10816
|
+
*/
|
|
10817
|
+
function isNotAGitRepository(result) {
|
|
10818
|
+
return result.code !== 0 && /not a git repository/i.test(result.stderr);
|
|
10819
|
+
}
|
|
10820
|
+
function secretsModuleTemplate(config) {
|
|
10821
|
+
return `import { createNextSecrets } from "@gadicc/loom/next/secrets";
|
|
10822
|
+
|
|
10823
|
+
import loomManifest from "${toRelativeImportPath(config.modules.secretsModule, "loom.json")}";
|
|
10824
|
+
|
|
10825
|
+
const config = loomManifest.features.secrets.config;
|
|
10826
|
+
|
|
10827
|
+
// loom.json records the fingerprint of every key a deployed environment is
|
|
10828
|
+
// expected to hold, so a key that differs from the saved copy is refused.
|
|
10829
|
+
export const secrets = createNextSecrets({
|
|
10830
|
+
expectedKeys: config.keys,
|
|
10831
|
+
variables: config.env,
|
|
10832
|
+
});
|
|
10833
|
+
|
|
10834
|
+
// Declare one purpose per kind of secret, beside the code that uses it:
|
|
10835
|
+
//
|
|
10836
|
+
// export const thingSecret = secrets.purpose("area.thing");
|
|
10837
|
+
//
|
|
10838
|
+
// A purpose name and its binding are permanent: a value sealed under them can
|
|
10839
|
+
// never be opened under different ones.
|
|
10840
|
+
`;
|
|
10841
|
+
}
|
|
10842
|
+
function secretLocationsModuleTemplate() {
|
|
10843
|
+
return `import { defineSecretLocations } from "@gadicc/loom/secrets/maintenance";
|
|
10844
|
+
|
|
10845
|
+
// Every column that holds a sealed string must be declared here. The
|
|
10846
|
+
// maintenance operations (report, verify, reseal) only reach declared
|
|
10847
|
+
// locations, so an undeclared column is never re-encrypted and keeps its old
|
|
10848
|
+
// key in use without anyone noticing.
|
|
10849
|
+
export const secretLocations = defineSecretLocations([]);
|
|
10850
|
+
`;
|
|
10851
|
+
}
|
|
10852
|
+
/**
|
|
10853
|
+
* The normalised config laid over what loom.json already holds, so that a
|
|
10854
|
+
* property Loom does not know (under `config` or one of its sections) is
|
|
10855
|
+
* kept instead of being dropped by a rewrite.
|
|
10856
|
+
*/
|
|
10857
|
+
function mergeSecretsConfig(existing, config) {
|
|
10858
|
+
const current = isJsonObject(existing) ? existing : {};
|
|
10859
|
+
const section = (name) => ({
|
|
10860
|
+
...(isJsonObject(current[name]) ? current[name] : {}),
|
|
10861
|
+
...config[name],
|
|
10862
|
+
});
|
|
10863
|
+
return {
|
|
10864
|
+
...current,
|
|
10865
|
+
modules: section("modules"),
|
|
10866
|
+
env: section("env"),
|
|
10867
|
+
keys: section("keys"),
|
|
10868
|
+
};
|
|
10869
|
+
}
|
|
10870
|
+
/**
|
|
10871
|
+
* Gives a new checkout a working development key: writes a random key and the
|
|
10872
|
+
* pointer to gitignored `.env.local` when it holds neither. An existing
|
|
10873
|
+
* variable is never changed, and the key is never returned or reported.
|
|
10874
|
+
*/
|
|
10875
|
+
async function ensureLocalSecretsKey(cwd, config, commandRunner) {
|
|
10876
|
+
const changedFiles = [];
|
|
10877
|
+
const { activeKeyName, keyPrefix } = config.env;
|
|
10878
|
+
const envPath = (0, node_path_1.join)(cwd, ".env.local");
|
|
10879
|
+
const envText = await readTextIfExists(envPath);
|
|
10880
|
+
const existingName = [...readEnvAssignments(envText ?? "").keys()].find((name) => name === activeKeyName || name.startsWith(keyPrefix));
|
|
10881
|
+
if (existingName !== undefined) {
|
|
10882
|
+
return {
|
|
10883
|
+
changedFiles,
|
|
10884
|
+
notes: [
|
|
10885
|
+
`No development secrets key was generated: .env.local already sets ${existingName}, and Loom never changes an existing secrets variable.`,
|
|
10886
|
+
],
|
|
10887
|
+
};
|
|
10888
|
+
}
|
|
10889
|
+
const tracked = await commandRunner("git", [
|
|
10890
|
+
"ls-files",
|
|
10891
|
+
"--error-unmatch",
|
|
10892
|
+
"--",
|
|
10893
|
+
".env.local",
|
|
10894
|
+
], { cwd, stdio: "pipe" });
|
|
10895
|
+
if (tracked.code === 0) {
|
|
10896
|
+
return {
|
|
10897
|
+
changedFiles,
|
|
10898
|
+
notes: [
|
|
10899
|
+
"No development secrets key was written: .env.local is tracked by Git. Remove it from the index, then rerun `loom add secrets`.",
|
|
10900
|
+
],
|
|
10901
|
+
};
|
|
10902
|
+
}
|
|
10903
|
+
// Exit 1 is Git's answer that the file is untracked, and outside a
|
|
10904
|
+
// repository nothing can be tracked. Any other failure is not an answer.
|
|
10905
|
+
if (tracked.code !== 1 && !isNotAGitRepository(tracked)) {
|
|
10906
|
+
return {
|
|
10907
|
+
changedFiles,
|
|
10908
|
+
notes: [
|
|
10909
|
+
"No development secrets key was written: Git could not be asked whether .env.local is tracked. Rerun `loom add secrets` once `git ls-files` works in this project.",
|
|
10910
|
+
],
|
|
10911
|
+
};
|
|
10912
|
+
}
|
|
10913
|
+
let envFileExists = true;
|
|
10914
|
+
try {
|
|
10915
|
+
if ((await (0, promises_1.lstat)(envPath)).isSymbolicLink()) {
|
|
10916
|
+
return {
|
|
10917
|
+
changedFiles,
|
|
10918
|
+
notes: [
|
|
10919
|
+
"No development secrets key was written: .env.local is a symlink, and Loom will not write a key through it.",
|
|
10920
|
+
],
|
|
10921
|
+
};
|
|
10922
|
+
}
|
|
10923
|
+
}
|
|
10924
|
+
catch (error) {
|
|
10925
|
+
if (!isNodeErrorCode(error, "ENOENT"))
|
|
10926
|
+
throw error;
|
|
10927
|
+
envFileExists = false;
|
|
10928
|
+
}
|
|
10929
|
+
const keyName = `${keyPrefix}1`;
|
|
10930
|
+
const merged = mergeEnvValues(envText, {
|
|
10931
|
+
[keyName]: (0, encoding_js_1.toBase64Url)(globalThis.crypto.getRandomValues(new Uint8Array(keyring_js_1.SECRETS_KEY_BYTES))),
|
|
10932
|
+
[activeKeyName]: "1",
|
|
10933
|
+
// Lets a production build run locally (`next start`): without it the
|
|
10934
|
+
// wrapper cannot tell this machine from an unidentified production host
|
|
10935
|
+
// once fingerprints are recorded, and refuses.
|
|
10936
|
+
[mod_js_1.SECRETS_ENVIRONMENT_ENV]: "development",
|
|
10937
|
+
});
|
|
10938
|
+
// Ignored before the key exists on disk, so it is never an untracked file
|
|
10939
|
+
// that a broad `git add` would pick up. Git is asked first, because a rule
|
|
10940
|
+
// such as `.env*` already covers it; when Git cannot answer, the rule is
|
|
10941
|
+
// appended unless it is already the last one.
|
|
10942
|
+
const ignored = await commandRunner("git", [
|
|
10943
|
+
"check-ignore",
|
|
10944
|
+
"-q",
|
|
10945
|
+
"--",
|
|
10946
|
+
".env.local",
|
|
10947
|
+
], { cwd, stdio: "pipe" });
|
|
10948
|
+
if (ignored.code !== 0) {
|
|
10949
|
+
const gitignorePath = (0, node_path_1.join)(cwd, ".gitignore");
|
|
10950
|
+
const gitignore = await readTextIfExists(gitignorePath) ?? "";
|
|
10951
|
+
const lastIgnoreRule = normalizeText(gitignore).split("\n")
|
|
10952
|
+
.map((line) => line.trim()).filter(Boolean).at(-1);
|
|
10953
|
+
if (lastIgnoreRule !== ".env.local" && lastIgnoreRule !== "/.env.local") {
|
|
10954
|
+
if (await writeTextIfChanged(gitignorePath, `${gitignore && !gitignore.endsWith("\n")
|
|
10955
|
+
? `${gitignore}\n`
|
|
10956
|
+
: gitignore}.env.local\n`))
|
|
10957
|
+
changedFiles.push(".gitignore");
|
|
10958
|
+
}
|
|
10959
|
+
}
|
|
10960
|
+
// An existing file keeps its mode when it is rewritten, so it is made
|
|
10961
|
+
// owner-only before the key is in it, not after.
|
|
10962
|
+
if (envFileExists)
|
|
10963
|
+
await (0, promises_1.chmod)(envPath, 0o600);
|
|
10964
|
+
await (0, promises_1.writeFile)(envPath, merged.text, { mode: 0o600 });
|
|
10965
|
+
await (0, promises_1.chmod)(envPath, 0o600);
|
|
10966
|
+
changedFiles.push(".env.local");
|
|
10967
|
+
return {
|
|
10968
|
+
changedFiles,
|
|
10969
|
+
notes: [
|
|
10970
|
+
`Wrote a development secrets key to .env.local (${merged.changedNames.join(", ")}). It is for this machine only and was not printed.${merged.conflicts.length
|
|
10971
|
+
? ` Left unchanged: ${merged.conflicts.join(", ")}.`
|
|
10972
|
+
: ""}`,
|
|
10973
|
+
],
|
|
10974
|
+
};
|
|
10975
|
+
}
|
|
10976
|
+
async function applySecretsFeature(cwd, framework, manifest, activate, options = {}) {
|
|
10977
|
+
const changedFiles = [];
|
|
10978
|
+
const notes = [];
|
|
10979
|
+
const currentFeature = manifest.features.secrets;
|
|
10980
|
+
if (!activate && currentFeature?.status !== "active") {
|
|
10981
|
+
return { changedFiles, notes };
|
|
10982
|
+
}
|
|
10983
|
+
const config = getSecretsConfig(framework, currentFeature?.config);
|
|
10984
|
+
const feature = currentFeature
|
|
10985
|
+
? structuredClone(currentFeature)
|
|
10986
|
+
: { status: "planned" };
|
|
10987
|
+
if (activate && feature.status !== "active") {
|
|
10988
|
+
feature.status = "active";
|
|
10989
|
+
feature.activatedOn ??= todayIso();
|
|
10990
|
+
}
|
|
10991
|
+
const scaffolds = [
|
|
10992
|
+
[config.modules.secretsModule, secretsModuleTemplate(config), "module"],
|
|
10993
|
+
[
|
|
10994
|
+
config.modules.locationsModule,
|
|
10995
|
+
secretLocationsModuleTemplate(),
|
|
10996
|
+
"locations module",
|
|
10997
|
+
],
|
|
10998
|
+
];
|
|
10999
|
+
for (const [relativePath, text, label] of scaffolds) {
|
|
11000
|
+
const scaffoldState = await scaffoldTextFile((0, node_path_1.join)(cwd, relativePath), text);
|
|
11001
|
+
if (scaffoldState === "created") {
|
|
11002
|
+
changedFiles.push(relativePath);
|
|
11003
|
+
}
|
|
11004
|
+
else if (activate && scaffoldState === "preserved") {
|
|
11005
|
+
notes.push(`Preserved existing secrets ${label}: ${relativePath}`);
|
|
11006
|
+
}
|
|
11007
|
+
}
|
|
11008
|
+
// Only an explicit `loom add secrets` may create a key; `loom init` reruns
|
|
11009
|
+
// this hook for every active feature and must never write one.
|
|
11010
|
+
if (activate) {
|
|
11011
|
+
const localKey = await ensureLocalSecretsKey(cwd, config, options.commandRunner ?? defaultCommandRunner);
|
|
11012
|
+
changedFiles.push(...localKey.changedFiles);
|
|
11013
|
+
notes.push(...localKey.notes);
|
|
11014
|
+
if (!Array.isArray(config.keys.production) || !config.keys.production.length) {
|
|
11015
|
+
notes.push("No production key is recorded yet. Before the first production deploy, an operator runs `loom secrets keygen` in their own terminal; an agent must not run it. On a linked Vercel project it offers to add the key and pointer there.");
|
|
11016
|
+
}
|
|
11017
|
+
}
|
|
11018
|
+
feature.config = mergeSecretsConfig(currentFeature?.config, config);
|
|
11019
|
+
manifest.features.secrets = feature;
|
|
11020
|
+
return { changedFiles, notes };
|
|
11021
|
+
}
|
|
10671
11022
|
function linguiCliCommand(tooling) {
|
|
10672
11023
|
switch (tooling.dependencies.manager) {
|
|
10673
11024
|
case "deno":
|
|
@@ -13408,6 +13759,165 @@ async function checkPwaFeature(cwd, framework, manifest) {
|
|
|
13408
13759
|
warnings,
|
|
13409
13760
|
};
|
|
13410
13761
|
}
|
|
13762
|
+
const VERCEL_PRODUCTION_ENV_POLICY_PATH = ".github/vercel-production-env.json";
|
|
13763
|
+
/**
|
|
13764
|
+
* Escapes text for use as a literal in a regular expression, in a form both
|
|
13765
|
+
* JavaScript and POSIX extended syntax (`git grep -E`) read the same way.
|
|
13766
|
+
*/
|
|
13767
|
+
function escapeExtendedRegex(text) {
|
|
13768
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13769
|
+
}
|
|
13770
|
+
async function checkSecretsFeature(cwd, framework, manifest, options) {
|
|
13771
|
+
const issues = [];
|
|
13772
|
+
const warnings = [];
|
|
13773
|
+
const suggestions = new Set();
|
|
13774
|
+
const feature = manifest.features.secrets;
|
|
13775
|
+
if (!feature || feature.status !== "active") {
|
|
13776
|
+
return { issues, suggestions: [], warnings };
|
|
13777
|
+
}
|
|
13778
|
+
const releaseBlocking = (message) => {
|
|
13779
|
+
if (options.production)
|
|
13780
|
+
issues.push(message);
|
|
13781
|
+
else
|
|
13782
|
+
warnings.push(message);
|
|
13783
|
+
};
|
|
13784
|
+
const config = getSecretsConfig(framework, feature.config);
|
|
13785
|
+
const { activeKeyName, keyPrefix } = config.env;
|
|
13786
|
+
const moduleChecks = [
|
|
13787
|
+
[
|
|
13788
|
+
config.modules.secretsModule,
|
|
13789
|
+
"Secrets module",
|
|
13790
|
+
// A Next.js app must use the wrapper: the core entry point has no
|
|
13791
|
+
// build-phase refusal and no environment-selected key list.
|
|
13792
|
+
framework.kind === "nextjs"
|
|
13793
|
+
? /["']@gadicc\/loom\/next\/secrets["']/
|
|
13794
|
+
: /["']@gadicc\/loom\/(?:next\/)?secrets["']/,
|
|
13795
|
+
"is not wired to @gadicc/loom/next/secrets",
|
|
13796
|
+
],
|
|
13797
|
+
[
|
|
13798
|
+
config.modules.locationsModule,
|
|
13799
|
+
"Secret locations module",
|
|
13800
|
+
/\bdefineSecretLocations\b/,
|
|
13801
|
+
"does not declare its locations with defineSecretLocations",
|
|
13802
|
+
],
|
|
13803
|
+
];
|
|
13804
|
+
for (const [relativePath, label, pattern, problem] of moduleChecks) {
|
|
13805
|
+
const text = await readTextIfExists((0, node_path_1.join)(cwd, relativePath));
|
|
13806
|
+
if (text === null) {
|
|
13807
|
+
issues.push(`${label} is missing: ${relativePath}`);
|
|
13808
|
+
suggestions.add("Run `loom add secrets`.");
|
|
13809
|
+
}
|
|
13810
|
+
else if (!pattern.test(text)) {
|
|
13811
|
+
issues.push(`${label} ${problem}: ${relativePath}`);
|
|
13812
|
+
suggestions.add("Restore the Loom secrets wiring in the app-local module, or point features.secrets.config.modules in loom.json at the module that has it.");
|
|
13813
|
+
}
|
|
13814
|
+
}
|
|
13815
|
+
for (const environment of ["production", "preview"]) {
|
|
13816
|
+
const recorded = config.keys[environment];
|
|
13817
|
+
if (recorded === undefined)
|
|
13818
|
+
continue;
|
|
13819
|
+
if (Array.isArray(recorded) && recorded.length === 0)
|
|
13820
|
+
continue;
|
|
13821
|
+
try {
|
|
13822
|
+
(0, fingerprint_js_1.parseExpectedSecretKeys)(recorded);
|
|
13823
|
+
}
|
|
13824
|
+
catch (error) {
|
|
13825
|
+
issues.push(`Secrets ${environment} key list in loom.json is invalid: ${error.message}`);
|
|
13826
|
+
suggestions.add("Correct features.secrets.config.keys in loom.json; `loom secrets keygen`, `activate` and `retire` keep it valid.");
|
|
13827
|
+
}
|
|
13828
|
+
}
|
|
13829
|
+
// Every tracked file is searched, not only root `.env*` files: a key is as
|
|
13830
|
+
// exposed in `deploy/.env.production` or a compose file. The pattern finds
|
|
13831
|
+
// candidates; only a value that decodes as a key is reported, so an
|
|
13832
|
+
// example file's placeholder is not. The pattern ends at the value's end,
|
|
13833
|
+
// so the first 43 characters of a longer value are not taken for a key.
|
|
13834
|
+
const keyAssignment = `${escapeExtendedRegex(keyPrefix)}[1-9][0-9]{0,8}["']?[[:space:]]*[=:][[:space:]]*["']?[A-Za-z0-9+/_-]{43}=?([^A-Za-z0-9+/_=-]|$)`;
|
|
13835
|
+
const gitResult = await (options.commandRunner ?? defaultCommandRunner)("git", ["grep", "-I", "--null", "-o", "-E", "-e", keyAssignment], { cwd, stdio: "pipe" });
|
|
13836
|
+
if (gitResult.code === 0) {
|
|
13837
|
+
const reported = new Set();
|
|
13838
|
+
for (const line of gitResult.stdout.split(/\r?\n/)) {
|
|
13839
|
+
const separator = line.indexOf("\0");
|
|
13840
|
+
if (separator < 0)
|
|
13841
|
+
continue;
|
|
13842
|
+
const relativePath = line.slice(0, separator);
|
|
13843
|
+
const match = line.slice(separator + 1).match(/^(.*?)["']?\s*[=:]\s*["']?([A-Za-z0-9+/_-]{43}=?)[^A-Za-z0-9+/_=-]?$/);
|
|
13844
|
+
if (!match)
|
|
13845
|
+
continue;
|
|
13846
|
+
const [, name, candidate] = match;
|
|
13847
|
+
try {
|
|
13848
|
+
(0, keyring_js_1.decodeSecretKey)(candidate, name);
|
|
13849
|
+
}
|
|
13850
|
+
catch {
|
|
13851
|
+
continue;
|
|
13852
|
+
}
|
|
13853
|
+
// Names the file and the variable only; the value must not reach a log.
|
|
13854
|
+
const issue = `A secrets key value is committed in a git-tracked file: ${relativePath} (${name})`;
|
|
13855
|
+
if (reported.has(issue))
|
|
13856
|
+
continue;
|
|
13857
|
+
reported.add(issue);
|
|
13858
|
+
issues.push(issue);
|
|
13859
|
+
suggestions.add("Remove the value from the tracked file and treat that key as exposed: generate a replacement with `loom secrets keygen` and rotate to it.");
|
|
13860
|
+
}
|
|
13861
|
+
}
|
|
13862
|
+
else if (gitResult.code !== 1 && !isNotAGitRepository(gitResult)) {
|
|
13863
|
+
// Exit 1 means no match and, outside a repository, nothing is tracked.
|
|
13864
|
+
// Anything else means the search did not happen, which is not "clean".
|
|
13865
|
+
releaseBlocking("Git-tracked files could not be checked for a committed secrets key: `git grep` failed.");
|
|
13866
|
+
suggestions.add("Make sure Git is installed and `git grep` works in this project, then rerun `loom check`.");
|
|
13867
|
+
}
|
|
13868
|
+
if (Array.isArray(config.keys.production) && config.keys.production.length === 0) {
|
|
13869
|
+
releaseBlocking("No production secrets key is recorded in loom.json, so production would run with unverified keys.");
|
|
13870
|
+
suggestions.add("Have an operator run `loom secrets keygen` in their own terminal, then commit the recorded fingerprint. On a linked Vercel project it offers to add the key there too.");
|
|
13871
|
+
}
|
|
13872
|
+
const policyText = await readTextIfExists((0, node_path_1.join)(cwd, VERCEL_PRODUCTION_ENV_POLICY_PATH));
|
|
13873
|
+
if (policyText !== null) {
|
|
13874
|
+
let covered = false;
|
|
13875
|
+
// True until the policy has been read, so that an unreadable policy is
|
|
13876
|
+
// reported once and not also as a missing pointer.
|
|
13877
|
+
let pointerRequired = true;
|
|
13878
|
+
let problem = `has no requirement that covers the secrets keys (${keyPrefix}<n>) as Production-only Sensitive variables`;
|
|
13879
|
+
try {
|
|
13880
|
+
const requirements = (0, vercelBuildEnv_js_1.parseVercelBuildEnvironmentPolicy)(parseJson(policyText, VERCEL_PRODUCTION_ENV_POLICY_PATH));
|
|
13881
|
+
pointerRequired = requirements.some((requirement) => requirement.keys.includes(activeKeyName));
|
|
13882
|
+
covered = requirements.some((requirement) => requirement.keyPattern !== undefined &&
|
|
13883
|
+
// Several versions, so a pattern written for one key (`..._1$`) or
|
|
13884
|
+
// for a single digit does not pass for the keys that follow it.
|
|
13885
|
+
[1, 2, 10].every((version) => requirement.matches(`${keyPrefix}${version}`)) && requirement.sensitive && requirement.productionOnly);
|
|
13886
|
+
}
|
|
13887
|
+
catch (error) {
|
|
13888
|
+
problem = `could not be read: ${error.message}`;
|
|
13889
|
+
}
|
|
13890
|
+
if (!covered) {
|
|
13891
|
+
releaseBlocking(`Vercel release policy ${VERCEL_PRODUCTION_ENV_POLICY_PATH} ${problem}.`);
|
|
13892
|
+
}
|
|
13893
|
+
if (!pointerRequired) {
|
|
13894
|
+
releaseBlocking(`Vercel release policy ${VERCEL_PRODUCTION_ENV_POLICY_PATH} has no requirement whose keys include the secrets active key pointer (${activeKeyName}): a deployment without the pointer cannot seal.`);
|
|
13895
|
+
}
|
|
13896
|
+
if (!covered || !pointerRequired) {
|
|
13897
|
+
// Serialised as JSON so that a name with a character that needs
|
|
13898
|
+
// escaping, in the pattern or in the string, can be pasted as it is.
|
|
13899
|
+
// Both are shown whichever is missing: the policy needs the pair.
|
|
13900
|
+
const suggestedKeys = JSON.stringify({
|
|
13901
|
+
name: "secrets keys",
|
|
13902
|
+
keyPattern: `^${escapeExtendedRegex(keyPrefix)}[1-9][0-9]*$`,
|
|
13903
|
+
sensitive: true,
|
|
13904
|
+
productionOnly: true,
|
|
13905
|
+
placeholder: { kind: "secret" },
|
|
13906
|
+
});
|
|
13907
|
+
// The pointer is a readable variable, so it is not marked sensitive.
|
|
13908
|
+
const suggestedPointer = JSON.stringify({
|
|
13909
|
+
name: "secrets active key pointer",
|
|
13910
|
+
keys: [activeKeyName],
|
|
13911
|
+
});
|
|
13912
|
+
suggestions.add(`Add requirements such as ${suggestedKeys} and ${suggestedPointer} to ${VERCEL_PRODUCTION_ENV_POLICY_PATH}.`);
|
|
13913
|
+
}
|
|
13914
|
+
}
|
|
13915
|
+
return {
|
|
13916
|
+
issues,
|
|
13917
|
+
suggestions: [...suggestions],
|
|
13918
|
+
warnings,
|
|
13919
|
+
};
|
|
13920
|
+
}
|
|
13411
13921
|
const featureHooks = {
|
|
13412
13922
|
"api-keys": {
|
|
13413
13923
|
apply: applyApiKeysFeature,
|
|
@@ -13443,6 +13953,10 @@ const featureHooks = {
|
|
|
13443
13953
|
apply: applyPwaFeature,
|
|
13444
13954
|
check: checkPwaFeature,
|
|
13445
13955
|
},
|
|
13956
|
+
secrets: {
|
|
13957
|
+
apply: applySecretsFeature,
|
|
13958
|
+
check: checkSecretsFeature,
|
|
13959
|
+
},
|
|
13446
13960
|
};
|
|
13447
13961
|
async function ensureActiveFeatureScaffolds(cwd, framework, manifest) {
|
|
13448
13962
|
const changedFiles = [];
|
|
@@ -13544,13 +14058,13 @@ async function initProject(cwd, versionRange) {
|
|
|
13544
14058
|
.packageJson,
|
|
13545
14059
|
};
|
|
13546
14060
|
}
|
|
13547
|
-
async function addFeature(cwd, featureKey, versionRange) {
|
|
14061
|
+
async function addFeature(cwd, featureKey, versionRange, options = {}) {
|
|
13548
14062
|
const hook = featureHooks[featureKey];
|
|
13549
14063
|
if (!hook) {
|
|
13550
14064
|
throw new Error(`Unknown feature: ${featureKey}`);
|
|
13551
14065
|
}
|
|
13552
14066
|
const base = await initProject(cwd, versionRange);
|
|
13553
|
-
const result = await hook.apply(cwd, base.framework, base.manifest, true);
|
|
14067
|
+
const result = await hook.apply(cwd, base.framework, base.manifest, true, options);
|
|
13554
14068
|
const skillSync = await ensureManagedSkillLinks(cwd, base.manifest);
|
|
13555
14069
|
const changedFiles = [
|
|
13556
14070
|
...base.changedFiles,
|
|
@@ -13566,6 +14080,218 @@ async function addFeature(cwd, featureKey, versionRange) {
|
|
|
13566
14080
|
notes: [...new Set(notes)],
|
|
13567
14081
|
};
|
|
13568
14082
|
}
|
|
14083
|
+
async function readActiveSecretsFeature(cwd) {
|
|
14084
|
+
const manifest = await readManifestIfExists(cwd);
|
|
14085
|
+
if (!manifest) {
|
|
14086
|
+
throw new Error("Missing loom.json. Run `loom add secrets` first.");
|
|
14087
|
+
}
|
|
14088
|
+
const feature = manifest.features.secrets;
|
|
14089
|
+
if (feature?.status !== "active") {
|
|
14090
|
+
throw new Error("The secrets feature is not active. Run `loom add secrets` first.");
|
|
14091
|
+
}
|
|
14092
|
+
const framework = manifest.project?.framework ??
|
|
14093
|
+
await detectFramework(cwd, (await readProjectPackageJson(cwd)).packageJson);
|
|
14094
|
+
const config = getSecretsConfig(framework, feature.config);
|
|
14095
|
+
return { config, feature, manifest };
|
|
14096
|
+
}
|
|
14097
|
+
function recordedSecretKeys(config, environment) {
|
|
14098
|
+
const recorded = config.keys[environment] ?? [];
|
|
14099
|
+
if (!Array.isArray(recorded)) {
|
|
14100
|
+
throw new Error(`features.secrets.config.keys.${environment} in loom.json must be a list.`);
|
|
14101
|
+
}
|
|
14102
|
+
return recorded;
|
|
14103
|
+
}
|
|
14104
|
+
/** Validates a changed key list, then records it in loom.json. */
|
|
14105
|
+
function validateSecretKeys(environment, keys) {
|
|
14106
|
+
if (!keys.length)
|
|
14107
|
+
return;
|
|
14108
|
+
try {
|
|
14109
|
+
(0, fingerprint_js_1.parseExpectedSecretKeys)(keys);
|
|
14110
|
+
}
|
|
14111
|
+
catch (error) {
|
|
14112
|
+
throw new Error(`The ${environment} key list in loom.json would be invalid: ${error.message}`);
|
|
14113
|
+
}
|
|
14114
|
+
}
|
|
14115
|
+
async function writeSecretKeys(cwd, loaded, environment, keys) {
|
|
14116
|
+
validateSecretKeys(environment, keys);
|
|
14117
|
+
// Replaces this one list and nothing else: any other property a user keeps
|
|
14118
|
+
// under `config` or `config.keys` is theirs, and stays.
|
|
14119
|
+
const existing = isJsonObject(loaded.feature.config)
|
|
14120
|
+
? loaded.feature.config
|
|
14121
|
+
: {};
|
|
14122
|
+
loaded.feature.config = {
|
|
14123
|
+
...existing,
|
|
14124
|
+
keys: {
|
|
14125
|
+
...(isJsonObject(existing.keys) ? existing.keys : {}),
|
|
14126
|
+
[environment]: keys,
|
|
14127
|
+
},
|
|
14128
|
+
};
|
|
14129
|
+
loaded.manifest.features.secrets = loaded.feature;
|
|
14130
|
+
return await writeManifestIfChanged(cwd, loaded.manifest)
|
|
14131
|
+
? ["loom.json"]
|
|
14132
|
+
: [];
|
|
14133
|
+
}
|
|
14134
|
+
function nextSecretsKey(config, environment) {
|
|
14135
|
+
const current = recordedSecretKeys(config, environment);
|
|
14136
|
+
const id = current.reduce((highest, key) => (0, keyring_js_1.isSecretKeyId)(key?.id) ? Math.max(highest, key.id) : highest, 0) + 1;
|
|
14137
|
+
const state = current.some((key) => key?.state === "active")
|
|
14138
|
+
? "decrypt-only"
|
|
14139
|
+
: "active";
|
|
14140
|
+
return { current, id, state };
|
|
14141
|
+
}
|
|
14142
|
+
/**
|
|
14143
|
+
* The version, state and variable names `generateSecretsKey` would use next,
|
|
14144
|
+
* without generating or recording anything.
|
|
14145
|
+
*/
|
|
14146
|
+
async function planSecretsKey(cwd, environment = "production") {
|
|
14147
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14148
|
+
const { id, state } = nextSecretsKey(loaded.config, environment);
|
|
14149
|
+
return {
|
|
14150
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14151
|
+
id,
|
|
14152
|
+
state,
|
|
14153
|
+
variableName: `${loaded.config.env.keyPrefix}${id}`,
|
|
14154
|
+
};
|
|
14155
|
+
}
|
|
14156
|
+
/**
|
|
14157
|
+
* A recorded key that is not retired, with its variable names, for putting it
|
|
14158
|
+
* on a deployment platform. Refuses a version that is not listed or retired.
|
|
14159
|
+
*/
|
|
14160
|
+
async function recordedSecretsKey(cwd, id, environment = "production") {
|
|
14161
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14162
|
+
const key = recordedSecretKeys(loaded.config, environment).find((entry) => entry?.id === id);
|
|
14163
|
+
if (!key) {
|
|
14164
|
+
throw new Error(`Key version ${id} is not listed for ${environment} in loom.json.`);
|
|
14165
|
+
}
|
|
14166
|
+
if (key.state === "retired") {
|
|
14167
|
+
throw new Error(`Key version ${id} is retired for ${environment}.`);
|
|
14168
|
+
}
|
|
14169
|
+
return {
|
|
14170
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14171
|
+
fingerprint: key.fingerprint,
|
|
14172
|
+
id,
|
|
14173
|
+
state: key.state,
|
|
14174
|
+
variableName: `${loaded.config.env.keyPrefix}${id}`,
|
|
14175
|
+
};
|
|
14176
|
+
}
|
|
14177
|
+
/**
|
|
14178
|
+
* Generates a key for a deployed environment and records its fingerprint in
|
|
14179
|
+
* loom.json: `active` when the environment has no active key, otherwise
|
|
14180
|
+
* `decrypt-only`. The version is one above the highest ever listed, so a
|
|
14181
|
+
* retired version is never reused. It always records: an unrecorded key
|
|
14182
|
+
* would let the next run give the same version to a different key.
|
|
14183
|
+
*
|
|
14184
|
+
* The returned `assignment` contains the key. A caller shows it once, to a
|
|
14185
|
+
* person at a terminal, and never logs or stores it.
|
|
14186
|
+
*/
|
|
14187
|
+
async function generateSecretsKey(cwd, options = {}) {
|
|
14188
|
+
const environment = options.environment ?? "production";
|
|
14189
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14190
|
+
const { current, id, state } = nextSecretsKey(loaded.config, environment);
|
|
14191
|
+
const key = globalThis.crypto.getRandomValues(new Uint8Array(keyring_js_1.SECRETS_KEY_BYTES));
|
|
14192
|
+
const fingerprint = await (0, fingerprint_js_1.secretKeyFingerprint)(key);
|
|
14193
|
+
const changedFiles = await writeSecretKeys(cwd, loaded, environment, [
|
|
14194
|
+
...current,
|
|
14195
|
+
{ id, fingerprint, state },
|
|
14196
|
+
]);
|
|
14197
|
+
const variableName = `${loaded.config.env.keyPrefix}${id}`;
|
|
14198
|
+
return {
|
|
14199
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14200
|
+
assignment: `${variableName}=${(0, encoding_js_1.toBase64Url)(key)}`,
|
|
14201
|
+
changedFiles,
|
|
14202
|
+
environment,
|
|
14203
|
+
fingerprint,
|
|
14204
|
+
id,
|
|
14205
|
+
state,
|
|
14206
|
+
variableName,
|
|
14207
|
+
};
|
|
14208
|
+
}
|
|
14209
|
+
/**
|
|
14210
|
+
* The public fingerprint of a key as an operator typed or pasted it, for
|
|
14211
|
+
* comparing a saved copy with what loom.json records. Errors never include
|
|
14212
|
+
* the key.
|
|
14213
|
+
*/
|
|
14214
|
+
async function fingerprintSecretsKey(value) {
|
|
14215
|
+
return await (0, fingerprint_js_1.secretKeyFingerprint)((0, keyring_js_1.decodeSecretKey)(value, "The entered key"));
|
|
14216
|
+
}
|
|
14217
|
+
/**
|
|
14218
|
+
* Marks a recorded key `active` in loom.json and the previously active key
|
|
14219
|
+
* `decrypt-only`. Refuses a version that is not listed or is retired.
|
|
14220
|
+
*
|
|
14221
|
+
* `beforeWrite` runs once those checks pass and before loom.json changes, so
|
|
14222
|
+
* the platform's pointer can be moved first; if it throws, loom.json is left
|
|
14223
|
+
* as it was.
|
|
14224
|
+
*/
|
|
14225
|
+
async function activateSecretsKey(cwd, id, environment = "production", options = {}) {
|
|
14226
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14227
|
+
const current = recordedSecretKeys(loaded.config, environment);
|
|
14228
|
+
const target = current.find((key) => key?.id === id);
|
|
14229
|
+
if (!target) {
|
|
14230
|
+
throw new Error(`Key version ${id} is not listed for ${environment} in loom.json.`);
|
|
14231
|
+
}
|
|
14232
|
+
if (target.state === "retired") {
|
|
14233
|
+
throw new Error(`Key version ${id} is retired and cannot be activated. Generate a new key with \`loom secrets keygen\`.`);
|
|
14234
|
+
}
|
|
14235
|
+
const next = current.map((key) => key?.id === id
|
|
14236
|
+
? { ...key, state: "active" }
|
|
14237
|
+
: key?.state === "active"
|
|
14238
|
+
? { ...key, state: "decrypt-only" }
|
|
14239
|
+
: key);
|
|
14240
|
+
// Checked before the hook, which may change a deployment platform: that
|
|
14241
|
+
// must not happen for a list that could not then be written.
|
|
14242
|
+
validateSecretKeys(environment, next);
|
|
14243
|
+
if (!options.beforeWrite) {
|
|
14244
|
+
return {
|
|
14245
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14246
|
+
changedFiles: await writeSecretKeys(cwd, loaded, environment, next),
|
|
14247
|
+
environment,
|
|
14248
|
+
id,
|
|
14249
|
+
};
|
|
14250
|
+
}
|
|
14251
|
+
const changedOutside = await options.beforeWrite({
|
|
14252
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14253
|
+
id,
|
|
14254
|
+
variableName: `${loaded.config.env.keyPrefix}${id}`,
|
|
14255
|
+
});
|
|
14256
|
+
let changedFiles;
|
|
14257
|
+
try {
|
|
14258
|
+
changedFiles = await writeSecretKeys(cwd, loaded, environment, next);
|
|
14259
|
+
}
|
|
14260
|
+
catch (error) {
|
|
14261
|
+
if (!changedOutside)
|
|
14262
|
+
throw error;
|
|
14263
|
+
throw new Error(`${error.message} The platform was already changed for key version ${id}; fix loom.json and run this again, or put the platform back.`);
|
|
14264
|
+
}
|
|
14265
|
+
return {
|
|
14266
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14267
|
+
changedFiles,
|
|
14268
|
+
environment,
|
|
14269
|
+
id,
|
|
14270
|
+
};
|
|
14271
|
+
}
|
|
14272
|
+
/**
|
|
14273
|
+
* Marks a recorded key `retired` in loom.json. Refuses the active key and a
|
|
14274
|
+
* version that is not listed. Whether anything still needs the key is the
|
|
14275
|
+
* operator's decision; nothing here can check stored data or backups.
|
|
14276
|
+
*/
|
|
14277
|
+
async function retireSecretsKey(cwd, id, environment = "production") {
|
|
14278
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14279
|
+
const current = recordedSecretKeys(loaded.config, environment);
|
|
14280
|
+
const target = current.find((key) => key?.id === id);
|
|
14281
|
+
if (!target) {
|
|
14282
|
+
throw new Error(`Key version ${id} is not listed for ${environment} in loom.json.`);
|
|
14283
|
+
}
|
|
14284
|
+
if (target.state === "active") {
|
|
14285
|
+
throw new Error(`Key version ${id} is the active key and cannot be retired. Activate another key with \`loom secrets activate <id>\` first.`);
|
|
14286
|
+
}
|
|
14287
|
+
const changedFiles = await writeSecretKeys(cwd, loaded, environment, current.map((key) => key?.id === id ? { ...key, state: "retired" } : key));
|
|
14288
|
+
return {
|
|
14289
|
+
changedFiles,
|
|
14290
|
+
environment,
|
|
14291
|
+
id,
|
|
14292
|
+
variableName: `${loaded.config.env.keyPrefix}${id}`,
|
|
14293
|
+
};
|
|
14294
|
+
}
|
|
13569
14295
|
function jobsRouteHasAuthorizationCallback(text) {
|
|
13570
14296
|
if (!text)
|
|
13571
14297
|
return false;
|
|
@@ -13668,7 +14394,7 @@ async function configureApiKeyRetention(cwd, enabled, overrides = {}) {
|
|
|
13668
14394
|
}
|
|
13669
14395
|
async function addSkills(cwd, versionRange, env = node_process_1.default.env, options = {}) {
|
|
13670
14396
|
const base = await initProject(cwd, versionRange);
|
|
13671
|
-
const skillSync = await (0, projectSkills_js_1.syncExternalProjectSkills)(cwd, getSkillsContext(base.packageJson, base.manifest), {
|
|
14397
|
+
const skillSync = await (0, projectSkills_js_1.syncExternalProjectSkills)(cwd, await getSkillsContext(cwd, base.packageJson, base.manifest), {
|
|
13672
14398
|
acceptUnknownLicense: options.acceptUnknownLicense,
|
|
13673
14399
|
adoptRecommended: !options.skillNames?.length,
|
|
13674
14400
|
commandRunner: options.commandRunner ?? defaultCommandRunner,
|
|
@@ -13807,7 +14533,7 @@ async function checkProject(cwd, env = node_process_1.default.env, options = {})
|
|
|
13807
14533
|
suggestions.add(suggestion);
|
|
13808
14534
|
}
|
|
13809
14535
|
}
|
|
13810
|
-
const projectSkillsCheck = await (0, projectSkills_js_1.checkProjectSkills)(cwd, getSkillsContext(packageJson, manifest), options.strictSkills);
|
|
14536
|
+
const projectSkillsCheck = await (0, projectSkills_js_1.checkProjectSkills)(cwd, await getSkillsContext(cwd, packageJson, manifest), options.strictSkills);
|
|
13811
14537
|
warnings.push(...projectSkillsCheck.warnings);
|
|
13812
14538
|
issues.push(...projectSkillsCheck.issues);
|
|
13813
14539
|
for (const suggestion of projectSkillsCheck.suggestions) {
|
|
@@ -14344,7 +15070,7 @@ async function runStatus(cwd, io) {
|
|
|
14344
15070
|
managedSkillLines.push(`${skill.skillName}: ${formatSkillLinkState(state)}`);
|
|
14345
15071
|
}
|
|
14346
15072
|
io.out(` managed: ${managedSkillLines.join("; ") || "none"}`);
|
|
14347
|
-
const skillStatus = await (0, projectSkills_js_1.getProjectSkillStatus)(cwd, getSkillsContext(packageJson, manifest));
|
|
15073
|
+
const skillStatus = await (0, projectSkills_js_1.getProjectSkillStatus)(cwd, await getSkillsContext(cwd, packageJson, manifest));
|
|
14348
15074
|
const packageSkillLines = skillStatus.packageSkills.map((skill) => `${skill.skillName} from ${skill.packageName} (${skill.disabled ? "disabled" : skill.active ? "active" : "available"})`);
|
|
14349
15075
|
io.out(` npm packages: ${formatInlineList(packageSkillLines)}`);
|
|
14350
15076
|
const externalSkillLines = skillStatus.external
|
|
@@ -14354,7 +15080,7 @@ async function runStatus(cwd, io) {
|
|
|
14354
15080
|
: "recommended"}; license ${skill.licenseStatus})`);
|
|
14355
15081
|
io.out(` external: ${formatInlineList(externalSkillLines)}`);
|
|
14356
15082
|
io.out(` disabled: ${formatInlineList(skillStatus.disabled)}`);
|
|
14357
|
-
io.out(" updates: run `loom skills sync`
|
|
15083
|
+
io.out(" updates: run `loom skills sync` to restore pins; review `loom skills update` to advance them.");
|
|
14358
15084
|
return 0;
|
|
14359
15085
|
}
|
|
14360
15086
|
function printHelp({ out }) {
|
|
@@ -14369,11 +15095,16 @@ function printHelp({ out }) {
|
|
|
14369
15095
|
out(" files r2 check Verify R2 buckets/account/privacy, Vercel env scoping, local storage, and Files adapter wiring.");
|
|
14370
15096
|
out(" api-keys integrate jobs Record an explicit API-key jobs integration after the route has session/admin authorization.");
|
|
14371
15097
|
out(" api-keys retention enable|disable Record API-key audit cleanup policy; scheduling remains app-owned.");
|
|
15098
|
+
out(" secrets keygen Generate a production secrets key, print it once to a terminal, and record its fingerprint in loom.json. On a linked Vercel project it offers to add the key there.");
|
|
15099
|
+
out(" secrets push <id> Add a recorded secrets key to Vercel Production as a Secret, from a copy pasted back and checked against loom.json.");
|
|
15100
|
+
out(" secrets fingerprint Read a secrets key from a hidden terminal prompt and print only its fingerprint.");
|
|
15101
|
+
out(" secrets activate <id> Record a listed secrets key as the active one; the previous active key becomes decrypt-only. On a linked Vercel project it offers to move the pointer there first.");
|
|
15102
|
+
out(" secrets retire <id> Record a secrets key that nothing needs any more as retired.");
|
|
14372
15103
|
out(" status Show the Loom package, manifest, active features, local-dev state, and project skill state.");
|
|
14373
15104
|
out(" check Validate project bootstrap, managed guidance, features, skill locks, caches, and links.");
|
|
14374
15105
|
out(" env -- <command> Load project .env* files with Next-compatible semantics, then run a command from the project root.");
|
|
14375
|
-
out(" skills sync
|
|
14376
|
-
out(" skills update
|
|
15106
|
+
out(" skills sync Restore recorded skill content and links without adopting updates.");
|
|
15107
|
+
out(" skills update Approve reviewed updates for adopted skills, or select names.");
|
|
14377
15108
|
out(" db fixtures Run the Loom-managed DB fixture dump script for the active DB feature.");
|
|
14378
15109
|
out(" db schema-gen Run the Loom-managed Valibot generator workflow for the active DB feature. Pass extra generator args after `--`.");
|
|
14379
15110
|
out(" db schemas sync Materialize active Loom-managed DB schema blueprints into app-local schema files.");
|
|
@@ -14395,11 +15126,12 @@ function printHelp({ out }) {
|
|
|
14395
15126
|
out(" dev published Remove the managed local-dev override and return to the published dependency.");
|
|
14396
15127
|
out("");
|
|
14397
15128
|
out("Options:");
|
|
14398
|
-
out(" --strict-skills Treat
|
|
15129
|
+
out(" --strict-skills Treat invalid recorded skill content or links as check failures.");
|
|
14399
15130
|
out(" --accept-unknown-license <skill> Explicitly adopt an upstream skill without a clear declared license.");
|
|
14400
15131
|
out(" --network Run registered network checks after the local project checks.");
|
|
14401
15132
|
out(" --production Treat local Loom dev overrides and local lockfile resolutions as release-blocking check failures.");
|
|
14402
15133
|
out(" --no-progress Disable the interactive network progress renderer.");
|
|
15134
|
+
out(" --vercel, --no-vercel For secrets keygen and activate: change the linked Vercel project without asking, or never. Without either, only a person at a terminal is asked.");
|
|
14403
15135
|
out(" --local-db-host <host> Local PostgreSQL host (default: db.localtest.me).");
|
|
14404
15136
|
out(" --local-db-port <port> Local PostgreSQL port (default: 5432).");
|
|
14405
15137
|
out(" --replace-local-target Replace an existing development URL during local DB setup.");
|
|
@@ -14427,6 +15159,7 @@ function printHelp({ out }) {
|
|
|
14427
15159
|
out(" --token-expiry-days <days> Vercel release token lifetime (default 90).");
|
|
14428
15160
|
out(" --timeout <duration> Bounded Vercel promotion wait (default 3m).");
|
|
14429
15161
|
out(" --environment <name> GitHub Environment for migration credential setup (default production).");
|
|
15162
|
+
out(" --environment production|preview Key list a `loom secrets` command uses (default production).");
|
|
14430
15163
|
out(" --env-file <path> Preserved env snapshot for `db migrations verify-env`; process values take precedence.");
|
|
14431
15164
|
out(" --connect Authenticate and check migration database identity and schema privileges.");
|
|
14432
15165
|
out(" --resource <name> Permission resource for API-key integration.");
|
|
@@ -14471,6 +15204,559 @@ async function runApiKeys(cwd, command, target, options, io) {
|
|
|
14471
15204
|
io.out(`Note: ${note}`);
|
|
14472
15205
|
return 0;
|
|
14473
15206
|
}
|
|
15207
|
+
/**
|
|
15208
|
+
* Whether what follows `loom secrets push` is only a version number and
|
|
15209
|
+
* options Loom knows. Anything else may be a key typed in the wrong place,
|
|
15210
|
+
* which the argument parser would quote back in its error.
|
|
15211
|
+
*/
|
|
15212
|
+
function secretsPushArgumentsAreSafe(rest) {
|
|
15213
|
+
const flags = ["--vercel", "--no-vercel", "--no-color", "--help", "-h"];
|
|
15214
|
+
const withValue = ["--cwd", "--environment"];
|
|
15215
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
15216
|
+
const arg = rest[index];
|
|
15217
|
+
if (/^[1-9][0-9]{0,8}$/.test(arg) || flags.includes(arg))
|
|
15218
|
+
continue;
|
|
15219
|
+
if (withValue.some((name) => arg.startsWith(`${name}=`)))
|
|
15220
|
+
continue;
|
|
15221
|
+
if (withValue.includes(arg) && index + 1 < rest.length) {
|
|
15222
|
+
index += 1;
|
|
15223
|
+
continue;
|
|
15224
|
+
}
|
|
15225
|
+
return false;
|
|
15226
|
+
}
|
|
15227
|
+
return true;
|
|
15228
|
+
}
|
|
15229
|
+
const SECRETS_PUSH_ARGUMENT_REFUSAL = "loom secrets push takes only a key version number, such as `loom secrets push 1`. A key must never be passed as an argument: if a key was typed there, treat it as exposed, because it is now in the shell history and was visible in the process list. The key is read from a hidden terminal prompt instead.";
|
|
15230
|
+
const SECRETS_FINGERPRINT_ARGUMENT_REFUSAL = "loom secrets fingerprint takes no arguments. A key must never be passed as an argument: if a key was typed there, treat it as exposed, because it is now in the shell history and was visible in the process list. The key is read from a hidden terminal prompt instead.";
|
|
15231
|
+
/**
|
|
15232
|
+
* Variables that an automated or agent session sets. A key must not be shown
|
|
15233
|
+
* to, or typed into, such a session even when it runs under a pseudo-terminal.
|
|
15234
|
+
*/
|
|
15235
|
+
const AUTOMATED_SESSION_ENV_NAMES = [
|
|
15236
|
+
"CI",
|
|
15237
|
+
"GITHUB_ACTIONS",
|
|
15238
|
+
"CLAUDECODE",
|
|
15239
|
+
"CLAUDE_CODE_ENTRYPOINT",
|
|
15240
|
+
"AI_AGENT",
|
|
15241
|
+
"CODEX_SANDBOX",
|
|
15242
|
+
"CURSOR_AGENT",
|
|
15243
|
+
"GEMINI_CLI",
|
|
15244
|
+
];
|
|
15245
|
+
/**
|
|
15246
|
+
* Whether a command may change something outside the repository, such as a
|
|
15247
|
+
* deployment platform's settings. An explicit flag decides. Without one, only
|
|
15248
|
+
* a person at a terminal is asked, and the default answer is no; anywhere
|
|
15249
|
+
* else nothing outside changes and the command says how to do it instead.
|
|
15250
|
+
* See "CLI prompts and outside changes" in AGENTS.md.
|
|
15251
|
+
*/
|
|
15252
|
+
function resolveOutsideChange(flags, interactive) {
|
|
15253
|
+
if (flags.yes)
|
|
15254
|
+
return "yes";
|
|
15255
|
+
if (flags.no)
|
|
15256
|
+
return "no";
|
|
15257
|
+
return interactive ? "ask" : "no";
|
|
15258
|
+
}
|
|
15259
|
+
const isYesAnswer = (answer) => /^y(es)?$/i.test(answer.trim());
|
|
15260
|
+
/**
|
|
15261
|
+
* Parses `vercel env ls --format json` output, or returns null when it is not
|
|
15262
|
+
* that listing. Vercel CLI 54 and newer print it.
|
|
15263
|
+
*/
|
|
15264
|
+
function parseVercelEnvListing(text) {
|
|
15265
|
+
let parsed;
|
|
15266
|
+
try {
|
|
15267
|
+
parsed = JSON.parse(text.slice(text.indexOf("{"), text.lastIndexOf("}") + 1));
|
|
15268
|
+
}
|
|
15269
|
+
catch {
|
|
15270
|
+
return null;
|
|
15271
|
+
}
|
|
15272
|
+
const envs = isJsonObject(parsed) ? parsed.envs : undefined;
|
|
15273
|
+
if (!Array.isArray(envs))
|
|
15274
|
+
return null;
|
|
15275
|
+
return envs.flatMap((entry) => {
|
|
15276
|
+
if (!isJsonObject(entry) || typeof entry.key !== "string")
|
|
15277
|
+
return [];
|
|
15278
|
+
const targets = (Array.isArray(entry.target) ? entry.target : [entry.target])
|
|
15279
|
+
.filter((target) => typeof target === "string");
|
|
15280
|
+
return [{
|
|
15281
|
+
custom: Array.isArray(entry.customEnvironmentIds) &&
|
|
15282
|
+
entry.customEnvironmentIds.length > 0,
|
|
15283
|
+
key: entry.key,
|
|
15284
|
+
secret: entry.type === "sensitive" || entry.visibility === "secret",
|
|
15285
|
+
targets,
|
|
15286
|
+
type: typeof entry.type === "string" ? entry.type : "",
|
|
15287
|
+
}];
|
|
15288
|
+
});
|
|
15289
|
+
}
|
|
15290
|
+
async function listVercelProductionVariables(cwd, commandRunner, command, env) {
|
|
15291
|
+
// JSON, not the table: the table cannot tell a variable that applies to
|
|
15292
|
+
// Production alone from one shared with Preview, and a name could appear
|
|
15293
|
+
// inside another variable's displayed value.
|
|
15294
|
+
const result = await commandRunner(command, ["env", "ls", "production", "--format", "json"], { cwd, env, stdio: "pipe" });
|
|
15295
|
+
if (result.code !== 0) {
|
|
15296
|
+
throw new Error(`Could not list Vercel Production variables: ${vercelFailureDetail(result, "")}`);
|
|
15297
|
+
}
|
|
15298
|
+
const variables = parseVercelEnvListing(result.stdout);
|
|
15299
|
+
if (!variables) {
|
|
15300
|
+
throw new Error("Vercel did not list Production variables as JSON.");
|
|
15301
|
+
}
|
|
15302
|
+
return variables.filter((variable) => variable.targets.includes("production"));
|
|
15303
|
+
}
|
|
15304
|
+
const vercelVariables = (target, key) => target.variables.filter((variable) => variable.key === key);
|
|
15305
|
+
/**
|
|
15306
|
+
* Why the pointer cannot simply be updated for Production, or null when it
|
|
15307
|
+
* can. A variable shared with Preview would move its pointer too, and Preview
|
|
15308
|
+
* has a key list of its own. Sharing with a custom environment is not in
|
|
15309
|
+
* Vercel's listing, so it cannot be seen here.
|
|
15310
|
+
*/
|
|
15311
|
+
function vercelPointerProblem(target, name) {
|
|
15312
|
+
const found = vercelVariables(target, name);
|
|
15313
|
+
if (found.length === 0)
|
|
15314
|
+
return null;
|
|
15315
|
+
const shared = found.find((variable) => variable.custom || variable.targets.some((each) => each !== "production"));
|
|
15316
|
+
return found.length > 1 || shared
|
|
15317
|
+
? `${name} on Vercel is shared with ${shared
|
|
15318
|
+
? shared.targets.filter((each) => each !== "production").join(", ") ||
|
|
15319
|
+
"a custom environment"
|
|
15320
|
+
: "another entry"}. Give Production its own ${name} by hand, so the other environments keep theirs.`
|
|
15321
|
+
: null;
|
|
15322
|
+
}
|
|
15323
|
+
async function findSecretsVercelTarget(cwd, commandRunner) {
|
|
15324
|
+
const link = await readVercelProjectLink(cwd);
|
|
15325
|
+
if (!link.linked || !link.projectId) {
|
|
15326
|
+
return {
|
|
15327
|
+
linked: false,
|
|
15328
|
+
reason: `This project is not linked to Vercel: ${link.detail} Run \`vercel link\` first.`,
|
|
15329
|
+
};
|
|
15330
|
+
}
|
|
15331
|
+
// The link names the project; inherited ids would silently point the
|
|
15332
|
+
// writes somewhere else.
|
|
15333
|
+
const env = withoutInheritedVercelProject(node_process_1.default.env);
|
|
15334
|
+
const cli = await detectVercelCliCommand(cwd, commandRunner, env);
|
|
15335
|
+
if (!cli.command) {
|
|
15336
|
+
return {
|
|
15337
|
+
linked: true,
|
|
15338
|
+
reason: "The Vercel CLI (`vercel` or `vc`) was not found.",
|
|
15339
|
+
};
|
|
15340
|
+
}
|
|
15341
|
+
try {
|
|
15342
|
+
return {
|
|
15343
|
+
target: {
|
|
15344
|
+
command: cli.command,
|
|
15345
|
+
env,
|
|
15346
|
+
project: link.projectName ?? link.projectId,
|
|
15347
|
+
variables: await listVercelProductionVariables(cwd, commandRunner, cli.command, env),
|
|
15348
|
+
},
|
|
15349
|
+
};
|
|
15350
|
+
}
|
|
15351
|
+
catch (error) {
|
|
15352
|
+
return { linked: true, reason: error.message };
|
|
15353
|
+
}
|
|
15354
|
+
}
|
|
15355
|
+
function warnIfPointerSecret(target, name, io) {
|
|
15356
|
+
if (vercelVariables(target, name).some((variable) => variable.secret)) {
|
|
15357
|
+
io.err(`Vercel holds ${name} as a Secret, perhaps by team policy. It is not secret, and the release build cannot read a Secret back: give its release-policy requirement a placeholder, or store it readable.`);
|
|
15358
|
+
}
|
|
15359
|
+
}
|
|
15360
|
+
/** Sets the pointer for Production only, as a readable variable. */
|
|
15361
|
+
async function setVercelPointer(cwd, commandRunner, target, name, id) {
|
|
15362
|
+
if (vercelVariables(target, name).length) {
|
|
15363
|
+
await updateVercelEnvValue(cwd, commandRunner, target.env, target.command, name, String(id), "production");
|
|
15364
|
+
}
|
|
15365
|
+
else {
|
|
15366
|
+
// Without --no-sensitive, a value given on stdin is stored as a Secret,
|
|
15367
|
+
// which `vercel pull` cannot read back for the release build.
|
|
15368
|
+
await addVercelEnvValue(cwd, commandRunner, target.env, target.command, name, String(id), "production", ["--no-sensitive", "--yes"]);
|
|
15369
|
+
}
|
|
15370
|
+
}
|
|
15371
|
+
/**
|
|
15372
|
+
* Puts a secrets key on Vercel Production as a Secret, and the pointer when
|
|
15373
|
+
* the key is the active one, from a copy the operator pastes back from their
|
|
15374
|
+
* password manager. That copy is checked against the fingerprint in loom.json
|
|
15375
|
+
* before Vercel gets it: a key that reached Vercel but not the password
|
|
15376
|
+
* manager could never be recovered, since Vercel never shows a Secret again.
|
|
15377
|
+
* Afterwards Vercel is listed again to confirm how it stored them.
|
|
15378
|
+
*/
|
|
15379
|
+
async function pushSecretsKeyToVercel(cwd, commandRunner, target, key, terminal, io, options) {
|
|
15380
|
+
if (vercelVariables(target, key.variableName).length) {
|
|
15381
|
+
io.err(`${key.variableName} already exists in Vercel Production. Loom never replaces a key there; find out why Vercel and loom.json differ first.`);
|
|
15382
|
+
return false;
|
|
15383
|
+
}
|
|
15384
|
+
io.out(`Paste the key back from your password manager: the value after \`${key.variableName}=\`. Loom checks the saved copy against the fingerprint in loom.json before Vercel gets it.`);
|
|
15385
|
+
let value = null;
|
|
15386
|
+
for (let attempt = 1; attempt <= 3 && value === null; attempt += 1) {
|
|
15387
|
+
let pasted = (await terminal.prompt(`${key.variableName} from your password manager (input is hidden): `)).trim();
|
|
15388
|
+
if (!pasted) {
|
|
15389
|
+
io.err("Nothing was entered, so nothing was sent to Vercel.");
|
|
15390
|
+
return false;
|
|
15391
|
+
}
|
|
15392
|
+
// The whole printed line is a likely thing to have saved.
|
|
15393
|
+
if (pasted.startsWith(`${key.variableName}=`)) {
|
|
15394
|
+
pasted = pasted.slice(key.variableName.length + 1).trim();
|
|
15395
|
+
}
|
|
15396
|
+
let fingerprint = null;
|
|
15397
|
+
try {
|
|
15398
|
+
fingerprint = await fingerprintSecretsKey(pasted);
|
|
15399
|
+
}
|
|
15400
|
+
catch {
|
|
15401
|
+
io.err("That is not a secrets key: it does not decode to 32 bytes. Check the saved copy.");
|
|
15402
|
+
continue;
|
|
15403
|
+
}
|
|
15404
|
+
if (fingerprint === key.fingerprint) {
|
|
15405
|
+
value = pasted;
|
|
15406
|
+
}
|
|
15407
|
+
else {
|
|
15408
|
+
io.err(`That is a different key from version ${key.id}: its fingerprint does not match loom.json. Check the saved copy.`);
|
|
15409
|
+
}
|
|
15410
|
+
}
|
|
15411
|
+
if (value === null) {
|
|
15412
|
+
io.err(`Nothing was sent to Vercel. Fix the saved copy, then run \`loom secrets push ${key.id}\`.`);
|
|
15413
|
+
return false;
|
|
15414
|
+
}
|
|
15415
|
+
let setPointer = key.state === "active";
|
|
15416
|
+
const pointerProblem = setPointer
|
|
15417
|
+
? vercelPointerProblem(target, key.activeKeyName)
|
|
15418
|
+
: null;
|
|
15419
|
+
if (pointerProblem)
|
|
15420
|
+
setPointer = false;
|
|
15421
|
+
else if (setPointer && vercelVariables(target, key.activeKeyName).length) {
|
|
15422
|
+
setPointer = options.replacePointer === "ask" &&
|
|
15423
|
+
isYesAnswer(await terminal.ask(`${key.activeKeyName} already exists in Vercel Production. Set it to ${key.id}? [y/N] `));
|
|
15424
|
+
}
|
|
15425
|
+
try {
|
|
15426
|
+
await addVercelEnvValue(cwd, commandRunner, target.env, target.command, key.variableName, value, "production", ["--sensitive", "--yes"]);
|
|
15427
|
+
}
|
|
15428
|
+
catch (error) {
|
|
15429
|
+
io.err(`${error.message} Nothing else was changed.`);
|
|
15430
|
+
return false;
|
|
15431
|
+
}
|
|
15432
|
+
if (setPointer) {
|
|
15433
|
+
try {
|
|
15434
|
+
await setVercelPointer(cwd, commandRunner, target, key.activeKeyName, key.id);
|
|
15435
|
+
}
|
|
15436
|
+
catch (error) {
|
|
15437
|
+
io.err(`${key.variableName} was added, but ${key.activeKeyName} was not: ${error.message} Set ${key.activeKeyName}=${key.id} in Vercel Production yourself.`);
|
|
15438
|
+
return false;
|
|
15439
|
+
}
|
|
15440
|
+
}
|
|
15441
|
+
// Confirm what Vercel stored, rather than trusting how it was asked.
|
|
15442
|
+
let stored;
|
|
15443
|
+
try {
|
|
15444
|
+
stored = await listVercelProductionVariables(cwd, commandRunner, target.command, target.env);
|
|
15445
|
+
}
|
|
15446
|
+
catch (error) {
|
|
15447
|
+
io.err(`Added ${key.variableName}, but could not confirm how Vercel stored it: ${error.message} Check it is a Secret for Production only.`);
|
|
15448
|
+
return false;
|
|
15449
|
+
}
|
|
15450
|
+
const confirmed = { ...target, variables: stored };
|
|
15451
|
+
const keyEntry = vercelVariables(confirmed, key.variableName);
|
|
15452
|
+
if (keyEntry.length !== 1 || !keyEntry[0].secret ||
|
|
15453
|
+
keyEntry[0].custom || keyEntry[0].targets.join() !== "production") {
|
|
15454
|
+
io.err(`Vercel did not store ${key.variableName} as a Secret for Production only. Fix it in Vercel before deploying.`);
|
|
15455
|
+
return false;
|
|
15456
|
+
}
|
|
15457
|
+
io.out(`Added ${key.variableName} to Vercel project ${target.project}, Production only, as a Secret${setPointer ? `, and set ${key.activeKeyName}=${key.id}` : ""}. Deployments built before this keep their old environment.`);
|
|
15458
|
+
if (setPointer)
|
|
15459
|
+
warnIfPointerSecret(confirmed, key.activeKeyName, io);
|
|
15460
|
+
if (pointerProblem)
|
|
15461
|
+
io.err(pointerProblem);
|
|
15462
|
+
else if (key.state === "active" && !setPointer) {
|
|
15463
|
+
io.out(`Set ${key.activeKeyName}=${key.id} in Vercel Production before deploying.`);
|
|
15464
|
+
}
|
|
15465
|
+
return true;
|
|
15466
|
+
}
|
|
15467
|
+
async function runSecrets(cwd, command, target, options, io, terminal = {}, commandRunner = defaultCommandRunner) {
|
|
15468
|
+
const usage = "Usage: loom secrets keygen [--environment production|preview] [--vercel|--no-vercel]\n or: loom secrets fingerprint\n or: loom secrets push <id>\n or: loom secrets activate <id> [--environment production|preview] [--vercel|--no-vercel]\n or: loom secrets retire <id> [--environment production|preview]";
|
|
15469
|
+
const environmentOption = options.environment ?? "production";
|
|
15470
|
+
if (environmentOption !== "production" && environmentOption !== "preview") {
|
|
15471
|
+
io.err("--environment must be production or preview.");
|
|
15472
|
+
return 1;
|
|
15473
|
+
}
|
|
15474
|
+
if (options.vercel && options.noVercel) {
|
|
15475
|
+
io.err("--vercel and --no-vercel cannot be used together.");
|
|
15476
|
+
return 1;
|
|
15477
|
+
}
|
|
15478
|
+
const environment = environmentOption;
|
|
15479
|
+
const platformTarget = environment === "production"
|
|
15480
|
+
? "Production"
|
|
15481
|
+
: "Preview";
|
|
15482
|
+
const stdinIsTty = terminal.stdinIsTty ?? Boolean(node_process_1.default.stdin.isTTY);
|
|
15483
|
+
const stdoutIsTty = terminal.stdoutIsTty ?? Boolean(node_process_1.default.stdout.isTTY);
|
|
15484
|
+
const sessionEnv = terminal.env ?? node_process_1.default.env;
|
|
15485
|
+
const automatedMarker = AUTOMATED_SESSION_ENV_NAMES.find((name) => Boolean(sessionEnv[name]));
|
|
15486
|
+
const vercelChoice = resolveOutsideChange({ no: options.noVercel, yes: options.vercel }, stdinIsTty && stdoutIsTty && !automatedMarker);
|
|
15487
|
+
if (options.vercel && environment !== "production") {
|
|
15488
|
+
io.err("--vercel sets Vercel Production only. Set Preview variables yourself.");
|
|
15489
|
+
return 1;
|
|
15490
|
+
}
|
|
15491
|
+
// Raw mode rather than readline: under Deno a readline question never
|
|
15492
|
+
// settles on Ctrl-C, and the command would end without a word.
|
|
15493
|
+
const ask = terminal.ask ??
|
|
15494
|
+
((question) => promptForTerminalValue(question, false, {
|
|
15495
|
+
cancelled: "Cancelled.",
|
|
15496
|
+
notInteractive: "This question needs a terminal.",
|
|
15497
|
+
}, { rawEcho: true }));
|
|
15498
|
+
const prompt = (cancelled, notInteractive) => terminal.prompt ??
|
|
15499
|
+
((question) => promptForTerminalValue(question, true, { cancelled, notInteractive }));
|
|
15500
|
+
// Reading a key is only for a person at a terminal: never a pipe, a file
|
|
15501
|
+
// or an agent's session, whose transcript would then hold the key.
|
|
15502
|
+
const keyReadRefusal = (name) => automatedMarker
|
|
15503
|
+
? `loom secrets ${name} reads a key, so it only runs for a person at a terminal, and this is an automated or agent session. A key must not be typed into, or read by, such a session. An operator runs it personally, in their own terminal.`
|
|
15504
|
+
: !stdinIsTty
|
|
15505
|
+
? `loom secrets ${name} reads the key from a hidden terminal prompt, so its input must be a terminal. Never pass a key as an argument, through a pipe, or from a file. Run it yourself, in your own terminal.`
|
|
15506
|
+
: null;
|
|
15507
|
+
try {
|
|
15508
|
+
switch (command) {
|
|
15509
|
+
case "keygen": {
|
|
15510
|
+
// Deliberately no flag overrides these: the only safe destination for
|
|
15511
|
+
// a production key is the screen of the operator who will save it.
|
|
15512
|
+
// They are a guardrail, not proof that a person is watching; a
|
|
15513
|
+
// pseudo-terminal with a clean environment still passes.
|
|
15514
|
+
const refusal = automatedMarker
|
|
15515
|
+
? `this is an automated or agent session`
|
|
15516
|
+
: !stdoutIsTty
|
|
15517
|
+
? "its output is not a terminal"
|
|
15518
|
+
: !stdinIsTty
|
|
15519
|
+
? "its input is not a terminal"
|
|
15520
|
+
: null;
|
|
15521
|
+
if (refusal) {
|
|
15522
|
+
io.err(`loom secrets keygen prints a production key, so it only runs for a person at a terminal, and ${refusal}. A production key must not be written to a pipe, a file, a log or an AI agent transcript. An operator runs it personally, in their own terminal.`);
|
|
15523
|
+
return 1;
|
|
15524
|
+
}
|
|
15525
|
+
// Asked for explicitly, Vercel must be reachable before a key exists:
|
|
15526
|
+
// finding out afterwards would leave a recorded key with nowhere to go.
|
|
15527
|
+
let vercel = null;
|
|
15528
|
+
let vercelNote = null;
|
|
15529
|
+
if (vercelChoice !== "no" && environment === "production") {
|
|
15530
|
+
const found = await findSecretsVercelTarget(cwd, commandRunner);
|
|
15531
|
+
const planned = await planSecretsKey(cwd, environment);
|
|
15532
|
+
if ("target" in found &&
|
|
15533
|
+
vercelVariables(found.target, planned.variableName).length) {
|
|
15534
|
+
// Drift between Vercel and loom.json, whether or not Vercel was
|
|
15535
|
+
// asked for; a key generated now would have nowhere to go.
|
|
15536
|
+
io.err(`${planned.variableName} already exists in Vercel Production, but loom.json has no such key. Find out why they differ before generating one. No key was generated.`);
|
|
15537
|
+
return 1;
|
|
15538
|
+
}
|
|
15539
|
+
if (!("target" in found) && vercelChoice === "yes") {
|
|
15540
|
+
io.err(`${found.reason} No key was generated.`);
|
|
15541
|
+
return 1;
|
|
15542
|
+
}
|
|
15543
|
+
if ("target" in found)
|
|
15544
|
+
vercel = found.target;
|
|
15545
|
+
else if (found.linked)
|
|
15546
|
+
vercelNote = found.reason;
|
|
15547
|
+
}
|
|
15548
|
+
const result = await generateSecretsKey(cwd, { environment });
|
|
15549
|
+
io.out(`Generated secrets key version ${result.id} for ${environment}. It is shown once and Loom keeps no copy.`);
|
|
15550
|
+
io.out("");
|
|
15551
|
+
io.out(result.assignment);
|
|
15552
|
+
io.out(`Fingerprint: ${result.fingerprint}`);
|
|
15553
|
+
io.out("");
|
|
15554
|
+
io.out(`Recorded the fingerprint in loom.json as ${result.state}. Commit loom.json; it holds no key.`);
|
|
15555
|
+
let pushed = false;
|
|
15556
|
+
let go = false;
|
|
15557
|
+
if (vercel) {
|
|
15558
|
+
io.out("Save the key and its fingerprint in your password manager now, before anything else.");
|
|
15559
|
+
try {
|
|
15560
|
+
go = vercelChoice === "yes" || isYesAnswer(await ask(`Add ${result.variableName} (Secret, Production only)${result.state === "active"
|
|
15561
|
+
? ` and ${result.activeKeyName}=${result.id}`
|
|
15562
|
+
: ""} to Vercel project ${vercel.project}? [y/N] `));
|
|
15563
|
+
}
|
|
15564
|
+
catch {
|
|
15565
|
+
// An interrupted question is a no; the next steps still print.
|
|
15566
|
+
}
|
|
15567
|
+
if (go) {
|
|
15568
|
+
pushed = await pushSecretsKeyToVercel(cwd, commandRunner, vercel, result, {
|
|
15569
|
+
ask,
|
|
15570
|
+
prompt: prompt("Nothing was sent to Vercel.", "This needs a terminal."),
|
|
15571
|
+
}, io,
|
|
15572
|
+
// An explicit --vercel asks nothing more, so it leaves an
|
|
15573
|
+
// existing pointer alone and says so.
|
|
15574
|
+
{ replacePointer: vercelChoice === "yes" ? "no" : "ask" }).catch((error) => {
|
|
15575
|
+
io.err(`${error.message} Nothing was sent to Vercel.`);
|
|
15576
|
+
return false;
|
|
15577
|
+
});
|
|
15578
|
+
}
|
|
15579
|
+
}
|
|
15580
|
+
else if (vercelNote) {
|
|
15581
|
+
io.out(`Note: Vercel was not offered: ${vercelNote}`);
|
|
15582
|
+
}
|
|
15583
|
+
io.out("Next steps:");
|
|
15584
|
+
const steps = [];
|
|
15585
|
+
if (!vercel) {
|
|
15586
|
+
steps.push("Save the key and its fingerprint in your password manager now, before anything else.");
|
|
15587
|
+
}
|
|
15588
|
+
if (!pushed) {
|
|
15589
|
+
steps.push(`Add ${result.variableName} to the deployment platform from the password-manager copy, ${platformTarget} only, as a write-only secret${result.state === "active"
|
|
15590
|
+
? `, and set ${result.activeKeyName}=${result.id} there`
|
|
15591
|
+
: ""}.${environment === "production"
|
|
15592
|
+
? ` On Vercel, \`loom secrets push ${result.id}\` checks the saved copy and does this for you.`
|
|
15593
|
+
: ""}`);
|
|
15594
|
+
}
|
|
15595
|
+
steps.push("Deploy.");
|
|
15596
|
+
steps.push(`Confirm \`secrets.assertReady()\` passes in the deployment: that proves the deployed key is the one you saved.${result.state === "active"
|
|
15597
|
+
? ""
|
|
15598
|
+
: ` Then switch to it with \`loom secrets activate ${result.id}\`.`}`);
|
|
15599
|
+
steps.forEach((step, index) => io.out(` ${index + 1}. ${step}`));
|
|
15600
|
+
// The key exists either way; a push that was asked for and did not
|
|
15601
|
+
// happen is still a failure for whoever runs this.
|
|
15602
|
+
return go && !pushed ? 1 : 0;
|
|
15603
|
+
}
|
|
15604
|
+
case "push": {
|
|
15605
|
+
const id = target === undefined ? null : (0, keyring_js_1.parseSecretKeyId)(target);
|
|
15606
|
+
if (id === null) {
|
|
15607
|
+
io.err(usage);
|
|
15608
|
+
return 1;
|
|
15609
|
+
}
|
|
15610
|
+
if (options.vercel || options.noVercel) {
|
|
15611
|
+
io.err("loom secrets push always asks first; it takes no --vercel or --no-vercel.");
|
|
15612
|
+
return 1;
|
|
15613
|
+
}
|
|
15614
|
+
const refusal = keyReadRefusal("push");
|
|
15615
|
+
if (refusal) {
|
|
15616
|
+
io.err(refusal);
|
|
15617
|
+
return 1;
|
|
15618
|
+
}
|
|
15619
|
+
if (environment !== "production") {
|
|
15620
|
+
io.err("loom secrets push sets Vercel Production only. Set Preview variables yourself.");
|
|
15621
|
+
return 1;
|
|
15622
|
+
}
|
|
15623
|
+
const key = await recordedSecretsKey(cwd, id, environment);
|
|
15624
|
+
const found = await findSecretsVercelTarget(cwd, commandRunner);
|
|
15625
|
+
if (!("target" in found)) {
|
|
15626
|
+
io.err(found.reason);
|
|
15627
|
+
return 1;
|
|
15628
|
+
}
|
|
15629
|
+
if (!isYesAnswer(await ask(`Add ${key.variableName} (Secret, Production only)${key.state === "active"
|
|
15630
|
+
? ` and ${key.activeKeyName}=${key.id}`
|
|
15631
|
+
: ""} to Vercel project ${found.target.project}? [y/N] `))) {
|
|
15632
|
+
io.out("Nothing was changed.");
|
|
15633
|
+
return 0;
|
|
15634
|
+
}
|
|
15635
|
+
return await pushSecretsKeyToVercel(cwd, commandRunner, found.target, key, {
|
|
15636
|
+
ask,
|
|
15637
|
+
prompt: prompt("Nothing was sent to Vercel.", keyReadRefusal("push") ?? "This needs a terminal."),
|
|
15638
|
+
}, io, { replacePointer: "ask" })
|
|
15639
|
+
? 0
|
|
15640
|
+
: 1;
|
|
15641
|
+
}
|
|
15642
|
+
case "fingerprint": {
|
|
15643
|
+
// Checked before anything else, and never echoed: whatever followed
|
|
15644
|
+
// the command may be a key.
|
|
15645
|
+
if (target !== undefined) {
|
|
15646
|
+
io.err(SECRETS_FINGERPRINT_ARGUMENT_REFUSAL);
|
|
15647
|
+
return 1;
|
|
15648
|
+
}
|
|
15649
|
+
if (options.vercel || options.noVercel) {
|
|
15650
|
+
io.err("loom secrets fingerprint changes nothing on Vercel.");
|
|
15651
|
+
return 1;
|
|
15652
|
+
}
|
|
15653
|
+
const refusal = keyReadRefusal("fingerprint");
|
|
15654
|
+
if (refusal) {
|
|
15655
|
+
io.err(refusal);
|
|
15656
|
+
return 1;
|
|
15657
|
+
}
|
|
15658
|
+
const readKey = prompt("Fingerprinting was cancelled.", "loom secrets fingerprint reads the key from a hidden terminal prompt, so its input must be a terminal. Never pass a key as an argument, through a pipe, or from a file. Run it yourself, in your own terminal.");
|
|
15659
|
+
io.out(await fingerprintSecretsKey(await readKey("Secrets key (input is hidden): ")));
|
|
15660
|
+
return 0;
|
|
15661
|
+
}
|
|
15662
|
+
case "activate":
|
|
15663
|
+
case "retire": {
|
|
15664
|
+
const id = target === undefined ? null : (0, keyring_js_1.parseSecretKeyId)(target);
|
|
15665
|
+
if (id === null) {
|
|
15666
|
+
io.err(usage);
|
|
15667
|
+
return 1;
|
|
15668
|
+
}
|
|
15669
|
+
if (command === "activate") {
|
|
15670
|
+
if (environment !== "production" && options.vercel) {
|
|
15671
|
+
io.err("--vercel sets Vercel Production only. Set Preview variables yourself.");
|
|
15672
|
+
return 1;
|
|
15673
|
+
}
|
|
15674
|
+
let pointerSet = false;
|
|
15675
|
+
let vercelNote = null;
|
|
15676
|
+
const result = await activateSecretsKey(cwd, id, environment, {
|
|
15677
|
+
// The platform's pointer moves first: a deployment carrying the
|
|
15678
|
+
// new list with the old pointer would fail every seal. A build
|
|
15679
|
+
// between the two, with the new pointer and the old list, fails
|
|
15680
|
+
// too, so loom.json should follow at once.
|
|
15681
|
+
beforeWrite: async (key) => {
|
|
15682
|
+
if (vercelChoice === "no" || environment !== "production") {
|
|
15683
|
+
return false;
|
|
15684
|
+
}
|
|
15685
|
+
const found = await findSecretsVercelTarget(cwd, commandRunner);
|
|
15686
|
+
const refusal = !("target" in found)
|
|
15687
|
+
? found.reason
|
|
15688
|
+
: !vercelVariables(found.target, key.variableName).length
|
|
15689
|
+
? `${key.variableName} is not in Vercel Production. Add it (\`loom secrets push ${id}\`) and deploy before activating it.`
|
|
15690
|
+
: vercelPointerProblem(found.target, key.activeKeyName);
|
|
15691
|
+
if (refusal) {
|
|
15692
|
+
if (vercelChoice === "yes") {
|
|
15693
|
+
throw new Error(`${refusal} loom.json was not changed.`);
|
|
15694
|
+
}
|
|
15695
|
+
if ("target" in found || found.linked)
|
|
15696
|
+
vercelNote = refusal;
|
|
15697
|
+
return false;
|
|
15698
|
+
}
|
|
15699
|
+
const vercel = found.target;
|
|
15700
|
+
if (vercelChoice === "ask" &&
|
|
15701
|
+
!isYesAnswer(await ask(`Set ${key.activeKeyName}=${id} in Vercel project ${vercel.project}, Production, before loom.json changes? [y/N] `).catch(() => ""))) {
|
|
15702
|
+
return false;
|
|
15703
|
+
}
|
|
15704
|
+
try {
|
|
15705
|
+
await setVercelPointer(cwd, commandRunner, vercel, key.activeKeyName, id);
|
|
15706
|
+
}
|
|
15707
|
+
catch (error) {
|
|
15708
|
+
throw new Error(`${error.message} loom.json was not changed.`);
|
|
15709
|
+
}
|
|
15710
|
+
pointerSet = true;
|
|
15711
|
+
io.out(`Set ${key.activeKeyName}=${id} in Vercel project ${vercel.project}, Production.`);
|
|
15712
|
+
// Team policy, or an existing Secret kept by `env update`, can
|
|
15713
|
+
// leave the pointer unreadable to the release build.
|
|
15714
|
+
try {
|
|
15715
|
+
warnIfPointerSecret({
|
|
15716
|
+
...vercel,
|
|
15717
|
+
variables: await listVercelProductionVariables(cwd, commandRunner, vercel.command, vercel.env),
|
|
15718
|
+
}, key.activeKeyName, io);
|
|
15719
|
+
}
|
|
15720
|
+
catch {
|
|
15721
|
+
// The pointer is set; how it is stored is a warning only.
|
|
15722
|
+
}
|
|
15723
|
+
return true;
|
|
15724
|
+
},
|
|
15725
|
+
});
|
|
15726
|
+
io.out(result.changedFiles.length
|
|
15727
|
+
? `Updated ${result.changedFiles.join(", ")}: key version ${id} is now the active ${environment} key.`
|
|
15728
|
+
: `Key version ${id} is already the active ${environment} key in loom.json.`);
|
|
15729
|
+
if (vercelNote)
|
|
15730
|
+
io.out(`Note: Vercel was not changed: ${vercelNote}`);
|
|
15731
|
+
io.out(pointerSet
|
|
15732
|
+
? "Next: run `loom check --production` and push this loom.json now. A production build made before it lands has the new pointer and the old list, and fails every seal."
|
|
15733
|
+
: `Note: Set ${result.activeKeyName}=${id} for ${platformTarget} on the deployment platform, before deploying this loom.json. Until both match, every seal fails (opens still work).${environment === "production"
|
|
15734
|
+
? " On Vercel, `--vercel` does this first."
|
|
15735
|
+
: ""}`);
|
|
15736
|
+
return 0;
|
|
15737
|
+
}
|
|
15738
|
+
if (options.vercel || options.noVercel) {
|
|
15739
|
+
io.err("loom secrets retire changes nothing on Vercel; remove the variable there yourself, after deploying the retired list.");
|
|
15740
|
+
return 1;
|
|
15741
|
+
}
|
|
15742
|
+
const result = await retireSecretsKey(cwd, id, environment);
|
|
15743
|
+
io.out(result.changedFiles.length
|
|
15744
|
+
? `Updated ${result.changedFiles.join(", ")}: key version ${id} is now retired for ${environment}.`
|
|
15745
|
+
: `Key version ${id} is already retired for ${environment} in loom.json.`);
|
|
15746
|
+
io.out(`Note: Retiring a key is only safe when no stored value, keyed fingerprint or restorable backup needs it. Remove ${result.variableName} from ${platformTarget} and delete every deployment built while it was active.`);
|
|
15747
|
+
return 0;
|
|
15748
|
+
}
|
|
15749
|
+
default:
|
|
15750
|
+
io.err(usage);
|
|
15751
|
+
return 1;
|
|
15752
|
+
}
|
|
15753
|
+
}
|
|
15754
|
+
catch (error) {
|
|
15755
|
+
// These are operator-facing refusals; a stack trace adds nothing.
|
|
15756
|
+
io.err(error.message);
|
|
15757
|
+
return 1;
|
|
15758
|
+
}
|
|
15759
|
+
}
|
|
14474
15760
|
async function runFiles(cwd, command, target, options, io) {
|
|
14475
15761
|
if (command === "id-generation") {
|
|
14476
15762
|
if (target !== "uuid-v4" && target !== "uuid-v7") {
|
|
@@ -14666,12 +15952,12 @@ function printSkillsHelp({ out }) {
|
|
|
14666
15952
|
out("");
|
|
14667
15953
|
out("Commands:");
|
|
14668
15954
|
out(" list Show discovered, adopted, disabled, and recommended skills.");
|
|
14669
|
-
out(" add Adopt
|
|
14670
|
-
out(" sync
|
|
15955
|
+
out(" add Adopt selected external or installed npm skills.");
|
|
15956
|
+
out(" sync Restore recorded skill content and links.");
|
|
14671
15957
|
out(" check Validate project skill locks, caches, and links.");
|
|
14672
|
-
out(" update
|
|
15958
|
+
out(" update Update adopted skills to reviewed catalog or installed npm content.");
|
|
14673
15959
|
out(" migrate Replace legacy packaged-skill links with project installs.");
|
|
14674
|
-
out(" disable
|
|
15960
|
+
out(" disable Disable a managed skill or opt out of a recommendation.");
|
|
14675
15961
|
out(" enable Clear a skill opt-out; run sync afterward.");
|
|
14676
15962
|
out("");
|
|
14677
15963
|
out("Unlicensed external skills require `--accept-unknown-license <name>`.");
|
|
@@ -14697,7 +15983,7 @@ async function runSkills(cwd, command, args, io, options) {
|
|
|
14697
15983
|
const manifest = manifestText
|
|
14698
15984
|
? parseJson(manifestText, "loom.json")
|
|
14699
15985
|
: null;
|
|
14700
|
-
const context = getSkillsContext(packageJson, manifest);
|
|
15986
|
+
const context = await getSkillsContext(cwd, packageJson, manifest);
|
|
14701
15987
|
const accepted = options.acceptUnknownLicense
|
|
14702
15988
|
? [options.acceptUnknownLicense]
|
|
14703
15989
|
: [];
|
|
@@ -14734,6 +16020,30 @@ async function runSkills(cwd, command, args, io, options) {
|
|
|
14734
16020
|
case "migrate":
|
|
14735
16021
|
case "sync":
|
|
14736
16022
|
case "update": {
|
|
16023
|
+
if ((command === "sync" || command === "migrate") && args.length) {
|
|
16024
|
+
io.err(`loom skills ${command} restores locked state and does not select new skills.`);
|
|
16025
|
+
return 1;
|
|
16026
|
+
}
|
|
16027
|
+
const status = await (0, projectSkills_js_1.getProjectSkillStatus)(cwd, context);
|
|
16028
|
+
const locked = await (0, projectSkills_js_1.readProjectSkillsLock)(cwd);
|
|
16029
|
+
const packageNames = new Set(status.packageSkills.map((skill) => skill.skillName));
|
|
16030
|
+
const externalNames = new Set([
|
|
16031
|
+
...status.external.map((skill) => skill.skillName),
|
|
16032
|
+
...Object.keys(locked.skills).filter((name) => locked.skills[name].kind === "external"),
|
|
16033
|
+
]);
|
|
16034
|
+
const unknown = args.filter((name) => !packageNames.has(name) && !externalNames.has(name));
|
|
16035
|
+
if (unknown.length) {
|
|
16036
|
+
io.err(`Unknown skill: ${unknown.join(", ")}`);
|
|
16037
|
+
return 1;
|
|
16038
|
+
}
|
|
16039
|
+
const ambiguous = args.filter((name) => !locked.skills[name] && packageNames.has(name) &&
|
|
16040
|
+
externalNames.has(name));
|
|
16041
|
+
if (ambiguous.length) {
|
|
16042
|
+
io.err(`Ambiguous skill source: ${ambiguous.join(", ")}. Choose and adopt the source explicitly before using its name.`);
|
|
16043
|
+
return 1;
|
|
16044
|
+
}
|
|
16045
|
+
const selectedPackages = args.filter((name) => locked.skills[name]?.kind === "package" ||
|
|
16046
|
+
(!locked.skills[name] && packageNames.has(name)));
|
|
14737
16047
|
const nextGuidance = await ensureNextAgentsFile(cwd, packageJson);
|
|
14738
16048
|
const migrationFiles = [];
|
|
14739
16049
|
const migrationNotes = [];
|
|
@@ -14745,12 +16055,18 @@ async function runSkills(cwd, command, args, io, options) {
|
|
|
14745
16055
|
migrationFiles.push(".agents/skills/next-best-practices");
|
|
14746
16056
|
migrationNotes.push("Removed the retired next-best-practices link; use Next.js version-matched agent documentation.");
|
|
14747
16057
|
}
|
|
14748
|
-
const packageResult = await (0, projectSkills_js_1.syncInstalledPackageSkills)(cwd
|
|
16058
|
+
const packageResult = await (0, projectSkills_js_1.syncInstalledPackageSkills)(cwd, {
|
|
16059
|
+
skillNames: selectedPackages,
|
|
16060
|
+
update: command === "update" && !args.length,
|
|
16061
|
+
});
|
|
14749
16062
|
const externalResult = await (0, projectSkills_js_1.syncExternalProjectSkills)(cwd, context, {
|
|
14750
16063
|
acceptUnknownLicense: accepted,
|
|
14751
|
-
adoptRecommended: command === "add"
|
|
16064
|
+
adoptRecommended: command === "add" && !args.length,
|
|
16065
|
+
update: command === "update",
|
|
14752
16066
|
commandRunner: defaultCommandRunner,
|
|
14753
|
-
skillNames: args.length
|
|
16067
|
+
skillNames: args.length
|
|
16068
|
+
? args.filter((name) => !selectedPackages.includes(name))
|
|
16069
|
+
: undefined,
|
|
14754
16070
|
});
|
|
14755
16071
|
if (await ensureExternalSkillsGitignore(cwd)) {
|
|
14756
16072
|
externalResult.changedFiles.push(".gitignore");
|
|
@@ -15289,20 +16605,10 @@ async function runDev(cwd, mode, pathInput, io, options = {}) {
|
|
|
15289
16605
|
}
|
|
15290
16606
|
}
|
|
15291
16607
|
async function runCheck(cwd, strictSkills, production, network, noProgress, noColor, io) {
|
|
15292
|
-
const packageSkills = await (0, projectSkills_js_1.syncInstalledPackageSkills)(cwd);
|
|
15293
|
-
if (packageSkills.changedFiles.length) {
|
|
15294
|
-
io.out(`Updated ${packageSkills.changedFiles.join(", ")} while activating npm package skills.`);
|
|
15295
|
-
}
|
|
15296
|
-
for (const note of packageSkills.notes)
|
|
15297
|
-
io.out(`Note: ${note}`);
|
|
15298
16608
|
const localResult = await checkProject(cwd, node_process_1.default.env, {
|
|
15299
16609
|
production,
|
|
15300
16610
|
strictSkills,
|
|
15301
16611
|
});
|
|
15302
|
-
if (production && packageSkills.changedFiles.length) {
|
|
15303
|
-
localResult.issues.push(`Production check activated or updated project skills: ${packageSkills.changedFiles.join(", ")}.`);
|
|
15304
|
-
localResult.suggestions.push("Review and commit the project skill lock and activation links before release.");
|
|
15305
|
-
}
|
|
15306
16612
|
let result = localResult;
|
|
15307
16613
|
if (network) {
|
|
15308
16614
|
const reporter = createNetworkProgressReporter(io, {
|
|
@@ -15346,6 +16652,20 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
15346
16652
|
err: (line) => console.error(line),
|
|
15347
16653
|
out: (line) => console.log(line),
|
|
15348
16654
|
}, options = {}) {
|
|
16655
|
+
// Checked before any argument is parsed: a parse error quotes the argument,
|
|
16656
|
+
// and a key pasted after `fingerprint` (base64url keys can begin with `-`)
|
|
16657
|
+
// must not be printed back.
|
|
16658
|
+
const secretsIndex = args.indexOf("secrets");
|
|
16659
|
+
if (secretsIndex >= 0 && args[secretsIndex + 1] === "fingerprint" &&
|
|
16660
|
+
args.length > secretsIndex + 2) {
|
|
16661
|
+
io.err(SECRETS_FINGERPRINT_ARGUMENT_REFUSAL);
|
|
16662
|
+
return 1;
|
|
16663
|
+
}
|
|
16664
|
+
if (secretsIndex >= 0 && args[secretsIndex + 1] === "push" &&
|
|
16665
|
+
!secretsPushArgumentsAreSafe(args.slice(secretsIndex + 2))) {
|
|
16666
|
+
io.err(SECRETS_PUSH_ARGUMENT_REFUSAL);
|
|
16667
|
+
return 1;
|
|
16668
|
+
}
|
|
15349
16669
|
const parsed = (0, node_util_1.parseArgs)({
|
|
15350
16670
|
allowPositionals: true,
|
|
15351
16671
|
args,
|
|
@@ -15375,6 +16695,8 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
15375
16695
|
"max-requests-per-key": { type: "string" },
|
|
15376
16696
|
"no-color": { type: "boolean" },
|
|
15377
16697
|
"no-progress": { type: "boolean" },
|
|
16698
|
+
"no-vercel": { type: "boolean" },
|
|
16699
|
+
vercel: { type: "boolean" },
|
|
15378
16700
|
"no-sync": { type: "boolean" },
|
|
15379
16701
|
network: { type: "boolean" },
|
|
15380
16702
|
"neon-auth": { type: "boolean" },
|
|
@@ -15410,6 +16732,9 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
15410
16732
|
const addListOnly = command === "add" && arg1 === undefined;
|
|
15411
16733
|
if (command !== undefined &&
|
|
15412
16734
|
command !== "dev" &&
|
|
16735
|
+
// `loom secrets` reads and writes only loom.json and the terminal. A
|
|
16736
|
+
// sync would put build output and notes around a key shown once.
|
|
16737
|
+
command !== "secrets" &&
|
|
15413
16738
|
command !== "skills" &&
|
|
15414
16739
|
command !== "status" &&
|
|
15415
16740
|
!addListOnly &&
|
|
@@ -15477,6 +16802,12 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
15477
16802
|
maxRequestsPerKey: parsed.values["max-requests-per-key"],
|
|
15478
16803
|
resource: parsed.values.resource,
|
|
15479
16804
|
}, io);
|
|
16805
|
+
case "secrets":
|
|
16806
|
+
return await runSecrets(cwd, arg1, arg2, {
|
|
16807
|
+
environment: parsed.values.environment,
|
|
16808
|
+
noVercel: parsed.values["no-vercel"],
|
|
16809
|
+
vercel: parsed.values.vercel,
|
|
16810
|
+
}, io, options.secretsTerminal, options.commandRunner);
|
|
15480
16811
|
case "skills":
|
|
15481
16812
|
return await runSkills(cwd, arg1, [arg2, ...rest].filter(Boolean), io, {
|
|
15482
16813
|
acceptUnknownLicense: parsed.values["accept-unknown-license"],
|