@theholocron/cli 5.0.0-alpha.260 → 5.0.0-alpha.262

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
@@ -12,7 +12,7 @@ import chalk from "chalk";
12
12
  import search from "@inquirer/search";
13
13
  import { execFileSync, spawn, spawnSync } from "node:child_process";
14
14
  import ora from "ora";
15
- import { checkbox, confirm, input, password, select } from "@inquirer/prompts";
15
+ import { Separator, checkbox, confirm, input, password, select } from "@inquirer/prompts";
16
16
  import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
17
17
  import { homedir, hostname, tmpdir, userInfo } from "node:os";
18
18
  import { PostHogSink } from "@theholocron/observability/analytics";
@@ -221,6 +221,7 @@ const COMMAND_CONTEXTS = {
221
221
  "monitoring resolve-checks": "workspace",
222
222
  "monitoring run-resolved": "global",
223
223
  "repo sync": "workspace",
224
+ "repo cleanup branches": "workspace",
224
225
  "sync github": "workspace"
225
226
  };
226
227
  /**
@@ -1683,6 +1684,26 @@ const COMMAND_REGISTRY = [
1683
1684
  positionals: [],
1684
1685
  supportsDryRun: true
1685
1686
  },
1687
+ {
1688
+ name: "repo cleanup branches",
1689
+ description: "List the branches whose pull request is merged and delete the ones you pick",
1690
+ positionals: [],
1691
+ options: [{
1692
+ key: "local",
1693
+ flag: "--local",
1694
+ type: "confirm",
1695
+ default: false,
1696
+ message: "Only the branches in this checkout?"
1697
+ }, {
1698
+ key: "remote",
1699
+ flag: "--remote",
1700
+ type: "confirm",
1701
+ default: false,
1702
+ message: "Only the branches on the remote?"
1703
+ }],
1704
+ skipOptions: ["yes", "repo"],
1705
+ supportsDryRun: false
1706
+ },
1686
1707
  {
1687
1708
  name: "run ci",
1688
1709
  description: "Run the merge-gating checks locally, in CI order — 'will CI pass?'",
@@ -10791,6 +10812,456 @@ function docsCoverageProbes(repoRoot, typedoc = runTypedoc(repoRoot), diff = rea
10791
10812
  }
10792
10813
  };
10793
10814
  }
10815
+ // src/commands/probe/generated/constants.ts
10816
+ /**
10817
+ * Workflow files that no task generates and that are not marked `# HAND-MAINTAINED`, so the check would take them for
10818
+ * stale generated files. Each is intentional.
10819
+ */
10820
+ const UNMANAGED_WORKFLOWS = { "platform.syncTemplates.yml": "its task is not in the config yet, on purpose (see astromech.config.ts)" };
10821
+ // src/commands/probe/generated/check-generated.ts
10822
+ const WORKFLOWS_DIR = ".github/workflows/";
10823
+ /** Where two texts first differ: the line number and both lines, cut to fit a terminal. */
10824
+ function firstDifference(committed, generated) {
10825
+ const a = committed.split("\n");
10826
+ const b = generated.split("\n");
10827
+ const line = a.findIndex((text, i) => text !== b[i]);
10828
+ const at = line === -1 ? Math.min(a.length, b.length) : line;
10829
+ const cut = (text) => text === void 0 ? "(end of file)" : JSON.stringify(text.slice(0, 80));
10830
+ return `first difference at line ${at + 1}: committed ${cut(a[at])}, generated ${cut(b[at])}`;
10831
+ }
10832
+ /** The package whose config generated a workflow, from its `# Source package:` marker (`.` is the root). */
10833
+ function sourcePackage(text) {
10834
+ return /^# Source package: (.+)$/m.exec(text)?.[1] ?? null;
10835
+ }
10836
+ /**
10837
+ * Problems with the generated files, as human-readable lines: a file that differs from the committed copy or is
10838
+ * missing, a file whose second generation differs from the first, and a workflow that nothing generates and that is not
10839
+ * marked as someone else's (hand-maintained, from another package's config, or on the unmanaged list).
10840
+ */
10841
+ function checkGenerated({ files, again, read, workflows }) {
10842
+ const problems = [];
10843
+ const second = new Map(again.map((f) => [f.path, f.content]));
10844
+ for (const file of files) {
10845
+ const committed = read(file.path);
10846
+ if (committed === null) problems.push(`${file.path}: missing; run \`holocron repo setup\` or \`holocron repo sync\` and commit it`);
10847
+ else if (committed !== file.content) problems.push(`${file.path}: differs from what holocron generates (${firstDifference(committed, file.content)}); run \`holocron repo setup\` or \`holocron repo sync\` and commit the result`);
10848
+ if (second.get(file.path) !== file.content) problems.push(`${file.path}: generating it twice gives different content`);
10849
+ }
10850
+ const generated = new Set(files.map((f) => f.path));
10851
+ for (const [name, text] of workflows) {
10852
+ const path = `${WORKFLOWS_DIR}${name}`;
10853
+ if (generated.has(path) || name in UNMANAGED_WORKFLOWS || text.startsWith("# HAND-MAINTAINED")) continue;
10854
+ const source = sourcePackage(text);
10855
+ if (text.startsWith("# AUTO-GENERATED") && source !== null && source !== ".") continue;
10856
+ problems.push(`${path}: no task generates it and it is not marked "# HAND-MAINTAINED"; remove it, or mark it hand-maintained`);
10857
+ }
10858
+ return problems;
10859
+ }
10860
+ // src/templates/dco.yml
10861
+ var dco_default = "allowRemediationCommits:\n individual: true\n";
10862
+ // src/commands/setup/own-catalog-packages/own-catalog-packages.ts
10863
+ /**
10864
+ * The packages of this workspace that a pnpm catalog also lists: the minimum versions a plugin accepts
10865
+ * as a peer, say. Dependabot reads every catalog entry as an ordinary dependency and would raise it to the
10866
+ * latest release, but such an entry is a compatibility floor that is raised by hand, and the package itself
10867
+ * is linked with `workspace:`. A package from outside the workspace in a catalog is left out, so it keeps
10868
+ * getting updates. Sorted; `[]` when there is no `pnpm-workspace.yaml`.
10869
+ */
10870
+ function ownCatalogPackages(repoRoot) {
10871
+ let yaml;
10872
+ try {
10873
+ yaml = readFileSync(join(repoRoot, "pnpm-workspace.yaml"), "utf8");
10874
+ } catch {
10875
+ return [];
10876
+ }
10877
+ const listed = new Set(Object.values(parseCatalogs(yaml)).flatMap((catalog) => Object.keys(catalog)));
10878
+ const own = discoverWorkspacePackages(repoRoot).flatMap(({ name }) => name && listed.has(name) ? [name] : []);
10879
+ return [...new Set(own)].sort();
10880
+ }
10881
+ // src/commands/repo-files/hooks-enabled.ts
10882
+ /** Whether git hooks are installed: `--hooks` / `--no-hooks` wins, then `config.hooks`, then on for `protection: "strict"`. */
10883
+ function hooksEnabled(input) {
10884
+ const config = input.loaded.resolved;
10885
+ if (input.hooks !== void 0) return input.hooks;
10886
+ if (typeof config.hooks === "boolean") return config.hooks;
10887
+ if (typeof config.hooks === "object") return config.hooks.prePush !== false;
10888
+ return config.repo?.protection === "strict";
10889
+ }
10890
+ // src/commands/repo-files/generate-config-files.ts
10891
+ const { workflowHeader: workflowHeader$1 } = createHeader({
10892
+ source: "cli/cli/src/commands/repo-files/generate-config-files.ts",
10893
+ tool: "holocron repo setup"
10894
+ });
10895
+ function file(path, content, note) {
10896
+ const step = `write ${path}`;
10897
+ return {
10898
+ kind: "file",
10899
+ path,
10900
+ content,
10901
+ step,
10902
+ syncStep: step,
10903
+ ...note === void 0 ? {} : { note }
10904
+ };
10905
+ }
10906
+ /**
10907
+ * The config files that are not workflows: the labeler, Dependabot and DCO configs, the lint and editor configs, the
10908
+ * git hooks and `codecov.yml`, in the order `repo setup` writes them. `codecov.yml` is merged into the copy already on
10909
+ * disk, so the file is read here.
10910
+ */
10911
+ async function generateConfigFiles(input) {
10912
+ const config = input.loaded.resolved;
10913
+ const taskNames = (config.tasks ?? []).map((e) => typeof e === "string" ? e : e.name);
10914
+ const entries = [];
10915
+ if (taskNames.includes("bookkeeping")) entries.push(file(".github/labeler.yml", createLabeler()));
10916
+ if (config.repo?.protection !== "none") entries.push(file(".github/dependabot.yml", createDependabot({ ignore: ownCatalogPackages(input.repoRoot) })), file(".github/dco.yml", `${workflowHeader$1()}${dco_default}`));
10917
+ entries.push(file(".alexrc.json", createAlexrc()), file(".alexignore", createAlexignore()), file(".yamllint.yml", createYamllint()), file(".yamlignore", createYamlignore()), file(".editorconfig", createEditorconfig()), file(".editorconfig-checker.json", createEditorconfigChecker()), file("devmoji.config.cjs", createDevmoji()), file(".husky/prepare-commit-msg", createPrepareCommitMsg()), file(".husky/commit-msg", createCommitMsg(config.holocronScript)));
10918
+ if (hooksEnabled(input)) entries.push(file(".husky/pre-push", createPrePush(config.holocronScript), "runs `holocron run ci` before push — bypass with `git push --no-verify`"), file(".husky/pre-commit", createPreCommit(), "runs GitLeaks (staged-only) + lint-staged before commit"));
10919
+ else for (const hook of [".husky/pre-push", ".husky/pre-commit"]) entries.push({
10920
+ kind: "skip",
10921
+ step: `write ${hook}`,
10922
+ syncStep: `write ${hook}`,
10923
+ message: "git hooks disabled"
10924
+ });
10925
+ const existing = await readFile(join(input.repoRoot, "codecov.yml"), "utf8").catch(() => null);
10926
+ if (!taskNames.includes("verification.unitTests") && existing == null) entries.push({
10927
+ kind: "skip",
10928
+ step: "write codecov.yml",
10929
+ syncStep: "write codecov.yml",
10930
+ message: "no test workflow configured"
10931
+ });
10932
+ else try {
10933
+ const content = createAstromech({
10934
+ cwd: input.repoRoot,
10935
+ logger: input.logger ?? getLogger()
10936
+ }).codecovConfig(existing);
10937
+ const packageCount = readWorkspacePackages(input.repoRoot).length;
10938
+ entries.push(file("codecov.yml", content, packageCount > 0 ? `${packageCount} components` : "no components"));
10939
+ } catch (error) {
10940
+ entries.push({
10941
+ kind: "error",
10942
+ step: "write codecov.yml",
10943
+ syncStep: "write codecov.yml",
10944
+ message: errorMessage(error)
10945
+ });
10946
+ }
10947
+ return entries;
10948
+ }
10949
+ // src/commands/repo-files/generate-turbo-files.ts
10950
+ /**
10951
+ * `turbo.json`, and the two edits that go with it: `turbo.json` alone is inert unless the root is a workspace member
10952
+ * (#692) and turbo is a dependency, so `pnpm-workspace.yaml` and the root `package.json` are fixed in the same step that
10953
+ * introduces the risk. An edit is an entry only when it changes the file.
10954
+ */
10955
+ async function generateTurboFiles(input) {
10956
+ const astromech = createAstromech({
10957
+ cwd: input.repoRoot,
10958
+ config: { tasks: input.loaded.resolved.tasks },
10959
+ logger: input.logger ?? getLogger()
10960
+ });
10961
+ const content = astromech.turboConfig();
10962
+ if (content === null) return [{
10963
+ kind: "skip",
10964
+ step: "write turbo.json",
10965
+ syncStep: "sync turbo.json",
10966
+ message: "no fan-out-eligible tasks configured"
10967
+ }];
10968
+ const entries = [{
10969
+ kind: "file",
10970
+ path: "turbo.json",
10971
+ content,
10972
+ step: "write turbo.json",
10973
+ syncStep: "sync turbo.json"
10974
+ }];
10975
+ const rootPkgRaw = await readFile(join(input.repoRoot, "package.json"), "utf8").catch(() => null);
10976
+ const rootPkg = rootPkgRaw ? JSON.parse(rootPkgRaw) : null;
10977
+ const workspaceYaml = await readFile(join(input.repoRoot, "pnpm-workspace.yaml"), "utf8").catch(() => "");
10978
+ const workspaceFix = astromech.ensureRootWorkspaceMember(workspaceYaml, rootPkg?.scripts ?? {});
10979
+ if (workspaceFix.changed) {
10980
+ const step = "fix pnpm-workspace.yaml (root workspace member, #692)";
10981
+ entries.push({
10982
+ kind: "file",
10983
+ path: "pnpm-workspace.yaml",
10984
+ content: workspaceFix.content,
10985
+ step,
10986
+ syncStep: step
10987
+ });
10988
+ }
10989
+ if (rootPkgRaw) {
10990
+ const depFix = astromech.ensureTurboDependency(rootPkgRaw, workspaceFix.content);
10991
+ if (depFix.changed) entries.push({
10992
+ kind: "file",
10993
+ path: "package.json",
10994
+ content: depFix.content,
10995
+ step: "add turbo devDependency",
10996
+ syncStep: "add turbo devDependency"
10997
+ });
10998
+ }
10999
+ return entries;
11000
+ }
11001
+ // src/commands/preview-deploy-paths/preview-deploy-paths.ts
11002
+ /** `realpathSync`, falling back to the unresolved input on a path that doesn't exist (e.g. a test fixture). */
11003
+ function tryRealpath(path) {
11004
+ try {
11005
+ return realpathSync(path);
11006
+ } catch {
11007
+ return path;
11008
+ }
11009
+ }
11010
+ /**
11011
+ * `delivery.previewDeploy`'s package directory plus its `workspace:*`
11012
+ * dependencies' directories (holocron#1023) — the reusable workflow's
11013
+ * `paths` input, so a PR touching only an unrelated package in the
11014
+ * monorepo skips the actual deploy work instead of spinning up a Vercel
11015
+ * preview for every PR regardless of relevance. `undefined` for a
11016
+ * root-level consumer (`cwd: "."` or omitted) -- every PR already IS a PR
11017
+ * to that package, no filter needed -- or when `cwd` doesn't resolve to
11018
+ * any known workspace package (soft-skip; the caller leaves `paths`
11019
+ * unset rather than guessing).
11020
+ */
11021
+ function resolvePreviewDeployPaths(gitRoot, cwdValue) {
11022
+ if (!cwdValue || cwdValue === ".") return void 0;
11023
+ const all = workspacePackages(gitRoot, {
11024
+ readJson: defaultReadJson,
11025
+ listDirs: defaultListDirs
11026
+ });
11027
+ const target = tryRealpath(resolve(gitRoot, cwdValue));
11028
+ const pkg = all.find((candidate) => tryRealpath(candidate.dir) === target);
11029
+ if (!pkg) return void 0;
11030
+ return defaultPaths(gitRoot, pkg, all);
11031
+ }
11032
+ /**
11033
+ * Returns `tasks` unchanged unless it has a `delivery.previewDeploy` entry
11034
+ * with a non-root `with.cwd` and no `with.paths` of its own -- in which
11035
+ * case that one entry gets an auto-computed `paths` (see
11036
+ * {@link resolvePreviewDeployPaths}), added without mutating the input.
11037
+ * An explicit `with.paths` from the repo's own config always wins; this
11038
+ * only fills in what the repo didn't already specify.
11039
+ */
11040
+ function withAutoPreviewDeployPaths(tasks, gitRoot) {
11041
+ return tasks.map((entry) => {
11042
+ if (typeof entry === "string" || entry.name !== "delivery.previewDeploy") return entry;
11043
+ const cwdValue = entry.with?.["cwd"];
11044
+ if (typeof cwdValue !== "string" || entry.with?.["paths"] !== void 0) return entry;
11045
+ const paths = resolvePreviewDeployPaths(gitRoot, cwdValue);
11046
+ if (!paths) return entry;
11047
+ return {
11048
+ ...entry,
11049
+ with: {
11050
+ ...entry.with,
11051
+ paths
11052
+ }
11053
+ };
11054
+ });
11055
+ }
11056
+ // src/commands/thin-caller-file/thin-caller-file.ts
11057
+ const { workflowHeader } = createHeader({
11058
+ source: "cli/astromech/src/thin-callers.ts",
11059
+ tool: "holocron repo sync"
11060
+ });
11061
+ /**
11062
+ * The text of a generated thin-caller workflow: the AUTO-GENERATED header, the `# Source package:` marker (see
11063
+ * `resolvePkgRelPath`) and the workflow itself. Both `repo setup` and `repo sync` write their workflows through
11064
+ * this, so the file is the same whichever command wrote it.
11065
+ */
11066
+ function thinCallerFile(pkgRelPath, content) {
11067
+ return `${workflowHeader()}# Source package: ${pkgRelPath}\n\n${content}`;
11068
+ }
11069
+ // src/commands/workflow-source-marker/workflow-source-marker.ts
11070
+ /** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
11071
+ const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
11072
+ /** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
11073
+ function sanitizeForDisplay(value) {
11074
+ return value.replace(/[\x00-\x1f\x7f]/g, "");
11075
+ }
11076
+ /**
11077
+ * Repo-root-relative path of the PACKAGE a workflow-writing command run is
11078
+ * scoped to — the directory holding the discovered `holocron.config.*`
11079
+ * (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
11080
+ * up to find the config from any subdirectory ("every command is usable
11081
+ * from any subdirectory of a repo, not only its exact root"), so a `--cwd`
11082
+ * one level too deep would otherwise stamp a different marker than a later
11083
+ * run from the package's own root and misfire the collision check this
11084
+ * feeds (holocron#1026).
11085
+ *
11086
+ * "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
11087
+ * to forward slashes so the same package produces the same marker on
11088
+ * Windows and POSIX. Throws if the result contains a line break — a path
11089
+ * containing one could otherwise break out of the `# Source package: `
11090
+ * comment line and inject arbitrary workflow YAML when the generated
11091
+ * content is later written. Not reachable through this CLI's own flows
11092
+ * (no code path writes a config file whose directory name contains a line
11093
+ * break), but cheap to reject outright rather than trust the filesystem.
11094
+ */
11095
+ function resolvePkgRelPath(gitRoot, configFilepath) {
11096
+ let root;
11097
+ try {
11098
+ root = realpathSync(gitRoot);
11099
+ } catch {
11100
+ root = gitRoot;
11101
+ }
11102
+ let configDir;
11103
+ try {
11104
+ configDir = realpathSync(dirname(configFilepath));
11105
+ } catch {
11106
+ configDir = dirname(configFilepath);
11107
+ }
11108
+ const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
11109
+ if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
11110
+ return pkgRelPath;
11111
+ }
11112
+ /**
11113
+ * Two different monorepo packages opting into the same generic task name
11114
+ * (e.g. both `apps/sentinel` and some future `apps/other` configuring
11115
+ * `delivery.previewDeploy`) would otherwise overwrite each other's
11116
+ * `.github/workflows/<task>.yml` on whichever package's write ran last —
11117
+ * only one package's behavior would ever actually run in CI, with no
11118
+ * signal that the other's was silently dropped (holocron#1026).
11119
+ *
11120
+ * Shared by both `holocron repo sync` (reads the file straight off local
11121
+ * disk) and `holocron repo setup` (reads it through the loaded `Source`
11122
+ * capability, which happens to be local disk too for the github plugin
11123
+ * today, but the interface doesn't promise that for every provider —
11124
+ * holocron#1068). The marker-parsing and error message are identical
11125
+ * either way; `readExisting` is how the two callers differ.
11126
+ *
11127
+ * A file with no marker at all predates this check (or was written before
11128
+ * #1026) and is never flagged — only a marker that's present AND disagrees
11129
+ * with the current run's own package is a real collision. `readExisting`
11130
+ * returning `null` means "nothing there," not "unreadable" — a caller
11131
+ * whose underlying read can fail for reasons other than "doesn't exist"
11132
+ * (e.g. local fs EISDIR) is expected to let that error propagate out of
11133
+ * `readExisting` itself rather than mapping it to `null`.
11134
+ */
11135
+ async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
11136
+ const existing = await readExisting();
11137
+ if (existing === null) return;
11138
+ const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
11139
+ 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.`);
11140
+ }
11141
+ // src/commands/repo-files/generate-workflow-files.ts
11142
+ /**
11143
+ * The thin-caller workflow for each task in the manifest, in the manifest's order. A task with no template is a
11144
+ * skipped entry, and a task with `ci: false` has no file. Nothing here is remote: astromech renders every file from the
11145
+ * manifest (the linter set, deploy paths, deploy and preview), and a bad manifest throws.
11146
+ */
11147
+ function generateWorkflowFiles(input) {
11148
+ const config = input.loaded.resolved;
11149
+ if (!config.tasks || config.tasks.length === 0) return [];
11150
+ const gitRoot = findRootSync(input.repoRoot, ".git", {
11151
+ fallback: "start",
11152
+ realpath: true
11153
+ });
11154
+ const pkgRelPath = resolvePkgRelPath(gitRoot, input.loaded.filepath);
11155
+ const tasks = withAutoPreviewDeployPaths(config.tasks, gitRoot);
11156
+ const files = createAstromech({
11157
+ cwd: input.repoRoot,
11158
+ config: { tasks },
11159
+ orgContext: {
11160
+ org: config.org,
11161
+ domain: config.domain
11162
+ },
11163
+ logger: input.logger ?? getLogger()
11164
+ }).thinCallers();
11165
+ const entries = [];
11166
+ for (const entry of tasks) {
11167
+ const name = typeof entry === "string" ? entry : entry.name;
11168
+ const isCombinedContentOnly = name === "knowledge.docs" || name === "knowledge.components";
11169
+ if (!KNOWN_WORKFLOWS.has(name) && !isCombinedContentOnly) {
11170
+ entries.push({
11171
+ kind: "skip",
11172
+ step: `write workflow ${name}`,
11173
+ syncStep: `sync workflow ${name}`,
11174
+ message: `unknown workflow "${name}" — no template available`
11175
+ });
11176
+ continue;
11177
+ }
11178
+ const filename = `${name}.yml`;
11179
+ const content = files.get(filename);
11180
+ if (content === void 0) continue;
11181
+ const preview = content.includes("workflows/preview.yml@main") ? " (with preview)" : "";
11182
+ entries.push({
11183
+ kind: "file",
11184
+ path: `.github/workflows/${filename}`,
11185
+ content: thinCallerFile(pkgRelPath, content),
11186
+ step: `write workflow ${name}${preview}`,
11187
+ syncStep: `sync workflow ${name}${preview}`,
11188
+ workflow: {
11189
+ task: name,
11190
+ filename
11191
+ }
11192
+ });
11193
+ }
11194
+ return entries;
11195
+ }
11196
+ // src/commands/repo-files/generate-repo-files.ts
11197
+ /**
11198
+ * Every file `holocron repo setup` writes to disk from the config alone, in the order it writes them: the thin-caller
11199
+ * workflows, the config files, then `turbo.json` and its follow-up edits. No provider and no network, so a job without
11200
+ * a token can produce them, and `repo sync` takes the files it shares from here too. What setup reads from a provider
11201
+ * (CODEOWNERS, which needs the org, the installed skills, the agent prompts) is not here.
11202
+ */
11203
+ async function generateRepoFiles(input) {
11204
+ return [
11205
+ ...generateWorkflowFiles(input),
11206
+ ...await generateConfigFiles(input),
11207
+ ...await generateTurboFiles(input)
11208
+ ];
11209
+ }
11210
+ // src/commands/probe/generated/generated-probes.ts
11211
+ /** The group of probes that check the files `repo setup` and `repo sync` generate. */
11212
+ const GENERATED_PROVIDER = "generated";
11213
+ function readText(path) {
11214
+ try {
11215
+ return readFileSync(path, "utf8");
11216
+ } catch {
11217
+ return null;
11218
+ }
11219
+ }
11220
+ async function generate(input) {
11221
+ const entries = await generateRepoFiles(input);
11222
+ return {
11223
+ files: entries.filter((e) => e.kind === "file"),
11224
+ errors: entries.flatMap((e) => e.kind === "error" ? [`${e.step}: ${e.message}`] : [])
11225
+ };
11226
+ }
11227
+ /**
11228
+ * `generated check` generates every file `repo setup` writes from the config alone (no provider, no token), twice, and
11229
+ * fails for each one that differs from the committed copy, differs the second time, or is a workflow nothing
11230
+ * generates. CI runs it, so a change to a generator or to the config that was not followed by a run of `repo setup`
11231
+ * or `repo sync` cannot merge.
11232
+ */
11233
+ function generatedProbes(loaded, repoRoot) {
11234
+ return { check: {
11235
+ summary: "Fail for each generated file that differs from the committed copy (CI runs this).",
11236
+ writes: false,
11237
+ async run(ctx) {
11238
+ const input = {
11239
+ loaded,
11240
+ repoRoot
11241
+ };
11242
+ const first = await generate(input);
11243
+ const second = await generate(input);
11244
+ const workflowsDir = join(repoRoot, ".github", "workflows");
11245
+ const workflows = /* @__PURE__ */ new Map();
11246
+ for (const name of readdirSync(workflowsDir).filter((n) => n.endsWith(".yml")).sort()) workflows.set(name, readFileSync(join(workflowsDir, name), "utf8"));
11247
+ const problems = [...first.errors, ...checkGenerated({
11248
+ files: first.files,
11249
+ again: second.files,
11250
+ read: (path) => readText(join(repoRoot, path)),
11251
+ workflows
11252
+ })];
11253
+ for (const line of problems) ctx.say({
11254
+ status: "fail",
11255
+ label: line
11256
+ });
11257
+ if (problems.length === 0) ctx.say({
11258
+ status: "ok",
11259
+ label: `${first.files.length} files`,
11260
+ detail: "all match what holocron generates"
11261
+ });
11262
+ }
11263
+ } };
11264
+ }
10794
11265
  // src/commands/probe/list-probes.ts
10795
11266
  /** The listing `holocron probe` prints: each provider, and under it each probe with its summary; writers are marked. */
10796
11267
  function listProbes(groups) {
@@ -10977,6 +11448,7 @@ async function runProbeCommand(input) {
10977
11448
  groups.set(COMLINK_PROVIDER, comlink);
10978
11449
  groups.set(DOCS_PROVIDER, docsCoverageProbes(input.context.repoRoot, input.typedoc));
10979
11450
  groups.set(DEPS_PROVIDER, depsProbes(input.context.repoRoot, print));
11451
+ groups.set(GENERATED_PROVIDER, generatedProbes(input.loaded, input.context.repoRoot));
10980
11452
  if (!input.provider) {
10981
11453
  if (input.pick) await input.pick(groups);
10982
11454
  else for (const line of listProbes(groups)) print(line);
@@ -11231,148 +11703,6 @@ const STALE_LABELS = [
11231
11703
  "autorelease: tagged",
11232
11704
  "released on @alpha"
11233
11705
  ];
11234
- // src/templates/dco.yml
11235
- var dco_default = "allowRemediationCommits:\n individual: true\n";
11236
- // src/commands/preview-deploy-paths/preview-deploy-paths.ts
11237
- /** `realpathSync`, falling back to the unresolved input on a path that doesn't exist (e.g. a test fixture). */
11238
- function tryRealpath(path) {
11239
- try {
11240
- return realpathSync(path);
11241
- } catch {
11242
- return path;
11243
- }
11244
- }
11245
- /**
11246
- * `delivery.previewDeploy`'s package directory plus its `workspace:*`
11247
- * dependencies' directories (holocron#1023) — the reusable workflow's
11248
- * `paths` input, so a PR touching only an unrelated package in the
11249
- * monorepo skips the actual deploy work instead of spinning up a Vercel
11250
- * preview for every PR regardless of relevance. `undefined` for a
11251
- * root-level consumer (`cwd: "."` or omitted) -- every PR already IS a PR
11252
- * to that package, no filter needed -- or when `cwd` doesn't resolve to
11253
- * any known workspace package (soft-skip; the caller leaves `paths`
11254
- * unset rather than guessing).
11255
- */
11256
- function resolvePreviewDeployPaths(gitRoot, cwdValue) {
11257
- if (!cwdValue || cwdValue === ".") return void 0;
11258
- const all = workspacePackages(gitRoot, {
11259
- readJson: defaultReadJson,
11260
- listDirs: defaultListDirs
11261
- });
11262
- const target = tryRealpath(resolve(gitRoot, cwdValue));
11263
- const pkg = all.find((candidate) => tryRealpath(candidate.dir) === target);
11264
- if (!pkg) return void 0;
11265
- return defaultPaths(gitRoot, pkg, all);
11266
- }
11267
- /**
11268
- * Returns `tasks` unchanged unless it has a `delivery.previewDeploy` entry
11269
- * with a non-root `with.cwd` and no `with.paths` of its own -- in which
11270
- * case that one entry gets an auto-computed `paths` (see
11271
- * {@link resolvePreviewDeployPaths}), added without mutating the input.
11272
- * An explicit `with.paths` from the repo's own config always wins; this
11273
- * only fills in what the repo didn't already specify.
11274
- */
11275
- function withAutoPreviewDeployPaths(tasks, gitRoot) {
11276
- return tasks.map((entry) => {
11277
- if (typeof entry === "string" || entry.name !== "delivery.previewDeploy") return entry;
11278
- const cwdValue = entry.with?.["cwd"];
11279
- if (typeof cwdValue !== "string" || entry.with?.["paths"] !== void 0) return entry;
11280
- const paths = resolvePreviewDeployPaths(gitRoot, cwdValue);
11281
- if (!paths) return entry;
11282
- return {
11283
- ...entry,
11284
- with: {
11285
- ...entry.with,
11286
- paths
11287
- }
11288
- };
11289
- });
11290
- }
11291
- // src/commands/thin-caller-file/thin-caller-file.ts
11292
- const { workflowHeader: workflowHeader$1 } = createHeader({
11293
- source: "cli/astromech/src/thin-callers.ts",
11294
- tool: "holocron repo sync"
11295
- });
11296
- /**
11297
- * The text of a generated thin-caller workflow: the AUTO-GENERATED header, the `# Source package:` marker (see
11298
- * `resolvePkgRelPath`) and the workflow itself. Both `repo setup` and `repo sync` write their workflows through
11299
- * this, so the file is the same whichever command wrote it.
11300
- */
11301
- function thinCallerFile(pkgRelPath, content) {
11302
- return `${workflowHeader$1()}# Source package: ${pkgRelPath}\n\n${content}`;
11303
- }
11304
- // src/commands/workflow-source-marker/workflow-source-marker.ts
11305
- /** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
11306
- const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
11307
- /** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
11308
- function sanitizeForDisplay(value) {
11309
- return value.replace(/[\x00-\x1f\x7f]/g, "");
11310
- }
11311
- /**
11312
- * Repo-root-relative path of the PACKAGE a workflow-writing command run is
11313
- * scoped to — the directory holding the discovered `holocron.config.*`
11314
- * (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
11315
- * up to find the config from any subdirectory ("every command is usable
11316
- * from any subdirectory of a repo, not only its exact root"), so a `--cwd`
11317
- * one level too deep would otherwise stamp a different marker than a later
11318
- * run from the package's own root and misfire the collision check this
11319
- * feeds (holocron#1026).
11320
- *
11321
- * "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
11322
- * to forward slashes so the same package produces the same marker on
11323
- * Windows and POSIX. Throws if the result contains a line break — a path
11324
- * containing one could otherwise break out of the `# Source package: `
11325
- * comment line and inject arbitrary workflow YAML when the generated
11326
- * content is later written. Not reachable through this CLI's own flows
11327
- * (no code path writes a config file whose directory name contains a line
11328
- * break), but cheap to reject outright rather than trust the filesystem.
11329
- */
11330
- function resolvePkgRelPath(gitRoot, configFilepath) {
11331
- let root;
11332
- try {
11333
- root = realpathSync(gitRoot);
11334
- } catch {
11335
- root = gitRoot;
11336
- }
11337
- let configDir;
11338
- try {
11339
- configDir = realpathSync(dirname(configFilepath));
11340
- } catch {
11341
- configDir = dirname(configFilepath);
11342
- }
11343
- const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
11344
- if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
11345
- return pkgRelPath;
11346
- }
11347
- /**
11348
- * Two different monorepo packages opting into the same generic task name
11349
- * (e.g. both `apps/sentinel` and some future `apps/other` configuring
11350
- * `delivery.previewDeploy`) would otherwise overwrite each other's
11351
- * `.github/workflows/<task>.yml` on whichever package's write ran last —
11352
- * only one package's behavior would ever actually run in CI, with no
11353
- * signal that the other's was silently dropped (holocron#1026).
11354
- *
11355
- * Shared by both `holocron repo sync` (reads the file straight off local
11356
- * disk) and `holocron repo setup` (reads it through the loaded `Source`
11357
- * capability, which happens to be local disk too for the github plugin
11358
- * today, but the interface doesn't promise that for every provider —
11359
- * holocron#1068). The marker-parsing and error message are identical
11360
- * either way; `readExisting` is how the two callers differ.
11361
- *
11362
- * A file with no marker at all predates this check (or was written before
11363
- * #1026) and is never flagged — only a marker that's present AND disagrees
11364
- * with the current run's own package is a real collision. `readExisting`
11365
- * returning `null` means "nothing there," not "unreadable" — a caller
11366
- * whose underlying read can fail for reasons other than "doesn't exist"
11367
- * (e.g. local fs EISDIR) is expected to let that error propagate out of
11368
- * `readExisting` itself rather than mapping it to `null`.
11369
- */
11370
- async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
11371
- const existing = await readExisting();
11372
- if (existing === null) return;
11373
- const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
11374
- 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.`);
11375
- }
11376
11706
  // src/commands/setup/agent-prompts-data.ts
11377
11707
  /**
11378
11708
  * Canonical AI engineering workflow role prompts.
@@ -11917,25 +12247,6 @@ async function installEngineeringStructure({ repoRoot }) {
11917
12247
  for (const [path, content] of writes) if (await writeIfAbsent(path, content)) results.push(path.replace(repoRoot + "/", ""));
11918
12248
  return results.length > 0 ? `created: ${results.join(", ")}` : "all files already exist — nothing to write";
11919
12249
  }
11920
- // src/commands/setup/own-catalog-packages/own-catalog-packages.ts
11921
- /**
11922
- * The packages of this workspace that a pnpm catalog also lists: the minimum versions a plugin accepts
11923
- * as a peer, say. Dependabot reads every catalog entry as an ordinary dependency and would raise it to the
11924
- * latest release, but such an entry is a compatibility floor that is raised by hand, and the package itself
11925
- * is linked with `workspace:`. A package from outside the workspace in a catalog is left out, so it keeps
11926
- * getting updates. Sorted; `[]` when there is no `pnpm-workspace.yaml`.
11927
- */
11928
- function ownCatalogPackages(repoRoot) {
11929
- let yaml;
11930
- try {
11931
- yaml = readFileSync(join(repoRoot, "pnpm-workspace.yaml"), "utf8");
11932
- } catch {
11933
- return [];
11934
- }
11935
- const listed = new Set(Object.values(parseCatalogs(yaml)).flatMap((catalog) => Object.keys(catalog)));
11936
- const own = discoverWorkspacePackages(repoRoot).flatMap(({ name }) => name && listed.has(name) ? [name] : []);
11937
- return [...new Set(own)].sort();
11938
- }
11939
12250
  // src/commands/setup/repo-settings.ts
11940
12251
  const BALANCED_REPO_SETTINGS = {
11941
12252
  allow_squash_merge: true,
@@ -12213,10 +12524,6 @@ async function updateSkillsGitignore(gitignorePath, skills, symlinkFn) {
12213
12524
  * extensible but pushes the same knowledge into N plugins instead of
12214
12525
  * one central place.
12215
12526
  */
12216
- const { workflowHeader } = createHeader({
12217
- source: "cli/cli/src/commands/setup/run-setup.ts",
12218
- tool: "holocron repo setup"
12219
- });
12220
12527
  async function runSetup(input) {
12221
12528
  const print = input.print ?? ((line) => console.log(line));
12222
12529
  const logger = getLogger();
@@ -12228,12 +12535,10 @@ async function runSetup(input) {
12228
12535
  const steps = [];
12229
12536
  const repo = config.repo;
12230
12537
  const effectivePreset = repo?.protection;
12231
- const setupGitRoot = findRootSync(input.context.repoRoot, ".git", {
12538
+ const setupPkgRelPath = resolvePkgRelPath(findRootSync(input.context.repoRoot, ".git", {
12232
12539
  fallback: "start",
12233
12540
  realpath: true
12234
- });
12235
- const setupPkgRelPath = resolvePkgRelPath(setupGitRoot, input.loaded.filepath);
12236
- const hooksEnabled = input.hooks ?? (typeof config.hooks === "boolean" ? config.hooks : typeof config.hooks === "object" ? config.hooks.prePush !== false : effectivePreset === "strict");
12541
+ }), input.loaded.filepath);
12237
12542
  print(style.header(`Holocron setup — ${config.name}${dryRun ? " (dry-run)" : ""}`));
12238
12543
  print(style.dim(` config: ${input.loaded.filepath}`));
12239
12544
  print("");
@@ -12281,187 +12586,43 @@ async function runSetup(input) {
12281
12586
  print(formatStep(steps[steps.length - 1]));
12282
12587
  }
12283
12588
  }
12284
- const tasks = config.tasks && config.tasks.length > 0 ? withAutoPreviewDeployPaths(config.tasks, setupGitRoot) : config.tasks;
12285
- if (loader.has("source") && tasks && tasks.length > 0) {
12286
- const source = loader.get("source");
12287
- print(style.step("workflows"));
12288
- const files = createAstromech({
12289
- cwd: input.context.repoRoot,
12290
- config: { tasks },
12291
- orgContext: {
12292
- org: config.org,
12293
- domain: config.domain
12294
- },
12295
- logger
12296
- }).thinCallers();
12297
- for (const entry of tasks) {
12298
- const name = typeof entry === "string" ? entry : entry.name;
12299
- const isCombinedContentOnly = name === "knowledge.docs" || name === "knowledge.components";
12300
- if (!KNOWN_WORKFLOWS.has(name) && !isCombinedContentOnly) {
12301
- steps.push({
12302
- capability: "source",
12303
- step: `write workflow ${name}`,
12304
- status: "skip",
12305
- message: `unknown workflow "${name}" — no template available`
12306
- });
12307
- print(formatStep(steps[steps.length - 1]));
12308
- continue;
12309
- }
12310
- const filename = `${name}.yml`;
12311
- const content = files.get(filename);
12312
- if (content === void 0) continue;
12313
- const step = content.includes("workflows/preview.yml@main") ? `write workflow ${name} (with preview)` : `write workflow ${name}`;
12314
- steps.push(await runStep("source", step, dryRun, async () => {
12315
- await assertNoPackageCollision(name, setupPkgRelPath, filename, () => source.readWorkflowFile(filename));
12316
- await source.writeWorkflowFile(filename, thinCallerFile(setupPkgRelPath, content));
12317
- }));
12318
- print(formatStep(steps[steps.length - 1]));
12319
- }
12320
- }
12321
- if (loader.has("source") && (config.tasks ?? []).map((e) => typeof e === "string" ? e : e.name).includes("bookkeeping")) {
12322
- const source = loader.get("source");
12323
- steps.push(await runStep("source", "write .github/labeler.yml", dryRun, async () => {
12324
- await source.writeRepoFile(".github/labeler.yml", createLabeler());
12325
- }));
12326
- print(formatStep(steps[steps.length - 1]));
12327
- }
12328
- if (loader.has("source") && effectivePreset !== "none") {
12329
- const source = loader.get("source");
12330
- steps.push(await runStep("source", "write .github/dependabot.yml", dryRun, async () => {
12331
- await source.writeRepoFile(".github/dependabot.yml", createDependabot({ ignore: ownCatalogPackages(input.context.repoRoot) }));
12332
- }));
12333
- print(formatStep(steps[steps.length - 1]));
12334
- steps.push(await runStep("source", "write .github/dco.yml", dryRun, async () => {
12335
- await source.writeRepoFile(".github/dco.yml", `${workflowHeader()}${dco_default}`);
12336
- }));
12337
- print(formatStep(steps[steps.length - 1]));
12338
- }
12339
12589
  if (loader.has("source")) {
12340
12590
  const source = loader.get("source");
12341
- steps.push(await runStep("source", "write .alexrc.json", dryRun, async () => {
12342
- await source.writeRepoFile(".alexrc.json", createAlexrc());
12343
- }));
12344
- print(formatStep(steps[steps.length - 1]));
12345
- steps.push(await runStep("source", "write .alexignore", dryRun, async () => {
12346
- await source.writeRepoFile(".alexignore", createAlexignore());
12347
- }));
12348
- print(formatStep(steps[steps.length - 1]));
12349
- steps.push(await runStep("source", "write .yamllint.yml", dryRun, async () => {
12350
- await source.writeRepoFile(".yamllint.yml", createYamllint());
12351
- }));
12352
- print(formatStep(steps[steps.length - 1]));
12353
- steps.push(await runStep("source", "write .yamlignore", dryRun, async () => {
12354
- await source.writeRepoFile(".yamlignore", createYamlignore());
12355
- }));
12356
- print(formatStep(steps[steps.length - 1]));
12357
- steps.push(await runStep("source", "write .editorconfig", dryRun, async () => {
12358
- await source.writeRepoFile(".editorconfig", createEditorconfig());
12359
- }));
12360
- print(formatStep(steps[steps.length - 1]));
12361
- steps.push(await runStep("source", "write .editorconfig-checker.json", dryRun, async () => {
12362
- await source.writeRepoFile(".editorconfig-checker.json", createEditorconfigChecker());
12363
- }));
12364
- print(formatStep(steps[steps.length - 1]));
12365
- steps.push(await runStep("source", "write devmoji.config.cjs", dryRun, async () => {
12366
- await source.writeRepoFile("devmoji.config.cjs", createDevmoji());
12367
- }));
12368
- print(formatStep(steps[steps.length - 1]));
12369
- steps.push(await runStep("source", "write .husky/prepare-commit-msg", dryRun, async () => {
12370
- await source.writeRepoFile(".husky/prepare-commit-msg", createPrepareCommitMsg());
12371
- }));
12372
- print(formatStep(steps[steps.length - 1]));
12373
- steps.push(await runStep("source", "write .husky/commit-msg", dryRun, async () => {
12374
- await source.writeRepoFile(".husky/commit-msg", createCommitMsg(config.holocronScript));
12375
- }));
12376
- print(formatStep(steps[steps.length - 1]));
12377
- if (hooksEnabled) {
12378
- steps.push(await runStep("source", "write .husky/pre-push", dryRun, async () => {
12379
- await source.writeRepoFile(".husky/pre-push", createPrePush(config.holocronScript));
12380
- return "runs `holocron run ci` before push — bypass with `git push --no-verify`";
12591
+ if (config.tasks && config.tasks.length > 0) print(style.step("workflows"));
12592
+ for (const entry of await generateRepoFiles({
12593
+ loaded: input.loaded,
12594
+ repoRoot: input.context.repoRoot,
12595
+ hooks: input.hooks,
12596
+ logger
12597
+ })) {
12598
+ if (entry.kind === "skip") steps.push({
12599
+ capability: "source",
12600
+ step: entry.step,
12601
+ status: "skip",
12602
+ message: entry.message
12603
+ });
12604
+ else if (entry.kind === "error") steps.push(await runStep("source", entry.step, dryRun, async () => {
12605
+ throw new Error(entry.message);
12381
12606
  }));
12382
- print(formatStep(steps[steps.length - 1]));
12383
- steps.push(await runStep("source", "write .husky/pre-commit", dryRun, async () => {
12384
- await source.writeRepoFile(".husky/pre-commit", createPreCommit());
12385
- return "runs GitLeaks (staged-only) + lint-staged before commit";
12607
+ else steps.push(await runStep("source", entry.step, dryRun, async () => {
12608
+ if (entry.workflow) {
12609
+ const { task, filename } = entry.workflow;
12610
+ await assertNoPackageCollision(task, setupPkgRelPath, filename, () => source.readWorkflowFile(filename));
12611
+ await source.writeWorkflowFile(filename, entry.content);
12612
+ } else await source.writeRepoFile(entry.path, entry.content);
12613
+ return entry.note;
12386
12614
  }));
12387
12615
  print(formatStep(steps[steps.length - 1]));
12388
- if (config.syncScripts !== false) {
12616
+ if (entry.kind === "file" && entry.path === ".husky/pre-commit" && config.syncScripts !== false) {
12389
12617
  steps.push(await runStep("source", "set package.json prepare script", dryRun, async () => {
12390
12618
  return await ensurePrepareScript(input.context.repoRoot) ? "prepare now runs husky" : "already runs husky";
12391
12619
  }));
12392
12620
  print(formatStep(steps[steps.length - 1]));
12393
12621
  }
12394
- } else {
12395
- steps.push({
12396
- capability: "source",
12397
- step: "write .husky/pre-push",
12398
- status: "skip",
12399
- message: "git hooks disabled"
12400
- });
12401
- print(formatStep(steps[steps.length - 1]));
12402
- steps.push({
12403
- capability: "source",
12404
- step: "write .husky/pre-commit",
12405
- status: "skip",
12406
- message: "git hooks disabled"
12407
- });
12408
- print(formatStep(steps[steps.length - 1]));
12409
- }
12410
- {
12411
- const hasTestWorkflow = (config.tasks ?? []).map((e) => typeof e === "string" ? e : e.name).includes("verification.unitTests");
12412
- const existing = await readFile(join(input.context.repoRoot, "codecov.yml"), "utf8").catch(() => null);
12413
- if (!hasTestWorkflow && existing == null) steps.push({
12414
- capability: "source",
12415
- step: "write codecov.yml",
12416
- status: "skip",
12417
- message: "no test workflow configured"
12418
- });
12419
- else steps.push(await runStep("source", "write codecov.yml", dryRun, async () => {
12420
- const content = createAstromech({
12421
- cwd: input.context.repoRoot,
12422
- logger
12423
- }).codecovConfig(existing);
12424
- await source.writeRepoFile("codecov.yml", content);
12425
- const packageCount = readWorkspacePackages(input.context.repoRoot).length;
12426
- return packageCount > 0 ? `${packageCount} components` : "no components";
12427
- }));
12428
- print(formatStep(steps[steps.length - 1]));
12429
- }
12430
- {
12431
- const astromechTurbo = createAstromech({
12432
- cwd: input.context.repoRoot,
12433
- config: { tasks: config.tasks },
12434
- logger
12435
- });
12436
- const content = astromechTurbo.turboConfig();
12437
- const firstStep = steps.length;
12438
- if (content === null) steps.push({
12439
- capability: "source",
12440
- step: "write turbo.json",
12441
- status: "skip",
12442
- message: "no fan-out-eligible tasks configured"
12443
- });
12444
- else {
12445
- steps.push(await runStep("source", "write turbo.json", dryRun, async () => {
12446
- await source.writeRepoFile("turbo.json", content);
12447
- }));
12448
- const rootPkgRaw = await readFile(join(input.context.repoRoot, "package.json"), "utf8").catch(() => null);
12449
- const rootPkg = rootPkgRaw ? JSON.parse(rootPkgRaw) : null;
12450
- const workspaceYaml = await readFile(join(input.context.repoRoot, "pnpm-workspace.yaml"), "utf8").catch(() => "");
12451
- const rootScripts = rootPkg?.scripts ?? {};
12452
- const workspaceFix = astromechTurbo.ensureRootWorkspaceMember(workspaceYaml, rootScripts);
12453
- if (workspaceFix.changed) steps.push(await runStep("source", "fix pnpm-workspace.yaml (root workspace member, #692)", dryRun, async () => {
12454
- await source.writeRepoFile("pnpm-workspace.yaml", workspaceFix.content);
12455
- }));
12456
- if (rootPkgRaw) {
12457
- const depFix = astromechTurbo.ensureTurboDependency(rootPkgRaw, workspaceFix.content);
12458
- if (depFix.changed) steps.push(await runStep("source", "add turbo devDependency", dryRun, async () => {
12459
- await source.writeRepoFile("package.json", depFix.content);
12460
- }));
12461
- }
12462
- }
12463
- for (const step of steps.slice(firstStep)) print(formatStep(step));
12464
12622
  }
12623
+ }
12624
+ if (loader.has("source")) {
12625
+ const source = loader.get("source");
12465
12626
  if (source.syncLabels) {
12466
12627
  steps.push(await runStep("source", "sync labels", dryRun, async () => {
12467
12628
  return source.syncLabels(CANONICAL_LABELS, STALE_LABELS);
@@ -12996,6 +13157,361 @@ const setupCommand = {
12996
13157
  })).summary.fail > 0) process.exitCode = 1;
12997
13158
  }
12998
13159
  };
13160
+ // src/commands/repo-cleanup-branches/classify-branches.ts
13161
+ /** The merged PRs that had this branch as their head, newest first (the order the provider lists them). */
13162
+ function mergedFor(name, closed) {
13163
+ return closed.filter((pr) => pr.merged && pr.branch === name);
13164
+ }
13165
+ /**
13166
+ * Whether a merged PR accounts for a branch's tip: it is the PR's head, an ancestor of it, or (when the head
13167
+ * commit is not in the checkout) one of the PR's own commits. The provider is asked for the commits last, and
13168
+ * only for a branch the cheaper checks did not settle.
13169
+ */
13170
+ async function accounts(pr, tip, input) {
13171
+ if (pr.headSha === void 0) return (await input.pullRequestCommits(pr.number)).includes(tip);
13172
+ if (tip === pr.headSha || input.git.isAncestor(tip, pr.headSha)) return true;
13173
+ return (await input.pullRequestCommits(pr.number)).includes(tip);
13174
+ }
13175
+ async function classifyOne(ref, input) {
13176
+ if (input.git.isMergedIntoBase(ref.sha)) return {
13177
+ ref,
13178
+ group: "merged"
13179
+ };
13180
+ const merged = mergedFor(ref.name, input.closedPullRequests);
13181
+ for (const pr of merged) if (await accounts(pr, ref.sha, input)) return {
13182
+ ref,
13183
+ group: "squash-merged",
13184
+ pr: pr.number
13185
+ };
13186
+ const newest = merged[0];
13187
+ if (newest) return {
13188
+ ref,
13189
+ group: "has-extra",
13190
+ pr: newest.number
13191
+ };
13192
+ return {
13193
+ ref,
13194
+ group: input.closedPullRequests.some((pr) => pr.branch === ref.name) ? "closed-unmerged" : "no-pr"
13195
+ };
13196
+ }
13197
+ /**
13198
+ * Sorts branches, local and remote, into what is proven merged and what is not. A branch is skipped outright
13199
+ * when it is excluded (a base branch, or locally the checked-out one or one a worktree has out) or has an open
13200
+ * PR; the rest are classified by {@link BranchGroup}. Nothing here deletes.
13201
+ */
13202
+ async function classifyBranches(input) {
13203
+ const open = new Set(input.openPullRequests.map((pr) => pr.branch));
13204
+ const classification = {
13205
+ classified: [],
13206
+ skipped: []
13207
+ };
13208
+ for (const ref of input.branches) {
13209
+ const excluded = input.excluded(ref);
13210
+ if (excluded) classification.skipped.push({
13211
+ ref,
13212
+ reason: excluded
13213
+ });
13214
+ else if (open.has(ref.name)) classification.skipped.push({
13215
+ ref,
13216
+ reason: "open-pr"
13217
+ });
13218
+ else classification.classified.push(await classifyOne(ref, input));
13219
+ }
13220
+ return classification;
13221
+ }
13222
+ // src/commands/repo-cleanup-branches/group-branches.ts
13223
+ /**
13224
+ * One row per branch name and group: a branch on both sides that classifies the same on each is one entry
13225
+ * listing both places. A name whose two refs classify differently (the remote moved on) is two entries.
13226
+ * Newest first by local commit date; a remote-only branch has no date and follows, by name.
13227
+ */
13228
+ function groupBranches(classified) {
13229
+ const entries = /* @__PURE__ */ new Map();
13230
+ for (const { ref, group, pr } of classified) {
13231
+ const key = `${group}:${ref.name}`;
13232
+ const entry = entries.get(key) ?? {
13233
+ name: ref.name,
13234
+ group,
13235
+ ...pr === void 0 ? {} : { pr },
13236
+ locations: []
13237
+ };
13238
+ entry.locations.push(ref.where);
13239
+ if (ref.date !== void 0 && (entry.date === void 0 || ref.date > entry.date)) entry.date = ref.date;
13240
+ entries.set(key, entry);
13241
+ }
13242
+ return [...entries.values()].sort((a, b) => (b.date ?? "").localeCompare(a.date ?? "") || a.name.localeCompare(b.name));
13243
+ }
13244
+ // src/commands/repo-cleanup-branches/constants.ts
13245
+ /** The long-lived branches: never deleted, and what a branch must be an ancestor of (as `origin/<name>`) to count as merged. */
13246
+ const BASE_BRANCHES = ["alpha", "main"];
13247
+ // src/commands/repo-cleanup-branches/local-git.ts
13248
+ /** `git` run in `cwd`, no shell: its trimmed stdout and stderr, and whether it exited 0. */
13249
+ function git(cwd, args) {
13250
+ const r = spawnSync("git", args, {
13251
+ cwd,
13252
+ encoding: "utf8"
13253
+ });
13254
+ return {
13255
+ out: (r.stdout ?? "").trim(),
13256
+ ok: r.status === 0,
13257
+ err: (r.stderr ?? "").trim()
13258
+ };
13259
+ }
13260
+ /** {@link LocalGit} over the checkout at `cwd`. */
13261
+ function createLocalGit(cwd) {
13262
+ return {
13263
+ branches() {
13264
+ const { out } = git(cwd, [
13265
+ "for-each-ref",
13266
+ "--format=%(refname:short)%09%(objectname)%09%(committerdate:iso-strict)",
13267
+ "refs/heads"
13268
+ ]);
13269
+ return out.split("\n").filter(Boolean).map((line) => {
13270
+ const [name = "", sha = "", date = ""] = line.split(" ");
13271
+ return {
13272
+ name,
13273
+ sha,
13274
+ date,
13275
+ where: "local"
13276
+ };
13277
+ });
13278
+ },
13279
+ currentBranch() {
13280
+ return git(cwd, [
13281
+ "symbolic-ref",
13282
+ "--quiet",
13283
+ "--short",
13284
+ "HEAD"
13285
+ ]).out || void 0;
13286
+ },
13287
+ worktreeBranches() {
13288
+ return git(cwd, [
13289
+ "worktree",
13290
+ "list",
13291
+ "--porcelain"
13292
+ ]).out.split("\n").filter((line) => line.startsWith("branch refs/heads/")).map((line) => line.slice(18));
13293
+ },
13294
+ isMergedIntoBase(sha) {
13295
+ return BASE_BRANCHES.some((base) => git(cwd, [
13296
+ "merge-base",
13297
+ "--is-ancestor",
13298
+ sha,
13299
+ `origin/${base}`
13300
+ ]).ok);
13301
+ },
13302
+ isAncestor(sha, of) {
13303
+ return git(cwd, [
13304
+ "merge-base",
13305
+ "--is-ancestor",
13306
+ sha,
13307
+ of
13308
+ ]).ok;
13309
+ },
13310
+ deleteBranch(name) {
13311
+ const r = git(cwd, [
13312
+ "branch",
13313
+ "-D",
13314
+ "--",
13315
+ name
13316
+ ]);
13317
+ if (!r.ok) throw new Error(r.err || `git branch -D ${name} failed`);
13318
+ }
13319
+ };
13320
+ }
13321
+ // src/commands/repo-cleanup-branches/run-cleanup-branches.ts
13322
+ const GROUPS = [
13323
+ "merged",
13324
+ "squash-merged",
13325
+ "has-extra",
13326
+ "closed-unmerged",
13327
+ "no-pr"
13328
+ ];
13329
+ /** The two groups that are proven merged: ticked in the checklist, and what `--yes` deletes. */
13330
+ const SAFE = ["merged", "squash-merged"];
13331
+ const GROUP_LABEL = {
13332
+ merged: "merged (an ancestor of a base branch)",
13333
+ "squash-merged": "squash-merged (its PR merged and the branch holds nothing beyond it)",
13334
+ "has-extra": "merged PR, but the branch has more commits",
13335
+ "closed-unmerged": "PR closed without merging",
13336
+ "no-pr": "no PR and not merged"
13337
+ };
13338
+ const SKIP_LABEL = {
13339
+ base: "base branch",
13340
+ current: "checked out",
13341
+ worktree: "checked out in a worktree",
13342
+ "open-pr": "has an open PR"
13343
+ };
13344
+ /** A row's label: the name, where it lives, when it was last committed to (local only) and its PR. */
13345
+ function rowLabel(entry) {
13346
+ const detail = [entry.date?.slice(0, 10), entry.pr === void 0 ? void 0 : `PR #${entry.pr}`].filter(Boolean);
13347
+ return `${entry.name} [${entry.locations.join(", ")}]${detail.length > 0 ? ` ${style.dim(detail.join(" "))}` : ""}`;
13348
+ }
13349
+ /**
13350
+ * Classifies the branches against the provider's pull requests, shows them grouped, and deletes the ones
13351
+ * chosen. With no flag it covers local and remote branches, each row saying where the branch lives.
13352
+ *
13353
+ * - `--dry-run` stops after the list.
13354
+ * - `--yes` deletes every proven-merged branch without asking.
13355
+ * - Otherwise it asks, then offers a checklist of every branch with the proven-merged ones ticked.
13356
+ */
13357
+ async function runCleanupBranches(input) {
13358
+ const print = input.print ?? ((line) => console.log(line));
13359
+ const logger = input.logger ?? getLogger();
13360
+ const scope = input.scope ?? "both";
13361
+ const git = input.git ?? createLocalGit(input.context.repoRoot);
13362
+ // c8 ignore next -- real PluginLoader construction is integration-level; unit tests always supply loader
13363
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
13364
+ await loader.load();
13365
+ assertPluginsResolvable(loader, "repo cleanup branches");
13366
+ if (!loader.has("source")) throw new Error("source capability is not configured — add a source provider to holocron.config.json");
13367
+ const source = loader.get("source");
13368
+ const { listPullRequests, listPullRequestCommits, listBranches, deleteBranch } = source;
13369
+ if (!listPullRequests || !listPullRequestCommits) throw new Error(`${source.providerName} source provider does not support listing pull requests`);
13370
+ if (scope !== "local" && (!listBranches || !deleteBranch)) throw new Error(`${source.providerName} source provider does not support listing and deleting remote branches`);
13371
+ const worktrees = new Set(scope === "remote" ? [] : git.worktreeBranches());
13372
+ const current = scope === "remote" ? void 0 : git.currentBranch();
13373
+ const refs = [];
13374
+ if (scope !== "remote") refs.push(...git.branches());
13375
+ if (scope !== "local") {
13376
+ const remote = await listBranches.call(source, input.repo);
13377
+ refs.push(...remote.map((b) => ({
13378
+ name: b.name,
13379
+ sha: b.sha,
13380
+ where: "remote"
13381
+ })));
13382
+ }
13383
+ const [openPullRequests, closedPullRequests] = await Promise.all([listPullRequests.call(source, "open", input.repo), listPullRequests.call(source, "closed", input.repo)]);
13384
+ const classification = await classifyBranches({
13385
+ branches: refs,
13386
+ git,
13387
+ excluded: (ref) => {
13388
+ if (BASE_BRANCHES.includes(ref.name)) return "base";
13389
+ if (ref.where === "remote") return void 0;
13390
+ if (ref.name === current) return "current";
13391
+ return worktrees.has(ref.name) ? "worktree" : void 0;
13392
+ },
13393
+ openPullRequests,
13394
+ closedPullRequests,
13395
+ pullRequestCommits: (number) => listPullRequestCommits.call(source, number, input.repo)
13396
+ });
13397
+ const entries = groupBranches(classification.classified);
13398
+ const report = {
13399
+ classification,
13400
+ deleted: [],
13401
+ failed: [],
13402
+ status: "ok"
13403
+ };
13404
+ print("");
13405
+ for (const group of GROUPS) {
13406
+ const rows = entries.filter((e) => e.group === group);
13407
+ const line = `${rows.length} ${GROUP_LABEL[group]}`;
13408
+ print(SAFE.includes(group) ? style.success(line) : style.warn(line));
13409
+ for (const row of rows) print(` ${rowLabel(row)}`);
13410
+ }
13411
+ if (classification.skipped.length > 0) {
13412
+ print(style.dim(`${classification.skipped.length} skipped`));
13413
+ for (const { ref, reason } of classification.skipped) print(style.dim(` ${ref.name} [${ref.where}] ${SKIP_LABEL[reason]}`));
13414
+ }
13415
+ print("");
13416
+ const safe = entries.filter((e) => SAFE.includes(e.group));
13417
+ if (input.context.dryRun === true) {
13418
+ print(style.dim(`Dry run: ${safe.length} branches are proven merged. Nothing was deleted.`));
13419
+ logger.info({
13420
+ proven: safe.length,
13421
+ deleted: 0
13422
+ }, "repo cleanup branches: dry run");
13423
+ return report;
13424
+ }
13425
+ if (entries.length === 0) return report;
13426
+ let chosen = safe;
13427
+ if (input.yes !== true) {
13428
+ if (!process.stdin.isTTY) throw new NonInteractiveError("`repo cleanup branches` asks which branches to delete — run it in a terminal, or pass --yes to delete the proven-merged ones, or --dry-run to only list them");
13429
+ if (!await confirm({
13430
+ message: "Choose branches to delete?",
13431
+ default: true
13432
+ })) return report;
13433
+ chosen = (await checkbox({
13434
+ message: "Delete which branches? (the proven-merged ones are ticked)",
13435
+ pageSize: 20,
13436
+ choices: GROUPS.flatMap((group) => {
13437
+ const rows = entries.filter((e) => e.group === group);
13438
+ if (rows.length === 0) return [];
13439
+ return [new Separator(`── ${GROUP_LABEL[group]} (${rows.length})`), ...rows.map((row) => ({
13440
+ name: rowLabel(row),
13441
+ value: entries.indexOf(row),
13442
+ checked: SAFE.includes(group)
13443
+ }))];
13444
+ })
13445
+ })).map((index) => entries[index]);
13446
+ }
13447
+ for (const entry of chosen) for (const where of entry.locations) try {
13448
+ if (where === "local") git.deleteBranch(entry.name);
13449
+ else await deleteBranch.call(source, entry.name, input.repo);
13450
+ report.deleted.push({
13451
+ name: entry.name,
13452
+ where
13453
+ });
13454
+ } catch (err) {
13455
+ report.failed.push({
13456
+ name: entry.name,
13457
+ where,
13458
+ message: errorMessage(err)
13459
+ });
13460
+ }
13461
+ for (const { name, where, message } of report.failed) print(style.fail(`${name} [${where}]: ${message}`));
13462
+ print(`Deleted ${report.deleted.length} of ${report.deleted.length + report.failed.length} branches.`);
13463
+ if (report.failed.length > 0) report.status = "fail";
13464
+ logger.info({
13465
+ deleted: report.deleted.length,
13466
+ failed: report.failed.length
13467
+ }, "repo cleanup branches: done");
13468
+ return report;
13469
+ }
13470
+ // src/commands/repo-cleanup-branches/repo-cleanup-branches.args.ts
13471
+ const repoCleanupBranchesArgs = (y) => y.option("local", {
13472
+ type: "boolean",
13473
+ describe: "Only the branches in this checkout (with neither --local nor --remote: both)"
13474
+ }).option("remote", {
13475
+ type: "boolean",
13476
+ describe: "Only the branches on the remote (with neither --local nor --remote: both)"
13477
+ }).option("yes", {
13478
+ type: "boolean",
13479
+ describe: "Delete every branch proven merged without asking. Without it a checklist asks."
13480
+ }).option("repo", {
13481
+ type: "string",
13482
+ describe: "Repo coords (\"owner/name\") to look branches and pull requests up in. Defaults to plugin-specific resolution."
13483
+ });
13484
+ // src/commands/repo-cleanup-branches/repo-cleanup-branches.command.ts
13485
+ const repoCleanupBranchesCommand = {
13486
+ command: "branches",
13487
+ describe: "List the branches whose pull request is merged and delete the ones you pick (local, remote or both)",
13488
+ builder: repoCleanupBranchesArgs,
13489
+ handler: async (argv) => {
13490
+ const tokens = tokenContext(argv.token);
13491
+ if (!tokens) return;
13492
+ const loaded = await loadConfig(argv.cwd);
13493
+ applyResolvedConfig(argv, loaded.resolved);
13494
+ if ((await runCleanupBranches({
13495
+ loaded,
13496
+ context: {
13497
+ repoRoot: argv.cwd,
13498
+ dryRun: argv.dryRun,
13499
+ ...tokens,
13500
+ org: resolveOrg(argv, loaded.resolved)
13501
+ },
13502
+ scope: argv.local && !argv.remote ? "local" : argv.remote && !argv.local ? "remote" : "both",
13503
+ ...argv.yes ? { yes: true } : {},
13504
+ ...argv.repo ? { repo: argv.repo } : {}
13505
+ })).status === "fail") process.exitCode = 1;
13506
+ }
13507
+ };
13508
+ // src/commands/repo/repo-cleanup.command.ts
13509
+ const repoCleanupCommand = {
13510
+ command: "cleanup",
13511
+ describe: "Clean up what a repo accumulates (merged branches)",
13512
+ builder: (y) => y.command(repoCleanupBranchesCommand).command(groupMenu("repo cleanup")),
13513
+ handler: () => {}
13514
+ };
12999
13515
  // src/commands/sync-readme/generate-readme.ts
