@orkestrel/scaffold 0.0.62 → 0.0.64

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 (52) hide show
  1. package/README.md +18 -103
  2. package/dist/bin/main.js +95 -27
  3. package/dist/bin/main.js.map +1 -1
  4. package/dist/host/AGENTS.md +2 -2
  5. package/dist/host/CLAUDE.md +6 -0
  6. package/dist/host/agents/orchestration.md +23 -15
  7. package/dist/host/agents/skills/enterprise-bootstrap/references/bootstrap-reference.md +16 -16
  8. package/dist/host/agents/skills/enterprise-bootstrap/references/frontend-design.md +6 -6
  9. package/dist/host/agents/skills/enterprise-bootstrap/references/utilities.md +4 -4
  10. package/dist/host/agents/skills/orkestrel-debrief/references/field-testing.md +5 -5
  11. package/dist/host/agents/skills/orkestrel-falsify/references/reconcile.md +1 -1
  12. package/dist/host/agents/skills/orkestrel-publish/SKILL.md +15 -15
  13. package/dist/host/agents/skills/orkestrel-publish/references/wave.md +43 -17
  14. package/dist/host/agents/skills/orkestrel-publish/references/window.md +41 -16
  15. package/dist/host/claude/agents/orkestrel.md +56 -56
  16. package/dist/host/claude/agents/reviewer.md +13 -0
  17. package/dist/host/claude/rules/architecture.md +51 -45
  18. package/dist/host/claude/rules/documentation.md +18 -1
  19. package/dist/host/claude/rules/portability.md +2 -0
  20. package/dist/host/claude/rules/quality.md +1 -1
  21. package/dist/host/claude/rules/tests.md +12 -11
  22. package/dist/host/claude/rules/typescript.md +5 -0
  23. package/dist/host/claude/rules/workspace.md +23 -18
  24. package/dist/host/claude/rules/writing.md +4 -0
  25. package/dist/host/codex/agents/orkestrel.toml +3 -3
  26. package/dist/host/codex/agents/reviewer.toml +4 -2
  27. package/dist/host/configs/helpers.ts +311 -2
  28. package/dist/host/configs/policy.ts +1100 -51
  29. package/dist/host/dotfiles/oxlintrc.json +72 -1
  30. package/dist/host/guides/guide.md +749 -222
  31. package/dist/host/guides/scaffold.md +472 -378
  32. package/dist/host/manifest.json +34 -33
  33. package/dist/host/scripts/codex.sh +0 -0
  34. package/dist/host/scripts/cursor.sh +0 -0
  35. package/dist/host/scripts/deps.sh +0 -0
  36. package/dist/host/scripts/ollama.sh +0 -0
  37. package/dist/host/tests/config.test.ts +1200 -16
  38. package/dist/host/tests/policy.test.ts +157 -173
  39. package/dist/host/tests/setupPolicy.ts +522 -1007
  40. package/dist/src/core/index.cjs +373 -279
  41. package/dist/src/core/index.cjs.map +1 -1
  42. package/dist/src/core/index.d.cts +130 -120
  43. package/dist/src/core/index.d.ts +130 -120
  44. package/dist/src/core/index.js +373 -278
  45. package/dist/src/core/index.js.map +1 -1
  46. package/dist/src/server/index.cjs +28 -21
  47. package/dist/src/server/index.cjs.map +1 -1
  48. package/dist/src/server/index.d.cts +38 -33
  49. package/dist/src/server/index.d.ts +38 -33
  50. package/dist/src/server/index.js +28 -21
  51. package/dist/src/server/index.js.map +1 -1
  52. package/package.json +17 -18
