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

Function cli_uninstall_activate

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

10849 * a partially removed installation. Keep every filesystem mutation inside
10850 * the same startup-lock + lifetime-reservation guard as install/update. */
10851static int cli_uninstall_activate(void *opaque) {
10852 cli_uninstall_activation_t *activation = opaque;
10853 if (!activation || !activation->home) {
10854 return CLI_TRUE;
10855 }
10856
10857 if (activation->agents.claude_code) {
10858 uninstall_claude_code(activation->home, activation->dry_run);
10859 }
10860 uninstall_cli_agents(&activation->agents, activation->home, activation->dry_run);
10861 uninstall_editor_agents(&activation->agents, activation->home, activation->dry_run);
10862 uninstall_additional_agents(&activation->agents, activation->home, activation->dry_run);
10863 uninstall_agent_client_registry(activation->home, activation->dry_run);
10864
10865 if (g_agent_uninstall_errors != 0) {
10866 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
10867 "uninstall_transaction_config_cleanup_abort");
10868 (void)fprintf(stderr, "error: one or more agent cleanup operations failed; executable "
10869 "and index removal were not started\n");
10870 return CLI_ACTIVATION_PARTIAL;
10871 }
10872
10873 if (activation->delete_indexes && !activation->dry_run) {
10874 int expected = count_db_indexes(activation->home);
10875 int idx_removed = cbm_remove_indexes(activation->home);
10876 printf("Removed %d index(es).\n", idx_removed);
10877 if (idx_removed != expected) {
10878 cli_activation_transaction_abort_or_fail_stop(
10879 &activation->binary_transaction, "uninstall_transaction_index_failure_abort");
10880 (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", idx_removed,
10881 expected);
10882 return CLI_ACTIVATION_PARTIAL;
10883 }
10884 }
10885 if (!activation->dry_run && activation->binary_transaction) {
10886 if (cli_activation_transaction_commit_removal(activation->binary_transaction) != CLI_OK) {
10887 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
10888 "uninstall_transaction_removal_recovery");
10889 (void)fprintf(stderr,
10890 "error: failed to remove %s; completed "
10891 "configuration/index cleanup may remain\n",
10892 activation->bin_path);
10893 return CLI_ACTIVATION_PARTIAL;
10894 }
10895 cli_activation_transaction_finalize_committed_or_fail_stop(
10896 &activation->binary_transaction, "uninstall_transaction_removal_finalize");
10897 }
10898 if (activation->binary_exists) {
10899 printf("Removed %s\n", activation->bin_path);
10900 }
10901 cli_uninstall_report_leftover_installer(activation->bin_path, activation->dry_run);
10902 return CLI_OK;
10903}
10904
10905int cbm_cmd_uninstall(int argc, char **argv) {
10906 parse_auto_answer(argc, argv);

Callers 1

cbm_cmd_uninstallFunction · 0.85

Tested by

no test coverage detected