@theholocron/cli 5.0.0-alpha.503 → 5.0.0-alpha.505

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
@@ -15359,6 +15359,11 @@ const CANONICAL_LABELS = [
15359
15359
  color: "a2eeef",
15360
15360
  description: "New feature or request"
15361
15361
  },
15362
+ {
15363
+ name: "epic",
15364
+ color: "5319e7",
15365
+ description: "A body of work made of several issues"
15366
+ },
15362
15367
  {
15363
15368
  name: "good first issue",
15364
15369
  color: "7057ff",
@@ -20075,6 +20080,294 @@ async function handOffHeartbeats(input) {
20075
20080
  reason: "file-left"
20076
20081
  };
20077
20082
  }
20083
+ // src/commands/probe/tasks/script-keys.ts
20084
+ /**
20085
+ * The keys of the object `field` (`scripts` in a `package.json`, `tasks` in a `turbo.json`) with their lines; none when
20086
+ * the text is not JSON or has no such object.
20087
+ */
20088
+ function scriptKeys(text, field) {
20089
+ let value;
20090
+ try {
20091
+ value = JSON.parse(text)[field];
20092
+ } catch {
20093
+ return [];
20094
+ }
20095
+ if (typeof value !== "object" || value === null) return [];
20096
+ const lines = text.split("\n");
20097
+ const start = lines.findIndex((l) => l.includes(`"${field}"`));
20098
+ return Object.keys(value).map((key) => ({
20099
+ key,
20100
+ line: lines.findIndex((l, i) => i > start && l.trimStart().startsWith(`"${key}"`)) + 1
20101
+ }));
20102
+ }
20103
+ // src/commands/probe/tasks/find-reserved.ts
20104
+ /** What to use instead of a reserved script name: `publish` has a task of its own, the rest are never tasks. */
20105
+ function instead(name) {
20106
+ return name === "publish" ? "release (`publish` is reserved by npm and pnpm)" : "(reserved by npm and pnpm, never a task)";
20107
+ }
20108
+ /**
20109
+ * Every `package.json` script named like an npm/pnpm lifecycle word (`RESERVED_SCRIPT_NAMES`): `pnpm publish` would run
20110
+ * it after publishing. The root `prepare` (husky) is the one allowed.
20111
+ */
20112
+ function findReserved(file) {
20113
+ if (!/(^|\/)package\.json$/.test(file.path)) return [];
20114
+ return scriptKeys(file.text, "scripts").filter(({ key }) => RESERVED_SCRIPT_NAMES.has(key) && !(file.path === "package.json" && key === "prepare")).map(({ key, line }) => ({
20115
+ file: file.path,
20116
+ line,
20117
+ old: key,
20118
+ replacement: instead(key)
20119
+ }));
20120
+ }
20121
+ // src/commands/probe/tasks/find-leftovers.ts
20122
+ /** The commands that take a task name as their next word: `holocron run`, `turbo run`, `pnpm run`, `pnpm`, ... */
20123
+ const COMMAND$4 = String.raw`(?:holocron run|turbo run|pnpm run|npm run|pnpm|yarn)\s+`;
20124
+ /** A regex alternation of `names`, escaped; matches nothing for an empty list. */
20125
+ function alternation(names) {
20126
+ return names.length === 0 ? "(?!)" : names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
20127
+ }
20128
+ /** The field of a manifest whose keys are tasks or scripts: `scripts` in a `package.json`, `tasks` in a `turbo.json`. */
20129
+ function taskField(path) {
20130
+ return /(^|\/)package\.json$/.test(path) ? "scripts" : /(^|\/)turbo\.json$/.test(path) ? "tasks" : void 0;
20131
+ }
20132
+ /**
20133
+ * Every use of an old task name in `files`, with its file, line and replacement.
20134
+ *
20135
+ * - A dotted name (`delivery.build`) matches as a whole token: found in `turbo run delivery.build`, not in
20136
+ * `delivery.buildX`. Followed by `.yml`/`.yaml` it is a workflow file name and is left out unless `options.files`.
20137
+ * - A bare name (`review`, `stale`: the keys of `names` without a dot) is an ordinary word, so it is found only where it
20138
+ * is used as a task: after `holocron run`, `turbo run`, `pnpm` or `pnpm run`, as a `package.json` script or as a
20139
+ * `turbo.json` task.
20140
+ * - A `package.json` script named like an npm/pnpm lifecycle word is reported too (see {@link findReserved}).
20141
+ * - A line, or the line below one, that carries the {@link ALLOW_MARKER} is skipped.
20142
+ *
20143
+ * Files come back in the order given, lines top to bottom.
20144
+ */
20145
+ function findLeftovers(files, names, options = {}) {
20146
+ const dotted = Object.keys(names).filter((n) => n.includes("."));
20147
+ const bare = Object.keys(names).filter((n) => !n.includes("."));
20148
+ const tail = options.files ? String.raw`(?![\w-])` : String.raw`(?![\w-]|\.ya?ml\b)`;
20149
+ const dottedPattern = new RegExp(`(?<![\\w.-])(${alternation(dotted)})${tail}`, "g");
20150
+ const barePattern = new RegExp(`(?<![\\w.-])${COMMAND$4}(${alternation(bare)})(?![\\w:-]|\\.\\w)`, "g");
20151
+ return files.flatMap((file) => {
20152
+ const lines = file.text.split("\n");
20153
+ const field = taskField(file.path);
20154
+ const inText = lines.flatMap((text, i) => [...text.matchAll(dottedPattern), ...text.matchAll(barePattern)].map((m) => ({
20155
+ file: file.path,
20156
+ line: i + 1,
20157
+ old: m[1],
20158
+ replacement: names[m[1]]
20159
+ })));
20160
+ const asKey = (field === void 0 ? [] : scriptKeys(file.text, field)).filter(({ key }) => bare.includes(key)).map(({ key, line }) => ({
20161
+ file: file.path,
20162
+ line,
20163
+ old: key,
20164
+ replacement: names[key]
20165
+ }));
20166
+ const seen = /* @__PURE__ */ new Set();
20167
+ return [
20168
+ ...inText,
20169
+ ...asKey,
20170
+ ...findReserved(file)
20171
+ ].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"));
20172
+ });
20173
+ }
20174
+ // src/commands/probe/tasks/is-generated.ts
20175
+ /** Whether a file carries the generated-file header in its first lines; drift in those is `probe generated check`'s to report. */
20176
+ function isGenerated(text) {
20177
+ return text.split("\n", 3).some((line) => line.includes("AUTO-GENERATED"));
20178
+ }
20179
+ // src/commands/probe/tasks/is-scanned.ts
20180
+ /** Files that describe the old names on purpose: specs, ADRs, the changelog, tests, and this probe's own folder. */
20181
+ const SKIPPED = [
20182
+ /(^|\/)CHANGELOG\.md$/,
20183
+ /^\.notes\//,
20184
+ /^docs\/wiki\//,
20185
+ /\.test\.tsx?$/,
20186
+ /^cli\/cli\/src\/commands\/probe\/tasks\//
20187
+ ];
20188
+ /** The kinds of file the probe reads: workflows, scripts, docs, configs, hooks and manifests. */
20189
+ const SCANNED = [
20190
+ /^\.github\/(workflows|actions)\/.+\.ya?ml$/,
20191
+ /^\.husky\//,
20192
+ /^scripts\//,
20193
+ /(^|\/)(package|turbo)\.json$/,
20194
+ /(^|\/)(holocron|astromech)\.config\.[cm]?[jt]s$/,
20195
+ /(^|\/)\.lintstagedrc/,
20196
+ /\.mdx?$/
20197
+ ];
20198
+ /** Whether `path` (repo-relative) is a hand-written kind of place to scan for old task names. */
20199
+ function isScanned(path) {
20200
+ return SCANNED.some((p) => p.test(path)) && !SKIPPED.some((p) => p.test(path));
20201
+ }
20202
+ // src/commands/probe/tasks/legacy-replacements.ts
20203
+ /**
20204
+ * Each old task name astromech's `LEGACY_NAMES` still accepts, with the text the `tasks names` probe prints as its
20205
+ * replacement: the flat ids it became, in run order. A successor that adds args (`format --check`, the read-only
20206
+ * prettier half of `sourceQuality.formatting`) is named last, in parentheses: `lint:editorconfig, lint:markdown (format
20207
+ * for prettier)`. A name that is a suite now (`validate`, once the interim id of `platform.repoValidation`) is left out:
20208
+ * `holocron run validate` is the suite, not a leftover.
20209
+ */
20210
+ function legacyReplacements() {
20211
+ return Object.fromEntries(Object.entries(LEGACY_NAMES).filter(([old]) => !SUITES.includes(old)).map(([old, targets]) => {
20212
+ const own = targets.filter((t) => t.passthrough === void 0).map((t) => t.id);
20213
+ const checked = targets.filter((t) => t.passthrough !== void 0).map((t) => `${t.id} for prettier`);
20214
+ return [old, checked.length === 0 ? own.join(", ") : `${own.join(", ")} (${checked.join(", ")})`];
20215
+ }));
20216
+ }
20217
+ // src/commands/probe/tasks/real-tasks-io.ts
20218
+ /** The `tasks names` probe's inputs from the tracked files under `repoRoot`. */
20219
+ function realTasksIo(repoRoot) {
20220
+ /* v8 ignore start -- reads git and the real filesystem; the probe is tested with an injected io */
20221
+ return { files: () => execFileSync("git", ["ls-files", "-z"], {
20222
+ cwd: repoRoot,
20223
+ encoding: "utf8",
20224
+ maxBuffer: 67108864
20225
+ }).split("\0").filter((path) => path !== "" && isScanned(path)).flatMap((path) => {
20226
+ try {
20227
+ const text = readFileSync(join(repoRoot, path), "utf8");
20228
+ return isGenerated(text) ? [] : [{
20229
+ path,
20230
+ text
20231
+ }];
20232
+ } catch {
20233
+ return [];
20234
+ }
20235
+ }) };
20236
+ /* v8 ignore stop */
20237
+ }
20238
+ // src/commands/probe/tasks/tasks-probes.ts
20239
+ /** The group of probes that check the repo's task vocabulary. */
20240
+ const TASKS_PROVIDER = "tasks";
20241
+ /**
20242
+ * `tasks names`: finds the hand-written places that still use an old task name from the flat-vocabulary map
20243
+ * (SPEC-0064, astromech's `LEGACY_NAMES`): a dotted one (`delivery.build`, `verification.unitTests`), a bare one used as a
20244
+ * task (`holocron run review`, a `review` script) or a `package.json` script with a reserved npm/pnpm name (`publish`).
20245
+ * It scans workflows, scripts, docs, `turbo.json`, `package.json`, the configs' `tasks:` and the hooks, and reports each
20246
+ * with file, line and the id to use instead. Each is a failure (exit code 1); `--warn` reports them as `info` rows
20247
+ * instead. A dotted name that is part of a workflow file name (`delivery.build.yml`) is skipped until the files are
20248
+ * renamed; `--files` lists those too. An intentional mention carries the `holocron-allow-old-name` marker on its line or the line above.
20249
+ * Files `sync` generates are left to `generated check`; specs, ADRs and the changelog name the old tasks on purpose.
20250
+ */
20251
+ function tasksProbes(io, names = legacyReplacements()) {
20252
+ return { names: {
20253
+ summary: "Report each use of an old task name in hand-written files; fails unless --warn; --files adds file names.",
20254
+ writes: false,
20255
+ async run(ctx) {
20256
+ const status = ctx.args?.includes("--warn") ? "info" : "fail";
20257
+ ctx.say({
20258
+ status: "heading",
20259
+ label: "Old task names"
20260
+ });
20261
+ const found = findLeftovers(io.files(), names, { files: ctx.args?.includes("--files") === true });
20262
+ for (const f of found) ctx.say({
20263
+ status,
20264
+ label: `${f.file}:${f.line}`,
20265
+ detail: `${f.old} -> ${f.replacement}`
20266
+ });
20267
+ ctx.say({
20268
+ status: found.length === 0 ? "ok" : status,
20269
+ label: "old names",
20270
+ detail: `${found.length} use(s) of ${Object.keys(names).length} old name(s)`
20271
+ });
20272
+ }
20273
+ } };
20274
+ }
20275
+ // src/commands/workflow-source-marker/workflow-source-marker.ts
20276
+ /** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
20277
+ const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
20278
+ /** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
20279
+ function sanitizeForDisplay(value) {
20280
+ return value.replace(/[\x00-\x1f\x7f]/g, "");
20281
+ }
20282
+ /**
20283
+ * Repo-root-relative path of the PACKAGE a workflow-writing command run is
20284
+ * scoped to — the directory holding the discovered `holocron.config.*`
20285
+ * (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
20286
+ * up to find the config from any subdirectory ("every command is usable
20287
+ * from any subdirectory of a repo, not only its exact root"), so a `--cwd`
20288
+ * one level too deep would otherwise stamp a different marker than a later
20289
+ * run from the package's own root and misfire the collision check this
20290
+ * feeds (holocron#1026).
20291
+ *
20292
+ * "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
20293
+ * to forward slashes so the same package produces the same marker on
20294
+ * Windows and POSIX. Throws if the result contains a line break — a path
20295
+ * containing one could otherwise break out of the `# Source package: `
20296
+ * comment line and inject arbitrary workflow YAML when the generated
20297
+ * content is later written. Not reachable through this CLI's own flows
20298
+ * (no code path writes a config file whose directory name contains a line
20299
+ * break), but cheap to reject outright rather than trust the filesystem.
20300
+ */
20301
+ function resolvePkgRelPath(gitRoot, configFilepath) {
20302
+ let root;
20303
+ try {
20304
+ root = realpathSync(gitRoot);
20305
+ } catch {
20306
+ root = gitRoot;
20307
+ }
20308
+ let configDir;
20309
+ try {
20310
+ configDir = realpathSync(dirname(configFilepath));
20311
+ } catch {
20312
+ configDir = dirname(configFilepath);
20313
+ }
20314
+ const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
20315
+ if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
20316
+ return pkgRelPath;
20317
+ }
20318
+ /**
20319
+ * Two different monorepo packages opting into the same generic task name
20320
+ * (e.g. both `apps/sentinel` and some future `apps/other` configuring
20321
+ * `delivery.previewDeploy`) would otherwise overwrite each other's
20322
+ * `.github/workflows/<task>.yml` on whichever package's write ran last —
20323
+ * only one package's behavior would ever actually run in CI, with no
20324
+ * signal that the other's was silently dropped (holocron#1026).
20325
+ *
20326
+ * Shared by both `holocron sync` (reads the file straight off local
20327
+ * disk) and `holocron setup` (reads it through the loaded `Source`
20328
+ * capability, which happens to be local disk too for the github plugin
20329
+ * today, but the interface doesn't promise that for every provider —
20330
+ * holocron#1068). The marker-parsing and error message are identical
20331
+ * either way; `readExisting` is how the two callers differ.
20332
+ *
20333
+ * A file with no marker at all predates this check (or was written before
20334
+ * #1026) and is never flagged — only a marker that's present AND disagrees
20335
+ * with the current run's own package is a real collision. `readExisting`
20336
+ * returning `null` means "nothing there," not "unreadable" — a caller
20337
+ * whose underlying read can fail for reasons other than "doesn't exist"
20338
+ * (e.g. local fs EISDIR) is expected to let that error propagate out of
20339
+ * `readExisting` itself rather than mapping it to `null`.
20340
+ */
20341
+ async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
20342
+ const existing = await readExisting();
20343
+ if (existing === null) return;
20344
+ const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
20345
+ 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.`);
20346
+ }
20347
+ // src/commands/obsolete-workflows/find-obsolete-workflows.ts
20348
+ /** The lines at the head of a generated workflow that hold the header and the `# Source package:` marker. */
20349
+ const HEADER_LINES = 6;
20350
+ /**
20351
+ * The workflow files in `.github/workflows` that an earlier `sync` generated and that this run no longer writes, because
20352
+ * their task left the config or a preset (#2338). Sorted by name.
20353
+ *
20354
+ * It names a file only when all of these hold, so a file nobody generated is never removed:
20355
+ * - the generator's own `AUTO-GENERATED` header is at its head;
20356
+ * - it is not marked `# HAND-MAINTAINED`;
20357
+ * - its `# Source package:` line is this run's package, so a run for `apps/sentinel` leaves the root's files alone, and a
20358
+ * file with no marker (written before the marker existed) is left for `probe generated check` to report;
20359
+ * - this run does not write it.
20360
+ */
20361
+ function findObsoleteWorkflows({ workflows, written, pkgRelPath }) {
20362
+ const obsolete = [];
20363
+ for (const [name, text] of workflows) {
20364
+ if (written.has(name) || text.startsWith("# HAND-MAINTAINED") || !isGenerated(text)) continue;
20365
+ const head = text.split("\n", HEADER_LINES).join("\n");
20366
+ if (SOURCE_PACKAGE_MARKER.exec(head)?.[1] !== pkgRelPath) continue;
20367
+ obsolete.push(name);
20368
+ }
20369
+ return obsolete.sort();
20370
+ }
20078
20371
  // ../../.holocron/org.md
