MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cli_uninstall_activate

Function cli_uninstall_activate

src/cli/cli.c:11310–11362  ·  view source on GitHub ↗

Uninstall is an activation too: removing the executable or its indexes * while a daemon generation is starting/running would leave live sessions on * a partially removed installation. Keep every filesystem mutation inside * the same startup-lock + lifetime-reservation guard as install/update. */

Source from the content-addressed store, hash-verified

11308 * a partially removed installation. Keep every filesystem mutation inside
11309 * the same startup-lock + lifetime-reservation guard as install/update. */
11310static int cli_uninstall_activate(void *opaque) {
11311 cli_uninstall_activation_t *activation = opaque;
11312 if (!activation || !activation->home) {
11313 return CLI_TRUE;
11314 }
11315
11316 if (activation->agents.claude_code) {
11317 uninstall_claude_code(activation->home, activation->dry_run);
11318 }
11319 uninstall_cli_agents(&activation->agents, activation->home, activation->dry_run);
11320 uninstall_editor_agents(&activation->agents, activation->home, activation->dry_run);
11321 uninstall_additional_agents(&activation->agents, activation->home, activation->dry_run);
11322 uninstall_agent_client_registry(activation->home, activation->dry_run);
11323
11324 if (g_agent_uninstall_errors != 0) {
11325 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
11326 "uninstall_transaction_config_cleanup_abort");
11327 (void)fprintf(stderr, "error: one or more agent cleanup operations failed; executable "
11328 "and index removal were not started\n");
11329 return CLI_ACTIVATION_PARTIAL;
11330 }
11331
11332 if (activation->delete_indexes && !activation->dry_run) {
11333 int expected = count_db_indexes(activation->home);
11334 int idx_removed = cbm_remove_indexes(activation->home);
11335 printf("Removed %d index(es).\n", idx_removed);
11336 if (idx_removed != expected) {
11337 cli_activation_transaction_abort_or_fail_stop(
11338 &activation->binary_transaction, "uninstall_transaction_index_failure_abort");
11339 (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", idx_removed,
11340 expected);
11341 return CLI_ACTIVATION_PARTIAL;
11342 }
11343 }
11344 if (!activation->dry_run && activation->binary_transaction) {
11345 if (cli_activation_transaction_commit_removal(activation->binary_transaction) != CLI_OK) {
11346 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
11347 "uninstall_transaction_removal_recovery");
11348 (void)fprintf(stderr,
11349 "error: failed to remove %s; completed "
11350 "configuration/index cleanup may remain\n",
11351 activation->bin_path);
11352 return CLI_ACTIVATION_PARTIAL;
11353 }
11354 cli_activation_transaction_finalize_committed_or_fail_stop(
11355 &activation->binary_transaction, "uninstall_transaction_removal_finalize");
11356 }
11357 if (activation->binary_exists) {
11358 printf("Removed %s\n", activation->bin_path);
11359 }
11360 cli_uninstall_report_leftover_installer(activation->bin_path, activation->dry_run);
11361 return CLI_OK;
11362}
11363
11364int cbm_cmd_uninstall(int argc, char **argv) {
11365 parse_auto_answer(argc, argv);

Callers 1

cbm_cmd_uninstallFunction · 0.85

Tested by

no test coverage detected