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.
- package/dist/agents/base-agent.d.ts +11 -11
- package/dist/agents/base-agent.d.ts.map +1 -1
- package/dist/agents/base-agent.js +25 -25
- package/dist/agents/base-agent.js.map +1 -1
- package/dist/agents/base-agent.test.js +2 -1
- package/dist/agents/base-agent.test.js.map +1 -1
- package/dist/agents/intermediate.d.ts +2 -0
- package/dist/agents/intermediate.d.ts.map +1 -1
- package/dist/agents/intermediate.js +25 -18
- package/dist/agents/intermediate.js.map +1 -1
- package/dist/agents/junior.d.ts +2 -0
- package/dist/agents/junior.d.ts.map +1 -1
- package/dist/agents/junior.js +25 -18
- package/dist/agents/junior.js.map +1 -1
- package/dist/agents/qa.d.ts +2 -0
- package/dist/agents/qa.d.ts.map +1 -1
- package/dist/agents/qa.js +47 -38
- package/dist/agents/qa.js.map +1 -1
- package/dist/agents/senior.d.ts +2 -0
- package/dist/agents/senior.d.ts.map +1 -1
- package/dist/agents/senior.js +40 -27
- package/dist/agents/senior.js.map +1 -1
- package/dist/agents/tech-lead.d.ts +2 -0
- package/dist/agents/tech-lead.d.ts.map +1 -1
- package/dist/agents/tech-lead.js +37 -31
- package/dist/agents/tech-lead.js.map +1 -1
- package/dist/cli/commands/add-repo.js +2 -2
- package/dist/cli/commands/add-repo.js.map +1 -1
- package/dist/cli/commands/add-repo.test.js +1 -1
- package/dist/cli/commands/add-repo.test.js.map +1 -1
- package/dist/cli/commands/agents.d.ts.map +1 -1
- package/dist/cli/commands/agents.js +12 -10
- package/dist/cli/commands/agents.js.map +1 -1
- package/dist/cli/commands/agents.test.js +7 -7
- package/dist/cli/commands/agents.test.js.map +1 -1
- package/dist/cli/commands/approach.js +2 -2
- package/dist/cli/commands/approach.js.map +1 -1
- package/dist/cli/commands/approvals.js +7 -7
- package/dist/cli/commands/approvals.js.map +1 -1
- package/dist/cli/commands/approvals.test.js +8 -8
- package/dist/cli/commands/approvals.test.js.map +1 -1
- package/dist/cli/commands/assign.js +4 -4
- package/dist/cli/commands/assign.js.map +1 -1
- package/dist/cli/commands/assign.test.js +18 -16
- package/dist/cli/commands/assign.test.js.map +1 -1
- package/dist/cli/commands/cleanup.d.ts.map +1 -1
- package/dist/cli/commands/cleanup.js +8 -8
- package/dist/cli/commands/cleanup.js.map +1 -1
- package/dist/cli/commands/cleanup.test.js +5 -1
- package/dist/cli/commands/cleanup.test.js.map +1 -1
- package/dist/cli/commands/escalations.js +9 -7
- package/dist/cli/commands/escalations.js.map +1 -1
- package/dist/cli/commands/escalations.test.js +2 -2
- package/dist/cli/commands/escalations.test.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +48 -5
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/init.test.js +4 -0
- package/dist/cli/commands/init.test.js.map +1 -1
- package/dist/cli/commands/manager/agent-monitoring.d.ts +2 -2
- package/dist/cli/commands/manager/agent-monitoring.d.ts.map +1 -1
- package/dist/cli/commands/manager/agent-monitoring.js +1 -1
- package/dist/cli/commands/manager/agent-monitoring.js.map +1 -1
- package/dist/cli/commands/manager/auditor-lifecycle.js +3 -3
- package/dist/cli/commands/manager/auditor-lifecycle.js.map +1 -1
- package/dist/cli/commands/manager/auditor-lifecycle.test.js +21 -14
- package/dist/cli/commands/manager/auditor-lifecycle.test.js.map +1 -1
- package/dist/cli/commands/manager/auto-reject-comment-only-reviews.test.js +28 -23
- package/dist/cli/commands/manager/auto-reject-comment-only-reviews.test.js.map +1 -1
- package/dist/cli/commands/manager/escalation-handler.d.ts +2 -2
- package/dist/cli/commands/manager/escalation-handler.d.ts.map +1 -1
- package/dist/cli/commands/manager/escalation-handler.js +11 -10
- package/dist/cli/commands/manager/escalation-handler.js.map +1 -1
- package/dist/cli/commands/manager/escalation-handler.test.js +8 -8
- package/dist/cli/commands/manager/escalation-handler.test.js.map +1 -1
- package/dist/cli/commands/manager/feature-sign-off.js +7 -7
- package/dist/cli/commands/manager/feature-sign-off.js.map +1 -1
- package/dist/cli/commands/manager/feature-sign-off.test.js +40 -31
- package/dist/cli/commands/manager/feature-sign-off.test.js.map +1 -1
- package/dist/cli/commands/manager/feature-test-result.d.ts.map +1 -1
- package/dist/cli/commands/manager/feature-test-result.js +12 -13
- package/dist/cli/commands/manager/feature-test-result.js.map +1 -1
- package/dist/cli/commands/manager/handoff-recovery.d.ts.map +1 -1
- package/dist/cli/commands/manager/handoff-recovery.js +14 -15
- package/dist/cli/commands/manager/handoff-recovery.js.map +1 -1
- package/dist/cli/commands/manager/index.d.ts.map +1 -1
- package/dist/cli/commands/manager/index.js +26 -26
- package/dist/cli/commands/manager/index.js.map +1 -1
- package/dist/cli/commands/manager/index.test.js +3 -3
- package/dist/cli/commands/manager/index.test.js.map +1 -1
- package/dist/cli/commands/manager/merged-story-cleanup.d.ts +2 -2
- package/dist/cli/commands/manager/merged-story-cleanup.d.ts.map +1 -1
- package/dist/cli/commands/manager/merged-story-cleanup.js +6 -7
- package/dist/cli/commands/manager/merged-story-cleanup.js.map +1 -1
- package/dist/cli/commands/manager/merged-story-cleanup.test.js +27 -18
- package/dist/cli/commands/manager/merged-story-cleanup.test.js.map +1 -1
- package/dist/cli/commands/manager/pr-sync-orchestrator.d.ts.map +1 -1
- package/dist/cli/commands/manager/pr-sync-orchestrator.js +46 -38
- package/dist/cli/commands/manager/pr-sync-orchestrator.js.map +1 -1
- package/dist/cli/commands/manager/qa-review-handler.d.ts.map +1 -1
- package/dist/cli/commands/manager/qa-review-handler.js +25 -22
- package/dist/cli/commands/manager/qa-review-handler.js.map +1 -1
- package/dist/cli/commands/manager/spin-down.d.ts.map +1 -1
- package/dist/cli/commands/manager/spin-down.js +23 -19
- package/dist/cli/commands/manager/spin-down.js.map +1 -1
- package/dist/cli/commands/manager/stale-escalations.d.ts +2 -3
- package/dist/cli/commands/manager/stale-escalations.d.ts.map +1 -1
- package/dist/cli/commands/manager/stale-escalations.js.map +1 -1
- package/dist/cli/commands/manager/stuck-story-helpers.js +8 -8
- package/dist/cli/commands/manager/stuck-story-helpers.js.map +1 -1
- package/dist/cli/commands/manager/stuck-story-processor.d.ts +2 -2
- package/dist/cli/commands/manager/stuck-story-processor.d.ts.map +1 -1
- package/dist/cli/commands/manager/stuck-story-processor.js +23 -22
- package/dist/cli/commands/manager/stuck-story-processor.js.map +1 -1
- package/dist/cli/commands/manager/tech-lead-lifecycle.js +6 -6
- package/dist/cli/commands/manager/tech-lead-lifecycle.js.map +1 -1
- package/dist/cli/commands/manager/types.d.ts +2 -3
- package/dist/cli/commands/manager/types.d.ts.map +1 -1
- package/dist/cli/commands/manager/types.js.map +1 -1
- package/dist/cli/commands/msg.test.js +2 -2
- package/dist/cli/commands/msg.test.js.map +1 -1
- package/dist/cli/commands/my-stories.d.ts.map +1 -1
- package/dist/cli/commands/my-stories.js +17 -18
- package/dist/cli/commands/my-stories.js.map +1 -1
- package/dist/cli/commands/my-stories.test.js +2 -2
- package/dist/cli/commands/my-stories.test.js.map +1 -1
- package/dist/cli/commands/nuke.test.js +1 -1
- package/dist/cli/commands/nuke.test.js.map +1 -1
- package/dist/cli/commands/pr.js +32 -32
- package/dist/cli/commands/pr.js.map +1 -1
- package/dist/cli/commands/pr.test.js +10 -6
- package/dist/cli/commands/pr.test.js.map +1 -1
- package/dist/cli/commands/progress.d.ts.map +1 -1
- package/dist/cli/commands/progress.js +4 -5
- package/dist/cli/commands/progress.js.map +1 -1
- package/dist/cli/commands/progress.test.js +1 -1
- package/dist/cli/commands/progress.test.js.map +1 -1
- package/dist/cli/commands/req-headless.test.d.ts +2 -0
- package/dist/cli/commands/req-headless.test.d.ts.map +1 -0
- package/dist/cli/commands/req-headless.test.js +128 -0
- package/dist/cli/commands/req-headless.test.js.map +1 -0
- package/dist/cli/commands/req-spawn.test.js +5 -1
- package/dist/cli/commands/req-spawn.test.js.map +1 -1
- package/dist/cli/commands/req.d.ts.map +1 -1
- package/dist/cli/commands/req.js +13 -14
- package/dist/cli/commands/req.js.map +1 -1
- package/dist/cli/commands/resume.d.ts.map +1 -1
- package/dist/cli/commands/resume.js +7 -8
- package/dist/cli/commands/resume.js.map +1 -1
- package/dist/cli/commands/resume.test.js +1 -1
- package/dist/cli/commands/resume.test.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +42 -40
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/status.test.js +1 -1
- package/dist/cli/commands/status.test.js.map +1 -1
- package/dist/cli/commands/stories.js +9 -9
- package/dist/cli/commands/stories.js.map +1 -1
- package/dist/cli/commands/stories.test.js +2 -2
- package/dist/cli/commands/stories.test.js.map +1 -1
- package/dist/cli/commands/teams.js +11 -11
- package/dist/cli/commands/teams.js.map +1 -1
- package/dist/cli/commands/teams.test.js +2 -2
- package/dist/cli/commands/teams.test.js.map +1 -1
- package/dist/cli/dashboard/index.d.ts +2 -2
- package/dist/cli/dashboard/index.d.ts.map +1 -1
- package/dist/cli/dashboard/index.js +29 -20
- package/dist/cli/dashboard/index.js.map +1 -1
- package/dist/cli/dashboard/index.test.js +34 -32
- package/dist/cli/dashboard/index.test.js.map +1 -1
- package/dist/cli/dashboard/panels/activity.d.ts +3 -3
- package/dist/cli/dashboard/panels/activity.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/activity.js +1 -1
- package/dist/cli/dashboard/panels/activity.js.map +1 -1
- package/dist/cli/dashboard/panels/agents.d.ts +3 -3
- package/dist/cli/dashboard/panels/agents.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/agents.js +2 -2
- package/dist/cli/dashboard/panels/agents.js.map +1 -1
- package/dist/cli/dashboard/panels/escalations.d.ts +3 -3
- package/dist/cli/dashboard/panels/escalations.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/escalations.js +1 -1
- package/dist/cli/dashboard/panels/escalations.js.map +1 -1
- package/dist/cli/dashboard/panels/merge-queue.d.ts +3 -3
- package/dist/cli/dashboard/panels/merge-queue.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/merge-queue.js +1 -1
- package/dist/cli/dashboard/panels/merge-queue.js.map +1 -1
- package/dist/cli/dashboard/panels/pipeline.d.ts +3 -3
- package/dist/cli/dashboard/panels/pipeline.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/pipeline.js +1 -1
- package/dist/cli/dashboard/panels/pipeline.js.map +1 -1
- package/dist/config/schema.d.ts +85 -82
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +1 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/connectors/project-management/operations.d.ts +7 -7
- package/dist/connectors/project-management/operations.d.ts.map +1 -1
- package/dist/connectors/project-management/operations.js +2 -3
- package/dist/connectors/project-management/operations.js.map +1 -1
- package/dist/context-files/index.test.js +1 -0
- package/dist/context-files/index.test.js.map +1 -1
- package/dist/db/client.d.ts +6 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +7 -0
- package/dist/db/client.js.map +1 -1
- package/dist/db/postgres-provider.d.ts +43 -0
- package/dist/db/postgres-provider.d.ts.map +1 -0
- package/dist/db/postgres-provider.integration.test.d.ts +2 -0
- package/dist/db/postgres-provider.integration.test.d.ts.map +1 -0
- package/dist/db/postgres-provider.integration.test.js +399 -0
- package/dist/db/postgres-provider.integration.test.js.map +1 -0
- package/dist/db/postgres-provider.js +315 -0
- package/dist/db/postgres-provider.js.map +1 -0
- package/dist/db/postgres-provider.test.d.ts +2 -0
- package/dist/db/postgres-provider.test.d.ts.map +1 -0
- package/dist/db/postgres-provider.test.js +72 -0
- package/dist/db/postgres-provider.test.js.map +1 -0
- package/dist/db/provider.d.ts +59 -0
- package/dist/db/provider.d.ts.map +1 -0
- package/dist/db/provider.js +121 -0
- package/dist/db/provider.js.map +1 -0
- package/dist/db/provider.test.d.ts +2 -0
- package/dist/db/provider.test.d.ts.map +1 -0
- package/dist/db/provider.test.js +226 -0
- package/dist/db/provider.test.js.map +1 -0
- package/dist/db/queries/agents.d.ts +13 -13
- package/dist/db/queries/agents.d.ts.map +1 -1
- package/dist/db/queries/agents.js +27 -28
- package/dist/db/queries/agents.js.map +1 -1
- package/dist/db/queries/agents.test.js +113 -111
- package/dist/db/queries/agents.test.js.map +1 -1
- package/dist/db/queries/escalations.d.ts +16 -16
- package/dist/db/queries/escalations.d.ts.map +1 -1
- package/dist/db/queries/escalations.js +34 -35
- package/dist/db/queries/escalations.js.map +1 -1
- package/dist/db/queries/escalations.test.js +133 -131
- package/dist/db/queries/escalations.test.js.map +1 -1
- package/dist/db/queries/heartbeat.d.ts +5 -5
- package/dist/db/queries/heartbeat.d.ts.map +1 -1
- package/dist/db/queries/heartbeat.js +7 -23
- package/dist/db/queries/heartbeat.js.map +1 -1
- package/dist/db/queries/heartbeat.test.js +76 -76
- package/dist/db/queries/heartbeat.test.js.map +1 -1
- package/dist/db/queries/integration-sync.d.ts +7 -7
- package/dist/db/queries/integration-sync.d.ts.map +1 -1
- package/dist/db/queries/integration-sync.js +13 -14
- package/dist/db/queries/integration-sync.js.map +1 -1
- package/dist/db/queries/logs.d.ts +10 -10
- package/dist/db/queries/logs.d.ts.map +1 -1
- package/dist/db/queries/logs.js +44 -42
- package/dist/db/queries/logs.js.map +1 -1
- package/dist/db/queries/logs.test.js +149 -146
- package/dist/db/queries/logs.test.js.map +1 -1
- package/dist/db/queries/messages.d.ts +6 -6
- package/dist/db/queries/messages.d.ts.map +1 -1
- package/dist/db/queries/messages.js +12 -11
- package/dist/db/queries/messages.js.map +1 -1
- package/dist/db/queries/messages.test.js +47 -46
- package/dist/db/queries/messages.test.js.map +1 -1
- package/dist/db/queries/pull-requests.d.ts +18 -18
- package/dist/db/queries/pull-requests.d.ts.map +1 -1
- package/dist/db/queries/pull-requests.js +50 -48
- package/dist/db/queries/pull-requests.js.map +1 -1
- package/dist/db/queries/pull-requests.test.js +195 -198
- package/dist/db/queries/pull-requests.test.js.map +1 -1
- package/dist/db/queries/requirements.d.ts +8 -8
- package/dist/db/queries/requirements.d.ts.map +1 -1
- package/dist/db/queries/requirements.js +17 -18
- package/dist/db/queries/requirements.js.map +1 -1
- package/dist/db/queries/requirements.test.js +83 -81
- package/dist/db/queries/requirements.test.js.map +1 -1
- package/dist/db/queries/stories.d.ts +29 -29
- package/dist/db/queries/stories.d.ts.map +1 -1
- package/dist/db/queries/stories.js +58 -64
- package/dist/db/queries/stories.js.map +1 -1
- package/dist/db/queries/stories.test.js +172 -170
- package/dist/db/queries/stories.test.js.map +1 -1
- package/dist/db/queries/teams.d.ts +6 -6
- package/dist/db/queries/teams.d.ts.map +1 -1
- package/dist/db/queries/teams.js +11 -12
- package/dist/db/queries/teams.js.map +1 -1
- package/dist/db/queries/teams.test.js +36 -34
- package/dist/db/queries/teams.test.js.map +1 -1
- package/dist/integrations/jira/repair.test.js +26 -24
- package/dist/integrations/jira/repair.test.js.map +1 -1
- package/dist/integrations/jira/stories.d.ts +3 -3
- package/dist/integrations/jira/stories.d.ts.map +1 -1
- package/dist/integrations/jira/stories.js +12 -12
- package/dist/integrations/jira/stories.js.map +1 -1
- package/dist/integrations/jira/stories.test.js +10 -8
- package/dist/integrations/jira/stories.test.js.map +1 -1
- package/dist/integrations/jira/sync.d.ts +7 -7
- package/dist/integrations/jira/sync.d.ts.map +1 -1
- package/dist/integrations/jira/sync.js +17 -20
- package/dist/integrations/jira/sync.js.map +1 -1
- package/dist/integrations/jira/sync.test.js +63 -62
- package/dist/integrations/jira/sync.test.js.map +1 -1
- package/dist/integrations/jira/transitions.d.ts +3 -3
- package/dist/integrations/jira/transitions.d.ts.map +1 -1
- package/dist/integrations/jira/transitions.js +3 -3
- package/dist/integrations/jira/transitions.js.map +1 -1
- package/dist/orchestrator/agent-selector.d.ts +3 -3
- package/dist/orchestrator/agent-selector.d.ts.map +1 -1
- package/dist/orchestrator/agent-selector.js +5 -6
- package/dist/orchestrator/agent-selector.js.map +1 -1
- package/dist/orchestrator/dependency-resolver.d.ts +4 -4
- package/dist/orchestrator/dependency-resolver.d.ts.map +1 -1
- package/dist/orchestrator/dependency-resolver.js +6 -6
- package/dist/orchestrator/dependency-resolver.js.map +1 -1
- package/dist/orchestrator/feature-branch.d.ts +3 -3
- package/dist/orchestrator/feature-branch.d.ts.map +1 -1
- package/dist/orchestrator/feature-branch.js +9 -10
- package/dist/orchestrator/feature-branch.js.map +1 -1
- package/dist/orchestrator/feature-branch.test.js +80 -78
- package/dist/orchestrator/feature-branch.test.js.map +1 -1
- package/dist/orchestrator/orphan-recovery.d.ts +2 -2
- package/dist/orchestrator/orphan-recovery.d.ts.map +1 -1
- package/dist/orchestrator/orphan-recovery.js +10 -10
- package/dist/orchestrator/orphan-recovery.js.map +1 -1
- package/dist/orchestrator/scheduler.d.ts +4 -4
- package/dist/orchestrator/scheduler.d.ts.map +1 -1
- package/dist/orchestrator/scheduler.js +90 -76
- package/dist/orchestrator/scheduler.js.map +1 -1
- package/dist/orchestrator/scheduler.test.js +496 -374
- package/dist/orchestrator/scheduler.test.js.map +1 -1
- package/dist/utils/auto-merge.d.ts.map +1 -1
- package/dist/utils/auto-merge.js +74 -56
- package/dist/utils/auto-merge.js.map +1 -1
- package/dist/utils/auto-merge.test.js +101 -66
- package/dist/utils/auto-merge.test.js.map +1 -1
- package/dist/utils/cli-helpers.d.ts +5 -5
- package/dist/utils/cli-helpers.d.ts.map +1 -1
- package/dist/utils/cli-helpers.js +8 -9
- package/dist/utils/cli-helpers.js.map +1 -1
- package/dist/utils/cli-helpers.test.js +28 -30
- package/dist/utils/cli-helpers.test.js.map +1 -1
- package/dist/utils/paths.d.ts +6 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +12 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/paths.test.js +1 -0
- package/dist/utils/paths.test.js.map +1 -1
- package/dist/utils/pr-sync.d.ts +10 -10
- package/dist/utils/pr-sync.d.ts.map +1 -1
- package/dist/utils/pr-sync.js +20 -21
- package/dist/utils/pr-sync.js.map +1 -1
- package/dist/utils/pr-sync.test.js +52 -50
- package/dist/utils/pr-sync.test.js.map +1 -1
- package/dist/utils/with-hive-context.d.ts.map +1 -1
- package/dist/utils/with-hive-context.js +70 -1
- package/dist/utils/with-hive-context.js.map +1 -1
- package/package.json +3 -1
- package/src/agents/base-agent.test.ts +2 -1
- package/src/agents/base-agent.ts +32 -28
- package/src/agents/intermediate.ts +27 -18
- package/src/agents/junior.ts +27 -18
- package/src/agents/qa.ts +54 -40
- package/src/agents/senior.ts +42 -27
- package/src/agents/tech-lead.ts +42 -32
- package/src/cli/commands/add-repo.test.ts +1 -1
- package/src/cli/commands/add-repo.ts +2 -2
- package/src/cli/commands/agents.test.ts +7 -7
- package/src/cli/commands/agents.ts +12 -10
- package/src/cli/commands/approach.ts +2 -2
- package/src/cli/commands/approvals.test.ts +8 -8
- package/src/cli/commands/approvals.ts +9 -7
- package/src/cli/commands/assign.test.ts +19 -18
- package/src/cli/commands/assign.ts +4 -4
- package/src/cli/commands/cleanup.test.ts +5 -1
- package/src/cli/commands/cleanup.ts +11 -9
- package/src/cli/commands/escalations.test.ts +2 -2
- package/src/cli/commands/escalations.ts +9 -7
- package/src/cli/commands/init.test.ts +5 -0
- package/src/cli/commands/init.ts +53 -5
- package/src/cli/commands/manager/agent-monitoring.ts +3 -3
- package/src/cli/commands/manager/auditor-lifecycle.test.ts +21 -14
- package/src/cli/commands/manager/auditor-lifecycle.ts +3 -3
- package/src/cli/commands/manager/auto-reject-comment-only-reviews.test.ts +28 -23
- package/src/cli/commands/manager/escalation-handler.test.ts +13 -13
- package/src/cli/commands/manager/escalation-handler.ts +19 -12
- package/src/cli/commands/manager/feature-sign-off.test.ts +40 -31
- package/src/cli/commands/manager/feature-sign-off.ts +7 -7
- package/src/cli/commands/manager/feature-test-result.ts +13 -16
- package/src/cli/commands/manager/handoff-recovery.ts +20 -20
- package/src/cli/commands/manager/index.test.ts +4 -4
- package/src/cli/commands/manager/index.ts +58 -59
- package/src/cli/commands/manager/merged-story-cleanup.test.ts +28 -19
- package/src/cli/commands/manager/merged-story-cleanup.ts +11 -14
- package/src/cli/commands/manager/pr-sync-orchestrator.ts +115 -110
- package/src/cli/commands/manager/qa-review-handler.ts +50 -63
- package/src/cli/commands/manager/spin-down.ts +27 -25
- package/src/cli/commands/manager/stale-escalations.ts +2 -3
- package/src/cli/commands/manager/stuck-story-helpers.ts +10 -10
- package/src/cli/commands/manager/stuck-story-processor.ts +56 -62
- package/src/cli/commands/manager/tech-lead-lifecycle.ts +6 -6
- package/src/cli/commands/manager/types.ts +2 -3
- package/src/cli/commands/msg.test.ts +2 -2
- package/src/cli/commands/my-stories.test.ts +4 -2
- package/src/cli/commands/my-stories.ts +22 -27
- package/src/cli/commands/nuke.test.ts +1 -1
- package/src/cli/commands/pr.test.ts +10 -6
- package/src/cli/commands/pr.ts +41 -32
- package/src/cli/commands/progress.test.ts +1 -1
- package/src/cli/commands/progress.ts +11 -6
- package/src/cli/commands/req-headless.test.ts +170 -0
- package/src/cli/commands/req-spawn.test.ts +12 -2
- package/src/cli/commands/req.ts +13 -14
- package/src/cli/commands/resume.test.ts +1 -1
- package/src/cli/commands/resume.ts +7 -8
- package/src/cli/commands/status.test.ts +1 -1
- package/src/cli/commands/status.ts +52 -40
- package/src/cli/commands/stories.test.ts +4 -2
- package/src/cli/commands/stories.ts +11 -11
- package/src/cli/commands/teams.test.ts +2 -2
- package/src/cli/commands/teams.ts +11 -11
- package/src/cli/dashboard/index.test.ts +35 -34
- package/src/cli/dashboard/index.ts +34 -23
- package/src/cli/dashboard/panels/activity.ts +10 -4
- package/src/cli/dashboard/panels/agents.ts +8 -5
- package/src/cli/dashboard/panels/escalations.ts +4 -4
- package/src/cli/dashboard/panels/merge-queue.ts +4 -4
- package/src/cli/dashboard/panels/pipeline.ts +10 -4
- package/src/config/schema.ts +1 -0
- package/src/connectors/project-management/operations.ts +9 -10
- package/src/context-files/index.test.ts +1 -0
- package/src/db/client.ts +17 -0
- package/src/db/pg-migrations/001-full-schema.sql +209 -0
- package/src/db/postgres-provider.integration.test.ts +574 -0
- package/src/db/postgres-provider.test.ts +97 -0
- package/src/db/postgres-provider.ts +364 -0
- package/src/db/provider.test.ts +283 -0
- package/src/db/provider.ts +161 -0
- package/src/db/queries/agents.test.ts +114 -113
- package/src/db/queries/agents.ts +50 -36
- package/src/db/queries/escalations.test.ts +134 -133
- package/src/db/queries/escalations.ts +72 -57
- package/src/db/queries/heartbeat.test.ts +77 -78
- package/src/db/queries/heartbeat.ts +24 -46
- package/src/db/queries/integration-sync.ts +26 -26
- package/src/db/queries/logs.test.ts +151 -148
- package/src/db/queries/logs.ts +78 -53
- package/src/db/queries/messages.test.ts +48 -50
- package/src/db/queries/messages.ts +26 -18
- package/src/db/queries/pull-requests.test.ts +194 -199
- package/src/db/queries/pull-requests.ts +117 -88
- package/src/db/queries/requirements.test.ts +84 -83
- package/src/db/queries/requirements.ts +33 -28
- package/src/db/queries/stories.test.ts +173 -172
- package/src/db/queries/stories.ts +141 -110
- package/src/db/queries/teams.test.ts +37 -36
- package/src/db/queries/teams.ts +22 -14
- package/src/integrations/jira/repair.test.ts +27 -26
- package/src/integrations/jira/stories.test.ts +15 -16
- package/src/integrations/jira/stories.ts +15 -15
- package/src/integrations/jira/sync.test.ts +68 -68
- package/src/integrations/jira/sync.ts +29 -39
- package/src/integrations/jira/transitions.ts +6 -6
- package/src/orchestrator/agent-selector.ts +9 -8
- package/src/orchestrator/dependency-resolver.ts +16 -7
- package/src/orchestrator/feature-branch.test.ts +85 -80
- package/src/orchestrator/feature-branch.ts +13 -14
- package/src/orchestrator/orphan-recovery.ts +14 -13
- package/src/orchestrator/scheduler.test.ts +536 -394
- package/src/orchestrator/scheduler.ts +129 -115
- package/src/utils/auto-merge.test.ts +102 -68
- package/src/utils/auto-merge.ts +161 -168
- package/src/utils/cli-helpers.test.ts +30 -32
- package/src/utils/cli-helpers.ts +15 -11
- package/src/utils/paths.test.ts +1 -0
- package/src/utils/paths.ts +14 -1
- package/src/utils/pr-sync.test.ts +55 -52
- package/src/utils/pr-sync.ts +27 -32
- package/src/utils/with-hive-context.ts +89 -1
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
|
|
3
3
|
import { join } from 'path';
|
|
4
|
-
import type { Database } from 'sql.js';
|
|
5
4
|
import { loadEnvIntoProcess } from '../../auth/env-store.js';
|
|
6
5
|
import { TokenStore } from '../../auth/token-store.js';
|
|
7
6
|
import { loadConfig } from '../../config/loader.js';
|
|
8
7
|
import type { JiraConfig } from '../../config/schema.js';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
queryOne,
|
|
12
|
-
withTransaction,
|
|
13
|
-
type RequirementRow,
|
|
14
|
-
type StoryRow,
|
|
15
|
-
} from '../../db/client.js';
|
|
8
|
+
import { type RequirementRow, type StoryRow } from '../../db/client.js';
|
|
9
|
+
import type { DatabaseProvider } from '../../db/provider.js';
|
|
16
10
|
import { getAgentById } from '../../db/queries/agents.js';
|
|
17
11
|
import { createLog } from '../../db/queries/logs.js';
|
|
18
12
|
import { getStoryById, updateStory, type StoryStatus } from '../../db/queries/stories.js';
|
|
@@ -79,7 +73,7 @@ function createJiraClient(tokenStore: TokenStore): JiraClient {
|
|
|
79
73
|
* @returns Number of stories acted upon
|
|
80
74
|
*/
|
|
81
75
|
async function processBidirectionalStatusSync(
|
|
82
|
-
db:
|
|
76
|
+
db: DatabaseProvider,
|
|
83
77
|
client: JiraClient,
|
|
84
78
|
config: JiraConfig,
|
|
85
79
|
stories: StoryRow[],
|
|
@@ -110,7 +104,7 @@ async function processBidirectionalStatusSync(
|
|
|
110
104
|
} catch (err) {
|
|
111
105
|
const message = err instanceof Error ? err.message : String(err);
|
|
112
106
|
logger.warn(`Failed to sync Jira status for story ${story.id} (${issueKey}): ${message}`);
|
|
113
|
-
createLog(db, {
|
|
107
|
+
await createLog(db, {
|
|
114
108
|
agentId: 'manager',
|
|
115
109
|
storyId: story.id,
|
|
116
110
|
eventType: 'JIRA_SYNC_WARNING',
|
|
@@ -134,7 +128,7 @@ async function processBidirectionalStatusSync(
|
|
|
134
128
|
* @returns Number of stories updated
|
|
135
129
|
*/
|
|
136
130
|
export async function syncJiraStatusesToHive(
|
|
137
|
-
db:
|
|
131
|
+
db: DatabaseProvider,
|
|
138
132
|
tokenStore: TokenStore,
|
|
139
133
|
config: JiraConfig
|
|
140
134
|
): Promise<number> {
|
|
@@ -145,8 +139,7 @@ export async function syncJiraStatusesToHive(
|
|
|
145
139
|
}
|
|
146
140
|
|
|
147
141
|
// Fetch all stories that have an external issue key (provider-agnostic query)
|
|
148
|
-
const storiesWithJira = queryAll<StoryRow>(
|
|
149
|
-
db,
|
|
142
|
+
const storiesWithJira = await db.queryAll<StoryRow>(
|
|
150
143
|
`SELECT * FROM stories WHERE external_issue_key IS NOT NULL AND status NOT IN ('merged')`
|
|
151
144
|
);
|
|
152
145
|
|
|
@@ -183,10 +176,10 @@ export async function syncJiraStatusesToHive(
|
|
|
183
176
|
}
|
|
184
177
|
|
|
185
178
|
// Update the story status in Hive
|
|
186
|
-
await withTransaction(
|
|
187
|
-
updateStory(db, story.id, { status: mappedHiveStatus as StoryStatus });
|
|
179
|
+
await db.withTransaction(async () => {
|
|
180
|
+
await updateStory(db, story.id, { status: mappedHiveStatus as StoryStatus });
|
|
188
181
|
|
|
189
|
-
createLog(db, {
|
|
182
|
+
await createLog(db, {
|
|
190
183
|
agentId: 'manager',
|
|
191
184
|
storyId: story.id,
|
|
192
185
|
eventType: 'JIRA_SYNC_COMPLETED',
|
|
@@ -222,13 +215,12 @@ export async function syncJiraStatusesToHive(
|
|
|
222
215
|
* @returns Number of stories synced to Jira
|
|
223
216
|
*/
|
|
224
217
|
export async function syncUnsyncedStoriesToJira(
|
|
225
|
-
db:
|
|
218
|
+
db: DatabaseProvider,
|
|
226
219
|
tokenStore: TokenStore,
|
|
227
220
|
config: JiraConfig
|
|
228
221
|
): Promise<number> {
|
|
229
222
|
// Find stories that have no external_issue_key but are not in draft status
|
|
230
|
-
const unsyncedStories = queryAll<StoryRow>(
|
|
231
|
-
db,
|
|
223
|
+
const unsyncedStories = await db.queryAll<StoryRow>(
|
|
232
224
|
`SELECT * FROM stories WHERE external_issue_key IS NULL AND status NOT IN ('draft') ORDER BY requirement_id, id`
|
|
233
225
|
);
|
|
234
226
|
|
|
@@ -257,9 +249,10 @@ export async function syncUnsyncedStoriesToJira(
|
|
|
257
249
|
continue;
|
|
258
250
|
}
|
|
259
251
|
|
|
260
|
-
const requirement = queryOne<RequirementRow>(
|
|
261
|
-
|
|
262
|
-
|
|
252
|
+
const requirement = await db.queryOne<RequirementRow>(
|
|
253
|
+
`SELECT * FROM requirements WHERE id = ?`,
|
|
254
|
+
[requirementId]
|
|
255
|
+
);
|
|
263
256
|
|
|
264
257
|
if (!requirement) {
|
|
265
258
|
logger.warn(`Requirement ${requirementId} not found, skipping ${stories.length} stories`);
|
|
@@ -273,7 +266,7 @@ export async function syncUnsyncedStoriesToJira(
|
|
|
273
266
|
// (another sync cycle may have updated it since our initial query)
|
|
274
267
|
const confirmedStoryIds: string[] = [];
|
|
275
268
|
for (const s of stories) {
|
|
276
|
-
const fresh = getStoryById(db, s.id);
|
|
269
|
+
const fresh = await getStoryById(db, s.id);
|
|
277
270
|
if (fresh && !fresh.jira_issue_key) {
|
|
278
271
|
confirmedStoryIds.push(s.id);
|
|
279
272
|
} else {
|
|
@@ -336,7 +329,7 @@ export async function syncUnsyncedStoriesToJira(
|
|
|
336
329
|
* @returns Number of stories repaired
|
|
337
330
|
*/
|
|
338
331
|
export async function repairMissedAssignmentHooks(
|
|
339
|
-
db:
|
|
332
|
+
db: DatabaseProvider,
|
|
340
333
|
tokenStore: TokenStore,
|
|
341
334
|
config: JiraConfig
|
|
342
335
|
): Promise<number> {
|
|
@@ -344,8 +337,7 @@ export async function repairMissedAssignmentHooks(
|
|
|
344
337
|
// - Have an external_issue_key (synced to a PM provider)
|
|
345
338
|
// - Have an assigned_agent_id (assigned to an agent)
|
|
346
339
|
// - But are missing an external_subtask_key (subtask never created)
|
|
347
|
-
const storiesMissingSubtasks = queryAll<StoryRow>(
|
|
348
|
-
db,
|
|
340
|
+
const storiesMissingSubtasks = await db.queryAll<StoryRow>(
|
|
349
341
|
`SELECT * FROM stories
|
|
350
342
|
WHERE external_issue_key IS NOT NULL
|
|
351
343
|
AND assigned_agent_id IS NOT NULL
|
|
@@ -369,7 +361,7 @@ export async function repairMissedAssignmentHooks(
|
|
|
369
361
|
for (const story of storiesMissingSubtasks) {
|
|
370
362
|
try {
|
|
371
363
|
// Look up the assigned agent for naming
|
|
372
|
-
const agent = getAgentById(db, story.assigned_agent_id!);
|
|
364
|
+
const agent = await getAgentById(db, story.assigned_agent_id!);
|
|
373
365
|
const agentName = agent?.tmux_session || agent?.id || story.assigned_agent_id!;
|
|
374
366
|
|
|
375
367
|
// Create the subtask
|
|
@@ -382,7 +374,7 @@ export async function repairMissedAssignmentHooks(
|
|
|
382
374
|
|
|
383
375
|
if (subtask) {
|
|
384
376
|
// Persist subtask reference
|
|
385
|
-
updateStory(db, story.id, {
|
|
377
|
+
await updateStory(db, story.id, {
|
|
386
378
|
externalSubtaskKey: subtask.key,
|
|
387
379
|
externalSubtaskId: subtask.id,
|
|
388
380
|
});
|
|
@@ -399,7 +391,7 @@ export async function repairMissedAssignmentHooks(
|
|
|
399
391
|
|
|
400
392
|
repairedCount++;
|
|
401
393
|
|
|
402
|
-
createLog(db, {
|
|
394
|
+
await createLog(db, {
|
|
403
395
|
agentId: 'manager',
|
|
404
396
|
storyId: story.id,
|
|
405
397
|
eventType: 'JIRA_ASSIGNMENT_REPAIRED',
|
|
@@ -421,7 +413,7 @@ export async function repairMissedAssignmentHooks(
|
|
|
421
413
|
const message = err instanceof Error ? err.message : String(err);
|
|
422
414
|
logger.warn(`Failed to repair assignment hook for story ${story.id}: ${message}`);
|
|
423
415
|
|
|
424
|
-
createLog(db, {
|
|
416
|
+
await createLog(db, {
|
|
425
417
|
agentId: 'manager',
|
|
426
418
|
storyId: story.id,
|
|
427
419
|
eventType: 'JIRA_ASSIGNMENT_REPAIR_FAILED',
|
|
@@ -445,12 +437,11 @@ export async function repairMissedAssignmentHooks(
|
|
|
445
437
|
* @returns Number of stories moved to sprint
|
|
446
438
|
*/
|
|
447
439
|
export async function retrySprintAssignment(
|
|
448
|
-
db:
|
|
440
|
+
db: DatabaseProvider,
|
|
449
441
|
tokenStore: TokenStore,
|
|
450
442
|
config: JiraConfig
|
|
451
443
|
): Promise<number> {
|
|
452
|
-
const storiesNotInSprint = queryAll<StoryRow>(
|
|
453
|
-
db,
|
|
444
|
+
const storiesNotInSprint = await db.queryAll<StoryRow>(
|
|
454
445
|
`SELECT * FROM stories
|
|
455
446
|
WHERE jira_issue_key IS NOT NULL
|
|
456
447
|
AND (in_sprint IS NULL OR in_sprint = 0)
|
|
@@ -471,7 +462,7 @@ export async function retrySprintAssignment(
|
|
|
471
462
|
const moved = await tryMoveToActiveSprint(client, config, issueKeys);
|
|
472
463
|
if (moved) {
|
|
473
464
|
for (const story of storiesNotInSprint) {
|
|
474
|
-
updateStory(db, story.id, { inSprint: true });
|
|
465
|
+
await updateStory(db, story.id, { inSprint: true });
|
|
475
466
|
}
|
|
476
467
|
return storiesNotInSprint.length;
|
|
477
468
|
}
|
|
@@ -490,7 +481,7 @@ export async function retrySprintAssignment(
|
|
|
490
481
|
* @returns Number of stories pushed to Jira
|
|
491
482
|
*/
|
|
492
483
|
export async function syncHiveStatusesToJira(
|
|
493
|
-
db:
|
|
484
|
+
db: DatabaseProvider,
|
|
494
485
|
tokenStore: TokenStore,
|
|
495
486
|
config: JiraConfig
|
|
496
487
|
): Promise<number> {
|
|
@@ -501,8 +492,7 @@ export async function syncHiveStatusesToJira(
|
|
|
501
492
|
}
|
|
502
493
|
|
|
503
494
|
// Fetch all stories that have a Jira issue key
|
|
504
|
-
const storiesWithJira = queryAll<StoryRow>(
|
|
505
|
-
db,
|
|
495
|
+
const storiesWithJira = await db.queryAll<StoryRow>(
|
|
506
496
|
`SELECT * FROM stories WHERE jira_issue_key IS NOT NULL AND status NOT IN ('merged')`
|
|
507
497
|
);
|
|
508
498
|
|
|
@@ -539,7 +529,7 @@ export async function syncHiveStatusesToJira(
|
|
|
539
529
|
);
|
|
540
530
|
|
|
541
531
|
if (transitioned) {
|
|
542
|
-
createLog(db, {
|
|
532
|
+
await createLog(db, {
|
|
543
533
|
agentId: 'manager',
|
|
544
534
|
storyId: story.id,
|
|
545
535
|
eventType: 'JIRA_SYNC_COMPLETED',
|
|
@@ -577,7 +567,7 @@ export async function syncHiveStatusesToJira(
|
|
|
577
567
|
* @param db - Database instance
|
|
578
568
|
* @returns Number of stories updated (from bidirectional status sync)
|
|
579
569
|
*/
|
|
580
|
-
export async function syncFromJira(root: string, db:
|
|
570
|
+
export async function syncFromJira(root: string, db: DatabaseProvider): Promise<number> {
|
|
581
571
|
try {
|
|
582
572
|
const paths = getHivePaths(root);
|
|
583
573
|
const config = loadConfig(paths.hiveDir);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
|
|
3
3
|
import { join } from 'path';
|
|
4
|
-
import type { Database } from 'sql.js';
|
|
5
4
|
import { loadEnvIntoProcess } from '../../auth/env-store.js';
|
|
6
5
|
import { TokenStore } from '../../auth/token-store.js';
|
|
7
6
|
import { loadConfig } from '../../config/loader.js';
|
|
8
7
|
import type { JiraConfig } from '../../config/schema.js';
|
|
8
|
+
import type { DatabaseProvider } from '../../db/provider.js';
|
|
9
9
|
import { createLog } from '../../db/queries/logs.js';
|
|
10
10
|
import { getStoryById } from '../../db/queries/stories.js';
|
|
11
11
|
import * as logger from '../../utils/logger.js';
|
|
@@ -122,7 +122,7 @@ export async function transitionJiraIssue(
|
|
|
122
122
|
* @param newStatus - The new Hive status
|
|
123
123
|
*/
|
|
124
124
|
export async function syncStoryStatusToJira(
|
|
125
|
-
db:
|
|
125
|
+
db: DatabaseProvider,
|
|
126
126
|
tokenStore: TokenStore,
|
|
127
127
|
config: JiraConfig,
|
|
128
128
|
storyId: string,
|
|
@@ -134,7 +134,7 @@ export async function syncStoryStatusToJira(
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
// Look up the story to get its Jira issue key
|
|
137
|
-
const story = getStoryById(db, storyId);
|
|
137
|
+
const story = await getStoryById(db, storyId);
|
|
138
138
|
if (!story?.external_issue_key) {
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
@@ -156,7 +156,7 @@ export async function syncStoryStatusToJira(
|
|
|
156
156
|
);
|
|
157
157
|
|
|
158
158
|
if (transitioned) {
|
|
159
|
-
createLog(db, {
|
|
159
|
+
await createLog(db, {
|
|
160
160
|
agentId: 'manager',
|
|
161
161
|
storyId,
|
|
162
162
|
eventType: 'JIRA_TRANSITION_SUCCESS',
|
|
@@ -169,7 +169,7 @@ export async function syncStoryStatusToJira(
|
|
|
169
169
|
logger.warn(
|
|
170
170
|
`Failed to transition Jira issue ${story.external_issue_key} for story ${storyId}: ${message}`
|
|
171
171
|
);
|
|
172
|
-
createLog(db, {
|
|
172
|
+
await createLog(db, {
|
|
173
173
|
agentId: 'manager',
|
|
174
174
|
storyId,
|
|
175
175
|
eventType: 'JIRA_TRANSITION_FAILED',
|
|
@@ -194,7 +194,7 @@ export async function syncStoryStatusToJira(
|
|
|
194
194
|
*/
|
|
195
195
|
export async function syncStatusToJira(
|
|
196
196
|
root: string,
|
|
197
|
-
db:
|
|
197
|
+
db: DatabaseProvider,
|
|
198
198
|
storyId: string,
|
|
199
199
|
newStatus: string
|
|
200
200
|
): Promise<void> {
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import { queryOne } from '../db/client.js';
|
|
3
|
+
import type { DatabaseProvider } from '../db/provider.js';
|
|
5
4
|
import type { AgentRow } from '../db/queries/agents.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Select the agent with the least workload (queue-depth aware).
|
|
9
8
|
* Returns the agent with fewest active stories; breaks ties by creation order.
|
|
10
9
|
*/
|
|
11
|
-
export function selectAgentWithLeastWorkload(
|
|
10
|
+
export async function selectAgentWithLeastWorkload(
|
|
11
|
+
db: DatabaseProvider,
|
|
12
|
+
agents: AgentRow[]
|
|
13
|
+
): Promise<AgentRow> {
|
|
12
14
|
let selectedAgent = agents[0];
|
|
13
|
-
let minWorkload = getAgentWorkload(db, selectedAgent.id);
|
|
15
|
+
let minWorkload = await getAgentWorkload(db, selectedAgent.id);
|
|
14
16
|
|
|
15
17
|
for (let i = 1; i < agents.length; i++) {
|
|
16
|
-
const workload = getAgentWorkload(db, agents[i].id);
|
|
18
|
+
const workload = await getAgentWorkload(db, agents[i].id);
|
|
17
19
|
if (workload < minWorkload) {
|
|
18
20
|
minWorkload = workload;
|
|
19
21
|
selectedAgent = agents[i];
|
|
@@ -26,9 +28,8 @@ export function selectAgentWithLeastWorkload(db: Database, agents: AgentRow[]):
|
|
|
26
28
|
/**
|
|
27
29
|
* Calculate queue depth for an agent (number of active stories).
|
|
28
30
|
*/
|
|
29
|
-
export function getAgentWorkload(db:
|
|
30
|
-
const result = queryOne<{ count: number }>(
|
|
31
|
-
db,
|
|
31
|
+
export async function getAgentWorkload(db: DatabaseProvider, agentId: string): Promise<number> {
|
|
32
|
+
const result = await db.queryOne<{ count: number }>(
|
|
32
33
|
`
|
|
33
34
|
SELECT COUNT(*) as count FROM stories
|
|
34
35
|
WHERE assigned_agent_id = ?
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { DatabaseProvider } from '../db/provider.js';
|
|
4
4
|
import {
|
|
5
5
|
getBatchStoryDependencies,
|
|
6
6
|
getStoryDependencies,
|
|
@@ -11,7 +11,10 @@ import {
|
|
|
11
11
|
* Build a dependency graph for stories.
|
|
12
12
|
* Returns a map of story ID to its direct dependencies.
|
|
13
13
|
*/
|
|
14
|
-
export function buildDependencyGraph(
|
|
14
|
+
export async function buildDependencyGraph(
|
|
15
|
+
db: DatabaseProvider,
|
|
16
|
+
stories: StoryRow[]
|
|
17
|
+
): Promise<Map<string, Set<string>>> {
|
|
15
18
|
const graph = new Map<string, Set<string>>();
|
|
16
19
|
const storyIds = new Set(stories.map(s => s.id));
|
|
17
20
|
|
|
@@ -23,7 +26,7 @@ export function buildDependencyGraph(db: Database, stories: StoryRow[]): Map<str
|
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
// Fetch all dependencies in a single query to avoid N+1 pattern
|
|
26
|
-
const allDepsMap = getBatchStoryDependencies(db, Array.from(storyIds));
|
|
29
|
+
const allDepsMap = await getBatchStoryDependencies(db, Array.from(storyIds));
|
|
27
30
|
|
|
28
31
|
// Add dependencies (only within the planned set; external deps handled by areDependenciesSatisfied)
|
|
29
32
|
for (const [storyId, depIds] of allDepsMap) {
|
|
@@ -42,8 +45,11 @@ export function buildDependencyGraph(db: Database, stories: StoryRow[]): Map<str
|
|
|
42
45
|
* Returns stories in order where dependencies come before dependents.
|
|
43
46
|
* Returns null if circular dependency is detected.
|
|
44
47
|
*/
|
|
45
|
-
export function topologicalSort(
|
|
46
|
-
|
|
48
|
+
export async function topologicalSort(
|
|
49
|
+
db: DatabaseProvider,
|
|
50
|
+
stories: StoryRow[]
|
|
51
|
+
): Promise<StoryRow[] | null> {
|
|
52
|
+
const graph = await buildDependencyGraph(db, stories);
|
|
47
53
|
const storyMap = new Map(stories.map(s => [s.id, s]));
|
|
48
54
|
|
|
49
55
|
// Kahn's algorithm for topological sort
|
|
@@ -95,8 +101,11 @@ export function topologicalSort(db: Database, stories: StoryRow[]): StoryRow[] |
|
|
|
95
101
|
* Check if a story's dependencies are satisfied.
|
|
96
102
|
* A dependency is satisfied only if it's merged (completed).
|
|
97
103
|
*/
|
|
98
|
-
export function areDependenciesSatisfied(
|
|
99
|
-
|
|
104
|
+
export async function areDependenciesSatisfied(
|
|
105
|
+
db: DatabaseProvider,
|
|
106
|
+
storyId: string
|
|
107
|
+
): Promise<boolean> {
|
|
108
|
+
const dependencies = await getStoryDependencies(db, storyId);
|
|
100
109
|
|
|
101
110
|
for (const dep of dependencies) {
|
|
102
111
|
// Check if dependency is in a terminal state (merged)
|