Skip to content

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.

fix(cli): support non-ASCII Windows agent paths

lorenzozanee56de845327dc
diff --git a/src/cli/cli.c b/src/cli/cli.c
index 51fbafc02..7cd59e0bf 100644
--- a/src/cli/cli.c
+++ b/src/cli/cli.c
@@ -19,6 +19,7 @@
#include "daemon/runtime.h"
#include "daemon/version_cohort.h"
#include "foundation/compat.h"
+#include "foundation/compat_fs.h"
#include "foundation/platform.h"
#include "foundation/constants.h"
#include "foundation/log.h"
@@ -2600,12 +2601,8 @@ int cbm_remove_zed_mcp_owned(const char *binary_path, const char *config_path) {
/* ── Agent detection ──────────────────────────────────────────── */
static bool dir_exists(const char *path) {
- struct stat st;
-#ifndef _WIN32
- return lstat(path, &st) == 0 && S_ISDIR(st.st_mode);
-#else
- return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
-#endif
+ cbm_path_info_t info = {0};
+ return cbm_path_info_utf8(path, &info) == CBM_PATH_INFO_OK && info.is_directory;
}
/* Resolve the Claude Code config dir.
diff --git a/tests/test_cli.c b/tests/test_cli.c
index 06ebb3841..b3c3c2f27 100644
--- a/tests/test_cli.c
+++ b/tests/test_cli.c
@@ -13074,6 +13074,24 @@ TEST(cli_detect_agents_finds_zed_in_roaming_appdata) {
}
#endif
+#ifdef _WIN32
+TEST(cli_detect_agents_handles_non_ascii_windows_profile) {
+ char home[1024];
+ snprintf(home, sizeof(home), "%s/cbm-用户-profile", cbm_tmpdir());
+ test_rmdir_r(home);
+ char claude_dir[1024];
+ snprintf(claude_dir, sizeof(claude_dir), "%s/.claude", home);
+ if (!test_mkdirp(claude_dir))
+ FAIL("could not create non-ASCII Windows profile path");
+
+ cbm_detected_agents_t agents = cbm_detect_agents(home);
+ test_rmdir_r(home);
+ if (!agents.claude_code)
+ FAIL("Claude detection must support non-ASCII Windows profile paths");
+ PASS();
+}
+#endif
+
TEST(cli_detect_agents_finds_antigravity) {
char tmpdir[256];
snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-detect-XXXXXX");
@@ -16258,6 +16276,7 @@ SUITE(cli) {
#endif
#ifdef _WIN32
RUN_TEST(cli_detect_agents_finds_zed_in_roaming_appdata);
+ RUN_TEST(cli_detect_agents_handles_non_ascii_windows_profile);
#endif
RUN_TEST(cli_detect_agents_finds_antigravity);
RUN_TEST(cli_detect_agents_finds_kilocode);