@orkestrel/scaffold 0.0.134 → 0.0.136

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 (53) hide show
  1. package/dist/agents/skills/orkestrel-parallel/scripts/lane.js +777 -83
  2. package/dist/agents/skills/orkestrel-publish/scripts/wave.js +327 -21
  3. package/dist/bin/main.js +254 -36
  4. package/dist/bin/main.js.map +1 -1
  5. package/dist/host/AGENTS.md +2 -2
  6. package/dist/host/agents/orchestration.md +2 -2
  7. package/dist/host/agents/skills/orkestrel-parallel/SKILL.md +1 -1
  8. package/dist/host/agents/skills/orkestrel-parallel/scripts/lane.ts +983 -123
  9. package/dist/host/agents/skills/orkestrel-publish/references/release.md +1 -0
  10. package/dist/host/agents/skills/orkestrel-publish/references/wave.md +22 -5
  11. package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +403 -32
  12. package/dist/host/claude/agents/orkestrel.md +17 -17
  13. package/dist/host/claude/agents/reviewer.md +1 -1
  14. package/dist/host/claude/rules/architecture.md +1 -1
  15. package/dist/host/claude/rules/documentation.md +1 -1
  16. package/dist/host/claude/rules/patterns.md +4 -2
  17. package/dist/host/claude/rules/workspace.md +73 -67
  18. package/dist/host/configs/helpers.ts +109 -73
  19. package/dist/host/dotfiles/oxlintrc.json +1 -57
  20. package/dist/host/guides/agent.md +989 -395
  21. package/dist/host/guides/contract.md +198 -163
  22. package/dist/host/guides/database.md +978 -503
  23. package/dist/host/guides/indexeddb.md +80 -66
  24. package/dist/host/guides/middleware.md +5 -5
  25. package/dist/host/guides/ollama.md +41 -42
  26. package/dist/host/guides/relation.md +56 -32
  27. package/dist/host/guides/scaffold.md +185 -107
  28. package/dist/host/guides/sqlite.md +44 -23
  29. package/dist/host/guides/study.md +12 -12
  30. package/dist/host/guides/test.md +163 -47
  31. package/dist/host/guides/toolbox.md +127 -81
  32. package/dist/host/guides/workspace.md +21 -14
  33. package/dist/host/manifest.json +30 -30
  34. package/dist/host/scripts/browsers.sh +0 -0
  35. package/dist/host/scripts/codex.sh +0 -0
  36. package/dist/host/scripts/cursor.sh +0 -0
  37. package/dist/host/scripts/deps.sh +0 -0
  38. package/dist/host/scripts/npm.sh +0 -0
  39. package/dist/host/scripts/ollama.sh +0 -0
  40. package/dist/host/tests/config.test.ts +237 -115
  41. package/dist/src/core/index.cjs +591 -218
  42. package/dist/src/core/index.cjs.map +1 -1
  43. package/dist/src/core/index.d.cts +248 -29
  44. package/dist/src/core/index.d.ts +248 -29
  45. package/dist/src/core/index.js +581 -216
  46. package/dist/src/core/index.js.map +1 -1
  47. package/dist/src/server/index.cjs +18 -8
  48. package/dist/src/server/index.cjs.map +1 -1
  49. package/dist/src/server/index.d.cts +4 -3
  50. package/dist/src/server/index.d.ts +4 -3
  51. package/dist/src/server/index.js +19 -9
  52. package/dist/src/server/index.js.map +1 -1
  53. package/package.json +3 -3
@@ -4,7 +4,7 @@ let _orkestrel_template = require("@orkestrel/template");
4
4
  let _orkestrel_emitter = require("@orkestrel/emitter");
