Commit Graph
91 Commits
Author SHA1 Message Date
Martin Vogel 4fe90cabd8 Fix file handle leak in gitignore loading for Windows compatibility
Replace the go-gitignore library's NewRepository (which opens .gitignore
files via os.Open but never closes the handles) with a custom repoMatcher
that reads files via os.ReadFile and passes strings.NewReader to the
library's New() function. This ensures all file handles are closed
immediately after reading.

The library's ignore.Relative() pattern matching is preserved — only the
hierarchy walker and file loading are reimplemented. The matching algorithm
follows standard git precedence: child .gitignore overrides parent,
negation patterns in child override matching patterns in parent, and
.git/info/exclude is checked last.

Fixes Windows CI where leaked handles prevented t.TempDir() cleanup.
2026-03-12 13:47:51 +01:00
Martin Vogel bd6bbc2ab1 Add Go LSP hybrid type resolver, config store, and supporting infrastructure
- Go LSP cross-file type resolution engine (internal/cbm/lsp/) with C-based
  type registry, scope tracking, and Go stdlib data (30K+ definitions)
- lsp_bridge.go: CrossFileDef struct and RunGoLSPCrossFile CGo bridge
- config.go: persistent ConfigStore (SQLite) for auto_index, mem_limit settings
- CLI config subcommand for get/set/list/delete operations
- Store: edge batch upsert, project config columns, goleak test harness
- Pipeline: prefetch parallelism, resolver improvements, memleak tests
- CI: dry-run workflow improvements, vendor-grammar.sh enhancements
2026-03-12 13:26:13 +01:00
Martin VogelandHarry Chan c4848a89aa Fix: respect explicit LIMIT in Cypher query_graph
applyLimit() silently capped all results to maxRows (default 200), even
when the user specified a higher LIMIT clause. This caused queries like
MATCH (f:Function) RETURN f.name LIMIT 500 to return only 200 rows,
and COUNT() aggregations to silently undercount on large datasets.

Now explicit LIMIT values from Cypher are respected as-is. The 200-row
default still applies when no LIMIT clause is provided.

Incorporates the fix from PR #40 by @re-thc.

Co-authored-by: Harry Chan <38070640+re-thc@users.noreply.github.com>
2026-03-12 13:05:53 +01:00
Martin Vogelandwassertim 342ff5a27f Skip .worktrees directory during indexing
Git worktrees (stored in .worktrees/) duplicate the entire source tree,
causing the knowledge graph to contain duplicate nodes and edges for
every function, class, and route. Add .worktrees to IGNORE_PATTERNS
alongside .git and .svn.

Incorporates the fix from PR #37 by @wassertim. Closes #31 (partial).

Co-authored-by: wassertim <wassertim@gmail.com>
2026-03-12 13:02:02 +01:00
Martin Vogel f92fff86d4 Add comprehensive --help, update README with gitignore/LSP hybrid docs
CLI --help now shows:
- All 14 MCP tools with parameter schemas and example JSON payloads
- Layered file ignoring (.gitignore → .cbmignore → .cgrignore)
- 64-language list with Go tree-sitter+LSP hybrid note
- CLI invocation syntax and examples
- Configuration and data storage paths

README updates:
- Replace .cgrignore section with layered ignoring docs
  (.gitignore, .cbmignore, .cgrignore backward compat)
- Add Go tree-sitter + LSP hybrid feature note (coming soon for more languages)
- Update tool count from 12 to 14 (index_status, ingest_traces)
- Update architecture section (discover, cbm/lsp descriptions)
2026-03-12 12:58:14 +01:00
Martin Vogel d8df2be5dc Respect .gitignore, add .cbmignore support, skip symlinks, expand ignore list
- Parse full .gitignore hierarchy (nested files + .git/info/exclude) via
  boyter/gocodewalker go-gitignore library for git repos
- Add .cbmignore as repo-root gitignore-style file that stacks on top of
  .gitignore for indexer-specific exclusions (e.g. generated code in git)
- Skip symlinked files and directories to prevent duplicate indexing
- Move bin/, build/, out/ from always-on IGNORE_PATTERNS to fast-mode-only
  (prevents false exclusions in Go, CMake, Maven projects)
