@orkestrel/scaffold 0.0.134 → 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 (40) hide show
  1. package/dist/agents/skills/orkestrel-parallel/scripts/lane.js +610 -79
  2. package/dist/agents/skills/orkestrel-publish/scripts/wave.js +307 -16
  3. package/dist/bin/main.js +253 -35
  4. package/dist/bin/main.js.map +1 -1
  5. package/dist/host/AGENTS.md +1 -1
  6. package/dist/host/agents/skills/orkestrel-parallel/SKILL.md +1 -1
  7. package/dist/host/agents/skills/orkestrel-parallel/scripts/lane.ts +782 -115
  8. package/dist/host/agents/skills/orkestrel-publish/references/release.md +1 -0
  9. package/dist/host/agents/skills/orkestrel-publish/references/wave.md +22 -5
  10. package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +379 -27
  11. package/dist/host/claude/agents/orkestrel.md +14 -14
  12. package/dist/host/claude/rules/architecture.md +1 -1
  13. package/dist/host/claude/rules/patterns.md +2 -0
  14. package/dist/host/claude/rules/workspace.md +64 -63
  15. package/dist/host/configs/helpers.ts +88 -67
  16. package/dist/host/dotfiles/oxlintrc.json +1 -57
  17. package/dist/host/guides/agent.md +989 -395
  18. package/dist/host/guides/database.md +357 -342
  19. package/dist/host/guides/middleware.md +5 -5
  20. package/dist/host/guides/ollama.md +41 -42
  21. package/dist/host/guides/scaffold.md +177 -105
  22. package/dist/host/guides/study.md +12 -12
  23. package/dist/host/guides/test.md +158 -46
  24. package/dist/host/guides/toolbox.md +127 -81
  25. package/dist/host/guides/workspace.md +21 -14
  26. package/dist/host/manifest.json +23 -23
  27. package/dist/host/tests/config.test.ts +166 -112
  28. package/dist/src/core/index.cjs +491 -195
  29. package/dist/src/core/index.cjs.map +1 -1
  30. package/dist/src/core/index.d.cts +217 -24
  31. package/dist/src/core/index.d.ts +217 -24
  32. package/dist/src/core/index.js +482 -193
  33. package/dist/src/core/index.js.map +1 -1
  34. package/dist/src/server/index.cjs +18 -8
  35. package/dist/src/server/index.cjs.map +1 -1
  36. package/dist/src/server/index.d.cts +4 -3
  37. package/dist/src/server/index.d.ts +4 -3
  38. package/dist/src/server/index.js +19 -9
  39. package/dist/src/server/index.js.map +1 -1
  40. package/package.json +2 -2