13000
13516
  const SCRIPT_ORDER = [
13001
13517
  "build",
@@ -13700,9 +14216,12 @@ async function runSync(input) {
13700
14216
  print(formatSyncStep(steps[steps.length - 1]));
13701
14217
  }
13702
14218
  if (stepName === "workflows") {
13703
- const rawTaskEntries = config.tasks ?? [];
13704
- const taskEntries = rawTaskEntries.length === 0 ? rawTaskEntries : withAutoPreviewDeployPaths(rawTaskEntries, gitRoot);
13705
- if (taskEntries.length === 0) {
14219
+ const entries = generateWorkflowFiles({
14220
+ loaded: input.loaded,
14221
+ repoRoot: input.context.repoRoot,
14222
+ logger
14223
+ });
14224
+ if ((config.tasks ?? []).length === 0) {
13706
14225
  steps.push({
13707
14226
  capability: "local",
13708
14227
  step: "sync workflows",
@@ -13710,39 +14229,22 @@ async function runSync(input) {
13710
14229
  message: "no tasks configured"
13711
14230
  });
13712
14231
  print(formatSyncStep(steps[steps.length - 1]));
13713
- } else {
13714
- const files = createAstromech({
13715
- cwd: input.context.repoRoot,
13716
- config: { tasks: taskEntries },
13717
- orgContext: {
13718
- org: config.org,
13719
- domain: config.domain
13720
- },
13721
- logger
13722
- }).thinCallers();
13723
- for (const entry of taskEntries) {
13724
- const name = typeof entry === "string" ? entry : entry.name;
13725
- const isCombinedContentOnly = name === "knowledge.docs" || name === "knowledge.components";
13726
- if (!KNOWN_WORKFLOWS.has(name) && !isCombinedContentOnly) {
13727
- steps.push({
13728
- capability: "local",
13729
- step: `sync workflow ${name}`,
13730
- status: "skip",
13731
- message: `unknown workflow "${name}" — no template available`
13732
- });
13733
- print(formatSyncStep(steps[steps.length - 1]));
13734
- continue;
13735
- }
13736
- const filename = `${name}.yml`;
13737
- const content = files.get(filename);
13738
- if (content === void 0) continue;
13739
- const step = `sync workflow ${name}${content.includes("workflows/preview.yml@main") ? " (with preview)" : ""}`;
13740
- steps.push(await runSyncStep("local", step, dryRun, async () => {
13741
- await assertNoPackageCollision(name, pkgRelPath, filename, () => readExistingWorkflowFile(gitRoot, filename));
13742
- await writeWorkflowFile(gitRoot, filename, thinCallerFile(pkgRelPath, content));
14232
+ }
14233
+ for (const entry of entries) {
14234
+ if (entry.kind === "skip") steps.push({
14235
+ capability: "local",
14236
+ step: entry.syncStep,
14237
+ status: "skip",
14238
+ message: entry.message
14239
+ });
14240
+ else {
14241
+ const { task, filename } = entry.workflow;
14242
+ steps.push(await runSyncStep("local", entry.syncStep, dryRun, async () => {
14243
+ await assertNoPackageCollision(task, pkgRelPath, filename, () => readExistingWorkflowFile(gitRoot, filename));
14244
+ await writeWorkflowFile(gitRoot, filename, entry.content);
13743
14245
  }));
13744
- print(formatSyncStep(steps[steps.length - 1]));
13745
14246
  }
14247
+ print(formatSyncStep(steps[steps.length - 1]));
13746
14248
  }
13747
14249
  }
13748
14250
  if (stepName === "scripts") {
@@ -13785,45 +14287,21 @@ async function runSync(input) {
13785
14287
  print(formatSyncStep(steps[steps.length - 1]));
13786
14288
  continue;
13787
14289
  }
13788
- const astromechTurbo = createAstromech({
13789
- cwd: input.context.repoRoot,
13790
- config: { tasks: config.tasks },
14290
+ for (const entry of await generateTurboFiles({
14291
+ loaded: input.loaded,
14292
+ repoRoot: input.context.repoRoot,
13791
14293
  logger
13792
- });
13793
- const content = astromechTurbo.turboConfig();
13794
- if (content === null) {
13795
- steps.push({
14294
+ })) {
14295
+ if (entry.kind === "skip") steps.push({
13796
14296
  capability: "local",
13797
- step: "sync turbo.json",
14297
+ step: entry.syncStep,
13798
14298
  status: "skip",
13799
- message: "no fan-out-eligible tasks configured"
14299
+ message: entry.message
13800
14300
  });
13801
- print(formatSyncStep(steps[steps.length - 1]));
13802
- } else {
13803
- steps.push(await runSyncStep("local", "sync turbo.json", dryRun, async () => {
13804
- await writeFile(join(gitRoot, "turbo.json"), content, "utf8");
14301
+ else steps.push(await runSyncStep("local", entry.syncStep, dryRun, async () => {
14302
+ await writeFile(join(gitRoot, entry.path), entry.content, "utf8");
13805
14303
  }));
13806
14304
  print(formatSyncStep(steps[steps.length - 1]));
13807
- const rootPkgRaw = await readFile(join(gitRoot, "package.json"), "utf8").catch(() => null);
13808
- const rootPkg = rootPkgRaw ? JSON.parse(rootPkgRaw) : null;
13809
- const workspaceYaml = await readFile(join(gitRoot, "pnpm-workspace.yaml"), "utf8").catch(() => "");
13810
- const rootScripts = rootPkg?.scripts ?? {};
13811
- const workspaceFix = astromechTurbo.ensureRootWorkspaceMember(workspaceYaml, rootScripts);
13812
- if (workspaceFix.changed) {
13813
- steps.push(await runSyncStep("local", "fix pnpm-workspace.yaml (root workspace member, #692)", dryRun, async () => {
13814
- await writeFile(join(gitRoot, "pnpm-workspace.yaml"), workspaceFix.content, "utf8");
13815
- }));
13816
- print(formatSyncStep(steps[steps.length - 1]));
13817
- }
13818
- if (rootPkgRaw) {
13819
- const depFix = astromechTurbo.ensureTurboDependency(rootPkgRaw, workspaceFix.content);
13820
- if (depFix.changed) {
13821
- steps.push(await runSyncStep("local", "add turbo devDependency", dryRun, async () => {
13822
- await writeFile(join(gitRoot, "package.json"), depFix.content, "utf8");
13823
- }));
13824
- print(formatSyncStep(steps[steps.length - 1]));
13825
- }
13826
- }
13827
14305
  }
13828
14306
  }
13829
14307
  if (stepName === "wiki") {
@@ -14548,8 +15026,8 @@ const repoUpgradeCommand = {
14548
15026
  // src/commands/repo/repo.command.ts
14549
15027
  const repoCommand = {
14550
15028
  command: "repo",
14551
- describe: "Set up, sync and upgrade the current repo",
14552
- builder: (y) => y.command(setupCommand).command(repoSyncCommand).command(repoUpgradeCommand).command(groupMenu("repo")),
15029
+ describe: "Set up, sync, upgrade and clean up the current repo",
15030
+ builder: (y) => y.command(setupCommand).command(repoSyncCommand).command(repoUpgradeCommand).command(repoCleanupCommand).command(groupMenu("repo")),
14553
15031
  handler: () => {}
14554
15032
  };
14555
15033
  // src/commands/run/run.args.ts