MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_opencode_config_path

Function cbm_opencode_config_path

src/cli/cli.c:2953–2975  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2951}
2952
2953static void cbm_opencode_config_path(const char *home_dir, char *out, size_t out_sz) {
2954 char env_buf[CLI_BUF_1K];
2955 const char *custom = cbm_safe_getenv("OPENCODE_CONFIG", env_buf, sizeof(env_buf), NULL);
2956 if (custom && custom[0]) {
2957 snprintf(out, out_sz, "%s", custom);
2958 return;
2959 }
2960 /* OpenCode reads either opencode.json or opencode.jsonc. We always wrote
2961 * the .json name, so a user whose real config is .jsonc got a SECOND file
2962 * that OpenCode ignores — their MCP server silently never appeared, and the
2963 * install looked like it had succeeded (discussion #1560). Prefer whichever
2964 * file already exists, .jsonc first since it is the one we used to miss;
2965 * with neither present, create .json as before. Other clients in this file
2966 * (pochi, kilo) already carry .jsonc paths — OpenCode was the gap. */
2967 char candidate[CLI_BUF_1K];
2968 int written = snprintf(candidate, sizeof(candidate), "%s/.config/opencode/opencode.jsonc",
2969 home_dir ? home_dir : "");
2970 if (written > 0 && (size_t)written < sizeof(candidate) && cbm_file_exists(candidate)) {
2971 snprintf(out, out_sz, "%s", candidate);
2972 return;
2973 }
2974 snprintf(out, out_sz, "%s/.config/opencode/opencode.json", home_dir);
2975}
2976
2977static void cbm_copilot_config_dir(const char *home_dir, char *out, size_t out_sz) {
2978 char env_buf[CLI_BUF_1K];

Callers 3

cbm_opencode_detectedFunction · 0.85
uninstall_cli_agentsFunction · 0.85

Calls 2

cbm_safe_getenvFunction · 0.85
cbm_file_existsFunction · 0.85

Tested by

no test coverage detected