| 4082 | } |
| 4083 | |
| 4084 | int cbm_cmd_uninstall(int argc, char **argv) { |
| 4085 | parse_auto_answer(argc, argv); |
| 4086 | bool dry_run = false; |
| 4087 | for (int i = 0; i < argc; i++) { |
| 4088 | if (strcmp(argv[i], "--dry-run") == 0) { |
| 4089 | dry_run = true; |
| 4090 | } |
| 4091 | } |
| 4092 | |
| 4093 | const char *home = cbm_get_home_dir(); |
| 4094 | if (!home) { |
| 4095 | (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n"); |
| 4096 | return CLI_TRUE; |
| 4097 | } |
| 4098 | |
| 4099 | printf("codebase-memory-mcp uninstall\n\n"); |
| 4100 | |
| 4101 | cbm_detected_agents_t agents = cbm_detect_agents(home); |
| 4102 | if (agents.claude_code) { |
| 4103 | uninstall_claude_code(home, dry_run); |
| 4104 | } |
| 4105 | uninstall_cli_agents(&agents, home, dry_run); |
| 4106 | uninstall_editor_agents(&agents, home, dry_run); |
| 4107 | |
| 4108 | /* Step 2: Remove indexes */ |
| 4109 | int index_count = count_db_indexes(home); |
| 4110 | if (index_count > 0) { |
| 4111 | printf("\nFound %d index(es):\n", index_count); |
| 4112 | cbm_list_indexes(home); |
| 4113 | if (prompt_yn("Delete these indexes?")) { |
| 4114 | int idx_removed = cbm_remove_indexes(home); |
| 4115 | printf("Removed %d index(es).\n", idx_removed); |
| 4116 | } else { |
| 4117 | printf("Indexes kept.\n"); |
| 4118 | } |
| 4119 | } |
| 4120 | |
| 4121 | /* Step 3: Remove binary */ |
| 4122 | char bin_path[CLI_BUF_1K]; |
| 4123 | #ifdef _WIN32 |
| 4124 | snprintf(bin_path, sizeof(bin_path), "%s/.local/bin/codebase-memory-mcp.exe", home); |
| 4125 | #else |
| 4126 | snprintf(bin_path, sizeof(bin_path), "%s/.local/bin/codebase-memory-mcp", home); |
| 4127 | #endif |
| 4128 | struct stat st; |
| 4129 | if (stat(bin_path, &st) == 0) { |
| 4130 | if (!dry_run) { |
| 4131 | cbm_unlink(bin_path); |
| 4132 | } |
| 4133 | printf("Removed %s\n", bin_path); |
| 4134 | } |
| 4135 | |
| 4136 | printf("\nUninstall complete.\n"); |
| 4137 | if (dry_run) { |
| 4138 | printf("(dry-run — no files were modified)\n"); |
| 4139 | } |
| 4140 | return 0; |
| 4141 | } |
no test coverage detected