@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
@@ -19,14 +19,19 @@ import {
19
19
  rmSync,
20
20
  writeFileSync,
21
21
  } from 'node:fs'
22
- import { dirname, isAbsolute, join, relative, resolve as resolvePath, sep } from 'node:path'
22
+ import {
23
+ basename,
24
+ dirname,
25
+ extname,
26
+ isAbsolute,
27
+ join,
28
+ relative,
29
+ resolve as resolvePath,
30
+ sep,
31
+ } from 'node:path'
23
32
 
24
33
  export function hasASCIIURLControl(value: string): boolean {
25
- for (const character of value) {
26
- const code = character.codePointAt(0)
27
- if (code !== undefined && (code <= 0x1f || code === 0x7f)) return true
28
- }
29
- return false
34
+ return /[\p{Cc}--[\u0080-\u009f]]/v.test(value)
30
35
  }
31
36
 
32
37
  /**
@@ -372,7 +377,7 @@ export function findPackageDirectory(current: string): string | undefined {
372
377
  export function packageRootOf(packageName: string, resolvedPath: string): string | undefined {
373
378
  const physical = physicalPath(resolvedPath)
374
379
  const directory = findPackageDirectory(
375
- existsSync(physical) && lstatSync(physical).isDirectory() ? physical : dirname(physical),
380
+ lstatSync(physical, { throwIfNoEntry: false })?.isDirectory() ? physical : dirname(physical),
376
381
  )
377
382
  return directory !== undefined && packageManifestName(directory) === packageName
378
383
  ? realpathSync.native(directory)
@@ -382,7 +387,7 @@ export function packageRootOf(packageName: string, resolvedPath: string): string
382
387
  export function packageRootForResolved(resolvedPath: string): string | undefined {
383
388
  const physical = physicalPath(resolvedPath)
384
389
  const directory = findPackageDirectory(
385
- existsSync(physical) && lstatSync(physical).isDirectory() ? physical : dirname(physical),
390
+ lstatSync(physical, { throwIfNoEntry: false })?.isDirectory() ? physical : dirname(physical),
386
391
  )
387
392
  return directory !== undefined && packageManifestName(directory) !== undefined
388
393
  ? realpathSync.native(directory)
@@ -518,7 +523,7 @@ export class BuildState {
518
523
  #building = false
519
524
  #output: string
520
525
  #root = WORKSPACE_ROOT
521
- #source = ''
526
+ #entries: Readonly<Record<string, string>> = {}
522
527
  readonly #trusted = new Set<string>()
523
528
 
524
529
  constructor(output = WORKSPACE_ROOT) {
@@ -540,9 +545,9 @@ export class BuildState {
540
545
  return this.#root
541
546
  }
542
547
 
543
- /** The library entry path, or an empty string when the build has none. */
544
- get source(): string {
545
- return this.#source
548
+ /** The library entry paths by entry name, empty when the build has none. */
549
+ get entries(): Readonly<Record<string, string>> {
550
+ return this.#entries
546
551
  }
547
552
 
548
553
  /**
@@ -567,7 +572,10 @@ export class BuildState {
567
572
  }
568
573
 
569
574
  /**
570
- * Reads the command, output directory, project root, and library entry from a resolved config.
575
+ * Reads the command, output directory, project root, and library entries from a resolved config.
576
+ *
577
+ * @remarks
578
+ * A single-path entry and each member of an entry list take their file's stem as their name.
571
579
  *
572
580
  * @param config - The resolved Vite configuration.
573
581
  */
@@ -575,10 +583,11 @@ export class BuildState {
575
583
  this.#building = config.command === 'build'
576
584
  this.#output = resolvePath(config.root, config.build.outDir)
577
585
  this.#root = physicalPath(config.root)
578
- this.#source =
579
- config.build.lib !== false && typeof config.build.lib.entry === 'string'
580
- ? config.build.lib.entry
581
- : ''
586
+ const entry = config.build.lib === false ? {} : config.build.lib.entry
587
+ this.#entries =
588
+ typeof entry === 'string' || Array.isArray(entry)
589
+ ? Object.fromEntries([entry].flat().map((path) => [basename(path, extname(path)), path]))
590
+ : { ...entry }
582
591
  }
583
592
  }
584
593
 
