@aibyzero/cm-workflow 0.10.5
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/.codex-plugin/plugin.json +30 -0
- package/AGENTS.md +74 -0
- package/CONTRIBUTING.md +62 -0
- package/LICENSE +21 -0
- package/README.md +263 -0
- package/SECURITY.md +49 -0
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/VERSION +1 -0
- package/agents/cm-backend-agent.md +34 -0
- package/agents/cm-contract-agent.md +34 -0
- package/agents/cm-database-agent.md +34 -0
- package/agents/cm-frontend-agent.md +33 -0
- package/agents/cm-miniprogram-agent.md +33 -0
- package/agents/cm-ui-agent.md +34 -0
- package/assets/docs/command-picker-mobile.svg +56 -0
- package/assets/docs/command-picker.svg +56 -0
- package/assets/docs/user-guide-hero-mobile.svg +35 -0
- package/assets/docs/user-guide-hero.svg +36 -0
- package/assets/readme/delivery-flow.svg +86 -0
- package/assets/readme/hero.svg +77 -0
- package/assets/readme/recovery-record.svg +73 -0
- package/assets/readme/test-evidence.svg +64 -0
- package/compat/claude-commands/cm-ai.md +3 -0
- package/compat/claude-commands/cm-check.md +3 -0
- package/compat/claude-commands/cm-fix.md +3 -0
- package/compat/claude-commands/cm-idea.md +3 -0
- package/compat/claude-commands/cm-init.md +3 -0
- package/compat/claude-commands/cm-prd.md +3 -0
- package/compat/claude-commands/cm-refactor.md +3 -0
- package/compat/claude-commands/cm-test.md +3 -0
- package/docs/architecture.md +155 -0
- package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-a1-handoff.json +57 -0
- package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-a2-handoff.json +58 -0
- package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-r1.md +121 -0
- package/docs/fixes/.reviews/fix-cancel-throw-v2-T-FIX-cancel-throw-v2-a1-handoff.json +56 -0
- package/docs/fixes/.reviews/fix-cancel-throw-v2-T-FIX-cancel-throw-v2-r1.md +100 -0
- package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-a1-handoff.json +61 -0
- package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-a2-handoff.json +63 -0
- package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-r1.md +58 -0
- package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-r2.md +55 -0
- package/docs/fixes/.reviews/fix-f01-dual-failure-terminal-T-FIX-f01-dual-failure-terminal-a1-handoff.json +65 -0
- package/docs/fixes/.reviews/fix-f01-dual-failure-terminal-T-FIX-f01-dual-failure-terminal-r1.md +88 -0
- package/docs/fixes/.reviews/fix-manifest-runtime-checkbox-drift-r1.md +33 -0
- package/docs/fixes/.reviews/fix-manifest-runtime-checkbox-drift-r2.md +31 -0
- package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-a1-handoff.json +56 -0
- package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-a2-handoff.json +85 -0
- package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-r1.md +53 -0
- package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-r2.md +80 -0
- package/docs/fixes/.reviews/fix-review-evidence-scope-honesty-T-FIX-review-evidence-scope-honesty-a1-handoff.json +35 -0
- package/docs/fixes/.reviews/fix-review-evidence-scope-honesty-T-FIX-review-evidence-scope-honesty-r1.md +33 -0
- package/docs/fixes/.reviews/fix-windows-cp1252-log-output-r1.md +30 -0
- package/docs/fixes/.reviews/fix-windows-cp1252-log-output-r2.md +16 -0
- package/docs/fixes/.reviews/openai-compatible-depth-fixture-T-FIX-openai-compatible-depth-fixture-a1-handoff.json +40 -0
- package/docs/fixes/.reviews/openai-compatible-depth-fixture-T-FIX-openai-compatible-depth-fixture-r1.md +30 -0
- package/docs/fixes/20260729-windows-cp1252-log-output.md +65 -0
- package/docs/fixes/20260804-manifest-runtime-checkbox-drift.md +67 -0
- package/docs/fixes/20260806-model-call-boundary-identity.md +80 -0
- package/docs/fixes/20260807-prelanding-integrity.md +58 -0
- package/docs/fixes/20260826-openai-compatible-depth-fixture.md +39 -0
- package/docs/fixes/20260903-cm-js-n1n2-admission-r1.md +64 -0
- package/docs/fixes/20260903-cm-js-n1n2-admission-successor.md +83 -0
- package/docs/fixes/20260903-s4c1b-v3-cancel-throw.md +89 -0
- package/docs/fixes/20260904-f01-codex-dual-failure-terminal.md +89 -0
- package/docs/fixes/20260907-wip-triage-log.md +44 -0
- package/docs/installation.md +202 -0
- package/docs/js-workflow-control.md +1010 -0
- package/docs/sample-prd/prd-funding-rate-alert.md +42 -0
- package/docs/sample-specs/docs//351/234/200/346/261/202/347/244/272/344/276/213.md +24 -0
- package/docs/user-guide.md +526 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/README.md +19 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.excalidraw +3650 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.mp4 +0 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.png +0 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.spec.json +223 -0
- package/install-codex.sh +184 -0
- package/install.ps1 +206 -0
- package/install.sh +244 -0
- package/package.json +58 -0
- package/runtime/external-expert.md +302 -0
- package/runtime/js/cm-ai/accepted-fix.mjs +28 -0
- package/runtime/js/cm-ai/claude-developer-adapter.mjs +6 -0
- package/runtime/js/cm-ai/claude-review-adapter.mjs +16 -0
- package/runtime/js/cm-ai/claude-review-stream.mjs +53 -0
- package/runtime/js/cm-ai/claude-tool-preview.mjs +107 -0
- package/runtime/js/cm-ai/cm-ai-admission.mjs +353 -0
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +217 -0
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +538 -0
- package/runtime/js/cm-ai/cm-ai-learning-handoff-writer.mjs +119 -0
- package/runtime/js/cm-ai/cm-ai-learning-writer.mjs +172 -0
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +320 -0
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +107 -0
- package/runtime/js/cm-ai/code-projects.mjs +85 -0
- package/runtime/js/cm-ai/codex-config.mjs +48 -0
- package/runtime/js/cm-ai/codex-developer-adapter.mjs +5 -0
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +6 -0
- package/runtime/js/cm-ai/codex-developer-output.schema.json +37 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +73 -0
- package/runtime/js/cm-ai/contracts.mjs +156 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +93 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +504 -0
- package/runtime/js/cm-ai/effect-contract.mjs +102 -0
- package/runtime/js/cm-ai/execution-platform.mjs +7 -0
- package/runtime/js/cm-ai/execution-store.mjs +211 -0
- package/runtime/js/cm-ai/fix-code-association.mjs +40 -0
- package/runtime/js/cm-ai/gate-bridge.mjs +25 -0
- package/runtime/js/cm-ai/host-bootstrap.mjs +170 -0
- package/runtime/js/cm-ai/host-check.mjs +89 -0
- package/runtime/js/cm-ai/host-conversation-execution.mjs +125 -0
- package/runtime/js/cm-ai/host-documentation.mjs +40 -0
- package/runtime/js/cm-ai/host-handoff.mjs +71 -0
- package/runtime/js/cm-ai/host-project-execution.mjs +58 -0
- package/runtime/js/cm-ai/host-qa-executor.mjs +238 -0
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +131 -0
- package/runtime/js/cm-ai/host-qa-fix.mjs +30 -0
- package/runtime/js/cm-ai/host-qa-policy.mjs +70 -0
- package/runtime/js/cm-ai/host-review-authority.mjs +36 -0
- package/runtime/js/cm-ai/host-review-file.mjs +56 -0
- package/runtime/js/cm-ai/host-role-routing.mjs +41 -0
- package/runtime/js/cm-ai/host-session.mjs +96 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +53 -0
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +45 -0
- package/runtime/js/cm-ai/host.mjs +20 -0
- package/runtime/js/cm-ai/index.mjs +7 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +86 -0
- package/runtime/js/cm-ai/qa-fix-definition.mjs +21 -0
- package/runtime/js/cm-ai/review-evidence-file.mjs +38 -0
- package/runtime/js/cm-ai/review-package.mjs +426 -0
- package/runtime/js/cm-ai/review-result.schema.json +40 -0
- package/runtime/js/cm-ai/review-runner.mjs +35 -0
- package/runtime/js/cm-ai/task-commit-codec.mjs +54 -0
- package/runtime/js/cm-ai/task-commit.mjs +201 -0
- package/runtime/js/cm-ai/task-owner.mjs +97 -0
- package/runtime/js/cm-ai/task-runner.mjs +766 -0
- package/runtime/js/cm-ai/tool-preview.mjs +205 -0
- package/runtime/js/cm-ai/worker-claude.mjs +104 -0
- package/runtime/js/cm-ai/worker-codex-developer.mjs +124 -0
- package/runtime/js/cm-ai/worker-codex.mjs +143 -0
- package/runtime/js/cm-check/host.mjs +101 -0
- package/runtime/js/cm-fix/baseline.mjs +70 -0
- package/runtime/js/cm-fix/cause-evidence.mjs +24 -0
- package/runtime/js/cm-fix/cause-invocation.mjs +40 -0
- package/runtime/js/cm-fix/cause-package.mjs +68 -0
- package/runtime/js/cm-fix/dossier.mjs +140 -0
- package/runtime/js/cm-fix/execution.mjs +1549 -0
- package/runtime/js/cm-fix/final-review-evidence.mjs +20 -0
- package/runtime/js/cm-fix/final-review.mjs +156 -0
- package/runtime/js/cm-fix/finish.mjs +124 -0
- package/runtime/js/cm-fix/handoff.mjs +64 -0
- package/runtime/js/cm-fix/host-review.mjs +38 -0
- package/runtime/js/cm-fix/host.mjs +96 -0
- package/runtime/js/cm-fix/investigation.mjs +25 -0
- package/runtime/js/cm-fix/layout.mjs +17 -0
- package/runtime/js/cm-fix/learning-writeback.mjs +86 -0
- package/runtime/js/cm-fix/learning.mjs +31 -0
- package/runtime/js/cm-fix/metrics.mjs +75 -0
- package/runtime/js/cm-fix/progress.mjs +64 -0
- package/runtime/js/cm-fix/protected-edits.mjs +95 -0
- package/runtime/js/cm-fix/qa-source.mjs +58 -0
- package/runtime/js/cm-fix/red-test.mjs +92 -0
- package/runtime/js/cm-fix/regression-evidence.mjs +64 -0
- package/runtime/js/cm-fix/regression.mjs +41 -0
- package/runtime/js/cm-fix/repair.mjs +95 -0
- package/runtime/js/cm-fix/reproduce.mjs +54 -0
- package/runtime/js/cm-fix/retrospective.mjs +41 -0
- package/runtime/js/cm-fix/review-baseline.mjs +47 -0
- package/runtime/js/cm-fix/start.mjs +49 -0
- package/runtime/js/cm-fix/test-author.mjs +63 -0
- package/runtime/js/cm-fix/visual.mjs +72 -0
- package/runtime/js/cm-fix/walkthrough.mjs +126 -0
- package/runtime/js/cm-idea/session.mjs +79 -0
- package/runtime/js/cm-init/draft-generation.mjs +66 -0
- package/runtime/js/cm-init/draft-inspection.mjs +70 -0
- package/runtime/js/cm-init/project-analysis.mjs +60 -0
- package/runtime/js/cm-init/project-scan.mjs +55 -0
- package/runtime/js/cm-init/review-evidence.mjs +80 -0
- package/runtime/js/cm-prd/accepted-design.mjs +46 -0
- package/runtime/js/cm-prd/analysis.mjs +260 -0
- package/runtime/js/cm-prd/change.mjs +268 -0
- package/runtime/js/cm-prd/correction-check.mjs +49 -0
- package/runtime/js/cm-prd/design-risk.mjs +30 -0
- package/runtime/js/cm-prd/disposition-plan.mjs +33 -0
- package/runtime/js/cm-prd/draft-save.mjs +122 -0
- package/runtime/js/cm-prd/draft.mjs +70 -0
- package/runtime/js/cm-prd/materials.mjs +48 -0
- package/runtime/js/cm-prd/review-correction.mjs +158 -0
- package/runtime/js/cm-prd/review-disposition.mjs +96 -0
- package/runtime/js/cm-prd/review-findings.mjs +36 -0
- package/runtime/js/cm-prd/review-host.mjs +48 -0
- package/runtime/js/cm-prd/review-preparation.mjs +49 -0
- package/runtime/js/cm-prd/review-publication.mjs +56 -0
- package/runtime/js/cm-prd/self-check.mjs +75 -0
- package/runtime/js/cm-prd/session.mjs +74 -0
- package/runtime/js/cm-prd/summary.mjs +133 -0
- package/runtime/js/cm-refactor/host.mjs +2 -0
- package/runtime/js/cm-refactor/records.mjs +86 -0
- package/runtime/js/cm-refactor/workflow.mjs +478 -0
- package/runtime/js/cm-test/declared-command.mjs +32 -0
- package/runtime/js/cm-test/host.mjs +319 -0
- package/runtime/js/cm-test/logic-results.mjs +39 -0
- package/runtime/js/cm-test/recovery.mjs +58 -0
- package/runtime/js/cm-test/session.mjs +56 -0
- package/runtime/js/cm-test/source-snapshot.mjs +136 -0
- package/runtime/logging.md +207 -0
- package/runtime/model-efficiency.md +201 -0
- package/runtime/orchestration.md +113 -0
- package/runtime/project-context.md +43 -0
- package/runtime/project-learning.md +49 -0
- package/runtime/review.md +140 -0
- package/runtime/steelman-review.md +111 -0
- package/runtime/task-gates.md +283 -0
- package/runtime/task-handoff.schema.json +103 -0
- package/runtime/test-contract.md +212 -0
- package/runtime/workflow-config.md +118 -0
- package/runtime/workflow-routing.md +82 -0
- package/scripts/cm-ai-admission.mjs +50 -0
- package/scripts/cm-ai-admission.test.mjs +38 -0
- package/scripts/cm-ai-batch-host.mjs +77 -0
- package/scripts/cm-ai-batch-host.test.mjs +155 -0
- package/scripts/cm-ai-batch-run.mjs +136 -0
- package/scripts/cm-ai-batch-run.test.mjs +128 -0
- package/scripts/cm-ai-bootstrap.test.mjs +228 -0
- package/scripts/cm-ai-fix-integration.test.mjs +233 -0
- package/scripts/cm-ai-host.mjs +175 -0
- package/scripts/cm-ai-host.test.mjs +368 -0
- package/scripts/cm-ai-multi-root.test.mjs +289 -0
- package/scripts/cm-ai-nested-execution.test.mjs +313 -0
- package/scripts/cm-ai-run.mjs +293 -0
- package/scripts/cm-ai-run.test.mjs +336 -0
- package/scripts/cm-check-entry.mjs +120 -0
- package/scripts/cm-check-host.mjs +29 -0
- package/scripts/cm-check-host.test.mjs +71 -0
- package/scripts/cm-check-runtime.ps1 +69 -0
- package/scripts/cm-check-runtime.sh +910 -0
- package/scripts/cm-claude-probe.test.mjs +54 -0
- package/scripts/cm-claude-review-stream.test.mjs +45 -0
- package/scripts/cm-claude-worker.test.mjs +92 -0
- package/scripts/cm-codex-developer-adapter.test.mjs +85 -0
- package/scripts/cm-codex-developer-worker.test.mjs +128 -0
- package/scripts/cm-codex-review-progress.test.mjs +96 -0
- package/scripts/cm-execution-platform.test.mjs +47 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +72 -0
- package/scripts/cm-fix-cause-package.test.mjs +68 -0
- package/scripts/cm-fix-code-association.test.mjs +55 -0
- package/scripts/cm-fix-entry.mjs +132 -0
- package/scripts/cm-fix-execution.test.mjs +63 -0
- package/scripts/cm-fix-final-review.test.mjs +124 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +34 -0
- package/scripts/cm-fix-host-review.test.mjs +261 -0
- package/scripts/cm-fix-host-sequence.test.mjs +26 -0
- package/scripts/cm-fix-host.mjs +89 -0
- package/scripts/cm-fix-host.test.mjs +105 -0
- package/scripts/cm-fix-learning-writeback.test.mjs +73 -0
- package/scripts/cm-fix-learning.test.mjs +66 -0
- package/scripts/cm-fix-metrics.test.mjs +58 -0
- package/scripts/cm-fix-no-existing-tests.test.mjs +92 -0
- package/scripts/cm-fix-observation-dossier.test.mjs +452 -0
- package/scripts/cm-fix-progress.test.mjs +45 -0
- package/scripts/cm-fix-protected-edits.test.mjs +54 -0
- package/scripts/cm-fix-qa-source.test.mjs +206 -0
- package/scripts/cm-fix-red-owner.test.mjs +143 -0
- package/scripts/cm-fix-red-test.test.mjs +38 -0
- package/scripts/cm-fix-regression.test.mjs +57 -0
- package/scripts/cm-fix-repair-owner.test.mjs +370 -0
- package/scripts/cm-fix-repair.test.mjs +68 -0
- package/scripts/cm-fix-reproduce.test.mjs +31 -0
- package/scripts/cm-fix-retrospective.test.mjs +46 -0
- package/scripts/cm-fix-review-baseline.test.mjs +54 -0
- package/scripts/cm-fix-review-recovery.test.mjs +197 -0
- package/scripts/cm-fix-test-author.test.mjs +105 -0
- package/scripts/cm-fix-visual-bare.test.mjs +171 -0
- package/scripts/cm-fix-walkthrough.test.mjs +45 -0
- package/scripts/cm-host-check.test.mjs +113 -0
- package/scripts/cm-host-documentation.test.mjs +45 -0
- package/scripts/cm-host-handoff.test.mjs +58 -0
- package/scripts/cm-host-qa-executor.test.mjs +156 -0
- package/scripts/cm-host-qa-policy.test.mjs +59 -0
- package/scripts/cm-host-review-authority.test.mjs +60 -0
- package/scripts/cm-host-role-routing.test.mjs +33 -0
- package/scripts/cm-idea-entry.mjs +104 -0
- package/scripts/cm-idea-host.mjs +144 -0
- package/scripts/cm-idea-host.test.mjs +75 -0
- package/scripts/cm-idea-recovery.test.mjs +90 -0
- package/scripts/cm-init-analysis-host.test.mjs +50 -0
- package/scripts/cm-init-draft-generation.test.mjs +52 -0
- package/scripts/cm-init-draft-inspection.test.mjs +41 -0
- package/scripts/cm-init-entry.mjs +170 -0
- package/scripts/cm-init-host.mjs +284 -0
- package/scripts/cm-init-host.test.mjs +231 -0
- package/scripts/cm-init-project-analysis.test.mjs +47 -0
- package/scripts/cm-init-project-scan.test.mjs +41 -0
- package/scripts/cm-init-revision-host.test.mjs +61 -0
- package/scripts/cm-init-session.test.mjs +122 -0
- package/scripts/cm-log-event.mjs +538 -0
- package/scripts/cm-log-event.py +133 -0
- package/scripts/cm-log-event.test.mjs +70 -0
- package/scripts/cm-openai-compatible-call.py +661 -0
- package/scripts/cm-prd-analysis.test.mjs +67 -0
- package/scripts/cm-prd-completion.test.mjs +190 -0
- package/scripts/cm-prd-design-phase.test.mjs +296 -0
- package/scripts/cm-prd-draft-save.test.mjs +63 -0
- package/scripts/cm-prd-draft.test.mjs +39 -0
- package/scripts/cm-prd-entry.mjs +245 -0
- package/scripts/cm-prd-host.mjs +273 -0
- package/scripts/cm-prd-host.test.mjs +169 -0
- package/scripts/cm-prd-materials.test.mjs +41 -0
- package/scripts/cm-prd-review-claim.test.mjs +42 -0
- package/scripts/cm-prd-review-disposition.test.mjs +196 -0
- package/scripts/cm-prd-review-gate.mjs +194 -0
- package/scripts/cm-prd-review-gate.py +26 -0
- package/scripts/cm-prd-review-host.test.mjs +30 -0
- package/scripts/cm-prd-review-preparation.test.mjs +69 -0
- package/scripts/cm-prd-review-publication.test.mjs +95 -0
- package/scripts/cm-prd-revision.test.mjs +32 -0
- package/scripts/cm-prd-self-check.test.mjs +23 -0
- package/scripts/cm-prd-sources.test.mjs +76 -0
- package/scripts/cm-prd-timing.py +272 -0
- package/scripts/cm-refactor-entry.mjs +145 -0
- package/scripts/cm-refactor-host.mjs +26 -0
- package/scripts/cm-refactor-host.test.mjs +201 -0
- package/scripts/cm-review-dependency-snapshot.test.mjs +67 -0
- package/scripts/cm-review-inventory.test.mjs +109 -0
- package/scripts/cm-spec-manifest.mjs +104 -0
- package/scripts/cm-spec-manifest.py +26 -0
- package/scripts/cm-task-gate.mjs +879 -0
- package/scripts/cm-task-gate.py +312 -0
- package/scripts/cm-task-gate.test.mjs +202 -0
- package/scripts/cm-test-declared-command.test.mjs +18 -0
- package/scripts/cm-test-entry.mjs +231 -0
- package/scripts/cm-test-host.mjs +40 -0
- package/scripts/cm-test-host.test.mjs +169 -0
- package/scripts/cm-test-logic-results.test.mjs +26 -0
- package/scripts/cm-test-session.test.mjs +138 -0
- package/scripts/cm-usage-report.py +516 -0
- package/scripts/cm-workflow-config.mjs +463 -0
- package/scripts/cm-workflow-config.test.mjs +181 -0
- package/scripts/cm-workflow.mjs +36 -0
- package/scripts/cm-workflow.test.mjs +51 -0
- package/scripts/cm_workflow_config.py +52 -0
- package/scripts/fixtures/claude-review-process.mjs +35 -0
- package/scripts/fixtures/codex-review-process.mjs +22 -0
- package/scripts/fixtures/prd-review-gate-python-oracle.py +320 -0
- package/scripts/fixtures/spec-manifest-python-oracle.py +172 -0
- package/scripts/scan-public-safety.py +117 -0
- package/scripts/test-cm-log-event.py +1213 -0
- package/scripts/test-cm-openai-compatible-call.py +1185 -0
- package/scripts/test-cm-prd-review-gate.py +272 -0
- package/scripts/test-cm-prd-timing.py +168 -0
- package/scripts/test-cm-usage-report.py +584 -0
- package/scripts/test-npm-install.py +171 -0
- package/scripts/test-scan-public-safety.py +76 -0
- package/scripts/test-shell-compat.sh +365 -0
- package/scripts/test-spec-manifest.py +263 -0
- package/scripts/test-task-gate.py +46 -0
- package/scripts/test-workflow-config.py +30 -0
- package/scripts/validate-public-repo.py +245 -0
- package/scripts/validate-test-cases.mjs +71 -0
- package/scripts/validate-test-cases.py +27 -0
- package/scripts/validate-test-cases.test.mjs +36 -0
- package/skills/cm-ai/SKILL.md +137 -0
- package/skills/cm-ai/references/N1-init.md +108 -0
- package/skills/cm-ai/references/N2-enter-feature.md +38 -0
- package/skills/cm-ai/references/N3-execute-task.md +123 -0
- package/skills/cm-ai/references/N4-review.md +103 -0
- package/skills/cm-ai/references/N5-mark-done.md +117 -0
- package/skills/cm-ai/references/N6-qa-eval.md +102 -0
- package/skills/cm-ai/references/N7-context.md +23 -0
- package/skills/cm-ai/references/N8-finish.md +103 -0
- package/skills/cm-ai/references/js-host.md +126 -0
- package/skills/cm-backend-engineer/SKILL.md +100 -0
- package/skills/cm-check/SKILL.md +52 -0
- package/skills/cm-check/references/js-host.md +44 -0
- package/skills/cm-contract-engineer/SKILL.md +136 -0
- package/skills/cm-database-engineer/SKILL.md +89 -0
- package/skills/cm-devops-engineer/SKILL.md +137 -0
- package/skills/cm-doc-syncer/SKILL.md +150 -0
- package/skills/cm-finance-expert/SKILL.md +85 -0
- package/skills/cm-fix/SKILL.md +199 -0
- package/skills/cm-fix/references/cross-boundary-debugging.md +44 -0
- package/skills/cm-fix/references/js-host.md +135 -0
- package/skills/cm-frontend-engineer/SKILL.md +127 -0
- package/skills/cm-idea/SKILL.md +55 -0
- package/skills/cm-idea/references/domains/trading.md +97 -0
- package/skills/cm-idea/references/example-prd.md +92 -0
- package/skills/cm-idea/references/idea-to-prd.md +282 -0
- package/skills/cm-idea/references/js-host.md +63 -0
- package/skills/cm-init/SKILL.md +191 -0
- package/skills/cm-init/references/js-host.md +123 -0
- package/skills/cm-miniprogram-engineer/SKILL.md +141 -0
- package/skills/cm-miniprogram-engineer/references/platform-readiness.md +58 -0
- package/skills/cm-miniprogram-engineer/references/release-checklist.md +59 -0
- package/skills/cm-prd/SKILL.md +548 -0
- package/skills/cm-prd/references/brownfield.md +13 -0
- package/skills/cm-prd/references/change-mode.md +145 -0
- package/skills/cm-prd/references/context-scope.md +62 -0
- package/skills/cm-prd/references/greenfield.md +80 -0
- package/skills/cm-prd/references/js-change-recovery.md +57 -0
- package/skills/cm-prd/references/js-host.md +98 -0
- package/skills/cm-prd/references/phase-timing.md +68 -0
- package/skills/cm-prd/references/spec-self-check.md +22 -0
- package/skills/cm-product-manager/SKILL.md +83 -0
- package/skills/cm-qa-engineer/SKILL.md +142 -0
- package/skills/cm-refactor/SKILL.md +236 -0
- package/skills/cm-refactor/references/js-batch.md +75 -0
- package/skills/cm-refactor/references/js-host.md +78 -0
- package/skills/cm-test/SKILL.md +288 -0
- package/skills/cm-test/references/js-host.md +118 -0
- package/skills/cm-ui-engineer/SKILL.md +105 -0
- package/skills/codebase-context/SKILL.md +489 -0
- package/skills/darwin-skill/NOTICE.md +26 -0
- package/skills/darwin-skill/README.md +272 -0
- package/skills/darwin-skill/SKILL.md +492 -0
- package/skills/darwin-skill/references/runtime-neutrality.md +68 -0
- package/skills/darwin-skill/references/skilllens-evidence.md +142 -0
- package/skills/darwin-skill/scripts/screenshot.mjs +71 -0
- package/skills/darwin-skill/templates/result-card-dark.html +698 -0
- package/skills/darwin-skill/templates/result-card-white.html +444 -0
- package/skills/darwin-skill/templates/result-card.html +616 -0
- package/skills/external-expert/SKILL.md +250 -0
- package/templates/arch-reference.md +68 -0
- package/templates/auto-update/cm-announce.sh +19 -0
- package/templates/auto-update/cm-update.sh +274 -0
- package/templates/cm-workflow.yml +52 -0
- package/templates/dashboard/dashboard.html +153 -0
- package/templates/dashboard/serve.sh +10 -0
- package/templates/hooks/pre-commit-cm-task-check +67 -0
- package/templates/pixel/cm-pixel.html +388 -0
- package/templates/pixel/cm-pixel.sh +212 -0
- package/templates/pixel/dev/README.md +20 -0
- package/templates/pixel/dev/atlas-preview.png +0 -0
- package/templates/pixel/dev/build.py +55 -0
- package/templates/pixel/dev/sheets/roguelikeChar_transparent.png +0 -0
- package/templates/pixel/dev/sheets/roguelikeCity_tilemap.png +0 -0
- package/templates/pixel/dev/sheets/roguelikeIndoor_transparent.png +0 -0
- package/templates/pixel/dev/template.html +388 -0
- package/templates/pixel/serve.sh +12 -0
- package/templates/refactor/cm-refactor-denies.json +14 -0
- package/templates/rules/backend-api.md +36 -0
- package/templates/rules/coding-style.md +44 -0
- package/templates/rules/database.md +27 -0
- package/templates/rules/finance.md +32 -0
- package/templates/rules/frontend.md +32 -0
- package/templates/rules/git-workflow.md +25 -0
- package/templates/rules/miniprogram.md +31 -0
- package/templates/rules/security.md +31 -0
- package/templates/rules/smart-contract.md +28 -0
- package/templates/rules/testing.md +36 -0
- package/templates/statusline/cm-statusline.sh +73 -0
- package/templates/ui-lens/cm-ui-lens-extract.mjs +55 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Fixed, no-provider control entry. Executing adapters are a subsequent slice.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import {fileURLToPath} from 'node:url';
|
|
6
|
+
import {serveCmAiHost} from '../runtime/js/cm-ai/host-session.mjs';
|
|
7
|
+
import {digest as sha} from '../runtime/js/cm-ai/contracts.mjs';
|
|
8
|
+
import {resolveCodeProjects,codeProjectPaths,assertCodeProjectSelections} from '../runtime/js/cm-ai/code-projects.mjs';
|
|
9
|
+
import {isSupportedExecutionPlatform} from '../runtime/js/cm-ai/execution-platform.mjs';
|
|
10
|
+
|
|
11
|
+
const usage='cm-ai-run.mjs serve --config PATH --mode create|resume (no provider dispatch)';
|
|
12
|
+
const fail=code=>{throw Object.assign(new Error(code),{code});};
|
|
13
|
+
// In-process provenance only; a config flag cannot certify protected callbacks.
|
|
14
|
+
const protectedExecutions=new WeakMap();
|
|
15
|
+
|
|
16
|
+
// Fixed adapter assembly for a trusted host. The authority callbacks are never
|
|
17
|
+
// sourced from run.json or the JSONL channel. Construction performs no dispatch.
|
|
18
|
+
export async function createCodexExecution(configuration,authority){
|
|
19
|
+
const {json,shape,need,id,text,validCallTimeout,freeze}=await import('../runtime/js/cm-ai/effect-contract.mjs');
|
|
20
|
+
const config=json(configuration);
|
|
21
|
+
shape(config,['codeProject','developerModel','reviewerModel','hostContextId','developerContextId',
|
|
22
|
+
'checkCommands','timeoutMs','reviewerPreflight',...['specsRoot','disabledSkills','workflow','bootstrap'].filter(key=>Object.hasOwn(config,key))]);
|
|
23
|
+
text(config.codeProject);text(config.developerModel);text(config.reviewerModel);
|
|
24
|
+
id(config.hostContextId);id(config.developerContextId);need(config.hostContextId!==config.developerContextId);
|
|
25
|
+
need(/^[A-Za-z0-9._-]+$/.test(config.developerModel));
|
|
26
|
+
need(!['codex-independent-review-1','codex-independent-review-2'].some(value=>
|
|
27
|
+
value===config.hostContextId||value===config.developerContextId),'not_independent');
|
|
28
|
+
validCallTimeout(config.timeoutMs);
|
|
29
|
+
shape(authority,['authorizeDevelopment','authorizeReview','hostDecision',
|
|
30
|
+
...['hostDecisionProvider','developmentAttempt','workflow','bootstrap'].filter(key=>Object.hasOwn(authority,key))]);
|
|
31
|
+
need(typeof authority.authorizeDevelopment==='function'&&typeof authority.authorizeReview==='function');
|
|
32
|
+
if(Object.hasOwn(authority,'developmentAttempt'))need([1,2].includes(authority.developmentAttempt),'invalid_development_attempt');
|
|
33
|
+
if(Object.hasOwn(authority,'hostDecisionProvider')){
|
|
34
|
+
shape(authority.hostDecisionProvider,['decide','timeoutMs']);
|
|
35
|
+
need(typeof authority.hostDecisionProvider.decide==='function'
|
|
36
|
+
&&Number.isInteger(authority.hostDecisionProvider.timeoutMs)&&authority.hostDecisionProvider.timeoutMs>0
|
|
37
|
+
&&authority.hostDecisionProvider.timeoutMs<=60000,'invalid_input');
|
|
38
|
+
}
|
|
39
|
+
const disabledSkills=config.disabledSkills??[];
|
|
40
|
+
need(Array.isArray(disabledSkills)&&disabledSkills.length<=4096
|
|
41
|
+
&&disabledSkills.every(p=>typeof p==='string'&&path.isAbsolute(p)&&!/[\n\r\0]/.test(p)),'invalid_review_config');
|
|
42
|
+
const {codexWorker,preflightMatches}=await import('../runtime/js/cm-ai/worker-codex.mjs');
|
|
43
|
+
const {codexDeveloperWorker}=await import('../runtime/js/cm-ai/worker-codex-developer.mjs');
|
|
44
|
+
const {createCodexDeveloperRun,readCodexDeveloperRequest}=await import('../runtime/js/cm-ai/codex-developer-adapter.mjs');
|
|
45
|
+
const {createCodexReviewRun}=await import('../runtime/js/cm-ai/codex-review-adapter.mjs');
|
|
46
|
+
const {createHostCheck}=await import('../runtime/js/cm-ai/host-check.mjs');
|
|
47
|
+
const specsRoot=config.specsRoot??null;
|
|
48
|
+
if(Object.hasOwn(config,'specsRoot')){
|
|
49
|
+
need(typeof specsRoot==='string','unsupported_path');
|
|
50
|
+
const {specsPermissionArgs}=await import('../runtime/js/cm-ai/codex-config.mjs');
|
|
51
|
+
specsPermissionArgs({cwd:config.codeProject,specsRoot});
|
|
52
|
+
}
|
|
53
|
+
let bootstrap=null;
|
|
54
|
+
need(Object.hasOwn(config,'bootstrap')===Object.hasOwn(authority,'bootstrap'),'bootstrap_configuration_required');
|
|
55
|
+
if(config.bootstrap){
|
|
56
|
+
shape(config.bootstrap,['definition','selection']);shape(authority.bootstrap,['bridge','allowWrite']);
|
|
57
|
+
need(specsRoot!==null&&config.bootstrap.definition.codeProject===config.codeProject
|
|
58
|
+
&&config.bootstrap.definition.specsDir===specsRoot,'execution_specs_mismatch');
|
|
59
|
+
const {createHostBootstrap}=await import('../runtime/js/cm-ai/host-bootstrap.mjs');
|
|
60
|
+
bootstrap=createHostBootstrap({definition:config.bootstrap.definition,workflowRoot:path.resolve(fileURLToPath(new URL('..',import.meta.url))),
|
|
61
|
+
selection:config.bootstrap.selection,...authority.bootstrap});
|
|
62
|
+
}
|
|
63
|
+
let workflowCapabilities={},documentationPaths=[],workflowDefinition=null;
|
|
64
|
+
need(Object.hasOwn(config,'workflow')===Object.hasOwn(authority,'workflow'),'workflow_configuration_required');
|
|
65
|
+
if(Object.hasOwn(config,'workflow')){
|
|
66
|
+
need(specsRoot!==null,'protected_configuration_required');
|
|
67
|
+
shape(config.workflow,['definition','configuration']);shape(authority.workflow,['bridge','allowQa']);
|
|
68
|
+
need(typeof authority.workflow.bridge?.call==='function'&&typeof authority.workflow.allowQa==='boolean');
|
|
69
|
+
workflowDefinition=validateRunDefinition(config.workflow.definition);
|
|
70
|
+
need(workflowDefinition.codeProject===config.codeProject&&workflowDefinition.specsDir===specsRoot,'execution_specs_mismatch');
|
|
71
|
+
const {validateHostWorkflowConfiguration,createHostWorkflowCapabilities}=await import('../runtime/js/cm-ai/host-workflow-capabilities.mjs');
|
|
72
|
+
const {validateDocumentationPaths}=await import('../runtime/js/cm-ai/host-documentation.mjs');
|
|
73
|
+
const workflow=validateHostWorkflowConfiguration(config.workflow.configuration);
|
|
74
|
+
documentationPaths=validateDocumentationPaths(workflow.documentationPaths,workflowDefinition.scope);
|
|
75
|
+
workflowCapabilities=createHostWorkflowCapabilities({definition:workflowDefinition,configuration:workflow,
|
|
76
|
+
bridge:authority.workflow.bridge,allowQa:authority.workflow.allowQa,protectedExecution:true,bootstrap});
|
|
77
|
+
}
|
|
78
|
+
const reviewOptions={cwd:config.codeProject,model:config.reviewerModel,promptTransport:'stdin',
|
|
79
|
+
schemaPath:fileURLToPath(new URL('../runtime/js/cm-ai/review-result.schema.json',import.meta.url)),
|
|
80
|
+
preflight:config.reviewerPreflight,timeoutMs:config.timeoutMs,disabledSkills};
|
|
81
|
+
need(preflightMatches(config.reviewerPreflight,reviewOptions),'tool_preflight_missing');
|
|
82
|
+
const check=createHostCheck({cwd:config.codeProject,commands:config.checkCommands,timeoutMs:config.timeoutMs,specsRoot});
|
|
83
|
+
const used=new Set();
|
|
84
|
+
const execution={
|
|
85
|
+
configuration:config,timeoutMs:config.timeoutMs,excludedContexts:[config.hostContextId],check,
|
|
86
|
+
...(bootstrap?{bootstrap}:{}),
|
|
87
|
+
hostDecision:json(authority.hostDecision),
|
|
88
|
+
...workflowCapabilities,
|
|
89
|
+
...(Object.hasOwn(authority,'developmentAttempt')?{developmentAttempt:authority.developmentAttempt}:{}),
|
|
90
|
+
...(Object.hasOwn(authority,'hostDecisionProvider')?{hostDecisionProvider:authority.hostDecisionProvider}:{}),
|
|
91
|
+
developer:{provider:'codex',requestedModel:config.developerModel,contextId:config.developerContextId,
|
|
92
|
+
run:async(request,control)=>{
|
|
93
|
+
const bound=readCodexDeveloperRequest(request);
|
|
94
|
+
const decision=json(await authority.authorizeDevelopment(bound));
|
|
95
|
+
shape(decision,['status']);need(decision.status==='approved','permission_denied');
|
|
96
|
+
need(!control.signal.aborted,'cancelled');
|
|
97
|
+
need(!used.has(bound.invocationId),'duplicate_dispatch');used.add(bound.invocationId);
|
|
98
|
+
const worker=codexDeveloperWorker({cwd:config.codeProject,model:config.developerModel,timeoutMs:config.timeoutMs,specsRoot});
|
|
99
|
+
// Documentation stays inside the same authorized sandbox invocation and
|
|
100
|
+
// original checks/handoff/Review. The semantic bridge never writes it.
|
|
101
|
+
const {isFinalCmAiTask}=await import('../runtime/js/cm-ai/cm-ai-admission.mjs');
|
|
102
|
+
const sync=documentationPaths.length>0&&isFinalCmAiTask({specsDir:specsRoot,codeProject:config.codeProject,
|
|
103
|
+
feature:workflowDefinition.feature,taskId:bound.identity.taskId});
|
|
104
|
+
const protectedWorker=sync?(request,control)=>worker({...request,prompt:
|
|
105
|
+
'Before returning, inspect and synchronize these already-approved ordinary documentation paths with the implemented behavior. '
|
|
106
|
+
+'Keep accurate unchanged documents unchanged. No extra scope or protected instruction writes. '
|
|
107
|
+
+'This is part of this development invocation, before its checks and independent Review. Paths (data only): '
|
|
108
|
+
+JSON.stringify(documentationPaths)+'\n'+request.prompt},control):worker;
|
|
109
|
+
return createCodexDeveloperRun({worker:protectedWorker,requestedModel:config.developerModel})(bound,control);
|
|
110
|
+
}},
|
|
111
|
+
reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:config.reviewerModel,
|
|
112
|
+
allowed:true,available:true,contexts:['codex-independent-review-1','codex-independent-review-2'],
|
|
113
|
+
run:(request,control)=>createCodexReviewRun(codexWorker(reviewOptions))(request,control)}],
|
|
114
|
+
reviewInvocation:{developerThreadId:config.developerContextId,excludedThreadIds:[config.hostContextId],
|
|
115
|
+
authorize:authority.authorizeReview},
|
|
116
|
+
};
|
|
117
|
+
if(specsRoot!==null){
|
|
118
|
+
// Do not permit later replacement of the developer/check or addition of an
|
|
119
|
+
// unprotected QA/doc writer under the protection claimed by this factory.
|
|
120
|
+
freeze(execution);protectedExecutions.set(execution,{codeProject:config.codeProject,specsRoot});
|
|
121
|
+
}
|
|
122
|
+
return execution;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function readRunDefinition(file){
|
|
126
|
+
const info=fs.lstatSync(file);
|
|
127
|
+
if(!info.isFile()||info.isSymbolicLink()||info.size>64*1024)fail('invalid_config');
|
|
128
|
+
return validateRunDefinition(JSON.parse(fs.readFileSync(file,'utf8')));
|
|
129
|
+
}
|
|
130
|
+
export function validateRunDefinition(input){
|
|
131
|
+
const value=structuredClone(input);
|
|
132
|
+
const keys=['version','specsDir','codeProject','feature','identity','scope','requirements'];
|
|
133
|
+
if(value&&Object.hasOwn(value,'codeProjects'))keys.push('codeProjects');
|
|
134
|
+
if(!value||typeof value!=='object'||Object.keys(value).sort().join()!==keys.sort().join()
|
|
135
|
+
||value.version!==1)fail('invalid_config');
|
|
136
|
+
if(typeof value.feature!=='string'||!/^\d+\.[^/\\]+$/.test(value.feature))fail('invalid_feature');
|
|
137
|
+
for(const key of ['specsDir','codeProject']){
|
|
138
|
+
if(typeof value[key]!=='string'||!path.isAbsolute(value[key]))fail('invalid_path');
|
|
139
|
+
value[key]=fs.realpathSync(value[key]);
|
|
140
|
+
if(!fs.statSync(value[key]).isDirectory())fail('invalid_path');
|
|
141
|
+
}
|
|
142
|
+
if(!value.identity||Object.keys(value.identity).sort().join()!=='attempt,repositoryId,runId,taskId'
|
|
143
|
+
||value.identity.attempt!==1)fail('invalid_identity');
|
|
144
|
+
for(const key of ['repositoryId','runId','taskId']){
|
|
145
|
+
if(typeof value.identity[key]!=='string'||!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(value.identity[key]))fail('invalid_identity');
|
|
146
|
+
}
|
|
147
|
+
for(const key of ['scope','requirements']){
|
|
148
|
+
if(!Array.isArray(value[key])||(!value[key].length&&!(key==='requirements'&&value.feature==='0.bootstrap'))||value[key].length>256
|
|
149
|
+
||value[key].some(p=>typeof p!=='string'||!p||p.includes('\\')||p.includes('\0')
|
|
150
|
+
||path.isAbsolute(p)||p.split('/').some(x=>!x||x==='.'||x==='..')))fail('invalid_paths');
|
|
151
|
+
}
|
|
152
|
+
if(Object.hasOwn(value,'codeProjects')){
|
|
153
|
+
value.codeProjects=[...resolveCodeProjects(value.codeProject,value.codeProjects)];
|
|
154
|
+
const prefixes=codeProjectPaths(value.codeProject,value.codeProjects);
|
|
155
|
+
assertCodeProjectSelections(prefixes,[...value.scope,...value.requirements]);
|
|
156
|
+
for(const root of value.codeProjects)if(root===value.specsDir||root.startsWith(value.specsDir+path.sep))fail('overlapping_roots');
|
|
157
|
+
}
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export async function openControlRun(definition,mode,execution=null){
|
|
162
|
+
// Check before importing node:sqlite: legacy Node users get a useful error.
|
|
163
|
+
if(!isSupportedExecutionPlatform())fail('unsupported_runner_platform');
|
|
164
|
+
const {conversationProtection}=await import('../runtime/js/cm-ai/host-conversation-execution.mjs');
|
|
165
|
+
if(!['create','resume'].includes(mode))fail('invalid_mode');
|
|
166
|
+
const {openTaskExecutionStore}=await import('../runtime/js/cm-ai/task-owner.mjs');
|
|
167
|
+
const {createCmAiHost}=await import('../runtime/js/cm-ai/host.mjs');
|
|
168
|
+
const {inspectCmAiAdmission}=await import('../runtime/js/cm-ai/cm-ai-admission.mjs');
|
|
169
|
+
const {captureReviewBaseline}=await import('../runtime/js/cm-ai/review-package.mjs');
|
|
170
|
+
if(execution!==null){
|
|
171
|
+
const {shape,json,validCallTimeout}=await import('../runtime/js/cm-ai/effect-contract.mjs');
|
|
172
|
+
shape(execution,['configuration','developer','reviewers','reviewInvocation','check','hostDecision','excludedContexts','timeoutMs',
|
|
173
|
+
...['bootstrap','developmentAttempt','hostDecisionProvider','qaDecisionProvider','qaLogHome','qaExecutor','applicableAgentFiles','documentationProvider','documentationResult','documentationSync'].filter(key=>Object.hasOwn(execution,key))]);
|
|
174
|
+
json(execution.configuration);validCallTimeout(execution.timeoutMs);
|
|
175
|
+
if(Object.hasOwn(execution.configuration,'codeProject'))
|
|
176
|
+
if(execution.configuration.codeProject!==definition.codeProject)fail('execution_root_mismatch');
|
|
177
|
+
if(Object.hasOwn(execution.configuration,'workflow')&&protectedExecutions.has(execution)
|
|
178
|
+
&&sha(execution.configuration.workflow.definition)!==sha(definition))fail('execution_definition_mismatch');
|
|
179
|
+
const conversation=conversationProtection(execution);
|
|
180
|
+
const protection=protectedExecutions.get(execution)??conversation;
|
|
181
|
+
if(conversation&&conversation.definitionDigest!==sha(definition))fail('execution_definition_mismatch');
|
|
182
|
+
if(protection){
|
|
183
|
+
if(protection.codeProject!==definition.codeProject||protection.specsRoot!==definition.specsDir)
|
|
184
|
+
fail('execution_specs_mismatch');
|
|
185
|
+
const {specsPermissionArgs}=await import('../runtime/js/cm-ai/codex-config.mjs');
|
|
186
|
+
specsPermissionArgs({cwd:definition.codeProject,specsRoot:definition.specsDir});
|
|
187
|
+
}
|
|
188
|
+
// Only the unchanged factory object can open the built-in nested execution
|
|
189
|
+
// path. Custom trusted test hosts retain their existing separate contract.
|
|
190
|
+
if((Object.hasOwn(execution.configuration,'codeProject')||execution.configuration.kind==='cm-current-conversation-v1')
|
|
191
|
+
&&definition.specsDir.startsWith(definition.codeProject+path.sep)&&!protection)fail('nested_specs_protection_required');
|
|
192
|
+
}
|
|
193
|
+
const {specsDir,codeProject,feature,identity,scope,requirements}=definition;
|
|
194
|
+
let bootstrapConfig=null;
|
|
195
|
+
if(execution?.bootstrap){
|
|
196
|
+
const {bootstrapConfiguration}=await import('../runtime/js/cm-ai/host-bootstrap.mjs');
|
|
197
|
+
bootstrapConfig=bootstrapConfiguration(execution.bootstrap,{root:codeProject,identity,scope,feature});
|
|
198
|
+
}
|
|
199
|
+
if(requirements.length===0&&!bootstrapConfig)fail('bootstrap_capability_required');
|
|
200
|
+
const selectedRoots=definition.codeProjects?codeProjectPaths(codeProject,resolveCodeProjects(codeProject,definition.codeProjects)):null;
|
|
201
|
+
if(selectedRoots){
|
|
202
|
+
if(!execution||conversationProtection(execution)===null)fail('multi_root_protection_required');
|
|
203
|
+
for(const root of definition.codeProjects){
|
|
204
|
+
const selected=inspectCmAiAdmission({specsDir,codeProject:root});
|
|
205
|
+
if(mode==='create'&&(selected.state!=='ready'||selected.nextTask.feature!==feature||selected.nextTask.id!==identity.taskId))
|
|
206
|
+
return {blocked:selected,close:()=>{}};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const developer=execution?.documentationSync
|
|
210
|
+
?(await import('../runtime/js/cm-ai/host-documentation.mjs')).withHostDocumentation({developer:execution.developer,
|
|
211
|
+
documentationSync:execution.documentationSync,specsDir,codeProject,feature,scope}):execution?.developer;
|
|
212
|
+
const admission=inspectCmAiAdmission({specsDir,codeProject});
|
|
213
|
+
if(mode==='create'&&admission.state!=='ready')return {blocked:admission,close:()=>{}};
|
|
214
|
+
if(mode==='create'&&(admission.nextTask.feature!==feature||admission.nextTask.id!==identity.taskId))fail('task_selection_mismatch');
|
|
215
|
+
const tasksPath=path.join(specsDir,feature,'tasks.md');
|
|
216
|
+
const featureSlug=feature.replace(/^\d+\./,'');
|
|
217
|
+
const reviewsDir=path.join(specsDir,'.reviews');
|
|
218
|
+
const handoffs=[1,2].map(attempt=>path.join(reviewsDir,`${featureSlug}-${identity.taskId}-a${attempt}-handoff.json`));
|
|
219
|
+
// Reuse the runner's real validator before creating durable state. A failed
|
|
220
|
+
// baseline must not strand an otherwise unused run ID.
|
|
221
|
+
const baselineOptions={root:codeProject,specsRoot:specsDir,identity,scope,requirements,
|
|
222
|
+
...(bootstrapConfig?{bootstrapRequirements:bootstrapConfig.bootstrapRequirements}:{}),
|
|
223
|
+
...(selectedRoots?{codeProjectPaths:selectedRoots}:{})};
|
|
224
|
+
if(mode==='create')captureReviewBaseline(baselineOptions);
|
|
225
|
+
// Definition is data, never an import path, command, grant or executable callback.
|
|
226
|
+
const store=openTaskExecutionStore({tasksPath,feature:featureSlug,specsRoot:specsDir,
|
|
227
|
+
identity:{repositoryId:identity.repositoryId,runId:identity.runId},
|
|
228
|
+
fingerprints:{workflow:sha(execution===null?'cm-ai-control-v1':'cm-ai-host-execution-v1'),
|
|
229
|
+
config:sha(execution===null?definition:{definition,execution:execution.configuration,
|
|
230
|
+
...(bootstrapConfig?{bootstrap:bootstrapConfig}:{}),
|
|
231
|
+
...(Object.hasOwn(execution,'developmentAttempt')?{developmentAuthorization:'per-attempt-v1'}:{}),
|
|
232
|
+
...(execution.hostDecisionProvider?{hostDecisionProvider:{version:1,timeoutMs:execution.hostDecisionProvider.timeoutMs}}:{}),
|
|
233
|
+
...(execution.qaDecisionProvider?{qaDecisionProvider:'host-v1',qaTimeoutMs:execution.qaDecisionProvider.timeoutMs}:{}),
|
|
234
|
+
...(execution.qaExecutor?{qaExecutor:{version:1,mode:execution.qaExecutor.mode,
|
|
235
|
+
caseCount:execution.qaExecutor.caseCount,timeoutMs:execution.qaExecutor.timeoutMs,
|
|
236
|
+
...(Object.hasOwn(execution.qaExecutor,'configuration')?{configuration:execution.qaExecutor.configuration}:{})}}:{}),
|
|
237
|
+
...(execution.applicableAgentFiles?{applicableAgentFiles:execution.applicableAgentFiles}:{}),
|
|
238
|
+
...(execution.documentationProvider?{documentationProvider:{version:1,timeoutMs:execution.documentationProvider.timeoutMs}}:{}),
|
|
239
|
+
...(execution.documentationResult?{documentationResult:execution.documentationResult}:{}),
|
|
240
|
+
...(execution.documentationSync?{documentationSync:{version:1,paths:execution.documentationSync.paths}}:{})}),inputs:sha({feature,task:identity.taskId})},
|
|
241
|
+
create:mode==='create'});
|
|
242
|
+
try{
|
|
243
|
+
let runnerMode=mode;
|
|
244
|
+
if(mode==='resume'&&store.snapshot().records.length===0){
|
|
245
|
+
// Only the genuine, fingerprint-matching empty initializer can be finished.
|
|
246
|
+
// Never reset/recreate a journal that contains any event.
|
|
247
|
+
if(admission.state!=='ready'||admission.nextTask.feature!==feature||admission.nextTask.id!==identity.taskId)
|
|
248
|
+
fail('initialization_admission_required');
|
|
249
|
+
captureReviewBaseline(baselineOptions);
|
|
250
|
+
runnerMode='create';
|
|
251
|
+
}
|
|
252
|
+
const unavailable=()=>fail('execution_adapter_required');
|
|
253
|
+
const host=createCmAiHost({
|
|
254
|
+
runner:{root:codeProject,identity,scope,requirements,...(selectedRoots?{codeProjectPaths:selectedRoots}:{}),excludedContexts:['control-host'],
|
|
255
|
+
developer:{provider:'codex',requestedModel:'unconfigured',contextId:'control-developer',run:unavailable},
|
|
256
|
+
reviewers:[],check:unavailable,taskCompletion:{reviewsDir,handoffs},taskLearning:{feature},
|
|
257
|
+
persistence:{store,mode:runnerMode,version:execution===null?2:3},
|
|
258
|
+
...(execution===null?{}:{developer,reviewers:execution.reviewers,
|
|
259
|
+
...(execution.bootstrap?{bootstrap:execution.bootstrap}:{}),
|
|
260
|
+
reviewInvocation:execution.reviewInvocation,check:execution.check,
|
|
261
|
+
excludedContexts:execution.excludedContexts,timeoutMs:execution.timeoutMs,
|
|
262
|
+
taskLearning:{feature,hostHandoff:true}})},
|
|
263
|
+
entry:{specsDir,codeProject,feature,identity,...(execution===null?{}:{hostDecision:execution.hostDecision,
|
|
264
|
+
...Object.fromEntries(['developmentAttempt','hostDecisionProvider','qaDecisionProvider','qaLogHome','qaExecutor','applicableAgentFiles','documentationProvider','documentationResult'].filter(key=>Object.hasOwn(execution,key)).map(key=>[key,execution[key]]))})},
|
|
265
|
+
});
|
|
266
|
+
return {host:{async handle(request){
|
|
267
|
+
if(execution===null&&!['status','cancel'].includes(request.operation)){
|
|
268
|
+
// Do not imply an unavailable execution adapter was dispatched.
|
|
269
|
+
return {outcome:'blocked',code:'execution_adapter_required',providerCalls:0};
|
|
270
|
+
}
|
|
271
|
+
return host.handle(request);
|
|
272
|
+
}},inspectFixAssociation:host.inspectFixAssociation,acceptCompletedFix:host.acceptCompletedFix,
|
|
273
|
+
checkpoint:()=>store.snapshot().revision,close:()=>store.close()};
|
|
274
|
+
}catch(error){store.close();throw error;}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Only a trusted in-process host supplies executable adapters/decisions. JSON
|
|
278
|
+
// config and protocol messages cannot load a module or turn execution on.
|
|
279
|
+
export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr,execution=null}={}){
|
|
280
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\n');return 0;}
|
|
281
|
+
let run;
|
|
282
|
+
try{
|
|
283
|
+
if(argv.length!==5||argv[0]!=='serve'||argv[1]!=='--config'||argv[3]!=='--mode')fail('invalid_arguments');
|
|
284
|
+
run=await openControlRun(readRunDefinition(argv[2]),argv[4],execution);
|
|
285
|
+
if(run.blocked){output.write(JSON.stringify({outcome:'blocked',admission:run.blocked})+'\n');return 1;}
|
|
286
|
+
await serveCmAiHost({host:run.host,input,output});return 0;
|
|
287
|
+
}catch(cause){
|
|
288
|
+
// No raw config/source/provider text in protocol errors.
|
|
289
|
+
const code=typeof cause.code==='string'&&/^[a-z_]+$/.test(cause.code)?cause.code:'control_failed';
|
|
290
|
+
error.write(JSON.stringify({error:{code}})+'\n');return 1;
|
|
291
|
+
}finally{run?.close();}
|
|
292
|
+
}
|
|
293
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=await main();
|