@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,231 @@
|
|
|
1
|
+
// Read-only admission for the existing cm-test workflow.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {fileURLToPath} from 'node:url';
|
|
5
|
+
|
|
6
|
+
const FEATURE=/^(\d+)\.(.+)$/;
|
|
7
|
+
const OPTIONAL=new Set(['description','specs','feature','cases','reportDir','generateCases',
|
|
8
|
+
'logic','commands','browser','all','explore']);
|
|
9
|
+
|
|
10
|
+
function reject(code) {
|
|
11
|
+
const error=new Error(code);
|
|
12
|
+
error.code=code;
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function frozen(value) {
|
|
17
|
+
if(value&&typeof value==='object'){
|
|
18
|
+
for(const item of Object.values(value))frozen(item);
|
|
19
|
+
Object.freeze(value);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function text(value,code) {
|
|
25
|
+
if(typeof value!=='string'||value.trim().length===0||value.includes('\0'))reject(code);
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function boolean(value,code) {
|
|
30
|
+
if(typeof value!=='boolean')reject(code);
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function realDirectory(raw,code) {
|
|
35
|
+
try {
|
|
36
|
+
const target=fs.realpathSync(path.resolve(text(raw,code)));
|
|
37
|
+
const stat=fs.lstatSync(target);
|
|
38
|
+
if(!stat.isDirectory()||stat.isSymbolicLink())reject(code);
|
|
39
|
+
return target;
|
|
40
|
+
} catch(error) {
|
|
41
|
+
if(error?.code===code)throw error;
|
|
42
|
+
reject(code);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function realFile(raw,code) {
|
|
47
|
+
try {
|
|
48
|
+
const target=fs.realpathSync(path.resolve(text(raw,code)));
|
|
49
|
+
const stat=fs.lstatSync(target);
|
|
50
|
+
if(!stat.isFile()||stat.isSymbolicLink())reject(code);
|
|
51
|
+
return target;
|
|
52
|
+
} catch(error) {
|
|
53
|
+
if(error?.code===code)throw error;
|
|
54
|
+
reject(code);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function ownedFile(root,relative,code) {
|
|
59
|
+
try {
|
|
60
|
+
const target=path.join(root,relative);
|
|
61
|
+
const stat=fs.lstatSync(target);
|
|
62
|
+
if(!stat.isFile()||stat.isSymbolicLink()||stat.nlink!==1||fs.realpathSync(target)!==target)reject(code);
|
|
63
|
+
return target;
|
|
64
|
+
} catch(error) {
|
|
65
|
+
if(error?.code===code)throw error;
|
|
66
|
+
reject(code);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function inside(root,target) {
|
|
71
|
+
const relative=path.relative(root,target);
|
|
72
|
+
return relative===''||(!relative.startsWith(`..${path.sep}`)&&relative!=='..'&&!path.isAbsolute(relative));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function workflowRoot(skillDir) {
|
|
76
|
+
const skill=realDirectory(skillDir,'skill_path_invalid');
|
|
77
|
+
const root=realDirectory(path.resolve(skill,'../..'),'skill_path_invalid');
|
|
78
|
+
if(skill!==path.join(root,'skills','cm-test'))reject('skill_path_invalid');
|
|
79
|
+
let layout;
|
|
80
|
+
if(fs.existsSync(path.join(root,'VERSION'))){
|
|
81
|
+
ownedFile(root,'VERSION','skill_path_invalid');layout='plugin';
|
|
82
|
+
}else if(fs.existsSync(path.join(root,'templates','cm-VERSION'))){
|
|
83
|
+
ownedFile(root,'templates/cm-VERSION','skill_path_invalid');layout='claude-compat';
|
|
84
|
+
}else reject('skill_path_invalid');
|
|
85
|
+
ownedFile(root,'skills/cm-test/SKILL.md','skill_path_invalid');
|
|
86
|
+
ownedFile(root,'runtime/test-contract.md','skill_path_invalid');
|
|
87
|
+
ownedFile(root,'scripts/cm-test-entry.mjs','skill_path_invalid');
|
|
88
|
+
realDirectory(path.join(root,'templates'),'skill_path_invalid');
|
|
89
|
+
return {root,skill,layout};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function featureNames(specs) {
|
|
93
|
+
return fs.readdirSync(specs,{withFileTypes:true})
|
|
94
|
+
.filter(item=>item.isDirectory()&&FEATURE.test(item.name))
|
|
95
|
+
.map(item=>item.name)
|
|
96
|
+
.sort((left,right)=>Number(left.match(FEATURE)[1])-Number(right.match(FEATURE)[1])
|
|
97
|
+
||left.localeCompare(right));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function validFeature(specs,name,strict) {
|
|
101
|
+
try {
|
|
102
|
+
const featureRoot=path.join(specs,name);
|
|
103
|
+
if(fs.realpathSync(featureRoot)!==featureRoot)reject('feature_contract_invalid');
|
|
104
|
+
for(const file of ['requirements.md','design.md','tasks.md'])ownedFile(featureRoot,file,'feature_contract_missing');
|
|
105
|
+
return true;
|
|
106
|
+
} catch(error) {
|
|
107
|
+
if(strict)throw error;
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function normalizeInput(input) {
|
|
113
|
+
if(!input||typeof input!=='object'||Array.isArray(input))reject('invalid_input');
|
|
114
|
+
const keys=Object.keys(input);
|
|
115
|
+
if(!keys.includes('skillDir')||!keys.includes('project')
|
|
116
|
+
||keys.some(key=>!['skillDir','project'].includes(key)&&!OPTIONAL.has(key)))reject('invalid_input');
|
|
117
|
+
for(const key of ['generateCases','logic','commands','browser','all'])
|
|
118
|
+
if(Object.hasOwn(input,key))boolean(input[key],'invalid_input');
|
|
119
|
+
return input;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function inspectCmTestAdmission(raw) {
|
|
123
|
+
const input=normalizeInput(raw);
|
|
124
|
+
const {root,skill,layout}=workflowRoot(input.skillDir);
|
|
125
|
+
const project=realDirectory(input.project,'project_path_invalid');
|
|
126
|
+
const flags={
|
|
127
|
+
generateCases:input.generateCases===true,
|
|
128
|
+
logic:input.logic===true,
|
|
129
|
+
commands:input.commands===true,
|
|
130
|
+
browser:input.browser===true,
|
|
131
|
+
all:input.all===true
|
|
132
|
+
};
|
|
133
|
+
const hasCases=Object.hasOwn(input,'cases'),hasExplore=Object.hasOwn(input,'explore');
|
|
134
|
+
const explicitExecution=flags.logic||flags.commands||flags.browser||flags.all;
|
|
135
|
+
if(flags.generateCases&&(hasCases||explicitExecution||hasExplore))reject('generate_cases_conflict');
|
|
136
|
+
if(hasExplore&&(hasCases||explicitExecution))reject('explore_conflict');
|
|
137
|
+
if(Object.hasOwn(input,'feature')&&!Object.hasOwn(input,'specs'))reject('feature_without_specs');
|
|
138
|
+
const description=Object.hasOwn(input,'description')?text(input.description,'description_invalid'):null;
|
|
139
|
+
const explore=Object.hasOwn(input,'explore')?text(input.explore,'explore_invalid'):null;
|
|
140
|
+
const requestedReportDir=Object.hasOwn(input,'reportDir')
|
|
141
|
+
?path.resolve(text(input.reportDir,'report_dir_invalid')):null;
|
|
142
|
+
const cases=hasCases?realFile(input.cases,'cases_path_invalid'):null;
|
|
143
|
+
let specs=null,features=[],feature=null;
|
|
144
|
+
if(Object.hasOwn(input,'specs')){
|
|
145
|
+
specs=realDirectory(input.specs,'specs_path_invalid');
|
|
146
|
+
if(inside(project,specs)&&specs!==path.join(project,'specs'))reject('specs_location_invalid');
|
|
147
|
+
const discovered=featureNames(specs);
|
|
148
|
+
if(discovered.length===0)reject('features_missing');
|
|
149
|
+
if(Object.hasOwn(input,'feature')){
|
|
150
|
+
feature=text(input.feature,'feature_invalid');
|
|
151
|
+
if(!FEATURE.test(feature)||!discovered.includes(feature))reject('feature_invalid');
|
|
152
|
+
validFeature(specs,feature,true);features=[feature];
|
|
153
|
+
}else{
|
|
154
|
+
features=discovered.filter(name=>validFeature(specs,name,false));
|
|
155
|
+
if(features.length===0)reject('feature_contract_missing');
|
|
156
|
+
if(features.length===1)feature=features[0];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if(specs&&feature===null)return frozen({
|
|
160
|
+
schemaVersion:1,workflow:'cm-test',status:'selection_required',reason:'feature_required',
|
|
161
|
+
workflowRoot:root,skillDir:skill,runtimeLayout:layout,project,specs,features,
|
|
162
|
+
executionAuthorized:false,writeAuthorized:false
|
|
163
|
+
});
|
|
164
|
+
let operation,modes,hardStopAfterGeneration=false;
|
|
165
|
+
if(flags.generateCases){
|
|
166
|
+
if(description===null&&feature===null)reject('generation_target_required');
|
|
167
|
+
operation='generate_cases';modes=[];hardStopAfterGeneration=true;
|
|
168
|
+
}else if(explore){
|
|
169
|
+
operation='explore';modes=['browser'];
|
|
170
|
+
}else{
|
|
171
|
+
if(description===null&&specs===null&&cases===null)reject('test_target_required');
|
|
172
|
+
operation='execute';
|
|
173
|
+
modes=flags.all||!explicitExecution?['logic','commands','browser']:
|
|
174
|
+
['logic','commands','browser'].filter(mode=>flags[mode]);
|
|
175
|
+
}
|
|
176
|
+
const requiredRoles=[];
|
|
177
|
+
if(modes.includes('logic')||modes.includes('commands'))requiredRoles.push('tester');
|
|
178
|
+
if(modes.includes('browser'))requiredRoles.push('browser_qa');
|
|
179
|
+
return frozen({
|
|
180
|
+
schemaVersion:1,workflow:'cm-test',status:'ready',reason:null,operation,modes,requiredRoles,
|
|
181
|
+
workflowRoot:root,skillDir:skill,runtimeLayout:layout,project,specs,feature,features,cases,requestedReportDir,
|
|
182
|
+
reportDirBoundary:'pending',hardStopAfterGeneration,executionAuthorized:false,writeAuthorized:false
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function parseCli(argv) {
|
|
187
|
+
const input={};
|
|
188
|
+
const values=new Map([
|
|
189
|
+
['--skill-dir','skillDir'],['--project','project'],['--description','description'],['--specs','specs'],
|
|
190
|
+
['--feature','feature'],['--cases','cases'],['--report-dir','reportDir'],['--explore','explore']
|
|
191
|
+
]);
|
|
192
|
+
const switches=new Map([
|
|
193
|
+
['--generate-cases','generateCases'],['--logic','logic'],['--commands','commands'],
|
|
194
|
+
['--browser','browser'],['--all','all']
|
|
195
|
+
]);
|
|
196
|
+
const known=new Set([...values.keys(),...switches.keys()]);
|
|
197
|
+
for(let index=0;index<argv.length;index+=1){
|
|
198
|
+
const flag=argv[index];
|
|
199
|
+
const valueKey=values.get(flag),switchKey=switches.get(flag);
|
|
200
|
+
if(valueKey){
|
|
201
|
+
if(Object.hasOwn(input,valueKey)||index+1>=argv.length||known.has(argv[index+1]))reject('invalid_arguments');
|
|
202
|
+
input[valueKey]=argv[index+1];index+=1;
|
|
203
|
+
}else if(switchKey){
|
|
204
|
+
if(Object.hasOwn(input,switchKey))reject('invalid_arguments');
|
|
205
|
+
input[switchKey]=true;
|
|
206
|
+
}else reject('invalid_arguments');
|
|
207
|
+
}
|
|
208
|
+
return input;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function isMainModule(entry) {
|
|
212
|
+
if(!entry)return false;
|
|
213
|
+
try {
|
|
214
|
+
return fs.realpathSync(entry)===fileURLToPath(import.meta.url);
|
|
215
|
+
} catch {
|
|
216
|
+
return path.resolve(entry)===fileURLToPath(import.meta.url);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if(isMainModule(process.argv[1])){
|
|
221
|
+
try {
|
|
222
|
+
const result=inspectCmTestAdmission(parseCli(process.argv.slice(2)));
|
|
223
|
+
if(fileURLToPath(import.meta.url)!==path.join(result.workflowRoot,'scripts','cm-test-entry.mjs'))
|
|
224
|
+
reject('entry_path_invalid');
|
|
225
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
226
|
+
} catch(error) {
|
|
227
|
+
process.stderr.write(`${JSON.stringify({schemaVersion:1,workflow:'cm-test',status:'blocked',
|
|
228
|
+
reason:error?.code??'admission_failed'})}\n`);
|
|
229
|
+
process.exitCode=2;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Shared Codex/Claude current-conversation entry. Configuration is supplied by
|
|
3
|
+
// the trusted host before startup, never by a test-case/model response.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {fileURLToPath} from 'node:url';
|
|
7
|
+
import {createCmTestHost} from '../runtime/js/cm-test/host.mjs';
|
|
8
|
+
import {inspectCmTestRecovery} from '../runtime/js/cm-test/recovery.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 {need} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
12
|
+
import {openTestSession} from '../runtime/js/cm-test/session.mjs';
|
|
13
|
+
|
|
14
|
+
export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr}={}){
|
|
15
|
+
let bridge,session;
|
|
16
|
+
try{
|
|
17
|
+
if(argv.length===1&&argv[0]==='--help'){
|
|
18
|
+
output.write('Optional serve trailing --session-dir ABS_PRIVATE_DIR preserves the original run and effects. Explicit JSONL resume {resolution:null} consumes recorded results; unknown original host/command results require {key,requestDigest,result,evidence,cleanup:"completed"}. Never redispatch unknown actions. Unknown log/publication writes require manual reconciliation. inspect remains read-only history.\n');
|
|
19
|
+
output.write('cm-test-host.mjs serve --config ABSOLUTE_JSON\ncm-test-host.mjs inspect --config ABSOLUTE_JSON --run-id ID --log-file ABSOLUTE_LOG\nInspect is read-only historical recovery, never command replay. Config: {skillDir,project,runtime,arguments,sources,commands,environment,logHome}. Commands are trusted startup capabilities, not model output. JSONL start/status/cancel; host replies test_cases/qa_logic/qa_browser. No provider or repair. See skills/cm-test/references/js-host.md.\n');return 0;
|
|
20
|
+
}
|
|
21
|
+
const sessionDir=argv[0]==='serve'&&argv.at(-2)==='--session-dir'?argv.at(-1):null;
|
|
22
|
+
if(sessionDir!==null)argv=argv.slice(0,-2);
|
|
23
|
+
const inspecting=argv.length===7&&argv[0]==='inspect'&&argv[3]==='--run-id'&&argv[5]==='--log-file';
|
|
24
|
+
need((inspecting||(argv.length===3&&argv[0]==='serve'))&&argv[1]==='--config'&&path.isAbsolute(argv[2]),'invalid_arguments');
|
|
25
|
+
const stat=fs.lstatSync(argv[2]);need(stat.isFile()&&!stat.isSymbolicLink()&&stat.size<=64*1024,'cm_test_config_invalid');
|
|
26
|
+
const configuration=JSON.parse(fs.readFileSync(argv[2],'utf8'));
|
|
27
|
+
if(inspecting){
|
|
28
|
+
output.write(JSON.stringify(inspectCmTestRecovery(configuration,{runId:argv[4],logFile:argv[6]}))+'\n');return 0;
|
|
29
|
+
}
|
|
30
|
+
need(path.resolve(configuration.skillDir,'../..','scripts/cm-test-host.mjs')===fileURLToPath(import.meta.url),'entry_path_invalid');
|
|
31
|
+
bridge=createHostToolBridge();
|
|
32
|
+
if(sessionDir!==null)session=openTestSession(sessionDir,configuration);
|
|
33
|
+
const host=createCmTestHost(configuration,{call:(...args)=>bridge.call(...args),session});
|
|
34
|
+
const rawMode=input.isTTY&&typeof input.setRawMode==='function';if(rawMode)input.setRawMode(true);
|
|
35
|
+
try{await serveCmAiHost({host,input,output,toolBridge:bridge});}finally{if(rawMode)input.setRawMode(false);}
|
|
36
|
+
return 0;
|
|
37
|
+
}catch(cause){error.write(JSON.stringify({error:{code:cause?.code??'cm_test_host_failed'}})+'\n');return 1;}
|
|
38
|
+
finally{bridge?.close();session?.close();}
|
|
39
|
+
}
|
|
40
|
+
if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=await main();
|
|
@@ -0,0 +1,169 @@
|
|
|
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 {once} from 'node:events';
|
|
8
|
+
import {createInterface} from 'node:readline';
|
|
9
|
+
import {fileURLToPath} from 'node:url';
|
|
10
|
+
import {createCmTestHost} from '../runtime/js/cm-test/host.mjs';
|
|
11
|
+
import {inspectCmTestRecovery} from '../runtime/js/cm-test/recovery.mjs';
|
|
12
|
+
import {snapshotSource,sourceChanges} from '../runtime/js/cm-test/source-snapshot.mjs';
|
|
13
|
+
const root=fileURLToPath(new URL('..',import.meta.url));
|
|
14
|
+
const contract=(kind='logic')=>({schemaVersion:'1.0',feature:'guide',cases:[{id:'TC-001',origin:'user',kind,blocking:true,
|
|
15
|
+
acIds:[],taskIds:[],title:'Reject invalid input',preconditions:[],steps:['Call invalid input'],expected:['Returns error'],cleanup:[]}]});
|
|
16
|
+
function fixture(t,args={}){
|
|
17
|
+
const temp=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-test-host-'))),project=path.join(temp,'project');
|
|
18
|
+
fs.mkdirSync(project);fs.writeFileSync(path.join(project,'input.mjs'),'export const valid = value => value !== null;\n');
|
|
19
|
+
fs.writeFileSync(path.join(project,'AGENTS.md'),'Declared test: node --version\n');
|
|
20
|
+
const cases=path.join(temp,'cases.json');fs.writeFileSync(cases,JSON.stringify(contract()));
|
|
21
|
+
t.after(()=>fs.rmSync(temp,{recursive:true,force:true}));
|
|
22
|
+
const config={skillDir:path.join(root,'skills/cm-test'),project,runtime:'codex',arguments:{cases,logic:true,...args},
|
|
23
|
+
sources:['input.mjs','AGENTS.md'],commands:[],environment:{scope:'local',kind:'web',carrier:'browser',target:'http://127.0.0.1:3000'},logHome:path.join(temp,'logs')};
|
|
24
|
+
return {temp,project,cases,config};
|
|
25
|
+
}
|
|
26
|
+
const logicReply=payload=>({contractDigest:payload.contractDigest,results:payload.contract.cases.filter(item=>item.kind==='logic')
|
|
27
|
+
.map(item=>({id:item.id,verdict:'SUPPORTED',evidence:[{path:'input.mjs',line:1}],explanation:'Invalid input -> validation branch -> rejected'}))});
|
|
28
|
+
async function run(config,call){return createCmTestHost(config,{call}).handle({requestId:'run',operation:'start'});}
|
|
29
|
+
|
|
30
|
+
test('actual shared CLI: Codex and Claude logic -> immutable report and closed original log',async t=>{
|
|
31
|
+
for(const runtime of ['codex','claude']){
|
|
32
|
+
const {temp,config}=fixture(t);config.runtime=runtime;
|
|
33
|
+
const configPath=path.join(temp,'config.json');fs.writeFileSync(configPath,JSON.stringify(config));
|
|
34
|
+
const child=spawn(process.execPath,[path.join(root,'scripts/cm-test-host.mjs'),'serve','--config',configPath],{stdio:['pipe','pipe','pipe']});
|
|
35
|
+
const closed=once(child,'close'),lines=createInterface({input:child.stdout});let sessionId,result,calls=0,stderr='';
|
|
36
|
+
const send=value=>child.stdin.write(JSON.stringify(value)+'\n');child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
37
|
+
t.after(()=>child.kill());
|
|
38
|
+
for await(const line of lines){
|
|
39
|
+
const message=JSON.parse(line);
|
|
40
|
+
if(message.type==='host_ready'){sessionId=message.sessionId;send({requestId:'run',operation:'start'});}
|
|
41
|
+
else if(message.type==='host_request'){
|
|
42
|
+
calls++;assert.equal(message.kind,'qa_logic');
|
|
43
|
+
send({type:'host_result',sessionId,callId:message.callId,requestDigest:message.requestDigest,result:logicReply(message.payload)});
|
|
44
|
+
}else if(message.requestId==='run'){result=message.result;send({type:'host_close',sessionId});}
|
|
45
|
+
}
|
|
46
|
+
assert.equal((await closed)[0],0,stderr);assert.equal(calls,1,JSON.stringify(result));
|
|
47
|
+
assert.equal(result.overall,'REVIEWED',JSON.stringify(result));assert.equal(result.executionPassed,0);
|
|
48
|
+
assert.equal(result.completionAuthorized,false);assert.ok(fs.readFileSync(result.report,'utf8').includes('not execution PASS'));
|
|
49
|
+
const logs=fs.readdirSync(path.join(config.logHome,'runs'),{recursive:true}).filter(name=>name.endsWith('.jsonl'));
|
|
50
|
+
const events=logs.flatMap(name=>fs.readFileSync(path.join(config.logHome,'runs',name),'utf8').trim().split('\n').map(JSON.parse));
|
|
51
|
+
assert.equal(events.at(-1).event,'run_done');assert.ok(events.some(event=>event.event==='test_run'&&event.phase==='complete'));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
test('generation hard-stops with validated inferred drafts, never calls execution',async t=>{
|
|
55
|
+
const {config}=fixture(t);config.arguments={description:'Validation',generateCases:true};let calls=0;
|
|
56
|
+
const result=await run(config,async kind=>{calls++;assert.equal(kind,'test_cases');return {contract:contract(),report:'# Generation\nScope: validation; source input.mjs:1; expected needs confirmation.'};});
|
|
57
|
+
assert.equal(result.overall,'GENERATED',JSON.stringify(result));assert.equal(calls,1);assert.equal(result.executionPassed,0);
|
|
58
|
+
const draft=JSON.parse(fs.readFileSync(result.artifacts[0],'utf8'));
|
|
59
|
+
assert.equal(draft.cases[0].origin,'inferred');assert.match(draft.cases[0].expected[0],/^\[需确认\]/);
|
|
60
|
+
});
|
|
61
|
+
test('all: actual declared command plus synthetic browser evidence, no model command authority',async t=>{
|
|
62
|
+
const {config,cases}=fixture(t);config.arguments={cases,all:true};
|
|
63
|
+
const value=contract();value.cases.push({...contract('browser').cases[0],id:'TC-002'});fs.writeFileSync(cases,JSON.stringify(value));
|
|
64
|
+
config.commands=[{id:'version',command:['node','--version'],caseIds:['TC-001'],declaration:{path:'AGENTS.md',line:1}}];
|
|
65
|
+
const result=await run(config,async(kind,payload)=>{
|
|
66
|
+
if(kind==='qa_logic')return logicReply(payload);
|
|
67
|
+
assert.equal(kind,'qa_browser');fs.mkdirSync(payload.reportDir,{recursive:true});
|
|
68
|
+
const evidence=path.join(payload.reportDir,'browser.md');fs.writeFileSync(evidence,'Synthetic browser observation, not live browser proof');
|
|
69
|
+
return {verdict:'PASS',evidence:[evidence],environment:payload.environment,cleanup:'not_needed'};
|
|
70
|
+
});
|
|
71
|
+
assert.equal(result.overall,'PASS',JSON.stringify(result));assert.equal(result.rows.find(row=>row.kind==='commands').exitCode,0);
|
|
72
|
+
assert.equal(result.executionPassed,2);assert.equal(result.completionAuthorized,false);
|
|
73
|
+
});
|
|
74
|
+
test('source mutation and fabricated evidence block; user changes are not rolled back',async t=>{
|
|
75
|
+
for(const mode of ['drift','bad-line','path-escape']){
|
|
76
|
+
const {config,project}=fixture(t);
|
|
77
|
+
const result=await run(config,async(kind,payload)=>{
|
|
78
|
+
const reply=logicReply(payload);
|
|
79
|
+
if(mode==='drift')fs.writeFileSync(path.join(project,'input.mjs'),'User changed this file');
|
|
80
|
+
if(mode==='bad-line')reply.results[0].evidence[0].line=999;
|
|
81
|
+
if(mode==='path-escape')reply.results[0].evidence[0].path='../outside.mjs';
|
|
82
|
+
return reply;
|
|
83
|
+
});
|
|
84
|
+
assert.equal(result.overall,'BLOCKED',JSON.stringify(result));
|
|
85
|
+
if(mode==='drift'){assert.ok(result.sourceChanges.includes('input.mjs'));assert.equal(fs.readFileSync(path.join(project,'input.mjs'),'utf8'),'User changed this file');}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
test('report aliases into source are rejected before any callback/write',t=>{
|
|
89
|
+
const {config,project,temp}=fixture(t);
|
|
90
|
+
fs.symlinkSync(project,path.join(temp,'alias'),'dir');config.arguments.reportDir=path.join(temp,'alias','src');
|
|
91
|
+
assert.throws(()=>createCmTestHost(config,{call:()=>assert.fail()}),/cm_test_report_path_invalid/);
|
|
92
|
+
});
|
|
93
|
+
test('specs-local logging remains authoritative without mistaking audit writes for source edits',async t=>{
|
|
94
|
+
const {config,project}=fixture(t),specs=path.join(project,'specs'),feature=path.join(specs,'1.guide');
|
|
95
|
+
fs.mkdirSync(feature,{recursive:true});
|
|
96
|
+
for(const name of ['requirements.md','design.md','tasks.md'])fs.writeFileSync(path.join(feature,name),'# Fixture\n');
|
|
97
|
+
fs.writeFileSync(path.join(feature,'test-cases.json'),JSON.stringify(contract()));
|
|
98
|
+
config.arguments={specs,logic:true};
|
|
99
|
+
const result=await run(config,async(kind,payload)=>logicReply(payload));
|
|
100
|
+
assert.equal(result.overall,'REVIEWED',JSON.stringify(result));
|
|
101
|
+
assert.ok(result.report.startsWith(path.join(specs,'.reviews')));
|
|
102
|
+
const events=fs.readFileSync(path.join(specs,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
103
|
+
assert.equal(events.at(-1).event,'run_done');assert.equal(result.sourceChanges.length,0);
|
|
104
|
+
const added=path.join(specs,'2.later');fs.mkdirSync(added);
|
|
105
|
+
for(const name of ['requirements.md','design.md','tasks.md'])fs.writeFileSync(path.join(added,name),'# Later feature\n');
|
|
106
|
+
assert.equal(inspectCmTestRecovery(config,result).status,'recovered');
|
|
107
|
+
});
|
|
108
|
+
test('Git snapshot catches edits within the same dirty status and excludes only this report',t=>{
|
|
109
|
+
const {project}=fixture(t),report=path.join(project,'docs/test-reports/current');
|
|
110
|
+
const git=(...args)=>{const result=spawnSync('git',args,{cwd:project});assert.equal(result.status,0,result.stderr.toString());};
|
|
111
|
+
git('init','-q');git('add','.');git('-c','user.name=Fixture','-c','user.email=fixture@example.invalid','commit','-qm','fixture');
|
|
112
|
+
const file=path.join(project,'input.mjs');fs.writeFileSync(file,'first edit');
|
|
113
|
+
const before=snapshotSource(project,report);fs.writeFileSync(file,'second edit');
|
|
114
|
+
fs.mkdirSync(report,{recursive:true});fs.writeFileSync(path.join(report,'result.md'),'report');
|
|
115
|
+
assert.deepEqual(sourceChanges(before,snapshotSource(project,report)),['input.mjs']);
|
|
116
|
+
});
|
|
117
|
+
test('review regression: existing specs contract cannot upgrade generated draft origin',async t=>{
|
|
118
|
+
const {config,project}=fixture(t),specs=path.join(project,'specs'),feature=path.join(specs,'1.guide');
|
|
119
|
+
fs.mkdirSync(feature,{recursive:true});
|
|
120
|
+
for(const name of ['requirements.md','design.md','tasks.md'])fs.writeFileSync(path.join(feature,name),'# Fixture\n');
|
|
121
|
+
fs.writeFileSync(path.join(feature,'test-cases.json'),JSON.stringify(contract()));
|
|
122
|
+
config.arguments={specs,feature:'1.guide',generateCases:true};let calls=0;
|
|
123
|
+
const result=await run(config,async(kind,payload)=>{
|
|
124
|
+
calls++;assert.equal(kind,'test_cases');assert.equal(payload.operation,'generate');assert.ok(payload.caseText);
|
|
125
|
+
const value=contract();value.cases.push({...value.cases[0],id:'TC-002',origin:'inferred',title:'New inferred case'});
|
|
126
|
+
return {contract:value,report:'# Generation\nExisting and new cases; input.mjs:1; expected intent unconfirmed.'};
|
|
127
|
+
});
|
|
128
|
+
assert.equal(result.overall,'GENERATED',JSON.stringify(result));assert.equal(calls,1);
|
|
129
|
+
const draft=JSON.parse(fs.readFileSync(result.artifacts[0],'utf8'));
|
|
130
|
+
for(const item of draft.cases){assert.equal(item.origin,'inferred');assert.ok(item.expected.every(value=>value.startsWith('[需确认]')));}
|
|
131
|
+
assert.equal(JSON.parse(fs.readFileSync(path.join(feature,'test-cases.json'),'utf8')).cases.length,1);
|
|
132
|
+
});
|
|
133
|
+
test('review regression: missing commands do not hide observed blocking FAIL',async t=>{
|
|
134
|
+
const {config,cases}=fixture(t);config.arguments={cases,all:true};
|
|
135
|
+
fs.writeFileSync(cases,JSON.stringify(contract('browser')));
|
|
136
|
+
const result=await run(config,async(kind,payload)=>{
|
|
137
|
+
assert.equal(kind,'qa_browser');fs.mkdirSync(payload.reportDir,{recursive:true});
|
|
138
|
+
const evidence=path.join(payload.reportDir,'failure.md');fs.writeFileSync(evidence,'Synthetic assertion failure');
|
|
139
|
+
return {verdict:'FAIL',evidence:[evidence],environment:payload.environment,cleanup:'not_needed'};
|
|
140
|
+
});
|
|
141
|
+
assert.equal(result.overall,'FAIL',JSON.stringify(result));assert.ok(result.problems.includes('No declared project commands'));
|
|
142
|
+
assert.equal(result.sourceChanges.length,0);assert.equal(result.executionPassed,0);
|
|
143
|
+
});
|
|
144
|
+
test('recovery: new CLI reads historical result without callbacks, rejects changed report/config',async t=>{
|
|
145
|
+
const {temp,config}=fixture(t);
|
|
146
|
+
const result=await run(config,async(kind,payload)=>logicReply(payload));
|
|
147
|
+
assert.equal(result.overall,'REVIEWED',JSON.stringify(result));
|
|
148
|
+
const configPath=path.join(temp,'recover-config.json');fs.writeFileSync(configPath,JSON.stringify(config));
|
|
149
|
+
const output=spawnSync(process.execPath,[path.join(root,'scripts/cm-test-host.mjs'),'inspect','--config',configPath,
|
|
150
|
+
'--run-id',result.runId,'--log-file',result.logFile],{encoding:'utf8'});
|
|
151
|
+
assert.equal(output.status,0,output.stderr);const restored=JSON.parse(output.stdout);
|
|
152
|
+
assert.equal(restored.status,'recovered');assert.equal(restored.overall,'REVIEWED');
|
|
153
|
+
assert.equal(restored.historical,true);assert.equal(restored.currentSourceVerified,false);assert.equal(restored.automaticReplayAllowed,false);
|
|
154
|
+
fs.unlinkSync(config.arguments.cases);
|
|
155
|
+
assert.equal(inspectCmTestRecovery(config,result).status,'recovered');
|
|
156
|
+
assert.throws(()=>inspectCmTestRecovery({...config,sources:['AGENTS.md']},result),/cm_test_config_changed/);
|
|
157
|
+
fs.appendFileSync(result.report,'User report edit');
|
|
158
|
+
assert.throws(()=>inspectCmTestRecovery(config,result),/cm_test_report_changed/);
|
|
159
|
+
});
|
|
160
|
+
test('recovery: crash prefix returns pending stage, never success or automatic retry',async t=>{
|
|
161
|
+
const {config}=fixture(t);const result=await run(config,async(kind,payload)=>logicReply(payload));
|
|
162
|
+
const events=fs.readFileSync(result.logFile,'utf8').trim().split('\n').map(JSON.parse);
|
|
163
|
+
const stop=events.findIndex(event=>event.event==='decision'&&event.phase==='test_stage');assert.ok(stop>=0);
|
|
164
|
+
fs.writeFileSync(result.logFile,events.slice(0,stop+1).map(event=>JSON.stringify(event)).join('\n')+'\n');
|
|
165
|
+
const before=fs.readFileSync(result.logFile),restored=inspectCmTestRecovery(config,result);
|
|
166
|
+
assert.equal(restored.status,'interrupted');assert.equal(restored.overall,null);assert.equal(restored.lastStage,'qa_logic');
|
|
167
|
+
assert.equal(restored.runClosed,false);assert.equal(restored.automaticReplayAllowed,false);
|
|
168
|
+
assert.deepEqual(fs.readFileSync(result.logFile),before);
|
|
169
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {inspectCmTestLogicResults} from '../runtime/js/cm-test/logic-results.mjs';
|
|
4
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
5
|
+
const contract=()=>({schemaVersion:'1.0',feature:'guide',cases:[{id:'TC-001',origin:'user',kind:'logic',blocking:true,
|
|
6
|
+
acIds:[],taskIds:[],title:'Reject invalid input',preconditions:[],steps:['Call with invalid input'],expected:['Returns an error'],cleanup:[]}]});
|
|
7
|
+
const response=(value,verdict)=>({contractDigest:digest(value),results:[{id:'TC-001',verdict,
|
|
8
|
+
evidence:verdict==='INSUFFICIENT_EVIDENCE'?[]:[{path:'src/input.mjs',line:12}],
|
|
9
|
+
explanation:'Synthetic input -> validation branch -> error result'}]});
|
|
10
|
+
test('static verdicts preserve original FAIL/BLOCKED/REVIEWED without execution PASS',()=>{
|
|
11
|
+
const value=contract();
|
|
12
|
+
for(const [verdict,overall] of [['SUPPORTED','REVIEWED'],['CONTRADICTED','FAIL'],['INSUFFICIENT_EVIDENCE','BLOCKED']]){
|
|
13
|
+
const result=inspectCmTestLogicResults(value,response(value,verdict));
|
|
14
|
+
assert.equal(result.overall,overall);assert.equal(result.counts.executedPassed,0);assert.equal(result.executed,false);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
test('missing cases, stale binding, invented PASS and unconfirmed expectations cannot succeed',()=>{
|
|
18
|
+
const value=contract();
|
|
19
|
+
for(const change of [row=>{row.results=[];},row=>{row.contractDigest='0'.repeat(64);},
|
|
20
|
+
row=>{row.results[0].verdict='PASS';},row=>{row.results[0].evidence=[];}]){
|
|
21
|
+
const row=response(value,'SUPPORTED');change(row);assert.throws(()=>inspectCmTestLogicResults(value,row));
|
|
22
|
+
}
|
|
23
|
+
value.cases[0].origin='inferred';value.cases[0].expected=['[需确认] 当前行为刻画: Returns an error'];
|
|
24
|
+
assert.throws(()=>inspectCmTestLogicResults(value,response(value,'SUPPORTED')));
|
|
25
|
+
assert.equal(inspectCmTestLogicResults(value,response(value,'INSUFFICIENT_EVIDENCE')).overall,'BLOCKED');
|
|
26
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import {spawn,spawnSync} from 'node:child_process';
|
|
7
|
+
import {once} from 'node:events';
|
|
8
|
+
import {createInterface} from 'node:readline';
|
|
9
|
+
import {fileURLToPath} from 'node:url';
|
|
10
|
+
import {snapshotSource,sourceChanges,readSourceFiles} from '../runtime/js/cm-test/source-snapshot.mjs';
|
|
11
|
+
import {openTestSession} from '../runtime/js/cm-test/session.mjs';
|
|
12
|
+
import {createCmTestHost} from '../runtime/js/cm-test/host.mjs';
|
|
13
|
+
const root=fileURLToPath(new URL('..',import.meta.url));
|
|
14
|
+
const item=(id,kind)=>({id,kind,origin:'user',blocking:true,acIds:[],taskIds:[],title:'Synthetic behavior',preconditions:[],steps:['Observe'],expected:['Expected result'],cleanup:[]});
|
|
15
|
+
function fixture(t,{specs=false}={}){
|
|
16
|
+
const temp=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-test-session-'))),project=path.join(temp,'project');
|
|
17
|
+
fs.mkdirSync(project);t.after(()=>fs.rmSync(temp,{recursive:true,force:true}));
|
|
18
|
+
const counter=path.join(temp,'count');
|
|
19
|
+
fs.writeFileSync(path.join(project,'check.mjs'),`import fs from 'node:fs';const p=${JSON.stringify(counter)};fs.appendFileSync(p,'executed\\n');console.log('synthetic command');`);
|
|
20
|
+
fs.writeFileSync(path.join(project,'AGENTS.md'),'Declared command: node check.mjs\n');
|
|
21
|
+
const cases=path.join(temp,'cases.json'),contract={schemaVersion:'1.0',feature:'example',cases:[item('TC-001','logic'),item('TC-002','browser')]};
|
|
22
|
+
fs.writeFileSync(cases,JSON.stringify(contract));
|
|
23
|
+
const config={skillDir:path.join(root,'skills/cm-test'),project,runtime:'codex',arguments:{cases,all:true},sources:['check.mjs','AGENTS.md'],
|
|
24
|
+
commands:[{id:'check',command:['node','check.mjs'],caseIds:['TC-001'],declaration:{path:'AGENTS.md',line:1}}],
|
|
25
|
+
environment:{scope:'local',kind:'web',carrier:'browser',target:'http://127.0.0.1:3000'},logHome:path.join(temp,'logs')};
|
|
26
|
+
if(specs){const base=path.join(project,'specs'),feature=path.join(base,'1.example');fs.mkdirSync(feature,{recursive:true});
|
|
27
|
+
for(const name of ['requirements.md','design.md','tasks.md'])fs.writeFileSync(path.join(feature,name),'# Synthetic\n');
|
|
28
|
+
fs.writeFileSync(path.join(feature,'test-cases.json'),JSON.stringify(contract));config.arguments={specs:base,feature:'1.example',all:true};}
|
|
29
|
+
const configPath=path.join(temp,'config.json');fs.writeFileSync(configPath,JSON.stringify(config));
|
|
30
|
+
return {temp,project,counter,config,configPath,directory:path.join(temp,'session')};
|
|
31
|
+
}
|
|
32
|
+
async function client(t,f,respond){
|
|
33
|
+
const child=spawn(process.execPath,[path.join(root,'scripts/cm-test-host.mjs'),'serve','--config',f.configPath,'--session-dir',f.directory],{stdio:['pipe','pipe','pipe']});
|
|
34
|
+
t.after(()=>{if(child.exitCode===null&&!child.killed)child.kill();});
|
|
35
|
+
let sessionId,seq=0,stderr='';const pending=new Map(),closed=once(child,'close');
|
|
36
|
+
let acceptReady,rejectReady;const ready=new Promise((yes,no)=>{acceptReady=yes;rejectReady=no;});
|
|
37
|
+
const send=value=>child.stdin.write(JSON.stringify(value)+'\n');child.stderr.on('data',bytes=>stderr+=bytes);
|
|
38
|
+
createInterface({input:child.stdout}).on('line',line=>{
|
|
39
|
+
const message=JSON.parse(line);
|
|
40
|
+
if(message.type==='host_ready'){sessionId=message.sessionId;acceptReady();}
|
|
41
|
+
else if(message.type==='host_request')Promise.resolve().then(()=>respond(message,child)).then(result=>{
|
|
42
|
+
if(result!==undefined)send({type:'host_result',sessionId,callId:message.callId,requestDigest:message.requestDigest,result});
|
|
43
|
+
}).catch(rejectReady);
|
|
44
|
+
else if(pending.has(message.requestId)){pending.get(message.requestId)(message);pending.delete(message.requestId);}
|
|
45
|
+
});
|
|
46
|
+
child.on('close',code=>{if(!sessionId)rejectReady(Error(stderr));for(const resolve of pending.values())resolve({closed:code});pending.clear();});
|
|
47
|
+
await ready;
|
|
48
|
+
return {child,request:(operation,fields={})=>new Promise(resolve=>{
|
|
49
|
+
const requestId=`request-${++seq}`;pending.set(requestId,resolve);send({requestId,operation,...fields});}),
|
|
50
|
+
close:async()=>{send({type:'host_close',sessionId});const [code]=await closed;assert.equal(code,0,stderr);}};
|
|
51
|
+
}
|
|
52
|
+
const logic=payload=>({contractDigest:payload.contractDigest,results:[{id:'TC-001',verdict:'SUPPORTED',evidence:[{path:'check.mjs',line:1}],explanation:'Synthetic characterization'}]});
|
|
53
|
+
test('CLI resumes original specs run after command; unknown browser never redispatched, evidence and log preserved',{timeout:20000},async t=>{
|
|
54
|
+
const f=fixture(t,{specs:true});let browserResult;
|
|
55
|
+
let c=await client(t,f,(message,child)=>{
|
|
56
|
+
if(message.kind==='qa_logic')return logic(message.payload);
|
|
57
|
+
assert.equal(message.kind,'qa_browser');fs.mkdirSync(message.payload.reportDir,{recursive:true});
|
|
58
|
+
const evidence=path.join(message.payload.reportDir,'browser.md');fs.writeFileSync(evidence,'Synthetic original observation');
|
|
59
|
+
browserResult={verdict:'PASS',evidence:[evidence],environment:message.payload.environment,cleanup:'not_needed'};
|
|
60
|
+
setImmediate(()=>child.kill('SIGKILL'));
|
|
61
|
+
});
|
|
62
|
+
await c.request('start');assert.equal(fs.readFileSync(f.counter,'utf8'),'executed\n');
|
|
63
|
+
c=await client(t,f,()=>assert.fail('prior calls must not redispatch'));
|
|
64
|
+
const status=(await c.request('status')).result;assert.equal(status.pending.kind,'host');assert.ok(status.logFile);
|
|
65
|
+
assert.ok((await c.request('start')).error);
|
|
66
|
+
assert.equal((await c.request('resume',{resolution:null})).result.stage,'interrupted');
|
|
67
|
+
const receipt={...status.pending,result:browserResult,evidence:'Synthetic original browser receipt',cleanup:'completed'};delete receipt.kind;
|
|
68
|
+
assert.equal((await c.request('resume',{resolution:{...receipt,requestDigest:'0'.repeat(64)}})).result.stage,'interrupted');
|
|
69
|
+
const result=(await c.request('resume',{resolution:receipt})).result;
|
|
70
|
+
assert.equal(result.overall,'PASS',JSON.stringify(result));assert.equal(result.runId,status.runId);await c.close();
|
|
71
|
+
assert.equal(fs.readFileSync(f.counter,'utf8'),'executed\n');
|
|
72
|
+
const events=fs.readFileSync(result.logFile,'utf8').trim().split('\n').map(JSON.parse);
|
|
73
|
+
assert.equal(events.filter(row=>row.event==='run_start').length,1);assert.equal(events.filter(row=>row.event==='run_done').length,1);
|
|
74
|
+
assert.equal(events.filter(row=>row.event==='resource'&&row.phase==='acquired').length,1);
|
|
75
|
+
c=await client(t,f,()=>assert.fail('completed history is read-only'));
|
|
76
|
+
assert.equal((await c.request('resume',{resolution:null})).result.historical,true);
|
|
77
|
+
fs.appendFileSync(result.report,'changed report');assert.ok((await c.request('resume',{resolution:null})).error);await c.close();
|
|
78
|
+
});
|
|
79
|
+
test('pending logic rejects source/config drift and cancellation survives another process',{timeout:12000},async t=>{
|
|
80
|
+
const f=fixture(t);let response;
|
|
81
|
+
let c=await client(t,f,(message,child)=>{response=logic(message.payload);setImmediate(()=>child.kill('SIGKILL'));});await c.request('start');
|
|
82
|
+
c=await client(t,f,()=>assert.fail('must not redispatch'));
|
|
83
|
+
const pending=(await c.request('status')).result.pending;
|
|
84
|
+
const target=path.join(f.project,'AGENTS.md');fs.appendFileSync(target,'User change\n');
|
|
85
|
+
const resolution={key:pending.key,requestDigest:pending.requestDigest,result:response,evidence:'Synthetic receipt',cleanup:'completed'};
|
|
86
|
+
assert.equal((await c.request('resume',{resolution})).result.reason,'cm_test_resume_source_changed');
|
|
87
|
+
await c.request('cancel');await c.close();
|
|
88
|
+
c=await client(t,f,()=>assert.fail('cancel persists'));assert.equal((await c.request('status')).result.stage,'cancelled');
|
|
89
|
+
assert.ok((await c.request('resume',{resolution})).error);await c.close();
|
|
90
|
+
fs.writeFileSync(f.configPath,JSON.stringify({...f.config,commands:[]}));
|
|
91
|
+
await assert.rejects(()=>client(t,f,()=>assert.fail()),/cm_test_session_binding_changed/);
|
|
92
|
+
assert.equal(fs.existsSync(f.counter),false);assert.match(fs.readFileSync(target,'utf8'),/User change/);
|
|
93
|
+
});
|
|
94
|
+
test('recursive initialized submodule snapshot detects dirty content, index and HEAD; missing checkout blocks',t=>{
|
|
95
|
+
const f=fixture(t),repo=path.join(f.temp,'library');fs.mkdirSync(repo);
|
|
96
|
+
const git=(cwd,...args)=>{const result=spawnSync('git',['-C',cwd,...args],{encoding:'utf8'});assert.equal(result.status,0,result.stderr);return result.stdout.trim();};
|
|
97
|
+
const commit=cwd=>git(cwd,'-c','user.name=Fixture','-c','user.email=fixture@example.invalid','commit','-qm','fixture');
|
|
98
|
+
git(repo,'init','-q');fs.writeFileSync(path.join(repo,'lib.mjs'),'export const value=1;\n');git(repo,'add','.');commit(repo);
|
|
99
|
+
git(f.project,'init','-q');git(f.project,'-c','protocol.file.allow=always','submodule','add',repo,'deps/lib');git(f.project,'add','.');commit(f.project);
|
|
100
|
+
const child=path.join(f.project,'deps/lib'),report=path.join(f.temp,'reports'),file=path.join(child,'lib.mjs');
|
|
101
|
+
const before=snapshotSource(f.project,report);assert.equal(readSourceFiles(f.project,['deps/lib/lib.mjs'],before)[0].path,'deps/lib/lib.mjs');
|
|
102
|
+
fs.writeFileSync(file,'first dirty content');const dirty=snapshotSource(f.project,report);fs.writeFileSync(file,'second dirty content');
|
|
103
|
+
assert.ok(sourceChanges(dirty,snapshotSource(f.project,report)).includes('deps/lib/lib.mjs'));
|
|
104
|
+
git(child,'add','.');const staged=snapshotSource(f.project,report);commit(child);
|
|
105
|
+
assert.ok(sourceChanges(staged,snapshotSource(f.project,report)).includes('deps/lib'));
|
|
106
|
+
fs.renameSync(child,path.join(f.temp,'preserved-checkout'));
|
|
107
|
+
assert.throws(()=>snapshotSource(f.project,report),/cm_test_submodule_uninitialized/);
|
|
108
|
+
});
|
|
109
|
+
test('unknown command accepts only bound original result after cleanup; it never invokes perform twice',async t=>{
|
|
110
|
+
const f=fixture(t),source=snapshotSource(f.project,path.join(f.temp,'reports')),binding={fixture:'synthetic'};
|
|
111
|
+
let record=openTestSession(f.directory,f.config),calls=0;
|
|
112
|
+
record.initialize({runId:'test-00000000-0000-0000-0000-000000000001',binding,source,inputs:[]});record.begin(source,null);
|
|
113
|
+
const input={command:f.config.commands[0]},original={observed:{id:'check',command:['node','check.mjs'],outcome:'passed',exitCode:0,evidence:'Synthetic recorded exit'},output:['stdout: synthetic']};
|
|
114
|
+
await assert.rejects(()=>record.effect('command',input,()=>{calls++;throw Error('synthetic crash before result persistence');},()=>source));
|
|
115
|
+
const pending=record.pending;record.close();record=openTestSession(f.directory,f.config);record.validate(binding);
|
|
116
|
+
record.begin(source,null);await assert.rejects(()=>record.effect('command',input,()=>assert.fail('must not rerun'),()=>source),/cm_test_outcome_unknown/);
|
|
117
|
+
const receipt={key:pending.key,requestDigest:pending.requestDigest,result:original,evidence:'Synthetic original process exit and cleanup evidence',cleanup:'completed'};
|
|
118
|
+
assert.throws(()=>record.begin(source,{...receipt,cleanup:'unknown'}),/cm_test_resolution_invalid/);
|
|
119
|
+
record.begin(source,receipt);assert.deepEqual(await record.effect('command',input,()=>assert.fail('must not rerun'),()=>source),original);
|
|
120
|
+
record.close();assert.equal(calls,1);
|
|
121
|
+
const saved=fs.readFileSync(path.join(f.directory,'execution.jsonl'),'utf8').trim().split('\n').map(JSON.parse).find(row=>row.type==='result');
|
|
122
|
+
assert.deepEqual(saved.result.reconciliation,{source:'trusted_host_original_result',key:pending.key,requestDigest:pending.requestDigest,evidence:receipt.evidence,cleanup:'completed'});
|
|
123
|
+
});
|
|
124
|
+
test('recorded report and closed specs log survive interruption immediately before final progress save',{timeout:12000},async t=>{
|
|
125
|
+
const f=fixture(t,{specs:true});f.config.arguments={...f.config.arguments,all:false,logic:true};
|
|
126
|
+
// Use the same original config on both launches; only execution progress is interrupted.
|
|
127
|
+
fs.writeFileSync(f.configPath,JSON.stringify(f.config));
|
|
128
|
+
let session=openTestSession(f.directory,f.config),calls=0;
|
|
129
|
+
const broken=new Proxy(session,{get:(target,key)=>key==='save'?()=>{throw Error('synthetic crash before final progress');}:Reflect.get(target,key)});
|
|
130
|
+
const host=createCmTestHost(f.config,{session:broken,call:async(kind,payload)=>{calls++;assert.equal(kind,'qa_logic');return logic(payload);}});
|
|
131
|
+
await assert.rejects(async()=>{const result=await host.handle({requestId:'first',operation:'start'});assert.fail(JSON.stringify(result));},/synthetic crash/);
|
|
132
|
+
assert.equal(session.pending,null);assert.equal(session.progress,null);const logFile=session.logFile;
|
|
133
|
+
const logBytes=fs.readFileSync(logFile);session.close();
|
|
134
|
+
const c=await client(t,f,()=>assert.fail('completed effects must not redispatch'));
|
|
135
|
+
const result=(await c.request('resume',{resolution:null})).result;
|
|
136
|
+
assert.equal(result.overall,'REVIEWED',JSON.stringify(result));assert.equal(calls,1);
|
|
137
|
+
assert.ok(fs.readFileSync(logFile).equals(logBytes));assert.ok(fs.readFileSync(result.report,'utf8').includes('REVIEWED'));await c.close();
|
|
138
|
+
});
|