Skip to content

Commit b42159e

Browse files
committed
Merge origin/main into fix/mcp-frontend-recovery
Signed-off-by: Martin Vogel <[email protected]>
2 parents 37245a2 + 8ae04f4 commit b42159e

29 files changed

Lines changed: 5572 additions & 25 deletions

‎Makefile.cbm‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ TEST_CS_LSP_SRCS = tests/test_cs_lsp.c
887887
TEST_CS_LSP_BENCH_SRCS = tests/test_cs_lsp_bench.c
888888

889889
TEST_PERL_LSP_SRCS = tests/test_perl_lsp.c
890+
TEST_RUBY_LSP_SRCS = tests/test_ruby_lsp.c
890891

891892
TEST_SCOPE_SRCS = tests/test_scope.c
892893

@@ -1010,7 +1011,7 @@ TEST_REPRO_SRCS = \
10101011
tests/repro/repro_lsp_java_cs.c \
10111012
tests/repro/repro_lsp_kt_php_rust.c
10121013

1013-
ALL_TEST_SRCS =$(TEST_FOUNDATION_SRCS) $(TEST_EXTRACTION_SRCS) $(TEST_STORE_SRCS) $(TEST_CYPHER_SRCS) $(TEST_MCP_SRCS) $(TEST_DAEMON_SRCS) $(TEST_DISCOVER_SRCS) $(TEST_GRAPH_BUFFER_SRCS) $(TEST_PIPELINE_SRCS) $(TEST_WATCHER_SRCS) $(TEST_LZ4_SRCS) $(TEST_ZSTD_SRCS) $(TEST_ARTIFACT_SRCS) $(TEST_SQLITE_WRITER_SRCS) $(TEST_GO_LSP_SRCS) $(TEST_C_LSP_SRCS) $(TEST_PHP_LSP_SRCS) $(TEST_CS_LSP_SRCS) $(TEST_CS_LSP_BENCH_SRCS) $(TEST_PERL_LSP_SRCS) $(TEST_SCOPE_SRCS) $(TEST_TYPE_REP_SRCS) $(TEST_PY_LSP_SRCS) $(TEST_PY_LSP_BENCH_SRCS) $(TEST_PY_LSP_STRESS_SRCS) $(TEST_PY_LSP_SCALE_SRCS) $(TEST_TS_LSP_SRCS) $(TEST_JAVA_LSP_SRCS) $(TEST_KOTLIN_LSP_SRCS) $(TEST_RUST_LSP_SRCS) $(TEST_TRACES_SRCS) $(TEST_CLI_SRCS) $(TEST_MEM_SRCS) $(TEST_UI_SRCS) $(TEST_HTTPD_SRCS) $(TEST_SECURITY_SRCS) $(TEST_YAML_SRCS) $(TEST_SEMANTIC_SRCS) $(TEST_AST_PROFILE_SRCS) $(TEST_SLAB_ALLOC_SRCS) $(TEST_SIMHASH_SRCS) $(TEST_STACK_OVERFLOW_SRCS) $(TEST_INTEGRATION_SRCS)
1014+
ALL_TEST_SRCS =$(TEST_FOUNDATION_SRCS) $(TEST_EXTRACTION_SRCS) $(TEST_STORE_SRCS) $(TEST_CYPHER_SRCS) $(TEST_MCP_SRCS) $(TEST_DAEMON_SRCS) $(TEST_DISCOVER_SRCS) $(TEST_GRAPH_BUFFER_SRCS) $(TEST_PIPELINE_SRCS) $(TEST_WATCHER_SRCS) $(TEST_LZ4_SRCS) $(TEST_ZSTD_SRCS) $(TEST_ARTIFACT_SRCS) $(TEST_SQLITE_WRITER_SRCS) $(TEST_GO_LSP_SRCS) $(TEST_C_LSP_SRCS) $(TEST_PHP_LSP_SRCS) $(TEST_CS_LSP_SRCS) $(TEST_CS_LSP_BENCH_SRCS) $(TEST_PERL_LSP_SRCS) $(TEST_RUBY_LSP_SRCS) $(TEST_SCOPE_SRCS) $(TEST_TYPE_REP_SRCS) $(TEST_PY_LSP_SRCS) $(TEST_PY_LSP_BENCH_SRCS) $(TEST_PY_LSP_STRESS_SRCS) $(TEST_PY_LSP_SCALE_SRCS) $(TEST_TS_LSP_SRCS) $(TEST_JAVA_LSP_SRCS) $(TEST_KOTLIN_LSP_SRCS) $(TEST_RUST_LSP_SRCS) $(TEST_TRACES_SRCS) $(TEST_CLI_SRCS) $(TEST_MEM_SRCS) $(TEST_UI_SRCS) $(TEST_HTTPD_SRCS) $(TEST_SECURITY_SRCS) $(TEST_YAML_SRCS) $(TEST_SEMANTIC_SRCS) $(TEST_AST_PROFILE_SRCS) $(TEST_SLAB_ALLOC_SRCS) $(TEST_SIMHASH_SRCS) $(TEST_STACK_OVERFLOW_SRCS) $(TEST_INTEGRATION_SRCS)
10141015

