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

Function cli_uninstall_activate

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

10899 * a partially removed installation. Keep every filesystem mutation inside
10900 * the same startup-lock + lifetime-reservation guard as install/update. */
10901static int cli_uninstall_activate(void *opaque) {
10902 cli_uninstall_activation_t *activation = opaque;
10903 if (!activation || !activation->home) {
10904 return CLI_TRUE;
10905 }
10906
10907 if (activation->agents.claude_code) {
10908 uninstall_claude_code(activation->home, activation->dry_run);
10909 }
10910 uninstall_cli_agents(&activation->agents, activation->home, activation->dry_run);
10911 uninstall_editor_agents(&activation->agents, activation->home, activation->dry_run);
10912 uninstall_additional_agents(&activation->agents, activation->home, activation->dry_run);
10913 uninstall_agent_client_registry(activation->home, activation->dry_run);
10914
10915 if (g_agent_uninstall_errors != 0) {
10916 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
10917 "uninstall_transaction_config_cleanup_abort");
10918 (void)fprintf(stderr, "error: one or more agent cleanup operations failed; executable "
10919 "and index removal were not started\n");
10920 return CLI_ACTIVATION_PARTIAL;
10921 }
10922
10923 if (activation->delete_indexes && !activation->dry_run) {
10924 int expected = count_db_indexes(activation->home);
10925 int idx_removed = cbm_remove_indexes(activation->home);
10926 printf("Removed %d index(es).\n", idx_removed);
10927 if (idx_removed != expected) {
10928 cli_activation_transaction_abort_or_fail_stop(
10929 &activation->binary_transaction, "uninstall_transaction_index_failure_abort");
10930 (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", idx_removed,
10931 expected);
10932 return CLI_ACTIVATION_PARTIAL;
10933 }
10934 }
10935 if (!activation->dry_run && activation->binary_transaction) {
10936 if (cli_activation_transaction_commit_removal(activation->binary_transaction) != CLI_OK) {
10937 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
10938 "uninstall_transaction_removal_recovery");
10939 (void)fprintf(stderr,
10940 "error: failed to remove %s; completed "
10941 "configuration/index cleanup may remain\n",
10942 activation->bin_path);
10943 return CLI_ACTIVATION_PARTIAL;
10944 }
10945 cli_activation_transaction_finalize_committed_or_fail_stop(
10946 &activation->binary_transaction, "uninstall_transaction_removal_finalize");
10947 }
10948 if (activation->binary_exists) {
10949 printf("Removed %s\n", activation->bin_path);
10950 }
10951 cli_uninstall_report_leftover_installer(activation->bin_path, activation->dry_run);
10952 return CLI_OK;
10953}
10954
10955int cbm_cmd_uninstall(int argc, char **argv) {
10956 parse_auto_answer(argc, argv);

Callers 1

cbm_cmd_uninstallFunction · 0.85

Tested by

no test coverage detected