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

Function cli_uninstall_activate

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

11542 * a partially removed installation. Keep every filesystem mutation inside
11543 * the same startup-lock + lifetime-reservation guard as install/update. */
11544static int cli_uninstall_activate(void *opaque) {
11545 cli_uninstall_activation_t *activation = opaque;
11546 if (!activation || !activation->home) {
11547 return CLI_TRUE;
11548 }
11549
11550 if (activation->agents.claude_code) {
11551 uninstall_claude_code(activation->home, activation->dry_run);
11552 }
11553 uninstall_cli_agents(&activation->agents, activation->home, activation->dry_run);
11554 uninstall_editor_agents(&activation->agents, activation->home, activation->dry_run);
11555 uninstall_additional_agents(&activation->agents, activation->home, activation->dry_run);
11556 uninstall_agent_client_registry(activation->home, activation->dry_run);
11557
11558 if (g_agent_uninstall_errors != 0) {
11559 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
11560 "uninstall_transaction_config_cleanup_abort");
11561 (void)fprintf(stderr, "error: one or more agent cleanup operations failed; executable "
11562 "and index removal were not started\n");
11563 return CLI_ACTIVATION_PARTIAL;
11564 }
11565
11566 if (activation->delete_indexes && !activation->dry_run) {
11567 int expected = count_db_indexes(activation->home);
11568 int idx_removed = cbm_remove_indexes(activation->home);
11569 printf("Removed %d index(es).\n", idx_removed);
11570 if (idx_removed != expected) {
11571 cli_activation_transaction_abort_or_fail_stop(
11572 &activation->binary_transaction, "uninstall_transaction_index_failure_abort");
11573 (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", idx_removed,
11574 expected);
11575 return CLI_ACTIVATION_PARTIAL;
11576 }
11577 }
11578 if (!activation->dry_run && activation->binary_transaction) {
11579 if (cli_activation_transaction_commit_removal(activation->binary_transaction) != CLI_OK) {
11580 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
11581 "uninstall_transaction_removal_recovery");
11582 (void)fprintf(stderr,
11583 "error: failed to remove %s; completed "
11584 "configuration/index cleanup may remain\n",
11585 activation->bin_path);
11586 return CLI_ACTIVATION_PARTIAL;
11587 }
11588 cli_activation_transaction_finalize_committed_or_fail_stop(
11589 &activation->binary_transaction, "uninstall_transaction_removal_finalize");
11590 }
11591 if (activation->binary_exists) {
11592 printf("Removed %s\n", activation->bin_path);
11593 }
11594 cli_uninstall_report_leftover_installer(activation->bin_path, activation->dry_run);
11595 return CLI_OK;
11596}
11597
11598int cbm_cmd_uninstall(int argc, char **argv) {
11599 /* `uninstall --help` used to UNINSTALL.

Callers 1

cbm_cmd_uninstallFunction · 0.85

Tested by

no test coverage detected