agent-bober 0.12.0 → 0.15.0

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 (518) hide show
  1. package/CHANGELOG.md +213 -0
  2. package/README.md +112 -3
  3. package/agents/bober-architect.md +38 -0
  4. package/agents/bober-code-reviewer.md +236 -0
  5. package/agents/bober-curator.md +37 -0
  6. package/agents/bober-deployer.md +267 -0
  7. package/agents/bober-diagnoser.md +289 -0
  8. package/agents/bober-evaluator.md +89 -1
  9. package/agents/bober-generator.md +68 -3
  10. package/agents/bober-planner.md +39 -0
  11. package/agents/bober-postmortemer.md +185 -0
  12. package/agents/bober-researcher.md +38 -0
  13. package/dist/cli/commands/approve.d.ts +17 -0
  14. package/dist/cli/commands/approve.d.ts.map +1 -0
  15. package/dist/cli/commands/approve.js +64 -0
  16. package/dist/cli/commands/approve.js.map +1 -0
  17. package/dist/cli/commands/audit-show.d.ts +14 -0
  18. package/dist/cli/commands/audit-show.d.ts.map +1 -0
  19. package/dist/cli/commands/audit-show.js +85 -0
  20. package/dist/cli/commands/audit-show.js.map +1 -0
  21. package/dist/cli/commands/config.d.ts +10 -0
  22. package/dist/cli/commands/config.d.ts.map +1 -0
  23. package/dist/cli/commands/config.js +73 -0
  24. package/dist/cli/commands/config.js.map +1 -0
  25. package/dist/cli/commands/graph.d.ts +8 -0
  26. package/dist/cli/commands/graph.d.ts.map +1 -0
  27. package/dist/cli/commands/graph.js +219 -0
  28. package/dist/cli/commands/graph.js.map +1 -0
  29. package/dist/cli/commands/impact.d.ts +19 -0
  30. package/dist/cli/commands/impact.d.ts.map +1 -0
  31. package/dist/cli/commands/impact.js +191 -0
  32. package/dist/cli/commands/impact.js.map +1 -0
  33. package/dist/cli/commands/incident.d.ts +19 -0
  34. package/dist/cli/commands/incident.d.ts.map +1 -0
  35. package/dist/cli/commands/incident.js +324 -0
  36. package/dist/cli/commands/incident.js.map +1 -0
  37. package/dist/cli/commands/init.js +36 -1
  38. package/dist/cli/commands/init.js.map +1 -1
  39. package/dist/cli/commands/list-approvals.d.ts +16 -0
  40. package/dist/cli/commands/list-approvals.d.ts.map +1 -0
  41. package/dist/cli/commands/list-approvals.js +57 -0
  42. package/dist/cli/commands/list-approvals.js.map +1 -0
  43. package/dist/cli/commands/onboard.d.ts +3 -0
  44. package/dist/cli/commands/onboard.d.ts.map +1 -0
  45. package/dist/cli/commands/onboard.js +190 -0
  46. package/dist/cli/commands/onboard.js.map +1 -0
  47. package/dist/cli/commands/playbook.d.ts +17 -0
  48. package/dist/cli/commands/playbook.d.ts.map +1 -0
  49. package/dist/cli/commands/playbook.js +123 -0
  50. package/dist/cli/commands/playbook.js.map +1 -0
  51. package/dist/cli/commands/postmortem.d.ts +12 -0
  52. package/dist/cli/commands/postmortem.d.ts.map +1 -0
  53. package/dist/cli/commands/postmortem.js +67 -0
  54. package/dist/cli/commands/postmortem.js.map +1 -0
  55. package/dist/cli/commands/reject.d.ts +17 -0
  56. package/dist/cli/commands/reject.d.ts.map +1 -0
  57. package/dist/cli/commands/reject.js +52 -0
  58. package/dist/cli/commands/reject.js.map +1 -0
  59. package/dist/cli/commands/rollback.d.ts +21 -0
  60. package/dist/cli/commands/rollback.d.ts.map +1 -0
  61. package/dist/cli/commands/rollback.js +90 -0
  62. package/dist/cli/commands/rollback.js.map +1 -0
  63. package/dist/cli/commands/run.d.ts +9 -0
  64. package/dist/cli/commands/run.d.ts.map +1 -1
  65. package/dist/cli/commands/run.js +29 -0
  66. package/dist/cli/commands/run.js.map +1 -1
  67. package/dist/cli/commands/telemetry.d.ts +16 -0
  68. package/dist/cli/commands/telemetry.d.ts.map +1 -0
  69. package/dist/cli/commands/telemetry.js +152 -0
  70. package/dist/cli/commands/telemetry.js.map +1 -0
  71. package/dist/cli/commands/worktree.d.ts +12 -0
  72. package/dist/cli/commands/worktree.d.ts.map +1 -0
  73. package/dist/cli/commands/worktree.js +57 -0
  74. package/dist/cli/commands/worktree.js.map +1 -0
  75. package/dist/cli/index.js +50 -0
  76. package/dist/cli/index.js.map +1 -1
  77. package/dist/config/defaults.d.ts.map +1 -1
  78. package/dist/config/defaults.js +27 -0
  79. package/dist/config/defaults.js.map +1 -1
  80. package/dist/config/index.d.ts +1 -1
  81. package/dist/config/index.d.ts.map +1 -1
  82. package/dist/config/index.js +4 -0
  83. package/dist/config/index.js.map +1 -1
  84. package/dist/config/loader.d.ts.map +1 -1
  85. package/dist/config/loader.js +18 -1
  86. package/dist/config/loader.js.map +1 -1
  87. package/dist/config/schema.d.ts +976 -56
  88. package/dist/config/schema.d.ts.map +1 -1
  89. package/dist/config/schema.js +147 -0
  90. package/dist/config/schema.js.map +1 -1
  91. package/dist/graph/artifact-store.d.ts +14 -0
  92. package/dist/graph/artifact-store.d.ts.map +1 -0
  93. package/dist/graph/artifact-store.js +100 -0
  94. package/dist/graph/artifact-store.js.map +1 -0
  95. package/dist/graph/cli.d.ts +49 -0
  96. package/dist/graph/cli.d.ts.map +1 -0
  97. package/dist/graph/cli.js +140 -0
  98. package/dist/graph/cli.js.map +1 -0
  99. package/dist/graph/client.d.ts +64 -0
  100. package/dist/graph/client.d.ts.map +1 -0
  101. package/dist/graph/client.js +216 -0
  102. package/dist/graph/client.js.map +1 -0
  103. package/dist/graph/fallback.d.ts +13 -0
  104. package/dist/graph/fallback.d.ts.map +1 -0
  105. package/dist/graph/fallback.js +57 -0
  106. package/dist/graph/fallback.js.map +1 -0
  107. package/dist/graph/hook-handler.d.ts +50 -0
  108. package/dist/graph/hook-handler.d.ts.map +1 -0
  109. package/dist/graph/hook-handler.js +217 -0
  110. package/dist/graph/hook-handler.js.map +1 -0
  111. package/dist/graph/incidents.d.ts +59 -0
  112. package/dist/graph/incidents.d.ts.map +1 -0
  113. package/dist/graph/incidents.js +22 -0
  114. package/dist/graph/incidents.js.map +1 -0
  115. package/dist/graph/mcp-client.d.ts +51 -0
  116. package/dist/graph/mcp-client.d.ts.map +1 -0
  117. package/dist/graph/mcp-client.js +285 -0
  118. package/dist/graph/mcp-client.js.map +1 -0
  119. package/dist/graph/onboarding-composer.d.ts +30 -0
  120. package/dist/graph/onboarding-composer.d.ts.map +1 -0
  121. package/dist/graph/onboarding-composer.js +275 -0
  122. package/dist/graph/onboarding-composer.js.map +1 -0
  123. package/dist/graph/pipeline-lifecycle.d.ts +86 -0
  124. package/dist/graph/pipeline-lifecycle.d.ts.map +1 -0
  125. package/dist/graph/pipeline-lifecycle.js +329 -0
  126. package/dist/graph/pipeline-lifecycle.js.map +1 -0
  127. package/dist/graph/preflight-budgets.d.ts +52 -0
  128. package/dist/graph/preflight-budgets.d.ts.map +1 -0
  129. package/dist/graph/preflight-budgets.js +78 -0
  130. package/dist/graph/preflight-budgets.js.map +1 -0
  131. package/dist/graph/preflight-injector.d.ts +116 -0
  132. package/dist/graph/preflight-injector.d.ts.map +1 -0
  133. package/dist/graph/preflight-injector.js +538 -0
  134. package/dist/graph/preflight-injector.js.map +1 -0
  135. package/dist/graph/prereq.d.ts +12 -0
  136. package/dist/graph/prereq.d.ts.map +1 -0
  137. package/dist/graph/prereq.js +61 -0
  138. package/dist/graph/prereq.js.map +1 -0
  139. package/dist/graph/prompts.d.ts +42 -0
  140. package/dist/graph/prompts.d.ts.map +1 -0
  141. package/dist/graph/prompts.js +80 -0
  142. package/dist/graph/prompts.js.map +1 -0
  143. package/dist/graph/sandbox.d.ts +19 -0
  144. package/dist/graph/sandbox.d.ts.map +1 -0
  145. package/dist/graph/sandbox.js +25 -0
  146. package/dist/graph/sandbox.js.map +1 -0
  147. package/dist/graph/token-usage.d.ts +21 -0
  148. package/dist/graph/token-usage.d.ts.map +1 -0
  149. package/dist/graph/token-usage.js +22 -0
  150. package/dist/graph/token-usage.js.map +1 -0
  151. package/dist/graph/types.d.ts +129 -0
  152. package/dist/graph/types.d.ts.map +1 -0
  153. package/dist/graph/types.js +12 -0
  154. package/dist/graph/types.js.map +1 -0
  155. package/dist/incident/orchestrator.d.ts +168 -0
  156. package/dist/incident/orchestrator.d.ts.map +1 -0
  157. package/dist/incident/orchestrator.js +279 -0
  158. package/dist/incident/orchestrator.js.map +1 -0
  159. package/dist/incident/playbook-search.d.ts +67 -0
  160. package/dist/incident/playbook-search.d.ts.map +1 -0
  161. package/dist/incident/playbook-search.js +288 -0
  162. package/dist/incident/playbook-search.js.map +1 -0
  163. package/dist/incident/postmortem.d.ts +44 -0
  164. package/dist/incident/postmortem.d.ts.map +1 -0
  165. package/dist/incident/postmortem.js +486 -0
  166. package/dist/incident/postmortem.js.map +1 -0
  167. package/dist/incident/resolution-verify.d.ts +186 -0
  168. package/dist/incident/resolution-verify.d.ts.map +1 -0
  169. package/dist/incident/resolution-verify.js +210 -0
  170. package/dist/incident/resolution-verify.js.map +1 -0
  171. package/dist/incident/rollback.d.ts +137 -0
  172. package/dist/incident/rollback.d.ts.map +1 -0
  173. package/dist/incident/rollback.js +328 -0
  174. package/dist/incident/rollback.js.map +1 -0
  175. package/dist/incident/timeline.d.ts +147 -0
  176. package/dist/incident/timeline.d.ts.map +1 -0
  177. package/dist/incident/timeline.js +452 -0
  178. package/dist/incident/timeline.js.map +1 -0
  179. package/dist/incident/types.d.ts +335 -0
  180. package/dist/incident/types.d.ts.map +1 -0
  181. package/dist/incident/types.js +158 -0
  182. package/dist/incident/types.js.map +1 -0
  183. package/dist/index.d.ts +1 -1
  184. package/dist/index.d.ts.map +1 -1
  185. package/dist/index.js +1 -1
  186. package/dist/index.js.map +1 -1
  187. package/dist/mcp/event-stream.d.ts +46 -0
  188. package/dist/mcp/event-stream.d.ts.map +1 -0
  189. package/dist/mcp/event-stream.js +421 -0
  190. package/dist/mcp/event-stream.js.map +1 -0
  191. package/dist/mcp/external-client.d.ts +38 -0
  192. package/dist/mcp/external-client.d.ts.map +1 -0
  193. package/dist/mcp/external-client.js +121 -0
  194. package/dist/mcp/external-client.js.map +1 -0
  195. package/dist/mcp/run-manager.d.ts +74 -9
  196. package/dist/mcp/run-manager.d.ts.map +1 -1
  197. package/dist/mcp/run-manager.js +127 -31
  198. package/dist/mcp/run-manager.js.map +1 -1
  199. package/dist/mcp/server.d.ts.map +1 -1
  200. package/dist/mcp/server.js +56 -0
  201. package/dist/mcp/server.js.map +1 -1
  202. package/dist/mcp/tools/abort-run.d.ts +2 -0
  203. package/dist/mcp/tools/abort-run.d.ts.map +1 -0
  204. package/dist/mcp/tools/abort-run.js +62 -0
  205. package/dist/mcp/tools/abort-run.js.map +1 -0
  206. package/dist/mcp/tools/anchor.js +1 -1
  207. package/dist/mcp/tools/anchor.js.map +1 -1
  208. package/dist/mcp/tools/approve-checkpoint.d.ts +2 -0
  209. package/dist/mcp/tools/approve-checkpoint.d.ts.map +1 -0
  210. package/dist/mcp/tools/approve-checkpoint.js +70 -0
  211. package/dist/mcp/tools/approve-checkpoint.js.map +1 -0
  212. package/dist/mcp/tools/brownfield.js +1 -1
  213. package/dist/mcp/tools/brownfield.js.map +1 -1
  214. package/dist/mcp/tools/get-project-state.d.ts +2 -0
  215. package/dist/mcp/tools/get-project-state.d.ts.map +1 -0
  216. package/dist/mcp/tools/get-project-state.js +107 -0
  217. package/dist/mcp/tools/get-project-state.js.map +1 -0
  218. package/dist/mcp/tools/get-run-status.d.ts +2 -0
  219. package/dist/mcp/tools/get-run-status.d.ts.map +1 -0
  220. package/dist/mcp/tools/get-run-status.js +40 -0
  221. package/dist/mcp/tools/get-run-status.js.map +1 -0
  222. package/dist/mcp/tools/graph-schemas.d.ts +100 -0
  223. package/dist/mcp/tools/graph-schemas.d.ts.map +1 -0
  224. package/dist/mcp/tools/graph-schemas.js +39 -0
  225. package/dist/mcp/tools/graph-schemas.js.map +1 -0
  226. package/dist/mcp/tools/graph.d.ts +19 -0
  227. package/dist/mcp/tools/graph.d.ts.map +1 -0
  228. package/dist/mcp/tools/graph.js +263 -0
  229. package/dist/mcp/tools/graph.js.map +1 -0
  230. package/dist/mcp/tools/incident.d.ts +2 -0
  231. package/dist/mcp/tools/incident.d.ts.map +1 -0
  232. package/dist/mcp/tools/incident.js +246 -0
  233. package/dist/mcp/tools/incident.js.map +1 -0
  234. package/dist/mcp/tools/index.d.ts +38 -18
  235. package/dist/mcp/tools/index.d.ts.map +1 -1
  236. package/dist/mcp/tools/index.js +74 -18
  237. package/dist/mcp/tools/index.js.map +1 -1
  238. package/dist/mcp/tools/list-active-runs.d.ts +2 -0
  239. package/dist/mcp/tools/list-active-runs.d.ts.map +1 -0
  240. package/dist/mcp/tools/list-active-runs.js +35 -0
  241. package/dist/mcp/tools/list-active-runs.js.map +1 -0
  242. package/dist/mcp/tools/list-pending-approvals.d.ts +2 -0
  243. package/dist/mcp/tools/list-pending-approvals.d.ts.map +1 -0
  244. package/dist/mcp/tools/list-pending-approvals.js +40 -0
  245. package/dist/mcp/tools/list-pending-approvals.js.map +1 -0
  246. package/dist/mcp/tools/list-projects.d.ts +2 -0
  247. package/dist/mcp/tools/list-projects.d.ts.map +1 -0
  248. package/dist/mcp/tools/list-projects.js +101 -0
  249. package/dist/mcp/tools/list-projects.js.map +1 -0
  250. package/dist/mcp/tools/list-specs.d.ts +2 -0
  251. package/dist/mcp/tools/list-specs.d.ts.map +1 -0
  252. package/dist/mcp/tools/list-specs.js +48 -0
  253. package/dist/mcp/tools/list-specs.js.map +1 -0
  254. package/dist/mcp/tools/playbook.d.ts +2 -0
  255. package/dist/mcp/tools/playbook.d.ts.map +1 -0
  256. package/dist/mcp/tools/playbook.js +104 -0
  257. package/dist/mcp/tools/playbook.js.map +1 -0
  258. package/dist/mcp/tools/postmortem.d.ts +2 -0
  259. package/dist/mcp/tools/postmortem.d.ts.map +1 -0
  260. package/dist/mcp/tools/postmortem.js +75 -0
  261. package/dist/mcp/tools/postmortem.js.map +1 -0
  262. package/dist/mcp/tools/react.js +1 -1
  263. package/dist/mcp/tools/react.js.map +1 -1
  264. package/dist/mcp/tools/reject-checkpoint.d.ts +2 -0
  265. package/dist/mcp/tools/reject-checkpoint.d.ts.map +1 -0
  266. package/dist/mcp/tools/reject-checkpoint.js +79 -0
  267. package/dist/mcp/tools/reject-checkpoint.js.map +1 -0
  268. package/dist/mcp/tools/rollback.d.ts +2 -0
  269. package/dist/mcp/tools/rollback.d.ts.map +1 -0
  270. package/dist/mcp/tools/rollback.js +78 -0
  271. package/dist/mcp/tools/rollback.js.map +1 -0
  272. package/dist/mcp/tools/run-in-worktree.d.ts +2 -0
  273. package/dist/mcp/tools/run-in-worktree.d.ts.map +1 -0
  274. package/dist/mcp/tools/run-in-worktree.js +90 -0
  275. package/dist/mcp/tools/run-in-worktree.js.map +1 -0
  276. package/dist/mcp/tools/run.js +1 -1
  277. package/dist/mcp/tools/run.js.map +1 -1
  278. package/dist/mcp/tools/solidity.js +1 -1
  279. package/dist/mcp/tools/solidity.js.map +1 -1
  280. package/dist/mcp/tools/status.d.ts.map +1 -1
  281. package/dist/mcp/tools/status.js +11 -0
  282. package/dist/mcp/tools/status.js.map +1 -1
  283. package/dist/mcp/tools/subscribe-events.d.ts +2 -0
  284. package/dist/mcp/tools/subscribe-events.d.ts.map +1 -0
  285. package/dist/mcp/tools/subscribe-events.js +48 -0
  286. package/dist/mcp/tools/subscribe-events.js.map +1 -0
  287. package/dist/mcp/tools/unsubscribe-events.d.ts +2 -0
  288. package/dist/mcp/tools/unsubscribe-events.d.ts.map +1 -0
  289. package/dist/mcp/tools/unsubscribe-events.js +45 -0
  290. package/dist/mcp/tools/unsubscribe-events.js.map +1 -0
  291. package/dist/orchestrator/agent-loader.d.ts +16 -0
  292. package/dist/orchestrator/agent-loader.d.ts.map +1 -1
  293. package/dist/orchestrator/agent-loader.js +16 -0
  294. package/dist/orchestrator/agent-loader.js.map +1 -1
  295. package/dist/orchestrator/architect-agent.d.ts.map +1 -1
  296. package/dist/orchestrator/architect-agent.js +37 -8
  297. package/dist/orchestrator/architect-agent.js.map +1 -1
  298. package/dist/orchestrator/checkpoints/audit.d.ts +128 -0
  299. package/dist/orchestrator/checkpoints/audit.d.ts.map +1 -0
  300. package/dist/orchestrator/checkpoints/audit.js +272 -0
  301. package/dist/orchestrator/checkpoints/audit.js.map +1 -0
  302. package/dist/orchestrator/checkpoints/feedback-router.d.ts +213 -0
  303. package/dist/orchestrator/checkpoints/feedback-router.d.ts.map +1 -0
  304. package/dist/orchestrator/checkpoints/feedback-router.js +438 -0
  305. package/dist/orchestrator/checkpoints/feedback-router.js.map +1 -0
  306. package/dist/orchestrator/checkpoints/index.d.ts +11 -0
  307. package/dist/orchestrator/checkpoints/index.d.ts.map +1 -0
  308. package/dist/orchestrator/checkpoints/index.js +12 -0
  309. package/dist/orchestrator/checkpoints/index.js.map +1 -0
  310. package/dist/orchestrator/checkpoints/mechanisms/cli.d.ts +35 -0
  311. package/dist/orchestrator/checkpoints/mechanisms/cli.d.ts.map +1 -0
  312. package/dist/orchestrator/checkpoints/mechanisms/cli.js +153 -0
  313. package/dist/orchestrator/checkpoints/mechanisms/cli.js.map +1 -0
  314. package/dist/orchestrator/checkpoints/mechanisms/disk.d.ts +34 -0
  315. package/dist/orchestrator/checkpoints/mechanisms/disk.d.ts.map +1 -0
  316. package/dist/orchestrator/checkpoints/mechanisms/disk.js +139 -0
  317. package/dist/orchestrator/checkpoints/mechanisms/disk.js.map +1 -0
  318. package/dist/orchestrator/checkpoints/mechanisms/pr.d.ts +141 -0
  319. package/dist/orchestrator/checkpoints/mechanisms/pr.d.ts.map +1 -0
  320. package/dist/orchestrator/checkpoints/mechanisms/pr.js +445 -0
  321. package/dist/orchestrator/checkpoints/mechanisms/pr.js.map +1 -0
  322. package/dist/orchestrator/checkpoints/noop.d.ts +12 -0
  323. package/dist/orchestrator/checkpoints/noop.d.ts.map +1 -0
  324. package/dist/orchestrator/checkpoints/noop.js +13 -0
  325. package/dist/orchestrator/checkpoints/noop.js.map +1 -0
  326. package/dist/orchestrator/checkpoints/registry.d.ts +48 -0
  327. package/dist/orchestrator/checkpoints/registry.d.ts.map +1 -0
  328. package/dist/orchestrator/checkpoints/registry.js +89 -0
  329. package/dist/orchestrator/checkpoints/registry.js.map +1 -0
  330. package/dist/orchestrator/checkpoints/renderers/_util.d.ts +50 -0
  331. package/dist/orchestrator/checkpoints/renderers/_util.d.ts.map +1 -0
  332. package/dist/orchestrator/checkpoints/renderers/_util.js +137 -0
  333. package/dist/orchestrator/checkpoints/renderers/_util.js.map +1 -0
  334. package/dist/orchestrator/checkpoints/renderers/code-review.d.ts +15 -0
  335. package/dist/orchestrator/checkpoints/renderers/code-review.d.ts.map +1 -0
  336. package/dist/orchestrator/checkpoints/renderers/code-review.js +66 -0
  337. package/dist/orchestrator/checkpoints/renderers/code-review.js.map +1 -0
  338. package/dist/orchestrator/checkpoints/renderers/curator-briefing.d.ts +15 -0
  339. package/dist/orchestrator/checkpoints/renderers/curator-briefing.d.ts.map +1 -0
  340. package/dist/orchestrator/checkpoints/renderers/curator-briefing.js +40 -0
  341. package/dist/orchestrator/checkpoints/renderers/curator-briefing.js.map +1 -0
  342. package/dist/orchestrator/checkpoints/renderers/eval-result.d.ts +15 -0
  343. package/dist/orchestrator/checkpoints/renderers/eval-result.d.ts.map +1 -0
  344. package/dist/orchestrator/checkpoints/renderers/eval-result.js +54 -0
  345. package/dist/orchestrator/checkpoints/renderers/eval-result.js.map +1 -0
  346. package/dist/orchestrator/checkpoints/renderers/generator-diff.d.ts +49 -0
  347. package/dist/orchestrator/checkpoints/renderers/generator-diff.d.ts.map +1 -0
  348. package/dist/orchestrator/checkpoints/renderers/generator-diff.js +154 -0
  349. package/dist/orchestrator/checkpoints/renderers/generator-diff.js.map +1 -0
  350. package/dist/orchestrator/checkpoints/renderers/pipeline-summary.d.ts +15 -0
  351. package/dist/orchestrator/checkpoints/renderers/pipeline-summary.d.ts.map +1 -0
  352. package/dist/orchestrator/checkpoints/renderers/pipeline-summary.js +59 -0
  353. package/dist/orchestrator/checkpoints/renderers/pipeline-summary.js.map +1 -0
  354. package/dist/orchestrator/checkpoints/renderers/plan.d.ts +15 -0
  355. package/dist/orchestrator/checkpoints/renderers/plan.d.ts.map +1 -0
  356. package/dist/orchestrator/checkpoints/renderers/plan.js +34 -0
  357. package/dist/orchestrator/checkpoints/renderers/plan.js.map +1 -0
  358. package/dist/orchestrator/checkpoints/renderers/registry.d.ts +43 -0
  359. package/dist/orchestrator/checkpoints/renderers/registry.d.ts.map +1 -0
  360. package/dist/orchestrator/checkpoints/renderers/registry.js +83 -0
  361. package/dist/orchestrator/checkpoints/renderers/registry.js.map +1 -0
  362. package/dist/orchestrator/checkpoints/renderers/research.d.ts +15 -0
  363. package/dist/orchestrator/checkpoints/renderers/research.d.ts.map +1 -0
  364. package/dist/orchestrator/checkpoints/renderers/research.js +39 -0
  365. package/dist/orchestrator/checkpoints/renderers/research.js.map +1 -0
  366. package/dist/orchestrator/checkpoints/renderers/sprint-contract.d.ts +20 -0
  367. package/dist/orchestrator/checkpoints/renderers/sprint-contract.d.ts.map +1 -0
  368. package/dist/orchestrator/checkpoints/renderers/sprint-contract.js +57 -0
  369. package/dist/orchestrator/checkpoints/renderers/sprint-contract.js.map +1 -0
  370. package/dist/orchestrator/checkpoints/renderers/sprint-summary.d.ts +15 -0
  371. package/dist/orchestrator/checkpoints/renderers/sprint-summary.d.ts.map +1 -0
  372. package/dist/orchestrator/checkpoints/renderers/sprint-summary.js +38 -0
  373. package/dist/orchestrator/checkpoints/renderers/sprint-summary.js.map +1 -0
  374. package/dist/orchestrator/checkpoints/sites.d.ts +22 -0
  375. package/dist/orchestrator/checkpoints/sites.d.ts.map +1 -0
  376. package/dist/orchestrator/checkpoints/sites.js +57 -0
  377. package/dist/orchestrator/checkpoints/sites.js.map +1 -0
  378. package/dist/orchestrator/checkpoints/types.d.ts +51 -0
  379. package/dist/orchestrator/checkpoints/types.d.ts.map +1 -0
  380. package/dist/orchestrator/checkpoints/types.js +9 -0
  381. package/dist/orchestrator/checkpoints/types.js.map +1 -0
  382. package/dist/orchestrator/code-reviewer-agent.d.ts +50 -0
  383. package/dist/orchestrator/code-reviewer-agent.d.ts.map +1 -0
  384. package/dist/orchestrator/code-reviewer-agent.js +283 -0
  385. package/dist/orchestrator/code-reviewer-agent.js.map +1 -0
  386. package/dist/orchestrator/curator-agent.d.ts.map +1 -1
  387. package/dist/orchestrator/curator-agent.js +59 -8
  388. package/dist/orchestrator/curator-agent.js.map +1 -1
  389. package/dist/orchestrator/deploy/classify.d.ts +31 -0
  390. package/dist/orchestrator/deploy/classify.d.ts.map +1 -0
  391. package/dist/orchestrator/deploy/classify.js +109 -0
  392. package/dist/orchestrator/deploy/classify.js.map +1 -0
  393. package/dist/orchestrator/deploy/execute.d.ts +45 -0
  394. package/dist/orchestrator/deploy/execute.d.ts.map +1 -0
  395. package/dist/orchestrator/deploy/execute.js +146 -0
  396. package/dist/orchestrator/deploy/execute.js.map +1 -0
  397. package/dist/orchestrator/deploy/executor.d.ts +22 -0
  398. package/dist/orchestrator/deploy/executor.d.ts.map +1 -0
  399. package/dist/orchestrator/deploy/executor.js +31 -0
  400. package/dist/orchestrator/deploy/executor.js.map +1 -0
  401. package/dist/orchestrator/deploy/index.d.ts +21 -0
  402. package/dist/orchestrator/deploy/index.d.ts.map +1 -0
  403. package/dist/orchestrator/deploy/index.js +21 -0
  404. package/dist/orchestrator/deploy/index.js.map +1 -0
  405. package/dist/orchestrator/deploy/resolve.d.ts +51 -0
  406. package/dist/orchestrator/deploy/resolve.d.ts.map +1 -0
  407. package/dist/orchestrator/deploy/resolve.js +53 -0
  408. package/dist/orchestrator/deploy/resolve.js.map +1 -0
  409. package/dist/orchestrator/deploy/spawn.d.ts +60 -0
  410. package/dist/orchestrator/deploy/spawn.d.ts.map +1 -0
  411. package/dist/orchestrator/deploy/spawn.js +62 -0
  412. package/dist/orchestrator/deploy/spawn.js.map +1 -0
  413. package/dist/orchestrator/deploy/types.d.ts +98 -0
  414. package/dist/orchestrator/deploy/types.d.ts.map +1 -0
  415. package/dist/orchestrator/deploy/types.js +39 -0
  416. package/dist/orchestrator/deploy/types.js.map +1 -0
  417. package/dist/orchestrator/evaluator-agent.d.ts.map +1 -1
  418. package/dist/orchestrator/evaluator-agent.js +21 -8
  419. package/dist/orchestrator/evaluator-agent.js.map +1 -1
  420. package/dist/orchestrator/generator-agent.d.ts.map +1 -1
  421. package/dist/orchestrator/generator-agent.js +21 -8
  422. package/dist/orchestrator/generator-agent.js.map +1 -1
  423. package/dist/orchestrator/model-resolver.d.ts.map +1 -1
  424. package/dist/orchestrator/model-resolver.js +3 -1
  425. package/dist/orchestrator/model-resolver.js.map +1 -1
  426. package/dist/orchestrator/observability/index.d.ts +12 -0
  427. package/dist/orchestrator/observability/index.d.ts.map +1 -0
  428. package/dist/orchestrator/observability/index.js +12 -0
  429. package/dist/orchestrator/observability/index.js.map +1 -0
  430. package/dist/orchestrator/observability/merge.d.ts +73 -0
  431. package/dist/orchestrator/observability/merge.d.ts.map +1 -0
  432. package/dist/orchestrator/observability/merge.js +110 -0
  433. package/dist/orchestrator/observability/merge.js.map +1 -0
  434. package/dist/orchestrator/pipeline.d.ts +21 -0
  435. package/dist/orchestrator/pipeline.d.ts.map +1 -1
  436. package/dist/orchestrator/pipeline.js +156 -2
  437. package/dist/orchestrator/pipeline.js.map +1 -1
  438. package/dist/orchestrator/planner-agent.d.ts.map +1 -1
  439. package/dist/orchestrator/planner-agent.js +5 -4
  440. package/dist/orchestrator/planner-agent.js.map +1 -1
  441. package/dist/orchestrator/research-agent.d.ts.map +1 -1
  442. package/dist/orchestrator/research-agent.js +46 -9
  443. package/dist/orchestrator/research-agent.js.map +1 -1
  444. package/dist/orchestrator/tools/handlers.d.ts +2 -0
  445. package/dist/orchestrator/tools/handlers.d.ts.map +1 -1
  446. package/dist/orchestrator/tools/handlers.js +1 -1
  447. package/dist/orchestrator/tools/handlers.js.map +1 -1
  448. package/dist/orchestrator/tools/index.d.ts +84 -1
  449. package/dist/orchestrator/tools/index.d.ts.map +1 -1
  450. package/dist/orchestrator/tools/index.js +164 -1
  451. package/dist/orchestrator/tools/index.js.map +1 -1
  452. package/dist/orchestrator/worktree.d.ts +18 -0
  453. package/dist/orchestrator/worktree.d.ts.map +1 -0
  454. package/dist/orchestrator/worktree.js +129 -0
  455. package/dist/orchestrator/worktree.js.map +1 -0
  456. package/dist/providers/anthropic.d.ts +8 -1
  457. package/dist/providers/anthropic.d.ts.map +1 -1
  458. package/dist/providers/anthropic.js +86 -5
  459. package/dist/providers/anthropic.js.map +1 -1
  460. package/dist/providers/factory.d.ts.map +1 -1
  461. package/dist/providers/factory.js +35 -2
  462. package/dist/providers/factory.js.map +1 -1
  463. package/dist/providers/google.d.ts.map +1 -1
  464. package/dist/providers/google.js +5 -0
  465. package/dist/providers/google.js.map +1 -1
  466. package/dist/providers/index.d.ts +1 -1
  467. package/dist/providers/index.d.ts.map +1 -1
  468. package/dist/providers/index.js.map +1 -1
  469. package/dist/providers/openai.d.ts.map +1 -1
  470. package/dist/providers/openai.js +4 -0
  471. package/dist/providers/openai.js.map +1 -1
  472. package/dist/providers/types.d.ts +25 -2
  473. package/dist/providers/types.d.ts.map +1 -1
  474. package/dist/state/approval-state.d.ts +74 -0
  475. package/dist/state/approval-state.d.ts.map +1 -0
  476. package/dist/state/approval-state.js +127 -0
  477. package/dist/state/approval-state.js.map +1 -0
  478. package/dist/state/index.d.ts +3 -0
  479. package/dist/state/index.d.ts.map +1 -1
  480. package/dist/state/index.js +4 -1
  481. package/dist/state/index.js.map +1 -1
  482. package/dist/state/review-state.d.ts +15 -0
  483. package/dist/state/review-state.d.ts.map +1 -0
  484. package/dist/state/review-state.js +51 -0
  485. package/dist/state/review-state.js.map +1 -0
  486. package/dist/state/run-state.d.ts +39 -0
  487. package/dist/state/run-state.d.ts.map +1 -0
  488. package/dist/state/run-state.js +101 -0
  489. package/dist/state/run-state.js.map +1 -0
  490. package/dist/telemetry/emit.d.ts +41 -0
  491. package/dist/telemetry/emit.d.ts.map +1 -0
  492. package/dist/telemetry/emit.js +65 -0
  493. package/dist/telemetry/emit.js.map +1 -0
  494. package/dist/utils/git.d.ts +27 -0
  495. package/dist/utils/git.d.ts.map +1 -1
  496. package/dist/utils/git.js +50 -0
  497. package/dist/utils/git.js.map +1 -1
  498. package/hooks/hooks.json +17 -1
  499. package/hooks/session-start +42 -0
  500. package/package.json +5 -2
  501. package/scripts/check-prereqs.sh +12 -0
  502. package/scripts/e2e-graph-smoke.sh +167 -0
  503. package/scripts/graph-hook.mjs +151 -0
  504. package/scripts/run-kpi-gate.mjs +245 -0
  505. package/scripts/sync-skills.mjs +4 -1
  506. package/skills/bober.code-review/SKILL.md +186 -0
  507. package/skills/bober.debug/SKILL.md +300 -0
  508. package/skills/bober.deploy/SKILL.md +262 -0
  509. package/skills/bober.diagnose/SKILL.md +254 -0
  510. package/skills/bober.graph/SKILL.md +85 -0
  511. package/skills/bober.impact/SKILL.md +101 -0
  512. package/skills/bober.incident/SKILL.md +245 -0
  513. package/skills/bober.onboard/SKILL.md +84 -0
  514. package/skills/bober.plan/SKILL.md +10 -0
  515. package/skills/bober.postmortem/SKILL.md +231 -0
  516. package/skills/bober.runbook/SKILL.md +335 -0
  517. package/skills/bober.using-bober/SKILL.md +133 -0
  518. package/skills/bober.verify/SKILL.md +143 -0
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Append-only approval audit logger (Sprint 13).
3
+ *
4
+ * Each call to recordApproval() appends ONE JSON line to
5
+ * .bober/audits/<runId>.jsonl. Lines never span. Concurrent appends from
6
+ * multiple async checkpoints serialize via an in-process Promise chain
7
+ * (per-runId mutex — unrelated runs proceed in parallel).
8
+ *
9
+ * File is created with mode 0600 on first append via fs.open with
10
+ * O_WRONLY|O_APPEND|O_CREAT flags. Subsequent appends preserve the mode
11
+ * (kernel does not re-chmod on O_APPEND). appendFile is NOT used because
12
+ * it does not reliably honor the mode argument across all Node versions.
13
+ *
14
+ * POSIX O_APPEND atomicity: single-line records are well under PIPE_BUF
15
+ * (4096 bytes), so cross-process appends are also safe in practice.
16
+ * Multi-process safety is not formally guaranteed beyond PIPE_BUF limits.
17
+ *
18
+ * approverId resolution: chooses a strategy per mechanism name.
19
+ * 1. PR mechanism: GitHub user from comment/merge actor (passed in).
20
+ * 2. CLI mechanism: process.env["USER"] || process.env["USERNAME"].
21
+ * 3. disk mechanism: `git config user.name` then env USER.
22
+ * 4. noop mechanism: 'autopilot'.
23
+ * 5. fallback: 'unknown'.
24
+ *
25
+ * Audit write failures NEVER break the pipeline — the finally block in
26
+ * runWithAudit swallows recordApproval errors via .catch(() => {}).
27
+ *
28
+ * Mechanism fallback chains (cli→noop, pr→disk) are transparent to this
29
+ * module. The audit records the *requested* mechanism name, not the actual
30
+ * fallback that fired inside the mechanism.
31
+ *
32
+ * Sprint 13 — colocated in src/orchestrator/checkpoints/ per Sprints 7-12 precedent.
33
+ */
34
+ import type { CheckpointOutcome } from "./types.js";
35
+ export type ApprovalOutcome = "approved" | "rejected" | "edited" | "aborted";
36
+ export type MechanismName = "cli" | "disk" | "pr" | "noop";
37
+ export interface EditDeltaSummary {
38
+ /** Number of lines in the after-text. */
39
+ lineCount: number;
40
+ /** First 200 characters of the after-text. */
41
+ firstChars: string;
42
+ }
43
+ export interface ApprovalRecord {
44
+ /** ISO-8601 timestamp set at write time. */
45
+ timestamp: string;
46
+ runId: string;
47
+ /** Widened to string: CheckpointId values are valid here but not enforced at runtime. */
48
+ checkpointId: string;
49
+ mechanism: MechanismName;
50
+ outcome: ApprovalOutcome;
51
+ approverId: string;
52
+ /** 1-based iteration count (per checkpoint invocation, not global). */
53
+ iteration: number;
54
+ /** First 500 chars of feedback text, if any. */
55
+ feedbackText?: string;
56
+ /** Null when outcome is not 'edited'. */
57
+ editDeltaSummary?: EditDeltaSummary | null;
58
+ durationMs: number;
59
+ }
60
+ export declare function getAuditPath(projectRoot: string, runId: string): string;
61
+ /**
62
+ * Append one ApprovalRecord to .bober/audits/<runId>.jsonl.
63
+ *
64
+ * Writes are serialized per-runId via a Promise chain so concurrent async
65
+ * callers for the same run never interleave partial lines.
66
+ *
67
+ * Propagates errors to the caller but does NOT break the chain — subsequent
68
+ * appends for the same runId will still proceed.
69
+ */
70
+ export declare function recordApproval(projectRoot: string, runId: string, record: ApprovalRecord): Promise<void>;
71
+ /**
72
+ * Resolve the identity of the approver from the mechanism name and optional hint.
73
+ *
74
+ * Resolution chain (per generatorNotes):
75
+ * 1. pr → `hint` (GitHub actor passed by caller) or 'github:unknown'
76
+ * 2. cli → process.env["USER"] || process.env["USERNAME"] || 'unknown'
77
+ * 3. disk → `git config user.name` (with 5s timeout, reject:false) → env USER → 'unknown'
78
+ * 4. noop → 'autopilot'
79
+ * 5. fallback → 'unknown'
80
+ */
81
+ export declare function resolveApproverId(mechanism: MechanismName, hint?: string): Promise<string>;
82
+ /**
83
+ * Extract a compact summary from an editDelta value.
84
+ * Returns null if the value cannot be coerced to a meaningful string.
85
+ *
86
+ * Rules:
87
+ * - string editDelta → after-text is the string itself
88
+ * - { after: string } → use `after`
89
+ * - { before, after } or any other object → JSON.stringify
90
+ * - null/undefined → null
91
+ */
92
+ export declare function summarizeEditDelta(editDelta: unknown): EditDeltaSummary | null;
93
+ /**
94
+ * Truncate feedback text to 500 characters to minimize PII surface in the audit log.
95
+ * Returns undefined if the input is undefined.
96
+ */
97
+ export declare function truncateFeedback(s: string | undefined): string | undefined;
98
+ /**
99
+ * Wrap a mechanism.request() call with audit accounting in a try/finally.
100
+ *
101
+ * This is the canonical seam (B) — every caller (pipeline.ts × 9 sites,
102
+ * feedback-router's runCheckpointWithFeedback) calls runWithAudit instead
103
+ * of mechanism.request() directly. The wrapper owns the try/finally so the
104
+ * audit entry is recorded even when the mechanism throws.
105
+ *
106
+ * Outcome mapping:
107
+ * { approved: true } → 'approved'
108
+ * { approved: false } → 'rejected' (feedbackText from outcome.feedback)
109
+ * { edit: true } → 'edited' (editDeltaSummary from outcome.editDelta)
110
+ * thrown error → 'aborted' (feedbackText from err.message)
111
+ *
112
+ * Audit write failures NEVER break the pipeline — they are swallowed via
113
+ * .catch(() => {}) after a logger.warn. The mechanism's outcome is always
114
+ * returned to the caller.
115
+ *
116
+ * Re-throws the original error after writing the audit entry so callers see
117
+ * the mechanism failure.
118
+ */
119
+ export declare function runWithAudit<T extends CheckpointOutcome>(opts: {
120
+ projectRoot: string;
121
+ runId: string;
122
+ checkpointId: string;
123
+ mechanism: MechanismName;
124
+ iteration: number;
125
+ approverHint?: string;
126
+ fn: () => Promise<T>;
127
+ }): Promise<T>;
128
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/checkpoints/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKpD,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC7E,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,yFAAyF;IACzF,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC3C,UAAU,EAAE,MAAM,CAAC;CACpB;AAID,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvE;AAwDD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,IAAI,CAAC,CAOf;AAID;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,aAAa,EACxB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CA8BjB;AAID;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CA0B9E;AAID;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAG1E;AAID;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,YAAY,CAAC,CAAC,SAAS,iBAAiB,EAAE,IAAI,EAAE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;CACtB,GAAG,OAAO,CAAC,CAAC,CAAC,CAkDb"}
@@ -0,0 +1,272 @@
1
+ /**
2
+ * Append-only approval audit logger (Sprint 13).
3
+ *
4
+ * Each call to recordApproval() appends ONE JSON line to
5
+ * .bober/audits/<runId>.jsonl. Lines never span. Concurrent appends from
6
+ * multiple async checkpoints serialize via an in-process Promise chain
7
+ * (per-runId mutex — unrelated runs proceed in parallel).
8
+ *
9
+ * File is created with mode 0600 on first append via fs.open with
10
+ * O_WRONLY|O_APPEND|O_CREAT flags. Subsequent appends preserve the mode
11
+ * (kernel does not re-chmod on O_APPEND). appendFile is NOT used because
12
+ * it does not reliably honor the mode argument across all Node versions.
13
+ *
14
+ * POSIX O_APPEND atomicity: single-line records are well under PIPE_BUF
15
+ * (4096 bytes), so cross-process appends are also safe in practice.
16
+ * Multi-process safety is not formally guaranteed beyond PIPE_BUF limits.
17
+ *
18
+ * approverId resolution: chooses a strategy per mechanism name.
19
+ * 1. PR mechanism: GitHub user from comment/merge actor (passed in).
20
+ * 2. CLI mechanism: process.env["USER"] || process.env["USERNAME"].
21
+ * 3. disk mechanism: `git config user.name` then env USER.
22
+ * 4. noop mechanism: 'autopilot'.
23
+ * 5. fallback: 'unknown'.
24
+ *
25
+ * Audit write failures NEVER break the pipeline — the finally block in
26
+ * runWithAudit swallows recordApproval errors via .catch(() => {}).
27
+ *
28
+ * Mechanism fallback chains (cli→noop, pr→disk) are transparent to this
29
+ * module. The audit records the *requested* mechanism name, not the actual
30
+ * fallback that fired inside the mechanism.
31
+ *
32
+ * Sprint 13 — colocated in src/orchestrator/checkpoints/ per Sprints 7-12 precedent.
33
+ */
34
+ import { open, mkdir } from "node:fs/promises";
35
+ import { constants } from "node:fs";
36
+ import { join } from "node:path";
37
+ import { execa } from "execa";
38
+ import { logger } from "../../utils/logger.js";
39
+ // ── Path helper ───────────────────────────────────────────────────────────────
40
+ export function getAuditPath(projectRoot, runId) {
41
+ return join(projectRoot, ".bober", "audits", `${runId}.jsonl`);
42
+ }
43
+ // ── Per-runId mutex (Promise-chain pattern) ──────────────────────────────────
44
+ // Mirrors prReadyTimer module-state idiom in mechanisms/pr.ts.
45
+ // One chain per runId so unrelated runs proceed in parallel.
46
+ const writeChains = new Map();
47
+ // ── Internal: append one JSON line atomically ─────────────────────────────────
48
+ async function appendOneLine(projectRoot, runId, record) {
49
+ const dir = join(projectRoot, ".bober", "audits");
50
+ await mkdir(dir, { recursive: true });
51
+ const path = getAuditPath(projectRoot, runId);
52
+ // Serialize the record — guard against circular references.
53
+ let line;
54
+ try {
55
+ line = JSON.stringify(record) + "\n";
56
+ }
57
+ catch (err) {
58
+ // Circular reference or other serialization failure — write a synthesized fallback.
59
+ const fallback = {
60
+ ...record,
61
+ feedbackText: `AUDIT_SERIALIZE_FAILED: ${err instanceof Error ? err.message : String(err)}`,
62
+ };
63
+ try {
64
+ line = JSON.stringify(fallback) + "\n";
65
+ }
66
+ catch {
67
+ // Extremely unlikely — give up and write a minimal record.
68
+ line = JSON.stringify({
69
+ timestamp: record.timestamp,
70
+ runId: record.runId,
71
+ checkpointId: record.checkpointId,
72
+ mechanism: record.mechanism,
73
+ outcome: record.outcome,
74
+ approverId: record.approverId,
75
+ iteration: record.iteration,
76
+ durationMs: record.durationMs,
77
+ feedbackText: "AUDIT_SERIALIZE_FAILED_UNRECOVERABLE",
78
+ }) + "\n";
79
+ }
80
+ }
81
+ const flags = constants.O_WRONLY | constants.O_APPEND | constants.O_CREAT;
82
+ const fh = await open(path, flags, 0o600);
83
+ try {
84
+ // Guarantee mode 0600 even if umask would have reduced it.
85
+ await fh.chmod(0o600);
86
+ await fh.write(line);
87
+ }
88
+ finally {
89
+ await fh.close();
90
+ }
91
+ }
92
+ // ── Public: recordApproval ────────────────────────────────────────────────────
93
+ /**
94
+ * Append one ApprovalRecord to .bober/audits/<runId>.jsonl.
95
+ *
96
+ * Writes are serialized per-runId via a Promise chain so concurrent async
97
+ * callers for the same run never interleave partial lines.
98
+ *
99
+ * Propagates errors to the caller but does NOT break the chain — subsequent
100
+ * appends for the same runId will still proceed.
101
+ */
102
+ export async function recordApproval(projectRoot, runId, record) {
103
+ const prev = writeChains.get(runId) ?? Promise.resolve();
104
+ const next = prev.then(() => appendOneLine(projectRoot, runId, record));
105
+ // Swallow errors in the chain pointer so subsequent appends aren't blocked,
106
+ // but propagate the real error to THIS caller via `next`.
107
+ writeChains.set(runId, next.catch(() => { }));
108
+ return next;
109
+ }
110
+ // ── Public: resolveApproverId ─────────────────────────────────────────────────
111
+ /**
112
+ * Resolve the identity of the approver from the mechanism name and optional hint.
113
+ *
114
+ * Resolution chain (per generatorNotes):
115
+ * 1. pr → `hint` (GitHub actor passed by caller) or 'github:unknown'
116
+ * 2. cli → process.env["USER"] || process.env["USERNAME"] || 'unknown'
117
+ * 3. disk → `git config user.name` (with 5s timeout, reject:false) → env USER → 'unknown'
118
+ * 4. noop → 'autopilot'
119
+ * 5. fallback → 'unknown'
120
+ */
121
+ export async function resolveApproverId(mechanism, hint) {
122
+ switch (mechanism) {
123
+ case "pr": {
124
+ return hint ?? "github:unknown";
125
+ }
126
+ case "cli": {
127
+ return process.env["USER"] ?? process.env["USERNAME"] ?? "unknown";
128
+ }
129
+ case "disk": {
130
+ // Try git config user.name first.
131
+ try {
132
+ const r = await execa("git", ["config", "user.name"], {
133
+ reject: false,
134
+ timeout: 5000,
135
+ });
136
+ if (r.exitCode === 0 && r.stdout.trim().length > 0) {
137
+ return r.stdout.trim();
138
+ }
139
+ }
140
+ catch {
141
+ // git not available — fall through.
142
+ }
143
+ return process.env["USER"] ?? process.env["USERNAME"] ?? "unknown";
144
+ }
145
+ case "noop": {
146
+ return "autopilot";
147
+ }
148
+ default: {
149
+ return "unknown";
150
+ }
151
+ }
152
+ }
153
+ // ── Public: summarizeEditDelta ────────────────────────────────────────────────
154
+ /**
155
+ * Extract a compact summary from an editDelta value.
156
+ * Returns null if the value cannot be coerced to a meaningful string.
157
+ *
158
+ * Rules:
159
+ * - string editDelta → after-text is the string itself
160
+ * - { after: string } → use `after`
161
+ * - { before, after } or any other object → JSON.stringify
162
+ * - null/undefined → null
163
+ */
164
+ export function summarizeEditDelta(editDelta) {
165
+ if (editDelta === null || editDelta === undefined) {
166
+ return null;
167
+ }
168
+ let afterText;
169
+ if (typeof editDelta === "string") {
170
+ afterText = editDelta;
171
+ }
172
+ else if (typeof editDelta === "object" &&
173
+ "after" in editDelta &&
174
+ typeof editDelta["after"] === "string") {
175
+ afterText = editDelta["after"];
176
+ }
177
+ else {
178
+ try {
179
+ afterText = JSON.stringify(editDelta);
180
+ }
181
+ catch {
182
+ return null;
183
+ }
184
+ }
185
+ return {
186
+ lineCount: afterText.split("\n").length,
187
+ firstChars: afterText.slice(0, 200),
188
+ };
189
+ }
190
+ // ── Public: truncateFeedback ─────────────────────────────────────────────────
191
+ /**
192
+ * Truncate feedback text to 500 characters to minimize PII surface in the audit log.
193
+ * Returns undefined if the input is undefined.
194
+ */
195
+ export function truncateFeedback(s) {
196
+ if (s === undefined)
197
+ return undefined;
198
+ return s.slice(0, 500);
199
+ }
200
+ // ── Public: runWithAudit ─────────────────────────────────────────────────────
201
+ /**
202
+ * Wrap a mechanism.request() call with audit accounting in a try/finally.
203
+ *
204
+ * This is the canonical seam (B) — every caller (pipeline.ts × 9 sites,
205
+ * feedback-router's runCheckpointWithFeedback) calls runWithAudit instead
206
+ * of mechanism.request() directly. The wrapper owns the try/finally so the
207
+ * audit entry is recorded even when the mechanism throws.
208
+ *
209
+ * Outcome mapping:
210
+ * { approved: true } → 'approved'
211
+ * { approved: false } → 'rejected' (feedbackText from outcome.feedback)
212
+ * { edit: true } → 'edited' (editDeltaSummary from outcome.editDelta)
213
+ * thrown error → 'aborted' (feedbackText from err.message)
214
+ *
215
+ * Audit write failures NEVER break the pipeline — they are swallowed via
216
+ * .catch(() => {}) after a logger.warn. The mechanism's outcome is always
217
+ * returned to the caller.
218
+ *
219
+ * Re-throws the original error after writing the audit entry so callers see
220
+ * the mechanism failure.
221
+ */
222
+ export async function runWithAudit(opts) {
223
+ const start = Date.now();
224
+ let outcome = "aborted";
225
+ let feedbackText;
226
+ let editDeltaSummary = null;
227
+ let thrown;
228
+ let result;
229
+ try {
230
+ result = await opts.fn();
231
+ // Narrow the CheckpointOutcome discriminated union.
232
+ if ("approved" in result && result.approved === true) {
233
+ outcome = "approved";
234
+ }
235
+ else if ("approved" in result && result.approved === false) {
236
+ outcome = "rejected";
237
+ feedbackText = truncateFeedback(result.feedback);
238
+ }
239
+ else if ("edit" in result && result.edit === true) {
240
+ outcome = "edited";
241
+ editDeltaSummary = summarizeEditDelta(result.editDelta);
242
+ }
243
+ }
244
+ catch (err) {
245
+ thrown = err;
246
+ outcome = "aborted";
247
+ feedbackText = truncateFeedback(err instanceof Error ? err.message : String(err));
248
+ }
249
+ finally {
250
+ const approverId = await resolveApproverId(opts.mechanism, opts.approverHint).catch(() => "unknown");
251
+ const record = {
252
+ timestamp: new Date().toISOString(),
253
+ runId: opts.runId,
254
+ checkpointId: opts.checkpointId,
255
+ mechanism: opts.mechanism,
256
+ outcome,
257
+ approverId,
258
+ iteration: opts.iteration,
259
+ feedbackText,
260
+ editDeltaSummary,
261
+ durationMs: Date.now() - start,
262
+ };
263
+ // Audit write failures MUST never break the pipeline.
264
+ await recordApproval(opts.projectRoot, opts.runId, record).catch((err) => {
265
+ logger.warn(`[audit] Failed to write audit entry for ${opts.checkpointId}/${opts.runId}: ${err instanceof Error ? err.message : String(err)}`);
266
+ });
267
+ }
268
+ if (thrown !== undefined)
269
+ throw thrown;
270
+ return result;
271
+ }
272
+ //# sourceMappingURL=audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../src/orchestrator/checkpoints/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAgC/C,iFAAiF;AAEjF,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,KAAa;IAC7D,OAAO,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,QAAQ,CAAC,CAAC;AACjE,CAAC;AAED,gFAAgF;AAChF,+DAA+D;AAC/D,6DAA6D;AAE7D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAyB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AAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAClI,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,MAAM,CAAC;IACvC,OAAO,MAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Feedback router (Sprint 12).
3
+ *
4
+ * Maps a CheckpointId to the responsible agent and re-invokes that agent
5
+ * with the prior feedback woven into its prompt. Per-agent adaptation
6
+ * differs by agent role (s12-c6). The 'gate' checkpoints abort
7
+ * the run on rejection — they are not iteration points.
8
+ *
9
+ * Abort token matching is case-SENSITIVE: `feedback.startsWith("!!abort")`.
10
+ * This matches shell convention markers (e.g., `#!`) where case matters.
11
+ * Tests must use the exact prefix "!!abort" (all lowercase).
12
+ *
13
+ * Edit delta application uses full-replacement semantics (no json-patch lib
14
+ * installed). If editDelta is a string, it replaces the file content directly.
15
+ * If it is { after: string }, the `after` property is used. Otherwise the
16
+ * value is JSON.stringify-ed. The original is backed up to
17
+ * `.bober/runs/<runId>/edits/<checkpointId>.original.<ext>` BEFORE overwrite
18
+ * to satisfy evaluatorNotes reversibility requirement.
19
+ *
20
+ * Iteration counters are per-checkpoint-invocation (passed in by the caller),
21
+ * NOT stored in a module-level map. The pipeline wires one counter per
22
+ * checkpoint-invocation site so post-sprint for sprint-1 and post-sprint for
23
+ * sprint-2 are independent.
24
+ *
25
+ * Sprint 12 — colocated in src/orchestrator/checkpoints/ per Sprint 7+8 precedent.
26
+ */
27
+ import type { CheckpointId, CheckpointOutcome } from "./types.js";
28
+ import { type MechanismName } from "./audit.js";
29
+ /**
30
+ * Agent types that can be re-invoked after a checkpoint rejection.
31
+ * 'gate' checkpoints are not re-invoked; rejection always aborts.
32
+ */
33
+ export type CheckpointAgent = "researcher" | "planner" | "generator" | "evaluator" | "gate";
34
+ /**
35
+ * Per-checkpoint responsibility table. Source-of-truth for s12-c1 + s12-c6.
36
+ * Gate entries abort the run on rejection; they have no agent to re-invoke.
37
+ */
38
+ export declare const CHECKPOINT_TO_AGENT: Record<CheckpointId, CheckpointAgent>;
39
+ /**
40
+ * Default escape-hatch prefix. Case-SENSITIVE: must be exactly "!!abort"
41
+ * at the start of the feedback string. Documented here and matched in
42
+ * shouldAbort() below.
43
+ */
44
+ export declare const ABORT_TOKEN = "!!abort";
45
+ /**
46
+ * Returns true if the feedback triggers an immediate abort.
47
+ *
48
+ * Two sources:
49
+ * 1. Feedback starts with ABORT_TOKEN ("!!abort") — case-sensitive prefix match.
50
+ * 2. envAbortToken is non-empty and appears anywhere in the feedback string.
51
+ */
52
+ export declare function shouldAbort(feedback: string, envAbortToken?: string): boolean;
53
+ /**
54
+ * A single feedback/rejection event in the iteration history for a checkpoint.
55
+ */
56
+ export interface FeedbackHistoryEntry {
57
+ iteration: number;
58
+ feedback: string;
59
+ editDelta?: unknown;
60
+ timestamp: string;
61
+ }
62
+ /**
63
+ * Structured reason for run abort. Written to .bober/runs/<runId>.aborted.json.
64
+ */
65
+ export interface RunAbortedReason {
66
+ reason: "CHECKPOINT_ITERATION_EXHAUSTED" | "GATE_REJECTED" | "USER_ABORT";
67
+ checkpointId: CheckpointId;
68
+ lastFeedback?: string;
69
+ iterationsCompleted: number;
70
+ }
71
+ /**
72
+ * Discriminated union returned by routeOutcome(). Callers MUST narrow on `kind`.
73
+ */
74
+ export type RouterDecision = {
75
+ kind: "approved";
76
+ } | {
77
+ kind: "retry";
78
+ newPrompt: string;
79
+ feedbackHistory: FeedbackHistoryEntry[];
80
+ } | {
81
+ kind: "edit-applied";
82
+ updatedArtifact: unknown;
83
+ } | {
84
+ kind: "abort";
85
+ reason: RunAbortedReason;
86
+ };
87
+ /**
88
+ * Discriminated union returned by runCheckpointWithFeedback().
89
+ */
90
+ export type CheckpointResolution = {
91
+ kind: "approved";
92
+ iterations: number;
93
+ finalArtifact: unknown;
94
+ } | {
95
+ kind: "edited";
96
+ iterations: number;
97
+ finalArtifact: unknown;
98
+ editDelta: unknown;
99
+ } | {
100
+ kind: "aborted";
101
+ reason: RunAbortedReason;
102
+ lastFeedback: string;
103
+ };
104
+ /**
105
+ * Get the responsible agent for a checkpoint ID.
106
+ */
107
+ export declare function getResponsibleAgent(checkpointId: CheckpointId): CheckpointAgent;
108
+ /**
109
+ * Build a per-agent augmented prompt for a retry invocation.
110
+ * Each agent type uses a distinct framing strategy (s12-c6).
111
+ *
112
+ * @throws Error if the agent is 'gate' — gate checkpoints must not be re-invoked.
113
+ */
114
+ export declare function buildFeedbackPrompt(checkpointId: CheckpointId, originalPrompt: string, feedbackHistory: FeedbackHistoryEntry[], maxIterations: number): string;
115
+ /**
116
+ * Apply an edit delta to an artifact file on disk.
117
+ *
118
+ * Steps:
119
+ * 1. Read original file content.
120
+ * 2. Write backup to <runsDir>/<runId>/edits/<checkpointId>.original.<ext>
121
+ * 3. Determine new content:
122
+ * - string editDelta → full replacement
123
+ * - { after: string } → use `after` property
124
+ * - anything else → JSON.stringify(editDelta, null, 2)
125
+ * 4. Atomic write: write to <artifactPath>.tmp then fs.rename.
126
+ */
127
+ export declare function applyEditDelta(artifactPath: string, editDelta: unknown, runsDir: string, runId: string, checkpointId: string): Promise<void>;
128
+ /**
129
+ * Write an abort marker to .bober/runs/<runId>.aborted.json atomically.
130
+ * Creates parent directories as needed.
131
+ */
132
+ export declare function writeAbortMarker(projectRoot: string, runId: string, reason: RunAbortedReason): Promise<void>;
133
+ /**
134
+ * Write a completion marker to .bober/runs/<runId>.completed.json atomically.
135
+ * Creates parent directories as needed.
136
+ */
137
+ export declare function writeCompletionMarker(projectRoot: string, runId: string, summary: Record<string, unknown>): Promise<void>;
138
+ /**
139
+ * Route a single CheckpointOutcome to a RouterDecision.
140
+ *
141
+ * This is a pure decision function — callers (pipeline.ts / runCheckpointWithFeedback)
142
+ * are responsible for acting on the returned decision (re-invoking agents, writing
143
+ * abort markers, etc.).
144
+ *
145
+ * @param checkpointId The checkpoint whose outcome is being routed.
146
+ * @param outcome The discriminated outcome from the mechanism.
147
+ * @param iteration Current iteration count (1-based).
148
+ * @param maxIterations Cap from config.pipeline.maxCheckpointIterations.
149
+ * @param feedbackHistory All prior feedback entries for this checkpoint invocation.
150
+ * @param originalPrompt The agent's original prompt (for augmentation).
151
+ * @param envAbortToken Optional env-var abort token (checked in addition to ABORT_TOKEN).
152
+ */
153
+ export declare function routeOutcome(checkpointId: CheckpointId, outcome: CheckpointOutcome, iteration: number, maxIterations: number, feedbackHistory: FeedbackHistoryEntry[], originalPrompt: string, envAbortToken?: string): RouterDecision;
154
+ /**
155
+ * Options for runCheckpointWithFeedback.
156
+ */
157
+ export interface RunCheckpointWithFeedbackOpts {
158
+ /** The checkpoint to invoke. */
159
+ checkpointId: CheckpointId;
160
+ /** The artifact to pass to the mechanism on the first call. */
161
+ artifact: unknown;
162
+ /** The mechanism to use for this checkpoint. */
163
+ mechanism: {
164
+ request: (id: CheckpointId, artifact: unknown) => Promise<CheckpointOutcome>;
165
+ };
166
+ /** Maximum re-invocations for this checkpoint (from config.pipeline.maxCheckpointIterations). */
167
+ maxIterations: number;
168
+ /** Run identifier used for abort/edit markers on disk. */
169
+ runId: string;
170
+ /** Absolute path to the project root (for .bober/runs/ markers). */
171
+ projectRoot: string;
172
+ /**
173
+ * Mechanism name for audit logging. Defaults to 'noop' when omitted
174
+ * (safe for tests that don't exercise the audit path).
175
+ */
176
+ mechanismName?: MechanismName;
177
+ /**
178
+ * Orchestrator-injected callback to re-run the responsible agent.
179
+ * Returns the new artifact produced by the agent.
180
+ * The callback receives: (agentType, augmentedPrompt) → Promise<unknown>.
181
+ */
182
+ reinvokeAgent: (agentType: CheckpointAgent, augmentedPrompt: string) => Promise<unknown>;
183
+ /** The original prompt that was passed to the responsible agent. */
184
+ originalPrompt: string;
185
+ /**
186
+ * Optional path to the artifact file on disk (needed for edit-delta application).
187
+ * If omitted, edit deltas are returned but not written to disk.
188
+ */
189
+ artifactPath?: string;
190
+ /**
191
+ * Optional env-var abort token (checked alongside ABORT_TOKEN).
192
+ * If omitted, falls back to process.env['BOBER_CHECKPOINT_ABORT_TOKEN'] automatically.
193
+ */
194
+ envAbortToken?: string;
195
+ }
196
+ /**
197
+ * Run a checkpoint with automatic feedback propagation and iteration cap.
198
+ *
199
+ * Loop semantics:
200
+ * - Start at iteration 1.
201
+ * - Call mechanism.request(checkpointId, artifact).
202
+ * - On approved → resolve { kind: 'approved', iterations: N, finalArtifact }.
203
+ * - On edit → applyEditDelta if artifactPath is set; resolve { kind: 'edited', ... }.
204
+ * - On rejection:
205
+ * - shouldAbort → write .aborted.json; resolve { kind: 'aborted', reason: 'USER_ABORT' }.
206
+ * - gate → write .aborted.json; resolve { kind: 'aborted', reason: 'GATE_REJECTED' }.
207
+ * - iteration >= maxIterations → write .aborted.json; resolve 'CHECKPOINT_ITERATION_EXHAUSTED'.
208
+ * - else → buildFeedbackPrompt; reinvokeAgent; new artifact; loop with N+1.
209
+ *
210
+ * Iteration counters are per-invocation of this function, not global.
211
+ */
212
+ export declare function runCheckpointWithFeedback(opts: RunCheckpointWithFeedbackOpts): Promise<CheckpointResolution>;
213
+ //# sourceMappingURL=feedback-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback-router.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/checkpoints/feedback-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAElE,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAI9D;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,MAAM,CAAC;AAE5F;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,YAAY,EAAE,eAAe,CAUrE,CAA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