hungry-ghost-hive 0.47.4 → 0.49.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 (478) hide show
  1. package/dist/agents/base-agent.d.ts +11 -11
  2. package/dist/agents/base-agent.d.ts.map +1 -1
  3. package/dist/agents/base-agent.js +25 -25
  4. package/dist/agents/base-agent.js.map +1 -1
  5. package/dist/agents/base-agent.test.js +2 -1
  6. package/dist/agents/base-agent.test.js.map +1 -1
  7. package/dist/agents/intermediate.d.ts +2 -0
  8. package/dist/agents/intermediate.d.ts.map +1 -1
  9. package/dist/agents/intermediate.js +25 -18
  10. package/dist/agents/intermediate.js.map +1 -1
  11. package/dist/agents/junior.d.ts +2 -0
  12. package/dist/agents/junior.d.ts.map +1 -1
  13. package/dist/agents/junior.js +25 -18
  14. package/dist/agents/junior.js.map +1 -1
  15. package/dist/agents/qa.d.ts +2 -0
  16. package/dist/agents/qa.d.ts.map +1 -1
  17. package/dist/agents/qa.js +47 -38
  18. package/dist/agents/qa.js.map +1 -1
  19. package/dist/agents/senior.d.ts +2 -0
  20. package/dist/agents/senior.d.ts.map +1 -1
  21. package/dist/agents/senior.js +40 -27
  22. package/dist/agents/senior.js.map +1 -1
  23. package/dist/agents/tech-lead.d.ts +2 -0
  24. package/dist/agents/tech-lead.d.ts.map +1 -1
  25. package/dist/agents/tech-lead.js +37 -31
  26. package/dist/agents/tech-lead.js.map +1 -1
  27. package/dist/cli/commands/add-repo.js +2 -2
  28. package/dist/cli/commands/add-repo.js.map +1 -1
  29. package/dist/cli/commands/add-repo.test.js +1 -1
  30. package/dist/cli/commands/add-repo.test.js.map +1 -1
  31. package/dist/cli/commands/agents.d.ts.map +1 -1
  32. package/dist/cli/commands/agents.js +12 -10
  33. package/dist/cli/commands/agents.js.map +1 -1
  34. package/dist/cli/commands/agents.test.js +7 -7
  35. package/dist/cli/commands/agents.test.js.map +1 -1
  36. package/dist/cli/commands/approach.js +2 -2
  37. package/dist/cli/commands/approach.js.map +1 -1
  38. package/dist/cli/commands/approvals.js +7 -7
  39. package/dist/cli/commands/approvals.js.map +1 -1
  40. package/dist/cli/commands/approvals.test.js +8 -8
  41. package/dist/cli/commands/approvals.test.js.map +1 -1
  42. package/dist/cli/commands/assign.js +4 -4
  43. package/dist/cli/commands/assign.js.map +1 -1
  44. package/dist/cli/commands/assign.test.js +18 -16
  45. package/dist/cli/commands/assign.test.js.map +1 -1
  46. package/dist/cli/commands/cleanup.d.ts.map +1 -1
  47. package/dist/cli/commands/cleanup.js +8 -8
  48. package/dist/cli/commands/cleanup.js.map +1 -1
  49. package/dist/cli/commands/cleanup.test.js +5 -1
  50. package/dist/cli/commands/cleanup.test.js.map +1 -1
  51. package/dist/cli/commands/escalations.js +9 -7
  52. package/dist/cli/commands/escalations.js.map +1 -1
  53. package/dist/cli/commands/escalations.test.js +2 -2
  54. package/dist/cli/commands/escalations.test.js.map +1 -1
  55. package/dist/cli/commands/init.d.ts.map +1 -1
  56. package/dist/cli/commands/init.js +48 -5
  57. package/dist/cli/commands/init.js.map +1 -1
  58. package/dist/cli/commands/init.test.js +4 -0
  59. package/dist/cli/commands/init.test.js.map +1 -1
  60. package/dist/cli/commands/manager/agent-monitoring.d.ts +2 -2
  61. package/dist/cli/commands/manager/agent-monitoring.d.ts.map +1 -1
  62. package/dist/cli/commands/manager/agent-monitoring.js +1 -1
  63. package/dist/cli/commands/manager/agent-monitoring.js.map +1 -1
  64. package/dist/cli/commands/manager/auditor-lifecycle.js +3 -3
  65. package/dist/cli/commands/manager/auditor-lifecycle.js.map +1 -1
  66. package/dist/cli/commands/manager/auditor-lifecycle.test.js +21 -14
  67. package/dist/cli/commands/manager/auditor-lifecycle.test.js.map +1 -1
  68. package/dist/cli/commands/manager/auto-reject-comment-only-reviews.test.js +28 -23
  69. package/dist/cli/commands/manager/auto-reject-comment-only-reviews.test.js.map +1 -1
  70. package/dist/cli/commands/manager/escalation-handler.d.ts +2 -2
  71. package/dist/cli/commands/manager/escalation-handler.d.ts.map +1 -1
  72. package/dist/cli/commands/manager/escalation-handler.js +11 -10
  73. package/dist/cli/commands/manager/escalation-handler.js.map +1 -1
  74. package/dist/cli/commands/manager/escalation-handler.test.js +8 -8
  75. package/dist/cli/commands/manager/escalation-handler.test.js.map +1 -1
  76. package/dist/cli/commands/manager/feature-sign-off.js +7 -7
  77. package/dist/cli/commands/manager/feature-sign-off.js.map +1 -1
  78. package/dist/cli/commands/manager/feature-sign-off.test.js +40 -31
  79. package/dist/cli/commands/manager/feature-sign-off.test.js.map +1 -1
  80. package/dist/cli/commands/manager/feature-test-result.d.ts.map +1 -1
  81. package/dist/cli/commands/manager/feature-test-result.js +12 -13
  82. package/dist/cli/commands/manager/feature-test-result.js.map +1 -1
  83. package/dist/cli/commands/manager/handoff-recovery.d.ts.map +1 -1
  84. package/dist/cli/commands/manager/handoff-recovery.js +14 -15
  85. package/dist/cli/commands/manager/handoff-recovery.js.map +1 -1
  86. package/dist/cli/commands/manager/index.d.ts.map +1 -1
  87. package/dist/cli/commands/manager/index.js +26 -26
  88. package/dist/cli/commands/manager/index.js.map +1 -1
  89. package/dist/cli/commands/manager/index.test.js +3 -3
  90. package/dist/cli/commands/manager/index.test.js.map +1 -1
  91. package/dist/cli/commands/manager/merged-story-cleanup.d.ts +2 -2
  92. package/dist/cli/commands/manager/merged-story-cleanup.d.ts.map +1 -1
  93. package/dist/cli/commands/manager/merged-story-cleanup.js +6 -7
  94. package/dist/cli/commands/manager/merged-story-cleanup.js.map +1 -1
  95. package/dist/cli/commands/manager/merged-story-cleanup.test.js +27 -18
  96. package/dist/cli/commands/manager/merged-story-cleanup.test.js.map +1 -1
  97. package/dist/cli/commands/manager/pr-sync-orchestrator.d.ts.map +1 -1
  98. package/dist/cli/commands/manager/pr-sync-orchestrator.js +46 -38
  99. package/dist/cli/commands/manager/pr-sync-orchestrator.js.map +1 -1
  100. package/dist/cli/commands/manager/qa-review-handler.d.ts.map +1 -1
  101. package/dist/cli/commands/manager/qa-review-handler.js +25 -22
  102. package/dist/cli/commands/manager/qa-review-handler.js.map +1 -1
  103. package/dist/cli/commands/manager/spin-down.d.ts.map +1 -1
  104. package/dist/cli/commands/manager/spin-down.js +23 -19
  105. package/dist/cli/commands/manager/spin-down.js.map +1 -1
  106. package/dist/cli/commands/manager/stale-escalations.d.ts +2 -3
  107. package/dist/cli/commands/manager/stale-escalations.d.ts.map +1 -1
  108. package/dist/cli/commands/manager/stale-escalations.js.map +1 -1
  109. package/dist/cli/commands/manager/stuck-story-helpers.js +8 -8
  110. package/dist/cli/commands/manager/stuck-story-helpers.js.map +1 -1
  111. package/dist/cli/commands/manager/stuck-story-processor.d.ts +2 -2
  112. package/dist/cli/commands/manager/stuck-story-processor.d.ts.map +1 -1
  113. package/dist/cli/commands/manager/stuck-story-processor.js +23 -22
  114. package/dist/cli/commands/manager/stuck-story-processor.js.map +1 -1
  115. package/dist/cli/commands/manager/tech-lead-lifecycle.js +6 -6
  116. package/dist/cli/commands/manager/tech-lead-lifecycle.js.map +1 -1
  117. package/dist/cli/commands/manager/types.d.ts +2 -3
  118. package/dist/cli/commands/manager/types.d.ts.map +1 -1
  119. package/dist/cli/commands/manager/types.js.map +1 -1
  120. package/dist/cli/commands/msg.test.js +2 -2
  121. package/dist/cli/commands/msg.test.js.map +1 -1
  122. package/dist/cli/commands/my-stories.d.ts.map +1 -1
  123. package/dist/cli/commands/my-stories.js +17 -18
  124. package/dist/cli/commands/my-stories.js.map +1 -1
  125. package/dist/cli/commands/my-stories.test.js +2 -2
  126. package/dist/cli/commands/my-stories.test.js.map +1 -1
  127. package/dist/cli/commands/nuke.test.js +1 -1
  128. package/dist/cli/commands/nuke.test.js.map +1 -1
  129. package/dist/cli/commands/pr.js +32 -32
  130. package/dist/cli/commands/pr.js.map +1 -1
  131. package/dist/cli/commands/pr.test.js +10 -6
  132. package/dist/cli/commands/pr.test.js.map +1 -1
  133. package/dist/cli/commands/progress.d.ts.map +1 -1
  134. package/dist/cli/commands/progress.js +4 -5
  135. package/dist/cli/commands/progress.js.map +1 -1
  136. package/dist/cli/commands/progress.test.js +1 -1
  137. package/dist/cli/commands/progress.test.js.map +1 -1
  138. package/dist/cli/commands/req-headless.test.d.ts +2 -0
  139. package/dist/cli/commands/req-headless.test.d.ts.map +1 -0
  140. package/dist/cli/commands/req-headless.test.js +128 -0
  141. package/dist/cli/commands/req-headless.test.js.map +1 -0
  142. package/dist/cli/commands/req-spawn.test.js +5 -1
  143. package/dist/cli/commands/req-spawn.test.js.map +1 -1
  144. package/dist/cli/commands/req.d.ts.map +1 -1
  145. package/dist/cli/commands/req.js +24 -21
  146. package/dist/cli/commands/req.js.map +1 -1
  147. package/dist/cli/commands/req.test.js +31 -0
  148. package/dist/cli/commands/req.test.js.map +1 -1
  149. package/dist/cli/commands/resume.d.ts.map +1 -1
  150. package/dist/cli/commands/resume.js +7 -8
  151. package/dist/cli/commands/resume.js.map +1 -1
  152. package/dist/cli/commands/resume.test.js +1 -1
  153. package/dist/cli/commands/resume.test.js.map +1 -1
  154. package/dist/cli/commands/status.d.ts.map +1 -1
  155. package/dist/cli/commands/status.js +42 -40
  156. package/dist/cli/commands/status.js.map +1 -1
  157. package/dist/cli/commands/status.test.js +1 -1
  158. package/dist/cli/commands/status.test.js.map +1 -1
  159. package/dist/cli/commands/stories.js +9 -9
  160. package/dist/cli/commands/stories.js.map +1 -1
  161. package/dist/cli/commands/stories.test.js +2 -2
  162. package/dist/cli/commands/stories.test.js.map +1 -1
  163. package/dist/cli/commands/teams.js +11 -11
  164. package/dist/cli/commands/teams.js.map +1 -1
  165. package/dist/cli/commands/teams.test.js +2 -2
  166. package/dist/cli/commands/teams.test.js.map +1 -1
  167. package/dist/cli/dashboard/index.d.ts +2 -2
  168. package/dist/cli/dashboard/index.d.ts.map +1 -1
  169. package/dist/cli/dashboard/index.js +29 -20
  170. package/dist/cli/dashboard/index.js.map +1 -1
  171. package/dist/cli/dashboard/index.test.js +34 -32
  172. package/dist/cli/dashboard/index.test.js.map +1 -1
  173. package/dist/cli/dashboard/panels/activity.d.ts +3 -3
  174. package/dist/cli/dashboard/panels/activity.d.ts.map +1 -1
  175. package/dist/cli/dashboard/panels/activity.js +1 -1
  176. package/dist/cli/dashboard/panels/activity.js.map +1 -1
  177. package/dist/cli/dashboard/panels/agents.d.ts +3 -3
  178. package/dist/cli/dashboard/panels/agents.d.ts.map +1 -1
  179. package/dist/cli/dashboard/panels/agents.js +2 -2
  180. package/dist/cli/dashboard/panels/agents.js.map +1 -1
  181. package/dist/cli/dashboard/panels/escalations.d.ts +3 -3
  182. package/dist/cli/dashboard/panels/escalations.d.ts.map +1 -1
  183. package/dist/cli/dashboard/panels/escalations.js +1 -1
  184. package/dist/cli/dashboard/panels/escalations.js.map +1 -1
  185. package/dist/cli/dashboard/panels/merge-queue.d.ts +3 -3
  186. package/dist/cli/dashboard/panels/merge-queue.d.ts.map +1 -1
  187. package/dist/cli/dashboard/panels/merge-queue.js +1 -1
  188. package/dist/cli/dashboard/panels/merge-queue.js.map +1 -1
  189. package/dist/cli/dashboard/panels/pipeline.d.ts +3 -3
  190. package/dist/cli/dashboard/panels/pipeline.d.ts.map +1 -1
  191. package/dist/cli/dashboard/panels/pipeline.js +1 -1
  192. package/dist/cli/dashboard/panels/pipeline.js.map +1 -1
  193. package/dist/config/schema.d.ts +85 -82
  194. package/dist/config/schema.d.ts.map +1 -1
  195. package/dist/config/schema.js +1 -0
  196. package/dist/config/schema.js.map +1 -1
  197. package/dist/connectors/project-management/operations.d.ts +7 -7
  198. package/dist/connectors/project-management/operations.d.ts.map +1 -1
  199. package/dist/connectors/project-management/operations.js +2 -3
  200. package/dist/connectors/project-management/operations.js.map +1 -1
  201. package/dist/context-files/index.test.js +1 -0
  202. package/dist/context-files/index.test.js.map +1 -1
  203. package/dist/db/client.d.ts +6 -0
  204. package/dist/db/client.d.ts.map +1 -1
  205. package/dist/db/client.js +7 -0
  206. package/dist/db/client.js.map +1 -1
  207. package/dist/db/postgres-provider.d.ts +43 -0
  208. package/dist/db/postgres-provider.d.ts.map +1 -0
  209. package/dist/db/postgres-provider.integration.test.d.ts +2 -0
  210. package/dist/db/postgres-provider.integration.test.d.ts.map +1 -0
  211. package/dist/db/postgres-provider.integration.test.js +399 -0
  212. package/dist/db/postgres-provider.integration.test.js.map +1 -0
  213. package/dist/db/postgres-provider.js +315 -0
  214. package/dist/db/postgres-provider.js.map +1 -0
  215. package/dist/db/postgres-provider.test.d.ts +2 -0
  216. package/dist/db/postgres-provider.test.d.ts.map +1 -0
  217. package/dist/db/postgres-provider.test.js +72 -0
  218. package/dist/db/postgres-provider.test.js.map +1 -0
  219. package/dist/db/provider.d.ts +59 -0
  220. package/dist/db/provider.d.ts.map +1 -0
  221. package/dist/db/provider.js +121 -0
  222. package/dist/db/provider.js.map +1 -0
  223. package/dist/db/provider.test.d.ts +2 -0
  224. package/dist/db/provider.test.d.ts.map +1 -0
  225. package/dist/db/provider.test.js +226 -0
  226. package/dist/db/provider.test.js.map +1 -0
  227. package/dist/db/queries/agents.d.ts +13 -13
  228. package/dist/db/queries/agents.d.ts.map +1 -1
  229. package/dist/db/queries/agents.js +27 -28
  230. package/dist/db/queries/agents.js.map +1 -1
  231. package/dist/db/queries/agents.test.js +113 -111
  232. package/dist/db/queries/agents.test.js.map +1 -1
  233. package/dist/db/queries/escalations.d.ts +16 -16
  234. package/dist/db/queries/escalations.d.ts.map +1 -1
  235. package/dist/db/queries/escalations.js +34 -35
  236. package/dist/db/queries/escalations.js.map +1 -1
  237. package/dist/db/queries/escalations.test.js +133 -131
  238. package/dist/db/queries/escalations.test.js.map +1 -1
  239. package/dist/db/queries/heartbeat.d.ts +5 -5
  240. package/dist/db/queries/heartbeat.d.ts.map +1 -1
  241. package/dist/db/queries/heartbeat.js +7 -23
  242. package/dist/db/queries/heartbeat.js.map +1 -1
  243. package/dist/db/queries/heartbeat.test.js +76 -76
  244. package/dist/db/queries/heartbeat.test.js.map +1 -1
  245. package/dist/db/queries/integration-sync.d.ts +7 -7
  246. package/dist/db/queries/integration-sync.d.ts.map +1 -1
  247. package/dist/db/queries/integration-sync.js +13 -14
  248. package/dist/db/queries/integration-sync.js.map +1 -1
  249. package/dist/db/queries/logs.d.ts +10 -10
  250. package/dist/db/queries/logs.d.ts.map +1 -1
  251. package/dist/db/queries/logs.js +44 -42
  252. package/dist/db/queries/logs.js.map +1 -1
  253. package/dist/db/queries/logs.test.js +149 -146
  254. package/dist/db/queries/logs.test.js.map +1 -1
  255. package/dist/db/queries/messages.d.ts +6 -6
  256. package/dist/db/queries/messages.d.ts.map +1 -1
  257. package/dist/db/queries/messages.js +12 -11
  258. package/dist/db/queries/messages.js.map +1 -1
  259. package/dist/db/queries/messages.test.js +47 -46
  260. package/dist/db/queries/messages.test.js.map +1 -1
  261. package/dist/db/queries/pull-requests.d.ts +18 -18
  262. package/dist/db/queries/pull-requests.d.ts.map +1 -1
  263. package/dist/db/queries/pull-requests.js +50 -48
  264. package/dist/db/queries/pull-requests.js.map +1 -1
  265. package/dist/db/queries/pull-requests.test.js +195 -198
  266. package/dist/db/queries/pull-requests.test.js.map +1 -1
  267. package/dist/db/queries/requirements.d.ts +8 -8
  268. package/dist/db/queries/requirements.d.ts.map +1 -1
  269. package/dist/db/queries/requirements.js +17 -18
  270. package/dist/db/queries/requirements.js.map +1 -1
  271. package/dist/db/queries/requirements.test.js +83 -81
  272. package/dist/db/queries/requirements.test.js.map +1 -1
  273. package/dist/db/queries/stories.d.ts +29 -29
  274. package/dist/db/queries/stories.d.ts.map +1 -1
  275. package/dist/db/queries/stories.js +58 -64
  276. package/dist/db/queries/stories.js.map +1 -1
  277. package/dist/db/queries/stories.test.js +172 -170
  278. package/dist/db/queries/stories.test.js.map +1 -1
  279. package/dist/db/queries/teams.d.ts +6 -6
  280. package/dist/db/queries/teams.d.ts.map +1 -1
  281. package/dist/db/queries/teams.js +11 -12
  282. package/dist/db/queries/teams.js.map +1 -1
  283. package/dist/db/queries/teams.test.js +36 -34
  284. package/dist/db/queries/teams.test.js.map +1 -1
  285. package/dist/index.js +8 -1
  286. package/dist/index.js.map +1 -1
  287. package/dist/integrations/jira/repair.test.js +26 -24
  288. package/dist/integrations/jira/repair.test.js.map +1 -1
  289. package/dist/integrations/jira/stories.d.ts +3 -3
  290. package/dist/integrations/jira/stories.d.ts.map +1 -1
  291. package/dist/integrations/jira/stories.js +12 -12
  292. package/dist/integrations/jira/stories.js.map +1 -1
  293. package/dist/integrations/jira/stories.test.js +10 -8
  294. package/dist/integrations/jira/stories.test.js.map +1 -1
  295. package/dist/integrations/jira/sync.d.ts +7 -7
  296. package/dist/integrations/jira/sync.d.ts.map +1 -1
  297. package/dist/integrations/jira/sync.js +17 -20
  298. package/dist/integrations/jira/sync.js.map +1 -1
  299. package/dist/integrations/jira/sync.test.js +63 -62
  300. package/dist/integrations/jira/sync.test.js.map +1 -1
  301. package/dist/integrations/jira/transitions.d.ts +3 -3
  302. package/dist/integrations/jira/transitions.d.ts.map +1 -1
  303. package/dist/integrations/jira/transitions.js +3 -3
  304. package/dist/integrations/jira/transitions.js.map +1 -1
  305. package/dist/orchestrator/agent-selector.d.ts +3 -3
  306. package/dist/orchestrator/agent-selector.d.ts.map +1 -1
  307. package/dist/orchestrator/agent-selector.js +5 -6
  308. package/dist/orchestrator/agent-selector.js.map +1 -1
  309. package/dist/orchestrator/dependency-resolver.d.ts +4 -4
  310. package/dist/orchestrator/dependency-resolver.d.ts.map +1 -1
  311. package/dist/orchestrator/dependency-resolver.js +6 -6
  312. package/dist/orchestrator/dependency-resolver.js.map +1 -1
  313. package/dist/orchestrator/feature-branch.d.ts +3 -3
  314. package/dist/orchestrator/feature-branch.d.ts.map +1 -1
  315. package/dist/orchestrator/feature-branch.js +9 -10
  316. package/dist/orchestrator/feature-branch.js.map +1 -1
  317. package/dist/orchestrator/feature-branch.test.js +80 -78
  318. package/dist/orchestrator/feature-branch.test.js.map +1 -1
  319. package/dist/orchestrator/orphan-recovery.d.ts +2 -2
  320. package/dist/orchestrator/orphan-recovery.d.ts.map +1 -1
  321. package/dist/orchestrator/orphan-recovery.js +10 -10
  322. package/dist/orchestrator/orphan-recovery.js.map +1 -1
  323. package/dist/orchestrator/scheduler.d.ts +4 -4
  324. package/dist/orchestrator/scheduler.d.ts.map +1 -1
  325. package/dist/orchestrator/scheduler.js +90 -76
  326. package/dist/orchestrator/scheduler.js.map +1 -1
  327. package/dist/orchestrator/scheduler.test.js +496 -374
  328. package/dist/orchestrator/scheduler.test.js.map +1 -1
  329. package/dist/utils/auto-merge.d.ts.map +1 -1
  330. package/dist/utils/auto-merge.js +74 -56
  331. package/dist/utils/auto-merge.js.map +1 -1
  332. package/dist/utils/auto-merge.test.js +101 -66
  333. package/dist/utils/auto-merge.test.js.map +1 -1
  334. package/dist/utils/cli-helpers.d.ts +5 -5
  335. package/dist/utils/cli-helpers.d.ts.map +1 -1
  336. package/dist/utils/cli-helpers.js +8 -9
  337. package/dist/utils/cli-helpers.js.map +1 -1
  338. package/dist/utils/cli-helpers.test.js +28 -30
  339. package/dist/utils/cli-helpers.test.js.map +1 -1
  340. package/dist/utils/paths.d.ts +6 -0
  341. package/dist/utils/paths.d.ts.map +1 -1
  342. package/dist/utils/paths.js +12 -1
  343. package/dist/utils/paths.js.map +1 -1
  344. package/dist/utils/paths.test.js +1 -0
  345. package/dist/utils/paths.test.js.map +1 -1
  346. package/dist/utils/pr-sync.d.ts +10 -10
  347. package/dist/utils/pr-sync.d.ts.map +1 -1
  348. package/dist/utils/pr-sync.js +20 -21
  349. package/dist/utils/pr-sync.js.map +1 -1
  350. package/dist/utils/pr-sync.test.js +52 -50
  351. package/dist/utils/pr-sync.test.js.map +1 -1
  352. package/dist/utils/with-hive-context.d.ts.map +1 -1
  353. package/dist/utils/with-hive-context.js +70 -1
  354. package/dist/utils/with-hive-context.js.map +1 -1
  355. package/package.json +3 -1
  356. package/src/agents/base-agent.test.ts +2 -1
  357. package/src/agents/base-agent.ts +32 -28
  358. package/src/agents/intermediate.ts +27 -18
  359. package/src/agents/junior.ts +27 -18
  360. package/src/agents/qa.ts +54 -40
  361. package/src/agents/senior.ts +42 -27
  362. package/src/agents/tech-lead.ts +42 -32
  363. package/src/cli/commands/add-repo.test.ts +1 -1
  364. package/src/cli/commands/add-repo.ts +2 -2
  365. package/src/cli/commands/agents.test.ts +7 -7
  366. package/src/cli/commands/agents.ts +12 -10
  367. package/src/cli/commands/approach.ts +2 -2
  368. package/src/cli/commands/approvals.test.ts +8 -8
  369. package/src/cli/commands/approvals.ts +9 -7
  370. package/src/cli/commands/assign.test.ts +19 -18
  371. package/src/cli/commands/assign.ts +4 -4
  372. package/src/cli/commands/cleanup.test.ts +5 -1
  373. package/src/cli/commands/cleanup.ts +11 -9
  374. package/src/cli/commands/escalations.test.ts +2 -2
  375. package/src/cli/commands/escalations.ts +9 -7
  376. package/src/cli/commands/init.test.ts +5 -0
  377. package/src/cli/commands/init.ts +53 -5
  378. package/src/cli/commands/manager/agent-monitoring.ts +3 -3
  379. package/src/cli/commands/manager/auditor-lifecycle.test.ts +21 -14
  380. package/src/cli/commands/manager/auditor-lifecycle.ts +3 -3
  381. package/src/cli/commands/manager/auto-reject-comment-only-reviews.test.ts +28 -23
  382. package/src/cli/commands/manager/escalation-handler.test.ts +13 -13
  383. package/src/cli/commands/manager/escalation-handler.ts +19 -12
  384. package/src/cli/commands/manager/feature-sign-off.test.ts +40 -31
  385. package/src/cli/commands/manager/feature-sign-off.ts +7 -7
  386. package/src/cli/commands/manager/feature-test-result.ts +13 -16
  387. package/src/cli/commands/manager/handoff-recovery.ts +20 -20
  388. package/src/cli/commands/manager/index.test.ts +4 -4
  389. package/src/cli/commands/manager/index.ts +58 -59
  390. package/src/cli/commands/manager/merged-story-cleanup.test.ts +28 -19
  391. package/src/cli/commands/manager/merged-story-cleanup.ts +11 -14
  392. package/src/cli/commands/manager/pr-sync-orchestrator.ts +115 -110
  393. package/src/cli/commands/manager/qa-review-handler.ts +50 -63
  394. package/src/cli/commands/manager/spin-down.ts +27 -25
  395. package/src/cli/commands/manager/stale-escalations.ts +2 -3
  396. package/src/cli/commands/manager/stuck-story-helpers.ts +10 -10
  397. package/src/cli/commands/manager/stuck-story-processor.ts +56 -62
  398. package/src/cli/commands/manager/tech-lead-lifecycle.ts +6 -6
  399. package/src/cli/commands/manager/types.ts +2 -3
  400. package/src/cli/commands/msg.test.ts +2 -2
  401. package/src/cli/commands/my-stories.test.ts +4 -2
  402. package/src/cli/commands/my-stories.ts +22 -27
  403. package/src/cli/commands/nuke.test.ts +1 -1
  404. package/src/cli/commands/pr.test.ts +10 -6
  405. package/src/cli/commands/pr.ts +41 -32
  406. package/src/cli/commands/progress.test.ts +1 -1
  407. package/src/cli/commands/progress.ts +11 -6
  408. package/src/cli/commands/req-headless.test.ts +170 -0
  409. package/src/cli/commands/req-spawn.test.ts +12 -2
  410. package/src/cli/commands/req.test.ts +36 -0
  411. package/src/cli/commands/req.ts +24 -20
  412. package/src/cli/commands/resume.test.ts +1 -1
  413. package/src/cli/commands/resume.ts +7 -8
  414. package/src/cli/commands/status.test.ts +1 -1
  415. package/src/cli/commands/status.ts +52 -40
  416. package/src/cli/commands/stories.test.ts +4 -2
  417. package/src/cli/commands/stories.ts +11 -11
  418. package/src/cli/commands/teams.test.ts +2 -2
  419. package/src/cli/commands/teams.ts +11 -11
  420. package/src/cli/dashboard/index.test.ts +35 -34
  421. package/src/cli/dashboard/index.ts +34 -23
  422. package/src/cli/dashboard/panels/activity.ts +10 -4
  423. package/src/cli/dashboard/panels/agents.ts +8 -5
  424. package/src/cli/dashboard/panels/escalations.ts +4 -4
  425. package/src/cli/dashboard/panels/merge-queue.ts +4 -4
  426. package/src/cli/dashboard/panels/pipeline.ts +10 -4
  427. package/src/config/schema.ts +1 -0
  428. package/src/connectors/project-management/operations.ts +9 -10
  429. package/src/context-files/index.test.ts +1 -0
  430. package/src/db/client.ts +17 -0
  431. package/src/db/pg-migrations/001-full-schema.sql +209 -0
  432. package/src/db/postgres-provider.integration.test.ts +574 -0
  433. package/src/db/postgres-provider.test.ts +97 -0
  434. package/src/db/postgres-provider.ts +364 -0
  435. package/src/db/provider.test.ts +283 -0
  436. package/src/db/provider.ts +161 -0
  437. package/src/db/queries/agents.test.ts +114 -113
  438. package/src/db/queries/agents.ts +50 -36
  439. package/src/db/queries/escalations.test.ts +134 -133
  440. package/src/db/queries/escalations.ts +72 -57
  441. package/src/db/queries/heartbeat.test.ts +77 -78
  442. package/src/db/queries/heartbeat.ts +24 -46
  443. package/src/db/queries/integration-sync.ts +26 -26
  444. package/src/db/queries/logs.test.ts +151 -148
  445. package/src/db/queries/logs.ts +78 -53
  446. package/src/db/queries/messages.test.ts +48 -50
  447. package/src/db/queries/messages.ts +26 -18
  448. package/src/db/queries/pull-requests.test.ts +194 -199
  449. package/src/db/queries/pull-requests.ts +117 -88
  450. package/src/db/queries/requirements.test.ts +84 -83
  451. package/src/db/queries/requirements.ts +33 -28
  452. package/src/db/queries/stories.test.ts +173 -172
  453. package/src/db/queries/stories.ts +141 -110
  454. package/src/db/queries/teams.test.ts +37 -36
  455. package/src/db/queries/teams.ts +22 -14
  456. package/src/index.ts +8 -1
  457. package/src/integrations/jira/repair.test.ts +27 -26
  458. package/src/integrations/jira/stories.test.ts +15 -16
  459. package/src/integrations/jira/stories.ts +15 -15
  460. package/src/integrations/jira/sync.test.ts +68 -68
  461. package/src/integrations/jira/sync.ts +29 -39
  462. package/src/integrations/jira/transitions.ts +6 -6
  463. package/src/orchestrator/agent-selector.ts +9 -8
  464. package/src/orchestrator/dependency-resolver.ts +16 -7
  465. package/src/orchestrator/feature-branch.test.ts +85 -80
  466. package/src/orchestrator/feature-branch.ts +13 -14
  467. package/src/orchestrator/orphan-recovery.ts +14 -13
  468. package/src/orchestrator/scheduler.test.ts +536 -394
  469. package/src/orchestrator/scheduler.ts +129 -115
  470. package/src/utils/auto-merge.test.ts +102 -68
  471. package/src/utils/auto-merge.ts +161 -168
  472. package/src/utils/cli-helpers.test.ts +30 -32
  473. package/src/utils/cli-helpers.ts +15 -11
  474. package/src/utils/paths.test.ts +1 -0
  475. package/src/utils/paths.ts +14 -1
  476. package/src/utils/pr-sync.test.ts +55 -52
  477. package/src/utils/pr-sync.ts +27 -32
  478. package/src/utils/with-hive-context.ts +89 -1
