@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
@@ -6,6 +6,7 @@ import type {
6
6
  PolicyExpression,
7
7
  PolicyScopeCode,
8
8
  } from '../configs/policy.js'
9
+ import { isRecord } from '@orkestrel/contract'
9
10
  import {
10
11
  createGuide,
11
12
  extractSourceLines,
@@ -159,6 +160,20 @@ export function createPolicySurfaceGuide(names: readonly string[]): string {
159
160
  ].join('\n')
160
161
  }
161
162
 
163
+ /**
164
+ * Describes the refusal for a name that two packages claim, with the owner's import.
165
+ *
166
+ * @param name - The colliding bare name.
167
+ * @param owner - The package that owns the name, without its scope.
168
+ * @returns The refusal text that names the owner's import and the reuse-before-renaming rule.
169
+ */
170
+ export function describeSurfaceCollision(name: string, owner: string): string {
171
+ const subject = JSON.stringify(name.slice(0, 512)).slice(1, -1)
172
+ const label = JSON.stringify(owner.slice(0, 512)).slice(1, -1)
173
+ const specifier = JSON.stringify(`@orkestrel/${owner.slice(0, 512)}`)
174
+ return `surface name belongs to one package: ${subject} (${label}). Where the local declaration carries the owner's contract, delete it and import the owner's: import { ${subject} } from ${specifier}, or from the owner's environment entry that exports it. Rename the local declaration only when its contract differs from the owner's, and name it for the thing it is.`
175
+ }
176
+
162
177
  /**
163
178
  * Writes a complete hosted reference population for a physical policy control.
164
179
  *
@@ -637,7 +652,8 @@ export const POLICY_LAZY_CASES: readonly PolicyLazyCase[] = Object.freeze([
637
652
  [POLICY_LAZY_SHAPES.hole, 'return []', [1]],
638
653
  [POLICY_LAZY_SHAPES.holeFailure, 'throw RangeError', [1]],
639
654
  [POLICY_LAZY_SHAPES.failureFirst, 'throw RangeError', [0]],
640
- [POLICY_LAZY_SHAPES.refusalFirst, 'throw TypeError', [0]],
655
+ // `isRecord` reports a revoked proxy as no record instead of throwing, so the reader skips it.
656
+ [POLICY_LAZY_SHAPES.refusalFirst, 'return []', [0, 1]],
641
657
  [POLICY_LAZY_SHAPES.holeBetween, 'return []', [0, 2]],
642
658
  [POLICY_LAZY_SHAPES.unlisted, 'throw TypeError', []],
643
659
  ],
@@ -656,7 +672,8 @@ export const POLICY_LAZY_CASES: readonly PolicyLazyCase[] = Object.freeze([
656
672
  [POLICY_LAZY_SHAPES.hole, 'return ["override entries must be records"]', [1]],
657
673
  [POLICY_LAZY_SHAPES.holeFailure, 'throw RangeError', [1]],
658
674
  [POLICY_LAZY_SHAPES.failureFirst, 'throw RangeError', [0]],
659
- [POLICY_LAZY_SHAPES.refusalFirst, 'throw TypeError', [0]],
675
+ // `isRecord` reports a revoked proxy as no record instead of throwing, so the reader refuses it.
676
+ [POLICY_LAZY_SHAPES.refusalFirst, 'return ["override entries must be records"]', [0, 1]],
660
677
  [POLICY_LAZY_SHAPES.holeBetween, 'return ["override entries must be records"]', [0, 2]],
661
678
  [POLICY_LAZY_SHAPES.unlisted, 'throw TypeError', []],
662
679
  ],
@@ -1146,14 +1163,6 @@ export function normalizePolicyFilename(root: string, filename: string): string
1146
1163
  return normalizePolicyPath(relativePath(base, path))
1147
1164
  }
1148
1165
 
1149
- /**
1150
- * Reports whether a parsed configuration value is a plain record rather than an array or a
1151
- * primitive.
1152
- */
1153
- export function isPolicyRecord(value: unknown): value is Readonly<Record<string, unknown>> {
1154
- return typeof value === 'object' && value !== null && !Array.isArray(value)
1155
- }
1156
-
1157
1166
  /**
1158
1167
  * Parses JSON text without throwing.
1159
1168
  *
@@ -1309,7 +1318,7 @@ export function matchesScaffoldSetup(path: string, root: string): boolean {
1309
1318
  const manifest = readPolicyJSON(join(root, 'package.json'))
1310
1319
  return (
1311
1320
  (normalized === DISTRIBUTION_SETUP_PATH &&
1312
- (!isPolicyRecord(manifest) || manifest.private !== true)) ||
1321
+ (!isRecord(manifest) || manifest.private !== true)) ||
1313
1322
  HOST_PATHS.some(
1314
1323
  (vendored) =>
1315
1324
  normalized === normalizePolicyPath(vendored) ||
@@ -1539,7 +1548,7 @@ export function inspectPolicyText(root: string): readonly PolicyViolation[] {
1539
1548
  */
