@theholocron/cli 5.7.0 → 5.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -15,7 +15,7 @@ import { hideBin } from "yargs/helpers";
15
15
  import { appendFileSync, closeSync, copyFileSync, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync, writeSync } from "node:fs";
16
16
  import { Entry, findCredentials } from "@napi-rs/keyring";
17
17
  import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, createPrivateFile, deferCredentials, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
18
- import { AGGREGATE_CHECK, AGGREGATE_CHECK_NAME, AGGREGATE_SHADOW_CHECK_NAME, DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, DOT_GITHUB_REPO as DOT_GITHUB_REPO$1, HOLOCRON_REPO, HOLOCRON_REPO as HOLOCRON_REPO$1, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, aggregatePoster, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, hostedReusableWorkflows, isDeprecated, isTask, localize, mergeScripts, packageLocation, postAggregate, readWorkspacePackages, recordDeploys, requiredChecks, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
18
+ import { AGGREGATE_CHECK, AGGREGATE_CHECK_NAME, AGGREGATE_SHADOW_CHECK_NAME, DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, DOT_GITHUB_REPO as DOT_GITHUB_REPO$1, HOLOCRON_REPO, HOLOCRON_REPO as HOLOCRON_REPO$1, KNOWN_TASKS, KNOWN_WORKFLOWS, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, SUITES, TASKS, aggregateChecks, aggregatePoster, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, hostedReusableWorkflows, isDeprecated, isTask, localize, mergeScripts, packageLocation, postAggregate, readWorkspacePackages, recordDeploys, requiredChecks, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKey, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
19
19
  import { loadTasksConfig, releaseGroups } from "@theholocron/astromech/config";
20
20
  import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
21
21
  import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
@@ -330,7 +330,8 @@ const cleanupPreviewEntry = {
330
330
  "target",
331
331
  "files",
332
332
  "repo",
333
- "yes"
333
+ "yes",
334
+ "closed"
334
335
  ],
335
336
  supportsDryRun: true
336
337
  };
@@ -464,7 +465,7 @@ const deployEntry = {
464
465
  // src/commands/deploy/deploy-on-release.entry.ts
465
466
  const deployOnReleaseEntry = {
466
467
  name: "deploy on-release",
467
- description: "Deploy every workspace package whose delivery.deploy task is `on: release`",
468
+ description: "Deploy every workspace package whose deploy task is `on: release`",
468
469
  positionals: [],
469
470
  skipOptions: [
470
471
  "project-id",
@@ -1240,7 +1241,8 @@ const newRepoEntry = {
1240
1241
  "skills",
1241
1242
  "is-template",
1242
1243
  "verify",
1243
- "org"
1244
+ "org",
1245
+ "scope"
1244
1246
  ],
1245
1247
  supportsDryRun: true
1246
1248
  };
@@ -1561,8 +1563,6 @@ const pluginCreateEntry = {
1561
1563
  /** The options of `probe`: each probe that takes one asks for it itself, so the menu offers none (the probe menu entries share this). */
1562
1564
  const PROBE_SKIP_OPTIONS = [
1563
1565
  "lcov",
1564
- "warn",
1565
- "files",
1566
1566
  "only",
1567
1567
  "copy",
1568
1568
  "environment",
@@ -2165,7 +2165,7 @@ const startWorkEntry = {
2165
2165
  // src/commands/sync/sync.entry.ts
2166
2166
  const syncEntry = {
2167
2167
  name: "sync",
2168
- description: "Sync state from config to the provider and local files (labels, properties, teams, topics, keywords, description, homepage, readme, workflows, scripts, wiki)",
2168
+ description: "Sync state from config to the provider and local files (labels, properties, teams, topics, keywords, description, homepage, readme, workflows, config, scripts, wiki)",
2169
2169
  positionals: [],
2170
2170
  skipOptions: [
2171
2171
  "repo",
@@ -2310,7 +2310,7 @@ const syncTemplatesEntry = {
2310
2310
  description: "Publish each templates/<type>/ folder to its template repo and tag it with the templates version",
2311
2311
  positionals: [],
2312
2312
  options: [],
2313
- skipOptions: ["yes"],
2313
+ skipOptions: ["yes", "template"],
2314
2314
  supportsDryRun: true
2315
2315
  };
2316
2316
  // src/commands/sync-tooling/sync-tooling.entry.ts
@@ -4043,14 +4043,13 @@ function mergeRepo(prev, next) {
4043
4043
  }
4044
4044
  // src/config/compose/task-name/task-name.ts
4045
4045
  /**
4046
- * The key a task entry merges under. A name that stands for exactly one flat id (the id itself, or an old dotted
4047
- * alias such as `verification.unitTests`) keys by that id, so the alias overrides the preset's entry instead of
4048
- * sitting next to it; a name that stands for several ids or none (a suite, an unknown name) keys by itself.
4046
+ * The key a task entry merges under. A name that stands for a flat id (the id itself, or its script spelling
4047
+ * `deploy:preview`) keys by that id, so the entry overrides the preset's instead of sitting next to it; a name that
4048
+ * stands for none (a suite, an unknown name) keys by itself.
4049
4049
  */
4050
4050
  function taskName(e) {
4051
4051
  const name = typeof e === "string" ? e : e.name;
4052
- const resolved = resolveTaskName(name);
4053
- return resolved.length === 1 ? resolved[0].id : name;
4052
+ return resolveTaskName(name) ?? name;
4054
4053
  }
4055
4054
  // src/config/compose/merge-strategies/merge-strategies.ts
4056
4055
  /**
@@ -6515,7 +6514,7 @@ const authCheckCommand = {
6515
6514
  * check against an arbitrary URL instead of each check's own configured
6516
6515
  * one (holocron#1010).
6517
6516
  *
6518
- * Built for CI: the `delivery.previewCheck` task runs this against a
6517
+ * Built for CI: the `check-preview` task runs this against a
6519
6518
  * PR's Vercel preview deployment, reusing the exact same check
6520
6519
  * definitions already in `holocron.config.ts` for production — no
6521
6520
  * vendor API call, no separate checks-as-code file to keep in sync.
@@ -6617,7 +6616,7 @@ async function reportChecks(input) {
6617
6616
  * `resolveMonitoringChecks` + `reportChecks` in one call — the plain CLI
6618
6617
  * contract, unchanged. Only safe to run with a credential present when
6619
6618
  * the config being loaded is trusted (no PR in the loop); CI's
6620
- * `delivery.previewCheck` uses the two halves separately instead.
6619
+ * `check-preview` uses the two halves separately instead.
6621
6620
  */
6622
6621
  async function runMonitoringCheck(input) {
6623
6622
  return reportChecks({
@@ -6673,7 +6672,7 @@ async function verifyVercelDeploymentProject(url, expectedProjectId, token, opts
6673
6672
  * The shared gate every caller that might attach the Deployment
6674
6673
  * Protection bypass header goes through — `check monitor`'s direct
6675
6674
  * CLI invocation included (sourcery review on holocron#1032 called this
6676
- * out explicitly: verifying only in `delivery.previewCheck`'s own split
6675
+ * out explicitly: verifying only in `check-preview`'s own split
6677
6676
  * commands and not here would leave the exact same unverified-host
6678
6677
  * problem reachable by hand). No `vercelProject` → never attach
6679
6678
  * anything, regardless of whether a `bypassSecret` happens to be
@@ -6796,7 +6795,7 @@ const monitoringRunResolvedArgs = (y) => y.positional("url", {
6796
6795
  // src/commands/monitoring-run-resolved/monitoring-run-resolved.command.ts
6797
6796
  const monitoringRunResolvedCommand = {
6798
6797
  command: "resolved <url>",
6799
- describe: "Run an already-resolved check list (from `resolve checks`) against a URL — no config/plugin loading at all, the trusted half of the delivery.previewCheck split (holocron#1030/#1032)",
6798
+ describe: "Run an already-resolved check list (from `resolve checks`) against a URL — no config/plugin loading at all, the trusted half of the check-preview split (holocron#1030/#1032)",
6800
6799
  builder: monitoringRunResolvedArgs,
6801
6800
  handler: async (argv) => {
6802
6801
  if ((await runMonitoringRunResolved({
@@ -9425,7 +9424,7 @@ function createProjectRows(print, logger) {
9425
9424
  * the item must already be on the board: it is never added here. It asks nothing (a status is easy to set back);
9426
9425
  * `--dry-run` prints the change and calls no mutator. Prints one line, `<key> <from> → <to>`.
9427
9426
  */
9428
- const COMMAND$9 = "project status";
9427
+ const COMMAND$8 = "project status";
9429
9428
  /** `#12`, `12`, `o/r#12` as a repository (or none) and a number; anything else (a Linear key) is undefined. */
9430
9429
  const parseKey$1 = (key) => {
9431
9430
  const m = /^(?:([^#\s]+)#|#)?(\d+)$/.exec(key.trim());
@@ -9440,10 +9439,10 @@ async function runProjectStatus(input) {
9440
9439
  const dryRun = input.context.dryRun ?? false;
9441
9440
  const failed = (label, detail) => {
9442
9441
  rows.fail(label, detail);
9443
- return rows.finish(COMMAND$9);
9442
+ return rows.finish(COMMAND$8);
9444
9443
  };
9445
- const { projects, options } = await openProjects(input, COMMAND$9);
9446
- if (!projects.items || !projects.setStatus) return failed(COMMAND$9, `the \`${projects.providerName}\` provider cannot list items or set a status`);
9444
+ const { projects, options } = await openProjects(input, COMMAND$8);
9445
+ if (!projects.items || !projects.setStatus) return failed(COMMAND$8, `the \`${projects.providerName}\` provider cannot list items or set a status`);
9447
9446
  const declared = input.board === void 0 ? options.boards[0] : options.boards.find((b) => b.name === input.board);
9448
9447
  if (!declared) return failed(input.board === void 0 ? "no boards" : `board ${input.board}`, options.boards.length === 0 ? "declare them in providers.projects: boards: [{ template, name }]" : `not declared; declared boards: ${options.boards.map((b) => b.name).join(", ")}`);
9449
9448
  try {
@@ -9485,7 +9484,7 @@ async function runProjectStatus(input) {
9485
9484
  print(result.transitioned ? change : `${change} (already)`);
9486
9485
  return done;
9487
9486
  } catch (err) {
9488
- return failed(COMMAND$9, errorMessage(err));
9487
+ return failed(COMMAND$8, errorMessage(err));
9489
9488
  }
9490
9489
  }
9491
9490
  // src/commands/project/project-status/project-status.command.ts
@@ -11282,17 +11281,17 @@ function terminalPrompt() {
11282
11281
  * `holocron close project <number-or-name> [--yes]` — close an open board. Reversible (the provider can reopen it).
11283
11282
  * Asks first in a terminal; without one it needs `--yes` and is a {@link NonInteractiveError} otherwise.
11284
11283
  */
11285
- const COMMAND$8 = "close project";
11284
+ const COMMAND$7 = "close project";
11286
11285
  async function runProjectClose(input) {
11287
11286
  const print = input.print ?? ((line) => console.log(line));
11288
11287
  const rows = createProjectRows(print, input.logger ?? getLogger());
11289
11288
  const prompt = input.prompt ?? terminalPrompt();
11290
11289
  const dryRun = input.context.dryRun ?? false;
11291
11290
  const done = (closed) => ({
11292
- ...rows.finish(COMMAND$8),
11291
+ ...rows.finish(COMMAND$7),
11293
11292
  closed
11294
11293
  });
11295
- const { projects, options } = await openProjects(input, COMMAND$8);
11294
+ const { projects, options } = await openProjects(input, COMMAND$7);
11296
11295
  print(style.header(`Holocron close project — ${options.owner}${dryRun ? " (dry-run)" : ""}`));
11297
11296
  print("");
11298
11297
  try {
@@ -11375,6 +11374,10 @@ const cleanupPreviewArgs = (y) => y.positional("pr", {
11375
11374
  }).option("repo", {
11376
11375
  type: "string",
11377
11376
  describe: "GitHub repo as owner/name — defaults to the repo in holocron.config"
11377
+ }).option("closed", {
11378
+ type: "boolean",
11379
+ default: false,
11380
+ describe: "The pull request is known to be closed (CI runs on close): skip looking it up, so no source provider is needed."
11378
11381
  }).option("yes", {
11379
11382
  type: "boolean",
11380
11383
  default: false,
@@ -11397,15 +11400,25 @@ async function runCleanupPreview(input) {
11397
11400
  pr: input.prNumber,
11398
11401
  project: input.project
11399
11402
  }, "cleanup-preview: start");
11400
- if (!loader.has("source")) throw new Error("source capability is not configured — add a source provider to holocron.config.json");
11401
- const source = loader.get("source");
11402
- if (!source.getPullRequest) throw new Error(`${source.providerName} source provider does not support getPullRequest`);
11403
11403
  let pr;
11404
- try {
11405
- pr = await source.getPullRequest(input.prNumber, input.repo);
11406
- } catch (err) {
11407
- const message = errorMessage(err);
11408
- throw new Error(`Failed to fetch PR #${input.prNumber}: ${message}`, { cause: err });
11404
+ if (input.closed) pr = {
11405
+ number: input.prNumber,
11406
+ title: "(not looked up: --closed)",
11407
+ state: "closed",
11408
+ merged: false,
11409
+ branch: "n/a",
11410
+ url: "n/a"
11411
+ };
11412
+ else {
11413
+ if (!loader.has("source")) throw new Error(`source capability is not configured, so PR #${input.prNumber} cannot be looked up (project ${input.project}): add a source provider to holocron.config.json, or pass --closed when the pull request is known to be closed`);
11414
+ const source = loader.get("source");
11415
+ if (!source.getPullRequest) throw new Error(`${source.providerName} source provider does not support getPullRequest`);
11416
+ try {
11417
+ pr = await source.getPullRequest(input.prNumber, input.repo);
11418
+ } catch (err) {
11419
+ const message = errorMessage(err);
11420
+ throw new Error(`Failed to fetch PR #${input.prNumber}: ${message}`, { cause: err });
11421
+ }
11409
11422
  }
11410
11423
  const branch = `${(input.repo ?? input.loaded.resolved.repo?.name ?? "").split("/").pop()}-pr-${pr.number}`;
11411
11424
  print("");
@@ -11559,7 +11572,8 @@ const cleanupPreviewCommand = {
11559
11572
  prNumber: Number(pr),
11560
11573
  project: argv.project,
11561
11574
  ...argv.repo ? { repo: argv.repo } : {},
11562
- ...argv.yes ? { yes: true } : {}
11575
+ ...argv.yes ? { yes: true } : {},
11576
+ ...argv.closed ? { closed: true } : {}
11563
11577
  })).status === "fail") process.exitCode = 1;
11564
11578
  }
11565
11579
  };
@@ -11774,7 +11788,7 @@ function vercelEngines(engines) {
11774
11788
  * Output:
11775
11789
  * .vercel-deploy/
11776
11790
  * api/webhook.mjs — the Vercel Function entry point (checked in, copied verbatim; any other api/*.mjs too)
11777
- * dist/index.mjs — the package's built library (run `delivery.build` first)
11791
+ * dist/index.mjs — the package's built library (run `pnpm build` first)
11778
11792
  * vercel.json — checked in, copied verbatim: `functions["api/webhook.mjs"]
11779
11793
  * .includeFiles: "node_modules/**"` forces Vercel to ship the
11780
11794
  * function's ENTIRE installed node_modules, bypassing
@@ -11839,7 +11853,7 @@ function stageDeploy(input) {
11839
11853
  const resolvePeers = input.resolvePeers ?? installedPeers;
11840
11854
  try {
11841
11855
  const distIndex = join(packageDir, "dist", "index.mjs");
11842
- if (!existsSync(distIndex)) throw new Error(`${distIndex} not found — run \`pnpm run delivery.build\` first`);
11856
+ if (!existsSync(distIndex)) throw new Error(`${distIndex} not found — run \`pnpm build\` first`);
11843
11857
  const pkg = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
11844
11858
  const missing = undeclaredExternals(readFileSync(distIndex, "utf8"), pkg.dependencies ?? {});
11845
11859
  if (missing.length > 0) throw new Error([
@@ -12620,7 +12634,7 @@ const deployOnReleaseArgs = (y) => y.option("channel", {
12620
12634
  // src/commands/deploy/deploy-on-release.command.ts
12621
12635
  const deployOnReleaseCommand = {
12622
12636
  command: "on-release",
12623
- describe: "Deploy every workspace package whose delivery.deploy task is `on: release` — run by the delivery.publish workflow's deploy job",
12637
+ describe: "Deploy every workspace package whose deploy task is `on: release` — run by the release workflow's deploy job",
12624
12638
  builder: deployOnReleaseArgs,
12625
12639
  handler: async (argv) => {
12626
12640
  const print = (line) => console.log(line);
@@ -13193,9 +13207,9 @@ function runCloudflared(token, spawnImpl = spawn) {
13193
13207
  * hostname at it. Both are idempotent, so a second run changes nothing. With `run`, the connector is started in the
13194
13208
  * foreground with the token in its environment. The token is never printed.
13195
13209
  */
13196
- const COMMAND$7 = "new tunnel";
13210
+ const COMMAND$6 = "new tunnel";
13197
13211
  /** Why a provider is missing: its own load error when it failed to load, else how to configure it. */
13198
- function missing(loader, key, hint) {
13212
+ function missing$1(loader, key, hint) {
13199
13213
  const failure = loader.loadFailures().find((f) => f.key === key);
13200
13214
  return failure ? `${hint} (\`${failure.provider}\` failed to load: ${describeError(failure.error)})` : hint;
13201
13215
  }
@@ -13218,7 +13232,7 @@ async function runTunnelUp(input) {
13218
13232
  logger[status === "ok" ? "info" : "warn"]({
13219
13233
  status,
13220
13234
  ...summary
13221
- }, COMMAND$7);
13235
+ }, COMMAND$6);
13222
13236
  return {
13223
13237
  status,
13224
13238
  summary,
@@ -13227,16 +13241,16 @@ async function runTunnelUp(input) {
13227
13241
  };
13228
13242
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
13229
13243
  await withSpinner("Loading plugins…", () => loader.load());
13230
- assertPluginsResolvable(loader, COMMAND$7);
13244
+ assertPluginsResolvable(loader, COMMAND$6);
13231
13245
  const dryRun = input.context.dryRun ?? false;
13232
13246
  print(style.header(`Holocron new tunnel — ${input.hostname}${dryRun ? " (dry-run)" : ""}`));
13233
13247
  print("");
13234
13248
  if (!loader.has("tunnels")) {
13235
- row(false, "tunnels", missing(loader, "tunnels", "needs a `tunnels` provider in holocron.config.ts (cloudflare)"));
13249
+ row(false, "tunnels", missing$1(loader, "tunnels", "needs a `tunnels` provider in holocron.config.ts (cloudflare)"));
13236
13250
  return finish("fail");
13237
13251
  }
13238
13252
  if (!loader.has("dns")) {
13239
- row(false, "dns", missing(loader, "dns", "needs a `dns` provider in holocron.config.ts (cloudflare)"));
13253
+ row(false, "dns", missing$1(loader, "dns", "needs a `dns` provider in holocron.config.ts (cloudflare)"));
13240
13254
  return finish("fail");
13241
13255
  }
13242
13256
  const tunnels = loader.get("tunnels");
@@ -13351,7 +13365,7 @@ const tunnelUpCommand = {
13351
13365
  * disk or printed (only how many there are). The tunnel and its DNS record are set up the way `holocron new tunnel`
13352
13366
  * does, and the tunnel's connector runs beside the application; Ctrl-C stops both.
13353
13367
  */
13354
- const COMMAND$6 = "dev";
13368
+ const COMMAND$5 = "dev";
13355
13369
  /** The environment the application is told it runs in, which its logger tags every line with. */
13356
13370
  const APP_ENVIRONMENT = "development";
13357
13371
  async function runDev(input) {
@@ -13373,7 +13387,7 @@ async function runDev(input) {
13373
13387
  logger[status === "ok" ? "info" : "warn"]({
13374
13388
  status,
13375
13389
  ...summary
13376
- }, COMMAND$6);
13390
+ }, COMMAND$5);
13377
13391
  return {
13378
13392
  status,
13379
13393
  summary,
@@ -13382,7 +13396,7 @@ async function runDev(input) {
13382
13396
  };
13383
13397
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
13384
13398
  await withSpinner("Loading plugins…", () => loader.load());
13385
- assertPluginsResolvable(loader, COMMAND$6);
13399
+ assertPluginsResolvable(loader, COMMAND$5);
13386
13400
  const dryRun = input.context.dryRun ?? false;
13387
13401
  const [program, ...args] = input.command;
13388
13402
  const shown = input.command.join(" ");
@@ -14274,17 +14288,14 @@ const PREFIX = "ci.";
14274
14288
  /**
14275
14289
  * What is wrong with the names of the generated callers, one line each. A caller is named for its task id in three
14276
14290
  * places: the file (`workflowFile(id)`, `ci.` first in the repo that hosts the reusables), the workflow `name:` and each
14277
- * job's `name:` (a job may add a suffix after a space: `release ${{ matrix.group }}`). A file still named for an old
14278
- * task (`ci.verification.unitTests.yml`) is reported once, with the flat file or files that replace it; its workflow and
14279
- * job names are old too and are not listed again. A caller that is not for a known task is left alone.
14291
+ * job's `name:` (a job may add a suffix after a space: `release ${{ matrix.group }}`). A caller that is not for a known
14292
+ * task (a file still named for an old task, `ci.verification.unitTests.yml`) is left alone.
14280
14293
  */
14281
14294
  function callerProblems(callers) {
14282
14295
  return callers.flatMap(({ file, name, jobs }) => {
14283
14296
  const base = file.replace(/\.yml$/, "");
14284
14297
  const prefix = base.startsWith(PREFIX) ? PREFIX : "";
14285
14298
  const stem = base.slice(prefix.length);
14286
- const oldFiles = Object.hasOwn(LEGACY_NAMES, stem) ? workflowKeys(stem).map((id) => `${prefix}${workflowFile(id)}`) : [];
14287
- if (oldFiles.length > 0 && !(oldFiles.length === 1 && oldFiles[0] === file)) return [`${file}: an old caller name; the flat name is ${oldFiles.join(", ")}`];
14288
14299
  const id = CALLER_IDS.find((candidate) => workflowFile(candidate).replace(/\.yml$/, "") === stem);
14289
14300
  if (id === void 0) return [];
14290
14301
  const problems = [];
@@ -14477,13 +14488,16 @@ const CI_TAG = "ci-v1";
14477
14488
  const FROZEN_NOTICE = "DEPRECATED — frozen copy";
14478
14489
  const API = "https://api.github.com";
14479
14490
  const RAW = "https://raw.githubusercontent.com";
14491
+ /** The first-line marker of a workflow nobody generates (`# HAND-MAINTAINED`), live rather than a frozen copy. */
14492
+ const HAND_MAINTAINED = "# HAND-MAINTAINED";
14480
14493
  // src/commands/doctor-ci/frozen-row.ts
14481
14494
  const ID$11 = "frozen";
14482
14495
  const TITLE$11 = `the workflows left in ${DOT_GITHUB_REPO} say they are frozen`;
14483
14496
  /**
14484
14497
  * The `frozen` row: every workflow still in `theholocron/.github` carries the deprecation notice, so nobody mistakes a
14485
14498
  * copy for the live reusable. A file without it is one callers may still use unmarked (a repo still calling
14486
- * `security.yml@main` is why it is there), so it fails with the file names. A read that cannot be made is a skip.
14499
+ * `security.yml@main` is why it is there), so it fails with the file names. A file marked `# HAND-MAINTAINED` is live,
14500
+ * not a copy (`tag.yml` runs `.github`'s own Release Please), so it is left out. A read that cannot be made is a skip.
14487
14501
  */
14488
14502
  async function frozenRow(read) {
14489
14503
  const listing = await read(`${API}/repos/${DOT_GITHUB_REPO}/contents/.github/workflows`);
@@ -14518,19 +14532,28 @@ async function frozenRow(read) {
14518
14532
  detail: `could not read ${unread.name} (HTTP ${unread.res.status || "no answer"})`,
14519
14533
  problems: []
14520
14534
  };
14521
- const unmarked = files.filter(({ res }) => !res.text.split("\n", 15).some((line) => line.includes(FROZEN_NOTICE)));
14535
+ const head = (text) => text.split("\n", 15);
14536
+ const copies = files.filter(({ res }) => !head(res.text).some((line) => line.startsWith(HAND_MAINTAINED)));
14537
+ if (copies.length === 0) return {
14538
+ id: ID$11,
14539
+ title: TITLE$11,
14540
+ status: "ok",
14541
+ detail: `none left (${files.length} hand-maintained)`,
14542
+ problems: []
14543
+ };
14544
+ const unmarked = copies.filter(({ res }) => !head(res.text).some((line) => line.includes(FROZEN_NOTICE)));
14522
14545
  if (unmarked.length > 0) return {
14523
14546
  id: ID$11,
14524
14547
  title: TITLE$11,
14525
14548
  status: "fail",
14526
- detail: `${unmarked.length} of ${files.length} carry no notice`,
14549
+ detail: `${unmarked.length} of ${copies.length} carry no notice`,
14527
14550
  problems: unmarked.map(({ name }) => `${name}: no "${FROZEN_NOTICE}" notice`)
14528
14551
  };
14529
14552
  return {
14530
14553
  id: ID$11,
14531
14554
  title: TITLE$11,
14532
14555
  status: "ok",
14533
- detail: `${files.length} of ${files.length} carry the notice`,
14556
+ detail: `${copies.length} of ${copies.length} carry the notice`,
14534
14557
  problems: []
14535
14558
  };
14536
14559
  }
@@ -15038,15 +15061,11 @@ async function shadowRows(input) {
15038
15061
  }
15039
15062
  // src/commands/doctor-ci/tasks-row.ts
15040
15063
  /**
15041
- * The `tasks` row: a `tasks:` entry in the config that uses a deprecated alias (an old dotted name, `validate`,
15042
- * `stale`, ...) is a problem, and the problem line names the flat id or ids that replace it. This is what
15043
- * `holocron probe tasks names` finds in the files, read here through the config.
15064
+ * The `tasks` row: a `tasks:` entry in the config that is not a flat task id (an old dotted name such as
15065
+ * `verification.unitTests`, a misspelling) is a problem, and the problem line says so.
15044
15066
  */
15045
15067
  function tasksRow(names) {
15046
- return problemRow("tasks", "tasks use flat ids", names.flatMap((name) => {
15047
- if (!Object.hasOwn(LEGACY_NAMES, name)) return [];
15048
- return [`${name}: a deprecated alias; use ${LEGACY_NAMES[name].map((target) => target.id).join(", ")}`];
15049
- }), `${names.length} of ${names.length} use flat ids`);
15068
+ return problemRow("tasks", "tasks use flat ids", names.filter((name) => !KNOWN_TASKS.has(name)).map((name) => `${name}: not a task id`), `${names.length} of ${names.length} use flat ids`);
15050
15069
  }
15051
15070
  // src/commands/doctor-ci/doctor-ci.ts
15052
15071
  /**
@@ -15221,7 +15240,7 @@ function missingTokenReason(err) {
15221
15240
  // src/commands/setup/preview-config-of.ts
15222
15241
  /**
15223
15242
  * The preview configuration (the Pages project and the preview domain) that drives project and DNS provisioning.
15224
- * `delivery.deploy`, `knowledge.docs` and `knowledge.components` all share the same combined production and preview
15243
+ * `deploy`, `deploy-docs` and `deploy-components` all share the same combined production and preview
15225
15244
  * mechanism, so any one of them can carry it. `null` when none does.
15226
15245
  */
15227
15246
  function previewConfigOf(config) {
@@ -18890,7 +18909,8 @@ const ID = /^[a-z][a-z0-9:-]*$/;
18890
18909
  const unquote = (value) => value.trim().replace(/^(["'])(.*)\1$/, "$2");
18891
18910
  /**
18892
18911
  * Problems with the workflow names a workflow lists under `workflow_run: workflows:`, as human-readable lines: one for
18893
- * each name that is an old group name (`Verification`), an old dotted task name or a lowercase name that is no task id.
18912
+ * each name that is an old group name (`Verification`) or a lowercase name that is no task id (an old bare task name such
18913
+ * as `stale` is one).
18894
18914
  * A caller's workflow `name:` is its task id, so a listed id that no task has matches no run and its failures are never
18895
18915
  * posted. A name that is not shaped like an id (`Sentinel Deploy`) is a hand-written workflow's own name and is left
18896
18916
  * alone: this reads the text, not the repo's workflows.
@@ -18899,7 +18919,6 @@ function workflowNameProblems(text) {
18899
18919
  return [...(/^ {2}workflow_run:\n {4}workflows:\n((?: {6}- [^\n]+\n)+)/m.exec(text)?.[1] ?? "").matchAll(/^ {6}- ([^\n#]+)/gm)].map((m) => unquote(m[1])).flatMap((name) => {
18900
18920
  if (GROUP_NAMES.has(name)) return [`${name}: an old group name; a caller's workflow is named for its task id`];
18901
18921
  if (!ID.test(name)) return [];
18902
- if (name in LEGACY_NAMES) return [`${name}: an old task name; a caller's workflow is named for its task id`];
18903
18922
  return KNOWN_TASKS.has(name) || KNOWN_WORKFLOWS.has(name) ? [] : [`${name}: no task has this id, so no run carries this workflow name`];
18904
18923
  });
18905
18924
  }
@@ -21378,7 +21397,7 @@ const chromaticSecret = (tokenName) => !tokenName || tokenName === "default" ? "
21378
21397
  /**
21379
21398
  * The secrets the config says must exist: the names listed in `repo.secrets`, plus the ones it implies. A
21380
21399
  * notification layout fills a secret per webhook and per role (organization scope), and each project of a
21381
- * `verification.visualRegression` task reads a Chromatic token (repository scope).
21400
+ * `test:visual` task reads a Chromatic token (repository scope).
21382
21401
  */
21383
21402
  function expectedSecrets(config, layouts) {
21384
21403
  const declared = config.repo?.secrets;
@@ -23421,7 +23440,7 @@ const SHAPES = [
23421
23440
  /\bBearer\s+[\w.~+/=-]+/gi,
23422
23441
  /\bsntry[a-z]_[\w+/=-]+/g
23423
23442
  ];
23424
- const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23443
+ const escape$1 = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23425
23444
  /**
23426
23445
  * Returns a function that replaces secrets in a line of output: every value the caller gave (a token, a signing secret)
23427
23446
  * and every string shaped like a credential. Values shorter than 6 characters are left, since replacing `ab` would
@@ -23431,7 +23450,7 @@ function createScrubber(secrets) {
23431
23450
  return (text) => {
23432
23451
  let out = text;
23433
23452
  const known = [...secrets].filter((s) => s.length >= 6).sort((a, b) => b.length - a.length);
23434
- for (const secret of known) out = out.replace(new RegExp(escape(secret), "g"), HIDDEN);
23453
+ for (const secret of known) out = out.replace(new RegExp(escape$1(secret), "g"), HIDDEN);
23435
23454
  for (const shape of SHAPES) out = out.replace(shape, HIDDEN);
23436
23455
  return out;
23437
23456
  };
@@ -24820,7 +24839,7 @@ const doctorCommand = {
24820
24839
  * printed to a screen or left in scrollback; to the clipboard when asked. A regular file as stdout (`> file`) is
24821
24840
  * refused, because it would leave plaintext tokens on disk without any of those protections.
24822
24841
  */
24823
- const COMMAND$5 = "export tokens";
24842
+ const COMMAND$4 = "export tokens";
24824
24843
  /** Plain code-unit order: the same on every machine, whatever its locale. The names it sorts are all different. */
24825
24844
  const compare = (a, b) => a < b ? -1 : 1;
24826
24845
  /** What a variable can be called in a dotenv file and in a shell. */
@@ -24833,7 +24852,7 @@ async function runAuthExport(input) {
24833
24852
  logger.warn({
24834
24853
  status: "fail",
24835
24854
  reason
24836
- }, COMMAND$5);
24855
+ }, COMMAND$4);
24837
24856
  return {
24838
24857
  status: "fail",
24839
24858
  exported: [],
@@ -24884,7 +24903,7 @@ async function runAuthExport(input) {
24884
24903
  });
24885
24904
  }
24886
24905
  }
24887
- if (packages.length > 0 && unavailable.length === packages.length) throw new WorkspaceContextError(COMMAND$5, unavailable);
24906
+ if (packages.length > 0 && unavailable.length === packages.length) throw new WorkspaceContextError(COMMAND$4, unavailable);
24888
24907
  const literals = /* @__PURE__ */ new Map();
24889
24908
  const placeholders = [];
24890
24909
  if (input.only?.length) {
@@ -25022,7 +25041,7 @@ async function runAuthExport(input) {
25022
25041
  unavailable: unavailable.length,
25023
25042
  status,
25024
25043
  destination
25025
- }, COMMAND$5);
25044
+ }, COMMAND$4);
25026
25045
  return {
25027
25046
  status,
25028
25047
  exported,
@@ -25462,198 +25481,6 @@ async function handOffHeartbeats(input) {
25462
25481
  reason: "file-left"
25463
25482
  };
25464
25483
  }
25465
- // src/commands/probe/tasks/script-keys.ts
25466
- /**
25467
- * The keys of the object `field` (`scripts` in a `package.json`, `tasks` in a `turbo.json`) with their lines; none when
25468
- * the text is not JSON or has no such object.
25469
- */
25470
- function scriptKeys(text, field) {
25471
- let value;
25472
- try {
25473
- value = JSON.parse(text)[field];
25474
- } catch {
25475
- return [];
25476
- }
25477
- if (typeof value !== "object" || value === null) return [];
25478
- const lines = text.split("\n");
25479
- const start = lines.findIndex((l) => l.includes(`"${field}"`));
25480
- return Object.keys(value).map((key) => ({
25481
- key,
25482
- line: lines.findIndex((l, i) => i > start && l.trimStart().startsWith(`"${key}"`)) + 1
25483
- }));
25484
- }
25485
- // src/commands/probe/tasks/find-reserved.ts
25486
- /** What to use instead of a reserved script name: `publish` has a task of its own, the rest are never tasks. */
25487
- function instead(name) {
25488
- return name === "publish" ? "release (`publish` is reserved by npm and pnpm)" : "(reserved by npm and pnpm, never a task)";
25489
- }
25490
- /**
25491
- * Every `package.json` script named like an npm/pnpm lifecycle word (`RESERVED_SCRIPT_NAMES`): `pnpm publish` would run
25492
- * it after publishing. The root `prepare` (husky) is the one allowed.
25493
- */
25494
- function findReserved(file) {
25495
- if (!/(^|\/)package\.json$/.test(file.path)) return [];
25496
- return scriptKeys(file.text, "scripts").filter(({ key }) => RESERVED_SCRIPT_NAMES.has(key) && !(file.path === "package.json" && key === "prepare")).map(({ key, line }) => ({
25497
- file: file.path,
25498
- line,
25499
- old: key,
25500
- replacement: instead(key)
25501
- }));
25502
- }
25503
- // src/commands/probe/tasks/find-leftovers.ts
25504
- /** The commands that take a task name as their next word: `holocron run`, `turbo run`, `pnpm run`, `pnpm`, ... */
25505
- const COMMAND$4 = String.raw`(?:holocron run|turbo run|pnpm run|npm run|pnpm|yarn)\s+`;
25506
- /** A regex alternation of `names`, escaped; matches nothing for an empty list. */
25507
- function alternation(names) {
25508
- return names.length === 0 ? "(?!)" : names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
25509
- }
25510
- /** The field of a manifest whose keys are tasks or scripts: `scripts` in a `package.json`, `tasks` in a `turbo.json`. */
25511
- function taskField(path) {
25512
- return /(^|\/)package\.json$/.test(path) ? "scripts" : /(^|\/)turbo\.json$/.test(path) ? "tasks" : void 0;
25513
- }
25514
- /**
25515
- * Every use of an old task name in `files`, with its file, line and replacement.
25516
- *
25517
- * - A dotted name (`delivery.build`) matches as a whole token: found in `turbo run delivery.build`, not in
25518
- * `delivery.buildX`. Followed by `.yml`/`.yaml` it is a workflow file name and is left out unless `options.files`.
25519
- * - A bare name (`review`, `stale`: the keys of `names` without a dot) is an ordinary word, so it is found only where it
25520
- * is used as a task: after `holocron run`, `turbo run`, `pnpm` or `pnpm run`, as a `package.json` script or as a
25521
- * `turbo.json` task.
25522
- * - A `package.json` script named like an npm/pnpm lifecycle word is reported too (see {@link findReserved}).
25523
- * - A line, or the line below one, that carries the {@link ALLOW_MARKER} is skipped.
25524
- *
25525
- * Files come back in the order given, lines top to bottom.
25526
- */
25527
- function findLeftovers(files, names, options = {}) {
25528
- const dotted = Object.keys(names).filter((n) => n.includes("."));
25529
- const bare = Object.keys(names).filter((n) => !n.includes("."));
25530
- const tail = options.files ? String.raw`(?![\w-])` : String.raw`(?![\w-]|\.ya?ml\b)`;
25531
- const dottedPattern = new RegExp(`(?<![\\w.-])(${alternation(dotted)})${tail}`, "g");
25532
- const barePattern = new RegExp(`(?<![\\w.-])${COMMAND$4}(${alternation(bare)})(?![\\w:-]|\\.\\w)`, "g");
25533
- return files.flatMap((file) => {
25534
- const lines = file.text.split("\n");
25535
- const field = taskField(file.path);
25536
- const inText = lines.flatMap((text, i) => [...text.matchAll(dottedPattern), ...text.matchAll(barePattern)].map((m) => ({
25537
- file: file.path,
25538
- line: i + 1,
25539
- old: m[1],
25540
- replacement: names[m[1]]
25541
- })));
25542
- const asKey = (field === void 0 ? [] : scriptKeys(file.text, field)).filter(({ key }) => bare.includes(key)).map(({ key, line }) => ({
25543
- file: file.path,
25544
- line,
25545
- old: key,
25546
- replacement: names[key]
25547
- }));
25548
- const seen = /* @__PURE__ */ new Set();
25549
- return [
25550
- ...inText,
25551
- ...asKey,
25552
- ...findReserved(file)
25553
- ].sort((a, b) => a.line - b.line).filter(({ line, old }) => !seen.has(`${line}:${old}`) && seen.add(`${line}:${old}`)).filter(({ line }) => !lines[line - 1].includes("holocron-allow-old-name") && !lines[line - 2]?.includes("holocron-allow-old-name"));
25554
- });
25555
- }
25556
- // src/commands/probe/tasks/is-generated.ts
25557
- /** Whether a file carries the generated-file header in its first lines; drift in those is `probe generated check`'s to report. */
25558
- function isGenerated(text) {
25559
- return text.split("\n", 3).some((line) => line.includes("AUTO-GENERATED"));
25560
- }
25561
- // src/commands/probe/tasks/is-scanned.ts
25562
- /** Files that describe the old names on purpose: specs, ADRs, the changelog, tests, and this probe's own folder. */
25563
- const SKIPPED$1 = [
25564
- /(^|\/)CHANGELOG\.md$/,
25565
- /^\.notes\//,
25566
- /^docs\/wiki\//,
25567
- /\.test\.tsx?$/,
25568
- /^cli\/cli\/src\/commands\/probe\/tasks\//
25569
- ];
25570
- /** The kinds of file the probe reads: workflows, scripts, docs, configs, hooks and manifests. */
25571
- const SCANNED = [
25572
- /^\.github\/(workflows|actions)\/.+\.ya?ml$/,
25573
- /^\.husky\//,
25574
- /^scripts\//,
25575
- /(^|\/)(package|turbo)\.json$/,
25576
- /(^|\/)(holocron|astromech)\.config\.[cm]?[jt]s$/,
25577
- /(^|\/)\.lintstagedrc/,
25578
- /\.mdx?$/
25579
- ];
25580
- /** Whether `path` (repo-relative) is a hand-written kind of place to scan for old task names. */
25581
- function isScanned(path) {
25582
- return SCANNED.some((p) => p.test(path)) && !SKIPPED$1.some((p) => p.test(path));
25583
- }
25584
- // src/commands/probe/tasks/legacy-replacements.ts
25585
- /**
25586
- * Each old task name astromech's `LEGACY_NAMES` still accepts, with the text the `tasks names` probe prints as its
25587
- * replacement: the flat ids it became, in run order. A successor that adds args (`format --check`, the read-only
25588
- * prettier half of `sourceQuality.formatting`) is named last, in parentheses: `lint:editorconfig, lint:markdown (format
25589
- * for prettier)`. A name that is a suite now (`validate`, once the interim id of `platform.repoValidation`) is left out:
25590
- * `holocron run validate` is the suite, not a leftover.
25591
- */
25592
- function legacyReplacements() {
25593
- return Object.fromEntries(Object.entries(LEGACY_NAMES).filter(([old]) => !SUITES.includes(old)).map(([old, targets]) => {
25594
- const own = targets.filter((t) => t.passthrough === void 0).map((t) => t.id);
25595
- const checked = targets.filter((t) => t.passthrough !== void 0).map((t) => `${t.id} for prettier`);
25596
- return [old, checked.length === 0 ? own.join(", ") : `${own.join(", ")} (${checked.join(", ")})`];
25597
- }));
25598
- }
25599
- // src/commands/probe/tasks/real-tasks-io.ts
25600
- /** The `tasks names` probe's inputs from the tracked files under `repoRoot`. */
25601
- function realTasksIo(repoRoot) {
25602
- /* v8 ignore start -- reads git and the real filesystem; the probe is tested with an injected io */
25603
- return { files: () => execFileSync("git", ["ls-files", "-z"], {
25604
- cwd: repoRoot,
25605
- encoding: "utf8",
25606
- maxBuffer: 67108864
25607
- }).split("\0").filter((path) => path !== "" && isScanned(path)).flatMap((path) => {
25608
- try {
25609
- const text = readFileSync(join(repoRoot, path), "utf8");
25610
- return isGenerated(text) ? [] : [{
25611
- path,
25612
- text
25613
- }];
25614
- } catch {
25615
- return [];
25616
- }
25617
- }) };
25618
- /* v8 ignore stop */
25619
- }
25620
- // src/commands/probe/tasks/tasks-probes.ts
25621
- /** The group of probes that check the repo's task vocabulary. */
25622
- const TASKS_PROVIDER = "tasks";
25623
- /**
25624
- * `tasks names`: finds the hand-written places that still use an old task name from the flat-vocabulary map
25625
- * (SPEC-0064, astromech's `LEGACY_NAMES`): a dotted one (`delivery.build`, `verification.unitTests`), a bare one used as a
25626
- * task (`holocron run review`, a `review` script) or a `package.json` script with a reserved npm/pnpm name (`publish`).
25627
- * It scans workflows, scripts, docs, `turbo.json`, `package.json`, the configs' `tasks:` and the hooks, and reports each
25628
- * with file, line and the id to use instead. Each is a failure (exit code 1); `--warn` reports them as `info` rows
25629
- * instead. A dotted name that is part of a workflow file name (`delivery.build.yml`) is skipped until the files are
25630
- * renamed; `--files` lists those too. An intentional mention carries the `holocron-allow-old-name` marker on its line or the line above.
25631
- * Files `sync` generates are left to `generated check`; specs, ADRs and the changelog name the old tasks on purpose.
25632
- */
25633
- function tasksProbes(io, names = legacyReplacements()) {
25634
- return { names: {
25635
- summary: "Report each use of an old task name in hand-written files; fails unless --warn; --files adds file names.",
25636
- writes: false,
25637
- async run(ctx) {
25638
- const status = ctx.args?.includes("--warn") ? "info" : "fail";
25639
- ctx.say({
25640
- status: "heading",
25641
- label: "Old task names"
25642
- });
25643
- const found = findLeftovers(io.files(), names, { files: ctx.args?.includes("--files") === true });
25644
- for (const f of found) ctx.say({
25645
- status,
25646
- label: `${f.file}:${f.line}`,
25647
- detail: `${f.old} -> ${f.replacement}`
25648
- });
25649
- ctx.say({
25650
- status: found.length === 0 ? "ok" : status,
25651
- label: "old names",
25652
- detail: `${found.length} use(s) of ${Object.keys(names).length} old name(s)`
25653
- });
25654
- }
25655
- } };
25656
- }
25657
25484
  // src/commands/workflow-source-marker/workflow-source-marker.ts
25658
25485
  /** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
25659
25486
  const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
@@ -25700,7 +25527,7 @@ function resolvePkgRelPath(gitRoot, configFilepath) {
25700
25527
  /**
25701
25528
  * Two different monorepo packages opting into the same generic task name
25702
25529
  * (e.g. both `apps/sentinel` and some future `apps/other` configuring
25703
- * `delivery.previewDeploy`) would otherwise overwrite each other's
25530
+ * `deploy-preview`) would otherwise overwrite each other's
25704
25531
  * `.github/workflows/<task>.yml` on whichever package's write ran last —
25705
25532
  * only one package's behavior would ever actually run in CI, with no
25706
25533
  * signal that the other's was silently dropped (holocron#1026).
@@ -25726,6 +25553,11 @@ async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExis
25726
25553
  const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
25727
25554
  if (previousPkg !== void 0 && previousPkg !== pkgRelPath) throw new Error(`task "${taskName}" would overwrite .github/workflows/${filename}, already generated for package "${sanitizeForDisplay(previousPkg)}" — the same task name can't be used by two different packages (holocron#1026). If "${sanitizeForDisplay(previousPkg)}" moved or was renamed to this path, delete .github/workflows/${filename} first and re-run this command; otherwise rename one or give it a different thin-caller filename.`);
25728
25555
  }
25556
+ // src/commands/obsolete-workflows/is-generated/is-generated.ts
25557
+ /** Whether a file carries the generated-file header in its first lines; drift in those is `probe generated check`'s to report. */
25558
+ function isGenerated(text) {
25559
+ return text.split("\n", 3).some((line) => line.includes("AUTO-GENERATED"));
25560
+ }
25729
25561
  // src/commands/obsolete-workflows/find-obsolete-workflows.ts
25730
25562
  /** The lines at the head of a generated workflow that hold the header and the `# Source package:` marker. */
25731
25563
  const HEADER_LINES = 6;
@@ -25750,14 +25582,49 @@ function findObsoleteWorkflows({ workflows, written, pkgRelPath }) {
25750
25582
  }
25751
25583
  return obsolete.sort();
25752
25584
  }
25585
+ // src/commands/repo-files/generate-actionlint-files.ts
25586
+ /** Where actionlint reads its settings. */
25587
+ const ACTIONLINT_CONFIG_PATH = ".github/actionlint.yaml";
25588
+ /** The key a low-trust caller carries (`withCacheMode()` in astromech, #1242), at the job's indent. */
25589
+ const CACHE_MODE_KEY = /^ {4}cache-mode:/m;
25590
+ /**
25591
+ * The actionlint settings that let a caller carry `cache-mode: read`. GitHub accepts the key; the bundled actionlint
25592
+ * does not (#1954), so `lint:code` fails on `unexpected key "cache-mode"` in a repo with no such file (#3006). Drop this
25593
+ * file, and `generateActionlintFiles()`, when the bundled actionlint knows the key.
25594
+ */
25595
+ const ACTIONLINT_CONFIG = [
25596
+ "paths:",
25597
+ " .github/workflows/**/*.{yml,yaml}:",
25598
+ " ignore:",
25599
+ ` - 'unexpected key "cache-mode" for "(job|workflow)" section'`,
25600
+ ""
25601
+ ].join("\n");
25602
+ /**
25603
+ * `.github/actionlint.yaml`, written only when one of the generated callers carries `cache-mode:`; a repo whose callers
25604
+ * do not has nothing for actionlint to reject, so nothing is written.
25605
+ */
25606
+ function generateActionlintFiles(workflows) {
25607
+ if (!workflows.some((entry) => entry.kind === "file" && CACHE_MODE_KEY.test(entry.content))) return [];
25608
+ const step = `write ${ACTIONLINT_CONFIG_PATH}`;
25609
+ return [{
25610
+ kind: "file",
25611
+ path: ACTIONLINT_CONFIG_PATH,
25612
+ content: ACTIONLINT_CONFIG,
25613
+ step,
25614
+ syncStep: step
25615
+ }];
25616
+ }
25753
25617
  // ../../.holocron/org.md
25754
25618
  var org_default = "<!-- editorconfig-checker-disable-file -->\n\n# theholocron — agent operating contract\n\nOrg-level agent conventions for all `theholocron` repositories. The canonical\ncopy is `.holocron/org.md` in `theholocron/holocron`. `holocron sync` writes\nit into each repo's `AGENTS.md` between generated markers, so no repo needs a\nsibling checkout to read it; holocron itself imports it with `@.holocron/org.md`.\nEdit it in holocron, then run `holocron sync`.\n\n## Repo map\n\nEach concern lives in exactly one repo:\n\n| Concern | Repo |\n| ----------------------------------------------------------------- | ----------------------------------------- |\n| Shareable tool config (ESLint, Prettier, TSConfig, Vitest, …) | `theholocron/holocron` (`configs/`) |\n| HTTP clients and API wrappers | `theholocron/holocron` (`clients/`) |\n| Infrastructure automation, CI orchestration, repo lifecycle | `theholocron/holocron` |\n| Org-level CI workflows, composite actions, community health files | `theholocron/.github` |\n| Internal member docs and private org config | `theholocron/.github-private` (this repo) |\n| Shared agent skills registry | `theholocron/holocron` (`skills/`) |\n\nIf you find yourself copy-pasting a tool config across repos, it belongs in\nthe `configs/` folder of `theholocron/holocron`. If you find yourself writing a new\nautomation command, it belongs in `holocron` too. Generic helpers (`utils/`) and\nobservability (`observability/`) live in that monorepo as well.\n\n### `holocron.config` format\n\n- Repos **with** a `package.json` → `holocron.config.ts` with `defineConfig`\n from `@theholocron/cli`. The CLI must be resolvable at runtime for the TS\n format to work.\n- Repos **without** a `package.json` (e.g. `.github`, `.github-private`) →\n `holocron.config.json`.\n\n## Workflow\n\n- **Always open a PR — never push directly to the default branch.** Even for\n small fixes: create a branch, push it, open a PR. This lets CI run, keeps\n history reviewable, and respects branch protection. The only exception is\n bootstrapping a brand-new repo before protection is set up.\n- **Conventional Commits.** `feat:` / `fix:` / `chore:` / `docs:` / `ci:` /\n `test:` / `refactor:` / `perf:` — semantic-release uses these for versioning\n and changelogs. Repos without a release step use the subset relevant to them.\n- **Always `git commit -s`** (DCO). The `Signed-off-by:` trailer is required\n on every commit. `-s` generates it automatically from `git config user.name`\n and `user.email`.\n- **Always rebase, never merge `main`.** Use `git rebase origin/main` to keep a\n branch current. `git merge main` creates an unsigned merge commit and drags bot\n commits into the PR history — both trigger DCO check failures.\n- **No Claude attribution** in commits, PRs, issues, or docs. No\n `Co-Authored-By` trailer. The author is the user.\n- **One PR = one focused change.** Squash-merge; the PR title becomes the\n squashed commit subject that semantic-release reads.\n- **File issues for non-trivial work** and reference them in commits/PRs\n (`Closes #N` / `Refs #N`). Skip for typo fixes.\n- **Spec process: Issue before spec.** Before writing a spec file, file an issue\n first, in the tracker the config's `issues` provider names (GitHub when the\n config sets no `issues` provider). The issue is the durable tracking artifact.\n The spec's frontmatter `issue:` field must reference it. Order: Issue → Spec →\n PR → Review → merge.\n- **Reference the issue in that tracker's syntax** in commits and the PR: `Closes #N`\n / `Refs #N` for GitHub, the issue key (`Closes ENG-42` / `Refs ENG-42`) for Linear.\n\n## Before starting any coding task\n\n1. Verify you are on a feature branch, not `main`. If on `main`, create a branch\n first. Never commit directly to `main`. If on an existing feature branch, run\n `git fetch origin && git rebase origin/main` to ensure it has the latest from\n `main` — never start work on a stale branch.\n2. Any PR that adds new behavior must include tests and documentation in the same\n PR. Do not open docs-only or test-only follow-up PRs — tests and docs ship with\n the feature. This applies to new packages, capabilities, commands, APIs, and\n any observable behavior change.\n3. If adding a new client or plugin package, update the docs-theme registry in\n the same PR or a cleanly scoped immediate follow-up.\n4. One PR per logical change. Do not bundle unrelated fixes with a feature.\n\n## After completing any coding task\n\n1. Confirm you are still on the intended feature branch.\n2. Confirm all checklist items in any invoked skill are complete.\n3. Confirm CI is green before requesting review.\n\n## Keeping the project board true\n\nThe board's statuses follow the pull request, so an agent only starts the work and marks the pull request ready.\n\n1. **Starting an issue:** `holocron start work <issue>` makes the branch, the first commit and a draft pull request,\n and the open pull request moves the board to In Progress. Only while the automation is down, set it by hand with\n `holocron update work <issue> --status \"In Progress\"` (a hand-set status is temporary).\n2. **Open the pull request as a draft** (`start work` does; otherwise `gh pr create --draft`) as soon as there is\n something to push.\n3. **When the required checks are green, mark it ready** with `holocron close work <issue> --wait` (it\n waits for the required checks, marks the pull request ready and never merges; `gh pr ready` does the same by hand). The\n board moves to In Review by itself. After the maintainer merges, run `holocron close work <issue>` again to remove\n the worktree and the local branch.\n4. **Never set In Review, Blocked or Done by hand.** The rules own them; Blocked comes from a blocked-by link, never\n from the status.\n\n## CI workflows\n\nAll reusable workflow implementations and composite actions **live as source in\n`theholocron/holocron` — `packages/astromech/src/templates/reusable/`** and are\ngenerated + pushed to `theholocron/.github` by `holocron sync github`.\n**`theholocron/.github` and `.github-private` are pure sync targets** — never\nhand-edit their `.github/workflows/*`, `.github/actions/*` or\n`workflow-templates/*`; edit the source in `holocron` and merge.\n\nEvery other repo (`configs`, `clients`, `holocron`, `.github-private`) gets\n**thin callers** — lightweight `.github/workflows/` files that delegate to\n`.github` via `uses: theholocron/.github/.github/workflows/<name>.yml@main` and\n`secrets: inherit`. Thin callers are generated from the manifest by\n`astromech.thinCallers()` (`holocron sync` / `holocron setup`).\n\n### Sync\n\nThe `sync-workflow-templates` workflow in `theholocron/holocron` keeps thin\ncallers up to date. It runs automatically on push to `main` when\n`packages/cli/src/templates/**` or `packages/astromech/src/templates/**` change.\nChanges to other parts of the sync machinery (e.g. `sync-github.ts`) require a\nmanual dispatch:\n\n```sh\ngh workflow run sync-workflow-templates.yml --repo theholocron/holocron --ref main\n```\n\n### Per-repo task list\n\nEach secondary repo controls which tasks (and their CI workflows) it\nreceives — and can supply per-task `with:` overrides — via the `tasks`\narray in its `holocron.config.ts` (or `holocron.config.json`).\n`@theholocron/astromech` reads it as the single source for `holocron run`\n/ `holocron run ci` / the generated workflow thin callers:\n\n```typescript\ntasks: [\"lint\", { name: \"release\", with: { \"run-build\": false } }];\n```\n\nOnly add a task if the corresponding capability exists in the repo:\n\n| Task | Requires |\n| ------------- | ------------------------------------------------- |\n| `test` | vitest suite with `--coverage` |\n| `typecheck` | TypeScript (`pnpm typecheck` script) |\n| `audit` | a bundle build step (`pnpm build` script) |\n| `sync-github` | `packages/cli/src/templates/**` — `holocron` only |\n\n### Release workflow — npm prefix and registry-url\n\n**Never run `npm config set prefix <path>` in a release workflow.** It writes\n`prefix=<path>` to `~/.npmrc`, which pnpm reads for npm configuration. With a\nnon-default prefix set, pnpm cannot locate the registry auth it needs to perform\nthe GitHub OIDC token exchange and fails with `ENEEDAUTH` — even when Trusted\nPublishers are correctly configured on npmjs.com.\n\nNode.js from `hostedtoolcache` already provides a user-writable npm prefix on\nPATH. Run `npm install -g <pkg>` directly.\n\n**Never cache `~/.npm-global` or any npm global directory in release workflows.**\nA stale cache restores old auth config that poisons the OIDC exchange.\n\n**Never set `registry-url` in the shared `setup-node` composite action.** It\ncauses `actions/setup-node` to write `//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}`\nto a temp `.npmrc` and set `NPM_CONFIG_USERCONFIG` pointing at it. pnpm then\nreads that file, fails env-var substitution when the token is empty, and loses\nauth entirely.\n\nThe reference implementation is `theholocron/holocron`'s own release workflow —\nno prefix step, no cache, no `registry-url`.\n\n### Discarding a bad sync PR\n\n**Delete the branch, don't only close the PR.** A closed-but-existing branch\nblocks future PR creation — GitHub returns 422 \"A pull request already exists\"\nand the sync silently skips opening a new one.\n\n```sh\ngh pr close <n> --repo <owner>/<repo> --delete-branch\n```\n\n## Code standards\n\n### Package manager\n\n**pnpm only.** Never use `npm` or `yarn`. Run workspace-wide tasks through\nTurbo (`pnpm test`, `pnpm build`, etc.); run single-package tasks with\n`pnpm --filter <name> <script>`.\n\n### TypeScript\n\n**No `any`.** Use `unknown` for values of genuinely unknown shape and narrow\nwith type guards. Use generics instead of `any` in function signatures.\n`as never` and `as unknown as T` are acceptable for internal casts where the\ntype system can't follow; `any` is not.\n\n### Node.js version\n\n`engines.node` must be set in every `package.json`. To update the Node.js\nversion across a repo run `holocron upgrade node <to>` from any repo that has\nthe CLI installed — it patches `engines.node`, `@types/node`, `.nvmrc`,\n`.node-version`, and `.github/workflows/*.yml` automatically.\n\n### Inclusive language (`alex`)\n\n`holocron setup` no longer writes `.alexrc.json` or `.alexignore` (#831). The\ncheck is Sentinel's `lint:language / Run alex`, which reads the org's own\nallow-list, `alexrc.json` in `theholocron/holocron · cli/astromech/src/lint/alex-config/`\n(`ALEX_CONFIG`). To allow a new term across all repos: edit that file, open a PR\nin `holocron`, merge; Sentinel uses it after its next deploy. A repo that still\nhas the two files from an earlier setup can delete them; nothing reads them.\n\n### Running `holocron setup`\n\nInstall `@theholocron/cli` and `@theholocron/holocron-plugin-github` under\n`catalogs.holocron` in `pnpm-workspace.yaml`:\n\n```yaml\ncatalogs:\n holocron:\n \"@theholocron/cli\": <version>\n \"@theholocron/holocron-plugin-github\": <version>\n```\n\nThen run:\n\n```sh\nGITHUB_TOKEN=$(gh auth token) \\\nHOLOCRON_ORG_TOKEN=$(security find-generic-password -s \"com.theholocron.cli\" -a \"github.org\" -w) \\\npnpm exec holocron setup --token $(security find-generic-password -s \"com.theholocron.cli\" -a \"github.admin\" -w)\n```\n\nAll tokens are stored in the macOS keychain under service `com.theholocron.cli`. See `docs/tokens.md` in the `holocron` repo for the full token matrix and required scopes.\n\nBump both catalog entries together when upgrading — they publish in lockstep.\n\n### README structure\n\nEvery repo README follows this layout. Use `holocron sync readme` to regenerate the Installation + Usage block automatically.\n\n```markdown\n# Package Name\n\n<!-- holocron:description -->\n\nOne-line description (synced from holocron.config.ts description field).\n<!-- /holocron:description -->\n\n<!-- holocron:installation -->\n\n## Installation\n\n...generated from package.json bin / exports...\n\n## Usage\n\n...generated from package.json bin / exports...\n<!-- /holocron:installation -->\n\n## What's Included ← template repos only; omit for libraries\n\n...feature table...\n\n## Development\n\npnpm scripts table or code block\n\n## Releases\n\nAutomated via semantic-release. Link to CHANGELOG.md.\n\n## Documentation\n\nLink to docs site.\n```\n\n**Rules:**\n\n- Never write \"Getting Started\" — use separate \"Installation\" and \"Usage\" headings.\n- The `<!-- holocron:description -->` and `<!-- holocron:installation -->` marker blocks must stay in sync with the config/package; run `holocron sync readme` after changing `description` in `holocron.config.ts` or `bin` in `package.json`.\n- The \"What's Included\" section belongs only in template repos (cli-template, node-template, react-template, etc.) where it describes what the template ships. Library and app repos omit it.\n\n---\n\n## This repo (`.github-private`)\n\n> **Local path:** `~/Code/theholocron/github-private/`\n> **GitHub repo:** `theholocron/.github-private`\n\nInternal member documentation and private org-level configuration for the\n`theholocron` org. Content here is only visible to org members.\n\nConventional Commit types used here: `docs:` for content changes, `ci:` for\nworkflow changes, `chore:` for maintenance.\n\nNo test suite (documentation repo). `pnpm lint` runs `yamllint` on workflow\nfiles. Branch protection on `main` requires DCO and passing CI checks.\n";
25755
25619
  // src/commands/repo-files/generate-agent-files.ts
25756
25620
  const ORG_BLOCK_BEGIN = "<!-- BEGIN holocron org agent instructions (generated by `holocron sync` from theholocron/holocron .agents/org.md; do not edit) -->";
25757
25621
  const ORG_BLOCK_END = "<!-- END holocron org agent instructions -->";
25758
- /** The generated block: the org agent instructions between two markers. */
25622
+ /**
25623
+ * The generated block: the org agent instructions between two markers. Its title goes one level down, because the
25624
+ * file it lands in has a title of its own and markdownlint fails a second top-level heading (MD025, #3026).
25625
+ */
25759
25626
  function orgAgentsBlock() {
25760
- return `${ORG_BLOCK_BEGIN}\n\n${org_default.trim()}\n\n${ORG_BLOCK_END}\n`;
25627
+ return `${ORG_BLOCK_BEGIN}\n\n${org_default.trim().replace(/^# /m, "## ")}\n\n${ORG_BLOCK_END}\n`;
25761
25628
  }
25762
25629
  /**
25763
25630
  * `text` with the generated block set to the current org instructions: replaced in place when the markers are there,
@@ -26004,7 +25871,7 @@ function generateConfigFiles(input) {
26004
25871
  const config = input.loaded.resolved;
26005
25872
  const taskNames = (config.tasks ?? []).map((e) => typeof e === "string" ? e : e.name);
26006
25873
  const entries = [];
26007
- if (taskNames.includes("bookkeeping")) entries.push(file(".github/labeler.yml", createLabeler()));
25874
+ if (taskNames.some((name) => isTask(name, "label"))) entries.push(file(".github/labeler.yml", createLabeler()));
26008
25875
  if (config.repo?.protection !== "none") entries.push(file(".github/dependabot.yml", createDependabot({
26009
25876
  ignore: ownCatalogPackages(input.repoRoot),
26010
25877
  sources: hostsReusables(input.repoRoot) ? HOSTED_SOURCES : []
@@ -26110,7 +25977,7 @@ function tryRealpath(path) {
26110
25977
  }
26111
25978
  }
26112
25979
  /**
26113
- * `delivery.previewDeploy`'s package directory plus its `workspace:*`
25980
+ * `deploy-preview`'s package directory plus its `workspace:*`
26114
25981
  * dependencies' directories (holocron#1023) — the reusable workflow's
26115
25982
  * `paths` input, so a PR touching only an unrelated package in the
26116
25983
  * monorepo skips the actual deploy work instead of spinning up a Vercel
@@ -26132,7 +25999,7 @@ function resolvePreviewDeployPaths(gitRoot, cwdValue) {
26132
25999
  return defaultPaths(gitRoot, pkg, all);
26133
26000
  }
26134
26001
  /**
26135
- * Returns `tasks` unchanged unless it has a `delivery.previewDeploy` entry
26002
+ * Returns `tasks` unchanged unless it has a `deploy-preview` entry
26136
26003
  * with a non-root `with.cwd` and no `with.paths` of its own -- in which
26137
26004
  * case that one entry gets an auto-computed `paths` (see
26138
26005
  * {@link resolvePreviewDeployPaths}), added without mutating the input.
@@ -26209,12 +26076,12 @@ function generateWorkflowFiles(input) {
26209
26076
  const entries = [];
26210
26077
  const wanted = tasks.flatMap((entry) => {
26211
26078
  const name = typeof entry === "string" ? entry : entry.name;
26212
- const ids = resolveTaskName(name);
26213
- if (ids.length > 0 && ids.every(({ id }) => TASKS[id]?.workflow === false)) return [];
26214
- return workflowKeys(name).map((key) => ({
26079
+ const id = resolveTaskName(name);
26080
+ if (id !== void 0 && TASKS[id]?.workflow === false) return [];
26081
+ return [{
26215
26082
  name,
26216
- key
26217
- }));
26083
+ key: workflowKey(name)
26084
+ }];
26218
26085
  });
26219
26086
  for (const { name, key } of wanted) {
26220
26087
  const isCombinedContentOnly = key === "deploy-docs" || key === "deploy-components";
@@ -26294,14 +26161,16 @@ function generateWorkflowFiles(input) {
26294
26161
  // src/commands/repo-files/generate-repo-files.ts
26295
26162
  /**
26296
26163
  * Every file `holocron setup` writes to disk from the config alone, in the order it writes them: the thin-caller
26297
- * workflows, the config files, the agent instructions block, `.claude/settings.json` (only when `agent: ["claude", { dcg: true }]` opts in), the private directory (`.holocron/.private/.gitkeep` and its `.gitignore` block), then
26164
+ * workflows, `.github/actionlint.yaml` where a caller carries `cache-mode:`, the config files, the agent instructions block, `.claude/settings.json` (only when `agent: ["claude", { dcg: true }]` opts in), the private directory (`.holocron/.private/.gitkeep` and its `.gitignore` block), then
26298
26165
  * `turbo.json` and its follow-up edits. No provider and no network, so a job without
26299
26166
  * a token can produce them, and `sync` takes the files it shares from here too. What setup reads from a provider
26300
26167
  * (CODEOWNERS, which needs the org, the installed skills, the agent prompts) is not here.
26301
26168
  */
26302
26169
  async function generateRepoFiles(input) {
26170
+ const workflows = generateWorkflowFiles(input);
26303
26171
  return [
26304
- ...generateWorkflowFiles(input),
26172
+ ...workflows,
26173
+ ...generateActionlintFiles(workflows),
26305
26174
  ...generateConfigFiles(input),
26306
26175
  ...await generateAgentFiles(input),
26307
26176
  ...await generateClaudeFiles(input),
@@ -26671,7 +26540,7 @@ cp .agents/skills/adr/assets/template.md docs/wiki/decisions/000N-short-title.md
26671
26540
  \`\`\`
26672
26541
 
26673
26542
  \`madr\` has no CLI — creation is manual. Frontmatter is validated in CI
26674
- via \`holocron probe specs check\` (the \`adrs\` job of \`platform.repoValidation\`).
26543
+ via \`holocron probe specs check\` (the \`adrs\` job of \`validate:specs\`).
26675
26544
 
26676
26545
  ## Status values
26677
26546
 
@@ -33069,12 +32938,12 @@ function render$10(inputs) {
33069
32938
  } },
33070
32939
  files: ["dist"],
33071
32940
  scripts: {
33072
- "delivery.build": "tsdown",
33073
- "sourceQuality.staticAnalysis": "eslint .",
32941
+ build: "tsdown",
32942
+ "lint:code": "eslint .",
33074
32943
  "test:watch": "vitest",
33075
32944
  validate: "tsx scripts/validate.mjs",
33076
- "verification.typeSafety": "tsc --noEmit",
33077
- "verification.unitTests": "vitest run"
32945
+ typecheck: "tsc --noEmit",
32946
+ "test:unit": "vitest run"
33078
32947
  },
33079
32948
  devDependencies: {
33080
32949
  "@theholocron/cli": "workspace:*",
@@ -33629,8 +33498,8 @@ function render(_inputs) {
33629
33498
  * plugins/holocron-plugin-<slug>/<path>. Tests sit beside their source;
33630
33499
  * tsdown.config.ts is written only when the workspace has no root one.
33631
33500
  * 5. Verify (unless --no-verify) — runs pnpm install +
33632
- * pnpm --filter <pkg> verification.typeSafety, sourceQuality.staticAnalysis,
33633
- * verification.unitTests.
33501
+ * pnpm --filter <pkg> typecheck, lint:code,
33502
+ * test:unit.
33634
33503
  * 6. Print next steps.
33635
33504
  */
33636
33505
  /**
@@ -33732,7 +33601,7 @@ function runPluginCreate(input) {
33732
33601
  const print = input.print ?? ((line) => console.log(line));
33733
33602
  const logger = input.logger ?? getLogger();
33734
33603
  const write = input.writeFile ?? defaultWrite;
33735
- preflight$1(cwd);
33604
+ preflight(cwd);
33736
33605
  validateSlug(input.slug);
33737
33606
  validateVendorName(input.vendorName);
33738
33607
  const packageDir = path.join(cwd, "plugins", `holocron-plugin-${input.slug}`);
@@ -33787,7 +33656,7 @@ function runPluginCreate(input) {
33787
33656
  execFn("pnpm", [
33788
33657
  "--filter",
33789
33658
  pkg,
33790
- "verification.typeSafety"
33659
+ "typecheck"
33791
33660
  ], {
33792
33661
  cwd,
33793
33662
  stdio: "inherit"
@@ -33795,7 +33664,7 @@ function runPluginCreate(input) {
33795
33664
  execFn("pnpm", [
33796
33665
  "--filter",
33797
33666
  pkg,
33798
- "sourceQuality.staticAnalysis"
33667
+ "lint:code"
33799
33668
  ], {
33800
33669
  cwd,
33801
33670
  stdio: "inherit"
@@ -33803,7 +33672,7 @@ function runPluginCreate(input) {
33803
33672
  execFn("pnpm", [
33804
33673
  "--filter",
33805
33674
  pkg,
33806
- "verification.unitTests"
33675
+ "test:unit"
33807
33676
  ], {
33808
33677
  cwd,
33809
33678
  stdio: "inherit"
@@ -33839,7 +33708,7 @@ function runPluginCreate(input) {
33839
33708
  filesWritten
33840
33709
  };
33841
33710
  }
33842
- function preflight$1(cwd) {
33711
+ function preflight(cwd) {
33843
33712
  if (!existsSync(path.join(cwd, "pnpm-workspace.yaml"))) throw new PluginCreateError(`\`pnpm-workspace.yaml\` not found in \`${cwd}\`. Run \`holocron new plugin\` from the monorepo root.`);
33844
33713
  const { include } = resolveWorkspaceGlobs(cwd);
33845
33714
  if (!include.some((glob) => existsSync(path.join(cwd, glob.replace(/\/\*$/, ""))))) throw new PluginCreateError(`\`pnpm-workspace.yaml\` in \`${cwd}\` declares no package directory.`);
@@ -33888,9 +33757,9 @@ function printNextSteps$1(print, inputs, filesCount) {
33888
33757
  print("");
33889
33758
  print(" Next:");
33890
33759
  print(` 1. pnpm install # picks up the workspace package`);
33891
- print(` 2. pnpm --filter @theholocron/holocron-plugin-${inputs.slug} verification.typeSafety # green`);
33892
- print(` 3. pnpm --filter @theholocron/holocron-plugin-${inputs.slug} sourceQuality.staticAnalysis # green`);
33893
- print(` 4. pnpm --filter @theholocron/holocron-plugin-${inputs.slug} verification.unitTests # green (stubs pass, real tests are it.todo)`);
33760
+ print(` 2. pnpm --filter @theholocron/holocron-plugin-${inputs.slug} typecheck # green`);
33761
+ print(` 3. pnpm --filter @theholocron/holocron-plugin-${inputs.slug} lint:code # green`);
33762
+ print(` 4. pnpm --filter @theholocron/holocron-plugin-${inputs.slug} test:unit # green (stubs pass, real tests are it.todo)`);
33894
33763
  print(` 5. Implement ${inputs.capabilityClass} methods in src/capabilities/${inputs.capability}.ts`);
33895
33764
  print(` 6. Replace it.todo(...) with real tests in src/capabilities/${inputs.capability}.test.ts`);
33896
33765
  print(" 7. Commit + push when capability is functionally complete.");
@@ -34452,6 +34321,65 @@ const secretSetCommand = {
34452
34321
  })).status === "fail") process.exitCode = 1;
34453
34322
  }
34454
34323
  };
34324
+ // src/commands/rename-scope/rename-scope.ts
34325
+ /** An npm scope, without the `@`: lowercase letters, digits and `-`, `.`, `_`, `~`, starting with a letter or digit. */
34326
+ const SCOPE$2 = /^[a-z0-9][a-z0-9._~-]*$/;
34327
+ var ScopeError = class extends Error {
34328
+ name = "ScopeError";
34329
+ };
34330
+ /**
34331
+ * The npm scope of the new repo's packages: `--scope` (with or without the `@`), else the org that owns the new repo.
34332
+ * A scope npm would refuse is an error, found before anything is created.
34333
+ */
34334
+ function resolveScope(scope, org) {
34335
+ const chosen = (scope ?? org).trim().replace(/^@/, "");
34336
+ if (!SCOPE$2.test(chosen)) throw new ScopeError(`"${scope ?? org}" is not an npm scope: use lowercase letters, digits and - . _ ~ (e.g. acme).`);
34337
+ return chosen;
34338
+ }
34339
+ /**
34340
+ * The names of the packages the template ships: the `name` of every `package.json` in the clone that is in the
34341
+ * templates' scope. A file that cannot be read or parsed, or has no such name, adds none.
34342
+ */
34343
+ function collectPackageNames(input) {
34344
+ const names = [];
34345
+ for (const file of input.walkFiles(input.dir)) {
34346
+ if (path.basename(file) !== "package.json") continue;
34347
+ try {
34348
+ const pkg = JSON.parse(input.readFile(file));
34349
+ if (typeof pkg.name === "string" && pkg.name.startsWith(`@${input.templateScope}/`)) names.push(pkg.name);
34350
+ } catch {}
34351
+ }
34352
+ return names;
34353
+ }
34354
+ /**
34355
+ * Search and replacement pairs that move each of the template's packages to the new scope. A name that starts with the
34356
+ * template's slug (`@theholocron/monorepo-template-site`) also takes the new repo's name (`@acme/my-repo-site`); any
34357
+ * other (`@theholocron/package-a`) keeps its own and takes only the scope. Longest first, so a name that starts
34358
+ * another is not cut short. A dependency on a package outside the template (`@theholocron/eslint-config`) is not listed,
34359
+ * so it stays.
34360
+ */
34361
+ function scopeVariants(input) {
34362
+ const prefix = `@${input.templateScope}/`;
34363
+ return [...new Set(input.packageNames)].map((full) => {
34364
+ const rest = full.slice(prefix.length);
34365
+ const renamed = rest.startsWith(input.templateSlug) ? input.name + rest.slice(input.templateSlug.length) : rest;
34366
+ return [full, `@${input.scope}/${renamed}`];
34367
+ }).sort((a, b) => b[0].length - a[0].length);
34368
+ }
34369
+ // src/commands/replace-variants/replace-variants.ts
34370
+ /**
34371
+ * Replace every search string of `variants` in `content` in ONE pass, longest
34372
+ * search string first, so text a replacement wrote is never searched again
34373
+ * (a new name that contains the template's slug is not grown by the next
34374
+ * variant's pass). A search string listed twice keeps its first replacement.
34375
+ */
34376
+ function replaceVariants(content, variants) {
34377
+ const lookup = /* @__PURE__ */ new Map();
34378
+ for (const [search, replacement] of variants) if (search !== "" && !lookup.has(search)) lookup.set(search, replacement);
34379
+ if (lookup.size === 0) return content;
34380
+ const pattern = [...lookup.keys()].sort((a, b) => b.length - a.length).map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
34381
+ return content.replace(new RegExp(pattern, "g"), (match) => lookup.get(match));
34382
+ }
34455
34383
  // src/commands/new/without-tokens/without-tokens.ts
34456
34384
  /** The names of variables that hold a credential for GitHub, this CLI or 1Password. */
34457
34385
  const CREDENTIAL_NAME = /^(HOLOCRON|GITHUB|GH|OP)_.*(TOKEN|SECRET|KEY)$/;
@@ -34482,6 +34410,130 @@ function defaultExec$1(cmd, args, opts) {
34482
34410
  } } : {}
34483
34411
  });
34484
34412
  }
34413
+ // src/commands/new/default-gh/default-gh.ts
34414
+ /** Runs `gh` with `args` and returns what it gave back, without printing it. */
34415
+ function defaultGh(args) {
34416
+ const result = spawnSync("gh", args, { encoding: "utf8" });
34417
+ return {
34418
+ status: result.status,
34419
+ stdout: result.stdout ?? "",
34420
+ ...result.error ? { error: result.error } : {}
34421
+ };
34422
+ }
34423
+ // src/commands/new/gh-problem/gh-problem.ts
34424
+ /**
34425
+ * What stops `gh` from creating a repository, in words a person can act on: not installed, or not logged in. A
34426
+ * logged-out `gh` would otherwise fail inside `gh repo create` with a message that names neither. `undefined` when `gh`
34427
+ * is ready.
34428
+ */
34429
+ function ghProblem(gh) {
34430
+ const version = gh(["--version"]);
34431
+ if (version.error != null || version.status !== 0) return "`gh` CLI is not installed or not on PATH. Install it from https://cli.github.com";
34432
+ if (gh([
34433
+ "auth",
34434
+ "status",
34435
+ "--hostname",
34436
+ "github.com"
34437
+ ]).status !== 0) return "`gh` is not logged in to GitHub. Run `gh auth login`, then try again.";
34438
+ }
34439
+ // src/commands/new/patch-holocron-config/patch-holocron-config.ts
34440
+ const PROVIDERS = "...preset.providers";
34441
+ const PROPERTIES = "...preset.repo?.properties,";
34442
+ /**
34443
+ * Sets the repo-specific fields of a template's own `holocron.config.ts` and leaves the rest (the tasks, the
34444
+ * providers, the teams) as the template wrote them. Every template lays these fields out the same way, one per
34445
+ * line at a fixed indent, so each is found by its line; a field the file does not have is an error that names it,
34446
+ * never a silent skip.
34447
+ */
34448
+ function patchHolocronConfig(source, opts) {
34449
+ let out = source;
34450
+ const org = opts.org ?? "theholocron";
34451
+ if (opts.description !== void 0) out = setLine(out, " ", "description", JSON.stringify(opts.description));
34452
+ if (opts.homepage !== void 0) out = setLine(out, " ", "homepage", JSON.stringify(opts.homepage));
34453
+ out = setLine(out, " ", "name", JSON.stringify(`${org}/${opts.name}`));
34454
+ if (opts.topics?.length) out = setLine(out, " ", "topics", JSON.stringify(opts.topics));
34455
+ if (opts.protection && opts.protection !== "strict") out = setOrInsert(out, " ", "protection", JSON.stringify(opts.protection), "name");
34456
+ const properties = [];
34457
+ if (opts.openSource !== void 0) properties.push(["open_source", String(opts.openSource)]);
34458
+ if (opts.usesExternalPackages !== void 0) properties.push(["uses_external_packages", String(opts.usesExternalPackages)]);
34459
+ if (opts.runtimeEnvironment && opts.runtimeEnvironment !== "node") properties.push(["runtime_environment", JSON.stringify(opts.runtimeEnvironment)]);
34460
+ if (properties.length && !source.includes(`\t\t\t${PROPERTIES}`)) out = insertAfter(out, " ", "...preset.repo,", `\t\tproperties: {\n\t\t\t${PROPERTIES}\n\t\t},`);
34461
+ for (const [key, value] of properties) out = setOrInsert(out, " ", key, value, PROPERTIES);
34462
+ if (opts.vaultProvider === "doppler") {
34463
+ const project = JSON.stringify(opts.vaultProject ?? opts.name);
34464
+ const config = JSON.stringify(opts.vaultConfig ?? "dev");
34465
+ out = setOrInsert(out, " ", "vault", `["doppler", { project: ${project}, config: ${config} }]`, PROVIDERS);
34466
+ } else if (opts.vaultProvider === "1password") {
34467
+ const vault = JSON.stringify(opts.vaultProject ?? opts.name);
34468
+ out = setOrInsert(out, " ", "vault", `["1password", { vault: ${vault} }]`, PROVIDERS);
34469
+ } else if (opts.vaultProvider === "infisical") {
34470
+ const project = JSON.stringify(opts.vaultProject ?? opts.name);
34471
+ out = setOrInsert(out, " ", "vault", `["infisical", { project: ${project} }]`, PROVIDERS);
34472
+ }
34473
+ if (opts.deploymentProvider === "vercel") out = setOrInsert(out, " ", "deployment", `"vercel"`, PROVIDERS);
34474
+ if (opts.agent === "none") out = removeLine(out, "agent");
34475
+ else if (opts.agent) out = setOrAppend(out, "agent", JSON.stringify(opts.agent));
34476
+ if (opts.skills?.length) out = setOrAppend(out, "skills", JSON.stringify(opts.skills));
34477
+ return out;
34478
+ }
34479
+ const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
34480
+ /** The line `<indent><key>: ...,` of the file. */
34481
+ function lineOf(source, indent, key) {
34482
+ return new RegExp(`^${indent}${escape(key)}: .*,$`, "m").exec(source);
34483
+ }
34484
+ function missing(key) {
34485
+ return /* @__PURE__ */ new Error(`cannot find \`${key}\` in the template's holocron.config.ts`);
34486
+ }
34487
+ function replaceAt(source, found, text) {
34488
+ return source.slice(0, found.index) + text + source.slice(found.index + found[0].length);
34489
+ }
34490
+ function setLine(source, indent, key, value) {
34491
+ const found = lineOf(source, indent, key);
34492
+ if (!found) throw missing(key);
34493
+ return replaceAt(source, found, `${indent}${key}: ${value},`);
34494
+ }
34495
+ /** Sets the line when the file has it, else puts it after the line that starts with `anchor`. */
34496
+ function setOrInsert(source, indent, key, value, anchor) {
34497
+ const found = lineOf(source, indent, key);
34498
+ if (found) return replaceAt(source, found, `${indent}${key}: ${value},`);
34499
+ return insertAfter(source, indent, anchor, `${indent}${key}: ${value},`);
34500
+ }
34501
+ /** Puts `text` on a new line after the line that starts with `anchor`. */
34502
+ function insertAfter(source, indent, anchor, text) {
34503
+ const after = new RegExp(`^${indent}${escape(anchor)}.*$`, "m").exec(source);
34504
+ if (!after) throw missing(anchor);
34505
+ return replaceAt(source, after, `${after[0]}\n${text}`);
34506
+ }
34507
+ function removeLine(source, key) {
34508
+ const found = lineOf(source, " ", key);
34509
+ return found ? source.replace(`${found[0]}\n`, "") : source;
34510
+ }
34511
+ /** A top-level key: set when the file has it, else added before the closing `});`. */
34512
+ function setOrAppend(source, key, value) {
34513
+ const found = lineOf(source, " ", key);
34514
+ if (found) return replaceAt(source, found, `\t${key}: ${value},`);
34515
+ const end = source.lastIndexOf("\n});");
34516
+ if (end === -1) throw new Error(`cannot find the closing \`});\` of the template's holocron.config.ts to add \`${key}\``);
34517
+ return `${source.slice(0, end)}\n\t${key}: ${value},${source.slice(end)}`;
34518
+ }
34519
+ // src/commands/new/template-problem/template-problem.ts
34520
+ /**
34521
+ * What stops `gh repo create --template <repo>` from working: the repository cannot be read, or it is not flagged as
34522
+ * a template repository (GitHub refuses it otherwise). `undefined` when `repo` is a template.
34523
+ */
34524
+ function templateProblem(gh, repo) {
34525
+ const view = gh([
34526
+ "repo",
34527
+ "view",
34528
+ repo,
34529
+ "--json",
34530
+ "isTemplate",
34531
+ "--jq",
34532
+ ".isTemplate"
34533
+ ]);
34534
+ if (view.status !== 0) return `Could not read the template repository ${repo}. Check the name and that this \`gh\` login can see it.`;
34535
+ if (view.stdout.trim() !== "true") return `${repo} is not flagged as a template repository. Turn it on with \`gh repo edit ${repo} --template\`, then try again.`;
34536
+ }
34485
34537
  // src/commands/new/new.ts
34486
34538
  /**
34487
34539
  * `holocron new repo <type> <name>` — create a GitHub repo from a template and
@@ -34490,16 +34542,19 @@ function defaultExec$1(cmd, args, opts) {
34490
34542
  * during the interactive wizard.
34491
34543
  *
34492
34544
  * Flow:
34493
- * 1. Preflight — verify `gh` CLI is available.
34545
+ * 1. Preflight — verify `gh` is installed and logged in, and that the template repo is flagged as a template.
34494
34546
  * 2. Resolve type, name, description, homepage, vault/deployment/agent options.
34495
34547
  * 3. `gh repo create <org>/<name> --template <org>/<type>-template --private --clone`
34496
34548
  * → clones to `<cwd>/<name>/`
34497
34549
  * 4. Detect template slug from cloned package.json.
34498
34550
  * 5. Replace all casing variants of the slug across every text file.
34499
34551
  * 6. Replace `<description>` and `<homepage>` placeholders.
34500
- * 7. Generate and write `holocron.config.ts` based on wizard answers.
34552
+ * 7. Keep the template's own `holocron.config.ts` and set its repo fields from the wizard answers; a template
34553
+ * with none gets one generated.
34501
34554
  * 8. Commit the patched files (-s for DCO).
34502
- * 9. Unless --no-verify: `pnpm install` in the new repo.
34555
+ * 9. Unless --no-verify: `pnpm install`, then `sync` and `setup` of this same CLI in the new repo, the admin token
34556
+ * in their environment (`HOLOCRON_ADMIN_TOKEN`), not on their command line, then `pnpm install` again so the
34557
+ * lockfile matches the package.json that `sync` edited (#3008).
34503
34558
  * 10. Print next steps.
34504
34559
  */
34505
34560
  const env$4 = createEnvLookup();
@@ -34631,7 +34686,7 @@ function patchFiles(dir, variants, description, homepage, runtimeEnvironment, pr
34631
34686
  }
34632
34687
  if (isBinary(content)) continue;
34633
34688
  const original = content;
34634
- for (const [search, replacement] of variants) content = content.split(search).join(replacement);
34689
+ content = replaceVariants(content, variants);
34635
34690
  if (description !== void 0) {
34636
34691
  content = content.split("<description>").join(description);
34637
34692
  content = content.replace(/(<!-- holocron:description -->)[\s\S]*?(<!-- \/holocron:description -->)/g, `$1\n${description}\n$2`);
@@ -34647,10 +34702,6 @@ function patchFiles(dir, variants, description, homepage, runtimeEnvironment, pr
34647
34702
  }
34648
34703
  return patched;
34649
34704
  }
34650
- function preflight() {
34651
- const result = spawnSync("gh", ["--version"], { encoding: "utf8" });
34652
- if (result.error != null || result.status !== 0) throw new NewError("`gh` CLI is not installed or not on PATH. Install it from https://cli.github.com");
34653
- }
34654
34705
  function keychainLookup(key) {
34655
34706
  const result = spawnSync("security", [
34656
34707
  "find-generic-password",
@@ -34669,6 +34720,20 @@ function defaultWriteFile(filepath, content) {
34669
34720
  mkdirSync(path.dirname(filepath), { recursive: true });
34670
34721
  writeFileSync(filepath, content, "utf-8");
34671
34722
  }
34723
+ /** The second install, after `sync` and `setup` edited package.json; a failure is a warning, the repo is made. */
34724
+ function refreshLockfile(execFn, repoDir, print) {
34725
+ print("");
34726
+ print(" Updating pnpm-lock.yaml to match package.json…");
34727
+ try {
34728
+ execFn("pnpm", ["install"], {
34729
+ cwd: repoDir,
34730
+ stdio: "inherit",
34731
+ cleanEnv: true
34732
+ });
34733
+ } catch (err) {
34734
+ print(` ✗ pnpm install failed (${errorMessage(err)}) — run it by hand: cd ${repoDir} && pnpm install`);
34735
+ }
34736
+ }
34672
34737
  async function runNew(input) {
34673
34738
  const cwd = input.cwd ?? process.cwd();
34674
34739
  const org = input.org ?? DEFAULT_ORG;
@@ -34679,7 +34744,10 @@ async function runNew(input) {
34679
34744
  const writeFn = input.writeFile ?? defaultWriteFile;
34680
34745
  const walkFn = input.walkFiles ?? defaultWalkFiles;
34681
34746
  const self = input.selfCommand ?? [process.execPath, process.argv[1]];
34682
- preflight();
34747
+ const gh = input.gh ?? defaultGh;
34748
+ const ghIssue = ghProblem(gh);
34749
+ if (ghIssue) throw new NewError(ghIssue);
34750
+ const scope = resolveScope(input.scope, org);
34683
34751
  const templateRepo = `${org}/${input.type}-template`;
34684
34752
  const newRepo = `${org}/${input.name}`;
34685
34753
  const repoDir = path.join(cwd, input.name);
@@ -34692,6 +34760,7 @@ async function runNew(input) {
34692
34760
  print(` Would create ${newRepo} from template ${templateRepo}`);
34693
34761
  print(` Would clone to ${repoDir}`);
34694
34762
  print(` Would patch all casing variants of "${input.type}-template" → "${input.name}"`);
34763
+ print(` Would move the template's packages from @${DEFAULT_ORG}/ to @${scope}/`);
34695
34764
  if (input.description) print(` Would replace <description> → "${input.description}"`);
34696
34765
  if (input.homepage) print(` Would replace <homepage> → "${input.homepage}"`);
34697
34766
  if (input.runtimeEnvironment) print(` Would replace <runtime_environment> → "${input.runtimeEnvironment}"`);
@@ -34704,8 +34773,11 @@ async function runNew(input) {
34704
34773
  return { status: "dry-run" };
34705
34774
  }
34706
34775
  if (existsSync(repoDir)) throw new NewError(`\`${repoDir}\` already exists — delete it or pick a different name.`);
34776
+ const templateIssue = templateProblem(gh, templateRepo);
34777
+ if (templateIssue) throw new NewError(templateIssue);
34707
34778
  print(` Creating ${newRepo} from template ${templateRepo}…`);
34708
34779
  const visibility = input.openSource ? "--public" : "--private";
34780
+ const describe = input.description ? [`--description=${input.description}`] : [];
34709
34781
  try {
34710
34782
  execFn("gh", [
34711
34783
  "repo",
@@ -34713,6 +34785,7 @@ async function runNew(input) {
34713
34785
  newRepo,
34714
34786
  `--template=${templateRepo}`,
34715
34787
  visibility,
34788
+ ...describe,
34716
34789
  "--clone"
34717
34790
  ], {
34718
34791
  cwd,
@@ -34737,7 +34810,8 @@ async function runNew(input) {
34737
34810
  "repo",
34738
34811
  "edit",
34739
34812
  newRepo,
34740
- `--visibility=${input.openSource ? "public" : "private"}`
34813
+ `--visibility=${input.openSource ? "public" : "private"}`,
34814
+ "--accept-visibility-change-consequences"
34741
34815
  ], {
34742
34816
  cwd,
34743
34817
  stdio: "inherit"
@@ -34755,6 +34829,8 @@ async function runNew(input) {
34755
34829
  };
34756
34830
  const hasPackageJson = canRead(pkgJsonPath);
34757
34831
  const hasJsonConfig = canRead(path.join(repoDir, "holocron.config.json"));
34832
+ const tsConfigPath = path.join(repoDir, "holocron.config.ts");
34833
+ const hasTsConfig = canRead(tsConfigPath);
34758
34834
  if (existsSync(pkgJsonPath)) try {
34759
34835
  const pkg = JSON.parse(readFn(pkgJsonPath));
34760
34836
  if (typeof pkg.name === "string") templateSlug = pkg.name.split("/").at(-1) || templateSlug;
@@ -34763,6 +34839,18 @@ async function runNew(input) {
34763
34839
  print(` Patching files…`);
34764
34840
  const variants = deriveVariants(templateSlug, input.name);
34765
34841
  variants.unshift([`${DEFAULT_ORG}/${templateSlug}`, `${org}/${input.name}`]);
34842
+ variants.unshift(...scopeVariants({
34843
+ packageNames: collectPackageNames({
34844
+ dir: repoDir,
34845
+ walkFiles: walkFn,
34846
+ readFile: readFn,
34847
+ templateScope: DEFAULT_ORG
34848
+ }),
34849
+ templateSlug,
34850
+ name: input.name,
34851
+ scope,
34852
+ templateScope: DEFAULT_ORG
34853
+ }));
34766
34854
  const filesPatched = patchFiles(repoDir, variants, input.description, input.homepage, input.runtimeEnvironment, print, readFn, writeFn, walkFn);
34767
34855
  print(` ${filesPatched.length} file${filesPatched.length === 1 ? "" : "s"} patched`);
34768
34856
  if (input.description !== void 0 || input.homepage !== void 0) try {
@@ -34784,27 +34872,34 @@ async function runNew(input) {
34784
34872
  print(` ✓ tsconfig.json (display)`);
34785
34873
  }
34786
34874
  } catch {}
34875
+ const configOptions = {
34876
+ name: input.name,
34877
+ type: input.type,
34878
+ org,
34879
+ description: input.description,
34880
+ homepage: input.homepage,
34881
+ vaultProvider: input.vaultProvider,
34882
+ vaultProject: input.vaultProject,
34883
+ vaultConfig: input.vaultConfig,
34884
+ deploymentProvider: input.deploymentProvider,
34885
+ agent: input.agent,
34886
+ runtimeEnvironment: input.runtimeEnvironment,
34887
+ protection: input.protection,
34888
+ openSource: input.openSource,
34889
+ usesExternalPackages: input.usesExternalPackages,
34890
+ topics: input.topics,
34891
+ skills: input.skills
34892
+ };
34787
34893
  if (hasJsonConfig) print(` Kept holocron.config.json`);
34788
- else {
34789
- const configContent = generateHolocronConfig({
34790
- name: input.name,
34791
- type: input.type,
34792
- org,
34793
- description: input.description,
34794
- homepage: input.homepage,
34795
- vaultProvider: input.vaultProvider,
34796
- vaultProject: input.vaultProject,
34797
- vaultConfig: input.vaultConfig,
34798
- deploymentProvider: input.deploymentProvider,
34799
- agent: input.agent,
34800
- runtimeEnvironment: input.runtimeEnvironment,
34801
- protection: input.protection,
34802
- openSource: input.openSource,
34803
- usesExternalPackages: input.usesExternalPackages,
34804
- topics: input.topics,
34805
- skills: input.skills
34806
- });
34807
- writeFn(path.join(repoDir, "holocron.config.ts"), configContent);
34894
+ else if (hasTsConfig) {
34895
+ try {
34896
+ writeFn(tsConfigPath, patchHolocronConfig(readFn(tsConfigPath), configOptions));
34897
+ } catch (err) {
34898
+ throw new NewError(`holocron.config.ts of the template: ${errorMessage(err)}`);
34899
+ }
34900
+ print(` Kept holocron.config.ts, set its repo fields`);
34901
+ } else {
34902
+ writeFn(tsConfigPath, generateHolocronConfig(configOptions));
34808
34903
  print(` Generated holocron.config.ts`);
34809
34904
  }
34810
34905
  execFn("git", ["add", "-A"], {
@@ -34839,8 +34934,8 @@ async function runNew(input) {
34839
34934
  message: "pnpm install failed; inspect output above"
34840
34935
  };
34841
34936
  }
34842
- const adminToken = input.token ?? keychainLookup("github.admin");
34843
- const tokenEnv = {};
34937
+ const adminToken = input.token ?? resolveValue$2(["ADMIN_TOKEN"], void 0, { prefix: PREFIX$1 }) ?? keychainLookup("github.admin");
34938
+ const tokenEnv = adminToken ? { HOLOCRON_ADMIN_TOKEN: adminToken } : {};
34844
34939
  if (!env$4.get("HOLOCRON_ORG_TOKEN")) {
34845
34940
  const orgToken = keychainLookup("github.org");
34846
34941
  if (orgToken) tokenEnv["HOLOCRON_ORG_TOKEN"] = orgToken;
@@ -34855,12 +34950,7 @@ async function runNew(input) {
34855
34950
  else {
34856
34951
  print(" Running holocron sync…");
34857
34952
  try {
34858
- execFn(self[0], [
34859
- ...self.slice(1),
34860
- "sync",
34861
- "--token",
34862
- adminToken
34863
- ], {
34953
+ execFn(self[0], [...self.slice(1), "sync"], {
34864
34954
  cwd: repoDir,
34865
34955
  stdio: "inherit",
34866
34956
  env: tokenEnv
@@ -34872,9 +34962,7 @@ async function runNew(input) {
34872
34962
  print("");
34873
34963
  print(" Running holocron setup…");
34874
34964
  try {
34875
- const setupArgs = ["setup"];
34876
- if (adminToken) setupArgs.push("--token", adminToken);
34877
- execFn("holocron", setupArgs, {
34965
+ execFn(self[0], [...self.slice(1), "setup"], {
34878
34966
  cwd: repoDir,
34879
34967
  stdio: "inherit",
34880
34968
  env: tokenEnv
@@ -34882,6 +34970,7 @@ async function runNew(input) {
34882
34970
  } catch {
34883
34971
  print(" ✗ holocron setup failed — run it manually after checking your config");
34884
34972
  }
34973
+ if (hasPackageJson) refreshLockfile(execFn, repoDir, print);
34885
34974
  }
34886
34975
  print("");
34887
34976
  print(` Scaffolded ${newRepo} (${filesPatched.length} file${filesPatched.length === 1 ? "" : "s"} patched).`);
@@ -34892,7 +34981,8 @@ async function runNew(input) {
34892
34981
  print(` 2. pnpm install`);
34893
34982
  print(` 3. holocron sync # thin callers, org AGENTS.md block, generated files`);
34894
34983
  print(` 4. holocron setup # wire up secrets, teams, labels, etc.`);
34895
- print(` 5. git push -u origin HEAD`);
34984
+ print(` 5. pnpm install # again: sync edits package.json, and the lockfile has to match it`);
34985
+ print(` 6. git push -u origin HEAD`);
34896
34986
  } else print(` 2. git push -u origin HEAD`);
34897
34987
  logger.info({
34898
34988
  repo: newRepo,
@@ -34936,10 +35026,15 @@ const newRepoArgs = (y) => y.positional("type", {
34936
35026
  describe: "Comma-separated repo topics (e.g. typescript,nodejs)"
34937
35027
  }).option("protection", {
34938
35028
  type: "string",
34939
- describe: "Branch protection level: strict, balanced, minimal"
35029
+ choices: [
35030
+ "strict",
35031
+ "balanced",
35032
+ "none"
35033
+ ],
35034
+ describe: "Branch protection level: strict, balanced, none"
34940
35035
  }).option("open-source", {
34941
35036
  type: "boolean",
34942
- describe: "Whether the repo is open source (default: true)"
35037
+ describe: "Make the repo public (--open-source) or private (--no-open-source); required, asked on a terminal"
34943
35038
  }).option("uses-external-packages", {
34944
35039
  type: "boolean",
34945
35040
  describe: "Whether the repo calls external APIs or services (default: true)"
@@ -34953,10 +35048,13 @@ const newRepoArgs = (y) => y.positional("type", {
34953
35048
  type: "string",
34954
35049
  default: DEFAULT_ORG,
34955
35050
  describe: "GitHub org that owns the template and will own the new repo"
35051
+ }).option("scope", {
35052
+ type: "string",
35053
+ describe: "npm scope for the packages the template ships (default: the org, so @<org>/<name>)"
34956
35054
  }).option("verify", {
34957
35055
  type: "boolean",
34958
35056
  default: true,
34959
- describe: "Run pnpm install + holocron setup after bootstrapping (--no-verify skips)"
35057
+ describe: "Run pnpm install, holocron sync and holocron setup after bootstrapping (--no-verify skips all three)"
34960
35058
  });
34961
35059
  // src/commands/new/new-repo-wizard.ts
34962
35060
  /** `holocron new repo`'s interactive wizard: asks for every field not already supplied as an argument. */
@@ -35116,20 +35214,21 @@ async function askNewRepoAnswers(argv, prompts = {
35116
35214
  value: "balanced"
35117
35215
  },
35118
35216
  {
35119
- name: "minimal — branch protection only",
35120
- value: "minimal"
35217
+ name: "none — no branch ruleset",
35218
+ value: "none"
35121
35219
  }
35122
35220
  ]
35123
35221
  });
35124
35222
  if (openSource === void 0) openSource = await choose({
35125
- message: "Open source?",
35223
+ message: "Open source (a public repository)?",
35126
35224
  choices: [{
35127
- name: "Yes",
35128
- value: "yes"
35129
- }, {
35130
- name: "No",
35225
+ name: "No (private)",
35131
35226
  value: "no"
35132
- }]
35227
+ }, {
35228
+ name: "Yes (public)",
35229
+ value: "yes"
35230
+ }],
35231
+ default: "no"
35133
35232
  }) === "yes";
35134
35233
  if (usesExternalPackages === void 0) usesExternalPackages = await choose({
35135
35234
  message: "Uses external APIs or services?",
@@ -35168,6 +35267,11 @@ const newRepoCommand = {
35168
35267
  builder: newRepoArgs,
35169
35268
  handler: async (argv) => {
35170
35269
  try {
35270
+ if (argv["open-source"] === void 0 && process.stdin.isTTY !== true) {
35271
+ reportError("new: say whether the repo is public: pass --open-source or --no-open-source");
35272
+ process.exitCode = 1;
35273
+ return;
35274
+ }
35171
35275
  const tokens = tokenContext(argv.token);
35172
35276
  if (!tokens) return;
35173
35277
  const adminToken = tokens.cliTokens?.["github"] ?? tokens.cliToken;
@@ -35196,19 +35300,20 @@ const newRepoCommand = {
35196
35300
  agent: agent ?? "claude",
35197
35301
  runtimeEnvironment: runtimeEnvironment ?? "node",
35198
35302
  protection: protection ?? "strict",
35199
- openSource: openSource ?? true,
35303
+ openSource,
35200
35304
  usesExternalPackages: usesExternalPackages ?? true,
35201
35305
  topics,
35202
35306
  skills,
35203
35307
  isTemplate,
35204
35308
  org: argv.org,
35309
+ scope: argv.scope,
35205
35310
  token: adminToken,
35206
35311
  dryRun: argv.dryRun,
35207
35312
  noVerify: !argv.verify,
35208
35313
  cwd: argv.cwd
35209
35314
  })).status === "fail") process.exitCode = 1;
35210
35315
  } catch (err) {
35211
- if (err instanceof NewError) {
35316
+ if (err instanceof NewError || err instanceof ScopeError) {
35212
35317
  reportError(`new: ${err.message}`);
35213
35318
  process.exitCode = 1;
35214
35319
  return;
@@ -35693,12 +35798,6 @@ const probeArgs = (y) => y.positional("provider", {
35693
35798
  }).option("lcov", {
35694
35799
  type: "string",
35695
35800
  describe: "Also write the coverage a `docs` probe measures to this lcov file (relative to the repo root)"
35696
- }).option("warn", {
35697
- type: "boolean",
35698
- describe: "`tasks names`: report each old task name as an info row instead of failing"
35699
- }).option("files", {
35700
- type: "boolean",
35701
- describe: "`tasks names`: also report old names that are part of a workflow file name (`delivery.build.yml`)"
35702
35801
  }).option("only", {
35703
35802
  type: "string",
35704
35803
  array: true,
@@ -36067,7 +36166,7 @@ function workspaceDirs(root, yamlText) {
36067
36166
  const dirs = [""];
36068
36167
  for (const line of packagesBlock.split("\n")) {
36069
36168
  const glob = line.match(/^\s+-\s+"?([^"\n]+?)"?\s*$/)?.[1];
36070
- if (!glob || glob.startsWith("!")) continue;
36169
+ if (!glob || glob.startsWith("!") || glob === ".") continue;
36071
36170
  if (glob.endsWith("/*")) {
36072
36171
  const base = glob.slice(0, -2);
36073
36172
  if (!existsSync(join(root, base))) continue;
@@ -36082,6 +36181,18 @@ function resolveSpec(spec, name, catalogs) {
36082
36181
  return catalogs[spec.slice(8) || "default"]?.[name];
36083
36182
  }
36084
36183
  /**
36184
+ * The named catalog a dependency that only the root manifest uses already sits in, when every edge names the same one.
36185
+ * The root is no group, so the rule has nothing to say about where its own tooling goes, and the org's convention is
36186
+ * a catalog per family (`catalogs.holocron` for the CLI and its plugins, `catalogs.configs` for the shareable configs,
36187
+ * which `missing-plugin-hint` tells a repo to write): a repo made from a template keeps them.
36188
+ */
36189
+ function rootOnlyCatalog(groups, edges) {
36190
+ if (groups.size !== 1 || !groups.has("root")) return void 0;
36191
+ const names = new Set(edges.map((e) => e.spec.startsWith("catalog:") ? e.spec.slice(8) : ""));
36192
+ const [name] = names;
36193
+ return names.size === 1 && name && name !== "default" ? name : void 0;
36194
+ }
36195
+ /**
36085
36196
  * Reads every workspace manifest and `pnpm-workspace.yaml` live and works out, for every dependency, the catalog it
36086
36197
  * belongs in and its range, plus the entries that need a human look.
36087
36198
  */
@@ -36123,7 +36234,7 @@ function planDeps(root) {
36123
36234
  edges: entry.edges
36124
36235
  });
36125
36236
  continue;
36126
- } else target = targetCatalog(entry.groups);
36237
+ } else target = rootOnlyCatalog(entry.groups, nonPeer) ?? targetCatalog(entry.groups);
36127
36238
  const usedFrom = isScoped && nonPeer.length === 0 ? peers : nonPeer;
36128
36239
  const ranges = [];
36129
36240
  for (const e of usedFrom) {
@@ -36351,7 +36462,7 @@ function newPublicPackages(addedFiles, io) {
36351
36462
  * root `index`) with no docs signal for that package: its README, a docs page named after it, or a doc comment added
36352
36463
  * in its source. `[skip docs] <reason>` in the PR description (`PR_BODY`) or a commit message excuses it, scoped with
36353
36464
  * `[skip docs: <package>]`; a marker with no reason excuses nothing. This is the `docsEnforcement` job of
36354
- * `platform.repoValidation`. The base to diff against is `HOLOCRON_BASE_SHA`, else `BASE_SHA` (default `HEAD~1`); the title and body are `HOLOCRON_PR_TITLE` / `HOLOCRON_PR_BODY`, else `PR_TITLE` / `PR_BODY`.
36465
+ * `validate:specs`. The base to diff against is `HOLOCRON_BASE_SHA`, else `BASE_SHA` (default `HEAD~1`); the title and body are `HOLOCRON_PR_TITLE` / `HOLOCRON_PR_BODY`, else `PR_TITLE` / `PR_BODY`.
36355
36466
  */
36356
36467
  function docsPresenceProbe(io) {
36357
36468
  return {
@@ -37197,28 +37308,16 @@ async function generatePackageWorkflows(repoRoot) {
37197
37308
  }
37198
37309
  // src/commands/probe/generated/check-scripts.ts
37199
37310
  /**
37200
- * Problems with the scripts: a root script that differs from what `scriptsFor` writes (a hand edit is drift, as it is
37201
- * for any generated file), and in every `package.json` a script that breaks a naming or recursion rule
37202
- * (`checkPackageScripts`). A deprecated dotted name is reported once for the whole repo, not failed, while the old
37203
- * names are accepted.
37311
+ * The lines that fail the check: a root script that differs from what `scriptsFor` writes (a hand edit is drift, as it
37312
+ * is for any generated file), and in every `package.json` a script that breaks a naming or recursion rule
37313
+ * (`checkPackageScripts`).
37204
37314
  */
37205
37315
  function checkScripts({ packages, desired, turboKeys }) {
37206
- const problems = {
37207
- fail: [],
37208
- info: []
37209
- };
37210
- const deprecated = [];
37316
+ const problems = [];
37211
37317
  for (const { location, scripts } of packages) {
37212
37318
  const file = location === "." ? "package.json" : `${location}/package.json`;
37213
- if (location === "." && desired !== null) for (const name of mergeScripts(scripts, desired, turboKeys).changed) problems.fail.push(`${file}: script "${name}" is ${scripts[name] === void 0 ? "missing" : JSON.stringify(scripts[name])}, holocron generates ${JSON.stringify(desired[name])}; run \`holocron sync\` and commit the result`);
37214
- const found = checkPackageScripts(scripts, location === "." ? "root" : "package");
37215
- for (const problem of found.filter((p) => p.level === "fail")) problems.fail.push(`${file}: ${problem.message}`);
37216
- const names = found.filter((p) => p.level === "warn").map((p) => p.script);
37217
- if (names.length > 0) deprecated.push(`${file} (${names.join(", ")})`);
37218
- }
37219
- if (deprecated.length > 0) {
37220
- const [first] = deprecated;
37221
- problems.info.push(`deprecated task names still used as scripts in ${deprecated.length} package.json file(s), for example ${first}: rename them to flat ids`);
37319
+ if (location === "." && desired !== null) for (const name of mergeScripts(scripts, desired, turboKeys).changed) problems.push(`${file}: script "${name}" is ${scripts[name] === void 0 ? "missing" : JSON.stringify(scripts[name])}, holocron generates ${JSON.stringify(desired[name])}; run \`holocron sync\` and commit the result`);
37320
+ for (const problem of checkPackageScripts(scripts, location === "." ? "root" : "package")) problems.push(`${file}: ${problem.message}`);
37222
37321
  }
37223
37322
  return problems;
37224
37323
  }
@@ -37326,8 +37425,7 @@ function generatedProbes(loaded, repoRoot, statusContexts, coverageFiles) {
37326
37425
  workflows
37327
37426
  })
37328
37427
  ];
37329
- const scripts = checkScripts(scriptsInput(loaded, repoRoot));
37330
- problems.push(...scripts.fail);
37428
+ problems.push(...checkScripts(scriptsInput(loaded, repoRoot)));
37331
37429
  for (const line of problems) ctx.say({
37332
37430
  status: "fail",
37333
37431
  label: line
@@ -37336,10 +37434,6 @@ function generatedProbes(loaded, repoRoot, statusContexts, coverageFiles) {
37336
37434
  status: "info",
37337
37435
  label: line
37338
37436
  });
37339
- for (const line of scripts.info) ctx.say({
37340
- status: "info",
37341
- label: line
37342
- });
37343
37437
  if (problems.length === 0) ctx.say({
37344
37438
  status: "ok",
37345
37439
  label: `${first.files.length} files`,
@@ -37405,7 +37499,7 @@ function filesToRead(args, io) {
37405
37499
  * and spec; with files it checks the ones among them that are an ADR or a spec, and ignores the rest. An error fails
37406
37500
  * the run (a bad or missing `id`, `title`, `status` or `date`, an unknown status, no frontmatter); a warning is
37407
37501
  * reported and never fails it (an accepted ADR with no discussion link, a spec with no issue). This is the `adrs` job of
37408
- * `platform.repoValidation`; the rules are `checkSpecs` in `@theholocron/astromech/repo-validation`, which Sentinel runs on
37502
+ * `validate:specs`; the rules are `checkSpecs` in `@theholocron/astromech/repo-validation`, which Sentinel runs on
37409
37503
  * a pull request's files too.
37410
37504
  */
37411
37505
  function specsCheckProbe(io) {
@@ -37470,7 +37564,6 @@ async function runProbeCommand(input) {
37470
37564
  })));
37471
37565
  groups.set("ci", ciProbes(input.context.org));
37472
37566
  groups.set(SPECS_PROVIDER, specsProbes(realSpecsIo(input.context.repoRoot)));
37473
- groups.set(TASKS_PROVIDER, tasksProbes(realTasksIo(input.context.repoRoot)));
37474
37567
  if (!input.provider || !groups.has(input.provider)) {
37475
37568
  extras = input.workspaceProviders ?? await workspaceProviders(input.context.repoRoot, input.loaded.resolved);
37476
37569
  if (extras.length > 0) {
@@ -37610,8 +37703,6 @@ const probeCommand = {
37610
37703
  applyResolvedConfig(argv, loaded.resolved);
37611
37704
  const args = [
37612
37705
  ...(argv.args ?? []).map(String),
37613
- ...argv.warn ? ["--warn"] : [],
37614
- ...argv.files ? ["--files"] : [],
37615
37706
  ...(argv.only ?? []).flatMap((name) => ["--only", String(name)]),
37616
37707
  ...argv.copy ? ["--copy"] : [],
37617
37708
  ...(argv["--"] ?? []).map(String)
@@ -40455,7 +40546,7 @@ const removeCommand = {
40455
40546
  * the configured `monitoring` checks to a file as JSON (holocron#1030/
40456
40547
  * #1032 review).
40457
40548
  *
40458
- * The untrusted half of the `delivery.previewCheck` split: this process
40549
+ * The untrusted half of the `check-preview` split: this process
40459
40550
  * executes a PR's own `holocron.config.ts`, so it must never run with a
40460
40551
  * credential worth protecting (e.g. a Deployment Protection bypass
40461
40552
  * secret) present in its environment. `check resolved` is the
@@ -40481,7 +40572,7 @@ const monitoringResolveChecksArgs = (y) => y.option("out", {
40481
40572
  // src/commands/monitoring-resolve-checks/monitoring-resolve-checks.command.ts
40482
40573
  const monitoringResolveChecksCommand = {
40483
40574
  command: "checks",
40484
- describe: "Load config/plugins and write the configured `monitoring` checks to a file as JSON — the untrusted half of the delivery.previewCheck split (holocron#1030/#1032)",
40575
+ describe: "Load config/plugins and write the configured `monitoring` checks to a file as JSON — the untrusted half of the check-preview split (holocron#1030/#1032)",
40485
40576
  builder: monitoringResolveChecksArgs,
40486
40577
  handler: async (argv) => {
40487
40578
  const tokens = tokenContext(argv.token);
@@ -43505,8 +43596,8 @@ function pnpmCommand(script) {
43505
43596
  /** The `holocron run` call that does what a script does (a suite, or one task: `test:unit` is `test unit`); none for a dev script. */
43506
43597
  function holocronEquivalent(script) {
43507
43598
  if (SUITES.includes(script)) return `\`holocron run ${script}\``;
43508
- const [target] = resolveTaskName(script);
43509
- return target === void 0 ? "—" : `\`holocron run ${target.id.replace(":", " ")}\``;
43599
+ const id = resolveTaskName(script);
43600
+ return id === void 0 ? "—" : `\`holocron run ${id.replace(":", " ")}\``;
43510
43601
  }
43511
43602
  function generateReadme(config) {
43512
43603
  return {
@@ -43539,7 +43630,7 @@ function generateReleases(homepage) {
43539
43630
  function readmeScriptProblems(readme, scripts) {
43540
43631
  const missing = /* @__PURE__ */ new Set();
43541
43632
  for (const [, run, name] of readme.matchAll(/\bpnpm (run )?([a-z][\w:.-]*)/g)) {
43542
- if (!(SUITES.includes(name) || resolveTaskName(name).length > 0) || name in scripts) continue;
43633
+ if (!(SUITES.includes(name) || resolveTaskName(name) !== void 0) || name in scripts) continue;
43543
43634
  if (run === void 0 && PNPM_BUILTIN_COMMANDS.has(name)) continue;
43544
43635
  missing.add(name);
43545
43636
  }
@@ -44360,6 +44451,33 @@ const syncRequestsCommand = {
44360
44451
  })).status === "fail") process.exitCode = 1;
44361
44452
  }
44362
44453
  };
44454
+ // src/commands/sync-templates/read-templates-token/read-templates-token.ts
44455
+ /** The variable a maintainer's Environment holds the templates token under (`tokens.mdx`). */
44456
+ const TEMPLATES_TOKEN = "TEMPLATES_TOKEN";
44457
+ /**
44458
+ * The token `holocron sync templates` publishes with, found the way every other value is: the process environment, the
44459
+ * repository's `.env`, then the Environments this machine reads (`- local`, then `- dev`), as
44460
+ * `HOLOCRON_TEMPLATES_TOKEN`. So a maintainer's terminal needs no copy of it. It looks for nothing when a `--token` was
44461
+ * given or the run is CI (the release workflow maps the secret itself), and it never fails the command: a load that
44462
+ * throws gives a `note`, and the command goes on to the usual chain.
44463
+ *
44464
+ * @param input - The tokens already given, the environment and how to load the credentials.
44465
+ * @returns The token, or `{ note }` saying why none was found.
44466
+ */
44467
+ async function readTemplatesToken(input) {
44468
+ if (input.tokens.cliToken || Object.keys(input.tokens.cliTokens ?? {}).length > 0) return {};
44469
+ if (input.ci) return {};
44470
+ const loader = input.makeLoader();
44471
+ try {
44472
+ await loader.load();
44473
+ } catch (err) {
44474
+ return { note: `could not load this machine's credentials: ${errorMessage(err)}` };
44475
+ }
44476
+ const token = resolveValue$2([TEMPLATES_TOKEN], input.env, { prefix: PREFIX$1 });
44477
+ if (token) return { token };
44478
+ const failed = loader.loadFailures().map((f) => `${f.provider}: ${errorMessage(f.error)}`);
44479
+ return { note: `no HOLOCRON_TEMPLATES_TOKEN in the environment, .env or the local/dev Environment${failed.length > 0 ? ` (${failed.join("; ")})` : ""}` };
44480
+ }
44363
44481
  // src/commands/sync-templates/blob-sha/blob-sha.ts
44364
44482
  /** The git blob sha of some bytes: `sha1("blob <size>\0" + bytes)`, what `git hash-object` prints, so a file is compared with a tree entry without reading it. */
44365
44483
  function blobSha(bytes) {
@@ -44471,7 +44589,9 @@ function templatesVersion(templatesDir) {
44471
44589
  * Each folder is compared with its repo's default branch by path, mode and git blob sha; only the difference is written
44472
44590
  * through the `source` capability, as ONE commit per template (files made or replaced, symlinks and the executable bit
44473
44591
  * included, and files removed when the repo has them and the folder no longer does), a fast-forward that is refused
44474
- * when the branch moved since it was read. Then the repo is tagged with the `templates` group's version from `templates/package.json`, and the major tag (`templates-v1`) is moved
44592
+ * when the branch moved since it was read. A source that opens and merges pull requests (GitHub) carries each commit on
44593
+ * a `sync/templates-v<version>` branch and merges that pull request at once, so a ruleset that refuses a direct commit
44594
+ * does not stop it (#2941); one the repo's checks hold stays open and is not tagged until a rerun after it merges. Then the repo is tagged with the `templates` group's version from `templates/package.json`, and the major tag (`templates-v1`) is moved
44475
44595
  * to the same commit, so a caller that follows it gets the newest minor. A rerun makes no commit, a version tag already
44476
44596
  * at the same content is left alone and a major tag already there stays. It never creates or deletes a repository: a missing template repo is a failing row.
44477
44597
  * One template failing does not stop the others. It writes, so it asks first; `--yes` skips the question and, without a
@@ -44502,6 +44622,12 @@ async function runSyncTemplates(input) {
44502
44622
  names = templateFolders(dir);
44503
44623
  if (names.length === 0) return stop("skip", `no template folders under ${dir}`);
44504
44624
  version = templatesVersion(dir);
44625
+ const only = input.only ?? [];
44626
+ if (only.length > 0) {
44627
+ const unknown = only.filter((name) => !names.includes(name));
44628
+ if (unknown.length > 0) return stop("fail", `no template named ${unknown.join(", ")} (templates: ${names.join(", ")})`);
44629
+ names = names.filter((name) => only.includes(name));
44630
+ }
44505
44631
  } catch (err) {
44506
44632
  return stop("fail", errorMessage(err));
44507
44633
  }
@@ -44515,7 +44641,8 @@ async function runSyncTemplates(input) {
44515
44641
  assertPluginsResolvable(loader, "sync templates");
44516
44642
  const source = loader.has("source") ? loader.get("source") : void 0;
44517
44643
  if (!source?.readTree || !source.commitFiles || !source.ensureTag || !source.moveTag) return stop("fail", whyMissing(loader, "source", "no `source` provider that can read a file tree (`readTree`), commit files (`commitFiles`) and tag is available"));
44518
- const { readTree, commitFiles, ensureTag, moveTag } = source;
44644
+ const { readTree, commitFiles, ensureTag, moveTag, createPullRequest, mergePullRequest, deleteBranch } = source;
44645
+ const viaPullRequest = Boolean(createPullRequest && mergePullRequest);
44519
44646
  const results = [];
44520
44647
  const planned = [];
44521
44648
  for (const name of names) {
@@ -44527,6 +44654,7 @@ async function runSyncTemplates(input) {
44527
44654
  name,
44528
44655
  repo,
44529
44656
  base: tree.commit,
44657
+ branch: tree.branch,
44530
44658
  plan: planTemplateSync({
44531
44659
  files,
44532
44660
  remote: tree.entries
@@ -44590,7 +44718,7 @@ async function runSyncTemplates(input) {
44590
44718
  }
44591
44719
  }
44592
44720
  const message = `chore: sync from ${HOLOCRON_REPO$1} ${tag}`;
44593
- for (const { name, repo, base, plan } of planned) {
44721
+ for (const { name, repo, base, branch, plan } of planned) {
44594
44722
  const result = {
44595
44723
  name,
44596
44724
  repo,
@@ -44601,19 +44729,44 @@ async function runSyncTemplates(input) {
44601
44729
  };
44602
44730
  try {
44603
44731
  if (plan.changes.length > 0) {
44732
+ const carrier = `sync/${tag}`;
44604
44733
  result.commit = (await commitFiles.call(source, {
44605
44734
  repo,
44606
44735
  message,
44607
44736
  changes: plan.changes,
44608
- base
44737
+ base,
44738
+ ...viaPullRequest ? { branch: carrier } : {}
44609
44739
  })).commit;
44610
44740
  result.created = plan.create.length;
44611
44741
  result.updated = plan.update.length;
44612
44742
  result.removed = plan.remove.length;
44743
+ if (viaPullRequest) {
44744
+ const opened = await createPullRequest.call(source, {
44745
+ title: message,
44746
+ head: carrier,
44747
+ base: branch,
44748
+ draft: false,
44749
+ body: `Published by \`holocron sync templates\` from ${HOLOCRON_REPO$1} as ${tag}: ${counts(plan)}.`
44750
+ }, repo);
44751
+ result.pullRequest = opened.pullRequest.number;
44752
+ const merged = await mergePullRequest.call(source, opened.pullRequest.number, {
44753
+ method: "squash",
44754
+ title: message
44755
+ }, repo);
44756
+ if (!merged.merged) {
44757
+ result.status = "skip";
44758
+ result.reason = merged.reason ?? "not mergeable yet";
44759
+ row("skip", name, repo, `opened #${opened.pullRequest.number}, not merged yet (${result.reason}); run it again after it merges to tag ${tag}`);
44760
+ results.push(result);
44761
+ continue;
44762
+ }
44763
+ if (merged.commit) result.commit = merged.commit;
44764
+ await deleteBranch?.call(source, carrier, repo);
44765
+ }
44613
44766
  }
44614
44767
  result.tagged = await ensureTag.call(source, tag, repo);
44615
44768
  result.majorMoved = await moveTag.call(source, majorTag, repo);
44616
- row("ok", name, repo, `${result.commit ? `committed ${result.commit.slice(0, 7)} (${result.created} created, ${result.updated} replaced, ${result.removed} removed)` : "already up to date"}; ${result.tagged ? `tagged ${tag}` : `${tag} already there`}; ${result.majorMoved ? `${majorTag} moved here` : `${majorTag} already here`}`);
44769
+ row("ok", name, repo, `${result.commit ? `${result.pullRequest ? `merged #${result.pullRequest}` : "committed"} ${result.commit.slice(0, 7)} (${result.created} created, ${result.updated} replaced, ${result.removed} removed)` : "already up to date"}; ${result.tagged ? `tagged ${tag}` : `${tag} already there`}; ${result.majorMoved ? `${majorTag} moved here` : `${majorTag} already here`}`);
44617
44770
  } catch (err) {
44618
44771
  result.status = "fail";
44619
44772
  result.reason = errorMessage(err);
@@ -44635,21 +44788,40 @@ const syncTemplatesCommand = {
44635
44788
  builder: (y) => y.option("yes", {
44636
44789
  type: "boolean",
44637
44790
  describe: "Write without asking (a workflow needs it)"
44791
+ }).option("template", {
44792
+ type: "array",
44793
+ string: true,
44794
+ describe: "Publish only this template (repeatable, e.g. --template base --template cli); all when absent"
44638
44795
  }),
44639
44796
  handler: async (argv) => {
44640
44797
  const tokens = tokenContext(argv.token);
44641
44798
  if (!tokens) return;
44642
44799
  const loaded = await loadConfig(argv.cwd);
44643
44800
  applyResolvedConfig(argv, loaded.resolved);
44801
+ const org = resolveOrg(argv, loaded.resolved);
44802
+ const read = await readTemplatesToken({
44803
+ tokens,
44804
+ env: process.env,
44805
+ ci: isCI(),
44806
+ makeLoader: () => new PluginLoader(loaded.resolved, {
44807
+ repoRoot: argv.cwd,
44808
+ dryRun: false,
44809
+ ...tokens,
44810
+ org
44811
+ })
44812
+ });
44813
+ if (read.note) getLogger().warn(`sync templates: ${read.note}`);
44814
+ const used = read.token ? { cliTokens: { github: read.token } } : tokens;
44644
44815
  if ((await runSyncTemplates({
44645
44816
  loaded,
44646
44817
  context: {
44647
44818
  repoRoot: argv.cwd,
44648
44819
  dryRun: argv.dryRun,
44649
- ...tokens,
44650
- org: resolveOrg(argv, loaded.resolved)
44820
+ ...used,
44821
+ org
44651
44822
  },
44652
- ...argv.yes ? { yes: true } : {}
44823
+ ...argv.yes ? { yes: true } : {},
44824
+ ...argv.template?.length ? { only: argv.template } : {}
44653
44825
  })).status === "fail") process.exitCode = 1;
44654
44826
  }
44655
44827
  };
@@ -44955,6 +45127,12 @@ async function runSyncWiki(input) {
44955
45127
  status: "dry-run"
44956
45128
  };
44957
45129
  const docsYmlPath = join(input.context.repoRoot, "fern", "docs.yml");
45130
+ if (!await access(docsYmlPath).then(() => true, () => false)) return {
45131
+ capability: "local",
45132
+ step: "sync wiki",
45133
+ status: "skip",
45134
+ message: "no fern/docs.yml yet; `holocron setup` provisions it, then run sync again"
45135
+ };
44958
45136
  try {
44959
45137
  const repos = await discoverWikiRepos(org, token, input.fetch);
44960
45138
  const wikiOpts = config.providers.wiki?.tuple?.options;
@@ -44988,6 +45166,7 @@ const SYNC_STEPS = [
44988
45166
  "homepage",
44989
45167
  "readme",
44990
45168
  "workflows",
45169
+ "config",
44991
45170
  "scripts",
44992
45171
  "turbo",
44993
45172
  "agents",
@@ -45001,6 +45180,7 @@ const LOCAL_STEPS = /* @__PURE__ */ new Set([
45001
45180
  "homepage",
45002
45181
  "readme",
45003
45182
  "workflows",
45183
+ "config",
45004
45184
  "scripts",
45005
45185
  "turbo",
45006
45186
  "agents",
@@ -45182,6 +45362,7 @@ async function runSync(input) {
45182
45362
  "homepage",
45183
45363
  "readme",
45184
45364
  "workflows",
45365
+ "config",
45185
45366
  "scripts",
45186
45367
  "turbo",
45187
45368
  "agents",
@@ -45308,6 +45489,13 @@ async function runSync(input) {
45308
45489
  }
45309
45490
  print(formatSyncStep(steps[steps.length - 1]));
45310
45491
  }
45492
+ for (const entry of generateActionlintFiles(entries)) {
45493
+ steps.push(await runSyncStep("local", entry.syncStep, dryRun, async () => {
45494
+ await mkdir(dirname(join(gitRoot, entry.path)), { recursive: true });
45495
+ await writeFile(join(gitRoot, entry.path), entry.content, "utf8");
45496
+ }));
45497
+ print(formatSyncStep(steps[steps.length - 1]));
45498
+ }
45311
45499
  if ((config.tasks ?? []).length > 0) {
45312
45500
  const files = entries.filter((entry) => entry.kind === "file");
45313
45501
  if (files.length < entries.length) {
@@ -45339,6 +45527,47 @@ async function runSync(input) {
45339
45527
  }
45340
45528
  }
45341
45529
  }
45530
+ if (stepName === "config") {
45531
+ if (resolvedRepoRoot !== gitRoot) {
45532
+ steps.push({
45533
+ capability: "local",
45534
+ step: "sync config files",
45535
+ status: "skip",
45536
+ message: "--cwd is a monorepo subpackage, not the git root — run from the root"
45537
+ });
45538
+ print(formatSyncStep(steps[steps.length - 1]));
45539
+ continue;
45540
+ }
45541
+ const coverageFiles = coverageConfigFiles({
45542
+ loader,
45543
+ repoRoot: input.context.repoRoot,
45544
+ docsCoverage: config.repoValidation?.docsCoverage
45545
+ });
45546
+ for (const entry of generateConfigFiles({
45547
+ loaded: input.loaded,
45548
+ repoRoot: input.context.repoRoot,
45549
+ ...coverageFiles ? { coverageConfigFiles: coverageFiles } : {},
45550
+ logger
45551
+ })) {
45552
+ if (entry.kind === "skip") steps.push({
45553
+ capability: "local",
45554
+ step: entry.syncStep,
45555
+ status: "skip",
45556
+ message: entry.message
45557
+ });
45558
+ else if (entry.kind === "error") steps.push({
45559
+ capability: "local",
45560
+ step: entry.syncStep,
45561
+ status: "fail",
45562
+ message: entry.message
45563
+ });
45564
+ else steps.push(await runSyncStep("local", entry.syncStep, dryRun, async () => {
45565
+ await mkdir(dirname(join(gitRoot, entry.path)), { recursive: true });
45566
+ await writeFile(join(gitRoot, entry.path), entry.content, "utf8");
45567
+ }));
45568
+ print(formatSyncStep(steps[steps.length - 1]));
45569
+ }
45570
+ }
45342
45571
  if (stepName === "scripts") {
45343
45572
  if (config.syncScripts === false) {
45344
45573
  steps.push({
@@ -45645,7 +45874,7 @@ async function readExistingWorkflowFile(repoRoot, filename) {
45645
45874
  const syncArgs = (y) => y.positional("steps", {
45646
45875
  type: "string",
45647
45876
  array: true,
45648
- describe: "Steps to run: labels, properties, teams, topics, keywords, description, homepage, readme, workflows, scripts, wiki (default: all); or a workspace app's name with --env"
45877
+ describe: "Steps to run: labels, properties, teams, topics, keywords, description, homepage, readme, workflows, config, scripts, wiki (default: all); or a workspace app's name with --env"
45649
45878
  }).option("env", {
45650
45879
  type: "string",
45651
45880
  array: true,
@@ -45716,7 +45945,7 @@ async function syncApp(argv) {
45716
45945
  // src/commands/sync/sync.command.ts
45717
45946
  const syncCommand = {
45718
45947
  command: "sync [steps..]",
45719
- describe: "Sync state from config to the provider and local files (labels, properties, teams, topics, keywords, description, homepage, readme, workflows, scripts, wiki)",
45948
+ describe: "Sync state from config to the provider and local files (labels, properties, teams, topics, keywords, description, homepage, readme, workflows, config, scripts, wiki)",
45720
45949
  builder: (y) => syncArgs(y).command(syncGithubCommand).command(syncIssuesCommand).command(syncIncidentsCommand).command(syncPrsCommand).command(syncReleasesCommand).command(syncTemplatesCommand).command(syncReadmeCommand).command(ideasSyncCommand).command(syncToolingCommand).command(syncRequestsCommand).command(specsSyncCommand).command(secretsSyncCommand).command(notificationsSyncRolesCommand),
45721
45950
  handler: async (argv) => {
45722
45951
  if (argv.env !== void 0 || argv.steps?.[0] !== void 0) {