@orkestrel/scaffold 0.0.115 → 0.0.117

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.
Files changed (70) hide show
  1. package/dist/bin/main.js +138 -16
  2. package/dist/bin/main.js.map +1 -1
  3. package/dist/host/agents/skills/orkestrel-publish/references/wave.md +1 -1
  4. package/dist/host/claude/agents/orkestrel.md +2 -2
  5. package/dist/host/claude/rules/names.md +3 -1
  6. package/dist/host/guides/abort.md +17 -17
  7. package/dist/host/guides/agent.md +445 -445
  8. package/dist/host/guides/brief.md +143 -143
  9. package/dist/host/guides/browser.md +731 -731
  10. package/dist/host/guides/budget.md +39 -39
  11. package/dist/host/guides/capture.md +298 -298
  12. package/dist/host/guides/console.md +109 -109
  13. package/dist/host/guides/contract.md +335 -335
  14. package/dist/host/guides/csv.md +30 -30
  15. package/dist/host/guides/database.md +163 -163
  16. package/dist/host/guides/emitter.md +17 -17
  17. package/dist/host/guides/form.md +99 -99
  18. package/dist/host/guides/guide.md +368 -183
  19. package/dist/host/guides/html.md +49 -49
  20. package/dist/host/guides/indexeddb.md +40 -40
  21. package/dist/host/guides/interpret.md +139 -139
  22. package/dist/host/guides/lsp.md +114 -114
  23. package/dist/host/guides/markdown.md +68 -68
  24. package/dist/host/guides/mcp.md +3745 -3745
  25. package/dist/host/guides/middleware.md +170 -170
  26. package/dist/host/guides/msg.md +95 -95
  27. package/dist/host/guides/ndjson.md +8 -8
  28. package/dist/host/guides/ollama.md +56 -56
  29. package/dist/host/guides/pool.md +21 -21
  30. package/dist/host/guides/probe.md +82 -82
  31. package/dist/host/guides/process.md +99 -99
  32. package/dist/host/guides/program.md +98 -96
  33. package/dist/host/guides/qualifier.md +70 -70
  34. package/dist/host/guides/queue.md +37 -37
  35. package/dist/host/guides/rater.md +38 -38
  36. package/dist/host/guides/reason.md +308 -308
  37. package/dist/host/guides/relation.md +50 -50
  38. package/dist/host/guides/router.md +58 -58
  39. package/dist/host/guides/scaffold.md +558 -419
  40. package/dist/host/guides/sea.md +128 -128
  41. package/dist/host/guides/server.md +100 -100
  42. package/dist/host/guides/sqlite.md +28 -28
  43. package/dist/host/guides/sse.md +20 -20
  44. package/dist/host/guides/study.md +444 -444
  45. package/dist/host/guides/table.md +82 -82
  46. package/dist/host/guides/template.md +41 -41
  47. package/dist/host/guides/terminal.md +121 -121
  48. package/dist/host/guides/test.md +273 -273
  49. package/dist/host/guides/timeout.md +18 -18
  50. package/dist/host/guides/tool.md +27 -27
  51. package/dist/host/guides/toolbox.md +166 -166
  52. package/dist/host/guides/websocket.md +54 -54
  53. package/dist/host/guides/worker.md +24 -24
  54. package/dist/host/guides/workflow.md +187 -187
  55. package/dist/host/guides/workspace.md +55 -55
  56. package/dist/host/manifest.json +55 -55
  57. package/dist/host/tests/setupPolicy.ts +5 -3
  58. package/dist/src/core/index.cjs +90 -4
  59. package/dist/src/core/index.cjs.map +1 -1
  60. package/dist/src/core/index.d.cts +229 -144
  61. package/dist/src/core/index.d.ts +229 -144
  62. package/dist/src/core/index.js +88 -5
  63. package/dist/src/core/index.js.map +1 -1
  64. package/dist/src/server/index.cjs +295 -66
  65. package/dist/src/server/index.cjs.map +1 -1
  66. package/dist/src/server/index.d.cts +193 -6
  67. package/dist/src/server/index.d.ts +193 -6
  68. package/dist/src/server/index.js +290 -69
  69. package/dist/src/server/index.js.map +1 -1
  70. package/package.json +5 -4
@@ -90,72 +90,7 @@ export declare type Artifact = HostArtifact | HydratedArtifact | ContentArtifact
90
90
  * ARTIFACT_TEMPLATES.source.empty // ''