5
5
  var package_default = {
6
6
  name: "@orkestrel/scaffold",
7
- version: "0.0.134",
7
+ version: "0.0.136",
8
8
  description: "Scaffold workspaces with commands: new, audit, surface, repair, catalog, and overwrite.",
9
9
  keywords: [
10
10
  "audit",
@@ -97,7 +97,7 @@ var package_default = {
97
97
  },
98
98
  dependencies: {
99
99
  "@orkestrel/console": "^0.0.20",
100
- "@orkestrel/contract": "^0.0.23",
100
+ "@orkestrel/contract": "^0.0.24",
101
101
  "@orkestrel/emitter": "^0.0.16",
102
102
  "@orkestrel/markdown": "^0.0.21",
103
103
  "@orkestrel/process": "^0.0.19",
@@ -109,7 +109,7 @@ var package_default = {
109
109
  "@orkestrel/guide": "^0.0.31",
110
110
  "@orkestrel/html": "^0.0.16",
111
111
  "@orkestrel/probe": "^0.0.30",
112
- "@orkestrel/test": "^0.0.37",
112
+ "@orkestrel/test": "^0.0.39",
113
113
  "@types/node": "^24.19.2",
114
114
  "@vitest/browser-playwright": "^5.1.0",
115
115
  "oxfmt": "^0.78.0",
@@ -170,7 +170,6 @@ var STYLES_DEV_DEPENDENCIES = Object.freeze({ sass: "^1.105.1" });
170
170
  var RESERVED_SHEET_NAMES = Object.freeze([
171
171
  ...ENVIRONMENTS,
172
172
  "bin",
173
- "reporter",
174
173
  "styles",
175
174
  "themes",
176
175
  ...FRAMEWORKS
@@ -249,18 +248,37 @@ var APP_MATRIX = Object.freeze({
249
248
  });
250
249
  /** Lists the configuration files a workspace that ships its own executable adds, frozen. */
251
250
  var BIN_CONFIGS = Object.freeze(["configs/src/vite.bin.config.ts", "configs/src/tsconfig.bin.json"]);
252
- /** Lists the configuration files a workspace that publishes a Vitest reporter adds, frozen. */
253
- var REPORTER_CONFIGS = Object.freeze(["configs/src/vite.reporter.config.ts", "configs/src/tsconfig.reporter.json"]);
254
251
  /** Lists the configuration file a workspace with studies and a server application adds, frozen. */
255
252
  var BARREL_CONFIGS = Object.freeze(["configs/app/vite.barrel.config.ts"]);
256
- /** Names the executable entry whose presence makes a workspace `bin`. */
253
+ /** Names the executable entry, the `main` module of `src/bin`. */
257
254
  var BIN_ENTRY_PATH = "src/bin/main.ts";
258
255
  /** Names the built executable a bin workspace's manifest command runs. */
259
256
  var BIN_OUTPUT_PATH = "dist/bin/main.js";
260
- /** Names the reporter entry whose presence makes a workspace `reporter`. */
261
- var REPORTER_ENTRY_PATH = "src/reporter/main.ts";
262
- /** Names the built reporter module a reporter workspace's `./reporter` export loads. */
263
- var REPORTER_OUTPUT_PATH = "dist/reporter/main.js";
257
+ /** Lists the stems of the centralized files the architecture kind table names, which no `src/bin` module takes, frozen. */
258
+ var CENTRAL_FILE_NAMES = Object.freeze([
259
+ "cloners",
260
+ "combinators",
261
+ "compilers",
262
+ "constants",
263
+ "contracts",
264
+ "errors",
265
+ "factories",
266
+ "handlers",
267
+ "helpers",
268
+ "index",
269
+ "inferers",
270
+ "middlewares",
271
+ "parsers",
272
+ "plugins",
273
+ "relations",
274
+ "routes",
275
+ "schemas",
276
+ "seeders",
277
+ "shapers",
278
+ "templates",
279
+ "types",
280
+ "validators"
281
+ ]);
264
282
  /**
265
283
  * Lists the paths a target receives from the vendored data root, frozen.
266
284
  *
@@ -519,6 +537,42 @@ var RELEASE_PROOF_COMMAND = "npm run test:distribution -- --mode release";
519
537
  var INTEGRATION_TEST_PATH = "tests/integration.test.ts";
520
538
  /** Names the manifest path every compiler plan emits with birth ownership. */
521
539
  var MANIFEST_PATH = "package.json";
540
+ /**
541
+ * Lists the top-level manifest keys in the order a compiled manifest emits them.
542
+ *
543
+ * @remarks
544
+ * An entry write that creates an absent `bin`, `files`, or `exports` key places it before the
545
+ * first declared key this list orders after it, so a created key lands where a born manifest
546
+ * carries it.
547
+ */
548
+ var MANIFEST_KEY_ORDER = Object.freeze([
549
+ "name",
550
+ "version",
551
+ "private",
552
+ "description",
553
+ "keywords",
554
+ "homepage",
555
+ "bugs",
556
+ "license",
557
+ "repository",
558
+ "bin",
559
+ "files",
560
+ "type",
561
+ "sideEffects",
562
+ "main",
563
+ "module",
564
+ "types",
565
+ "exports",
566
+ "publishConfig",
567
+ "scripts",
568
+ "dependencies",
569
+ "devDependencies",
570
+ "overrides",
571
+ "peerDependencies",
572
+ "peerDependenciesMeta",
573
+ "devEngines",
574
+ "engines"
575
+ ]);
522
576
  /** Names the official-tooling drift proof whose presence makes a workspace `conformance`. */
523
577
  var CONFORMANCE_TEST_PATH = "tests/conformance.test.ts";
524
578
  /** Names the real-tree proof whose presence makes a workspace `tree`. */
@@ -548,6 +602,8 @@ var JOURNEY_CONFIG_PATH = "configs/app/vite.journey.config.ts";
548
602
  var SKILLS_CONFIG_PATH = "configs/agents/tsconfig.skills.json";
549
603
  /** Matches the bare workspace name syntax: lowercase alphanumeric with hyphens, letter first. */
550
604
  var NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
605
+ /** Matches the stem of a `src/bin` module: lowercase letters and digits, letter first, no hyphen. */
606
+ var BIN_MODULE_PATTERN = /^[a-z][a-z0-9]*$/;
551
607
  /**
552
608
  * Matches the runtime dependency name syntax: the `@orkestrel` scope and a bare name.
553
609
  *
@@ -899,7 +955,7 @@ var CONFIG_TEMPLATES = Object.freeze({
899
955
  `,
900
956
  vite: `{{journey}}import type { PluginOption, UserConfig } from 'vite'
901
957
  import { mergeConfig } from 'vite'
902
- {{imports}}import { defineConfig } from 'vitest/config'
958
+ {{imports}}import { {{vitest}}defineConfig } from 'vitest/config'
903
959
  import manifest from './package.json' with { type: 'json' }
904
960
  import tsconfig from './tsconfig.json' with { type: 'json' }
905
961
  {{helpers}}{{browsers}}import { fileURLToPath, URL } from 'node:url'
@@ -1216,8 +1272,8 @@ export function srcServer(override?: UserConfig): UserConfig {
1216
1272
  return mergeOverride(project, override)
1217
1273
  }
1218
1274
  `,
1219
- bin: `function resolveBinFilename(): string {
1220
- return 'main.js'
1275
+ bin: `function resolveBinFilename(_format: string, entry: string): string {
1276
+ return \`\${entry}.js\`
1221
1277
  }
1222
1278
 
1223
1279
  function resolveBinExternal(id: string): boolean {
@@ -1234,7 +1290,9 @@ export function srcBin(override?: UserConfig): UserConfig {
1234
1290
  sourcemap: true,
1235
1291
  minify: false,
1236
1292
  lib: {
1237
- entry: resolveWorkspacePath('${BIN_ENTRY_PATH}'),
1293
+ entry: {
1294
+ {{entries}}
1295
+ },
1238
1296
  formats: ['es'],
1239
1297
  fileName: resolveBinFilename,
1240
1298
  },
@@ -1259,46 +1317,6 @@ export function srcBin(override?: UserConfig): UserConfig {
1259
1317
  }
1260
1318
  return mergeOverride(project, override)
1261
1319
  }
1262
- `,
1263
- reporter: `function resolveReporterFilename(): string {
1264
- return 'main.js'
1265
- }
1266
-
1267
- function resolveReporterExternal(id: string): boolean {
1268
- return id.startsWith('@src/') || resolveExternal(id, { peers, refused: [], siblings: [] })
1269
- }
1270
-
1271
- export function srcReporter(override?: UserConfig): UserConfig {
1272
- const project: UserConfig = {
1273
- resolve,
1274
- publicDir: false,
1275
- plugins: [outputBoundary('dist/reporter')],
1276
- build: {
1277
- emptyOutDir: true,
1278
- sourcemap: true,
1279
- minify: false,
1280
- lib: {
1281
- entry: resolveWorkspacePath('${REPORTER_ENTRY_PATH}'),
1282
- formats: ['es'],
1283
- fileName: resolveReporterFilename,
1284
- },
1285
- outDir: 'dist/reporter',
1286
- target: 'node22',
1287
- rolldownOptions: {
1288
- onLog: enforceBuildLog,
1289
- external: resolveReporterExternal,
1290
- },
1291
- },
1292
- test: {
1293
- name: { label: 'src:reporter', color: 'cyan' },
1294
- include: ['tests/src/reporter/**/*.test.ts'],
1295
- setupFiles: ['./tests/setup.ts', './tests/setupServer.ts'],
1296
- environment: 'node',
1297
- browser: { enabled: false },
1298
- },
1299
- }
1300
- return mergeOverride(project, override)
1301
- }
1302
1320
  `
1303
1321
  }),
1304
1322
  app: Object.freeze({
@@ -1772,11 +1790,11 @@ export function studies(override?: UserConfig): UserConfig {
1772
1790
  return mergeOverride(project, override)
1773
1791
  }
1774
1792
  `,
1775
- probe: `// A workbench, not a proof. No gate selects this project. Run in test mode by the
1793
+ probe: `{{benches}}// A workbench, not a proof. No gate selects this project. Run in test mode by the
1776
1794
  // \`test:probe\` script, it collects \`tmp/probes/**/*.test.ts\`. Run in benchmark mode by the
1777
- // \`test:bench\` script, it collects \`*.bench.ts\` files under \`tmp/probes\` and \`tests\`.
1778
- // Each benchmark is a regular test that uses its context's \`bench\` fixture and awaits
1779
- // \`bench(name, options, fn).run()\` or \`bench.compare(...)\`.
1795
+ // \`test:bench\` script, it collects \`*.bench.ts\` files under \`tmp/probes\` and \`tests\`, other
1796
+ // than a browser-hosted face's benches. Each benchmark is a regular test that uses its
1797
+ // context's \`bench\` fixture and awaits \`bench(name, options, fn).run()\` or \`bench.compare(...)\`.
1780
1798
  export function probe(override?: UserConfig): UserConfig {
1781
1799
  const project: UserConfig = {
1782
1800
  resolve,
@@ -1789,7 +1807,29 @@ export function probe(override?: UserConfig): UserConfig {
1789
1807
  fileParallelism: false,
1790
1808
  sequence: { groupOrder: 1 },
1791
1809
  pool: 'threads',
1792
- benchmark: { include: ['tmp/probes/**/*.bench.ts', 'tests/**/*.bench.ts'] },
1810
+ {{benchmark}} },
1811
+ }
1812
+ return mergeOverride(project, override)
1813
+ }
1814
+ `,
1815
+ bench: `// Runs the browser benches in Playwright Chromium beside the \`probe\` workbench, through the
1816
+ // \`test:bench\` script. No gate selects this project, and it collects no test file.
1817
+ export function benchBrowser(override?: UserConfig): UserConfig {
1818
+ const project: UserConfig = {
1819
+ resolve,
1820
+ {{optimization}},
1821
+ {{plugins}} test: {
1822
+ name: { label: 'bench:browser', color: 'black' },
1823
+ include: [],
1824
+ setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
1825
+ browser: {
1826
+ enabled: true,
1827
+ provider: playwright(browserOptions),
1828
+ commands,
1829
+ screenshotDirectory: screenshots,
1830
+ instances: [{ browser: 'chromium', headless: true }],
1831
+ },
1832
+ benchmark: { include: browserBenches },
1793
1833
  },
1794
1834
  }
1795
1835
  return mergeOverride(project, override)
@@ -1983,25 +2023,6 @@ export function probe(override?: UserConfig): UserConfig {
1983
2023
  "../../src/bin/**/*.tsx"
1984
2024
  ]
1985
2025
  }
1986
- `,
1987
- reporter: `{
1988
- "extends": "../../tsconfig.json",
1989
- "compilerOptions": {
1990
- "lib": ["ESNext"],
1991
- "types": ["node"],
1992
- "noEmit": false,
1993
- "declaration": true,
1994
- "emitDeclarationOnly": true,
1995
- "rootDir": "../../src",
1996
- "outDir": "../../dist/reporter"
1997
- },
1998
- "include": [
1999
- "../../src/reporter/**/*.cts",
2000
- "../../src/reporter/**/*.mts",
2001
- "../../src/reporter/**/*.ts",
2002
- "../../src/reporter/**/*.tsx"
2003
- ]
2004
- }
2005
2026
  `,
2006
2027
  skills: `{
2007
2028
  "extends": "../../tsconfig.json",
@@ -2145,45 +2166,28 @@ export default defineConfig(
2145
2166
  `
2146
2167
  }),
2147
2168
  bin: `import { defineConfig } from 'vite'
2148
- import { resolveExternal } from '../helpers.js'
2149
- import { peers, srcBin } from '../../vite.config.ts'
2150
-
2151
- // The \`scaffold\` executable build — a single ESM lib file, no declarations (an
2152
- // executable ships no types), with the \`#!/usr/bin/env node\` shebang re-emitted through
2153
- // \`output.banner\` (rolldown strips shebangs from source during bundling), and
2154
- // \`output.paths\` rewriting the externalized \`@src/*\` specifiers to the built sibling
2155
- // src environments (relative to \`dist/bin/\`), so the emitted bin resolves at runtime.
2156
- export default defineConfig(
2157
- srcBin({
2158
- build: {
2159
- rolldownOptions: {
2160
- external: (id: string) =>
2161
- id.startsWith('@src/') || resolveExternal(id, { peers, refused: [], siblings: [] }),
2162
- output: {
2163
- banner: '#!/usr/bin/env node',
2164
- {{paths}}
2165
- },
2166
- },
2167
- },
2168
- }),
2169
- )
2170
- `,
2171
- reporter: `import { defineConfig } from 'vite'
2172
- import { declarationRollup, rewriteServerSpecifier } from '../helpers.js'
2173
- import { resolveWorkspacePath, srcReporter } from '../../vite.config.ts'
2169
+ import { declarationRollup, resolveExternal, rewriteSourceSpecifier } from '../helpers.js'
2170
+ import { peers, resolveWorkspacePath, srcBin } from '../../vite.config.ts'
2174
2171
 
2175
- // Each external \`@src/*\` path resolves from \`dist/reporter/\` to the built environment.
2172
+ // One ES file per \`src/bin\` module. Rolldown strips a source shebang, so \`main\` alone takes
2173
+ // the \`#!/usr/bin/env node\` banner; every other module ships its rolled-up declaration.
2174
+ // \`output.paths\` and the declaration rewrite point each external \`@src/*\` specifier at the
2175
+ // built environment beside \`dist/bin/\`.
2176
2176
  export default defineConfig(
2177
- srcReporter({
2177
+ srcBin({
2178
2178
  plugins: [
2179
2179
  declarationRollup({
2180
- project: resolveWorkspacePath('configs/src/tsconfig.reporter.json'),
2181
- rewrite: rewriteServerSpecifier,
2180
+ project: resolveWorkspacePath('configs/src/tsconfig.bin.json'),
2181
+ entries: [{{modules}}],
2182
+ rewrite: rewriteSourceSpecifier,
2182
2183
  }),
2183
2184
  ],
2184
2185
  build: {
2185
2186
  rolldownOptions: {
2187
+ external: (id: string) =>
2188
+ id.startsWith('@src/') || resolveExternal(id, { peers, refused: [], siblings: [] }),
2186
2189
  output: {
2190
+ banner: (chunk) => (chunk.name === 'main' ? '#!/usr/bin/env node' : ''),
2187
2191
  {{paths}}
2188
2192
  },
2189
2193
  },
@@ -2790,15 +2794,6 @@ describe('bin entry', () => {
2790
2794
  expect(Object.keys(entry)).toStrictEqual([])
2791
2795
  })
2792
2796
  })
2793
- `,
2794
- reporter: `import { describe, expect, it } from 'vitest'
2795
- import reporter from '../../../src/reporter/main.js'
2796
-
2797
- describe('reporter entry', () => {
2798
- it('exports the reporter class by default', () => {
2799
- expect(reporter).toBeTypeOf('function')
2800
- })
2801
- })
2802
2797
  `,
2803
2798
  distribution: Object.freeze({
2804
2799
  module: `{{types}}import type { SpawnSyncReturns } from 'node:child_process'
@@ -4020,13 +4015,7 @@ export function collectDistributionFiles(directory: string): readonly string[] {
4020
4015
  */
4021
4016
  export function readDistributionFace(installed: string, path: string): string | undefined {
4022
4017
  const [output, axis, face] = relativePath(installed, path).split(sep)
4023
- return output === 'dist'
4024
- ? axis === 'src'
4025
- ? face
4026
- : axis === 'bin' || axis === 'reporter'
4027
- ? axis
4028
- : undefined
4029
- : undefined
4018
+ return output === 'dist' ? (axis === 'src' ? face : axis === 'bin' ? axis : undefined) : undefined
4030
4019
  }
4031
4020
 
4032
4021
  /**
@@ -5064,6 +5053,29 @@ function isCollection(value) {
5064
5053
  return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isArray)(value) && value.length <= 1e3);
5065
5054
  }
5066
5055
  /**
5056
+ * Narrows a manifest `exports` value to a map of subpaths.
5057
+ *
5058
+ * @param value - The declared `exports` value.
5059
+ * @returns True if the value is an object whose every key opens with `.`; false otherwise.
5060
+ *
5061
+ * @remarks
5062
+ * Node reads a string, an array, or an object whose keys are conditions, such as `import` and
5063
+ * `require`, as the root export alone, and refuses an object that mixes conditions with subpaths,
5064
+ * so a subpath can be added only to a subpath map. A value whose keys cannot be read answers
5065
+ * `false`.
5066
+ *
5067
+ * @example
5068
+ * ```ts
5069
+ * import { isSubpathMap } from '@orkestrel/scaffold'
5070
+ *
5071
+ * isSubpathMap({ '.': './index.js' }) // true
5072
+ * isSubpathMap({ import: './index.js' }) // false
5073
+ * ```
5074
+ */
5075
+ function isSubpathMap(value) {
5076
+ return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && Object.keys(value).every((key) => key.startsWith(".")));
5077
+ }
5078
+ /**
5067
5079
  * Narrows a value to one {@link Environment} a workspace may select.
5068
5080
  *
5069
5081
  * @example
@@ -5104,6 +5116,22 @@ function isSheetName(value) {
5104
5116
  return (0, _orkestrel_contract.isString)(value) && value.length <= 203 && NAME_PATTERN.test(value) && !RESERVED_SHEET_NAMES.includes(value);
5105
5117
  }
5106
5118
  /**
5119
+ * Narrows a value to the stem of a `src/bin` module.
5120
+ * @param value - The candidate stem.
5121
+ * @returns True if the stem matches `BIN_MODULE_PATTERN` within the name length cap and names no
5122
+ * centralized file; false otherwise.
5123
+ * @example
5124
+ * ```ts
5125
+ * import { isBinModule } from '@orkestrel/scaffold'
5126
+ *
5127
+ * isBinModule('reporter') // true
5128
+ * isBinModule('helpers') // false
5129
+ * ```
5130
+ */
5131
+ function isBinModule(value) {
5132
+ return (0, _orkestrel_contract.isString)(value) && value.length <= 203 && BIN_MODULE_PATTERN.test(value) && !CENTRAL_FILE_NAMES.includes(value);
5133
+ }
5134
+ /**
5107
5135
  * Narrows a value to a supported browser framework with distinct occupied axes.
5108
5136
  * @param value - The candidate extension.
5109
5137
  * @returns True if the value is an admitted extension; false otherwise.
@@ -5295,8 +5323,7 @@ var isBlueprint = (0, _orkestrel_contract.recordOf)({
5295
5323
  version: _orkestrel_contract.isString,
5296
5324
  engines: _orkestrel_contract.isString,
5297
5325
  overrides: (0, _orkestrel_contract.andOf)(isCollection, (0, _orkestrel_contract.arrayOf)(isOverride)),
5298
- bin: _orkestrel_contract.isBoolean,
5299
- reporter: _orkestrel_contract.isBoolean,
5326
+ bin: (0, _orkestrel_contract.andOf)(isCollection, (0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)),
5300
5327
  setup: (0, _orkestrel_contract.andOf)(isCollection, (0, _orkestrel_contract.arrayOf)((0, _orkestrel_contract.literalOf)("node", "browser"))),
5301
5328
  guides: _orkestrel_contract.isBoolean,
5302
5329
  integration: _orkestrel_contract.isBoolean,
@@ -6324,6 +6351,35 @@ function matchesBarrel(blueprint) {
6324
6351
  return blueprint.studies && blueprint.app.includes("server");
6325
6352
  }
6326
6353
  /**
6354
+ * Lists the bench globs of the browser-hosted projects among a workspace's project labels.
6355
+ *
6356
+ * @param projects - The project labels, in registration order.
6357
+ * @returns One glob per browser-hosted label, matching every `*.bench.ts` file beneath that
6358
+ * label's directory under `tests/<axis>/`, in label order.
6359
+ *
6360
+ * @remarks
6361
+ * A label on the `src` or `app` axis names a project that runs in Playwright Chromium unless it
6362
+ * names `core`, `server`, or `bin`, which run in Node. The `src:themes` target collects
6363
+ * `tests/src/styles/themes`. Every other label sits on neither axis and adds no glob.
6364
+ *
6365
+ * @example
6366
+ * ```ts
6367
+ * import { projectsToBenches } from '@orkestrel/scaffold'
6368
+ *
6369
+ * const benches = projectsToBenches(['src:core', 'src:browser', 'app:vue', 'policy'])
6370
+ *
6371
+ * benches.length // 2
6372
+ * benches[1]?.startsWith('tests/app/vue/') // true
6373
+ * ```
6374
+ */
6375
+ function projectsToBenches(projects) {
6376
+ return projects.flatMap((label) => {
6377
+ const [axis, face, ...rest] = label.split(":");
6378
+ if (axis !== "src" && axis !== "app" || face === void 0 || face.length === 0 || rest.length > 0 || face === "core" || face === "server" || face === "bin") return [];
6379
+ return [`tests/${axis}/${face === "themes" ? "styles/themes" : face}/**/*.bench.ts`];
6380
+ });
6381
+ }
6382
+ /**
6327
6383
  * Selects the single published environment a package root points at.
6328
6384
  *
6329
6385
  * @param src - The declared published environments.
@@ -6906,6 +6962,106 @@ function manifestToDependencies(manifest) {
6906
6962
  };
6907
6963
  }
6908
6964
  /**
6965
+ * Projects a package manifest's text to the planned `bin`, `files`, and `exports` entries it lacks.
6966
+ *
6967
+ * @param manifest - The `package.json` text.
6968
+ * @param planned - The entries the plan emits.
6969
+ * @returns The planned entries the manifest does not declare, each in planned order.
6970
+ *
6971
+ * @remarks
6972
+ * A planned command counts as declared when the manifest names it, or when any declared command
6973
+ * runs the planned file: a package keeps the command name it publishes. A string `bin` declares
6974
+ * the planned command when it names the planned file. A planned packed path counts as declared
6975
+ * when a declared path equals it or names a directory above it, as {@link matchesPackedPath} reads
6976
+ * the pair. A subpath counts as declared by name alone, so a declared entry holding another value
6977
+ * stays the package's. A string `exports`, a fallback array, or an object whose keys are conditions
6978
+ * rather than subpaths declares the root subpath `.` alone, as Node reads each. A section holding any other shape declares none of
6979
+ * its planned entries. A manifest that is not an object lacks nothing, because no entry can be read
6980
+ * from it or written into it.
6981
+ *
6982
+ * @example
6983
+ * ```ts
6984
+ * import { manifestToEntries } from '@orkestrel/scaffold'
6985
+ *
6986
+ * manifestToEntries('{"files": ["dist/src"]}', {
6987
+ * bin: {},
6988
+ * files: ['dist/src', 'dist/bin'],
6989
+ * exports: {},
6990
+ * }).files // ['dist/bin']
6991
+ * ```
6992
+ */
6993
+ function manifestToEntries(manifest, planned) {
6994
+ const parsed = (0, _orkestrel_contract.parseJSON)(manifest);
6995
+ if (!(0, _orkestrel_contract.isRecord)(parsed)) return {
6996
+ bin: {},
6997
+ files: [],
6998
+ exports: {}
6999
+ };
7000
+ const { bin, files, exports } = parsed;
7001
+ const commands = (0, _orkestrel_contract.isString)(bin) ? { "": bin } : (0, _orkestrel_contract.isRecord)(bin) ? bin : {};
7002
+ const runs = Object.values(commands).flatMap((path) => (0, _orkestrel_contract.isString)(path) ? [normalizePackagePath(path)] : []);
7003
+ const packed = (0, _orkestrel_contract.isArray)(files) ? files.filter(_orkestrel_contract.isString) : [];
7004
+ const subpaths = isSubpathMap(exports) ? exports : (0, _orkestrel_contract.isString)(exports) || (0, _orkestrel_contract.isArray)(exports) || (0, _orkestrel_contract.isRecord)(exports) ? { ".": exports } : {};
7005
+ return {
7006
+ bin: Object.fromEntries(Object.entries(planned.bin).filter(([name, path]) => !((0, _orkestrel_contract.isRecord)(bin) && Object.hasOwn(bin, name)) && !runs.includes(normalizePackagePath(path)))),
7007
+ files: planned.files.filter((path) => !packed.some((declared) => matchesPackedPath(declared, path))),
7008
+ exports: Object.fromEntries(Object.entries(planned.exports).filter(([path]) => !Object.hasOwn(subpaths, path)))
7009
+ };
7010
+ }
7011
+ /**
7012
+ * Returns the canonical form of a path a manifest names inside its package.
7013
+ *
7014
+ * @param path - A `bin` target or a `files` entry.
7015
+ * @returns The path with `/` for every backslash, one `/` for every run of separators, and no
7016
+ * leading `./` or trailing `/`.
7017
+ *
7018
+ * @remarks
7019
+ * npm reads a backslash in a `bin` or `files` path as a separator and collapses repeated
7020
+ * separators, so `dist\bin\main.js` and `dist//bin/main.js` name `dist/bin/main.js`.
7021
+ *
7022
+ * @example
7023
+ * ```ts
7024
+ * import { normalizePackagePath } from '@orkestrel/scaffold'
7025
+ *
7026
+ * normalizePackagePath('./dist/bin/main.js') // 'dist/bin/main.js'
7027
+ * normalizePackagePath('dist//bin/main.js') // 'dist/bin/main.js'
7028
+ * ```
7029
+ */
7030
+ function normalizePackagePath(path) {
7031
+ return path.replaceAll("\\", "/").replace(/\/{2,}/gu, "/").replace(/^(\.\/)+/u, "").replace(/\/+$/u, "");
7032
+ }
7033
+ /**
7034
+ * Checks whether a declared `files` entry packs a planned one.
7035
+ *
7036
+ * @param declared - The entry the manifest declares.
7037
+ * @param planned - The entry the plan emits.
7038
+ * @returns True if the entries are equal, or the declared entry names a directory whose path
7039
+ * segments open the planned entry's; false otherwise.
7040
+ *
7041
+ * @remarks
7042
+ * A declared entry ending in `/**` or `/*` packs the directory it names, so `dist/**` packs
7043
+ * `dist/app`. No other glob is read: an entry such as `dist/*.js` packs no planned path it does not
7044
+ * equal. A negated entry such as `!dist/src/styles/index.js` excludes a path rather than packing
7045
+ * one, so only an equal entry declares it.
7046
+ *
7047
+ * @example
7048
+ * ```ts
7049
+ * import { matchesPackedPath } from '@orkestrel/scaffold'
7050
+ *
7051
+ * matchesPackedPath('dist', 'dist/app') // true
7052
+ * matchesPackedPath('dist-old', 'dist/app') // false
7053
+ * ```
7054
+ */
7055
+ function matchesPackedPath(declared, planned) {
7056
+ const left = normalizePackagePath(declared).replace(/\/\*\*?$/u, "");
7057
+ const right = normalizePackagePath(planned);
7058
+ if (left === right) return true;
7059
+ if (left.startsWith("!") || right.startsWith("!") || left === "") return false;
7060
+ const segments = left.split("/");
7061
+ const target = right.split("/");
7062
+ return segments.length < target.length && segments.every((segment, index) => segment === target[index]);
7063
+ }
7064
+ /**
6909
7065
  * Renders the `SKILL.md` pointer a target carries in place of a canonical skill.
6910
7066
  *
6911
7067
  * @param canonical - The canonical `SKILL.md` text, which opens with a frontmatter block.
@@ -7016,10 +7172,10 @@ function blueprintToSheets(blueprint) {
7016
7172
  return [...blueprint.styles ? ["styles"] : [], ...(0, _orkestrel_contract.sortValues)(blueprint.extensions.flatMap((extension) => extension.surface === "styles" && isSheetName(extension.name) ? [extension.name] : []))];
7017
7173
  }
7018
7174
  /**
7019
- * Projects published environments, sheets, and the reporter entry into the manifest export map.
7175
+ * Projects published environments, sheets, and `src/bin` modules into the manifest export map.
7020
7176
  * @param blueprint - The workspace specification.
7021
- * @returns JavaScript conditions, CSS and SCSS subpaths, and the ES-only `./reporter` subpath,
7022
- * without an invented JavaScript root.
7177
+ * @returns JavaScript conditions, CSS and SCSS subpaths, and the ES-only `./<name>` subpath of
7178
+ * each `src/bin` module other than `main`, without an invented JavaScript root.
7023
7179
  * @example
7024
7180
  * ```ts
7025
7181
  * import { blueprintToExports, createBlueprint } from '@orkestrel/scaffold'
@@ -7036,7 +7192,7 @@ function blueprintToExports(blueprint) {
7036
7192
  return blueprint.src.includes("browser") ? [face, ["./browser", pathToCondition("./dist/src/browser/index", ["es"])]] : [face];
7037
7193
  })),
7038
7194
  ...Object.fromEntries([...blueprintToSheets(blueprint), ...blueprint.themes ? ["styles/themes"] : []].flatMap((name) => [[`./${name}`, `./dist/src/${name}/index.css`], [`./${name}/scss`, `./src/${name}/index.scss`]])),
7039
- ...blueprint.reporter ? { "./reporter": pathToCondition(`./${REPORTER_OUTPUT_PATH.replace(/\.js$/u, "")}`, ["es"]) } : {}
7195
+ ...Object.fromEntries(blueprint.bin.flatMap((name) => name === "main" ? [] : [[`./${name}`, pathToCondition(`./dist/bin/${name}`, ["es"])]]))
7040
7196
  };
7041
7197
  return Object.keys(exported).length > 0 ? {
7042
7198
  ...exported,
@@ -7210,7 +7366,7 @@ function blueprintToDevDependencies(blueprint) {
7210
7366
  ...rendered && !BROWSE_UPSTREAM.includes(own) ? BROWSE_DEV_DEPENDENCIES : {},
7211
7367
  ...blueprint.journey && blueprint.app.includes("browser") && (blueprint.base || blueprintToFaces(blueprint).some((extension) => extension.axes.includes("app"))) && !CAPTURE_UPSTREAM.includes(own) ? CAPTURE_DEV_DEPENDENCIES : {},
7212
7368
  ...sheets ? STYLES_DEV_DEPENDENCIES : {},
7213
- ...blueprint.src.length > 0 || blueprint.bin || blueprint.reporter ? DECLARATION_DEV_DEPENDENCIES : {},
7369
+ ...blueprint.src.length > 0 || blueprint.bin.length > 0 ? DECLARATION_DEV_DEPENDENCIES : {},
7214
7370
  ...blueprint.src.includes("browser") || blueprint.setup.includes("browser") || sheets ? SOURCE_BROWSER_DEV_DEPENDENCIES : {},
7215
7371
  ...blueprint.app.includes("browser") ? APP_BROWSER_DEV_DEPENDENCIES : {},
7216
7372
  ...blueprint.app.includes("server") ? APP_SERVER_DEV_DEPENDENCIES : {},
@@ -7403,7 +7559,7 @@ function blueprintToScripts(blueprint) {
7403
7559
  const checker = application.includes("vue") ? FRAMEWORK_MATRIX.vue.checker : "tsc";
7404
7560
  const publishes = blueprint.src.length > 0 || targets.length > 0;
7405
7561
  const integrates = blueprint.integration;
7406
- const compiles = publishes || blueprint.bin || blueprint.reporter;
7562
+ const compiles = publishes || blueprint.bin.length > 0;
7407
7563
  const runtime = blueprint.app.filter((environment) => environment !== "core" && (environment !== "browser" || base));
7408
7564
  const vitest = "vitest run --config vite.config.ts --no-cache --reporter=dot";
7409
7565
  const built = [...runtime, ...application].flatMap((environment) => environment === "server" && matchesBarrel(blueprint) ? [environment, "barrel"] : [environment]);
@@ -7411,8 +7567,7 @@ function blueprintToScripts(blueprint) {
7411
7567
  ...blueprint.src,
7412
7568
  ...source,
7413
7569
  ...sheets,
7414
- ...blueprint.bin ? ["bin"] : [],
7415
- ...blueprint.reporter ? ["reporter"] : []
7570
+ ...blueprint.bin.length > 0 ? ["bin"] : []
7416
7571
  ].map((name) => `npm run check:src:${name}`);
7417
7572
  const journey = `vitest run --config ${JOURNEY_CONFIG_PATH} --no-cache --reporter=dot`;
7418
7573
  const showcase = `vite --config ${SHOWCASE_CONFIG_PATH}`;
@@ -7433,8 +7588,7 @@ function blueprintToScripts(blueprint) {
7433
7588
  ...checks.length > 0 ? {
7434
7589
  "check:src": checks.join(" && "),
7435
7590
  ...Object.fromEntries(Iterator.from(blueprint.src).map((environment) => [`check:src:${environment}`, `tsc --noEmit -p configs/src/tsconfig.${environment}.json`]).toArray()),
7436
- ...blueprint.bin ? { "check:src:bin": "tsc --noEmit -p configs/src/tsconfig.bin.json" } : {},
7437
- ...blueprint.reporter ? { "check:src:reporter": "tsc --noEmit -p configs/src/tsconfig.reporter.json" } : {},
7591
+ ...blueprint.bin.length > 0 ? { "check:src:bin": "tsc --noEmit -p configs/src/tsconfig.bin.json" } : {},
7438
7592
  ...Object.fromEntries([...sheets, ...source].map((name) => [`check:src:${name}`, `tsc --noEmit -p configs/src/tsconfig.${name}.json`]))
7439
7593
  } : {},
7440
7594
  ...blueprint.app.length > 0 ? {
@@ -7459,16 +7613,14 @@ function blueprintToScripts(blueprint) {
7459
7613
  ...!publishes && blueprint.service ? ["npm run test:service"] : []
7460
7614
  ].join(" && "),
7461
7615
  ...compiles ? {
7462
- "test:src": [...blueprint.src.length > 0 || blueprint.bin || blueprint.reporter ? [[
7616
+ "test:src": [...blueprint.src.length > 0 || blueprint.bin.length > 0 ? [[
7463
7617
  vitest,
7464
7618
  ...blueprint.src.map((environment) => `--project ${SRC_MATRIX[environment].project}`),
7465
7619
  ...source.map((name) => `--project src:${name}`),
7466
- ...blueprint.bin ? ["--project src:bin"] : [],
7467
- ...blueprint.reporter ? ["--project src:reporter"] : []
7620
+ ...blueprint.bin.length > 0 ? ["--project src:bin"] : []
7468
7621
  ].join(" ")] : [], ...targets.map((name) => `npm run test:src:${name}`)].join(" && "),
7469
7622
  ...Object.fromEntries(Iterator.from(blueprint.src).map((environment) => [`test:src:${environment}`, `${vitest} --project ${SRC_MATRIX[environment].project}`]).toArray()),
7470
- ...blueprint.bin ? { "test:src:bin": `${vitest} --project src:bin` } : {},
7471
- ...blueprint.reporter ? { "test:src:reporter": `${vitest} --project src:reporter` } : {},
7623
+ ...blueprint.bin.length > 0 ? { "test:src:bin": `${vitest} --project src:bin` } : {},
7472
7624
  ...Object.fromEntries(source.map((name) => [`test:src:${name}`, `${vitest} --project src:${name}`])),
7473
7625
  ...Object.fromEntries(targets.map((name) => [`test:src:${name}`, `npm run build:src:${name} && ${vitest} --project src:${name}`]))
7474
7626
  } : {},
@@ -7500,7 +7652,11 @@ function blueprintToScripts(blueprint) {
7500
7652
  ...blueprint.conformance ? { "test:conformance": `${vitest} --project conformance` } : {},
7501
7653
  ...blueprint.tree ? { "test:tree": `${vitest} --project tree` } : {},
7502
7654
  "test:probe": "vitest run --config vite.config.ts --no-cache --reporter=verbose --project probe",
7503
- "test:bench": "vitest bench --config vite.config.ts --no-cache --project \"probe (bench)\" --mode benchmark",
7655
+ "test:bench": [
7656
+ "vitest bench --config vite.config.ts --no-cache --project \"probe (bench)\"",
7657
+ ...blueprintToProjects(blueprint).includes("bench:browser") ? ["--project bench:browser"] : [],
7658
+ "--mode benchmark"
7659
+ ].join(" "),
7504
7660
  ...publishes ? { "test:distribution": `${vitest} --project distribution` } : {},
7505
7661
  ...integrates ? { "test:integration": `${vitest} --project integration` } : {},
7506
7662
  ...blueprint.service ? { "test:service": `${vitest} --project service` } : {},
@@ -7515,12 +7671,10 @@ function blueprintToScripts(blueprint) {
7515
7671
  ...blueprint.src.map((environment) => `npm run build:src:${environment}`),
7516
7672
  ...source.map((name) => `npm run build:src:${name}`),
7517
7673
  ...targets.map((name) => `npm run build:src:${name}`),
7518
- ...blueprint.bin ? ["npm run build:src:bin"] : [],
7519
- ...blueprint.reporter ? ["npm run build:src:reporter"] : []
7674
+ ...blueprint.bin.length > 0 ? ["npm run build:src:bin"] : []
7520
7675
  ].join(" && "),
7521
7676
  ...Object.fromEntries(Iterator.from(blueprint.src).map((environment) => [`build:src:${environment}`, SRC_MATRIX[environment].formats.includes("cjs") ? `vite build --config configs/src/vite.${environment}.config.ts && npm run copy dist/src/${environment}/index.d.ts dist/src/${environment}/index.d.cts` : `vite build --config configs/src/vite.${environment}.config.ts`]).toArray()),
7522
- ...blueprint.bin ? { "build:src:bin": "vite build --config configs/src/vite.bin.config.ts" } : {},
7523
- ...blueprint.reporter ? { "build:src:reporter": "vite build --config configs/src/vite.reporter.config.ts" } : {},
7677
+ ...blueprint.bin.length > 0 ? { "build:src:bin": "vite build --config configs/src/vite.bin.config.ts" } : {},
7524
7678
  ...Object.fromEntries(source.map((name) => [`build:src:${name}`, `vite build --config configs/src/vite.${name}.config.ts`])),
7525
7679
  ...Object.fromEntries(targets.map((name) => [`build:src:${name}`, [`vite build --config configs/src/vite.${name}.config.ts`, ...name === "styles" && blueprint.themes ? ["vite build --config configs/src/vite.themes.config.ts"] : []].join(" && ")]))
7526
7680
  } : {},
@@ -7564,7 +7718,8 @@ function blueprintToScripts(blueprint) {
7564
7718
  * benchmark workbench scripts. A workspace carrying guides adds `test:guides`,
7565
7719
  * whose package-owned entry runs the guides project and handles explicit parity
7566
7720
  * rewrites, and one carrying skills adds `test:skills`. Publishing adds the pack and publication
7567
- * lifecycle scripts. Sheet and framework faces add their check and build scripts, application
7721
+ * lifecycle scripts. Library environments, sheet faces, framework faces, and `src/bin` modules
7722
+ * add their check and build scripts, application
7568
7723
  * frameworks add dev scripts, and selected showcases and journeys add their mode scripts.
7569
7724
  * A base browser application's journey axis also adds `journey` and `capture`, and each
7570
7725
  * app-side browser face adds `journey:<name>` and `capture:<name>`. Their generated
@@ -7577,10 +7732,11 @@ function blueprintToScripts(blueprint) {
7577
7732
  *
7578
7733
  * `accepted` carries each generated predecessor the region can replace. The
7579
7734
  * guides entry accepts the generated command that invoked the guides project
7580
- * through Vitest alone. The benchmark entry accepts the one command that ran the
7735
+ * through Vitest alone. The benchmark entry accepts the command that ran the
7581
7736
  * `probe` project through `vitest bench`, before the dedicated bench project
7582
- * existed. The pack hook accepts the build chain emitted before it
7583
- * delegated to `build`. The publication hook accepts the same gate chain without
7737
+ * existed, and the command planned for the other state of the browser bench project, so
7738
+ * the entry follows a browser-hosted face that arrives or leaves. The pack hook accepts the
7739
+ * build chain emitted before it delegated to `build`. The publication hook accepts the same gate chain without
7584
7740
  * {@link RELEASE_PROOF_COMMAND}. No accepted publication chain carries a study
7585
7741
  * step. `serve:build` accepts the server-only chain it ran before it delegated to `build`.
7586
7742
  * The value being written is always writable, so it is not repeated there. Any other value is a
@@ -7593,7 +7749,7 @@ function blueprintToScripts(blueprint) {
7593
7749
  *
7594
7750
  * const blueprint = createBlueprint('router', { src: ['core'] })
7595
7751
  *
7596
- * blueprintToWritableScripts(blueprint)[0]?.name // 'test:src:core'
7752
+ * blueprintToWritableScripts(blueprint)[0]?.name // 'check:src:core'
7597
7753
  * ```
7598
7754
  */
7599
7755
  function blueprintToWritableScripts(blueprint) {
@@ -7602,16 +7758,21 @@ function blueprintToWritableScripts(blueprint) {
7602
7758
  const body = Object.entries(scripts).flatMap(([name, command]) => {
7603
7759
  const direct = name.startsWith("test:") && name !== "test:src" && name !== "test:app";
7604
7760
  const sheet = sheets.some((face) => name === `build:src:${face}` || name === `check:src:${face}`);
7761
+ const entry = [...blueprint.src, "bin"].some((face) => name === `build:src:${face}` || name === `check:src:${face}`);
7605
7762
  const framework = blueprintToFaces(blueprint).some((extension) => extension.surface === "browser" && extension.axes.some((axis) => name === `check:${axis}:${extension.name}` || name === `build:${axis}:${extension.name}` || axis === "app" && (name === `dev:${extension.name}` || name === `journey:${extension.name}` || name === `capture:${extension.name}`)));
7606
7763
  const showcase = name === "showcase" || name.startsWith("showcase:") || name === "build:showcase" || name.startsWith("build:showcase:");
7607
7764
  const capture = name === "journey" || name === "capture";
7608
7765
  const barrel = matchesBarrel(blueprint) && name === "build:app:barrel";
7609
7766
  const served = blueprint.app.includes("server") && name === "serve:build";
7610
- if (!direct && !sheet && !framework && !showcase && !capture && !barrel && !served) return [];
7767
+ if (!direct && !sheet && !entry && !framework && !showcase && !capture && !barrel && !served) return [];
7611
7768
  return [{
7612
7769
  name,
7613
7770
  command,
7614
- accepted: name === "test:guides" ? ["vitest run --config vite.config.ts --no-cache --reporter=dot --project guides"] : name === "test:bench" ? ["vitest bench --config vite.config.ts --no-cache --project probe"] : name === "build:src:styles" && blueprint.themes ? ["vite build --config configs/src/vite.styles.config.ts"] : sheets.some((face) => name === `test:src:${face}`) ? [command.slice(command.indexOf(" && ") + 4)] : name === "serve:build" ? ["npm run build:app:server && npm run serve"] : []
7771
+ accepted: name === "test:guides" ? ["vitest run --config vite.config.ts --no-cache --reporter=dot --project guides"] : name === "test:bench" ? [
7772
+ "vitest bench --config vite.config.ts --no-cache --project probe",
7773
+ "vitest bench --config vite.config.ts --no-cache --project \"probe (bench)\" --mode benchmark",
7774
+ "vitest bench --config vite.config.ts --no-cache --project \"probe (bench)\" --project bench:browser --mode benchmark"
7775
+ ].filter((predecessor) => predecessor !== command) : name === "build:src:styles" && blueprint.themes ? ["vite build --config configs/src/vite.styles.config.ts"] : sheets.some((face) => name === `test:src:${face}`) ? [command.slice(command.indexOf(" && ") + 4)] : name === "serve:build" ? ["npm run build:app:server && npm run serve"] : []
7615
7776
  }];
7616
7777
  });
7617
7778
  const prepack = scripts.prepack;
@@ -7632,6 +7793,45 @@ function blueprintToWritableScripts(blueprint) {
7632
7793
  ];
7633
7794
  }
7634
7795
  /**
7796
+ * Projects a blueprint into the `bin`, `files`, and `exports` entries its manifest carries.
7797
+ *
7798
+ * @param blueprint - The workspace specification.
7799
+ * @returns The planned commands, packed paths, and subpaths, each in the order the manifest emits.
7800
+ *
7801
+ * @remarks
7802
+ * A workspace without an executable plans no command, and one publishing nothing plans no
7803
+ * subpath, because its manifest carries no `exports` map. `dist/src` is packed only where a
7804
+ * library environment or a sheet builds into it: an executable reaches `dist/src` only through
7805
+ * the `@src/*` specifiers its build rewrites, one per library environment, so an executable
7806
+ * beside no library environment bundles what it imports and packs `dist/bin` alone. A workspace
7807
+ * publishing nothing packs `dist/app` when it builds an application.
7808
+ *
7809
+ * @example
7810
+ * ```ts
7811
+ * import { blueprintToEntries, createBlueprint } from '@orkestrel/scaffold'
7812
+ *
7813
+ * blueprintToEntries(createBlueprint('router', { src: ['core'], bin: ['main'] })).files
7814
+ * // ['dist/src', 'dist/bin', 'README.md']
7815
+ * ```
7816
+ */
7817
+ function blueprintToEntries(blueprint) {
7818
+ const sheets = blueprintToSheets(blueprint);
7819
+ const targets = [...sheets, ...blueprint.themes ? ["styles/themes"] : []];
7820
+ const publishes = blueprint.src.length > 0 || targets.length > 0;
7821
+ return {
7822
+ bin: blueprint.bin.includes("main") ? { [blueprint.name]: BIN_OUTPUT_PATH } : {},
7823
+ files: [
7824
+ ...publishes ? ["dist/src"] : blueprint.app.length > 0 ? ["dist/app"] : [],
7825
+ ...blueprint.bin.length > 0 ? ["dist/bin"] : [],
7826
+ ...targets.map((face) => `!dist/src/${face}/index.js`),
7827
+ ...sheets.map((face) => `src/${face}/**/*.scss`),
7828
+ ...blueprint.themes && !blueprint.styles ? ["src/styles/themes/**/*.scss"] : [],
7829
+ "README.md"
7830
+ ],
7831
+ exports: publishes ? blueprintToExports(blueprint) : {}
7832
+ };
7833
+ }
7834
+ /**
7635
7835
  * Compiles a blueprint into its `package.json` content.
7636
7836
  *
7637
7837
  * @param blueprint - The workspace specification.
@@ -7667,8 +7867,7 @@ function blueprintToWritableScripts(blueprint) {
7667
7867
  * ```
7668
7868
  */
7669
7869
  function blueprintToManifest(blueprint) {
7670
- const sheets = blueprintToSheets(blueprint);
7671
- const targets = [...sheets, ...blueprint.themes ? ["styles/themes"] : []];
7870
+ const targets = [...blueprintToSheets(blueprint), ...blueprint.themes ? ["styles/themes"] : []];
7672
7871
  const publishes = blueprint.src.length > 0 || targets.length > 0;
7673
7872
  const name = publishes ? `@orkestrel/${blueprint.name}` : blueprint.name;
7674
7873
  const dependencies = Object.fromEntries(blueprint.dependencies.toSorted((left, right) => (0, _orkestrel_contract.comparePrimitives)(left.name, right.name)).map((dependency) => [dependency.name, dependency.range]));
@@ -7676,6 +7875,7 @@ function blueprintToManifest(blueprint) {
7676
7875
  const peerDependencies = Object.fromEntries(peers.map((peer) => [peer.name, peer.range]));
7677
7876
  const peerDependenciesMeta = Object.fromEntries(peers.filter((peer) => peer.optional === true).map((peer) => [peer.name, { optional: true }]));
7678
7877
  const entry = srcToEntry(blueprint.src);
7878
+ const entries = blueprintToEntries(blueprint);
7679
7879
  const manifest = {
7680
7880
  name,
7681
7881
  version: blueprint.version,
@@ -7691,21 +7891,13 @@ function blueprintToManifest(blueprint) {
7691
7891
  type: "git",
7692
7892
  url: `git+https://github.com/orkestrel/${blueprint.name}.git`
7693
7893
  } } : {},
7694
- ...blueprint.bin ? { bin: { [blueprint.name]: BIN_OUTPUT_PATH } } : {},
7695
- files: [
7696
- blueprint.bin || publishes ? "dist/src" : "dist/app",
7697
- ...blueprint.bin ? ["dist/bin"] : [],
7698
- ...blueprint.reporter ? ["dist/reporter"] : [],
7699
- ...targets.map((face) => `!dist/src/${face}/index.js`),
7700
- ...sheets.map((face) => `src/${face}/**/*.scss`),
7701
- ...blueprint.themes && !blueprint.styles ? ["src/styles/themes/**/*.scss"] : [],
7702
- "README.md"
7703
- ],
7894
+ ...blueprint.bin.includes("main") ? { bin: entries.bin } : {},
7895
+ files: entries.files,
7704
7896
  type: "module",
7705
7897
  ...publishes ? {
7706
- sideEffects: targets.length > 0 || blueprint.bin ? [...targets.length > 0 ? ["**/*.css", "**/*.scss"] : [], ...blueprint.bin ? [`./${BIN_ENTRY_PATH}`, `./${BIN_OUTPUT_PATH}`] : []] : false,
7898
+ sideEffects: targets.length > 0 || blueprint.bin.includes("main") ? [...targets.length > 0 ? ["**/*.css", "**/*.scss"] : [], ...blueprint.bin.includes("main") ? [`./${BIN_ENTRY_PATH}`, `./${BIN_OUTPUT_PATH}`] : []] : false,
7707
7899
  ...blueprint.src.length > 0 ? entry : {},
7708
- exports: blueprintToExports(blueprint),
7900
+ exports: entries.exports,
7709
7901
  publishConfig: { access: "public" }
7710
7902
  } : {},
7711
7903
  scripts: blueprintToScripts(blueprint),
@@ -7752,7 +7944,7 @@ function blueprintToMachinery(blueprint) {
7752
7944
  return {
7753
7945
  browser: blueprint.src.includes("browser") || blueprint.app.includes("browser") || blueprint.setup.includes("browser") || blueprintToSheets(blueprint).length > 0 || blueprint.themes || frameworks.length > 0,
7754
7946
  frameworks,
7755
- output: blueprint.src.length > 0 || blueprint.bin || blueprint.reporter || hosted || blueprintToSheets(blueprint).length > 0 || blueprint.themes,
7947
+ output: blueprint.src.length > 0 || blueprint.bin.length > 0 || hosted || blueprintToSheets(blueprint).length > 0 || blueprint.themes,
7756
7948
  showcase: blueprint.showcase && (blueprint.base && blueprint.app.includes("browser") || blueprintToFaces(blueprint).some((extension) => extension.axes.includes("app")))
7757
7949
  };
7758
7950
  }
@@ -7829,8 +8021,8 @@ function blueprintToRootTsconfig(blueprint) {
7829
8021
  * Projects a blueprint into the project labels its root Vitest configuration registers.
7830
8022
  *
7831
8023
  * @param blueprint - The workspace specification.
7832
- * @returns Project labels in registration order, including wrapper-registered sheet faces and
7833
- * the probe benchmark variant.
8024
+ * @returns Project labels in registration order, including wrapper-registered sheet faces,
8025
+ * the probe benchmark variant, and, beside a browser-hosted face, the browser bench project.
7834
8026
  *
7835
8027
  * @example
7836
8028
  * ```ts
@@ -7843,16 +8035,19 @@ function blueprintToProjects(blueprint) {
7843
8035
  const sheets = blueprintToSheets(blueprint);
7844
8036
  const styled = sheets.length > 0 || blueprint.themes;
7845
8037
  const faces = blueprintToFaces(blueprint);
7846
- return [
8038
+ const environments = AXES.flatMap((axis) => [
8039
+ ...ENVIRONMENTS.filter((environment) => (axis !== "app" || environment !== "server") && blueprint[axis].includes(environment)).map((environment) => `${axis}:${environment}`),
8040
+ ...faces.filter((face) => face.axes.includes(axis)).map((face) => `${axis}:${face.name}`),
8041
+ ...axis === "src" && blueprint.bin.length > 0 ? ["src:bin"] : [],
8042
+ ...axis === "app" && blueprint.app.includes("server") ? ["app:server"] : []
8043
+ ]);
8044
+ const labels = [
7847
8045
  ...sheets.map((name) => `src:${name}`),
7848
8046
  ...blueprint.themes && !blueprint.styles ? ["src:themes"] : [],
7849
- ...AXES.flatMap((axis) => [
7850
- ...ENVIRONMENTS.filter((environment) => (axis !== "app" || environment !== "server") && blueprint[axis].includes(environment)).map((environment) => `${axis}:${environment}`),
7851
- ...faces.filter((face) => face.axes.includes(axis)).map((face) => `${axis}:${face.name}`),
7852
- ...axis === "src" && blueprint.bin ? ["src:bin"] : [],
7853
- ...axis === "src" && blueprint.reporter ? ["src:reporter"] : [],
7854
- ...axis === "app" && blueprint.app.includes("server") ? ["app:server"] : []
7855
- ]),
8047
+ ...environments
8048
+ ];
8049
+ return [
8050
+ ...labels,
7856
8051
  "policy",
7857
8052
  "config",
7858
8053
  ...blueprint.setup.includes("node") || blueprint.global ? ["setup"] : [],
@@ -7866,7 +8061,8 @@ function blueprintToProjects(blueprint) {
7866
8061
  ...blueprint.src.length > 0 || styled ? ["distribution"] : [],
7867
8062
  ...blueprint.integration ? ["integration"] : [],
7868
8063
  "probe",
7869
- "probe (bench)"
8064
+ "probe (bench)",
8065
+ ...projectsToBenches(labels).length > 0 ? ["bench:browser"] : []
7870
8066
  ];
7871
8067
  }
7872
8068
  /**
@@ -7939,6 +8135,8 @@ function blueprintToRootVite(blueprint) {
7939
8135
  ...machinery.showcase ? ["import { viteSingleFile } from 'vite-plugin-singlefile'", "import { resolve as resolvePath } from 'node:path'"] : []
7940
8136
  ];
7941
8137
  const external = "external: resolveSourceExternal,";
8138
+ const benches = projectsToBenches([...planned]);
8139
+ const inlineBenches = `const browserBenches = [${benches.map((glob) => `'${glob}'`).join(", ")}]`;
7942
8140
  const factories = [
7943
8141
  ...blueprint.src.includes("browser") || blueprint.src.includes("server") ? [blueprint.src.includes("core") ? `function resolveSourceExternal(id: string): boolean {
7944
8142
  return (
@@ -7980,8 +8178,7 @@ function blueprintToRootVite(blueprint) {
7980
8178
  exclude: core ? " exclude: ['tests/src/core/**/*.test.ts'],\n" : ""
7981
8179
  })) : [],
7982
8180
  ...planned.has("src:vue") ? [CONFIG_TEMPLATES.factories.src.vue] : [],
7983
- ...planned.has("src:bin") ? [CONFIG_TEMPLATES.factories.src.bin] : [],
7984
- ...planned.has("src:reporter") ? [CONFIG_TEMPLATES.factories.src.reporter] : [],
8181
+ ...planned.has("src:bin") ? [(0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.factories.src.bin, { entries: blueprint.bin.map((name) => `\t\t\t\t\t${name}: resolveWorkspacePath(${serializeTypeScriptString(`src/bin/${name}.ts`)}),`).join("\n") })] : [],
7985
8182
  ...planned.has("app:core") ? [CONFIG_TEMPLATES.factories.app.core] : [],
7986
8183
  ...planned.has("app:browser") ? [(0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.factories.app.browser, {
7987
8184
  vuePlugin: machinery.frameworks.includes("vue") ? ", vue()" : "",
@@ -8008,7 +8205,14 @@ function blueprintToRootVite(blueprint) {
8008
8205
  ...planned.has("studies") ? [CONFIG_TEMPLATES.factories.studies] : [],
8009
8206
  ...planned.has("distribution") ? [CONFIG_TEMPLATES.factories.distribution] : [],
8010
8207
  ...planned.has("integration") ? [(0, _orkestrel_template.fillTemplate)(styled ? CONFIG_TEMPLATES.factories.integration.sheet : CONFIG_TEMPLATES.factories.integration.module, { global })] : [],
8011
- CONFIG_TEMPLATES.factories.probe
8208
+ (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.factories.probe, {
8209
+ benches: benches.length === 0 ? "" : `// A browser-hosted face's bench reads host APIs that Node lacks, so only \`bench:browser\` runs it.\n${matchesPrintWidth(inlineBenches) ? inlineBenches : `const browserBenches = [\n${benches.map((glob) => `\t'${glob}',`).join("\n")}\n]`}\n\n`,
8210
+ benchmark: benches.length === 0 ? " benchmark: { include: ['tmp/probes/**/*.bench.ts', 'tests/**/*.bench.ts'] },\n" : " benchmark: {\n include: ['tmp/probes/**/*.bench.ts', 'tests/**/*.bench.ts'],\n // A set `exclude` replaces Vitest's default, so the default is kept.\n exclude: [...defaultExclude, ...browserBenches],\n },\n"
8211
+ }),
8212
+ ...planned.has("bench:browser") ? [(0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.factories.bench, {
8213
+ optimization: machinery.frameworks.includes("vue") ? "optimizeDeps: { include: [...optimizeDeps.include, 'vue'] }" : "optimizeDeps",
8214
+ plugins: machinery.frameworks.includes("vue") ? " plugins: [vue()],\n" : ""
8215
+ })] : []
8012
8216
  ];
8013
8217
  const projects = [
8014
8218
  ...styled ? [...sheets.map((name) => `'./configs/src/vite.${name}.config.ts'`), ...planned.has("src:themes") ? ["'./configs/src/vite.themes.config.ts'"] : []] : [],
@@ -8017,7 +8221,6 @@ function blueprintToRootVite(blueprint) {
8017
8221
  ...planned.has("src:server") ? ["srcServer"] : [],
8018
8222
  ...planned.has("src:vue") ? ["srcVue"] : [],
8019
8223
  ...planned.has("src:bin") ? ["srcBin"] : [],
8020
- ...planned.has("src:reporter") ? ["srcReporter"] : [],
8021
8224
  ...planned.has("app:core") ? ["appCore"] : [],
8022
8225
  ...planned.has("app:browser") ? ["appBrowser"] : [],
8023
8226
  ...planned.has("app:vue") ? ["appVue"] : [],
@@ -8034,7 +8237,8 @@ function blueprintToRootVite(blueprint) {
8034
8237
  ...planned.has("studies") ? ["studies"] : [],
8035
8238
  ...planned.has("distribution") ? ["distribution"] : [],
8036
8239
  ...planned.has("integration") ? ["integration"] : [],
8037
- "probe"
8240
+ "probe",
8241
+ ...planned.has("bench:browser") ? ["benchBrowser"] : []
8038
8242
  ];
8039
8243
  const joinedProjects = `\t\tprojects: [${projects.join(", ")}],`;
8040
8244
  const projectRows = matchesPrintWidth(joinedProjects) ? joinedProjects : `\t\tprojects: [
@@ -8053,6 +8257,7 @@ ${projects.map((project) => `\t\t\t${project},`).join("\n")}
8053
8257
  return (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.root.vite, {
8054
8258
  journey: journeyed ? "import type { JourneyVariant } from '@orkestrel/test'\n" : "",
8055
8259
  imports: imports.length === 0 ? "" : `${imports.join("\n")}\n`,
8260
+ vitest: benches.length === 0 ? "" : "defaultExclude, ",
8056
8261
  helpers: helpers.length === 0 ? "" : matchesPrintWidth(helperImport.trimEnd()) ? helperImport : `import {\n${helpers.map((helper) => `\t${helper},`).join("\n")}\n} from './configs/helpers.js'\n`,
8057
8262
  browsers: machinery.browser ? "import { resolveBrowser, resolvePinnedBrowser } from './configs/browsers.js'\nimport { commands } from './configs/commands.js'\n" : "",
8058
8263
  options: (machinery.browser ? "const browserOptions = resolveBrowser(resolvePinnedBrowser(), process.platform, process.env)\n// Vitest writes a page.screenshot() capture beside its test file unless a directory is named.\nconst screenshots = resolveWorkspacePath('tmp/captures/screenshots')\n\n" + blueprintToOptimizedDependencies(blueprint) : "") + (journeyed ? "const capture = process.env.CAPTURE === '1'\n\n" : "") + ((blueprint.journey || blueprint.showcase) && (base || applicationFaces.length > 0) ? `const applications = {\n${base ? " browser: appBrowser,\n" : ""}${applicationFaces.map((extension) => `\t${extension.name}: app${extension.name[0]?.toUpperCase()}${extension.name.slice(1)},\n`).join("")}}\n\n` : ""),
@@ -8131,23 +8336,19 @@ function blueprintToConfigArtifacts(blueprint) {
8131
8336
  environment,
8132
8337
  content: path === "configs/src/tsconfig.core.json" ? CONFIG_TEMPLATES.tsconfigs.src.core : path === "configs/src/vite.browser.config.ts" ? CONFIG_TEMPLATES.vites.src.browser : path === "configs/src/tsconfig.browser.json" ? CONFIG_TEMPLATES.tsconfigs.src.browser : path === "configs/src/vite.server.config.ts" ? CONFIG_TEMPLATES.vites.src.server : path === "configs/src/tsconfig.server.json" ? CONFIG_TEMPLATES.tsconfigs.src.server : CONFIG_TEMPLATES.vites.src.core
8133
8338
  }))).toArray();
8134
- const paths = blueprint.bin || blueprint.reporter ? blueprint.src.map((environment) => `\t\t\t\t\t\t'@src/${environment}': '../src/${environment}/index.js',`) : [];
8339
+ const paths = blueprint.bin.length > 0 ? blueprint.src.map((environment) => `\t\t\t\t\t\t'@src/${environment}': '../src/${environment}/index.js',`) : [];
8135
8340
  const renderedPaths = paths.length === 0 ? " paths: {}," : `\t\t\t\t\tpaths: {
8136
8341
  ${paths.join("\n")}
8137
8342
  },`;
8138
- const bins = blueprint.bin ? BIN_CONFIGS.map((path) => ({
8139
- path,
8140
- group: "configs",
8141
- ownership: "content",
8142
- origin: "template",
8143
- content: path === "configs/src/tsconfig.bin.json" ? CONFIG_TEMPLATES.tsconfigs.bin : (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.vites.bin, { paths: renderedPaths })
8144
- })) : [];
8145
- const reporters = blueprint.reporter ? REPORTER_CONFIGS.map((path) => ({
8343
+ const bins = blueprint.bin.length > 0 ? BIN_CONFIGS.map((path) => ({
8146
8344
  path,
8147
8345
  group: "configs",
8148
8346
  ownership: "content",
8149
8347
  origin: "template",
8150
- content: path === "configs/src/tsconfig.reporter.json" ? CONFIG_TEMPLATES.tsconfigs.reporter : (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.vites.reporter, { paths: renderedPaths })
8348
+ content: path === "configs/src/tsconfig.bin.json" ? CONFIG_TEMPLATES.tsconfigs.bin : (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.vites.bin, {
8349
+ modules: blueprint.bin.filter((name) => name !== "main").map((name) => serializeTypeScriptString(name)).join(", "),
8350
+ paths: renderedPaths
8351
+ })
8151
8352
  })) : [];
8152
8353
  const barrels = matchesBarrel(blueprint) ? BARREL_CONFIGS.map((path) => ({
8153
8354
  path,
@@ -8261,7 +8462,6 @@ ${paths.join("\n")}
8261
8462
  ...sheets,
8262
8463
  ...sources,
8263
8464
  ...bins,
8264
- ...reporters,
8265
8465
  ...applications,
8266
8466
  ...barrels,
8267
8467
  ...faces,
@@ -8374,7 +8574,7 @@ function blueprintToSourceArtifacts(blueprint) {
8374
8574
  }))
8375
8575
  ] : [barrel];
8376
8576
  }));
8377
- const bin = blueprint.bin ? [{
8577
+ const bin = blueprint.bin.includes("main") ? [{
8378
8578
  path: BIN_ENTRY_PATH,
8379
8579
  group: "source",
8380
8580
  ownership: "birth",
@@ -8473,7 +8673,7 @@ function blueprintToTestArtifacts(blueprint) {
8473
8673
  environment: "browser",
8474
8674
  content: blueprint.journey ? ARTIFACT_TEMPLATES.tests.browser : ARTIFACT_TEMPLATES.tests.setup
8475
8675
  }] : [];
8476
- const servers = blueprint.src.includes("server") || blueprint.app.includes("server") || blueprint.bin || blueprint.reporter || blueprint.conformance || blueprint.tree ? [{
8676
+ const servers = blueprint.src.includes("server") || blueprint.app.includes("server") || blueprint.bin.length > 0 || blueprint.conformance || blueprint.tree ? [{
8477
8677
  path: "tests/setupServer.ts",
8478
8678
  group: "tests",
8479
8679
  ownership: "birth",
@@ -8530,20 +8730,13 @@ function blueprintToTestArtifacts(blueprint) {
8530
8730
  })).toArray();
8531
8731
  const binSpecifier = serializeTypeScriptString("../../../src/bin/main.js");
8532
8732
  const joinedImport = `\t\tconst entry = await import(${binSpecifier})`;
8533
- const bins = blueprint.bin ? [{
8733
+ const bins = blueprint.bin.includes("main") ? [{
8534
8734
  path: "tests/src/bin/main.test.ts",
8535
8735
  group: "tests",
8536
8736
  ownership: "birth",
8537
8737
  origin: "template",
8538
8738
  content: (0, _orkestrel_template.fillTemplate)(ARTIFACT_TEMPLATES.tests.bin, { import: matchesPrintWidth(joinedImport) ? joinedImport : `\t\tconst entry =\n\t\t\tawait import(${binSpecifier})` })
8539
8739
  }] : [];
8540
- const reporters = blueprint.reporter ? [{
8541
- path: "tests/src/reporter/main.test.ts",
8542
- group: "tests",
8543
- ownership: "birth",
8544
- origin: "template",
8545
- content: ARTIFACT_TEMPLATES.tests.reporter
8546
- }] : [];
8547
8740
  const applications = Iterator.from(blueprint.app).map((environment) => ({
8548
8741
  path: `tests/app/${environment}/index.test.ts`,
8549
8742
  group: "tests",
@@ -8622,7 +8815,6 @@ function blueprintToTestArtifacts(blueprint) {
8622
8815
  ...journeys,
8623
8816
  ...sources,
8624
8817
  ...bins,
8625
- ...reporters,
8626
8818
  ...applications,
8627
8819
  ...distributions,
8628
8820
  ...integrations
@@ -8655,14 +8847,10 @@ function blueprintToGuideArtifacts(blueprint) {
8655
8847
  directory: `src/${environment}`,
8656
8848
  test: `tests/src/${environment}`
8657
8849
  })),
8658
- ...blueprint.bin ? [{
8850
+ ...blueprint.bin.length > 0 ? [{
8659
8851
  directory: "src/bin",
8660
8852
  test: "tests/src/bin"
8661
8853
  }] : [],
8662
- ...blueprint.reporter ? [{
8663
- directory: "src/reporter",
8664
- test: "tests/src/reporter"
8665
- }] : [],
8666
8854
  ...[...blueprint.app, ...blueprintToFaces(blueprint).filter((extension) => extension.axes.includes("app")).map((extension) => extension.name)].map((environment) => ({
8667
8855
  directory: `app/${environment}`,
8668
8856
  test: `tests/app/${environment}`
@@ -9132,6 +9320,154 @@ function insertManifestSection(manifest, section, dependencies, present) {
9132
9320
  return [...Map.groupBy(placements, ({ position }) => position)].map(([position, group]) => [position, group.map(({ text }) => text).join("")]).sort(([left], [right]) => right - left).reduce((text, [position, insertion]) => text.slice(0, position) + insertion + text.slice(position), manifest);
9133
9321
  }
9134
9322
  /**
9323
+ * Inserts the planned `bin`, `files`, and `exports` entries a package manifest lacks.
9324
+ *
9325
+ * @param manifest - The manifest text to compile.
9326
+ * @param planned - The entries the plan emits, each in planned order.
9327
+ * @returns The manifest declaring every planned entry, or `undefined` when the text is not a
9328
+ * manifest object, or a section that must take an entry holds a value of another shape: `bin` not
9329
+ * an object, `exports` not a map of subpaths, or `files` not an array of strings.
9330
+ *
9331
+ * @remarks
9332
+ * The compiler inserts text instead of serializing the manifest, so every declared byte survives,
9333
+ * and a declared entry keeps its value whatever the plan holds. An inserted entry lands before the
9334
+ * first declared entry the plan orders after it, or after the last declared entry when none does,
9335
+ * and copies the indentation of the section's first entry; a nested value takes the same step per
9336
+ * level. An absent section is created as one top-level key holding the planned entries, before the
9337
+ * first declared key `MANIFEST_KEY_ORDER` orders after it, or last in the manifest object. A
9338
+ * manifest declaring every planned entry is returned unchanged.
9339
+ *
9340
+ * @example
9341
+ * ```ts
9342
+ * import { insertManifestEntries } from '@orkestrel/scaffold'
9343
+ *
9344
+ * insertManifestEntries('{\n\t"files": [\n\t\t"dist/src",\n\t\t"README.md"\n\t]\n}\n', {
9345
+ * bin: {},
9346
+ * files: ['dist/src', 'dist/bin', 'README.md'],
9347
+ * exports: {},
9348
+ * })
9349
+ * // '{\n\t"files": [\n\t\t"dist/src",\n\t\t"dist/bin",\n\t\t"README.md"\n\t]\n}\n'
9350
+ * ```
9351
+ */
9352
+ function insertManifestEntries(manifest, planned) {
9353
+ const parsed = (0, _orkestrel_contract.parseJSON)(manifest);
9354
+ const tokens = scanManifestTokens(manifest);
9355
+ if (!(0, _orkestrel_contract.isRecord)(parsed) || tokens === void 0) return void 0;
9356
+ const missing = manifestToEntries(manifest, planned);
9357
+ const keys = tokens.flatMap((token, at) => {
9358
+ const name = token.depth === 1 && token.value !== void 0 ? (0, _orkestrel_contract.parseJSON)(token.text) : void 0;
9359
+ return (0, _orkestrel_contract.isString)(name) && token.value !== void 0 ? [{
9360
+ name,
9361
+ index: token.index,
9362
+ value: token.value,
9363
+ at
9364
+ }] : [];
9365
+ });
9366
+ const open = tokens[0];
9367
+ const root = tokens.find((token) => token.text === "}" && token.depth === 0);
9368
+ const head = keys[0];
9369
+ if (open?.text !== "{" || root === void 0 || head === void 0) return void 0;
9370
+ const lineBreak = manifest.lastIndexOf("\n", head.index);
9371
+ const margin = lineBreak < 0 ? "" : manifest.slice(lineBreak + 1, head.index);
9372
+ const step = /\S/u.test(margin) ? "" : margin;
9373
+ const edits = [
9374
+ {
9375
+ name: "bin",
9376
+ array: false,
9377
+ members: Object.entries(missing.bin),
9378
+ order: Object.keys(planned.bin)
9379
+ },
9380
+ {
9381
+ name: "files",
9382
+ array: true,
9383
+ members: missing.files.map((path) => [path, path]),
9384
+ order: planned.files
9385
+ },
9386
+ {
9387
+ name: "exports",
9388
+ array: false,
9389
+ members: Object.entries(missing.exports),
9390
+ order: Object.keys(planned.exports)
9391
+ }
9392
+ ].map((section) => {
9393
+ if (section.members.length === 0) return [];
9394
+ const key = keys.find(({ name }) => name === section.name);
9395
+ if (key === void 0) {
9396
+ const value = section.array ? section.members.map(([path]) => path) : Object.fromEntries(section.members);
9397
+ const block = `${JSON.stringify(section.name)}: ${JSON.stringify(value, void 0, step).replaceAll("\n", `\n${margin}`)}`;
9398
+ const gap = step === "" ? "" : `\n${margin}`;
9399
+ const successors = MANIFEST_KEY_ORDER.slice(MANIFEST_KEY_ORDER.indexOf(section.name) + 1);
9400
+ const anchor = keys.find(({ name }) => successors.includes(name));
9401
+ const tail = open.index + 1 + manifest.slice(open.index + 1, root.index).trimEnd().length;
9402
+ return [anchor === void 0 ? {
9403
+ start: tail,
9404
+ end: tail,
9405
+ text: `,${gap}${block}`
9406
+ } : {
9407
+ start: anchor.index,
9408
+ end: anchor.index,
9409
+ text: `${block},${gap}`
9410
+ }];
9411
+ }
9412
+ const current = parsed[section.name];
9413
+ const length = (0, _orkestrel_contract.isArray)(current) && current.every(_orkestrel_contract.isString) ? current.length : void 0;
9414
+ if (manifest.charAt(key.value) !== (section.array ? "[" : "{")) return void 0;
9415
+ if (section.array && length === void 0) return void 0;
9416
+ if (section.name === "exports" && !isSubpathMap(current)) return void 0;
9417
+ const following = tokens.slice(key.at + 1);
9418
+ const strings = following.slice(0, length ?? 0);
9419
+ const last = strings.at(-1);
9420
+ const close = section.array ? manifest.indexOf("]", last === void 0 ? key.value + 1 : last.index + last.text.length) : following.find((token) => token.text === "}" && token.depth === 1)?.index ?? -1;
9421
+ if (close < 0) return void 0;
9422
+ const declared = (section.array ? strings : following).flatMap((token) => {
9423
+ const name = (0, _orkestrel_contract.parseJSON)(token.text);
9424
+ return (section.array || token.depth === 2 && token.value !== void 0) && token.index < close && (0, _orkestrel_contract.isString)(name) ? [{
9425
+ name,
9426
+ index: token.index
9427
+ }] : [];
9428
+ });
9429
+ const keyBreak = manifest.lastIndexOf("\n", key.index);
9430
+ const level = keyBreak < 0 ? "" : /^\s*/u.exec(manifest.slice(keyBreak + 1, key.index))?.[0] ?? "";
9431
+ const first = declared[0];
9432
+ const firstBreak = first === void 0 ? -1 : manifest.lastIndexOf("\n", first.index);
9433
+ const lead = first === void 0 || firstBreak < 0 ? "" : manifest.slice(firstBreak + 1, first.index);
9434
+ const indent = first === void 0 ? step === "" ? "" : `${level}${step}` : /\S/u.test(lead) ? "" : lead;
9435
+ const nested = indent.startsWith(level) ? indent.slice(level.length) : step;
9436
+ const lines = section.members.map(([name, value]) => section.array ? JSON.stringify(name) : `${JSON.stringify(name)}: ${JSON.stringify(value, void 0, nested).replaceAll("\n", `\n${indent}`)}`);
9437
+ const separator = indent === "" ? "" : `\n${indent}`;
9438
+ if (first === void 0) {
9439
+ const start = key.value + 1;
9440
+ const suffix = indent === "" ? "" : `\n${level}`;
9441
+ return [{
9442
+ start,
9443
+ end: close,
9444
+ text: `${lines.map((line) => `${separator}${line}`).join(",")}${suffix}`
9445
+ }];
9446
+ }
9447
+ const tail = key.value + 1 + manifest.slice(key.value + 1, close).trimEnd().length;
9448
+ return section.members.map(([name], position) => {
9449
+ const line = lines[position] ?? "";
9450
+ const rank = section.order.indexOf(name);
9451
+ const anchor = declared.find((entry) => section.order.indexOf(entry.name) > rank);
9452
+ return anchor === void 0 ? {
9453
+ start: tail,
9454
+ end: tail,
9455
+ text: `,${separator}${line}`
9456
+ } : {
9457
+ start: anchor.index,
9458
+ end: anchor.index,
9459
+ text: `${line},${separator}`
9460
+ };
9461
+ });
9462
+ });
9463
+ if (edits.some((edit) => edit === void 0)) return void 0;
9464
+ return [...Map.groupBy(edits.flatMap((edit) => edit ?? []), ({ start }) => start)].map(([start, group]) => ({
9465
+ start,
9466
+ end: Math.max(...group.map(({ end }) => end)),
9467
+ text: group.map(({ text }) => text).join("")
9468
+ })).sort((left, right) => right.start - left.start).reduce((text, edit) => text.slice(0, edit.start) + edit.text + text.slice(edit.end), manifest);
9469
+ }
9470
+ /**
9135
9471
  * Replaces named script values in package manifest text.
9136
9472
  *
9137
9473
  * @param manifest - The manifest text to compile.
@@ -9573,6 +9909,36 @@ function blueprintToQuestions(blueprint) {
9573
9909
  message: "integration drives features across environments, and this workspace declares fewer than two, so its seed composes nothing.",
9574
9910
  blocking: false
9575
9911
  }] : [],
9912
+ ...Iterator.from(blueprint.bin).map((name) => ({
9913
+ name,
9914
+ valid: isBinModule(name)
9915
+ })).toArray().flatMap(({ name, valid }, index, declared) => {
9916
+ if (!valid) return [{
9917
+ field: "bin",
9918
+ message: `${name} is not a src/bin module name: write 1 to ${String(203)} lowercase letters and digits, starting with a letter, that name no centralized file.`,
9919
+ blocking: true
9920
+ }];
9921
+ if (declared.findIndex((other) => other.name === name) < index) return [{
9922
+ field: "bin",
9923
+ message: `${name} is declared more than once on bin.`,
9924
+ blocking: true
9925
+ }];
9926
+ if (name === "main") return [];
9927
+ const subpaths = blueprintToExports({
9928
+ ...blueprint,
9929
+ bin: []
9930
+ });
9931
+ if (Object.hasOwn(subpaths, `./${name}`)) return [{
9932
+ field: "bin",
9933
+ message: `src/bin/${name}.ts publishes ./${name}, which src/${name} already publishes. Rename the module.`,
9934
+ blocking: true
9935
+ }];
9936
+ return Object.keys(subpaths).length === 0 ? [{
9937
+ field: "bin",
9938
+ message: `src/bin/${name}.ts publishes ./${name} through the exports map, and this workspace publishes no library environment or sheet, so its manifest carries no exports map.`,
9939
+ blocking: false
9940
+ }] : [];
9941
+ }),
9576
9942
  ...Iterator.from(blueprint.vendors).map((vendor) => ({
9577
9943
  vendor,
9578
9944
  valid: NAME_PATTERN.test(vendor)
@@ -9765,7 +10131,7 @@ function overridesToQuestions(overrides, artifacts) {
9765
10131
  * const blueprint = createBlueprint('router', {
9766
10132
  * src: ['core', 'server'],
9767
10133
  * dependencies: [{ name: '@orkestrel/emitter', range: '^0.0.5' }],
9768
- * bin: true,
10134
+ * bin: ['main'],
9769
10135
  * })
9770
10136
  *
9771
10137
  * blueprint.version // '0.0.1'
@@ -9788,8 +10154,7 @@ function createBlueprint(name, input) {
9788
10154
  version: input?.version ?? "0.0.1",
9789
10155
  engines: input?.engines ?? ">=22.18.0",
9790
10156
  overrides: input?.overrides ?? [],
9791
- bin: input?.bin ?? false,
9792
- reporter: input?.reporter ?? false,
10157
+ bin: input?.bin ?? [],
9793
10158
  setup: input?.setup ?? [],
9794
10159
  guides: input?.guides ?? false,
9795
10160
  integration: input?.integration ?? false,
@@ -10117,6 +10482,7 @@ exports.BARREL_CONFIGS = BARREL_CONFIGS;
10117
10482
  exports.BASE_DEV_DEPENDENCIES = BASE_DEV_DEPENDENCIES;
10118
10483
  exports.BIN_CONFIGS = BIN_CONFIGS;
10119
10484
  exports.BIN_ENTRY_PATH = BIN_ENTRY_PATH;
10485
+ exports.BIN_MODULE_PATTERN = BIN_MODULE_PATTERN;
10120
10486
  exports.BIN_OUTPUT_PATH = BIN_OUTPUT_PATH;
10121
10487
  exports.BROWSER_ENTRIES = BROWSER_ENTRIES;
10122
10488
  exports.BROWSE_DEV_DEPENDENCIES = BROWSE_DEV_DEPENDENCIES;
@@ -10127,6 +10493,7 @@ exports.CAPTURE_UPSTREAM = CAPTURE_UPSTREAM;
10127
10493
  exports.CATALOG_AGENT_PATH = CATALOG_AGENT_PATH;
10128
10494
  exports.CATALOG_END_MARKER = CATALOG_END_MARKER;
10129
10495
  exports.CATALOG_START_MARKER = CATALOG_START_MARKER;
10496
+ exports.CENTRAL_FILE_NAMES = CENTRAL_FILE_NAMES;
10130
10497
  exports.CONFIG_TEMPLATES = CONFIG_TEMPLATES;
10131
10498
  exports.CONFORMANCE_TEST_PATH = CONFORMANCE_TEST_PATH;
10132
10499
  exports.CONTROL_CHARACTER_PATTERN = CONTROL_CHARACTER_PATTERN;
@@ -10153,6 +10520,7 @@ exports.HOST_PATHS = HOST_PATHS;
10153
10520
  exports.INTEGRATION_TEST_PATH = INTEGRATION_TEST_PATH;
10154
10521
  exports.INVALID_PATH_CHARACTER_PATTERN = INVALID_PATH_CHARACTER_PATTERN;
10155
10522
  exports.JOURNEY_CONFIG_PATH = JOURNEY_CONFIG_PATH;
10523
+ exports.MANIFEST_KEY_ORDER = MANIFEST_KEY_ORDER;
10156
10524
  exports.MANIFEST_PATH = MANIFEST_PATH;
10157
10525
  exports.MAX_ARTIFACT_BYTES = MAX_ARTIFACT_BYTES;
10158
10526
  exports.MAX_ARTIFACT_HEX_LENGTH = MAX_ARTIFACT_HEX_LENGTH;
@@ -10176,9 +10544,6 @@ exports.ORKESTREL_RANGE_PATTERN = ORKESTREL_RANGE_PATTERN;
10176
10544
  exports.PRINT_WIDTH = PRINT_WIDTH;
10177
10545
  exports.REFERENCE_PATHS = REFERENCE_PATHS;
10178
10546
  exports.RELEASE_PROOF_COMMAND = RELEASE_PROOF_COMMAND;
10179
- exports.REPORTER_CONFIGS = REPORTER_CONFIGS;
10180
- exports.REPORTER_ENTRY_PATH = REPORTER_ENTRY_PATH;
10181
- exports.REPORTER_OUTPUT_PATH = REPORTER_OUTPUT_PATH;
10182
10547
  exports.RESERVED_SHEET_NAMES = RESERVED_SHEET_NAMES;
10183
10548
  exports.SEED_GUIDE_PATHS = SEED_GUIDE_PATHS;
10184
10549
  exports.SERVICE_SCRIPT_PATH = SERVICE_SCRIPT_PATH;
@@ -10215,6 +10580,7 @@ exports.artifactsToQuestions = artifactsToQuestions;
10215
10580
  exports.blueprintToConfigArtifacts = blueprintToConfigArtifacts;
10216
10581
  exports.blueprintToDevDependencies = blueprintToDevDependencies;
10217
10582
  exports.blueprintToDocumentArtifacts = blueprintToDocumentArtifacts;
10583
+ exports.blueprintToEntries = blueprintToEntries;
10218
10584
  exports.blueprintToExports = blueprintToExports;
10219
10585
  exports.blueprintToFaces = blueprintToFaces;
10220
10586
  exports.blueprintToGuideArtifacts = blueprintToGuideArtifacts;
@@ -10253,12 +10619,14 @@ exports.inferArtifactDrift = inferArtifactDrift;
10253
10619
  exports.inferArtifactGroup = inferArtifactGroup;
10254
10620
  exports.inferSurfaceSimilarity = inferSurfaceSimilarity;
10255
10621
  exports.insertManifestDependencies = insertManifestDependencies;
10622
+ exports.insertManifestEntries = insertManifestEntries;
10256
10623
  exports.insertManifestSection = insertManifestSection;
10257
10624
  exports.isArtifact = isArtifact;
10258
10625
  exports.isArtifactFinding = isArtifactFinding;
10259
10626
  exports.isArtifactGroup = isArtifactGroup;
10260
10627
  exports.isArtifactGroups = isArtifactGroups;
10261
10628
  exports.isAudit = isAudit;
10629
+ exports.isBinModule = isBinModule;
10262
10630
  exports.isBlueprint = isBlueprint;
10263
10631
  exports.isBrowserExtension = isBrowserExtension;
10264
10632
  exports.isCanonPath = isCanonPath;
@@ -10285,19 +10653,23 @@ exports.isScaffoldError = isScaffoldError;
10285
10653
  exports.isSheetName = isSheetName;
10286
10654
  exports.isSnapshot = isSnapshot;
10287
10655
  exports.isStylesExtension = isStylesExtension;
10656
+ exports.isSubpathMap = isSubpathMap;
10288
10657
  exports.isSurface = isSurface;
10289
10658
  exports.iterateAnswers = iterateAnswers;
10290
10659
  exports.manifestToDependencies = manifestToDependencies;
10660
+ exports.manifestToEntries = manifestToEntries;
10291
10661
  exports.manifestToName = manifestToName;
10292
10662
  exports.matchesArtifactDriftReachability = matchesArtifactDriftReachability;
10293
10663
  exports.matchesBarrel = matchesBarrel;
10294
10664
  exports.matchesEngines = matchesEngines;
10295
10665
  exports.matchesGuideRefusal = matchesGuideRefusal;
10296
10666
  exports.matchesOrchestrationPath = matchesOrchestrationPath;
10667
+ exports.matchesPackedPath = matchesPackedPath;
10297
10668
  exports.matchesPrintWidth = matchesPrintWidth;
10298
10669
  exports.matchesRange = matchesRange;
10299
10670
  exports.matchesSurfaceStructure = matchesSurfaceStructure;
10300
10671
  exports.nameToGuide = nameToGuide;
10672
+ exports.normalizePackagePath = normalizePackagePath;
10301
10673
  exports.overridesToQuestions = overridesToQuestions;
10302
10674
  exports.parseArtifactGroups = parseArtifactGroups;
10303
10675
  exports.parseBlueprint = parseBlueprint;
@@ -10309,6 +10681,7 @@ exports.pathToCondition = pathToCondition;
10309
10681
  exports.planToArtifactFindings = planToArtifactFindings;
10310
10682
  exports.planToHash = planToHash;
10311
10683
  exports.planToSummary = planToSummary;
10684
+ exports.projectsToBenches = projectsToBenches;
10312
10685
  exports.renderSkillPointer = renderSkillPointer;
10313
10686
  exports.replaceManifestOverride = replaceManifestOverride;
10314
10687
  exports.replaceManifestOverrides = replaceManifestOverrides;