@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
@@ -4,7 +4,7 @@ let _orkestrel_template = require("@orkestrel/template");
4
4
  let _orkestrel_emitter = require("@orkestrel/emitter");
5
5
  var package_default = {
6
6
  name: "@orkestrel/scaffold",
7
- version: "0.0.133",
7
+ version: "0.0.135",
8
8
  description: "Scaffold workspaces with commands: new, audit, surface, repair, catalog, and overwrite.",
9
9
  keywords: [
10
10
  "audit",
@@ -109,7 +109,7 @@ var package_default = {
109
109
  "@orkestrel/guide": "^0.0.31",
110
110
  "@orkestrel/html": "^0.0.16",
111
111
  "@orkestrel/probe": "^0.0.30",
112
- "@orkestrel/test": "^0.0.36",
112
+ "@orkestrel/test": "^0.0.38",
113
113
  "@types/node": "^24.19.2",
114
114
  "@vitest/browser-playwright": "^5.1.0",
115
115
  "oxfmt": "^0.78.0",
@@ -250,10 +250,35 @@ var APP_MATRIX = Object.freeze({
250
250
  var BIN_CONFIGS = Object.freeze(["configs/src/vite.bin.config.ts", "configs/src/tsconfig.bin.json"]);
251
251
  /** Lists the configuration file a workspace with studies and a server application adds, frozen. */
252
252
  var BARREL_CONFIGS = Object.freeze(["configs/app/vite.barrel.config.ts"]);
253
- /** Names the executable entry whose presence makes a workspace `bin`. */
253
+ /** Names the executable entry, the `main` module of `src/bin`. */
254
254
  var BIN_ENTRY_PATH = "src/bin/main.ts";
255
255
  /** Names the built executable a bin workspace's manifest command runs. */
256
256
  var BIN_OUTPUT_PATH = "dist/bin/main.js";
257
+ /** Lists the stems of the centralized files the architecture kind table names, which no `src/bin` module takes, frozen. */
258
+ var CENTRAL_FILE_NAMES = Object.freeze([
259
+ "cloners",
260
+ "combinators",
261
+ "compilers",
262
+ "constants",
263
+ "contracts",
264
+ "errors",
265
+ "factories",
266
+ "handlers",
267
+ "helpers",
268
+ "index",
269
+ "inferers",
270
+ "middlewares",
271
+ "parsers",
272
+ "plugins",
273
+ "relations",
274
+ "routes",
275
+ "schemas",
276
+ "seeders",
277
+ "shapers",
278
+ "templates",
279
+ "types",
280
+ "validators"
281
+ ]);
257
282
  /**
258
283
  * Lists the paths a target receives from the vendored data root, frozen.
259
284
  *
@@ -512,6 +537,42 @@ var RELEASE_PROOF_COMMAND = "npm run test:distribution -- --mode release";
512
537
  var INTEGRATION_TEST_PATH = "tests/integration.test.ts";
513
538
  /** Names the manifest path every compiler plan emits with birth ownership. */
514
539
  var MANIFEST_PATH = "package.json";
540
+ /**
541
+ * Lists the top-level manifest keys in the order a compiled manifest emits them.
542
+ *
543
+ * @remarks
544
+ * An entry write that creates an absent `bin`, `files`, or `exports` key places it before the
545
+ * first declared key this list orders after it, so a created key lands where a born manifest
546
+ * carries it.
547
+ */
548
+ var MANIFEST_KEY_ORDER = Object.freeze([
549
+ "name",
550
+ "version",
551
+ "private",
552
+ "description",
553
+ "keywords",
554
+ "homepage",
555
+ "bugs",
556
+ "license",
557
+ "repository",
558
+ "bin",
559
+ "files",
560
+ "type",
561
+ "sideEffects",
562
+ "main",
563
+ "module",
564
+ "types",
565
+ "exports",
566
+ "publishConfig",
567
+ "scripts",
568
+ "dependencies",
569
+ "devDependencies",
570
+ "overrides",
571
+ "peerDependencies",
572
+ "peerDependenciesMeta",
573
+ "devEngines",
574
+ "engines"
575
+ ]);
515
576
  /** Names the official-tooling drift proof whose presence makes a workspace `conformance`. */
516
577
  var CONFORMANCE_TEST_PATH = "tests/conformance.test.ts";
517
578
  /** Names the real-tree proof whose presence makes a workspace `tree`. */
@@ -541,6 +602,8 @@ var JOURNEY_CONFIG_PATH = "configs/app/vite.journey.config.ts";
541
602
  var SKILLS_CONFIG_PATH = "configs/agents/tsconfig.skills.json";
542
603
  /** Matches the bare workspace name syntax: lowercase alphanumeric with hyphens, letter first. */
543
604
  var NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
605
+ /** Matches the stem of a `src/bin` module: lowercase letters and digits, letter first, no hyphen. */
606
+ var BIN_MODULE_PATTERN = /^[a-z][a-z0-9]*$/;
544
607
  /**
545
608
  * Matches the runtime dependency name syntax: the `@orkestrel` scope and a bare name.
546
609
  *
@@ -674,6 +737,7 @@ var WORKSPACE_DEV_ENGINES = Object.freeze({ packageManager: Object.freeze({
674
737
  }) });
675
738
  /** Holds the baseline tooling versions, before framework holds apply. */
676
739
  var BASE_DEV_DEPENDENCIES = Object.freeze({
740
+ "@orkestrel/contract": package_default.dependencies["@orkestrel/contract"],
677
741
  "@orkestrel/guide": package_default.devDependencies["@orkestrel/guide"],
678
742
  "@orkestrel/probe": package_default.devDependencies["@orkestrel/probe"],
679
743
  "@orkestrel/scaffold": `^${package_default.version}`,
@@ -813,8 +877,6 @@ var BROWSE_UPSTREAM = Object.freeze([
813
877
  "@orkestrel/tool",
814
878
  "@orkestrel/websocket"
815
879
  ]);
816
- /** Names the development dependency every private `app` environment adds. */
817
- var APP_DEV_DEPENDENCIES = Object.freeze({ "@orkestrel/contract": package_default.dependencies["@orkestrel/contract"] });
818
880
  /** Lists the development dependencies a private browser application adds. */
819
881
  var APP_BROWSER_DEV_DEPENDENCIES = Object.freeze({
820
882
  ...SOURCE_BROWSER_DEV_DEPENDENCIES,
@@ -1210,8 +1272,8 @@ export function srcServer(override?: UserConfig): UserConfig {
1210
1272
  return mergeOverride(project, override)
1211
1273
  }
1212
1274
  `,
1213
- bin: `function resolveBinFilename(): string {
1214
- return 'main.js'
1275
+ bin: `function resolveBinFilename(_format: string, entry: string): string {
1276
+ return \`\${entry}.js\`
1215
1277
  }
1216
1278
 
1217
1279
  function resolveBinExternal(id: string): boolean {
@@ -1228,7 +1290,9 @@ export function srcBin(override?: UserConfig): UserConfig {
1228
1290
  sourcemap: true,
1229
1291
  minify: false,
1230
1292
  lib: {
1231
- entry: resolveWorkspacePath('${BIN_ENTRY_PATH}'),
1293
+ entry: {
1294
+ {{entries}}
1295
+ },
1232
1296
  formats: ['es'],
1233
1297
  fileName: resolveBinFilename,
1234
1298
  },
@@ -2080,22 +2144,28 @@ export default defineConfig(
2080
2144
  `
2081
2145
  }),
2082
2146
  bin: `import { defineConfig } from 'vite'
2083
- import { resolveExternal } from '../helpers.js'
2084
- import { peers, srcBin } from '../../vite.config.ts'
2085
-
2086
- // The \`scaffold\` executable build — a single ESM lib file, no declarations (an
2087
- // executable ships no types), with the \`#!/usr/bin/env node\` shebang re-emitted through
2088
- // \`output.banner\` (rolldown strips shebangs from source during bundling), and
2089
- // \`output.paths\` rewriting the externalized \`@src/*\` specifiers to the built sibling
2090
- // src environments (relative to \`dist/bin/\`), so the emitted bin resolves at runtime.
2147
+ import { declarationRollup, resolveExternal, rewriteSourceSpecifier } from '../helpers.js'
2148
+ import { peers, resolveWorkspacePath, srcBin } from '../../vite.config.ts'
2149
+
2150
+ // One ES file per \`src/bin\` module. Rolldown strips a source shebang, so \`main\` alone takes
2151
+ // the \`#!/usr/bin/env node\` banner; every other module ships its rolled-up declaration.
2152
+ // \`output.paths\` and the declaration rewrite point each external \`@src/*\` specifier at the
2153
+ // built environment beside \`dist/bin/\`.
2091
2154
  export default defineConfig(
2092
2155
  srcBin({
2156
+ plugins: [
2157
+ declarationRollup({
2158
+ project: resolveWorkspacePath('configs/src/tsconfig.bin.json'),
2159
+ entries: [{{modules}}],
2160
+ rewrite: rewriteSourceSpecifier,
2161
+ }),
2162
+ ],
2093
2163
  build: {
2094
2164
  rolldownOptions: {
2095
2165
  external: (id: string) =>
2096
2166
  id.startsWith('@src/') || resolveExternal(id, { peers, refused: [], siblings: [] }),
2097
2167
  output: {
2098
- banner: '#!/usr/bin/env node',
2168
+ banner: (chunk) => (chunk.name === 'main' ? '#!/usr/bin/env node' : ''),
2099
2169
  {{paths}}
2100
2170
  },
2101
2171
  },
@@ -2706,8 +2776,9 @@ describe('bin entry', () => {
2706
2776
  distribution: Object.freeze({
2707
2777
  module: `{{types}}import type { SpawnSyncReturns } from 'node:child_process'
2708
2778
  import type { TestContext } from 'vitest'
2779
+ import { arrayOf, isArray, isRecord, isString } from '@orkestrel/contract'
2709
2780
  import { spawnSync } from 'node:child_process'
2710
- import {
2781
+ {{events}}import {
2711
2782
  existsSync,
2712
2783
  mkdirSync,
2713
2784
  mkdtempSync,
@@ -2954,39 +3025,6 @@ export interface DistributionStage {
2954
3025
  readonly targets: readonly string[]
2955
3026
  }
2956
3027
 
2957
- /**
2958
- * Checks whether a value is a non-null object other than an array.
2959
- *
2960
- * @param value - The value to inspect.
2961
- * @returns True if the value is a record; false otherwise.
2962
- */
2963
- export function isDistributionRecord(value: unknown): value is Readonly<Record<string, unknown>> {
2964
- return typeof value === 'object' && value !== null && !Array.isArray(value)
2965
- }
2966
-
2967
- /**
2968
- * Checks whether a value is an array of strings.
2969
- *
2970
- * @param value - The value to inspect.
2971
- * @returns True if every array member is a string; false otherwise.
2972
- */
2973
- export function isDistributionNames(value: unknown): value is readonly string[] {
2974
- return Array.isArray(value) && value.every((name) => typeof name === 'string')
2975
- }
2976
-
2977
- // A fallback list, which is what Node reads an array in an exports entry as. The
2978
- // narrowing is what the following walkers need: \`Array.isArray\` widens an \`unknown\`
2979
- // member to \`any\`, and an entry read that way is not read at all.
2980
- /**
2981
- * Checks whether a value is a fallback array.
2982
- *
2983
- * @param value - The value to inspect.
2984
- * @returns True if the value is an array; false otherwise.
2985
- */
2986
- export function isDistributionList(value: unknown): value is readonly unknown[] {
2987
- return Array.isArray(value)
2988
- }
2989
-
2990
3028
  // Whether a string is a valid package target. Node rejects a target outside the
2991
3029
  // package and a target containing a dot, parent, or node_modules segment during
2992
3030
  // package-target resolution. A later module-resolution failure is not the same
@@ -3031,7 +3069,7 @@ export function readDistributionJSON(path: string): unknown {
3031
3069
  */
3032
3070
  export function readDistributionManifestName(path: string): string {
3033
3071
  const manifest = readDistributionJSON(path)
3034
- if (!isDistributionRecord(manifest) || typeof manifest.name !== 'string') {
3072
+ if (!isRecord(manifest) || typeof manifest.name !== 'string') {
3035
3073
  throw new Error(\`The manifest at \${path} declares no package name\`)
3036
3074
  }
3037
3075
  return manifest.name
@@ -3048,19 +3086,17 @@ export function readDistributionManifestName(path: string): string {
3048
3086
  */
3049
3087
  export function readDistributionPeers(path: string): Readonly<Record<string, string>> {
3050
3088
  const manifest = readDistributionJSON(path)
3051
- if (!isDistributionRecord(manifest) || !isDistributionRecord(manifest.peerDependencies)) {
3089
+ if (!isRecord(manifest) || !isRecord(manifest.peerDependencies)) {
3052
3090
  return {}
3053
3091
  }
3054
- const meta = isDistributionRecord(manifest.peerDependenciesMeta)
3055
- ? manifest.peerDependenciesMeta
3056
- : undefined
3092
+ const meta = isRecord(manifest.peerDependenciesMeta) ? manifest.peerDependenciesMeta : undefined
3057
3093
  const peers = Object.entries(manifest.peerDependencies).filter(
3058
3094
  (entry): entry is [string, string] => typeof entry[1] === 'string',
3059
3095
  )
3060
3096
  return Object.fromEntries(
3061
3097
  peers.filter(([name]) => {
3062
3098
  const entry = meta?.[name]
3063
- return !isDistributionRecord(entry) || entry.optional !== true
3099
+ return !isRecord(entry) || entry.optional !== true
3064
3100
  }),
3065
3101
  )
3066
3102
  }
@@ -3075,7 +3111,7 @@ export function createDistributionConsumerManifest(
3075
3111
  peers: Readonly<Record<string, string>>,
3076
3112
  ): string {
3077
3113
  const manifest: unknown = JSON.parse(DISTRIBUTION_CONSUMER_MANIFEST)
3078
- if (Object.keys(peers).length === 0 || !isDistributionRecord(manifest)) {
3114
+ if (Object.keys(peers).length === 0 || !isRecord(manifest)) {
3079
3115
  return DISTRIBUTION_CONSUMER_MANIFEST
3080
3116
  }
3081
3117
  return \`\${JSON.stringify({ ...manifest, dependencies: peers })}\\n\`
@@ -3196,7 +3232,7 @@ export function resolveDistributionPackageTarget(
3196
3232
  conditions: readonly string[],
3197
3233
  ): DistributionTargetResult | undefined {
3198
3234
  if (typeof entry === 'string') return { target: entry }
3199
- if (isDistributionList(entry)) {
3235
+ if (isArray(entry)) {
3200
3236
  for (const member of entry) {
3201
3237
  const resolved = resolveDistributionPackageTarget(member, conditions)
3202
3238
  if (resolved !== undefined && matchesDistributionPackageTarget(resolved.target))
@@ -3204,7 +3240,7 @@ export function resolveDistributionPackageTarget(
3204
3240
  }
3205
3241
  return undefined
3206
3242
  }
3207
- if (!isDistributionRecord(entry)) return undefined
3243
+ if (!isRecord(entry)) return undefined
3208
3244
  for (const [condition, nested] of Object.entries(entry)) {
3209
3245
  if (condition !== 'default' && !conditions.includes(condition)) continue
3210
3246
  const resolved = resolveDistributionPackageTarget(nested, conditions)
@@ -3289,14 +3325,14 @@ export function resolveDistributionDeclaration(
3289
3325
  installed: string,
3290
3326
  ): string | undefined {
3291
3327
  if (typeof entry === 'string') return targetToDistributionDeclaration(entry, installed)
3292
- if (isDistributionList(entry)) {
3328
+ if (isArray(entry)) {
3293
3329
  for (const member of entry) {
3294
3330
  const resolved = resolveDistributionDeclaration(member, conditions, installed)
3295
3331
  if (resolved !== undefined) return resolved
3296
3332
  }
3297
3333
  return undefined
3298
3334
  }
3299
- if (!isDistributionRecord(entry)) return undefined
3335
+ if (!isRecord(entry)) return undefined
3300
3336
  for (const [condition, nested] of Object.entries(entry)) {
3301
3337
  if (condition !== 'default' && !conditions.includes(condition)) continue
3302
3338
  const resolved = resolveDistributionDeclaration(nested, conditions, installed)
@@ -3329,7 +3365,7 @@ export function readDistributionPackageType(installed: string, target: string):
3329
3365
  if (scope === undefined) return undefined
3330
3366
  try {
3331
3367
  const manifest = readDistributionJSON(join(scope, 'package.json'))
3332
- return isDistributionRecord(manifest) ? manifest.type : undefined
3368
+ return isRecord(manifest) ? manifest.type : undefined
3333
3369
  } catch {
3334
3370
  return undefined
3335
3371
  }
@@ -3406,9 +3442,9 @@ export function declaresDistributionCommonJS(entry: unknown, installed: string):
3406
3442
  */
3407
3443
  export function collectDistributionTargets(entry: unknown): readonly string[] {
3408
3444
  if (typeof entry === 'string') return [entry]
3409
- if (isDistributionList(entry))
3445
+ if (isArray(entry))
3410
3446
  return entry.flatMap(collectDistributionTargets).filter(matchesDistributionPackageTarget)
3411
- if (!isDistributionRecord(entry)) return []
3447
+ if (!isRecord(entry)) return []
3412
3448
  return Object.values(entry).flatMap((nested) => collectDistributionTargets(nested))
3413
3449
  }
3414
3450
 
@@ -3539,7 +3575,7 @@ export function filterDistributionUntypable(
3539
3575
  return entries.filter(
3540
3576
  (entry) =>
3541
3577
  entry.requirable &&
3542
- isDistributionRecord(entry.mapping) &&
3578
+ isRecord(entry.mapping) &&
3543
3579
  Object.hasOwn(entry.mapping, 'require') &&
3544
3580
  !declaresDistributionCommonJS(entry.mapping, installed),
3545
3581
  )
@@ -3729,7 +3765,7 @@ export function driveDistributionRuntime(
3729
3765
  )
3730
3766
  }
3731
3767
  const published: unknown = JSON.parse(result.stdout)
3732
- if (!isDistributionNames(published))
3768
+ if (!arrayOf(isString)(published))
3733
3769
  throw new Error(\`The driver printed no name list for \${specifier}\`)
3734
3770
  return published
3735
3771
  }
@@ -3775,7 +3811,7 @@ export function buildDistributionStage(scratch: string): DistributionStage {
3775
3811
  const name = readDistributionManifestName(join(DISTRIBUTION_ROOT, 'package.json'))
3776
3812
  const installed = join(consumer, 'node_modules', ...name.split('/'))
3777
3813
  const manifest = readDistributionJSON(join(installed, 'package.json'))
3778
- if (!isDistributionRecord(manifest) || !isDistributionRecord(manifest.exports)) {
3814
+ if (!isRecord(manifest) || !isRecord(manifest.exports)) {
3779
3815
  throw new Error('The installed manifest publishes no exports map')
3780
3816
  }
3781
3817
  return { consumer, installed, archives, ...classifyDistributionStage(manifest, installed, name) }
@@ -3870,7 +3906,7 @@ export function classifyDistributionStage(
3870
3906
  installed: string,
3871
3907
  name: string,
3872
3908
  ): DistributionClassification {
3873
- if (!isDistributionRecord(manifest.exports))
3909
+ if (!isRecord(manifest.exports))
3874
3910
  throw new Error('The installed manifest publishes no exports map')
3875
3911
  const readings = Object.entries(manifest.exports).map(([subpath, mapping]) => {
3876
3912
  const files = collectDistributionTargets(mapping)
@@ -3957,13 +3993,7 @@ export function collectDistributionFiles(directory: string): readonly string[] {
3957
3993
  */
3958
3994
  export function readDistributionFace(installed: string, path: string): string | undefined {
3959
3995
  const [output, axis, face] = relativePath(installed, path).split(sep)
3960
- return output === 'dist'
3961
- ? axis === 'src'
3962
- ? face
3963
- : axis === 'bin'
3964
- ? 'bin'
3965
- : undefined
3966
- : undefined
3996
+ return output === 'dist' ? (axis === 'src' ? face : axis === 'bin' ? axis : undefined) : undefined
3967
3997
  }
3968
3998
 
3969
3999
  /**
@@ -4049,8 +4079,8 @@ export function scanDistributionSourceMaps(installed: string): readonly string[]
4049
4079
  : Buffer.from(payload[2], 'base64').toString('utf8'),
4050
4080
  )
4051
4081
  if (
4052
- !isDistributionRecord(map) ||
4053
- !isDistributionNames(map.sources) ||
4082
+ !isRecord(map) ||
4083
+ !arrayOf(isString)(map.sources) ||
4054
4084
  (map.sourceRoot !== undefined && typeof map.sourceRoot !== 'string')
4055
4085
  ) {
4056
4086
  throw new Error('Unreadable source map')
@@ -4216,8 +4246,7 @@ export function checkDistributionManifest(installed: string, scratch: string): r
4216
4246
  if (result.status !== 0)
4217
4247
  throw new Error(\`npm pkg fix failed: \${readDistributionOutput(result)}\`)
4218
4248
  const after = readDistributionJSON(path)
4219
- if (!isDistributionRecord(before) || !isDistributionRecord(after))
4220
- throw new Error('Unreadable manifest')
4249
+ if (!isRecord(before) || !isRecord(after)) throw new Error('Unreadable manifest')
4221
4250
  return [...new Set([...Object.keys(before), ...Object.keys(after)])]
4222
4251
  .filter((key) => !isDeepStrictEqual(before[key], after[key]))
4223
4252
  .sort()
@@ -4269,7 +4298,7 @@ export function buildDistributionCases(
4269
4298
  writeDistributionFile(join(root, 'module/package.json'), '{ "type": "module" }\\n')
4270
4299
  writeDistributionFile(join(root, 'commonjs/package.json'), '{ "type": "commonjs" }\\n')
4271
4300
  const manifest = readDistributionJSON(join(root, 'package.json'))
4272
- if (!isDistributionRecord(manifest) || !isDistributionRecord(manifest.exports)) {
4301
+ if (!isRecord(manifest) || !isRecord(manifest.exports)) {
4273
4302
  throw new Error('The classifier fixture declares no exports map')
4274
4303
  }
4275
4304
  const mappings = manifest.exports
@@ -4394,7 +4423,7 @@ export function buildDistributionCases(
4394
4423
  },
4395
4424
  expected: {
4396
4425
  undeclared: [],
4397
- partitioned: [...stage.subpaths].sort(),
4426
+ partitioned: stage.subpaths.toSorted(),
4398
4427
  unreachable: [],
4399
4428
  untypable: [],
4400
4429
  },
@@ -4540,6 +4569,8 @@ describe('installed package consumer', () => {
4540
4569
  })
4541
4570
  }
4542
4571
  {{guard}}{{drive}}})
4572
+ `,
4573
+ events: `import { once } from 'node:events'
4543
4574
  `,
4544
4575
  transport: `import { createServer } from 'node:http'
4545
4576
  `,
@@ -4668,9 +4699,8 @@ export async function readDistributionBrowserExports(
4668
4699
  response.end(readFileSync(path))
4669
4700
  })
4670
4701
  try {
4671
- await new Promise<void>((settle) => {
4672
- server.listen(0, '127.0.0.1', settle)
4673
- })
4702
+ server.listen(0, '127.0.0.1')
4703
+ await once(server, 'listening')
4674
4704
  const address = server.address()
4675
4705
  if (address === null || typeof address === 'string') {
4676
4706
  throw new Error('The bundle server bound no port')
@@ -4681,8 +4711,7 @@ export async function readDistributionBrowserExports(
4681
4711
  await page.goto(\`http://127.0.0.1:\${String(address.port)}/\`, { waitUntil: 'load' })
4682
4712
  const published: unknown = await page.evaluate('globalThis.subject')
4683
4713
  if (failures.length > 0) throw new Error(\`The bundle raised \${failures.join(' | ')}\`)
4684
- if (!isDistributionNames(published))
4685
- throw new Error('The bundled module published no name list')
4714
+ if (!arrayOf(isString)(published)) throw new Error('The bundled module published no name list')
4686
4715
  return published
4687
4716
  } finally {
4688
4717
  server.close()
@@ -5002,6 +5031,29 @@ function isCollection(value) {
5002
5031
  return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isArray)(value) && value.length <= 1e3);
5003
5032
  }
5004
5033
  /**
5034
+ * Narrows a manifest `exports` value to a map of subpaths.
5035
+ *
5036
+ * @param value - The declared `exports` value.
5037
+ * @returns True if the value is an object whose every key opens with `.`; false otherwise.
5038
+ *
5039
+ * @remarks
5040
+ * Node reads a string, an array, or an object whose keys are conditions, such as `import` and
5041
+ * `require`, as the root export alone, and refuses an object that mixes conditions with subpaths,
5042
+ * so a subpath can be added only to a subpath map. A value whose keys cannot be read answers
5043
+ * `false`.
5044
+ *
5045
+ * @example
5046
+ * ```ts
5047
+ * import { isSubpathMap } from '@orkestrel/scaffold'
5048
+ *
5049
+ * isSubpathMap({ '.': './index.js' }) // true
5050
+ * isSubpathMap({ import: './index.js' }) // false
5051
+ * ```
5052
+ */
5053
+ function isSubpathMap(value) {
5054
+ return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && Object.keys(value).every((key) => key.startsWith(".")));
5055
+ }
5056
+ /**
5005
5057
  * Narrows a value to one {@link Environment} a workspace may select.
5006
5058
  *
5007
5059
  * @example
@@ -5042,6 +5094,22 @@ function isSheetName(value) {
5042
5094
  return (0, _orkestrel_contract.isString)(value) && value.length <= 203 && NAME_PATTERN.test(value) && !RESERVED_SHEET_NAMES.includes(value);
5043
5095
  }
5044
5096
  /**
5097
+ * Narrows a value to the stem of a `src/bin` module.
5098
+ * @param value - The candidate stem.
5099
+ * @returns True if the stem matches `BIN_MODULE_PATTERN` within the name length cap and names no
5100
+ * centralized file; false otherwise.
5101
+ * @example
5102
+ * ```ts
5103
+ * import { isBinModule } from '@orkestrel/scaffold'
5104
+ *
5105
+ * isBinModule('reporter') // true
5106
+ * isBinModule('helpers') // false
5107
+ * ```
5108
+ */
5109
+ function isBinModule(value) {
5110
+ return (0, _orkestrel_contract.isString)(value) && value.length <= 203 && BIN_MODULE_PATTERN.test(value) && !CENTRAL_FILE_NAMES.includes(value);
5111
+ }
5112
+ /**
5045
5113
  * Narrows a value to a supported browser framework with distinct occupied axes.
5046
5114
  * @param value - The candidate extension.
5047
5115
  * @returns True if the value is an admitted extension; false otherwise.
@@ -5233,7 +5301,7 @@ var isBlueprint = (0, _orkestrel_contract.recordOf)({
5233
5301
  version: _orkestrel_contract.isString,
5234
5302
  engines: _orkestrel_contract.isString,
5235
5303
  overrides: (0, _orkestrel_contract.andOf)(isCollection, (0, _orkestrel_contract.arrayOf)(isOverride)),
5236
- bin: _orkestrel_contract.isBoolean,
5304
+ bin: (0, _orkestrel_contract.andOf)(isCollection, (0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)),
5237
5305
  setup: (0, _orkestrel_contract.andOf)(isCollection, (0, _orkestrel_contract.arrayOf)((0, _orkestrel_contract.literalOf)("node", "browser"))),
5238
5306
  guides: _orkestrel_contract.isBoolean,
5239
5307
  integration: _orkestrel_contract.isBoolean,
@@ -6843,6 +6911,106 @@ function manifestToDependencies(manifest) {
6843
6911
  };
6844
6912
  }
6845
6913
  /**
6914
+ * Projects a package manifest's text to the planned `bin`, `files`, and `exports` entries it lacks.
6915
+ *
6916
+ * @param manifest - The `package.json` text.
6917
+ * @param planned - The entries the plan emits.
6918
+ * @returns The planned entries the manifest does not declare, each in planned order.
6919
+ *
6920
+ * @remarks
6921
+ * A planned command counts as declared when the manifest names it, or when any declared command
6922
+ * runs the planned file: a package keeps the command name it publishes. A string `bin` declares
6923
+ * the planned command when it names the planned file. A planned packed path counts as declared
6924
+ * when a declared path equals it or names a directory above it, as {@link matchesPackedPath} reads
6925
+ * the pair. A subpath counts as declared by name alone, so a declared entry holding another value
6926
+ * stays the package's. A string `exports`, a fallback array, or an object whose keys are conditions
6927
+ * rather than subpaths declares the root subpath `.` alone, as Node reads each. A section holding any other shape declares none of
6928
+ * its planned entries. A manifest that is not an object lacks nothing, because no entry can be read
6929
+ * from it or written into it.
6930
+ *
6931
+ * @example
6932
+ * ```ts
6933
+ * import { manifestToEntries } from '@orkestrel/scaffold'
6934
+ *
6935
+ * manifestToEntries('{"files": ["dist/src"]}', {
6936
+ * bin: {},
6937
+ * files: ['dist/src', 'dist/bin'],
6938
+ * exports: {},
6939
+ * }).files // ['dist/bin']
6940
+ * ```
6941
+ */
6942
+ function manifestToEntries(manifest, planned) {
6943
+ const parsed = (0, _orkestrel_contract.parseJSON)(manifest);
6944
+ if (!(0, _orkestrel_contract.isRecord)(parsed)) return {
6945
+ bin: {},
6946
+ files: [],
6947
+ exports: {}
6948
+ };
6949
+ const { bin, files, exports } = parsed;
6950
+ const commands = (0, _orkestrel_contract.isString)(bin) ? { "": bin } : (0, _orkestrel_contract.isRecord)(bin) ? bin : {};
6951
+ const runs = Object.values(commands).flatMap((path) => (0, _orkestrel_contract.isString)(path) ? [normalizePackagePath(path)] : []);
6952
+ const packed = (0, _orkestrel_contract.isArray)(files) ? files.filter(_orkestrel_contract.isString) : [];
6953
+ const subpaths = isSubpathMap(exports) ? exports : (0, _orkestrel_contract.isString)(exports) || (0, _orkestrel_contract.isArray)(exports) || (0, _orkestrel_contract.isRecord)(exports) ? { ".": exports } : {};
6954
+ return {
6955
+ bin: Object.fromEntries(Object.entries(planned.bin).filter(([name, path]) => !((0, _orkestrel_contract.isRecord)(bin) && Object.hasOwn(bin, name)) && !runs.includes(normalizePackagePath(path)))),
6956
+ files: planned.files.filter((path) => !packed.some((declared) => matchesPackedPath(declared, path))),
6957
+ exports: Object.fromEntries(Object.entries(planned.exports).filter(([path]) => !Object.hasOwn(subpaths, path)))
6958
+ };
6959
+ }
6960
+ /**
6961
+ * Returns the canonical form of a path a manifest names inside its package.
6962
+ *
6963
+ * @param path - A `bin` target or a `files` entry.
6964
+ * @returns The path with `/` for every backslash, one `/` for every run of separators, and no
6965
+ * leading `./` or trailing `/`.
6966
+ *
6967
+ * @remarks
6968
+ * npm reads a backslash in a `bin` or `files` path as a separator and collapses repeated
6969
+ * separators, so `dist\bin\main.js` and `dist//bin/main.js` name `dist/bin/main.js`.
6970
+ *
6971
+ * @example
6972
+ * ```ts
6973
+ * import { normalizePackagePath } from '@orkestrel/scaffold'
6974
+ *
6975
+ * normalizePackagePath('./dist/bin/main.js') // 'dist/bin/main.js'
6976
+ * normalizePackagePath('dist//bin/main.js') // 'dist/bin/main.js'
6977
+ * ```
6978
+ */
6979
+ function normalizePackagePath(path) {
6980
+ return path.replaceAll("\\", "/").replace(/\/{2,}/gu, "/").replace(/^(\.\/)+/u, "").replace(/\/+$/u, "");
6981
+ }
6982
+ /**
6983
+ * Checks whether a declared `files` entry packs a planned one.
6984
+ *
6985
+ * @param declared - The entry the manifest declares.
6986
+ * @param planned - The entry the plan emits.
6987
+ * @returns True if the entries are equal, or the declared entry names a directory whose path
6988
+ * segments open the planned entry's; false otherwise.
6989
+ *
6990
+ * @remarks
6991
+ * A declared entry ending in `/**` or `/*` packs the directory it names, so `dist/**` packs
6992
+ * `dist/app`. No other glob is read: an entry such as `dist/*.js` packs no planned path it does not
6993
+ * equal. A negated entry such as `!dist/src/styles/index.js` excludes a path rather than packing
6994
+ * one, so only an equal entry declares it.
6995
+ *
6996
+ * @example
6997
+ * ```ts
6998
+ * import { matchesPackedPath } from '@orkestrel/scaffold'
6999
+ *
7000
+ * matchesPackedPath('dist', 'dist/app') // true
7001
+ * matchesPackedPath('dist-old', 'dist/app') // false
7002
+ * ```
7003
+ */
7004
+ function matchesPackedPath(declared, planned) {
7005
+ const left = normalizePackagePath(declared).replace(/\/\*\*?$/u, "");
7006
+ const right = normalizePackagePath(planned);
7007
+ if (left === right) return true;
7008
+ if (left.startsWith("!") || right.startsWith("!") || left === "") return false;
7009
+ const segments = left.split("/");
7010
+ const target = right.split("/");
7011
+ return segments.length < target.length && segments.every((segment, index) => segment === target[index]);
7012
+ }
7013
+ /**
6846
7014
  * Renders the `SKILL.md` pointer a target carries in place of a canonical skill.
6847
7015
  *
6848
7016
  * @param canonical - The canonical `SKILL.md` text, which opens with a frontmatter block.
@@ -6953,9 +7121,10 @@ function blueprintToSheets(blueprint) {
6953
7121
  return [...blueprint.styles ? ["styles"] : [], ...(0, _orkestrel_contract.sortValues)(blueprint.extensions.flatMap((extension) => extension.surface === "styles" && isSheetName(extension.name) ? [extension.name] : []))];
6954
7122
  }
6955
7123
  /**
6956
- * Projects published environments and sheets into the manifest export map.
7124
+ * Projects published environments, sheets, and `src/bin` modules into the manifest export map.
6957
7125
  * @param blueprint - The workspace specification.
6958
- * @returns JavaScript conditions and CSS and SCSS subpaths, without an invented JavaScript root.
7126
+ * @returns JavaScript conditions, CSS and SCSS subpaths, and the ES-only `./<name>` subpath of
7127
+ * each `src/bin` module other than `main`, without an invented JavaScript root.
6959
7128
  * @example
6960
7129
  * ```ts
6961
7130
  * import { blueprintToExports, createBlueprint } from '@orkestrel/scaffold'
@@ -6971,7 +7140,8 @@ function blueprintToExports(blueprint) {
6971
7140
  const face = [`./${extension.name}`, pathToCondition(`./dist/src/${extension.name}/index`, ["es"])];
6972
7141
  return blueprint.src.includes("browser") ? [face, ["./browser", pathToCondition("./dist/src/browser/index", ["es"])]] : [face];
6973
7142
  })),
6974
- ...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([...blueprintToSheets(blueprint), ...blueprint.themes ? ["styles/themes"] : []].flatMap((name) => [[`./${name}`, `./dist/src/${name}/index.css`], [`./${name}/scss`, `./src/${name}/index.scss`]])),
7144
+ ...Object.fromEntries(blueprint.bin.flatMap((name) => name === "main" ? [] : [[`./${name}`, pathToCondition(`./dist/bin/${name}`, ["es"])]]))
6975
7145
  };
6976
7146
  return Object.keys(exported).length > 0 ? {
6977
7147
  ...exported,
@@ -7145,9 +7315,8 @@ function blueprintToDevDependencies(blueprint) {
7145
7315
  ...rendered && !BROWSE_UPSTREAM.includes(own) ? BROWSE_DEV_DEPENDENCIES : {},
7146
7316
  ...blueprint.journey && blueprint.app.includes("browser") && (blueprint.base || blueprintToFaces(blueprint).some((extension) => extension.axes.includes("app"))) && !CAPTURE_UPSTREAM.includes(own) ? CAPTURE_DEV_DEPENDENCIES : {},
7147
7317
  ...sheets ? STYLES_DEV_DEPENDENCIES : {},
7148
- ...blueprint.src.length > 0 || blueprint.bin ? DECLARATION_DEV_DEPENDENCIES : {},
7318
+ ...blueprint.src.length > 0 || blueprint.bin.length > 0 ? DECLARATION_DEV_DEPENDENCIES : {},
7149
7319
  ...blueprint.src.includes("browser") || blueprint.setup.includes("browser") || sheets ? SOURCE_BROWSER_DEV_DEPENDENCIES : {},
7150
- ...blueprint.app.length > 0 ? APP_DEV_DEPENDENCIES : {},
7151
7320
  ...blueprint.app.includes("browser") ? APP_BROWSER_DEV_DEPENDENCIES : {},
7152
7321
  ...blueprint.app.includes("server") ? APP_SERVER_DEV_DEPENDENCIES : {},
7153
7322
  ...Object.fromEntries(blueprintToMachinery(blueprint).frameworks.flatMap((framework) => Object.entries(FRAMEWORK_MATRIX[framework].dependencies))),
@@ -7339,7 +7508,7 @@ function blueprintToScripts(blueprint) {
7339
7508
  const checker = application.includes("vue") ? FRAMEWORK_MATRIX.vue.checker : "tsc";
7340
7509
  const publishes = blueprint.src.length > 0 || targets.length > 0;
7341
7510
  const integrates = blueprint.integration;
7342
- const compiles = publishes || blueprint.bin;
7511
+ const compiles = publishes || blueprint.bin.length > 0;
7343
7512
  const runtime = blueprint.app.filter((environment) => environment !== "core" && (environment !== "browser" || base));
7344
7513
  const vitest = "vitest run --config vite.config.ts --no-cache --reporter=dot";
7345
7514
  const built = [...runtime, ...application].flatMap((environment) => environment === "server" && matchesBarrel(blueprint) ? [environment, "barrel"] : [environment]);
@@ -7347,7 +7516,7 @@ function blueprintToScripts(blueprint) {
7347
7516
  ...blueprint.src,
7348
7517
  ...source,
7349
7518
  ...sheets,
7350
- ...blueprint.bin ? ["bin"] : []
7519
+ ...blueprint.bin.length > 0 ? ["bin"] : []
7351
7520
  ].map((name) => `npm run check:src:${name}`);
7352
7521
  const journey = `vitest run --config ${JOURNEY_CONFIG_PATH} --no-cache --reporter=dot`;
7353
7522
  const showcase = `vite --config ${SHOWCASE_CONFIG_PATH}`;
@@ -7368,7 +7537,7 @@ function blueprintToScripts(blueprint) {
7368
7537
  ...checks.length > 0 ? {
7369
7538
  "check:src": checks.join(" && "),
7370
7539
  ...Object.fromEntries(Iterator.from(blueprint.src).map((environment) => [`check:src:${environment}`, `tsc --noEmit -p configs/src/tsconfig.${environment}.json`]).toArray()),
7371
- ...blueprint.bin ? { "check:src:bin": "tsc --noEmit -p configs/src/tsconfig.bin.json" } : {},
7540
+ ...blueprint.bin.length > 0 ? { "check:src:bin": "tsc --noEmit -p configs/src/tsconfig.bin.json" } : {},
7372
7541
  ...Object.fromEntries([...sheets, ...source].map((name) => [`check:src:${name}`, `tsc --noEmit -p configs/src/tsconfig.${name}.json`]))
7373
7542
  } : {},
7374
7543
  ...blueprint.app.length > 0 ? {
@@ -7393,14 +7562,14 @@ function blueprintToScripts(blueprint) {
7393
7562
  ...!publishes && blueprint.service ? ["npm run test:service"] : []
7394
7563
  ].join(" && "),
7395
7564
  ...compiles ? {
7396
- "test:src": [...blueprint.src.length > 0 || blueprint.bin ? [[
7565
+ "test:src": [...blueprint.src.length > 0 || blueprint.bin.length > 0 ? [[
7397
7566
  vitest,
7398
7567
  ...blueprint.src.map((environment) => `--project ${SRC_MATRIX[environment].project}`),
7399
7568
  ...source.map((name) => `--project src:${name}`),
7400
- ...blueprint.bin ? ["--project src:bin"] : []
7569
+ ...blueprint.bin.length > 0 ? ["--project src:bin"] : []
7401
7570
  ].join(" ")] : [], ...targets.map((name) => `npm run test:src:${name}`)].join(" && "),
7402
7571
  ...Object.fromEntries(Iterator.from(blueprint.src).map((environment) => [`test:src:${environment}`, `${vitest} --project ${SRC_MATRIX[environment].project}`]).toArray()),
7403
- ...blueprint.bin ? { "test:src:bin": `${vitest} --project src:bin` } : {},
7572
+ ...blueprint.bin.length > 0 ? { "test:src:bin": `${vitest} --project src:bin` } : {},
7404
7573
  ...Object.fromEntries(source.map((name) => [`test:src:${name}`, `${vitest} --project src:${name}`])),
7405
7574
  ...Object.fromEntries(targets.map((name) => [`test:src:${name}`, `npm run build:src:${name} && ${vitest} --project src:${name}`]))
7406
7575
  } : {},
@@ -7447,10 +7616,10 @@ function blueprintToScripts(blueprint) {
7447
7616
  ...blueprint.src.map((environment) => `npm run build:src:${environment}`),
7448
7617
  ...source.map((name) => `npm run build:src:${name}`),
7449
7618
  ...targets.map((name) => `npm run build:src:${name}`),
7450
- ...blueprint.bin ? ["npm run build:src:bin"] : []
7619
+ ...blueprint.bin.length > 0 ? ["npm run build:src:bin"] : []
7451
7620
  ].join(" && "),
7452
7621
  ...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()),
7453
- ...blueprint.bin ? { "build:src:bin": "vite build --config configs/src/vite.bin.config.ts" } : {},
7622
+ ...blueprint.bin.length > 0 ? { "build:src:bin": "vite build --config configs/src/vite.bin.config.ts" } : {},
7454
7623
  ...Object.fromEntries(source.map((name) => [`build:src:${name}`, `vite build --config configs/src/vite.${name}.config.ts`])),
7455
7624
  ...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(" && ")]))
7456
7625
  } : {},
@@ -7493,9 +7662,10 @@ function blueprintToScripts(blueprint) {
7493
7662
  * Every direct `test:<project>` script is writable, together with the probe and
7494
7663
  * benchmark workbench scripts. A workspace carrying guides adds `test:guides`,
7495
7664
  * whose package-owned entry runs the guides project and handles explicit parity
7496
- * rewrites, and one carrying skills adds `test:skills`. Publishing adds the pack and publication lifecycle scripts.
7497
- * Sheet and framework faces add their check and build scripts, application frameworks add dev scripts,
7498
- * and selected showcases and journeys add their mode scripts.
7665
+ * rewrites, and one carrying skills adds `test:skills`. Publishing adds the pack and publication
7666
+ * lifecycle scripts. Library environments, sheet faces, framework faces, and `src/bin` modules
7667
+ * add their check and build scripts, application
7668
+ * frameworks add dev scripts, and selected showcases and journeys add their mode scripts.
7499
7669
  * A base browser application's journey axis also adds `journey` and `capture`, and each
7500
7670
  * app-side browser face adds `journey:<name>` and `capture:<name>`. Their generated
7501
7671
  * commands are writable and have no predecessor forms; customized values remain caller-owned.
@@ -7512,10 +7682,10 @@ function blueprintToScripts(blueprint) {
7512
7682
  * existed. The pack hook accepts the build chain emitted before it
7513
7683
  * delegated to `build`. The publication hook accepts the same gate chain without
7514
7684
  * {@link RELEASE_PROOF_COMMAND}. No accepted publication chain carries a study
7515
- * step. `serve:build` accepts the server-only chain it ran before it delegated to
7516
- * `build`. The value being written is always writable, so it is not repeated there. Any other value is a script the workspace author
7517
- * customized, and {@link replaceManifestScripts} retains it while writing the
7518
- * other named scripts independently.
7685
+ * step. `serve:build` accepts the server-only chain it ran before it delegated to `build`.
7686
+ * The value being written is always writable, so it is not repeated there. Any other value is a
7687
+ * script the workspace author customized, and {@link replaceManifestScripts} retains it while
7688
+ * writing the other named scripts independently.
7519
7689
  *
7520
7690
  * @example
7521
7691
  * ```ts
@@ -7523,7 +7693,7 @@ function blueprintToScripts(blueprint) {
7523
7693
  *
7524
7694
  * const blueprint = createBlueprint('router', { src: ['core'] })
7525
7695
  *
7526
- * blueprintToWritableScripts(blueprint)[0]?.name // 'test:src:core'
7696
+ * blueprintToWritableScripts(blueprint)[0]?.name // 'check:src:core'
7527
7697
  * ```
7528
7698
  */
7529
7699
  function blueprintToWritableScripts(blueprint) {
@@ -7532,12 +7702,13 @@ function blueprintToWritableScripts(blueprint) {
7532
7702
  const body = Object.entries(scripts).flatMap(([name, command]) => {
7533
7703
  const direct = name.startsWith("test:") && name !== "test:src" && name !== "test:app";
7534
7704
  const sheet = sheets.some((face) => name === `build:src:${face}` || name === `check:src:${face}`);
7705
+ const entry = [...blueprint.src, "bin"].some((face) => name === `build:src:${face}` || name === `check:src:${face}`);
7535
7706
  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}`)));
7536
7707
  const showcase = name === "showcase" || name.startsWith("showcase:") || name === "build:showcase" || name.startsWith("build:showcase:");
7537
7708
  const capture = name === "journey" || name === "capture";
7538
7709
  const barrel = matchesBarrel(blueprint) && name === "build:app:barrel";
7539
7710
  const served = blueprint.app.includes("server") && name === "serve:build";
7540
- if (!direct && !sheet && !framework && !showcase && !capture && !barrel && !served) return [];
7711
+ if (!direct && !sheet && !entry && !framework && !showcase && !capture && !barrel && !served) return [];
7541
7712
  return [{
7542
7713
  name,
7543
7714
  command,
@@ -7562,6 +7733,45 @@ function blueprintToWritableScripts(blueprint) {
7562
7733
  ];
7563
7734
  }
7564
7735
  /**
7736
+ * Projects a blueprint into the `bin`, `files`, and `exports` entries its manifest carries.
7737
+ *
7738
+ * @param blueprint - The workspace specification.
7739
+ * @returns The planned commands, packed paths, and subpaths, each in the order the manifest emits.
7740
+ *
7741
+ * @remarks
7742
+ * A workspace without an executable plans no command, and one publishing nothing plans no
7743
+ * subpath, because its manifest carries no `exports` map. `dist/src` is packed only where a
7744
+ * library environment or a sheet builds into it: an executable reaches `dist/src` only through
7745
+ * the `@src/*` specifiers its build rewrites, one per library environment, so an executable
7746
+ * beside no library environment bundles what it imports and packs `dist/bin` alone. A workspace
7747
+ * publishing nothing packs `dist/app` when it builds an application.
7748
+ *
7749
+ * @example
7750
+ * ```ts
7751
+ * import { blueprintToEntries, createBlueprint } from '@orkestrel/scaffold'
7752
+ *
7753
+ * blueprintToEntries(createBlueprint('router', { src: ['core'], bin: ['main'] })).files
7754
+ * // ['dist/src', 'dist/bin', 'README.md']
7755
+ * ```
7756
+ */
7757
+ function blueprintToEntries(blueprint) {
7758
+ const sheets = blueprintToSheets(blueprint);
7759
+ const targets = [...sheets, ...blueprint.themes ? ["styles/themes"] : []];
7760
+ const publishes = blueprint.src.length > 0 || targets.length > 0;
7761
+ return {
7762
+ bin: blueprint.bin.includes("main") ? { [blueprint.name]: BIN_OUTPUT_PATH } : {},
7763
+ files: [
7764
+ ...publishes ? ["dist/src"] : blueprint.app.length > 0 ? ["dist/app"] : [],
7765
+ ...blueprint.bin.length > 0 ? ["dist/bin"] : [],
7766
+ ...targets.map((face) => `!dist/src/${face}/index.js`),
7767
+ ...sheets.map((face) => `src/${face}/**/*.scss`),
7768
+ ...blueprint.themes && !blueprint.styles ? ["src/styles/themes/**/*.scss"] : [],
7769
+ "README.md"
7770
+ ],
7771
+ exports: publishes ? blueprintToExports(blueprint) : {}
7772
+ };
7773
+ }
7774
+ /**
7565
7775
  * Compiles a blueprint into its `package.json` content.
7566
7776
  *
7567
7777
  * @param blueprint - The workspace specification.
@@ -7597,15 +7807,15 @@ function blueprintToWritableScripts(blueprint) {
7597
7807
  * ```
7598
7808
  */
7599
7809
  function blueprintToManifest(blueprint) {
7600
- const sheets = blueprintToSheets(blueprint);
7601
- const targets = [...sheets, ...blueprint.themes ? ["styles/themes"] : []];
7810
+ const targets = [...blueprintToSheets(blueprint), ...blueprint.themes ? ["styles/themes"] : []];
7602
7811
  const publishes = blueprint.src.length > 0 || targets.length > 0;
7603
7812
  const name = publishes ? `@orkestrel/${blueprint.name}` : blueprint.name;
7604
- const dependencies = Object.fromEntries([...blueprint.dependencies].sort((left, right) => (0, _orkestrel_contract.comparePrimitives)(left.name, right.name)).map((dependency) => [dependency.name, dependency.range]));
7605
- const peers = [...blueprint.peers].sort((left, right) => (0, _orkestrel_contract.comparePrimitives)(left.name, right.name));
7813
+ const dependencies = Object.fromEntries(blueprint.dependencies.toSorted((left, right) => (0, _orkestrel_contract.comparePrimitives)(left.name, right.name)).map((dependency) => [dependency.name, dependency.range]));
7814
+ const peers = blueprint.peers.toSorted((left, right) => (0, _orkestrel_contract.comparePrimitives)(left.name, right.name));
7606
7815
  const peerDependencies = Object.fromEntries(peers.map((peer) => [peer.name, peer.range]));
7607
7816
  const peerDependenciesMeta = Object.fromEntries(peers.filter((peer) => peer.optional === true).map((peer) => [peer.name, { optional: true }]));
7608
7817
  const entry = srcToEntry(blueprint.src);
7818
+ const entries = blueprintToEntries(blueprint);
7609
7819
  const manifest = {
7610
7820
  name,
7611
7821
  version: blueprint.version,
@@ -7621,20 +7831,13 @@ function blueprintToManifest(blueprint) {
7621
7831
  type: "git",
7622
7832
  url: `git+https://github.com/orkestrel/${blueprint.name}.git`
7623
7833
  } } : {},
7624
- ...blueprint.bin ? { bin: { [blueprint.name]: BIN_OUTPUT_PATH } } : {},
7625
- files: [
7626
- blueprint.bin || publishes ? "dist/src" : "dist/app",
7627
- ...blueprint.bin ? ["dist/bin"] : [],
7628
- ...targets.map((face) => `!dist/src/${face}/index.js`),
7629
- ...sheets.map((face) => `src/${face}/**/*.scss`),
7630
- ...blueprint.themes && !blueprint.styles ? ["src/styles/themes/**/*.scss"] : [],
7631
- "README.md"
7632
- ],
7834
+ ...blueprint.bin.includes("main") ? { bin: entries.bin } : {},
7835
+ files: entries.files,
7633
7836
  type: "module",
7634
7837
  ...publishes ? {
7635
- sideEffects: targets.length > 0 || blueprint.bin ? [...targets.length > 0 ? ["**/*.css", "**/*.scss"] : [], ...blueprint.bin ? [`./${BIN_ENTRY_PATH}`, `./${BIN_OUTPUT_PATH}`] : []] : false,
7838
+ sideEffects: targets.length > 0 || blueprint.bin.includes("main") ? [...targets.length > 0 ? ["**/*.css", "**/*.scss"] : [], ...blueprint.bin.includes("main") ? [`./${BIN_ENTRY_PATH}`, `./${BIN_OUTPUT_PATH}`] : []] : false,
7636
7839
  ...blueprint.src.length > 0 ? entry : {},
7637
- exports: blueprintToExports(blueprint),
7840
+ exports: entries.exports,
7638
7841
  publishConfig: { access: "public" }
7639
7842
  } : {},
7640
7843
  scripts: blueprintToScripts(blueprint),
@@ -7681,7 +7884,7 @@ function blueprintToMachinery(blueprint) {
7681
7884
  return {
7682
7885
  browser: blueprint.src.includes("browser") || blueprint.app.includes("browser") || blueprint.setup.includes("browser") || blueprintToSheets(blueprint).length > 0 || blueprint.themes || frameworks.length > 0,
7683
7886
  frameworks,
7684
- output: blueprint.src.length > 0 || blueprint.bin || hosted || blueprintToSheets(blueprint).length > 0 || blueprint.themes,
7887
+ output: blueprint.src.length > 0 || blueprint.bin.length > 0 || hosted || blueprintToSheets(blueprint).length > 0 || blueprint.themes,
7685
7888
  showcase: blueprint.showcase && (blueprint.base && blueprint.app.includes("browser") || blueprintToFaces(blueprint).some((extension) => extension.axes.includes("app")))
7686
7889
  };
7687
7890
  }
@@ -7778,7 +7981,7 @@ function blueprintToProjects(blueprint) {
7778
7981
  ...AXES.flatMap((axis) => [
7779
7982
  ...ENVIRONMENTS.filter((environment) => (axis !== "app" || environment !== "server") && blueprint[axis].includes(environment)).map((environment) => `${axis}:${environment}`),
7780
7983
  ...faces.filter((face) => face.axes.includes(axis)).map((face) => `${axis}:${face.name}`),
7781
- ...axis === "src" && blueprint.bin ? ["src:bin"] : [],
7984
+ ...axis === "src" && blueprint.bin.length > 0 ? ["src:bin"] : [],
7782
7985
  ...axis === "app" && blueprint.app.includes("server") ? ["app:server"] : []
7783
7986
  ]),
7784
7987
  "policy",
@@ -7908,7 +8111,7 @@ function blueprintToRootVite(blueprint) {
7908
8111
  exclude: core ? " exclude: ['tests/src/core/**/*.test.ts'],\n" : ""
7909
8112
  })) : [],
7910
8113
  ...planned.has("src:vue") ? [CONFIG_TEMPLATES.factories.src.vue] : [],
7911
- ...planned.has("src:bin") ? [CONFIG_TEMPLATES.factories.src.bin] : [],
8114
+ ...planned.has("src:bin") ? [(0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.factories.src.bin, { entries: blueprint.bin.map((name) => `\t\t\t\t\t${name}: resolveWorkspacePath(${serializeTypeScriptString(`src/bin/${name}.ts`)}),`).join("\n") })] : [],
7912
8115
  ...planned.has("app:core") ? [CONFIG_TEMPLATES.factories.app.core] : [],
7913
8116
  ...planned.has("app:browser") ? [(0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.factories.app.browser, {
7914
8117
  vuePlugin: machinery.frameworks.includes("vue") ? ", vue()" : "",
@@ -8057,16 +8260,19 @@ function blueprintToConfigArtifacts(blueprint) {
8057
8260
  environment,
8058
8261
  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
8059
8262
  }))).toArray();
8060
- const paths = blueprint.bin ? blueprint.src.map((environment) => `\t\t\t\t\t\t'@src/${environment}': '../src/${environment}/index.js',`) : [];
8263
+ const paths = blueprint.bin.length > 0 ? blueprint.src.map((environment) => `\t\t\t\t\t\t'@src/${environment}': '../src/${environment}/index.js',`) : [];
8061
8264
  const renderedPaths = paths.length === 0 ? " paths: {}," : `\t\t\t\t\tpaths: {
8062
8265
  ${paths.join("\n")}
8063
8266
  },`;
8064
- const bins = blueprint.bin ? BIN_CONFIGS.map((path) => ({
8267
+ const bins = blueprint.bin.length > 0 ? BIN_CONFIGS.map((path) => ({
8065
8268
  path,
8066
8269
  group: "configs",
8067
8270
  ownership: "content",
8068
8271
  origin: "template",
8069
- content: path === "configs/src/tsconfig.bin.json" ? CONFIG_TEMPLATES.tsconfigs.bin : (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.vites.bin, { paths: renderedPaths })
8272
+ content: path === "configs/src/tsconfig.bin.json" ? CONFIG_TEMPLATES.tsconfigs.bin : (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.vites.bin, {
8273
+ modules: blueprint.bin.filter((name) => name !== "main").map((name) => serializeTypeScriptString(name)).join(", "),
8274
+ paths: renderedPaths
8275
+ })
8070
8276
  })) : [];
8071
8277
  const barrels = matchesBarrel(blueprint) ? BARREL_CONFIGS.map((path) => ({
8072
8278
  path,
@@ -8292,7 +8498,7 @@ function blueprintToSourceArtifacts(blueprint) {
8292
8498
  }))
8293
8499
  ] : [barrel];
8294
8500
  }));
8295
- const bin = blueprint.bin ? [{
8501
+ const bin = blueprint.bin.includes("main") ? [{
8296
8502
  path: BIN_ENTRY_PATH,
8297
8503
  group: "source",
8298
8504
  ownership: "birth",
@@ -8391,7 +8597,7 @@ function blueprintToTestArtifacts(blueprint) {
8391
8597
  environment: "browser",
8392
8598
  content: blueprint.journey ? ARTIFACT_TEMPLATES.tests.browser : ARTIFACT_TEMPLATES.tests.setup
8393
8599
  }] : [];
8394
- const servers = blueprint.src.includes("server") || blueprint.app.includes("server") || blueprint.bin || blueprint.conformance || blueprint.tree ? [{
8600
+ const servers = blueprint.src.includes("server") || blueprint.app.includes("server") || blueprint.bin.length > 0 || blueprint.conformance || blueprint.tree ? [{
8395
8601
  path: "tests/setupServer.ts",
8396
8602
  group: "tests",
8397
8603
  ownership: "birth",
@@ -8448,7 +8654,7 @@ function blueprintToTestArtifacts(blueprint) {
8448
8654
  })).toArray();
8449
8655
  const binSpecifier = serializeTypeScriptString("../../../src/bin/main.js");
8450
8656
  const joinedImport = `\t\tconst entry = await import(${binSpecifier})`;
8451
- const bins = blueprint.bin ? [{
8657
+ const bins = blueprint.bin.includes("main") ? [{
8452
8658
  path: "tests/src/bin/main.test.ts",
8453
8659
  group: "tests",
8454
8660
  ownership: "birth",
@@ -8474,6 +8680,7 @@ function blueprintToTestArtifacts(blueprint) {
8474
8680
  origin: "template",
8475
8681
  content: (0, _orkestrel_template.fillTemplate)(distribution.module, {
8476
8682
  types: browser ? distribution.types : "",
8683
+ events: browser ? distribution.events : "",
8477
8684
  transport: browser ? distribution.transport : "",
8478
8685
  launcher: browser ? distribution.launcher : "",
8479
8686
  helpers: browser ? distribution.helpers : ""
@@ -8564,7 +8771,7 @@ function blueprintToGuideArtifacts(blueprint) {
8564
8771
  directory: `src/${environment}`,
8565
8772
  test: `tests/src/${environment}`
8566
8773
  })),
8567
- ...blueprint.bin ? [{
8774
+ ...blueprint.bin.length > 0 ? [{
8568
8775
  directory: "src/bin",
8569
8776
  test: "tests/src/bin"
8570
8777
  }] : [],
@@ -8962,7 +9169,7 @@ function insertManifestDependencies(manifest, additions) {
8962
9169
  function insertManifestSection(manifest, section, dependencies, present) {
8963
9170
  const tokens = scanManifestTokens(manifest);
8964
9171
  if (tokens === void 0) return void 0;
8965
- const ordered = [...dependencies].sort((left, right) => (0, _orkestrel_contract.comparePrimitives)(left.name, right.name));
9172
+ const ordered = dependencies.toSorted((left, right) => (0, _orkestrel_contract.comparePrimitives)(left.name, right.name));
8966
9173
  const lines = ordered.map(({ name, range }) => `${JSON.stringify(name)}: ${JSON.stringify(range)}`);
8967
9174
  const sibling = section === "dependencies" ? "devDependencies" : "dependencies";
8968
9175
  const occurrences = tokens.flatMap((token, at) => {
@@ -9037,6 +9244,154 @@ function insertManifestSection(manifest, section, dependencies, present) {
9037
9244
  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);
9038
9245
  }
9039
9246
  /**
9247
+ * Inserts the planned `bin`, `files`, and `exports` entries a package manifest lacks.
9248
+ *
9249
+ * @param manifest - The manifest text to compile.
9250
+ * @param planned - The entries the plan emits, each in planned order.
9251
+ * @returns The manifest declaring every planned entry, or `undefined` when the text is not a
9252
+ * manifest object, or a section that must take an entry holds a value of another shape: `bin` not
9253
+ * an object, `exports` not a map of subpaths, or `files` not an array of strings.
9254
+ *
9255
+ * @remarks
9256
+ * The compiler inserts text instead of serializing the manifest, so every declared byte survives,
9257
+ * and a declared entry keeps its value whatever the plan holds. An inserted entry lands before the
9258
+ * first declared entry the plan orders after it, or after the last declared entry when none does,
9259
+ * and copies the indentation of the section's first entry; a nested value takes the same step per
9260
+ * level. An absent section is created as one top-level key holding the planned entries, before the
9261
+ * first declared key `MANIFEST_KEY_ORDER` orders after it, or last in the manifest object. A
9262
+ * manifest declaring every planned entry is returned unchanged.
9263
+ *
9264
+ * @example
9265
+ * ```ts
9266
+ * import { insertManifestEntries } from '@orkestrel/scaffold'
9267
+ *
9268
+ * insertManifestEntries('{\n\t"files": [\n\t\t"dist/src",\n\t\t"README.md"\n\t]\n}\n', {
9269
+ * bin: {},
9270
+ * files: ['dist/src', 'dist/bin', 'README.md'],
9271
+ * exports: {},
9272
+ * })
9273
+ * // '{\n\t"files": [\n\t\t"dist/src",\n\t\t"dist/bin",\n\t\t"README.md"\n\t]\n}\n'
9274
+ * ```
9275
+ */
9276
+ function insertManifestEntries(manifest, planned) {
9277
+ const parsed = (0, _orkestrel_contract.parseJSON)(manifest);
9278
+ const tokens = scanManifestTokens(manifest);
9279
+ if (!(0, _orkestrel_contract.isRecord)(parsed) || tokens === void 0) return void 0;
9280
+ const missing = manifestToEntries(manifest, planned);
9281
+ const keys = tokens.flatMap((token, at) => {
9282
+ const name = token.depth === 1 && token.value !== void 0 ? (0, _orkestrel_contract.parseJSON)(token.text) : void 0;
9283
+ return (0, _orkestrel_contract.isString)(name) && token.value !== void 0 ? [{
9284
+ name,
9285
+ index: token.index,
9286
+ value: token.value,
9287
+ at
9288
+ }] : [];
9289
+ });
9290
+ const open = tokens[0];
9291
+ const root = tokens.find((token) => token.text === "}" && token.depth === 0);
9292
+ const head = keys[0];
9293
+ if (open?.text !== "{" || root === void 0 || head === void 0) return void 0;
9294
+ const lineBreak = manifest.lastIndexOf("\n", head.index);
9295
+ const margin = lineBreak < 0 ? "" : manifest.slice(lineBreak + 1, head.index);
9296
+ const step = /\S/u.test(margin) ? "" : margin;
9297
+ const edits = [
9298
+ {
9299
+ name: "bin",
9300
+ array: false,
9301
+ members: Object.entries(missing.bin),
9302
+ order: Object.keys(planned.bin)
9303
+ },
9304
+ {
9305
+ name: "files",
9306
+ array: true,
9307
+ members: missing.files.map((path) => [path, path]),
9308
+ order: planned.files
9309
+ },
9310
+ {
9311
+ name: "exports",
9312
+ array: false,
9313
+ members: Object.entries(missing.exports),
9314
+ order: Object.keys(planned.exports)
9315
+ }
9316
+ ].map((section) => {
9317
+ if (section.members.length === 0) return [];
9318
+ const key = keys.find(({ name }) => name === section.name);
9319
+ if (key === void 0) {
9320
+ const value = section.array ? section.members.map(([path]) => path) : Object.fromEntries(section.members);
9321
+ const block = `${JSON.stringify(section.name)}: ${JSON.stringify(value, void 0, step).replaceAll("\n", `\n${margin}`)}`;
9322
+ const gap = step === "" ? "" : `\n${margin}`;
9323
+ const successors = MANIFEST_KEY_ORDER.slice(MANIFEST_KEY_ORDER.indexOf(section.name) + 1);
9324
+ const anchor = keys.find(({ name }) => successors.includes(name));
9325
+ const tail = open.index + 1 + manifest.slice(open.index + 1, root.index).trimEnd().length;
9326
+ return [anchor === void 0 ? {
9327
+ start: tail,
9328
+ end: tail,
9329
+ text: `,${gap}${block}`
9330
+ } : {
9331
+ start: anchor.index,
9332
+ end: anchor.index,
9333
+ text: `${block},${gap}`
9334
+ }];
9335
+ }
9336
+ const current = parsed[section.name];
9337
+ const length = (0, _orkestrel_contract.isArray)(current) && current.every(_orkestrel_contract.isString) ? current.length : void 0;
9338
+ if (manifest.charAt(key.value) !== (section.array ? "[" : "{")) return void 0;
9339
+ if (section.array && length === void 0) return void 0;
9340
+ if (section.name === "exports" && !isSubpathMap(current)) return void 0;
9341
+ const following = tokens.slice(key.at + 1);
9342
+ const strings = following.slice(0, length ?? 0);
9343
+ const last = strings.at(-1);
9344
+ 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;
9345
+ if (close < 0) return void 0;
9346
+ const declared = (section.array ? strings : following).flatMap((token) => {
9347
+ const name = (0, _orkestrel_contract.parseJSON)(token.text);
9348
+ return (section.array || token.depth === 2 && token.value !== void 0) && token.index < close && (0, _orkestrel_contract.isString)(name) ? [{
9349
+ name,
9350
+ index: token.index
9351
+ }] : [];
9352
+ });
9353
+ const keyBreak = manifest.lastIndexOf("\n", key.index);
9354
+ const level = keyBreak < 0 ? "" : /^\s*/u.exec(manifest.slice(keyBreak + 1, key.index))?.[0] ?? "";
9355
+ const first = declared[0];
9356
+ const firstBreak = first === void 0 ? -1 : manifest.lastIndexOf("\n", first.index);
9357
+ const lead = first === void 0 || firstBreak < 0 ? "" : manifest.slice(firstBreak + 1, first.index);
9358
+ const indent = first === void 0 ? step === "" ? "" : `${level}${step}` : /\S/u.test(lead) ? "" : lead;
9359
+ const nested = indent.startsWith(level) ? indent.slice(level.length) : step;
9360
+ 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}`)}`);
9361
+ const separator = indent === "" ? "" : `\n${indent}`;
9362
+ if (first === void 0) {
9363
+ const start = key.value + 1;
9364
+ const suffix = indent === "" ? "" : `\n${level}`;
9365
+ return [{
9366
+ start,
9367
+ end: close,
9368
+ text: `${lines.map((line) => `${separator}${line}`).join(",")}${suffix}`
9369
+ }];
9370
+ }
9371
+ const tail = key.value + 1 + manifest.slice(key.value + 1, close).trimEnd().length;
9372
+ return section.members.map(([name], position) => {
9373
+ const line = lines[position] ?? "";
9374
+ const rank = section.order.indexOf(name);
9375
+ const anchor = declared.find((entry) => section.order.indexOf(entry.name) > rank);
9376
+ return anchor === void 0 ? {
9377
+ start: tail,
9378
+ end: tail,
9379
+ text: `,${separator}${line}`
9380
+ } : {
9381
+ start: anchor.index,
9382
+ end: anchor.index,
9383
+ text: `${line},${separator}`
9384
+ };
9385
+ });
9386
+ });
9387
+ if (edits.some((edit) => edit === void 0)) return void 0;
9388
+ return [...Map.groupBy(edits.flatMap((edit) => edit ?? []), ({ start }) => start)].map(([start, group]) => ({
9389
+ start,
9390
+ end: Math.max(...group.map(({ end }) => end)),
9391
+ text: group.map(({ text }) => text).join("")
9392
+ })).sort((left, right) => right.start - left.start).reduce((text, edit) => text.slice(0, edit.start) + edit.text + text.slice(edit.end), manifest);
9393
+ }
9394
+ /**
9040
9395
  * Replaces named script values in package manifest text.
9041
9396
  *
9042
9397
  * @param manifest - The manifest text to compile.
@@ -9478,6 +9833,36 @@ function blueprintToQuestions(blueprint) {
9478
9833
  message: "integration drives features across environments, and this workspace declares fewer than two, so its seed composes nothing.",
9479
9834
  blocking: false
9480
9835
  }] : [],
9836
+ ...Iterator.from(blueprint.bin).map((name) => ({
9837
+ name,
9838
+ valid: isBinModule(name)
9839
+ })).toArray().flatMap(({ name, valid }, index, declared) => {
9840
+ if (!valid) return [{
9841
+ field: "bin",
9842
+ 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.`,
9843
+ blocking: true
9844
+ }];
9845
+ if (declared.findIndex((other) => other.name === name) < index) return [{
9846
+ field: "bin",
9847
+ message: `${name} is declared more than once on bin.`,
9848
+ blocking: true
9849
+ }];
9850
+ if (name === "main") return [];
9851
+ const subpaths = blueprintToExports({
9852
+ ...blueprint,
9853
+ bin: []
9854
+ });
9855
+ if (Object.hasOwn(subpaths, `./${name}`)) return [{
9856
+ field: "bin",
9857
+ message: `src/bin/${name}.ts publishes ./${name}, which src/${name} already publishes. Rename the module.`,
9858
+ blocking: true
9859
+ }];
9860
+ return Object.keys(subpaths).length === 0 ? [{
9861
+ field: "bin",
9862
+ 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.`,
9863
+ blocking: false
9864
+ }] : [];
9865
+ }),
9481
9866
  ...Iterator.from(blueprint.vendors).map((vendor) => ({
9482
9867
  vendor,
9483
9868
  valid: NAME_PATTERN.test(vendor)
@@ -9670,7 +10055,7 @@ function overridesToQuestions(overrides, artifacts) {
9670
10055
  * const blueprint = createBlueprint('router', {
9671
10056
  * src: ['core', 'server'],
9672
10057
  * dependencies: [{ name: '@orkestrel/emitter', range: '^0.0.5' }],
9673
- * bin: true,
10058
+ * bin: ['main'],
9674
10059
  * })
9675
10060
  *
9676
10061
  * blueprint.version // '0.0.1'
@@ -9693,7 +10078,7 @@ function createBlueprint(name, input) {
9693
10078
  version: input?.version ?? "0.0.1",
9694
10079
  engines: input?.engines ?? ">=22.18.0",
9695
10080
  overrides: input?.overrides ?? [],
9696
- bin: input?.bin ?? false,
10081
+ bin: input?.bin ?? [],
9697
10082
  setup: input?.setup ?? [],
9698
10083
  guides: input?.guides ?? false,
9699
10084
  integration: input?.integration ?? false,
@@ -10012,7 +10397,6 @@ var Compiler = class {
10012
10397
  }
10013
10398
  };
10014
10399
  exports.APP_BROWSER_DEV_DEPENDENCIES = APP_BROWSER_DEV_DEPENDENCIES;
10015
- exports.APP_DEV_DEPENDENCIES = APP_DEV_DEPENDENCIES;
10016
10400
  exports.APP_MATRIX = APP_MATRIX;
10017
10401
  exports.APP_SERVER_DEV_DEPENDENCIES = APP_SERVER_DEV_DEPENDENCIES;
10018
10402
  exports.ARTIFACT_GROUPS = ARTIFACT_GROUPS;
@@ -10022,6 +10406,7 @@ exports.BARREL_CONFIGS = BARREL_CONFIGS;
10022
10406
  exports.BASE_DEV_DEPENDENCIES = BASE_DEV_DEPENDENCIES;
10023
10407
  exports.BIN_CONFIGS = BIN_CONFIGS;
10024
10408
  exports.BIN_ENTRY_PATH = BIN_ENTRY_PATH;
10409
+ exports.BIN_MODULE_PATTERN = BIN_MODULE_PATTERN;
10025
10410
  exports.BIN_OUTPUT_PATH = BIN_OUTPUT_PATH;
10026
10411
  exports.BROWSER_ENTRIES = BROWSER_ENTRIES;
10027
10412
  exports.BROWSE_DEV_DEPENDENCIES = BROWSE_DEV_DEPENDENCIES;
@@ -10032,6 +10417,7 @@ exports.CAPTURE_UPSTREAM = CAPTURE_UPSTREAM;
10032
10417
  exports.CATALOG_AGENT_PATH = CATALOG_AGENT_PATH;
10033
10418
  exports.CATALOG_END_MARKER = CATALOG_END_MARKER;
10034
10419
  exports.CATALOG_START_MARKER = CATALOG_START_MARKER;
10420
+ exports.CENTRAL_FILE_NAMES = CENTRAL_FILE_NAMES;
10035
10421
  exports.CONFIG_TEMPLATES = CONFIG_TEMPLATES;
10036
10422
  exports.CONFORMANCE_TEST_PATH = CONFORMANCE_TEST_PATH;
10037
10423
  exports.CONTROL_CHARACTER_PATTERN = CONTROL_CHARACTER_PATTERN;
@@ -10058,6 +10444,7 @@ exports.HOST_PATHS = HOST_PATHS;
10058
10444
  exports.INTEGRATION_TEST_PATH = INTEGRATION_TEST_PATH;
10059
10445
  exports.INVALID_PATH_CHARACTER_PATTERN = INVALID_PATH_CHARACTER_PATTERN;
10060
10446
  exports.JOURNEY_CONFIG_PATH = JOURNEY_CONFIG_PATH;
10447
+ exports.MANIFEST_KEY_ORDER = MANIFEST_KEY_ORDER;
10061
10448
  exports.MANIFEST_PATH = MANIFEST_PATH;
10062
10449
  exports.MAX_ARTIFACT_BYTES = MAX_ARTIFACT_BYTES;
10063
10450
  exports.MAX_ARTIFACT_HEX_LENGTH = MAX_ARTIFACT_HEX_LENGTH;
@@ -10117,6 +10504,7 @@ exports.artifactsToQuestions = artifactsToQuestions;
10117
10504
  exports.blueprintToConfigArtifacts = blueprintToConfigArtifacts;
10118
10505
  exports.blueprintToDevDependencies = blueprintToDevDependencies;
10119
10506
  exports.blueprintToDocumentArtifacts = blueprintToDocumentArtifacts;
10507
+ exports.blueprintToEntries = blueprintToEntries;
10120
10508
  exports.blueprintToExports = blueprintToExports;
10121
10509
  exports.blueprintToFaces = blueprintToFaces;
10122
10510
  exports.blueprintToGuideArtifacts = blueprintToGuideArtifacts;
@@ -10155,12 +10543,14 @@ exports.inferArtifactDrift = inferArtifactDrift;
10155
10543
  exports.inferArtifactGroup = inferArtifactGroup;
10156
10544
  exports.inferSurfaceSimilarity = inferSurfaceSimilarity;
10157
10545
  exports.insertManifestDependencies = insertManifestDependencies;
10546
+ exports.insertManifestEntries = insertManifestEntries;
10158
10547
  exports.insertManifestSection = insertManifestSection;
10159
10548
  exports.isArtifact = isArtifact;
10160
10549
  exports.isArtifactFinding = isArtifactFinding;
10161
10550
  exports.isArtifactGroup = isArtifactGroup;
10162
10551
  exports.isArtifactGroups = isArtifactGroups;
10163
10552
  exports.isAudit = isAudit;
10553
+ exports.isBinModule = isBinModule;
10164
10554
  exports.isBlueprint = isBlueprint;
10165
10555
  exports.isBrowserExtension = isBrowserExtension;
10166
10556
  exports.isCanonPath = isCanonPath;
@@ -10187,19 +10577,23 @@ exports.isScaffoldError = isScaffoldError;
10187
10577
  exports.isSheetName = isSheetName;
10188
10578
  exports.isSnapshot = isSnapshot;
10189
10579
  exports.isStylesExtension = isStylesExtension;
10580
+ exports.isSubpathMap = isSubpathMap;
10190
10581
  exports.isSurface = isSurface;
10191
10582
  exports.iterateAnswers = iterateAnswers;
10192
10583
  exports.manifestToDependencies = manifestToDependencies;
10584
+ exports.manifestToEntries = manifestToEntries;
10193
10585
  exports.manifestToName = manifestToName;
10194
10586
  exports.matchesArtifactDriftReachability = matchesArtifactDriftReachability;
10195
10587
  exports.matchesBarrel = matchesBarrel;
10196
10588
  exports.matchesEngines = matchesEngines;
10197
10589
  exports.matchesGuideRefusal = matchesGuideRefusal;
10198
10590
  exports.matchesOrchestrationPath = matchesOrchestrationPath;
10591
+ exports.matchesPackedPath = matchesPackedPath;
10199
10592
  exports.matchesPrintWidth = matchesPrintWidth;
10200
10593
  exports.matchesRange = matchesRange;
10201
10594
  exports.matchesSurfaceStructure = matchesSurfaceStructure;
10202
10595
  exports.nameToGuide = nameToGuide;
10596
+ exports.normalizePackagePath = normalizePackagePath;
10203
10597
  exports.overridesToQuestions = overridesToQuestions;
10204
10598
  exports.parseArtifactGroups = parseArtifactGroups;
10205
10599
  exports.parseBlueprint = parseBlueprint;