@theholocron/cli 5.0.0-alpha.504 → 5.0.0-alpha.506

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
@@ -2692,11 +2692,28 @@ function validateEnvironmentChoice(entry, what, required = true) {
2692
2692
  const AREA_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
2693
2693
  /** GitHub's longest label name is 50 characters, and `area:` takes five. */
2694
2694
  const MAX_NAME = 45;
2695
+ /** GitHub's longest label name. */
2696
+ const MAX_LABEL = 50;
2697
+ /** `owner/name`, as GitHub spells a repository. */
2698
+ const REPOSITORY = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
2699
+ /** Checks one label-to-Type table and records each label (lower case) in `seen`, so no label is in two tables. */
2700
+ function validateKinds(key, table, seen) {
2701
+ for (const [label, type] of Object.entries(table ?? {})) {
2702
+ const at = `\`repo.labels.${key}.${label}\``;
2703
+ if (label.trim() === "" || label.length > MAX_LABEL) throw new ConfigError$1(`${at}: a label name is 1 to ${MAX_LABEL} characters`);
2704
+ if (typeof type !== "string" || type.trim() === "") throw new ConfigError$1(`${at} needs the name of an issue Type, such as "Bug"`);
2705
+ const lower = label.toLowerCase();
2706
+ const first = seen.get(lower);
2707
+ if (first !== void 0) throw new ConfigError$1(`${at}: ${JSON.stringify(label)} is already in \`${first}\``);
2708
+ seen.set(lower, `repo.labels.${key}.${label}`);
2709
+ }
2710
+ }
2695
2711
  /**
2696
2712
  * Check `repo.labels` (spec `tech-github-area-labels`): each area name must be usable as the suffix of a label (letters,
2697
2713
  * digits, `.`, `_` and `-`, at most 45 characters) and appear once whatever the case (GitHub's labels are
2698
2714
  * case-insensitive), each area needs a list of patterns with at least one that includes a path, and each scope names a
2699
- * declared area.
2715
+ * declared area. `kinds` and `fallbackKinds` map a label name (at most 50 characters, in one table only) to a Type name,
2716
+ * and `repos` lists `owner/name` repositories; whether a Type exists is the organization's to say, so the probe checks it.
2700
2717
  *
2701
2718
  * @param labels - `repo.labels`, if the config has it.
2702
2719
  * @throws {ConfigError} Naming the path of the first problem found.
@@ -2724,6 +2741,12 @@ function validateRepoLabels(labels) {
2724
2741
  throw new ConfigError$1(`${at} names the unknown area ${JSON.stringify(area)}; ${known.length > 0 ? `the declared areas are ${known.join(", ")}` : "`repo.labels.areas` declares none"}`);
2725
2742
  }
2726
2743
  }
2744
+ const kinds = /* @__PURE__ */ new Map();
2745
+ validateKinds("kinds", labels.kinds, kinds);
2746
+ validateKinds("fallbackKinds", labels.fallbackKinds, kinds);
2747
+ const repos = labels.repos ?? [];
2748
+ if (!Array.isArray(repos)) throw new ConfigError$1("`repo.labels.repos` is a list of `owner/name` repositories");
2749
+ for (const repo of repos) if (typeof repo !== "string" || !REPOSITORY.test(repo)) throw new ConfigError$1(`\`repo.labels.repos\` has ${JSON.stringify(repo)}, which is not an \`owner/name\` repository`);
2727
2750
  }
2728
2751
  // src/credentials-environments/repo-slug/repo-slug.ts
