Skip to content

feat(hooks): add icm hook disable (#268) - #338

Merged
pszymkowiak merged 2 commits into
developfrom
feat/hook-disable-268-clean
Jul 24, 2026
Merged

feat(hooks): add icm hook disable (#268)#338
pszymkowiak merged 2 commits into
developfrom
feat/hook-disable-268-clean

Conversation

@pszymkowiak

Copy link
Copy Markdown
Contributor

Closes #268.

Adds icm hook disable — removes ICM's hooks from every detected AI tool while keeping everything else. Useful after an upgrade, or to stop hook-driven extraction without a full icm uninstall.

What it does

  • Strips ICM hook entries from Claude Code / Gemini / Codex / Copilot settings JSON (and removes the OpenCode plugin file), preserving:
    • each tool's non-ICM hooks,
    • the MCP server config,
    • your memory database and any unrelated settings.
  • Backs up each modified file to <file>.icm-bak-<ts> before writing.
  • --dry-run previews without changing anything.
  • ICM-only event arrays are dropped (no "SessionEnd": [] left behind).
  • Reversible: icm init --mode hook re-installs.

Why not just icm uninstall

icm uninstall removes all ICM config (hooks and MCP server) across tools. hook disable is the narrower, reversible "hooks only" operation #268 asked for.

Implementation notes

  • Reuses the per-tool hook-location catalog (extracted to hook_targets, now shared with icm doctor) and the existing check_icm_hook_command detection — no new heuristics.
  • Dispatched before open_store, so it only touches settings files and never opens/creates the DB.

Tests / validation

  • Unit: removes only ICM hooks (non-ICM entries + MCP + unrelated settings preserved, ICM-only events dropped, idempotent); --dry-run leaves the file byte-identical.
  • E2E on the binary against a temp HOME: 2 ICM hooks removed, othertool hook + mcpServers + otherSetting intact, backup written, dry-run correct, empty-home → "nothing to disable".
  • cargo clippy --all-targets -- -D warnings clean; 296 cli tests pass.

🤖 Generated with Claude Code

patrick and others added 2 commits July 24, 2026 11:43
Adds a command that strips ICM's hook entries from every detected AI tool
(Claude Code, Gemini, Codex, Copilot settings JSON + the OpenCode plugin file)
while preserving each tool's non-ICM hooks, the MCP server config, and your
memory database. It's the reverse of `icm init --mode hook` — useful after an
upgrade or to stop hook-driven extraction without a full `icm uninstall`.

- Backs up each modified settings file to `<file>.icm-bak-<ts>` before writing.
- `--dry-run` previews removals without touching anything.
- Reuses the existing per-tool hook-location catalog (extracted to
  `hook_targets`, shared with `icm doctor`) and ICM-hook detection
  (`check_icm_hook_command`).
- Dispatched before `open_store`, so it edits only settings files — it never
  opens or creates the DB.
- Re-enable with `icm init --mode hook`.

Tests: removes only ICM hooks (non-ICM entries, MCP config, and unrelated
settings preserved; ICM-only events dropped; idempotent) and dry-run leaves the
file byte-identical. Verified e2e against a temp HOME. clippy `-D warnings`
clean; 296 cli tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adversarial review flagged that rewriting a settings file drops JSONC comments
and reformats it (a backup is already written). Surface that in the command
output so it's expected, not a surprise.
@pszymkowiak
pszymkowiak merged commit 9c8c802 into develop Jul 24, 2026
7 checks passed
@rtk-ai-icm-ci rtk-ai-icm-ci Bot mentioned this pull request Jul 24, 2026
@pszymkowiak
pszymkowiak deleted the feat/hook-disable-268-clean branch July 28, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant