@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,175 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Opt-in current-conversation host. Review requires a separately authorized
|
|
3
|
+
// attempt and the registered V3 boundary; preflight is only local diagnostics.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {fileURLToPath} from 'node:url';
|
|
7
|
+
import {readRunDefinition,openControlRun,createCodexExecution} from './cm-ai-run.mjs';
|
|
8
|
+
import {createConversationExecution as executionFor} from '../runtime/js/cm-ai/host-conversation-execution.mjs';
|
|
9
|
+
import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
10
|
+
import {serveCmAiHost} from '../runtime/js/cm-ai/host-session.mjs';
|
|
11
|
+
import {createQaFixOwnerHost} from '../runtime/js/cm-ai/host-qa-fix-owner.mjs';
|
|
12
|
+
import {createFixLearningPreparation} from '../runtime/js/cm-fix/learning.mjs';
|
|
13
|
+
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
14
|
+
import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
|
|
15
|
+
import {readHostWorkflowConfiguration} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
16
|
+
import {digest,json,need,shape} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
17
|
+
export {executionFor as createConversationExecution,reviewConfiguration as readConversationReviewConfiguration};
|
|
18
|
+
export {conversationProtection} from '../runtime/js/cm-ai/host-conversation-execution.mjs';
|
|
19
|
+
export function readConversationProtection(file){
|
|
20
|
+
const stat=fs.lstatSync(file);need(stat.isFile()&&!stat.isSymbolicLink()&&stat.size<=64*1024,'invalid_protected_config');
|
|
21
|
+
const config=json(JSON.parse(fs.readFileSync(file,'utf8')));shape(config,['checkCommands','timeoutMs']);return config;
|
|
22
|
+
}
|
|
23
|
+
export function readBootstrapConfiguration(file){
|
|
24
|
+
const stat=fs.lstatSync(file);need(stat.isFile()&&!stat.isSymbolicLink()&&stat.size<=64*1024,'invalid_bootstrap_config');
|
|
25
|
+
const config=json(JSON.parse(fs.readFileSync(file,'utf8')));shape(config,['selection']);return config;
|
|
26
|
+
}
|
|
27
|
+
const fixLocalPermissions=new Map(['red-test','baseline','regression','learning-writeback','walkthrough','finish',
|
|
28
|
+
'test-author','repair','cause-review','final-review']
|
|
29
|
+
.map(name=>[`--allow-qa-fix-${name}`,`--allow-${name}`]));
|
|
30
|
+
|
|
31
|
+
const usage='cm-ai-host.mjs serve --config PATH --mode create|resume --host-context ID --allow-development [--runtime codex|claude] [--review-config PATH] [--allow-review-attempt 1|2] [--workflow-config PATH] [--allow-qa]\ncm-ai-host.mjs preflight --config PATH --review-model MODEL [--runtime codex|claude] (synthetic loopback only)';
|
|
32
|
+
|
|
33
|
+
function reviewConfiguration(file){
|
|
34
|
+
const info=fs.lstatSync(file);
|
|
35
|
+
need(info.isFile()&&!info.isSymbolicLink()&&info.size<=64*1024,'invalid_review_config');
|
|
36
|
+
const config=json(JSON.parse(fs.readFileSync(file,'utf8')));
|
|
37
|
+
shape(config,['model','preflight',...(Object.hasOwn(config,'disabledSkills')?['disabledSkills']:[])]);
|
|
38
|
+
need(typeof config.model==='string'&&/^[a-zA-Z0-9._-]+$/.test(config.model),'invalid_review_config');
|
|
39
|
+
const disabledSkills=config.disabledSkills??[];
|
|
40
|
+
need(Array.isArray(disabledSkills)&&disabledSkills.length<=4096
|
|
41
|
+
&&disabledSkills.every(item=>typeof item==='string'&&path.isAbsolute(item)&&!/[\n\r\0]/.test(item)),'invalid_review_config');
|
|
42
|
+
return json({...config,disabledSkills});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function protectedExecutionFor(definition,hostContextId,extra,review,mode,workflow,bridge,bootstrap=null){
|
|
46
|
+
need((extra.get('--runtime')??'codex')==='codex','protected_runtime_unsupported');
|
|
47
|
+
need(review!==null,'review_configuration_required');
|
|
48
|
+
need(['1','2'].includes(extra.get('--allow-provider-development-attempt')),'provider_development_authorization_required');
|
|
49
|
+
const attempt=Number(extra.get('--allow-provider-development-attempt'));
|
|
50
|
+
need(mode!=='create'||attempt===1,'invalid_development_attempt');
|
|
51
|
+
// Child fix configuration is checked before opening the parent store below.
|
|
52
|
+
const file=extra.get('--protected-config'),info=fs.lstatSync(file);
|
|
53
|
+
need(info.isFile()&&!info.isSymbolicLink()&&info.size<=64*1024,'invalid_protected_config');
|
|
54
|
+
const config=json(JSON.parse(fs.readFileSync(file,'utf8')));shape(config,['model','checkCommands','timeoutMs']);
|
|
55
|
+
const authority=createHostReviewAuthority({hostContextId,reviewerId:'reviewer',adapterId:'codex-review-adapter',
|
|
56
|
+
decide:async binding=>String(binding.identity.attempt)===extra.get('--allow-review-attempt')?{status:'approved'}:null});
|
|
57
|
+
return createCodexExecution({codeProject:definition.codeProject,specsRoot:definition.specsDir,
|
|
58
|
+
developerModel:config.model,checkCommands:config.checkCommands,timeoutMs:config.timeoutMs,
|
|
59
|
+
hostContextId,developerContextId:'cm-protected-author',reviewerModel:review.model,
|
|
60
|
+
reviewerPreflight:review.preflight,disabledSkills:review.disabledSkills,
|
|
61
|
+
...(workflow?{workflow:{definition,configuration:workflow}}:{}),
|
|
62
|
+
...(bootstrap?{bootstrap:{definition,selection:bootstrap.selection}}:{})},
|
|
63
|
+
{hostDecision:null,developmentAttempt:attempt,hostDecisionProvider:authority.hostDecisionProvider,authorizeReview:authority.authorize,
|
|
64
|
+
...(workflow?{workflow:{bridge,allowQa:extra.has('--allow-qa')}}:{}),
|
|
65
|
+
...(bootstrap?{bootstrap:{bridge,allowWrite:extra.has('--allow-bootstrap-write')}}:{}),
|
|
66
|
+
authorizeDevelopment:request=>({status:request.identity.attempt===attempt
|
|
67
|
+
&&digest({...request.identity,attempt:1})===digest(definition.identity)?'approved':'denied'})});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr}={}){
|
|
72
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Approved 0.bootstrap only: --bootstrap-config PATH {selection:null for scaffold, or original cm-init selection for rules} and --allow-bootstrap-write. Original scope must include fixed instruction targets; they are host-written inside the original task effect, checked/reviewed and reloaded. No Git/install/network grant. Optional codeProjects selects disjoint real roots below codeProject; prefix scope/requirements and use protected current-session checks with a declared codeProject per command.\n');
|
|
73
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Protected current-session mode (Codex or Claude; also batch): --protected-conversation-config PATH with {checkCommands,timeoutMs}. No extra model call. The current host returns scoped UTF-8 edits; native Codex sandbox applies them and runs the declared checks. Original author runtime, per-attempt Review and QA permissions remain required. Do not combine with --protected-config. Same original 64KiB transport limit; unavailable/binary changes stop, never switch to direct writes.\n');
|
|
74
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Protected single-task Codex mode: add --protected-config PATH --allow-provider-development-attempt 1|2 and --review-config PATH. Protected config is {model,checkCommands,timeoutMs}; roots and host identity come from the original run definition and launch. This explicitly permits one task attempt of real developer execution and its declared native-sandbox checks; --allow-development alone does not. Review separately requires --allow-review-attempt 1|2. Diagnostics are required but are not review authorization. Optional original --workflow-config PATH and --allow-qa connect protected QA commands and documentation within the same developer invocation before Review; host semantic/browser/inspection requests retain their original contracts, not arbitrary writes. Default current-session mode is unchanged. Protected parent mode rejects Claude; original QA-fix options require child configuration.protectSpecs=true and all original child action permissions. Protected fix writes use text proposals, not direct host edits. The original QA/documentation/finalizer gates remain required. No installation or Git authority.\n');
|
|
75
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--auto-qa-fix optionally connects parent advance -> fix_run -> re-QA. Requires --qa-fix-template-config, --allow-qa-fix-start, original action permissions and project policies.auto_fix=auto. Explicit/never policies stop. Unknown, blocked or incomplete repair stops; status/cancel remain available and no fourth QA round is dispatched.\n');
|
|
76
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--qa-fix-template-config PATH is an alternative to --qa-fix-owner-config. Supply {specsRoot, feature, identity: parent identity, configuration: original fix configuration without qaSource}. Each fix request binds it to the latest completed QA failure; identity/digests are generated, commands/scope/permissions are not. Existing child configuration remains immutable.\n');
|
|
77
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('fix_run continuously executes normal stages of the fixed QA child using the same binding as fix_advance. Requires --allow-qa-fix-start and every original per-action permission/configuration. Stops on unknown, blocked, observation, revision-required or unchanged state. It does not auto-switch child configuration or run parent QA.\n');
|
|
78
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('fix_action delegates to the shared original cm-fix dispatcher. Local flags: --allow-qa-fix-red-test, --allow-qa-fix-baseline, --allow-qa-fix-regression, --allow-qa-fix-learning-writeback, --allow-qa-fix-walkthrough, --allow-qa-fix-finish. Adapter flags: --allow-qa-fix-test-author, --allow-qa-fix-repair, --allow-qa-fix-cause-review, --allow-qa-fix-final-review, with separate --qa-fix-review-config PATH and matching original child reviewer metadata. All require --allow-qa-fix-start and the original action configuration/gates. Parent --review-config/--allow-review-attempt do not grant child review permission.\n');
|
|
79
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--allow-qa-fix-start additionally permits fix_advance to create or resume the fixed QA child and run only its original Learning/reproduction/diagnosis stages. Child hostContextId and runtime must match this host. It does not authorize test authoring, repair, independent provider Review, finish, Git or re-QA. Active child status/cancel use the original child owner; repeated advance never resets an unknown or completed step.\n');
|
|
80
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--qa-fix-owner-config PATH enables read-only fix_status. The file contains the existing fix owner definition {specsRoot, identity, configuration}, including its exact original qaSource and immutable configuration, not provider grants. fix_status binds the parent identity/packageDigest/testRunId, serially closes the parent writer, opens only an existing child, reads its original completion evidence, closes it and resumes the same parent. It does not create/execute repairs, rerun QA or clear correction gates.\n');
|
|
81
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\n');return 0;}
|
|
82
|
+
let run,bridge;
|
|
83
|
+
try{
|
|
84
|
+
if(argv[0]==='preflight'){
|
|
85
|
+
need((argv.length===5||argv.length===7)&&argv[1]==='--config'&&argv[3]==='--review-model','invalid_arguments');
|
|
86
|
+
const runtime=argv.length===5?'codex':argv[6];
|
|
87
|
+
need(argv.length===5||argv[5]==='--runtime','invalid_arguments');
|
|
88
|
+
need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
89
|
+
const definition=readRunDefinition(argv[2]);
|
|
90
|
+
if(runtime==='claude'){
|
|
91
|
+
const {previewClaudeTools}=await import('../runtime/js/cm-ai/claude-tool-preview.mjs');
|
|
92
|
+
const config=await previewClaudeTools({cwd:definition.codeProject,model:argv[4]});
|
|
93
|
+
output.write(JSON.stringify(config)+'\n');return config.preflight.passed?0:1;
|
|
94
|
+
}
|
|
95
|
+
const {previewIsolated}=await import('../runtime/js/cm-ai/tool-preview.mjs');
|
|
96
|
+
const receipt=await previewIsolated({cwd:definition.codeProject,model:argv[4],allowCodeProject:true,promptTransport:'stdin'});
|
|
97
|
+
// No raw startup diagnostics, headers, prompt or discovered content.
|
|
98
|
+
output.write(JSON.stringify({model:argv[4],disabledSkills:receipt.disabledSkillFolders,preflight:{passed:receipt.passed,
|
|
99
|
+
cli_model:receipt.cli_model,config_fingerprint:receipt.config_fingerprint,prompt_transport:receipt.prompt_transport,
|
|
100
|
+
real_model_requests:receipt.real_model_requests,listener_closed:receipt.listener_closed}})+'\n');
|
|
101
|
+
return receipt.passed?0:1;
|
|
102
|
+
}
|
|
103
|
+
need(argv.length>=8&&argv[0]==='serve'&&argv[1]==='--config'&&argv[3]==='--mode'
|
|
104
|
+
&&argv[5]==='--host-context'&&argv[7]==='--allow-development','host_launch_authorization_required');
|
|
105
|
+
const extra=new Map();
|
|
106
|
+
for(let index=8;index<argv.length;index++){
|
|
107
|
+
const name=argv[index];need(!extra.has(name),'invalid_arguments');
|
|
108
|
+
need(['--bootstrap-config','--allow-bootstrap-write','--protected-conversation-config','--protected-config','--allow-provider-development-attempt','--review-config','--allow-review-attempt','--workflow-config','--allow-qa','--runtime','--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name),'invalid_arguments');
|
|
109
|
+
if(['--allow-bootstrap-write','--allow-qa','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name))extra.set(name,true);
|
|
110
|
+
else{need(typeof argv[index+1]==='string'&&!argv[index+1].startsWith('--'),'invalid_arguments');extra.set(name,argv[++index]);}
|
|
111
|
+
}
|
|
112
|
+
const review=extra.has('--review-config')?reviewConfiguration(extra.get('--review-config')):null;
|
|
113
|
+
const workflow=extra.has('--workflow-config')?readHostWorkflowConfiguration(extra.get('--workflow-config')):null;
|
|
114
|
+
let allowedAttempt=null;
|
|
115
|
+
if(extra.has('--allow-review-attempt')){need(['1','2'].includes(extra.get('--allow-review-attempt')),'invalid_arguments');allowedAttempt=Number(extra.get('--allow-review-attempt'));}
|
|
116
|
+
need(!extra.has('--allow-qa')||workflow?.qa!=null,'invalid_arguments');
|
|
117
|
+
const hasFix=extra.has('--qa-fix-owner-config')||extra.has('--qa-fix-template-config');
|
|
118
|
+
need(!(extra.has('--qa-fix-owner-config')&&extra.has('--qa-fix-template-config')),'invalid_fix_config');
|
|
119
|
+
need(!extra.has('--allow-qa-fix-start')||hasFix,'qa_fix_source_required');
|
|
120
|
+
need(!extra.has('--qa-fix-review-config')||hasFix,'qa_fix_source_required');
|
|
121
|
+
need(!extra.has('--auto-qa-fix')||(extra.has('--qa-fix-template-config')&&extra.has('--allow-qa-fix-start')),'qa_fix_auto_authorization_required');
|
|
122
|
+
need(![...fixLocalPermissions.keys()].some(flag=>extra.has(flag))||extra.has('--allow-qa-fix-start'),'qa_fix_start_authorization_required');
|
|
123
|
+
need(!extra.has('--allow-provider-development-attempt')||extra.has('--protected-config'),'protected_configuration_required');
|
|
124
|
+
need(!(extra.has('--protected-config')&&extra.has('--protected-conversation-config')),'invalid_arguments');
|
|
125
|
+
const protection=extra.has('--protected-conversation-config')?readConversationProtection(extra.get('--protected-conversation-config')):null;
|
|
126
|
+
const bootstrap=extra.has('--bootstrap-config')?readBootstrapConfiguration(extra.get('--bootstrap-config')):null;
|
|
127
|
+
need(!extra.has('--allow-bootstrap-write')||bootstrap!==null,'bootstrap_configuration_required');
|
|
128
|
+
const definition=readRunDefinition(argv[2]);bridge=createHostToolBridge();
|
|
129
|
+
const templated=extra.has('--qa-fix-template-config');let fix=null;
|
|
130
|
+
if(hasFix){
|
|
131
|
+
const file=extra.get(templated?'--qa-fix-template-config':'--qa-fix-owner-config'),info=fs.lstatSync(file);
|
|
132
|
+
need(info.isFile()&&!info.isSymbolicLink()&&info.size<=64*1024,'invalid_fix_config');
|
|
133
|
+
fix=json(JSON.parse(fs.readFileSync(file,'utf8')),64*1024);
|
|
134
|
+
if(extra.has('--protected-config')||protection)need(fix.configuration?.protectSpecs===true,'protected_fix_required');
|
|
135
|
+
}
|
|
136
|
+
const execution=extra.has('--protected-config')
|
|
137
|
+
?await protectedExecutionFor(definition,argv[6],extra,review,argv[4],workflow,bridge,bootstrap)
|
|
138
|
+
:executionFor(definition,argv[6],bridge,review,allowedAttempt,workflow,extra.has('--allow-qa'),extra.get('--runtime')??'codex',
|
|
139
|
+
{...(protection?{protection}:{}),...(bootstrap?{bootstrap:{...bootstrap,allowWrite:extra.has('--allow-bootstrap-write')}}:{})});
|
|
140
|
+
run=await openControlRun(definition,argv[4],execution);
|
|
141
|
+
if(run.blocked){output.write(JSON.stringify({outcome:'blocked',admission:run.blocked})+'\n');return 1;}
|
|
142
|
+
if(hasFix){
|
|
143
|
+
need(fs.realpathSync(fix.specsRoot)===fs.realpathSync(definition.specsDir)
|
|
144
|
+
&&fs.realpathSync(fix.configuration.reproduction.cwd)===fs.realpathSync(definition.codeProject)
|
|
145
|
+
&&(templated?fix.feature:fix.configuration.qaSource.feature)===definition.feature,'qa_fix_source_mismatch');
|
|
146
|
+
if(templated)need(digest(fix.identity)===digest(definition.identity),'qa_fix_source_mismatch');
|
|
147
|
+
if(extra.has('--allow-qa-fix-start'))need(fix.configuration.hostContextId===argv[6]
|
|
148
|
+
&&(fix.configuration.runtime??'codex')===(extra.get('--runtime')??'codex'),'qa_fix_host_mismatch');
|
|
149
|
+
const fixPermissions=[...fixLocalPermissions].filter(([flag])=>extra.has(flag)).map(([,permission])=>permission);
|
|
150
|
+
const fixReview=extra.has('--qa-fix-review-config')?reviewConfiguration(extra.get('--qa-fix-review-config')):null;
|
|
151
|
+
need(!fixPermissions.includes('--allow-test-author')||(fix.configuration.testAuthor&&fixReview),'test_author_configuration_required');
|
|
152
|
+
need(!fixPermissions.includes('--allow-repair')||(fix.configuration.repair&&fixReview),'repair_configuration_required');
|
|
153
|
+
const fixReviewHost=createFixReviewHost({codeProject:definition.codeProject,
|
|
154
|
+
hostContextId:fix.configuration.hostContextId,runtime:fix.configuration.runtime??'codex',
|
|
155
|
+
review:fixReview,permissions:fixPermissions});
|
|
156
|
+
if(fixReview)need(digest(fix.configuration.causeReview??null)===digest(fixReviewHost.reviewer),'qa_fix_review_configuration_mismatch');
|
|
157
|
+
const host=createQaFixOwnerHost({parent:run,...(templated?{template:fix}:{fix}),reopenParent:()=>openControlRun(definition,'resume',execution),
|
|
158
|
+
fixPermissions,fixAuthorities:{authority:fixReviewHost.authority,finalAuthority:fixReviewHost.finalAuthority},
|
|
159
|
+
allowStart:extra.has('--allow-qa-fix-start'),autoFix:extra.has('--auto-qa-fix'),fixExecution:{bridge,...fixReviewHost.execution,
|
|
160
|
+
prepare:createFixLearningPreparation({bridge,codeProject:definition.codeProject,
|
|
161
|
+
applicableAgentFiles:fix.configuration.applicableAgentFiles??[]})}});
|
|
162
|
+
run={host,close:host.close};
|
|
163
|
+
}
|
|
164
|
+
// PTY sessions are used by desktop tool hosts. Disable echo only on this
|
|
165
|
+
// process's own terminal so tool results are not mistaken for output frames.
|
|
166
|
+
const rawMode=input.isTTY&&typeof input.setRawMode==='function';if(rawMode)input.setRawMode(true);
|
|
167
|
+
try{await serveCmAiHost({host:run.host,input,output,toolBridge:bridge});}
|
|
168
|
+
finally{if(rawMode)input.setRawMode(false);}
|
|
169
|
+
return 0;
|
|
170
|
+
}catch(cause){
|
|
171
|
+
const code=typeof cause?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(cause.code)?cause.code:'host_launch_failed';
|
|
172
|
+
error.write(JSON.stringify({error:{code}})+'\n');return 1;
|
|
173
|
+
}finally{bridge?.close();run?.close();}
|
|
174
|
+
}
|
|
175
|
+
if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=await main();
|
|
@@ -0,0 +1,368 @@
|
|
|
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 {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
9
|
+
import {createConversationExecution} from './cm-ai-host.mjs';
|
|
10
|
+
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
11
|
+
|
|
12
|
+
const cli=fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url));
|
|
13
|
+
const identity={repositoryId:'host-fixture',runId:'host-fixture-run',taskId:'T-001',attempt:1};
|
|
14
|
+
const request=(operation,requestId=operation)=>({version:1,operation,requestId,identity});
|
|
15
|
+
function fixture(){
|
|
16
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-native-host-')));
|
|
17
|
+
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.work',config=path.join(root,'run.json');
|
|
18
|
+
fs.mkdirSync(codeProject);fs.mkdirSync(path.join(specsDir,feature),{recursive:true});
|
|
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: fixture\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
|
+
fs.writeFileSync(config,JSON.stringify({version:1,specsDir,codeProject,feature,identity,scope:['target.mjs'],requirements:['requirements.md']}));
|
|
24
|
+
return {root,specsDir,codeProject,config,args:['serve','--config',config,'--mode','create','--host-context','native-host-fixture','--allow-development']};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function runCli(f,mode,action='create'){
|
|
28
|
+
return new Promise((resolve,reject)=>{
|
|
29
|
+
const args=[...f.args];args[4]=action;
|
|
30
|
+
const child=spawn(process.execPath,[cli,...args],{stdio:['pipe','pipe','pipe'],env:f.env??process.env});
|
|
31
|
+
let buffer='',stderr='',closed=false,sessionId;const rows=[],calls=[];
|
|
32
|
+
const timer=setTimeout(()=>{child.kill('SIGTERM');reject(new Error('host fixture timed out'));},15000);
|
|
33
|
+
child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
34
|
+
child.once('error',reject);
|
|
35
|
+
const send=value=>child.stdin.write(JSON.stringify(value)+'\n');
|
|
36
|
+
const response=(row,result)=>({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result});
|
|
37
|
+
child.stdout.on('data',chunk=>{
|
|
38
|
+
buffer+=chunk;
|
|
39
|
+
let newline;
|
|
40
|
+
while((newline=buffer.indexOf('\n'))!==-1){
|
|
41
|
+
const line=buffer.slice(0,newline);buffer=buffer.slice(newline+1);
|
|
42
|
+
if(!line)continue;
|
|
43
|
+
try{
|
|
44
|
+
const row=JSON.parse(line);rows.push(row);
|
|
45
|
+
if(row.type==='host_ready')sessionId=row.sessionId;
|
|
46
|
+
if(row.type==='host_request'){
|
|
47
|
+
calls.push(row.kind);
|
|
48
|
+
if(action!=='create')assert((mode==='authorized-review'&&['check','qa_assess','documentation_inspect'].includes(row.kind))
|
|
49
|
+
||(f.workflow&&row.kind==='documentation_inspect'),'resume must not resend development');
|
|
50
|
+
if(mode==='disconnect'){child.stdin.end();continue;}
|
|
51
|
+
if(mode==='cancel'){send(request('status'));send(request('cancel'));continue;}
|
|
52
|
+
if(f.fix&&row.kind==='fix_learning'){
|
|
53
|
+
send(response(row,{contextDigest:row.payload.contextDigest,status:'no_relevant_lesson',summary:'Synthetic no project lessons'}));
|
|
54
|
+
}else if(f.fix&&row.kind==='fix_diagnose'){
|
|
55
|
+
send(response(row,{status:'diagnosed',rootCause:'Wrong exported constant',affectedPaths:['target.mjs','README.md'],
|
|
56
|
+
affectedModules:['value'],plan:'Set value and documentation to 43',crossLayer:false,
|
|
57
|
+
investigation:{discardedAlternatives:[],boundaryAnalysis:null}}));
|
|
58
|
+
}else if(f.fix&&row.kind==='fix_repair'){
|
|
59
|
+
if(f.protected){
|
|
60
|
+
assert.equal(row.payload.editMode,'protected-text-v1');
|
|
61
|
+
send(response(row,{outcome:'repaired',edits:[
|
|
62
|
+
{path:'target.mjs',beforeSha256:row.payload.expected['target.mjs'],content:'export const value = 43;\n'},
|
|
63
|
+
{path:'README.md',beforeSha256:row.payload.expected['README.md'],content:'# Fixture value\n\nExports value = 43.\n'}]}));
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
fs.writeFileSync(path.join(f.codeProject,'target.mjs'),'export const value = 43;\n');
|
|
67
|
+
fs.writeFileSync(path.join(f.codeProject,'README.md'),'# Fixture value\n\nExports value = 43.\n');
|
|
68
|
+
send(response(row,{outcome:'repaired'}));
|
|
69
|
+
}else if(f.fix&&row.kind==='fix_retrospective'){
|
|
70
|
+
send(response(row,{status:'no_new_lesson',candidates:[],reason:null}));
|
|
71
|
+
}else if(row.kind==='develop'){
|
|
72
|
+
assert.equal(row.payload.request.provider,f.runtime??'codex');
|
|
73
|
+
assert.equal(row.payload.route.runtime,f.runtime??'codex');
|
|
74
|
+
assert.equal(row.payload.route.role,'coder');
|
|
75
|
+
assert.equal(row.payload.route.route_state,'current-runtime');
|
|
76
|
+
assert.equal(row.payload.codeProject,f.codeProject);
|
|
77
|
+
assert.deepEqual(row.payload.request.payload.scope,f.workflow?['target.mjs','README.md']:['target.mjs']);
|
|
78
|
+
// Wrong-session self-reported results must not settle the live call.
|
|
79
|
+
send({...response(row,{status:'succeeded',value:{outcome:'implemented'}}),sessionId:'wrong-session'});
|
|
80
|
+
fs.writeFileSync(path.join(f.codeProject,'target.mjs'),'export const value = 42;\n');
|
|
81
|
+
send(response(row,{status:'succeeded',value:{outcome:'implemented',
|
|
82
|
+
application:{status:'no_relevant_lesson',note:null},retrospective:{status:'no_new_lesson',candidates:[],reason:null}}}));
|
|
83
|
+
}else if(row.kind==='documentation_sync'){
|
|
84
|
+
assert(f.workflow);assert.deepEqual(row.payload.paths,['README.md']);
|
|
85
|
+
fs.writeFileSync(path.join(f.codeProject,'README.md'),'# Verified fixture value\n\nExports value = 42.\n');
|
|
86
|
+
send(response(row,{status:'completed'}));
|
|
87
|
+
}else if(row.kind==='qa_assess'){
|
|
88
|
+
assert(f.workflow);assert.equal(row.payload.pending,0);
|
|
89
|
+
send(response(row,{scores:{scope:1,risk:1,accumulation:1,boundary:1},
|
|
90
|
+
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}}));
|
|
91
|
+
}else if(row.kind==='documentation_inspect'){
|
|
92
|
+
assert(f.workflow);assert(fs.readFileSync(path.join(f.codeProject,'README.md'),'utf8').includes(f.fix?'43':'42'));
|
|
93
|
+
const {syncId,identity,packageDigest,contextDigest}=row.payload;
|
|
94
|
+
send(response(row,{syncId,identity,packageDigest,contextDigest,status:'completed',reason:'Actual fixture README checked',
|
|
95
|
+
at:new Date().toISOString().replace(/\.\d{3}Z$/,'Z')}));
|
|
96
|
+
}else{
|
|
97
|
+
assert.equal(row.kind,'check');
|
|
98
|
+
assert.equal(row.payload.route.role,'tester');
|
|
99
|
+
assert.equal(row.payload.route.route_state,'local-tool');
|
|
100
|
+
const command=[process.execPath,'--check',path.join(f.codeProject,'target.mjs')];
|
|
101
|
+
const checked=spawnSync(command[0],command.slice(1),{timeout:3000});assert.equal(checked.status,0);
|
|
102
|
+
send(response(row,[{id:'syntax',command,outcome:'passed',exitCode:0,evidence:'Actual isolated node --check exited 0'}]));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if(row.requestId==='advance'&&row.result&&!closed){
|
|
106
|
+
closed=true;
|
|
107
|
+
if(mode!=='disconnect'||action==='resume')send({type:'host_close',sessionId});
|
|
108
|
+
}
|
|
109
|
+
}catch(error){clearTimeout(timer);child.kill('SIGTERM');reject(error);return;}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
child.once('close',code=>{clearTimeout(timer);resolve({code,stderr,rows,calls});});
|
|
113
|
+
send(request('advance'));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
test('current conversation CLI performs real file/check work and stops at the original unauthorised review gate',async()=>{
|
|
118
|
+
const f=fixture();
|
|
119
|
+
try{
|
|
120
|
+
const denied=spawnSync(process.execPath,[cli,...f.args.slice(0,-1)],{encoding:'utf8',timeout:3000});
|
|
121
|
+
assert.equal(denied.status,1);assert(denied.stderr.includes('host_launch_authorization_required'));
|
|
122
|
+
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
123
|
+
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
124
|
+
assert.deepEqual(first.calls,['develop','check']);
|
|
125
|
+
const roleEvents=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse)
|
|
126
|
+
.filter(row=>row.event==='decision'&&row.phase==='route');
|
|
127
|
+
assert.deepEqual(roleEvents.map(row=>row.role),['coder','tester']);
|
|
128
|
+
assert(roleEvents.every(row=>!Object.hasOwn(row,'effective_model')&&row.task==='T-001'));
|
|
129
|
+
const result=first.rows.find(row=>row.requestId==='advance').result;
|
|
130
|
+
assert.equal(result.state,'awaiting_review');assert.equal(result.code,'decision_required');
|
|
131
|
+
assert(first.rows.some(row=>row.type==='host_response'&&row.accepted===false));
|
|
132
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-001'));
|
|
133
|
+
const handoff=JSON.parse(fs.readFileSync(path.join(f.specsDir,'.reviews','work-T-001-a1-handoff.json'),'utf8'));
|
|
134
|
+
assert.equal(handoff.status,'ready_for_review');assert(handoff.changed_files.includes('target.mjs'));
|
|
135
|
+
const second=await runCli(f,'normal','resume');assert.equal(second.code,0,second.stderr);
|
|
136
|
+
assert.deepEqual(second.calls,[]);assert.equal(second.rows.find(row=>row.requestId==='advance').result.code,'decision_required');
|
|
137
|
+
const resumedRoles=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse)
|
|
138
|
+
.filter(row=>row.event==='decision'&&row.phase==='route');
|
|
139
|
+
assert.deepEqual(resumedRoles,roleEvents);
|
|
140
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('invalid role configuration blocks CLI before any current-conversation tool request',async()=>{
|
|
144
|
+
const f=fixture();
|
|
145
|
+
try{
|
|
146
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.json'),'{invalid-config');
|
|
147
|
+
const result=await runCli(f,'normal');
|
|
148
|
+
assert.deepEqual(result.calls,[]);
|
|
149
|
+
assert(!fs.existsSync(path.join(f.codeProject,'target.mjs')));
|
|
150
|
+
assert(!fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[x]'));
|
|
151
|
+
const logs=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8');
|
|
152
|
+
assert(logs.includes('invalid_workflow_config'));assert(!logs.includes('invalid-config'));
|
|
153
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
for(const mode of ['disconnect','cancel'])test(`current conversation ${mode} preserves the original recovery boundary`,async()=>{
|
|
157
|
+
const f=fixture();
|
|
158
|
+
try{
|
|
159
|
+
const first=await runCli(f,mode);assert.equal(first.code,0,first.stderr);
|
|
160
|
+
assert.deepEqual(first.calls,['develop']);
|
|
161
|
+
const expected=mode==='disconnect'?'unknown':'cancelled';
|
|
162
|
+
assert.equal(first.rows.find(row=>row.requestId==='advance').result.state,expected);
|
|
163
|
+
if(mode==='cancel')assert(first.rows.some(row=>row.requestId==='status'));
|
|
164
|
+
const resumed=await runCli(f,mode,'resume');assert.equal(resumed.code,0,resumed.stderr);assert.deepEqual(resumed.calls,[]);
|
|
165
|
+
assert.equal(resumed.rows.find(row=>row.requestId==='advance').result.state,expected);
|
|
166
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
for(const mode of ['normal','disconnect','cancel'])test(`Claude conversation uses original runner development and recovery: ${mode}`,async()=>{
|
|
170
|
+
const f=fixture();f.runtime='claude';f.args.push('--runtime','claude');
|
|
171
|
+
try{
|
|
172
|
+
const first=await runCli(f,mode);assert.equal(first.code,0,first.stderr);
|
|
173
|
+
const state=mode==='normal'?'awaiting_review':mode==='disconnect'?'unknown':'cancelled';
|
|
174
|
+
assert.equal(first.rows.find(row=>row.requestId==='advance').result.state,state);
|
|
175
|
+
assert.deepEqual(first.calls,mode==='normal'?['develop','check']:['develop']);
|
|
176
|
+
const logs=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
177
|
+
assert(logs.filter(row=>row.phase==='route').every(row=>row.runtime==='claude'));
|
|
178
|
+
const reopened=await runCli(f,mode,'resume');assert.equal(reopened.code,0,reopened.stderr);
|
|
179
|
+
assert.deepEqual(reopened.calls,[]);
|
|
180
|
+
assert.equal(reopened.rows.find(row=>row.requestId==='advance').result.state,state);
|
|
181
|
+
f.args=f.args.slice(0,-2);
|
|
182
|
+
const wrongRuntime=await runCli(f,mode,'resume');
|
|
183
|
+
assert.equal(wrongRuntime.code,1);assert.deepEqual(wrongRuntime.calls,[]);
|
|
184
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-001'));
|
|
185
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('Claude Review option rejects before store instead of borrowing the Codex reviewer',()=>{
|
|
189
|
+
const f=fixture();
|
|
190
|
+
try{
|
|
191
|
+
const result=spawnSync(process.execPath,[cli,...f.args,'--runtime','claude','--allow-review-attempt','1'],{encoding:'utf8',timeout:3000});
|
|
192
|
+
assert.equal(result.status,1);assert(result.stderr.includes('review_configuration_required'));
|
|
193
|
+
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
194
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
195
|
+
});
|
|
196
|
+
test('unconfigured Claude preserves P4a persisted reviewer metadata and denies direct dispatch',()=>{
|
|
197
|
+
const f=fixture(),bridge=createHostToolBridge();
|
|
198
|
+
try {
|
|
199
|
+
const execution=createConversationExecution(JSON.parse(fs.readFileSync(f.config,'utf8')),
|
|
200
|
+
'native-host-fixture',bridge,null,null,null,false,'claude');
|
|
201
|
+
const {run,...persisted}=execution.reviewers[0];
|
|
202
|
+
assert.deepEqual(persisted,{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',
|
|
203
|
+
requestedModel:'unconfigured',allowed:true,available:true,
|
|
204
|
+
contexts:['cm-conversation-review-1','cm-conversation-review-2']});
|
|
205
|
+
assert.throws(()=>run({},{}),{code:'review_configuration_required'});
|
|
206
|
+
} finally {bridge.close();fs.rmSync(f.root,{recursive:true,force:true});}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test('bridge cancellation before publication cannot dispatch a late host request',async()=>{
|
|
210
|
+
const bridge=createHostToolBridge(),controller=new AbortController(),sent=[];
|
|
211
|
+
bridge.attach(value=>{sent.push(value);});
|
|
212
|
+
const pending=bridge.call('develop',{fixture:true},controller.signal);controller.abort();
|
|
213
|
+
await assert.rejects(pending,{code:'cancelled'});await Promise.resolve();
|
|
214
|
+
assert(!sent.some(row=>row.type==='host_request'));bridge.close();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
for(const variant of ['codex','claude','protected'])test(`automatic fix ${variant} CLI starts before QA and finishes through original transport`,async()=>{
|
|
218
|
+
const runtime=variant==='protected'?'codex':variant;
|
|
219
|
+
const f=fixture();f.workflow=true;f.fix=true;f.runtime=runtime;
|
|
220
|
+
try{
|
|
221
|
+
f.protected=variant==='protected';
|
|
222
|
+
const definition=JSON.parse(fs.readFileSync(f.config,'utf8'));definition.scope.push('README.md');
|
|
223
|
+
if(f.protected){const nested=path.join(f.codeProject,'specs');fs.renameSync(f.specsDir,nested);f.specsDir=nested;definition.specsDir=nested;}
|
|
224
|
+
fs.writeFileSync(f.config,JSON.stringify(definition));
|
|
225
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.json'),JSON.stringify({version:1,policies:{auto_fix:'auto',delivery:'diff'}}));
|
|
226
|
+
fs.writeFileSync(path.join(f.codeProject,'red.mjs'),"import {value} from './target.mjs';if(value!==43){console.error('BUG');process.exit(1)}");
|
|
227
|
+
fs.writeFileSync(path.join(f.codeProject,'baseline.mjs'),"import {value} from './target.mjs';if(typeof value!=='number')process.exit(1)");
|
|
228
|
+
const bin=path.join(f.root,'bin');fs.mkdirSync(bin);
|
|
229
|
+
const fake=path.join(bin,runtime);fs.copyFileSync(fileURLToPath(new URL(`./fixtures/${runtime}-review-process.mjs`,import.meta.url)),fake);fs.chmodSync(fake,0o700);
|
|
230
|
+
if(f.protected){
|
|
231
|
+
const located=spawnSync('/usr/bin/which',['codex'],{encoding:'utf8'});assert.equal(located.status,0);
|
|
232
|
+
const real=located.stdout.trim(),reviewFixture=fileURLToPath(new URL('./fixtures/codex-review-process.mjs',import.meta.url));
|
|
233
|
+
fs.writeFileSync(fake,String.raw`#!${process.execPath}
|
|
234
|
+
const fs=require('node:fs'),cp=require('node:child_process'),a=require('node:assert/strict');
|
|
235
|
+
const args=process.argv.slice(2),real=${JSON.stringify(real)};
|
|
236
|
+
if(args[0]==='sandbox'){const r=cp.spawnSync(real,args,{stdio:'inherit'});process.exit(r.status??1);}
|
|
237
|
+
let input='';process.stdin.on('data',s=>input+=s);process.stdin.on('end',()=>{
|
|
238
|
+
if(!input.includes('<cm-developer-data-json>')){
|
|
239
|
+
const r=cp.spawnSync(process.execPath,[${JSON.stringify(reviewFixture)},...args],{input,encoding:'utf8'});
|
|
240
|
+
process.stdout.write(r.stdout??'');process.stderr.write(r.stderr??'');process.exit(r.status??1);
|
|
241
|
+
}
|
|
242
|
+
const profile=[];for(let i=0;i<args.length;i++)if(args[i]==='-c'&&/^(default_permissions=|permissions.cm-specs=)/.test(args[i+1]))profile.push(args[i],args[i+1]);
|
|
243
|
+
a.equal(profile.length,4);
|
|
244
|
+
const code="const fs=require('node:fs');fs.writeFileSync('target.mjs','export const value = 42;\\n');fs.writeFileSync('README.md','# Before fix\\n');";
|
|
245
|
+
const r=cp.spawnSync(real,['sandbox','-P','cm-specs','--include-managed-config','-C',process.cwd(),...profile,'--',process.execPath,'-e',code],{encoding:'utf8'});
|
|
246
|
+
if(r.status!==0){process.stderr.write(r.stderr??'');process.exit(1);}
|
|
247
|
+
for(const row of [{type:'thread.started',thread_id:'synthetic-protected-developer'},{type:'turn.started'},
|
|
248
|
+
{type:'item.completed',item:{type:'agent_message',text:JSON.stringify({outcome:'implemented',application:{status:'no_relevant_lesson',note:null},retrospective:{status:'no_new_lesson',candidates:[],reason:null}})}},{type:'turn.completed'}])process.stdout.write(JSON.stringify(row)+'\n');
|
|
249
|
+
});
|
|
250
|
+
`,{mode:0o700});
|
|
251
|
+
// Every original fix command also asserts actual native specs/instruction protection.
|
|
252
|
+
const assertion="import fs from 'node:fs';import a from 'node:assert/strict';"
|
|
253
|
+
+"for(const file of ['specs/1.work/tasks.md','AGENTS.md'])a.throws(()=>fs.writeFileSync(file,'forged'),e=>['EPERM','EACCES'].includes(e.code));\n";
|
|
254
|
+
for(const name of ['red.mjs','baseline.mjs'])fs.writeFileSync(path.join(f.codeProject,name),assertion+fs.readFileSync(path.join(f.codeProject,name),'utf8'));
|
|
255
|
+
}
|
|
256
|
+
f.env={...process.env,PATH:bin+path.delimiter+process.env.PATH,CM_WORKFLOW_LOG_HOME:path.join(f.root,'private-logs')};
|
|
257
|
+
const preview=spawnSync(process.execPath,[cli,'preflight','--config',f.config,'--review-model','fixture','--runtime',runtime],
|
|
258
|
+
{encoding:'utf8',env:f.env,timeout:5000});
|
|
259
|
+
assert.equal(preview.status,0,preview.stderr);
|
|
260
|
+
const review=JSON.parse(preview.stdout),reviewFile=path.join(f.root,'review.json');
|
|
261
|
+
fs.writeFileSync(reviewFile,JSON.stringify(review));
|
|
262
|
+
const command=[process.execPath,'red.mjs'];
|
|
263
|
+
const workflowFile=path.join(f.root,'workflow.json');
|
|
264
|
+
fs.writeFileSync(workflowFile,JSON.stringify({documentationPaths:['README.md'],applicableAgentFiles:[],
|
|
265
|
+
qa:{commands:[{id:'value-check',command,caseIds:[]}],environment:{kind:'web',carrier:'browser',target:'http://127.0.0.1',scope:'local'}}}));
|
|
266
|
+
const permissions=['red-test','baseline','repair','regression','final-review','walkthrough','finish'];
|
|
267
|
+
const reviewHost=createFixReviewHost({codeProject:f.codeProject,hostContextId:'native-host-fixture',runtime,review,
|
|
268
|
+
permissions:permissions.map(name=>`--allow-${name}`)});
|
|
269
|
+
const configuration={hostContextId:'native-host-fixture',...(runtime==='claude'?{runtime}:{}),defect:'Exported value must be 43',
|
|
270
|
+
...(f.protected?{protectSpecs:true}:{}),
|
|
271
|
+
causeReview:reviewHost.reviewer,reproduction:{cwd:f.codeProject,command,expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
272
|
+
redTest:{cwd:f.codeProject,testFiles:['red.mjs'],command,expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
273
|
+
baseline:{cwd:f.codeProject,testFiles:['baseline.mjs'],commands:[{id:'baseline',command:[process.execPath,'baseline.mjs']}],timeoutMs:2000},
|
|
274
|
+
repair:{scope:['target.mjs','README.md'],requirements:['requirements.md']},
|
|
275
|
+
walkthrough:{timeoutMs:2000,flows:[{id:'value',modules:['value'],steps:['Read exported value'],expected:['43'],kind:'commands',command}]}};
|
|
276
|
+
const template=path.join(f.root,'template.json');fs.writeFileSync(template,JSON.stringify({specsRoot:f.specsDir,feature:'1.work',identity,configuration}));
|
|
277
|
+
f.args.push('--runtime',runtime,'--review-config',reviewFile,'--allow-review-attempt','1','--workflow-config',workflowFile,'--allow-qa',
|
|
278
|
+
'--qa-fix-template-config',template,'--qa-fix-review-config',reviewFile,'--allow-qa-fix-start','--auto-qa-fix',
|
|
279
|
+
...permissions.map(name=>`--allow-qa-fix-${name}`));
|
|
280
|
+
if(f.protected){
|
|
281
|
+
const protectedFile=path.join(f.root,'protected.json');
|
|
282
|
+
fs.writeFileSync(protectedFile,JSON.stringify({model:'fixture',timeoutMs:5000,checkCommands:[{id:'syntax',command:[process.execPath,'--check','target.mjs']}]}));
|
|
283
|
+
f.args.push('--protected-config',protectedFile,'--allow-provider-development-attempt','1');
|
|
284
|
+
fs.writeFileSync(template,JSON.stringify({specsRoot:f.specsDir,feature:'1.work',identity,configuration:{...configuration,protectSpecs:false}}));
|
|
285
|
+
const denied=await runCli(f,'normal');assert.equal(denied.code,1);assert(denied.stderr.includes('protected_fix_required'));
|
|
286
|
+
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));fs.writeFileSync(template,JSON.stringify({specsRoot:f.specsDir,feature:'1.work',identity,configuration}));
|
|
287
|
+
}
|
|
288
|
+
assert.equal(fs.existsSync(path.join(f.specsDir,'运行日志.jsonl')),false);
|
|
289
|
+
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
290
|
+
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,'run_done',JSON.stringify(first.rows.at(-1)));
|
|
291
|
+
for(const kind of [...(f.protected?[]:['develop']),'fix_diagnose','fix_repair','fix_retrospective'])assert.equal(first.calls.filter(item=>item===kind).length,1,kind);
|
|
292
|
+
if(f.protected)assert(!first.calls.some(kind=>['develop','check','documentation_sync'].includes(kind)));
|
|
293
|
+
assert(first.calls.includes('fix_learning')); // Original owner refreshes Learning before multiple stages.
|
|
294
|
+
const resumed=await runCli(f,'normal','resume');assert.equal(resumed.code,0,resumed.stderr);
|
|
295
|
+
assert.equal(resumed.rows.find(row=>row.requestId==='advance').result.code,'run_done');
|
|
296
|
+
assert.deepEqual(resumed.calls,['documentation_inspect']);
|
|
297
|
+
const rows=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
298
|
+
assert.equal(rows.filter(row=>row.workflow==='cm-ai'&&row.event==='test_run'&&row.phase==='start').length,2);
|
|
299
|
+
assert.equal(rows.filter(row=>row.workflow==='cm-ai'&&row.event==='run_done').length,1);
|
|
300
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[x] T-001'));
|
|
301
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
for(const runtime of ['codex','claude'])for(const workflow of [false,true])test(`configured ${runtime} CLI waits for the authorized attempt and resumes via the original review worker/gate workflow=${workflow}`,async()=>{
|
|
305
|
+
const f=fixture();
|
|
306
|
+
try{
|
|
307
|
+
f.workflow=workflow;
|
|
308
|
+
if(runtime==='claude'){f.runtime=runtime;f.args.push('--runtime',runtime);}
|
|
309
|
+
if(workflow){
|
|
310
|
+
const definition=JSON.parse(fs.readFileSync(f.config,'utf8'));definition.scope.push('README.md');
|
|
311
|
+
fs.writeFileSync(f.config,JSON.stringify(definition));
|
|
312
|
+
}
|
|
313
|
+
const bin=path.join(f.root,'bin');fs.mkdirSync(bin);
|
|
314
|
+
const fake=path.join(bin,runtime);fs.copyFileSync(fileURLToPath(new URL(`./fixtures/${runtime}-review-process.mjs`,import.meta.url)),fake);
|
|
315
|
+
fs.chmodSync(fake,0o700);f.env={...process.env,PATH:bin+path.delimiter+process.env.PATH};
|
|
316
|
+
// Actual separate CLI and loopback diagnostic process; the executable is synthetic.
|
|
317
|
+
let review;
|
|
318
|
+
const preview=spawnSync(process.execPath,[cli,'preflight','--config',f.config,'--review-model','fixture',
|
|
319
|
+
...(runtime==='claude'?['--runtime','claude']:[])],
|
|
320
|
+
{encoding:'utf8',env:f.env,timeout:5000});
|
|
321
|
+
assert.equal(preview.status,0,preview.stderr);
|
|
322
|
+
review=JSON.parse(preview.stdout);assert.equal(review.preflight.passed,true);
|
|
323
|
+
if(runtime==='codex')assert.equal(review.preflight.real_model_requests,0);
|
|
324
|
+
else assert.equal(review.preflight.isolation,'macos-loopback-sandbox');
|
|
325
|
+
assert.equal(review.preflight.listener_closed,true);
|
|
326
|
+
const config=path.join(f.root,'review.json');fs.writeFileSync(config,JSON.stringify(review));
|
|
327
|
+
f.args.push('--review-config',config);
|
|
328
|
+
if(runtime==='claude'){
|
|
329
|
+
fs.writeFileSync(config,JSON.stringify({...review,preflight:{...review.preflight,provider:'codex'}}));
|
|
330
|
+
const denied=spawnSync(process.execPath,[cli,...f.args,'--allow-review-attempt','1'],{encoding:'utf8',env:f.env,timeout:3000});
|
|
331
|
+
assert.equal(denied.status,1);assert(denied.stderr.includes('tool_preflight_missing'));
|
|
332
|
+
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
333
|
+
fs.writeFileSync(config,JSON.stringify(review));
|
|
334
|
+
}
|
|
335
|
+
if(workflow){
|
|
336
|
+
const workflowFile=path.join(f.root,'workflow.json');
|
|
337
|
+
fs.writeFileSync(workflowFile,JSON.stringify({documentationPaths:['README.md'],applicableAgentFiles:[],
|
|
338
|
+
qa:{commands:[{id:'value-check',command:[process.execPath,'-e',"import('./target.mjs').then(m=>{if(m.value!==42)process.exit(1)})"],caseIds:[]}],
|
|
339
|
+
environment:{kind:'web',carrier:'browser',target:'http://127.0.0.1',scope:'local'}}}));
|
|
340
|
+
f.args.push('--workflow-config',workflowFile);
|
|
341
|
+
const denied=spawnSync(process.execPath,[cli,...f.args],{encoding:'utf8',env:f.env,timeout:5000});
|
|
342
|
+
assert.equal(denied.status,1);assert(denied.stderr.includes('qa_authorization_required'));
|
|
343
|
+
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
344
|
+
f.args.push('--allow-qa');
|
|
345
|
+
}
|
|
346
|
+
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
347
|
+
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,'decision_required');
|
|
348
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-001'));
|
|
349
|
+
// An approved different round cannot authorize this pending round.
|
|
350
|
+
f.args.push('--allow-review-attempt','2');
|
|
351
|
+
const wrong=await runCli(f,'normal','resume');assert.equal(wrong.code,0,wrong.stderr);
|
|
352
|
+
assert.deepEqual(wrong.calls,[]);assert.equal(wrong.rows.find(row=>row.requestId==='advance').result.code,'decision_required');
|
|
353
|
+
f.args[f.args.length-1]='1';
|
|
354
|
+
const completed=await runCli(f,'authorized-review','resume');assert.equal(completed.code,0,completed.stderr);
|
|
355
|
+
assert.deepEqual(completed.calls,workflow?['check','qa_assess','documentation_inspect']:['check']);
|
|
356
|
+
const result=completed.rows.find(row=>row.requestId==='advance').result;
|
|
357
|
+
assert.equal(result.state,workflow?'run_done':'fixture_completed');assert.equal(result.code,workflow?'run_done':'qa_decision_required');
|
|
358
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[x] T-001'));
|
|
359
|
+
const reopened=await runCli(f,'normal','resume');assert.equal(reopened.code,0,reopened.stderr);
|
|
360
|
+
assert.deepEqual(reopened.calls,workflow?['documentation_inspect']:[]);
|
|
361
|
+
assert.equal(reopened.rows.find(row=>row.requestId==='advance').result.code,workflow?'run_done':'qa_decision_required');
|
|
362
|
+
if(workflow){
|
|
363
|
+
const rows=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
364
|
+
assert.equal(rows.filter(row=>row.event==='run_done').length,1);
|
|
365
|
+
assert.equal(rows.filter(row=>row.event==='test_run'&&row.phase==='start').length,1);
|
|
366
|
+
}
|
|
367
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
368
|
+
});
|