peaks-loop 4.1.4 → 4.1.6
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/.claude-plugin/marketplace.json +7 -2
- package/CHANGELOG.md +148 -0
- package/README-en.md +47 -183
- package/README.md +24 -188
- package/dist/cli/cli-helpers.d.ts +20 -0
- package/dist/cli/cli-helpers.js +34 -0
- package/dist/cli/commands/_register.js +2 -0
- package/dist/cli/commands/best-practice-scan-command.d.ts +11 -6
- package/dist/cli/commands/best-practice-scan-command.js +35 -20
- package/dist/cli/commands/best-practice-scan-helpers.d.ts +47 -0
- package/dist/cli/commands/best-practice-scan-helpers.js +88 -5
- package/dist/cli/commands/best-practice-scan-lookup-results.d.ts +13 -0
- package/dist/cli/commands/best-practice-scan-lookup-results.js +237 -0
- package/dist/cli/commands/code-commands.d.ts +6 -4
- package/dist/cli/commands/code-commands.js +6 -4
- package/dist/cli/commands/code-gate-command.d.ts +5 -5
- package/dist/cli/commands/code-gate-command.js +49 -9
- package/dist/cli/commands/code-mode-gate-plan-command.d.ts +1 -1
- package/dist/cli/commands/code-mode-gate-plan-command.js +2 -2
- package/dist/cli/commands/core/memory-extract-command.js +10 -5
- package/dist/cli/commands/dispatch-cli-invocation-check.d.ts +108 -0
- package/dist/cli/commands/dispatch-cli-invocation-check.js +87 -0
- package/dist/cli/commands/dispatch-cli-invocation-scan.d.ts +66 -0
- package/dist/cli/commands/dispatch-cli-invocation-scan.js +162 -0
- package/dist/cli/commands/dispatch-command-spec.js +1 -1
- package/dist/cli/commands/dispatch-commands.js +12 -5
- package/dist/cli/commands/dispatch-isolation-lease.d.ts +1 -1
- package/dist/cli/commands/dispatch-isolation-lease.js +6 -53
- package/dist/cli/commands/dispatch-preflight.js +46 -0
- package/dist/cli/commands/dispatch-prompt-blocks.d.ts +1 -1
- package/dist/cli/commands/dispatch-prompt-composition.d.ts +7 -1
- package/dist/cli/commands/dispatch-prompt-composition.js +29 -7
- package/dist/cli/commands/dispatch-record-write.d.ts +1 -1
- package/dist/cli/commands/dispatch-tool-call.d.ts +1 -1
- package/dist/cli/commands/doc-commands.js +1 -1
- package/dist/cli/commands/feedback-commands-helpers.js +1 -1
- package/dist/cli/commands/final-review-prepare-command.js +22 -1
- package/dist/cli/commands/gate-commands-enforce.js +3 -3
- package/dist/cli/commands/hook-handle.js +41 -20
- package/dist/cli/commands/lint-commands.js +3 -1
- package/dist/cli/commands/loop-eval-capture-index.js +2 -4
- package/dist/cli/commands/openspec-command-shared.js +2 -2
- package/dist/cli/commands/perf-audit-commands.js +15 -5
- package/dist/cli/commands/project-commands.js +9 -6
- package/dist/cli/commands/race-commands.d.ts +15 -0
- package/dist/cli/commands/race-commands.js +65 -0
- package/dist/cli/commands/race-pilot-gate-record-command.d.ts +3 -0
- package/dist/cli/commands/race-pilot-gate-record-command.js +81 -0
- package/dist/cli/commands/request-command-options.d.ts +8 -0
- package/dist/cli/commands/request-commands.js +2 -0
- package/dist/cli/commands/request-init-command.js +67 -12
- package/dist/cli/commands/{vm-status-command.d.ts → request-retag-command.d.ts} +1 -1
- package/dist/cli/commands/request-retag-command.js +50 -0
- package/dist/cli/commands/request-show-command.d.ts +8 -0
- package/dist/cli/commands/request-show-command.js +14 -1
- package/dist/cli/commands/request-transition-command.js +12 -4
- package/dist/cli/commands/request-transition-failures.d.ts +14 -0
- package/dist/cli/commands/request-transition-failures.js +76 -7
- package/dist/cli/commands/request-transition-preflight.js +1 -1
- package/dist/cli/commands/scan-scope-commands.js +2 -2
- package/dist/cli/commands/security-audit-commands.js +26 -6
- package/dist/cli/commands/slice-decompose-artifacts.js +2 -1
- package/dist/cli/commands/verdict-aggregate-command.js +2 -1
- package/dist/cli/commands/workflow-gate-commands.js +4 -4
- package/dist/cli/commands/worktree-lease-gc-command.js +1 -1
- package/dist/cli/program.js +0 -2
- package/dist/services/artifacts/artifact-contract-block.d.ts +53 -0
- package/dist/services/artifacts/artifact-contract-block.js +231 -0
- package/dist/services/artifacts/artifact-prerequisites.d.ts +27 -19
- package/dist/services/artifacts/artifact-prerequisites.js +65 -135
- package/dist/services/artifacts/artifact-templates.d.ts +1 -1
- package/dist/services/artifacts/artifact-templates.js +17 -10
- package/dist/services/artifacts/prerequisite-checks.d.ts +87 -0
- package/dist/services/artifacts/prerequisite-checks.js +198 -0
- package/dist/services/artifacts/prerequisite-transition-event.d.ts +20 -0
- package/dist/services/artifacts/prerequisite-transition-event.js +27 -0
- package/dist/services/artifacts/rd-transition-gates.d.ts +33 -0
- package/dist/services/artifacts/rd-transition-gates.js +71 -0
- package/dist/services/artifacts/request-artifact-metadata.d.ts +31 -0
- package/dist/services/artifacts/request-artifact-metadata.js +44 -0
- package/dist/services/artifacts/request-artifact-service.d.ts +5 -0
- package/dist/services/artifacts/request-artifact-service.js +43 -69
- package/dist/services/artifacts/request-artifact-state-helpers.d.ts +21 -1
- package/dist/services/artifacts/request-artifact-state-helpers.js +34 -8
- package/dist/services/artifacts/request-retag-service.d.ts +68 -0
- package/dist/services/artifacts/request-retag-service.js +125 -0
- package/dist/services/artifacts/request-state-order.d.ts +38 -0
- package/dist/services/artifacts/request-state-order.js +99 -0
- package/dist/services/artifacts/request-type-demand.d.ts +44 -0
- package/dist/services/artifacts/request-type-demand.js +71 -0
- package/dist/services/audit/audit-goal-service.d.ts +7 -0
- package/dist/services/audit/enforcers/active-skill-resolver.d.ts +18 -0
- package/dist/services/audit/enforcers/active-skill-resolver.js +48 -1
- package/dist/services/audit/enforcers/code-ban.d.ts +11 -2
- package/dist/services/audit/enforcers/code-ban.js +21 -1
- package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.d.ts +17 -0
- package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.js +24 -7
- package/dist/services/audit-independent/handoff-missing-refusal.d.ts +26 -0
- package/dist/services/audit-independent/handoff-missing-refusal.js +109 -0
- package/dist/services/audit-independent/handoff-readers.d.ts +37 -0
- package/dist/services/audit-independent/handoff-readers.js +81 -0
- package/dist/services/audit-independent/index.d.ts +6 -1
- package/dist/services/audit-independent/index.js +6 -1
- package/dist/services/audit-independent/judged-declaration-build.d.ts +48 -0
- package/dist/services/audit-independent/judged-declaration-build.js +73 -0
- package/dist/services/audit-independent/judged-declaration-check.d.ts +80 -0
- package/dist/services/audit-independent/judged-declaration-check.js +216 -0
- package/dist/services/audit-independent/judged-declaration.d.ts +94 -0
- package/dist/services/audit-independent/judged-declaration.js +218 -0
- package/dist/services/audit-independent/perf-audit-service.js +12 -14
- package/dist/services/audit-independent/security-audit-artifact.d.ts +28 -0
- package/dist/services/audit-independent/security-audit-artifact.js +90 -0
- package/dist/services/audit-independent/security-audit-service.d.ts +6 -53
- package/dist/services/audit-independent/security-audit-service.js +34 -178
- package/dist/services/capability-guard-runner/contracts/J05.js +60 -14
- package/dist/services/codegraph/codegraph-index-integrity.js +2 -0
- package/dist/services/context/build-dispatch-system-prompt.d.ts +8 -12
- package/dist/services/context/build-dispatch-system-prompt.js +18 -18
- package/dist/services/context/collector.js +5 -1
- package/dist/services/context/post-compact-reinjection.js +1 -1
- package/dist/services/dispatch/active-dispatch-index.d.ts +36 -0
- package/dist/services/dispatch/active-dispatch-index.js +118 -0
- package/dist/services/dispatch/batch-counter.js +1 -2
- package/dist/services/dispatch/dispatch-record-writer.d.ts +29 -16
- package/dist/services/dispatch/dispatch-record-writer.js +58 -100
- package/dist/services/dispatch/dispatch-sub-agent.js +1 -1
- package/dist/services/dispatch/karpathy-block.d.ts +55 -0
- package/dist/services/dispatch/karpathy-block.js +101 -0
- package/dist/services/dispatch/ledger-reaper.d.ts +80 -0
- package/dist/services/dispatch/ledger-reaper.js +131 -0
- package/dist/services/dispatch/test-tool-detection.d.ts +17 -1
- package/dist/services/dispatch/test-tool-detection.js +12 -1
- package/dist/services/evidence/evidence-generator.js +23 -12
- package/dist/services/feedback/feedback-promotion-service.d.ts +8 -11
- package/dist/services/feedback/feedback-promotion-service.js +30 -35
- package/dist/services/feedback/promotion-artifact-json-evidence.d.ts +18 -0
- package/dist/services/feedback/promotion-artifact-missing.d.ts +22 -0
- package/dist/services/feedback/promotion-artifact-missing.js +63 -0
- package/dist/services/final-review/final-review-contract.d.ts +95 -4
- package/dist/services/final-review/final-review-contract.js +64 -0
- package/dist/services/final-review/final-review-delivery.d.ts +13 -0
- package/dist/services/final-review/final-review-delivery.js +26 -12
- package/dist/services/final-review/final-review-evidence-collect.js +8 -53
- package/dist/services/final-review/final-review-evidence-records.d.ts +21 -0
- package/dist/services/final-review/final-review-evidence-records.js +67 -0
- package/dist/services/final-review/final-review-evidence-sources.d.ts +22 -0
- package/dist/services/final-review/final-review-evidence-sources.js +28 -4
- package/dist/services/final-review/final-review-prompt.js +19 -6
- package/dist/services/final-review/final-review-runner.js +5 -0
- package/dist/services/final-review/final-review-service.d.ts +2 -2
- package/dist/services/final-review/index.d.ts +1 -1
- package/dist/services/final-review/pre-post-diff.d.ts +2 -75
- package/dist/services/final-review/pre-post-diff.js +60 -59
- package/dist/services/hooks/pre-tool-code-gate.d.ts +7 -1
- package/dist/services/hooks/pre-tool-code-gate.js +21 -2
- package/dist/services/hooks/worktree-authorization-gate.js +6 -31
- package/dist/services/hooks/worktree-refusal-messages.d.ts +74 -0
- package/dist/services/hooks/worktree-refusal-messages.js +102 -0
- package/dist/services/lint/eslint-runner-support.d.ts +1 -1
- package/dist/services/lint/eslint-runner-support.js +2 -1
- package/dist/services/lint/eslint-runner-types.d.ts +8 -0
- package/dist/services/lint/eslint-runner.js +17 -4
- package/dist/services/llm/anthropic-runner.js +24 -7
- package/dist/services/loop/loop-observability.d.ts +39 -0
- package/dist/services/loop/loop-observability.js +55 -0
- package/dist/services/loop/monotonic-guard.js +6 -9
- package/dist/services/loop/monotonic-runner.js +8 -7
- package/dist/services/loop/run-driver.js +18 -22
- package/dist/services/memory/project-memory-service/index/kind-dispatch.js +14 -1
- package/dist/services/memory/project-memory-service/index/project-memory-plan-exec.js +13 -2
- package/dist/services/memory/project-memory-service/index.d.ts +2 -2
- package/dist/services/memory/project-memory-service/index.js +1 -1
- package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.d.ts +36 -0
- package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.js +48 -2
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +23 -1
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +37 -0
- package/dist/services/memory/project-memory-service/types.d.ts +32 -0
- package/dist/services/observability/observability-service.d.ts +7 -0
- package/dist/services/observability/observability-service.js +2 -1
- package/dist/services/openspec/coverage-evidence-reader.d.ts +9 -9
- package/dist/services/openspec/coverage-evidence-reader.js +8 -8
- package/dist/services/openspec/openspec-archive-service.d.ts +1 -1
- package/dist/services/openspec/openspec-archive-service.js +6 -6
- package/dist/services/prd/gate-evidence-derivation.d.ts +4 -3
- package/dist/services/prd/gate-evidence-derivation.js +4 -3
- package/dist/services/qa/bdd-test-style-verifier.js +22 -8
- package/dist/services/race/gate2-evaluator.d.ts +58 -0
- package/dist/services/race/gate2-evaluator.js +111 -0
- package/dist/services/race/gate2-policy.d.ts +17 -0
- package/dist/services/race/gate2-policy.js +31 -0
- package/dist/services/race/lane-phase.d.ts +19 -0
- package/dist/services/race/lane-phase.js +113 -0
- package/dist/services/race/pilot-gate-store.d.ts +67 -0
- package/dist/services/race/pilot-gate-store.js +227 -0
- package/dist/services/scan/file-size-baseline.d.ts +33 -0
- package/dist/services/scan/file-size-baseline.js +173 -0
- package/dist/services/scan/file-size-scan.d.ts +35 -3
- package/dist/services/scan/file-size-scan.js +63 -42
- package/dist/services/scan/type-corroboration.d.ts +32 -0
- package/dist/services/scan/type-corroboration.js +51 -0
- package/dist/services/scan/type-sanity-service.d.ts +14 -0
- package/dist/services/scan/type-sanity-service.js +23 -22
- package/dist/services/security/safe-settings-path.d.ts +5 -0
- package/dist/services/security/safe-settings-path.js +64 -8
- package/dist/services/skill/resume-detector.js +11 -11
- package/dist/services/skills/hooks-codegate-superpowers.d.ts +5 -6
- package/dist/services/skills/hooks-codegate-superpowers.js +7 -8
- package/dist/services/skills/hooks-settings-service.d.ts +1 -1
- package/dist/services/skills/hooks-settings-service.js +1 -1
- package/dist/services/skills/presence-lease-order.d.ts +13 -0
- package/dist/services/skills/presence-lease-order.js +24 -0
- package/dist/services/skills/skill-conformance-service.js +1 -0
- package/dist/services/skills/skill-statusline-service.js +4 -7
- package/dist/services/slice/slice-check-service.js +8 -8
- package/dist/services/workflow/pipeline-verify-gate-support.d.ts +24 -8
- package/dist/services/workflow/pipeline-verify-gate-support.js +34 -39
- package/dist/services/workflow/pipeline-verify-qa-phase.d.ts +102 -0
- package/dist/services/workflow/pipeline-verify-qa-phase.js +176 -0
- package/dist/services/workflow/pipeline-verify-service.js +27 -28
- package/dist/services/workflow/request-type-resolution.d.ts +99 -0
- package/dist/services/workflow/request-type-resolution.js +130 -0
- package/dist/services/workflow/workflow-skip-service.d.ts +1 -20
- package/dist/services/workflow/workflow-skip-service.js +22 -25
- package/dist/services/workflow/workflow-state-store.d.ts +9 -0
- package/dist/services/workflow/workflow-state-store.js +26 -1
- package/dist/services/workspace/claude-settings-retirements.d.ts +54 -0
- package/dist/services/workspace/claude-settings-retirements.js +112 -0
- package/dist/services/workspace/claude-settings-template-merge.d.ts +35 -15
- package/dist/services/workspace/claude-settings-template-merge.js +33 -53
- package/dist/services/workspace/claude-settings-template.d.ts +62 -12
- package/dist/services/workspace/claude-settings-template.js +58 -58
- package/dist/services/workspace/migrate-1-4-1-service.js +3 -0
- package/dist/services/workspace/reconcile-service.js +0 -1
- package/dist/shared/incrementing-number.d.ts +33 -2
- package/dist/shared/incrementing-number.js +72 -3
- package/package.json +5 -7
- package/skills/bee/peaks-perf-audit/SKILL.md +1 -1
- package/skills/bee/peaks-prd/SKILL.md +4 -3
- package/skills/bee/peaks-qa/SKILL.md +1 -1
- package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
- package/skills/bee/peaks-qa/references/qa-transition-gates.md +1 -1
- package/skills/bee/peaks-rd/SKILL.md +2 -2
- package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +1 -1
- package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +8 -4
- package/skills/bee/peaks-rd/references/rd-transition-gates.md +3 -3
- package/skills/bee/peaks-rd/references/v2-12-fanout-collapse.md +2 -2
- package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +1 -1
- package/skills/bee/peaks-reviewer/SKILL.md +1 -1
- package/skills/bee/peaks-sc/SKILL.md +1 -1
- package/skills/bee/peaks-security-audit/SKILL.md +10 -2
- package/skills/bee/peaks-txt/SKILL.md +4 -3
- package/skills/bee/peaks-ui/SKILL.md +3 -3
- package/skills/peaks-audit/SKILL.md +29 -1
- package/skills/peaks-code/SKILL.md +37 -17
- package/skills/peaks-code/references/fast-lane-norm.md +42 -0
- package/skills/peaks-code/references/fast-mode.md +3 -2
- package/skills/peaks-code/references/local-artifact-workspace.md +3 -3
- package/skills/peaks-code/references/micro-cycle.md +3 -3
- package/skills/peaks-code/references/resume-detection.md +1 -1
- package/skills/peaks-code/references/runbook.md +12 -6
- package/skills/peaks-code/references/step-11-memory-sediment.md +4 -0
- package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
- package/skills/peaks-code/references/swarm-dispatch-contract.md +40 -16
- package/skills/peaks-code/references/workflow-gates-and-types.md +6 -6
- package/skills/peaks-code/references/worktree-governance.md +4 -4
- package/skills/peaks-content/SKILL.md +1 -1
- package/skills/peaks-doctor/SKILL.md +1 -1
- package/skills/peaks-final-review/SKILL.md +31 -11
- package/skills/peaks-ide/SKILL.md +1 -1
- package/skills/peaks-issue-fix-orchestrator/SKILL.md +1 -1
- package/skills/peaks-race-code/SKILL.md +185 -0
- package/skills/peaks-resume/SKILL.md +1 -1
- package/skills/peaks-slice-decompose/SKILL.md +1 -1
- package/skills/peaks-solo/SKILL.md +1 -1
- package/skills/peaks-sop/SKILL.md +1 -1
- package/skills/peaks-status/SKILL.md +1 -1
- package/skills/peaks-test/SKILL.md +7 -4
- package/dist/cli/commands/vm-command-shared.d.ts +0 -23
- package/dist/cli/commands/vm-command-shared.js +0 -23
- package/dist/cli/commands/vm-commands.d.ts +0 -3
- package/dist/cli/commands/vm-commands.js +0 -45
- package/dist/cli/commands/vm-hypervisor-probe.d.ts +0 -27
- package/dist/cli/commands/vm-hypervisor-probe.js +0 -78
- package/dist/cli/commands/vm-hypervisor-runtime.d.ts +0 -15
- package/dist/cli/commands/vm-hypervisor-runtime.js +0 -64
- package/dist/cli/commands/vm-release-command.d.ts +0 -5
- package/dist/cli/commands/vm-release-command.js +0 -101
- package/dist/cli/commands/vm-spawn-command.d.ts +0 -5
- package/dist/cli/commands/vm-spawn-command.js +0 -177
- package/dist/cli/commands/vm-status-command.js +0 -50
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +0 -23
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +0 -64
- package/dist/services/vm/vm-lease.d.ts +0 -40
- package/dist/services/vm/vm-lease.js +0 -160
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `claude-settings-retirements.ts` — the `hooks.PreToolUse` entries this template
|
|
3
|
+
* used to declare and has since RETIRED, plus the shape predicate the retirement
|
|
4
|
+
* is tested against.
|
|
5
|
+
*
|
|
6
|
+
* WHY A RETIREMENT IS NOT A DELETION. `mergeTemplateOwnedHooks` (in
|
|
7
|
+
* `claude-settings-template-merge.ts`) carries across every on-disk entry the
|
|
8
|
+
* template does not declare — that is the whole point of the entry-level
|
|
9
|
+
* ownership rule, and it is what keeps `installAutoCompactHook`'s `Bash|Task`
|
|
10
|
+
* entry alive across an init. So simply STOPPING the emission reaches nobody: an
|
|
11
|
+
* install written by an earlier release keeps the entry forever. Declaring less
|
|
12
|
+
* cannot retire an entry; something has to say "this one is gone", and
|
|
13
|
+
* `isRetiredTemplateEntry` is that something. `templateContentMatches` calls it
|
|
14
|
+
* too, because a file still carrying a retired entry has to compare as DRIFTED or
|
|
15
|
+
* the merge that would drop it never runs.
|
|
16
|
+
*
|
|
17
|
+
* Extracted from `claude-settings-template-merge.ts` when the second retirement
|
|
18
|
+
* pushed that module past the 300-line cap. The bodies moved verbatim; the
|
|
19
|
+
* predicate and its two shape types came along because the predicate is their
|
|
20
|
+
* only reader inside that module.
|
|
21
|
+
*
|
|
22
|
+
* TWO RETIREMENTS SO FAR:
|
|
23
|
+
* - TEMPLATE_VERSION 1.8.0 — the `Write|Edit|MultiEdit` gate handler;
|
|
24
|
+
* - TEMPLATE_VERSION 1.10.0 — the two layer-B feedback hooks.
|
|
25
|
+
* They share neither a matcher nor a command form, so each gets its own narrow
|
|
26
|
+
* predicate rather than one looser rule. The narrowness is load-bearing: a
|
|
27
|
+
* predicate that dropped "anything on this matcher" would delete a USER's hook,
|
|
28
|
+
* which is the failure the ownership rule exists to prevent.
|
|
29
|
+
*/
|
|
30
|
+
export function isPreToolUseEntry(value) {
|
|
31
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const candidate = value;
|
|
35
|
+
return typeof candidate.matcher === 'string' && Array.isArray(candidate.hooks);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The retired `Write|Edit|MultiEdit` gate entry, as an on-disk file written by a
|
|
39
|
+
* pre-1.8.0 release holds it.
|
|
40
|
+
*
|
|
41
|
+
* TEMPLATE_VERSION 1.8.0 stopped emitting this entry. Declaring less is not
|
|
42
|
+
* enough on its own: `mergeTemplateOwnedHooks` preserves every on-disk entry the
|
|
43
|
+
* template does not declare — that is the whole point of the entry-level
|
|
44
|
+
* ownership rule (it is what keeps `installAutoCompactHook`'s `Bash|Task` entry
|
|
45
|
+
* alive) — so a project installed by an earlier release would keep the no-op
|
|
46
|
+
* handler, and its `node "C:/…/nvm/v24.14.0/…"` path, forever.
|
|
47
|
+
*
|
|
48
|
+
* Deliberately narrow. It matches the exact command shape this template used to
|
|
49
|
+
* emit — one handler, `node "<…>/services/hooks/write-gate.js"` — under the exact
|
|
50
|
+
* legacy matcher spelling, so a user's OWN `Write|Edit|MultiEdit` entry (a
|
|
51
|
+
* different command, or more than one handler) is preserved like any other entry
|
|
52
|
+
* the template does not declare.
|
|
53
|
+
*/
|
|
54
|
+
const RETIRED_WRITE_GATE_MATCHER = 'Write|Edit|MultiEdit';
|
|
55
|
+
const RETIRED_WRITE_GATE_COMMAND = /^node "[^"]*\/services\/hooks\/write-gate\.js"$/;
|
|
56
|
+
/**
|
|
57
|
+
* The two layer-B feedback hooks TEMPLATE_VERSION 1.10.0 retired, as a file
|
|
58
|
+
* written by 1.9.0 holds them.
|
|
59
|
+
*
|
|
60
|
+
* 1.9.0 emitted them into the CONSUMER template on purpose, to make the promotion
|
|
61
|
+
* a property of a fresh clone rather than of one machine. The template cannot do
|
|
62
|
+
* that: it is written into a consumer project's `.claude/settings.local.json`,
|
|
63
|
+
* where `${CLAUDE_PROJECT_DIR}` is the CONSUMER's root, `src/**` is absent from
|
|
64
|
+
* the npm `files` list, and nothing copies it — so every downstream project
|
|
65
|
+
* received two `Bash` PreToolUse entries whose command could never resolve, and a
|
|
66
|
+
* fresh clone of THIS repository got neither them nor a tracked copy of the
|
|
67
|
+
* registration (`settings.local.json` is gitignored). They are this repository's
|
|
68
|
+
* own development hooks; the registration now lives in this repository's tracked
|
|
69
|
+
* `.claude/settings.json`, where `${CLAUDE_PROJECT_DIR}` really is the root that
|
|
70
|
+
* contains `src/`.
|
|
71
|
+
*
|
|
72
|
+
* Same mechanism and same reason as the write gate above: `mergeTemplateOwnedHooks`
|
|
73
|
+
* preserves every on-disk entry the template does not declare, so REMOVING the
|
|
74
|
+
* spread from `buildClaudeSettingsLocalJson` would leave the two unresolvable
|
|
75
|
+
* entries in every install that already had them, forever.
|
|
76
|
+
*
|
|
77
|
+
* Deliberately narrow: it matches the exact command string 1.9.0 emitted — `bash`,
|
|
78
|
+
* then the project-root variable, then that script's shipped path — under the
|
|
79
|
+
* matcher 1.9.0 used, with a single handler. A consumer's own `Bash` entry (a
|
|
80
|
+
* different command, or more than one handler) is preserved like any other entry
|
|
81
|
+
* the template does not declare.
|
|
82
|
+
*/
|
|
83
|
+
const RETIRED_FEEDBACK_HOOK_MATCHER = 'Bash';
|
|
84
|
+
const RETIRED_FEEDBACK_HOOK_COMMANDS = new Set([
|
|
85
|
+
'pre-tool-peaks-current-directory-scope.sh',
|
|
86
|
+
'pre-tool-piping-a-test-run-reports-the-pipes-exit-code.sh'
|
|
87
|
+
].map((script) => `bash "\${CLAUDE_PROJECT_DIR}/src/services/hooks/${script}"`));
|
|
88
|
+
/**
|
|
89
|
+
* Is `entry` one this template used to declare and has since RETIRED?
|
|
90
|
+
*
|
|
91
|
+
* Each retirement gets its own narrow predicate — the shapes share neither a
|
|
92
|
+
* matcher nor a command form. An entry whose shape matches nothing here is not
|
|
93
|
+
* retired, and is preserved.
|
|
94
|
+
*/
|
|
95
|
+
export function isRetiredTemplateEntry(entry) {
|
|
96
|
+
if (!isPreToolUseEntry(entry))
|
|
97
|
+
return false;
|
|
98
|
+
if (entry.hooks.length !== 1)
|
|
99
|
+
return false;
|
|
100
|
+
const [handler] = entry.hooks;
|
|
101
|
+
if (handler === undefined)
|
|
102
|
+
return false;
|
|
103
|
+
if (handler.type !== 'command')
|
|
104
|
+
return false;
|
|
105
|
+
if (entry.matcher === RETIRED_WRITE_GATE_MATCHER) {
|
|
106
|
+
return RETIRED_WRITE_GATE_COMMAND.test(handler.command);
|
|
107
|
+
}
|
|
108
|
+
if (entry.matcher === RETIRED_FEEDBACK_HOOK_MATCHER) {
|
|
109
|
+
return RETIRED_FEEDBACK_HOOK_COMMANDS.has(handler.command);
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* `claude-settings-template.ts` re-exports every symbol below, so it stays the
|
|
12
12
|
* single public entry point for this concern.
|
|
13
13
|
*/
|
|
14
|
+
import { isRetiredTemplateEntry } from './claude-settings-retirements.js';
|
|
14
15
|
/**
|
|
15
16
|
* Compare two serialized template strings: does the on-disk file already
|
|
16
17
|
* declare every entry the generated tree declares?
|
|
@@ -30,10 +31,15 @@
|
|
|
30
31
|
* ownership existed to prevent, and the reason the merge could not ship alone.
|
|
31
32
|
*
|
|
32
33
|
* Matching is order-insensitive AND multiset-aware: the template declares TWO
|
|
33
|
-
* `Bash` entries
|
|
34
|
+
* `Bash` entries — a MEASUREMENT, not a memory, so it is pinned to a predicate
|
|
35
|
+
* rather than restated in prose: `buildClaudeSettingsLocalJson().hooks.
|
|
36
|
+
* PreToolUse` filtered on `matcher === 'Bash'` has length 2 (the Step 0.8 gate
|
|
37
|
+
* and `gate enforce`). Each must have its own counterpart on disk, so a file
|
|
34
38
|
* carrying only one of them is still reported as drifted (the previous
|
|
35
39
|
* index-by-index loop had the same property; it is load-bearing, not a
|
|
36
|
-
* detail).
|
|
40
|
+
* detail). The live count was 4 from TEMPLATE_VERSION 1.9.0 until 1.10.0 retired
|
|
41
|
+
* the two layer-B feedback hooks from the template, which is exactly how a
|
|
42
|
+
* prose count goes stale.
|
|
37
43
|
*
|
|
38
44
|
* Returns `true` iff both strings parse to objects whose `hooks.PreToolUse`
|
|
39
45
|
* arrays satisfy that containment, the on-disk file carries NO entry this
|
|
@@ -66,24 +72,38 @@ export declare function templateContentMatches(generated: string, onDisk: string
|
|
|
66
72
|
* self-heal instead of lingering next to a correct copy of itself.
|
|
67
73
|
*
|
|
68
74
|
* Slot counting is per `matcher` and positional within it: the template
|
|
69
|
-
* declares TWO `Bash` entries
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
75
|
+
* declares TWO `Bash` entries — `buildClaudeSettingsLocalJson()` filtered on
|
|
76
|
+
* `matcher === 'Bash'` is the measurement, and it is 2 — so the first two
|
|
77
|
+
* on-disk `Bash` entries are theirs and a third is the user's. (It was 4 while
|
|
78
|
+
* TEMPLATE_VERSION 1.9.0 also declared the two layer-B feedback hooks; 1.10.0
|
|
79
|
+
* retired those, and because the retirement is tested BEFORE slot counting they
|
|
80
|
+
* never occupy a slot on their way out.) The template's entries are emitted
|
|
81
|
+
* first, in template order, then the preserved ones in their on-disk order —
|
|
82
|
+
* which is a fixed point: re-merging the result yields the result (the
|
|
83
|
+
* template's own entries are encountered first and refill their own slots).
|
|
74
84
|
*
|
|
75
85
|
* Non-conforming entries (no string `matcher`, no `hooks` array) are preserved
|
|
76
86
|
* rather than dropped: guessing at their shape is how a user's entry gets
|
|
77
87
|
* deleted.
|
|
78
88
|
*
|
|
79
89
|
* ONE exception to "preserve what I do not declare": an entry this template
|
|
80
|
-
* used to declare and RETIRED
|
|
81
|
-
*
|
|
82
|
-
* Declaring less cannot retire an entry on
|
|
83
|
-
* undeclared entries is exactly what this function
|
|
84
|
-
* pre-1.8.0 install would keep the no-op handler and
|
|
85
|
-
*
|
|
86
|
-
*
|
|
90
|
+
* used to declare and RETIRED is dropped rather than preserved — TEMPLATE_
|
|
91
|
+
* VERSION 1.8.0's `Write|Edit|MultiEdit` gate, and 1.10.0's two layer-B feedback
|
|
92
|
+
* hooks (see `isRetiredTemplateEntry`). Declaring less cannot retire an entry on
|
|
93
|
+
* its own, because preserving undeclared entries is exactly what this function
|
|
94
|
+
* does; without the drop, a pre-1.8.0 install would keep the no-op handler and
|
|
95
|
+
* its version-pinned script path forever, and a pre-1.10.0 consumer would keep
|
|
96
|
+
* two `Bash` entries whose command points into an `src/` tree it never
|
|
97
|
+
* received. Each predicate is narrow enough that only the exact command this
|
|
98
|
+
* template emitted matches.
|
|
87
99
|
*/
|
|
88
100
|
export declare function mergeTemplateOwnedHooks(onDisk: ReadonlyArray<unknown>, template: ReadonlyArray<unknown>): unknown[];
|
|
89
|
-
|
|
101
|
+
/**
|
|
102
|
+
* The retirement vocabulary — the entries this template used to declare and has
|
|
103
|
+
* since RETIRED, and the shape predicate that says so — lives in
|
|
104
|
+
* `claude-settings-retirements.ts`. It was extracted when the second retirement
|
|
105
|
+
* pushed this module past the 300-line cap. Re-exported here so
|
|
106
|
+
* `claude-settings-template.ts`, the single public entry point for the template
|
|
107
|
+
* concern, still reaches it through the module it always did.
|
|
108
|
+
*/
|
|
109
|
+
export { isRetiredTemplateEntry };
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* single public entry point for this concern.
|
|
13
13
|
*/
|
|
14
14
|
import { hasExternalGateExemptions } from '../skills/hooks-codegate-superpowers.js';
|
|
15
|
+
import { isPreToolUseEntry, isRetiredTemplateEntry } from './claude-settings-retirements.js';
|
|
15
16
|
/**
|
|
16
17
|
* Compare two serialized template strings: does the on-disk file already
|
|
17
18
|
* declare every entry the generated tree declares?
|
|
@@ -31,10 +32,15 @@ import { hasExternalGateExemptions } from '../skills/hooks-codegate-superpowers.
|
|
|
31
32
|
* ownership existed to prevent, and the reason the merge could not ship alone.
|
|
32
33
|
*
|
|
33
34
|
* Matching is order-insensitive AND multiset-aware: the template declares TWO
|
|
34
|
-
* `Bash` entries
|
|
35
|
+
* `Bash` entries — a MEASUREMENT, not a memory, so it is pinned to a predicate
|
|
36
|
+
* rather than restated in prose: `buildClaudeSettingsLocalJson().hooks.
|
|
37
|
+
* PreToolUse` filtered on `matcher === 'Bash'` has length 2 (the Step 0.8 gate
|
|
38
|
+
* and `gate enforce`). Each must have its own counterpart on disk, so a file
|
|
35
39
|
* carrying only one of them is still reported as drifted (the previous
|
|
36
40
|
* index-by-index loop had the same property; it is load-bearing, not a
|
|
37
|
-
* detail).
|
|
41
|
+
* detail). The live count was 4 from TEMPLATE_VERSION 1.9.0 until 1.10.0 retired
|
|
42
|
+
* the two layer-B feedback hooks from the template, which is exactly how a
|
|
43
|
+
* prose count goes stale.
|
|
38
44
|
*
|
|
39
45
|
* Returns `true` iff both strings parse to objects whose `hooks.PreToolUse`
|
|
40
46
|
* arrays satisfy that containment, the on-disk file carries NO entry this
|
|
@@ -118,24 +124,30 @@ export function templateContentMatches(generated, onDisk) {
|
|
|
118
124
|
* self-heal instead of lingering next to a correct copy of itself.
|
|
119
125
|
*
|
|
120
126
|
* Slot counting is per `matcher` and positional within it: the template
|
|
121
|
-
* declares TWO `Bash` entries
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
127
|
+
* declares TWO `Bash` entries — `buildClaudeSettingsLocalJson()` filtered on
|
|
128
|
+
* `matcher === 'Bash'` is the measurement, and it is 2 — so the first two
|
|
129
|
+
* on-disk `Bash` entries are theirs and a third is the user's. (It was 4 while
|
|
130
|
+
* TEMPLATE_VERSION 1.9.0 also declared the two layer-B feedback hooks; 1.10.0
|
|
131
|
+
* retired those, and because the retirement is tested BEFORE slot counting they
|
|
132
|
+
* never occupy a slot on their way out.) The template's entries are emitted
|
|
133
|
+
* first, in template order, then the preserved ones in their on-disk order —
|
|
134
|
+
* which is a fixed point: re-merging the result yields the result (the
|
|
135
|
+
* template's own entries are encountered first and refill their own slots).
|
|
126
136
|
*
|
|
127
137
|
* Non-conforming entries (no string `matcher`, no `hooks` array) are preserved
|
|
128
138
|
* rather than dropped: guessing at their shape is how a user's entry gets
|
|
129
139
|
* deleted.
|
|
130
140
|
*
|
|
131
141
|
* ONE exception to "preserve what I do not declare": an entry this template
|
|
132
|
-
* used to declare and RETIRED
|
|
133
|
-
*
|
|
134
|
-
* Declaring less cannot retire an entry on
|
|
135
|
-
* undeclared entries is exactly what this function
|
|
136
|
-
* pre-1.8.0 install would keep the no-op handler and
|
|
137
|
-
*
|
|
138
|
-
*
|
|
142
|
+
* used to declare and RETIRED is dropped rather than preserved — TEMPLATE_
|
|
143
|
+
* VERSION 1.8.0's `Write|Edit|MultiEdit` gate, and 1.10.0's two layer-B feedback
|
|
144
|
+
* hooks (see `isRetiredTemplateEntry`). Declaring less cannot retire an entry on
|
|
145
|
+
* its own, because preserving undeclared entries is exactly what this function
|
|
146
|
+
* does; without the drop, a pre-1.8.0 install would keep the no-op handler and
|
|
147
|
+
* its version-pinned script path forever, and a pre-1.10.0 consumer would keep
|
|
148
|
+
* two `Bash` entries whose command points into an `src/` tree it never
|
|
149
|
+
* received. Each predicate is narrow enough that only the exact command this
|
|
150
|
+
* template emitted matches.
|
|
139
151
|
*/
|
|
140
152
|
export function mergeTemplateOwnedHooks(onDisk, template) {
|
|
141
153
|
const slots = new Map();
|
|
@@ -170,13 +182,6 @@ export function mergeTemplateOwnedHooks(onDisk, template) {
|
|
|
170
182
|
function sameEntry(a, b) {
|
|
171
183
|
return a.matcher === b.matcher && sameHooksArray(a.hooks, b.hooks);
|
|
172
184
|
}
|
|
173
|
-
function isPreToolUseEntry(value) {
|
|
174
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
const candidate = value;
|
|
178
|
-
return typeof candidate.matcher === 'string' && Array.isArray(candidate.hooks);
|
|
179
|
-
}
|
|
180
185
|
function isTemplateShape(value) {
|
|
181
186
|
if (typeof value !== 'object' || value === null) {
|
|
182
187
|
return false;
|
|
@@ -208,36 +213,11 @@ function sameHooksArray(a, b) {
|
|
|
208
213
|
return true;
|
|
209
214
|
}
|
|
210
215
|
/**
|
|
211
|
-
* The
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* ownership rule (it is what keeps `installAutoCompactHook`'s `Bash|Task`
|
|
218
|
-
* entry alive) — so a project installed by an earlier release would keep the
|
|
219
|
-
* no-op handler, and its `node "C:/…/nvm/v24.14.0/…"` path, forever. This
|
|
220
|
-
* predicate is the retirement: `mergeTemplateOwnedHooks` drops a match.
|
|
221
|
-
*
|
|
222
|
-
* Deliberately narrow. It matches the exact command shape this template used
|
|
223
|
-
* to emit — one handler, `node "<…>/services/hooks/write-gate.js"` — under the
|
|
224
|
-
* exact legacy matcher spelling, so a user's OWN `Write|Edit|MultiEdit` entry
|
|
225
|
-
* (a different command, or more than one handler) is preserved like any other
|
|
226
|
-
* entry the template does not declare. A looser "drop anything on this
|
|
227
|
-
* matcher" rule would delete a user's hook, which is the failure the ownership
|
|
228
|
-
* rule exists to prevent.
|
|
216
|
+
* The retirement vocabulary — the entries this template used to declare and has
|
|
217
|
+
* since RETIRED, and the shape predicate that says so — lives in
|
|
218
|
+
* `claude-settings-retirements.ts`. It was extracted when the second retirement
|
|
219
|
+
* pushed this module past the 300-line cap. Re-exported here so
|
|
220
|
+
* `claude-settings-template.ts`, the single public entry point for the template
|
|
221
|
+
* concern, still reaches it through the module it always did.
|
|
229
222
|
*/
|
|
230
|
-
|
|
231
|
-
const RETIRED_WRITE_GATE_COMMAND = /^node "[^"]*\/services\/hooks\/write-gate\.js"$/;
|
|
232
|
-
export function isRetiredTemplateEntry(entry) {
|
|
233
|
-
if (!isPreToolUseEntry(entry))
|
|
234
|
-
return false;
|
|
235
|
-
if (entry.matcher !== RETIRED_WRITE_GATE_MATCHER)
|
|
236
|
-
return false;
|
|
237
|
-
if (entry.hooks.length !== 1)
|
|
238
|
-
return false;
|
|
239
|
-
const [handler] = entry.hooks;
|
|
240
|
-
if (handler === undefined)
|
|
241
|
-
return false;
|
|
242
|
-
return handler.type === 'command' && RETIRED_WRITE_GATE_COMMAND.test(handler.command);
|
|
243
|
-
}
|
|
223
|
+
export { isRetiredTemplateEntry };
|
|
@@ -23,11 +23,17 @@
|
|
|
23
23
|
* it can be unit-tested in isolation and so the on-disk file matches
|
|
24
24
|
* the in-memory template byte-for-byte.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
* gate-enforce handler
|
|
28
|
-
*
|
|
29
|
-
* `
|
|
30
|
-
*
|
|
26
|
+
* TWO `Bash` matchers are emitted: the Step 0.8 mechanical gate and the SOP
|
|
27
|
+
* gate-enforce handler. No `Write|Edit|MultiEdit` entry is emitted: that
|
|
28
|
+
* matcher's gate is `peaks code-gate`, installed into the committed
|
|
29
|
+
* `.claude/settings.json` by `peaks hooks install`. TEMPLATE_VERSION 1.10.0
|
|
30
|
+
* removed the two layer-B feedback hooks this file used to emit: they are this
|
|
31
|
+
* repository's OWN development hooks, and this file is written into a
|
|
32
|
+
* CONSUMER project, where `${CLAUDE_PROJECT_DIR}` is that project's root, no
|
|
33
|
+
* `src/**` is ever shipped, and the command therefore points at nothing. They
|
|
34
|
+
* are registered in this repository's tracked `.claude/settings.json` instead;
|
|
35
|
+
* `isRetiredTemplateEntry` in `claude-settings-template-merge.ts` is what makes
|
|
36
|
+
* an install that already has them converge.
|
|
31
37
|
*
|
|
32
38
|
* The previous `Bash` matcher (which whitelisted a fixed `peaks
|
|
33
39
|
* <subcommand>` prefix) was removed in TEMPLATE_VERSION 1.2.0. The
|
|
@@ -115,8 +121,22 @@ export declare const CLAUDE_SETTINGS_LOCAL_FILENAME = ".claude/settings.local.js
|
|
|
115
121
|
* promotion they carry was true only locally. See
|
|
116
122
|
* `buildFeedbackHookHandler` for why the pin is `bash` and not the
|
|
117
123
|
* `powershell` its three siblings take.
|
|
124
|
+
* 1.10.0 — REMOVED those two entries again, and retired them so every install
|
|
125
|
+
* that already carries them converges. 1.9.0's INTENT was right — a
|
|
126
|
+
* fresh clone should carry the registration, not just the scripts —
|
|
127
|
+
* but this file is the wrong mechanism for it. This template is
|
|
128
|
+
* written into a CONSUMER project's `.claude/settings.local.json`,
|
|
129
|
+
* where `${CLAUDE_PROJECT_DIR}` is the consumer's root, `src/**` is
|
|
130
|
+
* not in the npm `files` list, and nothing copies it, so the two
|
|
131
|
+
* entries were a command that could never resolve in every
|
|
132
|
+
* downstream project; and this repository, whose `settings.local.json`
|
|
133
|
+
* is gitignored, got no tracked copy either. The scripts STAY here —
|
|
134
|
+
* they are this repository's own development hooks — and the
|
|
135
|
+
* registration moved to the tracked `.claude/settings.json`.
|
|
136
|
+
* `isRetiredTemplateEntry` carries the retirement, because declaring
|
|
137
|
+
* less cannot retire an entry on its own.
|
|
118
138
|
*/
|
|
119
|
-
export declare const TEMPLATE_VERSION = "1.
|
|
139
|
+
export declare const TEMPLATE_VERSION = "1.10.0";
|
|
120
140
|
type ClaudeHookCommand = {
|
|
121
141
|
type: 'command';
|
|
122
142
|
command: string;
|
|
@@ -145,11 +165,41 @@ type ClaudeSettingsLocal = {
|
|
|
145
165
|
* forcing gate is a core feature that PreToolUse hooks can short-
|
|
146
166
|
* circuit but that the `permissions` block cannot.
|
|
147
167
|
*
|
|
148
|
-
* As of TEMPLATE_VERSION 1.
|
|
149
|
-
* two
|
|
150
|
-
*
|
|
151
|
-
* `
|
|
152
|
-
*
|
|
153
|
-
*
|
|
168
|
+
* As of TEMPLATE_VERSION 1.10.0 the template emits exactly TWO `Bash` matchers:
|
|
169
|
+
* the two below. (1.9.0 added one entry per layer-B feedback hook on top of
|
|
170
|
+
* them, which made four; 1.10.0 removed and retired those — see
|
|
171
|
+
* `isRetiredTemplateEntry`.) The `Write|Edit|MultiEdit` fact-forcing bypass is
|
|
172
|
+
* no longer a hook: it is the `env` exemption above, and that matcher's gate
|
|
173
|
+
* (`peaks code-gate`) is installed into the committed `.claude/settings.json`
|
|
174
|
+
* by `peaks hooks install`.
|
|
154
175
|
*/
|
|
155
176
|
export declare function buildClaudeSettingsLocalJson(): ClaudeSettingsLocal;
|
|
177
|
+
/**
|
|
178
|
+
* TEMPLATE_VERSION 1.9.0 emitted the two layer-B feedback hooks from here; 1.10.0
|
|
179
|
+
* removed and RETIRED them. See `claude-settings-retirements.ts` for the retirement
|
|
180
|
+
* itself and for why declaring less cannot carry one. What is worth keeping here:
|
|
181
|
+
*
|
|
182
|
+
* - WHERE THEY LIVE NOW. `pre-tool-peaks-current-directory-scope.sh` and
|
|
183
|
+
* `pre-tool-piping-a-test-run-reports-the-pipes-exit-code.sh` are this
|
|
184
|
+
* repository's OWN development hooks, so their registration is in this
|
|
185
|
+
* repository's tracked `.claude/settings.json` — where `${CLAUDE_PROJECT_DIR}`
|
|
186
|
+
* really is the root that contains `src/`.
|
|
187
|
+
* - THE SHELL PIN THEY STILL CARRY, and why it is not the `powershell` their CLI
|
|
188
|
+
* siblings take. Measured on this host, both shapes run the script and both
|
|
189
|
+
* print its refusal to stderr — but not the same exit code:
|
|
190
|
+
*
|
|
191
|
+
* bash "<script>" exit 2 (the script's own code)
|
|
192
|
+
* powershell "<script>" exit 1 (flattened by the shell)
|
|
193
|
+
*
|
|
194
|
+
* Under the Claude Code hook protocol only exit 2 blocks; any other non-zero
|
|
195
|
+
* exit is a NON-BLOCKING ERROR and the tool call goes ahead. So `powershell`
|
|
196
|
+
* would turn the refusal into a log line and let the command through — the
|
|
197
|
+
* failure these entries exist to prevent. `shell` accepts `bash` and
|
|
198
|
+
* `powershell` only, and `bash` is also the interpreter the command names.
|
|
199
|
+
* - WHAT THEY REFUSE. `peaks-current-directory-scope` refuses global-state
|
|
200
|
+
* mutations (`npm i -g`, writes under `~/.claude`) unless the user explicitly
|
|
201
|
+
* authorises them; `piping-a-test-run-reports-the-pipes-exit-code` refuses a
|
|
202
|
+
* test run piped into a pager, because the exit code read afterwards is the
|
|
203
|
+
* pager's, not the runner's. `tests/unit/hooks/feedback-promoted-pretool-hooks.test.ts`
|
|
204
|
+
* drives both, with a plant for each.
|
|
205
|
+
*/
|
|
@@ -23,11 +23,17 @@
|
|
|
23
23
|
* it can be unit-tested in isolation and so the on-disk file matches
|
|
24
24
|
* the in-memory template byte-for-byte.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
* gate-enforce handler
|
|
28
|
-
*
|
|
29
|
-
* `
|
|
30
|
-
*
|
|
26
|
+
* TWO `Bash` matchers are emitted: the Step 0.8 mechanical gate and the SOP
|
|
27
|
+
* gate-enforce handler. No `Write|Edit|MultiEdit` entry is emitted: that
|
|
28
|
+
* matcher's gate is `peaks code-gate`, installed into the committed
|
|
29
|
+
* `.claude/settings.json` by `peaks hooks install`. TEMPLATE_VERSION 1.10.0
|
|
30
|
+
* removed the two layer-B feedback hooks this file used to emit: they are this
|
|
31
|
+
* repository's OWN development hooks, and this file is written into a
|
|
32
|
+
* CONSUMER project, where `${CLAUDE_PROJECT_DIR}` is that project's root, no
|
|
33
|
+
* `src/**` is ever shipped, and the command therefore points at nothing. They
|
|
34
|
+
* are registered in this repository's tracked `.claude/settings.json` instead;
|
|
35
|
+
* `isRetiredTemplateEntry` in `claude-settings-template-merge.ts` is what makes
|
|
36
|
+
* an install that already has them converge.
|
|
31
37
|
*
|
|
32
38
|
* The previous `Bash` matcher (which whitelisted a fixed `peaks
|
|
33
39
|
* <subcommand>` prefix) was removed in TEMPLATE_VERSION 1.2.0. The
|
|
@@ -116,8 +122,22 @@ export const CLAUDE_SETTINGS_LOCAL_FILENAME = '.claude/settings.local.json';
|
|
|
116
122
|
* promotion they carry was true only locally. See
|
|
117
123
|
* `buildFeedbackHookHandler` for why the pin is `bash` and not the
|
|
118
124
|
* `powershell` its three siblings take.
|
|
125
|
+
* 1.10.0 — REMOVED those two entries again, and retired them so every install
|
|
126
|
+
* that already carries them converges. 1.9.0's INTENT was right — a
|
|
127
|
+
* fresh clone should carry the registration, not just the scripts —
|
|
128
|
+
* but this file is the wrong mechanism for it. This template is
|
|
129
|
+
* written into a CONSUMER project's `.claude/settings.local.json`,
|
|
130
|
+
* where `${CLAUDE_PROJECT_DIR}` is the consumer's root, `src/**` is
|
|
131
|
+
* not in the npm `files` list, and nothing copies it, so the two
|
|
132
|
+
* entries were a command that could never resolve in every
|
|
133
|
+
* downstream project; and this repository, whose `settings.local.json`
|
|
134
|
+
* is gitignored, got no tracked copy either. The scripts STAY here —
|
|
135
|
+
* they are this repository's own development hooks — and the
|
|
136
|
+
* registration moved to the tracked `.claude/settings.json`.
|
|
137
|
+
* `isRetiredTemplateEntry` carries the retirement, because declaring
|
|
138
|
+
* less cannot retire an entry on its own.
|
|
119
139
|
*/
|
|
120
|
-
export const TEMPLATE_VERSION = '1.
|
|
140
|
+
export const TEMPLATE_VERSION = '1.10.0';
|
|
121
141
|
/**
|
|
122
142
|
* TEMPLATE_VERSION 1.4.0 — the SOP gate-enforce handler, read from the same
|
|
123
143
|
* canonical hook spec `peaks hooks install` uses. Deriving it here (rather
|
|
@@ -141,12 +161,13 @@ function buildGateEnforceHandler() {
|
|
|
141
161
|
* forcing gate is a core feature that PreToolUse hooks can short-
|
|
142
162
|
* circuit but that the `permissions` block cannot.
|
|
143
163
|
*
|
|
144
|
-
* As of TEMPLATE_VERSION 1.
|
|
145
|
-
* two
|
|
146
|
-
*
|
|
147
|
-
* `
|
|
148
|
-
*
|
|
149
|
-
*
|
|
164
|
+
* As of TEMPLATE_VERSION 1.10.0 the template emits exactly TWO `Bash` matchers:
|
|
165
|
+
* the two below. (1.9.0 added one entry per layer-B feedback hook on top of
|
|
166
|
+
* them, which made four; 1.10.0 removed and retired those — see
|
|
167
|
+
* `isRetiredTemplateEntry`.) The `Write|Edit|MultiEdit` fact-forcing bypass is
|
|
168
|
+
* no longer a hook: it is the `env` exemption above, and that matcher's gate
|
|
169
|
+
* (`peaks code-gate`) is installed into the committed `.claude/settings.json`
|
|
170
|
+
* by `peaks hooks install`.
|
|
150
171
|
*/
|
|
151
172
|
export function buildClaudeSettingsLocalJson() {
|
|
152
173
|
return {
|
|
@@ -182,15 +203,7 @@ export function buildClaudeSettingsLocalJson() {
|
|
|
182
203
|
// group and the gate would run twice per Bash call.
|
|
183
204
|
matcher: 'Bash',
|
|
184
205
|
hooks: [buildGateEnforceHandler()]
|
|
185
|
-
}
|
|
186
|
-
...FEEDBACK_HOOK_SCRIPTS.map((script) => ({
|
|
187
|
-
// TEMPLATE_VERSION 1.9.0 — the layer-B feedback hooks, one matcher
|
|
188
|
-
// group each, for the same reason the entry above has its own: a
|
|
189
|
-
// group is peaks-managed only when EVERY handler in it carries a
|
|
190
|
-
// peaks sentinel, and none of these handlers does.
|
|
191
|
-
matcher: 'Bash',
|
|
192
|
-
hooks: [buildFeedbackHookHandler(script)]
|
|
193
|
-
}))
|
|
206
|
+
}
|
|
194
207
|
]
|
|
195
208
|
}
|
|
196
209
|
};
|
|
@@ -224,44 +237,31 @@ function buildBashGateStep08Handler() {
|
|
|
224
237
|
};
|
|
225
238
|
}
|
|
226
239
|
/**
|
|
227
|
-
* TEMPLATE_VERSION 1.9.0
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* the promotion a property of the repository rather than of that machine — the
|
|
231
|
-
* layer-B feedback gate reads THIS template's `hooks` block, so a fresh clone had
|
|
232
|
-
* the enforcement and nothing registering it.
|
|
233
|
-
*
|
|
234
|
-
* The filenames are the contract: the layer-B check looks for a hook command that
|
|
235
|
-
* INVOKES A FILE NAMED AFTER THE RULE, so the command has to carry the script's
|
|
236
|
-
* name and cannot be a `peaks` verb that dispatches to it.
|
|
237
|
-
*/
|
|
238
|
-
const FEEDBACK_HOOK_SCRIPTS = [
|
|
239
|
-
'pre-tool-peaks-current-directory-scope.sh',
|
|
240
|
-
'pre-tool-piping-a-test-run-reports-the-pipes-exit-code.sh'
|
|
241
|
-
];
|
|
242
|
-
/** The shell these two handlers are pinned to. See `buildFeedbackHookHandler`. */
|
|
243
|
-
const FEEDBACK_HOOK_SHELL = 'bash';
|
|
244
|
-
/**
|
|
245
|
-
* The handler for one feedback hook, pinned to `shell: 'bash'`.
|
|
240
|
+
* TEMPLATE_VERSION 1.9.0 emitted the two layer-B feedback hooks from here; 1.10.0
|
|
241
|
+
* removed and RETIRED them. See `claude-settings-retirements.ts` for the retirement
|
|
242
|
+
* itself and for why declaring less cannot carry one. What is worth keeping here:
|
|
246
243
|
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
244
|
+
* - WHERE THEY LIVE NOW. `pre-tool-peaks-current-directory-scope.sh` and
|
|
245
|
+
* `pre-tool-piping-a-test-run-reports-the-pipes-exit-code.sh` are this
|
|
246
|
+
* repository's OWN development hooks, so their registration is in this
|
|
247
|
+
* repository's tracked `.claude/settings.json` — where `${CLAUDE_PROJECT_DIR}`
|
|
248
|
+
* really is the root that contains `src/`.
|
|
249
|
+
* - THE SHELL PIN THEY STILL CARRY, and why it is not the `powershell` their CLI
|
|
250
|
+
* siblings take. Measured on this host, both shapes run the script and both
|
|
251
|
+
* print its refusal to stderr — but not the same exit code:
|
|
250
252
|
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
+
* bash "<script>" exit 2 (the script's own code)
|
|
254
|
+
* powershell "<script>" exit 1 (flattened by the shell)
|
|
253
255
|
*
|
|
254
|
-
*
|
|
255
|
-
* is a NON-BLOCKING ERROR and the tool call goes ahead. So
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
256
|
+
* Under the Claude Code hook protocol only exit 2 blocks; any other non-zero
|
|
257
|
+
* exit is a NON-BLOCKING ERROR and the tool call goes ahead. So `powershell`
|
|
258
|
+
* would turn the refusal into a log line and let the command through — the
|
|
259
|
+
* failure these entries exist to prevent. `shell` accepts `bash` and
|
|
260
|
+
* `powershell` only, and `bash` is also the interpreter the command names.
|
|
261
|
+
* - WHAT THEY REFUSE. `peaks-current-directory-scope` refuses global-state
|
|
262
|
+
* mutations (`npm i -g`, writes under `~/.claude`) unless the user explicitly
|
|
263
|
+
* authorises them; `piping-a-test-run-reports-the-pipes-exit-code` refuses a
|
|
264
|
+
* test run piped into a pager, because the exit code read afterwards is the
|
|
265
|
+
* pager's, not the runner's. `tests/unit/hooks/feedback-promoted-pretool-hooks.test.ts`
|
|
266
|
+
* drives both, with a plant for each.
|
|
260
267
|
*/
|
|
261
|
-
function buildFeedbackHookHandler(script) {
|
|
262
|
-
return {
|
|
263
|
-
type: 'command',
|
|
264
|
-
command: `bash "\${CLAUDE_PROJECT_DIR}/src/services/hooks/${script}"`,
|
|
265
|
-
shell: FEEDBACK_HOOK_SHELL
|
|
266
|
-
};
|
|
267
|
-
}
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync } from 'node:fs';
|
|
22
22
|
import { join } from 'node:path';
|
|
23
|
+
// Frozen: the filenames release 1.4.1 wrote, not the current contract. The
|
|
24
|
+
// entries name what this migration must FIND on an upgraded tree, so they stay
|
|
25
|
+
// bare even where a later release put the request id in the canonical name.
|
|
23
26
|
export const PER_SESSION_ARTIFACT_TYPES = [
|
|
24
27
|
'rd/tech-doc.md',
|
|
25
28
|
'rd/code-review.md',
|
|
@@ -277,7 +277,6 @@ function readActiveSkillSessionId(projectRoot) {
|
|
|
277
277
|
return null;
|
|
278
278
|
try {
|
|
279
279
|
// Sync read: tiny file, no I/O benefit from async
|
|
280
|
-
const { readFileSync } = require('node:fs');
|
|
281
280
|
const raw = readFileSync(pathToRead, 'utf8');
|
|
282
281
|
const parsed = JSON.parse(raw);
|
|
283
282
|
if (typeof parsed?.sessionId === 'string' && parsed.sessionId.length > 0) {
|