@@ -753,12 +753,6 @@ describe('root configuration', () => {
753
753
  'tests/src/bin/**/*.test.ts',
754
754
  ['./tests/setup.ts', './tests/setupServer.ts'],
755
755
  ],
756
- [
757
- 'src:reporter',
758
- 'src/reporter/main.ts',
759
- 'tests/src/reporter/**/*.test.ts',
760
- ['./tests/setup.ts', './tests/setupServer.ts'],
761
- ],
762
756
  ['app:core', 'app/core', 'tests/app/core/**/*.test.ts', ['./tests/setup.ts']],
763
757
  [
764
758
  'app:browser',
@@ -1143,9 +1137,6 @@ describe('root configuration', () => {
1143
1137
  ...(existsSync(resolve(POLICY_ROOT, 'src/bin'))
1144
1138
  ? ['configs/src/tsconfig.bin.json', 'configs/src/vite.bin.config.ts']
1145
1139
  : []),
1146
- ...(existsSync(resolve(POLICY_ROOT, 'src/reporter/main.ts'))
1147
- ? ['configs/src/tsconfig.reporter.json', 'configs/src/vite.reporter.config.ts']
1148
- : []),
1149
1140
  ...(existsSync(resolve(POLICY_ROOT, 'configs/app/vite.showcase.config.ts'))
1150
1141
  ? ['configs/app/vite.showcase.config.ts']
1151
1142
  : []),
@@ -1210,7 +1201,7 @@ describe('root configuration', () => {
1210
1201
  for (const { wrapper, directory } of targets) {
1211
1202
  expect(controlled).toContain(wrapper)
1212
1203
  const viteMatch =
1213
- /^configs\/(src|app)\/vite\.(core|browser|server|bin|reporter|showcase|journey)\.config\.ts$/u.exec(
1204
+ /^configs\/(src|app)\/vite\.(core|browser|server|bin|showcase|journey)\.config\.ts$/u.exec(
1214
1205
  wrapper,
1215
1206
  )
1216
1207
  if (viteMatch !== null) {
@@ -1270,7 +1261,7 @@ describe('root configuration', () => {
1270
1261
  const output = loaded.config.build?.outDir
1271
1262
  if (output === undefined) throw new Error(`${wrapper} carries no output`)
1272
1263
  const expected =
1273
- environment === 'bin' || environment === 'reporter'
1264
+ environment === 'bin'
1274
1265
  ? `dist/${environment}`
1275
1266
  : environment === 'showcase'
1276
1267
  ? 'showcase'
@@ -1283,9 +1274,7 @@ describe('root configuration', () => {
1283
1274
  }
1284
1275
 
1285
1276
  const tsconfigMatch =
1286
- /^configs\/(src|app)\/tsconfig\.(core|browser|server|bin|reporter|vue)\.json$/u.exec(
1287
- wrapper,
1288
- )
1277
+ /^configs\/(src|app)\/tsconfig\.(core|browser|server|bin|vue)\.json$/u.exec(wrapper)
1289
1278
  if (tsconfigMatch === null) {
1290
1279
  throw new Error(`${wrapper} is not a required target wrapper`)
1291
1280
  }
@@ -1560,33 +1549,42 @@ describe('root configuration', () => {
1560
1549
  }
1561
1550
  })
1562
1551
 
1563
- // A workspace that holds `src/reporter/main.ts` publishes a Vitest reporter. The case copies the
1564
- // workspace's build inputs into a scratch directory under `tmp/`, so the real `dist/` stays as
1565
- // the last build left it, builds core, server, and the reporter there through the workspace's own
1566
- // wrappers, and reads what the reporter ships. A child Node process loads the built entry, as a
1567
- // consumer's Vitest does. A workspace without the entry has no wrapper, and the assertion
1568
- // classifies the absence.
1569
- it('builds the reporter entry to one ES module whose default is the server class', async () => {
1570
- const wrapper = 'configs/src/vite.reporter.config.ts'
1571
- const planned = existsSync(resolve(POLICY_ROOT, 'src/reporter/main.ts'))
1572
- expect(existsSync(resolve(POLICY_ROOT, wrapper))).toBe(planned)
1573
- if (!planned) return
1552
+ // A workspace publishes each `src/bin` module other than `main`: a direct lowercase `.ts` child
1553
+ // that no centralized file names. The case copies the workspace's build inputs into a scratch
1554
+ // directory under `tmp/`, so the real `dist/` stays as the last build left it, builds the
1555
+ // library environments and the bin there through the workspace's own wrappers, and reads what
1556
+ // each module ships. A child Node process loads each built module, as a host tool does, and
1557
+ // its default must be a value an environment it imports exports. A workspace with no such
1558
+ // module builds nothing here.
1559
+ it('builds each src/bin module to one ES module whose default an environment exports', async () => {
1560
+ const wrapper = 'configs/src/vite.bin.config.ts'
1561
+ const directory = resolve(POLICY_ROOT, 'src/bin')
1562
+ const modules = existsSync(directory)
1563
+ ? readdirSync(directory)
1564
+ .filter(
1565
+ (file) => /^[a-z][a-z0-9]*\.ts$/u.test(file) && !CENTRAL_SOURCE_FILES.includes(file),
1566
+ )
1567
+ .map((file) => file.slice(0, -'.ts'.length))
1568
+ : []
1569
+ expect(existsSync(resolve(POLICY_ROOT, wrapper))).toBe(modules.length > 0)
1570
+ const published = modules.filter((name) => name !== 'main')
1571
+ if (published.length === 0) return
1574
1572
  mkdirSync(resolve(POLICY_ROOT, 'tmp'), { recursive: true })
1575
1573
  const scratch = createPolicyScratch({
1576
1574
  parent: resolve(POLICY_ROOT, 'tmp'),
1577
- prefix: 'config-reporter-',
1575
+ prefix: 'config-bin-',
1578
1576
  })
1579
1577
  try {
1580
1578
  for (const path of ['package.json', 'tsconfig.json', 'vite.config.ts', 'configs', 'src']) {
1581
1579
  cpSync(resolve(POLICY_ROOT, path), join(scratch.path, path), { recursive: true })
1582
1580
  }
1583
- const configs = [
1584
- ...['core', 'server']
1585
- .filter((environment) => existsSync(resolve(POLICY_ROOT, 'src', environment)))
1586
- .map((environment) => `configs/src/vite.${environment}.config.ts`),
1581
+ const environments = ['core', 'server'].filter((environment) =>
1582
+ existsSync(resolve(POLICY_ROOT, 'src', environment)),
1583
+ )
1584
+ for (const config of [
1585
+ ...environments.map((environment) => `configs/src/vite.${environment}.config.ts`),
1587
1586
  wrapper,
1588
- ]
1589
- for (const config of configs) {
1587
+ ]) {
1590
1588
  await build({
1591
1589
  configFile: join(scratch.path, config),
1592
1590
  root: scratch.path,
@@ -1594,56 +1592,80 @@ describe('root configuration', () => {
1594
1592
  logLevel: 'silent',
1595
1593
  })
1596
1594
  }
1597
- const output = join(scratch.path, 'dist/reporter')
1598
- const code = readFileSync(join(output, 'main.js'), 'utf8')
1599
- // Each reading names its file, so a failure's diff states which output kept the alias. The
1600
- // bundler and the extractor each choose their own quote, so the specifier reads either one.
1601
- const built = /from ["']\.\.\/src\/server\/index\.js["']/u
1595
+ const output = join(scratch.path, 'dist/bin')
1596
+ // Rolldown strips a source shebang, so the executable carries the banner and no module does.
1597
+ const executable = join(output, 'main.js')
1602
1598
  expect({
1603
1599
  file: 'main.js',
1604
- alias: code.includes('@src/server'),
1605
- built: built.test(code),
1606
- }).toStrictEqual({ file: 'main.js', alias: false, built: true })
1607
- const declaration = readFileSync(join(output, 'main.d.ts'), 'utf8')
1608
- expect({
1609
- file: 'main.d.ts',
1610
- alias: declaration.includes('@src/server'),
1611
- built: built.test(declaration),
1612
- exported: declaration.includes('export default'),
1613
- }).toStrictEqual({ file: 'main.d.ts', alias: false, built: true, exported: true })
1614
- // The distribution scan refuses a reporter map that names no `src/reporter/` source.
1615
- const map = join(output, 'main.js.map')
1616
- const parsed: unknown = existsSync(map) ? JSON.parse(readFileSync(map, 'utf8')) : undefined
1617
- const sources: unknown =
1618
- typeof parsed === 'object' && parsed !== null
1619
- ? Object.getOwnPropertyDescriptor(parsed, 'sources')?.value
1620
- : undefined
1621
- const listed = Array.isArray(sources)
1622
- ? sources.flatMap((source: unknown) =>
1623
- typeof source === 'string'
1624
- ? [relative(scratch.path, resolve(output, source)).replaceAll('\\', '/')]
1625
- : [],
1626
- )
1627
- : []
1628
- expect({ file: 'main.js.map', entry: listed.includes('src/reporter/main.ts') }).toStrictEqual(
1629
- { file: 'main.js.map', entry: true },
1630
- )
1631
- const reporter = pathToFileURL(join(output, 'main.js')).href
1632
- const server = pathToFileURL(join(scratch.path, 'dist/src/server/index.js')).href
1633
- const loaded = spawnSync(
1634
- process.execPath,
1635
- [
1636
- '--input-type=module',
1637
- '--eval',
1638
- `const reporter = await import(${JSON.stringify(reporter)})\nconst server = await import(${JSON.stringify(server)})\nprocess.stdout.write(JSON.stringify({ kind: typeof reporter.default, owned: Object.values(server).includes(reporter.default) }))`,
1639
- ],
1640
- { encoding: 'utf8' },
1641
- )
1642
- expect({ status: loaded.status, stderr: loaded.stderr }).toStrictEqual({
1643
- status: 0,
1644
- stderr: '',
1645
- })
1646
- expect(JSON.parse(loaded.stdout)).toStrictEqual({ kind: 'function', owned: true })
1600
+ shebang: existsSync(executable)
1601
+ ? readFileSync(executable, 'utf8').startsWith('#!/usr/bin/env node\n')
1602
+ : undefined,
1603
+ }).toStrictEqual({ file: 'main.js', shebang: modules.includes('main') ? true : undefined })
1604
+ for (const name of published) {
1605
+ const source = readFileSync(join(directory, `${name}.ts`), 'utf8')
1606
+ const imported = [...source.matchAll(/from ["']@src\/([a-z][a-z0-9-]*)["']/gu)].flatMap(
1607
+ (match) => (match[1] === undefined ? [] : [match[1]]),
1608
+ )
1609
+ const code = readFileSync(join(output, `${name}.js`), 'utf8')
1610
+ // Each reading names its file, so a failure's diff states which output kept the alias. The
1611
+ // bundler and the extractor each choose their own quote, so a specifier is read without one.
1612
+ expect({
1613
+ file: `${name}.js`,
1614
+ alias: code.includes('@src/'),
1615
+ built: imported.every((environment) => code.includes(`../src/${environment}/index.js`)),
1616
+ shebang: code.startsWith('#!'),
1617
+ }).toStrictEqual({ file: `${name}.js`, alias: false, built: true, shebang: false })
1618
+ const typed = join(output, `${name}.d.ts`)
1619
+ const declaration = existsSync(typed) ? readFileSync(typed, 'utf8') : ''
1620
+ expect({
1621
+ file: `${name}.d.ts`,
1622
+ present: existsSync(typed),
1623
+ alias: declaration.includes('@src/'),
1624
+ built: imported.every((environment) =>
1625
+ declaration.includes(`../src/${environment}/index.js`),
1626
+ ),
1627
+ exported: declaration.includes('export default'),
1628
+ }).toStrictEqual({
1629
+ file: `${name}.d.ts`,
1630
+ present: true,
1631
+ alias: false,
1632
+ built: true,
1633
+ exported: true,
1634
+ })
1635
+ // The distribution scan refuses a module map that names no `src/bin/` source.
1636
+ const map = join(output, `${name}.js.map`)
1637
+ const parsed: unknown = existsSync(map) ? JSON.parse(readFileSync(map, 'utf8')) : undefined
1638
+ const sources: unknown =
1639
+ typeof parsed === 'object' && parsed !== null
1640
+ ? Object.getOwnPropertyDescriptor(parsed, 'sources')?.value
1641
+ : undefined
1642
+ const listed = Array.isArray(sources)
1643
+ ? sources.flatMap((entry: unknown) =>
1644
+ typeof entry === 'string'
1645
+ ? [relative(scratch.path, resolve(output, entry)).replaceAll('\\', '/')]
1646
+ : [],
1647
+ )
1648
+ : []
1649
+ expect({
1650
+ file: `${name}.js.map`,
1651
+ entry: listed.includes(`src/bin/${name}.ts`),
1652
+ }).toStrictEqual({ file: `${name}.js.map`, entry: true })
1653
+ const loaded = spawnSync(
1654
+ process.execPath,
1655
+ [
1656
+ '--input-type=module',
1657
+ '--eval',
1658
+ `const module = await import(${JSON.stringify(pathToFileURL(join(output, `${name}.js`)).href)})\nconst values = []\nfor (const href of ${JSON.stringify(imported.map((environment) => pathToFileURL(join(scratch.path, `dist/src/${environment}/index.js`)).href))}) values.push(...Object.values(await import(href)))\nprocess.stdout.write(JSON.stringify({ defined: module.default !== undefined, owned: values.includes(module.default) }))`,
1659
+ ],
1660
+ { encoding: 'utf8' },
1661
+ )
1662
+ expect({ file: `${name}.js`, status: loaded.status, stderr: loaded.stderr }).toStrictEqual({
1663
+ file: `${name}.js`,
1664
+ status: 0,
1665
+ stderr: '',
1666
+ })
1667
+ expect(JSON.parse(loaded.stdout)).toStrictEqual({ defined: true, owned: true })
1668
+ }
1647
1669
  } finally {
1648
1670
  scratch.destroy()
1649
1671
  }
@@ -4425,7 +4447,6 @@ createSomething({
4425
4447
  'src/server',
4426
4448
  'app/server',
4427
4449
  'src/bin',
4428
- 'src/reporter',
4429
4450
  ].flatMap((owner) => {
4430
4451
  const sheet = ['src/bootstrap', 'src/tailwindcss', 'src/styles'].includes(owner)
4431
4452
  const refused: ReadonlyArray<string | readonly [string, string]> = [
@@ -4472,13 +4493,11 @@ createSomething({
4472
4493
  ]),
4473
4494
  ]
4474
4495
  : []),
4475
- ...(['src/browser', 'src/server', 'src/vue', 'src/bin', 'src/reporter'].includes(owner)
4496
+ ...(['src/browser', 'src/server', 'src/vue', 'src/bin'].includes(owner)
4476
4497
  ? ['../core/index.js', '../../src/core/index.js']
4477
4498
  : []),
4478
4499
  ...(owner === 'src/vue' ? ['../browser/index.js', '../../src/browser/index.js'] : []),
4479
- ...(owner === 'src/bin' || owner === 'src/reporter'
4480
- ? ['../server/index.js', '../../src/server/index.js']
4481
- : []),
4500
+ ...(owner === 'src/bin' ? ['../server/index.js', '../../src/server/index.js'] : []),
4482
4501
  ]
4483
4502
  const admitted = [
4484
4503
  ...(owner.endsWith('/vue')
@@ -4498,10 +4517,10 @@ createSomething({
4498
4517
  : []),
4499
4518
  ]
4500
4519
  : ['@src/core']),
4501
- ...(['src/browser', 'src/server', 'src/vue', 'src/bin', 'src/reporter'].includes(owner)
4520
+ ...(['src/browser', 'src/server', 'src/vue', 'src/bin'].includes(owner)
4502
4521
  ? []
4503
4522
  : ['../core/index.js']),
4504
- ...(owner === 'src/bin' || owner === 'src/reporter' ? ['@src/server'] : []),
4523
+ ...(owner === 'src/bin' ? ['@src/server'] : []),
4505
4524
  ...(sheet
4506
4525
  ? [
4507
4526
  ...faces
@@ -4529,9 +4548,7 @@ createSomething({
4529
4548
  [
4530
4549
  ...admitted,
4531
4550
  './index.js',
4532
- ...(owner.endsWith('/server') || owner === 'src/bin' || owner === 'src/reporter'
4533
- ? ['node:fs']
4534
- : []),
4551
+ ...(owner.endsWith('/server') || owner === 'src/bin' ? ['node:fs'] : []),
4535
4552
  ],
4536
4553
  false,
4537
4554
  ],
@@ -4552,12 +4569,12 @@ createSomething({
4552
4569
  }),
4553
4570
  )
4554
4571
  }),
4555
- // The reporter entry itself, in the form a relative server import would take: only the
4572
+ // A bin module in the form a relative server import would take: only the
4556
4573
  // `@src/server` alias reaches `output.paths`, so this import would bundle a server copy.
4557
4574
  ...(
4558
4575
  [
4559
4576
  [
4560
- 'src/reporter/main.ts',
4577
+ 'src/bin/reporter.ts',
4561
4578
  "import { ProgressReporter } from '../server/index.js'\n\nexport default ProgressReporter\ndebugger\n",
4562
4579
  true,
4563
4580
  ],
@@ -4600,7 +4617,7 @@ createSomething({
4600
4617
  !files.some(
4601
4618
  (file: unknown) =>
4602
4619
  typeof file === 'string' &&
4603
- (file.startsWith('src/vue/') || file.startsWith('src/reporter/')),
4620
+ (file.startsWith('src/vue/') || file.startsWith('src/bin/')),
4604
4621
  )
4605
4622
  )
4606
4623
  continue
@@ -4637,7 +4654,7 @@ createSomething({
4637
4654
  expect(control).toContainEqual({ path: 'src/vue/refused3.ts', expected: true, actual: false })
4638
4655
  expect(control).toContainEqual({ path: 'src/vue/refused8.ts', expected: true, actual: false })
4639
4656
  expect(control).toContainEqual({
4640
- path: 'src/reporter/main.ts',
4657
+ path: 'src/bin/reporter.ts',
4641
4658
  expected: true,
4642
4659
  actual: false,
4643
4660
  })
@@ -4960,12 +4977,12 @@ createSomething({
4960
4977
  '}',
4961
4978
  ].join('\n'),
4962
4979
  )
4963
- // The default-export exemption names `src/reporter/main.ts` alone. The entry's `debugger`
4964
- // statement is its arrival control, and a sibling in its folder and a `main.ts` in another
4980
+ // The default-export exemption names the direct `src/bin` modules alone. The module's `debugger`
4981
+ // statement is its arrival control, and a server module and a `main.ts` in another
4965
4982
  // folder carry the same default export and must each still draw the rule.
4966
4983
  for (const path of [
4967
- 'src/reporter/main.ts',
4968
- 'src/reporter/helpers.ts',
4984
+ 'src/bin/reporter.ts',
4985
+ 'src/server/reporter.ts',
4969
4986
  'src/violations/main.ts',
4970
4987
  ]) {
4971
4988
  scratch.write(
@@ -5023,7 +5040,8 @@ createSomething({
5023
5040
  '--format',
5024
5041
  'json',
5025
5042
  'src/violations',
5026
- 'src/reporter',
5043
+ 'src/bin',
5044
+ 'src/server',
5027
5045
  'app',
5028
5046
  'scripts',
5029
5047
  'tests',
@@ -5137,16 +5155,24 @@ createSomething({
5137
5155
  `eslint(no-debugger) ${normalizePolicyFilename(comparisonRoot, 'scripts/read.ts')}`,
5138
5156
  )
5139
5157
  expect(violationCodes).toContain(
5140
- `eslint(no-debugger) ${normalizePolicyFilename(comparisonRoot, 'src/reporter/main.ts')}`,
5158
+ `eslint(no-debugger) ${normalizePolicyFilename(comparisonRoot, 'src/bin/reporter.ts')}`,
5141
5159
  )
5142
5160
  expect(violationCodes).not.toContain(
5143
- `import(no-default-export) ${normalizePolicyFilename(comparisonRoot, 'src/reporter/main.ts')}`,
5161
+ `import(no-default-export) ${normalizePolicyFilename(comparisonRoot, 'src/bin/reporter.ts')}`,
5144
5162
  )
5145
- // The entry's `@src/server` import is the form the reporter boundary admits.
5163
+ // The module's `@src/server` import is the form the `src/bin` boundary admits, and the
5164
+ // placement rules read a lowercase module beside `main.ts` as no misplaced file.
5146
5165
  expect(violationCodes).not.toContain(
5147
- `eslint(no-restricted-imports) ${normalizePolicyFilename(comparisonRoot, 'src/reporter/main.ts')}`,
5166
+ `eslint(no-restricted-imports) ${normalizePolicyFilename(comparisonRoot, 'src/bin/reporter.ts')}`,
5148
5167
  )
5149
- for (const path of ['src/reporter/helpers.ts', 'src/violations/main.ts']) {
5168
+ expect(
5169
+ violationCodes.filter(
5170
+ (code) =>
5171
+ code.startsWith('policy(') &&
5172
+ code.endsWith(` ${normalizePolicyFilename(comparisonRoot, 'src/bin/reporter.ts')}`),
5173
+ ),
5174
+ ).toStrictEqual([])
5175
+ for (const path of ['src/server/reporter.ts', 'src/violations/main.ts']) {
5150
5176
  expect(violationCodes).toContain(
5151
5177
  `import(no-default-export) ${normalizePolicyFilename(comparisonRoot, path)}`,
5152
5178
  )
@@ -5359,7 +5385,7 @@ describe('configuration helpers', () => {
5359
5385
  'readCompilerOutput',
5360
5386
  'resolveCompiler',
5361
5387
  'rewriteCoreSpecifier',
5362
- 'rewriteServerSpecifier',
5388
+ 'rewriteSourceSpecifier',
5363
5389
  'sourceFallback',
5364
5390
  'workspacePath',
5365
5391
  ]
@@ -5550,7 +5576,7 @@ describe('configuration helpers', () => {
5550
5576
  expect(fresh.building).toBe(false)
5551
5577
  expect(fresh.output).toBe(configHelpers.WORKSPACE_ROOT)
5552
5578
  expect(fresh.root).toBe(configHelpers.WORKSPACE_ROOT)
5553
- expect(fresh.source).toBe('')
5579
+ expect(fresh.entries).toStrictEqual({})
5554
5580
  expect(new configHelpers.BuildState('C:/output').output).toBe('C:/output')
5555
5581
 
5556
5582
  const entry = resolve(scratch.path, 'index.ts')
@@ -5565,13 +5591,34 @@ describe('configuration helpers', () => {
5565
5591
  expect(buildState.building).toBe(true)
5566
5592
  expect(buildState.output).toBe(resolve(scratch.path, 'out'))
5567
5593
  expect(buildState.root).toBe(realpathSync.native(scratch.path))
5568
- expect(buildState.source).toBe(entry)
5594
+ expect(buildState.entries).toStrictEqual({ index: entry })
5595
+ // A named entry map keeps its names; a list names each member by its file's stem.
5596
+ const tool = resolve(scratch.path, 'reporter.ts')
5597
+ const named = new configHelpers.BuildState()
5598
+ named.resolve(
5599
+ await resolveConfig(
5600
+ {
5601
+ ...inline,
5602
+ build: { outDir: 'out', lib: { entry: { main: entry, tool }, formats: ['es'] } },
5603
+ },
5604
+ 'build',
5605
+ ),
5606
+ )
5607
+ expect(named.entries).toStrictEqual({ main: entry, tool })
5608
+ const listed = new configHelpers.BuildState()
5609
+ listed.resolve(
5610
+ await resolveConfig(
5611
+ { ...inline, build: { outDir: 'out', lib: { entry: [entry, tool], formats: ['es'] } } },
5612
+ 'build',
5613
+ ),
5614
+ )
5615
+ expect(listed.entries).toStrictEqual({ index: entry, reporter: tool })
5569
5616
 
5570
5617
  // The control: a serve command is not a build, and a config with no library entry has no source.
5571
5618
  const serveState = new configHelpers.BuildState()
5572
5619
  serveState.resolve(await resolveConfig({ ...inline, build: { outDir: 'out' } }, 'serve'))
5573
5620
  expect(serveState.building).toBe(false)
5574
- expect(serveState.source).toBe('')
5621
+ expect(serveState.entries).toStrictEqual({})
5575
5622
  } finally {
5576
5623
  scratch.destroy()
5577
5624
  }
@@ -5605,11 +5652,11 @@ describe('configuration helpers', () => {
5605
5652
  expect(Object.getOwnPropertyNames(configHelpers.BuildState.prototype).sort()).toEqual([
5606
5653
  'building',
5607
5654
  'constructor',
5655
+ 'entries',
5608
5656
  'locate',
5609
5657
  'output',
5610
5658
  'resolve',
5611
5659
  'root',
5612
- 'source',
5613
5660
  'trust',
5614
5661
  ])
5615
5662
  } finally {
@@ -5953,10 +6000,17 @@ describe('configuration helpers', () => {
5953
6000
  `from '${name}/browser'`,
5954
6001
  )
5955
6002
  expect(configHelpers.rewriteBrowserSpecifier("from './sibling.js'")).toBe("from './sibling.js'")
5956
- expect(configHelpers.rewriteServerSpecifier("import { Reporter } from '@src/server'")).toBe(
5957
- "import { Reporter } from '../src/server/index.js'",
6003
+ expect(
6004
+ configHelpers.rewriteSourceSpecifier(
6005
+ 'import { Reporter } from \'@src/server\'\nimport type { Shape } from "@src/core"',
6006
+ ),
6007
+ ).toBe(
6008
+ 'import { Reporter } from \'../src/server/index.js\'\nimport type { Shape } from "../src/core/index.js"',
6009
+ )
6010
+ // A specifier past the environment, and a mention outside quotes, are no environment alias.
6011
+ expect(configHelpers.rewriteSourceSpecifier("from '@src/core/types.js' // @src/server")).toBe(
6012
+ "from '@src/core/types.js' // @src/server",
5958
6013
  )
5959
- expect(configHelpers.rewriteServerSpecifier("from '@src/core'")).toBe("from '@src/core'")
5960
6014
 
5961
6015
  // The mechanism the roll-up proof's skip reads: an absent package rejects resolution.
5962
6016
  expect(() => createRequire(import.meta.url).resolve('@absent/declaration-extractor')).toThrow(