@orkestrel/scaffold 0.0.30 → 0.0.32

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":"main.js","names":["#stdout","#stderr","#output","#diagnostic","#upstream","#say","#refuse","#dispatch","#create","#inspect","#restore","#refresh","#replace","#environments","#resolve","#packages","#compile","#report","#tally","#derive","#projectQuestion","#survey","#groups","#present","#assertProjects","#warn","#previous","#fetch","#publish","#recount","#repository","#merge","#reconcile","#lookup","#pin","#manifest","#probe","#scriptProjects","#inventory","#sanitize"],"sources":["../../src/bin/constants.ts","../../src/bin/errors.ts","../../src/bin/helpers.ts","../../src/bin/CLI.ts","../../src/bin/main.ts"],"sourcesContent":["import type { ParseArgsOptionsConfig } from 'node:util'\nimport type { Verb } from './types.js'\n\n/**\n * The name the executable installs as.\n *\n * @remarks\n * `package.json`'s `bin` field is the authority for what the command is called;\n * this is the same word, so every usage line the executable prints is a command\n * a reader can paste back.\n */\nexport const EXECUTABLE_NAME = 'scaffold'\n\n/**\n * The five {@link Verb} values in usage order, frozen.\n *\n * @remarks\n * The order the type declares them in, which is also the order usage lists them:\n * the verb that creates a workspace, then the one that only reads it, then the\n * three that write to one that already exists, widest last.\n */\nexport const VERBS: readonly Verb[] = Object.freeze([\n\t'new',\n\t'audit',\n\t'repair',\n\t'catalog',\n\t'overwrite',\n])\n\n/** The exit code reporting that the target matched its plan and every step completed. */\nexport const EXIT_CLEAN = 0\n\n/** The exit code reporting that the target drifted, or that a step failed. */\nexport const EXIT_DRIFT = 1\n\n/** The exit code reporting that the command line was not a command. */\nexport const EXIT_USAGE = 2\n\n/**\n * What each exit code means, frozen.\n *\n * @remarks\n * Keyed by the three code constants rather than by literals, so the usage block\n * cannot document a code the executable does not return.\n */\nexport const EXIT_SUMMARY: Readonly<Record<number, string>> = Object.freeze({\n\t[EXIT_CLEAN]: 'clean',\n\t[EXIT_DRIFT]: 'drift or failure',\n\t[EXIT_USAGE]: 'usage error',\n})\n\n/**\n * The machine-readable code a malformed command line reports.\n *\n * @remarks\n * The executable contributes its own codes to the failure envelope, which is why\n * that envelope's `code` is a plain string rather than a `ScaffoldErrorCode`: a\n * command line that never became a command failed before any coded package\n * operation could.\n */\nexport const USAGE_CODE = 'USAGE'\n\n/** The machine-readable code a failure carrying no code of its own reports. */\nexport const FAILED_CODE = 'FAILED'\n\n/** What the failure envelope says when the raised value carried no message. */\nexport const FAILED_MESSAGE = 'The command failed for an unrecognized reason'\n\n/**\n * The positional argument `new` alone takes, as usage writes it.\n *\n * @remarks\n * The workspace name is the only positional argument any verb takes, so it is\n * one value rather than a per-verb table with four holes in it.\n */\nexport const NAME_ARGUMENT = '<name>'\n\n/**\n * Every option the executable accepts, as `node:util` parses them, frozen.\n *\n * @remarks\n * One table for every verb rather than one per verb, because the verb an option\n * belongs to is a domain fact the command union already fixes: parsing decides\n * only whether the word is an option at all, and {@link VERB_OPTIONS} decides\n * whether this verb takes it. No option declares a default, so the parsed keys\n * are exactly the options the caller supplied, which is what makes an option\n * offered to the wrong verb visible rather than silently absorbed. `from`\n * collects repeats because `catalog` may draw on more than one local source; a\n * verb that takes it once refuses the second.\n */\nexport const COMMAND_OPTIONS: ParseArgsOptionsConfig = Object.freeze({\n\tsrc: Object.freeze({ type: 'string' }),\n\tapp: Object.freeze({ type: 'string' }),\n\tbin: Object.freeze({ type: 'boolean' }),\n\tdeps: Object.freeze({ type: 'string' }),\n\tgroups: Object.freeze({ type: 'string' }),\n\tall: Object.freeze({ type: 'boolean' }),\n\tdirty: Object.freeze({ type: 'boolean' }),\n\tfrom: Object.freeze({ type: 'string', multiple: true }),\n\ttarget: Object.freeze({ type: 'string' }),\n\tjson: Object.freeze({ type: 'boolean' }),\n})\n\n/**\n * What each option does, keyed by the token usage prints, frozen.\n *\n * @remarks\n * The key order is the glossary order. A key is the whole displayed token,\n * value placeholder included, because that token is what a reader copies and\n * what {@link VERB_OPTIONS} lists.\n */\nexport const OPTION_SUMMARY: Readonly<Record<string, string>> = Object.freeze({\n\t'--src <list>': 'the published library environments to build: core, browser, server',\n\t'--app <list>': 'the private application environments to build: core, browser, server',\n\t'--bin': 'scaffold a command-line executable at src/bin/main.ts',\n\t'--deps <list>': 'the @orkestrel/* packages the workspace depends on',\n\t'--groups <list>': 'the artifact groups to cover; every group when absent',\n\t'--all': 'fetch a guide for every package the organization publishes, not just the declared ones',\n\t'--dirty': 'delete from a tree carrying uncommitted changes',\n\t'--from <path>':\n\t\t'read the data root from a local path instead of the bundled one; catalog alone accepts it more than once',\n\t'--target <path>': 'the directory the verb operates on; the working directory when absent',\n\t'--json': 'emit one machine-readable value instead of a report',\n})\n\n/**\n * The options each verb takes, in usage order, frozen.\n *\n * @remarks\n * The executable's half of the frozen command union: every option a branch\n * declares is listed against its verb, and every option a branch excludes is\n * absent from it. An option a verb does not list is refused by name rather than\n * parsed and ignored.\n */\nexport const VERB_OPTIONS: Readonly<Record<Verb, readonly string[]>> = Object.freeze({\n\tnew: Object.freeze([\n\t\t'--src <list>',\n\t\t'--app <list>',\n\t\t'--bin',\n\t\t'--deps <list>',\n\t\t'--from <path>',\n\t\t'--target <path>',\n\t\t'--json',\n\t]),\n\taudit: Object.freeze(['--groups <list>', '--from <path>', '--target <path>', '--json']),\n\trepair: Object.freeze(['--groups <list>', '--from <path>', '--target <path>', '--json']),\n\tcatalog: Object.freeze(['--all', '--from <path>', '--target <path>', '--json']),\n\toverwrite: Object.freeze([\n\t\t'--groups <list>',\n\t\t'--dirty',\n\t\t'--from <path>',\n\t\t'--target <path>',\n\t\t'--json',\n\t]),\n})\n\n/**\n * What each verb does, in one line, frozen.\n *\n * @remarks\n * Each line names what the verb writes, because authority is the verb's: a\n * reader deciding which one to run is deciding what they are authorizing.\n */\nexport const VERB_SUMMARY: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'scaffold a workspace',\n\taudit: 'report how the target compares to its plan, writing nothing',\n\trepair: 'write each planned path the target is missing or has let drift',\n\tcatalog: 'regenerate the package table and refresh the guide mirrors',\n\toverwrite:\n\t\t'do everything repair and catalog do, then delete what the plan does not own and re-declare the dependency ranges',\n})\n","import { USAGE_CODE } from './constants.js'\n\n/**\n * The error raised when a command line is not a command.\n *\n * @remarks\n * Distinct from `ScaffoldError` because the two answer different questions and\n * exit differently: a `ScaffoldError` says the package could not serve a\n * well-formed request and exits `1`, while this says there was no request to\n * serve and exits `2`. Folding a usage error into `INVALID` would report a\n * mistyped flag as a failed run.\n *\n * It carries no `context`. Everything a caller can act on is in the message,\n * because the reader of a usage error is a person at a terminal rather than a\n * program branching on a cause.\n *\n * @example\n * ```ts\n * import { isUsageError, UsageError } from './errors.js'\n *\n * try {\n * \tthrow new UsageError(\"Unknown command 'pull'.\")\n * } catch (error) {\n * \tif (isUsageError(error)) error.code // 'USAGE'\n * }\n * ```\n */\nexport class UsageError extends Error {\n\treadonly code: string\n\n\t/**\n\t * Construct a usage error.\n\t *\n\t * @param message - What was wrong with the command line, in one sentence.\n\t */\n\tconstructor(message: string) {\n\t\tsuper(message)\n\t\tthis.name = 'UsageError'\n\t\tthis.code = USAGE_CODE\n\t}\n}\n\n/**\n * Narrow a caught value to a {@link UsageError}.\n *\n * @param value - The caught value to narrow.\n * @returns `true` when `value` is a {@link UsageError}.\n *\n * @example\n * ```ts\n * import { isUsageError } from './errors.js'\n *\n * isUsageError(new Error('plain')) // false\n * isUsageError(undefined) // false\n * ```\n */\nexport function isUsageError(value: unknown): value is UsageError {\n\treturn value instanceof UsageError\n}\n","import type { Audit } from '@src/core'\nimport type { CLICommand, ErrorEnvelope, Verb } from './types.js'\nimport { align, width } from '@orkestrel/console'\nimport { attempt } from '@orkestrel/contract'\nimport { isScaffoldError } from '@src/core'\nimport { parseArgs } from 'node:util'\nimport {\n\tCOMMAND_OPTIONS,\n\tEXECUTABLE_NAME,\n\tEXIT_CLEAN,\n\tEXIT_DRIFT,\n\tEXIT_SUMMARY,\n\tFAILED_CODE,\n\tFAILED_MESSAGE,\n\tNAME_ARGUMENT,\n\tOPTION_SUMMARY,\n\tVERB_OPTIONS,\n\tVERB_SUMMARY,\n\tVERBS,\n} from './constants.js'\nimport { isUsageError, UsageError } from './errors.js'\n\n/**\n * Read the option name out of the token usage displays it as.\n *\n * @param option - The displayed token, such as `--from <path>`.\n * @returns The bare name `node:util` parses the option under.\n *\n * @remarks\n * One token serves both readers: a person reads the value placeholder and the\n * parser reads the name in front of it. Deriving the name means a documented\n * option and an accepted option cannot be two different lists.\n *\n * @example\n * ```ts\n * import { optionToName } from './helpers.js'\n *\n * optionToName('--from <path>') // 'from'\n * optionToName('--json') // 'json'\n * ```\n */\nexport function optionToName(option: string): string {\n\tconst [token = option] = option.split(' ')\n\treturn token.startsWith('--') ? token.slice(2) : token\n}\n\n/**\n * Render one verb's synopsis.\n *\n * @param verb - The verb to describe.\n * @returns The command line this verb accepts, with every option bracketed.\n *\n * @remarks\n * The synopsis is derived from the verb's own option list rather than stored\n * beside it, so a line that documents an option the verb does not take cannot be\n * written. `new` alone carries the positional argument.\n *\n * @example\n * ```ts\n * import { verbToSyntax } from './helpers.js'\n *\n * verbToSyntax('audit') // 'scaffold audit [--groups <list>] …'\n * ```\n */\nexport function verbToSyntax(verb: Verb): string {\n\tconst argument = verb === 'new' ? ` ${NAME_ARGUMENT}` : ''\n\tconst options = VERB_OPTIONS[verb].map((option) => `[${option}]`).join(' ')\n\treturn `${EXECUTABLE_NAME} ${verb}${argument} ${options}`\n}\n\n/**\n * Render the whole command reference.\n *\n * @returns One line per output call: the synopsis, every verb, the option glossary, and the exit codes.\n *\n * @remarks\n * Returned as lines because the executable writes through a handler that takes\n * one line, so the caller never has to split a block back apart. The glossary is\n * printed once for every verb rather than repeated per verb, since seven of the\n * nine options are shared and a reader comparing two verbs wants the difference,\n * not the repetition.\n */\nexport function renderUsage(): readonly string[] {\n\tconst summaries = Object.entries(OPTION_SUMMARY)\n\tconst column = Math.max(...summaries.map(([option]) => width(option)))\n\treturn [\n\t\t`${EXECUTABLE_NAME} <verb> [options]`,\n\t\t'',\n\t\t...VERBS.flatMap((verb) => [` ${verbToSyntax(verb)}`, ` ${VERB_SUMMARY[verb]}`]),\n\t\t'',\n\t\t'options',\n\t\t...summaries.map(([option, summary]) => ` ${align(option, column)} ${summary}`),\n\t\t'',\n\t\t'exit codes',\n\t\t...Object.entries(EXIT_SUMMARY).map(([code, meaning]) => ` ${code} ${meaning}`),\n\t]\n}\n\n/**\n * Read one command out of the arguments following the executable's own name.\n *\n * @param argv - The arguments the executable was given.\n * @returns The command the arguments denote.\n * @throws {@link UsageError} when they denote no command.\n *\n * @remarks\n * The one place untrusted argument text becomes a domain value, and it stays one\n * function because the command union admits no partial command to hand on: every\n * refusal has to happen before the value exists. It refuses in four ways, each\n * naming what was wrong — a word that is not a verb, a word that is not an\n * option, an option this verb does not take, and an argument this verb does not\n * take. `node:util` decides the second and this decides the rest, so an unknown\n * option is reported by the parser that found it rather than re-derived here.\n *\n * A request for usage is not a command and never reaches this: the caller\n * answers it first.\n *\n * @example\n * ```ts\n * import { argvToCommand } from './helpers.js'\n *\n * argvToCommand(['audit', '--json']) // { verb: 'audit', json: true }\n * ```\n */\nexport function argvToCommand(argv: readonly string[]): CLICommand {\n\tconst [head, ...rest] = argv\n\tconst verb = VERBS.find((candidate) => candidate === head)\n\tif (verb === undefined) {\n\t\tconst found = head === undefined ? 'No command given.' : `Unknown command '${head}'.`\n\t\tthrow new UsageError(`${found} Run '${EXECUTABLE_NAME} --help' for the command list.`)\n\t}\n\tconst parsed = attempt(() =>\n\t\tparseArgs({ args: rest, options: COMMAND_OPTIONS, allowPositionals: true, strict: true }),\n\t)\n\tif (!parsed.success) {\n\t\tconst cause = parsed.error\n\t\tthrow new UsageError(\n\t\t\tcause instanceof Error ? cause.message : `Could not read the arguments to '${verb}'.`,\n\t\t)\n\t}\n\tconst { positionals, values } = parsed.value\n\tconst accepted = VERB_OPTIONS[verb].map((option) => optionToName(option))\n\tconst refused = Object.keys(values).filter((name) => !accepted.includes(name))\n\tif (refused.length > 0) {\n\t\tconst names = refused.map((name) => `--${name}`).join(', ')\n\t\tthrow new UsageError(`'${verb}' does not take ${names}.`)\n\t}\n\tconst [name] = positionals\n\tif (positionals.length > 1) {\n\t\tthrow new UsageError(\n\t\t\t`'${verb}' takes at most one argument, and was given ${String(positionals.length)}.`,\n\t\t)\n\t}\n\tif (verb !== 'new' && name !== undefined) {\n\t\tthrow new UsageError(`'${verb}' takes no argument, and was given '${name}'.`)\n\t}\n\tconst paths = Array.isArray(values.from)\n\t\t? values.from.filter((value) => typeof value === 'string')\n\t\t: []\n\tif (verb !== 'catalog' && paths.length > 1) {\n\t\tthrow new UsageError(\n\t\t\t`'${verb}' takes --from once, and was given it ${String(paths.length)} times.`,\n\t\t)\n\t}\n\tconst src = typeof values.src === 'string' ? values.src : undefined\n\tconst app = typeof values.app === 'string' ? values.app : undefined\n\tconst bin = values.bin === true\n\tconst dependencies = typeof values.deps === 'string' ? values.deps : undefined\n\tconst target = typeof values.target === 'string' ? values.target : undefined\n\tconst json = values.json === true\n\tconst [from] = paths\n\tconst location = target === undefined ? {} : { target }\n\tconst source = from === undefined ? {} : { from }\n\tconst selection = typeof values.groups === 'string' ? { groups: values.groups } : {}\n\tswitch (verb) {\n\t\tcase 'new':\n\t\t\tif (name === undefined) {\n\t\t\t\tthrow new UsageError(`'new' needs the workspace ${NAME_ARGUMENT} it is scaffolding.`)\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tverb,\n\t\t\t\tname,\n\t\t\t\tjson,\n\t\t\t\t...location,\n\t\t\t\t...source,\n\t\t\t\t...(src === undefined ? {} : { src }),\n\t\t\t\t...(app === undefined ? {} : { app }),\n\t\t\t\t...(bin ? { bin } : {}),\n\t\t\t\t...(dependencies === undefined ? {} : { dependencies }),\n\t\t\t}\n\t\tcase 'audit':\n\t\t\treturn { verb, json, ...location, ...source, ...selection }\n\t\tcase 'repair':\n\t\t\treturn { verb, json, ...location, ...source, ...selection }\n\t\tcase 'catalog':\n\t\t\treturn {\n\t\t\t\tverb,\n\t\t\t\tjson,\n\t\t\t\tall: values.all === true,\n\t\t\t\t...location,\n\t\t\t\t...(paths.length === 0 ? {} : { from: paths }),\n\t\t\t}\n\t\tcase 'overwrite':\n\t\t\treturn {\n\t\t\t\tverb,\n\t\t\t\tjson,\n\t\t\t\tdirty: values.dirty === true,\n\t\t\t\t...location,\n\t\t\t\t...source,\n\t\t\t\t...selection,\n\t\t\t}\n\t}\n}\n\n/**\n * Read the exit code an audit reports.\n *\n * @param audit - The comparison of a plan against a target.\n * @returns `EXIT_CLEAN` when the target matched the plan, `EXIT_DRIFT` otherwise.\n *\n * @remarks\n * One rule for every verb that carries an audit, so `audit`, `repair`, and\n * `overwrite` cannot disagree about what a clean run is. A blocking question\n * means the gate refused the blueprint, so the audit says nothing about the\n * target and the run is a failure. A foreign finding counts: the target holds a\n * file the plan does not own, which is a difference from the plan whether or not\n * this verb was allowed to remove it. A non-blocking question rides a complete\n * result and does not.\n *\n * @example\n * ```ts\n * import { auditToExit } from './helpers.js'\n *\n * auditToExit({ findings: [], questions: [] }) // 0\n * ```\n */\nexport function auditToExit(audit: Audit): number {\n\tconst blocked = audit.questions.some((question) => question.blocking)\n\tconst drifted = audit.findings.some((finding) => finding.drift !== 'aligned')\n\treturn blocked || drifted ? EXIT_DRIFT : EXIT_CLEAN\n}\n\n/**\n * Project an audit into the human summary of its outcome.\n *\n * @param audit - The comparison to summarize.\n * @returns The refusal, or the planned-path outcome, its grounds, and any foreign-path count.\n *\n * @remarks\n * A blocking question means the gate produced no plan, so the target was not\n * compared and no finding count is reported. Otherwise the three grounds\n * describe what this run did. `bytes` means content-owned\n * bytes were observed, `existence` means presence or absence alone decided the\n * finding, and `nothing` means a birth-owned path was not examined. Foreign\n * paths remain a separate population because no planned ownership accounts for\n * them.\n *\n * @example\n * ```ts\n * import { auditToSummary } from './helpers.js'\n *\n * auditToSummary({\n * findings: [],\n * questions: [{ field: 'src', message: 'Core is required.', blocking: true }],\n * })\n * // 'Audit did not compare the target because the blueprint was refused.'\n * ```\n */\nexport function auditToSummary(audit: Audit): string {\n\tif (audit.questions.some((question) => question.blocking)) {\n\t\treturn 'Audit did not compare the target because the blueprint was refused.'\n\t}\n\tconst planned = audit.findings.filter((finding) => finding.drift !== 'foreign')\n\tconst drifted = planned.filter((finding) => finding.drift !== 'aligned').length\n\t// These counts say what decided each verdict on this run. They partition the\n\t// planned findings, so they sum to `planned.length` and never to `drifted`.\n\tconst bytes = planned.filter(\n\t\t(finding) => finding.ownership === 'content' && finding.observed !== undefined,\n\t).length\n\tconst existence = planned.filter(\n\t\t(finding) =>\n\t\t\tfinding.ownership === 'presence' ||\n\t\t\t(finding.ownership === 'content' && finding.drift === 'missing'),\n\t).length\n\tconst nothing = planned.filter((finding) => finding.ownership === 'birth').length\n\tconst foreign = audit.findings.length - planned.length\n\tconst summary = `${String(drifted)} of ${String(planned.length)} planned path${planned.length === 1 ? '' : 's'} drifted from the plan. Audit compared bytes at ${String(bytes)}, existence at ${String(existence)}, and nothing at ${String(nothing)}.`\n\treturn foreign === 0\n\t\t? summary\n\t\t: `${summary} The plan does not own ${String(foreign)} further path${foreign === 1 ? '' : 's'} beneath its groups.`\n}\n\n/**\n * Project a raised value into the machine-readable failure envelope.\n *\n * @param error - The value a command raised.\n * @returns The envelope naming the coded reason and what went wrong.\n *\n * @remarks\n * A `ScaffoldError` and a {@link UsageError} both publish a code, so both are\n * reported under their own. Anything else failed without saying why, and is\n * reported under one code rather than under an invented reading of it; a raised\n * value that is not an `Error` carries no message worth quoting, so the envelope\n * says so instead of stringifying whatever it was.\n *\n * @example\n * ```ts\n * import { errorToEnvelope } from './helpers.js'\n *\n * errorToEnvelope(new Error('boom')) // { error: { code: 'FAILED', message: 'boom' } }\n * ```\n */\nexport function errorToEnvelope(error: unknown): ErrorEnvelope {\n\tif (isUsageError(error) || isScaffoldError(error)) {\n\t\treturn { error: { code: error.code, message: error.message } }\n\t}\n\tconst message = error instanceof Error ? error.message : FAILED_MESSAGE\n\treturn { error: { code: FAILED_CODE, message } }\n}\n","import type {\n\tAudit,\n\tBlueprint,\n\tCatalogEntry,\n\tDependency,\n\tEnvironment,\n\tGroup,\n\tMirror,\n\tPlan,\n\tQuestion,\n\tRelease,\n} from '@src/core'\nimport type {\n\tMaterializeResult,\n\tMaterializerInterface,\n\tRepository,\n\tUpstreamOptions,\n} from '@src/server'\nimport type {\n\tAuditCommand,\n\tCatalogCommand,\n\tCatalogResult,\n\tCLICommand,\n\tCLIInterface,\n\tCLIOptions,\n\tNewCommand,\n\tOutputHandler,\n\tOverwriteCommand,\n\tOverwriteResult,\n\tRepairCommand,\n\tRepairResult,\n} from './types.js'\nimport { execFileSync } from 'node:child_process'\nimport { renderTable, strip, stripControls } from '@orkestrel/console'\nimport { attempt, isRecord, isString, parseJSON } from '@orkestrel/contract'\nimport { createMarkdown, flattenText, isTableNode } from '@orkestrel/markdown'\nimport {\n\tCATALOG_AGENT_PATH,\n\tBIN_ENTRY_PATH,\n\tblueprintToRootVite,\n\tCONFORMANCE_TEST_PATH,\n\tcreateBlueprint,\n\tcreateCompiler,\n\tDEPENDENCY_NAME_PATTERN,\n\tENVIRONMENTS,\n\tGROUPS,\n\tGLOBAL_SETUP_PATH,\n\tGUIDES_TEST_PATH,\n\tINTEGRATION_TEST_PATH,\n\tmanifestToDependencies,\n\tmanifestToName,\n\tMAX_MANIFEST_BYTES,\n\tnameToGuide,\n\tScaffoldError,\n\tSERVICE_SETUP_PATH,\n\tSHOWCASE_CONFIG_PATH,\n} from '@src/core'\nimport {\n\tcreateMaterializer,\n\tcreateUpstream,\n\tisExactCaseFile,\n\tisPhysicalDirectory,\n\tisRepository,\n\treadFileText,\n\treadSnapshot,\n\tresolveContainedPath,\n} from '@src/server'\nimport { EXIT_CLEAN, EXIT_DRIFT, EXIT_USAGE } from './constants.js'\nimport { isUsageError, UsageError } from './errors.js'\nimport {\n\targvToCommand,\n\tauditToExit,\n\tauditToSummary,\n\terrorToEnvelope,\n\trenderUsage,\n} from './helpers.js'\n\n/**\n * The executable: one command line in, one exit code out.\n *\n * @remarks\n * Every destination this class writes to is a handler it was given, and the run\n * ends by returning its code rather than by setting one, so the whole executable\n * is drivable from inside another process. That is what makes proving what a\n * command prints cost a function call: `src/bin/main.ts` is the only module\n * that reads `process.argv` or assigns `process.exitCode`.\n *\n * Every line leaving here is stripped of ANSI escapes and control characters\n * once, on the way out, because a refusal quotes the argument that caused it and\n * that argument came from an untrusted command line. The machine-readable path\n * needs no second pass: `JSON.stringify` escapes a control character into text\n * before it reaches the handler.\n *\n * The collaborators are constructed per run rather than received, because\n * `--from` decides the vendored root the materializer reads and an instance\n * handed in before the command line was parsed could not honour it. The\n * upstream reader is built the same way but from the options, because no\n * command line names an endpoint: a terminal caller means the published\n * registry and the published guide host, and only the process driving the\n * executable can mean anything else. That is the seam that makes the three\n * verbs which read the network provable without one.\n *\n * @example\n * ```ts\n * import { CLI } from './CLI.js'\n *\n * const lines: string[] = []\n * const code = await new CLI({ output: (line) => lines.push(line) }).execute(['--help'])\n * code // 0\n * ```\n */\nexport class CLI implements CLIInterface {\n\t// The two destinations a terminal caller means. They are the only process\n\t// streams this class names, and it names them once: a handler is what every\n\t// write goes through, so the default is a handler too rather than a branch at\n\t// each write site.\n\tstatic readonly #stdout: OutputHandler = (line) => void process.stdout.write(`${line}\\n`)\n\tstatic readonly #stderr: OutputHandler = (line) => void process.stderr.write(`${line}\\n`)\n\treadonly #output: OutputHandler\n\treadonly #diagnostic: OutputHandler\n\t// What every upstream reader this class builds is constructed from. It is held\n\t// once and read by each verb that reads the network, so the three of them\n\t// cannot disagree about which registry and which guide host a run addresses.\n\treadonly #upstream: UpstreamOptions | undefined\n\n\t/**\n\t * Construct the executable over the two destinations it writes to.\n\t *\n\t * @param options - The report and diagnostic handlers and the upstream\n\t * endpoints; the process streams and the published endpoints when absent.\n\t */\n\tconstructor(options?: CLIOptions) {\n\t\tthis.#output = options?.output ?? CLI.#stdout\n\t\tthis.#diagnostic = options?.diagnostic ?? CLI.#stderr\n\t\tthis.#upstream = options?.upstream\n\t}\n\n\t/**\n\t * Run one command line to completion and report through the configured output.\n\t *\n\t * @param argv - The arguments following the executable's own name.\n\t * @returns The exit code: `0` clean, `1` drift or failure, `2` a usage error.\n\t *\n\t * @remarks\n\t * A request for usage is answered before anything is parsed, because it\n\t * replaces the run rather than modifying it, and because `--help` is not an\n\t * option any verb takes. Everything after that is one command: read it,\n\t * dispatch it, render what it produced, and answer with the code it earned.\n\t *\n\t * @example\n\t * ```ts\n\t * import { CLI } from './CLI.js'\n\t *\n\t * await new CLI().execute(['audit', '--json']) // 0 when the target matches its plan\n\t * ```\n\t */\n\tasync execute(argv: readonly string[]): Promise<number> {\n\t\tif (argv.includes('--help')) {\n\t\t\tfor (const line of renderUsage()) this.#say(line)\n\t\t\treturn EXIT_CLEAN\n\t\t}\n\t\tconst read = attempt(() => argvToCommand(argv))\n\t\t// A command line that never became a command carries no `--json`, so the\n\t\t// refusal is prose: there is no machine-readable value for it to pollute.\n\t\tif (!read.success) return this.#refuse(read.error, false)\n\t\tconst command = read.value\n\t\ttry {\n\t\t\treturn await this.#dispatch(command)\n\t\t} catch (error) {\n\t\t\treturn this.#refuse(error, command.json === true)\n\t\t}\n\t}\n\n\t// One verb per branch, each answering with its own exit code. The switch is\n\t// exhaustive over the command union, so a new verb fails to compile here.\n\tasync #dispatch(command: CLICommand): Promise<number> {\n\t\tswitch (command.verb) {\n\t\t\tcase 'new':\n\t\t\t\treturn this.#create(command)\n\t\t\tcase 'audit':\n\t\t\t\treturn this.#inspect(command)\n\t\t\tcase 'repair':\n\t\t\t\treturn this.#restore(command)\n\t\t\tcase 'catalog':\n\t\t\t\treturn this.#refresh(command)\n\t\t\tcase 'overwrite':\n\t\t\t\treturn this.#replace(command)\n\t\t}\n\t}\n\n\t// `new` — resolve the declared dependencies against the registry, compile the\n\t// blueprint the command line describes, and write it into a vacant target.\n\tasync #create(command: NewCommand): Promise<number> {\n\t\tconst target = command.target ?? command.name\n\t\tconst blueprint = createBlueprint(command.name, {\n\t\t\tsrc: this.#environments(command.src, 'src'),\n\t\t\tapp: this.#environments(command.app, 'app'),\n\t\t\tbin: command.bin === true,\n\t\t\tdependencies: await this.#resolve(this.#packages(command.dependencies)),\n\t\t})\n\t\tconst plan = this.#compile(blueprint)\n\t\tconst materializer = createMaterializer(\n\t\t\tcommand.from === undefined ? undefined : { host: command.from },\n\t\t)\n\t\ttry {\n\t\t\tconst result = materializer.materialize(plan, target)\n\t\t\tif (command.json === true) this.#report(result)\n\t\t\telse {\n\t\t\t\tthis.#say(`Scaffolded ${blueprint.name} into ${result.target}.`)\n\t\t\t\tthis.#say(this.#tally(result))\n\t\t\t}\n\t\t\treturn EXIT_CLEAN\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t}\n\n\t// `audit` — compare a target to the plan its own manifest and directories\n\t// describe, through the vendored host a repair would write from, and write\n\t// nothing whatever it finds.\n\t//\n\t// The host is load-bearing here where it once was not, so `--from` reaches the\n\t// comparison and a host that cannot be read refuses the run under its own\n\t// coded reason. Refusing is the honest answer: the comparison this verb\n\t// reports is the hydrated one, and a fallback to the pure compile would report\n\t// `aligned` for exactly the files whose bytes it failed to read.\n\t#inspect(command: AuditCommand): number {\n\t\tconst target = command.target ?? '.'\n\t\tconst blueprint = this.#derive(target)\n\t\tconst question = this.#projectQuestion(target, blueprint)\n\t\tconst materializer = createMaterializer(\n\t\t\tcommand.from === undefined ? undefined : { host: command.from },\n\t\t)\n\t\ttry {\n\t\t\tconst [measured] = this.#survey(materializer, blueprint, target, this.#groups(command.groups))\n\t\t\tconst audit: Audit =\n\t\t\t\tquestion === undefined\n\t\t\t\t\t? measured\n\t\t\t\t\t: { ...measured, questions: [...measured.questions, question] }\n\t\t\tif (command.json === true) this.#report(audit)\n\t\t\telse this.#present(audit)\n\t\t\treturn auditToExit(audit)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t}\n\n\t// `repair` — write each planned path the target is missing or has let drift,\n\t// then re-audit, because the audit a repair reports is the one taken after it.\n\t// One materializer spans the whole verb: the audit that guides the write, the\n\t// write, and the audit that answers for it are three readings of one vendored\n\t// host, and a second instance could not promise they were.\n\t#restore(command: RepairCommand): number {\n\t\tconst target = command.target ?? '.'\n\t\tconst groups = this.#groups(command.groups)\n\t\tconst blueprint = this.#derive(target)\n\t\tthis.#assertProjects(target, blueprint)\n\t\tconst materializer = createMaterializer(\n\t\t\tcommand.from === undefined ? undefined : { host: command.from },\n\t\t)\n\t\ttry {\n\t\t\tconst [audit, plan] = this.#survey(materializer, blueprint, target, groups)\n\t\t\tif (plan === undefined) {\n\t\t\t\tif (command.json === true) this.#report(audit)\n\t\t\t\telse this.#present(audit)\n\t\t\t\treturn EXIT_DRIFT\n\t\t\t}\n\t\t\tconst result = materializer.repair(plan, audit, target)\n\t\t\tconst [terminal] = this.#survey(materializer, blueprint, target, groups)\n\t\t\tconst outcome: RepairResult = { ...result, audit: terminal }\n\t\t\tif (command.json === true) this.#report(outcome)\n\t\t\telse {\n\t\t\t\tthis.#present(terminal)\n\t\t\t\tthis.#say(this.#tally(result))\n\t\t\t}\n\t\t\treturn auditToExit(terminal)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t}\n\n\t// `catalog` — regenerate the package table from the organization's published\n\t// list and refresh the guide mirrors the target draws on.\n\tasync #refresh(command: CatalogCommand): Promise<number> {\n\t\tconst target = command.target ?? '.'\n\t\tconst [host, ...extra] = command.from ?? []\n\t\tif (extra.length > 0) {\n\t\t\tthis.#warn(\n\t\t\t\t`Read the data root from ${String(host)}. The other ${String(extra.length)} local root${extra.length === 1 ? '' : 's'} named by --from reach nothing this run does.`,\n\t\t\t)\n\t\t}\n\t\tconst previous = this.#previous(target)\n\t\tconst fetched = await this.#fetch(target, command.all === true)\n\t\tconst materializer = createMaterializer(host === undefined ? undefined : { host })\n\t\tlet result: MaterializeResult\n\t\ttry {\n\t\t\tresult = this.#publish(materializer, target, fetched.entries, fetched.mirrors)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t\tconst outcome: CatalogResult = {\n\t\t\t...result,\n\t\t\tentries: fetched.entries,\n\t\t\tmirrors: fetched.mirrors,\n\t\t\tdropped: previous.filter((name) => !fetched.entries.some((entry) => entry.name === name)),\n\t\t}\n\t\tif (command.json === true) this.#report(outcome)\n\t\telse this.#recount(outcome)\n\t\treturn fetched.mirrors.some((mirror) => mirror.lookup === 'failed') ? EXIT_DRIFT : EXIT_CLEAN\n\t}\n\n\t// `overwrite` — everything repair and catalog do, plus the two steps only this\n\t// verb carries. The offline half runs first and persists whatever it did,\n\t// because it is the destructive one: a run that cannot reach upstream still\n\t// leaves the target repaired and says which step it could not complete.\n\tasync #replace(command: OverwriteCommand): Promise<number> {\n\t\tconst target = command.target ?? '.'\n\t\tconst groups = this.#groups(command.groups)\n\t\tconst blueprint = this.#derive(target)\n\t\tthis.#assertProjects(target, blueprint)\n\t\tconst repository = this.#repository(target)\n\t\tif (repository.dirty.length > 0 && command.dirty !== true) {\n\t\t\tthrow new ScaffoldError(\n\t\t\t\t'TARGET',\n\t\t\t\t`The target at ${target} carries ${String(repository.dirty.length)} uncommitted change${repository.dirty.length === 1 ? '' : 's'}. Commit them, or pass --dirty to waive the refusal.`,\n\t\t\t\t{ target, dirty: repository.dirty.length },\n\t\t\t)\n\t\t}\n\t\tconst materializer = createMaterializer(\n\t\t\tcommand.from === undefined ? undefined : { host: command.from },\n\t\t)\n\t\ttry {\n\t\t\tconst [audit, plan] = this.#survey(materializer, blueprint, target, groups)\n\t\t\tif (plan === undefined) {\n\t\t\t\tif (command.json === true) this.#report(audit)\n\t\t\t\telse this.#present(audit)\n\t\t\t\treturn EXIT_DRIFT\n\t\t\t}\n\t\t\tconst repaired = materializer.repair(plan, audit, target)\n\t\t\t// The candidate set is the audit's own foreign findings, so a path the\n\t\t\t// plan claims is never a deletion candidate whatever the tree holds, and\n\t\t\t// neither is a path outside the vendored directories this plan expands.\n\t\t\t// `--dirty` is expressed here and nowhere else: the waiver clears the\n\t\t\t// refusal the observed dirty set would otherwise trigger downstream, and\n\t\t\t// waives nothing about which paths are eligible.\n\t\t\tconst removed = materializer.remove(\n\t\t\t\taudit,\n\t\t\t\tcommand.dirty === true ? { tracked: repository.tracked, dirty: [] } : repository,\n\t\t\t\ttarget,\n\t\t\t)\n\t\t\tconst offline = this.#merge(repaired, removed)\n\t\t\tconst online = await this.#reconcile(materializer, target, blueprint.dependencies)\n\t\t\tconst [terminal] = this.#survey(materializer, blueprint, target, groups)\n\t\t\tconst outcome: OverwriteResult = {\n\t\t\t\t...online,\n\t\t\t\t...this.#merge(offline, online),\n\t\t\t\taudit: terminal,\n\t\t\t}\n\t\t\tif (command.json === true) this.#report(outcome)\n\t\t\telse {\n\t\t\t\tthis.#present(terminal)\n\t\t\t\tthis.#recount(outcome)\n\t\t\t\tif (online.note !== undefined) this.#warn(online.note)\n\t\t\t}\n\t\t\tif (online.note !== undefined) return EXIT_DRIFT\n\t\t\treturn auditToExit(terminal)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t}\n\n\t// The network half of `overwrite`, collected rather than thrown: the offline\n\t// half has already written, so a step that cannot complete is reported as the\n\t// step it was instead of discarding what already landed. It writes through the\n\t// verb's own materializer rather than opening a second one, so every byte the\n\t// run lands comes from the host the caller named once.\n\tasync #reconcile(\n\t\tmaterializer: MaterializerInterface,\n\t\ttarget: string,\n\t\tdeclared: readonly Dependency[],\n\t): Promise<Omit<OverwriteResult, 'audit'>> {\n\t\tconst previous = this.#previous(target)\n\t\ttry {\n\t\t\tconst releases = await this.#lookup(declared)\n\t\t\tconst fetched = await this.#fetch(target, false)\n\t\t\tconst written = this.#merge(\n\t\t\t\tthis.#publish(materializer, target, fetched.entries, fetched.mirrors),\n\t\t\t\tmaterializer.declare(this.#pin(releases), target),\n\t\t\t)\n\t\t\treturn {\n\t\t\t\t...written,\n\t\t\t\tentries: fetched.entries,\n\t\t\t\tmirrors: fetched.mirrors,\n\t\t\t\tdropped: previous.filter((name) => !fetched.entries.some((entry) => entry.name === name)),\n\t\t\t\treleases,\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\ttarget,\n\t\t\t\twritten: [],\n\t\t\t\tskipped: [],\n\t\t\t\tremoved: [],\n\t\t\t\tentries: [],\n\t\t\t\tmirrors: [],\n\t\t\t\tdropped: [],\n\t\t\t\treleases: [],\n\t\t\t\tnote: `The catalog step did not complete: ${errorToEnvelope(error).error.message}`,\n\t\t\t}\n\t\t}\n\t}\n\n\t// Measure each declared range against the registry's latest release.\n\tasync #lookup(declared: readonly Dependency[]): Promise<readonly Release[]> {\n\t\tconst upstream = createUpstream(this.#upstream)\n\t\ttry {\n\t\t\treturn await upstream.lookup(declared)\n\t\t} finally {\n\t\t\tupstream.destroy()\n\t\t}\n\t}\n\n\t// Read the organization's published list and the guides the target draws on.\n\t// The workspace never fetches its own guide: that file is its own product.\n\tasync #fetch(\n\t\ttarget: string,\n\t\tall: boolean,\n\t): Promise<{ readonly entries: readonly CatalogEntry[]; readonly mirrors: readonly Mirror[] }> {\n\t\tconst manifest = this.#manifest(target)\n\t\tconst own = manifestToName(manifest)\n\t\tconst declared = manifestToDependencies(manifest).map((dependency) => dependency.name)\n\t\tconst upstream = createUpstream(this.#upstream)\n\t\ttry {\n\t\t\tconst entries = await upstream.catalog()\n\t\t\tconst names = (all ? entries.map((entry) => entry.name) : declared).filter(\n\t\t\t\t(name) => name !== own,\n\t\t\t)\n\t\t\tconst mirrors = await upstream.fetch(names, readSnapshot(target, names.map(nameToGuide)))\n\t\t\treturn { entries, mirrors }\n\t\t} finally {\n\t\t\tupstream.destroy()\n\t\t}\n\t}\n\n\t// Write the fetched guides to their mirrors and the published list to the\n\t// marker-bounded table, as one result.\n\t#publish(\n\t\tmaterializer: MaterializerInterface,\n\t\ttarget: string,\n\t\tentries: readonly CatalogEntry[],\n\t\tmirrors: readonly Mirror[],\n\t): MaterializeResult {\n\t\treturn this.#merge(materializer.mirror(mirrors, target), materializer.catalog(entries, target))\n\t}\n\n\t// The ranges a found release pins. A lookup that produced no answer names no\n\t// version, so it is left declared as it stands rather than rewritten to a\n\t// guess.\n\t#pin(releases: readonly Release[]): readonly Dependency[] {\n\t\tconst pinned: Dependency[] = []\n\t\tfor (const release of releases) {\n\t\t\tif (release.lookup === 'found')\n\t\t\t\tpinned.push({ name: release.name, range: `^${release.latest}` })\n\t\t}\n\t\treturn pinned\n\t}\n\n\t// Compile a blueprint into the plan it describes, or refuse with the questions\n\t// the gate raised.\n\t//\n\t// `new` is the only caller, and it chooses the shape rather than reading one, so\n\t// it refuses every question the gate raises, advisory or not: an advisory names\n\t// a workspace this package can describe honestly and should not create, and this\n\t// is the last moment the caller can pick a different shape. `#survey` is the\n\t// reading counterpart, and it carries the same advisories through instead.\n\t//\n\t// The refusal is `BLOCKED` whichever kind of question earned it, because both\n\t// are the one fact that code names: this blueprint will not be built. The\n\t// questions the message quotes are what tells the two apart, and a second code\n\t// would be a label for a fact they already carry.\n\t#compile(blueprint: Blueprint, groups?: readonly Group[]): Plan {\n\t\tconst compiler = createCompiler()\n\t\ttry {\n\t\t\tconst scaffolding = compiler.compile(blueprint, groups)\n\t\t\tif (scaffolding.plan !== undefined && scaffolding.questions.length === 0) {\n\t\t\t\treturn scaffolding.plan\n\t\t\t}\n\t\t\tthrow new ScaffoldError(\n\t\t\t\t'BLOCKED',\n\t\t\t\tscaffolding.questions.map((question) => `${question.field}: ${question.message}`).join(' '),\n\t\t\t\t{ questions: scaffolding.questions.length },\n\t\t\t)\n\t\t} finally {\n\t\t\tcompiler.destroy()\n\t\t}\n\t}\n\n\t// Compile a blueprint and compare its plan to what the target currently holds,\n\t// through the vendored host a write would draw on.\n\t//\n\t// The materializer owns the comparison because it is the only one that can\n\t// make it: the pure compile claims presence alone, so it reads a canon file a\n\t// consumer has edited as aligned and a vendored directory as one missing path\n\t// no write could ever satisfy. Hydrating first states the bytes and expands\n\t// the directory into the files the host actually stores, which is the same\n\t// derivation the repair that follows is held to.\n\t//\n\t// The compiler answers the refused case alone. A blueprint the gate closed\n\t// carries no plan, so there is nothing to hydrate and nothing to say about the\n\t// target; the audit carries the questions instead.\n\t#survey(\n\t\tmaterializer: MaterializerInterface,\n\t\tblueprint: Blueprint,\n\t\ttarget: string,\n\t\tgroups?: readonly Group[],\n\t): readonly [audit: Audit, plan: Plan | undefined] {\n\t\tconst compiler = createCompiler()\n\t\ttry {\n\t\t\tconst scaffolding = compiler.compile(blueprint, groups)\n\t\t\tif (scaffolding.plan === undefined) return [compiler.audit(blueprint, {}, groups), undefined]\n\t\t\t// The materializer answers for the target and the gate answers for the\n\t\t\t// blueprint, so an advisory the gate raised rides the comparison rather\n\t\t\t// than being dropped between them. It is non-blocking, so it changes no\n\t\t\t// exit code and never makes an aligned target drift.\n\t\t\tconst measured = materializer.audit(scaffolding.plan, target)\n\t\t\treturn [\n\t\t\t\t{ ...measured, questions: [...measured.questions, ...scaffolding.questions] },\n\t\t\t\tscaffolding.plan,\n\t\t\t]\n\t\t} finally {\n\t\t\tcompiler.destroy()\n\t\t}\n\t}\n\n\t// The blueprint a target describes about itself: manifest identity and fleet\n\t// packages, environment directories, and exact structural files. Vendors stay\n\t// unknown because their birth-owned script is not a declaration of its list.\n\t// The live-service project does not wait on that list: it follows its own\n\t// readiness module, which the root configuration names by path.\n\t#derive(target: string): Blueprint {\n\t\tconst manifest = this.#manifest(target)\n\t\tconst declared = manifestToName(manifest)\n\t\tif (declared === undefined) {\n\t\t\tthrow new ScaffoldError('TARGET', `The manifest at ${target} declares no package name.`, {\n\t\t\t\ttarget,\n\t\t\t})\n\t\t}\n\t\tconst bin = resolveContainedPath(target, BIN_ENTRY_PATH)\n\t\tconst integration = resolveContainedPath(target, INTEGRATION_TEST_PATH)\n\t\tconst conformance = resolveContainedPath(target, CONFORMANCE_TEST_PATH)\n\t\tconst service = resolveContainedPath(target, SERVICE_SETUP_PATH)\n\t\tconst global = resolveContainedPath(target, GLOBAL_SETUP_PATH)\n\t\tconst showcase = resolveContainedPath(target, SHOWCASE_CONFIG_PATH)\n\t\treturn createBlueprint(declared.slice(declared.lastIndexOf('/') + 1), {\n\t\t\tsrc: this.#probe(target, 'src'),\n\t\t\tapp: this.#probe(target, 'app'),\n\t\t\tdependencies: manifestToDependencies(manifest),\n\t\t\tbin: bin !== undefined && isExactCaseFile(bin),\n\t\t\tintegration: integration !== undefined && isExactCaseFile(integration),\n\t\t\tconformance: conformance !== undefined && isExactCaseFile(conformance),\n\t\t\tservice: service !== undefined && isExactCaseFile(service),\n\t\t\tglobal: global !== undefined && isExactCaseFile(global),\n\t\t\tshowcase: showcase !== undefined && isExactCaseFile(showcase),\n\t\t})\n\t}\n\n\t// Read literal Vitest project values from one shell command. Quotes group a\n\t// token but do not hide the option, while shell expansions make its value\n\t// unresolved and therefore refuse the write that asked the question.\n\t#scriptProjects(script: string): readonly string[] | undefined {\n\t\tconst tokens: Array<{ value: string; resolved: boolean }> = []\n\t\tlet value = ''\n\t\tlet resolved = true\n\t\tlet started = false\n\t\tlet quote: string | undefined\n\t\tfor (let index = 0; index < script.length; index += 1) {\n\t\t\tconst character = script[index]\n\t\t\tif (character === undefined) return undefined\n\t\t\tif (quote === undefined) {\n\t\t\t\tif (/\\s/.test(character)) {\n\t\t\t\t\tif (started) tokens.push({ value, resolved })\n\t\t\t\t\tvalue = ''\n\t\t\t\t\tresolved = true\n\t\t\t\t\tstarted = false\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (';&|()'.includes(character)) {\n\t\t\t\t\tif (started) tokens.push({ value, resolved })\n\t\t\t\t\tconst paired = script[index + 1] === character && (character === '&' || character === '|')\n\t\t\t\t\ttokens.push({ value: paired ? `${character}${character}` : character, resolved: true })\n\t\t\t\t\tvalue = ''\n\t\t\t\t\tresolved = true\n\t\t\t\t\tstarted = false\n\t\t\t\t\tif (paired) index += 1\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '\"' || character === \"'\") {\n\t\t\t\t\tquote = character\n\t\t\t\t\tstarted = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '\\\\') {\n\t\t\t\t\tconst escaped = script[index + 1]\n\t\t\t\t\tif (escaped === undefined) return undefined\n\t\t\t\t\tvalue += escaped\n\t\t\t\t\tstarted = true\n\t\t\t\t\tindex += 1\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '$' || character === '`' || character === '%') resolved = false\n\t\t\t\tvalue += character\n\t\t\t\tstarted = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (character === quote) {\n\t\t\t\tquote = undefined\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (character === '\\\\' && quote === '\"') {\n\t\t\t\tconst escaped = script[index + 1]\n\t\t\t\tif (escaped === undefined) return undefined\n\t\t\t\tvalue += escaped\n\t\t\t\tindex += 1\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (quote === '\"' && (character === '$' || character === '`' || character === '%')) {\n\t\t\t\tresolved = false\n\t\t\t}\n\t\t\tvalue += character\n\t\t\tstarted = true\n\t\t}\n\t\tif (quote !== undefined) return undefined\n\t\tif (started) tokens.push({ value, resolved })\n\n\t\tconst projects: string[] = []\n\t\tfor (let index = 0; index < tokens.length; index += 1) {\n\t\t\tconst token = tokens[index]\n\t\t\tif (token === undefined) return undefined\n\t\t\tif (token.value === '--project') {\n\t\t\t\tconst project = tokens[index + 1]\n\t\t\t\tif (\n\t\t\t\t\tproject === undefined ||\n\t\t\t\t\t!project.resolved ||\n\t\t\t\t\tproject.value.length === 0 ||\n\t\t\t\t\t['&&', '||', ';', '|', '&', '(', ')'].includes(project.value)\n\t\t\t\t)\n\t\t\t\t\treturn undefined\n\t\t\t\tprojects.push(project.value)\n\t\t\t\tindex += 1\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (token.value.startsWith('--project=')) {\n\t\t\t\tconst project = token.value.slice('--project='.length)\n\t\t\t\tif (!token.resolved || project.length === 0) return undefined\n\t\t\t\tprojects.push(project)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!token.resolved && token.value.includes('--project')) return undefined\n\t\t}\n\t\treturn projects\n\t}\n\n\t// Report the manifest's Vitest calls that the planned root configuration\n\t// cannot register. Audit carries the advisory; writing verbs turn it into the\n\t// hard boundary that keeps a birth-owned script from pointing at a project\n\t// their content-owned configuration removed.\n\t#projectQuestion(target: string, blueprint: Blueprint, writing = false): Question | undefined {\n\t\tconst manifest = this.#manifest(target)\n\t\tconst guides = resolveContainedPath(target, GUIDES_TEST_PATH)\n\t\tconst planned = blueprintToRootVite(blueprint)\n\t\tconst parsed = parseJSON(manifest)\n\t\tconst scripts = isRecord(parsed) && isRecord(parsed.scripts) ? parsed.scripts : undefined\n\t\tconst absent = new Set<string>()\n\t\tlet unresolved = false\n\t\tif (scripts !== undefined) {\n\t\t\tfor (const script of Object.values(scripts)) {\n\t\t\t\tif (!isString(script) || !script.includes('vitest')) continue\n\t\t\t\tconst projects = this.#scriptProjects(script)\n\t\t\t\tif (projects === undefined) {\n\t\t\t\t\tunresolved = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfor (const project of projects) {\n\t\t\t\t\tconst guide = project === 'guides' && guides !== undefined && isExactCaseFile(guides)\n\t\t\t\t\tif (\n\t\t\t\t\t\t!planned.includes(`name: { label: '${project}',`) ||\n\t\t\t\t\t\t(project === 'guides' && !guide)\n\t\t\t\t\t) {\n\t\t\t\t\t\tabsent.add(project)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (absent.size === 0 && !unresolved) return undefined\n\t\tconst projects = [...absent].sort()\n\t\tif (unresolved) {\n\t\t\treturn {\n\t\t\t\tfield: 'projects',\n\t\t\t\tmessage: `The manifest at ${target} contains a Vitest project expression that cannot be resolved statically.${projects.length === 0 ? '' : ` It also names projects the planned configuration does not register: ${projects.join(', ')}.`} ${writing ? 'Replace it with a literal --project value or remove the script before using a scaffold writing verb.' : 'Replace it with a literal --project value before relying on the planned configuration.'}`,\n\t\t\t\tblocking: false,\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tfield: 'projects',\n\t\t\tmessage: writing\n\t\t\t\t? `The manifest at ${target} names ${projects.length === 1 ? 'a Vitest project' : 'Vitest projects'} the planned configuration does not register: ${projects.join(', ')}. To continue, remove the ${projects.length === 1 ? 'script that names it' : 'scripts that name them'} or do not use scaffold writing verbs on a workspace that needs ${projects.length === 1 ? 'a custom Vitest project' : 'custom Vitest projects'}.`\n\t\t\t\t: `The manifest at ${target} names ${projects.length === 1 ? 'a Vitest project' : 'Vitest projects'} the planned configuration does not register: ${projects.join(', ')}. Add ${projects.length === 1 ? 'the project' : 'each project'} to vite.config.ts or remove the ${projects.length === 1 ? 'script that names it' : 'scripts that name them'}.`,\n\t\t\tblocking: false,\n\t\t}\n\t}\n\n\t// Writing verbs refuse the advisory because their next step would replace the\n\t// configuration. Audit alone may report it without changing the target.\n\t#assertProjects(target: string, blueprint: Blueprint): void {\n\t\tconst question = this.#projectQuestion(target, blueprint, true)\n\t\tif (question === undefined) return\n\t\tthrow new ScaffoldError('TARGET', question.message, { target })\n\t}\n\n\t// A target's manifest text, which every reading verb needs before it can say\n\t// anything about the target at all.\n\t#manifest(target: string): string {\n\t\tconst manifest = readFileText(target, 'package.json', MAX_MANIFEST_BYTES)\n\t\tif (manifest === undefined) {\n\t\t\tthrow new ScaffoldError('TARGET', `The target at ${target} carries no readable manifest.`, {\n\t\t\t\ttarget,\n\t\t\t})\n\t\t}\n\t\treturn manifest\n\t}\n\n\t// The environments one axis physically ships, read as directories rather than\n\t// declared, because a directory is the fact and a declaration would be a\n\t// second copy of it free to disagree.\n\t#probe(target: string, axis: string): readonly Environment[] {\n\t\treturn ENVIRONMENTS.filter((environment) => {\n\t\t\tconst full = resolveContainedPath(target, `${axis}/${environment}`)\n\t\t\treturn full !== undefined && isPhysicalDirectory(full)\n\t\t})\n\t}\n\n\t// The packages the target's catalog table listed before this run. Read through\n\t// the declared markdown parser rather than by pattern, so a row is a row\n\t// because the document says so.\n\t#previous(target: string): readonly string[] {\n\t\tconst text = readFileText(target, CATALOG_AGENT_PATH)\n\t\tif (text === undefined) return []\n\t\tconst names: string[] = []\n\t\tfor (const table of createMarkdown(text).filter(isTableNode)) {\n\t\t\tfor (const row of table.rows) {\n\t\t\t\tconst [cell] = row\n\t\t\t\tif (cell === undefined) continue\n\t\t\t\tconst name = cell.map(flattenText).join('').trim()\n\t\t\t\tif (DEPENDENCY_NAME_PATTERN.test(name)) names.push(name)\n\t\t\t}\n\t\t}\n\t\treturn names\n\t}\n\n\t// What git reports about the target's working tree. Deletion draws only on\n\t// what git tracks and refuses a tree carrying uncommitted work, so a target\n\t// that is not a repository has no recovery mechanism and is refused here.\n\t#repository(target: string): Repository {\n\t\tconst tracked = this.#inventory(target, ['ls-files', '-z'])\n\t\tconst dirty = this.#inventory(target, [\n\t\t\t'status',\n\t\t\t'--porcelain=v1',\n\t\t\t'--untracked-files=all',\n\t\t\t'-z',\n\t\t]).map((record) => (record.length > 3 && record[2] === ' ' ? record.slice(3) : record))\n\t\tconst state = { tracked, dirty }\n\t\tif (!isRepository(state)) {\n\t\t\tthrow new ScaffoldError('TARGET', `The git state at ${target} is not a readable inventory.`, {\n\t\t\t\ttarget,\n\t\t\t\ttracked: tracked.length,\n\t\t\t\tdirty: dirty.length,\n\t\t\t})\n\t\t}\n\t\treturn state\n\t}\n\n\t// One git query, answered as its NUL-separated records. Git is asked rather\n\t// than reimplemented, because the tracked set and the dirty set are git's own\n\t// answers and nothing else can give them.\n\t#inventory(target: string, args: readonly string[]): readonly string[] {\n\t\tconst read = attempt(() =>\n\t\t\texecFileSync('git', [...args], {\n\t\t\t\tcwd: target,\n\t\t\t\tencoding: 'utf8',\n\t\t\t\twindowsHide: true,\n\t\t\t\tmaxBuffer: MAX_MANIFEST_BYTES,\n\t\t\t\t// git writes its own refusal to its own stderr, and this class owns\n\t\t\t\t// what leaves it: a failure is reported through the diagnostic handler\n\t\t\t\t// the caller supplied, never straight onto a stream nobody chose.\n\t\t\t\tstdio: ['ignore', 'pipe', 'ignore'],\n\t\t\t}),\n\t\t)\n\t\tif (!read.success) {\n\t\t\tthrow new ScaffoldError('TARGET', `The target at ${target} is not a git repository.`, {\n\t\t\t\ttarget,\n\t\t\t})\n\t\t}\n\t\treturn read.value.split('\\0').filter((record) => record.length > 0)\n\t}\n\n\t// The environments a comma-separated selection names, refused by name when it\n\t// names something that is not one.\n\t#environments(selection: string | undefined, axis: string): readonly Environment[] {\n\t\tif (selection === undefined) return []\n\t\tconst requested = selection.split(',')\n\t\tconst refused = requested.filter(\n\t\t\t(name) => !ENVIRONMENTS.some((environment) => environment === name),\n\t\t)\n\t\tif (refused.length > 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`'--${axis}' does not take ${refused.join(', ')}. It takes ${ENVIRONMENTS.join(', ')}.`,\n\t\t\t)\n\t\t}\n\t\treturn ENVIRONMENTS.filter((environment) => requested.includes(environment))\n\t}\n\n\t// The groups a comma-separated selection names; absence covers every group.\n\t#groups(selection: string | undefined): readonly Group[] | undefined {\n\t\tif (selection === undefined) return undefined\n\t\tconst requested = selection.split(',')\n\t\tconst refused = requested.filter((name) => !GROUPS.some((group) => group === name))\n\t\tif (refused.length > 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`'--groups' does not take ${refused.join(', ')}. It takes ${GROUPS.join(', ')}.`,\n\t\t\t)\n\t\t}\n\t\treturn GROUPS.filter((group) => requested.includes(group))\n\t}\n\n\t// The fleet packages a comma-separated selection names.\n\t#packages(selection: string | undefined): readonly string[] {\n\t\tif (selection === undefined) return []\n\t\tconst requested = selection.split(',')\n\t\tconst refused = requested.filter((name) => !DEPENDENCY_NAME_PATTERN.test(name))\n\t\tif (refused.length > 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`'--deps' does not take ${refused.join(', ')}. Every name is a published @orkestrel package.`,\n\t\t\t)\n\t\t}\n\t\treturn requested\n\t}\n\n\t// Pin each named package to the registry's latest release. A name upstream\n\t// cannot answer for is refused rather than pinned to an invented range: the\n\t// workspace would carry a dependency that does not resolve.\n\tasync #resolve(names: readonly string[]): Promise<readonly Dependency[]> {\n\t\tif (names.length === 0) return []\n\t\tconst upstream = createUpstream(this.#upstream)\n\t\tlet releases: readonly Release[]\n\t\ttry {\n\t\t\treleases = await upstream.lookup(names.map((name) => ({ name, range: '*' })))\n\t\t} finally {\n\t\t\tupstream.destroy()\n\t\t}\n\t\tconst refused = releases.filter((release) => release.lookup !== 'found')\n\t\tif (refused.length > 0) {\n\t\t\tthrow new ScaffoldError(\n\t\t\t\t'FETCH',\n\t\t\t\t`The registry named no release for ${refused.map((release) => release.name).join(', ')}.`,\n\t\t\t\t{ names: refused.length },\n\t\t\t)\n\t\t}\n\t\treturn this.#pin(releases)\n\t}\n\n\t// Two results of one run, read as one. Written and skipped never overlap\n\t// across the calls a verb makes, because each call answers for its own paths.\n\t#merge(first: MaterializeResult, second: MaterializeResult): MaterializeResult {\n\t\treturn {\n\t\t\ttarget: first.target,\n\t\t\twritten: [...first.written, ...second.written],\n\t\t\tskipped: [...first.skipped, ...second.skipped],\n\t\t\tremoved: [...first.removed, ...second.removed],\n\t\t}\n\t}\n\n\t// The audit as a person reads it: every advisory first, then one row per path\n\t// that differs, then the summary. An aligned path is not listed, because a\n\t// report of everything that is fine is a report nobody reads.\n\t#present(audit: Audit): void {\n\t\tfor (const question of audit.questions) this.#warn(`${question.field}: ${question.message}`)\n\t\tconst rows = audit.findings\n\t\t\t.filter((finding) => finding.drift !== 'aligned')\n\t\t\t.map((finding) => [finding.path, finding.group, finding.drift])\n\t\tif (rows.length > 0) {\n\t\t\tconst table = renderTable({\n\t\t\t\tcolumns: [{ label: 'path' }, { label: 'group' }, { label: 'drift' }],\n\t\t\t\trows,\n\t\t\t})\n\t\t\tfor (const line of table.split('\\n')) this.#say(line)\n\t\t}\n\t\tthis.#say(auditToSummary(audit))\n\t}\n\n\t// The catalog outcome as a person reads it.\n\t#recount(result: CatalogResult): void {\n\t\tthis.#say(this.#tally(result))\n\t\tthis.#say(\n\t\t\t`${String(result.entries.length)} published, ${String(result.mirrors.filter((mirror) => mirror.lookup === 'found').length)} guide${result.mirrors.length === 1 ? '' : 's'} fetched, ${String(result.dropped.length)} no longer listed.`,\n\t\t)\n\t\tfor (const mirror of result.mirrors) {\n\t\t\tif (mirror.lookup !== 'found') this.#warn(`${mirror.name}: ${mirror.note}`)\n\t\t}\n\t}\n\n\t// One line stating what a mutation did.\n\t#tally(result: MaterializeResult): string {\n\t\treturn `${String(result.written.length)} written, ${String(result.skipped.length)} unchanged, ${String(result.removed.length)} removed in ${result.target}.`\n\t}\n\n\t// The one machine-readable value a `--json` run emits.\n\t#report(value: unknown): void {\n\t\tthis.#say(JSON.stringify(value))\n\t}\n\n\t// Report a refusal under the code it carries and answer with the code it\n\t// earned: a command line that was not a command is a usage error, and\n\t// everything else is a failed run.\n\t#refuse(error: unknown, json: boolean): number {\n\t\tconst envelope = errorToEnvelope(error)\n\t\tif (json) this.#report(envelope)\n\t\telse this.#warn(`${envelope.error.code}: ${envelope.error.message}`)\n\t\treturn isUsageError(error) ? EXIT_USAGE : EXIT_DRIFT\n\t}\n\n\t#say(line: string): void {\n\t\tthis.#output(this.#sanitize(line))\n\t}\n\n\t#warn(line: string): void {\n\t\tthis.#diagnostic(this.#sanitize(line))\n\t}\n\n\t// The single write path, and the only place hostile bytes are answered for.\n\t// A refusal quotes the argument that caused it, so an escape sequence, a bell,\n\t// or a forged second line arrives here inside otherwise ordinary prose. ANSI\n\t// escapes go first because they are what repaints a terminal, control\n\t// characters next, and what remains is folded onto one line because a handler\n\t// takes one line and a caller writing a record per call must get one record.\n\t#sanitize(line: string): string {\n\t\treturn stripControls(strip(line)).split(/\\r?\\n/).join(' ')\n\t}\n}\n","// The executable entry, and the only module that touches process state: it reads\n// the arguments the process was given and assigns the code the run returned. The\n// `#!/usr/bin/env node` shebang is re-emitted by the build's `output.banner`\n// rather than written here, because the bundler strips a shebang from source.\nimport { CLI } from './CLI.js'\n\nprocess.stdout.on('error', (error) => {\n\tif ('code' in error && error.code === 'EPIPE') return\n\tthrow error\n})\nprocess.exitCode = await new CLI().execute(process.argv.slice(2))\n"],"mappings":";;;;;;;;;;;;;;;;;AAWA,IAAa,kBAAkB;;;;;;;;;AAU/B,IAAa,QAAyB,OAAO,OAAO;CACnD;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;;;AAkBD,IAAa,eAAiD,OAAO,OAAO;EAC7D,IAAA;EACA,IAAA;EACA,IAAA;AACf,CAAC;;;;;;;;;;AAWD,IAAa,aAAa;;AAG1B,IAAa,cAAc;;AAG3B,IAAa,iBAAiB;;;;;;;;AAS9B,IAAa,gBAAgB;;;;;;;;;;;;;;AAe7B,IAAa,kBAA0C,OAAO,OAAO;CACpE,KAAK,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACrC,KAAK,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACrC,KAAK,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;CACtC,MAAM,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACtC,QAAQ,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACxC,KAAK,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;CACtC,OAAO,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;CACxC,MAAM,OAAO,OAAO;EAAE,MAAM;EAAU,UAAU;CAAK,CAAC;CACtD,QAAQ,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACxC,MAAM,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,CAAC;;;;;;;;;AAUD,IAAa,iBAAmD,OAAO,OAAO;CAC7E,gBAAgB;CAChB,gBAAgB;CAChB,SAAS;CACT,iBAAiB;CACjB,mBAAmB;CACnB,SAAS;CACT,WAAW;CACX,iBACC;CACD,mBAAmB;CACnB,UA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spect","#restore","#refresh","#replace","#environments","#resolve","#packages","#compile","#report","#tally","#derive","#targetQuestions","#survey","#groups","#present","#assertTarget","#reportReplacements","#warn","#previous","#fetch","#publish","#recount","#repository","#merge","#reconcile","#lookup","#pin","#manifest","#probe","#invocations","#projectQuestion","#dependencyQuestion","#inventory","#sanitize"],"sources":["../../src/bin/constants.ts","../../src/bin/errors.ts","../../src/bin/helpers.ts","../../src/bin/CLI.ts","../../src/bin/main.ts"],"sourcesContent":["import type { ParseArgsOptionsConfig } from 'node:util'\nimport type { Verb } from './types.js'\n\n/**\n * The name the executable installs as.\n *\n * @remarks\n * `package.json`'s `bin` field is the authority for what the command is called;\n * this is the same word, so every usage line the executable prints is a command\n * a reader can paste back.\n */\nexport const EXECUTABLE_NAME = 'scaffold'\n\n/**\n * The five {@link Verb} values in usage order, frozen.\n *\n * @remarks\n * The order the type declares them in, which is also the order usage lists them:\n * the verb that creates a workspace, then the one that only reads it, then the\n * three that write to one that already exists, widest last.\n */\nexport const VERBS: readonly Verb[] = Object.freeze([\n\t'new',\n\t'audit',\n\t'repair',\n\t'catalog',\n\t'overwrite',\n])\n\n/** The exit code reporting that the target matched its plan and every step completed. */\nexport const EXIT_CLEAN = 0\n\n/** The exit code reporting that the target drifted, or that a step failed. */\nexport const EXIT_DRIFT = 1\n\n/** The exit code reporting that the command line was not a command. */\nexport const EXIT_USAGE = 2\n\n/**\n * What each exit code means, frozen.\n *\n * @remarks\n * Keyed by the three code constants rather than by literals, so the usage block\n * cannot document a code the executable does not return.\n */\nexport const EXIT_SUMMARY: Readonly<Record<number, string>> = Object.freeze({\n\t[EXIT_CLEAN]: 'clean',\n\t[EXIT_DRIFT]: 'drift or failure',\n\t[EXIT_USAGE]: 'usage error',\n})\n\n/**\n * The machine-readable code a malformed command line reports.\n *\n * @remarks\n * The executable contributes its own codes to the failure envelope, which is why\n * that envelope's `code` is a plain string rather than a `ScaffoldErrorCode`: a\n * command line that never became a command failed before any coded package\n * operation could.\n */\nexport const USAGE_CODE = 'USAGE'\n\n/** The machine-readable code a failure carrying no code of its own reports. */\nexport const FAILED_CODE = 'FAILED'\n\n/** What the failure envelope says when the raised value carried no message. */\nexport const FAILED_MESSAGE = 'The command failed for an unrecognized reason'\n\n/**\n * The positional argument `new` alone takes, as usage writes it.\n *\n * @remarks\n * The workspace name is the only positional argument any verb takes, so it is\n * one value rather than a per-verb table with four holes in it.\n */\nexport const NAME_ARGUMENT = '<name>'\n\n/**\n * Every option the executable accepts, as `node:util` parses them, frozen.\n *\n * @remarks\n * One table for every verb rather than one per verb, because the verb an option\n * belongs to is a domain fact the command union already fixes: parsing decides\n * only whether the word is an option at all, and {@link VERB_OPTIONS} decides\n * whether this verb takes it. No option declares a default, so the parsed keys\n * are exactly the options the caller supplied, which is what makes an option\n * offered to the wrong verb visible rather than silently absorbed. `from`\n * collects repeats because `catalog` may draw on more than one local source; a\n * verb that takes it once refuses the second.\n */\nexport const COMMAND_OPTIONS: ParseArgsOptionsConfig = Object.freeze({\n\tsrc: Object.freeze({ type: 'string' }),\n\tapp: Object.freeze({ type: 'string' }),\n\tbin: Object.freeze({ type: 'boolean' }),\n\tdeps: Object.freeze({ type: 'string' }),\n\tgroups: Object.freeze({ type: 'string' }),\n\tall: Object.freeze({ type: 'boolean' }),\n\tdirty: Object.freeze({ type: 'boolean' }),\n\tfrom: Object.freeze({ type: 'string', multiple: true }),\n\ttarget: Object.freeze({ type: 'string' }),\n\tjson: Object.freeze({ type: 'boolean' }),\n})\n\n/**\n * What each option does, keyed by the token usage prints, frozen.\n *\n * @remarks\n * The key order is the glossary order. A key is the whole displayed token,\n * value placeholder included, because that token is what a reader copies and\n * what {@link VERB_OPTIONS} lists.\n */\nexport const OPTION_SUMMARY: Readonly<Record<string, string>> = Object.freeze({\n\t'--src <list>': 'the published library environments to build: core, browser, server',\n\t'--app <list>': 'the private application environments to build: core, browser, server',\n\t'--bin': 'scaffold a command-line executable at src/bin/main.ts',\n\t'--deps <list>': 'the @orkestrel/* packages the workspace depends on',\n\t'--groups <list>': 'the artifact groups to cover; every group when absent',\n\t'--all': 'fetch a guide for every package the organization publishes, not just the declared ones',\n\t'--dirty': 'delete from a tree carrying uncommitted changes',\n\t'--from <path>':\n\t\t'read the data root from a local path instead of the bundled one; catalog alone accepts it more than once',\n\t'--target <path>': 'the directory the verb operates on; the working directory when absent',\n\t'--json': 'emit one machine-readable value instead of a report',\n})\n\n/**\n * The options each verb takes, in usage order, frozen.\n *\n * @remarks\n * The executable's half of the frozen command union: every option a branch\n * declares is listed against its verb, and every option a branch excludes is\n * absent from it. An option a verb does not list is refused by name rather than\n * parsed and ignored.\n */\nexport const VERB_OPTIONS: Readonly<Record<Verb, readonly string[]>> = Object.freeze({\n\tnew: Object.freeze([\n\t\t'--src <list>',\n\t\t'--app <list>',\n\t\t'--bin',\n\t\t'--deps <list>',\n\t\t'--from <path>',\n\t\t'--target <path>',\n\t\t'--json',\n\t]),\n\taudit: Object.freeze(['--groups <list>', '--from <path>', '--target <path>', '--json']),\n\trepair: Object.freeze(['--groups <list>', '--from <path>', '--target <path>', '--json']),\n\tcatalog: Object.freeze(['--all', '--from <path>', '--target <path>', '--json']),\n\toverwrite: Object.freeze([\n\t\t'--groups <list>',\n\t\t'--dirty',\n\t\t'--from <path>',\n\t\t'--target <path>',\n\t\t'--json',\n\t]),\n})\n\n/**\n * What each verb does, in one line, frozen.\n *\n * @remarks\n * Each line names what the verb writes, because authority is the verb's: a\n * reader deciding which one to run is deciding what they are authorizing.\n */\nexport const VERB_SUMMARY: Readonly<Record<Verb, string>> = Object.freeze({\n\tnew: 'scaffold a workspace',\n\taudit: 'report how the target compares to its plan, writing nothing',\n\trepair: 'write each planned path the target is missing or has let drift',\n\tcatalog: 'regenerate the package table and refresh the guide mirrors',\n\toverwrite:\n\t\t'do everything repair and catalog do, then delete what the plan does not own and re-declare the dependency ranges',\n})\n","import { USAGE_CODE } from './constants.js'\n\n/**\n * The error raised when a command line is not a command.\n *\n * @remarks\n * Distinct from `ScaffoldError` because the two answer different questions and\n * exit differently: a `ScaffoldError` says the package could not serve a\n * well-formed request and exits `1`, while this says there was no request to\n * serve and exits `2`. Folding a usage error into `INVALID` would report a\n * mistyped flag as a failed run.\n *\n * It carries no `context`. Everything a caller can act on is in the message,\n * because the reader of a usage error is a person at a terminal rather than a\n * program branching on a cause.\n *\n * @example\n * ```ts\n * import { isUsageError, UsageError } from './errors.js'\n *\n * try {\n * \tthrow new UsageError(\"Unknown command 'pull'.\")\n * } catch (error) {\n * \tif (isUsageError(error)) error.code // 'USAGE'\n * }\n * ```\n */\nexport class UsageError extends Error {\n\treadonly code: string\n\n\t/**\n\t * Construct a usage error.\n\t *\n\t * @param message - What was wrong with the command line, in one sentence.\n\t */\n\tconstructor(message: string) {\n\t\tsuper(message)\n\t\tthis.name = 'UsageError'\n\t\tthis.code = USAGE_CODE\n\t}\n}\n\n/**\n * Narrow a caught value to a {@link UsageError}.\n *\n * @param value - The caught value to narrow.\n * @returns `true` when `value` is a {@link UsageError}.\n *\n * @example\n * ```ts\n * import { isUsageError } from './errors.js'\n *\n * isUsageError(new Error('plain')) // false\n * isUsageError(undefined) // false\n * ```\n */\nexport function isUsageError(value: unknown): value is UsageError {\n\treturn value instanceof UsageError\n}\n","import type { Audit } from '@src/core'\nimport type { CLICommand, ErrorEnvelope, Verb } from './types.js'\nimport { align, width } from '@orkestrel/console'\nimport { attempt } from '@orkestrel/contract'\nimport { isScaffoldError } from '@src/core'\nimport { parseArgs } from 'node:util'\nimport {\n\tCOMMAND_OPTIONS,\n\tEXECUTABLE_NAME,\n\tEXIT_CLEAN,\n\tEXIT_DRIFT,\n\tEXIT_SUMMARY,\n\tFAILED_CODE,\n\tFAILED_MESSAGE,\n\tNAME_ARGUMENT,\n\tOPTION_SUMMARY,\n\tVERB_OPTIONS,\n\tVERB_SUMMARY,\n\tVERBS,\n} from './constants.js'\nimport { isUsageError, UsageError } from './errors.js'\n\n/**\n * Read the option name out of the token usage displays it as.\n *\n * @param option - The displayed token, such as `--from <path>`.\n * @returns The bare name `node:util` parses the option under.\n *\n * @remarks\n * One token serves both readers: a person reads the value placeholder and the\n * parser reads the name in front of it. Deriving the name means a documented\n * option and an accepted option cannot be two different lists.\n *\n * @example\n * ```ts\n * import { optionToName } from './helpers.js'\n *\n * optionToName('--from <path>') // 'from'\n * optionToName('--json') // 'json'\n * ```\n */\nexport function optionToName(option: string): string {\n\tconst [token = option] = option.split(' ')\n\treturn token.startsWith('--') ? token.slice(2) : token\n}\n\n/**\n * Render one verb's synopsis.\n *\n * @param verb - The verb to describe.\n * @returns The command line this verb accepts, with every option bracketed.\n *\n * @remarks\n * The synopsis is derived from the verb's own option list rather than stored\n * beside it, so a line that documents an option the verb does not take cannot be\n * written. `new` alone carries the positional argument.\n *\n * @example\n * ```ts\n * import { verbToSyntax } from './helpers.js'\n *\n * verbToSyntax('audit') // 'scaffold audit [--groups <list>] …'\n * ```\n */\nexport function verbToSyntax(verb: Verb): string {\n\tconst argument = verb === 'new' ? ` ${NAME_ARGUMENT}` : ''\n\tconst options = VERB_OPTIONS[verb].map((option) => `[${option}]`).join(' ')\n\treturn `${EXECUTABLE_NAME} ${verb}${argument} ${options}`\n}\n\n/**\n * Render the whole command reference.\n *\n * @returns One line per output call: the synopsis, every verb, the option glossary, and the exit codes.\n *\n * @remarks\n * Returned as lines because the executable writes through a handler that takes\n * one line, so the caller never has to split a block back apart. The glossary is\n * printed once for every verb rather than repeated per verb, since seven of the\n * nine options are shared and a reader comparing two verbs wants the difference,\n * not the repetition.\n */\nexport function renderUsage(): readonly string[] {\n\tconst summaries = Object.entries(OPTION_SUMMARY)\n\tconst column = Math.max(...summaries.map(([option]) => width(option)))\n\treturn [\n\t\t`${EXECUTABLE_NAME} <verb> [options]`,\n\t\t'',\n\t\t...VERBS.flatMap((verb) => [` ${verbToSyntax(verb)}`, ` ${VERB_SUMMARY[verb]}`]),\n\t\t'',\n\t\t'options',\n\t\t...summaries.map(([option, summary]) => ` ${align(option, column)} ${summary}`),\n\t\t'',\n\t\t'exit codes',\n\t\t...Object.entries(EXIT_SUMMARY).map(([code, meaning]) => ` ${code} ${meaning}`),\n\t]\n}\n\n/**\n * Read one command out of the arguments following the executable's own name.\n *\n * @param argv - The arguments the executable was given.\n * @returns The command the arguments denote.\n * @throws {@link UsageError} when they denote no command.\n *\n * @remarks\n * The one place untrusted argument text becomes a domain value, and it stays one\n * function because the command union admits no partial command to hand on: every\n * refusal has to happen before the value exists. It refuses in four ways, each\n * naming what was wrong — a word that is not a verb, a word that is not an\n * option, an option this verb does not take, and an argument this verb does not\n * take. `node:util` decides the second and this decides the rest, so an unknown\n * option is reported by the parser that found it rather than re-derived here.\n *\n * A request for usage is not a command and never reaches this: the caller\n * answers it first.\n *\n * @example\n * ```ts\n * import { argvToCommand } from './helpers.js'\n *\n * argvToCommand(['audit', '--json']) // { verb: 'audit', json: true }\n * ```\n */\nexport function argvToCommand(argv: readonly string[]): CLICommand {\n\tconst [head, ...rest] = argv\n\tconst verb = VERBS.find((candidate) => candidate === head)\n\tif (verb === undefined) {\n\t\tconst found = head === undefined ? 'No command given.' : `Unknown command '${head}'.`\n\t\tthrow new UsageError(`${found} Run '${EXECUTABLE_NAME} --help' for the command list.`)\n\t}\n\tconst parsed = attempt(() =>\n\t\tparseArgs({ args: rest, options: COMMAND_OPTIONS, allowPositionals: true, strict: true }),\n\t)\n\tif (!parsed.success) {\n\t\tconst cause = parsed.error\n\t\tthrow new UsageError(\n\t\t\tcause instanceof Error ? cause.message : `Could not read the arguments to '${verb}'.`,\n\t\t)\n\t}\n\tconst { positionals, values } = parsed.value\n\tconst accepted = VERB_OPTIONS[verb].map((option) => optionToName(option))\n\tconst refused = Object.keys(values).filter((name) => !accepted.includes(name))\n\tif (refused.length > 0) {\n\t\tconst names = refused.map((name) => `--${name}`).join(', ')\n\t\tthrow new UsageError(`'${verb}' does not take ${names}.`)\n\t}\n\tconst [name] = positionals\n\tif (positionals.length > 1) {\n\t\tthrow new UsageError(\n\t\t\t`'${verb}' takes at most one argument, and was given ${String(positionals.length)}.`,\n\t\t)\n\t}\n\tif (verb !== 'new' && name !== undefined) {\n\t\tthrow new UsageError(`'${verb}' takes no argument, and was given '${name}'.`)\n\t}\n\tconst paths = Array.isArray(values.from)\n\t\t? values.from.filter((value) => typeof value === 'string')\n\t\t: []\n\tif (verb !== 'catalog' && paths.length > 1) {\n\t\tthrow new UsageError(\n\t\t\t`'${verb}' takes --from once, and was given it ${String(paths.length)} times.`,\n\t\t)\n\t}\n\tconst src = typeof values.src === 'string' ? values.src : undefined\n\tconst app = typeof values.app === 'string' ? values.app : undefined\n\tconst bin = values.bin === true\n\tconst dependencies = typeof values.deps === 'string' ? values.deps : undefined\n\tconst target = typeof values.target === 'string' ? values.target : undefined\n\tconst json = values.json === true\n\tconst [from] = paths\n\tconst location = target === undefined ? {} : { target }\n\tconst source = from === undefined ? {} : { from }\n\tconst selection = typeof values.groups === 'string' ? { groups: values.groups } : {}\n\tswitch (verb) {\n\t\tcase 'new':\n\t\t\tif (name === undefined) {\n\t\t\t\tthrow new UsageError(`'new' needs the workspace ${NAME_ARGUMENT} it is scaffolding.`)\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tverb,\n\t\t\t\tname,\n\t\t\t\tjson,\n\t\t\t\t...location,\n\t\t\t\t...source,\n\t\t\t\t...(src === undefined ? {} : { src }),\n\t\t\t\t...(app === undefined ? {} : { app }),\n\t\t\t\t...(bin ? { bin } : {}),\n\t\t\t\t...(dependencies === undefined ? {} : { dependencies }),\n\t\t\t}\n\t\tcase 'audit':\n\t\t\treturn { verb, json, ...location, ...source, ...selection }\n\t\tcase 'repair':\n\t\t\treturn { verb, json, ...location, ...source, ...selection }\n\t\tcase 'catalog':\n\t\t\treturn {\n\t\t\t\tverb,\n\t\t\t\tjson,\n\t\t\t\tall: values.all === true,\n\t\t\t\t...location,\n\t\t\t\t...(paths.length === 0 ? {} : { from: paths }),\n\t\t\t}\n\t\tcase 'overwrite':\n\t\t\treturn {\n\t\t\t\tverb,\n\t\t\t\tjson,\n\t\t\t\tdirty: values.dirty === true,\n\t\t\t\t...location,\n\t\t\t\t...source,\n\t\t\t\t...selection,\n\t\t\t}\n\t}\n}\n\n/**\n * Read the exit code an audit reports.\n *\n * @param audit - The comparison of a plan against a target.\n * @returns `EXIT_CLEAN` when the target matched the plan, `EXIT_DRIFT` otherwise.\n *\n * @remarks\n * One rule for every verb that carries an audit, so `audit`, `repair`, and\n * `overwrite` cannot disagree about what a clean run is. A blocking question\n * means the gate refused the blueprint, so the audit says nothing about the\n * target and the run is a failure. A foreign finding counts: the target holds a\n * file the plan does not own, which is a difference from the plan whether or not\n * this verb was allowed to remove it. A non-blocking question rides a complete\n * result and does not.\n *\n * @example\n * ```ts\n * import { auditToExit } from './helpers.js'\n *\n * auditToExit({ findings: [], questions: [] }) // 0\n * ```\n */\nexport function auditToExit(audit: Audit): number {\n\tconst blocked = audit.questions.some((question) => question.blocking)\n\tconst drifted = audit.findings.some((finding) => finding.drift !== 'aligned')\n\treturn blocked || drifted ? EXIT_DRIFT : EXIT_CLEAN\n}\n\n/**\n * Project an audit into the human summary of its outcome.\n *\n * @param audit - The comparison to summarize.\n * @returns The refusal, or the planned-path outcome, its grounds, and any foreign-path count.\n *\n * @remarks\n * A blocking question means the gate produced no plan, so the target was not\n * compared and no finding count is reported. Otherwise the three grounds\n * describe what this run did. `bytes` means content-owned\n * bytes were observed, `existence` means presence or absence alone decided the\n * finding, and `nothing` means a birth-owned path was not examined. Foreign\n * paths remain a separate population because no planned ownership accounts for\n * them.\n *\n * @example\n * ```ts\n * import { auditToSummary } from './helpers.js'\n *\n * auditToSummary({\n * findings: [],\n * questions: [{ field: 'src', message: 'Core is required.', blocking: true }],\n * })\n * // 'Audit did not compare the target because the blueprint was refused.'\n * ```\n */\nexport function auditToSummary(audit: Audit): string {\n\tif (audit.questions.some((question) => question.blocking)) {\n\t\treturn 'Audit did not compare the target because the blueprint was refused.'\n\t}\n\tconst planned = audit.findings.filter((finding) => finding.drift !== 'foreign')\n\tconst drifted = planned.filter((finding) => finding.drift !== 'aligned').length\n\t// These counts say what decided each verdict on this run. They partition the\n\t// planned findings, so they sum to `planned.length` and never to `drifted`.\n\tconst bytes = planned.filter(\n\t\t(finding) => finding.ownership === 'content' && finding.observed !== undefined,\n\t).length\n\tconst existence = planned.filter(\n\t\t(finding) =>\n\t\t\tfinding.ownership === 'presence' ||\n\t\t\t(finding.ownership === 'content' && finding.drift === 'missing'),\n\t).length\n\tconst nothing = planned.filter((finding) => finding.ownership === 'birth').length\n\tconst foreign = audit.findings.length - planned.length\n\tconst summary = `${String(drifted)} of ${String(planned.length)} planned path${planned.length === 1 ? '' : 's'} drifted from the plan. Audit compared bytes at ${String(bytes)}, existence at ${String(existence)}, and nothing at ${String(nothing)}.`\n\treturn foreign === 0\n\t\t? summary\n\t\t: `${summary} The plan does not own ${String(foreign)} further path${foreign === 1 ? '' : 's'} beneath its groups.`\n}\n\n/**\n * Project a raised value into the machine-readable failure envelope.\n *\n * @param error - The value a command raised.\n * @returns The envelope naming the coded reason and what went wrong.\n *\n * @remarks\n * A `ScaffoldError` and a {@link UsageError} both publish a code, so both are\n * reported under their own. Anything else failed without saying why, and is\n * reported under one code rather than under an invented reading of it; a raised\n * value that is not an `Error` carries no message worth quoting, so the envelope\n * says so instead of stringifying whatever it was.\n *\n * @example\n * ```ts\n * import { errorToEnvelope } from './helpers.js'\n *\n * errorToEnvelope(new Error('boom')) // { error: { code: 'FAILED', message: 'boom' } }\n * ```\n */\nexport function errorToEnvelope(error: unknown): ErrorEnvelope {\n\tif (isUsageError(error) || isScaffoldError(error)) {\n\t\treturn { error: { code: error.code, message: error.message } }\n\t}\n\tconst message = error instanceof Error ? error.message : FAILED_MESSAGE\n\treturn { error: { code: FAILED_CODE, message } }\n}\n","import type {\n\tAudit,\n\tBlueprint,\n\tCatalogEntry,\n\tDependency,\n\tEnvironment,\n\tGroup,\n\tMirror,\n\tPlan,\n\tQuestion,\n\tRelease,\n} from '@src/core'\nimport type {\n\tMaterializeResult,\n\tMaterializerInterface,\n\tRepository,\n\tUpstreamOptions,\n} from '@src/server'\nimport type {\n\tAuditCommand,\n\tCatalogCommand,\n\tCatalogResult,\n\tCLICommand,\n\tCLIInterface,\n\tCLIOptions,\n\tNewCommand,\n\tOutputHandler,\n\tOverwriteCommand,\n\tOverwriteResult,\n\tRepairCommand,\n\tRepairResult,\n} from './types.js'\nimport { execFileSync } from 'node:child_process'\nimport { renderTable, strip, stripControls } from '@orkestrel/console'\nimport { attempt, isRecord, isString, parseJSON } from '@orkestrel/contract'\nimport { createMarkdown, flattenText, isTableNode } from '@orkestrel/markdown'\nimport {\n\tCATALOG_AGENT_PATH,\n\tBIN_ENTRY_PATH,\n\tblueprintToDevDependencies,\n\tblueprintToRootVite,\n\tblueprintToScripts,\n\tCONFORMANCE_TEST_PATH,\n\tDISTRIBUTION_TEST_PATH,\n\tcreateBlueprint,\n\tcreateCompiler,\n\tDEPENDENCY_NAME_PATTERN,\n\tENVIRONMENTS,\n\tGROUPS,\n\tGLOBAL_SETUP_PATH,\n\tGUIDES_TEST_PATH,\n\tINTEGRATION_TEST_PATH,\n\tmanifestToDependencies,\n\tmanifestToName,\n\tMAX_MANIFEST_BYTES,\n\tnameToGuide,\n\tScaffoldError,\n\tSERVICE_SETUP_PATH,\n\tSHOWCASE_CONFIG_PATH,\n} from '@src/core'\nimport {\n\tcreateMaterializer,\n\tcreateUpstream,\n\tisExactCaseFile,\n\tisPhysicalDirectory,\n\tisRepository,\n\treadFileText,\n\treadSnapshot,\n\tresolveContainedPath,\n} from '@src/server'\nimport { EXIT_CLEAN, EXIT_DRIFT, EXIT_USAGE } from './constants.js'\nimport { isUsageError, UsageError } from './errors.js'\nimport {\n\targvToCommand,\n\tauditToExit,\n\tauditToSummary,\n\terrorToEnvelope,\n\trenderUsage,\n} from './helpers.js'\n\n/**\n * The executable: one command line in, one exit code out.\n *\n * @remarks\n * Every destination this class writes to is a handler it was given, and the run\n * ends by returning its code rather than by setting one, so the whole executable\n * is drivable from inside another process. That is what makes proving what a\n * command prints cost a function call: `src/bin/main.ts` is the only module\n * that reads `process.argv` or assigns `process.exitCode`.\n *\n * Every line leaving here is stripped of ANSI escapes and control characters\n * once, on the way out, because a refusal quotes the argument that caused it and\n * that argument came from an untrusted command line. The machine-readable path\n * needs no second pass: `JSON.stringify` escapes a control character into text\n * before it reaches the handler.\n *\n * The collaborators are constructed per run rather than received, because\n * `--from` decides the vendored root the materializer reads and an instance\n * handed in before the command line was parsed could not honour it. The\n * upstream reader is built the same way but from the options, because no\n * command line names an endpoint: a terminal caller means the published\n * registry and the published guide host, and only the process driving the\n * executable can mean anything else. That is the seam that makes the three\n * verbs which read the network provable without one.\n *\n * @example\n * ```ts\n * import { CLI } from './CLI.js'\n *\n * const lines: string[] = []\n * const code = await new CLI({ output: (line) => lines.push(line) }).execute(['--help'])\n * code // 0\n * ```\n */\nexport class CLI implements CLIInterface {\n\t// The two destinations a terminal caller means. They are the only process\n\t// streams this class names, and it names them once: a handler is what every\n\t// write goes through, so the default is a handler too rather than a branch at\n\t// each write site.\n\tstatic readonly #stdout: OutputHandler = (line) => void process.stdout.write(`${line}\\n`)\n\tstatic readonly #stderr: OutputHandler = (line) => void process.stderr.write(`${line}\\n`)\n\treadonly #output: OutputHandler\n\treadonly #diagnostic: OutputHandler\n\t// What every upstream reader this class builds is constructed from. It is held\n\t// once and read by each verb that reads the network, so the three of them\n\t// cannot disagree about which registry and which guide host a run addresses.\n\treadonly #upstream: UpstreamOptions | undefined\n\n\t/**\n\t * Construct the executable over the two destinations it writes to.\n\t *\n\t * @param options - The report and diagnostic handlers and the upstream\n\t * endpoints; the process streams and the published endpoints when absent.\n\t */\n\tconstructor(options?: CLIOptions) {\n\t\tthis.#output = options?.output ?? CLI.#stdout\n\t\tthis.#diagnostic = options?.diagnostic ?? CLI.#stderr\n\t\tthis.#upstream = options?.upstream\n\t}\n\n\t/**\n\t * Run one command line to completion and report through the configured output.\n\t *\n\t * @param argv - The arguments following the executable's own name.\n\t * @returns The exit code: `0` clean, `1` drift or failure, `2` a usage error.\n\t *\n\t * @remarks\n\t * A request for usage is answered before anything is parsed, because it\n\t * replaces the run rather than modifying it, and because `--help` is not an\n\t * option any verb takes. Everything after that is one command: read it,\n\t * dispatch it, render what it produced, and answer with the code it earned.\n\t *\n\t * @example\n\t * ```ts\n\t * import { CLI } from './CLI.js'\n\t *\n\t * await new CLI().execute(['audit', '--json']) // 0 when the target matches its plan\n\t * ```\n\t */\n\tasync execute(argv: readonly string[]): Promise<number> {\n\t\tif (argv.includes('--help')) {\n\t\t\tfor (const line of renderUsage()) this.#say(line)\n\t\t\treturn EXIT_CLEAN\n\t\t}\n\t\tconst read = attempt(() => argvToCommand(argv))\n\t\t// A command line that never became a command carries no `--json`, so the\n\t\t// refusal is prose: there is no machine-readable value for it to pollute.\n\t\tif (!read.success) return this.#refuse(read.error, false)\n\t\tconst command = read.value\n\t\ttry {\n\t\t\treturn await this.#dispatch(command)\n\t\t} catch (error) {\n\t\t\treturn this.#refuse(error, command.json === true)\n\t\t}\n\t}\n\n\t// One verb per branch, each answering with its own exit code. The switch is\n\t// exhaustive over the command union, so a new verb fails to compile here.\n\tasync #dispatch(command: CLICommand): Promise<number> {\n\t\tswitch (command.verb) {\n\t\t\tcase 'new':\n\t\t\t\treturn this.#create(command)\n\t\t\tcase 'audit':\n\t\t\t\treturn this.#inspect(command)\n\t\t\tcase 'repair':\n\t\t\t\treturn this.#restore(command)\n\t\t\tcase 'catalog':\n\t\t\t\treturn this.#refresh(command)\n\t\t\tcase 'overwrite':\n\t\t\t\treturn this.#replace(command)\n\t\t}\n\t}\n\n\t// `new` — resolve the declared dependencies against the registry, compile the\n\t// blueprint the command line describes, and write it into a vacant target.\n\tasync #create(command: NewCommand): Promise<number> {\n\t\tconst target = command.target ?? command.name\n\t\tconst blueprint = createBlueprint(command.name, {\n\t\t\tsrc: this.#environments(command.src, 'src'),\n\t\t\tapp: this.#environments(command.app, 'app'),\n\t\t\tbin: command.bin === true,\n\t\t\tdependencies: await this.#resolve(this.#packages(command.dependencies)),\n\t\t})\n\t\tconst plan = this.#compile(blueprint)\n\t\tconst materializer = createMaterializer(\n\t\t\tcommand.from === undefined ? undefined : { host: command.from },\n\t\t)\n\t\ttry {\n\t\t\tconst result = materializer.materialize(plan, target)\n\t\t\tif (command.json === true) this.#report(result)\n\t\t\telse {\n\t\t\t\tthis.#say(`Scaffolded ${blueprint.name} into ${result.target}.`)\n\t\t\t\tthis.#say(this.#tally(result))\n\t\t\t}\n\t\t\treturn EXIT_CLEAN\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t}\n\n\t// `audit` — compare a target to the plan its own manifest and directories\n\t// describe, through the vendored host a repair would write from, and write\n\t// nothing whatever it finds.\n\t//\n\t// The host is load-bearing here where it once was not, so `--from` reaches the\n\t// comparison and a host that cannot be read refuses the run under its own\n\t// coded reason. Refusing is the honest answer: the comparison this verb\n\t// reports is the hydrated one, and a fallback to the pure compile would report\n\t// `aligned` for exactly the files whose bytes it failed to read.\n\t#inspect(command: AuditCommand): number {\n\t\tconst target = command.target ?? '.'\n\t\tconst blueprint = this.#derive(target)\n\t\tconst questions = this.#targetQuestions(target, blueprint)\n\t\tconst materializer = createMaterializer(\n\t\t\tcommand.from === undefined ? undefined : { host: command.from },\n\t\t)\n\t\ttry {\n\t\t\tconst [measured] = this.#survey(materializer, blueprint, target, this.#groups(command.groups))\n\t\t\tconst audit: Audit =\n\t\t\t\tquestions.length === 0\n\t\t\t\t\t? measured\n\t\t\t\t\t: { ...measured, questions: [...measured.questions, ...questions] }\n\t\t\tif (command.json === true) this.#report(audit)\n\t\t\telse this.#present(audit)\n\t\t\treturn auditToExit(audit)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t}\n\n\t// `repair` — write each planned path the target is missing or has let drift,\n\t// then re-audit, because the audit a repair reports is the one taken after it.\n\t// One materializer spans the whole verb: the audit that guides the write, the\n\t// write, and the audit that answers for it are three readings of one vendored\n\t// host, and a second instance could not promise they were.\n\t#restore(command: RepairCommand): number {\n\t\tconst target = command.target ?? '.'\n\t\tconst groups = this.#groups(command.groups)\n\t\tconst blueprint = this.#derive(target)\n\t\tthis.#assertTarget(target, blueprint)\n\t\tconst materializer = createMaterializer(\n\t\t\tcommand.from === undefined ? undefined : { host: command.from },\n\t\t)\n\t\ttry {\n\t\t\tconst [audit, plan] = this.#survey(materializer, blueprint, target, groups)\n\t\t\tif (plan === undefined) {\n\t\t\t\tif (command.json === true) this.#report(audit)\n\t\t\t\telse this.#present(audit)\n\t\t\t\treturn EXIT_DRIFT\n\t\t\t}\n\t\t\tconst result = materializer.repair(plan, audit, target)\n\t\t\tconst [terminal] = this.#survey(materializer, blueprint, target, groups)\n\t\t\tconst outcome: RepairResult = { ...result, audit: terminal }\n\t\t\tif (command.json === true) this.#report(outcome)\n\t\t\telse {\n\t\t\t\tthis.#present(terminal)\n\t\t\t\tthis.#reportReplacements(audit, terminal)\n\t\t\t\tthis.#say(this.#tally(result))\n\t\t\t}\n\t\t\treturn auditToExit(terminal)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t}\n\n\t// `catalog` — regenerate the package table from the organization's published\n\t// list and refresh the guide mirrors the target draws on.\n\tasync #refresh(command: CatalogCommand): Promise<number> {\n\t\tconst target = command.target ?? '.'\n\t\tconst [host, ...extra] = command.from ?? []\n\t\tif (extra.length > 0) {\n\t\t\tthis.#warn(\n\t\t\t\t`Read the data root from ${String(host)}. The other ${String(extra.length)} local root${extra.length === 1 ? '' : 's'} named by --from reach nothing this run does.`,\n\t\t\t)\n\t\t}\n\t\tconst previous = this.#previous(target)\n\t\tconst fetched = await this.#fetch(target, command.all === true)\n\t\tconst materializer = createMaterializer(host === undefined ? undefined : { host })\n\t\tlet result: MaterializeResult\n\t\ttry {\n\t\t\tresult = this.#publish(materializer, target, fetched.entries, fetched.mirrors)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t\tconst outcome: CatalogResult = {\n\t\t\t...result,\n\t\t\tentries: fetched.entries,\n\t\t\tmirrors: fetched.mirrors,\n\t\t\tdropped: previous.filter((name) => !fetched.entries.some((entry) => entry.name === name)),\n\t\t}\n\t\tif (command.json === true) this.#report(outcome)\n\t\telse this.#recount(outcome)\n\t\treturn fetched.mirrors.some((mirror) => mirror.lookup === 'failed') ? EXIT_DRIFT : EXIT_CLEAN\n\t}\n\n\t// `overwrite` — everything repair and catalog do, plus the two steps only this\n\t// verb carries. The offline half runs first and persists whatever it did,\n\t// because it is the destructive one: a run that cannot reach upstream still\n\t// leaves the target repaired and says which step it could not complete.\n\tasync #replace(command: OverwriteCommand): Promise<number> {\n\t\tconst target = command.target ?? '.'\n\t\tconst groups = this.#groups(command.groups)\n\t\tconst blueprint = this.#derive(target)\n\t\tthis.#assertTarget(target, blueprint)\n\t\tconst repository = this.#repository(target)\n\t\tif (repository.dirty.length > 0 && command.dirty !== true) {\n\t\t\tthrow new ScaffoldError(\n\t\t\t\t'TARGET',\n\t\t\t\t`The target at ${target} carries ${String(repository.dirty.length)} uncommitted change${repository.dirty.length === 1 ? '' : 's'}. Commit them, or pass --dirty to waive the refusal.`,\n\t\t\t\t{ target, dirty: repository.dirty.length },\n\t\t\t)\n\t\t}\n\t\tconst materializer = createMaterializer(\n\t\t\tcommand.from === undefined ? undefined : { host: command.from },\n\t\t)\n\t\ttry {\n\t\t\tconst [audit, plan] = this.#survey(materializer, blueprint, target, groups)\n\t\t\tif (plan === undefined) {\n\t\t\t\tif (command.json === true) this.#report(audit)\n\t\t\t\telse this.#present(audit)\n\t\t\t\treturn EXIT_DRIFT\n\t\t\t}\n\t\t\tconst repaired = materializer.repair(plan, audit, target)\n\t\t\t// The candidate set is the audit's own foreign findings, so a path the\n\t\t\t// plan claims is never a deletion candidate whatever the tree holds, and\n\t\t\t// neither is a path outside the vendored directories this plan expands.\n\t\t\t// `--dirty` is expressed here and nowhere else: the waiver clears the\n\t\t\t// refusal the observed dirty set would otherwise trigger downstream, and\n\t\t\t// waives nothing about which paths are eligible.\n\t\t\tconst removed = materializer.remove(\n\t\t\t\taudit,\n\t\t\t\tcommand.dirty === true ? { tracked: repository.tracked, dirty: [] } : repository,\n\t\t\t\ttarget,\n\t\t\t)\n\t\t\tconst offline = this.#merge(repaired, removed)\n\t\t\tconst online = await this.#reconcile(materializer, target, blueprint.dependencies)\n\t\t\tconst [terminal] = this.#survey(materializer, blueprint, target, groups)\n\t\t\tconst outcome: OverwriteResult = {\n\t\t\t\t...online,\n\t\t\t\t...this.#merge(offline, online),\n\t\t\t\taudit: terminal,\n\t\t\t}\n\t\t\tif (command.json === true) this.#report(outcome)\n\t\t\telse {\n\t\t\t\tthis.#present(terminal)\n\t\t\t\tthis.#reportReplacements(audit, terminal)\n\t\t\t\tthis.#recount(outcome)\n\t\t\t\tif (online.note !== undefined) this.#warn(online.note)\n\t\t\t}\n\t\t\tif (online.note !== undefined) return EXIT_DRIFT\n\t\t\treturn auditToExit(terminal)\n\t\t} finally {\n\t\t\tmaterializer.destroy()\n\t\t}\n\t}\n\n\t// The network half of `overwrite`, collected rather than thrown: the offline\n\t// half has already written, so a step that cannot complete is reported as the\n\t// step it was instead of discarding what already landed. It writes through the\n\t// verb's own materializer rather than opening a second one, so every byte the\n\t// run lands comes from the host the caller named once.\n\tasync #reconcile(\n\t\tmaterializer: MaterializerInterface,\n\t\ttarget: string,\n\t\tdeclared: readonly Dependency[],\n\t): Promise<Omit<OverwriteResult, 'audit'>> {\n\t\tconst previous = this.#previous(target)\n\t\ttry {\n\t\t\tconst releases = await this.#lookup(declared)\n\t\t\tconst fetched = await this.#fetch(target, false)\n\t\t\tconst written = this.#merge(\n\t\t\t\tthis.#publish(materializer, target, fetched.entries, fetched.mirrors),\n\t\t\t\tmaterializer.declare(this.#pin(releases), target),\n\t\t\t)\n\t\t\treturn {\n\t\t\t\t...written,\n\t\t\t\tentries: fetched.entries,\n\t\t\t\tmirrors: fetched.mirrors,\n\t\t\t\tdropped: previous.filter((name) => !fetched.entries.some((entry) => entry.name === name)),\n\t\t\t\treleases,\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\ttarget,\n\t\t\t\twritten: [],\n\t\t\t\tskipped: [],\n\t\t\t\tremoved: [],\n\t\t\t\tentries: [],\n\t\t\t\tmirrors: [],\n\t\t\t\tdropped: [],\n\t\t\t\treleases: [],\n\t\t\t\tnote: `The catalog step did not complete: ${errorToEnvelope(error).error.message}`,\n\t\t\t}\n\t\t}\n\t}\n\n\t// Measure each declared range against the registry's latest release.\n\tasync #lookup(declared: readonly Dependency[]): Promise<readonly Release[]> {\n\t\tconst upstream = createUpstream(this.#upstream)\n\t\ttry {\n\t\t\treturn await upstream.lookup(declared)\n\t\t} finally {\n\t\t\tupstream.destroy()\n\t\t}\n\t}\n\n\t// Read the organization's published list and the guides the target draws on.\n\t// The workspace never fetches its own guide: that file is its own product.\n\tasync #fetch(\n\t\ttarget: string,\n\t\tall: boolean,\n\t): Promise<{ readonly entries: readonly CatalogEntry[]; readonly mirrors: readonly Mirror[] }> {\n\t\tconst manifest = this.#manifest(target)\n\t\tconst own = manifestToName(manifest)\n\t\tconst declared = manifestToDependencies(manifest).map((dependency) => dependency.name)\n\t\tconst upstream = createUpstream(this.#upstream)\n\t\ttry {\n\t\t\tconst entries = await upstream.catalog()\n\t\t\tconst names = (all ? entries.map((entry) => entry.name) : declared).filter(\n\t\t\t\t(name) => name !== own,\n\t\t\t)\n\t\t\tconst mirrors = await upstream.fetch(names, readSnapshot(target, names.map(nameToGuide)))\n\t\t\treturn { entries, mirrors }\n\t\t} finally {\n\t\t\tupstream.destroy()\n\t\t}\n\t}\n\n\t// Write the fetched guides to their mirrors and the published list to the\n\t// marker-bounded table, as one result.\n\t#publish(\n\t\tmaterializer: MaterializerInterface,\n\t\ttarget: string,\n\t\tentries: readonly CatalogEntry[],\n\t\tmirrors: readonly Mirror[],\n\t): MaterializeResult {\n\t\treturn this.#merge(materializer.mirror(mirrors, target), materializer.catalog(entries, target))\n\t}\n\n\t// The ranges a found release pins. A lookup that produced no answer names no\n\t// version, so it is left declared as it stands rather than rewritten to a\n\t// guess.\n\t#pin(releases: readonly Release[]): readonly Dependency[] {\n\t\tconst pinned: Dependency[] = []\n\t\tfor (const release of releases) {\n\t\t\tif (release.lookup === 'found')\n\t\t\t\tpinned.push({ name: release.name, range: `^${release.latest}` })\n\t\t}\n\t\treturn pinned\n\t}\n\n\t// Compile a blueprint into the plan it describes, or refuse with the questions\n\t// the gate raised.\n\t//\n\t// `new` is the only caller, and it chooses the shape rather than reading one, so\n\t// it refuses every question the gate raises, advisory or not: an advisory names\n\t// a workspace this package can describe honestly and should not create, and this\n\t// is the last moment the caller can pick a different shape. `#survey` is the\n\t// reading counterpart, and it carries the same advisories through instead.\n\t//\n\t// The refusal is `BLOCKED` whichever kind of question earned it, because both\n\t// are the one fact that code names: this blueprint will not be built. The\n\t// questions the message quotes are what tells the two apart, and a second code\n\t// would be a label for a fact they already carry.\n\t#compile(blueprint: Blueprint, groups?: readonly Group[]): Plan {\n\t\tconst compiler = createCompiler()\n\t\ttry {\n\t\t\tconst scaffolding = compiler.compile(blueprint, groups)\n\t\t\tif (scaffolding.plan !== undefined && scaffolding.questions.length === 0) {\n\t\t\t\treturn scaffolding.plan\n\t\t\t}\n\t\t\tthrow new ScaffoldError(\n\t\t\t\t'BLOCKED',\n\t\t\t\tscaffolding.questions.map((question) => `${question.field}: ${question.message}`).join(' '),\n\t\t\t\t{ questions: scaffolding.questions.length },\n\t\t\t)\n\t\t} finally {\n\t\t\tcompiler.destroy()\n\t\t}\n\t}\n\n\t// Compile a blueprint and compare its plan to what the target currently holds,\n\t// through the vendored host a write would draw on.\n\t//\n\t// The materializer owns the comparison because it is the only one that can\n\t// make it: the pure compile claims presence alone, so it reads a canon file a\n\t// consumer has edited as aligned and a vendored directory as one missing path\n\t// no write could ever satisfy. Hydrating first states the bytes and expands\n\t// the directory into the files the host actually stores, which is the same\n\t// derivation the repair that follows is held to.\n\t//\n\t// The compiler answers the refused case alone. A blueprint the gate closed\n\t// carries no plan, so there is nothing to hydrate and nothing to say about the\n\t// target; the audit carries the questions instead.\n\t#survey(\n\t\tmaterializer: MaterializerInterface,\n\t\tblueprint: Blueprint,\n\t\ttarget: string,\n\t\tgroups?: readonly Group[],\n\t): readonly [audit: Audit, plan: Plan | undefined] {\n\t\tconst compiler = createCompiler()\n\t\ttry {\n\t\t\tconst scaffolding = compiler.compile(blueprint, groups)\n\t\t\tif (scaffolding.plan === undefined) return [compiler.audit(blueprint, {}, groups), undefined]\n\t\t\t// The materializer answers for the target and the gate answers for the\n\t\t\t// blueprint, so an advisory the gate raised rides the comparison rather\n\t\t\t// than being dropped between them. It is non-blocking, so it changes no\n\t\t\t// exit code and never makes an aligned target drift.\n\t\t\tconst measured = materializer.audit(scaffolding.plan, target)\n\t\t\treturn [\n\t\t\t\t{ ...measured, questions: [...measured.questions, ...scaffolding.questions] },\n\t\t\t\tscaffolding.plan,\n\t\t\t]\n\t\t} finally {\n\t\t\tcompiler.destroy()\n\t\t}\n\t}\n\n\t// The blueprint a target describes about itself: manifest identity and fleet\n\t// packages, environment directories, and exact structural files. Vendors stay\n\t// unknown because their birth-owned script is not a declaration of its list.\n\t// The live-service project does not wait on that list: it follows its own\n\t// readiness module, which the root configuration names by path.\n\t#derive(target: string): Blueprint {\n\t\tconst manifest = this.#manifest(target)\n\t\tconst declared = manifestToName(manifest)\n\t\tif (declared === undefined) {\n\t\t\tthrow new ScaffoldError('TARGET', `The manifest at ${target} declares no package name.`, {\n\t\t\t\ttarget,\n\t\t\t})\n\t\t}\n\t\tconst bin = resolveContainedPath(target, BIN_ENTRY_PATH)\n\t\tconst guides = resolveContainedPath(target, GUIDES_TEST_PATH)\n\t\tconst distribution = resolveContainedPath(target, DISTRIBUTION_TEST_PATH)\n\t\tconst integration = resolveContainedPath(target, INTEGRATION_TEST_PATH)\n\t\tconst conformance = resolveContainedPath(target, CONFORMANCE_TEST_PATH)\n\t\tconst service = resolveContainedPath(target, SERVICE_SETUP_PATH)\n\t\tconst global = resolveContainedPath(target, GLOBAL_SETUP_PATH)\n\t\tconst showcase = resolveContainedPath(target, SHOWCASE_CONFIG_PATH)\n\t\treturn createBlueprint(declared.slice(declared.lastIndexOf('/') + 1), {\n\t\t\tsrc: this.#probe(target, 'src'),\n\t\t\tapp: this.#probe(target, 'app'),\n\t\t\tdependencies: manifestToDependencies(manifest),\n\t\t\tbin: bin !== undefined && isExactCaseFile(bin),\n\t\t\tguides: guides !== undefined && isExactCaseFile(guides),\n\t\t\tdistribution: distribution !== undefined && isExactCaseFile(distribution),\n\t\t\tintegration: integration !== undefined && isExactCaseFile(integration),\n\t\t\tconformance: conformance !== undefined && isExactCaseFile(conformance),\n\t\t\tservice: service !== undefined && isExactCaseFile(service),\n\t\t\tglobal: global !== undefined && isExactCaseFile(global),\n\t\t\tshowcase: showcase !== undefined && isExactCaseFile(showcase),\n\t\t})\n\t}\n\n\t// Read the literal Vitest projects and npm run scripts one shell command\n\t// invokes. Quotes group a token but do not hide the option, while shell\n\t// expansions make its value unresolved and therefore refuse the write that\n\t// asked the question.\n\t#invocations(\n\t\tscript: string,\n\t): { readonly projects: readonly string[]; readonly scripts: readonly string[] } | undefined {\n\t\tconst tokens: Array<{ value: string; resolved: boolean }> = []\n\t\tlet value = ''\n\t\tlet resolved = true\n\t\tlet started = false\n\t\tlet quote: string | undefined\n\t\tfor (let index = 0; index < script.length; index += 1) {\n\t\t\tconst character = script[index]\n\t\t\tif (character === undefined) return undefined\n\t\t\tif (quote === undefined) {\n\t\t\t\tif (/\\s/.test(character)) {\n\t\t\t\t\tif (started) tokens.push({ value, resolved })\n\t\t\t\t\tvalue = ''\n\t\t\t\t\tresolved = true\n\t\t\t\t\tstarted = false\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (';&|()'.includes(character)) {\n\t\t\t\t\tif (started) tokens.push({ value, resolved })\n\t\t\t\t\tconst paired = script[index + 1] === character && (character === '&' || character === '|')\n\t\t\t\t\ttokens.push({ value: paired ? `${character}${character}` : character, resolved: true })\n\t\t\t\t\tvalue = ''\n\t\t\t\t\tresolved = true\n\t\t\t\t\tstarted = false\n\t\t\t\t\tif (paired) index += 1\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '\"' || character === \"'\") {\n\t\t\t\t\tquote = character\n\t\t\t\t\tstarted = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '\\\\') {\n\t\t\t\t\tconst escaped = script[index + 1]\n\t\t\t\t\tif (escaped === undefined) return undefined\n\t\t\t\t\tvalue += escaped\n\t\t\t\t\tstarted = true\n\t\t\t\t\tindex += 1\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '$' || character === '`' || character === '%') resolved = false\n\t\t\t\tvalue += character\n\t\t\t\tstarted = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (character === quote) {\n\t\t\t\tquote = undefined\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (character === '\\\\' && quote === '\"') {\n\t\t\t\tconst escaped = script[index + 1]\n\t\t\t\tif (escaped === undefined) return undefined\n\t\t\t\tvalue += escaped\n\t\t\t\tindex += 1\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (quote === '\"' && (character === '$' || character === '`' || character === '%')) {\n\t\t\t\tresolved = false\n\t\t\t}\n\t\t\tvalue += character\n\t\t\tstarted = true\n\t\t}\n\t\tif (quote !== undefined) return undefined\n\t\tif (started) tokens.push({ value, resolved })\n\n\t\tconst projects: string[] = []\n\t\tconst scripts: string[] = []\n\t\tfor (let index = 0; index < tokens.length; index += 1) {\n\t\t\tconst token = tokens[index]\n\t\t\tif (token === undefined) return undefined\n\t\t\tif (token.value === 'npm' && tokens[index + 1]?.value === 'run') {\n\t\t\t\tconst name = tokens[index + 2]\n\t\t\t\tif (\n\t\t\t\t\tname === undefined ||\n\t\t\t\t\t!name.resolved ||\n\t\t\t\t\tname.value.length === 0 ||\n\t\t\t\t\t['&&', '||', ';', '|', '&', '(', ')'].includes(name.value)\n\t\t\t\t)\n\t\t\t\t\treturn undefined\n\t\t\t\tscripts.push(name.value)\n\t\t\t\tindex += 2\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (token.value === '--project') {\n\t\t\t\tconst project = tokens[index + 1]\n\t\t\t\tif (\n\t\t\t\t\tproject === undefined ||\n\t\t\t\t\t!project.resolved ||\n\t\t\t\t\tproject.value.length === 0 ||\n\t\t\t\t\t['&&', '||', ';', '|', '&', '(', ')'].includes(project.value)\n\t\t\t\t)\n\t\t\t\t\treturn undefined\n\t\t\t\tprojects.push(project.value)\n\t\t\t\tindex += 1\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (token.value.startsWith('--project=')) {\n\t\t\t\tconst project = token.value.slice('--project='.length)\n\t\t\t\tif (!token.resolved || project.length === 0) return undefined\n\t\t\t\tprojects.push(project)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!token.resolved && token.value.includes('--project')) return undefined\n\t\t}\n\t\treturn { projects, scripts }\n\t}\n\n\t// Report either side of the planned-project invariant. Audit carries the\n\t// advisory; writing verbs turn it into the hard boundary that keeps a\n\t// birth-owned manifest from disagreeing with content-owned configuration.\n\t#projectQuestion(target: string, blueprint: Blueprint, writing = false): Question | undefined {\n\t\tconst manifest = this.#manifest(target)\n\t\tconst planned = blueprintToRootVite(blueprint)\n\t\tconst parsed = parseJSON(manifest)\n\t\tconst scripts = isRecord(parsed) && isRecord(parsed.scripts) ? parsed.scripts : {}\n\t\tconst publishes = !isRecord(parsed) || parsed.private !== true\n\t\tconst gates = publishes ? ['test', 'prepublishOnly'] : ['test']\n\t\tconst gateNames = gates.join(' or ')\n\t\tconst absent = new Set<string>()\n\t\tlet unresolved = false\n\t\tfor (const script of Object.values(scripts)) {\n\t\t\tif (!isString(script) || !script.includes('vitest')) continue\n\t\t\tconst invoked = this.#invocations(script)\n\t\t\tif (invoked === undefined) {\n\t\t\t\tunresolved = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const project of invoked.projects) {\n\t\t\t\tif (!planned.includes(`name: { label: '${project}',`)) absent.add(project)\n\t\t\t}\n\t\t}\n\t\tconst projects = [...absent].sort()\n\t\tif (unresolved) {\n\t\t\treturn {\n\t\t\t\tfield: 'projects',\n\t\t\t\tmessage: `The manifest at ${target} contains a Vitest project expression that cannot be resolved statically.${projects.length === 0 ? '' : ` It also names projects the planned configuration does not register: ${projects.join(', ')}.`} ${writing ? 'Replace it with a literal --project value or remove the script before using a scaffold writing verb.' : 'Replace it with a literal --project value before relying on the planned configuration.'}`,\n\t\t\t\tblocking: false,\n\t\t\t}\n\t\t}\n\t\tif (projects.length > 0) {\n\t\t\treturn {\n\t\t\t\tfield: 'projects',\n\t\t\t\tmessage: writing\n\t\t\t\t\t? `The manifest at ${target} names ${projects.length === 1 ? 'a Vitest project' : 'Vitest projects'} the planned configuration does not register: ${projects.join(', ')}. To continue, remove the ${projects.length === 1 ? 'script that names it' : 'scripts that name them'} or do not use scaffold writing verbs on a workspace that needs ${projects.length === 1 ? 'a custom Vitest project' : 'custom Vitest projects'}.`\n\t\t\t\t\t: `The manifest at ${target} names ${projects.length === 1 ? 'a Vitest project' : 'Vitest projects'} the planned configuration does not register: ${projects.join(', ')}. Add ${projects.length === 1 ? 'the project' : 'each project'} to vite.config.ts or remove the ${projects.length === 1 ? 'script that names it' : 'scripts that name them'}.`,\n\t\t\t\tblocking: false,\n\t\t\t}\n\t\t}\n\t\tconst expected = blueprintToScripts(blueprint)\n\t\tconst expectedLines = new Map<string, string>()\n\t\tfor (const [name, script] of Object.entries(expected)) {\n\t\t\tif (!name.startsWith('test:') || name === 'test:probe') continue\n\t\t\tconst invoked = this.#invocations(script)\n\t\t\tif (invoked === undefined) continue\n\t\t\tfor (const project of invoked.projects) {\n\t\t\t\tif (project === 'probe') continue\n\t\t\t\tconst direct = `test:${project}`\n\t\t\t\tconst command = expected[direct]\n\t\t\t\tif (command !== undefined) {\n\t\t\t\t\texpectedLines.set(project, `\"${direct}\": ${JSON.stringify(command)},`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst reachable = new Set<string>()\n\t\tconst visited = new Set<string>()\n\t\tconst pending = [...gates]\n\t\twhile (pending.length > 0) {\n\t\t\tconst name = pending.shift()\n\t\t\tif (name === undefined || visited.has(name)) continue\n\t\t\tvisited.add(name)\n\t\t\tconst script = scripts[name]\n\t\t\tif (!isString(script)) continue\n\t\t\tconst invoked = this.#invocations(script)\n\t\t\tif (invoked === undefined) {\n\t\t\t\tunresolved = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const project of invoked.projects) reachable.add(project)\n\t\t\tfor (const called of invoked.scripts) {\n\t\t\t\tif (!visited.has(called)) pending.push(called)\n\t\t\t}\n\t\t}\n\t\tif (unresolved) {\n\t\t\treturn {\n\t\t\t\tfield: 'projects',\n\t\t\t\tmessage: `The manifest at ${target} contains a ${gateNames} chain that cannot be resolved statically. ${writing ? 'Replace it with literal npm run script names before using a scaffold writing verb.' : 'Replace it with literal npm run script names before relying on the planned configuration.'}`,\n\t\t\t\tblocking: false,\n\t\t\t}\n\t\t}\n\t\tconst missing = [...expectedLines]\n\t\t\t.filter(([project]) => !reachable.has(project))\n\t\t\t.sort(([left], [right]) => left.localeCompare(right))\n\t\tif (missing.length === 0) return undefined\n\t\tconst names = missing.map(([project]) => project)\n\t\t// A project goes unreached for one of two reasons, and they take opposite\n\t\t// repairs. Where the direct script is absent, the script is what is missing.\n\t\t// Where the target already declares it, adding that line again changes\n\t\t// nothing and the gate chain is what is missing.\n\t\tconst unscripted = missing.filter(([project]) => !isString(scripts[`test:${project}`]))\n\t\tconst ungated = missing.filter(([project]) => isString(scripts[`test:${project}`]))\n\t\t// The script lines are meant to be pasted and end in a trailing comma, so\n\t\t// they go last. Any prose after them reads as part of the paste.\n\t\tconst remedies: string[] = []\n\t\tif (ungated.length > 0) {\n\t\t\tconst declared = ungated.map(([project]) => `test:${project}`)\n\t\t\tremedies.push(\n\t\t\t\t`${declared.join(', ')} ${declared.length === 1 ? 'is' : 'are'} already declared, so the gate is missing rather than the script: invoke ${declared.length === 1 ? 'it' : 'each of them'} by name from the ${gateNames} chain.`,\n\t\t\t)\n\t\t}\n\t\tif (unscripted.length > 0) {\n\t\t\tconst lines = unscripted.map(([, line]) => line)\n\t\t\tremedies.push(\n\t\t\t\t`${writing ? 'To continue, add' : 'Add'} ${lines.length === 1 ? 'this exact script line' : 'these exact script lines'} to package.json: ${lines.join(' ')}`,\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\tfield: 'projects',\n\t\t\tmessage: `The manifest at ${target} does not reach ${names.length === 1 ? 'a Vitest project' : 'Vitest projects'} the planned configuration registers: ${names.join(', ')}. No chain from ${gateNames} invokes ${names.length === 1 ? 'it' : 'them'}. ${remedies.join(' ')}`,\n\t\t\tblocking: false,\n\t\t}\n\t}\n\n\t// Compare planned tooling by membership alone. Ranges are deliberately out of\n\t// scope: overwrite already re-pins declared fleet packages, and a workspace may\n\t// deliberately pin any other tool. Either manifest section may carry a planned\n\t// tool, and workspace-owned extras are not part of the comparison.\n\t#dependencyQuestion(target: string, blueprint: Blueprint, writing = false): Question | undefined {\n\t\tconst parsed = parseJSON(this.#manifest(target))\n\t\tif (!isRecord(parsed)) return undefined\n\t\tconst malformed = ['dependencies', 'devDependencies'].filter(\n\t\t\t(section) => parsed[section] !== undefined && !isRecord(parsed[section]),\n\t\t)\n\t\tif (malformed.length > 0) {\n\t\t\treturn {\n\t\t\t\tfield: 'dependencies',\n\t\t\t\tmessage: `The manifest at ${target} declares ${malformed.join(' and ')} as ${malformed.length === 1 ? 'a value' : 'values'} that ${malformed.length === 1 ? 'is' : 'are'} not ${malformed.length === 1 ? 'an object' : 'objects'}. Replace ${malformed.length === 1 ? 'it' : 'them'} with ${malformed.length === 1 ? 'an object' : 'objects'} before ${writing ? 'using a scaffold writing verb' : 'relying on the planned dependency set'}.`,\n\t\t\t\tblocking: false,\n\t\t\t}\n\t\t}\n\t\tconst dependencies = isRecord(parsed.dependencies) ? parsed.dependencies : {}\n\t\tconst development = isRecord(parsed.devDependencies) ? parsed.devDependencies : {}\n\t\tconst missing = Object.entries(blueprintToDevDependencies(blueprint))\n\t\t\t.filter(([name]) => !Object.hasOwn(dependencies, name) && !Object.hasOwn(development, name))\n\t\t\t.sort(([left], [right]) => left.localeCompare(right))\n\t\tif (missing.length === 0) return undefined\n\t\tconst names = missing.map(([name]) => name)\n\t\tconst lines = missing.map(\n\t\t\t([name, range]) => `${JSON.stringify(name)}: ${JSON.stringify(range)},`,\n\t\t)\n\t\treturn {\n\t\t\tfield: 'dependencies',\n\t\t\tmessage: `The manifest at ${target} does not declare ${names.length === 1 ? 'a planned dependency' : 'planned dependencies'}: ${names.join(', ')}. ${writing ? 'To continue, add' : 'Add'} ${lines.length === 1 ? 'this exact dependency line' : 'these exact dependency lines'} to dependencies or devDependencies in package.json: ${lines.join(' ')}`,\n\t\t\tblocking: false,\n\t\t}\n\t}\n\n\t// Collect the target questions in a fixed order so audit reports every\n\t// independent advisory and writing verbs refuse the same complete answer.\n\t#targetQuestions(target: string, blueprint: Blueprint, writing = false): readonly Question[] {\n\t\tconst questions: Question[] = []\n\t\tconst project = this.#projectQuestion(target, blueprint, writing)\n\t\tif (project !== undefined) questions.push(project)\n\t\tconst dependency = this.#dependencyQuestion(target, blueprint, writing)\n\t\tif (dependency !== undefined) questions.push(dependency)\n\t\treturn questions\n\t}\n\n\t// Writing verbs refuse the advisories because their next step would replace\n\t// planned configuration. Audit alone reports them without changing the target.\n\t#assertTarget(target: string, blueprint: Blueprint): void {\n\t\tconst questions = this.#targetQuestions(target, blueprint, true)\n\t\tif (questions.length === 0) return\n\t\tthrow new ScaffoldError('TARGET', questions.map((question) => question.message).join(' '), {\n\t\t\ttarget,\n\t\t})\n\t}\n\n\t// A target's manifest text, which every reading verb needs before it can say\n\t// anything about the target at all.\n\t#manifest(target: string): string {\n\t\tconst manifest = readFileText(target, 'package.json', MAX_MANIFEST_BYTES)\n\t\tif (manifest === undefined) {\n\t\t\tthrow new ScaffoldError('TARGET', `The target at ${target} carries no readable manifest.`, {\n\t\t\t\ttarget,\n\t\t\t})\n\t\t}\n\t\treturn manifest\n\t}\n\n\t// The environments one axis physically ships, read as directories rather than\n\t// declared, because a directory is the fact and a declaration would be a\n\t// second copy of it free to disagree.\n\t#probe(target: string, axis: string): readonly Environment[] {\n\t\treturn ENVIRONMENTS.filter((environment) => {\n\t\t\tconst full = resolveContainedPath(target, `${axis}/${environment}`)\n\t\t\treturn full !== undefined && isPhysicalDirectory(full)\n\t\t})\n\t}\n\n\t// The packages the target's catalog table listed before this run. Read through\n\t// the declared markdown parser rather than by pattern, so a row is a row\n\t// because the document says so.\n\t#previous(target: string): readonly string[] {\n\t\tconst text = readFileText(target, CATALOG_AGENT_PATH)\n\t\tif (text === undefined) return []\n\t\tconst names: string[] = []\n\t\tfor (const table of createMarkdown(text).filter(isTableNode)) {\n\t\t\tfor (const row of table.rows) {\n\t\t\t\tconst [cell] = row\n\t\t\t\tif (cell === undefined) continue\n\t\t\t\tconst name = cell.map(flattenText).join('').trim()\n\t\t\t\tif (DEPENDENCY_NAME_PATTERN.test(name)) names.push(name)\n\t\t\t}\n\t\t}\n\t\treturn names\n\t}\n\n\t// What git reports about the target's working tree. Deletion draws only on\n\t// what git tracks and refuses a tree carrying uncommitted work, so a target\n\t// that is not a repository has no recovery mechanism and is refused here.\n\t#repository(target: string): Repository {\n\t\tconst tracked = this.#inventory(target, ['ls-files', '-z'])\n\t\tconst dirty = this.#inventory(target, [\n\t\t\t'status',\n\t\t\t'--porcelain=v1',\n\t\t\t'--untracked-files=all',\n\t\t\t'-z',\n\t\t]).map((record) => (record.length > 3 && record[2] === ' ' ? record.slice(3) : record))\n\t\tconst state = { tracked, dirty }\n\t\tif (!isRepository(state)) {\n\t\t\tthrow new ScaffoldError('TARGET', `The git state at ${target} is not a readable inventory.`, {\n\t\t\t\ttarget,\n\t\t\t\ttracked: tracked.length,\n\t\t\t\tdirty: dirty.length,\n\t\t\t})\n\t\t}\n\t\treturn state\n\t}\n\n\t// One git query, answered as its NUL-separated records. Git is asked rather\n\t// than reimplemented, because the tracked set and the dirty set are git's own\n\t// answers and nothing else can give them.\n\t#inventory(target: string, args: readonly string[]): readonly string[] {\n\t\tconst read = attempt(() =>\n\t\t\texecFileSync('git', [...args], {\n\t\t\t\tcwd: target,\n\t\t\t\tencoding: 'utf8',\n\t\t\t\twindowsHide: true,\n\t\t\t\tmaxBuffer: MAX_MANIFEST_BYTES,\n\t\t\t\t// git writes its own refusal to its own stderr, and this class owns\n\t\t\t\t// what leaves it: a failure is reported through the diagnostic handler\n\t\t\t\t// the caller supplied, never straight onto a stream nobody chose.\n\t\t\t\tstdio: ['ignore', 'pipe', 'ignore'],\n\t\t\t}),\n\t\t)\n\t\tif (!read.success) {\n\t\t\tthrow new ScaffoldError('TARGET', `The target at ${target} is not a git repository.`, {\n\t\t\t\ttarget,\n\t\t\t})\n\t\t}\n\t\treturn read.value.split('\\0').filter((record) => record.length > 0)\n\t}\n\n\t// The environments a comma-separated selection names, refused by name when it\n\t// names something that is not one.\n\t#environments(selection: string | undefined, axis: string): readonly Environment[] {\n\t\tif (selection === undefined) return []\n\t\tconst requested = selection.split(',')\n\t\tconst refused = requested.filter(\n\t\t\t(name) => !ENVIRONMENTS.some((environment) => environment === name),\n\t\t)\n\t\tif (refused.length > 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`'--${axis}' does not take ${refused.join(', ')}. It takes ${ENVIRONMENTS.join(', ')}.`,\n\t\t\t)\n\t\t}\n\t\treturn ENVIRONMENTS.filter((environment) => requested.includes(environment))\n\t}\n\n\t// The groups a comma-separated selection names; absence covers every group.\n\t#groups(selection: string | undefined): readonly Group[] | undefined {\n\t\tif (selection === undefined) return undefined\n\t\tconst requested = selection.split(',')\n\t\tconst refused = requested.filter((name) => !GROUPS.some((group) => group === name))\n\t\tif (refused.length > 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`'--groups' does not take ${refused.join(', ')}. It takes ${GROUPS.join(', ')}.`,\n\t\t\t)\n\t\t}\n\t\treturn GROUPS.filter((group) => requested.includes(group))\n\t}\n\n\t// The fleet packages a comma-separated selection names.\n\t#packages(selection: string | undefined): readonly string[] {\n\t\tif (selection === undefined) return []\n\t\tconst requested = selection.split(',')\n\t\tconst refused = requested.filter((name) => !DEPENDENCY_NAME_PATTERN.test(name))\n\t\tif (refused.length > 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`'--deps' does not take ${refused.join(', ')}. Every name is a published @orkestrel package.`,\n\t\t\t)\n\t\t}\n\t\treturn requested\n\t}\n\n\t// Pin each named package to the registry's latest release. A name upstream\n\t// cannot answer for is refused rather than pinned to an invented range: the\n\t// workspace would carry a dependency that does not resolve.\n\tasync #resolve(names: readonly string[]): Promise<readonly Dependency[]> {\n\t\tif (names.length === 0) return []\n\t\tconst upstream = createUpstream(this.#upstream)\n\t\tlet releases: readonly Release[]\n\t\ttry {\n\t\t\treleases = await upstream.lookup(names.map((name) => ({ name, range: '*' })))\n\t\t} finally {\n\t\t\tupstream.destroy()\n\t\t}\n\t\tconst refused = releases.filter((release) => release.lookup !== 'found')\n\t\tif (refused.length > 0) {\n\t\t\tthrow new ScaffoldError(\n\t\t\t\t'FETCH',\n\t\t\t\t`The registry named no release for ${refused.map((release) => release.name).join(', ')}.`,\n\t\t\t\t{ names: refused.length },\n\t\t\t)\n\t\t}\n\t\treturn this.#pin(releases)\n\t}\n\n\t// Two results of one run, read as one. Written and skipped never overlap\n\t// across the calls a verb makes, because each call answers for its own paths.\n\t#merge(first: MaterializeResult, second: MaterializeResult): MaterializeResult {\n\t\treturn {\n\t\t\ttarget: first.target,\n\t\t\twritten: [...first.written, ...second.written],\n\t\t\tskipped: [...first.skipped, ...second.skipped],\n\t\t\tremoved: [...first.removed, ...second.removed],\n\t\t}\n\t}\n\n\t// The audit as a person reads it: every advisory first, then one row per path\n\t// that differs, then the summary. An aligned path is not listed, because a\n\t// report of everything that is fine is a report nobody reads.\n\t#present(audit: Audit): void {\n\t\tfor (const question of audit.questions) this.#warn(`${question.field}: ${question.message}`)\n\t\tconst rows = audit.findings\n\t\t\t.filter((finding) => finding.drift !== 'aligned')\n\t\t\t.map((finding) => [finding.path, finding.group, finding.drift])\n\t\tif (rows.length > 0) {\n\t\t\tconst table = renderTable({\n\t\t\t\tcolumns: [{ label: 'path' }, { label: 'group' }, { label: 'drift' }],\n\t\t\t\trows,\n\t\t\t})\n\t\t\tfor (const line of table.split('\\n')) this.#say(line)\n\t\t}\n\t\tthis.#say(auditToSummary(audit))\n\t}\n\n\t// Name each stale content path the verb replaced, beside the line-count\n\t// difference between the bytes it audited and the bytes its terminal audit\n\t// read back. Missing paths are creations and never enter this report.\n\t#reportReplacements(before: Audit, after: Audit): void {\n\t\tconst terminal = new Map(after.findings.map((finding) => [finding.path, finding]))\n\t\tfor (const finding of before.findings) {\n\t\t\tif (finding.drift !== 'stale') continue\n\t\t\tconst current = terminal.get(finding.path)\n\t\t\tif (current?.drift !== 'aligned' || current.observed === undefined) continue\n\t\t\tconst previousLines = Buffer.from(finding.observed, 'hex')\n\t\t\t\t.toString('utf8')\n\t\t\t\t.split(/\\r\\n|\\r|\\n/u).length\n\t\t\tconst currentLines = Buffer.from(current.observed, 'hex')\n\t\t\t\t.toString('utf8')\n\t\t\t\t.split(/\\r\\n|\\r|\\n/u).length\n\t\t\tconst delta = currentLines - previousLines\n\t\t\tif (delta === 0) {\n\t\t\t\tthis.#say(`${finding.path} replaced (0-line delta).`)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst count = Math.abs(delta)\n\t\t\tthis.#say(\n\t\t\t\t`${finding.path} replaced (${String(count)} line${count === 1 ? '' : 's'} ${delta > 0 ? 'added' : 'removed'}).`,\n\t\t\t)\n\t\t}\n\t}\n\n\t// The catalog outcome as a person reads it.\n\t#recount(result: CatalogResult): void {\n\t\tthis.#say(this.#tally(result))\n\t\tthis.#say(\n\t\t\t`${String(result.entries.length)} published, ${String(result.mirrors.filter((mirror) => mirror.lookup === 'found').length)} guide${result.mirrors.length === 1 ? '' : 's'} fetched, ${String(result.dropped.length)} no longer listed.`,\n\t\t)\n\t\tfor (const mirror of result.mirrors) {\n\t\t\tif (mirror.lookup !== 'found') this.#warn(`${mirror.name}: ${mirror.note}`)\n\t\t}\n\t}\n\n\t// One line stating what a mutation did.\n\t#tally(result: MaterializeResult): string {\n\t\treturn `${String(result.written.length)} written, ${String(result.skipped.length)} unchanged, ${String(result.removed.length)} removed in ${result.target}.`\n\t}\n\n\t// The one machine-readable value a `--json` run emits.\n\t#report(value: unknown): void {\n\t\tthis.#say(JSON.stringify(value))\n\t}\n\n\t// Report a refusal under the code it carries and answer with the code it\n\t// earned: a command line that was not a command is a usage error, and\n\t// everything else is a failed run.\n\t#refuse(error: unknown, json: boolean): number {\n\t\tconst envelope = errorToEnvelope(error)\n\t\tif (json) this.#report(envelope)\n\t\telse this.#warn(`${envelope.error.code}: ${envelope.error.message}`)\n\t\treturn isUsageError(error) ? EXIT_USAGE : EXIT_DRIFT\n\t}\n\n\t#say(line: string): void {\n\t\tthis.#output(this.#sanitize(line))\n\t}\n\n\t#warn(line: string): void {\n\t\tthis.#diagnostic(this.#sanitize(line))\n\t}\n\n\t// The single write path, and the only place hostile bytes are answered for.\n\t// A refusal quotes the argument that caused it, so an escape sequence, a bell,\n\t// or a forged second line arrives here inside otherwise ordinary prose. ANSI\n\t// escapes go first because they are what repaints a terminal, control\n\t// characters next, and what remains is folded onto one line because a handler\n\t// takes one line and a caller writing a record per call must get one record.\n\t#sanitize(line: string): string {\n\t\treturn stripControls(strip(line)).split(/\\r?\\n/).join(' ')\n\t}\n}\n","// The executable entry, and the only module that touches process state: it reads\n// the arguments the process was given and assigns the code the run returned. The\n// `#!/usr/bin/env node` shebang is re-emitted by the build's `output.banner`\n// rather than written here, because the bundler strips a shebang from source.\nimport { CLI } from './CLI.js'\n\nprocess.stdout.on('error', (error) => {\n\tif ('code' in error && error.code === 'EPIPE') return\n\tthrow error\n})\nprocess.exitCode = await new CLI().execute(process.argv.slice(2))\n"],"mappings":";;;;;;;;;;;;;;;;;AAWA,IAAa,kBAAkB;;;;;;;;;AAU/B,IAAa,QAAyB,OAAO,OAAO;CACnD;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;;;AAkBD,IAAa,eAAiD,OAAO,OAAO;EAC7D,IAAA;EACA,IAAA;EACA,IAAA;AACf,CAAC;;;;;;;;;;AAWD,IAAa,aAAa;;AAG1B,IAAa,cAAc;;AAG3B,IAAa,iBAAiB;;;;;;;;AAS9B,IAAa,gBAAgB;;;;;;;;;;;;;;AAe7B,IAAa,kBAA0C,OAAO,OAAO;CACpE,KAAK,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACrC,KAAK,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACrC,KAAK,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;CACtC,MAAM,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACtC,QAAQ,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACxC,KAAK,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;CACtC,OAAO,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;CACxC,MAAM,OAAO,OAAO;EAAE,MAAM;EAAU,UAAU;CAAK,CAAC;CACtD,QAAQ,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;CACxC,MAAM,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,CAAC;;;;;;;;;AAUD,IAAa,iBAAmD,OAAO,OAAO;CAC7E,gBAAgB;CAChB,gBAAgB;CAChB,SAAS;CACT,iBAAiB;CACjB,mBAAmB;CACnB,SAAS;CACT,WAAW;CACX,iBACC;CACD,mBAAmB;CACnB,UAAU;AACX,CAAC;;;;;;;;;;AAWD,IAAa,eAA0D,OAAO,OAAO;CACpF,KAAK,OAAO,OAAO;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ACnlCA,QAAQ,OAAO,GAAG,UAAU,UAAU;CACrC,IAAI,UAAU,SAAS,MAAM,SAAS,SAAS;CAC/C,MAAM;AACP,CAAC;AACD,QAAQ,WAAW,MAAM,IAAI,IAAI,CAAC,CAAC,QAAQ,QAAQ,KAAK,MAAM,CAAC,CAAC"}
@@ -230,6 +230,16 @@ clobbered edits, formatter and build races, cache phantoms, and validation cross
230
230
  invalidates will repair the same drift the other way and report a state that is already false.
