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,7 +1,7 @@
1
1
  // Licensed under the Hungry Ghost Hive License. See LICENSE.
2
2
 
3
- import type { Database } from 'sql.js';
4
3
  import { beforeEach, describe, expect, it } from 'vitest';
4
+ import { SqliteProvider } from '../provider.js';
5
5
  import { createAgent } from './agents.js';
6
6
  import { createRequirement } from './requirements.js';
7
7
  import {
@@ -28,24 +28,25 @@ import { createTeam } from './teams.js';
28
28
  import { createTestDatabase } from './test-helpers.js';
29
29
 
30
30
  describe('stories queries', () => {
31
- let db: Database;
31
+ let db: SqliteProvider;
32
32
  let teamId: string;
33
33
  let agentId: string;
34
34
  let requirementId: string;
35
35
 
36
36
  beforeEach(async () => {
37
- db = await createTestDatabase();
38
- const team = createTeam(db, {
37
+ const rawDb = await createTestDatabase();
38
+ db = new SqliteProvider(rawDb);
39
+ const team = await createTeam(db, {
39
40
  repoUrl: 'https://github.com/test/repo.git',
40
41
  repoPath: '/path/to/repo',
41
42
  name: 'Test Team',
42
43
  });
43
44
  teamId = team.id;
44
45
 
45
- const agent = createAgent(db, { type: 'senior', teamId });
46
+ const agent = await createAgent(db, { type: 'senior', teamId });
46
47
  agentId = agent.id;
47
48
 
48
- const requirement = createRequirement(db, {
49
+ const requirement = await createRequirement(db, {
49
50
  title: 'Test Requirement',
50
51
  description: 'Test description',
51
52
  });
@@ -53,8 +54,8 @@ describe('stories queries', () => {
53
54
  });
54
55
 
55
56
  describe('createStory', () => {
56
- it('should create a story with all fields', () => {
57
- const story = createStory(db, {
57
+ it('should create a story with all fields', async () => {
58
+ const story = await createStory(db, {
58
59
  requirementId,
59
60
  teamId,
60
61
  title: 'Implement feature X',
@@ -72,8 +73,8 @@ describe('stories queries', () => {
72
73
  expect(story.created_at).toBeDefined();
73
74
  });
74
75
 
75
- it('should create story with minimal fields', () => {
76
- const story = createStory(db, {
76
+ it('should create story with minimal fields', async () => {
77
+ const story = await createStory(db, {
77
78
  title: 'Simple Story',
78
79
  description: 'Simple description',
79
80
  });
@@ -83,13 +84,13 @@ describe('stories queries', () => {
83
84
  expect(story.acceptance_criteria).toBeNull();
84
85
  });
85
86
 
86
- it('should generate unique IDs', () => {
87
- const story1 = createStory(db, {
87
+ it('should generate unique IDs', async () => {
88
+ const story1 = await createStory(db, {
88
89
  title: 'Story 1',
89
90
  description: 'Description 1',
90
91
  });
91
92
 
92
- const story2 = createStory(db, {
93
+ const story2 = await createStory(db, {
93
94
  title: 'Story 2',
94
95
  description: 'Description 2',
95
96
  });
@@ -97,8 +98,8 @@ describe('stories queries', () => {
97
98
  expect(story1.id).not.toBe(story2.id);
98
99
  });
99
100
 
100
- it('should handle null acceptance criteria', () => {
101
- const story = createStory(db, {
101
+ it('should handle null acceptance criteria', async () => {
102
+ const story = await createStory(db, {
102
103
  title: 'Story',
103
104
  description: 'Description',
104
105
  acceptanceCriteria: null,
@@ -109,71 +110,71 @@ describe('stories queries', () => {
109
110
  });
110
111
 
111
112
  describe('getStoryById', () => {
112
- it('should retrieve a story by ID', () => {
113
- const created = createStory(db, {
113
+ it('should retrieve a story by ID', async () => {
114
+ const created = await createStory(db, {
114
115
  title: 'Test Story',
115
116
  description: 'Test description',
116
117
  teamId,
117
118
  });
118
119
 
119
- const retrieved = getStoryById(db, created.id);
120
+ const retrieved = await getStoryById(db, created.id);
120
121
 
121
122
  expect(retrieved).toBeDefined();
122
123
  expect(retrieved?.id).toBe(created.id);
123
124
  expect(retrieved?.title).toBe('Test Story');
124
125
  });
125
126
 
126
- it('should return undefined for non-existent story', () => {
127
- const result = getStoryById(db, 'non-existent-id');
127
+ it('should return undefined for non-existent story', async () => {
128
+ const result = await getStoryById(db, 'non-existent-id');
128
129
  expect(result).toBeUndefined();
129
130
  });
130
131
  });
131
132
 
132
133
  describe('getStoriesByRequirement', () => {
133
- it('should return stories for a requirement', () => {
134
- const story1 = createStory(db, {
134
+ it('should return stories for a requirement', async () => {
135
+ const story1 = await createStory(db, {
135
136
  requirementId,
136
137
  title: 'Story 1',
137
138
  description: 'Description 1',
138
139
  });
139
140
 
140
- const story2 = createStory(db, {
141
+ const story2 = await createStory(db, {
141
142
  requirementId,
142
143
  title: 'Story 2',
143
144
  description: 'Description 2',
144
145
  });
145
146
 
146
- const req2 = createRequirement(db, {
147
+ const req2 = await createRequirement(db, {
147
148
  title: 'Requirement 2',
148
149
  description: 'Description',
149
150
  });
150
- createStory(db, {
151
+ await createStory(db, {
151
152
  requirementId: req2.id,
152
153
  title: 'Story 3',
153
154
  description: 'Description 3',
154
155
  });
155
156
 
156
- const stories = getStoriesByRequirement(db, requirementId);
157
+ const stories = await getStoriesByRequirement(db, requirementId);
157
158
 
158
159
  expect(stories).toHaveLength(2);
159
160
  expect(stories.map(s => s.id)).toContain(story1.id);
160
161
  expect(stories.map(s => s.id)).toContain(story2.id);
161
162
  });
162
163
 
163
- it('should order by created_at', () => {
164
- const story1 = createStory(db, {
164
+ it('should order by created_at', async () => {
165
+ const story1 = await createStory(db, {
165
166
  requirementId,
166
167
  title: 'First',
167
168
  description: 'Description',
168
169
  });
169
170
 
170
- const story2 = createStory(db, {
171
+ const story2 = await createStory(db, {
171
172
  requirementId,
172
173
  title: 'Second',
173
174
  description: 'Description',
174
175
  });
175
176
 
176
- const stories = getStoriesByRequirement(db, requirementId);
177
+ const stories = await getStoriesByRequirement(db, requirementId);
177
178
 
178
179
  expect(stories[0].id).toBe(story1.id);
179
180
  expect(stories[1].id).toBe(story2.id);
@@ -181,25 +182,25 @@ describe('stories queries', () => {
181
182
  });
182
183
 
183
184
  describe('getStoriesByTeam', () => {
184
- it('should filter stories by team', () => {
185
- const story1 = createStory(db, {
185
+ it('should filter stories by team', async () => {
186
+ const story1 = await createStory(db, {
186
187
  teamId,
187
188
  title: 'Story 1',
188
189
  description: 'Description',
189
190
  });
190
191
 
191
- const team2 = createTeam(db, {
192
+ const team2 = await createTeam(db, {
192
193
  repoUrl: 'https://github.com/test/repo2.git',
193
194
  repoPath: '/path/to/repo2',
194
195
  name: 'Team 2',
195
196
  });
196
- createStory(db, {
197
+ await createStory(db, {
197
198
  teamId: team2.id,
198
199
  title: 'Story 2',
199
200
  description: 'Description',
200
201
  });
201
202
 
202
- const stories = getStoriesByTeam(db, teamId);
203
+ const stories = await getStoriesByTeam(db, teamId);
203
204
 
204
205
  expect(stories).toHaveLength(1);
205
206
  expect(stories[0].id).toBe(story1.id);
@@ -207,20 +208,20 @@ describe('stories queries', () => {
207
208
  });
208
209
 
209
210
  describe('getStoriesByStatus', () => {
210
- it('should filter stories by status', () => {
211
- const story1 = createStory(db, {
211
+ it('should filter stories by status', async () => {
212
+ const story1 = await createStory(db, {
212
213
  title: 'Draft Story',
213
214
  description: 'Description',
214
215
  });
215
216
 
216
- const story2 = createStory(db, {
217
+ const story2 = await createStory(db, {
217
218
  title: 'In Progress Story',
218
219
  description: 'Description',
219
220
  });
220
- updateStory(db, story2.id, { status: 'in_progress' });
221
+ await updateStory(db, story2.id, { status: 'in_progress' });
221
222
 
222
- const draft = getStoriesByStatus(db, 'draft');
223
- const inProgress = getStoriesByStatus(db, 'in_progress');
223
+ const draft = await getStoriesByStatus(db, 'draft');
224
+ const inProgress = await getStoriesByStatus(db, 'in_progress');
224
225
 
225
226
  expect(draft).toHaveLength(1);
226
227
  expect(draft[0].id).toBe(story1.id);
@@ -230,27 +231,27 @@ describe('stories queries', () => {
230
231
  });
231
232
 
232
233
  describe('getStoriesByAgent', () => {
233
- it('should return stories assigned to an agent', () => {
234
- const story1 = createStory(db, {
234
+ it('should return stories assigned to an agent', async () => {
235
+ const story1 = await createStory(db, {
235
236
  title: 'Story 1',
236
237
  description: 'Description',
237
238
  });
238
- updateStory(db, story1.id, { assignedAgentId: agentId });
239
+ await updateStory(db, story1.id, { assignedAgentId: agentId });
239
240
 
240
- const story2 = createStory(db, {
241
+ const story2 = await createStory(db, {
241
242
  title: 'Story 2',
242
243
  description: 'Description',
243
244
  });
244
- updateStory(db, story2.id, { assignedAgentId: agentId });
245
+ await updateStory(db, story2.id, { assignedAgentId: agentId });
245
246
 
246
- const agent2 = createAgent(db, { type: 'junior', teamId });
247
- const story3 = createStory(db, {
247
+ const agent2 = await createAgent(db, { type: 'junior', teamId });
248
+ const story3 = await createStory(db, {
248
249
  title: 'Story 3',
249
250
  description: 'Description',
250
251
  });
251
- updateStory(db, story3.id, { assignedAgentId: agent2.id });
252
+ await updateStory(db, story3.id, { assignedAgentId: agent2.id });
252
253
 
253
- const stories = getStoriesByAgent(db, agentId);
254
+ const stories = await getStoriesByAgent(db, agentId);
254
255
 
255
256
  expect(stories).toHaveLength(2);
256
257
  expect(stories.map(s => s.id)).toContain(story1.id);
@@ -259,26 +260,26 @@ describe('stories queries', () => {
259
260
  });
260
261
 
261
262
  describe('getActiveStoriesByAgent', () => {
262
- it('should return only active stories for an agent', () => {
263
- const story1 = createStory(db, {
263
+ it('should return only active stories for an agent', async () => {
264
+ const story1 = await createStory(db, {
264
265
  title: 'Planned Story',
265
266
  description: 'Description',
266
267
  });
267
- updateStory(db, story1.id, {
268
+ await updateStory(db, story1.id, {
268
269
  assignedAgentId: agentId,
269
270
  status: 'planned',
270
271
  });
271
272
 
272
- const story2 = createStory(db, {
273
+ const story2 = await createStory(db, {
273
274
  title: 'Merged Story',
274
275
  description: 'Description',
275
276
  });
276
- updateStory(db, story2.id, {
277
+ await updateStory(db, story2.id, {
277
278
  assignedAgentId: agentId,
278
279
  status: 'merged',
279
280
  });
280
281
 
281
- const activeStories = getActiveStoriesByAgent(db, agentId);
282
+ const activeStories = await getActiveStoriesByAgent(db, agentId);
282
283
 
283
284
  expect(activeStories).toHaveLength(1);
284
285
  expect(activeStories[0].id).toBe(story1.id);
@@ -286,18 +287,18 @@ describe('stories queries', () => {
286
287
  });
287
288
 
288
289
  describe('getAllStories', () => {
289
- it('should return all stories ordered by created_at DESC', () => {
290
- const story1 = createStory(db, {
290
+ it('should return all stories ordered by created_at DESC', async () => {
291
+ const story1 = await createStory(db, {
291
292
  title: 'First',
292
293
  description: 'Description',
293
294
  });
294
295
 
295
- const story2 = createStory(db, {
296
+ const story2 = await createStory(db, {
296
297
  title: 'Second',
297
298
  description: 'Description',
298
299
  });
299
300
 
300
- const stories = getAllStories(db);
301
+ const stories = await getAllStories(db);
301
302
 
302
303
  expect(stories).toHaveLength(2);
303
304
  // Verify both stories are present
@@ -307,25 +308,25 @@ describe('stories queries', () => {
307
308
  });
308
309
 
309
310
  describe('getPlannedStories', () => {
310
- it('should return planned stories ordered by story points DESC', () => {
311
- const story1 = createStory(db, {
311
+ it('should return planned stories ordered by story points DESC', async () => {
312
+ const story1 = await createStory(db, {
312
313
  title: 'Story 1',
313
314
  description: 'Description',
314
315
  });
315
- updateStory(db, story1.id, { status: 'planned', storyPoints: 5 });
316
+ await updateStory(db, story1.id, { status: 'planned', storyPoints: 5 });
316
317
 
317
- const story2 = createStory(db, {
318
+ const story2 = await createStory(db, {
318
319
  title: 'Story 2',
319
320
  description: 'Description',
320
321
  });
321
- updateStory(db, story2.id, { status: 'planned', storyPoints: 8 });
322
+ await updateStory(db, story2.id, { status: 'planned', storyPoints: 8 });
322
323
 
323
- createStory(db, {
324
+ await createStory(db, {
324
325
  title: 'Draft Story',
325
326
  description: 'Description',
326
327
  });
327
328
 
328
- const planned = getPlannedStories(db);
329
+ const planned = await getPlannedStories(db);
329
330
 
330
331
  expect(planned).toHaveLength(2);
331
332
  expect(planned[0].id).toBe(story2.id); // 8 points first
@@ -334,26 +335,26 @@ describe('stories queries', () => {
334
335
  });
335
336
 
336
337
  describe('getInProgressStories', () => {
337
- it('should return stories in progress statuses', () => {
338
- const story1 = createStory(db, {
338
+ it('should return stories in progress statuses', async () => {
339
+ const story1 = await createStory(db, {
339
340
  title: 'In Progress',
340
341
  description: 'Description',
341
342
  });
342
- updateStory(db, story1.id, { status: 'in_progress' });
343
+ await updateStory(db, story1.id, { status: 'in_progress' });
343
344
 
344
- const story2 = createStory(db, {
345
+ const story2 = await createStory(db, {
345
346
  title: 'QA',
346
347
  description: 'Description',
347
348
  });
348
- updateStory(db, story2.id, { status: 'qa' });
349
+ await updateStory(db, story2.id, { status: 'qa' });
349
350
 
350
- const story3 = createStory(db, {
351
+ const story3 = await createStory(db, {
351
352
  title: 'Merged',
352
353
  description: 'Description',
353
354
  });
354
- updateStory(db, story3.id, { status: 'merged' });
355
+ await updateStory(db, story3.id, { status: 'merged' });
355
356
 
356
- const inProgress = getInProgressStories(db);
357
+ const inProgress = await getInProgressStories(db);
357
358
 
358
359
  expect(inProgress).toHaveLength(2);
359
360
  expect(inProgress.map(s => s.id)).toContain(story1.id);
@@ -363,58 +364,58 @@ describe('stories queries', () => {
363
364
  });
364
365
 
365
366
  describe('getStoryPointsByTeam', () => {
366
- it('should sum story points for active team stories', () => {
367
- createStory(db, { title: 'S1', description: 'D', teamId });
368
- const s1 = createStory(db, { title: 'S1', description: 'D', teamId });
369
- updateStory(db, s1.id, { status: 'planned', storyPoints: 5 });
367
+ it('should sum story points for active team stories', async () => {
368
+ await createStory(db, { title: 'S1', description: 'D', teamId });
369
+ const s1 = await createStory(db, { title: 'S1', description: 'D', teamId });
370
+ await updateStory(db, s1.id, { status: 'planned', storyPoints: 5 });
370
371
 
371
- const s2 = createStory(db, { title: 'S2', description: 'D', teamId });
372
- updateStory(db, s2.id, { status: 'in_progress', storyPoints: 8 });
372
+ const s2 = await createStory(db, { title: 'S2', description: 'D', teamId });
373
+ await updateStory(db, s2.id, { status: 'in_progress', storyPoints: 8 });
373
374
 
374
- const s3 = createStory(db, { title: 'S3', description: 'D', teamId });
375
- updateStory(db, s3.id, { status: 'merged', storyPoints: 3 });
375
+ const s3 = await createStory(db, { title: 'S3', description: 'D', teamId });
376
+ await updateStory(db, s3.id, { status: 'merged', storyPoints: 3 });
376
377
 
377
- const total = getStoryPointsByTeam(db, teamId);
378
+ const total = await getStoryPointsByTeam(db, teamId);
378
379
 
379
380
  expect(total).toBe(13); // 5 + 8, not including merged
380
381
  });
381
382
 
382
- it('should return 0 when no active stories', () => {
383
- const total = getStoryPointsByTeam(db, teamId);
383
+ it('should return 0 when no active stories', async () => {
384
+ const total = await getStoryPointsByTeam(db, teamId);
384
385
  expect(total).toBe(0);
385
386
  });
386
387
  });
387
388
 
388
389
  describe('updateStory', () => {
389
- it('should update story title', () => {
390
- const story = createStory(db, {
390
+ it('should update story title', async () => {
391
+ const story = await createStory(db, {
391
392
  title: 'Original',
392
393
  description: 'Description',
393
394
  });
394
395
 
395
- const updated = updateStory(db, story.id, { title: 'Updated' });
396
+ const updated = await updateStory(db, story.id, { title: 'Updated' });
396
397
 
397
398
  expect(updated?.title).toBe('Updated');
398
399
  });
399
400
 
400
- it('should update story status', () => {
401
- const story = createStory(db, {
401
+ it('should update story status', async () => {
402
+ const story = await createStory(db, {
402
403
  title: 'Story',
403
404
  description: 'Description',
404
405
  });
405
406
 
406
- const updated = updateStory(db, story.id, { status: 'in_progress' });
407
+ const updated = await updateStory(db, story.id, { status: 'in_progress' });
407
408
 
408
409
  expect(updated?.status).toBe('in_progress');
409
410
  });
410
411
 
411
- it('should update complexity and story points', () => {
412
- const story = createStory(db, {
412
+ it('should update complexity and story points', async () => {
413
+ const story = await createStory(db, {
413
414
  title: 'Story',
414
415
  description: 'Description',
415
416
  });
416
417
 
417
- const updated = updateStory(db, story.id, {
418
+ const updated = await updateStory(db, story.id, {
418
419
  complexityScore: 8,
419
420
  storyPoints: 5,
420
421
  });
@@ -423,24 +424,24 @@ describe('stories queries', () => {
423
424
  expect(updated?.story_points).toBe(5);
424
425
  });
425
426
 
426
- it('should update assigned agent', () => {
427
- const story = createStory(db, {
427
+ it('should update assigned agent', async () => {
428
+ const story = await createStory(db, {
428
429
  title: 'Story',
429
430
  description: 'Description',
430
431
  });
431
432
 
432
- const updated = updateStory(db, story.id, { assignedAgentId: agentId });
433
+ const updated = await updateStory(db, story.id, { assignedAgentId: agentId });
433
434
 
434
435
  expect(updated?.assigned_agent_id).toBe(agentId);
435
436
  });
436
437
 
437
- it('should update acceptance criteria', () => {
438
- const story = createStory(db, {
438
+ it('should update acceptance criteria', async () => {
439
+ const story = await createStory(db, {
439
440
  title: 'Story',
440
441
  description: 'Description',
441
442
  });
442
443
 
443
- const updated = updateStory(db, story.id, {
444
+ const updated = await updateStory(db, story.id, {
444
445
  acceptanceCriteria: ['New criterion 1', 'New criterion 2'],
445
446
  });
446
447
 
@@ -449,13 +450,13 @@ describe('stories queries', () => {
449
450
  );
450
451
  });
451
452
 
452
- it('should update branch and PR info', () => {
453
- const story = createStory(db, {
453
+ it('should update branch and PR info', async () => {
454
+ const story = await createStory(db, {
454
455
  title: 'Story',
455
456
  description: 'Description',
456
457
  });
457
458
 
458
- const updated = updateStory(db, story.id, {
459
+ const updated = await updateStory(db, story.id, {
459
460
  branchName: 'feature/test-branch',
460
461
  prUrl: 'https://github.com/test/repo/pull/123',
461
462
  });
@@ -464,13 +465,13 @@ describe('stories queries', () => {
464
465
  expect(updated?.pr_url).toBe('https://github.com/test/repo/pull/123');
465
466
  });
466
467
 
467
- it('should update multiple fields at once', () => {
468
- const story = createStory(db, {
468
+ it('should update multiple fields at once', async () => {
469
+ const story = await createStory(db, {
469
470
  title: 'Original',
470
471
  description: 'Original description',
471
472
  });
472
473
 
473
- const updated = updateStory(db, story.id, {
474
+ const updated = await updateStory(db, story.id, {
474
475
  title: 'Updated',
475
476
  description: 'Updated description',
476
477
  status: 'in_progress',
@@ -483,30 +484,30 @@ describe('stories queries', () => {
483
484
  expect(updated?.assigned_agent_id).toBe(agentId);
484
485
  });
485
486
 
486
- it('should return story when no updates provided', () => {
487
- const story = createStory(db, {
487
+ it('should return story when no updates provided', async () => {
488
+ const story = await createStory(db, {
488
489
  title: 'Story',
489
490
  description: 'Description',
490
491
  });
491
492
 
492
- const updated = updateStory(db, story.id, {});
493
+ const updated = await updateStory(db, story.id, {});
493
494
 
494
495
  expect(updated?.id).toBe(story.id);
495
496
  });
496
497
 
497
- it('should return undefined for non-existent story', () => {
498
- const updated = updateStory(db, 'non-existent-id', { title: 'Updated' });
498
+ it('should return undefined for non-existent story', async () => {
499
+ const updated = await updateStory(db, 'non-existent-id', { title: 'Updated' });
499
500
  expect(updated).toBeUndefined();
500
501
  });
501
502
 
502
- it('should handle setting fields to null', () => {
503
- const story = createStory(db, {
503
+ it('should handle setting fields to null', async () => {
504
+ const story = await createStory(db, {
504
505
  title: 'Story',
505
506
  description: 'Description',
506
507
  teamId,
507
508
  });
508
509
 
509
- const updated = updateStory(db, story.id, {
510
+ const updated = await updateStory(db, story.id, {
510
511
  teamId: null,
511
512
  acceptanceCriteria: null,
512
513
  });
@@ -517,120 +518,120 @@ describe('stories queries', () => {
517
518
  });
518
519
 
519
520
  describe('deleteStory', () => {
520
- it('should delete a story', () => {
521
- const story = createStory(db, {
521
+ it('should delete a story', async () => {
522
+ const story = await createStory(db, {
522
523
  title: 'To Delete',
523
524
  description: 'Description',
524
525
  });
525
526
 
526
- deleteStory(db, story.id);
527
+ await deleteStory(db, story.id);
527
528
 
528
- const retrieved = getStoryById(db, story.id);
529
+ const retrieved = await getStoryById(db, story.id);
529
530
  expect(retrieved).toBeUndefined();
530
531
  });
531
532
 
532
- it('should delete story dependencies when deleting story', () => {
533
- const story1 = createStory(db, {
533
+ it('should delete story dependencies when deleting story', async () => {
534
+ const story1 = await createStory(db, {
534
535
  title: 'Story 1',
535
536
  description: 'Description',
536
537
  });
537
538
 
538
- const story2 = createStory(db, {
539
+ const story2 = await createStory(db, {
539
540
  title: 'Story 2',
540
541
  description: 'Description',
541
542
  });
542
543
 
543
- addStoryDependency(db, story2.id, story1.id);
544
+ await addStoryDependency(db, story2.id, story1.id);
544
545
 
545
- deleteStory(db, story1.id);
546
+ await deleteStory(db, story1.id);
546
547
 
547
- const dependencies = getStoryDependencies(db, story2.id);
548
+ const dependencies = await getStoryDependencies(db, story2.id);
548
549
  expect(dependencies).toEqual([]);
549
550
  });
550
551
 
551
- it('should not throw when deleting non-existent story', () => {
552
- expect(() => deleteStory(db, 'non-existent-id')).not.toThrow();
552
+ it('should not throw when deleting non-existent story', async () => {
553
+ await expect(deleteStory(db, 'non-existent-id')).resolves.not.toThrow();
553
554
  });
554
555
  });
555
556
 
556
557
  describe('story dependencies', () => {
557
- it('should add a story dependency', () => {
558
- const story1 = createStory(db, {
558
+ it('should add a story dependency', async () => {
559
+ const story1 = await createStory(db, {
559
560
  title: 'Story 1',
560
561
  description: 'Description',
561
562
  });
562
563
 
563
- const story2 = createStory(db, {
564
+ const story2 = await createStory(db, {
564
565
  title: 'Story 2',
565
566
  description: 'Description',
566
567
  });
567
568
 
568
- addStoryDependency(db, story2.id, story1.id);
569
+ await addStoryDependency(db, story2.id, story1.id);
569
570
 
570
- const dependencies = getStoryDependencies(db, story2.id);
571
+ const dependencies = await getStoryDependencies(db, story2.id);
571
572
 
572
573
  expect(dependencies).toHaveLength(1);
573
574
  expect(dependencies[0].id).toBe(story1.id);
574
575
  });
575
576
 
576
- it('should not duplicate dependencies', () => {
577
- const story1 = createStory(db, {
577
+ it('should not duplicate dependencies', async () => {
578
+ const story1 = await createStory(db, {
578
579
  title: 'Story 1',
579
580
  description: 'Description',
580
581
  });
581
582
 
582
- const story2 = createStory(db, {
583
+ const story2 = await createStory(db, {
583
584
  title: 'Story 2',
584
585
  description: 'Description',
585
586
  });
586
587
 
587
- addStoryDependency(db, story2.id, story1.id);
588
- addStoryDependency(db, story2.id, story1.id);
588
+ await addStoryDependency(db, story2.id, story1.id);
589
+ await addStoryDependency(db, story2.id, story1.id);
589
590
 
590
- const dependencies = getStoryDependencies(db, story2.id);
591
+ const dependencies = await getStoryDependencies(db, story2.id);
591
592
 
592
593
  expect(dependencies).toHaveLength(1);
593
594
  });
594
595
 
595
- it('should remove a story dependency', () => {
596
- const story1 = createStory(db, {
596
+ it('should remove a story dependency', async () => {
597
+ const story1 = await createStory(db, {
597
598
  title: 'Story 1',
598
599
  description: 'Description',
599
600
  });
600
601
 
601
- const story2 = createStory(db, {
602
+ const story2 = await createStory(db, {
602
603
  title: 'Story 2',
603
604
  description: 'Description',
604
605
  });
605
606
 
606
- addStoryDependency(db, story2.id, story1.id);
607
- removeStoryDependency(db, story2.id, story1.id);
607
+ await addStoryDependency(db, story2.id, story1.id);
608
+ await removeStoryDependency(db, story2.id, story1.id);
608
609
 
609
- const dependencies = getStoryDependencies(db, story2.id);
610
+ const dependencies = await getStoryDependencies(db, story2.id);
610
611
 
611
612
  expect(dependencies).toEqual([]);
612
613
  });
613
614
 
614
- it('should get stories depending on a story', () => {
615
- const story1 = createStory(db, {
615
+ it('should get stories depending on a story', async () => {
616
+ const story1 = await createStory(db, {
616
617
  title: 'Base Story',
617
618
  description: 'Description',
618
619
  });
619
620
 
620
- const story2 = createStory(db, {
621
+ const story2 = await createStory(db, {
621
622
  title: 'Dependent 1',
622
623
  description: 'Description',
623
624
  });
624
625
 
625
- const story3 = createStory(db, {
626
+ const story3 = await createStory(db, {
626
627
  title: 'Dependent 2',
627
628
  description: 'Description',
628
629
  });
629
630
 
630
- addStoryDependency(db, story2.id, story1.id);
631
- addStoryDependency(db, story3.id, story1.id);
631
+ await addStoryDependency(db, story2.id, story1.id);
632
+ await addStoryDependency(db, story3.id, story1.id);
632
633
 
633
- const dependents = getStoriesDependingOn(db, story1.id);
634
+ const dependents = await getStoriesDependingOn(db, story1.id);
634
635
 
635
636
  expect(dependents).toHaveLength(2);
636
637
  expect(dependents.map(s => s.id)).toContain(story2.id);
@@ -639,17 +640,17 @@ describe('stories queries', () => {
639
640
  });
640
641
 
641
642
  describe('getStoryCounts', () => {
642
- it('should return counts by status', () => {
643
- createStory(db, { title: 'S1', description: 'D' }); // draft
644
- createStory(db, { title: 'S2', description: 'D' }); // draft
643
+ it('should return counts by status', async () => {
644
+ await createStory(db, { title: 'S1', description: 'D' }); // draft
645
+ await createStory(db, { title: 'S2', description: 'D' }); // draft
645
646
 
646
- const s3 = createStory(db, { title: 'S3', description: 'D' });
647
- updateStory(db, s3.id, { status: 'planned' });
647
+ const s3 = await createStory(db, { title: 'S3', description: 'D' });
648
+ await updateStory(db, s3.id, { status: 'planned' });
648
649
 
649
- const s4 = createStory(db, { title: 'S4', description: 'D' });
650
- updateStory(db, s4.id, { status: 'in_progress' });
650
+ const s4 = await createStory(db, { title: 'S4', description: 'D' });
651
+ await updateStory(db, s4.id, { status: 'in_progress' });
651
652
 
652
- const counts = getStoryCounts(db);
653
+ const counts = await getStoryCounts(db);
653
654
 
654
655
  expect(counts.draft).toBe(2);
655
656
  expect(counts.planned).toBe(1);
@@ -657,8 +658,8 @@ describe('stories queries', () => {
657
658
  expect(counts.merged).toBe(0);
658
659
  });
659
660
 
660
- it('should return zero counts when no stories', () => {
661
- const counts = getStoryCounts(db);
661
+ it('should return zero counts when no stories', async () => {
662
+ const counts = await getStoryCounts(db);
662
663
 
663
664
  expect(counts.draft).toBe(0);
664
665
  expect(counts.estimated).toBe(0);
@@ -667,7 +668,7 @@ describe('stories queries', () => {
667
668
  });
668
669
 
669
670
  describe('edge cases', () => {
670
- it('should handle all story statuses', () => {
671
+ it('should handle all story statuses', async () => {
671
672
  const statuses: Array<
672
673
  | 'draft'
673
674
  | 'estimated'
@@ -690,36 +691,36 @@ describe('stories queries', () => {
690
691
  'merged',
691
692
  ];
692
693
 
693
- const story = createStory(db, {
694
+ const story = await createStory(db, {
694
695
  title: 'Test',
695
696
  description: 'Description',
696
697
  });
697
698
 
698
- statuses.forEach(status => {
699
- const updated = updateStory(db, story.id, { status });
699
+ for (const status of statuses) {
700
+ const updated = await updateStory(db, story.id, { status });
700
701
  expect(updated?.status).toBe(status);
701
- });
702
+ }
702
703
  });
703
704
 
704
- it('should handle very long text fields', () => {
705
+ it('should handle very long text fields', async () => {
705
706
  const longText = 'A'.repeat(100000);
706
- const story = createStory(db, {
707
+ const story = await createStory(db, {
707
708
  title: longText,
708
709
  description: longText,
709
710
  });
710
711
 
711
- const retrieved = getStoryById(db, story.id);
712
+ const retrieved = await getStoryById(db, story.id);
712
713
  expect(retrieved?.title).toBe(longText);
713
714
  expect(retrieved?.description).toBe(longText);
714
715
  });
715
716
 
716
- it('should handle special characters', () => {
717
- const story = createStory(db, {
717
+ it('should handle special characters', async () => {
718
+ const story = await createStory(db, {
718
719
  title: 'Title with \'quotes\' and "double"',
719
720
  description: 'Description with\nnewlines\tand\ttabs',
720
721
  });
721
722
 
722
- const retrieved = getStoryById(db, story.id);
723
+ const retrieved = await getStoryById(db, story.id);
723
724
  expect(retrieved?.title).toBe('Title with \'quotes\' and "double"');
724
725
  expect(retrieved?.description).toBe('Description with\nnewlines\tand\ttabs');
725
726
  });