@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/esm/src/cli/mod.js
CHANGED
|
@@ -17,11 +17,15 @@ import { classifyManagedFile, classifyManagedTask, describeManagedFileDifference
|
|
|
17
17
|
import { legacyDbPgliteHarnessOutputs, legacyDbTaskValues, legacyJobsDirectRunnerOutputs, legacyJobsTaskValues, } from "./legacyManagedOutputs.js";
|
|
18
18
|
import { BETTER_AUTH_API_KEY_HTTP_PATHS } from "../apiKeys/betterAuth.js";
|
|
19
19
|
import { DEFAULT_API_KEY_AUDIT_RETENTION } from "../apiKeys/retention.js";
|
|
20
|
-
import {
|
|
20
|
+
import { SECRETS_ENVIRONMENT_ENV } from "../next/secrets/mod.js";
|
|
21
|
+
import { toBase64Url } from "../secrets/encoding.js";
|
|
22
|
+
import { parseExpectedSecretKeys, secretKeyFingerprint, } from "../secrets/fingerprint.js";
|
|
23
|
+
import { decodeSecretKey, DEFAULT_SECRETS_ACTIVE_KEY_ENV, DEFAULT_SECRETS_KEY_ENV_PREFIX, isSecretKeyId, parseSecretKeyId, SECRETS_KEY_BYTES, } from "../secrets/keyring.js";
|
|
24
|
+
import { checkProjectSkills, getProjectSkillStatus, LOOM_EXTERNAL_SKILLS_GITIGNORE_LINE, readProjectSkillsLock, removeLegacyNextSkillLink, setProjectSkillDisabled, syncExternalProjectSkills, syncInstalledPackageSkills, } from "./projectSkills.js";
|
|
21
25
|
import { resolveMigrationEnvironment, resolveMigrationEnvironmentFromEnvFile, verifyMigrationConnection, verifyMigrationConnectionFromEnvFile, } from "./migrationEnv.js";
|
|
22
|
-
import { prepareVercelBuildEnvironment, verifyVercelBuildArtifact, } from "./vercelBuildEnv.js";
|
|
26
|
+
import { parseVercelBuildEnvironmentPolicy, prepareVercelBuildEnvironment, verifyVercelBuildArtifact, } from "./vercelBuildEnv.js";
|
|
23
27
|
import { parseVercelReleaseTimeout, prepareVercelProjectRelease, promoteVercelProjectRelease, } from "./vercelProjectRelease.js";
|
|
24
|
-
import { detectProjectTooling, ensureTask, ensureTaskFollowup, ensureTaskPrerequisite, findTaskConflicts, formatTaskInvocation, getTaskCommand, jsonValuesEqual, mutateDenoLinks, mutatePackageJsonOverride, mutateProjectDependencies, parseJsonc, patchJsonText, readDenoLinks, readProjectPackageMetadata, readTaskStore, taskInvokes, taskRunsBeforeCommand, } from "./projectTooling.js";
|
|
28
|
+
import { denoConfigAsPackageJson, detectProjectTooling, ensureTask, ensureTaskFollowup, ensureTaskPrerequisite, findTaskConflicts, formatTaskInvocation, getTaskCommand, jsonValuesEqual, mutateDenoLinks, mutatePackageJsonOverride, mutateProjectDependencies, parseJsonc, patchJsonText, readDenoLinks, readProjectPackageMetadata, readTaskStore, taskInvokes, taskRunsBeforeCommand, } from "./projectTooling.js";
|
|
25
29
|
import { withLocalDevLock, } from "./localDevLock.js";
|
|
26
30
|
import { computeLoomSourceFingerprint, computePackageContentDigest, computePackageTreeSignature, findNewPeerVariantDuplicates, findPackageTreeDifference, formatLoomBuildStamp, getLockfileOverride, getLockfileRootImporterDependency, hasLoomBuildProvenance, LOOM_BUILD_STAMP_FILE, LOOM_PACKAGE_RELEVANT_PATHS, readLoomBuildStamp, } from "./localDevPackage.js";
|
|
27
31
|
export const DEFAULT_LOOM_RANGE = "^1.0.0";
|
|
@@ -136,6 +140,12 @@ const managedSkills = [
|
|
|
136
140
|
relativePackagePath: "skills/loom-lingui",
|
|
137
141
|
skillName: "loom-lingui",
|
|
138
142
|
},
|
|
143
|
+
{
|
|
144
|
+
featureKey: "secrets",
|
|
145
|
+
label: "loom secrets skill",
|
|
146
|
+
relativePackagePath: "skills/loom-secrets",
|
|
147
|
+
skillName: "loom-secrets",
|
|
148
|
+
},
|
|
139
149
|
];
|
|
140
150
|
const featureDefinitions = [
|
|
141
151
|
{
|
|
@@ -170,6 +180,10 @@ const featureDefinitions = [
|
|
|
170
180
|
key: "pwa",
|
|
171
181
|
description: "Shared Serwist PWA worker, provider lifecycle, update prompts, and build wiring.",
|
|
172
182
|
},
|
|
183
|
+
{
|
|
184
|
+
key: "secrets",
|
|
185
|
+
description: "Reversible secrets at rest with versioned, fingerprint-verified keys.",
|
|
186
|
+
},
|
|
173
187
|
];
|
|
174
188
|
const DB_DEFAULT_DEPENDENCIES = {
|
|
175
189
|
"@neondatabase/serverless": "^1.1.0",
|
|
@@ -2068,6 +2082,31 @@ function mergeApiKeyAuditSchemaConfig(dbConfig, schemaConfig) {
|
|
|
2068
2082
|
hashManagedSchemaText(buildApiKeyAuditSchemaText(merged)),
|
|
2069
2083
|
};
|
|
2070
2084
|
}
|
|
2085
|
+
function getSecretsConfig(framework, featureConfig) {
|
|
2086
|
+
const moduleRoot = framework.srcDir ? "src/" : "";
|
|
2087
|
+
return {
|
|
2088
|
+
modules: {
|
|
2089
|
+
secretsModule: featureConfig?.modules?.secretsModule ??
|
|
2090
|
+
`${moduleRoot}secrets.ts`,
|
|
2091
|
+
locationsModule: featureConfig?.modules?.locationsModule ??
|
|
2092
|
+
`${moduleRoot}secretLocations.ts`,
|
|
2093
|
+
},
|
|
2094
|
+
env: {
|
|
2095
|
+
keyPrefix: featureConfig?.env?.keyPrefix ??
|
|
2096
|
+
DEFAULT_SECRETS_KEY_ENV_PREFIX,
|
|
2097
|
+
activeKeyName: featureConfig?.env?.activeKeyName ??
|
|
2098
|
+
DEFAULT_SECRETS_ACTIVE_KEY_ENV,
|
|
2099
|
+
},
|
|
2100
|
+
// Recorded by `loom secrets`; passed through unvalidated so `loom check`
|
|
2101
|
+
// can report a hand-edited list instead of this getter hiding it.
|
|
2102
|
+
keys: {
|
|
2103
|
+
production: featureConfig?.keys?.production ?? [],
|
|
2104
|
+
...(featureConfig?.keys?.preview !== undefined
|
|
2105
|
+
? { preview: featureConfig.keys.preview }
|
|
2106
|
+
: {}),
|
|
2107
|
+
},
|
|
2108
|
+
};
|
|
2109
|
+
}
|
|
2071
2110
|
function getApiKeysConfig(framework, dbConfig, packageJson, featureConfig) {
|
|
2072
2111
|
const appRoot = framework.srcDir ? "src/app" : "app";
|
|
2073
2112
|
const apiKeysRoot = framework.srcDir
|
|
@@ -4512,7 +4551,16 @@ async function checkPnpm11Compatibility(cwd, packageJson, npmrcText) {
|
|
|
4512
4551
|
warnings: major === null || major < 11 ? findings : [],
|
|
4513
4552
|
};
|
|
4514
4553
|
}
|
|
4515
|
-
function getSkillsContext(packageJson, manifest) {
|
|
4554
|
+
async function getSkillsContext(cwd, packageJson, manifest) {
|
|
4555
|
+
const tooling = await detectProjectTooling(cwd, manifest?.project?.tooling);
|
|
4556
|
+
const dependencyConfig = tooling.dependencies.config;
|
|
4557
|
+
if (dependencyConfig !== "package.json") {
|
|
4558
|
+
const text = await readTextIfExists(join(cwd, dependencyConfig));
|
|
4559
|
+
if (text === null) {
|
|
4560
|
+
throw new Error(`Missing dependency config: ${dependencyConfig}`);
|
|
4561
|
+
}
|
|
4562
|
+
packageJson = denoConfigAsPackageJson(parseJsonc(text, dependencyConfig));
|
|
4563
|
+
}
|
|
4516
4564
|
return {
|
|
4517
4565
|
activeFeatureKeys: new Set(manifest
|
|
4518
4566
|
? Object.entries(manifest.features)
|
|
@@ -7934,16 +7982,29 @@ async function listVercelEnvironmentNames(cwd, commandRunner, env, vercelCommand
|
|
|
7934
7982
|
}
|
|
7935
7983
|
return result.stdout;
|
|
7936
7984
|
}
|
|
7937
|
-
|
|
7938
|
-
|
|
7985
|
+
/**
|
|
7986
|
+
* What a failed Vercel CLI call said. In an agent session the CLI reports
|
|
7987
|
+
* errors as JSON on stdout. Vercel does not echo a value it was given, but a
|
|
7988
|
+
* long one is masked anyway, in case a later version does.
|
|
7989
|
+
*/
|
|
7990
|
+
function vercelFailureDetail(result, value) {
|
|
7991
|
+
const detail = result.stderr.trim() || result.stdout.trim() ||
|
|
7992
|
+
`exit code ${result.code}`;
|
|
7993
|
+
return value.length >= 16 ? detail.split(value).join("[redacted]") : detail;
|
|
7994
|
+
}
|
|
7995
|
+
async function addVercelEnvValue(cwd, commandRunner, env, vercelCommand, name, value, environment, extraArgs = []) {
|
|
7996
|
+
// The value goes on stdin, never into the arguments, where the process
|
|
7997
|
+
// list and shell history would show it.
|
|
7998
|
+
const result = await commandRunner(vercelCommand, ["env", "add", name, environment, ...extraArgs], { cwd, env, input: `${value}\n`, stdio: "pipe" });
|
|
7939
7999
|
if (result.code !== 0) {
|
|
7940
|
-
throw new Error(`Could not add ${name} to Vercel ${environment}: ${result
|
|
8000
|
+
throw new Error(`Could not add ${name} to Vercel ${environment}: ${vercelFailureDetail(result, value)}`);
|
|
7941
8001
|
}
|
|
7942
8002
|
}
|
|
7943
8003
|
async function updateVercelEnvValue(cwd, commandRunner, env, vercelCommand, name, value, environment) {
|
|
8004
|
+
// No type flag: `env update` keeps the variable's existing type.
|
|
7944
8005
|
const result = await commandRunner(vercelCommand, ["env", "update", name, environment, "--yes"], { cwd, env, input: `${value}\n`, stdio: "pipe" });
|
|
7945
8006
|
if (result.code !== 0) {
|
|
7946
|
-
throw new Error(`Could not update ${name} in Vercel ${environment}: ${result
|
|
8007
|
+
throw new Error(`Could not update ${name} in Vercel ${environment}: ${vercelFailureDetail(result, value)}`);
|
|
7947
8008
|
}
|
|
7948
8009
|
}
|
|
7949
8010
|
async function promptForVercelSecret(cwd, commandRunner, env, vercelCommand, name, environment) {
|
|
@@ -7981,10 +8042,38 @@ function buildVercelFilesEnvListArgs(environment, project) {
|
|
|
7981
8042
|
}
|
|
7982
8043
|
function withoutInheritedVercelProject(env) {
|
|
7983
8044
|
const result = { ...env };
|
|
7984
|
-
|
|
7985
|
-
|
|
8045
|
+
// The Vercel CLI still honours the older NOW_* names too.
|
|
8046
|
+
for (const name of [
|
|
8047
|
+
"VERCEL_ORG_ID",
|
|
8048
|
+
"VERCEL_PROJECT_ID",
|
|
8049
|
+
"NOW_ORG_ID",
|
|
8050
|
+
"NOW_PROJECT_ID",
|
|
8051
|
+
]) {
|
|
8052
|
+
delete result[name];
|
|
8053
|
+
}
|
|
7986
8054
|
return result;
|
|
7987
8055
|
}
|
|
8056
|
+
/**
|
|
8057
|
+
* Which of `names` Vercel stores as Secrets for `environment`, or null when
|
|
8058
|
+
* the JSON listing is unavailable. A Secret reads back empty, so it looks like
|
|
8059
|
+
* drift, but `vercel env update` keeps a variable's type and cannot fix it.
|
|
8060
|
+
*/
|
|
8061
|
+
async function findVercelFilesValuesStoredAsSecrets(cwd, commandRunner, env, vercelCommand, environment, listArgs, names) {
|
|
8062
|
+
const result = await commandRunner(vercelCommand, [...listArgs, "--format", "json"], { cwd, env, stdio: "pipe" });
|
|
8063
|
+
if (result.code !== 0)
|
|
8064
|
+
return null;
|
|
8065
|
+
const variables = parseVercelEnvListing(result.stdout);
|
|
8066
|
+
if (!variables)
|
|
8067
|
+
return null;
|
|
8068
|
+
return names.filter((name) => variables.some((variable) => variable.key === name && variable.secret &&
|
|
8069
|
+
variable.targets.includes(environment)));
|
|
8070
|
+
}
|
|
8071
|
+
function filesSecretTypeProblem(environment, names) {
|
|
8072
|
+
return `Vercel ${environment} stores ${names.join(", ")} as Secrets, so their values cannot be read back, and \`vercel env update\` keeps a Secret a Secret.`;
|
|
8073
|
+
}
|
|
8074
|
+
function filesSecretTypeFix(environment) {
|
|
8075
|
+
return `Remove them from Vercel ${environment}, then run \`loom files r2 setup\` to add them back as readable values.`;
|
|
8076
|
+
}
|
|
7988
8077
|
async function readVercelFilesNonSecretValues(cwd, commandRunner, env, vercelCommand, environment) {
|
|
7989
8078
|
const link = await readVercelProjectLink(cwd);
|
|
7990
8079
|
if (!link.linked || !link.orgId || !link.projectId)
|
|
@@ -8062,13 +8151,16 @@ async function ensureMinioBucket(cwd, commandRunner, env, endpoint, bucket, acce
|
|
|
8062
8151
|
ok: false,
|
|
8063
8152
|
};
|
|
8064
8153
|
}
|
|
8065
|
-
|
|
8154
|
+
/**
|
|
8155
|
+
* Reads one line from the terminal, writing the question to stderr. A secret
|
|
8156
|
+
* is read in raw mode so it is never echoed. Refuses when stdin is not a
|
|
8157
|
+
* terminal, with the caller's explanation of what to do instead.
|
|
8158
|
+
*/
|
|
8159
|
+
async function promptForTerminalValue(question, secret, messages, options = {}) {
|
|
8066
8160
|
if (!process.stdin.isTTY) {
|
|
8067
|
-
throw new Error(
|
|
8068
|
-
? "MinIO admin credentials are required. Run interactively or set MINIO_ROOT_USER and MINIO_ROOT_PASSWORD in the command environment."
|
|
8069
|
-
: "PostgreSQL admin credentials are required. Run interactively or set LOOM_DB_LOCAL_ADMIN_PASSWORD in the command environment.");
|
|
8161
|
+
throw new Error(messages.notInteractive);
|
|
8070
8162
|
}
|
|
8071
|
-
if (!secret) {
|
|
8163
|
+
if (!secret && !options.rawEcho) {
|
|
8072
8164
|
const input = createInterface({
|
|
8073
8165
|
input: process.stdin,
|
|
8074
8166
|
output: process.stderr,
|
|
@@ -8098,13 +8190,17 @@ async function promptForLocalFilesValue(question, secret = false, context = "Min
|
|
|
8098
8190
|
}
|
|
8099
8191
|
if (character === "\u0003") {
|
|
8100
8192
|
stdin.off("data", onData);
|
|
8101
|
-
rejectPromise(new Error(
|
|
8193
|
+
rejectPromise(new Error(messages.cancelled));
|
|
8102
8194
|
return;
|
|
8103
8195
|
}
|
|
8104
8196
|
if (character === "\u007f" || character === "\b") {
|
|
8197
|
+
if (options.rawEcho && value)
|
|
8198
|
+
process.stderr.write("\b \b");
|
|
8105
8199
|
value = value.slice(0, -1);
|
|
8106
8200
|
}
|
|
8107
8201
|
else {
|
|
8202
|
+
if (options.rawEcho)
|
|
8203
|
+
process.stderr.write(character);
|
|
8108
8204
|
value += character;
|
|
8109
8205
|
}
|
|
8110
8206
|
}
|
|
@@ -8117,6 +8213,14 @@ async function promptForLocalFilesValue(question, secret = false, context = "Min
|
|
|
8117
8213
|
stdin.pause();
|
|
8118
8214
|
}
|
|
8119
8215
|
}
|
|
8216
|
+
function promptForLocalFilesValue(question, secret = false, context = "MinIO") {
|
|
8217
|
+
return promptForTerminalValue(question, secret, {
|
|
8218
|
+
cancelled: `${context} setup was cancelled.`,
|
|
8219
|
+
notInteractive: context === "MinIO"
|
|
8220
|
+
? "MinIO admin credentials are required. Run interactively or set MINIO_ROOT_USER and MINIO_ROOT_PASSWORD in the command environment."
|
|
8221
|
+
: "PostgreSQL admin credentials are required. Run interactively or set LOOM_DB_LOCAL_ADMIN_PASSWORD in the command environment.",
|
|
8222
|
+
});
|
|
8223
|
+
}
|
|
8120
8224
|
function minioHostEnv(env, endpoint, accessKey, secretKey) {
|
|
8121
8225
|
const url = new URL(endpoint);
|
|
8122
8226
|
url.username = accessKey;
|
|
@@ -8774,6 +8878,12 @@ export async function setupCloudflareR2(cwd, options = {}) {
|
|
|
8774
8878
|
throw new Error(`Could not inspect existing non-secret Files values in Vercel ${environment}.`);
|
|
8775
8879
|
}
|
|
8776
8880
|
const drift = existingNonSecretNames.filter((name) => actualValues[name] !== nonSecretValues[name]);
|
|
8881
|
+
const storedAsSecrets = drift.length
|
|
8882
|
+
? await findVercelFilesValuesStoredAsSecrets(cwd, commandRunner, providerEnv, vercelCli.command, environment, ["env", "ls", environment], drift)
|
|
8883
|
+
: null;
|
|
8884
|
+
if (storedAsSecrets?.length) {
|
|
8885
|
+
throw new Error(`${filesSecretTypeProblem(environment, storedAsSecrets)} ${filesSecretTypeFix(environment)}`);
|
|
8886
|
+
}
|
|
8777
8887
|
if (drift.length && !options.repair) {
|
|
8778
8888
|
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.`);
|
|
8779
8889
|
}
|
|
@@ -8783,7 +8893,11 @@ export async function setupCloudflareR2(cwd, options = {}) {
|
|
|
8783
8893
|
}
|
|
8784
8894
|
for (const [name, value] of Object.entries(nonSecretValues)) {
|
|
8785
8895
|
if (!hasExactEnvName(listing, name)) {
|
|
8786
|
-
await addVercelEnvValue(cwd, commandRunner, providerEnv, vercelCli.command, name, value, environment
|
|
8896
|
+
await addVercelEnvValue(cwd, commandRunner, providerEnv, vercelCli.command, name, value, environment,
|
|
8897
|
+
// Vercel CLI stores a Production or Preview value read from
|
|
8898
|
+
// stdin as a Secret unless told otherwise, and the env-run probe
|
|
8899
|
+
// and release env policies must be able to read these back.
|
|
8900
|
+
["--no-sensitive", "--yes"]);
|
|
8787
8901
|
listing += `\n${name}`;
|
|
8788
8902
|
}
|
|
8789
8903
|
}
|
|
@@ -8891,6 +9005,9 @@ async function readVercelProjectLink(cwd) {
|
|
|
8891
9005
|
linked: true,
|
|
8892
9006
|
orgId,
|
|
8893
9007
|
projectId,
|
|
9008
|
+
projectName: typeof project.projectName === "string"
|
|
9009
|
+
? project.projectName
|
|
9010
|
+
: null,
|
|
8894
9011
|
relativePath,
|
|
8895
9012
|
};
|
|
8896
9013
|
}
|
|
@@ -9813,6 +9930,23 @@ function checkFilesNetworkFeature(context) {
|
|
|
9813
9930
|
FILES_S3_FORCE_PATH_STYLE: String(provider.forcePathStyle ?? false),
|
|
9814
9931
|
};
|
|
9815
9932
|
const drift = Object.entries(expectedValues).filter(([name, value]) => actualValues[name] !== value).map(([name]) => name);
|
|
9933
|
+
const storedAsSecrets = drift.length
|
|
9934
|
+
? await findVercelFilesValuesStoredAsSecrets(context.cwd, context.commandRunner, withoutInheritedVercelProject(context.env), state.vercelCommand, environment, buildVercelFilesEnvListArgs(environment, state.vercelProject), drift)
|
|
9935
|
+
: null;
|
|
9936
|
+
if (storedAsSecrets?.length) {
|
|
9937
|
+
const otherDrift = drift.filter((name) => !storedAsSecrets.includes(name));
|
|
9938
|
+
return networkCheckResult("issue", `Vercel ${environment} stores non-secret Files values as Secrets: ${storedAsSecrets.join(", ")}.`, {
|
|
9939
|
+
issues: [
|
|
9940
|
+
filesSecretTypeProblem(environment, storedAsSecrets),
|
|
9941
|
+
...(otherDrift.length
|
|
9942
|
+
? [
|
|
9943
|
+
`Vercel ${environment} has incompatible non-secret Files R2 values: ${otherDrift.join(", ")}.`,
|
|
9944
|
+
]
|
|
9945
|
+
: []),
|
|
9946
|
+
],
|
|
9947
|
+
suggestions: [filesSecretTypeFix(environment)],
|
|
9948
|
+
});
|
|
9949
|
+
}
|
|
9816
9950
|
return drift.length
|
|
9817
9951
|
? networkCheckResult("issue", `Vercel ${environment} Files values drift from loom.json: ${drift.join(", ")}.`, {
|
|
9818
9952
|
issues: [
|
|
@@ -10595,6 +10729,216 @@ async function applyAuthFeature(cwd, framework, manifest, activate) {
|
|
|
10595
10729
|
}
|
|
10596
10730
|
return { changedFiles, notes };
|
|
10597
10731
|
}
|
|
10732
|
+
/**
|
|
10733
|
+
* Whether a failed Git command failed because there is no repository, in
|
|
10734
|
+
* which case no file is tracked. The message is matched because Git uses the
|
|
10735
|
+
* same exit status (128) for failures that are not an answer at all.
|
|
10736
|
+
*/
|
|
10737
|
+
function isNotAGitRepository(result) {
|
|
10738
|
+
return result.code !== 0 && /not a git repository/i.test(result.stderr);
|
|
10739
|
+
}
|
|
10740
|
+
function secretsModuleTemplate(config) {
|
|
10741
|
+
return `import { createNextSecrets } from "@gadicc/loom/next/secrets";
|
|
10742
|
+
|
|
10743
|
+
import loomManifest from "${toRelativeImportPath(config.modules.secretsModule, "loom.json")}";
|
|
10744
|
+
|
|
10745
|
+
const config = loomManifest.features.secrets.config;
|
|
10746
|
+
|
|
10747
|
+
// loom.json records the fingerprint of every key a deployed environment is
|
|
10748
|
+
// expected to hold, so a key that differs from the saved copy is refused.
|
|
10749
|
+
export const secrets = createNextSecrets({
|
|
10750
|
+
expectedKeys: config.keys,
|
|
10751
|
+
variables: config.env,
|
|
10752
|
+
});
|
|
10753
|
+
|
|
10754
|
+
// Declare one purpose per kind of secret, beside the code that uses it:
|
|
10755
|
+
//
|
|
10756
|
+
// export const thingSecret = secrets.purpose("area.thing");
|
|
10757
|
+
//
|
|
10758
|
+
// A purpose name and its binding are permanent: a value sealed under them can
|
|
10759
|
+
// never be opened under different ones.
|
|
10760
|
+
`;
|
|
10761
|
+
}
|
|
10762
|
+
function secretLocationsModuleTemplate() {
|
|
10763
|
+
return `import { defineSecretLocations } from "@gadicc/loom/secrets/maintenance";
|
|
10764
|
+
|
|
10765
|
+
// Every column that holds a sealed string must be declared here. The
|
|
10766
|
+
// maintenance operations (report, verify, reseal) only reach declared
|
|
10767
|
+
// locations, so an undeclared column is never re-encrypted and keeps its old
|
|
10768
|
+
// key in use without anyone noticing.
|
|
10769
|
+
export const secretLocations = defineSecretLocations([]);
|
|
10770
|
+
`;
|
|
10771
|
+
}
|
|
10772
|
+
/**
|
|
10773
|
+
* The normalised config laid over what loom.json already holds, so that a
|
|
10774
|
+
* property Loom does not know (under `config` or one of its sections) is
|
|
10775
|
+
* kept instead of being dropped by a rewrite.
|
|
10776
|
+
*/
|
|
10777
|
+
function mergeSecretsConfig(existing, config) {
|
|
10778
|
+
const current = isJsonObject(existing) ? existing : {};
|
|
10779
|
+
const section = (name) => ({
|
|
10780
|
+
...(isJsonObject(current[name]) ? current[name] : {}),
|
|
10781
|
+
...config[name],
|
|
10782
|
+
});
|
|
10783
|
+
return {
|
|
10784
|
+
...current,
|
|
10785
|
+
modules: section("modules"),
|
|
10786
|
+
env: section("env"),
|
|
10787
|
+
keys: section("keys"),
|
|
10788
|
+
};
|
|
10789
|
+
}
|
|
10790
|
+
/**
|
|
10791
|
+
* Gives a new checkout a working development key: writes a random key and the
|
|
10792
|
+
* pointer to gitignored `.env.local` when it holds neither. An existing
|
|
10793
|
+
* variable is never changed, and the key is never returned or reported.
|
|
10794
|
+
*/
|
|
10795
|
+
async function ensureLocalSecretsKey(cwd, config, commandRunner) {
|
|
10796
|
+
const changedFiles = [];
|
|
10797
|
+
const { activeKeyName, keyPrefix } = config.env;
|
|
10798
|
+
const envPath = join(cwd, ".env.local");
|
|
10799
|
+
const envText = await readTextIfExists(envPath);
|
|
10800
|
+
const existingName = [...readEnvAssignments(envText ?? "").keys()].find((name) => name === activeKeyName || name.startsWith(keyPrefix));
|
|
10801
|
+
if (existingName !== undefined) {
|
|
10802
|
+
return {
|
|
10803
|
+
changedFiles,
|
|
10804
|
+
notes: [
|
|
10805
|
+
`No development secrets key was generated: .env.local already sets ${existingName}, and Loom never changes an existing secrets variable.`,
|
|
10806
|
+
],
|
|
10807
|
+
};
|
|
10808
|
+
}
|
|
10809
|
+
const tracked = await commandRunner("git", [
|
|
10810
|
+
"ls-files",
|
|
10811
|
+
"--error-unmatch",
|
|
10812
|
+
"--",
|
|
10813
|
+
".env.local",
|
|
10814
|
+
], { cwd, stdio: "pipe" });
|
|
10815
|
+
if (tracked.code === 0) {
|
|
10816
|
+
return {
|
|
10817
|
+
changedFiles,
|
|
10818
|
+
notes: [
|
|
10819
|
+
"No development secrets key was written: .env.local is tracked by Git. Remove it from the index, then rerun `loom add secrets`.",
|
|
10820
|
+
],
|
|
10821
|
+
};
|
|
10822
|
+
}
|
|
10823
|
+
// Exit 1 is Git's answer that the file is untracked, and outside a
|
|
10824
|
+
// repository nothing can be tracked. Any other failure is not an answer.
|
|
10825
|
+
if (tracked.code !== 1 && !isNotAGitRepository(tracked)) {
|
|
10826
|
+
return {
|
|
10827
|
+
changedFiles,
|
|
10828
|
+
notes: [
|
|
10829
|
+
"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.",
|
|
10830
|
+
],
|
|
10831
|
+
};
|
|
10832
|
+
}
|
|
10833
|
+
let envFileExists = true;
|
|
10834
|
+
try {
|
|
10835
|
+
if ((await lstat(envPath)).isSymbolicLink()) {
|
|
10836
|
+
return {
|
|
10837
|
+
changedFiles,
|
|
10838
|
+
notes: [
|
|
10839
|
+
"No development secrets key was written: .env.local is a symlink, and Loom will not write a key through it.",
|
|
10840
|
+
],
|
|
10841
|
+
};
|
|
10842
|
+
}
|
|
10843
|
+
}
|
|
10844
|
+
catch (error) {
|
|
10845
|
+
if (!isNodeErrorCode(error, "ENOENT"))
|
|
10846
|
+
throw error;
|
|
10847
|
+
envFileExists = false;
|
|
10848
|
+
}
|
|
10849
|
+
const keyName = `${keyPrefix}1`;
|
|
10850
|
+
const merged = mergeEnvValues(envText, {
|
|
10851
|
+
[keyName]: toBase64Url(globalThis.crypto.getRandomValues(new Uint8Array(SECRETS_KEY_BYTES))),
|
|
10852
|
+
[activeKeyName]: "1",
|
|
10853
|
+
// Lets a production build run locally (`next start`): without it the
|
|
10854
|
+
// wrapper cannot tell this machine from an unidentified production host
|
|
10855
|
+
// once fingerprints are recorded, and refuses.
|
|
10856
|
+
[SECRETS_ENVIRONMENT_ENV]: "development",
|
|
10857
|
+
});
|
|
10858
|
+
// Ignored before the key exists on disk, so it is never an untracked file
|
|
10859
|
+
// that a broad `git add` would pick up. Git is asked first, because a rule
|
|
10860
|
+
// such as `.env*` already covers it; when Git cannot answer, the rule is
|
|
10861
|
+
// appended unless it is already the last one.
|
|
10862
|
+
const ignored = await commandRunner("git", [
|
|
10863
|
+
"check-ignore",
|
|
10864
|
+
"-q",
|
|
10865
|
+
"--",
|
|
10866
|
+
".env.local",
|
|
10867
|
+
], { cwd, stdio: "pipe" });
|
|
10868
|
+
if (ignored.code !== 0) {
|
|
10869
|
+
const gitignorePath = join(cwd, ".gitignore");
|
|
10870
|
+
const gitignore = await readTextIfExists(gitignorePath) ?? "";
|
|
10871
|
+
const lastIgnoreRule = normalizeText(gitignore).split("\n")
|
|
10872
|
+
.map((line) => line.trim()).filter(Boolean).at(-1);
|
|
10873
|
+
if (lastIgnoreRule !== ".env.local" && lastIgnoreRule !== "/.env.local") {
|
|
10874
|
+
if (await writeTextIfChanged(gitignorePath, `${gitignore && !gitignore.endsWith("\n")
|
|
10875
|
+
? `${gitignore}\n`
|
|
10876
|
+
: gitignore}.env.local\n`))
|
|
10877
|
+
changedFiles.push(".gitignore");
|
|
10878
|
+
}
|
|
10879
|
+
}
|
|
10880
|
+
// An existing file keeps its mode when it is rewritten, so it is made
|
|
10881
|
+
// owner-only before the key is in it, not after.
|
|
10882
|
+
if (envFileExists)
|
|
10883
|
+
await chmod(envPath, 0o600);
|
|
10884
|
+
await writeFile(envPath, merged.text, { mode: 0o600 });
|
|
10885
|
+
await chmod(envPath, 0o600);
|
|
10886
|
+
changedFiles.push(".env.local");
|
|
10887
|
+
return {
|
|
10888
|
+
changedFiles,
|
|
10889
|
+
notes: [
|
|
10890
|
+
`Wrote a development secrets key to .env.local (${merged.changedNames.join(", ")}). It is for this machine only and was not printed.${merged.conflicts.length
|
|
10891
|
+
? ` Left unchanged: ${merged.conflicts.join(", ")}.`
|
|
10892
|
+
: ""}`,
|
|
10893
|
+
],
|
|
10894
|
+
};
|
|
10895
|
+
}
|
|
10896
|
+
async function applySecretsFeature(cwd, framework, manifest, activate, options = {}) {
|
|
10897
|
+
const changedFiles = [];
|
|
10898
|
+
const notes = [];
|
|
10899
|
+
const currentFeature = manifest.features.secrets;
|
|
10900
|
+
if (!activate && currentFeature?.status !== "active") {
|
|
10901
|
+
return { changedFiles, notes };
|
|
10902
|
+
}
|
|
10903
|
+
const config = getSecretsConfig(framework, currentFeature?.config);
|
|
10904
|
+
const feature = currentFeature
|
|
10905
|
+
? structuredClone(currentFeature)
|
|
10906
|
+
: { status: "planned" };
|
|
10907
|
+
if (activate && feature.status !== "active") {
|
|
10908
|
+
feature.status = "active";
|
|
10909
|
+
feature.activatedOn ??= todayIso();
|
|
10910
|
+
}
|
|
10911
|
+
const scaffolds = [
|
|
10912
|
+
[config.modules.secretsModule, secretsModuleTemplate(config), "module"],
|
|
10913
|
+
[
|
|
10914
|
+
config.modules.locationsModule,
|
|
10915
|
+
secretLocationsModuleTemplate(),
|
|
10916
|
+
"locations module",
|
|
10917
|
+
],
|
|
10918
|
+
];
|
|
10919
|
+
for (const [relativePath, text, label] of scaffolds) {
|
|
10920
|
+
const scaffoldState = await scaffoldTextFile(join(cwd, relativePath), text);
|
|
10921
|
+
if (scaffoldState === "created") {
|
|
10922
|
+
changedFiles.push(relativePath);
|
|
10923
|
+
}
|
|
10924
|
+
else if (activate && scaffoldState === "preserved") {
|
|
10925
|
+
notes.push(`Preserved existing secrets ${label}: ${relativePath}`);
|
|
10926
|
+
}
|
|
10927
|
+
}
|
|
10928
|
+
// Only an explicit `loom add secrets` may create a key; `loom init` reruns
|
|
10929
|
+
// this hook for every active feature and must never write one.
|
|
10930
|
+
if (activate) {
|
|
10931
|
+
const localKey = await ensureLocalSecretsKey(cwd, config, options.commandRunner ?? defaultCommandRunner);
|
|
10932
|
+
changedFiles.push(...localKey.changedFiles);
|
|
10933
|
+
notes.push(...localKey.notes);
|
|
10934
|
+
if (!Array.isArray(config.keys.production) || !config.keys.production.length) {
|
|
10935
|
+
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.");
|
|
10936
|
+
}
|
|
10937
|
+
}
|
|
10938
|
+
feature.config = mergeSecretsConfig(currentFeature?.config, config);
|
|
10939
|
+
manifest.features.secrets = feature;
|
|
10940
|
+
return { changedFiles, notes };
|
|
10941
|
+
}
|
|
10598
10942
|
function linguiCliCommand(tooling) {
|
|
10599
10943
|
switch (tooling.dependencies.manager) {
|
|
10600
10944
|
case "deno":
|
|
@@ -13335,6 +13679,165 @@ async function checkPwaFeature(cwd, framework, manifest) {
|
|
|
13335
13679
|
warnings,
|
|
13336
13680
|
};
|
|
13337
13681
|
}
|
|
13682
|
+
const VERCEL_PRODUCTION_ENV_POLICY_PATH = ".github/vercel-production-env.json";
|
|
13683
|
+
/**
|
|
13684
|
+
* Escapes text for use as a literal in a regular expression, in a form both
|
|
13685
|
+
* JavaScript and POSIX extended syntax (`git grep -E`) read the same way.
|
|
13686
|
+
*/
|
|
13687
|
+
function escapeExtendedRegex(text) {
|
|
13688
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13689
|
+
}
|
|
13690
|
+
async function checkSecretsFeature(cwd, framework, manifest, options) {
|
|
13691
|
+
const issues = [];
|
|
13692
|
+
const warnings = [];
|
|
13693
|
+
const suggestions = new Set();
|
|
13694
|
+
const feature = manifest.features.secrets;
|
|
13695
|
+
if (!feature || feature.status !== "active") {
|
|
13696
|
+
return { issues, suggestions: [], warnings };
|
|
13697
|
+
}
|
|
13698
|
+
const releaseBlocking = (message) => {
|
|
13699
|
+
if (options.production)
|
|
13700
|
+
issues.push(message);
|
|
13701
|
+
else
|
|
13702
|
+
warnings.push(message);
|
|
13703
|
+
};
|
|
13704
|
+
const config = getSecretsConfig(framework, feature.config);
|
|
13705
|
+
const { activeKeyName, keyPrefix } = config.env;
|
|
13706
|
+
const moduleChecks = [
|
|
13707
|
+
[
|
|
13708
|
+
config.modules.secretsModule,
|
|
13709
|
+
"Secrets module",
|
|
13710
|
+
// A Next.js app must use the wrapper: the core entry point has no
|
|
13711
|
+
// build-phase refusal and no environment-selected key list.
|
|
13712
|
+
framework.kind === "nextjs"
|
|
13713
|
+
? /["']@gadicc\/loom\/next\/secrets["']/
|
|
13714
|
+
: /["']@gadicc\/loom\/(?:next\/)?secrets["']/,
|
|
13715
|
+
"is not wired to @gadicc/loom/next/secrets",
|
|
13716
|
+
],
|
|
13717
|
+
[
|
|
13718
|
+
config.modules.locationsModule,
|
|
13719
|
+
"Secret locations module",
|
|
13720
|
+
/\bdefineSecretLocations\b/,
|
|
13721
|
+
"does not declare its locations with defineSecretLocations",
|
|
13722
|
+
],
|
|
13723
|
+
];
|
|
13724
|
+
for (const [relativePath, label, pattern, problem] of moduleChecks) {
|
|
13725
|
+
const text = await readTextIfExists(join(cwd, relativePath));
|
|
13726
|
+
if (text === null) {
|
|
13727
|
+
issues.push(`${label} is missing: ${relativePath}`);
|
|
13728
|
+
suggestions.add("Run `loom add secrets`.");
|
|
13729
|
+
}
|
|
13730
|
+
else if (!pattern.test(text)) {
|
|
13731
|
+
issues.push(`${label} ${problem}: ${relativePath}`);
|
|
13732
|
+
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.");
|
|
13733
|
+
}
|
|
13734
|
+
}
|
|
13735
|
+
for (const environment of ["production", "preview"]) {
|
|
13736
|
+
const recorded = config.keys[environment];
|
|
13737
|
+
if (recorded === undefined)
|
|
13738
|
+
continue;
|
|
13739
|
+
if (Array.isArray(recorded) && recorded.length === 0)
|
|
13740
|
+
continue;
|
|
13741
|
+
try {
|
|
13742
|
+
parseExpectedSecretKeys(recorded);
|
|
13743
|
+
}
|
|
13744
|
+
catch (error) {
|
|
13745
|
+
issues.push(`Secrets ${environment} key list in loom.json is invalid: ${error.message}`);
|
|
13746
|
+
suggestions.add("Correct features.secrets.config.keys in loom.json; `loom secrets keygen`, `activate` and `retire` keep it valid.");
|
|
13747
|
+
}
|
|
13748
|
+
}
|
|
13749
|
+
// Every tracked file is searched, not only root `.env*` files: a key is as
|
|
13750
|
+
// exposed in `deploy/.env.production` or a compose file. The pattern finds
|
|
13751
|
+
// candidates; only a value that decodes as a key is reported, so an
|
|
13752
|
+
// example file's placeholder is not. The pattern ends at the value's end,
|
|
13753
|
+
// so the first 43 characters of a longer value are not taken for a key.
|
|
13754
|
+
const keyAssignment = `${escapeExtendedRegex(keyPrefix)}[1-9][0-9]{0,8}["']?[[:space:]]*[=:][[:space:]]*["']?[A-Za-z0-9+/_-]{43}=?([^A-Za-z0-9+/_=-]|$)`;
|
|
13755
|
+
const gitResult = await (options.commandRunner ?? defaultCommandRunner)("git", ["grep", "-I", "--null", "-o", "-E", "-e", keyAssignment], { cwd, stdio: "pipe" });
|
|
13756
|
+
if (gitResult.code === 0) {
|
|
13757
|
+
const reported = new Set();
|
|
13758
|
+
for (const line of gitResult.stdout.split(/\r?\n/)) {
|
|
13759
|
+
const separator = line.indexOf("\0");
|
|
13760
|
+
if (separator < 0)
|
|
13761
|
+
continue;
|
|
13762
|
+
const relativePath = line.slice(0, separator);
|
|
13763
|
+
const match = line.slice(separator + 1).match(/^(.*?)["']?\s*[=:]\s*["']?([A-Za-z0-9+/_-]{43}=?)[^A-Za-z0-9+/_=-]?$/);
|
|
13764
|
+
if (!match)
|
|
13765
|
+
continue;
|
|
13766
|
+
const [, name, candidate] = match;
|
|
13767
|
+
try {
|
|
13768
|
+
decodeSecretKey(candidate, name);
|
|
13769
|
+
}
|
|
13770
|
+
catch {
|
|
13771
|
+
continue;
|
|
13772
|
+
}
|
|
13773
|
+
// Names the file and the variable only; the value must not reach a log.
|
|
13774
|
+
const issue = `A secrets key value is committed in a git-tracked file: ${relativePath} (${name})`;
|
|
13775
|
+
if (reported.has(issue))
|
|
13776
|
+
continue;
|
|
13777
|
+
reported.add(issue);
|
|
13778
|
+
issues.push(issue);
|
|
13779
|
+
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.");
|
|
13780
|
+
}
|
|
13781
|
+
}
|
|
13782
|
+
else if (gitResult.code !== 1 && !isNotAGitRepository(gitResult)) {
|
|
13783
|
+
// Exit 1 means no match and, outside a repository, nothing is tracked.
|
|
13784
|
+
// Anything else means the search did not happen, which is not "clean".
|
|
13785
|
+
releaseBlocking("Git-tracked files could not be checked for a committed secrets key: `git grep` failed.");
|
|
13786
|
+
suggestions.add("Make sure Git is installed and `git grep` works in this project, then rerun `loom check`.");
|
|
13787
|
+
}
|
|
13788
|
+
if (Array.isArray(config.keys.production) && config.keys.production.length === 0) {
|
|
13789
|
+
releaseBlocking("No production secrets key is recorded in loom.json, so production would run with unverified keys.");
|
|
13790
|
+
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.");
|
|
13791
|
+
}
|
|
13792
|
+
const policyText = await readTextIfExists(join(cwd, VERCEL_PRODUCTION_ENV_POLICY_PATH));
|
|
13793
|
+
if (policyText !== null) {
|
|
13794
|
+
let covered = false;
|
|
13795
|
+
// True until the policy has been read, so that an unreadable policy is
|
|
13796
|
+
// reported once and not also as a missing pointer.
|
|
13797
|
+
let pointerRequired = true;
|
|
13798
|
+
let problem = `has no requirement that covers the secrets keys (${keyPrefix}<n>) as Production-only Sensitive variables`;
|
|
13799
|
+
try {
|
|
13800
|
+
const requirements = parseVercelBuildEnvironmentPolicy(parseJson(policyText, VERCEL_PRODUCTION_ENV_POLICY_PATH));
|
|
13801
|
+
pointerRequired = requirements.some((requirement) => requirement.keys.includes(activeKeyName));
|
|
13802
|
+
covered = requirements.some((requirement) => requirement.keyPattern !== undefined &&
|
|
13803
|
+
// Several versions, so a pattern written for one key (`..._1$`) or
|
|
13804
|
+
// for a single digit does not pass for the keys that follow it.
|
|
13805
|
+
[1, 2, 10].every((version) => requirement.matches(`${keyPrefix}${version}`)) && requirement.sensitive && requirement.productionOnly);
|
|
13806
|
+
}
|
|
13807
|
+
catch (error) {
|
|
13808
|
+
problem = `could not be read: ${error.message}`;
|
|
13809
|
+
}
|
|
13810
|
+
if (!covered) {
|
|
13811
|
+
releaseBlocking(`Vercel release policy ${VERCEL_PRODUCTION_ENV_POLICY_PATH} ${problem}.`);
|
|
13812
|
+
}
|
|
13813
|
+
if (!pointerRequired) {
|
|
13814
|
+
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.`);
|
|
13815
|
+
}
|
|
13816
|
+
if (!covered || !pointerRequired) {
|
|
13817
|
+
// Serialised as JSON so that a name with a character that needs
|
|
13818
|
+
// escaping, in the pattern or in the string, can be pasted as it is.
|
|
13819
|
+
// Both are shown whichever is missing: the policy needs the pair.
|
|
13820
|
+
const suggestedKeys = JSON.stringify({
|
|
13821
|
+
name: "secrets keys",
|
|
13822
|
+
keyPattern: `^${escapeExtendedRegex(keyPrefix)}[1-9][0-9]*$`,
|
|
13823
|
+
sensitive: true,
|
|
13824
|
+
productionOnly: true,
|
|
13825
|
+
placeholder: { kind: "secret" },
|
|
13826
|
+
});
|
|
13827
|
+
// The pointer is a readable variable, so it is not marked sensitive.
|
|
13828
|
+
const suggestedPointer = JSON.stringify({
|
|
13829
|
+
name: "secrets active key pointer",
|
|
13830
|
+
keys: [activeKeyName],
|
|
13831
|
+
});
|
|
13832
|
+
suggestions.add(`Add requirements such as ${suggestedKeys} and ${suggestedPointer} to ${VERCEL_PRODUCTION_ENV_POLICY_PATH}.`);
|
|
13833
|
+
}
|
|
13834
|
+
}
|
|
13835
|
+
return {
|
|
13836
|
+
issues,
|
|
13837
|
+
suggestions: [...suggestions],
|
|
13838
|
+
warnings,
|
|
13839
|
+
};
|
|
13840
|
+
}
|
|
13338
13841
|
const featureHooks = {
|
|
13339
13842
|
"api-keys": {
|
|
13340
13843
|
apply: applyApiKeysFeature,
|
|
@@ -13370,6 +13873,10 @@ const featureHooks = {
|
|
|
13370
13873
|
apply: applyPwaFeature,
|
|
13371
13874
|
check: checkPwaFeature,
|
|
13372
13875
|
},
|
|
13876
|
+
secrets: {
|
|
13877
|
+
apply: applySecretsFeature,
|
|
13878
|
+
check: checkSecretsFeature,
|
|
13879
|
+
},
|
|
13373
13880
|
};
|
|
13374
13881
|
async function ensureActiveFeatureScaffolds(cwd, framework, manifest) {
|
|
13375
13882
|
const changedFiles = [];
|
|
@@ -13471,13 +13978,13 @@ export async function initProject(cwd, versionRange) {
|
|
|
13471
13978
|
.packageJson,
|
|
13472
13979
|
};
|
|
13473
13980
|
}
|
|
13474
|
-
export async function addFeature(cwd, featureKey, versionRange) {
|
|
13981
|
+
export async function addFeature(cwd, featureKey, versionRange, options = {}) {
|
|
13475
13982
|
const hook = featureHooks[featureKey];
|
|
13476
13983
|
if (!hook) {
|
|
13477
13984
|
throw new Error(`Unknown feature: ${featureKey}`);
|
|
13478
13985
|
}
|
|
13479
13986
|
const base = await initProject(cwd, versionRange);
|
|
13480
|
-
const result = await hook.apply(cwd, base.framework, base.manifest, true);
|
|
13987
|
+
const result = await hook.apply(cwd, base.framework, base.manifest, true, options);
|
|
13481
13988
|
const skillSync = await ensureManagedSkillLinks(cwd, base.manifest);
|
|
13482
13989
|
const changedFiles = [
|
|
13483
13990
|
...base.changedFiles,
|
|
@@ -13493,6 +14000,218 @@ export async function addFeature(cwd, featureKey, versionRange) {
|
|
|
13493
14000
|
notes: [...new Set(notes)],
|
|
13494
14001
|
};
|
|
13495
14002
|
}
|
|
14003
|
+
async function readActiveSecretsFeature(cwd) {
|
|
14004
|
+
const manifest = await readManifestIfExists(cwd);
|
|
14005
|
+
if (!manifest) {
|
|
14006
|
+
throw new Error("Missing loom.json. Run `loom add secrets` first.");
|
|
14007
|
+
}
|
|
14008
|
+
const feature = manifest.features.secrets;
|
|
14009
|
+
if (feature?.status !== "active") {
|
|
14010
|
+
throw new Error("The secrets feature is not active. Run `loom add secrets` first.");
|
|
14011
|
+
}
|
|
14012
|
+
const framework = manifest.project?.framework ??
|
|
14013
|
+
await detectFramework(cwd, (await readProjectPackageJson(cwd)).packageJson);
|
|
14014
|
+
const config = getSecretsConfig(framework, feature.config);
|
|
14015
|
+
return { config, feature, manifest };
|
|
14016
|
+
}
|
|
14017
|
+
function recordedSecretKeys(config, environment) {
|
|
14018
|
+
const recorded = config.keys[environment] ?? [];
|
|
14019
|
+
if (!Array.isArray(recorded)) {
|
|
14020
|
+
throw new Error(`features.secrets.config.keys.${environment} in loom.json must be a list.`);
|
|
14021
|
+
}
|
|
14022
|
+
return recorded;
|
|
14023
|
+
}
|
|
14024
|
+
/** Validates a changed key list, then records it in loom.json. */
|
|
14025
|
+
function validateSecretKeys(environment, keys) {
|
|
14026
|
+
if (!keys.length)
|
|
14027
|
+
return;
|
|
14028
|
+
try {
|
|
14029
|
+
parseExpectedSecretKeys(keys);
|
|
14030
|
+
}
|
|
14031
|
+
catch (error) {
|
|
14032
|
+
throw new Error(`The ${environment} key list in loom.json would be invalid: ${error.message}`);
|
|
14033
|
+
}
|
|
14034
|
+
}
|
|
14035
|
+
async function writeSecretKeys(cwd, loaded, environment, keys) {
|
|
14036
|
+
validateSecretKeys(environment, keys);
|
|
14037
|
+
// Replaces this one list and nothing else: any other property a user keeps
|
|
14038
|
+
// under `config` or `config.keys` is theirs, and stays.
|
|
14039
|
+
const existing = isJsonObject(loaded.feature.config)
|
|
14040
|
+
? loaded.feature.config
|
|
14041
|
+
: {};
|
|
14042
|
+
loaded.feature.config = {
|
|
14043
|
+
...existing,
|
|
14044
|
+
keys: {
|
|
14045
|
+
...(isJsonObject(existing.keys) ? existing.keys : {}),
|
|
14046
|
+
[environment]: keys,
|
|
14047
|
+
},
|
|
14048
|
+
};
|
|
14049
|
+
loaded.manifest.features.secrets = loaded.feature;
|
|
14050
|
+
return await writeManifestIfChanged(cwd, loaded.manifest)
|
|
14051
|
+
? ["loom.json"]
|
|
14052
|
+
: [];
|
|
14053
|
+
}
|
|
14054
|
+
function nextSecretsKey(config, environment) {
|
|
14055
|
+
const current = recordedSecretKeys(config, environment);
|
|
14056
|
+
const id = current.reduce((highest, key) => isSecretKeyId(key?.id) ? Math.max(highest, key.id) : highest, 0) + 1;
|
|
14057
|
+
const state = current.some((key) => key?.state === "active")
|
|
14058
|
+
? "decrypt-only"
|
|
14059
|
+
: "active";
|
|
14060
|
+
return { current, id, state };
|
|
14061
|
+
}
|
|
14062
|
+
/**
|
|
14063
|
+
* The version, state and variable names `generateSecretsKey` would use next,
|
|
14064
|
+
* without generating or recording anything.
|
|
14065
|
+
*/
|
|
14066
|
+
export async function planSecretsKey(cwd, environment = "production") {
|
|
14067
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14068
|
+
const { id, state } = nextSecretsKey(loaded.config, environment);
|
|
14069
|
+
return {
|
|
14070
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14071
|
+
id,
|
|
14072
|
+
state,
|
|
14073
|
+
variableName: `${loaded.config.env.keyPrefix}${id}`,
|
|
14074
|
+
};
|
|
14075
|
+
}
|
|
14076
|
+
/**
|
|
14077
|
+
* A recorded key that is not retired, with its variable names, for putting it
|
|
14078
|
+
* on a deployment platform. Refuses a version that is not listed or retired.
|
|
14079
|
+
*/
|
|
14080
|
+
export async function recordedSecretsKey(cwd, id, environment = "production") {
|
|
14081
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14082
|
+
const key = recordedSecretKeys(loaded.config, environment).find((entry) => entry?.id === id);
|
|
14083
|
+
if (!key) {
|
|
14084
|
+
throw new Error(`Key version ${id} is not listed for ${environment} in loom.json.`);
|
|
14085
|
+
}
|
|
14086
|
+
if (key.state === "retired") {
|
|
14087
|
+
throw new Error(`Key version ${id} is retired for ${environment}.`);
|
|
14088
|
+
}
|
|
14089
|
+
return {
|
|
14090
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14091
|
+
fingerprint: key.fingerprint,
|
|
14092
|
+
id,
|
|
14093
|
+
state: key.state,
|
|
14094
|
+
variableName: `${loaded.config.env.keyPrefix}${id}`,
|
|
14095
|
+
};
|
|
14096
|
+
}
|
|
14097
|
+
/**
|
|
14098
|
+
* Generates a key for a deployed environment and records its fingerprint in
|
|
14099
|
+
* loom.json: `active` when the environment has no active key, otherwise
|
|
14100
|
+
* `decrypt-only`. The version is one above the highest ever listed, so a
|
|
14101
|
+
* retired version is never reused. It always records: an unrecorded key
|
|
14102
|
+
* would let the next run give the same version to a different key.
|
|
14103
|
+
*
|
|
14104
|
+
* The returned `assignment` contains the key. A caller shows it once, to a
|
|
14105
|
+
* person at a terminal, and never logs or stores it.
|
|
14106
|
+
*/
|
|
14107
|
+
export async function generateSecretsKey(cwd, options = {}) {
|
|
14108
|
+
const environment = options.environment ?? "production";
|
|
14109
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14110
|
+
const { current, id, state } = nextSecretsKey(loaded.config, environment);
|
|
14111
|
+
const key = globalThis.crypto.getRandomValues(new Uint8Array(SECRETS_KEY_BYTES));
|
|
14112
|
+
const fingerprint = await secretKeyFingerprint(key);
|
|
14113
|
+
const changedFiles = await writeSecretKeys(cwd, loaded, environment, [
|
|
14114
|
+
...current,
|
|
14115
|
+
{ id, fingerprint, state },
|
|
14116
|
+
]);
|
|
14117
|
+
const variableName = `${loaded.config.env.keyPrefix}${id}`;
|
|
14118
|
+
return {
|
|
14119
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14120
|
+
assignment: `${variableName}=${toBase64Url(key)}`,
|
|
14121
|
+
changedFiles,
|
|
14122
|
+
environment,
|
|
14123
|
+
fingerprint,
|
|
14124
|
+
id,
|
|
14125
|
+
state,
|
|
14126
|
+
variableName,
|
|
14127
|
+
};
|
|
14128
|
+
}
|
|
14129
|
+
/**
|
|
14130
|
+
* The public fingerprint of a key as an operator typed or pasted it, for
|
|
14131
|
+
* comparing a saved copy with what loom.json records. Errors never include
|
|
14132
|
+
* the key.
|
|
14133
|
+
*/
|
|
14134
|
+
export async function fingerprintSecretsKey(value) {
|
|
14135
|
+
return await secretKeyFingerprint(decodeSecretKey(value, "The entered key"));
|
|
14136
|
+
}
|
|
14137
|
+
/**
|
|
14138
|
+
* Marks a recorded key `active` in loom.json and the previously active key
|
|
14139
|
+
* `decrypt-only`. Refuses a version that is not listed or is retired.
|
|
14140
|
+
*
|
|
14141
|
+
* `beforeWrite` runs once those checks pass and before loom.json changes, so
|
|
14142
|
+
* the platform's pointer can be moved first; if it throws, loom.json is left
|
|
14143
|
+
* as it was.
|
|
14144
|
+
*/
|
|
14145
|
+
export async function activateSecretsKey(cwd, id, environment = "production", options = {}) {
|
|
14146
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14147
|
+
const current = recordedSecretKeys(loaded.config, environment);
|
|
14148
|
+
const target = current.find((key) => key?.id === id);
|
|
14149
|
+
if (!target) {
|
|
14150
|
+
throw new Error(`Key version ${id} is not listed for ${environment} in loom.json.`);
|
|
14151
|
+
}
|
|
14152
|
+
if (target.state === "retired") {
|
|
14153
|
+
throw new Error(`Key version ${id} is retired and cannot be activated. Generate a new key with \`loom secrets keygen\`.`);
|
|
14154
|
+
}
|
|
14155
|
+
const next = current.map((key) => key?.id === id
|
|
14156
|
+
? { ...key, state: "active" }
|
|
14157
|
+
: key?.state === "active"
|
|
14158
|
+
? { ...key, state: "decrypt-only" }
|
|
14159
|
+
: key);
|
|
14160
|
+
// Checked before the hook, which may change a deployment platform: that
|
|
14161
|
+
// must not happen for a list that could not then be written.
|
|
14162
|
+
validateSecretKeys(environment, next);
|
|
14163
|
+
if (!options.beforeWrite) {
|
|
14164
|
+
return {
|
|
14165
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14166
|
+
changedFiles: await writeSecretKeys(cwd, loaded, environment, next),
|
|
14167
|
+
environment,
|
|
14168
|
+
id,
|
|
14169
|
+
};
|
|
14170
|
+
}
|
|
14171
|
+
const changedOutside = await options.beforeWrite({
|
|
14172
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14173
|
+
id,
|
|
14174
|
+
variableName: `${loaded.config.env.keyPrefix}${id}`,
|
|
14175
|
+
});
|
|
14176
|
+
let changedFiles;
|
|
14177
|
+
try {
|
|
14178
|
+
changedFiles = await writeSecretKeys(cwd, loaded, environment, next);
|
|
14179
|
+
}
|
|
14180
|
+
catch (error) {
|
|
14181
|
+
if (!changedOutside)
|
|
14182
|
+
throw error;
|
|
14183
|
+
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.`);
|
|
14184
|
+
}
|
|
14185
|
+
return {
|
|
14186
|
+
activeKeyName: loaded.config.env.activeKeyName,
|
|
14187
|
+
changedFiles,
|
|
14188
|
+
environment,
|
|
14189
|
+
id,
|
|
14190
|
+
};
|
|
14191
|
+
}
|
|
14192
|
+
/**
|
|
14193
|
+
* Marks a recorded key `retired` in loom.json. Refuses the active key and a
|
|
14194
|
+
* version that is not listed. Whether anything still needs the key is the
|
|
14195
|
+
* operator's decision; nothing here can check stored data or backups.
|
|
14196
|
+
*/
|
|
14197
|
+
export async function retireSecretsKey(cwd, id, environment = "production") {
|
|
14198
|
+
const loaded = await readActiveSecretsFeature(cwd);
|
|
14199
|
+
const current = recordedSecretKeys(loaded.config, environment);
|
|
14200
|
+
const target = current.find((key) => key?.id === id);
|
|
14201
|
+
if (!target) {
|
|
14202
|
+
throw new Error(`Key version ${id} is not listed for ${environment} in loom.json.`);
|
|
14203
|
+
}
|
|
14204
|
+
if (target.state === "active") {
|
|
14205
|
+
throw new Error(`Key version ${id} is the active key and cannot be retired. Activate another key with \`loom secrets activate <id>\` first.`);
|
|
14206
|
+
}
|
|
14207
|
+
const changedFiles = await writeSecretKeys(cwd, loaded, environment, current.map((key) => key?.id === id ? { ...key, state: "retired" } : key));
|
|
14208
|
+
return {
|
|
14209
|
+
changedFiles,
|
|
14210
|
+
environment,
|
|
14211
|
+
id,
|
|
14212
|
+
variableName: `${loaded.config.env.keyPrefix}${id}`,
|
|
14213
|
+
};
|
|
14214
|
+
}
|
|
13496
14215
|
function jobsRouteHasAuthorizationCallback(text) {
|
|
13497
14216
|
if (!text)
|
|
13498
14217
|
return false;
|
|
@@ -13595,7 +14314,7 @@ export async function configureApiKeyRetention(cwd, enabled, overrides = {}) {
|
|
|
13595
14314
|
}
|
|
13596
14315
|
export async function addSkills(cwd, versionRange, env = process.env, options = {}) {
|
|
13597
14316
|
const base = await initProject(cwd, versionRange);
|
|
13598
|
-
const skillSync = await syncExternalProjectSkills(cwd, getSkillsContext(base.packageJson, base.manifest), {
|
|
14317
|
+
const skillSync = await syncExternalProjectSkills(cwd, await getSkillsContext(cwd, base.packageJson, base.manifest), {
|
|
13599
14318
|
acceptUnknownLicense: options.acceptUnknownLicense,
|
|
13600
14319
|
adoptRecommended: !options.skillNames?.length,
|
|
13601
14320
|
commandRunner: options.commandRunner ?? defaultCommandRunner,
|
|
@@ -13734,7 +14453,7 @@ export async function checkProject(cwd, env = process.env, options = {}) {
|
|
|
13734
14453
|
suggestions.add(suggestion);
|
|
13735
14454
|
}
|
|
13736
14455
|
}
|
|
13737
|
-
const projectSkillsCheck = await checkProjectSkills(cwd, getSkillsContext(packageJson, manifest), options.strictSkills);
|
|
14456
|
+
const projectSkillsCheck = await checkProjectSkills(cwd, await getSkillsContext(cwd, packageJson, manifest), options.strictSkills);
|
|
13738
14457
|
warnings.push(...projectSkillsCheck.warnings);
|
|
13739
14458
|
issues.push(...projectSkillsCheck.issues);
|
|
13740
14459
|
for (const suggestion of projectSkillsCheck.suggestions) {
|
|
@@ -14271,7 +14990,7 @@ async function runStatus(cwd, io) {
|
|
|
14271
14990
|
managedSkillLines.push(`${skill.skillName}: ${formatSkillLinkState(state)}`);
|
|
14272
14991
|
}
|
|
14273
14992
|
io.out(` managed: ${managedSkillLines.join("; ") || "none"}`);
|
|
14274
|
-
const skillStatus = await getProjectSkillStatus(cwd, getSkillsContext(packageJson, manifest));
|
|
14993
|
+
const skillStatus = await getProjectSkillStatus(cwd, await getSkillsContext(cwd, packageJson, manifest));
|
|
14275
14994
|
const packageSkillLines = skillStatus.packageSkills.map((skill) => `${skill.skillName} from ${skill.packageName} (${skill.disabled ? "disabled" : skill.active ? "active" : "available"})`);
|
|
14276
14995
|
io.out(` npm packages: ${formatInlineList(packageSkillLines)}`);
|
|
14277
14996
|
const externalSkillLines = skillStatus.external
|
|
@@ -14281,7 +15000,7 @@ async function runStatus(cwd, io) {
|
|
|
14281
15000
|
: "recommended"}; license ${skill.licenseStatus})`);
|
|
14282
15001
|
io.out(` external: ${formatInlineList(externalSkillLines)}`);
|
|
14283
15002
|
io.out(` disabled: ${formatInlineList(skillStatus.disabled)}`);
|
|
14284
|
-
io.out(" updates: run `loom skills sync`
|
|
15003
|
+
io.out(" updates: run `loom skills sync` to restore pins; review `loom skills update` to advance them.");
|
|
14285
15004
|
return 0;
|
|
14286
15005
|
}
|
|
14287
15006
|
function printHelp({ out }) {
|
|
@@ -14296,11 +15015,16 @@ function printHelp({ out }) {
|
|
|
14296
15015
|
out(" files r2 check Verify R2 buckets/account/privacy, Vercel env scoping, local storage, and Files adapter wiring.");
|
|
14297
15016
|
out(" api-keys integrate jobs Record an explicit API-key jobs integration after the route has session/admin authorization.");
|
|
14298
15017
|
out(" api-keys retention enable|disable Record API-key audit cleanup policy; scheduling remains app-owned.");
|
|
15018
|
+
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.");
|
|
15019
|
+
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.");
|
|
15020
|
+
out(" secrets fingerprint Read a secrets key from a hidden terminal prompt and print only its fingerprint.");
|
|
15021
|
+
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.");
|
|
15022
|
+
out(" secrets retire <id> Record a secrets key that nothing needs any more as retired.");
|
|
14299
15023
|
out(" status Show the Loom package, manifest, active features, local-dev state, and project skill state.");
|
|
14300
15024
|
out(" check Validate project bootstrap, managed guidance, features, skill locks, caches, and links.");
|
|
14301
15025
|
out(" env -- <command> Load project .env* files with Next-compatible semantics, then run a command from the project root.");
|
|
14302
|
-
out(" skills sync
|
|
14303
|
-
out(" skills update
|
|
15026
|
+
out(" skills sync Restore recorded skill content and links without adopting updates.");
|
|
15027
|
+
out(" skills update Approve reviewed updates for adopted skills, or select names.");
|
|
14304
15028
|
out(" db fixtures Run the Loom-managed DB fixture dump script for the active DB feature.");
|
|
14305
15029
|
out(" db schema-gen Run the Loom-managed Valibot generator workflow for the active DB feature. Pass extra generator args after `--`.");
|
|
14306
15030
|
out(" db schemas sync Materialize active Loom-managed DB schema blueprints into app-local schema files.");
|
|
@@ -14322,11 +15046,12 @@ function printHelp({ out }) {
|
|
|
14322
15046
|
out(" dev published Remove the managed local-dev override and return to the published dependency.");
|
|
14323
15047
|
out("");
|
|
14324
15048
|
out("Options:");
|
|
14325
|
-
out(" --strict-skills Treat
|
|
15049
|
+
out(" --strict-skills Treat invalid recorded skill content or links as check failures.");
|
|
14326
15050
|
out(" --accept-unknown-license <skill> Explicitly adopt an upstream skill without a clear declared license.");
|
|
14327
15051
|
out(" --network Run registered network checks after the local project checks.");
|
|
14328
15052
|
out(" --production Treat local Loom dev overrides and local lockfile resolutions as release-blocking check failures.");
|
|
14329
15053
|
out(" --no-progress Disable the interactive network progress renderer.");
|
|
15054
|
+
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.");
|
|
14330
15055
|
out(" --local-db-host <host> Local PostgreSQL host (default: db.localtest.me).");
|
|
14331
15056
|
out(" --local-db-port <port> Local PostgreSQL port (default: 5432).");
|
|
14332
15057
|
out(" --replace-local-target Replace an existing development URL during local DB setup.");
|
|
@@ -14354,6 +15079,7 @@ function printHelp({ out }) {
|
|
|
14354
15079
|
out(" --token-expiry-days <days> Vercel release token lifetime (default 90).");
|
|
14355
15080
|
out(" --timeout <duration> Bounded Vercel promotion wait (default 3m).");
|
|
14356
15081
|
out(" --environment <name> GitHub Environment for migration credential setup (default production).");
|
|
15082
|
+
out(" --environment production|preview Key list a `loom secrets` command uses (default production).");
|
|
14357
15083
|
out(" --env-file <path> Preserved env snapshot for `db migrations verify-env`; process values take precedence.");
|
|
14358
15084
|
out(" --connect Authenticate and check migration database identity and schema privileges.");
|
|
14359
15085
|
out(" --resource <name> Permission resource for API-key integration.");
|
|
@@ -14398,6 +15124,559 @@ async function runApiKeys(cwd, command, target, options, io) {
|
|
|
14398
15124
|
io.out(`Note: ${note}`);
|
|
14399
15125
|
return 0;
|
|
14400
15126
|
}
|
|
15127
|
+
/**
|
|
15128
|
+
* Whether what follows `loom secrets push` is only a version number and
|
|
15129
|
+
* options Loom knows. Anything else may be a key typed in the wrong place,
|
|
15130
|
+
* which the argument parser would quote back in its error.
|
|
15131
|
+
*/
|
|
15132
|
+
function secretsPushArgumentsAreSafe(rest) {
|
|
15133
|
+
const flags = ["--vercel", "--no-vercel", "--no-color", "--help", "-h"];
|
|
15134
|
+
const withValue = ["--cwd", "--environment"];
|
|
15135
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
15136
|
+
const arg = rest[index];
|
|
15137
|
+
if (/^[1-9][0-9]{0,8}$/.test(arg) || flags.includes(arg))
|
|
15138
|
+
continue;
|
|
15139
|
+
if (withValue.some((name) => arg.startsWith(`${name}=`)))
|
|
15140
|
+
continue;
|
|
15141
|
+
if (withValue.includes(arg) && index + 1 < rest.length) {
|
|
15142
|
+
index += 1;
|
|
15143
|
+
continue;
|
|
15144
|
+
}
|
|
15145
|
+
return false;
|
|
15146
|
+
}
|
|
15147
|
+
return true;
|
|
15148
|
+
}
|
|
15149
|
+
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.";
|
|
15150
|
+
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.";
|
|
15151
|
+
/**
|
|
15152
|
+
* Variables that an automated or agent session sets. A key must not be shown
|
|
15153
|
+
* to, or typed into, such a session even when it runs under a pseudo-terminal.
|
|
15154
|
+
*/
|
|
15155
|
+
const AUTOMATED_SESSION_ENV_NAMES = [
|
|
15156
|
+
"CI",
|
|
15157
|
+
"GITHUB_ACTIONS",
|
|
15158
|
+
"CLAUDECODE",
|
|
15159
|
+
"CLAUDE_CODE_ENTRYPOINT",
|
|
15160
|
+
"AI_AGENT",
|
|
15161
|
+
"CODEX_SANDBOX",
|
|
15162
|
+
"CURSOR_AGENT",
|
|
15163
|
+
"GEMINI_CLI",
|
|
15164
|
+
];
|
|
15165
|
+
/**
|
|
15166
|
+
* Whether a command may change something outside the repository, such as a
|
|
15167
|
+
* deployment platform's settings. An explicit flag decides. Without one, only
|
|
15168
|
+
* a person at a terminal is asked, and the default answer is no; anywhere
|
|
15169
|
+
* else nothing outside changes and the command says how to do it instead.
|
|
15170
|
+
* See "CLI prompts and outside changes" in AGENTS.md.
|
|
15171
|
+
*/
|
|
15172
|
+
export function resolveOutsideChange(flags, interactive) {
|
|
15173
|
+
if (flags.yes)
|
|
15174
|
+
return "yes";
|
|
15175
|
+
if (flags.no)
|
|
15176
|
+
return "no";
|
|
15177
|
+
return interactive ? "ask" : "no";
|
|
15178
|
+
}
|
|
15179
|
+
const isYesAnswer = (answer) => /^y(es)?$/i.test(answer.trim());
|
|
15180
|
+
/**
|
|
15181
|
+
* Parses `vercel env ls --format json` output, or returns null when it is not
|
|
15182
|
+
* that listing. Vercel CLI 54 and newer print it.
|
|
15183
|
+
*/
|
|
15184
|
+
function parseVercelEnvListing(text) {
|
|
15185
|
+
let parsed;
|
|
15186
|
+
try {
|
|
15187
|
+
parsed = JSON.parse(text.slice(text.indexOf("{"), text.lastIndexOf("}") + 1));
|
|
15188
|
+
}
|
|
15189
|
+
catch {
|
|
15190
|
+
return null;
|
|
15191
|
+
}
|
|
15192
|
+
const envs = isJsonObject(parsed) ? parsed.envs : undefined;
|
|
15193
|
+
if (!Array.isArray(envs))
|
|
15194
|
+
return null;
|
|
15195
|
+
return envs.flatMap((entry) => {
|
|
15196
|
+
if (!isJsonObject(entry) || typeof entry.key !== "string")
|
|
15197
|
+
return [];
|
|
15198
|
+
const targets = (Array.isArray(entry.target) ? entry.target : [entry.target])
|
|
15199
|
+
.filter((target) => typeof target === "string");
|
|
15200
|
+
return [{
|
|
15201
|
+
custom: Array.isArray(entry.customEnvironmentIds) &&
|
|
15202
|
+
entry.customEnvironmentIds.length > 0,
|
|
15203
|
+
key: entry.key,
|
|
15204
|
+
secret: entry.type === "sensitive" || entry.visibility === "secret",
|
|
15205
|
+
targets,
|
|
15206
|
+
type: typeof entry.type === "string" ? entry.type : "",
|
|
15207
|
+
}];
|
|
15208
|
+
});
|
|
15209
|
+
}
|
|
15210
|
+
async function listVercelProductionVariables(cwd, commandRunner, command, env) {
|
|
15211
|
+
// JSON, not the table: the table cannot tell a variable that applies to
|
|
15212
|
+
// Production alone from one shared with Preview, and a name could appear
|
|
15213
|
+
// inside another variable's displayed value.
|
|
15214
|
+
const result = await commandRunner(command, ["env", "ls", "production", "--format", "json"], { cwd, env, stdio: "pipe" });
|
|
15215
|
+
if (result.code !== 0) {
|
|
15216
|
+
throw new Error(`Could not list Vercel Production variables: ${vercelFailureDetail(result, "")}`);
|
|
15217
|
+
}
|
|
15218
|
+
const variables = parseVercelEnvListing(result.stdout);
|
|
15219
|
+
if (!variables) {
|
|
15220
|
+
throw new Error("Vercel did not list Production variables as JSON.");
|
|
15221
|
+
}
|
|
15222
|
+
return variables.filter((variable) => variable.targets.includes("production"));
|
|
15223
|
+
}
|
|
15224
|
+
const vercelVariables = (target, key) => target.variables.filter((variable) => variable.key === key);
|
|
15225
|
+
/**
|
|
15226
|
+
* Why the pointer cannot simply be updated for Production, or null when it
|
|
15227
|
+
* can. A variable shared with Preview would move its pointer too, and Preview
|
|
15228
|
+
* has a key list of its own. Sharing with a custom environment is not in
|
|
15229
|
+
* Vercel's listing, so it cannot be seen here.
|
|
15230
|
+
*/
|
|
15231
|
+
function vercelPointerProblem(target, name) {
|
|
15232
|
+
const found = vercelVariables(target, name);
|
|
15233
|
+
if (found.length === 0)
|
|
15234
|
+
return null;
|
|
15235
|
+
const shared = found.find((variable) => variable.custom || variable.targets.some((each) => each !== "production"));
|
|
15236
|
+
return found.length > 1 || shared
|
|
15237
|
+
? `${name} on Vercel is shared with ${shared
|
|
15238
|
+
? shared.targets.filter((each) => each !== "production").join(", ") ||
|
|
15239
|
+
"a custom environment"
|
|
15240
|
+
: "another entry"}. Give Production its own ${name} by hand, so the other environments keep theirs.`
|
|
15241
|
+
: null;
|
|
15242
|
+
}
|
|
15243
|
+
async function findSecretsVercelTarget(cwd, commandRunner) {
|
|
15244
|
+
const link = await readVercelProjectLink(cwd);
|
|
15245
|
+
if (!link.linked || !link.projectId) {
|
|
15246
|
+
return {
|
|
15247
|
+
linked: false,
|
|
15248
|
+
reason: `This project is not linked to Vercel: ${link.detail} Run \`vercel link\` first.`,
|
|
15249
|
+
};
|
|
15250
|
+
}
|
|
15251
|
+
// The link names the project; inherited ids would silently point the
|
|
15252
|
+
// writes somewhere else.
|
|
15253
|
+
const env = withoutInheritedVercelProject(process.env);
|
|
15254
|
+
const cli = await detectVercelCliCommand(cwd, commandRunner, env);
|
|
15255
|
+
if (!cli.command) {
|
|
15256
|
+
return {
|
|
15257
|
+
linked: true,
|
|
15258
|
+
reason: "The Vercel CLI (`vercel` or `vc`) was not found.",
|
|
15259
|
+
};
|
|
15260
|
+
}
|
|
15261
|
+
try {
|
|
15262
|
+
return {
|
|
15263
|
+
target: {
|
|
15264
|
+
command: cli.command,
|
|
15265
|
+
env,
|
|
15266
|
+
project: link.projectName ?? link.projectId,
|
|
15267
|
+
variables: await listVercelProductionVariables(cwd, commandRunner, cli.command, env),
|
|
15268
|
+
},
|
|
15269
|
+
};
|
|
15270
|
+
}
|
|
15271
|
+
catch (error) {
|
|
15272
|
+
return { linked: true, reason: error.message };
|
|
15273
|
+
}
|
|
15274
|
+
}
|
|
15275
|
+
function warnIfPointerSecret(target, name, io) {
|
|
15276
|
+
if (vercelVariables(target, name).some((variable) => variable.secret)) {
|
|
15277
|
+
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.`);
|
|
15278
|
+
}
|
|
15279
|
+
}
|
|
15280
|
+
/** Sets the pointer for Production only, as a readable variable. */
|
|
15281
|
+
async function setVercelPointer(cwd, commandRunner, target, name, id) {
|
|
15282
|
+
if (vercelVariables(target, name).length) {
|
|
15283
|
+
await updateVercelEnvValue(cwd, commandRunner, target.env, target.command, name, String(id), "production");
|
|
15284
|
+
}
|
|
15285
|
+
else {
|
|
15286
|
+
// Without --no-sensitive, a value given on stdin is stored as a Secret,
|
|
15287
|
+
// which `vercel pull` cannot read back for the release build.
|
|
15288
|
+
await addVercelEnvValue(cwd, commandRunner, target.env, target.command, name, String(id), "production", ["--no-sensitive", "--yes"]);
|
|
15289
|
+
}
|
|
15290
|
+
}
|
|
15291
|
+
/**
|
|
15292
|
+
* Puts a secrets key on Vercel Production as a Secret, and the pointer when
|
|
15293
|
+
* the key is the active one, from a copy the operator pastes back from their
|
|
15294
|
+
* password manager. That copy is checked against the fingerprint in loom.json
|
|
15295
|
+
* before Vercel gets it: a key that reached Vercel but not the password
|
|
15296
|
+
* manager could never be recovered, since Vercel never shows a Secret again.
|
|
15297
|
+
* Afterwards Vercel is listed again to confirm how it stored them.
|
|
15298
|
+
*/
|
|
15299
|
+
async function pushSecretsKeyToVercel(cwd, commandRunner, target, key, terminal, io, options) {
|
|
15300
|
+
if (vercelVariables(target, key.variableName).length) {
|
|
15301
|
+
io.err(`${key.variableName} already exists in Vercel Production. Loom never replaces a key there; find out why Vercel and loom.json differ first.`);
|
|
15302
|
+
return false;
|
|
15303
|
+
}
|
|
15304
|
+
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.`);
|
|
15305
|
+
let value = null;
|
|
15306
|
+
for (let attempt = 1; attempt <= 3 && value === null; attempt += 1) {
|
|
15307
|
+
let pasted = (await terminal.prompt(`${key.variableName} from your password manager (input is hidden): `)).trim();
|
|
15308
|
+
if (!pasted) {
|
|
15309
|
+
io.err("Nothing was entered, so nothing was sent to Vercel.");
|
|
15310
|
+
return false;
|
|
15311
|
+
}
|
|
15312
|
+
// The whole printed line is a likely thing to have saved.
|
|
15313
|
+
if (pasted.startsWith(`${key.variableName}=`)) {
|
|
15314
|
+
pasted = pasted.slice(key.variableName.length + 1).trim();
|
|
15315
|
+
}
|
|
15316
|
+
let fingerprint = null;
|
|
15317
|
+
try {
|
|
15318
|
+
fingerprint = await fingerprintSecretsKey(pasted);
|
|
15319
|
+
}
|
|
15320
|
+
catch {
|
|
15321
|
+
io.err("That is not a secrets key: it does not decode to 32 bytes. Check the saved copy.");
|
|
15322
|
+
continue;
|
|
15323
|
+
}
|
|
15324
|
+
if (fingerprint === key.fingerprint) {
|
|
15325
|
+
value = pasted;
|
|
15326
|
+
}
|
|
15327
|
+
else {
|
|
15328
|
+
io.err(`That is a different key from version ${key.id}: its fingerprint does not match loom.json. Check the saved copy.`);
|
|
15329
|
+
}
|
|
15330
|
+
}
|
|
15331
|
+
if (value === null) {
|
|
15332
|
+
io.err(`Nothing was sent to Vercel. Fix the saved copy, then run \`loom secrets push ${key.id}\`.`);
|
|
15333
|
+
return false;
|
|
15334
|
+
}
|
|
15335
|
+
let setPointer = key.state === "active";
|
|
15336
|
+
const pointerProblem = setPointer
|
|
15337
|
+
? vercelPointerProblem(target, key.activeKeyName)
|
|
15338
|
+
: null;
|
|
15339
|
+
if (pointerProblem)
|
|
15340
|
+
setPointer = false;
|
|
15341
|
+
else if (setPointer && vercelVariables(target, key.activeKeyName).length) {
|
|
15342
|
+
setPointer = options.replacePointer === "ask" &&
|
|
15343
|
+
isYesAnswer(await terminal.ask(`${key.activeKeyName} already exists in Vercel Production. Set it to ${key.id}? [y/N] `));
|
|
15344
|
+
}
|
|
15345
|
+
try {
|
|
15346
|
+
await addVercelEnvValue(cwd, commandRunner, target.env, target.command, key.variableName, value, "production", ["--sensitive", "--yes"]);
|
|
15347
|
+
}
|
|
15348
|
+
catch (error) {
|
|
15349
|
+
io.err(`${error.message} Nothing else was changed.`);
|
|
15350
|
+
return false;
|
|
15351
|
+
}
|
|
15352
|
+
if (setPointer) {
|
|
15353
|
+
try {
|
|
15354
|
+
await setVercelPointer(cwd, commandRunner, target, key.activeKeyName, key.id);
|
|
15355
|
+
}
|
|
15356
|
+
catch (error) {
|
|
15357
|
+
io.err(`${key.variableName} was added, but ${key.activeKeyName} was not: ${error.message} Set ${key.activeKeyName}=${key.id} in Vercel Production yourself.`);
|
|
15358
|
+
return false;
|
|
15359
|
+
}
|
|
15360
|
+
}
|
|
15361
|
+
// Confirm what Vercel stored, rather than trusting how it was asked.
|
|
15362
|
+
let stored;
|
|
15363
|
+
try {
|
|
15364
|
+
stored = await listVercelProductionVariables(cwd, commandRunner, target.command, target.env);
|
|
15365
|
+
}
|
|
15366
|
+
catch (error) {
|
|
15367
|
+
io.err(`Added ${key.variableName}, but could not confirm how Vercel stored it: ${error.message} Check it is a Secret for Production only.`);
|
|
15368
|
+
return false;
|
|
15369
|
+
}
|
|
15370
|
+
const confirmed = { ...target, variables: stored };
|
|
15371
|
+
const keyEntry = vercelVariables(confirmed, key.variableName);
|
|
15372
|
+
if (keyEntry.length !== 1 || !keyEntry[0].secret ||
|
|
15373
|
+
keyEntry[0].custom || keyEntry[0].targets.join() !== "production") {
|
|
15374
|
+
io.err(`Vercel did not store ${key.variableName} as a Secret for Production only. Fix it in Vercel before deploying.`);
|
|
15375
|
+
return false;
|
|
15376
|
+
}
|
|
15377
|
+
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.`);
|
|
15378
|
+
if (setPointer)
|
|
15379
|
+
warnIfPointerSecret(confirmed, key.activeKeyName, io);
|
|
15380
|
+
if (pointerProblem)
|
|
15381
|
+
io.err(pointerProblem);
|
|
15382
|
+
else if (key.state === "active" && !setPointer) {
|
|
15383
|
+
io.out(`Set ${key.activeKeyName}=${key.id} in Vercel Production before deploying.`);
|
|
15384
|
+
}
|
|
15385
|
+
return true;
|
|
15386
|
+
}
|
|
15387
|
+
async function runSecrets(cwd, command, target, options, io, terminal = {}, commandRunner = defaultCommandRunner) {
|
|
15388
|
+
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]";
|
|
15389
|
+
const environmentOption = options.environment ?? "production";
|
|
15390
|
+
if (environmentOption !== "production" && environmentOption !== "preview") {
|
|
15391
|
+
io.err("--environment must be production or preview.");
|
|
15392
|
+
return 1;
|
|
15393
|
+
}
|
|
15394
|
+
if (options.vercel && options.noVercel) {
|
|
15395
|
+
io.err("--vercel and --no-vercel cannot be used together.");
|
|
15396
|
+
return 1;
|
|
15397
|
+
}
|
|
15398
|
+
const environment = environmentOption;
|
|
15399
|
+
const platformTarget = environment === "production"
|
|
15400
|
+
? "Production"
|
|
15401
|
+
: "Preview";
|
|
15402
|
+
const stdinIsTty = terminal.stdinIsTty ?? Boolean(process.stdin.isTTY);
|
|
15403
|
+
const stdoutIsTty = terminal.stdoutIsTty ?? Boolean(process.stdout.isTTY);
|
|
15404
|
+
const sessionEnv = terminal.env ?? process.env;
|
|
15405
|
+
const automatedMarker = AUTOMATED_SESSION_ENV_NAMES.find((name) => Boolean(sessionEnv[name]));
|
|
15406
|
+
const vercelChoice = resolveOutsideChange({ no: options.noVercel, yes: options.vercel }, stdinIsTty && stdoutIsTty && !automatedMarker);
|
|
15407
|
+
if (options.vercel && environment !== "production") {
|
|
15408
|
+
io.err("--vercel sets Vercel Production only. Set Preview variables yourself.");
|
|
15409
|
+
return 1;
|
|
15410
|
+
}
|
|
15411
|
+
// Raw mode rather than readline: under Deno a readline question never
|
|
15412
|
+
// settles on Ctrl-C, and the command would end without a word.
|
|
15413
|
+
const ask = terminal.ask ??
|
|
15414
|
+
((question) => promptForTerminalValue(question, false, {
|
|
15415
|
+
cancelled: "Cancelled.",
|
|
15416
|
+
notInteractive: "This question needs a terminal.",
|
|
15417
|
+
}, { rawEcho: true }));
|
|
15418
|
+
const prompt = (cancelled, notInteractive) => terminal.prompt ??
|
|
15419
|
+
((question) => promptForTerminalValue(question, true, { cancelled, notInteractive }));
|
|
15420
|
+
// Reading a key is only for a person at a terminal: never a pipe, a file
|
|
15421
|
+
// or an agent's session, whose transcript would then hold the key.
|
|
15422
|
+
const keyReadRefusal = (name) => automatedMarker
|
|
15423
|
+
? `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.`
|
|
15424
|
+
: !stdinIsTty
|
|
15425
|
+
? `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.`
|
|
15426
|
+
: null;
|
|
15427
|
+
try {
|
|
15428
|
+
switch (command) {
|
|
15429
|
+
case "keygen": {
|
|
15430
|
+
// Deliberately no flag overrides these: the only safe destination for
|
|
15431
|
+
// a production key is the screen of the operator who will save it.
|
|
15432
|
+
// They are a guardrail, not proof that a person is watching; a
|
|
15433
|
+
// pseudo-terminal with a clean environment still passes.
|
|
15434
|
+
const refusal = automatedMarker
|
|
15435
|
+
? `this is an automated or agent session`
|
|
15436
|
+
: !stdoutIsTty
|
|
15437
|
+
? "its output is not a terminal"
|
|
15438
|
+
: !stdinIsTty
|
|
15439
|
+
? "its input is not a terminal"
|
|
15440
|
+
: null;
|
|
15441
|
+
if (refusal) {
|
|
15442
|
+
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.`);
|
|
15443
|
+
return 1;
|
|
15444
|
+
}
|
|
15445
|
+
// Asked for explicitly, Vercel must be reachable before a key exists:
|
|
15446
|
+
// finding out afterwards would leave a recorded key with nowhere to go.
|
|
15447
|
+
let vercel = null;
|
|
15448
|
+
let vercelNote = null;
|
|
15449
|
+
if (vercelChoice !== "no" && environment === "production") {
|
|
15450
|
+
const found = await findSecretsVercelTarget(cwd, commandRunner);
|
|
15451
|
+
const planned = await planSecretsKey(cwd, environment);
|
|
15452
|
+
if ("target" in found &&
|
|
15453
|
+
vercelVariables(found.target, planned.variableName).length) {
|
|
15454
|
+
// Drift between Vercel and loom.json, whether or not Vercel was
|
|
15455
|
+
// asked for; a key generated now would have nowhere to go.
|
|
15456
|
+
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.`);
|
|
15457
|
+
return 1;
|
|
15458
|
+
}
|
|
15459
|
+
if (!("target" in found) && vercelChoice === "yes") {
|
|
15460
|
+
io.err(`${found.reason} No key was generated.`);
|
|
15461
|
+
return 1;
|
|
15462
|
+
}
|
|
15463
|
+
if ("target" in found)
|
|
15464
|
+
vercel = found.target;
|
|
15465
|
+
else if (found.linked)
|
|
15466
|
+
vercelNote = found.reason;
|
|
15467
|
+
}
|
|
15468
|
+
const result = await generateSecretsKey(cwd, { environment });
|
|
15469
|
+
io.out(`Generated secrets key version ${result.id} for ${environment}. It is shown once and Loom keeps no copy.`);
|
|
15470
|
+
io.out("");
|
|
15471
|
+
io.out(result.assignment);
|
|
15472
|
+
io.out(`Fingerprint: ${result.fingerprint}`);
|
|
15473
|
+
io.out("");
|
|
15474
|
+
io.out(`Recorded the fingerprint in loom.json as ${result.state}. Commit loom.json; it holds no key.`);
|
|
15475
|
+
let pushed = false;
|
|
15476
|
+
let go = false;
|
|
15477
|
+
if (vercel) {
|
|
15478
|
+
io.out("Save the key and its fingerprint in your password manager now, before anything else.");
|
|
15479
|
+
try {
|
|
15480
|
+
go = vercelChoice === "yes" || isYesAnswer(await ask(`Add ${result.variableName} (Secret, Production only)${result.state === "active"
|
|
15481
|
+
? ` and ${result.activeKeyName}=${result.id}`
|
|
15482
|
+
: ""} to Vercel project ${vercel.project}? [y/N] `));
|
|
15483
|
+
}
|
|
15484
|
+
catch {
|
|
15485
|
+
// An interrupted question is a no; the next steps still print.
|
|
15486
|
+
}
|
|
15487
|
+
if (go) {
|
|
15488
|
+
pushed = await pushSecretsKeyToVercel(cwd, commandRunner, vercel, result, {
|
|
15489
|
+
ask,
|
|
15490
|
+
prompt: prompt("Nothing was sent to Vercel.", "This needs a terminal."),
|
|
15491
|
+
}, io,
|
|
15492
|
+
// An explicit --vercel asks nothing more, so it leaves an
|
|
15493
|
+
// existing pointer alone and says so.
|
|
15494
|
+
{ replacePointer: vercelChoice === "yes" ? "no" : "ask" }).catch((error) => {
|
|
15495
|
+
io.err(`${error.message} Nothing was sent to Vercel.`);
|
|
15496
|
+
return false;
|
|
15497
|
+
});
|
|
15498
|
+
}
|
|
15499
|
+
}
|
|
15500
|
+
else if (vercelNote) {
|
|
15501
|
+
io.out(`Note: Vercel was not offered: ${vercelNote}`);
|
|
15502
|
+
}
|
|
15503
|
+
io.out("Next steps:");
|
|
15504
|
+
const steps = [];
|
|
15505
|
+
if (!vercel) {
|
|
15506
|
+
steps.push("Save the key and its fingerprint in your password manager now, before anything else.");
|
|
15507
|
+
}
|
|
15508
|
+
if (!pushed) {
|
|
15509
|
+
steps.push(`Add ${result.variableName} to the deployment platform from the password-manager copy, ${platformTarget} only, as a write-only secret${result.state === "active"
|
|
15510
|
+
? `, and set ${result.activeKeyName}=${result.id} there`
|
|
15511
|
+
: ""}.${environment === "production"
|
|
15512
|
+
? ` On Vercel, \`loom secrets push ${result.id}\` checks the saved copy and does this for you.`
|
|
15513
|
+
: ""}`);
|
|
15514
|
+
}
|
|
15515
|
+
steps.push("Deploy.");
|
|
15516
|
+
steps.push(`Confirm \`secrets.assertReady()\` passes in the deployment: that proves the deployed key is the one you saved.${result.state === "active"
|
|
15517
|
+
? ""
|
|
15518
|
+
: ` Then switch to it with \`loom secrets activate ${result.id}\`.`}`);
|
|
15519
|
+
steps.forEach((step, index) => io.out(` ${index + 1}. ${step}`));
|
|
15520
|
+
// The key exists either way; a push that was asked for and did not
|
|
15521
|
+
// happen is still a failure for whoever runs this.
|
|
15522
|
+
return go && !pushed ? 1 : 0;
|
|
15523
|
+
}
|
|
15524
|
+
case "push": {
|
|
15525
|
+
const id = target === undefined ? null : parseSecretKeyId(target);
|
|
15526
|
+
if (id === null) {
|
|
15527
|
+
io.err(usage);
|
|
15528
|
+
return 1;
|
|
15529
|
+
}
|
|
15530
|
+
if (options.vercel || options.noVercel) {
|
|
15531
|
+
io.err("loom secrets push always asks first; it takes no --vercel or --no-vercel.");
|
|
15532
|
+
return 1;
|
|
15533
|
+
}
|
|
15534
|
+
const refusal = keyReadRefusal("push");
|
|
15535
|
+
if (refusal) {
|
|
15536
|
+
io.err(refusal);
|
|
15537
|
+
return 1;
|
|
15538
|
+
}
|
|
15539
|
+
if (environment !== "production") {
|
|
15540
|
+
io.err("loom secrets push sets Vercel Production only. Set Preview variables yourself.");
|
|
15541
|
+
return 1;
|
|
15542
|
+
}
|
|
15543
|
+
const key = await recordedSecretsKey(cwd, id, environment);
|
|
15544
|
+
const found = await findSecretsVercelTarget(cwd, commandRunner);
|
|
15545
|
+
if (!("target" in found)) {
|
|
15546
|
+
io.err(found.reason);
|
|
15547
|
+
return 1;
|
|
15548
|
+
}
|
|
15549
|
+
if (!isYesAnswer(await ask(`Add ${key.variableName} (Secret, Production only)${key.state === "active"
|
|
15550
|
+
? ` and ${key.activeKeyName}=${key.id}`
|
|
15551
|
+
: ""} to Vercel project ${found.target.project}? [y/N] `))) {
|
|
15552
|
+
io.out("Nothing was changed.");
|
|
15553
|
+
return 0;
|
|
15554
|
+
}
|
|
15555
|
+
return await pushSecretsKeyToVercel(cwd, commandRunner, found.target, key, {
|
|
15556
|
+
ask,
|
|
15557
|
+
prompt: prompt("Nothing was sent to Vercel.", keyReadRefusal("push") ?? "This needs a terminal."),
|
|
15558
|
+
}, io, { replacePointer: "ask" })
|
|
15559
|
+
? 0
|
|
15560
|
+
: 1;
|
|
15561
|
+
}
|
|
15562
|
+
case "fingerprint": {
|
|
15563
|
+
// Checked before anything else, and never echoed: whatever followed
|
|
15564
|
+
// the command may be a key.
|
|
15565
|
+
if (target !== undefined) {
|
|
15566
|
+
io.err(SECRETS_FINGERPRINT_ARGUMENT_REFUSAL);
|
|
15567
|
+
return 1;
|
|
15568
|
+
}
|
|
15569
|
+
if (options.vercel || options.noVercel) {
|
|
15570
|
+
io.err("loom secrets fingerprint changes nothing on Vercel.");
|
|
15571
|
+
return 1;
|
|
15572
|
+
}
|
|
15573
|
+
const refusal = keyReadRefusal("fingerprint");
|
|
15574
|
+
if (refusal) {
|
|
15575
|
+
io.err(refusal);
|
|
15576
|
+
return 1;
|
|
15577
|
+
}
|
|
15578
|
+
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.");
|
|
15579
|
+
io.out(await fingerprintSecretsKey(await readKey("Secrets key (input is hidden): ")));
|
|
15580
|
+
return 0;
|
|
15581
|
+
}
|
|
15582
|
+
case "activate":
|
|
15583
|
+
case "retire": {
|
|
15584
|
+
const id = target === undefined ? null : parseSecretKeyId(target);
|
|
15585
|
+
if (id === null) {
|
|
15586
|
+
io.err(usage);
|
|
15587
|
+
return 1;
|
|
15588
|
+
}
|
|
15589
|
+
if (command === "activate") {
|
|
15590
|
+
if (environment !== "production" && options.vercel) {
|
|
15591
|
+
io.err("--vercel sets Vercel Production only. Set Preview variables yourself.");
|
|
15592
|
+
return 1;
|
|
15593
|
+
}
|
|
15594
|
+
let pointerSet = false;
|
|
15595
|
+
let vercelNote = null;
|
|
15596
|
+
const result = await activateSecretsKey(cwd, id, environment, {
|
|
15597
|
+
// The platform's pointer moves first: a deployment carrying the
|
|
15598
|
+
// new list with the old pointer would fail every seal. A build
|
|
15599
|
+
// between the two, with the new pointer and the old list, fails
|
|
15600
|
+
// too, so loom.json should follow at once.
|
|
15601
|
+
beforeWrite: async (key) => {
|
|
15602
|
+
if (vercelChoice === "no" || environment !== "production") {
|
|
15603
|
+
return false;
|
|
15604
|
+
}
|
|
15605
|
+
const found = await findSecretsVercelTarget(cwd, commandRunner);
|
|
15606
|
+
const refusal = !("target" in found)
|
|
15607
|
+
? found.reason
|
|
15608
|
+
: !vercelVariables(found.target, key.variableName).length
|
|
15609
|
+
? `${key.variableName} is not in Vercel Production. Add it (\`loom secrets push ${id}\`) and deploy before activating it.`
|
|
15610
|
+
: vercelPointerProblem(found.target, key.activeKeyName);
|
|
15611
|
+
if (refusal) {
|
|
15612
|
+
if (vercelChoice === "yes") {
|
|
15613
|
+
throw new Error(`${refusal} loom.json was not changed.`);
|
|
15614
|
+
}
|
|
15615
|
+
if ("target" in found || found.linked)
|
|
15616
|
+
vercelNote = refusal;
|
|
15617
|
+
return false;
|
|
15618
|
+
}
|
|
15619
|
+
const vercel = found.target;
|
|
15620
|
+
if (vercelChoice === "ask" &&
|
|
15621
|
+
!isYesAnswer(await ask(`Set ${key.activeKeyName}=${id} in Vercel project ${vercel.project}, Production, before loom.json changes? [y/N] `).catch(() => ""))) {
|
|
15622
|
+
return false;
|
|
15623
|
+
}
|
|
15624
|
+
try {
|
|
15625
|
+
await setVercelPointer(cwd, commandRunner, vercel, key.activeKeyName, id);
|
|
15626
|
+
}
|
|
15627
|
+
catch (error) {
|
|
15628
|
+
throw new Error(`${error.message} loom.json was not changed.`);
|
|
15629
|
+
}
|
|
15630
|
+
pointerSet = true;
|
|
15631
|
+
io.out(`Set ${key.activeKeyName}=${id} in Vercel project ${vercel.project}, Production.`);
|
|
15632
|
+
// Team policy, or an existing Secret kept by `env update`, can
|
|
15633
|
+
// leave the pointer unreadable to the release build.
|
|
15634
|
+
try {
|
|
15635
|
+
warnIfPointerSecret({
|
|
15636
|
+
...vercel,
|
|
15637
|
+
variables: await listVercelProductionVariables(cwd, commandRunner, vercel.command, vercel.env),
|
|
15638
|
+
}, key.activeKeyName, io);
|
|
15639
|
+
}
|
|
15640
|
+
catch {
|
|
15641
|
+
// The pointer is set; how it is stored is a warning only.
|
|
15642
|
+
}
|
|
15643
|
+
return true;
|
|
15644
|
+
},
|
|
15645
|
+
});
|
|
15646
|
+
io.out(result.changedFiles.length
|
|
15647
|
+
? `Updated ${result.changedFiles.join(", ")}: key version ${id} is now the active ${environment} key.`
|
|
15648
|
+
: `Key version ${id} is already the active ${environment} key in loom.json.`);
|
|
15649
|
+
if (vercelNote)
|
|
15650
|
+
io.out(`Note: Vercel was not changed: ${vercelNote}`);
|
|
15651
|
+
io.out(pointerSet
|
|
15652
|
+
? "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."
|
|
15653
|
+
: `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"
|
|
15654
|
+
? " On Vercel, `--vercel` does this first."
|
|
15655
|
+
: ""}`);
|
|
15656
|
+
return 0;
|
|
15657
|
+
}
|
|
15658
|
+
if (options.vercel || options.noVercel) {
|
|
15659
|
+
io.err("loom secrets retire changes nothing on Vercel; remove the variable there yourself, after deploying the retired list.");
|
|
15660
|
+
return 1;
|
|
15661
|
+
}
|
|
15662
|
+
const result = await retireSecretsKey(cwd, id, environment);
|
|
15663
|
+
io.out(result.changedFiles.length
|
|
15664
|
+
? `Updated ${result.changedFiles.join(", ")}: key version ${id} is now retired for ${environment}.`
|
|
15665
|
+
: `Key version ${id} is already retired for ${environment} in loom.json.`);
|
|
15666
|
+
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.`);
|
|
15667
|
+
return 0;
|
|
15668
|
+
}
|
|
15669
|
+
default:
|
|
15670
|
+
io.err(usage);
|
|
15671
|
+
return 1;
|
|
15672
|
+
}
|
|
15673
|
+
}
|
|
15674
|
+
catch (error) {
|
|
15675
|
+
// These are operator-facing refusals; a stack trace adds nothing.
|
|
15676
|
+
io.err(error.message);
|
|
15677
|
+
return 1;
|
|
15678
|
+
}
|
|
15679
|
+
}
|
|
14401
15680
|
async function runFiles(cwd, command, target, options, io) {
|
|
14402
15681
|
if (command === "id-generation") {
|
|
14403
15682
|
if (target !== "uuid-v4" && target !== "uuid-v7") {
|
|
@@ -14593,12 +15872,12 @@ function printSkillsHelp({ out }) {
|
|
|
14593
15872
|
out("");
|
|
14594
15873
|
out("Commands:");
|
|
14595
15874
|
out(" list Show discovered, adopted, disabled, and recommended skills.");
|
|
14596
|
-
out(" add Adopt
|
|
14597
|
-
out(" sync
|
|
15875
|
+
out(" add Adopt selected external or installed npm skills.");
|
|
15876
|
+
out(" sync Restore recorded skill content and links.");
|
|
14598
15877
|
out(" check Validate project skill locks, caches, and links.");
|
|
14599
|
-
out(" update
|
|
15878
|
+
out(" update Update adopted skills to reviewed catalog or installed npm content.");
|
|
14600
15879
|
out(" migrate Replace legacy packaged-skill links with project installs.");
|
|
14601
|
-
out(" disable
|
|
15880
|
+
out(" disable Disable a managed skill or opt out of a recommendation.");
|
|
14602
15881
|
out(" enable Clear a skill opt-out; run sync afterward.");
|
|
14603
15882
|
out("");
|
|
14604
15883
|
out("Unlicensed external skills require `--accept-unknown-license <name>`.");
|
|
@@ -14624,7 +15903,7 @@ async function runSkills(cwd, command, args, io, options) {
|
|
|
14624
15903
|
const manifest = manifestText
|
|
14625
15904
|
? parseJson(manifestText, "loom.json")
|
|
14626
15905
|
: null;
|
|
14627
|
-
const context = getSkillsContext(packageJson, manifest);
|
|
15906
|
+
const context = await getSkillsContext(cwd, packageJson, manifest);
|
|
14628
15907
|
const accepted = options.acceptUnknownLicense
|
|
14629
15908
|
? [options.acceptUnknownLicense]
|
|
14630
15909
|
: [];
|
|
@@ -14661,6 +15940,30 @@ async function runSkills(cwd, command, args, io, options) {
|
|
|
14661
15940
|
case "migrate":
|
|
14662
15941
|
case "sync":
|
|
14663
15942
|
case "update": {
|
|
15943
|
+
if ((command === "sync" || command === "migrate") && args.length) {
|
|
15944
|
+
io.err(`loom skills ${command} restores locked state and does not select new skills.`);
|
|
15945
|
+
return 1;
|
|
15946
|
+
}
|
|
15947
|
+
const status = await getProjectSkillStatus(cwd, context);
|
|
15948
|
+
const locked = await readProjectSkillsLock(cwd);
|
|
15949
|
+
const packageNames = new Set(status.packageSkills.map((skill) => skill.skillName));
|
|
15950
|
+
const externalNames = new Set([
|
|
15951
|
+
...status.external.map((skill) => skill.skillName),
|
|
15952
|
+
...Object.keys(locked.skills).filter((name) => locked.skills[name].kind === "external"),
|
|
15953
|
+
]);
|
|
15954
|
+
const unknown = args.filter((name) => !packageNames.has(name) && !externalNames.has(name));
|
|
15955
|
+
if (unknown.length) {
|
|
15956
|
+
io.err(`Unknown skill: ${unknown.join(", ")}`);
|
|
15957
|
+
return 1;
|
|
15958
|
+
}
|
|
15959
|
+
const ambiguous = args.filter((name) => !locked.skills[name] && packageNames.has(name) &&
|
|
15960
|
+
externalNames.has(name));
|
|
15961
|
+
if (ambiguous.length) {
|
|
15962
|
+
io.err(`Ambiguous skill source: ${ambiguous.join(", ")}. Choose and adopt the source explicitly before using its name.`);
|
|
15963
|
+
return 1;
|
|
15964
|
+
}
|
|
15965
|
+
const selectedPackages = args.filter((name) => locked.skills[name]?.kind === "package" ||
|
|
15966
|
+
(!locked.skills[name] && packageNames.has(name)));
|
|
14664
15967
|
const nextGuidance = await ensureNextAgentsFile(cwd, packageJson);
|
|
14665
15968
|
const migrationFiles = [];
|
|
14666
15969
|
const migrationNotes = [];
|
|
@@ -14672,12 +15975,18 @@ async function runSkills(cwd, command, args, io, options) {
|
|
|
14672
15975
|
migrationFiles.push(".agents/skills/next-best-practices");
|
|
14673
15976
|
migrationNotes.push("Removed the retired next-best-practices link; use Next.js version-matched agent documentation.");
|
|
14674
15977
|
}
|
|
14675
|
-
const packageResult = await syncInstalledPackageSkills(cwd
|
|
15978
|
+
const packageResult = await syncInstalledPackageSkills(cwd, {
|
|
15979
|
+
skillNames: selectedPackages,
|
|
15980
|
+
update: command === "update" && !args.length,
|
|
15981
|
+
});
|
|
14676
15982
|
const externalResult = await syncExternalProjectSkills(cwd, context, {
|
|
14677
15983
|
acceptUnknownLicense: accepted,
|
|
14678
|
-
adoptRecommended: command === "add"
|
|
15984
|
+
adoptRecommended: command === "add" && !args.length,
|
|
15985
|
+
update: command === "update",
|
|
14679
15986
|
commandRunner: defaultCommandRunner,
|
|
14680
|
-
skillNames: args.length
|
|
15987
|
+
skillNames: args.length
|
|
15988
|
+
? args.filter((name) => !selectedPackages.includes(name))
|
|
15989
|
+
: undefined,
|
|
14681
15990
|
});
|
|
14682
15991
|
if (await ensureExternalSkillsGitignore(cwd)) {
|
|
14683
15992
|
externalResult.changedFiles.push(".gitignore");
|
|
@@ -15216,20 +16525,10 @@ async function runDev(cwd, mode, pathInput, io, options = {}) {
|
|
|
15216
16525
|
}
|
|
15217
16526
|
}
|
|
15218
16527
|
async function runCheck(cwd, strictSkills, production, network, noProgress, noColor, io) {
|
|
15219
|
-
const packageSkills = await syncInstalledPackageSkills(cwd);
|
|
15220
|
-
if (packageSkills.changedFiles.length) {
|
|
15221
|
-
io.out(`Updated ${packageSkills.changedFiles.join(", ")} while activating npm package skills.`);
|
|
15222
|
-
}
|
|
15223
|
-
for (const note of packageSkills.notes)
|
|
15224
|
-
io.out(`Note: ${note}`);
|
|
15225
16528
|
const localResult = await checkProject(cwd, process.env, {
|
|
15226
16529
|
production,
|
|
15227
16530
|
strictSkills,
|
|
15228
16531
|
});
|
|
15229
|
-
if (production && packageSkills.changedFiles.length) {
|
|
15230
|
-
localResult.issues.push(`Production check activated or updated project skills: ${packageSkills.changedFiles.join(", ")}.`);
|
|
15231
|
-
localResult.suggestions.push("Review and commit the project skill lock and activation links before release.");
|
|
15232
|
-
}
|
|
15233
16532
|
let result = localResult;
|
|
15234
16533
|
if (network) {
|
|
15235
16534
|
const reporter = createNetworkProgressReporter(io, {
|
|
@@ -15273,6 +16572,20 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
15273
16572
|
err: (line) => console.error(line),
|
|
15274
16573
|
out: (line) => console.log(line),
|
|
15275
16574
|
}, options = {}) {
|
|
16575
|
+
// Checked before any argument is parsed: a parse error quotes the argument,
|
|
16576
|
+
// and a key pasted after `fingerprint` (base64url keys can begin with `-`)
|
|
16577
|
+
// must not be printed back.
|
|
16578
|
+
const secretsIndex = args.indexOf("secrets");
|
|
16579
|
+
if (secretsIndex >= 0 && args[secretsIndex + 1] === "fingerprint" &&
|
|
16580
|
+
args.length > secretsIndex + 2) {
|
|
16581
|
+
io.err(SECRETS_FINGERPRINT_ARGUMENT_REFUSAL);
|
|
16582
|
+
return 1;
|
|
16583
|
+
}
|
|
16584
|
+
if (secretsIndex >= 0 && args[secretsIndex + 1] === "push" &&
|
|
16585
|
+
!secretsPushArgumentsAreSafe(args.slice(secretsIndex + 2))) {
|
|
16586
|
+
io.err(SECRETS_PUSH_ARGUMENT_REFUSAL);
|
|
16587
|
+
return 1;
|
|
16588
|
+
}
|
|
15276
16589
|
const parsed = parseArgs({
|
|
15277
16590
|
allowPositionals: true,
|
|
15278
16591
|
args,
|
|
@@ -15302,6 +16615,8 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
15302
16615
|
"max-requests-per-key": { type: "string" },
|
|
15303
16616
|
"no-color": { type: "boolean" },
|
|
15304
16617
|
"no-progress": { type: "boolean" },
|
|
16618
|
+
"no-vercel": { type: "boolean" },
|
|
16619
|
+
vercel: { type: "boolean" },
|
|
15305
16620
|
"no-sync": { type: "boolean" },
|
|
15306
16621
|
network: { type: "boolean" },
|
|
15307
16622
|
"neon-auth": { type: "boolean" },
|
|
@@ -15337,6 +16652,9 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
15337
16652
|
const addListOnly = command === "add" && arg1 === undefined;
|
|
15338
16653
|
if (command !== undefined &&
|
|
15339
16654
|
command !== "dev" &&
|
|
16655
|
+
// `loom secrets` reads and writes only loom.json and the terminal. A
|
|
16656
|
+
// sync would put build output and notes around a key shown once.
|
|
16657
|
+
command !== "secrets" &&
|
|
15340
16658
|
command !== "skills" &&
|
|
15341
16659
|
command !== "status" &&
|
|
15342
16660
|
!addListOnly &&
|
|
@@ -15404,6 +16722,12 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
15404
16722
|
maxRequestsPerKey: parsed.values["max-requests-per-key"],
|
|
15405
16723
|
resource: parsed.values.resource,
|
|
15406
16724
|
}, io);
|
|
16725
|
+
case "secrets":
|
|
16726
|
+
return await runSecrets(cwd, arg1, arg2, {
|
|
16727
|
+
environment: parsed.values.environment,
|
|
16728
|
+
noVercel: parsed.values["no-vercel"],
|
|
16729
|
+
vercel: parsed.values.vercel,
|
|
16730
|
+
}, io, options.secretsTerminal, options.commandRunner);
|
|
15407
16731
|
case "skills":
|
|
15408
16732
|
return await runSkills(cwd, arg1, [arg2, ...rest].filter(Boolean), io, {
|
|
15409
16733
|
acceptUnknownLicense: parsed.values["accept-unknown-license"],
|