agentplane 0.3.13 → 0.3.15

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 (278) 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/framework.manifest.json +7 -0
  5. package/assets/policy/incidents.md +5 -3
  6. package/assets/policy/workflow.branch_pr.md +10 -5
  7. package/dist/.build-manifest.json +280 -180
  8. package/dist/cli/output.d.ts +29 -0
  9. package/dist/cli/output.d.ts.map +1 -1
  10. package/dist/cli/output.js +33 -0
  11. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  12. package/dist/cli/run-cli/command-catalog/core.js +29 -87
  13. package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
  14. package/dist/cli/run-cli/command-catalog/lifecycle.js +4 -12
  15. package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
  16. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  17. package/dist/cli/run-cli/command-catalog/project.js +16 -38
  18. package/dist/cli/run-cli/command-catalog/shared.d.ts +9 -6
  19. package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
  20. package/dist/cli/run-cli/command-catalog/shared.js +23 -6
  21. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  22. package/dist/cli/run-cli/command-catalog/task.js +6 -18
  23. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  24. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  25. package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
  26. package/dist/cli/run-cli/commands/init/recipes.js +1 -0
  27. package/dist/cli/run-cli.js +1 -1
  28. package/dist/cli/run-cli.test-helpers.d.ts +1 -74
  29. package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
  30. package/dist/cli/run-cli.test-helpers.js +1 -769
  31. package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
  32. package/dist/commands/branch/cleanup-merged.js +5 -9
  33. package/dist/commands/branch/work-start.command.d.ts.map +1 -1
  34. package/dist/commands/branch/work-start.command.js +1 -0
  35. package/dist/commands/commit.spec.d.ts.map +1 -1
  36. package/dist/commands/commit.spec.js +2 -0
  37. package/dist/commands/doctor/branch-pr.d.ts +1 -1
  38. package/dist/commands/doctor/branch-pr.d.ts.map +1 -1
  39. package/dist/commands/doctor/branch-pr.js +5 -2
  40. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  41. package/dist/commands/guard/impl/commands.js +4 -1
  42. package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -1
  43. package/dist/commands/guard/impl/comment-commit.js +2 -1
  44. package/dist/commands/guard/impl/env.d.ts +6 -0
  45. package/dist/commands/guard/impl/env.d.ts.map +1 -1
  46. package/dist/commands/guard/impl/env.js +41 -0
  47. package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
  48. package/dist/commands/pr/internal/auto-commit.js +2 -1
  49. package/dist/commands/pr/internal/sync-branch.d.ts +36 -0
  50. package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -0
  51. package/dist/commands/pr/internal/sync-branch.js +113 -0
  52. package/dist/commands/pr/internal/sync-github.d.ts +28 -0
  53. package/dist/commands/pr/internal/sync-github.d.ts.map +1 -0
  54. package/dist/commands/pr/internal/sync-github.js +178 -0
  55. package/dist/commands/pr/internal/sync-model.d.ts +36 -0
  56. package/dist/commands/pr/internal/sync-model.d.ts.map +1 -0
  57. package/dist/commands/pr/internal/sync-model.js +1 -0
  58. package/dist/commands/pr/internal/sync-open-step.d.ts +10 -0
  59. package/dist/commands/pr/internal/sync-open-step.d.ts.map +1 -0
  60. package/dist/commands/pr/internal/sync-open-step.js +128 -0
  61. package/dist/commands/pr/internal/sync-support.d.ts +7 -0
  62. package/dist/commands/pr/internal/sync-support.d.ts.map +1 -0
  63. package/dist/commands/pr/internal/sync-support.js +29 -0
  64. package/dist/commands/pr/internal/sync-update-step.d.ts +6 -0
  65. package/dist/commands/pr/internal/sync-update-step.d.ts.map +1 -0
  66. package/dist/commands/pr/internal/sync-update-step.js +68 -0
  67. package/dist/commands/pr/internal/sync.d.ts +2 -6
  68. package/dist/commands/pr/internal/sync.d.ts.map +1 -1
  69. package/dist/commands/pr/internal/sync.js +83 -529
  70. package/dist/commands/pr/open.d.ts.map +1 -1
  71. package/dist/commands/pr/open.js +25 -8
  72. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  73. package/dist/commands/pr/pr.command.js +7 -2
  74. package/dist/commands/recipes/impl/apply.d.ts +1 -1
  75. package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
  76. package/dist/commands/recipes/impl/apply.js +1 -2
  77. package/dist/commands/recipes/impl/commands/active.d.ts.map +1 -1
  78. package/dist/commands/recipes/impl/commands/active.js +6 -5
  79. package/dist/commands/recipes/impl/commands/add.d.ts +1 -0
  80. package/dist/commands/recipes/impl/commands/add.d.ts.map +1 -1
  81. package/dist/commands/recipes/impl/commands/add.js +32 -27
  82. package/dist/commands/recipes/impl/commands/detach.d.ts.map +1 -1
  83. package/dist/commands/recipes/impl/commands/detach.js +35 -21
  84. package/dist/commands/recipes/impl/commands/disable.d.ts.map +1 -1
  85. package/dist/commands/recipes/impl/commands/disable.js +5 -3
  86. package/dist/commands/recipes/impl/commands/enable.d.ts.map +1 -1
  87. package/dist/commands/recipes/impl/commands/enable.js +5 -3
  88. package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
  89. package/dist/commands/recipes/impl/commands/explain.js +57 -47
  90. package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
  91. package/dist/commands/recipes/impl/commands/info.js +25 -21
  92. package/dist/commands/recipes/impl/commands/install.d.ts +1 -1
  93. package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
  94. package/dist/commands/recipes/impl/commands/install.js +3 -13
  95. package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
  96. package/dist/commands/recipes/impl/commands/list-remote.js +2 -3
  97. package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -1
  98. package/dist/commands/recipes/impl/commands/list.js +7 -6
  99. package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
  100. package/dist/commands/recipes/impl/commands/remove.js +12 -7
  101. package/dist/commands/recipes/impl/commands/update.d.ts.map +1 -1
  102. package/dist/commands/recipes/impl/commands/update.js +38 -24
  103. package/dist/commands/recipes/impl/index.d.ts +1 -1
  104. package/dist/commands/recipes/impl/index.d.ts.map +1 -1
  105. package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
  106. package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
  107. package/dist/commands/recipes/impl/installed-recipes.js +1 -2
  108. package/dist/commands/recipes/impl/mutation-transaction.d.ts +7 -0
  109. package/dist/commands/recipes/impl/mutation-transaction.d.ts.map +1 -0
  110. package/dist/commands/recipes/impl/mutation-transaction.js +47 -0
  111. package/dist/commands/recipes/impl/overlay-project.d.ts +19 -3
  112. package/dist/commands/recipes/impl/overlay-project.d.ts.map +1 -1
  113. package/dist/commands/recipes/impl/overlay-project.js +76 -38
  114. package/dist/commands/recipes/impl/paths.d.ts +0 -3
  115. package/dist/commands/recipes/impl/paths.d.ts.map +1 -1
  116. package/dist/commands/recipes/impl/paths.js +0 -3
  117. package/dist/commands/recipes/impl/project-installed-recipes.d.ts +4 -1
  118. package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
  119. package/dist/commands/recipes/impl/project-installed-recipes.js +6 -4
  120. package/dist/commands/recipes/impl/project-recipe-state.d.ts +1 -1
  121. package/dist/commands/recipes/impl/project-recipe-state.d.ts.map +1 -1
  122. package/dist/commands/recipes/impl/project-registry.d.ts +5 -1
  123. package/dist/commands/recipes/impl/project-registry.d.ts.map +1 -1
  124. package/dist/commands/recipes/impl/project-registry.js +34 -14
  125. package/dist/commands/recipes/impl/resolver.d.ts +1 -1
  126. package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
  127. package/dist/commands/recipes/impl/resolver.js +1 -1
  128. package/dist/commands/recipes/impl/types.d.ts +1 -1
  129. package/dist/commands/recipes/impl/types.d.ts.map +1 -1
  130. package/dist/commands/recipes/impl/version.d.ts +5 -0
  131. package/dist/commands/recipes/impl/version.d.ts.map +1 -0
  132. package/dist/commands/recipes/impl/version.js +9 -0
  133. package/dist/commands/recipes.d.ts +5 -4
  134. package/dist/commands/recipes.d.ts.map +1 -1
  135. package/dist/commands/recipes.js +3 -3
  136. package/dist/commands/release/apply.command.d.ts +1 -1
  137. package/dist/commands/release/apply.command.d.ts.map +1 -1
  138. package/dist/commands/release/apply.command.js +15 -379
  139. package/dist/commands/release/apply.mutation.d.ts +1 -0
  140. package/dist/commands/release/apply.mutation.d.ts.map +1 -1
  141. package/dist/commands/release/apply.mutation.js +24 -1
  142. package/dist/commands/release/apply.pipeline.d.ts +22 -0
  143. package/dist/commands/release/apply.pipeline.d.ts.map +1 -0
  144. package/dist/commands/release/apply.pipeline.js +371 -0
  145. package/dist/commands/release/apply.preflight.d.ts +2 -0
  146. package/dist/commands/release/apply.preflight.d.ts.map +1 -1
  147. package/dist/commands/release/apply.preflight.js +13 -4
  148. package/dist/commands/release/apply.types.d.ts +27 -0
  149. package/dist/commands/release/apply.types.d.ts.map +1 -1
  150. package/dist/commands/release.test-helpers.d.ts +4 -0
  151. package/dist/commands/release.test-helpers.d.ts.map +1 -1
  152. package/dist/commands/release.test-helpers.js +7 -0
  153. package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
  154. package/dist/commands/shared/reconcile-check.js +2 -2
  155. package/dist/commands/shared/task-backend.d.ts +6 -1
  156. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  157. package/dist/commands/shared/task-backend.js +34 -2
  158. package/dist/commands/shared/task-mutation.d.ts.map +1 -1
  159. package/dist/commands/shared/task-mutation.js +4 -4
  160. package/dist/commands/shared/task-store/intents.d.ts +34 -0
  161. package/dist/commands/shared/task-store/intents.d.ts.map +1 -0
  162. package/dist/commands/shared/task-store/intents.js +265 -0
  163. package/dist/commands/shared/task-store/readme.d.ts +28 -0
  164. package/dist/commands/shared/task-store/readme.d.ts.map +1 -0
  165. package/dist/commands/shared/task-store/readme.js +125 -0
  166. package/dist/commands/shared/task-store/store.d.ts +26 -0
  167. package/dist/commands/shared/task-store/store.d.ts.map +1 -0
  168. package/dist/commands/shared/task-store/store.js +105 -0
  169. package/dist/commands/shared/task-store/types.d.ts +94 -0
  170. package/dist/commands/shared/task-store/types.d.ts.map +1 -0
  171. package/dist/commands/shared/task-store/types.js +1 -0
  172. package/dist/commands/shared/task-store.d.ts +3 -109
  173. package/dist/commands/shared/task-store.d.ts.map +1 -1
  174. package/dist/commands/shared/task-store.js +2 -493
  175. package/dist/commands/task/block.d.ts.map +1 -1
  176. package/dist/commands/task/block.js +7 -2
  177. package/dist/commands/task/comment.d.ts.map +1 -1
  178. package/dist/commands/task/comment.js +7 -2
  179. package/dist/commands/task/finish-shared.d.ts.map +1 -1
  180. package/dist/commands/task/finish-shared.js +3 -3
  181. package/dist/commands/task/finish.d.ts.map +1 -1
  182. package/dist/commands/task/finish.js +102 -15
  183. package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
  184. package/dist/commands/task/hosted-close.command.js +23 -2
  185. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
  186. package/dist/commands/task/hosted-merge-sync.js +9 -4
  187. package/dist/commands/task/list.run.d.ts.map +1 -1
  188. package/dist/commands/task/list.run.js +14 -4
  189. package/dist/commands/task/new.command.d.ts.map +1 -1
  190. package/dist/commands/task/new.command.js +16 -2
  191. package/dist/commands/task/new.js +2 -2
  192. package/dist/commands/task/show.d.ts.map +1 -1
  193. package/dist/commands/task/show.js +3 -3
  194. package/dist/commands/task/update.d.ts.map +1 -1
  195. package/dist/commands/task/update.js +11 -3
  196. package/dist/runner/adapters/codex.d.ts.map +1 -1
  197. package/dist/runner/adapters/codex.js +3 -33
  198. package/dist/runner/adapters/custom.d.ts.map +1 -1
  199. package/dist/runner/adapters/custom.js +3 -30
  200. package/dist/runner/adapters/runtime-shared.d.ts +14 -0
  201. package/dist/runner/adapters/runtime-shared.d.ts.map +1 -0
  202. package/dist/runner/adapters/runtime-shared.js +36 -0
  203. package/dist/runner/context/base-prompt-sources.d.ts +30 -0
  204. package/dist/runner/context/base-prompt-sources.d.ts.map +1 -0
  205. package/dist/runner/context/base-prompt-sources.js +144 -0
  206. package/dist/runner/context/base-prompts.d.ts +3 -22
  207. package/dist/runner/context/base-prompts.d.ts.map +1 -1
  208. package/dist/runner/context/base-prompts.js +6 -450
  209. package/dist/runner/context/overlay-prompt-blocks.d.ts +7 -0
  210. package/dist/runner/context/overlay-prompt-blocks.d.ts.map +1 -0
  211. package/dist/runner/context/overlay-prompt-blocks.js +72 -0
  212. package/dist/runner/context/prompt-block-shared.d.ts +54 -0
  213. package/dist/runner/context/prompt-block-shared.d.ts.map +1 -0
  214. package/dist/runner/context/prompt-block-shared.js +106 -0
  215. package/dist/runner/context/recipe-context.d.ts +2 -1
  216. package/dist/runner/context/recipe-context.d.ts.map +1 -1
  217. package/dist/runner/context/recipe-context.js +2 -1
  218. package/dist/runner/context/recipe-prompt-blocks.d.ts +6 -0
  219. package/dist/runner/context/recipe-prompt-blocks.d.ts.map +1 -0
  220. package/dist/runner/context/recipe-prompt-blocks.js +143 -0
  221. package/dist/runner/usecases/scenario-materialize-task.js +2 -2
  222. package/dist/runner/usecases/task-run-inspect.js +2 -2
  223. package/dist/runner/usecases/task-run-lifecycle-shared.js +2 -2
  224. package/dist/runner/usecases/task-run.d.ts.map +1 -1
  225. package/dist/runner/usecases/task-run.js +4 -2
  226. package/dist/runtime/capabilities/recipe.d.ts +1 -1
  227. package/dist/runtime/capabilities/recipe.d.ts.map +1 -1
  228. package/dist/runtime/execution-context.d.ts +63 -0
  229. package/dist/runtime/execution-context.d.ts.map +1 -0
  230. package/dist/{usecases/context/resolve-context.js → runtime/execution-context.js} +23 -26
  231. package/dist/runtime/incidents/advice-strategy.d.ts +15 -0
  232. package/dist/runtime/incidents/advice-strategy.d.ts.map +1 -0
  233. package/dist/runtime/incidents/advice-strategy.js +54 -0
  234. package/dist/runtime/incidents/plan-strategy.d.ts +9 -0
  235. package/dist/runtime/incidents/plan-strategy.d.ts.map +1 -0
  236. package/dist/runtime/incidents/plan-strategy.js +205 -0
  237. package/dist/runtime/incidents/registry-strategy.d.ts +6 -0
  238. package/dist/runtime/incidents/registry-strategy.d.ts.map +1 -0
  239. package/dist/runtime/incidents/registry-strategy.js +280 -0
  240. package/dist/runtime/incidents/resolve.d.ts +3 -25
  241. package/dist/runtime/incidents/resolve.d.ts.map +1 -1
  242. package/dist/runtime/incidents/resolve.js +3 -683
  243. package/dist/runtime/incidents/shared.d.ts +34 -0
  244. package/dist/runtime/incidents/shared.d.ts.map +1 -0
  245. package/dist/runtime/incidents/shared.js +171 -0
  246. package/dist/testing/cli-harness/recipe-archives.d.ts +28 -0
  247. package/dist/testing/cli-harness/recipe-archives.d.ts.map +1 -0
  248. package/dist/testing/cli-harness/recipe-archives.js +374 -0
  249. package/dist/testing/cli-harness/stdio.d.ts +26 -0
  250. package/dist/testing/cli-harness/stdio.d.ts.map +1 -0
  251. package/dist/testing/cli-harness/stdio.js +84 -0
  252. package/dist/testing/cli-harness.d.ts +25 -0
  253. package/dist/testing/cli-harness.d.ts.map +1 -0
  254. package/dist/testing/cli-harness.js +313 -0
  255. package/dist/testing/index.d.ts +2 -0
  256. package/dist/testing/index.d.ts.map +1 -0
  257. package/dist/testing/index.js +1 -0
  258. package/package.json +7 -4
  259. package/dist/commands/recipes/impl/manifest.d.ts +0 -4
  260. package/dist/commands/recipes/impl/manifest.d.ts.map +0 -1
  261. package/dist/commands/recipes/impl/manifest.js +0 -7
  262. package/dist/commands/recipes/impl/normalize.d.ts +0 -8
  263. package/dist/commands/recipes/impl/normalize.d.ts.map +0 -1
  264. package/dist/commands/recipes/impl/normalize.js +0 -54
  265. package/dist/commands/recipes/impl/scenario.d.ts +0 -16
  266. package/dist/commands/recipes/impl/scenario.d.ts.map +0 -1
  267. package/dist/commands/recipes/impl/scenario.js +0 -262
  268. package/dist/recipes/bundled-recipes.d.ts +0 -17
  269. package/dist/recipes/bundled-recipes.d.ts.map +0 -1
  270. package/dist/recipes/bundled-recipes.js +0 -15
  271. package/dist/usecases/context/resolve-context.d.ts +0 -68
  272. package/dist/usecases/context/resolve-context.d.ts.map +0 -1
  273. package/dist/usecases/task/task-list-usecase.d.ts +0 -9
  274. package/dist/usecases/task/task-list-usecase.d.ts.map +0 -1
  275. package/dist/usecases/task/task-list-usecase.js +0 -17
  276. package/dist/usecases/task/task-new-usecase.d.ts +0 -9
  277. package/dist/usecases/task/task-new-usecase.d.ts.map +0 -1
  278. package/dist/usecases/task/task-new-usecase.js +0 -17
