agentplane 0.3.12 → 0.3.14

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 (376) hide show
  1. package/assets/RUNNER.md +1 -1
  2. package/assets/agents/ORCHESTRATOR.json +1 -1
  3. package/assets/agents/SKILL_EXTRACTOR.json +31 -0
  4. package/assets/codex-plugin/assets/header.png +0 -0
  5. package/assets/codex-plugin/assets/icon.svg +1 -0
  6. package/assets/codex-plugin/assets/logo.svg +1 -0
  7. package/assets/codex-plugin/skills/agentplane/SKILL.md +35 -0
  8. package/assets/framework.manifest.json +7 -0
  9. package/assets/policy/governance.md +4 -2
  10. package/assets/policy/incidents.md +4 -19
  11. package/assets/policy/workflow.branch_pr.md +10 -5
  12. package/assets/policy/workflow.release.md +5 -2
  13. package/dist/.build-manifest.json +409 -219
  14. package/dist/cli/exit-codes.d.ts.map +1 -1
  15. package/dist/cli/exit-codes.js +1 -0
  16. package/dist/cli/output.d.ts +29 -0
  17. package/dist/cli/output.d.ts.map +1 -1
  18. package/dist/cli/output.js +33 -0
  19. package/dist/cli/reason-codes.d.ts +1 -1
  20. package/dist/cli/reason-codes.d.ts.map +1 -1
  21. package/dist/cli/reason-codes.js +12 -0
  22. package/dist/cli/run-cli/command-catalog/core.d.ts +1 -1
  23. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  24. package/dist/cli/run-cli/command-catalog/core.js +36 -78
  25. package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
  26. package/dist/cli/run-cli/command-catalog/lifecycle.js +4 -12
  27. package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
  28. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  29. package/dist/cli/run-cli/command-catalog/project.js +27 -31
  30. package/dist/cli/run-cli/command-catalog/shared.d.ts +9 -6
  31. package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
  32. package/dist/cli/run-cli/command-catalog/shared.js +23 -6
  33. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  34. package/dist/cli/run-cli/command-catalog/task.js +6 -18
  35. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  36. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  37. package/dist/cli/run-cli/commands/codex.d.ts +14 -0
  38. package/dist/cli/run-cli/commands/codex.d.ts.map +1 -0
  39. package/dist/cli/run-cli/commands/codex.js +100 -0
  40. package/dist/cli/run-cli/commands/core.d.ts +1 -0
  41. package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
  42. package/dist/cli/run-cli/commands/core.js +1 -0
  43. package/dist/cli/run-cli/commands/init/recipes.d.ts +9 -1
  44. package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
  45. package/dist/cli/run-cli/commands/init/recipes.js +33 -22
  46. package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
  47. package/dist/cli/run-cli/commands/init.js +26 -21
  48. package/dist/cli/run-cli/error-guidance.js +20 -0
  49. package/dist/cli/run-cli.js +1 -1
  50. package/dist/cli/run-cli.test-helpers.d.ts +1 -74
  51. package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
  52. package/dist/cli/run-cli.test-helpers.js +1 -766
  53. package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
  54. package/dist/commands/branch/cleanup-merged.js +5 -9
  55. package/dist/commands/branch/work-start.command.d.ts.map +1 -1
  56. package/dist/commands/branch/work-start.command.js +1 -0
  57. package/dist/commands/codex/plugin-install.d.ts +26 -0
  58. package/dist/commands/codex/plugin-install.d.ts.map +1 -0
  59. package/dist/commands/codex/plugin-install.js +209 -0
  60. package/dist/commands/commit.spec.d.ts.map +1 -1
  61. package/dist/commands/commit.spec.js +2 -0
  62. package/dist/commands/doctor/branch-pr.d.ts +1 -1
  63. package/dist/commands/doctor/branch-pr.d.ts.map +1 -1
  64. package/dist/commands/doctor/branch-pr.js +5 -2
  65. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  66. package/dist/commands/guard/impl/commands.js +4 -1
  67. package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -1
  68. package/dist/commands/guard/impl/comment-commit.js +2 -1
  69. package/dist/commands/guard/impl/env.d.ts +6 -0
  70. package/dist/commands/guard/impl/env.d.ts.map +1 -1
  71. package/dist/commands/guard/impl/env.js +41 -0
  72. package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
  73. package/dist/commands/pr/integrate/cmd.js +81 -5
  74. package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
  75. package/dist/commands/pr/integrate/internal/prepare.js +38 -7
  76. package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
  77. package/dist/commands/pr/internal/auto-commit.js +13 -7
  78. package/dist/commands/pr/internal/sync-branch.d.ts +36 -0
  79. package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -0
  80. package/dist/commands/pr/internal/sync-branch.js +113 -0
  81. package/dist/commands/pr/internal/sync-github.d.ts +28 -0
  82. package/dist/commands/pr/internal/sync-github.d.ts.map +1 -0
  83. package/dist/commands/pr/internal/sync-github.js +178 -0
  84. package/dist/commands/pr/internal/sync-model.d.ts +36 -0
  85. package/dist/commands/pr/internal/sync-model.d.ts.map +1 -0
  86. package/dist/commands/pr/internal/sync-model.js +1 -0
  87. package/dist/commands/pr/internal/sync-open-step.d.ts +10 -0
  88. package/dist/commands/pr/internal/sync-open-step.d.ts.map +1 -0
  89. package/dist/commands/pr/internal/sync-open-step.js +128 -0
  90. package/dist/commands/pr/internal/sync-support.d.ts +7 -0
  91. package/dist/commands/pr/internal/sync-support.d.ts.map +1 -0
  92. package/dist/commands/pr/internal/sync-support.js +29 -0
  93. package/dist/commands/pr/internal/sync-update-step.d.ts +6 -0
  94. package/dist/commands/pr/internal/sync-update-step.d.ts.map +1 -0
  95. package/dist/commands/pr/internal/sync-update-step.js +68 -0
  96. package/dist/commands/pr/internal/sync.d.ts +2 -6
  97. package/dist/commands/pr/internal/sync.d.ts.map +1 -1
  98. package/dist/commands/pr/internal/sync.js +83 -525
  99. package/dist/commands/pr/open.d.ts.map +1 -1
  100. package/dist/commands/pr/open.js +62 -7
  101. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  102. package/dist/commands/pr/pr.command.js +7 -2
  103. package/dist/commands/recipes/active.command.d.ts +7 -0
  104. package/dist/commands/recipes/active.command.d.ts.map +1 -0
  105. package/dist/commands/recipes/active.command.js +12 -0
  106. package/dist/commands/recipes/add.command.d.ts +8 -0
  107. package/dist/commands/recipes/add.command.d.ts.map +1 -0
  108. package/dist/commands/recipes/add.command.js +33 -0
  109. package/dist/commands/recipes/detach.command.d.ts +7 -0
  110. package/dist/commands/recipes/detach.command.d.ts.map +1 -0
  111. package/dist/commands/recipes/detach.command.js +19 -0
  112. package/dist/commands/recipes/disable.command.d.ts +7 -0
  113. package/dist/commands/recipes/disable.command.d.ts.map +1 -0
  114. package/dist/commands/recipes/disable.command.js +10 -0
  115. package/dist/commands/recipes/enable.command.d.ts +7 -0
  116. package/dist/commands/recipes/enable.command.d.ts.map +1 -0
  117. package/dist/commands/recipes/enable.command.js +10 -0
  118. package/dist/commands/recipes/explain-active.command.d.ts +5 -0
  119. package/dist/commands/recipes/explain-active.command.d.ts.map +1 -0
  120. package/dist/commands/recipes/explain-active.command.js +11 -0
  121. package/dist/commands/recipes/explain.command.d.ts.map +1 -1
  122. package/dist/commands/recipes/explain.command.js +4 -2
  123. package/dist/commands/recipes/impl/apply.d.ts +1 -1
  124. package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
  125. package/dist/commands/recipes/impl/apply.js +34 -16
  126. package/dist/commands/recipes/impl/commands/active.d.ts +6 -0
  127. package/dist/commands/recipes/impl/commands/active.d.ts.map +1 -0
  128. package/dist/commands/recipes/impl/commands/active.js +47 -0
  129. package/dist/commands/recipes/impl/commands/add.d.ts +8 -0
  130. package/dist/commands/recipes/impl/commands/add.d.ts.map +1 -0
  131. package/dist/commands/recipes/impl/commands/add.js +105 -0
  132. package/dist/commands/recipes/impl/commands/detach.d.ts +6 -0
  133. package/dist/commands/recipes/impl/commands/detach.d.ts.map +1 -0
  134. package/dist/commands/recipes/impl/commands/detach.js +99 -0
  135. package/dist/commands/recipes/impl/commands/disable.d.ts +6 -0
  136. package/dist/commands/recipes/impl/commands/disable.d.ts.map +1 -0
  137. package/dist/commands/recipes/impl/commands/disable.js +23 -0
  138. package/dist/commands/recipes/impl/commands/enable.d.ts +6 -0
  139. package/dist/commands/recipes/impl/commands/enable.d.ts.map +1 -0
  140. package/dist/commands/recipes/impl/commands/enable.js +41 -0
  141. package/dist/commands/recipes/impl/commands/explain-active.d.ts +5 -0
  142. package/dist/commands/recipes/impl/commands/explain-active.d.ts.map +1 -0
  143. package/dist/commands/recipes/impl/commands/explain-active.js +20 -0
  144. package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
  145. package/dist/commands/recipes/impl/commands/explain.js +83 -36
  146. package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
  147. package/dist/commands/recipes/impl/commands/info.js +39 -22
  148. package/dist/commands/recipes/impl/commands/install.d.ts +1 -1
  149. package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
  150. package/dist/commands/recipes/impl/commands/install.js +35 -42
  151. package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
  152. package/dist/commands/recipes/impl/commands/list-remote.js +2 -3
  153. package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -1
  154. package/dist/commands/recipes/impl/commands/list.js +13 -12
  155. package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
  156. package/dist/commands/recipes/impl/commands/remove.js +12 -2
  157. package/dist/commands/recipes/impl/commands/update.d.ts +7 -0
  158. package/dist/commands/recipes/impl/commands/update.d.ts.map +1 -0
  159. package/dist/commands/recipes/impl/commands/update.js +107 -0
  160. package/dist/commands/recipes/impl/commands.d.ts +7 -0
  161. package/dist/commands/recipes/impl/commands.d.ts.map +1 -1
  162. package/dist/commands/recipes/impl/commands.js +7 -0
  163. package/dist/commands/recipes/impl/constants.d.ts +1 -14
  164. package/dist/commands/recipes/impl/constants.d.ts.map +1 -1
  165. package/dist/commands/recipes/impl/constants.js +1 -18
  166. package/dist/commands/recipes/impl/index.d.ts +1 -1
  167. package/dist/commands/recipes/impl/index.d.ts.map +1 -1
  168. package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
  169. package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
  170. package/dist/commands/recipes/impl/installed-recipes.js +1 -2
  171. package/dist/commands/recipes/impl/mutation-transaction.d.ts +7 -0
  172. package/dist/commands/recipes/impl/mutation-transaction.d.ts.map +1 -0
  173. package/dist/commands/recipes/impl/mutation-transaction.js +47 -0
  174. package/dist/commands/recipes/impl/overlay-project.d.ts +48 -0
  175. package/dist/commands/recipes/impl/overlay-project.d.ts.map +1 -0
  176. package/dist/commands/recipes/impl/overlay-project.js +320 -0
  177. package/dist/commands/recipes/impl/paths.d.ts +17 -2
  178. package/dist/commands/recipes/impl/paths.d.ts.map +1 -1
  179. package/dist/commands/recipes/impl/paths.js +20 -5
  180. package/dist/commands/recipes/impl/project-installed-recipes.d.ts +5 -4
  181. package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
  182. package/dist/commands/recipes/impl/project-installed-recipes.js +34 -76
  183. package/dist/commands/recipes/impl/project-recipe-state.d.ts +18 -0
  184. package/dist/commands/recipes/impl/project-recipe-state.d.ts.map +1 -0
  185. package/dist/commands/recipes/impl/project-recipe-state.js +94 -0
  186. package/dist/commands/recipes/impl/project-registry.d.ts +24 -0
  187. package/dist/commands/recipes/impl/project-registry.d.ts.map +1 -0
  188. package/dist/commands/recipes/impl/project-registry.js +124 -0
  189. package/dist/commands/recipes/impl/resolver.d.ts +1 -1
  190. package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
  191. package/dist/commands/recipes/impl/resolver.js +6 -4
  192. package/dist/commands/recipes/impl/types.d.ts +1 -240
  193. package/dist/commands/recipes/impl/types.d.ts.map +1 -1
  194. package/dist/commands/recipes/impl/version.d.ts +5 -0
  195. package/dist/commands/recipes/impl/version.d.ts.map +1 -0
  196. package/dist/commands/recipes/impl/version.js +9 -0
  197. package/dist/commands/recipes/info.command.js +2 -2
  198. package/dist/commands/recipes/install.spec.js +4 -4
  199. package/dist/commands/recipes/list.command.js +4 -4
  200. package/dist/commands/recipes/remove.command.js +2 -2
  201. package/dist/commands/recipes/update.command.d.ts +8 -0
  202. package/dist/commands/recipes/update.command.d.ts.map +1 -0
  203. package/dist/commands/recipes/update.command.js +35 -0
  204. package/dist/commands/recipes.d.ts +10 -6
  205. package/dist/commands/recipes.d.ts.map +1 -1
  206. package/dist/commands/recipes.js +8 -5
  207. package/dist/commands/recipes.test-helpers.d.ts +3 -3
  208. package/dist/commands/recipes.test-helpers.d.ts.map +1 -1
  209. package/dist/commands/recipes.test-helpers.js +105 -15
  210. package/dist/commands/release/apply.command.d.ts +1 -1
  211. package/dist/commands/release/apply.command.d.ts.map +1 -1
  212. package/dist/commands/release/apply.command.js +15 -379
  213. package/dist/commands/release/apply.mutation.d.ts +1 -0
  214. package/dist/commands/release/apply.mutation.d.ts.map +1 -1
  215. package/dist/commands/release/apply.mutation.js +24 -1
  216. package/dist/commands/release/apply.pipeline.d.ts +22 -0
  217. package/dist/commands/release/apply.pipeline.d.ts.map +1 -0
  218. package/dist/commands/release/apply.pipeline.js +371 -0
  219. package/dist/commands/release/apply.preflight.d.ts +2 -0
  220. package/dist/commands/release/apply.preflight.d.ts.map +1 -1
  221. package/dist/commands/release/apply.preflight.js +13 -4
  222. package/dist/commands/release/apply.types.d.ts +27 -0
  223. package/dist/commands/release/apply.types.d.ts.map +1 -1
  224. package/dist/commands/release.test-helpers.d.ts +4 -0
  225. package/dist/commands/release.test-helpers.d.ts.map +1 -1
  226. package/dist/commands/release.test-helpers.js +7 -0
  227. package/dist/commands/scenario/execute.command.js +4 -4
  228. package/dist/commands/scenario/impl/commands.js +4 -4
  229. package/dist/commands/scenario/info.command.js +4 -4
  230. package/dist/commands/scenario/list.command.js +3 -3
  231. package/dist/commands/scenario/run.command.js +5 -5
  232. package/dist/commands/scenario/scenario.command.js +7 -7
  233. package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
  234. package/dist/commands/shared/reconcile-check.js +2 -2
  235. package/dist/commands/shared/task-backend.d.ts +6 -1
  236. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  237. package/dist/commands/shared/task-backend.js +34 -2
  238. package/dist/commands/shared/task-handoff.d.ts +2 -1
  239. package/dist/commands/shared/task-handoff.d.ts.map +1 -1
  240. package/dist/commands/shared/task-handoff.js +15 -0
  241. package/dist/commands/shared/task-mutation.d.ts.map +1 -1
  242. package/dist/commands/shared/task-mutation.js +4 -4
  243. package/dist/commands/shared/task-store/intents.d.ts +34 -0
  244. package/dist/commands/shared/task-store/intents.d.ts.map +1 -0
  245. package/dist/commands/shared/task-store/intents.js +265 -0
  246. package/dist/commands/shared/task-store/readme.d.ts +28 -0
  247. package/dist/commands/shared/task-store/readme.d.ts.map +1 -0
  248. package/dist/commands/shared/task-store/readme.js +125 -0
  249. package/dist/commands/shared/task-store/store.d.ts +26 -0
  250. package/dist/commands/shared/task-store/store.d.ts.map +1 -0
  251. package/dist/commands/shared/task-store/store.js +105 -0
  252. package/dist/commands/shared/task-store/types.d.ts +94 -0
  253. package/dist/commands/shared/task-store/types.d.ts.map +1 -0
  254. package/dist/commands/shared/task-store/types.js +1 -0
  255. package/dist/commands/shared/task-store.d.ts +3 -109
  256. package/dist/commands/shared/task-store.d.ts.map +1 -1
  257. package/dist/commands/shared/task-store.js +2 -493
  258. package/dist/commands/task/block.d.ts.map +1 -1
  259. package/dist/commands/task/block.js +7 -2
  260. package/dist/commands/task/comment.d.ts.map +1 -1
  261. package/dist/commands/task/comment.js +7 -2
  262. package/dist/commands/task/finish-shared.d.ts.map +1 -1
  263. package/dist/commands/task/finish-shared.js +3 -3
  264. package/dist/commands/task/finish.d.ts.map +1 -1
  265. package/dist/commands/task/finish.js +102 -15
  266. package/dist/commands/task/handoff-show.command.d.ts.map +1 -1
  267. package/dist/commands/task/handoff-show.command.js +24 -0
  268. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
  269. package/dist/commands/task/hosted-merge-sync.js +9 -4
  270. package/dist/commands/task/list.run.d.ts.map +1 -1
  271. package/dist/commands/task/list.run.js +14 -4
  272. package/dist/commands/task/new.command.d.ts.map +1 -1
  273. package/dist/commands/task/new.command.js +16 -2
  274. package/dist/commands/task/new.js +2 -2
  275. package/dist/commands/task/show.d.ts.map +1 -1
  276. package/dist/commands/task/show.js +3 -3
  277. package/dist/commands/task/update.d.ts.map +1 -1
  278. package/dist/commands/task/update.js +11 -3
  279. package/dist/runner/adapters/codex.d.ts.map +1 -1
  280. package/dist/runner/adapters/codex.js +3 -33
  281. package/dist/runner/adapters/custom.d.ts.map +1 -1
  282. package/dist/runner/adapters/custom.js +3 -30
  283. package/dist/runner/adapters/runtime-shared.d.ts +14 -0
  284. package/dist/runner/adapters/runtime-shared.d.ts.map +1 -0
  285. package/dist/runner/adapters/runtime-shared.js +36 -0
  286. package/dist/runner/context/base-prompt-sources.d.ts +30 -0
  287. package/dist/runner/context/base-prompt-sources.d.ts.map +1 -0
  288. package/dist/runner/context/base-prompt-sources.js +144 -0
  289. package/dist/runner/context/base-prompts.d.ts +5 -23
  290. package/dist/runner/context/base-prompts.d.ts.map +1 -1
  291. package/dist/runner/context/base-prompts.js +10 -358
  292. package/dist/runner/context/overlay-prompt-blocks.d.ts +7 -0
  293. package/dist/runner/context/overlay-prompt-blocks.d.ts.map +1 -0
  294. package/dist/runner/context/overlay-prompt-blocks.js +72 -0
  295. package/dist/runner/context/prompt-block-shared.d.ts +54 -0
  296. package/dist/runner/context/prompt-block-shared.d.ts.map +1 -0
  297. package/dist/runner/context/prompt-block-shared.js +106 -0
  298. package/dist/runner/context/recipe-context.d.ts +2 -1
  299. package/dist/runner/context/recipe-context.d.ts.map +1 -1
  300. package/dist/runner/context/recipe-context.js +41 -8
  301. package/dist/runner/context/recipe-prompt-blocks.d.ts +6 -0
  302. package/dist/runner/context/recipe-prompt-blocks.d.ts.map +1 -0
  303. package/dist/runner/context/recipe-prompt-blocks.js +143 -0
  304. package/dist/runner/types.d.ts +4 -0
  305. package/dist/runner/types.d.ts.map +1 -1
  306. package/dist/runner/usecases/scenario-materialize-task.js +2 -2
  307. package/dist/runner/usecases/task-run-inspect.js +2 -2
  308. package/dist/runner/usecases/task-run-lifecycle-shared.js +2 -2
  309. package/dist/runner/usecases/task-run.d.ts.map +1 -1
  310. package/dist/runner/usecases/task-run.js +6 -3
  311. package/dist/runtime/behavior/resolve.d.ts +2 -1
  312. package/dist/runtime/behavior/resolve.d.ts.map +1 -1
  313. package/dist/runtime/behavior/resolve.js +25 -5
  314. package/dist/runtime/behavior/types.d.ts +1 -0
  315. package/dist/runtime/behavior/types.d.ts.map +1 -1
  316. package/dist/runtime/capabilities/recipe.d.ts +2 -1
  317. package/dist/runtime/capabilities/recipe.d.ts.map +1 -1
  318. package/dist/runtime/capabilities/recipe.js +88 -28
  319. package/dist/runtime/execution-context.d.ts +63 -0
  320. package/dist/runtime/execution-context.d.ts.map +1 -0
  321. package/dist/{usecases/context/resolve-context.js → runtime/execution-context.js} +23 -26
  322. package/dist/runtime/incidents/advice-strategy.d.ts +15 -0
  323. package/dist/runtime/incidents/advice-strategy.d.ts.map +1 -0
  324. package/dist/runtime/incidents/advice-strategy.js +54 -0
  325. package/dist/runtime/incidents/plan-strategy.d.ts +9 -0
  326. package/dist/runtime/incidents/plan-strategy.d.ts.map +1 -0
  327. package/dist/runtime/incidents/plan-strategy.js +205 -0
  328. package/dist/runtime/incidents/registry-strategy.d.ts +6 -0
  329. package/dist/runtime/incidents/registry-strategy.d.ts.map +1 -0
  330. package/dist/runtime/incidents/registry-strategy.js +280 -0
  331. package/dist/runtime/incidents/resolve.d.ts +3 -25
  332. package/dist/runtime/incidents/resolve.d.ts.map +1 -1
  333. package/dist/runtime/incidents/resolve.js +3 -683
  334. package/dist/runtime/incidents/shared.d.ts +34 -0
  335. package/dist/runtime/incidents/shared.d.ts.map +1 -0
  336. package/dist/runtime/incidents/shared.js +171 -0
  337. package/dist/shared/errors.d.ts +1 -1
  338. package/dist/shared/errors.d.ts.map +1 -1
  339. package/dist/shared/runtime-source.d.ts.map +1 -1
  340. package/dist/shared/runtime-source.js +8 -3
  341. package/dist/testing/cli-harness/recipe-archives.d.ts +28 -0
  342. package/dist/testing/cli-harness/recipe-archives.d.ts.map +1 -0
  343. package/dist/testing/cli-harness/recipe-archives.js +374 -0
  344. package/dist/testing/cli-harness/stdio.d.ts +26 -0
  345. package/dist/testing/cli-harness/stdio.d.ts.map +1 -0
  346. package/dist/testing/cli-harness/stdio.js +84 -0
  347. package/dist/testing/cli-harness.d.ts +25 -0
  348. package/dist/testing/cli-harness.d.ts.map +1 -0
  349. package/dist/testing/cli-harness.js +313 -0
  350. package/dist/testing/index.d.ts +2 -0
  351. package/dist/testing/index.d.ts.map +1 -0
  352. package/dist/testing/index.js +1 -0
  353. package/package.json +7 -3
  354. package/dist/cli/recipes-bundled.d.ts +0 -10
  355. package/dist/cli/recipes-bundled.d.ts.map +0 -1
  356. package/dist/cli/recipes-bundled.js +0 -36
  357. package/dist/commands/recipes/impl/manifest.d.ts +0 -4
  358. package/dist/commands/recipes/impl/manifest.d.ts.map +0 -1
  359. package/dist/commands/recipes/impl/manifest.js +0 -229
  360. package/dist/commands/recipes/impl/normalize.d.ts +0 -8
  361. package/dist/commands/recipes/impl/normalize.d.ts.map +0 -1
  362. package/dist/commands/recipes/impl/normalize.js +0 -54
  363. package/dist/commands/recipes/impl/scenario.d.ts +0 -16
  364. package/dist/commands/recipes/impl/scenario.d.ts.map +0 -1
  365. package/dist/commands/recipes/impl/scenario.js +0 -262
  366. package/dist/recipes/bundled-recipes.d.ts +0 -17
  367. package/dist/recipes/bundled-recipes.d.ts.map +0 -1
  368. package/dist/recipes/bundled-recipes.js +0 -15
  369. package/dist/usecases/context/resolve-context.d.ts +0 -68
  370. package/dist/usecases/context/resolve-context.d.ts.map +0 -1
  371. package/dist/usecases/task/task-list-usecase.d.ts +0 -9
  372. package/dist/usecases/task/task-list-usecase.d.ts.map +0 -1
  373. package/dist/usecases/task/task-list-usecase.js +0 -17
  374. package/dist/usecases/task/task-new-usecase.d.ts +0 -9
  375. package/dist/usecases/task/task-new-usecase.d.ts.map +0 -1
  376. package/dist/usecases/task/task-new-usecase.js +0 -17
