| 9109 | } |
| 9110 | |
| 9111 | static bool cbm_omp_agent_dir(const char *home_dir, char *out, size_t out_sz) { |
| 9112 | char profile_buf[CLI_BUF_256]; |
| 9113 | const char *profile = cbm_safe_getenv("OMP_PROFILE", profile_buf, sizeof(profile_buf), NULL); |
| 9114 | if (profile && profile[0]) { |
| 9115 | for (const unsigned char *p = (const unsigned char *)profile; *p; p++) { |
| 9116 | if (!isalnum(*p) && *p != '-' && *p != '_') { |
| 9117 | return false; |
| 9118 | } |
| 9119 | } |
| 9120 | int written = snprintf(out, out_sz, "%s/.omp/profiles/%s/agent", home_dir, profile); |
| 9121 | return written > 0 && (size_t)written < out_sz; |
| 9122 | } |
| 9123 | |
| 9124 | char agent_dir_buf[CLI_BUF_1K]; |
| 9125 | const char *agent_dir = |
| 9126 | cbm_safe_getenv("PI_CODING_AGENT_DIR", agent_dir_buf, sizeof(agent_dir_buf), NULL); |
| 9127 | if (agent_dir && agent_dir[0]) { |
| 9128 | return cbm_expand_user_path(home_dir, agent_dir, out, out_sz); |
| 9129 | } |
| 9130 | int written = snprintf(out, out_sz, "%s/.omp/agent", home_dir); |
| 9131 | return written > 0 && (size_t)written < out_sz; |
| 9132 | } |
| 9133 | |
| 9134 | typedef struct { |
| 9135 | cbm_agent_client_resolve_options_t options; |
no test coverage detected