Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(cli): respect OMP agent directory and preserve instructions
DavidHLP410cd9a33443
diff --git a/README.md b/README.mdindex 6a5759368..5474451cc 100644--- a/README.md+++ b/README.md@@ -490,7 +490,7 @@ overwrite user-modified agents.| Pochi | Detected | `~/.pochi/config.jsonc` (`mcp`) | `README.pochi.md`, skill, and three `readFile`-only parent-handoff agents || Pi | Detected | — | `~/.pi/agent/AGENTS.md` + skill; MCP/subagents require an explicit reviewed extension || IBM Bob IDE | Conditional | Existing `~/.bob/mcp.json` | Shared rule + IDE skill; no invented hook or agent |-| Oh My Pi (omp) | Detected | `~/.omp/agent/mcp.json` | `AGENTS.md`, skill, three direct-MCP graph-tool subagents (Scout/Verify/Auditor) |+| Oh My Pi (omp) | Detected | Effective agent directory (`OMP_PROFILE` / `PI_CODING_AGENT_DIR`; default `~/.omp/agent/mcp.json`) | Skill and three direct-MCP graph-tool subagents (Scout/Verify/Auditor); preserves user `AGENTS.md` || Sourcegraph Cody | Explicit opt-in | Existing `$CBM_CODY_CONFIG_PATH` | MCP only |### Sessions, compaction, and subagentsdiff --git a/src/cli/agent_clients.c b/src/cli/agent_clients.cindex 0f5ec3bfe..6f19b0593 100644--- a/src/cli/agent_clients.c+++ b/src/cli/agent_clients.c@@ -74,8 +74,8 @@ static const cbm_agent_client_profile_t agent_profiles[CBM_AGENT_CLIENT_COUNT] ={CBM_AGENT_CLIENT_SOURCEGRAPH_CODY, "sourcegraph-cody", "Sourcegraph Cody", CBM_AGENT_OPT_IN,CBM_AGENT_CAP_MCP, NULL, agent_install_callback, agent_remove_callback},{CBM_AGENT_CLIENT_OMP, "omp", "Oh My Pi (omp)", CBM_AGENT_STABLE,- CBM_AGENT_CAP_MCP | CBM_AGENT_CAP_INSTRUCTIONS | CBM_AGENT_CAP_SKILL | CBM_AGENT_CAP_AGENT,- "omp", agent_install_callback, agent_remove_callback},+ CBM_AGENT_CAP_MCP | CBM_AGENT_CAP_SKILL | CBM_AGENT_CAP_AGENT, "omp",+ agent_install_callback, agent_remove_callback},};size_t cbm_agent_client_count(void) {@@ -585,6 +585,10 @@ int cbm_agent_client_resolve_path(cbm_agent_client_id_t id,case CBM_AGENT_CLIENT_POCHI:return agent_join_path(path_out, path_out_size, options->home_dir, ".pochi/config.jsonc");case CBM_AGENT_CLIENT_OMP:+ if (options->omp_agent_dir && options->omp_agent_dir[0]) {+ int written = snprintf(path_out, path_out_size, "%s/mcp.json", options->omp_agent_dir);+ return written >= 0 && (size_t)written < path_out_size ? 0 : -1;+ }return agent_join_path(path_out, path_out_size, options->home_dir, ".omp/agent/mcp.json");case CBM_AGENT_CLIENT_PI:return 1;@@ -652,6 +656,10 @@ static int agent_client_marker_path(cbm_agent_client_id_t id,case CBM_AGENT_CLIENT_POCHI:return agent_join_path(path_out, path_out_size, options->home_dir, ".pochi");case CBM_AGENT_CLIENT_OMP:+ if (options->omp_agent_dir && options->omp_agent_dir[0]) {+ int written = snprintf(path_out, path_out_size, "%s", options->omp_agent_dir);+ return written >= 0 && (size_t)written < path_out_size ? 0 : 1;+ }return agent_join_path(path_out, path_out_size, options->home_dir, ".omp/agent");case CBM_AGENT_CLIENT_PI:return agent_join_path(path_out, path_out_size, options->home_dir, ".pi/agent");diff --git a/src/cli/agent_clients.h b/src/cli/agent_clients.hindex 8db225e43..ccf9f81a1 100644--- a/src/cli/agent_clients.h+++ b/src/cli/agent_clients.h@@ -76,6 +76,7 @@ typedef struct {const char *trae_config_path;const char *roo_config_path;const char *cody_config_path;+ const char *omp_agent_dir;bool is_windows;cbm_agent_probe_fn path_exists;cbm_agent_probe_fn command_exists;diff --git a/src/cli/cli.c b/src/cli/cli.cindex db0d02af0..2c8807125 100644--- a/src/cli/cli.c+++ b/src/cli/cli.c@@ -8109,6 +8109,29 @@ static void install_copilot_durable_context(const char *home, const char *binary}}+static bool cbm_omp_agent_dir(const char *home_dir, char *out, size_t out_sz) {+ char profile_buf[CLI_BUF_256];+ const char *profile = cbm_safe_getenv("OMP_PROFILE", profile_buf, sizeof(profile_buf), NULL);+ if (profile && profile[0]) {+ for (const unsigned char *p = (const unsigned char *)profile; *p; p++) {+ if (!isalnum(*p) && *p != '-' && *p != '_') {+ return false;+ }+ }+ int written = snprintf(out, out_sz, "%s/.omp/profiles/%s/agent", home_dir, profile);+ return written > 0 && (size_t)written < out_sz;+ }++ char agent_dir_buf[CLI_BUF_1K];+ const char *agent_dir =+ cbm_safe_getenv("PI_CODING_AGENT_DIR", agent_dir_buf, sizeof(agent_dir_buf), NULL);+ if (agent_dir && agent_dir[0]) {+ return cbm_expand_user_path(home_dir, agent_dir, out, out_sz);+ }+ int written = snprintf(out, out_sz, "%s/.omp/agent", home_dir);+ return written > 0 && (size_t)written < out_sz;+}+typedef struct {cbm_agent_client_resolve_options_t options;char xdg_config_home[CLI_BUF_1K];@@ -8119,6 +8142,7 @@ typedef struct {char trae_config_path[CLI_BUF_1K];char roo_config_path[CLI_BUF_1K];char cody_config_path[CLI_BUF_1K];+ char omp_agent_dir[CLI_BUF_1K];} cbm_agent_registry_context_t;static const char *cbm_agent_registry_env_path(const char *env_name, const char *home,@@ -8170,6 +8194,9 @@ static void cbm_init_agent_registry_context(const char *home,registry->options.cody_config_path =cbm_agent_registry_env_path("CBM_CODY_CONFIG_PATH", home, registry->cody_config_path,sizeof(registry->cody_config_path));+ if (cbm_omp_agent_dir(home, registry->omp_agent_dir, sizeof(registry->omp_agent_dir))) {+ registry->options.omp_agent_dir = registry->omp_agent_dir;+ }#ifdef _WIN32registry->options.is_windows = true;#else@@ -8535,14 +8562,26 @@ static void install_pochi_durable_context(const char *home, bool force, bool drydry_run);}-static void install_omp_durable_context(const char *home, bool force, bool dry_run) {- char instructions_path[CLI_BUF_1K];+static void install_omp_durable_context(const cbm_agent_registry_context_t *registry,+ bool force, bool dry_run) {+ const char *agent_dir = registry->options.omp_agent_dir+ && registry->options.omp_agent_dir[0]+ ? registry->options.omp_agent_dir+ : NULL;+ char resolved_dir[CLI_BUF_1K];+ if (!agent_dir) {+ int written = snprintf(resolved_dir, sizeof(resolved_dir), "%s/.omp/agent",+ registry->options.home_dir);+ if (written < 0 || (size_t)written >= sizeof(resolved_dir)) {+ record_agent_config_error(false, "Oh My Pi (omp)", "context_resolve", "omp");+ return;+ }+ agent_dir = resolved_dir;+ }char skills_dir[CLI_BUF_1K];char agent_path[CLI_BUF_1K];- snprintf(instructions_path, sizeof(instructions_path), "%s/.omp/agent/AGENTS.md", home);- snprintf(skills_dir, sizeof(skills_dir), "%s/.omp/agent/skills", home);- snprintf(agent_path, sizeof(agent_path), "%s/.omp/agent/agents/codebase-memory.md", home);- install_managed_agent_instructions("Oh My Pi (omp)", instructions_path, dry_run);+ snprintf(skills_dir, sizeof(skills_dir), "%s/skills", agent_dir);+ snprintf(agent_path, sizeof(agent_path), "%s/agents/codebase-memory.md", agent_dir);install_agent_skill("Oh My Pi (omp)", skills_dir, force, dry_run);install_tiered_agent_profiles((cbm_tiered_profile_set_t){@@ -8623,7 +8662,7 @@ static void install_agent_client_registry(const char *home, const char *binary_p} else if (profile->id == CBM_AGENT_CLIENT_PI) {install_pi_durable_context(home, binary_path, force, dry_run);} else if (profile->id == CBM_AGENT_CLIENT_OMP) {- install_omp_durable_context(home, force, dry_run);+ install_omp_durable_context(®istry, force, dry_run);}}}@@ -10838,14 +10877,26 @@ static void uninstall_pochi_durable_context(const char *home, bool dry_run) {dry_run);}-static void uninstall_omp_durable_context(const char *home, bool dry_run) {- char instructions_path[CLI_BUF_1K];+static void uninstall_omp_durable_context(const cbm_agent_registry_context_t *registry,+ bool dry_run) {+ const char *agent_dir = registry->options.omp_agent_dir+ && registry->options.omp_agent_dir[0]+ ? registry->options.omp_agent_dir+ : NULL;+ char resolved_dir[CLI_BUF_1K];+ if (!agent_dir) {+ int written = snprintf(resolved_dir, sizeof(resolved_dir), "%s/.omp/agent",+ registry->options.home_dir);+ if (written < 0 || (size_t)written >= sizeof(resolved_dir)) {+ record_agent_config_error(true, "Oh My Pi (omp)", "context_resolve", "omp");+ return;+ }+ agent_dir = resolved_dir;+ }char skills_dir[CLI_BUF_1K];char agent_path[CLI_BUF_1K];- snprintf(instructions_path, sizeof(instructions_path), "%s/.omp/agent/AGENTS.md", home);- snprintf(skills_dir, sizeof(skills_dir), "%s/.omp/agent/skills", home);- snprintf(agent_path, sizeof(agent_path), "%s/.omp/agent/agents/codebase-memory.md", home);- uninstall_managed_agent_instructions("Oh My Pi (omp)", instructions_path, dry_run);+ snprintf(skills_dir, sizeof(skills_dir), "%s/skills", agent_dir);+ snprintf(agent_path, sizeof(agent_path), "%s/agents/codebase-memory.md", agent_dir);uninstall_agent_skill("Oh My Pi (omp)", skills_dir, dry_run);uninstall_tiered_agent_profiles((cbm_tiered_profile_set_t){@@ -10917,7 +10968,7 @@ static void uninstall_agent_client_registry(const char *home, bool dry_run) {} else if (profile->id == CBM_AGENT_CLIENT_PI) {uninstall_pi_durable_context(home, dry_run);} else if (profile->id == CBM_AGENT_CLIENT_OMP) {- uninstall_omp_durable_context(home, dry_run);+ uninstall_omp_durable_context(®istry, dry_run);}}}diff --git a/tests/test_agent_clients.c b/tests/test_agent_clients.cindex a99aa3a15..ceb4ddf7b 100644--- a/tests/test_agent_clients.c+++ b/tests/test_agent_clients.c@@ -49,6 +49,7 @@ static cbm_agent_client_resolve_options_t agent_options(agent_probe_t *probe) {.trae_config_path = NULL,.roo_config_path = NULL,.cody_config_path = NULL,+ .omp_agent_dir = NULL,.is_windows = false,.path_exists = agent_path_exists,.command_exists = agent_command_exists,@@ -182,7 +183,7 @@ TEST(agent_clients_registry_is_stable_and_callback_driven) {CBM_AGENT_CAP_MCP | CBM_AGENT_CAP_INSTRUCTIONS | CBM_AGENT_CAP_SKILL | CBM_AGENT_CAP_AGENT,CBM_AGENT_CAP_INSTRUCTIONS | CBM_AGENT_CAP_SKILL,CBM_AGENT_CAP_MCP,- CBM_AGENT_CAP_MCP | CBM_AGENT_CAP_INSTRUCTIONS | CBM_AGENT_CAP_SKILL | CBM_AGENT_CAP_AGENT,+ CBM_AGENT_CAP_MCP | CBM_AGENT_CAP_SKILL | CBM_AGENT_CAP_AGENT,};ASSERT_EQ(cbm_agent_client_count(), CBM_AGENT_CLIENT_COUNT);ASSERT_EQ(CBM_AGENT_CLIENT_COUNT, sizeof(expected) / sizeof(expected[0]));@@ -934,6 +935,45 @@ TEST(agent_clients_refuse_foreign_and_preserve_modified_entries) {PASS();}+TEST(agent_clients_omp_resolves_to_injected_agent_dir_when_provided) {+ agent_probe_t probe = {0};+ cbm_agent_client_resolve_options_t options = agent_options(&probe);+ char resolved[512];++ /* Default (no env) keeps the documented ~/.omp/agent path. */+ ASSERT_EQ(cbm_agent_client_resolve_path(CBM_AGENT_CLIENT_OMP, &options, resolved,+ sizeof(resolved)),+ 0);+ ASSERT_STR_EQ(resolved, "/home/tester/.omp/agent/mcp.json");++ /* Named profile directory takes precedence over the home-relative default. */+ options.omp_agent_dir = "/home/tester/.omp/profiles/work/agent";+ ASSERT_EQ(cbm_agent_client_resolve_path(CBM_AGENT_CLIENT_OMP, &options, resolved,+ sizeof(resolved)),+ 0);+ ASSERT_STR_EQ(resolved, "/home/tester/.omp/profiles/work/agent/mcp.json");++ /* PI_CODING_AGENT_DIR relocations also flow through the resolved option. */+ options.omp_agent_dir = "/srv/omp-shared/agent";+ ASSERT_EQ(cbm_agent_client_resolve_path(CBM_AGENT_CLIENT_OMP, &options, resolved,+ sizeof(resolved)),+ 0);+ ASSERT_STR_EQ(resolved, "/srv/omp-shared/agent/mcp.json");+ PASS();+}++TEST(agent_clients_omp_profile_does_not_register_global_instructions_capability) {+ const cbm_agent_client_profile_t *profile =+ cbm_agent_client_by_id(CBM_AGENT_CLIENT_OMP);+ ASSERT_NOT_NULL(profile);+ ASSERT_EQ(profile->capabilities & CBM_AGENT_CAP_INSTRUCTIONS, 0U);+ ASSERT_NEQ(profile->capabilities & CBM_AGENT_CAP_MCP, 0U);+ ASSERT_NEQ(profile->capabilities & CBM_AGENT_CAP_SKILL, 0U);+ ASSERT_NEQ(profile->capabilities & CBM_AGENT_CAP_AGENT, 0U);+ PASS();+}++TEST(agent_clients_remove_only_canonical_and_missing_is_noop) {char *dir = NULL;char *path = agent_fixture("{\"keep\":true}\n", &dir);@@ -1243,6 +1283,8 @@ SUITE(agent_clients) {RUN_TEST(agent_clients_json_schemas_are_exact_and_policy_neutral);RUN_TEST(agent_clients_new_standard_json_profiles_preserve_foreign_entries);RUN_TEST(agent_clients_refuse_foreign_and_preserve_modified_entries);+ RUN_TEST(agent_clients_omp_resolves_to_injected_agent_dir_when_provided);+ RUN_TEST(agent_clients_omp_profile_does_not_register_global_instructions_capability);RUN_TEST(agent_clients_remove_only_canonical_and_missing_is_noop);RUN_TEST(agent_clients_registry_callbacks_apply_the_selected_schema);RUN_TEST(agent_clients_malformed_json_fails_byte_identically);diff --git a/tests/test_cli.c b/tests/test_cli.cindex 893fe2a83..24254df34 100644--- a/tests/test_cli.c+++ b/tests/test_cli.c@@ -6737,6 +6737,300 @@ TEST(cli_registry_installs_kimi_rovo_amp_durable_context) {"cleanup and no trust or permission widening");PASS();}+TEST(cli_registry_routes_omp_via_profile_and_pi_coding_agent_dir) {+ char tmpdir[256];+ snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-registry-omp-XXXXXX");+ if (!cbm_mkdtemp(tmpdir))+ FAIL("cbm_mkdtemp failed");++ const char *const env_names[] = {+ "HOME", "PATH", "OMP_PROFILE", "PI_CODING_AGENT_DIR",+ "XDG_CONFIG_HOME", "APPDATA",+ };+ char *saved_env[sizeof(env_names) / sizeof(env_names[0])];+ for (size_t i = 0U; i < sizeof(env_names) / sizeof(env_names[0]); i++) {+ saved_env[i] = save_test_env(env_names[i]);+ cbm_unsetenv(env_names[i]);+ }++ char binary_path[640];+#ifdef _WIN32+ snprintf(binary_path, sizeof(binary_path), "%s/.local/bin/codebase-memory-mcp.exe", tmpdir);+#else+ snprintf(binary_path, sizeof(binary_path), "%s/.local/bin/codebase-memory-mcp", tmpdir);+#endif++ char omp_default_dir[640];+ char omp_profile_dir[640];+ char omp_relocated_dir[640];+ char omp_default_mcp[768];+ char omp_profile_mcp[768];+ char omp_relocated_mcp[768];+ char omp_default_agent[768];+ char omp_profile_agent[768];+ char omp_relocated_agent[768];+ snprintf(omp_default_dir, sizeof(omp_default_dir), "%s/.omp/agent", tmpdir);+ snprintf(omp_profile_dir, sizeof(omp_profile_dir), "%s/.omp/profiles/work/agent", tmpdir);+ snprintf(omp_relocated_dir, sizeof(omp_relocated_dir), "%s/custom-agent", tmpdir);+ snprintf(omp_default_mcp, sizeof(omp_default_mcp), "%s/mcp.json", omp_default_dir);+ snprintf(omp_profile_mcp, sizeof(omp_profile_mcp), "%s/mcp.json", omp_profile_dir);+ snprintf(omp_relocated_mcp, sizeof(omp_relocated_mcp), "%s/mcp.json", omp_relocated_dir);+ snprintf(omp_default_agent, sizeof(omp_default_agent), "%s/agents/codebase-memory.md",+ omp_default_dir);+ snprintf(omp_profile_agent, sizeof(omp_profile_agent), "%s/agents/codebase-memory.md",+ omp_profile_dir);+ snprintf(omp_relocated_agent, sizeof(omp_relocated_agent), "%s/agents/codebase-memory.md",+ omp_relocated_dir);+ test_mkdirp(omp_default_dir);+ test_mkdirp(omp_profile_dir);+ test_mkdirp(omp_relocated_dir);++ cbm_setenv("HOME", tmpdir, 1);+ cbm_setenv("PATH", tmpdir, 1);++ /* Case 1: documented fallback (no env overrides). */+ char *default_plan = cbm_build_install_plan_json(tmpdir, binary_path);+ yyjson_doc *default_doc =+ default_plan ? yyjson_read(default_plan, strlen(default_plan), 0) : NULL;+ yyjson_val *default_root = default_doc ? yyjson_doc_get_root(default_doc) : NULL;+ bool default_plan_ok =+ default_plan && strstr(default_plan, "\"omp\"") &&+ test_json_string_array_contains(default_root, "config_files_planned", omp_default_mcp) &&+ test_json_string_array_contains(default_root, "agent_files_planned", omp_default_agent) &&+ !test_json_string_array_contains(default_root, "instruction_files_planned",+ omp_default_dir);+ yyjson_doc_free(default_doc);+ free(default_plan);++ /* Case 2: OMP_PROFILE=work routes to ~/.omp/profiles/<name>/agent. */+ cbm_setenv("OMP_PROFILE", "work", 1);+ char *profile_plan = cbm_build_install_plan_json(tmpdir, binary_path);+ yyjson_doc *profile_doc =+ profile_plan ? yyjson_read(profile_plan, strlen(profile_plan), 0) : NULL;+ yyjson_val *profile_root = profile_doc ? yyjson_doc_get_root(profile_doc) : NULL;+ bool profile_plan_ok =+ profile_plan && strstr(profile_plan, "\"omp\"") &&+ test_json_string_array_contains(profile_root, "config_files_planned", omp_profile_mcp) &&+ test_json_string_array_contains(profile_root, "agent_files_planned", omp_profile_agent) &&+ !test_json_string_array_contains(profile_root, "config_files_planned", omp_default_mcp) &&+ !test_json_string_array_contains(profile_root, "agent_files_planned", omp_default_agent);+ yyjson_doc_free(profile_doc);+ free(profile_plan);+ cbm_unsetenv("OMP_PROFILE");++ /* Case 3: PI_CODING_AGENT_DIR relocates the resolved agent dir. The+ * target must already exist on disk for the registry to recognize the+ * client, which matches how end users opt in to a shared layout. */+ cbm_setenv("PI_CODING_AGENT_DIR", omp_relocated_dir, 1);+ char *relocated_plan = cbm_build_install_plan_json(tmpdir, binary_path);+ yyjson_doc *relocated_doc =+ relocated_plan ? yyjson_read(relocated_plan, strlen(relocated_plan), 0) : NULL;+ yyjson_val *relocated_root = relocated_doc ? yyjson_doc_get_root(relocated_doc) : NULL;+ bool relocated_plan_ok =+ relocated_plan && strstr(relocated_plan, "\"omp\"") &&+ test_json_string_array_contains(relocated_root, "config_files_planned",+ omp_relocated_mcp) &&+ test_json_string_array_contains(relocated_root, "agent_files_planned",+ omp_relocated_agent);+ yyjson_doc_free(relocated_doc);+ free(relocated_plan);+ cbm_unsetenv("PI_CODING_AGENT_DIR");++ /* Case 4: invalid profile characters must fall back to the documented+ * ~/.omp/agent path rather than emit something unsafe. */+ cbm_setenv("OMP_PROFILE", "bad;name", 1);+ char *fallback_plan = cbm_build_install_plan_json(tmpdir, binary_path);+ yyjson_doc *fallback_doc =+ fallback_plan ? yyjson_read(fallback_plan, strlen(fallback_plan), 0) : NULL;+ yyjson_val *fallback_root = fallback_doc ? yyjson_doc_get_root(fallback_doc) : NULL;+ bool fallback_plan_ok =+ fallback_plan && strstr(fallback_plan, "\"omp\"") &&+ test_json_string_array_contains(fallback_root, "config_files_planned", omp_default_mcp) &&+ !test_json_string_array_contains(fallback_root, "config_files_planned", omp_profile_mcp);+ yyjson_doc_free(fallback_doc);+ free(fallback_plan);+ cbm_unsetenv("OMP_PROFILE");++ /* None of the plan-only invocations may have written OMP-owned content. */+ struct stat state;+ bool plan_did_not_mutate =+ (stat(omp_default_mcp, &state) != 0) &&+ (stat(omp_default_agent, &state) != 0) &&+ (stat(omp_profile_mcp, &state) != 0) &&+ (stat(omp_profile_agent, &state) != 0) &&+ (stat(omp_relocated_mcp, &state) != 0) &&+ (stat(omp_relocated_agent, &state) != 0);++ for (size_t i = 0U; i < sizeof(env_names) / sizeof(env_names[0]); i++) {+ restore_test_env(env_names[i], saved_env[i]);+ }+ test_rmdir_r(tmpdir);+ if (!default_plan_ok || !profile_plan_ok || !relocated_plan_ok || !fallback_plan_ok ||+ !plan_did_not_mutate) {+ fprintf(stderr,+ "omp diag default=%d profile=%d relocated=%d fallback=%d plan_clean=%d\n",+ default_plan_ok, profile_plan_ok, relocated_plan_ok, fallback_plan_ok,+ plan_did_not_mutate);+ FAIL("OMP must resolve ~/.omp/agent under the documented fallback, honor OMP_PROFILE "+ "named-profile layout, follow PI_CODING_AGENT_DIR relocations, and never write a "+ "global AGENTS.md");+ }+ PASS();+}+++TEST(cli_registry_omp_named_profile_install_and_uninstall_preserve_user_content) {+ char tmpdir[256];+ snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-registry-omp-lifecycle-XXXXXX");+ if (!cbm_mkdtemp(tmpdir))+ FAIL("cbm_mkdtemp failed");++ const char *const env_names[] = {"HOME", "PATH", "OMP_PROFILE", "PI_CODING_AGENT_DIR",+ "XDG_CONFIG_HOME", "APPDATA"};+ char *saved_env[sizeof(env_names) / sizeof(env_names[0])];+ for (size_t i = 0U; i < sizeof(env_names) / sizeof(env_names[0]); i++) {+ saved_env[i] = save_test_env(env_names[i]);+ cbm_unsetenv(env_names[i]);+ }++ char agent_dir[640];+ char mcp_path[768];+ char instructions_path[768];+ char skill_path[768];+ char scout_path[768];+ char verify_path[768];+ char auditor_path[768];+ char binary_path[640];+ snprintf(agent_dir, sizeof(agent_dir), "%s/.omp/profiles/work/agent", tmpdir);+ snprintf(mcp_path, sizeof(mcp_path), "%s/mcp.json", agent_dir);+ snprintf(instructions_path, sizeof(instructions_path), "%s/AGENTS.md", agent_dir);+ snprintf(skill_path, sizeof(skill_path), "%s/skills/codebase-memory/SKILL.md", agent_dir);+ snprintf(scout_path, sizeof(scout_path), "%s/agents/codebase-memory-scout.md", agent_dir);+ snprintf(verify_path, sizeof(verify_path), "%s/agents/codebase-memory.md", agent_dir);+ snprintf(auditor_path, sizeof(auditor_path), "%s/agents/codebase-memory-auditor.md", agent_dir);+#ifdef _WIN32+ snprintf(binary_path, sizeof(binary_path), "%s/.local/bin/codebase-memory-mcp.exe", tmpdir);+#else+ snprintf(binary_path, sizeof(binary_path), "%s/.local/bin/codebase-memory-mcp", tmpdir);+#endif+ test_mkdirp(agent_dir);+ const char *user_instructions = "# User safety policy\nNever publish without approval.\n";+ write_test_file(instructions_path, user_instructions);+ cbm_setenv("HOME", tmpdir, 1);+ cbm_setenv("PATH", tmpdir, 1);+ cbm_setenv("OMP_PROFILE", "work", 1);++ int install_rc = cbm_install_agent_configs(tmpdir, binary_path, false, false);+ char *installed_mcp = read_test_file_alloc(mcp_path);+ char *installed_instructions = read_test_file_alloc(instructions_path);+ bool installed =+ install_rc == 0 && installed_mcp && strstr(installed_mcp, "codebase-memory-mcp") &&+ strstr(installed_mcp, binary_path) && installed_instructions &&+ strcmp(installed_instructions, user_instructions) == 0 &&+ test_file_contains_all(skill_path,+ (const char *const[]){"search_graph", "trace_path",+ "Sessions and Subagents"},+ 3U) &&+ test_file_contains_all(scout_path,+ (const char *const[]){"autoloadSkills: [codebase-memory]",+ "mcp__codebase_memory_mcp_search_graph"},+ 2U) &&+ test_file_contains_all(verify_path,+ (const char *const[]){"read-summarize: false",+ "mcp__codebase_memory_mcp_trace_path"},+ 2U) &&+ test_file_contains_all(auditor_path,+ (const char *const[]){"autoloadSkills: [codebase-memory]",+ "mcp__codebase_memory_mcp_check_index_coverage"},+ 2U);+ free(installed_mcp);+ free(installed_instructions);++ const char *modified_verify =+ "---\nname: codebase-memory\ndescription: User-owned OMP profile.\n---\n";+ write_test_file(verify_path, modified_verify);+ char *argv[] = {"uninstall", "--yes"};+ int uninstall_rc = cli_test_cmd_uninstall(2, argv);+ struct stat state;+ char *preserved_instructions = read_test_file_alloc(instructions_path);+ char *preserved_verify = read_test_file_alloc(verify_path);+ char *mcp_after = read_test_file_alloc(mcp_path);+ bool uninstalled =+ uninstall_rc == 0 && preserved_instructions &&+ strcmp(preserved_instructions, user_instructions) == 0 && preserved_verify &&+ strcmp(preserved_verify, modified_verify) == 0 && stat(skill_path, &state) != 0 &&+ stat(scout_path, &state) != 0 && stat(auditor_path, &state) != 0 &&+ (!mcp_after || !strstr(mcp_after, "codebase-memory-mcp"));+ free(preserved_instructions);+ free(preserved_verify);+ free(mcp_after);++ for (size_t i = 0U; i < sizeof(env_names) / sizeof(env_names[0]); i++) {+ restore_test_env(env_names[i], saved_env[i]);+ }+ test_rmdir_r(tmpdir);+ if (!installed || !uninstalled) {+ fprintf(stderr, "omp lifecycle diag install=%d uninstall=%d\n", installed, uninstalled);+ FAIL("OMP named-profile install/uninstall must use the effective directory, remove only "+ "canonical owned files, and preserve user AGENTS.md and modified profiles");+ }+ PASS();+}++TEST(cli_registry_omp_relocated_dry_run_is_non_mutating) {+ char tmpdir[256];+ snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-registry-omp-dry-run-XXXXXX");+ if (!cbm_mkdtemp(tmpdir))+ FAIL("cbm_mkdtemp failed");++ const char *const env_names[] = {"HOME", "PATH", "OMP_PROFILE", "PI_CODING_AGENT_DIR",+ "XDG_CONFIG_HOME", "APPDATA"};+ char *saved_env[sizeof(env_names) / sizeof(env_names[0])];+ for (size_t i = 0U; i < sizeof(env_names) / sizeof(env_names[0]); i++) {+ saved_env[i] = save_test_env(env_names[i]);+ cbm_unsetenv(env_names[i]);+ }++ char agent_dir[640];+ char mcp_path[768];+ char instructions_path[768];+ char skill_path[768];+ char verify_path[768];+ char binary_path[640];+ snprintf(agent_dir, sizeof(agent_dir), "%s/custom-agent", tmpdir);+ snprintf(mcp_path, sizeof(mcp_path), "%s/mcp.json", agent_dir);+ snprintf(instructions_path, sizeof(instructions_path), "%s/AGENTS.md", agent_dir);+ snprintf(skill_path, sizeof(skill_path), "%s/skills/codebase-memory/SKILL.md", agent_dir);+ snprintf(verify_path, sizeof(verify_path), "%s/agents/codebase-memory.md", agent_dir);+#ifdef _WIN32+ snprintf(binary_path, sizeof(binary_path), "%s/.local/bin/codebase-memory-mcp.exe", tmpdir);+#else+ snprintf(binary_path, sizeof(binary_path), "%s/.local/bin/codebase-memory-mcp", tmpdir);+#endif+ test_mkdirp(agent_dir);+ const char *user_instructions = "# Existing OMP instructions\nKeep this byte-identical.\n";+ write_test_file(instructions_path, user_instructions);+ cbm_setenv("HOME", tmpdir, 1);+ cbm_setenv("PATH", tmpdir, 1);+ cbm_setenv("PI_CODING_AGENT_DIR", agent_dir, 1);++ int dry_run_rc = cbm_install_agent_configs(tmpdir, binary_path, false, true);+ struct stat state;+ char *instructions_after = read_test_file_alloc(instructions_path);+ bool unchanged = dry_run_rc == 0 && instructions_after &&+ strcmp(instructions_after, user_instructions) == 0 &&+ stat(mcp_path, &state) != 0 && stat(skill_path, &state) != 0 &&+ stat(verify_path, &state) != 0;+ free(instructions_after);++ for (size_t i = 0U; i < sizeof(env_names) / sizeof(env_names[0]); i++) {+ restore_test_env(env_names[i], saved_env[i]);+ }+ test_rmdir_r(tmpdir);+ if (!unchanged)+ FAIL("OMP relocated dry-run must not create MCP, skill, agent, or instruction content");+ PASS();+}TEST(cli_registry_installs_gitlab_and_devin_lifecycle_context) {char tmpdir[256];@@ -13140,6 +13434,9 @@ SUITE(cli) {#endifRUN_TEST(cli_agent_client_registry_routes_plan_install_and_uninstall);RUN_TEST(cli_registry_installs_kimi_rovo_amp_durable_context);+ RUN_TEST(cli_registry_routes_omp_via_profile_and_pi_coding_agent_dir);+ RUN_TEST(cli_registry_omp_named_profile_install_and_uninstall_preserve_user_content);+ RUN_TEST(cli_registry_omp_relocated_dry_run_is_non_mutating);RUN_TEST(cli_registry_installs_gitlab_and_devin_lifecycle_context);#ifndef _WIN32RUN_TEST(cli_registry_hook_cleanup_is_independent_from_mcp_ownership);