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,228 @@
|
|
|
1
|
+
import { STATUS } from '../core/constants.js';
|
|
2
|
+
import { resolveProviderSelection, NullWorkerProvider } from '../providers/providers.js';
|
|
3
|
+
import { SupervisorRuntime } from '../supervisor/runtime.js';
|
|
4
|
+
import type { AopKernel } from '../core/kernel.js';
|
|
5
|
+
import type { ToolClient } from '../mcp/tool-client.js';
|
|
6
|
+
import type { CliOptions, ToolTransport } from './types.js';
|
|
7
|
+
|
|
8
|
+
type AnyRecord = Record<string, unknown>;
|
|
9
|
+
|
|
10
|
+
interface ResumeFeature {
|
|
11
|
+
feature_id: string;
|
|
12
|
+
status: string;
|
|
13
|
+
resume_phase: string;
|
|
14
|
+
sources: string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ResumeCommandContext {
|
|
18
|
+
repoRoot: string;
|
|
19
|
+
env: NodeJS.ProcessEnv;
|
|
20
|
+
runId: string;
|
|
21
|
+
transport: ToolTransport;
|
|
22
|
+
options: CliOptions;
|
|
23
|
+
kernel: AopKernel;
|
|
24
|
+
toolClient: ToolClient;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function asRecord(value: unknown): AnyRecord {
|
|
28
|
+
return value && typeof value === 'object' ? (value as AnyRecord) : {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function asStringArray(value: unknown): string[] {
|
|
32
|
+
if (!Array.isArray(value)) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const normalized: string[] = [];
|
|
36
|
+
for (const item of value) {
|
|
37
|
+
if (typeof item !== 'string') {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const trimmed = item.trim();
|
|
41
|
+
if (trimmed.length > 0) {
|
|
42
|
+
normalized.push(trimmed);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return normalized;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function toResumePhase(status: string): string {
|
|
49
|
+
if (status === STATUS.BUILDING) {
|
|
50
|
+
return STATUS.BUILDING;
|
|
51
|
+
}
|
|
52
|
+
if (status === STATUS.QA) {
|
|
53
|
+
return STATUS.QA;
|
|
54
|
+
}
|
|
55
|
+
if (status === STATUS.READY_TO_MERGE) {
|
|
56
|
+
return STATUS.READY_TO_MERGE;
|
|
57
|
+
}
|
|
58
|
+
return STATUS.PLANNING;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function phaseRank(phase: string): number {
|
|
62
|
+
switch (phase) {
|
|
63
|
+
case STATUS.PLANNING:
|
|
64
|
+
return 0;
|
|
65
|
+
case STATUS.BUILDING:
|
|
66
|
+
return 1;
|
|
67
|
+
case STATUS.QA:
|
|
68
|
+
return 2;
|
|
69
|
+
case STATUS.READY_TO_MERGE:
|
|
70
|
+
return 3;
|
|
71
|
+
default:
|
|
72
|
+
return 99;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isTerminalStatus(status: string): boolean {
|
|
77
|
+
return status === STATUS.MERGED || status === STATUS.FAILED;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface ResumePlan {
|
|
81
|
+
run_id: string;
|
|
82
|
+
owner_instance_id: string;
|
|
83
|
+
features: ResumeFeature[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class ResumeCommandHandler {
|
|
87
|
+
async execute(context: ResumeCommandContext): Promise<unknown> {
|
|
88
|
+
const { env, runId, transport, options, kernel, toolClient } = context;
|
|
89
|
+
const recovery = await kernel.recoverFromState();
|
|
90
|
+
const resumePlan = await this.buildResumePlan(kernel, runId);
|
|
91
|
+
|
|
92
|
+
if (resumePlan.features.length === 0) {
|
|
93
|
+
return {
|
|
94
|
+
ok: true,
|
|
95
|
+
data: {
|
|
96
|
+
command: 'resume',
|
|
97
|
+
transport,
|
|
98
|
+
resumed: false,
|
|
99
|
+
recovery: recovery.data,
|
|
100
|
+
resume_plan: resumePlan
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const selection = resolveProviderSelection({
|
|
106
|
+
cli: options as unknown as Record<string, string | undefined>,
|
|
107
|
+
env,
|
|
108
|
+
agentsConfig: kernel.getAgentsConfig()
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const provider = new NullWorkerProvider(selection);
|
|
112
|
+
const supervisor = new SupervisorRuntime(kernel, provider, toolClient, {
|
|
113
|
+
max_active_features: 5,
|
|
114
|
+
max_parallel_gate_runs: 3,
|
|
115
|
+
run_id: resumePlan.run_id,
|
|
116
|
+
owner_instance_id: resumePlan.owner_instance_id,
|
|
117
|
+
takeover_stale_run: options.takeover_stale_run
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const startResult = await supervisor.start(
|
|
121
|
+
resumePlan.features.map((feature) => ({
|
|
122
|
+
feature_id: feature.feature_id
|
|
123
|
+
}))
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
ok: true,
|
|
128
|
+
data: {
|
|
129
|
+
command: 'resume',
|
|
130
|
+
transport,
|
|
131
|
+
resumed: true,
|
|
132
|
+
resumed_features: resumePlan.features,
|
|
133
|
+
queue_depth: startResult.queue_depth,
|
|
134
|
+
runtime_status: startResult.status,
|
|
135
|
+
run_metadata: startResult.run_metadata,
|
|
136
|
+
dashboard: startResult.dashboard,
|
|
137
|
+
recovery: recovery.data
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private async buildResumePlan(kernel: AopKernel, fallbackRunId: string): Promise<ResumePlan> {
|
|
143
|
+
const index = await kernel.readIndex();
|
|
144
|
+
const runtimeSessions = await kernel.getRuntimeSessions();
|
|
145
|
+
const discovered = await kernel.featureDiscoverSpecs();
|
|
146
|
+
|
|
147
|
+
const sourcesByFeature = new Map<string, Set<string>>();
|
|
148
|
+
for (const featureId of asStringArray(index.active)) {
|
|
149
|
+
this.addSource(sourcesByFeature, featureId, 'index.active');
|
|
150
|
+
}
|
|
151
|
+
for (const featureId of asStringArray(index.blocked)) {
|
|
152
|
+
this.addSource(sourcesByFeature, featureId, 'index.blocked');
|
|
153
|
+
}
|
|
154
|
+
for (const [featureId] of Object.entries(asRecord(runtimeSessions.feature_sessions))) {
|
|
155
|
+
this.addSource(sourcesByFeature, featureId, 'runtime_sessions.feature_sessions');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const blockedQueue = Array.isArray(index.blocked_queue) ? index.blocked_queue : [];
|
|
159
|
+
for (const entry of blockedQueue) {
|
|
160
|
+
const featureId = asRecord(entry).feature_id;
|
|
161
|
+
if (typeof featureId === 'string' && featureId.length > 0) {
|
|
162
|
+
this.addSource(sourcesByFeature, featureId, 'index.blocked_queue');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const specs = Array.isArray(discovered.data?.specs) ? discovered.data.specs : [];
|
|
167
|
+
for (const item of specs) {
|
|
168
|
+
const featureId = asRecord(item).feature_id;
|
|
169
|
+
if (typeof featureId === 'string' && featureId.length > 0) {
|
|
170
|
+
this.addSource(sourcesByFeature, featureId, 'feature.discover_specs');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const resumable: ResumeFeature[] = [];
|
|
175
|
+
const sortedFeatureIds = [...sourcesByFeature.keys()].sort((a, b) => a.localeCompare(b));
|
|
176
|
+
for (const featureId of sortedFeatureIds) {
|
|
177
|
+
try {
|
|
178
|
+
const state = await kernel.featureStateGet(featureId);
|
|
179
|
+
const frontMatter = asRecord(state.data.front_matter);
|
|
180
|
+
const status = typeof frontMatter.status === 'string' ? frontMatter.status : STATUS.PLANNING;
|
|
181
|
+
if (isTerminalStatus(status)) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
resumable.push({
|
|
186
|
+
feature_id: featureId,
|
|
187
|
+
status,
|
|
188
|
+
resume_phase: toResumePhase(status),
|
|
189
|
+
sources: [...(sourcesByFeature.get(featureId) ?? new Set<string>())].sort((a, b) => a.localeCompare(b))
|
|
190
|
+
});
|
|
191
|
+
} catch (_error) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
resumable.sort((a, b) => {
|
|
197
|
+
const phaseDelta = phaseRank(a.resume_phase) - phaseRank(b.resume_phase);
|
|
198
|
+
if (phaseDelta !== 0) {
|
|
199
|
+
return phaseDelta;
|
|
200
|
+
}
|
|
201
|
+
return a.feature_id.localeCompare(b.feature_id);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const resolvedRunId = runtimeSessions.run_id !== 'none' ? runtimeSessions.run_id : fallbackRunId;
|
|
205
|
+
const resolvedOwnerInstanceId =
|
|
206
|
+
runtimeSessions.owner_instance_id !== 'none'
|
|
207
|
+
? runtimeSessions.owner_instance_id
|
|
208
|
+
: `supervisor:${process.pid}:resume`;
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
run_id: resolvedRunId,
|
|
212
|
+
owner_instance_id: resolvedOwnerInstanceId,
|
|
213
|
+
features: resumable
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
private addSource(sourcesByFeature: Map<string, Set<string>>, featureId: string, source: string): void {
|
|
218
|
+
if (!featureId) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const existing = sourcesByFeature.get(featureId);
|
|
222
|
+
if (existing) {
|
|
223
|
+
existing.add(source);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
sourcesByFeature.set(featureId, new Set([source]));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { resolveProviderSelection, NullWorkerProvider } from '../providers/providers.js';
|
|
2
|
+
import { SupervisorRuntime } from '../supervisor/runtime.js';
|
|
3
|
+
import type { AopKernel } from '../core/kernel.js';
|
|
4
|
+
import type { ToolClient } from '../mcp/tool-client.js';
|
|
5
|
+
import type { CliOptions, ToolTransport } from './types.js';
|
|
6
|
+
import { SpecInputResolver } from './spec-input-resolver.js';
|
|
7
|
+
import { SpecIngestionService } from './spec-ingestion-service.js';
|
|
8
|
+
|
|
9
|
+
export interface RunCommandContext {
|
|
10
|
+
repoRoot: string;
|
|
11
|
+
env: NodeJS.ProcessEnv;
|
|
12
|
+
runId: string;
|
|
13
|
+
transport: ToolTransport;
|
|
14
|
+
options: CliOptions;
|
|
15
|
+
kernel: AopKernel;
|
|
16
|
+
toolClient: ToolClient;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class RunCommandHandler {
|
|
20
|
+
async execute(context: RunCommandContext): Promise<unknown> {
|
|
21
|
+
const { repoRoot, env, runId, transport, options, kernel, toolClient } = context;
|
|
22
|
+
const specResolver = new SpecInputResolver(repoRoot, toolClient, runId);
|
|
23
|
+
const ingestionService = new SpecIngestionService(repoRoot, toolClient, runId);
|
|
24
|
+
|
|
25
|
+
const resolvedPaths = await specResolver.resolve(options);
|
|
26
|
+
const ingested = await ingestionService.ingest(resolvedPaths);
|
|
27
|
+
|
|
28
|
+
const selection = resolveProviderSelection({
|
|
29
|
+
cli: options as unknown as Record<string, string | undefined>,
|
|
30
|
+
env,
|
|
31
|
+
agentsConfig: kernel.getAgentsConfig()
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const provider = new NullWorkerProvider(selection);
|
|
35
|
+
const supervisor = new SupervisorRuntime(kernel, provider, toolClient, {
|
|
36
|
+
max_active_features: 5,
|
|
37
|
+
max_parallel_gate_runs: 3,
|
|
38
|
+
run_id: runId,
|
|
39
|
+
takeover_stale_run: options.takeover_stale_run
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const startResult = await supervisor.start(ingested as Array<{ feature_id: string }>);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
ok: true,
|
|
46
|
+
data: {
|
|
47
|
+
command: 'run',
|
|
48
|
+
transport,
|
|
49
|
+
active_features: ingested,
|
|
50
|
+
queue_depth: startResult.queue_depth,
|
|
51
|
+
runtime_status: startResult.status,
|
|
52
|
+
run_metadata: startResult.run_metadata,
|
|
53
|
+
dashboard: startResult.dashboard
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { stableHash, ensureDir } from '../core/fs.js';
|
|
4
|
+
import { ERROR_CODES } from '../core/error-codes.js';
|
|
5
|
+
import { TOOLS } from '../core/constants.js';
|
|
6
|
+
import type { AppError } from '../providers/providers.js';
|
|
7
|
+
import type { ToolClient } from '../mcp/tool-client.js';
|
|
8
|
+
import type { FeatureStatePayload } from './types.js';
|
|
9
|
+
import { callCliTool } from './tooling.js';
|
|
10
|
+
import { canonicalFeatureIdFromPath, isCanonicalSpecPath, isLegacyCanonicalSpecPath } from './spec-utils.js';
|
|
11
|
+
|
|
12
|
+
export class SpecIngestionService {
|
|
13
|
+
private readonly repoRoot: string;
|
|
14
|
+
private readonly toolClient: ToolClient;
|
|
15
|
+
private readonly runId: string;
|
|
16
|
+
|
|
17
|
+
constructor(repoRoot: string, toolClient: ToolClient, runId: string) {
|
|
18
|
+
this.repoRoot = repoRoot;
|
|
19
|
+
this.toolClient = toolClient;
|
|
20
|
+
this.runId = runId;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async ingest(resolvedPaths: string[]): Promise<Array<Record<string, string>>> {
|
|
24
|
+
const featureIds = new Set<string>();
|
|
25
|
+
const items: Array<Record<string, string>> = [];
|
|
26
|
+
|
|
27
|
+
for (const sourcePath of resolvedPaths) {
|
|
28
|
+
const canonical = isCanonicalSpecPath(this.repoRoot, sourcePath);
|
|
29
|
+
const legacyCanonical = canonical ? null : isLegacyCanonicalSpecPath(this.repoRoot, sourcePath);
|
|
30
|
+
let featureId: string;
|
|
31
|
+
let targetPath: string;
|
|
32
|
+
if (canonical) {
|
|
33
|
+
featureId = canonical;
|
|
34
|
+
targetPath = sourcePath;
|
|
35
|
+
} else if (legacyCanonical) {
|
|
36
|
+
featureId = legacyCanonical;
|
|
37
|
+
targetPath = path.join(this.repoRoot, '.aop', 'features', featureId, 'spec.md');
|
|
38
|
+
} else {
|
|
39
|
+
featureId = canonicalFeatureIdFromPath(sourcePath);
|
|
40
|
+
targetPath = path.join(this.repoRoot, '.aop', 'features', featureId, 'spec.md');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (featureIds.has(featureId)) {
|
|
44
|
+
const error = new Error(ERROR_CODES.FEATURE_SLUG_COLLISION) as AppError;
|
|
45
|
+
error.code = ERROR_CODES.FEATURE_SLUG_COLLISION;
|
|
46
|
+
error.details = { feature_id: featureId };
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
featureIds.add(featureId);
|
|
50
|
+
|
|
51
|
+
if (!canonical) {
|
|
52
|
+
await ensureDir(path.dirname(targetPath));
|
|
53
|
+
const sourceContent = await fs.readFile(sourcePath, 'utf8');
|
|
54
|
+
await fs.writeFile(targetPath, sourceContent, 'utf8');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await callCliTool(this.toolClient, this.runId, TOOLS.FEATURE_INIT, { feature_id: featureId });
|
|
58
|
+
|
|
59
|
+
const sourceContent = await fs.readFile(sourcePath, 'utf8');
|
|
60
|
+
const sourceHash = stableHash(sourceContent);
|
|
61
|
+
const state = await callCliTool(this.toolClient, this.runId, TOOLS.FEATURE_STATE_GET, {
|
|
62
|
+
feature_id: featureId
|
|
63
|
+
});
|
|
64
|
+
const typedState = state.data as unknown as FeatureStatePayload;
|
|
65
|
+
|
|
66
|
+
await callCliTool(this.toolClient, this.runId, TOOLS.FEATURE_STATE_PATCH, {
|
|
67
|
+
feature_id: featureId,
|
|
68
|
+
expected_version: typedState.front_matter.version,
|
|
69
|
+
patch: {
|
|
70
|
+
front_matter: {
|
|
71
|
+
source: {
|
|
72
|
+
path: path.relative(this.repoRoot, sourcePath).replaceAll('\\\\', '/'),
|
|
73
|
+
hash: sourceHash
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
items.push({
|
|
80
|
+
feature_id: featureId,
|
|
81
|
+
source_path: path.relative(this.repoRoot, sourcePath).replaceAll('\\\\', '/'),
|
|
82
|
+
canonical_spec_path: path.relative(this.repoRoot, targetPath).replaceAll('\\\\', '/')
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return items;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { ERROR_CODES } from '../core/error-codes.js';
|
|
4
|
+
import { TOOLS } from '../core/constants.js';
|
|
5
|
+
import type { AppError } from '../providers/providers.js';
|
|
6
|
+
import type { ToolClient } from '../mcp/tool-client.js';
|
|
7
|
+
import type { CliOptions, DiscoveredSpecsPayload } from './types.js';
|
|
8
|
+
import { callCliTool } from './tooling.js';
|
|
9
|
+
|
|
10
|
+
async function readMarkdownFilesRecursive(folder: string): Promise<string[]> {
|
|
11
|
+
const results: string[] = [];
|
|
12
|
+
|
|
13
|
+
async function walk(current: string): Promise<void> {
|
|
14
|
+
const entries = await fs.readdir(current, { withFileTypes: true });
|
|
15
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
16
|
+
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
const absolute = path.join(current, entry.name);
|
|
19
|
+
if (entry.isDirectory()) {
|
|
20
|
+
await walk(absolute);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) {
|
|
24
|
+
results.push(absolute);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await walk(folder);
|
|
30
|
+
results.sort((a, b) => a.localeCompare(b));
|
|
31
|
+
return results;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class SpecInputResolver {
|
|
35
|
+
private readonly repoRoot: string;
|
|
36
|
+
private readonly toolClient: ToolClient;
|
|
37
|
+
private readonly runId: string;
|
|
38
|
+
|
|
39
|
+
constructor(repoRoot: string, toolClient: ToolClient, runId: string) {
|
|
40
|
+
this.repoRoot = repoRoot;
|
|
41
|
+
this.toolClient = toolClient;
|
|
42
|
+
this.runId = runId;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async resolve(options: CliOptions): Promise<string[]> {
|
|
46
|
+
if (options.file_input && options.folder_input) {
|
|
47
|
+
const error = new Error(ERROR_CODES.INVALID_CLI_ARGS) as AppError;
|
|
48
|
+
error.code = ERROR_CODES.INVALID_CLI_ARGS;
|
|
49
|
+
error.details = { reason: '-fi and -fl are mutually exclusive' };
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (options.file_input) {
|
|
54
|
+
const absolute = path.resolve(this.repoRoot, options.file_input);
|
|
55
|
+
const stat = await fs.stat(absolute).catch(() => null);
|
|
56
|
+
if (!stat || !stat.isFile()) {
|
|
57
|
+
const error = new Error(ERROR_CODES.INPUT_PATH_NOT_FOUND) as AppError;
|
|
58
|
+
error.code = ERROR_CODES.INPUT_PATH_NOT_FOUND;
|
|
59
|
+
error.details = { path: options.file_input };
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
return [absolute];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (options.folder_input) {
|
|
66
|
+
const absolute = path.resolve(this.repoRoot, options.folder_input);
|
|
67
|
+
const stat = await fs.stat(absolute).catch(() => null);
|
|
68
|
+
if (!stat || !stat.isDirectory()) {
|
|
69
|
+
const error = new Error(ERROR_CODES.INPUT_PATH_NOT_FOUND) as AppError;
|
|
70
|
+
error.code = ERROR_CODES.INPUT_PATH_NOT_FOUND;
|
|
71
|
+
error.details = { path: options.folder_input };
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const markdownFiles = await readMarkdownFilesRecursive(absolute);
|
|
76
|
+
if (markdownFiles.length === 0) {
|
|
77
|
+
const error = new Error(ERROR_CODES.NO_SPECS_FOUND) as AppError;
|
|
78
|
+
error.code = ERROR_CODES.NO_SPECS_FOUND;
|
|
79
|
+
error.details = { folder: options.folder_input };
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
return markdownFiles;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const discovered = await callCliTool(this.toolClient, this.runId, TOOLS.FEATURE_DISCOVER_SPECS, {});
|
|
86
|
+
const specs = (discovered.data as unknown as DiscoveredSpecsPayload).specs ?? [];
|
|
87
|
+
if (specs.length === 0) {
|
|
88
|
+
const error = new Error(ERROR_CODES.NO_SPECS_FOUND) as AppError;
|
|
89
|
+
error.code = ERROR_CODES.NO_SPECS_FOUND;
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return specs.map((item: { spec_path: string }) => path.join(this.repoRoot, item.spec_path));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import {ERROR_CODES} from '../core/error-codes.js';
|
|
3
|
+
import type {AppError} from '../providers/providers.js';
|
|
4
|
+
|
|
5
|
+
export function canonicalFeatureIdFromPath(inputPath: string): string {
|
|
6
|
+
const basename = path.basename(inputPath);
|
|
7
|
+
let candidate = basename.replace(/\.[^.]+$/, '');
|
|
8
|
+
if (candidate.endsWith('.spec')) {
|
|
9
|
+
candidate = candidate.slice(0, -'.spec'.length);
|
|
10
|
+
} else if (candidate.endsWith('-spec')) {
|
|
11
|
+
candidate = candidate.slice(0, -'-spec'.length);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!candidate || !/^[a-z0-9_][a-z0-9_-]*$/.test(candidate)) {
|
|
15
|
+
const error = new Error(ERROR_CODES.INVALID_FEATURE_SLUG) as AppError;
|
|
16
|
+
error.code = ERROR_CODES.INVALID_FEATURE_SLUG;
|
|
17
|
+
error.details = { input_path: inputPath, derived_feature_id: candidate };
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return candidate;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function isCanonicalSpecPath(repoRoot: string, candidate: string): string | null {
|
|
25
|
+
const relative = path.relative(repoRoot, candidate).replaceAll('\\\\', '/');
|
|
26
|
+
const match = relative.match(/^\.aop\/features\/([a-z0-9_][a-z0-9_-]*)\/spec\.md$/);
|
|
27
|
+
if (!match) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return match[1];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isLegacyCanonicalSpecPath(repoRoot: string, candidate: string): string | null {
|
|
34
|
+
const relative = path.relative(repoRoot, candidate).replaceAll('\\\\', '/');
|
|
35
|
+
const match = relative.match(/^agentic\/features\/([a-z0-9_][a-z0-9_-]*)\/spec\.md$/);
|
|
36
|
+
if (!match) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return match[1];
|
|
40
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {TOOLS} from '../core/constants.js';
|
|
2
|
+
import type {ToolClient} from '../mcp/tool-client.js';
|
|
3
|
+
import {callCliTool} from './tooling.js';
|
|
4
|
+
|
|
5
|
+
export class StatusCommandHandler {
|
|
6
|
+
private readonly toolClient: ToolClient;
|
|
7
|
+
private readonly runId: string;
|
|
8
|
+
|
|
9
|
+
constructor(toolClient: ToolClient, runId: string) {
|
|
10
|
+
this.toolClient = toolClient;
|
|
11
|
+
this.runId = runId;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async execute(): Promise<unknown> {
|
|
15
|
+
return await callCliTool(this.toolClient, this.runId, TOOLS.REPORT_DASHBOARD, {});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ERROR_CODES } from '../core/error-codes.js';
|
|
2
|
+
import type { FailResponse, OkResponse, ToolResponse } from '../core/response.js';
|
|
3
|
+
import type { AppError } from '../providers/providers.js';
|
|
4
|
+
import { createOperationId, type ToolClient } from '../mcp/tool-client.js';
|
|
5
|
+
import { withOperationIdIfRequired } from '../application/tools/tool-metadata.js';
|
|
6
|
+
|
|
7
|
+
export function assertOkResponse<TData extends Record<string, unknown>>(
|
|
8
|
+
response: ToolResponse<TData>
|
|
9
|
+
): OkResponse<TData> {
|
|
10
|
+
if (!response.ok) {
|
|
11
|
+
const failed = response as FailResponse;
|
|
12
|
+
const error = new Error(failed.error.message ?? ERROR_CODES.INTERNAL_ERROR) as AppError;
|
|
13
|
+
error.code = failed.error.code ?? ERROR_CODES.INTERNAL_ERROR;
|
|
14
|
+
error.details = failed.error.details ?? {};
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
return response;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function callCliTool(
|
|
21
|
+
toolClient: ToolClient,
|
|
22
|
+
runId: string,
|
|
23
|
+
toolName: string,
|
|
24
|
+
args: Record<string, unknown>
|
|
25
|
+
): Promise<OkResponse<Record<string, unknown>>> {
|
|
26
|
+
const payload = withOperationIdIfRequired(toolName, args, createOperationId);
|
|
27
|
+
|
|
28
|
+
const response = await toolClient.call(toolName, payload, {
|
|
29
|
+
run_id: runId,
|
|
30
|
+
session_id: 'bootstrap:cli',
|
|
31
|
+
actor_type: 'system',
|
|
32
|
+
actor_id: 'cli:system'
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return assertOkResponse(response);
|
|
36
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface CliOptions {
|
|
2
|
+
command: string;
|
|
3
|
+
file_input?: string;
|
|
4
|
+
folder_input?: string;
|
|
5
|
+
feature_id?: string;
|
|
6
|
+
dry_run?: boolean;
|
|
7
|
+
yes?: boolean;
|
|
8
|
+
remove_worktree?: boolean;
|
|
9
|
+
remove_branch?: string;
|
|
10
|
+
agent_provider?: string;
|
|
11
|
+
agent_model?: string;
|
|
12
|
+
provider_config_env?: string;
|
|
13
|
+
transport?: string;
|
|
14
|
+
takeover_stale_run?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type RemoveBranchMode = 'none' | 'safe' | 'force';
|
|
18
|
+
|
|
19
|
+
export interface RuntimeContext {
|
|
20
|
+
cwd: string;
|
|
21
|
+
env: NodeJS.ProcessEnv;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type ToolTransport = 'inprocess' | 'mcp';
|
|
25
|
+
|
|
26
|
+
export interface FeatureStatePayload {
|
|
27
|
+
front_matter: {
|
|
28
|
+
version: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface DiscoveredSpecsPayload {
|
|
33
|
+
specs: Array<{ spec_path: string }>;
|
|
34
|
+
}
|