agentic-orchestrator 0.1.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/.dockerignore +24 -0
- package/.github/workflows/mcp-contract-validation.yml +38 -0
- package/Agentic-Orchestrator.iml +9 -0
- package/LICENSE +21 -0
- package/README.md +679 -0
- package/agentic/orchestrator/agents.yaml +14 -0
- package/agentic/orchestrator/gates.yaml +31 -0
- package/agentic/orchestrator/policy.yaml +145 -0
- package/agentic/orchestrator/prompts/builder.system.md +1 -0
- package/agentic/orchestrator/prompts/planner.system.md +15 -0
- package/agentic/orchestrator/prompts/qa.system.md +1 -0
- package/agentic/orchestrator/schemas/agents.schema.json +49 -0
- package/agentic/orchestrator/schemas/gates.schema.json +65 -0
- package/agentic/orchestrator/schemas/index.schema.json +108 -0
- package/agentic/orchestrator/schemas/plan.schema.json +127 -0
- package/agentic/orchestrator/schemas/policy.schema.json +227 -0
- package/agentic/orchestrator/schemas/qa_test_index.schema.json +53 -0
- package/agentic/orchestrator/schemas/state.schema.json +92 -0
- package/agentic/orchestrator/tools/catalog.json +399 -0
- package/agentic/orchestrator/tools/errors.schema.json +21 -0
- package/agentic/orchestrator/tools/protocol.json +8 -0
- package/agentic/orchestrator/tools/schemas/input/collisions.scan.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/evidence.latest.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.delete.input.schema.json +42 -0
- package/agentic/orchestrator/tools/schemas/input/feature.discover_specs.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/feature.get_context.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.init.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/feature.log_append.input.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/input/feature.ready_to_merge.input.schema.json +34 -0
- package/agentic/orchestrator/tools/schemas/input/feature.state_get.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.state_patch.input.schema.json +28 -0
- package/agentic/orchestrator/tools/schemas/input/gates.list.input.schema.json +11 -0
- package/agentic/orchestrator/tools/schemas/input/gates.run.input.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/input/locks.acquire.input.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/input/locks.release.input.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/input/mutating.schema.json +14 -0
- package/agentic/orchestrator/tools/schemas/input/plan.get.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/plan.submit.input.schema.json +28 -0
- package/agentic/orchestrator/tools/schemas/input/plan.update.input.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/input/qa.test_index_get.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/qa.test_index_update.input.schema.json +38 -0
- package/agentic/orchestrator/tools/schemas/input/read.schema.json +6 -0
- package/agentic/orchestrator/tools/schemas/input/repo.apply_patch.input.schema.json +25 -0
- package/agentic/orchestrator/tools/schemas/input/repo.diff.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/repo.diff_bundle.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/repo.ensure_worktree.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/repo.read_file.input.schema.json +20 -0
- package/agentic/orchestrator/tools/schemas/input/repo.search.input.schema.json +20 -0
- package/agentic/orchestrator/tools/schemas/input/repo.status.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/report.dashboard.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/report.feature_summary.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/output/collisions.scan.output.schema.json +17 -0
- package/agentic/orchestrator/tools/schemas/output/evidence.latest.output.schema.json +20 -0
- package/agentic/orchestrator/tools/schemas/output/feature.delete.output.schema.json +224 -0
- package/agentic/orchestrator/tools/schemas/output/feature.discover_specs.output.schema.json +32 -0
- package/agentic/orchestrator/tools/schemas/output/feature.get_context.output.schema.json +40 -0
- package/agentic/orchestrator/tools/schemas/output/feature.init.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/feature.log_append.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/feature.ready_to_merge.output.schema.json +30 -0
- package/agentic/orchestrator/tools/schemas/output/feature.state_get.output.schema.json +18 -0
- package/agentic/orchestrator/tools/schemas/output/feature.state_patch.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/gates.list.output.schema.json +42 -0
- package/agentic/orchestrator/tools/schemas/output/gates.run.output.schema.json +37 -0
- package/agentic/orchestrator/tools/schemas/output/locks.acquire.output.schema.json +34 -0
- package/agentic/orchestrator/tools/schemas/output/locks.release.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/plan.get.output.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/output/plan.submit.output.schema.json +23 -0
- package/agentic/orchestrator/tools/schemas/output/plan.update.output.schema.json +23 -0
- package/agentic/orchestrator/tools/schemas/output/qa.test_index_get.output.schema.json +22 -0
- package/agentic/orchestrator/tools/schemas/output/qa.test_index_update.output.schema.json +19 -0
- package/agentic/orchestrator/tools/schemas/output/repo.apply_patch.output.schema.json +33 -0
- package/agentic/orchestrator/tools/schemas/output/repo.diff.output.schema.json +19 -0
- package/agentic/orchestrator/tools/schemas/output/repo.diff_bundle.output.schema.json +32 -0
- package/agentic/orchestrator/tools/schemas/output/repo.ensure_worktree.output.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/output/repo.read_file.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/repo.search.output.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/output/repo.status.output.schema.json +27 -0
- package/agentic/orchestrator/tools/schemas/output/report.dashboard.output.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/output/report.feature_summary.output.schema.json +36 -0
- package/agentic/orchestrator/tools/schemas/output/standard_success.schema.json +6 -0
- package/agentic/orchestrator/tools.md +32 -0
- package/apps/control-plane/project.json +39 -0
- package/apps/control-plane/scripts/validate-architecture-rules.mjs +170 -0
- package/apps/control-plane/scripts/validate-docker-mcp-contract.mjs +84 -0
- package/apps/control-plane/scripts/validate-mcp-contracts.ts +61 -0
- package/apps/control-plane/src/application/services/collision-queue-service.ts +227 -0
- package/apps/control-plane/src/application/services/feature-deletion-service.ts +459 -0
- package/apps/control-plane/src/application/services/feature-lifecycle-service.ts +177 -0
- package/apps/control-plane/src/application/services/feature-state-service.ts +125 -0
- package/apps/control-plane/src/application/services/gate-service.ts +232 -0
- package/apps/control-plane/src/application/services/lock-service.ts +298 -0
- package/apps/control-plane/src/application/services/merge-service.ts +246 -0
- package/apps/control-plane/src/application/services/patch-service.ts +259 -0
- package/apps/control-plane/src/application/services/plan-service.ts +302 -0
- package/apps/control-plane/src/application/services/qa-index-service.ts +98 -0
- package/apps/control-plane/src/application/services/reporting-service.ts +120 -0
- package/apps/control-plane/src/application/services/run-lease-service.ts +340 -0
- package/apps/control-plane/src/application/tools/tool-metadata.ts +56 -0
- package/apps/control-plane/src/application/tools/tool-router.ts +43 -0
- package/apps/control-plane/src/cli/aop.ts +31 -0
- package/apps/control-plane/src/cli/cli-argument-parser.ts +116 -0
- package/apps/control-plane/src/cli/delete-command-handler.ts +90 -0
- package/apps/control-plane/src/cli/io.ts +14 -0
- package/apps/control-plane/src/cli/resume-command-handler.ts +228 -0
- package/apps/control-plane/src/cli/run-command-handler.ts +57 -0
- package/apps/control-plane/src/cli/spec-ingestion-service.ts +88 -0
- package/apps/control-plane/src/cli/spec-input-resolver.ts +95 -0
- package/apps/control-plane/src/cli/spec-utils.ts +40 -0
- package/apps/control-plane/src/cli/status-command-handler.ts +17 -0
- package/apps/control-plane/src/cli/stop-command-handler.ts +5 -0
- package/apps/control-plane/src/cli/tooling.ts +36 -0
- package/apps/control-plane/src/cli/types.ts +34 -0
- package/apps/control-plane/src/core/collisions.ts +121 -0
- package/apps/control-plane/src/core/constants.ts +72 -0
- package/apps/control-plane/src/core/error-codes.ts +54 -0
- package/apps/control-plane/src/core/frontmatter.ts +42 -0
- package/apps/control-plane/src/core/fs.ts +173 -0
- package/apps/control-plane/src/core/gates.ts +361 -0
- package/apps/control-plane/src/core/git.ts +115 -0
- package/apps/control-plane/src/core/kernel.ts +1077 -0
- package/apps/control-plane/src/core/patch.ts +152 -0
- package/apps/control-plane/src/core/path-layout.ts +113 -0
- package/apps/control-plane/src/core/path-rules.ts +71 -0
- package/apps/control-plane/src/core/qa-index.ts +179 -0
- package/apps/control-plane/src/core/response.ts +62 -0
- package/apps/control-plane/src/core/runtime-sessions.ts +20 -0
- package/apps/control-plane/src/core/schemas.ts +125 -0
- package/apps/control-plane/src/index.ts +21 -0
- package/apps/control-plane/src/interfaces/cli/bootstrap.ts +100 -0
- package/apps/control-plane/src/mcp/kernel-tool-executor.ts +39 -0
- package/apps/control-plane/src/mcp/mcp-server-adapter.ts +74 -0
- package/apps/control-plane/src/mcp/operation-ledger.ts +108 -0
- package/apps/control-plane/src/mcp/protocol-contract.ts +9 -0
- package/apps/control-plane/src/mcp/runtime-factory.ts +105 -0
- package/apps/control-plane/src/mcp/runtime-types.ts +44 -0
- package/apps/control-plane/src/mcp/token-auth-verifier.ts +63 -0
- package/apps/control-plane/src/mcp/token-claims-validator.ts +72 -0
- package/apps/control-plane/src/mcp/token-codec.ts +62 -0
- package/apps/control-plane/src/mcp/tool-authorizer.ts +43 -0
- package/apps/control-plane/src/mcp/tool-client.ts +78 -0
- package/apps/control-plane/src/mcp/tool-contract-validator.ts +83 -0
- package/apps/control-plane/src/mcp/tool-registry-loader.ts +135 -0
- package/apps/control-plane/src/mcp/tool-runtime.ts +336 -0
- package/apps/control-plane/src/mcp/tools-markdown-generator.ts +26 -0
- package/apps/control-plane/src/mcp/transport-types.ts +16 -0
- package/apps/control-plane/src/mcp/types.ts +2 -0
- package/apps/control-plane/src/providers/providers.ts +177 -0
- package/apps/control-plane/src/supervisor/build-wave-executor.ts +55 -0
- package/apps/control-plane/src/supervisor/lease-heartbeat-service.ts +22 -0
- package/apps/control-plane/src/supervisor/planning-wave-executor.ts +316 -0
- package/apps/control-plane/src/supervisor/prompt-bundle-loader.ts +62 -0
- package/apps/control-plane/src/supervisor/qa-wave-executor.ts +99 -0
- package/apps/control-plane/src/supervisor/run-coordinator.ts +224 -0
- package/apps/control-plane/src/supervisor/runtime.ts +347 -0
- package/apps/control-plane/src/supervisor/session-orchestrator.ts +268 -0
- package/apps/control-plane/src/supervisor/types.ts +149 -0
- package/apps/control-plane/src/supervisor/worker-decision-loop.ts +299 -0
- package/apps/control-plane/test/aop.spec.ts +101 -0
- package/apps/control-plane/test/cli-helpers.spec.ts +102 -0
- package/apps/control-plane/test/cli.spec.ts +12 -0
- package/apps/control-plane/test/cli.unit.spec.ts +609 -0
- package/apps/control-plane/test/collision-queue.spec.ts +158 -0
- package/apps/control-plane/test/collisions.spec.ts +138 -0
- package/apps/control-plane/test/core-utils.spec.ts +102 -0
- package/apps/control-plane/test/delete-command-handler.spec.ts +202 -0
- package/apps/control-plane/test/epoch-tracking.spec.ts +121 -0
- package/apps/control-plane/test/gates.spec.ts +452 -0
- package/apps/control-plane/test/helpers.ts +68 -0
- package/apps/control-plane/test/index.spec.ts +18 -0
- package/apps/control-plane/test/kernel-collision-replay.spec.ts +222 -0
- package/apps/control-plane/test/kernel.branches.spec.ts +321 -0
- package/apps/control-plane/test/kernel.coverage.spec.ts +408 -0
- package/apps/control-plane/test/kernel.spec.ts +369 -0
- package/apps/control-plane/test/mcp-helpers.spec.ts +195 -0
- package/apps/control-plane/test/mcp.spec.ts +776 -0
- package/apps/control-plane/test/merge-service.spec.ts +357 -0
- package/apps/control-plane/test/plan-service.spec.ts +195 -0
- package/apps/control-plane/test/planning-wave-executor.spec.ts +229 -0
- package/apps/control-plane/test/providers.spec.ts +168 -0
- package/apps/control-plane/test/qa-index-service.spec.ts +187 -0
- package/apps/control-plane/test/qa-index.spec.ts +317 -0
- package/apps/control-plane/test/response.spec.ts +55 -0
- package/apps/control-plane/test/run-coordinator.spec.ts +334 -0
- package/apps/control-plane/test/schema-date-time.spec.ts +170 -0
- package/apps/control-plane/test/service-retry-paths.spec.ts +305 -0
- package/apps/control-plane/test/services.spec.ts +693 -0
- package/apps/control-plane/test/spec-input-resolver.spec.ts +76 -0
- package/apps/control-plane/test/supervisor-collaborators.spec.ts +201 -0
- package/apps/control-plane/test/supervisor.calltool.spec.ts +120 -0
- package/apps/control-plane/test/supervisor.spec.ts +415 -0
- package/apps/control-plane/test/supervisor.unit.spec.ts +522 -0
- package/apps/control-plane/test/token-auth-verifier.spec.ts +111 -0
- package/apps/control-plane/test/tool-registry-loader.spec.ts +268 -0
- package/apps/control-plane/test/tool-runtime.spec.ts +294 -0
- package/apps/control-plane/test/worker-decision-loop.spec.ts +587 -0
- package/apps/control-plane/tsconfig.build.json +17 -0
- package/apps/control-plane/tsconfig.json +11 -0
- package/apps/control-plane/vitest.config.ts +28 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.d.ts +69 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.js +158 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.d.ts +79 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js +336 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.d.ts +81 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js +117 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-state-service.d.ts +34 -0
- package/dist/apps/control-plane/application/services/feature-state-service.js +90 -0
- package/dist/apps/control-plane/application/services/feature-state-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/gate-service.d.ts +46 -0
- package/dist/apps/control-plane/application/services/gate-service.js +160 -0
- package/dist/apps/control-plane/application/services/gate-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/lock-service.d.ts +56 -0
- package/dist/apps/control-plane/application/services/lock-service.js +242 -0
- package/dist/apps/control-plane/application/services/lock-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/merge-service.d.ts +33 -0
- package/dist/apps/control-plane/application/services/merge-service.js +194 -0
- package/dist/apps/control-plane/application/services/merge-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/patch-service.d.ts +39 -0
- package/dist/apps/control-plane/application/services/patch-service.js +189 -0
- package/dist/apps/control-plane/application/services/patch-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/plan-service.d.ts +60 -0
- package/dist/apps/control-plane/application/services/plan-service.js +234 -0
- package/dist/apps/control-plane/application/services/plan-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/qa-index-service.d.ts +26 -0
- package/dist/apps/control-plane/application/services/qa-index-service.js +66 -0
- package/dist/apps/control-plane/application/services/qa-index-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/reporting-service.d.ts +47 -0
- package/dist/apps/control-plane/application/services/reporting-service.js +90 -0
- package/dist/apps/control-plane/application/services/reporting-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/run-lease-service.d.ts +74 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js +263 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js.map +1 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.d.ts +8 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.js +37 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.js.map +1 -0
- package/dist/apps/control-plane/application/tools/tool-router.d.ts +16 -0
- package/dist/apps/control-plane/application/tools/tool-router.js +25 -0
- package/dist/apps/control-plane/application/tools/tool-router.js.map +1 -0
- package/dist/apps/control-plane/cli/aop.d.ts +5 -0
- package/dist/apps/control-plane/cli/aop.js +19 -0
- package/dist/apps/control-plane/cli/aop.js.map +1 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.d.ts +5 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.js +109 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -0
- package/dist/apps/control-plane/cli/delete-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/delete-command-handler.js +77 -0
- package/dist/apps/control-plane/cli/delete-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/io.d.ts +2 -0
- package/dist/apps/control-plane/cli/io.js +14 -0
- package/dist/apps/control-plane/cli/io.js.map +1 -0
- package/dist/apps/control-plane/cli/resume-command-handler.d.ts +17 -0
- package/dist/apps/control-plane/cli/resume-command-handler.js +178 -0
- package/dist/apps/control-plane/cli/resume-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/run-command-handler.d.ts +15 -0
- package/dist/apps/control-plane/cli/run-command-handler.js +39 -0
- package/dist/apps/control-plane/cli/run-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.d.ts +8 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.js +77 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-input-resolver.d.ts +9 -0
- package/dist/apps/control-plane/cli/spec-input-resolver.js +81 -0
- package/dist/apps/control-plane/cli/spec-input-resolver.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-utils.d.ts +3 -0
- package/dist/apps/control-plane/cli/spec-utils.js +36 -0
- package/dist/apps/control-plane/cli/spec-utils.js.map +1 -0
- package/dist/apps/control-plane/cli/status-command-handler.d.ts +7 -0
- package/dist/apps/control-plane/cli/status-command-handler.js +14 -0
- package/dist/apps/control-plane/cli/status-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/stop-command-handler.d.ts +3 -0
- package/dist/apps/control-plane/cli/stop-command-handler.js +6 -0
- package/dist/apps/control-plane/cli/stop-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/tooling.d.ts +4 -0
- package/dist/apps/control-plane/cli/tooling.js +24 -0
- package/dist/apps/control-plane/cli/tooling.js.map +1 -0
- package/dist/apps/control-plane/cli/types.d.ts +31 -0
- package/dist/apps/control-plane/cli/types.js +2 -0
- package/dist/apps/control-plane/cli/types.js.map +1 -0
- package/dist/apps/control-plane/core/collisions.d.ts +39 -0
- package/dist/apps/control-plane/core/collisions.js +78 -0
- package/dist/apps/control-plane/core/collisions.js.map +1 -0
- package/dist/apps/control-plane/core/constants.d.ts +64 -0
- package/dist/apps/control-plane/core/constants.js +64 -0
- package/dist/apps/control-plane/core/constants.js.map +1 -0
- package/dist/apps/control-plane/core/error-codes.d.ts +50 -0
- package/dist/apps/control-plane/core/error-codes.js +52 -0
- package/dist/apps/control-plane/core/error-codes.js.map +1 -0
- package/dist/apps/control-plane/core/frontmatter.d.ts +11 -0
- package/dist/apps/control-plane/core/frontmatter.js +30 -0
- package/dist/apps/control-plane/core/frontmatter.js.map +1 -0
- package/dist/apps/control-plane/core/fs.d.ts +33 -0
- package/dist/apps/control-plane/core/fs.js +134 -0
- package/dist/apps/control-plane/core/fs.js.map +1 -0
- package/dist/apps/control-plane/core/gates.d.ts +88 -0
- package/dist/apps/control-plane/core/gates.js +229 -0
- package/dist/apps/control-plane/core/gates.js.map +1 -0
- package/dist/apps/control-plane/core/git.d.ts +31 -0
- package/dist/apps/control-plane/core/git.js +79 -0
- package/dist/apps/control-plane/core/git.js.map +1 -0
- package/dist/apps/control-plane/core/kernel.d.ts +445 -0
- package/dist/apps/control-plane/core/kernel.js +805 -0
- package/dist/apps/control-plane/core/kernel.js.map +1 -0
- package/dist/apps/control-plane/core/patch.d.ts +23 -0
- package/dist/apps/control-plane/core/patch.js +118 -0
- package/dist/apps/control-plane/core/patch.js.map +1 -0
- package/dist/apps/control-plane/core/path-layout.d.ts +23 -0
- package/dist/apps/control-plane/core/path-layout.js +90 -0
- package/dist/apps/control-plane/core/path-layout.js.map +1 -0
- package/dist/apps/control-plane/core/path-rules.d.ts +13 -0
- package/dist/apps/control-plane/core/path-rules.js +52 -0
- package/dist/apps/control-plane/core/path-rules.js.map +1 -0
- package/dist/apps/control-plane/core/qa-index.d.ts +53 -0
- package/dist/apps/control-plane/core/qa-index.js +112 -0
- package/dist/apps/control-plane/core/qa-index.js.map +1 -0
- package/dist/apps/control-plane/core/response.d.ts +19 -0
- package/dist/apps/control-plane/core/response.js +34 -0
- package/dist/apps/control-plane/core/response.js.map +1 -0
- package/dist/apps/control-plane/core/runtime-sessions.d.ts +19 -0
- package/dist/apps/control-plane/core/runtime-sessions.js +2 -0
- package/dist/apps/control-plane/core/runtime-sessions.js.map +1 -0
- package/dist/apps/control-plane/core/schemas.d.ts +23 -0
- package/dist/apps/control-plane/core/schemas.js +80 -0
- package/dist/apps/control-plane/core/schemas.js.map +1 -0
- package/dist/apps/control-plane/index.d.ts +11 -0
- package/dist/apps/control-plane/index.js +9 -0
- package/dist/apps/control-plane/index.js.map +1 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.d.ts +2 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js +86 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.d.ts +14 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js +26 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js.map +1 -0
- package/dist/apps/control-plane/mcp/mcp-server-adapter.d.ts +19 -0
- package/dist/apps/control-plane/mcp/mcp-server-adapter.js +55 -0
- package/dist/apps/control-plane/mcp/mcp-server-adapter.js.map +1 -0
- package/dist/apps/control-plane/mcp/operation-ledger.d.ts +21 -0
- package/dist/apps/control-plane/mcp/operation-ledger.js +75 -0
- package/dist/apps/control-plane/mcp/operation-ledger.js.map +1 -0
- package/dist/apps/control-plane/mcp/protocol-contract.d.ts +8 -0
- package/dist/apps/control-plane/mcp/protocol-contract.js +9 -0
- package/dist/apps/control-plane/mcp/protocol-contract.js.map +1 -0
- package/dist/apps/control-plane/mcp/runtime-factory.d.ts +38 -0
- package/dist/apps/control-plane/mcp/runtime-factory.js +71 -0
- package/dist/apps/control-plane/mcp/runtime-factory.js.map +1 -0
- package/dist/apps/control-plane/mcp/runtime-types.d.ts +40 -0
- package/dist/apps/control-plane/mcp/runtime-types.js +2 -0
- package/dist/apps/control-plane/mcp/runtime-types.js.map +1 -0
- package/dist/apps/control-plane/mcp/token-auth-verifier.d.ts +24 -0
- package/dist/apps/control-plane/mcp/token-auth-verifier.js +45 -0
- package/dist/apps/control-plane/mcp/token-auth-verifier.js.map +1 -0
- package/dist/apps/control-plane/mcp/token-claims-validator.d.ts +9 -0
- package/dist/apps/control-plane/mcp/token-claims-validator.js +62 -0
- package/dist/apps/control-plane/mcp/token-claims-validator.js.map +1 -0
- package/dist/apps/control-plane/mcp/token-codec.d.ts +11 -0
- package/dist/apps/control-plane/mcp/token-codec.js +46 -0
- package/dist/apps/control-plane/mcp/token-codec.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-authorizer.d.ts +8 -0
- package/dist/apps/control-plane/mcp/tool-authorizer.js +36 -0
- package/dist/apps/control-plane/mcp/tool-authorizer.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-client.d.ts +30 -0
- package/dist/apps/control-plane/mcp/tool-client.js +50 -0
- package/dist/apps/control-plane/mcp/tool-client.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-contract-validator.d.ts +29 -0
- package/dist/apps/control-plane/mcp/tool-contract-validator.js +61 -0
- package/dist/apps/control-plane/mcp/tool-contract-validator.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.d.ts +15 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.js +109 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-runtime.d.ts +34 -0
- package/dist/apps/control-plane/mcp/tool-runtime.js +252 -0
- package/dist/apps/control-plane/mcp/tool-runtime.js.map +1 -0
- package/dist/apps/control-plane/mcp/tools-markdown-generator.d.ts +7 -0
- package/dist/apps/control-plane/mcp/tools-markdown-generator.js +22 -0
- package/dist/apps/control-plane/mcp/tools-markdown-generator.js.map +1 -0
- package/dist/apps/control-plane/mcp/transport-types.d.ts +14 -0
- package/dist/apps/control-plane/mcp/transport-types.js +2 -0
- package/dist/apps/control-plane/mcp/transport-types.js.map +1 -0
- package/dist/apps/control-plane/mcp/types.d.ts +2 -0
- package/dist/apps/control-plane/mcp/types.js +3 -0
- package/dist/apps/control-plane/mcp/types.js.map +1 -0
- package/dist/apps/control-plane/providers/providers.d.ts +72 -0
- package/dist/apps/control-plane/providers/providers.js +94 -0
- package/dist/apps/control-plane/providers/providers.js.map +1 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.d.ts +13 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js +40 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -0
- package/dist/apps/control-plane/supervisor/lease-heartbeat-service.d.ts +12 -0
- package/dist/apps/control-plane/supervisor/lease-heartbeat-service.js +14 -0
- package/dist/apps/control-plane/supervisor/lease-heartbeat-service.js.map +1 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.d.ts +19 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js +249 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js.map +1 -0
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.d.ts +9 -0
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js +53 -0
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js.map +1 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.d.ts +24 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js +70 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.d.ts +49 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js +162 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js.map +1 -0
- package/dist/apps/control-plane/supervisor/runtime.d.ts +58 -0
- package/dist/apps/control-plane/supervisor/runtime.js +270 -0
- package/dist/apps/control-plane/supervisor/runtime.js.map +1 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.d.ts +29 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.js +211 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.js.map +1 -0
- package/dist/apps/control-plane/supervisor/types.d.ts +148 -0
- package/dist/apps/control-plane/supervisor/types.js +2 -0
- package/dist/apps/control-plane/supervisor/types.js.map +1 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.d.ts +37 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js +236 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js.map +1 -0
- package/docker/mcp.Dockerfile +14 -0
- package/docker/mcp.compose.yaml +15 -0
- package/docker/mcp.entrypoint.sh +17 -0
- package/eslint.config.mjs +93 -0
- package/example-configurations/README.md +26 -0
- package/example-configurations/java/agents.yaml +14 -0
- package/example-configurations/java/gates.yaml +29 -0
- package/example-configurations/java/policy.yaml +148 -0
- package/example-configurations/node/agents.yaml +14 -0
- package/example-configurations/node/gates.yaml +32 -0
- package/example-configurations/node/policy.yaml +143 -0
- package/nx.json +16 -0
- package/package.json +39 -0
- package/prompts/vitest-testing-standards.instructions.md +204 -0
- package/scripts/dev-shell-env.sh +7 -0
- package/scripts/nx-safe.mjs +33 -0
- package/spec-files/agentic_orchestrator_cli_delete_command_spec.md +310 -0
- package/spec-files/agentic_orchestrator_dot_aop_generated_artifacts_spec.md +211 -0
- package/spec-files/agentic_orchestrator_mcp_formalization_spec.md +379 -0
- package/spec-files/agentic_orchestrator_oop_refactor_spec.md +415 -0
- package/spec-files/agentic_orchestrator_single_global_orchestrator_spec.md +265 -0
- package/spec-files/agentic_orchestrator_spec.md +1334 -0
- package/spec-files/progress.md +452 -0
- package/tsconfig.base.json +15 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { ERROR_CODES } from '../src/core/error-codes.js';
|
|
6
|
+
import { TOOLS } from '../src/core/constants.js';
|
|
7
|
+
|
|
8
|
+
const ensureLoadedMock = vi.hoisted(() => vi.fn(async () => undefined));
|
|
9
|
+
const recoverFromStateMock = vi.hoisted(
|
|
10
|
+
() =>
|
|
11
|
+
vi.fn(async () => ({
|
|
12
|
+
data: {
|
|
13
|
+
recovered: true,
|
|
14
|
+
stale_features: [] as string[],
|
|
15
|
+
active: {}
|
|
16
|
+
}
|
|
17
|
+
}))
|
|
18
|
+
);
|
|
19
|
+
const createToolingRuntimeMock = vi.hoisted(() => vi.fn(async () => ({ runtime: 'ok' })));
|
|
20
|
+
const resolveToolClientMock = vi.hoisted(() => vi.fn());
|
|
21
|
+
const toolCallMock = vi.hoisted(() => vi.fn());
|
|
22
|
+
const readIndexMock = vi.hoisted(
|
|
23
|
+
() =>
|
|
24
|
+
vi.fn(async () => ({
|
|
25
|
+
version: 1,
|
|
26
|
+
active: ['feature_resume'],
|
|
27
|
+
blocked: [],
|
|
28
|
+
blocked_queue: []
|
|
29
|
+
}))
|
|
30
|
+
);
|
|
31
|
+
const getRuntimeSessionsMock = vi.hoisted(
|
|
32
|
+
() =>
|
|
33
|
+
vi.fn(async () => ({
|
|
34
|
+
run_id: 'run:resume',
|
|
35
|
+
owner_instance_id: 'owner:resume',
|
|
36
|
+
feature_sessions: {}
|
|
37
|
+
}))
|
|
38
|
+
);
|
|
39
|
+
const featureDiscoverSpecsMock = vi.hoisted(
|
|
40
|
+
() =>
|
|
41
|
+
vi.fn(async () => ({
|
|
42
|
+
data: {
|
|
43
|
+
specs: [{ feature_id: 'feature_resume', spec_path: '.aop/features/feature_resume/spec.md' }]
|
|
44
|
+
}
|
|
45
|
+
}))
|
|
46
|
+
);
|
|
47
|
+
const featureStateGetMock = vi.hoisted(
|
|
48
|
+
() =>
|
|
49
|
+
vi.fn(async (_featureId?: string) => ({
|
|
50
|
+
data: {
|
|
51
|
+
front_matter: {
|
|
52
|
+
status: 'planning'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}))
|
|
56
|
+
);
|
|
57
|
+
const resolveProviderSelectionMock = vi.hoisted(
|
|
58
|
+
() =>
|
|
59
|
+
vi.fn(() => ({
|
|
60
|
+
provider: 'custom',
|
|
61
|
+
model: 'model',
|
|
62
|
+
provider_config_env: null,
|
|
63
|
+
provider_config_ref: null
|
|
64
|
+
}))
|
|
65
|
+
);
|
|
66
|
+
const supervisorConstructorOptionsMock = vi.hoisted(() => vi.fn());
|
|
67
|
+
const supervisorStartMock = vi.hoisted(
|
|
68
|
+
() =>
|
|
69
|
+
vi.fn(async (..._args: unknown[]) => ({
|
|
70
|
+
queue_depth: 0,
|
|
71
|
+
status: 'running',
|
|
72
|
+
run_metadata: { started_at: 'now' } as Record<string, unknown>,
|
|
73
|
+
dashboard: { features: [] }
|
|
74
|
+
}))
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
vi.mock('../src/core/kernel.js', () => {
|
|
78
|
+
class AopKernel {
|
|
79
|
+
private readonly repoRoot: string;
|
|
80
|
+
private readonly agentsConfig: Record<string, unknown>;
|
|
81
|
+
|
|
82
|
+
constructor(repoRoot: string) {
|
|
83
|
+
this.repoRoot = repoRoot;
|
|
84
|
+
this.agentsConfig = {};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async ensureLoaded() {
|
|
88
|
+
await ensureLoadedMock();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async recoverFromState() {
|
|
92
|
+
return await recoverFromStateMock();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getRepoRoot() {
|
|
96
|
+
return this.repoRoot;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getAgentsConfig() {
|
|
100
|
+
return this.agentsConfig;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getRbacPolicy() {
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async readIndex() {
|
|
108
|
+
return await readIndexMock();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async getRuntimeSessions() {
|
|
112
|
+
return await getRuntimeSessionsMock();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async featureDiscoverSpecs() {
|
|
116
|
+
return await featureDiscoverSpecsMock();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async featureStateGet(featureId: string) {
|
|
120
|
+
return await featureStateGetMock(featureId);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return { AopKernel };
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
vi.mock('../src/mcp/runtime-factory.js', () => ({
|
|
128
|
+
createToolingRuntime: createToolingRuntimeMock,
|
|
129
|
+
resolveToolClient: resolveToolClientMock
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
vi.mock('../src/providers/providers.js', () => ({
|
|
133
|
+
resolveProviderSelection: resolveProviderSelectionMock,
|
|
134
|
+
NullWorkerProvider: class NullWorkerProvider {
|
|
135
|
+
selection: unknown;
|
|
136
|
+
|
|
137
|
+
constructor(selection: unknown) {
|
|
138
|
+
this.selection = selection;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}));
|
|
142
|
+
|
|
143
|
+
vi.mock('../src/supervisor/runtime.js', () => {
|
|
144
|
+
class SupervisorRuntime {
|
|
145
|
+
private readonly options: unknown;
|
|
146
|
+
|
|
147
|
+
constructor(
|
|
148
|
+
_kernel: unknown,
|
|
149
|
+
_provider: unknown,
|
|
150
|
+
_toolClient: unknown,
|
|
151
|
+
options: unknown
|
|
152
|
+
) {
|
|
153
|
+
this.options = options;
|
|
154
|
+
supervisorConstructorOptionsMock(options);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async start(features: Array<{ feature_id: string }>) {
|
|
158
|
+
return await supervisorStartMock(features, this.options);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return { SupervisorRuntime };
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
import { main } from '../src/cli/aop.js';
|
|
166
|
+
|
|
167
|
+
function asJsonWrites(writeSpy: ReturnType<typeof vi.spyOn>): any[] {
|
|
168
|
+
return writeSpy.mock.calls
|
|
169
|
+
.map((call) => call[0])
|
|
170
|
+
.filter((payload) => typeof payload === 'string')
|
|
171
|
+
.map((payload) => JSON.parse(String(payload).trim()));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
describe('aop CLI unit', () => {
|
|
175
|
+
let cwd: string;
|
|
176
|
+
let stdoutSpy: ReturnType<typeof vi.spyOn>;
|
|
177
|
+
|
|
178
|
+
beforeEach(async () => {
|
|
179
|
+
cwd = await fs.mkdtemp(path.join(os.tmpdir(), 'aop-cli-unit-'));
|
|
180
|
+
await fs.mkdir(path.join(cwd, '.aop', 'features'), { recursive: true });
|
|
181
|
+
resolveToolClientMock.mockReturnValue({ call: toolCallMock });
|
|
182
|
+
toolCallMock.mockReset();
|
|
183
|
+
ensureLoadedMock.mockClear();
|
|
184
|
+
recoverFromStateMock.mockClear();
|
|
185
|
+
readIndexMock.mockClear();
|
|
186
|
+
getRuntimeSessionsMock.mockClear();
|
|
187
|
+
featureDiscoverSpecsMock.mockClear();
|
|
188
|
+
featureStateGetMock.mockClear();
|
|
189
|
+
createToolingRuntimeMock.mockClear();
|
|
190
|
+
resolveProviderSelectionMock.mockClear();
|
|
191
|
+
supervisorConstructorOptionsMock.mockClear();
|
|
192
|
+
supervisorStartMock.mockClear();
|
|
193
|
+
stdoutSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
afterEach(async () => {
|
|
197
|
+
stdoutSpy.mockRestore();
|
|
198
|
+
await fs.rm(cwd, { recursive: true, force: true });
|
|
199
|
+
vi.restoreAllMocks();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('GIVEN_unknown_command_WHEN_main_runs_THEN_returns_invalid_cli_args', async () => {
|
|
203
|
+
const code = await main(['bogus'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
204
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
205
|
+
|
|
206
|
+
expect(code).toBe(1);
|
|
207
|
+
expect(writes[0]).toMatchObject({
|
|
208
|
+
ok: false,
|
|
209
|
+
error: {
|
|
210
|
+
code: ERROR_CODES.INVALID_CLI_ARGS
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('GIVEN_invalid_transport_WHEN_main_runs_THEN_returns_invalid_cli_args', async () => {
|
|
216
|
+
const code = await main(['run', '--transport', 'ssh'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
217
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
218
|
+
|
|
219
|
+
expect(code).toBe(1);
|
|
220
|
+
expect(writes[0]).toMatchObject({
|
|
221
|
+
ok: false,
|
|
222
|
+
error: {
|
|
223
|
+
code: ERROR_CODES.INVALID_CLI_ARGS
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('GIVEN_status_command_WHEN_main_runs_THEN_calls_dashboard_and_returns_zero', async () => {
|
|
229
|
+
toolCallMock.mockResolvedValue({ ok: true, data: { healthy: true } });
|
|
230
|
+
const code = await main(['status'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
231
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
232
|
+
|
|
233
|
+
expect(code).toBe(0);
|
|
234
|
+
expect(resolveToolClientMock).toHaveBeenCalledWith('mcp', expect.any(Object));
|
|
235
|
+
expect(toolCallMock).toHaveBeenCalledWith(
|
|
236
|
+
TOOLS.REPORT_DASHBOARD,
|
|
237
|
+
expect.any(Object),
|
|
238
|
+
expect.objectContaining({ actor_type: 'system' })
|
|
239
|
+
);
|
|
240
|
+
expect(writes[0]).toMatchObject({ ok: true, data: { healthy: true } });
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('GIVEN_resume_command_WHEN_main_runs_THEN_resumes_non_terminal_features_from_persisted_state', async () => {
|
|
244
|
+
recoverFromStateMock.mockResolvedValue({ data: { recovered: true, stale_features: ['f1'], active: {} } });
|
|
245
|
+
supervisorStartMock.mockResolvedValue({
|
|
246
|
+
queue_depth: 0,
|
|
247
|
+
status: 'running',
|
|
248
|
+
run_metadata: { resumed: true },
|
|
249
|
+
dashboard: { features: ['feature_resume'] }
|
|
250
|
+
});
|
|
251
|
+
const code = await main(['resume'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
252
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
253
|
+
|
|
254
|
+
expect(code).toBe(0);
|
|
255
|
+
expect(recoverFromStateMock).toHaveBeenCalledTimes(1);
|
|
256
|
+
expect(featureDiscoverSpecsMock).toHaveBeenCalledTimes(1);
|
|
257
|
+
expect(featureStateGetMock).toHaveBeenCalledWith('feature_resume');
|
|
258
|
+
expect(supervisorStartMock).toHaveBeenCalledWith([{ feature_id: 'feature_resume' }], expect.any(Object));
|
|
259
|
+
expect(writes[0]).toMatchObject({
|
|
260
|
+
ok: true,
|
|
261
|
+
data: {
|
|
262
|
+
command: 'resume',
|
|
263
|
+
resumed: true,
|
|
264
|
+
resumed_features: [
|
|
265
|
+
expect.objectContaining({
|
|
266
|
+
feature_id: 'feature_resume',
|
|
267
|
+
resume_phase: 'planning'
|
|
268
|
+
})
|
|
269
|
+
],
|
|
270
|
+
recovery: { stale_features: ['f1'] }
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('GIVEN_stop_command_WHEN_main_runs_THEN_returns_not_implemented_status', async () => {
|
|
276
|
+
const code = await main(['stop'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
277
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
278
|
+
|
|
279
|
+
expect(code).toBe(0);
|
|
280
|
+
expect(writes[0]).toMatchObject({
|
|
281
|
+
ok: true,
|
|
282
|
+
data: { status: 'stop_not_implemented_yet' }
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('GIVEN_delete_without_feature_id_WHEN_main_runs_THEN_returns_invalid_cli_args', async () => {
|
|
287
|
+
const code = await main(['delete'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
288
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
289
|
+
|
|
290
|
+
expect(code).toBe(1);
|
|
291
|
+
expect(writes[0]).toMatchObject({
|
|
292
|
+
ok: false,
|
|
293
|
+
error: {
|
|
294
|
+
code: ERROR_CODES.INVALID_CLI_ARGS
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
expect(toolCallMock).not.toHaveBeenCalled();
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('GIVEN_delete_without_yes_WHEN_main_runs_THEN_executes_preview_mode', async () => {
|
|
301
|
+
toolCallMock.mockResolvedValue({
|
|
302
|
+
ok: true,
|
|
303
|
+
data: {
|
|
304
|
+
feature_id: 'feature_delete',
|
|
305
|
+
dry_run: true,
|
|
306
|
+
plan: { feature_dir_exists: true },
|
|
307
|
+
summary: { feature_dir_removed: false }
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const code = await main(['delete', '--feature-id', 'feature_delete'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
312
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
313
|
+
|
|
314
|
+
expect(code).toBe(0);
|
|
315
|
+
expect(toolCallMock).toHaveBeenCalledWith(
|
|
316
|
+
TOOLS.FEATURE_DELETE,
|
|
317
|
+
expect.objectContaining({
|
|
318
|
+
feature_id: 'feature_delete',
|
|
319
|
+
dry_run: true,
|
|
320
|
+
confirm: false,
|
|
321
|
+
remove_worktree: true,
|
|
322
|
+
remove_branch: 'none'
|
|
323
|
+
}),
|
|
324
|
+
expect.objectContaining({ actor_type: 'system' })
|
|
325
|
+
);
|
|
326
|
+
expect(writes[0]).toMatchObject({
|
|
327
|
+
ok: true,
|
|
328
|
+
data: {
|
|
329
|
+
command: 'delete',
|
|
330
|
+
feature_id: 'feature_delete',
|
|
331
|
+
dry_run: true
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('GIVEN_delete_with_yes_and_remove_options_WHEN_main_runs_THEN_executes_destructive_mode', async () => {
|
|
337
|
+
toolCallMock.mockResolvedValue({
|
|
338
|
+
ok: true,
|
|
339
|
+
data: {
|
|
340
|
+
feature_id: 'feature_delete',
|
|
341
|
+
dry_run: false,
|
|
342
|
+
plan: { feature_dir_exists: true },
|
|
343
|
+
applied: { feature_dir_removed: true },
|
|
344
|
+
summary: { feature_dir_removed: true }
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
const code = await main(
|
|
349
|
+
[
|
|
350
|
+
'delete',
|
|
351
|
+
'--feature-id',
|
|
352
|
+
'feature_delete',
|
|
353
|
+
'--yes',
|
|
354
|
+
'--remove-worktree',
|
|
355
|
+
'false',
|
|
356
|
+
'--remove-branch',
|
|
357
|
+
'force'
|
|
358
|
+
],
|
|
359
|
+
{ cwd, env: {} as NodeJS.ProcessEnv }
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
expect(code).toBe(0);
|
|
363
|
+
expect(toolCallMock).toHaveBeenCalledWith(
|
|
364
|
+
TOOLS.FEATURE_DELETE,
|
|
365
|
+
expect.objectContaining({
|
|
366
|
+
feature_id: 'feature_delete',
|
|
367
|
+
dry_run: false,
|
|
368
|
+
confirm: true,
|
|
369
|
+
remove_worktree: false,
|
|
370
|
+
remove_branch: 'force'
|
|
371
|
+
}),
|
|
372
|
+
expect.objectContaining({ actor_type: 'system' })
|
|
373
|
+
);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it('GIVEN_delete_with_invalid_remove_branch_WHEN_main_runs_THEN_returns_invalid_cli_args', async () => {
|
|
377
|
+
const code = await main(
|
|
378
|
+
['delete', '--feature-id', 'feature_delete', '--remove-branch', 'hard'],
|
|
379
|
+
{ cwd, env: {} as NodeJS.ProcessEnv }
|
|
380
|
+
);
|
|
381
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
382
|
+
|
|
383
|
+
expect(code).toBe(1);
|
|
384
|
+
expect(writes[0]).toMatchObject({
|
|
385
|
+
ok: false,
|
|
386
|
+
error: {
|
|
387
|
+
code: ERROR_CODES.INVALID_CLI_ARGS
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
expect(toolCallMock).not.toHaveBeenCalled();
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it('GIVEN_missing_file_input_WHEN_run_command_THEN_returns_input_path_not_found', async () => {
|
|
394
|
+
const code = await main(['run', '-fi', 'missing.md'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
395
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
396
|
+
|
|
397
|
+
expect(code).toBe(1);
|
|
398
|
+
expect(writes[0]).toMatchObject({
|
|
399
|
+
ok: false,
|
|
400
|
+
error: {
|
|
401
|
+
code: ERROR_CODES.INPUT_PATH_NOT_FOUND
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it('GIVEN_empty_folder_input_WHEN_run_command_THEN_returns_no_specs_found', async () => {
|
|
407
|
+
await fs.mkdir(path.join(cwd, 'incoming'), { recursive: true });
|
|
408
|
+
const code = await main(['run', '-fl', 'incoming'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
409
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
410
|
+
|
|
411
|
+
expect(code).toBe(1);
|
|
412
|
+
expect(writes[0]).toMatchObject({
|
|
413
|
+
ok: false,
|
|
414
|
+
error: {
|
|
415
|
+
code: ERROR_CODES.NO_SPECS_FOUND
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('GIVEN_duplicate_slug_files_WHEN_run_command_THEN_returns_feature_slug_collision', async () => {
|
|
421
|
+
const folder = path.join(cwd, 'incoming');
|
|
422
|
+
await fs.mkdir(folder, { recursive: true });
|
|
423
|
+
await fs.writeFile(path.join(folder, 'alpha.spec.md'), '# A\n', 'utf8');
|
|
424
|
+
await fs.writeFile(path.join(folder, 'alpha-spec.md'), '# B\n', 'utf8');
|
|
425
|
+
|
|
426
|
+
toolCallMock.mockResolvedValue({ ok: true, data: { front_matter: { version: 1 } } });
|
|
427
|
+
const code = await main(['run', '-fl', 'incoming'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
428
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
429
|
+
|
|
430
|
+
expect(code).toBe(1);
|
|
431
|
+
expect(writes[0]).toMatchObject({
|
|
432
|
+
ok: false,
|
|
433
|
+
error: {
|
|
434
|
+
code: ERROR_CODES.FEATURE_SLUG_COLLISION
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it('GIVEN_successful_file_ingest_WHEN_run_command_THEN_starts_supervisor', async () => {
|
|
440
|
+
const incoming = path.join(cwd, 'incoming');
|
|
441
|
+
await fs.mkdir(incoming, { recursive: true });
|
|
442
|
+
await fs.writeFile(path.join(incoming, 'feature_one.md'), '# Spec\n\nBuild.\n', 'utf8');
|
|
443
|
+
|
|
444
|
+
toolCallMock.mockImplementation(async (toolName: string) => {
|
|
445
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
446
|
+
return { ok: true, data: { front_matter: { version: 1 } } };
|
|
447
|
+
}
|
|
448
|
+
return { ok: true, data: {} };
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
const code = await main(
|
|
452
|
+
['run', '-fi', path.join('incoming', 'feature_one.md'), '--agent-provider', 'custom'],
|
|
453
|
+
{ cwd, env: {} as NodeJS.ProcessEnv }
|
|
454
|
+
);
|
|
455
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
456
|
+
|
|
457
|
+
expect(code).toBe(0);
|
|
458
|
+
expect(supervisorStartMock).toHaveBeenCalledWith(
|
|
459
|
+
[expect.objectContaining({ feature_id: 'feature_one' })],
|
|
460
|
+
expect.any(Object)
|
|
461
|
+
);
|
|
462
|
+
expect(resolveProviderSelectionMock).toHaveBeenCalledTimes(1);
|
|
463
|
+
expect(writes.at(-1)).toMatchObject({
|
|
464
|
+
ok: true,
|
|
465
|
+
data: {
|
|
466
|
+
command: 'run',
|
|
467
|
+
runtime_status: 'running'
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
await expect(
|
|
471
|
+
fs.stat(path.join(cwd, '.aop', 'features', 'feature_one', 'spec.md'))
|
|
472
|
+
).resolves.toBeTruthy();
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
it('GIVEN_takeover_flag_WHEN_run_command_THEN_forwards_takeover_option_to_supervisor', async () => {
|
|
476
|
+
const incoming = path.join(cwd, 'incoming');
|
|
477
|
+
await fs.mkdir(incoming, { recursive: true });
|
|
478
|
+
await fs.writeFile(path.join(incoming, 'feature_takeover.md'), '# Spec\n\nRecover stale run.\n', 'utf8');
|
|
479
|
+
|
|
480
|
+
toolCallMock.mockImplementation(async (toolName: string) => {
|
|
481
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
482
|
+
return { ok: true, data: { front_matter: { version: 1 } } };
|
|
483
|
+
}
|
|
484
|
+
return { ok: true, data: {} };
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
const code = await main(
|
|
488
|
+
['run', '-fi', path.join('incoming', 'feature_takeover.md'), '--agent-provider', 'custom', '--takeover-stale-run'],
|
|
489
|
+
{ cwd, env: {} as NodeJS.ProcessEnv }
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
expect(code).toBe(0);
|
|
493
|
+
expect(supervisorConstructorOptionsMock).toHaveBeenCalledWith(
|
|
494
|
+
expect.objectContaining({
|
|
495
|
+
takeover_stale_run: true
|
|
496
|
+
})
|
|
497
|
+
);
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it('GIVEN_stale_takeover_contract_WHEN_run_without_and_with_flag_THEN_returns_run_already_active_then_succeeds', async () => {
|
|
501
|
+
const incoming = path.join(cwd, 'incoming');
|
|
502
|
+
await fs.mkdir(incoming, { recursive: true });
|
|
503
|
+
await fs.writeFile(path.join(incoming, 'feature_stale.md'), '# Spec\n\nHandle takeover.\n', 'utf8');
|
|
504
|
+
|
|
505
|
+
toolCallMock.mockImplementation(async (toolName: string) => {
|
|
506
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
507
|
+
return { ok: true, data: { front_matter: { version: 1 } } };
|
|
508
|
+
}
|
|
509
|
+
return { ok: true, data: {} };
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
supervisorStartMock.mockImplementation(async (_features: Array<{ feature_id: string }>, options?: any) => {
|
|
513
|
+
if (!options?.takeover_stale_run) {
|
|
514
|
+
const error = new Error('run_already_active');
|
|
515
|
+
(error as any).code = ERROR_CODES.RUN_ALREADY_ACTIVE;
|
|
516
|
+
throw error;
|
|
517
|
+
}
|
|
518
|
+
return {
|
|
519
|
+
queue_depth: 0,
|
|
520
|
+
status: 'running',
|
|
521
|
+
run_metadata: { started_at: 'now', took_over_stale: true },
|
|
522
|
+
dashboard: { features: [] }
|
|
523
|
+
};
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
const noTakeoverCode = await main(
|
|
527
|
+
['run', '-fi', path.join('incoming', 'feature_stale.md'), '--agent-provider', 'custom'],
|
|
528
|
+
{ cwd, env: {} as NodeJS.ProcessEnv }
|
|
529
|
+
);
|
|
530
|
+
const noTakeoverWrites = asJsonWrites(stdoutSpy);
|
|
531
|
+
expect(noTakeoverCode).toBe(1);
|
|
532
|
+
expect(noTakeoverWrites.at(-1)).toMatchObject({
|
|
533
|
+
ok: false,
|
|
534
|
+
error: {
|
|
535
|
+
code: ERROR_CODES.RUN_ALREADY_ACTIVE
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
stdoutSpy.mockClear();
|
|
540
|
+
|
|
541
|
+
const withTakeoverCode = await main(
|
|
542
|
+
['run', '-fi', path.join('incoming', 'feature_stale.md'), '--agent-provider', 'custom', '--takeover-stale-run'],
|
|
543
|
+
{ cwd, env: {} as NodeJS.ProcessEnv }
|
|
544
|
+
);
|
|
545
|
+
const withTakeoverWrites = asJsonWrites(stdoutSpy);
|
|
546
|
+
expect(withTakeoverCode).toBe(0);
|
|
547
|
+
expect(withTakeoverWrites.at(-1)).toMatchObject({
|
|
548
|
+
ok: true,
|
|
549
|
+
data: {
|
|
550
|
+
command: 'run',
|
|
551
|
+
runtime_status: 'running'
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
it('GIVEN_discovery_returns_no_specs_WHEN_run_command_without_inputs_THEN_returns_no_specs_found', async () => {
|
|
557
|
+
toolCallMock.mockImplementation(async (toolName: string) => {
|
|
558
|
+
if (toolName === TOOLS.FEATURE_DISCOVER_SPECS) {
|
|
559
|
+
return { ok: true, data: { specs: [] } };
|
|
560
|
+
}
|
|
561
|
+
return { ok: true, data: {} };
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
const code = await main(['run'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
565
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
566
|
+
|
|
567
|
+
expect(code).toBe(1);
|
|
568
|
+
expect(writes[0]).toMatchObject({
|
|
569
|
+
ok: false,
|
|
570
|
+
error: {
|
|
571
|
+
code: ERROR_CODES.NO_SPECS_FOUND
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it('GIVEN_inprocess_transport_flag_WHEN_status_runs_THEN_uses_inprocess_transport_override', async () => {
|
|
577
|
+
toolCallMock.mockResolvedValue({ ok: true, data: { healthy: true } });
|
|
578
|
+
|
|
579
|
+
const code = await main(['status', '--transport', 'inprocess'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
580
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
581
|
+
|
|
582
|
+
expect(code).toBe(0);
|
|
583
|
+
expect(resolveToolClientMock).toHaveBeenCalledWith('inprocess', expect.any(Object));
|
|
584
|
+
expect(writes[0]).toMatchObject({ ok: true, data: { healthy: true } });
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it('GIVEN_tool_error_WHEN_discovering_specs_THEN_returns_error_code_from_tool', async () => {
|
|
588
|
+
toolCallMock.mockResolvedValue({
|
|
589
|
+
ok: false,
|
|
590
|
+
error: {
|
|
591
|
+
code: ERROR_CODES.INTERNAL_ERROR,
|
|
592
|
+
message: 'tool failure',
|
|
593
|
+
details: { reason: 'simulated' }
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
const code = await main(['run'], { cwd, env: {} as NodeJS.ProcessEnv });
|
|
598
|
+
const writes = asJsonWrites(stdoutSpy);
|
|
599
|
+
|
|
600
|
+
expect(code).toBe(1);
|
|
601
|
+
expect(writes[0]).toMatchObject({
|
|
602
|
+
ok: false,
|
|
603
|
+
error: {
|
|
604
|
+
code: ERROR_CODES.INTERNAL_ERROR,
|
|
605
|
+
message: 'tool failure'
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
});
|