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

Function cli_uninstall_activate

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

10955 * a partially removed installation. Keep every filesystem mutation inside
10956 * the same startup-lock + lifetime-reservation guard as install/update. */
10957static int cli_uninstall_activate(void *opaque) {
10958 cli_uninstall_activation_t *activation = opaque;
10959 if (!activation || !activation->home) {
10960 return CLI_TRUE;
10961 }
10962
10963 if (activation->agents.claude_code) {
10964 uninstall_claude_code(activation->home, activation->dry_run);
10965 }
10966 uninstall_cli_agents(&activation->agents, activation->home, activation->dry_run);
10967 uninstall_editor_agents(&activation->agents, activation->home, activation->dry_run);
10968 uninstall_additional_agents(&activation->agents, activation->home, activation->dry_run);
10969 uninstall_agent_client_registry(activation->home, activation->dry_run);
10970
10971 if (g_agent_uninstall_errors != 0) {
10972 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
10973 "uninstall_transaction_config_cleanup_abort");
10974 (void)fprintf(stderr, "error: one or more agent cleanup operations failed; executable "
10975 "and index removal were not started\n");
10976 return CLI_ACTIVATION_PARTIAL;
10977 }
10978
10979 if (activation->delete_indexes && !activation->dry_run) {
10980 int expected = count_db_indexes(activation->home);
10981 int idx_removed = cbm_remove_indexes(activation->home);
10982 printf("Removed %d index(es).\n", idx_removed);
10983 if (idx_removed != expected) {
10984 cli_activation_transaction_abort_or_fail_stop(
10985 &activation->binary_transaction, "uninstall_transaction_index_failure_abort");
10986 (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", idx_removed,
10987 expected);
10988 return CLI_ACTIVATION_PARTIAL;
10989 }
10990 }
10991 if (!activation->dry_run && activation->binary_transaction) {
10992 if (cli_activation_transaction_commit_removal(activation->binary_transaction) != CLI_OK) {
10993 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
10994 "uninstall_transaction_removal_recovery");
10995 (void)fprintf(stderr,
10996 "error: failed to remove %s; completed "
10997 "configuration/index cleanup may remain\n",
10998 activation->bin_path);
10999 return CLI_ACTIVATION_PARTIAL;
11000 }
11001 cli_activation_transaction_finalize_committed_or_fail_stop(
11002 &activation->binary_transaction, "uninstall_transaction_removal_finalize");
11003 }
11004 if (activation->binary_exists) {
11005 printf("Removed %s\n", activation->bin_path);
11006 }
11007 cli_uninstall_report_leftover_installer(activation->bin_path, activation->dry_run);
11008 return CLI_OK;
11009}
11010
11011int cbm_cmd_uninstall(int argc, char **argv) {
11012 parse_auto_answer(argc, argv);

Callers 1

cbm_cmd_uninstallFunction · 0.85

Tested by

no test coverage detected