Skip to content

Commit 56de845

Browse files
committed
fix(cli): support non-ASCII Windows agent paths
Signed-off-by: lorenzozanee <wyz0707@proton.me>
1 parent 45c45be commit 56de845

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

‎src/cli/cli.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "daemon/runtime.h"
2020
#include "daemon/version_cohort.h"
2121
#include "foundation/compat.h"
22+
#include "foundation/compat_fs.h"
2223
#include "foundation/platform.h"
2324
#include "foundation/constants.h"
2425
#include "foundation/log.h"
@@ -2600,12 +2601,8 @@ int cbm_remove_zed_mcp_owned(const char *binary_path, const char *config_path) {
26002601
/* ── Agent detection ──────────────────────────────────────────── */
26012602

26022603
static bool dir_exists(const char *path) {
2603-
struct stat st;
2604-
#ifndef _WIN32
2605-
return lstat(path, &st) == 0 && S_ISDIR(st.st_mode);
2606-
#else
2607-
return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
2608-
#endif
2604+
cbm_path_info_t info = {0};
2605+
return cbm_path_info_utf8(path, &info) == CBM_PATH_INFO_OK && info.is_directory;
26092606
}
26102607

26112608
/* Resolve the Claude Code config dir.

‎tests/test_cli.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13074,6 +13074,24 @@ TEST(cli_detect_agents_finds_zed_in_roaming_appdata) {
1307413074
}
1307513075
#endif
1307613076

13077+
#ifdef _WIN32
13078+
TEST(cli_detect_agents_handles_non_ascii_windows_profile) {
13079+
char home[1024];
13080+
snprintf(home, sizeof(home), "%s/cbm-用户-profile", cbm_tmpdir());
13081+
test_rmdir_r(home);
13082+
char claude_dir[1024];
13083+
snprintf(claude_dir, sizeof(claude_dir), "%s/.claude", home);
13084+
if (!test_mkdirp(claude_dir))
13085+
FAIL("could not create non-ASCII Windows profile path");
13086+
13087+
cbm_detected_agents_t agents = cbm_detect_agents(home);
13088+
test_rmdir_r(home);
13089+
if (!agents.claude_code)
13090+
FAIL("Claude detection must support non-ASCII Windows profile paths");
13091+
PASS();
13092+
}
13093+
#endif
13094+
1307713095
TEST(cli_detect_agents_finds_antigravity) {
1307813096
char tmpdir[256];
1307913097
snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-detect-XXXXXX");
@@ -16258,6 +16276,7 @@ SUITE(cli) {
1625816276
#endif
1625916277
#ifdef _WIN32
1626016278
RUN_TEST(cli_detect_agents_finds_zed_in_roaming_appdata);
16279+
RUN_TEST(cli_detect_agents_handles_non_ascii_windows_profile);
1626116280
#endif
1626216281
RUN_TEST(cli_detect_agents_finds_antigravity);
1626316282
RUN_TEST(cli_detect_agents_finds_kilocode);

0 commit comments

Comments
 (0)