Skip to content

Commit 7f33e8b

Browse files
committed
Fix lint issues in userconfig + add custom extensions docs to README
- clang-format: fix alignment in userconfig.c and userconfig.h - Magic number 1280 → PATH_BUF_SZ named constant - Remove dead g-- before break in dedup loop (cppcheck) - Add "Custom File Extensions" section to README documenting .codebase-memory.json and global config
1 parent 556ccef commit 7f33e8b

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,24 @@ codebase-memory-mcp config set auto_index_limit 50000 # max files for auto-in
306306
codebase-memory-mcp config reset auto_index # reset to default
307307
```
308308

309+
## Custom File Extensions
310+
311+
Map additional file extensions to supported languages via JSON config files. Useful for framework-specific extensions like `.blade.php` (Laravel) or `.mjs` (ES modules).
312+
313+
**Per-project** (in your repo root):
314+
```json
315+
// .codebase-memory.json
316+
{"extra_extensions": {".blade.php": "php", ".mjs": "javascript"}}
317+
```
318+
319+
**Global** (applies to all projects):
320+
```json
321+
// ~/.config/codebase-memory-mcp/config.json (or $XDG_CONFIG_HOME/...)
322+
{"extra_extensions": {".twig": "html", ".phtml": "php"}}
323+
```
324+
325+
Project config overrides global for conflicting extensions. Unknown language values are silently skipped. Missing config files are ignored.
326+
309327
## Persistence
310328

311329
SQLite databases stored at `~/.cache/codebase-memory-mcp/`. Persists across restarts (WAL mode, ACID-safe). To reset: `rm -rf ~/.cache/codebase-memory-mcp/`.

src/discover/userconfig.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ static int parse_extra_extensions(yyjson_val *root, cbm_userext_t **entries, int
219219
}
220220

221221
/* Grow the array */
222-
cbm_userext_t *tmp =
223-
realloc(*entries, (size_t)(*count + 1) * sizeof(cbm_userext_t));
222+
cbm_userext_t *tmp = realloc(*entries, (size_t)(*count + 1) * sizeof(cbm_userext_t));
224223
if (!tmp) {
225224
return -1;
226225
}
@@ -297,10 +296,11 @@ cbm_userconfig_t *cbm_userconfig_load(const char *repo_path) {
297296
int count = 0;
298297

299298
/* ── Step 1: Load global config ── */
299+
enum { PATH_BUF_SZ = 1280 };
300300
char global_dir[1024];
301301
cbm_app_config_dir(global_dir, sizeof(global_dir));
302302

303-
char global_path[1280];
303+
char global_path[PATH_BUF_SZ];
304304
snprintf(global_path, sizeof(global_path), "%s/config.json", global_dir);
305305

306306
if (load_config_file(global_path, &entries, &count) != 0) {
@@ -316,7 +316,7 @@ cbm_userconfig_t *cbm_userconfig_load(const char *repo_path) {
316316

317317
/* ── Step 2: Load project config ── */
318318
if (repo_path && repo_path[0]) {
319-
char project_path[1280];
319+
char project_path[PATH_BUF_SZ];
320320
snprintf(project_path, sizeof(project_path), "%s/.codebase-memory.json", repo_path);
321321

322322
if (load_config_file(project_path, &entries, &count) != 0) {
@@ -345,7 +345,6 @@ cbm_userconfig_t *cbm_userconfig_load(const char *repo_path) {
345345
entries[g] = entries[global_count - 1];
346346
entries[global_count - 1].ext = NULL; /* mark as consumed */
347347
global_count--;
348-
g--; /* re-check this index */
349348
break;
350349
}
351350
}

src/discover/userconfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
/* ── Types ──────────────────────────────────────────────────────── */
2323

2424
typedef struct {
25-
char *ext; /* file extension including dot, e.g. ".blade.php" */
26-
CBMLanguage lang; /* resolved language enum */
25+
char *ext; /* file extension including dot, e.g. ".blade.php" */
26+
CBMLanguage lang; /* resolved language enum */
2727
} cbm_userext_t;
2828

2929
typedef struct {

0 commit comments

Comments
 (0)