@@ -4,8 +4,8 @@ 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.62",
8
- description: "Scaffold workspaces with five commands: new, audit, repair, catalog, and overwrite.",
7
+ version: "0.0.64",
8
+ description: "Scaffold workspaces with commands: new, audit, repair, catalog, and overwrite.",
9
9
  keywords: [
10
10
  "audit",
11
11
  "catalog",
@@ -74,7 +74,7 @@ var package_default = {
74
74
  "test:src:bin": "vitest run --config vite.config.ts --no-cache --reporter=dot --project src:bin",
75
75
  "test:policy": "vitest run --config vite.config.ts --no-cache --reporter=dot --project policy",
76
76
  "test:config": "vitest run --config vite.config.ts --no-cache --reporter=dot --project config",
77
- "test:guides": "vitest run --config vite.config.ts --no-cache --reporter=dot --project guides",
77
+ "test:guides": "node --experimental-strip-types tests/guides.test.ts",
78
78
  "test:distribution": "vitest run --config vite.config.ts --no-cache --reporter=dot --project distribution",
79
79
  "test:probe": "vitest run --config vite.config.ts --no-cache --reporter=verbose --project probe",
80
80
  "test:bench": "vitest bench --config vite.config.ts --no-cache --project probe",
@@ -90,27 +90,26 @@ var package_default = {
90
90
  "prepublishOnly": "npm run format:check && npm run lint:check && npm run check && npm run build && npm test && npm run test:distribution -- --mode release"
91
91
  },
92
92
  dependencies: {
93
- "@orkestrel/console": "^0.0.12",
94
- "@orkestrel/contract": "^0.0.16",
95
- "@orkestrel/emitter": "^0.0.9",
96
- "@orkestrel/markdown": "^0.0.13",
97
- "@orkestrel/process": "^0.0.10",
98
- "@orkestrel/template": "^0.0.6"
93
+ "@orkestrel/console": "^0.0.13",
94
+ "@orkestrel/contract": "^0.0.17",
95
+ "@orkestrel/emitter": "^0.0.10",
96
+ "@orkestrel/markdown": "^0.0.14",
97
+ "@orkestrel/process": "^0.0.11",
98
+ "@orkestrel/template": "^0.0.7"
99
99
  },
100
100
  devDependencies: {
101
101
  "@microsoft/api-extractor": "^7.59.0",
102
- "@orkestrel/guide": "^0.0.16",
103
- "@orkestrel/html": "^0.0.8",
104
- "@orkestrel/probe": "^0.0.11",
105
- "@orkestrel/test": "^0.0.13",
106
- "@types/node": "^26.4.0",
102
+ "@orkestrel/guide": "^0.0.17",
103
+ "@orkestrel/html": "^0.0.9",
104
+ "@orkestrel/probe": "^0.0.12",
105
+ "@orkestrel/test": "^0.0.14",
106
+ "@types/node": "^26.5.0",
107
107
  "@vitest/browser-playwright": "^4.1.11",
108
- "oxfmt": "^0.65.0",
109
- "oxlint": "^1.80.0",
110
- "playwright": "^1.62.1",
108
+ "oxfmt": "^0.67.0",
109
+ "oxlint": "^1.82.0",
110
+ "playwright": "^1.63.0",
111
111
  "typescript": "^6.0.3",
112
112
  "vite": "^8.2.2",
113
- "vite-plugin-dts": "^5.0.3",
114
113
  "vitest": "^4.1.11"
115
114
  },
116
115
  engines: { "node": ">=22.12.0" }
@@ -213,10 +212,11 @@ var BIN_ENTRY_PATH = "src/bin/main.ts";
213
212
  * @remarks
214
213
  * These are the files the fleet shares verbatim, and each target holds a copy
215
214
  * of the paths it selects: the licence, the harness permission file, the
216
- * session-start hooks, the shared policy register, the shared policy proof,
217
- * the shared policy plugin, the shared configuration leaf and its proof, the
218
- * byte-identical root dotfiles, and the guide mirrors a generated workspace
219
- * starts from. A directory entry vendors everything beneath it.
215
+ * session-start hooks, the shared policy
216
+ * register, the shared policy proof, the shared policy plugin, the shared
217
+ * configuration leaf and its proof, the byte-identical root dotfiles, and the
218
+ * guide mirrors a generated workspace starts from. A directory entry vendors
219
+ * everything beneath it.
220
220
  *
221
221
  * A plan carries the subset its target selects, which is why the list is a
222
222
  * candidate set rather than a plan: a workspace never mirrors its own guide.
@@ -225,16 +225,13 @@ var BIN_ENTRY_PATH = "src/bin/main.ts";
225
225
  * its rules, its skills, its agent roles, its bench configuration, and its MCP
226
226
  * registrations from {@link CANON_PATHS} inside the installed package, so no
227
227
  * file scaffold leaves in a target names a path the target does not hold.
228
- * `nameToHostArtifacts` appends {@link CATALOG_AGENT_PATH} to what this list
228
+ * `blueprintToHostArtifacts` appends {@link CATALOG_AGENT_PATH} to what this list
229
229
  * selects, which is what keeps the list itself disjoint from the canon.
230
230
  */
231
231
  var HOST_PATHS = Object.freeze([
232
232
  "LICENSE",
233
233
  ".claude/settings.json",
234
- "scripts/deps.sh",
235
- "scripts/cursor.sh",
236
- "scripts/codex.sh",
237
- "scripts/ollama.sh",
234
+ "scripts",
238
235
  "tests/setupPolicy.ts",
239
236
  "tests/policy.test.ts",
240
237
  "tests/config.test.ts",
@@ -273,7 +270,7 @@ var HOST_PATHS = Object.freeze([
273
270
  *
274
271
  * The plan claims paths inside the canon deliberately, and each has a reason.
275
272
  * `blueprintToDocumentArtifacts` claims `AGENTS.md` and `CLAUDE.md` as this
276
- * package's own template pointers. `nameToHostArtifacts` claims
273
+ * package's own template pointers. `blueprintToHostArtifacts` claims
277
274
  * {@link CATALOG_AGENT_PATH}, because the catalog verb refuses a target that
278
275
  * lacks the file and repair restores its absence.
279
276
  *
@@ -347,19 +344,19 @@ var ORCHESTRATION_PATH_PREFIXES = Object.freeze([
347
344
  "scripts/"
348
345
  ]);
349
346
  /**
350
- * Lists the exact root filenames that wire an agent bench rather than the toolchain, frozen.
347
+ * Lists the exact root paths that wire an agent bench or own an orchestration directory, frozen.
351
348
  *
352
349
  * @remarks
353
- * `.mcp.json` registers MCP servers for the harness. It sits among the root
354
- * dotfiles but governs agents, so it groups with the harness bridges.
350
+ * `.mcp.json` registers MCP servers for the harness. `scripts` is the owned
351
+ * directory whose members wire the development environment.
355
352
  */
356
- var ORCHESTRATION_PATH_NAMES = Object.freeze([".mcp.json"]);
353
+ var ORCHESTRATION_PATH_NAMES = Object.freeze([".mcp.json", "scripts"]);
357
354
  /**
358
355
  * Names the agent file whose marker-bounded package table the catalog verb alone owns.
359
356
  *
360
357
  * @remarks
361
358
  * A plan claims it at a canon path, because the catalog verb refuses a target
362
- * that lacks the file. `nameToHostArtifacts` appends it to the vendored
359
+ * that lacks the file. `blueprintToHostArtifacts` appends it to the vendored
363
360
  * selection, and it reaches a release through the `.claude/agents` directory in
364
361
  * {@link CANON_PATHS} rather than through {@link HOST_PATHS}, which is what
365
362
  * keeps the two lists disjoint.
@@ -391,7 +388,7 @@ var CATALOG_CLOSING_MARKER = "<!-- /orkestrel:catalog -->";
391
388
  var SERVICE_SCRIPT_PATH = "scripts/service.sh";
392
389
  /** Names the shared Vitest global-setup module whose presence makes a workspace `global`. */
393
390
  var GLOBAL_SETUP_PATH = "tests/setupGlobal.ts";
394
- /** Names the guide-parity proof whose presence selects the planned `guides` project. */
391
+ /** Names the package-owned guide-parity entry used by `test:guides` and to select the `guides` project. */
395
392
  var GUIDES_TEST_PATH = "tests/guides.test.ts";
396
393
  /** Names the generated packed-package proof every publishing workspace is planned at. */
397
394
  var DISTRIBUTION_TEST_PATH = "tests/distribution.test.ts";
@@ -549,13 +546,13 @@ var BASE_DEV_DEPENDENCIES = Object.freeze({
549
546
  vitest: package_default.devDependencies.vitest
550
547
  });
551
548
  /**
552
- * Lists the development dependencies that emit declarations for published source or an
553
- * executable.
549
+ * Lists the development dependencies that roll declarations up for published source.
550
+ *
551
+ * @remarks
552
+ * The toolchain runs the compiler it already installs as a command, emitting one declaration per
553
+ * module, and the extractor rolls that emit into the single file each published face ships.
554
554
  */
555
- var DECLARATION_DEV_DEPENDENCIES = Object.freeze({
556
- "@microsoft/api-extractor": package_default.devDependencies["@microsoft/api-extractor"],
557
- "vite-plugin-dts": package_default.devDependencies["vite-plugin-dts"]
558
- });
555
+ var DECLARATION_DEV_DEPENDENCIES = Object.freeze({ "@microsoft/api-extractor": package_default.devDependencies["@microsoft/api-extractor"] });
559
556
  /** Lists the development dependencies a published browser `src` environment adds. */
560
557
  var SOURCE_BROWSER_DEV_DEPENDENCIES = Object.freeze({
561
558
  "@vitest/browser-playwright": package_default.devDependencies["@vitest/browser-playwright"],
@@ -896,9 +893,10 @@ export function appBrowser(): UserConfig {
896
893
  setupFiles: ['./tests/setup.ts'],
897
894
  environment: 'node',
898
895
  browser: { enabled: false },
899
- // A config test validates every target wrapper and runs the real linter twice with
900
- // 15-second child caps, so this budget clears both caps and reports their diagnostics.
901
- testTimeout: 45_000,
896
+ // A config test validates every target wrapper, spawns the real linter twice under
897
+ // 15-second child caps, and rolls one face up through the compiler and the extractor it
898
+ // spawns, so this budget clears the capped pair with room for a contended host.
899
+ testTimeout: 60_000,
902
900
  },
903
901
  })
904
902
  `,
@@ -1124,8 +1122,7 @@ export const probe = (): UserConfig => ({
1124
1122
  vites: Object.freeze({
1125
1123
  src: Object.freeze({
1126
1124
  core: `import { defineConfig, mergeConfig } from 'vite'
1127
- import dts from 'vite-plugin-dts'
1128
- import { environmentBoundary, outputBoundary } from '../helpers.js'
1125
+ import { declarationRollup, environmentBoundary, outputBoundary } from '../helpers.js'
1129
1126
  import { peers, srcCore, resolveWorkspacePath } from '../../vite.config.ts'
1130
1127
 
1131
1128
  export default defineConfig(
@@ -1134,17 +1131,9 @@ export default defineConfig(
1134
1131
  plugins: [
1135
1132
  outputBoundary('dist/src/core'),
1136
1133
  environmentBoundary('src/core'),
1137
- dts({
1138
- tsconfigPath: resolveWorkspacePath('configs/src/tsconfig.core.json'),
1139
- bundleTypes: {
1140
- extractorConfig: {
1141
- compiler: {
1142
- overrideTsconfig: {
1143
- compilerOptions: { types: ['node'] },
1144
- },
1145
- },
1146
- },
1147
- },
1134
+ declarationRollup({
1135
+ project: resolveWorkspacePath('configs/src/tsconfig.core.json'),
1136
+ types: ['node'],
1148
1137
  }),
1149
1138
  ],
1150
1139
  build: {
@@ -1165,49 +1154,34 @@ export default defineConfig(
1165
1154
  )
1166
1155
  `,
1167
1156
  browser: `import { defineConfig, mergeConfig } from 'vite'
1168
- import dts from 'vite-plugin-dts'
1157
+ import { declarationRollup, rewriteCoreSpecifier } from '../helpers.js'
1169
1158
  import { srcBrowser, resolveWorkspacePath } from '../../vite.config.ts'
1170
1159
 
1171
- // vite-plugin-dts rolls this face into one declaration, and the roll-up reaches
1172
- // src/core through a relative source path the tarball does not carry. The path
1173
- // keeps each source module's own depth, so a module in a browser subfolder emits
1174
- // one that leaves dist/src entirely. The following rewrite externalizes core
1175
- // through the package's own published root export, on the final roll-up only.
1160
+ // The roll-up reaches src/core through a specifier the tarball does not carry, so the rewrite
1161
+ // externalizes core through the package's own published root export, on the final roll-up alone.
1176
1162
  export default defineConfig(
1177
1163
  mergeConfig(srcBrowser(), {
1178
1164
  plugins: [
1179
- dts({
1180
- tsconfigPath: resolveWorkspacePath('configs/src/tsconfig.browser.json'),
1181
- bundleTypes: true,
1182
- beforeWriteFile: (path, content) => ({
1183
- content: /[\\\\/]dist[\\\\/]src[\\\\/]browser[\\\\/]index\\.d\\.ts$/.test(path)
1184
- {{replacement}}
1185
- : content,
1186
- }),
1165
+ declarationRollup({
1166
+ project: resolveWorkspacePath('configs/src/tsconfig.browser.json'),
1167
+ rewrite: rewriteCoreSpecifier,
1187
1168
  }),
1188
1169
  ],
1189
1170
  }),
1190
1171
  )
1191
1172
  `,
1192
1173
  server: `import { defineConfig, mergeConfig } from 'vite'
1193
- import dts from 'vite-plugin-dts'
1174
+ import { declarationRollup, rewriteCoreSpecifier } from '../helpers.js'
1194
1175
  import { srcServer, resolveWorkspacePath } from '../../vite.config.ts'
1195
1176
 
1196
- // vite-plugin-dts rolls this face into one declaration, and the roll-up reaches
1197
- // src/core through a relative source path the tarball does not carry. The
1198
- // following rewrite externalizes core through the package's own published root
1199
- // export, on the final roll-up only.
1177
+ // The roll-up reaches src/core through a specifier the tarball does not carry, so the rewrite
1178
+ // externalizes core through the package's own published root export, on the final roll-up alone.
1200
1179
  export default defineConfig(
1201
1180
  mergeConfig(srcServer(), {
1202
1181
  plugins: [
1203
- dts({
1204
- tsconfigPath: resolveWorkspacePath('configs/src/tsconfig.server.json'),
1205
- bundleTypes: true,
1206
- beforeWriteFile: (path, content) => ({
1207
- content: /[\\\\/]dist[\\\\/]src[\\\\/]server[\\\\/]index\\.d\\.ts$/.test(path)
1208
- {{replacement}}
1209
- : content,
1210
- }),
1182
+ declarationRollup({
1183
+ project: resolveWorkspacePath('configs/src/tsconfig.server.json'),
1184
+ rewrite: rewriteCoreSpecifier,
1211
1185
  }),
1212
1186
  ],
1213
1187
  }),
@@ -1644,14 +1618,20 @@ import {
1644
1618
  statSync,
1645
1619
  writeFileSync,
1646
1620
  } from 'node:fs'
1647
- {{transport}}import { tmpdir } from 'node:os'
1621
+ {{transport}}import { createRequire } from 'node:module'
1622
+ import { tmpdir } from 'node:os'
1648
1623
  import { dirname, join, resolve } from 'node:path'
1649
1624
  import { fileURLToPath } from 'node:url'
1650
- {{launcher}}import ts from 'typescript'
1651
- import { afterAll, describe, expect, it } from 'vitest'
1625
+ {{launcher}}import { afterAll, describe, expect, it } from 'vitest'
1652
1626
 
1653
1627
  const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
1654
1628
  const NPM = process.platform === 'win32' ? 'npm.cmd' : 'npm'
1629
+ // The compiler this workspace installs, run as a command rather than called in
1630
+ // process: the command and its plain-text diagnostics are the same across the
1631
+ // compiler majors this toolchain supports, and its in-process API is not. It is
1632
+ // resolved from the workspace under proof, so a consumer of the packed artifact is
1633
+ // checked by the same compiler that workspace's own \`check\` script runs.
1634
+ const TSC = createRequire(join(ROOT, 'package.json')).resolve('typescript/bin/tsc')
1655
1635
  // Windows needs a shell to launch a \`.cmd\`: Node refuses one directly since the
1656
1636
  // batch-argument hardening, and \`spawnSync\` returns \`EINVAL\` with a null status
1657
1637
  // rather than an exit code a caller can read. Every following argument is a literal or
@@ -1668,6 +1648,12 @@ const RELEASE = import.meta.env.MODE === 'release'
1668
1648
  // Node and the miss is silent.
1669
1649
  const BROWSER_OUTPUT = './dist/src/browser/'
1670
1650
  const ABSENT_SUBPATH = '/no-subpath-is-published-under-this-name'
1651
+ // A compiler diagnostic that says where it is: the path relative to the directory
1652
+ // the compiler ran in, the 1-based line and column, the code, and the message. The
1653
+ // diagnostics are the verdict rather than the exit code, which differs between the
1654
+ // compiler majors this toolchain supports, so a reported line matching nothing here
1655
+ // came from something other than a check of a consumer module.
1656
+ const DIAGNOSTIC_PATTERN = /^(.+?)\\(\\d+,\\d+\\): error TS\\d+: /u
1671
1657
  const PING = ['ping', '--fetch-retries=0', '--fetch-timeout=5000', '--loglevel=silent']
1672
1658
  const ESM_DRIVER = 'drive.mjs'
1673
1659
  const CJS_DRIVER = 'drive.cjs'
@@ -1713,8 +1699,8 @@ const DECLARATION_CONDITIONS = Object.freeze({
1713
1699
 
1714
1700
  interface Resolution {
1715
1701
  readonly label: string
1716
- readonly resolution: ts.ModuleResolutionKind
1717
- readonly module: ts.ModuleKind
1702
+ readonly resolution: string
1703
+ readonly module: string
1718
1704
  readonly conditions: Readonly<Record<Format, readonly string[]>>
1719
1705
  }
1720
1706
 
@@ -1722,51 +1708,61 @@ interface TargetResolution {
1722
1708
  readonly target: string
1723
1709
  }
1724
1710
 
1725
- // Each compile driver carries the conditions TypeScript applies for its resolution
1726
- // and importing format. A \`require\`-only subpath therefore stays in each CommonJS
1727
- // probe that can resolve it.
1711
+ // Each compile driver carries the compiler options its scratch project sets and
1712
+ // the conditions TypeScript applies for that resolution and importing format. A
1713
+ // \`require\`-only subpath therefore stays in each CommonJS probe that can resolve it.
1714
+ // The option values are the spellings the project file takes, so nothing here needs
1715
+ // the compiler's own API to name them.
1728
1716
  const RESOLUTIONS: readonly Resolution[] = [
1729
1717
  {
1730
1718
  label: 'node16',
1731
- resolution: ts.ModuleResolutionKind.Node16,
1732
- module: ts.ModuleKind.Node16,
1719
+ resolution: 'node16',
1720
+ module: 'node16',
1733
1721
  conditions: DECLARATION_CONDITIONS,
1734
1722
  },
1735
1723
  {
1736
1724
  label: 'nodenext',
1737
- resolution: ts.ModuleResolutionKind.NodeNext,
1738
- module: ts.ModuleKind.NodeNext,
1725
+ resolution: 'nodenext',
1726
+ module: 'nodenext',
1739
1727
  conditions: DECLARATION_CONDITIONS,
1740
1728
  },
1741
1729
  {
1742
1730
  label: 'bundler',
1743
- resolution: ts.ModuleResolutionKind.Bundler,
1744
- module: ts.ModuleKind.ESNext,
1731
+ resolution: 'bundler',
1732
+ module: 'esnext',
1745
1733
  conditions: BUNDLER_CONDITIONS,
1746
1734
  },
1747
1735
  ]
1748
1736
 
1737
+ // The driver a bundled consumer reads declarations under. A browser application
1738
+ // compiles through a bundler, so the browser drive answers under this one alone,
1739
+ // and naming it here is what keeps that selection tied to the driver it selects.
1740
+ const BROWSER_DRIVER = RESOLUTIONS.find((candidate) => candidate.label === 'bundler')
1741
+ if (BROWSER_DRIVER === undefined) throw new Error("RESOLUTIONS carries no 'bundler' row")
1742
+
1749
1743
  const FORMATS: ReadonlyArray<readonly [extension: string, format: Format]> = [
1750
1744
  ['ts', 'module'],
1751
1745
  ['cts', 'commonjs'],
1752
1746
  ]
1753
1747
 
1754
1748
  // One published subpath, resolved to what this proof can drive: the specifier a
1755
- // consumer writes, the declarations its consumer formats name, whether its target
1756
- // is a browser bundle, and whether it answers \`import\` and \`require\` at all.
1749
+ // consumer writes, whether the declarations its consumer formats resolve at all,
1750
+ // whether the exports map answers the browser condition with a target of its own,
1751
+ // whether it answers \`import\` and \`require\` at all, and whether the target that
1752
+ // \`require\` answers with is one that a CommonJS consumer loads.
1757
1753
  interface Entry {
1758
1754
  readonly subpath: string
1759
1755
  readonly specifier: string
1760
1756
  readonly mapping: unknown
1761
1757
  readonly declaration: {
1762
- readonly module: string | undefined
1763
- readonly commonjs: string | undefined
1764
- readonly browser: string | undefined
1758
+ readonly importable: boolean
1759
+ readonly requirable: boolean
1760
+ readonly browsable: boolean
1765
1761
  }
1766
- readonly browser: boolean
1767
- readonly module: boolean
1768
- readonly commonjs: boolean
1769
- readonly required: boolean
1762
+ readonly browsable: boolean
1763
+ readonly importable: boolean
1764
+ readonly requirable: boolean
1765
+ readonly loadable: boolean
1770
1766
  }
1771
1767
 
1772
1768
  // The installed tree every claim is read from. Every subpath the exports map names
@@ -2019,7 +2015,14 @@ function isDeclaration(target: string): boolean {
2019
2015
  // against. Each field uses the conditions of the TypeScript consumer paired with
2020
2016
  // that runtime. A JavaScript target resolves through TypeScript's adjacent
2021
2017
  // declaration substitution rather than standing in for the declaration itself.
2022
- function readDeclaration(entry: unknown, installed: string): Entry['declaration'] {
2018
+ function readDeclaration(
2019
+ entry: unknown,
2020
+ installed: string,
2021
+ ): {
2022
+ readonly module: string | undefined
2023
+ readonly commonjs: string | undefined
2024
+ readonly browser: string | undefined
2025
+ } {
2023
2026
  return {
2024
2027
  module: resolveDeclaration(entry, DECLARATION_CONDITIONS.module, installed),
2025
2028
  commonjs: resolveDeclaration(entry, DECLARATION_CONDITIONS.commonjs, installed),
@@ -2032,72 +2035,137 @@ function selectEntries(entries: readonly Entry[], conditions: readonly string[])
2032
2035
  return entries.filter(
2033
2036
  (entry) =>
2034
2037
  resolveTarget(entry.mapping, conditions) !== undefined &&
2035
- (!conditions.includes('require') || entry.commonjs),
2038
+ (!conditions.includes('require') || entry.loadable),
2039
+ )
2040
+ }
2041
+
2042
+ // The compile drivers whose conditions reach one entry under one importing format.
2043
+ // A driver that resolves no target for that entry compiles nothing, so a consumer
2044
+ // written under it would report a resolution failure this package never made.
2045
+ function selectDrivers(entry: Entry, format: Format): readonly Resolution[] {
2046
+ return RESOLUTIONS.filter(
2047
+ (driver) => selectEntries([entry], driver.conditions[format]).length > 0,
2036
2048
  )
2037
2049
  }
2038
2050
 
2039
- // Require-loadable entries that declare CommonJS support but a typed CommonJS
2040
- // consumer cannot compile against. A default branch resolving under the require
2041
- // condition set makes no CommonJS claim.
2051
+ // Requirable entries that declare CommonJS support but a typed CommonJS consumer
2052
+ // cannot compile against. A default branch resolving under the require condition
2053
+ // set makes no CommonJS claim.
2042
2054
  function selectUntypable(entries: readonly Entry[], installed: string): readonly Entry[] {
2043
2055
  return entries.filter(
2044
2056
  (entry) =>
2045
- entry.required &&
2057
+ entry.requirable &&
2046
2058
  isRecord(entry.mapping) &&
2047
2059
  Object.hasOwn(entry.mapping, 'require') &&
2048
2060
  !declaresCommonJS(entry.mapping, installed),
2049
2061
  )
2050
2062
  }
2051
2063
 
2052
- // The value exports a declaration publishes, read through the compiler's checker
2053
- // over the module symbol rather than off the declaration text. An alias resolves to
2054
- // what it names, so a re-export counts as the thing it re-exports, and a type-only
2055
- // symbol is dropped because no runtime publishes one.
2056
- function readDeclaredExports(declaration: string): readonly string[] {
2057
- const program = ts.createProgram([declaration], {
2058
- module: ts.ModuleKind.ESNext,
2059
- moduleResolution: ts.ModuleResolutionKind.Bundler,
2060
- noEmit: true,
2061
- skipLibCheck: true,
2062
- target: ts.ScriptTarget.ESNext,
2063
- })
2064
- const source = program.getSourceFile(declaration)
2065
- if (source === undefined) throw new Error(\`The declaration \${declaration} was not read\`)
2066
- const checker = program.getTypeChecker()
2067
- const symbol = checker.getSymbolAtLocation(source)
2068
- if (symbol === undefined) throw new Error(\`\${declaration} declares no module symbol\`)
2069
- const values: string[] = []
2070
- for (const exported of checker.getExportsOfModule(symbol)) {
2071
- const direct = (exported.flags & ts.SymbolFlags.Alias) === 0
2072
- const resolved = direct ? exported : checker.getAliasedSymbol(exported)
2073
- if ((resolved.flags & ts.SymbolFlags.Value) !== 0) values.push(exported.getName())
2064
+ // One surface comparison, written as the consumer module that proves it: the
2065
+ // installed entry that consumer imports, the file extension fixing its importing
2066
+ // format, the names a real runtime published off it, and the driver whose scratch
2067
+ // project compiles it.
2068
+ interface Surface {
2069
+ readonly entry: Entry
2070
+ readonly extension: string
2071
+ readonly published: readonly string[]
2072
+ readonly driver: Resolution
2073
+ }
2074
+
2075
+ // A scratch project over named consumer modules, written beside them so their own
2076
+ // resolution reaches the installed package. Nothing is emitted and no ambient types
2077
+ // are pulled in, so what the check reads is the installed declarations alone.
2078
+ function writeProject(
2079
+ stage: Stage,
2080
+ name: string,
2081
+ driver: Resolution,
2082
+ files: readonly string[],
2083
+ ): string {
2084
+ const path = join(stage.consumer, \`tsconfig.\${name}.json\`)
2085
+ const project = {
2086
+ compilerOptions: {
2087
+ module: driver.module,
2088
+ moduleResolution: driver.resolution,
2089
+ noEmit: true,
2090
+ skipLibCheck: true,
2091
+ strict: true,
2092
+ target: 'esnext',
2093
+ types: [],
2094
+ },
2095
+ files: [...files],
2074
2096
  }
2075
- return [...values].sort()
2097
+ writeFile(path, \`\${JSON.stringify(project, undefined, '\\t')}\\n\`)
2098
+ return path
2076
2099
  }
2077
2100
 
2078
- // The diagnostics a consumer compiling against the installed declarations reports,
2079
- // flattened to their messages so a failure names what the consumer could not do.
2080
- function compileConsumer(
2081
- entry: string,
2082
- resolution: ts.ModuleResolutionKind,
2083
- module: ts.ModuleKind,
2084
- ): readonly string[] {
2085
- const program = ts.createProgram([entry], {
2086
- module,
2087
- moduleResolution: resolution,
2088
- noEmit: true,
2089
- skipLibCheck: true,
2090
- strict: true,
2091
- target: ts.ScriptTarget.ESNext,
2092
- })
2093
- return ts
2094
- .getPreEmitDiagnostics(program)
2095
- .map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, ' '))
2101
+ // The diagnostics the compiler this workspace installs reports for one scratch
2102
+ // project. The compiler runs as a command, so nothing here reaches an API that
2103
+ // moves between its majors, and the located lines it prints are the verdict rather
2104
+ // than the exit code, which moves between them. A line carrying no location, a line
2105
+ // naming the scratch project rather than a consumer module, and anything at all on
2106
+ // the error stream are faults of this proof rather than of the package under proof,
2107
+ // so each is raised where it happens instead of counted against the package.
2108
+ function checkProject(stage: Stage, project: string): readonly string[] {
2109
+ const result = runNode([TSC, '--noEmit', '--pretty', 'false', '-p', project], stage.consumer)
2110
+ const refused = \`\${result.stderr ?? ''}\`.trim()
2111
+ if (refused.length > 0) {
2112
+ throw new Error(\`The consumer compiler wrote \${refused} to its error stream\`)
2113
+ }
2114
+ const reported: string[] = []
2115
+ for (const line of \`\${result.stdout ?? ''}\`.split(/\\r\\n|\\n/u)) {
2116
+ if (line.trim().length === 0) continue
2117
+ const last = reported.at(-1)
2118
+ // An elaborated diagnostic prints its detail on indented lines under its own
2119
+ // first line, so each of those joins the diagnostic it elaborates.
2120
+ if (/^\\s/u.test(line) && last !== undefined) {
2121
+ reported[reported.length - 1] = \`\${last} \${line.trim()}\`
2122
+ continue
2123
+ }
2124
+ const located = DIAGNOSTIC_PATTERN.exec(line)?.[1]
2125
+ if (located === undefined) {
2126
+ throw new Error(\`The consumer compiler reported \${line}, which names no location\`)
2127
+ }
2128
+ if (resolve(stage.consumer, located) === project) {
2129
+ throw new Error(\`The scratch project is itself at fault: \${line}\`)
2130
+ }
2131
+ reported.push(line)
2132
+ }
2133
+ if (reported.length === 0 && result.status !== 0) {
2134
+ throw new Error(\`The consumer compiler refused the project: \${readOutput(result)}\`)
2135
+ }
2136
+ return reported
2137
+ }
2138
+
2139
+ // One installed entry's published names checked against its own declarations by
2140
+ // the compiler this workspace installs, in the direction each divergence surfaces
2141
+ // under. The runtime's key list is written into the consumer as a literal, so the
2142
+ // published side comes from a real process and the declared side from the
2143
+ // declarations that process's package ships, and the two can disagree. A name the
2144
+ // declarations carry and the runtime does not lands on \`declared\`. A name the
2145
+ // runtime carries and the declarations do not, and a name the declarations publish
2146
+ // as a type alone, land on \`surfaced\`: a variable widens into the type
2147
+ // \`declared\` annotates, and only \`surfaced\` reads the literal's own keys back.
2148
+ // Each names the member it is about, so the failure says which export moved.
2149
+ function checkSurface(stage: Stage, surface: Surface): readonly string[] {
2150
+ const slug = surface.entry.subpath.replaceAll(/[^\\w]+/gu, '-')
2151
+ const name = \`surface.\${surface.driver.label}\${slug}.\${surface.extension}\`
2152
+ const module = \`\${name}\`
2153
+ const keys = surface.published.map((key) => \`\${JSON.stringify(key)}: true\`).join(', ')
2154
+ writeFile(
2155
+ join(stage.consumer, module),
2156
+ \`import * as entry from \${JSON.stringify(surface.entry.specifier)}
2157
+ const published = {\${keys.length === 0 ? '' : \` \${keys} \`}} as const
2158
+ const declared: Record<keyof typeof entry, true> = published
2159
+ const surfaced: Record<keyof typeof published, true> = declared
2160
+ \`,
2161
+ )
2162
+ const project = writeProject(stage, name, surface.driver, [\`./\${module}\`])
2163
+ return checkProject(stage, project).map((line) => \`\${surface.driver.label}: \${line}\`)
2096
2164
  }
2097
2165
 
2098
2166
  // One consumer module importing every installed entry, written where its own
2099
2167
  // resolution finds the installed package.
2100
- function writeConsumerProbe(stage: Stage, path: string, specifiers: readonly string[]): string {
2168
+ function writeConsumerProbe(stage: Stage, path: string, specifiers: readonly string[]): void {
2101
2169
  const names: string[] = []
2102
2170
  const bindings: string[] = []
2103
2171
  for (const [index, specifier] of specifiers.entries()) {
@@ -2105,9 +2173,8 @@ function writeConsumerProbe(stage: Stage, path: string, specifiers: readonly str
2105
2173
  names.push(binding)
2106
2174
  bindings.push(\`import * as \${binding} from \${JSON.stringify(specifier)}\`)
2107
2175
  }
2108
- const target = join(stage.consumer, path)
2109
- writeFile(target, \`\${bindings.join('\\n')}\\nexport const surface = [\${names.join(', ')}]\\n\`)
2110
- return target
2176
+ const source = \`\${bindings.join('\\n')}\\nexport const surface = [\${names.join(', ')}]\\n\`
2177
+ writeFile(join(stage.consumer, path), source)
2111
2178
  }
2112
2179
 
2113
2180
  // The runtime key set a real process reads off one installed entry under one
@@ -2177,27 +2244,26 @@ function buildStage(): Stage {
2177
2244
  else excluded.push(subpath)
2178
2245
  continue
2179
2246
  }
2180
- const imported = resolveTarget(entry, RUNTIME_CONDITIONS.module)
2181
- const requiredTarget = resolveTarget(entry, RUNTIME_CONDITIONS.commonjs)
2247
+ const importTarget = resolveTarget(entry, RUNTIME_CONDITIONS.module)
2248
+ const requireTarget = resolveTarget(entry, RUNTIME_CONDITIONS.commonjs)
2182
2249
  const browserTarget = resolveTarget(entry, RUNTIME_CONDITIONS.browser)
2183
- const browser = resolvesBrowser(entry)
2184
- const required = requiredTarget !== undefined && !(browser && requiredTarget === browserTarget)
2185
- const commonjs = required && resolvesCommonJS(entry, installed)
2250
+ const browsable = resolvesBrowser(entry)
2251
+ const shadowed = browsable && requireTarget === browserTarget
2252
+ const requirable = requireTarget !== undefined && !shadowed
2253
+ const loadable = requirable && resolvesCommonJS(entry, installed)
2186
2254
  entries.push({
2187
2255
  subpath,
2188
2256
  specifier: subpath === '.' ? name : \`\${name}\${subpath.slice(1)}\`,
2189
2257
  mapping: entry,
2190
2258
  declaration: {
2191
- module: declaration.module === undefined ? undefined : join(installed, declaration.module),
2192
- commonjs:
2193
- declaration.commonjs === undefined ? undefined : join(installed, declaration.commonjs),
2194
- browser:
2195
- declaration.browser === undefined ? undefined : join(installed, declaration.browser),
2259
+ importable: declaration.module !== undefined,
2260
+ requirable: declaration.commonjs !== undefined,
2261
+ browsable: declaration.browser !== undefined,
2196
2262
  },
2197
- browser,
2198
- module: imported !== undefined && !(browser && imported === browserTarget),
2199
- commonjs,
2200
- required,
2263
+ browsable,
2264
+ importable: importTarget !== undefined && !(browsable && importTarget === browserTarget),
2265
+ requirable,
2266
+ loadable,
2201
2267
  })
2202
2268
  }
2203
2269
  return { consumer, installed, archives, entries, subpaths, undeclared, excluded, targets }
@@ -2348,7 +2414,7 @@ describe('installed package consumer', () => {
2348
2414
  // loads it. Each later drive retires itself for that entry, so this assertion names
2349
2415
  // the subpath rather than counting it as driven.
2350
2416
  const unreachable = stage.entries.filter(
2351
- (entry) => !entry.module && !entry.required && !entry.browser,
2417
+ (entry) => !entry.importable && !entry.requirable && !entry.browsable,
2352
2418
  )
2353
2419
  expect(unreachable.map((entry) => entry.subpath)).toStrictEqual([])
2354
2420
  const untypable = selectUntypable(stage.entries, stage.installed)
@@ -2377,16 +2443,18 @@ describe('installed package consumer', () => {
2377
2443
  for (const [extension, format] of FORMATS) {
2378
2444
  const written = selectEntries(stage.entries, driver.conditions[format])
2379
2445
  if (written.length === 0) continue
2446
+ const label = \`\${driver.label}.\${extension}\`
2447
+ const probe = \`probe.\${label}\`
2380
2448
  const specifiers = written.map((entry) => entry.specifier)
2381
- const probe = writeConsumerProbe(stage, \`probe.\${driver.label}.\${extension}\`, specifiers)
2382
- for (const message of compileConsumer(probe, driver.resolution, driver.module)) {
2383
- reported.push(\`\${driver.label}.\${extension}: \${message}\`)
2384
- }
2385
- const absent = [\`\${name}\${ABSENT_SUBPATH}\`]
2386
- const control = writeConsumerProbe(stage, \`control.\${driver.label}.\${extension}\`, absent)
2387
- if (compileConsumer(control, driver.resolution, driver.module).length === 0) {
2388
- silent.push(\`\${driver.label}.\${extension}\`)
2449
+ writeConsumerProbe(stage, probe, specifiers)
2450
+ const project = writeProject(stage, probe, driver, [\`./\${probe}\`])
2451
+ for (const message of checkProject(stage, project)) {
2452
+ reported.push(\`\${label}: \${message}\`)
2389
2453
  }
2454
+ const control = \`control.\${label}\`
2455
+ writeConsumerProbe(stage, control, [\`\${name}\${ABSENT_SUBPATH}\`])
2456
+ const refused = writeProject(stage, control, driver, [\`./\${control}\`])
2457
+ if (checkProject(stage, refused).length === 0) silent.push(label)
2390
2458
  }
2391
2459
  }
2392
2460
  expect(reported).toStrictEqual([])
@@ -2396,27 +2464,44 @@ describe('installed package consumer', () => {
2396
2464
 
2397
2465
  for (const entry of STAGE?.entries ?? []) {
2398
2466
  describe(\`installed entry \${entry.subpath}\`, () => {
2399
- it.runIf(entry.module)(
2467
+ it.runIf(entry.importable)(
2400
2468
  'publishes what it declares to a Node import, and no more',
2401
2469
  (context) => {
2402
- const declaration = entry.declaration.module
2403
- if (declaration === undefined) {
2470
+ const stage = requireStage(context)
2471
+ // The exports-map walk resolved a declaration a typed importer reads, so an
2472
+ // entry reaching this drive without one is reported for that rather than for
2473
+ // what a consumer of a missing declaration goes on to say.
2474
+ if (!entry.declaration.importable) {
2404
2475
  throw new Error(\`\${entry.subpath} publishes no import declaration\`)
2405
2476
  }
2406
- const published = driveRuntime(requireStage(context), entry.specifier, ESM_DRIVER)
2407
- expect(published).toStrictEqual(readDeclaredExports(declaration))
2477
+ const published = driveRuntime(stage, entry.specifier, ESM_DRIVER)
2478
+ const drivers = selectDrivers(entry, 'module')
2479
+ expect(drivers).not.toStrictEqual([])
2480
+ const reported = drivers.flatMap((driver) =>
2481
+ checkSurface(stage, { entry, extension: 'ts', published, driver }),
2482
+ )
2483
+ expect(reported).toStrictEqual([])
2408
2484
  },
2409
2485
  )
2410
2486
 
2411
- it.runIf(entry.required)(
2487
+ it.runIf(entry.requirable)(
2412
2488
  'publishes what it declares to a Node require, and no more',
2413
2489
  (context) => {
2414
- const declaration = entry.declaration.commonjs
2415
- if (declaration === undefined) {
2490
+ const stage = requireStage(context)
2491
+ if (!entry.declaration.requirable) {
2416
2492
  throw new Error(\`\${entry.subpath} publishes no require declaration\`)
2417
2493
  }
2418
- const published = driveRuntime(requireStage(context), entry.specifier, CJS_DRIVER)
2419
- expect(published).toStrictEqual(readDeclaredExports(declaration))
2494
+ const published = driveRuntime(stage, entry.specifier, CJS_DRIVER)
2495
+ // A subpath whose \`require\` resolves to a module that no typed CommonJS
2496
+ // consumer can compile against carries no declared side to compare here, and
2497
+ // whether it may publish one at all is the untypable set's question rather
2498
+ // than this drive's. The preceding runtime drive ran either way.
2499
+ const drivers = selectDrivers(entry, 'commonjs')
2500
+ expect(drivers).not.toStrictEqual([])
2501
+ const reported = drivers.flatMap((driver) =>
2502
+ checkSurface(stage, { entry, extension: 'cts', published, driver }),
2503
+ )
2504
+ expect(reported).toStrictEqual([])
2420
2505
  },
2421
2506
  )
2422
2507
  {{drive}} })
@@ -2529,12 +2614,11 @@ async function readBrowserExports(browser: Browser, bundle: string): Promise<rea
2529
2614
  }
2530
2615
  `,
2531
2616
  drive: `
2532
- it.runIf(entry.browser)(
2617
+ it.runIf(entry.browsable)(
2533
2618
  'publishes what it declares to a real browser, and no more [requires a browser]',
2534
2619
  async (context) => {
2535
2620
  const stage = requireStage(context)
2536
- const declaration = entry.declaration.browser
2537
- if (declaration === undefined) {
2621
+ if (!entry.declaration.browsable) {
2538
2622
  throw new Error(\`\${entry.subpath} publishes no browser declaration\`)
2539
2623
  }
2540
2624
  const options = resolveBrowser(resolvePinnedBrowser(), process.platform, process.env)
@@ -2545,9 +2629,16 @@ async function readBrowserExports(browser: Browser, bundle: string): Promise<rea
2545
2629
  })
2546
2630
  try {
2547
2631
  const bundle = await bundleEntry(stage, entry)
2548
- expect(await readBrowserExports(browser, bundle)).toStrictEqual(
2549
- readDeclaredExports(declaration),
2550
- )
2632
+ const published = await readBrowserExports(browser, bundle)
2633
+ // A browser consumer reads the installed declarations through a bundler, so
2634
+ // that is the one driver this face answers under.
2635
+ const reported = checkSurface(stage, {
2636
+ entry,
2637
+ extension: 'ts',
2638
+ published,
2639
+ driver: BROWSER_DRIVER,
2640
+ })
2641
+ expect(reported).toStrictEqual([])
2551
2642
  } finally {
2552
2643
  await browser.close()
2553
2644
  }
@@ -2570,7 +2661,7 @@ async function readBrowserExports(browser: Browser, bundle: string): Promise<rea
2570
2661
  // file and runs the \`repair\` verb, which writes the variant carrying that branch.
2571
2662
  it('publishes no browser face this proof cannot drive [requires the registry]', (context) => {
2572
2663
  const stage = requireStage(context)
2573
- const faces = stage.entries.filter((entry) => entry.browser)
2664
+ const faces = stage.entries.filter((entry) => entry.browsable)
2574
2665
  expect(faces.map((entry) => entry.subpath)).toStrictEqual([])
2575
2666
  })
2576
2667
  `
@@ -2685,12 +2776,12 @@ printf '%s\\n' \\
2685
2776
  *
2686
2777
  * @example
2687
2778
  * ```ts
2688
- * import { ScaffoldError, isScaffoldError } from '@orkestrel/scaffold'
2779
+ * import { isScaffoldError, ScaffoldError } from '@orkestrel/scaffold'
2689
2780
  *
2690
2781
  * try {
2691
- * throw new ScaffoldError('INVALID', 'Blueprint is not an exact record')
2782
+ * throw new ScaffoldError('TARGET', 'The target carries no readable manifest.')
2692
2783
  * } catch (error) {
2693
- * if (isScaffoldError(error)) error.code // 'INVALID'
2784
+ * if (isScaffoldError(error)) error.code // 'TARGET'
2694
2785
  * }
2695
2786
  * ```
2696
2787
  */
@@ -3135,7 +3226,8 @@ var isCatalogEntry = (0, _orkestrel_contract.unionOf)((0, _orkestrel_contract.re
3135
3226
  name: isDependencyName,
3136
3227
  lookup: (0, _orkestrel_contract.literalOf)("found"),
3137
3228
  version: _orkestrel_contract.isString,
3138
- dependencies: (0, _orkestrel_contract.andOf)(isCollection, (0, _orkestrel_contract.arrayOf)(isDependency))
3229
+ dependencies: (0, _orkestrel_contract.andOf)(isCollection, (0, _orkestrel_contract.arrayOf)(isDependency)),
3230
+ peers: (0, _orkestrel_contract.andOf)(isCollection, (0, _orkestrel_contract.arrayOf)(isDependency))
3139
3231
  }), (0, _orkestrel_contract.recordOf)({
3140
3232
  name: isDependencyName,
3141
3233
  lookup: (0, _orkestrel_contract.literalOf)("missing", "unmatched", "failed"),
@@ -3521,7 +3613,7 @@ function isCanonPath(path) {
3521
3613
  return CANON_PATHS.some((canon) => path === canon || path.startsWith(`${canon}/`));
3522
3614
  }
3523
3615
  /**
3524
- * Checks whether a target's present bytes at a path are owned by another surface.
3616
+ * Checks whether another surface owns a target's present bytes at a path.
3525
3617
  *
3526
3618
  * @param path - The target-relative path to test.
3527
3619
  * @returns True if the path is a {@link WORKSPACE_OWNED_PATHS} member or a
@@ -3698,46 +3790,6 @@ function matchesPrintWidth(line) {
3698
3790
  return line.replaceAll(" ", " ".repeat(2)).length <= 100;
3699
3791
  }
3700
3792
  /**
3701
- * Derives the declaration rewrite a published face's `beforeWriteFile` applies.
3702
- *
3703
- * @param name - The workspace's own bare package name.
3704
- * @returns The ternary consequent an emitted `vite.{browser,server}.config.ts`
3705
- * fills its `{{replacement}}` span with, indented for that span.
3706
- *
3707
- * @remarks
3708
- * `vite-plugin-dts` rolls a face into one declaration and keeps each source
3709
- * module's own relative depth, so a nested module emits a path that escapes
3710
- * `dist/src` and a flat one resolves only by luck. Both faces rewrite the same
3711
- * relative core path to the package's published root export, so the branch is
3712
- * derived once here. The extension alternation is what the permitted import
3713
- * spellings produce: an `@src/core` alias resolves to the core source module and
3714
- * prints `.ts`, while a relative import prints the `.js` specifier it was
3715
- * written with. The formatter keeps the call on one line only while the line it
3716
- * prints measures inside the vendored width, and the workspace name is what
3717
- * varies, so the shape is chosen by measuring the candidate: a tab prints as the
3718
- * vendored two columns, and the gate admits a name long enough to push the
3719
- * joined call past 100.
3720
- *
3721
- * @example
3722
- * ```ts
3723
- * import { nameToRewrite } from '@orkestrel/scaffold'
3724
- *
3725
- * nameToRewrite('router').includes("'@orkestrel/router'") // true
3726
- * ```
3727
- */
3728
- function nameToRewrite(name) {
3729
- const specifier = serializeTypeScriptString(`@orkestrel/${name}`);
3730
- const pattern = "/(?:\\.\\.\\/)+core\\/index\\.[jt]s/g";
3731
- const joined = `\t\t\t\t\t\t? content.replaceAll(${pattern}, ${specifier})`;
3732
- if (matchesPrintWidth(joined)) return joined;
3733
- return [
3734
- " ? content.replaceAll(",
3735
- `\t\t\t\t\t\t\t\t${pattern},`,
3736
- `\t\t\t\t\t\t\t\t${specifier},`,
3737
- " )"
3738
- ].join("\n");
3739
- }
3740
- /**
3741
3793
  * Selects the single published environment a package root points at.
3742
3794
  *
3743
3795
  * @param src - The declared published environments.
@@ -3993,9 +4045,11 @@ function matchesDriftReachability(ownership, finding) {
3993
4045
  * @remarks
3994
4046
  * A layer is a deterministic function of the catalog's own edges, so it is
3995
4047
  * computed here rather than stored on a row that could disagree with them.
3996
- * Only RUNTIME edges between catalogued packages count: a development
4048
+ * Only RUNTIME and PEER edges between catalogued packages count: a development
3997
4049
  * dependency reaches no consumer, so it constrains nothing about publish order,
3998
- * and an edge leaving the fleet is a package this catalog does not publish.
4050
+ * and an edge leaving the fleet is a package this catalog does not publish. A
4051
+ * peer edge counts like a runtime edge, because a caret peer range at `0.0.x`
4052
+ * names one exact release the dependent cannot publish ahead of.
3999
4053
  *
4000
4054
  * The order matters because these packages are `0.0.x`, where a caret pins one
4001
4055
  * exact release. Publishing a dependent before its dependency leaves the
@@ -4006,11 +4060,12 @@ function matchesDriftReachability(ownership, finding) {
4006
4060
  * placed in an order that would be wrong. An absent name is the report: compare
4007
4061
  * the returned names against the catalog to find one.
4008
4062
  *
4009
- * @example
4063
+ * @example Fleet catalog
4010
4064
  * ```ts
4011
4065
  * import { catalogToLayers } from '@orkestrel/scaffold'
4012
4066
  *
4013
- * catalogToLayers(entries)[0] // the names that depend on nothing in the fleet
4067
+ * const layers = catalogToLayers(entries)
4068
+ * layers[0] // the names that depend on nothing else in the fleet
4014
4069
  * ```
4015
4070
  */
4016
4071
  function catalogToLayers(entries) {
@@ -4018,7 +4073,7 @@ function catalogToLayers(entries) {
4018
4073
  const pending = /* @__PURE__ */ new Map();
4019
4074
  for (const entry of entries) {
4020
4075
  if (entry.lookup !== "found") continue;
4021
- const edges = entry.dependencies.map((dependency) => dependency.name);
4076
+ const edges = [...entry.dependencies, ...entry.peers].map((dependency) => dependency.name);
4022
4077
  pending.set(entry.name, new Set(edges.filter((name) => published.has(name))));
4023
4078
  }
4024
4079
  const layers = [];
@@ -4595,7 +4650,7 @@ function blueprintToScripts(blueprint) {
4595
4650
  scripts["test:policy"] = `${vitest} --project policy`;
4596
4651
  scripts["test:config"] = `${vitest} --project config`;
4597
4652
  if (blueprint.setup) scripts["test:setup"] = `${vitest} --project setup`;
4598
- if (blueprint.guides) scripts["test:guides"] = `${vitest} --project guides`;
4653
+ if (blueprint.guides) scripts["test:guides"] = `node --experimental-strip-types ${GUIDES_TEST_PATH}`;
4599
4654
  if (blueprint.conformance) scripts["test:conformance"] = `${vitest} --project conformance`;
4600
4655
  scripts["test:probe"] = "vitest run --config vite.config.ts --no-cache --reporter=verbose --project probe";
4601
4656
  scripts["test:bench"] = "vitest bench --config vite.config.ts --no-cache --project probe";
@@ -4649,13 +4704,16 @@ function blueprintToScripts(blueprint) {
4649
4704
  *
4650
4705
  * @remarks
4651
4706
  * Every direct `test:<project>` script is writable, together with the probe and
4652
- * benchmark workbench scripts. Publishing adds the pack and publication
4653
- * lifecycle scripts. Aggregate test scripts and maintainer-owned gate chains
4654
- * stay outside the region.
4707
+ * benchmark workbench scripts. A workspace carrying guides adds `test:guides`,
4708
+ * whose package-owned entry runs the guides project and handles explicit parity
4709
+ * rewrites. Publishing adds the pack and publication lifecycle scripts.
4710
+ * Aggregate test scripts and
4711
+ * maintainer-owned gate chains stay outside the region.
4655
4712
  *
4656
4713
  * `accepted` carries each generated predecessor the region can replace. The
4657
- * pack hook accepts the build chain emitted before it delegated to `build`. The
4658
- * publication hook accepts the same gate chain without
4714
+ * guides entry accepts the generated command that invoked the guides project
4715
+ * through Vitest alone. The pack hook accepts the build chain emitted before it
4716
+ * delegated to `build`. The publication hook accepts the same gate chain without
4659
4717
  * {@link RELEASE_PROOF_COMMAND}. The value being written is always writable, so
4660
4718
  * it is not repeated there. Any other value is a script the workspace author
4661
4719
  * customized, and {@link replaceManifestScripts} retains it while writing the
@@ -4674,11 +4732,11 @@ function blueprintToWritableScripts(blueprint) {
4674
4732
  const scripts = blueprintToScripts(blueprint);
4675
4733
  const writable = [];
4676
4734
  for (const [name, command] of Object.entries(scripts)) {
4677
- if (!name.startsWith("test:") || name === "test:src" || name === "test:app") continue;
4735
+ if (!(name.startsWith("test:") && name !== "test:src" && name !== "test:app")) continue;
4678
4736
  writable.push({
4679
4737
  name,
4680
4738
  command,
4681
- accepted: []
4739
+ accepted: name === "test:guides" ? ["vitest run --config vite.config.ts --no-cache --reporter=dot --project guides"] : []
4682
4740
  });
4683
4741
  }
4684
4742
  const prepack = scripts.prepack;
@@ -4826,6 +4884,21 @@ function blueprintToMachinery(blueprint) {
4826
4884
  * @param blueprint - The workspace specification.
4827
4885
  * @returns Formatter-stable `tsconfig.json` text.
4828
4886
  *
4887
+ * @remarks
4888
+ * `paths` carries the workspace's own published specifiers beside the `@src` and
4889
+ * `@app` aliases, mapped to source. The published set is what
4890
+ * {@link srcToExports} publishes, read the same way here so the two never name
4891
+ * different subpaths, and the `app` axis publishes nothing so it maps nothing.
4892
+ * A package's own name resolves inside its own checkout through that `exports`
4893
+ * map, to the built `dist/` entry, so a module importing it would make the root
4894
+ * typecheck depend on a build; mapping the specifier to source is what keeps
4895
+ * `npm run check` independent of `npm run build`. The root Vite configuration
4896
+ * derives its `alias` record from every `paths` entry, so the same specifiers
4897
+ * resolve to source under Vitest, and every subpath is emitted before the bare
4898
+ * specifier: an alias record is matched in declaration order and a bare pattern
4899
+ * also matches its own subpaths, so the reverse order would resolve
4900
+ * `@orkestrel/<name>/server` through the core entry.
4901
+ *
4829
4902
  * @example
4830
4903
  * ```ts
4831
4904
  * import { blueprintToRootTsconfig, createBlueprint } from '@orkestrel/scaffold'
@@ -4837,9 +4910,21 @@ function blueprintToMachinery(blueprint) {
4837
4910
  */
4838
4911
  function blueprintToRootTsconfig(blueprint) {
4839
4912
  const aliases = [];
4840
- for (const environment of ENVIRONMENTS) if (blueprint.src.includes(environment)) aliases.push(`"@src/${environment}": ["./src/${environment}/index.ts"]`);
4841
- for (const environment of ENVIRONMENTS) if (blueprint.app.includes(environment)) aliases.push(`"@app/${environment}": ["./app/${environment}/index.ts"]`);
4842
- const paths = aliases.map((alias, index) => `\t\t\t${alias}${index === aliases.length - 1 ? "" : ","}`).join("\n");
4913
+ for (const environment of ENVIRONMENTS) if (blueprint.src.includes(environment)) aliases.push([`@src/${environment}`, `./src/${environment}/index.ts`]);
4914
+ for (const environment of ENVIRONMENTS) if (blueprint.app.includes(environment)) aliases.push([`@app/${environment}`, `./app/${environment}/index.ts`]);
4915
+ const root = srcToRoot(blueprint.src);
4916
+ if (root === void 0) for (const environment of ENVIRONMENTS) {
4917
+ if (environment === "core" || !blueprint.src.includes(environment)) continue;
4918
+ const subpath = SRC_MATRIX[environment].path.slice(1);
4919
+ aliases.push([`@orkestrel/${blueprint.name}${subpath}`, `./src/${environment}/index.ts`]);
4920
+ }
4921
+ if (blueprint.src.length > 0) aliases.push([`@orkestrel/${blueprint.name}`, `./src/${root ?? "core"}/index.ts`]);
4922
+ const paths = aliases.map(([specifier, target], index) => {
4923
+ const separator = index === aliases.length - 1 ? "" : ",";
4924
+ const line = `\t\t\t"${specifier}": ["${target}"]${separator}`;
4925
+ if (matchesPrintWidth(line)) return line;
4926
+ return `\t\t\t"${specifier}": [\n\t\t\t\t"${target}"\n\t\t\t]${separator}`;
4927
+ }).join("\n");
4843
4928
  return (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.root.tsconfig, { paths });
4844
4929
  }
4845
4930
  /**
@@ -5072,9 +5157,9 @@ function blueprintToConfigArtifacts(blueprint) {
5072
5157
  for (const environment of blueprint.src) for (const path of SRC_MATRIX[environment].configs) {
5073
5158
  let content = CONFIG_TEMPLATES.vites.src.core;
5074
5159
  if (path === "configs/src/tsconfig.core.json") content = CONFIG_TEMPLATES.tsconfigs.src.core;
5075
- else if (path === "configs/src/vite.browser.config.ts") content = (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.vites.src.browser, { replacement: nameToRewrite(blueprint.name) });
5160
+ else if (path === "configs/src/vite.browser.config.ts") content = CONFIG_TEMPLATES.vites.src.browser;
5076
5161
  else if (path === "configs/src/tsconfig.browser.json") content = CONFIG_TEMPLATES.tsconfigs.src.browser;
5077
- else if (path === "configs/src/vite.server.config.ts") content = (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.vites.src.server, { replacement: nameToRewrite(blueprint.name) });
5162
+ else if (path === "configs/src/vite.server.config.ts") content = CONFIG_TEMPLATES.vites.src.server;
5078
5163
  else if (path === "configs/src/tsconfig.server.json") content = CONFIG_TEMPLATES.tsconfigs.src.server;
5079
5164
  artifacts.push({
5080
5165
  path,
@@ -5517,11 +5602,11 @@ function blueprintToOrchestrationArtifacts(blueprint) {
5517
5602
  }];
5518
5603
  }
5519
5604
  /**
5520
- * Compiles the vendored host artifacts a named workspace plans.
5605
+ * Compiles the vendored host artifacts a workspace plans.
5521
5606
  *
5522
- * @param name - The target workspace's own bare package name.
5523
- * @returns One artifact per vendored path in `HOST_PATHS` order, then the
5524
- * catalog file.
5607
+ * @param blueprint - The workspace specification.
5608
+ * @returns One artifact per selected vendored path in `HOST_PATHS` order, then
5609
+ * the catalog file.
5525
5610
  *
5526
5611
  * @remarks
5527
5612
  * Every artifact is claimed by presence, which is the strongest claim a pure
@@ -5546,15 +5631,16 @@ function blueprintToOrchestrationArtifacts(blueprint) {
5546
5631
  *
5547
5632
  * @example
5548
5633
  * ```ts
5549
- * import { nameToHostArtifacts } from '@orkestrel/scaffold'
5634
+ * import { blueprintToHostArtifacts, createBlueprint } from '@orkestrel/scaffold'
5550
5635
  *
5551
- * nameToHostArtifacts('router').some((artifact) => artifact.path === '.claude/settings.json') // true
5552
- * nameToHostArtifacts('router').some((artifact) => artifact.path === '.claude/agents/orkestrel.md') // true
5553
- * nameToHostArtifacts('router').some((artifact) => artifact.path === 'guides/router.md') // false
5636
+ * const blueprint = createBlueprint('router')
5637
+ *
5638
+ * blueprintToHostArtifacts(blueprint).some((artifact) => artifact.path === 'tests/guides.test.ts') // false
5639
+ * blueprintToHostArtifacts(blueprint).some((artifact) => artifact.path === 'guides/router.md') // false
5554
5640
  * ```
5555
5641
  */
5556
- function nameToHostArtifacts(name) {
5557
- return [...selectHostPaths(HOST_PATHS, name), CATALOG_AGENT_PATH].map((path) => ({
5642
+ function blueprintToHostArtifacts(blueprint) {
5643
+ return [...selectHostPaths(HOST_PATHS, blueprint.name), CATALOG_AGENT_PATH].map((path) => ({
5558
5644
  path,
5559
5645
  group: inferGroup(path),
5560
5646
  ownership: "presence",
@@ -5597,7 +5683,8 @@ function applyOverrides(artifacts, overrides) {
5597
5683
  });
5598
5684
  }
5599
5685
  /**
5600
- * Replaces declared dependency ranges in package manifest text.
5686
+ * Replaces the runtime and development dependency ranges in package manifest text, and never a
5687
+ * peer range.
5601
5688
  *
5602
5689
  * @param manifest - The manifest text to compile.
5603
5690
  * @param pins - The runtime and development names and replacement ranges.
@@ -6483,12 +6570,18 @@ function overridesToQuestions(overrides, artifacts) {
6483
6570
  * and let the answers disagree, so a blueprint the gate will
6484
6571
  * refuse is still constructible.
6485
6572
  *
6486
- * @example
6573
+ * @example Blueprint
6487
6574
  * ```ts
6488
6575
  * import { createBlueprint } from '@orkestrel/scaffold'
6489
6576
  *
6490
- * createBlueprint('router', { src: ['core'] }).version // '0.0.1'
6491
- * createBlueprint('Router').name // 'Router' — the gate refuses it, this does not
6577
+ * const blueprint = createBlueprint('router', {
6578
+ * src: ['core', 'server'],
6579
+ * dependencies: [{ name: '@orkestrel/emitter', range: '^0.0.5' }],
6580
+ * bin: true,
6581
+ * })
6582
+ *
6583
+ * blueprint.version // '0.0.1'
6584
+ * blueprint.engines // '>=22.12.0'
6492
6585
  * ```
6493
6586
  */
6494
6587
  function createBlueprint(name, input) {
@@ -6552,11 +6645,13 @@ function createBlueprint(name, input) {
6552
6645
  *
6553
6646
  * @example
6554
6647
  * ```ts
6555
- * import { createBlueprint, Compiler } from '@orkestrel/scaffold'
6648
+ * import { Compiler, createBlueprint } from '@orkestrel/scaffold'
6556
6649
  *
6557
6650
  * const compiler = new Compiler()
6558
6651
  * const scaffolding = compiler.compile(createBlueprint('router', { src: ['core'] }))
6559
- * scaffolding.plan?.hash?.length // 16
6652
+ *
6653
+ * scaffolding.plan?.artifacts // every planned file, in group order
6654
+ * scaffolding.stages // one CompileRecord per stage that ran
6560
6655
  * compiler.destroy()
6561
6656
  * ```
6562
6657
  */
@@ -6788,7 +6883,7 @@ var Compiler = class {
6788
6883
  ...blueprintToGuideArtifacts(blueprint),
6789
6884
  ...blueprintToDocumentArtifacts(blueprint),
6790
6885
  ...blueprintToOrchestrationArtifacts(blueprint),
6791
- ...nameToHostArtifacts(blueprint.name)
6886
+ ...blueprintToHostArtifacts(blueprint)
6792
6887
  ];
6793
6888
  }
6794
6889
  #gate(blueprint, draft, artifacts) {
@@ -6894,6 +6989,7 @@ exports.blueprintToConfigArtifacts = blueprintToConfigArtifacts;
6894
6989
  exports.blueprintToDevDependencies = blueprintToDevDependencies;
6895
6990
  exports.blueprintToDocumentArtifacts = blueprintToDocumentArtifacts;
6896
6991
  exports.blueprintToGuideArtifacts = blueprintToGuideArtifacts;
6992
+ exports.blueprintToHostArtifacts = blueprintToHostArtifacts;
6897
6993
  exports.blueprintToMachinery = blueprintToMachinery;
6898
6994
  exports.blueprintToManifest = blueprintToManifest;
6899
6995
  exports.blueprintToOrchestrationArtifacts = blueprintToOrchestrationArtifacts;
@@ -6952,8 +7048,6 @@ exports.matchesOrchestrationPath = matchesOrchestrationPath;
6952
7048
  exports.matchesPrintWidth = matchesPrintWidth;
6953
7049
  exports.matchesRange = matchesRange;
6954
7050
  exports.nameToGuide = nameToGuide;
6955
- exports.nameToHostArtifacts = nameToHostArtifacts;
6956
- exports.nameToRewrite = nameToRewrite;
6957
7051
  exports.overridesToQuestions = overridesToQuestions;
6958
7052
  exports.parseBlueprint = parseBlueprint;
6959
7053
  exports.parseCompilerOptions = parseCompilerOptions;