@aibyzero/cm-workflow 0.17.1 → 0.19.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 +23 -0
- package/CHANGELOG.md +242 -0
- package/README.md +20 -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 +11 -0
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +150 -15
- 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/autonomy.mjs +152 -0
- 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 +83 -14
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +56 -17
- 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 +21 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +115 -11
- 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 +11 -5
- 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 +1 -1
- 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 +9 -2
- 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 +242 -39
- 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 +11 -5
- 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 +581 -65
- 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 +5 -4
- 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 +3 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +21 -7
- package/scripts/cm-ai-admission.test.mjs +171 -3
- 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 +6 -5
- 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 +471 -57
- 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 +14 -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.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +34 -2
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host.mjs +60 -19
- 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 +16 -1
- 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-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-autonomy.mjs +94 -0
- package/scripts/cm-autonomy.test.mjs +162 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +1 -1
- package/scripts/cm-check-runtime.sh +60 -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-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +13 -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-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 +4 -3
- 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-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -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 +581 -59
- 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 +45 -1
- 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 +1 -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-summary.test.mjs +24 -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 +1 -1
- 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 +323 -0
- package/scripts/cm-start-check.test.mjs +406 -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-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/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 +4 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N3-execute-task.md +1 -1
- 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 +82 -16
- 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 +14 -9
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +8 -1
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-change-recovery.md +14 -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,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Standing "run to the end" authorization (runtime/js/autonomy.mjs).
|
|
3
|
+
// show (default) read-only
|
|
4
|
+
// on --response TEXT record the person's own words; nothing else grants it
|
|
5
|
+
// off keep the record as autonomy.off.json
|
|
6
|
+
// notify --kind fatal|finished --project PATH --reason TEXT [--session NAME]
|
|
7
|
+
// page at once (never rate limited): a fatal stop, or everything finished
|
|
8
|
+
// check-proposal --specs-dir PATH --proposal FILE
|
|
9
|
+
// before any decision: may the standing authorization approve it? (exit 1: no)
|
|
10
|
+
// reopen --project PATH --task N.feature/T-xxx
|
|
11
|
+
// take one automatic reopen of the task (exit 1 at the limit: a fatal stop)
|
|
12
|
+
import fs from 'node:fs';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import {readAutonomy,writeAutonomy,clearAutonomy,autonomyHome,takeReopen,readReopens,standingProposalProblem,AUTO_REOPEN_LIMIT} from '../runtime/js/autonomy.mjs';
|
|
15
|
+
import {notify} from '../runtime/js/notify.mjs';
|
|
16
|
+
import {createHash} from 'node:crypto';
|
|
17
|
+
|
|
18
|
+
const usage='usage: cm-autonomy.mjs [show] | on --response TEXT | off | notify --kind fatal|finished --project PATH --reason TEXT [--session NAME]'
|
|
19
|
+
+' | check-proposal --specs-dir PATH --proposal FILE | reopen --project PATH --task N.feature/T-xxx';
|
|
20
|
+
|
|
21
|
+
function parse(argv){
|
|
22
|
+
const [command='show',...rest]=argv,options={};
|
|
23
|
+
for(let index=0;index<rest.length;index++){
|
|
24
|
+
const key={'--response':'response','--kind':'kind','--project':'project','--reason':'reason','--session':'session',
|
|
25
|
+
'--specs-dir':'specsDir','--proposal':'proposal','--task':'task'}[rest[index]];
|
|
26
|
+
if(!key||index+1>=rest.length||Object.hasOwn(options,key))throw new Error('invalid arguments');
|
|
27
|
+
options[key]=rest[++index];
|
|
28
|
+
}
|
|
29
|
+
const allowed={show:[],off:[],on:['response'],notify:['kind','project','reason','session'],
|
|
30
|
+
'check-proposal':['specsDir','proposal'],reopen:['project','task']}[command];
|
|
31
|
+
if(!allowed||Object.keys(options).some(key=>!allowed.includes(key)))throw new Error('invalid arguments');
|
|
32
|
+
if(command==='on'&&!options.response?.trim())throw new Error('on needs --response with the person\'s own words');
|
|
33
|
+
if(command==='notify'&&(!['fatal','finished'].includes(options.kind)||!options.project||!options.reason?.trim()))
|
|
34
|
+
throw new Error('notify needs --kind fatal|finished, --project and --reason');
|
|
35
|
+
if(command==='check-proposal'&&(!options.specsDir||!options.proposal))throw new Error('check-proposal needs --specs-dir and --proposal');
|
|
36
|
+
if(command==='reopen'&&(!options.project||!options.task))throw new Error('reopen needs --project and --task');
|
|
37
|
+
return {command,...options};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const readReopensSafe=env=>{try{return readReopens(env);}catch{return {};}};
|
|
41
|
+
|
|
42
|
+
export function main(argv=process.argv.slice(2),{env=process.env,stdout=process.stdout,stderr=process.stderr}={}){
|
|
43
|
+
let input;
|
|
44
|
+
try{input=parse(argv);}catch(error){stderr.write(`${usage}\nERROR: ${error.message}\n`);return 2;}
|
|
45
|
+
if(input.command==='on'){
|
|
46
|
+
const value=writeAutonomy(input.response,{env});
|
|
47
|
+
stdout.write(`常设授权已开启:一路执行到底,只在致命问题时停下并立即提醒。\n用户原话:${value.response}\n时间:${value.at}\n`);
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
if(input.command==='off'){
|
|
51
|
+
stdout.write(clearAutonomy({env})?'常设授权已关闭(记录改名为 autonomy.off.json 保留)。\n':'常设授权本来就没开。\n');
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
if(input.command==='notify'){
|
|
55
|
+
const fatal=input.kind==='fatal',project=path.resolve(input.project),reason=input.reason.trim();
|
|
56
|
+
const key=`autonomy|${input.kind}|${project}|${createHash('sha256').update(reason).digest('hex').slice(0,16)}`;
|
|
57
|
+
const result=notify({key,event:fatal?'stuck':'done',workflow:'cm-ai',project,session:input.session,
|
|
58
|
+
code:fatal?'autonomy_fatal_stop':'autonomy_finished',nextAction:reason,
|
|
59
|
+
action:fatal?`致命问题,已停下:${reason}`:`已全部完成:${reason}`},{env,urgent:true});
|
|
60
|
+
// Handed to the channel is not delivered: the channel's own failures go to notify.log.
|
|
61
|
+
if(result.sent){stdout.write('已交给提醒渠道发送(是否送达看手机;发送失败记在 notify.log)。\n');return 0;}
|
|
62
|
+
if(result.reason==='duplicate'){stdout.write('6 小时内已发过同一条提醒,这次不重复发。\n');return 0;}
|
|
63
|
+
stdout.write(`没有发出提醒(${result.reason}):请直接在会话里告诉用户。\n`);return 1;
|
|
64
|
+
}
|
|
65
|
+
if(input.command==='check-proposal'){
|
|
66
|
+
let problem;
|
|
67
|
+
try{
|
|
68
|
+
const raw=JSON.parse(fs.readFileSync(input.proposal,'utf8')),proposal=raw?.result?.proposal??raw?.proposal??raw;
|
|
69
|
+
const specs=path.resolve(input.specsDir),directories=fs.readdirSync(specs).filter(dir=>/^\d+\./.test(dir)).sort(),files={};
|
|
70
|
+
for(const dir of directories)for(const name of ['requirements.md','design.md','tasks.md','test-cases.json']){
|
|
71
|
+
const file=path.join(specs,dir,name);if(fs.existsSync(file))files[`${dir}/${name}`]=fs.readFileSync(file,'utf8');
|
|
72
|
+
}
|
|
73
|
+
problem=standingProposalProblem({directories,files},proposal);
|
|
74
|
+
}catch{problem='读不到提案或规格目录';}
|
|
75
|
+
stdout.write(problem?`不能自行批准:${problem}。这是致命停车:不要发送 decision,先提醒用户。\n`:'可以按常设授权自行批准。\n');
|
|
76
|
+
return problem?1:0;
|
|
77
|
+
}
|
|
78
|
+
if(input.command==='reopen'){
|
|
79
|
+
if(!readAutonomy(env).on){stdout.write('常设授权没开:重开要用户本人同意。\n');return 1;}
|
|
80
|
+
let taken;
|
|
81
|
+
try{taken=takeReopen(input.project,input.task,{env});}catch(error){stderr.write(`ERROR: ${error.message}\n`);return 2;}
|
|
82
|
+
stdout.write(taken.refused?`${input.task} 已自动重开 ${taken.count} 次(上限 ${AUTO_REOPEN_LIMIT}):这是致命停车,先提醒用户。\n`
|
|
83
|
+
:`可以自动重开:这是 ${input.task} 第 ${taken.count} 次自动重开(上限 ${AUTO_REOPEN_LIMIT})。--supersede-reason 以「常设授权自动重开第 ${taken.count} 次:」开头。\n`);
|
|
84
|
+
return taken.refused?1:0;
|
|
85
|
+
}
|
|
86
|
+
const state=readAutonomy(env);
|
|
87
|
+
stdout.write(state.on
|
|
88
|
+
?`常设授权:开启(${autonomyHome(env)}/autonomy.json)\n用户原话:${state.value.response}\n时间:${state.value.at}\n同一任务自动重开上限:${AUTO_REOPEN_LIMIT} 次\n`
|
|
89
|
+
+Object.entries(readReopensSafe(env)).map(([key,count])=>`已自动重开:${key.split('|').pop()} ${count} 次(${key.split('|')[0]})\n`).join('')
|
|
90
|
+
:`常设授权:关闭(${state.reason==='missing'?'未开启':'文件无效,按关闭处理'})\n`);
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if(import.meta.main)process.exitCode=main();
|
|
@@ -0,0 +1,162 @@
|
|
|
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 {main} from './cm-autonomy.mjs';
|
|
7
|
+
import {spawn} from 'node:child_process';
|
|
8
|
+
import {fileURLToPath} from 'node:url';
|
|
9
|
+
import {readAutonomy,standingProposalProblem,takeReopen,readReopens} from '../runtime/js/autonomy.mjs';
|
|
10
|
+
import {driveNotice,notifyLater,sendPendingNotice} from '../runtime/js/notify.mjs';
|
|
11
|
+
|
|
12
|
+
function home(t){
|
|
13
|
+
const dir=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-autonomy-')));
|
|
14
|
+
t.after(()=>fs.rmSync(dir,{recursive:true,force:true}));
|
|
15
|
+
const env={...process.env,CM_WORKFLOW_HOME:dir};delete env.CM_NOTIFY_OFF;delete env.CLAUDE_CODE_SESSION_ID;
|
|
16
|
+
const out=[],err=[];
|
|
17
|
+
const run=(...argv)=>({code:main(argv,{env,stdout:{write:s=>out.push(s)},stderr:{write:s=>err.push(s)}}),out:out.splice(0).join(''),err:err.splice(0).join('')});
|
|
18
|
+
return {dir,env,run};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
test('autonomy is on only from recorded words, and off keeps the record',t=>{
|
|
22
|
+
const h=home(t);
|
|
23
|
+
assert.match(h.run().out,/关闭(未开启)/);
|
|
24
|
+
assert.equal(h.run('on').code,2);
|
|
25
|
+
assert.equal(h.run('on','--response',' ').code,2);
|
|
26
|
+
assert.equal(h.run('on','--response','就按这份','--kind','fatal').code,2);
|
|
27
|
+
assert.equal(h.run('on','--response','就按这份').code,0);
|
|
28
|
+
assert.deepEqual({on:readAutonomy(h.env).on,response:readAutonomy(h.env).value.response},{on:true,response:'就按这份'});
|
|
29
|
+
assert.equal(fs.statSync(path.join(h.dir,'autonomy.json')).mode&0o777,0o600);
|
|
30
|
+
assert.match(h.run('show').out,/开启[\s\S]*就按这份[\s\S]*上限:2 次/);
|
|
31
|
+
assert.equal(h.run('off').code,0);
|
|
32
|
+
assert.equal(readAutonomy(h.env).on,false);
|
|
33
|
+
assert.ok(fs.existsSync(path.join(h.dir,'autonomy.off.json')));
|
|
34
|
+
// A file that is not exactly the recorded shape is off, never on.
|
|
35
|
+
for(const value of [{version:1,mode:'until_fatal',response:'',at:'2026-11-01T00:00:00.000Z'},{version:2,mode:'until_fatal',response:'x',at:'2026-11-01T00:00:00.000Z'},'not json']){
|
|
36
|
+
fs.writeFileSync(path.join(h.dir,'autonomy.json'),typeof value==='string'?value:JSON.stringify(value));
|
|
37
|
+
assert.deepEqual(readAutonomy(h.env),{on:false,reason:'invalid'});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('a fatal stop pages at once with the reason as the action',async t=>{
|
|
42
|
+
const h=home(t),sent=path.join(h.dir,'sent.jsonl'),script=path.join(h.dir,'fake.mjs');
|
|
43
|
+
fs.writeFileSync(script,`import fs from 'node:fs';let i='';process.stdin.on('data',c=>i+=c);process.stdin.on('end',()=>{fs.appendFileSync(${JSON.stringify(sent)},i);});`);
|
|
44
|
+
fs.writeFileSync(path.join(h.dir,'notify.json'),JSON.stringify({version:1,command:[process.execPath,script]}));
|
|
45
|
+
assert.equal(h.run('notify','--kind','fatal','--project','/w/app').code,2);
|
|
46
|
+
const result=h.run('notify','--kind','fatal','--project','/w/app','--reason','T-004 自动重开 2 次仍未通过');
|
|
47
|
+
assert.equal(result.code,0);assert.match(result.out,/已交给提醒渠道发送/);
|
|
48
|
+
for(let i=0;i<100&&!fs.existsSync(sent);i++)await new Promise(resolve=>setTimeout(resolve,50));
|
|
49
|
+
const payload=JSON.parse(fs.readFileSync(sent,'utf8'));
|
|
50
|
+
assert.equal(payload.event,'stuck');assert.equal(payload.code,'autonomy_fatal_stop');
|
|
51
|
+
assert.match(payload.action,/致命问题,已停下:T-004 自动重开 2 次仍未通过/);
|
|
52
|
+
// The window limit never swallows a fatal stop.
|
|
53
|
+
const state=path.join(h.dir,'notify-state.json'),now=Date.now();
|
|
54
|
+
fs.writeFileSync(state,JSON.stringify({version:2,keys:{},attention:{},sends:[now-3000,now-2000,now-1000],suppressed:0}));
|
|
55
|
+
assert.equal(h.run('notify','--kind','fatal','--project','/w/app','--reason','额度用完').code,0);
|
|
56
|
+
assert.equal(h.run('notify','--kind','fatal','--project','/w/app','--reason','额度用完').code,0,'same reason within 6 h is not resent');
|
|
57
|
+
fs.rmSync(path.join(h.dir,'notify.json'));
|
|
58
|
+
const off=h.run('notify','--kind','fatal','--project','/w/app','--reason','设备要本人解锁');
|
|
59
|
+
assert.equal(off.code,1);assert.match(off.out,/没有发出提醒/);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('under autonomy a driver stop waits and a finished unit is not paged',t=>{
|
|
63
|
+
const h=home(t);
|
|
64
|
+
const notice=row=>driveNotice({host:'/x/scripts/cm-ai-host.mjs',cwd:'/w/app',args:['serve'],operation:'advance',row,env:h.env});
|
|
65
|
+
const result=over=>({requestId:'drive',result:{version:1,workflow:'cm-ai',operation:'advance',
|
|
66
|
+
identity:{runId:'r1',taskId:'T-001',attempt:1},packageDigest:'d',...over}});
|
|
67
|
+
const limit=result({outcome:'advanced',state:'blocked',code:'review_limit',pendingAction:'none'});
|
|
68
|
+
const done=result({outcome:'finalized',state:'run_done',code:'run_done',pendingAction:'none'});
|
|
69
|
+
assert.equal(notice(limit).delivery,'now');assert.equal(notice(done)?.event,'done');
|
|
70
|
+
h.run('on','--response','就按这份');
|
|
71
|
+
assert.equal(notice(limit).delivery,'later');assert.equal(notice(done),null);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('standing approval covers design, tasks and generated cases, never requirements, features or user cases',()=>{
|
|
75
|
+
const cases=list=>JSON.stringify({schemaVersion:1,feature:'login',cases:list});
|
|
76
|
+
const user={id:'TC-001',origin:'user',title:'login works'},generated={id:'TC-002',origin:'generated',title:'g'};
|
|
77
|
+
const before={directories:['1.login'],files:{'1.login/requirements.md':'R','1.login/design.md':'D','1.login/tasks.md':'T',
|
|
78
|
+
'1.login/test-cases.json':cases([user,generated])}};
|
|
79
|
+
const proposal=(files={},over={})=>({changedUserCases:[],removed:[],...over,files:{...before.files,'1.login/tasks.md':'T2',...files}});
|
|
80
|
+
assert.equal(standingProposalProblem(before,proposal()),null);
|
|
81
|
+
assert.equal(standingProposalProblem(before,proposal({'1.login/design.md':'D2','1.login/test-cases.json':cases([user])})),null);
|
|
82
|
+
const refused=[
|
|
83
|
+
[proposal({'1.login/requirements.md':'R2'}),'提案改了需求'],
|
|
84
|
+
[proposal({},{changedUserCases:[{id:'TC-001'}]}),'提案删除或减弱了用户用例'],
|
|
85
|
+
[proposal({'1.login/test-cases.json':cases([generated])}),'提案删除或减弱了用户用例'],
|
|
86
|
+
[proposal({'1.login/test-cases.json':cases([{...user,title:'weaker'}])}),'提案删除或减弱了用户用例'],
|
|
87
|
+
[(()=>{const value=proposal();delete value.files['1.login/test-cases.json'];return value;})(),'提案删除或减弱了用户用例'],
|
|
88
|
+
[proposal({'1.login/test-cases.json':'not json'}),'提案的测试用例无法解析'],
|
|
89
|
+
[proposal({},{removed:['1.login']}),'提案删除了功能'],
|
|
90
|
+
[proposal({'2.new/requirements.md':'R','2.new/design.md':'D','2.new/tasks.md':'T'}),'提案新增了功能'],
|
|
91
|
+
[proposal({'1.login/assets/x.png':'b'}),'提案改了规格以外的文件(1.login/assets/x.png)'],
|
|
92
|
+
[(()=>{const value=proposal();delete value.files['1.login/design.md'];return value;})(),'提案内容不完整,无法判断'],
|
|
93
|
+
[{changedUserCases:[],removed:[],files:[]},'提案内容不完整,无法判断'],
|
|
94
|
+
[{changedUserCases:[],removed:[],files:{}},'提案内容不完整,无法判断'],
|
|
95
|
+
[{changedUserCases:[],removed:[],files:null},'提案内容不完整,无法判断'],
|
|
96
|
+
[proposal({'1.login/tasks.md':5}),'提案内容不完整,无法判断']];
|
|
97
|
+
for(const [value,reason] of refused)assert.equal(standingProposalProblem(before,value),reason,JSON.stringify(value).slice(0,120));
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('check-proposal judges against the specs on disk and reopen counts to the limit',t=>{
|
|
101
|
+
const h=home(t),specs=path.join(h.dir,'specs'),feature=path.join(specs,'1.login');
|
|
102
|
+
fs.mkdirSync(feature,{recursive:true});
|
|
103
|
+
for(const [name,content] of [['requirements.md','R'],['design.md','D'],['tasks.md','T']])fs.writeFileSync(path.join(feature,name),content);
|
|
104
|
+
const file=path.join(h.dir,'proposal.json'),check=files=>{
|
|
105
|
+
fs.writeFileSync(file,JSON.stringify({result:{proposal:{changedUserCases:[],removed:[],files}}}));
|
|
106
|
+
return h.run('check-proposal','--specs-dir',specs,'--proposal',file);
|
|
107
|
+
};
|
|
108
|
+
const ok=check({'1.login/requirements.md':'R','1.login/design.md':'D','1.login/tasks.md':'T2'});
|
|
109
|
+
assert.equal(ok.code,0);assert.match(ok.out,/可以按常设授权自行批准/);
|
|
110
|
+
const no=check({'1.login/requirements.md':'R2','1.login/design.md':'D','1.login/tasks.md':'T2'});
|
|
111
|
+
assert.equal(no.code,1);assert.match(no.out,/提案改了需求.*不要发送 decision/);
|
|
112
|
+
assert.equal(h.run('check-proposal','--specs-dir',specs,'--proposal',path.join(h.dir,'missing.json')).code,1);
|
|
113
|
+
const reopen=()=>h.run('reopen','--project',h.dir,'--task','1.login/T-004');
|
|
114
|
+
assert.equal(reopen().code,1,'off: the person decides');
|
|
115
|
+
h.run('on','--response','就按这份');
|
|
116
|
+
assert.equal(h.run('reopen','--project',h.dir,'--task','T-004').code,2);
|
|
117
|
+
assert.match(reopen().out,/第 1 次/);assert.match(reopen().out,/第 2 次/);
|
|
118
|
+
const third=reopen();assert.equal(third.code,1);assert.match(third.out,/上限 2.*致命停车/);
|
|
119
|
+
assert.match(h.run('reopen','--project',h.dir,'--task','1.login/T-005').out,/第 1 次/);
|
|
120
|
+
assert.match(h.run('show').out,/1\.login\/T-004 2 次/);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('a deferred stop that comes due is not lost to the window limit',async t=>{
|
|
124
|
+
const h=home(t),sent=path.join(h.dir,'sent.jsonl'),script=path.join(h.dir,'fake.mjs');
|
|
125
|
+
fs.writeFileSync(script,`import fs from 'node:fs';let i='';process.stdin.on('data',c=>i+=c);process.stdin.on('end',()=>{fs.appendFileSync(${JSON.stringify(sent)},i);});`);
|
|
126
|
+
fs.writeFileSync(path.join(h.dir,'notify.json'),JSON.stringify({version:1,command:[process.execPath,script]}));
|
|
127
|
+
const fields={key:'cm-ai|r1|T-001|1|blocked|review_limit',attentionKey:'attn|w/app|cm-ai|r1',event:'stuck',workflow:'cm-ai',project:'/w/app',code:'review_limit'};
|
|
128
|
+
assert.equal((await notifyLater(fields,{env:h.env,delayMs:5*60000})).scheduled,true);
|
|
129
|
+
const pending=path.join(h.dir,'notify-pending'),[name]=fs.readdirSync(pending);
|
|
130
|
+
const token=JSON.parse(fs.readFileSync(path.join(pending,name),'utf8')).token,now=Date.now();
|
|
131
|
+
// Both the window and the daily limit are already used up.
|
|
132
|
+
fs.writeFileSync(path.join(h.dir,'notify-state.json'),JSON.stringify({version:2,keys:{},attention:{},
|
|
133
|
+
sends:Array.from({length:150},(_,i)=>now-1000-i*1000),suppressed:0}));
|
|
134
|
+
assert.deepEqual(await sendPendingNotice(fields,token,{env:h.env}),{sent:true,reason:'launched'});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('concurrent reopen takers never pass the limit',async t=>{
|
|
138
|
+
const h=home(t),cli=fileURLToPath(new URL('./cm-autonomy.mjs',import.meta.url));
|
|
139
|
+
h.run('on','--response','就按这份');
|
|
140
|
+
const take=()=>new Promise(resolve=>{
|
|
141
|
+
const child=spawn(process.execPath,[cli,'reopen','--project',h.dir,'--task','1.login/T-004'],{env:h.env,stdio:'ignore'});
|
|
142
|
+
child.on('exit',code=>resolve(code));
|
|
143
|
+
});
|
|
144
|
+
const codes=await Promise.all(Array.from({length:8},take));
|
|
145
|
+
assert.deepEqual(codes.sort(),[0,0,1,1,1,1,1,1]);
|
|
146
|
+
assert.equal(readReopens(h.env)[`${h.dir}|1.login/T-004`],2);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('a reopen slot left half-written by a crash still counts',t=>{
|
|
150
|
+
const h=home(t);
|
|
151
|
+
assert.deepEqual(takeReopen(h.dir,'1.login/T-004',{env:h.env}),{count:1});
|
|
152
|
+
const dir=path.join(h.dir,'autonomy-reopens'),[first]=fs.readdirSync(dir);
|
|
153
|
+
// The second slot exists but its content never got written.
|
|
154
|
+
fs.writeFileSync(path.join(dir,first.replace(/-1$/,'-2')),'');
|
|
155
|
+
assert.deepEqual(takeReopen(h.dir,'1.login/T-004',{env:h.env}),{refused:true,count:2});
|
|
156
|
+
assert.equal(readReopens(h.env)[`${h.dir}|1.login/T-004`],2,'show counts the half-written slot too');
|
|
157
|
+
fs.writeFileSync(path.join(dir,first),'');
|
|
158
|
+
assert.deepEqual(Object.values(readReopens(h.env)),[2],'a group with no readable slot is still shown');
|
|
159
|
+
// A count kept in any other file stops the take instead of starting over.
|
|
160
|
+
fs.writeFileSync(path.join(h.dir,'autonomy-reopens.json'),'{}');
|
|
161
|
+
assert.throws(()=>takeReopen(h.dir,'1.login/T-009',{env:h.env}),/autonomy_reopens_legacy/);
|
|
162
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Source/distribution checks only; model behavior is exercised separately.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {fileURLToPath} from 'node:url';
|
|
7
|
+
import test from 'node:test';
|
|
8
|
+
|
|
9
|
+
const root = fileURLToPath(new URL('..', import.meta.url));
|
|
10
|
+
const read = file => fs.readFileSync(path.join(root, file), 'utf8');
|
|
11
|
+
const entry = 'skills/cm-challenge/SKILL.md';
|
|
12
|
+
|
|
13
|
+
test('cm-challenge is discoverable through Pi, Codex and the thin Claude alias', () => {
|
|
14
|
+
const pkg = JSON.parse(read('package.json'));
|
|
15
|
+
assert.equal(pkg.pi.skills.filter(p => p === './skills/cm-challenge').length, 1);
|
|
16
|
+
assert.ok(pkg.files.includes('skills') && pkg.files.includes('runtime') && pkg.files.includes('compat'));
|
|
17
|
+
const plugin = JSON.parse(read('.codex-plugin/plugin.json'));
|
|
18
|
+
assert.equal(plugin.skills, './skills/');
|
|
19
|
+
const skill = read(entry);
|
|
20
|
+
assert.match(skill, /^---\nname: cm-challenge\ndescription: [^\n]+\n---\n/);
|
|
21
|
+
const alias = read('compat/claude-commands/cm-challenge.md');
|
|
22
|
+
assert.ok(alias.trim().split('\n').length <= 8);
|
|
23
|
+
assert.ok(alias.includes('skills/cm-challenge/SKILL.md'));
|
|
24
|
+
assert.ok(alias.includes('$ARGUMENTS'));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('cm-challenge references resolve from a relocated package without personal Skills', t => {
|
|
28
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'cm-challenge-source-'));
|
|
29
|
+
t.after(() => fs.rmSync(temp, {recursive: true, force: true}));
|
|
30
|
+
for (const file of [entry, 'skills/cm-challenge/references/examples.md', 'runtime/steelman-review.md']) {
|
|
31
|
+
const target = path.join(temp, file);
|
|
32
|
+
fs.mkdirSync(path.dirname(target), {recursive: true});
|
|
33
|
+
fs.copyFileSync(path.join(root, file), target);
|
|
34
|
+
}
|
|
35
|
+
const skill = fs.readFileSync(path.join(temp, entry), 'utf8');
|
|
36
|
+
const refs = [...skill.matchAll(/`(\.\.\/[^`]+\.md)`|\]\((references\/[^)]+\.md)\)/g)]
|
|
37
|
+
.map(match => match[1] ?? match[2]);
|
|
38
|
+
assert.ok(refs.includes('../../runtime/steelman-review.md'), 'must reuse the shared reasoning contract');
|
|
39
|
+
assert.ok(refs.includes('references/examples.md'));
|
|
40
|
+
for (const ref of refs) {
|
|
41
|
+
const resolved = path.resolve(temp, path.dirname(entry), ref);
|
|
42
|
+
assert.ok(resolved.startsWith(`${temp}${path.sep}`));
|
|
43
|
+
assert.ok(fs.statSync(resolved).isFile(), ref);
|
|
44
|
+
}
|
|
45
|
+
assert.equal(fs.existsSync(path.join(temp, 'runtime/js')), false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('registered entry sets and documented count stay aligned', () => {
|
|
49
|
+
const pkg = JSON.parse(read('package.json'));
|
|
50
|
+
const entries = pkg.pi.skills.map(p => p.split('/').at(-1));
|
|
51
|
+
const validator = read('scripts/validate-public-repo.py').match(/CORE_SKILLS = \(([\s\S]*?)\n\)/)[1];
|
|
52
|
+
const registered = [...validator.matchAll(/"(cm-[a-z-]+)"/g)].map(m => m[1]);
|
|
53
|
+
assert.deepEqual([...registered].sort(), [...entries].sort());
|
|
54
|
+
const checker = read('scripts/cm-check-runtime.sh').match(/for name in (cm-[^;]+); do/)[1].split(' ');
|
|
55
|
+
assert.deepEqual([...checker].sort(), [...entries].sort());
|
|
56
|
+
assert.ok(read('README.md').includes(`入口目录与计数:${entries.length} 个核心入口`));
|
|
57
|
+
for (const name of entries) {
|
|
58
|
+
assert.ok(fs.existsSync(path.join(root, `skills/${name}/SKILL.md`)));
|
|
59
|
+
assert.ok(fs.existsSync(path.join(root, `compat/claude-commands/${name}.md`)));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// guard (cm-ai-light-modules.test.mjs) imports operator-guidance.mjs from exactly this copy.
|
|
3
3
|
export const CHECK_DRIVE_COPIED_FILES=Object.freeze([
|
|
4
4
|
'scripts/cm-check-entry.mjs','scripts/cm-check-host.mjs','scripts/cm-check-drive.mjs',
|
|
5
|
-
'scripts/cm-workflow-config.mjs','runtime/js/cm-check/host.mjs','runtime/js/cm-ai/drive-core.mjs',
|
|
5
|
+
'scripts/cm-workflow-config.mjs','runtime/js/cm-check/host.mjs','runtime/js/cm-ai/drive-core.mjs','runtime/js/cm-ai/drive-rate-limit.mjs',
|
|
6
6
|
'runtime/js/cm-ai/operator-guidance.mjs','runtime/js/cm-ai/host-stage-observer.mjs',
|
|
7
7
|
'runtime/js/cm-ai/host-tool-bridge.mjs','runtime/js/cm-ai/host-session.mjs','runtime/js/cm-ai/diagnostic-reason.mjs','runtime/js/cm-ai/effect-contract.mjs',
|
|
8
8
|
'runtime/js/cm-ai/contracts.mjs','runtime/js/cm-init/draft-inspection.mjs','skills/cm-check/SKILL.md']);
|
|
@@ -287,11 +287,43 @@ for module in \
|
|
|
287
287
|
task-owner.mjs task-runner.mjs worker-codex.mjs operator-guidance.mjs; do
|
|
288
288
|
require_file "runtime/js/cm-ai/$module"
|
|
289
289
|
done
|
|
290
|
+
# completion_rework is a paired producer/consumer contract, including transport.
|
|
291
|
+
CONTROL_POLICY_DOC="docs/cm-control-policy-v2.md"
|
|
292
|
+
if [ "$MODE" != "plugin" ]; then
|
|
293
|
+
CONTROL_POLICY_DOC="cm-workflow/docs/cm-control-policy-v2.md"
|
|
294
|
+
fi
|
|
295
|
+
for consumer in runtime/js/cm-ai/control-policy.mjs runtime/js/cm-ai/host-session.mjs \
|
|
296
|
+
runtime/js/cm-ai/cm-ai-conversation-entry.mjs scripts/cm-ai-drive.mjs "$CONTROL_POLICY_DOC"; do
|
|
297
|
+
grep -q 'completion_rework' "$ROOT/$consumer" || fail "missing completion_rework consumer: $consumer"
|
|
298
|
+
done
|
|
299
|
+
for consumer in runtime/js/cm-ai/task-runner.mjs runtime/js/cm-ai/durable-runner-state.mjs scripts/cm-ai-control-v2-drive.test.mjs; do
|
|
300
|
+
grep -q 'completion-rework-requested' "$ROOT/$consumer" || fail "missing completion rework journal pairing: $consumer"
|
|
301
|
+
done
|
|
302
|
+
grep -q 'cm-completion-rework-v1:' "$ROOT/scripts/cm-task-gate.mjs" || fail "missing native completion rework verifier"
|
|
303
|
+
require_file "scripts/cm-ai-development-rework.test.mjs"
|
|
304
|
+
for consumer in runtime/js/cm-ai/control-policy.mjs runtime/js/cm-ai/host-session.mjs \
|
|
305
|
+
runtime/js/cm-ai/cm-ai-conversation-entry.mjs scripts/cm-ai-drive.mjs "$CONTROL_POLICY_DOC"; do
|
|
306
|
+
grep -q 'development_rework' "$ROOT/$consumer" || fail "missing development rework consumer: $consumer"
|
|
307
|
+
done
|
|
308
|
+
for consumer in runtime/js/cm-ai/task-runner.mjs runtime/js/cm-ai/durable-runner-state.mjs scripts/cm-ai-development-rework.test.mjs; do
|
|
309
|
+
grep -q 'development-rework-authorized' "$ROOT/$consumer" || fail "missing development rework journal pairing: $consumer"
|
|
310
|
+
done
|
|
311
|
+
require_file "runtime/js/cm-ai/scope-revision.mjs"
|
|
312
|
+
require_file "scripts/cm-ai-scope-revision.test.mjs"
|
|
313
|
+
for consumer in runtime/js/cm-ai/control-policy.mjs runtime/js/cm-ai/host-session.mjs \
|
|
314
|
+
runtime/js/cm-ai/cm-ai-conversation-entry.mjs scripts/cm-ai-drive.mjs "$CONTROL_POLICY_DOC"; do
|
|
315
|
+
grep -q 'revise_scope' "$ROOT/$consumer" || fail "missing scope revision consumer: $consumer"
|
|
316
|
+
done
|
|
317
|
+
for consumer in runtime/js/cm-ai/task-runner.mjs runtime/js/cm-ai/durable-runner-state.mjs scripts/cm-ai-scope-revision.test.mjs; do
|
|
318
|
+
grep -q 'scope-revised' "$ROOT/$consumer" || fail "missing scope revision journal pairing: $consumer"
|
|
319
|
+
done
|
|
290
320
|
require_file "scripts/cm-check-runtime.ps1"
|
|
291
321
|
require_file "scripts/cm-security.mjs"
|
|
292
322
|
require_file "scripts/cm-security.test.mjs"
|
|
293
323
|
require_file "runtime/js/cm-security/scan.mjs"
|
|
294
324
|
require_file "scripts/cm-notify.mjs"
|
|
325
|
+
require_file "scripts/cm-autonomy.mjs"
|
|
326
|
+
require_file "runtime/js/autonomy.mjs"
|
|
295
327
|
require_file "runtime/js/notify-send.mjs"
|
|
296
328
|
require_file "scripts/cm-check-update.mjs"
|
|
297
329
|
require_file "scripts/cm-check-update.test.mjs"
|
|
@@ -430,6 +462,17 @@ if [ -n "$NODE_BIN" ]; then
|
|
|
430
462
|
fi
|
|
431
463
|
fi
|
|
432
464
|
fi
|
|
465
|
+
# Optional Matt Pocock companion skills: a /cm-check report only, never a failure.
|
|
466
|
+
# Installers run this check without --print-effective and print their own hint.
|
|
467
|
+
if [ "$PRINT_EFFECTIVE" -eq 1 ] && [ -f "$ROOT/scripts/cm-matt-skills.mjs" ]; then
|
|
468
|
+
"$NODE_BIN" "$ROOT/scripts/cm-matt-skills.mjs" status ||
|
|
469
|
+
warn "recommended skills status unavailable"
|
|
470
|
+
fi
|
|
471
|
+
# Optional skill-hints hook: wiring, switch and table counts; a report only, never a failure.
|
|
472
|
+
if [ "$PRINT_EFFECTIVE" -eq 1 ] && [ -f "$ROOT/scripts/cm-skill-hints.mjs" ]; then
|
|
473
|
+
"$NODE_BIN" "$ROOT/scripts/cm-skill-hints.mjs" status ||
|
|
474
|
+
warn "skill hints status unavailable"
|
|
475
|
+
fi
|
|
433
476
|
else
|
|
434
477
|
fail "Node.js 18+ is required for CM workflow config validation"
|
|
435
478
|
fi
|
|
@@ -652,7 +695,7 @@ for consumer in \
|
|
|
652
695
|
fail "external-expert AUTO routing is not wired into $consumer"
|
|
653
696
|
done
|
|
654
697
|
|
|
655
|
-
for name in cm-idea cm-init cm-prd cm-ai cm-test cm-security cm-fix cm-refactor cm-check cm-runtime cm-notify; do
|
|
698
|
+
for name in cm-challenge cm-idea cm-init cm-prd cm-ai cm-test cm-security cm-fix cm-refactor cm-check cm-runtime cm-notify; do
|
|
656
699
|
require_file "skills/$name/SKILL.md"
|
|
657
700
|
require_file "compat/claude-commands/$name.md"
|
|
658
701
|
wrapper="$ROOT/compat/claude-commands/$name.md"
|
|
@@ -903,6 +946,22 @@ elif grep -Fq 'ls {SPECS_DIR}/.reviews/fix-{slug}-r*.md' "$ROOT/skills/cm-fix/SK
|
|
|
903
946
|
else
|
|
904
947
|
fail "cm-fix is missing the mechanical post-fix review evidence gate"
|
|
905
948
|
fi
|
|
949
|
+
# Fixed recovery producers, transport consumers and documentation stay paired.
|
|
950
|
+
for correction in command-correction test-type-correction; do
|
|
951
|
+
operation="prepare_${correction//-/_}"
|
|
952
|
+
permission="--allow-${correction}"
|
|
953
|
+
require_file "runtime/js/cm-fix/${correction}.mjs"
|
|
954
|
+
require_file "scripts/cm-fix-${correction}.mjs"
|
|
955
|
+
require_file "skills/cm-fix/references/${correction}.md"
|
|
956
|
+
for surface in runtime/js/cm-ai/host-session.mjs runtime/js/cm-fix/host.mjs scripts/cm-fix-drive.mjs; do
|
|
957
|
+
grep -Fq "'${operation}'" "$ROOT/$surface" || fail "${surface} does not route ${operation}"
|
|
958
|
+
done
|
|
959
|
+
for surface in scripts/cm-fix-host.mjs scripts/cm-fix-drive.mjs; do
|
|
960
|
+
grep -Fq -e "$permission" "$ROOT/$surface" || fail "${surface} does not bind ${permission}"
|
|
961
|
+
done
|
|
962
|
+
grep -Fq "${correction}.md" "$ROOT/skills/cm-fix/references/js-host.md" ||
|
|
963
|
+
fail "cm-fix host manual does not link ${correction}"
|
|
964
|
+
done
|
|
906
965
|
require_file "skills/cm-fix/references/cross-boundary-debugging.md"
|
|
907
966
|
grep -q "references/cross-boundary-debugging.md" "$ROOT/skills/cm-fix/SKILL.md" ||
|
|
908
967
|
fail "cm-fix does not load its cross-boundary debugging reference"
|
|
@@ -23,7 +23,7 @@ function fixture(t){
|
|
|
23
23
|
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
24
24
|
return root;
|
|
25
25
|
}
|
|
26
|
-
function fakeWorker(cwd,{value=proposal,mode='normal',timeoutMs=3000,noticeEvents=[],noticeAt=1,onNotice,
|
|
26
|
+
function fakeWorker(cwd,{value=proposal,mode='normal',timeoutMs=3000,noticeEvents=[],noticeAt=1,heartbeats=0,onNotice,
|
|
27
27
|
resultFields={},toolName='Read',toolResultId='read-1',
|
|
28
28
|
assistantContent=[{type:'text',text:'proposal'}]}={}){
|
|
29
29
|
// The timeout mode hangs; the guard ends it if this test process dies first.
|
|
@@ -40,7 +40,9 @@ function fakeWorker(cwd,{value=proposal,mode='normal',timeoutMs=3000,noticeEvent
|
|
|
40
40
|
${JSON.stringify(mode)}==='write'?[{type:'tool_use',id:'bad',name:'Write',input:{}}]:${JSON.stringify(assistantContent)}}},
|
|
41
41
|
{type:'result',session_id,subtype:${JSON.stringify(mode)}==='failed'?'error_during_execution':'success',
|
|
42
42
|
is_error:${JSON.stringify(mode)}==='failed',num_turns:1,result:JSON.stringify(value),...${JSON.stringify(resultFields)}});
|
|
43
|
-
|
|
43
|
+
// Heartbeats are generated here: thousands of them inlined would exceed the per-argument limit.
|
|
44
|
+
const heartbeats=Array.from({length:${JSON.stringify(heartbeats)}},()=>({type:'system',subtype:'thinking_tokens',session_id,estimated_tokens:10}));
|
|
45
|
+
events.splice(${JSON.stringify(noticeAt)},0,...heartbeats,...${JSON.stringify(noticeEvents)});
|
|
44
46
|
for(const event of events)process.stdout.write(JSON.stringify(event)+'\\n');
|
|
45
47
|
});`;
|
|
46
48
|
return claudeDeveloperWorker({cwd,model:'fixture',timeoutMs,onNotice,spawnProcess:(cli,args,options)=>{
|
|
@@ -76,6 +78,23 @@ test('developer accepts dev_intent on either side of init with a sanitized notic
|
|
|
76
78
|
assert.deepEqual(result,baseline);
|
|
77
79
|
}
|
|
78
80
|
});
|
|
81
|
+
// Regression: CLI 2.1.289 emits ui_invalidate before init. The review stream
|
|
82
|
+
// already accepts it (docs/fixes/20261013-claude-preinit-ui-invalidate.md); the
|
|
83
|
+
// developer stream rejected it as missing_init and killed its own process group.
|
|
84
|
+
test('developer accepts ui_invalidate on either side of init with a sanitized notice',async t=>{
|
|
85
|
+
const root=fixture(t),control={signal:new AbortController().signal};
|
|
86
|
+
const baseline=await fakeWorker(root)({prompt:prompt()},control);
|
|
87
|
+
const uiInvalidate={type:'system',subtype:'ui_invalidate',session_id:'synthetic-claude-developer',payload:{private:'x'}};
|
|
88
|
+
for(const noticeAt of [0,1,2]){
|
|
89
|
+
const notices=[],result=await fakeWorker(root,{noticeAt,noticeEvents:[uiInvalidate],onNotice:n=>notices.push(n)})
|
|
90
|
+
({prompt:prompt()},control);
|
|
91
|
+
assert.deepEqual(result,baseline);
|
|
92
|
+
assert.deepEqual(notices,[{kind:'claude_system_notice',subtype:'ui_invalidate'}]);
|
|
93
|
+
}
|
|
94
|
+
// It never initializes a turn: alone it still fails as missing init, and it binds the session.
|
|
95
|
+
assert.deepEqual(await fakeWorker(root,{noticeAt:0,noticeEvents:[{...uiInvalidate,session_id:'other'}]})({prompt:prompt()},control),
|
|
96
|
+
{status:'unknown',code:'session_mismatch'});
|
|
97
|
+
});
|
|
79
98
|
test('developer dev_intent binds init session and shares a 32-notice budget',async t=>{
|
|
80
99
|
const root=fixture(t),control={signal:new AbortController().signal};
|
|
81
100
|
for(const [noticeEvents,noticeAt,code] of [
|
|
@@ -120,9 +139,10 @@ const thoughts={type:'assistant',session_id:'synthetic-claude-developer',parent_
|
|
|
120
139
|
test('developer thinking events preserve proposal and read tool pairing with developer schema',async t=>{
|
|
121
140
|
const root=fixture(t),control={signal:new AbortController().signal};
|
|
122
141
|
const baseline=await fakeWorker(root)({prompt:prompt()},control);
|
|
123
|
-
|
|
142
|
+
// 回归:长开发会话的思考心跳曾在第 65 条被拒(aihot T-001);上限与审查端同为 4096。
|
|
143
|
+
for(const [mode,noticeAt,count] of [['normal',1,2],['normal',2,64],['normal',2,65],['normal',2,4096],['read',2,2]]){
|
|
124
144
|
const result=await fakeWorker(root,{mode,noticeAt,
|
|
125
|
-
noticeEvents:[rateLimit()
|
|
145
|
+
heartbeats:count,noticeEvents:[rateLimit(),thoughts],
|
|
126
146
|
assistantContent:[...thoughts.message.content,{type:'text',text:'proposal'}]})({prompt:prompt()},control);
|
|
127
147
|
assert.deepEqual(result,baseline);
|
|
128
148
|
}
|
|
@@ -133,15 +153,15 @@ test('developer thinking events preserve proposal and read tool pairing with dev
|
|
|
133
153
|
});
|
|
134
154
|
test('developer thinking preserves initial, terminal, count and unknown-system rejection',async t=>{
|
|
135
155
|
const root=fixture(t),control={signal:new AbortController().signal};
|
|
136
|
-
for(const [noticeEvents,noticeAt,code] of [
|
|
137
|
-
[
|
|
156
|
+
for(const [noticeEvents,noticeAt,code,heartbeats=0] of [
|
|
157
|
+
[[],1,'unexpected_event',4097],
|
|
138
158
|
[[{...thinkingTokens(),subtype:'unknown'}],1,'unexpected_event'],
|
|
139
159
|
[[{...thinkingTokens(),subtype:'init'}],1,'unexpected_event'],
|
|
140
160
|
[[{...thinkingTokens(),session_id:'other'}],1,'session_mismatch'],
|
|
141
161
|
[[thinkingTokens()],0,'missing_init'],
|
|
142
162
|
[[thinkingTokens()],3,'invalid_event'],
|
|
143
163
|
]){
|
|
144
|
-
const result=await fakeWorker(root,{noticeEvents,noticeAt})({prompt:prompt()},control);
|
|
164
|
+
const result=await fakeWorker(root,{noticeEvents,noticeAt,heartbeats})({prompt:prompt()},control);
|
|
145
165
|
assert.deepEqual(result,{status:'unknown',code});
|
|
146
166
|
}
|
|
147
167
|
const result=await fakeWorker(root,{assistantContent:thoughts.message.content})({prompt:prompt()},control);
|
|
@@ -290,3 +310,32 @@ test('developer stream treats a synthetic CLI reminder as a notice, except betwe
|
|
|
290
310
|
assert.equal(pending.code,'unexpected_tool_or_content');
|
|
291
311
|
assert.deepEqual(fs.readdirSync(root),[]);
|
|
292
312
|
});
|
|
313
|
+
|
|
314
|
+
// 2026-10-26: a provider developer hitting the API rate limit is recognised by class.
|
|
315
|
+
// The stream shape is the one Claude CLI 2.1.274 prints for an API failure (see
|
|
316
|
+
// cm-ai-review-failure.test.mjs): a synthetic assistant message carrying the error
|
|
317
|
+
// class, then an is_error result with api_error_status. Only the class is kept.
|
|
318
|
+
function apiErrorWorker(cwd,{error,status,text}){
|
|
319
|
+
const source=`${ownerGuardSource()}let input='';process.stdin.on('data',s=>input+=s);process.stdin.on('end',()=>{
|
|
320
|
+
const session_id='synthetic-claude-developer',out=e=>process.stdout.write(JSON.stringify(e)+'\\n');
|
|
321
|
+
out({type:'system',subtype:'init',session_id});
|
|
322
|
+
out({type:'assistant',session_id,parent_tool_use_id:null,error:${JSON.stringify(error)},is_api_error_message:true,
|
|
323
|
+
message:{role:'assistant',content:[{type:'text',text:${JSON.stringify(text)}}]}});
|
|
324
|
+
out({type:'result',session_id,subtype:'success',is_error:true,num_turns:1,result:${JSON.stringify(text)},
|
|
325
|
+
terminal_reason:'api_error',api_error_status:${JSON.stringify(status)}});
|
|
326
|
+
process.exit(1);
|
|
327
|
+
});`;
|
|
328
|
+
return claudeDeveloperWorker({cwd,model:'fixture',timeoutMs:5000,spawnProcess:(cli,args,options)=>spawn(process.execPath,['-e',source],options)});
|
|
329
|
+
}
|
|
330
|
+
for(const [error,status,text,code] of [
|
|
331
|
+
['rate_limit',429,'API Error: 429 rate limited','developer_rate_limited'],
|
|
332
|
+
['server_error',529,'API Error: 529 Overloaded','developer_server_error'],
|
|
333
|
+
['authentication_failed',401,'Invalid API key','developer_auth_failed'],
|
|
334
|
+
['billing_error',402,'Credit balance too low','developer_billing_error'],
|
|
335
|
+
['model_not_found',404,'model not found','developer_model_not_found'],
|
|
336
|
+
['invalid_request',400,'API Error: 400 bad request','developer_api_error'],
|
|
337
|
+
])test(`Claude developer API error ${error} ends as ${code} (class only, status unchanged)`,async t=>{
|
|
338
|
+
const root=fixture(t),result=await apiErrorWorker(root,{error,status,text})({prompt:prompt()},{signal:new AbortController().signal});
|
|
339
|
+
// Same terminal status as before (unknown): only the code names the class, never the text.
|
|
340
|
+
assert.deepEqual(result,{status:'unknown',code});assert.deepEqual(fs.readdirSync(root),[]);
|
|
341
|
+
});
|
|
@@ -11,7 +11,7 @@ test('real isolated Claude install checks correction docs at its installed layou
|
|
|
11
11
|
const home=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-claude-install-layout-')));
|
|
12
12
|
t.after(()=>fs.rmSync(home,{recursive:true,force:true}));
|
|
13
13
|
const target=path.join(home,'.claude'),env={...process.env,HOME:home,CLAUDE_HOME:target,
|
|
14
|
-
CM_WORKFLOW_HOME:path.join(home,'user'),CM_WORKFLOW_LOG_HOME:path.join(home,'logs')};
|
|
14
|
+
CM_WORKFLOW_HOME:path.join(home,'user'),CM_WORKFLOW_LOG_HOME:path.join(home,'logs'),CM_MATT_SKILLS_INSTALL:'off'};
|
|
15
15
|
const installed=spawnSync('/bin/bash',[path.join(source,'install.sh'),'--yes'],{cwd:source,env,encoding:'utf8',timeout:120000,maxBuffer:4*1024*1024});
|
|
16
16
|
assert.equal(installed.status,0,installed.stdout+installed.stderr);
|
|
17
17
|
assert.match(installed.stdout,/cm runtime check: PASSED \(claude-compat v/);
|