@aibyzero/cm-workflow 0.17.0 → 0.18.0
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 +1 -1
- package/AGENTS.md +27 -0
- package/CHANGELOG.md +230 -1
- package/CONTRIBUTING.md +47 -0
- package/README.md +21 -3
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/VERSION +1 -1
- package/compat/claude-commands/cm-challenge.md +3 -0
- package/docs/architecture.md +40 -13
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +153 -16
- package/docs/live-evidence-drivers.md +28 -4
- package/docs/out-of-scope/README.md +25 -0
- package/docs/out-of-scope/background-supervisor.md +32 -0
- package/docs/reviewed-integration.md +48 -0
- package/docs/user-guide.md +50 -21
- package/install-codex.sh +331 -18
- package/install.ps1 +28 -2
- package/install.sh +321 -17
- package/package.json +2 -1
- package/runtime/js/cm-ai/batch-location.mjs +55 -0
- package/runtime/js/cm-ai/batch-plan.mjs +242 -0
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +94 -21
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
- package/runtime/js/cm-ai/codex-config.mjs +6 -2
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
- package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
- package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
- package/runtime/js/cm-ai/control-policy.mjs +24 -6
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +236 -34
- package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
- package/runtime/js/cm-ai/effect-contract.mjs +11 -2
- package/runtime/js/cm-ai/execution-policy.mjs +3 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
- package/runtime/js/cm-ai/execution-store.mjs +60 -17
- package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
- package/runtime/js/cm-ai/host-check.mjs +14 -6
- package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
- package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
- package/runtime/js/cm-ai/host-replay.mjs +148 -0
- package/runtime/js/cm-ai/host-session.mjs +42 -9
- package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +22 -9
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
- package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
- package/runtime/js/cm-ai/live-evidence.mjs +28 -6
- package/runtime/js/cm-ai/operator-guidance.mjs +63 -30
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
- package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
- package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
- package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
- package/runtime/js/cm-ai/review-package.mjs +79 -7
- package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
- package/runtime/js/cm-ai/review-presentation.mjs +177 -8
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
- package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
- package/runtime/js/cm-ai/scope-revision.mjs +38 -0
- package/runtime/js/cm-ai/specification-material.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +247 -41
- package/runtime/js/cm-ai/verification-auto.mjs +38 -0
- package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
- package/runtime/js/cm-ai/worker-claude.mjs +35 -13
- package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
- package/runtime/js/cm-ai/worker-codex.mjs +41 -7
- package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
- package/runtime/js/cm-fix/cause-package.mjs +46 -1
- package/runtime/js/cm-fix/command-correction.mjs +37 -0
- package/runtime/js/cm-fix/cooperative.mjs +12 -0
- package/runtime/js/cm-fix/dossier.mjs +8 -2
- package/runtime/js/cm-fix/execution.mjs +578 -100
- package/runtime/js/cm-fix/final-review.mjs +39 -8
- package/runtime/js/cm-fix/finish.mjs +15 -11
- package/runtime/js/cm-fix/host-review.mjs +65 -10
- package/runtime/js/cm-fix/host.mjs +35 -12
- package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
- package/runtime/js/cm-fix/metrics.mjs +18 -5
- package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
- package/runtime/js/cm-fix/regression.mjs +16 -7
- package/runtime/js/cm-fix/repair.mjs +29 -8
- package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
- package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
- package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
- package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
- package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
- package/runtime/js/cm-fix/review-verification.mjs +214 -0
- package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
- package/runtime/js/cm-fix/start.mjs +6 -3
- package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
- package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
- package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
- package/runtime/js/cm-prd/accepted-design.mjs +8 -0
- package/runtime/js/cm-prd/analysis.mjs +13 -9
- package/runtime/js/cm-prd/change.mjs +37 -16
- package/runtime/js/cm-prd/draft-save.mjs +13 -6
- package/runtime/js/cm-prd/draft.mjs +31 -3
- package/runtime/js/cm-prd/failed-correction.mjs +19 -3
- package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
- package/runtime/js/cm-prd/review-correction.mjs +6 -4
- package/runtime/js/cm-prd/review-disposition.mjs +7 -1
- package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
- package/runtime/js/cm-prd/self-check.mjs +125 -6
- package/runtime/js/cm-prd/session.mjs +30 -1
- package/runtime/js/cm-prd/summary.mjs +38 -17
- package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
- package/runtime/js/cm-prd/tree-digest.mjs +34 -0
- package/runtime/js/cm-prd/validation-reason.mjs +8 -4
- package/runtime/js/cm-security/scan.mjs +1 -1
- package/runtime/js/commander/decision.mjs +44 -0
- package/runtime/js/commander/dispatch-registry.mjs +110 -0
- package/runtime/js/commander/ledger.mjs +265 -0
- package/runtime/js/commander/preflight.mjs +107 -0
- package/runtime/js/notify-later.mjs +13 -0
- package/runtime/js/notify-send.mjs +6 -2
- package/runtime/js/notify.mjs +570 -63
- package/runtime/js/review-findings.mjs +38 -0
- package/runtime/js/session-boundary.mjs +56 -0
- package/runtime/js/session-handoff.mjs +68 -0
- package/runtime/js/spec-task-line.mjs +27 -13
- package/runtime/js/specs-status.mjs +1 -1
- package/runtime/js/task-scope.mjs +197 -0
- package/runtime/logging.md +6 -1
- package/runtime/model-efficiency.md +69 -10
- package/runtime/orchestration.md +3 -1
- package/runtime/project-learning.md +2 -0
- package/runtime/review.md +12 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +11 -5
- package/scripts/cm-ai-admission.test.mjs +23 -2
- package/scripts/cm-ai-batch-drive.mjs +79 -18
- package/scripts/cm-ai-batch-drive.test.mjs +169 -3
- package/scripts/cm-ai-batch-host.mjs +38 -9
- package/scripts/cm-ai-batch-host.test.mjs +27 -14
- package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
- package/scripts/cm-ai-batch-location.test.mjs +57 -0
- package/scripts/cm-ai-batch-plan.mjs +52 -0
- package/scripts/cm-ai-batch-plan.test.mjs +397 -0
- package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
- package/scripts/cm-ai-batch-run.mjs +483 -63
- package/scripts/cm-ai-batch-run.test.mjs +23 -4
- package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
- package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
- package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
- package/scripts/cm-ai-control-launch.test.mjs +21 -0
- package/scripts/cm-ai-control-policy.test.mjs +82 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
- package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
- package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
- package/scripts/cm-ai-development-rework.test.mjs +423 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +3 -2
- package/scripts/cm-ai-drive.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +37 -5
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host-fixture.mjs +9 -6
- package/scripts/cm-ai-host-protected.test.mjs +1 -1
- package/scripts/cm-ai-host.mjs +60 -19
- package/scripts/cm-ai-host.test.mjs +15 -0
- package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
- package/scripts/cm-ai-integration-independence.test.mjs +23 -0
- package/scripts/cm-ai-integration-launch.test.mjs +240 -0
- package/scripts/cm-ai-integration-preview.mjs +41 -0
- package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
- package/scripts/cm-ai-nested-execution.test.mjs +29 -1
- package/scripts/cm-ai-operator-guidance.test.mjs +71 -0
- package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
- package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
- package/scripts/cm-ai-review-failure.test.mjs +150 -5
- package/scripts/cm-ai-review-timeout.test.mjs +20 -0
- package/scripts/cm-ai-run.mjs +88 -21
- package/scripts/cm-ai-scope-revision.test.mjs +341 -0
- package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
- package/scripts/cm-ai-supersede.test.mjs +28 -0
- package/scripts/cm-ai-verification-auto.test.mjs +99 -0
- package/scripts/cm-announce-hook.mjs +35 -8
- package/scripts/cm-announce-hook.test.mjs +25 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +2 -2
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +58 -1
- package/scripts/cm-claude-developer-worker.test.mjs +56 -7
- package/scripts/cm-claude-install-layout.test.mjs +1 -1
- package/scripts/cm-claude-probe.test.mjs +26 -0
- package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +49 -0
- package/scripts/cm-claude-worker.test.mjs +16 -0
- package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
- package/scripts/cm-codex-developer-worker.test.mjs +120 -0
- package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
- package/scripts/cm-codex-prompt-input.test.mjs +153 -0
- package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
- package/scripts/cm-commander-ledger.test.mjs +260 -0
- package/scripts/cm-commander-p2.test.mjs +295 -0
- package/scripts/cm-commander-preflight.mjs +84 -0
- package/scripts/cm-commander.mjs +116 -0
- package/scripts/cm-config-lock.mjs +35 -0
- package/scripts/cm-controlled-correction.test.mjs +10 -1
- package/scripts/cm-developer-failure-code.test.mjs +62 -0
- package/scripts/cm-display-task-id.test.mjs +41 -0
- package/scripts/cm-drive-liveness.test.mjs +83 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
- package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
- package/scripts/cm-external-batch-host.test.mjs +12 -9
- package/scripts/cm-external-process-cleanup.test.mjs +128 -0
- package/scripts/cm-external-qa-fix.test.mjs +89 -7
- package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
- package/scripts/cm-failover.mjs +48 -10
- package/scripts/cm-failover.test.mjs +46 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
- package/scripts/cm-fix-command-correction.mjs +17 -0
- package/scripts/cm-fix-command-correction.test.mjs +211 -0
- package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
- package/scripts/cm-fix-drive.mjs +33 -5
- package/scripts/cm-fix-drive.test.mjs +49 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
- package/scripts/cm-fix-host-review.test.mjs +21 -9
- package/scripts/cm-fix-host.mjs +26 -8
- package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
- package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
- package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
- package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
- package/scripts/cm-fix-review-preflight.mjs +24 -0
- package/scripts/cm-fix-review-storage.test.mjs +233 -0
- package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
- package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
- package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
- package/scripts/cm-fix-review-verification.test.mjs +146 -0
- package/scripts/cm-fix-revision-transport.test.mjs +81 -0
- package/scripts/cm-fix-source-correction.test.mjs +296 -0
- package/scripts/cm-fix-test-type-correction.mjs +18 -0
- package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
- package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
- package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
- package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
- package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
- package/scripts/cm-fix-verification-recovery.mjs +33 -0
- package/scripts/cm-host-diagnostic.test.mjs +33 -0
- package/scripts/cm-host-liveness.test.mjs +150 -0
- package/scripts/cm-host-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -0
- package/scripts/cm-host-stage-observer.test.mjs +41 -0
- package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
- package/scripts/cm-install-manifest.sh +351 -0
- package/scripts/cm-live-evidence.test.mjs +59 -1
- package/scripts/cm-log-event.mjs +61 -10
- package/scripts/cm-log-event.test.mjs +121 -1
- package/scripts/cm-matt-skills.mjs +576 -0
- package/scripts/cm-matt-skills.test.mjs +550 -0
- package/scripts/cm-notify-command.test.mjs +42 -10
- package/scripts/cm-notify.mjs +14 -10
- package/scripts/cm-notify.test.mjs +625 -75
- package/scripts/cm-patrol.mjs +4 -1
- package/scripts/cm-patrol.test.mjs +23 -5
- package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
- package/scripts/cm-prd-completion.test.mjs +56 -13
- package/scripts/cm-prd-design-phase.test.mjs +78 -8
- package/scripts/cm-prd-draft-save.test.mjs +12 -0
- package/scripts/cm-prd-draft.test.mjs +1 -1
- package/scripts/cm-prd-drive.mjs +13 -6
- package/scripts/cm-prd-drive.test.mjs +46 -2
- package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
- package/scripts/cm-prd-host.mjs +10 -5
- package/scripts/cm-prd-host.test.mjs +4 -2
- package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
- package/scripts/cm-prd-review-disposition.test.mjs +124 -8
- package/scripts/cm-prd-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +16 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
- package/scripts/cm-prd-self-check.test.mjs +105 -5
- package/scripts/cm-prd-session-recovery.test.mjs +5 -3
- package/scripts/cm-prd-summary.test.mjs +55 -3
- package/scripts/cm-prd-task-grouping.test.mjs +6 -6
- package/scripts/cm-prd-tree-digest.test.mjs +74 -0
- package/scripts/cm-refactor-drive.mjs +2 -1
- package/scripts/cm-refactor-drive.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +3 -15
- package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
- package/scripts/cm-skill-hints-exam.mjs +149 -0
- package/scripts/cm-skill-hints-install.test.mjs +168 -0
- package/scripts/cm-skill-hints.exam.json +706 -0
- package/scripts/cm-skill-hints.json +119 -0
- package/scripts/cm-skill-hints.mjs +669 -0
- package/scripts/cm-skill-hints.test.mjs +831 -0
- package/scripts/cm-skill-judge.mjs +181 -0
- package/scripts/cm-skill-judge.test.mjs +255 -0
- package/scripts/cm-specs-status.test.mjs +4 -2
- package/scripts/cm-start-check.mjs +208 -0
- package/scripts/cm-start-check.test.mjs +321 -0
- package/scripts/cm-task-gate.mjs +150 -29
- package/scripts/cm-task-gate.test.mjs +73 -1
- package/scripts/cm-task-id-grammar.test.mjs +66 -0
- package/scripts/cm-task-scope.test.mjs +308 -0
- package/scripts/cm-test-suite.mjs +109 -0
- package/scripts/cm-test-suite.test.mjs +162 -0
- package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
- package/scripts/cm-upgrade-compat.test.mjs +239 -0
- package/scripts/cm-workflow-config.mjs +12 -2
- package/scripts/fixtures/fix-verification-claude.mjs +44 -0
- package/scripts/fixtures/host-diagnostic.mjs +33 -0
- package/scripts/fixtures/reviewed-integration.mjs +202 -0
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/session-boundary.test.mjs +170 -0
- package/scripts/test-npm-install.py +14 -3
- package/scripts/test-shell-compat.sh +2 -0
- package/scripts/validate-public-repo.py +1 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N4-review.md +2 -1
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/N8-finish.md +22 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
- package/skills/cm-ai/references/js-host-recovery.md +79 -3
- package/skills/cm-ai/references/js-host.md +89 -17
- package/skills/cm-challenge/SKILL.md +65 -0
- package/skills/cm-challenge/evals/README.md +18 -0
- package/skills/cm-challenge/evals/trigger-cases.json +20 -0
- package/skills/cm-challenge/evals/trigger-config.json +28 -0
- package/skills/cm-challenge/references/examples.md +15 -0
- package/skills/cm-check/SKILL.md +5 -0
- package/skills/cm-check/references/js-host.md +2 -0
- package/skills/cm-fix/SKILL.md +12 -3
- package/skills/cm-fix/references/command-correction.md +67 -0
- package/skills/cm-fix/references/isolated-review.md +54 -0
- package/skills/cm-fix/references/js-host.md +62 -2
- package/skills/cm-fix/references/test-type-correction.md +72 -0
- package/skills/cm-fix/references/verification-recovery.md +114 -0
- package/skills/cm-idea/SKILL.md +2 -0
- package/skills/cm-idea/references/js-host.md +2 -0
- package/skills/cm-notify/SKILL.md +2 -0
- package/skills/cm-prd/SKILL.md +12 -8
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +6 -0
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-host.md +4 -2
- package/skills/cm-prd/references/spec-self-check.md +5 -1
- package/skills/cm-refactor/SKILL.md +8 -0
- package/skills/cm-refactor/references/js-host.md +2 -0
- package/skills/cm-test/SKILL.md +4 -0
- package/templates/dashboard/dashboard.html +2 -2
- package/templates/pixel/cm-pixel.html +1 -1
- package/templates/pixel/cm-pixel.sh +1 -1
- package/templates/pixel/dev/template.html +1 -1
- package/templates/statusline/cm-statusline.sh +1 -1
|
@@ -0,0 +1,397 @@
|
|
|
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 {buildManifest} from './cm-spec-manifest.mjs';
|
|
8
|
+
import {createCmAiBatch} from './cm-ai-batch-run.mjs';
|
|
9
|
+
import {main} from './cm-ai-batch-plan.mjs';
|
|
10
|
+
import {planCmAiBatch,parallelSettings} from '../runtime/js/cm-ai/batch-plan.mjs';
|
|
11
|
+
|
|
12
|
+
const scope=file=>`\n - 范围: \`${file}\``;
|
|
13
|
+
function project(t,tasks,{feature='1.work',emptyCode=false,caseKinds=null,taskGrammar=null}={}){
|
|
14
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-batch-plan-')));
|
|
15
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
16
|
+
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code');
|
|
17
|
+
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
|
|
18
|
+
if(!emptyCode)fs.writeFileSync(path.join(codeProject,'README.md'),'# Existing project\n');
|
|
19
|
+
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
|
|
20
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),tasks);
|
|
21
|
+
// caseKinds: a test contract with one blocking case per kind (browser = interactive QA).
|
|
22
|
+
if(caseKinds){
|
|
23
|
+
fs.writeFileSync(path.join(specsDir,feature,'requirements.md'),'- [AC-001]: fixture\n');
|
|
24
|
+
fs.writeFileSync(path.join(specsDir,feature,'test-cases.json'),JSON.stringify({schemaVersion:'1.0',feature:feature.replace(/^\d+\./,''),
|
|
25
|
+
cases:caseKinds.map((kind,index)=>({id:`TC-${String(index+1).padStart(3,'0')}`,origin:'user',kind,blocking:true,acIds:['AC-001'],
|
|
26
|
+
taskIds:['T-001'],title:`${kind} fixture`,preconditions:[],steps:['Observe fixture'],expected:['Fixture evidence'],cleanup:[]}))}));
|
|
27
|
+
}
|
|
28
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir),...(taskGrammar?{taskGrammar}:{})}));
|
|
29
|
+
return {root,specsDir,codeProject,plan:(settings,workflow)=>planCmAiBatch({specsDir,codeProject,repositoryId:'r',batchId:'plan-batch-1',...(settings?{settings}:{}),...(workflow?{workflow}:{})})};
|
|
30
|
+
}
|
|
31
|
+
// worktree_all:false keeps the earlier planner: only groups of two or more.
|
|
32
|
+
const legacy=Object.freeze({enabled:true,max:2,worktree_all:false});
|
|
33
|
+
// T-001 first; T-002 and T-003 each need only T-001; T-004 needs both.
|
|
34
|
+
const diamond=(extra={})=>`- [ ] T-001: contract${scope('a.js')}\n- [ ] T-002: left${scope(extra.left??'b.js')}${extra.leftDevice?'\n - 设备: 需要':''}\n`
|
|
35
|
+
+`- [ ] T-003: right${scope(extra.right??'c.js')}\n- [ ] T-004: final${scope('d.js')}\n\n`
|
|
36
|
+
+'- T-002 依赖 T-001\n- T-003 依赖 T-001\n- T-004 依赖 T-002, T-003\n';
|
|
37
|
+
|
|
38
|
+
test('legacy (worktree_all:false): the diamond groups its two independent middle tasks, and the batch host accepts the config',t=>{
|
|
39
|
+
const f=project(t,diamond()),plan=f.plan(legacy);
|
|
40
|
+
assert.equal(plan.mode,'batch');assert.equal(plan.feature,'1.work');
|
|
41
|
+
assert.deepEqual(plan.groups,[['T-002','T-003']]);
|
|
42
|
+
assert.deepEqual(plan.config.batch.parallel,[['1.work/T-002','1.work/T-003']]);
|
|
43
|
+
assert.deepEqual(plan.config.batch.tasks.map(task=>[task.taskId,task.scope]),[['T-001',['a.js']],['T-002',['b.js']],['T-003',['c.js']],['T-004',['d.js']]]);
|
|
44
|
+
assert.deepEqual(Object.keys(plan.config.workflows),['1.work/T-001','1.work/T-002','1.work/T-003','1.work/T-004']);
|
|
45
|
+
// The same validation the batch host runs: dependencies, final task, overlap, declared scope, device.
|
|
46
|
+
assert.ok(createCmAiBatch({configuration:plan.config.batch,executionFor:async()=>({}),logHome:path.join(f.root,'log')}));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('legacy: no group when a task is undeclared, overlapping, needs a device, chains, or parallelism is off',t=>{
|
|
50
|
+
assert.deepEqual(project(t,diamond().replace(scope('b.js'),'')).plan(legacy),{mode:'serial',feature:'1.work',reason:'scope_undeclared'});
|
|
51
|
+
assert.equal(project(t,diamond().replace(scope('b.js'),'\n - 范围: `src/*`')).plan(legacy).reason,'scope_invalid');
|
|
52
|
+
assert.deepEqual(project(t,diamond({right:'b.js'})).plan(legacy).groups,[]);
|
|
53
|
+
assert.deepEqual(project(t,diamond({leftDevice:true})).plan(legacy).groups,[]);
|
|
54
|
+
const chain=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n\n- T-002 依赖 T-001\n- T-003 依赖 T-002\n`;
|
|
55
|
+
assert.deepEqual(project(t,chain).plan(legacy).groups,[]);
|
|
56
|
+
const off=project(t,diamond()).plan({enabled:false,max:2});
|
|
57
|
+
assert.equal(off.mode,'batch');assert.deepEqual(off.groups,[]);assert.equal(Object.hasOwn(off.config.batch,'parallel'),false);
|
|
58
|
+
assert.deepEqual(project(t,diamond()).plan({...legacy,max:1}).groups,[]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('legacy: max bounds the group; a member needing a task still to run is not pulled ahead of it',t=>{
|
|
62
|
+
const four=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n- [ ] T-004: d${scope('d.js')}\n- [ ] T-005: final${scope('e.js')}\n\n- T-005 依赖 T-001, T-002, T-003, T-004\n`;
|
|
63
|
+
assert.deepEqual(project(t,four).plan(legacy).groups,[['T-001','T-002'],['T-003','T-004']]);
|
|
64
|
+
assert.deepEqual(project(t,four).plan({...legacy,max:3}).groups,[['T-001','T-002','T-003']]);
|
|
65
|
+
// T-003 needs T-001, which is in the group T-002 would start: it starts its own.
|
|
66
|
+
const pulled=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n- [ ] T-004: final${scope('d.js')}\n\n- T-003 依赖 T-001\n`;
|
|
67
|
+
assert.deepEqual(project(t,pulled).plan({...legacy,max:3}).groups,[['T-001','T-002']]);
|
|
68
|
+
// The feature's last task never joins, even when nothing ties it to the others.
|
|
69
|
+
const loose=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: final${scope('b.js')}\n`;
|
|
70
|
+
assert.deepEqual(project(t,loose).plan(legacy).groups,[]);
|
|
71
|
+
// A task waiting on a later task runs after it: the batch order is the one admission
|
|
72
|
+
// follows (its first task is admission's next task), and the host accepts it.
|
|
73
|
+
const forward=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n- [ ] T-004: final${scope('d.js')}\n\n- T-001 依赖 T-003\n`;
|
|
74
|
+
const ahead=project(t,forward),forwardPlan=ahead.plan({...legacy,max:3});
|
|
75
|
+
assert.deepEqual(forwardPlan.config.batch.tasks.map(task=>task.taskId),['T-002','T-003','T-001','T-004']);
|
|
76
|
+
assert.deepEqual(forwardPlan.groups,[['T-002','T-003']]);
|
|
77
|
+
assert.ok(createCmAiBatch({configuration:forwardPlan.config.batch,executionFor:async()=>({}),logHome:path.join(ahead.root,'log')}));
|
|
78
|
+
assert.deepEqual(project(t,forward).plan({enabled:false,max:2}).config.batch.tasks.map(task=>task.taskId),['T-002','T-003','T-001','T-004']);
|
|
79
|
+
// A member whose prerequisite runs later never joins an earlier group.
|
|
80
|
+
const later=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n- [ ] T-004: d${scope('d.js')}\n- [ ] T-005: final${scope('e.js')}\n\n- T-002 依赖 T-004\n`;
|
|
81
|
+
const laterPlan=project(t,later).plan(legacy);
|
|
82
|
+
assert.deepEqual(laterPlan.config.batch.tasks.map(task=>task.taskId),['T-001','T-003','T-004','T-002','T-005']);
|
|
83
|
+
assert.deepEqual(laterPlan.groups,[['T-001','T-003']]);
|
|
84
|
+
// A cycle has no order; admission already refuses it, and so does the plan.
|
|
85
|
+
assert.throws(()=>project(t,`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: final${scope('c.js')}\n\n- T-001 依赖 T-002\n- T-002 依赖 T-001\n`).plan(legacy),
|
|
86
|
+
{code:'batch_plan_not_ready'});
|
|
87
|
+
// The feature's last task already done: the host would refuse any group, so none is planned.
|
|
88
|
+
const lastDone=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n- [x] T-004: final${scope('d.js')}\n`;
|
|
89
|
+
const donePlan=project(t,lastDone).plan(legacy);
|
|
90
|
+
assert.equal(donePlan.mode,'batch');assert.deepEqual(donePlan.groups,[]);
|
|
91
|
+
// T-003 runs first, so T-002 runs last: it collects the deferred QA and cannot be a
|
|
92
|
+
// member, and the host refuses a hand-written tail group for a new batch.
|
|
93
|
+
const tail=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n\n- T-001 依赖 T-003\n- T-002 依赖 T-003\n`;
|
|
94
|
+
const tailProject=project(t,tail),tailPlan=tailProject.plan({...legacy,max:3});
|
|
95
|
+
assert.deepEqual(tailPlan.config.batch.tasks.map(task=>task.taskId),['T-003','T-001','T-002']);assert.deepEqual(tailPlan.groups,[]);
|
|
96
|
+
assert.throws(()=>createCmAiBatch({configuration:{...tailPlan.config.batch,parallel:[['1.work/T-001','1.work/T-002']]},
|
|
97
|
+
executionFor:async()=>({}),logHome:path.join(tailProject.root,'log')}),{code:'parallel_final_task_excluded'});
|
|
98
|
+
// Completed tasks are satisfied prerequisites, not batch members.
|
|
99
|
+
const done=diamond().replace('- [ ] T-001','- [x] T-001');
|
|
100
|
+
const plan=project(t,done).plan(legacy);
|
|
101
|
+
assert.deepEqual(plan.config.batch.tasks.map(task=>task.taskId),['T-002','T-003','T-004']);assert.deepEqual(plan.groups,[['T-002','T-003']]);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('worktree_all (default): every task except the last ones and device tasks runs in its own worktree',t=>{
|
|
105
|
+
// Diamond: T-001 alone in a worktree, then T-002 + T-003 together; T-004 (the last) in the main checkout.
|
|
106
|
+
const f=project(t,diamond()),plan=f.plan();
|
|
107
|
+
assert.deepEqual(plan.groups,[['T-001'],['T-002','T-003']]);
|
|
108
|
+
assert.deepEqual(plan.config.batch.parallel,[['1.work/T-001'],['1.work/T-002','1.work/T-003']]);
|
|
109
|
+
assert.ok(createCmAiBatch({configuration:plan.config.batch,executionFor:async()=>({}),logHome:path.join(f.root,'log')}));
|
|
110
|
+
// A chain cannot pair, but each task before the last still gets a one-member group.
|
|
111
|
+
const chain=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n\n- T-002 依赖 T-001\n- T-003 依赖 T-002\n`;
|
|
112
|
+
const chained=project(t,chain),chainPlan=chained.plan();
|
|
113
|
+
assert.deepEqual(chainPlan.groups,[['T-001'],['T-002']]);
|
|
114
|
+
assert.ok(createCmAiBatch({configuration:chainPlan.config.batch,executionFor:async()=>({}),logHome:path.join(chained.root,'log')}));
|
|
115
|
+
// max:1 never pairs; every candidate is still alone in a worktree.
|
|
116
|
+
assert.deepEqual(project(t,diamond()).plan({enabled:true,max:1}).groups,[['T-001'],['T-002'],['T-003']]);
|
|
117
|
+
// Overlapping scopes cannot share a group; they run one after another, each in its own worktree.
|
|
118
|
+
assert.deepEqual(project(t,diamond({right:'b.js'})).plan().groups,[['T-001'],['T-002'],['T-003']]);
|
|
119
|
+
// A device task stays in the main checkout; the tasks around it still get worktrees.
|
|
120
|
+
const device=project(t,diamond({leftDevice:true})),devicePlan=device.plan();
|
|
121
|
+
assert.deepEqual(devicePlan.groups,[['T-001'],['T-003']]);
|
|
122
|
+
assert.throws(()=>createCmAiBatch({configuration:{...devicePlan.config.batch,parallel:[['1.work/T-002']]},
|
|
123
|
+
executionFor:async()=>({}),logHome:path.join(device.root,'log')}),{code:'parallel_device_task'});
|
|
124
|
+
// The feature's last task never gets a worktree, not even alone.
|
|
125
|
+
assert.throws(()=>createCmAiBatch({configuration:{...plan.config.batch,parallel:[['1.work/T-004']]},
|
|
126
|
+
executionFor:async()=>({}),logHome:path.join(f.root,'log-final')}),{code:'parallel_final_task_excluded'});
|
|
127
|
+
// Two tasks: only the first gets a worktree. One task left: nothing to group.
|
|
128
|
+
assert.deepEqual(project(t,`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: final${scope('b.js')}\n`).plan().groups,[['T-001']]);
|
|
129
|
+
assert.deepEqual(project(t,`- [x] T-001: a${scope('a.js')}\n- [ ] T-002: final${scope('b.js')}\n`).plan().groups,[]);
|
|
130
|
+
// T-003 runs first, so T-002 runs last: neither the feature's last task (T-003) nor the
|
|
131
|
+
// last one to run (T-002) gets a worktree; the host refuses a hand-written one for T-002.
|
|
132
|
+
const tail=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n\n- T-001 依赖 T-003\n- T-002 依赖 T-003\n`;
|
|
133
|
+
const tailProject=project(t,tail),tailPlan=tailProject.plan();
|
|
134
|
+
assert.deepEqual(tailPlan.config.batch.tasks.map(task=>task.taskId),['T-003','T-001','T-002']);assert.deepEqual(tailPlan.groups,[['T-001']]);
|
|
135
|
+
assert.throws(()=>createCmAiBatch({configuration:{...tailPlan.config.batch,parallel:[['1.work/T-002']]},
|
|
136
|
+
executionFor:async()=>({}),logHome:path.join(tailProject.root,'log')}),{code:'parallel_final_task_excluded'});
|
|
137
|
+
// The feature's last task already done: no group at all, as before.
|
|
138
|
+
assert.deepEqual(project(t,`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [x] T-003: final${scope('c.js')}\n`).plan().groups,[]);
|
|
139
|
+
// Off switches: worktree_all:false keeps only real pairs; enabled:false plans no worktree at all.
|
|
140
|
+
assert.deepEqual(project(t,diamond()).plan({enabled:true,max:2,worktree_all:false}).groups,[['T-002','T-003']]);
|
|
141
|
+
assert.deepEqual(project(t,chain).plan({enabled:true,max:2,worktree_all:false}).groups,[]);
|
|
142
|
+
const off=project(t,diamond()).plan({enabled:false,max:2,worktree_all:true});
|
|
143
|
+
assert.deepEqual(off.groups,[]);assert.equal(Object.hasOwn(off.config.batch,'parallel'),false);
|
|
144
|
+
// Serial modes are unchanged: undeclared scope and the scaffold feature.
|
|
145
|
+
assert.equal(project(t,diamond().replace(scope('b.js'),'')).plan().mode,'serial');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('a feature with interactive QA cases keeps its unpaired tasks in the main checkout; real groups are unchanged',t=>{
|
|
149
|
+
// Interactive QA (browser, simulator) may target a server or app built from the main
|
|
150
|
+
// checkout, so a task alone in a worktree would be checked against unmerged code.
|
|
151
|
+
const f=project(t,diamond(),{caseKinds:['logic','browser']}),plan=f.plan();
|
|
152
|
+
assert.deepEqual(plan.groups,[['T-002','T-003']]);
|
|
153
|
+
assert.ok(createCmAiBatch({configuration:plan.config.batch,executionFor:async()=>({}),logHome:path.join(f.root,'log')}));
|
|
154
|
+
const chain=`- [ ] T-001: a${scope('a.js')}\n- [ ] T-002: b${scope('b.js')}\n- [ ] T-003: c${scope('c.js')}\n\n- T-002 依赖 T-001\n- T-003 依赖 T-002\n`;
|
|
155
|
+
assert.deepEqual(project(t,chain,{caseKinds:['browser']}).plan().groups,[]);
|
|
156
|
+
// The batch host refuses a hand-written one-member group in such a feature.
|
|
157
|
+
assert.throws(()=>createCmAiBatch({configuration:{...plan.config.batch,parallel:[['1.work/T-001'],['1.work/T-002','1.work/T-003']]},
|
|
158
|
+
executionFor:async()=>({}),logHome:path.join(f.root,'log-solo')}),{code:'parallel_solo_interactive_qa'});
|
|
159
|
+
// Logic-only cases do not stop one-member groups.
|
|
160
|
+
assert.deepEqual(project(t,diamond(),{caseKinds:['logic']}).plan().groups,[['T-001'],['T-002','T-003']]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// A task alone in a worktree should not hit a fixed N6 checkpoint there: the batch has no
|
|
164
|
+
// QA repair path. The planner predicts it with the same N6 rules (host-qa-policy.mjs) and
|
|
165
|
+
// keeps such a task in the main checkout; the batch host refuses a hand-written one.
|
|
166
|
+
const chainOf=(count,done=0)=>Array.from({length:count},(_,index)=>`- [${index<done?'x':' '}] T-00${index+1}: t${index+1}${scope(`f${index+1}.js`)}\n`).join('')
|
|
167
|
+
+'\n'+Array.from({length:count-1},(_,index)=>`- T-00${index+2} 依赖 T-00${index+1}\n`).join('');
|
|
168
|
+
const host=(f,batch,workflows={})=>createCmAiBatch({configuration:batch,workflows,executionFor:async()=>({}),logHome:path.join(f.root,`log-${Math.random()}`)});
|
|
169
|
+
test('one-member groups stop before a task could be the fifth without QA',t=>{
|
|
170
|
+
// Nothing assessed yet: tasks 1-4 may run alone; task 5 could trigger five_tasks_without_qa.
|
|
171
|
+
const f=project(t,chainOf(7)),plan=f.plan();
|
|
172
|
+
assert.deepEqual(plan.groups,[['T-001'],['T-002'],['T-003'],['T-004']]);
|
|
173
|
+
assert.ok(host(f,plan.config.batch));
|
|
174
|
+
assert.throws(()=>host(f,{...plan.config.batch,parallel:[['1.work/T-005']]}),{code:'parallel_solo_qa_checkpoint'});
|
|
175
|
+
// Two tasks already completed without a QA row count, as the decision counts them.
|
|
176
|
+
assert.deepEqual(project(t,chainOf(7,2)).plan().groups,[['T-003'],['T-004']]);
|
|
177
|
+
// Real groups defer their QA and are unaffected.
|
|
178
|
+
assert.deepEqual(project(t,chainOf(7)).plan({enabled:true,max:2,worktree_all:false}).groups,[]);
|
|
179
|
+
});
|
|
180
|
+
test('a fifth task kept in the main checkout resets the count when the host policy decides QA',t=>{
|
|
181
|
+
// Ticket 05: T-005 stays in the main checkout as the fifth without QA, so its QA
|
|
182
|
+
// triggers for certain and T-006 starts from zero again. That holds only where the
|
|
183
|
+
// host policy decides QA: a workflow configuration, or the batch's control policy.
|
|
184
|
+
const none={qa:{criticalPaths:{}},applicableAgentFiles:[]};
|
|
185
|
+
const keys=ids=>ids.map(id=>[`T-00${id}`]);
|
|
186
|
+
const f=project(t,chainOf(9)),plan=f.plan(undefined,none);
|
|
187
|
+
assert.deepEqual(plan.groups,keys([1,2,3,4,6,7,8]));
|
|
188
|
+
const every=workflow=>Object.fromEntries(plan.config.batch.tasks.map(task=>[`1.work/${task.taskId}`,workflow]));
|
|
189
|
+
assert.ok(host(f,plan.config.batch,every(none)));
|
|
190
|
+
assert.ok(host(f,{...plan.config.batch,controlPolicy:{version:2,development:'conversation',bootstrap:'disabled',qa:'disabled',qaFix:'disabled'}}));
|
|
191
|
+
// Without either the session supplies the decision, which may skip: no certain reset.
|
|
192
|
+
assert.deepEqual(f.plan().groups,keys([1,2,3,4]));
|
|
193
|
+
assert.throws(()=>host(f,plan.config.batch),{code:'parallel_solo_qa_checkpoint',reason:/^1\.work\/T-006: /});
|
|
194
|
+
// A task kept in the main checkout for a registered path may or may not trigger (the
|
|
195
|
+
// decision sees the files actually changed), so both counts stay possible after it.
|
|
196
|
+
const auth={qa:{criticalPaths:{authentication:['f2.js']}},applicableAgentFiles:[]};
|
|
197
|
+
assert.deepEqual(f.plan(undefined,auth).groups,keys([1,3,4,6,8]));
|
|
198
|
+
assert.throws(()=>host(f,{...plan.config.batch,parallel:[1,3,4,6,7].map(id=>[`1.work/T-00${id}`])},every(auth)),{code:'parallel_solo_qa_checkpoint',reason:/T-007/});
|
|
199
|
+
// Tasks completed with no QA row at all stay counted after a triggered QA.
|
|
200
|
+
assert.deepEqual(project(t,chainOf(9,2)).plan(undefined,none).groups,keys([3,4,6,7]));
|
|
201
|
+
});
|
|
202
|
+
test('the count walk keeps every reset a group, qa:null or several features may hide',t=>{
|
|
203
|
+
// Review r1 (ticket 05). Each case once let a one-member group reach five in its worktree.
|
|
204
|
+
const none={qa:{criticalPaths:{}},applicableAgentFiles:[]};
|
|
205
|
+
const solo=ids=>ids.map(id=>[`1.work/T-00${id}`]);
|
|
206
|
+
const every=(batch,workflow)=>Object.fromEntries(batch.tasks.map(task=>[`1.work/${task.taskId}`,workflow]));
|
|
207
|
+
// 1. A workflow with qa:null keeps the session-supplied QA decision: no certain reset.
|
|
208
|
+
const f=project(t,chainOf(9)),reset=f.plan(undefined,none);
|
|
209
|
+
assert.deepEqual(f.plan(undefined,{qa:null,applicableAgentFiles:[]}).groups,solo([1,2,3,4]).map(([key])=>[key.slice(7)]));
|
|
210
|
+
assert.throws(()=>host(f,reset.config.batch,every(reset.config.batch,{qa:null,applicableAgentFiles:[]})),
|
|
211
|
+
{code:'parallel_solo_qa_checkpoint',reason:/^1\.work\/T-006: /});
|
|
212
|
+
// 2. A blocked member of a real group reruns in the main checkout and may trigger QA
|
|
213
|
+
// there, after the other members' rows: the count after the group may be low.
|
|
214
|
+
const grouped=`- [ ] T-001: t1${scope('f1.js')}\n- [ ] T-002: t2${scope('f2.js')}\n`
|
|
215
|
+
+Array.from({length:7},(_,index)=>`- [ ] T-00${index+3}: t${index+3}${scope(`f${index+3}.js`)}\n`).join('')
|
|
216
|
+
+'\n- T-003 依赖 T-001, T-002\n'+Array.from({length:6},(_,index)=>`- T-00${index+4} 依赖 T-00${index+3}\n`).join('');
|
|
217
|
+
const g=project(t,grouped),plan=g.plan(undefined,none);
|
|
218
|
+
assert.deepEqual(plan.groups,[['T-001','T-002'],['T-003'],['T-004'],['T-008']]);
|
|
219
|
+
assert.ok(host(g,plan.config.batch,every(plan.config.batch,none)));
|
|
220
|
+
assert.throws(()=>host(g,{...plan.config.batch,parallel:[['1.work/T-001','1.work/T-002'],...solo([3,4,6,7,8])]},every(plan.config.batch,none)),
|
|
221
|
+
{code:'parallel_solo_qa_checkpoint',reason:/^1\.work\/T-006: /});
|
|
222
|
+
// 3. A hand-written group out of task order starts at its first member (T-001 and T-005
|
|
223
|
+
// run first), and a blocked later member reruns only once it is the first unfinished
|
|
224
|
+
// task, after the outside tasks before it (review r2: T-003 rerun after T-002 reset the
|
|
225
|
+
// count, T-008 reached five). With one-member groups, groups must be contiguous.
|
|
226
|
+
const free=Array.from({length:9},(_,index)=>`- [ ] T-00${index+1}: t${index+1}${scope(`f${index+1}.js`)}\n`).join('');
|
|
227
|
+
const h=project(t,free),batch=h.plan(undefined,none).config.batch;
|
|
228
|
+
assert.throws(()=>host(h,{...batch,parallel:[['1.work/T-001','1.work/T-005'],...solo([7,8])]},every(batch,none)),
|
|
229
|
+
{code:'parallel_solo_split_group',reason:/^1\.work\/T-001,1\.work\/T-005: /});
|
|
230
|
+
assert.throws(()=>host(h,{...batch,parallel:[['1.work/T-001','1.work/T-003'],...solo([8])]},every(batch,none)),
|
|
231
|
+
{code:'parallel_solo_split_group',reason:/^1\.work\/T-001,1\.work\/T-003: /});
|
|
232
|
+
// Contiguous in task order is enough, whatever the order inside the group; and with no
|
|
233
|
+
// one-member group there is no count to protect.
|
|
234
|
+
assert.ok(host(h,{...batch,parallel:[['1.work/T-002','1.work/T-001'],...solo([8])]},every(batch,none)));
|
|
235
|
+
assert.ok(host(h,{...batch,parallel:[['1.work/T-001','1.work/T-005']]},every(batch,none)));
|
|
236
|
+
// 4. The count spans features and a closing feature leaves floor: no one-member group
|
|
237
|
+
// in a batch of several features.
|
|
238
|
+
const more=path.join(h.specsDir,'2.more');fs.mkdirSync(more);
|
|
239
|
+
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(more,name),'# Fixture\n');
|
|
240
|
+
fs.writeFileSync(path.join(more,'tasks.md'),`- [ ] T-001: g1${scope('g1.js')}\n`);
|
|
241
|
+
fs.writeFileSync(path.join(h.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.work','2.more'],specFiles:buildManifest(h.specsDir)}));
|
|
242
|
+
assert.throws(()=>host(h,{...batch,tasks:[...batch.tasks,{feature:'2.more',taskId:'T-001',scope:['g1.js'],requirements:[]}],
|
|
243
|
+
parallel:solo([1])},{...every(batch,none),'2.more/T-001':none}),{code:'parallel_solo_multi_feature'});
|
|
244
|
+
});
|
|
245
|
+
test('one-member groups skip a task whose scope hits a registered QA critical path',t=>{
|
|
246
|
+
const workflow={qa:{criticalPaths:{authentication:['a.js']}},applicableAgentFiles:[]};
|
|
247
|
+
const f=project(t,diamond());
|
|
248
|
+
// T-001 changes a.js (authentication): it stays in the main checkout.
|
|
249
|
+
assert.deepEqual(f.plan(undefined,workflow).groups,[['T-002','T-003']]);
|
|
250
|
+
// A registered path a real group member changes does not matter: that QA is deferred.
|
|
251
|
+
assert.deepEqual(f.plan(undefined,{qa:{criticalPaths:{payment:['b.js']}},applicableAgentFiles:[]}).groups,[['T-001'],['T-002','T-003']]);
|
|
252
|
+
// The batch host checks the workflows it is launched with, whatever the plan said.
|
|
253
|
+
const plan=f.plan();
|
|
254
|
+
assert.deepEqual(plan.groups,[['T-001'],['T-002','T-003']]);
|
|
255
|
+
assert.throws(()=>host(f,plan.config.batch,{'1.work/T-001':workflow}),{code:'parallel_solo_qa_checkpoint'});
|
|
256
|
+
// Learning writes AGENTS.md, so a registered AGENTS.md path counts as well.
|
|
257
|
+
assert.throws(()=>host(f,plan.config.batch,{'1.work/T-001':{qa:{criticalPaths:{api:['AGENTS.md']}},applicableAgentFiles:[]}}),
|
|
258
|
+
{code:'parallel_solo_qa_checkpoint'});
|
|
259
|
+
assert.ok(host(f,plan.config.batch,{'1.work/T-001':{qa:{criticalPaths:{api:['other.js']}},applicableAgentFiles:[]}}));
|
|
260
|
+
});
|
|
261
|
+
test('one-member groups need the project configuration a worktree gets from Git',t=>{
|
|
262
|
+
// Review r2: a Git-ignored local .cm-workflow.yml does not reach the worktree, where QA
|
|
263
|
+
// reloads the configuration. Here it narrows tests to commands, so the main checkout sees
|
|
264
|
+
// no applicable browser case while the worktree (defaults) would plan one.
|
|
265
|
+
const f=project(t,diamond(),{caseKinds:['logic','browser']});
|
|
266
|
+
const cases=path.join(f.specsDir,'1.work','test-cases.json'),contract=JSON.parse(fs.readFileSync(cases,'utf8'));
|
|
267
|
+
contract.cases.find(item=>item.kind==='browser').blocking=false;fs.writeFileSync(cases,JSON.stringify(contract));
|
|
268
|
+
fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.work'],specFiles:buildManifest(f.specsDir)}));
|
|
269
|
+
const git=(...args)=>{const result=spawnSync('git',['-C',f.codeProject,...args],{encoding:'utf8'});assert.equal(result.status,0,result.stderr);return result.stdout;};
|
|
270
|
+
git('init','-q','-b','main');git('config','user.name','Fixture');git('config','user.email','fixture@example.invalid');
|
|
271
|
+
fs.writeFileSync(path.join(f.codeProject,'.gitignore'),'.cm-workflow.yml\n');
|
|
272
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.yml'),'version: 1\npolicies:\n tests: [commands]\n');
|
|
273
|
+
git('add','-A');git('commit','-qm','base');assert.equal(git('status','--porcelain'),'');
|
|
274
|
+
const plan=f.plan();
|
|
275
|
+
assert.deepEqual(plan.groups,[['T-002','T-003']]);
|
|
276
|
+
assert.throws(()=>host(f,{...plan.config.batch,parallel:[['1.work/T-001'],['1.work/T-002','1.work/T-003']]}),{code:'parallel_solo_config_untracked'});
|
|
277
|
+
// Committed as it is, the same bytes reach every worktree: one-member groups are back.
|
|
278
|
+
fs.writeFileSync(path.join(f.codeProject,'.gitignore'),'');git('add','-A');git('commit','-qm','track config');
|
|
279
|
+
assert.deepEqual(f.plan().groups,[['T-001'],['T-002','T-003']]);
|
|
280
|
+
// Review r3: tracked and `git status` clean is not enough. With skip-worktree the main
|
|
281
|
+
// checkout keeps a local override that a worktree (checked out from HEAD) never sees.
|
|
282
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.yml'),'version: 1\n');git('commit','-qam','default config in HEAD');
|
|
283
|
+
git('update-index','--skip-worktree','.cm-workflow.yml');
|
|
284
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.yml'),'version: 1\npolicies:\n tests: [commands]\n');
|
|
285
|
+
assert.equal(git('status','--porcelain'),'');
|
|
286
|
+
const diverged=f.plan();
|
|
287
|
+
assert.deepEqual(diverged.groups,[['T-002','T-003']]);
|
|
288
|
+
assert.throws(()=>host(f,{...diverged.config.batch,parallel:[['1.work/T-001'],['1.work/T-002','1.work/T-003']]}),{code:'parallel_solo_config_diverged'});
|
|
289
|
+
// The same holds for assume-unchanged.
|
|
290
|
+
git('update-index','--no-skip-worktree','.cm-workflow.yml');git('checkout','--','.cm-workflow.yml');
|
|
291
|
+
git('update-index','--assume-unchanged','.cm-workflow.yml');
|
|
292
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.yml'),'version: 1\npolicies:\n tests: [commands]\n');
|
|
293
|
+
assert.equal(git('status','--porcelain'),'');
|
|
294
|
+
assert.deepEqual(f.plan().groups,[['T-002','T-003']]);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
test('a scaffold feature is serial; a finished project is complete; settings are validated',t=>{
|
|
298
|
+
assert.deepEqual(project(t,`- [ ] T-001: scaffold\n - 范围: 串行\n`,{feature:'0.bootstrap',emptyCode:true}).plan(),{mode:'serial',feature:'0.bootstrap',reason:'bootstrap_feature'});
|
|
299
|
+
assert.deepEqual(project(t,diamond().replaceAll('- [ ]','- [x]')).plan(),{mode:'complete'});
|
|
300
|
+
assert.deepEqual(parallelSettings({}),{enabled:true,max:2,worktree_all:true});
|
|
301
|
+
assert.deepEqual(parallelSettings({parallel:{max:3}}),{enabled:true,max:3,worktree_all:true});
|
|
302
|
+
assert.deepEqual(parallelSettings({parallel:{worktree_all:false}}),{enabled:true,max:2,worktree_all:false});
|
|
303
|
+
for(const parallel of [{max:5},{max:0},{enabled:'yes'},{max:2.5},{worktree_all:'no'},{worktree_all:1}])assert.throws(()=>parallelSettings({parallel}),{code:'invalid_parallel_settings'});
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
test('the CLI reads the project parallel settings and prints the plan',t=>{
|
|
307
|
+
const f=project(t,diamond());
|
|
308
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.yml'),'version: 1\nparallel:\n enabled: false\n');
|
|
309
|
+
const writes=[];const original=process.stdout.write.bind(process.stdout);
|
|
310
|
+
process.stdout.write=chunk=>{writes.push(String(chunk));return true;};
|
|
311
|
+
let code;try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1']);}
|
|
312
|
+
finally{process.stdout.write=original;}
|
|
313
|
+
assert.equal(code,0);assert.deepEqual(JSON.parse(writes.join('')).groups,[]);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test('the CLI reads parallel.worktree_all; the default gives every task before the last its own worktree',t=>{
|
|
317
|
+
const run=f=>{
|
|
318
|
+
const writes=[];const original=process.stdout.write.bind(process.stdout);
|
|
319
|
+
process.stdout.write=chunk=>{writes.push(String(chunk));return true;};
|
|
320
|
+
let code;try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1']);}
|
|
321
|
+
finally{process.stdout.write=original;}
|
|
322
|
+
assert.equal(code,0);return JSON.parse(writes.join('')).groups;
|
|
323
|
+
};
|
|
324
|
+
assert.deepEqual(run(project(t,diamond())),[['T-001'],['T-002','T-003']]);
|
|
325
|
+
const legacyProject=project(t,diamond());
|
|
326
|
+
fs.writeFileSync(path.join(legacyProject.codeProject,'.cm-workflow.yml'),'version: 1\nparallel:\n worktree_all: false\n');
|
|
327
|
+
assert.deepEqual(run(legacyProject),[['T-002','T-003']]);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
test('the CLI reads --workflow-config and keeps a task hitting a registered QA path in the main checkout',t=>{
|
|
331
|
+
const f=project(t,diamond()),workflow=path.join(f.root,'workflow.json');
|
|
332
|
+
fs.writeFileSync(workflow,JSON.stringify({qa:{commands:[],environment:{kind:'web',carrier:'browser',target:'fixture',scope:'local'},
|
|
333
|
+
criticalPaths:{authentication:['a.js']}},documentationPaths:[],applicableAgentFiles:[]}));
|
|
334
|
+
const writes=[];const original=process.stdout.write.bind(process.stdout);
|
|
335
|
+
process.stdout.write=chunk=>{writes.push(String(chunk));return true;};
|
|
336
|
+
let code;try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1','--workflow-config',workflow]);}
|
|
337
|
+
finally{process.stdout.write=original;}
|
|
338
|
+
assert.equal(code,0);assert.deepEqual(JSON.parse(writes.join('')).groups,[['T-002','T-003']]);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// Grammar 3 (design 3.3/3.5): the session's walkthrough stays in the batch as the
|
|
342
|
+
// serial last task; the plan lists it in batch.memberDevelopment and fills workflows.
|
|
343
|
+
const workflowConfig=Object.freeze({qa:null,documentationPaths:[],applicableAgentFiles:[]});
|
|
344
|
+
const walkthrough='\n - 开发: 会话';
|
|
345
|
+
test('grammar 3: the session last task stays serial in the batch and is listed in memberDevelopment',t=>{
|
|
346
|
+
const tasks=diamond().replace(`- [ ] T-004: final${scope('d.js')}`,`- [ ] T-004: final${scope('d.js')}${walkthrough}`);
|
|
347
|
+
const f=project(t,tasks,{taskGrammar:3}),plan=f.plan(legacy,workflowConfig);
|
|
348
|
+
assert.deepEqual(plan.groups,[['T-002','T-003']]);
|
|
349
|
+
assert.deepEqual(plan.config.batch.tasks.map(task=>task.taskId),['T-001','T-002','T-003','T-004']);
|
|
350
|
+
assert.deepEqual(plan.config.batch.memberDevelopment,{'1.work/T-004':'session'});
|
|
351
|
+
assert.deepEqual(Object.keys(plan.config.batch),['version','repositoryId','batchId','specsDir','codeProject','tasks','parallel','memberDevelopment']);
|
|
352
|
+
assert.deepEqual(Object.values(plan.config.workflows),[workflowConfig,workflowConfig,workflowConfig,workflowConfig]);
|
|
353
|
+
// Under grammar 2 the same bytes have no session task: the field is absent.
|
|
354
|
+
const two=project(t,tasks,{taskGrammar:2}).plan(legacy,workflowConfig);
|
|
355
|
+
assert.equal(Object.hasOwn(two.config.batch,'memberDevelopment'),false);
|
|
356
|
+
});
|
|
357
|
+
test('without a session task the plan has the exact pre-grammar-3 shape; a workflow config fills workflows',t=>{
|
|
358
|
+
for(const taskGrammar of [null,2,3]){
|
|
359
|
+
const f=project(t,diamond(),{taskGrammar}),plan=f.plan(legacy);
|
|
360
|
+
assert.deepEqual(plan.config,{batch:{version:1,repositoryId:'r',batchId:'plan-batch-1',specsDir:f.specsDir,codeProject:f.codeProject,
|
|
361
|
+
tasks:[['T-001','a.js'],['T-002','b.js'],['T-003','c.js'],['T-004','d.js']].map(([taskId,file])=>({feature:'1.work',taskId,scope:[file],requirements:[]})),
|
|
362
|
+
parallel:[['1.work/T-002','1.work/T-003']]},
|
|
363
|
+
workflows:{'1.work/T-001':null,'1.work/T-002':null,'1.work/T-003':null,'1.work/T-004':null}});
|
|
364
|
+
assert.deepEqual(f.plan(legacy,workflowConfig).config.workflows,Object.fromEntries(['T-001','T-002','T-003','T-004'].map(id=>[`1.work/${id}`,workflowConfig])));
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
test('the CLI writes --workflow-config into every member workflows entry',t=>{
|
|
368
|
+
const f=project(t,diamond()),file=path.join(f.root,'workflow.json');
|
|
369
|
+
fs.writeFileSync(file,JSON.stringify(workflowConfig));
|
|
370
|
+
const writes=[];const original=process.stdout.write.bind(process.stdout);
|
|
371
|
+
process.stdout.write=chunk=>{writes.push(String(chunk));return true;};
|
|
372
|
+
let code;try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1','--workflow-config',file]);}
|
|
373
|
+
finally{process.stdout.write=original;}
|
|
374
|
+
assert.equal(code,0);
|
|
375
|
+
assert.ok(Object.values(JSON.parse(writes.join('')).config.workflows).every(item=>JSON.stringify(item)===JSON.stringify(workflowConfig)));
|
|
376
|
+
});
|
|
377
|
+
test('grammar 3: a task waiting for the session task, directly or transitively, is refused by the planner',t=>{
|
|
378
|
+
const text=deps=>[1,2,3].map(n=>`- [ ] T-00${n}: t${n}${scope(`${n}.js`)}${n===3?walkthrough:''}`).join('\n')+'\n\n'+deps.join('\n')+'\n';
|
|
379
|
+
const refused=(deps,dependents)=>assert.throws(()=>project(t,text(deps),{taskGrammar:3}).plan(legacy),
|
|
380
|
+
error=>error.code==='session_task_depended_on'&&error.reason.includes(`任务 ${dependents} 直接或间接依赖`)&&error.reason.includes('T-003'),deps.join(' / '));
|
|
381
|
+
// Declared last, but the dependency order would run T-003 before T-001.
|
|
382
|
+
refused(['- T-001 依赖 T-003'],'T-001');
|
|
383
|
+
refused(['- T-001 依赖 T-002','- T-002 依赖 T-003'],'T-001, T-002');
|
|
384
|
+
// Legal: the session task waits for the others and is the last task the batch runs.
|
|
385
|
+
const plan=project(t,text(['- T-003 依赖 T-001, T-002']),{taskGrammar:3}).plan(legacy);
|
|
386
|
+
assert.equal(plan.mode,'batch');assert.equal(plan.config.batch.tasks.at(-1).taskId,'T-003');
|
|
387
|
+
assert.deepEqual(plan.config.batch.memberDevelopment,{'1.work/T-003':'session'});
|
|
388
|
+
});
|
|
389
|
+
test('grammar 3 session tasks: not final, several, or (defensively) grouped are refused by code',t=>{
|
|
390
|
+
const chain=(marks)=>[1,2,3].map(n=>`- [ ] T-00${n}: t${n}${scope(`${n}.js`)}${marks.includes(n)?walkthrough:''}`).join('\n')+'\n';
|
|
391
|
+
assert.throws(()=>project(t,chain([2]),{taskGrammar:3}).plan(),{code:'session_task_not_final'});
|
|
392
|
+
assert.throws(()=>project(t,chain([2,3]),{taskGrammar:3}).plan(),{code:'session_task_multiple'});
|
|
393
|
+
assert.equal(project(t,chain([2]),{taskGrammar:2}).plan().mode,'batch','grammar 2 ignores the mark');
|
|
394
|
+
// The final task is never a group member; one marked session is still listed alone.
|
|
395
|
+
const plan=project(t,chain([3]),{taskGrammar:3}).plan();
|
|
396
|
+
assert.ok(plan.groups.every(group=>!group.includes('T-003')));assert.deepEqual(plan.config.batch.memberDevelopment,{'1.work/T-003':'session'});
|
|
397
|
+
});
|