@theholocron/cli 5.0.0-alpha.404 → 5.0.0-alpha.406

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 CHANGED
@@ -307,6 +307,10 @@ these functions unchanged, gathering the same inputs over the GitHub API
307
307
  instead (D8 — one derivation, two input sources, not two
308
308
  implementations).
309
309
 
310
+ A provider's `Errors.describe()` returns `envKeys` (always pushed to repo secrets by `holocron repo setup`) and an optional
311
+ `frameworkEnvKeys` (`{ next: ["NEXT_PUBLIC_SENTRY_DSN"] }`), keyed by a `StackName` from `deriveStack()` and pushed only when
312
+ the root or a workspace package depends on that framework.
313
+
310
314
  `missingCapabilities(capabilities)` is `deriveCompliance()`'s sibling —
311
315
  same `REQUIRED_BASELINE` table, but returns _which_ required capabilities
312
316
  are absent rather than whether any are. `@theholocron/sentinel`'s
package/dist/cli.mjs CHANGED
@@ -9794,6 +9794,7 @@ function deriveProfile(input) {
9794
9794
  if (pkg?.private) return "app";
9795
9795
  return "library";
9796
9796
  }
9797
+ /** The framework and build-tool names `deriveStack()` can detect, in the order it lists them; `StackName` is derived from it. */
9797
9798
  const KNOWN_STACK_DEPS = [
9798
9799
  "next",
9799
9800
  "vite",
@@ -11228,7 +11229,8 @@ async function runSmokeCheck(key, provider, impl) {
11228
11229
  const who = errors.whoami ? await errors.whoami() : null;
11229
11230
  if (who) return mk(key, provider, "ok", `org: ${who.org}`);
11230
11231
  const desc = await errors.describe();
11231
- return mk(key, provider, "ok", `provider: ${desc.provider}; env keys: ${desc.envKeys.join(", ")}`);
11232
+ const keys = [...desc.envKeys, ...Object.entries(desc.frameworkEnvKeys ?? {}).flatMap(([framework, extra]) => extra?.length ? [`${extra.join(", ")} (with ${framework})`] : [])];
11233
+ return mk(key, provider, "ok", `provider: ${desc.provider}; env keys: ${keys.join(", ")}`);
11232
11234
  }
11233
11235
  case "logs": {
11234
11236
  const logs = impl;
@@ -20403,6 +20405,16 @@ async function installAgentPrompts({ repoRoot }) {
20403
20405
  });
20404
20406
  return `wrote ${Object.keys(AGENT_PROMPTS).length} prompt files to ${AGENTS_PROMPTS_ROOT}/`;
20405
20407
  }
20408
+ // src/commands/setup/derive-repo-stack/derive-repo-stack.ts
20409
+ /**
20410
+ * The stack of a whole repo: `deriveStack()` of the root `package.json` and of
20411
+ * every workspace package's, unioned (in `KNOWN_STACK_DEPS` order, no repeats).
20412
+ * A repo with no readable `package.json` has no stack.
20413
+ */
20414
+ function deriveRepoStack(rootPackageJson, workspacePackageJsons) {
20415
+ const found = new Set([rootPackageJson, ...workspacePackageJsons].flatMap((pkg) => deriveStack(pkg)));
20416
+ return KNOWN_STACK_DEPS.filter((name) => found.has(name));
20417
+ }
20406
20418
  // src/commands/setup/engineering.ts
20407
20419
  async function writeIfAbsent(filePath, content) {
20408
20420
  try {
@@ -20424,6 +20436,23 @@ async function installEngineeringStructure({ repoRoot }) {
20424
20436
  for (const [path, content] of writes) if (await writeIfAbsent(path, content)) results.push(path.replace(repoRoot + "/", ""));
20425
20437
  return results.length > 0 ? `created: ${results.join(", ")}` : "all files already exist — nothing to write";
20426
20438
  }
20439
+ // src/commands/setup/errors-env-keys/errors-env-keys.ts
20440
+ /**
20441
+ * The env keys `holocron repo setup` pushes a tracker's DSN under: the
20442
+ * provider's `envKeys` (always), then the `frameworkEnvKeys` of every
20443
+ * framework in the repo's detected `stack`; a repeated key is pushed once.
20444
+ * `unknown` lists the `frameworkEnvKeys` names that are not a known stack name
20445
+ * (a typo in a plugin), whose keys are never pushed, so the caller can say so.
20446
+ */
20447
+ function errorsEnvKeys(described, stack) {
20448
+ const extra = stack.flatMap((framework) => described.frameworkEnvKeys?.[framework] ?? []);
20449
+ const known = KNOWN_STACK_DEPS;
20450
+ const unknown = Object.keys(described.frameworkEnvKeys ?? {}).filter((name) => !known.includes(name));
20451
+ return {
20452
+ keys: [.../* @__PURE__ */ new Set([...described.envKeys, ...extra])],
20453
+ unknown
20454
+ };
20455
+ }
20427
20456
  // src/commands/setup/run-step/run-step.ts
20428
20457
  async function runStep(capability, step, dryRun, body, opts = {}) {
20429
20458
  const result = await execStep(capability, step, dryRun, body, opts);
@@ -21118,8 +21147,31 @@ async function runSetup(input) {
21118
21147
  print(formatStep(steps[steps.length - 1]));
21119
21148
  if (dsn && loader.has("secrets")) {
21120
21149
  const secrets = loader.get("secrets");
21121
- const { envKeys } = await errors.describe();
21122
- for (const key of envKeys) {
21150
+ const rootPackageJson = await readFile(join(input.context.repoRoot, "package.json"), "utf8").then((raw) => JSON.parse(raw)).catch(() => null);
21151
+ let workspacePackageJsons = [];
21152
+ try {
21153
+ workspacePackageJsons = await readWorkspacePackageJsons(input.context.repoRoot, readWorkspacePackages(input.context.repoRoot));
21154
+ } catch (err) {
21155
+ steps.push({
21156
+ capability: "errors",
21157
+ step: "detect stack",
21158
+ status: "skip",
21159
+ message: `workspace packages not read (${errorMessage(err)}); using the root package.json only`
21160
+ });
21161
+ print(formatStep(steps[steps.length - 1]));
21162
+ }
21163
+ const stack = deriveRepoStack(rootPackageJson, workspacePackageJsons);
21164
+ const { keys, unknown } = errorsEnvKeys(await errors.describe(), stack);
21165
+ for (const name of unknown) {
21166
+ steps.push({
21167
+ capability: "errors",
21168
+ step: `frameworkEnvKeys ${name}`,
21169
+ status: "skip",
21170
+ message: `"${name}" is not a known framework name (${KNOWN_STACK_DEPS.join(", ")}); its keys are not pushed`
21171
+ });
21172
+ print(formatStep(steps[steps.length - 1]));
21173
+ }
21174
+ for (const key of keys) {
21123
21175
  steps.push(await runStep("errors", `secrets set ${key}`, dryRun, async () => {
21124
21176
  await secrets.setSecret({ kind: "repo" }, key, dsn);
21125
21177
  }));