@@ -0,0 +1,106 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { resolveBehavior, stripBehaviorValue, } from "../../runtime/behavior/index.js";
3
+ export const FRAMEWORK_RUNNER_PROMPT_URL = new URL("../../../assets/RUNNER.md", import.meta.url);
4
+ export const BASE_PROMPT_PRIORITIES = {
5
+ framework_runner: 100,
6
+ policy_gateway: 200,
7
+ execution_profile: 250,
8
+ owner_profile: 300,
9
+ recipe_execution_context: 400,
10
+ recipe_agent_profile: 500,
11
+ recipe_skill_context: 600,
12
+ recipe_tools_context: 700,
13
+ };
14
+ export const OVERLAY_PROMPT_PRIORITIES = {
15
+ planning: 410,
16
+ execution: 420,
17
+ coding: 430,
18
+ debugging: 440,
19
+ review: 450,
20
+ verification: 460,
21
+ docs: 470,
22
+ finish: 480,
23
+ };
24
+ export function ensureTrailingNewline(text) {
25
+ return text.endsWith("\n") ? text : `${text}\n`;
26
+ }
27
+ export function normalizeOwnerId(ownerIdRaw) {
28
+ const trimmed = ownerIdRaw.trim();
29
+ if (!trimmed)
30
+ throw new Error("Runner base prompt collection requires a non-empty owner id.");
31
+ return trimmed.toUpperCase();
32
+ }
33
+ export function normalizeText(text) {
34
+ return ensureTrailingNewline(text.trimEnd());
35
+ }
36
+ export function validateJsonPrompt(source, text) {
37
+ let parsed;
38
+ try {
39
+ parsed = JSON.parse(text);
40
+ }
41
+ catch {
42
+ throw new Error(`Invalid prompt JSON: ${source} (malformed JSON)`);
43
+ }
44
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
45
+ throw new Error(`Invalid prompt JSON: ${source} (expected object)`);
46
+ }
47
+ return normalizeText(text);
48
+ }
49
+ export function renderRecipePromptJson(value) {
50
+ return normalizeText(JSON.stringify(value, null, 2));
51
+ }
52
+ export function toPromptSource(gitRoot, absPath) {
53
+ return absPath.replace(`${gitRoot}/`, "").replaceAll("\\", "/");
54
+ }
55
+ export function isRecord(value) {
56
+ return !!value && typeof value === "object" && !Array.isArray(value);
57
+ }
58
+ export function readOptionalStringArray(value) {
59
+ return Array.isArray(value)
60
+ ? value.filter((entry) => typeof entry === "string")
61
+ : [];
62
+ }
63
+ export function promptCandidate(opts) {
64
+ return {
65
+ layer: opts.layer,
66
+ source: opts.source,
67
+ value: opts.value,
68
+ order: opts.order,
69
+ metadata: {
70
+ title: opts.value.title,
71
+ },
72
+ };
73
+ }
74
+ export function promptBlockFromResolved(opts) {
75
+ return {
76
+ id: opts.id,
77
+ role: opts.role,
78
+ title: opts.resolved.value.title,
79
+ source: opts.resolved.value.source,
80
+ priority: opts.priority,
81
+ content: opts.resolved.value.content,
82
+ resolution: stripBehaviorValue(opts.resolved),
83
+ };
84
+ }
85
+ export async function loadFrameworkRunnerPrompt() {
86
+ const resolved = resolveBehavior({
87
+ key: "runner.framework_prompt",
88
+ candidates: [
89
+ promptCandidate({
90
+ layer: "builtin",
91
+ source: "bundled:runner-prompt:RUNNER.md",
92
+ value: {
93
+ source: "bundled:runner-prompt:RUNNER.md",
94
+ title: "Framework Runner Prompt",
95
+ content: normalizeText(await readFile(FRAMEWORK_RUNNER_PROMPT_URL, "utf8")),
96
+ },
97
+ }),
98
+ ],
99
+ });
100
+ return promptBlockFromResolved({
101
+ id: "base.framework_runner",
102
+ role: "system",
103
+ priority: BASE_PROMPT_PRIORITIES.framework_runner,
104
+ resolved,
105
+ });
106
+ }
@@ -1,5 +1,6 @@
1
1
  import type { ResolvedProject } from "@agentplaneorg/core";
