peaks-loop 4.1.4 → 4.1.5
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 +112 -0
- package/README-en.md +1 -1
- package/README.md +1 -1
- 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/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-commands.js +12 -5
- package/dist/cli/commands/dispatch-preflight.js +46 -0
- package/dist/cli/commands/dispatch-prompt-composition.d.ts +6 -0
- package/dist/cli/commands/dispatch-prompt-composition.js +29 -7
- 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/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/request-retag-command.d.ts +3 -0
- 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 +45 -3
- package/dist/cli/commands/scan-scope-commands.js +2 -2
- package/dist/cli/commands/security-audit-commands.js +26 -6
- package/dist/cli/commands/worktree-lease-gc-command.js +1 -1
- package/dist/services/artifacts/artifact-contract-block.d.ts +53 -0
- package/dist/services/artifacts/artifact-contract-block.js +212 -0
- package/dist/services/artifacts/artifact-prerequisites.d.ts +27 -19
- package/dist/services/artifacts/artifact-prerequisites.js +63 -133
- 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/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 +23 -51
- package/dist/services/artifacts/request-artifact-state-helpers.d.ts +12 -0
- package/dist/services/artifacts/request-artifact-state-helpers.js +28 -4
- 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 +79 -0
- package/dist/services/audit-independent/judged-declaration-check.js +155 -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 +3 -3
- package/dist/services/context/build-dispatch-system-prompt.js +7 -7
- package/dist/services/context/collector.js +5 -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/evidence/evidence-generator.js +15 -8
- 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/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 +26 -0
- package/dist/services/scan/file-size-baseline.js +150 -0
- package/dist/services/scan/file-size-scan.d.ts +42 -3
- package/dist/services/scan/file-size-scan.js +58 -42
- package/dist/services/scan/type-sanity-service.js +13 -3
- package/dist/services/skill/resume-detector.js +3 -3
- 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.js +2 -1
- package/dist/services/workflow/pipeline-verify-service.js +1 -1
- package/dist/services/workflow/workflow-skip-service.d.ts +0 -20
- package/dist/services/workflow/workflow-skip-service.js +3 -4
- 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 +10 -0
- package/dist/shared/incrementing-number.js +27 -0
- package/package.json +5 -5
- package/skills/bee/peaks-perf-audit/SKILL.md +1 -1
- package/skills/bee/peaks-prd/SKILL.md +1 -1
- 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 +5 -2
- 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/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +0 -23
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +0 -64
|
@@ -209,7 +209,7 @@ export async function verifyPipeline(options) {
|
|
|
209
209
|
// artifact is absent, so `unpromoted` mixes "never promoted" with
|
|
210
210
|
// "promoted on paper only" — the reason on each entry says which.
|
|
211
211
|
feedbackGates[0].detail = `${unpromoted.length} feedback memor${unpromoted.length === 1 ? 'y' : 'ies'} without a backed promotion: ${unpromoted.map((u) => `${u.name} (${u.reason})`).join('; ')}${exemptNote}`;
|
|
212
|
-
violations.push(`Gate H feedback-promotion FAILED: ${unpromoted.length} feedback memor${unpromoted.length === 1 ? 'y is' : 'ies are'} not yet promoted to an enforcement layer with a real artifact (${unpromoted.map((u) => u.name).join(', ')})${exemptNote}. A marker alone does not count: layer A needs a registered SOP manifest, layer B a hook command that runs something named after the rule in .peaks/.claude-settings-template.json, layer C a hard-floor category in src/services/code/mode-gate.ts. Run \`peaks feedback promote <memory-file> --layer <A|B|C>\` for each and read what it reports. See sops/feedback-promotion-sop.md.`);
|
|
212
|
+
violations.push(`Gate H feedback-promotion FAILED: ${unpromoted.length} feedback memor${unpromoted.length === 1 ? 'y is' : 'ies are'} not yet promoted to an enforcement layer with a real artifact (${unpromoted.map((u) => u.name).join(', ')})${exemptNote}. A marker alone does not count: layer A needs a registered SOP manifest, layer B a hook command that runs something named after the rule in .peaks/.claude-settings-template.json or the tracked .claude/settings.json, layer C a hard-floor category in src/services/code/mode-gate.ts. Run \`peaks feedback promote <memory-file> --layer <A|B|C>\` for each and read what it reports. See sops/feedback-promotion-sop.md.`);
|
|
213
213
|
nextActions.push(`Run \`peaks feedback promote <memory-file> --layer <A|B|C>\` for each feedback memory without a backed promotion to satisfy Gate H.`);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* Pure-function classifier (`canSkipSlice`) + side-effecting applicator
|
|
4
|
-
* (`applySkip`). Both are testable without filesystem mocks (the
|
|
5
|
-
* applicator accepts an injected `readSkipState` / `writeSkipState`
|
|
6
|
-
* pair so the unit tests use in-memory fakes; the production caller
|
|
7
|
-
* passes the real store from `workflow-state-store.ts`).
|
|
8
|
-
*
|
|
9
|
-
* Three rules (per RD §Why + Tech Doc §2-4):
|
|
10
|
-
* - Rule 1 (slice type allowlist): `bugfix` / `feature` / `refactor`
|
|
11
|
-
* can never skip QA, regardless of `--reason`. The allowlist is
|
|
12
|
-
* `['docs', 'config', 'chore']`.
|
|
13
|
-
* - Rule 2 (one-time semantics): if a skip-marker already exists for
|
|
14
|
-
* this rid AND the requested skip is the same → idempotent
|
|
15
|
-
* no-op (`applied: false, idempotent: true`). If different → deny
|
|
16
|
-
* with `reason: "rid already has a different skip applied"`.
|
|
17
|
-
* - Rule 3 (role-based authorization): scripts (caller kind derived
|
|
18
|
-
* from `$PEAKS_CALLER_ID` env var) MUST pass `--i-have-reviewed`
|
|
19
|
-
* in addition to `--reason`.
|
|
20
|
-
*/
|
|
21
1
|
import { type WorkflowSkipState } from './workflow-state-store.js';
|
|
22
2
|
import type { RequestType } from '../artifacts/artifact-prerequisites.js';
|
|
23
3
|
export type SkipArgs = {
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* from `$PEAKS_CALLER_ID` env var) MUST pass `--i-have-reviewed`
|
|
19
19
|
* in addition to `--reason`.
|
|
20
20
|
*/
|
|
21
|
+
import { execFileSync } from 'node:child_process';
|
|
22
|
+
import { userInfo } from 'node:os';
|
|
21
23
|
import { readSkipState, writeSkipState } from './workflow-state-store.js';
|
|
22
24
|
import { showRequestArtifact } from '../artifacts/request-artifact-service.js';
|
|
23
25
|
const SKIPPABLE_TYPES = ['docs', 'config', 'chore'];
|
|
@@ -190,8 +192,6 @@ function pathFromStateFile(projectRoot, sessionId, rid) {
|
|
|
190
192
|
* unavailable. Never throws. */
|
|
191
193
|
function resolveSkipAppliedBy() {
|
|
192
194
|
try {
|
|
193
|
-
// Lazy require so the unit tests can stub via process.env.
|
|
194
|
-
const { execFileSync } = require('node:child_process');
|
|
195
195
|
const out = execFileSync('git', ['config', '--global', 'user.name'], {
|
|
196
196
|
encoding: 'utf8',
|
|
197
197
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
@@ -207,8 +207,7 @@ function resolveSkipAppliedBy() {
|
|
|
207
207
|
// fall through
|
|
208
208
|
}
|
|
209
209
|
try {
|
|
210
|
-
const
|
|
211
|
-
const info = os.userInfo();
|
|
210
|
+
const info = userInfo();
|
|
212
211
|
return info.username;
|
|
213
212
|
}
|
|
214
213
|
catch {
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
/** One handler in a `hooks.PreToolUse` entry, in the shape this template declares. */
|
|
31
|
+
export type TemplateHookCommand = {
|
|
32
|
+
type: string;
|
|
33
|
+
command: string;
|
|
34
|
+
shell?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* One `hooks.PreToolUse` entry in the shape this template declares. The
|
|
38
|
+
* `matcher` + `hooks` pair is the entry's identity everywhere in this concern:
|
|
39
|
+
* `matcher` alone is not unique (two `Bash` entries), and whole-object identity
|
|
40
|
+
* would make a hand-edited entry unrecognizable and therefore unrepairable.
|
|
41
|
+
*/
|
|
42
|
+
export type TemplatePreToolUseEntry = {
|
|
43
|
+
matcher: string;
|
|
44
|
+
hooks: TemplateHookCommand[];
|
|
45
|
+
};
|
|
46
|
+
export declare function isPreToolUseEntry(value: unknown): value is TemplatePreToolUseEntry;
|
|
47
|
+
/**
|
|
48
|
+
* Is `entry` one this template used to declare and has since RETIRED?
|
|
49
|
+
*
|
|
50
|
+
* Each retirement gets its own narrow predicate — the shapes share neither a
|
|
51
|
+
* matcher nor a command form. An entry whose shape matches nothing here is not
|
|
52
|
+
* retired, and is preserved.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isRetiredTemplateEntry(entry: unknown): boolean;
|
|
@@ -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
|
+
*/
|