@bastani/atomic 0.9.20-alpha.4 → 0.9.20-alpha.5

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 (245) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/intercom/skills/intercom/SKILL.md +32 -1
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  7. package/dist/builtin/subagents/README.md +2 -0
  8. package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
  9. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  10. package/dist/builtin/subagents/agents/codebase-online-researcher.md +3 -3
  11. package/dist/builtin/subagents/agents/debugger.md +7 -5
  12. package/dist/builtin/subagents/agents/worker.md +4 -2
  13. package/dist/builtin/subagents/package.json +1 -1
  14. package/dist/builtin/subagents/skills/agent-browser/SKILL.md +56 -0
  15. package/dist/builtin/subagents/skills/subagent/SKILL.md +32 -8
  16. package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -4
  17. package/dist/builtin/web-access/package.json +1 -1
  18. package/dist/builtin/workflows/CHANGELOG.md +30 -0
  19. package/dist/builtin/workflows/README.md +4 -2
  20. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  21. package/dist/builtin/workflows/builtin/{chunk-n8g2da69.js → chunk-00ywx588.js} +1 -1
  22. package/dist/builtin/workflows/builtin/{chunk-d1xqh1rd.js → chunk-55p5dxjk.js} +1 -1
  23. package/dist/builtin/workflows/builtin/{chunk-1dydq7w3.js → chunk-7f381xnq.js} +62 -24
  24. package/dist/builtin/workflows/builtin/{chunk-k18g9me8.js → chunk-7h7s5xdj.js} +1 -1
  25. package/dist/builtin/workflows/builtin/{chunk-n4yxrsm9.js → chunk-e83tc6nr.js} +1 -1
  26. package/dist/builtin/workflows/builtin/{chunk-sn5mchnx.js → chunk-evfb0312.js} +1 -1
  27. package/dist/builtin/workflows/builtin/{chunk-scgprmdj.js → chunk-ne6vh5ct.js} +1 -1
  28. package/dist/builtin/workflows/builtin/{chunk-119kxb28.js → chunk-pfm1kgqz.js} +62 -43
  29. package/dist/builtin/workflows/builtin/{chunk-hnbbb5r0.js → chunk-tdqvdrg1.js} +4 -4
  30. package/dist/builtin/workflows/builtin/{chunk-kf5xpbkz.js → chunk-tvcydq13.js} +1 -1
  31. package/dist/builtin/workflows/builtin/{chunk-9y0f90rd.js → chunk-x2nftpgj.js} +1 -1
  32. package/dist/builtin/workflows/builtin/{chunk-vt9zgr9d.js → chunk-zj5162bh.js} +4 -4
  33. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  34. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  35. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  36. package/dist/builtin/workflows/builtin/goal.js +4 -4
  37. package/dist/builtin/workflows/builtin/index.d.ts +1 -1
  38. package/dist/builtin/workflows/builtin/index.js +12 -12
  39. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  40. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -1
  41. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  42. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  43. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  44. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  45. package/dist/builtin/workflows/package.json +1 -1
  46. package/dist/builtin/workflows/skills/impeccable/SKILL.md +18 -11
  47. package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -1
  48. package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +1 -1
  49. package/dist/builtin/workflows/skills/impeccable/reference/animate.md +1 -1
  50. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +5 -5
  51. package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +6 -6
  52. package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +2 -2
  53. package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +1 -1
  54. package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +1 -1
  55. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +0 -6
  56. package/dist/builtin/workflows/skills/impeccable/reference/critique.md +19 -41
  57. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +11 -65
  58. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +3 -3
  59. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +4 -4
  60. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +1 -1
  61. package/dist/builtin/workflows/skills/impeccable/reference/delight.md +1 -1
  62. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
  63. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +4 -4
  64. package/dist/builtin/workflows/skills/impeccable/reference/document.md +4 -4
  65. package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
  66. package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -1
  67. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +21 -21
  68. package/dist/builtin/workflows/skills/impeccable/reference/init.md +8 -8
  69. package/dist/builtin/workflows/skills/impeccable/reference/layout.md +2 -2
  70. package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +10 -8
  71. package/dist/builtin/workflows/skills/impeccable/reference/live.md +39 -38
  72. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +48 -21
  73. package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +1 -1
  74. package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +1 -1
  75. package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
  76. package/dist/builtin/workflows/skills/impeccable/reference/polish.md +11 -3
  77. package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +2 -2
  78. package/dist/builtin/workflows/skills/impeccable/reference/routing.md +13 -7
  79. package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +2 -2
  80. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +13 -19
  81. package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -0
  82. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index-failures.json +121 -0
  83. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index.json +1 -0
  84. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +212 -0
  85. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +218 -0
  86. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +21 -0
  87. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +242 -0
  88. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +25 -4
  89. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +666 -197
  90. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
  91. package/dist/builtin/workflows/src/extension/index.bundle.mjs +156 -84
  92. package/dist/builtin/workflows/src/index.js +62 -24
  93. package/dist/core/execution-model-router.d.ts +2 -0
  94. package/dist/core/execution-model-router.d.ts.map +1 -1
  95. package/dist/core/execution-model-router.js +30 -4
  96. package/dist/core/execution-model-router.js.map +1 -1
  97. package/dist/core/model-routing-task.d.ts +1 -1
  98. package/dist/core/model-routing-task.d.ts.map +1 -1
  99. package/dist/core/model-routing-task.js +4 -3
  100. package/dist/core/model-routing-task.js.map +1 -1
  101. package/dist/core/system-prompt.d.ts.map +1 -1
  102. package/dist/core/system-prompt.js +2 -1
  103. package/dist/core/system-prompt.js.map +1 -1
  104. package/dist/index.d.ts +1 -1
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +1 -1
  107. package/dist/index.js.map +1 -1
  108. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  109. package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
  110. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  111. package/docs/computer-use.md +22 -21
  112. package/docs/getting-started/first-session.md +2 -2
  113. package/docs/getting-started/installation.md +6 -2
  114. package/docs/intercom.md +6 -1
  115. package/docs/models/model-selection.md +11 -7
  116. package/docs/quickstart.md +1 -1
  117. package/docs/skills.md +1 -1
  118. package/docs/subagents/reference.md +2 -2
  119. package/docs/subagents.md +7 -1
  120. package/docs/usage.md +2 -0
  121. package/docs/windows.md +1 -1
  122. package/docs/workflows/api-reference.md +3 -4
  123. package/docs/workflows/builtins.md +2 -2
  124. package/docs/workflows/operations.md +1 -1
  125. package/docs/workflows/reliable-design.md +12 -1
  126. package/docs/workflows/verification.md +8 -8
  127. package/npm-shrinkwrap.json +32 -32
  128. package/package.json +3 -3
  129. package/dist/builtin/subagents/skills/playwright-cli/SKILL.md +0 -420
  130. package/dist/builtin/subagents/skills/playwright-cli/references/element-attributes.md +0 -23
  131. package/dist/builtin/subagents/skills/playwright-cli/references/playwright-tests.md +0 -39
  132. package/dist/builtin/subagents/skills/playwright-cli/references/request-mocking.md +0 -87
  133. package/dist/builtin/subagents/skills/playwright-cli/references/running-code.md +0 -241
  134. package/dist/builtin/subagents/skills/playwright-cli/references/session-management.md +0 -225
  135. package/dist/builtin/subagents/skills/playwright-cli/references/storage-state.md +0 -275
  136. package/dist/builtin/subagents/skills/playwright-cli/references/test-generation.md +0 -433
  137. package/dist/builtin/subagents/skills/playwright-cli/references/tracing.md +0 -139
  138. package/dist/builtin/subagents/skills/playwright-cli/references/video-recording.md +0 -143
  139. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +0 -94
  140. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +0 -27
  141. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +0 -41
  142. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
  143. package/dist/builtin/workflows/skills/impeccable/agents/openai.yaml +0 -4
  144. package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +0 -695
  145. package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +0 -325
  146. package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +0 -1503
  147. package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +0 -222
  148. package/dist/builtin/workflows/skills/impeccable/scripts/detect-csp.mjs +0 -198
  149. package/dist/builtin/workflows/skills/impeccable/scripts/detect.mjs +0 -21
  150. package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -2073
  151. package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +0 -432
  152. package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +0 -1121
  153. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -8746
  154. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -51
  155. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -376
  156. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -1168
  157. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1192
  158. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -290
  159. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
  160. package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +0 -18
  161. package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +0 -213
  162. package/dist/builtin/workflows/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
  163. package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -617
  164. package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +0 -5534
  165. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +0 -588
  166. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +0 -112
  167. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +0 -30
  168. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
  169. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +0 -35
  170. package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +0 -338
  171. package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +0 -270
  172. package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +0 -277
  173. package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +0 -783
  174. package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +0 -2305
  175. package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +0 -78
  176. package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +0 -93
  177. package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +0 -200
  178. package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +0 -395
  179. package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +0 -925
  180. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -640
  181. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -137
  182. package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +0 -72
  183. package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +0 -57
  184. package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +0 -5
  185. package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +0 -369
  186. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +0 -483
  187. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +0 -169
  188. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +0 -528
  189. package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +0 -151
  190. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-args.mjs +0 -42
  191. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +0 -33
  192. package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +0 -146
  193. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +0 -617
  194. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +0 -71
  195. package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -77
  196. package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +0 -28
  197. package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +0 -199
  198. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +0 -47
  199. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +0 -157
  200. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +0 -143
  201. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +0 -205
  202. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +0 -49
  203. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +0 -170
  204. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +0 -26
  205. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +0 -26
  206. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +0 -71
  207. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +0 -247
  208. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +0 -70
  209. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +0 -42
  210. package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +0 -149
  211. package/dist/builtin/workflows/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
  212. package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +0 -169
  213. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
  214. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
  215. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
  216. package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +0 -14
  217. package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +0 -670
  218. package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +0 -563
  219. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +0 -105
  220. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +0 -105
  221. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +0 -969
  222. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +0 -1401
  223. package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -314
  224. package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +0 -280
  225. package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +0 -75
  226. package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +0 -171
  227. package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +0 -961
  228. package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1244
  229. package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +0 -107
  230. package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -800
  231. package/dist/builtin/workflows/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
  232. package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +0 -515
  233. package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +0 -292
  234. package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -371
  235. package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +0 -427
  236. package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +0 -123
  237. package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +0 -1675
  238. package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +0 -71
  239. package/dist/builtin/workflows/skills/impeccable/scripts/live-target.mjs +0 -30
  240. package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +0 -927
  241. package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +0 -365
  242. package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +0 -628
  243. package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +0 -224
  244. package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +0 -1540
  245. package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +0 -74
