@aibyzero/cm-workflow 0.17.1 → 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 +23 -0
- package/CHANGELOG.md +224 -0
- package/README.md +14 -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/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 +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 +21 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +114 -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 +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 +3 -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 +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-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.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-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 +575 -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 +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-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 +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 +56 -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 +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,168 @@
|
|
|
1
|
+
// Installers and the skill-hints copy: the hook runs ~/.cm-workflow/skill-hints/,
|
|
2
|
+
// which only `enable` used to write, so an upgrade left enabled users on the old
|
|
3
|
+
// table (real case 2026-10-24, after PR #242). A reinstall must refresh that copy
|
|
4
|
+
// for users who turned hints on. Since 2026-10-25 a first install also wires the hook
|
|
5
|
+
// for its own host, unless the user opted out or removed the hook earlier.
|
|
6
|
+
// Every run uses a disposable HOME; the Codex run uses stub creator and CLI.
|
|
7
|
+
import test from 'node:test';
|
|
8
|
+
import assert from 'node:assert/strict';
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import os from 'node:os';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import {spawnSync} from 'node:child_process';
|
|
13
|
+
import {fileURLToPath} from 'node:url';
|
|
14
|
+
|
|
15
|
+
const source = fileURLToPath(new URL('..', import.meta.url));
|
|
16
|
+
const COPIED = ['cm-skill-hints.mjs', 'cm-skill-hints.json', 'cm-matt-skills.mjs', 'cm-config-lock.mjs', 'cm-skill-judge.mjs'];
|
|
17
|
+
const STUB_CREATOR = `import json, pathlib, sys
|
|
18
|
+
args = sys.argv[1:]
|
|
19
|
+
path = pathlib.Path(args[args.index('--marketplace-path') + 1])
|
|
20
|
+
data = json.loads(path.read_text()) if path.exists() else {'name': 'personal', 'plugins': [{'name': 'cm-workflow'}]}
|
|
21
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
22
|
+
path.write_text(json.dumps(data) + '\\n')
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
function sandbox(t) {
|
|
26
|
+
const home = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'cm-skill-hints-install-')));
|
|
27
|
+
t.after(() => fs.rmSync(home, {recursive: true, force: true}));
|
|
28
|
+
const codexHome = path.join(home, '.codex');
|
|
29
|
+
const creator = path.join(codexHome, 'skills/.system/plugin-creator/scripts');
|
|
30
|
+
fs.mkdirSync(creator, {recursive: true});
|
|
31
|
+
fs.writeFileSync(path.join(creator, 'create_basic_plugin.py'), STUB_CREATOR);
|
|
32
|
+
const bin = path.join(home, 'bin');
|
|
33
|
+
fs.mkdirSync(bin);
|
|
34
|
+
fs.writeFileSync(path.join(bin, 'codex'), '#!/bin/sh\nexit 0\n', {mode: 0o755});
|
|
35
|
+
const env = {...process.env, HOME: home, CLAUDE_HOME: path.join(home, '.claude'), CODEX_HOME: codexHome,
|
|
36
|
+
PATH: `${bin}:${process.env.PATH}`,
|
|
37
|
+
CM_WORKFLOW_HOME: path.join(home, 'workflow'), CM_WORKFLOW_LOG_HOME: path.join(home, 'logs')};
|
|
38
|
+
delete env.CM_SKILL_HINTS;
|
|
39
|
+
delete env.CM_SKILL_HINTS_INSTALL;
|
|
40
|
+
env.CM_MATT_SKILLS_INSTALL = 'off'; // the companion-skill download is tested by cm-matt-skills.test.mjs offline
|
|
41
|
+
delete env.TYPESAFE_API_KEY;
|
|
42
|
+
return {home, env, copy: path.join(home, 'workflow/skill-hints'),
|
|
43
|
+
settings: path.join(home, '.claude/settings.json'), hooks: path.join(codexHome, 'hooks.json'),
|
|
44
|
+
trust: path.join(codexHome, 'config.toml'), log: path.join(home, 'logs/skill-hints.jsonl')};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function install(script, env, args = ['--yes']) {
|
|
48
|
+
return spawnSync('/bin/bash', [path.join(source, script), ...args],
|
|
49
|
+
{cwd: source, env, encoding: 'utf8', timeout: 240000, maxBuffer: 8 * 1024 * 1024, input: ''});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const output = result => result.stdout + result.stderr;
|
|
53
|
+
const bytesOf = file => fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : null;
|
|
54
|
+
const wiredConfig = (box, host) => JSON.stringify({hooks: {UserPromptSubmit: [{hooks: [{type: 'command',
|
|
55
|
+
command: `/usr/bin/node ${path.join(box.copy, 'cm-skill-hints.mjs')} hook --host ${host}`, timeout: 5}]}]}}, null, 2) + '\n';
|
|
56
|
+
|
|
57
|
+
// An enabled user mid-trial: an old copy, session state, a log and Codex trust.
|
|
58
|
+
function enabledUser(box, host) {
|
|
59
|
+
fs.mkdirSync(path.join(box.copy, 'state'), {recursive: true});
|
|
60
|
+
for (const name of COPIED) fs.writeFileSync(path.join(box.copy, name), '// old version\n');
|
|
61
|
+
fs.writeFileSync(path.join(box.copy, 'state/0123456789abcdef.json'), '{"hinted":["cm-fix"],"pending":[]}');
|
|
62
|
+
fs.mkdirSync(path.dirname(box.log), {recursive: true});
|
|
63
|
+
fs.writeFileSync(box.log, '{"event":"hint"}\n');
|
|
64
|
+
fs.writeFileSync(box.trust, '[hooks.state]\nx = "trusted"\n');
|
|
65
|
+
const file = host === 'codex' ? box.hooks : box.settings;
|
|
66
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
67
|
+
fs.writeFileSync(file, wiredConfig(box, host));
|
|
68
|
+
return [path.join(box.copy, 'state/0123456789abcdef.json'), box.log, box.trust, file].map(bytesOf);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const KEPT = (box, host) => [path.join(box.copy, 'state/0123456789abcdef.json'), box.log, box.trust,
|
|
72
|
+
host === 'codex' ? box.hooks : box.settings];
|
|
73
|
+
|
|
74
|
+
for (const [script, scripts, host] of [
|
|
75
|
+
['install.sh', box => path.join(box.home, '.claude/scripts'), 'claude'],
|
|
76
|
+
['install-codex.sh', box => path.join(box.home, 'plugins/cm-workflow/scripts'), 'codex'],
|
|
77
|
+
]) {
|
|
78
|
+
test(`${script}: an enabled user's skill-hints copy is refreshed; configs, trust, state and logs are kept`,
|
|
79
|
+
{skip: process.platform === 'win32', timeout: 600000}, t => {
|
|
80
|
+
const box = sandbox(t);
|
|
81
|
+
const before = enabledUser(box, host);
|
|
82
|
+
const result = install(script, box.env);
|
|
83
|
+
assert.equal(result.status, 0, output(result));
|
|
84
|
+
for (const name of COPIED) {
|
|
85
|
+
// A boolean, so a failure names the file instead of dumping both copies.
|
|
86
|
+
assert.ok(fs.readFileSync(path.join(box.copy, name)).equals(fs.readFileSync(path.join(scripts(box), name))),
|
|
87
|
+
`${name} not refreshed`);
|
|
88
|
+
}
|
|
89
|
+
assert.deepEqual(KEPT(box, host).map(bytesOf), before);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test(`${script}: a first install wires the hint hook for its own host only and says how to turn it off`,
|
|
93
|
+
{skip: process.platform === 'win32', timeout: 600000}, t => {
|
|
94
|
+
const box = sandbox(t);
|
|
95
|
+
const result = install(script, box.env);
|
|
96
|
+
assert.equal(result.status, 0, output(result));
|
|
97
|
+
const own = host === 'codex' ? box.hooks : box.settings;
|
|
98
|
+
const other = host === 'codex' ? box.settings : box.hooks;
|
|
99
|
+
assert.match(bytesOf(own) ?? '', new RegExp(`skill-hints/cm-skill-hints\\.mjs hook --host ${host}`));
|
|
100
|
+
assert.doesNotMatch(bytesOf(other) ?? '', /cm-skill-hints/);
|
|
101
|
+
assert.ok(fs.existsSync(path.join(box.copy, 'cm-skill-hints.mjs')));
|
|
102
|
+
assert.match(output(result), /已给 (Claude|Codex) 挂上技能提醒钩子.*--no-skill-hints.*TypeSafe/);
|
|
103
|
+
if (host === 'codex') assert.match(output(result), /确认信任/);
|
|
104
|
+
assert.ok(!fs.existsSync(box.trust) || !/cm-skill-hints/.test(bytesOf(box.trust)), 'CM never trusts the hook for the user');
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
test('install.sh --no-skill-hints wires nothing and makes no copy',
|
|
109
|
+
{skip: process.platform === 'win32', timeout: 600000}, t => {
|
|
110
|
+
const box = sandbox(t);
|
|
111
|
+
const result = install('install.sh', box.env, ['--yes', '--no-skill-hints']);
|
|
112
|
+
assert.equal(result.status, 0, output(result));
|
|
113
|
+
assert.match(output(result), /没给 Claude 挂钩子.*只管这一次/);
|
|
114
|
+
assert.ok(!fs.existsSync(box.copy));
|
|
115
|
+
assert.doesNotMatch(bytesOf(box.settings) ?? '', /cm-skill-hints/);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('install-codex.sh with CM_SKILL_HINTS_INSTALL=off wires nothing; --no-skill-hints is accepted',
|
|
119
|
+
{skip: process.platform === 'win32', timeout: 600000}, t => {
|
|
120
|
+
const box = sandbox(t);
|
|
121
|
+
const result = install('install-codex.sh', {...box.env, CM_SKILL_HINTS_INSTALL: 'off'});
|
|
122
|
+
assert.equal(result.status, 0, output(result));
|
|
123
|
+
assert.match(output(result), /CM_SKILL_HINTS_INSTALL=off/);
|
|
124
|
+
assert.ok(!fs.existsSync(box.copy));
|
|
125
|
+
assert.doesNotMatch(bytesOf(box.hooks) ?? '', /cm-skill-hints/);
|
|
126
|
+
const flagged = install('install-codex.sh', box.env, ['--yes', '--no-skill-hints']);
|
|
127
|
+
assert.equal(flagged.status, 0, output(flagged));
|
|
128
|
+
assert.doesNotMatch(bytesOf(box.hooks) ?? '', /cm-skill-hints/);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('install.sh does not add back a hook the user removed',
|
|
132
|
+
{skip: process.platform === 'win32', timeout: 600000}, t => {
|
|
133
|
+
const box = sandbox(t);
|
|
134
|
+
// Wired once by an earlier install, then taken out by the user.
|
|
135
|
+
fs.mkdirSync(box.copy, {recursive: true});
|
|
136
|
+
fs.writeFileSync(path.join(box.home, 'workflow/skill-hints.auto.json'), '{"version":1,"hosts":["claude"]}\n');
|
|
137
|
+
fs.mkdirSync(path.dirname(box.settings), {recursive: true});
|
|
138
|
+
fs.writeFileSync(box.settings, '{"hooks":{"UserPromptSubmit":[]}}\n');
|
|
139
|
+
const result = install('install.sh', box.env);
|
|
140
|
+
assert.equal(result.status, 0, output(result));
|
|
141
|
+
assert.equal(bytesOf(box.settings), '{"hooks":{"UserPromptSubmit":[]}}\n');
|
|
142
|
+
assert.match(output(result), /之前挂过后被移除/);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const pwsh = spawnSync('pwsh', ['-NoProfile', '-Command', 'exit 0']).status === 0;
|
|
146
|
+
test('install.ps1 wires the Claude hook by default and not with -NoSkillHints',
|
|
147
|
+
{skip: !pwsh && 'pwsh not available', timeout: 600000}, t => {
|
|
148
|
+
for (const [args, wired] of [[['-NoSkillHints'], false], [[], true]]) {
|
|
149
|
+
const box = sandbox(t);
|
|
150
|
+
const result = spawnSync('pwsh', ['-NoProfile', '-File', path.join(source, 'install.ps1'), '-Yes', ...args],
|
|
151
|
+
{cwd: source, env: {...box.env, USERPROFILE: box.home}, encoding: 'utf8', timeout: 240000, maxBuffer: 8 * 1024 * 1024, input: ''});
|
|
152
|
+
assert.equal(result.status, 0, output(result));
|
|
153
|
+
assert.equal(/skill-hints\/cm-skill-hints\.mjs hook --host claude/.test(bytesOf(box.settings) ?? ''), wired, output(result));
|
|
154
|
+
assert.equal(fs.existsSync(box.copy), wired);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('install.sh: a failed refresh only warns; the install still succeeds',
|
|
159
|
+
{skip: process.platform === 'win32', timeout: 600000}, t => {
|
|
160
|
+
const box = sandbox(t);
|
|
161
|
+
enabledUser(box, 'claude');
|
|
162
|
+
fs.rmSync(path.join(box.copy, 'cm-config-lock.mjs'));
|
|
163
|
+
fs.mkdirSync(path.join(box.copy, 'cm-config-lock.mjs/blocker'), {recursive: true});
|
|
164
|
+
const result = install('install.sh', box.env);
|
|
165
|
+
assert.equal(result.status, 0, output(result));
|
|
166
|
+
assert.match(output(result), /⚠.*技能提醒.*未刷新/);
|
|
167
|
+
assert.equal(fs.readFileSync(path.join(box.copy, 'cm-skill-hints.mjs'), 'utf8'), '// old version\n');
|
|
168
|
+
});
|