231
231
  Run it before the units, or after them, or send the decision to every unit in flight per the
232
232
  mid-campaign rule under **Dispatch anatomy**. Never beside them.
233
+ 8. A fleet pass that records a per-target status commits only the targets it recorded green. Reading
234
+ "is the tree dirty" instead of "did this target pass" pushes a red target the moment one exists,
235
+ and a flake makes that look like it worked. Refuse the failed row, name it, and re-run it alone
236
+ before deciding what it was.
237
+ 9. Run a fleet pass in slices that report as they finish, never as one block. A block hides its first
238
+ failure behind every target that follows, so the failure surfaces after the work it should have
239
+ stopped. A slice hands control back while most of the fleet is still unstarted.
240
+ 10. Re-run a timing or resource failure alone before believing it. Concurrent slices, builds, and
241
+ suites make a container miss deadlines it meets when idle, so a red result under load is a
242
+ question rather than an answer.
233
243
 
234
244
  ## Execution loop
235
245
 
@@ -411,7 +421,7 @@ The harness bridge names the concrete mechanism for each of these.
411
421
 
412
422
  ### Check the brief before you send it
413
423
 
414
- Run these seven checks on every brief. Each is cheap, and skipping one costs a full dispatch cycle
424
+ Run these nine checks on every brief. Each is cheap, and skipping one costs a full dispatch cycle
415
425
  that produces no work, because a unit given a brief that is internally consistent and factually