@@ -6548,7 +6548,7 @@ async function withSetupLock(lockDir, fn, options = {}) {
6548
6548
  const isProcessAlive = options.isProcessAlive ?? processIsAlive2;
6549
6549
  let lease;
6550
6550
  for (let attempt = 0;attempt < attempts; attempt += 1) {
6551
- lease = acquireSetupLock(lockDir, clock(), staleMs, isProcessAlive);
6551
+ lease = acquireSetupLock(lockDir, clock(), staleMs, isProcessAlive, options.beforeOwnerMarkerWrite);
6552
6552
  if (lease !== undefined)
6553
6553
  break;
6554
6554
  if (attempt === attempts - 1) {
@@ -6570,29 +6570,15 @@ async function withSetupLock(lockDir, fn, options = {}) {
6570
6570
  releaseSetupLock(lease);
6571
6571
  }
6572
6572
  }
6573
- function acquireSetupLock(lockDir, now, staleMs, isProcessAlive) {
6573
+ function acquireSetupLock(lockDir, now, staleMs, isProcessAlive, beforeOwnerMarkerWrite) {
6574
6574
  const abandonedOwnerTokens = new Set;
6575
6575
  for (let attempt = 0;attempt < 2; attempt += 1) {
6576
6576
  const token = `${process.pid}-${crypto.randomUUID()}`;
6577
- const markerPath = join4(lockDir, `.owner-${token}`);
6578
- try {
6579
- mkdirSync2(lockDir);
6580
- try {
6581
- writeFileSync2(markerPath, serializeLockOwner({ token, pid: process.pid, heartbeatMonotonicMs: now.monotonicMs }), {
6582
- flag: "wx",
6583
- mode: 384
6584
- });
6585
- return { lockDir, markerPath, token, ownerPid: process.pid, abandonedOwnerTokens };
6586
- } catch (error) {
6587
- try {
6588
- rmdirSync(lockDir);
6589
- } catch {}
6590
- throw error;
6591
- }
6592
- } catch (error) {
6593
- const code = error instanceof Error && "code" in error ? error.code : undefined;
6594
- if (code !== "EEXIST")
6595
- throw error;
6577
+ if (createSetupLockDirectory(lockDir)) {
6578
+ beforeOwnerMarkerWrite?.(lockDir);
6579
+ const lease = claimCreatedSetupLock(lockDir, token, now, abandonedOwnerTokens);
6580
+ if (lease !== undefined)
6581
+ return lease;
6596
6582
  }
6597
6583
  const observation = observeSetupLock(lockDir);
6598
6584
  if (observation === undefined || !setupLockIsStale(observation, now, staleMs, isProcessAlive))
@@ -6605,6 +6591,52 @@ function acquireSetupLock(lockDir, now, staleMs, isProcessAlive) {
6605
6591
  }
6606
6592
  return;
6607
6593
  }
6594
+ function createSetupLockDirectory(lockDir) {
6595
+ try {
6596
+ mkdirSync2(lockDir);
6597
+ return true;
6598
+ } catch (error) {
6599
+ if (errorCode(error) === "EEXIST")
6600
+ return false;
6601
+ throw error;
6602
+ }
6603
+ }
6604
+ function claimCreatedSetupLock(lockDir, token, now, abandonedOwnerTokens) {
6605
+ const markerName = `.owner-${token}`;
6606
+ const markerPath = join4(lockDir, markerName);
6607
+ try {
6608
+ writeFileSync2(markerPath, serializeLockOwner({ token, pid: process.pid, heartbeatMonotonicMs: now.monotonicMs }), {
6609
+ flag: "wx",
6610
+ mode: 384
6611
+ });
6612
+ } catch (error) {
6613
+ try {
6614
+ rmdirSync(lockDir);
6615
+ } catch {}
6616
+ if (errorCode(error) === "ENOENT")
6617
+ return;
6618
+ throw error;
6619
+ }
6620
+ if (createdSetupLockHoldsOnly(lockDir, markerName)) {
6621
+ return { lockDir, markerPath, token, ownerPid: process.pid, abandonedOwnerTokens };
6622
+ }
6623
+ rmSync2(markerPath, { force: true });
6624
+ try {
6625
+ rmdirSync(lockDir);
6626
+ } catch {}
6627
+ return;
6628
+ }
6629
+ function createdSetupLockHoldsOnly(lockDir, markerName) {
6630
+ try {
6631
+ const entries = readdirSync2(lockDir);
6632
+ return entries.length === 1 && entries[0] === markerName;
6633
+ } catch {
6634
+ return false;
6635
+ }
6636
+ }
6637
+ function errorCode(error) {
6638
+ return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : undefined;
6639
+ }
6608
6640
  function refreshSetupLockLease(lease, now, beforeReplace) {
6609
6641
  if (!ownsSetupLock(lease))
6610
6642
  return false;
@@ -6725,9 +6757,15 @@ function setupLockIsStale(observation, now, staleMs, isProcessAlive) {
6725
6757
  return false;
6726
6758
  }
6727
6759
  }
6728
- if (!observation.hasUnexpectedState)
6729
- return observation.owners.length > 0;
6730
- return now.wallTimeMs < observation.latestMtimeMs || now.wallTimeMs - observation.latestMtimeMs > staleMs;
6760
+ if (observation.hasUnexpectedState) {
6761
+ return now.wallTimeMs < observation.latestMtimeMs || now.wallTimeMs - observation.latestMtimeMs > staleMs;
6762
+ }
6763
+ if (observation.owners.length > 0)
6764
+ return true;
6765
+ return emptySetupLockIsAbandoned(observation, now, staleMs);
6766
+ }
6767
+ function emptySetupLockIsAbandoned(observation, now, staleMs) {
6768
+ return Number.isFinite(observation.latestMtimeMs) && now.wallTimeMs - observation.latestMtimeMs > staleMs;
6731
6769
  }
6732
6770
  function serializeLockOwner(owner) {
6733
6771
  const serialized = JSON.stringify(owner);
@@ -13,6 +13,8 @@ export interface ModelRoute {
13
13
  assertCurrent(): void;
14
14
  allowsModel(model: Model<Api>, effort?: string): boolean;
15
15
  }
16
+ /** Static selection policy sent with every auto-routing request alongside the dated `evals` evidence. */
17
+ export declare const MODEL_SELECTION_GUIDE = "## Benchmarks are evidence, not policy\n\nBenchmark results are measurements under named harnesses, dates, models, efforts, agents, tools, prompts, prices, and scoring rules. Treat a bracketed effort level as the measurement configuration for that row, not a command to run every task at that effort. Compare only records whose measured setup resembles the decision at hand, and keep unmeasured work under ordinary validation rather than inheriting a score.\n\nMissing evidence is unknown, not zero. A rounded lead is not proof of significance. A result for one provider, model version, effort, agent, fallback setting, or benchmark harness does not transfer to another identity.\n\n## Role-based thinking effort\n\nUse these starting defaults unless the user requests a level. Higher effort can improve hard reasoning, but it also costs more and can be slower. `max` is an exception, not a default.\n\nPrice is per task. Candidate cost is USD per million tokens, and roles differ in token volume and in what a mistake costs. High-volume, tool-checked roles such as exploration and routine implementation default to cheaper, faster models; roles where a missed defect is expensive, such as review, verification, and final approval, justify frontier models at high effort. Pick the tier first, then the effort within it; do not compensate for a cheap model with `max` or for an expensive one with `minimal`.\n\n| Stage role | Default thinking level | Model cost tier | Why |\n| --- | --- | --- | --- |\n| Codebase exploration: locating files, reading code, tracing call sites | `minimal` or `low` | Cheap, fast | Tool-driven lookups need speed, not deliberation; escalate to mapping or analysis only when the question becomes a design judgement. |\n| Coding, implementation, routine fixes | `low` or `medium` | Cheap or mid-priced | Runs many times per task and is validated by tools and review afterwards. |\n| Code review, test design, failure analysis, security, identity, adversarial challenge, final approval | `high` or `xhigh` | Frontier | A missed defect is the expensive outcome; spend the strongest model and reasoning here. |\n| Codebase mapping, lifecycle analysis, compatibility, planning, synthesis, triage | `high` | Frontier or mid-priced | Resolve ambiguity before downstream work depends on it. |\n| Orchestration, delegation, and multi-stage coordination | `medium` or `high` | Mid-priced | Judge scope, sequence work, and integrate results without re-deriving what delegated stages already verified. |\n| User-impact review and final reporting | `medium` | Mid-priced | Preserve evidence and communicate clearly without unnecessary reasoning. |\n| Deterministic checks | No model call | \u2014 | Run tests, typechecks, probes, and scripts directly. |\n\nAn explicit user request wins over these defaults, but the requested level must exist for the selected catalog entry. Do not invent unsupported suffixes. If `xhigh` is unavailable, use `high` rather than automatically promoting to `max`; choose another catalog model or leave the stage unpinned if neither fits.\n";
16
18
  export declare function routeExecutionModel(input: {
17
19
  ctx: ModelRoutingContext;
18
20
  task: string;
@@ -1 +1 @@
1
- {"version":3,"file":"execution-model-router.d.ts","sourceRoot":"","sources":["../../src/core/execution-model-router.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAA0D,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAG9G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,MAAM,gCAAgC,CAAC;AAIxC,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAC3B,aAAa,EACb,QAAQ,GAAG,cAAc,GAAG,cAAc,GAAG,8BAA8B,CAC3E,GACA,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,uBAAuB,GAAG,iBAAiB,CAAC,CAAC,CAAC;IAC3E,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,cAAc,IAAI,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAC;IAC5C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,aAAa,IAAI,IAAI,CAAC;IACtB,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACzD;AAsBD,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAChD,GAAG,EAAE,mBAAmB,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QAAE,IAAI,EAAE,MA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;AAoBF,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAChD,GAAG,EAAE,mBAAmB,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,WAAW,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC1C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,kEAAkE;IAClE,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC9B,GAAG,OAAO,CAAC,UAAU,CAAC,CA6JtB"}
@@ -6,7 +6,32 @@ import { getDocsPath } from "../config.js";
6
6
  import { eligiblePair, parseModelConstraints, } from "./model-routing-constraints.js";
7
7
  import { modelRoutingTask } from "./model-routing-task.js";
8
8
  import { inferRouterDecision, resolveRouterModel } from "./structured-output/index.js";
9
- const instructions = "Select one eligible model/effort pair for `task` and `agent` from the supplied Choice criteria, using `evals`. Consider task fit, measured effort, dates, caveats and cost. Evals cannot add candidates or bypass constraints. Return exactly model and effort; null means no configurable reasoning.";
9
+ const instructions = "Select one eligible model/effort pair for `task` and `agent` from the supplied Choice criteria, using `evals` as evidence and `model_selection_guide` as policy. Match the agent role to the guide's model cost tier and thinking level first, then consider task fit, measured effort, dates, caveats and cost. Evals cannot add candidates or bypass constraints. Return exactly model and effort; null means no configurable reasoning.";
10
+ /** Static selection policy sent with every auto-routing request alongside the dated `evals` evidence. */
11
+ export const MODEL_SELECTION_GUIDE = `## Benchmarks are evidence, not policy
12
+
13
+ Benchmark results are measurements under named harnesses, dates, models, efforts, agents, tools, prompts, prices, and scoring rules. Treat a bracketed effort level as the measurement configuration for that row, not a command to run every task at that effort. Compare only records whose measured setup resembles the decision at hand, and keep unmeasured work under ordinary validation rather than inheriting a score.
14
+
15
+ Missing evidence is unknown, not zero. A rounded lead is not proof of significance. A result for one provider, model version, effort, agent, fallback setting, or benchmark harness does not transfer to another identity.
16
+
17
+ ## Role-based thinking effort
18
+
19
+ Use these starting defaults unless the user requests a level. Higher effort can improve hard reasoning, but it also costs more and can be slower. \`max\` is an exception, not a default.
20
+
21
+ Price is per task. Candidate cost is USD per million tokens, and roles differ in token volume and in what a mistake costs. High-volume, tool-checked roles such as exploration and routine implementation default to cheaper, faster models; roles where a missed defect is expensive, such as review, verification, and final approval, justify frontier models at high effort. Pick the tier first, then the effort within it; do not compensate for a cheap model with \`max\` or for an expensive one with \`minimal\`.
22
+
23
+ | Stage role | Default thinking level | Model cost tier | Why |
24
+ | --- | --- | --- | --- |
25
+ | Codebase exploration: locating files, reading code, tracing call sites | \`minimal\` or \`low\` | Cheap, fast | Tool-driven lookups need speed, not deliberation; escalate to mapping or analysis only when the question becomes a design judgement. |
26
+ | Coding, implementation, routine fixes | \`low\` or \`medium\` | Cheap or mid-priced | Runs many times per task and is validated by tools and review afterwards. |
27
+ | Code review, test design, failure analysis, security, identity, adversarial challenge, final approval | \`high\` or \`xhigh\` | Frontier | A missed defect is the expensive outcome; spend the strongest model and reasoning here. |
28
+ | Codebase mapping, lifecycle analysis, compatibility, planning, synthesis, triage | \`high\` | Frontier or mid-priced | Resolve ambiguity before downstream work depends on it. |
29
+ | Orchestration, delegation, and multi-stage coordination | \`medium\` or \`high\` | Mid-priced | Judge scope, sequence work, and integrate results without re-deriving what delegated stages already verified. |
30
+ | User-impact review and final reporting | \`medium\` | Mid-priced | Preserve evidence and communicate clearly without unnecessary reasoning. |
31
+ | Deterministic checks | No model call | — | Run tests, typechecks, probes, and scripts directly. |
32
+
33
+ An explicit user request wins over these defaults, but the requested level must exist for the selected catalog entry. Do not invent unsupported suffixes. If \`xhigh\` is unavailable, use \`high\` rather than automatically promoting to \`max\`; choose another catalog model or leave the stage unpinned if neither fits.
34
+ `;
10
35
  const MODEL_SELECTION_EVALS_JSON_BYTES = 16_000;
11
36
  async function readModelSelectionEvals(signal) {
12
37
  try {
@@ -55,6 +80,7 @@ export async function routeExecutionModel(input) {
55
80
  task: input.task,
56
81
  agent: { name: input.agent.name, description: input.agent.description },
57
82
  evals: await readModelSelectionEvals(signal),
83
+ model_selection_guide: MODEL_SELECTION_GUIDE,
58
84
  };
59
85
  if (!state.task.trim())
60
86
  throw new Error("Auto routing requires task instructions.");
@@ -71,9 +97,9 @@ export async function routeExecutionModel(input) {
71
97
  /\bBearer\s+[A-Za-z0-9._~+/-]{8,}|-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:sk|ghp|github_pat)[-_][A-Za-z0-9_-]{16,}/i.test(serialized))
72
98
  throw new Error("Auto routing context contains credential material. Remove secrets before retrying.");
73
99
  // Screen the full task first, even credentials in text the router will omit.
100
+ // Shortening only affects the routing request, never the execution prompt,
101
+ // so it is not surfaced to the user.
74
102
  state.task = modelRoutingTask(state.task);
75
- if (state.task !== input.task)
76
- console.warn("Text was truncated to fit the input budget. Continuing with the shortened text.");
77
103
  const ranked = [];
78
104
  // Rank by repeated bounded choices, excluding all efforts of earlier models.
79
105
  // Probabilities from separate tournament batches are not comparable.
@@ -110,7 +136,7 @@ export async function routeExecutionModel(input) {
110
136
  jev: {
111
137
  questions: {
112
138
  pair: {
113
- instructions: "Which eligible model and reasoning effort best suit this task and agent role, considering evals and candidate capabilities and prices? Candidate cost is USD per million tokens, not benchmark task cost.",
139
+ instructions: "Which eligible model and reasoning effort best suit this task and agent role, considering the model_selection_guide role tiers, evals, and candidate capabilities and prices? Prefer cheaper candidates for exploration and routine implementation and stronger ones for review and verification. Candidate cost is USD per million tokens, not benchmark task cost.",
114
140
  criteria,
115
141
  },
116
142
  },
@@ -1 +1 @@
1
- {"version":3,"file":"execution-model-router.js","sourceRoot":"","sources":["../../src/core/execution-model-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAY,0BAA0B,EAAE,0BAA0B,EAAc,MAAM,gBAAg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AAK,EAAE,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;YACvE,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,aAAa,GAAG,GAAG,EAAE;QAC1B,MAAM,EAAE,cAAc,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,eAAe,EAAE,GAAG,CAAC,eAAe,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;YAC1E,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IACtG,CAAC,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO;QACN,eAAe;QACf,aAAa,EAAE,eAAe,CAAC,KAAK,GAAG,CAAC,eAAe,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;QAC5G,cAAc,EAAE,MAAM,CAAC,MAAM,CAC5B,CAAC,eAAe,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAC7G;QACD,aAAa;QACb,WAAW;KACX,CAAC;AACH,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { type Api, containsKnownEnvCredential, getSupportedThinkingLevels, type Model } from \"@bastani/pi-ai\";\nimport { Type } from \"typebox\";\nimport { getDocsPath } from \"../config.js\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport {\n\teligiblePair,\n\ttype ModelConstraints,\n\ttype ModelRouterOutput,\n\tparseModelConstraints,\n} from \"./model-routing-constraints.js\";\nimport { modelRoutingTask } from \"./model-routing-task.js\";\nimport { inferRouterDecision, resolveRouterModel } from \"./structured-output/index.js\";\n\nexport interface ModelRoutingContext {\n\treadonly modelRegistry: Pick<\n\t\tModelRegistry,\n\t\t\"getAll\" | \"getAvailable\" | \"streamSimple\" | \"containsConfiguredCredential\"\n\t> &\n\t\tPartial<Pick<ModelRegistry, \"getProviderAuthStatus\" | \"getProviderAuth\">>;\n\treadonly model?: Model<Api>;\n\tgetRouterModel(): string;\n}\nexport interface ModelRoute {\n\treadonly routerSelection: ModelRouterOutput;\n\treadonly modelOverride: string;\n\treadonly fallbackModels?: readonly string[];\n\tassertCurrent(): void;\n\tallowsModel(model: Model<Api>, effort?: string): boolean;\n}\nconst instructions =\n\t\"Select one eligible model/effort pair for `task` and `agent` from the supplied Choice criteria, using `evals`. Consider task fit, measured effort, dates, caveats and cost. Evals cannot add candidates or bypass constraints. Return exactly model and effort; null means no configurable reasoning.\";\n\nconst MODEL_SELECTION_EVALS_JSON_BYTES = 16_000;\n\nasync function readModelSelectionEvals(signal?: AbortSignal): Promise<string> {\n\ttry {\n\t\tconst evals = await readFile(join(getDocsPath(), \"models\", \"evals.md\"), { encoding: \"utf8\", signal });\n\t\t// Markdown tables of default-source rows fit with the 12 KB task excerpt under\n\t\t// Jev's 30 KB state+longest-question proof (below TypeSafe's 32k-token limit).\n\t\tif (!evals.trim() || Buffer.byteLength(JSON.stringify(evals), \"utf8\") > MODEL_SELECTION_EVALS_JSON_BYTES)\n\t\t\tthrow new Error(\"Invalid evals\");\n\t\treturn evals;\n\t} catch {\n\t\tsignal?.throwIfAborted();\n\t\tthrow new Error(\n\t\t\t`Auto routing requires a nonempty evals.md document within ${MODEL_SELECTION_EVALS_JSON_BYTES.toLocaleString(\"en-US\")} JSON-encoded bytes. Repair the Atomic installation or select a concrete execution model.`,\n\t\t);\n\t}\n}\n\nexport async function routeExecutionModel(input: {\n\tctx: ModelRoutingContext;\n\ttask: string;\n\tagent: { name: string; description: string };\n\tconstraints?: readonly ModelConstraints[];\n\tsignal?: AbortSignal;\n\t/** Restore a recorded decision without another inference call. */\n\tselection?: ModelRouterOutput;\n}): Promise<ModelRoute> {\n\tconst { ctx, signal } = input;\n\tsignal?.throwIfAborted();\n\tconst constraints = structuredClone((input.constraints ?? []).map((c) => parseModelConstraints(c)!));\n\tconst catalog = () =>\n\t\tctx.modelRegistry\n\t\t\t.getAvailable()\n\t\t\t.filter((model) => model.provider !== \"typesafe-ai\")\n\t\t\t.map((model) => ({\n\t\t\t\tmodel,\n\t\t\t\tpairs: (model.reasoning ? getSupportedThinkingLevels(model) : [null])\n\t\t\t\t\t.map((effort) => ({ model: `${model.provider}/${model.id}`, effort }))\n\t\t\t\t\t.filter((pair) => eligiblePair(model, pair, constraints)),\n\t\t\t}))\n\t\t\t.filter((entry) => entry.pairs.length > 0);\n\tconst available = catalog();\n\tconst pairs = available.flatMap((entry) => entry.pairs);\n\tif (!pairs.length)\n\t\tthrow new Error(\n\t\t\t\"Auto routing has no eligible model/effort pairs. Check configured providers and modelConstraints.\",\n\t\t);\n\tlet selection = input.selection;\n\tif (selection === undefined) {\n\t\tconst settings = { getRouterModel: () => ctx.getRouterModel() };\n\t\tresolveRouterModel({ settings, currentModel: ctx.model, modelRegistry: ctx.modelRegistry });\n\t\tconst candidates = available.flatMap(({ model, pairs }) =>\n\t\t\tpairs.map((pair) => ({\n\t\t\t\t...pair,\n\t\t\t\tinput: model.input,\n\t\t\t\tcontextWindow: model.contextWindow,\n\t\t\t\tcost: { ...model.cost, tiers: (model.cost.tiers ?? []).map((tier) => ({ ...tier })) },\n\t\t\t})),\n\t\t);\n\t\tconst allCriteria = Object.fromEntries(\n\t\t\tcandidates.map((candidate, index) => [`pair_${index}`, JSON.stringify(candidate)]),\n\t\t);\n\t\tconst state = {\n\t\t\ttask: input.task,\n\t\t\tagent: { name: input.agent.name, description: input.agent.description },\n\t\t\tevals: await readModelSelectionEvals(signal),\n\t\t};\n\t\tif (!state.task.trim()) throw new Error(\"Auto routing requires task instructions.\");\n\t\tconst serialized = JSON.stringify({ state, criteria: allCriteria, constraints });\n\t\tlet configuredCredential: boolean;\n\t\ttry {\n\t\t\tconfiguredCredential = await ctx.modelRegistry.containsConfiguredCredential(serialized);\n\t\t} catch {\n\t\t\tthrow new Error(\"Auto routing could not screen configured credentials. No inference was performed.\");\n\t\t}\n\t\tif (\n\t\t\tcontainsKnownEnvCredential(serialized) ||\n\t\t\tconfiguredCredential ||\n\t\t\t/\\bBearer\\s+[A-Za-z0-9._~+/-]{8,}|-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\\b(?:sk|ghp|github_pat)[-_][A-Za-z0-9_-]{16,}/i.test(\n\t\t\t\tserialized,\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(\"Auto routing context contains credential material. Remove secrets before retrying.\");\n\t\t// Screen the full task first, even credentials in text the router will omit.\n\t\tstate.task = modelRoutingTask(state.task);\n\t\tif (state.task !== input.task)\n\t\t\tconsole.warn(\"Text was truncated to fit the input budget. Continuing with the shortened text.\");\n\t\tconst ranked: ModelRouterOutput[] = [];\n\t\t// Rank by repeated bounded choices, excluding all efforts of earlier models.\n\t\t// Probabilities from separate tournament batches are not comparable.\n\t\tconst deadline = performance.now() + 30_000;\n\t\twhile (ranked.length < Math.min(3, available.length)) {\n\t\t\tconst remaining = pairs.filter((pair) => !ranked.some((selected) => selected.model === pair.model));\n\t\t\tif (!remaining.length) break;\n\t\t\tconst criteria = Object.fromEntries(\n\t\t\t\tremaining.map((pair) => {\n\t\t\t\t\tconst key = `pair_${pairs.indexOf(pair)}`;\n\t\t\t\t\treturn [key, allCriteria[key]];\n\t\t\t\t}),\n\t\t\t);\n\t\t\t// Strict Responses providers reject object unions. Enumerate scalar values\n\t\t\t// on the wire, then verify the exact model/effort relation before admission.\n\t\t\tconst schema = Type.Unsafe<ModelRouterOutput>({\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tmodel: Type.String({ enum: [...new Set(remaining.map((pair) => pair.model))] }),\n\t\t\t\t\teffort: { type: [\"string\", \"null\"], enum: [...new Set(remaining.map((pair) => pair.effort))] },\n\t\t\t\t},\n\t\t\t\trequired: [\"model\", \"effort\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t});\n\t\t\tconst timeoutMs = Math.ceil(deadline - performance.now());\n\t\t\tif (timeoutMs <= 0) throw new Error(\"Auto model ranking timed out; no decision was accepted.\");\n\t\t\tconst result = await inferRouterDecision(\n\t\t\t\t{\n\t\t\t\t\tsettings,\n\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\tcurrentModel: ctx.model,\n\t\t\t\t\tstate,\n\t\t\t\t\tinstructions,\n\t\t\t\t\tschema,\n\t\t\t\t\tjev: {\n\t\t\t\t\t\tquestions: {\n\t\t\t\t\t\t\tpair: {\n\t\t\t\t\t\t\t\tinstructions:\n\t\t\t\t\t\t\t\t\t\"Which eligible model and reasoning effort best suit this task and agent role, considering evals and candidate capabilities and prices? Candidate cost is USD per million tokens, not benchmark task cost.\",\n\t\t\t\t\t\t\t\tcriteria,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdecode: (choices) => {\n\t\t\t\t\t\t\tconst pair = pairs[Number(choices.pair?.replace(/^pair_/, \"\"))];\n\t\t\t\t\t\t\tif (!pair || choices.pair !== `pair_${pairs.indexOf(pair)}`)\n\t\t\t\t\t\t\t\tthrow new Error(\"Invalid execution model Choice.\");\n\t\t\t\t\t\t\treturn { ...pair };\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tsignal,\n\t\t\t\t\ttimeoutMs,\n\t\t\t\t},\n\t\t\t\t(value) => remaining.some((pair) => pair.model === value.model && pair.effort === value.effort),\n\t\t\t);\n\t\t\tranked.push(result.value);\n\t\t}\n\t\tselection = { ...ranked[0]!, ...(ranked.length > 1 ? { fallbacks: ranked.slice(1) } : {}) };\n\t}\n\tconst fallbacks = selection.fallbacks?.map((pair) => Object.freeze({ model: pair.model, effort: pair.effort }));\n\tif (\n\t\tfallbacks &&\n\t\t(fallbacks.length > 2 ||\n\t\t\tnew Set([selection.model, ...fallbacks.map((pair) => pair.model)]).size !== fallbacks.length + 1)\n\t)\n\t\tthrow new Error(\"Invalid ranked auto selection: expected up to three distinct models.\");\n\tconst routerSelection = Object.freeze({\n\t\tmodel: selection.model,\n\t\teffort: selection.effort,\n\t\t...(fallbacks?.length ? { fallbacks: Object.freeze(fallbacks) } : {}),\n\t});\n\tconst hasPair = (pair: ModelRouterOutput) =>\n\t\tcatalog().some((entry) => entry.pairs.some((p) => p.model === pair.model && p.effort === pair.effort));\n\tconst allowsModel = (model: Model<Api>, effort?: string): boolean => {\n\t\tconst levels = model.reasoning ? getSupportedThinkingLevels(model) : [null];\n\t\treturn levels.some((level) => {\n\t\t\tif (model.reasoning && effort !== undefined && level !== effort) return false;\n\t\t\tconst pair = { model: `${model.provider}/${model.id}`, effort: level };\n\t\t\treturn eligiblePair(model, pair, constraints) && hasPair(pair);\n\t\t});\n\t};\n\tconst assertCurrent = () => {\n\t\tsignal?.throwIfAborted();\n\t\tif (![routerSelection, ...(routerSelection.fallbacks ?? [])].every(hasPair))\n\t\t\tthrow new Error(\"Auto selection is no longer eligible. Retry explicitly with the current catalog.\");\n\t};\n\tassertCurrent();\n\treturn {\n\t\trouterSelection,\n\t\tmodelOverride: routerSelection.model + (routerSelection.effort === null ? \"\" : `:${routerSelection.effort}`),\n\t\tfallbackModels: Object.freeze(\n\t\t\t(routerSelection.fallbacks ?? []).map((pair) => pair.model + (pair.effort === null ? \"\" : `:${pair.effort}`)),\n\t\t),\n\t\tassertCurrent,\n\t\tallowsModel,\n\t};\n}\n"]}
1
+ {"version":3,"file":"execution-model-router.js","sourceRoot":"","sources":["../../src/core/execution-model-router.ts"],"names":[],"mappings":"AAAA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AC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { type Api, containsKnownEnvCredential, getSupportedThinkingLevels, type Model } from \"@bastani/pi-ai\";\nimport { Type } from \"typebox\";\nimport { getDocsPath } from \"../config.js\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport {\n\teligiblePair,\n\ttype ModelConstraints,\n\ttype ModelRouterOutput,\n\tparseModelConstraints,\n} from \"./model-routing-constraints.js\";\nimport { modelRoutingTask } from \"./model-routing-task.js\";\nimport { inferRouterDecision, resolveRouterModel } from \"./structured-output/index.js\";\n\nexport interface ModelRoutingContext {\n\treadonly modelRegistry: Pick<\n\t\tModelRegistry,\n\t\t\"getAll\" | \"getAvailable\" | \"streamSimple\" | \"containsConfiguredCredential\"\n\t> &\n\t\tPartial<Pick<ModelRegistry, \"getProviderAuthStatus\" | \"getProviderAuth\">>;\n\treadonly model?: Model<Api>;\n\tgetRouterModel(): string;\n}\nexport interface ModelRoute {\n\treadonly routerSelection: ModelRouterOutput;\n\treadonly modelOverride: string;\n\treadonly fallbackModels?: readonly string[];\n\tassertCurrent(): void;\n\tallowsModel(model: Model<Api>, effort?: string): boolean;\n}\nconst instructions =\n\t\"Select one eligible model/effort pair for `task` and `agent` from the supplied Choice criteria, using `evals` as evidence and `model_selection_guide` as policy. Match the agent role to the guide's model cost tier and thinking level first, then consider task fit, measured effort, dates, caveats and cost. Evals cannot add candidates or bypass constraints. Return exactly model and effort; null means no configurable reasoning.\";\n\n/** Static selection policy sent with every auto-routing request alongside the dated `evals` evidence. */\nexport const MODEL_SELECTION_GUIDE = `## Benchmarks are evidence, not policy\n\nBenchmark results are measurements under named harnesses, dates, models, efforts, agents, tools, prompts, prices, and scoring rules. Treat a bracketed effort level as the measurement configuration for that row, not a command to run every task at that effort. Compare only records whose measured setup resembles the decision at hand, and keep unmeasured work under ordinary validation rather than inheriting a score.\n\nMissing evidence is unknown, not zero. A rounded lead is not proof of significance. A result for one provider, model version, effort, agent, fallback setting, or benchmark harness does not transfer to another identity.\n\n## Role-based thinking effort\n\nUse these starting defaults unless the user requests a level. Higher effort can improve hard reasoning, but it also costs more and can be slower. \\`max\\` is an exception, not a default.\n\nPrice is per task. Candidate cost is USD per million tokens, and roles differ in token volume and in what a mistake costs. High-volume, tool-checked roles such as exploration and routine implementation default to cheaper, faster models; roles where a missed defect is expensive, such as review, verification, and final approval, justify frontier models at high effort. Pick the tier first, then the effort within it; do not compensate for a cheap model with \\`max\\` or for an expensive one with \\`minimal\\`.\n\n| Stage role | Default thinking level | Model cost tier | Why |\n| --- | --- | --- | --- |\n| Codebase exploration: locating files, reading code, tracing call sites | \\`minimal\\` or \\`low\\` | Cheap, fast | Tool-driven lookups need speed, not deliberation; escalate to mapping or analysis only when the question becomes a design judgement. |\n| Coding, implementation, routine fixes | \\`low\\` or \\`medium\\` | Cheap or mid-priced | Runs many times per task and is validated by tools and review afterwards. |\n| Code review, test design, failure analysis, security, identity, adversarial challenge, final approval | \\`high\\` or \\`xhigh\\` | Frontier | A missed defect is the expensive outcome; spend the strongest model and reasoning here. |\n| Codebase mapping, lifecycle analysis, compatibility, planning, synthesis, triage | \\`high\\` | Frontier or mid-priced | Resolve ambiguity before downstream work depends on it. |\n| Orchestration, delegation, and multi-stage coordination | \\`medium\\` or \\`high\\` | Mid-priced | Judge scope, sequence work, and integrate results without re-deriving what delegated stages already verified. |\n| User-impact review and final reporting | \\`medium\\` | Mid-priced | Preserve evidence and communicate clearly without unnecessary reasoning. |\n| Deterministic checks | No model call | — | Run tests, typechecks, probes, and scripts directly. |\n\nAn explicit user request wins over these defaults, but the requested level must exist for the selected catalog entry. Do not invent unsupported suffixes. If \\`xhigh\\` is unavailable, use \\`high\\` rather than automatically promoting to \\`max\\`; choose another catalog model or leave the stage unpinned if neither fits.\n`;\n\nconst MODEL_SELECTION_EVALS_JSON_BYTES = 16_000;\n\nasync function readModelSelectionEvals(signal?: AbortSignal): Promise<string> {\n\ttry {\n\t\tconst evals = await readFile(join(getDocsPath(), \"models\", \"evals.md\"), { encoding: \"utf8\", signal });\n\t\t// Markdown tables of default-source rows fit with the 12 KB task excerpt under\n\t\t// Jev's 30 KB state+longest-question proof (below TypeSafe's 32k-token limit).\n\t\tif (!evals.trim() || Buffer.byteLength(JSON.stringify(evals), \"utf8\") > MODEL_SELECTION_EVALS_JSON_BYTES)\n\t\t\tthrow new Error(\"Invalid evals\");\n\t\treturn evals;\n\t} catch {\n\t\tsignal?.throwIfAborted();\n\t\tthrow new Error(\n\t\t\t`Auto routing requires a nonempty evals.md document within ${MODEL_SELECTION_EVALS_JSON_BYTES.toLocaleString(\"en-US\")} JSON-encoded bytes. Repair the Atomic installation or select a concrete execution model.`,\n\t\t);\n\t}\n}\n\nexport async function routeExecutionModel(input: {\n\tctx: ModelRoutingContext;\n\ttask: string;\n\tagent: { name: string; description: string };\n\tconstraints?: readonly ModelConstraints[];\n\tsignal?: AbortSignal;\n\t/** Restore a recorded decision without another inference call. */\n\tselection?: ModelRouterOutput;\n}): Promise<ModelRoute> {\n\tconst { ctx, signal } = input;\n\tsignal?.throwIfAborted();\n\tconst constraints = structuredClone((input.constraints ?? []).map((c) => parseModelConstraints(c)!));\n\tconst catalog = () =>\n\t\tctx.modelRegistry\n\t\t\t.getAvailable()\n\t\t\t.filter((model) => model.provider !== \"typesafe-ai\")\n\t\t\t.map((model) => ({\n\t\t\t\tmodel,\n\t\t\t\tpairs: (model.reasoning ? getSupportedThinkingLevels(model) : [null])\n\t\t\t\t\t.map((effort) => ({ model: `${model.provider}/${model.id}`, effort }))\n\t\t\t\t\t.filter((pair) => eligiblePair(model, pair, constraints)),\n\t\t\t}))\n\t\t\t.filter((entry) => entry.pairs.length > 0);\n\tconst available = catalog();\n\tconst pairs = available.flatMap((entry) => entry.pairs);\n\tif (!pairs.length)\n\t\tthrow new Error(\n\t\t\t\"Auto routing has no eligible model/effort pairs. Check configured providers and modelConstraints.\",\n\t\t);\n\tlet selection = input.selection;\n\tif (selection === undefined) {\n\t\tconst settings = { getRouterModel: () => ctx.getRouterModel() };\n\t\tresolveRouterModel({ settings, currentModel: ctx.model, modelRegistry: ctx.modelRegistry });\n\t\tconst candidates = available.flatMap(({ model, pairs }) =>\n\t\t\tpairs.map((pair) => ({\n\t\t\t\t...pair,\n\t\t\t\tinput: model.input,\n\t\t\t\tcontextWindow: model.contextWindow,\n\t\t\t\tcost: { ...model.cost, tiers: (model.cost.tiers ?? []).map((tier) => ({ ...tier })) },\n\t\t\t})),\n\t\t);\n\t\tconst allCriteria = Object.fromEntries(\n\t\t\tcandidates.map((candidate, index) => [`pair_${index}`, JSON.stringify(candidate)]),\n\t\t);\n\t\tconst state = {\n\t\t\ttask: input.task,\n\t\t\tagent: { name: input.agent.name, description: input.agent.description },\n\t\t\tevals: await readModelSelectionEvals(signal),\n\t\t\tmodel_selection_guide: MODEL_SELECTION_GUIDE,\n\t\t};\n\t\tif (!state.task.trim()) throw new Error(\"Auto routing requires task instructions.\");\n\t\tconst serialized = JSON.stringify({ state, criteria: allCriteria, constraints });\n\t\tlet configuredCredential: boolean;\n\t\ttry {\n\t\t\tconfiguredCredential = await ctx.modelRegistry.containsConfiguredCredential(serialized);\n\t\t} catch {\n\t\t\tthrow new Error(\"Auto routing could not screen configured credentials. No inference was performed.\");\n\t\t}\n\t\tif (\n\t\t\tcontainsKnownEnvCredential(serialized) ||\n\t\t\tconfiguredCredential ||\n\t\t\t/\\bBearer\\s+[A-Za-z0-9._~+/-]{8,}|-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\\b(?:sk|ghp|github_pat)[-_][A-Za-z0-9_-]{16,}/i.test(\n\t\t\t\tserialized,\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(\"Auto routing context contains credential material. Remove secrets before retrying.\");\n\t\t// Screen the full task first, even credentials in text the router will omit.\n\t\t// Shortening only affects the routing request, never the execution prompt,\n\t\t// so it is not surfaced to the user.\n\t\tstate.task = modelRoutingTask(state.task);\n\t\tconst ranked: ModelRouterOutput[] = [];\n\t\t// Rank by repeated bounded choices, excluding all efforts of earlier models.\n\t\t// Probabilities from separate tournament batches are not comparable.\n\t\tconst deadline = performance.now() + 30_000;\n\t\twhile (ranked.length < Math.min(3, available.length)) {\n\t\t\tconst remaining = pairs.filter((pair) => !ranked.some((selected) => selected.model === pair.model));\n\t\t\tif (!remaining.length) break;\n\t\t\tconst criteria = Object.fromEntries(\n\t\t\t\tremaining.map((pair) => {\n\t\t\t\t\tconst key = `pair_${pairs.indexOf(pair)}`;\n\t\t\t\t\treturn [key, allCriteria[key]];\n\t\t\t\t}),\n\t\t\t);\n\t\t\t// Strict Responses providers reject object unions. Enumerate scalar values\n\t\t\t// on the wire, then verify the exact model/effort relation before admission.\n\t\t\tconst schema = Type.Unsafe<ModelRouterOutput>({\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tmodel: Type.String({ enum: [...new Set(remaining.map((pair) => pair.model))] }),\n\t\t\t\t\teffort: { type: [\"string\", \"null\"], enum: [...new Set(remaining.map((pair) => pair.effort))] },\n\t\t\t\t},\n\t\t\t\trequired: [\"model\", \"effort\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t});\n\t\t\tconst timeoutMs = Math.ceil(deadline - performance.now());\n\t\t\tif (timeoutMs <= 0) throw new Error(\"Auto model ranking timed out; no decision was accepted.\");\n\t\t\tconst result = await inferRouterDecision(\n\t\t\t\t{\n\t\t\t\t\tsettings,\n\t\t\t\t\tmodelRegistry: ctx.modelRegistry,\n\t\t\t\t\tcurrentModel: ctx.model,\n\t\t\t\t\tstate,\n\t\t\t\t\tinstructions,\n\t\t\t\t\tschema,\n\t\t\t\t\tjev: {\n\t\t\t\t\t\tquestions: {\n\t\t\t\t\t\t\tpair: {\n\t\t\t\t\t\t\t\tinstructions:\n\t\t\t\t\t\t\t\t\t\"Which eligible model and reasoning effort best suit this task and agent role, considering the model_selection_guide role tiers, evals, and candidate capabilities and prices? Prefer cheaper candidates for exploration and routine implementation and stronger ones for review and verification. Candidate cost is USD per million tokens, not benchmark task cost.\",\n\t\t\t\t\t\t\t\tcriteria,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdecode: (choices) => {\n\t\t\t\t\t\t\tconst pair = pairs[Number(choices.pair?.replace(/^pair_/, \"\"))];\n\t\t\t\t\t\t\tif (!pair || choices.pair !== `pair_${pairs.indexOf(pair)}`)\n\t\t\t\t\t\t\t\tthrow new Error(\"Invalid execution model Choice.\");\n\t\t\t\t\t\t\treturn { ...pair };\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tsignal,\n\t\t\t\t\ttimeoutMs,\n\t\t\t\t},\n\t\t\t\t(value) => remaining.some((pair) => pair.model === value.model && pair.effort === value.effort),\n\t\t\t);\n\t\t\tranked.push(result.value);\n\t\t}\n\t\tselection = { ...ranked[0]!, ...(ranked.length > 1 ? { fallbacks: ranked.slice(1) } : {}) };\n\t}\n\tconst fallbacks = selection.fallbacks?.map((pair) => Object.freeze({ model: pair.model, effort: pair.effort }));\n\tif (\n\t\tfallbacks &&\n\t\t(fallbacks.length > 2 ||\n\t\t\tnew Set([selection.model, ...fallbacks.map((pair) => pair.model)]).size !== fallbacks.length + 1)\n\t)\n\t\tthrow new Error(\"Invalid ranked auto selection: expected up to three distinct models.\");\n\tconst routerSelection = Object.freeze({\n\t\tmodel: selection.model,\n\t\teffort: selection.effort,\n\t\t...(fallbacks?.length ? { fallbacks: Object.freeze(fallbacks) } : {}),\n\t});\n\tconst hasPair = (pair: ModelRouterOutput) =>\n\t\tcatalog().some((entry) => entry.pairs.some((p) => p.model === pair.model && p.effort === pair.effort));\n\tconst allowsModel = (model: Model<Api>, effort?: string): boolean => {\n\t\tconst levels = model.reasoning ? getSupportedThinkingLevels(model) : [null];\n\t\treturn levels.some((level) => {\n\t\t\tif (model.reasoning && effort !== undefined && level !== effort) return false;\n\t\t\tconst pair = { model: `${model.provider}/${model.id}`, effort: level };\n\t\t\treturn eligiblePair(model, pair, constraints) && hasPair(pair);\n\t\t});\n\t};\n\tconst assertCurrent = () => {\n\t\tsignal?.throwIfAborted();\n\t\tif (![routerSelection, ...(routerSelection.fallbacks ?? [])].every(hasPair))\n\t\t\tthrow new Error(\"Auto selection is no longer eligible. Retry explicitly with the current catalog.\");\n\t};\n\tassertCurrent();\n\treturn {\n\t\trouterSelection,\n\t\tmodelOverride: routerSelection.model + (routerSelection.effort === null ? \"\" : `:${routerSelection.effort}`),\n\t\tfallbackModels: Object.freeze(\n\t\t\t(routerSelection.fallbacks ?? []).map((pair) => pair.model + (pair.effort === null ? \"\" : `:${pair.effort}`)),\n\t\t),\n\t\tassertCurrent,\n\t\tallowsModel,\n\t};\n}\n"]}
@@ -1,4 +1,4 @@
1
- export declare const MODEL_ROUTING_TASK_BYTES = 12000;
1
+ export declare const MODEL_ROUTING_TASK_BYTES = 9000;
2
2
  /** Bound only the model selector's copy. Execution and hard constraints stay intact. */
3
3
  export declare function modelRoutingTask(task: string): string;
4
4
  //# sourceMappingURL=model-routing-task.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-routing-task.d.ts","sourceRoot":"","sources":["../../src/core/model-routing-task.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,QAAS,CAAC;AA4B/C,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAsCrD"}
1
+ {"version":3,"file":"model-routing-task.d.ts","sourceRoot":"","sources":["../../src/core/model-routing-task.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AA4B9C,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAsCrD"}
@@ -1,6 +1,7 @@
1
- // Leave half of Jev's per-question budget for policy, agent metadata and candidate
2
- // batches. Count JSON-encoded UTF-8 bytes, including escapes, not JS characters.
3
- export const MODEL_ROUTING_TASK_BYTES = 12_000;
1
+ // Jev's per-question budget is 30 KB. The task excerpt shares it with the evals
2
+ // document (<= 16 KB), the static model-selection guide (~3 KB), agent metadata and
3
+ // a candidate batch. Count JSON-encoded UTF-8 bytes, including escapes, not JS characters.
4
+ export const MODEL_ROUTING_TASK_BYTES = 9_000;
4
5
  const omitted = "\n[... text omitted for model selection only ...]\n";
5
6
  const notice = "[Model-routing excerpt. Omitted text remains in the execution task.]\n";
6
7
  function protectedRanges(task) {
@@ -1 +1 @@
1
- {"version":3,"file":"model-routing-task.js","sourceRoot":"","sources":["../../src/core/model-routing-task.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,iFAAiF;AACjF,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAC/C,MAAM,OAAO,GAAG,qDAAqD,CAAC;AACtE,MAAM,MAAM,GAAG,wEAAwE,CAAC;AAGxF,SAAS,eAAe,CAAC,IAAY;IACpC,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACzD,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACzB,IAAI,KAAK,EAAE,KAAK,CAAC;gBAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACxC,CAAC;aAAM,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC;YACvC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5D,CAAC;IACF,CAAC;IACD,6EAA6E;IAC7E,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GA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;YACP,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC;QACnB,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["// Leave half of Jev's per-question budget for policy, agent metadata and candidate\n// batches. Count JSON-encoded UTF-8 bytes, including escapes, not JS characters.\nexport const MODEL_ROUTING_TASK_BYTES = 12_000;\nconst omitted = \"\\n[... text omitted for model selection only ...]\\n\";\nconst notice = \"[Model-routing excerpt. Omitted text remains in the execution task.]\\n\";\ntype Range = { start: number; end: number };\n\nfunction protectedRanges(task: string): Range[] {\n\tconst ranges: Range[] = [];\n\tlet depth = 0;\n\tlet start = 0;\n\tfor (const match of task.matchAll(/<\\/?keepContext>/gi)) {\n\t\tif (match[0][1] !== \"/\") {\n\t\t\tif (depth++ === 0) start = match.index;\n\t\t} else if (depth > 0 && --depth === 0) {\n\t\t\tranges.push({ start, end: match.index + match[0].length });\n\t\t}\n\t}\n\t// An unclosed protected span protects through the end rather than losing it.\n\tif (depth > 0) ranges.push({ start, end: task.length });\n\treturn ranges;\n}\n\n// Never split a UTF-16 surrogate pair at an excerpt boundary.\nfunction boundary(task: string, index: number, direction: -1 | 1): number {\n\tconst before = task.charCodeAt(index - 1);\n\tconst after = task.charCodeAt(index);\n\treturn before >= 0xd800 && before <= 0xdbff && after >= 0xdc00 && after <= 0xdfff ? index + direction : index;\n}\n\n/** Bound only the model selector's copy. Execution and hard constraints stay intact. */\nexport function modelRoutingTask(task: string): string {\n\tconst fits = (text: string) => Buffer.byteLength(JSON.stringify(text), \"utf8\") <= MODEL_ROUTING_TASK_BYTES;\n\tif (fits(task)) return task;\n\tconst protectedSpans = protectedRanges(task);\n\tconst excerpt = (edgeChars: number): string => {\n\t\tconst ranges = [\n\t\t\t{ start: 0, end: boundary(task, edgeChars, -1) },\n\t\t\t...protectedSpans,\n\t\t\t{ start: boundary(task, task.length - edgeChars, 1), end: task.length },\n\t\t];\n\t\tconst parts = [notice];\n\t\tlet end = 0;\n\t\tfor (const range of ranges) {\n\t\t\tif (range.end <= end) continue;\n\t\t\tif (range.start > end) parts.push(omitted);\n\t\t\tparts.push(task.slice(Math.max(end, range.start), range.end));\n\t\t\tend = range.end;\n\t\t}\n\t\tif (end < task.length) parts.push(omitted);\n\t\treturn parts.join(\"\");\n\t};\n\tlet result = excerpt(0);\n\t// Keep the original context when protection cannot fit. The existing transport\n\t// budget guard still prevents oversized Jev requests and handles chat fallback.\n\tif (!fits(result)) return task;\n\tlet low = 0;\n\tlet high = Math.min(Math.floor(task.length / 2), MODEL_ROUTING_TASK_BYTES);\n\twhile (low < high) {\n\t\tconst middle = Math.ceil((low + high) / 2);\n\t\tconst candidate = excerpt(middle);\n\t\tif (fits(candidate)) {\n\t\t\tresult = candidate;\n\t\t\tlow = middle;\n\t\t} else {\n\t\t\thigh = middle - 1;\n\t\t}\n\t}\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"model-routing-task.js","sourceRoot":"","sources":["../../src/core/model-routing-task.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oFAAoF;AACpF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,OAAO,GAAG,qDAAqD,CAAC;AACtE,MAAM,MAAM,GAAG,wEAAwE,CAAC;AAGxF,SAAS,eAAe,CAAC,IAAY;IACpC,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACzD,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACzB,IAAI,KAAK,EAAE,KAAK,CAAC;gBAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACxC,CAAC;aAAM,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,KAAK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,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3C,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACrB,MAAM,GAAG,SAAS,CAAC;YACnB,GAAG,GAAG,MAAM,CAAC;QACd,CAAC;aAAM,CAAC;YACP,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC;QACnB,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["// Jev's per-question budget is 30 KB. The task excerpt shares it with the evals\n// document (<= 16 KB), the static model-selection guide (~3 KB), agent metadata and\n// a candidate batch. Count JSON-encoded UTF-8 bytes, including escapes, not JS characters.\nexport const MODEL_ROUTING_TASK_BYTES = 9_000;\nconst omitted = \"\\n[... text omitted for model selection only ...]\\n\";\nconst notice = \"[Model-routing excerpt. Omitted text remains in the execution task.]\\n\";\ntype Range = { start: number; end: number };\n\nfunction protectedRanges(task: string): Range[] {\n\tconst ranges: Range[] = [];\n\tlet depth = 0;\n\tlet start = 0;\n\tfor (const match of task.matchAll(/<\\/?keepContext>/gi)) {\n\t\tif (match[0][1] !== \"/\") {\n\t\t\tif (depth++ === 0) start = match.index;\n\t\t} else if (depth > 0 && --depth === 0) {\n\t\t\tranges.push({ start, end: match.index + match[0].length });\n\t\t}\n\t}\n\t// An unclosed protected span protects through the end rather than losing it.\n\tif (depth > 0) ranges.push({ start, end: task.length });\n\treturn ranges;\n}\n\n// Never split a UTF-16 surrogate pair at an excerpt boundary.\nfunction boundary(task: string, index: number, direction: -1 | 1): number {\n\tconst before = task.charCodeAt(index - 1);\n\tconst after = task.charCodeAt(index);\n\treturn before >= 0xd800 && before <= 0xdbff && after >= 0xdc00 && after <= 0xdfff ? index + direction : index;\n}\n\n/** Bound only the model selector's copy. Execution and hard constraints stay intact. */\nexport function modelRoutingTask(task: string): string {\n\tconst fits = (text: string) => Buffer.byteLength(JSON.stringify(text), \"utf8\") <= MODEL_ROUTING_TASK_BYTES;\n\tif (fits(task)) return task;\n\tconst protectedSpans = protectedRanges(task);\n\tconst excerpt = (edgeChars: number): string => {\n\t\tconst ranges = [\n\t\t\t{ start: 0, end: boundary(task, edgeChars, -1) },\n\t\t\t...protectedSpans,\n\t\t\t{ start: boundary(task, task.length - edgeChars, 1), end: task.length },\n\t\t];\n\t\tconst parts = [notice];\n\t\tlet end = 0;\n\t\tfor (const range of ranges) {\n\t\t\tif (range.end <= end) continue;\n\t\t\tif (range.start > end) parts.push(omitted);\n\t\t\tparts.push(task.slice(Math.max(end, range.start), range.end));\n\t\t\tend = range.end;\n\t\t}\n\t\tif (end < task.length) parts.push(omitted);\n\t\treturn parts.join(\"\");\n\t};\n\tlet result = excerpt(0);\n\t// Keep the original context when protection cannot fit. The existing transport\n\t// budget guard still prevents oversized Jev requests and handles chat fallback.\n\tif (!fits(result)) return task;\n\tlet low = 0;\n\tlet high = Math.min(Math.floor(task.length / 2), MODEL_ROUTING_TASK_BYTES);\n\twhile (low < high) {\n\t\tconst middle = Math.ceil((low + high) / 2);\n\t\tconst candidate = excerpt(middle);\n\t\tif (fits(candidate)) {\n\t\t\tresult = candidate;\n\t\t\tlow = middle;\n\t\t} else {\n\t\t\thigh = middle - 1;\n\t\t}\n\t}\n\treturn result;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAIhE,MAAM,WAAW,iBAAiB;IACjC,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,wBAAwB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B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,MAAM,EAAE,KAAK,EAAE,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAG1D,gGAAgG;AAChG,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,wBAAwB,GAAG,kCAAkC,CAmBrH;AAgED,6FAA6F;AAC7F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,wBAAwB,GAAG,oBAAoB,CA0E/F;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,wBAAwB,GAAG;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CAChC,CAGA;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EACvC,OAAO,EAAE,oBAAoB,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,SAAS,CAS3C"}
@@ -71,6 +71,7 @@ function buildRules(selectedTools, toolGuidelines, promptGuidelines) {
71
71
  }
72
72
  for (const rule of promptGuidelines)
73
73
  addRule(rule);
74
+ addRule("Write self-describing code and do not add comments unless the user explicitly asks for them or the task instructions call for them. Code that needs a comment to be understood is a smell: restructure it with clearer names, smaller units, or explicit types instead");
74
75
  addRule("Be concise in your responses");
75
76
  addRule("Show file paths clearly when working with files");
76
77
  return rules.map((rule) => `- ${rule}`).join("\n");
@@ -113,7 +114,7 @@ Atomic documentation (read when the user asks about model choice, computer use o
113
114
  - When asked about: atomic workflows (docs/workflows.md), extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), atomic packages (docs/packages.md)
114
115
  - Bundled integrations use the same docs root in npm and binary installations: MCP servers (docs/mcp-servers.md), web access (docs/web-access.md), intercom (docs/intercom.md), subagents (docs/subagents.md), workflows (docs/workflows.md). Read these guides rather than guessing paths inside builtin packages.
115
116
  - When the user asks which model to choose for a task, read ${docsPath}/models/model-selection.md and ${docsPath}/models/evals.md, then consult https://artificialanalysis.ai/ for the relevant benchmark charts and methodology. Match the task to individual evaluations rather than an aggregate winner. Cite the benchmark, source date, exact model/effort and cost or latency tradeoff; distinguish measured results from recommendations. If live evidence is unavailable, label the dated docs snapshot instead of claiming a refresh. Check the configured catalog before giving an exact provider/model or thinking setting; catalog presence is not proof of live access.
116
- - For computer use (CUA), use PyAutoGUI for desktop mouse, keyboard and screenshot automation; for browser automation use the playwright-cli skill. For terminal automation/testing, prefer herdr on macOS, Linux and Windows; install it if missing when network access and permissions permit, and fall back to tmux or native Windows psmux if installation or use is not possible. Load the matching skill and ${docsPath}/workflows/verification.md. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed capabilities, use dedicated sessions, preserve desktop failsafes and permissions, and release held input on interruption. These CLIs are not interchangeable, and skills do not grant tools or authorization.
117
+ - For computer use (CUA), use PyAutoGUI for desktop mouse, keyboard and screenshot automation; for browser automation use the agent-browser skill. For terminal automation/testing, prefer herdr on macOS, Linux and Windows; install it if missing when network access and permissions permit, and fall back to tmux or native Windows psmux if installation or use is not possible. Load the matching skill and ${docsPath}/workflows/verification.md. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed capabilities, use dedicated sessions, preserve desktop failsafes and permissions, and release held input on interruption. These CLIs are not interchangeable, and skills do not grant tools or authorization.
117
118
  - When working on Atomic topics, read the docs and examples, and follow .md cross-references before implementing
118
119
  - Always read Atomic .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;
119
120
  }
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAEhE,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,CAAU,CAAC;AA4DvH,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AACxD,gGAAgG;AAChG,MAAM,UAAU,iCAAiC,CAAC,KAA+B;IAChF,OAAO;QACN,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,aAAa,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,oBAAoB,CAAC,CAAC;QACjE,YAAY,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE;QAC/C,cAAc,EAAE,MAAM,CAAC,WAAW,CACjC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAC/F;QACD,gBAAgB,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,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,IAAI,CAAC,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjD,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1C,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getSystemMessageText } from \"@bastani/pi-ai\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nconst DEFAULT_PROMPT_TOOLS = [\"read\", \"bash\", \"edit\", \"write\", \"find\", \"search\", \"ask_user_question\", \"todo\"] as const;\n\nexport interface SystemPromptModel {\n\t/** Provider identifier for the selected model. */\n\tprovider: string;\n\t/** Stable provider-specific model identifier. */\n\tid: string;\n\t/** Human-readable model name, when available. */\n\tname?: string;\n}\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces the default prefix). */\n\tcustomPrompt?: string;\n\t/** Exact full prompt replacement set by a before_agent_start handler. */\n\tforceSystemPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write, find, search, ask_user_question, todo] */\n\tselectedTools?: string[];\n\t/** Tool names explicitly excluded by the caller and omitted from generated guidance. */\n\texcludedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Guideline bullets contributed by each tool, keyed by tool name. */\n\ttoolGuidelines?: Record<string, string[]>;\n\t/** Additional guideline bullets appended to the default system prompt rules. */\n\tpromptGuidelines?: string[];\n\t/** Text appended from user configuration before project context, skills, and cwd. */\n\tappendSystemPrompt?: string;\n\t/** Additional XML-wrapped prompt sections keyed by tag name. */\n\tsections?: Record<string, string>;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Currently selected model, used for model-aware prompt metadata. */\n\tselectedModel?: SystemPromptModel;\n\t/** Current reasoning/thinking level for the selected model. */\n\tselectedThinkingLevel?: string;\n\t/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n}\n\nexport type NormalizedBuildSystemPromptOptions = BuildSystemPromptOptions & {\n\tselectedTools: string[];\n\ttoolSnippets: Record<string, string>;\n\ttoolGuidelines: Record<string, string[]>;\n\tpromptGuidelines: string[];\n\tappendSystemPrompt: string;\n\tsections: Record<string, string>;\n\tcontextFiles: Array<{ path: string; content: string }>;\n\tskills: Skill[];\n};\n\n/**\n * Ordered system prompt sections, keyed by name. `preamble` is untagged text; every other\n * section is wrapped in a tag of the same name so the model can match later updates to it.\n * These become `SystemMessage.sections` in the transcript.\n */\nexport type SystemPromptSections = Record<string, string>;\n\nconst SYSTEM_PROMPT_SECTION_NAME = /^[a-z][a-z0-9_-]*$/;\n/** Normalize prompt input into the mutable, collection-complete shape exposed to extensions. */\nexport function normalizeBuildSystemPromptOptions(input: BuildSystemPromptOptions): NormalizedBuildSystemPromptOptions {\n\treturn {\n\t\tcustomPrompt: input.customPrompt,\n\t\tforceSystemPrompt: input.forceSystemPrompt,\n\t\tselectedTools: [...(input.selectedTools ?? DEFAULT_PROMPT_TOOLS)],\n\t\ttoolSnippets: { ...(input.toolSnippets ?? {}) },\n\t\ttoolGuidelines: Object.fromEntries(\n\t\t\tObject.entries(input.toolGuidelines ?? {}).map(([name, guidelines]) => [name, [...guidelines]]),\n\t\t),\n\t\tpromptGuidelines: [...(input.promptGuidelines ?? [])],\n\t\tappendSystemPrompt: input.appendSystemPrompt ?? \"\",\n\t\tsections: { ...(input.sections ?? {}) },\n\t\tcwd: input.cwd,\n\t\t...(input.excludedTools === undefined ? {} : { excludedTools: [...input.excludedTools] }),\n\t\t...(input.selectedModel === undefined ? {} : { selectedModel: { ...input.selectedModel } }),\n\t\t...(input.selectedThinkingLevel === undefined ? {} : { selectedThinkingLevel: input.selectedThinkingLevel }),\n\t\tcontextFiles: (input.contextFiles ?? []).map((file) => ({ ...file })),\n\t\tskills: (input.skills ?? []).map((skill) => ({ ...skill })),\n\t};\n}\n\nfunction renderProjectContext(contextFiles: Array<{ path: string; content: string }>): string {\n\treturn [\n\t\t\"Project-specific instructions and guidelines:\",\n\t\t...contextFiles.map(\n\t\t\t({ path, content }) => `<project_instructions path=\"${path}\">\\n${content}\\n</project_instructions>`,\n\t\t),\n\t].join(\"\\n\\n\");\n}\n\nfunction buildRules(\n\tselectedTools: string[],\n\ttoolGuidelines: Record<string, string[]>,\n\tpromptGuidelines: string[],\n): string {\n\tconst rules: string[] = [];\n\tconst seen = new Set<string>();\n\tconst addRule = (rule: string): void => {\n\t\tconst normalized = rule.trim();\n\t\tif (!normalized || seen.has(normalized)) return;\n\t\tseen.add(normalized);\n\t\trules.push(normalized);\n\t};\n\n\tconst tools = selectedTools;\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasPowerShell = tools.includes(\"powershell\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst shouldIncludeAskUserFallbackGuidance = tools.length > 0 && !tools.includes(\"ask_user_question\");\n\tconst addGuideline = addRule;\n\tif ((hasBash || hasPowerShell) && !hasFind && !hasLs) {\n\t\tif (hasBash && hasPowerShell) {\n\t\t\taddRule(\"Use bash or PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else if (hasPowerShell) {\n\t\t\taddRule(\"Use PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else {\n\t\t\taddRule(\"Use bash for file operations like ls, rg, find\");\n\t\t}\n\t}\n\tif (shouldIncludeAskUserFallbackGuidance) {\n\t\taddGuideline(\n\t\t\t\"If an equivalent user-question tool is available, use it for all questions to the user instead of plain text, including confirmations and approvals, following its supported schema. When no usable question tool or human-input channel exists, do not stall on a question: choose the interpretation best supported by the repository and the stated objective, state the assumption in your response, and continue fully autonomously on best judgment. Tool unavailability alone is not a blocker. Preserve safety and authorization constraints.\",\n\t\t);\n\t}\n\tif (hasBash || hasPowerShell) {\n\t\taddGuideline(\n\t\t\t\"**Repository intent**: When working in a repository, infer how its maintainers actually work before imposing defaults: review recent commits, open and merged PRs, issues and their comments, and project/board status when tooling allows (for example `git log` and the `gh` CLI) to learn conventions, priorities, and scope norms. Better, identify the requesting user (`git config user.name`/`user.email`, `gh api user`) and study their own commits, PRs, reviews, and issue comments so you interpret ambiguous requests the way they would, aligning style, scope, and process with their patterns.\",\n\t\t);\n\t}\n\n\tfor (const name of selectedTools) {\n\t\tfor (const rule of toolGuidelines[name] ?? []) addRule(rule);\n\t}\n\tfor (const rule of promptGuidelines) addRule(rule);\n\taddRule(\"Be concise in your responses\");\n\taddRule(\"Show file paths clearly when working with files\");\n\treturn rules.map((rule) => `- ${rule}`).join(\"\\n\");\n}\n\n/** Build the ordered, independently replaceable sections of the structured system prompt. */\nexport function buildSystemPromptSections(input: BuildSystemPromptOptions): SystemPromptSections {\n\tconst options = normalizeBuildSystemPromptOptions(input);\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\ttoolGuidelines,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tsections: customSections,\n\t\tcwd,\n\t\tcontextFiles,\n\t\tskills,\n\t} = options;\n\tconst explicitlyExcludedTools = new Set(options.excludedTools ?? []);\n\tconst tools = selectedTools.filter((name) => !explicitlyExcludedTools.has(name));\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\tconst modelName = options.selectedModel?.name?.trim() || options.selectedModel?.id || \"unknown\";\n\tconst modelReasoningLevel = options.selectedThinkingLevel?.trim() || \"off\";\n\tconst now = new Date();\n\tconst date = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}`;\n\n\tfor (const name of Object.keys(customSections)) {\n\t\tif (!SYSTEM_PROMPT_SECTION_NAME.test(name) || name === \"preamble\") {\n\t\t\tthrow new Error(`Invalid system prompt section name: ${name}`);\n\t\t}\n\t}\n\n\tconst promptSections: Record<string, string> = {};\n\tif (customPrompt) {\n\t\tpromptSections.preamble = customPrompt;\n\t} else {\n\t\tpromptSections.preamble =\n\t\t\t\"You are an expert coding assistant operating named Atomic, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\";\n\t\tconst visibleTools = tools.filter((name) => !!toolSnippets[name]);\n\t\tconst toolsList =\n\t\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets[name]}`).join(\"\\n\") : \"(none)\";\n\t\tpromptSections.tools = `Available tools:\\n${toolsList}\\n\\nIn addition to the tools above, you may have access to other custom tools depending on the project.`;\n\t\tpromptSections.rules = `Guidelines:\\n${buildRules(tools, toolGuidelines, promptGuidelines)}`;\n\t\tpromptSections.docs = `\nAtomic documentation (read when the user asks about model choice, computer use or automation, MCP, web access, intercom, subagents, or customizing Atomic itself, its SDK, creating workflows, packages, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- Docs/examples references above must be resolved against these absolute roots; e.g. docs/foo.md means ${docsPath}/foo.md and examples/bar means ${examplesPath}/bar.\n- When asked about: atomic workflows (docs/workflows.md), extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), atomic packages (docs/packages.md)\n- Bundled integrations use the same docs root in npm and binary installations: MCP servers (docs/mcp-servers.md), web access (docs/web-access.md), intercom (docs/intercom.md), subagents (docs/subagents.md), workflows (docs/workflows.md). Read these guides rather than guessing paths inside builtin packages.\n- When the user asks which model to choose for a task, read ${docsPath}/models/model-selection.md and ${docsPath}/models/evals.md, then consult https://artificialanalysis.ai/ for the relevant benchmark charts and methodology. Match the task to individual evaluations rather than an aggregate winner. Cite the benchmark, source date, exact model/effort and cost or latency tradeoff; distinguish measured results from recommendations. If live evidence is unavailable, label the dated docs snapshot instead of claiming a refresh. Check the configured catalog before giving an exact provider/model or thinking setting; catalog presence is not proof of live access.\n- For computer use (CUA), use PyAutoGUI for desktop mouse, keyboard and screenshot automation; for browser automation use the playwright-cli skill. For terminal automation/testing, prefer herdr on macOS, Linux and Windows; install it if missing when network access and permissions permit, and fall back to tmux or native Windows psmux if installation or use is not possible. Load the matching skill and ${docsPath}/workflows/verification.md. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed capabilities, use dedicated sessions, preserve desktop failsafes and permissions, and release held input on interruption. These CLIs are not interchangeable, and skills do not grant tools or authorization.\n- When working on Atomic topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read Atomic .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\t}\n\n\tif (appendSystemPrompt) promptSections.addendum = appendSystemPrompt;\n\tif (contextFiles.length > 0) promptSections.project_context = renderProjectContext(contextFiles);\n\tconst skillFileReadTool = ([\"read\", \"bash\"] as const).find((tool) => tools.includes(tool));\n\tif (skillFileReadTool && skills.length > 0) {\n\t\tconst skillsPrompt = formatSkillsForPrompt(skills, skillFileReadTool).trim();\n\t\tif (skillsPrompt) promptSections.skills = skillsPrompt;\n\t}\n\tpromptSections.model = `Model name (used for commit attribution): ${modelName}\\nModel reasoning level: ${modelReasoningLevel}`;\n\tpromptSections.date = `Current date: ${date}`;\n\tpromptSections.cwd = `Current working directory: ${cwd.replace(/\\\\/g, \"/\")}`;\n\tfor (const [name, content] of Object.entries(customSections)) {\n\t\tif (content) promptSections[name] = content;\n\t}\n\n\tconst sections: SystemPromptSections = { preamble: promptSections.preamble };\n\tfor (const [name, content] of Object.entries(promptSections)) {\n\t\tif (name !== \"preamble\") sections[name] = `<${name}>\\n${content}\\n</${name}>`;\n\t}\n\treturn sections;\n}\n\n/**\n * The complete prompt state for `input`. A forced prompt is opaque and lives in `content`\n * with no sections; otherwise `content` is empty and the structured sections carry the prompt.\n */\nexport function buildSystemPromptState(input: BuildSystemPromptOptions): {\n\tcontent: string;\n\tsections?: SystemPromptSections;\n} {\n\tif (input.forceSystemPrompt !== undefined) return { content: input.forceSystemPrompt };\n\treturn { content: \"\", sections: buildSystemPromptSections(input) };\n}\n\n/** Build the system prompt text, rendered exactly as the transcript's system message replays it. */\nexport function buildSystemPrompt(input: BuildSystemPromptOptions): string {\n\treturn getSystemMessageText({ role: \"system\", ...buildSystemPromptState(input), timestamp: 0 });\n}\n\n/**\n * Diff the sections the model currently has (replayed from the transcript, so never null)\n * against the desired ones. Returns a `SystemMessage.sections` patch, or undefined when\n * nothing changed.\n */\nexport function diffSystemPromptSections(\n\tprevious: Record<string, string | null>,\n\tcurrent: SystemPromptSections,\n): Record<string, string | null> | undefined {\n\tconst patch: Record<string, string | null> = {};\n\tfor (const [name, text] of Object.entries(current)) {\n\t\tif (previous[name] !== text) patch[name] = text;\n\t}\n\tfor (const name of Object.keys(previous)) {\n\t\tif (current[name] === undefined) patch[name] = null;\n\t}\n\treturn Object.keys(patch).length > 0 ? patch : undefined;\n}\n"]}
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAEhE,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAM,EAA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astani/pi-ai\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nconst DEFAULT_PROMPT_TOOLS = [\"read\", \"bash\", \"edit\", \"write\", \"find\", \"search\", \"ask_user_question\", \"todo\"] as const;\n\nexport interface SystemPromptModel {\n\t/** Provider identifier for the selected model. */\n\tprovider: string;\n\t/** Stable provider-specific model identifier. */\n\tid: string;\n\t/** Human-readable model name, when available. */\n\tname?: string;\n}\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces the default prefix). */\n\tcustomPrompt?: string;\n\t/** Exact full prompt replacement set by a before_agent_start handler. */\n\tforceSystemPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write, find, search, ask_user_question, todo] */\n\tselectedTools?: string[];\n\t/** Tool names explicitly excluded by the caller and omitted from generated guidance. */\n\texcludedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Guideline bullets contributed by each tool, keyed by tool name. */\n\ttoolGuidelines?: Record<string, string[]>;\n\t/** Additional guideline bullets appended to the default system prompt rules. */\n\tpromptGuidelines?: string[];\n\t/** Text appended from user configuration before project context, skills, and cwd. */\n\tappendSystemPrompt?: string;\n\t/** Additional XML-wrapped prompt sections keyed by tag name. */\n\tsections?: Record<string, string>;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Currently selected model, used for model-aware prompt metadata. */\n\tselectedModel?: SystemPromptModel;\n\t/** Current reasoning/thinking level for the selected model. */\n\tselectedThinkingLevel?: string;\n\t/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n}\n\nexport type NormalizedBuildSystemPromptOptions = BuildSystemPromptOptions & {\n\tselectedTools: string[];\n\ttoolSnippets: Record<string, string>;\n\ttoolGuidelines: Record<string, string[]>;\n\tpromptGuidelines: string[];\n\tappendSystemPrompt: string;\n\tsections: Record<string, string>;\n\tcontextFiles: Array<{ path: string; content: string }>;\n\tskills: Skill[];\n};\n\n/**\n * Ordered system prompt sections, keyed by name. `preamble` is untagged text; every other\n * section is wrapped in a tag of the same name so the model can match later updates to it.\n * These become `SystemMessage.sections` in the transcript.\n */\nexport type SystemPromptSections = Record<string, string>;\n\nconst SYSTEM_PROMPT_SECTION_NAME = /^[a-z][a-z0-9_-]*$/;\n/** Normalize prompt input into the mutable, collection-complete shape exposed to extensions. */\nexport function normalizeBuildSystemPromptOptions(input: BuildSystemPromptOptions): NormalizedBuildSystemPromptOptions {\n\treturn {\n\t\tcustomPrompt: input.customPrompt,\n\t\tforceSystemPrompt: input.forceSystemPrompt,\n\t\tselectedTools: [...(input.selectedTools ?? DEFAULT_PROMPT_TOOLS)],\n\t\ttoolSnippets: { ...(input.toolSnippets ?? {}) },\n\t\ttoolGuidelines: Object.fromEntries(\n\t\t\tObject.entries(input.toolGuidelines ?? {}).map(([name, guidelines]) => [name, [...guidelines]]),\n\t\t),\n\t\tpromptGuidelines: [...(input.promptGuidelines ?? [])],\n\t\tappendSystemPrompt: input.appendSystemPrompt ?? \"\",\n\t\tsections: { ...(input.sections ?? {}) },\n\t\tcwd: input.cwd,\n\t\t...(input.excludedTools === undefined ? {} : { excludedTools: [...input.excludedTools] }),\n\t\t...(input.selectedModel === undefined ? {} : { selectedModel: { ...input.selectedModel } }),\n\t\t...(input.selectedThinkingLevel === undefined ? {} : { selectedThinkingLevel: input.selectedThinkingLevel }),\n\t\tcontextFiles: (input.contextFiles ?? []).map((file) => ({ ...file })),\n\t\tskills: (input.skills ?? []).map((skill) => ({ ...skill })),\n\t};\n}\n\nfunction renderProjectContext(contextFiles: Array<{ path: string; content: string }>): string {\n\treturn [\n\t\t\"Project-specific instructions and guidelines:\",\n\t\t...contextFiles.map(\n\t\t\t({ path, content }) => `<project_instructions path=\"${path}\">\\n${content}\\n</project_instructions>`,\n\t\t),\n\t].join(\"\\n\\n\");\n}\n\nfunction buildRules(\n\tselectedTools: string[],\n\ttoolGuidelines: Record<string, string[]>,\n\tpromptGuidelines: string[],\n): string {\n\tconst rules: string[] = [];\n\tconst seen = new Set<string>();\n\tconst addRule = (rule: string): void => {\n\t\tconst normalized = rule.trim();\n\t\tif (!normalized || seen.has(normalized)) return;\n\t\tseen.add(normalized);\n\t\trules.push(normalized);\n\t};\n\n\tconst tools = selectedTools;\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasPowerShell = tools.includes(\"powershell\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst shouldIncludeAskUserFallbackGuidance = tools.length > 0 && !tools.includes(\"ask_user_question\");\n\tconst addGuideline = addRule;\n\tif ((hasBash || hasPowerShell) && !hasFind && !hasLs) {\n\t\tif (hasBash && hasPowerShell) {\n\t\t\taddRule(\"Use bash or PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else if (hasPowerShell) {\n\t\t\taddRule(\"Use PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else {\n\t\t\taddRule(\"Use bash for file operations like ls, rg, find\");\n\t\t}\n\t}\n\tif (shouldIncludeAskUserFallbackGuidance) {\n\t\taddGuideline(\n\t\t\t\"If an equivalent user-question tool is available, use it for all questions to the user instead of plain text, including confirmations and approvals, following its supported schema. When no usable question tool or human-input channel exists, do not stall on a question: choose the interpretation best supported by the repository and the stated objective, state the assumption in your response, and continue fully autonomously on best judgment. Tool unavailability alone is not a blocker. Preserve safety and authorization constraints.\",\n\t\t);\n\t}\n\tif (hasBash || hasPowerShell) {\n\t\taddGuideline(\n\t\t\t\"**Repository intent**: When working in a repository, infer how its maintainers actually work before imposing defaults: review recent commits, open and merged PRs, issues and their comments, and project/board status when tooling allows (for example `git log` and the `gh` CLI) to learn conventions, priorities, and scope norms. Better, identify the requesting user (`git config user.name`/`user.email`, `gh api user`) and study their own commits, PRs, reviews, and issue comments so you interpret ambiguous requests the way they would, aligning style, scope, and process with their patterns.\",\n\t\t);\n\t}\n\n\tfor (const name of selectedTools) {\n\t\tfor (const rule of toolGuidelines[name] ?? []) addRule(rule);\n\t}\n\tfor (const rule of promptGuidelines) addRule(rule);\n\taddRule(\n\t\t\"Write self-describing code and do not add comments unless the user explicitly asks for them or the task instructions call for them. Code that needs a comment to be understood is a smell: restructure it with clearer names, smaller units, or explicit types instead\",\n\t);\n\taddRule(\"Be concise in your responses\");\n\taddRule(\"Show file paths clearly when working with files\");\n\treturn rules.map((rule) => `- ${rule}`).join(\"\\n\");\n}\n\n/** Build the ordered, independently replaceable sections of the structured system prompt. */\nexport function buildSystemPromptSections(input: BuildSystemPromptOptions): SystemPromptSections {\n\tconst options = normalizeBuildSystemPromptOptions(input);\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\ttoolGuidelines,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tsections: customSections,\n\t\tcwd,\n\t\tcontextFiles,\n\t\tskills,\n\t} = options;\n\tconst explicitlyExcludedTools = new Set(options.excludedTools ?? []);\n\tconst tools = selectedTools.filter((name) => !explicitlyExcludedTools.has(name));\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\tconst modelName = options.selectedModel?.name?.trim() || options.selectedModel?.id || \"unknown\";\n\tconst modelReasoningLevel = options.selectedThinkingLevel?.trim() || \"off\";\n\tconst now = new Date();\n\tconst date = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}`;\n\n\tfor (const name of Object.keys(customSections)) {\n\t\tif (!SYSTEM_PROMPT_SECTION_NAME.test(name) || name === \"preamble\") {\n\t\t\tthrow new Error(`Invalid system prompt section name: ${name}`);\n\t\t}\n\t}\n\n\tconst promptSections: Record<string, string> = {};\n\tif (customPrompt) {\n\t\tpromptSections.preamble = customPrompt;\n\t} else {\n\t\tpromptSections.preamble =\n\t\t\t\"You are an expert coding assistant operating named Atomic, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\";\n\t\tconst visibleTools = tools.filter((name) => !!toolSnippets[name]);\n\t\tconst toolsList =\n\t\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets[name]}`).join(\"\\n\") : \"(none)\";\n\t\tpromptSections.tools = `Available tools:\\n${toolsList}\\n\\nIn addition to the tools above, you may have access to other custom tools depending on the project.`;\n\t\tpromptSections.rules = `Guidelines:\\n${buildRules(tools, toolGuidelines, promptGuidelines)}`;\n\t\tpromptSections.docs = `\nAtomic documentation (read when the user asks about model choice, computer use or automation, MCP, web access, intercom, subagents, or customizing Atomic itself, its SDK, creating workflows, packages, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- Docs/examples references above must be resolved against these absolute roots; e.g. docs/foo.md means ${docsPath}/foo.md and examples/bar means ${examplesPath}/bar.\n- When asked about: atomic workflows (docs/workflows.md), extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), atomic packages (docs/packages.md)\n- Bundled integrations use the same docs root in npm and binary installations: MCP servers (docs/mcp-servers.md), web access (docs/web-access.md), intercom (docs/intercom.md), subagents (docs/subagents.md), workflows (docs/workflows.md). Read these guides rather than guessing paths inside builtin packages.\n- When the user asks which model to choose for a task, read ${docsPath}/models/model-selection.md and ${docsPath}/models/evals.md, then consult https://artificialanalysis.ai/ for the relevant benchmark charts and methodology. Match the task to individual evaluations rather than an aggregate winner. Cite the benchmark, source date, exact model/effort and cost or latency tradeoff; distinguish measured results from recommendations. If live evidence is unavailable, label the dated docs snapshot instead of claiming a refresh. Check the configured catalog before giving an exact provider/model or thinking setting; catalog presence is not proof of live access.\n- For computer use (CUA), use PyAutoGUI for desktop mouse, keyboard and screenshot automation; for browser automation use the agent-browser skill. For terminal automation/testing, prefer herdr on macOS, Linux and Windows; install it if missing when network access and permissions permit, and fall back to tmux or native Windows psmux if installation or use is not possible. Load the matching skill and ${docsPath}/workflows/verification.md. Preserve the pinned herdr skill's explicit-request and HERDR_ENV=1 requirements; never control a focused session from outside Herdr. Check installed capabilities, use dedicated sessions, preserve desktop failsafes and permissions, and release held input on interruption. These CLIs are not interchangeable, and skills do not grant tools or authorization.\n- When working on Atomic topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read Atomic .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\t}\n\n\tif (appendSystemPrompt) promptSections.addendum = appendSystemPrompt;\n\tif (contextFiles.length > 0) promptSections.project_context = renderProjectContext(contextFiles);\n\tconst skillFileReadTool = ([\"read\", \"bash\"] as const).find((tool) => tools.includes(tool));\n\tif (skillFileReadTool && skills.length > 0) {\n\t\tconst skillsPrompt = formatSkillsForPrompt(skills, skillFileReadTool).trim();\n\t\tif (skillsPrompt) promptSections.skills = skillsPrompt;\n\t}\n\tpromptSections.model = `Model name (used for commit attribution): ${modelName}\\nModel reasoning level: ${modelReasoningLevel}`;\n\tpromptSections.date = `Current date: ${date}`;\n\tpromptSections.cwd = `Current working directory: ${cwd.replace(/\\\\/g, \"/\")}`;\n\tfor (const [name, content] of Object.entries(customSections)) {\n\t\tif (content) promptSections[name] = content;\n\t}\n\n\tconst sections: SystemPromptSections = { preamble: promptSections.preamble };\n\tfor (const [name, content] of Object.entries(promptSections)) {\n\t\tif (name !== \"preamble\") sections[name] = `<${name}>\\n${content}\\n</${name}>`;\n\t}\n\treturn sections;\n}\n\n/**\n * The complete prompt state for `input`. A forced prompt is opaque and lives in `content`\n * with no sections; otherwise `content` is empty and the structured sections carry the prompt.\n */\nexport function buildSystemPromptState(input: BuildSystemPromptOptions): {\n\tcontent: string;\n\tsections?: SystemPromptSections;\n} {\n\tif (input.forceSystemPrompt !== undefined) return { content: input.forceSystemPrompt };\n\treturn { content: \"\", sections: buildSystemPromptSections(input) };\n}\n\n/** Build the system prompt text, rendered exactly as the transcript's system message replays it. */\nexport function buildSystemPrompt(input: BuildSystemPromptOptions): string {\n\treturn getSystemMessageText({ role: \"system\", ...buildSystemPromptState(input), timestamp: 0 });\n}\n\n/**\n * Diff the sections the model currently has (replayed from the transcript, so never null)\n * against the desired ones. Returns a `SystemMessage.sections` patch, or undefined when\n * nothing changed.\n */\nexport function diffSystemPromptSections(\n\tprevious: Record<string, string | null>,\n\tcurrent: SystemPromptSections,\n): Record<string, string | null> | undefined {\n\tconst patch: Record<string, string | null> = {};\n\tfor (const [name, text] of Object.entries(current)) {\n\t\tif (previous[name] !== text) patch[name] = text;\n\t}\n\tfor (const name of Object.keys(previous)) {\n\t\tif (current[name] === undefined) patch[name] = null;\n\t}\n\treturn Object.keys(patch).length > 0 ? patch : undefined;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -62,7 +62,7 @@ export { ArminComponent, AssistantMessageComponent, BashExecutionComponent, Bord
62
62
  export { classifyChatCommand, createSessionSkillAutocompleteProvider, getSessionSkillCommands, } from "./modes/interactive/skill-command-autocomplete.ts";
63
63
  export { getLanguageFromPath, getMarkdownTheme, getSelectListTheme, getSettingsListTheme, highlightCode, initTheme, Theme, type ThemeColor, } from "./modes/interactive/theme/theme.js";
64
64
  export { pickWhimsicalWorkingMessage } from "./modes/interactive/whimsical-messages.ts";
65
- export { createChildProcessEnvironment } from "./utils/child-process.ts";
65
+ export { createChildProcessEnvironment, spawnProcess } from "./utils/child-process.ts";
66
66
  export { copyToClipboard } from "./utils/clipboard.ts";
67
67
  export { parseFrontmatter, stripFrontmatter } from "./utils/frontmatter.ts";
68
68
  export { isSafeFsWatchPathError, isUnsafeWindowsShortPath, resolveNativeWatchPath, SAFE_FS_WATCH_CANONICALIZATION_FAILED, SAFE_FS_WATCH_UNSAFE_WINDOWS_SHORT_PATH, type SafeFsWatchErrorCode, type SafeFsWatchPathError, watchWithErrorHand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ACb,SAAS,EACT,KAAK,EACL,KAAK,UAAU,GACf,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,6BAA6B,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EACN,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,qCAAqC,EACrC,uCAAuC,EACvC,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,KAAK,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC3G,OAAO,EAAE,oCAAoC,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ export { classifyChatCommand, createSessionSkillAutocompleteProvider, getSession
73
73
  export { getLanguageFromPath, getMarkdownTheme, getSelectListTheme, getSettingsListTheme, highlightCode, initTheme, Theme, } from "./modes/interactive/theme/theme.js";
74
74
  // Run modes for programmatic SDK usage
75
75
  export { pickWhimsicalWorkingMessage } from "./modes/interactive/whimsical-messages.js";
76
- export { createChildProcessEnvironment } from "./utils/child-process.js";
76
+ export { createChildProcessEnvironment, spawnProcess } from "./utils/child-process.js";
77
77
  // Clipboard utilities
78
78
  export { copyToClipboard } from "./utils/clipboard.js";
79
79
  export { parseFrontmatter, stripFrontmatter } from "./utils/frontmatter.js";