@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,131 @@
|
|
|
1
|
+
// Serial child host. Existing owners retain lifecycle and action authority.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {openFixExecution} from '../cm-fix/execution.mjs';
|
|
5
|
+
import {createFixHost} from '../cm-fix/host.mjs';
|
|
6
|
+
import {bindQaFixDefinition} from './qa-fix-definition.mjs';
|
|
7
|
+
import {digest,id,json,need,shape,validIdentity,hex} from './effect-contract.mjs';
|
|
8
|
+
|
|
9
|
+
export function createQaFixOwnerHost({parent,reopenParent,fix=null,template=null,allowStart=false,autoFix=false,fixExecution={},fixPermissions=[],fixAuthorities={}}){
|
|
10
|
+
need((fix===null)!==(template===null),'invalid_fix_config');
|
|
11
|
+
let definition=null;
|
|
12
|
+
const fixedTemplate=template===null?null:json(template,64*1024);
|
|
13
|
+
if(fixedTemplate){
|
|
14
|
+
shape(fixedTemplate,['specsRoot','feature','identity','configuration']);validIdentity(fixedTemplate.identity);
|
|
15
|
+
need(!Object.hasOwn(fixedTemplate.configuration,'qaSource'),'invalid_fix_template');
|
|
16
|
+
}else{
|
|
17
|
+
shape(fix,['specsRoot','identity','configuration']);definition=json(fix,64*1024);
|
|
18
|
+
validIdentity(definition.identity);need(definition.configuration.qaSource,'qa_fix_source_required');
|
|
19
|
+
}
|
|
20
|
+
need(typeof allowStart==='boolean','invalid_input');
|
|
21
|
+
need(typeof autoFix==='boolean'&&(!autoFix||(allowStart&&fixedTemplate!==null)),'qa_fix_auto_authorization_required');
|
|
22
|
+
need(typeof reopenParent==='function','invalid_input');
|
|
23
|
+
const permissions=json(fixPermissions);need(Array.isArray(permissions)&&permissions.every(value=>typeof value==='string'),'invalid_input');
|
|
24
|
+
shape(fixAuthorities,['authority','finalAuthority'].filter(key=>Object.hasOwn(fixAuthorities,key)));
|
|
25
|
+
let current=parent,busy=false,switching=false,closed=false,activeChild=null;
|
|
26
|
+
const dispatch={
|
|
27
|
+
async handle(request){
|
|
28
|
+
need(!closed,'host_unavailable');
|
|
29
|
+
if(busy){
|
|
30
|
+
if(activeChild&&['status','cancel'].includes(request.operation)){
|
|
31
|
+
const control=json(request);shape(control,['version','requestId','operation','identity']);
|
|
32
|
+
need(control.version===1,'invalid_input');id(control.requestId);validIdentity(control.identity);
|
|
33
|
+
need(digest(control.identity)===digest(definition.configuration.qaSource.identity),'qa_fix_source_mismatch');
|
|
34
|
+
return {outcome:'reported',code:'qa_fix_active',fix:control.operation==='cancel'?activeChild.cancel():activeChild.status()};
|
|
35
|
+
}
|
|
36
|
+
if(['status','cancel'].includes(request.operation))return switching
|
|
37
|
+
?{outcome:'blocked',code:'qa_fix_owner_busy'}:current.host.handle(request);
|
|
38
|
+
need(false,'host_busy');
|
|
39
|
+
}
|
|
40
|
+
need(current!==null,'host_unavailable');
|
|
41
|
+
if(!['fix_status','fix_advance','fix_action','fix_run'].includes(request.operation)){
|
|
42
|
+
busy=true;try{return await current.host.handle(request);}finally{busy=false;}
|
|
43
|
+
}
|
|
44
|
+
const value=json(request);shape(value,['version','requestId','operation','identity','packageDigest','testRunId',
|
|
45
|
+
...(request.operation==='fix_action'?['fixOperation']:[])]);
|
|
46
|
+
need(value.version===1,'invalid_input');id(value.requestId);validIdentity(value.identity);hex(value.packageDigest);id(value.testRunId);
|
|
47
|
+
if(fixedTemplate)definition=bindQaFixDefinition({template:fixedTemplate,identity:value.identity,
|
|
48
|
+
packageDigest:value.packageDigest,testRunId:value.testRunId});
|
|
49
|
+
const source=definition.configuration.qaSource;
|
|
50
|
+
need(digest(source.identity)===digest(value.identity)&&source.packageDigest===value.packageDigest
|
|
51
|
+
&&source.testRunId===value.testRunId,'qa_fix_source_mismatch');
|
|
52
|
+
const running=value.operation==='fix_run';
|
|
53
|
+
const advancing=value.operation==='fix_advance'||running;
|
|
54
|
+
const acting=value.operation==='fix_action';
|
|
55
|
+
if(acting)need(['red_test','baseline','author_tests','repair','regression','retrospective','learning_writeback',
|
|
56
|
+
'handoff','final_review_package','final_review','publish_review','check_n5','post_review_regression',
|
|
57
|
+
'publish_dossier','walkthrough','finish','prepare_revision','cause_review_package','cause_review'].includes(value.fixOperation),'fix_operation_unavailable');
|
|
58
|
+
need(!(advancing||acting)||allowStart,'qa_fix_start_authorization_required');
|
|
59
|
+
busy=true;let child=null,released=false,result;
|
|
60
|
+
try{
|
|
61
|
+
const status=await current.host.handle({version:1,operation:'status',requestId:value.requestId,identity:value.identity});
|
|
62
|
+
need(status.state==='fixture_completed'&&status.packageDigest===value.packageDigest
|
|
63
|
+
&&digest(status.identity)===digest(value.identity),'qa_fix_parent_not_completed');
|
|
64
|
+
switching=true;current.close();current=null;released=true;
|
|
65
|
+
const existing=fs.existsSync(path.join(definition.specsRoot,'.reviews','.execution',definition.identity.runId));
|
|
66
|
+
child=openFixExecution({...definition,create:advancing&&!existing},advancing||acting?fixExecution:{});
|
|
67
|
+
activeChild=child;
|
|
68
|
+
let actionResult;
|
|
69
|
+
if(advancing||acting){
|
|
70
|
+
const host=createFixHost({owner:child,config:{...definition.configuration,specsRoot:definition.specsRoot,identity:definition.identity},
|
|
71
|
+
runtime:definition.configuration.runtime??'codex',permissions:[...permissions,'--allow-reproduction'],...fixAuthorities});
|
|
72
|
+
actionResult=running?await host.run(value.requestId)
|
|
73
|
+
:await host.handle({requestId:value.requestId,operation:advancing?'advance':value.fixOperation});
|
|
74
|
+
}
|
|
75
|
+
// Original observing finish intentionally closes its owner. Preserve
|
|
76
|
+
// that successful incomplete exit without reading a closed store.
|
|
77
|
+
if(acting&&value.fixOperation==='finish'&&actionResult?.observationRunEnded===true)
|
|
78
|
+
return json({outcome:'blocked',code:'qa_fix_incomplete',fixStage:actionResult.stage,actionResult},12*1024*1024);
|
|
79
|
+
const observed=child.status();
|
|
80
|
+
result=observed.stage==='completed'&&observed.completionEligible===true
|
|
81
|
+
?json({outcome:'verified',code:'qa_fix_completed',evidence:child.completionEvidence()},12*1024*1024)
|
|
82
|
+
:json({outcome:'blocked',code:'qa_fix_incomplete',fixStage:observed.stage,
|
|
83
|
+
...(acting?{actionResult}: {})},12*1024*1024);
|
|
84
|
+
}finally{
|
|
85
|
+
try{activeChild=null;child?.close();if(released)current=await reopenParent();}
|
|
86
|
+
finally{busy=false;switching=false;}
|
|
87
|
+
}
|
|
88
|
+
// Evidence came from the original child owner, not from a caller receipt.
|
|
89
|
+
// Read-only comparison alone does not clear a gate; accepting the original
|
|
90
|
+
// completion evidence uses the existing parent journal contract.
|
|
91
|
+
if(result.code==='qa_fix_completed'&&typeof current.inspectFixAssociation==='function'){
|
|
92
|
+
try{
|
|
93
|
+
const association=current.inspectFixAssociation(result.evidence.reviewPackage);
|
|
94
|
+
const accepted=(running||(acting&&value.fixOperation==='finish'))&&typeof current.acceptCompletedFix==='function'
|
|
95
|
+
?current.acceptCompletedFix(result.evidence):null;
|
|
96
|
+
return json({...result,association,...(accepted?{accepted}: {})},12*1024*1024);
|
|
97
|
+
}
|
|
98
|
+
catch(error){return json({...result,outcome:'blocked',code:'qa_fix_code_unmatched',
|
|
99
|
+
reason:error.code??error.message},12*1024*1024);}
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
},
|
|
103
|
+
close(){need(!busy,'host_busy');if(!closed){closed=true;current?.close();current=null;}},
|
|
104
|
+
};
|
|
105
|
+
let advancing=false,cancellationEpoch=0;
|
|
106
|
+
return Object.freeze({
|
|
107
|
+
async handle(request){
|
|
108
|
+
if(advancing){
|
|
109
|
+
need(['status','cancel'].includes(request.operation),'host_busy');
|
|
110
|
+
const result=await dispatch.handle(request);
|
|
111
|
+
if(request.operation==='cancel'&&(result.outcome==='cancelled'||result.code==='qa_fix_active'))cancellationEpoch++;
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
if(!autoFix||request.operation!=='advance')return dispatch.handle(request);
|
|
115
|
+
request=json(request);
|
|
116
|
+
advancing=true;const epoch=cancellationEpoch;
|
|
117
|
+
try{
|
|
118
|
+
for(let round=0;round<3;round++){
|
|
119
|
+
const result=await dispatch.handle(request);
|
|
120
|
+
if(result.code!=='qa_failed'||result.fixHandoff?.status!=='dispatch_required'||epoch!==cancellationEpoch)return result;
|
|
121
|
+
need(round<2,'qa_round_invalid');
|
|
122
|
+
const repaired=await dispatch.handle({version:1,requestId:request.requestId,operation:'fix_run',
|
|
123
|
+
identity:result.identity,packageDigest:result.packageDigest,testRunId:result.fixHandoff.source.testRunId});
|
|
124
|
+
if(repaired.code!=='qa_fix_completed'||!repaired.accepted||epoch!==cancellationEpoch)return repaired;
|
|
125
|
+
}
|
|
126
|
+
need(false,'qa_round_invalid');
|
|
127
|
+
}finally{advancing=false;}
|
|
128
|
+
},
|
|
129
|
+
close(){need(!advancing,'host_busy');dispatch.close();},
|
|
130
|
+
});
|
|
131
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Read-only handoff to the separate cm-fix lifecycle. Never a dispatch grant.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {loadConfig} from '../../../scripts/cm-workflow-config.mjs';
|
|
4
|
+
import {inspectCmAiQaFailure,readCmAiQaFailureHistory} from './cm-ai-qa-log.mjs';
|
|
5
|
+
import {readReviewSourceFiles} from './review-package.mjs';
|
|
6
|
+
import {digest,freeze,need,shape} from './effect-contract.mjs';
|
|
7
|
+
|
|
8
|
+
export function readHostQaFixHandoff(input){
|
|
9
|
+
return readHandoff(input,inspectCmAiQaFailure);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function readHostQaFixHistory(input){
|
|
13
|
+
return readHandoff(input,readCmAiQaFailureHistory);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function readHandoff(input,inspectFailure){
|
|
17
|
+
shape(input,['specsDir','codeProject','feature','identity','packageDigest','testRunId']);
|
|
18
|
+
const {codeProject,...binding}=input;
|
|
19
|
+
const failure=inspectFailure(binding);
|
|
20
|
+
const config=loadConfig({projectRoot:codeProject}),policy=config.policies.auto_fix;
|
|
21
|
+
need(['never','explicit','auto'].includes(policy),'qa_fix_policy_unavailable');
|
|
22
|
+
const relative=path.relative(input.specsDir,failure.report).split(path.sep).join('/');
|
|
23
|
+
const [{contentBase64,...reportEvidence}]=readReviewSourceFiles(input.specsDir,[relative]);
|
|
24
|
+
const exhausted=failure.qaRound>=3;
|
|
25
|
+
const value={version:1,kind:'cm-qa-fix-handoff',policy,policyDigest:digest(config),
|
|
26
|
+
status:exhausted||policy==='never'?'blocked':policy==='explicit'?'authorization_required':'dispatch_required',
|
|
27
|
+
reason:exhausted?'qa_round_limit':policy==='never'?'auto_fix_disabled':policy==='explicit'?'fix_authorization_required':'fix_dispatch_required',
|
|
28
|
+
source:{...failure,reportEvidence},execution:'not_started'};
|
|
29
|
+
return freeze({...value,handoffDigest:digest(value)});
|
|
30
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// N6 policy over host semantic assessment; no provider, QA execution or new state.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {inspectCmAiQaTaskContext} from './cm-ai-admission.mjs';
|
|
5
|
+
import {scanRows,readDecision} from './cm-ai-qa-log.mjs';
|
|
6
|
+
import {digest,freeze,hex,json,need,shape,validIdentity} from './effect-contract.mjs';
|
|
7
|
+
|
|
8
|
+
const key=(feature,task)=>`${feature}/${task}`;
|
|
9
|
+
|
|
10
|
+
function history(binding,context) {
|
|
11
|
+
const completed=new Set(context.completed.map(task=>key(task.feature,task.id)));
|
|
12
|
+
const unseen=new Set(completed),since=new Set();
|
|
13
|
+
const log=path.join(binding.specsDir,'运行日志.jsonl');
|
|
14
|
+
if(fs.existsSync(log))scanRows(log,row=>{
|
|
15
|
+
if(row?.schema_version!==1||row.workflow!=='cm-ai'||row.event!=='qa'||row.node!=='N6'
|
|
16
|
+
||row.repository_id!==binding.identity.repositoryId||!completed.has(key(row.feature,row.task)))return;
|
|
17
|
+
const identity={repositoryId:row.repository_id,runId:row.run_id,taskId:row.task,attempt:row.attempt};
|
|
18
|
+
readDecision({decisionId:row.decision_id,identity,packageDigest:row.package_digest,status:row.status,
|
|
19
|
+
reason:row.reason,score:row.score,at:row.at},identity,row.package_digest);
|
|
20
|
+
const task=key(row.feature,row.task);unseen.delete(task);
|
|
21
|
+
if(row.status==='triggered')since.clear();else since.add(task);
|
|
22
|
+
});
|
|
23
|
+
// Missing historical QA rows are unknown coverage, never evidence of a reset.
|
|
24
|
+
// This callback only proposes a fresh decision. An older run/package for the
|
|
25
|
+
// same task cannot cover the current work; exact recovery happens in entry.
|
|
26
|
+
return new Set([...unseen,...since,key(binding.feature,binding.identity.taskId)]).size;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function decideHostQaPolicy({assessment,pending,mergeEligible,unassessedTasks}) {
|
|
30
|
+
const value=json(assessment);shape(value,['scores','changes']);
|
|
31
|
+
shape(value.scores,['scope','risk','accumulation','boundary']);
|
|
32
|
+
shape(value.changes,['api','migration','authentication','authorization','payment']);
|
|
33
|
+
for(const score of Object.values(value.scores))need(Number.isInteger(score)&&score>=1&&score<=5,'qa_assessment_invalid');
|
|
34
|
+
for(const flag of Object.values(value.changes))need(typeof flag==='boolean','qa_assessment_invalid');
|
|
35
|
+
need(Number.isSafeInteger(pending)&&pending>=0&&typeof mergeEligible==='boolean'
|
|
36
|
+
&&Number.isSafeInteger(unassessedTasks)&&unassessedTasks>=1,'qa_policy_unavailable');
|
|
37
|
+
need(!mergeEligible||pending===1,'qa_policy_unavailable');
|
|
38
|
+
const score=Object.values(value.scores).reduce((sum,item)=>sum+item,0);
|
|
39
|
+
const reasons=[];
|
|
40
|
+
if(pending===0)reasons.push('feature_complete');
|
|
41
|
+
for(const name of ['migration','authentication','authorization','payment'])if(value.changes[name])reasons.push(name);
|
|
42
|
+
if(unassessedTasks>=5)reasons.push('five_tasks_without_qa');
|
|
43
|
+
if(value.changes.api&&!mergeEligible)reasons.push('api_change');
|
|
44
|
+
if(reasons.length)return {status:'triggered',score:null,reason:reasons.join(',')};
|
|
45
|
+
if(score>=8)return {status:'triggered',score,reason:'risk_score'};
|
|
46
|
+
return {status:'skipped',score,reason:value.changes.api&&mergeEligible?'merged_to_feature_qa':'risk_score_below_threshold'};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Plug directly into the existing trusted qaDecisionProvider seam. The host
|
|
50
|
+
// classifies meaning; this function owns the mechanical decision and binding.
|
|
51
|
+
export function createHostQaDecisionProvider({assess,timeoutMs}) {
|
|
52
|
+
need(typeof assess==='function'&&Number.isSafeInteger(timeoutMs)&&timeoutMs>0&&timeoutMs<=60000,'qa_assessment_invalid');
|
|
53
|
+
return Object.freeze({timeoutMs,async decide(raw,signal){
|
|
54
|
+
const binding=json(raw);shape(binding,['specsDir','codeProject','feature','identity','packageDigest']);
|
|
55
|
+
validIdentity(binding.identity);hex(binding.packageDigest);
|
|
56
|
+
const context=inspectCmAiQaTaskContext({...binding,taskId:binding.identity.taskId});
|
|
57
|
+
const unassessedTasks=history(binding,context);
|
|
58
|
+
need(!signal.aborted,'cancelled');
|
|
59
|
+
const assessment=await assess(freeze({...binding,pending:context.pending,mergeEligible:context.mergeEligible,
|
|
60
|
+
unassessedTasks}),signal);
|
|
61
|
+
need(!signal.aborted,'cancelled');
|
|
62
|
+
// Assessment is read-only. A task/log change while it was pending requires
|
|
63
|
+
// another decision; do not bind an answer to different policy inputs.
|
|
64
|
+
const current=inspectCmAiQaTaskContext({...binding,taskId:binding.identity.taskId});
|
|
65
|
+
need(digest(current)===digest(context)&&history(binding,current)===unassessedTasks,'stale_qa');
|
|
66
|
+
const result=decideHostQaPolicy({assessment,pending:context.pending,mergeEligible:context.mergeEligible,unassessedTasks});
|
|
67
|
+
return freeze({...result,decisionId:`qa-${digest({identity:binding.identity,packageDigest:binding.packageDigest}).slice(0,48)}`,
|
|
68
|
+
identity:binding.identity,packageDigest:binding.packageDigest,at:new Date().toISOString().replace(/\.\d{3}Z$/,'Z')});
|
|
69
|
+
}});
|
|
70
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Trusted host decision -> existing V3 synchronous grant. No dispatch or durable
|
|
2
|
+
// authority database. The runner alone registers, consumes and replays grants.
|
|
3
|
+
import {randomUUID} from 'node:crypto';
|
|
4
|
+
import {digest,id,json,need,shape,validIdentity} from './effect-contract.mjs';
|
|
5
|
+
|
|
6
|
+
const denied=()=>({status:'denied',code:'permission_denied'});
|
|
7
|
+
export function createHostReviewAuthority({hostContextId,reviewerId,adapterId,decide,timeoutMs=60000}){
|
|
8
|
+
[hostContextId,reviewerId,adapterId].forEach(id);
|
|
9
|
+
need(typeof decide==='function'&&Number.isInteger(timeoutMs)&&timeoutMs>=1&&timeoutMs<=60000);
|
|
10
|
+
let approved=null;
|
|
11
|
+
const hostDecisionProvider=Object.freeze({timeoutMs,async decide(binding,signal){
|
|
12
|
+
approved=null;need(!signal.aborted,'cancelled');
|
|
13
|
+
const decision=json(await decide(binding,signal));need(!signal.aborted,'cancelled');
|
|
14
|
+
if(decision===null)return null;
|
|
15
|
+
if(decision.status==='denied'){shape(decision,['status','code']);need(decision.code==='permission_denied');return denied();}
|
|
16
|
+
shape(decision,['status']);need(decision.status==='approved');
|
|
17
|
+
// The binding is supplied by the original entry, not by the returned text.
|
|
18
|
+
validIdentity(binding.identity);
|
|
19
|
+
approved={identity:json(binding.identity),packageDigest:binding.packageDigest,signal,
|
|
20
|
+
decisionId:randomUUID(),decidedAt:Date.now()};
|
|
21
|
+
return {status:'approved'};
|
|
22
|
+
}});
|
|
23
|
+
const authorize=(request,{authorizationAt})=>{
|
|
24
|
+
const decision=approved;approved=null;
|
|
25
|
+
if(!decision||decision.signal.aborted||request.role!=='reviewer'
|
|
26
|
+
||!Number.isSafeInteger(authorizationAt)||authorizationAt<decision.decidedAt||authorizationAt>=decision.decidedAt+60000
|
|
27
|
+
||digest(request.identity)!==digest(decision.identity)
|
|
28
|
+
||request.payload.reviewPackage.packageDigest!==decision.packageDigest)return denied();
|
|
29
|
+
const body={version:1,kind:'cm-review-dispatch-grant',grantId:randomUUID(),adapterId,
|
|
30
|
+
invocationId:request.invocationId,requestDigest:request.requestDigest,identity:json(request.identity),
|
|
31
|
+
reviewerId,logicalContextId:request.contextId,packageDigest:decision.packageDigest,hostContextId,
|
|
32
|
+
decisionId:decision.decisionId,decision:'approved',issuedAt:authorizationAt,expiresAt:decision.decidedAt+60000};
|
|
33
|
+
return {...body,grantDigest:digest(body)};
|
|
34
|
+
};
|
|
35
|
+
return Object.freeze({hostDecisionProvider,authorize});
|
|
36
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Deterministic projection of the runner's already-registered receipt, not a grant.
|
|
2
|
+
// Only the owning runner calls this after its durable review checkpoint exists.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import {writeReviewEvidence} from './review-evidence-file.mjs';
|
|
6
|
+
import {digest,need,id,text} from './effect-contract.mjs';
|
|
7
|
+
import {readReviewPackage} from './review-package.mjs';
|
|
8
|
+
import {reviewResult} from './review-runner.mjs';
|
|
9
|
+
import {validateReview} from '../../../scripts/cm-task-gate.mjs';
|
|
10
|
+
|
|
11
|
+
export function publishHostReview({reviewsDir,feature,handoffPath,reviewPackage,receipt,registered,at,inspectOnly=false}) {
|
|
12
|
+
id(feature);
|
|
13
|
+
const pkg=readReviewPackage(reviewPackage),r=receipt;
|
|
14
|
+
need(r&®istered&&digest(r)===digest(registered),'unregistered_review');
|
|
15
|
+
const {receiptDigest,...body}=r;
|
|
16
|
+
need(receiptDigest===digest(body)&&r.packageDigest===pkg.packageDigest
|
|
17
|
+
&&digest(r.identity)===digest(pkg.identity),'review_package_mismatch');
|
|
18
|
+
need(r.execution.channel==='host-authorized'&&r.execution.started===true
|
|
19
|
+
&&r.execution.terminal==='succeeded'&&['codex','claude'].includes(r.execution.provider),'execution_mismatch');
|
|
20
|
+
id(r.execution.providerThreadId);
|
|
21
|
+
const result=reviewResult(r.result,pkg);
|
|
22
|
+
need(r.execution.resultDigest===digest(result),'execution_mismatch');
|
|
23
|
+
return publishImplementationReview({reviewsDir,feature,handoffPath,reviewPackage:pkg,result,provider:r.execution.provider,
|
|
24
|
+
reference:`Registered receipt: ${r.receiptDigest}`,at,inspectOnly});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Shared deterministic file projection. Owning callers validate their durable
|
|
28
|
+
// invocation/receipt before entering here; this function grants no authority.
|
|
29
|
+
export function publishImplementationReview({reviewsDir,feature,handoffPath,reviewPackage,result:rawResult,provider,reference,at,inspectOnly=false}){
|
|
30
|
+
id(feature);need(['codex','claude'].includes(provider),'execution_mismatch');text(reference);
|
|
31
|
+
need(!/[\r\n\0]/.test(reference),'invalid_review_reference');
|
|
32
|
+
const pkg=readReviewPackage(reviewPackage),result=reviewResult(rawResult,pkg);
|
|
33
|
+
need(Number.isSafeInteger(at)&&at>=0,'clock_invalid');
|
|
34
|
+
const {taskId,attempt}=pkg.identity;id(taskId);
|
|
35
|
+
const handoff=pkg.handoff;need(handoff,'missing_material');
|
|
36
|
+
need(path.isAbsolute(reviewsDir)&&fs.realpathSync(reviewsDir)===reviewsDir,'unsupported_path');
|
|
37
|
+
need(handoffPath===path.join(reviewsDir,`${feature}-${taskId}-a${attempt}-handoff.json`)
|
|
38
|
+
&&handoff.path===path.basename(handoffPath),'unsupported_path');
|
|
39
|
+
const target=path.join(reviewsDir,`${feature}-${taskId}-r${attempt}.md`);
|
|
40
|
+
const verdict=result.verdict==='changes_requested'&&attempt===2?'blocked':result.verdict;
|
|
41
|
+
const blocking=result.findings.filter(f=>f.severity!=='P3').length;
|
|
42
|
+
// A blocked review may be blocked by missing evidence rather than a code finding.
|
|
43
|
+
const count=verdict==='approved'?0:Math.max(1,blocking);
|
|
44
|
+
const scope=pkg.changes.map(c=>c.path);
|
|
45
|
+
need(scope.every(p=>p.trim()===p),'unsupported_path');
|
|
46
|
+
const bytes=Buffer.from(['---',`at: ${new Date(at).toISOString()}`,`reviewer: ${provider}-cli`,'independent: true',
|
|
47
|
+
`task: ${taskId}`,`attempt: ${attempt}`,`round: ${attempt}`,`verdict: ${verdict}`,
|
|
48
|
+
`handoff: ${handoff.path}`,`handoff_sha256: ${handoff.sha256}`,`blocking_findings: ${count}`,
|
|
49
|
+
'scope:',...scope.map(p=>` - ${p}`),'---','',
|
|
50
|
+
verdict==='approved'?'No blocking findings.':'Review is not approved.',
|
|
51
|
+
reference,
|
|
52
|
+
'Reviewer result (JSON data):',JSON.stringify(result),'' ].join('\n'));
|
|
53
|
+
need(bytes.length<=256*1024,'limit_exceeded');
|
|
54
|
+
return writeReviewEvidence({reviewsDir,name:path.basename(target),bytes,inspectOnly,
|
|
55
|
+
validate:file=>validateReview(file,{task:taskId,attempt,handoff:handoffPath,changedFiles:scope})});
|
|
56
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Current-conversation projection; the existing config and log writer remain authoritative.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {spawnSync} from 'node:child_process';
|
|
4
|
+
import {fileURLToPath} from 'node:url';
|
|
5
|
+
import {loadConfig,resolveRole} from '../../../scripts/cm-workflow-config.mjs';
|
|
6
|
+
import {json,need,validIdentity} from './effect-contract.mjs';
|
|
7
|
+
|
|
8
|
+
const writer=fileURLToPath(new URL('../../../scripts/cm-log-event.py',import.meta.url));
|
|
9
|
+
|
|
10
|
+
export function resolveHostRole({definition,identity,role,signal,runtime='codex'}){
|
|
11
|
+
need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
12
|
+
validIdentity(identity);need(['coder','tester'].includes(role),'invalid_role');
|
|
13
|
+
need(!signal.aborted,'cancelled');
|
|
14
|
+
const log=(event,data,detail)=>{
|
|
15
|
+
const result=spawnSync('python3',[writer,'--workflow','cm-ai','--event',event,'--phase','route',
|
|
16
|
+
'--runtime',runtime,'--project-root',definition.codeProject,'--specs-dir',definition.specsDir,
|
|
17
|
+
'--run-id',identity.runId,'--detail',detail,'--data-json',JSON.stringify({node:'N3',
|
|
18
|
+
feature:definition.feature,task:identity.taskId,attempt:identity.attempt,
|
|
19
|
+
repository_id:identity.repositoryId,role,...data})],
|
|
20
|
+
{env:{...process.env,CM_WORKFLOW_LOG_HOME:path.join(definition.specsDir,'.reviews','host-log-mirror')},
|
|
21
|
+
timeout:10000,maxBuffer:1024*1024});
|
|
22
|
+
need(!result.error&&result.status===0&&result.signal===null,'role_log_failed');
|
|
23
|
+
const receipt=JSON.parse(result.stdout.toString('utf8'));
|
|
24
|
+
need(receipt.run_id===identity.runId&&receipt.project_log===path.join(definition.specsDir,'运行日志.jsonl'),'role_log_failed');
|
|
25
|
+
};
|
|
26
|
+
let route;
|
|
27
|
+
try{route=resolveRole(loadConfig({projectRoot:definition.codeProject}),role,runtime);}
|
|
28
|
+
catch{
|
|
29
|
+
// Do not echo parser errors: they can contain user configuration values.
|
|
30
|
+
log('error',{outcome:'invalid_workflow_config'},'Workflow role configuration invalid; no tool request');
|
|
31
|
+
need(false,'invalid_workflow_config');
|
|
32
|
+
}
|
|
33
|
+
log('decision',{adapter:route.adapter,requested_model:route.model,source:route.source,
|
|
34
|
+
purpose:role==='coder'?'implementation':'task_checks',route_state:route.route_state},`Current conversation role: ${role}`);
|
|
35
|
+
if(!['current-runtime','local-tool'].includes(route.route_state))
|
|
36
|
+
log('degrade',{adapter:route.adapter,requested_model:route.model,route_state:route.route_state,
|
|
37
|
+
outcome:'current_conversation_only'},'Requested role adapter not invoked; current conversation tools only');
|
|
38
|
+
// Metadata does not select a model, invoke an adapter, or grant any tool permission.
|
|
39
|
+
need(!signal.aborted,'cancelled');
|
|
40
|
+
return json(route);
|
|
41
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// JSONL transport only. The existing host/runner owns decisions and durable state.
|
|
2
|
+
|
|
3
|
+
const LIMIT=64*1024;
|
|
4
|
+
const operationNames=new Set(['recover_final_review','advance','start','plan_design','promote_design','select_design_reviews','status','fix_status','fix_advance','fix_action','fix_run','decision','complete','qa','qa_result','prepare_revision','prepare_save',
|
|
5
|
+
'context_refresh','finish','completion_evidence','run_finalize','review_findings','review_disposition','save_draft','save_design','correct_findings','prepare_summary','publish_summary','inspect_correction','resume_correction','cancel','resume','cause_review_package','cause_review','red_test','baseline','author_tests','repair','regression','retrospective','learning_writeback','handoff','final_review_package','final_review','publish_review','check_n5','post_review_regression','publish_dossier','walkthrough']);
|
|
6
|
+
|
|
7
|
+
export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimit=LIMIT}){
|
|
8
|
+
if(!Number.isSafeInteger(inputLimit)||inputLimit<LIMIT||inputLimit>4*1024*1024)throw Error('input_limit_invalid');
|
|
9
|
+
let pending=null,buffer=Buffer.alloc(0),failure=null,closeRequested=false;
|
|
10
|
+
let writing=Promise.resolve();
|
|
11
|
+
const controls=new Set();let queuedWrites=0;
|
|
12
|
+
const outputError=error=>{failure=error;toolBridge?.close();input.destroy(error);};
|
|
13
|
+
const inputError=error=>{if(!closeRequested)failure=error;toolBridge?.close();};
|
|
14
|
+
input.on('error',inputError);
|
|
15
|
+
output.on('error',outputError);
|
|
16
|
+
const reply=value=>{
|
|
17
|
+
if(queuedWrites>=64){
|
|
18
|
+
const error=new Error('output_backlog_exceeded');
|
|
19
|
+
outputError(error);output.destroy(error);return Promise.reject(error);
|
|
20
|
+
}
|
|
21
|
+
queuedWrites++;
|
|
22
|
+
const bytes=JSON.stringify(value)+'\n';
|
|
23
|
+
writing=writing.then(()=>new Promise((resolve,reject)=>{
|
|
24
|
+
if(failure){reject(failure);return;}
|
|
25
|
+
const done=error=>{output.off('error',done);error?reject(error):resolve();};
|
|
26
|
+
output.once('error',done);
|
|
27
|
+
try{output.write(bytes,done);}catch(error){done(error);}
|
|
28
|
+
})).finally(()=>{queuedWrites--;});
|
|
29
|
+
// A broken output must not become an unhandled rejection while work is pending.
|
|
30
|
+
writing.catch(error=>{failure=error;});
|
|
31
|
+
return writing;
|
|
32
|
+
};
|
|
33
|
+
toolBridge?.attach(reply);
|
|
34
|
+
async function dispatch(bytes){
|
|
35
|
+
if(failure)throw failure;
|
|
36
|
+
let request;
|
|
37
|
+
try{
|
|
38
|
+
request=JSON.parse(bytes.toString('utf8'));
|
|
39
|
+
if(toolBridge!==null&&['host_result','host_close'].includes(request?.type)){
|
|
40
|
+
const accepted=toolBridge.accept(request);closeRequested=accepted.closing===true;
|
|
41
|
+
reply({type:'host_response',...accepted}).catch(error=>{failure=error;});return;
|
|
42
|
+
}
|
|
43
|
+
if(!request||typeof request!=='object'||Array.isArray(request)
|
|
44
|
+
||typeof request.requestId!=='string'||request.requestId.length>128
|
|
45
|
+
||!operationNames.has(request.operation))throw Error('invalid');
|
|
46
|
+
}catch{reply({requestId:null,error:{code:'invalid_request'}}).catch(error=>{failure=error;});return;}
|
|
47
|
+
const requestId=request.requestId;
|
|
48
|
+
const invoke=async()=>{
|
|
49
|
+
try{await reply({requestId,result:await host.handle(request)});}
|
|
50
|
+
catch{await reply({requestId,error:{code:'host_request_failed'}});}
|
|
51
|
+
};
|
|
52
|
+
// Never queue cancel/status behind a long developer or reviewer call.
|
|
53
|
+
if(request.operation==='status'||request.operation==='cancel'){
|
|
54
|
+
// The input reader must not wait for a slow response consumer before it
|
|
55
|
+
// can deliver the next control request (especially cancellation).
|
|
56
|
+
const control=invoke().finally(()=>{controls.delete(control);});
|
|
57
|
+
controls.add(control);control.catch(error=>{failure=error;});return;
|
|
58
|
+
}
|
|
59
|
+
if(pending){reply({requestId,error:{code:'host_busy'}}).catch(error=>{failure=error;});return;}
|
|
60
|
+
pending=invoke().finally(()=>{pending=null;});
|
|
61
|
+
pending.catch(error=>{failure=error;});
|
|
62
|
+
}
|
|
63
|
+
try{
|
|
64
|
+
reading: for await(const chunk of input){
|
|
65
|
+
if(failure)throw failure;
|
|
66
|
+
const bytes=Buffer.isBuffer(chunk)?chunk:Buffer.from(chunk);
|
|
67
|
+
let start=0;
|
|
68
|
+
for(let end=0;end<bytes.length;end++){
|
|
69
|
+
if(bytes[end]!==10)continue;
|
|
70
|
+
if(buffer.length+end-start>inputLimit)throw Error('request_too_large');
|
|
71
|
+
const line=Buffer.concat([buffer,bytes.subarray(start,end)]);
|
|
72
|
+
buffer=Buffer.alloc(0);start=end+1;
|
|
73
|
+
if(line.length)await dispatch(line);
|
|
74
|
+
if(closeRequested)break reading;
|
|
75
|
+
}
|
|
76
|
+
if(buffer.length+bytes.length-start>inputLimit)throw Error('request_too_large');
|
|
77
|
+
buffer=Buffer.concat([buffer,bytes.subarray(start)]);
|
|
78
|
+
}
|
|
79
|
+
if(buffer.length&&!closeRequested)await dispatch(buffer);
|
|
80
|
+
}finally{
|
|
81
|
+
// With a duplex conversation, EOF means no more tool replies can arrive.
|
|
82
|
+
// Reject that wait as disconnected, not as an explicit user cancellation.
|
|
83
|
+
toolBridge?.close();
|
|
84
|
+
// EOF is not a user cancellation. Finish the in-flight result before close.
|
|
85
|
+
try{await Promise.allSettled([...(pending?[pending]:[]),...controls,writing]);}
|
|
86
|
+
finally{
|
|
87
|
+
// destroy() emits error/close on a later tick; retain its error listener
|
|
88
|
+
// until that lifecycle finishes rather than leaking an uncaught error.
|
|
89
|
+
if(output.destroyed&&!output.closed)await new Promise(resolve=>output.once('close',resolve));
|
|
90
|
+
if(input.destroyed&&!input.closed)await new Promise(resolve=>input.once('close',resolve));
|
|
91
|
+
output.off('error',outputError);
|
|
92
|
+
input.off('error',inputError);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if(failure)throw failure;
|
|
96
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Duplex transport for a trusted current conversation. This has no task,
|
|
2
|
+
// permission, dispatch-grant or completion authority and persists no state.
|
|
3
|
+
import {randomUUID} from 'node:crypto';
|
|
4
|
+
import {digest,json,need,shape} from './effect-contract.mjs';
|
|
5
|
+
|
|
6
|
+
export function createHostToolBridge({responseLimit=64*1024}={}){
|
|
7
|
+
need(Number.isSafeInteger(responseLimit)&&responseLimit>=64*1024&&responseLimit<=4*1024*1024,'host_response_limit_invalid');
|
|
8
|
+
const sessionId=randomUUID();let send=null,pending=null,closed=false;
|
|
9
|
+
const stop=code=>{
|
|
10
|
+
const call=pending;if(!call)return;pending=null;
|
|
11
|
+
call.signal.removeEventListener('abort',call.abort);
|
|
12
|
+
call.reject(Object.assign(new Error(code),{code}));
|
|
13
|
+
};
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
attach(sender){
|
|
16
|
+
need(send===null&&typeof sender==='function'&&!closed,'host_bridge_unavailable');send=sender;
|
|
17
|
+
Promise.resolve(send({type:'host_ready',sessionId})).catch(()=>{closed=true;stop('host_disconnected');});
|
|
18
|
+
},
|
|
19
|
+
call(kind,payload,signal){
|
|
20
|
+
need(send!==null&&!closed,'host_bridge_unavailable');need(pending===null,'host_bridge_busy');
|
|
21
|
+
need(['develop','check','check_runtime','check_semantic','qa_assess','qa_logic','qa_browser','test_cases','refactor_analyze','refactor_confirm','refactor_apply','refactor_review','refactor_batch','refactor_prepare_tests','refactor_retrospective','refactor_recover','documentation_sync','documentation_inspect','fix_diagnose','fix_learning','fix_test_author','fix_repair','fix_retrospective','init_analyze','init_generate','init_verify','init_confirm','init_review','init_write','idea_interview','idea_confirm_save','prd_analyze','prd_materials','prd_generate','prd_self_check','prd_review','prd_correct','prd_summary']
|
|
22
|
+
.includes(kind),'host_operation_invalid');need(!signal.aborted,'cancelled');
|
|
23
|
+
const data=json({kind,payload},12*1024*1024);
|
|
24
|
+
const request={type:'host_request',sessionId,callId:randomUUID(),requestDigest:digest(data),...data};
|
|
25
|
+
return new Promise((resolve,reject)=>{
|
|
26
|
+
const abort=()=>{
|
|
27
|
+
stop('cancelled');
|
|
28
|
+
Promise.resolve(send({type:'host_call_cancelled',sessionId,callId:request.callId})).catch(()=>{});
|
|
29
|
+
};
|
|
30
|
+
pending={request,signal,abort,resolve,reject};signal.addEventListener('abort',abort,{once:true});
|
|
31
|
+
if(signal.aborted){abort();return;}
|
|
32
|
+
Promise.resolve().then(()=>{
|
|
33
|
+
if(pending?.request===request&&!closed&&!signal.aborted)return send(request);
|
|
34
|
+
}).catch(()=>stop('host_disconnected'));
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
accept(raw){
|
|
38
|
+
let reply;
|
|
39
|
+
try{
|
|
40
|
+
if(raw?.type==='host_close'){
|
|
41
|
+
shape(raw,['type','sessionId']);need(raw.sessionId===sessionId&&!closed,'host_response_mismatch');
|
|
42
|
+
closed=true;stop('host_disconnected');return {accepted:true,closing:true};
|
|
43
|
+
}
|
|
44
|
+
reply=json(raw,responseLimit);shape(reply,['type','sessionId','callId','requestDigest','result']);
|
|
45
|
+
need(reply.type==='host_result'&&pending!==null&&!closed,'host_response_mismatch');
|
|
46
|
+
for(const key of ['sessionId','callId','requestDigest'])need(reply[key]===pending.request[key],'host_response_mismatch');
|
|
47
|
+
}catch{return {accepted:false,code:'host_response_mismatch'};}
|
|
48
|
+
const call=pending;pending=null;call.signal.removeEventListener('abort',call.abort);
|
|
49
|
+
call.resolve(reply.result);return {accepted:true,callId:reply.callId};
|
|
50
|
+
},
|
|
51
|
+
close(){closed=true;stop('host_disconnected');},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Fixed current-conversation capabilities over the existing N6/N8 adapters.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {json,need,shape} from './effect-contract.mjs';
|
|
5
|
+
import {createHostQaDecisionProvider} from './host-qa-policy.mjs';
|
|
6
|
+
import {createHostQaExecutor} from './host-qa-executor.mjs';
|
|
7
|
+
|
|
8
|
+
export function readHostWorkflowConfiguration(file){
|
|
9
|
+
const stat=fs.lstatSync(file);
|
|
10
|
+
need(stat.isFile()&&!stat.isSymbolicLink()&&stat.size<=64*1024,'invalid_workflow_config');
|
|
11
|
+
return validateHostWorkflowConfiguration(JSON.parse(fs.readFileSync(file,'utf8')));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function validateHostWorkflowConfiguration(raw){
|
|
15
|
+
const config=json(raw);
|
|
16
|
+
shape(config,['qa','documentationPaths','applicableAgentFiles']);
|
|
17
|
+
for(const key of ['documentationPaths','applicableAgentFiles'])
|
|
18
|
+
need(Array.isArray(config[key])&&config[key].length<=256&&config[key].every(item=>typeof item==='string'),'invalid_workflow_config');
|
|
19
|
+
if(config.qa!==null)shape(config.qa,['commands','environment']);
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createHostWorkflowCapabilities({definition,configuration,bridge,allowQa,runtime='codex',protectedExecution=false,bootstrap=null}){
|
|
24
|
+
need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
25
|
+
const {specsDir,codeProject,feature,requirements}=definition;
|
|
26
|
+
const logHome=path.join(specsDir,'.reviews','host-log-mirror');
|
|
27
|
+
const result={applicableAgentFiles:configuration.applicableAgentFiles,
|
|
28
|
+
documentationProvider:{timeoutMs:60000,inspect:(request,signal)=>bridge.call('documentation_inspect',request,signal)}};
|
|
29
|
+
if(!protectedExecution&&configuration.documentationPaths.length)result.documentationSync={paths:configuration.documentationPaths,
|
|
30
|
+
run:(request,signal)=>bridge.call('documentation_sync',request,signal)};
|
|
31
|
+
if(configuration.qa!==null){
|
|
32
|
+
need(allowQa===true,'qa_authorization_required');
|
|
33
|
+
result.qaLogHome=logHome;
|
|
34
|
+
result.qaDecisionProvider=createHostQaDecisionProvider({timeoutMs:60000,
|
|
35
|
+
assess:(request,signal)=>bridge.call('qa_assess',request,signal)});
|
|
36
|
+
result.qaExecutor=createHostQaExecutor({specsDir,codeProject,feature,requirements,runtime,
|
|
37
|
+
...(definition.codeProjects?{codeProjects:definition.codeProjects}:{}),
|
|
38
|
+
...(bootstrap?{bootstrap:{requirements:bootstrap.configuration.bootstrapRequirements,scope:definition.scope}}:{}),
|
|
39
|
+
...configuration.qa,timeoutMs:1800000,logHome,
|
|
40
|
+
...(protectedExecution?{specsRoot:specsDir}:{}),
|
|
41
|
+
logic:(request,signal)=>bridge.call('qa_logic',request,signal),
|
|
42
|
+
browser:(request,signal)=>bridge.call('qa_browser',request,signal)});
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Formal cm-ai host assembly. It adds no workflow, authorization, or completion path.
|
|
2
|
+
import {createCmAiConversationEntry} from './cm-ai-conversation-entry.mjs';
|
|
3
|
+
import {json,need,shape} from './effect-contract.mjs';
|
|
4
|
+
import {createTaskRunner} from './task-runner.mjs';
|
|
5
|
+
|
|
6
|
+
export function createCmAiHost(options) {
|
|
7
|
+
need(arguments.length===1,'invalid_input');
|
|
8
|
+
shape(options,['runner','entry']);
|
|
9
|
+
const keys=Object.keys(options.entry);shape(options.entry,keys);
|
|
10
|
+
const {hostDecisionProvider,qaDecisionProvider,qaExecutor,documentationProvider,...data}=options.entry;
|
|
11
|
+
const entryOptions=json(data);
|
|
12
|
+
need(!Object.hasOwn(entryOptions,'runner'),'invalid_input');
|
|
13
|
+
const runner=createTaskRunner(options.runner);
|
|
14
|
+
const entry=createCmAiConversationEntry({...entryOptions,runner,
|
|
15
|
+
...(hostDecisionProvider===undefined?{}:{hostDecisionProvider}),
|
|
16
|
+
...(qaExecutor===undefined?{}:{qaExecutor}),
|
|
17
|
+
...(documentationProvider===undefined?{}:{documentationProvider}),
|
|
18
|
+
...(qaDecisionProvider===undefined?{}:{qaDecisionProvider})});
|
|
19
|
+
return Object.freeze({handle:entry.handle,inspectFixAssociation:runner.inspectFixAssociation,acceptCompletedFix:runner.acceptCompletedFix});
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {fileURLToPath} from 'node:url';
|
|
2
|
+
|
|
3
|
+
export {createCmAiHost} from './host.mjs';
|
|
4
|
+
export {createCodexReviewRun} from './codex-review-adapter.mjs';
|
|
5
|
+
export {codexWorker} from './worker-codex.mjs';
|
|
6
|
+
export {configFingerprint} from './codex-config.mjs';
|
|
7
|
+
export const codexReviewResultSchemaPath=fileURLToPath(new URL('./review-result.schema.json',import.meta.url));
|