10151016

10161017
# ── Build directories ────────────────────────────────────────────

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ To turn the watcher off entirely, set `config set watcher_enabled false` (defaul
263263

264264
The watcher follows **git** projects only by default: a project indexed from a directory that is not a git repository is not watched and stays at its last index until you run `index_repository` again. To have such roots polled too, set `config set watch_non_git true` (default `false`, read when the daemon starts): they are then checked on the same cadence with a file-tree scan that uses the indexer's own ignore rules.
265265

266+
Linked git worktrees are indexed as their own projects by default. Set `config set ignore_worktrees true` to skip them on the automatic paths — useful when short-lived `git worktree add` checkouts would otherwise each leave behind a permanent index of the same repository. An explicit `index_repository` call on a worktree is then refused unless you pass `index_worktree=true`. See [docs/CONFIGURATION.md](docs/CONFIGURATION.md#ignore_worktrees).
267+
266268
### Keeping Up to Date
267269

268270
**Updates run from the install script on every platform, not from inside the running binary.** `codebase-memory-mcp update` validates your flags and then prints the exact command to run:
@@ -1016,6 +1018,7 @@ codebase-memory-mcp config list # show all settings
10161018
codebase-memory-mcp config set auto_index true # auto-index on session start
10171019
codebase-memory-mcp config set auto_index_limit 50000 # max files for auto-index
10181020
codebase-memory-mcp config set auto_watch false # remove/disable all background watches (default: true)
1021+
codebase-memory-mcp config set ignore_worktrees true # skip linked git worktrees when auto-indexing (default: false)
10191022
codebase-memory-mcp config set doc_candidates false # skip doc<->code candidate scoring on huge repos (default: auto = on for full, off for moderate/fast)
10201023
codebase-memory-mcp config set watcher_enabled false # stop the watcher thread entirely (default: true)
10211024
codebase-memory-mcp config set watch_non_git true # also poll non-git project roots (default: false)

‎docs/CONFIGURATION.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Current keys:
8787
|---|---|---|
8888
| `auto_index` | `false` | Automatically index new projects when an MCP session starts. |
8989
| `auto_index_limit` | `50000` | Maximum file count allowed for automatic indexing of a new project. |
90+
| `ignore_worktrees` | `false` | Skip linked git worktrees (`git worktree add`) when indexing automatically. |
9091
| `auto_watch` | `true` | Global switch for MCP session watch registration. On the next refresh or registration request, `true` allows session roots and successful `index_repository` targets to be watched; `false` removes all watches. The background watcher can still run with no registered projects. |
9192
| `doc_candidates` | `auto` | Score documentation sections against code to store doc↔code candidates (the possible targets of a section, and the sections that may describe a function or file, each with a judged probability). Unset (`auto`), the index mode decides: on for `full` indexes (the default mode), off for `moderate` and `fast`. Set `true` or `false` to choose for every mode; `config reset doc_candidates` returns to `auto`. The scoring grows with sections × functions: under a second up to ~100k functions, ~15 s at ~400k, ~3 minutes on the Linux kernel. Off stores no candidates and leaves the rest of the graph unchanged; on in `fast` mode stores candidates without adding `fast`'s skipped `SIMILAR_TO` / `SEMANTICALLY_RELATED` edges. `index_repository` also takes `doc_candidates` for a single index, which wins over this setting. Applies from the next index. |
9293
| `watcher_enabled` | `true` | Master switch for the background watcher subsystem. Set `false` to stop the watcher from starting at all — no poll thread and no project registration. Reindex manually with `index_repository` when disabled. Active MCP sessions can register their root project and successful explicit index targets; under `daemon start` those watches outlive the session until the daemon stops, the project is deleted, its directory disappears, or `auto_watch` is set to `false`. `index_status` reports the current state in its `watch` object. |
@@ -142,6 +143,44 @@ and preserves any previously serving database. See
142143
[Index resource limits](INDEX_RESOURCE_LIMITS.md) for counting, validation, and
143144
error-response details.
144145
146+
### `ignore_worktrees`
147+
148+
Every indexed project is registered under its own absolute root path, so each
149+
linked worktree becomes a separate permanent index. On machines that create many
150+
short-lived worktrees, the automatic paths (`auto_index`, and the session hook's
151+
"index this project first" guidance) turn every throwaway checkout into another
152+
stored index of what is largely the same repository.
153+
154+
Enable the key to keep those checkouts out of the index:
155+
156+
```bash
157+
codebase-memory-mcp config set ignore_worktrees true
158+
```
159+
160+
With it enabled:
161+
162+
- automatic indexing skips a session whose root is a linked worktree;
163+
- the `hook-augment` context says the worktree is unindexed on purpose instead
164+
of telling the agent to run `index_repository`;
165+
- an explicit `index_repository` call on a linked worktree is refused, and names
166+
both ways forward — pass `index_worktree=true` for that one call, or turn the
167+
key back off.
168+
169+
The main checkout of the same repository is unaffected, as are ordinary clones
170+
and submodules. Detection is git plumbing only: a linked worktree's `.git` is a
171+
file pointing at a gitdir that contains a `commondir` entry.
172+
173+
A subdirectory counts as the worktree it sits in. Detection walks up from the
174+
given path to the nearest `.git` entry, so `index_repository` on any
175+
subdirectory of a linked worktree is refused the same way, and a session root or
176+
hook working directory inside one is treated as that worktree. The walk stops at
177+
the first `.git` it finds; a main checkout or a submodule ends it as "not a
178+
worktree". A path outside any git checkout is checked one directory at a time up
179+
to the filesystem root and is never treated as a worktree. None of this runs
180+
while the key is off.
181+
182+
The default is `false`, so indexing behavior is unchanged unless you opt in.
183+
145184
## 3. UI Settings
146185
147186
The optional built-in graph UI stores its settings in:

‎internal/cbm/cbm.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "lsp/php_lsp.h"
1717
#include "lsp/perl_lsp.h"
1818
#include "lsp/py_lsp.h"
19+
#include "lsp/ruby_lsp.h"
1920
#include "lsp/ts_lsp.h"
2021
#include "lsp/cs_lsp.h"
2122
#include "lsp/java_lsp.h"
@@ -3951,6 +3952,9 @@ static CBMFileResult *extract_file_ex_body(const char *source, int source_len, C
39513952
if (language == CBM_LANG_PERL) {
39523953
cbm_run_perl_lsp(a, result, source, source_len, root);
39533954
}
3955+
if (language == CBM_LANG_RUBY) {
3956+
cbm_run_ruby_lsp(a, result, source, source_len, root);
3957+
}
39543958
if (language == CBM_LANG_PYTHON) {
39553959
cbm_run_py_lsp(a, result, source, source_len, root);
39563960
}

0 commit comments

Comments
 (0)