Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![CI](https://img.shields.io/github/actions/workflow/status/DeusData/codebase-memory-mcp/release.yml?branch=main&label=main%20CI)](https://github.com/DeusData/codebase-memory-mcp/actions/workflows/release.yml)
[![Native and frontend tests](https://img.shields.io/badge/tests-native_%2B_frontend-blue)](#tests)
[![MCP tools](https://img.shields.io/badge/MCP_tools-17-blue)](#mcp-tools)
[![Languages](https://img.shields.io/badge/languages-162-orange)](https://github.com/DeusData/codebase-memory-mcp)
[![Languages](https://img.shields.io/badge/languages-163-orange)](https://github.com/DeusData/codebase-memory-mcp)
[![Hybrid LSP](https://img.shields.io/badge/Hybrid_LSP-type_resolution-blue)](#hybrid-lsp)
[![Agents](https://img.shields.io/badge/agent_surfaces-45-purple)](https://github.com/DeusData/codebase-memory-mcp)
[![Pure C](https://img.shields.io/badge/pure_C-no_language_runtime-blue)](https://github.com/DeusData/codebase-memory-mcp)
Expand Down Expand Up @@ -394,7 +394,7 @@ In this repository, test narrowing is wired to the Linux x86_64 test leg when `T
- `SEMANTICALLY_RELATED` (vocabulary-mismatch, same-language, score ≥ 0.80)

### Indexing pipeline
- **162 vendored tree-sitter grammars** compiled into the binary
- **163 vendored tree-sitter grammars** compiled into the binary
- **Generic package / module resolution**: bare specifiers like `@myorg/pkg`, `github.com/foo/bar`, `use my_crate::foo` resolved via manifest scanning (`package.json`, `go.mod`, `Cargo.toml`, `pyproject.toml`, `composer.json`, `pubspec.yaml`, `pom.xml`, `build.gradle`, `mix.exs`, `*.gemspec`)
- **Infrastructure-as-code indexing**: Dockerfiles (`Dockerfile.*`, `*.Dockerfile`, `Containerfile`: bases, what the container runs, `ENV`), container images (`Image`: the normalised repository, tag and digest on the edges; a repository built from several Dockerfiles, one per component tag, gets an `Image` per component), docker compose services (`Resource`), Kubernetes manifests (`Resource`, with `group`, `version`, `kind`, `namespace`, `labels` as `k=v,k2=v2`), Kustomize overlays (`IMPORTS` to their entries and patch files, `OVERRIDE` from their patches), Helm charts (`Chart`, `DEPENDS_ON`), Terraform / OpenTofu (`.tf`, `.tofu`, `.tfvars`) as graph nodes. A Service walks to the code it runs: Service → workload → `Image` → Dockerfile → `main`
- **[Hybrid LSP semantic type resolution](#hybrid-lsp)** for Python, TypeScript / JavaScript / JSX / TSX, PHP, C#, Go, C, C++, Java, Kotlin, Rust, and Perl; a lightweight C implementation of language type-resolution algorithms, structurally inspired by and compatible with major language servers including tsserver / typescript-go, pyright, gopls, Roslyn, Eclipse JDT, and rust-analyzer (parameter binding, return-type inference, generic substitution, JSX component dispatch, JSDoc inference for plain JS files, namespace + trait + late-static-binding resolution for PHP, file-scoped namespaces + records + LINQ method syntax for C#, class-hierarchy + overload + lambda resolution for Java, extension-function + scope-function resolution for Kotlin, trait-method + UFCS resolution for Rust)
Expand Down Expand Up @@ -1066,7 +1066,7 @@ Need the full config-file reference? See [docs/CONFIGURATION.md](docs/CONFIGURAT

Each entry maps an extension (which **must** start with `.`) to a language name. Language names are matched **case-insensitively**. Accepted values (aliases in parentheses) are:

`arkts`, `asciidoc`, `bash` (`sh`), `c`, `c++` (`cpp`), `c#` (`csharp`), `chialisp`, `clojure`, `cmake`, `cobol`, `common lisp` (`commonlisp`, `lisp`), `css`, `cuda`, `dart`, `diagram`, `dockerfile`, `elixir`, `elm`, `emacs lisp` (`emacslisp`), `erlang`, `f#` (`fsharp`), `form`, `fortran`, `glsl`, `go`, `graphql`, `groovy`, `haskell`, `hcl` (`terraform`), `html`, `ini`, `java`, `javascript`, `jinja2` (`jinja`), `json`, `julia`, `kotlin`, `lean`, `lua`, `magma`, `makefile`, `markdown`, `matlab`, `meson`, `mojo`, `nix`, `objective-c` (`objc`), `ocaml`, `openapi`, `pdf`, `perl`, `php`, `plsql`, `protobuf`, `python`, `r`, `ruby`, `rust`, `scala`, `scss`, `sql`, `svelte`, `swift`, `toml`, `tsx`, `typescript`, `verilog`, `vimscript`, `vue`, `wolfram`, `xml`, `yaml`, `zig`.
`arkts`, `asciidoc`, `bash` (`sh`), `c`, `c++` (`cpp`), `c#` (`csharp`), `chialisp`, `clojure`, `cmake`, `cobol`, `common lisp` (`commonlisp`, `lisp`), `css`, `cuda`, `dart`, `diagram`, `dockerfile`, `elixir`, `elm`, `emacs lisp` (`emacslisp`), `erlang`, `f#` (`fsharp`), `form`, `fortran`, `glsl`, `go`, `graphql`, `groovy`, `haskell`, `hcl` (`terraform`), `html`, `ini`, `java`, `javascript`, `jinja2` (`jinja`), `json`, `julia`, `kotlin`, `lean`, `lua`, `magma`, `makefile`, `markdown`, `matlab`, `meson`, `mojo`, `nix`, `objective-c` (`objc`), `ocaml`, `openapi`, `pdf`, `perl`, `php`, `plsql`, `protobuf`, `python`, `r`, `ruby`, `rust`, `scala`, `scss`, `sql`, `svelte`, `swift`, `toml`, `tsx`, `typescript`, `verilog`, `vimscript`, `visual basic .net` (`vb`, `vbnet`), `vue`, `wolfram`, `xml`, `yaml`, `zig`.

Project config overrides global for conflicting extensions. An entry whose language name is unknown, or whose extension does not start with `.`, is skipped and logged as a warning. Missing config files are ignored.

Expand Down Expand Up @@ -1114,22 +1114,22 @@ codebase-memory-mcp ships a **lightweight C implementation of language type-reso

**Two-layer architecture:**

1. **Tree-sitter pass**: fast, syntactic, runs for every one of the 162 languages. Extracts definitions, calls, imports.
1. **Tree-sitter pass**: fast, syntactic, runs for every one of the 163 languages. Extracts definitions, calls, imports.
2. **Hybrid LSP pass**: type-aware, runs above the tree-sitter pass per-language. Refines call edges using the import graph plus a per-file or pre-built cross-file definition registry. Languages without a Hybrid LSP pass yet fall back to textual resolution, with coverage varying by language and construct.

The result is a knowledge graph accurate enough to drive `trace_path` across packages, inheritance hierarchies, and stdlib calls; without paying for a language server process per project.

## Language Support

162 languages, counted by the vendored grammar directories in [the parser manifest](internal/cbm/vendored/grammars/MANIFEST.md). Benchmarked against 64 real open-source repositories (78 to 49K nodes):
163 languages, counted by the vendored grammar directories in [the parser manifest](internal/cbm/vendored/grammars/MANIFEST.md). Benchmarked against 64 real open-source repositories (78 to 49K nodes):

| Tier | Score | Languages |
|------|-------|-----------|
| **Excellent** (>= 90%) | | Lua, Kotlin, C++, Perl, Objective-C, Groovy, C, Bash, Zig, Swift, CSS, YAML, TOML, HTML, SCSS, HCL, Dockerfile |
| **Good** (75-89%) | | Python, TypeScript, TSX, Go, Rust, Java, R, Dart, JavaScript, Erlang, Elixir, Scala, Ruby, PHP, C#, SQL |
| **Functional** (< 75%) | | OCaml, Haskell |

Also supported (not yet benchmarked): Ada, Agda, Apex, ArkTS, Assembly (NASM), Astro, AWK, Beancount, BibTeX, Bicep, Bitbake, Blade, Cairo, Cap'n Proto, CFML, CFScript, Chialisp, Clojure, CMake, COBOL, Common Lisp, Crystal, CSV, CUDA, D, Devicetree, Diff, .env, Elm, Emacs Lisp, F#, Fennel, Fish, FORM, Fortran, FunC, GDScript, .gitattributes, .gitignore, Gleam, GLSL, GN, Go module, Go template, GraphQL, Hare, HLSL, Hyprlang, INI, ISPC, Janet, Jinja2, JSDoc, JSON, JSON5, Jsonnet, Julia, Just, Kconfig, KDL, Lean 4, Linker Script, Liquid, LLVM IR, Luau, Magma, Makefile, Markdown, MATLAB, Mermaid, Meson, Mojo, Move, Nickel, Nix, ObjectScript (UDL and routines), Odin, Pascal, Pine Script, Pkl, PL/SQL, PO (gettext), Pony, PowerShell, Prisma, .properties, Protobuf, Puppet, PureScript, QML, Racket, Regex, requirements.txt, ReScript, RON, reStructuredText, Scheme, Slang, Smali, Smithy, Solidity, SOQL, SOSL, Squirrel, SSH config, Starlark, Svelte, Sway, SystemVerilog, TableGen, Tcl, Teal, Templ, Thrift, TLA+, Typst, Verilog, VHDL, Vim script, Vue, WGSL, WIT, Wolfram, XML, Zsh.
Also supported (not yet benchmarked): Ada, Agda, Apex, ArkTS, Assembly (NASM), Astro, AWK, Beancount, BibTeX, Bicep, Bitbake, Blade, Cairo, Cap'n Proto, CFML, CFScript, Chialisp, Clojure, CMake, COBOL, Common Lisp, Crystal, CSV, CUDA, D, Devicetree, Diff, .env, Elm, Emacs Lisp, F#, Fennel, Fish, FORM, Fortran, FunC, GDScript, .gitattributes, .gitignore, Gleam, GLSL, GN, Go module, Go template, GraphQL, Hare, HLSL, Hyprlang, INI, ISPC, Janet, Jinja2, JSDoc, JSON, JSON5, Jsonnet, Julia, Just, Kconfig, KDL, Lean 4, Linker Script, Liquid, LLVM IR, Luau, Magma, Makefile, Markdown, MATLAB, Mermaid, Meson, Mojo, Move, Nickel, Nix, ObjectScript (UDL and routines), Odin, Pascal, Pine Script, Pkl, PL/SQL, PO (gettext), Pony, PowerShell, Prisma, .properties, Protobuf, Puppet, PureScript, QML, Racket, Regex, requirements.txt, ReScript, RON, reStructuredText, Scheme, Slang, Smali, Smithy, Solidity, SOQL, SOSL, Squirrel, SSH config, Starlark, Svelte, Sway, SystemVerilog, TableGen, Tcl, Teal, Templ, Thrift, TLA+, Typst, Verilog, VHDL, Vim script, Visual Basic .NET, Vue, WGSL, WIT, Wolfram, XML, Zsh.

## Architecture

Expand All @@ -1148,7 +1148,7 @@ src/
ui/ Local HTTP server + embedded CBM Lens frontend
foundation/ Platform abstractions (threads, filesystem, logging, memory)
graph-ui/ CodeAtlasWeb: React, Monaco, and Three.js browser frontend
internal/cbm/ Vendored tree-sitter grammars (162 languages) + AST extraction engine
internal/cbm/ Vendored tree-sitter grammars (163 languages) + AST extraction engine
```

## Security
Expand Down
9 changes: 7 additions & 2 deletions THIRD_PARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ License summary:
smart-coin language, written for this project because no usable public
grammar exists; its source and corpus tests live in
`tools/tree-sitter-chialisp/`.
- Ten further grammars (`arkts`, `assembly`, `cfml`,
`cfscript`, `dotenv`, `javascript`, `pascal`, `pine`, `qml`, `tsx`) are
- Eleven further grammars (`arkts`, `assembly`, `cfml`,
`cfscript`, `dotenv`, `javascript`, `pascal`, `pine`, `qml`, `tsx`, `vbnet`) are
self-maintained forks that retain their original upstream authors' licenses —
see the manifest for per-grammar provenance. `arkts` is a first-party derivative of
[tree-sitter/tree-sitter-typescript](https://github.com/tree-sitter/tree-sitter-typescript)
Expand All @@ -80,6 +80,11 @@ License summary:
MIT, (c) 2018 Benjamin Gray) is the upstream grammar with one (c) 2026
DeusData patch that accepts non-ASCII letters in identifiers; its grammar
source lives in `tools/tree-sitter-pascal/`.
`vbnet` is based on
[govindbanura/tree-sitter-vbnet](https://github.com/govindbanura/tree-sitter-vbnet)
(MIT, (c) 2025 Govind Banura) and carries the real-world compatibility patch
from [CodeGraph MCP](https://github.com/ColbyMchenry/CodeGraph) (MIT,
(c) 2025 Colby Mchenry); source and patch live in `tools/tree-sitter-vbnet/`.

### tree-sitter-plsql

Expand Down
1 change: 1 addition & 0 deletions internal/cbm/cbm.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ typedef enum {
// operations are Routes (openapi.c)
CBM_LANG_DIAGRAM, // diagram files (PlantUML, DOT, D2, draw.io, Excalidraw), read
// without a grammar (diagram.c)
CBM_LANG_VISUALBASIC, // Visual Basic .NET (.vb)
CBM_LANG_COUNT
} CBMLanguage;

Expand Down
9 changes: 9 additions & 0 deletions internal/cbm/extract_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,15 @@ static char *extract_callee_lang_specific(CBMArena *a, TSNode node, const char *
CBMLanguage lang) {
const char *nk = ts_node_type(node);

/* VB.NET uses invocation syntax for both calls and array access. The
* grammar consequently places many ordinary callees in the `array` field. */
if (lang == CBM_LANG_VISUALBASIC && strcmp(nk, "array_access_expression") == 0) {
TSNode callee = ts_node_child_by_field_name(node, TS_FIELD("array"));
if (!ts_node_is_null(callee)) {
return cbm_node_text(a, callee, source);
}
}

if (lang == CBM_LANG_FORTRAN && strcmp(nk, "subroutine_call") == 0) {
TSNode subroutine = ts_node_child_by_field_name(node, TS_FIELD("subroutine"));
if (!ts_node_is_null(subroutine)) {
Expand Down
107 changes: 104 additions & 3 deletions internal/cbm/extract_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4605,6 +4605,39 @@ static const char **extract_julia_base_classes(CBMArena *a, TSNode node, const c

static const char **extract_base_classes(CBMArena *a, TSNode node, const char *source,
CBMLanguage lang) {
/* VB.NET puts Inherits/Implements statements directly among a type's
* children and gives them no superclass/interface field. */
if (lang == CBM_LANG_VISUALBASIC) {
const char *vb_bases[MAX_BASES];
int vb_count = 0;
uint32_t nc = ts_node_named_child_count(node);
for (uint32_t i = 0; i < nc && vb_count < MAX_BASES_MINUS_1; i++) {
TSNode stmt = ts_node_named_child(node, i);
const char *sk = ts_node_type(stmt);
if (strcmp(sk, "inherits_statement") != 0 &&
strcmp(sk, "implements_statement") != 0) {
continue;
}
uint32_t bc = ts_node_named_child_count(stmt);
for (uint32_t j = 0; j < bc && vb_count < MAX_BASES_MINUS_1; j++) {
char *base = cbm_node_text(a, ts_node_named_child(stmt, j), source);
if (base && base[0]) {
vb_bases[vb_count++] = base;
}
}
}
if (vb_count > 0) {
const char **result =
(const char **)cbm_arena_alloc(a, (size_t)(vb_count + 1) * sizeof(*result));
if (result) {
for (int i = 0; i < vb_count; i++) {
result[i] = vb_bases[i];
}
result[vb_count] = NULL;
return result;
}
}
}
// ObjectScript: `Class X Extends (A, B)` — bases are class_name children of
// the class_extends node.
if (lang == CBM_LANG_OBJECTSCRIPT_UDL) {
Expand Down Expand Up @@ -6982,7 +7015,8 @@ static void extract_func_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
if (ctx->enclosing_class_qn &&
(ctx->language == CBM_LANG_CPP || ctx->language == CBM_LANG_CUDA ||
ctx->language == CBM_LANG_TYPESCRIPT || ctx->language == CBM_LANG_TSX ||
ctx->language == CBM_LANG_ARKTS || ctx->language == CBM_LANG_NIX ||
ctx->language == CBM_LANG_ARKTS || ctx->language == CBM_LANG_VISUALBASIC ||
ctx->language == CBM_LANG_NIX ||
ctx->language == CBM_LANG_PYTHON)) {
def.qualified_name = cbm_arena_sprintf(a, "%s.%s", ctx->enclosing_class_qn, qn_name);
}
Expand Down Expand Up @@ -9015,6 +9049,11 @@ static void drop_c_typedefs_shadowed_by_tags(CBMExtractCtx *ctx, int first) {

// Find the body/members node inside a class node
static TSNode find_class_body(TSNode class_node, CBMLanguage lang) {
/* VB.NET type declarations carry members directly. Their repeated `body`
* field exposes only the first member through child_by_field_name. */
if (lang == CBM_LANG_VISUALBASIC) {
return class_node;
}
// Try field names first
static const char *body_fields[] = {"body", "members", "class_body", "declaration_list", NULL};
for (const char **f = body_fields; *f; f++) {
Expand Down Expand Up @@ -9581,8 +9620,10 @@ static void extract_class_methods(CBMExtractCtx *ctx, TSNode class_node, const c
* under the owning class using the class name (`Explicit.Explicit`).
* Classes with only an implicit constructor do not enter this branch
* and therefore do not gain a fabricated callable target. */
if (ctx->language == CBM_LANG_KOTLIN &&
strcmp(ts_node_type(method_node), "secondary_constructor") == 0) {
if ((ctx->language == CBM_LANG_KOTLIN &&
strcmp(ts_node_type(method_node), "secondary_constructor") == 0) ||
(ctx->language == CBM_LANG_VISUALBASIC &&
strcmp(ts_node_type(method_node), "constructor_declaration") == 0)) {
TSNode constructor_name = ts_node_child_by_field_name(class_node, TS_FIELD("name"));
if (ts_node_is_null(constructor_name)) {
constructor_name = cbm_find_child_by_kind(class_node, "type_identifier");
Expand Down Expand Up @@ -12107,6 +12148,63 @@ static bool extract_schema_field(CBMExtractCtx *ctx, TSNode child, const char *c
return true;
}

/* VB.NET fields declare one or more variable_declarator children and carry
* their type in an as_clause rather than a `type` field. Properties/events do
* expose `name` directly. Emit every declarator instead of dropping the whole
* declaration in the generic C-family path. */
static bool extract_visual_basic_fields(CBMExtractCtx *ctx, TSNode child, const char *class_qn,
const CBMLangSpec *spec) {
if (ctx->language != CBM_LANG_VISUALBASIC) {
return false;
}
CBMArena *a = ctx->arena;
const char *kind = ts_node_type(child);
TSNode names[CBM_SZ_64];
int name_count = 0;
if (strcmp(kind, "field_declaration") == 0) {
uint32_t nc = ts_node_named_child_count(child);
for (uint32_t i = 0; i < nc && name_count < CBM_SZ_64; i++) {
TSNode declarator = ts_node_named_child(child, i);
if (strcmp(ts_node_type(declarator), "variable_declarator") != 0) {
continue;
}
TSNode name = ts_node_child_by_field_name(declarator, TS_FIELD("name"));
if (!ts_node_is_null(name)) {
names[name_count++] = name;
}
}
} else {
TSNode name = ts_node_child_by_field_name(child, TS_FIELD("name"));
if (!ts_node_is_null(name)) {
names[name_count++] = name;
}
}
TSNode as_clause =
find_first_descendant_by_kind(child, "as_clause", CBM_DESCENDANT_MAX_DEPTH);
for (int i = 0; i < name_count; i++) {
char *name = cbm_node_text(a, names[i], ctx->source);
if (!name || !name[0]) {
continue;
}
CBMDefinition def;
memset(&def, 0, sizeof(def));
def.name = name;
def.qualified_name = cbm_arena_sprintf(a, "%s.%s", class_qn, name);
def.label = "Field";
def.file_path = ctx->rel_path;
def.parent_class = class_qn;
def.return_type =
ts_node_is_null(as_clause) ? NULL : cbm_node_text(a, as_clause, ctx->source);
def.start_line = ts_node_start_point(child).row + TS_LINE_OFFSET;
def.end_line = ts_node_end_point(child).row + TS_LINE_OFFSET;
def.is_exported = cbm_is_exported(name, ctx->language);
def.decorators = extract_decorators(a, child, ctx->source, ctx->language, spec);
def.docstring = extract_member_docstring(ctx, child);
cbm_defs_push(&ctx->result->defs, a, def);
}
return true;
}

static void extract_class_fields(CBMExtractCtx *ctx, TSNode class_node, const char *class_qn,
const CBMLangSpec *spec) {
if (!spec->field_node_types || !spec->field_node_types[0]) {
Expand Down Expand Up @@ -12152,6 +12250,9 @@ static void extract_class_fields(CBMExtractCtx *ctx, TSNode class_node, const ch
if (extract_schema_field(ctx, child, class_qn)) {
continue;
}
if (extract_visual_basic_fields(ctx, child, class_qn, spec)) {
continue;
}

// ObjectScript UDL member extraction. property/parameter -> Variable;
// index/trigger/xdata/storage/foreignkey -> labelled members with
Expand Down
Loading
Loading