@aibyzero/cm-workflow 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +27 -0
- package/CHANGELOG.md +230 -1
- package/CONTRIBUTING.md +47 -0
- package/README.md +21 -3
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/VERSION +1 -1
- package/compat/claude-commands/cm-challenge.md +3 -0
- package/docs/architecture.md +40 -13
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +153 -16
- package/docs/live-evidence-drivers.md +28 -4
- package/docs/out-of-scope/README.md +25 -0
- package/docs/out-of-scope/background-supervisor.md +32 -0
- package/docs/reviewed-integration.md +48 -0
- package/docs/user-guide.md +50 -21
- package/install-codex.sh +331 -18
- package/install.ps1 +28 -2
- package/install.sh +321 -17
- package/package.json +2 -1
- package/runtime/js/cm-ai/batch-location.mjs +55 -0
- package/runtime/js/cm-ai/batch-plan.mjs +242 -0
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +94 -21
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
- package/runtime/js/cm-ai/codex-config.mjs +6 -2
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
- package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
- package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
- package/runtime/js/cm-ai/control-policy.mjs +24 -6
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +236 -34
- package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
- package/runtime/js/cm-ai/effect-contract.mjs +11 -2
- package/runtime/js/cm-ai/execution-policy.mjs +3 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
- package/runtime/js/cm-ai/execution-store.mjs +60 -17
- package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
- package/runtime/js/cm-ai/host-check.mjs +14 -6
- package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
- package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
- package/runtime/js/cm-ai/host-replay.mjs +148 -0
- package/runtime/js/cm-ai/host-session.mjs +42 -9
- package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +22 -9
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
- package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
- package/runtime/js/cm-ai/live-evidence.mjs +28 -6
- package/runtime/js/cm-ai/operator-guidance.mjs +63 -30
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
- package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
- package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
- package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
- package/runtime/js/cm-ai/review-package.mjs +79 -7
- package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
- package/runtime/js/cm-ai/review-presentation.mjs +177 -8
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
- package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
- package/runtime/js/cm-ai/scope-revision.mjs +38 -0
- package/runtime/js/cm-ai/specification-material.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +247 -41
- package/runtime/js/cm-ai/verification-auto.mjs +38 -0
- package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
- package/runtime/js/cm-ai/worker-claude.mjs +35 -13
- package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
- package/runtime/js/cm-ai/worker-codex.mjs +41 -7
- package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
- package/runtime/js/cm-fix/cause-package.mjs +46 -1
- package/runtime/js/cm-fix/command-correction.mjs +37 -0
- package/runtime/js/cm-fix/cooperative.mjs +12 -0
- package/runtime/js/cm-fix/dossier.mjs +8 -2
- package/runtime/js/cm-fix/execution.mjs +578 -100
- package/runtime/js/cm-fix/final-review.mjs +39 -8
- package/runtime/js/cm-fix/finish.mjs +15 -11
- package/runtime/js/cm-fix/host-review.mjs +65 -10
- package/runtime/js/cm-fix/host.mjs +35 -12
- package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
- package/runtime/js/cm-fix/metrics.mjs +18 -5
- package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
- package/runtime/js/cm-fix/regression.mjs +16 -7
- package/runtime/js/cm-fix/repair.mjs +29 -8
- package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
- package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
- package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
- package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
- package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
- package/runtime/js/cm-fix/review-verification.mjs +214 -0
- package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
- package/runtime/js/cm-fix/start.mjs +6 -3
- package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
- package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
- package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
- package/runtime/js/cm-prd/accepted-design.mjs +8 -0
- package/runtime/js/cm-prd/analysis.mjs +13 -9
- package/runtime/js/cm-prd/change.mjs +37 -16
- package/runtime/js/cm-prd/draft-save.mjs +13 -6
- package/runtime/js/cm-prd/draft.mjs +31 -3
- package/runtime/js/cm-prd/failed-correction.mjs +19 -3
- package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
- package/runtime/js/cm-prd/review-correction.mjs +6 -4
- package/runtime/js/cm-prd/review-disposition.mjs +7 -1
- package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
- package/runtime/js/cm-prd/self-check.mjs +125 -6
- package/runtime/js/cm-prd/session.mjs +30 -1
- package/runtime/js/cm-prd/summary.mjs +38 -17
- package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
- package/runtime/js/cm-prd/tree-digest.mjs +34 -0
- package/runtime/js/cm-prd/validation-reason.mjs +8 -4
- package/runtime/js/cm-security/scan.mjs +1 -1
- package/runtime/js/commander/decision.mjs +44 -0
- package/runtime/js/commander/dispatch-registry.mjs +110 -0
- package/runtime/js/commander/ledger.mjs +265 -0
- package/runtime/js/commander/preflight.mjs +107 -0
- package/runtime/js/notify-later.mjs +13 -0
- package/runtime/js/notify-send.mjs +6 -2
- package/runtime/js/notify.mjs +570 -63
- package/runtime/js/review-findings.mjs +38 -0
- package/runtime/js/session-boundary.mjs +56 -0
- package/runtime/js/session-handoff.mjs +68 -0
- package/runtime/js/spec-task-line.mjs +27 -13
- package/runtime/js/specs-status.mjs +1 -1
- package/runtime/js/task-scope.mjs +197 -0
- package/runtime/logging.md +6 -1
- package/runtime/model-efficiency.md +69 -10
- package/runtime/orchestration.md +3 -1
- package/runtime/project-learning.md +2 -0
- package/runtime/review.md +12 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +11 -5
- package/scripts/cm-ai-admission.test.mjs +23 -2
- package/scripts/cm-ai-batch-drive.mjs +79 -18
- package/scripts/cm-ai-batch-drive.test.mjs +169 -3
- package/scripts/cm-ai-batch-host.mjs +38 -9
- package/scripts/cm-ai-batch-host.test.mjs +27 -14
- package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
- package/scripts/cm-ai-batch-location.test.mjs +57 -0
- package/scripts/cm-ai-batch-plan.mjs +52 -0
- package/scripts/cm-ai-batch-plan.test.mjs +397 -0
- package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
- package/scripts/cm-ai-batch-run.mjs +483 -63
- package/scripts/cm-ai-batch-run.test.mjs +23 -4
- package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
- package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
- package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
- package/scripts/cm-ai-control-launch.test.mjs +21 -0
- package/scripts/cm-ai-control-policy.test.mjs +82 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
- package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
- package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
- package/scripts/cm-ai-development-rework.test.mjs +423 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +3 -2
- package/scripts/cm-ai-drive.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +37 -5
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host-fixture.mjs +9 -6
- package/scripts/cm-ai-host-protected.test.mjs +1 -1
- package/scripts/cm-ai-host.mjs +60 -19
- package/scripts/cm-ai-host.test.mjs +15 -0
- package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
- package/scripts/cm-ai-integration-independence.test.mjs +23 -0
- package/scripts/cm-ai-integration-launch.test.mjs +240 -0
- package/scripts/cm-ai-integration-preview.mjs +41 -0
- package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
- package/scripts/cm-ai-nested-execution.test.mjs +29 -1
- package/scripts/cm-ai-operator-guidance.test.mjs +71 -0
- package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
- package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
- package/scripts/cm-ai-review-failure.test.mjs +150 -5
- package/scripts/cm-ai-review-timeout.test.mjs +20 -0
- package/scripts/cm-ai-run.mjs +88 -21
- package/scripts/cm-ai-scope-revision.test.mjs +341 -0
- package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
- package/scripts/cm-ai-supersede.test.mjs +28 -0
- package/scripts/cm-ai-verification-auto.test.mjs +99 -0
- package/scripts/cm-announce-hook.mjs +35 -8
- package/scripts/cm-announce-hook.test.mjs +25 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +2 -2
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +58 -1
- package/scripts/cm-claude-developer-worker.test.mjs +56 -7
- package/scripts/cm-claude-install-layout.test.mjs +1 -1
- package/scripts/cm-claude-probe.test.mjs +26 -0
- package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +49 -0
- package/scripts/cm-claude-worker.test.mjs +16 -0
- package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
- package/scripts/cm-codex-developer-worker.test.mjs +120 -0
- package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
- package/scripts/cm-codex-prompt-input.test.mjs +153 -0
- package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
- package/scripts/cm-commander-ledger.test.mjs +260 -0
- package/scripts/cm-commander-p2.test.mjs +295 -0
- package/scripts/cm-commander-preflight.mjs +84 -0
- package/scripts/cm-commander.mjs +116 -0
- package/scripts/cm-config-lock.mjs +35 -0
- package/scripts/cm-controlled-correction.test.mjs +10 -1
- package/scripts/cm-developer-failure-code.test.mjs +62 -0
- package/scripts/cm-display-task-id.test.mjs +41 -0
- package/scripts/cm-drive-liveness.test.mjs +83 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
- package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
- package/scripts/cm-external-batch-host.test.mjs +12 -9
- package/scripts/cm-external-process-cleanup.test.mjs +128 -0
- package/scripts/cm-external-qa-fix.test.mjs +89 -7
- package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
- package/scripts/cm-failover.mjs +48 -10
- package/scripts/cm-failover.test.mjs +46 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
- package/scripts/cm-fix-command-correction.mjs +17 -0
- package/scripts/cm-fix-command-correction.test.mjs +211 -0
- package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
- package/scripts/cm-fix-drive.mjs +33 -5
- package/scripts/cm-fix-drive.test.mjs +49 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
- package/scripts/cm-fix-host-review.test.mjs +21 -9
- package/scripts/cm-fix-host.mjs +26 -8
- package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
- package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
- package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
- package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
- package/scripts/cm-fix-review-preflight.mjs +24 -0
- package/scripts/cm-fix-review-storage.test.mjs +233 -0
- package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
- package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
- package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
- package/scripts/cm-fix-review-verification.test.mjs +146 -0
- package/scripts/cm-fix-revision-transport.test.mjs +81 -0
- package/scripts/cm-fix-source-correction.test.mjs +296 -0
- package/scripts/cm-fix-test-type-correction.mjs +18 -0
- package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
- package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
- package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
- package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
- package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
- package/scripts/cm-fix-verification-recovery.mjs +33 -0
- package/scripts/cm-host-diagnostic.test.mjs +33 -0
- package/scripts/cm-host-liveness.test.mjs +150 -0
- package/scripts/cm-host-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -0
- package/scripts/cm-host-stage-observer.test.mjs +41 -0
- package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
- package/scripts/cm-install-manifest.sh +351 -0
- package/scripts/cm-live-evidence.test.mjs +59 -1
- package/scripts/cm-log-event.mjs +61 -10
- package/scripts/cm-log-event.test.mjs +121 -1
- package/scripts/cm-matt-skills.mjs +576 -0
- package/scripts/cm-matt-skills.test.mjs +550 -0
- package/scripts/cm-notify-command.test.mjs +42 -10
- package/scripts/cm-notify.mjs +14 -10
- package/scripts/cm-notify.test.mjs +625 -75
- package/scripts/cm-patrol.mjs +4 -1
- package/scripts/cm-patrol.test.mjs +23 -5
- package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
- package/scripts/cm-prd-completion.test.mjs +56 -13
- package/scripts/cm-prd-design-phase.test.mjs +78 -8
- package/scripts/cm-prd-draft-save.test.mjs +12 -0
- package/scripts/cm-prd-draft.test.mjs +1 -1
- package/scripts/cm-prd-drive.mjs +13 -6
- package/scripts/cm-prd-drive.test.mjs +46 -2
- package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
- package/scripts/cm-prd-host.mjs +10 -5
- package/scripts/cm-prd-host.test.mjs +4 -2
- package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
- package/scripts/cm-prd-review-disposition.test.mjs +124 -8
- package/scripts/cm-prd-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +16 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
- package/scripts/cm-prd-self-check.test.mjs +105 -5
- package/scripts/cm-prd-session-recovery.test.mjs +5 -3
- package/scripts/cm-prd-summary.test.mjs +55 -3
- package/scripts/cm-prd-task-grouping.test.mjs +6 -6
- package/scripts/cm-prd-tree-digest.test.mjs +74 -0
- package/scripts/cm-refactor-drive.mjs +2 -1
- package/scripts/cm-refactor-drive.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +3 -15
- package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
- package/scripts/cm-skill-hints-exam.mjs +149 -0
- package/scripts/cm-skill-hints-install.test.mjs +168 -0
- package/scripts/cm-skill-hints.exam.json +706 -0
- package/scripts/cm-skill-hints.json +119 -0
- package/scripts/cm-skill-hints.mjs +669 -0
- package/scripts/cm-skill-hints.test.mjs +831 -0
- package/scripts/cm-skill-judge.mjs +181 -0
- package/scripts/cm-skill-judge.test.mjs +255 -0
- package/scripts/cm-specs-status.test.mjs +4 -2
- package/scripts/cm-start-check.mjs +208 -0
- package/scripts/cm-start-check.test.mjs +321 -0
- package/scripts/cm-task-gate.mjs +150 -29
- package/scripts/cm-task-gate.test.mjs +73 -1
- package/scripts/cm-task-id-grammar.test.mjs +66 -0
- package/scripts/cm-task-scope.test.mjs +308 -0
- package/scripts/cm-test-suite.mjs +109 -0
- package/scripts/cm-test-suite.test.mjs +162 -0
- package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
- package/scripts/cm-upgrade-compat.test.mjs +239 -0
- package/scripts/cm-workflow-config.mjs +12 -2
- package/scripts/fixtures/fix-verification-claude.mjs +44 -0
- package/scripts/fixtures/host-diagnostic.mjs +33 -0
- package/scripts/fixtures/reviewed-integration.mjs +202 -0
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/session-boundary.test.mjs +170 -0
- package/scripts/test-npm-install.py +14 -3
- package/scripts/test-shell-compat.sh +2 -0
- package/scripts/validate-public-repo.py +1 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N4-review.md +2 -1
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/N8-finish.md +22 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
- package/skills/cm-ai/references/js-host-recovery.md +79 -3
- package/skills/cm-ai/references/js-host.md +89 -17
- package/skills/cm-challenge/SKILL.md +65 -0
- package/skills/cm-challenge/evals/README.md +18 -0
- package/skills/cm-challenge/evals/trigger-cases.json +20 -0
- package/skills/cm-challenge/evals/trigger-config.json +28 -0
- package/skills/cm-challenge/references/examples.md +15 -0
- package/skills/cm-check/SKILL.md +5 -0
- package/skills/cm-check/references/js-host.md +2 -0
- package/skills/cm-fix/SKILL.md +12 -3
- package/skills/cm-fix/references/command-correction.md +67 -0
- package/skills/cm-fix/references/isolated-review.md +54 -0
- package/skills/cm-fix/references/js-host.md +62 -2
- package/skills/cm-fix/references/test-type-correction.md +72 -0
- package/skills/cm-fix/references/verification-recovery.md +114 -0
- package/skills/cm-idea/SKILL.md +2 -0
- package/skills/cm-idea/references/js-host.md +2 -0
- package/skills/cm-notify/SKILL.md +2 -0
- package/skills/cm-prd/SKILL.md +12 -8
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +6 -0
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-host.md +4 -2
- package/skills/cm-prd/references/spec-self-check.md +5 -1
- package/skills/cm-refactor/SKILL.md +8 -0
- package/skills/cm-refactor/references/js-host.md +2 -0
- package/skills/cm-test/SKILL.md +4 -0
- package/templates/dashboard/dashboard.html +2 -2
- package/templates/pixel/cm-pixel.html +1 -1
- package/templates/pixel/cm-pixel.sh +1 -1
- package/templates/pixel/dev/template.html +1 -1
- package/templates/statusline/cm-statusline.sh +1 -1
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Optional companion skills from mattpocock/skills (MIT): report which are installed
|
|
3
|
+
// and copy a pinned and fully verified set.
|
|
4
|
+
//
|
|
5
|
+
// CM never depends on these skills. Since 2026-10-27 the installers put them in by
|
|
6
|
+
// default (`auto`, replacing the earlier report-only hint decided 2026-10-20), unless
|
|
7
|
+
// the user says no: --no-matt-skills or CM_MATT_SKILLS_INSTALL=off for one run,
|
|
8
|
+
// {"install": false} in ~/.cm-workflow/matt-skills.local.json for good, and a skill the
|
|
9
|
+
// user removed after CM saw it there is never put back (see "settled skills" below).
|
|
10
|
+
// A fetch that fails only warns; CM itself is installed either way. /cm-check only
|
|
11
|
+
// reports. `install` and `auto` fetch one fixed commit, read blobs straight from git
|
|
12
|
+
// (no checkout, nothing downloaded is executed), check every file against the SHA-256
|
|
13
|
+
// list below, and write nothing unless the whole set verifies. Existing skills with
|
|
14
|
+
// the same name are never overwritten.
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import os from 'node:os';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import crypto from 'node:crypto';
|
|
19
|
+
import {execFileSync} from 'node:child_process';
|
|
20
|
+
import {fileURLToPath} from 'node:url';
|
|
21
|
+
|
|
22
|
+
export const UPSTREAM=Object.freeze({
|
|
23
|
+
repo:'https://github.com/mattpocock/skills.git',
|
|
24
|
+
commit:'5beb35b040e3de97e54fa9e386d7e42d15c295c2',
|
|
25
|
+
license:{path:'LICENSE',sha256:'0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5'},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Ordered by how often a CM user reaches for them; hints list missing ones in this order.
|
|
29
|
+
export const SKILLS=Object.freeze([
|
|
30
|
+
{name:'grill-with-docs',dir:'skills/engineering/grill-with-docs',use:'在仓库里追问技术方案,结论留进术语表和决策记录',files:{
|
|
31
|
+
'SKILL.md':'7de372c13488f1ee96cc11cd8907b56b6809cc93eef776eeddd37de6b6cbe3fe',
|
|
32
|
+
'agents/openai.yaml':'94cd0ab161fb468a836349f5ed482ba58ce8e709a05c57ce533d739dbd35cca9'}},
|
|
33
|
+
{name:'grill-me',dir:'skills/productivity/grill-me',use:'不在仓库里,只想把一个想法问透',files:{
|
|
34
|
+
'SKILL.md':'caaf8b8de1684f96e26b28f3c29189db5c89cce4b73e1c93d86164f66ef88637',
|
|
35
|
+
'agents/openai.yaml':'c061e39c3e0f9d865fb1b97556d485704af2a8a58f4b8221a8917a5c2074a32b'}},
|
|
36
|
+
{name:'grilling',dir:'skills/productivity/grilling',use:'追问类技能背后的引擎,由其他技能自动调用',files:{
|
|
37
|
+
'SKILL.md':'befdff1e27a1dfe2a294d5871169ac1afe16d983911daa4f32627514a48c1e15',
|
|
38
|
+
'agents/openai.yaml':'1411d7df7d99b7e621a1ff8283c8133cc2464be63d064e52d8ce169c6800ee9b'}},
|
|
39
|
+
{name:'improve-codebase-architecture',dir:'skills/engineering/improve-codebase-architecture',use:'想重构但不知从哪下手时,找出重构机会并出报告',files:{
|
|
40
|
+
'HTML-REPORT.md':'581e8bb5a521e46bbda8ca7e19b15948bed882187108092ebb90c62513b77528',
|
|
41
|
+
'SKILL.md':'552240a5ab5cec6b67c15dd1ad6e9f6962b1bca6ce870059a8c2713760c20392',
|
|
42
|
+
'agents/openai.yaml':'c8cb20f68ebf0edb4e497bc11ae5fcaa196004e661cd189015b04f4109ced7f1'}},
|
|
43
|
+
{name:'codebase-design',dir:'skills/engineering/codebase-design',use:'讨论模块边界和接口设计时自动起作用',files:{
|
|
44
|
+
'DEEPENING.md':'f3dd099ce99289bd213914d8ee3e2429b78309c3957ca4583f7659551b1d53c1',
|
|
45
|
+
'DESIGN-IT-TWICE.md':'52b52e75655a27aea59c6966b410bac82448968ad46ef1ebb9f07c274e3ae010',
|
|
46
|
+
'SKILL.md':'2c20617f87ec8af6a434859f381b2f061a69b530444e74eb39e78bb016a6d1e2',
|
|
47
|
+
'agents/openai.yaml':'edebc9e4fcfe102114012575eaa9600b9b5fd08c311664f389c36e7bc717740f'}},
|
|
48
|
+
{name:'domain-modeling',dir:'skills/engineering/domain-modeling',use:'讨论术语、写决策记录时保持叫法一致',files:{
|
|
49
|
+
'ADR-FORMAT.md':'944c92aa790e8fbdc9199640b170979abb8a34ba8d0fe18c2a01a63bce140ca0',
|
|
50
|
+
'GLOSSARY-FORMAT.md':'21dcc40cdec8e151a829b98ab1517c1867bc444e3665134a98c6983411996801',
|
|
51
|
+
'SKILL.md':'7b925d7b1e341a2eeae33ad68a8a8c0ab889a38ddd22a7598e4c240e5a7556a3',
|
|
52
|
+
'agents/openai.yaml':'f6bf2aa996c6e6f53fdd0708e18a0d16a56aed8322cca59fedbe3c0d2c75f06b'}},
|
|
53
|
+
{name:'prototype',dir:'skills/engineering/prototype',use:'逻辑或界面想不清时,做个用完就扔的原型',files:{
|
|
54
|
+
'LOGIC.md':'f61c7d249e786a79ef289018901c348271e1798dd0b0bc5607b5c6f4d4a01ab9',
|
|
55
|
+
'SKILL.md':'714de632d116bb73f65cdb5a882db15b9369a6713b9a47c0fad827848f0bfbe3',
|
|
56
|
+
'UI.md':'723211e878acbc7b6ff09755263f3295cde724ba902ff0064da41eed51d45ad3',
|
|
57
|
+
'agents/openai.yaml':'5af65e43ab41a350436697b81e27b7f848d36782043b73c322bb2c9fa9cc55dc'}},
|
|
58
|
+
{name:'wayfinder',dir:'skills/engineering/wayfinder',use:'一个会话装不下的大活,拆成决策票逐张处理',files:{
|
|
59
|
+
'SKILL.md':'9be7b478c389605a24517d27752f278933588da97a1b5921b165f455edf4c5b7',
|
|
60
|
+
'agents/openai.yaml':'88bc81a11a6d52ac67aeaa76b8b619e387020d47c5133a4dd4927fd15c4ad073'}},
|
|
61
|
+
{name:'setup-matt-pocock-skills',dir:'skills/engineering/setup-matt-pocock-skills',use:'每个仓库跑一次,为 wayfinder 做准备',files:{
|
|
62
|
+
'SKILL.md':'f148858ffb7f63c03c06fca06e6fdb1d91a35c6b293244b8fdfacd5f4cc028c4',
|
|
63
|
+
'agents/openai.yaml':'9527de0110541c45712319025155aeab8dc7d77c6ed6e5e83271bab1851ab939',
|
|
64
|
+
'domain.md':'593a7042218689f1d24df89df14eaf0a20e19e0d0a7d479a01947ac78f0784b9',
|
|
65
|
+
'issue-tracker-github.md':'f0653fe106dd8ee7b33be27bd7fe3104b40555896cb45f61997aed20467020c3',
|
|
66
|
+
'issue-tracker-gitlab.md':'591a9e7057382aaccdfbed3f7ea3f2ad07e0cd29f012d18b82ee4e485fd81e24',
|
|
67
|
+
'issue-tracker-local.md':'7dcda20a2eb4bdc89b95d1143423c0691309921cadae3132e6424f371030506e',
|
|
68
|
+
'triage-labels.md':'ae512af838c78b8750471c42cd2b20fa32319553e61d84c9a23d171b40ce14aa'}},
|
|
69
|
+
{name:'handoff',dir:'skills/productivity/handoff',use:'CM 之外的长讨论,换新会话前写交接',files:{
|
|
70
|
+
'SKILL.md':'4cbb043950dad2ffd3662ff1a5a0b51ae676004b5cae10e3787e8ee7a4ee69d3',
|
|
71
|
+
'agents/openai.yaml':'5c479fd562c691851690e8b18c8501045bef0943c10743d636b2fae26add1d28'}},
|
|
72
|
+
{name:'writing-for-agents',dir:'skills/productivity/writing-for-agents',use:'写技能或改 CLAUDE.md / AGENTS.md 时自动起作用',files:{
|
|
73
|
+
'SKILL-MECHANICS.md':'c768e6307c7c10728c401c213f2c4ba71c542127eeb7ad2956aabd15a0fa0059',
|
|
74
|
+
'SKILL.md':'551adca942227b44192edba88acd4e8db911f0121ce58ad16944ccf6a896a74a',
|
|
75
|
+
'agents/openai.yaml':'eacb24b2a618cfb81dacb0416f4fdd75ddf3a8060f8ddb99aae1b1e301907e4b'}},
|
|
76
|
+
{name:'wait-what',dir:'skills/productivity/wait-what',use:'上一条回复没看懂,让模型换个说法重讲',files:{
|
|
77
|
+
'SKILL.md':'d961bb37defd975c539427edb8f450cdbccdcdd552e213c1ece46676a7970905',
|
|
78
|
+
'agents/openai.yaml':'b41faadf741d51e4ea184148b2d1854d93f947aaf754c7844f70a00f04194999'}},
|
|
79
|
+
{name:'retro',dir:'skills/engineering/retro',use:'cm-ai 收尾后复盘这一轮,看哪些错该交给脚本拦、哪些该写进指引',files:{
|
|
80
|
+
'SKILL.md':'33fbc28568e3146f20fd908b12998bc0ab30aa4f4c87288199a40793efa94696',
|
|
81
|
+
'agents/openai.yaml':'cb6fb9d7e6b4be5975f41f6def1dd00a1255bad5d9b02696b124c924a8b8745c'}},
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
const HINT_STATE='matt-skills-hint';
|
|
85
|
+
export const LOCAL_NAME='matt-skills.local.json';
|
|
86
|
+
export const AUTO_NAME='matt-skills.auto.json';
|
|
87
|
+
const MAX_READ=1024*1024;
|
|
88
|
+
const RUNTIMES=['claude','codex'];
|
|
89
|
+
const NOTE={other:'(已有同名技能但内容不同,安装时会跳过)',unreadable:'(无法读取,安装时会报错)'};
|
|
90
|
+
const sha256=buffer=>crypto.createHash('sha256').update(buffer).digest('hex');
|
|
91
|
+
const homeOf=env=>env.HOME||os.homedir();
|
|
92
|
+
export const cmHome=env=>path.resolve(env.CM_WORKFLOW_HOME||path.join(homeOf(env),'.cm-workflow'));
|
|
93
|
+
export const localPath=env=>path.join(cmHome(env),LOCAL_NAME);
|
|
94
|
+
export const autoPath=env=>path.join(cmHome(env),AUTO_NAME);
|
|
95
|
+
|
|
96
|
+
export const skillRoots=(env=process.env)=>[
|
|
97
|
+
{runtime:'claude',label:'Claude',root:path.join(path.resolve(env.CLAUDE_HOME||path.join(homeOf(env),'.claude')),'skills')},
|
|
98
|
+
{runtime:'codex',label:'Codex',root:path.join(homeOf(env),'.agents','skills')},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
// Files under a directory as relative paths; null when anything is not a plain
|
|
102
|
+
// file or directory (a link inside a skill is never the pinned author content).
|
|
103
|
+
// Finder's .DS_Store is ignored so browsing a skill folder does not demote it.
|
|
104
|
+
function listFiles(dir,prefix=''){
|
|
105
|
+
const out=[];
|
|
106
|
+
for(const entry of fs.readdirSync(dir,{withFileTypes:true})){
|
|
107
|
+
if(entry.name==='.DS_Store')continue;
|
|
108
|
+
const relative=prefix?`${prefix}/${entry.name}`:entry.name;
|
|
109
|
+
if(entry.isDirectory()){
|
|
110
|
+
const nested=listFiles(path.join(dir,entry.name),relative);
|
|
111
|
+
if(!nested)return null;
|
|
112
|
+
out.push(...nested);
|
|
113
|
+
}else if(entry.isFile())out.push(relative);
|
|
114
|
+
else return null;
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// "author": exactly the pinned files plus the upstream LICENSE, byte for byte.
|
|
120
|
+
// "other": a same-named skill with any other content, never counted as installed.
|
|
121
|
+
// "missing": nothing at that name. "unreadable": the state cannot be determined
|
|
122
|
+
// (root is not a directory, no permission), which callers report as a failure.
|
|
123
|
+
// The skill directory itself may be a link (e.g. a release symlink); its contents may not.
|
|
124
|
+
export function skillState(root,skill,license=UPSTREAM.license.sha256){
|
|
125
|
+
const dir=path.join(root,skill.name);
|
|
126
|
+
try{fs.lstatSync(dir);}catch(error){return error.code==='ENOENT'?'missing':'unreadable';}
|
|
127
|
+
const expected={...skill.files,LICENSE:license};
|
|
128
|
+
try{
|
|
129
|
+
if(!fs.statSync(dir).isDirectory())return 'other';
|
|
130
|
+
const actual=listFiles(dir);
|
|
131
|
+
if(!actual||actual.sort().join('\n')!==Object.keys(expected).sort().join('\n'))return 'other';
|
|
132
|
+
for(const [relative,sum] of Object.entries(expected)){
|
|
133
|
+
if(sha256(fs.readFileSync(path.join(dir,relative)))!==sum)return 'other';
|
|
134
|
+
}
|
|
135
|
+
}catch(error){
|
|
136
|
+
return ['EACCES','EPERM','EIO'].includes(error.code)?'unreadable':'other';
|
|
137
|
+
}
|
|
138
|
+
return 'author';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Why a skills root cannot be used, or null. A missing root is fine (install creates it).
|
|
142
|
+
export function rootProblem(root){
|
|
143
|
+
try{
|
|
144
|
+
if(!fs.statSync(root).isDirectory())return '不是目录';
|
|
145
|
+
fs.accessSync(root,fs.constants.R_OK|fs.constants.X_OK);
|
|
146
|
+
return null;
|
|
147
|
+
}catch(error){
|
|
148
|
+
if(error.code==='ENOENT'){
|
|
149
|
+
try{fs.lstatSync(root);return '是失效的链接';}catch{/* 真的不存在 */}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
return `无法访问(${error.code})`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function status({env=process.env,skills=SKILLS,upstream=UPSTREAM}={}){
|
|
157
|
+
return skillRoots(env).map(({runtime,label,root})=>{
|
|
158
|
+
const problem=rootProblem(root);
|
|
159
|
+
return {runtime,label,root,problem,
|
|
160
|
+
skills:skills.map(skill=>({name:skill.name,use:skill.use,
|
|
161
|
+
state:problem?'unreadable':skillState(root,skill,upstream.license.sha256)}))};
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const tilde=(file,env)=>{
|
|
166
|
+
const home=homeOf(env);
|
|
167
|
+
return file===home||file.startsWith(home+path.sep)?'~'+file.slice(home.length):file;
|
|
168
|
+
};
|
|
169
|
+
// Printed for the user to copy: a plain ~ path when it is shell-safe, else single-quoted.
|
|
170
|
+
export function installCommand(env=process.env,script=fileURLToPath(import.meta.url)){
|
|
171
|
+
const short=tilde(script,env);
|
|
172
|
+
const shown=/^[\w~./-]+$/.test(short)?short:`'${script.replace(/'/g,`'\\''`)}'`;
|
|
173
|
+
return `node ${shown} install`;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function hintStatePath(env){
|
|
177
|
+
return path.join(path.resolve(env.CM_WORKFLOW_HOME||path.join(homeOf(env),'.cm-workflow')),HINT_STATE);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// The hint state is a disposable cache. It is read only when it is a plain,
|
|
181
|
+
// singly linked file, and replaced by renaming a freshly created file over the
|
|
182
|
+
// entry, so a link planted at that path is replaced, never written through.
|
|
183
|
+
function readHintState(file){
|
|
184
|
+
try{
|
|
185
|
+
const st=fs.lstatSync(file);
|
|
186
|
+
if(!st.isFile()||st.nlink!==1)return null;
|
|
187
|
+
return fs.readFileSync(file,'utf8');
|
|
188
|
+
}catch{return null;}
|
|
189
|
+
}
|
|
190
|
+
function writeHintState(file,text){
|
|
191
|
+
const temporary=`${file}.${process.pid}.${crypto.randomBytes(6).toString('hex')}.tmp`;
|
|
192
|
+
try{
|
|
193
|
+
fs.mkdirSync(path.dirname(file),{recursive:true});
|
|
194
|
+
fs.writeFileSync(temporary,text,{flag:'wx',mode:0o600});
|
|
195
|
+
fs.renameSync(temporary,file);
|
|
196
|
+
}catch{/* 记不住只是下次再列全 */}
|
|
197
|
+
finally{try{fs.unlinkSync(temporary);}catch{/* 已改名或未创建 */}}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Installer hint: the full list the first time a given set is missing, one line after.
|
|
201
|
+
export function hint({env=process.env,skills=SKILLS,upstream=UPSTREAM,command=installCommand(env)}={}){
|
|
202
|
+
const report=status({env,skills,upstream});
|
|
203
|
+
const missing=report.flatMap(r=>r.skills.filter(s=>s.state!=='author').map(s=>`${r.runtime}:${s.name}:${s.state}`));
|
|
204
|
+
const fingerprint=missing.join('\n');
|
|
205
|
+
const stateFile=hintStatePath(env);
|
|
206
|
+
const seen=readHintState(stateFile);
|
|
207
|
+
if(!missing.length){
|
|
208
|
+
// Recorded so a gap that reappears later is listed in full again.
|
|
209
|
+
if(seen!=='')writeHintState(stateFile,'');
|
|
210
|
+
return `✓ 推荐搭配的 ${skills.length} 个 Matt Pocock 技能已齐(Claude 与 Codex)。\n`;
|
|
211
|
+
}
|
|
212
|
+
const names=[...new Set(report.flatMap(r=>r.skills.filter(s=>s.state!=='author').map(s=>s.name)))];
|
|
213
|
+
let text;
|
|
214
|
+
if(seen===fingerprint){
|
|
215
|
+
text=`ℹ 推荐的 Matt Pocock 技能还缺 ${names.length} 个(可选,CM 不依赖)。安装:${command}\n`;
|
|
216
|
+
}else{
|
|
217
|
+
const lines=['ℹ 推荐搭配 Matt Pocock 的技能(可选,CM 不依赖)。'];
|
|
218
|
+
const width=Math.max(...names.map(n=>n.length));
|
|
219
|
+
const absentOf=r=>r.skills.filter(s=>s.state!=='author');
|
|
220
|
+
const key=r=>absentOf(r).map(s=>`${s.name}:${s.state}`).join(',');
|
|
221
|
+
// Both directories missing the same set is the common case: list it once.
|
|
222
|
+
const groups=report.every(r=>key(r)===key(report[0]))
|
|
223
|
+
?[{title:report.map(r=>`${r.label}(${tilde(r.root,env)})`).join('和')+'都',absent:absentOf(report[0])}]
|
|
224
|
+
:report.filter(r=>absentOf(r).length).map(r=>({title:`${r.label}(${tilde(r.root,env)})`,absent:absentOf(r)}));
|
|
225
|
+
for(const g of groups){
|
|
226
|
+
lines.push(` ${g.title}缺 ${g.absent.length} 个:`);
|
|
227
|
+
for(const s of g.absent)lines.push(` ${s.name.padEnd(width)} ${s.use}${NOTE[s.state]||''}`);
|
|
228
|
+
}
|
|
229
|
+
for(const r of report)if(r.problem)lines.push(` ⚠ ${r.label} 技能目录 ${tilde(r.root,env)} ${r.problem},安装前请先处理。`);
|
|
230
|
+
lines.push(` 安装(只拉固定提交 ${UPSTREAM.commit.slice(0,7)},逐个文件核对,不覆盖已有技能):`);
|
|
231
|
+
lines.push(` ${command}`);
|
|
232
|
+
text=lines.join('\n')+'\n';
|
|
233
|
+
}
|
|
234
|
+
writeHintState(stateFile,fingerprint);
|
|
235
|
+
return text;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const STATE_TEXT={missing:'missing',other:'same name, different content (not the pinned author version)',unreadable:'cannot be read'};
|
|
239
|
+
export function statusText({env=process.env,skills=SKILLS,upstream=UPSTREAM,command=installCommand(env)}={}){
|
|
240
|
+
const lines=[];
|
|
241
|
+
for(const r of status({env,skills,upstream})){
|
|
242
|
+
if(r.problem)lines.push(`recommended skills [${r.runtime}] WARN skills directory ${tilde(r.root,env)}: ${r.problem}`);
|
|
243
|
+
const count=r.skills.filter(s=>s.state==='author').length;
|
|
244
|
+
lines.push(`recommended skills [${r.runtime}] ${count}/${r.skills.length} author versions in ${tilde(r.root,env)}`);
|
|
245
|
+
for(const s of r.skills)if(s.state!=='author')lines.push(`recommended skills [${r.runtime}] ${s.name}: ${STATE_TEXT[s.state]}`);
|
|
246
|
+
}
|
|
247
|
+
if(lines.length>2)lines.push(`recommended skills install (optional): ${command}`);
|
|
248
|
+
const gate=installGate(env,false);
|
|
249
|
+
const settled=settledSkills(env);
|
|
250
|
+
lines.push(`recommended skills auto-install at install time: ${gate?.optOut?`skipped this run (${gate.optOut})`:gate?.off?`off (${gate.off})`
|
|
251
|
+
:gate?.pause?`paused (${gate.pause})`:settled.state==='invalid'?`paused (${autoPath(env)} ${settled.reason})`:'on'}`
|
|
252
|
+
+`; seen installed: ${RUNTIMES.map(runtime=>`${runtime} ${(settled.installed[runtime]||[]).length}`).join(', ')}`);
|
|
253
|
+
return lines.join('\n')+'\n';
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
class VerifyError extends Error{}
|
|
257
|
+
|
|
258
|
+
// Git sees none of the user's configuration or GIT_* control variables: no system
|
|
259
|
+
// or global config, no config injected through the environment, no hooks, no
|
|
260
|
+
// credential helper or askpass, and only https/file transports. Proxy and CA
|
|
261
|
+
// variables pass through so networks that need a proxy still work.
|
|
262
|
+
const PASS_ENV=['PATH','LANG','LC_ALL','SYSTEMROOT','TMPDIR','http_proxy','https_proxy','HTTP_PROXY','HTTPS_PROXY',
|
|
263
|
+
'all_proxy','ALL_PROXY','no_proxy','NO_PROXY','SSL_CERT_FILE','SSL_CERT_DIR'];
|
|
264
|
+
export function gitEnv(base=process.env,home){
|
|
265
|
+
const env={};
|
|
266
|
+
for(const key of PASS_ENV)if(base[key]!==undefined)env[key]=base[key];
|
|
267
|
+
return {...env,HOME:home,XDG_CONFIG_HOME:home,GIT_CONFIG_NOSYSTEM:'1',GIT_CONFIG_GLOBAL:os.devNull,
|
|
268
|
+
GIT_TERMINAL_PROMPT:'0',GIT_ASKPASS:'',SSH_ASKPASS:'',GCM_INTERACTIVE:'never'};
|
|
269
|
+
}
|
|
270
|
+
const GIT_SAFETY=['-c','core.hooksPath='+os.devNull,'-c','credential.helper=','-c','core.fsmonitor=false',
|
|
271
|
+
'-c','protocol.allow=never','-c','protocol.https.allow=always','-c','protocol.file.allow=always'];
|
|
272
|
+
// Every git call is bounded so an optional download can never hold an install for long.
|
|
273
|
+
export const GIT_TIMEOUT_MS=120000;
|
|
274
|
+
function git(args,home){
|
|
275
|
+
return execFileSync('git',[...GIT_SAFETY,...args],{stdio:['ignore','pipe','pipe'],maxBuffer:64*1024*1024,
|
|
276
|
+
cwd:home,env:gitEnv(process.env,home),timeout:GIT_TIMEOUT_MS,killSignal:'SIGKILL'});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Fetches the pinned commit into a private bare repository and returns every
|
|
280
|
+
// pinned file's bytes. Throws VerifyError before anything is written elsewhere.
|
|
281
|
+
export function fetchVerified({source,upstream,skills,workdir}){
|
|
282
|
+
const repo=path.join(workdir,'repo.git');
|
|
283
|
+
const run=args=>git(args,workdir);
|
|
284
|
+
run(['init','-q','--bare','--template=',repo]);
|
|
285
|
+
// Only the pinned commit, one level deep; a source that cannot serve it by id is refused.
|
|
286
|
+
try{run(['-C',repo,'fetch','-q','--no-tags','--no-recurse-submodules','--depth','1',source,upstream.commit]);}
|
|
287
|
+
catch(error){
|
|
288
|
+
const reason=error.code==='ETIMEDOUT'?`超过 ${GIT_TIMEOUT_MS/1000} 秒未完成,已中止`
|
|
289
|
+
:error.signal?`进程被强制终止(${error.signal})`
|
|
290
|
+
:String(error.stderr||error.message).trim().split('\n').pop();
|
|
291
|
+
throw new VerifyError(`无法从 ${source} 拉取固定提交 ${upstream.commit}:${reason}`);
|
|
292
|
+
}
|
|
293
|
+
let commit;
|
|
294
|
+
try{commit=run(['-C',repo,'rev-parse','--verify','-q',`${upstream.commit}^{commit}`]).toString().trim();}
|
|
295
|
+
catch{throw new VerifyError(`来源里找不到固定提交 ${upstream.commit}`);}
|
|
296
|
+
if(commit!==upstream.commit)throw new VerifyError(`提交号不一致:期望 ${upstream.commit},得到 ${commit}`);
|
|
297
|
+
|
|
298
|
+
const blob=(file,expected)=>{
|
|
299
|
+
let content;
|
|
300
|
+
try{content=run(['-C',repo,'cat-file','blob',`${commit}:${file}`]);}
|
|
301
|
+
catch{throw new VerifyError(`缺少文件 ${file}`);}
|
|
302
|
+
if(sha256(content)!==expected)throw new VerifyError(`${file} 的 SHA-256 与内置清单不一致`);
|
|
303
|
+
return content;
|
|
304
|
+
};
|
|
305
|
+
const license=blob(upstream.license.path,upstream.license.sha256);
|
|
306
|
+
const result=new Map();
|
|
307
|
+
for(const skill of skills){
|
|
308
|
+
let listing;
|
|
309
|
+
try{listing=run(['-C',repo,'ls-tree','-r','-z','--full-tree',commit,'--',`${skill.dir}/`]).toString();}
|
|
310
|
+
catch{throw new VerifyError(`无法列出 ${skill.dir}`);}
|
|
311
|
+
const entries=listing.split('\0').filter(Boolean).map(line=>{
|
|
312
|
+
const tab=line.indexOf('\t');
|
|
313
|
+
const [mode,type]=line.slice(0,tab).split(' ');
|
|
314
|
+
const file=line.slice(tab+1);
|
|
315
|
+
return {mode,type,relative:file.slice(skill.dir.length+1)};
|
|
316
|
+
});
|
|
317
|
+
for(const e of entries){
|
|
318
|
+
if(e.type!=='blob'||(e.mode!=='100644'&&e.mode!=='100755'))throw new VerifyError(`${skill.dir}/${e.relative} 不是普通文件(${e.mode})`);
|
|
319
|
+
}
|
|
320
|
+
const actual=entries.map(e=>e.relative).sort();
|
|
321
|
+
const expected=Object.keys(skill.files).sort();
|
|
322
|
+
if(actual.join('\n')!==expected.join('\n')){
|
|
323
|
+
const extra=actual.filter(f=>!expected.includes(f));
|
|
324
|
+
const lost=expected.filter(f=>!actual.includes(f));
|
|
325
|
+
throw new VerifyError(`${skill.dir} 的文件列表与清单不一致${extra.length?`,多出 ${extra.join(', ')}`:''}${lost.length?`,缺少 ${lost.join(', ')}`:''}`);
|
|
326
|
+
}
|
|
327
|
+
const files=new Map();
|
|
328
|
+
for(const relative of expected)files.set(relative,blob(`${skill.dir}/${relative}`,skill.files[relative]));
|
|
329
|
+
files.set('LICENSE',license);
|
|
330
|
+
result.set(skill.name,files);
|
|
331
|
+
}
|
|
332
|
+
return result;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Claims the name with an exclusive mkdir, which fails when anything (directory,
|
|
336
|
+
// file, link) already sits there, so an existing skill can never be replaced, even
|
|
337
|
+
// one created a moment ago by another process. Files are staged next to it and
|
|
338
|
+
// moved in; on any failure only the directory this call created is removed.
|
|
339
|
+
export function placeSkill(root,name,files){
|
|
340
|
+
const target=path.join(root,name);
|
|
341
|
+
const stage=fs.mkdtempSync(path.join(root,`.cm-matt-skills.${name}.`));
|
|
342
|
+
let claimed=false;
|
|
343
|
+
try{
|
|
344
|
+
for(const [relative,content] of files){
|
|
345
|
+
const file=path.join(stage,relative);
|
|
346
|
+
fs.mkdirSync(path.dirname(file),{recursive:true});
|
|
347
|
+
fs.writeFileSync(file,content,{flag:'wx',mode:0o644});
|
|
348
|
+
}
|
|
349
|
+
try{fs.mkdirSync(target);}catch(error){if(error.code==='EEXIST')return 'exists';throw error;}
|
|
350
|
+
claimed=true;
|
|
351
|
+
for(const entry of fs.readdirSync(stage))fs.renameSync(path.join(stage,entry),path.join(target,entry));
|
|
352
|
+
claimed=false;
|
|
353
|
+
return 'installed';
|
|
354
|
+
}finally{
|
|
355
|
+
if(claimed)fs.rmSync(target,{recursive:true,force:true});
|
|
356
|
+
fs.rmSync(stage,{recursive:true,force:true});
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// `settled` maps a runtime to skill names CM once saw installed there and are now gone:
|
|
361
|
+
// the user removed them, so they are left out and reported, never put back.
|
|
362
|
+
export function install({env=process.env,source=UPSTREAM.repo,upstream=UPSTREAM,skills=SKILLS,tmpRoot=os.tmpdir(),write=text=>process.stdout.write(text),settled={}}={}){
|
|
363
|
+
try{git(['--version'],tmpRoot);}
|
|
364
|
+
catch{write('✗ 未找到 git,无法安装;未写入任何文件。\n');return 1;}
|
|
365
|
+
const plan=status({env,skills,upstream}).map(r=>({...r,
|
|
366
|
+
todo:r.problem?[]:skills.filter(s=>r.skills.find(x=>x.name===s.name).state==='missing'&&!(settled[r.runtime]||[]).includes(s.name)),
|
|
367
|
+
removed:r.problem?[]:r.skills.filter(s=>s.state==='missing'&&(settled[r.runtime]||[]).includes(s.name)),
|
|
368
|
+
skipped:r.skills.filter(s=>s.state==='author'||s.state==='other'),
|
|
369
|
+
unreadable:r.problem?[]:r.skills.filter(s=>s.state==='unreadable')}));
|
|
370
|
+
let failed=0;
|
|
371
|
+
for(const r of plan){
|
|
372
|
+
if(r.problem){write(`✗ ${r.label} 技能目录 ${tilde(r.root,env)} ${r.problem},这一侧不安装。\n`);failed++;}
|
|
373
|
+
for(const s of r.unreadable){write(`✗ ${r.label} ${s.name} 无法读取,未判断也未安装。\n`);failed++;}
|
|
374
|
+
}
|
|
375
|
+
if(plan.every(r=>!r.todo.length)){
|
|
376
|
+
if(!failed&&plan.every(r=>!r.removed.length))write(`✓ 无需安装:两个目录都已有这 ${skills.length} 个同名技能。\n`);
|
|
377
|
+
for(const r of plan)for(const s of r.skipped)if(s.state==='other')write(` 跳过 ${r.label} ${s.name}:已有同名技能但内容不同,未覆盖\n`);
|
|
378
|
+
for(const r of plan)if(r.removed.length)write(` ${r.label} 的 ${r.removed.map(s=>s.name).join('、')} 之前装过后被你删掉,不再自动装回\n`);
|
|
379
|
+
return failed?1:0;
|
|
380
|
+
}
|
|
381
|
+
// git runs inside a private temporary directory, so a local path is fixed to the caller's cwd first.
|
|
382
|
+
if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(source))source=path.resolve(source);
|
|
383
|
+
write(`拉取 ${source} 的固定提交 ${upstream.commit.slice(0,7)} 并逐个文件核对……\n`);
|
|
384
|
+
const workdir=fs.mkdtempSync(path.join(tmpRoot,'cm-matt-skills-'));
|
|
385
|
+
let verified;
|
|
386
|
+
try{verified=fetchVerified({source,upstream,skills,workdir});}
|
|
387
|
+
catch(error){
|
|
388
|
+
fs.rmSync(workdir,{recursive:true,force:true});
|
|
389
|
+
if(!(error instanceof VerifyError))throw error;
|
|
390
|
+
write(`✗ 核对失败,整批放弃,未写入任何文件:${error.message}\n`);
|
|
391
|
+
return 1;
|
|
392
|
+
}
|
|
393
|
+
fs.rmSync(workdir,{recursive:true,force:true});
|
|
394
|
+
write(`✓ ${skills.length} 个技能共 ${skills.reduce((n,s)=>n+Object.keys(s.files).length,0)} 个文件和 LICENSE 均与内置清单一致。\n`);
|
|
395
|
+
|
|
396
|
+
for(const r of plan){
|
|
397
|
+
if(r.problem)continue;
|
|
398
|
+
const installed=[];
|
|
399
|
+
const skipped=r.skipped.map(s=>`${s.name}(${s.state==='author'?'已是作者版':'已有同名技能但内容不同'})`);
|
|
400
|
+
if(r.todo.length){
|
|
401
|
+
try{fs.mkdirSync(r.root,{recursive:true});}
|
|
402
|
+
catch(error){write(`✗ ${r.label} 目录 ${tilde(r.root,env)} 无法创建:${error.message}\n`);failed++;continue;}
|
|
403
|
+
}
|
|
404
|
+
for(const skill of r.todo){
|
|
405
|
+
try{
|
|
406
|
+
if(placeSkill(r.root,skill.name,verified.get(skill.name))==='installed')installed.push(skill.name);
|
|
407
|
+
else skipped.push(`${skill.name}(安装时已出现同名目录)`);
|
|
408
|
+
}catch(error){write(`✗ ${r.label} ${skill.name} 写入失败:${error.message}\n`);failed++;}
|
|
409
|
+
}
|
|
410
|
+
write(`${r.label}(${tilde(r.root,env)}):新装 ${installed.length} 个${installed.length?`:${installed.join('、')}`:''}\n`);
|
|
411
|
+
if(skipped.length)write(` 跳过 ${skipped.length} 个,未覆盖:${skipped.join('、')}\n`);
|
|
412
|
+
if(r.removed.length)write(` ${r.removed.map(s=>s.name).join('、')} 之前装过后被你删掉,不再自动装回\n`);
|
|
413
|
+
}
|
|
414
|
+
if(failed){write(`⚠ 有 ${failed} 处失败,见上;已装好的技能保留。\n`);return 1;}
|
|
415
|
+
write('装完的技能要开新会话才能看到。\n');
|
|
416
|
+
return 0;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// ---- Install-time default ("auto") ----
|
|
420
|
+
// Only a regular file of bounded size is read; every config is strict JSON (an empty file
|
|
421
|
+
// is a problem, never rewritten).
|
|
422
|
+
function readJson(file){
|
|
423
|
+
let text;
|
|
424
|
+
try{
|
|
425
|
+
const st=fs.lstatSync(file);
|
|
426
|
+
if(!st.isFile())return {error:'not-file'};
|
|
427
|
+
if(st.size>MAX_READ)return {error:'too-large'};
|
|
428
|
+
text=fs.readFileSync(file,'utf8');
|
|
429
|
+
}catch(error){if(error.code==='ENOENT')return {missing:true};return {error:error.code||'read'};}
|
|
430
|
+
if(!text.trim())return {error:'empty'};
|
|
431
|
+
try{return {value:JSON.parse(text),text};}catch{return {error:'parse'};}
|
|
432
|
+
}
|
|
433
|
+
const plainObject=value=>Boolean(value)&&typeof value==='object'&&!Array.isArray(value);
|
|
434
|
+
class Drift extends Error{}
|
|
435
|
+
// Replace by renaming a fresh file over the path; `before` runs right before the rename.
|
|
436
|
+
function writeAtomic(file,text,{before}={}){
|
|
437
|
+
fs.mkdirSync(path.dirname(file),{recursive:true});
|
|
438
|
+
const temporary=`${file}.${process.pid}.${crypto.randomBytes(6).toString('hex')}.tmp`;
|
|
439
|
+
try{
|
|
440
|
+
fs.writeFileSync(temporary,text,{flag:'wx',mode:0o600});
|
|
441
|
+
before?.();
|
|
442
|
+
fs.renameSync(temporary,file);
|
|
443
|
+
}finally{try{fs.unlinkSync(temporary);}catch{/* 已改名或未创建 */}}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// The user's local file: {"install": false} turns the install-time default off for good.
|
|
447
|
+
export function localShapeError(value){
|
|
448
|
+
if(!plainObject(value))return '应为对象';
|
|
449
|
+
if(value.install!==undefined&&typeof value.install!=='boolean')return 'install 只能是 true 或 false';
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
export function readLocal(env){
|
|
453
|
+
const local=readJson(localPath(env));
|
|
454
|
+
if(local.missing)return {settings:{},error:null,missing:true};
|
|
455
|
+
if(local.error)return {settings:{},error:`读取失败(${local.error})`};
|
|
456
|
+
const shape=localShapeError(local.value);
|
|
457
|
+
return shape?{settings:{},error:`格式异常(${shape})`}:{settings:local.value,error:null};
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Settled skills: ~/.cm-workflow/matt-skills.auto.json records, per runtime, every skill
|
|
461
|
+
// the install-time default has seen installed there (put in by it, or found already
|
|
462
|
+
// there). A settled skill that is missing later was removed by the user, and no install
|
|
463
|
+
// puts it back. --no-matt-skills and CM_MATT_SKILLS_INSTALL=off cover one run only and
|
|
464
|
+
// settle nothing. A record CM cannot read or whose shape is unknown is kept as is, and no
|
|
465
|
+
// install adds anything while it is there.
|
|
466
|
+
function readRecord(env){
|
|
467
|
+
const read=readJson(autoPath(env));
|
|
468
|
+
if(read.missing)return {state:'missing',read,installed:{}};
|
|
469
|
+
const value=read.value;
|
|
470
|
+
const names=list=>Array.isArray(list)&&list.every(name=>typeof name==='string'&&/^[a-z0-9][a-z0-9-]*$/.test(name));
|
|
471
|
+
if(read.error||!plainObject(value)||value.version!==1||!plainObject(value.installed)
|
|
472
|
+
||!Object.keys(value.installed).every(runtime=>RUNTIMES.includes(runtime)&&names(value.installed[runtime])))
|
|
473
|
+
return {state:'invalid',read,reason:read.error??'格式异常',installed:{}};
|
|
474
|
+
return {state:'ok',read,installed:Object.fromEntries(RUNTIMES.map(runtime=>[runtime,[...new Set(value.installed[runtime]||[])]]))};
|
|
475
|
+
}
|
|
476
|
+
export function settledSkills(env){
|
|
477
|
+
const record=readRecord(env);
|
|
478
|
+
return {state:record.state,reason:record.reason,installed:record.installed};
|
|
479
|
+
}
|
|
480
|
+
const recordWarning=(env,reason)=>`⚠ 作者技能:${autoPath(env)} 异常(${reason}),已保留原样;修好或删掉它之前,安装不会自动装作者技能。\n`;
|
|
481
|
+
// Adds the skills now present to the record, under the shared config lock. Never throws.
|
|
482
|
+
async function noteRecord(env,found,{lockWaitMs}={}){
|
|
483
|
+
const file=autoPath(env);
|
|
484
|
+
try{
|
|
485
|
+
const {withConfigLock,LockBusy}=await import('./cm-config-lock.mjs');
|
|
486
|
+
try{
|
|
487
|
+
return withConfigLock(env,file,()=>{
|
|
488
|
+
const record=readRecord(env);
|
|
489
|
+
if(record.state==='invalid')return {warning:recordWarning(env,record.reason)};
|
|
490
|
+
const next=Object.fromEntries(RUNTIMES.map(runtime=>[runtime,
|
|
491
|
+
[...new Set([...(record.installed[runtime]||[]),...(found[runtime]||[])])].sort()]));
|
|
492
|
+
// Nothing new to note: an existing record stays as it is, and no record is created for nothing.
|
|
493
|
+
if(RUNTIMES.every(runtime=>next[runtime].length===(record.installed[runtime]||[]).length))return {installed:next};
|
|
494
|
+
writeAtomic(file,JSON.stringify({version:1,installed:next})+'\n',{before:()=>{
|
|
495
|
+
const now=readJson(file);
|
|
496
|
+
if(record.read.missing?!now.missing:now.text!==record.read.text)throw new Drift();
|
|
497
|
+
}});
|
|
498
|
+
return {installed:next};
|
|
499
|
+
},lockWaitMs===undefined?{}:{waitMs:lockWaitMs});
|
|
500
|
+
}catch(error){
|
|
501
|
+
const why=error instanceof Drift?'刚被其他程序改动':error instanceof LockBusy?'另一个 CM 程序正在改它':error.message;
|
|
502
|
+
return {warning:`⚠ 作者技能:未能记下已装的技能(${file}:${why});不影响本次安装,下次安装再记。\n`};
|
|
503
|
+
}
|
|
504
|
+
}catch(error){return {warning:`⚠ 作者技能:未能记下已装的技能(${file}:${error.message})。\n`};}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// Why an install must not add skills now, or null. `optOut` is the user skipping this run;
|
|
508
|
+
// `off` is {"install": false}; `pause` is a local file CM cannot use, so it does nothing.
|
|
509
|
+
export function installGate(env,skip=false){
|
|
510
|
+
if(skip)return {optOut:'安装参数 --no-matt-skills'};
|
|
511
|
+
if(env.CM_MATT_SKILLS_INSTALL==='off')return {optOut:'环境变量 CM_MATT_SKILLS_INSTALL=off'};
|
|
512
|
+
const local=readLocal(env);
|
|
513
|
+
if(local.error)return {pause:`${localPath(env)} ${local.error}`};
|
|
514
|
+
if(local.settings.install===false)return {off:`${localPath(env)} 里 install 为 false`};
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
const OFF_NOTE=env=>`不想要:重装加 --no-matt-skills 只管这一次;永久关闭在 ${localPath(env)} 写 {"install": false};你删掉的技能不会再自动装回。`;
|
|
518
|
+
|
|
519
|
+
// Run by the installers. Installs the missing skills into both directories unless the user
|
|
520
|
+
// said no, records what is there, and never throws; 1 means a warning (CM itself is
|
|
521
|
+
// installed either way).
|
|
522
|
+
export async function autoInstall({env=process.env,source=UPSTREAM.repo,upstream=UPSTREAM,skills=SKILLS,tmpRoot=os.tmpdir(),
|
|
523
|
+
write=text=>process.stdout.write(text),skip=false,command=installCommand(env),lockWaitMs}={}){
|
|
524
|
+
try{
|
|
525
|
+
const gate=installGate(env,skip);
|
|
526
|
+
if(gate?.optOut){
|
|
527
|
+
write(`作者技能:按${gate.optOut},这次不自动安装(只管这一次,下次不带它安装照常装)。\n`);
|
|
528
|
+
write(hint({env,skills,upstream,command}));
|
|
529
|
+
return 0;
|
|
530
|
+
}
|
|
531
|
+
if(gate?.off){write(`作者技能:${gate.off},不自动安装;要装运行 ${command}\n`);return 0;}
|
|
532
|
+
if(gate){write(`⚠ 作者技能:${gate.pause},这次不自动安装;改好后重装或运行 ${command}\n`);return 1;}
|
|
533
|
+
const settled=settledSkills(env);
|
|
534
|
+
if(settled.state==='invalid'){write(recordWarning(env,settled.reason));write(hint({env,skills,upstream,command}));return 1;}
|
|
535
|
+
// Seen = a skill of that name is there, the pinned author version or not ("other" is kept
|
|
536
|
+
// as it is and must enjoy the same removal protection). Unreadable is never "seen".
|
|
537
|
+
const present=()=>Object.fromEntries(status({env,skills,upstream}).map(r=>[r.runtime,r.skills.filter(s=>s.state==='author'||s.state==='other').map(s=>s.name)]));
|
|
538
|
+
const code=install({env,source,upstream,skills,tmpRoot,write,settled:settled.installed});
|
|
539
|
+
if(code!==0)write(` 作者技能不影响 CM 使用;稍后可手动运行 ${command}\n`);
|
|
540
|
+
const noted=await noteRecord(env,present(),{lockWaitMs});
|
|
541
|
+
if(noted.warning)write(noted.warning);
|
|
542
|
+
write(` ${OFF_NOTE(env)}\n`);
|
|
543
|
+
return Math.max(code,noted.warning?1:0);
|
|
544
|
+
}catch(error){
|
|
545
|
+
write(`⚠ 作者技能未处理:${error.message}\n`);
|
|
546
|
+
return 1;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const USAGE='用法: cm-matt-skills.mjs status | hint | install [--source <git 地址或本地路径>] | auto [--no-matt-skills] [--source <git 地址或本地路径>]\n';
|
|
551
|
+
|
|
552
|
+
export function main(argv=process.argv.slice(2),{env=process.env,write=text=>process.stdout.write(text),error=text=>process.stderr.write(text)}={}){
|
|
553
|
+
const [command,...rest]=argv;
|
|
554
|
+
if(command==='status'&&!rest.length){write(statusText({env}));return 0;}
|
|
555
|
+
if(command==='hint'&&!rest.length){write(hint({env}));return 0;}
|
|
556
|
+
if(command==='install'){
|
|
557
|
+
let source=UPSTREAM.repo;
|
|
558
|
+
if(rest.length===2&&rest[0]==='--source'&&rest[1])source=rest[1];
|
|
559
|
+
else if(rest.length){error(USAGE);return 2;}
|
|
560
|
+
return install({env,source,write});
|
|
561
|
+
}
|
|
562
|
+
if(command==='auto'){
|
|
563
|
+
let source=UPSTREAM.repo,skip=false;
|
|
564
|
+
const args=[...rest];
|
|
565
|
+
if(args[0]==='--no-matt-skills'){skip=true;args.shift();}
|
|
566
|
+
if(args.length===2&&args[0]==='--source'&&args[1])source=args[1];
|
|
567
|
+
else if(args.length){error(USAGE);return 2;}
|
|
568
|
+
return autoInstall({env,source,write,skip});
|
|
569
|
+
}
|
|
570
|
+
error(USAGE);
|
|
571
|
+
return 2;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
if(process.argv[1]&&fs.realpathSync(process.argv[1])===fs.realpathSync(fileURLToPath(import.meta.url))){
|
|
575
|
+
Promise.resolve(main()).then(code=>{process.exitCode=code;});
|
|
576
|
+
}
|