Skip to content

Commit 3daac78

Browse files
committed
Merge fu/codex-uninstall-warning into fu/integration
Retain the Codex uninstall legacy-MCP warning and dry-run/real-uninstall preservation checks. No textual conflicts. Scanned both-side changed files, including platform conditionals, for duplicate definitions, declarations, TEST bodies and RUN_TEST registrations; no new duplicates.
2 parents 8758668 + 21117cc commit 3daac78

2 files changed

Lines changed: 65 additions & 3 deletions

File tree

‎src/cli/cli.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10832,6 +10832,11 @@ static void uninstall_cli_agents(const cbm_detected_agents_t *agents, const char
1083210832
snprintf(ip, sizeof(ip), "%s/AGENTS.md", config_dir);
1083310833
snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir);
1083410834
snprintf(ap, sizeof(ap), "%s/agents/codebase-memory.toml", config_dir);
10835+
/* The Codex branch removes instructions through its own activation
10836+
* pointer helper instead of uninstall_agent_mcp_instr, so it has to
10837+
* emit the legacy MCP block warning itself. Read-only under --dry-run
10838+
* too, like the generic path. */
10839+
cbm_warn_legacy_mcp_block(ip);
1083510840
bool pointer_removed = uninstall_codex_activation_pointer(ip, dry_run);
1083610841
cbm_agent_installed_binary_path(home, installed_binary, sizeof(installed_binary));
1083710842
char hook_command[CLI_BUF_8K];

‎tests/test_cli.c‎

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7550,6 +7550,61 @@ TEST(cli_install_warns_about_legacy_mcp_instruction_block) {
75507550
NULL;
75517551
#endif
75527552

7553+
/* Codex uninstall removes instructions through its own helper instead of
7554+
* uninstall_agent_mcp_instr, so it needs its own legacy-block warning: same
7555+
* text, in --dry-run and for real, and the legacy bytes must survive both. */
7556+
#ifndef _WIN32
7557+
cli_fd_capture_t uninstall_dry_capture;
7558+
cli_fd_capture_begin(&uninstall_dry_capture, stderr, STDERR_FILENO);
7559+
#endif
7560+
char *uninstall_dry_argv[] = {"--dry-run", "--yes"};
7561+
int uninstall_dry_rc = cbm_cmd_uninstall(2, uninstall_dry_argv);
7562+
#ifndef _WIN32
7563+
char *uninstall_dry_err = cli_fd_capture_end(&uninstall_dry_capture);
7564+
#else
7565+
char *uninstall_dry_err = NULL;
7566+
#endif
7567+
cbm_set_auto_answer_for_test(0);
7568+
char *after_uninstall_dry = read_test_file_alloc(agents_path);
7569+
bool uninstall_dry_preserved =
7570+
after_uninstall_dry && after && strcmp(after_uninstall_dry, after) == 0;
7571+
bool uninstall_dry_warned = true;
7572+
#ifndef _WIN32
7573+
uninstall_dry_warned =
7574+
uninstall_dry_err && strstr(uninstall_dry_err, agents_path) != NULL &&
7575+
strstr(uninstall_dry_err,
7576+
"still contains a legacy codebase-memory-mcp instruction block") != NULL;
7577+
#endif
7578+
free(after_uninstall_dry);
7579+
free(uninstall_dry_err);
7580+
7581+
#ifndef _WIN32
7582+
cli_fd_capture_t uninstall_capture;
7583+
cli_fd_capture_begin(&uninstall_capture, stderr, STDERR_FILENO);
7584+
#endif
7585+
char *uninstall_argv[] = {"--yes"};
7586+
int uninstall_rc = cbm_cmd_uninstall(1, uninstall_argv);
7587+
#ifndef _WIN32
7588+
char *uninstall_err = cli_fd_capture_end(&uninstall_capture);
7589+
#else
7590+
char *uninstall_err = NULL;
7591+
#endif
7592+
cbm_set_auto_answer_for_test(0);
7593+
char *after_uninstall = read_test_file_alloc(agents_path);
7594+
bool uninstall_legacy_preserved =
7595+
after_uninstall && strstr(after_uninstall, legacy_block) != NULL;
7596+
bool uninstall_user_preserved =
7597+
after_uninstall && strstr(after_uninstall, user_guidance) != NULL;
7598+
bool uninstall_warned = true;
7599+
#ifndef _WIN32
7600+
uninstall_warned =
7601+
uninstall_err && strstr(uninstall_err, agents_path) != NULL &&
7602+
strstr(uninstall_err, "still contains a legacy codebase-memory-mcp instruction block") !=
7603+
NULL;
7604+
#endif
7605+
free(after_uninstall);
7606+
free(uninstall_err);
7607+
75537608
free(after);
75547609
free(install_err);
75557610
restore_test_env("HOME", saved_home);
@@ -7558,9 +7613,11 @@ TEST(cli_install_warns_about_legacy_mcp_instruction_block) {
75587613
test_rmdir_r(tmpdir);
75597614

75607615
if (dry_rc != 0 || install_rc != 0 || !dry_preserved || !dry_warned || !legacy_preserved ||
7561-
!user_preserved || !cli_block_added_once || !install_warned)
7562-
FAIL("Codex install must warn about a legacy codebase-memory-mcp block in --dry-run and "
7563-
"on install, keep its bytes and the user's, and add one CLI managed block");
7616+
!user_preserved || !cli_block_added_once || !install_warned || uninstall_dry_rc != 0 ||
7617+
uninstall_rc != 0 || !uninstall_dry_preserved || !uninstall_dry_warned ||
7618+
!uninstall_legacy_preserved || !uninstall_user_preserved || !uninstall_warned)
7619+
FAIL("Codex install and uninstall must warn about a legacy codebase-memory-mcp block "
7620+
"(--dry-run and real), keep its bytes and the user's, and add one CLI managed block");
75647621
PASS();
75657622
}
75667623

0 commit comments

Comments
 (0)