20079
20372
  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 `ci / Required checks` aggregate is green, mark it ready** with `holocron close work <issue> --wait` (it\n waits for the aggregate, 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";
20080
20373
  // src/commands/repo-files/generate-agent-files.ts
@@ -20436,97 +20729,25 @@ function withAutoPreviewDeployPaths(tasks, gitRoot) {
20436
20729
  if (!paths) return entry;
20437
20730
  return {
20438
20731
  ...entry,
20439
- with: {
20440
- ...entry.with,
20441
- paths
20442
- }
20443
- };
20444
- });
20445
- }
20446
- // src/commands/thin-caller-file/thin-caller-file.ts
20447
- const { workflowHeader } = createHeader({
20448
- source: "cli/astromech/src/generators/github-action-thin-callers/github-action-thin-callers.ts",
20449
- tool: "holocron sync"
20450
- });
20451
- /**
20452
- * The text of a generated thin-caller workflow: the AUTO-GENERATED header, the `# Source package:` marker (see
20453
- * `resolvePkgRelPath`) and the workflow itself. Both `setup` and `sync` write their workflows through
20454
- * this, so the file is the same whichever command wrote it.
20455
- */
20456
- function thinCallerFile(pkgRelPath, content) {
20457
- return `${workflowHeader()}# Source package: ${pkgRelPath}\n\n${content}`;
20458
- }
20459
- // src/commands/workflow-source-marker/workflow-source-marker.ts
20460
- /** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
20461
- const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
20462
- /** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
20463
- function sanitizeForDisplay(value) {
20464
- return value.replace(/[\x00-\x1f\x7f]/g, "");
20465
- }
20466
- /**
20467
- * Repo-root-relative path of the PACKAGE a workflow-writing command run is
20468
- * scoped to — the directory holding the discovered `holocron.config.*`
20469
- * (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
20470
- * up to find the config from any subdirectory ("every command is usable
20471
- * from any subdirectory of a repo, not only its exact root"), so a `--cwd`
20472
- * one level too deep would otherwise stamp a different marker than a later
20473
- * run from the package's own root and misfire the collision check this
20474
- * feeds (holocron#1026).
20475
- *
20476
- * "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
20477
- * to forward slashes so the same package produces the same marker on
20478
- * Windows and POSIX. Throws if the result contains a line break — a path
20479
- * containing one could otherwise break out of the `# Source package: `
20480
- * comment line and inject arbitrary workflow YAML when the generated
20481
- * content is later written. Not reachable through this CLI's own flows
20482
- * (no code path writes a config file whose directory name contains a line
20483
- * break), but cheap to reject outright rather than trust the filesystem.
20484
- */
20485
- function resolvePkgRelPath(gitRoot, configFilepath) {
20486
- let root;
20487
- try {
20488
- root = realpathSync(gitRoot);
20489
- } catch {
20490
- root = gitRoot;
20491
- }
20492
- let configDir;
20493
- try {
20494
- configDir = realpathSync(dirname(configFilepath));
20495
- } catch {
20496
- configDir = dirname(configFilepath);
20497
- }
20498
- const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
20499
- if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
20500
- return pkgRelPath;
20501
- }
20502
- /**
20503
- * Two different monorepo packages opting into the same generic task name
20504
- * (e.g. both `apps/sentinel` and some future `apps/other` configuring
20505
- * `delivery.previewDeploy`) would otherwise overwrite each other's
20506
- * `.github/workflows/<task>.yml` on whichever package's write ran last —
20507
- * only one package's behavior would ever actually run in CI, with no
20508
- * signal that the other's was silently dropped (holocron#1026).
20509
- *
20510
- * Shared by both `holocron sync` (reads the file straight off local
20511
- * disk) and `holocron setup` (reads it through the loaded `Source`
20512
- * capability, which happens to be local disk too for the github plugin
20513
- * today, but the interface doesn't promise that for every provider —
20514
- * holocron#1068). The marker-parsing and error message are identical
20515
- * either way; `readExisting` is how the two callers differ.
20516
- *
20517
- * A file with no marker at all predates this check (or was written before
20518
- * #1026) and is never flagged — only a marker that's present AND disagrees
20519
- * with the current run's own package is a real collision. `readExisting`
20520
- * returning `null` means "nothing there," not "unreadable" — a caller
20521
- * whose underlying read can fail for reasons other than "doesn't exist"
20522
- * (e.g. local fs EISDIR) is expected to let that error propagate out of
20523
- * `readExisting` itself rather than mapping it to `null`.
20732
+ with: {
20733
+ ...entry.with,
20734
+ paths
20735
+ }
20736
+ };
20737
+ });
20738
+ }
20739
+ // src/commands/thin-caller-file/thin-caller-file.ts
20740
+ const { workflowHeader } = createHeader({
20741
+ source: "cli/astromech/src/generators/github-action-thin-callers/github-action-thin-callers.ts",
20742
+ tool: "holocron sync"
20743
+ });
20744
+ /**
20745
+ * The text of a generated thin-caller workflow: the AUTO-GENERATED header, the `# Source package:` marker (see
20746
+ * `resolvePkgRelPath`) and the workflow itself. Both `setup` and `sync` write their workflows through
20747
+ * this, so the file is the same whichever command wrote it.
20524
20748
  */
