Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Fix Zed and VS Code config paths on Windows
Martin Vogel9b302eeb8034
diff --git a/src/cli/cli.c b/src/cli/cli.cindex ecf198166..a0aab048d 100644--- a/src/cli/cli.c+++ b/src/cli/cli.c@@ -975,8 +975,20 @@ cbm_detected_agents_t cbm_detect_agents(const char *home_dir) {#ifdef __APPLE__snprintf(path, sizeof(path), "%s/Library/Application Support/Zed", home_dir);+#elif defined(_WIN32)+ {+ const char *zed_local = cbm_app_local_dir();+ if (zed_local) {+ snprintf(path, sizeof(path), "%s/Zed", zed_local);+ }+ }#else- snprintf(path, sizeof(path), "%s/.config/zed", home_dir);+ {+ const char *zed_cfg = cbm_app_config_dir();+ if (zed_cfg) {+ snprintf(path, sizeof(path), "%s/zed", zed_cfg);+ }+ }#endifagents.zed = dir_exists(path);@@ -996,7 +1008,12 @@ cbm_detected_agents_t cbm_detect_agents(const char *home_dir) {#ifdef __APPLE__snprintf(path, sizeof(path), "%s/Library/Application Support/Code/User", home_dir);#else- snprintf(path, sizeof(path), "%s/.config/Code/User", home_dir);+ {+ const char *vs_cfg = cbm_app_config_dir();+ if (vs_cfg) {+ snprintf(path, sizeof(path), "%s/Code/User", vs_cfg);+ }+ }#endifagents.vscode = dir_exists(path);@@ -2711,8 +2728,10 @@ static void install_editor_agent_configs(const cbm_detected_agents_t *agents, cochar cp[CLI_BUF_1K];#ifdef __APPLE__snprintf(cp, sizeof(cp), "%s/Library/Application Support/Zed/settings.json", home);+#elif defined(_WIN32)+ snprintf(cp, sizeof(cp), "%s/Zed/settings.json", cbm_app_local_dir());#else- snprintf(cp, sizeof(cp), "%s/.config/zed/settings.json", home);+ snprintf(cp, sizeof(cp), "%s/zed/settings.json", cbm_app_config_dir());#endifinstall_generic_agent_config("Zed", binary_path, cp, NULL, dry_run, cbm_install_zed_mcp);}@@ -2731,7 +2750,7 @@ static void install_editor_agent_configs(const cbm_detected_agents_t *agents, co#ifdef __APPLE__snprintf(cp, sizeof(cp), "%s/Library/Application Support/Code/User/mcp.json", home);#else- snprintf(cp, sizeof(cp), "%s/.config/Code/User/mcp.json", home);+ snprintf(cp, sizeof(cp), "%s/Code/User/mcp.json", cbm_app_config_dir());#endifinstall_generic_agent_config("VS Code", binary_path, cp, NULL, dry_run,cbm_install_vscode_mcp);@@ -2983,8 +3002,10 @@ static void uninstall_editor_agents(const cbm_detected_agents_t *agents, const cchar cp[CLI_BUF_1K];#ifdef __APPLE__snprintf(cp, sizeof(cp), "%s/Library/Application Support/Zed/settings.json", home);+#elif defined(_WIN32)+ snprintf(cp, sizeof(cp), "%s/Zed/settings.json", cbm_app_local_dir());#else- snprintf(cp, sizeof(cp), "%s/.config/zed/settings.json", home);+ snprintf(cp, sizeof(cp), "%s/zed/settings.json", cbm_app_config_dir());#endifuninstall_agent_mcp_instr((mcp_uninstall_args_t){"Zed", cp, NULL}, dry_run,cbm_remove_zed_mcp);@@ -3004,7 +3025,7 @@ static void uninstall_editor_agents(const cbm_detected_agents_t *agents, const c#ifdef __APPLE__snprintf(cp, sizeof(cp), "%s/Library/Application Support/Code/User/mcp.json", home);#else- snprintf(cp, sizeof(cp), "%s/.config/Code/User/mcp.json", home);+ snprintf(cp, sizeof(cp), "%s/Code/User/mcp.json", cbm_app_config_dir());#endifuninstall_agent_mcp_instr((mcp_uninstall_args_t){"VS Code", cp, NULL}, dry_run,cbm_remove_vscode_mcp);diff --git a/src/discover/userconfig.c b/src/discover/userconfig.cindex 3c9cbbe47..63ba4885c 100644--- a/src/discover/userconfig.c+++ b/src/discover/userconfig.c@@ -152,25 +152,7 @@ static CBMLanguage lang_from_string(const char *s) {/* ── Config directory helper ─────────────────────────────────────── */-/*- * Get the XDG config dir for codebase-memory-mcp.- * Writes "<dir>/codebase-memory-mcp" into buf (up to bufsz bytes).- * Uses $XDG_CONFIG_HOME if set, else ~/.config.- */-static void cbm_app_config_dir(char *buf, size_t bufsz) {- char xdg[CBM_SZ_512] = {0};- cbm_safe_getenv("XDG_CONFIG_HOME", xdg, sizeof(xdg), NULL);- if (xdg[0]) {- snprintf(buf, bufsz, "%s/codebase-memory-mcp", xdg);- } else {- char home[CBM_SZ_512] = {0};- cbm_safe_getenv("HOME", home, sizeof(home), NULL);- if (!home[0]) {- snprintf(home, sizeof(home), "/tmp");- }- snprintf(buf, bufsz, "%s/.config/codebase-memory-mcp", home);- }-}+/* cbm_app_config_dir() is now in platform.c (cross-platform). *//* ── JSON parsing ────────────────────────────────────────────────── */@@ -312,11 +294,10 @@ cbm_userconfig_t *cbm_userconfig_load(const char *repo_path) {/* ── Step 1: Load global config ── */enum { PATH_BUF_SZ = 1280 };- char global_dir[CBM_SZ_1K];- cbm_app_config_dir(global_dir, sizeof(global_dir));-+ const char *cfg_base = cbm_app_config_dir();+ const char *cfg_fallback = cfg_base ? cfg_base : "/tmp";char global_path[PATH_BUF_SZ];- snprintf(global_path, sizeof(global_path), "%s/config.json", global_dir);+ snprintf(global_path, sizeof(global_path), "%s/codebase-memory-mcp/config.json", cfg_fallback);if (load_config_file(global_path, &entries, &count) != 0) {for (int i = 0; i < count; i++) {diff --git a/src/foundation/platform.c b/src/foundation/platform.cindex da00f0213..5b2f56707 100644--- a/src/foundation/platform.c+++ b/src/foundation/platform.c@@ -299,3 +299,58 @@ const char *cbm_get_home_dir(void) {}return NULL;}++/* ── App config directories (cross-platform) ─────────────────── */++const char *cbm_app_config_dir(void) {+ static char buf[CBM_SZ_1K];+ char tmp[CBM_SZ_256] = "";+#ifdef _WIN32+ cbm_safe_getenv("APPDATA", tmp, sizeof(tmp), NULL);+ if (tmp[0]) {+ snprintf(buf, sizeof(buf), "%s", tmp);+ cbm_normalize_path_sep(buf);+ return buf;+ }+ const char *home = cbm_get_home_dir();+ if (home) {+ snprintf(buf, sizeof(buf), "%s/AppData/Roaming", home);+ return buf;+ }+ return NULL;+#else+ /* Linux: XDG_CONFIG_HOME or ~/.config */+ cbm_safe_getenv("XDG_CONFIG_HOME", tmp, sizeof(tmp), NULL);+ if (tmp[0]) {+ snprintf(buf, sizeof(buf), "%s", tmp);+ return buf;+ }+ const char *home = cbm_get_home_dir();+ if (home) {+ snprintf(buf, sizeof(buf), "%s/.config", home);+ return buf;+ }+ return NULL;+#endif /* _WIN32 */+}++const char *cbm_app_local_dir(void) {+#ifdef _WIN32+ static char buf[CBM_SZ_1K];+ char tmp[CBM_SZ_256] = "";+ cbm_safe_getenv("LOCALAPPDATA", tmp, sizeof(tmp), NULL);+ if (tmp[0]) {+ snprintf(buf, sizeof(buf), "%s", tmp);+ cbm_normalize_path_sep(buf);+ return buf;+ }+ const char *home = cbm_get_home_dir();+ if (home) {+ snprintf(buf, sizeof(buf), "%s/AppData/Local", home);+ return buf;+ }+ return NULL;+#else+ return cbm_app_config_dir();+#endif+}diff --git a/src/foundation/platform.h b/src/foundation/platform.hindex 382768fee..99df10128 100644--- a/src/foundation/platform.h+++ b/src/foundation/platform.h@@ -81,6 +81,18 @@ const char *cbm_safe_getenv(const char *name, char *buf, size_t buf_sz, const ch* Returns NULL when neither is set. */const char *cbm_get_home_dir(void);+/* ── App config directories ────────────────────────────────────── */++/* Cross-platform app config directory (static buffer, not thread-safe).+ * Windows: %APPDATA% (e.g. C:/Users/.../AppData/Roaming)+ * macOS: $HOME (callers append Library/Application Support/...)+ * Linux: $XDG_CONFIG_HOME or ~/.config */+const char *cbm_app_config_dir(void);++/* Windows: %LOCALAPPDATA% (e.g. C:/Users/.../AppData/Local)+ * macOS/Linux: same as cbm_app_config_dir(). */+const char *cbm_app_local_dir(void);+/* ── File system ───────────────────────────────────────────────── *//* Check if a path exists. */