agentplane 0.3.12 → 0.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. package/assets/RUNNER.md +1 -1
  2. package/assets/agents/ORCHESTRATOR.json +1 -1
  3. package/assets/agents/SKILL_EXTRACTOR.json +31 -0
  4. package/assets/codex-plugin/assets/header.png +0 -0
  5. package/assets/codex-plugin/assets/icon.svg +1 -0
  6. package/assets/codex-plugin/assets/logo.svg +1 -0
  7. package/assets/codex-plugin/skills/agentplane/SKILL.md +35 -0
  8. package/assets/framework.manifest.json +7 -0
  9. package/assets/policy/governance.md +4 -2
  10. package/assets/policy/incidents.md +4 -19
  11. package/assets/policy/workflow.branch_pr.md +10 -5
  12. package/assets/policy/workflow.release.md +5 -2
  13. package/dist/.build-manifest.json +409 -219
  14. package/dist/cli/exit-codes.d.ts.map +1 -1
  15. package/dist/cli/exit-codes.js +1 -0
  16. package/dist/cli/output.d.ts +29 -0
  17. package/dist/cli/output.d.ts.map +1 -1
  18. package/dist/cli/output.js +33 -0
  19. package/dist/cli/reason-codes.d.ts +1 -1
  20. package/dist/cli/reason-codes.d.ts.map +1 -1
  21. package/dist/cli/reason-codes.js +12 -0
  22. package/dist/cli/run-cli/command-catalog/core.d.ts +1 -1
  23. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  24. package/dist/cli/run-cli/command-catalog/core.js +36 -78
  25. package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
  26. package/dist/cli/run-cli/command-catalog/lifecycle.js +4 -12
  27. package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
  28. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  29. package/dist/cli/run-cli/command-catalog/project.js +27 -31
  30. package/dist/cli/run-cli/command-catalog/shared.d.ts +9 -6
  31. package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
  32. package/dist/cli/run-cli/command-catalog/shared.js +23 -6
  33. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  34. package/dist/cli/run-cli/command-catalog/task.js +6 -18
  35. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  36. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  37. package/dist/cli/run-cli/commands/codex.d.ts +14 -0
  38. package/dist/cli/run-cli/commands/codex.d.ts.map +1 -0
  39. package/dist/cli/run-cli/commands/codex.js +100 -0
  40. package/dist/cli/run-cli/commands/core.d.ts +1 -0
  41. package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
  42. package/dist/cli/run-cli/commands/core.js +1 -0
  43. package/dist/cli/run-cli/commands/init/recipes.d.ts +9 -1
  44. package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
  45. package/dist/cli/run-cli/commands/init/recipes.js +33 -22
  46. package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
  47. package/dist/cli/run-cli/commands/init.js +26 -21
  48. package/dist/cli/run-cli/error-guidance.js +20 -0
  49. package/dist/cli/run-cli.js +1 -1
  50. package/dist/cli/run-cli.test-helpers.d.ts +1 -74
  51. package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
  52. package/dist/cli/run-cli.test-helpers.js +1 -766
  53. package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
  54. package/dist/commands/branch/cleanup-merged.js +5 -9
  55. package/dist/commands/branch/work-start.command.d.ts.map +1 -1
  56. package/dist/commands/branch/work-start.command.js +1 -0
  57. package/dist/commands/codex/plugin-install.d.ts +26 -0
  58. package/dist/commands/codex/plugin-install.d.ts.map +1 -0
  59. package/dist/commands/codex/plugin-install.js +209 -0
  60. package/dist/commands/commit.spec.d.ts.map +1 -1
  61. package/dist/commands/commit.spec.js +2 -0
  62. package/dist/commands/doctor/branch-pr.d.ts +1 -1
  63. package/dist/commands/doctor/branch-pr.d.ts.map +1 -1
  64. package/dist/commands/doctor/branch-pr.js +5 -2
  65. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  66. package/dist/commands/guard/impl/commands.js +4 -1
  67. package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -1
  68. package/dist/commands/guard/impl/comment-commit.js +2 -1
  69. package/dist/commands/guard/impl/env.d.ts +6 -0
  70. package/dist/commands/guard/impl/env.d.ts.map +1 -1
  71. package/dist/commands/guard/impl/env.js +41 -0
  72. package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
  73. package/dist/commands/pr/integrate/cmd.js +81 -5
  74. package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
  75. package/dist/commands/pr/integrate/internal/prepare.js +38 -7
  76. package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
  77. package/dist/commands/pr/internal/auto-commit.js +13 -7
  78. package/dist/commands/pr/internal/sync-branch.d.ts +36 -0
  79. package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -0
  80. package/dist/commands/pr/internal/sync-branch.js +113 -0
  81. package/dist/commands/pr/internal/sync-github.d.ts +28 -0
  82. package/dist/commands/pr/internal/sync-github.d.ts.map +1 -0
  83. package/dist/commands/pr/internal/sync-github.js +178 -0
  84. package/dist/commands/pr/internal/sync-model.d.ts +36 -0
  85. package/dist/commands/pr/internal/sync-model.d.ts.map +1 -0
  86. package/dist/commands/pr/internal/sync-model.js +1 -0
  87. package/dist/commands/pr/internal/sync-open-step.d.ts +10 -0
  88. package/dist/commands/pr/internal/sync-open-step.d.ts.map +1 -0
  89. package/dist/commands/pr/internal/sync-open-step.js +128 -0
  90. package/dist/commands/pr/internal/sync-support.d.ts +7 -0
  91. package/dist/commands/pr/internal/sync-support.d.ts.map +1 -0
  92. package/dist/commands/pr/internal/sync-support.js +29 -0
  93. package/dist/commands/pr/internal/sync-update-step.d.ts +6 -0
  94. package/dist/commands/pr/internal/sync-update-step.d.ts.map +1 -0
  95. package/dist/commands/pr/internal/sync-update-step.js +68 -0
  96. package/dist/commands/pr/internal/sync.d.ts +2 -6
  97. package/dist/commands/pr/internal/sync.d.ts.map +1 -1
  98. package/dist/commands/pr/internal/sync.js +83 -525
  99. package/dist/commands/pr/open.d.ts.map +1 -1
  100. package/dist/commands/pr/open.js +62 -7
  101. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  102. package/dist/commands/pr/pr.command.js +7 -2
  103. package/dist/commands/recipes/active.command.d.ts +7 -0
  104. package/dist/commands/recipes/active.command.d.ts.map +1 -0
  105. package/dist/commands/recipes/active.command.js +12 -0
  106. package/dist/commands/recipes/add.command.d.ts +8 -0
  107. package/dist/commands/recipes/add.command.d.ts.map +1 -0
  108. package/dist/commands/recipes/add.command.js +33 -0
  109. package/dist/commands/recipes/detach.command.d.ts +7 -0
  110. package/dist/commands/recipes/detach.command.d.ts.map +1 -0
  111. package/dist/commands/recipes/detach.command.js +19 -0
  112. package/dist/commands/recipes/disable.command.d.ts +7 -0
  113. package/dist/commands/recipes/disable.command.d.ts.map +1 -0
  114. package/dist/commands/recipes/disable.command.js +10 -0
  115. package/dist/commands/recipes/enable.command.d.ts +7 -0
  116. package/dist/commands/recipes/enable.command.d.ts.map +1 -0
  117. package/dist/commands/recipes/enable.command.js +10 -0
  118. package/dist/commands/recipes/explain-active.command.d.ts +5 -0
  119. package/dist/commands/recipes/explain-active.command.d.ts.map +1 -0
  120. package/dist/commands/recipes/explain-active.command.js +11 -0
  121. package/dist/commands/recipes/explain.command.d.ts.map +1 -1
  122. package/dist/commands/recipes/explain.command.js +4 -2
  123. package/dist/commands/recipes/impl/apply.d.ts +1 -1
  124. package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
  125. package/dist/commands/recipes/impl/apply.js +34 -16
  126. package/dist/commands/recipes/impl/commands/active.d.ts +6 -0
  127. package/dist/commands/recipes/impl/commands/active.d.ts.map +1 -0
  128. package/dist/commands/recipes/impl/commands/active.js +47 -0
  129. package/dist/commands/recipes/impl/commands/add.d.ts +8 -0
  130. package/dist/commands/recipes/impl/commands/add.d.ts.map +1 -0
  131. package/dist/commands/recipes/impl/commands/add.js +105 -0
  132. package/dist/commands/recipes/impl/commands/detach.d.ts +6 -0
  133. package/dist/commands/recipes/impl/commands/detach.d.ts.map +1 -0
  134. package/dist/commands/recipes/impl/commands/detach.js +99 -0
  135. package/dist/commands/recipes/impl/commands/disable.d.ts +6 -0
  136. package/dist/commands/recipes/impl/commands/disable.d.ts.map +1 -0
  137. package/dist/commands/recipes/impl/commands/disable.js +23 -0
  138. package/dist/commands/recipes/impl/commands/enable.d.ts +6 -0
  139. package/dist/commands/recipes/impl/commands/enable.d.ts.map +1 -0
  140. package/dist/commands/recipes/impl/commands/enable.js +41 -0
  141. package/dist/commands/recipes/impl/commands/explain-active.d.ts +5 -0
  142. package/dist/commands/recipes/impl/commands/explain-active.d.ts.map +1 -0
  143. package/dist/commands/recipes/impl/commands/explain-active.js +20 -0
  144. package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
  145. package/dist/commands/recipes/impl/commands/explain.js +83 -36
  146. package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
  147. package/dist/commands/recipes/impl/commands/info.js +39 -22
  148. package/dist/commands/recipes/impl/commands/install.d.ts +1 -1
  149. package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
  150. package/dist/commands/recipes/impl/commands/install.js +35 -42
  151. package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
  152. package/dist/commands/recipes/impl/commands/list-remote.js +2 -3
  153. package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -1
  154. package/dist/commands/recipes/impl/commands/list.js +13 -12
  155. package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
  156. package/dist/commands/recipes/impl/commands/remove.js +12 -2
  157. package/dist/commands/recipes/impl/commands/update.d.ts +7 -0
  158. package/dist/commands/recipes/impl/commands/update.d.ts.map +1 -0
  159. package/dist/commands/recipes/impl/commands/update.js +107 -0
  160. package/dist/commands/recipes/impl/commands.d.ts +7 -0
  161. package/dist/commands/recipes/impl/commands.d.ts.map +1 -1
  162. package/dist/commands/recipes/impl/commands.js +7 -0
  163. package/dist/commands/recipes/impl/constants.d.ts +1 -14
  164. package/dist/commands/recipes/impl/constants.d.ts.map +1 -1
  165. package/dist/commands/recipes/impl/constants.js +1 -18
  166. package/dist/commands/recipes/impl/index.d.ts +1 -1
  167. package/dist/commands/recipes/impl/index.d.ts.map +1 -1
  168. package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
  169. package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
  170. package/dist/commands/recipes/impl/installed-recipes.js +1 -2
  171. package/dist/commands/recipes/impl/mutation-transaction.d.ts +7 -0
  172. package/dist/commands/recipes/impl/mutation-transaction.d.ts.map +1 -0
  173. package/dist/commands/recipes/impl/mutation-transaction.js +47 -0
  174. package/dist/commands/recipes/impl/overlay-project.d.ts +48 -0
  175. package/dist/commands/recipes/impl/overlay-project.d.ts.map +1 -0
  176. package/dist/commands/recipes/impl/overlay-project.js +320 -0
  177. package/dist/commands/recipes/impl/paths.d.ts +17 -2
  178. package/dist/commands/recipes/impl/paths.d.ts.map +1 -1
  179. package/dist/commands/recipes/impl/paths.js +20 -5
  180. package/dist/commands/recipes/impl/project-installed-recipes.d.ts +5 -4
  181. package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
  182. package/dist/commands/recipes/impl/project-installed-recipes.js +34 -76
  183. package/dist/commands/recipes/impl/project-recipe-state.d.ts +18 -0
  184. package/dist/commands/recipes/impl/project-recipe-state.d.ts.map +1 -0
  185. package/dist/commands/recipes/impl/project-recipe-state.js +94 -0
  186. package/dist/commands/recipes/impl/project-registry.d.ts +24 -0
  187. package/dist/commands/recipes/impl/project-registry.d.ts.map +1 -0
  188. package/dist/commands/recipes/impl/project-registry.js +124 -0
  189. package/dist/commands/recipes/impl/resolver.d.ts +1 -1
  190. package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
  191. package/dist/commands/recipes/impl/resolver.js +6 -4
  192. package/dist/commands/recipes/impl/types.d.ts +1 -240
  193. package/dist/commands/recipes/impl/types.d.ts.map +1 -1
  194. package/dist/commands/recipes/impl/version.d.ts +5 -0
  195. package/dist/commands/recipes/impl/version.d.ts.map +1 -0
  196. package/dist/commands/recipes/impl/version.js +9 -0
  197. package/dist/commands/recipes/info.command.js +2 -2
  198. package/dist/commands/recipes/install.spec.js +4 -4
  199. package/dist/commands/recipes/list.command.js +4 -4
  200. package/dist/commands/recipes/remove.command.js +2 -2
  201. package/dist/commands/recipes/update.command.d.ts +8 -0
  202. package/dist/commands/recipes/update.command.d.ts.map +1 -0
  203. package/dist/commands/recipes/update.command.js +35 -0
  204. package/dist/commands/recipes.d.ts +10 -6
  205. package/dist/commands/recipes.d.ts.map +1 -1
  206. package/dist/commands/recipes.js +8 -5
  207. package/dist/commands/recipes.test-helpers.d.ts +3 -3
  208. package/dist/commands/recipes.test-helpers.d.ts.map +1 -1
  209. package/dist/commands/recipes.test-helpers.js +105 -15
  210. package/dist/commands/release/apply.command.d.ts +1 -1
  211. package/dist/commands/release/apply.command.d.ts.map +1 -1
  212. package/dist/commands/release/apply.command.js +15 -379
  213. package/dist/commands/release/apply.mutation.d.ts +1 -0
  214. package/dist/commands/release/apply.mutation.d.ts.map +1 -1
  215. package/dist/commands/release/apply.mutation.js +24 -1
  216. package/dist/commands/release/apply.pipeline.d.ts +22 -0
  217. package/dist/commands/release/apply.pipeline.d.ts.map +1 -0
  218. package/dist/commands/release/apply.pipeline.js +371 -0
  219. package/dist/commands/release/apply.preflight.d.ts +2 -0
  220. package/dist/commands/release/apply.preflight.d.ts.map +1 -1
  221. package/dist/commands/release/apply.preflight.js +13 -4
  222. package/dist/commands/release/apply.types.d.ts +27 -0
  223. package/dist/commands/release/apply.types.d.ts.map +1 -1
  224. package/dist/commands/release.test-helpers.d.ts +4 -0
  225. package/dist/commands/release.test-helpers.d.ts.map +1 -1
  226. package/dist/commands/release.test-helpers.js +7 -0
  227. package/dist/commands/scenario/execute.command.js +4 -4
  228. package/dist/commands/scenario/impl/commands.js +4 -4
  229. package/dist/commands/scenario/info.command.js +4 -4
  230. package/dist/commands/scenario/list.command.js +3 -3
  231. package/dist/commands/scenario/run.command.js +5 -5
  232. package/dist/commands/scenario/scenario.command.js +7 -7
  233. package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
  234. package/dist/commands/shared/reconcile-check.js +2 -2
  235. package/dist/commands/shared/task-backend.d.ts +6 -1
  236. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  237. package/dist/commands/shared/task-backend.js +34 -2
  238. package/dist/commands/shared/task-handoff.d.ts +2 -1
  239. package/dist/commands/shared/task-handoff.d.ts.map +1 -1
  240. package/dist/commands/shared/task-handoff.js +15 -0
  241. package/dist/commands/shared/task-mutation.d.ts.map +1 -1
  242. package/dist/commands/shared/task-mutation.js +4 -4
  243. package/dist/commands/shared/task-store/intents.d.ts +34 -0
  244. package/dist/commands/shared/task-store/intents.d.ts.map +1 -0
  245. package/dist/commands/shared/task-store/intents.js +265 -0
  246. package/dist/commands/shared/task-store/readme.d.ts +28 -0
  247. package/dist/commands/shared/task-store/readme.d.ts.map +1 -0
  248. package/dist/commands/shared/task-store/readme.js +125 -0
  249. package/dist/commands/shared/task-store/store.d.ts +26 -0
  250. package/dist/commands/shared/task-store/store.d.ts.map +1 -0
  251. package/dist/commands/shared/task-store/store.js +105 -0
  252. package/dist/commands/shared/task-store/types.d.ts +94 -0
  253. package/dist/commands/shared/task-store/types.d.ts.map +1 -0
  254. package/dist/commands/shared/task-store/types.js +1 -0
  255. package/dist/commands/shared/task-store.d.ts +3 -109
  256. package/dist/commands/shared/task-store.d.ts.map +1 -1
  257. package/dist/commands/shared/task-store.js +2 -493
  258. package/dist/commands/task/block.d.ts.map +1 -1
  259. package/dist/commands/task/block.js +7 -2
  260. package/dist/commands/task/comment.d.ts.map +1 -1
  261. package/dist/commands/task/comment.js +7 -2
  262. package/dist/commands/task/finish-shared.d.ts.map +1 -1
  263. package/dist/commands/task/finish-shared.js +3 -3
  264. package/dist/commands/task/finish.d.ts.map +1 -1
  265. package/dist/commands/task/finish.js +102 -15
  266. package/dist/commands/task/handoff-show.command.d.ts.map +1 -1
  267. package/dist/commands/task/handoff-show.command.js +24 -0
  268. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
  269. package/dist/commands/task/hosted-merge-sync.js +9 -4
  270. package/dist/commands/task/list.run.d.ts.map +1 -1
  271. package/dist/commands/task/list.run.js +14 -4
  272. package/dist/commands/task/new.command.d.ts.map +1 -1
  273. package/dist/commands/task/new.command.js +16 -2
  274. package/dist/commands/task/new.js +2 -2
  275. package/dist/commands/task/show.d.ts.map +1 -1
  276. package/dist/commands/task/show.js +3 -3
  277. package/dist/commands/task/update.d.ts.map +1 -1
  278. package/dist/commands/task/update.js +11 -3
  279. package/dist/runner/adapters/codex.d.ts.map +1 -1
  280. package/dist/runner/adapters/codex.js +3 -33
  281. package/dist/runner/adapters/custom.d.ts.map +1 -1
  282. package/dist/runner/adapters/custom.js +3 -30
  283. package/dist/runner/adapters/runtime-shared.d.ts +14 -0
  284. package/dist/runner/adapters/runtime-shared.d.ts.map +1 -0
  285. package/dist/runner/adapters/runtime-shared.js +36 -0
  286. package/dist/runner/context/base-prompt-sources.d.ts +30 -0
  287. package/dist/runner/context/base-prompt-sources.d.ts.map +1 -0
  288. package/dist/runner/context/base-prompt-sources.js +144 -0
  289. package/dist/runner/context/base-prompts.d.ts +5 -23
  290. package/dist/runner/context/base-prompts.d.ts.map +1 -1
  291. package/dist/runner/context/base-prompts.js +10 -358
  292. package/dist/runner/context/overlay-prompt-blocks.d.ts +7 -0
  293. package/dist/runner/context/overlay-prompt-blocks.d.ts.map +1 -0
  294. package/dist/runner/context/overlay-prompt-blocks.js +72 -0
  295. package/dist/runner/context/prompt-block-shared.d.ts +54 -0
  296. package/dist/runner/context/prompt-block-shared.d.ts.map +1 -0
  297. package/dist/runner/context/prompt-block-shared.js +106 -0
  298. package/dist/runner/context/recipe-context.d.ts +2 -1
  299. package/dist/runner/context/recipe-context.d.ts.map +1 -1
  300. package/dist/runner/context/recipe-context.js +41 -8
  301. package/dist/runner/context/recipe-prompt-blocks.d.ts +6 -0
  302. package/dist/runner/context/recipe-prompt-blocks.d.ts.map +1 -0
  303. package/dist/runner/context/recipe-prompt-blocks.js +143 -0
  304. package/dist/runner/types.d.ts +4 -0
  305. package/dist/runner/types.d.ts.map +1 -1
  306. package/dist/runner/usecases/scenario-materialize-task.js +2 -2
  307. package/dist/runner/usecases/task-run-inspect.js +2 -2
  308. package/dist/runner/usecases/task-run-lifecycle-shared.js +2 -2
  309. package/dist/runner/usecases/task-run.d.ts.map +1 -1
  310. package/dist/runner/usecases/task-run.js +6 -3
  311. package/dist/runtime/behavior/resolve.d.ts +2 -1
  312. package/dist/runtime/behavior/resolve.d.ts.map +1 -1
  313. package/dist/runtime/behavior/resolve.js +25 -5
  314. package/dist/runtime/behavior/types.d.ts +1 -0
  315. package/dist/runtime/behavior/types.d.ts.map +1 -1
  316. package/dist/runtime/capabilities/recipe.d.ts +2 -1
  317. package/dist/runtime/capabilities/recipe.d.ts.map +1 -1
  318. package/dist/runtime/capabilities/recipe.js +88 -28
  319. package/dist/runtime/execution-context.d.ts +63 -0
  320. package/dist/runtime/execution-context.d.ts.map +1 -0
  321. package/dist/{usecases/context/resolve-context.js → runtime/execution-context.js} +23 -26
  322. package/dist/runtime/incidents/advice-strategy.d.ts +15 -0
  323. package/dist/runtime/incidents/advice-strategy.d.ts.map +1 -0
  324. package/dist/runtime/incidents/advice-strategy.js +54 -0
  325. package/dist/runtime/incidents/plan-strategy.d.ts +9 -0
  326. package/dist/runtime/incidents/plan-strategy.d.ts.map +1 -0
  327. package/dist/runtime/incidents/plan-strategy.js +205 -0
  328. package/dist/runtime/incidents/registry-strategy.d.ts +6 -0
  329. package/dist/runtime/incidents/registry-strategy.d.ts.map +1 -0
  330. package/dist/runtime/incidents/registry-strategy.js +280 -0
  331. package/dist/runtime/incidents/resolve.d.ts +3 -25
  332. package/dist/runtime/incidents/resolve.d.ts.map +1 -1
  333. package/dist/runtime/incidents/resolve.js +3 -683
  334. package/dist/runtime/incidents/shared.d.ts +34 -0
  335. package/dist/runtime/incidents/shared.d.ts.map +1 -0
  336. package/dist/runtime/incidents/shared.js +171 -0
  337. package/dist/shared/errors.d.ts +1 -1
  338. package/dist/shared/errors.d.ts.map +1 -1
  339. package/dist/shared/runtime-source.d.ts.map +1 -1
  340. package/dist/shared/runtime-source.js +8 -3
  341. package/dist/testing/cli-harness/recipe-archives.d.ts +28 -0
  342. package/dist/testing/cli-harness/recipe-archives.d.ts.map +1 -0
  343. package/dist/testing/cli-harness/recipe-archives.js +374 -0
  344. package/dist/testing/cli-harness/stdio.d.ts +26 -0
  345. package/dist/testing/cli-harness/stdio.d.ts.map +1 -0
  346. package/dist/testing/cli-harness/stdio.js +84 -0
  347. package/dist/testing/cli-harness.d.ts +25 -0
  348. package/dist/testing/cli-harness.d.ts.map +1 -0
  349. package/dist/testing/cli-harness.js +313 -0
  350. package/dist/testing/index.d.ts +2 -0
  351. package/dist/testing/index.d.ts.map +1 -0
  352. package/dist/testing/index.js +1 -0
  353. package/package.json +7 -3
  354. package/dist/cli/recipes-bundled.d.ts +0 -10
  355. package/dist/cli/recipes-bundled.d.ts.map +0 -1
  356. package/dist/cli/recipes-bundled.js +0 -36
  357. package/dist/commands/recipes/impl/manifest.d.ts +0 -4
  358. package/dist/commands/recipes/impl/manifest.d.ts.map +0 -1
  359. package/dist/commands/recipes/impl/manifest.js +0 -229
  360. package/dist/commands/recipes/impl/normalize.d.ts +0 -8
  361. package/dist/commands/recipes/impl/normalize.d.ts.map +0 -1
  362. package/dist/commands/recipes/impl/normalize.js +0 -54
  363. package/dist/commands/recipes/impl/scenario.d.ts +0 -16
  364. package/dist/commands/recipes/impl/scenario.d.ts.map +0 -1
  365. package/dist/commands/recipes/impl/scenario.js +0 -262
  366. package/dist/recipes/bundled-recipes.d.ts +0 -17
  367. package/dist/recipes/bundled-recipes.d.ts.map +0 -1
  368. package/dist/recipes/bundled-recipes.js +0 -15
  369. package/dist/usecases/context/resolve-context.d.ts +0 -68
  370. package/dist/usecases/context/resolve-context.d.ts.map +0 -1
  371. package/dist/usecases/task/task-list-usecase.d.ts +0 -9
  372. package/dist/usecases/task/task-list-usecase.d.ts.map +0 -1
  373. package/dist/usecases/task/task-list-usecase.js +0 -17
  374. package/dist/usecases/task/task-new-usecase.d.ts +0 -9
  375. package/dist/usecases/task/task-new-usecase.d.ts.map +0 -1
  376. package/dist/usecases/task/task-new-usecase.js +0 -17