416
426
  wrong is right to stop.
417
427
 
@@ -439,9 +449,18 @@ wrong is right to stop.
439
449
  - Ask what the change will do to the facts you just measured. A criterion fixed to a measured set is
440
450
  unreachable if the change alters that set, and a file marked off-limits is wrong if the change
441
451
  writes to it. Measure the state the unit will finish in, not only the state it starts from.
452
+ - Grant both halves of a template change where the package generates the configuration it runs on.
453
+ The template and the repository's own materialized copy of that template's output are one change:
454
+ adding a fixed Vitest project moves the template, `vite.config.ts`, `package.json`, and the proof
455
+ file that project includes. Withhold either half and no edit to the owned files can reach the
456
+ gates the brief requires.
442
457
  - Name the property the unit must change, and stop. A consequence you expect to follow from it is an
443
458
  observation for the report, not a criterion. Bundled together, the unit can satisfy neither and
444
459
  cannot tell which half you meant.
460
+ - Keep the brief's control identifiers inside the brief. Label controls so the brief's own table can
461
+ be read, and say in the brief that a test is named for what it proves, never for the control that
462
+ specified it. An implementer writing one test per control otherwise takes the label as the obvious
463
+ name, and a private brief vocabulary becomes a permanent test name.
445
464
 
446
465
  ### Carry every finding
