@theholocron/cli 5.0.0-alpha.504 → 5.0.0-alpha.505
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +360 -319
- package/dist/cli.mjs.map +1 -1
- package/package.json +11 -11
package/dist/cli.mjs
CHANGED
|
@@ -20080,6 +20080,294 @@ async function handOffHeartbeats(input) {
|
|
|
20080
20080
|
reason: "file-left"
|
|
20081
20081
|
};
|
|
20082
20082
|
}
|
|
20083
|
+
// src/commands/probe/tasks/script-keys.ts
|
|
20084
|
+
/**
|
|
20085
|
+
* The keys of the object `field` (`scripts` in a `package.json`, `tasks` in a `turbo.json`) with their lines; none when
|
|
20086
|
+
* the text is not JSON or has no such object.
|
|
20087
|
+
*/
|
|
20088
|
+
function scriptKeys(text, field) {
|
|
20089
|
+
let value;
|
|
20090
|
+
try {
|
|
20091
|
+
value = JSON.parse(text)[field];
|
|
20092
|
+
} catch {
|
|
20093
|
+
return [];
|
|
20094
|
+
}
|
|
20095
|
+
if (typeof value !== "object" || value === null) return [];
|
|
20096
|
+
const lines = text.split("\n");
|
|
20097
|
+
const start = lines.findIndex((l) => l.includes(`"${field}"`));
|
|
20098
|
+
return Object.keys(value).map((key) => ({
|
|
20099
|
+
key,
|
|
20100
|
+
line: lines.findIndex((l, i) => i > start && l.trimStart().startsWith(`"${key}"`)) + 1
|
|
20101
|
+
}));
|
|
20102
|
+
}
|
|
20103
|
+
// src/commands/probe/tasks/find-reserved.ts
|
|
20104
|
+
/** What to use instead of a reserved script name: `publish` has a task of its own, the rest are never tasks. */
|
|
20105
|
+
function instead(name) {
|
|
20106
|
+
return name === "publish" ? "release (`publish` is reserved by npm and pnpm)" : "(reserved by npm and pnpm, never a task)";
|
|
20107
|
+
}
|
|
20108
|
+
/**
|
|
20109
|
+
* Every `package.json` script named like an npm/pnpm lifecycle word (`RESERVED_SCRIPT_NAMES`): `pnpm publish` would run
|
|
20110
|
+
* it after publishing. The root `prepare` (husky) is the one allowed.
|
|
20111
|
+
*/
|
|
20112
|
+
function findReserved(file) {
|
|
20113
|
+
if (!/(^|\/)package\.json$/.test(file.path)) return [];
|
|
20114
|
+
return scriptKeys(file.text, "scripts").filter(({ key }) => RESERVED_SCRIPT_NAMES.has(key) && !(file.path === "package.json" && key === "prepare")).map(({ key, line }) => ({
|
|
20115
|
+
file: file.path,
|
|
20116
|
+
line,
|
|
20117
|
+
old: key,
|
|
20118
|
+
replacement: instead(key)
|
|
20119
|
+
}));
|
|
20120
|
+
}
|
|
20121
|
+
// src/commands/probe/tasks/find-leftovers.ts
|
|
20122
|
+
/** The commands that take a task name as their next word: `holocron run`, `turbo run`, `pnpm run`, `pnpm`, ... */
|
|
20123
|
+
const COMMAND$4 = String.raw`(?:holocron run|turbo run|pnpm run|npm run|pnpm|yarn)\s+`;
|
|
20124
|
+
/** A regex alternation of `names`, escaped; matches nothing for an empty list. */
|
|
20125
|
+
function alternation(names) {
|
|
20126
|
+
return names.length === 0 ? "(?!)" : names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
20127
|
+
}
|
|
20128
|
+
/** The field of a manifest whose keys are tasks or scripts: `scripts` in a `package.json`, `tasks` in a `turbo.json`. */
|
|
20129
|
+
function taskField(path) {
|
|
20130
|
+
return /(^|\/)package\.json$/.test(path) ? "scripts" : /(^|\/)turbo\.json$/.test(path) ? "tasks" : void 0;
|
|
20131
|
+
}
|
|
20132
|
+
/**
|
|
20133
|
+
* Every use of an old task name in `files`, with its file, line and replacement.
|
|
20134
|
+
*
|
|
20135
|
+
* - A dotted name (`delivery.build`) matches as a whole token: found in `turbo run delivery.build`, not in
|
|
20136
|
+
* `delivery.buildX`. Followed by `.yml`/`.yaml` it is a workflow file name and is left out unless `options.files`.
|
|
20137
|
+
* - A bare name (`review`, `stale`: the keys of `names` without a dot) is an ordinary word, so it is found only where it
|
|
20138
|
+
* is used as a task: after `holocron run`, `turbo run`, `pnpm` or `pnpm run`, as a `package.json` script or as a
|
|
20139
|
+
* `turbo.json` task.
|
|
20140
|
+
* - A `package.json` script named like an npm/pnpm lifecycle word is reported too (see {@link findReserved}).
|
|
20141
|
+
* - A line, or the line below one, that carries the {@link ALLOW_MARKER} is skipped.
|
|
20142
|
+
*
|
|
20143
|
+
* Files come back in the order given, lines top to bottom.
|
|
20144
|
+
*/
|
|
20145
|
+
function findLeftovers(files, names, options = {}) {
|
|
20146
|
+
const dotted = Object.keys(names).filter((n) => n.includes("."));
|
|
20147
|
+
const bare = Object.keys(names).filter((n) => !n.includes("."));
|
|
20148
|
+
const tail = options.files ? String.raw`(?![\w-])` : String.raw`(?![\w-]|\.ya?ml\b)`;
|
|
20149
|
+
const dottedPattern = new RegExp(`(?<![\\w.-])(${alternation(dotted)})${tail}`, "g");
|
|
20150
|
+
const barePattern = new RegExp(`(?<![\\w.-])${COMMAND$4}(${alternation(bare)})(?![\\w:-]|\\.\\w)`, "g");
|
|
20151
|
+
return files.flatMap((file) => {
|
|
20152
|
+
const lines = file.text.split("\n");
|
|
20153
|
+
const field = taskField(file.path);
|
|
20154
|
+
const inText = lines.flatMap((text, i) => [...text.matchAll(dottedPattern), ...text.matchAll(barePattern)].map((m) => ({
|
|
20155
|
+
file: file.path,
|
|
20156
|
+
line: i + 1,
|
|
20157
|
+
old: m[1],
|
|
20158
|
+
replacement: names[m[1]]
|
|
20159
|
+
})));
|
|
20160
|
+
const asKey = (field === void 0 ? [] : scriptKeys(file.text, field)).filter(({ key }) => bare.includes(key)).map(({ key, line }) => ({
|
|
20161
|
+
file: file.path,
|
|
20162
|
+
line,
|
|
20163
|
+
old: key,
|
|
20164
|
+
replacement: names[key]
|
|
20165
|
+
}));
|
|
20166
|
+
const seen = /* @__PURE__ */ new Set();
|
|
20167
|
+
return [
|
|
20168
|
+
...inText,
|
|
20169
|
+
...asKey,
|
|
20170
|
+
...findReserved(file)
|
|
20171
|
+
].sort((a, b) => a.line - b.line).filter(({ line, old }) => !seen.has(`${line}:${old}`) && seen.add(`${line}:${old}`)).filter(({ line }) => !lines[line - 1].includes("holocron-allow-old-name") && !lines[line - 2]?.includes("holocron-allow-old-name"));
|
|
20172
|
+
});
|
|
20173
|
+
}
|
|
20174
|
+
// src/commands/probe/tasks/is-generated.ts
|
|
20175
|
+
/** Whether a file carries the generated-file header in its first lines; drift in those is `probe generated check`'s to report. */
|
|
20176
|
+
function isGenerated(text) {
|
|
20177
|
+
return text.split("\n", 3).some((line) => line.includes("AUTO-GENERATED"));
|
|
20178
|
+
}
|
|
20179
|
+
// src/commands/probe/tasks/is-scanned.ts
|
|
20180
|
+
/** Files that describe the old names on purpose: specs, ADRs, the changelog, tests, and this probe's own folder. */
|
|
20181
|
+
const SKIPPED = [
|
|
20182
|
+
/(^|\/)CHANGELOG\.md$/,
|
|
20183
|
+
/^\.notes\//,
|
|
20184
|
+
/^docs\/wiki\//,
|
|
20185
|
+
/\.test\.tsx?$/,
|
|
20186
|
+
/^cli\/cli\/src\/commands\/probe\/tasks\//
|
|
20187
|
+
];
|
|
20188
|
+
/** The kinds of file the probe reads: workflows, scripts, docs, configs, hooks and manifests. */
|
|
20189
|
+
const SCANNED = [
|
|
20190
|
+
/^\.github\/(workflows|actions)\/.+\.ya?ml$/,
|
|
20191
|
+
/^\.husky\//,
|
|
20192
|
+
/^scripts\//,
|
|
20193
|
+
/(^|\/)(package|turbo)\.json$/,
|
|
20194
|
+
/(^|\/)(holocron|astromech)\.config\.[cm]?[jt]s$/,
|
|
20195
|
+
/(^|\/)\.lintstagedrc/,
|
|
20196
|
+
/\.mdx?$/
|
|
20197
|
+
];
|
|
20198
|
+
/** Whether `path` (repo-relative) is a hand-written kind of place to scan for old task names. */
|
|
20199
|
+
function isScanned(path) {
|
|
20200
|
+
return SCANNED.some((p) => p.test(path)) && !SKIPPED.some((p) => p.test(path));
|
|
20201
|
+
}
|
|
20202
|
+
// src/commands/probe/tasks/legacy-replacements.ts
|
|
20203
|
+
/**
|
|
20204
|
+
* Each old task name astromech's `LEGACY_NAMES` still accepts, with the text the `tasks names` probe prints as its
|
|
20205
|
+
* replacement: the flat ids it became, in run order. A successor that adds args (`format --check`, the read-only
|
|
20206
|
+
* prettier half of `sourceQuality.formatting`) is named last, in parentheses: `lint:editorconfig, lint:markdown (format
|
|
20207
|
+
* for prettier)`. A name that is a suite now (`validate`, once the interim id of `platform.repoValidation`) is left out:
|
|
20208
|
+
* `holocron run validate` is the suite, not a leftover.
|
|
20209
|
+
*/
|
|
20210
|
+
function legacyReplacements() {
|
|
20211
|
+
return Object.fromEntries(Object.entries(LEGACY_NAMES).filter(([old]) => !SUITES.includes(old)).map(([old, targets]) => {
|
|
20212
|
+
const own = targets.filter((t) => t.passthrough === void 0).map((t) => t.id);
|
|
20213
|
+
const checked = targets.filter((t) => t.passthrough !== void 0).map((t) => `${t.id} for prettier`);
|
|
20214
|
+
return [old, checked.length === 0 ? own.join(", ") : `${own.join(", ")} (${checked.join(", ")})`];
|
|
20215
|
+
}));
|
|
20216
|
+
}
|
|
20217
|
+
// src/commands/probe/tasks/real-tasks-io.ts
|
|
20218
|
+
/** The `tasks names` probe's inputs from the tracked files under `repoRoot`. */
|
|
20219
|
+
function realTasksIo(repoRoot) {
|
|
20220
|
+
/* v8 ignore start -- reads git and the real filesystem; the probe is tested with an injected io */
|
|
20221
|
+
return { files: () => execFileSync("git", ["ls-files", "-z"], {
|
|
20222
|
+
cwd: repoRoot,
|
|
20223
|
+
encoding: "utf8",
|
|
20224
|
+
maxBuffer: 67108864
|
|
20225
|
+
}).split("\0").filter((path) => path !== "" && isScanned(path)).flatMap((path) => {
|
|
20226
|
+
try {
|
|
20227
|
+
const text = readFileSync(join(repoRoot, path), "utf8");
|
|
20228
|
+
return isGenerated(text) ? [] : [{
|
|
20229
|
+
path,
|
|
20230
|
+
text
|
|
20231
|
+
}];
|
|
20232
|
+
} catch {
|
|
20233
|
+
return [];
|
|
20234
|
+
}
|
|
20235
|
+
}) };
|
|
20236
|
+
/* v8 ignore stop */
|
|
20237
|
+
}
|
|
20238
|
+
// src/commands/probe/tasks/tasks-probes.ts
|
|
20239
|
+
/** The group of probes that check the repo's task vocabulary. */
|
|
20240
|
+
const TASKS_PROVIDER = "tasks";
|
|
20241
|
+
/**
|
|
20242
|
+
* `tasks names`: finds the hand-written places that still use an old task name from the flat-vocabulary map
|
|
20243
|
+
* (SPEC-0064, astromech's `LEGACY_NAMES`): a dotted one (`delivery.build`, `verification.unitTests`), a bare one used as a
|
|
20244
|
+
* task (`holocron run review`, a `review` script) or a `package.json` script with a reserved npm/pnpm name (`publish`).
|
|
20245
|
+
* It scans workflows, scripts, docs, `turbo.json`, `package.json`, the configs' `tasks:` and the hooks, and reports each
|
|
20246
|
+
* with file, line and the id to use instead. Each is a failure (exit code 1); `--warn` reports them as `info` rows
|
|
20247
|
+
* instead. A dotted name that is part of a workflow file name (`delivery.build.yml`) is skipped until the files are
|
|
20248
|
+
* renamed; `--files` lists those too. An intentional mention carries the `holocron-allow-old-name` marker on its line or the line above.
|
|
20249
|
+
* Files `sync` generates are left to `generated check`; specs, ADRs and the changelog name the old tasks on purpose.
|
|
20250
|
+
*/
|
|
20251
|
+
function tasksProbes(io, names = legacyReplacements()) {
|
|
20252
|
+
return { names: {
|
|
20253
|
+
summary: "Report each use of an old task name in hand-written files; fails unless --warn; --files adds file names.",
|
|
20254
|
+
writes: false,
|
|
20255
|
+
async run(ctx) {
|
|
20256
|
+
const status = ctx.args?.includes("--warn") ? "info" : "fail";
|
|
20257
|
+
ctx.say({
|
|
20258
|
+
status: "heading",
|
|
20259
|
+
label: "Old task names"
|
|
20260
|
+
});
|
|
20261
|
+
const found = findLeftovers(io.files(), names, { files: ctx.args?.includes("--files") === true });
|
|
20262
|
+
for (const f of found) ctx.say({
|
|
20263
|
+
status,
|
|
20264
|
+
label: `${f.file}:${f.line}`,
|
|
20265
|
+
detail: `${f.old} -> ${f.replacement}`
|
|
20266
|
+
});
|
|
20267
|
+
ctx.say({
|
|
20268
|
+
status: found.length === 0 ? "ok" : status,
|
|
20269
|
+
label: "old names",
|
|
20270
|
+
detail: `${found.length} use(s) of ${Object.keys(names).length} old name(s)`
|
|
20271
|
+
});
|
|
20272
|
+
}
|
|
20273
|
+
} };
|
|
20274
|
+
}
|
|
20275
|
+
// src/commands/workflow-source-marker/workflow-source-marker.ts
|
|
20276
|
+
/** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
|
|
20277
|
+
const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
|
|
20278
|
+
/** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
|
|
20279
|
+
function sanitizeForDisplay(value) {
|
|
20280
|
+
return value.replace(/[\x00-\x1f\x7f]/g, "");
|
|
20281
|
+
}
|
|
20282
|
+
/**
|
|
20283
|
+
* Repo-root-relative path of the PACKAGE a workflow-writing command run is
|
|
20284
|
+
* scoped to — the directory holding the discovered `holocron.config.*`
|
|
20285
|
+
* (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
|
|
20286
|
+
* up to find the config from any subdirectory ("every command is usable
|
|
20287
|
+
* from any subdirectory of a repo, not only its exact root"), so a `--cwd`
|
|
20288
|
+
* one level too deep would otherwise stamp a different marker than a later
|
|
20289
|
+
* run from the package's own root and misfire the collision check this
|
|
20290
|
+
* feeds (holocron#1026).
|
|
20291
|
+
*
|
|
20292
|
+
* "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
|
|
20293
|
+
* to forward slashes so the same package produces the same marker on
|
|
20294
|
+
* Windows and POSIX. Throws if the result contains a line break — a path
|
|
20295
|
+
* containing one could otherwise break out of the `# Source package: `
|
|
20296
|
+
* comment line and inject arbitrary workflow YAML when the generated
|
|
20297
|
+
* content is later written. Not reachable through this CLI's own flows
|
|
20298
|
+
* (no code path writes a config file whose directory name contains a line
|
|
20299
|
+
* break), but cheap to reject outright rather than trust the filesystem.
|
|
20300
|
+
*/
|
|
20301
|
+
function resolvePkgRelPath(gitRoot, configFilepath) {
|
|
20302
|
+
let root;
|
|
20303
|
+
try {
|
|
20304
|
+
root = realpathSync(gitRoot);
|
|
20305
|
+
} catch {
|
|
20306
|
+
root = gitRoot;
|
|
20307
|
+
}
|
|
20308
|
+
let configDir;
|
|
20309
|
+
try {
|
|
20310
|
+
configDir = realpathSync(dirname(configFilepath));
|
|
20311
|
+
} catch {
|
|
20312
|
+
configDir = dirname(configFilepath);
|
|
20313
|
+
}
|
|
20314
|
+
const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
|
|
20315
|
+
if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
|
|
20316
|
+
return pkgRelPath;
|
|
20317
|
+
}
|
|
20318
|
+
/**
|
|
20319
|
+
* Two different monorepo packages opting into the same generic task name
|
|
20320
|
+
* (e.g. both `apps/sentinel` and some future `apps/other` configuring
|
|
20321
|
+
* `delivery.previewDeploy`) would otherwise overwrite each other's
|
|
20322
|
+
* `.github/workflows/<task>.yml` on whichever package's write ran last —
|
|
20323
|
+
* only one package's behavior would ever actually run in CI, with no
|
|
20324
|
+
* signal that the other's was silently dropped (holocron#1026).
|
|
20325
|
+
*
|
|
20326
|
+
* Shared by both `holocron sync` (reads the file straight off local
|
|
20327
|
+
* disk) and `holocron setup` (reads it through the loaded `Source`
|
|
20328
|
+
* capability, which happens to be local disk too for the github plugin
|
|
20329
|
+
* today, but the interface doesn't promise that for every provider —
|
|
20330
|
+
* holocron#1068). The marker-parsing and error message are identical
|
|
20331
|
+
* either way; `readExisting` is how the two callers differ.
|
|
20332
|
+
*
|
|
20333
|
+
* A file with no marker at all predates this check (or was written before
|
|
20334
|
+
* #1026) and is never flagged — only a marker that's present AND disagrees
|
|
20335
|
+
* with the current run's own package is a real collision. `readExisting`
|
|
20336
|
+
* returning `null` means "nothing there," not "unreadable" — a caller
|
|
20337
|
+
* whose underlying read can fail for reasons other than "doesn't exist"
|
|
20338
|
+
* (e.g. local fs EISDIR) is expected to let that error propagate out of
|
|
20339
|
+
* `readExisting` itself rather than mapping it to `null`.
|
|
20340
|
+
*/
|
|
20341
|
+
async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
|
|
20342
|
+
const existing = await readExisting();
|
|
20343
|
+
if (existing === null) return;
|
|
20344
|
+
const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
|
|
20345
|
+
if (previousPkg !== void 0 && previousPkg !== pkgRelPath) throw new Error(`task "${taskName}" would overwrite .github/workflows/${filename}, already generated for package "${sanitizeForDisplay(previousPkg)}" — the same task name can't be used by two different packages (holocron#1026). If "${sanitizeForDisplay(previousPkg)}" moved or was renamed to this path, delete .github/workflows/${filename} first and re-run this command; otherwise rename one or give it a different thin-caller filename.`);
|
|
20346
|
+
}
|
|
20347
|
+
// src/commands/obsolete-workflows/find-obsolete-workflows.ts
|
|
20348
|
+
/** The lines at the head of a generated workflow that hold the header and the `# Source package:` marker. */
|
|
20349
|
+
const HEADER_LINES = 6;
|
|
20350
|
+
/**
|
|
20351
|
+
* The workflow files in `.github/workflows` that an earlier `sync` generated and that this run no longer writes, because
|
|
20352
|
+
* their task left the config or a preset (#2338). Sorted by name.
|
|
20353
|
+
*
|
|
20354
|
+
* It names a file only when all of these hold, so a file nobody generated is never removed:
|
|
20355
|
+
* - the generator's own `AUTO-GENERATED` header is at its head;
|
|
20356
|
+
* - it is not marked `# HAND-MAINTAINED`;
|
|
20357
|
+
* - its `# Source package:` line is this run's package, so a run for `apps/sentinel` leaves the root's files alone, and a
|
|
20358
|
+
* file with no marker (written before the marker existed) is left for `probe generated check` to report;
|
|
20359
|
+
* - this run does not write it.
|
|
20360
|
+
*/
|
|
20361
|
+
function findObsoleteWorkflows({ workflows, written, pkgRelPath }) {
|
|
20362
|
+
const obsolete = [];
|
|
20363
|
+
for (const [name, text] of workflows) {
|
|
20364
|
+
if (written.has(name) || text.startsWith("# HAND-MAINTAINED") || !isGenerated(text)) continue;
|
|
20365
|
+
const head = text.split("\n", HEADER_LINES).join("\n");
|
|
20366
|
+
if (SOURCE_PACKAGE_MARKER.exec(head)?.[1] !== pkgRelPath) continue;
|
|
20367
|
+
obsolete.push(name);
|
|
20368
|
+
}
|
|
20369
|
+
return obsolete.sort();
|
|
20370
|
+
}
|
|
20083
20371
|
// ../../.holocron/org.md
|
|
20084
20372
|
var org_default = "<!-- editorconfig-checker-disable-file -->\n\n# theholocron — agent operating contract\n\nOrg-level agent conventions for all `theholocron` repositories. The canonical\ncopy is `.holocron/org.md` in `theholocron/holocron`. `holocron sync` writes\nit into each repo's `AGENTS.md` between generated markers, so no repo needs a\nsibling checkout to read it; holocron itself imports it with `@.holocron/org.md`.\nEdit it in holocron, then run `holocron sync`.\n\n## Repo map\n\nEach concern lives in exactly one repo:\n\n| Concern | Repo |\n| ----------------------------------------------------------------- | ----------------------------------------- |\n| Shareable tool config (ESLint, Prettier, TSConfig, Vitest, …) | `theholocron/holocron` (`configs/`) |\n| HTTP clients and API wrappers | `theholocron/holocron` (`clients/`) |\n| Infrastructure automation, CI orchestration, repo lifecycle | `theholocron/holocron` |\n| Org-level CI workflows, composite actions, community health files | `theholocron/.github` |\n| Internal member docs and private org config | `theholocron/.github-private` (this repo) |\n| Shared agent skills registry | `theholocron/holocron` (`skills/`) |\n\nIf you find yourself copy-pasting a tool config across repos, it belongs in\nthe `configs/` folder of `theholocron/holocron`. If you find yourself writing a new\nautomation command, it belongs in `holocron` too. Generic helpers (`utils/`) and\nobservability (`observability/`) live in that monorepo as well.\n\n### `holocron.config` format\n\n- Repos **with** a `package.json` → `holocron.config.ts` with `defineConfig`\n from `@theholocron/cli`. The CLI must be resolvable at runtime for the TS\n format to work.\n- Repos **without** a `package.json` (e.g. `.github`, `.github-private`) →\n `holocron.config.json`.\n\n## Workflow\n\n- **Always open a PR — never push directly to the default branch.** Even for\n small fixes: create a branch, push it, open a PR. This lets CI run, keeps\n history reviewable, and respects branch protection. The only exception is\n bootstrapping a brand-new repo before protection is set up.\n- **Conventional Commits.** `feat:` / `fix:` / `chore:` / `docs:` / `ci:` /\n `test:` / `refactor:` / `perf:` — semantic-release uses these for versioning\n and changelogs. Repos without a release step use the subset relevant to them.\n- **Always `git commit -s`** (DCO). The `Signed-off-by:` trailer is required\n on every commit. `-s` generates it automatically from `git config user.name`\n and `user.email`.\n- **Always rebase, never merge `main`.** Use `git rebase origin/main` to keep a\n branch current. `git merge main` creates an unsigned merge commit and drags bot\n commits into the PR history — both trigger DCO check failures.\n- **No Claude attribution** in commits, PRs, issues, or docs. No\n `Co-Authored-By` trailer. The author is the user.\n- **One PR = one focused change.** Squash-merge; the PR title becomes the\n squashed commit subject that semantic-release reads.\n- **File issues for non-trivial work** and reference them in commits/PRs\n (`Closes #N` / `Refs #N`). Skip for typo fixes.\n- **Spec process: Issue before spec.** Before writing a spec file, file an issue\n first, in the tracker the config's `issues` provider names (GitHub when the\n config sets no `issues` provider). The issue is the durable tracking artifact.\n The spec's frontmatter `issue:` field must reference it. Order: Issue → Spec →\n PR → Review → merge.\n- **Reference the issue in that tracker's syntax** in commits and the PR: `Closes #N`\n / `Refs #N` for GitHub, the issue key (`Closes ENG-42` / `Refs ENG-42`) for Linear.\n\n## Before starting any coding task\n\n1. Verify you are on a feature branch, not `main`. If on `main`, create a branch\n first. Never commit directly to `main`. If on an existing feature branch, run\n `git fetch origin && git rebase origin/main` to ensure it has the latest from\n `main` — never start work on a stale branch.\n2. Any PR that adds new behavior must include tests and documentation in the same\n PR. Do not open docs-only or test-only follow-up PRs — tests and docs ship with\n the feature. This applies to new packages, capabilities, commands, APIs, and\n any observable behavior change.\n3. If adding a new client or plugin package, update the docs-theme registry in\n the same PR or a cleanly scoped immediate follow-up.\n4. One PR per logical change. Do not bundle unrelated fixes with a feature.\n\n## After completing any coding task\n\n1. Confirm you are still on the intended feature branch.\n2. Confirm all checklist items in any invoked skill are complete.\n3. Confirm CI is green before requesting review.\n\n## Keeping the project board true\n\nThe board's statuses follow the pull request, so an agent only starts the work and marks the pull request ready.\n\n1. **Starting an issue:** `holocron start work <issue>` makes the branch, the first commit and a draft pull request,\n and the open pull request moves the board to In Progress. Only while the automation is down, set it by hand with\n `holocron update work <issue> --status \"In Progress\"` (a hand-set status is temporary).\n2. **Open the pull request as a draft** (`start work` does; otherwise `gh pr create --draft`) as soon as there is\n something to push.\n3. **When the `ci / Required checks` aggregate is green, mark it ready** with `holocron close work <issue> --wait` (it\n waits for the aggregate, marks the pull request ready and never merges; `gh pr ready` does the same by hand). The\n board moves to In Review by itself. After the maintainer merges, run `holocron close work <issue>` again to remove\n the worktree and the local branch.\n4. **Never set In Review, Blocked or Done by hand.** The rules own them; Blocked comes from a blocked-by link, never\n from the status.\n\n## CI workflows\n\nAll reusable workflow implementations and composite actions **live as source in\n`theholocron/holocron` — `packages/astromech/src/templates/reusable/`** and are\ngenerated + pushed to `theholocron/.github` by `holocron sync github`.\n**`theholocron/.github` and `.github-private` are pure sync targets** — never\nhand-edit their `.github/workflows/*`, `.github/actions/*` or\n`workflow-templates/*`; edit the source in `holocron` and merge.\n\nEvery other repo (`configs`, `clients`, `holocron`, `.github-private`) gets\n**thin callers** — lightweight `.github/workflows/` files that delegate to\n`.github` via `uses: theholocron/.github/.github/workflows/<name>.yml@main` and\n`secrets: inherit`. Thin callers are generated from the manifest by\n`astromech.thinCallers()` (`holocron sync` / `holocron setup`).\n\n### Sync\n\nThe `sync-workflow-templates` workflow in `theholocron/holocron` keeps thin\ncallers up to date. It runs automatically on push to `main` when\n`packages/cli/src/templates/**` or `packages/astromech/src/templates/**` change.\nChanges to other parts of the sync machinery (e.g. `sync-github.ts`) require a\nmanual dispatch:\n\n```sh\ngh workflow run sync-workflow-templates.yml --repo theholocron/holocron --ref main\n```\n\n### Per-repo task list\n\nEach secondary repo controls which tasks (and their CI workflows) it\nreceives — and can supply per-task `with:` overrides — via the `tasks`\narray in its `holocron.config.ts` (or `holocron.config.json`).\n`@theholocron/astromech` reads it as the single source for `holocron run`\n/ `holocron run ci` / the generated workflow thin callers:\n\n```typescript\ntasks: [\"lint\", { name: \"release\", with: { \"run-build\": false } }];\n```\n\nOnly add a task if the corresponding capability exists in the repo:\n\n| Task | Requires |\n| ------------- | ------------------------------------------------- |\n| `test` | vitest suite with `--coverage` |\n| `typecheck` | TypeScript (`pnpm typecheck` script) |\n| `audit` | a bundle build step (`pnpm build` script) |\n| `sync-github` | `packages/cli/src/templates/**` — `holocron` only |\n\n### Release workflow — npm prefix and registry-url\n\n**Never run `npm config set prefix <path>` in a release workflow.** It writes\n`prefix=<path>` to `~/.npmrc`, which pnpm reads for npm configuration. With a\nnon-default prefix set, pnpm cannot locate the registry auth it needs to perform\nthe GitHub OIDC token exchange and fails with `ENEEDAUTH` — even when Trusted\nPublishers are correctly configured on npmjs.com.\n\nNode.js from `hostedtoolcache` already provides a user-writable npm prefix on\nPATH. Run `npm install -g <pkg>` directly.\n\n**Never cache `~/.npm-global` or any npm global directory in release workflows.**\nA stale cache restores old auth config that poisons the OIDC exchange.\n\n**Never set `registry-url` in the shared `setup-node` composite action.** It\ncauses `actions/setup-node` to write `//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}`\nto a temp `.npmrc` and set `NPM_CONFIG_USERCONFIG` pointing at it. pnpm then\nreads that file, fails env-var substitution when the token is empty, and loses\nauth entirely.\n\nThe reference implementation is `theholocron/holocron`'s own release workflow —\nno prefix step, no cache, no `registry-url`.\n\n### Discarding a bad sync PR\n\n**Delete the branch, don't only close the PR.** A closed-but-existing branch\nblocks future PR creation — GitHub returns 422 \"A pull request already exists\"\nand the sync silently skips opening a new one.\n\n```sh\ngh pr close <n> --repo <owner>/<repo> --delete-branch\n```\n\n## Code standards\n\n### Package manager\n\n**pnpm only.** Never use `npm` or `yarn`. Run workspace-wide tasks through\nTurbo (`pnpm test`, `pnpm build`, etc.); run single-package tasks with\n`pnpm --filter <name> <script>`.\n\n### TypeScript\n\n**No `any`.** Use `unknown` for values of genuinely unknown shape and narrow\nwith type guards. Use generics instead of `any` in function signatures.\n`as never` and `as unknown as T` are acceptable for internal casts where the\ntype system can't follow; `any` is not.\n\n### Node.js version\n\n`engines.node` must be set in every `package.json`. To update the Node.js\nversion across a repo run `holocron upgrade node <to>` from any repo that has\nthe CLI installed — it patches `engines.node`, `@types/node`, `.nvmrc`,\n`.node-version`, and `.github/workflows/*.yml` automatically.\n\n### Inclusive language (`alex`)\n\n`holocron setup` no longer writes `.alexrc.json` or `.alexignore` (#831). The\ncheck is Sentinel's `lint:language / Run alex`, which reads the org's own\nallow-list, `alexrc.json` in `theholocron/holocron · cli/astromech/src/lint/alex-config/`\n(`ALEX_CONFIG`). To allow a new term across all repos: edit that file, open a PR\nin `holocron`, merge; Sentinel uses it after its next deploy. A repo that still\nhas the two files from an earlier setup can delete them; nothing reads them.\n\n### Running `holocron setup`\n\nInstall `@theholocron/cli` and `@theholocron/holocron-plugin-github` under\n`catalogs.holocron` in `pnpm-workspace.yaml`:\n\n```yaml\ncatalogs:\n holocron:\n \"@theholocron/cli\": <version>\n \"@theholocron/holocron-plugin-github\": <version>\n```\n\nThen run:\n\n```sh\nGITHUB_TOKEN=$(gh auth token) \\\nHOLOCRON_ORG_TOKEN=$(security find-generic-password -s \"com.theholocron.cli\" -a \"github.org\" -w) \\\npnpm exec holocron setup --token $(security find-generic-password -s \"com.theholocron.cli\" -a \"github.admin\" -w)\n```\n\nAll tokens are stored in the macOS keychain under service `com.theholocron.cli`. See `docs/tokens.md` in the `holocron` repo for the full token matrix and required scopes.\n\nBump both catalog entries together when upgrading — they publish in lockstep.\n\n### README structure\n\nEvery repo README follows this layout. Use `holocron sync readme` to regenerate the Installation + Usage block automatically.\n\n```markdown\n# Package Name\n\n<!-- holocron:description -->\n\nOne-line description (synced from holocron.config.ts description field).\n<!-- /holocron:description -->\n\n<!-- holocron:installation -->\n\n## Installation\n\n...generated from package.json bin / exports...\n\n## Usage\n\n...generated from package.json bin / exports...\n<!-- /holocron:installation -->\n\n## What's Included ← template repos only; omit for libraries\n\n...feature table...\n\n## Development\n\npnpm scripts table or code block\n\n## Releases\n\nAutomated via semantic-release. Link to CHANGELOG.md.\n\n## Documentation\n\nLink to docs site.\n```\n\n**Rules:**\n\n- Never write \"Getting Started\" — use separate \"Installation\" and \"Usage\" headings.\n- The `<!-- holocron:description -->` and `<!-- holocron:installation -->` marker blocks must stay in sync with the config/package; run `holocron sync readme` after changing `description` in `holocron.config.ts` or `bin` in `package.json`.\n- The \"What's Included\" section belongs only in template repos (cli-template, node-template, react-template, etc.) where it describes what the template ships. Library and app repos omit it.\n\n---\n\n## This repo (`.github-private`)\n\n> **Local path:** `~/Code/theholocron/github-private/`\n> **GitHub repo:** `theholocron/.github-private`\n\nInternal member documentation and private org-level configuration for the\n`theholocron` org. Content here is only visible to org members.\n\nConventional Commit types used here: `docs:` for content changes, `ci:` for\nworkflow changes, `chore:` for maintenance.\n\nNo test suite (documentation repo). `pnpm lint` runs `yamllint` on workflow\nfiles. Branch protection on `main` requires DCO and passing CI checks.\n";
|
|
20085
20373
|
// src/commands/repo-files/generate-agent-files.ts
|
|
@@ -20441,97 +20729,25 @@ function withAutoPreviewDeployPaths(tasks, gitRoot) {
|
|
|
20441
20729
|
if (!paths) return entry;
|
|
20442
20730
|
return {
|
|
20443
20731
|
...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`.
|
|
20732
|
+
with: {
|
|
20733
|
+
...entry.with,
|
|
20734
|
+
paths
|
|
20735
|
+
}
|
|
20736
|
+
};
|
|
20737
|
+
});
|
|
20738
|
+
}
|
|
20739
|
+
// src/commands/thin-caller-file/thin-caller-file.ts
|
|
20740
|
+
const { workflowHeader } = createHeader({
|
|
20741
|
+
source: "cli/astromech/src/generators/github-action-thin-callers/github-action-thin-callers.ts",
|
|
20742
|
+
tool: "holocron sync"
|
|
20743
|
+
});
|
|
20744
|
+
/**
|
|
20745
|
+
* The text of a generated thin-caller workflow: the AUTO-GENERATED header, the `# Source package:` marker (see
|
|
20746
|
+
* `resolvePkgRelPath`) and the workflow itself. Both `setup` and `sync` write their workflows through
|
|
20747
|
+
* this, so the file is the same whichever command wrote it.
|
|
20529
20748
|
*/
|
|
20530
|
-
|
|
20531
|
-
|
|
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.`);
|
|
20749
|
+
function thinCallerFile(pkgRelPath, content) {
|
|
20750
|
+
return `${workflowHeader()}# Source package: ${pkgRelPath}\n\n${content}`;
|
|
20535
20751
|
}
|
|
20536
20752
|
// src/commands/repo-files/generate-workflow-files.ts
|
|
20537
20753
|
/**
|
|
@@ -21689,14 +21905,15 @@ async function runSetup(input) {
|
|
|
21689
21905
|
if (loader.has("source")) {
|
|
21690
21906
|
const source = loader.get("source");
|
|
21691
21907
|
if (config.tasks && config.tasks.length > 0) print(style.step("workflows"));
|
|
21692
|
-
|
|
21908
|
+
const generatedEntries = await generateRepoFiles({
|
|
21693
21909
|
loaded: input.loaded,
|
|
21694
21910
|
repoRoot: input.context.repoRoot,
|
|
21695
21911
|
hooks: input.hooks,
|
|
21696
21912
|
...statusContexts ? { statusContexts } : {},
|
|
21697
21913
|
...coverageFiles ? { coverageConfigFiles: coverageFiles } : {},
|
|
21698
21914
|
logger
|
|
21699
|
-
})
|
|
21915
|
+
});
|
|
21916
|
+
for (const entry of generatedEntries) {
|
|
21700
21917
|
if (entry.kind === "skip") steps.push({
|
|
21701
21918
|
capability: "source",
|
|
21702
21919
|
step: entry.step,
|
|
@@ -21722,6 +21939,46 @@ async function runSetup(input) {
|
|
|
21722
21939
|
print(formatStep(steps[steps.length - 1]));
|
|
21723
21940
|
}
|
|
21724
21941
|
}
|
|
21942
|
+
if ((config.tasks ?? []).length > 0) {
|
|
21943
|
+
const written = /* @__PURE__ */ new Set();
|
|
21944
|
+
let unaccounted = false;
|
|
21945
|
+
for (const entry of generatedEntries) if (entry.kind === "file" && entry.workflow) written.add(entry.workflow.filename);
|
|
21946
|
+
else if (entry.kind === "skip" && entry.step.startsWith("write workflow ")) unaccounted = true;
|
|
21947
|
+
if (unaccounted) {
|
|
21948
|
+
steps.push({
|
|
21949
|
+
capability: "source",
|
|
21950
|
+
step: "remove obsolete workflows",
|
|
21951
|
+
status: "skip",
|
|
21952
|
+
message: "a task has no template, so no workflow is removed"
|
|
21953
|
+
});
|
|
21954
|
+
print(formatStep(steps[steps.length - 1]));
|
|
21955
|
+
} else try {
|
|
21956
|
+
const workflows = /* @__PURE__ */ new Map();
|
|
21957
|
+
for (const name of await source.listWorkflowFiles()) {
|
|
21958
|
+
const text = await source.readWorkflowFile(name);
|
|
21959
|
+
if (text !== null) workflows.set(name, text);
|
|
21960
|
+
}
|
|
21961
|
+
const obsolete = findObsoleteWorkflows({
|
|
21962
|
+
workflows,
|
|
21963
|
+
written,
|
|
21964
|
+
pkgRelPath: setupPkgRelPath
|
|
21965
|
+
});
|
|
21966
|
+
for (const filename of obsolete) {
|
|
21967
|
+
steps.push(await runStep("source", `remove obsolete workflow ${filename}`, dryRun, async () => {
|
|
21968
|
+
await source.removeWorkflowFile(filename);
|
|
21969
|
+
}));
|
|
21970
|
+
print(formatStep(steps[steps.length - 1]));
|
|
21971
|
+
}
|
|
21972
|
+
} catch (err) {
|
|
21973
|
+
steps.push({
|
|
21974
|
+
capability: "source",
|
|
21975
|
+
step: "remove obsolete workflows",
|
|
21976
|
+
status: "fail",
|
|
21977
|
+
message: errorMessage(err)
|
|
21978
|
+
});
|
|
21979
|
+
print(formatStep(steps[steps.length - 1]));
|
|
21980
|
+
}
|
|
21981
|
+
}
|
|
21725
21982
|
}
|
|
21726
21983
|
if (loader.has("source")) {
|
|
21727
21984
|
const source = loader.get("source");
|
|
@@ -22598,18 +22855,18 @@ const authListCommand = {
|
|
|
22598
22855
|
* `holocron list projects` — the owner's boards, newest first, with their number, name and state. Read-only, so
|
|
22599
22856
|
* `--dry-run` changes nothing here.
|
|
22600
22857
|
*/
|
|
22601
|
-
const COMMAND$
|
|
22858
|
+
const COMMAND$3 = "list projects";
|
|
22602
22859
|
async function runProjectList(input) {
|
|
22603
22860
|
const print = input.print ?? ((line) => console.log(line));
|
|
22604
22861
|
const rows = createProjectRows(print, input.logger ?? getLogger());
|
|
22605
|
-
const { projects, options } = await openProjects(input, COMMAND$
|
|
22862
|
+
const { projects, options } = await openProjects(input, COMMAND$3);
|
|
22606
22863
|
print(style.header(`Holocron list projects — ${options.owner}`));
|
|
22607
22864
|
print("");
|
|
22608
22865
|
try {
|
|
22609
22866
|
const boards = (await projects.list(options.owner)).toSorted((a, b) => (b.number ?? 0) - (a.number ?? 0));
|
|
22610
22867
|
if (boards.length === 0) {
|
|
22611
22868
|
rows.skip("no boards", options.owner);
|
|
22612
|
-
return rows.finish(COMMAND$
|
|
22869
|
+
return rows.finish(COMMAND$3);
|
|
22613
22870
|
}
|
|
22614
22871
|
const width = Math.max(1, ...boards.map((b) => String(b.number ?? "").length));
|
|
22615
22872
|
print(style.dim(` ${"#".padEnd(width)} ${"Name".padEnd(32)} State`));
|
|
@@ -22619,7 +22876,7 @@ async function runProjectList(input) {
|
|
|
22619
22876
|
} catch (err) {
|
|
22620
22877
|
rows.fail("list", errorMessage(err));
|
|
22621
22878
|
}
|
|
22622
|
-
return rows.finish(COMMAND$
|
|
22879
|
+
return rows.finish(COMMAND$3);
|
|
22623
22880
|
}
|
|
22624
22881
|
// src/commands/project/project-list/project-list.command.ts
|
|
22625
22882
|
const projectListCommand = {
|
|
@@ -23540,7 +23797,7 @@ const authSetCommand = {
|
|
|
23540
23797
|
* file is checked (git ignores it, it is not there already) before the browser opens. Nothing but names and paths is
|
|
23541
23798
|
* ever printed.
|
|
23542
23799
|
*/
|
|
23543
|
-
const COMMAND$
|
|
23800
|
+
const COMMAND$2 = "new github-app";
|
|
23544
23801
|
const DEFAULT_WEBHOOK_SECRET_VAR = "SENTINEL_WEBHOOK_SECRET";
|
|
23545
23802
|
async function runGithubAppCreate(input) {
|
|
23546
23803
|
const print = input.print ?? ((line) => console.error(line));
|
|
@@ -23550,7 +23807,7 @@ async function runGithubAppCreate(input) {
|
|
|
23550
23807
|
logger.warn({
|
|
23551
23808
|
status: "fail",
|
|
23552
23809
|
reason
|
|
23553
|
-
}, COMMAND$
|
|
23810
|
+
}, COMMAND$2);
|
|
23554
23811
|
return { status: "fail" };
|
|
23555
23812
|
};
|
|
23556
23813
|
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 +23868,7 @@ async function runGithubAppCreate(input) {
|
|
|
23611
23868
|
status: "fail",
|
|
23612
23869
|
reason: "write",
|
|
23613
23870
|
slug: app.slug
|
|
23614
|
-
}, COMMAND$
|
|
23871
|
+
}, COMMAND$2);
|
|
23615
23872
|
for (const line of [`created ${app.slug}, but could not keep its credentials: ${errorMessage(err)}`, `they are shown once: delete the App (${settings}) and run this again`]) print(line);
|
|
23616
23873
|
return {
|
|
23617
23874
|
status: "fail",
|
|
@@ -23636,7 +23893,7 @@ async function runGithubAppCreate(input) {
|
|
|
23636
23893
|
logger.info({
|
|
23637
23894
|
status,
|
|
23638
23895
|
slug: app.slug
|
|
23639
|
-
}, COMMAND$
|
|
23896
|
+
}, COMMAND$2);
|
|
23640
23897
|
return {
|
|
23641
23898
|
status,
|
|
23642
23899
|
slug: app.slug,
|
|
@@ -25969,18 +26226,18 @@ const pluginCreateCommand = {
|
|
|
25969
26226
|
* templates directory). Idempotent on the title: an open board that has it is not made again; a terminal is asked
|
|
25970
26227
|
* whether to open the existing one, `--yes` prints its address, and anything else is a {@link NonInteractiveError}.
|
|
25971
26228
|
*/
|
|
25972
|
-
const COMMAND$
|
|
26229
|
+
const COMMAND$1 = "new project";
|
|
25973
26230
|
async function runProjectCreate(input) {
|
|
25974
26231
|
const print = input.print ?? ((line) => console.log(line));
|
|
25975
26232
|
const rows = createProjectRows(print, input.logger ?? getLogger());
|
|
25976
26233
|
const prompt = input.prompt ?? terminalPrompt();
|
|
25977
26234
|
const dryRun = input.context.dryRun ?? false;
|
|
25978
26235
|
const done = (extra = {}) => ({
|
|
25979
|
-
...rows.finish(COMMAND$
|
|
26236
|
+
...rows.finish(COMMAND$1),
|
|
25980
26237
|
created: false,
|
|
25981
26238
|
...extra
|
|
25982
26239
|
});
|
|
25983
|
-
const { projects, options } = await openProjects(input, COMMAND$
|
|
26240
|
+
const { projects, options } = await openProjects(input, COMMAND$1);
|
|
25984
26241
|
const loaded = await loadTemplates(options.templatesDir, input.io ?? createFsTemplatesIo(input.context.repoRoot));
|
|
25985
26242
|
print(style.header(`Holocron new project — ${options.owner}${dryRun ? " (dry-run)" : ""}`));
|
|
25986
26243
|
print("");
|
|
@@ -29306,198 +29563,6 @@ function specsCheckProbe(io) {
|
|
|
29306
29563
|
function specsProbes(io) {
|
|
29307
29564
|
return { check: specsCheckProbe(io) };
|
|
29308
29565
|
}
|
|
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
29566
|
// src/commands/probe/probe.ts
|
|
29502
29567
|
/**
|
|
29503
29568
|
* `holocron probe [<provider> [<probe>]]`. With nothing, lists what can be probed; with a provider, lists its probes;
|
|
@@ -33896,30 +33961,6 @@ const syncToolingCommand = {
|
|
|
33896
33961
|
})).status === "fail") process.exitCode = 1;
|
|
33897
33962
|
}
|
|
33898
33963
|
};
|
|
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
33964
|
// src/presets/constants.ts
|
|
33924
33965
|
/**
|
|
33925
33966
|
* The org's DNS zone as the presets ship it to a consumer repo that has no `.holocron/org.ts` of its own. A repo
|