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

Function cli_uninstall_activate

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

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

Callers 1

cbm_cmd_uninstallFunction · 0.85

Tested by

no test coverage detected