- Add 28 ecosystem-specific cache/artifact dirs to IGNORE_PATTERNS:
  .next, .nuxt, .svelte-kit, .angular, .turbo, .terraform, bazel-bin,
  zig-cache, .cargo, .stack-work, elm-stuff, .metals, .bloop, etc.
- Keep .cgrignore for backward compatibility
- 17 new tests: gitignore patterns, negation, globstar, nested, exclude file,
  non-git repos, dir-only, cbmignore stacking, symlinks, pattern changes
2026-03-12 12:57:55 +01:00
Martin Vogel a208b34c8b Fix all golangci-lint issues across the codebase
- watcher_test.go: add mustWriteFile/mustMkdirAll helpers for errcheck (26 fixes),
  use exec.CommandContext for noctx
- watcher.go: remove unused projectsCacheTTLValue, fix nilerr in WalkDir callbacks,
  name return values on checkSentinel, fix gofmt
- executor.go: rename shadowed builtin 'cap' to bindingCap/stepCap
- pipeline.go: extract runPostFlushPasses (funlen), extract collectEdgeQNs/
  createLSPStubNodes/buildEdgesFromResults from flushResolvedEdges (gocognit)
- pipeline_cbm.go: extract runGoLSPCrossFileResolution/collectLSPResolvedEdges/
  resolveCallEdge (gocognit, nestif), fix gofmt
- go_dep_registry.go: extract extractFuncDef/extractTypeDefs/extractStructEmbeds
  (gocognit), preallocate retTypes, nolint for deprecated parser.ParseDir
- go_lsp_cross.go: extract enrichStructFieldsFromGenDecl/enrichIfaceMethodsFromGenDecl
  (gocognit), fix rangeValCopy for 152-byte structs
- memleak_test.go: change file permissions to 0o600 (gosec G306)
- router.go, tools.go: fix gofmt formatting
2026-03-12 12:57:20 +01:00
Martin Vogel 3ff579c670 Update language count to 64, add Wolfram to language lists 2026-03-07 18:27:31 +01:00
Martin Vogel f9945e75a4 Fix Windows linker: --allow-multiple-definition for GCC 15.2.0 UCRT64 regression 2026-03-07 18:12:33 +01:00
Martin Vogel 497dd6e61a Add Wolfram Language support (64 languages) + fix caller attribution
- Vendor LumaKernel/tree-sitter-wolfram grammar (ABI 13, parser.c + scanner.c)
- Register Wolfram language: .wl/.wls extensions, set_delayed_top/set_top/
  set_delayed/set as function types, apply as call type, get_top + Needs[]
  as import types
- Add CBM_LANG_WOLFRAM enum, lang spec entry, and grammar bridge
- Extract defs: resolve function name from apply(user_symbol("f"), ...) LHS
  of set/set_delayed definitions; recurse into function bodies for nested defs
- Extract calls: skip apply nodes that are definition LHS (not a call)
- Extract imports: handle << "file.wl" (get_top) and Needs["Package`"]
- Fix caller attribution: add func_kinds_wolfram to func_kinds_for_lang and
  add Wolfram name extraction in compute_func_qn (extract_unified.c) so the
  scope stack correctly tracks enclosing function for all call sites
- Add MATLAB function_call + command call extraction (63 -> 64 with Wolfram)
- Add Lean 4 apply call extraction with type-position filter
- Add regression tests for Wolfram, MATLAB, Lean calls + FORM pipeline test
2026-03-07 18:01:27 +01:00
Martin Vogel ced21194ac Fix Magma import/call extraction, resolve file-path imports in linker
- Add field('path', ...) to Magma load_statement grammar rule so
  parse_generic_imports() finds the import path via field lookup
  instead of the broken text fallback (which only extracted 1 per file)
- Fix passImports() to resolve file-path imports (e.g. "utils.mag",
  "lib/helpers.h") via fqn.ModuleQN() when raw path doesn't match
  any node QN — general fix benefiting any file-path-based import
