| 12175 | } |
| 12176 | |
| 12177 | int cbm_cmd_update(int argc, char **argv) { |
| 12178 | parse_auto_answer(argc, argv); |
| 12179 | |
| 12180 | bool dry_run = false; |
| 12181 | bool force = false; |
| 12182 | bool legacy_variant_flag = false; |
| 12183 | for (int i = 0; i < argc; i++) { |
| 12184 | if (strcmp(argv[i], "--dry-run") == 0) { |
| 12185 | dry_run = true; |
| 12186 | } else if (strcmp(argv[i], "--force") == 0) { |
| 12187 | force = true; |
| 12188 | } else if (strcmp(argv[i], "--ui") == 0 || strcmp(argv[i], "--standard") == 0) { |
| 12189 | /* v0.10.2 deleted the ui/standard chooser and, with it, these flags — |
| 12190 | * which turned `update --ui` from a working command into a hard |
| 12191 | * error for everyone who had it in a script, an alias, or muscle |
| 12192 | * memory (#1544). Removing a CHOICE is fine; removing the WORDS |
| 12193 | * people type is a break we owe them nothing for. Accept both, |
| 12194 | * ignore them, and say once why they no longer mean anything. */ |
| 12195 | legacy_variant_flag = true; |
| 12196 | } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 && |
| 12197 | strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) { |
| 12198 | (void)fprintf(stderr, "error: unknown update option: %s\n", argv[i]); |
| 12199 | return CLI_TRUE; |
| 12200 | } |
| 12201 | } |
| 12202 | if (legacy_variant_flag) { |
| 12203 | (void)fprintf(stderr, "note: --ui/--standard are accepted but no longer do anything; since " |
| 12204 | "v0.10.0 there is one build per platform and it always includes the " |
| 12205 | "graph UI.\n"); |
| 12206 | } |
| 12207 | |
| 12208 | /* #1566: we cannot update a binary a package manager owns, and pretending |
| 12209 | * otherwise is the dishonest-success pattern this project keeps fixing: |
| 12210 | * reporting that an update ran while changing nothing leaves the user |
| 12211 | * convinced they are current. Refuse, and name the command that WILL work. */ |
| 12212 | { |
| 12213 | char self_path[CLI_BUF_1K] = {0}; |
| 12214 | const char *home = cbm_get_home_dir(); |
| 12215 | bool self_exact = home && cbm_detect_self_path(self_path, sizeof(self_path), home); |
| 12216 | char managed_dir[CLI_BUF_1K] = {0}; |
| 12217 | if (self_exact && home) { |
| 12218 | snprintf(managed_dir, sizeof(managed_dir), "%s/.local/bin", home); |
| 12219 | } |
| 12220 | if (self_exact && cli_binary_is_externally_managed(self_path, true, managed_dir)) { |
| 12221 | const char *manager = cli_external_manager_name(self_path); |
| 12222 | (void)fprintf(stderr, |
| 12223 | "error: this binary is managed by %s, so `update` cannot replace it:\n" |
| 12224 | " %s\n", |
| 12225 | manager ? manager : "another installer", self_path); |
| 12226 | if (manager && strcmp(manager, "mise") == 0) { |
| 12227 | (void)fprintf(stderr, " update it with: mise upgrade codebase-memory-mcp\n"); |
| 12228 | } else if (manager && strcmp(manager, "Homebrew") == 0) { |
| 12229 | (void)fprintf(stderr, " update it with: brew upgrade codebase-memory-mcp\n"); |
| 12230 | } else { |
| 12231 | (void)fprintf(stderr, " update it through whichever tool installed it.\n"); |
| 12232 | } |
| 12233 | (void)fprintf(stderr, " to refresh only the agent configurations, run: " |
| 12234 | "codebase-memory-mcp install --skip-binary\n"); |
no test coverage detected