@@ -8109,6 +8109,29 @@ static void install_copilot_durable_context(const char *home, const char *binary
81098109 }
81108110}
81118111
8112+ static bool cbm_omp_agent_dir(const char *home_dir, char *out, size_t out_sz) {
8113+ char profile_buf[CLI_BUF_256];
8114+ const char *profile = cbm_safe_getenv("OMP_PROFILE", profile_buf, sizeof(profile_buf), NULL);
8115+ if (profile && profile[0]) {
8116+ for (const unsigned char *p = (const unsigned char *)profile; *p; p++) {
8117+ if (!isalnum(*p) && *p != '-' && *p != '_') {
8118+ return false;
8119+ }
8120+ }
8121+ int written = snprintf(out, out_sz, "%s/.omp/profiles/%s/agent", home_dir, profile);
8122+ return written > 0 && (size_t)written < out_sz;
8123+ }
8124+
8125+ char agent_dir_buf[CLI_BUF_1K];
8126+ const char *agent_dir =
8127+ cbm_safe_getenv("PI_CODING_AGENT_DIR", agent_dir_buf, sizeof(agent_dir_buf), NULL);
8128+ if (agent_dir && agent_dir[0]) {
8129+ return cbm_expand_user_path(home_dir, agent_dir, out, out_sz);
8130+ }
8131+ int written = snprintf(out, out_sz, "%s/.omp/agent", home_dir);
8132+ return written > 0 && (size_t)written < out_sz;
8133+ }
8134+
81128135typedef struct {
81138136 cbm_agent_client_resolve_options_t options;
81148137 char xdg_config_home[CLI_BUF_1K];
@@ -8119,6 +8142,7 @@ typedef struct {
81198142 char trae_config_path[CLI_BUF_1K];
81208143 char roo_config_path[CLI_BUF_1K];
81218144 char cody_config_path[CLI_BUF_1K];
8145+ char omp_agent_dir[CLI_BUF_1K];
81228146} cbm_agent_registry_context_t;
81238147
81248148static 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,
81708194 registry->options.cody_config_path =
81718195 cbm_agent_registry_env_path("CBM_CODY_CONFIG_PATH", home, registry->cody_config_path,
81728196 sizeof(registry->cody_config_path));
8197+ if (cbm_omp_agent_dir(home, registry->omp_agent_dir, sizeof(registry->omp_agent_dir))) {
8198+ registry->options.omp_agent_dir = registry->omp_agent_dir;
8199+ }
81738200#ifdef _WIN32
81748201 registry->options.is_windows = true;
81758202#else
@@ -8535,14 +8562,26 @@ static void install_pochi_durable_context(const char *home, bool force, bool dry
85358562 dry_run);
85368563}
85378564
8538- static void install_omp_durable_context(const char *home, bool force, bool dry_run) {
8539- char instructions_path[CLI_BUF_1K];
8565+ static void install_omp_durable_context(const cbm_agent_registry_context_t *registry,
8566+ bool force, bool dry_run) {
8567+ const char *agent_dir = registry->options.omp_agent_dir
8568+ && registry->options.omp_agent_dir[0]
8569+ ? registry->options.omp_agent_dir
8570+ : NULL;
8571+ char resolved_dir[CLI_BUF_1K];
8572+ if (!agent_dir) {
8573+ int written = snprintf(resolved_dir, sizeof(resolved_dir), "%s/.omp/agent",
8574+ registry->options.home_dir);
8575+ if (written < 0 || (size_t)written >= sizeof(resolved_dir)) {
8576+ record_agent_config_error(false, "Oh My Pi (omp)", "context_resolve", "omp");
8577+ return;
8578+ }
8579+ agent_dir = resolved_dir;
8580+ }
85408581 char skills_dir[CLI_BUF_1K];
85418582 char agent_path[CLI_BUF_1K];
8542- snprintf(instructions_path, sizeof(instructions_path), "%s/.omp/agent/AGENTS.md", home);
8543- snprintf(skills_dir, sizeof(skills_dir), "%s/.omp/agent/skills", home);
8544- snprintf(agent_path, sizeof(agent_path), "%s/.omp/agent/agents/codebase-memory.md", home);
8545- install_managed_agent_instructions("Oh My Pi (omp)", instructions_path, dry_run);
8583+ snprintf(skills_dir, sizeof(skills_dir), "%s/skills", agent_dir);
8584+ snprintf(agent_path, sizeof(agent_path), "%s/agents/codebase-memory.md", agent_dir);
85468585 install_agent_skill("Oh My Pi (omp)", skills_dir, force, dry_run);
85478586 install_tiered_agent_profiles(
85488587 (cbm_tiered_profile_set_t){
@@ -8623,7 +8662,7 @@ static void install_agent_client_registry(const char *home, const char *binary_p
86238662 } else if (profile->id == CBM_AGENT_CLIENT_PI) {
86248663 install_pi_durable_context(home, binary_path, force, dry_run);
86258664 } else if (profile->id == CBM_AGENT_CLIENT_OMP) {
8626- install_omp_durable_context(home , force, dry_run);
8665+ install_omp_durable_context(®istry , force, dry_run);
86278666 }
86288667 }
86298668}
@@ -10838,14 +10877,26 @@ static void uninstall_pochi_durable_context(const char *home, bool dry_run) {
1083810877 dry_run);
1083910878}
1084010879
10841- static void uninstall_omp_durable_context(const char *home, bool dry_run) {
10842- char instructions_path[CLI_BUF_1K];
10880+ static void uninstall_omp_durable_context(const cbm_agent_registry_context_t *registry,
10881+ bool dry_run) {
10882+ const char *agent_dir = registry->options.omp_agent_dir
10883+ && registry->options.omp_agent_dir[0]
10884+ ? registry->options.omp_agent_dir
10885+ : NULL;
10886+ char resolved_dir[CLI_BUF_1K];
10887+ if (!agent_dir) {
10888+ int written = snprintf(resolved_dir, sizeof(resolved_dir), "%s/.omp/agent",
10889+ registry->options.home_dir);
10890+ if (written < 0 || (size_t)written >= sizeof(resolved_dir)) {
10891+ record_agent_config_error(true, "Oh My Pi (omp)", "context_resolve", "omp");
10892+ return;
10893+ }
10894+ agent_dir = resolved_dir;
10895+ }
1084310896 char skills_dir[CLI_BUF_1K];
1084410897 char agent_path[CLI_BUF_1K];
10845- snprintf(instructions_path, sizeof(instructions_path), "%s/.omp/agent/AGENTS.md", home);
10846- snprintf(skills_dir, sizeof(skills_dir), "%s/.omp/agent/skills", home);
10847- snprintf(agent_path, sizeof(agent_path), "%s/.omp/agent/agents/codebase-memory.md", home);
10848- uninstall_managed_agent_instructions("Oh My Pi (omp)", instructions_path, dry_run);
10898+ snprintf(skills_dir, sizeof(skills_dir), "%s/skills", agent_dir);
10899+ snprintf(agent_path, sizeof(agent_path), "%s/agents/codebase-memory.md", agent_dir);
1084910900 uninstall_agent_skill("Oh My Pi (omp)", skills_dir, dry_run);
1085010901 uninstall_tiered_agent_profiles(
1085110902 (cbm_tiered_profile_set_t){
@@ -10917,7 +10968,7 @@ static void uninstall_agent_client_registry(const char *home, bool dry_run) {
1091710968 } else if (profile->id == CBM_AGENT_CLIENT_PI) {
1091810969 uninstall_pi_durable_context(home, dry_run);
1091910970 } else if (profile->id == CBM_AGENT_CLIENT_OMP) {
10920- uninstall_omp_durable_context(home , dry_run);
10971+ uninstall_omp_durable_context(®istry , dry_run);
1092110972 }
1092210973 }
1092310974}
0 commit comments