hungry-ghost-hive 0.48.0 → 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 (472) 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 +13 -14
  146. package/dist/cli/commands/req.js.map +1 -1
  147. package/dist/cli/commands/resume.d.ts.map +1 -1
  148. package/dist/cli/commands/resume.js +7 -8
  149. package/dist/cli/commands/resume.js.map +1 -1
  150. package/dist/cli/commands/resume.test.js +1 -1
  151. package/dist/cli/commands/resume.test.js.map +1 -1
  152. package/dist/cli/commands/status.d.ts.map +1 -1
  153. package/dist/cli/commands/status.js +42 -40
  154. package/dist/cli/commands/status.js.map +1 -1
  155. package/dist/cli/commands/status.test.js +1 -1
  156. package/dist/cli/commands/status.test.js.map +1 -1
  157. package/dist/cli/commands/stories.js +9 -9
  158. package/dist/cli/commands/stories.js.map +1 -1
  159. package/dist/cli/commands/stories.test.js +2 -2
  160. package/dist/cli/commands/stories.test.js.map +1 -1
  161. package/dist/cli/commands/teams.js +11 -11
  162. package/dist/cli/commands/teams.js.map +1 -1
  163. package/dist/cli/commands/teams.test.js +2 -2
  164. package/dist/cli/commands/teams.test.js.map +1 -1
  165. package/dist/cli/dashboard/index.d.ts +2 -2
  166. package/dist/cli/dashboard/index.d.ts.map +1 -1
  167. package/dist/cli/dashboard/index.js +29 -20
  168. package/dist/cli/dashboard/index.js.map +1 -1
  169. package/dist/cli/dashboard/index.test.js +34 -32
  170. package/dist/cli/dashboard/index.test.js.map +1 -1
  171. package/dist/cli/dashboard/panels/activity.d.ts +3 -3
  172. package/dist/cli/dashboard/panels/activity.d.ts.map +1 -1
  173. package/dist/cli/dashboard/panels/activity.js +1 -1
  174. package/dist/cli/dashboard/panels/activity.js.map +1 -1
  175. package/dist/cli/dashboard/panels/agents.d.ts +3 -3
  176. package/dist/cli/dashboard/panels/agents.d.ts.map +1 -1
  177. package/dist/cli/dashboard/panels/agents.js +2 -2
  178. package/dist/cli/dashboard/panels/agents.js.map +1 -1
  179. package/dist/cli/dashboard/panels/escalations.d.ts +3 -3
  180. package/dist/cli/dashboard/panels/escalations.d.ts.map +1 -1
  181. package/dist/cli/dashboard/panels/escalations.js +1 -1
  182. package/dist/cli/dashboard/panels/escalations.js.map +1 -1
  183. package/dist/cli/dashboard/panels/merge-queue.d.ts +3 -3
  184. package/dist/cli/dashboard/panels/merge-queue.d.ts.map +1 -1
  185. package/dist/cli/dashboard/panels/merge-queue.js +1 -1
  186. package/dist/cli/dashboard/panels/merge-queue.js.map +1 -1
  187. package/dist/cli/dashboard/panels/pipeline.d.ts +3 -3
  188. package/dist/cli/dashboard/panels/pipeline.d.ts.map +1 -1
  189. package/dist/cli/dashboard/panels/pipeline.js +1 -1
  190. package/dist/cli/dashboard/panels/pipeline.js.map +1 -1
  191. package/dist/config/schema.d.ts +85 -82
  192. package/dist/config/schema.d.ts.map +1 -1
  193. package/dist/config/schema.js +1 -0
  194. package/dist/config/schema.js.map +1 -1
  195. package/dist/connectors/project-management/operations.d.ts +7 -7
  196. package/dist/connectors/project-management/operations.d.ts.map +1 -1
  197. package/dist/connectors/project-management/operations.js +2 -3
  198. package/dist/connectors/project-management/operations.js.map +1 -1
  199. package/dist/context-files/index.test.js +1 -0
  200. package/dist/context-files/index.test.js.map +1 -1
  201. package/dist/db/client.d.ts +6 -0
  202. package/dist/db/client.d.ts.map +1 -1
  203. package/dist/db/client.js +7 -0
  204. package/dist/db/client.js.map +1 -1
  205. package/dist/db/postgres-provider.d.ts +43 -0
  206. package/dist/db/postgres-provider.d.ts.map +1 -0
  207. package/dist/db/postgres-provider.integration.test.d.ts +2 -0
  208. package/dist/db/postgres-provider.integration.test.d.ts.map +1 -0
  209. package/dist/db/postgres-provider.integration.test.js +399 -0
  210. package/dist/db/postgres-provider.integration.test.js.map +1 -0
  211. package/dist/db/postgres-provider.js +315 -0
  212. package/dist/db/postgres-provider.js.map +1 -0
  213. package/dist/db/postgres-provider.test.d.ts +2 -0
  214. package/dist/db/postgres-provider.test.d.ts.map +1 -0
  215. package/dist/db/postgres-provider.test.js +72 -0
  216. package/dist/db/postgres-provider.test.js.map +1 -0
  217. package/dist/db/provider.d.ts +59 -0
  218. package/dist/db/provider.d.ts.map +1 -0
  219. package/dist/db/provider.js +121 -0
  220. package/dist/db/provider.js.map +1 -0
  221. package/dist/db/provider.test.d.ts +2 -0
  222. package/dist/db/provider.test.d.ts.map +1 -0
  223. package/dist/db/provider.test.js +226 -0
  224. package/dist/db/provider.test.js.map +1 -0
  225. package/dist/db/queries/agents.d.ts +13 -13
  226. package/dist/db/queries/agents.d.ts.map +1 -1
  227. package/dist/db/queries/agents.js +27 -28
  228. package/dist/db/queries/agents.js.map +1 -1
  229. package/dist/db/queries/agents.test.js +113 -111
  230. package/dist/db/queries/agents.test.js.map +1 -1
  231. package/dist/db/queries/escalations.d.ts +16 -16
  232. package/dist/db/queries/escalations.d.ts.map +1 -1
  233. package/dist/db/queries/escalations.js +34 -35
  234. package/dist/db/queries/escalations.js.map +1 -1
  235. package/dist/db/queries/escalations.test.js +133 -131
  236. package/dist/db/queries/escalations.test.js.map +1 -1
  237. package/dist/db/queries/heartbeat.d.ts +5 -5
  238. package/dist/db/queries/heartbeat.d.ts.map +1 -1
  239. package/dist/db/queries/heartbeat.js +7 -23
  240. package/dist/db/queries/heartbeat.js.map +1 -1
  241. package/dist/db/queries/heartbeat.test.js +76 -76
  242. package/dist/db/queries/heartbeat.test.js.map +1 -1
  243. package/dist/db/queries/integration-sync.d.ts +7 -7
  244. package/dist/db/queries/integration-sync.d.ts.map +1 -1
  245. package/dist/db/queries/integration-sync.js +13 -14
  246. package/dist/db/queries/integration-sync.js.map +1 -1
  247. package/dist/db/queries/logs.d.ts +10 -10
  248. package/dist/db/queries/logs.d.ts.map +1 -1
  249. package/dist/db/queries/logs.js +44 -42
  250. package/dist/db/queries/logs.js.map +1 -1
  251. package/dist/db/queries/logs.test.js +149 -146
  252. package/dist/db/queries/logs.test.js.map +1 -1
  253. package/dist/db/queries/messages.d.ts +6 -6
  254. package/dist/db/queries/messages.d.ts.map +1 -1
  255. package/dist/db/queries/messages.js +12 -11
  256. package/dist/db/queries/messages.js.map +1 -1
  257. package/dist/db/queries/messages.test.js +47 -46
  258. package/dist/db/queries/messages.test.js.map +1 -1
  259. package/dist/db/queries/pull-requests.d.ts +18 -18
  260. package/dist/db/queries/pull-requests.d.ts.map +1 -1
  261. package/dist/db/queries/pull-requests.js +50 -48
  262. package/dist/db/queries/pull-requests.js.map +1 -1
  263. package/dist/db/queries/pull-requests.test.js +195 -198
  264. package/dist/db/queries/pull-requests.test.js.map +1 -1
  265. package/dist/db/queries/requirements.d.ts +8 -8
  266. package/dist/db/queries/requirements.d.ts.map +1 -1
  267. package/dist/db/queries/requirements.js +17 -18
  268. package/dist/db/queries/requirements.js.map +1 -1
  269. package/dist/db/queries/requirements.test.js +83 -81
  270. package/dist/db/queries/requirements.test.js.map +1 -1
  271. package/dist/db/queries/stories.d.ts +29 -29
  272. package/dist/db/queries/stories.d.ts.map +1 -1
  273. package/dist/db/queries/stories.js +58 -64
  274. package/dist/db/queries/stories.js.map +1 -1
  275. package/dist/db/queries/stories.test.js +172 -170
  276. package/dist/db/queries/stories.test.js.map +1 -1
  277. package/dist/db/queries/teams.d.ts +6 -6
  278. package/dist/db/queries/teams.d.ts.map +1 -1
  279. package/dist/db/queries/teams.js +11 -12
  280. package/dist/db/queries/teams.js.map +1 -1
  281. package/dist/db/queries/teams.test.js +36 -34
  282. package/dist/db/queries/teams.test.js.map +1 -1
  283. package/dist/integrations/jira/repair.test.js +26 -24
  284. package/dist/integrations/jira/repair.test.js.map +1 -1
  285. package/dist/integrations/jira/stories.d.ts +3 -3
  286. package/dist/integrations/jira/stories.d.ts.map +1 -1
  287. package/dist/integrations/jira/stories.js +12 -12
  288. package/dist/integrations/jira/stories.js.map +1 -1
  289. package/dist/integrations/jira/stories.test.js +10 -8
  290. package/dist/integrations/jira/stories.test.js.map +1 -1
  291. package/dist/integrations/jira/sync.d.ts +7 -7
  292. package/dist/integrations/jira/sync.d.ts.map +1 -1
  293. package/dist/integrations/jira/sync.js +17 -20
  294. package/dist/integrations/jira/sync.js.map +1 -1
  295. package/dist/integrations/jira/sync.test.js +63 -62
  296. package/dist/integrations/jira/sync.test.js.map +1 -1
  297. package/dist/integrations/jira/transitions.d.ts +3 -3
  298. package/dist/integrations/jira/transitions.d.ts.map +1 -1
  299. package/dist/integrations/jira/transitions.js +3 -3
  300. package/dist/integrations/jira/transitions.js.map +1 -1
  301. package/dist/orchestrator/agent-selector.d.ts +3 -3
  302. package/dist/orchestrator/agent-selector.d.ts.map +1 -1
  303. package/dist/orchestrator/agent-selector.js +5 -6
  304. package/dist/orchestrator/agent-selector.js.map +1 -1
  305. package/dist/orchestrator/dependency-resolver.d.ts +4 -4
  306. package/dist/orchestrator/dependency-resolver.d.ts.map +1 -1
  307. package/dist/orchestrator/dependency-resolver.js +6 -6
  308. package/dist/orchestrator/dependency-resolver.js.map +1 -1
  309. package/dist/orchestrator/feature-branch.d.ts +3 -3
  310. package/dist/orchestrator/feature-branch.d.ts.map +1 -1
  311. package/dist/orchestrator/feature-branch.js +9 -10
  312. package/dist/orchestrator/feature-branch.js.map +1 -1
  313. package/dist/orchestrator/feature-branch.test.js +80 -78
  314. package/dist/orchestrator/feature-branch.test.js.map +1 -1
  315. package/dist/orchestrator/orphan-recovery.d.ts +2 -2
  316. package/dist/orchestrator/orphan-recovery.d.ts.map +1 -1
  317. package/dist/orchestrator/orphan-recovery.js +10 -10
  318. package/dist/orchestrator/orphan-recovery.js.map +1 -1
  319. package/dist/orchestrator/scheduler.d.ts +4 -4
  320. package/dist/orchestrator/scheduler.d.ts.map +1 -1
  321. package/dist/orchestrator/scheduler.js +90 -76
  322. package/dist/orchestrator/scheduler.js.map +1 -1
  323. package/dist/orchestrator/scheduler.test.js +496 -374
  324. package/dist/orchestrator/scheduler.test.js.map +1 -1
  325. package/dist/utils/auto-merge.d.ts.map +1 -1
  326. package/dist/utils/auto-merge.js +74 -56
  327. package/dist/utils/auto-merge.js.map +1 -1
  328. package/dist/utils/auto-merge.test.js +101 -66
  329. package/dist/utils/auto-merge.test.js.map +1 -1
  330. package/dist/utils/cli-helpers.d.ts +5 -5
  331. package/dist/utils/cli-helpers.d.ts.map +1 -1
  332. package/dist/utils/cli-helpers.js +8 -9
  333. package/dist/utils/cli-helpers.js.map +1 -1
  334. package/dist/utils/cli-helpers.test.js +28 -30
  335. package/dist/utils/cli-helpers.test.js.map +1 -1
  336. package/dist/utils/paths.d.ts +6 -0
  337. package/dist/utils/paths.d.ts.map +1 -1
  338. package/dist/utils/paths.js +12 -1
  339. package/dist/utils/paths.js.map +1 -1
  340. package/dist/utils/paths.test.js +1 -0
  341. package/dist/utils/paths.test.js.map +1 -1
  342. package/dist/utils/pr-sync.d.ts +10 -10
  343. package/dist/utils/pr-sync.d.ts.map +1 -1
  344. package/dist/utils/pr-sync.js +20 -21
  345. package/dist/utils/pr-sync.js.map +1 -1
  346. package/dist/utils/pr-sync.test.js +52 -50
  347. package/dist/utils/pr-sync.test.js.map +1 -1
  348. package/dist/utils/with-hive-context.d.ts.map +1 -1
  349. package/dist/utils/with-hive-context.js +70 -1
  350. package/dist/utils/with-hive-context.js.map +1 -1
  351. package/package.json +3 -1
  352. package/src/agents/base-agent.test.ts +2 -1
  353. package/src/agents/base-agent.ts +32 -28
  354. package/src/agents/intermediate.ts +27 -18
  355. package/src/agents/junior.ts +27 -18
  356. package/src/agents/qa.ts +54 -40
  357. package/src/agents/senior.ts +42 -27
  358. package/src/agents/tech-lead.ts +42 -32
  359. package/src/cli/commands/add-repo.test.ts +1 -1
  360. package/src/cli/commands/add-repo.ts +2 -2
  361. package/src/cli/commands/agents.test.ts +7 -7
  362. package/src/cli/commands/agents.ts +12 -10
  363. package/src/cli/commands/approach.ts +2 -2
  364. package/src/cli/commands/approvals.test.ts +8 -8
  365. package/src/cli/commands/approvals.ts +9 -7
  366. package/src/cli/commands/assign.test.ts +19 -18
  367. package/src/cli/commands/assign.ts +4 -4
  368. package/src/cli/commands/cleanup.test.ts +5 -1
  369. package/src/cli/commands/cleanup.ts +11 -9
  370. package/src/cli/commands/escalations.test.ts +2 -2
  371. package/src/cli/commands/escalations.ts +9 -7
  372. package/src/cli/commands/init.test.ts +5 -0
  373. package/src/cli/commands/init.ts +53 -5
  374. package/src/cli/commands/manager/agent-monitoring.ts +3 -3
  375. package/src/cli/commands/manager/auditor-lifecycle.test.ts +21 -14
  376. package/src/cli/commands/manager/auditor-lifecycle.ts +3 -3
  377. package/src/cli/commands/manager/auto-reject-comment-only-reviews.test.ts +28 -23
  378. package/src/cli/commands/manager/escalation-handler.test.ts +13 -13
  379. package/src/cli/commands/manager/escalation-handler.ts +19 -12
  380. package/src/cli/commands/manager/feature-sign-off.test.ts +40 -31
  381. package/src/cli/commands/manager/feature-sign-off.ts +7 -7
  382. package/src/cli/commands/manager/feature-test-result.ts +13 -16
  383. package/src/cli/commands/manager/handoff-recovery.ts +20 -20
  384. package/src/cli/commands/manager/index.test.ts +4 -4
  385. package/src/cli/commands/manager/index.ts +58 -59
  386. package/src/cli/commands/manager/merged-story-cleanup.test.ts +28 -19
  387. package/src/cli/commands/manager/merged-story-cleanup.ts +11 -14
  388. package/src/cli/commands/manager/pr-sync-orchestrator.ts +115 -110
  389. package/src/cli/commands/manager/qa-review-handler.ts +50 -63
  390. package/src/cli/commands/manager/spin-down.ts +27 -25
  391. package/src/cli/commands/manager/stale-escalations.ts +2 -3
  392. package/src/cli/commands/manager/stuck-story-helpers.ts +10 -10
  393. package/src/cli/commands/manager/stuck-story-processor.ts +56 -62
  394. package/src/cli/commands/manager/tech-lead-lifecycle.ts +6 -6
  395. package/src/cli/commands/manager/types.ts +2 -3
  396. package/src/cli/commands/msg.test.ts +2 -2
  397. package/src/cli/commands/my-stories.test.ts +4 -2
  398. package/src/cli/commands/my-stories.ts +22 -27
  399. package/src/cli/commands/nuke.test.ts +1 -1
  400. package/src/cli/commands/pr.test.ts +10 -6
  401. package/src/cli/commands/pr.ts +41 -32
  402. package/src/cli/commands/progress.test.ts +1 -1
  403. package/src/cli/commands/progress.ts +11 -6
  404. package/src/cli/commands/req-headless.test.ts +170 -0
  405. package/src/cli/commands/req-spawn.test.ts +12 -2
  406. package/src/cli/commands/req.ts +13 -14
  407. package/src/cli/commands/resume.test.ts +1 -1
  408. package/src/cli/commands/resume.ts +7 -8
  409. package/src/cli/commands/status.test.ts +1 -1
  410. package/src/cli/commands/status.ts +52 -40
  411. package/src/cli/commands/stories.test.ts +4 -2
  412. package/src/cli/commands/stories.ts +11 -11
  413. package/src/cli/commands/teams.test.ts +2 -2
  414. package/src/cli/commands/teams.ts +11 -11
  415. package/src/cli/dashboard/index.test.ts +35 -34
  416. package/src/cli/dashboard/index.ts +34 -23
  417. package/src/cli/dashboard/panels/activity.ts +10 -4
  418. package/src/cli/dashboard/panels/agents.ts +8 -5
  419. package/src/cli/dashboard/panels/escalations.ts +4 -4
  420. package/src/cli/dashboard/panels/merge-queue.ts +4 -4
  421. package/src/cli/dashboard/panels/pipeline.ts +10 -4
  422. package/src/config/schema.ts +1 -0
  423. package/src/connectors/project-management/operations.ts +9 -10
  424. package/src/context-files/index.test.ts +1 -0
  425. package/src/db/client.ts +17 -0
  426. package/src/db/pg-migrations/001-full-schema.sql +209 -0
  427. package/src/db/postgres-provider.integration.test.ts +574 -0
  428. package/src/db/postgres-provider.test.ts +97 -0
  429. package/src/db/postgres-provider.ts +364 -0
  430. package/src/db/provider.test.ts +283 -0
  431. package/src/db/provider.ts +161 -0
  432. package/src/db/queries/agents.test.ts +114 -113
  433. package/src/db/queries/agents.ts +50 -36
  434. package/src/db/queries/escalations.test.ts +134 -133
  435. package/src/db/queries/escalations.ts +72 -57
  436. package/src/db/queries/heartbeat.test.ts +77 -78
  437. package/src/db/queries/heartbeat.ts +24 -46
  438. package/src/db/queries/integration-sync.ts +26 -26
  439. package/src/db/queries/logs.test.ts +151 -148
  440. package/src/db/queries/logs.ts +78 -53
  441. package/src/db/queries/messages.test.ts +48 -50
  442. package/src/db/queries/messages.ts +26 -18
  443. package/src/db/queries/pull-requests.test.ts +194 -199
  444. package/src/db/queries/pull-requests.ts +117 -88
  445. package/src/db/queries/requirements.test.ts +84 -83
  446. package/src/db/queries/requirements.ts +33 -28
  447. package/src/db/queries/stories.test.ts +173 -172
  448. package/src/db/queries/stories.ts +141 -110
  449. package/src/db/queries/teams.test.ts +37 -36
  450. package/src/db/queries/teams.ts +22 -14
  451. package/src/integrations/jira/repair.test.ts +27 -26
  452. package/src/integrations/jira/stories.test.ts +15 -16
  453. package/src/integrations/jira/stories.ts +15 -15
  454. package/src/integrations/jira/sync.test.ts +68 -68
  455. package/src/integrations/jira/sync.ts +29 -39
  456. package/src/integrations/jira/transitions.ts +6 -6
  457. package/src/orchestrator/agent-selector.ts +9 -8
  458. package/src/orchestrator/dependency-resolver.ts +16 -7
  459. package/src/orchestrator/feature-branch.test.ts +85 -80
  460. package/src/orchestrator/feature-branch.ts +13 -14
  461. package/src/orchestrator/orphan-recovery.ts +14 -13
  462. package/src/orchestrator/scheduler.test.ts +536 -394
  463. package/src/orchestrator/scheduler.ts +129 -115
  464. package/src/utils/auto-merge.test.ts +102 -68
  465. package/src/utils/auto-merge.ts +161 -168
  466. package/src/utils/cli-helpers.test.ts +30 -32
  467. package/src/utils/cli-helpers.ts +15 -11
  468. package/src/utils/paths.test.ts +1 -0
  469. package/src/utils/paths.ts +14 -1
  470. package/src/utils/pr-sync.test.ts +55 -52
  471. package/src/utils/pr-sync.ts +27 -32
  472. package/src/utils/with-hive-context.ts +89 -1