- Add TestMagmaImport_Regression and TestMagmaCall_Regression
- Update language count 59 → 63 in README, docs/index.html, marketing
2026-03-07 12:55:56 +01:00
Martin Vogel 33293b89d3 Add MATLAB, Lean 4, FORM, and Magma language support (59 -> 63)
Custom tree-sitter grammars for FORM and Magma (no upstream exists).
MATLAB uses acristoffers/tree-sitter-matlab, Lean uses leanprover/tree-sitter-lean4.
Includes .m file disambiguation (Objective-C vs MATLAB) via Linguist heuristics.
2026-03-07 10:46:32 +01:00
Martin Vogel 0474a5c78e Add MATLAB, Lean 4, FORM, and Magma language support (59 -> 63)
- MATLAB: vendored from acristoffers/tree-sitter-matlab, definitions-only
  (no call graph due to A(1) indexing ambiguity), .m file disambiguation
  via GitHub Linguist heuristics in discover.go
- Lean 4: vendored from Julian/tree-sitter-lean, definitions-only
  (Lean 4 syntax is runtime-extensible), ABI 13 backward-compatible
- FORM: custom tree-sitter grammar written from scratch for symbolic
  manipulation language used in particle physics (CERN/Nikhef)
- Magma: custom tree-sitter grammar written from scratch for computer
  algebra system (Univ. Sydney)

Integration touchpoints per language: cbm.h enum, cbm.go map, lang.go
constants, lang_specs.c (extern + arrays + table + switch), helpers.c
(func_kinds + module_parents + test detection), extract_defs.c
(resolve_func_name for MATLAB/Lean), extract_imports.c, lang/<name>.go
spec, discover.go (.m heuristic), regression_test.go (9 new tests).
2026-03-07 10:46:21 +01:00
Martin Vogel fcff5b8dc9 Unify version management via build-injected ldflags
tools.Version was a hardcoded const that needed manual bumping.
Now it defaults to "dev" and is set from main.version (injected
via -ldflags during release builds) through tools.SetVersion().
2026-03-07 00:07:43 +01:00
Martin Vogel f7574a3622 Fix Windows file URI path parsing in watcher
parseFileURI returned /C:/Users/... (with leading /) for Windows
file:///C:/... URIs, causing watcher.root_gone loop because os.Stat
fails on that path. Strip the leading / before drive letters and
normalize with filepath.FromSlash.