447
466
 
@@ -604,6 +623,16 @@ layering would report a cycle that does not exist. Each package builds against t
604
623
  `scaffold`, never against an unpublished one, and a `scaffold` release therefore publishes on its own
605
624
  and propagates as files rather than as a cascade.
606
625
 
626
+ `scaffold` also carries a second published surface beside `dist/src`: `package.json` ships
627
+ `dist/host`, the vendored file set every target receives through `repair`.
628
+
629
+ - Bump and publish `scaffold` when any vendored byte changes, or when the set of vendored paths
630
+ changes. That surface moved on its own account, and `dist/src` need not move with it.
631
+ - Re-pin `@orkestrel/scaffold` in each target after a vendored-only release, run `repair` there, and
632
+ prove that target's gates still green. `repair` restores `tests/setupPolicy.ts` and
633
+ `tests/policy.test.ts`, so a vendored-only release can turn a green target red. A target bumps
634
+ only when its own published surface moved.
635
+
607
636
  ### Preparing
608
637
 
609
638
  1. **Bump from what the registry serves, not from the local manifest.** A repository's `version`
@@ -641,17 +670,30 @@ flag is what stops the gate chain running a second time inside the five minutes.
641
670
  zero.
642
671
  - Re-probe `whoami` immediately before opening the window. A stored credential expires mid-session,
