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,5 +1,6 @@
1
1
  // Licensed under the Hungry Ghost Hive License. See LICENSE.
2
2
  import { beforeEach, describe, expect, it } from 'vitest';
3
+ import { SqliteProvider } from '../provider.js';
3
4
  import { createAgent } from './agents.js';
4
5
  import { createRequirement } from './requirements.js';
5
6
  import { addStoryDependency, createStory, deleteStory, getActiveStoriesByAgent, getAllStories, getInProgressStories, getPlannedStories, getStoriesByAgent, getStoriesByRequirement, getStoriesByStatus, getStoriesByTeam, getStoriesDependingOn, getStoryById, getStoryCounts, getStoryDependencies, getStoryPointsByTeam, removeStoryDependency, updateStory, } from './stories.js';
@@ -11,24 +12,25 @@ describe('stories queries', () => {
11
12
  let agentId;
12
13
  let requirementId;
13
14
  beforeEach(async () => {
14
- db = await createTestDatabase();
15
- const team = createTeam(db, {
15
+ const rawDb = await createTestDatabase();
16
+ db = new SqliteProvider(rawDb);
17
+ const team = await createTeam(db, {
16
18
  repoUrl: 'https://github.com/test/repo.git',
17
19
  repoPath: '/path/to/repo',
18
20
  name: 'Test Team',
19
21
  });
20
22
  teamId = team.id;
21
- const agent = createAgent(db, { type: 'senior', teamId });
23
+ const agent = await createAgent(db, { type: 'senior', teamId });
22
24
  agentId = agent.id;
23
- const requirement = createRequirement(db, {
25
+ const requirement = await createRequirement(db, {
24
26
  title: 'Test Requirement',
25
27
  description: 'Test description',
26
28
  });
27
29
  requirementId = requirement.id;
28
30
  });
29
31
  describe('createStory', () => {
30
- it('should create a story with all fields', () => {
31
- const story = createStory(db, {
32
+ it('should create a story with all fields', async () => {
33
+ const story = await createStory(db, {
32
34
  requirementId,
33
35
  teamId,
34
36
  title: 'Implement feature X',
@@ -44,8 +46,8 @@ describe('stories queries', () => {
44
46
  expect(story.status).toBe('draft');
45
47
  expect(story.created_at).toBeDefined();
46
48
  });
47
- it('should create story with minimal fields', () => {
48
- const story = createStory(db, {
49
+ it('should create story with minimal fields', async () => {
50
+ const story = await createStory(db, {
49
51
  title: 'Simple Story',
50
52
  description: 'Simple description',
51
53
  });
@@ -53,19 +55,19 @@ describe('stories queries', () => {
53
55
  expect(story.team_id).toBeNull();
54
56
  expect(story.acceptance_criteria).toBeNull();
55
57
  });
56
- it('should generate unique IDs', () => {
57
- const story1 = createStory(db, {
58
+ it('should generate unique IDs', async () => {
59
+ const story1 = await createStory(db, {
58
60
  title: 'Story 1',
59
61
  description: 'Description 1',
60
62
  });
61
- const story2 = createStory(db, {
63
+ const story2 = await createStory(db, {
62
64
  title: 'Story 2',
63
65
  description: 'Description 2',
64
66
  });
65
67
  expect(story1.id).not.toBe(story2.id);
66
68
  });
67
- it('should handle null acceptance criteria', () => {
68
- const story = createStory(db, {
69
+ it('should handle null acceptance criteria', async () => {
70
+ const story = await createStory(db, {
69
71
  title: 'Story',
70
72
  description: 'Description',
71
73
  acceptanceCriteria: null,
@@ -74,99 +76,99 @@ describe('stories queries', () => {
74
76
  });
75
77
  });
76
78
  describe('getStoryById', () => {
77
- it('should retrieve a story by ID', () => {
78
- const created = createStory(db, {
79
+ it('should retrieve a story by ID', async () => {
80
+ const created = await createStory(db, {
79
81
  title: 'Test Story',
80
82
  description: 'Test description',
81
83
  teamId,
82
84
  });
83
- const retrieved = getStoryById(db, created.id);
85
+ const retrieved = await getStoryById(db, created.id);
84
86
  expect(retrieved).toBeDefined();
85
87
  expect(retrieved?.id).toBe(created.id);
86
88
  expect(retrieved?.title).toBe('Test Story');
87
89
  });
88
- it('should return undefined for non-existent story', () => {
89
- const result = getStoryById(db, 'non-existent-id');
90
+ it('should return undefined for non-existent story', async () => {
91
+ const result = await getStoryById(db, 'non-existent-id');
90
92
  expect(result).toBeUndefined();
91
93
  });
92
94
  });
93
95
  describe('getStoriesByRequirement', () => {
94
- it('should return stories for a requirement', () => {
95
- const story1 = createStory(db, {
96
+ it('should return stories for a requirement', async () => {
97
+ const story1 = await createStory(db, {
96
98
  requirementId,
97
99
  title: 'Story 1',
98
100
  description: 'Description 1',
99
101
  });
100
- const story2 = createStory(db, {
102
+ const story2 = await createStory(db, {
101
103
  requirementId,
102
104
  title: 'Story 2',
103
105
  description: 'Description 2',
104
106
  });
105
- const req2 = createRequirement(db, {
107
+ const req2 = await createRequirement(db, {
106
108
  title: 'Requirement 2',
107
109
  description: 'Description',
108
110
  });
109
- createStory(db, {
111
+ await createStory(db, {
110
112
  requirementId: req2.id,
111
113
  title: 'Story 3',
112
114
  description: 'Description 3',
113
115
  });
114
- const stories = getStoriesByRequirement(db, requirementId);
116
+ const stories = await getStoriesByRequirement(db, requirementId);
115
117
  expect(stories).toHaveLength(2);
116
118
  expect(stories.map(s => s.id)).toContain(story1.id);
117
119
  expect(stories.map(s => s.id)).toContain(story2.id);
118
120
  });
119
- it('should order by created_at', () => {
120
- const story1 = createStory(db, {
121
+ it('should order by created_at', async () => {
122
+ const story1 = await createStory(db, {
121
123
  requirementId,
122
124
  title: 'First',
123
125
  description: 'Description',
124
126
  });
125
- const story2 = createStory(db, {
127
+ const story2 = await createStory(db, {
126
128
  requirementId,
127
129
  title: 'Second',
128
130
  description: 'Description',
129
131
  });
130
- const stories = getStoriesByRequirement(db, requirementId);
132
+ const stories = await getStoriesByRequirement(db, requirementId);
131
133
  expect(stories[0].id).toBe(story1.id);
132
134
  expect(stories[1].id).toBe(story2.id);
133
135
  });
134
136
  });
135
137
  describe('getStoriesByTeam', () => {
136
- it('should filter stories by team', () => {
137
- const story1 = createStory(db, {
138
+ it('should filter stories by team', async () => {
139
+ const story1 = await createStory(db, {
138
140
  teamId,
139
141
  title: 'Story 1',
140
142
  description: 'Description',
141
143
  });
142
- const team2 = createTeam(db, {
144
+ const team2 = await createTeam(db, {
143
145
  repoUrl: 'https://github.com/test/repo2.git',
144
146
  repoPath: '/path/to/repo2',
145
147
  name: 'Team 2',
146
148
  });
147
- createStory(db, {
149
+ await createStory(db, {
148
150
  teamId: team2.id,
149
151
  title: 'Story 2',
150
152
  description: 'Description',
151
153
  });
152
- const stories = getStoriesByTeam(db, teamId);
154
+ const stories = await getStoriesByTeam(db, teamId);
153
155
  expect(stories).toHaveLength(1);
154
156
  expect(stories[0].id).toBe(story1.id);
155
157
  });
156
158
  });
157
159
  describe('getStoriesByStatus', () => {
158
- it('should filter stories by status', () => {
159
- const story1 = createStory(db, {
160
+ it('should filter stories by status', async () => {
161
+ const story1 = await createStory(db, {
160
162
  title: 'Draft Story',
161
163
  description: 'Description',
162
164
  });
163
- const story2 = createStory(db, {
165
+ const story2 = await createStory(db, {
164
166
  title: 'In Progress Story',
165
167
  description: 'Description',
166
168
  });
167
- updateStory(db, story2.id, { status: 'in_progress' });
168
- const draft = getStoriesByStatus(db, 'draft');
169
- const inProgress = getStoriesByStatus(db, 'in_progress');
169
+ await updateStory(db, story2.id, { status: 'in_progress' });
170
+ const draft = await getStoriesByStatus(db, 'draft');
171
+ const inProgress = await getStoriesByStatus(db, 'in_progress');
170
172
  expect(draft).toHaveLength(1);
171
173
  expect(draft[0].id).toBe(story1.id);
172
174
  expect(inProgress).toHaveLength(1);
@@ -174,63 +176,63 @@ describe('stories queries', () => {
174
176
  });
175
177
  });
176
178
  describe('getStoriesByAgent', () => {
177
- it('should return stories assigned to an agent', () => {
178
- const story1 = createStory(db, {
179
+ it('should return stories assigned to an agent', async () => {
180
+ const story1 = await createStory(db, {
179
181
  title: 'Story 1',
180
182
  description: 'Description',
181
183
  });
182
- updateStory(db, story1.id, { assignedAgentId: agentId });
183
- const story2 = createStory(db, {
184
+ await updateStory(db, story1.id, { assignedAgentId: agentId });
185
+ const story2 = await createStory(db, {
184
186
  title: 'Story 2',
185
187
  description: 'Description',
186
188
  });
187
- updateStory(db, story2.id, { assignedAgentId: agentId });
188
- const agent2 = createAgent(db, { type: 'junior', teamId });
189
- const story3 = createStory(db, {
189
+ await updateStory(db, story2.id, { assignedAgentId: agentId });
190
+ const agent2 = await createAgent(db, { type: 'junior', teamId });
191
+ const story3 = await createStory(db, {
190
192
  title: 'Story 3',
191
193
  description: 'Description',
192
194
  });
193
- updateStory(db, story3.id, { assignedAgentId: agent2.id });
194
- const stories = getStoriesByAgent(db, agentId);
195
+ await updateStory(db, story3.id, { assignedAgentId: agent2.id });
196
+ const stories = await getStoriesByAgent(db, agentId);
195
197
  expect(stories).toHaveLength(2);
196
198
  expect(stories.map(s => s.id)).toContain(story1.id);
197
199
  expect(stories.map(s => s.id)).toContain(story2.id);
198
200
  });
199
201
  });
200
202
  describe('getActiveStoriesByAgent', () => {
201
- it('should return only active stories for an agent', () => {
202
- const story1 = createStory(db, {
203
+ it('should return only active stories for an agent', async () => {
204
+ const story1 = await createStory(db, {
203
205
  title: 'Planned Story',
204
206
  description: 'Description',
205
207
  });
206
- updateStory(db, story1.id, {
208
+ await updateStory(db, story1.id, {
207
209
  assignedAgentId: agentId,
208
210
  status: 'planned',
209
211
  });
210
- const story2 = createStory(db, {
212
+ const story2 = await createStory(db, {
211
213
  title: 'Merged Story',
212
214
  description: 'Description',
213
215
  });
214
- updateStory(db, story2.id, {
216
+ await updateStory(db, story2.id, {
215
217
  assignedAgentId: agentId,
216
218
  status: 'merged',
217
219
  });
218
- const activeStories = getActiveStoriesByAgent(db, agentId);
220
+ const activeStories = await getActiveStoriesByAgent(db, agentId);
219
221
  expect(activeStories).toHaveLength(1);
220
222
  expect(activeStories[0].id).toBe(story1.id);
221
223
  });
222
224
  });
223
225
  describe('getAllStories', () => {
224
- it('should return all stories ordered by created_at DESC', () => {
225
- const story1 = createStory(db, {
226
+ it('should return all stories ordered by created_at DESC', async () => {
227
+ const story1 = await createStory(db, {
226
228
  title: 'First',
227
229
  description: 'Description',
228
230
  });
229
- const story2 = createStory(db, {
231
+ const story2 = await createStory(db, {
230
232
  title: 'Second',
231
233
  description: 'Description',
232
234
  });
233
- const stories = getAllStories(db);
235
+ const stories = await getAllStories(db);
234
236
  expect(stories).toHaveLength(2);
235
237
  // Verify both stories are present
236
238
  expect(stories.map(s => s.id)).toContain(story1.id);
@@ -238,45 +240,45 @@ describe('stories queries', () => {
238
240
  });
239
241
  });
240
242
  describe('getPlannedStories', () => {
241
- it('should return planned stories ordered by story points DESC', () => {
242
- const story1 = createStory(db, {
243
+ it('should return planned stories ordered by story points DESC', async () => {
244
+ const story1 = await createStory(db, {
243
245
  title: 'Story 1',
244
246
  description: 'Description',
245
247
  });
246
- updateStory(db, story1.id, { status: 'planned', storyPoints: 5 });
247
- const story2 = createStory(db, {
248
+ await updateStory(db, story1.id, { status: 'planned', storyPoints: 5 });
249
+ const story2 = await createStory(db, {
248
250
  title: 'Story 2',
249
251
  description: 'Description',
250
252
  });
251
- updateStory(db, story2.id, { status: 'planned', storyPoints: 8 });
252
- createStory(db, {
253
+ await updateStory(db, story2.id, { status: 'planned', storyPoints: 8 });
254
+ await createStory(db, {
253
255
  title: 'Draft Story',
254
256
  description: 'Description',
255
257
  });
256
- const planned = getPlannedStories(db);
258
+ const planned = await getPlannedStories(db);
257
259
  expect(planned).toHaveLength(2);
258
260
  expect(planned[0].id).toBe(story2.id); // 8 points first
259
261
  expect(planned[1].id).toBe(story1.id); // 5 points second
260
262
  });
261
263
  });
262
264
  describe('getInProgressStories', () => {
263
- it('should return stories in progress statuses', () => {
264
- const story1 = createStory(db, {
265
+ it('should return stories in progress statuses', async () => {
266
+ const story1 = await createStory(db, {
265
267
  title: 'In Progress',
266
268
  description: 'Description',
267
269
  });
268
- updateStory(db, story1.id, { status: 'in_progress' });
269
- const story2 = createStory(db, {
270
+ await updateStory(db, story1.id, { status: 'in_progress' });
271
+ const story2 = await createStory(db, {
270
272
  title: 'QA',
271
273
  description: 'Description',
272
274
  });
273
- updateStory(db, story2.id, { status: 'qa' });
274
- const story3 = createStory(db, {
275
+ await updateStory(db, story2.id, { status: 'qa' });
276
+ const story3 = await createStory(db, {
275
277
  title: 'Merged',
276
278
  description: 'Description',
277
279
  });
278
- updateStory(db, story3.id, { status: 'merged' });
279
- const inProgress = getInProgressStories(db);
280
+ await updateStory(db, story3.id, { status: 'merged' });
281
+ const inProgress = await getInProgressStories(db);
280
282
  expect(inProgress).toHaveLength(2);
281
283
  expect(inProgress.map(s => s.id)).toContain(story1.id);
282
284
  expect(inProgress.map(s => s.id)).toContain(story2.id);
@@ -284,87 +286,87 @@ describe('stories queries', () => {
284
286
  });
285
287
  });
286
288
  describe('getStoryPointsByTeam', () => {
287
- it('should sum story points for active team stories', () => {
288
- createStory(db, { title: 'S1', description: 'D', teamId });
289
- const s1 = createStory(db, { title: 'S1', description: 'D', teamId });
290
- updateStory(db, s1.id, { status: 'planned', storyPoints: 5 });
291
- const s2 = createStory(db, { title: 'S2', description: 'D', teamId });
292
- updateStory(db, s2.id, { status: 'in_progress', storyPoints: 8 });
293
- const s3 = createStory(db, { title: 'S3', description: 'D', teamId });
294
- updateStory(db, s3.id, { status: 'merged', storyPoints: 3 });
295
- const total = getStoryPointsByTeam(db, teamId);
289
+ it('should sum story points for active team stories', async () => {
290
+ await createStory(db, { title: 'S1', description: 'D', teamId });
291
+ const s1 = await createStory(db, { title: 'S1', description: 'D', teamId });
292
+ await updateStory(db, s1.id, { status: 'planned', storyPoints: 5 });
293
+ const s2 = await createStory(db, { title: 'S2', description: 'D', teamId });
294
+ await updateStory(db, s2.id, { status: 'in_progress', storyPoints: 8 });
295
+ const s3 = await createStory(db, { title: 'S3', description: 'D', teamId });
296
+ await updateStory(db, s3.id, { status: 'merged', storyPoints: 3 });
297
+ const total = await getStoryPointsByTeam(db, teamId);
296
298
  expect(total).toBe(13); // 5 + 8, not including merged
297
299
  });
298
- it('should return 0 when no active stories', () => {
299
- const total = getStoryPointsByTeam(db, teamId);
300
+ it('should return 0 when no active stories', async () => {
301
+ const total = await getStoryPointsByTeam(db, teamId);
300
302
  expect(total).toBe(0);
301
303
  });
302
304
  });
303
305
  describe('updateStory', () => {
304
- it('should update story title', () => {
305
- const story = createStory(db, {
306
+ it('should update story title', async () => {
307
+ const story = await createStory(db, {
306
308
  title: 'Original',
307
309
  description: 'Description',
308
310
  });
309
- const updated = updateStory(db, story.id, { title: 'Updated' });
311
+ const updated = await updateStory(db, story.id, { title: 'Updated' });
310
312
  expect(updated?.title).toBe('Updated');
311
313
  });
312
- it('should update story status', () => {
313
- const story = createStory(db, {
314
+ it('should update story status', async () => {
315
+ const story = await createStory(db, {
314
316
  title: 'Story',
315
317
  description: 'Description',
316
318
  });
317
- const updated = updateStory(db, story.id, { status: 'in_progress' });
319
+ const updated = await updateStory(db, story.id, { status: 'in_progress' });
318
320
  expect(updated?.status).toBe('in_progress');
319
321
  });
320
- it('should update complexity and story points', () => {
321
- const story = createStory(db, {
322
+ it('should update complexity and story points', async () => {
323
+ const story = await createStory(db, {
322
324
  title: 'Story',
323
325
  description: 'Description',
324
326
  });
325
- const updated = updateStory(db, story.id, {
327
+ const updated = await updateStory(db, story.id, {
326
328
  complexityScore: 8,
327
329
  storyPoints: 5,
328
330
  });
329
331
  expect(updated?.complexity_score).toBe(8);
330
332
  expect(updated?.story_points).toBe(5);
331
333
  });
332
- it('should update assigned agent', () => {
333
- const story = createStory(db, {
334
+ it('should update assigned agent', async () => {
335
+ const story = await createStory(db, {
334
336
  title: 'Story',
335
337
  description: 'Description',
336
338
  });
337
- const updated = updateStory(db, story.id, { assignedAgentId: agentId });
339
+ const updated = await updateStory(db, story.id, { assignedAgentId: agentId });
338
340
  expect(updated?.assigned_agent_id).toBe(agentId);
339
341
  });
340
- it('should update acceptance criteria', () => {
341
- const story = createStory(db, {
342
+ it('should update acceptance criteria', async () => {
343
+ const story = await createStory(db, {
342
344
  title: 'Story',
343
345
  description: 'Description',
344
346
  });
345
- const updated = updateStory(db, story.id, {
347
+ const updated = await updateStory(db, story.id, {
346
348
  acceptanceCriteria: ['New criterion 1', 'New criterion 2'],
347
349
  });
348
350
  expect(updated?.acceptance_criteria).toBe(JSON.stringify(['New criterion 1', 'New criterion 2']));
349
351
  });
350
- it('should update branch and PR info', () => {
351
- const story = createStory(db, {
352
+ it('should update branch and PR info', async () => {
353
+ const story = await createStory(db, {
352
354
  title: 'Story',
353
355
  description: 'Description',
354
356
  });
355
- const updated = updateStory(db, story.id, {
357
+ const updated = await updateStory(db, story.id, {
356
358
  branchName: 'feature/test-branch',
357
359
  prUrl: 'https://github.com/test/repo/pull/123',
358
360
  });
359
361
  expect(updated?.branch_name).toBe('feature/test-branch');
360
362
  expect(updated?.pr_url).toBe('https://github.com/test/repo/pull/123');
361
363
  });
362
- it('should update multiple fields at once', () => {
363
- const story = createStory(db, {
364
+ it('should update multiple fields at once', async () => {
365
+ const story = await createStory(db, {
364
366
  title: 'Original',
365
367
  description: 'Original description',
366
368
  });
367
- const updated = updateStory(db, story.id, {
369
+ const updated = await updateStory(db, story.id, {
368
370
  title: 'Updated',
369
371
  description: 'Updated description',
370
372
  status: 'in_progress',
@@ -375,25 +377,25 @@ describe('stories queries', () => {
375
377
  expect(updated?.status).toBe('in_progress');
376
378
  expect(updated?.assigned_agent_id).toBe(agentId);
377
379
  });
378
- it('should return story when no updates provided', () => {
379
- const story = createStory(db, {
380
+ it('should return story when no updates provided', async () => {
381
+ const story = await createStory(db, {
380
382
  title: 'Story',
381
383
  description: 'Description',
382
384
  });
383
- const updated = updateStory(db, story.id, {});
385
+ const updated = await updateStory(db, story.id, {});
384
386
  expect(updated?.id).toBe(story.id);
385
387
  });
386
- it('should return undefined for non-existent story', () => {
387
- const updated = updateStory(db, 'non-existent-id', { title: 'Updated' });
388
+ it('should return undefined for non-existent story', async () => {
389
+ const updated = await updateStory(db, 'non-existent-id', { title: 'Updated' });
388
390
  expect(updated).toBeUndefined();
389
391
  });
390
- it('should handle setting fields to null', () => {
391
- const story = createStory(db, {
392
+ it('should handle setting fields to null', async () => {
393
+ const story = await createStory(db, {
392
394
  title: 'Story',
393
395
  description: 'Description',
394
396
  teamId,
395
397
  });
396
- const updated = updateStory(db, story.id, {
398
+ const updated = await updateStory(db, story.id, {
397
399
  teamId: null,
398
400
  acceptanceCriteria: null,
399
401
  });
@@ -402,120 +404,120 @@ describe('stories queries', () => {
402
404
  });
403
405
  });
404
406
  describe('deleteStory', () => {
405
- it('should delete a story', () => {
406
- const story = createStory(db, {
407
+ it('should delete a story', async () => {
408
+ const story = await createStory(db, {
407
409
  title: 'To Delete',
408
410
  description: 'Description',
409
411
  });
410
- deleteStory(db, story.id);
411
- const retrieved = getStoryById(db, story.id);
412
+ await deleteStory(db, story.id);
413
+ const retrieved = await getStoryById(db, story.id);
412
414
  expect(retrieved).toBeUndefined();
413
415
  });
414
- it('should delete story dependencies when deleting story', () => {
415
- const story1 = createStory(db, {
416
+ it('should delete story dependencies when deleting story', async () => {
417
+ const story1 = await createStory(db, {
416
418
  title: 'Story 1',
417
419
  description: 'Description',
418
420
  });
419
- const story2 = createStory(db, {
421
+ const story2 = await createStory(db, {
420
422
  title: 'Story 2',
421
423
  description: 'Description',
422
424
  });
423
- addStoryDependency(db, story2.id, story1.id);
424
- deleteStory(db, story1.id);
425
- const dependencies = getStoryDependencies(db, story2.id);
425
+ await addStoryDependency(db, story2.id, story1.id);
426
+ await deleteStory(db, story1.id);
427
+ const dependencies = await getStoryDependencies(db, story2.id);
426
428
  expect(dependencies).toEqual([]);
427
429
  });
428
- it('should not throw when deleting non-existent story', () => {
429
- expect(() => deleteStory(db, 'non-existent-id')).not.toThrow();
430
+ it('should not throw when deleting non-existent story', async () => {
431
+ await expect(deleteStory(db, 'non-existent-id')).resolves.not.toThrow();
430
432
  });
431
433
  });
432
434
  describe('story dependencies', () => {
433
- it('should add a story dependency', () => {
434
- const story1 = createStory(db, {
435
+ it('should add a story dependency', async () => {
436
+ const story1 = await createStory(db, {
435
437
  title: 'Story 1',
436
438
  description: 'Description',
437
439
  });
438
- const story2 = createStory(db, {
440
+ const story2 = await createStory(db, {
439
441
  title: 'Story 2',
440
442
  description: 'Description',
441
443
  });
442
- addStoryDependency(db, story2.id, story1.id);
443
- const dependencies = getStoryDependencies(db, story2.id);
444
+ await addStoryDependency(db, story2.id, story1.id);
445
+ const dependencies = await getStoryDependencies(db, story2.id);
444
446
  expect(dependencies).toHaveLength(1);
445
447
  expect(dependencies[0].id).toBe(story1.id);
446
448
  });
447
- it('should not duplicate dependencies', () => {
448
- const story1 = createStory(db, {
449
+ it('should not duplicate dependencies', async () => {
450
+ const story1 = await createStory(db, {
449
451
  title: 'Story 1',
450
452
  description: 'Description',
451
453
  });
452
- const story2 = createStory(db, {
454
+ const story2 = await createStory(db, {
453
455
  title: 'Story 2',
454
456
  description: 'Description',
455
457
  });
456
- addStoryDependency(db, story2.id, story1.id);
457
- addStoryDependency(db, story2.id, story1.id);
458
- const dependencies = getStoryDependencies(db, story2.id);
458
+ await addStoryDependency(db, story2.id, story1.id);
459
+ await addStoryDependency(db, story2.id, story1.id);
460
+ const dependencies = await getStoryDependencies(db, story2.id);
459
461
  expect(dependencies).toHaveLength(1);
460
462
  });
461
- it('should remove a story dependency', () => {
462
- const story1 = createStory(db, {
463
+ it('should remove a story dependency', async () => {
464
+ const story1 = await createStory(db, {
463
465
  title: 'Story 1',
464
466
  description: 'Description',
465
467
  });
466
- const story2 = createStory(db, {
468
+ const story2 = await createStory(db, {
467
469
  title: 'Story 2',
468
470
  description: 'Description',
469
471
  });
470
- addStoryDependency(db, story2.id, story1.id);
471
- removeStoryDependency(db, story2.id, story1.id);
472
- const dependencies = getStoryDependencies(db, story2.id);
472
+ await addStoryDependency(db, story2.id, story1.id);
473
+ await removeStoryDependency(db, story2.id, story1.id);
474
+ const dependencies = await getStoryDependencies(db, story2.id);
473
475
  expect(dependencies).toEqual([]);
474
476
  });
475
- it('should get stories depending on a story', () => {
476
- const story1 = createStory(db, {
477
+ it('should get stories depending on a story', async () => {
478
+ const story1 = await createStory(db, {
477
479
  title: 'Base Story',
478
480
  description: 'Description',
479
481
  });
480
- const story2 = createStory(db, {
482
+ const story2 = await createStory(db, {
481
483
  title: 'Dependent 1',
482
484
  description: 'Description',
483
485
  });
484
- const story3 = createStory(db, {
486
+ const story3 = await createStory(db, {
485
487
  title: 'Dependent 2',
486
488
  description: 'Description',
487
489
  });
488
- addStoryDependency(db, story2.id, story1.id);
489
- addStoryDependency(db, story3.id, story1.id);
490
- const dependents = getStoriesDependingOn(db, story1.id);
490
+ await addStoryDependency(db, story2.id, story1.id);
491
+ await addStoryDependency(db, story3.id, story1.id);
492
+ const dependents = await getStoriesDependingOn(db, story1.id);
491
493
  expect(dependents).toHaveLength(2);
492
494
  expect(dependents.map(s => s.id)).toContain(story2.id);
493
495
  expect(dependents.map(s => s.id)).toContain(story3.id);
494
496
  });
495
497
  });
496
498
  describe('getStoryCounts', () => {
497
- it('should return counts by status', () => {
498
- createStory(db, { title: 'S1', description: 'D' }); // draft
499
- createStory(db, { title: 'S2', description: 'D' }); // draft
500
- const s3 = createStory(db, { title: 'S3', description: 'D' });
501
- updateStory(db, s3.id, { status: 'planned' });
502
- const s4 = createStory(db, { title: 'S4', description: 'D' });
503
- updateStory(db, s4.id, { status: 'in_progress' });
504
- const counts = getStoryCounts(db);
499
+ it('should return counts by status', async () => {
500
+ await createStory(db, { title: 'S1', description: 'D' }); // draft
501
+ await createStory(db, { title: 'S2', description: 'D' }); // draft
502
+ const s3 = await createStory(db, { title: 'S3', description: 'D' });
503
+ await updateStory(db, s3.id, { status: 'planned' });
504
+ const s4 = await createStory(db, { title: 'S4', description: 'D' });
505
+ await updateStory(db, s4.id, { status: 'in_progress' });
506
+ const counts = await getStoryCounts(db);
505
507
  expect(counts.draft).toBe(2);
506
508
  expect(counts.planned).toBe(1);
507
509
  expect(counts.in_progress).toBe(1);
508
510
  expect(counts.merged).toBe(0);
509
511
  });
510
- it('should return zero counts when no stories', () => {
511
- const counts = getStoryCounts(db);
512
+ it('should return zero counts when no stories', async () => {
513
+ const counts = await getStoryCounts(db);
512
514
  expect(counts.draft).toBe(0);
513
515
  expect(counts.estimated).toBe(0);
514
516
  expect(counts.planned).toBe(0);
515
517
  });
516
518
  });
517
519
  describe('edge cases', () => {
518
- it('should handle all story statuses', () => {
520
+ it('should handle all story statuses', async () => {
519
521
  const statuses = [
520
522
  'draft',
521
523
  'estimated',
@@ -527,31 +529,31 @@ describe('stories queries', () => {
527
529
  'pr_submitted',
528
530
  'merged',
529
531
  ];
530
- const story = createStory(db, {
532
+ const story = await createStory(db, {
531
533
  title: 'Test',
532
534
  description: 'Description',
533
535
  });
534
- statuses.forEach(status => {
535
- const updated = updateStory(db, story.id, { status });
536
+ for (const status of statuses) {
537
+ const updated = await updateStory(db, story.id, { status });
536
538
  expect(updated?.status).toBe(status);
537
- });
539
+ }
538
540
  });
539
- it('should handle very long text fields', () => {
541
+ it('should handle very long text fields', async () => {
540
542
  const longText = 'A'.repeat(100000);
541
- const story = createStory(db, {
543
+ const story = await createStory(db, {
542
544
  title: longText,
543
545
  description: longText,
544
546
  });
545
- const retrieved = getStoryById(db, story.id);
547
+ const retrieved = await getStoryById(db, story.id);
546
548
  expect(retrieved?.title).toBe(longText);
547
549
  expect(retrieved?.description).toBe(longText);
548
550
  });
549
- it('should handle special characters', () => {
550
- const story = createStory(db, {
551
+ it('should handle special characters', async () => {
552
+ const story = await createStory(db, {
551
553
  title: 'Title with \'quotes\' and "double"',
552
554
  description: 'Description with\nnewlines\tand\ttabs',
553
555
  });
554
- const retrieved = getStoryById(db, story.id);
556
+ const retrieved = await getStoryById(db, story.id);
555
557
  expect(retrieved?.title).toBe('Title with \'quotes\' and "double"');
556
558
  expect(retrieved?.description).toBe('Description with\nnewlines\tand\ttabs');
557
559
  });