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
Add KiloCode support, fix Zed JSONC parsing (#24, #53)
Martin Vogel442cb958f02f
diff --git a/src/cli/cli.c b/src/cli/cli.cindex 1a969501c..23bf6d038 100644--- a/src/cli/cli.c+++ b/src/cli/cli.c@@ -537,7 +537,9 @@ static yyjson_doc *read_json_file(const char *path) {// NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[nread] = '\0';- yyjson_doc *doc = yyjson_read(buf, nread, 0);+ /* Allow JSONC (comments + trailing commas) — Zed settings.json uses this format */+ yyjson_read_flag flags = YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS;+ yyjson_doc *doc = yyjson_read(buf, nread, flags);free(buf);return doc;}@@ -811,7 +813,7 @@ int cbm_remove_zed_mcp(const char *config_path) {/* ── Agent detection ──────────────────────────────────────────── */cbm_detected_agents_t cbm_detect_agents(const char *home_dir) {- cbm_detected_agents_t agents = {false, false, false, false, false, false, false};+ cbm_detected_agents_t agents = {false, false, false, false, false, false, false, false};if (!home_dir || !home_dir[0]) {return agents;}@@ -866,6 +868,12 @@ cbm_detected_agents_t cbm_detect_agents(const char *home_dir) {agents.aider = true;}+ /* KiloCode: globalStorage dir */+ snprintf(path, sizeof(path), "%s/.config/Code/User/globalStorage/kilocode.kilo-code", home_dir);+ if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {+ agents.kilocode = true;+ }+return agents;}@@ -1808,8 +1816,11 @@ int cbm_cmd_install(int argc, char **argv) {if (agents.aider) {printf(" Aider");}+ if (agents.kilocode) {+ printf(" KiloCode");+ }if (!agents.claude_code && !agents.codex && !agents.gemini && !agents.zed && !agents.opencode &&- !agents.antigravity && !agents.aider) {+ !agents.antigravity && !agents.aider && !agents.kilocode) {printf(" (none)");}printf("\n\n");@@ -1949,7 +1960,28 @@ int cbm_cmd_install(int argc, char **argv) {printf(" instructions: %s\n", instr_path);}- /* Step 11: Ensure PATH */+ /* Step 11: Install KiloCode */+ if (agents.kilocode) {+ printf("KiloCode:\n");+ char config_path[1024];+ snprintf(config_path, sizeof(config_path),+ "%s/.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json",+ home);+ if (!dry_run) {+ cbm_install_editor_mcp(self_path, config_path);+ }+ printf(" mcp: %s\n", config_path);++ /* KiloCode uses ~/.kilocode/rules/ for global instructions */+ char instr_path[1024];+ snprintf(instr_path, sizeof(instr_path), "%s/.kilocode/rules/codebase-memory-mcp.md", home);+ if (!dry_run) {+ cbm_upsert_instructions(instr_path, agent_instructions_content);+ }+ printf(" instructions: %s\n", instr_path);+ }++ /* Step 12: Ensure PATH */char bin_dir[1024];snprintf(bin_dir, sizeof(bin_dir), "%s/.local/bin", home);const char *rc = cbm_detect_shell_rc(home);@@ -2105,6 +2137,24 @@ int cbm_cmd_uninstall(int argc, char **argv) {printf("Aider: removed instructions\n");}+ if (agents.kilocode) {+ char config_path[1024];+ snprintf(config_path, sizeof(config_path),+ "%s/.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json",+ home);+ if (!dry_run) {+ cbm_remove_editor_mcp(config_path);+ }+ printf("KiloCode: removed MCP config entry\n");++ char instr_path[1024];+ snprintf(instr_path, sizeof(instr_path), "%s/.kilocode/rules/codebase-memory-mcp.md", home);+ if (!dry_run) {+ cbm_remove_instructions(instr_path);+ }+ printf(" removed instructions\n");+ }+/* Step 2: Remove indexes */int index_count = 0;const char *cache_dir = get_cache_dir(home);diff --git a/src/cli/cli.h b/src/cli/cli.hindex a61432a51..a0351ae09 100644--- a/src/cli/cli.h+++ b/src/cli/cli.h@@ -112,6 +112,7 @@ typedef struct {bool opencode; /* opencode on PATH or config exists */bool antigravity; /* ~/.gemini/antigravity/ exists */bool aider; /* aider on PATH */+ bool kilocode; /* KiloCode globalStorage dir exists */} cbm_detected_agents_t;/* Detect which coding agents are installed.diff --git a/src/main.c b/src/main.cindex c8f17dcc5..efd7fb056 100644--- a/src/main.c+++ b/src/main.c@@ -134,7 +134,7 @@ static void print_help(void) {printf(" --ui=false Disable HTTP graph visualization (persisted)\n");printf(" --port=N Set UI port (default 9749, persisted)\n");printf("\nSupported agents (auto-detected):\n");- printf(" Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider\n");+ printf(" Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode\n");printf("\nTools: index_repository, search_graph, query_graph, trace_call_path,\n");printf(" get_code_snippet, get_graph_schema, get_architecture, search_code,\n");printf(" list_projects, delete_project, index_status, detect_changes,\n");diff --git a/tests/test_cli.c b/tests/test_cli.cindex c4ea3234c..2a1406c6a 100644--- a/tests/test_cli.c+++ b/tests/test_cli.c@@ -833,6 +833,44 @@ TEST(cli_zed_mcp_uninstall) {PASS();}+TEST(cli_zed_mcp_jsonc_comments) {+ /* Issue #24: Zed settings.json uses JSONC (comments + trailing commas) */+ char tmpdir[256]; snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-mcp-XXXXXX");+ if (!cbm_mkdtemp(tmpdir))+ SKIP("cbm_mkdtemp failed");++ char configpath[512];+ snprintf(configpath, sizeof(configpath), "%s/.config/zed/settings.json", tmpdir);+ char dir[512];+ snprintf(dir, sizeof(dir), "%s/.config/zed", tmpdir);+ test_mkdirp(dir);++ /* JSONC with comments and trailing commas — must not fail */+ write_test_file(configpath,+ "// Zed settings\n"+ "{\n"+ " \"theme\": \"One Dark\",\n"+ " /* multi-line\n"+ " comment */\n"+ " \"vim_mode\": true,\n" /* trailing comma */+ "}\n");++ int rc = cbm_install_zed_mcp("/usr/local/bin/codebase-memory-mcp", configpath);+ ASSERT_EQ(rc, 0);++ const char *data = read_test_file(configpath);+ ASSERT_NOT_NULL(data);+ /* Original settings preserved */+ ASSERT(strstr(data, "One Dark") != NULL);+ ASSERT(strstr(data, "vim_mode") != NULL);+ /* MCP server added */+ ASSERT(strstr(data, "codebase-memory-mcp") != NULL);+ ASSERT(strstr(data, "context_servers") != NULL);++ test_rmdir_r(tmpdir);+ PASS();+}+/* ═══════════════════════════════════════════════════════════════════* PATH management tests (port of TestCLI_InstallPATHAppend)* ═══════════════════════════════════════════════════════════════════ */@@ -1261,6 +1299,22 @@ TEST(cli_detect_agents_finds_antigravity) {PASS();}+TEST(cli_detect_agents_finds_kilocode) {+ char tmpdir[256]; snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-detect-XXXXXX");+ if (!cbm_mkdtemp(tmpdir)) SKIP("cbm_mkdtemp failed");++ char dir[512];+ snprintf(dir, sizeof(dir),+ "%s/.config/Code/User/globalStorage/kilocode.kilo-code", tmpdir);+ test_mkdirp(dir);++ cbm_detected_agents_t agents = cbm_detect_agents(tmpdir);+ ASSERT_TRUE(agents.kilocode);++ test_rmdir_r(tmpdir);+ PASS();+}+TEST(cli_detect_agents_none_found) {char tmpdir[256]; snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-detect-XXXXXX");if (!cbm_mkdtemp(tmpdir)) SKIP("cbm_mkdtemp failed");@@ -1274,6 +1328,7 @@ TEST(cli_detect_agents_none_found) {ASSERT_FALSE(agents.gemini);ASSERT_FALSE(agents.zed);ASSERT_FALSE(agents.antigravity);+ ASSERT_FALSE(agents.kilocode);rmdir(tmpdir);PASS();@@ -1871,6 +1926,7 @@ SUITE(cli) {RUN_TEST(cli_zed_mcp_install);RUN_TEST(cli_zed_mcp_preserves_settings);RUN_TEST(cli_zed_mcp_uninstall);+ RUN_TEST(cli_zed_mcp_jsonc_comments);/* PATH management (3 tests) */RUN_TEST(cli_ensure_path_append);@@ -1908,6 +1964,7 @@ SUITE(cli) {RUN_TEST(cli_detect_agents_finds_gemini);RUN_TEST(cli_detect_agents_finds_zed);RUN_TEST(cli_detect_agents_finds_antigravity);+ RUN_TEST(cli_detect_agents_finds_kilocode);RUN_TEST(cli_detect_agents_none_found);/* Codex MCP config upsert (3 tests — group B) */