Fixes the remaining watcher bug from #20.
2026-03-06 22:20:47 +01:00
Martin Vogel 26f686550c Statically link Windows binary to fix missing DLL error
Add -extldflags '-static' to Windows build so libwinpthread-1.dll
and other MinGW runtime DLLs are embedded in the binary.
2026-03-06 21:29:58 +01:00
Chitral Verma d248e7348f Fix binary move command in setup script (#16) 2026-03-06 21:19:38 +01:00
Martin Vogel fe20c998f2 Update landing page and README with latest stats
- Languages: 35 -> 59
- Add Gemini CLI, VS Code, Zed to supported clients list
- Update benchmark description to match v7 methodology
- Update meta tags and comparison table
2026-03-06 20:03:00 +01:00
Martin Vogel e292f875a9 Fix community issues #15, #17, #20 and add editor support #19
- Fix Continue.dev invalid_type error: add properties:{} to list_projects schema (#15)
- Fix Windows paths: sanitize colons and backslashes in ProjectNameFromPath (#20)
- Fix update double-v prefix: strip v from version before display (#17)
- Fix update context canceled: DownloadAsset returns []byte, not ReadCloser (#17)
- Strip v prefix in release workflow ldflags (Unix + Windows builds)
- Add Gemini CLI, VS Code Copilot, and Zed to install/uninstall commands (#19)
- Add tests for new editor configs and Windows path cases
2026-03-06 19:51:47 +01:00
Martin Vogel f3c80e94ae Fix Windows CLI test DLL_NOT_FOUND failure
Tests that replace PATH with an empty temp dir break DLL resolution
on Windows (MSYS2 libgcc/libwinpthread). Append original PATH on
Windows so CGo-linked binaries can still find required DLLs.
2026-03-06 19:05:33 +01:00
Martin Vogel c34a2da178 Fix Windows build: add ts_runtime/src to include path for unicode headers
The vendored ICU-subset headers use "unicode/umachine.h" includes.
Adding src/ to CFLAGS lets the compiler resolve these on Windows
where no system ICU is available.
2026-03-06 18:53:02 +01:00
Martin Vogel 8d4a0ece81 Vendor complete tree-sitter unicode headers for Windows
Add all 6 ICU-subset headers (ptypes.h, umachine.h, urename.h, utf.h,
utf16.h, utf8.h) from tree-sitter v0.24.7. MSYS2 lacks system ICU.
2026-03-06 18:44:11 +01:00
Martin Vogel f896318d84 Vendor tree-sitter unicode headers for Windows build
MSYS2 lacks system ICU headers. Vendor utf8.h and utf16.h from
tree-sitter v0.24.7 lib/src/unicode/ to fix Windows compilation.
2026-03-06 18:36:47 +01:00
Martin Vogel 5b25f885d7 Add smoke-test.sh for CI binary validation 2026-03-06 18:27:51 +01:00
Martin Vogel 07f0beadc6 Add manual dry-run workflow for pre-release validation
Lint + test + build on all 5 OS targets without creating a release.
Trigger manually before running the release workflow.
2026-03-06 18:22:36 +01:00
Martin Vogel affa63a435 Fix Linux build: add _DEFAULT_SOURCE for endian macros
-std=c11 disables _DEFAULT_SOURCE on glibc, hiding le16toh/be16toh
from <endian.h>. Add -D_DEFAULT_SOURCE to CGo CFLAGS.
2026-03-06 18:19:24 +01:00
Martin Vogel 03a99be966 Remove automatic CI workflow, keep manual-only releases 2026-03-06 18:11:57 +01:00
Martin Vogel 68fbfa4bee Fix linux build: replace removed syscall.Fadvise with unix.Fadvise
syscall.Fadvise was removed in Go 1.26. Use golang.org/x/sys/unix instead.
2026-03-06 18:09:41 +01:00
Martin Vogel da2d969aa3 Bump version constant to 0.4.0 for release 2026-03-06 18:05:45 +01:00
Martin Vogel ff7791613c Update README: 59 languages, correct edge types, cbm architecture
- Token efficiency section: 35 → 59 repos in benchmark description
- Edge types: remove stale (INHERITS, DEPENDS_ON_EXTERNAL, CONTAINS_MODULE),
  add current (ASYNC_CALLS, USAGE, CONFIGURES, WRITES, MEMBER_OF, etc.)
- Architecture: parser/ → cbm/ (vendored C grammars engine)
- Pipeline description: add config links pass
- Benchmark: update scoring terminology and overall score
- Not yet benchmarked: reduce to just Nix, Meson
2026-03-06 18:02:01 +01:00
Martin Vogel 05a35ac9b1 v0.5.1: Fix C/C++/CUDA/GLSL function extraction, add config linker and tests
- Fix extract_defs.c declarator chain traversal for C-family function_definition
  nodes (off-by-one in field name length, missing depth traversal)
- Add resolve_func_name() support for CommonLisp defun, Makefile rule, VimScript,
  Julia, Elm value_declaration, Groovy field_function methods
- Add config linker pipeline: 3 strategies linking config keys to code symbols,
  dependency manifest entries to imports, and config file path references
- Add regression tests (~150 cases across 50+ languages), language failure tests,
  and config extraction tests
- Refactor discover.go, configures.go, configlink_strategies.go to reduce
  cognitive complexity (extract helpers for gocognit compliance)
- Fix Louvain community detection: use map lookup instead of O(N) scan
2026-03-06 17:50:18 +01:00
Martin Vogel 59d40d4035 v0.5: CBM tree-sitter engine, 59 vendored language grammars
- Replace Go-binding tree-sitter with vendored C grammars compiled via
  CGo (internal/cbm/); eliminates all Go module/linker fragility
- Add 32 new languages: Clojure, CMake, COBOL, Common Lisp, CUDA, Elm,
  Emacs Lisp, Fortran, F#, GLSL, GraphQL, INI, JSON, Julia, Makefile,
  Markdown, Meson, Nix, Protobuf, Svelte, Verilog, Vim Script, Vue, XML
  (plus C, C#, Erlang, SQL, YAML quality improvements)
- Adaptive worker concurrency and mmap prefetch for faster indexing
- Graph buffer: batched SQLite writes for 3-5x throughput improvement
- Fix cancellation test: use 50ms timeout (pipeline now indexes 212-file
  Erlang repo in ~400ms, well under the old 2s deadline)
- Fix isTestFunction: add "Test" prefix for C#, "test" prefix for Scala
2026-03-05 22:39:01 +01:00
Martin Vogel 34839c2a81 Fix Louvain community detection O(N^2) bottleneck
Replace naive modularityGain (scanned all nodes per call) with
per-community commSumTot accumulators maintained incrementally.
Each iteration is now O(m) instead of O(N^2).

Django benchmark: communities pass 4m40s → 0.94s (297x faster),
total indexing 5m38s → 24s.
2026-03-03 18:07:45 +01:00
Martin Vogel 343f6e58ab Fix Windows CI: close SQLite before TempDir cleanup
Add t.Cleanup(router.CloseAll) to snippet and watcher test helpers.
Windows does not allow deleting files held by another process, so the
SQLite DB must be closed before t.TempDir() removal runs.
2026-03-03 16:50:01 +01:00
Martin Vogel 1ff78eae2d v0.4: Pipeline quality improvements, snippet tool optimization
Pipeline quality:
- 17 import parsers (ES modules, Java, Kotlin, Scala, C#, C, C++, PHP,
  Ruby, Rust, Lua, Elixir, Bash, Zig, Erlang, Haskell, OCaml)
- Language-aware isClassDeclaration() for TS, Java, C#, Scala, Kotlin, PHP
- Route test filtering (isTestNode + containsTestSegment)
- Haskell/OCaml/Elixir callee extraction for apply/infix/application nodes
- JSX component refs via extractJSXComponentRefs()
- Typed + dynamic type inference split
- Extraction test coverage (1679 lines)

Snippet tool optimization for AI coding agents:
- Replace "error" key with "status"/"message" in disambiguation responses
- Add auto_resolve param (opt-in, picks best from <=2 candidates)
- Add include_neighbors param (opt-in, returns caller/callee names)
- Fix fuzzy fallback to extract last dot-segment from qualified names
- Add NodeNeighborNames store method for neighbor name lookups
2026-03-03 16:26:31 +01:00
DeusData 33d7952791 Merge pull request #14 from utafrali/fix/issue-5-fix-r-function-name-resolution-all-funct
Add test for R function name resolution
2026-03-03 12:49:05 +01:00
ugurtafrali dbaca94366 Add test for R function name resolution 2026-03-03 02:16:20 +03:00
Martin Vogel 8397e4d00f Add robots.txt and sitemap.xml for search engine indexing 2026-03-02 23:15:48 +01:00
Martin Vogel 9e50803ca1 Add CONTRIBUTING.md and GitHub Pages landing page
- CONTRIBUTING.md: build from source, run tests, PR guidelines, language fix workflow
- docs/index.html: SEO-optimized landing page with benchmark data, feature grid, comparison table
2026-03-02 23:13:24 +01:00
Martin Vogel ee9f2b259b Add get_architecture, manage_adr tools; rename Leiden to Louvain
New tools:
- get_architecture: codebase architecture overview with 12 selectable aspects
  (languages, packages, entry_points, routes, hotspots, boundaries, services,
  layers, clusters, file_tree, adr)
- manage_adr: CRUD for Architecture Decision Records with 6 fixed sections,
  section filtering, validation, and discovery of existing architecture docs

Architecture analysis fixes:
- Fix qnToPackage extracting segment[2] for meaningful sub-packages instead
  of segment[1] which collapsed everything to top-level dirs
- Filter test functions from entry_points, hotspots, and routes using both
  is_test property (Module/File nodes) and file_path pattern matching
- Filter boundaries to Function/Method/Class nodes only
- Add FindArchitectureDocs for discovering existing architecture documentation

Naming corrections:
- Rename Leiden to Louvain throughout (algorithm is simplified Louvain,
  not actual Leiden which requires CPM-based refinement)
- leiden.go -> louvain.go with all symbols renamed
- Remove unused ClusterInfo.Modularity field (always zero)

Other changes:
- Case-insensitive search by default for search_graph and search_code
- Remove read_file and list_directory tools (handled by coding agents natively)
- Update tool descriptions and README for 8000 char ADR limit
2026-03-02 16:10:57 +01:00
Martin Vogel 57c8d9c2cb Update server.json to v0.3.1 release with SHA256 checksums
Bump version from 0.1.4 to 0.3.1, update all 5 platform download
URLs and SHA256 hashes, update language count from 12 to 35.
2026-03-02 01:35:18 +01:00
Martin Vogel dc506b4bd0 Release v0.3.1: detect_changes, risk scoring, editor support, SDK upgrade
- Add detect_changes tool: map git diff to affected symbols + blast radius
  with risk classification (unstaged/staged/all/branch scopes)
- Add risk_labels param to trace_call_path: depth-based impact classification
  (CRITICAL/HIGH/MEDIUM/LOW) with impact_summary counts
- Add Cursor + Windsurf MCP config auto-registration (install/uninstall)
- Upgrade go-sdk v1.3.1 → v1.4.0 (security fixes, spec compliance)
- Improve tool descriptions with inline regex examples for AI agents
- Update skills documentation and README
2026-03-02 01:02:00 +01:00
Martin Vogel 7d1f56836e Add replace option to release workflow
New boolean input allows re-releasing the same version by deleting
the existing release and force-updating the tag before rebuild.
2026-03-01 21:53:02 +01:00
Martin Vogel 3589a1bd1d Fix release binary naming and Codex CLI MCP registration
- Release workflow: build binary as `codebase-memory-mcp` (not
  `codebase-memory-mcp-<os>-<arch>`) inside tarballs. Users extract
  and get the correct name without renaming.
- Codex CLI: replace broken `codex mcp add/remove` calls with direct
  config.toml manipulation. Codex uses [mcp_servers.<name>] sections,
  not CLI subcommands.
- README: add explicit extract-and-move step to Quick Start.
2026-03-01 19:43:07 +01:00
Martin Vogel c4449d15f1 Fix mcp remove hanging: add -s user scope flag
claude mcp remove without -s user prompts interactively for scope,
which hangs when run from install/uninstall commands. Both
registerClaudeCodeMCP (pre-cleanup remove) and deregisterMCP
(uninstall) now pass -s user explicitly.
2026-03-01 19:32:07 +01:00
Martin Vogel b679b8a5ff Fix Windows CI: .exe suffix, USERPROFILE, skip Unix-specific tests
- TestMain: append .exe to binary name on Windows
- Add testEnvWithHome/setTestHome helpers for cross-platform HOME override
  (Windows uses USERPROFILE, not HOME)
- Add exeSuffix() helper for fake binary creation
- Skip Unix-specific tests on Windows: shell RC detection, PATH append,
  fallback path lookup
- Normalize CRLF in skill frontmatter check (git may convert on Windows)
2026-03-01 18:34:02 +01:00
Martin Vogel a6b872a6a3 Fix install: write skills unconditionally, not gated on claude CLI
Skill files were only written inside installClaudeCode(), which required
finding the `claude` CLI binary. In CI (Linux) with no claude installed,
skills were never written, causing 4 test failures.

Split into installSkills() (always runs) and registerClaudeCodeMCP()
(only when claude CLI found).
2026-03-01 18:16:24 +01:00
Martin Vogel 5fb14483af Update README numbers: 25 → 35 languages, fresh benchmark stats
- Feature line: list all 35 languages including Obj-C, Swift, Dart,
  Perl, Groovy, Erlang, R, SCSS, SQL, Dockerfile
- Performance section: updated with Django (49K nodes) and Linux
  kernel stress test numbers from the v0.3.0 benchmark
- Architecture section: 25 → 35 language specs
- Token efficiency: reference 35 real-world repos instead of single project
2026-03-01 18:06:27 +01:00
Martin Vogel 355e070b7a Remove root skills/ folder, now embedded in binary
Skills are shipped inside the binary and installed via
`codebase-memory-mcp install`. The standalone skills/ directory
is no longer needed.
2026-03-01 18:04:34 +01:00
Martin Vogel 402e98c5f4 Bump benchmark header to v0.3.0 2026-03-01 18:02:23 +01:00