@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,67 @@
|
|
|
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 {captureReviewBaseline,createReviewPackage,verifyReviewPackage,readReviewSourceFiles} from '../runtime/js/cm-ai/review-package.mjs';
|
|
7
|
+
import {digest} from '../runtime/js/cm-ai/contracts.mjs';
|
|
8
|
+
|
|
9
|
+
function fixture(t){
|
|
10
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-dependency-snapshot-')));
|
|
11
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
12
|
+
fs.mkdirSync(path.join(root,'src'));
|
|
13
|
+
fs.writeFileSync(path.join(root,'src/main.py'),'before');
|
|
14
|
+
fs.writeFileSync(path.join(root,'requirements.md'),'preserve CLI error contract');
|
|
15
|
+
const options={root,identity:{repositoryId:'fixture',runId:'deps',taskId:'T-001',attempt:1},scope:['src/main.py'],requirements:['requirements.md']};
|
|
16
|
+
return {root,options};
|
|
17
|
+
}
|
|
18
|
+
const checks=[{id:'unit',command:['test'],outcome:'passed',exitCode:0,evidence:'synthetic passing result'}];
|
|
19
|
+
|
|
20
|
+
test('dependency directories and nested Python caches do not enter business snapshots',t=>{
|
|
21
|
+
const {root,options}=fixture(t);
|
|
22
|
+
for(const folder of ['.venv','node_modules','src/__pycache__','.pytest_cache','.ruff_cache']){
|
|
23
|
+
fs.mkdirSync(path.join(root,folder),{recursive:true});
|
|
24
|
+
fs.symlinkSync('/nonexistent/synthetic-dependency',path.join(root,folder,'link'));
|
|
25
|
+
}
|
|
26
|
+
const baseline=captureReviewBaseline(options);
|
|
27
|
+
assert.deepEqual(baseline.files.map(f=>f.path),['requirements.md','src/main.py']);
|
|
28
|
+
fs.writeFileSync(path.join(root,'src/main.py'),'after');
|
|
29
|
+
const pkg=createReviewPackage({root,baseline,checks});
|
|
30
|
+
fs.writeFileSync(path.join(root,'.venv','cache'),'generated after review');
|
|
31
|
+
assert.equal(verifyReviewPackage({root,baseline,checks,reviewPackage:pkg,expectedDigest:pkg.packageDigest}).outcome,'matched');
|
|
32
|
+
fs.writeFileSync(path.join(root,'unexpected.py'),'business drift');
|
|
33
|
+
assert.throws(()=>createReviewPackage({root,baseline,checks}),{code:'out_of_scope'});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('excluded directories cannot be selected as business edits or requirements',t=>{
|
|
37
|
+
const {root,options}=fixture(t);
|
|
38
|
+
fs.mkdirSync(path.join(root,'.venv'));
|
|
39
|
+
fs.writeFileSync(path.join(root,'.venv','value.py'),'dependency');
|
|
40
|
+
for(const field of ['scope','requirements']){
|
|
41
|
+
for(const selected of ['.venv/value.py','src/node_modules/new.js','.VENV/new.py','src/Node_Modules/new.js'])
|
|
42
|
+
assert.throws(()=>captureReviewBaseline({...options,[field]:[selected]}),{code:'excluded_snapshot_path'});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('dependency root symlinks and business symlinks remain rejected',t=>{
|
|
47
|
+
const {root,options}=fixture(t);
|
|
48
|
+
for(const name of ['.venv','src/linked.py']){
|
|
49
|
+
fs.symlinkSync('requirements.md',path.join(root,name));
|
|
50
|
+
assert.throws(()=>captureReviewBaseline(options),{code:'unsupported_file'});
|
|
51
|
+
fs.unlinkSync(path.join(root,name));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('legacy baselines retain already-recorded dependency files and their drift checks',t=>{
|
|
56
|
+
const {root,options}=fixture(t);
|
|
57
|
+
const base=captureReviewBaseline(options);
|
|
58
|
+
fs.mkdirSync(path.join(root,'.venv'));
|
|
59
|
+
fs.writeFileSync(path.join(root,'.venv','recorded.txt'),'legacy snapshot material');
|
|
60
|
+
const {baselineDigest,...body}=base;
|
|
61
|
+
body.files=[...body.files,...readReviewSourceFiles(root,['.venv/recorded.txt'])].sort((a,b)=>a.path.localeCompare(b.path));
|
|
62
|
+
const baseline={...body,baselineDigest:digest(body)};
|
|
63
|
+
fs.writeFileSync(path.join(root,'src/main.py'),'after');
|
|
64
|
+
assert.equal(createReviewPackage({root,baseline,checks}).changes.length,1);
|
|
65
|
+
fs.writeFileSync(path.join(root,'.venv','recorded.txt'),'changed');
|
|
66
|
+
assert.throws(()=>createReviewPackage({root,baseline,checks}),{code:'out_of_scope'});
|
|
67
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
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 {captureReviewBaseline,createReviewPackage,readReviewBaseline,readReviewPackage,verifyReviewPackage} from '../runtime/js/cm-ai/review-package.mjs';
|
|
8
|
+
import {digest} from '../runtime/js/cm-ai/contracts.mjs';
|
|
9
|
+
|
|
10
|
+
const identity={repositoryId:'fixture',runId:'inventory',taskId:'T-001',attempt:1};
|
|
11
|
+
const checks=[{id:'fixture',command:['node','fixture.mjs'],outcome:'passed',exitCode:0,evidence:'synthetic check'}];
|
|
12
|
+
const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
13
|
+
const capture=(root,extra={})=>captureReviewBaseline({root,identity,scope:['code.js'],requirements:['requirements.md'],...extra});
|
|
14
|
+
const write=(root,name,body)=>fs.writeFileSync(path.join(root,name),body);
|
|
15
|
+
function fixture(fn){
|
|
16
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-inventory-')));
|
|
17
|
+
try{write(root,'code.js','before');write(root,'requirements.md','fixture');return fn(root);}
|
|
18
|
+
finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
test('large inventory retains hashes, emits only selected bodies, and verifies the review package',()=>fixture(root=>{
|
|
22
|
+
for(let i=0;i<510;i++)write(root,`asset-${i}`,Buffer.alloc(4096,i%256));
|
|
23
|
+
const media=Buffer.alloc(2*1024*1024+1,17);write(root,'media.bin',media);write(root,'AGENTS.md','fixture instructions');
|
|
24
|
+
const baseline=capture(root);
|
|
25
|
+
assert.equal(baseline.version,2);assert.equal(baseline.files.length,514);
|
|
26
|
+
assert.deepEqual(baseline.files.filter(f=>Object.hasOwn(f,'contentBase64')).map(f=>f.path),['AGENTS.md','code.js','requirements.md']);
|
|
27
|
+
assert.equal(baseline.files.find(f=>f.path==='media.bin').sha256,sha(media));
|
|
28
|
+
assert(Buffer.byteLength(JSON.stringify(baseline))<150000);
|
|
29
|
+
assert.deepEqual(readReviewBaseline(JSON.parse(JSON.stringify(baseline))),baseline);
|
|
30
|
+
write(root,'code.js','after');
|
|
31
|
+
const reviewPackage=createReviewPackage({root,baseline,checks});
|
|
32
|
+
assert.equal(reviewPackage.version,1);
|
|
33
|
+
assert.equal(Buffer.from(reviewPackage.changes[0].before.contentBase64,'base64').toString(),'before');
|
|
34
|
+
assert.deepEqual(readReviewPackage(reviewPackage),reviewPackage);
|
|
35
|
+
assert.equal(verifyReviewPackage({root,baseline,checks,reviewPackage,expectedDigest:reviewPackage.packageDigest}).outcome,'matched');
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
for(const mode of ['same-size edit','add','delete','rename','chmod','symlink','hardlink'])
|
|
39
|
+
test(`digest-only out-of-scope file rejects ${mode}`,()=>fixture(root=>{
|
|
40
|
+
write(root,'asset.bin',Buffer.alloc(1024*1024+1,7));const baseline=capture(root);write(root,'code.js','after');
|
|
41
|
+
const target=path.join(root,'asset.bin');
|
|
42
|
+
if(mode==='same-size edit'){const fd=fs.openSync(target,'r+');try{fs.writeSync(fd,Buffer.from([8]),0,1,65537);}finally{fs.closeSync(fd);}}
|
|
43
|
+
if(mode==='add')write(root,'new.bin','extra');
|
|
44
|
+
if(mode==='delete')fs.unlinkSync(target);
|
|
45
|
+
if(mode==='rename')fs.renameSync(target,path.join(root,'renamed.bin'));
|
|
46
|
+
if(mode==='chmod')fs.chmodSync(target,0o700);
|
|
47
|
+
if(mode==='symlink'){fs.unlinkSync(target);fs.symlinkSync('code.js',target);}
|
|
48
|
+
if(mode==='hardlink')fs.linkSync(target,path.join(root,'linked.bin'));
|
|
49
|
+
assert.throws(()=>createReviewPackage({root,baseline,checks}),{code:['symlink','hardlink'].includes(mode)?'unsupported_file':'out_of_scope'});
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
for(const mutation of ['truncate','grow','replace'])test(`streamed file ${mutation} fails and closes its descriptor`,t=>fixture(root=>{
|
|
53
|
+
const target=path.join(root,'asset.bin');write(root,'asset.bin',Buffer.alloc(1024*1024+1));
|
|
54
|
+
const originalRead=fs.readSync,originalOpen=fs.openSync,originalClose=fs.closeSync;
|
|
55
|
+
let targetFd,changed=false,closed=false,maxRead=0;
|
|
56
|
+
t.mock.method(fs,'openSync',(...args)=>{const fd=originalOpen(...args);if(args[0]===target)targetFd=fd;return fd;});
|
|
57
|
+
t.mock.method(fs,'readSync',(...args)=>{
|
|
58
|
+
const n=originalRead(...args);
|
|
59
|
+
if(args[0]===targetFd){
|
|
60
|
+
maxRead=Math.max(maxRead,args[3]);
|
|
61
|
+
if(!changed){changed=true;
|
|
62
|
+
if(mutation==='truncate')fs.truncateSync(target,1);
|
|
63
|
+
if(mutation==='grow')fs.appendFileSync(target,'extra');
|
|
64
|
+
if(mutation==='replace'){fs.renameSync(target,target+'.old');write(root,'asset.bin',Buffer.alloc(1024*1024+1));}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return n;
|
|
68
|
+
});
|
|
69
|
+
t.mock.method(fs,'closeSync',fd=>{if(fd===targetFd)closed=true;return originalClose(fd);});
|
|
70
|
+
assert.throws(()=>capture(root),{code:'snapshot_changed'});assert(changed&&closed);assert(maxRead<=64*1024);
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
test('oversized inventory fails before reading the file, while selected material retains its smaller cap',t=>fixture(root=>{
|
|
74
|
+
const target=path.join(root,'asset.bin');write(root,'asset.bin','');fs.truncateSync(target,1024*1024*1024+1);
|
|
75
|
+
const original=fs.openSync;let opened=false;
|
|
76
|
+
t.mock.method(fs,'openSync',(...args)=>{if(args[0]===target)opened=true;return original(...args);});
|
|
77
|
+
assert.throws(()=>capture(root),{code:'limit_exceeded'});assert.equal(opened,false);
|
|
78
|
+
fs.unlinkSync(target);write(root,'code.js',Buffer.alloc(1024*1024+1));
|
|
79
|
+
assert.throws(()=>capture(root),{code:'limit_exceeded'});
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
test('inventory count is bounded without silently omitting the last file',()=>fixture(root=>{
|
|
83
|
+
for(let i=0;i<9998;i++)write(root,`empty-${String(i).padStart(5,'0')}`,'');
|
|
84
|
+
const baseline=capture(root);assert.equal(baseline.files.length,10000);readReviewBaseline(baseline);
|
|
85
|
+
write(root,'one-more','');assert.throws(()=>capture(root),{code:'limit_exceeded'});
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
test('offline sparse baseline rejects missing required bodies, extra bodies, aliases, and malformed metadata',()=>fixture(root=>{
|
|
89
|
+
write(root,'asset.bin','outside');const original=capture(root);
|
|
90
|
+
for(const mutate of [
|
|
91
|
+
b=>{delete b.files.find(f=>f.path==='code.js').contentBase64;},
|
|
92
|
+
b=>{b.files.find(f=>f.path==='asset.bin').contentBase64=Buffer.from('outside').toString('base64');},
|
|
93
|
+
b=>{b.files[0].size=-1;},b=>{b.files[0].sha256='bad';},
|
|
94
|
+
b=>{b.files.push({...b.files[0],path:'ASSET.bin'});},
|
|
95
|
+
]){
|
|
96
|
+
const b=structuredClone(original);mutate(b);const {baselineDigest,...data}=b;
|
|
97
|
+
assert.throws(()=>readReviewBaseline({...data,baselineDigest:digest(data)}),{code:'invalid_baseline'});
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
test('legacy baseline preserves full records and package digests across offline restoration',()=>fixture(root=>{
|
|
102
|
+
write(root,'outside.txt','legacy body');const baseline=capture(root,{version:1});
|
|
103
|
+
assert(baseline.files.every(f=>Object.hasOwn(f,'contentBase64')));
|
|
104
|
+
assert.deepEqual(capture(root,{version:1}),readReviewBaseline(baseline));
|
|
105
|
+
write(root,'code.js','after');const reviewPackage=createReviewPackage({root,baseline,checks});
|
|
106
|
+
assert.equal(verifyReviewPackage({root,baseline:readReviewBaseline(JSON.parse(JSON.stringify(baseline))),checks,
|
|
107
|
+
reviewPackage,expectedDigest:reviewPackage.packageDigest}).outcome,'matched');
|
|
108
|
+
write(root,'outside.txt','changed');assert.throws(()=>createReviewPackage({root,baseline,checks}),{code:'out_of_scope'});
|
|
109
|
+
}));
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Semantic approval manifest; no writes, installation or external dependencies.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import {createHash} from 'node:crypto';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {TextDecoder} from 'node:util';
|
|
9
|
+
|
|
10
|
+
const required=['requirements.md','design.md','tasks.md'];
|
|
11
|
+
const feature=/^\p{Decimal_Number}+\.[^\n]+$(?![\s\S])/u;
|
|
12
|
+
const fail=message=>{throw new Error(message);};
|
|
13
|
+
const record=v=>v!==null&&typeof v==='object'&&!Array.isArray(v);
|
|
14
|
+
// UTF-8 ordering matches Python's Unicode code-point ordering for valid names.
|
|
15
|
+
const compare=(a,b)=>Buffer.compare(Buffer.from(a),Buffer.from(b));
|
|
16
|
+
const exists=p=>{try{fs.statSync(p);return true;}catch(e){if(['ENOENT','ENOTDIR'].includes(e.code))return false;throw e;}};
|
|
17
|
+
|
|
18
|
+
export function semanticDigest(file){
|
|
19
|
+
let bytes=fs.readFileSync(file);
|
|
20
|
+
const name=path.basename(file);
|
|
21
|
+
if(['tasks.md','requirements.md'].includes(name)){
|
|
22
|
+
const marker=name==='tasks.md'?/^([ ]{0,3}-[ \t]+)\[[xX]\]([ \t]+T-[A-Za-z0-9][A-Za-z0-9._-]*[ \t]*:)/
|
|
23
|
+
:/^([ ]{0,3}-[ \t]+)\[[xX]\]([ \t]+\[AC-[A-Za-z0-9][A-Za-z0-9._-]*\])/;
|
|
24
|
+
let fenceChar=null,width=0;
|
|
25
|
+
// Latin-1 is a reversible byte view, including invalid UTF-8 and CRLF.
|
|
26
|
+
const lines=bytes.toString('latin1').match(/[^\r\n]*(?:\r\n|\r|\n|$)/g)??[];
|
|
27
|
+
bytes=Buffer.from(lines.map(line=>{
|
|
28
|
+
const fence=/^[ ]{0,3}(`{3,}|~{3,})/.exec(line);
|
|
29
|
+
if(fenceChar!==null){
|
|
30
|
+
if(fence&&fence[1][0]===fenceChar&&fence[1].length>=width
|
|
31
|
+
&&/^[\t\n\v\f\r ]*$/.test(line.slice(fence[0].length))){fenceChar=null;width=0;}
|
|
32
|
+
return line;
|
|
33
|
+
}
|
|
34
|
+
if(fence){fenceChar=fence[1][0];width=fence[1].length;return line;}
|
|
35
|
+
if(line.startsWith(' ')||line.startsWith('\t'))return line;
|
|
36
|
+
return line.replace(marker,'$1[ ]$2');
|
|
37
|
+
}).join(''),'latin1');
|
|
38
|
+
}
|
|
39
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function buildManifest(specsDir){
|
|
43
|
+
if(!exists(specsDir)||!fs.statSync(specsDir).isDirectory())fail(`specs directory does not exist: ${specsDir}`);
|
|
44
|
+
const features=fs.readdirSync(specsDir).filter(name=>feature.test(name)).sort(compare);
|
|
45
|
+
if(!features.length)fail('specs directory contains no numbered feature directories');
|
|
46
|
+
const rows=[];
|
|
47
|
+
for(const name of features){
|
|
48
|
+
const dir=path.join(specsDir,name),stat=fs.lstatSync(dir);
|
|
49
|
+
if(stat.isSymbolicLink()||!stat.isDirectory())fail(`numbered feature must be a regular directory: ${dir}`);
|
|
50
|
+
for(const filename of required){
|
|
51
|
+
const file=path.join(dir,filename);
|
|
52
|
+
if(!exists(file)||!fs.statSync(file).isFile())fail(`missing required spec file: ${name}/${filename}`);
|
|
53
|
+
if(fs.lstatSync(file).isSymbolicLink())fail(`approved spec file must not be a symlink: ${file}`);
|
|
54
|
+
}
|
|
55
|
+
for(const filename of [...required,'test-cases.json']){
|
|
56
|
+
const file=path.join(dir,filename);if(!exists(file))continue;
|
|
57
|
+
if(!fs.statSync(file).isFile())fail(`approved spec path must be a file: ${file}`);
|
|
58
|
+
if(fs.lstatSync(file).isSymbolicLink())fail(`approved spec file must not be a symlink: ${file}`);
|
|
59
|
+
rows.push({path:`${name}/${filename}`,sha256:semanticDigest(file)});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return rows.sort((a,b)=>compare(a.path,b.path));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function verifyManifest(manifest,statusFile){
|
|
66
|
+
const value=JSON.parse(new TextDecoder('utf-8',{fatal:true,ignoreBOM:true}).decode(fs.readFileSync(statusFile)));
|
|
67
|
+
if(!record(value))fail('status file root must be an object');
|
|
68
|
+
if(!Array.isArray(value.specFiles)||!value.specFiles.length)fail('status file has no approved specFiles manifest');
|
|
69
|
+
const seen=new Set(),rows=value.specFiles.map((item,index)=>{
|
|
70
|
+
if(!record(item)||Object.keys(item).sort().join(',')!=='path,sha256')fail(`specFiles[${index}] must contain path and sha256 only`);
|
|
71
|
+
const p=item.path;
|
|
72
|
+
if(typeof p!=='string'||p.startsWith('/')||p.includes('\\')||p.split('/').includes('..')||seen.has(p))
|
|
73
|
+
fail(`specFiles[${index}].path is invalid or duplicated`);
|
|
74
|
+
if(typeof item.sha256!=='string'||!/^[0-9a-f]{64}$/.test(item.sha256))fail(`specFiles[${index}].sha256 is invalid`);
|
|
75
|
+
seen.add(p);return {path:p,sha256:item.sha256};
|
|
76
|
+
});
|
|
77
|
+
if(value.status!=='approved')fail('status file must have status approved before manifest verification');
|
|
78
|
+
if(JSON.stringify(rows)!==JSON.stringify(manifest))fail('approved spec manifest does not match current spec files');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Resolve symlinks before '..', like pathlib.resolve, rather than normalizing
|
|
82
|
+
// the spelling first. Both CLI inputs must exist for a successful operation.
|
|
83
|
+
const expand=p=>fs.realpathSync.native(p==='~'?os.homedir():p.startsWith('~/')?os.homedir()+'/'+p.slice(2):p);
|
|
84
|
+
export function main(argv=process.argv.slice(2),{stdout=process.stdout,stderr=process.stderr}={}){
|
|
85
|
+
if(argv.length===1&&['-h','--help'].includes(argv[0])){stdout.write('usage: cm-spec-manifest.mjs specs_dir [--status-file PATH]\n');return 0;}
|
|
86
|
+
try{
|
|
87
|
+
let specs,status,options=true;
|
|
88
|
+
for(let i=0;i<argv.length;i++){
|
|
89
|
+
const arg=argv[i];
|
|
90
|
+
if(options&&arg==='--'){options=false;continue;}
|
|
91
|
+
if(options&&arg==='--status-file'){
|
|
92
|
+
if(i+1>=argv.length)fail('invalid arguments');status=argv[++i];continue;
|
|
93
|
+
}
|
|
94
|
+
if(options&&arg.startsWith('--status-file=')){status=arg.slice('--status-file='.length);continue;}
|
|
95
|
+
if(options&&arg.startsWith('-')||specs!==undefined)fail('invalid arguments');
|
|
96
|
+
specs=arg;
|
|
97
|
+
}
|
|
98
|
+
if(specs===undefined)fail('invalid arguments');
|
|
99
|
+
const specFiles=buildManifest(expand(specs));
|
|
100
|
+
if(status!==undefined)verifyManifest(specFiles,expand(status));
|
|
101
|
+
stdout.write(JSON.stringify({schema_version:1,...(status!==undefined?{status:'matched'}:{}),specFiles})+'\n');return 0;
|
|
102
|
+
}catch(error){stderr.write(`cm-spec-manifest: ${error.message}\n`);return 1;}
|
|
103
|
+
}
|
|
104
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=main();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Compatibility CLI; semantic approval rules live in cm-spec-manifest.mjs."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main() -> int:
|
|
13
|
+
entry = Path(__file__).resolve().with_name("cm-spec-manifest.mjs")
|
|
14
|
+
try:
|
|
15
|
+
result = subprocess.run(
|
|
16
|
+
[os.environ.get("CM_NODE_BIN", "node"), str(entry), *sys.argv[1:]],
|
|
17
|
+
check=False,
|
|
18
|
+
)
|
|
19
|
+
except OSError as error:
|
|
20
|
+
print(f"cm-spec-manifest: cannot start JavaScript runtime: {error}", file=sys.stderr)
|
|
21
|
+
return 1
|
|
22
|
+
return result.returncode if result.returncode >= 0 else 128 - result.returncode
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if __name__ == "__main__":
|
|
26
|
+
raise SystemExit(main())
|