@orkestrel/scaffold 0.0.133 → 0.0.135

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 (92) hide show
  1. package/dist/agents/skills/orkestrel-dispatch/scripts/bench.js +61 -96
  2. package/dist/agents/skills/orkestrel-dispatch/scripts/brief.js +48 -76
  3. package/dist/agents/skills/orkestrel-dispatch/scripts/chain.js +27 -66
  4. package/dist/agents/skills/orkestrel-dispatch/scripts/cite.js +31 -64
  5. package/dist/agents/skills/orkestrel-dispatch/scripts/launch.js +43 -57
  6. package/dist/agents/skills/orkestrel-dispatch/scripts/login.js +43 -86
  7. package/dist/agents/skills/orkestrel-dispatch/scripts/patch.js +68 -104
  8. package/dist/agents/skills/orkestrel-dispatch/scripts/result.js +35 -69
  9. package/dist/agents/skills/orkestrel-dispatch/scripts/sweep.js +47 -84
  10. package/dist/agents/skills/orkestrel-falsify/scripts/mutate.js +134 -116
  11. package/dist/agents/skills/orkestrel-harden/scripts/discovery.js +38 -90
  12. package/dist/agents/skills/orkestrel-harden/scripts/interleave.js +39 -103
  13. package/dist/agents/skills/orkestrel-harden/scripts/measure.js +40 -89
  14. package/dist/agents/skills/orkestrel-harden/scripts/titles.js +41 -87
  15. package/dist/agents/skills/orkestrel-parallel/scripts/cases.js +43 -88
  16. package/dist/agents/skills/orkestrel-parallel/scripts/lane.js +1568 -213
  17. package/dist/agents/skills/orkestrel-publish/scripts/compare.js +40 -60
  18. package/dist/agents/skills/orkestrel-publish/scripts/pins.js +47 -81
  19. package/dist/agents/skills/orkestrel-publish/scripts/steps.js +66 -104
  20. package/dist/agents/skills/orkestrel-publish/scripts/swap.js +74 -88
  21. package/dist/agents/skills/orkestrel-publish/scripts/wave.js +387 -109
  22. package/dist/agents/skills/orkestrel-publish/scripts/window.js +55 -96
  23. package/dist/agents/skills/orkestrel-scout/scripts/map.js +54 -101
  24. package/dist/bin/main.js +275 -33
  25. package/dist/bin/main.js.map +1 -1
  26. package/dist/host/AGENTS.md +1 -1
  27. package/dist/host/agents/skills/orkestrel-dispatch/scripts/bench.ts +81 -97
  28. package/dist/host/agents/skills/orkestrel-dispatch/scripts/brief.ts +64 -72
  29. package/dist/host/agents/skills/orkestrel-dispatch/scripts/chain.ts +41 -63
  30. package/dist/host/agents/skills/orkestrel-dispatch/scripts/cite.ts +56 -79
  31. package/dist/host/agents/skills/orkestrel-dispatch/scripts/launch.ts +61 -74
  32. package/dist/host/agents/skills/orkestrel-dispatch/scripts/login.ts +59 -89
  33. package/dist/host/agents/skills/orkestrel-dispatch/scripts/patch.ts +87 -106
  34. package/dist/host/agents/skills/orkestrel-dispatch/scripts/result.ts +57 -76
  35. package/dist/host/agents/skills/orkestrel-dispatch/scripts/sweep.ts +73 -88
  36. package/dist/host/agents/skills/orkestrel-falsify/SKILL.md +2 -2
  37. package/dist/host/agents/skills/orkestrel-falsify/scripts/mutate.ts +167 -119
  38. package/dist/host/agents/skills/orkestrel-harden/references/methods.md +1 -1
  39. package/dist/host/agents/skills/orkestrel-harden/scripts/discovery.ts +58 -75
  40. package/dist/host/agents/skills/orkestrel-harden/scripts/interleave.ts +55 -99
  41. package/dist/host/agents/skills/orkestrel-harden/scripts/measure.ts +59 -90
  42. package/dist/host/agents/skills/orkestrel-harden/scripts/titles.ts +60 -80
  43. package/dist/host/agents/skills/orkestrel-parallel/SKILL.md +4 -4
  44. package/dist/host/agents/skills/orkestrel-parallel/scripts/cases.ts +71 -108
  45. package/dist/host/agents/skills/orkestrel-parallel/scripts/lane.ts +1990 -274
  46. package/dist/host/agents/skills/orkestrel-publish/references/release.md +1 -0
  47. package/dist/host/agents/skills/orkestrel-publish/references/wave.md +28 -7
  48. package/dist/host/agents/skills/orkestrel-publish/scripts/compare.ts +58 -79
  49. package/dist/host/agents/skills/orkestrel-publish/scripts/pins.ts +66 -87
  50. package/dist/host/agents/skills/orkestrel-publish/scripts/steps.ts +84 -102
  51. package/dist/host/agents/skills/orkestrel-publish/scripts/swap.ts +92 -99
  52. package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +483 -127
  53. package/dist/host/agents/skills/orkestrel-publish/scripts/window.ts +82 -120
  54. package/dist/host/agents/skills/orkestrel-scout/SKILL.md +3 -3
  55. package/dist/host/agents/skills/orkestrel-scout/scripts/map.ts +85 -112
  56. package/dist/host/claude/agents/orkestrel.md +16 -16
  57. package/dist/host/claude/rules/architecture.md +1 -1
  58. package/dist/host/claude/rules/documentation.md +1 -1
  59. package/dist/host/claude/rules/patterns.md +7 -4
  60. package/dist/host/claude/rules/styles.md +1 -1
  61. package/dist/host/claude/rules/tests.md +3 -3
  62. package/dist/host/claude/rules/workspace.md +50 -37
  63. package/dist/host/configs/helpers.ts +117 -71
  64. package/dist/host/dotfiles/oxlintrc.json +6 -0
  65. package/dist/host/guides/agent.md +989 -395
  66. package/dist/host/guides/database.md +357 -342
  67. package/dist/host/guides/form.md +79 -4
  68. package/dist/host/guides/middleware.md +5 -5
  69. package/dist/host/guides/ollama.md +41 -42
  70. package/dist/host/guides/scaffold.md +170 -70
  71. package/dist/host/guides/study.md +12 -12
  72. package/dist/host/guides/table.md +20 -6
  73. package/dist/host/guides/test.md +166 -52
  74. package/dist/host/guides/toolbox.md +127 -81
  75. package/dist/host/guides/workspace.md +21 -14
  76. package/dist/host/manifest.json +54 -54
  77. package/dist/host/tests/config.test.ts +251 -7
  78. package/dist/host/tests/policy.test.ts +14 -21
  79. package/dist/host/tests/setupPolicy.ts +43 -36
  80. package/dist/src/core/index.cjs +533 -139
  81. package/dist/src/core/index.cjs.map +1 -1
  82. package/dist/src/core/index.d.cts +223 -16
  83. package/dist/src/core/index.d.ts +223 -16
  84. package/dist/src/core/index.js +524 -139
  85. package/dist/src/core/index.js.map +1 -1
  86. package/dist/src/server/index.cjs +23 -14
  87. package/dist/src/server/index.cjs.map +1 -1
  88. package/dist/src/server/index.d.cts +3 -2
  89. package/dist/src/server/index.d.ts +3 -2
  90. package/dist/src/server/index.js +24 -15
  91. package/dist/src/server/index.js.map +1 -1
  92. package/package.json +2 -2
@@ -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.133",
6
+ version: "0.0.135",
7
7
  description: "Scaffold workspaces with commands: new, audit, surface, repair, catalog, and overwrite.",
8
8
  keywords: [
9
9
  "audit",
@@ -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.36",
111
+ "@orkestrel/test": "^0.0.38",
112
112
  "@types/node": "^24.19.2",
113
113
  "@vitest/browser-playwright": "^5.1.0",
114
114
  "oxfmt": "^0.78.0",
@@ -249,10 +249,35 @@ var APP_MATRIX = Object.freeze({
249
249
  var BIN_CONFIGS = Object.freeze(["configs/src/vite.bin.config.ts", "configs/src/tsconfig.bin.json"]);
250
250
  /** Lists the configuration file a workspace with studies and a server application adds, frozen. */
251
251
  var BARREL_CONFIGS = Object.freeze(["configs/app/vite.barrel.config.ts"]);
252
- /** Names the executable entry whose presence makes a workspace `bin`. */
252
+ /** Names the executable entry, the `main` module of `src/bin`. */
253
253
  var BIN_ENTRY_PATH = "src/bin/main.ts";
254
254
  /** Names the built executable a bin workspace's manifest command runs. */
255
255
  var BIN_OUTPUT_PATH = "dist/bin/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
+ ]);
256
281
  /**
257
282
  * Lists the paths a target receives from the vendored data root, frozen.
258
283
  *
@@ -511,6 +536,42 @@ var RELEASE_PROOF_COMMAND = "npm run test:distribution -- --mode release";
511
536
  var INTEGRATION_TEST_PATH = "tests/integration.test.ts";
512
537
  /** Names the manifest path every compiler plan emits with birth ownership. */
513
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
+ ]);
514
575
  /** Names the official-tooling drift proof whose presence makes a workspace `conformance`. */
515
576
  var CONFORMANCE_TEST_PATH = "tests/conformance.test.ts";
516
577
  /** Names the real-tree proof whose presence makes a workspace `tree`. */
@@ -540,6 +601,8 @@ var JOURNEY_CONFIG_PATH = "configs/app/vite.journey.config.ts";
540
601
  var SKILLS_CONFIG_PATH = "configs/agents/tsconfig.skills.json";
541
602
  /** Matches the bare workspace name syntax: lowercase alphanumeric with hyphens, letter first. */
