| 2579 | } |
| 2580 | |
| 2581 | static void cbm_opencode_config_path(const char *home_dir, char *out, size_t out_sz) { |
| 2582 | char env_buf[CLI_BUF_1K]; |
| 2583 | const char *custom = cbm_safe_getenv("OPENCODE_CONFIG", env_buf, sizeof(env_buf), NULL); |
| 2584 | if (custom && custom[0]) { |
| 2585 | snprintf(out, out_sz, "%s", custom); |
| 2586 | return; |
| 2587 | } |
| 2588 | /* OpenCode reads either opencode.json or opencode.jsonc. We always wrote |
| 2589 | * the .json name, so a user whose real config is .jsonc got a SECOND file |
| 2590 | * that OpenCode ignores — their MCP server silently never appeared, and the |
| 2591 | * install looked like it had succeeded (discussion #1560). Prefer whichever |
| 2592 | * file already exists, .jsonc first since it is the one we used to miss; |
| 2593 | * with neither present, create .json as before. Other clients in this file |
| 2594 | * (pochi, kilo) already carry .jsonc paths — OpenCode was the gap. */ |
| 2595 | char candidate[CLI_BUF_1K]; |
| 2596 | int written = snprintf(candidate, sizeof(candidate), "%s/.config/opencode/opencode.jsonc", |
| 2597 | home_dir ? home_dir : ""); |
| 2598 | if (written > 0 && (size_t)written < sizeof(candidate) && cbm_file_exists(candidate)) { |
| 2599 | snprintf(out, out_sz, "%s", candidate); |
| 2600 | return; |
| 2601 | } |
| 2602 | snprintf(out, out_sz, "%s/.config/opencode/opencode.json", home_dir); |
| 2603 | } |
| 2604 | |
| 2605 | static void cbm_copilot_config_dir(const char *home_dir, char *out, size_t out_sz) { |
| 2606 | char env_buf[CLI_BUF_1K]; |
no test coverage detected