@@ -0,0 +1,170 @@
1
+ // Licensed under the Hungry Ghost Hive License. See LICENSE.
2
+
3
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
+
5
+ vi.mock('../../cli-runtimes/index.js', () => ({
6
+ getCliRuntimeBuilder: vi.fn(() => ({
7
+ buildSpawnCommand: vi.fn(() => ['claude', '--dangerously-skip-permissions']),
8
+ })),
9
+ resolveRuntimeModelForCli: vi.fn(model => model),
10
+ }));
11
+
12
+ vi.mock('../../cluster/runtime.js', () => ({
13
+ fetchLocalClusterStatus: vi.fn(() => null),
14
+ }));
15
+
16
+ vi.mock('../../config/loader.js', () => ({
17
+ loadConfig: vi.fn(() => ({
18
+ models: {
19
+ tech_lead: {
20
+ cli_tool: 'claude',
21
+ safety_mode: 'bypassPermissions',
22
+ model: 'claude-sonnet-4-6',
23
+ },
24
+ },
25
+ integrations: {
26
+ project_management: { provider: 'none' },
27
+ },
28
+ agents: { chrome_enabled: false },
29
+ cluster: { enabled: false },
30
+ })),
31
+ }));
32
+
33
+ vi.mock('../../connectors/registry.js', () => ({
34
+ registry: {
35
+ getProjectManagement: vi.fn(() => null),
36
+ },
37
+ }));
38
+
39
+ vi.mock('../../db/client.js', () => ({
40
+ withTransaction: vi.fn(async (_db: unknown, fn: () => unknown) => fn()),
41
+ }));
42
+
43
+ vi.mock('../../db/queries/agents.js', () => ({
44
+ createAgent: vi.fn(() => ({ id: 'agent-1' })),
45
+ getTechLead: vi.fn(() => ({ id: 'agent-1' })),
46
+ updateAgent: vi.fn(),
47
+ }));
48
+
49
+ vi.mock('../../db/queries/logs.js', () => ({
50
+ createLog: vi.fn(),
51
+ }));
52
+
53
+ vi.mock('../../db/queries/requirements.js', () => ({
54
+ createRequirement: vi.fn(() => ({ id: 'req-1', godmode: 0 })),
55
+ updateRequirement: vi.fn(),
56
+ }));
57
+
58
+ vi.mock('../../db/queries/teams.js', () => ({
59
+ getAllTeams: vi.fn(() => [{ id: 'team-1', name: 'alpha' }]),
60
+ }));
61
+
62
+ vi.mock('../../tmux/manager.js', () => ({
63
+ isTmuxAvailable: vi.fn(),
64
+ isTmuxSessionRunning: vi.fn(),
65
+ sendToTmuxSession: vi.fn(),
66
+ spawnTmuxSession: vi.fn(),
67
+ }));
68
+
69
+ vi.mock('../../utils/instance.js', () => ({
70
+ getTechLeadSessionName: vi.fn(() => 'hive-tech-lead'),
71
+ }));
72
+
73
+ vi.mock('../../utils/with-hive-context.js', () => ({
74
+ withHiveContext: vi.fn(
75
+ (
76
+ cb: (ctx: {
77
+ root: string;
78
+ paths: { hiveDir: string };
79
+ db: { db: object; provider: object };
80
+ }) => unknown
81
+ ) =>
82
+ cb({
83
+ root: '/tmp/hive',
84
+ paths: { hiveDir: '/tmp/hive/.hive' },
85
+ db: { db: {}, provider: { withTransaction: vi.fn(async (fn: () => unknown) => fn()) } },
86
+ })
87
+ ),
88
+ }));
89
+
90
+ vi.mock('../dashboard/index.js', () => ({
91
+ startDashboard: vi.fn(),
92
+ }));
93
+
94
+ vi.mock('ora', () => ({
95
+ default: vi.fn(() => ({
96
+ start: vi.fn().mockReturnThis(),
97
+ succeed: vi.fn().mockReturnThis(),
98
+ fail: vi.fn().mockReturnThis(),
99
+ warn: vi.fn().mockReturnThis(),
100
+ text: '',
101
+ })),
102
+ }));
103
+
104
+ import * as tmuxManager from '../../tmux/manager.js';
105
+ import * as dashboard from '../dashboard/index.js';
106
+ import { reqCommand } from './req.js';
107
+
108
+ describe('req command - headless dashboard behavior', () => {
109
+ beforeEach(() => {
110
+ vi.clearAllMocks();
111
+ delete process.env.HIVE_HEADLESS;
112
+ // Reset Commander option state between tests so --headless from one test
113
+ // doesn't bleed into the next.
114
+ reqCommand.setOptionValue('headless', undefined);
115
+ vi.mocked(tmuxManager.isTmuxAvailable).mockResolvedValue(true);
116
+ vi.mocked(tmuxManager.isTmuxSessionRunning).mockResolvedValue(false);
117
+ });
118
+
119
+ afterEach(() => {
120
+ delete process.env.HIVE_HEADLESS;
121
+ });
122
+
123
+ it('calls startDashboard when --headless flag is not set', async () => {
124
+ await reqCommand.parseAsync(['node', 'req', 'Build a feature', '--target-branch', 'main'], {
125
+ from: 'user',
126
+ });
127
+
128
+ expect(dashboard.startDashboard).toHaveBeenCalledOnce();
129
+ });
130
+
131
+ it('does not call startDashboard when --headless flag is passed', async () => {
132
+ await reqCommand.parseAsync(
133
+ ['node', 'req', 'Build a feature', '--target-branch', 'main', '--headless'],
134
+ { from: 'user' }
135
+ );
136
+
137
+ expect(dashboard.startDashboard).not.toHaveBeenCalled();
138
+ });
139
+
140
+ it('does not call startDashboard when HIVE_HEADLESS=1 env var is set', async () => {
141
+ process.env.HIVE_HEADLESS = '1';
142
+
143
+ await reqCommand.parseAsync(['node', 'req', 'Build a feature', '--target-branch', 'main'], {
144
+ from: 'user',
145
+ });
146
+
147
+ expect(dashboard.startDashboard).not.toHaveBeenCalled();
148
+ });
149
+
150
+ it('calls startDashboard when HIVE_HEADLESS env var is absent', async () => {
151
+ delete process.env.HIVE_HEADLESS;
152
+
153
+ await reqCommand.parseAsync(['node', 'req', 'Build a feature', '--target-branch', 'main'], {
154
+ from: 'user',
155
+ });
156
+
157
+ expect(dashboard.startDashboard).toHaveBeenCalledOnce();
158
+ });
159
+
160
+ it('does not call startDashboard when HIVE_HEADLESS is set to non-1 value', async () => {
161
+ process.env.HIVE_HEADLESS = '0';
162
+
163
+ await reqCommand.parseAsync(['node', 'req', 'Build a feature', '--target-branch', 'main'], {
164
+ from: 'user',
165
+ });
166
+
167
+ // HIVE_HEADLESS=0 is falsy for the === '1' check, so dashboard should launch
168
+ expect(dashboard.startDashboard).toHaveBeenCalledOnce();
169
+ });
170
+ });
@@ -75,8 +75,18 @@ vi.mock('../../utils/instance.js', () => ({
75
75
 
76
76
  vi.mock('../../utils/with-hive-context.js', () => ({
77
77
  withHiveContext: vi.fn(
78
- (cb: (ctx: { root: string; paths: { hiveDir: string }; db: { db: object } }) => unknown) =>
79
- cb({ root: '/tmp/hive', paths: { hiveDir: '/tmp/hive/.hive' }, db: { db: {} } })
78
+ (
79
+ cb: (ctx: {
80
+ root: string;
81
+ paths: { hiveDir: string };
82
+ db: { db: object; provider: object };
83
+ }) => unknown
84
+ ) =>
85
+ cb({
86
+ root: '/tmp/hive',
87
+ paths: { hiveDir: '/tmp/hive/.hive' },
88
+ db: { db: {}, provider: { withTransaction: vi.fn(async (fn: () => unknown) => fn()) } },
89
+ })
80
90
  ),
81
91
  }));
82
92
 
@@ -131,3 +131,39 @@ describe('req command - URL validation', () => {
131
131
  expect(connector).toBeNull();
132
132
  });
133
133
  });
134
+
135
+ describe('req command - headless flag', () => {
136
+ afterEach(() => {
137
+ delete process.env.HIVE_HEADLESS;
138
+ vi.restoreAllMocks();
139
+ });
140
+
141
+ it('should set HIVE_HEADLESS env var when headless option is true', () => {
142
+ // Simulate what req command does when --headless is passed
143
+ const options = { headless: true };
144
+ if (options.headless) {
145
+ process.env.HIVE_HEADLESS = '1';
146
+ }
147
+ expect(process.env.HIVE_HEADLESS).toBe('1');
148
+ });
149
+
150
+ it('should not set HIVE_HEADLESS env var when headless option is false', () => {
151
+ const options = { headless: false };
152
+ if (options.headless) {
153
+ process.env.HIVE_HEADLESS = '1';
154
+ }
155
+ expect(process.env.HIVE_HEADLESS).toBeUndefined();
156
+ });
157
+
158
+ it('should skip dashboard when HIVE_HEADLESS env var is set', () => {
159
+ process.env.HIVE_HEADLESS = '1';
160
+ const headless = process.env.HIVE_HEADLESS === '1';
161
+ expect(headless).toBe(true);
162
+ });
163
+
164
+ it('should launch dashboard when HIVE_HEADLESS env var is not set', () => {
165
+ delete process.env.HIVE_HEADLESS;
166
+ const headless = process.env.HIVE_HEADLESS === '1';
167
+ expect(headless).toBe(false);
168
+ });
169
+ });
@@ -9,7 +9,6 @@ import { getCliRuntimeBuilder, resolveRuntimeModelForCli } from '../../cli-runti
9
9
  import { fetchLocalClusterStatus } from '../../cluster/runtime.js';
10
10
  import { loadConfig } from '../../config/loader.js';
11
11
  import { registry } from '../../connectors/registry.js';
12
- import { withTransaction } from '../../db/client.js';
13
12
  import { createAgent, getTechLead, updateAgent } from '../../db/queries/agents.js';
14
13
  import { createLog } from '../../db/queries/logs.js';
15
14
  import { createRequirement, updateRequirement } from '../../db/queries/requirements.js';
@@ -32,6 +31,7 @@ export const reqCommand = new Command('req')
32
31
  .option('--dry-run', 'Create requirement without spawning agents')
33
32
  .option('--godmode', 'Enable godmode - use most powerful models for all agents')
34
33
  .option('--target-branch <branch>', 'Target branch for PRs (skips interactive prompt)')
34
+ .option('--headless', 'Skip TUI dashboard auto-launch after submitting requirement')
35
35
  .action(
36
36
  async (
37
37
  requirement: string | undefined,
@@ -41,6 +41,7 @@ export const reqCommand = new Command('req')
41
41
  dryRun?: boolean;
42
42
  godmode?: boolean;
43
43
  targetBranch?: string;
44
+ headless?: boolean;
44
45
  }
45
46
  ) => {
46
47
  await withHiveContext(async ({ root, paths, db }) => {
@@ -141,7 +142,7 @@ export const reqCommand = new Command('req')
141
142
 
142
143
  try {
143
144
  // Check if there are any teams
144
- const teams = getAllTeams(db.db);
145
+ const teams = await getAllTeams(db.provider);
145
146
  if (teams.length === 0) {
146
147
  spinner.fail(chalk.red('No teams found. Add a repository first:'));
147
148
  console.log(chalk.gray(' hive add-repo --url <repo-url> --team <team-name>'));
@@ -150,7 +151,7 @@ export const reqCommand = new Command('req')
150
151
 
151
152
  // Create requirement
152
153
  spinner.text = 'Creating requirement...';
153
- const req = createRequirement(db.db, {
154
+ const req = await createRequirement(db.provider, {
154
155
  title,
155
156
  description,
156
157
  godmode: options.godmode,
@@ -159,7 +160,7 @@ export const reqCommand = new Command('req')
159
160
 
160
161
  // If this came from a PM provider epic URL, store the epic key/id
161
162
  if (epicKey && epicId) {
162
- updateRequirement(db.db, req.id, {
163
+ await updateRequirement(db.provider, req.id, {
163
164
  jiraEpicKey: epicKey,
164
165
  jiraEpicId: epicId,
165
166
  });
@@ -188,7 +189,7 @@ export const reqCommand = new Command('req')
188
189
 
189
190
  // Get or create Tech Lead agent
190
191
  spinner.text = 'Spawning Tech Lead...';
191
- let techLead = getTechLead(db.db);
192
+ let techLead = await getTechLead(db.provider);
192
193
  const techLeadCliTool = config.models.tech_lead.cli_tool;
193
194
  const techLeadSafetyMode = config.models.tech_lead.safety_mode;
194
195
  const techLeadModel = resolveRuntimeModelForCli(
@@ -197,21 +198,21 @@ export const reqCommand = new Command('req')
197
198
  );
198
199
 
199
200
  if (!techLead) {
200
- techLead = createAgent(db.db, { type: 'tech_lead', model: techLeadModel });
201
+ techLead = await createAgent(db.provider, { type: 'tech_lead', model: techLeadModel });
201
202
  }
202
203
 
203
204
  // Update Tech Lead status and log event (atomic transaction)
204
- await withTransaction(db.db, () => {
205
- updateAgent(db.db, techLead.id, { status: 'working' });
205
+ await db.provider.withTransaction(async () => {
206
+ await updateAgent(db.provider, techLead.id, { status: 'working' });
206
207
 
207
- createLog(db.db, {
208
+ await createLog(db.provider, {
208
209
  agentId: techLead.id,
209
210
  eventType: 'REQUIREMENT_RECEIVED',
210
211
  message: title,
211
212
  metadata: { requirement_id: req.id, godmode: req.godmode ? true : false },
212
213
  });
213
214
 
214
- updateRequirement(db.db, req.id, { status: 'planning' });
215
+ await updateRequirement(db.provider, req.id, { status: 'planning' });
215
216
  });
216
217
 
217
218
  // Spawn Tech Lead tmux session
@@ -255,17 +256,17 @@ export const reqCommand = new Command('req')
255
256
  }
256
257
 
257
258
  // Update agent and log spawning/planning events (atomic transaction)
258
- await withTransaction(db.db, () => {
259
- updateAgent(db.db, techLead.id, { tmuxSession: sessionName });
259
+ await db.provider.withTransaction(async () => {
260
+ await updateAgent(db.provider, techLead.id, { tmuxSession: sessionName });
260
261
 
261
- createLog(db.db, {
262
+ await createLog(db.provider, {
262
263
  agentId: techLead.id,
263
264
  eventType: 'AGENT_SPAWNED',
264
265
  message: `Tech Lead spawned for requirement ${req.id}`,
265
266
  metadata: { tmux_session: sessionName },
266
267
  });
267
268
 
268
- createLog(db.db, {
269
+ await createLog(db.provider, {
269
270
  agentId: techLead.id,
270
271
  eventType: 'PLANNING_STARTED',
271
272
  message: `Planning started for requirement ${req.id}`,
@@ -284,12 +285,15 @@ export const reqCommand = new Command('req')
284
285
  console.log(chalk.cyan(` tmux attach -t ${sessionName}`));
285
286
  console.log();
286
287
 
287
- // Launch dashboard
288
- try {
289
- await startDashboard();
290
- } catch (dashboardErr) {
291
- console.warn(chalk.yellow('⚠️ Failed to start dashboard'));
292
- console.error(dashboardErr);
288
+ // Launch dashboard (skip if --headless flag or HIVE_HEADLESS env var is set)
289
+ const headless = options.headless || process.env.HIVE_HEADLESS === '1';
290
+ if (!headless) {
291
+ try {
292
+ await startDashboard();
293
+ } catch (dashboardErr) {
294
+ console.warn(chalk.yellow('⚠️ Failed to start dashboard'));
295
+ console.error(dashboardErr);
296
+ }
293
297
  }
294
298
  } catch (tmuxErr) {
295
299
  spinner.warn(chalk.yellow('Requirement created but failed to spawn Tech Lead'));
@@ -49,7 +49,7 @@ vi.mock('../../tmux/manager.js', () => ({
49
49
 
50
50
  vi.mock('../../utils/with-hive-context.js', () => ({
51
51
  withHiveContext: vi.fn(callback =>
52
- callback({ db: { db: {} }, root: '/tmp', paths: { hiveDir: '/tmp/.hive' } })
52
+ callback({ db: { db: {}, provider: {} }, root: '/tmp', paths: { hiveDir: '/tmp/.hive' } })
53
53
  ),
54
54
  }));
55
55
 
@@ -9,7 +9,6 @@ import {
9
9
  selectCompatibleModelForCli,
10
10
  } from '../../cli-runtimes/index.js';
11
11
  import { loadConfig } from '../../config/index.js';
12
- import { withTransaction } from '../../db/client.js';
13
12
  import { getAllAgents, updateAgent, type AgentRow } from '../../db/queries/agents.js';
14
13
  import { createLog } from '../../db/queries/logs.js';
15
14
  import { getTeamById } from '../../db/queries/teams.js';
@@ -35,17 +34,17 @@ export const resumeCommand = new Command('resume')
35
34
  let agentsToResume: AgentRow[];
36
35
 
37
36
  if (options.agent) {
38
- const agent = requireAgent(db.db, options.agent);
37
+ const agent = await requireAgent(db.provider, options.agent);
39
38
  if (agent.status === 'terminated') {
40
39
  console.error(chalk.red('Cannot resume a terminated agent'));
41
40
  process.exit(1);
42
41
  }
43
42
  agentsToResume = [agent];
44
43
  } else if (options.all) {
45
- agentsToResume = getAllAgents(db.db).filter(a => a.status !== 'terminated');
44
+ agentsToResume = (await getAllAgents(db.provider)).filter(a => a.status !== 'terminated');
46
45
  } else {
47
46
  // Default: resume blocked or idle agents that have memory state
48
- agentsToResume = getAllAgents(db.db).filter(
47
+ agentsToResume = (await getAllAgents(db.provider)).filter(
49
48
  a => a.status !== 'terminated' && a.memory_state
50
49
  );
51
50
  }
@@ -73,7 +72,7 @@ export const resumeCommand = new Command('resume')
73
72
  // Determine work directory
74
73
  let workDir = root;
75
74
  if (agent.team_id) {
76
- const team = getTeamById(db.db, agent.team_id);
75
+ const team = await getTeamById(db.provider, agent.team_id);
77
76
  if (team) {
78
77
  workDir = `${root}/${team.repo_path}`;
79
78
  }
@@ -105,13 +104,13 @@ export const resumeCommand = new Command('resume')
105
104
  });
106
105
 
107
106
  // Update agent state and log event (atomic transaction)
108
- await withTransaction(db.db, () => {
109
- updateAgent(db.db, agent.id, {
107
+ await db.provider.withTransaction(async () => {
108
+ await updateAgent(db.provider, agent.id, {
110
109
  status: 'working',
111
110
  tmuxSession: sessionName,
112
111
  });
113
112
 
114
- createLog(db.db, {
113
+ await createLog(db.provider, {
115
114
  agentId: agent.id,
116
115
  storyId: agent.current_story_id,
117
116
  eventType: 'AGENT_RESUMED',
@@ -36,7 +36,7 @@ vi.mock('../../db/queries/teams.js', () => ({
36
36
  }));
37
37
 
38
38
  vi.mock('../../utils/with-hive-context.js', () => ({
39
- withReadOnlyHiveContext: vi.fn(callback => callback({ db: { db: {} } })),
39
+ withReadOnlyHiveContext: vi.fn(callback => callback({ db: { db: {}, provider: {} } })),
40
40
  }));
41
41
 
42
42
  import { statusCommand } from './status.js';
@@ -2,6 +2,7 @@
2
2
 
3
3
  import chalk from 'chalk';
4
4
  import { Command } from 'commander';
5
+ import type { DatabaseProvider } from '../../db/provider.js';
5
6
  import { getActiveAgents, getAllAgents } from '../../db/queries/agents.js';
6
7
  import { getPendingEscalations, getPendingHumanEscalations } from '../../db/queries/escalations.js';
7
8
  import { getLogsByStory, getRecentLogs } from '../../db/queries/logs.js';
@@ -23,26 +24,26 @@ export const statusCommand = new Command('status')
23
24
  .option('--story <id>', 'Show status for a specific story')
24
25
  .option('--json', 'Output as JSON')
25
26
  .action(async (options: { team?: string; story?: string; json?: boolean }) => {
26
- await withReadOnlyHiveContext(({ db }) => {
27
+ await withReadOnlyHiveContext(async ({ db }) => {
27
28
  if (options.story) {
28
- showStoryStatus(db.db, options.story, options.json);
29
+ await showStoryStatus(db.provider, options.story, options.json);
29
30
  } else if (options.team) {
30
- showTeamStatus(db.db, options.team, options.json);
31
+ await showTeamStatus(db.provider, options.team, options.json);
31
32
  } else {
32
- showOverallStatus(db.db, options.json);
33
+ await showOverallStatus(db.provider, options.json);
33
34
  }
34
35
  });
35
36
  });
36
37
 
37
- function showOverallStatus(db: import('sql.js').Database, json?: boolean): void {
38
- const teams = getAllTeams(db);
39
- const allAgents = getAllAgents(db);
40
- const activeAgents = getActiveAgents(db);
41
- const storyCounts = getStoryCounts(db);
42
- const requirements = getPendingRequirements(db);
43
- const escalations = getPendingEscalations(db);
44
- const approvals = getPendingHumanEscalations(db);
45
- const recentLogs = getRecentLogs(db, 5);
38
+ async function showOverallStatus(db: DatabaseProvider, json?: boolean): Promise<void> {
39
+ const teams = await getAllTeams(db);
40
+ const allAgents = await getAllAgents(db);
41
+ const activeAgents = await getActiveAgents(db);
42
+ const storyCounts = await getStoryCounts(db);
43
+ const requirements = await getPendingRequirements(db);
44
+ const escalations = await getPendingEscalations(db);
45
+ const approvals = await getPendingHumanEscalations(db);
46
+ const recentLogs = await getRecentLogs(db, 5);
46
47
 
47
48
  const terminatedAgents = allAgents.filter(a => a.status === 'terminated').length;
48
49
 
@@ -153,21 +154,44 @@ function showOverallStatus(db: import('sql.js').Database, json?: boolean): void
153
154
  }
154
155
  }
155
156
 
156
- function showTeamStatus(db: import('sql.js').Database, teamName: string, json?: boolean): void {
157
- const team = getTeamByName(db, teamName);
157
+ async function showTeamStatus(
158
+ db: DatabaseProvider,
159
+ teamName: string,
160
+ json?: boolean
161
+ ): Promise<void> {
162
+ const team = await getTeamByName(db, teamName);
158
163
  if (!team) {
159
164
  console.error(chalk.red(`Team not found: ${teamName}`));
160
165
  process.exit(1);
161
166
  }
162
167
 
163
- const stories = getStoriesByTeam(db, team.id);
164
- const activeAgents = getActiveAgents(db).filter(a => a.team_id === team.id);
168
+ const stories = await getStoriesByTeam(db, team.id);
169
+ const activeAgents = (await getActiveAgents(db)).filter(a => a.team_id === team.id);
165
170
 
166
171
  const storyCounts: Record<string, number> = {};
167
172
  for (const story of stories) {
168
173
  storyCounts[story.status] = (storyCounts[story.status] || 0) + 1;
169
174
  }
170
175
 
176
+ const agentDetails = [];
177
+ for (const a of activeAgents) {
178
+ let godmode = false;
179
+ if (a.current_story_id) {
180
+ const story = await getStoryById(db, a.current_story_id);
181
+ if (story && story.requirement_id) {
182
+ const requirement = await getRequirementById(db, story.requirement_id);
183
+ godmode = requirement?.godmode ? true : false;
184
+ }
185
+ }
186
+ agentDetails.push({
187
+ id: a.id,
188
+ type: a.type,
189
+ status: a.status,
190
+ currentStory: a.current_story_id,
191
+ godmode,
192
+ });
193
+ }
194
+
171
195
  const status = {
172
196
  team: {
173
197
  id: team.id,
@@ -175,23 +199,7 @@ function showTeamStatus(db: import('sql.js').Database, teamName: string, json?:
175
199
  repo_url: team.repo_url,
176
200
  repo_path: team.repo_path,
177
201
  },
178
- agents: activeAgents.map(a => {
179
- let godmode = false;
180
- if (a.current_story_id) {
181
- const story = getStoryById(db, a.current_story_id);
182
- if (story && story.requirement_id) {
183
- const requirement = getRequirementById(db, story.requirement_id);
184
- godmode = requirement?.godmode ? true : false;
185
- }
186
- }
187
- return {
188
- id: a.id,
189
- type: a.type,
190
- status: a.status,
191
- currentStory: a.current_story_id,
192
- godmode,
193
- };
194
- }),
202
+ agents: agentDetails,
195
203
  stories: {
196
204
  total: stories.length,
197
205
  counts: storyCounts,
@@ -215,9 +223,9 @@ function showTeamStatus(db: import('sql.js').Database, teamName: string, json?:
215
223
  for (const agent of activeAgents) {
216
224
  let opusIndicator = '';
217
225
  if (agent.current_story_id) {
218
- const story = getStoryById(db, agent.current_story_id);
226
+ const story = await getStoryById(db, agent.current_story_id);
219
227
  if (story && story.requirement_id) {
220
- const requirement = getRequirementById(db, story.requirement_id);
228
+ const requirement = await getRequirementById(db, story.requirement_id);
221
229
  if (requirement?.godmode) {
222
230
  opusIndicator = chalk.yellow(' [Opus]');
223
231
  }
@@ -237,11 +245,15 @@ function showTeamStatus(db: import('sql.js').Database, teamName: string, json?:
237
245
  }
238
246
  }
239
247
 
240
- function showStoryStatus(db: import('sql.js').Database, storyId: string, json?: boolean): void {
241
- const story = requireStory(db, storyId);
248
+ async function showStoryStatus(
249
+ db: DatabaseProvider,
250
+ storyId: string,
251
+ json?: boolean
252
+ ): Promise<void> {
253
+ const story = await requireStory(db, storyId);
242
254
 
243
- const dependencies = getStoryDependencies(db, story.id);
244
- const logs = getLogsByStory(db, story.id).slice(0, 10);
255
+ const dependencies = await getStoryDependencies(db, story.id);
256
+ const logs = (await getLogsByStory(db, story.id)).slice(0, 10);
245
257
 
246
258
  const status = {
247
259
  story: {
@@ -34,8 +34,10 @@ vi.mock('../../integrations/jira/stories.js', () => ({
34
34
  }));
35
35
 
36
36
  vi.mock('../../utils/with-hive-context.js', () => ({
37
- withHiveContext: vi.fn(callback => callback({ db: { db: {} }, paths: { hiveDir: '/tmp' } })),
38
- withReadOnlyHiveContext: vi.fn(callback => callback({ db: { db: {} } })),
37
+ withHiveContext: vi.fn(callback =>
38
+ callback({ db: { db: {}, provider: {} }, paths: { hiveDir: '/tmp' } })
39
+ ),
40
+ withReadOnlyHiveContext: vi.fn(callback => callback({ db: { db: {}, provider: {} } })),
39
41
  }));
40
42
 
41
43
  import { storiesCommand } from './stories.js';
@@ -27,9 +27,9 @@ storiesCommand
27
27
  await withReadOnlyHiveContext(async ({ db }) => {
28
28
  let stories;
29
29
  if (options.status) {
30
- stories = getStoriesByStatus(db.db, options.status as StoryStatus);
30
+ stories = await getStoriesByStatus(db.provider, options.status as StoryStatus);
31
31
  } else {
32
- stories = getAllStories(db.db);
32
+ stories = await getAllStories(db.provider);
33
33
  }
34
34
 
35
35
  if (options.json) {
@@ -89,8 +89,8 @@ storiesCommand
89
89
  }) => {
90
90
  await withHiveContext(async ({ root, paths, db }) => {
91
91
  // Create local story
92
- const story = createStory(
93
- db.db,
92
+ const story = await createStory(
93
+ db.provider,
94
94
  {
95
95
  requirementId: options.requirement || null,
96
96
  teamId: options.team || null,
@@ -103,8 +103,8 @@ storiesCommand
103
103
 
104
104
  // Update with optional fields
105
105
  if (options.points !== undefined || options.complexity !== undefined) {
106
- updateStory(
107
- db.db,
106
+ await updateStory(
107
+ db.provider,
108
108
  story.id,
109
109
  {
110
110
  storyPoints: options.points ?? null,
@@ -118,8 +118,8 @@ storiesCommand
118
118
  // Sync to PM provider if configured
119
119
  let externalKey: string | null = null;
120
120
  try {
121
- const updatedStory = getStoryById(db.db, story.id)!;
122
- const result = await syncStoryToProvider(root, db.db, updatedStory);
121
+ const updatedStory = (await getStoryById(db.provider, story.id))!;
122
+ const result = await syncStoryToProvider(root, db.provider, updatedStory);
123
123
 
124
124
  if (result) {
125
125
  externalKey = result.key;
@@ -134,7 +134,7 @@ storiesCommand
134
134
  }
135
135
 
136
136
  if (options.json) {
137
- const finalStory = getStoryById(db.db, story.id);
137
+ const finalStory = await getStoryById(db.provider, story.id);
138
138
  console.log(JSON.stringify(finalStory, null, 2));
139
139
  return;
140
140
  }
@@ -154,9 +154,9 @@ storiesCommand
154
154
  .description('Show story details')
155
155
  .action(async (storyId: string) => {
156
156
  await withReadOnlyHiveContext(async ({ db }) => {
157
- const story = requireStory(db.db, storyId);
157
+ const story = await requireStory(db.provider, storyId);
158
158
 
159
- const dependencies = getStoryDependencies(db.db, story.id);
159
+ const dependencies = await getStoryDependencies(db.provider, story.id);
160
160
 
161
161
  console.log(chalk.bold(`\nStory: ${story.id}\n`));
162
162
  console.log(chalk.bold('Title:'), story.title);