2729
2752
  /**
@@ -20080,123 +20103,411 @@ async function handOffHeartbeats(input) {
20080
20103
  reason: "file-left"
20081
20104
  };
20082
20105
  }
20083
- // ../../.holocron/org.md
20084
- 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";
20085
- // src/commands/repo-files/generate-agent-files.ts
20086
- const ORG_BLOCK_BEGIN = "<!-- BEGIN holocron org agent instructions (generated by `holocron sync` from theholocron/holocron .agents/org.md; do not edit) -->";
20087
- const ORG_BLOCK_END = "<!-- END holocron org agent instructions -->";
20088
- /** The generated block: the org agent instructions between two markers. */
20089
- function orgAgentsBlock() {
20090
- return `${ORG_BLOCK_BEGIN}\n\n${org_default.trim()}\n\n${ORG_BLOCK_END}\n`;
20106
+ // src/commands/probe/tasks/script-keys.ts
20107
+ /**
20108
+ * The keys of the object `field` (`scripts` in a `package.json`, `tasks` in a `turbo.json`) with their lines; none when
20109
+ * the text is not JSON or has no such object.
20110
+ */
20111
+ function scriptKeys(text, field) {
20112
+ let value;
20113
+ try {
20114
+ value = JSON.parse(text)[field];
20115
+ } catch {
20116
+ return [];
20117
+ }
20118
+ if (typeof value !== "object" || value === null) return [];
20119
+ const lines = text.split("\n");
20120
+ const start = lines.findIndex((l) => l.includes(`"${field}"`));
20121
+ return Object.keys(value).map((key) => ({
20122
+ key,
20123
+ line: lines.findIndex((l, i) => i > start && l.trimStart().startsWith(`"${key}"`)) + 1
20124
+ }));
20125
+ }
20126
+ // src/commands/probe/tasks/find-reserved.ts
20127
+ /** What to use instead of a reserved script name: `publish` has a task of its own, the rest are never tasks. */
20128
+ function instead(name) {
20129
+ return name === "publish" ? "release (`publish` is reserved by npm and pnpm)" : "(reserved by npm and pnpm, never a task)";
20091
20130
  }
20092
20131
  /**
20093
- * `text` with the generated block set to the current org instructions: replaced in place when the markers are there,
20094
- * appended otherwise. A file that imports `@.holocron/org.md` (holocron itself) already has them and is left alone.
20132
+ * Every `package.json` script named like an npm/pnpm lifecycle word (`RESERVED_SCRIPT_NAMES`): `pnpm publish` would run
20133
+ * it after publishing. The root `prepare` (husky) is the one allowed.
20095
20134
  */
20096
- function withOrgBlock(text) {
20097
- if (/^@\.holocron\/org\.md\s*$/m.test(text)) return text;
20098
- const start = text.indexOf(ORG_BLOCK_BEGIN);
20099
- const end = text.indexOf(ORG_BLOCK_END);
20100
- if (start !== -1 && end > start) return `${text.slice(0, start)}${orgAgentsBlock()}${text.slice(end + 44).replace(/^\n/, "")}`;
20101
- return `${text.replace(/\n*$/, "\n\n")}${orgAgentsBlock()}`;
20135
+ function findReserved(file) {
20136
+ if (!/(^|\/)package\.json$/.test(file.path)) return [];
20137
+ return scriptKeys(file.text, "scripts").filter(({ key }) => RESERVED_SCRIPT_NAMES.has(key) && !(file.path === "package.json" && key === "prepare")).map(({ key, line }) => ({
20138
+ file: file.path,
20139
+ line,
20140
+ old: key,
20141
+ replacement: instead(key)
20142
+ }));
20143
+ }
20144
+ // src/commands/probe/tasks/find-leftovers.ts
20145
+ /** The commands that take a task name as their next word: `holocron run`, `turbo run`, `pnpm run`, `pnpm`, ... */
20146
+ const COMMAND$4 = String.raw`(?:holocron run|turbo run|pnpm run|npm run|pnpm|yarn)\s+`;
20147
+ /** A regex alternation of `names`, escaped; matches nothing for an empty list. */
20148
+ function alternation(names) {
20149
+ return names.length === 0 ? "(?!)" : names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
20150
+ }
20151
+ /** The field of a manifest whose keys are tasks or scripts: `scripts` in a `package.json`, `tasks` in a `turbo.json`. */
20152
+ function taskField(path) {
20153
+ return /(^|\/)package\.json$/.test(path) ? "scripts" : /(^|\/)turbo\.json$/.test(path) ? "tasks" : void 0;
20102
20154
  }
20103
20155
  /**
20104
- * The org agent instructions as a generated block in the repo's `AGENTS.md` (or `CLAUDE.md` when that is the only
20105
- * file, a symlink to `AGENTS.md` being the same file). The rest of the file is the repo's own and is kept. A repo with
20106
- * neither file gets none: this does not create the contract, only keeps the shared part of it current.
20156
+ * Every use of an old task name in `files`, with its file, line and replacement.
20157
+ *
20158
+ * - A dotted name (`delivery.build`) matches as a whole token: found in `turbo run delivery.build`, not in
20159
+ * `delivery.buildX`. Followed by `.yml`/`.yaml` it is a workflow file name and is left out unless `options.files`.
20160
+ * - A bare name (`review`, `stale`: the keys of `names` without a dot) is an ordinary word, so it is found only where it
20161
+ * is used as a task: after `holocron run`, `turbo run`, `pnpm` or `pnpm run`, as a `package.json` script or as a
20162
+ * `turbo.json` task.
20163
+ * - A `package.json` script named like an npm/pnpm lifecycle word is reported too (see {@link findReserved}).
20164
+ * - A line, or the line below one, that carries the {@link ALLOW_MARKER} is skipped.
20165
+ *
20166
+ * Files come back in the order given, lines top to bottom.
20107
20167
  */
20108
- async function generateAgentFiles(input) {
20109
- const path = await agentsFile(input.repoRoot);
20110
- const step = `write ${path ?? "AGENTS.md"}`;
20111
- if (path === null) return [{
20112
- kind: "skip",
20113
- step,
20114
- syncStep: step,
20115
- message: "no AGENTS.md or CLAUDE.md"
20116
- }];
20117
- const existing = await readFile(join(input.repoRoot, path), "utf8");
20118
- const content = withOrgBlock(existing);
20119
- if (content === existing && !existing.includes("<!-- BEGIN holocron org agent instructions (generated by `holocron sync` from theholocron/holocron .agents/org.md; do not edit) -->")) return [{
20120
- kind: "skip",
20121
- step,
20122
- syncStep: step,
20123
- message: "imports .holocron/org.md"
20124
- }];
20125
- return [{
20126
- kind: "file",
20127
- path,
20128
- content,
20129
- step,
20130
- syncStep: step,
20131
- note: "org agent instructions block"
20132
- }];
20168
+ function findLeftovers(files, names, options = {}) {
20169
+ const dotted = Object.keys(names).filter((n) => n.includes("."));
20170
+ const bare = Object.keys(names).filter((n) => !n.includes("."));
20171
+ const tail = options.files ? String.raw`(?![\w-])` : String.raw`(?![\w-]|\.ya?ml\b)`;
20172
+ const dottedPattern = new RegExp(`(?<![\\w.-])(${alternation(dotted)})${tail}`, "g");
20173
+ const barePattern = new RegExp(`(?<![\\w.-])${COMMAND$4}(${alternation(bare)})(?![\\w:-]|\\.\\w)`, "g");
20174
+ return files.flatMap((file) => {
20175
+ const lines = file.text.split("\n");
20176
+ const field = taskField(file.path);
20177
+ const inText = lines.flatMap((text, i) => [...text.matchAll(dottedPattern), ...text.matchAll(barePattern)].map((m) => ({
20178
+ file: file.path,
20179
+ line: i + 1,
20180
+ old: m[1],
20181
+ replacement: names[m[1]]
20182
+ })));
20183
+ const asKey = (field === void 0 ? [] : scriptKeys(file.text, field)).filter(({ key }) => bare.includes(key)).map(({ key, line }) => ({
20184
+ file: file.path,
20185
+ line,
20186
+ old: key,
20187
+ replacement: names[key]
20188
+ }));
20189
+ const seen = /* @__PURE__ */ new Set();
20190
+ return [
20191
+ ...inText,
20192
+ ...asKey,
20193
+ ...findReserved(file)
20194
+ ].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"));
20195
+ });
20133
20196
  }
20134
- async function agentsFile(root) {
20135
- for (const name of ["AGENTS.md", "CLAUDE.md"]) if ((await lstat(join(root, name)).catch(() => null))?.isFile()) return name;
20136
- return null;
20197
+ // src/commands/probe/tasks/is-generated.ts
20198
+ /** Whether a file carries the generated-file header in its first lines; drift in those is `probe generated check`'s to report. */
20199
+ function isGenerated(text) {
20200
+ return text.split("\n", 3).some((line) => line.includes("AUTO-GENERATED"));
20137
20201
  }
20138
- const isObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
20139
- /** Whether a hook entry already runs `dcg`, with or without arguments (`dcg`, `dcg --strict`, a path ending in `/dcg`). */
20140
- function runsDcg(hook) {
20141
- if (!isObject$1(hook) || typeof hook.command !== "string") return false;
20142
- const program = hook.command.trim().split(/\s+/)[0];
20143
- return program === "dcg" || program.endsWith(`/dcg`);
20202
+ // src/commands/probe/tasks/is-scanned.ts
20203
+ /** Files that describe the old names on purpose: specs, ADRs, the changelog, tests, and this probe's own folder. */
20204
+ const SKIPPED = [
20205
+ /(^|\/)CHANGELOG\.md$/,
20206
+ /^\.notes\//,
20207
+ /^docs\/wiki\//,
20208
+ /\.test\.tsx?$/,
20209
+ /^cli\/cli\/src\/commands\/probe\/tasks\//
20210
+ ];
20211
+ /** The kinds of file the probe reads: workflows, scripts, docs, configs, hooks and manifests. */
20212
+ const SCANNED = [
20213
+ /^\.github\/(workflows|actions)\/.+\.ya?ml$/,
20214
+ /^\.husky\//,
20215
+ /^scripts\//,
20216
+ /(^|\/)(package|turbo)\.json$/,
20217
+ /(^|\/)(holocron|astromech)\.config\.[cm]?[jt]s$/,
20218
+ /(^|\/)\.lintstagedrc/,
20219
+ /\.mdx?$/
20220
+ ];
20221
+ /** Whether `path` (repo-relative) is a hand-written kind of place to scan for old task names. */
20222
+ function isScanned(path) {
20223
+ return SCANNED.some((p) => p.test(path)) && !SKIPPED.some((p) => p.test(path));
20144
20224
  }
20225
+ // src/commands/probe/tasks/legacy-replacements.ts
20145
20226
  /**
20146
- * `settings` with the `dcg` `PreToolUse` hook for Bash calls wired in, and everything else in it (permissions, other
20147
- * hooks, other matchers) exactly as it was. Already wired, whatever the matcher entry looks like around it, is left
20148
- * alone, so a second run changes nothing. Throws on a file whose shape cannot hold the hook (`hooks` or `PreToolUse`
20149
- * that is not an object or a list), so a hand-edited file is never silently replaced.
20227
+ * Each old task name astromech's `LEGACY_NAMES` still accepts, with the text the `tasks names` probe prints as its
20228
+ * replacement: the flat ids it became, in run order. A successor that adds args (`format --check`, the read-only
20229
+ * prettier half of `sourceQuality.formatting`) is named last, in parentheses: `lint:editorconfig, lint:markdown (format
20230
+ * for prettier)`. A name that is a suite now (`validate`, once the interim id of `platform.repoValidation`) is left out:
20231
+ * `holocron run validate` is the suite, not a leftover.
20150
20232
  */
20151
- function withDcgHook(settings) {
20152
- if (!isObject$1(settings)) throw new Error("the settings file is not a JSON object");
20153
- const hooks = settings.hooks ?? {};
20154
- if (!isObject$1(hooks)) throw new Error("`hooks` in the settings file is not an object");
20155
- const listed = hooks.PreToolUse ?? [];
20156
- if (!Array.isArray(listed)) throw new Error("`hooks.PreToolUse` in the settings file is not a list");
20157
- const preToolUse = listed;
20158
- if (preToolUse.some((entry) => isObject$1(entry) && entry.matcher === "Bash" && Array.isArray(entry.hooks) && entry.hooks.some(runsDcg))) return settings;
20159
- return {
20160
- ...settings,
20161
- hooks: {
20162
- ...hooks,
20163
- PreToolUse: [...preToolUse, {
20164
- matcher: "Bash",
20165
- hooks: [{
20166
- type: "command",
20167
- command: "dcg"
20168
- }]
20169
- }]
20233
+ function legacyReplacements() {
20234
+ return Object.fromEntries(Object.entries(LEGACY_NAMES).filter(([old]) => !SUITES.includes(old)).map(([old, targets]) => {
20235
+ const own = targets.filter((t) => t.passthrough === void 0).map((t) => t.id);
20236
+ const checked = targets.filter((t) => t.passthrough !== void 0).map((t) => `${t.id} for prettier`);
20237
+ return [old, checked.length === 0 ? own.join(", ") : `${own.join(", ")} (${checked.join(", ")})`];
20238
+ }));
20239
+ }
20240
+ // src/commands/probe/tasks/real-tasks-io.ts
20241
+ /** The `tasks names` probe's inputs from the tracked files under `repoRoot`. */
20242
+ function realTasksIo(repoRoot) {
20243
+ /* v8 ignore start -- reads git and the real filesystem; the probe is tested with an injected io */
20244
+ return { files: () => execFileSync("git", ["ls-files", "-z"], {
20245
+ cwd: repoRoot,
20246
+ encoding: "utf8",
20247
+ maxBuffer: 67108864
20248
+ }).split("\0").filter((path) => path !== "" && isScanned(path)).flatMap((path) => {
20249
+ try {
20250
+ const text = readFileSync(join(repoRoot, path), "utf8");
20251
+ return isGenerated(text) ? [] : [{
20252
+ path,
20253
+ text
20254
+ }];
20255
+ } catch {
20256
+ return [];
20170
20257
  }
20171
- };
20258
+ }) };
20259
+ /* v8 ignore stop */
20172
20260
  }
20173
- // src/commands/repo-files/generate-claude-files.ts
20174
- const CLAUDE_SETTINGS_FILE = ".claude/settings.json";
20261
+ // src/commands/probe/tasks/tasks-probes.ts
20262
+ /** The group of probes that check the repo's task vocabulary. */
20263
+ const TASKS_PROVIDER = "tasks";
20175
20264
  /**
20176
- * `.claude/settings.json` with the `dcg` `PreToolUse` hook, for a repo whose config opts in with `agent: ["claude", { dcg: true }]`. The file
20177
- * already on disk is merged, so a repo's own `permissions` and hooks are kept; the same bytes come out of `setup` and
20178
- * `sync`, and `probe generated check` fails when the hook is missing. A repo that does not opt in gets nothing (no
20179
- * step, no file), so the repos that never used it are unchanged. A file that is not valid JSON, or has a shape that
20180
- * cannot hold the hook, is a failed step naming the file; it is never overwritten.
20265
+ * `tasks names`: finds the hand-written places that still use an old task name from the flat-vocabulary map
20266
+ * (SPEC-0064, astromech's `LEGACY_NAMES`): a dotted one (`delivery.build`, `verification.unitTests`), a bare one used as a
20267
+ * task (`holocron run review`, a `review` script) or a `package.json` script with a reserved npm/pnpm name (`publish`).
20268
+ * It scans workflows, scripts, docs, `turbo.json`, `package.json`, the configs' `tasks:` and the hooks, and reports each
20269
+ * with file, line and the id to use instead. Each is a failure (exit code 1); `--warn` reports them as `info` rows
20270
+ * instead. A dotted name that is part of a workflow file name (`delivery.build.yml`) is skipped until the files are
20271
+ * renamed; `--files` lists those too. An intentional mention carries the `holocron-allow-old-name` marker on its line or the line above.
20272
+ * Files `sync` generates are left to `generated check`; specs, ADRs and the changelog name the old tasks on purpose.
20181
20273
  */
20182
- async function generateClaudeFiles(input) {
20183
- if (input.loaded.resolved.agentOptions?.dcg !== true) return [];
20184
- const step = `write ${CLAUDE_SETTINGS_FILE}`;
20185
- const text = await readFile(join(input.repoRoot, CLAUDE_SETTINGS_FILE), "utf8").catch(() => void 0);
20186
- let existing = {};
20187
- if (text !== void 0) try {
20188
- existing = JSON.parse(text);
20189
- } catch {
20190
- return [{
20191
- kind: "error",
20192
- step,
20193
- syncStep: step,
20194
- message: `${CLAUDE_SETTINGS_FILE} is not valid JSON`
20195
- }];
20196
- }
20197
- try {
20198
- const content = formatJson(withDcgHook(existing));
20199
- return [{
20274
+ function tasksProbes(io, names = legacyReplacements()) {
20275
+ return { names: {
20276
+ summary: "Report each use of an old task name in hand-written files; fails unless --warn; --files adds file names.",
20277
+ writes: false,
20278
+ async run(ctx) {
20279
+ const status = ctx.args?.includes("--warn") ? "info" : "fail";
20280
+ ctx.say({
20281
+ status: "heading",
20282
+ label: "Old task names"
20283
+ });
20284
+ const found = findLeftovers(io.files(), names, { files: ctx.args?.includes("--files") === true });
20285
+ for (const f of found) ctx.say({
20286
+ status,
20287
+ label: `${f.file}:${f.line}`,
20288
+ detail: `${f.old} -> ${f.replacement}`
20289
+ });
20290
+ ctx.say({
20291
+ status: found.length === 0 ? "ok" : status,
20292
+ label: "old names",
20293
+ detail: `${found.length} use(s) of ${Object.keys(names).length} old name(s)`
20294
+ });
20295
+ }
20296
+ } };
20297
+ }
20298
+ // src/commands/workflow-source-marker/workflow-source-marker.ts
20299
+ /** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
20300
+ const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
20301
+ /** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
20302
+ function sanitizeForDisplay(value) {
20303
+ return value.replace(/[\x00-\x1f\x7f]/g, "");
20304
+ }
20305
+ /**
20306
+ * Repo-root-relative path of the PACKAGE a workflow-writing command run is
20307
+ * scoped to — the directory holding the discovered `holocron.config.*`
20308
+ * (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
20309
+ * up to find the config from any subdirectory ("every command is usable
20310
+ * from any subdirectory of a repo, not only its exact root"), so a `--cwd`
20311
+ * one level too deep would otherwise stamp a different marker than a later
20312
+ * run from the package's own root and misfire the collision check this
20313
+ * feeds (holocron#1026).
20314
+ *
20315
+ * "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
20316
+ * to forward slashes so the same package produces the same marker on
20317
+ * Windows and POSIX. Throws if the result contains a line break — a path
20318
+ * containing one could otherwise break out of the `# Source package: `
20319
+ * comment line and inject arbitrary workflow YAML when the generated
20320
+ * content is later written. Not reachable through this CLI's own flows
20321
+ * (no code path writes a config file whose directory name contains a line
20322
+ * break), but cheap to reject outright rather than trust the filesystem.
20323
+ */
20324
+ function resolvePkgRelPath(gitRoot, configFilepath) {
20325
+ let root;
20326
+ try {
20327
+ root = realpathSync(gitRoot);
20328
+ } catch {
20329
+ root = gitRoot;
20330
+ }
20331
+ let configDir;
20332
+ try {
20333
+ configDir = realpathSync(dirname(configFilepath));
20334
+ } catch {
20335
+ configDir = dirname(configFilepath);
20336
+ }
20337
+ const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
20338
+ if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
20339
+ return pkgRelPath;
20340
+ }
20341
+ /**
20342
+ * Two different monorepo packages opting into the same generic task name
20343
+ * (e.g. both `apps/sentinel` and some future `apps/other` configuring
20344
+ * `delivery.previewDeploy`) would otherwise overwrite each other's
20345
+ * `.github/workflows/<task>.yml` on whichever package's write ran last —
20346
+ * only one package's behavior would ever actually run in CI, with no
20347
+ * signal that the other's was silently dropped (holocron#1026).
20348
+ *
20349
+ * Shared by both `holocron sync` (reads the file straight off local
20350
+ * disk) and `holocron setup` (reads it through the loaded `Source`
20351
+ * capability, which happens to be local disk too for the github plugin
20352
+ * today, but the interface doesn't promise that for every provider —
20353
+ * holocron#1068). The marker-parsing and error message are identical
20354
+ * either way; `readExisting` is how the two callers differ.
20355
+ *
20356
+ * A file with no marker at all predates this check (or was written before
20357
+ * #1026) and is never flagged — only a marker that's present AND disagrees
20358
+ * with the current run's own package is a real collision. `readExisting`
20359
+ * returning `null` means "nothing there," not "unreadable" — a caller
20360
+ * whose underlying read can fail for reasons other than "doesn't exist"
20361
+ * (e.g. local fs EISDIR) is expected to let that error propagate out of
20362
+ * `readExisting` itself rather than mapping it to `null`.
20363
+ */
20364
+ async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
20365
+ const existing = await readExisting();
20366
+ if (existing === null) return;
20367
+ const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
20368
+ 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.`);
20369
+ }
20370
+ // src/commands/obsolete-workflows/find-obsolete-workflows.ts
20371
+ /** The lines at the head of a generated workflow that hold the header and the `# Source package:` marker. */
20372
+ const HEADER_LINES = 6;
20373
+ /**
20374
+ * The workflow files in `.github/workflows` that an earlier `sync` generated and that this run no longer writes, because
20375
+ * their task left the config or a preset (#2338). Sorted by name.
20376
+ *
20377
+ * It names a file only when all of these hold, so a file nobody generated is never removed:
20378
+ * - the generator's own `AUTO-GENERATED` header is at its head;
20379
+ * - it is not marked `# HAND-MAINTAINED`;
20380
+ * - its `# Source package:` line is this run's package, so a run for `apps/sentinel` leaves the root's files alone, and a
20381
+ * file with no marker (written before the marker existed) is left for `probe generated check` to report;
20382
+ * - this run does not write it.
20383
+ */
20384
+ function findObsoleteWorkflows({ workflows, written, pkgRelPath }) {
20385
+ const obsolete = [];
20386
+ for (const [name, text] of workflows) {
20387
+ if (written.has(name) || text.startsWith("# HAND-MAINTAINED") || !isGenerated(text)) continue;
20388
+ const head = text.split("\n", HEADER_LINES).join("\n");
20389
+ if (SOURCE_PACKAGE_MARKER.exec(head)?.[1] !== pkgRelPath) continue;
20390
+ obsolete.push(name);
20391
+ }
20392
+ return obsolete.sort();
20393
+ }
20394
+ // ../../.holocron/org.md
20395
+ 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";
20396
+ // src/commands/repo-files/generate-agent-files.ts
20397
+ const ORG_BLOCK_BEGIN = "<!-- BEGIN holocron org agent instructions (generated by `holocron sync` from theholocron/holocron .agents/org.md; do not edit) -->";
20398
+ const ORG_BLOCK_END = "<!-- END holocron org agent instructions -->";
20399
+ /** The generated block: the org agent instructions between two markers. */
20400
+ function orgAgentsBlock() {
20401
+ return `${ORG_BLOCK_BEGIN}\n\n${org_default.trim()}\n\n${ORG_BLOCK_END}\n`;
20402
+ }
20403
+ /**
20404
+ * `text` with the generated block set to the current org instructions: replaced in place when the markers are there,
20405
+ * appended otherwise. A file that imports `@.holocron/org.md` (holocron itself) already has them and is left alone.
20406
+ */
20407
+ function withOrgBlock(text) {
20408
+ if (/^@\.holocron\/org\.md\s*$/m.test(text)) return text;
20409
+ const start = text.indexOf(ORG_BLOCK_BEGIN);
20410
+ const end = text.indexOf(ORG_BLOCK_END);
20411
+ if (start !== -1 && end > start) return `${text.slice(0, start)}${orgAgentsBlock()}${text.slice(end + 44).replace(/^\n/, "")}`;
20412
+ return `${text.replace(/\n*$/, "\n\n")}${orgAgentsBlock()}`;
20413
+ }
20414
+ /**
20415
+ * The org agent instructions as a generated block in the repo's `AGENTS.md` (or `CLAUDE.md` when that is the only
20416
+ * file, a symlink to `AGENTS.md` being the same file). The rest of the file is the repo's own and is kept. A repo with
20417
+ * neither file gets none: this does not create the contract, only keeps the shared part of it current.
20418
+ */
20419
+ async function generateAgentFiles(input) {
20420
+ const path = await agentsFile(input.repoRoot);
20421
+ const step = `write ${path ?? "AGENTS.md"}`;
20422
+ if (path === null) return [{
20423
+ kind: "skip",
20424
+ step,
20425
+ syncStep: step,
20426
+ message: "no AGENTS.md or CLAUDE.md"
20427
+ }];
20428
+ const existing = await readFile(join(input.repoRoot, path), "utf8");
20429
+ const content = withOrgBlock(existing);
20430
+ if (content === existing && !existing.includes("<!-- BEGIN holocron org agent instructions (generated by `holocron sync` from theholocron/holocron .agents/org.md; do not edit) -->")) return [{
20431
+ kind: "skip",
20432
+ step,
20433
+ syncStep: step,
20434
+ message: "imports .holocron/org.md"
20435
+ }];
20436
+ return [{
20437
+ kind: "file",
20438
+ path,
20439
+ content,
20440
+ step,
20441
+ syncStep: step,
20442
+ note: "org agent instructions block"
20443
+ }];
20444
+ }
20445
+ async function agentsFile(root) {
20446
+ for (const name of ["AGENTS.md", "CLAUDE.md"]) if ((await lstat(join(root, name)).catch(() => null))?.isFile()) return name;
20447
+ return null;
20448
+ }
20449
+ const isObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
20450
+ /** Whether a hook entry already runs `dcg`, with or without arguments (`dcg`, `dcg --strict`, a path ending in `/dcg`). */
20451
+ function runsDcg(hook) {
20452
+ if (!isObject$1(hook) || typeof hook.command !== "string") return false;
20453
+ const program = hook.command.trim().split(/\s+/)[0];
20454
+ return program === "dcg" || program.endsWith(`/dcg`);
20455
+ }
20456
+ /**
20457
+ * `settings` with the `dcg` `PreToolUse` hook for Bash calls wired in, and everything else in it (permissions, other
20458
+ * hooks, other matchers) exactly as it was. Already wired, whatever the matcher entry looks like around it, is left
20459
+ * alone, so a second run changes nothing. Throws on a file whose shape cannot hold the hook (`hooks` or `PreToolUse`
20460
+ * that is not an object or a list), so a hand-edited file is never silently replaced.
20461
+ */
20462
+ function withDcgHook(settings) {
20463
+ if (!isObject$1(settings)) throw new Error("the settings file is not a JSON object");
20464
+ const hooks = settings.hooks ?? {};
20465
+ if (!isObject$1(hooks)) throw new Error("`hooks` in the settings file is not an object");
20466
+ const listed = hooks.PreToolUse ?? [];
20467
+ if (!Array.isArray(listed)) throw new Error("`hooks.PreToolUse` in the settings file is not a list");
20468
+ const preToolUse = listed;
20469
+ if (preToolUse.some((entry) => isObject$1(entry) && entry.matcher === "Bash" && Array.isArray(entry.hooks) && entry.hooks.some(runsDcg))) return settings;
20470
+ return {
20471
+ ...settings,
20472
+ hooks: {
20473
+ ...hooks,
20474
+ PreToolUse: [...preToolUse, {
20475
+ matcher: "Bash",
20476
+ hooks: [{
20477
+ type: "command",
20478
+ command: "dcg"
20479
+ }]
20480
+ }]
20481
+ }
20482
+ };
20483
+ }
20484
+ // src/commands/repo-files/generate-claude-files.ts
20485
+ const CLAUDE_SETTINGS_FILE = ".claude/settings.json";
20486
+ /**
20487
+ * `.claude/settings.json` with the `dcg` `PreToolUse` hook, for a repo whose config opts in with `agent: ["claude", { dcg: true }]`. The file
20488
+ * already on disk is merged, so a repo's own `permissions` and hooks are kept; the same bytes come out of `setup` and
20489
+ * `sync`, and `probe generated check` fails when the hook is missing. A repo that does not opt in gets nothing (no
20490
+ * step, no file), so the repos that never used it are unchanged. A file that is not valid JSON, or has a shape that
20491
+ * cannot hold the hook, is a failed step naming the file; it is never overwritten.
20492
+ */
20493
+ async function generateClaudeFiles(input) {
20494
+ if (input.loaded.resolved.agentOptions?.dcg !== true) return [];
20495
+ const step = `write ${CLAUDE_SETTINGS_FILE}`;
20496
+ const text = await readFile(join(input.repoRoot, CLAUDE_SETTINGS_FILE), "utf8").catch(() => void 0);
20497
+ let existing = {};
20498
+ if (text !== void 0) try {
20499
+ existing = JSON.parse(text);
20500
+ } catch {
20501
+ return [{
20502
+ kind: "error",
20503
+ step,
20504
+ syncStep: step,
20505
+ message: `${CLAUDE_SETTINGS_FILE} is not valid JSON`
20506
+ }];
20507
+ }
20508
+ try {
20509
+ const content = formatJson(withDcgHook(existing));
20510
+ return [{
20200
20511
  kind: "file",
20201
20512
  path: CLAUDE_SETTINGS_FILE,
20202
20513
  content,
@@ -20441,97 +20752,25 @@ function withAutoPreviewDeployPaths(tasks, gitRoot) {
20441
20752
  if (!paths) return entry;
20442
20753
  return {
20443
20754
  ...entry,
20444
- with: {
20445
- ...entry.with,
20446
- paths
20447
- }
20448
- };
20449
- });
20450
- }
20451
- // src/commands/thin-caller-file/thin-caller-file.ts
20452
- const { workflowHeader } = createHeader({
20453
- source: "cli/astromech/src/generators/github-action-thin-callers/github-action-thin-callers.ts",
20454
- tool: "holocron sync"
20455
- });
20456
- /**
20457
- * The text of a generated thin-caller workflow: the AUTO-GENERATED header, the `# Source package:` marker (see
20458
- * `resolvePkgRelPath`) and the workflow itself. Both `setup` and `sync` write their workflows through
20459
- * this, so the file is the same whichever command wrote it.
20460
- */
20461
- function thinCallerFile(pkgRelPath, content) {
20462
- return `${workflowHeader()}# Source package: ${pkgRelPath}\n\n${content}`;
20463
- }
20464
- // src/commands/workflow-source-marker/workflow-source-marker.ts
20465
- /** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
20466
- const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
20467
- /** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
20468
- function sanitizeForDisplay(value) {
20469
- return value.replace(/[\x00-\x1f\x7f]/g, "");
20470
- }
20471
- /**
20472
- * Repo-root-relative path of the PACKAGE a workflow-writing command run is
20473
- * scoped to — the directory holding the discovered `holocron.config.*`
20474
- * (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
20475
- * up to find the config from any subdirectory ("every command is usable
20476
- * from any subdirectory of a repo, not only its exact root"), so a `--cwd`
20477
- * one level too deep would otherwise stamp a different marker than a later
20478
- * run from the package's own root and misfire the collision check this
20479
- * feeds (holocron#1026).
20480
- *
20481
- * "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
20482
- * to forward slashes so the same package produces the same marker on
20483
- * Windows and POSIX. Throws if the result contains a line break — a path
20484
- * containing one could otherwise break out of the `# Source package: `
20485
- * comment line and inject arbitrary workflow YAML when the generated
20486
- * content is later written. Not reachable through this CLI's own flows
20487
- * (no code path writes a config file whose directory name contains a line
20488
- * break), but cheap to reject outright rather than trust the filesystem.
20489
- */
20490
- function resolvePkgRelPath(gitRoot, configFilepath) {
20491
- let root;
20492
- try {
20493
- root = realpathSync(gitRoot);
20494
- } catch {
20495
- root = gitRoot;
20496
- }
20497
- let configDir;
20498
- try {
20499
- configDir = realpathSync(dirname(configFilepath));
20500
- } catch {
20501
- configDir = dirname(configFilepath);
20502
- }
20503
- const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
20504
- if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
20505
- return pkgRelPath;
20506
- }
20507
- /**
20508
- * Two different monorepo packages opting into the same generic task name
20509
- * (e.g. both `apps/sentinel` and some future `apps/other` configuring
20510
- * `delivery.previewDeploy`) would otherwise overwrite each other's
20511
- * `.github/workflows/<task>.yml` on whichever package's write ran last —
20512
- * only one package's behavior would ever actually run in CI, with no
20513
- * signal that the other's was silently dropped (holocron#1026).
20514
- *
20515
- * Shared by both `holocron sync` (reads the file straight off local
20516
- * disk) and `holocron setup` (reads it through the loaded `Source`
20517
- * capability, which happens to be local disk too for the github plugin
20518
- * today, but the interface doesn't promise that for every provider —
20519
- * holocron#1068). The marker-parsing and error message are identical
20520
- * either way; `readExisting` is how the two callers differ.
20521
- *
20522
- * A file with no marker at all predates this check (or was written before
20523
- * #1026) and is never flagged — only a marker that's present AND disagrees
20524
- * with the current run's own package is a real collision. `readExisting`
20525
- * returning `null` means "nothing there," not "unreadable" — a caller
20526
- * whose underlying read can fail for reasons other than "doesn't exist"
20527
- * (e.g. local fs EISDIR) is expected to let that error propagate out of
20528
- * `readExisting` itself rather than mapping it to `null`.
20755
+ with: {
20756
+ ...entry.with,
20757
+ paths
20758
+ }
20759
+ };
20760
+ });
20761
+ }
20762
+ // src/commands/thin-caller-file/thin-caller-file.ts
20763
+ const { workflowHeader } = createHeader({
20764
+ source: "cli/astromech/src/generators/github-action-thin-callers/github-action-thin-callers.ts",
20765
+ tool: "holocron sync"
20766
+ });
20767
+ /**
20768
+ * The text of a generated thin-caller workflow: the AUTO-GENERATED header, the `# Source package:` marker (see
20769
+ * `resolvePkgRelPath`) and the workflow itself. Both `setup` and `sync` write their workflows through
20770
+ * this, so the file is the same whichever command wrote it.
20529
20771
  */
20530
- async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
20531
- const existing = await readExisting();
20532
- if (existing === null) return;
20533
- const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
20534
- 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.`);
20772
+ function thinCallerFile(pkgRelPath, content) {
20773
+ return `${workflowHeader()}# Source package: ${pkgRelPath}\n\n${content}`;
20535
20774
  }
20536
20775
  // src/commands/repo-files/generate-workflow-files.ts
20537
20776
  /**
@@ -21689,14 +21928,15 @@ async function runSetup(input) {
21689
21928
  if (loader.has("source")) {
21690
21929
  const source = loader.get("source");
21691
21930
  if (config.tasks && config.tasks.length > 0) print(style.step("workflows"));
21692
- for (const entry of await generateRepoFiles({
21931
+ const generatedEntries = await generateRepoFiles({
21693
21932
  loaded: input.loaded,
21694
21933
  repoRoot: input.context.repoRoot,
21695
21934
  hooks: input.hooks,
21696
21935
  ...statusContexts ? { statusContexts } : {},
21697
21936
  ...coverageFiles ? { coverageConfigFiles: coverageFiles } : {},
21698
21937
  logger
21699
- })) {
21938
+ });
21939
+ for (const entry of generatedEntries) {
21700
21940
  if (entry.kind === "skip") steps.push({
21701
21941
  capability: "source",
21702
21942
  step: entry.step,
@@ -21722,6 +21962,46 @@ async function runSetup(input) {
21722
21962
  print(formatStep(steps[steps.length - 1]));
21723
21963
  }
21724
21964
  }
21965
+ if ((config.tasks ?? []).length > 0) {
21966
+ const written = /* @__PURE__ */ new Set();
21967
+ let unaccounted = false;
21968
+ for (const entry of generatedEntries) if (entry.kind === "file" && entry.workflow) written.add(entry.workflow.filename);
21969
+ else if (entry.kind === "skip" && entry.step.startsWith("write workflow ")) unaccounted = true;
21970
+ if (unaccounted) {
21971
+ steps.push({
21972
+ capability: "source",
21973
+ step: "remove obsolete workflows",
21974
+ status: "skip",
21975
+ message: "a task has no template, so no workflow is removed"
21976
+ });
21977
+ print(formatStep(steps[steps.length - 1]));
21978
+ } else try {
21979
+ const workflows = /* @__PURE__ */ new Map();
21980
+ for (const name of await source.listWorkflowFiles()) {
21981
+ const text = await source.readWorkflowFile(name);
21982
+ if (text !== null) workflows.set(name, text);
21983
+ }
21984
+ const obsolete = findObsoleteWorkflows({
21985
+ workflows,
21986
+ written,
21987
+ pkgRelPath: setupPkgRelPath
21988
+ });
21989
+ for (const filename of obsolete) {
21990
+ steps.push(await runStep("source", `remove obsolete workflow ${filename}`, dryRun, async () => {
21991
+ await source.removeWorkflowFile(filename);
21992
+ }));
21993
+ print(formatStep(steps[steps.length - 1]));
21994
+ }
21995
+ } catch (err) {
21996
+ steps.push({
21997
+ capability: "source",
21998
+ step: "remove obsolete workflows",
21999
+ status: "fail",
22000
+ message: errorMessage(err)
22001
+ });
22002
+ print(formatStep(steps[steps.length - 1]));
22003
+ }
22004
+ }
21725
22005
  }
21726
22006
  if (loader.has("source")) {
21727
22007
  const source = loader.get("source");
@@ -22598,18 +22878,18 @@ const authListCommand = {
22598
22878
  * `holocron list projects` — the owner's boards, newest first, with their number, name and state. Read-only, so
22599
22879
  * `--dry-run` changes nothing here.
22600
22880
  */
22601
- const COMMAND$4 = "list projects";
22881
+ const COMMAND$3 = "list projects";
22602
22882
  async function runProjectList(input) {
22603
22883
  const print = input.print ?? ((line) => console.log(line));
22604
22884
  const rows = createProjectRows(print, input.logger ?? getLogger());
22605
- const { projects, options } = await openProjects(input, COMMAND$4);
22885
+ const { projects, options } = await openProjects(input, COMMAND$3);
22606
22886
  print(style.header(`Holocron list projects — ${options.owner}`));
22607
22887
  print("");
22608
22888
  try {
22609
22889
  const boards = (await projects.list(options.owner)).toSorted((a, b) => (b.number ?? 0) - (a.number ?? 0));
22610
22890
  if (boards.length === 0) {
22611
22891
  rows.skip("no boards", options.owner);
22612
- return rows.finish(COMMAND$4);
22892
+ return rows.finish(COMMAND$3);
22613
22893
  }
22614
22894
  const width = Math.max(1, ...boards.map((b) => String(b.number ?? "").length));
22615
22895
  print(style.dim(` ${"#".padEnd(width)} ${"Name".padEnd(32)} State`));
@@ -22619,7 +22899,7 @@ async function runProjectList(input) {
22619
22899
  } catch (err) {
22620
22900
  rows.fail("list", errorMessage(err));
22621
22901
  }
22622
- return rows.finish(COMMAND$4);
22902
+ return rows.finish(COMMAND$3);
22623
22903
  }
22624
22904
  // src/commands/project/project-list/project-list.command.ts
22625
22905
  const projectListCommand = {
@@ -23540,7 +23820,7 @@ const authSetCommand = {
23540
23820
  * file is checked (git ignores it, it is not there already) before the browser opens. Nothing but names and paths is
23541
23821
  * ever printed.
23542
23822
  */
23543
- const COMMAND$3 = "new github-app";
23823
+ const COMMAND$2 = "new github-app";
23544
23824
  const DEFAULT_WEBHOOK_SECRET_VAR = "SENTINEL_WEBHOOK_SECRET";
23545
23825
  async function runGithubAppCreate(input) {
23546
23826
  const print = input.print ?? ((line) => console.error(line));
@@ -23550,7 +23830,7 @@ async function runGithubAppCreate(input) {
23550
23830
  logger.warn({
23551
23831
  status: "fail",
23552
23832
  reason
23553
- }, COMMAND$3);
23833
+ }, COMMAND$2);
23554
23834
  return { status: "fail" };
23555
23835
  };
23556
23836
  if ((input.platform ?? process.platform) === "win32") return refuse("windows", "cannot make the credentials file private on Windows: its mode bits are not enforced");
@@ -23611,7 +23891,7 @@ async function runGithubAppCreate(input) {
23611
23891
  status: "fail",
23612
23892
  reason: "write",
23613
23893
  slug: app.slug
23614
- }, COMMAND$3);
23894
+ }, COMMAND$2);
23615
23895
  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);
23616
23896
  return {
23617
23897
  status: "fail",
@@ -23636,7 +23916,7 @@ async function runGithubAppCreate(input) {
23636
23916
  logger.info({
23637
23917
  status,
23638
23918
  slug: app.slug
23639
- }, COMMAND$3);
23919
+ }, COMMAND$2);
23640
23920
  return {
23641
23921
  status,
23642
23922
  slug: app.slug,
@@ -25969,18 +26249,18 @@ const pluginCreateCommand = {
25969
26249
  * templates directory). Idempotent on the title: an open board that has it is not made again; a terminal is asked
25970
26250
  * whether to open the existing one, `--yes` prints its address, and anything else is a {@link NonInteractiveError}.
25971
26251
  */
25972
- const COMMAND$2 = "new project";
26252
+ const COMMAND$1 = "new project";
25973
26253
  async function runProjectCreate(input) {
25974
26254
  const print = input.print ?? ((line) => console.log(line));
25975
26255
  const rows = createProjectRows(print, input.logger ?? getLogger());
25976
26256
  const prompt = input.prompt ?? terminalPrompt();
25977
26257
  const dryRun = input.context.dryRun ?? false;
25978
26258
  const done = (extra = {}) => ({
25979
- ...rows.finish(COMMAND$2),
26259
+ ...rows.finish(COMMAND$1),
25980
26260
  created: false,
25981
26261
  ...extra
25982
26262
  });
25983
- const { projects, options } = await openProjects(input, COMMAND$2);
26263
+ const { projects, options } = await openProjects(input, COMMAND$1);
25984
26264
  const loaded = await loadTemplates(options.templatesDir, input.io ?? createFsTemplatesIo(input.context.repoRoot));
25985
26265
  print(style.header(`Holocron new project — ${options.owner}${dryRun ? " (dry-run)" : ""}`));
25986
26266
  print("");
@@ -29306,198 +29586,6 @@ function specsCheckProbe(io) {
29306
29586
  function specsProbes(io) {
29307
29587
  return { check: specsCheckProbe(io) };
29308
29588
  }
29309
- // src/commands/probe/tasks/script-keys.ts
29310
- /**
29311
- * The keys of the object `field` (`scripts` in a `package.json`, `tasks` in a `turbo.json`) with their lines; none when
29312
- * the text is not JSON or has no such object.
29313
- */
29314
- function scriptKeys(text, field) {
29315
- let value;
29316
- try {
29317
- value = JSON.parse(text)[field];
29318
- } catch {
29319
- return [];
29320
- }
29321
- if (typeof value !== "object" || value === null) return [];
29322
- const lines = text.split("\n");
29323
- const start = lines.findIndex((l) => l.includes(`"${field}"`));
29324
- return Object.keys(value).map((key) => ({
29325
- key,
29326
- line: lines.findIndex((l, i) => i > start && l.trimStart().startsWith(`"${key}"`)) + 1
29327
- }));
29328
- }
29329
- // src/commands/probe/tasks/find-reserved.ts
29330
- /** What to use instead of a reserved script name: `publish` has a task of its own, the rest are never tasks. */
29331
- function instead(name) {
29332
- return name === "publish" ? "release (`publish` is reserved by npm and pnpm)" : "(reserved by npm and pnpm, never a task)";
29333
- }
29334
- /**
29335
- * Every `package.json` script named like an npm/pnpm lifecycle word (`RESERVED_SCRIPT_NAMES`): `pnpm publish` would run
29336
- * it after publishing. The root `prepare` (husky) is the one allowed.
29337
- */
29338
- function findReserved(file) {
29339
- if (!/(^|\/)package\.json$/.test(file.path)) return [];
29340
- return scriptKeys(file.text, "scripts").filter(({ key }) => RESERVED_SCRIPT_NAMES.has(key) && !(file.path === "package.json" && key === "prepare")).map(({ key, line }) => ({
29341
- file: file.path,
29342
- line,
29343
- old: key,
29344
- replacement: instead(key)
29345
- }));
29346
- }
29347
- // src/commands/probe/tasks/find-leftovers.ts
29348
- /** The commands that take a task name as their next word: `holocron run`, `turbo run`, `pnpm run`, `pnpm`, ... */
29349
- const COMMAND$1 = String.raw`(?:holocron run|turbo run|pnpm run|npm run|pnpm|yarn)\s+`;
29350
- /** A regex alternation of `names`, escaped; matches nothing for an empty list. */
29351
- function alternation(names) {
29352
- return names.length === 0 ? "(?!)" : names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
29353
- }
29354
- /** The field of a manifest whose keys are tasks or scripts: `scripts` in a `package.json`, `tasks` in a `turbo.json`. */
29355
- function taskField(path) {
29356
- return /(^|\/)package\.json$/.test(path) ? "scripts" : /(^|\/)turbo\.json$/.test(path) ? "tasks" : void 0;
29357
- }
29358
- /**
29359
- * Every use of an old task name in `files`, with its file, line and replacement.
29360
- *
29361
- * - A dotted name (`delivery.build`) matches as a whole token: found in `turbo run delivery.build`, not in
29362
- * `delivery.buildX`. Followed by `.yml`/`.yaml` it is a workflow file name and is left out unless `options.files`.
29363
- * - A bare name (`review`, `stale`: the keys of `names` without a dot) is an ordinary word, so it is found only where it
29364
- * is used as a task: after `holocron run`, `turbo run`, `pnpm` or `pnpm run`, as a `package.json` script or as a
29365
- * `turbo.json` task.
29366
- * - A `package.json` script named like an npm/pnpm lifecycle word is reported too (see {@link findReserved}).
29367
- * - A line, or the line below one, that carries the {@link ALLOW_MARKER} is skipped.
29368
- *
29369
- * Files come back in the order given, lines top to bottom.
29370
- */
29371
- function findLeftovers(files, names, options = {}) {
29372
- const dotted = Object.keys(names).filter((n) => n.includes("."));
29373
- const bare = Object.keys(names).filter((n) => !n.includes("."));
29374
- const tail = options.files ? String.raw`(?![\w-])` : String.raw`(?![\w-]|\.ya?ml\b)`;
29375
- const dottedPattern = new RegExp(`(?<![\\w.-])(${alternation(dotted)})${tail}`, "g");
29376
- const barePattern = new RegExp(`(?<![\\w.-])${COMMAND$1}(${alternation(bare)})(?![\\w:-]|\\.\\w)`, "g");
29377
- return files.flatMap((file) => {
29378
- const lines = file.text.split("\n");
29379
- const field = taskField(file.path);
29380
- const inText = lines.flatMap((text, i) => [...text.matchAll(dottedPattern), ...text.matchAll(barePattern)].map((m) => ({
29381
- file: file.path,
29382
- line: i + 1,
29383
- old: m[1],
29384
- replacement: names[m[1]]
29385
- })));
29386
- const asKey = (field === void 0 ? [] : scriptKeys(file.text, field)).filter(({ key }) => bare.includes(key)).map(({ key, line }) => ({
29387
- file: file.path,
29388
- line,
29389
- old: key,
29390
- replacement: names[key]
29391
- }));
29392
- const seen = /* @__PURE__ */ new Set();
29393
- return [
29394
- ...inText,
29395
- ...asKey,
29396
- ...findReserved(file)
29397
- ].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"));
29398
- });
29399
- }
29400
- // src/commands/probe/tasks/is-generated.ts
29401
- /** Whether a file carries the generated-file header in its first lines; drift in those is `probe generated check`'s to report. */
29402
- function isGenerated(text) {
29403
- return text.split("\n", 3).some((line) => line.includes("AUTO-GENERATED"));
29404
- }
29405
- // src/commands/probe/tasks/is-scanned.ts
29406
- /** Files that describe the old names on purpose: specs, ADRs, the changelog, tests, and this probe's own folder. */
29407
- const SKIPPED = [
29408
- /(^|\/)CHANGELOG\.md$/,
29409
- /^\.notes\//,
29410
- /^docs\/wiki\//,
29411
- /\.test\.tsx?$/,
29412
- /^cli\/cli\/src\/commands\/probe\/tasks\//
29413
- ];
29414
- /** The kinds of file the probe reads: workflows, scripts, docs, configs, hooks and manifests. */
29415
- const SCANNED = [
29416
- /^\.github\/(workflows|actions)\/.+\.ya?ml$/,
29417
- /^\.husky\//,
29418
- /^scripts\//,
29419
- /(^|\/)(package|turbo)\.json$/,
29420
- /(^|\/)(holocron|astromech)\.config\.[cm]?[jt]s$/,
29421
- /(^|\/)\.lintstagedrc/,
29422
- /\.mdx?$/
29423
- ];
29424
- /** Whether `path` (repo-relative) is a hand-written kind of place to scan for old task names. */
29425
- function isScanned(path) {
29426
- return SCANNED.some((p) => p.test(path)) && !SKIPPED.some((p) => p.test(path));
29427
- }
29428
- // src/commands/probe/tasks/legacy-replacements.ts
29429
- /**
29430
- * Each old task name astromech's `LEGACY_NAMES` still accepts, with the text the `tasks names` probe prints as its
29431
- * replacement: the flat ids it became, in run order. A successor that adds args (`format --check`, the read-only
29432
- * prettier half of `sourceQuality.formatting`) is named last, in parentheses: `lint:editorconfig, lint:markdown (format
29433
- * for prettier)`. A name that is a suite now (`validate`, once the interim id of `platform.repoValidation`) is left out:
29434
- * `holocron run validate` is the suite, not a leftover.
29435
- */
29436
- function legacyReplacements() {
29437
- return Object.fromEntries(Object.entries(LEGACY_NAMES).filter(([old]) => !SUITES.includes(old)).map(([old, targets]) => {
29438
- const own = targets.filter((t) => t.passthrough === void 0).map((t) => t.id);
29439
- const checked = targets.filter((t) => t.passthrough !== void 0).map((t) => `${t.id} for prettier`);
29440
- return [old, checked.length === 0 ? own.join(", ") : `${own.join(", ")} (${checked.join(", ")})`];
29441
- }));
29442
- }
29443
- // src/commands/probe/tasks/real-tasks-io.ts
29444
- /** The `tasks names` probe's inputs from the tracked files under `repoRoot`. */
29445
- function realTasksIo(repoRoot) {
29446
- /* v8 ignore start -- reads git and the real filesystem; the probe is tested with an injected io */
29447
- return { files: () => execFileSync("git", ["ls-files", "-z"], {
29448
- cwd: repoRoot,
29449
- encoding: "utf8",
29450
- maxBuffer: 67108864
29451
- }).split("\0").filter((path) => path !== "" && isScanned(path)).flatMap((path) => {
29452
- try {
29453
- const text = readFileSync(join(repoRoot, path), "utf8");
29454
- return isGenerated(text) ? [] : [{
29455
- path,
29456
- text
29457
- }];
29458
- } catch {
29459
- return [];
29460
- }
29461
- }) };
29462
- /* v8 ignore stop */
29463
- }
29464
- // src/commands/probe/tasks/tasks-probes.ts
29465
- /** The group of probes that check the repo's task vocabulary. */
29466
- const TASKS_PROVIDER = "tasks";
29467
- /**
29468
- * `tasks names`: finds the hand-written places that still use an old task name from the flat-vocabulary map
29469
- * (SPEC-0064, astromech's `LEGACY_NAMES`): a dotted one (`delivery.build`, `verification.unitTests`), a bare one used as a
29470
- * task (`holocron run review`, a `review` script) or a `package.json` script with a reserved npm/pnpm name (`publish`).
29471
- * It scans workflows, scripts, docs, `turbo.json`, `package.json`, the configs' `tasks:` and the hooks, and reports each
29472
- * with file, line and the id to use instead. Each is a failure (exit code 1); `--warn` reports them as `info` rows
29473
- * instead. A dotted name that is part of a workflow file name (`delivery.build.yml`) is skipped until the files are
29474
- * renamed; `--files` lists those too. An intentional mention carries the `holocron-allow-old-name` marker on its line or the line above.
29475
- * Files `sync` generates are left to `generated check`; specs, ADRs and the changelog name the old tasks on purpose.
29476
- */
29477
- function tasksProbes(io, names = legacyReplacements()) {
29478
- return { names: {
29479
- summary: "Report each use of an old task name in hand-written files; fails unless --warn; --files adds file names.",
29480
- writes: false,
29481
- async run(ctx) {
29482
- const status = ctx.args?.includes("--warn") ? "info" : "fail";
29483
- ctx.say({
29484
- status: "heading",
29485
- label: "Old task names"
29486
- });
29487
- const found = findLeftovers(io.files(), names, { files: ctx.args?.includes("--files") === true });
29488
- for (const f of found) ctx.say({
29489
- status,
29490
- label: `${f.file}:${f.line}`,
29491
- detail: `${f.old} -> ${f.replacement}`
29492
- });
29493
- ctx.say({
29494
- status: found.length === 0 ? "ok" : status,
29495
- label: "old names",
29496
- detail: `${found.length} use(s) of ${Object.keys(names).length} old name(s)`
29497
- });
29498
- }
29499
- } };
29500
- }
29501
29589
  // src/commands/probe/probe.ts
29502
29590
  /**
29503
29591
  * `holocron probe [<provider> [<probe>]]`. With nothing, lists what can be probed; with a provider, lists its probes;
@@ -33896,30 +33984,6 @@ const syncToolingCommand = {
33896
33984
  })).status === "fail") process.exitCode = 1;
33897
33985
  }
33898
33986
  };
33899
- // src/commands/obsolete-workflows/find-obsolete-workflows.ts
33900
- /** The lines at the head of a generated workflow that hold the header and the `# Source package:` marker. */
33901
- const HEADER_LINES = 6;
33902
- /**
33903
- * The workflow files in `.github/workflows` that an earlier `sync` generated and that this run no longer writes, because
33904
- * their task left the config or a preset (#2338). Sorted by name.
33905
- *
33906
- * It names a file only when all of these hold, so a file nobody generated is never removed:
33907
- * - the generator's own `AUTO-GENERATED` header is at its head;
33908
- * - it is not marked `# HAND-MAINTAINED`;
33909
- * - its `# Source package:` line is this run's package, so a run for `apps/sentinel` leaves the root's files alone, and a
33910
- * file with no marker (written before the marker existed) is left for `probe generated check` to report;
33911
- * - this run does not write it.
33912
- */
33913
- function findObsoleteWorkflows({ workflows, written, pkgRelPath }) {
33914
- const obsolete = [];
33915
- for (const [name, text] of workflows) {
33916
- if (written.has(name) || text.startsWith("# HAND-MAINTAINED") || !isGenerated(text)) continue;
33917
- const head = text.split("\n", HEADER_LINES).join("\n");
33918
- if (SOURCE_PACKAGE_MARKER.exec(head)?.[1] !== pkgRelPath) continue;
33919
- obsolete.push(name);
33920
- }
33921
- return obsolete.sort();
33922
- }
33923
33987
  // src/presets/constants.ts
33924
33988
  /**
33925
33989
  * 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