91
91
  * ```
92
92
  */
93
- export declare const ARTIFACT_TEMPLATES: Readonly<{
94
- source: Readonly<{
95
- sheet: Readonly<{
96
- 'index.scss': "@use 'tokens';\n@use 'elements';\n@use 'components';\n@use 'utilities';\n";
97
- '_tokens.scss': "@layer theme, reset, base, elements, components, utilities;\n";
98
- '_mixins.scss': "";
99
- 'elements/_index.scss': "";
100
- 'components/_index.scss': "";
101
- 'utilities/_index.scss': "";
102
- 'sheet.ts': "import './index.scss'\n";
103
- 'index.ts': "export * from './sheet.js'\n";
104
- }>;
105
- themes: Readonly<{
106
- 'index.scss': "@use '../tokens';\n@use 'default';\n";
107
- '_default.scss': "";
108
- 'sheet.ts': "import './index.scss'\n";
109
- }>;
110
- empty: "";
111
- barrel: "// TODO: [Feature] Export the browser extension API.\n";
112
- main: "document.body\n\t.appendChild(document.createElement('main'))\n\t.appendChild(document.createElement('h1')).textContent ={{heading}}\n";
113
- vue: Readonly<{
114
- 'main.ts': "import { createApp } from 'vue'\nimport App from './App.vue'\n\ncreateApp(App).mount(document.body.appendChild(document.createElement('main')))\n";
115
- 'App.vue': "<template>\n\t<h1>{{heading}}</h1>\n</template>\n";
116
- }>;
117
- browser: "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"UTF-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n\t\t<title>Application</title>\n\t</head>\n\t<body>\n\t\t<script type=\"module\" src=\"/main.ts\"></script>\n\t</body>\n</html>\n";
118
- }>;
119
- tests: Readonly<{
120
- journey: "import {\n\tACCESSIBLE_ROLES,\n\tcreatePortfolio,\n\texpandCaptures,\n\tisRendered,\n\treadRefusal,\n\treadStyle,\n} from '@orkestrel/test/browser'\n{{imports}}import { page } from 'vitest/browser'\nimport { describe, expect, inject, it } from 'vitest'\n\nconst VARIANT = inject('variant')\nconst VARIANTS = inject('variants')\nconst CAPTURE = inject('capture')\n\ndescribe('{{application}} arrival journey', () => {\n\tit('proves the declared arrival families', async () => {\n\t\tconst families = ['Journey', 'Refusal', 'Matrix', ...(CAPTURE ? ['Capture'] : [])]\n\t\tconst proven: string[] = []\n\t\tconst states = ['{{application}}-arrival']\n\t\tconst placed: string[] = []\n\t\tconst portfolio = createPortfolio({\n\t\t\tstates,\n\t\t\tvariants: VARIANTS,\n\t\t\tvariant: VARIANT,\n\t\t\tdirectory: '../../../tmp/captures/states',\n\t\t\tenabled: CAPTURE,\n\t\t})\n{{mount}}\t\ttry {\n{{arrival}}\t\t\tconst heading = page\n\t\t\t\t.getByRole('heading', {\n\t\t\t\t\tname: {{heading}},\n\t\t\t\t\texact: true,\n\t\t\t\t\tlevel: 1,\n\t\t\t\t})\n\t\t\t\t.element()\n\t\t\texpect(isRendered(heading)).toBe(true)\n\t\t\tproven.push('Journey')\n\t\t\tawait portfolio.place('{{application}}-arrival')\n\t\t\tplaced.push('{{application}}-arrival')\n\n\t\t\tfor (const role of ACCESSIBLE_ROLES) expect(page.getByRole(role).elements()).toEqual([])\n\t\t\texpect(readRefusal('Continue')).toBe(\n\t\t\t\t'No interactive element has the accessible name \"Continue\"',\n\t\t\t)\n\t\t\tproven.push('Refusal')\n\n\t\t\tconst measured: string[] = []\n\t\t\tfor (const variant of VARIANTS) {\n\t\t\t\tawait page.viewport(variant.width, variant.height)\n\t\t\t\texpect(readStyle(heading, 'display')).toBe('block')\n\t\t\t\texpect(window.innerWidth).toBe(variant.width)\n\t\t\t\tmeasured.push(variant.name)\n\t\t\t}\n\t\t\texpect(measured).toEqual(VARIANTS.map(({ name }) => name))\n\t\t\tproven.push('Matrix')\n\n\t\t\tconst files = expandCaptures(states, VARIANTS)\n\t\t\texpect(portfolio.files).toEqual(files)\n\t\t\texpect(new Set(files).size).toBe(states.length * VARIANTS.length)\n\t\t\texpect(placed).toEqual(states)\n\t\t\tconst expected = CAPTURE\n\t\t\t\t? expandCaptures(\n\t\t\t\t\t\tstates,\n\t\t\t\t\t\tVARIANTS.filter(({ name }) => name === VARIANT),\n\t\t\t\t\t)\n\t\t\t\t: []\n\t\t\texpect(portfolio.paths.map((path) => path.replaceAll('\\\\', '/').split('/').at(-1))).toEqual(\n\t\t\t\texpected,\n\t\t\t)\n\t\t\tif (CAPTURE) proven.push('Capture')\n\t\t\texpect(proven).toEqual(families)\n\t\t} finally {\n{{cleanup}}\t\t\tconst variant = VARIANTS.find(({ name }) => name === VARIANT)\n\t\t\tif (variant !== undefined) await page.viewport(variant.width, variant.height)\n\t\t}\n\t})\n})\n";
121
- browser: "import type { JourneyVariant } from '@orkestrel/test'\n\ndeclare module 'vitest' {\n\texport interface ProvidedContext {\n\t\treadonly variant: string\n\t\treadonly variants: readonly JourneyVariant[]\n\t\treadonly capture: boolean\n\t}\n}\n";
122
- sheet: "import sheet from '{{root}}dist/src/{{name}}/index.css?raw'\nimport { adoptSheet, readLayerNames } from '@orkestrel/test/browser'\nimport { describe, expect, it } from 'vitest'\n\ndescribe('{{name}} entry', () => {\n\tit('opens with the declared cascade order', () => {\n\t\tconst adopted = adoptSheet(sheet)\n\t\ttry {\n\t\t\texpect(adopted.sheet.cssRules[0]?.cssText).toBe(\n\t\t\t\t'@layer theme, reset, base, elements, components, utilities;',\n\t\t\t)\n\t\t\texpect(readLayerNames(adopted.sheet).slice(0, 6)).toEqual([\n\t\t\t\t'theme',\n\t\t\t\t'reset',\n\t\t\t\t'base',\n\t\t\t\t'elements',\n\t\t\t\t'components',\n\t\t\t\t'utilities',\n\t\t\t])\n\t\t} finally {\n\t\t\tadopted.release()\n\t\t}\n\t})\n})\n";
123
- styles: Readonly<{
124
- module: "";
125
- proof: "";
126
- }>;
127
- setup: "";
128
- global: Readonly<{
129
- module: "export function setup(): void {}\n";
130
- proof: "import { describe, expect, it } from 'vitest'\nimport { setup } from './setupGlobal.js'\n\ndescribe('global setup', () => {\n\tit('runs without producing a teardown', () => {\n\t\texpect(setup()).toBeUndefined()\n\t\texpect(setup()).toBeUndefined()\n\t})\n})\n";
131
- }>;
132
- entry: "import * as entry from {{specifier}}\nimport { describe, expect, it } from 'vitest'\n\ndescribe({{label}}, () => {\n\tit('has no starter exports', () => {\n\t\texpect(Object.keys(entry)).toStrictEqual([])\n\t})\n})\n";
133
- bin: "import { describe, expect, it } from 'vitest'\n\ndescribe('bin entry', () => {\n\tit('has no starter exports', async () => {\n{{import}}\n\t\texpect(Object.keys(entry)).toStrictEqual([])\n\t})\n})\n";
134
- distribution: Readonly<{
135
- module: "{{types}}import type { SpawnSyncReturns } from 'node:child_process'\nimport type { TestContext } from 'vitest'\nimport { spawnSync } from 'node:child_process'\nimport {\n\texistsSync,\n\tmkdirSync,\n\tmkdtempSync,\n\treaddirSync,\n\treadFileSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync,\n} from 'node:fs'\n{{transport}}import { createRequire } from 'node:module'\nimport { tmpdir } from 'node:os'\nimport { dirname, join, relative as relativePath, resolve, sep } from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { isDeepStrictEqual } from 'node:util'\nimport { parseSync } from 'vite'\n{{launcher}}\n/** Defines the lifecycle and installed consumer read by a distribution proof. */\nexport interface DistributionSuiteInterface {\n\treadonly scratch: string\n\tstart(): void\n\tread(context: TestContext): DistributionStage\n\tdestroy(): void\n}\n\n/** Holds the observed and required values for one distribution assertion. */\nexport interface DistributionObservation {\n\treadonly actual: unknown\n\treadonly expected: unknown\n}\n\n/** Defines one independently registered distribution observation. */\nexport interface DistributionCase {\n\treadonly label: string\n\treadonly observe: (\n\t\tcontext: TestContext,\n\t) => DistributionObservation | Promise<DistributionObservation>\n}\n\n/** Holds the installed export map's classified publications. */\nexport interface DistributionClassification {\n\treadonly entries: readonly DistributionEntry[]\n\treadonly subpaths: readonly string[]\n\treadonly undeclared: readonly string[]\n\treadonly excluded: readonly string[]\n\treadonly targets: readonly string[]\n}\n\n/** Names the workspace whose packed artifact the proof consumes. */\nexport const DISTRIBUTION_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')\n/** Names the npm executable on the running host. */\nexport const DISTRIBUTION_NPM = process.platform === 'win32' ? 'npm.cmd' : 'npm'\n// The compiler this workspace installs, run as a command rather than called in\n// process: the command and its plain-text diagnostics are the same across the\n// compiler majors this toolchain supports, and its in-process API is not. It is\n// resolved from the workspace under proof, so a consumer of the packed artifact is\n// checked by the same compiler that workspace's own `check` script runs. TypeScript 7 exports\n// `package.json` but not `bin/tsc`, so the path is joined from the manifest's directory.\n/** Names the TypeScript manifest installed by the workspace under proof. */\nexport const DISTRIBUTION_TYPESCRIPT = createRequire(\n\tjoin(DISTRIBUTION_ROOT, 'package.json'),\n).resolve('typescript/package.json')\n/** Names the compiler installed by the workspace under proof. */\nexport const DISTRIBUTION_COMPILER = join(dirname(DISTRIBUTION_TYPESCRIPT), 'bin', 'tsc')\n// Windows needs a shell to launch a `.cmd`: Node refuses one directly since the\n// batch-argument hardening, and `spawnSync` returns `EINVAL` with a null status\n// rather than an exit code a caller can read. Every following argument is a literal or\n// a path this file built, so the shell has nothing to escape.\n/** Selects the Windows command-shell route required by the npm shim. */\nexport const DISTRIBUTION_SHELL = process.platform === 'win32'\n// `prepublishOnly` runs this proof as `npm run test:distribution -- --mode release`,\n// and the root configuration's project factories carry that mode into this project.\n// Release is the publish gate, so evidence it cannot obtain fails there and skips\n// everywhere else: a gate that passes on missing evidence proves nothing.\n/** Indicates whether missing prerequisites must fail the publish gate. */\nexport const DISTRIBUTION_RELEASE = import.meta.env?.MODE === 'release'\n// The built output directory convention a browser face may publish from. Every\n// selection reads this prefix off the export target and never off the subpath name. A\n// workspace whose only published face is the browser one publishes that face at the\n// root subpath, so a rule keyed on the subpath name drives a browser bundle through\n// Node and the miss is silent.\n/** Names the conventional output prefix for a browser publication. */\nexport const DISTRIBUTION_BROWSER_OUTPUT = './dist/src/browser/'\n/** Names the unpublished subpath used as a resolution control. */\nexport const DISTRIBUTION_ABSENT_SUBPATH = '/no-subpath-is-published-under-this-name'\n// A compiler diagnostic that says where it is: the path relative to the directory\n// the compiler ran in, the 1-based line and column, the code, and the message. The\n// diagnostics are the verdict rather than the exit code, which differs between the\n// compiler majors this toolchain supports, so a reported line matching nothing here\n// came from something other than a check of a consumer module.\n/** Matches the location prefix of a consumer compiler diagnostic. */\nexport const DISTRIBUTION_DIAGNOSTIC_PATTERN = /^(.+?)\\(\\d+,\\d+\\): error TS\\d+: /u\n/** Lists the bounded registry-readiness command arguments. */\nexport const DISTRIBUTION_PING = Object.freeze([\n\t'ping',\n\t'--fetch-retries=0',\n\t'--fetch-timeout=5000',\n\t'--loglevel=silent',\n])\n/** Names the consumer entry that imports an installed module. */\nexport const DISTRIBUTION_ESM_DRIVER = 'drive.mjs'\n/** Names the consumer entry that requires an installed module. */\nexport const DISTRIBUTION_CJS_DRIVER = 'drive.cjs'\n/** Defines the isolated consumer package manifest. */\nexport const DISTRIBUTION_CONSUMER_MANIFEST =\n\t'{ \"name\": \"distribution-consumer\", \"private\": true, \"type\": \"module\" }\\n'\n/** Reads the names exported by an installed ESM entry. */\nexport const DISTRIBUTION_ESM_DRIVER_SOURCE = `const entry = await import(process.argv[2])\nprocess.stdout.write(JSON.stringify(Object.keys(entry).sort()))\n`\n/** Reads the names exported by an installed CommonJS entry. */\nexport const DISTRIBUTION_CJS_DRIVER_SOURCE = `const entry = require(process.argv[2])\nprocess.stdout.write(JSON.stringify(Object.keys(entry).sort()))\n`\n\n// The extensions a JavaScript handler loads as modules. Node loads a native addon\n// through its addon handler instead, so that extension is named separately.\n/** Lists extensions loaded as JavaScript modules. */\nexport const DISTRIBUTION_MODULE_EXTENSIONS = Object.freeze(['.js', '.mjs', '.cjs'])\n/** Names the extension loaded by the native-addon handler. */\nexport const DISTRIBUTION_ADDON_EXTENSION = '.node'\n// The extensions a declaration file carries. A `require` condition declares\n// `.d.cts` and an ESM-only one `.d.mts`, so the `.d.ts` spelling alone does not\n// name them.\n/** Lists the supported TypeScript declaration extensions. */\nexport const DISTRIBUTION_DECLARATION_EXTENSIONS = Object.freeze(['.d.ts', '.d.cts', '.d.mts'])\n/** Names the module format of a typed consumer. */\nexport type DistributionFormat = 'module' | 'commonjs'\n\n// The Node import target is resolved with the conditions that driver supplies. The\n// CommonJS compile probe is selected from its declaration's format, and its runtime\n// drive loads the same subpath through Node's require resolver. Vite's production\n// client build enables its module and browser conditions.\n/** Defines the conditions each runtime uses to resolve an entry. */\nexport const DISTRIBUTION_RUNTIME_CONDITIONS = Object.freeze({\n\tmodule: Object.freeze(['node-addons', 'node', 'import', 'module-sync']),\n\tcommonjs: Object.freeze(['node-addons', 'node', 'require', 'module-sync']),\n\tbrowser: Object.freeze(['module', 'browser', 'production', 'import']),\n})\n// TypeScript's Node resolutions add `node` to the format condition. Its bundler\n// resolution does not, so a browser drive compares against the declaration a bundler\n// consumer reads rather than borrowing the Node declaration.\n/** Defines the declaration conditions used by bundler consumers. */\nexport const DISTRIBUTION_BUNDLER_CONDITIONS = Object.freeze({\n\tmodule: Object.freeze(['types', 'import']),\n\tcommonjs: Object.freeze(['types', 'require']),\n})\n/** Defines the declaration conditions paired with each runtime. */\nexport const DISTRIBUTION_DECLARATION_CONDITIONS = Object.freeze({\n\tmodule: Object.freeze(['types', 'node', 'import']),\n\tcommonjs: Object.freeze(['types', 'node', 'require']),\n\tbrowser: DISTRIBUTION_BUNDLER_CONDITIONS.module,\n})\n\n/** Describes the compiler options and conditions for one consumer resolution. */\nexport interface DistributionResolution {\n\treadonly label: string\n\treadonly resolution: string\n\treadonly module: string\n\treadonly conditions: Readonly<Record<DistributionFormat, readonly string[]>>\n}\n\n/** Holds the target selected by package condition resolution. */\nexport interface DistributionTargetResult {\n\treadonly target: string\n}\n\n// Each compile driver carries the compiler options its scratch project sets and\n// the conditions TypeScript applies for that resolution and importing format. A\n// `require`-only subpath therefore stays in each CommonJS probe that can resolve it.\n// The option values are the spellings the project file takes, so nothing here needs\n// the compiler's own API to name them.\n/** Lists the compiler resolutions driven against installed declarations. */\nexport const DISTRIBUTION_RESOLUTIONS: readonly DistributionResolution[] = Object.freeze([\n\t{\n\t\tlabel: 'node16',\n\t\tresolution: 'node16',\n\t\tmodule: 'node16',\n\t\tconditions: DISTRIBUTION_DECLARATION_CONDITIONS,\n\t},\n\t{\n\t\tlabel: 'nodenext',\n\t\tresolution: 'nodenext',\n\t\tmodule: 'nodenext',\n\t\tconditions: DISTRIBUTION_DECLARATION_CONDITIONS,\n\t},\n\t{\n\t\tlabel: 'bundler',\n\t\tresolution: 'bundler',\n\t\tmodule: 'esnext',\n\t\tconditions: DISTRIBUTION_BUNDLER_CONDITIONS,\n\t},\n])\n\n// The driver a bundled consumer reads declarations under. A browser application\n// compiles through a bundler, so the browser drive answers under this one alone,\n// and naming it here is what keeps that selection tied to the driver it selects.\n/** Selects the compiler resolution used by a browser consumer. */\nexport const DISTRIBUTION_BROWSER_RESOLUTION = DISTRIBUTION_RESOLUTIONS.find(\n\t(candidate) => candidate.label === 'bundler',\n)\nif (DISTRIBUTION_BROWSER_RESOLUTION === undefined)\n\tthrow new Error(\"DISTRIBUTION_RESOLUTIONS carries no 'bundler' row\")\n\n/** Pairs consumer source extensions with their module formats. */\nexport const DISTRIBUTION_FORMATS: ReadonlyArray<\n\treadonly [extension: string, format: DistributionFormat]\n> = Object.freeze([\n\t['ts', 'module'],\n\t['cts', 'commonjs'],\n])\n\n// One published subpath, resolved to what this proof can drive: the specifier a\n// consumer writes, whether the declarations its consumer formats resolve at all,\n// whether the exports map answers the browser condition with a target of its own,\n// whether it answers `import` and `require` at all, and whether the target that\n// `require` answers with is one that a CommonJS consumer loads.\n/** Describes one published subpath and its runtime and declaration capabilities. */\nexport interface DistributionEntry {\n\treadonly subpath: string\n\treadonly specifier: string\n\treadonly mapping: unknown\n\treadonly declaration: {\n\t\treadonly importable: boolean\n\t\treadonly requirable: boolean\n\t\treadonly browsable: boolean\n\t}\n\treadonly browsable: boolean\n\treadonly importable: boolean\n\treadonly requirable: boolean\n\treadonly loadable: boolean\n}\n\n// The installed tree every claim is read from. Every subpath the exports map names\n// lands in exactly one of `entries`, `undeclared`, and `excluded`, so a subpath this\n// proof cannot drive is reported rather than dropped.\n/** Holds the installed consumer and the partition of its published subpaths. */\nexport interface DistributionStage {\n\treadonly consumer: string\n\treadonly installed: string\n\treadonly archives: readonly string[]\n\treadonly entries: readonly DistributionEntry[]\n\treadonly subpaths: readonly string[]\n\treadonly undeclared: readonly string[]\n\treadonly excluded: readonly string[]\n\treadonly targets: readonly string[]\n}\n\n/**\n * Checks whether a value is a non-null object other than an array.\n *\n * @param value - The value to inspect.\n * @returns True if the value is a record; false otherwise.\n */\nexport function isDistributionRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/**\n * Checks whether a value is an array of strings.\n *\n * @param value - The value to inspect.\n * @returns True if every array member is a string; false otherwise.\n */\nexport function isDistributionNames(value: unknown): value is readonly string[] {\n\treturn Array.isArray(value) && value.every((name) => typeof name === 'string')\n}\n\n// A fallback list, which is what Node reads an array in an exports entry as. The\n// narrowing is what the following walkers need: `Array.isArray` widens an `unknown`\n// member to `any`, and an entry read that way is not read at all.\n/**\n * Checks whether a value is a fallback array.\n *\n * @param value - The value to inspect.\n * @returns True if the value is an array; false otherwise.\n */\nexport function isDistributionList(value: unknown): value is readonly unknown[] {\n\treturn Array.isArray(value)\n}\n\n// Whether a string is a valid package target. Node rejects a target outside the\n// package and a target containing a dot, parent, or node_modules segment during\n// package-target resolution. A later module-resolution failure is not the same\n// thing: an array falls through the former and keeps the latter.\n/**\n * Checks whether a relative package target contains only admitted segments.\n *\n * @param target - The package-relative target.\n * @returns True if the target passes package-target validation; false otherwise.\n */\nexport function matchesDistributionPackageTarget(target: string): boolean {\n\tif (!target.startsWith('./')) return false\n\tconst refused = ['.', '..', 'node_modules']\n\treturn target\n\t\t.slice(2)\n\t\t.split(/[\\\\/]/u)\n\t\t.every((segment) => {\n\t\t\ttry {\n\t\t\t\treturn !refused.includes(decodeURIComponent(segment).toLowerCase())\n\t\t\t} catch {\n\t\t\t\treturn !refused.includes(segment.toLowerCase())\n\t\t\t}\n\t\t})\n}\n\n/**\n * Reads and parses a JSON file.\n *\n * @param path - The file to read.\n * @returns The parsed value. Throws when reading or parsing fails.\n */\nexport function readDistributionJSON(path: string): unknown {\n\tconst parsed: unknown = JSON.parse(readFileSync(path, 'utf8'))\n\treturn parsed\n}\n\n/**\n * Reads the package name from a manifest.\n *\n * @param path - The manifest to read.\n * @returns The package name. Throws when the manifest has no string name.\n */\nexport function readDistributionManifestName(path: string): string {\n\tconst manifest = readDistributionJSON(path)\n\tif (!isDistributionRecord(manifest) || typeof manifest.name !== 'string') {\n\t\tthrow new Error(`The manifest at ${path} declares no package name`)\n\t}\n\treturn manifest.name\n}\n\n// A host carries a package's required peers at its own root. A consumer that carries none leaves\n// npm to place them, and npm can then resolve an optional peer of a peer to a release the\n// package's own range refuses, so the consumer declares them as a host would.\n/**\n * Reads the peers a host must carry: every peer dependency its metadata does not mark optional.\n *\n * @param path - The manifest to read.\n * @returns Each required peer's name mapped to its declared range.\n */\nexport function readDistributionPeers(path: string): Readonly<Record<string, string>> {\n\tconst manifest = readDistributionJSON(path)\n\tif (!isDistributionRecord(manifest) || !isDistributionRecord(manifest.peerDependencies)) {\n\t\treturn {}\n\t}\n\tconst meta = isDistributionRecord(manifest.peerDependenciesMeta)\n\t\t? manifest.peerDependenciesMeta\n\t\t: undefined\n\tconst peers = Object.entries(manifest.peerDependencies).filter(\n\t\t(entry): entry is [string, string] => typeof entry[1] === 'string',\n\t)\n\treturn Object.fromEntries(\n\t\tpeers.filter(([name]) => {\n\t\t\tconst entry = meta?.[name]\n\t\t\treturn !isDistributionRecord(entry) || entry.optional !== true\n\t\t}),\n\t)\n}\n\n/**\n * Writes the consumer manifest, declaring the required peers as dependencies.\n *\n * @param peers - Each required peer's name mapped to its declared range.\n * @returns The manifest text; the bare manifest when the package declares no required peer.\n */\nexport function createDistributionConsumerManifest(\n\tpeers: Readonly<Record<string, string>>,\n): string {\n\tconst manifest: unknown = JSON.parse(DISTRIBUTION_CONSUMER_MANIFEST)\n\tif (Object.keys(peers).length === 0 || !isDistributionRecord(manifest)) {\n\t\treturn DISTRIBUTION_CONSUMER_MANIFEST\n\t}\n\treturn `${JSON.stringify({ ...manifest, dependencies: peers })}\\n`\n}\n\n/**\n * Writes a consumer file after creating its parent directory.\n *\n * @param path - The file to write.\n * @param content - The text to write.\n */\nexport function writeDistributionFile(path: string, content: string): void {\n\tmkdirSync(dirname(path), { recursive: true })\n\twriteFileSync(path, content)\n}\n\n/**\n * Combines the output streams of a completed command.\n *\n * @param result - The completed command.\n * @returns The trimmed diagnostic text.\n */\nexport function readDistributionOutput(result: SpawnSyncReturns<string>): string {\n\treturn `${result.stdout ?? ''}${result.stderr ?? ''}`.trim()\n}\n\n/**\n * Runs npm with a cache inside the owned scratch directory.\n *\n * @param args - The npm arguments.\n * @param cwd - The working directory.\n * @param scratch - The owned scratch root.\n * @returns The command status and captured streams.\n */\nexport function runDistributionNpm(\n\targs: readonly string[],\n\tcwd: string,\n\tscratch: string,\n): SpawnSyncReturns<string> {\n\treturn spawnSync(DISTRIBUTION_NPM, [...args], {\n\t\tcwd,\n\t\tencoding: 'utf8',\n\t\tenv: { ...process.env, npm_config_cache: join(scratch, 'cache') },\n\t\tshell: DISTRIBUTION_SHELL,\n\t\twindowsHide: true,\n\t})\n}\n\n/**\n * Runs a JavaScript entry with the running Node executable.\n *\n * @param args - The Node arguments.\n * @param cwd - The working directory.\n * @returns The command status and captured streams.\n */\nexport function runDistributionNode(\n\targs: readonly string[],\n\tcwd: string,\n): SpawnSyncReturns<string> {\n\treturn spawnSync(process.execPath, [...args], { cwd, encoding: 'utf8', windowsHide: true })\n}\n\n// Node's own condition matching, read in declaration order.\n/**\n * Resolves a package target through conditions and fallback arrays.\n *\n * @param entry - The exports-map entry.\n * @param conditions - The active resolution conditions.\n * @returns The selected target, or undefined when no branch resolves.\n */\nexport function resolveDistributionPackageTarget(\n\tentry: unknown,\n\tconditions: readonly string[],\n): DistributionTargetResult | undefined {\n\tif (typeof entry === 'string') return { target: entry }\n\tif (isDistributionList(entry)) {\n\t\tfor (const member of entry) {\n\t\t\tconst resolved = resolveDistributionPackageTarget(member, conditions)\n\t\t\tif (resolved !== undefined && matchesDistributionPackageTarget(resolved.target))\n\t\t\t\treturn resolved\n\t\t}\n\t\treturn undefined\n\t}\n\tif (!isDistributionRecord(entry)) return undefined\n\tfor (const [condition, nested] of Object.entries(entry)) {\n\t\tif (condition !== 'default' && !conditions.includes(condition)) continue\n\t\tconst resolved = resolveDistributionPackageTarget(nested, conditions)\n\t\tif (resolved !== undefined) return resolved\n\t}\n\treturn undefined\n}\n\n// A flat entry, a condition-nested entry, and a fallback list all resolve through\n// one walker. An entry may declare `types` beside `default` at its top level\n// rather than inside `import`, so a fixed `entry.import.types` lookup is not\n// equivalent to condition resolution.\n/**\n * Resolves the path selected by an exports-map entry.\n *\n * @param entry - The exports-map entry.\n * @param conditions - The active resolution conditions.\n * @returns The selected path, or undefined when no branch resolves.\n */\nexport function resolveDistributionTarget(\n\tentry: unknown,\n\tconditions: readonly string[],\n): string | undefined {\n\treturn resolveDistributionPackageTarget(entry, conditions)?.target\n}\n\n// Whether a path is a physical file. TypeScript's file-existence check refuses a\n// directory at the same spelling and continues to the outer package scope.\n/**\n * Checks whether a path names a physical file.\n *\n * @param path - The filesystem path.\n * @returns True if the path names a file; false otherwise.\n */\nexport function matchesDistributionFile(path: string): boolean {\n\ttry {\n\t\treturn statSync(path).isFile()\n\t} catch {\n\t\treturn false\n\t}\n}\n\n// TypeScript resolves a declaration target by accepting an existing declaration\n// directly or by substituting beside a JavaScript target. A missing target leaves\n// the containing condition or fallback list unresolved, so the walk continues.\n/**\n * Resolves an existing declaration beside a package target.\n *\n * @param target - The package-relative target.\n * @param installed - The installed package root.\n * @returns The declaration target, or undefined when no declaration exists.\n */\nexport function targetToDistributionDeclaration(\n\ttarget: string,\n\tinstalled: string,\n): string | undefined {\n\tif (!matchesDistributionPackageTarget(target)) return undefined\n\tconst declaration = target.endsWith('.cjs')\n\t\t? `${target.slice(0, -4)}.d.cts`\n\t\t: target.endsWith('.mjs')\n\t\t\t? `${target.slice(0, -4)}.d.mts`\n\t\t\t: target.endsWith('.js')\n\t\t\t\t? `${target.slice(0, -3)}.d.ts`\n\t\t\t\t: target\n\tif (declaration === target && !matchesDistributionDeclaration(target)) return undefined\n\treturn matchesDistributionFile(join(installed, declaration)) ? declaration : undefined\n}\n\n// The declaration TypeScript resolves through one importing format's conditions.\n// Condition objects keep manifest order, and arrays keep fallback order.\n/**\n * Resolves an existing declaration through consumer conditions.\n *\n * @param entry - The exports-map entry.\n * @param conditions - The active declaration conditions.\n * @param installed - The installed package root.\n * @returns The declaration target, or undefined when no branch resolves.\n */\nexport function resolveDistributionDeclaration(\n\tentry: unknown,\n\tconditions: readonly string[],\n\tinstalled: string,\n): string | undefined {\n\tif (typeof entry === 'string') return targetToDistributionDeclaration(entry, installed)\n\tif (isDistributionList(entry)) {\n\t\tfor (const member of entry) {\n\t\t\tconst resolved = resolveDistributionDeclaration(member, conditions, installed)\n\t\t\tif (resolved !== undefined) return resolved\n\t\t}\n\t\treturn undefined\n\t}\n\tif (!isDistributionRecord(entry)) return undefined\n\tfor (const [condition, nested] of Object.entries(entry)) {\n\t\tif (condition !== 'default' && !conditions.includes(condition)) continue\n\t\tconst resolved = resolveDistributionDeclaration(nested, conditions, installed)\n\t\tif (resolved !== undefined) return resolved\n\t}\n\treturn undefined\n}\n\n// The nearest package scope that decides a `.d.ts` declaration's module format. A\n// physical nested manifest starts a scope even when it omits `type` or cannot be\n// parsed. A directory at that spelling is not a manifest, so the walk continues.\n/**\n * Reads the nearest package scope for a target inside an installed package.\n *\n * @param installed - The installed package root.\n * @param target - The package-relative target.\n * @returns The manifest type, or undefined when the nearest scope omits it or cannot be read.\n */\nexport function readDistributionPackageType(installed: string, target: string): unknown {\n\t// One `dirname` per path segment reaches the root from any path. The walk ends at the\n\t// installed package, so no scope above it is consulted.\n\tconst start = dirname(join(installed, target))\n\tconst chain = start\n\t\t.split(/[\\\\/]/u)\n\t\t.reduce<string[]>((climbed) => [...climbed, dirname(climbed.at(-1) ?? start)], [start])\n\tconst end = chain.indexOf(installed)\n\tconst scope = chain\n\t\t.slice(0, end === -1 ? chain.length : end + 1)\n\t\t.find((directory) => matchesDistributionFile(join(directory, 'package.json')))\n\tif (scope === undefined) return undefined\n\ttry {\n\t\tconst manifest = readDistributionJSON(join(scope, 'package.json'))\n\t\treturn isDistributionRecord(manifest) ? manifest.type : undefined\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/**\n * Checks whether an entry publishes a distinct or conventional browser target.\n *\n * @param entry - The exports-map entry.\n * @returns True if the entry requires a browser drive; false otherwise.\n */\nexport function resolvesDistributionBrowser(entry: unknown): boolean {\n\tconst module = resolveDistributionTarget(entry, DISTRIBUTION_RUNTIME_CONDITIONS.browser)\n\tif (module !== undefined && module.startsWith(DISTRIBUTION_BROWSER_OUTPUT)) return true\n\tif (module === undefined) return false\n\tconst imported = resolveDistributionTarget(entry, DISTRIBUTION_RUNTIME_CONDITIONS.module)\n\tconst required = resolveDistributionTarget(entry, DISTRIBUTION_RUNTIME_CONDITIONS.commonjs)\n\treturn module !== imported && module !== required\n}\n\n// Whether the target selected by Node's CommonJS conditions is a module require can\n// load. A JavaScript target takes its own nearest package scope. Native addons and\n// extensionless targets have their own CommonJS handlers.\n/**\n * Checks whether Node require can load an entry selected by its conditions.\n *\n * @param entry - The exports-map entry.\n * @param installed - The installed package root.\n * @returns True if the target has a CommonJS-compatible format; false otherwise.\n */\nexport function resolvesDistributionCommonJS(entry: unknown, installed: string): boolean {\n\tconst target = resolveDistributionTarget(entry, DISTRIBUTION_RUNTIME_CONDITIONS.commonjs)\n\tif (target === undefined) return false\n\tconst name = target.slice(target.lastIndexOf('/') + 1)\n\tif (name.endsWith('.cjs')) return true\n\tif (name.endsWith('.mjs')) return false\n\tif (name.endsWith('.node')) return true\n\tif (!name.includes('.')) return true\n\treturn name.endsWith('.js') && readDistributionPackageType(installed, target) !== 'module'\n}\n\n// Whether the declaration selected by a typed CommonJS consumer admits that entry.\n// A `.d.cts` declaration admits and a `.d.mts` declaration refuses. A `.d.ts`\n// declaration takes its own nearest package scope.\n/**\n * Checks whether an entry resolves a CommonJS-compatible declaration.\n *\n * @param entry - The exports-map entry.\n * @param installed - The installed package root.\n * @returns True if the selected declaration admits CommonJS consumption; false otherwise.\n */\nexport function declaresDistributionCommonJS(entry: unknown, installed: string): boolean {\n\tconst declaration = resolveDistributionDeclaration(\n\t\tentry,\n\t\tDISTRIBUTION_DECLARATION_CONDITIONS.commonjs,\n\t\tinstalled,\n\t)\n\tif (declaration === undefined) return false\n\tif (declaration.endsWith('.d.cts')) return true\n\tif (declaration.endsWith('.d.mts')) return false\n\treturn (\n\t\tdeclaration.endsWith('.d.ts') &&\n\t\treadDistributionPackageType(installed, declaration) !== 'module'\n\t)\n}\n\n// Every target an entry names under any condition. A fallback list omits members\n// Node rejects during package-target validation, because no reader can take them.\n/**\n * Collects the targets an entry publishes under every condition.\n *\n * @param entry - The exports-map entry.\n * @returns The targets, excluding invalid members of fallback arrays.\n */\nexport function collectDistributionTargets(entry: unknown): readonly string[] {\n\tif (typeof entry === 'string') return [entry]\n\tif (isDistributionList(entry))\n\t\treturn entry.flatMap(collectDistributionTargets).filter(matchesDistributionPackageTarget)\n\tif (!isDistributionRecord(entry)) return []\n\treturn Object.values(entry).flatMap((nested) => collectDistributionTargets(nested))\n}\n\n// Whether a target is a file a runtime loads for its names, which is what a\n// declaration is owed for. The extension on the target's own file name decides it,\n// and a name carrying no extension is code: `require` reads such a file through its\n// JavaScript handler, so an extensionless target loads and publishes names. Node\n// loads `.node` through its native-addon handler. Every other extension is an asset\n// a consumer reads rather than imports — a stylesheet, a WebAssembly binary, the\n// `\"./package.json\"` manifest pointer, and a declaration alike.\n// The cost is an extensionless file published for a reader, such as a `LICENSE`:\n// that target reports undeclared until it is given an extension or a declaration.\n/**\n * Checks whether a target names a runtime module rather than an asset.\n *\n * @param target - The package-relative target.\n * @returns True if the target has a module extension or no extension; false otherwise.\n */\nexport function matchesDistributionModule(target: string): boolean {\n\tconst name = target.slice(target.lastIndexOf('/') + 1)\n\tconst dot = name.lastIndexOf('.')\n\tif (name.endsWith(DISTRIBUTION_ADDON_EXTENSION)) return true\n\treturn dot === -1 || DISTRIBUTION_MODULE_EXTENSIONS.includes(name.slice(dot))\n}\n\n// Whether a resolved target is a declaration rather than the JavaScript a\n// `default` branch answers with when the entry declares no `types` condition.\n/**\n * Checks whether a target names a TypeScript declaration.\n *\n * @param target - The package-relative target.\n * @returns True if the target has a declaration extension; false otherwise.\n */\nexport function matchesDistributionDeclaration(target: string): boolean {\n\treturn DISTRIBUTION_DECLARATION_EXTENSIONS.some((extension) => target.endsWith(extension))\n}\n\n// The declarations the Node module, Node CommonJS, and browser drives compare\n// against. Each field uses the conditions of the TypeScript consumer paired with\n// that runtime. A JavaScript target resolves through TypeScript's adjacent\n// declaration substitution rather than standing in for the declaration itself.\n/**\n * Reads the declarations paired with Node and browser consumers.\n *\n * @param entry - The exports-map entry.\n * @param installed - The installed package root.\n * @returns The declaration selected by each consumer format.\n */\nexport function readDistributionDeclaration(\n\tentry: unknown,\n\tinstalled: string,\n): {\n\treadonly module: string | undefined\n\treadonly commonjs: string | undefined\n\treadonly browser: string | undefined\n} {\n\treturn {\n\t\tmodule: resolveDistributionDeclaration(\n\t\t\tentry,\n\t\t\tDISTRIBUTION_DECLARATION_CONDITIONS.module,\n\t\t\tinstalled,\n\t\t),\n\t\tcommonjs: resolveDistributionDeclaration(\n\t\t\tentry,\n\t\t\tDISTRIBUTION_DECLARATION_CONDITIONS.commonjs,\n\t\t\tinstalled,\n\t\t),\n\t\tbrowser: resolveDistributionDeclaration(\n\t\t\tentry,\n\t\t\tDISTRIBUTION_DECLARATION_CONDITIONS.browser,\n\t\t\tinstalled,\n\t\t),\n\t}\n}\n\n// The entries one compile driver can resolve under its own conditions.\n/**\n * Filters entries to those a consumer can resolve.\n *\n * @param entries - The installed entries.\n * @param conditions - The active consumer conditions.\n * @returns The matching entries in their original order.\n */\nexport function filterDistributionEntries(\n\tentries: readonly DistributionEntry[],\n\tconditions: readonly string[],\n): readonly DistributionEntry[] {\n\treturn entries.filter(\n\t\t(entry) =>\n\t\t\tresolveDistributionTarget(entry.mapping, conditions) !== undefined &&\n\t\t\t(!conditions.includes('require') || entry.loadable),\n\t)\n}\n\n// The compile drivers whose conditions reach one entry under one importing format.\n// A driver that resolves no target for that entry compiles nothing, so a consumer\n// written under it would report a resolution failure this package never made.\n/**\n * Filters compiler resolutions to those that can read an entry.\n *\n * @param entry - The installed entry.\n * @param format - The consumer module format.\n * @returns The matching compiler resolutions.\n */\nexport function filterDistributionResolutions(\n\tentry: DistributionEntry,\n\tformat: DistributionFormat,\n): readonly DistributionResolution[] {\n\treturn DISTRIBUTION_RESOLUTIONS.filter(\n\t\t(driver) => filterDistributionEntries([entry], driver.conditions[format]).length > 0,\n\t)\n}\n\n// Requirable entries that declare CommonJS support but a typed CommonJS consumer\n// cannot compile against. A default branch resolving under the require condition\n// set makes no CommonJS claim.\n/**\n * Filters entries whose require target lacks a compatible declaration.\n *\n * @param entries - The installed entries.\n * @param installed - The installed package root.\n * @returns The entries a CommonJS consumer cannot typecheck.\n */\nexport function filterDistributionUntypable(\n\tentries: readonly DistributionEntry[],\n\tinstalled: string,\n): readonly DistributionEntry[] {\n\treturn entries.filter(\n\t\t(entry) =>\n\t\t\tentry.requirable &&\n\t\t\tisDistributionRecord(entry.mapping) &&\n\t\t\tObject.hasOwn(entry.mapping, 'require') &&\n\t\t\t!declaresDistributionCommonJS(entry.mapping, installed),\n\t)\n}\n\n// One surface comparison, written as the consumer module that proves it: the\n// installed entry that consumer imports, the file extension fixing its importing\n// format, the names a real runtime published off it, and the driver whose scratch\n// project compiles it.\n/** Describes the runtime names and declaration resolution compared for one entry. */\nexport interface DistributionSurface {\n\treadonly entry: DistributionEntry\n\treadonly extension: string\n\treadonly published: readonly string[]\n\treadonly driver: DistributionResolution\n}\n\n// A scratch project over named consumer modules, written beside them so their own\n// resolution reaches the installed package. Nothing is emitted and no ambient types\n// are pulled in, so what the check reads is the installed declarations alone.\n/**\n * Writes a compiler project for a consumer probe.\n *\n * @param stage - The installed consumer.\n * @param name - The project filename suffix.\n * @param driver - The compiler resolution.\n * @param files - The consumer source files.\n * @returns The absolute project path.\n */\nexport function writeDistributionProject(\n\tstage: DistributionStage,\n\tname: string,\n\tdriver: DistributionResolution,\n\tfiles: readonly string[],\n): string {\n\tconst path = join(stage.consumer, `tsconfig.${name}.json`)\n\tconst project = {\n\t\tcompilerOptions: {\n\t\t\tmodule: driver.module,\n\t\t\tmoduleResolution: driver.resolution,\n\t\t\tnoEmit: true,\n\t\t\tskipLibCheck: true,\n\t\t\tstrict: true,\n\t\t\ttarget: 'esnext',\n\t\t\ttypes: [],\n\t\t},\n\t\tfiles: [...files],\n\t}\n\twriteDistributionFile(path, `${JSON.stringify(project, undefined, '\\t')}\\n`)\n\treturn path\n}\n\n// The diagnostics the compiler this workspace installs reports for one scratch\n// project. The compiler runs as a command, so nothing here reaches an API that\n// moves between its majors, and the located lines it prints are the verdict rather\n// than the exit code, which moves between them. A line carrying no location, a line\n// naming the scratch project rather than a consumer module, and anything at all on\n// the error stream are faults of this proof rather than of the package under proof,\n// so each is raised where it happens instead of counted against the package.\n/**\n * Checks a consumer project with the installed TypeScript compiler.\n *\n * @param stage - The installed consumer.\n * @param project - The compiler project path.\n * @returns The located compiler diagnostics. Throws on a tool or project failure.\n */\nexport function checkDistributionProject(\n\tstage: DistributionStage,\n\tproject: string,\n): readonly string[] {\n\tconst result = runDistributionNode(\n\t\t[DISTRIBUTION_COMPILER, '--noEmit', '--pretty', 'false', '-p', project],\n\t\tstage.consumer,\n\t)\n\tconst refused = `${result.stderr ?? ''}`.trim()\n\tif (refused.length > 0) {\n\t\tthrow new Error(`The consumer compiler wrote ${refused} to its error stream`)\n\t}\n\tconst lines = `${result.stdout ?? ''}`.split(/\\r\\n|\\n/u).filter((line) => line.trim().length > 0)\n\t// An elaborated diagnostic prints its detail on indented lines under its own\n\t// first line, so each of those joins the diagnostic it elaborates. The first line\n\t// has no diagnostic above it to join, so it opens one whatever its indentation.\n\tconst heads = lines.flatMap((line, index) => (index === 0 || !/^\\s/u.test(line) ? [index] : []))\n\tconst reported = heads.map((head, position) => {\n\t\tconst line = lines[head] ?? ''\n\t\tconst located = DISTRIBUTION_DIAGNOSTIC_PATTERN.exec(line)?.[1]\n\t\tif (located === undefined) {\n\t\t\tthrow new Error(`The consumer compiler reported ${line}, which names no location`)\n\t\t}\n\t\tif (resolve(stage.consumer, located) === project) {\n\t\t\tthrow new Error(`The scratch project is itself at fault: ${line}`)\n\t\t}\n\t\treturn [\n\t\t\tline,\n\t\t\t...lines.slice(head + 1, heads[position + 1] ?? lines.length).map((detail) => detail.trim()),\n\t\t].join(' ')\n\t})\n\tif (reported.length === 0 && result.status !== 0) {\n\t\tthrow new Error(`The consumer compiler refused the project: ${readDistributionOutput(result)}`)\n\t}\n\treturn reported\n}\n\n// One installed entry's published names checked against its own declarations by\n// the compiler this workspace installs, in the direction each divergence surfaces\n// under. The runtime's key list is written into the consumer as a literal, so the\n// published side comes from a real process and the declared side from the\n// declarations that process's package ships, and the two can disagree. A name the\n// declarations carry and the runtime does not lands on `declared`. A name the\n// runtime carries and the declarations do not, and a name the declarations publish\n// as a type alone, land on `surfaced`: a variable widens into the type\n// `declared` annotates, and only `surfaced` reads the literal's own keys back.\n// Each names the member it is about, so the failure says which export moved.\n/**\n * Checks runtime export names against their installed declarations.\n *\n * @param stage - The installed consumer.\n * @param surface - The publication and declaration pair.\n * @returns The diagnostics labelled by compiler resolution.\n */\nexport function checkDistributionSurface(\n\tstage: DistributionStage,\n\tsurface: DistributionSurface,\n): readonly string[] {\n\tconst slug = surface.entry.subpath.replaceAll(/[^\\w]+/gu, '-')\n\tconst name = `surface.${surface.driver.label}${slug}.${surface.extension}`\n\tconst module = `${name}`\n\tconst keys = surface.published.map((key) => `${JSON.stringify(key)}: true`).join(', ')\n\twriteDistributionFile(\n\t\tjoin(stage.consumer, module),\n\t\t`import * as entry from ${JSON.stringify(surface.entry.specifier)}\nexport const published = {${keys.length === 0 ? '' : ` ${keys} `}} as const\nexport const declared: Record<keyof typeof entry, true> = published\nexport const surfaced: Record<keyof typeof published, true> = declared\n`,\n\t)\n\tconst project = writeDistributionProject(stage, name, surface.driver, [`./${module}`])\n\treturn checkDistributionProject(stage, project).map((line) => `${surface.driver.label}: ${line}`)\n}\n\n// One consumer module importing every installed entry, written where its own\n// resolution finds the installed package.\n/**\n * Writes a consumer importing the requested public specifiers.\n *\n * @param stage - The installed consumer.\n * @param path - The consumer-relative source path.\n * @param specifiers - The public imports to resolve.\n */\nexport function writeDistributionConsumerProbe(\n\tstage: DistributionStage,\n\tpath: string,\n\tspecifiers: readonly string[],\n): void {\n\tconst modules = specifiers.map((specifier, index) => ({\n\t\tbinding: `entry${String(index)}`,\n\t\tspecifier,\n\t}))\n\tconst bindings = modules.map(\n\t\t({ binding, specifier }) => `import * as ${binding} from ${JSON.stringify(specifier)}`,\n\t)\n\tconst names = modules.map(({ binding }) => binding)\n\tconst source = `${bindings.join('\\n')}\\nexport const surface = [${names.join(', ')}]\\n`\n\twriteDistributionFile(join(stage.consumer, path), source)\n}\n\n// The runtime key set a real process reads off one installed entry under one\n// condition. The driver is a file rather than an `--eval` string, so the specifier\n// travels as an argument and nothing needs escaping.\n/**\n * Reads the names a real Node process loads from an installed entry.\n *\n * @param stage - The installed consumer.\n * @param specifier - The public package specifier.\n * @param driver - The consumer driver filename.\n * @returns The exported names. Throws when loading or decoding fails.\n */\nexport function driveDistributionRuntime(\n\tstage: DistributionStage,\n\tspecifier: string,\n\tdriver: string,\n): readonly string[] {\n\tconst result = runDistributionNode([join(stage.consumer, driver), specifier], stage.consumer)\n\tif (result.status !== 0) {\n\t\tthrow new Error(\n\t\t\t`Loading ${specifier} from the consumer failed: ${readDistributionOutput(result)}`,\n\t\t)\n\t}\n\tconst published: unknown = JSON.parse(result.stdout)\n\tif (!isDistributionNames(published))\n\t\tthrow new Error(`The driver printed no name list for ${specifier}`)\n\treturn published\n}\n{{helpers}}\n// Pack this workspace, install the archive into an isolated consumer, and read the\n// published surface back off the installed tree. Every later claim reads this\n// result, so a failure here is raised where it happens rather than once per entry.\n/**\n * Packs the workspace and installs its archive into an isolated consumer.\n *\n * @param scratch - The owned scratch root.\n * @returns The installed consumer and classified exports.\n * @throws Thrown when packing or installation fails.\n */\nexport function buildDistributionStage(scratch: string): DistributionStage {\n\tconst packed = join(scratch, 'packed')\n\tconst consumer = join(scratch, 'consumer')\n\tmkdirSync(packed, { recursive: true })\n\tconst pack = runDistributionNpm(\n\t\t['pack', '--ignore-scripts', '--pack-destination', packed],\n\t\tDISTRIBUTION_ROOT,\n\t\tscratch,\n\t)\n\tif (pack.status !== 0)\n\t\tthrow new Error(`npm pack refused this workspace: ${readDistributionOutput(pack)}`)\n\tconst archives = readdirSync(packed).filter((name) => name.endsWith('.tgz'))\n\tconst archive = archives[0]\n\tif (archives.length !== 1 || archive === undefined) {\n\t\tthrow new Error(`npm pack wrote no single archive: ${archives.join(', ')}`)\n\t}\n\tconst peers = readDistributionPeers(join(DISTRIBUTION_ROOT, 'package.json'))\n\twriteDistributionFile(join(consumer, 'package.json'), createDistributionConsumerManifest(peers))\n\twriteDistributionFile(join(consumer, DISTRIBUTION_ESM_DRIVER), DISTRIBUTION_ESM_DRIVER_SOURCE)\n\twriteDistributionFile(join(consumer, DISTRIBUTION_CJS_DRIVER), DISTRIBUTION_CJS_DRIVER_SOURCE)\n\tconst install = runDistributionNpm(\n\t\t['install', '--ignore-scripts', '--no-audit', '--no-fund', join(packed, archive)],\n\t\tconsumer,\n\t\tscratch,\n\t)\n\tif (install.status !== 0) {\n\t\tthrow new Error(`Installing the packed archive failed: ${readDistributionOutput(install)}`)\n\t}\n\tconst name = readDistributionManifestName(join(DISTRIBUTION_ROOT, 'package.json'))\n\tconst installed = join(consumer, 'node_modules', ...name.split('/'))\n\tconst manifest = readDistributionJSON(join(installed, 'package.json'))\n\tif (!isDistributionRecord(manifest) || !isDistributionRecord(manifest.exports)) {\n\t\tthrow new Error('The installed manifest publishes no exports map')\n\t}\n\treturn { consumer, installed, archives, ...classifyDistributionStage(manifest, installed, name) }\n}\n\n// One file's run: the scratch directory and the staged consumer, which is absent when the\n// registry could not be reached.\n/** Binds an owned scratch directory to its optional installed consumer. */\nexport interface DistributionRun {\n\treadonly scratch: string\n\treadonly stage: DistributionStage | undefined\n}\n\n// The run the start hook binds once for this file and the stop hook releases.\n/** Owns the staged consumer shared by one distribution proof. */\nexport class DistributionSuite implements DistributionSuiteInterface {\n\t#run: DistributionRun | undefined\n\n\tget scratch(): string {\n\t\tif (this.#run === undefined) {\n\t\t\tthrow new Error('The distribution setup has not allocated its scratch directory')\n\t\t}\n\t\treturn this.#run.scratch\n\t}\n\n\tread(context: TestContext): DistributionStage {\n\t\tconst stage = this.#run?.stage\n\t\tif (stage === undefined) {\n\t\t\treturn context.skip('`npm ping` did not answer, so nothing was packed or installed')\n\t\t}\n\t\treturn stage\n\t}\n\n\tstart(): void {\n\t\tif (this.#run !== undefined) {\n\t\t\tthrow new Error('The distribution setup has already allocated its scratch directory')\n\t\t}\n\t\tconst scratch = mkdtempSync(join(tmpdir(), 'distribution-'))\n\t\tthis.#run = { scratch, stage: openDistributionStage(scratch) }\n\t}\n\n\tdestroy(): void {\n\t\tif (this.#run !== undefined) {\n\t\t\trmSync(this.#run.scratch, { force: true, recursive: true, maxRetries: 3, retryDelay: 100 })\n\t\t}\n\t\tthis.#run = undefined\n\t}\n}\n\n// Installing the packed archive resolves its own runtime dependencies, so an\n// unreachable registry leaves nothing to measure. Under release that is the gate\n// failing; anywhere else the suite skips and names the mechanism it wanted.\n/**\n * Opens an installed consumer after checking registry readiness.\n *\n * @param scratch - The owned scratch root.\n * @returns The installed consumer, or undefined when an ordinary run cannot reach the registry.\n * @throws Thrown in release mode or when staging fails, after removing scratch.\n */\nexport function openDistributionStage(scratch: string): DistributionStage | undefined {\n\ttry {\n\t\tmkdirSync(join(scratch, 'cache'), { recursive: true })\n\t\tif (runDistributionNpm(DISTRIBUTION_PING, DISTRIBUTION_ROOT, scratch).status !== 0) {\n\t\t\tif (!DISTRIBUTION_RELEASE) return undefined\n\t\t\tthrow new Error(\n\t\t\t\t'The release gate requires a reachable npm registry, and npm ping did not answer',\n\t\t\t)\n\t\t}\n\t\treturn buildDistributionStage(scratch)\n\t} catch (error) {\n\t\trmSync(scratch, {\n\t\t\tforce: true,\n\t\t\trecursive: true,\n\t\t\tmaxRetries: 3,\n\t\t\tretryDelay: 100,\n\t\t})\n\t\tthrow error\n\t}\n}\n\n/**\n * Partitions an installed exports map into driven, undeclared, and excluded subpaths.\n *\n * @param manifest - The installed package manifest.\n * @param installed - The installed package root.\n * @param name - The published package name.\n * @returns The classified entries and complete target population.\n * @throws Thrown when the exports map is absent.\n */\nexport function classifyDistributionStage(\n\tmanifest: Readonly<Record<string, unknown>>,\n\tinstalled: string,\n\tname: string,\n): DistributionClassification {\n\tif (!isDistributionRecord(manifest.exports))\n\t\tthrow new Error('The installed manifest publishes no exports map')\n\tconst readings = Object.entries(manifest.exports).map(([subpath, mapping]) => {\n\t\tconst files = collectDistributionTargets(mapping)\n\t\tconst declaration = readDistributionDeclaration(mapping, installed)\n\t\t// A subpath resolving no declaration is partitioned rather than dropped. It is a\n\t\t// defect when a runtime loads one of its targets for names, because a consumer\n\t\t// importing it compiles against nothing under `node16`. It is an excluded\n\t\t// publication otherwise: the `\"./package.json\"` manifest pointer and a stylesheet\n\t\t// are published for a reader rather than an importer.\n\t\tif (\n\t\t\tdeclaration.module === undefined &&\n\t\t\tdeclaration.commonjs === undefined &&\n\t\t\tdeclaration.browser === undefined\n\t\t) {\n\t\t\treturn { subpath, files, entry: undefined }\n\t\t}\n\t\tconst importTarget = resolveDistributionTarget(mapping, DISTRIBUTION_RUNTIME_CONDITIONS.module)\n\t\tconst requireTarget = resolveDistributionTarget(\n\t\t\tmapping,\n\t\t\tDISTRIBUTION_RUNTIME_CONDITIONS.commonjs,\n\t\t)\n\t\tconst browserTarget = resolveDistributionTarget(\n\t\t\tmapping,\n\t\t\tDISTRIBUTION_RUNTIME_CONDITIONS.browser,\n\t\t)\n\t\tconst browsable = resolvesDistributionBrowser(mapping)\n\t\tconst shadowed = browsable && requireTarget === browserTarget\n\t\tconst requirable = requireTarget !== undefined && !shadowed\n\t\tconst loadable = requirable && resolvesDistributionCommonJS(mapping, installed)\n\t\tconst entry: DistributionEntry = {\n\t\t\tsubpath,\n\t\t\tspecifier: subpath === '.' ? name : `${name}${subpath.slice(1)}`,\n\t\t\tmapping,\n\t\t\tdeclaration: {\n\t\t\t\timportable: declaration.module !== undefined,\n\t\t\t\trequirable: declaration.commonjs !== undefined,\n\t\t\t\tbrowsable: declaration.browser !== undefined,\n\t\t\t},\n\t\t\tbrowsable,\n\t\t\timportable: importTarget !== undefined && !(browsable && importTarget === browserTarget),\n\t\t\trequirable,\n\t\t\tloadable,\n\t\t}\n\t\treturn { subpath, files, entry }\n\t})\n\tconst entries = readings.flatMap(({ entry }) => (entry === undefined ? [] : [entry]))\n\tconst targets = readings.flatMap(({ files }) => files)\n\tconst subpaths = readings.map(({ subpath }) => subpath)\n\tconst undeclared = readings\n\t\t.filter(({ entry, files }) => entry === undefined && files.some(matchesDistributionModule))\n\t\t.map(({ subpath }) => subpath)\n\tconst excluded = readings\n\t\t.filter(({ entry, files }) => entry === undefined && !files.some(matchesDistributionModule))\n\t\t.map(({ subpath }) => subpath)\n\treturn { entries, subpaths, undeclared, excluded, targets }\n}\n\n/**\n * Creates the lifecycle boundary used by generated distribution proofs.\n * @returns The suite interface backed by an owned run.\n */\nexport function createDistributionSuite(): DistributionSuiteInterface {\n\treturn new DistributionSuite()\n}\n\n/**\n * Collects physical files beneath an installed output directory.\n * @param directory - The output directory to walk.\n * @returns The installed files, or an empty list when the directory is absent.\n */\nexport function collectDistributionFiles(directory: string): readonly string[] {\n\tif (!existsSync(directory)) return []\n\treturn readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {\n\t\tconst path = join(directory, entry.name)\n\t\treturn entry.isDirectory() ? collectDistributionFiles(path) : entry.isFile() ? [path] : []\n\t})\n}\n\n/**\n * Reads the source environment owning an installed output path.\n * @param installed - The installed package root.\n * @param path - The output file.\n * @returns The source environment, or undefined outside a JavaScript face.\n */\nexport function readDistributionFace(installed: string, path: string): string | undefined {\n\tconst [output, axis, face] = relativePath(installed, path).split(sep)\n\treturn output === 'dist'\n\t\t? axis === 'src'\n\t\t\t? face\n\t\t\t: axis === 'bin'\n\t\t\t\t? 'bin'\n\t\t\t\t: undefined\n\t\t: undefined\n}\n\n/**\n * Scans installed JavaScript maps for sources copied from another environment.\n * @param installed - The installed package root.\n * @returns The copied sources and unreadable maps.\n * @throws Thrown when a code-bearing output has no readable map of its own.\n */\nexport function scanDistributionSourceMaps(installed: string): readonly string[] {\n\tconst files = collectDistributionFiles(join(installed, 'dist')).filter(\n\t\t(path) => readDistributionFace(installed, path) !== undefined,\n\t)\n\tconst outputs = files\n\t\t.filter((path) => /\\.(?:js|cjs|mjs)$/u.test(path))\n\t\t.map((path) => {\n\t\t\tconst parsed = parseSync(path, readFileSync(path, 'utf8'))\n\t\t\tconst code = parsed.program.body.some(\n\t\t\t\t(statement) =>\n\t\t\t\t\tstatement.type !== 'EmptyStatement' &&\n\t\t\t\t\t!(\n\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' &&\n\t\t\t\t\t\tstatement.declaration === null &&\n\t\t\t\t\t\tstatement.specifiers.length === 0 &&\n\t\t\t\t\t\tstatement.source === null\n\t\t\t\t\t),\n\t\t\t)\n\t\t\tconst reference = parsed.comments\n\t\t\t\t.flatMap((comment) => {\n\t\t\t\t\tconst match = /^[@#]\\s*sourceMappingURL=(\\S+)\\s*$/u.exec(comment.value)\n\t\t\t\t\treturn match?.[1] === undefined ? [] : [match[1]]\n\t\t\t\t})\n\t\t\t\t.at(-1)\n\t\t\ttry {\n\t\t\t\tconst inline = reference?.startsWith('data:') === true\n\t\t\t\tconst target = inline\n\t\t\t\t\t? path\n\t\t\t\t\t: reference === undefined\n\t\t\t\t\t\t? `${path}.map`\n\t\t\t\t\t\t: fileURLToPath(new URL(reference.replaceAll('\\\\', '/'), pathToFileURL(path)))\n\t\t\t\treturn {\n\t\t\t\t\tpath: target,\n\t\t\t\t\tface: readDistributionFace(installed, path),\n\t\t\t\t\tcode,\n\t\t\t\t\treference: inline ? reference : undefined,\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Unreadable source maps for ${path}`)\n\t\t\t}\n\t\t})\n\tconst maps = [\n\t\t...outputs.filter(\n\t\t\t({ path, code, reference }) => code || reference !== undefined || existsSync(path),\n\t\t),\n\t\t...files\n\t\t\t.filter(\n\t\t\t\t(path) =>\n\t\t\t\t\t/\\.(?:js|cjs|mjs)\\.map$/u.test(path) && !outputs.some((output) => output.path === path),\n\t\t\t)\n\t\t\t.map((path) => ({\n\t\t\t\tpath,\n\t\t\t\tface: readDistributionFace(installed, path),\n\t\t\t\tcode: false,\n\t\t\t\treference: undefined,\n\t\t\t})),\n\t]\n\tif (maps.length === 0)\n\t\tconsole.info('No built JavaScript face holds code, so no source map is required')\n\treturn maps.flatMap(({ path, face, code, reference }) => {\n\t\tconst label = relativePath(installed, path).split(sep).join('/')\n\t\ttry {\n\t\t\tconst payload =\n\t\t\t\treference === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: /^data:application\\/json(?:;charset=[^;,]+)?(;base64)?,(.*)$/iu.exec(reference)\n\t\t\tconst map: unknown =\n\t\t\t\treference === undefined\n\t\t\t\t\t? readDistributionJSON(path)\n\t\t\t\t\t: payload?.[2] === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: JSON.parse(\n\t\t\t\t\t\t\t\tpayload[1] === undefined\n\t\t\t\t\t\t\t\t\t? decodeURIComponent(payload[2])\n\t\t\t\t\t\t\t\t\t: Buffer.from(payload[2], 'base64').toString('utf8'),\n\t\t\t\t\t\t\t)\n\t\t\tif (\n\t\t\t\t!isDistributionRecord(map) ||\n\t\t\t\t!isDistributionNames(map.sources) ||\n\t\t\t\t(map.sourceRoot !== undefined && typeof map.sourceRoot !== 'string')\n\t\t\t) {\n\t\t\t\tthrow new Error('Unreadable source map')\n\t\t\t}\n\t\t\tconst root = typeof map.sourceRoot === 'string' ? map.sourceRoot : ''\n\t\t\tconst directory = root.startsWith('file:')\n\t\t\t\t? fileURLToPath(new URL(root))\n\t\t\t\t: resolve(dirname(path), root.replaceAll('\\\\', '/'))\n\t\t\tconst sources = map.sources.map((source) =>\n\t\t\t\trelativePath(\n\t\t\t\t\tresolve(installed),\n\t\t\t\t\tsource.startsWith('file:')\n\t\t\t\t\t\t? fileURLToPath(new URL(source))\n\t\t\t\t\t\t: resolve(directory, source.replaceAll('\\\\', '/')),\n\t\t\t\t)\n\t\t\t\t\t.split(sep)\n\t\t\t\t\t.join('/'),\n\t\t\t)\n\t\t\tconst copied = sources.filter(\n\t\t\t\t(source) => source.startsWith('src/') && !source.startsWith(`src/${face}/`),\n\t\t\t)\n\t\t\treturn [\n\t\t\t\t...copied.map((source) => `${label}: ${source}`),\n\t\t\t\t...(sources.some((source) => source.startsWith(`src/${face}/`))\n\t\t\t\t\t? []\n\t\t\t\t\t: [`${label}: unreadable source map (no src/${face}/ source)`]),\n\t\t\t]\n\t\t} catch {\n\t\t\tif (code) throw new Error(`Unreadable source maps for ${path}`)\n\t\t\treturn [`${label}: unreadable source map`]\n\t\t}\n\t})\n}\n\n/**\n * Reads top-level names declared by a roll-up, including unexported declarations.\n * @param path - The installed declaration file.\n * @returns The declared names. Refuses syntax errors and unreadable binding patterns.\n */\nexport function readDistributionNames(path: string): readonly string[] {\n\tconst source = parseSync(path, readFileSync(path, 'utf8'))\n\tif (source.errors.length > 0) throw new Error(`Unreadable declarations at ${path}`)\n\treturn source.program.body.flatMap((statement) => {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' || statement.type === 'ExportDefaultDeclaration'\n\t\t\t\t? statement.declaration\n\t\t\t\t: statement\n\t\tif (declaration === null) return []\n\t\tif (declaration.type === 'VariableDeclaration') {\n\t\t\treturn declaration.declarations.map((binding) => {\n\t\t\t\tif (binding.id.type !== 'Identifier')\n\t\t\t\t\tthrow new Error(`Unreadable declaration binding at ${path}`)\n\t\t\t\treturn binding.id.name\n\t\t\t})\n\t\t}\n\t\tif (\n\t\t\tdeclaration.type === 'ClassDeclaration' ||\n\t\t\tdeclaration.type === 'FunctionDeclaration' ||\n\t\t\tdeclaration.type === 'TSDeclareFunction' ||\n\t\t\tdeclaration.type === 'TSInterfaceDeclaration' ||\n\t\t\tdeclaration.type === 'TSTypeAliasDeclaration' ||\n\t\t\tdeclaration.type === 'TSEnumDeclaration' ||\n\t\t\tdeclaration.type === 'TSModuleDeclaration'\n\t\t) {\n\t\t\treturn declaration.id?.type === 'Identifier' ? [declaration.id.name] : []\n\t\t}\n\t\treturn []\n\t})\n}\n\n/**\n * Checks whether a source entry exports names, following local star exports.\n * @param path - The source entry to inspect.\n * @param ancestors - The entries already visited on this export path.\n * @returns True if the entry exports a name; false otherwise.\n */\nexport function matchesDistributionSourceExports(\n\tpath: string,\n\tancestors: readonly string[] = [],\n): boolean {\n\tif (ancestors.includes(path)) return false\n\tconst source = parseSync(path, readFileSync(path, 'utf8'))\n\tif (source.errors.length > 0) throw new Error(`Unreadable source exports at ${path}`)\n\treturn source.program.body.some((statement) => {\n\t\tif (statement.type === 'ExportDefaultDeclaration') return ancestors.length === 0\n\t\tif (statement.type === 'ExportNamedDeclaration')\n\t\t\treturn (\n\t\t\t\tstatement.declaration !== null ||\n\t\t\t\tstatement.specifiers.some((specifier) => {\n\t\t\t\t\tconst name =\n\t\t\t\t\t\tspecifier.exported.type === 'Identifier'\n\t\t\t\t\t\t\t? specifier.exported.name\n\t\t\t\t\t\t\t: specifier.exported.value\n\t\t\t\t\treturn ancestors.length === 0 || name !== 'default'\n\t\t\t\t})\n\t\t\t)\n\t\tif (statement.type !== 'ExportAllDeclaration') return false\n\t\tif (statement.exported !== null || !statement.source.value.startsWith('.')) return true\n\t\tconst target = resolve(dirname(path), statement.source.value.replace(/\\.js$/u, '.ts'))\n\t\treturn matchesDistributionSourceExports(target, [...ancestors, path])\n\t})\n}\n\n/**\n * Scans installed declaration faces for names declared by multiple environments.\n * @param installed - The installed package root.\n * @param source - The workspace holding the source entries being published.\n * @returns The repeated names with their declaring faces.\n * @throws Thrown when a source entry exports names but its roll-up declares none.\n */\nexport function scanDistributionDeclarations(\n\tinstalled: string,\n\tsource: string = DISTRIBUTION_ROOT,\n): readonly string[] {\n\tconst declarations = collectDistributionFiles(join(installed, 'dist'))\n\t\t.filter(matchesDistributionDeclaration)\n\t\t.map((path) => ({\n\t\t\tpath,\n\t\t\tface: readDistributionFace(installed, path),\n\t\t\tnames: readDistributionNames(path),\n\t\t}))\n\tconst entries = collectDistributionFiles(join(source, 'src')).filter((path) => {\n\t\tconst parts = relativePath(source, path).split(sep)\n\t\treturn parts.length === 3 && parts[2] === 'index.ts'\n\t})\n\tconst published = entries.filter((path) => matchesDistributionSourceExports(path))\n\tfor (const path of published) {\n\t\tconst face = relativePath(source, path).split(sep)[1]\n\t\tif (!declarations.some((entry) => entry.face === face && entry.names.length > 0))\n\t\t\tthrow new Error(\n\t\t\t\t`The ${face} source entry exports names but its declaration roll-up declares none`,\n\t\t\t)\n\t}\n\tif (published.length === 0)\n\t\tconsole.info('No source entry exports names, so no declaration names are required')\n\tconst names = [...new Set(declarations.flatMap((entry) => entry.names))].sort()\n\treturn names.flatMap((name) => {\n\t\tconst faces = [\n\t\t\t...new Set(\n\t\t\t\tdeclarations\n\t\t\t\t\t.filter((entry) => entry.names.includes(name))\n\t\t\t\t\t.map((entry) => entry.face)\n\t\t\t\t\t.filter((face) => face !== undefined),\n\t\t\t),\n\t\t].sort()\n\t\treturn faces.length > 1 ? [`${name}: ${faces.join(', ')}`] : []\n\t})\n}\n\n/**\n * Checks the installed manifest against npm's normalization in an owned scratch copy.\n * @param installed - The installed package root, read only.\n * @param scratch - The suite's owned scratch root and npm cache parent.\n * @returns The top-level keys changed by npm. Refuses an unsuccessful npm command.\n */\nexport function checkDistributionManifest(installed: string, scratch: string): readonly string[] {\n\tconst directory = mkdtempSync(join(scratch, 'manifest-'))\n\ttry {\n\t\tconst path = join(directory, 'package.json')\n\t\twriteFileSync(path, readFileSync(join(installed, 'package.json')))\n\t\tconst before = readDistributionJSON(path)\n\t\tconst result = runDistributionNpm(['pkg', 'fix'], directory, scratch)\n\t\tif (result.status !== 0)\n\t\t\tthrow new Error(`npm pkg fix failed: ${readDistributionOutput(result)}`)\n\t\tconst after = readDistributionJSON(path)\n\t\tif (!isDistributionRecord(before) || !isDistributionRecord(after))\n\t\t\tthrow new Error('Unreadable manifest')\n\t\treturn [...new Set([...Object.keys(before), ...Object.keys(after)])]\n\t\t\t.filter((key) => !isDeepStrictEqual(before[key], after[key]))\n\t\t\t.sort()\n\t} finally {\n\t\trmSync(directory, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 })\n\t}\n}\n\n/**\n * Builds independently registered observations over the suite's installed consumer.\n * @param suite - The lifecycle shared by the proof's hooks and observations.\n * @returns The case rows whose observations each require one assertion.\n */\nexport function buildDistributionCases(\n\tsuite: DistributionSuiteInterface,\n): readonly DistributionCase[] {\n\treturn [\n\t\t{\n\t\t\tlabel: 'classifies synthetic export mappings without a registry stage',\n\t\t\tobserve: () => {\n\t\t\t\tconst root = join(suite.scratch, 'classifiers')\n\t\t\t\twriteDistributionFile(\n\t\t\t\t\tjoin(root, 'package.json'),\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\ttype: 'commonjs',\n\t\t\t\t\t\texports: {\n\t\t\t\t\t\t\tcondition: { browser: './b.js', default: './n.js' },\n\t\t\t\t\t\t\tconvention: { default: './dist/src/browser/index.js' },\n\t\t\t\t\t\t\tuniversal: { default: './shared.js' },\n\t\t\t\t\t\t\t'import-shared': {\n\t\t\t\t\t\t\t\tbrowser: './shared.mjs',\n\t\t\t\t\t\t\t\timport: './shared.mjs',\n\t\t\t\t\t\t\t\tdefault: './node.js',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'require-shared': {\n\t\t\t\t\t\t\t\tbrowser: './shared.cjs',\n\t\t\t\t\t\t\t\trequire: './shared.cjs',\n\t\t\t\t\t\t\t\tdefault: './node.js',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tnode: { node: './node.js', default: './node.js' },\n\t\t\t\t\t\t\tsilent: { 'module-sync': './x.cjs', import: './x.mjs' },\n\t\t\t\t\t\t\tmodule: { require: './x.mjs' },\n\t\t\t\t\t\t\t'nested-module': { require: './module/x.js' },\n\t\t\t\t\t\t\t'nested-commonjs': { require: './commonjs/x.js' },\n\t\t\t\t\t\t\tesm: { import: './x.mjs' },\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\twriteDistributionFile(join(root, 'module/package.json'), '{ \"type\": \"module\" }\\n')\n\t\t\t\twriteDistributionFile(join(root, 'commonjs/package.json'), '{ \"type\": \"commonjs\" }\\n')\n\t\t\t\tconst manifest = readDistributionJSON(join(root, 'package.json'))\n\t\t\t\tif (!isDistributionRecord(manifest) || !isDistributionRecord(manifest.exports)) {\n\t\t\t\t\tthrow new Error('The classifier fixture declares no exports map')\n\t\t\t\t}\n\t\t\t\tconst mappings = manifest.exports\n\n\t\t\t\treturn {\n\t\t\t\t\tactual: {\n\t\t\t\t\t\tbrowser: {\n\t\t\t\t\t\t\tcondition: resolvesDistributionBrowser(mappings.condition),\n\t\t\t\t\t\t\tconvention: resolvesDistributionBrowser(mappings.convention),\n\t\t\t\t\t\t\tuniversal: resolvesDistributionBrowser(mappings.universal),\n\t\t\t\t\t\t\timport: resolvesDistributionBrowser(mappings['import-shared']),\n\t\t\t\t\t\t\trequire: resolvesDistributionBrowser(mappings['require-shared']),\n\t\t\t\t\t\t\tnode: resolvesDistributionBrowser(mappings.node),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcommonjs: {\n\t\t\t\t\t\t\tsilent: resolvesDistributionCommonJS(mappings.silent, root),\n\t\t\t\t\t\t\tmodule: resolvesDistributionCommonJS(mappings.module, root),\n\t\t\t\t\t\t\tnestedModule: resolvesDistributionCommonJS(mappings['nested-module'], root),\n\t\t\t\t\t\t\tnestedCommonJS: resolvesDistributionCommonJS(mappings['nested-commonjs'], root),\n\t\t\t\t\t\t\tesm: resolvesDistributionCommonJS(mappings.esm, root),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\texpected: {\n\t\t\t\t\t\tbrowser: {\n\t\t\t\t\t\t\tcondition: true,\n\t\t\t\t\t\t\tconvention: true,\n\t\t\t\t\t\t\tuniversal: false,\n\t\t\t\t\t\t\timport: false,\n\t\t\t\t\t\t\trequire: false,\n\t\t\t\t\t\t\tnode: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcommonjs: {\n\t\t\t\t\t\t\tsilent: true,\n\t\t\t\t\t\t\tmodule: false,\n\t\t\t\t\t\t\tnestedModule: false,\n\t\t\t\t\t\t\tnestedCommonJS: true,\n\t\t\t\t\t\t\tesm: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tlabel: 'keeps installed JavaScript sources in their own environment [requires the registry]',\n\t\t\tobserve: (context) => {\n\t\t\t\tconst stage = suite.read(context)\n\t\t\t\treturn { actual: scanDistributionSourceMaps(stage.installed), expected: [] }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tlabel: 'declares each installed name in one environment [requires the registry]',\n\t\t\tobserve: (context) => {\n\t\t\t\tconst stage = suite.read(context)\n\t\t\t\tconst faces = new Set(\n\t\t\t\t\tcollectDistributionFiles(join(stage.installed, 'dist'))\n\t\t\t\t\t\t.filter(matchesDistributionDeclaration)\n\t\t\t\t\t\t.map((path) => readDistributionFace(stage.installed, path))\n\t\t\t\t\t\t.filter((face) => face !== undefined),\n\t\t\t\t)\n\t\t\t\tconst findings = scanDistributionDeclarations(stage.installed)\n\t\t\t\tif (faces.size <= 1)\n\t\t\t\t\tconsole.info(\n\t\t\t\t\t\t'Fewer than two declaration faces are installed, so no cross-face copy exists',\n\t\t\t\t\t)\n\t\t\t\treturn { actual: findings, expected: [] }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tlabel: 'keeps the installed manifest fixed under npm pkg fix [requires the registry]',\n\t\t\tobserve: (context) => ({\n\t\t\t\tactual: checkDistributionManifest(suite.read(context).installed, suite.scratch),\n\t\t\t\texpected: [],\n\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tlabel: 'packs one archive and installs it in isolation [requires the registry]',\n\t\t\tobserve: (context) => {\n\t\t\t\tconst stage = suite.read(context)\n\t\t\t\treturn {\n\t\t\t\t\tactual: {\n\t\t\t\t\t\tarchives: stage.archives.length,\n\t\t\t\t\t\tinstalled: existsSync(join(stage.installed, 'package.json')),\n\t\t\t\t\t\tentries: stage.entries.length > 0,\n\t\t\t\t\t},\n\t\t\t\t\texpected: { archives: 1, installed: true, entries: true },\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tlabel: 'ships every relative target its exports map names [requires the registry]',\n\t\t\tobserve: (context) => {\n\t\t\t\tconst stage = suite.read(context)\n\t\t\t\tconst relative = stage.targets.filter((target) => target.startsWith('./'))\n\t\t\t\treturn {\n\t\t\t\t\tactual: {\n\t\t\t\t\t\tpopulated: relative.length > 0,\n\t\t\t\t\t\tmissing: relative.filter((target) => !existsSync(join(stage.installed, target))),\n\t\t\t\t\t},\n\t\t\t\t\texpected: { populated: true, missing: [] },\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tlabel: 'declares types for every module it publishes [requires the registry]',\n\t\t\tobserve: (context) => {\n\t\t\t\tconst stage = suite.read(context)\n\t\t\t\tconst partitioned = [\n\t\t\t\t\t...stage.entries.map((entry) => entry.subpath),\n\t\t\t\t\t...stage.undeclared,\n\t\t\t\t\t...stage.excluded,\n\t\t\t\t]\n\t\t\t\treturn {\n\t\t\t\t\tactual: {\n\t\t\t\t\t\tundeclared: stage.undeclared,\n\t\t\t\t\t\tpartitioned: partitioned.sort(),\n\t\t\t\t\t\tunreachable: stage.entries\n\t\t\t\t\t\t\t.filter((entry) => !entry.importable && !entry.requirable && !entry.browsable)\n\t\t\t\t\t\t\t.map((entry) => entry.subpath),\n\t\t\t\t\t\tuntypable: filterDistributionUntypable(stage.entries, stage.installed).map(\n\t\t\t\t\t\t\t(entry) => entry.subpath,\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texpected: {\n\t\t\t\t\t\tundeclared: [],\n\t\t\t\t\t\tpartitioned: [...stage.subpaths].sort(),\n\t\t\t\t\t\tunreachable: [],\n\t\t\t\t\t\tuntypable: [],\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tlabel: 'refuses a subpath its exports map does not name [requires the registry]',\n\t\t\tobserve: (context) => {\n\t\t\t\tconst stage = suite.read(context)\n\t\t\t\tconst name = readDistributionManifestName(join(stage.installed, 'package.json'))\n\t\t\t\tconst result = runDistributionNode(\n\t\t\t\t\t[join(stage.consumer, DISTRIBUTION_ESM_DRIVER), `${name}${DISTRIBUTION_ABSENT_SUBPATH}`],\n\t\t\t\t\tstage.consumer,\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tactual: {\n\t\t\t\t\t\trefused: result.status !== 0,\n\t\t\t\t\t\tcoded: readDistributionOutput(result).includes('ERR_PACKAGE_PATH_NOT_EXPORTED'),\n\t\t\t\t\t},\n\t\t\t\t\texpected: { refused: true, coded: true },\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tlabel: 'compiles a consumer under every module resolution [requires the registry]',\n\t\t\tobserve: (context) => {\n\t\t\t\tconst stage = suite.read(context)\n\t\t\t\tconst name = readDistributionManifestName(join(stage.installed, 'package.json'))\n\t\t\t\tconst readings = DISTRIBUTION_RESOLUTIONS.flatMap((driver) =>\n\t\t\t\t\tDISTRIBUTION_FORMATS.flatMap(([extension, format]) => {\n\t\t\t\t\t\tconst written = filterDistributionEntries(stage.entries, driver.conditions[format])\n\t\t\t\t\t\tif (written.length === 0) return []\n\t\t\t\t\t\tconst label = `${driver.label}.${extension}`\n\t\t\t\t\t\tconst probe = `probe.${label}`\n\t\t\t\t\t\tconst specifiers = written.map((entry) => entry.specifier)\n\t\t\t\t\t\twriteDistributionConsumerProbe(stage, probe, specifiers)\n\t\t\t\t\t\tconst project = writeDistributionProject(stage, probe, driver, [`./${probe}`])\n\t\t\t\t\t\tconst messages = checkDistributionProject(stage, project).map(\n\t\t\t\t\t\t\t(message) => `${label}: ${message}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tconst control = `control.${label}`\n\t\t\t\t\t\twriteDistributionConsumerProbe(stage, control, [\n\t\t\t\t\t\t\t`${name}${DISTRIBUTION_ABSENT_SUBPATH}`,\n\t\t\t\t\t\t])\n\t\t\t\t\t\tconst refused = writeDistributionProject(stage, control, driver, [`./${control}`])\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmessages,\n\t\t\t\t\t\t\t\tsilent: checkDistributionProject(stage, refused).length === 0 ? [label] : [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tactual: {\n\t\t\t\t\t\tmessages: readings.flatMap(({ messages }) => messages),\n\t\t\t\t\t\tsilent: readings.flatMap(({ silent }) => silent),\n\t\t\t\t\t},\n\t\t\t\t\texpected: { messages: [], silent: [] },\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tlabel: 'publishes what it declares to a Node import, and no more',\n\t\t\tobserve: (context) => {\n\t\t\t\tconst stage = suite.read(context)\n\t\t\t\tconst entries = stage.entries.filter((entry) => entry.importable)\n\t\t\t\tif (entries.length === 0) return context.skip('No installed entry supports Node import')\n\t\t\t\tconst readings = entries.map((entry) => {\n\t\t\t\t\tif (!entry.declaration.importable)\n\t\t\t\t\t\tthrow new Error(`${entry.subpath} publishes no import declaration`)\n\t\t\t\t\tconst published = driveDistributionRuntime(\n\t\t\t\t\t\tstage,\n\t\t\t\t\t\tentry.specifier,\n\t\t\t\t\t\tDISTRIBUTION_ESM_DRIVER,\n\t\t\t\t\t)\n\t\t\t\t\tconst drivers = filterDistributionResolutions(entry, 'module')\n\t\t\t\t\treturn {\n\t\t\t\t\t\tentry: entry.subpath,\n\t\t\t\t\t\tdriven: drivers.length > 0,\n\t\t\t\t\t\treported: drivers.flatMap((driver) =>\n\t\t\t\t\t\t\tcheckDistributionSurface(stage, { entry, extension: 'ts', published, driver }),\n\t\t\t\t\t\t),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\treturn {\n\t\t\t\t\tactual: readings,\n\t\t\t\t\texpected: entries.map((entry) => ({ entry: entry.subpath, driven: true, reported: [] })),\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tlabel: 'publishes what it declares to a Node require, and no more',\n\t\t\tobserve: (context) => {\n\t\t\t\tconst stage = suite.read(context)\n\t\t\t\tconst entries = stage.entries.filter((entry) => entry.requirable)\n\t\t\t\tif (entries.length === 0) return context.skip('No installed entry supports Node require')\n\t\t\t\tconst readings = entries.map((entry) => {\n\t\t\t\t\tif (!entry.declaration.requirable)\n\t\t\t\t\t\tthrow new Error(`${entry.subpath} publishes no require declaration`)\n\t\t\t\t\tconst published = driveDistributionRuntime(\n\t\t\t\t\t\tstage,\n\t\t\t\t\t\tentry.specifier,\n\t\t\t\t\t\tDISTRIBUTION_CJS_DRIVER,\n\t\t\t\t\t)\n\t\t\t\t\tconst drivers = filterDistributionResolutions(entry, 'commonjs')\n\t\t\t\t\treturn {\n\t\t\t\t\t\tentry: entry.subpath,\n\t\t\t\t\t\tdriven: drivers.length > 0,\n\t\t\t\t\t\treported: drivers.flatMap((driver) =>\n\t\t\t\t\t\t\tcheckDistributionSurface(stage, { entry, extension: 'cts', published, driver }),\n\t\t\t\t\t\t),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\treturn {\n\t\t\t\t\tactual: readings,\n\t\t\t\t\texpected: entries.map((entry) => ({ entry: entry.subpath, driven: true, reported: [] })),\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t]\n}\n";
136
- proof: "import {\n\t// These exports remain available to proofs emitted by earlier scaffold releases.\n\tbuildDistributionCases,\n\t{{import}}createDistributionSuite,\n} from './setupDistribution.js'\nimport { afterAll, beforeAll, describe, expect, it } from 'vitest'\n\nconst DISTRIBUTION_SUITE = createDistributionSuite()\n\nbeforeAll(() => DISTRIBUTION_SUITE.start())\n\nafterAll(() => DISTRIBUTION_SUITE.destroy())\n\ndescribe('installed package consumer', () => {\n\tfor (const row of buildDistributionCases(DISTRIBUTION_SUITE)) {\n\t\tit(`${row.label}`, async (context) => {\n\t\t\tconst observation = await row.observe(context)\n\t\t\texpect(observation.actual).toStrictEqual(observation.expected)\n\t\t})\n\t}\n{{guard}}{{drive}}})\n";
137
- transport: "import { createServer } from 'node:http'\n";
138
- types: "import type { PlaywrightProviderOptions } from '@vitest/browser-playwright'\nimport type { Browser } from 'playwright'\n";
139
- launcher: "import { chromium } from 'playwright'\nimport { build } from 'vite'\nimport { resolveBrowser, resolvePinnedBrowser } from '../configs/browsers.js'\n";
140
- import: "checkDistributionBrowser,\n\t";
141
- helpers: "/** Defines the page that loads a bundled browser consumer. */\nexport const DISTRIBUTION_BROWSER_PAGE = `<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"UTF-8\" />\n\t\t<title>Distribution</title>\n\t</head>\n\t<body>\n\t\t<script type=\"module\" src=\"./main.js\"></script>\n\t</body>\n</html>\n`\n\n/**\n * Infers the response media type from a bundle filename.\n *\n * @param path - The requested bundle path.\n * @returns The media type, defaulting to application/octet-stream.\n */\nexport function inferDistributionContentType(path: string): string {\n\tif (path.endsWith('.html')) return 'text/html'\n\tif (path.endsWith('.js')) return 'text/javascript'\n\tif (path.endsWith('.css')) return 'text/css'\n\tif (path.endsWith('.json') || path.endsWith('.map')) return 'application/json'\n\treturn 'application/octet-stream'\n}\n\n// `resolveBrowser` answers with provider options and never reports absence: its\n// last resort is a channel nothing verified. So the launch is attempted and its\n// rejection classified, rather than probed for and ruled on.\n/**\n * Renders the browser endpoint selected by provider options.\n *\n * @param options - The browser provider options.\n * @returns The endpoint, executable, channel, or bundled-browser description.\n */\nexport function renderDistributionBrowser(options: PlaywrightProviderOptions): string {\n\tconst endpoint = options.connectOptions?.wsEndpoint\n\tif (endpoint !== undefined) return `the browser server at ${endpoint}`\n\tconst executable = options.launchOptions?.executablePath\n\tif (executable !== undefined) return `the executable at ${executable}`\n\tconst channel = options.launchOptions?.channel\n\tif (channel !== undefined) return `the ${channel} channel`\n\treturn 'the Chromium Playwright installed for itself'\n}\n\n/**\n * Launches or connects to the selected Chromium browser.\n *\n * @param options - The browser provider options.\n * @returns The real browser. Rejects when the selected browser is unavailable.\n */\nexport async function launchDistributionBrowser(\n\toptions: PlaywrightProviderOptions,\n): Promise<Browser> {\n\tconst endpoint = options.connectOptions?.wsEndpoint\n\tif (endpoint !== undefined) return chromium.connect(endpoint)\n\treturn chromium.launch({ ...options.launchOptions, headless: true })\n}\n\n// A consumer of one installed browser entry, bundled by the Vite toolchain this\n// workspace already declares. Nothing is stubbed: the bundle resolves the installed\n// package and its whole transitive graph as an application consuming it would.\n/**\n * Bundles a browser consumer against an installed public entry.\n *\n * @param stage - The installed consumer.\n * @param entry - The browser publication.\n * @returns The bundle directory. Rejects when Vite cannot build the consumer.\n */\nexport async function bundleDistributionEntry(\n\tstage: DistributionStage,\n\tentry: DistributionEntry,\n): Promise<string> {\n\tconst page = join(stage.consumer, 'pages', entry.subpath.replaceAll(/[^\\w]+/gu, '-'))\n\tconst specifier = JSON.stringify(entry.specifier)\n\twriteDistributionFile(join(page, 'index.html'), DISTRIBUTION_BROWSER_PAGE)\n\twriteDistributionFile(\n\t\tjoin(page, 'main.js'),\n\t\t`import * as entry from ${specifier}\\nglobalThis.subject = Object.keys(entry).sort()\\n`,\n\t)\n\tawait build({\n\t\tbase: './',\n\t\tbuild: { emptyOutDir: true, outDir: 'bundle' },\n\t\tconfigFile: false,\n\t\tlogLevel: 'error',\n\t\troot: page,\n\t})\n\treturn join(page, 'bundle')\n}\n\n// The key set the bundled module publishes in a real browser, read off the page\n// after it has loaded over a loopback server. A module that never evaluated\n// publishes nothing, and a page error is raised rather than compared away.\n/**\n * Reads the names a real browser publishes from a served bundle.\n *\n * @param browser - The browser to drive.\n * @param bundle - The built consumer directory.\n * @returns The exported names. Rejects on a page error or an invalid name list.\n */\nexport async function readDistributionBrowserExports(\n\tbrowser: Browser,\n\tbundle: string,\n): Promise<readonly string[]> {\n\tconst server = createServer((request, response) => {\n\t\tconst asked = request.url === undefined || request.url === '/' ? '/index.html' : request.url\n\t\tconst path = join(bundle, decodeURIComponent(asked))\n\t\tif (!path.startsWith(bundle) || !existsSync(path)) {\n\t\t\tresponse.writeHead(404)\n\t\t\tresponse.end()\n\t\t\treturn\n\t\t}\n\t\tresponse.writeHead(200, { 'content-type': inferDistributionContentType(path) })\n\t\tresponse.end(readFileSync(path))\n\t})\n\ttry {\n\t\tawait new Promise<void>((settle) => {\n\t\t\tserver.listen(0, '127.0.0.1', settle)\n\t\t})\n\t\tconst address = server.address()\n\t\tif (address === null || typeof address === 'string') {\n\t\t\tthrow new Error('The bundle server bound no port')\n\t\t}\n\t\tconst page = await browser.newPage()\n\t\tconst failures: string[] = []\n\t\tpage.on('pageerror', (error) => failures.push(String(error)))\n\t\tawait page.goto(`http://127.0.0.1:${String(address.port)}/`, { waitUntil: 'load' })\n\t\tconst published: unknown = await page.evaluate('globalThis.subject')\n\t\tif (failures.length > 0) throw new Error(`The bundle raised ${failures.join(' | ')}`)\n\t\tif (!isDistributionNames(published))\n\t\t\tthrow new Error('The bundled module published no name list')\n\t\treturn published\n\t} finally {\n\t\tserver.close()\n\t}\n}\n/**\n * Checks each browser publication against its installed declarations in a real browser.\n * @param stage - The installed consumer to drive.\n * @param context - The proof context that reports unavailable browser prerequisites.\n * @returns The compiler diagnostics each browser publication reports.\n */\nexport async function checkDistributionBrowser(\n\tstage: DistributionStage,\n\tcontext: TestContext,\n): Promise<readonly string[]> {\n\tconst driver = DISTRIBUTION_BROWSER_RESOLUTION\n\tif (driver === undefined) throw new Error(\"DISTRIBUTION_RESOLUTIONS carries no 'bundler' row\")\n\tconst entries = stage.entries.filter((entry) => entry.browsable)\n\tif (entries.length === 0) return context.skip('No installed entry supports a browser')\n\tconst readings: Array<readonly string[]> = []\n\tfor (const entry of entries) {\n\t\tif (!entry.declaration.browsable) {\n\t\t\tthrow new Error(`${entry.subpath} publishes no browser declaration`)\n\t\t}\n\t\tconst options = resolveBrowser(resolvePinnedBrowser(), process.platform, process.env)\n\t\tconst browser = await launchDistributionBrowser(options).catch((error: unknown) => {\n\t\t\tconst cause = `${renderDistributionBrowser(options)} was rejected: ${String(error)}`\n\t\t\tif (DISTRIBUTION_RELEASE) throw new Error(`The release gate requires a browser, and ${cause}`)\n\t\t\treturn context.skip(`No browser launched. ${cause}`)\n\t\t})\n\t\ttry {\n\t\t\tconst bundle = await bundleDistributionEntry(stage, entry)\n\t\t\tconst published = await readDistributionBrowserExports(browser, bundle)\n\t\t\t// A browser consumer reads the installed declarations through a bundler, so\n\t\t\t// that is the one driver this face answers under.\n\t\t\tconst reported = checkDistributionSurface(stage, {\n\t\t\t\tentry,\n\t\t\t\textension: 'ts',\n\t\t\t\tpublished,\n\t\t\t\tdriver,\n\t\t\t})\n\t\t\treadings.push(reported)\n\t\t} finally {\n\t\t\tawait browser.close()\n\t\t}\n\t}\n\treturn readings.flat()\n}\n";
142
- drive: "\tit('publishes what it declares to a real browser [requires a browser]', async (context) => {\n\t\texpect(await checkDistributionBrowser(DISTRIBUTION_SUITE.read(context), context)).toStrictEqual(\n\t\t\t[],\n\t\t)\n\t})\n";
143
- guard: "\tit('publishes no browser face this proof cannot drive [requires the registry]', (context) => {\n\t\tconst faces = DISTRIBUTION_SUITE.read(context).entries.filter((entry) => entry.browsable)\n\t\texpect(faces.map((entry) => entry.subpath)).toStrictEqual([])\n\t})\n";
144
- }>;
145
- integration: "{{imports}}import { describe, expect, it } from 'vitest'\n\ndescribe('workspace integration', () => {\n\tit('loads every selected public barrel together as a composition seed', () => {\n\t\t// Replace this empty-barrel seed with one observable flow that passes one\n\t\t// environment's public result into another.\n\t\t{{actual}}{{expected}})\n\t})\n})\n";
146
- }>;
147
- docs: Readonly<{
148
- readme: "# {{package}}\n\n{{description}}\n\n## Development\n\n```sh\nnpm install\nnpm test\n```\n";
149
- agents: "# AGENTS.md\n\nThe `@orkestrel/scaffold` package is this repository's coding and orchestration authority. This\nfile points at it and states no law of its own.\n\nRead these before working: the `AGENTS.md` coding contract, the `.agents/orchestration.md`\nagent-operation contract, every applicable rule the contract's rule map names under\n`.claude/rules/`, and the dispatch-named skill under `.agents/skills/` with the references it\nrequires.\n\nResolve every one of those paths against scaffold, never against this repository:\n\n- When a scaffold checkout sits beside this repository, read `../scaffold/AGENTS.md`, the\n `../scaffold/.agents/orchestration.md` file, the `../scaffold/.claude/rules/` directory, and\n the `../scaffold/.agents/skills/` directory.\n- Otherwise read the installed copy, whose paths drop the dot that opens each segment: the\n `node_modules/@orkestrel/scaffold/dist/host/AGENTS.md` file, the\n `node_modules/@orkestrel/scaffold/dist/host/agents/orchestration.md` file, the\n `node_modules/@orkestrel/scaffold/dist/host/claude/rules/` directory, and the\n `node_modules/@orkestrel/scaffold/dist/host/agents/skills/` directory.\n\nEvery path a scaffold-supplied file names resolves the same way. Run a script such a file names\nthrough its built twin: replace `node .agents/skills/` with\n`node node_modules/@orkestrel/scaffold/dist/agents/skills/` and the `.ts` extension with `.js`,\nbecause Node runs no `.ts` file under `node_modules`. The files this repository carries\n— the `.claude/agents/orkestrel.md` catalog file, the `.claude/settings.json` permission file,\nthe bench scripts under `scripts/`, and the skill pointers under `.agents/skills/` and\n`.claude/skills/`, which name the canonical skills and how to run their scripts — are this\nrepository's own copies and resolve here.\n\nIn Claude Code, also read the Claude bridge: `../scaffold/.claude/AGENTS.md` beside a checkout, or\n`node_modules/@orkestrel/scaffold/dist/host/claude/AGENTS.md` from the installed copy. Keep no\n`CLAUDE.md` in this repository; one stops Claude Code from reading this file.\n\nEdit none of the scaffold-owned files here. The `scaffold repair` command restores them, so a\nchange to one is a commit in the scaffold repository followed by a release.\n";
150
- }>;
151
- guides: Readonly<{
152
- readme: "# Guides\n\n## By concept\n\n- Package\n - Spec: Not created. Create this file when the workspace has a public surface:\n `guides/{{guide}}.md`\n - Source:\n{{source}}\n - Tests:\n{{tests}}\n\n## By directory\n\n{{directories}}\n";
153
- }>;
154
- orchestration: Readonly<{
155
- skill: "\n# Load the canonical skill\n\nThis file is a pointer the `@orkestrel/scaffold` package writes into every fleet workspace; the\nskill itself ships with that package. Read the canonical `SKILL.md` completely and follow it:\n\n- beside a scaffold checkout, `../scaffold/.agents/skills/{{name}}/SKILL.md`;\n- otherwise, `node_modules/@orkestrel/scaffold/dist/host/agents/skills/{{name}}/SKILL.md`.\n\nResolve every path the canonical skill names against the same root; under `node_modules` each\nsegment drops its opening dot. Run a script the skill names through its built twin, as this\nrepository's `AGENTS.md` states. This pointer carries no process of its own; the authority order is\n`.agents/orchestration.md` § Authority.\n";
156
- service: "#!/usr/bin/env sh\nset -eu\n\nprintf '%s\\n' \\\n{{vendors}}\n";
157
- }>;
158
- }>;
93
+ export declare const ARTIFACT_TEMPLATES: ArtifactTemplateSet;
159
94
 