1540
1549
  export function collectPolicyOverrideSegments(overrides: unknown): readonly string[] {
1541
1550
  return (Array.isArray(overrides) ? overrides : []).flatMap((override: unknown) => {
1542
- const files: unknown = isPolicyRecord(override)
1551
+ const files: unknown = isRecord(override)
1543
1552
  ? Object.getOwnPropertyDescriptor(override, 'files')?.value
1544
1553
  : undefined
1545
1554
  return (Array.isArray(files) ? files : []).flatMap((glob: unknown) =>
@@ -1592,7 +1601,7 @@ export function isPolicyIgnoreReaching(pattern: string, overrides: unknown): boo
1592
1601
  * @returns Every wiring violation in rule and configuration order.
1593
1602
  */
1594
1603
  export function inspectPolicyConfiguration(configuration: unknown): readonly string[] {
1595
- if (!isPolicyRecord(configuration)) {
1604
+ if (!isRecord(configuration)) {
1596
1605
  return ['Oxlint configuration must be a record']
1597
1606
  }
1598
1607
 
@@ -1604,7 +1613,7 @@ export function inspectPolicyConfiguration(configuration: unknown): readonly str
1604
1613
  const overrides: unknown = Object.getOwnPropertyDescriptor(configuration, 'overrides')?.value
1605
1614
  return [
1606
1615
  ...Object.entries(POLICY_WIRING_SETTINGS).flatMap(([rule, declared]) => {
1607
- const setting = isPolicyRecord(rules)
1616
+ const setting = isRecord(rules)
1608
1617
  ? Object.getOwnPropertyDescriptor(rules, rule)?.value
1609
1618
  : undefined
1610
1619
  return isDeepStrictEqual(setting, declared)
@@ -1627,9 +1636,9 @@ export function inspectPolicyConfiguration(configuration: unknown): readonly str
1627
1636
  // was in the loop, and no entry after a failing one is read.
1628
1637
  Iterator.from(Array.isArray(overrides) ? overrides : [])
1629
1638
  .flatMap((override) => {
1630
- if (!isPolicyRecord(override)) return ['override entries must be records']
1639
+ if (!isRecord(override)) return ['override entries must be records']
1631
1640
  const overrideRules: unknown = Object.getOwnPropertyDescriptor(override, 'rules')?.value
1632
- return isPolicyRecord(overrideRules)
1641
+ return isRecord(overrideRules)
1633
1642
  ? POLICY_WIRING_RULES.flatMap((rule) =>
1634
1643
  Object.getOwnPropertyDescriptor(overrideRules, rule) === undefined
1635
1644
  ? []
@@ -1654,7 +1663,7 @@ export function inspectPolicyWiring(
1654
1663
  rules: readonly string[],
1655
1664
  populations: ReadonlyArray<readonly string[]>,
1656
1665
  ): readonly string[] {
1657
- if (!isPolicyRecord(configuration)) {
1666
+ if (!isRecord(configuration)) {
1658
1667
  return ['Oxlint configuration must be a record']
1659
1668
  }
1660
1669
 
@@ -1664,7 +1673,7 @@ export function inspectPolicyWiring(
1664
1673
  // `undefined` and no entry after a failing one is read, as in the loops these replaced.
1665
1674
  const entries = Iterator.from(Array.isArray(overrides) ? overrides : [])
1666
1675
  .flatMap((entry) => {
1667
- if (!isPolicyRecord(entry)) return []
1676
+ if (!isRecord(entry)) return []
1668
1677
  const record: unknown = Object.getOwnPropertyDescriptor(entry, 'rules')?.value
1669
1678
  const files: unknown = Object.getOwnPropertyDescriptor(entry, 'files')?.value
1670
1679
  return [{ record, declared: Array.isArray(files) ? [files.join(' ')] : [] }]
@@ -1673,7 +1682,7 @@ export function inspectPolicyWiring(
1673
1682
  // A name enables its rule only at error severity: the string, or the first member of an array.
1674
1683
  const enabled = new Set(
1675
1684
  [topRules, ...entries.map(({ record }) => record)].flatMap((record) =>
1676
- isPolicyRecord(record)
1685
+ isRecord(record)
1677
1686
  ? Object.getOwnPropertyNames(record).filter((name) => {
1678
1687
  const setting = Object.getOwnPropertyDescriptor(record, name)?.value
1679
1688
  return (Array.isArray(setting) ? setting[0] : setting) === 'error'
@@ -2115,13 +2124,13 @@ export function readSkillExports(root: string, specifier: string): SkillDeclarat
2115
2124
  const segments = specifier.split('/')
2116
2125
  const key = segments.length === 2 ? '.' : `./${segments.slice(2).join('/')}`
2117
2126
  const own = readSkillManifest(root)
2118
- const owned = isPolicyRecord(own) && own['name'] === segments.slice(0, 2).join('/')
2127
+ const owned = isRecord(own) && own['name'] === segments.slice(0, 2).join('/')
2119
2128
  const directory = owned ? root : join(root, 'node_modules', ...segments.slice(0, 2))
2120
2129
  const manifest = owned ? own : readSkillManifest(directory)
2121
- if (!isPolicyRecord(manifest)) return { outcome: 'package', names: [] }
2130
+ if (!isRecord(manifest)) return { outcome: 'package', names: [] }
2122
2131
  const exports = manifest['exports']
2123
2132
  const target = resolveSkillDeclaration(
2124
- isPolicyRecord(exports) && Object.keys(exports).some((name) => name.startsWith('.'))
2133
+ isRecord(exports) && Object.keys(exports).some((name) => name.startsWith('.'))
2125
2134
  ? exports[key]
2126
2135
  : key === '.'
2127
2136
  ? exports
@@ -2140,7 +2149,7 @@ export function readSkillExports(root: string, specifier: string): SkillDeclarat
2140
2149
  */
2141
2150
  export function resolveSkillDeclaration(target: unknown): string | undefined {
2142
2151
  if (typeof target === 'string') return /\.d\.(?:ts|mts|cts)$/u.test(target) ? target : undefined
2143
- if (!isPolicyRecord(target)) return undefined
2152
+ if (!isRecord(target)) return undefined
2144
2153
  for (const condition of ['types', 'import', 'default']) {
2145
2154
  if (Object.hasOwn(target, condition)) return resolveSkillDeclaration(target[condition])
2146
2155
  }
@@ -2506,7 +2515,7 @@ export function inspectSkillImports(
2506
2515
  * @returns The literal specifier, or `undefined` when the source is computed.
2507
2516
  */
2508
2517
  export function readPolicyLiteral(source: unknown): string | undefined {
2509
- if (!isPolicyRecord(source)) return undefined
2518
+ if (!isRecord(source)) return undefined
2510
2519
  const value: unknown = Object.getOwnPropertyDescriptor(source, 'value')?.value
2511
2520
  if (typeof value === 'string') return value
2512
2521
  const expressions: unknown = Object.getOwnPropertyDescriptor(source, 'expressions')?.value
@@ -2521,10 +2530,10 @@ export function readPolicyLiteral(source: unknown): string | undefined {
2521
2530
  return undefined
2522
2531
  }
2523
2532
  const [quasi]: readonly unknown[] = quasis
2524
- const text: unknown = isPolicyRecord(quasi)
2533
+ const text: unknown = isRecord(quasi)
2525
2534
  ? Object.getOwnPropertyDescriptor(quasi, 'value')?.value
2526
2535
  : undefined
2527
- const cooked: unknown = isPolicyRecord(text)
2536
+ const cooked: unknown = isRecord(text)
2528
2537
  ? Object.getOwnPropertyDescriptor(text, 'cooked')?.value
2529
2538
  : undefined
2530
2539
  return typeof cooked === 'string' ? cooked : undefined
@@ -2543,7 +2552,7 @@ export function readPolicyLiteral(source: unknown): string | undefined {
2543
2552
  */
2544
2553
  export function collectPolicySpecifiers(node: unknown): readonly string[] {
2545
2554
  if (Array.isArray(node)) return node.flatMap((child: unknown) => collectPolicySpecifiers(child))
2546
- if (!isPolicyRecord(node)) return []
2555
+ if (!isRecord(node)) return []
2547
2556
  const type: unknown = Object.getOwnPropertyDescriptor(node, 'type')?.value
2548
2557
  const value = readPolicyLiteral(Object.getOwnPropertyDescriptor(node, 'source')?.value)
2549
2558
  return [
@@ -3218,9 +3227,9 @@ export function inspectPolicyFilenames(root: string): readonly PolicyViolation[]
3218
3227
  */
3219
3228
  export function parsePolicyScripts(content: string): ReadonlyMap<string, string> {
3220
3229
  const manifest = parsePolicyJSON(content)
3221
- if (!isPolicyRecord(manifest)) return new Map()
3230
+ if (!isRecord(manifest)) return new Map()
3222
3231
  const record: unknown = Object.getOwnPropertyDescriptor(manifest, 'scripts')?.value
3223
- if (!isPolicyRecord(record)) return new Map()
3232
+ if (!isRecord(record)) return new Map()
3224
3233
  return new Map(
3225
3234
  Object.getOwnPropertyNames(record).flatMap((name): Array<[string, string]> => {
3226
3235
  const command: unknown = Object.getOwnPropertyDescriptor(record, name)?.value
@@ -3335,7 +3344,7 @@ export function readPolicyProse(root: string): readonly string[] {
3335
3344
  export function readPolicyPackage(root: string): string | undefined {
3336
3345
  if (!isPolicyFile(root, POLICY_MANIFEST_FILE)) return undefined
3337
3346
  const manifest = readPolicyJSON(join(root, POLICY_MANIFEST_FILE))
3338
- if (!isPolicyRecord(manifest)) return undefined
3347
+ if (!isRecord(manifest)) return undefined
3339
3348
  const name: unknown = Object.getOwnPropertyDescriptor(manifest, 'name')?.value
3340
3349
  if (typeof name !== 'string') return undefined
3341
3350
  return name.slice(name.lastIndexOf('/') + 1)
@@ -3856,7 +3865,7 @@ export function inspectPolicySurface(root: string): readonly PolicyViolation[] {
3856
3865
  createPolicyViolation(
3857
3866
  'surface',
3858
3867
  declaration.path,
3859
- `surface name belongs to one package: ${declaration.name} (${owner})`,
3868
+ describeSurfaceCollision(declaration.name, owner),
3860
3869
  declaration.line,
3861
3870
  ),
3862
3871
  ),
@@ -4532,8 +4541,7 @@ export const SKILL_POLICY_CONTROLS: readonly PolicyControl[] = Object.freeze([
4532
4541
  files: [
4533
4542
  {
4534
4543
  path: '.agents/skills/sample/SKILL.md',
4535
- content:
4536
- SKILL_POLICY_TEXT + '\n```ts\nimport { isString } from "@orkestrel/contract"\n```\n',
4544
+ content: SKILL_POLICY_TEXT + '\n```ts\nimport { Logger } from "@orkestrel/console"\n```\n',
4537
4545
  },
4538
4546
  { path: '.agents/skills/sample/agents/openai.yaml', content: createSkillMetadata('sample') },
4539
4547
  ],
@@ -4542,7 +4550,7 @@ export const SKILL_POLICY_CONTROLS: readonly PolicyControl[] = Object.freeze([
4542
4550
  rule: 'skill',
4543
4551
  path: '.agents/skills/sample/SKILL.md',
4544
4552
  message:
4545
- 'skill fence import @orkestrel/contract is outside BASE_DEV_DEPENDENCIES: @orkestrel/contract',
4553
+ 'skill fence import @orkestrel/console is outside BASE_DEV_DEPENDENCIES: @orkestrel/console',
4546
4554
  },
4547
4555
  ],
4548
4556
  },
@@ -5946,8 +5954,7 @@ export function collectFrameworks(directory: string): readonly string[] {
5946
5954
  * @returns The record's own entries; throws for a non-record.
5947
5955
  */
5948
5956
  export function readConfigRecord(value: unknown): Readonly<Record<string, unknown>> {
5949
- if (typeof value !== 'object' || value === null || Array.isArray(value))
5950
- throw new Error('Expected a configuration record')
5957
+ if (!isRecord(value)) throw new Error('Expected a configuration record')
5951
5958
  return Object.fromEntries(Object.entries(value))
5952
5959
  }
5953
5960