@orkestrel/scaffold 0.0.11 → 0.0.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold.js","names":["#sync","#tty","#sink","#styler","#trust","#dispatch","#json","#write","#reporter","#error","#fail","#prunePaths","#scan","#compile","#guard","#apply","#prune","#prompt","#new","#usage","#contain","#names","#spinner","#succeed","#reject","#pull","#audit","#scanSafe","#repair","#prepareRepair","#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/** Repair's opt-in generated-canon ownership boundary. */\nexport const REPAIR_GENERATED_SCOPE =\n\t'repair scope: shared host-owned and generated artifacts — starter files and package.json 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 host-owned files, plus generated canon with --generated',\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 --generated --from <path> --groups a,b',\n\trepair: '--target . --generated --apply --yes --prune --from <path>',\n\tfleet: '--generated --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['--generated', 'include generated canon if the repair hand-off is accepted'],\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['--generated', 'also restore generated canon except package.json'],\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['--generated', 'also restore generated canon except package.json in every package'],\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/**\n * Render drift outside repair's selected ownership boundary.\n *\n * @param count - The number of findings outside the selected scope.\n * @param generated - Whether generated canon was included in the repair scope.\n * @returns The scope guidance line, or `undefined` when no findings remain outside scope.\n */\nexport function scopeNote(count: number, generated: boolean): string | undefined {\n\tif (count === 0) return undefined\n\treturn generated\n\t\t? `note: ${countPart(count, 'finding')} outside host-owned and generated repair scope — run 'audit' for the list; starter files and package.json remain protected`\n\t\t: `note: ${countPart(count, 'finding')} outside host-owned repair scope — run 'audit' for the list`\n}\n\n/**\n * Render repair's dry-run verdict.\n *\n * @param audit - The audit over the selected repair plan.\n * @param generated - Whether generated canon was included in the repair scope.\n * @returns The scope-aware clean or drifted verdict.\n */\nexport function repairVerdict(audit: Audit, generated: boolean): string {\n\tconst scope = generated ? 'host-owned and generated' : 'host-owned'\n\tif (audit.clean) {\n\t\treturn `repair: ${countPart(audit.findings.length, `${scope} artifact`)} aligned — nothing to write`\n\t}\n\treturn `repair: ${scope}: ${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; run 'scaffold repair --generated' to restore them`\n}\n\n/**\n * Render honest repair guidance for computed and protected manifest drift.\n *\n * @param findings - The audit findings to classify.\n * @param plan - The plan that owns each computed artifact.\n * @returns One line for repairable computed drift and one for protected manifest drift when present.\n */\nexport function renderComputedNotes(findings: readonly Finding[], plan: Plan): readonly string[] {\n\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\tlet computed = 0\n\tlet manifest = 0\n\tfor (const finding of findings) {\n\t\tif (finding.drift === 'aligned' || origins.get(finding.path) !== 'computed') continue\n\t\tif (finding.path === 'package.json') manifest += 1\n\t\telse computed += 1\n\t}\n\tconst notes: string[] = []\n\tif (computed > 0) notes.push(generatedNote(computed))\n\tif (manifest > 0) {\n\t\tnotes.push(\n\t\t\t`${countPart(manifest, 'finding')} in package.json — repair does not rewrite protected publication metadata; review and edit it directly`,\n\t\t)\n\t}\n\treturn notes\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\tgenerated: { 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\tQuestion,\n\tSnapshot,\n\tSyncReport,\n} from '@src/core'\nimport type { SyncOptions } from '@src/server'\nimport {\n\tblueprint,\n\tcatalogNames,\n\tcatalogToBlock,\n\tcreateCompiler,\n\tdependency,\n\tDEPENDENCY_NAME_PATTERN,\n\tdiffPlan,\n\tGROUPS,\n\tisScaffoldError,\n\tmanifestToDependencies,\n\tmanifestToName,\n\tMAX_ARTIFACT_BYTES,\n\tNAME_PATTERN,\n\tplanToSummary,\n\tScaffoldError,\n\tSERVICE_SCRIPT_PATH,\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\tparseSyncOptions,\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_GENERATED_SCOPE,\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\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\trenderComputedNotes,\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\treadonly #sync: SyncOptions\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/**\n\t * Create command-line orchestration with optional upstream endpoint settings.\n\t *\n\t * @param sync - Sync settings used by every live dependency operation.\n\t */\n\tconstructor(sync?: SyncOptions) {\n\t\tthis.#sync = parseSyncOptions(sync)\n\t}\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(\n\t\tspec: Blueprint,\n\t\tjson: boolean,\n\t\tgroups?: readonly Group[],\n\t): readonly [plan: Plan, questions: readonly Question[]] {\n\t\tconst compiler = createCompiler()\n\t\ttry {\n\t\t\tconst scaffolding = compiler.compile(spec, groups)\n\t\t\tif (!scaffolding.plan) {\n\t\t\t\tconst blocking = scaffolding.questions.filter((question) => question.blocking)\n\t\t\t\tconst message = (blocking.length > 0 ? blocking : scaffolding.questions)\n\t\t\t\t\t.map((question) => question.text)\n\t\t\t\t\t.join('; ')\n\t\t\t\tthis.#fail(message, json)\n\t\t\t}\n\t\t\treturn [scaffolding.plan, scaffolding.questions]\n\t\t} finally {\n\t\t\tcompiler.destroy()\n\t\t}\n\t}\n\n\t// Exclude the consumer-owned service provisioner from every physical scan.\n\t#prunePaths(target: string, host: string, service: boolean): readonly string[] {\n\t\tconst seam = service ? SERVICE_SCRIPT_PATH : undefined\n\t\treturn pruneTargets(target, host).filter((path) => path !== seam)\n\t}\n\n\t/**\n\t * Merge the physical prune 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 except the declared service\n\t * workspace's exact `SERVICE_SCRIPT_PATH` becomes one `'orchestration'`-group\n\t * `foreign` finding (the `Group` every `PRUNE_DIRECTORIES` entry—`.claude/agents`,\n\t * `.codex/agents`, `scripts`—belongs to); any scan hit makes the merged audit\n\t * unclean, so an \"unexpected file\" is honestly counted as drift (exit 1)\n\t * instead of the structurally-always-zero `diffPlan.foreign`.\n\t */\n\t#scan(audit: Audit, target: string, host: string, service: boolean): Audit {\n\t\tconst paths = this.#prunePaths(target, host, service)\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, service: boolean): ForeignScanResult {\n\t\tconst scanned = attempt(() => this.#scan(audit, target, host, service))\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` scopes to host-owned artifacts by default and optionally generated canon, but the\n\t * caller compiles the full plan anyway. Diff it too so a clean scoped verdict can point at drift\n\t * outside the selected boundary. 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/** Compile and audit the selected repair ownership boundary for one structural snapshot. */\n\t#prepareRepair(\n\t\tspec: Blueprint,\n\t\ttarget: string,\n\t\thost: string,\n\t\tgenerated: boolean,\n\t\tjson: boolean,\n\t): readonly [compiled: Plan, plan: Plan, audit: Audit] {\n\t\tconst [compiled] = this.#compile(spec, json)\n\t\tconst scoped: Plan = {\n\t\t\t...compiled,\n\t\t\tblueprint: { ...compiled.blueprint, overrides: [] },\n\t\t\tartifacts: compiled.artifacts.filter(\n\t\t\t\t(artifact) =>\n\t\t\t\t\tartifact.origin === 'host' ||\n\t\t\t\t\t(generated && artifact.origin === 'computed' && artifact.path !== 'package.json'),\n\t\t\t),\n\t\t}\n\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\ttry {\n\t\t\tconst audit = 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\treturn [compiled, plan, audit]\n\t\t} catch (error) {\n\t\t\tthis.#error(error, json)\n\t\t}\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(this.#sync)\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(\n\t\t\tvalues.strict === undefined ? this.#sync : { ...this.#sync, strict: values.strict },\n\t\t)\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, questions] = this.#compile(spec, json, 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 = {\n\t\t\t...diffPlan(plan, readTarget(target, artifactPaths)),\n\t\t\tquestions,\n\t\t}\n\t\tconst scanned = this.#scanSafe(rawAudit, target, host, spec.service)\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(this.#sync)\n\t\t\ttry {\n\t\t\t\tconst manifestName = manifestToName(readManifest(target))\n\t\t\t\tconst guideDependencies = deps.filter((entry) => entry.name !== manifestName)\n\t\t\t\tconst guides = await sync.guides(guideDependencies)\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\tfor (const question of audit.questions) {\n\t\t\tif (!question.blocking) this.#reporter.line(`warning: ${question.text}`)\n\t\t}\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 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, spec.service)\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\tfor (const note of renderComputedNotes(audit.findings, plan)) {\n\t\t\t\t\tthis.#reporter.line(note)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprocess.exitCode = drifted ? 1 : 0\n\t}\n\n\t/** `scaffold repair` — restore host-owned files and optionally generated canon 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\t// Repair defaults to the host-restoration boundary. `--generated` adds\n\t\t// generated canon while preserving the birth-only template boundary and\n\t\t// package.json's independent publication protection.\n\t\tconst generated = values.generated === true\n\t\tconst from = values.from?.[0]\n\t\tconst host = from ?? hostRoot()\n\t\tconst prepared = this.#prepareRepair(spec, target, host, generated, json)\n\t\tconst compiled = prepared[0]\n\t\tlet plan = prepared[1]\n\t\tlet audit = prepared[2]\n\n\t\tif (!json) {\n\t\t\tthis.#reporter.line(generated ? REPAIR_GENERATED_SCOPE : 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 ? this.#prunePaths(target, host, spec.service) : []\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, generated))\n\t\t\t\tconst note = scopeNote(this.#outside(compiled, target), generated)\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, generated))\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\tlet currentGlobal: boolean\n\t\ttry {\n\t\t\tcurrentGlobal = deriveBlueprint(target).global\n\t\t} catch (error) {\n\t\t\tthis.#error(error, json)\n\t\t}\n\t\tif (currentGlobal !== spec.global) {\n\t\t\tspec = { ...spec, global: currentGlobal }\n\t\t\tconst refreshed = this.#prepareRepair(spec, target, host, generated, json)\n\t\t\tplan = refreshed[1]\n\t\t\taudit = refreshed[2]\n\t\t}\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\t\tconst generated = values.generated === true\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\tlet questions: readonly Question[]\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\tblueprint: { ...scaffolding.plan.blueprint, overrides: [] },\n\t\t\t\t\t\tartifacts: scaffolding.plan.artifacts.filter(\n\t\t\t\t\t\t\t(artifact) =>\n\t\t\t\t\t\t\t\tartifact.origin === 'host' ||\n\t\t\t\t\t\t\t\t(generated && artifact.origin === 'computed' && artifact.path !== 'package.json'),\n\t\t\t\t\t\t),\n\t\t\t\t\t}\n\t\t\t\t\tquestions = scaffolding.questions\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 = {\n\t\t\t\t\t...diffPlan(plan, readTarget(directory, paths)),\n\t\t\t\t\tquestions,\n\t\t\t\t}\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, plan.blueprint.service)\n\t\t\t\trepos.push({\n\t\t\t\t\tname,\n\t\t\t\t\tdirectory,\n\t\t\t\t\tplan,\n\t\t\t\t\taudit,\n\t\t\t\t})\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\tfor (const question of repo.audit.questions) {\n\t\t\t\t\tif (!question.blocking) {\n\t\t\t\t\t\tthis.#reporter.line(`${repo.name}: warning: ${question.text}`)\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 = this.#prunePaths(repo.directory, host, repo.plan.blueprint.service)\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, repo.plan.blueprint.service)\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(this.#sync)\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,OAAO;CAC3E,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;AACV,CAAC;;AA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AAW;GACnB;EACD;EAEA,IAAI,YAAY,OAAO,OAAO,KAAKD,KAAK,QAAQ,UAAU,IAAI;EAC9D,IAAI,YAAY,QAAQ,OAAO,KAAKO,MAAM,QAAQ,IAAI;EACtD,IAAI,YAAY,SAAS,OAAO,KAAKC,OAAO,QAAQ,IAAI;EACxD,IAAI,YAAY,UAAU,OAAO,KAAKE,QAAQ,QAAQ,IAAI;EAC1D,IAAI,YAAY,SAAS,OAAO,KAAKG,OAAO,QAAQ,IAAI;EACxD,OAAO,KAAKC,SAAS,QAAQ,IAAI;CAClC;AACD;;;ACr7CA,MAAM,IAAI,IAAI,CAAC,CAAC,IAAI,QAAQ,KAAK,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"scaffold.js","names":["#sync","#tty","#sink","#styler","#trust","#dispatch","#json","#write","#reporter","#error","#fail","#prunePaths","#scan","#compile","#guard","#apply","#prune","#prompt","#new","#usage","#contain","#names","#spinner","#succeed","#reject","#pull","#audit","#scanSafe","#repair","#prepareRepair","#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/** Repair's opt-in generated-canon ownership boundary. */\nexport const REPAIR_GENERATED_SCOPE =\n\t'repair scope: shared host-owned and generated artifacts — starter files and package.json 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 host-owned files, plus generated canon with --generated',\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 --generated --from <path> --groups a,b',\n\trepair: '--target . --generated --apply --yes --prune --from <path>',\n\tfleet: '--generated --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['--generated', 'include generated canon if the repair hand-off is accepted'],\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['--generated', 'also restore generated canon except package.json'],\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['--generated', 'also restore generated canon except package.json in every package'],\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/**\n * Render drift outside repair's selected ownership boundary.\n *\n * @param count - The number of findings outside the selected scope.\n * @param generated - Whether generated canon was included in the repair scope.\n * @returns The scope guidance line, or `undefined` when no findings remain outside scope.\n */\nexport function scopeNote(count: number, generated: boolean): string | undefined {\n\tif (count === 0) return undefined\n\treturn generated\n\t\t? `note: ${countPart(count, 'finding')} outside host-owned and generated repair scope — run 'audit' for the list; starter files and package.json remain protected`\n\t\t: `note: ${countPart(count, 'finding')} outside host-owned repair scope — run 'audit' for the list`\n}\n\n/**\n * Render repair's dry-run verdict.\n *\n * @param audit - The audit over the selected repair plan.\n * @param generated - Whether generated canon was included in the repair scope.\n * @returns The scope-aware clean or drifted verdict.\n */\nexport function repairVerdict(audit: Audit, generated: boolean): string {\n\tconst scope = generated ? 'host-owned and generated' : 'host-owned'\n\tif (audit.clean) {\n\t\treturn `repair: ${countPart(audit.findings.length, `${scope} artifact`)} aligned — nothing to write`\n\t}\n\treturn `repair: ${scope}: ${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; run 'scaffold repair --generated' to restore them`\n}\n\n/**\n * Render honest repair guidance for computed and protected manifest drift.\n *\n * @param findings - The audit findings to classify.\n * @param plan - The plan that owns each computed artifact.\n * @returns One line for repairable computed drift and one for protected manifest drift when present.\n */\nexport function renderComputedNotes(findings: readonly Finding[], plan: Plan): readonly string[] {\n\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\tlet computed = 0\n\tlet manifest = 0\n\tfor (const finding of findings) {\n\t\tif (finding.drift === 'aligned' || origins.get(finding.path) !== 'computed') continue\n\t\tif (finding.path === 'package.json') manifest += 1\n\t\telse computed += 1\n\t}\n\tconst notes: string[] = []\n\tif (computed > 0) notes.push(generatedNote(computed))\n\tif (manifest > 0) {\n\t\tnotes.push(\n\t\t\t`${countPart(manifest, 'finding')} in package.json — repair does not rewrite protected publication metadata; review and edit it directly`,\n\t\t)\n\t}\n\treturn notes\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\tgenerated: { 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\tQuestion,\n\tSnapshot,\n\tSyncReport,\n} from '@src/core'\nimport type { SyncOptions } from '@src/server'\nimport {\n\tblueprint,\n\tcatalogNames,\n\tcatalogToBlock,\n\tcreateCompiler,\n\tdependency,\n\tDEPENDENCY_NAME_PATTERN,\n\tdiffPlan,\n\tGROUPS,\n\tisScaffoldError,\n\tmanifestToDependencies,\n\tmanifestToName,\n\tMAX_ARTIFACT_BYTES,\n\tNAME_PATTERN,\n\tplanToSummary,\n\tScaffoldError,\n\tSERVICE_SCRIPT_PATH,\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\tparseSyncOptions,\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_GENERATED_SCOPE,\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\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\trenderComputedNotes,\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\treadonly #sync: SyncOptions\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/**\n\t * Create command-line orchestration with optional upstream endpoint settings.\n\t *\n\t * @param sync - Sync settings used by every live dependency operation.\n\t */\n\tconstructor(sync?: SyncOptions) {\n\t\tthis.#sync = parseSyncOptions(sync)\n\t}\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(\n\t\tspec: Blueprint,\n\t\tjson: boolean,\n\t\tgroups?: readonly Group[],\n\t): readonly [plan: Plan, questions: readonly Question[]] {\n\t\tconst compiler = createCompiler()\n\t\ttry {\n\t\t\tconst scaffolding = compiler.compile(spec, groups)\n\t\t\tif (!scaffolding.plan) {\n\t\t\t\tconst blocking = scaffolding.questions.filter((question) => question.blocking)\n\t\t\t\tconst message = (blocking.length > 0 ? blocking : scaffolding.questions)\n\t\t\t\t\t.map((question) => question.text)\n\t\t\t\t\t.join('; ')\n\t\t\t\tthis.#fail(message, json)\n\t\t\t}\n\t\t\treturn [scaffolding.plan, scaffolding.questions]\n\t\t} finally {\n\t\t\tcompiler.destroy()\n\t\t}\n\t}\n\n\t// Exclude the consumer-owned service provisioner from every physical scan.\n\t#prunePaths(target: string, host: string, service: boolean): readonly string[] {\n\t\tconst seam = service ? SERVICE_SCRIPT_PATH : undefined\n\t\treturn pruneTargets(target, host).filter((path) => path !== seam)\n\t}\n\n\t/**\n\t * Merge the physical prune 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 except the declared service\n\t * workspace's exact `SERVICE_SCRIPT_PATH` becomes one `'orchestration'`-group\n\t * `foreign` finding (the `Group` every `PRUNE_DIRECTORIES` entry—`.claude/agents`,\n\t * `.codex/agents`, `scripts`—belongs to); any scan hit makes the merged audit\n\t * unclean, so an \"unexpected file\" is honestly counted as drift (exit 1)\n\t * instead of the structurally-always-zero `diffPlan.foreign`.\n\t */\n\t#scan(audit: Audit, target: string, host: string, service: boolean): Audit {\n\t\tconst paths = this.#prunePaths(target, host, service)\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, service: boolean): ForeignScanResult {\n\t\tconst scanned = attempt(() => this.#scan(audit, target, host, service))\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` scopes to host-owned artifacts by default and optionally generated canon, but the\n\t * caller compiles the full plan anyway. Diff it too so a clean scoped verdict can point at drift\n\t * outside the selected boundary. 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/** Compile and audit the selected repair ownership boundary for one structural snapshot. */\n\t#prepareRepair(\n\t\tspec: Blueprint,\n\t\ttarget: string,\n\t\thost: string,\n\t\tgenerated: boolean,\n\t\tjson: boolean,\n\t): readonly [compiled: Plan, plan: Plan, audit: Audit] {\n\t\tconst [compiled] = this.#compile(spec, json)\n\t\tconst scoped: Plan = {\n\t\t\t...compiled,\n\t\t\tblueprint: { ...compiled.blueprint, overrides: [] },\n\t\t\tartifacts: compiled.artifacts.filter(\n\t\t\t\t(artifact) =>\n\t\t\t\t\tartifact.origin === 'host' ||\n\t\t\t\t\t(generated && artifact.origin === 'computed' && artifact.path !== 'package.json'),\n\t\t\t),\n\t\t}\n\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\ttry {\n\t\t\tconst audit = 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\treturn [compiled, plan, audit]\n\t\t} catch (error) {\n\t\t\tthis.#error(error, json)\n\t\t}\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(this.#sync)\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(\n\t\t\tvalues.strict === undefined ? this.#sync : { ...this.#sync, strict: values.strict },\n\t\t)\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, questions] = this.#compile(spec, json, 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 = {\n\t\t\t...diffPlan(plan, readTarget(target, artifactPaths)),\n\t\t\tquestions,\n\t\t}\n\t\tconst scanned = this.#scanSafe(rawAudit, target, host, spec.service)\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(this.#sync)\n\t\t\ttry {\n\t\t\t\tconst manifestName = manifestToName(readManifest(target))\n\t\t\t\tconst guideDependencies = deps.filter((entry) => entry.name !== manifestName)\n\t\t\t\tconst guides = await sync.guides(guideDependencies)\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\tfor (const question of audit.questions) {\n\t\t\tif (!question.blocking) this.#reporter.line(`warning: ${question.text}`)\n\t\t}\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 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, spec.service)\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\tfor (const note of renderComputedNotes(audit.findings, plan)) {\n\t\t\t\t\tthis.#reporter.line(note)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprocess.exitCode = drifted ? 1 : 0\n\t}\n\n\t/** `scaffold repair` — restore host-owned files and optionally generated canon 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\t// Repair defaults to the host-restoration boundary. `--generated` adds\n\t\t// generated canon while preserving the birth-only template boundary and\n\t\t// package.json's independent publication protection.\n\t\tconst generated = values.generated === true\n\t\tconst from = values.from?.[0]\n\t\tconst host = from ?? hostRoot()\n\t\tconst prepared = this.#prepareRepair(spec, target, host, generated, json)\n\t\tconst compiled = prepared[0]\n\t\tlet plan = prepared[1]\n\t\tlet audit = prepared[2]\n\n\t\tif (!json) {\n\t\t\tthis.#reporter.line(generated ? REPAIR_GENERATED_SCOPE : 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 ? this.#prunePaths(target, host, spec.service) : []\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, generated))\n\t\t\t\tconst note = scopeNote(this.#outside(compiled, target), generated)\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, generated))\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\tlet currentGlobal: boolean\n\t\ttry {\n\t\t\tcurrentGlobal = deriveBlueprint(target).global\n\t\t} catch (error) {\n\t\t\tthis.#error(error, json)\n\t\t}\n\t\tif (currentGlobal !== spec.global) {\n\t\t\tspec = { ...spec, global: currentGlobal }\n\t\t\tconst refreshed = this.#prepareRepair(spec, target, host, generated, json)\n\t\t\tplan = refreshed[1]\n\t\t\taudit = refreshed[2]\n\t\t}\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\t\tconst generated = values.generated === true\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\tlet questions: readonly Question[]\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\tblueprint: { ...scaffolding.plan.blueprint, overrides: [] },\n\t\t\t\t\t\tartifacts: scaffolding.plan.artifacts.filter(\n\t\t\t\t\t\t\t(artifact) =>\n\t\t\t\t\t\t\t\tartifact.origin === 'host' ||\n\t\t\t\t\t\t\t\t(generated && artifact.origin === 'computed' && artifact.path !== 'package.json'),\n\t\t\t\t\t\t),\n\t\t\t\t\t}\n\t\t\t\t\tquestions = scaffolding.questions\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 = {\n\t\t\t\t\t...diffPlan(plan, readTarget(directory, paths)),\n\t\t\t\t\tquestions,\n\t\t\t\t}\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, plan.blueprint.service)\n\t\t\t\trepos.push({\n\t\t\t\t\tname,\n\t\t\t\t\tdirectory,\n\t\t\t\t\tplan,\n\t\t\t\t\taudit,\n\t\t\t\t})\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\tfor (const question of repo.audit.questions) {\n\t\t\t\t\tif (!question.blocking) {\n\t\t\t\t\t\tthis.#reporter.line(`${repo.name}: warning: ${question.text}`)\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 = this.#prunePaths(repo.directory, host, repo.plan.blueprint.service)\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, repo.plan.blueprint.service)\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(this.#sync)\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,M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