@orkestrel/scaffold 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/bin/scaffold.js +1539 -0
- package/dist/bin/scaffold.js.map +1 -0
- package/dist/host/AGENTS.md +939 -0
- package/dist/host/CLAUDE.md +495 -0
- package/dist/host/LICENSE +21 -0
- package/dist/host/claude/agents/builder.md +48 -0
- package/dist/host/claude/agents/checker.md +37 -0
- package/dist/host/claude/agents/composer.md +64 -0
- package/dist/host/claude/agents/grok.md +50 -0
- package/dist/host/claude/agents/orkestrel.md +236 -0
- package/dist/host/claude/agents/planner.md +44 -0
- package/dist/host/claude/agents/researcher.md +38 -0
- package/dist/host/claude/agents/reviewer.md +47 -0
- package/dist/host/claude/agents/scout.md +35 -0
- package/dist/host/claude/agents/verifier.md +34 -0
- package/dist/host/claude/settings.json +26 -0
- package/dist/host/dotfiles/editorconfig +17 -0
- package/dist/host/dotfiles/gitattributes +3 -0
- package/dist/host/dotfiles/gitignore +40 -0
- package/dist/host/dotfiles/oxfmtrc.json +18 -0
- package/dist/host/dotfiles/oxlintignore +20 -0
- package/dist/host/dotfiles/oxlintrc.json +58 -0
- package/dist/host/dotfiles/prettierignore +5 -0
- package/dist/host/github/workflows/ci.yml +64 -0
- package/dist/host/guides/src/guide.md +312 -0
- package/dist/host/guides/src/scaffold.md +2152 -0
- package/dist/host/manifest.json +137 -0
- package/dist/host/scripts/cursor.sh +74 -0
- package/dist/host/scripts/deps.sh +38 -0
- package/dist/host/scripts/ollama.sh +163 -0
- package/dist/src/core/index.cjs +3728 -0
- package/dist/src/core/index.cjs.map +1 -0
- package/dist/src/core/index.d.cts +1941 -0
- package/dist/src/core/index.d.ts +1941 -0
- package/dist/src/core/index.js +3636 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/server/index.cjs +1595 -0
- package/dist/src/server/index.cjs.map +1 -0
- package/dist/src/server/index.d.cts +779 -0
- package/dist/src/server/index.d.ts +779 -0
- package/dist/src/server/index.js +1572 -0
- package/dist/src/server/index.js.map +1 -0
- package/package.json +113 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.js","names":[],"sources":["../../src/bin/render.ts","../../src/bin/scaffold.ts"],"sourcesContent":["// The bin's ENTIRE presentation layer — every user-facing string, table, prompt\n// message, help tier, and --json serializer lives here as a pure, exported,\n// module-scope function. The bin (src/bin/scaffold.ts) calls only these; this\n// file never touches process.exit or fs, and never spawns nested functions\n// (AGENTS §no-nested-functions) — every helper is exported and top-level.\nimport type {\n\tAudit,\n\tCatalogEntry,\n\tDrift,\n\tFinding,\n\tOrigin,\n\tPlan,\n\tSurface,\n\tSyncReport,\n} from '@src/core'\nimport type { MaterializeResult } from '@src/server'\nimport { createStyler } from '@orkestrel/console'\nimport type { ColumnSpec, StylerInterface } from '@orkestrel/console'\n\n/** The bin's closed verb vocabulary. */\nexport const KNOWN_VERBS = Object.freeze([\n\t'new',\n\t'pull',\n\t'audit',\n\t'repair',\n\t'fleet',\n\t'catalog',\n] as const)\n\n/** One `KNOWN_VERBS` member. */\nexport type Verb = (typeof KNOWN_VERBS)[number]\n\n/** The jargon translation table — internal `Origin`/`Drift`/scope vocabulary → one user-facing register. */\nexport const ORIGIN_LABEL: Readonly<Record<Origin, string>> = Object.freeze({\n\thost: 'template-owned',\n\ttemplate: 'template-owned',\n\tcomputed: 'generated',\n})\n\n/** A `Finding`'s `Drift`, translated — `'aligned'` never reaches a rendered table (callers filter it first). */\nexport const DRIFT_LABEL: Readonly<Record<Drift, string>> = Object.freeze({\n\taligned: 'unchanged',\n\tstale: 'drifted',\n\tmissing: 'missing',\n\tforeign: 'unexpected file',\n})\n\n/** A `Freshness` outcome, translated for `pull`'s per-entry cause notes. */\nexport const FRESHNESS_LABEL: Readonly<Record<string, string>> = Object.freeze({\n\tcurrent: 'unchanged',\n\tbehind: 'behind',\n\tmissing: 'missing upstream',\n\tfailed: 'fetch failed',\n})\n\n/** The materializer's per-entry action words, translated (`copied` → `wrote`, `skipped` → `unchanged`). */\nexport const ACTION_LABEL: Readonly<Record<string, string>> = Object.freeze({\n\twritten: 'wrote',\n\tcopied: 'wrote',\n\tskipped: 'unchanged',\n\tremoved: 'removed',\n})\n\n/** One `{count} {label}` part, pluralized; used by every bucket/tally line. */\nexport function countPart(count: number, label: string): string {\n\treturn `${count} ${label}${count === 1 ? '' : 's'}`\n}\n\n/** Nonzero `{count} {label}` parts joined by `, `; `'clean'` when every count is zero — the shared bucket-text primitive every verdict line reuses. */\nexport function bucketText(counts: {\n\treadonly drifted: number\n\treadonly missing: number\n\treadonly foreign: number\n}): string {\n\tconst parts: string[] = []\n\tif (counts.drifted > 0) parts.push(countPart(counts.drifted, 'drifted'))\n\tif (counts.missing > 0) parts.push(countPart(counts.missing, 'missing'))\n\tif (counts.foreign > 0) parts.push(countPart(counts.foreign, 'unexpected'))\n\treturn parts.length > 0 ? parts.join(', ') : 'clean'\n}\n\n/**\n * Split `findings` by their `plan` artifact's `origin` — `host`/`template` lumped as\n * `template-owned` vs `computed` as `generated` (a `foreign` finding names no plan artifact,\n * so it counts as `generated`: it is never template-owned).\n */\nexport function partitionOrigin(\n\tfindings: readonly Finding[],\n\tplan: Plan,\n): {\n\treadonly owned: { readonly drifted: number; readonly missing: number; readonly foreign: number }\n\treadonly generated: {\n\t\treadonly drifted: number\n\t\treadonly missing: number\n\t\treadonly foreign: number\n\t}\n} {\n\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\tlet ownedDrifted = 0\n\tlet ownedMissing = 0\n\tlet ownedForeign = 0\n\tlet generatedDrifted = 0\n\tlet generatedMissing = 0\n\tlet generatedForeign = 0\n\tfor (const finding of findings) {\n\t\tconst origin = origins.get(finding.path)\n\t\tconst isOwned = origin === 'host' || origin === 'template'\n\t\tif (finding.drift === 'aligned') continue\n\t\telse if (finding.drift === 'stale') {\n\t\t\tif (isOwned) ownedDrifted += 1\n\t\t\telse generatedDrifted += 1\n\t\t} else if (finding.drift === 'missing') {\n\t\t\tif (isOwned) ownedMissing += 1\n\t\t\telse generatedMissing += 1\n\t\t} else {\n\t\t\tif (isOwned) ownedForeign += 1\n\t\t\telse generatedForeign += 1\n\t\t}\n\t}\n\treturn {\n\t\towned: { drifted: ownedDrifted, missing: ownedMissing, foreign: ownedForeign },\n\t\tgenerated: { drifted: generatedDrifted, missing: generatedMissing, foreign: generatedForeign },\n\t}\n}\n\n/** `audit`'s verdict line — lowercase, verb-led, origin-split so template-owned health is immediately visible. */\nexport function auditVerdict(audit: Audit, plan: Plan): string {\n\tconst total = audit.findings.length\n\tif (audit.clean) return `audit: ${countPart(total, 'artifact')} — clean`\n\tconst split = partitionOrigin(audit.findings, plan)\n\tconst ownedClean =\n\t\tsplit.owned.drifted === 0 && split.owned.missing === 0 && split.owned.foreign === 0\n\treturn ownedClean\n\t\t? `audit: ${countPart(total, 'artifact')} — template-owned clean; ${bucketText(split.generated)} (generated)`\n\t\t: `audit: ${countPart(total, 'artifact')} — template-owned: ${bucketText(split.owned)}; generated: ${bucketText(split.generated)}`\n}\n\n/** One aligned-column row per non-`aligned` `Finding` — `[status, kind, path]`, translated labels, ready for `reporter.table`. */\nexport function findingRows(\n\tfindings: readonly Finding[],\n\tplan: Plan,\n): readonly (readonly [string, string, string])[] {\n\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\treturn findings\n\t\t.filter((finding) => finding.drift !== 'aligned')\n\t\t.map((finding) => {\n\t\t\tconst origin = origins.get(finding.path)\n\t\t\tconst kind = origin === undefined ? 'unexpected file' : ORIGIN_LABEL[origin]\n\t\t\treturn [DRIFT_LABEL[finding.drift], kind, finding.path] as const\n\t\t})\n}\n\n/** The audit findings table — columns Status/Kind/Path, translated labels, via `reporter.table`. */\nexport function auditTable(\n\taudit: Audit,\n\tplan: Plan,\n): {\n\treadonly columns: readonly ColumnSpec[]\n\treadonly rows: readonly (readonly string[])[]\n} {\n\treturn {\n\t\tcolumns: [{ label: 'Status' }, { label: 'Kind' }, { label: 'Path' }],\n\t\trows: findingRows(audit.findings, plan),\n\t}\n}\n\n/** The banner `repair` opens with (dry-run AND `--apply`) — its scope is the template-owned set only. */\nexport const REPAIR_SCOPE =\n\t'repair scope: shared template-owned artifacts only — generated source/tests/configs are never touched'\n\n/** The `repair` note pointing at drift outside its scope — `undefined` when there is none. */\nexport function scopeNote(outsideCount: number): string | undefined {\n\tif (outsideCount === 0) return undefined\n\treturn `note: ${countPart(outsideCount, 'finding')} outside repair's scope — run 'audit' for the list; generated files are yours to edit`\n}\n\n/** `repair`'s dry-run verdict line. */\nexport function repairVerdict(audit: Audit): string {\n\tif (audit.clean)\n\t\treturn `repair: ${countPart(audit.findings.length, 'template-owned artifact')} aligned — nothing to write`\n\treturn `repair: ${bucketText({ drifted: audit.drifted, missing: audit.missing, foreign: audit.foreign })} — pass --apply to write`\n}\n\n/** `repair --apply`'s success line — the materializer tally, translated action words. */\nexport function repairSuccess(result: MaterializeResult, removed: readonly string[]): string {\n\tconst written = result.written.length + result.copied.length\n\treturn `${ACTION_LABEL.written} ${written}, ${ACTION_LABEL.skipped} ${result.skipped.length}, ${ACTION_LABEL.removed} ${removed.length}`\n}\n\n/** `pull`'s freshness table rows — `[name, kind, freshness]`, translated. */\nexport function pullRows(report: SyncReport): readonly (readonly [string, string, string])[] {\n\tconst guideRows = report.guides.map(\n\t\t(guide) => [guide.name, 'guide', FRESHNESS_LABEL[guide.freshness] ?? guide.freshness] as const,\n\t)\n\tconst versionRows = report.versions.map(\n\t\t(version) =>\n\t\t\t[version.name, 'version', FRESHNESS_LABEL[version.freshness] ?? version.freshness] as const,\n\t)\n\treturn [...guideRows, ...versionRows]\n}\n\n/** `pull`'s freshness table — columns Name/Kind/Freshness. */\nexport function pullTable(report: SyncReport): {\n\treadonly columns: readonly ColumnSpec[]\n\treadonly rows: readonly (readonly string[])[]\n} {\n\treturn {\n\t\tcolumns: [{ label: 'Name' }, { label: 'Kind' }, { label: 'Freshness' }],\n\t\trows: pullRows(report),\n\t}\n}\n\n/** Per-entry cause notes for a non-`current` `pull` entry that carries a `note`. */\nexport function pullCauseNotes(report: SyncReport): readonly string[] {\n\tconst entries = [...report.guides, ...report.versions]\n\treturn entries\n\t\t.filter((entry) => entry.note !== undefined)\n\t\t.map(\n\t\t\t(entry) =>\n\t\t\t\t` ${entry.name}: ${FRESHNESS_LABEL[entry.freshness] ?? entry.freshness} — ${entry.note}`,\n\t\t)\n}\n\n/** `pull`'s tally line. */\nexport function pullVerdict(report: SyncReport): string {\n\tconst total = report.guides.length + report.versions.length\n\treturn `pull: ${countPart(total, 'entry')} — ${countPart(report.failed, 'failed')}`\n}\n\n/** `pull --apply`'s success line. */\nexport function pullSuccess(count: number): string {\n\treturn `wrote ${countPart(count, 'guide')}`\n}\n\n/** One `fleet` per-repo line — clean, drifted (dry-run), or repaired (`--apply`). */\nexport function fleetRepoLine(\n\tname: string,\n\toutcome:\n\t\t| { readonly kind: 'clean' }\n\t\t| {\n\t\t\t\treadonly kind: 'drifted'\n\t\t\t\treadonly drifted: number\n\t\t\t\treadonly missing: number\n\t\t\t\treadonly foreign: number\n\t\t }\n\t\t| { readonly kind: 'repaired'; readonly remaining: number }\n\t\t| { readonly kind: 'failed'; readonly message: string },\n): string {\n\tif (outcome.kind === 'clean') return `${name}: clean`\n\tif (outcome.kind === 'drifted') {\n\t\treturn `${name}: ${bucketText({ drifted: outcome.drifted, missing: outcome.missing, foreign: outcome.foreign })}`\n\t}\n\tif (outcome.kind === 'repaired')\n\t\treturn `${name}: repaired (${countPart(outcome.remaining, 'finding')} remaining)`\n\treturn `${name}: ${outcome.message}`\n}\n\n/** `fleet`'s blast-radius totals line. */\nexport function fleetTotals(drifted: number, failed: number): string {\n\treturn `total: ${countPart(drifted, 'drifted repo')}, ${countPart(failed, 'failed')}`\n}\n\n/** The `catalog` terminal preview table — columns Package/Version (descriptions live only in the written table and `--json`). */\nexport function catalogTable(entries: readonly CatalogEntry[]): {\n\treadonly columns: readonly ColumnSpec[]\n\treadonly rows: readonly (readonly string[])[]\n} {\n\treturn {\n\t\tcolumns: [{ label: 'Package' }, { label: 'Version' }],\n\t\trows: entries.map((entry) => [entry.name, entry.version] as const),\n\t}\n}\n\n/** The `catalog` shrink warning — `undefined` when the table did not shrink. */\nexport function catalogShrinkWarning(oldRows: number, newRows: number): string | undefined {\n\tif (newRows >= oldRows) return undefined\n\treturn `warning: catalog shrinks from ${countPart(oldRows, 'row')} to ${newRows}`\n}\n\n/** `catalog`'s counts line. */\nexport function catalogCounts(published: number, localOnly: number): string {\n\treturn `catalog: ${countPart(published, 'published package')}, ${countPart(localOnly, 'local-only')}`\n}\n\n/** `new`'s dry-run plan preview — origin counts table description + the destination line. */\nexport function newPlanTable(scaffolding: {\n\treadonly host: number\n\treadonly template: number\n\treadonly computed: number\n}): {\n\treadonly columns: readonly ColumnSpec[]\n\treadonly rows: readonly (readonly string[])[]\n} {\n\treturn {\n\t\tcolumns: [{ label: 'Origin' }, { label: 'Count', align: 'right' as const }],\n\t\trows: [\n\t\t\t['template-owned', String(scaffolding.host + scaffolding.template)],\n\t\t\t['generated', String(scaffolding.computed)],\n\t\t],\n\t}\n}\n\n/** `new`'s dry-run destination line. */\nexport function newPlanPreview(name: string): string {\n\treturn `will write into ./${name}`\n}\n\n/** `new --apply`'s success line. */\nexport function newApplySuccess(count: number, name: string): string {\n\treturn `wrote ${countPart(count, 'file')} into ./${name}`\n}\n\n/** `new`'s dry-run declined-apply note. */\nexport const NEW_DRY_RUN_NOTE = 'dry run — pass --apply to write'\n\n/** `catalog --apply`'s success line. */\nexport function catalogApplySuccess(path: string): string {\n\treturn `wrote ${path}`\n}\n\n/** The fallback line for a `parseArgs` failure that carries no `Error` message of its own. */\nexport const INVALID_ARGUMENTS_MESSAGE = 'invalid arguments'\n\n/** The apply-confirm prompt message — singular repo, or fleet-wide across `repos` when given. */\nexport function applyConfirmMessage(fileCount: number, repoCount?: number): string {\n\tconst scope = repoCount === undefined ? '' : ` across ${countPart(repoCount, 'repo')}`\n\treturn `Apply — write ${countPart(fileCount, 'file')}${scope}? `\n}\n\n/** The prune double-confirm prompt message. */\nexport function pruneConfirmMessage(count: number): string {\n\treturn `Also delete ${countPart(count, 'unexpected file')} under .claude/agents and scripts? `\n}\n\n/**\n * The audit→repair handoff prompt message — names what will actually be\n * acted on: `owned` template-owned files with drift, and (only when `prune`\n * is active) `foreign` unexpected files that will be deleted. Never promises\n * a deletion the handoff will not perform — `prune` gates the foreign clause.\n */\nexport function repairHandoff(owned: number, foreign: number, prune: boolean): string {\n\tconst parts: string[] = []\n\tif (owned > 0) {\n\t\tparts.push(`${countPart(owned, 'template-owned file')} ${owned === 1 ? 'has' : 'have'} drift`)\n\t}\n\tif (prune && foreign > 0) parts.push(`${countPart(foreign, 'unexpected file')} will be deleted`)\n\treturn `${parts.join(' and ')} — run repair now? `\n}\n\n/** Printed when unexpected files exist but the handoff cannot help them (no `--prune`, or no handoff offered at all) — points at the one command that can. */\nexport function foreignHint(): string {\n\treturn \"unexpected files found — run 'scaffold repair --prune' to delete them\"\n}\n\n/** `new`'s interactive Q1 prompt (TTY only) — `@orkestrel` short-name deps, landing in `dependencies`. */\nexport function orkestrelDepsPrompt(): string {\n\treturn '@orkestrel dependencies (comma-separated short names, e.g. contract, emitter — installed as dependencies)'\n}\n\n/**\n * Re-ask wording for a Q1 token that does not resolve against the vendored\n * `@orkestrel` catalog — names the offending token and, when one was found,\n * the nearest catalog name (`render.ts`'s own `nearest`).\n */\nexport function unknownOrkestrelToken(token: string, suggestion: string | undefined): string {\n\tconst base = `\"${token}\" is not a published @orkestrel package`\n\treturn suggestion === undefined\n\t\t? `${base} — try again`\n\t\t: `${base} — did you mean \"${suggestion}\"? try again`\n}\n\n/** Printed once when the vendored `@orkestrel` catalog cannot be resolved — Q1 degrades to shape-only (`DEPENDENCY_NAME_PATTERN`) validation instead of blocking on it. */\nexport function catalogUnresolvedNote(): string {\n\treturn \"couldn't resolve the vendored @orkestrel catalog — validating names by shape only\"\n}\n\n/** The line printed when a confirm prompt is declined. */\nexport const CANCELLED_MESSAGE = 'cancelled — nothing written'\n\n/** `new`'s surface checkbox choices — per-choice descriptions grounded on the terminal guide's surface semantics. */\nexport function surfaceChoices(): readonly {\n\treadonly name: string\n\treadonly value: Surface\n\treadonly description: string\n}[] {\n\treturn [\n\t\t{ name: 'core', value: 'core', description: 'the pure engine' },\n\t\t{ name: 'browser', value: 'browser', description: 'DOM-facing surface' },\n\t\t{ name: 'server', value: 'server', description: 'node-facing surface' },\n\t]\n}\n\n/** The safety-model banner every full-help tier includes. */\nexport const SAFETY_BANNER = [\n\t'safety: every verb is a dry run by default.',\n\t'on a terminal, a write prompts for confirmation; in a script, pass --apply (and --yes to skip the confirm).',\n\t'every write is confined to the current working directory — cd there first.',\n\t'TLS trusts the system certificate store automatically (corporate proxies); NODE_EXTRA_CA_CERTS adds custom PEMs.',\n].join('\\n')\n\n/** The exit-code reference table every full-help tier includes. */\nexport const EXIT_CODES: readonly (readonly [string, string])[] = [\n\t['0', 'clean / success'],\n\t['1', 'drift or failure'],\n\t['2', 'usage error'],\n]\n\n/** One-line-per-verb summaries — the short and full help tiers share this table. */\nexport const VERB_SUMMARY: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'scaffold a package into ./<name>',\n\tpull: 'refresh vendored guides/versions, report drift',\n\taudit: 'whole-plan conformance report',\n\trepair: 'restore the shared template-owned set',\n\tfleet: \"audit/repair every package under the cwd's immediate children\",\n\tcatalog: 'regenerate the fleet package-catalog table',\n})\n\n/** ≤10 lines: one-liner per verb plus the escape hatch to `verbHelp`. */\nexport function shortUsage(): string {\n\tconst lines = KNOWN_VERBS.map((verb) => ` ${verb.padEnd(8)}${VERB_SUMMARY[verb]}`)\n\treturn [\n\t\t'scaffold <verb> [options]',\n\t\t'',\n\t\t...lines,\n\t\t'',\n\t\t\"run 'scaffold <verb> --help' for a verb's full reference\",\n\t].join('\\n')\n}\n\n/** Each verb's flag reference — the fullHelp reference and verbHelp share this table. */\nexport const VERB_FLAGS: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: '--surfaces a,b --deps x,y --apply --yes --target <path> --from <path>',\n\tpull: '--target . --deps x,y --apply --yes --strict',\n\taudit: '--target . --live --from <path> --groups a,b',\n\trepair: '--target . --apply --yes --prune --from <path>',\n\tfleet: '--apply --yes --prune --from <path>',\n\tcatalog: '--from <path> ... --target <repo> --offline --apply --yes',\n})\n\n/** Per-verb, per-flag plain-language descriptions — `verbHelp`'s one-line-per-flag body. `--prune` is marked destructive. */\nexport const VERB_FLAG_HELP: Readonly<Record<Verb, readonly (readonly [string, string])[]>> =\n\tObject.freeze({\n\t\tnew: [\n\t\t\t['--surfaces a,b', 'which surfaces to include (core, browser, server)'],\n\t\t\t['--deps x,y', '@orkestrel/* dependencies to add (installed as dependencies)'],\n\t\t\t['--apply', 'write the files (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--target <path>', 'destination directory (default: ./<name>)'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t],\n\t\tpull: [\n\t\t\t['--target .', 'directory to refresh (default: current directory)'],\n\t\t\t['--deps x,y', 'limit the refresh to these dependencies'],\n\t\t\t['--apply', 'write the refreshed files (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--strict', 'fail (exit 1) on any drift, even non-fatal'],\n\t\t],\n\t\taudit: [\n\t\t\t['--target .', 'directory to audit (default: current directory)'],\n\t\t\t['--live', 'also check upstream freshness over the network'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t\t['--groups a,b', 'limit the audit to these artifact groups'],\n\t\t],\n\t\trepair: [\n\t\t\t['--target .', 'directory to repair (default: current directory)'],\n\t\t\t['--apply', 'write the fixes (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--prune', 'also DELETE unexpected files under .claude/agents and scripts'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t],\n\t\tfleet: [\n\t\t\t['--apply', 'write fixes across every package (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t\t['--prune', 'also DELETE unexpected files under .claude/agents and scripts, per package'],\n\t\t\t['--from <path>', 'read the template from a local path instead of the bundled one'],\n\t\t],\n\t\tcatalog: [\n\t\t\t['--from <path> ...', 'one or more local package paths to include'],\n\t\t\t['--target <repo>', 'the repo whose README catalog table gets updated'],\n\t\t\t['--offline', 'skip network lookups (npm registry) for package descriptions'],\n\t\t\t['--apply', 'write the updated table (default is a dry run)'],\n\t\t\t['--yes', 'skip the confirmation question'],\n\t\t],\n\t})\n\n/** The dry-run/confirm note per verb — `audit` never writes, so its note says so instead. */\nexport const VERB_DRY_RUN_NOTE: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'dry run by default — add --apply to write the files, --yes to skip the question',\n\tpull: 'dry run by default — add --apply to write the refreshed files, --yes to skip the question',\n\taudit: 'read-only — audit never writes; pass --live to also check upstream freshness',\n\trepair: 'dry run by default — add --apply to write, --yes to skip the question',\n\tfleet:\n\t\t'dry run by default — add --apply to write across every package, --yes to skip the question',\n\tcatalog: 'dry run by default — add --apply to write, --yes to skip the question',\n})\n\n/** One concrete example invocation per verb — `verbHelp`'s closing line. */\nexport const VERB_EXAMPLE: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'example: scaffold new widget --surfaces core,server --apply',\n\tpull: 'example: scaffold pull --apply',\n\taudit: 'example: scaffold audit --live',\n\trepair: 'example: scaffold repair --apply',\n\tfleet: 'example: scaffold fleet --apply --yes',\n\tcatalog: 'example: scaffold catalog --apply',\n})\n\n/** The full reference help tier — every verb's summary + flags, the safety banner, and the exit-code table. */\nexport function fullHelp(): string {\n\tconst verbLines = KNOWN_VERBS.map(\n\t\t(verb) => ` ${verb} ${VERB_FLAGS[verb]}\\n ${VERB_SUMMARY[verb]}`,\n\t)\n\tconst exitLines = EXIT_CODES.map(([code, meaning]) => ` ${code} ${meaning}`)\n\treturn [\n\t\t'scaffold <verb> [options]',\n\t\t'',\n\t\t...verbLines,\n\t\t'',\n\t\tSAFETY_BANNER,\n\t\t'',\n\t\t'exit codes:',\n\t\t...exitLines,\n\t].join('\\n')\n}\n\n/** One verb's help section — summary, dry-run note, one line per flag, and a concrete example. */\nexport function verbHelp(verb: Verb): string {\n\tconst flagLines = VERB_FLAG_HELP[verb].map(([flag, meaning]) => ` ${flag.padEnd(20)}${meaning}`)\n\treturn [\n\t\t`scaffold ${verb} ${VERB_FLAGS[verb]}`,\n\t\t'',\n\t\tVERB_SUMMARY[verb],\n\t\tVERB_DRY_RUN_NOTE[verb],\n\t\t'',\n\t\t...flagLines,\n\t\t'',\n\t\tVERB_EXAMPLE[verb],\n\t].join('\\n')\n}\n\n/** Levenshtein edit distance between two strings — the did-you-mean primitive. */\nexport function editDistance(a: string, b: string): number {\n\tconst rows = a.length + 1\n\tconst cols = b.length + 1\n\tconst table: number[][] = Array.from({ length: rows }, () => new Array<number>(cols).fill(0))\n\tfor (let i = 0; i < rows; i += 1) table[i][0] = i\n\tfor (let j = 0; j < cols; j += 1) table[0][j] = j\n\tfor (let i = 1; i < rows; i += 1) {\n\t\tfor (let j = 1; j < cols; j += 1) {\n\t\t\tconst cost = a[i - 1] === b[j - 1] ? 0 : 1\n\t\t\ttable[i][j] = Math.min(table[i - 1][j] + 1, table[i][j - 1] + 1, table[i - 1][j - 1] + cost)\n\t\t}\n\t}\n\treturn table[rows - 1][cols - 1]\n}\n\n/** The nearest candidate to `input` by `editDistance` — `undefined` when `set` is empty. */\nexport function nearest(input: string, set: readonly string[]): string | undefined {\n\tlet best: string | undefined\n\tlet bestDistance = Number.POSITIVE_INFINITY\n\tfor (const candidate of set) {\n\t\tconst distance = editDistance(input, candidate)\n\t\tif (distance < bestDistance) {\n\t\t\tbestDistance = distance\n\t\t\tbest = candidate\n\t\t}\n\t}\n\treturn best\n}\n\n/** Retired verb names redirected to their replacement — checked before fuzzy matching in `didYouMean`. */\nexport const RETIRED_VERBS: Readonly<Record<string, string>> = Object.freeze({\n\tsync: 'pull',\n\tmirror: 'fleet',\n})\n\n/** The unknown-command message — a retired-verb redirect when recognized, otherwise the nearest `KNOWN_VERBS` guess. */\nexport function didYouMean(command: string): string {\n\tconst retired = RETIRED_VERBS[command]\n\tif (retired !== undefined) return `'${command}' has been renamed — use 'scaffold ${retired}'`\n\tconst guess = nearest(command, [...KNOWN_VERBS])\n\treturn guess === undefined\n\t\t? `unknown command \"${command}\"`\n\t\t: `unknown command \"${command}\" — did you mean \"${guess}\"?`\n}\n\n/** One JSON error envelope — the single shape every `--json` failure returns. */\nexport function errorEnvelope(\n\tcode: string,\n\tmessage: string,\n): { readonly error: { readonly code: string; readonly message: string } } {\n\treturn { error: { code, message } }\n}\n\n/** `new --json`'s value — the plan summary, deterministic key order. */\nexport function newJson(\n\tsummary: {\n\t\treadonly name: string\n\t\treadonly surfaces: readonly Surface[]\n\t\treadonly host: number\n\t\treadonly template: number\n\t\treadonly computed: number\n\t},\n\tapplied: boolean,\n): {\n\treadonly name: string\n\treadonly surfaces: readonly Surface[]\n\treadonly host: number\n\treadonly template: number\n\treadonly computed: number\n\treadonly applied: boolean\n} {\n\treturn {\n\t\tname: summary.name,\n\t\tsurfaces: summary.surfaces,\n\t\thost: summary.host,\n\t\ttemplate: summary.template,\n\t\tcomputed: summary.computed,\n\t\tapplied,\n\t}\n}\n\n/** `pull --json`'s value — the `SyncReport` verbatim (already deterministic + JSON-safe). */\nexport function pullJson(report: SyncReport): SyncReport {\n\treturn report\n}\n\n/** `audit --json`'s value — the `Audit` verbatim. */\nexport function auditJson(audit: Audit): Audit {\n\treturn audit\n}\n\n/** `repair --json`'s value — the `Audit` plus the `MaterializeResult` when `--apply` ran. */\nexport function repairJson(\n\taudit: Audit,\n\tresult?: MaterializeResult,\n): Audit | (Audit & { readonly result: MaterializeResult }) {\n\treturn result === undefined ? audit : { ...audit, result }\n}\n\n/** `fleet --json`'s value — a top-level ARRAY of per-repo objects, one entry per package. */\nexport function fleetJson(\n\tentries: readonly {\n\t\treadonly name: string\n\t\treadonly drifted: number\n\t\treadonly missing: number\n\t\treadonly foreign: number\n\t\treadonly failed: boolean\n\t}[],\n): readonly {\n\treadonly name: string\n\treadonly drifted: number\n\treadonly missing: number\n\treadonly foreign: number\n\treadonly failed: boolean\n}[] {\n\treturn entries\n}\n\n/** `catalog --json`'s value — the entries, drift flag, and optional shrink count. */\nexport function catalogJson(\n\tentries: readonly CatalogEntry[],\n\tdrifted: boolean,\n\tshrink?: number,\n): {\n\treadonly entries: readonly CatalogEntry[]\n\treadonly drift: boolean\n\treadonly shrink?: number\n} {\n\treturn shrink === undefined ? { entries, drift: drifted } : { entries, drift: drifted, shrink }\n}\n\n/** `enabled` for `createStyler` — off under `NO_COLOR` or when the sink is not a TTY (both read by the caller). */\nexport function chooseStyler(sinkIsTTY: boolean, noColor: boolean): StylerInterface {\n\treturn createStyler({ enabled: !noColor && sinkIsTTY })\n}\n\n/** Whether a long-running step should animate a spinner (TTY) or fall back to a one-line `status` (piped/non-TTY). */\nexport function shouldSpin(sinkIsTTY: boolean): boolean {\n\treturn sinkIsTTY\n}\n\n/** One line per exact relative path that WOULD be deleted — printed before the prune confirm. */\nexport function prunePreview(paths: readonly string[]): readonly string[] {\n\treturn paths.map((path) => ` delete ${path}`)\n}\n\n/** Printed when the prune scan finds nothing to delete. */\nexport const PRUNE_EMPTY = 'no unexpected files to delete'\n\n/** Printed on a non-TTY session when the prune question cannot be asked. */\nexport function pruneSkipped(): string {\n\treturn 'prune skipped — not a terminal; add --apply (or --yes) to delete non-interactively'\n}\n\n/** Non-TTY usage-error guidance for a missing required input. */\nexport function missingInput(what: string, verb: string): string {\n\treturn `missing ${what} — pass it as a flag/argument, or run 'scaffold ${verb}' on a terminal to be guided`\n}\n\n/** Printed when `audit` cannot establish the template source for the unexpected-file scan — the audit degrades to the un-scanned findings instead of crashing. */\nexport function scanSkipped(): string {\n\treturn \"unexpected-file scanning skipped — couldn't establish the template source\"\n}\n\n/** Usage-error message for a `new` package name that fails `PACKAGE_NAME_PATTERN` — same shape the interactive prompt enforces. */\nexport function invalidName(name: string, pattern: string): string {\n\treturn `Package name \"${name}\" must match ${pattern}`\n}\n\n/** `new`'s hard failure when `sync.versions` cannot resolve a latest version for one or more `--deps` names — names every unresolved package plainly so a `^` (unresolved-latest) range can never be silently written. */\nexport function unresolvedVersion(names: readonly string[]): string {\n\treturn `could not resolve the latest version for ${names.map((name) => `\"${name}\"`).join(', ')} — check the name or pass name@range`\n}\n\n/** Printed when every finding is `generated` drift — repair does not touch generated files. */\nexport function generatedNote(count: number): string {\n\treturn `${countPart(count, 'finding')} in generated files — these are regenerated, not hand-edited; repair does not touch them`\n}\n\n/** `audit --live`'s freshness summary line. */\nexport function auditLiveNote(current: number, behind: number, failed: number): string {\n\treturn `live: ${countPart(current, 'current')}, ${countPart(behind, 'behind')}, ${countPart(failed, 'failed')}`\n}\n\n/** Translated vocabulary for whether the audit compared file contents or only file names, for template-owned files. */\nexport function comparisonLine(aware: boolean): string {\n\treturn aware\n\t\t? 'comparing: file contents for template-owned files'\n\t\t: 'comparing: file names only for template-owned files (no vendored source found)'\n}\n\n/** `fleet`'s ci.yml note — each package customizes its own CI, so `fleet` leaves it unchanged. */\nexport function fleetCiSkipped(): string {\n\treturn \"ci.yml: left unchanged — each package customizes its own CI; run 'scaffold repair --apply' inside that package to update it\"\n}\n\n/** `catalog`'s verdict line — clean or drifted. */\nexport function catalogVerdict(clean: boolean): string {\n\treturn clean ? 'catalog: clean' : 'catalog: drifted — pass --apply to write'\n}\n","// The `#!/usr/bin/env node` shebang is re-emitted by the build's `output.banner`, not source.\nimport { existsSync, readFileSync, realpathSync, writeFileSync } from 'node:fs'\nimport { basename, dirname, join, relative as relativeOf, resolve, sep } from 'node:path'\nimport * as tls from 'node:tls'\nimport { parseArgs } from 'node:util'\nimport type {\n\tAudit,\n\tBlueprint,\n\tCatalogEntry,\n\tDependency,\n\tFinding,\n\tGroup,\n\tPlan,\n\tSyncReport,\n} from '@src/core'\nimport {\n\tblueprint,\n\tblueprintToPlan,\n\tcatalogNames,\n\tcatalogToBlock,\n\tcreateCompiler,\n\tdependency,\n\tDEPENDENCY_NAME_PATTERN,\n\tdiffPlan,\n\tGROUPS,\n\tisScaffoldError,\n\tmanifestToDependencies,\n\tNAME_PATTERN,\n\tplanToSummary,\n\tScaffoldError,\n\tSURFACES,\n} from '@src/core'\nimport {\n\tcatalogPackages,\n\tcreateMaterializer,\n\tcreateSync,\n\tderiveBlueprint,\n\tdiscoverPackages,\n\thostRoot,\n\thydratePlan,\n\tlocateHostSource,\n\tpruneTargets,\n\treadHostManifest,\n\treadManifest,\n\treadTarget,\n} from '@src/server'\nimport type { SpinnerInterface } from '@orkestrel/console'\nimport { createReporter, createSpinner } from '@orkestrel/console'\nimport { createServerSink } from '@orkestrel/console/server'\nimport { isTerminalError } from '@orkestrel/terminal'\nimport type { TerminalInterface } from '@orkestrel/terminal/server'\nimport { createTerminal } from '@orkestrel/terminal/server'\nimport type { Verb } from './render.js'\nimport {\n\tapplyConfirmMessage,\n\tauditJson,\n\tauditLiveNote,\n\tauditTable,\n\tauditVerdict,\n\tCANCELLED_MESSAGE,\n\tcatalogApplySuccess,\n\tcatalogCounts,\n\tcatalogJson,\n\tcatalogShrinkWarning,\n\tcatalogTable,\n\tcatalogUnresolvedNote,\n\tcatalogVerdict,\n\tchooseStyler,\n\tcomparisonLine,\n\tdidYouMean,\n\terrorEnvelope,\n\tfleetCiSkipped,\n\tfleetRepoLine,\n\tfleetTotals,\n\tforeignHint,\n\tfullHelp,\n\tgeneratedNote,\n\tinvalidName,\n\tINVALID_ARGUMENTS_MESSAGE,\n\tKNOWN_VERBS,\n\tmissingInput,\n\tnearest,\n\tnewApplySuccess,\n\tnewJson,\n\tNEW_DRY_RUN_NOTE,\n\tnewPlanPreview,\n\tnewPlanTable,\n\torkestrelDepsPrompt,\n\tprunePreview,\n\tPRUNE_EMPTY,\n\tpruneConfirmMessage,\n\tpruneSkipped,\n\tpullCauseNotes,\n\tpullJson,\n\tpullSuccess,\n\tpullTable,\n\tpullVerdict,\n\trepairHandoff,\n\trepairJson,\n\trepairSuccess,\n\trepairVerdict,\n\tREPAIR_SCOPE,\n\tscanSkipped,\n\tscopeNote,\n\tshortUsage,\n\tshouldSpin,\n\tsurfaceChoices,\n\tunknownOrkestrelToken,\n\tunresolvedVersion,\n\tverbHelp,\n\tfleetJson,\n} from './render.js'\n\nconst sink = createServerSink()\nconst sinkIsTTY = process.stdout.isTTY === true\nconst noColor = process.env.NO_COLOR !== undefined\nconst styler = chooseStyler(sinkIsTTY, noColor)\nconst reporter = createReporter({ sink, width: sink.columns, styler })\n\n/**\n * Widen Node's default trusted-issuer set to include the OS certificate\n * store, so `fetch` behind a corporate TLS-inspecting proxy behaves like npm\n * (`cafile`) and browsers (OS trust store) instead of failing with\n * `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` against Node's bundled CA list alone.\n * Feature-detected (`tls.getCACertificates` / `tls.setDefaultCACertificates`\n * ship on Node ≈22.16+/24.5+; this package's floor is `>=22`) and wrapped in\n * try/catch — any failure is a silent no-op, never a crash. This only ADDS\n * trusted issuers; it never touches `rejectUnauthorized` or\n * `NODE_TLS_REJECT_UNAUTHORIZED`, so certificate verification stays on.\n */\nfunction trustSystemCertificates(): void {\n\tif (\n\t\ttypeof tls.getCACertificates !== 'function' ||\n\t\ttypeof tls.setDefaultCACertificates !== 'function'\n\t) {\n\t\treturn\n\t}\n\ttry {\n\t\tconst merged = new Set([\n\t\t\t...tls.getCACertificates('default'),\n\t\t\t...tls.getCACertificates('system'),\n\t\t])\n\t\ttls.setDefaultCACertificates([...merged])\n\t} catch {\n\t\t// Trust-store quirks never crash the CLI — fetch failures still surface their own diagnosis.\n\t}\n}\n\n/**\n * The one sentinel that unwinds the whole command dispatch to a chosen exit\n * code (H4/Windows) — thrown instead of calling `process.exit`, so every\n * `finally` between the throw site and the top-level driver still runs\n * (entity teardown drains naturally instead of racing process teardown).\n * Caught exactly once, at the bottom of this file.\n */\nclass CliExit extends Error {\n\treadonly code: number\n\n\tconstructor(code: number) {\n\t\tsuper(`cli-exit:${String(code)}`)\n\t\tthis.code = code\n\t}\n}\n\n/** Halt command dispatch with `code` (H4) — never `process.exit`; unwinds through every `finally` first. */\nfunction halt(code: number): never {\n\tthrow new CliExit(code)\n}\n\n/** Render a caught error as a clean one-line message — a `ScaffoldError`'s code, or a bare message otherwise. */\nfunction describe(error: unknown): string {\n\tif (isScaffoldError(error)) return `[${error.code}] ${error.message}`\n\treturn error instanceof Error ? error.message : 'unknown error'\n}\n\n/** Write ONE machine-readable JSON value to stdout — the entire `--json` output contract. */\nfunction writeJson(value: unknown): void {\n\tprocess.stdout.write(`${JSON.stringify(value)}\\n`)\n}\n\n/**\n * Whether the current invocation carries `--json` — set once `parseArguments`\n * has run (`main`'s first act), so the OUTERMOST catch (bottom of this file)\n * can still honor `--json` for an error that escapes every verb runner's own\n * handling, emitting exactly one JSON error envelope instead of prose.\n */\nlet sessionJson = false\n\n/** A general operation failure (H1: exit 1) — a prose status line, or the one JSON error envelope under `--json`. */\nfunction fail(message: string, json: boolean): never {\n\tif (json) writeJson(errorEnvelope('ERROR', message))\n\telse reporter.status('error', message)\n\thalt(1)\n}\n\n/**\n * A general operation failure FROM A CAUGHT ERROR (H1: exit 1) — the real\n * `ScaffoldError` code when available ('ERROR' last resort), prose (via\n * `describe`, which still carries the bracketed code for a human reader) or\n * the one JSON error envelope under `--json` (code and message kept\n * SEPARATE — never double-encoding the code into the message text).\n */\nfunction failError(error: unknown, json: boolean): never {\n\tif (json) {\n\t\tconst code = isScaffoldError(error) ? error.code : 'ERROR'\n\t\tconst message = isScaffoldError(error) ? error.message : describe(error)\n\t\twriteJson(errorEnvelope(code, message))\n\t} else {\n\t\treporter.status('error', describe(error))\n\t}\n\thalt(1)\n}\n\n/** A usage error (bad flag value, unknown verb — exit 2) — stderr prose, or the one JSON error envelope under `--json`. */\nfunction usageFail(message: string, json: boolean): never {\n\tif (json) writeJson(errorEnvelope('USAGE', message))\n\telse process.stderr.write(`${message}\\n`)\n\thalt(2)\n}\n\n// Realpath-resolve the DEEPEST EXISTING ancestor of `path` (following any\n// symlink it or its ancestors are), then rejoin the still-nonexistent\n// remainder unchanged — mirrors the server `Materializer`'s `#resolveReal` so\n// a not-yet-created destination is checked against where a symlinked segment\n// actually points, without realpath'ing a leaf that does not exist yet.\nfunction resolveReal(path: string): string {\n\tif (existsSync(path)) return realpathSync(path)\n\tconst parent = dirname(path)\n\tif (parent === path) return path\n\treturn join(resolveReal(parent), relativeOf(parent, path))\n}\n\n/**\n * Confine a WRITE destination to the current working directory (global-CLI\n * safety): `new`'s resolved target, `--target` on pull/audit/repair/catalog,\n * and `fleet`'s always-cwd root all pass through here before use. A\n * READ-ONLY source (`--from`) is exempt — sibling-repo sourcing from outside\n * the cwd is legitimate. Equal to the cwd or nested beneath it passes;\n * anything else is a coded `INVALID` failure (AGENTS §12), never a silent clamp.\n *\n * @returns The resolved (non-realpath'd) absolute path, for use as the\n * verb's destination.\n */\nfunction containDestination(candidate: string): string {\n\tconst resolvedCwd = resolveReal(resolve(process.cwd()))\n\tconst resolvedCandidate = resolveReal(resolve(candidate))\n\tif (resolvedCandidate !== resolvedCwd && !resolvedCandidate.startsWith(resolvedCwd + sep)) {\n\t\tthrow new ScaffoldError(\n\t\t\t'INVALID',\n\t\t\t`Target \"${candidate}\" escapes the working directory — run scaffold from the directory you want to write beneath.`,\n\t\t\t{ path: candidate },\n\t\t)\n\t}\n\treturn resolve(candidate)\n}\n\n/** `containDestination`, halting (H1/`fail`) on a coded escape instead of throwing — the shared entry every runner's target resolution goes through. */\nfunction containOrFail(candidate: string, json: boolean): string {\n\ttry {\n\t\treturn containDestination(candidate)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n}\n\n/** Compile `spec` and unwrap its `plan`, halting (H1/`fail`) with the joined open-question text when compilation could not resolve one — the shared entry every runner's compile step goes through. */\nfunction compileOrFail(spec: Blueprint, json: boolean): Plan {\n\tconst compiler = createCompiler()\n\ttry {\n\t\tconst scaffolding = compiler.compile(spec)\n\t\tif (!scaffolding.plan) {\n\t\t\tconst message = scaffolding.questions.map((question) => question.text).join('; ')\n\t\t\tfail(message, json)\n\t\t}\n\t\treturn scaffolding.plan\n\t} finally {\n\t\tcompiler.destroy()\n\t}\n}\n\n/** `node:util`'s strict `parseArgs`, isolated so its throw on an unknown/malformed flag is catchable (H3). */\nfunction parseArguments() {\n\t// Strip a single leading literal '--' (npm passthrough residue that\n\t// PowerShell mangles, e.g. `npm run scaffold -- new x`) so it parses as `new x`.\n\tconst args = process.argv.slice(2)\n\tif (args[0] === '--') args.shift()\n\treturn parseArgs({\n\t\targs,\n\t\tallowPositionals: true,\n\t\toptions: {\n\t\t\tsurfaces: { type: 'string' },\n\t\t\tdeps: { type: 'string' },\n\t\t\tgroups: { type: 'string' },\n\t\t\ttarget: { type: 'string' },\n\t\t\tfrom: { type: 'string', multiple: true },\n\t\t\tapply: { type: 'boolean', default: false },\n\t\t\tyes: { type: 'boolean', default: false },\n\t\t\tjson: { type: 'boolean', default: false },\n\t\t\tprune: { type: 'boolean', default: false },\n\t\t\tstrict: { type: 'boolean', default: false },\n\t\t\tlive: { type: 'boolean', default: false },\n\t\t\toffline: { type: 'boolean', default: false },\n\t\t\thelp: { type: 'boolean', default: false, short: 'h' },\n\t\t},\n\t})\n}\n\n/** The parsed CLI flags — every verb runner reads the same bag (unused flags for a verb are simply ignored). */\ntype Values = ReturnType<typeof parseArguments>['values']\n\n/** Narrow a positional command to the closed `Verb` vocabulary (render.ts's `KNOWN_VERBS`). */\nfunction isVerb(value: string): value is Verb {\n\treturn KNOWN_VERBS.some((verb) => verb === value)\n}\n\n/**\n * Best-effort `hydratePlan` — used by `audit` / `repair` / `fleet` so a\n * missing DEFAULT vendored-source root degrades to presence-only auditing\n * instead of failing the verb. An EXPLICITLY-passed `--from` that does not\n * resolve to a usable directory is NOT downgraded silently — that is a coded\n * `TARGET` failure (M1), since the caller named that source on purpose.\n */\nfunction hydrateBestEffort(\n\tplan: Plan,\n\thost: string,\n\texplicit: boolean,\n): { readonly plan: Plan; readonly aware: boolean } {\n\tif (!existsSync(host)) {\n\t\tif (explicit) {\n\t\t\tthrow new ScaffoldError('TARGET', `--from does not resolve to a directory: ${host}`, {\n\t\t\t\thost,\n\t\t\t})\n\t\t}\n\t\treturn { plan, aware: false }\n\t}\n\ttry {\n\t\treturn { plan: hydratePlan(plan, host), aware: true }\n\t} catch (error) {\n\t\tif (isScaffoldError(error) && error.code === 'TARGET') return { plan, aware: false }\n\t\tthrow error\n\t}\n}\n\n/**\n * Merge a `pruneTargets` scan into `audit` as `foreign` findings — pure\n * object-spread composition in the BIN only (`src/core`'s `diffPlan` is never\n * modified/reimplemented). Every unexpected path becomes one\n * `'orchestration'`-group `foreign` finding (the `Group` every `PRUNE_DIRECTORIES`\n * entry — `.claude/agents`, `scripts` — belongs to); any scan hit makes the\n * merged audit unclean, so an \"unexpected file\" is honestly counted as drift\n * (exit 1) instead of the structurally-always-zero `diffPlan.foreign`.\n */\nfunction withForeignScan(audit: Audit, target: string, host: string): Audit {\n\tconst paths = pruneTargets(target, host)\n\tif (paths.length === 0) return audit\n\tconst findings: Finding[] = paths.map((path) => ({\n\t\tpath,\n\t\tgroup: 'orchestration',\n\t\tdrift: 'foreign',\n\t}))\n\treturn {\n\t\t...audit,\n\t\tclean: false,\n\t\tforeign: audit.foreign + paths.length,\n\t\tfindings: [...audit.findings, ...findings],\n\t}\n}\n\n/**\n * `withForeignScan`, degrading instead of crashing (F3): `pruneTargets` throws\n * a coded `TARGET` failure when a prune directory exists under `target` but\n * `host` cannot positively establish its allowlist (`vendoredPruneSet`'s\n * fail-closed contract) — an audit should report the un-scanned findings and\n * say scanning was skipped, never crash on this alone (`runFleet` already\n * shields its own per-repo audit the same way).\n */\nfunction withForeignScanSafe(\n\taudit: Audit,\n\ttarget: string,\n\thost: string,\n): { readonly audit: Audit; readonly skipped: boolean } {\n\ttry {\n\t\treturn { audit: withForeignScan(audit, target, host), skipped: false }\n\t} catch (error) {\n\t\tif (isScaffoldError(error) && error.code === 'TARGET') return { audit, skipped: true }\n\t\tthrow error\n\t}\n}\n\n/**\n * `repair`'s own scope is host-only, but the caller compiles the FULL plan anyway — diff it too\n * (cheap, local, no network) so a clean host verdict can point at drift OUTSIDE repair's reach.\n * The count feeds render.ts's `scopeNote`.\n */\nfunction repairOutsideCount(compiled: Plan, target: string): number {\n\tconst full = diffPlan(\n\t\tcompiled,\n\t\treadTarget(\n\t\t\ttarget,\n\t\t\tcompiled.artifacts.map((artifact) => artifact.path),\n\t\t),\n\t)\n\treturn full.drifted + full.missing + full.foreign\n}\n\n/** One `fleet --json` entry — `undefined` counts (a failed repo never got an audit) fall back to zero. */\nfunction fleetEntry(\n\tname: string,\n\tcounts:\n\t\t| { readonly drifted: number; readonly missing: number; readonly foreign: number }\n\t\t| undefined,\n\tfailed: boolean,\n): {\n\treadonly name: string\n\treadonly drifted: number\n\treadonly missing: number\n\treadonly foreign: number\n\treadonly failed: boolean\n} {\n\treturn {\n\t\tname,\n\t\tdrifted: counts?.drifted ?? 0,\n\t\tmissing: counts?.missing ?? 0,\n\t\tforeign: counts?.foreign ?? 0,\n\t\tfailed,\n\t}\n}\n\n/** Reject a cancelled prompt (ctrl-c) with the shared `CANCELLED_MESSAGE` — exit 1, nothing written. */\nasync function guarded<T>(promise: Promise<T>): Promise<T> {\n\ttry {\n\t\treturn await promise\n\t} catch (error) {\n\t\tif (isTerminalError(error) && error.code === 'CANCEL') {\n\t\t\treporter.line(CANCELLED_MESSAGE)\n\t\t\thalt(1)\n\t\t}\n\t\tthrow error\n\t}\n}\n\n/**\n * The shared write-confirmation gate every verb calls before it touches disk.\n * `--apply` writes without asking; `--json` (without `--apply`) is a pure\n * dry-run and NEVER prompts; `--yes` auto-answers yes; otherwise a real\n * confirm with `default: false` (EOF on stdin resolves to the default).\n */\nasync function resolveApply(\n\tterminal: TerminalInterface,\n\tmessage: string,\n\tvalues: Values,\n\tjson: boolean,\n): Promise<boolean> {\n\tif (values.apply) return true\n\tif (json) return false\n\tif (values.yes) return true\n\treturn guarded(terminal.confirm({ message, default: false }))\n}\n\n/**\n * The SECOND, separate confirm for `--prune`-eligible deletions — never\n * bundled into `resolveApply`'s question. `--yes` only auto-answers this\n * when `--prune` was also passed (it never enables pruning by itself).\n */\nasync function resolvePrune(\n\tterminal: TerminalInterface,\n\tmessage: string,\n\tvalues: Values,\n\tjson: boolean,\n): Promise<boolean> {\n\tif (!values.prune) return false\n\tif (values.apply) return true\n\tif (json) return false\n\tif (values.yes) return true\n\t// One-prompt-per-non-TTY-process ceiling (S3f): the write confirm\n\t// (`resolveApply`) already spent the ONE prompt a non-interactive stream\n\t// can reliably answer — a second `terminal.confirm` off the same drained\n\t// stdin hangs until the runtime's watchdog kills the process. Pruning is\n\t// therefore never asked on non-TTY; it resolves `false` and prints\n\t// `pruneSkipped()` instead.\n\tif (!sinkIsTTY) {\n\t\treporter.line(pruneSkipped())\n\t\treturn false\n\t}\n\treturn guarded(terminal.confirm({ message, default: false }))\n}\n\n/** A spinner for a long-running write step — `undefined` under `--json` or off a TTY sink (render.ts's `shouldSpin`). */\nfunction createSpinnerMaybe(message: string, json: boolean): SpinnerInterface | undefined {\n\treturn json || !shouldSpin(sinkIsTTY) ? undefined : createSpinner({ message, sink, styler })\n}\n\n/** Announce a successful write — the spinner's own success line, or a plain `reporter.status` without one (never under `--json`). */\nfunction announceApply(\n\tspinner: SpinnerInterface | undefined,\n\tjson: boolean,\n\tmessage: string,\n): void {\n\tif (spinner) spinner.success(message)\n\telse if (!json) reporter.status('success', message)\n}\n\n/** Announce a failed write and halt(1) — the spinner's own failure line (if any), then the shared `fail`. */\nfunction announceFailure(\n\tspinner: SpinnerInterface | undefined,\n\tjson: boolean,\n\terror: unknown,\n): never {\n\tconst message = describe(error)\n\tif (spinner) spinner.failure(message)\n\tfail(message, json)\n}\n\n/** Split a comma-separated token list, trimming and dropping empties — the parse `new`'s dependency prompt goes through. */\nfunction splitTokens(raw: string): readonly string[] {\n\treturn raw\n\t\t.split(',')\n\t\t.map((token) => token.trim())\n\t\t.filter((token) => token.length > 0)\n}\n\n/** Normalize a Q1 token to a full `@orkestrel/<name>` — an already-prefixed token passes through unchanged. */\nfunction normalizeOrkestrelToken(token: string): string {\n\treturn token.startsWith('@orkestrel/') ? token : `@orkestrel/${token}`\n}\n\n/**\n * Best-effort vendored `@orkestrel` catalog names, resolved via `host`\n * (`hostRoot()`, or the active `--from` override) through the host manifest\n * — `undefined` when the catalog cannot be established (a missing/unreadable\n * manifest, no `.claude/agents/orkestrel.md` entry, or any other failure),\n * degrading Q1 to shape-only validation instead of blocking on it.\n */\nfunction resolveCatalogNames(host: string): readonly string[] | undefined {\n\ttry {\n\t\tconst manifest = readHostManifest(host)\n\t\tconst full = locateHostSource(manifest, '.claude/agents/orkestrel.md', host)\n\t\tif (full === undefined || !existsSync(full)) return undefined\n\t\treturn catalogNames(readFileSync(full, 'utf8'))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/** One Q1 token's issue against `catalog` (`undefined` = valid) — shape-only (`DEPENDENCY_NAME_PATTERN`) when `catalog` itself could not be resolved. */\nfunction orkestrelTokenIssue(\n\tnormalized: string,\n\tcatalog: readonly string[] | undefined,\n): string | undefined {\n\tif (catalog === undefined) {\n\t\treturn DEPENDENCY_NAME_PATTERN.test(normalized)\n\t\t\t? undefined\n\t\t\t: unknownOrkestrelToken(normalized, undefined)\n\t}\n\tif (catalog.includes(normalized)) return undefined\n\treturn unknownOrkestrelToken(normalized, nearest(normalized, catalog))\n}\n\n/** Q1 (TTY only) — `@orkestrel` short-name deps, re-asking on any unresolved token until the input is clean or empty. */\nasync function promptOrkestrelDeps(\n\tterminal: TerminalInterface,\n\tcatalog: readonly string[] | undefined,\n): Promise<readonly string[]> {\n\tfor (;;) {\n\t\tconst raw = await guarded(terminal.input({ message: orkestrelDepsPrompt(), default: '' }))\n\t\tconst tokens = splitTokens(raw)\n\t\tif (tokens.length === 0) return []\n\t\tconst normalized = tokens.map(normalizeOrkestrelToken)\n\t\tconst issue = normalized\n\t\t\t.map((token) => orkestrelTokenIssue(token, catalog))\n\t\t\t.find((message) => message !== undefined)\n\t\tif (issue === undefined) return normalized\n\t\treporter.line(issue)\n\t}\n}\n\n/** `scaffold new` — scaffold a package into `./<name>` (or `--target`). */\nasync function runNew(values: Values, argument: string | undefined, json: boolean): Promise<void> {\n\tconst terminal = createTerminal()\n\n\tlet name: string\n\tif (argument !== undefined) {\n\t\tname = argument\n\t} else if (json) {\n\t\tusageFail('a package name is required with --json', json)\n\t} else if (!sinkIsTTY) {\n\t\tusageFail(missingInput('a package name', 'new'), json)\n\t} else {\n\t\tname = await guarded(\n\t\t\tterminal.input({\n\t\t\t\tmessage: 'Package name',\n\t\t\t\tvalidate: { pattern: NAME_PATTERN.source },\n\t\t\t}),\n\t\t)\n\t}\n\t// F4: the positional (or interactively-collected) name is validated against\n\t// the SAME `NAME_PATTERN` (core's single source of truth) the interactive\n\t// prompt enforces — a positional name never bypassed this shape before.\n\tif (!NAME_PATTERN.test(name)) {\n\t\tusageFail(invalidName(name, NAME_PATTERN.source), json)\n\t}\n\n\tlet surfaceInput: readonly string[]\n\tif (values.surfaces !== undefined) {\n\t\tsurfaceInput = values.surfaces.split(',')\n\t} else if (json) {\n\t\tusageFail('--surfaces is required with --json', json)\n\t} else if (!sinkIsTTY) {\n\t\tusageFail(missingInput('--surfaces', 'new'), json)\n\t} else {\n\t\tsurfaceInput = await guarded(\n\t\t\tterminal.checkbox({ message: 'Surfaces', choices: surfaceChoices(), min: 1 }),\n\t\t)\n\t}\n\tconst unrecognizedSurface = surfaceInput.filter(\n\t\t(candidate) => !SURFACES.some((surface) => surface === candidate),\n\t)\n\tif (unrecognizedSurface.length > 0) {\n\t\tusageFail(`Surface \"${unrecognizedSurface.join('\", \"')}\" is not recognized`, json)\n\t}\n\tconst surfaces = SURFACES.filter((surface) => surfaceInput.includes(surface))\n\n\t// S3g: containment happens ONCE, here, near the top — before any preview,\n\t// network call, or confirm — so a `--target` escape is caught up front\n\t// rather than after the user has already reviewed a plan for a\n\t// destination the write can never reach.\n\tconst destination = containOrFail(values.target ?? `./${name}`, json)\n\n\t// `--deps` is OPTIONAL — a non-TTY session with neither `--json` nor\n\t// `--deps` defaults to no extra dependencies rather than failing (only a\n\t// REQUIRED input triggers `missingInput`'s usage error); the multi-prompt\n\t// guidance below stays TTY-only (S3f's one-prompt-per-process ceiling).\n\t// `--deps` keeps its EXACT prior mechanism verbatim — untrimmed split,\n\t// `DEPENDENCY_NAME_PATTERN`-gated BEFORE any network call (A3). The\n\t// interactive Q1 replaces only the FREE-TEXT prompt, with short-name\n\t// normalization + vendored-catalog validation (re-asking on an unknown\n\t// token, degrading to shape-only when the catalog cannot be resolved).\n\tlet depNames: readonly string[]\n\tif (values.deps !== undefined) {\n\t\tdepNames = values.deps.split(',').filter((depName) => depName.length > 0)\n\t\tconst badDep = depNames.find((depName) => !DEPENDENCY_NAME_PATTERN.test(depName))\n\t\tif (badDep !== undefined) {\n\t\t\tusageFail(`Dependency name \"${badDep}\" must match ${DEPENDENCY_NAME_PATTERN.source}`, json)\n\t\t}\n\t} else if (json || !sinkIsTTY) {\n\t\tdepNames = []\n\t} else {\n\t\tconst catalogHost = values.from?.[0] ?? hostRoot()\n\t\tconst catalog = resolveCatalogNames(catalogHost)\n\t\tif (catalog === undefined) reporter.line(catalogUnresolvedNote())\n\t\tdepNames = await promptOrkestrelDeps(terminal, catalog)\n\t}\n\n\t// --deps/Q1 resolve latest from the registry → ranges pin ^latest; their\n\t// guides fetch into the plan.\n\tconst sync = createSync()\n\tlet versions\n\ttry {\n\t\tversions = await sync.versions(depNames.map((depName) => dependency(depName, '*')))\n\t} finally {\n\t\tsync.destroy()\n\t}\n\t// `createSync()` is non-strict — it never throws — so a range-less\n\t// `--deps` name that the registry could not resolve (`freshness`\n\t// 'missing'/'failed', `latest` '') is a HARD failure here: writing `^` +\n\t// an empty `latest` would otherwise land an unwritable `\"^\"` range in\n\t// package.json with exit 0.\n\tconst unresolved = versions\n\t\t.filter(\n\t\t\t(version) =>\n\t\t\t\t(version.freshness !== 'current' && version.freshness !== 'behind') ||\n\t\t\t\tversion.latest === '',\n\t\t)\n\t\t.map((version) => version.name)\n\tif (unresolved.length > 0) fail(unresolvedVersion(unresolved), json)\n\tconst deps = versions.map((version) => dependency(version.name, `^${version.latest}`))\n\n\t// Extra devDependencies are no longer collected here — hand-add them to\n\t// `package.json` after scaffolding; `deriveBlueprint`'s extras round-trip\n\t// (`@src/server`) recompiles them back into the plan, so `audit` stays\n\t// clean over a hand-added `devDependencies` entry (AGENTS §21 core stays\n\t// the single source of truth for that relaxation).\n\tconst plan = compileOrFail(blueprint(name, { surfaces, dependencies: deps }), json)\n\n\tconst summary = planToSummary(plan)\n\n\tif (!json) {\n\t\treporter.section('Plan')\n\t\treporter.table(newPlanTable(summary))\n\t\treporter.line(newPlanPreview(name))\n\t}\n\n\tconst proceed = await resolveApply(\n\t\tterminal,\n\t\tapplyConfirmMessage(summary.host + summary.template + summary.computed),\n\t\tvalues,\n\t\tjson,\n\t)\n\n\tif (!proceed) {\n\t\tif (json) writeJson(newJson(summary, false))\n\t\telse reporter.line(NEW_DRY_RUN_NOTE)\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tconst spinner = createSpinnerMaybe('materializing', json)\n\tspinner?.start()\n\tconst materializer = createMaterializer({ host: values.from?.[0] })\n\ttry {\n\t\tconst result = materializer.materialize(plan, destination)\n\t\tconst count = result.written.length + result.copied.length\n\t\tif (json) writeJson(newJson(summary, true))\n\t\telse announceApply(spinner, json, newApplySuccess(count, name))\n\t} catch (error) {\n\t\tannounceFailure(spinner, json, error)\n\t} finally {\n\t\tmaterializer.destroy()\n\t}\n\tprocess.exitCode = 0\n}\n\n/** `scaffold pull` — refresh vendored dependency mirrors and report range drift. */\nasync function runPull(values: Values, json: boolean): Promise<void> {\n\tconst target = containOrFail(values.target ?? '.', json)\n\n\tconst sync = createSync({ strict: values.strict })\n\ttry {\n\t\tconst wanted = values.deps?.split(',')\n\t\tlet report: SyncReport\n\t\ttry {\n\t\t\tconst declared = manifestToDependencies(readManifest(target))\n\t\t\tconst deps = wanted ? declared.filter((dep) => wanted.includes(dep.name)) : declared\n\t\t\tif (wanted) {\n\t\t\t\tconst guides = await sync.guides(deps)\n\t\t\t\tconst versions = await sync.versions(deps)\n\t\t\t\tconst failed = [...guides, ...versions].filter(\n\t\t\t\t\t(entry) => entry.freshness === 'missing' || entry.freshness === 'failed',\n\t\t\t\t).length\n\t\t\t\tconst clean =\n\t\t\t\t\tfailed === 0 &&\n\t\t\t\t\tguides.every((guide) => guide.freshness === 'current') &&\n\t\t\t\t\tversions.every((version) => version.freshness === 'current')\n\t\t\t\treport = { target, guides, versions, clean, failed }\n\t\t\t} else {\n\t\t\t\treport = await sync.pull(target)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfailError(error, json)\n\t\t}\n\n\t\tif (!json) {\n\t\t\treporter.table(pullTable(report))\n\t\t\tfor (const line of pullCauseNotes(report)) reporter.line(line)\n\t\t\treporter.line(pullVerdict(report))\n\t\t}\n\n\t\tconst toWrite = [...report.guides, ...report.versions].filter(\n\t\t\t(entry) => entry.freshness !== 'current',\n\t\t).length\n\n\t\tconst terminal = createTerminal()\n\t\tconst proceed =\n\t\t\ttoWrite > 0 ? await resolveApply(terminal, applyConfirmMessage(toWrite), values, json) : false\n\n\t\tif (proceed) {\n\t\t\tconst spinner = createSpinnerMaybe('writing mirrors', json)\n\t\t\tspinner?.start()\n\t\t\ttry {\n\t\t\t\tconst written = await sync.write(report, target)\n\t\t\t\tif (json) writeJson(pullJson(report))\n\t\t\t\telse announceApply(spinner, json, pullSuccess(written.length))\n\t\t\t} catch (error) {\n\t\t\t\tannounceFailure(spinner, json, error)\n\t\t\t}\n\t\t} else if (json) {\n\t\t\twriteJson(pullJson(report))\n\t\t}\n\n\t\tprocess.exitCode = report.clean ? 0 : proceed ? 0 : 1\n\t} finally {\n\t\tsync.destroy()\n\t}\n}\n\n/** `scaffold audit` — whole-plan conformance report; offers a repair handoff on drift. */\nasync function runAudit(values: Values, json: boolean): Promise<void> {\n\tconst target = containOrFail(values.target ?? '.', json)\n\n\tlet spec: Blueprint\n\ttry {\n\t\tspec = deriveBlueprint(target)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\n\tconst deps: readonly Dependency[] = [...spec.dependencies, ...spec.peers, ...spec.extras]\n\n\tconst groupsInput = values.groups?.split(',')\n\tlet groups: readonly Group[] | undefined\n\tif (groupsInput !== undefined) {\n\t\tconst unrecognized = groupsInput.filter((name) => !GROUPS.some((group) => group === name))\n\t\tif (unrecognized.length > 0) {\n\t\t\tusageFail(`Group \"${unrecognized.join('\", \"')}\" is not recognized`, json)\n\t\t}\n\t\tgroups = GROUPS.filter((group) => groupsInput.includes(group))\n\t}\n\n\tconst compiled = blueprintToPlan(spec, groups)\n\tconst from = values.from?.[0]\n\tconst host = from ?? hostRoot()\n\tlet hydrated: { readonly plan: Plan; readonly aware: boolean }\n\ttry {\n\t\thydrated = hydrateBestEffort(compiled, host, from !== undefined)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\tconst plan = hydrated.plan\n\tconst artifactPaths = plan.artifacts.map((artifact) => artifact.path)\n\n\t// S3b (honest audit): merge the `pruneTargets` scan into the presented\n\t// audit — an \"unexpected file\" is real drift here, not the structurally-\n\t// always-zero `diffPlan.foreign`. Only attempted when the host is actually\n\t// established (`hydrated.aware`) — the same condition `hostRoot`/`--from`\n\t// already require to positively enumerate a vendored allowlist. F3: the\n\t// scan itself degrades (never crashes) when a prune dir exists under\n\t// `target` but `host` cannot establish its allowlist.\n\tconst rawAudit = diffPlan(plan, readTarget(target, artifactPaths))\n\tconst scanned = hydrated.aware\n\t\t? withForeignScanSafe(rawAudit, target, host)\n\t\t: { audit: rawAudit, skipped: false }\n\tconst audit = scanned.audit\n\tlet drifted = !audit.clean\n\n\tlet live:\n\t\t| { readonly current: number; readonly behind: number; readonly failed: number }\n\t\t| undefined\n\tif (values.live) {\n\t\tconst sync = createSync()\n\t\ttry {\n\t\t\tconst guides = await sync.guides(deps)\n\t\t\tconst versions = await sync.versions(deps)\n\t\t\tconst entries = [...guides, ...versions]\n\t\t\tdrifted ||= entries.some((entry) => entry.freshness !== 'current')\n\t\t\tconst current = entries.filter((entry) => entry.freshness === 'current').length\n\t\t\tconst behind = entries.filter((entry) => entry.freshness === 'behind').length\n\t\t\tconst failed = entries.length - current - behind\n\t\t\tlive = { current, behind, failed }\n\t\t} finally {\n\t\t\tsync.destroy()\n\t\t}\n\t}\n\n\tif (json) {\n\t\twriteJson(live === undefined ? auditJson(audit) : { ...auditJson(audit), live })\n\t\tprocess.exitCode = drifted ? 1 : 0\n\t\treturn\n\t}\n\n\tif (scanned.skipped) reporter.line(scanSkipped())\n\treporter.line(comparisonLine(hydrated.aware))\n\treporter.table(auditTable(audit, plan))\n\treporter.line(auditVerdict(audit, plan))\n\tif (live !== undefined) reporter.line(auditLiveNote(live.current, live.behind, live.failed))\n\n\tif (!audit.clean) {\n\t\tconst origins = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact.origin]))\n\t\tconst isOwned = (path: string): boolean =>\n\t\t\torigins.get(path) === 'host' || origins.get(path) === 'template'\n\t\tconst ownedCount = audit.findings.filter(\n\t\t\t(finding) =>\n\t\t\t\tfinding.drift !== 'aligned' && finding.drift !== 'foreign' && isOwned(finding.path),\n\t\t).length\n\t\tconst computedCount = audit.findings.filter(\n\t\t\t(finding) =>\n\t\t\t\tfinding.drift !== 'aligned' && finding.drift !== 'foreign' && !isOwned(finding.path),\n\t\t).length\n\t\tconst pruneRequested = values.prune\n\n\t\t// F1 (audit never writes via flags): the handoff is an INTERACTIVE\n\t\t// convenience only, offered exclusively on a TTY session — `--apply` /\n\t\t// `--yes` NEVER count as handoff consent here (they gate the SEPARATE\n\t\t// `repair` run this branch may launch, never audit's own read-only\n\t\t// pass). F2 (foreign-only handoff dead-end): the handoff also covers\n\t\t// foreign files, but ONLY when `--prune` was passed — an inherited\n\t\t// repair without `--prune` cannot delete them, so offering the handoff\n\t\t// for foreign-only drift without `--prune` would be a dead end.\n\t\tconst offerHandoff = sinkIsTTY && (ownedCount > 0 || (audit.foreign > 0 && pruneRequested))\n\n\t\tlet handoffAccepted = false\n\t\tif (offerHandoff) {\n\t\t\tconst terminal = createTerminal()\n\t\t\tconst message = repairHandoff(ownedCount, audit.foreign, pruneRequested)\n\t\t\thandoffAccepted = await guarded(terminal.confirm({ message, default: false }))\n\t\t\tif (handoffAccepted) {\n\t\t\t\tawait runRepair(values, false)\n\t\t\t\t// S3c (handoff exit truth): repair's own exit code reflects only\n\t\t\t\t// ITS scope — re-diff the FULL plan (host/template/computed AND\n\t\t\t\t// the foreign scan) so the audit's exit code stays truthful about\n\t\t\t\t// ANY drift still remaining, mirroring `runFleet`'s post-repair\n\t\t\t\t// `finalAudit` pattern.\n\t\t\t\tconst rawFinal = diffPlan(plan, readTarget(target, artifactPaths))\n\t\t\t\tconst finalScanned = hydrated.aware\n\t\t\t\t\t? withForeignScanSafe(rawFinal, target, host)\n\t\t\t\t\t: { audit: rawFinal, skipped: false }\n\t\t\t\tprocess.exitCode = finalScanned.audit.clean ? 0 : 1\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (!handoffAccepted) {\n\t\t\t// F2: when the handoff cannot help foreign files (no `--prune`, or no\n\t\t\t// handoff offered at all), point at the one command that can.\n\t\t\tif (audit.foreign > 0 && !pruneRequested) reporter.line(foreignHint())\n\t\t\t// computed-origin drift is regenerated, never hand-edited — `repair`\n\t\t\t// has nothing to offer for it; `generatedNote` says so instead.\n\t\t\tif (computedCount > 0) reporter.line(generatedNote(computedCount))\n\t\t}\n\t}\n\n\tprocess.exitCode = drifted ? 1 : 0\n}\n\n/** `scaffold repair` — restore the shared template-owned set for ONE target. */\nasync function runRepair(values: Values, json: boolean): Promise<void> {\n\tconst target = containOrFail(values.target ?? '.', json)\n\n\tlet spec: Blueprint\n\ttry {\n\t\tspec = deriveBlueprint(target)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\n\tconst compiled = compileOrFail(spec, json)\n\n\t// H2: repair is the host-restoration tool ONLY — scope to host-origin\n\t// artifacts before hydrate/diff/apply so a mature repo's hand-written\n\t// src/tests/guides/package.json is never overwritten with a stub.\n\t// `.github/workflows/ci.yml` STAYS in scope here (unlike `fleet`'s\n\t// exclusion) — single-target `repair --apply` is explicit per-repo intent.\n\tconst scoped: Plan = {\n\t\t...compiled,\n\t\tartifacts: compiled.artifacts.filter((artifact) => artifact.origin === 'host'),\n\t}\n\n\tconst from = values.from?.[0]\n\tconst host = from ?? hostRoot()\n\tlet plan: Plan\n\ttry {\n\t\tplan = hydrateBestEffort(scoped, host, from !== undefined).plan\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\n\tlet audit: Audit\n\ttry {\n\t\taudit = diffPlan(\n\t\t\tplan,\n\t\t\treadTarget(\n\t\t\t\ttarget,\n\t\t\t\tplan.artifacts.map((artifact) => artifact.path),\n\t\t\t),\n\t\t)\n\t} catch (error) {\n\t\tfailError(error, json)\n\t}\n\n\tif (!json) {\n\t\treporter.line(REPAIR_SCOPE)\n\t\treporter.section('Audit')\n\t\treporter.table(auditTable(audit, plan))\n\t}\n\n\t// S3a: the prune preview/confirm are driven by the REAL scan\n\t// (`pruneTargets`), never `audit.foreign` (which `diffPlan` can never\n\t// populate through this call path — it only ever reads the plan's own\n\t// paths). A zero-length scan skips the question entirely and is a no-op.\n\t// U11 F2: computed BEFORE the clean-audit check so `--prune` still reaches\n\t// this scan (and the deletion flow below) on a clean-host repo — a clean\n\t// audit alone no longer bypasses pruning, only a clean audit WITH nothing\n\t// to prune does.\n\tconst prunePaths = values.prune && existsSync(host) ? pruneTargets(target, host) : []\n\n\tif (audit.clean && prunePaths.length === 0) {\n\t\tif (json) {\n\t\t\twriteJson(repairJson(audit))\n\t\t} else {\n\t\t\treporter.line(repairVerdict(audit))\n\t\t\tconst note = scopeNote(repairOutsideCount(compiled, target))\n\t\t\tif (note !== undefined) reporter.line(note)\n\t\t}\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tif (!json) reporter.line(repairVerdict(audit))\n\n\tconst terminal = createTerminal()\n\tlet proceed = true\n\tif (!audit.clean) {\n\t\tproceed = await resolveApply(\n\t\t\tterminal,\n\t\t\tapplyConfirmMessage(audit.drifted + audit.missing + audit.foreign),\n\t\t\tvalues,\n\t\t\tjson,\n\t\t)\n\t}\n\n\tif (!proceed) {\n\t\tif (json) writeJson(repairJson(audit))\n\t\tprocess.exitCode = 1\n\t\treturn\n\t}\n\n\tif (values.prune && !json) {\n\t\tif (prunePaths.length === 0) reporter.line(PRUNE_EMPTY)\n\t\telse for (const line of prunePreview(prunePaths)) reporter.line(line)\n\t}\n\tconst doPrune =\n\t\tprunePaths.length > 0 &&\n\t\t(await resolvePrune(terminal, pruneConfirmMessage(prunePaths.length), values, json))\n\n\tconst spinner = createSpinnerMaybe('repairing', json)\n\tspinner?.start()\n\tconst materializer = createMaterializer({ host: values.from?.[0] })\n\ttry {\n\t\tconst result = materializer.repair(plan, audit, target)\n\t\tconst removed = doPrune ? materializer.prune(target).removed : []\n\t\tif (json) writeJson(repairJson(audit, { ...result, removed }))\n\t\telse announceApply(spinner, json, repairSuccess(result, removed))\n\t} catch (error) {\n\t\tannounceFailure(spinner, json, error)\n\t} finally {\n\t\tmaterializer.destroy()\n\t}\n\tprocess.exitCode = 0\n}\n\n/** `scaffold fleet` — audit/repair every `@orkestrel` package beneath the current directory's immediate children. */\nasync function runFleet(values: Values, json: boolean): Promise<void> {\n\tconst root = containOrFail('.', json)\n\n\tconst packages = discoverPackages(root)\n\tif (packages.length === 0) {\n\t\tfail(\n\t\t\t`no @orkestrel packages under \"${root}\" — fleet scans the immediate children of the current directory; stand in the folder that contains your checkouts (cd ..), or use 'repair' to true up just this repo.`,\n\t\t\tjson,\n\t\t)\n\t}\n\n\tconst from = values.from?.[0]\n\tconst host = from ?? hostRoot()\n\tconst explicit = from !== undefined\n\n\tconst repos: {\n\t\treadonly name: string\n\t\treadonly directory: string\n\t\treadonly plan: Plan\n\t\treadonly audit: Audit\n\t\treadonly aware: boolean\n\t}[] = []\n\tconst failures: { readonly name: string; readonly message: string }[] = []\n\tlet ciExcluded = false\n\n\tfor (const directory of packages) {\n\t\tconst name = basename(directory)\n\t\ttry {\n\t\t\tconst compiler = createCompiler()\n\t\t\tlet scoped: Plan\n\t\t\ttry {\n\t\t\t\tconst spec = deriveBlueprint(directory)\n\t\t\t\tconst scaffolding = compiler.compile(spec)\n\t\t\t\tif (!scaffolding.plan) {\n\t\t\t\t\tconst message = scaffolding.questions.map((question) => question.text).join('; ')\n\t\t\t\t\tthrow new ScaffoldError('INVALID', message)\n\t\t\t\t}\n\t\t\t\t// Fleet apply must never clobber a repo's intentionally divergent\n\t\t\t\t// CI (e.g. ollama, sea) — `.github/workflows/ci.yml` is scoped out\n\t\t\t\t// of `fleet`; single-target `repair` keeps full scope.\n\t\t\t\tscoped = {\n\t\t\t\t\t...scaffolding.plan,\n\t\t\t\t\tartifacts: scaffolding.plan.artifacts.filter(\n\t\t\t\t\t\t(artifact) =>\n\t\t\t\t\t\t\tartifact.origin === 'host' && artifact.path !== '.github/workflows/ci.yml',\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!ciExcluded &&\n\t\t\t\t\tscaffolding.plan.artifacts.some(\n\t\t\t\t\t\t(artifact) => artifact.path === '.github/workflows/ci.yml',\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tif (!json) reporter.line(fleetCiSkipped())\n\t\t\t\t\tciExcluded = true\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tcompiler.destroy()\n\t\t\t}\n\n\t\t\tconst hydrated = hydrateBestEffort(scoped, host, explicit)\n\t\t\tconst plan = hydrated.plan\n\t\t\tconst paths = plan.artifacts.map((artifact) => artifact.path)\n\t\t\tconst rawAudit = diffPlan(plan, readTarget(directory, paths))\n\t\t\t// S3b (honest audit): merge each repo's `pruneTargets` scan in, same\n\t\t\t// as `runAudit` — an unexpected file is real drift here too.\n\t\t\tconst audit = hydrated.aware ? withForeignScan(rawAudit, directory, host) : rawAudit\n\t\t\trepos.push({ name, directory, plan, audit, aware: hydrated.aware })\n\t\t} catch (error) {\n\t\t\tfailures.push({ name, message: describe(error) })\n\t\t}\n\t}\n\n\tif (!json) {\n\t\tfor (const repo of repos) {\n\t\t\treporter.line(\n\t\t\t\tfleetRepoLine(\n\t\t\t\t\trepo.name,\n\t\t\t\t\trepo.audit.clean\n\t\t\t\t\t\t? { kind: 'clean' }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tkind: 'drifted',\n\t\t\t\t\t\t\t\tdrifted: repo.audit.drifted,\n\t\t\t\t\t\t\t\tmissing: repo.audit.missing,\n\t\t\t\t\t\t\t\tforeign: repo.audit.foreign,\n\t\t\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tfor (const failure of failures) {\n\t\t\treporter.line(fleetRepoLine(failure.name, { kind: 'failed', message: failure.message }))\n\t\t}\n\t}\n\n\tconst dirty = repos.filter((repo) => !repo.audit.clean)\n\n\tif (dirty.length === 0) {\n\t\tif (json) {\n\t\t\twriteJson(\n\t\t\t\tfleetJson([\n\t\t\t\t\t...repos.map((repo) => fleetEntry(repo.name, repo.audit, false)),\n\t\t\t\t\t...failures.map((failure) => fleetEntry(failure.name, undefined, true)),\n\t\t\t\t]),\n\t\t\t)\n\t\t} else {\n\t\t\treporter.line(fleetTotals(0, failures.length))\n\t\t}\n\t\tprocess.exitCode = failures.length > 0 ? 1 : 0\n\t\treturn\n\t}\n\n\tconst fileCount = dirty.reduce(\n\t\t(total, repo) => total + repo.audit.drifted + repo.audit.missing + repo.audit.foreign,\n\t\t0,\n\t)\n\n\tconst terminal = createTerminal()\n\tconst proceed = await resolveApply(\n\t\tterminal,\n\t\tapplyConfirmMessage(fileCount, dirty.length),\n\t\tvalues,\n\t\tjson,\n\t)\n\n\t// S3a: fleet's prune preview/confirm are driven by the REAL per-repo scan\n\t// (`pruneTargets`), never `audit.foreign` — each unexpected path is shown\n\t// `<repo>/<path>`-prefixed so the fleet-wide preview stays legible. Scanned\n\t// only when `host` itself is establishable (`existsSync`) — same\n\t// precondition `hydrateBestEffort` already gates awareness on; an\n\t// unestablished host degrades to a no-op prune, never a thrown scan.\n\tconst prunePaths =\n\t\tproceed && values.prune && existsSync(host)\n\t\t\t? dirty.flatMap((repo) =>\n\t\t\t\t\tpruneTargets(repo.directory, host).map((path) => `${repo.name}/${path}`),\n\t\t\t\t)\n\t\t\t: []\n\tif (proceed && values.prune && !json) {\n\t\tif (prunePaths.length === 0) reporter.line(PRUNE_EMPTY)\n\t\telse for (const line of prunePreview(prunePaths)) reporter.line(line)\n\t}\n\tconst doPrune =\n\t\tproceed &&\n\t\tprunePaths.length > 0 &&\n\t\t(await resolvePrune(terminal, pruneConfirmMessage(prunePaths.length), values, json))\n\n\tif (!proceed) {\n\t\tif (json) {\n\t\t\twriteJson(\n\t\t\t\tfleetJson([\n\t\t\t\t\t...repos.map((repo) => fleetEntry(repo.name, repo.audit, false)),\n\t\t\t\t\t...failures.map((failure) => fleetEntry(failure.name, undefined, true)),\n\t\t\t\t]),\n\t\t\t)\n\t\t} else {\n\t\t\treporter.line(fleetTotals(dirty.length, failures.length))\n\t\t}\n\t\tprocess.exitCode = 1\n\t\treturn\n\t}\n\n\tconst materializer = createMaterializer({ host })\n\tlet drifted = 0\n\tlet failedCount = failures.length\n\tconst entries: ReturnType<typeof fleetEntry>[] = repos\n\t\t.filter((repo) => repo.audit.clean)\n\t\t.map((repo) => fleetEntry(repo.name, repo.audit, false))\n\n\ttry {\n\t\tfor (const repo of dirty) {\n\t\t\ttry {\n\t\t\t\tmaterializer.repair(repo.plan, repo.audit, repo.directory)\n\t\t\t\tif (doPrune) materializer.prune(repo.directory)\n\t\t\t\tconst paths = repo.plan.artifacts.map((artifact) => artifact.path)\n\t\t\t\tconst rawFinal = diffPlan(repo.plan, readTarget(repo.directory, paths))\n\t\t\t\tconst finalAudit = repo.aware ? withForeignScan(rawFinal, repo.directory, host) : rawFinal\n\t\t\t\tif (!finalAudit.clean) drifted += 1\n\t\t\t\tentries.push(fleetEntry(repo.name, finalAudit, false))\n\t\t\t\tif (!json) {\n\t\t\t\t\treporter.line(\n\t\t\t\t\t\tfleetRepoLine(repo.name, {\n\t\t\t\t\t\t\tkind: 'repaired',\n\t\t\t\t\t\t\tremaining: finalAudit.drifted + finalAudit.missing + finalAudit.foreign,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tfailedCount += 1\n\t\t\t\tentries.push(fleetEntry(repo.name, undefined, true))\n\t\t\t\tif (!json) {\n\t\t\t\t\treporter.line(fleetRepoLine(repo.name, { kind: 'failed', message: describe(error) }))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tmaterializer.destroy()\n\t}\n\n\tif (json) {\n\t\twriteJson(\n\t\t\tfleetJson([\n\t\t\t\t...entries,\n\t\t\t\t...failures.map((failure) => fleetEntry(failure.name, undefined, true)),\n\t\t\t]),\n\t\t)\n\t} else {\n\t\treporter.line(fleetTotals(drifted, failedCount))\n\t}\n\tprocess.exitCode = drifted > 0 || failedCount > 0 ? 1 : 0\n}\n\n/** `scaffold catalog` — regenerate the fleet package catalog table embedded in `.claude/agents/orkestrel.md`. */\nasync function runCatalog(values: Values, json: boolean): Promise<void> {\n\tconst target = containOrFail(values.target ?? '.', json)\n\n\tconst explicitRoots = values.from\n\tlet entries: readonly CatalogEntry[]\n\tlet published = 0\n\tlet localOnly = 0\n\tconst notes = new Map<string, string>()\n\n\tif (values.offline) {\n\t\tconst roots = explicitRoots ?? [process.cwd()]\n\t\ttry {\n\t\t\tentries = catalogPackages(roots)\n\t\t} catch (error) {\n\t\t\tfailError(error, json)\n\t\t}\n\t} else {\n\t\tconst sync = createSync({\n\t\t\ton: {\n\t\t\t\tpackage: (name, note) => {\n\t\t\t\t\tif (note !== '') notes.set(name, note)\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tlet registryEntries: readonly CatalogEntry[]\n\t\ttry {\n\t\t\tregistryEntries = await sync.catalog()\n\t\t} catch (error) {\n\t\t\tfailError(error, json)\n\t\t} finally {\n\t\t\tsync.destroy()\n\t\t}\n\t\tpublished = registryEntries.length\n\n\t\tlet localEntries: readonly CatalogEntry[] = []\n\t\tif (explicitRoots !== undefined) {\n\t\t\ttry {\n\t\t\t\tlocalEntries = catalogPackages(explicitRoots)\n\t\t\t} catch (error) {\n\t\t\t\tfailError(error, json)\n\t\t\t}\n\t\t}\n\n\t\tconst merged = new Map<string, CatalogEntry>()\n\t\tfor (const entry of registryEntries) merged.set(entry.name, entry)\n\t\tfor (const local of localEntries) {\n\t\t\tconst existing = merged.get(local.name)\n\t\t\tif (existing === undefined) {\n\t\t\t\tmerged.set(local.name, local)\n\t\t\t\tlocalOnly += 1\n\t\t\t} else if (local.description.length > 0) {\n\t\t\t\tmerged.set(local.name, { ...existing, description: local.description })\n\t\t\t}\n\t\t}\n\t\tentries = [...merged.values()].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))\n\t}\n\n\tconst block = catalogToBlock(entries)\n\t// S3g: the LEAF write path is re-confined (same mechanism as every other\n\t// verb's destination) — `target` itself passed containment, but a\n\t// symlinked segment nested BENEATH it (e.g. a symlinked `.claude`) could\n\t// still let this specific path escape the cwd.\n\tconst agentPath = containOrFail(join(target, '.claude', 'agents', 'orkestrel.md'), json)\n\tlet current: string\n\ttry {\n\t\tcurrent = readFileSync(agentPath, 'utf8')\n\t} catch (error) {\n\t\tfailError(\n\t\t\tnew ScaffoldError('TARGET', `Failed to read ${agentPath}`, { path: agentPath, error }),\n\t\t\tjson,\n\t\t)\n\t}\n\n\tconst startMarker = '<!-- catalog:start -->'\n\tconst endMarker = '<!-- catalog:end -->'\n\tconst startIndex = current.indexOf(startMarker)\n\tconst endIndex = current.indexOf(endMarker)\n\tif (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {\n\t\tfailError(\n\t\t\tnew ScaffoldError(\n\t\t\t\t'TARGET',\n\t\t\t\t`Markers \"${startMarker}\" / \"${endMarker}\" not found in ${agentPath}`,\n\t\t\t\t{ path: agentPath },\n\t\t\t),\n\t\t\tjson,\n\t\t)\n\t}\n\n\tconst before = current.slice(0, startIndex + startMarker.length)\n\tconst after = current.slice(endIndex)\n\tconst updated = `${before}\\n\\n${block}\\n${after}`\n\n\tconst oldBlock = current.slice(startIndex + startMarker.length, endIndex)\n\tconst oldRows = catalogNames(oldBlock).length\n\tconst shrink = entries.length < oldRows ? oldRows - entries.length : undefined\n\n\tif (updated === current) {\n\t\tif (json) writeJson(catalogJson(entries, false))\n\t\telse reporter.line(catalogVerdict(true))\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tif (!json) {\n\t\treporter.table(catalogTable(entries))\n\t\tconst warning = catalogShrinkWarning(oldRows, entries.length)\n\t\tif (warning !== undefined) reporter.line(warning)\n\t\tif (values.offline) {\n\t\t\tconst missingDescription = entries\n\t\t\t\t.filter((entry) => entry.description.length === 0)\n\t\t\t\t.map((entry) => entry.name)\n\t\t\tif (missingDescription.length > 0) {\n\t\t\t\treporter.line(\n\t\t\t\t\t`${missingDescription.length} without guide description: ${missingDescription.join(', ')}`,\n\t\t\t\t)\n\t\t\t}\n\t\t} else {\n\t\t\treporter.line(catalogCounts(published, localOnly))\n\t\t\tfor (const [name, note] of notes) reporter.line(` ${name}: ${note}`)\n\t\t}\n\t}\n\n\tconst terminal = createTerminal()\n\tconst proceed = await resolveApply(terminal, applyConfirmMessage(1), values, json)\n\n\tif (!proceed) {\n\t\tif (json) writeJson(catalogJson(entries, true, shrink))\n\t\telse reporter.line(catalogVerdict(false))\n\t\tprocess.exitCode = 1\n\t\treturn\n\t}\n\n\ttry {\n\t\twriteFileSync(agentPath, updated, 'utf8')\n\t} catch (error) {\n\t\tfailError(\n\t\t\tnew ScaffoldError('TARGET', `Failed to write ${agentPath}`, { path: agentPath, error }),\n\t\t\tjson,\n\t\t)\n\t}\n\tif (json) writeJson(catalogJson(entries, true, shrink))\n\telse reporter.status('success', catalogApplySuccess(agentPath))\n\tprocess.exitCode = 0\n}\n\n/**\n * The whole command dispatch — a single top-level driver (no nested function\n * declarations, AGENTS §4). Every verb sets `process.exitCode` (never\n * `process.exit`, H4) and returns, or `halt()`s through a `finally` that\n * tears its entities down first; the caller at the bottom of this file\n * catches exactly one sentinel (`CliExit`) and stops.\n */\nasync function main(): Promise<void> {\n\tlet parsed: ReturnType<typeof parseArguments>\n\ttry {\n\t\tparsed = parseArguments()\n\t} catch (error) {\n\t\tprocess.stderr.write(`${error instanceof Error ? error.message : INVALID_ARGUMENTS_MESSAGE}\\n`)\n\t\tprocess.exitCode = 2\n\t\treturn\n\t}\n\n\tconst { values, positionals } = parsed\n\tconst [command, argument] = positionals\n\tconst json = values.json === true\n\tsessionJson = json\n\n\tif (command === undefined) {\n\t\tprocess.stdout.write(`${values.help ? fullHelp() : shortUsage()}\\n`)\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tif (!isVerb(command)) {\n\t\tusageFail(didYouMean(command), json)\n\t}\n\n\tif (values.help) {\n\t\tprocess.stdout.write(`${verbHelp(command)}\\n`)\n\t\tprocess.exitCode = 0\n\t\treturn\n\t}\n\n\tif (command === 'new') return runNew(values, argument, json)\n\tif (command === 'pull') return runPull(values, json)\n\tif (command === 'audit') return runAudit(values, json)\n\tif (command === 'repair') return runRepair(values, json)\n\tif (command === 'fleet') return runFleet(values, json)\n\treturn runCatalog(values, json)\n}\n\ntrustSystemCertificates()\n\ntry {\n\tawait main()\n} catch (error) {\n\tif (error instanceof CliExit) {\n\t\tprocess.exitCode = error.code\n\t} else if (sessionJson) {\n\t\tconst code = isScaffoldError(error) ? error.code : 'ERROR'\n\t\tconst message = isScaffoldError(error) ? error.message : describe(error)\n\t\twriteJson(errorEnvelope(code, message))\n\t\tprocess.exitCode = 1\n\t} else {\n\t\treporter.status('error', describe(error))\n\t\tprocess.exitCode = 1\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,IAAa,cAAc,OAAO,OAAO;CACxC;CACA;CACA;CACA;CACA;CACA;AACD,CAAU;;AAMV,IAAa,eAAiD,OAAO,OAAO;CAC3E,MAAM;CACN,UAAU;CACV,UAAU;AACX,CAAC;;AAGD,IAAa,cAA+C,OAAO,OAAO;CACzE,SAAS;CACT,OAAO;CACP,SAAS;CACT,SAAS;AACV,CAAC;;AAGD,IAAa,kBAAoD,OAAO,OAAO;CAC9E,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;AACT,CAAC;;AAGD,IAAa,eAAiD,OAAO,OAAO;CAC3E,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;AACV,CAAC;;AAGD,SAAgB,UAAU,OAAe,OAAuB;CAC/D,OAAO,GAAG,MAAM,GAAG,QAAQ,UAAU,IAAI,KAAK;AAC/C;;AAGA,SAAgB,WAAW,QAIhB;CACV,MAAM,QAAkB,CAAC;CACzB,IAAI,OAAO,UAAU,GAAG,MAAM,KAAK,UAAU,OAAO,SAAS,SAAS,CAAC;CACvE,IAAI,OAAO,UAAU,GAAG,MAAM,KAAK,UAAU,OAAO,SAAS,SAAS,CAAC;CACvE,IAAI,OAAO,UAAU,GAAG,MAAM,KAAK,UAAU,OAAO,SAAS,YAAY,CAAC;CAC1E,OAAO,MAAM,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI;AAC9C;;;;;;AAOA,SAAgB,gBACf,UACA,MAQC;CACD,MAAM,UAAU,IAAI,IAAI,KAAK,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,SAAS,MAAM,CAAC,CAA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