Remove Claude Code agent configs. */
| 11607 | |
| 11608 | /* Remove Claude Code agent configs. */ |
| 11609 | static void uninstall_claude_code(const char *home, const char *installed_binary, bool dry_run) { |
| 11610 | char config_dir[CLI_BUF_1K]; |
| 11611 | cbm_claude_config_dir(home, config_dir, sizeof(config_dir)); |
| 11612 | char user_root[CLI_BUF_1K]; |
| 11613 | cbm_claude_user_root(home, user_root, sizeof(user_root)); |
| 11614 | |
| 11615 | char skills_dir[CLI_BUF_1K]; |
| 11616 | snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir); |
| 11617 | int removed = cbm_remove_skills(skills_dir, dry_run); |
| 11618 | printf("Claude Code: removed %d skill(s)\n", removed); |
| 11619 | char agent_path[CLI_BUF_1K]; |
| 11620 | snprintf(agent_path, sizeof(agent_path), "%s/agents/codebase-memory.md", config_dir); |
| 11621 | uninstall_tiered_agent_profiles( |
| 11622 | (cbm_tiered_profile_set_t){ |
| 11623 | .label = "Claude Code", |
| 11624 | .verify_path = agent_path, |
| 11625 | .binary_path = installed_binary, |
| 11626 | .legacy_verify_content = legacy_claude_verify_agent_content, |
| 11627 | .dialect = CBM_GRAPH_DIALECT_CLAUDE, |
| 11628 | }, |
| 11629 | dry_run); |
| 11630 | |
| 11631 | char mcp_path[CLI_BUF_1K]; |
| 11632 | snprintf(mcp_path, sizeof(mcp_path), "%s/.mcp.json", config_dir); |
| 11633 | if (!dry_run && cbm_remove_editor_mcp_owned(installed_binary, mcp_path) != CLI_OK) { |
| 11634 | record_agent_config_error(true, "Claude Code", "legacy_mcp_uninstall", mcp_path); |
| 11635 | } |
| 11636 | printf(" removed MCP config entry\n"); |
| 11637 | |
| 11638 | char mcp_path2[CLI_BUF_1K]; |
| 11639 | snprintf(mcp_path2, sizeof(mcp_path2), "%s/.claude.json", user_root); |
| 11640 | if (!dry_run && cbm_remove_editor_mcp_owned(installed_binary, mcp_path2) != CLI_OK) { |
| 11641 | record_agent_config_error(true, "Claude Code", "mcp_uninstall", mcp_path2); |
| 11642 | } |
| 11643 | |
| 11644 | char settings_path[CLI_BUF_1K]; |
| 11645 | snprintf(settings_path, sizeof(settings_path), "%s/settings.json", config_dir); |
| 11646 | if (!dry_run) { |
| 11647 | if (cbm_remove_claude_hooks_with_binary(settings_path, installed_binary) != CLI_OK) { |
| 11648 | record_agent_config_error(true, "Claude Code", "pretool_hook_uninstall", settings_path); |
| 11649 | } |
| 11650 | if (cbm_remove_session_hooks(settings_path, installed_binary) != CLI_OK) { |
| 11651 | record_agent_config_error(true, "Claude Code", "session_hook_uninstall", settings_path); |
| 11652 | } |
| 11653 | if (cbm_remove_claude_subagent_hooks_with_binary(settings_path, installed_binary) != |
| 11654 | CLI_OK) { |
| 11655 | record_agent_config_error(true, "Claude Code", "subagent_hook_uninstall", |
| 11656 | settings_path); |
| 11657 | } |
| 11658 | char current_gate[CLI_BUF_8K]; |
| 11659 | char current_session[CLI_BUF_8K]; |
| 11660 | char current_subagent[CLI_BUF_8K]; |
| 11661 | char released_gate[CLI_BUF_8K]; |
| 11662 | const char *const gate_legacy[] = {released_gate}; |
| 11663 | const char *const session_legacy[] = {cmm_released_session_script}; |
| 11664 | const char *const subagent_legacy[] = {cmm_released_subagent_script}; |
| 11665 | size_t gate_legacy_count = cbm_build_released_gate_script(installed_binary, released_gate, |
| 11666 | sizeof(released_gate)) == CLI_OK |
no test coverage detected