@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,155 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {spawn,spawnSync} from 'node:child_process';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
9
|
+
import {claudeReviewFingerprint} from '../runtime/js/cm-ai/worker-claude.mjs';
|
|
10
|
+
|
|
11
|
+
const cli=fileURLToPath(new URL('./cm-ai-batch-host.mjs',import.meta.url));
|
|
12
|
+
function fixture(runtime='codex'){
|
|
13
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-batch-host-')));
|
|
14
|
+
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.work',bin=path.join(root,'bin');
|
|
15
|
+
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);fs.mkdirSync(bin);
|
|
16
|
+
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Synthetic batch\n');
|
|
17
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: first\n- [ ] T-002: second\n');
|
|
18
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature]}));
|
|
19
|
+
fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Two synthetic exports and README\n');
|
|
20
|
+
const batch={version:1,repositoryId:'batch-host',batchId:'batch-host-run',specsDir,codeProject,
|
|
21
|
+
tasks:[1,2].map(n=>({feature,taskId:`T-00${n}`,scope:[`task${n}.mjs`,...(n===2?['README.md']:[])],requirements:['requirements.md']}))};
|
|
22
|
+
const workflows=Object.fromEntries(batch.tasks.map((task,index)=>[`${feature}/${task.taskId}`,{
|
|
23
|
+
documentationPaths:index===1?['README.md']:[],applicableAgentFiles:[],qa:{
|
|
24
|
+
commands:[{id:'value',caseIds:[],command:[process.execPath,'-e',
|
|
25
|
+
`import('./task${index+1}.mjs').then(m=>{if(m.value!==${41+index})process.exit(1)})`]}],
|
|
26
|
+
environment:{kind:'web',carrier:'browser',target:'http://127.0.0.1',scope:'local'}}}]));
|
|
27
|
+
const config=path.join(root,'batch.json');fs.writeFileSync(config,JSON.stringify({batch,workflows}));
|
|
28
|
+
const review=path.join(root,'review.json');
|
|
29
|
+
fs.writeFileSync(review,JSON.stringify({model:'fixture',preflight:{passed:true,cli_model:'fixture',
|
|
30
|
+
...(runtime==='claude'?{provider:runtime}:{}),prompt_transport:'stdin',
|
|
31
|
+
config_fingerprint:(runtime==='claude'?claudeReviewFingerprint:configFingerprint)({cwd:codeProject,model:'fixture'})}}));
|
|
32
|
+
const fake=path.join(bin,runtime);fs.copyFileSync(fileURLToPath(new URL(`./fixtures/${runtime}-review-process.mjs`,import.meta.url)),fake);fs.chmodSync(fake,0o700);
|
|
33
|
+
return {runtime,root,specsDir,codeProject,config,review,batch,env:{...process.env,PATH:bin+path.delimiter+process.env.PATH},
|
|
34
|
+
args:['serve','--config',config,'--host-context','current-batch-host','--allow-development','--review-config',review,'--allow-qa',
|
|
35
|
+
...(runtime==='claude'?['--runtime','claude']:[])]};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function execute(f,approvals,{cancel=false}={}){
|
|
39
|
+
return new Promise((resolve,reject)=>{
|
|
40
|
+
const child=spawn(process.execPath,[cli,...f.args,...approvals.flatMap(value=>['--allow-review',value])],
|
|
41
|
+
{env:f.env,stdio:['pipe','pipe','pipe']});
|
|
42
|
+
let buffer='',stderr='',sessionId;const calls=[],rows=[];
|
|
43
|
+
const timer=setTimeout(()=>{child.kill('SIGTERM');reject(Error('batch host timeout'));},15000);
|
|
44
|
+
child.stderr.on('data',part=>{stderr+=part;});child.once('error',reject);
|
|
45
|
+
const send=value=>child.stdin.write(JSON.stringify(value)+'\n');
|
|
46
|
+
const respond=(row,result)=>send({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result});
|
|
47
|
+
child.stdout.on('data',part=>{
|
|
48
|
+
buffer+=part;let newline;
|
|
49
|
+
while((newline=buffer.indexOf('\n'))!==-1){
|
|
50
|
+
const line=buffer.slice(0,newline);buffer=buffer.slice(newline+1);if(!line)continue;
|
|
51
|
+
try{
|
|
52
|
+
const row=JSON.parse(line);rows.push(row);
|
|
53
|
+
if(row.type==='host_ready')sessionId=row.sessionId;
|
|
54
|
+
if(row.type==='host_request'){
|
|
55
|
+
const payload=row.payload,identity=payload.identity??payload.request.identity;
|
|
56
|
+
calls.push(`${identity.taskId}:${row.kind}`);
|
|
57
|
+
if(cancel){send({operation:'status',requestId:'status'});send({operation:'cancel',requestId:'cancel'});continue;}
|
|
58
|
+
if(row.kind==='develop'){
|
|
59
|
+
assert.equal(payload.request.provider,f.runtime);
|
|
60
|
+
const n=Number(identity.taskId.slice(-1));
|
|
61
|
+
assert.deepEqual(payload.request.payload.scope,f.batch.tasks[n-1].scope);
|
|
62
|
+
const content=`export const value = ${40+n};\n`;
|
|
63
|
+
if(!f.protected)fs.writeFileSync(path.join(f.codeProject,`task${n}.mjs`),content);
|
|
64
|
+
respond(row,{status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
|
|
65
|
+
retrospective:{status:'no_new_lesson',candidates:[],reason:null}},...(f.protected?{edits:
|
|
66
|
+
payload.request.payload.scope.map(file=>({path:file,beforeSha256:payload.expected[file],
|
|
67
|
+
content:file==='README.md'?'# Exports 41 and 42\n':content}))}:{})});
|
|
68
|
+
}else if(row.kind==='check'){
|
|
69
|
+
const checks=payload.scope.filter(file=>file.endsWith('.mjs')).map(file=>{
|
|
70
|
+
const command=[process.execPath,'--check',path.join(f.codeProject,file)];
|
|
71
|
+
const result=spawnSync(command[0],command.slice(1));assert.equal(result.status,0);
|
|
72
|
+
return {id:'syntax',command,outcome:'passed',exitCode:0,evidence:'Actual Node syntax check exited 0'};
|
|
73
|
+
});respond(row,checks);
|
|
74
|
+
}else if(row.kind==='qa_assess')respond(row,{scores:{scope:2,risk:2,accumulation:2,boundary:2},
|
|
75
|
+
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}});
|
|
76
|
+
else if(row.kind==='documentation_sync'){
|
|
77
|
+
assert.equal(identity.taskId,'T-002');assert.deepEqual(payload.paths,['README.md']);
|
|
78
|
+
fs.writeFileSync(path.join(f.codeProject,'README.md'),'# Exports 41 and 42\n');respond(row,{status:'completed'});
|
|
79
|
+
}else if(row.kind==='documentation_inspect'){
|
|
80
|
+
assert.equal(fs.readFileSync(path.join(f.codeProject,'README.md'),'utf8'),'# Exports 41 and 42\n');
|
|
81
|
+
const {syncId,packageDigest,contextDigest}=payload;
|
|
82
|
+
respond(row,{syncId,identity,packageDigest,contextDigest,status:'completed',reason:'Actual README checked',
|
|
83
|
+
at:new Date().toISOString().replace(/\.\d{3}Z$/,'Z')});
|
|
84
|
+
}else assert.fail(`Unexpected ${row.kind}`);
|
|
85
|
+
}
|
|
86
|
+
if(row.requestId==='advance'&&(row.result||row.error))send({type:'host_close',sessionId});
|
|
87
|
+
}catch(error){clearTimeout(timer);child.kill('SIGTERM');reject(error);}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
child.once('close',code=>{clearTimeout(timer);resolve({code,stderr,calls,rows,result:rows.find(row=>row.requestId==='advance')?.result});});
|
|
91
|
+
send({operation:'advance',requestId:'advance'});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
test('protected Claude batch uses actual sandbox edits/checks and original two-task completion with nested specs',
|
|
96
|
+
{skip:process.platform!=='darwin'},async()=>{
|
|
97
|
+
const f=fixture('claude');f.protected=true;
|
|
98
|
+
try{
|
|
99
|
+
const nested=path.join(f.codeProject,'specs');fs.renameSync(f.specsDir,nested);f.specsDir=nested;f.batch.specsDir=nested;
|
|
100
|
+
const bundle=JSON.parse(fs.readFileSync(f.config,'utf8'));bundle.batch=f.batch;fs.writeFileSync(f.config,JSON.stringify(bundle));
|
|
101
|
+
const protection=path.join(f.root,'protection.json');
|
|
102
|
+
fs.writeFileSync(protection,JSON.stringify({timeoutMs:5000,checkCommands:[{id:'syntax',command:[process.execPath,'-e',
|
|
103
|
+
"const fs=require('node:fs'),a=require('node:assert/strict');a.throws(()=>fs.writeFileSync('specs/1.work/tasks.md','bad'));a.throws(()=>fs.writeFileSync('AGENTS.md','bad'));for(const p of fs.readdirSync('.').filter(p=>/^task.*mjs$/.test(p)))a.match(fs.readFileSync(p,'utf8'),/export const value = 4[12];/);"]}]}));
|
|
104
|
+
f.args.push('--protected-conversation-config',protection);
|
|
105
|
+
const result=await execute(f,['1.work/T-001:1','1.work/T-002:1']);
|
|
106
|
+
assert.equal(result.code,0,result.stderr);assert.equal(result.result.state,'run_done',JSON.stringify(result.result));
|
|
107
|
+
assert.deepEqual(result.calls,['T-001:develop','T-001:qa_assess','T-002:develop','T-002:qa_assess','T-002:documentation_inspect']);
|
|
108
|
+
assert.equal(fs.readFileSync(path.join(nested,'1.work/tasks.md'),'utf8').match(/\[x\]/g).length,2);
|
|
109
|
+
const resume=await execute(f,[]);assert.equal(resume.result.state,'run_done');assert.deepEqual(resume.calls,['T-002:documentation_inspect']);
|
|
110
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
for(const runtime of ['codex','claude'])test(`${runtime} batch CLI preserves per-task review authorization and reaches one original run_done without redispatch`,async()=>{
|
|
114
|
+
const f=fixture(runtime);
|
|
115
|
+
try{
|
|
116
|
+
const first=await execute(f,['1.work/T-001:1']);assert.equal(first.code,0,first.stderr);
|
|
117
|
+
assert.equal(first.result.identity.taskId,'T-002');assert.equal(first.result.code,'decision_required');
|
|
118
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-002'));
|
|
119
|
+
assert.deepEqual(first.calls,['T-001:develop','T-001:check','T-001:check','T-001:qa_assess',
|
|
120
|
+
'T-002:develop','T-002:documentation_sync','T-002:check']);
|
|
121
|
+
const original=fs.readFileSync(f.config,'utf8'),changed=JSON.parse(original);
|
|
122
|
+
changed.workflows['1.work/T-002'].documentationPaths=[];
|
|
123
|
+
fs.writeFileSync(f.config,JSON.stringify(changed));
|
|
124
|
+
const drift=await execute(f,['1.work/T-002:1']);
|
|
125
|
+
assert.equal(drift.result.outcome,'blocked');assert.deepEqual(drift.calls,[]);
|
|
126
|
+
fs.writeFileSync(f.config,original);
|
|
127
|
+
if(runtime==='claude'){
|
|
128
|
+
const saved=[...f.args];f.args[f.args.length-1]='codex';
|
|
129
|
+
const wrongRuntime=await execute(f,[]);assert.equal(wrongRuntime.result.outcome,'blocked');
|
|
130
|
+
assert.deepEqual(wrongRuntime.calls,[]);f.args=saved;
|
|
131
|
+
}
|
|
132
|
+
const second=await execute(f,['1.work/T-002:1']);assert.equal(second.code,0,second.stderr);
|
|
133
|
+
assert.equal(second.result.state,'run_done',JSON.stringify(second.result));
|
|
134
|
+
assert.deepEqual(second.calls,['T-002:check','T-002:qa_assess','T-002:documentation_inspect']);
|
|
135
|
+
const reopened=await execute(f,[]);assert.equal(reopened.code,0,reopened.stderr);
|
|
136
|
+
assert.equal(reopened.result.state,'run_done',JSON.stringify(reopened.result));
|
|
137
|
+
assert.deepEqual(reopened.calls,['T-002:documentation_inspect']);
|
|
138
|
+
const rows=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
139
|
+
assert.equal(rows.filter(row=>row.event==='run_done').length,1);
|
|
140
|
+
assert.equal(rows.filter(row=>row.event==='decision'&&row.phase==='batch_handoff').length,1);
|
|
141
|
+
assert.equal(rows.filter(row=>row.event==='test_run'&&row.phase==='start').length,2);
|
|
142
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
for(const runtime of ['codex','claude'])test(`${runtime} batch CLI cancellation remains durable and an unknown task approval rejects before execution`,async()=>{
|
|
146
|
+
const f=fixture(runtime);
|
|
147
|
+
try{
|
|
148
|
+
const bad=spawnSync(process.execPath,[cli,...f.args,'--allow-review','1.work/T-999:1'],{env:f.env,encoding:'utf8',timeout:3000});
|
|
149
|
+
assert.equal(bad.status,1);assert(bad.stderr.includes('review_task_mismatch'));assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
150
|
+
const stopped=await execute(f,[],{cancel:true});assert.equal(stopped.code,0,stopped.stderr);
|
|
151
|
+
assert.equal(stopped.result.code,'cancelled');assert.equal(stopped.calls.length,1);
|
|
152
|
+
assert(stopped.rows.some(row=>row.requestId==='status'));
|
|
153
|
+
const reopened=await execute(f,[]);assert.equal(reopened.result.code,'cancelled');assert.deepEqual(reopened.calls,[]);
|
|
154
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
155
|
+
});
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Trusted in-process batch driver. Task lifecycle and completion remain owned
|
|
2
|
+
// by the existing runner; only transitions between task runs are logged here.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import {spawnSync} from 'node:child_process';
|
|
6
|
+
import {fileURLToPath} from 'node:url';
|
|
7
|
+
import {openControlRun,validateRunDefinition} from './cm-ai-run.mjs';
|
|
8
|
+
import {digest,json,shape,need,id,hex} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
9
|
+
import {scanRows,findCmAiQaDecision,latestCmAiQaRun} from '../runtime/js/cm-ai/cm-ai-qa-log.mjs';
|
|
10
|
+
import {inspectRunClosure} from './cm-log-event.mjs';
|
|
11
|
+
|
|
12
|
+
const writer=fileURLToPath(new URL('./cm-log-event.py',import.meta.url));
|
|
13
|
+
const key=task=>`${task.feature}/${task.taskId}`;
|
|
14
|
+
export function createCmAiBatch({configuration,executionFor,logHome}){
|
|
15
|
+
const config=json(configuration);
|
|
16
|
+
shape(config,['version','repositoryId','batchId','specsDir','codeProject','tasks',...(Object.hasOwn(config,'codeProjects')?['codeProjects']:[])]);
|
|
17
|
+
need(config.version===1);id(config.repositoryId);id(config.batchId);need(config.batchId.length>=8);
|
|
18
|
+
need(typeof executionFor==='function'&&typeof logHome==='string'&&path.isAbsolute(logHome));
|
|
19
|
+
need(Array.isArray(config.tasks)&&config.tasks.length>0&&config.tasks.length<=256);
|
|
20
|
+
const plans=new Map();
|
|
21
|
+
for(const task of config.tasks){
|
|
22
|
+
shape(task,['feature','taskId','scope','requirements']);
|
|
23
|
+
need(!plans.has(key(task)));const definition=validateRunDefinition({version:1,
|
|
24
|
+
specsDir:config.specsDir,codeProject:config.codeProject,...(config.codeProjects?{codeProjects:config.codeProjects}:{}),feature:task.feature,
|
|
25
|
+
identity:{repositoryId:config.repositoryId,runId:`task-${digest({batchId:config.batchId,task:key(task)}).slice(0,48)}`,
|
|
26
|
+
taskId:task.taskId,attempt:1},scope:task.scope,requirements:task.requirements});
|
|
27
|
+
need(definition.specsDir===config.specsDir&&definition.codeProject===config.codeProject,'invalid_path');
|
|
28
|
+
plans.set(key(task),definition);
|
|
29
|
+
}
|
|
30
|
+
const first=plans.keys().next().value,planDigest=digest(config),log=path.join(config.specsDir,'运行日志.jsonl');
|
|
31
|
+
let active=null,busy=false,cancelled=false,liveKey=first;
|
|
32
|
+
const executions=new Map();
|
|
33
|
+
async function executionForKey(taskKey){
|
|
34
|
+
if(!executions.has(taskKey)){
|
|
35
|
+
const execution=await executionFor(json(plans.get(taskKey)));
|
|
36
|
+
need(execution!==null&&typeof execution==='object','execution_adapter_required');
|
|
37
|
+
// Preserve fixed protected-factory provenance; never clone protected callbacks.
|
|
38
|
+
if(Object.isFrozen(execution)){
|
|
39
|
+
need(execution.qaLogHome===logHome,'batch_log_mismatch');executions.set(taskKey,execution);
|
|
40
|
+
}else executions.set(taskKey,{...execution,qaLogHome:logHome});
|
|
41
|
+
}
|
|
42
|
+
return executions.get(taskKey);
|
|
43
|
+
}
|
|
44
|
+
function progress(){
|
|
45
|
+
const rows=[];
|
|
46
|
+
if(fs.existsSync(log))scanRows(log,row=>{
|
|
47
|
+
if(row?.workflow==='cm-ai'&&row.event==='decision'&&row.run_id===config.batchId
|
|
48
|
+
&&['batch_start','batch_handoff','batch_cancel'].includes(row.phase))rows.push(row);
|
|
49
|
+
});
|
|
50
|
+
let current=first,stopped=false;const seen=new Set();
|
|
51
|
+
for(const [index,row] of rows.entries()){
|
|
52
|
+
need(row.schema_version===1&&row.repository_id===config.repositoryId
|
|
53
|
+
&&row.plan_digest===planDigest,'batch_plan_mismatch');
|
|
54
|
+
need(!stopped&&row.from_key===current,'batch_history_invalid');
|
|
55
|
+
if(row.phase==='batch_start'){need(index===0,'batch_history_invalid');continue;}
|
|
56
|
+
need(index>0&&rows[0].phase==='batch_start','batch_history_invalid');
|
|
57
|
+
if(row.phase==='batch_cancel'){stopped=true;continue;}
|
|
58
|
+
need(plans.has(row.to_key)&&!seen.has(row.to_key)&&row.to_key!==current,'batch_history_invalid');
|
|
59
|
+
hex(row.checkpoint);hex(row.package_digest);seen.add(current);current=row.to_key;
|
|
60
|
+
}
|
|
61
|
+
return {rows,current,stopped};
|
|
62
|
+
}
|
|
63
|
+
function record(phase,data){
|
|
64
|
+
const result=spawnSync('python3',[writer,'--workflow','cm-ai','--event','decision','--phase',phase,
|
|
65
|
+
'--runtime','codex','--project-root',config.codeProject,'--specs-dir',config.specsDir,'--run-id',config.batchId,
|
|
66
|
+
'--detail',phase==='batch_handoff'?'Task QA and context completed; advance to next task':
|
|
67
|
+
phase==='batch_start'?'Approved task batch started':'Batch cancelled',
|
|
68
|
+
'--data-json',JSON.stringify({repository_id:config.repositoryId,plan_digest:planDigest,...data})],
|
|
69
|
+
{timeout:10000,maxBuffer:1024*1024,encoding:'utf8',env:{...process.env,CM_WORKFLOW_LOG_HOME:logHome}});
|
|
70
|
+
need(!result.error&&result.status===0&&result.signal===null,'batch_log_failed');
|
|
71
|
+
const receipt=JSON.parse(result.stdout);need(receipt.run_id===config.batchId,'batch_log_failed');
|
|
72
|
+
}
|
|
73
|
+
async function open(taskKey){
|
|
74
|
+
const definition=plans.get(taskKey),state=path.join(config.specsDir,'.reviews','.execution',definition.identity.runId,'state.json');
|
|
75
|
+
return openControlRun(definition,fs.existsSync(state)?'resume':'create',await executionForKey(taskKey));
|
|
76
|
+
}
|
|
77
|
+
return Object.freeze({async handle(raw){
|
|
78
|
+
const request=json(raw);shape(request,['operation','requestId']);id(request.requestId);
|
|
79
|
+
need(['advance','status','cancel'].includes(request.operation));
|
|
80
|
+
if(request.operation==='cancel'&&busy){
|
|
81
|
+
cancelled=true;
|
|
82
|
+
if(active){
|
|
83
|
+
if(progress().rows.length===0)record('batch_start',{from_key:liveKey});
|
|
84
|
+
record('batch_cancel',{from_key:liveKey});
|
|
85
|
+
return active.host.handle({version:1,operation:'cancel',requestId:request.requestId,identity:plans.get(liveKey).identity});
|
|
86
|
+
}
|
|
87
|
+
return {outcome:'cancelled',code:'cancel_pending',batchId:config.batchId};
|
|
88
|
+
}
|
|
89
|
+
if(request.operation==='status'&&busy)return {outcome:'reported',batchId:config.batchId,currentTask:liveKey,state:'running'};
|
|
90
|
+
need(!busy,'batch_busy');busy=true;
|
|
91
|
+
try{
|
|
92
|
+
const initial=progress();liveKey=initial.current;
|
|
93
|
+
if(initial.stopped)return {outcome:'blocked',code:'cancelled',batchId:config.batchId};
|
|
94
|
+
// Validate durable checkpoints, not old live snapshots: later approved
|
|
95
|
+
// tasks may legitimately change the same code paths.
|
|
96
|
+
for(const row of initial.rows.filter(row=>row.phase==='batch_handoff')){
|
|
97
|
+
const previous=await open(row.from_key);
|
|
98
|
+
try{
|
|
99
|
+
need(!previous.blocked&&previous.checkpoint()===row.checkpoint,'batch_checkpoint_mismatch');
|
|
100
|
+
const definition=plans.get(row.from_key),status=await previous.host.handle({version:1,operation:'status',
|
|
101
|
+
requestId:request.requestId,identity:definition.identity});
|
|
102
|
+
need(status.state==='fixture_completed'&&[null,'correction_review_required'].includes(status.code)
|
|
103
|
+
&&status.packageDigest===row.package_digest,'batch_checkpoint_mismatch');
|
|
104
|
+
const binding={specsDir:config.specsDir,feature:definition.feature,identity:status.identity,packageDigest:status.packageDigest};
|
|
105
|
+
const qa=findCmAiQaDecision(binding);
|
|
106
|
+
need(qa?.status==='skipped'||(qa?.status==='triggered'&&latestCmAiQaRun(binding)?.status==='passed'),'batch_qa_not_ready');
|
|
107
|
+
need(inspectRunClosure(log,definition.identity.runId).closed,'batch_resources_open');
|
|
108
|
+
}
|
|
109
|
+
finally{previous.close();}
|
|
110
|
+
}
|
|
111
|
+
for(let count=0;count<plans.size;count++){
|
|
112
|
+
active=await open(liveKey);
|
|
113
|
+
if(active.blocked)return {outcome:'blocked',code:active.blocked.reason,batchId:config.batchId};
|
|
114
|
+
// The child store holds the existing exclusive writer lock here. Reject
|
|
115
|
+
// a stale selection made before another batch process advanced.
|
|
116
|
+
need(progress().current===liveKey&&!progress().stopped,'batch_history_changed');
|
|
117
|
+
if(progress().rows.length===0&&request.operation!=='status')record('batch_start',{from_key:liveKey});
|
|
118
|
+
if(cancelled||request.operation==='cancel'){
|
|
119
|
+
record('batch_cancel',{from_key:liveKey});cancelled=true;
|
|
120
|
+
return active.host.handle({version:1,operation:'cancel',requestId:request.requestId,identity:plans.get(liveKey).identity});
|
|
121
|
+
}
|
|
122
|
+
const result=await active.host.handle({version:1,operation:request.operation,requestId:request.requestId,
|
|
123
|
+
identity:plans.get(liveKey).identity});
|
|
124
|
+
if(cancelled)return {outcome:'cancelled',code:'cancelled',batchId:config.batchId};
|
|
125
|
+
if(result.state==='run_done'||result.pendingAction==='start_next_task')
|
|
126
|
+
need(inspectRunClosure(log,plans.get(liveKey).identity.runId).closed,'batch_resources_open');
|
|
127
|
+
if(result.outcome!=='refreshed'||result.pendingAction!=='start_next_task')return {...result,batchId:config.batchId};
|
|
128
|
+
const next=`${result.nextTask.feature}/${result.nextTask.id}`;
|
|
129
|
+
need(plans.has(next),'batch_task_scope_required');
|
|
130
|
+
record('batch_handoff',{from_key:liveKey,to_key:next,checkpoint:active.checkpoint(),package_digest:result.packageDigest});
|
|
131
|
+
active.close();active=null;liveKey=next;
|
|
132
|
+
}
|
|
133
|
+
need(false,'batch_limit');
|
|
134
|
+
}finally{active?.close();active=null;busy=false;}
|
|
135
|
+
}});
|
|
136
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {createCmAiBatch} from './cm-ai-batch-run.mjs';
|
|
7
|
+
import {createCodexDeveloperRun} from '../runtime/js/cm-ai/codex-developer-adapter.mjs';
|
|
8
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
9
|
+
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
10
|
+
import {createHostQaDecisionProvider} from '../runtime/js/cm-ai/host-qa-policy.mjs';
|
|
11
|
+
import {createHostQaExecutor} from '../runtime/js/cm-ai/host-qa-executor.mjs';
|
|
12
|
+
|
|
13
|
+
for(const mode of ['continuous','qa-resume','failed-qa','cancel','learning','policy','executor'])
|
|
14
|
+
test(`real multi-task runner keeps QA and recovery authoritative: ${mode}`,async()=>{
|
|
15
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-batch-')));
|
|
16
|
+
try{
|
|
17
|
+
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.work';
|
|
18
|
+
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
|
|
19
|
+
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
|
|
20
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: first\n- [ ] T-002: second\n');
|
|
21
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature]}));
|
|
22
|
+
fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Fixture\n');
|
|
23
|
+
const config={version:1,repositoryId:'batch-fixture',batchId:'batch-fixture',specsDir,codeProject,
|
|
24
|
+
tasks:['T-001','T-002'].map((taskId,index)=>({feature,taskId,scope:[`file${index}.js`],requirements:['requirements.md']}))};
|
|
25
|
+
const calls=[],qaCalls=[],assessments=[];let qaReady=mode!=='qa-resume',started;
|
|
26
|
+
const began=new Promise(resolve=>{started=resolve;});
|
|
27
|
+
const executionFor=async definition=>({configuration:{kind:'batch-fixture-v1'},timeoutMs:3000,
|
|
28
|
+
excludedContexts:['host'],hostDecision:{status:'approved'},applicableAgentFiles:[],
|
|
29
|
+
developer:{provider:'codex',requestedModel:'fixture',contextId:'author',run:createCodexDeveloperRun({requestedModel:'fixture',
|
|
30
|
+
worker:async({prompt},{signal})=>{
|
|
31
|
+
calls.push(definition.identity.taskId);fs.writeFileSync(path.join(codeProject,definition.scope[0]),'implemented\n');
|
|
32
|
+
if(mode==='cancel'){started();await new Promise(resolve=>signal.addEventListener('abort',resolve,{once:true}));}
|
|
33
|
+
const application={status:'no_relevant_lesson',note:null};
|
|
34
|
+
let retrospective={status:'no_new_lesson',candidates:[],reason:null};
|
|
35
|
+
if(mode==='learning'&&definition.identity.taskId==='T-001')retrospective={status:'lesson_candidate',reason:null,
|
|
36
|
+
candidates:[{classification:'structured',trigger:'Synthetic task input requires explicit validation',
|
|
37
|
+
action:'Read the validated input before writing the next fixture',evidence:['file0.js']}]};
|
|
38
|
+
if(mode==='learning'&&definition.identity.taskId==='T-002'){
|
|
39
|
+
const source=fs.readFileSync(path.join(codeProject,'AGENTS.md'),'utf8');
|
|
40
|
+
assert(source.includes('Synthetic task input requires explicit validation'));
|
|
41
|
+
assert(prompt.includes('AGENTS.md'));
|
|
42
|
+
application.status='applied';application.note='Read and applied the T-001 synthetic input-validation lesson from AGENTS.md';
|
|
43
|
+
}
|
|
44
|
+
return {status:'succeeded',value:{outcome:'implemented',application,retrospective}};
|
|
45
|
+
}})},
|
|
46
|
+
check:async()=>[{id:'fixture',command:['fixture'],outcome:'passed',exitCode:0,evidence:'Synthetic task check'}],
|
|
47
|
+
reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:'fixture',allowed:true,available:true,
|
|
48
|
+
contexts:['review-1','review-2'],run:(request,{onEvent})=>{
|
|
49
|
+
if(mode==='learning'&&request.identity.taskId==='T-001')
|
|
50
|
+
assert(request.payload.reviewPackage.changes.some(change=>change.path==='AGENTS.md'));
|
|
51
|
+
for(const event of [{event:'thread.started',provider_thread:`review-${request.identity.taskId}`},
|
|
52
|
+
{event:'turn.started',item_type:null},{event:'item.completed',item_type:'agent_message'},
|
|
53
|
+
{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
54
|
+
return {status:'succeeded',value:{verdict:'approved',packageDigest:request.payload.reviewPackage.packageDigest,
|
|
55
|
+
examinedPaths:reviewPaths(request.payload.reviewPackage),findings:[],summary:'Synthetic independent review'}};
|
|
56
|
+
}}],
|
|
57
|
+
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['host'],authorize:(request,{authorizationAt})=>{
|
|
58
|
+
const body={version:1,kind:'cm-review-dispatch-grant',grantId:'grant',adapterId:'codex-review-adapter',
|
|
59
|
+
invocationId:request.invocationId,requestDigest:request.requestDigest,identity:request.identity,reviewerId:'reviewer',
|
|
60
|
+
logicalContextId:request.contextId,packageDigest:request.payload.reviewPackage.packageDigest,hostContextId:'host',
|
|
61
|
+
decisionId:'decision',decision:'approved',issuedAt:authorizationAt,expiresAt:authorizationAt+60000};
|
|
62
|
+
return {...body,grantDigest:digest(body)};
|
|
63
|
+
}},
|
|
64
|
+
qaDecisionProvider:mode==='policy'?createHostQaDecisionProvider({timeoutMs:1000,assess:async binding=>{
|
|
65
|
+
assessments.push(binding.identity.taskId);
|
|
66
|
+
return {scores:{scope:1,risk:1,accumulation:1,boundary:1},
|
|
67
|
+
changes:{api:binding.identity.taskId==='T-001',migration:false,authentication:false,authorization:false,payment:false}};
|
|
68
|
+
}}):{timeoutMs:1000,decide:async binding=>{
|
|
69
|
+
if(!qaReady)throw Object.assign(new Error('await QA decision'),{code:'qa_decision_required'});
|
|
70
|
+
const skip=binding.identity.taskId==='T-001'&&mode!=='failed-qa';
|
|
71
|
+
return {decisionId:`qa-${binding.identity.taskId}`,identity:binding.identity,packageDigest:binding.packageDigest,
|
|
72
|
+
status:skip?'skipped':'triggered',reason:'synthetic',score:skip?4:null,at:'2026-09-08T01:00:00Z'};
|
|
73
|
+
}},
|
|
74
|
+
qaExecutor:mode==='executor'?(()=>{
|
|
75
|
+
const executor=createHostQaExecutor({specsDir,codeProject,feature,runtime:'codex',requirements:definition.requirements,
|
|
76
|
+
commands:[{id:'fixture-command',command:[process.execPath,'-e',
|
|
77
|
+
"require('node:assert/strict').equal(require('node:fs').readFileSync(process.argv[1],'utf8'),'implemented\\n')",
|
|
78
|
+
definition.scope[0]],caseIds:[]}],environment:{kind:'web',carrier:'browser',target:'fixture-command-only',scope:'local'},
|
|
79
|
+
timeoutMs:5000,logHome:path.join(root,'logs')});
|
|
80
|
+
return {...executor,run:(binding,signal)=>{qaCalls.push(binding.identity.taskId);return executor.run(binding,signal);}};
|
|
81
|
+
})():{mode:'commands',caseCount:1,timeoutMs:1000,run:async binding=>{
|
|
82
|
+
qaCalls.push(binding.identity.taskId);
|
|
83
|
+
const report=path.join(specsDir,'.reviews',`${binding.testRunId}.md`);fs.writeFileSync(report,'# Synthetic QA\n');
|
|
84
|
+
const fail=mode==='failed-qa';return {result:fail?'FAIL':'PASS',passed:fail?0:1,failed:fail?1:0,blocked:0,report};
|
|
85
|
+
}},
|
|
86
|
+
documentationProvider:{timeoutMs:1000,inspect:async binding=>({syncId:binding.syncId,identity:binding.identity,
|
|
87
|
+
packageDigest:binding.packageDigest,contextDigest:binding.contextDigest,status:'completed',reason:'Synthetic docs',at:'2026-09-08T01:00:00Z'})},
|
|
88
|
+
});
|
|
89
|
+
const open=()=>createCmAiBatch({configuration:config,executionFor,logHome:path.join(root,'logs')});
|
|
90
|
+
const batch=open(),pending=batch.handle({operation:'advance',requestId:'advance-1'});
|
|
91
|
+
if(mode==='cancel'){
|
|
92
|
+
await began;await batch.handle({operation:'cancel',requestId:'cancel'});
|
|
93
|
+
assert.equal((await pending).code,'cancelled');
|
|
94
|
+
assert.equal((await open().handle({operation:'advance',requestId:'resume'})).code,'cancelled');
|
|
95
|
+
assert.deepEqual(calls,['T-001']);return;
|
|
96
|
+
}
|
|
97
|
+
let result=await pending;
|
|
98
|
+
if(mode==='qa-resume'){
|
|
99
|
+
assert.equal(result.code,'qa_decision_required');assert.deepEqual(calls,['T-001']);
|
|
100
|
+
assert(fs.readFileSync(path.join(specsDir,feature,'tasks.md'),'utf8').includes('[x] T-001'));
|
|
101
|
+
const changed=structuredClone(config);changed.tasks[1].scope=['other.js'];
|
|
102
|
+
await assert.rejects(createCmAiBatch({configuration:changed,executionFor,logHome:path.join(root,'logs')})
|
|
103
|
+
.handle({operation:'advance',requestId:'changed-plan'}),{code:'batch_plan_mismatch'});
|
|
104
|
+
qaReady=true;result=await open().handle({operation:'advance',requestId:'advance-2'});
|
|
105
|
+
}
|
|
106
|
+
assert.equal(result.code,mode==='failed-qa'?'qa_failed':'run_done',JSON.stringify(result));
|
|
107
|
+
assert.deepEqual(calls,mode==='failed-qa'?['T-001']:['T-001','T-002']);
|
|
108
|
+
if(mode==='learning'){
|
|
109
|
+
const handoff=JSON.parse(fs.readFileSync(path.join(specsDir,'.reviews','work-T-002-a1-handoff.json'),'utf8'));
|
|
110
|
+
assert(handoff.evidence.some(item=>typeof item==='string'&&item.includes('"status":"applied"')));
|
|
111
|
+
}
|
|
112
|
+
const before=[...calls],qaBefore=[...qaCalls];
|
|
113
|
+
const resumed=await open().handle({operation:'advance',requestId:'resume'});
|
|
114
|
+
assert.equal(resumed.code,result.code);assert.deepEqual(calls,before);assert.deepEqual(qaCalls,qaBefore);
|
|
115
|
+
if(mode==='executor'){
|
|
116
|
+
assert.deepEqual(qaCalls,['T-002']);
|
|
117
|
+
const reports=fs.readdirSync(path.join(specsDir,'.reviews')).filter(name=>name.endsWith('-execution.md'));
|
|
118
|
+
assert.equal(reports.length,1);assert(fs.readFileSync(path.join(specsDir,'.reviews',reports[0]),'utf8').includes('host check exited 0'));
|
|
119
|
+
}
|
|
120
|
+
if(mode==='policy'){
|
|
121
|
+
assert.deepEqual(assessments,['T-001','T-002']);assert.deepEqual(qaCalls,['T-002']);
|
|
122
|
+
const log=fs.readFileSync(path.join(specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
123
|
+
assert(log.some(row=>row.event==='qa'&&row.task==='T-001'&&row.reason==='merged_to_feature_qa'));
|
|
124
|
+
assert.equal(log.filter(row=>row.event==='decision'&&row.phase==='qa_merge'&&row.task==='T-001').length,1);
|
|
125
|
+
assert(log.some(row=>row.event==='qa'&&row.task==='T-002'&&row.reason==='feature_complete'));
|
|
126
|
+
}
|
|
127
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
128
|
+
});
|