Skip to content

Commit 7ee29d8

Browse files
committed
Merge origin/main into fix/go-init-qn
Signed-off-by: Martin Vogel <[email protected]>
2 parents 7a9e6c6 + a33878c commit 7ee29d8

105 files changed

Lines changed: 10365 additions & 4499 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude-plugin/marketplace.json‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "codebase-memory",
3+
"description": "The codebase-memory-mcp code knowledge graph server, as a Claude Code plugin.",
4+
"owner": {
5+
"name": "DeusData",
6+
"url": "https://github.com/DeusData"
7+
},
8+
"plugins": [
9+
{
10+
"name": "codebase-memory",
11+
"source": "./plugin",
12+
"description": "Codebase knowledge graph for AI agents: sub-ms queries, 99% fewer tokens."
13+
}
14+
]
15+
}

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Thumbs.db
3333

3434
# MCP config (user-local, generated by install command)
3535
.mcp.json
36+
# ...except the Claude Code plugin's server definition, which is published
37+
!plugin/.mcp.json
3638

3739
# MCP Registry auth tokens
3840
.mcpregistry_*

‎Makefile.cbm‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ endif
4545

4646
# -Wdate-time: with -Werror, any use of __DATE__/__TIME__/__TIMESTAMP__ fails the
4747
# build. Build-time entropy is how one identical source tree produced a new hash
48-
# on every compile (see the local patch in vendored/mimalloc/src/options.c) —
49-
# once removed, it must not creep back through a new call site.
48+
# on every compile (mimalloc's version banner, patched locally until upstream
49+
# dropped the clock in v3.4.5; see vendored/mimalloc/PATCHES.md) — once
50+
# removed, it must not creep back through a new call site.
5051
CFLAGS_COMMON = -std=c11 -D_DEFAULT_SOURCE -D_GNU_SOURCE -Wall -Wextra -Werror \
5152
-Wno-unused-parameter -Wno-sign-compare -Wdate-time \
5253
$(GCC_ONLY_FLAGS) \
@@ -182,8 +183,9 @@ endif
182183
ifeq ($(IS_MINGW),yes)
183184
# --no-insert-timestamp: the PE header otherwise carries the link wall clock, so
184185
# two Windows builds of identical source are never byte-identical and every
185-
# release is a brand-new file to a reputation system. Same motivation as the
186-
# mimalloc __DATE__ patch; ELF and Mach-O have no equivalent field to clear.
186+
# release is a brand-new file to a reputation system. Same motivation as
187+
# dropping mimalloc's __DATE__ banner; ELF and Mach-O have no equivalent field
188+
# to clear.
187189
WIN32_LIBS := -lws2_32 -lpsapi -lshell32 -ladvapi32 -lbcrypt -Wl,--allow-multiple-definition -Wl,--stack,8388608 -Wl,--no-insert-timestamp -static
188190
endif
189191

@@ -644,6 +646,18 @@ ifneq ($(filter yes,$(IS_MINGW) $(IS_LINUX)),)
644646
MIMALLOC_OVERRIDE_DEFINE := -DMI_MALLOC_OVERRIDE=1
645647
GLOBAL_OVERRIDE_DEFINE := -DCBM_MEM_GLOBAL_OVERRIDE=1
646648
endif
649+
# MI_MINGW_UCRT64: since 3.5.3, mimalloc treats a MinGW build as having a
650+
# process-attach hook only when this is defined (src/prim/windows/prim.c);
651+
# upstream's CMake sets it, this Makefile must too. Without it src/prim/prim.c
652+
# also compiles its constructor, so _mi_auto_process_init runs twice (that
653+
# constructor plus the CRT TLS callback) and the second options flush writes a
654+
# stray newline to stderr before main: a blank first line on every run, which
655+
# failed smoke-win's one-line --version check. Every MinGW toolchain we build
656+
# with (MSYS2 CLANG64/CLANGARM64) is UCRT. 3.3.2 had no such condition.
657+
MIMALLOC_WIN_DEFINE :=
658+
ifeq ($(IS_MINGW),yes)
659+
MIMALLOC_WIN_DEFINE := -DMI_MINGW_UCRT64=1
660+
endif
647661
# MI_DEBUG=0: the production allocator is mimalloc's RELEASE build. Its header
648662
# defaults to MI_DEBUG=2 unless NDEBUG is defined, and nothing here defined it,
649663
# so every shipped binary up to v0.11.0 ran mimalloc's debug build: internal
@@ -653,15 +667,19 @@ endif
653667
# work inside the allocator (2026-09-17). Committed-bytes accounting, which the
654668
# memory budget reads, is kept in every build (subproc stats, not MI_STAT).
655669
# The TEST build below keeps mimalloc's debug checks.
670+
# MI_PROFILE=0: mimalloc 3.5.2+ compiles its allocation-sampling profiler in by
671+
# default, which puts a sample countdown on the allocation path. The product
672+
# never uses it, so the production allocator leaves it out (the contract in
673+
# tests/test_prod_allocator_contract.sh checks the banner has no profiling line).
656674
MIMALLOC_CFLAGS = -std=c11 -O2 -w \
657675
-Ivendored/mimalloc/include \
658676
-Ivendored/mimalloc/src \
659-
-DMI_OVERRIDE=1 -DMI_DEBUG=0 \
660-
$(MIMALLOC_OVERRIDE_DEFINE)
677+
-DMI_OVERRIDE=1 -DMI_DEBUG=0 -DMI_PROFILE=0 \
678+
$(MIMALLOC_OVERRIDE_DEFINE) $(MIMALLOC_WIN_DEFINE)
661679
MIMALLOC_CFLAGS_TEST = -std=c11 -g -O1 -w \
662680
-Ivendored/mimalloc/include \
663681
-Ivendored/mimalloc/src \
664-
-DMI_OVERRIDE=0
682+
-DMI_OVERRIDE=0 $(MIMALLOC_WIN_DEFINE)
665683