20525
- async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
20526
- const existing = await readExisting();
20527
- if (existing === null) return;
20528
- const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
20529
- 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.`);
20749
+ function thinCallerFile(pkgRelPath, content) {
20750
+ return `${workflowHeader()}# Source package: ${pkgRelPath}\n\n${content}`;
20530
20751
  }
20531
20752
  // src/commands/repo-files/generate-workflow-files.ts
20532
20753
  /**
@@ -21684,14 +21905,15 @@ async function runSetup(input) {
21684
21905
  if (loader.has("source")) {
21685
21906
  const source = loader.get("source");
21686
21907
  if (config.tasks && config.tasks.length > 0) print(style.step("workflows"));
21687
- for (const entry of await generateRepoFiles({
21908
+ const generatedEntries = await generateRepoFiles({
21688
21909
  loaded: input.loaded,
21689
21910
  repoRoot: input.context.repoRoot,
21690
21911
  hooks: input.hooks,
21691
21912
  ...statusContexts ? { statusContexts } : {},
21692
21913
  ...coverageFiles ? { coverageConfigFiles: coverageFiles } : {},
21693
21914
  logger
21694
- })) {
21915
+ });
21916
+ for (const entry of generatedEntries) {
21695
21917
  if (entry.kind === "skip") steps.push({
21696
21918
  capability: "source",
21697
21919
  step: entry.step,
@@ -21717,6 +21939,46 @@ async function runSetup(input) {
21717
21939
  print(formatStep(steps[steps.length - 1]));
21718
21940
  }
21719
21941
  }
21942
+ if ((config.tasks ?? []).length > 0) {
21943
+ const written = /* @__PURE__ */ new Set();
21944
+ let unaccounted = false;
21945
+ for (const entry of generatedEntries) if (entry.kind === "file" && entry.workflow) written.add(entry.workflow.filename);
21946
+ else if (entry.kind === "skip" && entry.step.startsWith("write workflow ")) unaccounted = true;
21947
+ if (unaccounted) {
21948
+ steps.push({
21949
+ capability: "source",
21950
+ step: "remove obsolete workflows",
21951
+ status: "skip",
21952
+ message: "a task has no template, so no workflow is removed"
21953
+ });
21954
+ print(formatStep(steps[steps.length - 1]));
21955
+ } else try {
21956
+ const workflows = /* @__PURE__ */ new Map();
21957
+ for (const name of await source.listWorkflowFiles()) {
21958
+ const text = await source.readWorkflowFile(name);
21959
+ if (text !== null) workflows.set(name, text);
21960
+ }
21961
+ const obsolete = findObsoleteWorkflows({
21962
+ workflows,
21963
+ written,
21964
+ pkgRelPath: setupPkgRelPath
21965
+ });
21966
+ for (const filename of obsolete) {
21967
+ steps.push(await runStep("source", `remove obsolete workflow ${filename}`, dryRun, async () => {
21968
+ await source.removeWorkflowFile(filename);
21969
+ }));
21970
+ print(formatStep(steps[steps.length - 1]));
21971
+ }
21972
+ } catch (err) {
21973
+ steps.push({
21974
+ capability: "source",
21975
+ step: "remove obsolete workflows",
21976
+ status: "fail",
21977
+ message: errorMessage(err)
21978
+ });
21979
+ print(formatStep(steps[steps.length - 1]));
21980
+ }
21981
+ }
21720
21982
  }
