feat(cli): add 'uninstall' command (closes #482)#491
Conversation
Closes tirth8205#482. Adds a symmetric counterpart to 'code-review-graph install' that walks the full inventory of files install creates and removes them — both per-repo and at user level. Per-repo it removes: - The .code-review-graph/ data directory and the legacy .code-review-graph.db. - Generated skill directories under .claude/skills, .gemini/skills, and .qoder/skills. - Our pre-commit hook block (preserving any user hooks that share the file). - The .code-review-graph/ entry from .gitignore. - The '<!-- code-review-graph MCP tools -->' section from CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules, .windsurfrules, QODER.md, the Kiro steering file, and the GitHub Copilot instruction file. User-level it removes: - ~/.code-review-graph/ (registry, daemon state, logs). - ~/.config/opencode/plugins/crg-plugin.ts. - Our entry from every MCP / hooks config we ever write: Codex (TOML), Cursor, Windsurf, Zed, Continue, Antigravity, Qwen, and Copilot CLI. All edits to shared configuration files are surgical: only the 'code-review-graph' entry is removed; other MCP servers, hooks, and content survive untouched. Flags: --dry-run preview without changing anything --yes / -y skip the confirmation prompt --repo PATH target a specific repo (default: cwd) --all-repos also sweep every repo in the registry --keep-data leave .code-review-graph/ data dirs in place --keep-user-configs skip the user-level pass Adds tests/test_uninstall.py with 18 tests covering: - Dry-run leaves the filesystem untouched. - Per-repo data dir / legacy DB removal. - --keep-data preserves the data dir and reports it as skipped. - MCP entry removal preserves unrelated servers (workspace + user level). - Claude settings.json keeps user-defined hooks and non-hook keys. - Generated skill directories are removed. - Pre-commit hook preserves preexisting user lines. - Instruction-file section removal preserves other content; file is deleted only when nothing else remains. - .gitignore: our entry removed, user entries preserved. - Codex config.toml: our section removed, other sections kept. - Continue array-format MCP config: our entry removed by name. - --keep-user-configs skips the user-level pass. - A clean repo is a no-op.
|
@tirth8205 I got this PR ready for review |
|
I was reviewing this repo, saw this issue #482 and then saw this. I had claude review it as part of my thought process as to whether or not to use code-review-graph. Here's the out put in case it helps. I'm going to hold off on using it till an uninstall process is added. Architecture is sound. uninstall.py (685 LOC) has a clean three-layer design:
Conservative-by-default UX: CLI always runs a dry-run first, prints planned actions, then asks for confirmation unless --yes (cli.py:849–895). --dry-run short-circuits at preview. Surgical-not-nuke is testable contract. 18 tests in test_uninstall.py pin exactly this — every MCP config and hook config test injects an unrelated server/hook and asserts it survives the uninstall. Strengths
Concerns (ranked by severity)
PR Verdict APPROVE-WITH-CHANGES (lean toward approve — this is high-quality work):
The core design — inventory + per-kind handlers + dry-run-first + surgical edits + test-the-contract — is exactly what an uninstall should look like. |
PR: feat(cli): add
uninstallcommand to remove all installed artifactsCloses #482.
Summary
code-review-graph installwrites a lot of files: a graph database, generated skills, MCP configs across 14 platforms, hooks at both repo and user level, and an injected section in seven different instruction files. Issue #482 asks for a symmetric way to remove all of it.This PR adds
code-review-graph uninstall.What it does
Per-repo
.code-review-graph/data directory and the legacy.code-review-graph.dbfile..claude/skills/,.gemini/skills/, and.qoder/skills/..code-review-graph/entry from.gitignore.<!-- code-review-graph MCP tools -->section fromCLAUDE.md,AGENTS.md,GEMINI.md,.cursorrules,.windsurfrules,QODER.md, the Kiro steering file, and the GitHub Copilot instruction file. If a file contained only our section, the file is deleted.User-level
~/.code-review-graph/(registry, daemon state, watch.toml, logs).~/.config/opencode/plugins/crg-plugin.tsand the user-level Cursor hook scripts directory.Surgical edits, not nukes
Every shared config file is edited rather than deleted. Only the
code-review-graphentry is removed; other MCP servers, hooks, and content stay untouched. The tests pin this contract explicitly.Flags
Tests
tests/test_uninstall.pyadds 18 tests covering:--keep-datapreserves the data dir and reports it as skipped.settings.jsonkeeps user-defined hooks and non-hook keys..gitignore: our entry removed, user entries preserved.config.toml: our section removed, other sections kept.--keep-user-configsskips the user-level pass.All 18 pass; existing tests in
test_cli,test_cli_install,test_skills, andtest_registrystill pass (the four pre-existing failures intest_incremental.pyare an environmental tree-sitter mismatch unrelated to this change).Files changed