@@ -0,0 +1,144 @@
1
+ import { readFile, readdir } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { loadAgentTemplates, loadPolicyGatewayTemplate } from "../../agents/agents-template.js";
4
+ import { fileExists } from "../../cli/fs-utils.js";
5
+ import { resolveBehavior } from "../../runtime/behavior/index.js";
6
+ import { resolvePolicyGatewayForRepo, } from "../../shared/policy-gateway.js";
7
+ import { BASE_PROMPT_PRIORITIES, normalizeText, promptBlockFromResolved, promptCandidate, toPromptSource, validateJsonPrompt, } from "./prompt-block-shared.js";
8
+ async function resolveRepoAgentProfilePath(opts) {
9
+ const agentsDir = path.join(opts.git_root, opts.agents_dir);
10
+ if (!(await fileExists(agentsDir)))
11
+ return null;
12
+ const entries = await readdir(agentsDir);
13
+ const wanted = `${opts.owner_id}.json`.toLowerCase();
14
+ const match = entries.find((entry) => entry.endsWith(".json") && entry.toLowerCase() === wanted);
15
+ if (!match)
16
+ return null;
17
+ return path.join(agentsDir, match);
18
+ }
19
+ export async function resolveOwnerProfilePromptSource(opts) {
20
+ const candidates = [];
21
+ const repoProfilePath = await resolveRepoAgentProfilePath(opts);
22
+ if (repoProfilePath) {
23
+ const source = toPromptSource(opts.git_root, repoProfilePath);
24
+ candidates.push(promptCandidate({
25
+ layer: "user",
26
+ source,
27
+ value: {
28
+ source,
29
+ title: `Owner Agent Profile (${opts.owner_id})`,
30
+ content: validateJsonPrompt(source, await readFile(repoProfilePath, "utf8")),
31
+ },
32
+ }));
33
+ }
34
+ const bundledFileName = `${opts.owner_id}.json`;
35
+ const bundledTemplates = await loadAgentTemplates();
36
+ const bundled = bundledTemplates.find((entry) => entry.fileName.toLowerCase() === bundledFileName.toLowerCase());
37
+ if (!bundled) {
38
+ throw new Error(`Bundled agent profile not found: ${bundledFileName}`);
39
+ }
40
+ candidates.push(promptCandidate({
41
+ layer: "builtin",
42
+ source: `bundled:agent-profile:${bundled.fileName}`,
43
+ value: {
44
+ source: `bundled:agent-profile:${bundled.fileName}`,
45
+ title: `Owner Agent Profile (${opts.owner_id})`,
46
+ content: validateJsonPrompt(`bundled:agent-profile:${bundled.fileName}`, bundled.contents),
47
+ },
48
+ order: 10,
49
+ }));
50
+ return resolveBehavior({
51
+ key: `runner.owner_profile:${opts.owner_id}`,
52
+ candidates,
53
+ });
54
+ }
55
+ export async function loadOwnerProfilePrompt(opts) {
56
+ const resolved = await resolveOwnerProfilePromptSource(opts);
57
+ return promptBlockFromResolved({
58
+ id: "base.owner_profile",
59
+ role: "profile",
60
+ priority: BASE_PROMPT_PRIORITIES.owner_profile,
61
+ resolved,
62
+ });
63
+ }
64
+ export async function resolvePolicyGatewayPromptSource(opts) {
65
+ const gateway = opts.harness?.repo.policy_gateway ??
66
+ (await resolvePolicyGatewayForRepo({
67
+ gitRoot: opts.git_root,
68
+ fallbackFlavor: opts.fallback_flavor,
69
+ }));
70
+ const candidates = [];
71
+ if (await fileExists(gateway.absPath)) {
72
+ const source = path.relative(opts.git_root, gateway.absPath).replaceAll("\\", "/");
73
+ candidates.push(promptCandidate({
74
+ layer: "harness",
75
+ source,
76
+ value: {
77
+ source,
78
+ title: `Repository Policy Gateway (${gateway.fileName})`,
79
+ content: normalizeText(await readFile(gateway.absPath, "utf8")),
80
+ },
81
+ }));
82
+ }
83
+ candidates.push(promptCandidate({
84
+ layer: "builtin",
85
+ source: `bundled:policy-gateway:${gateway.fileName}`,
86
+ value: {
87
+ source: `bundled:policy-gateway:${gateway.fileName}`,
88
+ title: `Bundled Policy Gateway Fallback (${gateway.fileName})`,
89
+ content: await loadPolicyGatewayTemplate(gateway.flavor),
90
+ },
91
+ order: 10,
92
+ }));
93
+ return resolveBehavior({
94
+ key: `runner.policy_gateway:${gateway.fileName}`,
95
+ candidates,
96
+ });
97
+ }
98
+ export async function loadPolicyGatewayPrompt(opts) {
99
+ const resolved = await resolvePolicyGatewayPromptSource(opts);
100
+ return promptBlockFromResolved({
101
+ id: "base.policy_gateway",
102
+ role: "policy",
103
+ priority: BASE_PROMPT_PRIORITIES.policy_gateway,
104
+ resolved,
105
+ });
106
+ }
107
+ function renderExecutionProfilePromptContent(runtime) {
108
+ return JSON.stringify({
109
+ profile: runtime.profile,
110
+ reasoning_effort: runtime.reasoning_effort,
111
+ budget: runtime.budget,
112
+ approvals: runtime.approvals,
113
+ stop_conditions: runtime.stop_conditions,
114
+ handoff_conditions: runtime.handoff_conditions,
115
+ unsafe_actions_requiring_explicit_user_ok: runtime.unsafe_actions_requiring_explicit_user_ok,
116
+ runner: runtime.runner,
117
+ }, null, 2);
118
+ }
119
+ export function loadExecutionProfilePrompt(opts) {
120
+ if (!opts.execution_profile)
121
+ return null;
122
+ const source = `runtime:execution-profile:${opts.execution_profile.profile}`;
123
+ const resolved = resolveBehavior({
124
+ key: "runner.execution_profile",
125
+ candidates: [
126
+ promptCandidate({
127
+ layer: "harness",
128
+ source,
129
+ value: {
130
+ source,
131
+ title: `Execution Profile Runtime (${opts.execution_profile.profile})`,
132
+ content: normalizeText(renderExecutionProfilePromptContent(opts.execution_profile)),
133
+ },
134
+ }),
135
+ ],
136
+ });
137
+ return promptBlockFromResolved({
138
+ id: "base.execution_profile",
139
+ role: "policy",
140
+ priority: BASE_PROMPT_PRIORITIES.execution_profile,
141
+ resolved,
142
+ });
143
+ }
144
+ export { loadFrameworkRunnerPrompt } from "./prompt-block-shared.js";
@@ -1,35 +1,17 @@
1
- import { type ResolvedBehavior } from "../../runtime/behavior/index.js";
2
- import { type PolicyGatewayFlavor } from "../../shared/policy-gateway.js";
3
1
  import type { ResolvedExecutionProfileRuntime } from "../../runtime/execution-profile/index.js";
4
2
  import type { ResolvedHarnessContract } from "../../runtime/harness/index.js";
5
- import type { RunnerPromptBlock, RunnerRecipeContext } from "../types.js";
6
- type PromptSourcePayload = {
7
- source: string;
8
- title: string;
9
- content: string;
10
- };
11
- type PromptSourceTraceMetadata = {
12
- title: string;
13
- };
14
- type ResolvedPromptSource = ResolvedBehavior<PromptSourcePayload, PromptSourceTraceMetadata>;
15
- export declare function resolveOwnerProfilePromptSource(opts: {
16
- git_root: string;
17
- agents_dir: string;
18
- owner_id: string;
19
- }): Promise<ResolvedPromptSource>;
20
- export declare function resolvePolicyGatewayPromptSource(opts: {
21
- git_root: string;
22
- fallback_flavor: PolicyGatewayFlavor;
23
- harness?: ResolvedHarnessContract;
24
- }): Promise<ResolvedPromptSource>;
3
+ import type { RunnerPromptBlock, RunnerRecipeContext, RunnerTaskContext } from "../types.js";
4
+ import type { PolicyGatewayFlavor } from "../../shared/policy-gateway.js";
5
+ export { resolveOwnerProfilePromptSource, resolvePolicyGatewayPromptSource, } from "./base-prompt-sources.js";
25
6
  export declare function collectRunnerBasePrompts(opts: {
26
7
  git_root: string;
27
8
  owner_id: string;
28
9
  agents_dir?: string;
29
10
  fallback_policy_gateway_flavor?: PolicyGatewayFlavor;
11
+ task?: RunnerTaskContext;
12
+ command?: string;
30
13
  recipe?: RunnerRecipeContext;
31
14
  harness?: ResolvedHarnessContract;
32
15
  execution_profile?: ResolvedExecutionProfileRuntime;
33
16
  }): Promise<RunnerPromptBlock[]>;