2
- import { readProjectInstalledRecipes, type ResolvedRecipeScenarioSelection, type ScenarioDefinition } from "../../commands/recipes.js";
2
+ import { type ResolvedRecipeScenarioSelection, type ScenarioDefinition } from "@agentplaneorg/recipes";
3
+ import { readProjectInstalledRecipes } from "../../commands/recipes.js";
3
4
  import type { RunnerRecipeContext } from "../types.js";
4
5
  type InstalledRecipeEntry = Awaited<ReturnType<typeof readProjectInstalledRecipes>>["recipes"][number];
5
6
  export type RunnerRecipeContextEnvelope = {
@@ -1 +1 @@
1
- {"version":3,"file":"recipe-context.d.ts","sourceRoot":"","sources":["../../../src/runner/context/recipe-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAEL,2BAA2B,EAG3B,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,EACxB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,KAAK,oBAAoB,GAAG,OAAO,CACjC,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAC/C,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAErB,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,oBAAoB,CAAC;IAC5B,SAAS,EAAE,+BAA+B,CAAC;IAC3C,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAoEF,wBAAsB,2BAA2B,CAAC,IAAI,EAAE;IACtD,OAAO,EAAE,eAAe,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CA4BvC"}
1
+ {"version":3,"file":"recipe-context.d.ts","sourceRoot":"","sources":["../../../src/runner/context/recipe-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAEL,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAEL,2BAA2B,EAE5B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,KAAK,oBAAoB,GAAG,OAAO,CACjC,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAC/C,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAErB,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,oBAAoB,CAAC;IAC5B,SAAS,EAAE,+BAA+B,CAAC;IAC3C,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAoEF,wBAAsB,2BAA2B,CAAC,IAAI,EAAE;IACtD,OAAO,EAAE,eAAe,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CA4BvC"}
@@ -1,4 +1,5 @@
1
- import { readProjectRecipeAssetRegistry, readProjectInstalledRecipes, readScenarioDefinition, resolveRecipeScenarioSelection, } from "../../commands/recipes.js";
1
+ import { readScenarioDefinition, } from "@agentplaneorg/recipes";
2
+ import { readProjectRecipeAssetRegistry, readProjectInstalledRecipes, resolveRecipeScenarioSelection, } from "../../commands/recipes.js";
2
3
  import { resolveRecipeCapabilityRegistry } from "../../runtime/capabilities/index.js";
3
4
  import { CliError } from "../../shared/errors.js";
4
5
  function toRecipeContext(opts) {
@@ -0,0 +1,6 @@
1
+ import type { RunnerPromptBlock, RunnerRecipeContext } from "../types.js";
2
+ export declare function collectRecipePromptBlocks(opts: {
3
+ git_root: string;
4
+ recipe: RunnerRecipeContext;
5
+ }): Promise<RunnerPromptBlock[]>;
6
+ //# sourceMappingURL=recipe-prompt-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe-prompt-blocks.d.ts","sourceRoot":"","sources":["../../../src/runner/context/recipe-prompt-blocks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAmF5F,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,mBAAmB,CAAC;CAC7B,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA4F/B"}
@@ -0,0 +1,143 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { fileExists } from "../../cli/fs-utils.js";
4
+ import { resolveBehavior } from "../../runtime/behavior/index.js";
5
+ import { BASE_PROMPT_PRIORITIES, isRecord, promptBlockFromResolved, promptCandidate, readOptionalStringArray, renderRecipePromptJson, toPromptSource, } from "./prompt-block-shared.js";
6
+ async function loadRecipePromptTextBlock(opts) {
7
+ const candidates = [];
8
+ const relativeFile = opts.relative_file?.trim();
9
+ if (relativeFile) {
10
+ const absPath = path.join(opts.recipe_dir, relativeFile);
11
+ if (await fileExists(absPath)) {
12
+ const source = toPromptSource(opts.git_root, absPath);
13
+ candidates.push(promptCandidate({
14
+ layer: "extension",
15
+ source,
16
+ value: {
17
+ source,
18
+ title: opts.title,
19
+ content: await readFile(absPath, "utf8"),
20
+ },
21
+ }));
22
+ }
23
+ }
24
+ if (typeof opts.fallback_content === "string" && opts.fallback_content.trim().length > 0) {
25
+ candidates.push(promptCandidate({
26
+ layer: "extension",
27
+ source: opts.fallback_source,
28
+ value: {
29
+ source: opts.fallback_source,
30
+ title: opts.title,
31
+ content: opts.fallback_content,
32
+ },
33
+ order: 10,
34
+ }));
35
+ }
36
+ else if (opts.fallback_payload) {
37
+ candidates.push(promptCandidate({
38
+ layer: "extension",
39
+ source: opts.fallback_source,
40
+ value: {
41
+ source: opts.fallback_source,
42
+ title: opts.title,
43
+ content: renderRecipePromptJson(opts.fallback_payload),
44
+ },
45
+ order: 10,
46
+ }));
47
+ }
48
+ const resolved = resolveBehavior({
49
+ key: opts.prompt_id,
50
+ candidates,
51
+ });
52
+ return promptBlockFromResolved({
53
+ id: opts.prompt_id,
54
+ role: opts.role,
55
+ priority: opts.priority,
56
+ resolved,
57
+ });
58
+ }
59
+ export async function collectRecipePromptBlocks(opts) {
60
+ const recipeDir = opts.recipe.recipe_dir?.trim();
61
+ if (!recipeDir)
62
+ return [];
63
+ const promptBlocks = [];
64
+ const scenario = isRecord(opts.recipe.scenario) ? opts.recipe.scenario : {};
65
+ const executionContext = {
66
+ recipe: {
67
+ id: opts.recipe.recipe_id,
68
+ name: opts.recipe.recipe_name ?? null,
69
+ version: opts.recipe.recipe_version ?? null,
70
+ scenario_id: opts.recipe.scenario_id,
71
+ scenario_file: opts.recipe.scenario_file ?? null,
72
+ },
73
+ selection_reasons: opts.recipe.selection_reasons ?? [],
74
+ run_profile: opts.recipe.run_profile ?? {},
75
+ scenario: {
76
+ summary: typeof scenario.summary === "string" ? scenario.summary : null,
77
+ description: typeof scenario.description === "string" ? scenario.description : null,
78
+ goal: typeof scenario.goal === "string" ? scenario.goal : null,
79
+ evidence: isRecord(scenario.evidence) ? scenario.evidence : null,
80
+ outputs: readOptionalStringArray(scenario.outputs),
81
+ },
82
+ };
83
+ promptBlocks.push({
84
+ id: "recipe.execution_context",
85
+ role: "context",
86
+ title: `Recipe Scenario Context (${opts.recipe.recipe_id}:${opts.recipe.scenario_id})`,
87
+ source: `recipe:${opts.recipe.recipe_id}:${opts.recipe.scenario_id}`,
88
+ priority: BASE_PROMPT_PRIORITIES.recipe_execution_context,
89
+ content: renderRecipePromptJson(executionContext),
90
+ });
91
+ const agentBlocks = await Promise.all((opts.recipe.agents ?? []).map(async (agent, index) => {
92
+ const agentId = typeof agent.id === "string" ? agent.id : `agent_${index + 1}`;
93
+ return loadRecipePromptTextBlock({
94
+ git_root: opts.git_root,
95
+ recipe_dir: recipeDir,
96
+ prompt_id: `recipe.agent.${agentId}`,
97
+ role: "profile",
98
+ title: `Recipe Agent Prompt (${agentId})`,
99
+ relative_file: typeof agent.file === "string" ? agent.file : undefined,
100
+ fallback_source: `recipe:${opts.recipe.recipe_id}:agent:${agentId}`,
101
+ fallback_content: typeof agent.content === "string" ? agent.content : undefined,
102
+ fallback_payload: agent,
103
+ priority: BASE_PROMPT_PRIORITIES.recipe_agent_profile + index,
104
+ });
105
+ }));
106
+ promptBlocks.push(...agentBlocks);
107
+ const skillBlocks = await Promise.all((opts.recipe.skills ?? []).map(async (skill, index) => {
108
+ const skillId = typeof skill.id === "string" ? skill.id : `skill_${index + 1}`;
109
+ return loadRecipePromptTextBlock({
110
+ git_root: opts.git_root,
111
+ recipe_dir: recipeDir,
112
+ prompt_id: `recipe.skill.${skillId}`,
113
+ role: "context",
114
+ title: `Recipe Skill Prompt (${skillId})`,
115
+ relative_file: typeof skill.file === "string" ? skill.file : undefined,
116
+ fallback_source: `recipe:${opts.recipe.recipe_id}:skill:${skillId}`,
117
+ fallback_content: typeof skill.content === "string" ? skill.content : undefined,
118
+ fallback_payload: skill,
119
+ priority: BASE_PROMPT_PRIORITIES.recipe_skill_context + index,
120
+ });
121
+ }));
122
+ promptBlocks.push(...skillBlocks);
123
+ if ((opts.recipe.tools ?? []).length > 0) {
124
+ const toolPayload = (opts.recipe.tools ?? []).map((tool) => ({
125
+ id: typeof tool.id === "string" ? tool.id : null,
126
+ summary: typeof tool.summary === "string" ? tool.summary : null,
127
+ runtime: typeof tool.runtime === "string" ? tool.runtime : null,
128
+ entrypoint: typeof tool.entrypoint === "string" ? tool.entrypoint : null,
129
+ permissions: readOptionalStringArray(tool.permissions),
130
+ timeout_ms: typeof tool.timeout_ms === "number" ? tool.timeout_ms : null,
131
+ cwd_policy: typeof tool.cwd_policy === "string" ? tool.cwd_policy : null,
132
+ }));
133
+ promptBlocks.push({
134
+ id: "recipe.tools_summary",
135
+ role: "context",
136
+ title: "Recipe Tool Context",
137
+ source: `recipe:${opts.recipe.recipe_id}:tools`,
138
+ priority: BASE_PROMPT_PRIORITIES.recipe_tools_context,
139
+ content: renderRecipePromptJson(toolPayload),
140
+ });
141
+ }
142
+ return promptBlocks;
143
+ }
@@ -5,7 +5,7 @@ import { TASK_DOC_VERSION_V3, buildDefaultVerifyStepsSection, defaultTaskDocV3,
5
5
  import { createClarificationContract, createTaskGraphDraft, createTaskIntakeContext, materializeTaskGraphDraft, } from "../../runtime/task-intake/index.js";
6
6
  import { buildTaskDocState } from "../../shared/task-doc-state.js";
7
7
  import { dedupeStrings } from "../../shared/strings.js";
8
- import { makeReadOnlyUsecaseContext } from "../../usecases/context/resolve-context.js";
8
+ import { makeReadOnlyExecutionContext } from "../../runtime/execution-context.js";
9
9
  import { createRunnerRunId } from "../run-id.js";
10
10
  import { assembleRunnerRecipeContext, } from "../context/recipe-context.js";
11
11
  function nowIso() {
@@ -121,7 +121,7 @@ export function buildMaterializedRecipeTask(opts) {
121
121
  export async function materializeRecipeScenarioTask(opts) {
122
122
  const command = opts.ctx ??
123
123
  (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
124
- const executionContext = await makeReadOnlyUsecaseContext(command);
124
+ const executionContext = await makeReadOnlyExecutionContext(command);
125
125
  if (!executionContext.backend.task_backend.generateTaskId) {
126
126
  throw new Error("Backend does not support task materialization: missing generateTaskId()");
127
127
  }
@@ -1,12 +1,12 @@
1
1
  import { loadCommandContext } from "../../commands/shared/task-backend.js";
2
2
  import { CliError } from "../../shared/errors.js";
3
- import { makeReadOnlyUsecaseContext } from "../../usecases/context/resolve-context.js";
3
+ import { makeReadOnlyExecutionContext } from "../../runtime/execution-context.js";
4
4
  import { resolveLatestRunnerRunId, RunnerRunRepository } from "../run-repository.js";
5
5
  import { resolveTaskRunnerPaths } from "../task-run-paths.js";
6
6
  export async function loadTaskRunnerInspection(opts) {
7
7
  const command = opts.ctx ??
8
8
  (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
9
- const executionContext = await makeReadOnlyUsecaseContext(command);
9
+ const executionContext = await makeReadOnlyExecutionContext(command);
10
10
  const task = await executionContext.backend.task_backend.getTask(opts.task_id);
11
11
  if (!task) {
12
12
  throw new CliError({
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
  import { loadCommandContext } from "../../commands/shared/task-backend.js";
3
3
  import { CliError } from "../../shared/errors.js";
4
- import { makeReadOnlyUsecaseContext } from "../../usecases/context/resolve-context.js";
4
+ import { makeReadOnlyExecutionContext } from "../../runtime/execution-context.js";
5
5
  import { createRunnerAdapter } from "../adapters/index.js";
6
6
  import { runnerAdapterCancelledResult } from "../adapters/shared.js";
7
7
  import { evolveRunnerRunState } from "../artifacts.js";
@@ -142,7 +142,7 @@ export function buildSyntheticCancelledState(opts) {
142
142
  export async function loadExistingRunnerExecution(opts) {
143
143
  const command = opts.ctx ??
144
144
  (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
145
- const executionContext = await makeReadOnlyUsecaseContext(command);
145
+ const executionContext = await makeReadOnlyExecutionContext(command);
146
146
  if (opts.require_task_doing !== false) {
147
147
  assertCurrentTaskDoing(opts.task_id, await executionContext.backend.task_backend.getTask(opts.task_id));
148
148
  }
@@ -1 +1 @@
1
- {"version":3,"file":"task-run.d.ts","sourceRoot":"","sources":["../../../src/runner/usecases/task-run.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAuBhG,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,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MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAgDvC"}
@@ -5,7 +5,7 @@ import { resolveRunnerAdapterCapabilityRegistry } from "../../runtime/capabiliti
5
5
  import { consumeExecutionProfileBudget } from "../../runtime/execution-profile/index.js";
6
6
  import { appendFrameworkExplainBehaviorInputs, } from "../../runtime/explain/index.js";
7
7
  import { buildFrameworkProtocolSurface } from "../../runtime/protocol/index.js";
8
- import { makeReadOnlyUsecaseContext } from "../../usecases/context/resolve-context.js";
8
+ import { makeReadOnlyExecutionContext } from "../../runtime/execution-context.js";
9
9
  import { evolveRunnerRunState } from "../artifacts.js";
10
10
  import { createRunnerAdapter } from "../adapters/index.js";
11
11
  import { readRecipeRunProfile } from "../adapters/recipe-run-profile.js";
@@ -166,7 +166,7 @@ export function renderTaskRunnerBootstrap(bundle, invocation) {
166
166
  export async function prepareTaskRunnerExecution(opts) {
167
167
  const command = opts.ctx ??
168
168
  (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
169
- const executionContext = await makeReadOnlyUsecaseContext(command);
169
+ const executionContext = await makeReadOnlyExecutionContext(command);
170
170
  const target = opts.target ?? { kind: "task", task_id: opts.task_id };
171
171
  void executionContext.policy.evaluate({
172
172
  action: target.kind === "recipe_scenario" ? "scenario_execute" : "task_run",
@@ -184,11 +184,13 @@ export async function prepareTaskRunnerExecution(opts) {
184
184
  rootOverride: opts.rootOverride ?? null,
185
185
  task_id: opts.task_id,
186
186
  });
187
+ const runnerCommand = target.kind === "recipe_scenario" ? "recipes scenario execute" : "task run";
187
188
  const base_prompts = await collectRunnerBasePrompts({
188
189
  git_root: executionContext.repo.git_root,
189
190
  owner_id: taskEnvelope.task.data.owner,
190
191
  agents_dir: executionContext.harness.workflow.paths.agents_dir,
191
192
  task: taskEnvelope.task,
193
+ command: runnerCommand,
192
194
  recipe: opts.recipe,
193
195
  harness: executionContext.harness,
194
196
  execution_profile: executionProfile,
@@ -1,4 +1,4 @@
1
- import type { CompiledRecipeAssetEntry, InstalledRecipeEntry, ResolvedRecipeScenarioSelection } from "../../commands/recipes/impl/types.js";
1
+ import type { CompiledRecipeAssetEntry, InstalledRecipeEntry, ResolvedRecipeScenarioSelection } from "@agentplaneorg/recipes";
2
2
  import type { AgentplaneCapabilityRegistry } from "./types.js";
3
3
  type RecipeSelection = Pick<ResolvedRecipeScenarioSelection, "scenario_id" | "agents_involved" | "skills_used" | "tools_used">;
4
4
  type RecipeEntry = Pick<InstalledRecipeEntry, "id" | "version" | "manifest">;
@@ -1 +1 @@
1
- {"version":3,"file":"recipe.d.ts","sourceRoot":"","sources":["../../../src/runtime/capabilities/recipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAChC,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAA6B,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE1F,KAAK,eAAe,GAAG,IAAI,CACzB,+BAA+B,EAC/B,aAAa,GAAG,iBAAiB,GAAG,aAAa,GAAG,YAAY,CACjE,CAAC;AAEF,KAAK,WAAW,GAAG,IAAI,CAAC,oBAAoB,EAAE,IAAI,GAAG,SAAS,GAAG,UAAU,CAAC,CAAC;AAsG7E,wBAAgB,+BAA+B,CAAC,IAAI,EAAE;IACpD,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACpC,SAAS,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CACpC,GAAG,4BAA4B,CAiG/B"}
1
+ {"version":3,"file":"recipe.d.ts","sourceRoot":"","sources":["../../../src/runtime/capabilities/recipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAChC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAA6B,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE1F,KAAK,eAAe,GAAG,IAAI,CACzB,+BAA+B,EAC/B,aAAa,GAAG,iBAAiB,GAAG,aAAa,GAAG,YAAY,CACjE,CAAC;AAEF,KAAK,WAAW,GAAG,IAAI,CAAC,oBAAoB,EAAE,IAAI,GAAG,SAAS,GAAG,UAAU,CAAC,CAAC;AAsG7E,wBAAgB,+BAA+B,CAAC,IAAI,EAAE;IACpD,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACpC,SAAS,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CACpC,GAAG,4BAA4B,CAiG/B"}
@@ -0,0 +1,63 @@
1
+ import type { AgentplaneConfig, ResolvedProject } from "@agentplaneorg/core";
2
+ import type { Adapters } from "../adapters/index.js";
3
+ import { type CommandContext } from "../commands/shared/task-backend.js";
4
+ import { PolicyEngine } from "../policy/engine.js";
5
+ import { type ApprovalRuntime } from "./approvals/index.js";
6
+ import { type AgentplaneCapabilityRegistry } from "./capabilities/index.js";
7
+ import { type ResolvedExecutionProfileRuntime } from "./execution-profile/index.js";
8
+ import { type FrameworkExplainPayload } from "./explain/index.js";
9
+ import { type ResolvedHarnessContract } from "./harness/index.js";
10
+ import { type FrameworkProtocolSurface } from "./protocol/index.js";
11
+ import { type TaskIntakeRuntime } from "./task-intake/index.js";
12
+ export type AgentplaneRepositoryContext = {
13
+ git_root: string;
14
+ agentplane_dir: string;
15
+ workflow_dir: string;
16
+ };
17
+ export type AgentplaneBackendContext = {
18
+ id: string;
19
+ config_path: string;
20
+ capabilities: CommandContext["taskBackend"]["capabilities"] | null;
21
+ task_backend: CommandContext["taskBackend"];
22
+ };
23
+ export type ReadOnlyExecutionContext = {
24
+ command: CommandContext;
25
+ project: CommandContext["resolvedProject"];
26
+ repo: AgentplaneRepositoryContext;
27
+ config: CommandContext["config"];
28
+ backend: AgentplaneBackendContext;
29
+ harness: ResolvedHarnessContract;
30
+ capabilities: AgentplaneCapabilityRegistry;
31
+ execution: ResolvedHarnessContract["execution"];
32
+ executionProfile: ResolvedExecutionProfileRuntime;
33
+ taskIntake: TaskIntakeRuntime;
34
+ frameworkExplain: FrameworkExplainPayload;
35
+ frameworkProtocol: FrameworkProtocolSurface;
36
+ approvals: ResolvedHarnessContract["policy"]["approvals"];
37
+ policy: PolicyEngine;
38
+ approvalRuntime: ApprovalRuntime;
39
+ };
40
+ export type ExecutionContext = ReadOnlyExecutionContext & {
41
+ adapters: Adapters;
42
+ };
43
+ export declare function resolveCommandContext(opts: {
44
+ cwd: string;
45
+ rootOverride?: string | null;
46
+ resolvedProject?: ResolvedProject;
47
+ config?: AgentplaneConfig;
48
+ }): Promise<CommandContext>;
49
+ export declare function resolveReadOnlyExecutionContext(opts: {
50
+ cwd: string;
51
+ rootOverride?: string | null;
52
+ resolvedProject?: ResolvedProject;
53
+ config?: AgentplaneConfig;
54
+ }): Promise<ReadOnlyExecutionContext>;
55
+ export declare function resolveExecutionContext(opts: {
56
+ cwd: string;
57
+ rootOverride?: string | null;
58
+ resolvedProject?: ResolvedProject;
59
+ config?: AgentplaneConfig;
60
+ }): Promise<ExecutionContext>;
61
+ export declare function makeReadOnlyExecutionContext(command: CommandContext): Promise<ReadOnlyExecutionContext>;
62
+ export declare function makeExecutionContext(command: CommandContext): Promise<ExecutionContext>;
63
+ //# sourceMappingURL=execution-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-context.d.ts","sourceRoot":"","sources":["../../src/runtime/execution-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAA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";
2
- import { loadCommandContext } from "../../commands/shared/task-backend.js";
3
- import { PolicyEngine } from "../../policy/engine.js";
4
- import { createApprovalRuntime } from "../../runtime/approvals/index.js";
5
- import { resolveTaskBackendCapabilityRegistry, } from "../../runtime/capabilities/index.js";
6
- import { resolveExecutionProfileRuntime, } from "../../runtime/execution-profile/index.js";
7
- import { buildFrameworkExplainPayload, } from "../../runtime/explain/index.js";
8
- import { resolveHarnessFromCommandContext, } from "../../runtime/harness/index.js";
9
- import { buildFrameworkProtocolSurface, } from "../../runtime/protocol/index.js";
10
- import { createTaskIntakeRuntime, } from "../../runtime/task-intake/index.js";
1
+ import { buildAdapters } from "../adapters/index.js";
2
+ import { loadCommandContext } from "../commands/shared/task-backend.js";
3
+ import { PolicyEngine } from "../policy/engine.js";
4
+ import { createApprovalRuntime } from "./approvals/index.js";
5
+ import { resolveTaskBackendCapabilityRegistry, } from "./capabilities/index.js";
6
+ import { resolveExecutionProfileRuntime, } from "./execution-profile/index.js";
7
+ import { buildFrameworkExplainPayload } from "./explain/index.js";
8
+ import { resolveHarnessFromCommandContext } from "./harness/index.js";
9
+ import { buildFrameworkProtocolSurface } from "./protocol/index.js";
10
+ import { createTaskIntakeRuntime } from "./task-intake/index.js";
11
11
  const READ_ONLY_CONTEXT_CACHE = new WeakMap();
12
- const USECASE_CONTEXT_CACHE = new WeakMap();
12
+ const CONTEXT_CACHE = new WeakMap();
13
13
  export async function resolveCommandContext(opts) {
14
14
  return await loadCommandContext({
15
15
  cwd: opts.cwd,
@@ -18,34 +18,31 @@ export async function resolveCommandContext(opts) {
18
18
  config: opts.config,
19
19
  });
20
20
  }
21
- export async function resolveContext(opts) {
21
+ export async function resolveReadOnlyExecutionContext(opts) {
22
22
  const command = await resolveCommandContext(opts);
23
- return await makeReadOnlyUsecaseContext(command);
23
+ return await makeReadOnlyExecutionContext(command);
24
24
  }
25
- export const resolveReadOnlyExecutionContext = resolveContext;
26
25
  export async function resolveExecutionContext(opts) {
27
26
  const command = await resolveCommandContext(opts);
28
- return await makeUsecaseContext(command);
27
+ return await makeExecutionContext(command);
29
28
  }
30
- export async function makeReadOnlyUsecaseContext(command) {
29
+ export async function makeReadOnlyExecutionContext(command) {
31
30
  let cached = READ_ONLY_CONTEXT_CACHE.get(command);
32
31
  if (!cached) {
33
- cached = buildReadOnlyUsecaseContext(command);
32
+ cached = buildReadOnlyExecutionContext(command);
34
33
  READ_ONLY_CONTEXT_CACHE.set(command, cached);
35
34
  }
36
35
  return await cached;
37
36
  }
38
- export async function makeUsecaseContext(command) {
39
- let cached = USECASE_CONTEXT_CACHE.get(command);
37
+ export async function makeExecutionContext(command) {
38
+ let cached = CONTEXT_CACHE.get(command);
40
39
  if (!cached) {
41
- cached = buildUsecaseContext(command);
42
- USECASE_CONTEXT_CACHE.set(command, cached);
40
+ cached = buildExecutionContext(command);
41
+ CONTEXT_CACHE.set(command, cached);
43
42
  }
44
43
  return await cached;
45
44
  }
46
- export const makeReadOnlyExecutionContext = makeReadOnlyUsecaseContext;
47
- export const makeExecutionContext = makeUsecaseContext;
48
- async function buildReadOnlyUsecaseContext(command) {
45
+ async function buildReadOnlyExecutionContext(command) {
49
46
  const harness = await resolveHarnessFromCommandContext(command);
50
47
  const policy = new PolicyEngine();
51
48
  const executionProfile = resolveExecutionProfileRuntime(command.config);
@@ -103,9 +100,9 @@ async function buildReadOnlyUsecaseContext(command) {
103
100
  approvalRuntime: createApprovalRuntime({ config: command.config, policy }),
104
101
  };
105
102
  }
106
- async function buildUsecaseContext(command) {
103
+ async function buildExecutionContext(command) {
107
104
  return {
108
- ...(await makeReadOnlyUsecaseContext(command)),
105
+ ...(await makeReadOnlyExecutionContext(command)),
109
106
  adapters: buildAdapters(command),
110
107
  };
111
108
  }
@@ -0,0 +1,15 @@
1
+ import type { IncidentAdviceMatch, IncidentAdviceQuery, IncidentRegistry } from "./types.js";
2
+ export declare function buildIncidentAdviceQueryFromTask(opts: {
3
+ taskId: string;
4
+ title: string;
5
+ description: string;
6
+ scope?: string | null;
7
+ tags: readonly string[];
8
+ }): IncidentAdviceQuery;
9
+ export declare function resolveIncidentAdviceMatches(opts: {
10
+ query: IncidentAdviceQuery;
11
+ registry: IncidentRegistry;
12
+ limit?: number;
13
+ }): IncidentAdviceMatch[];
14
+ export declare function renderIncidentAdvice(matches: readonly IncidentAdviceMatch[]): string;
15
+ //# sourceMappingURL=advice-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advice-strategy.d.ts","sourceRoot":"","sources":["../../../src/runtime/incidents/advice-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAS7F,wBAAgB,gCAAgC,CAAC,IAAI,EAAE;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CACzB,GAAG,mBAAmB,CAQtB;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,KAAK,EAAE,mBAAmB,CAAC;IAC3B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,mBAAmB,EAAE,CA8BxB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,mBAAmB,EAAE,GAAG,MAAM,CAcpF"}
@@ -0,0 +1,54 @@
1
+ import { buildIncidentSignature, compareIncidentAdviceMatch, dedupeCaseInsensitive, normalizeSearchText, tokenize, } from "./shared.js";
2
+ export function buildIncidentAdviceQueryFromTask(opts) {
3
+ return {
4
+ taskId: opts.taskId,
5
+ title: opts.title,
6
+ description: opts.description,
7
+ scope: opts.scope ?? null,
8
+ tags: dedupeCaseInsensitive(opts.tags),
9
+ };
10
+ }
11
+ export function resolveIncidentAdviceMatches(opts) {
12
+ const limit = Math.max(1, opts.limit ?? 5);
13
+ const tagSet = new Set(opts.query.tags.map((tag) => tag.trim().toLowerCase()).filter(Boolean));
14
+ const haystack = [opts.query.title, opts.query.description, opts.query.scope ?? ""].join(" ");
15
+ const normalizedHaystack = normalizeSearchText(haystack);
16
+ const queryTokens = new Set([...tokenize(haystack), ...tagSet]);
17
+ const matchesBySignature = new Map();
18
+ for (const entry of opts.registry.entries) {
19
+ const matchedTags = entry.tags.filter((tag) => tagSet.has(tag.trim().toLowerCase()));
20
+ const matchedTerms = entry.match.filter((term) => queryTokens.has(term.trim().toLowerCase()) ||
21
+ normalizedHaystack.includes(normalizeSearchText(term)));
22
+ const normalizedScope = normalizeSearchText(entry.scope);
23
+ const scopeMatched = normalizedScope.length > 0 && normalizedHaystack.includes(normalizedScope);
24
+ const score = matchedTags.length * 5 + matchedTerms.length * 2 + (scopeMatched ? 3 : 0);
25
+ if (score <= 0)
26
+ continue;
27
+ const match = { entry, score, matchedTags, matchedTerms, scopeMatched };
28
+ const signature = buildIncidentSignature(entry);
29
+ const existing = matchesBySignature.get(signature);
30
+ if (!existing || compareIncidentAdviceMatch(match, existing) < 0) {
31
+ matchesBySignature.set(signature, match);
32
+ }
33
+ }
34
+ const matches = [...matchesBySignature.values()];
35
+ matches.sort((left, right) => compareIncidentAdviceMatch(left, right));
36
+ return matches.slice(0, limit);
37
+ }
38
+ export function renderIncidentAdvice(matches) {
39
+ if (matches.length === 0)
40
+ return "No matching incident advice.";
41
+ return matches
42
+ .map((match) => {
43
+ const lines = [
44
+ `- ${match.entry.id} | scope: ${match.entry.scope}`,
45
+ ` failure: ${match.entry.failure}`,
46
+ ` advice: ${match.entry.advice ?? match.entry.rule}`,
47
+ ` rule: ${match.entry.rule}`,
48
+ ];
49
+ if (match.entry.evidence)
50
+ lines.push(` evidence: ${match.entry.evidence}`);
51
+ return lines.join("\n");
52
+ })
53
+ .join("\n");
54
+ }
@@ -0,0 +1,9 @@
1
+ import type { IncidentCollectionPlan, IncidentFindingCandidate, IncidentPromotionTaskContext, IncidentRegistry } from "./types.js";
2
+ export declare function extractIncidentCandidatesFromFindings(findings: string): IncidentFindingCandidate[];
3
+ export declare function planIncidentCollection(opts: {
4
+ task: IncidentPromotionTaskContext;
5
+ findings: string;
6
+ registry: IncidentRegistry;
7
+ now?: Date;
8
+ }): IncidentCollectionPlan;
9
+ //# sourceMappingURL=plan-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-strategy.d.ts","sourceRoot":"","sources":["../../../src/runtime/incidents/plan-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EAGxB,4BAA4B,EAC5B,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AAqBpB,wBAAgB,qCAAqC,CACnD,QAAQ,EAAE,MAAM,GACf,wBAAwB,EAAE,CAI5B;AAwKD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,IAAI,EAAE,4BAA4B,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ,GAAG,sBAAsB,CAyDzB"}