@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,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} from 'node:child_process';
|
|
7
|
+
import {once} from 'node:events';
|
|
8
|
+
import {createInterface} from 'node:readline';
|
|
9
|
+
import {fileURLToPath} from 'node:url';
|
|
10
|
+
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
|
11
|
+
for(const mode of ['codex','claude','cancel','cases','materials','draft','self-check'])test(`PRD actual CLI and original log adapter: ${mode}`,{timeout:15000},async()=>{
|
|
12
|
+
const dir=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-prd-host-')));
|
|
13
|
+
for(const name of ['docs','mirror'])fs.mkdirSync(path.join(dir,name));
|
|
14
|
+
fs.writeFileSync(path.join(dir,'docs/input.md'),'Synthetic requirement');
|
|
15
|
+
if(mode==='materials')fs.writeFileSync(path.join(dir,'docs/extra.pdf'),'%PDF synthetic');
|
|
16
|
+
if(mode==='cases'){
|
|
17
|
+
fs.writeFileSync(path.join(dir,'cases.md'),'User cancellation check');
|
|
18
|
+
fs.writeFileSync(path.join(dir,'.cm-workflow.json'),JSON.stringify({version:1,policies:{generate_cases:false}}));
|
|
19
|
+
}
|
|
20
|
+
const child=spawn(process.execPath,[path.join(root,'scripts/cm-prd-host.mjs'),'serve',
|
|
21
|
+
'--skill-dir',path.join(root,'skills/cm-prd'),'--project',dir,'--specs',dir,
|
|
22
|
+
'--runtime',mode==='claude'?'claude':'codex','--allow-log-write',
|
|
23
|
+
...(mode==='cases'?['--cases',path.join(dir,'cases.md')]:[]),
|
|
24
|
+
...(mode==='self-check'?['--allow-review-write','--allow-disposition-write','--allow-spec-write','--host-context','author-context']:[])],
|
|
25
|
+
{env:{...process.env,CM_WORKFLOW_LOG_HOME:path.join(dir,'mirror')},stdio:['pipe','pipe','pipe']});
|
|
26
|
+
const closed=once(child,'close'),lines=createInterface({input:child.stdout});
|
|
27
|
+
let sessionId,calls=0,status,stderr='',checks=0,reviewedDraft,summaries=0,firstSummary,currentSummary;child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
28
|
+
const send=value=>child.stdin.write(JSON.stringify(value)+'\n');
|
|
29
|
+
try{
|
|
30
|
+
for await(const line of lines){
|
|
31
|
+
const message=JSON.parse(line);
|
|
32
|
+
if(message.requestId!=='publish-old-summary')assert.equal(message.error,undefined,JSON.stringify(message));
|
|
33
|
+
if(message.type==='host_ready'){sessionId=message.sessionId;send({requestId:'turn',operation:'start',text:'Analyze'});}
|
|
34
|
+
else if(message.type==='host_request'){
|
|
35
|
+
if(message.kind==='prd_summary'){
|
|
36
|
+
summaries++;
|
|
37
|
+
send({type:'host_result',sessionId,callId:message.callId,requestDigest:message.requestDigest,
|
|
38
|
+
result:{evidenceDigest:message.payload.evidenceDigest,deliveryForm:`Documentation revision ${summaries}`,estimatedTime:'Human review required',
|
|
39
|
+
openQuestions:'None in synthetic fixture',risks:'Synthetic responses, not live verification',contextScope:'Targeted',
|
|
40
|
+
platformReadiness:'Not applicable',uiBaseline:'None',designRisk:[{feature:'1.guide',
|
|
41
|
+
signals:{greenfieldAdr:false,architectureOrDataFlow:false,newRuntimeDependencyOrToolchain:false,
|
|
42
|
+
publicContractDataOrSecurity:false,fiveOrMoreFunctions:false},evidence:['Synthetic documentation-only fixture']}]}});continue;
|
|
43
|
+
}
|
|
44
|
+
if(message.kind==='prd_correct'){
|
|
45
|
+
send({type:'host_result',sessionId,callId:message.callId,requestDigest:message.requestDigest,
|
|
46
|
+
result:{documents:message.payload.documents.map(item=>({path:item.path,
|
|
47
|
+
content:item.path==='1.guide/design.md'?'## 方案摘要\nCorrected synthetic design':item.content})),
|
|
48
|
+
decisions:[{id:'R1',status:'applied',evidence:['Synthetic clarification'],changedPaths:['1.guide/design.md']}]}});continue;
|
|
49
|
+
}
|
|
50
|
+
if(message.kind==='prd_review'){
|
|
51
|
+
assert.equal(mode,'self-check');assert.equal(message.payload.authorContextId,'author-context');
|
|
52
|
+
send({type:'host_result',sessionId,callId:message.callId,requestDigest:message.requestDigest,
|
|
53
|
+
result:{reviewer:'codex-subagent',contextId:'reviewer-context',independent:true,at:'2026-09-08T00:00:00.000Z',
|
|
54
|
+
result:{verdict:'changes_requested',packageDigest:message.payload.package.packageDigest,
|
|
55
|
+
examinedPaths:message.payload.examinedPaths,findings:[{id:'R1',severity:'P2',path:'1.guide/design.md',
|
|
56
|
+
message:'Clarify design',evidence:'Synthetic finding'}],summary:'Synthetic review result'}}});continue;
|
|
57
|
+
}
|
|
58
|
+
if(message.kind==='prd_self_check'){
|
|
59
|
+
checks++;const draft=message.payload.draft;
|
|
60
|
+
send({type:'host_result',sessionId,callId:message.callId,requestDigest:message.requestDigest,
|
|
61
|
+
result:{draftDigest:draft.draftDigest,features:draft.features.map(feature=>({directory:feature.directory,
|
|
62
|
+
checks:draft.mechanicalSelfCheck.pending.map((id,index)=>({id,status:checks===1&&index===0?'failed':'passed',evidence:['Synthetic context check']}))}))}});continue;
|
|
63
|
+
}
|
|
64
|
+
if(message.kind==='prd_generate'){
|
|
65
|
+
assert.ok(['draft','self-check'].includes(mode));assert.equal(message.payload.role.role,'planner');
|
|
66
|
+
send({type:'host_result',sessionId,callId:message.callId,requestDigest:message.requestDigest,
|
|
67
|
+
result:{status:'draft',summary:'Synthetic documentation draft',features:[{name:'guide',testCasesReason:'no_observable_behavior',
|
|
68
|
+
documents:['requirements.md','design.md','tasks.md'].map(file=>({path:file,
|
|
69
|
+
content:file==='requirements.md'?'## 功能需求\n1. [F-001] Guide\n- [ ] [AC-001] Document setup.':file==='tasks.md'?'- [ ] T-001: Update guide':'## 方案摘要\nUnreviewed synthetic design'}))}]}});continue;
|
|
70
|
+
}
|
|
71
|
+
if(message.kind==='prd_materials'){
|
|
72
|
+
assert.equal(mode,'materials');const source=message.payload.sources[0];
|
|
73
|
+
send({type:'host_result',sessionId,callId:message.callId,requestDigest:message.requestDigest,
|
|
74
|
+
result:{status:'processed',records:[{path:source.path,sha256:source.sha256,format:'pdf',pageCount:1,
|
|
75
|
+
pages:[{page:1,text:'Synthetic extracted text',evidence:'synthetic tool result'}]}]}});continue;
|
|
76
|
+
}
|
|
77
|
+
calls++;assert.equal(message.kind,'prd_analyze');
|
|
78
|
+
if(mode==='materials')assert.equal(message.payload.materialEvidence.records[0].pages[0].text,'Synthetic extracted text');
|
|
79
|
+
if(mode==='cases'){
|
|
80
|
+
assert.equal(message.payload.generateCases,false);
|
|
81
|
+
assert.equal(message.payload.sources.userCases.content,'User cancellation check');
|
|
82
|
+
}
|
|
83
|
+
assert.ok(fs.existsSync(path.join(dir,'运行日志.jsonl')));
|
|
84
|
+
if(mode==='cancel'){send({requestId:'cancel',operation:'cancel'});continue;}
|
|
85
|
+
send({type:'host_result',sessionId,callId:message.callId,requestDigest:message.requestDigest,
|
|
86
|
+
result:calls===1?{status:'question',question:'Who uses it?'}:
|
|
87
|
+
{status:'analyzed',summary:'Developer need',sourcePaths:['docs/input.md',
|
|
88
|
+
...(mode==='cases'?[path.join(dir,'cases.md')]:[]),...(mode==='materials'?['docs/extra.pdf']:[])],openQuestions:[]}});
|
|
89
|
+
}else if(message.requestId==='turn'){
|
|
90
|
+
assert.ok(message.result||mode==='cancel');
|
|
91
|
+
if(mode!=='cancel'&&calls===1)send({requestId:'turn',operation:'advance',text:'Developers'});
|
|
92
|
+
else if(['draft','self-check'].includes(mode))send({requestId:'plan',operation:'advance',text:'Generate specification draft'});
|
|
93
|
+
else send({requestId:'status',operation:'status'});
|
|
94
|
+
}else if(message.requestId==='plan'){
|
|
95
|
+
assert.equal(message.result.stage,'draft_ready');send(mode==='self-check'?{requestId:'verify',operation:'advance',text:'Self-check'}:{requestId:'status',operation:'status'});
|
|
96
|
+
}else if(message.requestId==='verify'){
|
|
97
|
+
if(checks===1){assert.equal(message.result.stage,'self_check_failed');send({requestId:'plan',operation:'advance',text:'Fix reported findings'});}
|
|
98
|
+
else{assert.equal(message.result.stage,'self_check_reported_passed');send({requestId:'save',operation:'save_draft'});}
|
|
99
|
+
}else if(message.requestId==='save'){
|
|
100
|
+
assert.equal(message.result.status,'draft_saved');assert.equal(message.result.artifacts.length,3);
|
|
101
|
+
assert.equal(fs.existsSync(path.join(dir,'.cm-specs-status')),false);
|
|
102
|
+
send({requestId:'package',operation:'final_review_package',stage:'split',feature:'1.guide'});
|
|
103
|
+
}else if(message.requestId==='package'){
|
|
104
|
+
assert.equal(message.result.gate.outcome,'dispatch_once');assert.equal(message.result.dispatchAuthorized,false);
|
|
105
|
+
assert.ok(message.result.reviewPackage.content.designSummary);send({requestId:'review',operation:'final_review',stage:'split',feature:'1.guide',mode:'independent'});
|
|
106
|
+
}else if(message.requestId==='review'){
|
|
107
|
+
assert.equal(message.result.reviewState.status,'review_recorded');
|
|
108
|
+
reviewedDraft=message.result.draft;
|
|
109
|
+
assert.ok(fs.existsSync(path.join(dir,'.reviews/prd-guide-split-r1.md')));
|
|
110
|
+
send({requestId:'findings',operation:'review_findings',stage:'split',feature:'1.guide'});
|
|
111
|
+
}else if(message.requestId==='findings'){
|
|
112
|
+
assert.equal(message.result.status,'review_findings_ready');
|
|
113
|
+
assert.equal(message.result.findings[0].id,'R1');
|
|
114
|
+
assert.equal(message.result.next,'resolve_original_findings');
|
|
115
|
+
assert.equal(message.result.completionAuthorized,false);
|
|
116
|
+
// Product owns both original save and the subsequent correction write.
|
|
117
|
+
for(const document of reviewedDraft.features[0].documents)assert.equal(fs.readFileSync(path.join(dir,'1.guide',document.path),'utf8'),document.content);
|
|
118
|
+
send({requestId:'correct',operation:'correct_findings',stage:'split',feature:'1.guide'});
|
|
119
|
+
}else if(message.requestId==='correct'){
|
|
120
|
+
assert.equal(message.result.status,'correction_saved');
|
|
121
|
+
assert.match(fs.readFileSync(path.join(dir,'1.guide/design.md'),'utf8'),/Corrected synthetic design/);
|
|
122
|
+
send({requestId:'inspect-correction',operation:'inspect_correction',stage:'split',feature:'1.guide'});
|
|
123
|
+
}else if(message.requestId==='inspect-correction'){
|
|
124
|
+
assert.equal(message.result.states.every(item=>item.status==='matches_correction'),true);
|
|
125
|
+
send({requestId:'resume-correction',operation:'resume_correction',stage:'split',feature:'1.guide'});
|
|
126
|
+
}else if(message.requestId==='resume-correction'){
|
|
127
|
+
assert.equal(message.result.status,'correction_saved');
|
|
128
|
+
send({requestId:'disposition',operation:'review_disposition',stage:'split',feature:'1.guide',
|
|
129
|
+
packageDigest:message.result.packageDigest,decisions:message.result.decisions,artifacts:message.result.artifacts});
|
|
130
|
+
}else if(message.requestId==='disposition'){
|
|
131
|
+
assert.equal(message.result.status,'disposition_recorded');
|
|
132
|
+
assert.equal(message.result.gate.disposition,'applied');assert.equal(checks,3);
|
|
133
|
+
assert.equal(message.result.completionAuthorized,false);
|
|
134
|
+
send({requestId:'summary',operation:'prepare_summary'});
|
|
135
|
+
}else if(message.requestId==='summary'){
|
|
136
|
+
assert.equal(message.result.status,'human_summary_prepared');assert.equal(message.result.readyForAwaitingReview,true);
|
|
137
|
+
assert.equal(message.result.totals.tasks,1);assert.equal(message.result.checklist.every(item=>!item.checked),true);
|
|
138
|
+
firstSummary=message.result;send({requestId:'summary-again',operation:'prepare_summary'});
|
|
139
|
+
}else if(message.requestId==='summary-again'){
|
|
140
|
+
currentSummary=message.result;
|
|
141
|
+
assert.equal(currentSummary.evidenceDigest,firstSummary.evidenceDigest);
|
|
142
|
+
assert.notEqual(currentSummary.summaryDigest,firstSummary.summaryDigest);
|
|
143
|
+
send({requestId:'publish-old-summary',operation:'publish_summary',summaryDigest:firstSummary.summaryDigest});
|
|
144
|
+
}else if(message.requestId==='publish-old-summary'){
|
|
145
|
+
assert.equal(message.error.code,'host_request_failed');
|
|
146
|
+
assert.equal(fs.existsSync(path.join(dir,'.cm-specs-status')),false);
|
|
147
|
+
send({requestId:'publish-summary',operation:'publish_summary',summaryDigest:currentSummary.summaryDigest});
|
|
148
|
+
}else if(message.requestId==='publish-summary'){
|
|
149
|
+
assert.equal(message.result.status,'awaiting_review');assert.equal(message.result.completionAuthorized,false);
|
|
150
|
+
assert.equal(JSON.parse(fs.readFileSync(path.join(dir,'.cm-specs-status'))).status,'awaiting_review');
|
|
151
|
+
send({requestId:'status',operation:'status'});
|
|
152
|
+
}else if(message.requestId==='status'){status=message.result;send({type:'host_close',sessionId});}
|
|
153
|
+
}
|
|
154
|
+
assert.equal((await closed)[0],0,stderr);
|
|
155
|
+
assert.equal(status.stage,mode==='cancel'?'cancelled':mode==='draft'?'draft_ready':mode==='self-check'?'self_check_reported_passed':'analysis_ready');
|
|
156
|
+
if(mode==='draft'){
|
|
157
|
+
assert.equal(status.draft.features[0].directory,'1.guide');
|
|
158
|
+
assert.equal(fs.existsSync(path.join(dir,'1.guide')),false);
|
|
159
|
+
}
|
|
160
|
+
const events=fs.readFileSync(path.join(dir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
161
|
+
assert.equal(events.filter(event=>event.event==='run_start').length,1);
|
|
162
|
+
const done=events.filter(event=>event.event==='run_done');assert.equal(done.length,1);
|
|
163
|
+
assert.equal(done[0].outcome,mode==='cancel'?'cancelled':'incomplete');
|
|
164
|
+
assert.equal(events.filter(event=>event.event==='decision').length,calls+(mode==='draft'?1:mode==='self-check'?2:0));
|
|
165
|
+
assert.equal(fs.readFileSync(path.join(dir,'docs/input.md'),'utf8'),'Synthetic requirement');
|
|
166
|
+
assert.equal(fs.existsSync(path.join(dir,'.cm-specs-status')),mode==='self-check');
|
|
167
|
+
assert.equal(status.completionAuthorized,false);
|
|
168
|
+
}finally{child.kill();lines.close();await closed;fs.rmSync(dir,{recursive:true,force:true});}
|
|
169
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
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 {fileURLToPath} from 'node:url';
|
|
7
|
+
import {createCmPrdAnalysis} from '../runtime/js/cm-prd/analysis.mjs';
|
|
8
|
+
import {inspectPrdMaterialResults} from '../runtime/js/cm-prd/materials.mjs';
|
|
9
|
+
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
|
10
|
+
const html=source=>({path:source.path,sha256:source.sha256,format:'html',pages:[{url:'fixture://page',
|
|
11
|
+
interactiveCount:1,evidence:'synthetic enumeration',elements:[{id:'save',action:'click',result:'no response',
|
|
12
|
+
kind:'dead_zone',screenshot:'synthetic screenshot',question:'Should Save work?'}]}]});
|
|
13
|
+
test('hash and element coverage reject incomplete host material reports',()=>{
|
|
14
|
+
const source={path:'docs/page.html',sha256:'a'.repeat(64),format:'html'};
|
|
15
|
+
const report={status:'processed',records:[html(source)]};
|
|
16
|
+
assert.equal(inspectPrdMaterialResults(report,[source]).independentVerification,false);
|
|
17
|
+
for(const mutate of [x=>x.records[0].sha256='b'.repeat(64),x=>x.records[0].pages[0].interactiveCount=2,
|
|
18
|
+
x=>x.records[0].pages[0].elements[0].question=null]){
|
|
19
|
+
const copy=structuredClone(report);mutate(copy);assert.throws(()=>inspectPrdMaterialResults(copy,[source]));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
test('material processing precedes analysis; dead zones ask user and cache is reused',async t=>{
|
|
23
|
+
const dir=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-prd-materials-')));
|
|
24
|
+
t.after(()=>fs.rmSync(dir,{recursive:true,force:true}));fs.mkdirSync(path.join(dir,'docs'));
|
|
25
|
+
fs.writeFileSync(path.join(dir,'docs/page.html'),'<button>Save</button>');
|
|
26
|
+
fs.writeFileSync(path.join(dir,'docs/input.pdf'),'%PDF synthetic');
|
|
27
|
+
let processed=0,analyzed=0;
|
|
28
|
+
const host=createCmPrdAnalysis({input:{skillDir:path.join(root,'skills/cm-prd'),project:dir,specs:dir},
|
|
29
|
+
runtime:'codex',record:async()=>{},processMaterials:async payload=>{
|
|
30
|
+
processed++;return {status:'processed',records:payload.sources.map(source=>source.format==='html'?html(source):
|
|
31
|
+
{path:source.path,sha256:source.sha256,format:'pdf',pageCount:1,
|
|
32
|
+
pages:[{page:1,text:'Extracted synthetic requirement',evidence:'synthetic PDF tool result'}]})};
|
|
33
|
+
},analyze:async payload=>{
|
|
34
|
+
analyzed++;assert.equal(payload.messages.at(-1).text,'Yes, Save must work');
|
|
35
|
+
assert.equal(payload.materialEvidence.records.length,2);
|
|
36
|
+
return {status:'analyzed',summary:'Save supported',sourcePaths:['docs/page.html','docs/input.pdf'],openQuestions:[]};
|
|
37
|
+
}});
|
|
38
|
+
assert.equal((await host.advance('Analyze')).stage,'awaiting_user');assert.equal(analyzed,0);
|
|
39
|
+
assert.equal((await host.advance('Yes, Save must work')).stage,'analysis_ready');
|
|
40
|
+
assert.equal(processed,1);assert.equal(analyzed,1);
|
|
41
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
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} from 'node:child_process';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {claimPrdReview,inspectPrdReview} from './cm-prd-review-gate.mjs';
|
|
9
|
+
const script=fileURLToPath(new URL('./cm-prd-review-gate.mjs',import.meta.url));
|
|
10
|
+
function fixture(t){
|
|
11
|
+
const dir=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-prd-claim-')));
|
|
12
|
+
t.after(()=>fs.rmSync(dir,{recursive:true,force:true}));fs.mkdirSync(path.join(dir,'.reviews'));
|
|
13
|
+
const args={stage:'split',feature:'guide',evidence:path.join(dir,'.reviews/prd-guide-split-r1.md'),
|
|
14
|
+
receipt:path.join(dir,'.reviews/prd-guide-split-disposition.json'),package_sha256:'a'.repeat(64)};
|
|
15
|
+
return {dir,args,file:path.join(dir,'.reviews/prd-guide-split-dispatch.json')};
|
|
16
|
+
}
|
|
17
|
+
test('persisted attempt prevents repeat and existing r1 resumes original disposition',t=>{
|
|
18
|
+
const {args,file}=fixture(t);assert.equal(inspectPrdReview(args).outcome,'dispatch_once');
|
|
19
|
+
const claimed=claimPrdReview(args);assert.equal(claimed.outcome,'dispatch_claimed');assert.equal(claimed.providerAuthorized,false);
|
|
20
|
+
assert.equal(fs.statSync(file).mode&0o777,0o600);
|
|
21
|
+
assert.deepEqual(inspectPrdReview(args),{stage:'split',feature:'guide',outcome:'dispatch_unknown',package_sha256:'a'.repeat(64)});
|
|
22
|
+
assert.throws(()=>claimPrdReview(args),/already consumed/);
|
|
23
|
+
fs.writeFileSync(args.evidence,'---\nat: 2026-09-08T00:00:00Z\nreviewer: codex-subagent\nindependent: true\nscope:\n - 1.guide/tasks.md\n---\nSynthetic result');
|
|
24
|
+
assert.equal(inspectPrdReview(args).outcome,'resume_disposition');
|
|
25
|
+
});
|
|
26
|
+
test('partial dispatch records remain blocking, never reset',t=>{
|
|
27
|
+
const {args,file}=fixture(t);fs.writeFileSync(file,'{');
|
|
28
|
+
assert.throws(()=>inspectPrdReview(args));assert.throws(()=>claimPrdReview(args));assert.equal(fs.readFileSync(file,'utf8'),'{');
|
|
29
|
+
});
|
|
30
|
+
test('two actual CLI processes can claim only once; fresh inspector sees unknown',async t=>{
|
|
31
|
+
const {args}=fixture(t);
|
|
32
|
+
const run=command=>new Promise((resolve,reject)=>{
|
|
33
|
+
const flags=Object.entries(args).filter(([key])=>command==='claim'||key!=='package_sha256')
|
|
34
|
+
.flatMap(([key,value])=>[`--${key.replaceAll('_','-')}`,value]);
|
|
35
|
+
const child=spawn(process.execPath,[script,command,...flags]);let stdout='',stderr='';
|
|
36
|
+
child.stdout.on('data',bytes=>{stdout+=bytes;});child.stderr.on('data',bytes=>{stderr+=bytes;});
|
|
37
|
+
child.on('error',reject);child.on('close',code=>resolve({code,stdout,stderr}));
|
|
38
|
+
});
|
|
39
|
+
const results=await Promise.all([run('claim'),run('claim')]);assert.equal(results.filter(result=>result.code===0).length,1);
|
|
40
|
+
const after=await run('inspect');assert.equal(after.code,0,after.stderr);
|
|
41
|
+
assert.equal(JSON.parse(after.stdout).outcome,'dispatch_unknown');
|
|
42
|
+
});
|
|
@@ -0,0 +1,196 @@
|
|
|
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 {createHash} from 'node:crypto';
|
|
7
|
+
import {spawnSync} from 'node:child_process';
|
|
8
|
+
import {preparePrdReview} from '../runtime/js/cm-prd/review-preparation.mjs';
|
|
9
|
+
import {publishPrdReview} from '../runtime/js/cm-prd/review-publication.mjs';
|
|
10
|
+
import {recordPrdHostDisposition,createPrdDispositionOwner} from '../runtime/js/cm-prd/review-disposition.mjs';
|
|
11
|
+
import {createPrdCorrectionOwner,inspectPrdCorrectionRecovery,resumePrdCorrection} from '../runtime/js/cm-prd/review-correction.mjs';
|
|
12
|
+
import {createPrdSummaryOwner,publishPrdAwaitingReview} from '../runtime/js/cm-prd/summary.mjs';
|
|
13
|
+
import {claimPrdReview} from './cm-prd-review-gate.mjs';
|
|
14
|
+
const sha=content=>createHash('sha256').update(content).digest('hex');
|
|
15
|
+
function fixture(t,{stage='design',finding=false,blocked=false,twoFindings=false}={}){
|
|
16
|
+
const specs=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-prd-disposition-')));
|
|
17
|
+
t.after(()=>fs.rmSync(specs,{recursive:true,force:true}));fs.mkdirSync(path.join(specs,'.reviews'));
|
|
18
|
+
const feature='1.guide',documents=[{path:'requirements.md',content:'## 功能需求\n1. [F-001] Guide\n- [ ] [AC-001] Document setup.'},
|
|
19
|
+
{path:'design.md',content:'## 方案摘要\nDocumentation'}, {path:'tasks.md',content:'- [ ] T-001: Guide'}];
|
|
20
|
+
const prepared=preparePrdReview({specs,stage,feature,draft:{draftDigest:'a'.repeat(64),features:[{name:'guide',directory:feature,documents}]}});
|
|
21
|
+
claimPrdReview({...prepared.paths,package_sha256:prepared.packageDigest});
|
|
22
|
+
const findings=finding?[{id:'R1',severity:'P2',path:'1.guide/design.md',message:'Clarify design',evidence:'Synthetic'}]:[];
|
|
23
|
+
if(twoFindings)findings.push({...findings[0],id:'R2',message:'Clarify another decision'});
|
|
24
|
+
publishPrdReview({specs,reviewPackage:prepared.reviewPackage,packageDigest:prepared.packageDigest,authorContextId:'author',
|
|
25
|
+
response:{reviewer:'codex-subagent',contextId:'reviewer',independent:true,at:'2026-09-08T00:00:00.000Z',
|
|
26
|
+
result:{verdict:blocked?'blocked':finding?'changes_requested':'approved',packageDigest:prepared.packageDigest,
|
|
27
|
+
examinedPaths:(stage==='design'?documents.slice(0,2):documents).map(item=>`${feature}/${item.path}`).sort(),findings,summary:'Synthetic review'}}});
|
|
28
|
+
const args={specs,stage,feature,packageDigest:prepared.packageDigest,decisions:[],
|
|
29
|
+
artifacts:documents.map(item=>({path:`${feature}/${item.path}`,sha256:sha(item.content)})),writeEnabled:true};
|
|
30
|
+
const save=()=>{fs.mkdirSync(path.join(specs,feature));for(const item of documents)fs.writeFileSync(path.join(specs,feature,item.path),item.content,{mode:0o600});};
|
|
31
|
+
return {args,save,receipt:prepared.paths.receipt};
|
|
32
|
+
}
|
|
33
|
+
test('no-findings requires saved original artifacts and records only original receipt',t=>{
|
|
34
|
+
const {args,save,receipt}=fixture(t);assert.throws(()=>recordPrdHostDisposition(args),/not_saved/);
|
|
35
|
+
save();const out=recordPrdHostDisposition(args);assert.equal(out.gate.disposition,'no_findings');
|
|
36
|
+
assert.equal(out.completionAuthorized,false);assert.equal(fs.existsSync(path.join(args.specs,'.cm-specs-status')),false);
|
|
37
|
+
const before=fs.readFileSync(receipt);assert.equal(recordPrdHostDisposition(args).outcome,'already_recorded');
|
|
38
|
+
assert.deepEqual(fs.readFileSync(receipt),before);
|
|
39
|
+
});
|
|
40
|
+
test('applied design maps exact finding and changed artifact to the original r1',t=>{
|
|
41
|
+
const {args,save}=fixture(t,{finding:true});save();
|
|
42
|
+
args.decisions=[{id:'R1',status:'applied',evidence:['Clarified original ambiguity'],changedPaths:['1.guide/design.md']}];
|
|
43
|
+
assert.throws(()=>recordPrdHostDisposition(args),/unaccounted_change/);
|
|
44
|
+
const content='## 方案摘要\nClarified documentation';fs.writeFileSync(path.join(args.specs,'1.guide/design.md'),content);
|
|
45
|
+
args.artifacts.find(item=>item.path==='1.guide/design.md').sha256=sha(content);
|
|
46
|
+
assert.equal(recordPrdHostDisposition(args).gate.disposition,'applied');
|
|
47
|
+
});
|
|
48
|
+
test('escalated findings remain visible for human decision; blocked and missing coverage cannot record',t=>{
|
|
49
|
+
const {args,save}=fixture(t,{finding:true});save();assert.throws(()=>recordPrdHostDisposition(args),/coverage/);
|
|
50
|
+
args.decisions=[{id:'R1',status:'escalated',evidence:['Requires human decision'],changedPaths:[]}];
|
|
51
|
+
const result=recordPrdHostDisposition(args);assert.equal(result.unresolvedFindings.length,1);
|
|
52
|
+
assert.equal(result.next,'include_unresolved_in_human_summary');
|
|
53
|
+
const blocked=fixture(t,{blocked:true});blocked.save();assert.throws(()=>recordPrdHostDisposition(blocked.args),/review_blocked/);
|
|
54
|
+
});
|
|
55
|
+
test('write enable and original package identity are required',t=>{
|
|
56
|
+
const {args,save,receipt}=fixture(t);save();
|
|
57
|
+
assert.throws(()=>recordPrdHostDisposition({...args,writeEnabled:false}),/not_enabled/);
|
|
58
|
+
assert.throws(()=>recordPrdHostDisposition({...args,packageDigest:'b'.repeat(64)}),/package_changed/);
|
|
59
|
+
assert.equal(fs.existsSync(receipt),false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('split no-findings binds all artifacts; applied split waits for the original self-check',t=>{
|
|
63
|
+
const clean=fixture(t,{stage:'split'});clean.save();
|
|
64
|
+
assert.equal(recordPrdHostDisposition(clean.args).gate.disposition,'no_findings');
|
|
65
|
+
assert.equal(JSON.parse(fs.readFileSync(clean.receipt)).artifacts.length,3);
|
|
66
|
+
const {args,save,receipt}=fixture(t,{stage:'split',finding:true});save();
|
|
67
|
+
const content='## 方案摘要\nCorrected design';fs.writeFileSync(path.join(args.specs,'1.guide/design.md'),content);
|
|
68
|
+
args.artifacts.find(item=>item.path==='1.guide/design.md').sha256=sha(content);
|
|
69
|
+
args.decisions=[{id:'R1',status:'applied',evidence:['Synthetic correction'],changedPaths:['1.guide/design.md']}];
|
|
70
|
+
assert.throws(()=>recordPrdHostDisposition(args),/split_self_check_required/);
|
|
71
|
+
assert.equal(fs.existsSync(receipt),false);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('aggregate receipt cannot authenticate swapped per-finding dispositions',t=>{
|
|
75
|
+
const {args,save,receipt}=fixture(t,{finding:true,twoFindings:true});save();
|
|
76
|
+
const content='## 方案摘要\nCorrected documentation';fs.writeFileSync(path.join(args.specs,'1.guide/design.md'),content);
|
|
77
|
+
args.artifacts.find(item=>item.path==='1.guide/design.md').sha256=sha(content);
|
|
78
|
+
args.decisions=[{id:'R1',status:'applied',evidence:['Corrected'],changedPaths:['1.guide/design.md']},
|
|
79
|
+
{id:'R2',status:'escalated',evidence:['Human decision'],changedPaths:[]}];
|
|
80
|
+
assert.equal(recordPrdHostDisposition(args).unresolvedFindings[0].id,'R2');
|
|
81
|
+
const before=fs.readFileSync(receipt);
|
|
82
|
+
args.decisions[0].id='R2';args.decisions[1].id='R1';
|
|
83
|
+
const result=recordPrdHostDisposition(args);
|
|
84
|
+
assert.equal(result.status,'disposition_details_need_verification');
|
|
85
|
+
assert.equal(result.unresolvedFindings,undefined);assert.equal(result.decisions,undefined);
|
|
86
|
+
assert.deepEqual(fs.readFileSync(receipt),before);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
for(const mode of ['passed','failed','drift','cancelled'])test(`split correction owner: ${mode}`,async t=>{
|
|
90
|
+
const {args,save,receipt}=fixture(t,{stage:'split',finding:true});save();
|
|
91
|
+
const content='## 方案摘要\nCorrected documentation';fs.writeFileSync(path.join(args.specs,'1.guide/design.md'),content);
|
|
92
|
+
args.artifacts.find(item=>item.path==='1.guide/design.md').sha256=sha(content);
|
|
93
|
+
args.decisions=[{id:'R1',status:'applied',evidence:['Synthetic correction'],changedPaths:['1.guide/design.md']}];
|
|
94
|
+
let calls=0;const controller=new AbortController();
|
|
95
|
+
const owner=createPrdDispositionOwner({checkContext:async({draft})=>{
|
|
96
|
+
calls++;
|
|
97
|
+
if(mode==='drift')fs.appendFileSync(path.join(args.specs,'1.guide/tasks.md'),'\nConcurrent edit');
|
|
98
|
+
if(mode==='cancelled')controller.abort();
|
|
99
|
+
return {draftDigest:draft.draftDigest,features:[{directory:'1.guide',checks:draft.mechanicalSelfCheck.pending
|
|
100
|
+
.map(id=>({id,status:mode==='failed'?'failed':'passed',evidence:['Synthetic context check']}))}]};
|
|
101
|
+
}});
|
|
102
|
+
if(['drift','cancelled'].includes(mode))await assert.rejects(owner(args,controller.signal),/not_saved|cancelled/);
|
|
103
|
+
else{
|
|
104
|
+
const result=await owner(args,controller.signal);
|
|
105
|
+
assert.equal(result.status,mode==='passed'?'disposition_recorded':'disposition_self_check_failed');
|
|
106
|
+
assert.equal(result.completionAuthorized,false);
|
|
107
|
+
}
|
|
108
|
+
assert.equal(calls,1);assert.equal(fs.existsSync(receipt),mode==='passed');
|
|
109
|
+
if(mode==='failed')assert.equal((await owner(args,controller.signal)).status,'disposition_self_check_failed');
|
|
110
|
+
assert.equal(calls,1);
|
|
111
|
+
if(mode!=='drift'){
|
|
112
|
+
// Reconstruct crash after durable result but before the original receipt.
|
|
113
|
+
if(mode==='passed')fs.unlinkSync(receipt);
|
|
114
|
+
const moduleUrl=new URL('../runtime/js/cm-prd/review-disposition.mjs',import.meta.url).href;
|
|
115
|
+
const fresh=spawnSync(process.execPath,['--input-type=module','-e',
|
|
116
|
+
`import {createPrdDispositionOwner} from ${JSON.stringify(moduleUrl)}; const owner=createPrdDispositionOwner({checkContext:async()=>{throw Error('must_not_redispatch')}}); process.stdout.write(JSON.stringify(await owner(${JSON.stringify(args)},new AbortController().signal)));`],
|
|
117
|
+
{encoding:'utf8',timeout:5000});
|
|
118
|
+
assert.equal(fresh.status,0,fresh.stderr);
|
|
119
|
+
assert.equal(JSON.parse(fresh.stdout).status,mode==='passed'?'disposition_recorded':mode==='failed'?'disposition_self_check_failed':'disposition_self_check_unknown');
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('invalid UTF-8 cannot become replacement text in correction self-check',async t=>{
|
|
124
|
+
const {args,save,receipt}=fixture(t,{stage:'split',finding:true});save();
|
|
125
|
+
const bytes=Buffer.from([0xff,0xfe]);fs.writeFileSync(path.join(args.specs,'1.guide/design.md'),bytes);
|
|
126
|
+
args.artifacts.find(item=>item.path==='1.guide/design.md').sha256=sha(bytes);
|
|
127
|
+
args.decisions=[{id:'R1',status:'applied',evidence:['Claimed correction'],changedPaths:['1.guide/design.md']}];
|
|
128
|
+
let calls=0;const owner=createPrdDispositionOwner({checkContext:async()=>{calls++;}});
|
|
129
|
+
await assert.rejects(owner(args,new AbortController().signal),/encoded data was not valid/);
|
|
130
|
+
assert.equal(calls,0);assert.equal(fs.existsSync(receipt),false);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
for(const mode of ['saved','partial','drift','outside','completed-task','cancelled'])test(`host correction applies original findings: ${mode}`,async t=>{
|
|
134
|
+
const {args,save,receipt}=fixture(t,{stage:'split',finding:true});save();
|
|
135
|
+
const controller=new AbortController();let calls=0;
|
|
136
|
+
const owner=createPrdCorrectionOwner({correct:async({documents})=>{
|
|
137
|
+
calls++;if(mode==='drift')fs.appendFileSync(path.join(args.specs,'1.guide/tasks.md'),'\nUser edit');
|
|
138
|
+
if(mode==='cancelled')controller.abort();
|
|
139
|
+
const output=documents.map(item=>({path:item.path,content:item.content+(item.path.endsWith('design.md')?'\nClarified':'')}));
|
|
140
|
+
if(mode==='partial')output.find(item=>item.path.endsWith('tasks.md')).content+='\nClarified task detail';
|
|
141
|
+
if(mode==='outside')output[0].path='../outside.md';
|
|
142
|
+
if(mode==='completed-task')output.find(item=>item.path.endsWith('tasks.md')).content='- [x] T-001: Guide';
|
|
143
|
+
return {documents:output,decisions:[{id:'R1',status:'applied',evidence:['Clarified'],
|
|
144
|
+
changedPaths:['1.guide/design.md',...(['completed-task','partial'].includes(mode)?['1.guide/tasks.md']:[])]}]};
|
|
145
|
+
}});
|
|
146
|
+
const run=()=>owner({specs:args.specs,stage:'split',feature:'1.guide',writeEnabled:true},controller.signal);
|
|
147
|
+
if(!['saved','partial'].includes(mode))await assert.rejects(run);
|
|
148
|
+
else{
|
|
149
|
+
const result=await run();assert.equal(result.status,'correction_saved');assert.equal(result.completionAuthorized,false);
|
|
150
|
+
assert.match(fs.readFileSync(path.join(args.specs,'1.guide/design.md'),'utf8'),/Clarified/);
|
|
151
|
+
const archive=fs.readFileSync(path.join(args.specs,result.archive),'utf8');assert.match(archive,/"before"/);assert.match(archive,/"decisions"/);
|
|
152
|
+
assert.equal((await run()).status,'correction_recovery_required');assert.equal(calls,1);
|
|
153
|
+
const input={specs:args.specs,stage:'split',feature:'1.guide'};
|
|
154
|
+
assert.equal(inspectPrdCorrectionRecovery(input).states.every(item=>item.status==='matches_correction'),true);
|
|
155
|
+
const original=JSON.parse(archive.match(/\n```json\n([^\n]+)\n```/)[1]);
|
|
156
|
+
const design=original.before.find(item=>item.path==='1.guide/design.md');
|
|
157
|
+
// Reconstruct a crash prefix: archive durable, original design not replaced.
|
|
158
|
+
fs.writeFileSync(path.join(args.specs,design.path),design.content);
|
|
159
|
+
assert.equal(inspectPrdCorrectionRecovery(input).states.some(item=>item.status==='needs_correction'),true);
|
|
160
|
+
assert.throws(()=>resumePrdCorrection({...input,writeEnabled:false},new AbortController().signal),/not_enabled/);
|
|
161
|
+
const moduleUrl=new URL('../runtime/js/cm-prd/review-correction.mjs',import.meta.url).href;
|
|
162
|
+
const fresh=spawnSync(process.execPath,['--input-type=module','-e',
|
|
163
|
+
`import {resumePrdCorrection} from ${JSON.stringify(moduleUrl)}; process.stdout.write(JSON.stringify(resumePrdCorrection(${JSON.stringify({...input,writeEnabled:true})},new AbortController().signal)));`],
|
|
164
|
+
{encoding:'utf8',timeout:5000});
|
|
165
|
+
assert.equal(fresh.status,0,fresh.stderr);assert.equal(JSON.parse(fresh.stdout).status,'correction_saved');
|
|
166
|
+
assert.equal(calls,1);assert.match(fs.readFileSync(path.join(args.specs,design.path),'utf8'),/Clarified/);
|
|
167
|
+
fs.appendFileSync(path.join(args.specs,design.path),'\nUser edit');
|
|
168
|
+
assert.throws(()=>inspectPrdCorrectionRecovery(input),/recovery_conflict/);
|
|
169
|
+
}
|
|
170
|
+
assert.equal(fs.existsSync(receipt),false);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
for(const mode of ['ready','design-required','missing-review','drift'])test(`human summary and awaiting-review boundary: ${mode}`,async t=>{
|
|
174
|
+
const {args,save}=fixture(t,{stage:'split'});save();
|
|
175
|
+
if(mode!=='missing-review')recordPrdHostDisposition(args);
|
|
176
|
+
const owner=createPrdSummaryOwner({summarize:async({evidenceDigest})=>{
|
|
177
|
+
if(mode==='drift')fs.appendFileSync(path.join(args.specs,'1.guide/tasks.md'),'\nUser change');
|
|
178
|
+
return {evidenceDigest,deliveryForm:'Documentation',estimatedTime:'Unknown',openQuestions:'None in fixture',risks:'Synthetic',
|
|
179
|
+
contextScope:'Targeted',platformReadiness:'Not applicable',uiBaseline:'None',designRisk:[{feature:'1.guide',
|
|
180
|
+
signals:{greenfieldAdr:false,architectureOrDataFlow:mode==='design-required',newRuntimeDependencyOrToolchain:false,
|
|
181
|
+
publicContractDataOrSecurity:false,fiveOrMoreFunctions:false},evidence:['Synthetic fixture']}]};
|
|
182
|
+
}});
|
|
183
|
+
if(mode==='drift'){await assert.rejects(owner(args.specs,new AbortController().signal));return;}
|
|
184
|
+
const summary=await owner(args.specs,new AbortController().signal);
|
|
185
|
+
assert.equal(summary.readyForAwaitingReview,mode==='ready');
|
|
186
|
+
const publish=()=>publishPrdAwaitingReview({specs:args.specs,summary,writeEnabled:true});
|
|
187
|
+
if(mode!=='ready')assert.throws(publish,/not_ready/);
|
|
188
|
+
else{
|
|
189
|
+
assert.equal(summary.totals.tasks,1);assert.equal(summary.checklist.every(item=>!item.checked),true);
|
|
190
|
+
assert.throws(()=>publishPrdAwaitingReview({specs:args.specs,summary,writeEnabled:false}),/not_enabled/);
|
|
191
|
+
assert.equal(publish().status,'awaiting_review');
|
|
192
|
+
const status=JSON.parse(fs.readFileSync(path.join(args.specs,'.cm-specs-status')));
|
|
193
|
+
assert.equal(status.status,'awaiting_review');assert.equal(status.specFiles.length,3);
|
|
194
|
+
assert.throws(publish,/inputs_changed/);
|
|
195
|
+
}
|
|
196
|
+
});
|