| 2469 | } |
| 2470 | |
| 2471 | static void cbm_opencode_config_path(const char *home_dir, char *out, size_t out_sz) { |
| 2472 | char env_buf[CLI_BUF_1K]; |
| 2473 | const char *custom = cbm_safe_getenv("OPENCODE_CONFIG", env_buf, sizeof(env_buf), NULL); |
| 2474 | if (custom && custom[0]) { |
| 2475 | snprintf(out, out_sz, "%s", custom); |
| 2476 | return; |
| 2477 | } |
| 2478 | /* OpenCode reads either opencode.json or opencode.jsonc. We always wrote |
| 2479 | * the .json name, so a user whose real config is .jsonc got a SECOND file |
| 2480 | * that OpenCode ignores — their MCP server silently never appeared, and the |
| 2481 | * install looked like it had succeeded (discussion #1560). Prefer whichever |
| 2482 | * file already exists, .jsonc first since it is the one we used to miss; |
| 2483 | * with neither present, create .json as before. Other clients in this file |
| 2484 | * (pochi, kilo) already carry .jsonc paths — OpenCode was the gap. */ |
| 2485 | char candidate[CLI_BUF_1K]; |
| 2486 | int written = snprintf(candidate, sizeof(candidate), "%s/.config/opencode/opencode.jsonc", |
| 2487 | home_dir ? home_dir : ""); |
| 2488 | if (written > 0 && (size_t)written < sizeof(candidate) && cbm_file_exists(candidate)) { |
| 2489 | snprintf(out, out_sz, "%s", candidate); |
| 2490 | return; |
| 2491 | } |
| 2492 | snprintf(out, out_sz, "%s/.config/opencode/opencode.json", home_dir); |
| 2493 | } |
| 2494 | |
| 2495 | static void cbm_copilot_config_dir(const char *home_dir, char *out, size_t out_sz) { |
| 2496 | char env_buf[CLI_BUF_1K]; |
no test coverage detected