643
672
  so a session-start answer does not hold.
644
- - Surface each approval URL the moment it appears in the log. Say that approving the publish one
645
- opens a five-minute window covering the rest of the layer.
673
+ - Surface each approval URL the moment it appears in the log, and take the **last** one in log order.
674
+ npm mints a new URL whenever an attempt restarts, and the log accumulates every one, so a URL
675
+ chosen by sorting rather than by position is already dead when the user opens it.
676
+ - Re-read the log before treating an approval as failed. The chain is usually still alive on a newer
677
+ URL, so surface that one rather than relaunching.
678
+ - A `404` on an approval URL usually means the publish already succeeded and consumed it. Read the
679
+ registry before calling it a failure.
680
+ - Say that approving the publish one opens a five-minute window covering the rest of the layer.
646
681
 
647
682
  ### Spending the window
648
683
 
649
684
  - The window opens when the user approves, not when the first publish starts. Chain every remaining
650
685
  publish inside the same process as the gate package, so no human turn sits inside it.
651
686
  - Publish serially. Concurrent publishes collide on the auth handshake and fail each other.
652
- - `EOTP` inside the window is intermittent contention rather than the window closing. Retry each
653
- package about three times before recording it failed, and retry a failed set once the layer ends;
654
- packages have landed on the third attempt and on a later pass with no new approval.
687
+ - **Never retry a publish that is still waiting for its authorization.** Each `npm publish` attempt
688
+ mints a new `authId` and invalidates the previous one, so a retry loop makes the URL a moving
689
+ target the user cannot approve in time. The abandoned poll then reports
690
+ `403 Forbidden - GET /-/v1/done?authId=…`, which reads as a permissions problem and is two attempts
691
+ colliding. Publish the first package of a layer with exactly one attempt.
692
+ - Retry only an upload that failed **inside** an already-open window. `EOTP` there is intermittent
693
+ contention rather than the window closing: retry about three times, and retry a failed set once the
694
+ layer ends. Packages have landed on the third attempt and on a later pass with no new approval.
695
+ These are two different failures wearing similar codes; a retry fixes the second and causes the
696
+ first.
655
697
  - Expect a large layer to outlast one window. Size batches to what uploads in five minutes and tell
