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