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
@@ -4,7 +4,7 @@ import { exitCodeForError } from "../../cli/exit-codes.js";
4
4
  import { createCliEmitter } from "../../cli/output.js";
5
5
  import { CliError } from "../../shared/errors.js";
6
6
  import { execFileAsync, gitEnv } from "../shared/git.js";
7
- import { gitBranchUpstream } from "../shared/git-ops.js";
7
+ import { gitBranchUpstream, gitCurrentBranch } from "../shared/git-ops.js";
8
8
  import { loadCommandContext } from "../shared/task-backend.js";
9
9
  import { maybeAutoCommitTaskPrArtifacts } from "./internal/auto-commit.js";
10
10
  import { syncPrArtifacts } from "./internal/sync.js";
@@ -21,8 +21,25 @@ function prOpenOutcomeDetails(meta, openOutcome) {
21
21
  async function pushTaskBranchUpstreamIfConfigured(opts) {
22
22
  const upstream = await gitBranchUpstream(opts.gitRoot, opts.branch);
23
23
  const trimmed = upstream?.trim() ?? "";
24
- if (!trimmed)
25
- return false;
24
+ if (!trimmed) {
25
+ const currentBranch = await gitCurrentBranch(opts.gitRoot).catch(() => "");
26
+ if (currentBranch.trim() !== opts.branch.trim())
27
+ return false;
28
+ try {
29
+ await execFileAsync("git", ["remote", "get-url", "origin"], {
30
+ cwd: opts.gitRoot,
31
+ env: gitEnv(),
32
+ });
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ await execFileAsync("git", ["push", "--no-verify", "-u", "origin", `HEAD:${opts.branch}`], {
38
+ cwd: opts.gitRoot,
39
+ env: gitEnv(),
40
+ });
41
+ return true;
42
+ }
26
43
  const slashIndex = trimmed.indexOf("/");
27
44
  if (slashIndex <= 0 || slashIndex === trimmed.length - 1)
28
45
  return false;
@@ -59,14 +76,14 @@ export async function cmdPrOpen(opts) {
59
76
  branch: opts.branch,
60
77
  remoteMode: "sync-only",
61
78
  });
62
- const didAutoCommit = initialSync.meta.branch
63
- ? await maybeAutoCommitTaskPrArtifacts({
79
+ if (initialSync.meta.branch) {
80
+ await maybeAutoCommitTaskPrArtifacts({
64
81
  ctx: commandCtx,
65
82
  taskId: opts.taskId,
66
83
  branch: initialSync.meta.branch,
67
- })
68
- : false;
69
- if (didAutoCommit && !opts.syncOnly && initialSync.meta.branch) {
84
+ });
85
+ }
86
+ if (!opts.syncOnly && initialSync.meta.branch) {
70
87
  await pushTaskBranchUpstreamIfConfigured({
71
88
  gitRoot: commandCtx.resolvedProject.gitRoot,
72
89
  branch: initialSync.meta.branch,
@@ -1 +1 @@
1
- {"version":3,"file":"pr.command.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/pr.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAWhE,KAAK,aAAa,GAAG,kBAAkB,CAAC;AAExC,eAAO,MAAM,MAAM,EAAE,WAAW,CAAC,aAAa,CA8B7C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACt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K,OAAO,CAAC,cAAc,CAAC,GAChD,cAAc,CAAC,kBAAkB,CAAC,CAEpC;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IACrE,KAAK,UAAU,EAAE,GAAG,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,CAWjE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IACvE,KAAK,UAAU,EAAE,GAAG,cAAc,KAAG,OAAO,CAAC,MAAM,CAAC,CAQnE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IACtE,KAAK,UAAU,EAAE,GAAG,aAAa,KAAG,OAAO,CAAC,MAAM,CAAC,CAQlE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IACrE,KAAK,UAAU,EAAE,GAAG,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,CAUjE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IACtE,KAAK,UAAU,EAAE,GAAG,aAAa,KAAG,OAAO,CAAC,MAAM,CAAC,CAWlE;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IAChF,KAAK,UAAU,EAAE,GAAG,uBAAuB,KAAG,OAAO,CAAC,MAAM,CAAC,CAS5E"}
@@ -34,7 +34,7 @@ export const prSpec = {
34
34
  export const prOpenSpec = {
35
35
  id: ["pr", "open"],
36
36
  group: "PR",
37
- summary: "Create PR artifacts for a task.",
37
+ summary: "Create PR artifacts for a task and, unless --sync-only is set, publish/link the remote GitHub PR.",
38
38
  args: [{ name: "task-id", required: true, valueHint: "<task-id>" }],
39
39
  options: [
40
40
  {
@@ -57,7 +57,12 @@ export const prOpenSpec = {
57
57
  description: "Only write local PR artifacts; do not create a remote GitHub PR.",
58
58
  },
59
59
  ],
60
- examples: [{ cmd: "agentplane pr open 202602030608-F1Q8AB --author CODER", why: "Open." }],
60
+ examples: [
61
+ {
62
+ cmd: "agentplane pr open 202602030608-F1Q8AB --author CODER",
63
+ why: "Sync local artifacts, publish the task branch to origin if needed, and create/link the GitHub PR.",
64
+ },
65
+ ],
61
66
  validateRaw: (raw) => {
62
67
  const author = typeof raw.opts.author === "string" ? raw.opts.author.trim() : "";
63
68
  if (!author) {
@@ -1,4 +1,4 @@
1
- import type { RecipeConflictMode, RecipeManifest } from "./types.js";
1
+ import { type RecipeConflictMode, type RecipeManifest } from "@agentplaneorg/recipes";
2
2
  export declare function moveRecipeDir(opts: {
3
3
  from: string;
4
4
  to: string;
@@ -1 +1 @@
1
- {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../src/commands/recipes/impl/apply.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAErE,wBAAsB,aAAa,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAarF;AAyBD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmChB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,kBAAkB,CAAC;CAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuDhB;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhB"}
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../src/commands/recipes/impl/apply.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAWhC,wBAAsB,aAAa,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAarF;AAyBD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmChB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,kBAAkB,CAAC;CAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuDhB;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhB"}
@@ -1,5 +1,6 @@
1
1
  import { cp, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import { normalizeAgentId, readScenarioDefinition, } from "@agentplaneorg/recipes";
3
4
  import { exitCodeForError } from "../../../cli/exit-codes.js";
4
5
  import { fileExists, getPathKind } from "../../../cli/fs-utils.js";
5
6
  import { invalidFieldMessage, missingFileMessage } from "../../../cli/output.js";
@@ -7,8 +8,6 @@ import { CliError } from "../../../shared/errors.js";
7
8
  import { isRecord } from "../../../shared/guards.js";
8
9
  import { writeJsonStableIfChanged } from "../../../shared/write-if-changed.js";
9
10
  import { RECIPES_SCENARIOS_DIR_NAME, RECIPES_SCENARIOS_INDEX_NAME } from "./constants.js";
10
- import { readScenarioDefinition } from "./scenario.js";
11
- import { normalizeAgentId } from "./normalize.js";
12
11
  export async function moveRecipeDir(opts) {
13
12
  await mkdir(path.dirname(opts.to), { recursive: true });
14
13
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"active.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/active.ts"],"names":[],"mappings":"AASA,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,OAAO,CAAC,MAAM,CAAC,CA2ClB"}
1
+ {"version":3,"file":"active.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/active.ts"],"names":[],"mappings":"AAWA,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,OAAO,CAAC,MAAM,CAAC,CAqClB"}
@@ -1,9 +1,10 @@
1
1
  import { resolveProject } from "@agentplaneorg/core";
2
2
  import { mapCoreError } from "../../../../cli/error-map.js";
3
- import { emptyStateMessage } from "../../../../cli/output.js";
3
+ import { createCliEmitter, emptyStateMessage } from "../../../../cli/output.js";
4
4
  import { CliError } from "../../../../shared/errors.js";
5
5
  import { readActiveRecipeIds } from "../overlay-project.js";
6
6
  import { readProjectInstalledRecipes } from "../project-installed-recipes.js";
7
+ const output = createCliEmitter();
7
8
  export async function cmdRecipeActiveParsed(opts) {
8
9
  try {
9
10
  const project = await resolveProject({
@@ -18,11 +19,11 @@ export async function cmdRecipeActiveParsed(opts) {
18
19
  .map((id) => installed.recipes.find((entry) => entry.id === id))
19
20
  .filter(Boolean);
20
21
  if (active.length === 0) {
21
- process.stdout.write(`${emptyStateMessage("active overlays")}\n`);
22
+ output.line(emptyStateMessage("active overlays"));
22
23
  return 0;
23
24
  }
24
25
  if (opts.full) {
25
- process.stdout.write(`${JSON.stringify({
26
+ output.json({
26
27
  schema_version: 1,
27
28
  active: active.map((entry) => ({
28
29
  id: entry.id,
@@ -30,11 +31,11 @@ export async function cmdRecipeActiveParsed(opts) {
30
31
  kind: entry.manifest.kind,
31
32
  summary: entry.manifest.summary,
32
33
  })),
33
- }, null, 2)}\n`);
34
+ });
34
35
  return 0;
35
36
  }
36
37
  for (const entry of active) {
37
- process.stdout.write(`${entry.id}@${entry.version} [${entry.manifest.kind}]\n`);
38
+ output.line(`${entry.id}@${entry.version} [${entry.manifest.kind}]`);
38
39
  }
39
40
  return 0;
40
41
  }
@@ -3,5 +3,6 @@ export declare function cmdRecipeAddParsed(opts: {
3
3
  rootOverride?: string;
4
4
  recipeRef: string;
5
5
  mode?: "copy" | "link";
6
+ activate?: boolean;
6
7
  }): Promise<number>;
7
8
  //# sourceMappingURL=add.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/add.ts"],"names":[],"mappings":"AAqCA,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkFlB"}
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/add.ts"],"names":[],"mappings":"AAuCA,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmFlB"}
@@ -1,13 +1,15 @@
1
1
  import { cp, mkdir, rm, symlink } from "node:fs/promises";
2
+ import { normalizeRecipeTags } from "@agentplaneorg/recipes";
2
3
  import { loadConfig, resolveProject } from "@agentplaneorg/core";
3
4
  import { mapCoreError } from "../../../../cli/error-map.js";
4
5
  import { exitCodeForError } from "../../../../cli/exit-codes.js";
5
6
  import { CliError } from "../../../../shared/errors.js";
6
- import { refreshProjectOverlayArtifacts } from "../overlay-project.js";
7
+ import { runVendoredRecipeMutation } from "../mutation-transaction.js";
8
+ import { publishProjectRecipesState } from "../overlay-project.js";
7
9
  import { readInstalledRecipesFile } from "../installed-recipes.js";
8
- import { normalizeRecipeTags } from "../normalize.js";
9
10
  import { hashRecipeTree } from "../project-recipe-state.js";
10
- import { readProjectRecipesRegistry, upsertProjectRecipeRegistryEntry, } from "../project-registry.js";
11
+ import { readProjectRecipesRegistry, replaceProjectRecipeRegistryEntry, } from "../project-registry.js";
12
+ import { pickLatestRecipeVersion } from "../version.js";
11
13
  import { resolveInstalledRecipeDir, resolveInstalledRecipesPath, resolveProjectRecipesPackagesDir, resolveProjectVendoredRecipeDir, } from "../paths.js";
12
14
  function parseRecipeRef(raw) {
13
15
  const value = raw.trim();
@@ -32,12 +34,10 @@ export async function cmdRecipeAddParsed(opts) {
32
34
  const loaded = await loadConfig(project.agentplaneDir);
33
35
  const requested = parseRecipeRef(opts.recipeRef);
34
36
  const cache = await readInstalledRecipesFile(resolveInstalledRecipesPath());
35
- const cachedEntries = cache.recipes
36
- .filter((entry) => entry.id === requested.id)
37
- .toSorted((left, right) => left.version.localeCompare(right.version));
37
+ const cachedEntries = cache.recipes.filter((entry) => entry.id === requested.id);
38
38
  const cached = requested.version
39
39
  ? cachedEntries.find((entry) => entry.version === requested.version)
40
- : cachedEntries.at(-1);
40
+ : pickLatestRecipeVersion(cachedEntries);
41
41
  if (!cached) {
42
42
  throw new CliError({
43
43
  exitCode: exitCodeForError("E_IO"),
@@ -61,31 +61,36 @@ export async function cmdRecipeAddParsed(opts) {
61
61
  : `Recipe already vendored: ${cached.id}@${existing.version}. Remove it first or use a dedicated update flow instead of overwriting it with recipes add.`,
62
62
  });
63
63
  }
64
- await mkdir(resolveProjectRecipesPackagesDir(project), { recursive: true });
65
- await rm(targetDir, { recursive: true, force: true });
66
- await (materialization === "link"
67
- ? symlink(sourceDir, targetDir, "dir")
68
- : cp(sourceDir, targetDir, { recursive: true }));
69
64
  const installedAt = new Date().toISOString();
70
65
  const tags = normalizeRecipeTags(cached.tags ?? cached.manifest.tags ?? []);
71
66
  const sourceSha256 = await hashRecipeTree(sourceDir);
72
- const vendoredSha256 = await hashRecipeTree(targetDir);
73
- await upsertProjectRecipeRegistryEntry({
74
- project,
75
- entry: {
76
- id: cached.id,
77
- version: cached.version,
78
- path: `packages/${cached.id}`,
79
- active: false,
80
- materialization,
81
- source_ref: `${cached.id}@${cached.version}`,
82
- source_sha256: sourceSha256,
83
- vendored_sha256: vendoredSha256,
84
- installed_at: installedAt,
85
- tags,
67
+ await mkdir(resolveProjectRecipesPackagesDir(project), { recursive: true });
68
+ await runVendoredRecipeMutation({
69
+ targetDir,
70
+ mode: "create",
71
+ materialize: async (nextTargetDir) => {
72
+ await rm(nextTargetDir, { recursive: true, force: true });
73
+ await (materialization === "link"
74
+ ? symlink(sourceDir, nextTargetDir, "dir")
75
+ : cp(sourceDir, nextTargetDir, { recursive: true }));
76
+ },
77
+ commit: async () => {
78
+ const vendoredSha256 = await hashRecipeTree(targetDir);
79
+ const nextRegistry = replaceProjectRecipeRegistryEntry(registry, {
80
+ id: cached.id,
81
+ version: cached.version,
82
+ path: `packages/${cached.id}`,
83
+ active: opts.activate === true,
84
+ materialization,
85
+ source_ref: `${cached.id}@${cached.version}`,
86
+ source_sha256: sourceSha256,
87
+ vendored_sha256: vendoredSha256,
88
+ installed_at: installedAt,
89
+ tags,
90
+ });
91
+ await publishProjectRecipesState({ project, registry: nextRegistry });
86
92
  },
87
93
  });
88
- await refreshProjectOverlayArtifacts(project);
89
94
  process.stdout.write(`Vendored recipe ${cached.id}@${cached.version} into project (${materialization})\n`);
90
95
  if (materialization === "link") {
91
96
  process.stdout.write("Warning: link mode is not portable; use `agentplane recipes detach` before sharing the repo.\n");
@@ -1 +1 @@
1
- {"version":3,"file":"detach.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/detach.ts"],"names":[],"mappings":"AAgBA,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CA+ElB"}
1
+ {"version":3,"file":"detach.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/detach.ts"],"names":[],"mappings":"AAoBA,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CA2FlB"}
@@ -1,14 +1,15 @@
1
- import { cp, rm } from "node:fs/promises";
1
+ import { cp } from "node:fs/promises";
2
+ import { normalizeRecipeTags } from "@agentplaneorg/recipes";
2
3
  import { loadConfig, resolveProject } from "@agentplaneorg/core";
3
4
  import { mapCoreError } from "../../../../cli/error-map.js";
4
5
  import { exitCodeForError } from "../../../../cli/exit-codes.js";
5
6
  import { CliError } from "../../../../shared/errors.js";
6
7
  import { ensureActionApproved } from "../../../shared/approval-requirements.js";
7
8
  import { readInstalledRecipesFile } from "../installed-recipes.js";
8
- import { normalizeRecipeTags } from "../normalize.js";
9
- import { readActiveRecipeIds, refreshProjectOverlayArtifacts } from "../overlay-project.js";
9
+ import { runVendoredRecipeMutation } from "../mutation-transaction.js";
10
+ import { publishProjectRecipesState } from "../overlay-project.js";
10
11
  import { hashRecipeTree, inspectProjectRecipe } from "../project-recipe-state.js";
11
- import { upsertProjectRecipeRegistryEntry } from "../project-registry.js";
12
+ import { readProjectRecipesRegistry, replaceProjectRecipeRegistryEntry, } from "../project-registry.js";
12
13
  import { resolveInstalledRecipesPath, resolveProjectVendoredRecipeDir } from "../paths.js";
13
14
  export async function cmdRecipeDetachParsed(opts) {
14
15
  try {
@@ -32,6 +33,14 @@ export async function cmdRecipeDetachParsed(opts) {
32
33
  message: `Cached source is missing for ${inspection.entry.id}@${inspection.entry.version}. Re-install it before detaching.`,
33
34
  });
34
35
  }
36
+ const currentSourceSha256 = inspection.current_source_sha256;
37
+ if (!currentSourceSha256) {
38
+ throw new CliError({
39
+ exitCode: exitCodeForError("E_IO"),
40
+ code: "E_IO",
41
+ message: `Cached source hash is missing for ${inspection.entry.id}@${inspection.entry.version}`,
42
+ });
43
+ }
35
44
  if (inspection.state === "modified") {
36
45
  throw new CliError({
37
46
  exitCode: exitCodeForError("E_USAGE"),
@@ -40,7 +49,7 @@ export async function cmdRecipeDetachParsed(opts) {
40
49
  });
41
50
  }
42
51
  const cache = await readInstalledRecipesFile(resolveInstalledRecipesPath());
43
- const activeIds = await readActiveRecipeIds(project);
52
+ const registry = await readProjectRecipesRegistry(project);
44
53
  const cached = cache.recipes.find((entry) => entry.id === inspection.entry.id && entry.version === inspection.entry.version);
45
54
  if (!cached) {
46
55
  throw new CliError({
@@ -56,24 +65,29 @@ export async function cmdRecipeDetachParsed(opts) {
56
65
  reason: `recipes detach ${inspection.entry.id}@${inspection.entry.version}`,
57
66
  });
58
67
  const targetDir = resolveProjectVendoredRecipeDir(project, inspection.entry.id);
59
- await rm(targetDir, { recursive: true, force: true });
60
- await cp(inspection.source_dir, targetDir, { recursive: true });
61
- await upsertProjectRecipeRegistryEntry({
62
- project,
63
- entry: {
64
- id: inspection.entry.id,
65
- version: inspection.entry.version,
66
- path: inspection.entry.project_path,
67
- active: activeIds.includes(inspection.entry.id),
68
- materialization: "copy",
69
- source_ref: inspection.entry.source_ref,
70
- source_sha256: inspection.current_source_sha256,
71
- vendored_sha256: await hashRecipeTree(targetDir),
72
- installed_at: inspection.entry.installed_at,
73
- tags: normalizeRecipeTags(cached.tags ?? cached.manifest.tags ?? []),
68
+ await runVendoredRecipeMutation({
69
+ targetDir,
70
+ mode: "replace",
71
+ materialize: async (nextTargetDir) => {
72
+ await cp(inspection.source_dir, nextTargetDir, { recursive: true });
73
+ },
74
+ commit: async () => {
75
+ const vendoredSha256 = await hashRecipeTree(targetDir);
76
+ const nextRegistry = replaceProjectRecipeRegistryEntry(registry, {
77
+ id: inspection.entry.id,
78
+ version: inspection.entry.version,
79
+ path: inspection.entry.project_path,
80
+ active: registry.recipes.find((entry) => entry.id === inspection.entry.id)?.active === true,
81
+ materialization: "copy",
82
+ source_ref: inspection.entry.source_ref,
83
+ source_sha256: currentSourceSha256,
84
+ vendored_sha256: vendoredSha256,
85
+ installed_at: inspection.entry.installed_at,
86
+ tags: normalizeRecipeTags(cached.tags ?? cached.manifest.tags ?? []),
87
+ });
88
+ await publishProjectRecipesState({ project, registry: nextRegistry });
74
89
  },
75
90
  });
76
- await refreshProjectOverlayArtifacts(project);
77
91
  process.stdout.write(`Detached recipe ${inspection.entry.id}@${inspection.entry.version} into a project-local copy.\n`);
78
92
  return 0;
79
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"disable.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/disable.ts"],"names":[],"mappings":"AAOA,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CAclB"}
1
+ {"version":3,"file":"disable.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/disable.ts"],"names":[],"mappings":"AAQA,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CAelB"}
@@ -1,15 +1,17 @@
1
1
  import { resolveProject } from "@agentplaneorg/core";
2
2
  import { mapCoreError } from "../../../../cli/error-map.js";
3
3
  import { CliError } from "../../../../shared/errors.js";
4
- import { refreshProjectOverlayArtifacts, setRecipeActive } from "../overlay-project.js";
4
+ import { publishProjectRecipesState } from "../overlay-project.js";
5
+ import { readProjectRecipesRegistry, setProjectRecipeActiveInFile } from "../project-registry.js";
5
6
  export async function cmdRecipeDisableParsed(opts) {
6
7
  try {
7
8
  const project = await resolveProject({
8
9
  cwd: opts.cwd,
9
10
  rootOverride: opts.rootOverride ?? null,
10
11
  });
11
- await setRecipeActive({ project, recipeId: opts.id, active: false });
12
- const { bundle } = await refreshProjectOverlayArtifacts(project);
12
+ const registry = await readProjectRecipesRegistry(project);
13
+ const nextRegistry = setProjectRecipeActiveInFile(registry, opts.id, false);
14
+ const { bundle } = await publishProjectRecipesState({ project, registry: nextRegistry });
13
15
  process.stdout.write(`Disabled overlay ${opts.id} (${bundle.active.length} active)\n`);
14
16
  return 0;
15
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enable.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/enable.ts"],"names":[],"mappings":"AASA,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BlB"}
1
+ {"version":3,"file":"enable.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/enable.ts"],"names":[],"mappings":"AAUA,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CA+BlB"}
@@ -2,8 +2,9 @@ import { resolveProject } from "@agentplaneorg/core";
2
2
  import { mapCoreError } from "../../../../cli/error-map.js";
3
3
  import { exitCodeForError } from "../../../../cli/exit-codes.js";
4
4
  import { CliError } from "../../../../shared/errors.js";
5
- import { refreshProjectOverlayArtifacts, setRecipeActive } from "../overlay-project.js";
5
+ import { publishProjectRecipesState } from "../overlay-project.js";
6
6
  import { readProjectInstalledRecipes } from "../project-installed-recipes.js";
7
+ import { readProjectRecipesRegistry, setProjectRecipeActiveInFile } from "../project-registry.js";
7
8
  export async function cmdRecipeEnableParsed(opts) {
8
9
  try {
9
10
  const project = await resolveProject({
@@ -26,8 +27,9 @@ export async function cmdRecipeEnableParsed(opts) {
26
27
  message: `Recipe ${opts.id} is not a project overlay`,
27
28
  });
28
29
  }
29
- await setRecipeActive({ project, recipeId: opts.id, active: true });
30
- const { bundle } = await refreshProjectOverlayArtifacts(project);
30
+ const registry = await readProjectRecipesRegistry(project);
31
+ const nextRegistry = setProjectRecipeActiveInFile(registry, opts.id, true);
32
+ const { bundle } = await publishProjectRecipesState({ project, registry: nextRegistry });
31
33
  process.stdout.write(`Enabled overlay ${opts.id} (${bundle.active.length} active)\n`);
32
34
  return 0;
33
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/explain.ts"],"names":[],"mappings":"AAeA,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CA4KlB"}
1
+ {"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/explain.ts"],"names":[],"mappings":"AAkBA,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CA0LlB"}