656
698
  the user how many approvals to expect, rather than discovering it mid-run.
657
699
  - Read the result from the registry, not from an exit code: a piped `npm publish` reports the exit
@@ -92,6 +92,10 @@ nobody claimed.
92
92
  the orchestrator too:** a tree-wide gate run while a round is live sees the auditors' in-flight probes
93
93
  and reports a failure nobody caused. Wait for the round, or scope the command to paths no auditor
94
94
  owns. Never delete another executor's working file to make your own command pass.
95
+ - **Tell a lane when its own engine wrote the half it is auditing, and tell it to attack that half
96
+ harder.** A fix round reviewed by the engine that wrote it is the case the round exists to avoid,
97
+ and where the pass cannot avoid it, naming it is what recovers the round. A clean pass on its own
98
+ engine's work is the least valuable result a lane can return.
95
99
  - Supply the evidence the subject type requires, per the table above.
96
100
  - Auditors are read-only and spawn nothing.
97
101
  - Blind reports are **immutable**. Nothing an auditor returns is edited, merged, or revised — by
@@ -143,6 +147,14 @@ Follow `references/reconcile.md`. The obligations that are not delegable:
143
147
 
144
148
  - **Reproduce every sharp finding yourself** before acting on it. An auditor's finding is a
145
149
  hypothesis until the orchestrator has run it.
