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

Function cli_uninstall_activate

src/cli/cli.c:11372–11424  ·  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

11370 * a partially removed installation. Keep every filesystem mutation inside
11371 * the same startup-lock + lifetime-reservation guard as install/update. */
11372static int cli_uninstall_activate(void *opaque) {
11373 cli_uninstall_activation_t *activation = opaque;
11374 if (!activation || !activation->home) {
11375 return CLI_TRUE;
11376 }
11377
11378 if (activation->agents.claude_code) {
11379 uninstall_claude_code(activation->home, activation->dry_run);
11380 }
11381 uninstall_cli_agents(&activation->agents, activation->home, activation->dry_run);
11382 uninstall_editor_agents(&activation->agents, activation->home, activation->dry_run);
11383 uninstall_additional_agents(&activation->agents, activation->home, activation->dry_run);
11384 uninstall_agent_client_registry(activation->home, activation->dry_run);
11385
11386 if (g_agent_uninstall_errors != 0) {
11387 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
11388 "uninstall_transaction_config_cleanup_abort");
11389 (void)fprintf(stderr, "error: one or more agent cleanup operations failed; executable "
11390 "and index removal were not started\n");
11391 return CLI_ACTIVATION_PARTIAL;
11392 }
11393
11394 if (activation->delete_indexes && !activation->dry_run) {
11395 int expected = count_db_indexes(activation->home);
11396 int idx_removed = cbm_remove_indexes(activation->home);
11397 printf("Removed %d index(es).\n", idx_removed);
11398 if (idx_removed != expected) {
11399 cli_activation_transaction_abort_or_fail_stop(
11400 &activation->binary_transaction, "uninstall_transaction_index_failure_abort");
11401 (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", idx_removed,
11402 expected);
11403 return CLI_ACTIVATION_PARTIAL;
11404 }
11405 }
11406 if (!activation->dry_run && activation->binary_transaction) {
11407 if (cli_activation_transaction_commit_removal(activation->binary_transaction) != CLI_OK) {
11408 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
11409 "uninstall_transaction_removal_recovery");
11410 (void)fprintf(stderr,
11411 "error: failed to remove %s; completed "
11412 "configuration/index cleanup may remain\n",
11413 activation->bin_path);
11414 return CLI_ACTIVATION_PARTIAL;
11415 }
11416 cli_activation_transaction_finalize_committed_or_fail_stop(
11417 &activation->binary_transaction, "uninstall_transaction_removal_finalize");
11418 }
11419 if (activation->binary_exists) {
11420 printf("Removed %s\n", activation->bin_path);
11421 }
11422 cli_uninstall_report_leftover_installer(activation->bin_path, activation->dry_run);
11423 return CLI_OK;
11424}
11425
11426int cbm_cmd_uninstall(int argc, char **argv) {
11427 /* `uninstall --help` used to UNINSTALL.

Callers 1

cbm_cmd_uninstallFunction · 0.85

Tested by

no test coverage detected