@@ -0,0 +1,205 @@
1
+ import { buildDerivedIncidentRule, buildIncidentFingerprint, buildMatchTerms, dedupeCaseInsensitive, normalizeLines, parseBoolean, parseCsvList, parseFixability, resolveIncidentState, summarizeTaskScope, appendFieldValue, normalizeKey, } from "./shared.js";
2
+ import { appendIncidentRegistryEntries, createIncidentRegistrySkeleton, parseIncidentRegistry, } from "./registry-strategy.js";
3
+ export function extractIncidentCandidatesFromFindings(findings) {
4
+ return parseIncidentFindingBlocks(findings)
5
+ .filter((candidate) => candidate.shouldPromote)
6
+ .map(({ shouldPromote: _shouldPromote, ...candidate }) => candidate);
7
+ }
8
+ function parseIncidentFindingBlocks(findings) {
9
+ const lines = normalizeLines(findings);
10
+ const candidates = [];
11
+ let currentFields = null;
12
+ let currentLine = 0;
13
+ let currentKey = null;
14
+ const flush = () => {
15
+ if (!currentFields)
16
+ return;
17
+ const promotion = currentFields.promotion?.trim() || null;
18
+ const fixability = parseFixability(currentFields.fixability);
19
+ const incidentExternal = parseBoolean(currentFields.incidentexternal) || fixability === "external";
20
+ const incidentInternal = parseBoolean(currentFields.incidentinternal) || fixability === "repo-fixable";
21
+ const shouldPromote = promotion?.toLowerCase() === "incident-candidate" || incidentExternal || incidentInternal;
22
+ const observation = currentFields.observation?.trim() ?? "";
23
+ if (!observation) {
24
+ currentFields = null;
25
+ currentKey = null;
26
+ currentLine = 0;
27
+ return;
28
+ }
29
+ candidates.push({
30
+ observation,
31
+ impact: currentFields.impact?.trim() || null,
32
+ resolution: currentFields.resolution?.trim() || null,
33
+ promotion,
34
+ incidentScope: currentFields.incidentscope?.trim() || null,
35
+ incidentRule: currentFields.incidentrule?.trim() || null,
36
+ incidentAdvice: currentFields.incidentadvice?.trim() || null,
37
+ incidentTags: parseCsvList(currentFields.incidenttags),
38
+ incidentMatch: parseCsvList(currentFields.incidentmatch),
39
+ incidentExternal,
40
+ incidentInternal,
41
+ fixability,
42
+ shouldPromote,
43
+ line: currentLine,
44
+ rawFields: { ...currentFields },
45
+ });
46
+ currentFields = null;
47
+ currentKey = null;
48
+ currentLine = 0;
49
+ };
50
+ for (const [index, line] of lines.entries()) {
51
+ const observationMatch = /^\s*-\s+Observation:\s*(.*?)\s*$/.exec(line);
52
+ if (observationMatch) {
53
+ flush();
54
+ currentFields = { observation: observationMatch[1] ?? "" };
55
+ currentKey = "observation";
56
+ currentLine = index + 1;
57
+ continue;
58
+ }
59
+ if (!currentFields)
60
+ continue;
61
+ if (/^\s*-\s+/.test(line)) {
62
+ flush();
63
+ const nestedObservationMatch = /^\s*-\s+Observation:\s*(.*?)\s*$/.exec(line);
64
+ if (nestedObservationMatch) {
65
+ currentFields = { observation: nestedObservationMatch[1] ?? "" };
66
+ currentKey = "observation";
67
+ currentLine = index + 1;
68
+ }
69
+ continue;
70
+ }
71
+ const fieldMatch = /^\s{2,}([A-Za-z][A-Za-z0-9 _-]*):\s*(.*?)\s*$/.exec(line);
72
+ if (fieldMatch) {
73
+ currentKey = normalizeKey(fieldMatch[1] ?? "");
74
+ currentFields[currentKey] = fieldMatch[2] ?? "";
75
+ continue;
76
+ }
77
+ if (currentKey && /^\s{2,}\S/.test(line)) {
78
+ appendFieldValue(currentFields, currentKey, line.trim(), "\n");
79
+ continue;
80
+ }
81
+ if (!line.trim())
82
+ continue;
83
+ if (currentKey)
84
+ appendFieldValue(currentFields, currentKey, line.trim());
85
+ }
86
+ flush();
87
+ return candidates;
88
+ }
89
+ function nextIncidentId(entries, now) {
90
+ const dateStamp = `${now.getUTCFullYear()}${String(now.getUTCMonth() + 1).padStart(2, "0")}${String(now.getUTCDate()).padStart(2, "0")}`;
91
+ const prefix = `INC-${dateStamp}-`;
92
+ let max = 0;
93
+ for (const entry of entries) {
94
+ if (!entry.id.startsWith(prefix))
95
+ continue;
96
+ const num = Number.parseInt(entry.id.slice(prefix.length), 10);
97
+ if (Number.isInteger(num) && num > max)
98
+ max = num;
99
+ }
100
+ return `${prefix}${String(max + 1).padStart(2, "0")}`;
101
+ }
102
+ function buildPromotionIssues(candidate) {
103
+ const missingFields = [];
104
+ if (!candidate.incidentExternal && !candidate.incidentInternal && candidate.fixability === null) {
105
+ missingFields.push("Fixability: external or IncidentExternal: true");
106
+ }
107
+ if (!candidate.incidentAdvice && !candidate.resolution) {
108
+ missingFields.push("Resolution or IncidentAdvice");
109
+ }
110
+ return missingFields.length > 0 ? { candidate, missingFields } : null;
111
+ }
112
+ function buildIncidentRegistryEntry(opts) {
113
+ const date = opts.now.toISOString().slice(0, 10);
114
+ const scope = opts.candidate.incidentScope ?? summarizeTaskScope(opts.task.scope, opts.task.title);
115
+ const tags = dedupeCaseInsensitive([
116
+ ...opts.candidate.incidentTags,
117
+ ...opts.task.tags.map((tag) => tag.trim()),
118
+ ]);
119
+ const advice = opts.candidate.incidentAdvice ?? opts.candidate.resolution ?? opts.candidate.observation;
120
+ const rule = opts.candidate.incidentRule ?? buildDerivedIncidentRule(scope);
121
+ const state = resolveIncidentState({
122
+ registry: opts.registry,
123
+ entry: {
124
+ scope,
125
+ failure: opts.candidate.observation,
126
+ rule,
127
+ },
128
+ now: opts.now,
129
+ });
130
+ const match = buildMatchTerms({
131
+ scope,
132
+ tags,
133
+ explicitMatch: opts.candidate.incidentMatch,
134
+ extraText: [opts.task.title, opts.task.description, advice],
135
+ });
136
+ return {
137
+ id: nextIncidentId(opts.registry.entries, opts.now),
138
+ date,
139
+ scope,
140
+ failure: opts.candidate.observation,
141
+ rule,
142
+ evidence: `task ${opts.task.id}${opts.task.commitHash ? `; commit ${opts.task.commitHash.slice(0, 12)}` : ""}`,
143
+ enforcement: "manual",
144
+ state,
145
+ tags,
146
+ match,
147
+ advice,
148
+ sourceTask: opts.task.id,
149
+ fixability: opts.candidate.fixability ?? (opts.candidate.incidentInternal ? "repo-fixable" : "external"),
150
+ rawFields: {},
151
+ line: 0,
152
+ };
153
+ }
154
+ export function planIncidentCollection(opts) {
155
+ const parsed = parseIncidentFindingBlocks(opts.findings);
156
+ const candidates = parsed
157
+ .filter((candidate) => candidate.shouldPromote)
158
+ .map(({ shouldPromote: _shouldPromote, ...candidate }) => candidate);
159
+ const skipped = parsed
160
+ .filter((candidate) => !candidate.shouldPromote)
161
+ .map(({ observation, line, rawFields }) => ({
162
+ observation,
163
+ line,
164
+ reason: "not_marked_external_or_promotable",
165
+ rawFields,
166
+ }));
167
+ const issues = [];
168
+ const promotable = [];
169
+ const duplicates = [];
170
+ const now = opts.now ?? new Date();
171
+ const seenFingerprints = new Set(opts.registry.entries.map((entry) => buildIncidentFingerprint(entry)));
172
+ for (const candidate of candidates) {
173
+ const issue = buildPromotionIssues(candidate);
174
+ if (issue) {
175
+ issues.push(issue);
176
+ continue;
177
+ }
178
+ const entry = buildIncidentRegistryEntry({
179
+ task: opts.task,
180
+ candidate,
181
+ now,
182
+ registry: parseIncidentRegistry(appendIncidentRegistryEntries(createIncidentRegistrySkeleton(), [
183
+ ...opts.registry.entries,
184
+ ...promotable.map((item) => item.entry),
185
+ ])),
186
+ });
187
+ const fingerprint = buildIncidentFingerprint(entry);
188
+ const draft = { candidate, entry, fingerprint };
189
+ if (seenFingerprints.has(fingerprint)) {
190
+ duplicates.push(draft);
191
+ continue;
192
+ }
193
+ seenFingerprints.add(fingerprint);
194
+ promotable.push(draft);
195
+ }
196
+ return {
197
+ candidates,
198
+ skipped,
199
+ promotable,
200
+ duplicates,
201
+ issues,
202
+ findingsTextPresent: opts.findings.trim().length > 0,
203
+ structuredFindingCount: parsed.length,
204
+ };
205
+ }
@@ -0,0 +1,6 @@
1
+ import type { IncidentRegistry, IncidentRegistryEntry } from "./types.js";
2
+ export declare function createIncidentRegistrySkeleton(): string;
3
+ export declare function parseIncidentRegistry(text: string): IncidentRegistry;
4
+ export declare function formatIncidentRegistryEntry(entry: IncidentRegistryEntry): string;
5
+ export declare function appendIncidentRegistryEntries(currentText: string, entries: readonly IncidentRegistryEntry[]): string;
6
+ //# sourceMappingURL=registry-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-strategy.d.ts","sourceRoot":"","sources":["../../../src/runtime/incidents/registry-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAe1E,wBAAgB,8BAA8B,IAAI,MAAM,CAkCvD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAkHpE;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAEhF;AAiJD,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,MAAM,CAOR"}
@@ -0,0 +1,280 @@
1
+ import { appendFieldValue, buildIncidentFingerprint, COMPACT_INCIDENTS_HEADER, deriveSourceTask, incidentField, normalizeKey, normalizeLines, parseCsvList, parseEntryState, parseFixability, STRUCTURED_INCIDENTS_HEADER, } from "./shared.js";
2
+ export function createIncidentRegistrySkeleton() {
3
+ return [
4
+ STRUCTURED_INCIDENTS_HEADER,
5
+ "",
6
+ "## Entry contract",
7
+ "",
8
+ "- Add entries append-only.",
9
+ "- Every entry MUST include: `id`, `date`, `scope`, `failure`, `rule`, `evidence`, `enforcement`, `state`.",
10
+ "- New machine-matched entries SHOULD also include: `tags`, `match`, `advice`, `source_task`, `fixability`.",
11
+ "- `rule` MUST be concrete and testable (`MUST` / `MUST NOT`).",
12
+ "- `fixability: external` means the issue cannot be removed by changing only repository code and should stay as reusable operational advice.",
13
+ "- `fixability: repo-fixable` means the issue can be removed by repository code changes and should still be captured as reusable incident advice when explicitly marked.",
14
+ "- First auto-promoted reusable incidents normally enter as `open` and still participate in targeted advice lookup; recurring equivalent incidents can append later `stabilized` entries.",
15
+ "- `state` values: `open`, `stabilized`, `promoted`.",
16
+ "",
17
+ "## Entry template",
18
+ "",
19
+ "- id: `INC-YYYYMMDD-NN`",
20
+ "- date: `YYYY-MM-DD`",
21
+ "- scope: `<affected scope>`",
22
+ "- tags: `<comma-separated matching tags>`",
23
+ "- match: `<comma-separated lookup keywords>`",
24
+ "- failure: `<observed failure mode>`",
25
+ "- advice: `<reusable recovery or prevention guidance>`",
26
+ "- rule: `<new or refined MUST/MUST NOT>`",
27
+ "- evidence: `<task ids / logs / links>`",
28
+ "- enforcement: `<CI|test|lint|script|manual>`",
29
+ "- source_task: `<task id>`",
30
+ "- fixability: `<external|repo-fixable>`",
31
+ "- state: `<open|stabilized|promoted>`",
32
+ "",
33
+ "## Entries",
34
+ "",
35
+ ].join("\n");
36
+ }
37
+ export function parseIncidentRegistry(text) {
38
+ const lines = normalizeLines(text);
39
+ const entries = [];
40
+ let currentFields = null;
41
+ let currentLine = 0;
42
+ let currentKey = null;
43
+ const flush = () => {
44
+ if (!currentFields)
45
+ return;
46
+ const id = currentFields.id?.trim();
47
+ if (!id || !/^INC-\d{8}-\d+$/u.test(id)) {
48
+ currentFields = null;
49
+ currentKey = null;
50
+ currentLine = 0;
51
+ return;
52
+ }
53
+ const scope = currentFields.scope?.trim() ?? "";
54
+ const failure = currentFields.failure?.trim() ?? "";
55
+ const rule = currentFields.rule?.trim() ?? "";
56
+ const evidence = currentFields.evidence?.trim() ?? "";
57
+ const enforcement = currentFields.enforcement?.trim() ?? "manual";
58
+ if (!scope || !failure || !rule || !evidence) {
59
+ currentFields = null;
60
+ currentKey = null;
61
+ currentLine = 0;
62
+ return;
63
+ }
64
+ const sourceTask = deriveSourceTask(currentFields.source_task ?? currentFields.sourcetask, evidence);
65
+ entries.push({
66
+ id,
67
+ date: currentFields.date?.trim() ?? "",
68
+ scope,
69
+ tags: parseCsvList(currentFields.tags),
70
+ match: parseCsvList(currentFields.match),
71
+ failure,
72
+ advice: currentFields.advice?.trim() || null,
73
+ rule,
74
+ evidence,
75
+ enforcement,
76
+ sourceTask,
77
+ fixability: parseFixability(currentFields.fixability),
78
+ state: parseEntryState(currentFields.state),
79
+ rawFields: { ...currentFields },
80
+ line: currentLine,
81
+ });
82
+ currentFields = null;
83
+ currentKey = null;
84
+ currentLine = 0;
85
+ };
86
+ for (const [index, line] of lines.entries()) {
87
+ const trimmed = line.trim();
88
+ const inlineFields = parseInlineIncidentEntry(trimmed);
89
+ if (inlineFields) {
90
+ flush();
91
+ currentFields = { ...inlineFields };
92
+ const keys = Object.keys(inlineFields);
93
+ currentKey = keys.at(-1) ?? "id";
94
+ currentLine = index + 1;
95
+ continue;
96
+ }
97
+ const idMatch = /^\s*-\s+id:\s*(.*?)\s*$/u.exec(line);
98
+ if (idMatch) {
99
+ flush();
100
+ currentFields = { id: idMatch[1] ?? "" };
101
+ currentKey = "id";
102
+ currentLine = index + 1;
103
+ continue;
104
+ }
105
+ if (!currentFields)
106
+ continue;
107
+ if (/^##\s+/.test(trimmed)) {
108
+ flush();
109
+ continue;
110
+ }
111
+ if (/^\s*-\s+/.test(line)) {
112
+ flush();
113
+ const nestedIdMatch = /^\s*-\s+id:\s*(.*?)\s*$/u.exec(line);
114
+ if (nestedIdMatch) {
115
+ currentFields = { id: nestedIdMatch[1] ?? "" };
116
+ currentKey = "id";
117
+ currentLine = index + 1;
118
+ }
119
+ continue;
120
+ }
121
+ const fieldMatch = /^\s{2,}([A-Za-z][A-Za-z0-9 _-]*):\s*(.*?)\s*$/u.exec(line);
122
+ if (fieldMatch) {
123
+ currentKey = normalizeKey(fieldMatch[1] ?? "");
124
+ currentFields[currentKey] = fieldMatch[2] ?? "";
125
+ continue;
126
+ }
127
+ if (currentKey && /^\s{2,}\S/.test(line)) {
128
+ appendFieldValue(currentFields, currentKey, line.trim(), "\n");
129
+ continue;
130
+ }
131
+ if (!trimmed) {
132
+ flush();
133
+ continue;
134
+ }
135
+ if (currentKey)
136
+ appendFieldValue(currentFields, currentKey, line.trim());
137
+ }
138
+ flush();
139
+ return { entries };
140
+ }
141
+ export function formatIncidentRegistryEntry(entry) {
142
+ return formatIncidentRegistryEntryForStyle(entry, "structured");
143
+ }
144
+ function parseInlineIncidentEntry(trimmedLine) {
145
+ if (!trimmedLine.startsWith("- "))
146
+ return null;
147
+ const body = trimmedLine.slice(2).trim();
148
+ if (!body)
149
+ return null;
150
+ const segments = body.split(/\s+\|\s+(?=[a-z_]+:\s*)/u);
151
+ const fields = {};
152
+ for (const segment of segments) {
153
+ const match = /^([a-z_]+):\s*(.*?)\s*$/u.exec(segment.trim());
154
+ if (!match)
155
+ return null;
156
+ const key = normalizeKey(match[1] ?? "");
157
+ if (!key)
158
+ return null;
159
+ fields[key] = match[2] ?? "";
160
+ }
161
+ return fields.id ? fields : null;
162
+ }
163
+ function formatIncidentRegistryEntryForStyle(entry, style) {
164
+ const compactFields = [
165
+ incidentField("id", entry.id),
166
+ incidentField("date", entry.date),
167
+ incidentField("scope", entry.scope),
168
+ ...(entry.tags.length > 0 ? [incidentField("tags", entry.tags.join(", "))] : []),
169
+ ...(entry.match.length > 0 ? [incidentField("match", entry.match.join(", "))] : []),
170
+ incidentField("failure", entry.failure),
171
+ ...(entry.advice ? [incidentField("advice", entry.advice)] : []),
172
+ incidentField("rule", entry.rule),
173
+ incidentField("evidence", entry.evidence),
174
+ incidentField("enforcement", entry.enforcement),
175
+ ...(entry.fixability ? [incidentField("fixability", entry.fixability)] : []),
176
+ incidentField("state", entry.state),
177
+ ];
178
+ if (style === "compact") {
179
+ return `- ${compactFields.map(([key, value]) => `${key}: ${value}`).join(" | ")}`;
180
+ }
181
+ const structuredFields = [
182
+ incidentField("id", entry.id),
183
+ incidentField("date", entry.date),
184
+ incidentField("scope", entry.scope),
185
+ ...(entry.tags.length > 0 ? [incidentField("tags", entry.tags.join(", "))] : []),
186
+ ...(entry.match.length > 0 ? [incidentField("match", entry.match.join(", "))] : []),
187
+ incidentField("failure", entry.failure),
188
+ ...(entry.advice ? [incidentField("advice", entry.advice)] : []),
189
+ incidentField("rule", entry.rule),
190
+ incidentField("evidence", entry.evidence),
191
+ incidentField("enforcement", entry.enforcement),
192
+ ...(entry.sourceTask ? [incidentField("source_task", entry.sourceTask)] : []),
193
+ ...(entry.fixability ? [incidentField("fixability", entry.fixability)] : []),
194
+ incidentField("state", entry.state),
195
+ ];
196
+ return [
197
+ `- ${structuredFields[0]?.[0]}: ${structuredFields[0]?.[1] ?? ""}`,
198
+ ...structuredFields.slice(1).map(([key, value]) => ` ${key}: ${value}`),
199
+ ].join("\n");
200
+ }
201
+ function detectRegistryStyle(text) {
202
+ return /(^|\n)## Entries\s*$/mu.test(text) || /(^|\n)## Entry contract\s*$/mu.test(text)
203
+ ? "structured"
204
+ : "compact";
205
+ }
206
+ function entryRichness(entry) {
207
+ return [
208
+ entry.sourceTask ? 4 : 0,
209
+ entry.advice ? 3 : 0,
210
+ entry.tags.length,
211
+ entry.match.length,
212
+ entry.fixability ? 1 : 0,
213
+ entry.evidence.length > 0 ? 1 : 0,
214
+ ].reduce((sum, item) => sum + item, 0);
215
+ }
216
+ function nextIncidentIdForDate(dateStamp, usedIds, nextByDate) {
217
+ let next = nextByDate.get(dateStamp) ?? 0;
218
+ do {
219
+ next += 1;
220
+ } while (usedIds.has(`INC-${dateStamp}-${String(next).padStart(2, "0")}`));
221
+ nextByDate.set(dateStamp, next);
222
+ return `INC-${dateStamp}-${String(next).padStart(2, "0")}`;
223
+ }
224
+ function normalizeIncidentRegistryEntries(entries) {
225
+ const byFingerprint = new Map();
226
+ const orderedFingerprints = [];
227
+ for (const entry of entries) {
228
+ const fingerprint = buildIncidentFingerprint(entry);
229
+ const existing = byFingerprint.get(fingerprint);
230
+ if (!existing) {
231
+ byFingerprint.set(fingerprint, { ...entry });
232
+ orderedFingerprints.push(fingerprint);
233
+ continue;
234
+ }
235
+ if (entryRichness(entry) >= entryRichness(existing)) {
236
+ byFingerprint.set(fingerprint, { ...entry });
237
+ }
238
+ }
239
+ const normalized = orderedFingerprints.map((fingerprint) => byFingerprint.get(fingerprint));
240
+ const usedIds = new Set();
241
+ const nextByDate = new Map();
242
+ for (const entry of normalized) {
243
+ const match = /^INC-(\d{8})-(\d+)$/u.exec(entry.id);
244
+ if (!match)
245
+ continue;
246
+ const [, dateStamp, seqRaw] = match;
247
+ const seq = Number.parseInt(seqRaw ?? "", 10);
248
+ if (!Number.isInteger(seq))
249
+ continue;
250
+ const existing = nextByDate.get(dateStamp) ?? 0;
251
+ if (seq > existing)
252
+ nextByDate.set(dateStamp, seq);
253
+ }
254
+ return normalized.map((entry) => {
255
+ const dateStamp = /^\d{4}-\d{2}-\d{2}$/u.test(entry.date)
256
+ ? entry.date.replaceAll("-", "")
257
+ : "00000000";
258
+ const nextId = usedIds.has(entry.id)
259
+ ? nextIncidentIdForDate(dateStamp, usedIds, nextByDate)
260
+ : entry.id;
261
+ usedIds.add(nextId);
262
+ return nextId === entry.id ? entry : { ...entry, id: nextId };
263
+ });
264
+ }
265
+ function renderIncidentRegistryDocument(entries, style) {
266
+ const header = style === "structured" ? createIncidentRegistrySkeleton().trimEnd() : COMPACT_INCIDENTS_HEADER;
267
+ if (entries.length === 0)
268
+ return `${header}\n`;
269
+ const separator = style === "structured" ? "\n\n" : "\n";
270
+ return `${header}\n${entries.map((entry) => formatIncidentRegistryEntryForStyle(entry, style)).join(separator)}\n`;
271
+ }
272
+ export function appendIncidentRegistryEntries(currentText, entries) {
273
+ if (entries.length === 0)
274
+ return currentText;
275
+ const baseText = currentText.trim().length > 0 ? currentText : createIncidentRegistrySkeleton();
276
+ const style = detectRegistryStyle(baseText);
277
+ const existing = parseIncidentRegistry(baseText);
278
+ const merged = normalizeIncidentRegistryEntries([...existing.entries, ...entries]);
279
+ return renderIncidentRegistryDocument(merged, style);
280
+ }
@@ -1,26 +1,4 @@
1
- import type { IncidentAdviceMatch, IncidentAdviceQuery, IncidentCollectionPlan, IncidentFindingCandidate, IncidentPromotionTaskContext, IncidentRegistry, IncidentRegistryEntry } from "./types.js";
2
- export declare function createIncidentRegistrySkeleton(): string;
3
- export declare function parseIncidentRegistry(text: string): IncidentRegistry;
4
- export declare function formatIncidentRegistryEntry(entry: IncidentRegistryEntry): string;
5
- export declare function appendIncidentRegistryEntries(currentText: string, entries: readonly IncidentRegistryEntry[]): string;
6
- export declare function extractIncidentCandidatesFromFindings(findings: string): IncidentFindingCandidate[];
7
- export declare function planIncidentCollection(opts: {
8
- task: IncidentPromotionTaskContext;
9
- findings: string;
10
- registry: IncidentRegistry;
11
- now?: Date;
12
- }): IncidentCollectionPlan;
13
- export declare function buildIncidentAdviceQueryFromTask(opts: {
14
- taskId: string;
15
- title: string;
16
- description: string;
17
- scope?: string | null;
18
- tags: readonly string[];
19
- }): IncidentAdviceQuery;
20
- export declare function resolveIncidentAdviceMatches(opts: {
21
- query: IncidentAdviceQuery;
22
- registry: IncidentRegistry;
23
- limit?: number;
24
- }): IncidentAdviceMatch[];
25
- export declare function renderIncidentAdvice(matches: readonly IncidentAdviceMatch[]): string;
1
+ export { appendIncidentRegistryEntries, createIncidentRegistrySkeleton, formatIncidentRegistryEntry, parseIncidentRegistry, } from "./registry-strategy.js";
2
+ export { buildIncidentAdviceQueryFromTask, renderIncidentAdvice, resolveIncidentAdviceMatches, } from "./advice-strategy.js";
3
+ export { extractIncidentCandidatesFromFindings, planIncidentCollection } from "./plan-strategy.js";
26
4
  //# sourceMappingURL=resolve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/runtime/incidents/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EAIxB,4BAA4B,EAC5B,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAmNpB,wBAAgB,8BAA8B,IAAI,MAAM,CAkCvD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAkFpE;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAEhF;AAiJD,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,MAAM,CAOR;AAED,wBAAgB,qCAAqC,CACnD,QAAQ,EAAE,MAAM,GACf,wBAAwB,EAAE,CAI5B;AA8KD,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;AAED,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,CAgCxB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,mBAAmB,EAAE,GAAG,MAAM,CAcpF"}
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/runtime/incidents/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gCAAgC,EAChC,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qCAAqC,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC"}