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 lint issues in userconfig + add custom extensions docs to README

Martin Vogel7f33e8b49b20
diff --git a/README.md b/README.md
index 8a4ffb3b8..c9e18baa6 100644
--- a/README.md
+++ b/README.md
@@ -306,6 +306,24 @@ codebase-memory-mcp config set auto_index_limit 50000 # max files for auto-in
codebase-memory-mcp config reset auto_index # reset to default
```
+## Custom File Extensions
+
+Map additional file extensions to supported languages via JSON config files. Useful for framework-specific extensions like `.blade.php` (Laravel) or `.mjs` (ES modules).
+
+**Per-project** (in your repo root):
+```json
+// .codebase-memory.json
+{"extra_extensions": {".blade.php": "php", ".mjs": "javascript"}}
+```
+
+**Global** (applies to all projects):
+```json
+// ~/.config/codebase-memory-mcp/config.json (or $XDG_CONFIG_HOME/...)
+{"extra_extensions": {".twig": "html", ".phtml": "php"}}
+```
+
+Project config overrides global for conflicting extensions. Unknown language values are silently skipped. Missing config files are ignored.
+
## Persistence
SQLite databases stored at `~/.cache/codebase-memory-mcp/`. Persists across restarts (WAL mode, ACID-safe). To reset: `rm -rf ~/.cache/codebase-memory-mcp/`.
diff --git a/src/discover/userconfig.c b/src/discover/userconfig.c
index d9dd74982..4b6d27b80 100644
--- a/src/discover/userconfig.c
+++ b/src/discover/userconfig.c
@@ -219,8 +219,7 @@ static int parse_extra_extensions(yyjson_val *root, cbm_userext_t **entries, int
}
/* Grow the array */
- cbm_userext_t *tmp =
- realloc(*entries, (size_t)(*count + 1) * sizeof(cbm_userext_t));
+ cbm_userext_t *tmp = realloc(*entries, (size_t)(*count + 1) * sizeof(cbm_userext_t));
if (!tmp) {
return -1;
}
@@ -297,10 +296,11 @@ cbm_userconfig_t *cbm_userconfig_load(const char *repo_path) {
int count = 0;
/* ── Step 1: Load global config ── */
+ enum { PATH_BUF_SZ = 1280 };
char global_dir[1024];
cbm_app_config_dir(global_dir, sizeof(global_dir));
- char global_path[1280];
+ char global_path[PATH_BUF_SZ];
snprintf(global_path, sizeof(global_path), "%s/config.json", global_dir);
if (load_config_file(global_path, &entries, &count) != 0) {
@@ -316,7 +316,7 @@ cbm_userconfig_t *cbm_userconfig_load(const char *repo_path) {
/* ── Step 2: Load project config ── */
if (repo_path && repo_path[0]) {
- char project_path[1280];
+ char project_path[PATH_BUF_SZ];
snprintf(project_path, sizeof(project_path), "%s/.codebase-memory.json", repo_path);
if (load_config_file(project_path, &entries, &count) != 0) {
@@ -345,7 +345,6 @@ cbm_userconfig_t *cbm_userconfig_load(const char *repo_path) {
entries[g] = entries[global_count - 1];
entries[global_count - 1].ext = NULL; /* mark as consumed */
global_count--;
- g--; /* re-check this index */
break;
}
}
diff --git a/src/discover/userconfig.h b/src/discover/userconfig.h
index c45777fba..233734845 100644
--- a/src/discover/userconfig.h
+++ b/src/discover/userconfig.h
@@ -22,8 +22,8 @@
/* ── Types ──────────────────────────────────────────────────────── */
typedef struct {
- char *ext; /* file extension including dot, e.g. ".blade.php" */
- CBMLanguage lang; /* resolved language enum */
+ char *ext; /* file extension including dot, e.g. ".blade.php" */
+ CBMLanguage lang; /* resolved language enum */
} cbm_userext_t;
typedef struct {