@orkestrel/scaffold 0.0.2 → 0.0.3
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/README.md +29 -15
- package/dist/bin/scaffold.js +1162 -1200
- package/dist/bin/scaffold.js.map +1 -1
- package/dist/host/AGENTS.md +124 -925
- package/dist/host/CLAUDE.md +260 -495
- package/dist/host/agents/skills/orkestrel-align-packages/SKILL.md +53 -0
- package/dist/host/agents/skills/orkestrel-align-packages/agents/openai.yaml +4 -0
- package/dist/host/agents/skills/orkestrel-align-packages/references/fleet.md +50 -0
- package/dist/host/agents/skills/orkestrel-align-packages/references/integration.md +56 -0
- package/dist/host/agents/skills/orkestrel-build-application/SKILL.md +64 -0
- package/dist/host/agents/skills/orkestrel-build-application/agents/openai.yaml +4 -0
- package/dist/host/agents/skills/orkestrel-build-application/references/application.md +129 -0
- package/dist/host/agents/skills/orkestrel-harden-package/SKILL.md +64 -0
- package/dist/host/agents/skills/orkestrel-harden-package/agents/openai.yaml +4 -0
- package/dist/host/agents/skills/orkestrel-harden-package/references/centralization.md +85 -0
- package/dist/host/agents/skills/orkestrel-harden-package/references/contract.md +57 -0
- package/dist/host/agents/skills/orkestrel-harden-package/references/hardening.md +93 -0
- package/dist/host/agents/skills/orkestrel-harden-package/references/research.md +61 -0
- package/dist/host/claude/agents/application.md +32 -0
- package/dist/host/claude/agents/builder.md +12 -7
- package/dist/host/claude/agents/checker.md +15 -8
- package/dist/host/claude/agents/codex.md +40 -0
- package/dist/host/claude/agents/grok.md +20 -37
- package/dist/host/claude/agents/orkestrel.md +89 -223
- package/dist/host/claude/agents/planner.md +14 -34
- package/dist/host/claude/agents/reviewer.md +39 -24
- package/dist/host/claude/agents/verifier.md +15 -10
- package/dist/host/claude/rules/application.md +57 -0
- package/dist/host/claude/rules/architecture.md +179 -0
- package/dist/host/claude/rules/browser.md +28 -0
- package/dist/host/claude/rules/documentation.md +64 -0
- package/dist/host/claude/rules/names.md +209 -0
- package/dist/host/claude/rules/patterns.md +130 -0
- package/dist/host/claude/rules/quality.md +45 -0
- package/dist/host/claude/rules/styles.md +64 -0
- package/dist/host/claude/rules/tests.md +123 -0
- package/dist/host/claude/rules/typescript.md +78 -0
- package/dist/host/claude/rules/workspace.md +180 -0
- package/dist/host/claude/settings.json +116 -0
- package/dist/host/claude/skills/orkestrel-align-packages/SKILL.md +10 -0
- package/dist/host/claude/skills/orkestrel-build-application/SKILL.md +12 -0
- package/dist/host/claude/skills/orkestrel-harden-package/SKILL.md +10 -0
- package/dist/host/codex/agents/analyst.toml +15 -0
- package/dist/host/codex/agents/application.toml +25 -0
- package/dist/host/codex/agents/builder.toml +24 -0
- package/dist/host/codex/agents/checker.toml +15 -0
- package/dist/host/codex/agents/grok.toml +17 -0
- package/dist/host/codex/agents/implementer.toml +17 -0
- package/dist/host/codex/agents/orkestrel.toml +16 -0
- package/dist/host/codex/agents/planner.toml +20 -0
- package/dist/host/codex/agents/reviewer.toml +18 -0
- package/dist/host/codex/agents/verifier.toml +14 -0
- package/dist/host/codex/config.toml +64 -0
- package/dist/host/dotfiles/oxlintrc.json +307 -1
- package/dist/host/guides/src/scaffold.md +2059 -2007
- package/dist/host/manifest.json +355 -137
- package/dist/host/scripts/codex.sh +49 -0
- package/dist/host/scripts/cursor.sh +33 -47
- package/dist/host/scripts/deps.sh +34 -16
- package/dist/host/scripts/ollama.sh +6 -149
- package/dist/host/tests/setupPolicy.ts +354 -0
- package/dist/src/core/index.cjs +6600 -1199
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +801 -266
- package/dist/src/core/index.d.ts +801 -266
- package/dist/src/core/index.js +6518 -1191
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +3132 -593
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +643 -95
- package/dist/src/server/index.d.ts +643 -95
- package/dist/src/server/index.js +3054 -594
- package/dist/src/server/index.js.map +1 -1
- package/package.json +15 -12
- package/dist/host/claude/agents/composer.md +0 -64
- package/dist/host/claude/agents/researcher.md +0 -38
- package/dist/host/claude/agents/scout.md +0 -35
- package/dist/host/github/workflows/ci.yml +0 -64
package/dist/bin/scaffold.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.js","names":[],"sources":["../../src/bin/render.ts","../../src/bin/scaffold.ts"],"sourcesContent":["// The bin's ENTIRE presentation layer — every user-facing string, table, prompt\n// message, help tier, and --json serializer lives here as a pure, exported,\n// module-scope function. The bin (src/bin/scaffold.ts) calls only these; this\n// file never touches process.exit or fs, and never spawns nested functions\n// (AGENTS §no-nested-functions) — every helper is exported and top-level.\nimport type {\n\tAudit,\n\tCatalogEntry,\n\tDrift,\n\tFinding,\n\tOrigin,\n\tPlan,\n\tSurface,\n\tSyncReport,\n} from '@src/core'\nimport type { MaterializeResult } from '@src/server'\nimport { createStyler } from '@orkestrel/console'\nimport type { ColumnSpec, StylerInterface } from '@orkestrel/console'\n\n/** The bin's closed verb vocabulary. */\nexport const KNOWN_VERBS = Object.freeze([\n\t'new',\n\t'pull',\n\t'audit',\n\t'repair',\n\t'fleet',\n\t'catalog',\n] as const)\n\n/** One `KNOWN_VERBS` member. */\nexport type Verb = (typeof KNOWN_VERBS)[number]\n\n/** The jargon translation table — internal `Origin`/`Drift`/scope vocabulary → one user-facing register. */\nexport const ORIGIN_LABEL: Readonly<Record<Origin, string>> = Object.freeze({\n\thost: 'template-owned',\n\ttemplate: 'template-owned',\n\tcomputed: 'generated',\n})\n\n/** A `Finding`'s `Drift`, translated — `'aligned'` never reaches a rendered table (callers filter it first). */\nexport const DRIFT_LABEL: Readonly<Record<Drift, string>> = Object.freeze({\n\taligned: 'unchanged',\n\tstale: 'drifted',\n\tmissing: 'missing',\n\tforeign: 'unexpected file',\n})\n\n/** A `Freshness` outcome, translated for `pull`'s per-entry cause notes. */\nexport const FRESHNESS_LABEL: Readonly<Record<string, string>> = Object.freeze({\n\tcurrent: 'unchanged',\n\tbehind: 'behind',\n\tmissing: 'missing upstream',\n\tfailed: 'fetch failed',\n})\n\n/** The materializer's per-entry action words, translated (`copied` → `wrote`, `skipped` → `unchanged`). */\nexport const ACTION_LABEL: Readonly<Record<string, string>> = Object.freeze({\n\twritten: 'wrote',\n\tcopied: 'wrote',\n\tskipped: 'unchanged',\n\tremoved: 'removed',\n})\n\n/** One `{count} {label}` part, pluralized; used by every bucket/tally line. */\nexport function countPart(count: number, label: string): string {\n\treturn `${count} ${label}${count === 1 ? '' : 's'}`\n}\n\n/** Nonzero `{count} {label}` parts joined by `, `; `'clean'` when every count is zero — the shared bucket-text primitive every verdict line reuses. */\nexport function bucketText(counts: {\n\treadonly drifted: number\n\treadonly missing: number\n\treadonly foreign: number\n}): string {\n\tconst parts: string[] = []\n\tif (counts.drifted > 0) parts.push(countPart(counts.drifted, 'drifted'))\n\tif (counts.missing > 0) parts.push(countPart(counts.missing, 'missing'))\n\tif (counts.foreign > 0) parts.push(countPart(counts.foreign, 'unexpected'))\n\treturn parts.length > 0 ? parts.join(', ') : 'clean'\n}\n\n/**\n * Split `findings` by their `plan` artifact's `origin` — `host`/`template` lumped as\n * `template-owned` vs `computed` as `generated` (a `foreign` finding names no plan artifact,\n * so it counts as `generated`: it is never template-owned).\n */\nexport function partitionOrigin(\n\tfindings: readonly Finding[],\n\tplan: Plan,\n): {\n\treadonly owned: { readonly drifted: number; readonly missing: number; readonly foreign: number }\n\treadonly generated: {\n\t\treadonly drifted: number\n\t\treadonly missing: number\n\t\treadonly foreign: number\n\t}\n} {\n\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\tlet ownedDrifted = 0\n\tlet ownedMissing = 0\n\tlet ownedForeign = 0\n\tlet generatedDrifted = 0\n\tlet generatedMissing = 0\n\tlet generatedForeign = 0\n\tfor (const finding of findings) {\n\t\tconst origin = origins.get(finding.path)\n\t\tconst isOwned = origin === 'host' || origin === 'template'\n\t\tif (finding.drift === 'aligned') continue\n\t\telse if (finding.drift === 'stale') {\n\t\t\tif (isOwned) ownedDrifted += 1\n\t\t\telse generatedDrifted += 1\n\t\t} else if (finding.drift === 'missing') {\n\t\t\tif (isOwned) ownedMissing += 1\n\t\t\telse generatedMissing += 1\n\t\t} else {\n\t\t\tif (isOwned) ownedForeign += 1\n\t\t\telse generatedForeign += 1\n\t\t}\n\t}\n\treturn {\n\t\towned: { drifted: ownedDrifted, missing: ownedMissing, foreign: ownedForeign },\n\t\tgenerated: { drifted: generatedDrifted, missing: generatedMissing, foreign: generatedForeign },\n\t}\n}\n\n/** `audit`'s verdict line — lowercase, verb-led, origin-split so template-owned health is immediately visible. */\nexport function auditVerdict(audit: Audit, plan: Plan): string {\n\tconst total = audit.findings.length\n\tif (audit.clean) return `audit: ${countPart(total, 'artifact')} — clean`\n\tconst split = partitionOrigin(audit.findings, plan)\n\tconst ownedClean =\n\t\tsplit.owned.drifted === 0 && split.owned.missing === 0 && split.owned.foreign === 0\n\treturn ownedClean\n\t\t? `audit: ${countPart(total, 'artifact')} — template-owned clean; ${bucketText(split.generated)} (generated)`\n\t\t: `audit: ${countPart(total, 'artifact')} — template-owned: ${bucketText(split.owned)}; generated: ${bucketText(split.generated)}`\n}\n\n/** One aligned-column row per non-`aligned` `Finding` — `[status, kind, path]`, translated labels, ready for `reporter.table`. */\nexport function findingRows(\n\tfindings: readonly Finding[],\n\tplan: Plan,\n): readonly (readonly [string, string, string])[] {\n\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\treturn findings\n\t\t.filter((finding) => finding.drift !== 'aligned')\n\t\t.map((finding) => {\n\t\t\tconst origin = origins.get(finding.path)\n\t\t\tconst kind = origin === undefined ? 'unexpected file' : ORIGIN_LABEL[origin]\n\t\t\treturn [DRIFT_LABEL[finding.drift], kind, finding.path] as const\n\t\t})\n}\n\n/** The audit findings table — columns Status/Kind/Path, translated labels, via `reporter.table`. */\nexport function auditTable(\n\taudit: Audit,\n\tplan: Plan,\n): {\n\treadonly columns: readonly ColumnSpec[]\n\treadonly rows: readonly (readonly string[])[]\n} {\n\treturn {\n\t\tcolumns: [{ label: 'Status' }, { label: 'Kind' }, { label: 'Path' }],\n\t\trows: findingRows(audit.findings, plan),\n\t}\n}\n\n/** The banner `repair` opens with (dry-run AND `--apply`) — its scope is the template-owned set only. */\nexport const REPAIR_SCOPE =\n\t'repair scope: shared template-owned artifacts only — generated source/tests/configs are never touched'\n\n/** The `repair` note pointing at drift outside its scope — `undefined` when there is none. */\nexport function scopeNote(outsideCount: number): string | undefined {\n\tif (outsideCount === 0) return undefined\n\treturn `note: ${countPart(outsideCount, 'finding')} outside repair's scope — run 'audit' for the list; generated files are yours to edit`\n}\n\n/** `repair`'s dry-run verdict line. */\nexport function repairVerdict(audit: Audit): string {\n\tif (audit.clean)\n\t\treturn `repair: ${countPart(audit.findings.length, 'template-owned artifact')} aligned — nothing to write`\n\treturn `repair: ${bucketText({ drifted: audit.drifted, missing: audit.missing, foreign: audit.foreign })} — pass --apply to write`\n}\n\n/** `repair --apply`'s success line — the materializer tally, translated action words. */\nexport function repairSuccess(result: MaterializeResult, removed: readonly string[]): string {\n\tconst written = result.written.length + result.copied.length\n\treturn `${ACTION_LABEL.written} ${written}, ${ACTION_LABEL.skipped} ${result.skipped.length}, ${ACTION_LABEL.removed} ${removed.length}`\n}\n\n/** `pull`'s freshness table rows — `[name, kind, freshness]`, translated. */\nexport function pullRows(report: SyncReport): readonly (readonly [string, string, string])[] {\n\tconst guideRows = report.guides.map(\n\t\t(guide) => [guide.name, 'guide', FRESHNESS_LABEL[guide.freshness] ?? guide.freshness] as const,\n\t)\n\tconst versionRows = report.versions.map(\n\t\t(version) =>\n\t\t\t[version.name, 'version', FRESHNESS_LABEL[version.freshness] ?? version.freshness] as const,\n\t)\n\treturn [...guideRows, ...versionRows]\n}\n\n/** `pull`'s freshness table — columns Name/Kind/Freshness. */\nexport function pullTable(report: SyncReport): {\n\treadonly columns: readonly ColumnSpec[]\n\treadonly rows: readonly (readonly string[])[]\n} {\n\treturn {\n\t\tcolumns: [{ label: 'Name' }, { label: 'Kind' }, { label: 'Freshness' }],\n\t\trows: pullRows(report),\n\t}\n}\n\n/** Per-entry cause notes for a non-`current` `pull` entry that carries a `note`. */\nexport function pullCauseNotes(report: SyncReport): readonly string[] {\n\tconst entries = [...report.guides, ...report.versions]\n\treturn entries\n\t\t.filter((entry) => entry.note !== undefined)\n\t\t.map(\n\t\t\t(entry) =>\n\t\t\t\t` ${entry.name}: ${FRESHNESS_LABEL[entry.freshness] ?? entry.freshness} — ${entry.note}`,\n\t\t)\n}\n\n/** `pull`'s tally line. */\nexport function pullVerdict(report: SyncReport): string {\n\tconst total = report.guides.length + report.versions.length\n\treturn `pull: ${countPart(total, 'entry')} — ${countPart(report.failed, 'failed')}`\n}\n\n/** `pull --apply`'s success line. */\nexport function pullSuccess(count: number): string {\n\treturn `wrote ${countPart(count, 'guide')}`\n}\n\n/** One `fleet` per-repo line — clean, drifted (dry-run), or repaired (`--apply`). */\nexport function fleetRepoLine(\n\tname: string,\n\toutcome:\n\t\t| { readonly kind: 'clean' }\n\t\t| {\n\t\t\t\treadonly kind: 'drifted'\n\t\t\t\treadonly drifted: number\n\t\t\t\treadonly missing: number\n\t\t\t\treadonly foreign: number\n\t\t }\n\t\t| { readonly kind: 'repaired'; readonly remaining: number }\n\t\t| { readonly kind: 'failed'; readonly message: string },\n): string {\n\tif (outcome.kind === 'clean') return `${name}: clean`\n\tif (outcome.kind === 'drifted') {\n\t\treturn `${name}: ${bucketText({ drifted: outcome.drifted, missing: outcome.missing, foreign: outcome.foreign })}`\n\t}\n\tif (outcome.kind === 'repaired')\n\t\treturn `${name}: repaired (${countPart(outcome.remaining, 'finding')} remaining)`\n\treturn `${name}: ${outcome.message}`\n}\n\n/** `fleet`'s blast-radius totals line. */\nexport function fleetTotals(drifted: number, failed: number): string {\n\treturn `total: ${countPart(drifted, 'drifted repo')}, ${countPart(failed, 'failed')}`\n}\n\n/** The `catalog` terminal preview table — columns Package/Version (descriptions live only in the written table and `--json`). */\nexport function catalogTable(entries: readonly CatalogEntry[]): {\n\treadonly columns: readonly ColumnSpec[]\n\treadonly rows: readonly (readonly string[])[]\n} {\n\treturn {\n\t\tcolumns: [{ label: 'Package' }, { label: 'Version' }],\n\t\trows: entries.map((entry) => [entry.name, entry.version] as const),\n\t}\n}\n\n/** The `catalog` shrink warning — `undefined` when the table did not shrink. */\nexport function catalogShrinkWarning(oldRows: number, newRows: number): string | undefined {\n\tif (newRows >= oldRows) return undefined\n\treturn `warning: catalog shrinks from ${countPart(oldRows, 'row')} to ${newRows}`\n}\n\n/** `catalog`'s counts line. */\nexport function catalogCounts(published: number, localOnly: number): string {\n\treturn `catalog: ${countPart(published, 'published package')}, ${countPart(localOnly, 'local-only')}`\n}\n\n/** `new`'s dry-run plan preview — origin counts table description + the destination line. */\nexport function newPlanTable(scaffolding: {\n\treadonly host: number\n\treadonly template: number\n\treadonly computed: number\n}): {\n\treadonly columns: readonly ColumnSpec[]\n\treadonly rows: readonly (readonly string[])[]\n} {\n\treturn {\n\t\tcolumns: [{ label: 'Origin' }, { label: 'Count', align: 'right' as const }],\n\t\trows: [\n\t\t\t['template-owned', String(scaffolding.host + scaffolding.template)],\n\t\t\t['generated', String(scaffolding.computed)],\n\t\t],\n\t}\n}\n\n/** `new`'s dry-run destination line. */\nexport function newPlanPreview(name: string): string {\n\treturn `will write into ./${name}`\n}\n\n/** `new --apply`'s success line. */\nexport function newApplySuccess(count: number, name: string): string {\n\treturn `wrote ${countPart(count, 'file')} into ./${name}`\n}\n\n/** `new`'s dry-run declined-apply note. */\nexport const NEW_DRY_RUN_NOTE = 'dry run — pass --apply to write'\n\n/** `catalog --apply`'s success line. */\nexport function catalogApplySuccess(path: string): string {\n\treturn `wrote ${path}`\n}\n\n/** The fallback line for a `parseArgs` failure that carries no `Error` message of its own. */\nexport const INVALID_ARGUMENTS_MESSAGE = 'invalid arguments'\n\n/** The apply-confirm prompt message — singular repo, or fleet-wide across `repos` when given. */\nexport function applyConfirmMessage(fileCount: number, repoCount?: number): string {\n\tconst scope = repoCount === undefined ? '' : ` across ${countPart(repoCount, 'repo')}`\n\treturn `Apply — write ${countPart(fileCount, 'file')}${scope}? `\n}\n\n/** The prune double-confirm prompt message. */\nexport function pruneConfirmMessage(count: number): string {\n\treturn `Also delete ${countPart(count, 'unexpected file')} under .claude/agents and scripts? `\n}\n\n/**\n * The audit→repair handoff prompt message — names what will actually be\n * acted on: `owned` template-owned files with drift, and (only when `prune`\n * is active) `foreign` unexpected files that will be deleted. Never promises\n * a deletion the handoff will not perform — `prune` gates the foreign clause.\n */\nexport function repairHandoff(owned: number, foreign: number, prune: boolean): string {\n\tconst parts: string[] = []\n\tif (owned > 0) {\n\t\tparts.push(`${countPart(owned, 'template-owned file')} ${owned === 1 ? 'has' : 'have'} drift`)\n\t}\n\tif (prune && foreign > 0) parts.push(`${countPart(foreign, 'unexpected file')} will be deleted`)\n\treturn `${parts.join(' and ')} — run repair now? `\n}\n\n/** Printed when unexpected files exist but the handoff cannot help them (no `--prune`, or no handoff offered at all) — points at the one command that can. */\nexport function foreignHint(): string {\n\treturn \"unexpected files found — run 'scaffold repair --prune' to delete them\"\n}\n\n/** `new`'s interactive Q1 prompt (TTY only) — `@orkestrel` short-name deps, landing in `dependencies`. */\nexport function orkestrelDepsPrompt(): string {\n\treturn '@orkestrel dependencies (comma-separated short names, e.g. contract, emitter — installed as dependencies)'\n}\n\n/**\n * Re-ask wording for a Q1 token that does not resolve against the vendored\n * `@orkestrel` catalog — names the offending token and, when one was found,\n * the nearest catalog name (`render.ts`'s own `nearest`).\n */\nexport function unknownOrkestrelToken(token: string, suggestion: string | undefined): string {\n\tconst base = `\"${token}\" is not a published @orkestrel package`\n\treturn suggestion === undefined\n\t\t? `${base} — try again`\n\t\t: `${base} — did you mean \"${suggestion}\"? try again`\n}\n\n/** Printed once when the vendored `@orkestrel` catalog cannot be resolved — Q1 degrades to shape-only (`DEPENDENCY_NAME_PATTERN`) validation instead of blocking on it. */\nexport function catalogUnresolvedNote(): string {\n\treturn \"couldn't resolve the vendored @orkestrel catalog — validating names by shape only\"\n}\n\n/** The line printed when a confirm prompt is declined. */\nexport const CANCELLED_MESSAGE = 'cancelled — nothing written'\n\n/** `new`'s surface checkbox choices — per-choice descriptions grounded on the terminal guide's surface semantics. */\nexport function surfaceChoices(): readonly {\n\treadonly name: string\n\treadonly value: Surface\n\treadonly description: string\n}[] {\n\treturn [\n\t\t{ name: 'core', value: 'core', description: 'the pure engine' },\n\t\t{ name: 'browser', value: 'browser', description: 'DOM-facing surface' },\n\t\t{ name: 'server', value: 'server', description: 'node-facing surface' },\n\t]\n}\n\n/** The safety-model banner every full-help tier includes. */\nexport const SAFETY_BANNER = [\n\t'safety: every verb is a dry run by default.',\n\t'on a terminal, a write prompts for confirmation; in a script, pass --apply (and --yes to skip the confirm).',\n\t'every write is confined to the current working directory — cd there first.',\n\t'TLS trusts the system certificate store automatically (corporate proxies); NODE_EXTRA_CA_CERTS adds custom PEMs.',\n].join('\\n')\n\n/** The exit-code reference table every full-help tier includes. */\nexport const EXIT_CODES: readonly (readonly [string, string])[] = [\n\t['0', 'clean / success'],\n\t['1', 'drift or failure'],\n\t['2', 'usage error'],\n]\n\n/** One-line-per-verb summaries — the short and full help tiers share this table. */\nexport const VERB_SUMMARY: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'scaffold a package into ./<name>',\n\tpull: 'refresh vendored guides/versions, report drift',\n\taudit: 'whole-plan conformance report',\n\trepair: 'restore the shared template-owned set',\n\tfleet: \"audit/repair every package under the cwd's immediate children\",\n\tcatalog: 'regenerate the fleet package-catalog table',\n})\n\n/** ≤10 lines: one-liner per verb plus the escape hatch to `verbHelp`. */\nexport function shortUsage(): string {\n\tconst lines = KNOWN_VERBS.map((verb) => ` ${verb.padEnd(8)}${VERB_SUMMARY[verb]}`)\n\treturn [\n\t\t'scaffold <verb> [options]',\n\t\t'',\n\t\t...lines,\n\t\t'',\n\t\t\"run 'scaffold <verb> --help' for a verb's full reference\",\n\t].join('\\n')\n}\n\n/** Each verb's flag reference — the fullHelp reference and verbHelp share this table. */\nexport const VERB_FLAGS: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: '--surfaces a,b --deps x,y --apply --yes --target <path> --from <path>',\n\tpull: '--target . --deps x,y --apply --yes --strict',\n\taudit: '--target . --live --from <path> --groups a,b',\n\trepair: '--target . --apply --yes --prune --from <path>',\n\tfleet: '--apply --yes --prune --from <path>',\n\tcatalog: '--from <path> ... --target <repo> --offline --apply --yes',\n})\n\n/** Per-verb, per-flag plain-language descriptions — `verbHelp`'s one-line-per-flag body. `--prune` is marked destructive. */\nexport const VERB_FLAG_HELP: Readonly<Record<Verb, readonly (readonly [string, string])[]>> =\n\tObject.freeze({\n\t\tnew: [\n\t\t\t['--surfaces a,b', 'which surfaces to include (core, browser, server)'],\n\t\t\t['--deps x,y', '@orkestrel/* dependencies to add (installed as dependencies)'],\n\t\t\t['--apply', 'write the files (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--target <path>', 'destination directory (default: ./<name>)'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t],\n\t\tpull: [\n\t\t\t['--target .', 'directory to refresh (default: current directory)'],\n\t\t\t['--deps x,y', 'limit the refresh to these dependencies'],\n\t\t\t['--apply', 'write the refreshed files (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--strict', 'fail (exit 1) on any drift, even non-fatal'],\n\t\t],\n\t\taudit: [\n\t\t\t['--target .', 'directory to audit (default: current directory)'],\n\t\t\t['--live', 'also check upstream freshness over the network'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t\t['--groups a,b', 'limit the audit to these artifact groups'],\n\t\t],\n\t\trepair: [\n\t\t\t['--target .', 'directory to repair (default: current directory)'],\n\t\t\t['--apply', 'write the fixes (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--prune', 'also DELETE unexpected files under .claude/agents and scripts'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t],\n\t\tfleet: [\n\t\t\t['--apply', 'write fixes across every package (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--prune', 'also DELETE unexpected files under .claude/agents and scripts, per package'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t],\n\t\tcatalog: [\n\t\t\t['--from <path> ...', 'one or more local package paths to include'],\n\t\t\t['--target <repo>', 'the repo whose README catalog table gets updated'],\n\t\t\t['--offline', 'skip network lookups (npm registry) for package descriptions'],\n\t\t\t['--apply', 'write the updated table (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t],\n\t})\n\n/** The dry-run/confirm note per verb — `audit` never writes, so its note says so instead. */\nexport const VERB_DRY_RUN_NOTE: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'dry run by default — add --apply to write the files, --yes to skip the question',\n\tpull: 'dry run by default — add --apply to write the refreshed files, --yes to skip the question',\n\taudit: 'read-only — audit never writes; pass --live to also check upstream freshness',\n\trepair: 'dry run by default — add --apply to write, --yes to skip the question',\n\tfleet:\n\t\t'dry run by default — add --apply to write across every package, --yes to skip the question',\n\tcatalog: 'dry run by default — add --apply to write, --yes to skip the question',\n})\n\n/** One concrete example invocation per verb — `verbHelp`'s closing line. */\nexport const VERB_EXAMPLE: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'example: scaffold new widget --surfaces core,server --apply',\n\tpull: 'example: scaffold pull --apply',\n\taudit: 'example: scaffold audit --live',\n\trepair: 'example: scaffold repair --apply',\n\tfleet: 'example: scaffold fleet --apply --yes',\n\tcatalog: 'example: scaffold catalog --apply',\n})\n\n/** The full reference help tier — every verb's summary + flags, the safety banner, and the exit-code table. */\nexport function fullHelp(): string {\n\tconst verbLines = KNOWN_VERBS.map(\n\t\t(verb) => ` ${verb} ${VERB_FLAGS[verb]}\\n ${VERB_SUMMARY[verb]}`,\n\t)\n\tconst exitLines = EXIT_CODES.map(([code, meaning]) => ` ${code} ${meaning}`)\n\treturn [\n\t\t'scaffold <verb> [options]',\n\t\t'',\n\t\t...verbLines,\n\t\t'',\n\t\tSAFETY_BANNER,\n\t\t'',\n\t\t'exit codes:',\n\t\t...exitLines,\n\t].join('\\n')\n}\n\n/** One verb's help section — summary, dry-run note, one line per flag, and a concrete example. */\nexport function verbHelp(verb: Verb): string {\n\tconst flagLines = VERB_FLAG_HELP[verb].map(([flag, meaning]) => ` ${flag.padEnd(20)}${meaning}`)\n\treturn [\n\t\t`scaffold ${verb} ${VERB_FLAGS[verb]}`,\n\t\t'',\n\t\tVERB_SUMMARY[verb],\n\t\tVERB_DRY_RUN_NOTE[verb],\n\t\t'',\n\t\t...flagLines,\n\t\t'',\n\t\tVERB_EXAMPLE[verb],\n\t].join('\\n')\n}\n\n/** Levenshtein edit distance between two strings — the did-you-mean primitive. */\nexport function editDistance(a: string, b: string): number {\n\tconst rows = a.length + 1\n\tconst cols = b.length + 1\n\tconst table: number[][] = Array.from({ length: rows }, () => new Array<number>(cols).fill(0))\n\tfor (let i = 0; i < rows; i += 1) table[i][0] = i\n\tfor (let j = 0; j < cols; j += 1) table[0][j] = j\n\tfor (let i = 1; i < rows; i += 1) {\n\t\tfor (let j = 1; j < cols; j += 1) {\n\t\t\tconst cost = a[i - 1] === b[j - 1] ? 0 : 1\n\t\t\ttable[i][j] = Math.min(table[i - 1][j] + 1, table[i][j - 1] + 1, table[i - 1][j - 1] + cost)\n\t\t}\n\t}\n\treturn table[rows - 1][cols - 1]\n}\n\n/** The nearest candidate to `input` by `editDistance` — `undefined` when `set` is empty. */\nexport function nearest(input: string, set: readonly string[]): string | undefined {\n\tlet best: string | undefined\n\tlet bestDistance = Number.POSITIVE_INFINITY\n\tfor (const candidate of set) {\n\t\tconst distance = editDistance(input, candidate)\n\t\tif (distance < bestDistance) {\n\t\t\tbestDistance = distance\n\t\t\tbest = candidate\n\t\t}\n\t}\n\treturn best\n}\n\n/** Retired verb names redirected to their replacement — checked before fuzzy matching in `didYouMean`. */\nexport const RETIRED_VERBS: Readonly<Record<string, string>> = Object.freeze({\n\tsync: 'pull',\n\tmirror: 'fleet',\n})\n\n/** The unknown-command message — a retired-verb redirect when recognized, otherwise the nearest `KNOWN_VERBS` guess. */\nexport function didYouMean(command: string): string {\n\tconst retired = RETIRED_VERBS[command]\n\tif (retired !== undefined) return `'${command}' has been renamed — use 'scaffold ${retired}'`\n\tconst guess = nearest(command, [...KNOWN_VERBS])\n\treturn guess === undefined\n\t\t? `unknown command \"${command}\"`\n\t\t: `unknown command \"${command}\" — did you mean \"${guess}\"?`\n}\n\n/** One JSON error envelope — the single shape every `--json` failure returns. */\nexport function errorEnvelope(\n\tcode: string,\n\tmessage: string,\n): { readonly error: { readonly code: string; readonly message: string } } {\n\treturn { error: { code, message } }\n}\n\n/** `new --json`'s value — the plan summary, deterministic key order. */\nexport function newJson(\n\tsummary: {\n\t\treadonly name: string\n\t\treadonly surfaces: readonly Surface[]\n\t\treadonly host: number\n\t\treadonly template: number\n\t\treadonly computed: number\n\t},\n\tapplied: boolean,\n): {\n\treadonly name: string\n\treadonly surfaces: readonly Surface[]\n\treadonly host: number\n\treadonly template: number\n\treadonly computed: number\n\treadonly applied: boolean\n} {\n\treturn {\n\t\tname: summary.name,\n\t\tsurfaces: summary.surfaces,\n\t\thost: summary.host,\n\t\ttemplate: summary.template,\n\t\tcomputed: summary.computed,\n\t\tapplied,\n\t}\n}\n\n/** `pull --json`'s value — the `SyncReport` verbatim (already deterministic + JSON-safe). */\nexport function pullJson(report: SyncReport): SyncReport {\n\treturn report\n}\n\n/** `audit --json`'s value — the `Audit` verbatim. */\nexport function auditJson(audit: Audit): Audit {\n\treturn audit\n}\n\n/** `repair --json`'s value — the `Audit` plus the `MaterializeResult` when `--apply` ran. */\nexport function repairJson(\n\taudit: Audit,\n\tresult?: MaterializeResult,\n): Audit | (Audit & { readonly result: MaterializeResult }) {\n\treturn result === undefined ? audit : { ...audit, result }\n}\n\n/** `fleet --json`'s value — a top-level ARRAY of per-repo objects, one entry per package. */\nexport function fleetJson(\n\tentries: readonly {\n\t\treadonly name: string\n\t\treadonly drifted: number\n\t\treadonly missing: number\n\t\treadonly foreign: number\n\t\treadonly failed: boolean\n\t}[],\n): readonly {\n\treadonly name: string\n\treadonly drifted: number\n\treadonly missing: number\n\treadonly foreign: number\n\treadonly failed: boolean\n}[] {\n\treturn entries\n}\n\n/** `catalog --json`'s value — the entries, drift flag, and optional shrink count. */\nexport function catalogJson(\n\tentries: readonly CatalogEntry[],\n\tdrifted: boolean,\n\tshrink?: number,\n): {\n\treadonly entries: readonly CatalogEntry[]\n\treadonly drift: boolean\n\treadonly shrink?: number\n} {\n\treturn shrink === undefined ? { entries, drift: drifted } : { entries, drift: drifted, shrink }\n}\n\n/** `enabled` for `createStyler` — off under `NO_COLOR` or when the sink is not a TTY (both read by the caller). */\nexport function chooseStyler(sinkIsTTY: boolean, noColor: boolean): StylerInterface {\n\treturn createStyler({ enabled: !noColor && sinkIsTTY })\n}\n\n/** Whether a long-running step should animate a spinner (TTY) or fall back to a one-line `status` (piped/non-TTY). */\nexport function shouldSpin(sinkIsTTY: boolean): boolean {\n\treturn sinkIsTTY\n}\n\n/** One line per exact relative path that WOULD be deleted — printed before the prune confirm. */\nexport function prunePreview(paths: readonly string[]): readonly string[] {\n\treturn paths.map((path) => ` delete ${path}`)\n}\n\n/** Printed when the prune scan finds nothing to delete. */\nexport const PRUNE_EMPTY = 'no unexpected files to delete'\n\n/** Printed on a non-TTY session when the prune question cannot be asked. */\nexport function pruneSkipped(): string {\n\treturn 'prune skipped — not a terminal; add --apply (or --yes) to delete non-interactively'\n}\n\n/** Non-TTY usage-error guidance for a missing required input. */\nexport function missingInput(what: string, verb: string): string {\n\treturn `missing ${what} — pass it as a flag/argument, or run 'scaffold ${verb}' on a terminal to be guided`\n}\n\n/** Printed when `audit` cannot establish the template source for the unexpected-file scan — the audit degrades to the un-scanned findings instead of crashing. */\nexport function scanSkipped(): string {\n\treturn \"unexpected-file scanning skipped — couldn't establish the template source\"\n}\n\n/** Usage-error message for a `new` package name that fails `PACKAGE_NAME_PATTERN` — same shape the interactive prompt enforces. */\nexport function invalidName(name: string, pattern: string): string {\n\treturn `Package name \"${name}\" must match ${pattern}`\n}\n\n/** `new`'s hard failure when `sync.versions` cannot resolve a latest version for one or more `--deps` names — names every unresolved package plainly so a `^` (unresolved-latest) range can never be silently written. */\nexport function unresolvedVersion(names: readonly string[]): string {\n\treturn `could not resolve the latest version for ${names.map((name) => `\"${name}\"`).join(', ')} — check the name or pass name@range`\n}\n\n/** Printed when every finding is `generated` drift — repair does not touch generated files. */\nexport function generatedNote(count: number): string {\n\treturn `${countPart(count, 'finding')} in generated files — these are regenerated, not hand-edited; repair does not touch them`\n}\n\n/** `audit --live`'s freshness summary line. */\nexport function auditLiveNote(current: number, behind: number, failed: number): string {\n\treturn `live: ${countPart(current, 'current')}, ${countPart(behind, 'behind')}, ${countPart(failed, 'failed')}`\n}\n\n/** Translated vocabulary for whether the audit compared file contents or only file names, for template-owned files. */\nexport function comparisonLine(aware: boolean): string {\n\treturn aware\n\t\t? 'comparing: file contents for template-owned files'\n\t\t: 'comparing: file names only for template-owned files (no vendored source found)'\n}\n\n/** `fleet`'s ci.yml note — each package customizes its own CI, so `fleet` leaves it unchanged. */\nexport function fleetCiSkipped(): string {\n\treturn \"ci.yml: left unchanged — each package customizes its own CI; run 'scaffold repair --apply' inside that package to update it\"\n}\n\n/** `catalog`'s verdict line — clean or drifted. */\nexport function catalogVerdict(clean: boolean): string {\n\treturn clean ? 'catalog: clean' : 'catalog: drifted — pass --apply to write'\n}\n","// The `#!/usr/bin/env node` shebang is re-emitted by the build's `output.banner`, not source.\nimport { existsSync, readFileSync, realpathSync, writeFileSync } from 'node:fs'\nimport { basename, dirname, join, relative as relativeOf, resolve, sep } from 'node:path'\nimport * as tls from 'node:tls'\nimport { parseArgs } from 'node:util'\nimport type {\n\tAudit,\n\tBlueprint,\n\tCatalogEntry,\n\tDependency,\n\tFinding,\n\tGroup,\n\tPlan,\n\tSyncReport,\n} from '@src/core'\nimport {\n\tblueprint,\n\tblueprintToPlan,\n\tcatalogNames,\n\tcatalogToBlock,\n\tcreateCompiler,\n\tdependency,\n\tDEPENDENCY_NAME_PATTERN,\n\tdiffPlan,\n\tGROUPS,\n\tisScaffoldError,\n\tmanifestToDependencies,\n\tNAME_PATTERN,\n\tplanToSummary,\n\tScaffoldError,\n\tSURFACES,\n} from '@src/core'\nimport {\n\tcatalogPackages,\n\tcreateMaterializer,\n\tcreateSync,\n\tderiveBlueprint,\n\tdiscoverPackages,\n\thostRoot,\n\thydratePlan,\n\tlocateHostSource,\n\tpruneTargets,\n\treadHostManifest,\n\treadManifest,\n\treadTarget,\n} from '@src/server'\nimport type { SpinnerInterface } from '@orkestrel/console'\nimport { createReporter, createSpinner } from '@orkestrel/console'\nimport { createServerSink } from '@orkestrel/console/server'\nimport { isTerminalError } from '@orkestrel/terminal'\nimport type { TerminalInterface } from '@orkestrel/terminal/server'\nimport { createTerminal } from '@orkestrel/terminal/server'\nimport type { Verb } from './render.js'\nimport {\n\tapplyConfirmMessage,\n\tauditJson,\n\tauditLiveNote,\n\tauditTable,\n\tauditVerdict,\n\tCANCELLED_MESSAGE,\n\tcatalogApplySuccess,\n\tcatalogCounts,\n\tcatalogJson,\n\tcatalogShrinkWarning,\n\tcatalogTable,\n\tcatalogUnresolvedNote,\n\tcatalogVerdict,\n\tchooseStyler,\n\tcomparisonLine,\n\tdidYouMean,\n\terrorEnvelope,\n\tfleetCiSkipped,\n\tfleetRepoLine,\n\tfleetTotals,\n\tforeignHint,\n\tfullHelp,\n\tgeneratedNote,\n\tinvalidName,\n\tINVALID_ARGUMENTS_MESSAGE,\n\tKNOWN_VERBS,\n\tmissingInput,\n\tnearest,\n\tnewApplySuccess,\n\tnewJson,\n\tNEW_DRY_RUN_NOTE,\n\tnewPlanPreview,\n\tnewPlanTable,\n\torkestrelDepsPrompt,\n\tprunePreview,\n\tPRUNE_EMPTY,\n\tpruneConfirmMessage,\n\tpruneSkipped,\n\tpullCauseNotes,\n\tpullJson,\n\tpullSuccess,\n\tpullTable,\n\tpullVerdict,\n\trepairHandoff,\n\trepairJson,\n\trepairSuccess,\n\trepairVerdict,\n\tREPAIR_SCOPE,\n\tscanSkipped,\n\tscopeNote,\n\tshortUsage,\n\tshouldSpin,\n\tsurfaceChoices,\n\tunknownOrkestrelToken,\n\tunresolvedVersion,\n\tverbHelp,\n\tfleetJson,\n} from './render.js'\n\nconst sink = createServerSink()\nconst sinkIsTTY = process.stdout.isTTY === true\nconst noColor = process.env.NO_COLOR !== undefined\nconst styler = chooseStyler(sinkIsTTY, noColor)\nconst reporter = createReporter({ sink, width: sink.columns, styler })\n\n/**\n * Widen Node's default trusted-issuer set to include the OS certificate\n * store, so `fetch` behind a corporate TLS-inspecting proxy behaves like npm\n * (`cafile`) and browsers (OS trust store) instead of failing with\n * `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` against Node's bundled CA list alone.\n * Feature-detected (`tls.getCACertificates` / `tls.setDefaultCACertificates`\n * ship on Node ≈22.16+/24.5+; this package's floor is `>=22`) and wrapped in\n * try/catch — any failure is a silent no-op, never a crash. This only ADDS\n * trusted issuers; it never touches `rejectUnauthorized` or\n * `NODE_TLS_REJECT_UNAUTHORIZED`, so certificate verification stays on.\n */\nfunction trustSystemCertificates(): void {\n\tif (\n\t\ttypeof tls.getCACertificates !== 'function' ||\n\t\ttypeof tls.setDefaultCACertificates !== 'function'\n\t) {\n\t\treturn\n\t}\n\ttry {\n\t\tconst merged = new Set([\n\t\t\t...tls.getCACertificates('default'),\n\t\t\t...tls.getCACertificates('system'),\n\t\t])\n\t\ttls.setDefaultCACertificates([...merged])\n\t} catch {\n\t\t// Trust-store quirks never crash the CLI — fetch failures still surface their own diagnosis.\n\t}\n}\n\n/**\n * The one sentinel that unwinds the whole command dispatch to a chosen exit\n * code (H4/Windows) — thrown instead of calling `process.exit`, so every\n * `finally` between the throw site and the top-level driver still runs\n * (entity teardown drains naturally instead of racing process teardown).\n * Caught exactly once, at the bottom of this file.\n */\nclass CliExit extends Error {\n\treadonly code: number\n\n\tconstructor(code: number) {\n\t\tsuper(`cli-exit:${String(code)}`)\n\t\tthis.code = code\n\t}\n}\n\n/** Halt command dispatch with `code` (H4) — never `process.exit`; unwinds through every `finally` first. */\nfunction halt(code: number): never {\n\tthrow new CliExit(code)\n}\n\n/** Render a caught error as a clean one-line message — a `ScaffoldError`'s code, or a bare message otherwise. */\nfunction describe(error: unknown): string {\n\tif (isScaffoldError(error)) return `[${error.code}] ${error.message}`\n\treturn error instanceof Error ? error.message : 'unknown error'\n}\n\n/** Write ONE machine-readable JSON value to stdout — the entire `--json` output contract. */\nfunction writeJson(value: unknown): void {\n\tprocess.stdout.write(`${JSON.stringify(value)}\\n`)\n}\n\n/**\n * Whether the current invocation carries `--json` — set once `parseArguments`\n * has run (`main`'s first act), so the OUTERMOST catch (bottom of this file)\n * can still honor `--json` for an error that escapes every verb runner's own\n * handling, emitting exactly one JSON error envelope instead of prose.\n */\nlet sessionJson = false\n\n/** A general operation failure (H1: exit 1) — a prose status line, or the one JSON error envelope under `--json`. */\nfunction fail(message: string, json: boolean): never {\n\tif (json) writeJson(errorEnvelope('ERROR', message))\n\telse reporter.status('error', message)\n\thalt(1)\n}\n\n/**\n * A general operation failure FROM A CAUGHT ERROR (H1: exit 1) — the real\n * `ScaffoldError` code when available ('ERROR' last resort), prose (via\n * `describe`, which still carries the bracketed code for a human reader) or\n * the one JSON error envelope under `--json` (code and message kept\n * SEPARATE — never double-encoding the code into the message text).\n */\nfunction failError(error: unknown, json: boolean): never {\n\tif (json) {\n\t\tconst code = isScaffoldError(error) ? error.code : 'ERROR'\n\t\tconst message = isScaffoldError(error) ? error.message : describe(error)\n\t\twriteJson(errorEnvelope(code, message))\n\t} else {\n\t\treporter.status('error', describe(error))\n\t}\n\thalt(1)\n}\n\n/** A usage error (bad flag value, unknown verb — exit 2) — stderr prose, or the one JSON error envelope under `--json`. */\nfunction usageFail(message: string, json: boolean): never {\n\tif (json) writeJson(errorEnvelope('USAGE', message))\n\telse process.stderr.write(`${message}\\n`)\n\thalt(2)\n}\n\n// Realpath-resolve the DEEPEST EXISTING ancestor of `path` (following any\n// symlink it or its ancestors are), then rejoin the still-nonexistent\n// remainder unchanged — mirrors the server `Materializer`'s `#resolveReal` so\n// a not-yet-created destination is checked against where a symlinked segment\n// actually points, without realpath'ing a leaf that does not exist yet.\nfunction resolveReal(path: string): string {\n\tif (existsSync(path)) return realpathSync(path)\n\tconst parent = dirname(path)\n\tif (parent === path) return path\n\treturn join(resolveReal(parent), relativeOf(parent, path))\n}\n\n/**\n * Confine a WRITE destination to the current working directory (global-CLI\n * safety): `new`'s resolved target, `--target` on pull/audit/repair/catalog,\n * and `fleet`'s always-cwd root all pass through here before use. A\n * READ-ONLY source (`--from`) is exempt — sibling-repo sourcing from outside\n * the cwd is legitimate. Equal to the cwd or nested beneath it passes;\n * anything else is a coded `INVALID` failure (AGENTS §12), never a silent clamp.\n *\n * @returns The resolved (non-realpath'd) absolute path, for use as the\n * verb's destination.\n */\nfunction containDestination(candidate: string): string {\n\tconst resolvedCwd = resolveReal(resolve(process.cwd()))\n\tconst resolvedCandidate = resolveReal(resolve(candidate))\n\tif (resolvedCandidate !== resolvedCwd && !resolvedCandidate.startsWith(resolvedCwd + sep)) {\n\t\tthrow new ScaffoldError(\n\t\t\t'INVALID',\n\t\t\t`Target \"${candidate}\" escapes the working directory — run scaffold from the directory you want to write beneath.`,\n\t\t\t{ path: candidate },\n\t\t)\n\t}\n\treturn resolve(candidate)\n}\n\n/** `containDestination`, halting (H1/`fail`) on a coded escape instead of throwing — the shared entry every runner's target resolution goes through. */\nfunction containOrFail(candidate: string, json: boolean): string {\n\ttry {\n\t\treturn containDestination(candidate)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n}\n\n/** Compile `spec` and unwrap its `plan`, halting (H1/`fail`) with the joined open-question text when compilation could not resolve one — the shared entry every runner's compile step goes through. */\nfunction compileOrFail(spec: Blueprint, json: boolean): Plan {\n\tconst compiler = createCompiler()\n\ttry {\n\t\tconst scaffolding = compiler.compile(spec)\n\t\tif (!scaffolding.plan) {\n\t\t\tconst message = scaffolding.questions.map((question) => question.text).join('; ')\n\t\t\tfail(message, json)\n\t\t}\n\t\treturn scaffolding.plan\n\t} finally {\n\t\tcompiler.destroy()\n\t}\n}\n\n/** `node:util`'s strict `parseArgs`, isolated so its throw on an unknown/malformed flag is catchable (H3). */\nfunction parseArguments() {\n\t// Strip a single leading literal '--' (npm passthrough residue that\n\t// PowerShell mangles, e.g. `npm run scaffold -- new x`) so it parses as `new x`.\n\tconst args = process.argv.slice(2)\n\tif (args[0] === '--') args.shift()\n\treturn parseArgs({\n\t\targs,\n\t\tallowPositionals: true,\n\t\toptions: {\n\t\t\tsurfaces: { type: 'string' },\n\t\t\tdeps: { type: 'string' },\n\t\t\tgroups: { type: 'string' },\n\t\t\ttarget: { type: 'string' },\n\t\t\tfrom: { type: 'string', multiple: true },\n\t\t\tapply: { type: 'boolean', default: false },\n\t\t\tyes: { type: 'boolean', default: false },\n\t\t\tjson: { type: 'boolean', default: false },\n\t\t\tprune: { type: 'boolean', default: false },\n\t\t\tstrict: { type: 'boolean', default: false },\n\t\t\tlive: { type: 'boolean', default: false },\n\t\t\toffline: { type: 'boolean', default: false },\n\t\t\thelp: { type: 'boolean', default: false, short: 'h' },\n\t\t},\n\t})\n}\n\n/** The parsed CLI flags — every verb runner reads the same bag (unused flags for a verb are simply ignored). */\ntype Values = ReturnType<typeof parseArguments>['values']\n\n/** Narrow a positional command to the closed `Verb` vocabulary (render.ts's `KNOWN_VERBS`). */\nfunction isVerb(value: string): value is Verb {\n\treturn KNOWN_VERBS.some((verb) => verb === value)\n}\n\n/**\n * Best-effort `hydratePlan` — used by `audit` / `repair` / `fleet` so a\n * missing DEFAULT vendored-source root degrades to presence-only auditing\n * instead of failing the verb. An EXPLICITLY-passed `--from` that does not\n * resolve to a usable directory is NOT downgraded silently — that is a coded\n * `TARGET` failure (M1), since the caller named that source on purpose.\n */\nfunction hydrateBestEffort(\n\tplan: Plan,\n\thost: string,\n\texplicit: boolean,\n): { readonly plan: Plan; readonly aware: boolean } {\n\tif (!existsSync(host)) {\n\t\tif (explicit) {\n\t\t\tthrow new ScaffoldError('TARGET', `--from does not resolve to a directory: ${host}`, {\n\t\t\t\thost,\n\t\t\t})\n\t\t}\n\t\treturn { plan, aware: false }\n\t}\n\ttry {\n\t\treturn { plan: hydratePlan(plan, host), aware: true }\n\t} catch (error) {\n\t\tif (isScaffoldError(error) && error.code === 'TARGET') return { plan, aware: false }\n\t\tthrow error\n\t}\n}\n\n/**\n * Merge a `pruneTargets` scan into `audit` as `foreign` findings — pure\n * object-spread composition in the BIN only (`src/core`'s `diffPlan` is never\n * modified/reimplemented). Every unexpected path becomes one\n * `'orchestration'`-group `foreign` finding (the `Group` every `PRUNE_DIRECTORIES`\n * entry — `.claude/agents`, `scripts` — belongs to); any scan hit makes the\n * merged audit unclean, so an \"unexpected file\" is honestly counted as drift\n * (exit 1) instead of the structurally-always-zero `diffPlan.foreign`.\n */\nfunction withForeignScan(audit: Audit, target: string, host: string): Audit {\n\tconst paths = pruneTargets(target, host)\n\tif (paths.length === 0) return audit\n\tconst findings: Finding[] = paths.map((path) => ({\n\t\tpath,\n\t\tgroup: 'orchestration',\n\t\tdrift: 'foreign',\n\t}))\n\treturn {\n\t\t...audit,\n\t\tclean: false,\n\t\tforeign: audit.foreign + paths.length,\n\t\tfindings: [...audit.findings, ...findings],\n\t}\n}\n\n/**\n * `withForeignScan`, degrading instead of crashing (F3): `pruneTargets` throws\n * a coded `TARGET` failure when a prune directory exists under `target` but\n * `host` cannot positively establish its allowlist (`vendoredPruneSet`'s\n * fail-closed contract) — an audit should report the un-scanned findings and\n * say scanning was skipped, never crash on this alone (`runFleet` already\n * shields its own per-repo audit the same way).\n */\nfunction withForeignScanSafe(\n\taudit: Audit,\n\ttarget: string,\n\thost: string,\n): { readonly audit: Audit; readonly skipped: boolean } {\n\ttry {\n\t\treturn { audit: withForeignScan(audit, target, host), skipped: false }\n\t} catch (error) {\n\t\tif (isScaffoldError(error) && error.code === 'TARGET') return { audit, skipped: true }\n\t\tthrow error\n\t}\n}\n\n/**\n * `repair`'s own scope is host-only, but the caller compiles the FULL plan anyway — diff it too\n * (cheap, local, no network) so a clean host verdict can point at drift OUTSIDE repair's reach.\n * The count feeds render.ts's `scopeNote`.\n */\nfunction repairOutsideCount(compiled: Plan, target: string): number {\n\tconst full = diffPlan(\n\t\tcompiled,\n\t\treadTarget(\n\t\t\ttarget,\n\t\t\tcompiled.artifacts.map((artifact) => artifact.path),\n\t\t),\n\t)\n\treturn full.drifted + full.missing + full.foreign\n}\n\n/** One `fleet --json` entry — `undefined` counts (a failed repo never got an audit) fall back to zero. */\nfunction fleetEntry(\n\tname: string,\n\tcounts:\n\t\t| { readonly drifted: number; readonly missing: number; readonly foreign: number }\n\t\t| undefined,\n\tfailed: boolean,\n): {\n\treadonly name: string\n\treadonly drifted: number\n\treadonly missing: number\n\treadonly foreign: number\n\treadonly failed: boolean\n} {\n\treturn {\n\t\tname,\n\t\tdrifted: counts?.drifted ?? 0,\n\t\tmissing: counts?.missing ?? 0,\n\t\tforeign: counts?.foreign ?? 0,\n\t\tfailed,\n\t}\n}\n\n/** Reject a cancelled prompt (ctrl-c) with the shared `CANCELLED_MESSAGE` — exit 1, nothing written. */\nasync function guarded<T>(promise: Promise<T>): Promise<T> {\n\ttry {\n\t\treturn await promise\n\t} catch (error) {\n\t\tif (isTerminalError(error) && error.code === 'CANCEL') {\n\t\t\treporter.line(CANCELLED_MESSAGE)\n\t\t\thalt(1)\n\t\t}\n\t\tthrow error\n\t}\n}\n\n/**\n * The shared write-confirmation gate every verb calls before it touches disk.\n * `--apply` writes without asking; `--json` (without `--apply`) is a pure\n * dry-run and NEVER prompts; `--yes` auto-answers yes; otherwise a real\n * confirm with `default: false` (EOF on stdin resolves to the default).\n */\nasync function resolveApply(\n\tterminal: TerminalInterface,\n\tmessage: string,\n\tvalues: Values,\n\tjson: boolean,\n): Promise<boolean> {\n\tif (values.apply) return true\n\tif (json) return false\n\tif (values.yes) return true\n\treturn guarded(terminal.confirm({ message, default: false }))\n}\n\n/**\n * The SECOND, separate confirm for `--prune`-eligible deletions — never\n * bundled into `resolveApply`'s question. `--yes` only auto-answers this\n * when `--prune` was also passed (it never enables pruning by itself).\n */\nasync function resolvePrune(\n\tterminal: TerminalInterface,\n\tmessage: string,\n\tvalues: Values,\n\tjson: boolean,\n): Promise<boolean> {\n\tif (!values.prune) return false\n\tif (values.apply) return true\n\tif (json) return false\n\tif (values.yes) return true\n\t// One-prompt-per-non-TTY-process ceiling (S3f): the write confirm\n\t// (`resolveApply`) already spent the ONE prompt a non-interactive stream\n\t// can reliably answer — a second `terminal.confirm` off the same drained\n\t// stdin hangs until the runtime's watchdog kills the process. Pruning is\n\t// therefore never asked on non-TTY; it resolves `false` and prints\n\t// `pruneSkipped()` instead.\n\tif (!sinkIsTTY) {\n\t\treporter.line(pruneSkipped())\n\t\treturn false\n\t}\n\treturn guarded(terminal.confirm({ message, default: false }))\n}\n\n/** A spinner for a long-running write step — `undefined` under `--json` or off a TTY sink (render.ts's `shouldSpin`). */\nfunction createSpinnerMaybe(message: string, json: boolean): SpinnerInterface | undefined {\n\treturn json || !shouldSpin(sinkIsTTY) ? undefined : createSpinner({ message, sink, styler })\n}\n\n/** Announce a successful write — the spinner's own success line, or a plain `reporter.status` without one (never under `--json`). */\nfunction announceApply(\n\tspinner: SpinnerInterface | undefined,\n\tjson: boolean,\n\tmessage: string,\n): void {\n\tif (spinner) spinner.success(message)\n\telse if (!json) reporter.status('success', message)\n}\n\n/** Announce a failed write and halt(1) — the spinner's own failure line (if any), then the shared `fail`. */\nfunction announceFailure(\n\tspinner: SpinnerInterface | undefined,\n\tjson: boolean,\n\terror: unknown,\n): never {\n\tconst message = describe(error)\n\tif (spinner) spinner.failure(message)\n\tfail(message, json)\n}\n\n/** Split a comma-separated token list, trimming and dropping empties — the parse `new`'s dependency prompt goes through. */\nfunction splitTokens(raw: string): readonly string[] {\n\treturn raw\n\t\t.split(',')\n\t\t.map((token) => token.trim())\n\t\t.filter((token) => token.length > 0)\n}\n\n/** Normalize a Q1 token to a full `@orkestrel/<name>` — an already-prefixed token passes through unchanged. */\nfunction normalizeOrkestrelToken(token: string): string {\n\treturn token.startsWith('@orkestrel/') ? token : `@orkestrel/${token}`\n}\n\n/**\n * Best-effort vendored `@orkestrel` catalog names, resolved via `host`\n * (`hostRoot()`, or the active `--from` override) through the host manifest\n * — `undefined` when the catalog cannot be established (a missing/unreadable\n * manifest, no `.claude/agents/orkestrel.md` entry, or any other failure),\n * degrading Q1 to shape-only validation instead of blocking on it.\n */\nfunction resolveCatalogNames(host: string): readonly string[] | undefined {\n\ttry {\n\t\tconst manifest = readHostManifest(host)\n\t\tconst full = locateHostSource(manifest, '.claude/agents/orkestrel.md', host)\n\t\tif (full === undefined || !existsSync(full)) return undefined\n\t\treturn catalogNames(readFileSync(full, 'utf8'))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/** One Q1 token's issue against `catalog` (`undefined` = valid) — shape-only (`DEPENDENCY_NAME_PATTERN`) when `catalog` itself could not be resolved. */\nfunction orkestrelTokenIssue(\n\tnormalized: string,\n\tcatalog: readonly string[] | undefined,\n): string | undefined {\n\tif (catalog === undefined) {\n\t\treturn DEPENDENCY_NAME_PATTERN.test(normalized)\n\t\t\t? undefined\n\t\t\t: unknownOrkestrelToken(normalized, undefined)\n\t}\n\tif (catalog.includes(normalized)) return undefined\n\treturn unknownOrkestrelToken(normalized, nearest(normalized, catalog))\n}\n\n/** Q1 (TTY only) — `@orkestrel` short-name deps, re-asking on any unresolved token until the input is clean or empty. */\nasync function promptOrkestrelDeps(\n\tterminal: TerminalInterface,\n\tcatalog: readonly string[] | undefined,\n): Promise<readonly string[]> {\n\tfor (;;) {\n\t\tconst raw = await guarded(terminal.input({ message: orkestrelDepsPrompt(), default: '' }))\n\t\tconst tokens = splitTokens(raw)\n\t\tif (tokens.length === 0) return []\n\t\tconst normalized = tokens.map(normalizeOrkestrelToken)\n\t\tconst issue = normalized\n\t\t\t.map((token) => orkestrelTokenIssue(token, catalog))\n\t\t\t.find((message) => message !== undefined)\n\t\tif (issue === undefined) return normalized\n\t\treporter.line(issue)\n\t}\n}\n\n/** `scaffold new` — scaffold a package into `./<name>` (or `--target`). */\nasync function runNew(values: Values, argument: string | undefined, json: boolean): Promise<void> {\n\tconst terminal = createTerminal()\n\n\tlet name: string\n\tif (argument !== undefined) {\n\t\tname = argument\n\t} else if (json) {\n\t\tusageFail('a package name is required with --json', json)\n\t} else if (!sinkIsTTY) {\n\t\tusageFail(missingInput('a package name', 'new'), json)\n\t} else {\n\t\tname = await guarded(\n\t\t\tterminal.input({\n\t\t\t\tmessage: 'Package name',\n\t\t\t\tvalidate: { pattern: NAME_PATTERN.source },\n\t\t\t}),\n\t\t)\n\t}\n\t// F4: the positional (or interactively-collected) name is validated against\n\t// the SAME `NAME_PATTERN` (core's single source of truth) the interactive\n\t// prompt enforces — a positional name never bypassed this shape before.\n\tif (!NAME_PATTERN.test(name)) {\n\t\tusageFail(invalidName(name, NAME_PATTERN.source), json)\n\t}\n\n\tlet surfaceInput: readonly string[]\n\tif (values.surfaces !== undefined) {\n\t\tsurfaceInput = values.surfaces.split(',')\n\t} else if (json) {\n\t\tusageFail('--surfaces is required with --json', json)\n\t} else if (!sinkIsTTY) {\n\t\tusageFail(missingInput('--surfaces', 'new'), json)\n\t} else {\n\t\tsurfaceInput = await guarded(\n\t\t\tterminal.checkbox({ message: 'Surfaces', choices: surfaceChoices(), min: 1 }),\n\t\t)\n\t}\n\tconst unrecognizedSurface = surfaceInput.filter(\n\t\t(candidate) => !SURFACES.some((surface) => surface === candidate),\n\t)\n\tif (unrecognizedSurface.length > 0) {\n\t\tusageFail(`Surface \"${unrecognizedSurface.join('\", \"')}\" is not recognized`, json)\n\t}\n\tconst surfaces = SURFACES.filter((surface) => surfaceInput.includes(surface))\n\n\t// S3g: containment happens ONCE, here, near the top — before any preview,\n\t// network call, or confirm — so a `--target` escape is caught up front\n\t// rather than after the user has already reviewed a plan for a\n\t// destination the write can never reach.\n\tconst destination = containOrFail(values.target ?? `./${name}`, json)\n\n\t// `--deps` is OPTIONAL — a non-TTY session with neither `--json` nor\n\t// `--deps` defaults to no extra dependencies rather than failing (only a\n\t// REQUIRED input triggers `missingInput`'s usage error); the multi-prompt\n\t// guidance below stays TTY-only (S3f's one-prompt-per-process ceiling).\n\t// `--deps` keeps its EXACT prior mechanism verbatim — untrimmed split,\n\t// `DEPENDENCY_NAME_PATTERN`-gated BEFORE any network call (A3). The\n\t// interactive Q1 replaces only the FREE-TEXT prompt, with short-name\n\t// normalization + vendored-catalog validation (re-asking on an unknown\n\t// token, degrading to shape-only when the catalog cannot be resolved).\n\tlet depNames: readonly string[]\n\tif (values.deps !== undefined) {\n\t\tdepNames = values.deps.split(',').filter((depName) => depName.length > 0)\n\t\tconst badDep = depNames.find((depName) => !DEPENDENCY_NAME_PATTERN.test(depName))\n\t\tif (badDep !== undefined) {\n\t\t\tusageFail(`Dependency name \"${badDep}\" must match ${DEPENDENCY_NAME_PATTERN.source}`, json)\n\t\t}\n\t} else if (json || !sinkIsTTY) {\n\t\tdepNames = []\n\t} else {\n\t\tconst catalogHost = values.from?.[0] ?? hostRoot()\n\t\tconst catalog = resolveCatalogNames(catalogHost)\n\t\tif (catalog === undefined) reporter.line(catalogUnresolvedNote())\n\t\tdepNames = await promptOrkestrelDeps(terminal, catalog)\n\t}\n\n\t// --deps/Q1 resolve latest from the registry → ranges pin ^latest; their\n\t// guides fetch into the plan.\n\tconst sync = createSync()\n\tlet versions\n\ttry {\n\t\tversions = await sync.versions(depNames.map((depName) => dependency(depName, '*')))\n\t} finally {\n\t\tsync.destroy()\n\t}\n\t// `createSync()` is non-strict — it never throws — so a range-less\n\t// `--deps` name that the registry could not resolve (`freshness`\n\t// 'missing'/'failed', `latest` '') is a HARD failure here: writing `^` +\n\t// an empty `latest` would otherwise land an unwritable `\"^\"` range in\n\t// package.json with exit 0.\n\tconst unresolved = versions\n\t\t.filter(\n\t\t\t(version) =>\n\t\t\t\t(version.freshness !== 'current' && version.freshness !== 'behind') ||\n\t\t\t\tversion.latest === '',\n\t\t)\n\t\t.map((version) => version.name)\n\tif (unresolved.length > 0) fail(unresolvedVersion(unresolved), json)\n\tconst deps = versions.map((version) => dependency(version.name, `^${version.latest}`))\n\n\t// Extra devDependencies are no longer collected here — hand-add them to\n\t// `package.json` after scaffolding; `deriveBlueprint`'s extras round-trip\n\t// (`@src/server`) recompiles them back into the plan, so `audit` stays\n\t// clean over a hand-added `devDependencies` entry (AGENTS §21 core stays\n\t// the single source of truth for that relaxation).\n\tconst plan = compileOrFail(blueprint(name, { surfaces, dependencies: deps }), json)\n\n\tconst summary = planToSummary(plan)\n\n\tif (!json) {\n\t\treporter.section('Plan')\n\t\treporter.table(newPlanTable(summary))\n\t\treporter.line(newPlanPreview(name))\n\t}\n\n\tconst proceed = await resolveApply(\n\t\tterminal,\n\t\tapplyConfirmMessage(summary.host + summary.template + summary.computed),\n\t\tvalues,\n\t\tjson,\n\t)\n\n\tif (!proceed) {\n\t\tif (json) writeJson(newJson(summary, false))\n\t\telse reporter.line(NEW_DRY_RUN_NOTE)\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tconst spinner = createSpinnerMaybe('materializing', json)\n\tspinner?.start()\n\tconst materializer = createMaterializer({ host: values.from?.[0] })\n\ttry {\n\t\tconst result = materializer.materialize(plan, destination)\n\t\tconst count = result.written.length + result.copied.length\n\t\tif (json) writeJson(newJson(summary, true))\n\t\telse announceApply(spinner, json, newApplySuccess(count, name))\n\t} catch (error) {\n\t\tannounceFailure(spinner, json, error)\n\t} finally {\n\t\tmaterializer.destroy()\n\t}\n\tprocess.exitCode = 0\n}\n\n/** `scaffold pull` — refresh vendored dependency mirrors and report range drift. */\nasync function runPull(values: Values, json: boolean): Promise<void> {\n\tconst target = containOrFail(values.target ?? '.', json)\n\n\tconst sync = createSync({ strict: values.strict })\n\ttry {\n\t\tconst wanted = values.deps?.split(',')\n\t\tlet report: SyncReport\n\t\ttry {\n\t\t\tconst declared = manifestToDependencies(readManifest(target))\n\t\t\tconst deps = wanted ? declared.filter((dep) => wanted.includes(dep.name)) : declared\n\t\t\tif (wanted) {\n\t\t\t\tconst guides = await sync.guides(deps)\n\t\t\t\tconst versions = await sync.versions(deps)\n\t\t\t\tconst failed = [...guides, ...versions].filter(\n\t\t\t\t\t(entry) => entry.freshness === 'missing' || entry.freshness === 'failed',\n\t\t\t\t).length\n\t\t\t\tconst clean =\n\t\t\t\t\tfailed === 0 &&\n\t\t\t\t\tguides.every((guide) => guide.freshness === 'current') &&\n\t\t\t\t\tversions.every((version) => version.freshness === 'current')\n\t\t\t\treport = { target, guides, versions, clean, failed }\n\t\t\t} else {\n\t\t\t\treport = await sync.pull(target)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfailError(error, json)\n\t\t}\n\n\t\tif (!json) {\n\t\t\treporter.table(pullTable(report))\n\t\t\tfor (const line of pullCauseNotes(report)) reporter.line(line)\n\t\t\treporter.line(pullVerdict(report))\n\t\t}\n\n\t\tconst toWrite = [...report.guides, ...report.versions].filter(\n\t\t\t(entry) => entry.freshness !== 'current',\n\t\t).length\n\n\t\tconst terminal = createTerminal()\n\t\tconst proceed =\n\t\t\ttoWrite > 0 ? await resolveApply(terminal, applyConfirmMessage(toWrite), values, json) : false\n\n\t\tif (proceed) {\n\t\t\tconst spinner = createSpinnerMaybe('writing mirrors', json)\n\t\t\tspinner?.start()\n\t\t\ttry {\n\t\t\t\tconst written = await sync.write(report, target)\n\t\t\t\tif (json) writeJson(pullJson(report))\n\t\t\t\telse announceApply(spinner, json, pullSuccess(written.length))\n\t\t\t} catch (error) {\n\t\t\t\tannounceFailure(spinner, json, error)\n\t\t\t}\n\t\t} else if (json) {\n\t\t\twriteJson(pullJson(report))\n\t\t}\n\n\t\tprocess.exitCode = report.clean ? 0 : proceed ? 0 : 1\n\t} finally {\n\t\tsync.destroy()\n\t}\n}\n\n/** `scaffold audit` — whole-plan conformance report; offers a repair handoff on drift. */\nasync function runAudit(values: Values, json: boolean): Promise<void> {\n\tconst target = containOrFail(values.target ?? '.', json)\n\n\tlet spec: Blueprint\n\ttry {\n\t\tspec = deriveBlueprint(target)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\n\tconst deps: readonly Dependency[] = [...spec.dependencies, ...spec.peers, ...spec.extras]\n\n\tconst groupsInput = values.groups?.split(',')\n\tlet groups: readonly Group[] | undefined\n\tif (groupsInput !== undefined) {\n\t\tconst unrecognized = groupsInput.filter((name) => !GROUPS.some((group) => group === name))\n\t\tif (unrecognized.length > 0) {\n\t\t\tusageFail(`Group \"${unrecognized.join('\", \"')}\" is not recognized`, json)\n\t\t}\n\t\tgroups = GROUPS.filter((group) => groupsInput.includes(group))\n\t}\n\n\tconst compiled = blueprintToPlan(spec, groups)\n\tconst from = values.from?.[0]\n\tconst host = from ?? hostRoot()\n\tlet hydrated: { readonly plan: Plan; readonly aware: boolean }\n\ttry {\n\t\thydrated = hydrateBestEffort(compiled, host, from !== undefined)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\tconst plan = hydrated.plan\n\tconst artifactPaths = plan.artifacts.map((artifact) => artifact.path)\n\n\t// S3b (honest audit): merge the `pruneTargets` scan into the presented\n\t// audit — an \"unexpected file\" is real drift here, not the structurally-\n\t// always-zero `diffPlan.foreign`. Only attempted when the host is actually\n\t// established (`hydrated.aware`) — the same condition `hostRoot`/`--from`\n\t// already require to positively enumerate a vendored allowlist. F3: the\n\t// scan itself degrades (never crashes) when a prune dir exists under\n\t// `target` but `host` cannot establish its allowlist.\n\tconst rawAudit = diffPlan(plan, readTarget(target, artifactPaths))\n\tconst scanned = hydrated.aware\n\t\t? withForeignScanSafe(rawAudit, target, host)\n\t\t: { audit: rawAudit, skipped: false }\n\tconst audit = scanned.audit\n\tlet drifted = !audit.clean\n\n\tlet live:\n\t\t| { readonly current: number; readonly behind: number; readonly failed: number }\n\t\t| undefined\n\tif (values.live) {\n\t\tconst sync = createSync()\n\t\ttry {\n\t\t\tconst guides = await sync.guides(deps)\n\t\t\tconst versions = await sync.versions(deps)\n\t\t\tconst entries = [...guides, ...versions]\n\t\t\tdrifted ||= entries.some((entry) => entry.freshness !== 'current')\n\t\t\tconst current = entries.filter((entry) => entry.freshness === 'current').length\n\t\t\tconst behind = entries.filter((entry) => entry.freshness === 'behind').length\n\t\t\tconst failed = entries.length - current - behind\n\t\t\tlive = { current, behind, failed }\n\t\t} finally {\n\t\t\tsync.destroy()\n\t\t}\n\t}\n\n\tif (json) {\n\t\twriteJson(live === undefined ? auditJson(audit) : { ...auditJson(audit), live })\n\t\tprocess.exitCode = drifted ? 1 : 0\n\t\treturn\n\t}\n\n\tif (scanned.skipped) reporter.line(scanSkipped())\n\treporter.line(comparisonLine(hydrated.aware))\n\treporter.table(auditTable(audit, plan))\n\treporter.line(auditVerdict(audit, plan))\n\tif (live !== undefined) reporter.line(auditLiveNote(live.current, live.behind, live.failed))\n\n\tif (!audit.clean) {\n\t\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\t\tconst isOwned = (path: string): boolean =>\n\t\t\torigins.get(path) === 'host' || origins.get(path) === 'template'\n\t\tconst ownedCount = audit.findings.filter(\n\t\t\t(finding) =>\n\t\t\t\tfinding.drift !== 'aligned' && finding.drift !== 'foreign' && isOwned(finding.path),\n\t\t).length\n\t\tconst computedCount = audit.findings.filter(\n\t\t\t(finding) =>\n\t\t\t\tfinding.drift !== 'aligned' && finding.drift !== 'foreign' && !isOwned(finding.path),\n\t\t).length\n\t\tconst pruneRequested = values.prune\n\n\t\t// F1 (audit never writes via flags): the handoff is an INTERACTIVE\n\t\t// convenience only, offered exclusively on a TTY session — `--apply` /\n\t\t// `--yes` NEVER count as handoff consent here (they gate the SEPARATE\n\t\t// `repair` run this branch may launch, never audit's own read-only\n\t\t// pass). F2 (foreign-only handoff dead-end): the handoff also covers\n\t\t// foreign files, but ONLY when `--prune` was passed — an inherited\n\t\t// repair without `--prune` cannot delete them, so offering the handoff\n\t\t// for foreign-only drift without `--prune` would be a dead end.\n\t\tconst offerHandoff = sinkIsTTY && (ownedCount > 0 || (audit.foreign > 0 && pruneRequested))\n\n\t\tlet handoffAccepted = false\n\t\tif (offerHandoff) {\n\t\t\tconst terminal = createTerminal()\n\t\t\tconst message = repairHandoff(ownedCount, audit.foreign, pruneRequested)\n\t\t\thandoffAccepted = await guarded(terminal.confirm({ message, default: false }))\n\t\t\tif (handoffAccepted) {\n\t\t\t\tawait runRepair(values, false)\n\t\t\t\t// S3c (handoff exit truth): repair's own exit code reflects only\n\t\t\t\t// ITS scope — re-diff the FULL plan (host/template/computed AND\n\t\t\t\t// the foreign scan) so the audit's exit code stays truthful about\n\t\t\t\t// ANY drift still remaining, mirroring `runFleet`'s post-repair\n\t\t\t\t// `finalAudit` pattern.\n\t\t\t\tconst rawFinal = diffPlan(plan, readTarget(target, artifactPaths))\n\t\t\t\tconst finalScanned = hydrated.aware\n\t\t\t\t\t? withForeignScanSafe(rawFinal, target, host)\n\t\t\t\t\t: { audit: rawFinal, skipped: false }\n\t\t\t\tprocess.exitCode = finalScanned.audit.clean ? 0 : 1\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (!handoffAccepted) {\n\t\t\t// F2: when the handoff cannot help foreign files (no `--prune`, or no\n\t\t\t// handoff offered at all), point at the one command that can.\n\t\t\tif (audit.foreign > 0 && !pruneRequested) reporter.line(foreignHint())\n\t\t\t// computed-origin drift is regenerated, never hand-edited — `repair`\n\t\t\t// has nothing to offer for it; `generatedNote` says so instead.\n\t\t\tif (computedCount > 0) reporter.line(generatedNote(computedCount))\n\t\t}\n\t}\n\n\tprocess.exitCode = drifted ? 1 : 0\n}\n\n/** `scaffold repair` — restore the shared template-owned set for ONE target. */\nasync function runRepair(values: Values, json: boolean): Promise<void> {\n\tconst target = containOrFail(values.target ?? '.', json)\n\n\tlet spec: Blueprint\n\ttry {\n\t\tspec = deriveBlueprint(target)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\n\tconst compiled = compileOrFail(spec, json)\n\n\t// H2: repair is the host-restoration tool ONLY — scope to host-origin\n\t// artifacts before hydrate/diff/apply so a mature repo's hand-written\n\t// src/tests/guides/package.json is never overwritten with a stub.\n\t// `.github/workflows/ci.yml` STAYS in scope here (unlike `fleet`'s\n\t// exclusion) — single-target `repair --apply` is explicit per-repo intent.\n\tconst scoped: Plan = {\n\t\t...compiled,\n\t\tartifacts: compiled.artifacts.filter((artifact) => artifact.origin === 'host'),\n\t}\n\n\tconst from = values.from?.[0]\n\tconst host = from ?? hostRoot()\n\tlet plan: Plan\n\ttry {\n\t\tplan = hydrateBestEffort(scoped, host, from !== undefined).plan\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\n\tlet audit: Audit\n\ttry {\n\t\taudit = diffPlan(\n\t\t\tplan,\n\t\t\treadTarget(\n\t\t\t\ttarget,\n\t\t\t\tplan.artifacts.map((artifact) => artifact.path),\n\t\t\t),\n\t\t)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\n\tif (!json) {\n\t\treporter.line(REPAIR_SCOPE)\n\t\treporter.section('Audit')\n\t\treporter.table(auditTable(audit, plan))\n\t}\n\n\t// S3a: the prune preview/confirm are driven by the REAL scan\n\t// (`pruneTargets`), never `audit.foreign` (which `diffPlan` can never\n\t// populate through this call path — it only ever reads the plan's own\n\t// paths). A zero-length scan skips the question entirely and is a no-op.\n\t// U11 F2: computed BEFORE the clean-audit check so `--prune` still reaches\n\t// this scan (and the deletion flow below) on a clean-host repo — a clean\n\t// audit alone no longer bypasses pruning, only a clean audit WITH nothing\n\t// to prune does.\n\tconst prunePaths = values.prune && existsSync(host) ? pruneTargets(target, host) : []\n\n\tif (audit.clean && prunePaths.length === 0) {\n\t\tif (json) {\n\t\t\twriteJson(repairJson(audit))\n\t\t} else {\n\t\t\treporter.line(repairVerdict(audit))\n\t\t\tconst note = scopeNote(repairOutsideCount(compiled, target))\n\t\t\tif (note !== undefined) reporter.line(note)\n\t\t}\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tif (!json) reporter.line(repairVerdict(audit))\n\n\tconst terminal = createTerminal()\n\tlet proceed = true\n\tif (!audit.clean) {\n\t\tproceed = await resolveApply(\n\t\t\tterminal,\n\t\t\tapplyConfirmMessage(audit.drifted + audit.missing + audit.foreign),\n\t\t\tvalues,\n\t\t\tjson,\n\t\t)\n\t}\n\n\tif (!proceed) {\n\t\tif (json) writeJson(repairJson(audit))\n\t\tprocess.exitCode = 1\n\t\treturn\n\t}\n\n\tif (values.prune && !json) {\n\t\tif (prunePaths.length === 0) reporter.line(PRUNE_EMPTY)\n\t\telse for (const line of prunePreview(prunePaths)) reporter.line(line)\n\t}\n\tconst doPrune =\n\t\tprunePaths.length > 0 &&\n\t\t(await resolvePrune(terminal, pruneConfirmMessage(prunePaths.length), values, json))\n\n\tconst spinner = createSpinnerMaybe('repairing', json)\n\tspinner?.start()\n\tconst materializer = createMaterializer({ host: values.from?.[0] })\n\ttry {\n\t\tconst result = materializer.repair(plan, audit, target)\n\t\tconst removed = doPrune ? materializer.prune(target).removed : []\n\t\tif (json) writeJson(repairJson(audit, { ...result, removed }))\n\t\telse announceApply(spinner, json, repairSuccess(result, removed))\n\t} catch (error) {\n\t\tannounceFailure(spinner, json, error)\n\t} finally {\n\t\tmaterializer.destroy()\n\t}\n\tprocess.exitCode = 0\n}\n\n/** `scaffold fleet` — audit/repair every `@orkestrel` package beneath the current directory's immediate children. */\nasync function runFleet(values: Values, json: boolean): Promise<void> {\n\tconst root = containOrFail('.', json)\n\n\tconst packages = discoverPackages(root)\n\tif (packages.length === 0) {\n\t\tfail(\n\t\t\t`no @orkestrel packages under \"${root}\" — fleet scans the immediate children of the current directory; stand in the folder that contains your checkouts (cd ..), or use 'repair' to true up just this repo.`,\n\t\t\tjson,\n\t\t)\n\t}\n\n\tconst from = values.from?.[0]\n\tconst host = from ?? hostRoot()\n\tconst explicit = from !== undefined\n\n\tconst repos: {\n\t\treadonly name: string\n\t\treadonly directory: string\n\t\treadonly plan: Plan\n\t\treadonly audit: Audit\n\t\treadonly aware: boolean\n\t}[] = []\n\tconst failures: { readonly name: string; readonly message: string }[] = []\n\tlet ciExcluded = false\n\n\tfor (const directory of packages) {\n\t\tconst name = basename(directory)\n\t\ttry {\n\t\t\tconst compiler = createCompiler()\n\t\t\tlet scoped: Plan\n\t\t\ttry {\n\t\t\t\tconst spec = deriveBlueprint(directory)\n\t\t\t\tconst scaffolding = compiler.compile(spec)\n\t\t\t\tif (!scaffolding.plan) {\n\t\t\t\t\tconst message = scaffolding.questions.map((question) => question.text).join('; ')\n\t\t\t\t\tthrow new ScaffoldError('INVALID', message)\n\t\t\t\t}\n\t\t\t\t// Fleet apply must never clobber a repo's intentionally divergent\n\t\t\t\t// CI (e.g. ollama, sea) — `.github/workflows/ci.yml` is scoped out\n\t\t\t\t// of `fleet`; single-target `repair` keeps full scope.\n\t\t\t\tscoped = {\n\t\t\t\t\t...scaffolding.plan,\n\t\t\t\t\tartifacts: scaffolding.plan.artifacts.filter(\n\t\t\t\t\t\t(artifact) =>\n\t\t\t\t\t\t\tartifact.origin === 'host' && artifact.path !== '.github/workflows/ci.yml',\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!ciExcluded &&\n\t\t\t\t\tscaffolding.plan.artifacts.some(\n\t\t\t\t\t\t(artifact) => artifact.path === '.github/workflows/ci.yml',\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tif (!json) reporter.line(fleetCiSkipped())\n\t\t\t\t\tciExcluded = true\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tcompiler.destroy()\n\t\t\t}\n\n\t\t\tconst hydrated = hydrateBestEffort(scoped, host, explicit)\n\t\t\tconst plan = hydrated.plan\n\t\t\tconst paths = plan.artifacts.map((artifact) => artifact.path)\n\t\t\tconst rawAudit = diffPlan(plan, readTarget(directory, paths))\n\t\t\t// S3b (honest audit): merge each repo's `pruneTargets` scan in, same\n\t\t\t// as `runAudit` — an unexpected file is real drift here too.\n\t\t\tconst audit = hydrated.aware ? withForeignScan(rawAudit, directory, host) : rawAudit\n\t\t\trepos.push({ name, directory, plan, audit, aware: hydrated.aware })\n\t\t} catch (error) {\n\t\t\tfailures.push({ name, message: describe(error) })\n\t\t}\n\t}\n\n\tif (!json) {\n\t\tfor (const repo of repos) {\n\t\t\treporter.line(\n\t\t\t\tfleetRepoLine(\n\t\t\t\t\trepo.name,\n\t\t\t\t\trepo.audit.clean\n\t\t\t\t\t\t? { kind: 'clean' }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tkind: 'drifted',\n\t\t\t\t\t\t\t\tdrifted: repo.audit.drifted,\n\t\t\t\t\t\t\t\tmissing: repo.audit.missing,\n\t\t\t\t\t\t\t\tforeign: repo.audit.foreign,\n\t\t\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tfor (const failure of failures) {\n\t\t\treporter.line(fleetRepoLine(failure.name, { kind: 'failed', message: failure.message }))\n\t\t}\n\t}\n\n\tconst dirty = repos.filter((repo) => !repo.audit.clean)\n\n\tif (dirty.length === 0) {\n\t\tif (json) {\n\t\t\twriteJson(\n\t\t\t\tfleetJson([\n\t\t\t\t\t...repos.map((repo) => fleetEntry(repo.name, repo.audit, false)),\n\t\t\t\t\t...failures.map((failure) => fleetEntry(failure.name, undefined, true)),\n\t\t\t\t]),\n\t\t\t)\n\t\t} else {\n\t\t\treporter.line(fleetTotals(0, failures.length))\n\t\t}\n\t\tprocess.exitCode = failures.length > 0 ? 1 : 0\n\t\treturn\n\t}\n\n\tconst fileCount = dirty.reduce(\n\t\t(total, repo) => total + repo.audit.drifted + repo.audit.missing + repo.audit.foreign,\n\t\t0,\n\t)\n\n\tconst terminal = createTerminal()\n\tconst proceed = await resolveApply(\n\t\tterminal,\n\t\tapplyConfirmMessage(fileCount, dirty.length),\n\t\tvalues,\n\t\tjson,\n\t)\n\n\t// S3a: fleet's prune preview/confirm are driven by the REAL per-repo scan\n\t// (`pruneTargets`), never `audit.foreign` — each unexpected path is shown\n\t// `<repo>/<path>`-prefixed so the fleet-wide preview stays legible. Scanned\n\t// only when `host` itself is establishable (`existsSync`) — same\n\t// precondition `hydrateBestEffort` already gates awareness on; an\n\t// unestablished host degrades to a no-op prune, never a thrown scan.\n\tconst prunePaths =\n\t\tproceed && values.prune && existsSync(host)\n\t\t\t? dirty.flatMap((repo) =>\n\t\t\t\t\tpruneTargets(repo.directory, host).map((path) => `${repo.name}/${path}`),\n\t\t\t\t)\n\t\t\t: []\n\tif (proceed && values.prune && !json) {\n\t\tif (prunePaths.length === 0) reporter.line(PRUNE_EMPTY)\n\t\telse for (const line of prunePreview(prunePaths)) reporter.line(line)\n\t}\n\tconst doPrune =\n\t\tproceed &&\n\t\tprunePaths.length > 0 &&\n\t\t(await resolvePrune(terminal, pruneConfirmMessage(prunePaths.length), values, json))\n\n\tif (!proceed) {\n\t\tif (json) {\n\t\t\twriteJson(\n\t\t\t\tfleetJson([\n\t\t\t\t\t...repos.map((repo) => fleetEntry(repo.name, repo.audit, false)),\n\t\t\t\t\t...failures.map((failure) => fleetEntry(failure.name, undefined, true)),\n\t\t\t\t]),\n\t\t\t)\n\t\t} else {\n\t\t\treporter.line(fleetTotals(dirty.length, failures.length))\n\t\t}\n\t\tprocess.exitCode = 1\n\t\treturn\n\t}\n\n\tconst materializer = createMaterializer({ host })\n\tlet drifted = 0\n\tlet failedCount = failures.length\n\tconst entries: ReturnType<typeof fleetEntry>[] = repos\n\t\t.filter((repo) => repo.audit.clean)\n\t\t.map((repo) => fleetEntry(repo.name, repo.audit, false))\n\n\ttry {\n\t\tfor (const repo of dirty) {\n\t\t\ttry {\n\t\t\t\tmaterializer.repair(repo.plan, repo.audit, repo.directory)\n\t\t\t\tif (doPrune) materializer.prune(repo.directory)\n\t\t\t\tconst paths = repo.plan.artifacts.map((artifact) => artifact.path)\n\t\t\t\tconst rawFinal = diffPlan(repo.plan, readTarget(repo.directory, paths))\n\t\t\t\tconst finalAudit = repo.aware ? withForeignScan(rawFinal, repo.directory, host) : rawFinal\n\t\t\t\tif (!finalAudit.clean) drifted += 1\n\t\t\t\tentries.push(fleetEntry(repo.name, finalAudit, false))\n\t\t\t\tif (!json) {\n\t\t\t\t\treporter.line(\n\t\t\t\t\t\tfleetRepoLine(repo.name, {\n\t\t\t\t\t\t\tkind: 'repaired',\n\t\t\t\t\t\t\tremaining: finalAudit.drifted + finalAudit.missing + finalAudit.foreign,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tfailedCount += 1\n\t\t\t\tentries.push(fleetEntry(repo.name, undefined, true))\n\t\t\t\tif (!json) {\n\t\t\t\t\treporter.line(fleetRepoLine(repo.name, { kind: 'failed', message: describe(error) }))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tmaterializer.destroy()\n\t}\n\n\tif (json) {\n\t\twriteJson(\n\t\t\tfleetJson([\n\t\t\t\t...entries,\n\t\t\t\t...failures.map((failure) => fleetEntry(failure.name, undefined, true)),\n\t\t\t]),\n\t\t)\n\t} else {\n\t\treporter.line(fleetTotals(drifted, failedCount))\n\t}\n\tprocess.exitCode = drifted > 0 || failedCount > 0 ? 1 : 0\n}\n\n/** `scaffold catalog` — regenerate the fleet package catalog table embedded in `.claude/agents/orkestrel.md`. */\nasync function runCatalog(values: Values, json: boolean): Promise<void> {\n\tconst target = containOrFail(values.target ?? '.', json)\n\n\tconst explicitRoots = values.from\n\tlet entries: readonly CatalogEntry[]\n\tlet published = 0\n\tlet localOnly = 0\n\tconst notes = new Map<string, string>()\n\n\tif (values.offline) {\n\t\tconst roots = explicitRoots ?? [process.cwd()]\n\t\ttry {\n\t\t\tentries = catalogPackages(roots)\n\t\t} catch (error) {\n\t\t\tfailError(error, json)\n\t\t}\n\t} else {\n\t\tconst sync = createSync({\n\t\t\ton: {\n\t\t\t\tpackage: (name, note) => {\n\t\t\t\t\tif (note !== '') notes.set(name, note)\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tlet registryEntries: readonly CatalogEntry[]\n\t\ttry {\n\t\t\tregistryEntries = await sync.catalog()\n\t\t} catch (error) {\n\t\t\tfailError(error, json)\n\t\t} finally {\n\t\t\tsync.destroy()\n\t\t}\n\t\tpublished = registryEntries.length\n\n\t\tlet localEntries: readonly CatalogEntry[] = []\n\t\tif (explicitRoots !== undefined) {\n\t\t\ttry {\n\t\t\t\tlocalEntries = catalogPackages(explicitRoots)\n\t\t\t} catch (error) {\n\t\t\t\tfailError(error, json)\n\t\t\t}\n\t\t}\n\n\t\tconst merged = new Map<string, CatalogEntry>()\n\t\tfor (const entry of registryEntries) merged.set(entry.name, entry)\n\t\tfor (const local of localEntries) {\n\t\t\tconst existing = merged.get(local.name)\n\t\t\tif (existing === undefined) {\n\t\t\t\tmerged.set(local.name, local)\n\t\t\t\tlocalOnly += 1\n\t\t\t} else if (local.description.length > 0) {\n\t\t\t\tmerged.set(local.name, { ...existing, description: local.description })\n\t\t\t}\n\t\t}\n\t\tentries = [...merged.values()].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))\n\t}\n\n\tconst block = catalogToBlock(entries)\n\t// S3g: the LEAF write path is re-confined (same mechanism as every other\n\t// verb's destination) — `target` itself passed containment, but a\n\t// symlinked segment nested BENEATH it (e.g. a symlinked `.claude`) could\n\t// still let this specific path escape the cwd.\n\tconst agentPath = containOrFail(join(target, '.claude', 'agents', 'orkestrel.md'), json)\n\tlet current: string\n\ttry {\n\t\tcurrent = readFileSync(agentPath, 'utf8')\n\t} catch (error) {\n\t\tfailError(\n\t\t\tnew ScaffoldError('TARGET', `Failed to read ${agentPath}`, { path: agentPath, error }),\n\t\t\tjson,\n\t\t)\n\t}\n\n\tconst startMarker = '<!-- catalog:start -->'\n\tconst endMarker = '<!-- catalog:end -->'\n\tconst startIndex = current.indexOf(startMarker)\n\tconst endIndex = current.indexOf(endMarker)\n\tif (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {\n\t\tfailError(\n\t\t\tnew ScaffoldError(\n\t\t\t\t'TARGET',\n\t\t\t\t`Markers \"${startMarker}\" / \"${endMarker}\" not found in ${agentPath}`,\n\t\t\t\t{ path: agentPath },\n\t\t\t),\n\t\t\tjson,\n\t\t)\n\t}\n\n\tconst before = current.slice(0, startIndex + startMarker.length)\n\tconst after = current.slice(endIndex)\n\tconst updated = `${before}\\n\\n${block}\\n${after}`\n\n\tconst oldBlock = current.slice(startIndex + startMarker.length, endIndex)\n\tconst oldRows = catalogNames(oldBlock).length\n\tconst shrink = entries.length < oldRows ? oldRows - entries.length : undefined\n\n\tif (updated === current) {\n\t\tif (json) writeJson(catalogJson(entries, false))\n\t\telse reporter.line(catalogVerdict(true))\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tif (!json) {\n\t\treporter.table(catalogTable(entries))\n\t\tconst warning = catalogShrinkWarning(oldRows, entries.length)\n\t\tif (warning !== undefined) reporter.line(warning)\n\t\tif (values.offline) {\n\t\t\tconst missingDescription = entries\n\t\t\t\t.filter((entry) => entry.description.length === 0)\n\t\t\t\t.map((entry) => entry.name)\n\t\t\tif (missingDescription.length > 0) {\n\t\t\t\treporter.line(\n\t\t\t\t\t`${missingDescription.length} without guide description: ${missingDescription.join(', ')}`,\n\t\t\t\t)\n\t\t\t}\n\t\t} else {\n\t\t\treporter.line(catalogCounts(published, localOnly))\n\t\t\tfor (const [name, note] of notes) reporter.line(` ${name}: ${note}`)\n\t\t}\n\t}\n\n\tconst terminal = createTerminal()\n\tconst proceed = await resolveApply(terminal, applyConfirmMessage(1), values, json)\n\n\tif (!proceed) {\n\t\tif (json) writeJson(catalogJson(entries, true, shrink))\n\t\telse reporter.line(catalogVerdict(false))\n\t\tprocess.exitCode = 1\n\t\treturn\n\t}\n\n\ttry {\n\t\twriteFileSync(agentPath, updated, 'utf8')\n\t} catch (error) {\n\t\tfailError(\n\t\t\tnew ScaffoldError('TARGET', `Failed to write ${agentPath}`, { path: agentPath, error }),\n\t\t\tjson,\n\t\t)\n\t}\n\tif (json) writeJson(catalogJson(entries, true, shrink))\n\telse reporter.status('success', catalogApplySuccess(agentPath))\n\tprocess.exitCode = 0\n}\n\n/**\n * The whole command dispatch — a single top-level driver (no nested function\n * declarations, AGENTS §4). Every verb sets `process.exitCode` (never\n * `process.exit`, H4) and returns, or `halt()`s through a `finally` that\n * tears its entities down first; the caller at the bottom of this file\n * catches exactly one sentinel (`CliExit`) and stops.\n */\nasync function main(): Promise<void> {\n\tlet parsed: ReturnType<typeof parseArguments>\n\ttry {\n\t\tparsed = parseArguments()\n\t} catch (error) {\n\t\tprocess.stderr.write(`${error instanceof Error ? error.message : INVALID_ARGUMENTS_MESSAGE}\\n`)\n\t\tprocess.exitCode = 2\n\t\treturn\n\t}\n\n\tconst { values, positionals } = parsed\n\tconst [command, argument] = positionals\n\tconst json = values.json === true\n\tsessionJson = json\n\n\tif (command === undefined) {\n\t\tprocess.stdout.write(`${values.help ? fullHelp() : shortUsage()}\\n`)\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tif (!isVerb(command)) {\n\t\tusageFail(didYouMean(command), json)\n\t}\n\n\tif (values.help) {\n\t\tprocess.stdout.write(`${verbHelp(command)}\\n`)\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tif (command === 'new') return runNew(values, argument, json)\n\tif (command === 'pull') return runPull(values, json)\n\tif (command === 'audit') return runAudit(values, json)\n\tif (command === 'repair') return runRepair(values, json)\n\tif (command === 'fleet') return runFleet(values, json)\n\treturn runCatalog(values, json)\n}\n\ntrustSystemCertificates()\n\ntry {\n\tawait main()\n} catch (error) {\n\tif (error instanceof CliExit) {\n\t\tprocess.exitCode = error.code\n\t} else if (sessionJson) {\n\t\tconst code = isScaffoldError(error) ? error.code : 'ERROR'\n\t\tconst message = isScaffoldError(error) ? error.message : describe(error)\n\t\twriteJson(errorEnvelope(code, message))\n\t\tprocess.exitCode = 1\n\t} else {\n\t\treporter.status('error', describe(error))\n\t\tprocess.exitCode = 1\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,IAAa,cAAc,OAAO,OAAO;CACxC;CACA;CACA;CACA;CACA;CACA;AACD,CAAU;;AAMV,IAAa,eAAiD,OAAO,OAAO;CAC3E,MAAM;CACN,UAAU;CACV,UAAU;AACX,CAAC;;AAGD,IAAa,cAA+C,OAAO,OAAO;CACzE,SAAS;CACT,OAAO;CACP,SAAS;CACT,SAAS;AACV,CAAC;;AAGD,IAAa,kBAAoD,OAAO,OAAO;CAC9E,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;AACT,CAAC;;AAGD,IAAa,eAAiD,OAAO,OAAO;CAC3E,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;AACV,CAAC;;AAGD,SAAgB,UAAU,OAAe,OAAuB;CAC/D,OAAO,GAAG,MAAM,GAAG,QAAQ,UAAU,IAAI,KAAK;AAC/C;;AAGA,SAAgB,WAAW,QAIhB;CACV,MAAM,QAAkB,CAAC;CACzB,IAAI,OAAO,UAAU,GAAG,MAAM,KAAK,UAAU,OAAO,SAAS,SAAS,CAAC;CACvE,IAAI,OAAO,UAAU,GAAG,MAAM,KAAK,UAAU,OAAO,SAAS,SAAS,CAAC;CACvE,IAAI,OAAO,UAAU,GAAG,MAAM,KAAK,UAAU,OAAO,SAAS,YAAY,CAAC;CAC1E,OAAO,MAAM,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI;AAC9C;;;;;;AAOA,SAAgB,gBACf,UACA,MAQC;CACD,MAAM,UAAU,IAAI,IAAI,KAAK,UAAU,KAAK,aA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AAE,QAAQ,gBAAgB;CAChC,MAAM,CAAC,SAAS,YAAY;CAC5B,MAAM,OAAO,OAAO,SAAS;CAC7B,cAAc;CAEd,IAAI,YAAY,KAAA,GAAW;EAC1B,QAAQ,OAAO,MAAM,GAAG,OAAO,OAAO,SAAS,IAAI,WAAW,EAAE,GAAG;EACnE,QAAQ,WAAW;EACnB;CACD;CAEA,IAAI,CAAC,OAAO,OAAO,GAClB,UAAU,WAAW,OAAO,GAAG,IAAI;CAGpC,IAAI,OAAO,MAAM;EAChB,QAAQ,OAAO,MAAM,GAAG,SAAS,OAAO,EAAE,GAAG;EAC7C,QAAQ,WAAW;EACnB;CACD;CAEA,IAAI,YAAY,OAAO,OAAO,OAAO,QAAQ,UAAU,IAAI;CAC3D,IAAI,YAAY,QAAQ,OAAO,QAAQ,QAAQ,IAAI;CACnD,IAAI,YAAY,SAAS,OAAO,SAAS,QAAQ,IAAI;CACrD,IAAI,YAAY,UAAU,OAAO,UAAU,QAAQ,IAAI;CACvD,IAAI,YAAY,SAAS,OAAO,SAAS,QAAQ,IAAI;CACrD,OAAO,WAAW,QAAQ,IAAI;AAC/B;AAEA,wBAAwB;AAExB,IAAI;CACH,MAAM,KAAK;AACZ,SAAS,OAAO;CACf,IAAI,iBAAiB,SACpB,QAAQ,WAAW,MAAM;MACnB,IAAI,aAAa;EAGvB,UAAU,cAFG,gBAAgB,KAAK,IAAI,MAAM,OAAO,SACnC,gBAAgB,KAAK,IAAI,MAAM,UAAU,SAAS,KAAK,CAClC,CAAC;EACtC,QAAQ,WAAW;CACpB,OAAO;EACN,SAAS,OAAO,SAAS,SAAS,KAAK,CAAC;EACxC,QAAQ,WAAW;CACpB;AACD"}
|
|
1
|
+
{"version":3,"file":"scaffold.js","names":["#tty","#sink","#styler","#trust","#dispatch","#json","#write","#reporter","#error","#fail","#scan","#guard","#apply","#prune","#prompt","#new","#usage","#contain","#names","#compile","#spinner","#succeed","#reject","#pull","#audit","#scanSafe","#repair","#outside","#fleet","#catalog"],"sources":["../../src/bin/constants.ts","../../src/bin/errors.ts","../../src/bin/shapers.ts","../../src/bin/helpers.ts","../../src/bin/parsers.ts","../../src/bin/validators.ts","../../src/bin/CLI.ts","../../src/bin/scaffold.ts"],"sourcesContent":["import type { Drift, Origin } from '@src/core'\nimport type { CheckboxChoice } from '@orkestrel/terminal'\nimport type { Verb } from './types.js'\n\n/** The command-line interface's closed command vocabulary. */\nexport const KNOWN_VERBS: readonly Verb[] = Object.freeze([\n\t'new',\n\t'pull',\n\t'audit',\n\t'repair',\n\t'fleet',\n\t'catalog',\n])\n\n/** Internal artifact origins translated into user-facing labels. */\nexport const ORIGIN_LABEL: Readonly<Record<Origin, string>> = Object.freeze({\n\thost: 'host-owned',\n\ttemplate: 'starter',\n\tcomputed: 'generated',\n})\n\n/** Internal drift states translated into user-facing labels. */\nexport const DRIFT_LABEL: Readonly<Record<Drift, string>> = Object.freeze({\n\taligned: 'unchanged',\n\tstale: 'drifted',\n\tmissing: 'missing',\n\tforeign: 'unexpected file',\n})\n\n/** Dependency freshness states translated into user-facing labels. */\nexport const FRESHNESS_LABEL: Readonly<Record<string, string>> = Object.freeze({\n\tcurrent: 'unchanged',\n\tbehind: 'behind',\n\tmissing: 'missing upstream',\n\tfailed: 'fetch failed',\n})\n\n/** Materializer actions translated into user-facing labels. */\nexport const ACTION_LABEL: Readonly<Record<string, string>> = Object.freeze({\n\twritten: 'wrote',\n\tcopied: 'wrote',\n\tskipped: 'unchanged',\n\tremoved: 'removed',\n})\n\n/** Repair's deliberately limited ownership boundary. */\nexport const REPAIR_SCOPE =\n\t'repair scope: shared host-owned artifacts only — starter and generated files are never touched'\n\n/** The dry-run note for `new`. */\nexport const NEW_DRY_RUN_NOTE = 'dry run — pass --apply to write'\n\n/** The fallback message for a malformed command line without an error message. */\nexport const INVALID_ARGUMENTS_MESSAGE = 'invalid arguments'\n\n/** Shared prompt-cancellation message. */\nexport const CANCELLED_MESSAGE = 'cancelled — nothing written'\n\n/** Terminal choices for a new workspace's src and app environments. */\nexport const ENVIRONMENT_CHOICES: readonly CheckboxChoice[] = Object.freeze([\n\t{ name: 'core', value: 'core', description: 'the pure engine' },\n\t{ name: 'browser', value: 'browser', description: 'DOM-facing environment' },\n\t{ name: 'server', value: 'server', description: 'node-facing environment' },\n])\n\n/** The safety model included in full help. */\nexport const SAFETY_BANNER = [\n\t'safety: every verb is a dry run by default.',\n\t'on a terminal, a write prompts for confirmation; in a script, pass --apply (and --yes to skip the confirm).',\n\t'every write is confined to the current working directory — cd there first.',\n\t'when Node exposes system-CA controls, TLS adds the OS certificate store; earlier supported Node 22 releases use default roots. NODE_EXTRA_CA_CERTS adds custom PEMs.',\n].join('\\n')\n\n/** Stable command exit-code meanings. */\nexport const EXIT_CODES: readonly (readonly [string, string])[] = Object.freeze([\n\t['0', 'clean / success'],\n\t['1', 'drift or failure'],\n\t['2', 'usage error'],\n])\n\n/** One-line command summaries. */\nexport const VERB_SUMMARY: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'scaffold a workspace into ./<name>',\n\tpull: 'refresh vendored guides/versions, report drift',\n\taudit: 'whole-plan conformance report',\n\trepair: 'restore the shared host-owned set',\n\tfleet: \"audit/repair every workspace under the cwd's immediate children\",\n\tcatalog: 'regenerate the fleet package-catalog table',\n})\n\n/** Compact command flag references. */\nexport const VERB_FLAGS: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: '--src a,b --app a,b --deps x,y --apply --yes --target <path> --from <path>',\n\tpull: '--target . --deps x,y --apply --yes --strict',\n\taudit: '--target . --live --from <path> --groups a,b',\n\trepair: '--target . --apply --yes --prune --from <path>',\n\tfleet: '--apply --yes --prune --from <path>',\n\tcatalog: '--from <path> ... --target <repo> --offline --apply --yes',\n})\n\n/** Plain-language command flag descriptions. */\nexport const VERB_FLAG_HELP: Readonly<Record<Verb, readonly (readonly [string, string])[]>> =\n\tObject.freeze({\n\t\tnew: [\n\t\t\t['--src a,b', 'which src environments to include (core, browser, server)'],\n\t\t\t['--app a,b', 'which app environments to include (core, browser, server)'],\n\t\t\t['--deps x,y', '@orkestrel/* dependencies to add (installed as dependencies)'],\n\t\t\t['--apply', 'write the files (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--target <path>', 'destination directory (default: ./<name>)'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t],\n\t\tpull: [\n\t\t\t['--target .', 'directory to refresh (default: current directory)'],\n\t\t\t['--deps x,y', 'limit the refresh to these dependencies'],\n\t\t\t['--apply', 'write the refreshed files (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--strict', 'fail (exit 1) on any drift, even non-fatal'],\n\t\t],\n\t\taudit: [\n\t\t\t['--target .', 'directory to audit (default: current directory)'],\n\t\t\t['--live', 'also check upstream freshness over the network'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t\t['--groups a,b', 'limit the audit to these artifact groups'],\n\t\t],\n\t\trepair: [\n\t\t\t['--target .', 'directory to repair (default: current directory)'],\n\t\t\t['--apply', 'write the fixes (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--prune', 'also DELETE unexpected files under .claude/agents, .codex/agents, and scripts'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t],\n\t\tfleet: [\n\t\t\t['--apply', 'write fixes across every package (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t[\n\t\t\t\t'--prune',\n\t\t\t\t'also DELETE unexpected files under .claude/agents, .codex/agents, and scripts, per package',\n\t\t\t],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t],\n\t\tcatalog: [\n\t\t\t['--from <path> ...', 'one or more local package paths to include'],\n\t\t\t['--target <repo>', 'the repository whose Orkestrel agent catalog table gets updated'],\n\t\t\t['--offline', 'skip network lookups (npm registry) for package descriptions'],\n\t\t\t['--apply', 'write the updated table (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t],\n\t})\n\n/** Dry-run and confirmation notes per command. */\nexport const VERB_DRY_RUN_NOTE: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'dry run by default — add --apply to write the files, --yes to skip the question',\n\tpull: 'dry run by default — add --apply to write the refreshed files, --yes to skip the question',\n\taudit: 'read-only — audit never writes; pass --live to also check upstream freshness',\n\trepair: 'dry run by default — add --apply to write, --yes to skip the question',\n\tfleet:\n\t\t'dry run by default — add --apply to write across every package, --yes to skip the question',\n\tcatalog: 'dry run by default — add --apply to write, --yes to skip the question',\n})\n\n/** One concrete invocation per command. */\nexport const VERB_EXAMPLE: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'example: scaffold new widget --src core,server --app core,browser --apply',\n\tpull: 'example: scaffold pull --apply',\n\taudit: 'example: scaffold audit --live',\n\trepair: 'example: scaffold repair --apply',\n\tfleet: 'example: scaffold fleet --apply --yes',\n\tcatalog: 'example: scaffold catalog --apply',\n})\n\n/** Message used when a prune scan has no candidates. */\nexport const PRUNE_EMPTY = 'no unexpected files to delete'\n\n/** Guidance for unexpected files outside a non-pruning repair handoff. */\nexport const FOREIGN_HINT = \"unexpected files found — run 'scaffold repair --prune' to delete them\"\n\n/** Interactive dependency prompt. */\nexport const ORKESTREL_DEPS_PROMPT =\n\t'@orkestrel dependencies (comma-separated short names, e.g. contract, emitter — installed as dependencies)'\n\n/** Catalog-degraded validation note. */\nexport const CATALOG_UNRESOLVED_NOTE =\n\t\"couldn't resolve the vendored @orkestrel catalog — validating names by shape only\"\n\n/** Catalog block destination in a scaffolded repository. */\nexport const CATALOG_AGENT_PATH = '.claude/agents/orkestrel.md'\n\n/** Opening marker for the generated package catalog block. */\nexport const CATALOG_START_MARKER = '<!-- catalog:start -->'\n\n/** Closing marker for the generated package catalog block. */\nexport const CATALOG_END_MARKER = '<!-- catalog:end -->'\n\n/** Non-terminal prune safety note. */\nexport const PRUNE_SKIPPED =\n\t'prune skipped — not a terminal; add --apply (or --yes) to delete non-interactively'\n\n/** Degraded unexpected-file scan note. */\nexport const SCAN_SKIPPED =\n\t\"unexpected-file scanning skipped — couldn't establish the template source\"\n","/** Internal sentinel that unwinds command dispatch without bypassing cleanup. */\nexport class CLIExitError extends Error {\n\treadonly code: number\n\n\tconstructor(code: number) {\n\t\tsuper(`cli-exit:${String(code)}`)\n\t\tthis.code = code\n\t}\n}\n","import type { Audit, CatalogEntry, Finding, Plan, PlanSummary } from '@src/core'\nimport type { MaterializeResult } from '@src/server'\nimport type {\n\tAuditCounts,\n\tCatalogResult,\n\tErrorEnvelope,\n\tFleetEntry,\n\tNewResult,\n\tOriginPartition,\n\tRepairResult,\n} from './types.js'\n\n/** Partition findings by whether repair owns their artifact origin. */\nexport function partitionFindings(findings: readonly Finding[], plan: Plan): OriginPartition {\n\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\tlet ownedDrifted = 0\n\tlet ownedMissing = 0\n\tlet ownedForeign = 0\n\tlet generatedDrifted = 0\n\tlet generatedMissing = 0\n\tlet generatedForeign = 0\n\tfor (const finding of findings) {\n\t\tconst origin = origins.get(finding.path)\n\t\tconst owned = origin === 'host' || origin === 'template'\n\t\tif (finding.drift === 'aligned') continue\n\t\tif (finding.drift === 'stale') {\n\t\t\tif (owned) ownedDrifted += 1\n\t\t\telse generatedDrifted += 1\n\t\t} else if (finding.drift === 'missing') {\n\t\t\tif (owned) ownedMissing += 1\n\t\t\telse generatedMissing += 1\n\t\t} else if (owned) {\n\t\t\townedForeign += 1\n\t\t} else {\n\t\t\tgeneratedForeign += 1\n\t\t}\n\t}\n\treturn {\n\t\towned: { drifted: ownedDrifted, missing: ownedMissing, foreign: ownedForeign },\n\t\tgenerated: {\n\t\t\tdrifted: generatedDrifted,\n\t\t\tmissing: generatedMissing,\n\t\t\tforeign: generatedForeign,\n\t\t},\n\t}\n}\n\n/** Create one deterministic fleet result entry. */\nexport function fleetEntryOf(\n\tname: string,\n\tcounts: AuditCounts | undefined,\n\tfailed: boolean,\n): FleetEntry {\n\treturn {\n\t\tname,\n\t\tdrifted: counts?.drifted ?? 0,\n\t\tmissing: counts?.missing ?? 0,\n\t\tforeign: counts?.foreign ?? 0,\n\t\tfailed,\n\t}\n}\n\n/** Create the command-line interface's machine-readable failure envelope. */\nexport function errorEnvelopeOf(code: string, message: string): ErrorEnvelope {\n\treturn { error: { code, message } }\n}\n\n/** Project a plan summary to the stable machine-readable `new` result. */\nexport function summaryToNewResult(summary: PlanSummary, applied: boolean): NewResult {\n\treturn {\n\t\tname: summary.name,\n\t\tsrc: summary.src,\n\t\tapp: summary.app,\n\t\thost: summary.host,\n\t\ttemplate: summary.template,\n\t\tcomputed: summary.computed,\n\t\tapplied,\n\t}\n}\n\n/** Add a materialization result to an audit. */\nexport function auditToRepairResult(audit: Audit, result: MaterializeResult): RepairResult {\n\treturn { ...audit, result }\n}\n\n/** Create the stable machine-readable catalog result. */\nexport function catalogResultOf(\n\tentries: readonly CatalogEntry[],\n\tdrift: boolean,\n\tshrink?: number,\n): CatalogResult {\n\treturn shrink === undefined ? { entries, drift } : { entries, drift, shrink }\n}\n","import type { Audit, CatalogEntry, Finding, Plan, PlanSummary, SyncReport } from '@src/core'\nimport { DEPENDENCY_NAME_PATTERN, isScaffoldError, ScaffoldError } from '@src/core'\nimport { isFilesystemPath, resolvePhysicalPath } from '@src/server'\nimport type { MaterializeResult } from '@src/server'\nimport type { TableOptions } from '@orkestrel/console'\nimport { attempt } from '@orkestrel/contract'\nimport {\n\tACTION_LABEL,\n\tDRIFT_LABEL,\n\tEXIT_CODES,\n\tFRESHNESS_LABEL,\n\tKNOWN_VERBS,\n\tORIGIN_LABEL,\n\tSAFETY_BANNER,\n\tVERB_DRY_RUN_NOTE,\n\tVERB_EXAMPLE,\n\tVERB_FLAG_HELP,\n\tVERB_FLAGS,\n\tVERB_SUMMARY,\n} from './constants.js'\nimport { partitionFindings } from './shapers.js'\nimport type { AuditCounts, FleetOutcome, Verb } from './types.js'\n\n/** Render one pluralized count. */\nexport function countPart(count: number, label: string): string {\n\treturn `${count} ${label}${count === 1 ? '' : 's'}`\n}\n\n/** Render nonzero audit buckets or `clean`. */\nexport function bucketText(counts: AuditCounts): string {\n\tconst parts: string[] = []\n\tif (counts.drifted > 0) parts.push(countPart(counts.drifted, 'drifted'))\n\tif (counts.missing > 0) parts.push(countPart(counts.missing, 'missing'))\n\tif (counts.foreign > 0) parts.push(countPart(counts.foreign, 'unexpected'))\n\treturn parts.length > 0 ? parts.join(', ') : 'clean'\n}\n\n/** Render audit's origin-aware verdict. */\nexport function auditVerdict(audit: Audit, plan: Plan): string {\n\tconst count = audit.findings.length\n\tif (audit.clean) return `audit: ${countPart(count, 'artifact')} — clean`\n\tconst split = partitionFindings(audit.findings, plan)\n\tconst owned = split.owned.drifted === 0 && split.owned.missing === 0 && split.owned.foreign === 0\n\treturn owned\n\t\t? `audit: ${countPart(count, 'artifact')} — host-owned clean; ${bucketText(split.generated)} (generated)`\n\t\t: `audit: ${countPart(count, 'artifact')} — host-owned: ${bucketText(split.owned)}; generated: ${bucketText(split.generated)}`\n}\n\n/** Render non-aligned audit findings as terminal table rows. */\nexport function findingRows(\n\tfindings: readonly Finding[],\n\tplan: Plan,\n): readonly (readonly [string, string, string])[] {\n\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\treturn findings\n\t\t.filter((finding) => finding.drift !== 'aligned')\n\t\t.map((finding): readonly [string, string, string] => {\n\t\t\tconst origin = origins.get(finding.path)\n\t\t\tconst category = origin === undefined ? 'unexpected file' : ORIGIN_LABEL[origin]\n\t\t\treturn [DRIFT_LABEL[finding.drift], category, finding.path]\n\t\t})\n}\n\n/** Create audit's terminal table. */\nexport function auditTable(audit: Audit, plan: Plan): TableOptions {\n\treturn {\n\t\tcolumns: [{ label: 'Status' }, { label: 'Kind' }, { label: 'Path' }],\n\t\trows: findingRows(audit.findings, plan),\n\t}\n}\n\n/** Render drift outside repair's ownership boundary. */\nexport function scopeNote(count: number): string | undefined {\n\tif (count === 0) return undefined\n\treturn `note: ${countPart(count, 'finding')} outside repair's scope — run 'audit' for the list; generated files are yours to edit`\n}\n\n/** Render repair's dry-run verdict. */\nexport function repairVerdict(audit: Audit): string {\n\tif (audit.clean) {\n\t\treturn `repair: ${countPart(audit.findings.length, 'host-owned artifact')} aligned — nothing to write`\n\t}\n\treturn `repair: ${bucketText(audit)} — pass --apply to write`\n}\n\n/** Render repair's materialization tally. */\nexport function repairSuccess(result: MaterializeResult, removed: readonly string[]): string {\n\tconst written = result.written.length + result.copied.length\n\treturn `${ACTION_LABEL.written} ${written}, ${ACTION_LABEL.skipped} ${result.skipped.length}, ${ACTION_LABEL.removed} ${removed.length}`\n}\n\n/** Render pull freshness as table rows. */\nexport function pullRows(report: SyncReport): readonly (readonly [string, string, string])[] {\n\tconst guides = report.guides.map((guide): readonly [string, string, string] => [\n\t\tguide.name,\n\t\t'guide',\n\t\tFRESHNESS_LABEL[guide.freshness] ?? guide.freshness,\n\t])\n\tconst versions = report.versions.map((version): readonly [string, string, string] => [\n\t\tversion.name,\n\t\t'version',\n\t\tFRESHNESS_LABEL[version.freshness] ?? version.freshness,\n\t])\n\treturn [...guides, ...versions]\n}\n\n/** Create pull's terminal table. */\nexport function pullTable(report: SyncReport): TableOptions {\n\treturn {\n\t\tcolumns: [{ label: 'Name' }, { label: 'Kind' }, { label: 'Freshness' }],\n\t\trows: pullRows(report),\n\t}\n}\n\n/** Render cause notes from non-current pull entries. */\nexport function pullCauseNotes(report: SyncReport): readonly string[] {\n\treturn [...report.guides, ...report.versions]\n\t\t.filter((entry) => entry.note !== undefined)\n\t\t.map(\n\t\t\t(entry) =>\n\t\t\t\t` ${entry.name}: ${FRESHNESS_LABEL[entry.freshness] ?? entry.freshness} — ${entry.note}`,\n\t\t)\n}\n\n/** Render pull's tally. */\nexport function pullVerdict(report: SyncReport): string {\n\tconst count = report.guides.length + report.versions.length\n\treturn `pull: ${countPart(count, 'entry')} — ${countPart(report.failed, 'failed')}`\n}\n\n/** Render pull's success tally. */\nexport function pullSuccess(count: number): string {\n\treturn `wrote ${countPart(count, 'guide')}`\n}\n\n/** Render one fleet repository outcome. */\nexport function fleetRepoLine(name: string, outcome: FleetOutcome): string {\n\tif (outcome.state === 'clean') return `${name}: clean`\n\tif (outcome.state === 'drifted') return `${name}: ${bucketText(outcome)}`\n\tif (outcome.state === 'repaired') {\n\t\treturn `${name}: repaired (${countPart(outcome.remaining, 'finding')} remaining)`\n\t}\n\treturn `${name}: ${outcome.message}`\n}\n\n/** Render fleet's repository totals. */\nexport function fleetTotals(drifted: number, failed: number): string {\n\treturn `total: ${countPart(drifted, 'drifted repo')}, ${countPart(failed, 'failed')}`\n}\n\n/** Create catalog's terminal table. */\nexport function catalogTable(entries: readonly CatalogEntry[]): TableOptions {\n\treturn {\n\t\tcolumns: [{ label: 'Package' }, { label: 'Version' }],\n\t\trows: entries.map((entry) => [entry.name, entry.version]),\n\t}\n}\n\n/** Render catalog shrink risk when present. */\nexport function catalogShrinkWarning(oldRows: number, newRows: number): string | undefined {\n\tif (newRows >= oldRows) return undefined\n\treturn `warning: catalog shrinks from ${countPart(oldRows, 'row')} to ${newRows}`\n}\n\n/** Render catalog source tallies. */\nexport function catalogCounts(published: number, local: number): string {\n\treturn `catalog: ${countPart(published, 'published package')}, ${countPart(local, 'local-only')}`\n}\n\n/** Create `new`'s plan summary table. */\nexport function newPlanTable(summary: PlanSummary): TableOptions {\n\treturn {\n\t\tcolumns: [{ label: 'Origin' }, { label: 'Count', align: 'right' }],\n\t\trows: [\n\t\t\t['host-owned', String(summary.host)],\n\t\t\t['starter', String(summary.template)],\n\t\t\t['generated', String(summary.computed)],\n\t\t],\n\t}\n}\n\n/** Render `new`'s dry-run destination. */\nexport function newPlanPreview(name: string): string {\n\treturn `will write into ./${name}`\n}\n\n/** Render `new`'s write result. */\nexport function newApplySuccess(count: number, name: string): string {\n\treturn `wrote ${countPart(count, 'file')} into ./${name}`\n}\n\n/** Render catalog's write result. */\nexport function catalogApplySuccess(path: string): string {\n\treturn `wrote ${path}`\n}\n\n/** Render the shared write confirmation. */\nexport function applyConfirmMessage(files: number, repos?: number): string {\n\tconst scope = repos === undefined ? '' : ` across ${countPart(repos, 'repo')}`\n\treturn `Apply — write ${countPart(files, 'file')}${scope}? `\n}\n\n/** Render the separate prune confirmation. */\nexport function pruneConfirmMessage(count: number): string {\n\treturn `Also delete ${countPart(count, 'unexpected file')} under .claude/agents, .codex/agents, and scripts? `\n}\n\n/** Render the interactive audit-to-repair handoff. */\nexport function repairHandoff(owned: number, foreign: number, prune: boolean): string {\n\tconst parts: string[] = []\n\tif (owned > 0) {\n\t\tparts.push(`${countPart(owned, 'host-owned file')} ${owned === 1 ? 'has' : 'have'} drift`)\n\t}\n\tif (prune && foreign > 0) {\n\t\tparts.push(`${countPart(foreign, 'unexpected file')} will be deleted`)\n\t}\n\treturn `${parts.join(' and ')} — run repair now? `\n}\n\n/** Render one unresolved Orkestrel dependency token. */\nexport function unknownOrkestrelToken(token: string, suggestion: string | undefined): string {\n\tconst message = `\"${token}\" is not a published @orkestrel package`\n\treturn suggestion === undefined\n\t\t? `${message} — try again`\n\t\t: `${message} — did you mean \"${suggestion}\"? try again`\n}\n\n/** Render compact command usage. */\nexport function shortUsage(): string {\n\tconst lines = KNOWN_VERBS.map((verb) => ` ${verb.padEnd(8)}${VERB_SUMMARY[verb]}`)\n\treturn [\n\t\t'scaffold <verb> [options]',\n\t\t'',\n\t\t...lines,\n\t\t'',\n\t\t\"run 'scaffold <verb> --help' for a verb's full reference\",\n\t].join('\\n')\n}\n\n/** Render the full command reference. */\nexport function fullHelp(): string {\n\tconst verbs = KNOWN_VERBS.map(\n\t\t(verb) => ` ${verb} ${VERB_FLAGS[verb]}\\n ${VERB_SUMMARY[verb]}`,\n\t)\n\tconst exits = EXIT_CODES.map(([code, meaning]) => ` ${code} ${meaning}`)\n\treturn [\n\t\t'scaffold <verb> [options]',\n\t\t'',\n\t\t...verbs,\n\t\t'',\n\t\tSAFETY_BANNER,\n\t\t'',\n\t\t'exit codes:',\n\t\t...exits,\n\t].join('\\n')\n}\n\n/** Render one command's help reference. */\nexport function verbHelp(verb: Verb): string {\n\tconst flags = VERB_FLAG_HELP[verb].map(([flag, meaning]) => ` ${flag.padEnd(20)}${meaning}`)\n\treturn [\n\t\t`scaffold ${verb} ${VERB_FLAGS[verb]}`,\n\t\t'',\n\t\tVERB_SUMMARY[verb],\n\t\tVERB_DRY_RUN_NOTE[verb],\n\t\t'',\n\t\t...flags,\n\t\t'',\n\t\tVERB_EXAMPLE[verb],\n\t].join('\\n')\n}\n\n/** Compute Levenshtein edit distance. */\nexport function editDistance(left: string, right: string): number {\n\tconst rows = left.length + 1\n\tconst columns = right.length + 1\n\tconst table = new Uint32Array(rows * columns)\n\tfor (let row = 0; row < rows; row += 1) table[row * columns] = row\n\tfor (let column = 0; column < columns; column += 1) table[column] = column\n\tfor (let row = 1; row < rows; row += 1) {\n\t\tfor (let column = 1; column < columns; column += 1) {\n\t\t\tconst cost = left[row - 1] === right[column - 1] ? 0 : 1\n\t\t\tconst index = row * columns + column\n\t\t\ttable[index] = Math.min(\n\t\t\t\t(table[index - columns] ?? 0) + 1,\n\t\t\t\t(table[index - 1] ?? 0) + 1,\n\t\t\t\t(table[index - columns - 1] ?? 0) + cost,\n\t\t\t)\n\t\t}\n\t}\n\treturn table[rows * columns - 1] ?? 0\n}\n\n/** Find the nearest string by edit distance. */\nexport function nearest(input: string, set: readonly string[]): string | undefined {\n\tlet best: string | undefined\n\tlet distance = Number.POSITIVE_INFINITY\n\tfor (const candidate of set) {\n\t\tconst candidateDistance = editDistance(input, candidate)\n\t\tif (candidateDistance < distance) {\n\t\t\tdistance = candidateDistance\n\t\t\tbest = candidate\n\t\t}\n\t}\n\treturn best\n}\n\n/** Render an unknown command with a nearest-command hint. */\nexport function didYouMean(command: string): string {\n\tconst suggestion = nearest(command, KNOWN_VERBS)\n\treturn suggestion === undefined\n\t\t? `unknown command \"${command}\"`\n\t\t: `unknown command \"${command}\" — did you mean \"${suggestion}\"?`\n}\n\n/** Render one prune preview line per exact path. */\nexport function prunePreview(paths: readonly string[]): readonly string[] {\n\treturn paths.map((path) => ` delete ${path}`)\n}\n\n/** Render non-terminal guidance for missing input. */\nexport function missingInput(input: string, verb: string): string {\n\treturn `missing ${input} — pass it as a flag/argument, or run 'scaffold ${verb}' on a terminal to be guided`\n}\n\n/** Render an invalid package name. */\nexport function invalidName(name: string, pattern: string): string {\n\treturn `Package name \"${name}\" must match ${pattern}`\n}\n\n/** Render dependencies whose latest versions could not be resolved. */\nexport function unresolvedVersion(names: readonly string[]): string {\n\treturn `could not resolve the latest version for ${names.map((name) => `\"${name}\"`).join(', ')} — check the name or pass name@range`\n}\n\n/** Render drift that belongs to generated artifacts. */\nexport function generatedNote(count: number): string {\n\treturn `${countPart(count, 'finding')} in generated files — these are regenerated, not hand-edited; repair does not touch them`\n}\n\n/** Render live dependency freshness tallies. */\nexport function auditLiveNote(current: number, behind: number, failed: number): string {\n\treturn `live: ${countPart(current, 'current')}, ${countPart(behind, 'behind')}, ${countPart(failed, 'failed')}`\n}\n\n/** Render whether an audit compared content or presence. */\nexport function comparisonLine(aware: boolean): string {\n\treturn aware\n\t\t? 'comparing: file contents for host-owned files'\n\t\t: 'comparing: file names only for host-owned files (no vendored source found)'\n}\n\n/** Render catalog's final verdict. */\nexport function catalogVerdict(clean: boolean): string {\n\treturn clean ? 'catalog: clean' : 'catalog: drifted — pass --apply to write'\n}\n\n/** Render a caught error without leaking implementation detail. */\nexport function describeError(error: unknown): string {\n\tif (isScaffoldError(error)) return `[${error.code}] ${error.message}`\n\treturn error instanceof Error ? error.message : 'unknown error'\n}\n\n/** Resolve and confine one write destination to its invocation root. */\nexport function containDestination(root: string, candidate: string): string {\n\tif (!isFilesystemPath(root) || !isFilesystemPath(candidate)) {\n\t\tthrow new ScaffoldError('INVALID', 'Target paths must not contain control characters')\n\t}\n\tconst contained = attempt(() =>\n\t\tresolvePhysicalPath(root, candidate, 'INVALID', 'working directory'),\n\t)\n\tif (contained.success) return contained.value\n\tif (isScaffoldError(contained.error) && contained.error.code === 'INVALID') {\n\t\tthrow new ScaffoldError(\n\t\t\t'INVALID',\n\t\t\t`Target \"${candidate}\" is outside or traverses a linked parent of the working directory — run scaffold from the physical directory you want to write beneath.`,\n\t\t\t{ path: candidate },\n\t\t)\n\t}\n\tthrow contained.error\n}\n\n/** Return one dependency-token issue, or absence when it is valid. */\nexport function orkestrelTokenIssue(\n\tnormalized: string,\n\tcatalog: readonly string[] | undefined,\n): string | undefined {\n\tif (catalog === undefined) {\n\t\treturn DEPENDENCY_NAME_PATTERN.test(normalized)\n\t\t\t? undefined\n\t\t\t: unknownOrkestrelToken(normalized, undefined)\n\t}\n\tif (catalog.includes(normalized)) return undefined\n\treturn unknownOrkestrelToken(normalized, nearest(normalized, catalog))\n}\n","import { parseArgs } from 'node:util'\nimport type { Dependency } from '@src/core'\nimport { isTerminalText } from '@src/server'\nimport { DEPENDENCY_NAME_PATTERN, ScaffoldError } from '@src/core'\nimport type { CLIArguments } from './types.js'\n\n/** Parse a strict command-line argument vector. */\nexport function parseArguments(argv: readonly string[]): CLIArguments {\n\tif (argv.some((argument) => !isTerminalText(argument))) {\n\t\tthrow new ScaffoldError('INVALID', 'Command arguments must not contain control characters')\n\t}\n\tconst args = argv[0] === '--' ? argv.slice(1) : [...argv]\n\treturn parseArgs({\n\t\targs,\n\t\tallowPositionals: true,\n\t\toptions: {\n\t\t\tsrc: { type: 'string' },\n\t\t\tapp: { type: 'string' },\n\t\t\tdeps: { type: 'string' },\n\t\t\tgroups: { type: 'string' },\n\t\t\ttarget: { type: 'string' },\n\t\t\tfrom: { type: 'string', multiple: true },\n\t\t\tapply: { type: 'boolean', default: false },\n\t\t\tyes: { type: 'boolean', default: false },\n\t\t\tjson: { type: 'boolean', default: false },\n\t\t\tprune: { type: 'boolean', default: false },\n\t\t\tstrict: { type: 'boolean', default: false },\n\t\t\tlive: { type: 'boolean', default: false },\n\t\t\toffline: { type: 'boolean', default: false },\n\t\t\thelp: { type: 'boolean', default: false, short: 'h' },\n\t\t},\n\t})\n}\n\n/** Split a comma-separated token list, trimming and dropping empty entries. */\nexport function splitTokens(raw: string): readonly string[] {\n\treturn raw\n\t\t.split(',')\n\t\t.map((token) => token.trim())\n\t\t.filter((token) => token.length > 0)\n}\n\n/** Normalize an Orkestrel dependency token to its full package name. */\nexport function normalizeOrkestrelToken(token: string): string {\n\treturn token.startsWith('@orkestrel/') ? token : `@orkestrel/${token}`\n}\n\n/**\n * Parse and resolve a pull dependency selection against the target manifest.\n *\n * @param raw - The comma-separated full package names, or `undefined` for all.\n * @param declared - The target's declared Orkestrel dependencies.\n * @returns `undefined` for all dependencies, otherwise the exact selected records.\n * @throws `ScaffoldError('INVALID')` for empty, malformed, repeated, or undeclared names.\n */\nexport function parsePullDependencies(\n\traw: string | undefined,\n\tdeclared: readonly Dependency[],\n): readonly Dependency[] | undefined {\n\tif (raw === undefined) return undefined\n\tconst names = raw.split(',').map((name) => name.trim())\n\tif (\n\t\tnames.length === 0 ||\n\t\tnames.some((name) => !DEPENDENCY_NAME_PATTERN.test(name)) ||\n\t\tnew Set(names).size !== names.length\n\t) {\n\t\tthrow new ScaffoldError(\n\t\t\t'INVALID',\n\t\t\t'Pull dependencies must be unique, comma-separated @orkestrel/* package names',\n\t\t)\n\t}\n\tconst selected = declared.filter((dependency) => names.includes(dependency.name))\n\tconst found = new Set(selected.map((dependency) => dependency.name))\n\tconst missing = names.filter((name) => !found.has(name))\n\tif (missing.length > 0) {\n\t\tthrow new ScaffoldError(\n\t\t\t'INVALID',\n\t\t\t`Pull dependencies are not declared by the target: ${missing.join(', ')}`,\n\t\t\t{ dependencies: missing },\n\t\t)\n\t}\n\treturn selected\n}\n","import { KNOWN_VERBS } from './constants.js'\nimport type { Verb } from './types.js'\n\n/** Narrow a positional command to the command-line interface's vocabulary. */\nexport function isVerb(value: string): value is Verb {\n\treturn KNOWN_VERBS.some((verb) => verb === value)\n}\n","// The `#!/usr/bin/env node` shebang is re-emitted by the build's `output.banner`, not source.\nimport { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { basename, dirname, join, relative as relativeOf } from 'node:path'\nimport * as tls from 'node:tls'\nimport type {\n\tAudit,\n\tBlueprint,\n\tCatalogEntry,\n\tFinding,\n\tDependency,\n\tGroup,\n\tPlan,\n\tSnapshot,\n\tSyncReport,\n} from '@src/core'\nimport {\n\tblueprint,\n\tblueprintToPlan,\n\tcatalogNames,\n\tcatalogToBlock,\n\tcreateCompiler,\n\tdependency,\n\tDEPENDENCY_NAME_PATTERN,\n\tdiffPlan,\n\tGROUPS,\n\tisScaffoldError,\n\tmanifestToDependencies,\n\tMAX_ARTIFACT_BYTES,\n\tNAME_PATTERN,\n\tplanToSummary,\n\tScaffoldError,\n\tENVIRONMENTS,\n} from '@src/core'\nimport {\n\tcatalogPackages,\n\tcommitWriteTransaction,\n\tcreateMaterializer,\n\tcreateSync,\n\tderiveBlueprint,\n\tdiscoverPackages,\n\tdigestFile,\n\tdigestText,\n\tdiscardWriteTransaction,\n\thostRoot,\n\thydratePlan,\n\tisRealDirectory,\n\tisVacant,\n\tlocateHostSource,\n\tpruneTargets,\n\treadFileText,\n\treadHostManifest,\n\treadManifest,\n\treadTarget,\n\tresolvePhysicalPath,\n\tvalidateWriteDirectories,\n\tWriteTransaction,\n} from '@src/server'\nimport type { SpinnerInterface } from '@orkestrel/console'\nimport { createReporter, createSpinner, createStyler } from '@orkestrel/console'\nimport { createServerSink } from '@orkestrel/console/server'\nimport { attempt } from '@orkestrel/contract'\nimport { isTerminalError } from '@orkestrel/terminal'\nimport type { TerminalInterface } from '@orkestrel/terminal/server'\nimport { createTerminal } from '@orkestrel/terminal/server'\nimport {\n\tCANCELLED_MESSAGE,\n\tCATALOG_UNRESOLVED_NOTE,\n\tCATALOG_AGENT_PATH,\n\tCATALOG_END_MARKER,\n\tCATALOG_START_MARKER,\n\tFOREIGN_HINT,\n\tINVALID_ARGUMENTS_MESSAGE,\n\tNEW_DRY_RUN_NOTE,\n\tORKESTREL_DEPS_PROMPT,\n\tPRUNE_EMPTY,\n\tPRUNE_SKIPPED,\n\tREPAIR_SCOPE,\n\tSCAN_SKIPPED,\n\tENVIRONMENT_CHOICES,\n} from './constants.js'\nimport { CLIExitError } from './errors.js'\nimport {\n\tapplyConfirmMessage,\n\tauditLiveNote,\n\tauditTable,\n\tauditVerdict,\n\tcatalogApplySuccess,\n\tcatalogCounts,\n\tcatalogShrinkWarning,\n\tcatalogTable,\n\tcatalogVerdict,\n\tcomparisonLine,\n\tcontainDestination,\n\tdescribeError,\n\tdidYouMean,\n\tfleetRepoLine,\n\tfleetTotals,\n\tfullHelp,\n\tgeneratedNote,\n\tinvalidName,\n\tmissingInput,\n\tnewApplySuccess,\n\tnewPlanPreview,\n\tnewPlanTable,\n\torkestrelTokenIssue,\n\tprunePreview,\n\tpruneConfirmMessage,\n\tpullCauseNotes,\n\tpullSuccess,\n\tpullTable,\n\tpullVerdict,\n\trepairHandoff,\n\trepairSuccess,\n\trepairVerdict,\n\tscopeNote,\n\tshortUsage,\n\tunresolvedVersion,\n\tverbHelp,\n} from './helpers.js'\nimport {\n\tnormalizeOrkestrelToken,\n\tparseArguments,\n\tparsePullDependencies,\n\tsplitTokens,\n} from './parsers.js'\nimport {\n\tauditToRepairResult,\n\tcatalogResultOf,\n\terrorEnvelopeOf,\n\tfleetEntryOf,\n\tpartitionFindings,\n\tsummaryToNewResult,\n} from './shapers.js'\nimport type {\n\tCLIArguments,\n\tCLIInterface,\n\tCLIValues,\n\tFleetEntry,\n\tFleetFailure,\n\tFleetRepo,\n\tForeignScanResult,\n\tLiveResult,\n} from './types.js'\nimport { isVerb } from './validators.js'\n\n/** Stateful command-line orchestration and its process boundary. */\nexport class CLI implements CLIInterface {\n\t#sink = createServerSink()\n\t#tty = process.stdout.isTTY === true\n\t#styler = createStyler({ enabled: process.env.NO_COLOR === undefined && this.#tty })\n\t#reporter = createReporter({\n\t\tsink: this.#sink,\n\t\twidth: this.#sink.columns,\n\t\tstyler: this.#styler,\n\t})\n\t#json = false\n\n\t/** Execute one command-line argument vector. */\n\tasync run(argv: readonly string[]): Promise<void> {\n\t\tthis.#trust()\n\t\ttry {\n\t\t\tawait this.#dispatch(argv)\n\t\t} catch (error) {\n\t\t\tif (error instanceof CLIExitError) {\n\t\t\t\tprocess.exitCode = error.code\n\t\t\t} else if (this.#json) {\n\t\t\t\tconst code = isScaffoldError(error) ? error.code : 'ERROR'\n\t\t\t\tconst message = isScaffoldError(error) ? error.message : describeError(error)\n\t\t\t\tthis.#write(errorEnvelopeOf(code, message))\n\t\t\t\tprocess.exitCode = 1\n\t\t\t} else {\n\t\t\t\tthis.#reporter.status('error', describeError(error))\n\t\t\t\tprocess.exitCode = 1\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Widen Node's default trusted-issuer set to include the OS certificate\n\t * store, so `fetch` behind a corporate TLS-inspecting proxy behaves like npm\n\t * (`cafile`) and browsers (OS trust store) instead of failing with\n\t * `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` against Node's bundled CA list alone.\n\t * Feature-detected (`tls.getCACertificates` / `tls.setDefaultCACertificates`\n\t * ship on Node ≈22.16+/24.5+; this package's floor is `>=22.12.0`) and captured\n\t * through `attempt` — any failure is a silent no-op, never a crash. This only ADDS\n\t * trusted issuers; it never touches `rejectUnauthorized` or\n\t * `NODE_TLS_REJECT_UNAUTHORIZED`, so certificate verification stays on.\n\t */\n\t#trust(): void {\n\t\tif (\n\t\t\ttypeof tls.getCACertificates !== 'function' ||\n\t\t\ttypeof tls.setDefaultCACertificates !== 'function'\n\t\t) {\n\t\t\treturn\n\t\t}\n\t\tattempt(() => {\n\t\t\tconst merged = new Set([\n\t\t\t\t...tls.getCACertificates('default'),\n\t\t\t\t...tls.getCACertificates('system'),\n\t\t\t])\n\t\t\ttls.setDefaultCACertificates([...merged])\n\t\t})\n\t}\n\n\t/** Write ONE machine-readable JSON value to stdout — the entire `--json` output contract. */\n\t#write(value: unknown): void {\n\t\tprocess.stdout.write(`${JSON.stringify(value)}\\n`)\n\t}\n\n\t/** Report a general operation failure with exit 1 as prose or one JSON error envelope. */\n\t#fail(message: string, json: boolean): never {\n\t\tif (json) this.#write(errorEnvelopeOf('ERROR', message))\n\t\telse this.#reporter.status('error', message)\n\t\tthrow new CLIExitError(1)\n\t}\n\n\t/**\n\t * A general operation failure from a caught error — the real\n\t * `ScaffoldError` code when available ('ERROR' last resort), prose (via\n\t * `describe`, which still carries the bracketed code for a human reader) or\n\t * the one JSON error envelope under `--json` (code and message kept\n\t * SEPARATE — never double-encoding the code into the message text).\n\t */\n\t#error(error: unknown, json: boolean): never {\n\t\tif (json) {\n\t\t\tconst code = isScaffoldError(error) ? error.code : 'ERROR'\n\t\t\tconst message = isScaffoldError(error) ? error.message : describeError(error)\n\t\t\tthis.#write(errorEnvelopeOf(code, message))\n\t\t} else {\n\t\t\tthis.#reporter.status('error', describeError(error))\n\t\t}\n\t\tthrow new CLIExitError(1)\n\t}\n\n\t/** A usage error (bad flag value, unknown verb — exit 2) — stderr prose, or the one JSON error envelope under `--json`. */\n\t#usage(message: string, json: boolean): never {\n\t\tif (json) this.#write(errorEnvelopeOf('USAGE', message))\n\t\telse process.stderr.write(`${message}\\n`)\n\t\tthrow new CLIExitError(2)\n\t}\n\n\t/** Contain a destination and report any coded escape through the shared CLI error path. */\n\t#contain(candidate: string, json: boolean): string {\n\t\tconst contained = attempt(() => containDestination(process.cwd(), candidate))\n\t\tif (contained.success) return contained.value\n\t\tthis.#error(contained.error, json)\n\t}\n\n\t/** Compile a spec and report unresolved blocking questions through the shared CLI error path. */\n\t#compile(spec: Blueprint, json: boolean): Plan {\n\t\tconst compiler = createCompiler()\n\t\ttry {\n\t\t\tconst scaffolding = compiler.compile(spec)\n\t\t\tif (!scaffolding.plan) {\n\t\t\t\tconst message = scaffolding.questions.map((question) => question.text).join('; ')\n\t\t\t\tthis.#fail(message, json)\n\t\t\t}\n\t\t\treturn scaffolding.plan\n\t\t} finally {\n\t\t\tcompiler.destroy()\n\t\t}\n\t}\n\n\t/**\n\t * Merge a `pruneTargets` scan into `audit` as `foreign` findings — pure\n\t * object-spread composition in the BIN only (`src/core`'s `diffPlan` is never\n\t * modified/reimplemented). Every unexpected path becomes one\n\t * `'orchestration'`-group `foreign` finding (the `Group` every `PRUNE_DIRECTORIES`\n\t * entry—`.claude/agents`, `.codex/agents`, `scripts`—belongs to); any scan hit makes the\n\t * merged audit unclean, so an \"unexpected file\" is honestly counted as drift\n\t * (exit 1) instead of the structurally-always-zero `diffPlan.foreign`.\n\t */\n\t#scan(audit: Audit, target: string, host: string): Audit {\n\t\tconst paths = pruneTargets(target, host)\n\t\tif (paths.length === 0) return audit\n\t\tconst findings: Finding[] = paths.map((path) => ({\n\t\t\tpath,\n\t\t\tgroup: 'orchestration',\n\t\t\tdrift: 'foreign',\n\t\t}))\n\t\treturn {\n\t\t\t...audit,\n\t\t\tclean: false,\n\t\t\tforeign: audit.foreign + paths.length,\n\t\t\tfindings: [...audit.findings, ...findings],\n\t\t}\n\t}\n\n\t/**\n\t * Add unexpected-file findings when the vendored allowlist can be established.\n\t * When fail-closed allowlist discovery raises a coded `TARGET` failure, retain\n\t * the existing findings and mark the audit incomplete instead of crashing.\n\t */\n\t#scanSafe(audit: Audit, target: string, host: string): ForeignScanResult {\n\t\tconst scanned = attempt(() => this.#scan(audit, target, host))\n\t\tif (scanned.success) return { audit: scanned.value, skipped: false }\n\t\tif (isScaffoldError(scanned.error) && scanned.error.code === 'TARGET') {\n\t\t\treturn {\n\t\t\t\taudit: {\n\t\t\t\t\t...audit,\n\t\t\t\t\tclean: false,\n\t\t\t\t\tcomplete: false,\n\t\t\t\t\tquestions: [\n\t\t\t\t\t\t...audit.questions,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'host',\n\t\t\t\t\t\t\ttext: scanned.error.message,\n\t\t\t\t\t\t\tblocking: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tskipped: true,\n\t\t\t}\n\t\t}\n\t\tthrow scanned.error\n\t}\n\n\t/**\n\t * `repair`'s own scope is host-only, but the caller compiles the FULL plan anyway — diff it too\n\t * (cheap, local, no network) so a clean host verdict can point at drift OUTSIDE repair's reach.\n\t * The count feeds the shared `scopeNote` renderer.\n\t */\n\t#outside(compiled: Plan, target: string): number {\n\t\tconst full = diffPlan(\n\t\t\tcompiled,\n\t\t\treadTarget(\n\t\t\t\ttarget,\n\t\t\t\tcompiled.artifacts.map((artifact) => artifact.path),\n\t\t\t),\n\t\t)\n\t\treturn full.drifted + full.missing + full.foreign\n\t}\n\n\t/** Reject a cancelled prompt (ctrl-c) with the shared `CANCELLED_MESSAGE` — exit 1, nothing written. */\n\tasync #guard<T>(promise: Promise<T>): Promise<T> {\n\t\ttry {\n\t\t\treturn await promise\n\t\t} catch (error) {\n\t\t\tif (isTerminalError(error) && error.code === 'CANCEL') {\n\t\t\t\tthis.#reporter.line(CANCELLED_MESSAGE)\n\t\t\t\tthrow new CLIExitError(1)\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * The shared write-confirmation gate every verb calls before it touches disk.\n\t * `--apply` writes without asking; `--json` (without `--apply`) is a pure\n\t * dry-run and NEVER prompts; `--yes` auto-answers yes; otherwise a real\n\t * confirm with `default: false` (EOF on stdin resolves to the default).\n\t */\n\tasync #apply(\n\t\tterminal: TerminalInterface,\n\t\tmessage: string,\n\t\tvalues: CLIValues,\n\t\tjson: boolean,\n\t): Promise<boolean> {\n\t\tif (values.apply) return true\n\t\tif (json) return false\n\t\tif (values.yes) return true\n\t\treturn this.#guard(terminal.confirm({ message, default: false }))\n\t}\n\n\t/**\n\t * The SECOND, separate confirm for `--prune`-eligible deletions — never\n\t * bundled into `resolveApply`'s question. `--yes` only auto-answers this\n\t * when `--prune` was also passed (it never enables pruning by itself).\n\t */\n\tasync #prune(\n\t\tterminal: TerminalInterface,\n\t\tmessage: string,\n\t\tvalues: CLIValues,\n\t\tjson: boolean,\n\t): Promise<boolean> {\n\t\tif (!values.prune) return false\n\t\tif (values.apply) return true\n\t\tif (json) return false\n\t\tif (values.yes) return true\n\t\t// The write confirmation already consumed the single answer available on a\n\t\t// non-interactive stream. Never ask a second question from drained stdin;\n\t\t// skip pruning explicitly instead.\n\t\tif (!this.#tty) {\n\t\t\tthis.#reporter.line(PRUNE_SKIPPED)\n\t\t\treturn false\n\t\t}\n\t\treturn this.#guard(terminal.confirm({ message, default: false }))\n\t}\n\n\t/** A spinner for a long-running write step, absent under `--json` or off a TTY sink. */\n\t#spinner(message: string, json: boolean): SpinnerInterface | undefined {\n\t\treturn json || !this.#tty\n\t\t\t? undefined\n\t\t\t: createSpinner({ message, sink: this.#sink, styler: this.#styler })\n\t}\n\n\t/** Announce a successful write — the spinner's own success line, or a plain `reporter.status` without one (never under `--json`). */\n\t#succeed(spinner: SpinnerInterface | undefined, json: boolean, message: string): void {\n\t\tif (spinner) spinner.success(message)\n\t\telse if (!json) this.#reporter.status('success', message)\n\t}\n\n\t/** Announce a failed write and halt(1) — the spinner's own failure line (if any), then the shared `fail`. */\n\t#reject(spinner: SpinnerInterface | undefined, json: boolean, error: unknown): never {\n\t\tconst message = describeError(error)\n\t\tif (spinner) spinner.failure(message)\n\t\tthis.#fail(message, json)\n\t}\n\n\t/**\n\t * Best-effort vendored `@orkestrel` catalog names, resolved via `host`\n\t * (`hostRoot()`, or the active `--from` override) through the host manifest\n\t * — `undefined` when the catalog cannot be established (a missing/unreadable\n\t * manifest, no `.claude/agents/orkestrel.md` entry, or any other failure),\n\t * degrading the dependency prompt to shape-only validation instead of blocking on it.\n\t */\n\t#names(host: string): readonly string[] | undefined {\n\t\tconst names = attempt(() => {\n\t\t\tconst manifest = readHostManifest(host)\n\t\t\tconst full = locateHostSource(manifest, '.claude/agents/orkestrel.md', host)\n\t\t\tif (full === undefined || !existsSync(full)) return undefined\n\t\t\tconst relative = relativeOf(host, full).replaceAll('\\\\', '/')\n\t\t\treturn catalogNames(readFileText(host, relative, 'TARGET', 'host'))\n\t\t})\n\t\treturn names.success ? names.value : undefined\n\t}\n\n\t/** Prompt for `@orkestrel` short-name dependencies until every token resolves or input is empty. */\n\tasync #prompt(\n\t\tterminal: TerminalInterface,\n\t\tcatalog: readonly string[] | undefined,\n\t): Promise<readonly string[]> {\n\t\tfor (;;) {\n\t\t\tconst raw = await this.#guard(terminal.input({ message: ORKESTREL_DEPS_PROMPT, default: '' }))\n\t\t\tconst tokens = splitTokens(raw)\n\t\t\tif (tokens.length === 0) return []\n\t\t\tconst normalized = tokens.map(normalizeOrkestrelToken)\n\t\t\tconst issue = normalized\n\t\t\t\t.map((token) => orkestrelTokenIssue(token, catalog))\n\t\t\t\t.find((message) => message !== undefined)\n\t\t\tif (issue === undefined) return normalized\n\t\t\tthis.#reporter.line(issue)\n\t\t}\n\t}\n\n\t/** `scaffold new` — scaffold a package into `./<name>` (or `--target`). */\n\tasync #new(values: CLIValues, argument: string | undefined, json: boolean): Promise<void> {\n\t\tconst terminal = createTerminal()\n\n\t\tlet name: string\n\t\tif (argument !== undefined) {\n\t\t\tname = argument\n\t\t} else if (json) {\n\t\t\tthis.#usage('a package name is required with --json', json)\n\t\t} else if (!this.#tty) {\n\t\t\tthis.#usage(missingInput('a package name', 'new'), json)\n\t\t} else {\n\t\t\tname = await this.#guard(\n\t\t\t\tterminal.input({\n\t\t\t\t\tmessage: 'Package name',\n\t\t\t\t\tvalidate: { pattern: NAME_PATTERN.source },\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\t// Validate positional and interactively collected names against the same\n\t\t// core-owned package-name contract.\n\t\tif (!NAME_PATTERN.test(name)) {\n\t\t\tthis.#usage(invalidName(name, NAME_PATTERN.source), json)\n\t\t}\n\n\t\tlet srcInput: readonly string[]\n\t\tlet appInput: readonly string[]\n\t\tif (values.src !== undefined) {\n\t\t\tsrcInput = values.src.split(',').map((candidate) => candidate.trim())\n\t\t} else if (values.app !== undefined) {\n\t\t\tsrcInput = []\n\t\t} else if (json || !this.#tty) {\n\t\t\tthis.#usage('at least one of --src or --app is required', json)\n\t\t} else {\n\t\t\tsrcInput = await this.#guard(\n\t\t\t\tterminal.checkbox({\n\t\t\t\t\tmessage: 'Published src environments',\n\t\t\t\t\tchoices: ENVIRONMENT_CHOICES,\n\t\t\t\t\tmin: 0,\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\tif (values.app !== undefined) {\n\t\t\tappInput = values.app.split(',').map((candidate) => candidate.trim())\n\t\t} else if (values.src !== undefined || json || !this.#tty) {\n\t\t\tappInput = []\n\t\t} else {\n\t\t\tappInput = await this.#guard(\n\t\t\t\tterminal.checkbox({\n\t\t\t\t\tmessage: 'Application environments',\n\t\t\t\t\tchoices: ENVIRONMENT_CHOICES,\n\t\t\t\t\tmin: 0,\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\tconst unrecognizedSrcEnvironment = srcInput.filter(\n\t\t\t(candidate) => !ENVIRONMENTS.some((environment) => environment === candidate),\n\t\t)\n\t\tif (unrecognizedSrcEnvironment.length > 0) {\n\t\t\tthis.#usage(\n\t\t\t\t`Environment \"${unrecognizedSrcEnvironment.join('\", \"')}\" is not recognized`,\n\t\t\t\tjson,\n\t\t\t)\n\t\t}\n\t\tif (new Set(srcInput).size !== srcInput.length) {\n\t\t\tthis.#usage('Published src environments must not repeat', json)\n\t\t}\n\t\tconst src = ENVIRONMENTS.filter((environment) => srcInput.includes(environment))\n\t\tconst unrecognizedAppEnvironment = appInput.filter(\n\t\t\t(candidate) => !ENVIRONMENTS.some((environment) => environment === candidate),\n\t\t)\n\t\tif (unrecognizedAppEnvironment.length > 0) {\n\t\t\tthis.#usage(\n\t\t\t\t`Application environment \"${unrecognizedAppEnvironment.join('\", \"')}\" is not recognized`,\n\t\t\t\tjson,\n\t\t\t)\n\t\t}\n\t\tif (new Set(appInput).size !== appInput.length) {\n\t\t\tthis.#usage('Application environments must not repeat', json)\n\t\t}\n\t\tconst app = ENVIRONMENTS.filter((environment) => appInput.includes(environment))\n\t\tif (src.length === 0 && app.length === 0) {\n\t\t\tthis.#usage('at least one source or application environment is required', json)\n\t\t}\n\n\t\t// Establish containment before preview, network access, confirmation, or\n\t\t// any other work that assumes the destination is writable.\n\t\tconst destination = this.#contain(values.target ?? `./${name}`, json)\n\t\tif (!isVacant(destination)) {\n\t\t\tthis.#error(\n\t\t\t\tnew ScaffoldError('TARGET', 'new requires a vacant target', { target: destination }),\n\t\t\t\tjson,\n\t\t\t)\n\t\t}\n\t\tconst explicitHost = values.from?.[0]\n\t\tif (explicitHost !== undefined) {\n\t\t\tif (!isRealDirectory(explicitHost)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\tnew ScaffoldError('TARGET', `Host root is not a physical directory at ${explicitHost}`, {\n\t\t\t\t\t\thost: explicitHost,\n\t\t\t\t\t}),\n\t\t\t\t\tjson,\n\t\t\t\t)\n\t\t\t}\n\t\t\treadHostManifest(explicitHost)\n\t\t}\n\n\t\t// `--deps` is OPTIONAL — a non-TTY session with neither `--json` nor\n\t\t// `--deps` defaults to no extra dependencies rather than failing (only a\n\t\t// REQUIRED input triggers `missingInput`'s usage error); the multi-prompt\n\t\t// guidance below stays TTY-only under the one-prompt-per-process ceiling.\n\t\t// `--deps` uses an untrimmed split and is\n\t\t// `DEPENDENCY_NAME_PATTERN`-gated BEFORE any network call. The\n\t\t// interactive prompt adds short-name\n\t\t// normalization + vendored-catalog validation (re-asking on an unknown\n\t\t// token, degrading to shape-only when the catalog cannot be resolved).\n\t\tlet depNames: readonly string[]\n\t\tif (values.deps !== undefined) {\n\t\t\tdepNames = values.deps.split(',').filter((depName) => depName.length > 0)\n\t\t\tconst badDep = depNames.find((depName) => !DEPENDENCY_NAME_PATTERN.test(depName))\n\t\t\tif (badDep !== undefined) {\n\t\t\t\tthis.#usage(\n\t\t\t\t\t`Dependency name \"${badDep}\" must match ${DEPENDENCY_NAME_PATTERN.source}`,\n\t\t\t\t\tjson,\n\t\t\t\t)\n\t\t\t}\n\t\t} else if (json || !this.#tty) {\n\t\t\tdepNames = []\n\t\t} else {\n\t\t\tconst catalogHost = values.from?.[0] ?? hostRoot()\n\t\t\tconst catalog = this.#names(catalogHost)\n\t\t\tif (catalog === undefined) this.#reporter.line(CATALOG_UNRESOLVED_NOTE)\n\t\t\tdepNames = await this.#prompt(terminal, catalog)\n\t\t}\n\n\t\t// `--deps` resolves latest versions from the registry and pins caret ranges; their\n\t\t// guides fetch into the plan.\n\t\tconst sync = createSync()\n\t\tlet versions\n\t\ttry {\n\t\t\tversions = await sync.versions(depNames.map((depName) => dependency(depName, '*')))\n\t\t} finally {\n\t\t\tsync.destroy()\n\t\t}\n\t\t// `createSync()` is non-strict — it never throws — so a range-less\n\t\t// `--deps` name that the registry could not resolve (`freshness`\n\t\t// 'missing'/'failed', `latest` '') is a HARD failure here: writing `^` +\n\t\t// an empty `latest` would otherwise land an unwritable `\"^\"` range in\n\t\t// package.json with exit 0.\n\t\tconst unresolved = versions\n\t\t\t.filter(\n\t\t\t\t(version) =>\n\t\t\t\t\t(version.freshness !== 'current' && version.freshness !== 'behind') ||\n\t\t\t\t\tversion.latest === '',\n\t\t\t)\n\t\t\t.map((version) => version.name)\n\t\tif (unresolved.length > 0) this.#fail(unresolvedVersion(unresolved), json)\n\t\tconst deps = versions.map((version) => dependency(version.name, `^${version.latest}`))\n\n\t\t// Extra devDependencies are authored in `package.json` after scaffolding;\n\t\t// `deriveBlueprint`'s extras round-trip\n\t\t// (`@src/server`) recompiles them back into the plan, so `audit` stays\n\t\t// clean over a hand-added `devDependencies` entry (AGENTS §21 core stays\n\t\t// the single source of truth for that relaxation).\n\t\tconst plan = this.#compile(blueprint(name, { src, app, dependencies: deps }), json)\n\n\t\tconst summary = planToSummary(plan)\n\n\t\tif (!json) {\n\t\t\tthis.#reporter.section('Plan')\n\t\t\tthis.#reporter.table(newPlanTable(summary))\n\t\t\tthis.#reporter.line(newPlanPreview(name))\n\t\t}\n\n\t\tconst proceed = await this.#apply(\n\t\t\tterminal,\n\t\t\tapplyConfirmMessage(summary.host + summary.template + summary.computed),\n\t\t\tvalues,\n\t\t\tjson,\n\t\t)\n\n\t\tif (!proceed) {\n\t\t\tif (json) this.#write(summaryToNewResult(summary, false))\n\t\t\telse this.#reporter.line(NEW_DRY_RUN_NOTE)\n\t\t\tprocess.exitCode = 0\n\t\t\treturn\n\t\t}\n\n\t\tconst spinner = this.#spinner('materializing', json)\n\t\tspinner?.start()\n\t\tconst host = values.from?.[0]\n\t\tconst materializer = createMaterializer(host === undefined ? undefined : { host })\n\t\ttry {\n\t\t\tconst result = materializer.materialize(plan, destination)\n\t\t\tconst count = result.written.length + result.copied.length\n\t\t\tif (json) this.#write(summaryToNewResult(summary, true))\n\t\t\telse this.#succeed(spinner, json, newApplySuccess(count, name))\n\t\t} catch (error) {\n\t\t\tthis.#reject(spinner, json, error)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t\tprocess.exitCode = 0\n\t}\n\n\t/** `scaffold pull` — refresh vendored dependency mirrors and report range drift. */\n\tasync #pull(values: CLIValues, json: boolean): Promise<void> {\n\t\tconst target = this.#contain(values.target ?? '.', json)\n\n\t\tconst sync = createSync(values.strict === undefined ? undefined : { strict: values.strict })\n\t\ttry {\n\t\t\tlet report: SyncReport\n\t\t\ttry {\n\t\t\t\tconst declared = manifestToDependencies(readManifest(target))\n\t\t\t\tconst selected = parsePullDependencies(values.deps, declared)\n\t\t\t\treport = await sync.pull(target, selected)\n\t\t\t} catch (error) {\n\t\t\t\tthis.#error(error, json)\n\t\t\t}\n\n\t\t\tif (!json) {\n\t\t\t\tthis.#reporter.table(pullTable(report))\n\t\t\t\tfor (const line of pullCauseNotes(report)) this.#reporter.line(line)\n\t\t\t\tthis.#reporter.line(pullVerdict(report))\n\t\t\t}\n\n\t\t\tconst toWrite = [...report.guides, ...report.versions].filter(\n\t\t\t\t(entry) => entry.freshness !== 'current',\n\t\t\t).length\n\n\t\t\tconst terminal = createTerminal()\n\t\t\tconst proceed =\n\t\t\t\ttoWrite > 0\n\t\t\t\t\t? await this.#apply(terminal, applyConfirmMessage(toWrite), values, json)\n\t\t\t\t\t: false\n\n\t\t\tif (proceed) {\n\t\t\t\tconst spinner = this.#spinner('writing mirrors', json)\n\t\t\t\tspinner?.start()\n\t\t\t\ttry {\n\t\t\t\t\tconst written = await sync.write(report, target)\n\t\t\t\t\tif (json) this.#write(report)\n\t\t\t\t\telse this.#succeed(spinner, json, pullSuccess(written.length))\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.#reject(spinner, json, error)\n\t\t\t\t}\n\t\t\t} else if (json) {\n\t\t\t\tthis.#write(report)\n\t\t\t}\n\n\t\t\tprocess.exitCode = report.clean ? 0 : proceed ? 0 : 1\n\t\t} finally {\n\t\t\tsync.destroy()\n\t\t}\n\t}\n\n\t/** `scaffold audit` — whole-plan conformance report; offers a repair handoff on drift. */\n\tasync #audit(values: CLIValues, json: boolean): Promise<void> {\n\t\tconst target = this.#contain(values.target ?? '.', json)\n\n\t\tlet spec: Blueprint\n\t\ttry {\n\t\t\tspec = deriveBlueprint(target)\n\t\t} catch (error) {\n\t\t\tthis.#error(error, json)\n\t\t}\n\n\t\tconst deps: readonly Dependency[] = [...spec.dependencies, ...spec.peers, ...spec.extras]\n\n\t\tconst groupsInput = values.groups?.split(',')\n\t\tlet groups: readonly Group[] | undefined\n\t\tif (groupsInput !== undefined) {\n\t\t\tconst unrecognized = groupsInput.filter((name) => !GROUPS.some((group) => group === name))\n\t\t\tif (unrecognized.length > 0) {\n\t\t\t\tthis.#usage(`Group \"${unrecognized.join('\", \"')}\" is not recognized`, json)\n\t\t\t}\n\t\t\tgroups = GROUPS.filter((group) => groupsInput.includes(group))\n\t\t}\n\n\t\tconst compiled = blueprintToPlan(spec, groups)\n\t\tconst from = values.from?.[0]\n\t\tconst host = from ?? hostRoot()\n\t\tlet plan: Plan\n\t\ttry {\n\t\t\tplan = hydratePlan(compiled, host)\n\t\t} catch (error) {\n\t\t\tthis.#error(error, json)\n\t\t}\n\t\tconst artifactPaths = plan.artifacts.map((artifact) => artifact.path)\n\n\t\t// Merge the physical unexpected-file scan into the presented audit. Only an\n\t\t// established host can positively define the vendored allowlist; a failed\n\t\t// scan marks the audit incomplete without erasing its other findings.\n\t\tconst rawAudit = diffPlan(plan, readTarget(target, artifactPaths))\n\t\tconst scanned = this.#scanSafe(rawAudit, target, host)\n\t\tconst audit = scanned.audit\n\t\tlet drifted = !audit.clean\n\n\t\tlet live: LiveResult | undefined\n\t\tif (values.live) {\n\t\t\tconst sync = createSync()\n\t\t\ttry {\n\t\t\t\tconst guides = await sync.guides(deps)\n\t\t\t\tconst versions = await sync.versions(deps)\n\t\t\t\tconst entries = [...guides, ...versions]\n\t\t\t\tdrifted ||= entries.some((entry) => entry.freshness !== 'current')\n\t\t\t\tconst current = entries.filter((entry) => entry.freshness === 'current').length\n\t\t\t\tconst behind = entries.filter((entry) => entry.freshness === 'behind').length\n\t\t\t\tconst failed = entries.length - current - behind\n\t\t\t\tlive = { current, behind, failed }\n\t\t\t} finally {\n\t\t\t\tsync.destroy()\n\t\t\t}\n\t\t}\n\n\t\tif (json) {\n\t\t\tthis.#write(live === undefined ? audit : { ...audit, live })\n\t\t\tprocess.exitCode = drifted ? 1 : 0\n\t\t\treturn\n\t\t}\n\n\t\tif (scanned.skipped) this.#reporter.line(SCAN_SKIPPED)\n\t\tthis.#reporter.line(comparisonLine(true))\n\t\tthis.#reporter.table(auditTable(audit, plan))\n\t\tthis.#reporter.line(auditVerdict(audit, plan))\n\t\tif (live !== undefined) {\n\t\t\tthis.#reporter.line(auditLiveNote(live.current, live.behind, live.failed))\n\t\t}\n\n\t\tif (!audit.clean) {\n\t\t\tconst split = partitionFindings(audit.findings, plan)\n\t\t\tconst ownedCount = split.owned.drifted + split.owned.missing\n\t\t\tconst computedCount = split.generated.drifted + split.generated.missing\n\t\t\tconst pruneRequested = values.prune === true\n\n\t\t\t// Audit never writes via flags: the handoff is an INTERACTIVE\n\t\t\t// convenience only, offered exclusively on a TTY session — `--apply` /\n\t\t\t// `--yes` NEVER count as handoff consent here (they gate the SEPARATE\n\t\t\t// `repair` run this branch may launch, never audit's own read-only\n\t\t\t// pass. A foreign-only handoff would be a dead end: the handoff also covers\n\t\t\t// foreign files, but ONLY when `--prune` was passed — an inherited\n\t\t\t// repair without `--prune` cannot delete them, so offering the handoff\n\t\t\t// for foreign-only drift without `--prune` would be a dead end.\n\t\t\tconst offerHandoff = this.#tty && (ownedCount > 0 || (audit.foreign > 0 && pruneRequested))\n\n\t\t\tlet handoffAccepted = false\n\t\t\tif (offerHandoff) {\n\t\t\t\tconst terminal = createTerminal()\n\t\t\t\tconst message = repairHandoff(ownedCount, audit.foreign, pruneRequested)\n\t\t\t\thandoffAccepted = await this.#guard(terminal.confirm({ message, default: false }))\n\t\t\t\tif (handoffAccepted) {\n\t\t\t\t\tawait this.#repair(values, false)\n\t\t\t\t\t// Repair's own exit code reflects only\n\t\t\t\t\t// ITS scope — re-diff the FULL plan (host/template/computed AND\n\t\t\t\t\t// the foreign scan) so the audit's exit code stays truthful about\n\t\t\t\t\t// ANY drift still remaining, mirroring `runFleet`'s post-repair\n\t\t\t\t\t// `finalAudit` pattern.\n\t\t\t\t\tconst rawFinal = diffPlan(plan, readTarget(target, artifactPaths))\n\t\t\t\t\tconst finalScanned = this.#scanSafe(rawFinal, target, host)\n\t\t\t\t\tprocess.exitCode = finalScanned.audit.clean ? 0 : 1\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!handoffAccepted) {\n\t\t\t\t// When the handoff cannot help foreign files (no `--prune`, or no\n\t\t\t\t// handoff offered at all), point at the one command that can.\n\t\t\t\tif (audit.foreign > 0 && !pruneRequested) this.#reporter.line(FOREIGN_HINT)\n\t\t\t\t// computed-origin drift is regenerated, never hand-edited — `repair`\n\t\t\t\t// has nothing to offer for it; `generatedNote` says so instead.\n\t\t\t\tif (computedCount > 0) this.#reporter.line(generatedNote(computedCount))\n\t\t\t}\n\t\t}\n\n\t\tprocess.exitCode = drifted ? 1 : 0\n\t}\n\n\t/** `scaffold repair` — restore the shared host-owned set for one target. */\n\tasync #repair(values: CLIValues, json: boolean): Promise<void> {\n\t\tconst target = this.#contain(values.target ?? '.', json)\n\n\t\tlet spec: Blueprint\n\t\ttry {\n\t\t\tspec = deriveBlueprint(target)\n\t\t} catch (error) {\n\t\t\tthis.#error(error, json)\n\t\t}\n\n\t\tconst compiled = this.#compile(spec, json)\n\n\t\t// Repair is the host-restoration tool ONLY — scope to host-origin\n\t\t// artifacts before hydrate/diff/apply so a mature repo's hand-written\n\t\t// src/tests/guides/package.json is never overwritten with a stub.\n\t\tconst scoped: Plan = {\n\t\t\t...compiled,\n\t\t\tartifacts: compiled.artifacts.filter((artifact) => artifact.origin === 'host'),\n\t\t}\n\n\t\tconst from = values.from?.[0]\n\t\tconst host = from ?? hostRoot()\n\t\tlet plan: Plan\n\t\ttry {\n\t\t\tplan = hydratePlan(scoped, host)\n\t\t} catch (error) {\n\t\t\tthis.#error(error, json)\n\t\t}\n\n\t\tlet audit: Audit\n\t\ttry {\n\t\t\taudit = diffPlan(\n\t\t\t\tplan,\n\t\t\t\treadTarget(\n\t\t\t\t\ttarget,\n\t\t\t\t\tplan.artifacts.map((artifact) => artifact.path),\n\t\t\t\t),\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthis.#error(error, json)\n\t\t}\n\n\t\tif (!json) {\n\t\t\tthis.#reporter.line(REPAIR_SCOPE)\n\t\t\tthis.#reporter.section('Audit')\n\t\t\tthis.#reporter.table(auditTable(audit, plan))\n\t\t}\n\n\t\t// The prune preview/confirm are driven by the real scan\n\t\t// (`pruneTargets`), never `audit.foreign` (which `diffPlan` can never\n\t\t// populate through this call path — it only ever reads the plan's own\n\t\t// paths). A zero-length scan skips the question entirely and is a no-op.\n\t\t// Compute this BEFORE the clean-audit check so `--prune` still reaches\n\t\t// this scan (and the deletion flow below) on a clean-host repo — a clean\n\t\t// this scan and deletion flow on a clean-host repo. Only a clean audit\n\t\t// with nothing to prune returns early.\n\t\tconst prunePaths = values.prune ? pruneTargets(target, host) : []\n\t\tconst pruneSnapshot = readTarget(target, prunePaths)\n\n\t\tif (audit.clean && prunePaths.length === 0) {\n\t\t\tif (json) {\n\t\t\t\tthis.#write(audit)\n\t\t\t} else {\n\t\t\t\tthis.#reporter.line(repairVerdict(audit))\n\t\t\t\tconst note = scopeNote(this.#outside(compiled, target))\n\t\t\t\tif (note !== undefined) this.#reporter.line(note)\n\t\t\t}\n\t\t\tprocess.exitCode = 0\n\t\t\treturn\n\t\t}\n\n\t\tif (!json) this.#reporter.line(repairVerdict(audit))\n\n\t\tconst terminal = createTerminal()\n\t\tlet proceed = true\n\t\tif (!audit.clean) {\n\t\t\tproceed = await this.#apply(\n\t\t\t\tterminal,\n\t\t\t\tapplyConfirmMessage(audit.drifted + audit.missing + audit.foreign),\n\t\t\t\tvalues,\n\t\t\t\tjson,\n\t\t\t)\n\t\t}\n\n\t\tif (!proceed) {\n\t\t\tif (json) this.#write(audit)\n\t\t\tprocess.exitCode = 1\n\t\t\treturn\n\t\t}\n\n\t\tif (values.prune && !json) {\n\t\t\tif (prunePaths.length === 0) this.#reporter.line(PRUNE_EMPTY)\n\t\t\telse for (const line of prunePreview(prunePaths)) this.#reporter.line(line)\n\t\t}\n\t\tconst doPrune =\n\t\t\tprunePaths.length > 0 &&\n\t\t\t(await this.#prune(terminal, pruneConfirmMessage(prunePaths.length), values, json))\n\n\t\tconst spinner = this.#spinner('repairing', json)\n\t\tspinner?.start()\n\t\tconst materializer = createMaterializer({ host })\n\t\ttry {\n\t\t\tconst result = materializer.repair(plan, audit, target)\n\t\t\tconst removed = doPrune ? materializer.prune(target, pruneSnapshot).removed : []\n\t\t\tif (json) this.#write(auditToRepairResult(audit, { ...result, removed }))\n\t\t\telse this.#succeed(spinner, json, repairSuccess(result, removed))\n\t\t} catch (error) {\n\t\t\tthis.#reject(spinner, json, error)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t\tprocess.exitCode = 0\n\t}\n\n\t/** `scaffold fleet` — audit/repair every `@orkestrel` package beneath the current directory's immediate children. */\n\tasync #fleet(values: CLIValues, json: boolean): Promise<void> {\n\t\tconst root = this.#contain('.', json)\n\n\t\tconst packages = discoverPackages(root)\n\t\tif (packages.length === 0) {\n\t\t\tthis.#fail(\n\t\t\t\t`no @orkestrel packages under \"${root}\" — fleet scans the immediate children of the current directory; stand in the folder that contains your checkouts (cd ..), or use 'repair' to true up just this repo.`,\n\t\t\t\tjson,\n\t\t\t)\n\t\t}\n\n\t\tconst from = values.from?.[0]\n\t\tconst host = from ?? hostRoot()\n\n\t\tconst repos: FleetRepo[] = []\n\t\tconst failures: FleetFailure[] = []\n\t\tfor (const directory of packages) {\n\t\t\tconst name = basename(directory)\n\t\t\ttry {\n\t\t\t\tconst compiler = createCompiler()\n\t\t\t\tlet scoped: Plan\n\t\t\t\ttry {\n\t\t\t\t\tconst spec = deriveBlueprint(directory)\n\t\t\t\t\tconst scaffolding = compiler.compile(spec)\n\t\t\t\t\tif (!scaffolding.plan) {\n\t\t\t\t\t\tconst message = scaffolding.questions.map((question) => question.text).join('; ')\n\t\t\t\t\t\tthrow new ScaffoldError('INVALID', message)\n\t\t\t\t\t}\n\t\t\t\t\tscoped = {\n\t\t\t\t\t\t...scaffolding.plan,\n\t\t\t\t\t\tartifacts: scaffolding.plan.artifacts.filter((artifact) => artifact.origin === 'host'),\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tcompiler.destroy()\n\t\t\t\t}\n\n\t\t\t\tconst plan = hydratePlan(scoped, host)\n\t\t\t\tconst paths = plan.artifacts.map((artifact) => artifact.path)\n\t\t\t\tconst rawAudit = diffPlan(plan, readTarget(directory, paths))\n\t\t\t\t// Include physical unexpected-file findings in each repository audit.\n\t\t\t\tconst audit = this.#scan(rawAudit, directory, host)\n\t\t\t\trepos.push({ name, directory, plan, audit })\n\t\t\t} catch (error) {\n\t\t\t\tfailures.push({ name, message: describeError(error) })\n\t\t\t}\n\t\t}\n\n\t\tif (!json) {\n\t\t\tfor (const repo of repos) {\n\t\t\t\tthis.#reporter.line(\n\t\t\t\t\tfleetRepoLine(\n\t\t\t\t\t\trepo.name,\n\t\t\t\t\t\trepo.audit.clean\n\t\t\t\t\t\t\t? { state: 'clean' }\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tstate: 'drifted',\n\t\t\t\t\t\t\t\t\tdrifted: repo.audit.drifted,\n\t\t\t\t\t\t\t\t\tmissing: repo.audit.missing,\n\t\t\t\t\t\t\t\t\tforeign: repo.audit.foreign,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t}\n\t\t\tfor (const failure of failures) {\n\t\t\t\tthis.#reporter.line(\n\t\t\t\t\tfleetRepoLine(failure.name, { state: 'failed', message: failure.message }),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tconst dirty = repos.filter((repo) => !repo.audit.clean)\n\n\t\tif (dirty.length === 0) {\n\t\t\tif (json) {\n\t\t\t\tthis.#write([\n\t\t\t\t\t...repos.map((repo) => fleetEntryOf(repo.name, repo.audit, false)),\n\t\t\t\t\t...failures.map((failure) => fleetEntryOf(failure.name, undefined, true)),\n\t\t\t\t])\n\t\t\t} else {\n\t\t\t\tthis.#reporter.line(fleetTotals(0, failures.length))\n\t\t\t}\n\t\t\tprocess.exitCode = failures.length > 0 ? 1 : 0\n\t\t\treturn\n\t\t}\n\n\t\tconst fileCount = dirty.reduce(\n\t\t\t(total, repo) => total + repo.audit.drifted + repo.audit.missing + repo.audit.foreign,\n\t\t\t0,\n\t\t)\n\n\t\tconst terminal = createTerminal()\n\t\tconst proceed = await this.#apply(\n\t\t\tterminal,\n\t\t\tapplyConfirmMessage(fileCount, dirty.length),\n\t\t\tvalues,\n\t\t\tjson,\n\t\t)\n\n\t\t// Drive the fleet prune preview from each repository's physical scan and\n\t\t// prefix every path with its repository name. An unestablished host cannot\n\t\t// define an allowlist, so pruning remains a no-op.\n\t\tconst pruneSets =\n\t\t\tproceed && values.prune\n\t\t\t\t? new Map(\n\t\t\t\t\t\tdirty.map((repo) => {\n\t\t\t\t\t\t\tconst paths = pruneTargets(repo.directory, host)\n\t\t\t\t\t\t\treturn [repo.name, readTarget(repo.directory, paths)]\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t: new Map<string, Snapshot>()\n\t\tconst prunePaths = dirty.flatMap((repo) =>\n\t\t\tObject.keys(pruneSets.get(repo.name) ?? {}).map((path) => `${repo.name}/${path}`),\n\t\t)\n\t\tif (proceed && values.prune && !json) {\n\t\t\tif (prunePaths.length === 0) this.#reporter.line(PRUNE_EMPTY)\n\t\t\telse for (const line of prunePreview(prunePaths)) this.#reporter.line(line)\n\t\t}\n\t\tconst doPrune =\n\t\t\tproceed &&\n\t\t\tprunePaths.length > 0 &&\n\t\t\t(await this.#prune(terminal, pruneConfirmMessage(prunePaths.length), values, json))\n\n\t\tif (!proceed) {\n\t\t\tif (json) {\n\t\t\t\tthis.#write([\n\t\t\t\t\t...repos.map((repo) => fleetEntryOf(repo.name, repo.audit, false)),\n\t\t\t\t\t...failures.map((failure) => fleetEntryOf(failure.name, undefined, true)),\n\t\t\t\t])\n\t\t\t} else {\n\t\t\t\tthis.#reporter.line(fleetTotals(dirty.length, failures.length))\n\t\t\t}\n\t\t\tprocess.exitCode = 1\n\t\t\treturn\n\t\t}\n\n\t\tconst materializer = createMaterializer({ host })\n\t\tlet drifted = 0\n\t\tlet failedCount = failures.length\n\t\tconst entries: FleetEntry[] = repos\n\t\t\t.filter((repo) => repo.audit.clean)\n\t\t\t.map((repo) => fleetEntryOf(repo.name, repo.audit, false))\n\n\t\ttry {\n\t\t\tfor (const repo of dirty) {\n\t\t\t\ttry {\n\t\t\t\t\tmaterializer.repair(repo.plan, repo.audit, repo.directory)\n\t\t\t\t\tif (doPrune) {\n\t\t\t\t\t\tmaterializer.prune(repo.directory, pruneSets.get(repo.name) ?? {})\n\t\t\t\t\t}\n\t\t\t\t\tconst paths = repo.plan.artifacts.map((artifact) => artifact.path)\n\t\t\t\t\tconst rawFinal = diffPlan(repo.plan, readTarget(repo.directory, paths))\n\t\t\t\t\tconst finalAudit = this.#scan(rawFinal, repo.directory, host)\n\t\t\t\t\tif (!finalAudit.clean) drifted += 1\n\t\t\t\t\tentries.push(fleetEntryOf(repo.name, finalAudit, false))\n\t\t\t\t\tif (!json) {\n\t\t\t\t\t\tthis.#reporter.line(\n\t\t\t\t\t\t\tfleetRepoLine(repo.name, {\n\t\t\t\t\t\t\t\tstate: 'repaired',\n\t\t\t\t\t\t\t\tremaining: finalAudit.drifted + finalAudit.missing + finalAudit.foreign,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailedCount += 1\n\t\t\t\t\tentries.push(fleetEntryOf(repo.name, undefined, true))\n\t\t\t\t\tif (!json) {\n\t\t\t\t\t\tthis.#reporter.line(\n\t\t\t\t\t\t\tfleetRepoLine(repo.name, {\n\t\t\t\t\t\t\t\tstate: 'failed',\n\t\t\t\t\t\t\t\tmessage: describeError(error),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\n\t\tif (json) {\n\t\t\tthis.#write([\n\t\t\t\t...entries,\n\t\t\t\t...failures.map((failure) => fleetEntryOf(failure.name, undefined, true)),\n\t\t\t])\n\t\t} else {\n\t\t\tthis.#reporter.line(fleetTotals(drifted, failedCount))\n\t\t}\n\t\tprocess.exitCode = drifted > 0 || failedCount > 0 ? 1 : 0\n\t}\n\n\t/** `scaffold catalog` — regenerate the fleet package catalog table embedded in `.claude/agents/orkestrel.md`. */\n\tasync #catalog(values: CLIValues, json: boolean): Promise<void> {\n\t\tconst target = this.#contain(values.target ?? '.', json)\n\n\t\tconst explicitRoots = values.from\n\t\tlet entries: readonly CatalogEntry[]\n\t\tlet published = 0\n\t\tlet localOnly = 0\n\t\tconst notes = new Map<string, string>()\n\n\t\tif (values.offline) {\n\t\t\tconst roots = explicitRoots ?? [process.cwd()]\n\t\t\ttry {\n\t\t\t\tentries = catalogPackages(roots)\n\t\t\t} catch (error) {\n\t\t\t\tthis.#error(error, json)\n\t\t\t}\n\t\t} else {\n\t\t\tconst sync = createSync()\n\t\t\tsync.emitter.on('package', (name, note) => {\n\t\t\t\tif (note !== '') notes.set(name, note)\n\t\t\t})\n\t\t\tlet registryEntries: readonly CatalogEntry[]\n\t\t\ttry {\n\t\t\t\tregistryEntries = await sync.catalog()\n\t\t\t} catch (error) {\n\t\t\t\tthis.#error(error, json)\n\t\t\t} finally {\n\t\t\t\tsync.destroy()\n\t\t\t}\n\t\t\tpublished = registryEntries.length\n\n\t\t\tlet localEntries: readonly CatalogEntry[] = []\n\t\t\tif (explicitRoots !== undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tlocalEntries = catalogPackages(explicitRoots)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.#error(error, json)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst merged = new Map<string, CatalogEntry>()\n\t\t\tfor (const entry of registryEntries) merged.set(entry.name, entry)\n\t\t\tfor (const local of localEntries) {\n\t\t\t\tconst existing = merged.get(local.name)\n\t\t\t\tif (existing === undefined) {\n\t\t\t\t\tmerged.set(local.name, local)\n\t\t\t\t\tlocalOnly += 1\n\t\t\t\t} else if (local.description.length > 0) {\n\t\t\t\t\tmerged.set(local.name, { ...existing, description: local.description })\n\t\t\t\t}\n\t\t\t}\n\t\t\tentries = [...merged.values()].sort((a, b) =>\n\t\t\t\ta.name < b.name ? -1 : a.name > b.name ? 1 : 0,\n\t\t\t)\n\t\t}\n\n\t\tconst block = catalogToBlock(entries)\n\t\t// Re-confine the exact leaf because a linked segment beneath an otherwise\n\t\t// contained target could redirect this write outside the working directory.\n\t\tconst agentPath = this.#contain(join(target, CATALOG_AGENT_PATH), json)\n\t\tlet current: string\n\t\tlet baseline: string\n\t\ttry {\n\t\t\tcurrent = readFileText(target, CATALOG_AGENT_PATH, 'TARGET', 'target')\n\t\t\tbaseline = digestText(current)\n\t\t} catch (error) {\n\t\t\tthis.#error(\n\t\t\t\tnew ScaffoldError('TARGET', `Failed to read ${agentPath}`, { path: agentPath, error }),\n\t\t\t\tjson,\n\t\t\t)\n\t\t}\n\n\t\tconst startIndex = current.indexOf(CATALOG_START_MARKER)\n\t\tconst endIndex = current.indexOf(CATALOG_END_MARKER)\n\t\tconst startParts = current.split(CATALOG_START_MARKER)\n\t\tconst endParts = current.split(CATALOG_END_MARKER)\n\t\tif (\n\t\t\tstartIndex === -1 ||\n\t\t\tendIndex === -1 ||\n\t\t\tendIndex < startIndex ||\n\t\t\tstartParts.length !== 2 ||\n\t\t\tendParts.length !== 2\n\t\t) {\n\t\t\tthis.#error(\n\t\t\t\tnew ScaffoldError(\n\t\t\t\t\t'TARGET',\n\t\t\t\t\t`Expected exactly one ordered \"${CATALOG_START_MARKER}\" / \"${CATALOG_END_MARKER}\" pair in ${agentPath}`,\n\t\t\t\t\t{ path: agentPath },\n\t\t\t\t),\n\t\t\t\tjson,\n\t\t\t)\n\t\t}\n\n\t\tconst before = current.slice(0, startIndex + CATALOG_START_MARKER.length)\n\t\tconst after = current.slice(endIndex)\n\t\tconst updated = `${before}\\n\\n${block}\\n${after}`\n\n\t\tconst oldBlock = current.slice(startIndex + CATALOG_START_MARKER.length, endIndex)\n\t\tconst oldRows = catalogNames(oldBlock).length\n\t\tconst shrink = entries.length < oldRows ? oldRows - entries.length : undefined\n\n\t\tif (updated === current) {\n\t\t\tif (json) this.#write(catalogResultOf(entries, false))\n\t\t\telse this.#reporter.line(catalogVerdict(true))\n\t\t\tprocess.exitCode = 0\n\t\t\treturn\n\t\t}\n\n\t\tif (!json) {\n\t\t\tthis.#reporter.table(catalogTable(entries))\n\t\t\tconst warning = catalogShrinkWarning(oldRows, entries.length)\n\t\t\tif (warning !== undefined) this.#reporter.line(warning)\n\t\t\tif (values.offline) {\n\t\t\t\tconst missingDescription = entries\n\t\t\t\t\t.filter((entry) => entry.description.length === 0)\n\t\t\t\t\t.map((entry) => entry.name)\n\t\t\t\tif (missingDescription.length > 0) {\n\t\t\t\t\tthis.#reporter.line(\n\t\t\t\t\t\t`${missingDescription.length} without guide description: ${missingDescription.join(', ')}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.#reporter.line(catalogCounts(published, localOnly))\n\t\t\t\tfor (const [name, note] of notes) this.#reporter.line(` ${name}: ${note}`)\n\t\t\t}\n\t\t}\n\n\t\tconst terminal = createTerminal()\n\t\tconst proceed = await this.#apply(terminal, applyConfirmMessage(1), values, json)\n\n\t\tif (!proceed) {\n\t\t\tif (json) this.#write(catalogResultOf(entries, true, shrink))\n\t\t\telse this.#reporter.line(catalogVerdict(false))\n\t\t\tprocess.exitCode = 1\n\t\t\treturn\n\t\t}\n\n\t\tif (Buffer.byteLength(updated, 'utf8') > MAX_ARTIFACT_BYTES) {\n\t\t\tthis.#error(\n\t\t\t\tnew ScaffoldError('WRITE', `Catalog exceeds the artifact limit at ${agentPath}`, {\n\t\t\t\t\tpath: agentPath,\n\t\t\t\t\tlimit: MAX_ARTIFACT_BYTES,\n\t\t\t\t}),\n\t\t\t\tjson,\n\t\t\t)\n\t\t}\n\t\tconst transaction = WriteTransaction.create(\n\t\t\ttarget,\n\t\t\t[CATALOG_AGENT_PATH],\n\t\t\t[{ path: CATALOG_AGENT_PATH, shape: 'file', digest: baseline }],\n\t\t)\n\t\tconst staged = attempt(() => {\n\t\t\tvalidateWriteDirectories(transaction)\n\t\t\tconst destination = resolvePhysicalPath(\n\t\t\t\ttransaction.stage,\n\t\t\t\tCATALOG_AGENT_PATH,\n\t\t\t\t'WRITE',\n\t\t\t\t'staging',\n\t\t\t)\n\t\t\tmkdirSync(dirname(destination), { recursive: true })\n\t\t\tvalidateWriteDirectories(transaction)\n\t\t\tconst contained = resolvePhysicalPath(\n\t\t\t\ttransaction.stage,\n\t\t\t\tCATALOG_AGENT_PATH,\n\t\t\t\t'WRITE',\n\t\t\t\t'staging',\n\t\t\t)\n\t\t\twriteFileSync(contained, updated, { encoding: 'utf8', flag: 'wx' })\n\t\t\tif (digestFile(contained) !== digestText(updated)) {\n\t\t\t\tthrow new ScaffoldError('WRITE', `Staged catalog changed at ${agentPath}`, {\n\t\t\t\t\tpath: agentPath,\n\t\t\t\t})\n\t\t\t}\n\t\t\tvalidateWriteDirectories(transaction)\n\t\t})\n\t\tif (!staged.success) {\n\t\t\tconst cleanup = attempt(() => discardWriteTransaction(transaction))\n\t\t\tthis.#error(\n\t\t\t\tnew ScaffoldError('WRITE', `Failed to stage ${agentPath}`, {\n\t\t\t\t\tpath: agentPath,\n\t\t\t\t\terror: staged.error,\n\t\t\t\t\tcleanup: cleanup.success ? undefined : cleanup.error,\n\t\t\t\t}),\n\t\t\t\tjson,\n\t\t\t)\n\t\t}\n\t\tconst committed = attempt(() => commitWriteTransaction(transaction, [CATALOG_AGENT_PATH]))\n\t\tif (!committed.success) this.#error(committed.error, json)\n\t\tif (json) this.#write(catalogResultOf(entries, true, shrink))\n\t\telse this.#reporter.status('success', catalogApplySuccess(agentPath))\n\t\tprocess.exitCode = 0\n\t}\n\n\t/**\n\t * The whole command dispatch — a single top-level driver (no nested function\n\t * declarations, AGENTS §4). Every verb sets `process.exitCode` (never\n\t * `process.exit`) and returns, or `halt()`s through a `finally` that\n\t * tears its entities down first; the caller at the bottom of this file\n\t * catches exactly one sentinel (`CliExit`) and stops.\n\t */\n\tasync #dispatch(argv: readonly string[]): Promise<void> {\n\t\tlet parsed: CLIArguments\n\t\ttry {\n\t\t\tparsed = parseArguments(argv)\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(\n\t\t\t\t`${error instanceof Error ? error.message : INVALID_ARGUMENTS_MESSAGE}\\n`,\n\t\t\t)\n\t\t\tprocess.exitCode = 2\n\t\t\treturn\n\t\t}\n\n\t\tconst { values, positionals } = parsed\n\t\tconst [command, argument] = positionals\n\t\tconst json = values.json === true\n\t\tthis.#json = json\n\n\t\tif (command === undefined) {\n\t\t\tprocess.stdout.write(`${values.help ? fullHelp() : shortUsage()}\\n`)\n\t\t\tprocess.exitCode = 0\n\t\t\treturn\n\t\t}\n\n\t\tif (!isVerb(command)) {\n\t\t\tthis.#usage(didYouMean(command), json)\n\t\t}\n\n\t\tif (command !== 'catalog' && values.from !== undefined && values.from.length > 1) {\n\t\t\tthis.#usage(`--from may be provided only once for '${command}'`, json)\n\t\t}\n\n\t\tif (values.help) {\n\t\t\tprocess.stdout.write(`${verbHelp(command)}\\n`)\n\t\t\tprocess.exitCode = 0\n\t\t\treturn\n\t\t}\n\n\t\tif (command === 'new') return this.#new(values, argument, json)\n\t\tif (command === 'pull') return this.#pull(values, json)\n\t\tif (command === 'audit') return this.#audit(values, json)\n\t\tif (command === 'repair') return this.#repair(values, json)\n\t\tif (command === 'fleet') return this.#fleet(values, json)\n\t\treturn this.#catalog(values, json)\n\t}\n}\n","// The `#!/usr/bin/env node` shebang is re-emitted by the build's `output.banner`, not source.\nimport { CLI } from './CLI.js'\n\nawait new CLI().run(process.argv.slice(2))\n"],"mappings":";;;;;;;;;;;;;;AAKA,IAAa,cAA+B,OAAO,OAAO;CACzD;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,IAAa,eAAiD,OAAO,OAAO;CAC3E,MAAM;CACN,UAAU;CACV,UAAU;AACX,CAAC;;AAGD,IAAa,cAA+C,OAAO,OAAO;CACzE,SAAS;CACT,OAAO;CACP,SAAS;CACT,SAAS;AACV,CAAC;;AAGD,IAAa,kBAAoD,OAAO,OAAO;CAC9E,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;AACT,CAAC;;AAGD,IAAa,eAAiD,OAAO,O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