666684
# sqlite3 (vendored amalgamation — compiled ourselves for ASan instrumentation)
667685
# SQLITE_ENABLE_FTS5: enables the FTS5 full-text search extension used by the

‎README.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,30 @@ Working in a clone? Use `.` in place of the flake URL, e.g. `nix run .#codebase-
578578
You: "Install this MCP server: https://github.com/DeusData/codebase-memory-mcp"
579579
```
580580

581+
### Install via Claude Code plugin
582+
583+
This repository is also a Claude Code plugin marketplace, so you can find and
584+
add the server from inside Claude Code:
585+
586+
```bash
587+
claude plugin marketplace add DeusData/codebase-memory-mcp
588+
claude plugin install codebase-memory@codebase-memory
589+
```
590+
591+
The plugin registers the MCP server only. It starts the server with
592+
`npx -y codebase-memory-mcp@<version>`, pinned to the current release; the first
593+
start downloads that release's binary through the npm package, which verifies
594+
it against the release checksums. The skill, the three graph agents and the
595+
context hooks are not part of the plugin: they come from
596+
`codebase-memory-mcp install`.
597+
598+
Use one or the other. `install` registers the same server for Claude Code, so
599+
with both you run it twice, under two tool namespaces
600+
(`mcp__codebase-memory-mcp__*` and
601+
`mcp__plugin_codebase-memory_codebase-memory-mcp__*`). Choose `install` for the
602+
full Claude Code setup; choose the plugin to add just the server without
603+
running an installer.
604+
581605
### Build from Source
582606

583607
<details>
@@ -1037,6 +1061,8 @@ SQLite databases stored at `~/.cache/codebase-memory-mcp/`. Persists across rest
10371061

10381062
## Troubleshooting
10391063

1064+
Windows users: see [Windows troubleshooting](docs/WINDOWS_TROUBLESHOOTING.md) for versioned known issues and workarounds.
1065+
10401066
| Problem | Fix |
10411067
|---------|-----|
10421068
| `/mcp` doesn't show the server | Check `.mcp.json` path is absolute. Restart agent. Test: `echo '{}' \| /path/to/binary` should output JSON. |

