@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,272 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Recovery fixtures for single-attempt CM PRD reviews."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
import tempfile
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
15
|
+
SCRIPT = ROOT / "scripts" / "cm-prd-review-gate.py"
|
|
16
|
+
if os.environ.get("CM_PRD_REVIEW_GATE_IMPL") == "js":
|
|
17
|
+
SCRIPT = SCRIPT.with_suffix(".mjs")
|
|
18
|
+
elif os.environ.get("CM_PRD_REVIEW_GATE_IMPL") == "oracle":
|
|
19
|
+
SCRIPT = ROOT / "scripts" / "fixtures" / "prd-review-gate-python-oracle.py"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def invoke(*args: str, expected_exit: int = 0) -> dict[str, object]:
|
|
23
|
+
result = subprocess.run(
|
|
24
|
+
[os.environ.get("CM_NODE_BIN", "node") if SCRIPT.suffix == ".mjs" else sys.executable, str(SCRIPT), *args],
|
|
25
|
+
cwd=ROOT,
|
|
26
|
+
text=True,
|
|
27
|
+
capture_output=True,
|
|
28
|
+
check=False,
|
|
29
|
+
)
|
|
30
|
+
if result.returncode != expected_exit:
|
|
31
|
+
raise AssertionError(
|
|
32
|
+
f"expected exit {expected_exit}, got {result.returncode}\n"
|
|
33
|
+
f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}"
|
|
34
|
+
)
|
|
35
|
+
if result.returncode == 0 and args[0] == "record":
|
|
36
|
+
# Cross-read the actual persisted receipt with the other implementation.
|
|
37
|
+
# Do not record twice into one tree and call the second result a diff.
|
|
38
|
+
other = (ROOT / "scripts" / "fixtures" / "prd-review-gate-python-oracle.py"
|
|
39
|
+
if SCRIPT.name != "prd-review-gate-python-oracle.py"
|
|
40
|
+
else ROOT / "scripts" / "cm-prd-review-gate.mjs")
|
|
41
|
+
command = [sys.executable if other.suffix == ".py" else os.environ.get("CM_NODE_BIN", "node"), str(other), "inspect"]
|
|
42
|
+
for flag in ("--stage", "--feature", "--evidence", "--receipt"):
|
|
43
|
+
command.extend([flag, args[args.index(flag) + 1]])
|
|
44
|
+
checked = subprocess.run(command, cwd=ROOT, text=True, capture_output=True, check=False)
|
|
45
|
+
if checked.returncode != 0 or json.loads(checked.stdout).get("outcome") != "completed":
|
|
46
|
+
raise AssertionError(f"cross-runtime receipt rejected: {checked.stderr}")
|
|
47
|
+
return json.loads(result.stdout) if result.stdout.strip() else {"stderr": result.stderr}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def main() -> int:
|
|
51
|
+
with tempfile.TemporaryDirectory(prefix="cm-prd-review-gate-") as raw:
|
|
52
|
+
root = Path(raw)
|
|
53
|
+
reviews = root / ".reviews"
|
|
54
|
+
reviews.mkdir()
|
|
55
|
+
artifact = root / "design.md"
|
|
56
|
+
artifact.write_text("# design v1\n", encoding="utf-8")
|
|
57
|
+
evidence = reviews / "prd-1.login-design-r1.md"
|
|
58
|
+
receipt = reviews / "prd-1.login-design-disposition.json"
|
|
59
|
+
|
|
60
|
+
fresh = invoke(
|
|
61
|
+
"inspect",
|
|
62
|
+
"--stage",
|
|
63
|
+
"design",
|
|
64
|
+
"--feature",
|
|
65
|
+
"1.login",
|
|
66
|
+
"--evidence",
|
|
67
|
+
str(evidence),
|
|
68
|
+
"--receipt",
|
|
69
|
+
str(receipt),
|
|
70
|
+
)
|
|
71
|
+
assert fresh["outcome"] == "dispatch_once"
|
|
72
|
+
|
|
73
|
+
fake_header_evidence = reviews / "prd-2.fake-design-r1.md"
|
|
74
|
+
fake_header_evidence.write_text(
|
|
75
|
+
"---\n"
|
|
76
|
+
"at: 2026-08-04T12:00:00-07:00\n"
|
|
77
|
+
"notreviewer: codex-subagent\n"
|
|
78
|
+
"notindependent: true\n"
|
|
79
|
+
"notscope:\n"
|
|
80
|
+
" - design.md\n"
|
|
81
|
+
"---\n\n"
|
|
82
|
+
"伪字段不能通过。\n",
|
|
83
|
+
encoding="utf-8",
|
|
84
|
+
)
|
|
85
|
+
fake_header = invoke(
|
|
86
|
+
"inspect",
|
|
87
|
+
"--stage",
|
|
88
|
+
"design",
|
|
89
|
+
"--feature",
|
|
90
|
+
"2.fake",
|
|
91
|
+
"--evidence",
|
|
92
|
+
str(fake_header_evidence),
|
|
93
|
+
"--receipt",
|
|
94
|
+
str(reviews / "prd-2.fake-design-disposition.json"),
|
|
95
|
+
expected_exit=1,
|
|
96
|
+
)
|
|
97
|
+
assert "stderr" in fake_header
|
|
98
|
+
|
|
99
|
+
degraded_evidence = reviews / "prd-3.degraded-design-r1.md"
|
|
100
|
+
degraded_evidence.write_text(
|
|
101
|
+
"---\n"
|
|
102
|
+
"at: 2026-08-04T12:00:00-07:00\n"
|
|
103
|
+
"reviewer: self-degraded\n"
|
|
104
|
+
"independent: false\n"
|
|
105
|
+
"degraded_reason: independent channels unavailable\n"
|
|
106
|
+
"scope:\n"
|
|
107
|
+
" - design.md\n"
|
|
108
|
+
"---\n\n"
|
|
109
|
+
"主执行者完成降级对抗检查,零发现。\n",
|
|
110
|
+
encoding="utf-8",
|
|
111
|
+
)
|
|
112
|
+
degraded = invoke(
|
|
113
|
+
"inspect",
|
|
114
|
+
"--stage",
|
|
115
|
+
"design",
|
|
116
|
+
"--feature",
|
|
117
|
+
"3.degraded",
|
|
118
|
+
"--evidence",
|
|
119
|
+
str(degraded_evidence),
|
|
120
|
+
"--receipt",
|
|
121
|
+
str(reviews / "prd-3.degraded-design-disposition.json"),
|
|
122
|
+
)
|
|
123
|
+
assert degraded["outcome"] == "resume_disposition"
|
|
124
|
+
|
|
125
|
+
evidence_body = (
|
|
126
|
+
"---\n"
|
|
127
|
+
"at: 2026-08-04T12:00:00-07:00\n"
|
|
128
|
+
"reviewer: codex-subagent\n"
|
|
129
|
+
"independent: true\n"
|
|
130
|
+
"scope:\n"
|
|
131
|
+
" - design.md\n"
|
|
132
|
+
"---\n\n"
|
|
133
|
+
"发现一项边界问题。\n"
|
|
134
|
+
)
|
|
135
|
+
evidence.write_text(evidence_body, encoding="utf-8")
|
|
136
|
+
inspect_args = ["inspect", "--stage", "design", "--feature", "1.login",
|
|
137
|
+
"--evidence", str(evidence), "--receipt", str(receipt)]
|
|
138
|
+
for invalid in ("\ufeff" + evidence_body,
|
|
139
|
+
evidence_body.replace("2026-08-04T12:00:00-07:00", "2026-09-07Z10:00:00Z")):
|
|
140
|
+
evidence.write_text(invalid, encoding="utf-8")
|
|
141
|
+
invoke(*inspect_args, expected_exit=1)
|
|
142
|
+
evidence.write_text(evidence_body, encoding="utf-8")
|
|
143
|
+
aliases = root / "aliases"
|
|
144
|
+
aliases.mkdir()
|
|
145
|
+
receipt_link = aliases / receipt.name
|
|
146
|
+
receipt_link.symlink_to(receipt) # absolute target does not exist yet
|
|
147
|
+
assert invoke(*inspect_args[:-1], str(receipt_link))["outcome"] == "resume_disposition"
|
|
148
|
+
recovering = invoke(
|
|
149
|
+
"inspect",
|
|
150
|
+
"--stage",
|
|
151
|
+
"design",
|
|
152
|
+
"--feature",
|
|
153
|
+
"1.login",
|
|
154
|
+
"--evidence",
|
|
155
|
+
str(evidence),
|
|
156
|
+
"--receipt",
|
|
157
|
+
str(receipt),
|
|
158
|
+
)
|
|
159
|
+
assert recovering["outcome"] == "resume_disposition"
|
|
160
|
+
|
|
161
|
+
recorded = invoke(
|
|
162
|
+
"record",
|
|
163
|
+
"--stage",
|
|
164
|
+
"design",
|
|
165
|
+
"--feature",
|
|
166
|
+
"1.login",
|
|
167
|
+
"--evidence",
|
|
168
|
+
str(evidence),
|
|
169
|
+
"--receipt",
|
|
170
|
+
str(receipt_link),
|
|
171
|
+
"--artifact",
|
|
172
|
+
str(artifact),
|
|
173
|
+
"--disposition",
|
|
174
|
+
"applied",
|
|
175
|
+
"--finding-count",
|
|
176
|
+
"1",
|
|
177
|
+
"--unresolved-count",
|
|
178
|
+
"0",
|
|
179
|
+
)
|
|
180
|
+
assert recorded["outcome"] == "recorded"
|
|
181
|
+
completed = invoke(
|
|
182
|
+
"inspect",
|
|
183
|
+
"--stage",
|
|
184
|
+
"design",
|
|
185
|
+
"--feature",
|
|
186
|
+
"1.login",
|
|
187
|
+
"--evidence",
|
|
188
|
+
str(evidence),
|
|
189
|
+
"--receipt",
|
|
190
|
+
str(receipt),
|
|
191
|
+
)
|
|
192
|
+
assert completed["outcome"] == "completed"
|
|
193
|
+
|
|
194
|
+
artifact.write_text("# changed after disposition\n", encoding="utf-8")
|
|
195
|
+
artifact_mismatch = invoke(
|
|
196
|
+
"inspect",
|
|
197
|
+
"--stage",
|
|
198
|
+
"design",
|
|
199
|
+
"--feature",
|
|
200
|
+
"1.login",
|
|
201
|
+
"--evidence",
|
|
202
|
+
str(evidence),
|
|
203
|
+
"--receipt",
|
|
204
|
+
str(receipt),
|
|
205
|
+
expected_exit=1,
|
|
206
|
+
)
|
|
207
|
+
assert "stderr" in artifact_mismatch
|
|
208
|
+
artifact.write_text("# design v1\n", encoding="utf-8")
|
|
209
|
+
|
|
210
|
+
receipt_value = json.loads(receipt.read_text(encoding="utf-8"))
|
|
211
|
+
invalid_receipt = dict(receipt_value)
|
|
212
|
+
invalid_receipt["disposition"] = "no_findings"
|
|
213
|
+
invalid_receipt["finding_count"] = 1
|
|
214
|
+
receipt.write_text(
|
|
215
|
+
json.dumps(invalid_receipt, ensure_ascii=False, separators=(",", ":")) + "\n",
|
|
216
|
+
encoding="utf-8",
|
|
217
|
+
)
|
|
218
|
+
receipt_mismatch = invoke(
|
|
219
|
+
"inspect",
|
|
220
|
+
"--stage",
|
|
221
|
+
"design",
|
|
222
|
+
"--feature",
|
|
223
|
+
"1.login",
|
|
224
|
+
"--evidence",
|
|
225
|
+
str(evidence),
|
|
226
|
+
"--receipt",
|
|
227
|
+
str(receipt),
|
|
228
|
+
expected_exit=1,
|
|
229
|
+
)
|
|
230
|
+
assert "stderr" in receipt_mismatch
|
|
231
|
+
receipt.write_text(
|
|
232
|
+
json.dumps(receipt_value, ensure_ascii=False, separators=(",", ":")) + "\n",
|
|
233
|
+
encoding="utf-8",
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
evidence.write_text(evidence.read_text(encoding="utf-8") + "tampered\n", encoding="utf-8")
|
|
237
|
+
mismatch = invoke(
|
|
238
|
+
"inspect",
|
|
239
|
+
"--stage",
|
|
240
|
+
"design",
|
|
241
|
+
"--feature",
|
|
242
|
+
"1.login",
|
|
243
|
+
"--evidence",
|
|
244
|
+
str(evidence),
|
|
245
|
+
"--receipt",
|
|
246
|
+
str(receipt),
|
|
247
|
+
expected_exit=1,
|
|
248
|
+
)
|
|
249
|
+
assert "stderr" in mismatch
|
|
250
|
+
|
|
251
|
+
r2 = reviews / "prd-2.profile-split-r2.md"
|
|
252
|
+
r2.write_text("forbidden second review\n", encoding="utf-8")
|
|
253
|
+
blocked = invoke(
|
|
254
|
+
"inspect",
|
|
255
|
+
"--stage",
|
|
256
|
+
"split",
|
|
257
|
+
"--feature",
|
|
258
|
+
"2.profile",
|
|
259
|
+
"--evidence",
|
|
260
|
+
str(reviews / "prd-2.profile-split-r1.md"),
|
|
261
|
+
"--receipt",
|
|
262
|
+
str(reviews / "prd-2.profile-split-disposition.json"),
|
|
263
|
+
expected_exit=1,
|
|
264
|
+
)
|
|
265
|
+
assert "stderr" in blocked
|
|
266
|
+
|
|
267
|
+
print("cm-prd review recovery fixtures: PASSED")
|
|
268
|
+
return 0
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
if __name__ == "__main__":
|
|
272
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Dependency-free fixtures for scripts/cm-prd-timing.py."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
import tempfile
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Dict, List, Optional
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
16
|
+
REPORTER = ROOT / "scripts" / "cm-prd-timing.py"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def write_jsonl(path: Path, rows: List[Dict[str, object]]) -> None:
|
|
20
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
21
|
+
path.write_text(
|
|
22
|
+
"".join(json.dumps(row, ensure_ascii=False) + "\n" for row in rows),
|
|
23
|
+
encoding="utf-8",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def invoke(
|
|
28
|
+
log_home: Path,
|
|
29
|
+
*args: str,
|
|
30
|
+
expected_exit: int = 0,
|
|
31
|
+
python_io_encoding: Optional[str] = None,
|
|
32
|
+
) -> subprocess.CompletedProcess:
|
|
33
|
+
env = os.environ.copy()
|
|
34
|
+
if python_io_encoding is not None:
|
|
35
|
+
env["PYTHONIOENCODING"] = python_io_encoding
|
|
36
|
+
result = subprocess.run(
|
|
37
|
+
[sys.executable, str(REPORTER), "--log-home", str(log_home), *args],
|
|
38
|
+
cwd=ROOT,
|
|
39
|
+
env=env,
|
|
40
|
+
text=True,
|
|
41
|
+
encoding="utf-8",
|
|
42
|
+
capture_output=True,
|
|
43
|
+
check=False,
|
|
44
|
+
)
|
|
45
|
+
if result.returncode != expected_exit:
|
|
46
|
+
raise AssertionError(
|
|
47
|
+
f"expected exit {expected_exit}, got {result.returncode}\n"
|
|
48
|
+
f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}"
|
|
49
|
+
)
|
|
50
|
+
return result
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def progress(
|
|
54
|
+
run_id: str,
|
|
55
|
+
phase: str,
|
|
56
|
+
at: str,
|
|
57
|
+
operation_id: str,
|
|
58
|
+
phase_name: str,
|
|
59
|
+
segment: int,
|
|
60
|
+
outcome: Optional[str] = None,
|
|
61
|
+
) -> Dict[str, object]:
|
|
62
|
+
row: Dict[str, object] = {
|
|
63
|
+
"schema_version": 1,
|
|
64
|
+
"run_id": run_id,
|
|
65
|
+
"at": at,
|
|
66
|
+
"workflow": "cm-prd",
|
|
67
|
+
"event": "progress",
|
|
68
|
+
"phase": phase,
|
|
69
|
+
"runtime": "codex",
|
|
70
|
+
"project": "fixture",
|
|
71
|
+
"detail": "fixture",
|
|
72
|
+
"operation_id": operation_id,
|
|
73
|
+
"phase_name": phase_name,
|
|
74
|
+
"segment": segment,
|
|
75
|
+
}
|
|
76
|
+
if outcome is not None:
|
|
77
|
+
row["outcome"] = outcome
|
|
78
|
+
return row
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def index_rows(run_id: str, at: str, project: str, status: str) -> Dict[str, object]:
|
|
82
|
+
return {
|
|
83
|
+
"schema_version": 1,
|
|
84
|
+
"at": at,
|
|
85
|
+
"run_id": run_id,
|
|
86
|
+
"status": status,
|
|
87
|
+
"workflow": "cm-prd",
|
|
88
|
+
"runtime": "codex",
|
|
89
|
+
"project": project,
|
|
90
|
+
"log_file": f"runs/2026-08/{run_id}.jsonl",
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def main() -> int:
|
|
95
|
+
with tempfile.TemporaryDirectory(prefix="cm-prd-timing-") as tmp:
|
|
96
|
+
home = Path(tmp)
|
|
97
|
+
old_run = "prd-old-0001"
|
|
98
|
+
done_run = "prd-done-0002"
|
|
99
|
+
live_run = "prd-live-0003"
|
|
100
|
+
write_jsonl(
|
|
101
|
+
home / "index.jsonl",
|
|
102
|
+
[
|
|
103
|
+
index_rows(old_run, "2026-08-01T10:00:00+00:00", "old-project", "done"),
|
|
104
|
+
index_rows(done_run, "2026-08-02T10:00:00+00:00", "done-project", "running"),
|
|
105
|
+
index_rows(done_run, "2026-08-02T10:01:00+00:00", "done-project", "done"),
|
|
106
|
+
index_rows(live_run, "2026-08-03T10:00:00+00:00", "live-project", "running"),
|
|
107
|
+
{
|
|
108
|
+
**index_rows("other-flow", "2026-08-04T10:00:00+00:00", "ignored", "done"),
|
|
109
|
+
"workflow": "cm-ai",
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
)
|
|
113
|
+
write_jsonl(
|
|
114
|
+
home / f"runs/2026-08/{old_run}.jsonl",
|
|
115
|
+
[
|
|
116
|
+
progress(old_run, "start", "2026-08-01T10:00:00Z", "prd-context", "context_load", 1),
|
|
117
|
+
progress(old_run, "complete", "2026-08-01T10:00:02Z", "prd-context", "context_load", 1, "completed"),
|
|
118
|
+
],
|
|
119
|
+
)
|
|
120
|
+
write_jsonl(
|
|
121
|
+
home / f"runs/2026-08/{done_run}.jsonl",
|
|
122
|
+
[
|
|
123
|
+
progress(done_run, "start", "2026-08-02T10:00:00Z", "prd-requirements", "requirements_analysis", 1),
|
|
124
|
+
progress(done_run, "complete", "2026-08-02T10:00:10Z", "prd-requirements", "requirements_analysis", 1, "awaiting_input"),
|
|
125
|
+
progress(done_run, "start", "2026-08-02T11:00:00Z", "prd-requirements", "requirements_analysis", 2),
|
|
126
|
+
progress(done_run, "complete", "2026-08-02T11:00:15Z", "prd-requirements", "requirements_analysis", 2, "completed"),
|
|
127
|
+
progress(done_run, "start", "2026-08-02T11:00:20Z", "prd-spec-review", "spec_review", 1),
|
|
128
|
+
progress(done_run, "complete", "2026-08-02T11:00:25Z", "prd-spec-review", "spec_review", 1, "completed"),
|
|
129
|
+
progress(done_run, "start", "2026-08-02T11:00:30Z", "prd-design-review", "design_review", 1),
|
|
130
|
+
],
|
|
131
|
+
)
|
|
132
|
+
write_jsonl(
|
|
133
|
+
home / f"runs/2026-08/{live_run}.jsonl",
|
|
134
|
+
[
|
|
135
|
+
progress(live_run, "start", "2026-08-03T10:00:00Z", "prd-context", "context_load", 1),
|
|
136
|
+
progress(live_run, "complete", "2026-08-03T10:00:03Z", "prd-context", "context_load", 1, "completed"),
|
|
137
|
+
],
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
report = invoke(home, "--last", "2")
|
|
141
|
+
assert "CM PRD 阶段耗时(最近 2 次)" in report.stdout
|
|
142
|
+
assert "old-project" not in report.stdout
|
|
143
|
+
assert "requirements_analysis: 25.0s" in report.stdout
|
|
144
|
+
assert "spec_review: 5.0s" in report.stdout
|
|
145
|
+
assert "最慢阶段: requirements_analysis 25.0s" in report.stdout
|
|
146
|
+
assert "人工暂停: 1" in report.stdout
|
|
147
|
+
assert "design_review 1,spec_review 1" in report.stdout
|
|
148
|
+
assert "未配对 segment: 1(未猜测耗时)" in report.stdout
|
|
149
|
+
assert f"{live_run} | running" in report.stdout
|
|
150
|
+
assert f"{done_run} | done" in report.stdout
|
|
151
|
+
|
|
152
|
+
empty = invoke(home / "empty")
|
|
153
|
+
assert "没有找到可读取的 cm-prd 阶段耗时日志" in empty.stdout
|
|
154
|
+
assert empty.stderr == ""
|
|
155
|
+
|
|
156
|
+
invalid = invoke(home, "--last", "0", expected_exit=2)
|
|
157
|
+
assert "must be at least 1" in invalid.stderr
|
|
158
|
+
|
|
159
|
+
legacy_console = invoke(home, "--last", "1", python_io_encoding="cp1252")
|
|
160
|
+
assert "UnicodeEncodeError" not in legacy_console.stderr
|
|
161
|
+
assert "CM PRD" in legacy_console.stdout
|
|
162
|
+
|
|
163
|
+
print("cm-prd timing fixtures: PASSED")
|
|
164
|
+
return 0
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
if __name__ == "__main__":
|
|
168
|
+
raise SystemExit(main())
|