34
- export {};
35
17
  //# sourceMappingURL=base-prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-prompts.d.ts","sourceRoot":"","sources":["../../../src/runner/context/base-prompts.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAoB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA8D5F,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,oBAAoB,GAAG,gBAAgB,CAAC,mBAAmB,EAAE,yBAAyB,CAAC,CAAC;AAmD7F,wBAAsB,+BAA+B,CAAC,IAAI,EAAE;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA2ChC;AAwCD,wBAAsB,gCAAgC,CAAC,IAAI,EAAE;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,mBAAmB,CAAC;IACrC,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACnC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAyChC;AA8MD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B,CAAC,EAAE,mBAAmB,CAAC;IACrD,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC,iBAAiB,CAAC,EAAE,+BAA+B,CAAC;CACrD,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAgC/B"}
1
+ {"version":3,"file":"base-prompts.d.ts","sourceRoot":"","sources":["../../../src/runner/context/base-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAS9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,0BAA0B,CAAC;AAElC,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B,CAAC,EAAE,mBAAmB,CAAC;IACrD,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC,iBAAiB,CAAC,EAAE,+BAA+B,CAAC;CACrD,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAqC/B"}
@@ -1,361 +1,8 @@
1
- import { readdir, readFile } from "node:fs/promises";
2
- import path from "node:path";
3
- import { loadAgentTemplates, loadPolicyGatewayTemplate } from "../../agents/agents-template.js";
4
- import { fileExists } from "../../cli/fs-utils.js";
5
- import { resolveBehavior, stripBehaviorValue, } from "../../runtime/behavior/index.js";
6
- import { resolvePolicyGatewayForRepo, } from "../../shared/policy-gateway.js";
7
- const FRAMEWORK_RUNNER_PROMPT_URL = new URL("../../../assets/RUNNER.md", import.meta.url);
8
- const BASE_PROMPT_PRIORITIES = {
9
- framework_runner: 100,
10
- policy_gateway: 200,
11
- execution_profile: 250,
12
- owner_profile: 300,
13
- recipe_execution_context: 400,
14
- recipe_agent_profile: 500,
15
- recipe_skill_context: 600,
16
- recipe_tools_context: 700,
17
- };
18
- function ensureTrailingNewline(text) {
19
- return text.endsWith("\n") ? text : `${text}\n`;
20
- }
21
- function normalizeOwnerId(ownerIdRaw) {
22
- const trimmed = ownerIdRaw.trim();
23
- if (!trimmed)
24
- throw new Error("Runner base prompt collection requires a non-empty owner id.");
25
- return trimmed.toUpperCase();
26
- }
27
- function normalizeText(text) {
28
- return ensureTrailingNewline(text.trimEnd());
29
- }
30
- function validateJsonPrompt(source, text) {
31
- let parsed;
32
- try {
33
- parsed = JSON.parse(text);
34
- }
35
- catch {
36
- throw new Error(`Invalid prompt JSON: ${source} (malformed JSON)`);
37
- }
38
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
39
- throw new Error(`Invalid prompt JSON: ${source} (expected object)`);
40
- }
41
- return normalizeText(text);
42
- }
43
- function renderRecipePromptJson(value) {
44
- return normalizeText(JSON.stringify(value, null, 2));
45
- }
46
- function toPromptSource(gitRoot, absPath) {
47
- return path.relative(gitRoot, absPath).replaceAll("\\", "/");
48
- }
49
- function isRecord(value) {
50
- return !!value && typeof value === "object" && !Array.isArray(value);
51
- }
52
- function readOptionalStringArray(value) {
53
- return Array.isArray(value)
54
- ? value.filter((entry) => typeof entry === "string")
55
- : [];
56
- }
57
- function promptCandidate(opts) {
58
- return {
59
- layer: opts.layer,
60
- source: opts.source,
61
- value: opts.value,
62
- order: opts.order,
63
- metadata: {
64
- title: opts.value.title,
65
- },
66
- };
67
- }
68
- function promptBlockFromResolved(opts) {
69
- return {
70
- id: opts.id,
71
- role: opts.role,
72
- title: opts.resolved.value.title,
73
- source: opts.resolved.value.source,
74
- priority: opts.priority,
75
- content: opts.resolved.value.content,
76
- resolution: stripBehaviorValue(opts.resolved),
77
- };
78
- }
79
- async function resolveRepoAgentProfilePath(opts) {
80
- const agentsDir = path.join(opts.git_root, opts.agents_dir);
81
- if (!(await fileExists(agentsDir)))
82
- return null;
83
- const entries = await readdir(agentsDir);
84
- const wanted = `${opts.owner_id}.json`.toLowerCase();
85
- const match = entries.find((entry) => entry.endsWith(".json") && entry.toLowerCase() === wanted);
86
- if (!match)
87
- return null;
88
- return path.join(agentsDir, match);
89
- }
90
- export async function resolveOwnerProfilePromptSource(opts) {
91
- const candidates = [];
92
- const repoProfilePath = await resolveRepoAgentProfilePath(opts);
93
- if (repoProfilePath) {
94
- const source = toPromptSource(opts.git_root, repoProfilePath);
95
- candidates.push(promptCandidate({
96
- layer: "user",
97
- source,
98
- value: {
99
- source,
100
- title: `Owner Agent Profile (${opts.owner_id})`,
101
- content: validateJsonPrompt(source, await readFile(repoProfilePath, "utf8")),
102
- },
103
- }));
104
- }
105
- const bundledFileName = `${opts.owner_id}.json`;
106
- const bundledTemplates = await loadAgentTemplates();
107
- const bundled = bundledTemplates.find((entry) => entry.fileName.toLowerCase() === bundledFileName.toLowerCase());
108
- if (!bundled) {
109
- throw new Error(`Bundled agent profile not found: ${bundledFileName}`);
110
- }
111
- candidates.push(promptCandidate({
112
- layer: "builtin",
113
- source: `bundled:agent-profile:${bundled.fileName}`,
114
- value: {
115
- source: `bundled:agent-profile:${bundled.fileName}`,
116
- title: `Owner Agent Profile (${opts.owner_id})`,
117
- content: validateJsonPrompt(`bundled:agent-profile:${bundled.fileName}`, bundled.contents),
118
- },
119
- order: 10,
120
- }));
121
- return resolveBehavior({
122
- key: `runner.owner_profile:${opts.owner_id}`,
123
- candidates,
124
- });
125
- }
126
- async function loadOwnerProfilePrompt(opts) {
127
- const resolved = await resolveOwnerProfilePromptSource(opts);
128
- return promptBlockFromResolved({
129
- id: "base.owner_profile",
130
- role: "profile",
131
- priority: BASE_PROMPT_PRIORITIES.owner_profile,
132
- resolved,
133
- });
134
- }
135
- async function loadFrameworkRunnerPrompt() {
136
- const resolved = resolveBehavior({
137
- key: "runner.framework_prompt",
138
- candidates: [
139
- promptCandidate({
140
- layer: "builtin",
141
- source: "bundled:runner-prompt:RUNNER.md",
142
- value: {
143
- source: "bundled:runner-prompt:RUNNER.md",
144
- title: "Framework Runner Prompt",
145
- content: normalizeText(await readFile(FRAMEWORK_RUNNER_PROMPT_URL, "utf8")),
146
- },
147
- }),
148
- ],
149
- });
150
- return promptBlockFromResolved({
151
- id: "base.framework_runner",
152
- role: "system",
153
- priority: BASE_PROMPT_PRIORITIES.framework_runner,
154
- resolved,
155
- });
156
- }
157
- export async function resolvePolicyGatewayPromptSource(opts) {
158
- const gateway = opts.harness?.repo.policy_gateway ??
159
- (await resolvePolicyGatewayForRepo({
160
- gitRoot: opts.git_root,
161
- fallbackFlavor: opts.fallback_flavor,
162
- }));
163
- const candidates = [];
164
- if (await fileExists(gateway.absPath)) {
165
- const source = path.relative(opts.git_root, gateway.absPath).replaceAll("\\", "/");
166
- candidates.push(promptCandidate({
167
- layer: "harness",
168
- source,
169
- value: {
170
- source,
171
- title: `Repository Policy Gateway (${gateway.fileName})`,
172
- content: normalizeText(await readFile(gateway.absPath, "utf8")),
173
- },
174
- }));
175
- }
176
- candidates.push(promptCandidate({
177
- layer: "builtin",
178
- source: `bundled:policy-gateway:${gateway.fileName}`,
179
- value: {
180
- source: `bundled:policy-gateway:${gateway.fileName}`,
181
- title: `Bundled Policy Gateway Fallback (${gateway.fileName})`,
182
- content: await loadPolicyGatewayTemplate(gateway.flavor),
183
- },
184
- order: 10,
185
- }));
186
- return resolveBehavior({
187
- key: `runner.policy_gateway:${gateway.fileName}`,
188
- candidates,
189
- });
190
- }
191
- async function loadPolicyGatewayPrompt(opts) {
192
- const resolved = await resolvePolicyGatewayPromptSource(opts);
193
- return promptBlockFromResolved({
194
- id: "base.policy_gateway",
195
- role: "policy",
196
- priority: BASE_PROMPT_PRIORITIES.policy_gateway,
197
- resolved,
198
- });
199
- }
200
- function renderExecutionProfilePromptContent(runtime) {
201
- return renderRecipePromptJson({
202
- profile: runtime.profile,
203
- reasoning_effort: runtime.reasoning_effort,
204
- budget: runtime.budget,
205
- approvals: runtime.approvals,
206
- stop_conditions: runtime.stop_conditions,
207
- handoff_conditions: runtime.handoff_conditions,
208
- unsafe_actions_requiring_explicit_user_ok: runtime.unsafe_actions_requiring_explicit_user_ok,
209
- runner: runtime.runner,
210
- });
211
- }
212
- function loadExecutionProfilePrompt(opts) {
213
- if (!opts.execution_profile)
214
- return null;
215
- const source = `runtime:execution-profile:${opts.execution_profile.profile}`;
216
- const resolved = resolveBehavior({
217
- key: "runner.execution_profile",
218
- candidates: [
219
- promptCandidate({
220
- layer: "harness",
221
- source,
222
- value: {
223
- source,
224
- title: `Execution Profile Runtime (${opts.execution_profile.profile})`,
225
- content: renderExecutionProfilePromptContent(opts.execution_profile),
226
- },
227
- }),
228
- ],
229
- });
230
- return promptBlockFromResolved({
231
- id: "base.execution_profile",
232
- role: "policy",
233
- priority: BASE_PROMPT_PRIORITIES.execution_profile,
234
- resolved,
235
- });
236
- }
237
- async function loadRecipePromptJsonBlock(opts) {
238
- const candidates = [];
239
- const relativeFile = opts.relative_file?.trim();
240
- if (relativeFile) {
241
- const absPath = path.join(opts.recipe_dir, relativeFile);
242
- if (await fileExists(absPath)) {
243
- const source = toPromptSource(opts.git_root, absPath);
244
- candidates.push(promptCandidate({
245
- layer: "extension",
246
- source,
247
- value: {
248
- source,
249
- title: opts.title,
250
- content: validateJsonPrompt(source, await readFile(absPath, "utf8")),
251
- },
252
- }));
253
- }
254
- }
255
- candidates.push(promptCandidate({
256
- layer: "extension",
257
- source: opts.fallback_source,
258
- value: {
259
- source: opts.fallback_source,
260
- title: opts.title,
261
- content: renderRecipePromptJson(opts.fallback_payload),
262
- },
263
- order: 10,
264
- }));
265
- const resolved = resolveBehavior({
266
- key: opts.prompt_id,
267
- candidates,
268
- });
269
- return promptBlockFromResolved({
270
- id: opts.prompt_id,
271
- role: opts.role,
272
- priority: opts.priority,
273
- resolved,
274
- });
275
- }
276
- async function collectRecipePromptBlocks(opts) {
277
- const recipeDir = opts.recipe.recipe_dir?.trim();
278
- if (!recipeDir)
279
- return [];
280
- const promptBlocks = [];
281
- const scenario = isRecord(opts.recipe.scenario) ? opts.recipe.scenario : {};
282
- const executionContext = {
283
- recipe: {
284
- id: opts.recipe.recipe_id,
285
- name: opts.recipe.recipe_name ?? null,
286
- version: opts.recipe.recipe_version ?? null,
287
- scenario_id: opts.recipe.scenario_id,
288
- scenario_file: opts.recipe.scenario_file ?? null,
289
- },
290
- selection_reasons: opts.recipe.selection_reasons ?? [],
291
- run_profile: opts.recipe.run_profile ?? {},
292
- scenario: {
293
- summary: typeof scenario.summary === "string" ? scenario.summary : null,
294
- description: typeof scenario.description === "string" ? scenario.description : null,
295
- goal: typeof scenario.goal === "string" ? scenario.goal : null,
296
- evidence: isRecord(scenario.evidence) ? scenario.evidence : null,
297
- outputs: readOptionalStringArray(scenario.outputs),
298
- },
299
- };
300
- promptBlocks.push({
301
- id: "recipe.execution_context",
302
- role: "context",
303
- title: `Recipe Scenario Context (${opts.recipe.recipe_id}:${opts.recipe.scenario_id})`,
304
- source: `recipe:${opts.recipe.recipe_id}:${opts.recipe.scenario_id}`,
305
- priority: BASE_PROMPT_PRIORITIES.recipe_execution_context,
306
- content: renderRecipePromptJson(executionContext),
307
- });
308
- const agentBlocks = await Promise.all((opts.recipe.agents ?? []).map(async (agent, index) => {
309
- const agentId = typeof agent.id === "string" ? agent.id : `agent_${index + 1}`;
310
- return loadRecipePromptJsonBlock({
311
- git_root: opts.git_root,
312
- recipe_dir: recipeDir,
313
- prompt_id: `recipe.agent.${agentId}`,
314
- role: "profile",
315
- title: `Recipe Agent Prompt (${agentId})`,
316
- relative_file: typeof agent.file === "string" ? agent.file : undefined,
317
- fallback_source: `recipe:${opts.recipe.recipe_id}:agent:${agentId}`,
318
- fallback_payload: agent,
319
- priority: BASE_PROMPT_PRIORITIES.recipe_agent_profile + index,
320
- });
321
- }));
322
- promptBlocks.push(...agentBlocks);
323
- const skillBlocks = await Promise.all((opts.recipe.skills ?? []).map(async (skill, index) => {
324
- const skillId = typeof skill.id === "string" ? skill.id : `skill_${index + 1}`;
325
- return loadRecipePromptJsonBlock({
326
- git_root: opts.git_root,
327
- recipe_dir: recipeDir,
328
- prompt_id: `recipe.skill.${skillId}`,
329
- role: "context",
330
- title: `Recipe Skill Prompt (${skillId})`,
331
- relative_file: typeof skill.file === "string" ? skill.file : undefined,
332
- fallback_source: `recipe:${opts.recipe.recipe_id}:skill:${skillId}`,
333
- fallback_payload: skill,
334
- priority: BASE_PROMPT_PRIORITIES.recipe_skill_context + index,
335
- });
336
- }));
337
- promptBlocks.push(...skillBlocks);
338
- if ((opts.recipe.tools ?? []).length > 0) {
339
- const toolPayload = (opts.recipe.tools ?? []).map((tool) => ({
340
- id: typeof tool.id === "string" ? tool.id : null,
341
- summary: typeof tool.summary === "string" ? tool.summary : null,
342
- runtime: typeof tool.runtime === "string" ? tool.runtime : null,
343
- entrypoint: typeof tool.entrypoint === "string" ? tool.entrypoint : null,
344
- permissions: readOptionalStringArray(tool.permissions),
345
- timeout_ms: typeof tool.timeout_ms === "number" ? tool.timeout_ms : null,
346
- cwd_policy: typeof tool.cwd_policy === "string" ? tool.cwd_policy : null,
347
- }));
348
- promptBlocks.push({
349
- id: "recipe.tools_summary",
350
- role: "context",
351
- title: "Recipe Tool Context",
352
- source: `recipe:${opts.recipe.recipe_id}:tools`,
353
- priority: BASE_PROMPT_PRIORITIES.recipe_tools_context,
354
- content: renderRecipePromptJson(toolPayload),
355
- });
356
- }
357
- return promptBlocks;
358
- }
1
+ import { loadExecutionProfilePrompt, loadOwnerProfilePrompt, loadPolicyGatewayPrompt, } from "./base-prompt-sources.js";
2
+ import { collectOverlayPromptBlocks } from "./overlay-prompt-blocks.js";
3
+ import { loadFrameworkRunnerPrompt, normalizeOwnerId } from "./prompt-block-shared.js";
4
+ import { collectRecipePromptBlocks } from "./recipe-prompt-blocks.js";
5
+ export { resolveOwnerProfilePromptSource, resolvePolicyGatewayPromptSource, } from "./base-prompt-sources.js";
359
6
  export async function collectRunnerBasePrompts(opts) {
360
7
  const owner_id = normalizeOwnerId(opts.owner_id);
361
8
  const trimmedAgentsDir = opts.agents_dir?.trim() ?? opts.harness?.workflow.paths.agents_dir;
@@ -374,6 +21,11 @@ export async function collectRunnerBasePrompts(opts) {
374
21
  const basePrompts = resolvedBasePrompts.filter((prompt) => prompt !== null);
375
22
  const prompts = [
376
23
  ...basePrompts,
24
+ ...(await collectOverlayPromptBlocks({
25
+ git_root: opts.git_root,
26
+ task: opts.task,
27
+ command: opts.command,
28
+ })),
377
29
  ...(await collectRecipePromptBlocks({
378
30
  git_root: opts.git_root,
379
31
  recipe: opts.recipe ?? { recipe_id: "", scenario_id: "" },
@@ -0,0 +1,7 @@
1
+ import type { RunnerPromptBlock, RunnerTaskContext } from "../types.js";
2
+ export declare function collectOverlayPromptBlocks(opts: {
3
+ git_root: string;
4
+ task?: RunnerTaskContext;
5
+ command?: string;
6
+ }): Promise<RunnerPromptBlock[]>;
7
+ //# sourceMappingURL=overlay-prompt-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-prompt-blocks.d.ts","sourceRoot":"","sources":["../../../src/runner/context/overlay-prompt-blocks.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA6BxE,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAuC/B"}
@@ -0,0 +1,72 @@
1
+ import path from "node:path";
2
+ import { matchOverlayWhen } from "@agentplaneorg/recipes";
3
+ import { fileExists } from "../../cli/fs-utils.js";
4
+ import { readProjectOverlayBundle } from "../../commands/recipes.js";
5
+ import { normalizeText, OVERLAY_PROMPT_PRIORITIES } from "./prompt-block-shared.js";
6
+ async function detectRepoTypes(gitRoot) {
7
+ const repoTypes = ["generic"];
8
+ const checks = [
9
+ ["package.json", "node"],
10
+ ["pyproject.toml", "python"],
11
+ ["go.mod", "go"],
12
+ ["Cargo.toml", "rust"],
13
+ ];
14
+ for (const [relativePath, repoType] of checks) {
15
+ if (await fileExists(path.join(gitRoot, relativePath)))
16
+ repoTypes.push(repoType);
17
+ }
18
+ return [...new Set(repoTypes)].toSorted();
19
+ }
20
+ function inferTaskKind(task) {
21
+ const tags = Array.isArray(task?.data.tags)
22
+ ? task.data.tags.filter((tag) => typeof tag === "string")
23
+ : [];
24
+ if (tags.includes("docs"))
25
+ return "docs";
26
+ if (tags.includes("refactor"))
27
+ return "refactor";
28
+ if (tags.includes("research"))
29
+ return "research";
30
+ if (tags.includes("bug") || tags.includes("bugfix"))
31
+ return "bugfix";
32
+ if (tags.length > 0)
33
+ return "feature";
34
+ return undefined;
35
+ }
36
+ export async function collectOverlayPromptBlocks(opts) {
37
+ const bundle = await readProjectOverlayBundle({
38
+ agentplaneDir: path.join(opts.git_root, ".agentplane"),
39
+ });
40
+ if (!bundle)
41
+ return [];
42
+ const repoTypes = await detectRepoTypes(opts.git_root);
43
+ const tags = Array.isArray(opts.task?.data.tags)
44
+ ? opts.task.data.tags.filter((tag) => typeof tag === "string")
45
+ : [];
46
+ const taskKind = inferTaskKind(opts.task);
47
+ const blocks = [];
48
+ for (const [surface, fragments] of Object.entries(bundle.surfaces)) {
49
+ for (const fragment of fragments) {
50
+ if (!matchOverlayWhen(fragment.when, {
51
+ task_kind: taskKind,
52
+ command: opts.command,
53
+ tags,
54
+ repo_types: repoTypes,
55
+ })) {
56
+ continue;
57
+ }
58
+ blocks.push({
59
+ id: `overlay.${fragment.recipe_id}.${fragment.id}`,
60
+ role: fragment.strength === "required" ? "policy" : "context",
61
+ title: `${fragment.recipe_name}: ${fragment.id}`,
62
+ source: fragment.source,
63
+ priority: OVERLAY_PROMPT_PRIORITIES[surface] +
64
+ (fragment.order ?? 0),
65
+ surface: surface,
66
+ strength: fragment.strength,
67
+ content: normalizeText(fragment.content),
68
+ });
69
+ }
70
+ }
71
+ return blocks;
72
+ }