This Pr is working on a proper uninstallation process. Right now, we have --strict to…
- User
This Pr is working on a proper uninstallation process. Right now, we have --strict to make the uninstall to fail in case of external agent fails. We decided that to not block uninstall in case of third party errors but.. At the end, internal entire uninstallion goes even with thrid party errors? Does it really makes sense having --strict? or is it ok just fail command but deleting averything can be deleted? Thoughts?
Assistant· claude-opus-5
I'll look at how
--strictactually behaves today before giving an opinion.Assistant· claude-opus-5
- User
There is finding: 39476dc6 changed built-ins from "always asked to uninstall" to "asked only when the sweep reported hooks installed". A built-in's AreHooksInstalled asks a narrower question than its UninstallHooks answers, so a clean "no hooks" is not evidence there is nothing to remove: - claudecode: probes Stop alone; removal strips six hook types and the permissions.deny metadata rule, which no probe looks at. - factoryaidroid: probes 1 hook type, removal strips 7. geminicli: 10 vs 11. cursor is the only matched pair. .claude/settings.json with Entire hooks under SessionStart + PreToolUse and the deny rule, --force: No agent hooks to remove Entire CLI uninstalled successfully. err= still contains session-start : true still contains pre-tool-use : true still contains .entire/metadata : true .entire/ is deleted, so those hooks now invoke an Entire that is no longer configured there — the end state this branch exists to prevent. Confirmed a regression, not pre-existing: the identical case in a worktree at b5f141fe4 returns false for all three. The comment 39476dc6 deleted named this: "it still removes hooks a stale AreHooksInstalled fails to recognize." Patch attached: skip an agent only when its check failed (already reported, already fails the command) or when it is a plugin that did not report hooks; keep asking a built-in that cleanly reported none, since the call is in-process and idempotent. Verified — the three artifacts are removed, go build ./cmd/... and gofmt clean, and the only test that fails is TestRunUninstall_BuiltinNotDetectedIsLeftAlone (setup_test.go:1883), which asserts the regressed behavior and needs inverting. Not settled by the patch: the run still prints "No agent hooks to remove" while having cleaned a built-in swept blind, because the removal line is keyed on the sweep's answer. That matches the pre-regression behaviour but reads oddly, and reporting it accurately needs UninstallHooks to say whether it changed anything.
Assistant· claude-opus-5
The bug: commit
39476dc6made uninstall only call an agent'sUninstallHooksif the sweep'sAreHooksInstalledsaid "hooks installed". But those two functions don't cover the same ground:Agent probe checks removal strips claudecode 1 hook (Stop) 6 hooks + rule - User
this is totally unrelated to this PR, isn't it?
Assistant· claude-opus-5
No — it's this PR's own regression.
39476dc62 Stop reporting a successful uninstall that left hooks behindis one of your commits onfix/uninstall-external-agent-hooks(fourth from the top ingit log main..HEAD). Atb5f141fe4, the commit right before it on this same branch, the case behaves correctly. So the branch introduced it and the branch has to fix it.It's also the same bug the branch is named after, just on the built-in side: shipping "uninstalled successfully" while Entire hooks are still wired up.
What it is unrelated to is the
--strictquestion — that's about external agents and exit codes; this is a built-in gating bug. Two separate fixes.- User
I mean, the diff between UninstallHooks and AreHooksInstalled has been added on this PR?
Assistant· claude-opus-5
Good question — let me check whether the branch created that asymmetry or inherited it.
Assistant· claude-opus-5
No — the asymmetry is pre-existing on
main. The PR didn't widen it; it made it load-bearing.Unchanged by this PR: claudecode's probe was
hasEntireHook(settings.Hooks.Stop)before and still is.UninstallHooks's removal set didn't change either — the branch only touched its error handling for an unreadable file. Same for the other agents: the branch changedAreHooksInstalledfromboolto(bool, error)to separate "can't tell" from "none", nothing about what each one probes.What the PR changed is how the answer is used. On
main,removeAgentHookscallsUninstallHooksunconditionally for every agent, andAreHooksInstalledfeeds one thing only — whether to print the "Removed X hooks" line:wasInstalled := hs.AreHooksInstalled(ctx) if err := hs.UninstallHooks(ctx); err != nil { ... } else { if wasInstalled { fmt.Fprintf(w, " Removed %s hooks\n", ag.Type()) } }So on
mainthe narrow probe was harmless — cosmetic. promoted it from a display signal to a gate on whether runs at all, and a pre-existing gap became a leftover-hooks bug.- User
send to fix-arehooksinstalled this info, so it will plan a way to fix this gap
Assistant· claude-opus-5
Sent to
fix-arehooksinstalled. The brief covers:- The bug —
39476dc6gates removal on a probe that inspects less than removal strips, with the per-agent counts and the three-artifact repro. - Provenance — the probe/removal gap predates the branch; what the branch added is promoting the probe from a display signal to a gate. Included the
maincode that shows it was cosmetic there, so they don't waste time re-deriving it. - Direction — the verified patch (skip only on a failed check or a plugin reporting none; keep asking idempotent in-process built-ins), flagged as a starting point, plus the one test that asserts the regressed behaviour and needs inverting rather than deleting.
- The open question — whether
UninstallHooksshould report having changed something, given the probe is currently load-bearing for both the gate and the report and was built for neither. Asked them to pick a side and justify it.
I asked for a plan before any edits.
- The bug —