150
+ - **Build before you pack.** `npm pack` runs no build, so it ships whatever `dist/` is on disk. An
151
+ auditor who packs an artifact to inspect it is reading the last build, not the current source, and
152
+ will report deleted exports as still shipping. Run the package's build first, and say in the brief
153
+ that the tarball was built from the commit under audit.
154
+ - **Check the subject before acting on a finding, not only the reasoning.** A brief that names attack
155
+ vectors teaches the lane those vectors matter, and a lane can hand back the brief's own questions as
156
+ the subject's claims — demanding coverage for a property the subject never documented. Grep the
157
+ subject for the claim the finding rests on. Where it is not there, the finding is against the brief.
146
158
  - **A disagreement between auditors is rarely a tie to average.** It is usually two correct answers
147
159
  to two different questions. Find the question each one answered.
148
160
  - **Bound every finding**: state what is _not_ broken, and why the adjacent behaviour that looks the
@@ -73,6 +73,16 @@ endpoint — lockfile generation, real installs, live fetches — belongs to the
73
73
  Orchestrator's own tracked commands or a network-capable native agent. Never put it in a
74
74
  brief. A Sol exec hanging on `npm` until its cap fires is this misroute, not a slow bench.
75
75
 
76
+ ## The exec sandbox mounts `.git` read-only
77
+
78
+ A `workspace-write` exec can write the working tree and cannot write `.git`. Every command
79
+ that takes the index lock fails, `git checkout -- <file>` included.
80
+
81
+ Never write a git command into a brief as a mechanism. A unit that must restore a file it
82
+ mutated restores it by rewriting the original text, and proves it with
83
+ `git diff --exit-code -- <file>`, which reads the index without locking it. Reading commands
84
+ — `status`, `diff`, `log` — are unaffected and stay available.
85
+
76
86
  ## Recovery ladder
77
87
 
78
88
  On any interruption or missing result, in order: