@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,463 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Authoritative dependency-free CM Workflow project configuration loader.
|
|
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
|
+
|
|
8
|
+
export const CONFIG_FILENAMES=Object.freeze(['.cm-workflow.yml','.cm-workflow.yaml','.cm-workflow.json']);
|
|
9
|
+
export const MAX_CONFIG_BYTES=64*1024;
|
|
10
|
+
|
|
11
|
+
const PROJECT_TYPES=new Set(['auto','java-backend','web-frontend','custom']);
|
|
12
|
+
const WORKFLOWS=new Set(['cm-default','java-backend','web-frontend']);
|
|
13
|
+
const ROLE_NAMES=new Set(['analyst','planner','coder','tester','reviewer','browser_qa','external_expert']);
|
|
14
|
+
const ROLE_FIELDS=new Set(['adapter','model','source']);
|
|
15
|
+
const EXTERNAL_FIELDS=new Set([...ROLE_FIELDS,'enabled','activation','model_policy']);
|
|
16
|
+
const ADAPTERS=new Set(['current-ai','codex-cli','claude-cli','claude-api','openai-compatible','local','browser','external-browser']);
|
|
17
|
+
const SOURCES=new Set(['local','subscription','api','browser','none']);
|
|
18
|
+
const TEST_KINDS=new Set(['logic','commands','browser']);
|
|
19
|
+
const ACTIVATIONS=new Set(['explicit']);
|
|
20
|
+
const MODEL_POLICIES=new Set(['pro-extra-high-high-skip','strict-pro','strict-Pro']);
|
|
21
|
+
const MODEL_POLICY_ALIASES=Object.freeze({'strict-Pro':'strict-pro'});
|
|
22
|
+
const AUTO_FIX_POLICIES=new Set(['explicit','never','auto']);
|
|
23
|
+
const DELIVERY_MODES=new Set(['diff','branch','draft-mr']);
|
|
24
|
+
const RUNTIMES=new Set(['codex','claude','unknown']);
|
|
25
|
+
const SECRET_KEY=/(?:api[_-]?key|access[_-]?token|secret|cookie|password|private[_-]?key|credential|authorization)/i;
|
|
26
|
+
const SECRET_VALUE=/(?:-----BEGIN [^-]+ PRIVATE KEY-----|\b(?:AKIA|ASIA)[0-9A-Z]{16}\b|\bAIza[0-9A-Za-z_-]{20,}\b|\bsk[-_](?:ant-api\d{2}[-_])?[A-Za-z0-9_-]{12,}\b|\b(?:ghp|gho|ghu|ghs|ghr|github_pat)[-_][A-Za-z0-9_-]{8,}\b|\bxox[baprs][-_][A-Za-z0-9_-]{8,}\b|\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b)/i;
|
|
27
|
+
const IDENTIFIER=/^[A-Za-z0-9][A-Za-z0-9._:/+@-]{0,127}$/;
|
|
28
|
+
|
|
29
|
+
export class ConfigError extends Error {
|
|
30
|
+
constructor(message){super(message);this.name='ConfigError';}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const rawDefault={
|
|
34
|
+
version:1,
|
|
35
|
+
project:{type:'auto',workflow:'cm-default'},
|
|
36
|
+
roles:{
|
|
37
|
+
analyst:{adapter:'current-ai',model:'default',source:'local'},
|
|
38
|
+
planner:{adapter:'current-ai',model:'default',source:'local'},
|
|
39
|
+
coder:{adapter:'current-ai',model:'default',source:'local'},
|
|
40
|
+
tester:{adapter:'local',model:'none',source:'local'},
|
|
41
|
+
reviewer:{adapter:'current-ai',model:'default',source:'local'},
|
|
42
|
+
browser_qa:{adapter:'browser',model:'none',source:'local'},
|
|
43
|
+
external_expert:{adapter:'external-browser',model:'chatgpt-pro',source:'browser',enabled:true,
|
|
44
|
+
activation:'explicit',model_policy:'pro-extra-high-high-skip'},
|
|
45
|
+
},
|
|
46
|
+
policies:{tests:['logic','commands','browser'],generate_cases:true,auto_fix:'explicit',delivery:'draft-mr'},
|
|
47
|
+
};
|
|
48
|
+
const deepFreeze=value=>{
|
|
49
|
+
if(value&&typeof value==='object'&&!Object.isFrozen(value)){
|
|
50
|
+
for(const item of Object.values(value))deepFreeze(item);
|
|
51
|
+
Object.freeze(value);
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
};
|
|
55
|
+
export const DEFAULT_CONFIG=deepFreeze(structuredClone(rawDefault));
|
|
56
|
+
|
|
57
|
+
const clone=value=>structuredClone(value);
|
|
58
|
+
function object(value){return value!==null&&typeof value==='object'&&!Array.isArray(value);}
|
|
59
|
+
function define(target,key,value){Object.defineProperty(target,key,{value,writable:true,enumerable:true,configurable:true});}
|
|
60
|
+
function deepMerge(base,override){
|
|
61
|
+
const result=clone(base);
|
|
62
|
+
for(const [key,value] of Object.entries(override)){
|
|
63
|
+
if(object(value)&&object(result[key]))result[key]=deepMerge(result[key],value);
|
|
64
|
+
else result[key]=clone(value);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function stripComment(value){
|
|
70
|
+
let quote=null,escaped=false;
|
|
71
|
+
for(let index=0;index<value.length;index++){
|
|
72
|
+
const character=value[index];
|
|
73
|
+
if(quote==='"'&&escaped){escaped=false;continue;}
|
|
74
|
+
if(character==='\\'&"e==='"'){escaped=true;continue;}
|
|
75
|
+
if(character==="'"||character==='"'){
|
|
76
|
+
if(quote===null)quote=character;else if(quote===character)quote=null;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if(character==='#'&"e===null&&(index===0||/\s/.test(value[index-1])))return value.slice(0,index).trimEnd();
|
|
80
|
+
}
|
|
81
|
+
return value.trimEnd();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function splitTopLevel(value,separator=','){
|
|
85
|
+
const parts=[];let start=0,depth=0,quote=null,escaped=false;
|
|
86
|
+
for(let index=0;index<value.length;index++){
|
|
87
|
+
const character=value[index];
|
|
88
|
+
if(quote==='"'&&escaped){escaped=false;continue;}
|
|
89
|
+
if(character==='\\'&"e==='"'){escaped=true;continue;}
|
|
90
|
+
if(character==="'"||character==='"'){
|
|
91
|
+
if(quote===null)quote=character;else if(quote===character)quote=null;
|
|
92
|
+
}else if(quote===null){
|
|
93
|
+
if('[{('.includes(character))depth++;
|
|
94
|
+
else if(']})'.includes(character))depth--;
|
|
95
|
+
else if(character===separator&&depth===0){parts.push(value.slice(start,index).trim());start=index+1;}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if(quote!==null||depth!==0)throw new ConfigError('unclosed quote or inline collection');
|
|
99
|
+
parts.push(value.slice(start).trim());return parts;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function mappingColon(value){
|
|
103
|
+
let depth=0,quote=null,escaped=false;
|
|
104
|
+
for(let index=0;index<value.length;index++){
|
|
105
|
+
const character=value[index];
|
|
106
|
+
if(quote==='"'&&escaped){escaped=false;continue;}
|
|
107
|
+
if(character==='\\'&"e==='"'){escaped=true;continue;}
|
|
108
|
+
if(character==="'"||character==='"'){
|
|
109
|
+
if(quote===null)quote=character;else if(quote===character)quote=null;
|
|
110
|
+
}else if(quote===null){
|
|
111
|
+
if('[{('.includes(character))depth++;
|
|
112
|
+
else if(']})'.includes(character))depth--;
|
|
113
|
+
else if(character===':'&&depth===0&&(index+1===value.length||/\s/.test(value[index+1])))return index;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return -1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function parseScalar(raw){
|
|
120
|
+
const value=raw.trim();
|
|
121
|
+
if(!value)throw new ConfigError('empty scalar is not allowed');
|
|
122
|
+
if('!&*|>'.includes(value[0]))throw new ConfigError(`unsupported YAML feature: ${value[0]}`);
|
|
123
|
+
if(value.startsWith('[')&&value.endsWith(']')){
|
|
124
|
+
const inner=value.slice(1,-1).trim();return inner?splitTopLevel(inner).map(parseScalar):[];
|
|
125
|
+
}
|
|
126
|
+
if(value.startsWith('{')&&value.endsWith('}')){
|
|
127
|
+
const inner=value.slice(1,-1).trim(),result={};
|
|
128
|
+
if(!inner)return result;
|
|
129
|
+
for(const item of splitTopLevel(inner)){
|
|
130
|
+
const colon=mappingColon(item);
|
|
131
|
+
if(colon<0)throw new ConfigError(`invalid inline mapping item: ${item}`);
|
|
132
|
+
const key=parseKey(item.slice(0,colon));
|
|
133
|
+
if(Object.hasOwn(result,key))throw new ConfigError(`duplicate key ${JSON.stringify(key)} in inline mapping`);
|
|
134
|
+
define(result,key,parseScalar(item.slice(colon+1)));
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
if(value.startsWith('"')||value.startsWith("'")){
|
|
139
|
+
if(value.length<2||value.at(-1)!==value[0])throw new ConfigError('unterminated quoted scalar');
|
|
140
|
+
if(value[0]==='"'){
|
|
141
|
+
try{return JSON.parse(value);}catch(error){throw new ConfigError(`invalid quoted scalar: ${error.message}`);}
|
|
142
|
+
}
|
|
143
|
+
return value.slice(1,-1).replaceAll("''", "'");
|
|
144
|
+
}
|
|
145
|
+
const lowered=value.toLowerCase();
|
|
146
|
+
if(lowered==='true'||lowered==='false')return lowered==='true';
|
|
147
|
+
if(lowered==='null'||lowered==='~')return null;
|
|
148
|
+
if(/^-?\d+$/.test(value))return BigInt(value);
|
|
149
|
+
if(/^-?(?:\d+\.\d*|\d*\.\d+)$/.test(value))return Number.parseFloat(value);
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function parseKey(value){
|
|
154
|
+
const key=value.trim();if(!key)throw new ConfigError('mapping key cannot be empty');
|
|
155
|
+
const parsed=parseScalar(key);if(typeof parsed!=='string')throw new ConfigError('mapping keys must be strings');
|
|
156
|
+
return parsed;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function parseYamlSubset(text){
|
|
160
|
+
const lines=[];
|
|
161
|
+
for(const [offset,raw] of text.split(/\r\n|[\n\r\v\f\x1c-\x1e\x85\u2028\u2029]/).entries()){
|
|
162
|
+
const prefix=raw.match(/^ */)[0];
|
|
163
|
+
if(raw.slice(0,raw.length-raw.trimStart().length).includes('\t'))
|
|
164
|
+
throw new ConfigError(`line ${offset+1}: tabs are not allowed for indentation`);
|
|
165
|
+
const content=stripComment(raw.slice(prefix.length));
|
|
166
|
+
if(content)lines.push([prefix.length,content,offset+1]);
|
|
167
|
+
}
|
|
168
|
+
if(lines.length===0)throw new ConfigError('configuration is empty');
|
|
169
|
+
if(lines[0][0]!==0)throw new ConfigError(`line ${lines[0][2]}: root indentation must be zero`);
|
|
170
|
+
function parseBlock(index,indent,depth=0){
|
|
171
|
+
if(depth>256)throw new ConfigError('configuration nesting is too deep');
|
|
172
|
+
if(index>=lines.length||lines[index][0]!==indent)throw new ConfigError('expected an indented mapping or list');
|
|
173
|
+
const isList=lines[index][1]==='-'||lines[index][1].startsWith('- '),result=isList?[]:{};
|
|
174
|
+
while(index<lines.length){
|
|
175
|
+
const [currentIndent,content,lineNumber]=lines[index];
|
|
176
|
+
if(currentIndent<indent)break;
|
|
177
|
+
if(currentIndent>indent)throw new ConfigError(`line ${lineNumber}: unexpected indentation`);
|
|
178
|
+
if(isList){
|
|
179
|
+
if(!(content==='-'||content.startsWith('- ')))throw new ConfigError(`line ${lineNumber}: mixed mapping and list`);
|
|
180
|
+
const itemText=content.slice(1).trim();let item;
|
|
181
|
+
if(!itemText){
|
|
182
|
+
if(index+1>=lines.length||lines[index+1][0]<=indent)throw new ConfigError(`line ${lineNumber}: empty list item`);
|
|
183
|
+
[item,index]=parseBlock(index+1,lines[index+1][0],depth+1);
|
|
184
|
+
}else{item=parseScalar(itemText);index++;}
|
|
185
|
+
result.push(item);continue;
|
|
186
|
+
}
|
|
187
|
+
const colon=mappingColon(content);
|
|
188
|
+
if(colon<0)throw new ConfigError(`line ${lineNumber}: expected 'key: value'`);
|
|
189
|
+
const key=parseKey(content.slice(0,colon));
|
|
190
|
+
if(Object.hasOwn(result,key))throw new ConfigError(`line ${lineNumber}: duplicate key ${JSON.stringify(key)}`);
|
|
191
|
+
const itemText=content.slice(colon+1).trim();let item;
|
|
192
|
+
if(itemText){item=parseScalar(itemText);index++;}
|
|
193
|
+
else{
|
|
194
|
+
if(index+1>=lines.length||lines[index+1][0]<=indent)throw new ConfigError(`line ${lineNumber}: missing value for ${JSON.stringify(key)}`);
|
|
195
|
+
[item,index]=parseBlock(index+1,lines[index+1][0],depth+1);
|
|
196
|
+
}
|
|
197
|
+
define(result,key,item);
|
|
198
|
+
}
|
|
199
|
+
return [result,index];
|
|
200
|
+
}
|
|
201
|
+
const [value,index]=parseBlock(0,0);
|
|
202
|
+
if(index!==lines.length)throw new ConfigError(`line ${lines[index][2]}: unexpected content`);
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function parseJsonStrict(text){
|
|
207
|
+
let index=0;
|
|
208
|
+
const whitespace=()=>{while(index<text.length&&/[ \t\r\n]/.test(text[index]))index++;};
|
|
209
|
+
function value(depth=0){
|
|
210
|
+
if(depth>256)throw new ConfigError('configuration nesting is too deep');
|
|
211
|
+
whitespace();const start=index,character=text[index];
|
|
212
|
+
if(character==='"'){
|
|
213
|
+
index++;
|
|
214
|
+
for(let escaped=false;index<text.length;index++){
|
|
215
|
+
const current=text[index];
|
|
216
|
+
if(escaped){escaped=false;continue;}
|
|
217
|
+
if(current==='\\'){escaped=true;continue;}
|
|
218
|
+
if(current==='"'){index++;try{return JSON.parse(text.slice(start,index));}catch(error){throw new ConfigError(`invalid JSON: ${error.message}`);}}
|
|
219
|
+
}
|
|
220
|
+
throw new ConfigError('invalid JSON: unterminated string');
|
|
221
|
+
}
|
|
222
|
+
if(character==='{'){
|
|
223
|
+
index++;whitespace();const result={},keys=new Set();
|
|
224
|
+
if(text[index]==='}'){index++;return result;}
|
|
225
|
+
while(true){
|
|
226
|
+
whitespace();if(text[index]!=='"')throw new ConfigError('invalid JSON: object key must be a string');
|
|
227
|
+
const key=value(depth+1);if(keys.has(key))throw new ConfigError(`duplicate JSON object key ${JSON.stringify(key)}`);keys.add(key);
|
|
228
|
+
whitespace();if(text[index++]!==':')throw new ConfigError("invalid JSON: expected ':'");
|
|
229
|
+
define(result,key,value(depth+1));whitespace();
|
|
230
|
+
if(text[index]==='}'){index++;return result;}
|
|
231
|
+
if(text[index++]!==',')throw new ConfigError("invalid JSON: expected ',' or '}'");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if(character==='['){
|
|
235
|
+
index++;whitespace();const result=[];
|
|
236
|
+
if(text[index]===']'){index++;return result;}
|
|
237
|
+
while(true){result.push(value(depth+1));whitespace();if(text[index]===']'){index++;return result;}
|
|
238
|
+
if(text[index++]!==',')throw new ConfigError("invalid JSON: expected ',' or ']'");}
|
|
239
|
+
}
|
|
240
|
+
for(const [literal,parsed] of [['true',true],['false',false],['null',null]]){
|
|
241
|
+
if(text.startsWith(literal,index)){index+=literal.length;return parsed;}
|
|
242
|
+
}
|
|
243
|
+
const number=text.slice(index).match(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/);
|
|
244
|
+
if(number){
|
|
245
|
+
index+=number[0].length;
|
|
246
|
+
return /^-?(?:0|[1-9]\d*)$/.test(number[0])?BigInt(number[0]):Number(number[0]);
|
|
247
|
+
}
|
|
248
|
+
throw new ConfigError(`invalid JSON near byte ${index}`);
|
|
249
|
+
}
|
|
250
|
+
try{const parsed=value();whitespace();if(index!==text.length)throw new ConfigError(`invalid JSON near byte ${index}`);return parsed;}
|
|
251
|
+
catch(error){if(error instanceof ConfigError)throw error;throw new ConfigError(`invalid JSON: ${error.message}`);}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function parseDocument(filePath,text){
|
|
255
|
+
if(text.startsWith('\ufeff'))text=text.slice(1);
|
|
256
|
+
return path.extname(filePath).toLowerCase()==='.json'?parseJsonStrict(text):parseYamlSubset(text);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function walkForSecrets(value,location='config'){
|
|
260
|
+
if(object(value))for(const [key,item] of Object.entries(value)){
|
|
261
|
+
if(SECRET_KEY.test(String(key)))throw new ConfigError(`${location}.${key}: credential fields are forbidden`);
|
|
262
|
+
walkForSecrets(item,`${location}.${key}`);
|
|
263
|
+
}else if(Array.isArray(value))value.forEach((item,index)=>walkForSecrets(item,`${location}[${index}]`));
|
|
264
|
+
else if(typeof value==='string'&&SECRET_VALUE.test(value))throw new ConfigError(`${location}: secret-like values are forbidden`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function requireMapping(value,location){if(!object(value))throw new ConfigError(`${location} must be a mapping`);return value;}
|
|
268
|
+
function rejectUnknown(mapping,allowed,location){
|
|
269
|
+
const unknown=Object.keys(mapping).filter(key=>!allowed.has(key)).sort();
|
|
270
|
+
if(unknown.length)throw new ConfigError(`${location} has unknown field(s): ${unknown.join(', ')}`);
|
|
271
|
+
}
|
|
272
|
+
function requireString(value,location,choices=null){
|
|
273
|
+
if(typeof value!=='string'||!value.trim())throw new ConfigError(`${location} must be a non-empty string`);
|
|
274
|
+
if(value.length>128||!IDENTIFIER.test(value))throw new ConfigError(`${location} contains unsupported characters`);
|
|
275
|
+
if(choices&&!choices.has(value))throw new ConfigError(`${location} must be one of: ${[...choices].sort().join(', ')}`);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function validateRaw(value){
|
|
279
|
+
const root=requireMapping(value,'config');rejectUnknown(root,new Set(['version','project','roles','policies']),'config');
|
|
280
|
+
if(typeof root.version!=='bigint'||root.version!==1n)throw new ConfigError('config.version must equal integer 1');
|
|
281
|
+
if(Object.hasOwn(root,'project')){
|
|
282
|
+
const project=requireMapping(root.project,'config.project');rejectUnknown(project,new Set(['type','workflow']),'config.project');
|
|
283
|
+
if(Object.hasOwn(project,'type'))requireString(project.type,'config.project.type',PROJECT_TYPES);
|
|
284
|
+
if(Object.hasOwn(project,'workflow'))requireString(project.workflow,'config.project.workflow',WORKFLOWS);
|
|
285
|
+
}
|
|
286
|
+
if(Object.hasOwn(root,'roles')){
|
|
287
|
+
const roles=requireMapping(root.roles,'config.roles');rejectUnknown(roles,ROLE_NAMES,'config.roles');
|
|
288
|
+
for(const [role,rawRole] of Object.entries(roles)){
|
|
289
|
+
const roleData=requireMapping(rawRole,`config.roles.${role}`),allowed=role==='external_expert'?EXTERNAL_FIELDS:ROLE_FIELDS;
|
|
290
|
+
rejectUnknown(roleData,allowed,`config.roles.${role}`);
|
|
291
|
+
for(const field of ['adapter','model','source'])if(Object.hasOwn(roleData,field))requireString(roleData[field],`config.roles.${role}.${field}`);
|
|
292
|
+
if(role!=='external_expert'){
|
|
293
|
+
if(roleData.adapter==='external-browser')throw new ConfigError(`config.roles.${role}.adapter cannot be external-browser; only external_expert may use the external browser`);
|
|
294
|
+
if(roleData.adapter==='browser'&&role!=='browser_qa')throw new ConfigError(`config.roles.${role}.adapter browser is reserved for browser_qa`);
|
|
295
|
+
if(roleData.source==='browser')throw new ConfigError(`config.roles.${role}.source browser is reserved for external_expert`);
|
|
296
|
+
}
|
|
297
|
+
if(Object.hasOwn(roleData,'enabled')&&typeof roleData.enabled!=='boolean')throw new ConfigError(`config.roles.${role}.enabled must be boolean`);
|
|
298
|
+
if(Object.hasOwn(roleData,'activation'))requireString(roleData.activation,`config.roles.${role}.activation`,ACTIVATIONS);
|
|
299
|
+
if(Object.hasOwn(roleData,'model_policy'))requireString(roleData.model_policy,`config.roles.${role}.model_policy`,MODEL_POLICIES);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if(Object.hasOwn(root,'policies')){
|
|
303
|
+
const policies=requireMapping(root.policies,'config.policies');
|
|
304
|
+
rejectUnknown(policies,new Set(['tests','generate_cases','auto_fix','delivery']),'config.policies');
|
|
305
|
+
if(Object.hasOwn(policies,'tests')&&(!Array.isArray(policies.tests)||policies.tests.length===0
|
|
306
|
+
||policies.tests.some(item=>typeof item!=='string'||!TEST_KINDS.has(item))))
|
|
307
|
+
throw new ConfigError('config.policies.tests must be a non-empty list of logic/commands/browser');
|
|
308
|
+
if(Object.hasOwn(policies,'generate_cases')&&typeof policies.generate_cases!=='boolean')
|
|
309
|
+
throw new ConfigError('config.policies.generate_cases must be boolean');
|
|
310
|
+
if(Object.hasOwn(policies,'auto_fix'))requireString(policies.auto_fix,'config.policies.auto_fix',AUTO_FIX_POLICIES);
|
|
311
|
+
if(Object.hasOwn(policies,'delivery'))requireString(policies.delivery,'config.policies.delivery',DELIVERY_MODES);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function validateEffective(config){
|
|
316
|
+
requireString(config.project.type,'project.type',PROJECT_TYPES);requireString(config.project.workflow,'project.workflow',WORKFLOWS);
|
|
317
|
+
for(const [role,roleData] of Object.entries(config.roles)){
|
|
318
|
+
requireString(roleData.adapter,`roles.${role}.adapter`,ADAPTERS);
|
|
319
|
+
if(role!=='external_expert'){
|
|
320
|
+
if(roleData.adapter==='external-browser')throw new ConfigError(`roles.${role}.adapter cannot be external-browser; only external_expert may use it`);
|
|
321
|
+
if(roleData.adapter==='browser'&&role!=='browser_qa')throw new ConfigError(`roles.${role}.adapter browser is reserved for browser_qa`);
|
|
322
|
+
if(roleData.source==='browser')throw new ConfigError(`roles.${role}.source browser is reserved for external_expert`);
|
|
323
|
+
}
|
|
324
|
+
requireString(roleData.model,`roles.${role}.model`);requireString(roleData.source,`roles.${role}.source`,SOURCES);
|
|
325
|
+
if(role==='external_expert'){
|
|
326
|
+
if(roleData.adapter!=='external-browser'||roleData.source!=='browser')
|
|
327
|
+
throw new ConfigError('roles.external_expert must use adapter external-browser and source browser');
|
|
328
|
+
if(typeof roleData.enabled!=='boolean')throw new ConfigError('roles.external_expert.enabled must be boolean');
|
|
329
|
+
requireString(roleData.activation,'roles.external_expert.activation',ACTIVATIONS);
|
|
330
|
+
requireString(roleData.model_policy,'roles.external_expert.model_policy',MODEL_POLICIES);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if(!Array.isArray(config.policies.tests)||config.policies.tests.length===0)throw new ConfigError('policies.tests must be a non-empty list');
|
|
334
|
+
if(config.policies.tests.some(item=>typeof item!=='string'||!TEST_KINDS.has(item)))throw new ConfigError('policies.tests contains an unsupported test kind');
|
|
335
|
+
if(typeof config.policies.generate_cases!=='boolean')throw new ConfigError('policies.generate_cases must be boolean');
|
|
336
|
+
requireString(config.policies.auto_fix,'policies.auto_fix',AUTO_FIX_POLICIES);
|
|
337
|
+
requireString(config.policies.delivery,'policies.delivery',DELIVERY_MODES);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function expandUser(raw){
|
|
341
|
+
if(raw==='~')return os.homedir();
|
|
342
|
+
if(raw.startsWith(`~${path.sep}`))return path.join(os.homedir(),raw.slice(2));
|
|
343
|
+
return raw;
|
|
344
|
+
}
|
|
345
|
+
function realDirectory(raw,label){
|
|
346
|
+
try{const target=fs.realpathSync(path.resolve(expandUser(raw)));if(!fs.statSync(target).isDirectory())throw new Error();return target;}
|
|
347
|
+
catch{throw new ConfigError(`${label} is not a directory: ${path.resolve(expandUser(raw))}`);}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export function findConfig(projectRoot){
|
|
351
|
+
const root=realDirectory(projectRoot,'project root');
|
|
352
|
+
const candidates=CONFIG_FILENAMES.map(name=>path.join(root,name)).filter(candidate=>{
|
|
353
|
+
try{return fs.statSync(candidate).isFile();}catch{return false;}
|
|
354
|
+
});
|
|
355
|
+
if(candidates.length>1)throw new ConfigError(`multiple CM workflow configs found: ${candidates.map(candidate=>path.basename(candidate)).join(', ')}`);
|
|
356
|
+
return candidates[0]??null;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export function loadConfig(input){
|
|
360
|
+
if(!object(input)||!Object.hasOwn(input,'projectRoot')
|
|
361
|
+
||Object.keys(input).some(key=>!['projectRoot','configPath','text'].includes(key)))throw new ConfigError('invalid config input');
|
|
362
|
+
const root=realDirectory(input.projectRoot,'project root');
|
|
363
|
+
let configPath=Object.hasOwn(input,'configPath')?path.resolve(expandUser(input.configPath)):findConfig(root);
|
|
364
|
+
let text=Object.hasOwn(input,'text')?input.text:null;
|
|
365
|
+
if(text===null&&configPath===null)return clone(DEFAULT_CONFIG);
|
|
366
|
+
if(text===null){
|
|
367
|
+
try{
|
|
368
|
+
const stat=fs.statSync(configPath);if(!stat.isFile())throw new Error('not-file');
|
|
369
|
+
if(stat.size>MAX_CONFIG_BYTES)throw new ConfigError(`configuration file exceeds ${MAX_CONFIG_BYTES} bytes: ${configPath}`);
|
|
370
|
+
const bytes=fs.readFileSync(configPath);text=new TextDecoder('utf-8',{fatal:true}).decode(bytes);
|
|
371
|
+
}catch(error){if(error instanceof ConfigError)throw error;throw new ConfigError(`cannot read configuration ${configPath}: ${error.message}`);}
|
|
372
|
+
}else{
|
|
373
|
+
if(typeof text!=='string')throw new ConfigError('configuration text must be a string');
|
|
374
|
+
configPath??='.cm-workflow.yml';
|
|
375
|
+
}
|
|
376
|
+
if(SECRET_VALUE.test(text))throw new ConfigError('configuration contains a secret-like value');
|
|
377
|
+
try{
|
|
378
|
+
const raw=parseDocument(configPath,text);walkForSecrets(raw);validateRaw(raw);
|
|
379
|
+
const normalizedRaw={...raw,version:Number(raw.version)};
|
|
380
|
+
const effective=deepMerge(DEFAULT_CONFIG,normalizedRaw),policy=effective.roles.external_expert.model_policy;
|
|
381
|
+
if(Object.hasOwn(MODEL_POLICY_ALIASES,policy))effective.roles.external_expert.model_policy=MODEL_POLICY_ALIASES[policy];
|
|
382
|
+
validateEffective(effective);return effective;
|
|
383
|
+
}catch(error){if(error instanceof ConfigError)throw error;if(error instanceof RangeError)throw new ConfigError('configuration nesting is too deep');throw error;}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function routeState(adapter,runtime){
|
|
387
|
+
if(adapter==='current-ai')return 'current-runtime';
|
|
388
|
+
if(adapter==='local')return 'local-tool';
|
|
389
|
+
if(adapter==='browser')return 'local-browser';
|
|
390
|
+
if(adapter==='external-browser')return 'external-expert';
|
|
391
|
+
if((runtime==='codex'&&adapter==='codex-cli')||(runtime==='claude'&&adapter==='claude-cli'))return 'current-runtime';
|
|
392
|
+
return 'declared-adapter';
|
|
393
|
+
}
|
|
394
|
+
export function resolveRole(config,role,runtime='unknown'){
|
|
395
|
+
if(!ROLE_NAMES.has(role))throw new ConfigError(`unknown workflow role: ${role}`);
|
|
396
|
+
if(!RUNTIMES.has(runtime))throw new ConfigError(`unknown runtime: ${runtime}`);
|
|
397
|
+
if(!object(config?.roles)||!object(config.roles[role]))throw new ConfigError(`roles.${role} is missing from the effective config`);
|
|
398
|
+
const result={role,...clone(config.roles[role]),runtime};
|
|
399
|
+
result.route_state=role==='external_expert'&&result.enabled===false?'disabled':routeState(String(result.adapter),runtime);
|
|
400
|
+
return result;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function stableJson(value){
|
|
404
|
+
const stable=item=>Array.isArray(item)?item.map(stable):object(item)
|
|
405
|
+
?Object.fromEntries(Object.keys(item).sort().map(key=>[key,stable(item[key])])):item;
|
|
406
|
+
return JSON.stringify(stable(value));
|
|
407
|
+
}
|
|
408
|
+
function usage(){const program=process.env.CM_COMPAT_PROGRAM||'cm-workflow-config.mjs';
|
|
409
|
+
return `usage: ${program} [--project PATH] [--config PATH] [--role ROLE] [--runtime RUNTIME] [--print-role] [--print-effective]`;}
|
|
410
|
+
const LONG_OPTIONS=Object.freeze(['--project','--config','--role','--runtime','--print-role','--print-effective','--help']);
|
|
411
|
+
function resolveLongOption(flag){
|
|
412
|
+
if(LONG_OPTIONS.includes(flag))return flag;
|
|
413
|
+
if(!flag.startsWith('--'))return flag;
|
|
414
|
+
const matches=LONG_OPTIONS.filter(option=>option.startsWith(flag));
|
|
415
|
+
if(matches.length===1)return matches[0];
|
|
416
|
+
throw new ConfigError('invalid arguments');
|
|
417
|
+
}
|
|
418
|
+
function parseCli(argv){
|
|
419
|
+
const result={project:process.cwd(),runtime:'unknown',printRole:false,printEffective:false};
|
|
420
|
+
for(let index=0;index<argv.length;index++){
|
|
421
|
+
const argument=argv[index];
|
|
422
|
+
const equals=argument.indexOf('=');
|
|
423
|
+
const flag=resolveLongOption(equals>=0?argument.slice(0,equals):argument);
|
|
424
|
+
const attached=equals>=0?argument.slice(equals+1):null;
|
|
425
|
+
if((flag==='--help'||flag==='-h')&&attached===null)return {help:true};
|
|
426
|
+
if(flag==='--print-role'&&attached===null){result.printRole=true;continue;}
|
|
427
|
+
if(flag==='--print-effective'&&attached===null){result.printEffective=true;continue;}
|
|
428
|
+
const key={'--project':'project','--config':'config','--role':'role','--runtime':'runtime'}[flag];
|
|
429
|
+
if(!key)throw new ConfigError('invalid arguments');
|
|
430
|
+
if(attached!==null){
|
|
431
|
+
if(!attached&&!['project','config'].includes(key))throw new ConfigError('invalid arguments');
|
|
432
|
+
result[key]=attached;continue;
|
|
433
|
+
}
|
|
434
|
+
if(index+1>=argv.length||(argv[index+1].length>1&&argv[index+1].startsWith('-')))
|
|
435
|
+
throw new ConfigError('invalid arguments');
|
|
436
|
+
result[key]=argv[++index];
|
|
437
|
+
}
|
|
438
|
+
if(Object.hasOwn(result,'role')&&!ROLE_NAMES.has(result.role))throw new ConfigError(`invalid role: ${result.role}`);
|
|
439
|
+
if(!RUNTIMES.has(result.runtime))throw new ConfigError(`invalid runtime: ${result.runtime}`);
|
|
440
|
+
return result;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export function main(argv=process.argv.slice(2)){
|
|
444
|
+
let args;
|
|
445
|
+
try{args=parseCli(argv);}catch(error){process.stderr.write(`${usage()}\nFAIL: ${error.message}\n`);return 2;}
|
|
446
|
+
if(args.help){process.stdout.write(`${usage()}\n`);return 0;}
|
|
447
|
+
let config;
|
|
448
|
+
try{config=loadConfig({projectRoot:args.project,...(args.config?{configPath:args.config}:{})});}
|
|
449
|
+
catch(error){process.stderr.write(`FAIL: ${error.message}\n`);return 1;}
|
|
450
|
+
if(args.printRole&&!args.role){process.stderr.write('FAIL: --print-role requires --role\n');return 2;}
|
|
451
|
+
if(args.role){
|
|
452
|
+
const role=resolveRole(config,args.role,args.runtime),body=stableJson(role);
|
|
453
|
+
process.stdout.write(args.printRole?`${body}\n`:`workflow role: ${body}\n`);
|
|
454
|
+
}else if(args.printEffective)process.stdout.write(`${stableJson(config)}\n`);
|
|
455
|
+
else process.stdout.write('workflow config: PASSED\n');
|
|
456
|
+
return 0;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function isMainModule(entry){
|
|
460
|
+
if(!entry)return false;
|
|
461
|
+
try{return fs.realpathSync(entry)===fileURLToPath(import.meta.url);}catch{return path.resolve(entry)===fileURLToPath(import.meta.url);}
|
|
462
|
+
}
|
|
463
|
+
if(isMainModule(process.argv[1]))process.exitCode=main();
|
|
@@ -0,0 +1,181 @@
|
|
|
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 {spawnSync} from 'node:child_process';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
|
|
9
|
+
const scriptsRoot=fileURLToPath(new URL('.',import.meta.url));
|
|
10
|
+
const entryPath=path.join(scriptsRoot,'cm-workflow-config.mjs');
|
|
11
|
+
const pythonPath=path.join(scriptsRoot,'cm_workflow_config.py');
|
|
12
|
+
const pythonExecutable=process.env.CM_PYTHON_BIN||'python3';
|
|
13
|
+
|
|
14
|
+
const validYaml=`version: 1
|
|
15
|
+
project:
|
|
16
|
+
type: java-backend
|
|
17
|
+
workflow: java-backend
|
|
18
|
+
roles:
|
|
19
|
+
planner:
|
|
20
|
+
adapter: claude-api
|
|
21
|
+
model: claude-opus
|
|
22
|
+
source: api
|
|
23
|
+
coder:
|
|
24
|
+
adapter: codex-cli
|
|
25
|
+
model: gpt-5.6-sol
|
|
26
|
+
source: subscription
|
|
27
|
+
external_expert:
|
|
28
|
+
enabled: true
|
|
29
|
+
activation: explicit
|
|
30
|
+
model_policy: pro-extra-high-high-skip
|
|
31
|
+
policies:
|
|
32
|
+
tests:
|
|
33
|
+
- logic
|
|
34
|
+
- commands
|
|
35
|
+
generate_cases: true
|
|
36
|
+
auto_fix: explicit
|
|
37
|
+
delivery: draft-mr`;
|
|
38
|
+
|
|
39
|
+
const fixture=async fn=>{
|
|
40
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-workflow-config-js-')));
|
|
41
|
+
try{return await fn(root);}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
test('JS config authority preserves defaults, YAML merge, canonical aliases, and route states',()=>fixture(async root=>{
|
|
45
|
+
const api=await import('./cm-workflow-config.mjs');
|
|
46
|
+
const defaults=api.loadConfig({projectRoot:root});
|
|
47
|
+
assert.deepEqual(defaults,api.DEFAULT_CONFIG);
|
|
48
|
+
assert.equal(api.resolveRole(defaults,'coder','codex').route_state,'current-runtime');
|
|
49
|
+
assert.equal(api.resolveRole(defaults,'tester','codex').route_state,'local-tool');
|
|
50
|
+
assert.equal(api.resolveRole(defaults,'browser_qa','codex').route_state,'local-browser');
|
|
51
|
+
assert.equal(api.resolveRole(defaults,'external_expert','codex').route_state,'external-expert');
|
|
52
|
+
|
|
53
|
+
const configPath=path.join(root,'.cm-workflow.yml');
|
|
54
|
+
fs.writeFileSync(configPath,validYaml);
|
|
55
|
+
const configured=api.loadConfig({projectRoot:root});
|
|
56
|
+
assert.equal(configured.project.type,'java-backend');
|
|
57
|
+
assert.equal(configured.roles.coder.adapter,'codex-cli');
|
|
58
|
+
assert.deepEqual(configured.roles.analyst,api.DEFAULT_CONFIG.roles.analyst);
|
|
59
|
+
assert.deepEqual(configured.policies.tests,['logic','commands']);
|
|
60
|
+
assert.equal(api.resolveRole(configured,'planner','codex').route_state,'declared-adapter');
|
|
61
|
+
|
|
62
|
+
const alias=api.loadConfig({projectRoot:root,configPath:path.join(root,'alias.yml'),
|
|
63
|
+
text:'version: 1\nroles:\n external_expert:\n model_policy: strict-Pro\n'});
|
|
64
|
+
assert.equal(alias.roles.external_expert.model_policy,'strict-pro');
|
|
65
|
+
const disabled=api.loadConfig({projectRoot:root,configPath:path.join(root,'disabled.yml'),
|
|
66
|
+
text:'version: 1\nroles:\n external_expert:\n enabled: false\n'});
|
|
67
|
+
assert.equal(api.resolveRole(disabled,'external_expert','codex').route_state,'disabled');
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
test('JS config authority rejects unsupported syntax, duplicate keys, secrets, and permission-shaped routes',()=>fixture(async root=>{
|
|
71
|
+
const {ConfigError,loadConfig,resolveRole}=await import('./cm-workflow-config.mjs');
|
|
72
|
+
const bad=(name,text)=>()=>loadConfig({projectRoot:root,configPath:path.join(root,name),text});
|
|
73
|
+
for(const [name,text] of [
|
|
74
|
+
['unknown.yml','version: 1\nforbidden: true\n'],
|
|
75
|
+
['secret-key.yml','version: 1\napi_key: leaked\n'],
|
|
76
|
+
['secret-value.yml','version: 1\nroles:\n coder:\n model: sk-testvalue123\n'],
|
|
77
|
+
['secret-comment.yml','# sk-testvalue123\nversion: 1\n'],
|
|
78
|
+
['alias.yml','version: 1\nroles: &defaults\n coder: *defaults\n'],
|
|
79
|
+
['external-coder.yml','version: 1\nroles:\n coder:\n adapter: external-browser\n model: chatgpt-pro\n source: browser\n'],
|
|
80
|
+
['browser-coder.yml','version: 1\nroles:\n coder:\n adapter: browser\n model: none\n source: local\n'],
|
|
81
|
+
['browser-source.yml','version: 1\nroles:\n analyst:\n adapter: current-ai\n model: default\n source: browser\n'],
|
|
82
|
+
['external-api.yml','version: 1\nroles:\n external_expert:\n adapter: claude-api\n model: claude-opus\n source: api\n'],
|
|
83
|
+
['persistent-auto.yml','version: 1\nroles:\n external_expert:\n activation: auto\n'],
|
|
84
|
+
['boolean-version.yml','version: true\n'],
|
|
85
|
+
['float-version.yml','version: 1.0\n'],
|
|
86
|
+
['duplicate.yml','version: 1\nproject: {type: auto, type: custom}\n'],
|
|
87
|
+
['duplicate.json','{"version":1,"project":{"type":"auto","type":"custom"}}'],
|
|
88
|
+
['exponent-version.json','{"version":1e0}'],
|
|
89
|
+
['nbsp-whitespace.json','{"version":\u00a01}'],
|
|
90
|
+
['form-feed-whitespace.json','{"version":\f1}'],
|
|
91
|
+
['bad-tests.yml','version: 1\npolicies:\n tests:\n - [logic]\n'],
|
|
92
|
+
])assert.throws(bad(name,text),ConfigError,name);
|
|
93
|
+
assert.throws(()=>resolveRole(loadConfig({projectRoot:root}),'not-a-role'),ConfigError);
|
|
94
|
+
assert.throws(()=>resolveRole(loadConfig({projectRoot:root}),'coder','other'),ConfigError);
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
test('JS config authority preserves file discovery, BOM, size, UTF-8, and nesting boundaries',()=>fixture(async root=>{
|
|
98
|
+
const {ConfigError,MAX_CONFIG_BYTES,loadConfig}=await import('./cm-workflow-config.mjs');
|
|
99
|
+
const jsonPath=path.join(root,'.cm-workflow.json');
|
|
100
|
+
fs.writeFileSync(jsonPath,JSON.stringify({version:1,project:{type:'web-frontend'}}));
|
|
101
|
+
assert.equal(loadConfig({projectRoot:root}).project.type,'web-frontend');
|
|
102
|
+
fs.rmSync(jsonPath);
|
|
103
|
+
const bomPath=path.join(root,'.cm-workflow.yml');
|
|
104
|
+
fs.writeFileSync(bomPath,'\ufeffversion: 1\nproject:\n type: custom\n');
|
|
105
|
+
assert.equal(loadConfig({projectRoot:root}).project.type,'custom');
|
|
106
|
+
for(const separator of ['\r','\u2028']){
|
|
107
|
+
const text=['version: 1','project:',' type: custom',''].join(separator);
|
|
108
|
+
assert.equal(loadConfig({projectRoot:root,configPath:path.join(root,'lines.yml'),text}).project.type,'custom');
|
|
109
|
+
}
|
|
110
|
+
fs.writeFileSync(path.join(root,'.cm-workflow.yaml'),'version: 1\n');
|
|
111
|
+
assert.throws(()=>loadConfig({projectRoot:root}),ConfigError);
|
|
112
|
+
fs.rmSync(path.join(root,'.cm-workflow.yaml'));
|
|
113
|
+
fs.writeFileSync(bomPath,Buffer.from([0xff,0xfe,0xfd]));
|
|
114
|
+
assert.throws(()=>loadConfig({projectRoot:root}),ConfigError);
|
|
115
|
+
fs.writeFileSync(bomPath,'version: 1\n#'+('x'.repeat(MAX_CONFIG_BYTES)));
|
|
116
|
+
assert.throws(()=>loadConfig({projectRoot:root}),ConfigError);
|
|
117
|
+
const deep=['version: 1'];
|
|
118
|
+
for(let index=0;index<1100;index++)deep.push(' '.repeat(index)+`nested${index}:`);
|
|
119
|
+
deep.push(' '.repeat(1100)+'value: 1');
|
|
120
|
+
assert.throws(()=>loadConfig({projectRoot:root,configPath:path.join(root,'deep.yml'),text:deep.join('\n')}),ConfigError);
|
|
121
|
+
assert.throws(()=>loadConfig({projectRoot:path.join(root,'missing')}),ConfigError);
|
|
122
|
+
}));
|
|
123
|
+
|
|
124
|
+
test('JS CLI is authoritative and Python CLI is an output-compatible forwarder',()=>fixture(root=>{
|
|
125
|
+
const configPath=path.join(root,'.cm-workflow.json');
|
|
126
|
+
fs.writeFileSync(configPath,JSON.stringify({version:1,project:{type:'web-frontend'}}));
|
|
127
|
+
const cases=[
|
|
128
|
+
['--project',root,'--print-effective'],
|
|
129
|
+
[`--project=${root}`,'--print-effective'],
|
|
130
|
+
['--project',root,'--role','coder','--runtime','codex','--print-role'],
|
|
131
|
+
[`--project=${root}`,'--role=coder','--runtime=codex','--print-role'],
|
|
132
|
+
['--project',root],
|
|
133
|
+
['--project',root,'--print-role'],
|
|
134
|
+
];
|
|
135
|
+
for(const args of cases){
|
|
136
|
+
const js=spawnSync(process.execPath,[entryPath,...args],{encoding:'utf8'});
|
|
137
|
+
const py=spawnSync(pythonExecutable,[pythonPath,...args],{encoding:'utf8'});
|
|
138
|
+
assert.equal(py.status,js.status,args.join(' '));
|
|
139
|
+
assert.equal(py.stdout,js.stdout,args.join(' '));
|
|
140
|
+
assert.equal(py.stderr.replaceAll('cm_workflow_config.py','cm-workflow-config.mjs'),js.stderr,args.join(' '));
|
|
141
|
+
}
|
|
142
|
+
const help=spawnSync(pythonExecutable,[pythonPath,'--help'],{encoding:'utf8'});
|
|
143
|
+
assert.equal(help.status,0);
|
|
144
|
+
assert.match(help.stdout,/^usage: cm_workflow_config\.py \[-h\]/);
|
|
145
|
+
assert.match(help.stdout,/Validate and print CM Workflow project configuration/);
|
|
146
|
+
assert.match(help.stdout,/--role \{analyst,browser_qa,coder,external_expert,planner,reviewer,tester\}/);
|
|
147
|
+
const invalidRole=spawnSync(pythonExecutable,[pythonPath,'--role','not-a-role','--print-role'],{encoding:'utf8'});
|
|
148
|
+
assert.equal(invalidRole.status,2);
|
|
149
|
+
assert.match(invalidRole.stderr,/^usage: cm_workflow_config\.py \[-h\]/);
|
|
150
|
+
assert.match(invalidRole.stderr,/cm_workflow_config\.py: error: argument --role: invalid choice: 'not-a-role'/);
|
|
151
|
+
const wrapper=fs.readFileSync(pythonPath,'utf8');
|
|
152
|
+
assert(!wrapper.includes('DEFAULT_CONFIG'));
|
|
153
|
+
assert(!wrapper.includes('_parse_yaml_subset'));
|
|
154
|
+
}));
|
|
155
|
+
|
|
156
|
+
test('frozen Python authority vectors preserve numeric token and equals-form behavior',()=>fixture(root=>{
|
|
157
|
+
const configPath=path.join(root,'.cm-workflow.yml');
|
|
158
|
+
for(const text of ['version: 1.0\n','version: 1e0\n']){
|
|
159
|
+
fs.writeFileSync(configPath,text);
|
|
160
|
+
const result=spawnSync(process.execPath,[entryPath,'--project',root],{encoding:'utf8'});
|
|
161
|
+
assert.equal(result.status,1,text.trim());
|
|
162
|
+
}
|
|
163
|
+
fs.writeFileSync(configPath,'version: 1\n');
|
|
164
|
+
const equals=spawnSync(process.execPath,[entryPath,`--project=${root}`,'--role=coder','--runtime=codex','--print-role'],{encoding:'utf8'});
|
|
165
|
+
assert.equal(equals.status,0);
|
|
166
|
+
assert.equal(JSON.parse(equals.stdout).route_state,'current-runtime');
|
|
167
|
+
for(const args of [['--help=x'],['-h=x']]){
|
|
168
|
+
const malformedHelp=spawnSync(process.execPath,[entryPath,...args],{encoding:'utf8'});
|
|
169
|
+
assert.equal(malformedHelp.status,2,args.join(' '));
|
|
170
|
+
}
|
|
171
|
+
for(const args of [['--project','-h'],['--config','-x']]){
|
|
172
|
+
const missingValue=spawnSync(process.execPath,[entryPath,...args],{encoding:'utf8'});
|
|
173
|
+
assert.equal(missingValue.status,2,args.join(' '));
|
|
174
|
+
}
|
|
175
|
+
const abbreviated=spawnSync(process.execPath,[entryPath,`--proj=${root}`,'--print-effective'],{encoding:'utf8'});
|
|
176
|
+
assert.equal(abbreviated.status,0);
|
|
177
|
+
assert.equal(JSON.parse(abbreviated.stdout).version,1);
|
|
178
|
+
const emptyProject=spawnSync(process.execPath,[entryPath,'--project=','--print-effective'],{encoding:'utf8',cwd:root});
|
|
179
|
+
assert.equal(emptyProject.status,0);
|
|
180
|
+
assert.equal(JSON.parse(emptyProject.stdout).version,1);
|
|
181
|
+
}));
|