@@ -1,10 +1,10 @@
1
1
  // Licensed under the Hungry Ghost Hive License. See LICENSE.
2
2
 
3
3
  import { nanoid } from 'nanoid';
4
- import type { Database } from 'sql.js';
5
4
  import { extractPRNumber } from '../../utils/github.js';
6
5
  import { normalizeStoryId } from '../../utils/story-id.js';
7
- import { queryAll, queryOne, run, type PullRequestRow, type StoryRow } from '../client.js';
6
+ import { type PullRequestRow, type StoryRow } from '../client.js';
7
+ import type { DatabaseProvider } from '../provider.js';
8
8
 
9
9
  export type { PullRequestRow };
10
10
 
@@ -33,7 +33,10 @@ export interface UpdatePullRequestInput {
33
33
  githubPrUrl?: string | null;
34
34
  }
35
35
 
36
- export function createPullRequest(db: Database, input: CreatePullRequestInput): PullRequestRow {
36
+ export async function createPullRequest(
37
+ provider: DatabaseProvider,
38
+ input: CreatePullRequestInput
39
+ ): Promise<PullRequestRow> {
37
40
  const id = `pr-${nanoid(8)}`;
38
41
  const now = new Date().toISOString();
39
42
 
@@ -43,8 +46,7 @@ export function createPullRequest(db: Database, input: CreatePullRequestInput):
43
46
  prNumber = extractPRNumber(input.githubPrUrl) || null;
44
47
  }
45
48
 
46
- run(
47
- db,
49
+ await provider.run(
48
50
  `
49
51
  INSERT INTO pull_requests (id, story_id, team_id, branch_name, github_pr_number, github_pr_url, submitted_by, status, created_at, updated_at)
50
52
  VALUES (?, ?, ?, ?, ?, ?, ?, 'queued', ?, ?)
@@ -62,32 +64,43 @@ export function createPullRequest(db: Database, input: CreatePullRequestInput):
62
64
  ]
63
65
  );
64
66
 
65
- return getPullRequestById(db, id)!;
67
+ return (await getPullRequestById(provider, id))!;
66
68
  }
67
69
 
68
- export function getPullRequestById(db: Database, id: string): PullRequestRow | undefined {
69
- return queryOne<PullRequestRow>(db, 'SELECT * FROM pull_requests WHERE id = ?', [id]);
70
+ export async function getPullRequestById(
71
+ provider: DatabaseProvider,
72
+ id: string
73
+ ): Promise<PullRequestRow | undefined> {
74
+ return await provider.queryOne<PullRequestRow>('SELECT * FROM pull_requests WHERE id = ?', [id]);
70
75
  }
71
76
 
72
- export function getPullRequestByStory(db: Database, storyId: string): PullRequestRow | undefined {
73
- return queryOne<PullRequestRow>(db, 'SELECT * FROM pull_requests WHERE story_id = ?', [storyId]);
77
+ export async function getPullRequestByStory(
78
+ provider: DatabaseProvider,
79
+ storyId: string
80
+ ): Promise<PullRequestRow | undefined> {
81
+ return await provider.queryOne<PullRequestRow>('SELECT * FROM pull_requests WHERE story_id = ?', [
82
+ storyId,
83
+ ]);
74
84
  }
75
85
 
76
- export function getPullRequestByGithubNumber(
77
- db: Database,
86
+ export async function getPullRequestByGithubNumber(
87
+ provider: DatabaseProvider,
78
88
  prNumber: number
79
- ): PullRequestRow | undefined {
80
- return queryOne<PullRequestRow>(db, 'SELECT * FROM pull_requests WHERE github_pr_number = ?', [
81
- prNumber,
82
- ]);
89
+ ): Promise<PullRequestRow | undefined> {
90
+ return await provider.queryOne<PullRequestRow>(
91
+ 'SELECT * FROM pull_requests WHERE github_pr_number = ?',
92
+ [prNumber]
93
+ );
83
94
  }
84
95
 
85
96
  // Merge Queue functions
86
97
 
87
- export function getMergeQueue(db: Database, teamId?: string): PullRequestRow[] {
98
+ export async function getMergeQueue(
99
+ provider: DatabaseProvider,
100
+ teamId?: string
101
+ ): Promise<PullRequestRow[]> {
88
102
  if (teamId) {
89
- return queryAll<PullRequestRow>(
90
- db,
103
+ return await provider.queryAll<PullRequestRow>(
91
104
  `
92
105
  SELECT * FROM pull_requests
93
106
  WHERE team_id = ? AND status IN ('queued', 'reviewing')
@@ -96,27 +109,27 @@ export function getMergeQueue(db: Database, teamId?: string): PullRequestRow[] {
96
109
  [teamId]
97
110
  );
98
111
  }
99
- return queryAll<PullRequestRow>(
100
- db,
101
- `
112
+ return await provider.queryAll<PullRequestRow>(`
102
113
  SELECT * FROM pull_requests
103
114
  WHERE status IN ('queued', 'reviewing')
104
115
  ORDER BY created_at ASC
105
- `
106
- );
116
+ `);
107
117
  }
108
118
 
109
- export function getNextInQueue(db: Database, teamId?: string): PullRequestRow | undefined {
119
+ export async function getNextInQueue(
120
+ provider: DatabaseProvider,
121
+ teamId?: string
122
+ ): Promise<PullRequestRow | undefined> {
110
123
  // Get the prioritized queue and return the first PR with status = 'queued'
111
- const queue = getPrioritizedMergeQueue(db, teamId);
124
+ const queue = await getPrioritizedMergeQueue(provider, teamId);
112
125
  return queue.find(pr => pr.status === 'queued');
113
126
  }
114
127
 
115
- export function getQueuePosition(db: Database, prId: string): number {
116
- const pr = getPullRequestById(db, prId);
128
+ export async function getQueuePosition(provider: DatabaseProvider, prId: string): Promise<number> {
129
+ const pr = await getPullRequestById(provider, prId);
117
130
  if (!pr || !['queued', 'reviewing'].includes(pr.status)) return -1;
118
131
 
119
- const queue = getPrioritizedMergeQueue(db, pr.team_id || undefined);
132
+ const queue = await getPrioritizedMergeQueue(provider, pr.team_id || undefined);
120
133
  return queue.findIndex(p => p.id === prId) + 1;
121
134
  }
122
135
 
@@ -124,9 +137,11 @@ export function getQueuePosition(db: Database, prId: string): number {
124
137
  * Check if a story's dependencies are satisfied (ready for QA review)
125
138
  * A dependency is satisfied if the story is merged or in active development
126
139
  */
127
- function areDependenciesSatisfied(db: Database, storyId: string): boolean {
128
- const dependencies = queryAll<StoryRow>(
129
- db,
140
+ async function areDependenciesSatisfied(
141
+ provider: DatabaseProvider,
142
+ storyId: string
143
+ ): Promise<boolean> {
144
+ const dependencies = await provider.queryAll<StoryRow>(
130
145
  `
131
146
  SELECT s.* FROM stories s
132
147
  JOIN story_dependencies sd ON s.id = sd.depends_on_story_id
@@ -149,29 +164,34 @@ function areDependenciesSatisfied(db: Database, storyId: string): boolean {
149
164
  }
150
165
 
151
166
  // Priority scoring for merge queue
152
- export function getPrioritizedMergeQueue(db: Database, teamId?: string): PullRequestRow[] {
153
- const baseQueue = getMergeQueue(db, teamId);
167
+ export async function getPrioritizedMergeQueue(
168
+ provider: DatabaseProvider,
169
+ teamId?: string
170
+ ): Promise<PullRequestRow[]> {
171
+ const baseQueue = await getMergeQueue(provider, teamId);
154
172
 
155
173
  // Score by dependency satisfaction first, then by age
156
- const scored = baseQueue.map(pr => {
157
- // Get the story for this PR to check dependencies
158
- let dependenciesSatisfied = true;
159
- if (pr.story_id) {
160
- dependenciesSatisfied = areDependenciesSatisfied(db, pr.story_id);
161
- }
162
-
163
- // Scoring: dependencies satisfied = higher priority (larger score)
164
- // Within each tier, older PRs get higher priority
165
- const dependencyScore = dependenciesSatisfied ? 1 : 0;
166
- const createdTime = new Date(pr.created_at).getTime();
167
- const ageScore = -createdTime;
168
-
169
- // Combined score: (dependencyScore * large_multiplier) + ageScore
170
- // This ensures dependency satisfaction is the primary sort key
171
- const score = dependencyScore * 1e15 + ageScore;
172
-
173
- return { pr, score, dependenciesSatisfied };
174
- });
174
+ const scored = await Promise.all(
175
+ baseQueue.map(async pr => {
176
+ // Get the story for this PR to check dependencies
177
+ let dependenciesSatisfied = true;
178
+ if (pr.story_id) {
179
+ dependenciesSatisfied = await areDependenciesSatisfied(provider, pr.story_id);
180
+ }
181
+
182
+ // Scoring: dependencies satisfied = higher priority (larger score)
183
+ // Within each tier, older PRs get higher priority
184
+ const dependencyScore = dependenciesSatisfied ? 1 : 0;
185
+ const createdTime = new Date(pr.created_at).getTime();
186
+ const ageScore = -createdTime;
187
+
188
+ // Combined score: (dependencyScore * large_multiplier) + ageScore
189
+ // This ensures dependency satisfaction is the primary sort key
190
+ const score = dependencyScore * 1e15 + ageScore;
191
+
192
+ return { pr, score, dependenciesSatisfied };
193
+ })
194
+ );
175
195
 
176
196
  // Sort by score (descending) = dependencies satisfied first, then older first
177
197
  scored.sort((a, b) => b.score - a.score);
@@ -179,9 +199,11 @@ export function getPrioritizedMergeQueue(db: Database, teamId?: string): PullReq
179
199
  return scored.map(item => item.pr);
180
200
  }
181
201
 
182
- export function getPullRequestsByStatus(db: Database, status: PullRequestStatus): PullRequestRow[] {
183
- return queryAll<PullRequestRow>(
184
- db,
202
+ export async function getPullRequestsByStatus(
203
+ provider: DatabaseProvider,
204
+ status: PullRequestStatus
205
+ ): Promise<PullRequestRow[]> {
206
+ return await provider.queryAll<PullRequestRow>(
185
207
  `
186
208
  SELECT * FROM pull_requests
187
209
  WHERE status = ?
@@ -191,20 +213,21 @@ export function getPullRequestsByStatus(db: Database, status: PullRequestStatus)
191
213
  );
192
214
  }
193
215
 
194
- export function getApprovedPullRequests(db: Database): PullRequestRow[] {
195
- return queryAll<PullRequestRow>(
196
- db,
197
- `
216
+ export async function getApprovedPullRequests(
217
+ provider: DatabaseProvider
218
+ ): Promise<PullRequestRow[]> {
219
+ return await provider.queryAll<PullRequestRow>(`
198
220
  SELECT * FROM pull_requests
199
221
  WHERE status = 'approved'
200
222
  ORDER BY created_at ASC
201
- `
202
- );
223
+ `);
203
224
  }
204
225
 
205
- export function getOpenPullRequestsByStory(db: Database, storyId: string): PullRequestRow[] {
206
- return queryAll<PullRequestRow>(
207
- db,
226
+ export async function getOpenPullRequestsByStory(
227
+ provider: DatabaseProvider,
228
+ storyId: string
229
+ ): Promise<PullRequestRow[]> {
230
+ return await provider.queryAll<PullRequestRow>(
208
231
  `
209
232
  SELECT * FROM pull_requests
210
233
  WHERE story_id = ? COLLATE NOCASE AND status IN ('queued', 'reviewing')
@@ -214,13 +237,17 @@ export function getOpenPullRequestsByStory(db: Database, storyId: string): PullR
214
237
  );
215
238
  }
216
239
 
217
- export function getAllPullRequests(db: Database): PullRequestRow[] {
218
- return queryAll<PullRequestRow>(db, 'SELECT * FROM pull_requests ORDER BY created_at DESC');
240
+ export async function getAllPullRequests(provider: DatabaseProvider): Promise<PullRequestRow[]> {
241
+ return await provider.queryAll<PullRequestRow>(
242
+ 'SELECT * FROM pull_requests ORDER BY created_at DESC'
243
+ );
219
244
  }
220
245
 
221
- export function getPullRequestsByTeam(db: Database, teamId: string): PullRequestRow[] {
222
- return queryAll<PullRequestRow>(
223
- db,
246
+ export async function getPullRequestsByTeam(
247
+ provider: DatabaseProvider,
248
+ teamId: string
249
+ ): Promise<PullRequestRow[]> {
250
+ return await provider.queryAll<PullRequestRow>(
224
251
  `
225
252
  SELECT * FROM pull_requests
226
253
  WHERE team_id = ?
@@ -230,11 +257,11 @@ export function getPullRequestsByTeam(db: Database, teamId: string): PullRequest
230
257
  );
231
258
  }
232
259
 
233
- export function updatePullRequest(
234
- db: Database,
260
+ export async function updatePullRequest(
261
+ provider: DatabaseProvider,
235
262
  id: string,
236
263
  input: UpdatePullRequestInput
237
- ): PullRequestRow | undefined {
264
+ ): Promise<PullRequestRow | undefined> {
238
265
  const updates: string[] = ['updated_at = ?'];
239
266
  const values: (string | number | null)[] = [new Date().toISOString()];
240
267
 
@@ -264,25 +291,27 @@ export function updatePullRequest(
264
291
  }
265
292
 
266
293
  if (updates.length === 1) {
267
- return getPullRequestById(db, id);
294
+ return await getPullRequestById(provider, id);
268
295
  }
269
296
 
270
297
  values.push(id);
271
- run(db, `UPDATE pull_requests SET ${updates.join(', ')} WHERE id = ?`, values);
272
- return getPullRequestById(db, id);
298
+ await provider.run(`UPDATE pull_requests SET ${updates.join(', ')} WHERE id = ?`, values);
299
+ return await getPullRequestById(provider, id);
273
300
  }
274
301
 
275
- export function deletePullRequest(db: Database, id: string): void {
276
- run(db, 'DELETE FROM pull_requests WHERE id = ?', [id]);
302
+ export async function deletePullRequest(provider: DatabaseProvider, id: string): Promise<void> {
303
+ await provider.run('DELETE FROM pull_requests WHERE id = ?', [id]);
277
304
  }
278
305
 
279
306
  /**
280
307
  * Check if an agent is actively reviewing a PR
281
308
  * Returns true if the agent has a PR with status 'reviewing'
282
309
  */
283
- export function isAgentReviewingPR(db: Database, agentId: string): boolean {
284
- const result = queryOne<{ count: number }>(
285
- db,
310
+ export async function isAgentReviewingPR(
311
+ provider: DatabaseProvider,
312
+ agentId: string
313
+ ): Promise<boolean> {
314
+ const result = await provider.queryOne<{ count: number }>(
286
315
  `
287
316
  SELECT COUNT(*) as count FROM pull_requests
288
317
  WHERE reviewed_by = ? AND status = 'reviewing'
@@ -297,20 +326,20 @@ export function isAgentReviewingPR(db: Database, agentId: string): boolean {
297
326
  * This is an idempotent operation - it only updates PRs with NULL github_pr_number
298
327
  * @returns Number of PRs updated
299
328
  */
300
- export function backfillGithubPrNumbers(db: Database): number {
301
- const prsToBackfill = queryAll<PullRequestRow>(
302
- db,
303
- `
329
+ export async function backfillGithubPrNumbers(provider: DatabaseProvider): Promise<number> {
330
+ const prsToBackfill = await provider.queryAll<PullRequestRow>(`
304
331
  SELECT * FROM pull_requests
305
332
  WHERE github_pr_number IS NULL AND github_pr_url IS NOT NULL
306
- `
307
- );
333
+ `);
308
334
 
309
335
  let updated = 0;
310
336
  for (const pr of prsToBackfill) {
311
337
  const prNumber = extractPRNumber(pr.github_pr_url!);
312
338
  if (prNumber) {
313
- run(db, 'UPDATE pull_requests SET github_pr_number = ? WHERE id = ?', [prNumber, pr.id]);
339
+ await provider.run('UPDATE pull_requests SET github_pr_number = ? WHERE id = ?', [
340
+ prNumber,
341
+ pr.id,
342
+ ]);
314
343
  updated++;
315
344
  }
316
345
  }