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,10 +1,9 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
import { nanoid } from 'nanoid';
|
|
3
|
-
|
|
4
|
-
export function createEscalation(db, input) {
|
|
3
|
+
export async function createEscalation(provider, input) {
|
|
5
4
|
const id = `ESC-${nanoid(6).toUpperCase()}`;
|
|
6
5
|
const now = new Date().toISOString();
|
|
7
|
-
run(
|
|
6
|
+
await provider.run(`
|
|
8
7
|
INSERT INTO escalations (id, story_id, from_agent_id, to_agent_id, reason, created_at)
|
|
9
8
|
VALUES (?, ?, ?, ?, ?, ?)
|
|
10
9
|
`, [
|
|
@@ -15,76 +14,76 @@ export function createEscalation(db, input) {
|
|
|
15
14
|
input.reason,
|
|
16
15
|
now,
|
|
17
16
|
]);
|
|
18
|
-
return getEscalationById(
|
|
17
|
+
return (await getEscalationById(provider, id));
|
|
19
18
|
}
|
|
20
|
-
export function getEscalationById(
|
|
21
|
-
return queryOne(
|
|
19
|
+
export async function getEscalationById(provider, id) {
|
|
20
|
+
return await provider.queryOne('SELECT * FROM escalations WHERE id = ?', [id]);
|
|
22
21
|
}
|
|
23
|
-
export function getEscalationsByStory(
|
|
24
|
-
return queryAll(
|
|
22
|
+
export async function getEscalationsByStory(provider, storyId) {
|
|
23
|
+
return await provider.queryAll(`
|
|
25
24
|
SELECT * FROM escalations
|
|
26
25
|
WHERE story_id = ?
|
|
27
26
|
ORDER BY created_at DESC
|
|
28
27
|
`, [storyId]);
|
|
29
28
|
}
|
|
30
|
-
export function getEscalationsByFromAgent(
|
|
31
|
-
return queryAll(
|
|
29
|
+
export async function getEscalationsByFromAgent(provider, agentId) {
|
|
30
|
+
return await provider.queryAll(`
|
|
32
31
|
SELECT * FROM escalations
|
|
33
32
|
WHERE from_agent_id = ?
|
|
34
33
|
ORDER BY created_at DESC
|
|
35
34
|
`, [agentId]);
|
|
36
35
|
}
|
|
37
|
-
export function getEscalationsByToAgent(
|
|
36
|
+
export async function getEscalationsByToAgent(provider, agentId) {
|
|
38
37
|
if (agentId === null) {
|
|
39
|
-
return queryAll(
|
|
38
|
+
return await provider.queryAll(`
|
|
40
39
|
SELECT * FROM escalations
|
|
41
40
|
WHERE to_agent_id IS NULL
|
|
42
41
|
ORDER BY created_at DESC
|
|
43
42
|
`);
|
|
44
43
|
}
|
|
45
|
-
return queryAll(
|
|
44
|
+
return await provider.queryAll(`
|
|
46
45
|
SELECT * FROM escalations
|
|
47
46
|
WHERE to_agent_id = ?
|
|
48
47
|
ORDER BY created_at DESC
|
|
49
48
|
`, [agentId]);
|
|
50
49
|
}
|
|
51
|
-
export function getEscalationsByStatus(
|
|
52
|
-
return queryAll(
|
|
50
|
+
export async function getEscalationsByStatus(provider, status) {
|
|
51
|
+
return await provider.queryAll(`
|
|
53
52
|
SELECT * FROM escalations
|
|
54
53
|
WHERE status = ?
|
|
55
54
|
ORDER BY created_at DESC
|
|
56
55
|
`, [status]);
|
|
57
56
|
}
|
|
58
|
-
export function getPendingEscalations(
|
|
59
|
-
return getEscalationsByStatus(
|
|
57
|
+
export async function getPendingEscalations(provider) {
|
|
58
|
+
return await getEscalationsByStatus(provider, 'pending');
|
|
60
59
|
}
|
|
61
|
-
export function getPendingHumanEscalations(
|
|
62
|
-
return queryAll(
|
|
60
|
+
export async function getPendingHumanEscalations(provider) {
|
|
61
|
+
return await provider.queryAll(`
|
|
63
62
|
SELECT * FROM escalations
|
|
64
63
|
WHERE status = 'pending' AND to_agent_id IS NULL
|
|
65
64
|
ORDER BY created_at
|
|
66
65
|
`);
|
|
67
66
|
}
|
|
68
|
-
export function getRecentEscalationsForAgent(
|
|
69
|
-
return queryAll(
|
|
67
|
+
export async function getRecentEscalationsForAgent(provider, agentId, minutesBack = 30) {
|
|
68
|
+
return await provider.queryAll(`
|
|
70
69
|
SELECT * FROM escalations
|
|
71
70
|
WHERE from_agent_id = ?
|
|
72
71
|
AND created_at > datetime('now', ?)
|
|
73
72
|
ORDER BY created_at DESC
|
|
74
73
|
`, [agentId, `-${minutesBack} minutes`]);
|
|
75
74
|
}
|
|
76
|
-
export function getActiveEscalationsForAgent(
|
|
77
|
-
return queryAll(
|
|
75
|
+
export async function getActiveEscalationsForAgent(provider, agentId) {
|
|
76
|
+
return await provider.queryAll(`
|
|
78
77
|
SELECT * FROM escalations
|
|
79
78
|
WHERE from_agent_id = ?
|
|
80
79
|
AND status IN ('pending', 'acknowledged')
|
|
81
80
|
ORDER BY created_at DESC
|
|
82
81
|
`, [agentId]);
|
|
83
82
|
}
|
|
84
|
-
export function getAllEscalations(
|
|
85
|
-
return queryAll(
|
|
83
|
+
export async function getAllEscalations(provider) {
|
|
84
|
+
return await provider.queryAll('SELECT * FROM escalations ORDER BY created_at DESC');
|
|
86
85
|
}
|
|
87
|
-
export function updateEscalation(
|
|
86
|
+
export async function updateEscalation(provider, id, input) {
|
|
88
87
|
const updates = [];
|
|
89
88
|
const values = [];
|
|
90
89
|
if (input.status !== undefined) {
|
|
@@ -104,19 +103,19 @@ export function updateEscalation(db, id, input) {
|
|
|
104
103
|
values.push(input.resolution);
|
|
105
104
|
}
|
|
106
105
|
if (updates.length === 0) {
|
|
107
|
-
return getEscalationById(
|
|
106
|
+
return await getEscalationById(provider, id);
|
|
108
107
|
}
|
|
109
108
|
values.push(id);
|
|
110
|
-
run(
|
|
111
|
-
return getEscalationById(
|
|
109
|
+
await provider.run(`UPDATE escalations SET ${updates.join(', ')} WHERE id = ?`, values);
|
|
110
|
+
return await getEscalationById(provider, id);
|
|
112
111
|
}
|
|
113
|
-
export function resolveEscalation(
|
|
114
|
-
return updateEscalation(
|
|
112
|
+
export async function resolveEscalation(provider, id, resolution) {
|
|
113
|
+
return await updateEscalation(provider, id, { status: 'resolved', resolution });
|
|
115
114
|
}
|
|
116
|
-
export function acknowledgeEscalation(
|
|
117
|
-
return updateEscalation(
|
|
115
|
+
export async function acknowledgeEscalation(provider, id) {
|
|
116
|
+
return await updateEscalation(provider, id, { status: 'acknowledged' });
|
|
118
117
|
}
|
|
119
|
-
export function deleteEscalation(
|
|
120
|
-
run(
|
|
118
|
+
export async function deleteEscalation(provider, id) {
|
|
119
|
+
await provider.run('DELETE FROM escalations WHERE id = ?', [id]);
|
|
121
120
|
}
|
|
122
121
|
//# sourceMappingURL=escalations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escalations.js","sourceRoot":"","sources":["../../../src/db/queries/escalations.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"escalations.js","sourceRoot":"","sources":["../../../src/db/queries/escalations.ts"],"names":[],"mappings":"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"}
|
|
@@ -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 { acknowledgeEscalation, createEscalation, deleteEscalation, getActiveEscalationsForAgent, getAllEscalations, getEscalationById, getEscalationsByFromAgent, getEscalationsByStatus, getEscalationsByStory, getEscalationsByToAgent, getPendingEscalations, getPendingHumanEscalations, getRecentEscalationsForAgent, resolveEscalation, updateEscalation, } from './escalations.js';
|
|
5
6
|
import { createStory } from './stories.js';
|
|
@@ -11,16 +12,17 @@ describe('escalations queries', () => {
|
|
|
11
12
|
let agentId;
|
|
12
13
|
let storyId;
|
|
13
14
|
beforeEach(async () => {
|
|
14
|
-
|
|
15
|
-
|
|
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 story = createStory(db, {
|
|
25
|
+
const story = await createStory(db, {
|
|
24
26
|
title: 'Test Story',
|
|
25
27
|
description: 'Test description',
|
|
26
28
|
teamId,
|
|
@@ -28,9 +30,9 @@ describe('escalations queries', () => {
|
|
|
28
30
|
storyId = story.id;
|
|
29
31
|
});
|
|
30
32
|
describe('createEscalation', () => {
|
|
31
|
-
it('should create an escalation with all fields', () => {
|
|
32
|
-
const agent2 = createAgent(db, { type: 'tech_lead', teamId });
|
|
33
|
-
const escalation = createEscalation(db, {
|
|
33
|
+
it('should create an escalation with all fields', async () => {
|
|
34
|
+
const agent2 = await createAgent(db, { type: 'tech_lead', teamId });
|
|
35
|
+
const escalation = await createEscalation(db, {
|
|
34
36
|
storyId,
|
|
35
37
|
fromAgentId: agentId,
|
|
36
38
|
toAgentId: agent2.id,
|
|
@@ -44,60 +46,60 @@ describe('escalations queries', () => {
|
|
|
44
46
|
expect(escalation.status).toBe('pending');
|
|
45
47
|
expect(escalation.created_at).toBeDefined();
|
|
46
48
|
});
|
|
47
|
-
it('should create escalation with null fields', () => {
|
|
48
|
-
const escalation = createEscalation(db, {
|
|
49
|
+
it('should create escalation with null fields', async () => {
|
|
50
|
+
const escalation = await createEscalation(db, {
|
|
49
51
|
reason: 'General question',
|
|
50
52
|
});
|
|
51
53
|
expect(escalation.story_id).toBeNull();
|
|
52
54
|
expect(escalation.from_agent_id).toBeNull();
|
|
53
55
|
expect(escalation.to_agent_id).toBeNull();
|
|
54
56
|
});
|
|
55
|
-
it('should generate unique IDs', () => {
|
|
56
|
-
const esc1 = createEscalation(db, { reason: 'Reason 1' });
|
|
57
|
-
const esc2 = createEscalation(db, { reason: 'Reason 2' });
|
|
57
|
+
it('should generate unique IDs', async () => {
|
|
58
|
+
const esc1 = await createEscalation(db, { reason: 'Reason 1' });
|
|
59
|
+
const esc2 = await createEscalation(db, { reason: 'Reason 2' });
|
|
58
60
|
expect(esc1.id).not.toBe(esc2.id);
|
|
59
61
|
});
|
|
60
62
|
});
|
|
61
63
|
describe('getEscalationById', () => {
|
|
62
|
-
it('should retrieve an escalation by ID', () => {
|
|
63
|
-
const created = createEscalation(db, {
|
|
64
|
+
it('should retrieve an escalation by ID', async () => {
|
|
65
|
+
const created = await createEscalation(db, {
|
|
64
66
|
storyId,
|
|
65
67
|
fromAgentId: agentId,
|
|
66
68
|
reason: 'Test escalation',
|
|
67
69
|
});
|
|
68
|
-
const retrieved = getEscalationById(db, created.id);
|
|
70
|
+
const retrieved = await getEscalationById(db, created.id);
|
|
69
71
|
expect(retrieved).toBeDefined();
|
|
70
72
|
expect(retrieved?.id).toBe(created.id);
|
|
71
73
|
expect(retrieved?.reason).toBe('Test escalation');
|
|
72
74
|
});
|
|
73
|
-
it('should return undefined for non-existent escalation', () => {
|
|
74
|
-
const result = getEscalationById(db, 'non-existent-id');
|
|
75
|
+
it('should return undefined for non-existent escalation', async () => {
|
|
76
|
+
const result = await getEscalationById(db, 'non-existent-id');
|
|
75
77
|
expect(result).toBeUndefined();
|
|
76
78
|
});
|
|
77
79
|
});
|
|
78
80
|
describe('getEscalationsByStory', () => {
|
|
79
|
-
it('should return escalations for a specific story', () => {
|
|
80
|
-
const esc1 = createEscalation(db, { storyId, reason: 'Reason 1' });
|
|
81
|
-
const esc2 = createEscalation(db, { storyId, reason: 'Reason 2' });
|
|
82
|
-
const story2 = createStory(db, {
|
|
81
|
+
it('should return escalations for a specific story', async () => {
|
|
82
|
+
const esc1 = await createEscalation(db, { storyId, reason: 'Reason 1' });
|
|
83
|
+
const esc2 = await createEscalation(db, { storyId, reason: 'Reason 2' });
|
|
84
|
+
const story2 = await createStory(db, {
|
|
83
85
|
title: 'Story 2',
|
|
84
86
|
description: 'Description',
|
|
85
87
|
teamId,
|
|
86
88
|
});
|
|
87
|
-
createEscalation(db, { storyId: story2.id, reason: 'Reason 3' });
|
|
88
|
-
const escalations = getEscalationsByStory(db, storyId);
|
|
89
|
+
await createEscalation(db, { storyId: story2.id, reason: 'Reason 3' });
|
|
90
|
+
const escalations = await getEscalationsByStory(db, storyId);
|
|
89
91
|
expect(escalations).toHaveLength(2);
|
|
90
92
|
expect(escalations.map(e => e.id)).toContain(esc1.id);
|
|
91
93
|
expect(escalations.map(e => e.id)).toContain(esc2.id);
|
|
92
94
|
});
|
|
93
|
-
it('should return empty array when no escalations for story', () => {
|
|
94
|
-
const escalations = getEscalationsByStory(db, 'non-existent-story');
|
|
95
|
+
it('should return empty array when no escalations for story', async () => {
|
|
96
|
+
const escalations = await getEscalationsByStory(db, 'non-existent-story');
|
|
95
97
|
expect(escalations).toEqual([]);
|
|
96
98
|
});
|
|
97
|
-
it('should order by created_at DESC', () => {
|
|
98
|
-
const esc1 = createEscalation(db, { storyId, reason: 'First' });
|
|
99
|
-
const esc2 = createEscalation(db, { storyId, reason: 'Second' });
|
|
100
|
-
const escalations = getEscalationsByStory(db, storyId);
|
|
99
|
+
it('should order by created_at DESC', async () => {
|
|
100
|
+
const esc1 = await createEscalation(db, { storyId, reason: 'First' });
|
|
101
|
+
const esc2 = await createEscalation(db, { storyId, reason: 'Second' });
|
|
102
|
+
const escalations = await getEscalationsByStory(db, storyId);
|
|
101
103
|
expect(escalations).toHaveLength(2);
|
|
102
104
|
// Verify both escalations are present
|
|
103
105
|
expect(escalations.map(e => e.id)).toContain(esc1.id);
|
|
@@ -105,54 +107,54 @@ describe('escalations queries', () => {
|
|
|
105
107
|
});
|
|
106
108
|
});
|
|
107
109
|
describe('getEscalationsByFromAgent', () => {
|
|
108
|
-
it('should return escalations from a specific agent', () => {
|
|
109
|
-
const esc1 = createEscalation(db, { fromAgentId: agentId, reason: 'Reason 1' });
|
|
110
|
-
const esc2 = createEscalation(db, { fromAgentId: agentId, reason: 'Reason 2' });
|
|
111
|
-
const agent2 = createAgent(db, { type: 'junior', teamId });
|
|
112
|
-
createEscalation(db, { fromAgentId: agent2.id, reason: 'Reason 3' });
|
|
113
|
-
const escalations = getEscalationsByFromAgent(db, agentId);
|
|
110
|
+
it('should return escalations from a specific agent', async () => {
|
|
111
|
+
const esc1 = await createEscalation(db, { fromAgentId: agentId, reason: 'Reason 1' });
|
|
112
|
+
const esc2 = await createEscalation(db, { fromAgentId: agentId, reason: 'Reason 2' });
|
|
113
|
+
const agent2 = await createAgent(db, { type: 'junior', teamId });
|
|
114
|
+
await createEscalation(db, { fromAgentId: agent2.id, reason: 'Reason 3' });
|
|
115
|
+
const escalations = await getEscalationsByFromAgent(db, agentId);
|
|
114
116
|
expect(escalations).toHaveLength(2);
|
|
115
117
|
expect(escalations.map(e => e.id)).toContain(esc1.id);
|
|
116
118
|
expect(escalations.map(e => e.id)).toContain(esc2.id);
|
|
117
119
|
});
|
|
118
120
|
});
|
|
119
121
|
describe('getEscalationsByToAgent', () => {
|
|
120
|
-
it('should return escalations to a specific agent', () => {
|
|
121
|
-
const techLead = createAgent(db, { type: 'tech_lead', teamId });
|
|
122
|
-
const esc1 = createEscalation(db, {
|
|
122
|
+
it('should return escalations to a specific agent', async () => {
|
|
123
|
+
const techLead = await createAgent(db, { type: 'tech_lead', teamId });
|
|
124
|
+
const esc1 = await createEscalation(db, {
|
|
123
125
|
fromAgentId: agentId,
|
|
124
126
|
toAgentId: techLead.id,
|
|
125
127
|
reason: 'Reason 1',
|
|
126
128
|
});
|
|
127
|
-
createEscalation(db, { fromAgentId: agentId, reason: 'Reason 2' });
|
|
128
|
-
const escalations = getEscalationsByToAgent(db, techLead.id);
|
|
129
|
+
await createEscalation(db, { fromAgentId: agentId, reason: 'Reason 2' });
|
|
130
|
+
const escalations = await getEscalationsByToAgent(db, techLead.id);
|
|
129
131
|
expect(escalations).toHaveLength(1);
|
|
130
132
|
expect(escalations[0].id).toBe(esc1.id);
|
|
131
133
|
});
|
|
132
|
-
it('should return escalations with null toAgentId when passed null', () => {
|
|
133
|
-
createEscalation(db, {
|
|
134
|
+
it('should return escalations with null toAgentId when passed null', async () => {
|
|
135
|
+
await createEscalation(db, {
|
|
134
136
|
fromAgentId: agentId,
|
|
135
137
|
toAgentId: null,
|
|
136
138
|
reason: 'To human',
|
|
137
139
|
});
|
|
138
|
-
const techLead = createAgent(db, { type: 'tech_lead', teamId });
|
|
139
|
-
createEscalation(db, {
|
|
140
|
+
const techLead = await createAgent(db, { type: 'tech_lead', teamId });
|
|
141
|
+
await createEscalation(db, {
|
|
140
142
|
fromAgentId: agentId,
|
|
141
143
|
toAgentId: techLead.id,
|
|
142
144
|
reason: 'To tech lead',
|
|
143
145
|
});
|
|
144
|
-
const humanEscalations = getEscalationsByToAgent(db, null);
|
|
146
|
+
const humanEscalations = await getEscalationsByToAgent(db, null);
|
|
145
147
|
expect(humanEscalations).toHaveLength(1);
|
|
146
148
|
expect(humanEscalations[0].reason).toBe('To human');
|
|
147
149
|
});
|
|
148
150
|
});
|
|
149
151
|
describe('getEscalationsByStatus', () => {
|
|
150
|
-
it('should filter escalations by status', () => {
|
|
151
|
-
const esc1 = createEscalation(db, { reason: 'Pending' });
|
|
152
|
-
const esc2 = createEscalation(db, { reason: 'Acknowledged' });
|
|
153
|
-
updateEscalation(db, esc2.id, { status: 'acknowledged' });
|
|
154
|
-
const pending = getEscalationsByStatus(db, 'pending');
|
|
155
|
-
const acknowledged = getEscalationsByStatus(db, 'acknowledged');
|
|
152
|
+
it('should filter escalations by status', async () => {
|
|
153
|
+
const esc1 = await createEscalation(db, { reason: 'Pending' });
|
|
154
|
+
const esc2 = await createEscalation(db, { reason: 'Acknowledged' });
|
|
155
|
+
await updateEscalation(db, esc2.id, { status: 'acknowledged' });
|
|
156
|
+
const pending = await getEscalationsByStatus(db, 'pending');
|
|
157
|
+
const acknowledged = await getEscalationsByStatus(db, 'acknowledged');
|
|
156
158
|
expect(pending).toHaveLength(1);
|
|
157
159
|
expect(pending[0].id).toBe(esc1.id);
|
|
158
160
|
expect(acknowledged).toHaveLength(1);
|
|
@@ -160,49 +162,49 @@ describe('escalations queries', () => {
|
|
|
160
162
|
});
|
|
161
163
|
});
|
|
162
164
|
describe('getPendingEscalations', () => {
|
|
163
|
-
it('should return all pending escalations', () => {
|
|
164
|
-
const esc1 = createEscalation(db, { reason: 'Pending 1' });
|
|
165
|
-
const esc2 = createEscalation(db, { reason: 'Pending 2' });
|
|
166
|
-
const esc3 = createEscalation(db, { reason: 'Resolved' });
|
|
167
|
-
updateEscalation(db, esc3.id, { status: 'resolved', resolution: 'Fixed' });
|
|
168
|
-
const pending = getPendingEscalations(db);
|
|
165
|
+
it('should return all pending escalations', async () => {
|
|
166
|
+
const esc1 = await createEscalation(db, { reason: 'Pending 1' });
|
|
167
|
+
const esc2 = await createEscalation(db, { reason: 'Pending 2' });
|
|
168
|
+
const esc3 = await createEscalation(db, { reason: 'Resolved' });
|
|
169
|
+
await updateEscalation(db, esc3.id, { status: 'resolved', resolution: 'Fixed' });
|
|
170
|
+
const pending = await getPendingEscalations(db);
|
|
169
171
|
expect(pending).toHaveLength(2);
|
|
170
172
|
expect(pending.map(e => e.id)).toContain(esc1.id);
|
|
171
173
|
expect(pending.map(e => e.id)).toContain(esc2.id);
|
|
172
174
|
});
|
|
173
175
|
});
|
|
174
176
|
describe('getPendingHumanEscalations', () => {
|
|
175
|
-
it('should return pending escalations with null toAgentId', () => {
|
|
176
|
-
const esc1 = createEscalation(db, {
|
|
177
|
+
it('should return pending escalations with null toAgentId', async () => {
|
|
178
|
+
const esc1 = await createEscalation(db, {
|
|
177
179
|
fromAgentId: agentId,
|
|
178
180
|
toAgentId: null,
|
|
179
181
|
reason: 'Need human help',
|
|
180
182
|
});
|
|
181
|
-
const techLead = createAgent(db, { type: 'tech_lead', teamId });
|
|
182
|
-
createEscalation(db, {
|
|
183
|
+
const techLead = await createAgent(db, { type: 'tech_lead', teamId });
|
|
184
|
+
await createEscalation(db, {
|
|
183
185
|
fromAgentId: agentId,
|
|
184
186
|
toAgentId: techLead.id,
|
|
185
187
|
reason: 'Need tech lead help',
|
|
186
188
|
});
|
|
187
|
-
const humanEscalations = getPendingHumanEscalations(db);
|
|
189
|
+
const humanEscalations = await getPendingHumanEscalations(db);
|
|
188
190
|
expect(humanEscalations).toHaveLength(1);
|
|
189
191
|
expect(humanEscalations[0].id).toBe(esc1.id);
|
|
190
192
|
});
|
|
191
|
-
it('should not return resolved human escalations', () => {
|
|
192
|
-
const esc = createEscalation(db, {
|
|
193
|
+
it('should not return resolved human escalations', async () => {
|
|
194
|
+
const esc = await createEscalation(db, {
|
|
193
195
|
toAgentId: null,
|
|
194
196
|
reason: 'Need help',
|
|
195
197
|
});
|
|
196
|
-
updateEscalation(db, esc.id, { status: 'resolved', resolution: 'Fixed' });
|
|
197
|
-
const humanEscalations = getPendingHumanEscalations(db);
|
|
198
|
+
await updateEscalation(db, esc.id, { status: 'resolved', resolution: 'Fixed' });
|
|
199
|
+
const humanEscalations = await getPendingHumanEscalations(db);
|
|
198
200
|
expect(humanEscalations).toEqual([]);
|
|
199
201
|
});
|
|
200
202
|
});
|
|
201
203
|
describe('getAllEscalations', () => {
|
|
202
|
-
it('should return all escalations ordered by created_at DESC', () => {
|
|
203
|
-
const esc1 = createEscalation(db, { reason: 'First' });
|
|
204
|
-
const esc2 = createEscalation(db, { reason: 'Second' });
|
|
205
|
-
const escalations = getAllEscalations(db);
|
|
204
|
+
it('should return all escalations ordered by created_at DESC', async () => {
|
|
205
|
+
const esc1 = await createEscalation(db, { reason: 'First' });
|
|
206
|
+
const esc2 = await createEscalation(db, { reason: 'Second' });
|
|
207
|
+
const escalations = await getAllEscalations(db);
|
|
206
208
|
expect(escalations).toHaveLength(2);
|
|
207
209
|
// Verify both escalations are present
|
|
208
210
|
expect(escalations.map(e => e.id)).toContain(esc1.id);
|
|
@@ -210,14 +212,14 @@ describe('escalations queries', () => {
|
|
|
210
212
|
});
|
|
211
213
|
});
|
|
212
214
|
describe('updateEscalation', () => {
|
|
213
|
-
it('should update escalation status', () => {
|
|
214
|
-
const esc = createEscalation(db, { reason: 'Test' });
|
|
215
|
-
const updated = updateEscalation(db, esc.id, { status: 'acknowledged' });
|
|
215
|
+
it('should update escalation status', async () => {
|
|
216
|
+
const esc = await createEscalation(db, { reason: 'Test' });
|
|
217
|
+
const updated = await updateEscalation(db, esc.id, { status: 'acknowledged' });
|
|
216
218
|
expect(updated?.status).toBe('acknowledged');
|
|
217
219
|
});
|
|
218
|
-
it('should set resolved_at when status is resolved', () => {
|
|
219
|
-
const esc = createEscalation(db, { reason: 'Test' });
|
|
220
|
-
const updated = updateEscalation(db, esc.id, {
|
|
220
|
+
it('should set resolved_at when status is resolved', async () => {
|
|
221
|
+
const esc = await createEscalation(db, { reason: 'Test' });
|
|
222
|
+
const updated = await updateEscalation(db, esc.id, {
|
|
221
223
|
status: 'resolved',
|
|
222
224
|
resolution: 'Issue fixed',
|
|
223
225
|
});
|
|
@@ -225,87 +227,87 @@ describe('escalations queries', () => {
|
|
|
225
227
|
expect(updated?.resolved_at).toBeDefined();
|
|
226
228
|
expect(updated?.resolution).toBe('Issue fixed');
|
|
227
229
|
});
|
|
228
|
-
it('should update toAgentId', () => {
|
|
229
|
-
const esc = createEscalation(db, { reason: 'Test' });
|
|
230
|
-
const techLead = createAgent(db, { type: 'tech_lead', teamId });
|
|
231
|
-
const updated = updateEscalation(db, esc.id, { toAgentId: techLead.id });
|
|
230
|
+
it('should update toAgentId', async () => {
|
|
231
|
+
const esc = await createEscalation(db, { reason: 'Test' });
|
|
232
|
+
const techLead = await createAgent(db, { type: 'tech_lead', teamId });
|
|
233
|
+
const updated = await updateEscalation(db, esc.id, { toAgentId: techLead.id });
|
|
232
234
|
expect(updated?.to_agent_id).toBe(techLead.id);
|
|
233
235
|
});
|
|
234
|
-
it('should return escalation when no updates provided', () => {
|
|
235
|
-
const esc = createEscalation(db, { reason: 'Test' });
|
|
236
|
-
const updated = updateEscalation(db, esc.id, {});
|
|
236
|
+
it('should return escalation when no updates provided', async () => {
|
|
237
|
+
const esc = await createEscalation(db, { reason: 'Test' });
|
|
238
|
+
const updated = await updateEscalation(db, esc.id, {});
|
|
237
239
|
expect(updated?.id).toBe(esc.id);
|
|
238
240
|
});
|
|
239
|
-
it('should return undefined for non-existent escalation', () => {
|
|
240
|
-
const updated = updateEscalation(db, 'non-existent-id', { status: 'acknowledged' });
|
|
241
|
+
it('should return undefined for non-existent escalation', async () => {
|
|
242
|
+
const updated = await updateEscalation(db, 'non-existent-id', { status: 'acknowledged' });
|
|
241
243
|
expect(updated).toBeUndefined();
|
|
242
244
|
});
|
|
243
245
|
});
|
|
244
246
|
describe('resolveEscalation', () => {
|
|
245
|
-
it('should resolve an escalation with resolution text', () => {
|
|
246
|
-
const esc = createEscalation(db, { reason: 'Test' });
|
|
247
|
-
const resolved = resolveEscalation(db, esc.id, 'Issue has been fixed');
|
|
247
|
+
it('should resolve an escalation with resolution text', async () => {
|
|
248
|
+
const esc = await createEscalation(db, { reason: 'Test' });
|
|
249
|
+
const resolved = await resolveEscalation(db, esc.id, 'Issue has been fixed');
|
|
248
250
|
expect(resolved?.status).toBe('resolved');
|
|
249
251
|
expect(resolved?.resolution).toBe('Issue has been fixed');
|
|
250
252
|
expect(resolved?.resolved_at).toBeDefined();
|
|
251
253
|
});
|
|
252
254
|
});
|
|
253
255
|
describe('acknowledgeEscalation', () => {
|
|
254
|
-
it('should acknowledge an escalation', () => {
|
|
255
|
-
const esc = createEscalation(db, { reason: 'Test' });
|
|
256
|
-
const acknowledged = acknowledgeEscalation(db, esc.id);
|
|
256
|
+
it('should acknowledge an escalation', async () => {
|
|
257
|
+
const esc = await createEscalation(db, { reason: 'Test' });
|
|
258
|
+
const acknowledged = await acknowledgeEscalation(db, esc.id);
|
|
257
259
|
expect(acknowledged?.status).toBe('acknowledged');
|
|
258
260
|
});
|
|
259
261
|
});
|
|
260
262
|
describe('deleteEscalation', () => {
|
|
261
|
-
it('should delete an escalation', () => {
|
|
262
|
-
const esc = createEscalation(db, { reason: 'To delete' });
|
|
263
|
-
deleteEscalation(db, esc.id);
|
|
264
|
-
const retrieved = getEscalationById(db, esc.id);
|
|
263
|
+
it('should delete an escalation', async () => {
|
|
264
|
+
const esc = await createEscalation(db, { reason: 'To delete' });
|
|
265
|
+
await deleteEscalation(db, esc.id);
|
|
266
|
+
const retrieved = await getEscalationById(db, esc.id);
|
|
265
267
|
expect(retrieved).toBeUndefined();
|
|
266
268
|
});
|
|
267
|
-
it('should not throw when deleting non-existent escalation', () => {
|
|
268
|
-
expect(
|
|
269
|
+
it('should not throw when deleting non-existent escalation', async () => {
|
|
270
|
+
await expect(deleteEscalation(db, 'non-existent-id')).resolves.not.toThrow();
|
|
269
271
|
});
|
|
270
272
|
});
|
|
271
273
|
describe('edge cases', () => {
|
|
272
|
-
it('should handle very long reason text', () => {
|
|
274
|
+
it('should handle very long reason text', async () => {
|
|
273
275
|
const longReason = 'A'.repeat(10000);
|
|
274
|
-
const esc = createEscalation(db, { reason: longReason });
|
|
275
|
-
const retrieved = getEscalationById(db, esc.id);
|
|
276
|
+
const esc = await createEscalation(db, { reason: longReason });
|
|
277
|
+
const retrieved = await getEscalationById(db, esc.id);
|
|
276
278
|
expect(retrieved?.reason).toBe(longReason);
|
|
277
279
|
});
|
|
278
|
-
it('should handle special characters in reason', () => {
|
|
280
|
+
it('should handle special characters in reason', async () => {
|
|
279
281
|
const reason = 'Reason with \'quotes\' and "double" and\nnewlines';
|
|
280
|
-
const esc = createEscalation(db, { reason });
|
|
281
|
-
const retrieved = getEscalationById(db, esc.id);
|
|
282
|
+
const esc = await createEscalation(db, { reason });
|
|
283
|
+
const retrieved = await getEscalationById(db, esc.id);
|
|
282
284
|
expect(retrieved?.reason).toBe(reason);
|
|
283
285
|
});
|
|
284
|
-
it('should handle null resolution', () => {
|
|
285
|
-
const esc = createEscalation(db, { reason: 'Test' });
|
|
286
|
+
it('should handle null resolution', async () => {
|
|
287
|
+
const esc = await createEscalation(db, { reason: 'Test' });
|
|
286
288
|
expect(esc.resolution).toBeNull();
|
|
287
289
|
expect(esc.resolved_at).toBeNull();
|
|
288
290
|
});
|
|
289
291
|
});
|
|
290
292
|
describe('getRecentEscalationsForAgent', () => {
|
|
291
|
-
it('should return recent escalations for an agent', () => {
|
|
292
|
-
const esc1 = createEscalation(db, { fromAgentId: agentId, reason: 'Recent 1' });
|
|
293
|
-
const esc2 = createEscalation(db, { fromAgentId: agentId, reason: 'Recent 2' });
|
|
294
|
-
const agent2 = createAgent(db, { type: 'junior', teamId });
|
|
295
|
-
createEscalation(db, { fromAgentId: agent2.id, reason: 'Other agent' });
|
|
296
|
-
const recent = getRecentEscalationsForAgent(db, agentId, 30);
|
|
293
|
+
it('should return recent escalations for an agent', async () => {
|
|
294
|
+
const esc1 = await createEscalation(db, { fromAgentId: agentId, reason: 'Recent 1' });
|
|
295
|
+
const esc2 = await createEscalation(db, { fromAgentId: agentId, reason: 'Recent 2' });
|
|
296
|
+
const agent2 = await createAgent(db, { type: 'junior', teamId });
|
|
297
|
+
await createEscalation(db, { fromAgentId: agent2.id, reason: 'Other agent' });
|
|
298
|
+
const recent = await getRecentEscalationsForAgent(db, agentId, 30);
|
|
297
299
|
expect(recent).toHaveLength(2);
|
|
298
300
|
expect(recent.map(e => e.id)).toContain(esc1.id);
|
|
299
301
|
expect(recent.map(e => e.id)).toContain(esc2.id);
|
|
300
302
|
});
|
|
301
|
-
it('should return empty array for agent with no recent escalations', () => {
|
|
302
|
-
const recent = getRecentEscalationsForAgent(db, 'non-existent-agent', 30);
|
|
303
|
+
it('should return empty array for agent with no recent escalations', async () => {
|
|
304
|
+
const recent = await getRecentEscalationsForAgent(db, 'non-existent-agent', 30);
|
|
303
305
|
expect(recent).toEqual([]);
|
|
304
306
|
});
|
|
305
|
-
it('should return escalations in DESC order', () => {
|
|
306
|
-
const esc1 = createEscalation(db, { fromAgentId: agentId, reason: 'First' });
|
|
307
|
-
const esc2 = createEscalation(db, { fromAgentId: agentId, reason: 'Second' });
|
|
308
|
-
const recent = getRecentEscalationsForAgent(db, agentId, 30);
|
|
307
|
+
it('should return escalations in DESC order', async () => {
|
|
308
|
+
const esc1 = await createEscalation(db, { fromAgentId: agentId, reason: 'First' });
|
|
309
|
+
const esc2 = await createEscalation(db, { fromAgentId: agentId, reason: 'Second' });
|
|
310
|
+
const recent = await getRecentEscalationsForAgent(db, agentId, 30);
|
|
309
311
|
expect(recent).toHaveLength(2);
|
|
310
312
|
// Both escalations should be present
|
|
311
313
|
expect(recent.map(e => e.id)).toContain(esc1.id);
|
|
@@ -313,28 +315,28 @@ describe('escalations queries', () => {
|
|
|
313
315
|
});
|
|
314
316
|
});
|
|
315
317
|
describe('getActiveEscalationsForAgent', () => {
|
|
316
|
-
it('should return pending and acknowledged escalations for an agent', () => {
|
|
317
|
-
const esc1 = createEscalation(db, { fromAgentId: agentId, reason: 'Pending' });
|
|
318
|
-
const esc2 = createEscalation(db, { fromAgentId: agentId, reason: 'Acknowledged' });
|
|
319
|
-
updateEscalation(db, esc2.id, { status: 'acknowledged' });
|
|
320
|
-
const esc3 = createEscalation(db, { fromAgentId: agentId, reason: 'Resolved' });
|
|
321
|
-
updateEscalation(db, esc3.id, { status: 'resolved', resolution: 'Fixed' });
|
|
322
|
-
const active = getActiveEscalationsForAgent(db, agentId);
|
|
318
|
+
it('should return pending and acknowledged escalations for an agent', async () => {
|
|
319
|
+
const esc1 = await createEscalation(db, { fromAgentId: agentId, reason: 'Pending' });
|
|
320
|
+
const esc2 = await createEscalation(db, { fromAgentId: agentId, reason: 'Acknowledged' });
|
|
321
|
+
await updateEscalation(db, esc2.id, { status: 'acknowledged' });
|
|
322
|
+
const esc3 = await createEscalation(db, { fromAgentId: agentId, reason: 'Resolved' });
|
|
323
|
+
await updateEscalation(db, esc3.id, { status: 'resolved', resolution: 'Fixed' });
|
|
324
|
+
const active = await getActiveEscalationsForAgent(db, agentId);
|
|
323
325
|
expect(active).toHaveLength(2);
|
|
324
326
|
expect(active.map(e => e.id)).toContain(esc1.id);
|
|
325
327
|
expect(active.map(e => e.id)).toContain(esc2.id);
|
|
326
328
|
expect(active.map(e => e.id)).not.toContain(esc3.id);
|
|
327
329
|
});
|
|
328
|
-
it('should not return resolved escalations', () => {
|
|
329
|
-
createEscalation(db, { fromAgentId: agentId, reason: 'Pending' });
|
|
330
|
-
const esc2 = createEscalation(db, { fromAgentId: agentId, reason: 'Will resolve' });
|
|
331
|
-
updateEscalation(db, esc2.id, { status: 'resolved', resolution: 'Fixed' });
|
|
332
|
-
const active = getActiveEscalationsForAgent(db, agentId);
|
|
330
|
+
it('should not return resolved escalations', async () => {
|
|
331
|
+
await createEscalation(db, { fromAgentId: agentId, reason: 'Pending' });
|
|
332
|
+
const esc2 = await createEscalation(db, { fromAgentId: agentId, reason: 'Will resolve' });
|
|
333
|
+
await updateEscalation(db, esc2.id, { status: 'resolved', resolution: 'Fixed' });
|
|
334
|
+
const active = await getActiveEscalationsForAgent(db, agentId);
|
|
333
335
|
expect(active).toHaveLength(1);
|
|
334
336
|
expect(active[0].reason).toBe('Pending');
|
|
335
337
|
});
|
|
336
|
-
it('should return empty array for agent with no active escalations', () => {
|
|
337
|
-
const active = getActiveEscalationsForAgent(db, 'non-existent-agent');
|
|
338
|
+
it('should return empty array for agent with no active escalations', async () => {
|
|
339
|
+
const active = await getActiveEscalationsForAgent(db, 'non-existent-agent');
|
|
338
340
|
expect(active).toEqual([]);
|
|
339
341
|
});
|
|
340
342
|
});
|