@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
package/install.sh
CHANGED
|
@@ -9,14 +9,45 @@ VERSION="$(cat "$SRC_DIR/VERSION" 2>/dev/null || echo 未知)"
|
|
|
9
9
|
STAGE="$DEST_PARENT/.cm-claude.stage.$$"
|
|
10
10
|
BACKUP="$DEST_PARENT/.cm-claude.backup.$$"
|
|
11
11
|
ASSUME_YES=0
|
|
12
|
+
OVERWRITE_LOCAL_EDITS=0
|
|
13
|
+
# Non-empty when --no-skill-hints is given: this run does not wire the skill-hints hook.
|
|
14
|
+
SKIP_SKILL_HINTS=""
|
|
15
|
+
# Non-empty when --no-matt-skills is given: this run does not install the companion skills.
|
|
16
|
+
SKIP_MATT_SKILLS=""
|
|
12
17
|
INSTALL_COMPLETE=0
|
|
13
18
|
DEST_TOUCHED=0
|
|
19
|
+
# Records what this install wrote so the next install can tell hand edits apart.
|
|
20
|
+
INSTALL_MANIFEST_RELATIVE="cm-workflow/install-manifest.sha256"
|
|
21
|
+
INSTALL_MANIFEST="$DEST/$INSTALL_MANIFEST_RELATIVE"
|
|
22
|
+
GUARD_TMP=""
|
|
23
|
+
MANIFEST_PUBLISHED=0
|
|
24
|
+
MANIFEST_TMP=""
|
|
25
|
+
# One install transaction per target; never taken over automatically. The path
|
|
26
|
+
# is set from the canonical target below (shared rule with install-codex.sh).
|
|
27
|
+
LOCK_DIR=""
|
|
28
|
+
LOCK_HELD=0
|
|
29
|
+
ROLLBACK_FAILED=0
|
|
30
|
+
# Files this run started writing; rollback restores only these, so a file that
|
|
31
|
+
# was never copied (e.g. one found hand-edited mid-copy) is left untouched.
|
|
32
|
+
WRITTEN_LIST=""
|
|
33
|
+
# Each rollback record is "<relative><TAB>W"; a record without this ending was
|
|
34
|
+
# cut short (e.g. a disk-full partial write) and is never used.
|
|
35
|
+
WRITTEN_MARK="$(printf '\tW')"
|
|
36
|
+
VERIFIED_MANIFEST=""
|
|
37
|
+
MANIFEST_SAVED_NAME=".cm-previous-install-manifest"
|
|
14
38
|
|
|
15
|
-
|
|
16
|
-
""
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
39
|
+
for arg in "$@"; do
|
|
40
|
+
case "$arg" in
|
|
41
|
+
--yes) ASSUME_YES=1 ;;
|
|
42
|
+
--overwrite-local-edits) OVERWRITE_LOCAL_EDITS=1 ;;
|
|
43
|
+
--no-skill-hints) SKIP_SKILL_HINTS=1 ;;
|
|
44
|
+
--no-matt-skills) SKIP_MATT_SKILLS=1 ;;
|
|
45
|
+
*) echo "用法: $0 [--yes] [--overwrite-local-edits] [--no-skill-hints] [--no-matt-skills]" >&2; exit 2 ;;
|
|
46
|
+
esac
|
|
47
|
+
done
|
|
48
|
+
|
|
49
|
+
# shellcheck source=scripts/cm-install-manifest.sh
|
|
50
|
+
. "$SRC_DIR/scripts/cm-install-manifest.sh"
|
|
20
51
|
|
|
21
52
|
if ! command -v node >/dev/null 2>&1 ||
|
|
22
53
|
! node -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 18 ? 0 : 1)' >/dev/null 2>&1; then
|
|
@@ -24,24 +55,108 @@ if ! command -v node >/dev/null 2>&1 ||
|
|
|
24
55
|
exit 1
|
|
25
56
|
fi
|
|
26
57
|
|
|
58
|
+
# Canonical install root: one physical path per real target, never a symlink.
|
|
59
|
+
if DEST_CANONICAL=$(cm_install_canonical_target "$DEST"); then
|
|
60
|
+
:
|
|
61
|
+
else
|
|
62
|
+
canonical_status=$?
|
|
63
|
+
if [ "$canonical_status" -eq 2 ]; then
|
|
64
|
+
echo "安装目录不能是符号链接或非目录: ${DEST};安装已停止,未修改任何文件。" >&2
|
|
65
|
+
else
|
|
66
|
+
echo "无法确定安装目录的真实路径: ${DEST};安装已停止,未修改任何文件。" >&2
|
|
67
|
+
fi
|
|
68
|
+
exit 2
|
|
69
|
+
fi
|
|
70
|
+
DEST="$DEST_CANONICAL"
|
|
71
|
+
DEST_PARENT="$(dirname "$DEST")"
|
|
72
|
+
STAGE="$DEST_PARENT/.cm-claude.stage.$$"
|
|
73
|
+
BACKUP="$DEST_PARENT/.cm-claude.backup.$$"
|
|
74
|
+
INSTALL_MANIFEST="$DEST/$INSTALL_MANIFEST_RELATIVE"
|
|
75
|
+
LOCK_DIR="$(cm_install_lock_path "$DEST")"
|
|
76
|
+
|
|
77
|
+
# Rollback keeps going after a failed step (no errexit, signals ignored), keeps
|
|
78
|
+
# the backup whenever anything could not be restored, and always unlocks.
|
|
79
|
+
rollback_fail() {
|
|
80
|
+
echo " 恢复失败: $1" >&2
|
|
81
|
+
ROLLBACK_FAILED=1
|
|
82
|
+
}
|
|
83
|
+
|
|
27
84
|
cleanup() {
|
|
28
85
|
status=$?
|
|
29
|
-
|
|
86
|
+
set +e
|
|
87
|
+
trap '' HUP INT TERM
|
|
88
|
+
trap - EXIT
|
|
30
89
|
if [ "$INSTALL_COMPLETE" -ne 1 ] && [ "$DEST_TOUCHED" -eq 1 ]; then
|
|
31
|
-
|
|
32
|
-
|
|
90
|
+
# Without a readable list of what was written nothing can be restored
|
|
91
|
+
# safely: report it and keep the backup instead of claiming success.
|
|
92
|
+
if written_files=$(cat "$WRITTEN_LIST" 2>/dev/null); then
|
|
93
|
+
:
|
|
94
|
+
else
|
|
95
|
+
written_files=""
|
|
96
|
+
rollback_fail "回滚清单不可读: ${WRITTEN_LIST}(已写入的文件未恢复)"
|
|
97
|
+
fi
|
|
98
|
+
# Split on newlines only (no temporary file, unlike a here-document).
|
|
99
|
+
saved_ifs=$IFS
|
|
100
|
+
IFS='
|
|
101
|
+
'
|
|
102
|
+
set -f
|
|
103
|
+
for record in $written_files; do
|
|
104
|
+
[ -n "$record" ] || continue
|
|
105
|
+
# Only complete records naming a file this install manages are used; a
|
|
106
|
+
# cut-short prefix could name an unrelated user file.
|
|
107
|
+
case "$record" in
|
|
108
|
+
*"$WRITTEN_MARK") relative=${record%"$WRITTEN_MARK"} ;;
|
|
109
|
+
*) rollback_fail "回滚清单记录不完整,未使用: ${record}"; continue ;;
|
|
110
|
+
esac
|
|
111
|
+
member=0
|
|
112
|
+
grep -Fxq -- "$relative" "$STAGE/.cm-managed-files" || member=$?
|
|
113
|
+
if [ "$member" -ne 0 ]; then
|
|
114
|
+
rollback_fail "回滚清单记录不属于本次安装或无法核对,未使用: ${relative}"
|
|
115
|
+
continue
|
|
116
|
+
fi
|
|
33
117
|
target="$DEST/$relative"
|
|
34
118
|
saved="$BACKUP/$relative"
|
|
119
|
+
access=0
|
|
120
|
+
cm_manifest_parent_is_safe "$DEST" "$relative" || access=$?
|
|
121
|
+
if [ "$access" -eq 2 ]; then
|
|
122
|
+
rollback_fail "$target(上级目录无法访问,未写入)"
|
|
123
|
+
continue
|
|
124
|
+
fi
|
|
125
|
+
if ! assert_safe_target "$relative"; then
|
|
126
|
+
rollback_fail "$target(路径类型已变化,未写入)"
|
|
127
|
+
continue
|
|
128
|
+
fi
|
|
35
129
|
if [ -f "$saved" ]; then
|
|
36
|
-
mkdir -p "$(dirname "$target")"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
130
|
+
{ mkdir -p "$(dirname "$target")" && cp -p "$saved" "$target"; } || rollback_fail "$target"
|
|
131
|
+
elif [ -f "$target" ]; then
|
|
132
|
+
rm -f "$target" || rollback_fail "$target"
|
|
133
|
+
fi
|
|
134
|
+
done
|
|
135
|
+
set +f
|
|
136
|
+
IFS=$saved_ifs
|
|
137
|
+
# Keep the manifest paired with the restored files.
|
|
138
|
+
if [ "$MANIFEST_PUBLISHED" -eq 1 ]; then
|
|
139
|
+
if ! assert_safe_target "$INSTALL_MANIFEST_RELATIVE"; then
|
|
140
|
+
rollback_fail "$INSTALL_MANIFEST(路径类型已变化,未写入)"
|
|
141
|
+
elif [ -f "$BACKUP/$MANIFEST_SAVED_NAME" ]; then
|
|
142
|
+
cp -p "$BACKUP/$MANIFEST_SAVED_NAME" "$INSTALL_MANIFEST" || rollback_fail "$INSTALL_MANIFEST"
|
|
143
|
+
else
|
|
144
|
+
rm -f "$INSTALL_MANIFEST" || rollback_fail "$INSTALL_MANIFEST"
|
|
40
145
|
fi
|
|
41
|
-
|
|
42
|
-
|
|
146
|
+
fi
|
|
147
|
+
if [ "$ROLLBACK_FAILED" -eq 1 ]; then
|
|
148
|
+
echo "⚠ 安装失败,回滚不完整。恢复材料保留在: ${BACKUP}" >&2
|
|
149
|
+
echo " (按相对路径存放的原文件;旧安装清单为 ${BACKUP}/${MANIFEST_SAVED_NAME})" >&2
|
|
150
|
+
else
|
|
151
|
+
echo "安装失败,已回滚本次写入。" >&2
|
|
152
|
+
fi
|
|
43
153
|
fi
|
|
44
|
-
rm -rf "$STAGE"
|
|
154
|
+
rm -rf "$STAGE"
|
|
155
|
+
[ "$ROLLBACK_FAILED" -eq 1 ] || rm -rf "$BACKUP"
|
|
156
|
+
[ -z "$GUARD_TMP" ] || rm -rf "$GUARD_TMP"
|
|
157
|
+
# Only the temporary manifest this run created (mktemp) is removed.
|
|
158
|
+
[ -z "$MANIFEST_TMP" ] || rm -f "$MANIFEST_TMP"
|
|
159
|
+
[ "$LOCK_HELD" -ne 1 ] || rm -rf "$LOCK_DIR" || echo "⚠ 无法释放安装锁: ${LOCK_DIR}" >&2
|
|
45
160
|
exit "$status"
|
|
46
161
|
}
|
|
47
162
|
trap cleanup EXIT
|
|
@@ -121,13 +236,69 @@ confirm_bundle_conflicts() {
|
|
|
121
236
|
echo "⚠ 以下 CM 文件已存在,将作为一个整体更新:"
|
|
122
237
|
printf '%s' "$conflicts" | sed '/^$/d; s/^/ /'
|
|
123
238
|
[ "$ASSUME_YES" -eq 1 ] && return 0
|
|
124
|
-
read -r -p "
|
|
239
|
+
read -r -p " 继续整体更新全部 CM 文件(失败时回滚)?[y/N] " answer
|
|
125
240
|
case "$answer" in
|
|
126
241
|
y|Y) return 0 ;;
|
|
127
242
|
*) echo "安装已取消,未修改现有运行时。"; return 1 ;;
|
|
128
243
|
esac
|
|
129
244
|
}
|
|
130
245
|
|
|
246
|
+
# Stop before any write when a file recorded by the previous install changed.
|
|
247
|
+
# --yes only accepts replacing CM files; it never discards hand edits.
|
|
248
|
+
# Runs twice: once up front, and again ("recheck") after staging and the
|
|
249
|
+
# overwrite prompt, right before the first write, because another session may
|
|
250
|
+
# edit an installed file while this one waits for an answer.
|
|
251
|
+
guard_local_edits() {
|
|
252
|
+
guard_mode=${1:-initial}
|
|
253
|
+
if ! cm_manifest_select_hasher; then
|
|
254
|
+
echo "未找到 shasum 或 sha256sum,无法核对已安装文件是否被手改;安装已停止,未修改任何文件。" >&2
|
|
255
|
+
return 2
|
|
256
|
+
fi
|
|
257
|
+
if ! assert_safe_target "$INSTALL_MANIFEST_RELATIVE"; then
|
|
258
|
+
return 2
|
|
259
|
+
fi
|
|
260
|
+
manifest_access=0
|
|
261
|
+
cm_manifest_parent_is_safe "$DEST" "$INSTALL_MANIFEST_RELATIVE" || manifest_access=$?
|
|
262
|
+
if [ "$manifest_access" -eq 2 ]; then
|
|
263
|
+
echo "安装目录无法访问,无法判断上次的安装清单是否存在: ${INSTALL_MANIFEST};安装已停止,未修改任何文件。" >&2
|
|
264
|
+
return 2
|
|
265
|
+
fi
|
|
266
|
+
if [ ! -e "$INSTALL_MANIFEST" ]; then
|
|
267
|
+
[ "$guard_mode" = recheck ] ||
|
|
268
|
+
echo "ℹ 未找到上次的安装清单(首次安装或旧版本安装),本次不核对手改;安装成功后会生成清单。"
|
|
269
|
+
return 0
|
|
270
|
+
fi
|
|
271
|
+
edits="$GUARD_TMP/local-edits"
|
|
272
|
+
if cm_manifest_find_edits "$DEST" "$INSTALL_MANIFEST" "$edits" "$GUARD_TMP"; then
|
|
273
|
+
:
|
|
274
|
+
else
|
|
275
|
+
find_status=$?
|
|
276
|
+
if [ "$find_status" -ne 3 ]; then
|
|
277
|
+
echo "核对已安装文件失败,安装已停止,未修改任何文件。" >&2
|
|
278
|
+
return 2
|
|
279
|
+
fi
|
|
280
|
+
echo "⚠ 安装清单格式无法识别: ${INSTALL_MANIFEST}" >&2
|
|
281
|
+
if [ "$OVERWRITE_LOCAL_EDITS" -eq 1 ]; then
|
|
282
|
+
echo "已指定 --overwrite-local-edits,跳过手改核对并重新生成清单。"
|
|
283
|
+
return 0
|
|
284
|
+
fi
|
|
285
|
+
echo "安装已停止,未修改任何文件。确认要覆盖现有 CM 文件时,加 --overwrite-local-edits 重新运行。" >&2
|
|
286
|
+
return 1
|
|
287
|
+
fi
|
|
288
|
+
[ -s "$edits" ] || return 0
|
|
289
|
+
if [ "$OVERWRITE_LOCAL_EDITS" -eq 1 ] && [ "$guard_mode" = recheck ]; then
|
|
290
|
+
return 0
|
|
291
|
+
fi
|
|
292
|
+
echo "⚠ 以下 CM 文件在上次安装后被改动过(与安装清单记录的 sha256 不一致):" >&2
|
|
293
|
+
sed 's/^/ /' "$edits" >&2
|
|
294
|
+
if [ "$OVERWRITE_LOCAL_EDITS" -eq 1 ]; then
|
|
295
|
+
echo "已指定 --overwrite-local-edits,将覆盖以上改动。"
|
|
296
|
+
return 0
|
|
297
|
+
fi
|
|
298
|
+
echo "安装已停止,未修改任何文件。--yes 不会覆盖手改;请先保存或合并这些改动,确认丢弃时加 --overwrite-local-edits 重新运行。" >&2
|
|
299
|
+
return 1
|
|
300
|
+
}
|
|
301
|
+
|
|
131
302
|
copy_file_atomic() {
|
|
132
303
|
src=$1
|
|
133
304
|
dst=$2
|
|
@@ -156,7 +327,47 @@ echo " 来源: $SRC_DIR"
|
|
|
156
327
|
echo " 目标: $DEST"
|
|
157
328
|
echo
|
|
158
329
|
|
|
159
|
-
mkdir -p "$DEST_PARENT"
|
|
330
|
+
mkdir -p "$DEST_PARENT"
|
|
331
|
+
cm_defer_signals
|
|
332
|
+
if cm_install_lock_acquire "$LOCK_DIR"; then
|
|
333
|
+
LOCK_HELD=1
|
|
334
|
+
cm_install_test_hook lock-acquired
|
|
335
|
+
cm_install_lock_write_owner "$LOCK_DIR" "$DEST"
|
|
336
|
+
fi
|
|
337
|
+
cm_resume_signals
|
|
338
|
+
if [ "$LOCK_HELD" -eq 1 ]; then
|
|
339
|
+
:
|
|
340
|
+
elif [ ! -d "$LOCK_DIR" ] || [ -L "$LOCK_DIR" ]; then
|
|
341
|
+
echo "无法创建安装锁: ${LOCK_DIR};安装已停止,未修改任何文件。" >&2
|
|
342
|
+
exit 2
|
|
343
|
+
else
|
|
344
|
+
lock_pid=$(cm_install_lock_field "$LOCK_DIR" pid)
|
|
345
|
+
lock_started=$(cm_install_lock_field "$LOCK_DIR" started)
|
|
346
|
+
lock_state=$(cm_install_lock_pid_state "$lock_pid")
|
|
347
|
+
echo "⚠ 另一个 CM 安装正在写同一目标,本次已停止,未修改任何文件。" >&2
|
|
348
|
+
echo " 锁: ${LOCK_DIR}" >&2
|
|
349
|
+
echo " 持有进程: ${lock_pid:-未知}(开始于 ${lock_started:-未知})" >&2
|
|
350
|
+
case "$lock_state" in
|
|
351
|
+
alive) echo " 该进程仍在运行;等它结束后重试。" >&2 ;;
|
|
352
|
+
not-running) echo " 该进程已不在运行,锁可能是中断遗留。确认没有安装在进行后,手动清理再重试:" >&2
|
|
353
|
+
echo " rm -rf $(cm_install_quote "$LOCK_DIR")" >&2 ;;
|
|
354
|
+
*) echo " 无法判断持有进程是否还在;确认没有安装在进行后,手动清理再重试:" >&2
|
|
355
|
+
echo " rm -rf $(cm_install_quote "$LOCK_DIR")" >&2 ;;
|
|
356
|
+
esac
|
|
357
|
+
exit 4
|
|
358
|
+
fi
|
|
359
|
+
GUARD_TMP="$(mktemp -d "${TMPDIR:-/tmp}/cm-install-guard.XXXXXX")"
|
|
360
|
+
WRITTEN_LIST="$GUARD_TMP/written-files"
|
|
361
|
+
: > "$WRITTEN_LIST"
|
|
362
|
+
if guard_local_edits; then
|
|
363
|
+
:
|
|
364
|
+
else
|
|
365
|
+
guard_status=$?
|
|
366
|
+
[ "$guard_status" -eq 1 ] && exit 3
|
|
367
|
+
exit "$guard_status"
|
|
368
|
+
fi
|
|
369
|
+
|
|
370
|
+
mkdir -p "$STAGE"
|
|
160
371
|
for part in skills agents runtime scripts compat; do
|
|
161
372
|
stage_tree "$SRC_DIR/$part" "$part"
|
|
162
373
|
done
|
|
@@ -203,6 +414,10 @@ done
|
|
|
203
414
|
|
|
204
415
|
(cd "$STAGE" && find . -type f ! -name .cm-managed-files | sed 's#^\./##' | sort) \
|
|
205
416
|
> "$STAGE/.cm-managed-files"
|
|
417
|
+
if ! cm_manifest_write "$STAGE" "$STAGE/.cm-managed-files" "$GUARD_TMP/new-manifest"; then
|
|
418
|
+
echo "生成安装清单失败,安装已停止,未修改任何文件。" >&2
|
|
419
|
+
exit 1
|
|
420
|
+
fi
|
|
206
421
|
|
|
207
422
|
if confirm_bundle_conflicts; then
|
|
208
423
|
:
|
|
@@ -215,22 +430,101 @@ fi
|
|
|
215
430
|
mkdir -p "$BACKUP"
|
|
216
431
|
while IFS= read -r relative; do
|
|
217
432
|
[ -n "$relative" ] || continue
|
|
433
|
+
if ! assert_safe_target "$relative"; then
|
|
434
|
+
echo "安装目标在确认后发生结构变化,安装已停止,未修改任何文件。" >&2
|
|
435
|
+
exit 3
|
|
436
|
+
fi
|
|
437
|
+
access=0
|
|
438
|
+
cm_manifest_parent_is_safe "$DEST" "$relative" || access=$?
|
|
439
|
+
if [ "$access" -eq 2 ]; then
|
|
440
|
+
echo "安装目标 ${relative} 的上级目录无法访问,安装已停止,未修改任何文件。" >&2
|
|
441
|
+
exit 2
|
|
442
|
+
fi
|
|
218
443
|
if [ -f "$DEST/$relative" ]; then
|
|
219
444
|
mkdir -p "$(dirname "$BACKUP/$relative")"
|
|
220
445
|
cp -p "$DEST/$relative" "$BACKUP/$relative"
|
|
221
446
|
fi
|
|
222
447
|
done < "$STAGE/.cm-managed-files"
|
|
448
|
+
if [ -f "$INSTALL_MANIFEST" ] && [ ! -L "$INSTALL_MANIFEST" ]; then
|
|
449
|
+
cp -p "$INSTALL_MANIFEST" "$BACKUP/$MANIFEST_SAVED_NAME"
|
|
450
|
+
fi
|
|
451
|
+
|
|
452
|
+
# Second check, just before the first write to the real target.
|
|
453
|
+
if guard_local_edits recheck; then
|
|
454
|
+
:
|
|
455
|
+
else
|
|
456
|
+
guard_status=$?
|
|
457
|
+
[ "$guard_status" -eq 1 ] && exit 3
|
|
458
|
+
exit "$guard_status"
|
|
459
|
+
fi
|
|
460
|
+
# Freeze the manifest the recheck just accepted for the per-file checks below.
|
|
461
|
+
if [ "$OVERWRITE_LOCAL_EDITS" -ne 1 ] && [ -f "$INSTALL_MANIFEST" ]; then
|
|
462
|
+
VERIFIED_MANIFEST="$GUARD_TMP/verified-manifest"
|
|
463
|
+
cp "$INSTALL_MANIFEST" "$VERIFIED_MANIFEST"
|
|
464
|
+
if ! cm_manifest_validate "$VERIFIED_MANIFEST"; then
|
|
465
|
+
echo "⚠ 安装清单在核对后发生变化,安装已停止,未修改任何文件。" >&2
|
|
466
|
+
exit 3
|
|
467
|
+
fi
|
|
468
|
+
fi
|
|
223
469
|
|
|
470
|
+
# Narrow the check-to-write window to a single file: right before each copy,
|
|
471
|
+
# compare the file's current sha256 with the previous manifest. This cannot be
|
|
472
|
+
# atomic; do not edit installed CM files while an install is running.
|
|
473
|
+
# CM_INSTALL_TEST_HOOK is for the repository's tests only (unset by default):
|
|
474
|
+
# it runs as `$CM_INSTALL_TEST_HOOK before-copy <relative>` before each file.
|
|
224
475
|
mkdir -p "$DEST"
|
|
225
476
|
DEST_TOUCHED=1
|
|
226
477
|
while IFS= read -r relative; do
|
|
227
478
|
[ -n "$relative" ] || continue
|
|
479
|
+
cm_install_test_hook before-copy "$relative"
|
|
480
|
+
# Type and parent path first: never write through a symlink or into a
|
|
481
|
+
# directory that replaced a file after the earlier checks.
|
|
482
|
+
if ! assert_safe_target "$relative"; then
|
|
483
|
+
echo "⚠ 安装过程中 ${relative} 的路径类型发生变化,已停止并回滚已写入的文件;该路径保持原样。" >&2
|
|
484
|
+
exit 3
|
|
485
|
+
fi
|
|
486
|
+
access=0
|
|
487
|
+
cm_manifest_parent_is_safe "$DEST" "$relative" || access=$?
|
|
488
|
+
if [ "$access" -eq 2 ]; then
|
|
489
|
+
echo "⚠ 安装过程中 ${relative} 的上级目录无法访问,已停止并回滚已写入的文件。" >&2
|
|
490
|
+
exit 2
|
|
491
|
+
fi
|
|
492
|
+
if [ -n "$VERIFIED_MANIFEST" ] && [ -f "$DEST/$relative" ]; then
|
|
493
|
+
recorded=$(cm_manifest_recorded_hash "$VERIFIED_MANIFEST" "$relative")
|
|
494
|
+
if [ -n "$recorded" ]; then
|
|
495
|
+
current=$(cm_manifest_file_hash "$DEST/$relative")
|
|
496
|
+
if [ "$current" != "$recorded" ]; then
|
|
497
|
+
echo "⚠ 安装过程中 ${relative} 被改动(与安装清单记录的 sha256 不一致),已停止并回滚已写入的文件;该文件保持原样。" >&2
|
|
498
|
+
echo " 确认丢弃这个改动时,加 --overwrite-local-edits 重新运行。" >&2
|
|
499
|
+
exit 3
|
|
500
|
+
fi
|
|
501
|
+
fi
|
|
502
|
+
fi
|
|
503
|
+
printf '%s\tW\n' "$relative" >> "$WRITTEN_LIST"
|
|
228
504
|
mkdir -p "$(dirname "$DEST/$relative")"
|
|
229
505
|
cp -p "$STAGE/$relative" "$DEST/$relative"
|
|
230
506
|
done < "$STAGE/.cm-managed-files"
|
|
231
507
|
|
|
232
508
|
"$DEST/scripts/cm-check-runtime.sh" --project "$SRC_DIR"
|
|
509
|
+
mkdir -p "$(dirname "$INSTALL_MANIFEST")"
|
|
510
|
+
if ! assert_safe_target "$INSTALL_MANIFEST_RELATIVE"; then
|
|
511
|
+
echo "安装清单路径类型发生变化,已停止并回滚。" >&2
|
|
512
|
+
exit 3
|
|
513
|
+
fi
|
|
514
|
+
# The temporary manifest is created exclusively by mktemp under a random name
|
|
515
|
+
# in the checked directory; cleanup removes only this file.
|
|
516
|
+
cm_defer_signals
|
|
517
|
+
MANIFEST_TMP=$(cm_run_shielded mktemp "$(dirname "$INSTALL_MANIFEST")/.install-manifest.XXXXXX")
|
|
518
|
+
cm_resume_signals
|
|
519
|
+
cp "$GUARD_TMP/new-manifest" "$MANIFEST_TMP"
|
|
520
|
+
chmod 644 "$MANIFEST_TMP"
|
|
521
|
+
cm_install_test_hook before-manifest-publish
|
|
522
|
+
MANIFEST_PUBLISHED=1
|
|
523
|
+
mv -f "$MANIFEST_TMP" "$INSTALL_MANIFEST"
|
|
524
|
+
MANIFEST_TMP=""
|
|
525
|
+
cm_install_test_hook after-manifest-publish
|
|
233
526
|
INSTALL_COMPLETE=1
|
|
527
|
+
echo "✓ 安装清单已写入: ${INSTALL_MANIFEST}"
|
|
234
528
|
|
|
235
529
|
# User runtimes.yml: only after the verified core install, before updater prompts.
|
|
236
530
|
if [ "$ASSUME_YES" -ne 1 ] && [ -t 0 ] && [ -t 1 ]; then
|
|
@@ -258,3 +552,13 @@ else
|
|
|
258
552
|
echo "自动更新器未自动启用;按 docs/installation.md 手工配置 SessionStart hook。"
|
|
259
553
|
fi
|
|
260
554
|
echo "后台自动升级仍需另行开启,见 docs/installation.md。"
|
|
555
|
+
# Skill hints: wire the hook into Claude settings once by default (not with --no-skill-hints,
|
|
556
|
+
# CM_SKILL_HINTS_INSTALL=off, "enabled": false, or after the user removed it); otherwise
|
|
557
|
+
# only refresh the copy under ~/.cm-workflow/skill-hints. Failure only warns.
|
|
558
|
+
node "$DEST/scripts/cm-skill-hints.mjs" install --host claude ${SKIP_SKILL_HINTS:+--no-skill-hints} </dev/null ||
|
|
559
|
+
echo "⚠ 技能提醒钩子未处理完(不影响本次安装)" >&2
|
|
560
|
+
# Optional Matt Pocock companion skills: put the pinned set in by default (not with
|
|
561
|
+
# --no-matt-skills, CM_MATT_SKILLS_INSTALL=off, {"install": false} in ~/.cm-workflow/matt-skills.local.json,
|
|
562
|
+
# or a skill the user removed after CM saw it there); a fetch that fails only warns.
|
|
563
|
+
echo
|
|
564
|
+
node "$DEST/scripts/cm-matt-skills.mjs" auto ${SKIP_MATT_SKILLS:+--no-matt-skills} </dev/null || true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aibyzero/cm-workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Spec-driven business development workflow for Pi, Codex, and Claude Code",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"pi": {
|
|
45
45
|
"skills": [
|
|
46
46
|
"./skills/cm-ai",
|
|
47
|
+
"./skills/cm-challenge",
|
|
47
48
|
"./skills/cm-check",
|
|
48
49
|
"./skills/cm-fix",
|
|
49
50
|
"./skills/cm-idea",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Where a batch's parallel members live: .cm-worktrees/<segment>/<taskId> and
|
|
2
|
+
// branch cm/<segment>/<feature>/<taskId>. One function for the scheduler, the
|
|
3
|
+
// driver and the batch host, so the three never disagree.
|
|
4
|
+
//
|
|
5
|
+
// Batches used to take the first 8 characters of batchId as the segment, so
|
|
6
|
+
// "batch-20261022-A" and "batch-20261022-B" shared worktrees and branches. A new
|
|
7
|
+
// batch now records a segment derived from its full id in its batch_start row.
|
|
8
|
+
// A batch that already started without that field keeps the old segment, so a
|
|
9
|
+
// resumed batch still finds the worktrees and branches it created.
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import {createHash} from 'node:crypto';
|
|
13
|
+
import {need} from './effect-contract.mjs';
|
|
14
|
+
import {scanRows} from './log-rows.mjs';
|
|
15
|
+
|
|
16
|
+
export const BATCH_SEGMENT_FIELD='worktree_segment';
|
|
17
|
+
|
|
18
|
+
// Git rejects ".." and a trailing dot in a ref component while batchId allows
|
|
19
|
+
// dots, so the readable prefix normalises them; the digest keeps it unique.
|
|
20
|
+
export function batchSegment(batchId){
|
|
21
|
+
need(typeof batchId==='string'&&batchId.length>0,'invalid_input');
|
|
22
|
+
return `${batchId.slice(0,8).replace(/\./g,'-')}-${createHash('sha256').update(batchId).digest('hex').slice(0,12)}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function batchStarted({specsDir,batchId}){return startRow(specsDir,batchId)!==null;}
|
|
26
|
+
// The same bounded, no-follow, strict reader the scheduler's progress() uses: a
|
|
27
|
+
// log it would refuse is refused here too, before any decision rests on it.
|
|
28
|
+
function startRow(specsDir,batchId){
|
|
29
|
+
const log=path.join(specsDir,'运行日志.jsonl');
|
|
30
|
+
if(!fs.existsSync(log))return null;
|
|
31
|
+
let found=null;
|
|
32
|
+
scanRows(log,row=>{if(found===null&&row?.workflow==='cm-ai'&&row.event==='decision'&&row.phase==='batch_start'&&row.run_id===batchId)found=row;});
|
|
33
|
+
return found;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// {dir, ref}: the directory segment and the ref segment. They differ only for a
|
|
37
|
+
// legacy batch whose 8-character prefix contains a dot.
|
|
38
|
+
export function batchSegments({specsDir,batchId}){
|
|
39
|
+
const row=startRow(specsDir,batchId);
|
|
40
|
+
if(row!==null&&!Object.hasOwn(row,BATCH_SEGMENT_FIELD)){
|
|
41
|
+
const legacy=batchId.slice(0,8);
|
|
42
|
+
return {dir:legacy,ref:legacy.replace(/\./g,'-'),legacy:true};
|
|
43
|
+
}
|
|
44
|
+
const segment=batchSegment(batchId);
|
|
45
|
+
// A recorded segment must be the one this id derives; never a path from the log.
|
|
46
|
+
if(row!==null)need(row[BATCH_SEGMENT_FIELD]===segment,'batch_history_invalid');
|
|
47
|
+
return {dir:segment,ref:segment,legacy:false};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function batchMemberWorktree({codeProject,segments,taskId}){
|
|
51
|
+
return path.resolve(codeProject,'..','.cm-worktrees',segments.dir,taskId);
|
|
52
|
+
}
|
|
53
|
+
export function batchMemberBranch({segments,feature,taskId}){
|
|
54
|
+
return `cm/${segments.ref}/${feature.replace(/^\d+\./,'')}/${taskId}`;
|
|
55
|
+
}
|