Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
feat(decisions): ask agents to record committed decisions by default (#4689)
Raghav Chamadiya9324cbcadb97
diff --git a/docs/agent/HOOKS.md b/docs/agent/HOOKS.mdindex 18c99cef3..aaa1bac17 100644--- a/docs/agent/HOOKS.md+++ b/docs/agent/HOOKS.md@@ -25,6 +25,7 @@ For the exact settings entries each install writes, see the| **SessionStart context** | Claude Code | `repowise init` | session `startup` / `resume` / `clear` | Index-freshness line, core-tool pointer, and the standing decisions relevant to this session || **PostToolUse enrichment** | Claude Code | `repowise init` | `Grep` / `Glob` / `Read` / `Edit` / `Write` / repowise MCP calls | Graph context on searches, read notices, edit-time decision and bug-history notices || **Wrong-path rescue** | Claude Code | `repowise init` | a path tool call that failed on a path this tree does not have | Names the file when exactly one indexed file carries that basename; silent otherwise |+| **Decision capture prompt** | Claude Code, Codex | `repowise init` and the Claude Code plugin; `repowise decision config capture-prompt --off` silences it per repository | a fresh `git commit` via `Bash` / `PowerShell` whose message states a choice | Once a session, asks the agent to record the decision with `repowise decision add --agent`; it lands as a candidate || **Coverage re-ingest** (opt-in) | Claude Code | `hooks.coverage_reingest: true`, then the next `repowise coverage add` / `init` / `update` | `Bash` / `PowerShell` | Re-ingests a fresh full-suite coverage report in the background || **Health gate** (opt-in) | Claude Code | `repowise hook health-gate install` | `git commit` / `git push` via `Bash` / `PowerShell` | Runs `repowise health check` on what the command records and blocks it when the gate fails ([details](../start/CI.md#before-an-agent-commits-or-pushes)) || **Command rewrite (distill)** | Claude Code, Codex, Cursor | `repowise hook rewrite install`, or Yes at the `repowise init` prompt | `Bash` / `PowerShell` (Cursor: `Shell`) | Rewrites noisy commands to `repowise distill <cmd>` |@@ -257,12 +258,17 @@ Flags and the `--reset` upgrade step: [CLI reference](../reference/CLI_REFERENCE| Claude Code | `PostToolUse` | `Grep\|Glob\|Read\|Edit\|Write\|mcp__.*[Rr]epowise.*__.*` | `~/.claude/settings.json` || Claude Code | `PostToolUseFailure` | `Read\|Edit\|Write\|Grep\|Glob\|NotebookEdit` | `~/.claude/settings.json` || Claude Code | `PreToolUse` (opt-in rewrite) | `Bash\|PowerShell` | `~/.claude/settings.json` |-| Claude Code | `PostToolUse` (opt-in decision capture prompt) | `Bash\|PowerShell` | `~/.claude/settings.json` |+| Claude Code | `PostToolUse` (decision capture prompt) | `Bash\|PowerShell` | `~/.claude/settings.json`, or the plugin's `hooks.json` || Claude Code | `PostToolUse` and `PostToolUseFailure` (opt-in coverage re-ingest) | `Bash\|PowerShell` | the repo's `.claude/settings.local.json` || Codex | `SessionStart` | `startup\|resume\|clear` | the repo's `.codex/hooks.json` || Codex | `PostToolUse` | `Bash\|shell_command`, `apply_patch\|Edit\|Write` | the repo's `.codex/hooks.json` || Cursor | `preToolUse` (opt-in rewrite) | `Shell` | `~/.cursor/hooks.json` |+The capture prompt's entry checks the payload for `git commit` in the shell+and starts `repowise-augment` only on a match, so any other shell call costs+only the shell start. `init` skips it when the repowise plugin already ships+it, so it never runs twice.+The coverage re-ingest entries are written by the next `repowise coverage add`,`init` or `update` once `hooks.coverage_reingest: true` is set, and removed whenthe key is false or gone. Command strings, the presence guard and the otherdiff --git a/docs/layers/DECISIONS.md b/docs/layers/DECISIONS.mdindex c224ba353..19c585258 100644--- a/docs/layers/DECISIONS.md+++ b/docs/layers/DECISIONS.md@@ -170,6 +170,9 @@ What gets stored depends on how you add it:- Flags (`--title` and `--decision`) store a candidate (`proposed`). A personanswering the prompts has reviewed the decision; a script or agent inferringone has not. Promote it with `repowise decision confirm ID`.+- After a commit whose message states a choice, a hook asks the agent once a+ session to record it with `decision add`. On by default;+ `repowise decision config capture-prompt --off` turns it off.- `--agent SLUG` marks a candidate an agent reasoned out itself. Unlike aperson's manual entry, accepting it needs an evidence reference(`--evidence-commit` on add, or `--evidence` on confirm).diff --git a/docs/reference/CLI_REFERENCE.md b/docs/reference/CLI_REFERENCE.mdindex 7be3f4aba..e06b49d13 100644--- a/docs/reference/CLI_REFERENCE.md+++ b/docs/reference/CLI_REFERENCE.md@@ -968,7 +968,7 @@ repowise decision config show # resolved capture policyrepowise decision config preset NAME # default | off | local_only | balanced | fullrepowise decision config discovery # broad discovery call budgetrepowise decision config agent-acceptance --on|--off # may an agent grant authority? (on)-repowise decision config capture-prompt --on|--off # agent records what it committed (off);+repowise decision config capture-prompt --on|--off # agent records what it committed (on);# --on installs the shell hookrepowise decision source list # source registry and staterepowise decision source set SRC --on|--off # switch one sourcediff --git a/docs/reference/CONFIG.md b/docs/reference/CONFIG.mdindex 4aa540206..39c8a3b38 100644--- a/docs/reference/CONFIG.md+++ b/docs/reference/CONFIG.md@@ -368,7 +368,7 @@ decisions:| `discovery.max_input_tokens` | `30000` | Per discovery pass, 2000-60000. || `harnesses` | `[claude_code]` | Whose transcripts the session lane reads; add `codex`. || `agent_acceptance` | `true` | Whether an agent may grant a decision authority, signed as itself. |-| `capture_prompt` | `false` | Ask the agent to record what it just committed. |+| `capture_prompt` | `true` | Ask the agent to record what it just committed. |### Sources@@ -415,16 +415,16 @@ Neither is about capture, and no preset changes them.agent's with the signing session, on every surface, never as yours. Off: anagent can propose and withdraw authority, never grant it. `false` is writtento the config so it survives a reload.-- `capture_prompt` on: a successful `git commit` with two or more decision- signals prompts the agent, once per session, to run `repowise decision add`;- never for a commit a record already cites, and only as a proposal. An agent- cannot decline a hook, hence off by default.-- `repowise decision config capture-prompt --on` also adds a separate- `Bash|PowerShell` PostToolUse entry (the shared matcher excludes shell tools:- 51% of hook invocations for 0.7% of emissions); `--off` removes it.-- That entry is per install: other repositories pay a process start on shell- calls and emit nothing unless enabled, and switching it off here turns it off- for all.+- `capture_prompt` on (default): a successful `git commit` with two or more+ decision signals prompts the agent, once per session, to run+ `repowise decision add`; never for a commit a record already cites, and only+ as a proposal. `false` is written to the config so it survives a reload.+- It fires from a separate `Bash|PowerShell` PostToolUse entry, which `init`+ and the Claude Code plugin install. The entry tests the payload for+ `git commit` in the shell, so other shell calls never start Python.+- `repowise decision config capture-prompt --off` switches the prompt off for+ one repository and leaves the per-install entry, which stays silent there.+ `--on` reinstalls the entry if it is missing.### From the CLIdiff --git a/docs/reference/HOOKS_REFERENCE.md b/docs/reference/HOOKS_REFERENCE.mdindex c3b59b4b6..ae3e1d27a 100644--- a/docs/reference/HOOKS_REFERENCE.md+++ b/docs/reference/HOOKS_REFERENCE.md@@ -11,7 +11,7 @@ hand. For what each hook does and when it fires, see [HOOKS.md](../agent/HOOKS.m| Claude Code | `PostToolUse` | `Grep\|Glob\|Read\|Edit\|Write\|mcp__.*[Rr]epowise.*__.*` | `repowise-augment` (guarded) | `~/.claude/settings.json` || Claude Code | `PostToolUseFailure` | `Read\|Edit\|Write\|Grep\|Glob\|NotebookEdit` | `repowise-augment` (guarded) | `~/.claude/settings.json` || Claude Code | `PreToolUse` (opt-in) | `Bash\|PowerShell` | `repowise-rewrite` | `~/.claude/settings.json` |-| Claude Code | `PostToolUse` (opt-in decision capture prompt) | `Bash\|PowerShell` | `repowise-augment` (guarded) | `~/.claude/settings.json` |+| Claude Code | `PostToolUse` (decision capture prompt) | `Bash\|PowerShell` | `repowise-augment`, only when the payload holds `git commit` (guarded) | `~/.claude/settings.json`, or the plugin's `hooks.json` || Claude Code | `PostToolUse` and `PostToolUseFailure` (opt-in coverage re-ingest) | `Bash\|PowerShell` | `repowise-augment --coverage-only` (guarded) | the repo's `.claude/settings.local.json` || Claude Code | `PreToolUse` (opt-in health gate) | `Bash\|PowerShell` | `repowise-augment --health-gate` (guarded) | the repo's `.claude/settings.local.json` || Codex | `PreToolUse` (opt-in) | the shell tool | `repowise-rewrite --agent codex` | `~/.codex/hooks.json` |@@ -23,7 +23,7 @@ Which switch turns each opt-in entry on:| Entry | Switch ||-------|--------|| Command rewrite | `repowise hook rewrite install`, or Yes at the `repowise init` prompt |-| Decision capture prompt | `repowise decision config capture-prompt --on` ([decisions](../layers/DECISIONS.md)). The entry is per install, so one repo opting in adds a process start on shell calls for every repo on the machine; repos with the policy off return at once |+| Decision capture prompt | On by default; `init` and the plugin install the entry, `repowise decision config capture-prompt --off` turns it off for one repo ([decisions](../layers/DECISIONS.md)). The entry is per install; a shell call that is not a commit costs one shell start and never starts Python || Coverage re-ingest | `hooks.coverage_reingest: true` in `.repowise/config.yaml`, applied by the next `repowise coverage add`, `init` or `update` ([test intelligence](../layers/TEST_INTELLIGENCE.md)) || Health gate | `repowise hook health-gate install`, which writes `hooks.health_gate: true` and the entry together |diff --git a/packages/cli/src/repowise/cli/commands/augment_cmd/decision_capture.py b/packages/cli/src/repowise/cli/commands/augment_cmd/decision_capture.pyindex 15672ecd2..75270f054 100644--- a/packages/cli/src/repowise/cli/commands/augment_cmd/decision_capture.py+++ b/packages/cli/src/repowise/cli/commands/augment_cmd/decision_capture.py@@ -53,7 +53,7 @@ _PROMPT = ("[repowise] Commit {sha} states a choice and nothing records it. If it is a ""decision a future edit should follow, record it while you still have the ""reasoning:\n"- " repowise decision add --title '<short>' --decision '<what you chose>' "+ " repowise decision add --agent <your slug> --title '<short>' --decision '<what you chose>' ""--rationale '<why, and what you rejected>' --affects <path> ""--evidence-commit {sha} --format json\n"" Lands as a candidate for review, never as a rule. Once a session. "@@ -90,8 +90,8 @@ def _notice(tool_input: dict, tool_output: object, cwd: str, session_id: str) ->repo_path = _find_repo_root(Path(cwd))if repo_path is None or not (repo_path / ".repowise").exists():return None- # Checked before the session state is read: the switch ships off, so the- # opted-out repository should pay one config read and nothing else.+ # Checked before the session state is read: an opted-out repository+ # should pay one config read and nothing else.if not _capture_enabled(repo_path):return None# ``.repowise`` marks the indexed repository, not the git one. This tree@@ -152,7 +152,7 @@ def _failed(tool_output: object) -> bool:def _capture_enabled(repo_path: Path) -> bool:- """Whether this repository switched the prompt on. Off is the default.+ """Whether this repository has the prompt on. On is the default.``decisions.enabled`` gates it too. That flag is the master switch forcapture and ``preset off`` is how a repository says it wants none, so adiff --git a/packages/cli/src/repowise/cli/commands/decision_config_cmd.py b/packages/cli/src/repowise/cli/commands/decision_config_cmd.pyindex 59b51ff6a..01153b558 100644--- a/packages/cli/src/repowise/cli/commands/decision_config_cmd.py+++ b/packages/cli/src/repowise/cli/commands/decision_config_cmd.py@@ -136,7 +136,7 @@ def _emit(repo_path: Path, resolution, fmt: str) -> None:)elif not claude_code_capture_hook_installed():# The flag is per repository and the hook is per install, so the- # two drift: another repository's --off removes the shared entry.+ # two drift: a settings file from before the entry shipped lacks it.console.print(" [yellow] ...but no shell hook is installed to fire it. ""Re-run `decision config capture-prompt --on`.[/yellow]"@@ -372,10 +372,14 @@ def config_capture_prompt() -> None:"""Ask the agent to record a decision after a commit that states one.- Off by default. An agent cannot decline a hook, so this fires at most once+ On by default. An agent cannot decline a hook, so this fires at most oncea session, only on a commit whose message carries two or more decisionsignals, and never on one a record already cites. It proposes; nothing isrecorded without the agent running `repowise decision add`.++ `--off` is per repository and leaves the per-install shell hook in place:+ the hook starts nothing on a shell call that is not a commit, and stays+ silent in a repository with the prompt off."""from repowise.cli.commands.decision_cmd import _resolve_decision_repo@@ -387,12 +391,13 @@ def config_capture_prompt(# The flag is per repository; the hook it fires from is a per-install# matcher, and the shared one deliberately excludes the shell tools.# Writing the flag without this would store a switch nothing reads.+ # Off removes nothing: other repositories rely on the same entry.from repowise.cli.editor_integrations.claude_config import (claude_code_capture_hook_installed,set_claude_code_capture_hook,)- settings = set_claude_code_capture_hook(bool(enabled))+ settings = set_claude_code_capture_hook(True) if enabled else Noneif fmt == "json":emit_json({@@ -412,19 +417,10 @@ def config_capture_prompt("`repowise init` or install the editor integration first.[/yellow]")return- if settings is None:- return- if enabled:- console.print(- f"[dim]Added a shell PostToolUse hook to {settings}. Other "- "repositories on this machine pay a process start on shell calls "- "and emit nothing unless they switch this on too.[/dim]"- )- else:+ if settings is not None:console.print(- f"[dim]Removed the shell PostToolUse hook from {settings}. Any "- "other repository using the capture prompt needs "- "`capture-prompt --on` again.[/dim]"+ f"[dim]Updated the shell PostToolUse hook in {settings}. A shell call "+ "that is not a commit starts nothing.[/dim]")diff --git a/packages/cli/src/repowise/cli/editor_integrations/claude_config.py b/packages/cli/src/repowise/cli/editor_integrations/claude_config.pyindex 14deb525d..568fc1847 100644--- a/packages/cli/src/repowise/cli/editor_integrations/claude_config.py+++ b/packages/cli/src/repowise/cli/editor_integrations/claude_config.py@@ -175,8 +175,8 @@ def enable_tool_search_in_claude_code() -> Path | None:# paid before repowise reads the payload, so no gate inside the handler can# avoid it — the only lever is the matcher. Shell commands were also paying it# twice, here and again for the ``repowise-rewrite`` PreToolUse hook.-# SessionStart already carries the freshness line, so what is given up is a-# mid-session commit going unflagged until the next session.+# SessionStart already carries the freshness line. A commit still reaches the+# handler through :data:`_CAPTURE_MATCHER`'s entry, which gates in the shell.## Claude Code only. ``_handle_bash_post`` stays in the augment dispatcher:# Codex has no Read/Grep/Glob tools and no SessionStart block, so the shell is@@ -217,16 +217,28 @@ _FAILURE_MATCHER = "Read|Edit|Write|Grep|Glob|NotebookEdit"#: The shell tools, as their own PostToolUse entry rather than widened into#: :data:`_AUGMENT_MATCHER`. The capture prompt is the only thing that needs-#: them, it is off by default, and the narrowing of the shared matcher is a-#: measured decision this must not quietly reverse: 51% of hook invocations-#: for 0.7% of emissions. A separate entry means the cost is paid only where-#: the prompt is switched on, and removing it is removing one entry.+#: them, and the narrowing of the shared matcher is a measured decision this+#: must not quietly reverse: 51% of hook invocations for 0.7% of emissions.+#: That cost was a Python start on every shell call; :data:`_CAPTURE_HOOK_COMMAND`+#: gates in the shell instead, so a call that is not a commit costs only the+#: shell the host already spawns for the hook.#:#: **Never add this to :data:`_LEGACY_AUGMENT_MATCHERS`.** That list is what#: the self-heal rewrites to the narrow matcher, and this entry exists#: precisely to survive it._CAPTURE_MATCHER = "Bash|PowerShell"+#: Starts ``repowise-augment`` only when the payload mentions ``git commit``,+#: the one command the capture prompt answers. ``$(cat)`` rather than a+#: builtin read: bash's ``read`` takes a pipe one byte at a time, and+#: ``/dev/stdin`` does not resolve for a Windows pipe under Git Bash. The+#: plugin's ``hooks.json`` ships this exact string.+_CAPTURE_HOOK_COMMAND = (+ 'input=$(cat); case "$input" in *"git commit"*) '+ "if command -v repowise-augment >/dev/null 2>&1; then "+ 'printf "%s" "$input" | repowise-augment; fi;; esac'+)+def _capture_entry() -> dict:return {@@ -234,7 +246,7 @@ def _capture_entry() -> dict:"hooks": [{"type": "command",- "command": _AUGMENT_HOOK_COMMAND,+ "command": _CAPTURE_HOOK_COMMAND,"timeout": 10,"statusMessage": "Checking for a decision to record...",}@@ -246,22 +258,62 @@ def _is_capture_entry(entry: object) -> bool:if not isinstance(entry, dict) or entry.get("matcher") != _CAPTURE_MATCHER:return Falseentry_hooks = _hooks_of(entry)- return bool(entry_hooks) and all(_is_repowise_hook(h) for h in entry_hooks)+ # The coverage and health-gate entries share the shell matcher; they are+ # repo-local today, but a sync here must never take one for this.+ return bool(entry_hooks) and all(+ _is_repowise_hook(h) and not _is_coverage_hook(h) and not _is_health_gate_hook(h)+ for h in entry_hooks+ )+++def _repowise_plugin_paths() -> list[Path]:+ """Install paths of every enabled repowise Claude Code plugin."""+ try:+ settings_path = _claude_code_settings_path()+ settings = json.loads(settings_path.read_text(encoding="utf-8"))+ index_path = settings_path.parent / "plugins" / "installed_plugins.json"+ installed = json.loads(index_path.read_text(encoding="utf-8")).get("plugins") or {}+ enabled = settings.get("enabledPlugins") or {}+ keys = [k for k, on in enabled.items() if on and str(k).startswith("repowise@")]+ return [Path(i["installPath"]) for k in keys for i in installed.get(k) or []]+ except (OSError, ValueError, KeyError, TypeError, AttributeError):+ return []+++def _plugin_ships_capture_hook() -> bool:+ """Whether an enabled repowise plugin already carries the shell entry.++ Claude Code runs a plugin's hook and the same hook in settings.json+ separately, so installing ours beside the plugin's would start the shell+ twice on every shell call. Unreadable plugin state reads as "no": being+ wrong that way costs one extra shell start, never a missing prompt.+ """+ for path in _repowise_plugin_paths():+ try:+ hooks = json.loads((path / "hooks" / "hooks.json").read_text(encoding="utf-8"))+ entries = hooks["hooks"]["PostToolUse"]+ except (OSError, ValueError, KeyError, TypeError):+ continue+ if isinstance(entries, list) and any(_is_capture_entry(e) for e in entries):+ return True+ return Falsedef set_claude_code_capture_hook(enabled: bool) -> Path | None:- """Add or remove the shell PostToolUse entry the capture prompt needs.+ """Add, refresh or remove the shell PostToolUse entry the capture prompt needs.The switch owns its own prerequisite: `decisions.capture_prompt` is aper-repository policy, but the hook it fires from is a per-installmatcher, so turning the policy on without this writes a flag nothing- reads. Returns the settings file when it changed, else ``None``.-- The entry is per *install*, so one repository opting in widens the surface- for every repository on this machine. They pay a process start on shell- calls and nothing else — the handler returns before any work when their- own policy is off — and turning it off here narrows it back for all of- them, which is why the caller says so.+ reads. Where the repowise plugin already ships the entry, ours is left+ out (and removed), so the hook runs once. Returns the settings file when+ it changed, else ``None``.++ The entry is per *install* and ships on with the prompt: ``init``, the+ self-heal and the plugin all put it in place. Every repository on this+ machine pays a shell start on shell calls and nothing else, since the+ entry starts Python only for a commit, so a repository that turns the+ prompt off keeps the entry and stays silent."""settings_path = _claude_code_settings_path()if not settings_path.exists():@@ -271,32 +323,45 @@ def set_claude_code_capture_hook(enabled: bool) -> Path | None:except Exception:return None- hooks = existing.setdefault("hooks", {}) if enabled else existing.get("hooks")+ want = enabled and not _plugin_ships_capture_hook()+ hooks = existing.setdefault("hooks", {}) if want else existing.get("hooks")if not isinstance(hooks, dict):return Noneentries = hooks.get("PostToolUse")if not isinstance(entries, list):- if not enabled:+ if not want:return Noneentries = []hooks["PostToolUse"] = entries- present = any(_is_capture_entry(e) for e in entries)- if enabled == present:+ if not _sync_capture_entry(entries, want):return None- if enabled:- entries.append(_capture_entry())- else:- entries[:] = [e for e in entries if not _is_capture_entry(e)]- if not entries:- hooks.pop("PostToolUse", None)- if not hooks:- existing.pop("hooks", None)+ if not entries:+ hooks.pop("PostToolUse", None)+ if not hooks:+ existing.pop("hooks", None)return settings_path if _write_settings(settings_path, existing) else None+def _sync_capture_entry(entries: list, want: bool) -> bool:+ """Leave exactly the current capture entry in *entries* when *want*, else none.++ An entry from an older release starts Python on every shell call, so it is+ replaced rather than kept. Returns whether *entries* changed.+ """+ ours = [e for e in entries if _is_capture_entry(e)]+ if ours == ([_capture_entry()] if want else []):+ return False+ entries[:] = [e for e in entries if not _is_capture_entry(e)]+ if want:+ entries.append(_capture_entry())+ return True++def claude_code_capture_hook_installed() -> bool:- """Whether the shell PostToolUse entry is present."""+ """Whether the shell PostToolUse entry is present, ours or the plugin's."""+ if _plugin_ships_capture_hook():+ return Truesettings_path = _claude_code_settings_path()if not settings_path.exists():return False@@ -528,7 +593,8 @@ def install_claude_code_hooks() -> Path | None:"""Register the augment hooks in ~/.claude/settings.json.PostToolUse enriches Grep/Glob results and emits- Read-intelligence notices; SessionStart injects the live index-freshness+ Read-intelligence notices, and a shell entry asks for a decision after a+ commit; SessionStart injects the live index-freshnesscontext block; PostToolUseFailure carries the wrong-path rescue. Existinguser hooks are preserved."""@@ -577,6 +643,9 @@ def install_claude_code_hooks() -> Path | None:# AttributeError the OSError handler below would not catch._backfill_event(hooks, "SessionStart", _session_start_entry)_backfill_event(hooks, "PostToolUseFailure", _failure_entry)+ # The capture prompt ships on, so its shell entry is part of the+ # install, unless the plugin already runs the same one.+ _sync_capture_entry(post_hooks, not _plugin_ships_capture_hook())settings_path.write_text(json.dumps(existing, indent=2) + "\n", encoding="utf-8")return settings_path@@ -1159,6 +1228,10 @@ def migrate_claude_code_hooks() -> bool:changed = Trueif _backfill_event(hooks, "PostToolUseFailure", _failure_entry):changed = True+ # The capture prompt ships on: add its shell entry, or refresh one an+ # older release wrote, unless the plugin already runs it.+ if _sync_capture_entry(post, not _plugin_ships_capture_hook()):+ changed = Trueif not changed:return Falsediff --git a/packages/core/src/repowise/core/analysis/decisions/policy.py b/packages/core/src/repowise/core/analysis/decisions/policy.pyindex 93c485123..1327a95c3 100644--- a/packages/core/src/repowise/core/analysis/decisions/policy.py+++ b/packages/core/src/repowise/core/analysis/decisions/policy.py@@ -348,9 +348,10 @@ class DecisionPolicy:#: default: agents do most of the reviewing, and every grant is signed#: as the agent's, never a person's. ``--off`` restores a person-only gate.agent_acceptance: bool = True- #: Whether the commit hook asks the agent to record a decision. An agent- #: cannot decline a hook, so this ships off and no preset turns it on.- capture_prompt: bool = False+ #: Whether the commit hook asks the agent to record a decision. On by+ #: default: it fires at most once a session, only on a commit that states+ #: a choice, and what it records lands as a candidate, never a rule.+ capture_prompt: bool = True# -- queries ---------------------------------------------------------@@ -499,8 +500,8 @@ class DecisionPolicy:block["harnesses"] = list(self.harnesses)if not self.agent_acceptance:block["agent_acceptance"] = False- if self.capture_prompt:- block["capture_prompt"] = True+ if not self.capture_prompt:+ block["capture_prompt"] = Falsereturn blockdef to_dict(self, *, provider_available: bool = True) -> dict[str, Any]:@@ -653,6 +654,21 @@ def _as_bool(value: Any) -> bool | None:return value if isinstance(value, bool) else None+def _default_on_switch(raw: dict, key: str, warnings: list[str]) -> bool:+ """A switch that ships on: absent reads as on, a boolean as itself.++ Present but not a boolean (a quoted "no") was written by someone saying+ something, so it reads as off, not on.+ """+ value = _as_bool(raw.get(key))+ if value is not None:+ return value+ if key not in raw:+ return True+ warnings.append(f"`decisions.{key}` is not a boolean; treating it as false.")+ return False++def _states_enabled(raw_source: Any) -> bool:"""Does a raw ``sources.<key>`` entry state an on/off of its own?@@ -782,21 +798,8 @@ def resolve_policy(repo_config: dict[str, Any] | None) -> PolicyResolution:discovery = _resolve_discovery(raw.get("discovery"), warnings)harnesses = _resolve_harnesses(raw.get("harnesses"), warnings)- # Absent means the default, on. Present but not a boolean (a quoted "no")- # was written by someone saying something, so it reads as off, not on.- agent_acceptance = _as_bool(raw.get("agent_acceptance"))- if agent_acceptance is None:- agent_acceptance = "agent_acceptance" not in raw- if not agent_acceptance:- warnings.append(- "`decisions.agent_acceptance` is not a boolean; treating it as false."- )-- capture_prompt = _as_bool(raw.get("capture_prompt"))- if capture_prompt is None:- if "capture_prompt" in raw:- warnings.append("`decisions.capture_prompt` is not a boolean; ignoring it.")- capture_prompt = False+ agent_acceptance = _default_on_switch(raw, "agent_acceptance", warnings)+ capture_prompt = _default_on_switch(raw, "capture_prompt", warnings)for field in set(raw) - POLICY_CONFIG_KEYS:warnings.append(f"Unknown key `decisions.{field}`; ignoring it.")diff --git a/plugins/claude-code/hooks/hooks.json b/plugins/claude-code/hooks/hooks.jsonindex 1de5312ca..8a6a43434 100644--- a/plugins/claude-code/hooks/hooks.json+++ b/plugins/claude-code/hooks/hooks.json@@ -25,6 +25,17 @@"statusMessage": "Checking codebase context..."}]+ },+ {+ "matcher": "Bash|PowerShell",+ "hooks": [+ {+ "type": "command",+ "command": "input=$(cat); case \"$input\" in *\"git commit\"*) if command -v repowise-augment >/dev/null 2>&1; then printf \"%s\" \"$input\" | repowise-augment; fi;; esac",+ "timeout": 10,+ "statusMessage": "Checking for a decision to record..."+ }+ ]}],"PostToolUseFailure": [diff --git a/tests/unit/cli/data/agent_target_baseline.json b/tests/unit/cli/data/agent_target_baseline.jsonindex 77c9f1d63..2db6c4722 100644--- a/tests/unit/cli/data/agent_target_baseline.json+++ b/tests/unit/cli/data/agent_target_baseline.json@@ -39,7 +39,7 @@},"user": {".claude/settings.json": {- "content": "{\n \"mcpServers\": {\n \"repowise\": {\n \"command\": \"/pinned/bin/repowise\",\n \"args\": [\n \"mcp\",\n \"{REPO}\",\n \"--transport\",\n \"stdio\"\n ],\n \"description\": \"repowise: codebase intelligence \\u2014 docs, graph, git signals, dead code, decisions\"\n }\n },\n \"hooks\": {\n \"PostToolUse\": [\n {\n \"matcher\": \"Grep|Glob|Read|Edit|Write|mcp__.*[Rr]epowise.*__.*\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"if command -v repowise-augment >/dev/null 2>&1; then exec repowise-augment; fi\",\n \"timeout\": 10,\n \"statusMessage\": \"Checking codebase context...\"\n }\n ]\n }\n ],\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"if command -v repowise-augment >/dev/null 2>&1; then exec repowise-augment; fi\",\n \"timeout\": 10,\n \"statusMessage\": \"Loading repowise context...\"\n }\n ]\n }\n ],\n \"PostToolUseFailure\": [\n {\n \"matcher\": \"Read|Edit|Write|Grep|Glob|NotebookEdit\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"if command -v repowise-augment >/dev/null 2>&1; then exec repowise-augment; fi\",\n \"timeout\": 10,\n \"statusMessage\": \"Checking codebase context...\"\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash|PowerShell\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"repowise-rewrite\",\n \"timeout\": 5,\n \"statusMessage\": \"Distilling command output...\"\n }\n ]\n }\n ]\n },\n \"env\": {\n \"ENABLE_TOOL_SEARCH\": \"true\"\n },\n \"permissions\": {\n \"allow\": [\n \"Bash(repowise distill:*)\",\n \"PowerShell(repowise distill:*)\"\n ]\n }\n}\n",+ "content": "{\n \"mcpServers\": {\n \"repowise\": {\n \"command\": \"/pinned/bin/repowise\",\n \"args\": [\n \"mcp\",\n \"{REPO}\",\n \"--transport\",\n \"stdio\"\n ],\n \"description\": \"repowise: codebase intelligence \\u2014 docs, graph, git signals, dead code, decisions\"\n }\n },\n \"hooks\": {\n \"PostToolUse\": [\n {\n \"matcher\": \"Grep|Glob|Read|Edit|Write|mcp__.*[Rr]epowise.*__.*\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"if command -v repowise-augment >/dev/null 2>&1; then exec repowise-augment; fi\",\n \"timeout\": 10,\n \"statusMessage\": \"Checking codebase context...\"\n }\n ]\n },\n {\n \"matcher\": \"Bash|PowerShell\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"input=$(cat); case \\\"$input\\\" in *\\\"git commit\\\"*) if command -v repowise-augment >/dev/null 2>&1; then printf \\\"%s\\\" \\\"$input\\\" | repowise-augment; fi;; esac\",\n \"timeout\": 10,\n \"statusMessage\": \"Checking for a decision to record...\"\n }\n ]\n }\n ],\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"if command -v repowise-augment >/dev/null 2>&1; then exec repowise-augment; fi\",\n \"timeout\": 10,\n \"statusMessage\": \"Loading repowise context...\"\n }\n ]\n }\n ],\n \"PostToolUseFailure\": [\n {\n \"matcher\": \"Read|Edit|Write|Grep|Glob|NotebookEdit\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"if command -v repowise-augment >/dev/null 2>&1; then exec repowise-augment; fi\",\n \"timeout\": 10,\n \"statusMessage\": \"Checking codebase context...\"\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash|PowerShell\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"repowise-rewrite\",\n \"timeout\": 5,\n \"statusMessage\": \"Distilling command output...\"\n }\n ]\n }\n ]\n },\n \"env\": {\n \"ENABLE_TOOL_SEARCH\": \"true\"\n },\n \"permissions\": {\n \"allow\": [\n \"Bash(repowise distill:*)\",\n \"PowerShell(repowise distill:*)\"\n ]\n }\n}\n","newlines": "platform"},".codex/hooks.json": {diff --git a/tests/unit/cli/test_augment_decision_capture.py b/tests/unit/cli/test_augment_decision_capture.pyindex b337e60b7..e11526898 100644--- a/tests/unit/cli/test_augment_decision_capture.py+++ b/tests/unit/cli/test_augment_decision_capture.py@@ -1,7 +1,7 @@"""The capture prompt: the gates, not the wording.An agent cannot decline a hook, so every gate is a cost control and each one-is tested on its own. The contract: off unless the repository switched it on,+is tested on its own. The contract: on unless the repository switched it off,at most once per session, only after a *fresh* commit in *this* repository,only on a message carrying two or more decision signals, and never for acommit a record already cites.@@ -124,13 +124,13 @@ def test_a_second_session_gets_its_own_ask(repo: Path) -> None:# --- the switch --------------------------------------------------------------def test_off_by_default(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:+def test_on_by_default(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:root = tmp_path / "repo"(root / ".repowise").mkdir(parents=True)_write_wiki(root, evidence=[])_fake_git(monkeypatch, root, _SHA, _MESSAGE)- assert _fire(root) is None+ assert _fire(root) is not Nonedef test_the_off_switch_turns_it_off(repo: Path) -> None:@@ -139,17 +139,31 @@ def test_the_off_switch_turns_it_off(repo: Path) -> None:assert _fire(repo) is None-def test_an_absent_key_resolves_to_off(tmp_path: Path) -> None:+def test_an_absent_key_resolves_to_on(tmp_path: Path) -> None:"""The parser's own default, not the dataclass field the parser overrides."""from repowise.core.analysis.decisions.policy_store import load_policyroot = tmp_path / "unconfigured"(root / ".repowise").mkdir(parents=True)+ assert load_policy(root).policy.capture_prompt is True+++def test_an_explicit_off_is_written_and_survives_a_reload(tmp_path: Path) -> None:+ """The block omits a defaulted setting, so off must be written out."""+ from repowise.core.analysis.decisions.policy import preset_policy+ from repowise.core.analysis.decisions.policy_store import load_policy, write_policy+ from repowise.core.repo_config import load_repo_config++ root = tmp_path / "off"+ (root / ".repowise").mkdir(parents=True)+ write_policy(root, preset_policy("default").with_capture_prompt(False))++ assert load_repo_config(root)["decisions"]["capture_prompt"] is Falseassert load_policy(root).policy.capture_prompt is False-def test_a_non_boolean_switch_warns_and_stays_off(tmp_path: Path) -> None:+def test_a_non_boolean_switch_warns_and_reads_as_off(tmp_path: Path) -> None:from repowise.core.analysis.decisions.policy_store import load_policyroot = tmp_path / "typo"@@ -382,6 +396,104 @@ def test_switching_on_adds_the_shell_entry(settings: Path) -> None:assert "Bash|PowerShell" in _post_matchers(settings)+def _install_plugin(settings: Path, *, with_capture: bool) -> None:+ """An enabled repowise plugin, in the layout Claude Code keeps it."""+ from repowise.cli.editor_integrations import claude_config++ install = settings.parent / "plugins" / "cache" / "repowise" / "repowise" / "9.9.9"+ (install / "hooks").mkdir(parents=True)+ post = [{"matcher": claude_config._AUGMENT_MATCHER, "hooks": [+ {"type": "command", "command": claude_config._AUGMENT_HOOK_COMMAND}]}]+ if with_capture:+ post.append(claude_config._capture_entry())+ (install / "hooks" / "hooks.json").write_text(+ json.dumps({"hooks": {"PostToolUse": post}}), encoding="utf-8"+ )+ (settings.parent / "plugins" / "installed_plugins.json").write_text(+ json.dumps({"version": 2, "plugins": {"repowise@repowise": [+ {"scope": "user", "installPath": str(install)}]}}),+ encoding="utf-8",+ )+ payload = json.loads(settings.read_text(encoding="utf-8"))+ payload["enabledPlugins"] = {"repowise@repowise": True}+ settings.write_text(json.dumps(payload), encoding="utf-8")+++def test_a_plugin_that_ships_the_entry_is_not_doubled(settings: Path) -> None:+ """Claude Code runs a plugin hook and a settings hook separately."""+ from repowise.cli.editor_integrations import claude_config++ claude_config.set_claude_code_capture_hook(True)+ _install_plugin(settings, with_capture=True)++ assert claude_config.set_claude_code_capture_hook(True) == settings+ assert "Bash|PowerShell" not in _post_matchers(settings)+ assert claude_config.claude_code_capture_hook_installed() is True+++def test_an_older_plugin_without_the_entry_still_gets_ours(settings: Path) -> None:+ from repowise.cli.editor_integrations import claude_config++ _install_plugin(settings, with_capture=False)++ assert claude_config.set_claude_code_capture_hook(True) == settings+ assert "Bash|PowerShell" in _post_matchers(settings)+++def test_an_entry_from_an_older_release_is_refreshed(settings: Path) -> None:+ """The old command started Python on every shell call; the gate is the fix."""+ from repowise.cli.editor_integrations import claude_config++ payload = json.loads(settings.read_text(encoding="utf-8"))+ payload["hooks"]["PostToolUse"].append({"matcher": "Bash|PowerShell", "hooks": [+ {"type": "command", "command": claude_config._AUGMENT_HOOK_COMMAND}]})+ settings.write_text(json.dumps(payload), encoding="utf-8")++ assert claude_config.set_claude_code_capture_hook(True) == settings++ entries = json.loads(settings.read_text(encoding="utf-8"))["hooks"]["PostToolUse"]+ assert [e for e in entries if e["matcher"] == "Bash|PowerShell"] == [+ claude_config._capture_entry()+ ]+++def test_init_installs_the_entry(settings: Path) -> None:+ """The prompt ships on, so the hook that fires it is part of the install."""+ from repowise.cli.editor_integrations import claude_config++ claude_config.install_claude_code_hooks()++ assert "Bash|PowerShell" in _post_matchers(settings)+++def test_init_leaves_it_to_a_plugin_that_ships_it(settings: Path) -> None:+ from repowise.cli.editor_integrations import claude_config++ _install_plugin(settings, with_capture=True)++ claude_config.install_claude_code_hooks()++ assert "Bash|PowerShell" not in _post_matchers(settings)+++def test_the_self_heal_adds_it_to_an_existing_install(settings: Path) -> None:+ """Existing installs predate the default; the once-per-version heal reaches them."""+ from repowise.cli.editor_integrations import claude_config++ assert claude_config.migrate_claude_code_hooks() is True++ assert "Bash|PowerShell" in _post_matchers(settings)+ assert claude_config.migrate_claude_code_hooks() is False+++def test_a_coverage_entry_is_never_taken_for_the_capture_entry() -> None:+ from repowise.cli.editor_integrations import claude_config++ assert not claude_config._is_capture_entry(claude_config._coverage_entry())+ assert not claude_config._is_capture_entry(claude_config._health_gate_entry())+ assert claude_config._is_capture_entry(claude_config._capture_entry())++def test_switching_off_removes_it(settings: Path) -> None:from repowise.cli.editor_integrations.claude_config import set_claude_code_capture_hookdiff --git a/tests/unit/cli/test_claude_plugin.py b/tests/unit/cli/test_claude_plugin.pyindex 4bb940f1e..a504df2e4 100644--- a/tests/unit/cli/test_claude_plugin.py+++ b/tests/unit/cli/test_claude_plugin.py@@ -96,7 +96,10 @@ def test_claude_plugin_hooks_match_installer() -> None:command = claude_config._AUGMENT_HOOK_COMMAND- assert rows("PostToolUse") == [(claude_config._AUGMENT_MATCHER, command)]+ assert rows("PostToolUse") == [+ (claude_config._AUGMENT_MATCHER, command),+ (claude_config._CAPTURE_MATCHER, claude_config._CAPTURE_HOOK_COMMAND),+ ]assert rows("SessionStart") == [(claude_config._SESSION_START_MATCHER, command)]assert rows("PostToolUseFailure") == [(claude_config._FAILURE_MATCHER, command)]@@ -110,6 +113,7 @@ def test_claude_plugin_hooks_match_installer() -> None:for entries in hooks.values()for entry in entriesfor hook in entry["hooks"]+ if entry.get("matcher") != claude_config._CAPTURE_MATCHER]assert commands == [command] * len(hooks)@@ -164,6 +168,101 @@ def test_the_augment_hook_is_silent_when_the_console_script_is_absent(tmp_path:assert proc.stderr == ""+def _fake_augment(bin_dir: Path, marker: Path) -> None:+ """A ``repowise-augment`` on PATH that records the payload it was given."""+ script = bin_dir / "repowise-augment"+ script.write_text(f"#!/bin/sh\ncat > '{marker.as_posix()}'\n", encoding="utf-8")+ script.chmod(0o755)+++def _run_capture_hook(shell: str, payload: dict, bin_dir: Path) -> None:+ import subprocess++ proc = subprocess.run(+ [shell, "-c", claude_config._CAPTURE_HOOK_COMMAND],+ input=json.dumps(payload),+ capture_output=True,+ text=True,+ env={**os.environ, "PATH": bin_dir.as_posix() + os.pathsep + os.environ.get("PATH", "")},+ )+ assert proc.returncode == 0, proc.stderr+ assert proc.stdout == ""+++def _shells() -> list[str]:+ """Git Bash or bash, plus a plain ``sh`` where it is a different shell (dash)."""+ import shutil++ found = [s for s in (_posix_bash(),) if s]+ sh = shutil.which("sh") if os.name != "nt" else None+ if sh and os.path.realpath(sh) != os.path.realpath(found[0] if found else ""):+ found.append(sh)+ return found+++def _shell_payload(command: str) -> dict:+ return {+ "hook_event_name": "PostToolUse",+ "tool_name": "Bash",+ "tool_input": {"command": command},+ "tool_response": {"stdout": "x" * 40_000, "stderr": ""},+ }+++def test_the_capture_hook_starts_nothing_for_a_shell_call_that_is_not_a_commit(+ tmp_path: Path,+) -> None:+ """The shell entry fires on every shell call, so the gate lives in the shell.++ A Python start is what made the shell matcher cost 51% of hook invocations;+ a call that is not a commit must never reach the console script.+ """+ shells = _shells()+ if not shells:+ pytest.skip("no POSIX shell available to execute a hook command")+ marker = tmp_path / "ran.json"+ _fake_augment(tmp_path, marker)++ for shell in shells:+ _run_capture_hook(shell, _shell_payload("npm test"), tmp_path)+ assert not marker.exists(), shell+++def test_the_capture_hook_hands_a_commit_to_augment_intact(tmp_path: Path) -> None:+ shells = _shells()+ if not shells:+ pytest.skip("no POSIX shell available to execute a hook command")+ marker = tmp_path / "ran.json"+ _fake_augment(tmp_path, marker)+ payload = _shell_payload('git commit -m "use sqlite, not postgres"')++ for shell in shells:+ _run_capture_hook(shell, payload, tmp_path)+ assert json.loads(marker.read_text(encoding="utf-8")) == payload, shell+ marker.unlink()+++def test_the_capture_hook_is_silent_when_the_console_script_is_absent(tmp_path: Path) -> None:+ bash = _posix_bash()+ if bash is None:+ pytest.skip("no POSIX bash available to execute a hook command")+ import shutil+ import subprocess++ # Coreutils stay reachable; only the console script is missing.+ cat_dir = Path(shutil.which("cat", path=os.environ.get("PATH")) or "/usr/bin/cat").parent+ proc = subprocess.run(+ [bash, "-c", claude_config._CAPTURE_HOOK_COMMAND],+ input=json.dumps(_shell_payload("git commit -m x")),+ capture_output=True,+ text=True,+ env={**os.environ, "PATH": f"{tmp_path}{os.pathsep}{cat_dir}"},+ )++ assert proc.returncode == 0, proc.stderr+ assert (proc.stdout, proc.stderr) == ("", "")++def test_claude_plugin_skills_have_metadata() -> None:skill_paths = sorted((PLUGIN_ROOT / "skills").glob("*/SKILL.md"))diff --git a/tests/unit/cli/test_mcp_config.py b/tests/unit/cli/test_mcp_config.pyindex cf1c167c0..55cda24a7 100644--- a/tests/unit/cli/test_mcp_config.py+++ b/tests/unit/cli/test_mcp_config.py@@ -518,6 +518,14 @@ def _repowise_entries(saved: dict, event: str) -> list:]+#: What a fresh install puts under PostToolUse: the augment entry, and the+#: capture prompt's shell entry, which ships on.+_INSTALLED_POST = [+ (claude_config._AUGMENT_MATCHER, claude_config._AUGMENT_HOOK_COMMAND),+ (claude_config._CAPTURE_MATCHER, claude_config._CAPTURE_HOOK_COMMAND),+]++def _post_repowise_entries(saved: dict) -> list:return _repowise_entries(saved, "PostToolUse")@@ -539,9 +547,7 @@ def test_install_claude_code_hooks_creates_missing_file(assert settings_path == tmp_path / ".claude" / "settings.json"saved = json.loads(settings_path.read_text(encoding="utf-8"))assert "PreToolUse" not in saved["hooks"]- assert _post_repowise_entries(saved) == [- (claude_config._AUGMENT_MATCHER, claude_config._AUGMENT_HOOK_COMMAND)- ]+ assert _post_repowise_entries(saved) == _INSTALLED_POSTassert _session_start_repowise_entries(saved) == [("startup|resume|clear", claude_config._AUGMENT_HOOK_COMMAND)]@@ -590,9 +596,7 @@ def test_install_claude_code_hooks_preserves_user_pretool_hooks(assert saved["hooks"]["PreToolUse"][0]["matcher"] == "Read"assert saved["hooks"]["PreToolUse"][0]["hooks"][0]["command"] == "echo read"# PostToolUse now has the repowise hook.- assert _post_repowise_entries(saved) == [- (claude_config._AUGMENT_MATCHER, claude_config._AUGMENT_HOOK_COMMAND)- ]+ assert _post_repowise_entries(saved) == _INSTALLED_POST# ---------------------------------------------------------------------------@@ -636,9 +640,7 @@ def test_install_claude_code_hooks_migrates_pre_0_6_1_command(saved = json.loads(settings_path.read_text(encoding="utf-8"))assert "PreToolUse" not in saved["hooks"]- assert _post_repowise_entries(saved) == [- (claude_config._AUGMENT_MATCHER, claude_config._AUGMENT_HOOK_COMMAND)- ]+ assert _post_repowise_entries(saved) == _INSTALLED_POSTdef test_install_claude_code_hooks_migrates_pre_0_6_2_matcher(@@ -676,9 +678,7 @@ def test_install_claude_code_hooks_migrates_pre_0_6_2_matcher(saved = json.loads(settings_path.read_text(encoding="utf-8"))assert "PreToolUse" not in saved["hooks"]- assert _post_repowise_entries(saved) == [- (claude_config._AUGMENT_MATCHER, claude_config._AUGMENT_HOOK_COMMAND)- ]+ assert _post_repowise_entries(saved) == _INSTALLED_POSTdef test_install_claude_code_hooks_idempotent_on_current_shape(@@ -732,9 +732,7 @@ def test_migrate_claude_code_hooks_handles_full_legacy_payload(saved = json.loads(settings_path.read_text(encoding="utf-8"))assert "PreToolUse" not in saved["hooks"]- assert _post_repowise_entries(saved) == [- (claude_config._AUGMENT_MATCHER, claude_config._AUGMENT_HOOK_COMMAND)- ]+ assert _post_repowise_entries(saved) == _INSTALLED_POST# Idempotent: a second run finds nothing to do.assert claude_config.migrate_claude_code_hooks() is False@@ -770,9 +768,7 @@ def test_migrate_claude_code_hooks_widens_legacy_matchers(assert claude_config.migrate_claude_code_hooks() is Truesaved = json.loads(settings_path.read_text(encoding="utf-8"))- assert _post_repowise_entries(saved) == [- (claude_config._AUGMENT_MATCHER, claude_config._AUGMENT_HOOK_COMMAND)- ]+ assert _post_repowise_entries(saved) == _INSTALLED_POSTdef test_migrate_claude_code_hooks_never_widens_user_matcher(@@ -799,7 +795,8 @@ def test_migrate_claude_code_hooks_never_widens_user_matcher(},{"type": "command", "command": "my-linter"},],- }+ },+ claude_config._capture_entry(),],# SessionStart and PostToolUseFailure already present so# their backfills (separate migrations) can't mask the@@ -877,7 +874,8 @@ def test_migrate_claude_code_hooks_noop_when_already_current({"matcher": claude_config._AUGMENT_MATCHER,"hooks": [{"type": "command", "command": claude_config._AUGMENT_HOOK_COMMAND}],- }+ },+ claude_config._capture_entry(),],"SessionStart": [{@@ -1169,7 +1167,8 @@ def test_plugin_hooks_json_mirrors_settings_entries(repo_root: Path) -> None:]assert rows("PostToolUse") == [- (claude_config._AUGMENT_MATCHER, claude_config._AUGMENT_HOOK_COMMAND)+ (claude_config._AUGMENT_MATCHER, claude_config._AUGMENT_HOOK_COMMAND),+ (claude_config._CAPTURE_MATCHER, claude_config._CAPTURE_HOOK_COMMAND),]assert rows("SessionStart") == [(claude_config._SESSION_START_MATCHER, claude_config._AUGMENT_HOOK_COMMAND)