@@ -692,13 +701,15 @@ export interface ExtractorModule {
692
701
  *
693
702
  * @remarks
694
703
  * `project` is the absolute path of that face's TypeScript project file. `types` overrides the
695
- * `types` the extractor's own program reads, and defaults to the face's resolved `types`. `rewrite`
696
- * receives the finished roll-up and returns what the face ships; a face that omits it ships the
697
- * roll-up as the extractor wrote it.
704
+ * `types` the extractor's own program reads, and defaults to the face's resolved `types`. `entries`
705
+ * names the library entries that roll up, and defaults to every entry the build declares; a
706
+ * single-path entry takes its file's stem as its name. `rewrite` receives each finished roll-up and
707
+ * returns what the face ships; a face that omits it ships the roll-up as the extractor wrote it.
698
708
  */
699
709
  export interface DeclarationRollupOptions {
700
710
  readonly project: string
701
711
  readonly types?: readonly string[]
712
+ readonly entries?: readonly string[]
702
713
  readonly rewrite?: (content: string) => string
703
714
  }
704
715
 
@@ -874,7 +885,28 @@ export function rewriteBrowserSpecifier(content: string): string {
874
885
  }
875
886
 
876
887
  /**
877
- * Rolls one published face's declarations into the single file that face ships.
888
+ * Rewrites every source environment alias in a roll-up to the built environment beside `dist/bin`.
889
+ *
890
+ * @param content - The finished roll-up.
891
+ * @returns That roll-up with each `@src/<environment>` specifier replaced by
892
+ * `../src/<environment>/index.js`.
893
+ *
894
+ * @remarks
895
+ * A `src/bin` module reaches a library environment through its `@src/*` alias, and the extractor
896
+ * keeps the alias external and writes it through unchanged. `dist/bin/<name>.d.ts` resolves the
897
+ * environment's declarations at the relative path its `<name>.js` imports through `output.paths`.
898
+ *
899
+ * @example
900
+ * ```ts
901
+ * rewriteSourceSpecifier("from '@src/server'") // "from '../src/server/index.js'"
902
+ * ```
903
+ */
904
+ export function rewriteSourceSpecifier(content: string): string {
905
+ return content.replaceAll(/@src\/([a-z][a-z0-9-]*)(?=['"])/gu, '../src/$1/index.js')
906
+ }
907
+
908
+ /**
909
+ * Rolls each named library entry's declarations into the single file that entry ships.
878
910
  *
879
911
  * @param options - The face's roll-up options.
880
912
  * @returns The Vite plugin that performs that roll-up.
@@ -882,13 +914,15 @@ export function rewriteBrowserSpecifier(content: string): string {
882
914
  * @remarks
883
915
  * At `closeBundle`, after Vite has written every format of the face, the plugin emits the face's
884
916
  * declarations with the workspace compiler run as a process into a scratch directory made fresh
885
- * under the host temporary directory, hands the emitted entry to the extractor's own engine,
886
- * applies `rewrite`, and removes the scratch directory. Keeping the scratch outside the face's own
887
- * output means its unconditional removal can never take a sibling the face already published, such
888
- * as its own `declarations` folder. The extractor is a publishing workspace's development
889
- * dependency, so this vendored leaf defers loading it to that hook: a workspace that publishes no
890
- * library installs no extractor, never reaches the hook, and never resolves the package at build
891
- * or at check.
917
+ * under the host temporary directory, hands each named entry to the extractor's own engine,
918
+ * applies `rewrite`, and removes the scratch directory. Each roll-up takes its entry's name, so
919
+ * an `index.ts` face ships `index.d.ts` and a `reporter` entry ships `reporter.d.ts`. An empty
920
+ * `entries` list rolls up nothing. Keeping the
921
+ * scratch outside the face's own output means its unconditional removal can never take a sibling
922
+ * the face already published, such as its own `declarations` folder. The extractor is a publishing
923
+ * workspace's development dependency, so this vendored leaf defers loading it to that hook: a
924
+ * workspace that publishes no library installs no extractor, never reaches the hook, and never
925
+ * resolves the package at build or at check.
892
926
  */
893
927
  export function declarationRollup(options: DeclarationRollupOptions): Plugin {
894
928
  const state = new BuildState()
@@ -899,12 +933,20 @@ export function declarationRollup(options: DeclarationRollupOptions): Plugin {
899
933
  },
900
934
  closeBundle() {
901
935
  if (!state.building) return
902
- const declaration = state.source.replace(/\.tsx?$/, '.d.ts')
903
- if (declaration === state.source) {
936
+ const named = options.entries ?? Object.keys(state.entries)
937
+ const declarations = named.map((name) => {
938
+ const source = state.entries[name] ?? ''
939
+ return { name, source, declaration: source.replace(/\.tsx?$/, '.d.ts') }
940
+ })
941
+ if (
942
+ (options.entries === undefined && declarations.length === 0) ||
943
+ declarations.some(({ source, declaration }) => declaration === source)
944
+ ) {
904
945
  throw new Error(
905
- '[orkestrel-declaration-rollup] The face must build one TypeScript library entry',
946
+ '[orkestrel-declaration-rollup] The face must build each named TypeScript library entry',
906
947
  )
907
948
  }
949
+ if (declarations.length === 0) return
908
950
  const load = createRequire(import.meta.url)
909
951
  const compiler = resolveCompiler(import.meta.url)
910
952
  const scope = parseProjectScope(
@@ -917,7 +959,6 @@ export function declarationRollup(options: DeclarationRollupOptions): Plugin {
917
959
  )
918
960
  }
919
961
  const scratch = mkdtempSync(join(tmpdir(), 'orkestrel-declarations-'))
920
- const rollup = resolvePath(state.output, 'index.d.ts')
921
962
  try {
922
963
  readCompilerOutput(compiler, [
923
964
  '-p',
@@ -929,7 +970,6 @@ export function declarationRollup(options: DeclarationRollupOptions): Plugin {
929
970
  '--outDir',
930
971
  scratch,
931
972
  ])
932
- const entry = resolvePath(scratch, relative(scope.root, declaration))
933
973
  // A literal `import()` of the extractor reddens `tsc` in a workspace that does not
934
974
  // install it, so the literal `createRequire` call is the form that clears the
935
975
  // typecheck in an app-only workspace.
@@ -939,45 +979,51 @@ export function declarationRollup(options: DeclarationRollupOptions): Plugin {
939
979
  '[orkestrel-declaration-rollup] The declaration extractor exposes no entry point',
940
980
  )
941
981
  }
942
- const prepared: unknown = loaded.ExtractorConfig.prepare({
943
- configObject: {
944
- projectFolder: WORKSPACE_ROOT,
945
- mainEntryPointFilePath: entry,
946
- bundledPackages: [],
947
- compiler: {
948
- overrideTsconfig: buildExtractorOverride(
949
- entry,
950
- scope.lib,
951
- options.types ?? scope.types,
952
- ),
953
- },
954
- apiReport: { enabled: false },
955
- docModel: { enabled: false },
956
- tsdocMetadata: { enabled: false },
957
- dtsRollup: { enabled: true, untrimmedFilePath: rollup },
958
- messages: {
959
- compilerMessageReporting: { default: { logLevel: 'none' } },
960
- extractorMessageReporting: { default: { logLevel: 'none' } },
961
- tsdocMessageReporting: { default: { logLevel: 'none' } },
982
+ for (const { name, declaration } of declarations) {
983
+ const entry = resolvePath(scratch, relative(scope.root, declaration))
984
+ const rollup = resolvePath(state.output, `${name}.d.ts`)
985
+ const prepared: unknown = loaded.ExtractorConfig.prepare({
986
+ configObject: {
987
+ projectFolder: WORKSPACE_ROOT,
988
+ mainEntryPointFilePath: entry,
989
+ bundledPackages: [],
990
+ compiler: {
991
+ overrideTsconfig: buildExtractorOverride(
992
+ entry,
993
+ scope.lib,
994
+ options.types ?? scope.types,
995
+ ),
996
+ },
997
+ apiReport: { enabled: false },
998
+ docModel: { enabled: false },
999
+ tsdocMetadata: { enabled: false },
1000
+ dtsRollup: { enabled: true, untrimmedFilePath: rollup },
1001
+ messages: {
1002
+ compilerMessageReporting: { default: { logLevel: 'none' } },
1003
+ extractorMessageReporting: { default: { logLevel: 'none' } },
1004
+ tsdocMessageReporting: { default: { logLevel: 'none' } },
1005
+ },
962
1006
  },
963
- },
964
- configObjectFullPath: resolvePath(WORKSPACE_ROOT, 'api-extractor.json'),
965
- packageJsonFullPath: resolvePath(WORKSPACE_ROOT, 'package.json'),
966
- })
967
- const outcome: unknown = loaded.Extractor.invoke(prepared, {
968
- localBuild: true,
969
- showVerboseMessages: false,
970
- showDiagnostics: false,
971
- })
972
- const succeeded: unknown =
973
- typeof outcome === 'object' && outcome !== null
974
- ? Reflect.get(outcome, 'succeeded')
975
- : undefined
976
- if (succeeded !== true) {
977
- throw new Error('[orkestrel-declaration-rollup] The declaration roll-up failed')
978
- }
979
- if (options.rewrite !== undefined) {
980
- writeFileSync(rollup, options.rewrite(readFileSync(rollup, 'utf8')), 'utf8')
1007
+ configObjectFullPath: resolvePath(WORKSPACE_ROOT, 'api-extractor.json'),
1008
+ packageJsonFullPath: resolvePath(WORKSPACE_ROOT, 'package.json'),
1009
+ })
1010
+ const outcome: unknown = loaded.Extractor.invoke(prepared, {
1011
+ localBuild: true,
1012
+ showVerboseMessages: false,
1013
+ showDiagnostics: false,
1014
+ })
1015
+ const succeeded: unknown =
1016
+ typeof outcome === 'object' && outcome !== null
1017
+ ? Reflect.get(outcome, 'succeeded')
1018
+ : undefined
1019
+ if (succeeded !== true) {
1020
+ throw new Error(
1021
+ `[orkestrel-declaration-rollup] The declaration roll-up of ${name} failed`,
1022
+ )
1023
+ }
1024
+ if (options.rewrite !== undefined) {
1025
+ writeFileSync(rollup, options.rewrite(readFileSync(rollup, 'utf8')), 'utf8')
1026
+ }
981
1027
  }
982
1028
  } finally {
983
1029
  rmSync(scratch, { recursive: true, force: true })
@@ -88,6 +88,12 @@
88
88
  "import/no-default-export": "off"
89
89
  }
90
90
  },
91
+ {
92
+ "files": ["src/bin/*.ts"],
93
+ "rules": {
94
+ "import/no-default-export": "off"
95
+ }
96
+ },
91
97
  {
92
98
  "files": [".agents/skills/*/scripts/*.ts"],
93
99
  "rules": {