agentic-orchestrator 0.1.2 → 0.1.4
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/.claude/settings.local.json +15 -0
- package/CLAUDE.md +126 -0
- package/README.md +166 -25
- package/agentic/orchestrator/adapters.yaml +3 -0
- package/agentic/orchestrator/gates.yaml +47 -0
- package/agentic/orchestrator/policy.yaml +89 -0
- package/agentic/orchestrator/schemas/adapters.schema.json +12 -0
- package/agentic/orchestrator/schemas/gates.schema.json +6 -1
- package/agentic/orchestrator/schemas/index.schema.json +14 -0
- package/agentic/orchestrator/schemas/multi-project.schema.json +41 -0
- package/agentic/orchestrator/schemas/policy.schema.json +449 -52
- package/agentic/orchestrator/schemas/state.schema.json +16 -0
- package/agentic/orchestrator/tools/catalog.json +68 -0
- package/agentic/orchestrator/tools/schemas/input/cost.get.input.schema.json +10 -0
- package/agentic/orchestrator/tools/schemas/input/cost.record.input.schema.json +13 -0
- package/agentic/orchestrator/tools/schemas/input/feature.send_message.input.schema.json +11 -0
- package/agentic/orchestrator/tools/schemas/input/performance.get_analytics.input.schema.json +10 -0
- package/agentic/orchestrator/tools/schemas/input/performance.record_outcome.input.schema.json +18 -0
- package/agentic/orchestrator/tools/schemas/output/cost.get.output.schema.json +13 -0
- package/agentic/orchestrator/tools/schemas/output/cost.record.output.schema.json +13 -0
- package/agentic/orchestrator/tools/schemas/output/feature.ready_to_merge.output.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/output/feature.send_message.output.schema.json +23 -0
- package/agentic/orchestrator/tools/schemas/output/performance.get_analytics.output.schema.json +46 -0
- package/agentic/orchestrator/tools/schemas/output/performance.record_outcome.output.schema.json +10 -0
- package/agentic/orchestrator/tools.md +5 -0
- package/apps/control-plane/scripts/validate-architecture-rules.mjs +28 -2
- package/apps/control-plane/scripts/validate-docker-mcp-contract.mjs +12 -0
- package/apps/control-plane/scripts/validate-mcp-contracts.ts +92 -0
- package/apps/control-plane/src/application/adapters/adapter-registry.ts +169 -0
- package/apps/control-plane/src/application/multi-project-loader.ts +119 -0
- package/apps/control-plane/src/application/services/activity-monitor-service.ts +199 -0
- package/apps/control-plane/src/application/services/cost-tracking-service.ts +82 -0
- package/apps/control-plane/src/application/services/dependency-scheduler-service.ts +86 -0
- package/apps/control-plane/src/application/services/feature-deletion-service.ts +8 -7
- package/apps/control-plane/src/application/services/gate-interpolation-service.ts +15 -0
- package/apps/control-plane/src/application/services/gate-service.ts +38 -2
- package/apps/control-plane/src/application/services/instance-isolation-service.ts +18 -0
- package/apps/control-plane/src/application/services/issue-tracker-service.ts +469 -0
- package/apps/control-plane/src/application/services/merge-service.ts +67 -3
- package/apps/control-plane/src/application/services/notifier-service.ts +295 -0
- package/apps/control-plane/src/application/services/performance-analytics-service.ts +122 -0
- package/apps/control-plane/src/application/services/plan-service.ts +51 -0
- package/apps/control-plane/src/application/services/pr-monitor-service.ts +262 -0
- package/apps/control-plane/src/application/services/reactions-service.ts +175 -0
- package/apps/control-plane/src/application/services/reporting-service.ts +17 -2
- package/apps/control-plane/src/application/services/run-lease-service.ts +16 -38
- package/apps/control-plane/src/application/tools/tool-metadata.ts +4 -1
- package/apps/control-plane/src/cli/aop.ts +1 -1
- package/apps/control-plane/src/cli/attach-command-handler.ts +120 -0
- package/apps/control-plane/src/cli/cleanup-command-handler.ts +190 -0
- package/apps/control-plane/src/cli/cli-argument-parser.ts +69 -3
- package/apps/control-plane/src/cli/dashboard-command-handler.ts +57 -0
- package/apps/control-plane/src/cli/help-command-handler.ts +163 -0
- package/apps/control-plane/src/cli/init-command-handler.ts +609 -0
- package/apps/control-plane/src/cli/resume-command-handler.ts +1 -0
- package/apps/control-plane/src/cli/retry-command-handler.ts +138 -0
- package/apps/control-plane/src/cli/run-command-handler.ts +115 -3
- package/apps/control-plane/src/cli/send-command-handler.ts +65 -0
- package/apps/control-plane/src/cli/status-command-handler.ts +102 -2
- package/apps/control-plane/src/cli/types.ts +26 -1
- package/apps/control-plane/src/core/constants.ts +8 -2
- package/apps/control-plane/src/core/error-codes.ts +3 -1
- package/apps/control-plane/src/core/gates.ts +170 -50
- package/apps/control-plane/src/core/kernel.ts +280 -5
- package/apps/control-plane/src/core/path-layout.ts +12 -0
- package/apps/control-plane/src/core/tool-caller.ts +36 -0
- package/apps/control-plane/src/core/workspace-hooks.ts +87 -0
- package/apps/control-plane/src/interfaces/cli/bootstrap.ts +258 -9
- package/apps/control-plane/src/providers/providers.ts +235 -14
- package/apps/control-plane/src/supervisor/build-wave-executor.ts +129 -8
- package/apps/control-plane/src/supervisor/qa-wave-executor.ts +123 -5
- package/apps/control-plane/src/supervisor/run-coordinator.ts +143 -6
- package/apps/control-plane/src/supervisor/runtime.ts +135 -6
- package/apps/control-plane/src/supervisor/types.ts +12 -21
- package/apps/control-plane/src/supervisor/worker-decision-loop.ts +8 -0
- package/apps/control-plane/test/activity-monitor.spec.ts +294 -0
- package/apps/control-plane/test/adapter-registry.spec.ts +132 -0
- package/apps/control-plane/test/batch-operations.spec.ts +112 -0
- package/apps/control-plane/test/bootstrap-attach.spec.ts +102 -0
- package/apps/control-plane/test/bootstrap-edge-cases.spec.ts +252 -0
- package/apps/control-plane/test/bootstrap.spec.ts +560 -0
- package/apps/control-plane/test/cleanup-command.spec.ts +301 -0
- package/apps/control-plane/test/cli-helpers.spec.ts +404 -1
- package/apps/control-plane/test/cli.unit.spec.ts +182 -1
- package/apps/control-plane/test/collision-queue.spec.ts +104 -1
- package/apps/control-plane/test/core-utils.spec.ts +175 -2
- package/apps/control-plane/test/cost-tracking.spec.ts +143 -0
- package/apps/control-plane/test/dashboard-api.integration.spec.ts +247 -0
- package/apps/control-plane/test/dashboard-client.spec.ts +116 -0
- package/apps/control-plane/test/dashboard-command.spec.ts +103 -0
- package/apps/control-plane/test/dependency-scheduler.spec.ts +189 -0
- package/apps/control-plane/test/epoch-tracking.spec.ts +4 -4
- package/apps/control-plane/test/feature-deletion-service.spec.ts +422 -0
- package/apps/control-plane/test/feature-lifecycle.spec.ts +202 -0
- package/apps/control-plane/test/git-spawn-error.spec.ts +24 -0
- package/apps/control-plane/test/incremental-gates.spec.ts +137 -0
- package/apps/control-plane/test/init-wizard.spec.ts +506 -0
- package/apps/control-plane/test/instance-isolation.spec.ts +83 -0
- package/apps/control-plane/test/issue-tracker.spec.ts +890 -0
- package/apps/control-plane/test/kernel.coverage.spec.ts +3 -5
- package/apps/control-plane/test/kernel.coverage2.spec.ts +871 -0
- package/apps/control-plane/test/kernel.spec.ts +13 -11
- package/apps/control-plane/test/lock-service.spec.ts +508 -0
- package/apps/control-plane/test/mcp-helpers.spec.ts +176 -0
- package/apps/control-plane/test/mcp.spec.ts +50 -15
- package/apps/control-plane/test/merge-service.spec.ts +67 -4
- package/apps/control-plane/test/multi-project.spec.ts +372 -0
- package/apps/control-plane/test/notifier-service.spec.ts +388 -0
- package/apps/control-plane/test/parallel-gates.spec.ts +312 -0
- package/apps/control-plane/test/patch-service.spec.ts +253 -0
- package/apps/control-plane/test/performance-analytics.spec.ts +338 -0
- package/apps/control-plane/test/planning-wave-executor.spec.ts +168 -0
- package/apps/control-plane/test/pr-monitor.spec.ts +385 -0
- package/apps/control-plane/test/providers.spec.ts +344 -1
- package/apps/control-plane/test/reactions.spec.ts +392 -0
- package/apps/control-plane/test/resume-command.spec.ts +390 -0
- package/apps/control-plane/test/run-coordinator.spec.ts +481 -2
- package/apps/control-plane/test/schema-date-time.spec.ts +46 -0
- package/apps/control-plane/test/service-retry-paths.spec.ts +30 -0
- package/apps/control-plane/test/services.spec.ts +95 -2
- package/apps/control-plane/test/session-management.spec.ts +450 -0
- package/apps/control-plane/test/spec-ingestion.spec.ts +190 -0
- package/apps/control-plane/test/supervisor-collaborators.spec.ts +699 -2
- package/apps/control-plane/test/supervisor.spec.ts +36 -30
- package/apps/control-plane/test/supervisor.unit.spec.ts +405 -0
- package/apps/control-plane/test/worker-decision-loop.spec.ts +57 -0
- package/apps/control-plane/test/workspace-hooks.spec.ts +177 -0
- package/apps/control-plane/vitest.config.ts +21 -5
- package/dist/apps/control-plane/application/adapters/adapter-registry.d.ts +44 -0
- package/dist/apps/control-plane/application/adapters/adapter-registry.js +76 -0
- package/dist/apps/control-plane/application/adapters/adapter-registry.js.map +1 -0
- package/dist/apps/control-plane/application/multi-project-loader.d.ts +31 -0
- package/dist/apps/control-plane/application/multi-project-loader.js +82 -0
- package/dist/apps/control-plane/application/multi-project-loader.js.map +1 -0
- package/dist/apps/control-plane/application/services/activity-monitor-service.d.ts +43 -0
- package/dist/apps/control-plane/application/services/activity-monitor-service.js +132 -0
- package/dist/apps/control-plane/application/services/activity-monitor-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.d.ts +28 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.js +48 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/dependency-scheduler-service.d.ts +26 -0
- package/dist/apps/control-plane/application/services/dependency-scheduler-service.js +75 -0
- package/dist/apps/control-plane/application/services/dependency-scheduler-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.d.ts +2 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js +6 -7
- package/dist/apps/control-plane/application/services/feature-deletion-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/gate-interpolation-service.d.ts +7 -0
- package/dist/apps/control-plane/application/services/gate-interpolation-service.js +7 -0
- package/dist/apps/control-plane/application/services/gate-interpolation-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/gate-service.js +32 -2
- package/dist/apps/control-plane/application/services/gate-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/instance-isolation-service.d.ts +11 -0
- package/dist/apps/control-plane/application/services/instance-isolation-service.js +17 -0
- package/dist/apps/control-plane/application/services/instance-isolation-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/issue-tracker-service.d.ts +65 -0
- package/dist/apps/control-plane/application/services/issue-tracker-service.js +358 -0
- package/dist/apps/control-plane/application/services/issue-tracker-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/merge-service.d.ts +4 -0
- package/dist/apps/control-plane/application/services/merge-service.js +44 -2
- package/dist/apps/control-plane/application/services/merge-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/notifier-service.d.ts +74 -0
- package/dist/apps/control-plane/application/services/notifier-service.js +212 -0
- package/dist/apps/control-plane/application/services/notifier-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.d.ts +39 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.js +75 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/plan-service.d.ts +1 -0
- package/dist/apps/control-plane/application/services/plan-service.js +53 -0
- package/dist/apps/control-plane/application/services/plan-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/pr-monitor-service.d.ts +44 -0
- package/dist/apps/control-plane/application/services/pr-monitor-service.js +192 -0
- package/dist/apps/control-plane/application/services/pr-monitor-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/reactions-service.d.ts +67 -0
- package/dist/apps/control-plane/application/services/reactions-service.js +114 -0
- package/dist/apps/control-plane/application/services/reactions-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/reporting-service.d.ts +1 -0
- package/dist/apps/control-plane/application/services/reporting-service.js +13 -2
- package/dist/apps/control-plane/application/services/reporting-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/run-lease-service.d.ts +2 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js +14 -38
- package/dist/apps/control-plane/application/services/run-lease-service.js.map +1 -1
- package/dist/apps/control-plane/application/tools/tool-metadata.js +3 -1
- package/dist/apps/control-plane/application/tools/tool-metadata.js.map +1 -1
- package/dist/apps/control-plane/cli/aop.d.ts +1 -1
- package/dist/apps/control-plane/cli/aop.js +1 -1
- package/dist/apps/control-plane/cli/attach-command-handler.d.ts +12 -0
- package/dist/apps/control-plane/cli/attach-command-handler.js +98 -0
- package/dist/apps/control-plane/cli/attach-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/cleanup-command-handler.d.ts +12 -0
- package/dist/apps/control-plane/cli/cleanup-command-handler.js +162 -0
- package/dist/apps/control-plane/cli/cleanup-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.js +73 -3
- package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -1
- package/dist/apps/control-plane/cli/dashboard-command-handler.d.ts +7 -0
- package/dist/apps/control-plane/cli/dashboard-command-handler.js +45 -0
- package/dist/apps/control-plane/cli/dashboard-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/help-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/help-command-handler.js +146 -0
- package/dist/apps/control-plane/cli/help-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/init-command-handler.d.ts +26 -0
- package/dist/apps/control-plane/cli/init-command-handler.js +517 -0
- package/dist/apps/control-plane/cli/init-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/resume-command-handler.js +1 -1
- package/dist/apps/control-plane/cli/resume-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/retry-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/retry-command-handler.js +111 -0
- package/dist/apps/control-plane/cli/retry-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/run-command-handler.d.ts +5 -0
- package/dist/apps/control-plane/cli/run-command-handler.js +82 -3
- package/dist/apps/control-plane/cli/run-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/send-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/send-command-handler.js +55 -0
- package/dist/apps/control-plane/cli/send-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/status-command-handler.d.ts +12 -1
- package/dist/apps/control-plane/cli/status-command-handler.js +55 -2
- package/dist/apps/control-plane/cli/status-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/types.d.ts +26 -1
- package/dist/apps/control-plane/cli/types.js +15 -1
- package/dist/apps/control-plane/cli/types.js.map +1 -1
- package/dist/apps/control-plane/core/constants.d.ts +6 -0
- package/dist/apps/control-plane/core/constants.js +8 -2
- package/dist/apps/control-plane/core/constants.js.map +1 -1
- package/dist/apps/control-plane/core/error-codes.d.ts +2 -0
- package/dist/apps/control-plane/core/error-codes.js +3 -1
- package/dist/apps/control-plane/core/error-codes.js.map +1 -1
- package/dist/apps/control-plane/core/gates.d.ts +4 -0
- package/dist/apps/control-plane/core/gates.js +140 -43
- package/dist/apps/control-plane/core/gates.js.map +1 -1
- package/dist/apps/control-plane/core/kernel.d.ts +50 -1
- package/dist/apps/control-plane/core/kernel.js +220 -7
- package/dist/apps/control-plane/core/kernel.js.map +1 -1
- package/dist/apps/control-plane/core/path-layout.d.ts +3 -0
- package/dist/apps/control-plane/core/path-layout.js +9 -0
- package/dist/apps/control-plane/core/path-layout.js.map +1 -1
- package/dist/apps/control-plane/core/tool-caller.d.ts +32 -0
- package/dist/apps/control-plane/core/tool-caller.js +2 -0
- package/dist/apps/control-plane/core/tool-caller.js.map +1 -0
- package/dist/apps/control-plane/core/workspace-hooks.d.ts +20 -0
- package/dist/apps/control-plane/core/workspace-hooks.js +69 -0
- package/dist/apps/control-plane/core/workspace-hooks.js.map +1 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js +245 -9
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -1
- package/dist/apps/control-plane/providers/providers.d.ts +42 -3
- package/dist/apps/control-plane/providers/providers.js +216 -5
- package/dist/apps/control-plane/providers/providers.js.map +1 -1
- package/dist/apps/control-plane/supervisor/build-wave-executor.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js +115 -6
- package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/qa-wave-executor.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js +109 -5
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/run-coordinator.d.ts +15 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js +132 -6
- package/dist/apps/control-plane/supervisor/run-coordinator.js.map +1 -1
- package/dist/apps/control-plane/supervisor/runtime.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/runtime.js +110 -6
- package/dist/apps/control-plane/supervisor/runtime.js.map +1 -1
- package/dist/apps/control-plane/supervisor/types.d.ts +9 -16
- package/dist/apps/control-plane/supervisor/types.js.map +1 -1
- package/dist/apps/control-plane/supervisor/worker-decision-loop.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js +5 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js.map +1 -1
- package/eslint.config.mjs +2 -1
- package/package.json +12 -2
- package/packages/web-dashboard/next-env.d.ts +5 -0
- package/packages/web-dashboard/next.config.js +7 -0
- package/packages/web-dashboard/package.json +26 -0
- package/packages/web-dashboard/src/app/api/actions/route.ts +64 -0
- package/packages/web-dashboard/src/app/api/events/route.ts +51 -0
- package/packages/web-dashboard/src/app/api/features/[id]/checkout/route.ts +256 -0
- package/packages/web-dashboard/src/app/api/features/[id]/diff/route.ts +10 -0
- package/packages/web-dashboard/src/app/api/features/[id]/evidence/[artifact]/route.ts +25 -0
- package/packages/web-dashboard/src/app/api/features/[id]/review/route.ts +63 -0
- package/packages/web-dashboard/src/app/api/features/[id]/route.ts +16 -0
- package/packages/web-dashboard/src/app/api/projects/route.ts +31 -0
- package/packages/web-dashboard/src/app/api/status/route.ts +15 -0
- package/packages/web-dashboard/src/app/globals.css +2 -0
- package/packages/web-dashboard/src/app/layout.tsx +15 -0
- package/packages/web-dashboard/src/app/page.tsx +393 -0
- package/packages/web-dashboard/src/lib/aop-client.ts +244 -0
- package/packages/web-dashboard/src/lib/multi-project-config.ts +116 -0
- package/packages/web-dashboard/src/lib/orchestrator-tools.ts +284 -0
- package/packages/web-dashboard/src/lib/types.ts +58 -0
- package/packages/web-dashboard/tsconfig.json +40 -0
- package/packages/web-dashboard/vitest.config.ts +6 -0
- package/spec-files/completed/agentic_orchestrator_feature_gaps_closure_spec.md +1764 -0
- package/spec-files/outstanding/agentic_orchestrator_enterprise_governance_dashboard_spec.md +348 -0
- package/spec-files/outstanding/agentic_orchestrator_knowledge_canary_spec.md +344 -0
- package/spec-files/outstanding/agentic_orchestrator_observability_integrity_diagnostics_spec.md +374 -0
- package/spec-files/outstanding/agentic_orchestrator_performance_improvements_spec.md +1059 -0
- package/spec-files/outstanding/agentic_orchestrator_planning_review_quality_spec.md +466 -0
- package/spec-files/outstanding/agentic_orchestrator_quality_adoption_execution_spec.md +198 -0
- package/spec-files/outstanding/agentic_orchestrator_validator_hardening_spec.md +365 -0
- package/spec-files/progress.md +481 -52
- /package/spec-files/{agentic_orchestrator_cli_delete_command_spec.md → completed/agentic_orchestrator_cli_delete_command_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_dot_aop_generated_artifacts_spec.md → completed/agentic_orchestrator_dot_aop_generated_artifacts_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_mcp_formalization_spec.md → completed/agentic_orchestrator_mcp_formalization_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_oop_refactor_spec.md → completed/agentic_orchestrator_oop_refactor_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_single_global_orchestrator_spec.md → completed/agentic_orchestrator_single_global_orchestrator_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_spec.md → completed/agentic_orchestrator_spec.md} +0 -0
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
import { ERROR_CODES } from '../src/core/error-codes.js';
|
|
4
|
+
import { TOOLS } from '../src/core/constants.js';
|
|
4
5
|
import { CliArgumentParser } from '../src/cli/cli-argument-parser.js';
|
|
5
6
|
import { assertOkResponse, callCliTool } from '../src/cli/tooling.js';
|
|
6
7
|
import { canonicalFeatureIdFromPath, isCanonicalSpecPath, isLegacyCanonicalSpecPath } from '../src/cli/spec-utils.js';
|
|
8
|
+
import { RetryCommandHandler } from '../src/cli/retry-command-handler.js';
|
|
9
|
+
import { StatusCommandHandler } from '../src/cli/status-command-handler.js';
|
|
10
|
+
import { SendCommandHandler } from '../src/cli/send-command-handler.js';
|
|
7
11
|
|
|
8
12
|
describe('cli helper modules', () => {
|
|
9
13
|
it('GIVEN_empty_argv_or_extended_flags_WHEN_parsing_THEN_handles_defaults_and_all_supported_tokens', () => {
|
|
10
14
|
const parser = new CliArgumentParser();
|
|
11
15
|
expect(parser.parse([])).toEqual({ command: 'run' });
|
|
16
|
+
// --all, --port, --foreground, --dev, --force, --project, --summary, --auto, --batch, --takeover-stale-run
|
|
17
|
+
const miscParsed = parser.parse([
|
|
18
|
+
'status',
|
|
19
|
+
'--all',
|
|
20
|
+
'--port',
|
|
21
|
+
'9090',
|
|
22
|
+
'--foreground',
|
|
23
|
+
'--dev',
|
|
24
|
+
'--force',
|
|
25
|
+
'--project',
|
|
26
|
+
'my-project',
|
|
27
|
+
'--summary',
|
|
28
|
+
'--auto',
|
|
29
|
+
'--batch',
|
|
30
|
+
'--takeover-stale-run',
|
|
31
|
+
'--message',
|
|
32
|
+
'hello world'
|
|
33
|
+
]);
|
|
34
|
+
expect(miscParsed).toMatchObject({
|
|
35
|
+
command: 'status',
|
|
36
|
+
all: true,
|
|
37
|
+
port: 9090,
|
|
38
|
+
foreground: true,
|
|
39
|
+
dev: true,
|
|
40
|
+
force: true,
|
|
41
|
+
project: 'my-project',
|
|
42
|
+
summary: true,
|
|
43
|
+
auto: true,
|
|
44
|
+
batch: true,
|
|
45
|
+
takeover_stale_run: true,
|
|
46
|
+
message: 'hello world'
|
|
47
|
+
});
|
|
48
|
+
// --port with non-numeric next token (no value consumed)
|
|
49
|
+
const portNoNum = parser.parse(['run', '--port', '--foreground']);
|
|
50
|
+
expect(portNoNum.port).toBeUndefined();
|
|
51
|
+
expect(portNoNum.foreground).toBe(true);
|
|
12
52
|
expect(parser.parse(['-fi', '.aop/features/feature_x/spec.md'])).toMatchObject({
|
|
13
53
|
command: 'run',
|
|
14
54
|
file_input: '.aop/features/feature_x/spec.md'
|
|
@@ -53,6 +93,17 @@ describe('cli helper modules', () => {
|
|
|
53
93
|
remove_worktree: false,
|
|
54
94
|
remove_branch: 'force'
|
|
55
95
|
});
|
|
96
|
+
const positionalSend = parser.parse(['send', 'feature_positional', 'please rerun qa with latest fixes']);
|
|
97
|
+
expect(positionalSend).toMatchObject({
|
|
98
|
+
command: 'send',
|
|
99
|
+
feature_id: 'feature_positional',
|
|
100
|
+
message: 'please rerun qa with latest fixes'
|
|
101
|
+
});
|
|
102
|
+
const positionalAttach = parser.parse(['attach', 'feature_positional']);
|
|
103
|
+
expect(positionalAttach).toMatchObject({
|
|
104
|
+
command: 'attach',
|
|
105
|
+
feature_id: 'feature_positional'
|
|
106
|
+
});
|
|
56
107
|
expect(parser.resolveTransport('InProcess')).toBe('inprocess');
|
|
57
108
|
expect(parser.resolveTransport(undefined)).toBe('mcp');
|
|
58
109
|
});
|
|
@@ -103,3 +154,355 @@ describe('cli helper modules', () => {
|
|
|
103
154
|
);
|
|
104
155
|
});
|
|
105
156
|
});
|
|
157
|
+
|
|
158
|
+
describe('RetryCommandHandler', () => {
|
|
159
|
+
beforeEach(() => {
|
|
160
|
+
vi.clearAllMocks();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('GIVEN_missing_feature_id_WHEN_execute_called_THEN_throws_invalid_cli_args', async () => {
|
|
164
|
+
const toolClient = { call: vi.fn() };
|
|
165
|
+
const handler = new RetryCommandHandler(toolClient as never, 'run:test');
|
|
166
|
+
await expect(handler.execute({ command: 'retry' })).rejects.toMatchObject({
|
|
167
|
+
code: ERROR_CODES.INVALID_CLI_ARGS
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('GIVEN_invalid_feature_id_slug_WHEN_execute_called_THEN_throws_invalid_cli_args', async () => {
|
|
172
|
+
const toolClient = { call: vi.fn() };
|
|
173
|
+
const handler = new RetryCommandHandler(toolClient as never, 'run:test');
|
|
174
|
+
await expect(
|
|
175
|
+
handler.execute({ command: 'retry', feature_id: 'INVALID Feature ID' })
|
|
176
|
+
).rejects.toMatchObject({ code: ERROR_CODES.INVALID_CLI_ARGS });
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('GIVEN_valid_feature_id_no_force_WHEN_execute_called_THEN_runs_retry_gate_without_reset', async () => {
|
|
180
|
+
const callMock = vi.fn().mockImplementation(async (toolName: string) => {
|
|
181
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
182
|
+
return { ok: true, data: { front_matter: { version: 5, status: 'qa' } } };
|
|
183
|
+
}
|
|
184
|
+
if (toolName === TOOLS.GATES_RUN) {
|
|
185
|
+
return { ok: true, data: { overall: 'pass' } };
|
|
186
|
+
}
|
|
187
|
+
return { ok: true, data: {} };
|
|
188
|
+
});
|
|
189
|
+
const handler = new RetryCommandHandler({ call: callMock } as never, 'run:test');
|
|
190
|
+
const result = await handler.execute({ command: 'retry', feature_id: 'feature_abc' });
|
|
191
|
+
expect(result).toMatchObject({
|
|
192
|
+
ok: true,
|
|
193
|
+
data: {
|
|
194
|
+
feature_id: 'feature_abc',
|
|
195
|
+
retry_count_reset: false,
|
|
196
|
+
retry_executed: true,
|
|
197
|
+
retry_mode: 'full',
|
|
198
|
+
retry_outcome: 'pass'
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
expect(callMock).toHaveBeenCalledWith(
|
|
202
|
+
TOOLS.GATES_RUN,
|
|
203
|
+
expect.objectContaining({ feature_id: 'feature_abc', mode: 'full' }),
|
|
204
|
+
expect.any(Object)
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('GIVEN_valid_feature_id_with_force_WHEN_execute_called_THEN_gets_current_state_and_patches_retry_count', async () => {
|
|
209
|
+
const callMock = vi.fn().mockImplementation(async (toolName: string) => {
|
|
210
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
211
|
+
return { ok: true, data: { front_matter: { version: 5 } } };
|
|
212
|
+
}
|
|
213
|
+
if (toolName === TOOLS.GATES_RUN) {
|
|
214
|
+
return { ok: true, data: { overall: 'fail' } };
|
|
215
|
+
}
|
|
216
|
+
return { ok: true, data: {} };
|
|
217
|
+
});
|
|
218
|
+
const handler = new RetryCommandHandler({ call: callMock } as never, 'run:test');
|
|
219
|
+
const result = await handler.execute({ command: 'retry', feature_id: 'feature_abc', force: true });
|
|
220
|
+
|
|
221
|
+
expect(result).toMatchObject({
|
|
222
|
+
ok: true,
|
|
223
|
+
data: { feature_id: 'feature_abc', retry_count_reset: true }
|
|
224
|
+
});
|
|
225
|
+
expect(callMock).toHaveBeenCalledWith(
|
|
226
|
+
TOOLS.FEATURE_STATE_GET,
|
|
227
|
+
expect.objectContaining({ feature_id: 'feature_abc' }),
|
|
228
|
+
expect.any(Object)
|
|
229
|
+
);
|
|
230
|
+
expect(callMock).toHaveBeenCalledWith(
|
|
231
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
232
|
+
expect.objectContaining({ feature_id: 'feature_abc', expected_version: 5 }),
|
|
233
|
+
expect.any(Object)
|
|
234
|
+
);
|
|
235
|
+
expect(callMock).toHaveBeenCalledWith(
|
|
236
|
+
TOOLS.GATES_RUN,
|
|
237
|
+
expect.objectContaining({ feature_id: 'feature_abc' }),
|
|
238
|
+
expect.any(Object)
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
describe('StatusCommandHandler', () => {
|
|
244
|
+
beforeEach(() => {
|
|
245
|
+
vi.clearAllMocks();
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('GIVEN_options_all_with_project_statuses_WHEN_execute_THEN_returns_aggregate', async () => {
|
|
249
|
+
const toolClient = { call: vi.fn() };
|
|
250
|
+
const handler = new StatusCommandHandler(toolClient as never, 'run:test');
|
|
251
|
+
const projectStatuses = [{ name: 'proj1', path: '/path/to/proj1', status: 'ok' }];
|
|
252
|
+
const result = await handler.execute({ all: true, projectStatuses });
|
|
253
|
+
expect(result).toMatchObject({ ok: true, data: { projects: projectStatuses } });
|
|
254
|
+
expect(toolClient.call).not.toHaveBeenCalled();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('GIVEN_summary_mode_WHEN_execute_THEN_returns_summary_with_activity_states', async () => {
|
|
258
|
+
const recentTs = new Date(Date.now() - 60_000).toISOString();
|
|
259
|
+
const oldTs = new Date(Date.now() - 600_000).toISOString();
|
|
260
|
+
const features = [
|
|
261
|
+
{ feature_id: 'no_ts', status: 'planning' },
|
|
262
|
+
{ feature_id: 'recent', status: 'building', last_heartbeat_at: recentTs },
|
|
263
|
+
{ feature_id: 'old_one', status: 'merged', last_run_at: oldTs }
|
|
264
|
+
];
|
|
265
|
+
const toolClient = { call: vi.fn(async () => ({ ok: true, data: { features } })) };
|
|
266
|
+
const handler = new StatusCommandHandler(toolClient as never, 'run:test');
|
|
267
|
+
const result = await handler.execute({ summary: true });
|
|
268
|
+
|
|
269
|
+
expect(result).toMatchObject({
|
|
270
|
+
ok: true,
|
|
271
|
+
data: {
|
|
272
|
+
summary: [
|
|
273
|
+
{ feature_id: 'no_ts', status: 'planning', activity: 'unknown' },
|
|
274
|
+
{ feature_id: 'recent', status: 'building', activity: 'active' },
|
|
275
|
+
{ feature_id: 'old_one', status: 'merged', activity: 'idle' }
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('GIVEN_features_with_pr_field_WHEN_execute_THEN_adds_pr_info', async () => {
|
|
282
|
+
const prData = {
|
|
283
|
+
number: 42,
|
|
284
|
+
url: 'https://github.com/repo/pull/42',
|
|
285
|
+
ci_status: 'success',
|
|
286
|
+
review_decision: 'approved',
|
|
287
|
+
merge_ready: true,
|
|
288
|
+
pending_review_threads: 0,
|
|
289
|
+
has_conflicts: false,
|
|
290
|
+
merge_score: 100
|
|
291
|
+
};
|
|
292
|
+
const features = [{ feature_id: 'feature_a', status: 'review', pr: prData }];
|
|
293
|
+
const toolClient = { call: vi.fn(async () => ({ ok: true, data: { features } })) };
|
|
294
|
+
const handler = new StatusCommandHandler(toolClient as never, 'run:test');
|
|
295
|
+
const result = await handler.execute();
|
|
296
|
+
|
|
297
|
+
expect(result).toMatchObject({
|
|
298
|
+
ok: true,
|
|
299
|
+
data: {
|
|
300
|
+
features: [expect.objectContaining({ feature_id: 'feature_a', pr_info: prData })]
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('GIVEN_features_without_pr_field_WHEN_execute_THEN_no_pr_info_added', async () => {
|
|
306
|
+
const features = [{ feature_id: 'feature_b', status: 'planning' }];
|
|
307
|
+
const toolClient = { call: vi.fn(async () => ({ ok: true, data: { features } })) };
|
|
308
|
+
const handler = new StatusCommandHandler(toolClient as never, 'run:test');
|
|
309
|
+
const result = await handler.execute();
|
|
310
|
+
|
|
311
|
+
const data = (result as { ok: boolean; data: { features: Record<string, unknown>[] } }).data;
|
|
312
|
+
expect(data.features[0]).not.toHaveProperty('pr_info');
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
describe('SendCommandHandler', () => {
|
|
317
|
+
it('GIVEN_invalid_feature_id_WHEN_send_executed_THEN_throws_invalid_cli_args', async () => {
|
|
318
|
+
const toolClient = { call: vi.fn() };
|
|
319
|
+
const handler = new SendCommandHandler(toolClient as never, 'run:test');
|
|
320
|
+
await expect(
|
|
321
|
+
handler.execute({ command: 'send', feature_id: 'INVALID Feature ID', message: 'hello' })
|
|
322
|
+
).rejects.toMatchObject({ code: ERROR_CODES.INVALID_CLI_ARGS });
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
describe('RetryCommandHandler branch coverage', () => {
|
|
327
|
+
it('GIVEN_feature_in_merged_status_without_force_WHEN_execute_called_THEN_throws_invalid_cli_args', async () => {
|
|
328
|
+
const callMock = vi.fn().mockImplementation(async (toolName: string) => {
|
|
329
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
330
|
+
return { ok: true, data: { front_matter: { version: 1, status: 'merged' } } };
|
|
331
|
+
}
|
|
332
|
+
return { ok: true, data: {} };
|
|
333
|
+
});
|
|
334
|
+
const handler = new RetryCommandHandler({ call: callMock } as never, 'run:test');
|
|
335
|
+
await expect(
|
|
336
|
+
handler.execute({ command: 'retry', feature_id: 'feature_x' })
|
|
337
|
+
).rejects.toMatchObject({ code: ERROR_CODES.INVALID_CLI_ARGS });
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it('GIVEN_feature_blocked_with_forced_retry_fast_reason_WHEN_execute_called_THEN_infers_fast_mode', async () => {
|
|
341
|
+
const callMock = vi.fn().mockImplementation(async (toolName: string) => {
|
|
342
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
343
|
+
return { ok: true, data: { front_matter: { version: 2, status: 'blocked', status_reason: 'forced_retry:fast' } } };
|
|
344
|
+
}
|
|
345
|
+
if (toolName === TOOLS.GATES_RUN) {
|
|
346
|
+
return { ok: true, data: { overall: 'pass' } };
|
|
347
|
+
}
|
|
348
|
+
return { ok: true, data: {} };
|
|
349
|
+
});
|
|
350
|
+
const handler = new RetryCommandHandler({ call: callMock } as never, 'run:test');
|
|
351
|
+
const result = await handler.execute({ command: 'retry', feature_id: 'feature_y', force: true }) as Record<string, unknown>;
|
|
352
|
+
const data = result.data as Record<string, unknown>;
|
|
353
|
+
expect(data.retry_mode).toBe('fast');
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('GIVEN_feature_blocked_with_force_and_last_gate_mode_full_WHEN_execute_called_THEN_patches_status_to_qa', async () => {
|
|
357
|
+
const callMock = vi.fn().mockImplementation(async (toolName: string) => {
|
|
358
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
359
|
+
return { ok: true, data: { front_matter: { version: 3, status: 'blocked', evidence: { last_gate_mode: 'full' } } } };
|
|
360
|
+
}
|
|
361
|
+
if (toolName === TOOLS.GATES_RUN) {
|
|
362
|
+
return { ok: true, data: { overall: 'pass' } };
|
|
363
|
+
}
|
|
364
|
+
return { ok: true, data: {} };
|
|
365
|
+
});
|
|
366
|
+
const handler = new RetryCommandHandler({ call: callMock } as never, 'run:test');
|
|
367
|
+
const result = await handler.execute({ command: 'retry', feature_id: 'feature_z', force: true }) as Record<string, unknown>;
|
|
368
|
+
const data = result.data as Record<string, unknown>;
|
|
369
|
+
expect(data.retry_mode).toBe('full');
|
|
370
|
+
expect(data.forced_retry_executed).toBe(true);
|
|
371
|
+
// verify patch was called with status qa
|
|
372
|
+
expect(callMock).toHaveBeenCalledWith(
|
|
373
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
374
|
+
expect.objectContaining({ patch: expect.objectContaining({ front_matter: expect.objectContaining({ status: 'qa' }) }) }),
|
|
375
|
+
expect.any(Object)
|
|
376
|
+
);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it('GIVEN_feature_blocked_with_force_and_merge_gate_mode_WHEN_execute_called_THEN_patches_status_to_ready_to_merge', async () => {
|
|
380
|
+
const callMock = vi.fn().mockImplementation(async (toolName: string) => {
|
|
381
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
382
|
+
return { ok: true, data: { front_matter: { version: 4, status: 'blocked', evidence: { last_gate_mode: 'merge' } } } };
|
|
383
|
+
}
|
|
384
|
+
if (toolName === TOOLS.GATES_RUN) {
|
|
385
|
+
return { ok: true, data: { overall: 'pass' } };
|
|
386
|
+
}
|
|
387
|
+
return { ok: true, data: {} };
|
|
388
|
+
});
|
|
389
|
+
const handler = new RetryCommandHandler({ call: callMock } as never, 'run:test');
|
|
390
|
+
const result = await handler.execute({ command: 'retry', feature_id: 'feature_m', force: true }) as Record<string, unknown>;
|
|
391
|
+
const data = result.data as Record<string, unknown>;
|
|
392
|
+
expect(data.retry_mode).toBe('merge');
|
|
393
|
+
expect(callMock).toHaveBeenCalledWith(
|
|
394
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
395
|
+
expect.objectContaining({ patch: expect.objectContaining({ front_matter: expect.objectContaining({ status: 'ready_to_merge' }) }) }),
|
|
396
|
+
expect.any(Object)
|
|
397
|
+
);
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
describe('HelpCommandHandler', () => {
|
|
402
|
+
it('GIVEN_no_subcommand_WHEN_execute_called_THEN_returns_full_help_text', async () => {
|
|
403
|
+
const { HelpCommandHandler } = await import('../src/cli/help-command-handler.js');
|
|
404
|
+
const handler = new HelpCommandHandler();
|
|
405
|
+
const result = handler.execute();
|
|
406
|
+
expect(result.ok).toBe(true);
|
|
407
|
+
expect(result.data.help).toContain('aop — Agentic Orchestrator');
|
|
408
|
+
expect(result.data.help).toContain('Commands:');
|
|
409
|
+
expect(result.data.help).toContain('run');
|
|
410
|
+
expect(result.data.help).toContain('status');
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it('GIVEN_valid_subcommand_WHEN_execute_called_THEN_returns_detailed_help_for_command', async () => {
|
|
414
|
+
const { HelpCommandHandler } = await import('../src/cli/help-command-handler.js');
|
|
415
|
+
const handler = new HelpCommandHandler();
|
|
416
|
+
const result = handler.execute('run');
|
|
417
|
+
expect(result.ok).toBe(true);
|
|
418
|
+
expect(result.data.help).toContain('Usage: aop run');
|
|
419
|
+
expect(result.data.help).toContain('Flags:');
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it('GIVEN_unknown_subcommand_WHEN_execute_called_THEN_returns_full_help_text', async () => {
|
|
423
|
+
const { HelpCommandHandler } = await import('../src/cli/help-command-handler.js');
|
|
424
|
+
const handler = new HelpCommandHandler();
|
|
425
|
+
const result = handler.execute('nonexistent');
|
|
426
|
+
expect(result.ok).toBe(true);
|
|
427
|
+
expect(result.data.help).toContain('Commands:');
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it('GIVEN_command_without_flags_WHEN_execute_called_THEN_renders_without_flags_section', async () => {
|
|
431
|
+
const { HelpCommandHandler } = await import('../src/cli/help-command-handler.js');
|
|
432
|
+
const handler = new HelpCommandHandler();
|
|
433
|
+
const result = handler.execute('stop');
|
|
434
|
+
expect(result.ok).toBe(true);
|
|
435
|
+
expect(result.data.help).toContain('Usage: aop stop');
|
|
436
|
+
// stop has no flags
|
|
437
|
+
expect(result.data.help).not.toContain('Flags:');
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
describe('StatusCommandHandler feature with no timestamp', () => {
|
|
442
|
+
it('GIVEN_feature_with_no_timestamp_fields_WHEN_summary_THEN_activity_is_unknown', async () => {
|
|
443
|
+
const features = [
|
|
444
|
+
{ feature_id: 'feat_no_ts', status: 'planning' }
|
|
445
|
+
];
|
|
446
|
+
const toolClient = { call: vi.fn(async () => ({ ok: true, data: { features } })) };
|
|
447
|
+
const handler = new StatusCommandHandler(toolClient as never, 'run:test');
|
|
448
|
+
const result = await handler.execute({ summary: true }) as any;
|
|
449
|
+
expect(result.ok).toBe(true);
|
|
450
|
+
const found = result.data.summary.find((f: any) => f.feature_id === 'feat_no_ts');
|
|
451
|
+
expect(found?.activity).toBe('unknown');
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
describe('StatusCommandHandler explicit activity_state branches', () => {
|
|
456
|
+
it('GIVEN_features_with_idle_and_waiting_input_states_WHEN_summary_THEN_returns_correct_activity', async () => {
|
|
457
|
+
const toolClient = {
|
|
458
|
+
call: vi.fn(async () => ({
|
|
459
|
+
ok: true,
|
|
460
|
+
data: {
|
|
461
|
+
features: [
|
|
462
|
+
{ feature_id: 'feat_idle', status: 'building', activity_state: 'idle' },
|
|
463
|
+
{ feature_id: 'feat_waiting', status: 'building', activity_state: 'waiting_input' },
|
|
464
|
+
{ feature_id: 'feat_blocked', status: 'blocked', activity_state: 'blocked' },
|
|
465
|
+
{ feature_id: 'feat_exited', status: 'failed', activity_state: 'exited' }
|
|
466
|
+
]
|
|
467
|
+
}
|
|
468
|
+
}))
|
|
469
|
+
};
|
|
470
|
+
const handler = new StatusCommandHandler(toolClient as never, 'run:test');
|
|
471
|
+
const result = await handler.execute({ summary: true }) as any;
|
|
472
|
+
expect(result.ok).toBe(true);
|
|
473
|
+
const idle = result.data.summary.find((f: any) => f.feature_id === 'feat_idle');
|
|
474
|
+
expect(idle?.activity).toBe('idle');
|
|
475
|
+
const waiting = result.data.summary.find((f: any) => f.feature_id === 'feat_waiting');
|
|
476
|
+
expect(waiting?.activity).toBe('waiting_input');
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
it('GIVEN_feature_with_pr_field_WHEN_execute_without_summary_THEN_includes_pr_info', async () => {
|
|
480
|
+
const toolClient = {
|
|
481
|
+
call: vi.fn(async () => ({
|
|
482
|
+
ok: true,
|
|
483
|
+
data: {
|
|
484
|
+
features: [
|
|
485
|
+
{
|
|
486
|
+
feature_id: 'feat_pr',
|
|
487
|
+
status: 'ready_to_merge',
|
|
488
|
+
pr: {
|
|
489
|
+
number: 42,
|
|
490
|
+
url: 'https://github.com/pr/42',
|
|
491
|
+
ci_status: 'pass',
|
|
492
|
+
review_decision: 'approved',
|
|
493
|
+
merge_ready: true,
|
|
494
|
+
pending_review_threads: 0,
|
|
495
|
+
has_conflicts: false,
|
|
496
|
+
merge_score: 1
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
}
|
|
501
|
+
}))
|
|
502
|
+
};
|
|
503
|
+
const handler = new StatusCommandHandler(toolClient as never, 'run:test');
|
|
504
|
+
const result = await handler.execute({}) as any;
|
|
505
|
+
expect(result.ok).toBe(true);
|
|
506
|
+
expect(result.data.features[0].pr_info.number).toBe(42);
|
|
507
|
+
});
|
|
508
|
+
});
|
|
@@ -3,7 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
import { ERROR_CODES } from '../src/core/error-codes.js';
|
|
6
|
-
import { TOOLS } from '../src/core/constants.js';
|
|
6
|
+
import { STATUS, TOOLS } from '../src/core/constants.js';
|
|
7
7
|
|
|
8
8
|
const ensureLoadedMock = vi.hoisted(() => vi.fn(async () => undefined));
|
|
9
9
|
const recoverFromStateMock = vi.hoisted(
|
|
@@ -606,4 +606,185 @@ describe('aop CLI unit', () => {
|
|
|
606
606
|
}
|
|
607
607
|
});
|
|
608
608
|
});
|
|
609
|
+
|
|
610
|
+
it('GIVEN_resume_with_BUILDING_status_WHEN_main_runs_THEN_resumes_in_building_phase', async () => {
|
|
611
|
+
featureStateGetMock.mockResolvedValue({ data: { front_matter: { status: STATUS.BUILDING } } });
|
|
612
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
613
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
614
|
+
expect(code).toBe(0);
|
|
615
|
+
expect(writes[0]).toMatchObject({
|
|
616
|
+
ok: true,
|
|
617
|
+
data: { resumed: true, resumed_features: [expect.objectContaining({ resume_phase: STATUS.BUILDING })] }
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
it('GIVEN_resume_with_QA_status_WHEN_main_runs_THEN_resumes_in_qa_phase', async () => {
|
|
622
|
+
featureStateGetMock.mockResolvedValue({ data: { front_matter: { status: STATUS.QA } } });
|
|
623
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
624
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
625
|
+
expect(code).toBe(0);
|
|
626
|
+
expect(writes[0]).toMatchObject({
|
|
627
|
+
ok: true,
|
|
628
|
+
data: { resumed_features: [expect.objectContaining({ resume_phase: STATUS.QA })] }
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
it('GIVEN_resume_with_READY_TO_MERGE_status_WHEN_main_runs_THEN_resumes_in_ready_to_merge_phase', async () => {
|
|
633
|
+
featureStateGetMock.mockResolvedValue({ data: { front_matter: { status: STATUS.READY_TO_MERGE } } });
|
|
634
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
635
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
636
|
+
expect(code).toBe(0);
|
|
637
|
+
expect(writes[0]).toMatchObject({
|
|
638
|
+
ok: true,
|
|
639
|
+
data: { resumed_features: [expect.objectContaining({ resume_phase: STATUS.READY_TO_MERGE })] }
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
it('GIVEN_feature_with_MERGED_status_WHEN_resume_runs_THEN_filters_terminal_feature_and_returns_resumed_false', async () => {
|
|
644
|
+
featureStateGetMock.mockResolvedValue({ data: { front_matter: { status: STATUS.MERGED } } });
|
|
645
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
646
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
647
|
+
expect(code).toBe(0);
|
|
648
|
+
expect(writes[0]).toMatchObject({ ok: true, data: { resumed: false } });
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
it('GIVEN_feature_with_FAILED_status_WHEN_resume_runs_THEN_filters_terminal_feature', async () => {
|
|
652
|
+
featureStateGetMock.mockResolvedValue({ data: { front_matter: { status: STATUS.FAILED } } });
|
|
653
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
654
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
655
|
+
expect(code).toBe(0);
|
|
656
|
+
expect(writes[0]).toMatchObject({ ok: true, data: { resumed: false } });
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
it('GIVEN_feature_state_throws_WHEN_resume_builds_plan_THEN_silently_skips_broken_feature', async () => {
|
|
660
|
+
featureStateGetMock.mockRejectedValue(new Error('parse error'));
|
|
661
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
662
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
663
|
+
expect(code).toBe(0);
|
|
664
|
+
expect(writes[0]).toMatchObject({ ok: true, data: { resumed: false } });
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
it('GIVEN_runtimeSessions_has_feature_sessions_WHEN_resume_builds_plan_THEN_includes_session_features', async () => {
|
|
668
|
+
getRuntimeSessionsMock.mockResolvedValue({
|
|
669
|
+
run_id: 'run:from-sessions',
|
|
670
|
+
owner_instance_id: 'owner:from-sessions',
|
|
671
|
+
feature_sessions: { feature_resume: { planner: 'p1', builder: 'b1', qa: 'q1' } }
|
|
672
|
+
});
|
|
673
|
+
featureDiscoverSpecsMock.mockResolvedValue({ data: { specs: [] } });
|
|
674
|
+
readIndexMock.mockResolvedValue({ version: 1, active: [], blocked: [], blocked_queue: [] });
|
|
675
|
+
featureStateGetMock.mockResolvedValue({ data: { front_matter: { status: STATUS.BUILDING } } });
|
|
676
|
+
|
|
677
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
678
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
679
|
+
expect(code).toBe(0);
|
|
680
|
+
expect(writes[0]).toMatchObject({
|
|
681
|
+
ok: true,
|
|
682
|
+
data: { resumed: true, resumed_features: [expect.objectContaining({ feature_id: 'feature_resume' })] }
|
|
683
|
+
});
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
it('GIVEN_index_has_blocked_queue_entry_WHEN_resume_builds_plan_THEN_includes_blocked_queue_feature', async () => {
|
|
687
|
+
readIndexMock.mockResolvedValue({
|
|
688
|
+
version: 1,
|
|
689
|
+
active: [],
|
|
690
|
+
blocked: [],
|
|
691
|
+
blocked_queue: [{ feature_id: 'feature_queued' }]
|
|
692
|
+
});
|
|
693
|
+
getRuntimeSessionsMock.mockResolvedValue({
|
|
694
|
+
run_id: 'none',
|
|
695
|
+
owner_instance_id: 'none',
|
|
696
|
+
feature_sessions: {}
|
|
697
|
+
});
|
|
698
|
+
featureDiscoverSpecsMock.mockResolvedValue({ data: { specs: [] } });
|
|
699
|
+
featureStateGetMock.mockResolvedValue({ data: { front_matter: { status: STATUS.PLANNING } } });
|
|
700
|
+
|
|
701
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
702
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
703
|
+
expect(code).toBe(0);
|
|
704
|
+
expect(writes[0]).toMatchObject({ ok: true, data: { resumed: true } });
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
it('GIVEN_index_has_blocked_feature_WHEN_resume_builds_plan_THEN_includes_blocked_feature', async () => {
|
|
708
|
+
readIndexMock.mockResolvedValue({
|
|
709
|
+
version: 1,
|
|
710
|
+
active: [],
|
|
711
|
+
blocked: ['feature_blocked'],
|
|
712
|
+
blocked_queue: []
|
|
713
|
+
});
|
|
714
|
+
getRuntimeSessionsMock.mockResolvedValue({ run_id: 'none', owner_instance_id: 'none', feature_sessions: {} });
|
|
715
|
+
featureDiscoverSpecsMock.mockResolvedValue({ data: { specs: [] } });
|
|
716
|
+
featureStateGetMock.mockResolvedValue({ data: { front_matter: { status: STATUS.PLANNING } } });
|
|
717
|
+
|
|
718
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
719
|
+
expect(code).toBe(0);
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
it('GIVEN_multiple_features_in_different_phases_WHEN_resume_runs_THEN_sorted_by_phase_rank', async () => {
|
|
723
|
+
readIndexMock.mockResolvedValue({
|
|
724
|
+
version: 1,
|
|
725
|
+
active: ['feature_a', 'feature_b'],
|
|
726
|
+
blocked: [],
|
|
727
|
+
blocked_queue: []
|
|
728
|
+
});
|
|
729
|
+
getRuntimeSessionsMock.mockResolvedValue({ run_id: 'none', owner_instance_id: 'none', feature_sessions: {} });
|
|
730
|
+
featureDiscoverSpecsMock.mockResolvedValue({ data: { specs: [] } });
|
|
731
|
+
featureStateGetMock.mockImplementation(async (featureId?: string) => {
|
|
732
|
+
if (featureId === 'feature_a') {
|
|
733
|
+
return { data: { front_matter: { status: STATUS.QA } } };
|
|
734
|
+
}
|
|
735
|
+
return { data: { front_matter: { status: STATUS.PLANNING } } };
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
739
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
740
|
+
expect(code).toBe(0);
|
|
741
|
+
const features = writes[0].data.resumed_features as Array<{ feature_id: string }>;
|
|
742
|
+
// PLANNING (rank 0) should come before QA (rank 2)
|
|
743
|
+
expect(features[0].feature_id).toBe('feature_b');
|
|
744
|
+
expect(features[1].feature_id).toBe('feature_a');
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
it('GIVEN_batch_flag_with_folder_input_WHEN_run_command_THEN_executes_batch_mode', async () => {
|
|
748
|
+
const incoming = path.join(cwd, 'batch_folder');
|
|
749
|
+
await fs.mkdir(incoming, { recursive: true });
|
|
750
|
+
await fs.writeFile(path.join(incoming, 'batch_feature.md'), '# Batch\n', 'utf8');
|
|
751
|
+
|
|
752
|
+
toolCallMock.mockResolvedValue({ ok: true, data: {} });
|
|
753
|
+
|
|
754
|
+
const code = await main(['run', '-fl', 'batch_folder', '--batch'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
755
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
756
|
+
expect(code).toBe(0);
|
|
757
|
+
expect(writes[0]).toMatchObject({ ok: true, data: { command: 'batch-run', created: 1 } });
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
it('GIVEN_batch_mode_with_already_active_feature_WHEN_run_command_THEN_skips_it', async () => {
|
|
761
|
+
const incoming = path.join(cwd, 'batch_folder2');
|
|
762
|
+
await fs.mkdir(incoming, { recursive: true });
|
|
763
|
+
await fs.writeFile(path.join(incoming, 'existing_feature.md'), '# Existing\n', 'utf8');
|
|
764
|
+
|
|
765
|
+
// Write an index that marks this feature as already active
|
|
766
|
+
const indexDir = path.join(cwd, '.aop', 'features');
|
|
767
|
+
await fs.mkdir(indexDir, { recursive: true });
|
|
768
|
+
await fs.writeFile(path.join(indexDir, 'index.json'), JSON.stringify({ active: ['existing_feature'] }), 'utf8');
|
|
769
|
+
|
|
770
|
+
toolCallMock.mockResolvedValue({ ok: true, data: {} });
|
|
771
|
+
|
|
772
|
+
const code = await main(['run', '-fl', 'batch_folder2', '--batch'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
773
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
774
|
+
expect(code).toBe(0);
|
|
775
|
+
expect(writes[0]).toMatchObject({ ok: true, data: { command: 'batch-run', skipped: 1, created: 0 } });
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
it('GIVEN_batch_mode_with_init_failure_WHEN_run_command_THEN_counts_as_failed', async () => {
|
|
779
|
+
const incoming = path.join(cwd, 'batch_folder3');
|
|
780
|
+
await fs.mkdir(incoming, { recursive: true });
|
|
781
|
+
await fs.writeFile(path.join(incoming, 'fail_feature.md'), '# Fail\n', 'utf8');
|
|
782
|
+
|
|
783
|
+
toolCallMock.mockRejectedValue(new Error('init failure'));
|
|
784
|
+
|
|
785
|
+
const code = await main(['run', '-fl', 'batch_folder3', '--batch'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
786
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
787
|
+
expect(code).toBe(0);
|
|
788
|
+
expect(writes[0]).toMatchObject({ ok: true, data: { command: 'batch-run', failed: 1 } });
|
|
789
|
+
});
|
|
609
790
|
});
|