542
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]*$/;
543
606
  /**
544
607
  * Matches the runtime dependency name syntax: the `@orkestrel` scope and a bare name.
545
608
  *
@@ -673,6 +736,7 @@ var WORKSPACE_DEV_ENGINES = Object.freeze({ packageManager: Object.freeze({
673
736
  }) });
674
737
  /** Holds the baseline tooling versions, before framework holds apply. */
675
738
  var BASE_DEV_DEPENDENCIES = Object.freeze({
739
+ "@orkestrel/contract": package_default.dependencies["@orkestrel/contract"],
676
740
  "@orkestrel/guide": package_default.devDependencies["@orkestrel/guide"],
677
741
  "@orkestrel/probe": package_default.devDependencies["@orkestrel/probe"],
678
742
  "@orkestrel/scaffold": `^${package_default.version}`,
@@ -812,8 +876,6 @@ var BROWSE_UPSTREAM = Object.freeze([
812
876
  "@orkestrel/tool",
813
877
  "@orkestrel/websocket"
814
878
  ]);
815
- /** Names the development dependency every private `app` environment adds. */
816
- var APP_DEV_DEPENDENCIES = Object.freeze({ "@orkestrel/contract": package_default.dependencies["@orkestrel/contract"] });
817
879
  /** Lists the development dependencies a private browser application adds. */
818
880
  var APP_BROWSER_DEV_DEPENDENCIES = Object.freeze({
819
881
  ...SOURCE_BROWSER_DEV_DEPENDENCIES,
@@ -1209,8 +1271,8 @@ export function srcServer(override?: UserConfig): UserConfig {
1209
1271
  return mergeOverride(project, override)
1210
1272
  }
1211
1273
  `,
1212
- bin: `function resolveBinFilename(): string {
1213
- return 'main.js'
1274
+ bin: `function resolveBinFilename(_format: string, entry: string): string {
1275
+ return \`\${entry}.js\`
1214
1276
  }
1215
1277
 
1216
1278
  function resolveBinExternal(id: string): boolean {
@@ -1227,7 +1289,9 @@ export function srcBin(override?: UserConfig): UserConfig {
1227
1289
  sourcemap: true,
1228
1290
  minify: false,
1229
1291
  lib: {
1230
- entry: resolveWorkspacePath('${BIN_ENTRY_PATH}'),
1292
+ entry: {
1293
+ {{entries}}
1294
+ },
1231
1295
  formats: ['es'],
1232
1296
  fileName: resolveBinFilename,
1233
1297
  },
@@ -2079,22 +2143,28 @@ export default defineConfig(
2079
2143
  `
2080
2144
  }),
2081
2145
  bin: `import { defineConfig } from 'vite'
2082
- import { resolveExternal } from '../helpers.js'
2083
- import { peers, srcBin } from '../../vite.config.ts'
2084
-
2085
- // The \`scaffold\` executable build — a single ESM lib file, no declarations (an
2086
- // executable ships no types), with the \`#!/usr/bin/env node\` shebang re-emitted through
2087
- // \`output.banner\` (rolldown strips shebangs from source during bundling), and
2088
- // \`output.paths\` rewriting the externalized \`@src/*\` specifiers to the built sibling
2089
- // src environments (relative to \`dist/bin/\`), so the emitted bin resolves at runtime.
2146
+ import { declarationRollup, resolveExternal, rewriteSourceSpecifier } from '../helpers.js'
2147
+ import { peers, resolveWorkspacePath, srcBin } from '../../vite.config.ts'
2148
+
2149
+ // One ES file per \`src/bin\` module. Rolldown strips a source shebang, so \`main\` alone takes
2150
+ // the \`#!/usr/bin/env node\` banner; every other module ships its rolled-up declaration.
2151
+ // \`output.paths\` and the declaration rewrite point each external \`@src/*\` specifier at the
2152
+ // built environment beside \`dist/bin/\`.
2090
2153
  export default defineConfig(
2091
2154
  srcBin({
2155
+ plugins: [
2156
+ declarationRollup({
2157
+ project: resolveWorkspacePath('configs/src/tsconfig.bin.json'),
2158
+ entries: [{{modules}}],
2159
+ rewrite: rewriteSourceSpecifier,
2160
+ }),
2161
+ ],
2092
2162
  build: {
2093
2163
  rolldownOptions: {
2094
2164
  external: (id: string) =>
2095
2165
  id.startsWith('@src/') || resolveExternal(id, { peers, refused: [], siblings: [] }),
2096
2166
  output: {
2097
- banner: '#!/usr/bin/env node',
2167
+ banner: (chunk) => (chunk.name === 'main' ? '#!/usr/bin/env node' : ''),
2098
2168
  {{paths}}
2099
2169
  },
2100
2170
  },
@@ -2705,8 +2775,9 @@ describe('bin entry', () => {
2705
2775
  distribution: Object.freeze({
2706
2776
  module: `{{types}}import type { SpawnSyncReturns } from 'node:child_process'
2707
2777
  import type { TestContext } from 'vitest'
2778
+ import { arrayOf, isArray, isRecord, isString } from '@orkestrel/contract'
2708
2779
  import { spawnSync } from 'node:child_process'
2709
- import {
2780
+ {{events}}import {
2710
2781
  existsSync,
2711
2782
  mkdirSync,
2712
2783
  mkdtempSync,
@@ -2953,39 +3024,6 @@ export interface DistributionStage {
2953
3024
  readonly targets: readonly string[]
2954
3025
  }
2955
3026
 
2956
- /**
2957
- * Checks whether a value is a non-null object other than an array.
2958
- *
2959
- * @param value - The value to inspect.
2960
- * @returns True if the value is a record; false otherwise.
2961
- */
2962
- export function isDistributionRecord(value: unknown): value is Readonly<Record<string, unknown>> {
2963
- return typeof value === 'object' && value !== null && !Array.isArray(value)
2964
- }
2965
-
2966
- /**
2967
- * Checks whether a value is an array of strings.
2968
- *
2969
- * @param value - The value to inspect.
2970
- * @returns True if every array member is a string; false otherwise.
2971
- */
2972
- export function isDistributionNames(value: unknown): value is readonly string[] {
2973
- return Array.isArray(value) && value.every((name) => typeof name === 'string')
2974
- }
2975
-
2976
- // A fallback list, which is what Node reads an array in an exports entry as. The
2977
- // narrowing is what the following walkers need: \`Array.isArray\` widens an \`unknown\`
2978
- // member to \`any\`, and an entry read that way is not read at all.
2979
- /**
2980
- * Checks whether a value is a fallback array.
2981
- *
2982
- * @param value - The value to inspect.
2983
- * @returns True if the value is an array; false otherwise.
2984
- */
2985
- export function isDistributionList(value: unknown): value is readonly unknown[] {
2986
- return Array.isArray(value)
2987
- }
2988
-
2989
3027
  // Whether a string is a valid package target. Node rejects a target outside the
2990
3028
  // package and a target containing a dot, parent, or node_modules segment during
2991
3029
  // package-target resolution. A later module-resolution failure is not the same
@@ -3030,7 +3068,7 @@ export function readDistributionJSON(path: string): unknown {
3030
3068
  */
3031
3069
  export function readDistributionManifestName(path: string): string {
3032
3070
  const manifest = readDistributionJSON(path)
3033
- if (!isDistributionRecord(manifest) || typeof manifest.name !== 'string') {
3071
+ if (!isRecord(manifest) || typeof manifest.name !== 'string') {
3034
3072
  throw new Error(\`The manifest at \${path} declares no package name\`)
3035
3073
  }
3036
3074
  return manifest.name
@@ -3047,19 +3085,17 @@ export function readDistributionManifestName(path: string): string {
3047
3085
  */
3048
3086
  export function readDistributionPeers(path: string): Readonly<Record<string, string>> {
3049
3087
  const manifest = readDistributionJSON(path)
3050
- if (!isDistributionRecord(manifest) || !isDistributionRecord(manifest.peerDependencies)) {
3088
+ if (!isRecord(manifest) || !isRecord(manifest.peerDependencies)) {
3051
3089
  return {}
3052
3090
  }
3053
- const meta = isDistributionRecord(manifest.peerDependenciesMeta)
3054
- ? manifest.peerDependenciesMeta
3055
- : undefined
3091
+ const meta = isRecord(manifest.peerDependenciesMeta) ? manifest.peerDependenciesMeta : undefined
3056
3092
  const peers = Object.entries(manifest.peerDependencies).filter(
3057
3093
  (entry): entry is [string, string] => typeof entry[1] === 'string',
3058
3094
  )
3059
3095
  return Object.fromEntries(
3060
3096
  peers.filter(([name]) => {
3061
3097
  const entry = meta?.[name]
3062
- return !isDistributionRecord(entry) || entry.optional !== true
3098
+ return !isRecord(entry) || entry.optional !== true
3063
3099
  }),
3064
3100
  )
3065
3101
  }
@@ -3074,7 +3110,7 @@ export function createDistributionConsumerManifest(
3074
3110
  peers: Readonly<Record<string, string>>,
3075
3111
  ): string {
3076
3112
  const manifest: unknown = JSON.parse(DISTRIBUTION_CONSUMER_MANIFEST)
3077
- if (Object.keys(peers).length === 0 || !isDistributionRecord(manifest)) {
3113
+ if (Object.keys(peers).length === 0 || !isRecord(manifest)) {
3078
3114
  return DISTRIBUTION_CONSUMER_MANIFEST
3079
3115
  }
3080
3116
  return \`\${JSON.stringify({ ...manifest, dependencies: peers })}\\n\`
@@ -3195,7 +3231,7 @@ export function resolveDistributionPackageTarget(
3195
3231
  conditions: readonly string[],
3196
3232
  ): DistributionTargetResult | undefined {
3197
3233
  if (typeof entry === 'string') return { target: entry }
3198
- if (isDistributionList(entry)) {
3234
+ if (isArray(entry)) {
3199
3235
  for (const member of entry) {
3200
3236
  const resolved = resolveDistributionPackageTarget(member, conditions)
3201
3237
  if (resolved !== undefined && matchesDistributionPackageTarget(resolved.target))
@@ -3203,7 +3239,7 @@ export function resolveDistributionPackageTarget(
3203
3239
  }
3204
3240
  return undefined
3205
3241
  }
3206
- if (!isDistributionRecord(entry)) return undefined
3242
+ if (!isRecord(entry)) return undefined
3207
3243
  for (const [condition, nested] of Object.entries(entry)) {
3208
3244
  if (condition !== 'default' && !conditions.includes(condition)) continue
3209
3245
  const resolved = resolveDistributionPackageTarget(nested, conditions)
@@ -3288,14 +3324,14 @@ export function resolveDistributionDeclaration(
3288
3324
  installed: string,
3289
3325
  ): string | undefined {
3290
3326
  if (typeof entry === 'string') return targetToDistributionDeclaration(entry, installed)
3291
- if (isDistributionList(entry)) {
3327
+ if (isArray(entry)) {
3292
3328
  for (const member of entry) {
3293
3329
  const resolved = resolveDistributionDeclaration(member, conditions, installed)
3294
3330
  if (resolved !== undefined) return resolved
3295
3331
  }
3296
3332
  return undefined
3297
3333
  }
3298
- if (!isDistributionRecord(entry)) return undefined
3334
+ if (!isRecord(entry)) return undefined
3299
3335
  for (const [condition, nested] of Object.entries(entry)) {
3300
3336
  if (condition !== 'default' && !conditions.includes(condition)) continue
3301
3337
  const resolved = resolveDistributionDeclaration(nested, conditions, installed)
@@ -3328,7 +3364,7 @@ export function readDistributionPackageType(installed: string, target: string):
3328
3364
  if (scope === undefined) return undefined
3329
3365
  try {
3330
3366
  const manifest = readDistributionJSON(join(scope, 'package.json'))
3331
- return isDistributionRecord(manifest) ? manifest.type : undefined
3367
+ return isRecord(manifest) ? manifest.type : undefined
3332
3368
  } catch {
3333
3369
  return undefined
3334
3370
  }
@@ -3405,9 +3441,9 @@ export function declaresDistributionCommonJS(entry: unknown, installed: string):
3405
3441
  */
3406
3442
  export function collectDistributionTargets(entry: unknown): readonly string[] {
3407
3443
  if (typeof entry === 'string') return [entry]
3408
- if (isDistributionList(entry))
3444
+ if (isArray(entry))
3409
3445
  return entry.flatMap(collectDistributionTargets).filter(matchesDistributionPackageTarget)
3410
- if (!isDistributionRecord(entry)) return []
3446
+ if (!isRecord(entry)) return []
3411
3447
  return Object.values(entry).flatMap((nested) => collectDistributionTargets(nested))
3412
3448
  }
3413
3449
 
@@ -3538,7 +3574,7 @@ export function filterDistributionUntypable(
3538
3574
  return entries.filter(
3539
3575
  (entry) =>
3540
3576
  entry.requirable &&
3541
- isDistributionRecord(entry.mapping) &&
3577
+ isRecord(entry.mapping) &&
3542
3578
  Object.hasOwn(entry.mapping, 'require') &&
3543
3579
  !declaresDistributionCommonJS(entry.mapping, installed),
3544
3580
  )
@@ -3728,7 +3764,7 @@ export function driveDistributionRuntime(
3728
3764
  )
3729
3765
  }
3730
3766
  const published: unknown = JSON.parse(result.stdout)
3731
- if (!isDistributionNames(published))
3767
+ if (!arrayOf(isString)(published))
3732
3768
  throw new Error(\`The driver printed no name list for \${specifier}\`)
3733
3769
  return published
3734
3770
  }
@@ -3774,7 +3810,7 @@ export function buildDistributionStage(scratch: string): DistributionStage {
3774
3810
  const name = readDistributionManifestName(join(DISTRIBUTION_ROOT, 'package.json'))
3775
3811
  const installed = join(consumer, 'node_modules', ...name.split('/'))
3776
3812
  const manifest = readDistributionJSON(join(installed, 'package.json'))
3777
- if (!isDistributionRecord(manifest) || !isDistributionRecord(manifest.exports)) {
3813
+ if (!isRecord(manifest) || !isRecord(manifest.exports)) {
3778
3814
  throw new Error('The installed manifest publishes no exports map')
3779
3815
  }
3780
3816
  return { consumer, installed, archives, ...classifyDistributionStage(manifest, installed, name) }
@@ -3869,7 +3905,7 @@ export function classifyDistributionStage(
3869
3905
  installed: string,
3870
3906
  name: string,
3871
3907
  ): DistributionClassification {
3872
- if (!isDistributionRecord(manifest.exports))
3908
+ if (!isRecord(manifest.exports))
3873
3909
  throw new Error('The installed manifest publishes no exports map')
3874
3910
  const readings = Object.entries(manifest.exports).map(([subpath, mapping]) => {
3875
3911
  const files = collectDistributionTargets(mapping)
@@ -3956,13 +3992,7 @@ export function collectDistributionFiles(directory: string): readonly string[] {
3956
3992
  */
3957
3993
  export function readDistributionFace(installed: string, path: string): string | undefined {
3958
3994
  const [output, axis, face] = relativePath(installed, path).split(sep)
3959
- return output === 'dist'
3960
- ? axis === 'src'
3961
- ? face
3962
- : axis === 'bin'
3963
- ? 'bin'
3964
- : undefined
3965
- : undefined
3995
+ return output === 'dist' ? (axis === 'src' ? face : axis === 'bin' ? axis : undefined) : undefined
3966
3996
  }
3967
3997
 
3968
3998
  /**
@@ -4048,8 +4078,8 @@ export function scanDistributionSourceMaps(installed: string): readonly string[]
4048
4078
  : Buffer.from(payload[2], 'base64').toString('utf8'),
4049
4079
  )
4050
4080
  if (
4051
- !isDistributionRecord(map) ||
4052
- !isDistributionNames(map.sources) ||
4081
+ !isRecord(map) ||
4082
+ !arrayOf(isString)(map.sources) ||
4053
4083
  (map.sourceRoot !== undefined && typeof map.sourceRoot !== 'string')
4054
4084
  ) {
4055
4085
  throw new Error('Unreadable source map')
@@ -4215,8 +4245,7 @@ export function checkDistributionManifest(installed: string, scratch: string): r
4215
4245
  if (result.status !== 0)
4216
4246
  throw new Error(\`npm pkg fix failed: \${readDistributionOutput(result)}\`)
4217
4247
  const after = readDistributionJSON(path)
4218
- if (!isDistributionRecord(before) || !isDistributionRecord(after))
4219
- throw new Error('Unreadable manifest')
4248
+ if (!isRecord(before) || !isRecord(after)) throw new Error('Unreadable manifest')
4220
4249
  return [...new Set([...Object.keys(before), ...Object.keys(after)])]
4221
4250
  .filter((key) => !isDeepStrictEqual(before[key], after[key]))
4222
4251
  .sort()
@@ -4268,7 +4297,7 @@ export function buildDistributionCases(
4268
4297
  writeDistributionFile(join(root, 'module/package.json'), '{ "type": "module" }\\n')
4269
4298
  writeDistributionFile(join(root, 'commonjs/package.json'), '{ "type": "commonjs" }\\n')
4270
4299
  const manifest = readDistributionJSON(join(root, 'package.json'))
4271
- if (!isDistributionRecord(manifest) || !isDistributionRecord(manifest.exports)) {
4300
+ if (!isRecord(manifest) || !isRecord(manifest.exports)) {
4272
4301
  throw new Error('The classifier fixture declares no exports map')
4273
4302
  }
4274
4303
  const mappings = manifest.exports
@@ -4393,7 +4422,7 @@ export function buildDistributionCases(
4393
4422
  },
4394
4423
  expected: {
4395
4424
  undeclared: [],
4396
- partitioned: [...stage.subpaths].sort(),
4425
+ partitioned: stage.subpaths.toSorted(),
4397
4426
  unreachable: [],
4398
4427
  untypable: [],
4399
4428
  },
@@ -4539,6 +4568,8 @@ describe('installed package consumer', () => {
4539
4568
  })
4540
4569
  }
4541
4570
  {{guard}}{{drive}}})
4571
+ `,
4572
+ events: `import { once } from 'node:events'
4542
4573
  `,
4543
4574
  transport: `import { createServer } from 'node:http'
4544
4575
  `,
@@ -4667,9 +4698,8 @@ export async function readDistributionBrowserExports(
4667
4698
  response.end(readFileSync(path))
4668
4699
  })
4669
4700
  try {
4670
- await new Promise<void>((settle) => {
4671
- server.listen(0, '127.0.0.1', settle)
4672
- })
4701
+ server.listen(0, '127.0.0.1')
4702
+ await once(server, 'listening')
4673
4703
  const address = server.address()
4674
4704
  if (address === null || typeof address === 'string') {
4675
4705
  throw new Error('The bundle server bound no port')
@@ -4680,8 +4710,7 @@ export async function readDistributionBrowserExports(
4680
4710
  await page.goto(\`http://127.0.0.1:\${String(address.port)}/\`, { waitUntil: 'load' })
4681
4711
  const published: unknown = await page.evaluate('globalThis.subject')
4682
4712
  if (failures.length > 0) throw new Error(\`The bundle raised \${failures.join(' | ')}\`)
4683
- if (!isDistributionNames(published))
4684
- throw new Error('The bundled module published no name list')
4713
+ if (!arrayOf(isString)(published)) throw new Error('The bundled module published no name list')
4685
4714
  return published
4686
4715
  } finally {
4687
4716
  server.close()
@@ -5001,6 +5030,29 @@ function isCollection(value) {
5001
5030
  return holds(() => isArray(value) && value.length <= 1e3);
5002
5031
  }
5003
5032
  /**
5033
+ * Narrows a manifest `exports` value to a map of subpaths.
5034
+ *
5035
+ * @param value - The declared `exports` value.
5036
+ * @returns True if the value is an object whose every key opens with `.`; false otherwise.
5037
+ *
5038
+ * @remarks
5039
+ * Node reads a string, an array, or an object whose keys are conditions, such as `import` and
5040
+ * `require`, as the root export alone, and refuses an object that mixes conditions with subpaths,
5041
+ * so a subpath can be added only to a subpath map. A value whose keys cannot be read answers
5042
+ * `false`.
5043
+ *
5044
+ * @example
5045
+ * ```ts
5046
+ * import { isSubpathMap } from '@orkestrel/scaffold'
5047
+ *
5048
+ * isSubpathMap({ '.': './index.js' }) // true
5049
+ * isSubpathMap({ import: './index.js' }) // false
5050
+ * ```
5051
+ */
5052
+ function isSubpathMap(value) {
5053
+ return holds(() => isRecord(value) && Object.keys(value).every((key) => key.startsWith(".")));
5054
+ }
5055
+ /**
5004
5056
  * Narrows a value to one {@link Environment} a workspace may select.
5005
5057
  *
5006
5058
  * @example
@@ -5041,6 +5093,22 @@ function isSheetName(value) {
5041
5093
  return isString(value) && value.length <= 203 && NAME_PATTERN.test(value) && !RESERVED_SHEET_NAMES.includes(value);
5042
5094
  }
5043
5095
  /**
5096
+ * Narrows a value to the stem of a `src/bin` module.
5097
+ * @param value - The candidate stem.
5098
+ * @returns True if the stem matches `BIN_MODULE_PATTERN` within the name length cap and names no
5099
+ * centralized file; false otherwise.
5100
+ * @example
5101
+ * ```ts
5102
+ * import { isBinModule } from '@orkestrel/scaffold'
5103
+ *
5104
+ * isBinModule('reporter') // true
5105
+ * isBinModule('helpers') // false
5106
+ * ```
5107
+ */
5108
+ function isBinModule(value) {
5109
+ return isString(value) && value.length <= 203 && BIN_MODULE_PATTERN.test(value) && !CENTRAL_FILE_NAMES.includes(value);
5110
+ }
5111
+ /**
5044
5112
  * Narrows a value to a supported browser framework with distinct occupied axes.
5045
5113
  * @param value - The candidate extension.
5046
5114
  * @returns True if the value is an admitted extension; false otherwise.
@@ -5232,7 +5300,7 @@ var isBlueprint = recordOf({
5232
5300
  version: isString,
5233
5301
  engines: isString,
5234
5302
  overrides: andOf(isCollection, arrayOf(isOverride)),
5235
- bin: isBoolean,
5303
+ bin: andOf(isCollection, arrayOf(isString)),
5236
5304
  setup: andOf(isCollection, arrayOf(literalOf("node", "browser"))),
5237
5305
  guides: isBoolean,
5238
5306
  integration: isBoolean,
@@ -6842,6 +6910,106 @@ function manifestToDependencies(manifest) {
6842
6910
  };
6843
6911
  }
6844
6912
  /**
6913
+ * Projects a package manifest's text to the planned `bin`, `files`, and `exports` entries it lacks.
6914
+ *
6915
+ * @param manifest - The `package.json` text.
6916
+ * @param planned - The entries the plan emits.
6917
+ * @returns The planned entries the manifest does not declare, each in planned order.
6918
+ *
6919
+ * @remarks
6920
+ * A planned command counts as declared when the manifest names it, or when any declared command
6921
+ * runs the planned file: a package keeps the command name it publishes. A string `bin` declares
6922
+ * the planned command when it names the planned file. A planned packed path counts as declared
6923
+ * when a declared path equals it or names a directory above it, as {@link matchesPackedPath} reads
6924
+ * the pair. A subpath counts as declared by name alone, so a declared entry holding another value
6925
+ * stays the package's. A string `exports`, a fallback array, or an object whose keys are conditions
6926
+ * rather than subpaths declares the root subpath `.` alone, as Node reads each. A section holding any other shape declares none of
6927
+ * its planned entries. A manifest that is not an object lacks nothing, because no entry can be read
6928
+ * from it or written into it.
6929
+ *
6930
+ * @example
6931
+ * ```ts
6932
+ * import { manifestToEntries } from '@orkestrel/scaffold'
6933
+ *
6934
+ * manifestToEntries('{"files": ["dist/src"]}', {
6935
+ * bin: {},
6936
+ * files: ['dist/src', 'dist/bin'],
6937
+ * exports: {},
6938
+ * }).files // ['dist/bin']
6939
+ * ```
6940
+ */
6941
+ function manifestToEntries(manifest, planned) {
6942
+ const parsed = parseJSON(manifest);
6943
+ if (!isRecord(parsed)) return {
6944
+ bin: {},
6945
+ files: [],
6946
+ exports: {}
6947
+ };
6948
+ const { bin, files, exports } = parsed;
6949
+ const commands = isString(bin) ? { "": bin } : isRecord(bin) ? bin : {};
6950
+ const runs = Object.values(commands).flatMap((path) => isString(path) ? [normalizePackagePath(path)] : []);
6951
+ const packed = isArray(files) ? files.filter(isString) : [];
6952
+ const subpaths = isSubpathMap(exports) ? exports : isString(exports) || isArray(exports) || isRecord(exports) ? { ".": exports } : {};
6953
+ return {
6954
+ bin: Object.fromEntries(Object.entries(planned.bin).filter(([name, path]) => !(isRecord(bin) && Object.hasOwn(bin, name)) && !runs.includes(normalizePackagePath(path)))),
6955
+ files: planned.files.filter((path) => !packed.some((declared) => matchesPackedPath(declared, path))),
6956
+ exports: Object.fromEntries(Object.entries(planned.exports).filter(([path]) => !Object.hasOwn(subpaths, path)))
6957
+ };
6958
+ }
6959
+ /**
6960
+ * Returns the canonical form of a path a manifest names inside its package.
6961
+ *
6962
+ * @param path - A `bin` target or a `files` entry.
6963
+ * @returns The path with `/` for every backslash, one `/` for every run of separators, and no
6964
+ * leading `./` or trailing `/`.
6965
+ *
6966
+ * @remarks
6967
+ * npm reads a backslash in a `bin` or `files` path as a separator and collapses repeated
6968
+ * separators, so `dist\bin\main.js` and `dist//bin/main.js` name `dist/bin/main.js`.
6969
+ *
6970
+ * @example
6971
+ * ```ts
6972
+ * import { normalizePackagePath } from '@orkestrel/scaffold'
6973
+ *
6974
+ * normalizePackagePath('./dist/bin/main.js') // 'dist/bin/main.js'
6975
+ * normalizePackagePath('dist//bin/main.js') // 'dist/bin/main.js'
6976
+ * ```
6977
+ */
6978
+ function normalizePackagePath(path) {
6979
+ return path.replaceAll("\\", "/").replace(/\/{2,}/gu, "/").replace(/^(\.\/)+/u, "").replace(/\/+$/u, "");
6980
+ }
6981
+ /**
6982
+ * Checks whether a declared `files` entry packs a planned one.
6983
+ *
6984
+ * @param declared - The entry the manifest declares.
6985
+ * @param planned - The entry the plan emits.
6986
+ * @returns True if the entries are equal, or the declared entry names a directory whose path
6987
+ * segments open the planned entry's; false otherwise.
6988
+ *
6989
+ * @remarks
6990
+ * A declared entry ending in `/**` or `/*` packs the directory it names, so `dist/**` packs
6991
+ * `dist/app`. No other glob is read: an entry such as `dist/*.js` packs no planned path it does not
6992
+ * equal. A negated entry such as `!dist/src/styles/index.js` excludes a path rather than packing
6993
+ * one, so only an equal entry declares it.
6994
+ *
6995
+ * @example
6996
+ * ```ts
6997
+ * import { matchesPackedPath } from '@orkestrel/scaffold'
6998
+ *
6999
+ * matchesPackedPath('dist', 'dist/app') // true
7000
+ * matchesPackedPath('dist-old', 'dist/app') // false
7001
+ * ```
7002
+ */
7003
+ function matchesPackedPath(declared, planned) {
7004
+ const left = normalizePackagePath(declared).replace(/\/\*\*?$/u, "");
7005
+ const right = normalizePackagePath(planned);
7006
+ if (left === right) return true;
7007
+ if (left.startsWith("!") || right.startsWith("!") || left === "") return false;
7008
+ const segments = left.split("/");
7009
+ const target = right.split("/");
7010
+ return segments.length < target.length && segments.every((segment, index) => segment === target[index]);
7011
+ }
7012
+ /**
6845
7013
  * Renders the `SKILL.md` pointer a target carries in place of a canonical skill.
6846
7014
  *
6847
7015
  * @param canonical - The canonical `SKILL.md` text, which opens with a frontmatter block.
@@ -6952,9 +7120,10 @@ function blueprintToSheets(blueprint) {
6952
7120
  return [...blueprint.styles ? ["styles"] : [], ...sortValues(blueprint.extensions.flatMap((extension) => extension.surface === "styles" && isSheetName(extension.name) ? [extension.name] : []))];
6953
7121
  }
6954
7122
  /**
6955
- * Projects published environments and sheets into the manifest export map.
7123
+ * Projects published environments, sheets, and `src/bin` modules into the manifest export map.
6956
7124
  * @param blueprint - The workspace specification.
6957
- * @returns JavaScript conditions and CSS and SCSS subpaths, without an invented JavaScript root.
7125
+ * @returns JavaScript conditions, CSS and SCSS subpaths, and the ES-only `./<name>` subpath of
7126
+ * each `src/bin` module other than `main`, without an invented JavaScript root.
6958
7127
  * @example
6959
7128
  * ```ts
6960
7129
  * import { blueprintToExports, createBlueprint } from '@orkestrel/scaffold'
@@ -6970,7 +7139,8 @@ function blueprintToExports(blueprint) {
6970
7139
  const face = [`./${extension.name}`, pathToCondition(`./dist/src/${extension.name}/index`, ["es"])];
6971
7140
  return blueprint.src.includes("browser") ? [face, ["./browser", pathToCondition("./dist/src/browser/index", ["es"])]] : [face];
6972
7141
  })),
6973
- ...Object.fromEntries([...blueprintToSheets(blueprint), ...blueprint.themes ? ["styles/themes"] : []].flatMap((name) => [[`./${name}`, `./dist/src/${name}/index.css`], [`./${name}/scss`, `./src/${name}/index.scss`]]))
7142
+ ...Object.fromEntries([...blueprintToSheets(blueprint), ...blueprint.themes ? ["styles/themes"] : []].flatMap((name) => [[`./${name}`, `./dist/src/${name}/index.css`], [`./${name}/scss`, `./src/${name}/index.scss`]])),
7143
+ ...Object.fromEntries(blueprint.bin.flatMap((name) => name === "main" ? [] : [[`./${name}`, pathToCondition(`./dist/bin/${name}`, ["es"])]]))
6974
7144
  };
6975
7145
  return Object.keys(exported).length > 0 ? {
6976
7146
  ...exported,
@@ -7144,9 +7314,8 @@ function blueprintToDevDependencies(blueprint) {
7144
7314
  ...rendered && !BROWSE_UPSTREAM.includes(own) ? BROWSE_DEV_DEPENDENCIES : {},
7145
7315
  ...blueprint.journey && blueprint.app.includes("browser") && (blueprint.base || blueprintToFaces(blueprint).some((extension) => extension.axes.includes("app"))) && !CAPTURE_UPSTREAM.includes(own) ? CAPTURE_DEV_DEPENDENCIES : {},
7146
7316
  ...sheets ? STYLES_DEV_DEPENDENCIES : {},
7147
- ...blueprint.src.length > 0 || blueprint.bin ? DECLARATION_DEV_DEPENDENCIES : {},
7317
+ ...blueprint.src.length > 0 || blueprint.bin.length > 0 ? DECLARATION_DEV_DEPENDENCIES : {},
7148
7318
  ...blueprint.src.includes("browser") || blueprint.setup.includes("browser") || sheets ? SOURCE_BROWSER_DEV_DEPENDENCIES : {},
7149
- ...blueprint.app.length > 0 ? APP_DEV_DEPENDENCIES : {},
7150
7319
  ...blueprint.app.includes("browser") ? APP_BROWSER_DEV_DEPENDENCIES : {},
7151
7320
  ...blueprint.app.includes("server") ? APP_SERVER_DEV_DEPENDENCIES : {},
7152
7321
  ...Object.fromEntries(blueprintToMachinery(blueprint).frameworks.flatMap((framework) => Object.entries(FRAMEWORK_MATRIX[framework].dependencies))),
@@ -7338,7 +7507,7 @@ function blueprintToScripts(blueprint) {
7338
7507
  const checker = application.includes("vue") ? FRAMEWORK_MATRIX.vue.checker : "tsc";
7339
7508
  const publishes = blueprint.src.length > 0 || targets.length > 0;
7340
7509
  const integrates = blueprint.integration;
7341
- const compiles = publishes || blueprint.bin;
7510
+ const compiles = publishes || blueprint.bin.length > 0;
7342
7511
  const runtime = blueprint.app.filter((environment) => environment !== "core" && (environment !== "browser" || base));
7343
7512
  const vitest = "vitest run --config vite.config.ts --no-cache --reporter=dot";
7344
7513
  const built = [...runtime, ...application].flatMap((environment) => environment === "server" && matchesBarrel(blueprint) ? [environment, "barrel"] : [environment]);
@@ -7346,7 +7515,7 @@ function blueprintToScripts(blueprint) {
7346
7515
  ...blueprint.src,
7347
7516
  ...source,
7348
7517
  ...sheets,
7349
- ...blueprint.bin ? ["bin"] : []
7518
+ ...blueprint.bin.length > 0 ? ["bin"] : []
7350
7519
  ].map((name) => `npm run check:src:${name}`);
7351
7520
  const journey = `vitest run --config ${JOURNEY_CONFIG_PATH} --no-cache --reporter=dot`;
7352
7521
  const showcase = `vite --config ${SHOWCASE_CONFIG_PATH}`;
@@ -7367,7 +7536,7 @@ function blueprintToScripts(blueprint) {
7367
7536
  ...checks.length > 0 ? {
7368
7537
  "check:src": checks.join(" && "),
7369
7538
  ...Object.fromEntries(Iterator.from(blueprint.src).map((environment) => [`check:src:${environment}`, `tsc --noEmit -p configs/src/tsconfig.${environment}.json`]).toArray()),
7370
- ...blueprint.bin ? { "check:src:bin": "tsc --noEmit -p configs/src/tsconfig.bin.json" } : {},
7539
+ ...blueprint.bin.length > 0 ? { "check:src:bin": "tsc --noEmit -p configs/src/tsconfig.bin.json" } : {},
7371
7540
  ...Object.fromEntries([...sheets, ...source].map((name) => [`check:src:${name}`, `tsc --noEmit -p configs/src/tsconfig.${name}.json`]))
7372
7541
  } : {},
7373
7542
  ...blueprint.app.length > 0 ? {
@@ -7392,14 +7561,14 @@ function blueprintToScripts(blueprint) {
7392
7561
  ...!publishes && blueprint.service ? ["npm run test:service"] : []
7393
7562
  ].join(" && "),
7394
7563
  ...compiles ? {
7395
- "test:src": [...blueprint.src.length > 0 || blueprint.bin ? [[
7564
+ "test:src": [...blueprint.src.length > 0 || blueprint.bin.length > 0 ? [[
7396
7565
  vitest,
7397
7566
  ...blueprint.src.map((environment) => `--project ${SRC_MATRIX[environment].project}`),
7398
7567
  ...source.map((name) => `--project src:${name}`),
7399
- ...blueprint.bin ? ["--project src:bin"] : []
7568
+ ...blueprint.bin.length > 0 ? ["--project src:bin"] : []
7400
7569
  ].join(" ")] : [], ...targets.map((name) => `npm run test:src:${name}`)].join(" && "),
7401
7570
  ...Object.fromEntries(Iterator.from(blueprint.src).map((environment) => [`test:src:${environment}`, `${vitest} --project ${SRC_MATRIX[environment].project}`]).toArray()),
7402
- ...blueprint.bin ? { "test:src:bin": `${vitest} --project src:bin` } : {},
7571
+ ...blueprint.bin.length > 0 ? { "test:src:bin": `${vitest} --project src:bin` } : {},
7403
7572
  ...Object.fromEntries(source.map((name) => [`test:src:${name}`, `${vitest} --project src:${name}`])),
7404
7573
  ...Object.fromEntries(targets.map((name) => [`test:src:${name}`, `npm run build:src:${name} && ${vitest} --project src:${name}`]))
7405
7574
  } : {},
@@ -7446,10 +7615,10 @@ function blueprintToScripts(blueprint) {
7446
7615
  ...blueprint.src.map((environment) => `npm run build:src:${environment}`),
7447
7616
  ...source.map((name) => `npm run build:src:${name}`),
7448
7617
  ...targets.map((name) => `npm run build:src:${name}`),
7449
- ...blueprint.bin ? ["npm run build:src:bin"] : []
7618
+ ...blueprint.bin.length > 0 ? ["npm run build:src:bin"] : []
7450
7619
  ].join(" && "),
7451
7620
  ...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()),
7452
- ...blueprint.bin ? { "build:src:bin": "vite build --config configs/src/vite.bin.config.ts" } : {},
7621
+ ...blueprint.bin.length > 0 ? { "build:src:bin": "vite build --config configs/src/vite.bin.config.ts" } : {},
7453
7622
  ...Object.fromEntries(source.map((name) => [`build:src:${name}`, `vite build --config configs/src/vite.${name}.config.ts`])),
7454
7623
  ...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(" && ")]))
7455
7624
  } : {},
@@ -7492,9 +7661,10 @@ function blueprintToScripts(blueprint) {
7492
7661
  * Every direct `test:<project>` script is writable, together with the probe and
7493
7662
  * benchmark workbench scripts. A workspace carrying guides adds `test:guides`,
7494
7663
  * whose package-owned entry runs the guides project and handles explicit parity
7495
- * rewrites, and one carrying skills adds `test:skills`. Publishing adds the pack and publication lifecycle scripts.
7496
- * Sheet and framework faces add their check and build scripts, application frameworks add dev scripts,
7497
- * and selected showcases and journeys add their mode scripts.
7664
+ * rewrites, and one carrying skills adds `test:skills`. Publishing adds the pack and publication
7665
+ * lifecycle scripts. Library environments, sheet faces, framework faces, and `src/bin` modules
7666
+ * add their check and build scripts, application
7667
+ * frameworks add dev scripts, and selected showcases and journeys add their mode scripts.
7498
7668
  * A base browser application's journey axis also adds `journey` and `capture`, and each
7499
7669
  * app-side browser face adds `journey:<name>` and `capture:<name>`. Their generated
7500
7670
  * commands are writable and have no predecessor forms; customized values remain caller-owned.
@@ -7511,10 +7681,10 @@ function blueprintToScripts(blueprint) {
7511
7681
  * existed. The pack hook accepts the build chain emitted before it
7512
7682
  * delegated to `build`. The publication hook accepts the same gate chain without
7513
7683
  * {@link RELEASE_PROOF_COMMAND}. No accepted publication chain carries a study
7514
- * step. `serve:build` accepts the server-only chain it ran before it delegated to
7515
- * `build`. The value being written is always writable, so it is not repeated there. Any other value is a script the workspace author
7516
- * customized, and {@link replaceManifestScripts} retains it while writing the
7517
- * other named scripts independently.
7684
+ * step. `serve:build` accepts the server-only chain it ran before it delegated to `build`.
7685
+ * The value being written is always writable, so it is not repeated there. Any other value is a
7686
+ * script the workspace author customized, and {@link replaceManifestScripts} retains it while
7687
+ * writing the other named scripts independently.
7518
7688
  *
7519
7689
  * @example
7520
7690
  * ```ts
@@ -7522,7 +7692,7 @@ function blueprintToScripts(blueprint) {
7522
7692
  *
7523
7693
  * const blueprint = createBlueprint('router', { src: ['core'] })
7524
7694
  *
7525
- * blueprintToWritableScripts(blueprint)[0]?.name // 'test:src:core'
7695
+ * blueprintToWritableScripts(blueprint)[0]?.name // 'check:src:core'
7526
7696
  * ```
7527
7697
  */
7528
7698
  function blueprintToWritableScripts(blueprint) {
@@ -7531,12 +7701,13 @@ function blueprintToWritableScripts(blueprint) {
7531
7701
  const body = Object.entries(scripts).flatMap(([name, command]) => {
7532
7702
  const direct = name.startsWith("test:") && name !== "test:src" && name !== "test:app";
7533
7703
  const sheet = sheets.some((face) => name === `build:src:${face}` || name === `check:src:${face}`);
7704
+ const entry = [...blueprint.src, "bin"].some((face) => name === `build:src:${face}` || name === `check:src:${face}`);
7534
7705
  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}`)));
7535
7706
  const showcase = name === "showcase" || name.startsWith("showcase:") || name === "build:showcase" || name.startsWith("build:showcase:");
7536
7707
  const capture = name === "journey" || name === "capture";
7537
7708
  const barrel = matchesBarrel(blueprint) && name === "build:app:barrel";
7538
7709
  const served = blueprint.app.includes("server") && name === "serve:build";
7539
- if (!direct && !sheet && !framework && !showcase && !capture && !barrel && !served) return [];
7710
+ if (!direct && !sheet && !entry && !framework && !showcase && !capture && !barrel && !served) return [];
7540
7711
  return [{
7541
7712
  name,
7542
7713
  command,
@@ -7561,6 +7732,45 @@ function blueprintToWritableScripts(blueprint) {
7561
7732
  ];
7562
7733
  }
7563
7734
  /**
7735
+ * Projects a blueprint into the `bin`, `files`, and `exports` entries its manifest carries.
7736
+ *
7737
+ * @param blueprint - The workspace specification.
7738
+ * @returns The planned commands, packed paths, and subpaths, each in the order the manifest emits.
7739
+ *
7740
+ * @remarks
7741
+ * A workspace without an executable plans no command, and one publishing nothing plans no
7742
+ * subpath, because its manifest carries no `exports` map. `dist/src` is packed only where a
7743
+ * library environment or a sheet builds into it: an executable reaches `dist/src` only through
7744
+ * the `@src/*` specifiers its build rewrites, one per library environment, so an executable
7745
+ * beside no library environment bundles what it imports and packs `dist/bin` alone. A workspace
7746
+ * publishing nothing packs `dist/app` when it builds an application.
7747
+ *
7748
+ * @example
7749
+ * ```ts
7750
+ * import { blueprintToEntries, createBlueprint } from '@orkestrel/scaffold'
7751
+ *
7752
+ * blueprintToEntries(createBlueprint('router', { src: ['core'], bin: ['main'] })).files
7753
+ * // ['dist/src', 'dist/bin', 'README.md']
7754
+ * ```
7755
+ */
7756
+ function blueprintToEntries(blueprint) {
7757
+ const sheets = blueprintToSheets(blueprint);
7758
+ const targets = [...sheets, ...blueprint.themes ? ["styles/themes"] : []];
7759
+ const publishes = blueprint.src.length > 0 || targets.length > 0;
7760
+ return {
7761
+ bin: blueprint.bin.includes("main") ? { [blueprint.name]: BIN_OUTPUT_PATH } : {},
7762
+ files: [
7763
+ ...publishes ? ["dist/src"] : blueprint.app.length > 0 ? ["dist/app"] : [],
7764
+ ...blueprint.bin.length > 0 ? ["dist/bin"] : [],
7765
+ ...targets.map((face) => `!dist/src/${face}/index.js`),
7766
+ ...sheets.map((face) => `src/${face}/**/*.scss`),
7767
+ ...blueprint.themes && !blueprint.styles ? ["src/styles/themes/**/*.scss"] : [],
7768
+ "README.md"
7769
+ ],
7770
+ exports: publishes ? blueprintToExports(blueprint) : {}
7771
+ };
7772
+ }
7773
+ /**
7564
7774
  * Compiles a blueprint into its `package.json` content.
7565
7775
  *
7566
7776
  * @param blueprint - The workspace specification.
@@ -7596,15 +7806,15 @@ function blueprintToWritableScripts(blueprint) {
7596
7806
  * ```
7597
7807
  */
7598
7808
  function blueprintToManifest(blueprint) {
7599
- const sheets = blueprintToSheets(blueprint);
7600
- const targets = [...sheets, ...blueprint.themes ? ["styles/themes"] : []];
7809
+ const targets = [...blueprintToSheets(blueprint), ...blueprint.themes ? ["styles/themes"] : []];
7601
7810
  const publishes = blueprint.src.length > 0 || targets.length > 0;
7602
7811
  const name = publishes ? `@orkestrel/${blueprint.name}` : blueprint.name;
7603
- const dependencies = Object.fromEntries([...blueprint.dependencies].sort((left, right) => comparePrimitives(left.name, right.name)).map((dependency) => [dependency.name, dependency.range]));
7604
- const peers = [...blueprint.peers].sort((left, right) => comparePrimitives(left.name, right.name));
7812
+ const dependencies = Object.fromEntries(blueprint.dependencies.toSorted((left, right) => comparePrimitives(left.name, right.name)).map((dependency) => [dependency.name, dependency.range]));
7813
+ const peers = blueprint.peers.toSorted((left, right) => comparePrimitives(left.name, right.name));
7605
7814
  const peerDependencies = Object.fromEntries(peers.map((peer) => [peer.name, peer.range]));
7606
7815
  const peerDependenciesMeta = Object.fromEntries(peers.filter((peer) => peer.optional === true).map((peer) => [peer.name, { optional: true }]));
7607
7816
  const entry = srcToEntry(blueprint.src);
7817
+ const entries = blueprintToEntries(blueprint);
7608
7818
  const manifest = {
7609
7819
  name,
7610
7820
  version: blueprint.version,
@@ -7620,20 +7830,13 @@ function blueprintToManifest(blueprint) {
7620
7830
  type: "git",
7621
7831
  url: `git+https://github.com/orkestrel/${blueprint.name}.git`
7622
7832
  } } : {},
7623
- ...blueprint.bin ? { bin: { [blueprint.name]: BIN_OUTPUT_PATH } } : {},
7624
- files: [
7625
- blueprint.bin || publishes ? "dist/src" : "dist/app",
7626
- ...blueprint.bin ? ["dist/bin"] : [],
7627
- ...targets.map((face) => `!dist/src/${face}/index.js`),
7628
- ...sheets.map((face) => `src/${face}/**/*.scss`),
7629
- ...blueprint.themes && !blueprint.styles ? ["src/styles/themes/**/*.scss"] : [],
7630
- "README.md"
7631
- ],
7833
+ ...blueprint.bin.includes("main") ? { bin: entries.bin } : {},
7834
+ files: entries.files,
7632
7835
  type: "module",
7633
7836
  ...publishes ? {
7634
- sideEffects: targets.length > 0 || blueprint.bin ? [...targets.length > 0 ? ["**/*.css", "**/*.scss"] : [], ...blueprint.bin ? [`./${BIN_ENTRY_PATH}`, `./${BIN_OUTPUT_PATH}`] : []] : false,
7837
+ sideEffects: targets.length > 0 || blueprint.bin.includes("main") ? [...targets.length > 0 ? ["**/*.css", "**/*.scss"] : [], ...blueprint.bin.includes("main") ? [`./${BIN_ENTRY_PATH}`, `./${BIN_OUTPUT_PATH}`] : []] : false,
7635
7838
  ...blueprint.src.length > 0 ? entry : {},
7636
- exports: blueprintToExports(blueprint),
7839
+ exports: entries.exports,
7637
7840
  publishConfig: { access: "public" }
7638
7841
  } : {},
7639
7842
  scripts: blueprintToScripts(blueprint),
@@ -7680,7 +7883,7 @@ function blueprintToMachinery(blueprint) {
7680
7883
  return {
7681
7884
  browser: blueprint.src.includes("browser") || blueprint.app.includes("browser") || blueprint.setup.includes("browser") || blueprintToSheets(blueprint).length > 0 || blueprint.themes || frameworks.length > 0,
7682
7885
  frameworks,
7683
- output: blueprint.src.length > 0 || blueprint.bin || hosted || blueprintToSheets(blueprint).length > 0 || blueprint.themes,
7886
+ output: blueprint.src.length > 0 || blueprint.bin.length > 0 || hosted || blueprintToSheets(blueprint).length > 0 || blueprint.themes,
7684
7887
  showcase: blueprint.showcase && (blueprint.base && blueprint.app.includes("browser") || blueprintToFaces(blueprint).some((extension) => extension.axes.includes("app")))
7685
7888
  };
7686
7889
  }
@@ -7777,7 +7980,7 @@ function blueprintToProjects(blueprint) {
7777
7980
  ...AXES.flatMap((axis) => [
7778
7981
  ...ENVIRONMENTS.filter((environment) => (axis !== "app" || environment !== "server") && blueprint[axis].includes(environment)).map((environment) => `${axis}:${environment}`),
7779
7982
  ...faces.filter((face) => face.axes.includes(axis)).map((face) => `${axis}:${face.name}`),
7780
- ...axis === "src" && blueprint.bin ? ["src:bin"] : [],
7983
+ ...axis === "src" && blueprint.bin.length > 0 ? ["src:bin"] : [],
7781
7984
  ...axis === "app" && blueprint.app.includes("server") ? ["app:server"] : []
7782
7985
  ]),
7783
7986
  "policy",
@@ -7907,7 +8110,7 @@ function blueprintToRootVite(blueprint) {
7907
8110
  exclude: core ? " exclude: ['tests/src/core/**/*.test.ts'],\n" : ""
7908
8111
  })) : [],
7909
8112
  ...planned.has("src:vue") ? [CONFIG_TEMPLATES.factories.src.vue] : [],
7910
- ...planned.has("src:bin") ? [CONFIG_TEMPLATES.factories.src.bin] : [],
8113
+ ...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") })] : [],
7911
8114
  ...planned.has("app:core") ? [CONFIG_TEMPLATES.factories.app.core] : [],
7912
8115
  ...planned.has("app:browser") ? [fillTemplate(CONFIG_TEMPLATES.factories.app.browser, {
7913
8116
  vuePlugin: machinery.frameworks.includes("vue") ? ", vue()" : "",
@@ -8056,16 +8259,19 @@ function blueprintToConfigArtifacts(blueprint) {
8056
8259
  environment,
8057
8260
  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
8058
8261
  }))).toArray();
8059
- const paths = blueprint.bin ? blueprint.src.map((environment) => `\t\t\t\t\t\t'@src/${environment}': '../src/${environment}/index.js',`) : [];
8262
+ const paths = blueprint.bin.length > 0 ? blueprint.src.map((environment) => `\t\t\t\t\t\t'@src/${environment}': '../src/${environment}/index.js',`) : [];
8060
8263
  const renderedPaths = paths.length === 0 ? " paths: {}," : `\t\t\t\t\tpaths: {
8061
8264
  ${paths.join("\n")}
8062
8265
  },`;
8063
- const bins = blueprint.bin ? BIN_CONFIGS.map((path) => ({
8266
+ const bins = blueprint.bin.length > 0 ? BIN_CONFIGS.map((path) => ({
8064
8267
  path,
8065
8268
  group: "configs",
8066
8269
  ownership: "content",
8067
8270
  origin: "template",
8068
- content: path === "configs/src/tsconfig.bin.json" ? CONFIG_TEMPLATES.tsconfigs.bin : fillTemplate(CONFIG_TEMPLATES.vites.bin, { paths: renderedPaths })
8271
+ content: path === "configs/src/tsconfig.bin.json" ? CONFIG_TEMPLATES.tsconfigs.bin : fillTemplate(CONFIG_TEMPLATES.vites.bin, {
8272
+ modules: blueprint.bin.filter((name) => name !== "main").map((name) => serializeTypeScriptString(name)).join(", "),
8273
+ paths: renderedPaths
8274
+ })
8069
8275
  })) : [];
8070
8276
  const barrels = matchesBarrel(blueprint) ? BARREL_CONFIGS.map((path) => ({
8071
8277
  path,
@@ -8291,7 +8497,7 @@ function blueprintToSourceArtifacts(blueprint) {
8291
8497
  }))
8292
8498
  ] : [barrel];
8293
8499
  }));
8294
- const bin = blueprint.bin ? [{
8500
+ const bin = blueprint.bin.includes("main") ? [{
8295
8501
  path: BIN_ENTRY_PATH,
8296
8502
  group: "source",
8297
8503
  ownership: "birth",
@@ -8390,7 +8596,7 @@ function blueprintToTestArtifacts(blueprint) {
8390
8596
  environment: "browser",
8391
8597
  content: blueprint.journey ? ARTIFACT_TEMPLATES.tests.browser : ARTIFACT_TEMPLATES.tests.setup
8392
8598
  }] : [];
8393
- const servers = blueprint.src.includes("server") || blueprint.app.includes("server") || blueprint.bin || blueprint.conformance || blueprint.tree ? [{
8599
+ const servers = blueprint.src.includes("server") || blueprint.app.includes("server") || blueprint.bin.length > 0 || blueprint.conformance || blueprint.tree ? [{
8394
8600
  path: "tests/setupServer.ts",
8395
8601
  group: "tests",
8396
8602
  ownership: "birth",
@@ -8447,7 +8653,7 @@ function blueprintToTestArtifacts(blueprint) {
8447
8653
  })).toArray();
8448
8654
  const binSpecifier = serializeTypeScriptString("../../../src/bin/main.js");
8449
8655
  const joinedImport = `\t\tconst entry = await import(${binSpecifier})`;
8450
- const bins = blueprint.bin ? [{
8656
+ const bins = blueprint.bin.includes("main") ? [{
8451
8657
  path: "tests/src/bin/main.test.ts",
8452
8658
  group: "tests",
8453
8659
  ownership: "birth",
@@ -8473,6 +8679,7 @@ function blueprintToTestArtifacts(blueprint) {
8473
8679
  origin: "template",
8474
8680
  content: fillTemplate(distribution.module, {
8475
8681
  types: browser ? distribution.types : "",
8682
+ events: browser ? distribution.events : "",
8476
8683
  transport: browser ? distribution.transport : "",
8477
8684
  launcher: browser ? distribution.launcher : "",
8478
8685
  helpers: browser ? distribution.helpers : ""
@@ -8563,7 +8770,7 @@ function blueprintToGuideArtifacts(blueprint) {
8563
8770
  directory: `src/${environment}`,
8564
8771
  test: `tests/src/${environment}`
8565
8772
  })),
8566
- ...blueprint.bin ? [{
8773
+ ...blueprint.bin.length > 0 ? [{
8567
8774
  directory: "src/bin",
8568
8775
  test: "tests/src/bin"
8569
8776
  }] : [],
@@ -8961,7 +9168,7 @@ function insertManifestDependencies(manifest, additions) {
8961
9168
  function insertManifestSection(manifest, section, dependencies, present) {
8962
9169
  const tokens = scanManifestTokens(manifest);
8963
9170
  if (tokens === void 0) return void 0;
8964
- const ordered = [...dependencies].sort((left, right) => comparePrimitives(left.name, right.name));
9171
+ const ordered = dependencies.toSorted((left, right) => comparePrimitives(left.name, right.name));
8965
9172
  const lines = ordered.map(({ name, range }) => `${JSON.stringify(name)}: ${JSON.stringify(range)}`);
8966
9173
  const sibling = section === "dependencies" ? "devDependencies" : "dependencies";
8967
9174
  const occurrences = tokens.flatMap((token, at) => {
@@ -9036,6 +9243,154 @@ function insertManifestSection(manifest, section, dependencies, present) {
9036
9243
  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);
9037
9244
  }
9038
9245
  /**
9246
+ * Inserts the planned `bin`, `files`, and `exports` entries a package manifest lacks.
9247
+ *
9248
+ * @param manifest - The manifest text to compile.
9249
+ * @param planned - The entries the plan emits, each in planned order.
9250
+ * @returns The manifest declaring every planned entry, or `undefined` when the text is not a
9251
+ * manifest object, or a section that must take an entry holds a value of another shape: `bin` not
9252
+ * an object, `exports` not a map of subpaths, or `files` not an array of strings.
9253
+ *
9254
+ * @remarks
9255
+ * The compiler inserts text instead of serializing the manifest, so every declared byte survives,
9256
+ * and a declared entry keeps its value whatever the plan holds. An inserted entry lands before the
9257
+ * first declared entry the plan orders after it, or after the last declared entry when none does,
9258
+ * and copies the indentation of the section's first entry; a nested value takes the same step per
9259
+ * level. An absent section is created as one top-level key holding the planned entries, before the
9260
+ * first declared key `MANIFEST_KEY_ORDER` orders after it, or last in the manifest object. A
9261
+ * manifest declaring every planned entry is returned unchanged.
9262
+ *
9263
+ * @example
9264
+ * ```ts
9265
+ * import { insertManifestEntries } from '@orkestrel/scaffold'
9266
+ *
9267
+ * insertManifestEntries('{\n\t"files": [\n\t\t"dist/src",\n\t\t"README.md"\n\t]\n}\n', {
9268
+ * bin: {},
9269
+ * files: ['dist/src', 'dist/bin', 'README.md'],
9270
+ * exports: {},
9271
+ * })
9272
+ * // '{\n\t"files": [\n\t\t"dist/src",\n\t\t"dist/bin",\n\t\t"README.md"\n\t]\n}\n'
9273
+ * ```
9274
+ */
9275
+ function insertManifestEntries(manifest, planned) {
9276
+ const parsed = parseJSON(manifest);
9277
+ const tokens = scanManifestTokens(manifest);
9278
+ if (!isRecord(parsed) || tokens === void 0) return void 0;
9279
+ const missing = manifestToEntries(manifest, planned);
9280
+ const keys = tokens.flatMap((token, at) => {
9281
+ const name = token.depth === 1 && token.value !== void 0 ? parseJSON(token.text) : void 0;
9282
+ return isString(name) && token.value !== void 0 ? [{
9283
+ name,
9284
+ index: token.index,
9285
+ value: token.value,
9286
+ at
9287
+ }] : [];
9288
+ });
9289
+ const open = tokens[0];
9290
+ const root = tokens.find((token) => token.text === "}" && token.depth === 0);
9291
+ const head = keys[0];
9292
+ if (open?.text !== "{" || root === void 0 || head === void 0) return void 0;
9293
+ const lineBreak = manifest.lastIndexOf("\n", head.index);
9294
+ const margin = lineBreak < 0 ? "" : manifest.slice(lineBreak + 1, head.index);
9295
+ const step = /\S/u.test(margin) ? "" : margin;
9296
+ const edits = [
9297
+ {
9298
+ name: "bin",
9299
+ array: false,
9300
+ members: Object.entries(missing.bin),
9301
+ order: Object.keys(planned.bin)
9302
+ },
9303
+ {
9304
+ name: "files",
9305
+ array: true,
9306
+ members: missing.files.map((path) => [path, path]),
9307
+ order: planned.files
9308
+ },
9309
+ {
9310
+ name: "exports",
9311
+ array: false,
9312
+ members: Object.entries(missing.exports),
9313
+ order: Object.keys(planned.exports)
9314
+ }
9315
+ ].map((section) => {
9316
+ if (section.members.length === 0) return [];
9317
+ const key = keys.find(({ name }) => name === section.name);
9318
+ if (key === void 0) {
9319
+ const value = section.array ? section.members.map(([path]) => path) : Object.fromEntries(section.members);
9320
+ const block = `${JSON.stringify(section.name)}: ${JSON.stringify(value, void 0, step).replaceAll("\n", `\n${margin}`)}`;
9321
+ const gap = step === "" ? "" : `\n${margin}`;
9322
+ const successors = MANIFEST_KEY_ORDER.slice(MANIFEST_KEY_ORDER.indexOf(section.name) + 1);
9323
+ const anchor = keys.find(({ name }) => successors.includes(name));
9324
+ const tail = open.index + 1 + manifest.slice(open.index + 1, root.index).trimEnd().length;
9325
+ return [anchor === void 0 ? {
9326
+ start: tail,
9327
+ end: tail,
9328
+ text: `,${gap}${block}`
9329
+ } : {
9330
+ start: anchor.index,
9331
+ end: anchor.index,
9332
+ text: `${block},${gap}`
9333
+ }];
9334
+ }
9335
+ const current = parsed[section.name];
9336
+ const length = isArray(current) && current.every(isString) ? current.length : void 0;
9337
+ if (manifest.charAt(key.value) !== (section.array ? "[" : "{")) return void 0;
9338
+ if (section.array && length === void 0) return void 0;
9339
+ if (section.name === "exports" && !isSubpathMap(current)) return void 0;
9340
+ const following = tokens.slice(key.at + 1);
9341
+ const strings = following.slice(0, length ?? 0);
9342
+ const last = strings.at(-1);
9343
+ 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;
9344
+ if (close < 0) return void 0;
9345
+ const declared = (section.array ? strings : following).flatMap((token) => {
9346
+ const name = parseJSON(token.text);
9347
+ return (section.array || token.depth === 2 && token.value !== void 0) && token.index < close && isString(name) ? [{
9348
+ name,
9349
+ index: token.index
9350
+ }] : [];
9351
+ });
9352
+ const keyBreak = manifest.lastIndexOf("\n", key.index);
9353
+ const level = keyBreak < 0 ? "" : /^\s*/u.exec(manifest.slice(keyBreak + 1, key.index))?.[0] ?? "";
9354
+ const first = declared[0];
9355
+ const firstBreak = first === void 0 ? -1 : manifest.lastIndexOf("\n", first.index);
9356
+ const lead = first === void 0 || firstBreak < 0 ? "" : manifest.slice(firstBreak + 1, first.index);
9357
+ const indent = first === void 0 ? step === "" ? "" : `${level}${step}` : /\S/u.test(lead) ? "" : lead;
9358
+ const nested = indent.startsWith(level) ? indent.slice(level.length) : step;
9359
+ 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}`)}`);
9360
+ const separator = indent === "" ? "" : `\n${indent}`;
9361
+ if (first === void 0) {
9362
+ const start = key.value + 1;
9363
+ const suffix = indent === "" ? "" : `\n${level}`;
9364
+ return [{
9365
+ start,
9366
+ end: close,
9367
+ text: `${lines.map((line) => `${separator}${line}`).join(",")}${suffix}`
9368
+ }];
9369
+ }
9370
+ const tail = key.value + 1 + manifest.slice(key.value + 1, close).trimEnd().length;
9371
+ return section.members.map(([name], position) => {
9372
+ const line = lines[position] ?? "";
9373
+ const rank = section.order.indexOf(name);
9374
+ const anchor = declared.find((entry) => section.order.indexOf(entry.name) > rank);
9375
+ return anchor === void 0 ? {
9376
+ start: tail,
9377
+ end: tail,
9378
+ text: `,${separator}${line}`
9379
+ } : {
9380
+ start: anchor.index,
9381
+ end: anchor.index,
9382
+ text: `${line},${separator}`
9383
+ };
9384
+ });
9385
+ });
9386
+ if (edits.some((edit) => edit === void 0)) return void 0;
9387
+ return [...Map.groupBy(edits.flatMap((edit) => edit ?? []), ({ start }) => start)].map(([start, group]) => ({
9388
+ start,
9389
+ end: Math.max(...group.map(({ end }) => end)),
9390
+ text: group.map(({ text }) => text).join("")
9391
+ })).sort((left, right) => right.start - left.start).reduce((text, edit) => text.slice(0, edit.start) + edit.text + text.slice(edit.end), manifest);
9392
+ }
9393
+ /**
9039
9394
  * Replaces named script values in package manifest text.
9040
9395
  *
9041
9396
  * @param manifest - The manifest text to compile.
@@ -9477,6 +9832,36 @@ function blueprintToQuestions(blueprint) {
9477
9832
  message: "integration drives features across environments, and this workspace declares fewer than two, so its seed composes nothing.",
9478
9833
  blocking: false
9479
9834
  }] : [],
9835
+ ...Iterator.from(blueprint.bin).map((name) => ({
9836
+ name,
9837
+ valid: isBinModule(name)
9838
+ })).toArray().flatMap(({ name, valid }, index, declared) => {
9839
+ if (!valid) return [{
9840
+ field: "bin",
9841
+ 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.`,
9842
+ blocking: true
9843
+ }];
9844
+ if (declared.findIndex((other) => other.name === name) < index) return [{
9845
+ field: "bin",
9846
+ message: `${name} is declared more than once on bin.`,
9847
+ blocking: true
9848
+ }];
9849
+ if (name === "main") return [];
9850
+ const subpaths = blueprintToExports({
9851
+ ...blueprint,
9852
+ bin: []
9853
+ });
9854
+ if (Object.hasOwn(subpaths, `./${name}`)) return [{
9855
+ field: "bin",
9856
+ message: `src/bin/${name}.ts publishes ./${name}, which src/${name} already publishes. Rename the module.`,
9857
+ blocking: true
9858
+ }];
9859
+ return Object.keys(subpaths).length === 0 ? [{
9860
+ field: "bin",
9861
+ 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.`,
9862
+ blocking: false
9863
+ }] : [];
9864
+ }),
9480
9865
  ...Iterator.from(blueprint.vendors).map((vendor) => ({
9481
9866
  vendor,
9482
9867
  valid: NAME_PATTERN.test(vendor)
@@ -9669,7 +10054,7 @@ function overridesToQuestions(overrides, artifacts) {
9669
10054
  * const blueprint = createBlueprint('router', {
9670
10055
  * src: ['core', 'server'],
9671
10056
  * dependencies: [{ name: '@orkestrel/emitter', range: '^0.0.5' }],
9672
- * bin: true,
10057
+ * bin: ['main'],
9673
10058
  * })
9674
10059
  *
9675
10060
  * blueprint.version // '0.0.1'
@@ -9692,7 +10077,7 @@ function createBlueprint(name, input) {
9692
10077
  version: input?.version ?? "0.0.1",
9693
10078
  engines: input?.engines ?? ">=22.18.0",
9694
10079
  overrides: input?.overrides ?? [],
9695
- bin: input?.bin ?? false,
10080
+ bin: input?.bin ?? [],
9696
10081
  setup: input?.setup ?? [],
9697
10082
  guides: input?.guides ?? false,
9698
10083
  integration: input?.integration ?? false,
@@ -10010,6 +10395,6 @@ var Compiler = class {
10010
10395
  return error;
10011
10396
  }
10012
10397
  };
10013
- export { APP_BROWSER_DEV_DEPENDENCIES, APP_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, 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 };
10398
+ 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, renderSkillPointer, replaceManifestOverride, replaceManifestOverrides, replaceManifestRanges, replaceManifestScripts, replacePlanRanges, scanManifestTokens, selectArtifactGroups, selectHostPaths, serializeTypeScriptString, srcToEntry, srcToExports, srcToRoot };
10014
10399
 
10015
10400
  //# sourceMappingURL=index.js.map