21721
21983
  if (loader.has("source")) {
21722
21984
  const source = loader.get("source");
@@ -22593,18 +22855,18 @@ const authListCommand = {
22593
22855
  * `holocron list projects` — the owner's boards, newest first, with their number, name and state. Read-only, so
22594
22856
  * `--dry-run` changes nothing here.
22595
22857
  */
22596
- const COMMAND$4 = "list projects";
22858
+ const COMMAND$3 = "list projects";
22597
22859
  async function runProjectList(input) {
22598
22860
  const print = input.print ?? ((line) => console.log(line));
22599
22861
  const rows = createProjectRows(print, input.logger ?? getLogger());
22600
- const { projects, options } = await openProjects(input, COMMAND$4);
22862
+ const { projects, options } = await openProjects(input, COMMAND$3);
22601
22863
  print(style.header(`Holocron list projects — ${options.owner}`));
22602
22864
  print("");
22603
22865
  try {
22604
22866
  const boards = (await projects.list(options.owner)).toSorted((a, b) => (b.number ?? 0) - (a.number ?? 0));
22605
22867
  if (boards.length === 0) {
22606
22868
  rows.skip("no boards", options.owner);
22607
- return rows.finish(COMMAND$4);
22869
+ return rows.finish(COMMAND$3);
22608
22870
  }
22609
22871
  const width = Math.max(1, ...boards.map((b) => String(b.number ?? "").length));
22610
22872
  print(style.dim(` ${"#".padEnd(width)} ${"Name".padEnd(32)} State`));
@@ -22614,7 +22876,7 @@ async function runProjectList(input) {
22614
22876
  } catch (err) {
22615
22877
  rows.fail("list", errorMessage(err));
22616
22878
  }
22617
- return rows.finish(COMMAND$4);
22879
+ return rows.finish(COMMAND$3);
22618
22880
  }
22619
22881
  // src/commands/project/project-list/project-list.command.ts
22620
22882
  const projectListCommand = {
@@ -23535,7 +23797,7 @@ const authSetCommand = {
23535
23797
  * file is checked (git ignores it, it is not there already) before the browser opens. Nothing but names and paths is
23536
23798
  * ever printed.
23537
23799
  */
23538
- const COMMAND$3 = "new github-app";
23800
+ const COMMAND$2 = "new github-app";
23539
23801
  const DEFAULT_WEBHOOK_SECRET_VAR = "SENTINEL_WEBHOOK_SECRET";
23540
23802
  async function runGithubAppCreate(input) {
23541
23803
  const print = input.print ?? ((line) => console.error(line));
@@ -23545,7 +23807,7 @@ async function runGithubAppCreate(input) {
23545
23807
  logger.warn({
23546
23808
  status: "fail",
23547
23809
  reason
23548
- }, COMMAND$3);
23810
+ }, COMMAND$2);
23549
23811
  return { status: "fail" };
23550
23812
  };
23551
23813
  if ((input.platform ?? process.platform) === "win32") return refuse("windows", "cannot make the credentials file private on Windows: its mode bits are not enforced");
@@ -23606,7 +23868,7 @@ async function runGithubAppCreate(input) {
23606
23868
  status: "fail",
23607
23869
  reason: "write",
23608
23870
  slug: app.slug
23609
- }, COMMAND$3);
23871
+ }, COMMAND$2);
23610
23872
  for (const line of [`created ${app.slug}, but could not keep its credentials: ${errorMessage(err)}`, `they are shown once: delete the App (${settings}) and run this again`]) print(line);
23611
23873
  return {
23612
23874
  status: "fail",
@@ -23631,7 +23893,7 @@ async function runGithubAppCreate(input) {
23631
23893
  logger.info({
23632
23894
  status,
23633
23895
  slug: app.slug
23634
- }, COMMAND$3);
23896
+ }, COMMAND$2);
23635
23897
  return {
23636
23898
  status,
23637
23899
  slug: app.slug,
@@ -25964,18 +26226,18 @@ const pluginCreateCommand = {
25964
26226
  * templates directory). Idempotent on the title: an open board that has it is not made again; a terminal is asked
25965
26227
  * whether to open the existing one, `--yes` prints its address, and anything else is a {@link NonInteractiveError}.
25966
26228
  */
25967
- const COMMAND$2 = "new project";
26229
+ const COMMAND$1 = "new project";
25968
26230
  async function runProjectCreate(input) {
25969
26231
  const print = input.print ?? ((line) => console.log(line));
25970
26232
  const rows = createProjectRows(print, input.logger ?? getLogger());
25971
26233
  const prompt = input.prompt ?? terminalPrompt();
25972
26234
  const dryRun = input.context.dryRun ?? false;
25973
26235
  const done = (extra = {}) => ({
25974
- ...rows.finish(COMMAND$2),
26236
+ ...rows.finish(COMMAND$1),
25975
26237
  created: false,
25976
26238
  ...extra
25977
26239
  });
25978
- const { projects, options } = await openProjects(input, COMMAND$2);
26240
+ const { projects, options } = await openProjects(input, COMMAND$1);
25979
26241
  const loaded = await loadTemplates(options.templatesDir, input.io ?? createFsTemplatesIo(input.context.repoRoot));
25980
26242
  print(style.header(`Holocron new project — ${options.owner}${dryRun ? " (dry-run)" : ""}`));
25981
26243
  print("");
@@ -29301,198 +29563,6 @@ function specsCheckProbe(io) {
29301
29563
  function specsProbes(io) {
29302
29564
  return { check: specsCheckProbe(io) };
29303
29565
  }
29304
- // src/commands/probe/tasks/script-keys.ts
29305
- /**
29306
- * The keys of the object `field` (`scripts` in a `package.json`, `tasks` in a `turbo.json`) with their lines; none when
29307
- * the text is not JSON or has no such object.
29308
- */
29309
- function scriptKeys(text, field) {
29310
- let value;
29311
- try {
29312
- value = JSON.parse(text)[field];
29313
- } catch {
29314
- return [];
29315
- }
29316
- if (typeof value !== "object" || value === null) return [];
29317
- const lines = text.split("\n");
29318
- const start = lines.findIndex((l) => l.includes(`"${field}"`));
29319
- return Object.keys(value).map((key) => ({
29320
- key,
29321
- line: lines.findIndex((l, i) => i > start && l.trimStart().startsWith(`"${key}"`)) + 1
29322
- }));
29323
- }
29324
- // src/commands/probe/tasks/find-reserved.ts
29325
- /** What to use instead of a reserved script name: `publish` has a task of its own, the rest are never tasks. */
29326
- function instead(name) {
29327
- return name === "publish" ? "release (`publish` is reserved by npm and pnpm)" : "(reserved by npm and pnpm, never a task)";
29328
- }
29329
- /**
29330
- * Every `package.json` script named like an npm/pnpm lifecycle word (`RESERVED_SCRIPT_NAMES`): `pnpm publish` would run
29331
- * it after publishing. The root `prepare` (husky) is the one allowed.
29332
- */
29333
- function findReserved(file) {
29334
- if (!/(^|\/)package\.json$/.test(file.path)) return [];
29335
- return scriptKeys(file.text, "scripts").filter(({ key }) => RESERVED_SCRIPT_NAMES.has(key) && !(file.path === "package.json" && key === "prepare")).map(({ key, line }) => ({
29336
- file: file.path,
29337
- line,
29338
- old: key,
29339
- replacement: instead(key)
29340
- }));
29341
- }
29342
- // src/commands/probe/tasks/find-leftovers.ts
29343
- /** The commands that take a task name as their next word: `holocron run`, `turbo run`, `pnpm run`, `pnpm`, ... */
29344
- const COMMAND$1 = String.raw`(?:holocron run|turbo run|pnpm run|npm run|pnpm|yarn)\s+`;
29345
- /** A regex alternation of `names`, escaped; matches nothing for an empty list. */
29346
- function alternation(names) {
29347
- return names.length === 0 ? "(?!)" : names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
29348
- }
29349
- /** The field of a manifest whose keys are tasks or scripts: `scripts` in a `package.json`, `tasks` in a `turbo.json`. */
29350
- function taskField(path) {
29351
- return /(^|\/)package\.json$/.test(path) ? "scripts" : /(^|\/)turbo\.json$/.test(path) ? "tasks" : void 0;
29352
- }
29353
- /**
29354
- * Every use of an old task name in `files`, with its file, line and replacement.
29355
- *
29356
- * - A dotted name (`delivery.build`) matches as a whole token: found in `turbo run delivery.build`, not in
29357
- * `delivery.buildX`. Followed by `.yml`/`.yaml` it is a workflow file name and is left out unless `options.files`.
29358
- * - A bare name (`review`, `stale`: the keys of `names` without a dot) is an ordinary word, so it is found only where it
29359
- * is used as a task: after `holocron run`, `turbo run`, `pnpm` or `pnpm run`, as a `package.json` script or as a
29360
- * `turbo.json` task.
29361
- * - A `package.json` script named like an npm/pnpm lifecycle word is reported too (see {@link findReserved}).
29362
- * - A line, or the line below one, that carries the {@link ALLOW_MARKER} is skipped.
29363
- *
29364
- * Files come back in the order given, lines top to bottom.
29365
- */
29366
- function findLeftovers(files, names, options = {}) {
29367
- const dotted = Object.keys(names).filter((n) => n.includes("."));
29368
- const bare = Object.keys(names).filter((n) => !n.includes("."));
29369
- const tail = options.files ? String.raw`(?![\w-])` : String.raw`(?![\w-]|\.ya?ml\b)`;
29370
- const dottedPattern = new RegExp(`(?<![\\w.-])(${alternation(dotted)})${tail}`, "g");
29371
- const barePattern = new RegExp(`(?<![\\w.-])${COMMAND$1}(${alternation(bare)})(?![\\w:-]|\\.\\w)`, "g");
29372
- return files.flatMap((file) => {
29373
- const lines = file.text.split("\n");
29374
- const field = taskField(file.path);
29375
- const inText = lines.flatMap((text, i) => [...text.matchAll(dottedPattern), ...text.matchAll(barePattern)].map((m) => ({
29376
- file: file.path,
29377
- line: i + 1,
29378
- old: m[1],
29379
- replacement: names[m[1]]
29380
- })));
29381
- const asKey = (field === void 0 ? [] : scriptKeys(file.text, field)).filter(({ key }) => bare.includes(key)).map(({ key, line }) => ({
29382
- file: file.path,
29383
- line,
29384
- old: key,
29385
- replacement: names[key]
29386
- }));
29387
- const seen = /* @__PURE__ */ new Set();
29388
- return [
29389
- ...inText,
29390
- ...asKey,
29391
- ...findReserved(file)
29392
- ].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"));
29393
- });
29394
- }
29395
- // src/commands/probe/tasks/is-generated.ts
29396
- /** Whether a file carries the generated-file header in its first lines; drift in those is `probe generated check`'s to report. */
29397
- function isGenerated(text) {
29398
- return text.split("\n", 3).some((line) => line.includes("AUTO-GENERATED"));
29399
- }
29400
- // src/commands/probe/tasks/is-scanned.ts
29401
- /** Files that describe the old names on purpose: specs, ADRs, the changelog, tests, and this probe's own folder. */
29402
- const SKIPPED = [
29403
- /(^|\/)CHANGELOG\.md$/,
29404
- /^\.notes\//,
29405
- /^docs\/wiki\//,
29406
- /\.test\.tsx?$/,
29407
- /^cli\/cli\/src\/commands\/probe\/tasks\//
29408
- ];
29409
- /** The kinds of file the probe reads: workflows, scripts, docs, configs, hooks and manifests. */
29410
- const SCANNED = [
29411
- /^\.github\/(workflows|actions)\/.+\.ya?ml$/,
29412
- /^\.husky\//,
29413
- /^scripts\//,
29414
- /(^|\/)(package|turbo)\.json$/,
29415
- /(^|\/)(holocron|astromech)\.config\.[cm]?[jt]s$/,
29416
- /(^|\/)\.lintstagedrc/,
29417
- /\.mdx?$/
29418
- ];
29419
- /** Whether `path` (repo-relative) is a hand-written kind of place to scan for old task names. */
29420
- function isScanned(path) {
29421
- return SCANNED.some((p) => p.test(path)) && !SKIPPED.some((p) => p.test(path));
29422
- }
29423
- // src/commands/probe/tasks/legacy-replacements.ts
29424
- /**
29425
- * Each old task name astromech's `LEGACY_NAMES` still accepts, with the text the `tasks names` probe prints as its
29426
- * replacement: the flat ids it became, in run order. A successor that adds args (`format --check`, the read-only
29427
- * prettier half of `sourceQuality.formatting`) is named last, in parentheses: `lint:editorconfig, lint:markdown (format
29428
- * for prettier)`. A name that is a suite now (`validate`, once the interim id of `platform.repoValidation`) is left out:
29429
- * `holocron run validate` is the suite, not a leftover.
29430
- */
29431
- function legacyReplacements() {
29432
- return Object.fromEntries(Object.entries(LEGACY_NAMES).filter(([old]) => !SUITES.includes(old)).map(([old, targets]) => {
29433
- const own = targets.filter((t) => t.passthrough === void 0).map((t) => t.id);
29434
- const checked = targets.filter((t) => t.passthrough !== void 0).map((t) => `${t.id} for prettier`);
29435
- return [old, checked.length === 0 ? own.join(", ") : `${own.join(", ")} (${checked.join(", ")})`];
29436
- }));
29437
- }
29438
- // src/commands/probe/tasks/real-tasks-io.ts
29439
- /** The `tasks names` probe's inputs from the tracked files under `repoRoot`. */
29440
- function realTasksIo(repoRoot) {
29441
- /* v8 ignore start -- reads git and the real filesystem; the probe is tested with an injected io */
29442
- return { files: () => execFileSync("git", ["ls-files", "-z"], {
29443
- cwd: repoRoot,
29444
- encoding: "utf8",
29445
- maxBuffer: 67108864
29446
- }).split("\0").filter((path) => path !== "" && isScanned(path)).flatMap((path) => {
29447
- try {
29448
- const text = readFileSync(join(repoRoot, path), "utf8");
29449
- return isGenerated(text) ? [] : [{
29450
- path,
29451
- text
29452
- }];
29453
- } catch {
29454
- return [];
29455
- }
29456
- }) };
29457
- /* v8 ignore stop */
29458
- }
29459
- // src/commands/probe/tasks/tasks-probes.ts
29460
- /** The group of probes that check the repo's task vocabulary. */
29461
- const TASKS_PROVIDER = "tasks";
29462
- /**
29463
- * `tasks names`: finds the hand-written places that still use an old task name from the flat-vocabulary map
29464
- * (SPEC-0064, astromech's `LEGACY_NAMES`): a dotted one (`delivery.build`, `verification.unitTests`), a bare one used as a
29465
- * task (`holocron run review`, a `review` script) or a `package.json` script with a reserved npm/pnpm name (`publish`).
29466
- * It scans workflows, scripts, docs, `turbo.json`, `package.json`, the configs' `tasks:` and the hooks, and reports each
29467
- * with file, line and the id to use instead. Each is a failure (exit code 1); `--warn` reports them as `info` rows
29468
- * instead. A dotted name that is part of a workflow file name (`delivery.build.yml`) is skipped until the files are
29469
- * renamed; `--files` lists those too. An intentional mention carries the `holocron-allow-old-name` marker on its line or the line above.
29470
- * Files `sync` generates are left to `generated check`; specs, ADRs and the changelog name the old tasks on purpose.
29471
- */
29472
- function tasksProbes(io, names = legacyReplacements()) {
29473
- return { names: {
29474
- summary: "Report each use of an old task name in hand-written files; fails unless --warn; --files adds file names.",
29475
- writes: false,
29476
- async run(ctx) {
29477
- const status = ctx.args?.includes("--warn") ? "info" : "fail";
29478
- ctx.say({
29479
- status: "heading",
29480
- label: "Old task names"
29481
- });
29482
- const found = findLeftovers(io.files(), names, { files: ctx.args?.includes("--files") === true });
29483
- for (const f of found) ctx.say({
29484
- status,
29485
- label: `${f.file}:${f.line}`,
29486
- detail: `${f.old} -> ${f.replacement}`
29487
- });
29488
- ctx.say({
29489
- status: found.length === 0 ? "ok" : status,
29490
- label: "old names",
29491
- detail: `${found.length} use(s) of ${Object.keys(names).length} old name(s)`
29492
- });
29493
- }
29494
- } };
29495
- }
29496
29566
  // src/commands/probe/probe.ts
29497
29567
  /**
29498
29568
  * `holocron probe [<provider> [<probe>]]`. With nothing, lists what can be probed; with a provider, lists its probes;
@@ -33891,30 +33961,6 @@ const syncToolingCommand = {
33891
33961
  })).status === "fail") process.exitCode = 1;
33892
33962
  }
33893
33963
  };
33894
- // src/commands/obsolete-workflows/find-obsolete-workflows.ts
33895
- /** The lines at the head of a generated workflow that hold the header and the `# Source package:` marker. */
33896
- const HEADER_LINES = 6;
33897
- /**
33898
- * The workflow files in `.github/workflows` that an earlier `sync` generated and that this run no longer writes, because
33899
- * their task left the config or a preset (#2338). Sorted by name.
33900
- *
33901
- * It names a file only when all of these hold, so a file nobody generated is never removed:
33902
- * - the generator's own `AUTO-GENERATED` header is at its head;
33903
- * - it is not marked `# HAND-MAINTAINED`;
33904
- * - its `# Source package:` line is this run's package, so a run for `apps/sentinel` leaves the root's files alone, and a
33905
- * file with no marker (written before the marker existed) is left for `probe generated check` to report;
33906
- * - this run does not write it.
33907
- */
33908
- function findObsoleteWorkflows({ workflows, written, pkgRelPath }) {
33909
- const obsolete = [];
33910
- for (const [name, text] of workflows) {
33911
- if (written.has(name) || text.startsWith("# HAND-MAINTAINED") || !isGenerated(text)) continue;
33912
- const head = text.split("\n", HEADER_LINES).join("\n");
33913
- if (SOURCE_PACKAGE_MARKER.exec(head)?.[1] !== pkgRelPath) continue;
33914
- obsolete.push(name);
33915
- }
33916
- return obsolete.sort();
33917
- }
33918
33964
  // src/presets/constants.ts
33919
33965
  /**
33920
33966
  * The org's DNS zone as the presets ship it to a consumer repo that has no `.holocron/org.ts` of its own. A repo