160
95
  /** Describes the fields every planned file carries. */
161
96
  export declare interface ArtifactBase {
@@ -193,6 +128,74 @@ export declare interface ArtifactBase {
193
128
  */
194
129
  export declare function artifactsToQuestions(artifacts: readonly Artifact[]): readonly Question[];
195
130
 
131
+ /** Represents the source, test, document, guide, and service template text. */
132
+ export declare interface ArtifactTemplateSet {
133
+ readonly source: {
134
+ readonly sheet: {
135
+ readonly 'index.scss': string;
136
+ readonly '_tokens.scss': string;
137
+ readonly '_mixins.scss': string;
138
+ readonly 'elements/_index.scss': string;
139
+ readonly 'components/_index.scss': string;
140
+ readonly 'utilities/_index.scss': string;
141
+ readonly 'sheet.ts': string;
142
+ readonly 'index.ts': string;
143
+ };
144
+ readonly themes: {
145
+ readonly 'index.scss': string;
146
+ readonly '_default.scss': string;
147
+ readonly 'sheet.ts': string;
148
+ };
149
+ readonly empty: string;
150
+ readonly barrel: string;
151
+ readonly main: string;
152
+ readonly vue: {
153
+ readonly 'main.ts': string;
154
+ readonly 'App.vue': string;
155
+ };
156
+ readonly browser: string;
157
+ };
158
+ readonly tests: {
159
+ readonly journey: string;
160
+ readonly browser: string;
161
+ readonly sheet: string;
162
+ readonly styles: {
163
+ readonly module: string;
164
+ readonly proof: string;
165
+ };
166
+ readonly setup: string;
167
+ readonly global: {
168
+ readonly module: string;
169
+ readonly proof: string;
170
+ };
171
+ readonly entry: string;
172
+ readonly bin: string;
173
+ readonly distribution: {
174
+ readonly module: string;
175
+ readonly proof: string;
176
+ readonly transport: string;
177
+ readonly types: string;
178
+ readonly launcher: string;
179
+ readonly import: string;
180
+ readonly helpers: string;
181
+ readonly drive: string;
182
+ readonly guard: string;
183
+ };
184
+ readonly integration: string;
185
+ };
186
+ readonly docs: {
187
+ readonly readme: string;
188
+ readonly agents: string;
189
+ };
190
+ readonly guides: {
191
+ readonly readme: string;
192
+ };
193
+ readonly orchestration: {
194
+ readonly skill: string;
195
+ readonly service: string;
196
+ };
197
+ }
198
+
196
199
  /**
197
200
  * Projects one planned artifact and the bytes found at its path into a verdict.
198
201
  *
@@ -1242,6 +1245,56 @@ export declare function catalogToLayers(entries: readonly CatalogEntry[]): Reado
1242
1245
  */
1243
1246
  export declare function cloneValue(value: unknown): JSONValue | undefined;
1244
1247
 
1248
+ /**
1249
+ * Collects bare names claimed by distinct owners in sorted order.
1250
+ *
1251
+ * @remarks
1252
+ * Declaration keywords and environments do not enter a claim's identity.
1253
+ * Repeated claims by one owner count once.
1254
+ *
1255
+ * @example
1256
+ * ```ts
1257
+ * import { collectSurfaceCollisions } from '@orkestrel/scaffold'
1258
+ *
1259
+ * collectSurfaceCollisions([{ owner: 'router', names: ['Route'] }]) // []
1260
+ * ```
1261
+ */
1262
+ export declare function collectSurfaceCollisions(claims: readonly SurfaceClaim[]): readonly SurfaceCollision[];
1263
+
1264
+ /**
1265
+ * Collects the bare names one owner exports from two or more of its environments.
1266
+ *
1267
+ * @param owner - The unscoped package that exports the names.
1268
+ * @param exports - Each environment's exported bare names, keyed by environment.
1269
+ * @returns One conflict per such name with its sorted environments, sorted by name.
1270
+ *
1271
+ * @example
1272
+ * ```ts
1273
+ * import { collectSurfaceConflicts } from '@orkestrel/scaffold'
1274
+ *
1275
+ * collectSurfaceConflicts('mcp', { core: ['Tool'], server: ['Tool', 'Server'] })
1276
+ * // [{ name: 'Tool', owner: 'mcp', environments: ['core', 'server'] }]
1277
+ * ```
1278
+ */
1279
+ export declare function collectSurfaceConflicts(owner: string, exports: Readonly<Record<string, readonly string[]>>): readonly SurfaceConflict[];
1280
+
1281
+ /**
1282
+ * Compares collisions with the record and reports errors, recorded subsets, and closures.
1283
+ *
1284
+ * @remarks
1285
+ * A name absent from the record or carrying an additional owner is an error.
1286
+ * A recorded name absent from the collisions is closed. Results sort by name.
1287
+ *
1288
+ * @example
1289
+ * ```ts
1290
+ * import { compareSurfaceCollisions } from '@orkestrel/scaffold'
1291
+ *
1292
+ * compareSurfaceCollisions([], [{ name: 'Route', owners: ['router', 'server'] }])
1293
+ * // [{ name: 'Route', owners: ['router', 'server'], standing: 'closed' }]
1294
+ * ```
1295
+ */
1296
+ export declare function compareSurfaceCollisions(collisions: readonly SurfaceCollision[], record: readonly SurfaceCollision[]): readonly SurfaceFinding[];
1297
+
1245
1298
  /**
1246
1299
  * Compares two versions by their numeric components.
1247
1300
  *
@@ -1575,84 +1628,87 @@ export declare class Compiler implements CompilerInterface {
1575
1628
  * CONFIG_TEMPLATES.root.tsconfig.startsWith('{') // true
1576
1629
  * ```
1577
1630
  */
1578
- export declare const CONFIG_TEMPLATES: Readonly<{
1579
- root: Readonly<{
1580
- tsconfig: "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\",\n\t\t\"module\": \"ESNext\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowImportingTsExtensions\": true,\n\t\t\"lib\": [\"ESNext\", \"DOM\", \"DOM.Iterable\"],\n\t\t\"types\": [\"node\", \"vite/client\", \"vitest/globals\"],\n\t\t\"moduleDetection\": \"force\",\n\t\t\"resolveJsonModule\": true,\n\t\t\"strict\": true,\n\t\t\"verbatimModuleSyntax\": true,\n\t\t\"noUncheckedIndexedAccess\": true,\n\t\t\"noUncheckedSideEffectImports\": true,\n\t\t\"exactOptionalPropertyTypes\": true,\n\t\t\"noUnusedLocals\": true,\n\t\t\"noUnusedParameters\": true,\n\t\t\"noImplicitOverride\": true,\n\t\t\"noFallthroughCasesInSwitch\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"noEmit\": true,\n{{paths}}\n\t},\n\t\"exclude\": [\"node_modules\", \"dist\", \"tmp\"]\n}\n";
1581
- vite: "{{journey}}import type { PluginOption, UserConfig } from 'vite'\nimport { mergeConfig } from 'vite'\n{{imports}}import { defineConfig } from 'vitest/config'\nimport manifest from './package.json' with { type: 'json' }\nimport tsconfig from './tsconfig.json' with { type: 'json' }\n{{helpers}}{{browsers}}import { fileURLToPath, URL } from 'node:url'\n\n{{options}}export function resolveWorkspacePath(relativePath: string): string {\n\treturn fileURLToPath(new URL(relativePath, import.meta.url))\n}\n\nconst peerDependencies = 'peerDependencies' in manifest ? manifest.peerDependencies : undefined\nif (\n\tpeerDependencies !== undefined &&\n\t(typeof peerDependencies !== 'object' ||\n\t\tpeerDependencies === null ||\n\t\tArray.isArray(peerDependencies))\n) {\n\tthrow new Error('package peerDependencies must be an object')\n}\nexport const peers: readonly string[] =\n\tpeerDependencies === undefined ? [] : Object.keys(peerDependencies)\n\nconst resolve = {\n\talias: Object.fromEntries(\n\t\tObject.entries(tsconfig.compilerOptions.paths).map(([key, values]) => {\n\t\t\tconst [path] = values\n\t\t\tif (path === undefined) throw new Error('tsconfig path alias ' + key + ' has no target')\n\t\t\treturn [key, resolveWorkspacePath(path)]\n\t\t}),\n\t),\n}\n\n// Merges a caller's override onto the configuration a factory declares, so a\n// package's own configuration reaches the factory through its parameter instead of\n// wrapping the call from outside.\n//\n// Vitest calls every registered project factory with its own invocation record —\n// `command`, `mode`, `isSsrBuild`, `isPreview` — so a factory that also takes an\n// override receives that record in the same position. A `UserConfig` declares `mode`\n// but not `command`, and the invocation record always carries both, so a value\n// carrying the pair is that record rather than an override. The merge returns the\n// base in the record's `mode` and carries none of the record's other fields. Vitest\n// runs a project that declares no `mode` in its own run mode, `test`, rather than in\n// the `--mode` value it was invoked with, so a distribution proof run with\n// `--mode release` would read `test` and skip where it must fail. A record whose\n// `mode` is not a string throws. The `tests/config.test.ts` file drives every\n// registered factory through it.\n//\n// `mergeConfig` concatenates arrays, so an override carrying `plugins` would otherwise\n// add a second copy of a plugin the base already declares. Only named top-level\n// objects replace a base plugin of the same name, in the base's position, and one\n// override entry is taken at most once. An entry no base position took appends in its\n// written order; the caller's own entries never merge with each other. Nested arrays,\n// promises, falsy entries, and anonymous objects pass through unchanged. An override\n// cannot remove a base plugin. Every key other than `plugins` merges as `mergeConfig`\n// merges it, so an override's arrays elsewhere concatenate with the base's rather than\n// replacing them.\nexport function mergeOverride(base: UserConfig, override?: UserConfig): UserConfig {\n\tif (\n\t\toverride !== undefined &&\n\t\t'command' in override &&\n\t\t'mode' in override &&\n\t\ttypeof override.mode !== 'string'\n\t) {\n\t\tthrow new Error('The project invocation carries no string mode')\n\t}\n\tconst effective: UserConfig | undefined =\n\t\toverride !== undefined && 'command' in override && typeof override.mode === 'string'\n\t\t\t? { mode: override.mode }\n\t\t\t: override\n\tconst merged: UserConfig = effective === undefined ? { ...base } : mergeConfig(base, effective)\n\tconst name = merged.test?.name\n\tconst label = typeof name === 'string' ? name : name?.label\n\tconst browser = merged.test?.browser\n\tconst named: UserConfig =\n\t\tlabel !== undefined && browser?.instances !== undefined\n\t\t\t? {\n\t\t\t\t\t...merged,\n\t\t\t\t\ttest: {\n\t\t\t\t\t\t...merged.test,\n\t\t\t\t\t\tbrowser: {\n\t\t\t\t\t\t\t...browser,\n\t\t\t\t\t\t\tinstances: browser.instances.map((instance) => ({\n\t\t\t\t\t\t\t\t...instance,\n\t\t\t\t\t\t\t\tname: instance.name ?? `${label} (${instance.browser})`,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: merged\n\tif (named.plugins === undefined || effective === undefined) return named\n\tconst candidates = [...(effective.plugins ?? [])]\n\tconst bases = [...(base.plugins ?? [])]\n\t// A base plugin takes the first candidate of its own name that no earlier base plugin took, and\n\t// candidates of other names never compete for it, so its pick is the candidate whose rank among\n\t// its name equals the number of earlier base plugins sharing that name.\n\tconst chosen = bases.map((plugin, position) =>\n\t\tisNamedPlugin(plugin)\n\t\t\t? candidates\n\t\t\t\t\t.flatMap((candidate, index) =>\n\t\t\t\t\t\tisNamedPlugin(candidate) && candidate.name === plugin.name ? [index] : [],\n\t\t\t\t\t)\n\t\t\t\t\t.at(\n\t\t\t\t\t\tbases\n\t\t\t\t\t\t\t.slice(0, position)\n\t\t\t\t\t\t\t.filter((earlier) => isNamedPlugin(earlier) && earlier.name === plugin.name).length,\n\t\t\t\t\t)\n\t\t\t: undefined,\n\t)\n\treturn {\n\t\t...named,\n\t\tplugins: [\n\t\t\t...bases.map((plugin, position) => {\n\t\t\t\tconst index = chosen[position]\n\t\t\t\treturn index === undefined ? plugin : (candidates[index] ?? plugin)\n\t\t\t}),\n\t\t\t...candidates.filter((_, index) => !chosen.includes(index)),\n\t\t],\n\t}\n}\n\nfunction isNamedPlugin(plugin: PluginOption): plugin is { name: string } {\n\treturn (\n\t\ttypeof plugin === 'object' &&\n\t\tplugin !== null &&\n\t\t!Array.isArray(plugin) &&\n\t\t!('then' in plugin && typeof plugin.then === 'function') &&\n\t\t'name' in plugin &&\n\t\ttypeof plugin.name === 'string'\n\t)\n}\n\n{{factories}}export default defineConfig({\n\tresolve,\n\ttest: {\n\t\t// Vitest 5.0.5 hands cached code to the module runner as bytes, which breaks stack mapping.\n\t\tfsModuleCache: false,\n{{projects}}\n\t},\n})\n";
1582
- }>;
1583
- factories: Readonly<{
1584
- sheet: "export function sheetProject(name: string, override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\toptimizeDeps,\n\t\tpublicDir: false,\n\t\ttest: {\n\t\t\tname: { label: name, color: 'magenta' },\n\t\t\troot: resolveWorkspacePath('.'),\n\t\t\tisolate: false,\n\t\t\tsetupFiles: [\n\t\t\t\t'./tests/setup.ts',\n\t\t\t\t'./tests/setupBrowser.ts',\n\t\t\t\t...(existsSync(resolveWorkspacePath('tests/setupStyles.ts'))\n\t\t\t\t\t? ['./tests/setupStyles.ts']\n\t\t\t\t\t: []),\n\t\t\t],\n\t\t\tbrowser: {\n\t\t\t\tenabled: true,\n\t\t\t\tprovider: playwright(browserOptions),\n\t\t\t\tcommands,\n\t\t\t\tinstances: [{ browser: 'chromium', headless: true }],\n\t\t\t},\n\t\t\tfileParallelism: false,\n\t\t\tsequence: { groupOrder: 1 },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1585
- src: Readonly<{
1586
- core: "export function srcCore(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\tpublicDir: false,\n\t\tbuild: {\n\t\t\temptyOutDir: true,\n\t\t\tsourcemap: true,\n\t\t\tminify: false,\n\t\t\trolldownOptions: { onLog: enforceBuildLog },\n\t\t},\n\t\ttest: {\n\t\t\tname: { label: 'src:core', color: 'magenta' },\n\t\t\tinclude: ['tests/src/core/**/*.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1587
- vue: "function resolveVueFilename(): string {\n\treturn 'index.js'\n}\n\nexport function srcVue(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\toptimizeDeps: { include: [...optimizeDeps.include, 'vue'] },\n\t\tpublicDir: false,\n\t\tplugins: [outputBoundary('dist/src/vue'), environmentBoundary('src/vue'), vue()],\n\t\tbuild: {\n\t\t\temptyOutDir: true,\n\t\t\tsourcemap: true,\n\t\t\tminify: false,\n\t\t\tlib: {\n\t\t\t\tentry: resolveWorkspacePath('src/vue/index.ts'),\n\t\t\t\tformats: ['es'],\n\t\t\t\tfileName: resolveVueFilename,\n\t\t\t},\n\t\t\toutDir: 'dist/src/vue',\n\t\t\trolldownOptions: { onLog: enforceBuildLog },\n\t\t},\n\t\ttest: {\n\t\t\tname: { label: 'src:vue', color: 'green' },\n\t\t\tinclude: ['tests/src/vue/**/*.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],\n\t\t\tbrowser: {\n\t\t\t\tenabled: true,\n\t\t\t\tprovider: playwright(browserOptions),\n\t\t\t\tcommands,\n\t\t\t\tinstances: [{ browser: 'chromium', headless: true }],\n\t\t\t},\n\t\t\tfileParallelism: false,\n\t\t\tsequence: { groupOrder: 1 },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1588
- browser: "function resolveBrowserFilename(): string {\n\treturn 'index.js'\n}\n\nexport function srcBrowser(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\toptimizeDeps,\n\t\tpublicDir: false,\n\t\tplugins: [outputBoundary('dist/src/browser'), environmentBoundary('src/browser')],\n\t\tbuild: {\n\t\t\temptyOutDir: true,\n\t\t\tsourcemap: true,\n\t\t\tminify: false,\n\t\t\tlib: {\n\t\t\t\tentry: resolveWorkspacePath('src/browser/index.ts'),\n\t\t\t\tformats: ['es'],\n\t\t\t\tfileName: resolveBrowserFilename,\n\t\t\t},\n\t\t\toutDir: 'dist/src/browser',\n\t\t\trolldownOptions: {\n\t\t\t\tonLog: enforceBuildLog,\n\t\t\t\t{{external}}\n{{output}}\n\t\t\t},\n\t\t},\n\t\ttest: {\n\t\t\tname: { label: 'src:browser', color: 'yellow' },\n\t\t\tinclude: ['tests/src/browser/**/*.test.ts'],\n{{exclude}}\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],\n{{global}}\n\t\t\tbrowser: {\n\t\t\t\tenabled: true,\n\t\t\t\tprovider: playwright(browserOptions),\n\t\t\t\tcommands,\n\t\t\t\tinstances: [{ browser: 'chromium', headless: true }],\n\t\t\t},\n\t\t\tfileParallelism: false,\n\t\t\tsequence: { groupOrder: 1 },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1589
- server: "function resolveServerFilename(format: string): string {\n\treturn format === 'es' ? 'index.js' : 'index.cjs'\n}\n\nexport function srcServer(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\tpublicDir: false,\n\t\tplugins: [outputBoundary('dist/src/server'), environmentBoundary('src/server')],\n\t\tbuild: {\n\t\t\temptyOutDir: true,\n\t\t\tsourcemap: true,\n\t\t\tminify: false,\n\t\t\tlib: {\n\t\t\t\tentry: resolveWorkspacePath('src/server/index.ts'),\n\t\t\t\tformats: ['es', 'cjs'],\n\t\t\t\tfileName: resolveServerFilename,\n\t\t\t},\n\t\t\toutDir: 'dist/src/server',\n\t\t\ttarget: 'node22',\n\t\t\trolldownOptions: {\n\t\t\t\tonLog: enforceBuildLog,\n\t\t\t\tplatform: 'node',\n\t\t\t\t{{external}}\n{{output}}\n\t\t\t},\n\t\t},\n\t\ttest: {\n\t\t\tname: { label: 'src:server', color: 'red' },\n\t\t\tinclude: ['tests/src/server/**/*.test.ts'],\n{{exclude}}\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupServer.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1590
- bin: "function resolveBinFilename(): string {\n\treturn 'main.js'\n}\n\nfunction resolveBinExternal(id: string): boolean {\n\treturn id.startsWith('@src/') || resolveExternal(id, { peers, refused: [], siblings: [] })\n}\n\nexport function srcBin(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\tpublicDir: false,\n\t\tplugins: [outputBoundary('dist/bin')],\n\t\tbuild: {\n\t\t\temptyOutDir: true,\n\t\t\tsourcemap: true,\n\t\t\tminify: false,\n\t\t\tlib: {\n\t\t\t\tentry: resolveWorkspacePath('src/bin/main.ts'),\n\t\t\t\tformats: ['es'],\n\t\t\t\tfileName: resolveBinFilename,\n\t\t\t},\n\t\t\toutDir: 'dist/bin',\n\t\t\ttarget: 'node22',\n\t\t\trolldownOptions: {\n\t\t\t\tonLog: enforceBuildLog,\n\t\t\t\texternal: resolveBinExternal,\n\t\t\t},\n\t\t},\n\t\ttest: {\n\t\t\tname: { label: 'src:bin', color: 'yellow' },\n\t\t\tinclude: ['tests/src/bin/**/*.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupServer.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t\t// A bin test drives the real executable over a real temporary repository, so it\n\t\t\t// spends seconds in process startup and filesystem work rather than milliseconds.\n\t\t\t// Vitest's five-second default clears one alone and times out under a full suite.\n\t\t\ttestTimeout: 15_000,\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1591
- }>;
1592
- app: Readonly<{
1593
- core: "export function appCore(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\tpublicDir: false,\n\t\tplugins: [environmentBoundary('app/core')],\n\t\ttest: {\n\t\t\tname: { label: 'app:core', color: 'cyan' },\n\t\t\tinclude: ['tests/app/core/**/*.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1594
- browser: "export function appBrowser(override?: UserConfig): UserConfig {\n\tconst output = 'dist/app/browser'\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\toptimizeDeps,\n\t\tplugins: [outputBoundary(output), environmentBoundary('app/browser')],\n\t\troot: resolveWorkspacePath('app/browser'),\n\t\tpublicDir: false,\n\t\tbuild: {\n\t\t\tassetsInlineLimit: 0,\n\t\t\temptyOutDir: true,\n\t\t\toutDir: resolveWorkspacePath(output),\n\t\t\trolldownOptions: {\n\t\t\t\tonLog: enforceBuildLog,\n\t\t\t\tinput: resolveWorkspacePath('app/browser/index.html'),\n\t\t\t},\n\t\t},\n\t\ttest: {\n\t\t\tname: { label: 'app:browser', color: 'blue' },\n\t\t\troot: resolveWorkspacePath('.'),\n\t\t\tdir: resolveWorkspacePath('.'),\n\t\t\tinclude: ['tests/app/browser/**/*.test.ts'],\n{{journeyExclude}}\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],\n\t\t\tbrowser: {\n\t\t\t\tenabled: true,\n\t\t\t\tprovider: playwright(browserOptions),\n\t\t\t\tcommands,\n\t\t\t\tinstances: [{ browser: 'chromium', headless: true }],\n\t\t\t},\n\t\t\tfileParallelism: false,\n\t\t\tsequence: { groupOrder: 1 },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n{{showcaseFactory}}{{journeyFactory}}";
1595
- vue: "export function appVue(override?: UserConfig): UserConfig {\n\tconst output = 'dist/app/vue'\n\tconst browser = appBrowser()\n\tconst project: UserConfig = {\n\t\t...browser,\n\t\toptimizeDeps: { include: [...optimizeDeps.include, 'vue'] },\n\t\tplugins: [outputBoundary(output), environmentBoundary('app/vue'), vue()],\n\t\troot: resolveWorkspacePath('app/vue'),\n\t\tbuild: {\n\t\t\t...browser.build,\n\t\t\toutDir: resolveWorkspacePath(output),\n\t\t\trolldownOptions: {\n\t\t\t\t...browser.build?.rolldownOptions,\n\t\t\t\tinput: resolveWorkspacePath('app/vue/index.html'),\n\t\t\t},\n\t\t},\n\t\ttest: {\n\t\t\t...browser.test,\n\t\t\tname: { label: 'app:vue', color: 'magenta' },\n\t\t\tbrowser: {\n\t\t\t\t...browser.test?.browser,\n\t\t\t\tinstances: (browser.test?.browser?.instances ?? []).map(\n\t\t\t\t\t({ name: _name, ...instance }) => instance,\n\t\t\t\t),\n\t\t\t},\n\t\t\tinclude: ['tests/app/vue/**/*.test.ts'],\n{{journeyExclude}}\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1596
- journey: "\n// Replace the journey fields directly: merging would concatenate the ordinary include\n// and retain the exclusion of the journey suite.\nexport function appJourney(\n\tvariant: JourneyVariant,\n\tvariants: readonly JourneyVariant[],\n\tmode?: string,\n\toverride?: UserConfig,\n): UserConfig {\n\tconst application = resolveApplication(mode, applications)\n\tconst browser = applications[application]()\n\tconst project: UserConfig = {\n\t\t...browser,\n\t\ttest: {\n\t\t\t...browser.test,\n\t\t\tname: { label: `journey:${variant.name}`, color: 'green' },\n\t\t\tinclude: [`tests/app/${application}/integration.test.ts`],\n\t\t\texclude: [],\n\t\t\tprovide: { variant: variant.name, variants, capture },\n\t\t\tbrowser: {\n\t\t\t\t...browser.test?.browser,\n\t\t\t\tenabled: true,\n\t\t\t\t// The runner UI CSS-scales the tester iframe, which scales observer root bounds and margins.\n\t\t\t\tui: false,\n\t\t\t\tviewport: { width: variant.width, height: variant.height },\n\t\t\t\tinstances: (browser.test?.browser?.instances ?? []).map(\n\t\t\t\t\t({ name: _name, ...instance }) => instance,\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1597
- showcase: "\nconst showcaseStamp: PluginOption = {\n\tname: 'orkestrel-showcase-html',\n\tenforce: 'post',\n\tgenerateBundle(_, bundle) {\n\t\tfor (const file of Object.values(bundle)) {\n\t\t\tif (\n\t\t\t\tfile.type === 'asset' &&\n\t\t\t\ttypeof file.source === 'string' &&\n\t\t\t\tfile.fileName.endsWith('.html')\n\t\t\t) {\n\t\t\t\tfile.source = stampPage(file.source)\n\t\t\t}\n\t\t}\n\t},\n}\n\nfunction createShowcaseNaming(application: string): PluginOption {\n\treturn {\n\t\tname: 'orkestrel-showcase-name',\n\t\tenforce: 'post',\n\t\twriteBundle(options) {\n\t\t\tif (options.dir === undefined) throw new Error('The showcase output is absent.')\n\t\t\trenameSync(\n\t\t\t\tresolvePath(options.dir, 'index.html'),\n\t\t\t\tresolvePath(options.dir, application + '.html'),\n\t\t\t)\n\t\t},\n\t}\n}\n\nexport function appShowcase(mode: string, override?: UserConfig): UserConfig {\n\tconst application = resolveApplication(mode, applications)\n\tconst output = 'showcase'\n\tconst showcase: UserConfig = {\n\t\tplugins: [\n\t\t\toutputBoundary(output),\n\t\t\tviteSingleFile({\n\t\t\t\tremoveViteModuleLoader: true,\n\t\t\t\tuseRecommendedBuildConfig: true,\n\t\t\t}),\n\t\t\tshowcaseStamp,\n\t\t\tcreateShowcaseNaming(application),\n\t\t],\n\t\tbuild: {\n\t\t\t// The `appBrowser` factory sets `assetsInlineLimit` to 0, so every asset becomes\n\t\t\t// its own file, and 4096 is Vite's own default put back. The `viteSingleFile`\n\t\t\t// plugin overwrites the value while the `useRecommendedBuildConfig` option stays\n\t\t\t// true, so this line takes effect only in a workspace that turns that option off.\n\t\t\tassetsInlineLimit: 4096,\n\t\t\tcssMinify: 'lightningcss',\n\t\t\temptyOutDir: false,\n\t\t\tminify: 'oxc',\n\t\t\tmodulePreload: false,\n\t\t\toutDir: resolveWorkspacePath(output),\n\t\t\treportCompressedSize: false,\n\t\t\tsourcemap: false,\n\t\t\ttarget: 'esnext',\n\t\t},\n\t}\n\treturn applications[application](mergeOverride(showcase, override))\n}\n";
1598
- server: "function resolveAppFilename(): string {\n\treturn 'main.cjs'\n}\n\nfunction resolveAppExternal(id: string): boolean {\n\treturn id.startsWith('node:')\n}\n\nexport function appServer(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\tpublicDir: false,\n\t\tplugins: [outputBoundary('dist/app/server'), environmentBoundary('app/server')],\n\t\tbuild: {\n\t\t\temptyOutDir: true,\n\t\t\tlib: {\n\t\t\t\tentry: resolveWorkspacePath('app/server/main.ts'),\n\t\t\t\tformats: ['cjs'],\n\t\t\t\tfileName: resolveAppFilename,\n\t\t\t},\n\t\t\toutDir: resolveWorkspacePath('dist/app/server'),\n\t\t\ttarget: 'node22',\n\t\t\trolldownOptions: {\n\t\t\t\tonLog: enforceBuildLog,\n\t\t\t\texternal: resolveAppExternal,\n\t\t\t},\n\t\t},\n\t\ttest: {\n\t\t\tname: { label: 'app:server', color: 'green' },\n\t\t\tinclude: ['tests/app/server/**/*.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupServer.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t},\n\t}\n\t// Fills the missing codeSplitting of each merged output with false and adds no output,\n\t// so an override's output list keeps its own members and their order. A member that\n\t// already supplies a value is returned as written, found by property lookup, so a value\n\t// an inherited getter supplies survives.\n\tconst merged = mergeOverride(project, override)\n\tconst rolldown = merged.build?.rolldownOptions\n\tconst output = rolldown?.output\n\tconst unsplit = { codeSplitting: false }\n\treturn {\n\t\t...merged,\n\t\tbuild: {\n\t\t\t...merged.build,\n\t\t\trolldownOptions: {\n\t\t\t\t...rolldown,\n\t\t\t\toutput: Array.isArray(output)\n\t\t\t\t\t? output.map((member) =>\n\t\t\t\t\t\t\tmember.codeSplitting === undefined ? { ...member, ...unsplit } : member,\n\t\t\t\t\t\t)\n\t\t\t\t\t: output?.codeSplitting === undefined\n\t\t\t\t\t\t? { ...output, ...unsplit }\n\t\t\t\t\t\t: output,\n\t\t\t},\n\t\t},\n\t}\n}\n";
1599
- }>;
1600
- policy: "export function policy(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'policy', color: 'white' },\n\t\t\tinclude: ['tests/policy.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1601
- config: "export function config(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'config', color: 'yellow' },\n\t\t\tinclude: ['tests/config.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t\t// A config test validates every target wrapper, spawns the real linter twice under\n\t\t\t// 15-second child caps, and rolls one face up through the compiler and the extractor it\n\t\t\t// spawns, so this budget clears the capped pair with room for a contended host.\n\t\t\ttestTimeout: 60_000,\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1602
- setup: "export function setup(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'setup', color: 'white' },\n\t\t\tinclude: ['tests/setup*.test.ts'],\n\t\t\texclude: ['tests/setupBrowser.test.ts', 'tests/setupStyles.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tpool: 'threads',\n\t\t\tisolate: false,\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1603
- browser: "export function setupBrowser(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\t{{optimization}},\n{{plugins}}\t\ttest: {\n\t\t\tname: { label: 'setup:browser', color: 'blue' },\n\t\t\tinclude: ['tests/setupBrowser.test.ts', 'tests/setupStyles.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],\n{{global}}\t\t\tbrowser: {\n\t\t\t\tenabled: true,\n\t\t\t\tprovider: playwright(browserOptions),\n\t\t\t\tcommands,\n\t\t\t\tinstances: [{ browser: 'chromium', headless: true }],\n\t\t\t},\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1604
- guides: "export function guides(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'guides', color: 'green' },\n\t\t\tinclude: ['tests/guides.test.ts'],\n\t\t\texclude: ['tests/src/**/*.test.ts', 'tests/app/**/*.test.ts', 'tests/setup.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1605
- skills: "// The skill scripts this package ships as canon, each driven as a child process against a\n// scratch fixture from its mirrored proof under `tests/agents/skills/<skill>/scripts/`. The\n// `configs/agents/tsconfig.skills.json` wrapper selects the project.\nexport function skills(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'skills', color: 'blue' },\n\t\t\tinclude: ['tests/agents/**/*.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t\t// Each case spawns node on a script; a census case runs `vitest list` over this checkout.\n\t\t\ttestTimeout: 60_000,\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1606
- tree: "// The laws this package states about its own real tree.\n// Standalone Node proof; reads the tree without a build, install, or service.\nexport function tree(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'tree', color: 'magenta' },\n\t\t\tinclude: ['tests/tree.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupServer.ts'],\n\t\t\tpool: 'threads',\n\t\t\tisolate: false,\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1607
- conformance: "// Where this package drifts from the official tooling it stays compatible with.\n// The subject is this package, so the proof is hermetic and stays in `npm test`.\nexport function conformance(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'conformance', color: 'magenta' },\n\t\t\tinclude: ['tests/conformance.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupServer.ts'],\n\t\t\tpool: 'threads',\n\t\t\tisolate: false,\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1608
- service: "// The caller prepares the live external services before this project.\n// `tests/setupService.ts` verifies readiness, and the project stays out of `npm test`\n// because a real service answers it.\nexport function service(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'service', color: 'red' },\n\t\t\tinclude: ['tests/service/**/*.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts', './tests/setupService.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t\ttestTimeout: 120_000,\n\t\t\thookTimeout: 120_000,\n\t\t\tfileParallelism: false,\n\t\t\tsequence: { groupOrder: 1 },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1609
- studies: "// Run these @orkestrel/study proofs on demand with npm run test:studies; no gate or chain runs them.\nexport function studies(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'studies', color: 'red' },\n\t\t\tinclude: ['tests/studies/**/*.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t\ttestTimeout: 120_000,\n\t\t\thookTimeout: 120_000,\n\t\t\tfileParallelism: false,\n\t\t\tsequence: { groupOrder: 1 },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1610
- distribution: "export function distribution(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'distribution', color: 'cyan' },\n\t\t\tinclude: ['tests/distribution.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tenvironment: 'node',\n\t\t\ttestTimeout: 120_000,\n\t\t\thookTimeout: 120_000,\n\t\t\tfileParallelism: false,\n\t\t\tsequence: { groupOrder: 1 },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1611
- probe: "// A workbench, not a proof. No gate selects this project. Run in test mode by the\n// `test:probe` script, it collects `tmp/probes/**/*.test.ts`. Run in benchmark mode by the\n// `test:bench` script, it collects `*.bench.ts` files under `tmp/probes` and `tests`.\n// Each benchmark is a regular test that uses its context's `bench` fixture and awaits\n// `bench(name, options, fn).run()` or `bench.compare(...)`.\nexport function probe(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'probe', color: 'black' },\n\t\t\tinclude: ['tmp/probes/**/*.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n\t\t\tenvironment: 'node',\n\t\t\tbrowser: { enabled: false },\n\t\t\tfileParallelism: false,\n\t\t\tsequence: { groupOrder: 1 },\n\t\t\tpool: 'threads',\n\t\t\tbenchmark: { include: ['tmp/probes/**/*.bench.ts', 'tests/**/*.bench.ts'] },\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1612
- integration: Readonly<{
1613
- sheet: "export function integration(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\ttest: {\n\t\t\tinclude: ['tests/integration.test.ts'],\n{{global}}\t\t},\n\t}\n\treturn sheetProject('integration', mergeOverride(project, override))\n}\n";
1614
- module: "export function integration(override?: UserConfig): UserConfig {\n\tconst project: UserConfig = {\n\t\tresolve,\n\t\ttest: {\n\t\t\tname: { label: 'integration', color: 'blue' },\n\t\t\tinclude: ['tests/integration.test.ts'],\n\t\t\tsetupFiles: ['./tests/setup.ts'],\n{{global}}\t\t\tenvironment: 'node',\n\t\t},\n\t}\n\treturn mergeOverride(project, override)\n}\n";
1615
- }>;
1616
- }>;
1617
- tsconfigs: Readonly<{
1618
- vue: Readonly<{
1619
- src: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\", \"DOM\", \"DOM.Iterable\"],\n\t\t\"types\": [\"vite/client\"],\n\t\t\"noEmit\": false,\n\t\t\"declaration\": true,\n\t\t\"emitDeclarationOnly\": true,\n\t\t\"rootDir\": \"../../src\",\n\t\t\"outDir\": \"../../dist/src\"\n\t},\n\t\"include\": [\n\t\t\"../../src/vue/**/*.cts\",\n\t\t\"../../src/vue/**/*.mts\",\n\t\t\"../../src/vue/**/*.ts\",\n\t\t\"../../src/vue/**/*.tsx\"\n\t]\n}\n";
1620
- app: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\", \"DOM\", \"DOM.Iterable\"],\n\t\t\"types\": [\"vite/client\", \"vue\"]\n\t},\n\t\"include\": [\n{{include}}\n\t]\n}\n";
1621
- }>;
1622
- sheet: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\"],\n\t\t\"types\": [\"vite/client\"],\n\t\t\"noEmit\": true\n\t},\n\t\"include\": [\"../../src/{{name}}/**/*.ts\"]\n}\n";
1623
- src: Readonly<{
1624
- core: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\", \"WebWorker\"],\n\t\t\"types\": [],\n\t\t\"noEmit\": false,\n\t\t\"declaration\": true,\n\t\t\"emitDeclarationOnly\": true,\n\t\t\"rootDir\": \"../../src/core\",\n\t\t\"outDir\": \"../../dist/src/core\"\n\t},\n\t\"include\": [\n\t\t\"../../src/core/**/*.cts\",\n\t\t\"../../src/core/**/*.mts\",\n\t\t\"../../src/core/**/*.ts\",\n\t\t\"../../src/core/**/*.tsx\"\n\t]\n}\n";
1625
- browser: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\", \"DOM\", \"DOM.Iterable\"],\n\t\t\"types\": [\"vite/client\"],\n\t\t\"noEmit\": false,\n\t\t\"declaration\": true,\n\t\t\"emitDeclarationOnly\": true,\n\t\t\"rootDir\": \"../../src\",\n\t\t\"outDir\": \"../../dist/src\"\n\t},\n\t\"include\": [\n\t\t\"../../src/browser/**/*.cts\",\n\t\t\"../../src/browser/**/*.mts\",\n\t\t\"../../src/browser/**/*.ts\",\n\t\t\"../../src/browser/**/*.tsx\"\n\t]\n}\n";
1626
- server: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\"],\n\t\t\"types\": [\"node\"],\n\t\t\"noEmit\": false,\n\t\t\"declaration\": true,\n\t\t\"emitDeclarationOnly\": true,\n\t\t\"rootDir\": \"../../src\",\n\t\t\"outDir\": \"../../dist/src\"\n\t},\n\t\"include\": [\n\t\t\"../../src/server/**/*.cts\",\n\t\t\"../../src/server/**/*.mts\",\n\t\t\"../../src/server/**/*.ts\",\n\t\t\"../../src/server/**/*.tsx\"\n\t]\n}\n";
1627
- }>;
1628
- app: Readonly<{
1629
- core: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\", \"WebWorker\"],\n\t\t\"types\": []\n\t},\n\t\"include\": [\n\t\t\"../../app/core/**/*.cts\",\n\t\t\"../../app/core/**/*.mts\",\n\t\t\"../../app/core/**/*.ts\",\n\t\t\"../../app/core/**/*.tsx\",\n\t\t\"../../tests/app/core/**/*.cts\",\n\t\t\"../../tests/app/core/**/*.mts\",\n\t\t\"../../tests/app/core/**/*.ts\",\n\t\t\"../../tests/app/core/**/*.tsx\",\n\t\t\"../../tests/setup.ts\"\n\t]\n}\n";
1630
- browser: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\", \"DOM\", \"DOM.Iterable\"],\n\t\t\"types\": [\"vite/client\"]\n\t},\n\t\"include\": [\n{{include}}\n\t]\n}\n";
1631
- server: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\"],\n\t\t\"types\": [\"node\"]\n\t},\n\t\"include\": [\n{{include}}\n\t]\n}\n";
1632
- }>;
1633
- bin: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\"],\n\t\t\"types\": [\"node\"],\n\t\t\"noEmit\": false,\n\t\t\"declaration\": true,\n\t\t\"emitDeclarationOnly\": true,\n\t\t\"rootDir\": \"../../src\",\n\t\t\"outDir\": \"../../dist/bin\"\n\t},\n\t\"include\": [\n\t\t\"../../src/bin/**/*.cts\",\n\t\t\"../../src/bin/**/*.mts\",\n\t\t\"../../src/bin/**/*.ts\",\n\t\t\"../../src/bin/**/*.tsx\"\n\t]\n}\n";
1634
- skills: "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"lib\": [\"ESNext\"],\n\t\t\"types\": [\"node\"]\n\t},\n\t\"include\": [\"../../.agents/skills/*/scripts/*.ts\"],\n\t\"exclude\": [\"../../node_modules\"]\n}\n";
1635
- }>;
1636
- vites: Readonly<{
1637
- sheet: "import { defineConfig } from 'vitest/config'\nimport { outputBoundary } from '../helpers.js'\nimport { resolveWorkspacePath, sheetProject } from '../../vite.config.ts'\n\nexport default defineConfig((invocation) => {\n\tconst project = sheetProject('src:{{label}}', {\n\t\tplugins: [outputBoundary('dist/src/{{name}}')],\n\t\tbuild: {\n\t\t\toutDir: 'dist/src/{{name}}',\n\t\t\temptyOutDir: true,\n\t\t\t// Preserve the authored layer-order statement in the published sheet.\n\t\t\tcssMinify: false,\n\t\t\tlib: {\n\t\t\t\tentry: resolveWorkspacePath('src/{{name}}/sheet.ts'),\n\t\t\t\tformats: ['es'],\n\t\t\t\tfileName: 'index',\n\t\t\t\tcssFileName: 'index',\n\t\t\t},\n\t\t},\n\t\ttest: { include: ['tests/src/{{name}}/**/*.test.ts'] },\n\t})\n\treturn { ...project, mode: invocation.mode }\n})\n";
1638
- src: Readonly<{
1639
- core: "import { defineConfig } from 'vite'\nimport {\n\tdeclarationRollup,\n\tenvironmentBoundary,\n\toutputBoundary,\n\tresolveExternal,\n} from '../helpers.js'\nimport { peers, srcCore, resolveWorkspacePath } from '../../vite.config.ts'\n\nexport default defineConfig(\n\tsrcCore({\n\t\tpublicDir: false,\n\t\tplugins: [\n\t\t\toutputBoundary('dist/src/core'),\n\t\t\tenvironmentBoundary('src/core'),\n\t\t\tdeclarationRollup({\n\t\t\t\tproject: resolveWorkspacePath('configs/src/tsconfig.core.json'),\n\t\t\t\ttypes: ['node'],\n\t\t\t}),\n\t\t],\n\t\tbuild: {\n\t\t\tlib: {\n\t\t\t\tentry: resolveWorkspacePath('src/core/index.ts'),\n\t\t\t\tformats: ['es', 'cjs'],\n\t\t\t\tfileName: (format: string) => (format === 'es' ? 'index.js' : 'index.cjs'),\n\t\t\t},\n\t\t\toutDir: 'dist/src/core',\n\t\t\trolldownOptions: {\n\t\t\t\texternal: (id: string) => resolveExternal(id, { peers, refused: [], siblings: [] }),\n\t\t\t},\n\t\t},\n\t}),\n)\n";
1640
- vue: "import { defineConfig } from 'vite'\nimport {\n\tdeclarationRollup,\n\tresolveExternal,\n\trewriteBrowserSpecifier,\n\trewriteCoreSpecifier,\n} from '../helpers.js'\nimport { peers, srcVue, resolveWorkspacePath } from '../../vite.config.ts'\n\nconst siblings = {\n{{siblings}}\n}\n\nexport default defineConfig(\n\tsrcVue({\n\t\tplugins: [\n\t\t\tdeclarationRollup({\n\t\t\t\tproject: resolveWorkspacePath('configs/src/tsconfig.vue.json'),\n\t\t\t\trewrite: (content) => rewriteBrowserSpecifier(rewriteCoreSpecifier(content)),\n\t\t\t}),\n\t\t],\n\t\tbuild: {\n\t\t\trolldownOptions: {\n\t\t\t\texternal: (id: string) =>\n\t\t\t\t\tresolveExternal(id, {\n\t\t\t\t\t\tpeers,\n\t\t\t\t\t\trefused: {{refused}},\n\t\t\t\t\t\tsiblings: Object.keys(siblings),\n\t\t\t\t\t}),\n\t\t\t\toutput: { paths: siblings },\n\t\t\t},\n\t\t},\n\t}),\n)\n";
1641
- browser: "import { defineConfig } from 'vite'\nimport { declarationRollup, rewriteCoreSpecifier } from '../helpers.js'\nimport { srcBrowser, resolveWorkspacePath } from '../../vite.config.ts'\n\n// The roll-up reaches src/core through a specifier the tarball does not carry, so the rewrite\n// externalizes core through the package's own published root export, on the final roll-up alone.\nexport default defineConfig(\n\tsrcBrowser({\n\t\tplugins: [\n\t\t\tdeclarationRollup({\n\t\t\t\tproject: resolveWorkspacePath('configs/src/tsconfig.browser.json'),\n\t\t\t\trewrite: rewriteCoreSpecifier,\n\t\t\t}),\n\t\t],\n\t}),\n)\n";
1642
- server: "import { defineConfig } from 'vite'\nimport { declarationRollup, rewriteCoreSpecifier } from '../helpers.js'\nimport { srcServer, resolveWorkspacePath } from '../../vite.config.ts'\n\n// The roll-up reaches src/core through a specifier the tarball does not carry, so the rewrite\n// externalizes core through the package's own published root export, on the final roll-up alone.\nexport default defineConfig(\n\tsrcServer({\n\t\tplugins: [\n\t\t\tdeclarationRollup({\n\t\t\t\tproject: resolveWorkspacePath('configs/src/tsconfig.server.json'),\n\t\t\t\trewrite: rewriteCoreSpecifier,\n\t\t\t}),\n\t\t],\n\t}),\n)\n";
1643
- }>;
1644
- bin: "import { defineConfig } from 'vite'\nimport { resolveExternal } from '../helpers.js'\nimport { peers, srcBin } from '../../vite.config.ts'\n\n// The `scaffold` executable build — a single ESM lib file, no declarations (an\n// executable ships no types), with the `#!/usr/bin/env node` shebang re-emitted through\n// `output.banner` (rolldown strips shebangs from source during bundling), and\n// `output.paths` rewriting the externalized `@src/*` specifiers to the built sibling\n// src environments (relative to `dist/bin/`), so the emitted bin resolves at runtime.\nexport default defineConfig(\n\tsrcBin({\n\t\tbuild: {\n\t\t\trolldownOptions: {\n\t\t\t\texternal: (id: string) =>\n\t\t\t\t\tid.startsWith('@src/') || resolveExternal(id, { peers, refused: [], siblings: [] }),\n\t\t\t\toutput: {\n\t\t\t\t\tbanner: '#!/usr/bin/env node',\n{{paths}}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}),\n)\n";
1645
- app: Readonly<{
1646
- vue: "import { defineConfig } from 'vite'\nimport { appVue } from '../../vite.config.ts'\n\nexport default defineConfig(appVue())\n";
1647
- browser: "import { defineConfig } from 'vite'\nimport { appBrowser } from '../../vite.config.ts'\n\nexport default defineConfig(appBrowser())\n";
1648
- server: "import { defineConfig } from 'vite'\nimport { appServer } from '../../vite.config.ts'\n\nexport default defineConfig(appServer())\n";
1649
- showcase: "import { defineConfig } from 'vite'\nimport { appShowcase } from '../../vite.config.ts'\n\nexport default defineConfig(({ mode }) => appShowcase(mode))\n";
1650
- journey: "import type { JourneyVariant } from '@orkestrel/test'\nimport { defineConfig } from 'vitest/config'\nimport { appJourney } from '../../vite.config.ts'\n\n// Rename and extend these viewports for the application. Apply themes through its interface.\nconst VARIANTS: readonly JourneyVariant[] = Object.freeze([\n\t{ name: 'desktop', width: 1280, height: 800 },\n\t{ name: 'compact', width: 390, height: 844 },\n])\n\nexport default defineConfig(({ mode }) => ({\n\ttest: {\n\t\tprojects: VARIANTS.map((variant) => () => appJourney(variant, VARIANTS, mode)),\n\t},\n}))\n";
1651
- }>;
1652
- }>;
1653
- browsers: "// A generated browser workspace resolves its own Chromium here rather than in\n// `configs/helpers.ts`, because that leaf is vendored byte-identical to every\n// workspace and most of them declare no `playwright` to import.\n\nimport type { PlaywrightProviderOptions } from '@vitest/browser-playwright'\nimport { chromium } from 'playwright'\nimport { accessSync, constants as FS_CONSTANTS, globSync, readdirSync, statSync } from 'node:fs'\nimport { basename, dirname, join, resolve as resolvePath } from 'node:path'\n\n/**\n * Lists the Chromium executable layouts inside a `chromium-<revision>` browsers-directory\n * entry, per platform.\n *\n * @remarks\n * The current Playwright build ships Chrome for Testing on macOS. The trailing `Chromium.app`\n * layouts are what earlier builds shipped, so the list spans Playwright versions instead of\n * pinning to the installed one.\n */\nexport const CHROMIUM_LAYOUTS = Object.freeze([\n\t'chrome-linux/chrome',\n\t'chrome-linux64/chrome',\n\t'chrome-win/chrome.exe',\n\t'chrome-win64/chrome.exe',\n\t'chrome-mac-x64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing',\n\t'chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing',\n\t'chrome-mac/Chromium.app/Contents/MacOS/Chromium',\n\t'chrome-mac-arm64/Chromium.app/Contents/MacOS/Chromium',\n])\n\n/** Matches the `chromium-<revision>` entry name Playwright installs one managed build into. */\nexport const CHROMIUM_ENTRY_PATTERN = /^chromium-\\d+$/\n\n/** Matches the revision number carried by any path containing a `chromium-<revision>` segment. */\nexport const CHROMIUM_REVISION_PATTERN = /chromium-(\\d+)/\n\n/** Names the directory a managed Linux container installs its bundled Playwright browsers into. */\nexport const BUNDLED_BROWSERS_ROOT = '/opt/pw-browsers'\n\n/**\n * Lists the bundled Chromium layouts under the managed-container browsers root, as glob patterns.\n *\n * @remarks\n * The revision directory and its inner layout both drift across Playwright builds, and the\n * container also carries a top-level `chromium` alias, so every known shape is globbed.\n */\nexport const BUNDLED_CHROMIUM_LAYOUTS = Object.freeze([\n\t'chromium',\n\t'chromium-*/chrome-linux64/chrome',\n\t'chromium-*/chrome-linux/chrome',\n])\n\n/** Lists the stable Playwright Chromium channels and their standard executable layouts. */\nexport const SYSTEM_BROWSER_CHANNELS = Object.freeze([\n\tObject.freeze({\n\t\tchannel: 'chrome',\n\t\tlayouts: Object.freeze({\n\t\t\tlinux: '/opt/google/chrome/chrome',\n\t\t\tdarwin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',\n\t\t\twin32: Object.freeze(['Google', 'Chrome', 'Application', 'chrome.exe']),\n\t\t}),\n\t}),\n\tObject.freeze({\n\t\tchannel: 'msedge',\n\t\tlayouts: Object.freeze({\n\t\t\tlinux: '/opt/microsoft/msedge/msedge',\n\t\t\tdarwin: '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',\n\t\t\twin32: Object.freeze(['Microsoft', 'Edge', 'Application', 'msedge.exe']),\n\t\t}),\n\t}),\n])\n\n/**\n * Determines whether a path identifies an executable regular file.\n *\n * @param path - The filesystem path to inspect.\n * @returns True if the path is a regular file with execute access; false otherwise.\n *\n * @example\n * ```ts\n * isBrowserExecutable('/opt/google/chrome/chrome')\n * ```\n */\nexport function isBrowserExecutable(path: string): boolean {\n\ttry {\n\t\tif (!statSync(path).isFile()) return false\n\t\taccessSync(path, FS_CONSTANTS.X_OK)\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/**\n * Orders two Chromium paths so the highest revision sorts first.\n *\n * @param left - The first path or directory entry to compare.\n * @param right - The second path or directory entry to compare.\n * @returns A negative number when `left` sorts first, positive when `right` does.\n *\n * @remarks\n * Revisions are numbers, so `chromium-1200` outranks `chromium-999` despite sorting below it\n * lexically. A path carrying no revision falls back to descending name order.\n *\n * @example\n * ```ts\n * ['chromium-999', 'chromium-1200'].sort(compareRevisions)\n * ```\n */\nexport function compareRevisions(left: string, right: string): number {\n\tconst leftRevision = CHROMIUM_REVISION_PATTERN.exec(left)?.[1]\n\tconst rightRevision = CHROMIUM_REVISION_PATTERN.exec(right)?.[1]\n\tif (leftRevision === undefined || rightRevision === undefined) return right.localeCompare(left)\n\treturn Number(rightRevision) - Number(leftRevision)\n}\n\n/**\n * Reads the executable path of Playwright's pinned Chromium revision.\n *\n * @returns The pinned executable path, or `undefined` when this platform has none.\n *\n * @remarks\n * Playwright throws rather than returning a path when the current platform carries no initialized\n * executable, and an unguarded call would fail configuration evaluation for every project.\n *\n * @example\n * ```ts\n * resolvePinnedBrowser()\n * ```\n */\nexport function resolvePinnedBrowser(): string | undefined {\n\ttry {\n\t\tconst pinned = chromium.executablePath()\n\t\treturn pinned.length === 0 ? undefined : pinned\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/**\n * Resolves a launchable Playwright-managed Chromium executable: the pinned revision when installed,\n * otherwise a `chromium` / `chromium.exe` alias or any other `chromium-*` revision under the same\n * Playwright browsers directory. A pinned-revision miss is not Chromium absence — managed\n * containers ship one usable build, often behind a revision-agnostic alias, for many Playwright\n * versions.\n *\n * @param pinned - The executable path for Playwright's pinned Chromium revision.\n * @returns The managed executable path, or `undefined` when none is executable.\n *\n * @example\n * ```ts\n * resolveManagedBrowser('/root/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome')\n * ```\n */\nexport function resolveManagedBrowser(pinned: string): string | undefined {\n\tif (isBrowserExecutable(pinned)) return pinned\n\t// One `dirname` per path segment reaches the root from any path, and the nearest\n\t// ancestor named `chromium-<revision>` is the revision directory this build sits in.\n\tconst directory = dirname(pinned)\n\tconst ancestors = directory\n\t\t.split(/[\\\\/]/u)\n\t\t.reduce<string[]>((chain) => [...chain, dirname(chain.at(-1) ?? directory)], [directory])\n\tconst revisionRoot = ancestors.find((ancestor) => CHROMIUM_ENTRY_PATTERN.test(basename(ancestor)))\n\tif (revisionRoot === undefined) return undefined\n\tconst browsersRoot = dirname(revisionRoot)\n\tfor (const alias of ['chromium', 'chromium.exe']) {\n\t\tconst candidate = resolvePath(browsersRoot, alias)\n\t\tif (isBrowserExecutable(candidate)) return candidate\n\t}\n\ttry {\n\t\tconst revisions = readdirSync(browsersRoot)\n\t\t\t.filter((entry) => CHROMIUM_ENTRY_PATTERN.test(entry))\n\t\t\t.sort(compareRevisions)\n\t\tfor (const revision of revisions) {\n\t\t\tfor (const layout of CHROMIUM_LAYOUTS) {\n\t\t\t\tconst candidate = resolvePath(browsersRoot, revision, layout)\n\t\t\t\tif (isBrowserExecutable(candidate)) return candidate\n\t\t\t}\n\t\t}\n\t\treturn undefined\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/**\n * Resolves the Chromium a managed Linux container bundles outside the Playwright cache.\n *\n * @param platform - The Node platform the container runs on.\n * @param root - The bundled browsers directory to search.\n * @returns The highest matching executable path, or `undefined` when none is executable.\n *\n * @example\n * ```ts\n * resolveBundledBrowser('linux', BUNDLED_BROWSERS_ROOT)\n * ```\n */\nexport function resolveBundledBrowser(platform: NodeJS.Platform, root: string): string | undefined {\n\tif (platform !== 'linux') return undefined\n\tfor (const layout of BUNDLED_CHROMIUM_LAYOUTS) {\n\t\ttry {\n\t\t\tfor (const match of globSync(layout, { cwd: root }).sort(compareRevisions)) {\n\t\t\t\tconst candidate = resolvePath(root, match)\n\t\t\t\tif (isBrowserExecutable(candidate)) return candidate\n\t\t\t}\n\t\t} catch {\n\t\t\treturn undefined\n\t\t}\n\t}\n\treturn undefined\n}\n\n/**\n * Resolves the first installed stable system Chromium channel.\n *\n * @param platform - The Node platform whose standard layouts this call probes.\n * @param environment - The process environment supplying Windows installation roots.\n * @returns `chrome`, then `msedge`, or `undefined` when neither is executable.\n *\n * @example\n * ```ts\n * resolveSystemBrowser(process.platform, process.env)\n * ```\n */\nexport function resolveSystemBrowser(\n\tplatform: NodeJS.Platform,\n\tenvironment: NodeJS.ProcessEnv,\n): string | undefined {\n\tif (platform !== 'linux' && platform !== 'darwin' && platform !== 'win32') return undefined\n\tconst roots = new Set(\n\t\tplatform === 'win32'\n\t\t\t? [\n\t\t\t\t\t...[\n\t\t\t\t\t\tenvironment.LOCALAPPDATA,\n\t\t\t\t\t\tenvironment.PROGRAMFILES,\n\t\t\t\t\t\tenvironment['PROGRAMFILES(X86)'],\n\t\t\t\t\t].flatMap((root) => (root !== undefined && root.length > 0 ? [root] : [])),\n\t\t\t\t\t...[environment.HOMEDRIVE].flatMap((homeDrive) =>\n\t\t\t\t\t\thomeDrive !== undefined && homeDrive.length > 0\n\t\t\t\t\t\t\t? [join(homeDrive, 'Program Files'), join(homeDrive, 'Program Files (x86)')]\n\t\t\t\t\t\t\t: [],\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: [],\n\t)\n\tfor (const browser of SYSTEM_BROWSER_CHANNELS) {\n\t\tif (platform === 'win32') {\n\t\t\tfor (const root of roots) {\n\t\t\t\tif (isBrowserExecutable(join(root, ...browser.layouts.win32))) return browser.channel\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif (isBrowserExecutable(browser.layouts[platform])) return browser.channel\n\t}\n\treturn undefined\n}\n\n/**\n * Resolves Playwright provider options for Chromium on this host.\n *\n * @param pinned - The executable path for Playwright's pinned Chromium revision, when it has one.\n * @param platform - The Node platform whose standard layouts this call probes.\n * @param environment - The process environment supplying operator overrides and Windows roots.\n * @param root - The managed-container bundled browsers directory to search.\n * @returns Provider options naming an executable, a WebSocket endpoint, or a channel.\n *\n * @remarks\n * Precedence, most important first: `PLAYWRIGHT_EXECUTABLE_PATH`, `PLAYWRIGHT_WS_ENDPOINT`,\n * `PLAYWRIGHT_CHANNEL`, the managed Playwright Chromium, the container's bundled Chromium, a\n * verified system channel, then the platform default channel. An operator override outranks\n * discovery and is returned exactly as given: none of those environment values is checked\n * against the filesystem, because verifying an override would defeat the override. The pinned\n * managed revision outranks anything found on the host because it is deterministic. Every resolved\n * managed path names the full Chromium executable so headless launches retain browser permissions.\n * Only a discovered system channel is verified before it is named. The platform default is\n * unverified as well and exists only as a last resort: Windows takes `msedge`, which ships with the\n * OS and never collides with a foreground Chrome.\n *\n * Set `PLAYWRIGHT_SCROLLBARS=classic` only for runs that measure scrollbar compensation, never\n * for a standing gate. Every Chromium launch in that run omits Playwright's `--hide-scrollbars`\n * default argument so classic scrollbars can take layout space in every case. An empty or unset\n * value preserves the launch defaults; any other value throws an `Error`. Pairing `classic`\n * with `PLAYWRIGHT_WS_ENDPOINT` throws an `Error`, even with an executable override, because the\n * server owns the launch.\n *\n * The resolver and the gate cover Chromium alone. Reopen engine selection when another\n * Playwright engine is installed and launches on the host with a `captureFrame` reading\n * back at its declared size, or when a journey or style divergence is recorded.\n *\n * @example\n * ```ts\n * resolveBrowser(resolvePinnedBrowser(), process.platform, process.env)\n * ```\n */\nexport function resolveBrowser(\n\tpinned: string | undefined,\n\tplatform: NodeJS.Platform,\n\tenvironment: NodeJS.ProcessEnv,\n\troot: string = BUNDLED_BROWSERS_ROOT,\n): PlaywrightProviderOptions {\n\tconst scrollbars = environment.PLAYWRIGHT_SCROLLBARS\n\tif (scrollbars !== undefined && scrollbars.length > 0 && scrollbars !== 'classic') {\n\t\tthrow new Error('PLAYWRIGHT_SCROLLBARS must be classic or empty')\n\t}\n\tconst endpoint = environment.PLAYWRIGHT_WS_ENDPOINT\n\tif (scrollbars === 'classic' && endpoint !== undefined && endpoint.length > 0) {\n\t\tthrow new Error('PLAYWRIGHT_SCROLLBARS=classic cannot be used with PLAYWRIGHT_WS_ENDPOINT')\n\t}\n\tconst launch: PlaywrightProviderOptions['launchOptions'] =\n\t\tscrollbars === 'classic' ? { ignoreDefaultArgs: ['--hide-scrollbars'] } : {}\n\tconst executable = environment.PLAYWRIGHT_EXECUTABLE_PATH\n\tif (executable !== undefined && executable.length > 0) {\n\t\treturn { launchOptions: { executablePath: executable, ...launch } }\n\t}\n\tif (endpoint !== undefined && endpoint.length > 0) {\n\t\treturn { connectOptions: { wsEndpoint: endpoint } }\n\t}\n\tconst requested = environment.PLAYWRIGHT_CHANNEL\n\tif (requested !== undefined && requested.length > 0) {\n\t\treturn { launchOptions: { channel: requested, ...launch } }\n\t}\n\tconst managed = pinned === undefined ? undefined : resolveManagedBrowser(pinned)\n\tif (managed !== undefined) {\n\t\treturn { launchOptions: { executablePath: managed, ...launch } }\n\t}\n\tconst bundled = resolveBundledBrowser(platform, root)\n\tif (bundled !== undefined) return { launchOptions: { executablePath: bundled, ...launch } }\n\tconst fallback = platform === 'win32' ? 'msedge' : 'chrome'\n\treturn {\n\t\tlaunchOptions: { channel: resolveSystemBrowser(platform, environment) ?? fallback, ...launch },\n\t}\n}\n";
1654
- commands: "import type { BrowserConfigOptions } from 'vitest/node'\n\nexport const commands: Readonly<NonNullable<BrowserConfigOptions['commands']>> = Object.freeze({})\n";
1655
- }>;
1631
+ export declare const CONFIG_TEMPLATES: ConfigTemplateSet;
1632
+
1633
+ /** Represents the configuration template text, grouped by the artifact each template builds. */
1634
+ export declare interface ConfigTemplateSet {
1635
+ readonly root: {
1636
+ readonly tsconfig: string;
1637
+ readonly vite: string;
1638
+ };
1639
+ readonly factories: {
1640
+ readonly sheet: string;
1641
+ readonly src: {
1642
+ readonly core: string;
1643
+ readonly vue: string;
1644
+ readonly browser: string;
1645
+ readonly server: string;
1646
+ readonly bin: string;
1647
+ };
1648
+ readonly app: {
1649
+ readonly core: string;
1650
+ readonly browser: string;
1651
+ readonly vue: string;
1652
+ readonly journey: string;
1653
+ readonly showcase: string;
1654
+ readonly server: string;
1655
+ };
1656
+ readonly policy: string;
1657
+ readonly config: string;
1658
+ readonly setup: string;
1659
+ readonly browser: string;
1660
+ readonly guides: string;
1661
+ readonly skills: string;
1662
+ readonly tree: string;
1663
+ readonly conformance: string;
1664
+ readonly service: string;
1665
+ readonly studies: string;
1666
+ readonly distribution: string;
1667
+ readonly probe: string;
1668
+ readonly integration: {
1669
+ readonly sheet: string;
1670
+ readonly module: string;
1671
+ };
1672
+ };
1673
+ readonly tsconfigs: {
1674
+ readonly vue: {
1675
+ readonly src: string;
1676
+ readonly app: string;
1677
+ };
1678
+ readonly sheet: string;
1679
+ readonly src: {
1680
+ readonly core: string;
1681
+ readonly browser: string;
1682
+ readonly server: string;
1683
+ };
1684
+ readonly app: {
1685
+ readonly core: string;
1686
+ readonly browser: string;
1687
+ readonly server: string;
1688
+ };
1689
+ readonly bin: string;
1690
+ readonly skills: string;
1691
+ };
1692
+ readonly vites: {
1693
+ readonly sheet: string;
1694
+ readonly src: {
1695
+ readonly core: string;
1696
+ readonly vue: string;
1697
+ readonly browser: string;
1698
+ readonly server: string;
1699
+ };
1700
+ readonly bin: string;
1701
+ readonly app: {
1702
+ readonly vue: string;
1703
+ readonly browser: string;
1704
+ readonly server: string;
1705
+ readonly showcase: string;
1706
+ readonly journey: string;
1707
+ };
1708
+ };
1709
+ readonly browsers: string;
1710
+ readonly commands: string;
1711
+ }
1656
1712
 
1657
1713
  /** Names the official-tooling drift proof whose presence makes a workspace `conformance`. */
1658
1714
  export declare const CONFORMANCE_TEST_PATH = "tests/conformance.test.ts";
@@ -4115,6 +4171,35 @@ export declare class Compiler implements CompilerInterface {
4115
4171
  /** Names the surface an extension extends. */
4116
4172
  export declare type Surface = 'browser' | 'styles';
4117
4173
 
4174
+ /** Represents a candidate checkout's claim with each name two or more of its environments export. */
4175
+ export declare interface SurfaceCandidate extends SurfaceClaim {
4176
+ readonly conflicts: readonly SurfaceConflict[];
4177
+ }
4178
+
4179
+ /** Represents one owner's bare exported names, including an empty candidate surface. */
4180
+ export declare interface SurfaceClaim {
4181
+ readonly owner: string;
4182
+ readonly names: readonly string[];
4183
+ }
4184
+
4185
+ /** Represents a bare name claimed by distinct package owners. */
4186
+ export declare interface SurfaceCollision {
4187
+ readonly name: string;
4188
+ readonly owners: readonly string[];
4189
+ }
4190
+
4191
+ /** Represents a bare name one owner's barrels export from two or more of its environments. */
4192
+ export declare interface SurfaceConflict {
4193
+ readonly name: string;
4194
+ readonly owner: string;
4195
+ readonly environments: readonly string[];
4196
+ }
4197
+
4198
+ /** Reports a collision's standing against the recorded owner set. */
4199
+ export declare interface SurfaceFinding extends SurfaceCollision {
4200
+ readonly standing: 'error' | 'recorded' | 'closed';
4201
+ }
4202
+
4118
4203
  /** Lists the surfaces an extension may extend, frozen. */
4119
4204
  export declare const SURFACES: readonly Surface[];
4120
4205