‎THIRD_PARTY.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ License summary:
121121
| wyhash | `internal/cbm/vendored/wyhash/` | Unlicense (public domain) | [wangyi-fudan/wyhash](https://github.com/wangyi-fudan/wyhash) |
122122

123123
Local modifications to these libraries are documented next to the
124-
vendored sources (currently only SQLite: `vendored/sqlite3/PATCHES.md`,
125-
raising the Unix VFS `MAX_PATHNAME` ceiling from 512 to 4096 to match
126-
CBM's 4 KiB path support). Patches must be reapplied on every upstream
127-
refresh and are covered by `scripts/vendored-checksums.txt`.
124+
vendored sources: `vendored/sqlite3/PATCHES.md` (raising the Unix VFS
125+
`MAX_PATHNAME` ceiling from 512 to 4096 to match CBM's 4 KiB path support)
126+
and `vendored/mimalloc/PATCHES.md` (the upstream source pin, mimalloc v3.5.3
127+
at commit `d4881d33`, plus the macOS decommit-recommit change and one comment
128+
rewording). Patches must be reapplied on every upstream refresh and are
129+
covered by `scripts/vendored-checksums.txt`.
128130

129131
The graph-UI HTTP server is a first-party implementation
130132
(`src/ui/httpd.c` + `src/ui/http_server.c`) — no third-party HTTP library

‎docs/CONFIGURATION.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,15 @@ root because they are too broad or too sensitive to index as a unit:
245245
- a credential directory at any depth — `.ssh`, `.aws`, `.gnupg`, `.kube`,
246246
`.docker`, `.netrc`, `.git-credentials`, `.password-store`, macOS `Keychains`.
247247

248+
A single top-level directory can still be indexed as one root on purpose, for
249+
example a container or build machine that keeps its project in `/work`, `/app` or
250+
`/src`, by approving that exact path in a terminal:
251+
`codebase-memory-mcp allow-root --approve-broad /work`. The approval is recorded
252+
like any other allowed root, listed as `(approved broad)` by `allow-root --list`,
253+
and covers no other top-level directory; as with any recorded root, indexing is
254+
then confined to the recorded roots. Filesystem, drive and share roots cannot be
255+
approved.
256+
248257
Two limits are worth stating plainly. This constrains *scope*, not
249258
*sensitivity*: inside a root that is allowed, every file the process can read may
250259
be indexed and later returned. And the credential list is a denylist, so it

‎docs/WINDOWS_TROUBLESHOOTING.md‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Windows Troubleshooting
2+
3+
This page collects known Windows-specific symptoms, with the version range each affects, confirmed workarounds, and links to the canonical tracking issues.
4+
5+
## Non-ASCII paths in CBM_CACHE_DIR or CBM_ALLOWED_ROOT
6+
7+
**Symptom:** Configuration appears not to persist, the config database cannot be opened (`error: cannot open config database`), or repositories inside `CBM_ALLOWED_ROOT` are rejected during indexing.
8+
9+
**Affected versions:** Affects v0.9.x and earlier. Fixed in v0.10.0 (environment variables are read as wide strings via `GetEnvironmentVariableW`).
10+
11+
**Workaround:** On an older build, use ASCII-only paths for these two variables or upgrade with `install.ps1`.
12+
13+
**Tracking:** #1165.
14+
15+
## Upgrade completes but binary version does not change
16+
17+
**Symptom:** `codebase-memory-mcp update` reports success and downloads files, but `codebase-memory-mcp --version` still reports the previous version (with `.exe.old` remaining alongside).
18+
19+
**Affected versions:** Affects v0.9.x and earlier (in-process self-update on Windows). From v0.10.0, `update` prints the `install.ps1` command instead of replacing itself.
20+
21+
**Workaround:** On an older build, run `install.ps1` once; it replaces the binary out-of-process and verifies the installed version.
22+
23+
**Tracking:** #1168 (closed; fixed in v0.10.0).
24+
25+
## Index worker hangs, crashes, or leaves an empty worker log
26+
27+
**Symptom:** `index_repository` reports worker hangs or crashes. (An *empty* worker log is a separate, fixed bug: v0.10.4 and earlier.)
28+
29+
**Affected versions:** Empty worker logs affect v0.10.4 and earlier (fixed in v0.10.5). Misleading "crashed on a file" reports for returned errors fixed in v0.10.0. From v0.11.0, the Windows worker is memory-capped. From v0.12.0, a worker that exits without returning a result is no longer counted as a success, and its log is kept. The underlying hang (#1130) and startup exit (#1145) remain open for investigation.
30+
31+
**Workaround:** For repositories containing large binary, media, or model directories, exclude those paths with `.cbmignore` before indexing (see [`.cbmignore` documentation](cbmignore.md)). From v0.10.5, the worker log names the in-flight file; if indexing still fails on v0.11.0 or newer, attach that log to #1130 or #1145.
32+
33+
**Tracking:** #1130, #1132, #1145.
34+
35+
## Antigravity 2.0 configuration not picked up
36+
37+
**Symptom:** Installation completes but Antigravity 2.0 does not see the MCP server or hooks, or the environment is detected as Gemini-CLI; duplicate large binaries may also be left on disk.
38+
39+
**Affected versions:** All releases through v0.12.1 when neither detection signal below is present (v0.9.x checks only for `~/.gemini/antigravity-cli`; from v0.10.0, `antigravity` on PATH also counts). The duplicate binary left behind by `install.ps1` affects v0.9.x and earlier (fixed in v0.10.0).
40+
41+
**Workaround:** Antigravity is configured only when `~/.gemini/antigravity-cli` exists or `antigravity` is on PATH; the target is `~/.gemini/config/mcp_config.json`, and no hooks are installed for it. If neither signal is present, the machine is treated as Gemini-CLI. From v0.10.0, `install.ps1` keeps a single binary; running `codebase-memory-mcp install` manually without `--dir` can still create a second copy in `~/.local/bin`.
42+
43+
**Tracking:** #1161.
44+
45+
## OpenCode installed but not detected
46+
47+
**Symptom:** `codebase-memory-mcp install` detects other clients but skips OpenCode on Windows.
48+
49+
**Affected versions:** v0.9.x and earlier detect OpenCode only through `opencode` on PATH. v0.10.0 also detects its configuration (the config file, `%USERPROFILE%\.config\opencode\`, or `OPENCODE_CONFIG_DIR`), and v0.12.0 also detects its data folder `%USERPROFILE%\.local\share\opencode\`, which the OpenCode CLI and the Desktop app both create, so detection no longer depends on PATH. In v0.12.1 and earlier, a PATH longer than 4 KB hides every CLI from detection, and npm, mise and scoop shim folders are not searched; both are fixed after v0.12.1 (#2381).
50+
51+
**Workaround:** On v0.12.0 or newer, start OpenCode once (CLI or Desktop app) so that its data folder exists, then re-run `codebase-memory-mcp install`. On v0.10.x or v0.11.0, make sure `%USERPROFILE%\.config\opencode\` exists (or point `OPENCODE_CONFIG` at an existing config file, or `OPENCODE_CONFIG_DIR` at an existing folder), then re-run `codebase-memory-mcp install`. On v0.9.x, `opencode` must be on PATH; upgrading with `install.ps1` is the simpler fix.
52+
53+
**Tracking:** #1167.
54+
55+
---
56+
57+
When a release resolves one of these issues, update or remove the corresponding entry rather than letting this page become a second issue tracker.

‎internal/cbm/cbm.h‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,10 @@ typedef struct {
298298
* are bound to the owning result's source identity before cross-file use. */
299299
uint32_t test_name_start_byte, test_name_end_byte;
300300
uint32_t test_body_start_byte, test_body_end_byte;
301-
/* Documents only: facts a document definition adds to its node's
302-
* properties, as a NULL-terminated key, value, key, value, ... list (an
303-
* ADR's id, status, date, deciders, title). Keys are fixed literals; the
301+
/* Facts a definition adds to its node's properties, as a NULL-terminated
302+
* key, value, key, value, ... list: a document's (an ADR's id, status,
303+
* date, deciders, title), or CBM_PROP_GENERATED on a member the compiler
304+
* writes and the source never spells. Keys are fixed literals; the
304305
* values are escaped where the properties are written. Tail field:
305306
* zero-init stays valid. */
306307
const char **extra_props;
@@ -321,6 +322,13 @@ typedef struct {
321322
const char *alias_target;
322323
} CBMDefinition;
323324

325+
/* extra_props key of a generated member, one the compiler writes and the
326+
* source never spells: a Java record's implicit accessor carries
327+
* `generated: record`. The node keeps the property, and the pipeline registers
328+
* such a definition by qualified name only, so no short-name guess can land on
329+
* it (pipeline.h cbm_def_props_generated). */
330+
#define CBM_PROP_GENERATED "generated"
331+
324332
/* Argument captured from a call expression */
325333
typedef struct {
326334
const char *expr; // raw expression text ("payload.info", "MY_URL", "'hello'")

‎internal/cbm/extract_calls.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,11 +2249,15 @@ static char *extract_callee_name(CBMArena *a, TSNode node, const char *source, C
22492249
// method is `new`. The constructor body lives in `initialize`, so a callee
22502250
// of "new" never resolves. Redirect to the receiver type name so the call
22512251
// links to the class/constructor like every other language's `new T()`.
2252+
// Scope-resolved receivers (`Admin::User.new`) get the same treatment —
2253+
// the callee carries the full constant path ("Admin::User"), whose bare
2254+
// leaf ("User") is what resolution joins on.
22522255
if (lang == CBM_LANG_RUBY) {
22532256
TSNode m = ts_node_child_by_field_name(node, TS_FIELD("method"));
22542257
TSNode recv = ts_node_child_by_field_name(node, TS_FIELD("receiver"));
22552258
if (!ts_node_is_null(m) && !ts_node_is_null(recv) &&
2256-
strcmp(ts_node_type(recv), "constant") == 0) {
2259+
(strcmp(ts_node_type(recv), "constant") == 0 ||
2260+
strcmp(ts_node_type(recv), "scope_resolution") == 0)) {
22572261
char *mt = cbm_node_text(a, m, source);
22582262
if (mt && strcmp(mt, "new") == 0) {
22592263
char *rt = cbm_node_text(a, recv, source);

0 commit comments

Comments
 (0)