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: restore cross-platform lint and builds

Martin Vogel62d191b6d196
diff --git a/src/cli/cli.c b/src/cli/cli.c
index bf0887aca..33927dd2d 100644
--- a/src/cli/cli.c
+++ b/src/cli/cli.c
@@ -3798,10 +3798,12 @@ static const char cmm_subagent_script_prefix[] =
"# Fail-open: it never blocks or logs hook/prompt content.\n"
"BIN=";
+#ifndef _WIN32
static const char cmm_hook_script_suffix[] = "\n"
"[ -x \"$BIN\" ] || exit 0\n"
"\"$BIN\" hook-augment 2>/dev/null\n"
"exit 0\n";
+#endif
#ifdef _WIN32
static int cbm_escape_batch_value(const char *value, char *escaped, size_t escaped_size) {
@@ -4275,6 +4277,7 @@ int cbm_remove_gemini_hooks(const char *settings_path) {
#define GEMINI_HOOK_TIMEOUT_MS 5000
+#ifndef _WIN32
static int cbm_upsert_gemini_coverage_hook(const char *settings_path, const char *binary_path) {
char command[CLI_BUF_8K];
if (cbm_build_augment_dialect_command(binary_path, "gemini", command, sizeof(command)) !=
@@ -4304,6 +4307,7 @@ static int cbm_remove_gemini_coverage_hook(const char *settings_path, const char
.match_command_exact = command,
});
}
+#endif
/* Gemini CLI SessionStart reminder. settings.json uses the same
* hooks.<Event>[].hooks[] JSON shape as Claude, so it reuses upsert_hooks_json. */
diff --git a/src/cli/config_toml_edit.c b/src/cli/config_toml_edit.c
index 362ccaf42..33a01d6cf 100644
--- a/src/cli/config_toml_edit.c
+++ b/src/cli/config_toml_edit.c
@@ -518,14 +518,9 @@ static int toml_read_file(const char *path, char **out_data, size_t *out_len,
return TOML_EDIT_OK;
}
+#ifndef _WIN32
static char *toml_parent_directory(const char *path) {
const char *separator = strrchr(path, '/');
-#ifdef _WIN32
- const char *backslash = strrchr(path, '\\');
- if (!separator || (backslash && backslash > separator)) {
- separator = backslash;
- }
-#endif
if (!separator) {
return cbm_strdup(".");
}
@@ -534,6 +529,7 @@ static char *toml_parent_directory(const char *path) {
}
return cbm_strndup(path, (size_t)(separator - path));
}
+#endif
static int toml_snapshot_matches_path(const char *path, const char *old_data, size_t old_len,
const toml_file_snapshot_t *expected) {
diff --git a/src/main.c b/src/main.c
index f246f5578..01083e809 100644
--- a/src/main.c
+++ b/src/main.c
@@ -704,7 +704,7 @@ int main(int argc, char **argv) {
return subcmd;
}
cbm_mcp_tool_profile_t tool_profile = CBM_MCP_TOOL_PROFILE_ALL;
- if (cbm_mcp_parse_tool_profile_args(argc, argv, &tool_profile) != 0) {
+ if (cbm_mcp_parse_tool_profile_args(argc, (const char *const *)argv, &tool_profile) != 0) {
(void)fprintf(stderr, "codebase-memory-mcp: --tool-profile requires the supported value "
"'analysis' or 'scout'\n");
return 2;
@@ -795,10 +795,7 @@ int main(int argc, char **argv) {
if (!restricted_tool_profile) {
watch_store = cbm_store_open_memory();
g_watcher = cbm_watcher_new(watch_store, watcher_index_fn, NULL);
- }
-
- /* Wire watcher + config into MCP server for session auto-index */
- if (!restricted_tool_profile) {
+ /* Wire watcher + config into MCP server for session auto-index. */
cbm_mcp_server_set_watcher(g_server, g_watcher);
cbm_mcp_server_set_config(g_server, runtime_config);
}
diff --git a/src/mcp/mcp.c b/src/mcp/mcp.c
index cdefda6fe..af95e139e 100644
--- a/src/mcp/mcp.c
+++ b/src/mcp/mcp.c
@@ -692,7 +692,7 @@ static const char *mcp_tool_profile_name(cbm_mcp_tool_profile_t profile) {
return profile == CBM_MCP_TOOL_PROFILE_SCOUT ? "scout" : "analysis";
}
-int cbm_mcp_parse_tool_profile_args(int argc, char *const argv[],
+int cbm_mcp_parse_tool_profile_args(int argc, const char *const argv[const],
cbm_mcp_tool_profile_t *profile_out) {
if (argc < 0 || !argv || !profile_out) {
return -1;
diff --git a/src/mcp/mcp.h b/src/mcp/mcp.h
index fd6de4659..09a7ed1ec 100644
--- a/src/mcp/mcp.h
+++ b/src/mcp/mcp.h
@@ -102,7 +102,7 @@ typedef enum {
/* Parse the process-level tool-profile flag. Explicit malformed or unknown
* values fail closed with -1; absence selects the full default surface. */
-int cbm_mcp_parse_tool_profile_args(int argc, char *const argv[],
+int cbm_mcp_parse_tool_profile_args(int argc, const char *const argv[const],
cbm_mcp_tool_profile_t *profile_out);
/* Restricted servers must not start a second unrestricted HTTP/RPC surface. */
diff --git a/tests/test_mcp.c b/tests/test_mcp.c
index 90183796e..7ca8ccc64 100644
--- a/tests/test_mcp.c
+++ b/tests/test_mcp.c
@@ -826,13 +826,13 @@ TEST(server_handle_scout_profile_exposes_only_the_fast_tier) {
TEST(analysis_profile_arguments_fail_closed_and_disable_http) {
cbm_mcp_tool_profile_t profile = CBM_MCP_TOOL_PROFILE_ALL;
- char *no_profile[] = {"codebase-memory-mcp"};
- char *analysis_equals[] = {"codebase-memory-mcp", "--tool-profile=analysis"};
- char *analysis_pair[] = {"codebase-memory-mcp", "--tool-profile", "analysis"};
- char *scout_equals[] = {"codebase-memory-mcp", "--tool-profile=scout"};
- char *unknown_equals[] = {"codebase-memory-mcp", "--tool-profile=analaysis"};
- char *unknown_pair[] = {"codebase-memory-mcp", "--tool-profile", "all"};
- char *missing_value[] = {"codebase-memory-mcp", "--tool-profile"};
+ const char *no_profile[] = {"codebase-memory-mcp"};
+ const char *analysis_equals[] = {"codebase-memory-mcp", "--tool-profile=analysis"};
+ const char *analysis_pair[] = {"codebase-memory-mcp", "--tool-profile", "analysis"};
+ const char *scout_equals[] = {"codebase-memory-mcp", "--tool-profile=scout"};
+ const char *unknown_equals[] = {"codebase-memory-mcp", "--tool-profile=analaysis"};
+ const char *unknown_pair[] = {"codebase-memory-mcp", "--tool-profile", "all"};
+ const char *missing_value[] = {"codebase-memory-mcp", "--tool-profile"};
ASSERT_EQ(cbm_mcp_parse_tool_profile_args(1, no_profile, &profile), 0);
ASSERT_EQ(profile, CBM_MCP_TOOL_PROFILE_ALL);