Commit Graph
68 Commits
Author SHA1 Message Date
Martin Vogel 85fc74fc31 Full Windows portability: proper implementations, not stubs
- handle_processes: GetProcessMemoryInfo + GetProcessTimes (Windows),
  getrusage (POSIX) — real process metrics on both platforms
- handle_process_kill: TerminateProcess via OpenProcess (Windows),
  kill(SIGTERM) (POSIX)
- index_thread_fn: CreateProcess + WaitForSingleObject (Windows),
  fork+exec+waitpid (POSIX)
- cbm_clock_gettime: QueryPerformanceCounter (Windows) — replaces
  all bare clock_gettime calls across 6 files
- cbm_nanosleep, cbm_strcasestr, cbm_mkdir: compat shims
- CBM_TLS: _Thread_local (C11 standard, works on all compilers)
- Replace bare strndup with cbm_strndup, guard POSIX headers
- Add mingw-w64 cross-compile to Docker test infrastructure
2026-03-18 18:47:43 +01:00
Martin Vogel a1d849aaaa Fix all memory leaks, vendor sqlite3, add Docker test infrastructure
Leak fixes (13 sources, 1.4MB → 0 bytes):
- Cypher: free col_names after rb_set_columns, free rejected inline
  prop nodes, store WITH aliases in qualified_name for auto-cleanup
- Store: add cbm_project_free_fields, fix find_node_ids_by_qns leak
- Graph buffer: free strdup'd hash keys during delete operations
- SQL scanner: free old start_tag before reassignment in deserialize

Platform independence:
- Vendor sqlite3 amalgamation (3.49.1) — eliminates system libsqlite3
  dependency, enables full ASan/LeakSanitizer instrumentation
- Add -I for vendored tree-sitter unicode headers — eliminates hidden
  dependency on system libicu-dev
- Add test-infrastructure/ with Docker Compose for local GCC+ASan
  testing that mirrors CI exactly
2026-03-18 16:28:27 +01:00
Martin Vogel c9ec1d1eb4 Fix Ubuntu CI: stack-use-after-return, L2 cache detection, memory leaks
- Arena-allocate pair_field_types in cpp_stdlib_data.c (was stack array
  escaping scope via registry pointer — caught by GCC ASan)
- Add sysfs fallback for L2 cache on Linux ARM (sysconf returns 0)
- Expose cbm_node_free_fields() and fix 12+ leak sites in tests where
  find_node_by_id/qn results were never freed (caught by LeakSanitizer)
2026-03-18 14:23:46 +01:00
Martin Vogel 4f3f2f4b22 Fix UBSan: guard cbm_type_is_unknown against misaligned dangling pointers 2026-03-18 00:42:12 +01:00
Martin Vogel 18fa9979ee Replace vmem with mimalloc global allocator, add extraction-phase prescan, fix __init__.py QN collision
Memory management:
- Vendor mimalloc v2.1.9 as global allocator (MI_OVERRIDE=1 in prod)
- New mem.h/mem.c: RSS-based budget tracking via mi_process_info()
- Remove vmem.c/vmem.h (mmap-based budget tracking)
- Remove slab tier2 bump allocator (~300 LOC); >64B goes to mimalloc
- Slab tier1 pages from malloc (= mimalloc) instead of vmem
- Arena blocks from malloc instead of vmem
- Budget raised from 35% to 50% RAM (no more untracked C++ heap)

Extraction-phase prescan (eliminates disk re-reads):
- HTTP call sites: keyword check + URL extraction during extraction
- HTTP routes: decorator + source-based extraction during extraction
- Config file refs: regex scan during extraction
- httplinks: 41.8s → 13ms on Linux kernel (3,212x faster)
- configlink: 41.4s → 0.8s on Linux kernel (54x faster)
- Linux kernel fast-mode total: 2m38s → 1m18s

Bug fixes:
- __init__.py Module QN no longer collides with Folder QN
- index.ts same fix for JS/TS packages
- 13 regression tests for QN collision at FQN + extraction layers
- search_graph/search_code default limit raised from 10 to 500k
- Resolve all clang-tidy, cppcheck, and clang-format warnings

Repo cleanup:
- tree-sitter-form, tree-sitter-magma moved to tools/
- .gitignore: build/, node_modules/, graph-ui/dist/, TEST_PLAN.md
2026-03-17 22:05:57 +01:00
Martin Vogel 0d216c7936 Resolve all clang-tidy, cppcheck, and clang-format warnings across 94 files
Enforce WarningsAsErrors: '*' with zero suppressions of entire check categories.
All non-FP warnings fixed at source; true false positives get per-instance NOLINT
with reasoning. Fixes include: braces around statements (1679), isolate declarations
(75), explicit casts for multilevel pointer conversions, missing includes, function
parameter documentation via NOLINT, and proper NOLINTBEGIN/NOLINTEND nesting.
2026-03-15 22:37:34 +01:00
Martin Vogel 6f0910278b Remove all Go code — project is now pure C
Delete Go MCP server, CGo bridges, Go pipeline, store, tools, watcher,
cypher engine, language specs, and all Go tests. Replace Go pre-commit
hook with C-only linting (clang-tidy, cppcheck, clang-format, tests).
Tree-sitter extraction engine (internal/cbm/*.c) retained for C pipeline.
2026-03-15 20:32:19 +01:00
Martin Vogel 94a9a92f83 Add C-native pipeline with blocking clang-tidy, cppcheck, clang-format linting
Complete C implementation of the indexing pipeline (src/), parallel worker
pool, graph buffer with merge support, SQLite writer, and 1893-test suite.

Linter setup: zero warnings from clang-tidy (all checks enabled, no NOLINT
suppressions), cppcheck, and clang-format. All issues fixed at source —
proper headers for external linkage, GROW_ARRAY macro restructured to
eliminate type parameter, null-deref paths guarded, named intermediates
for suspicious-argument checks.
2026-03-15 19:26:12 +01:00
Martin Vogel f85a4e1c14 RAM-first pipeline with fused C LZ4 + Aho-Corasick multi-pattern matching
Full indexing now runs entirely in RAM:
- One filepath.Walk, one bulk file read (LZ4 HC compressed sourceStore)
- In-memory SQLite for all passes, single Backup API dump at end
- Source access via C LZ4 decompression (~3μs per file, 5.7 GB/s)

Aho-Corasick engine (internal/cbm/ac.c):
- Custom ACISM automaton with bitmask output (≤64 patterns)
- Fused LZ4 decompress + AC scan in C-side thread-local buffer
- Batch API: single CGo call scans all files (ScanLZ4Batch)
- Compact alphabet mode for configlinker (38-char table)

Pipeline optimizations:
- httplinks: AC pre-screens files for HTTP client + route keywords
- configlinker: AC batch scan replaces O(n×m) substring matching
- Infrascan/envscan: iterate sourceStore keys instead of walking disk
- All source reads via getSource() (LZ4 decompress from RAM)
- File hashes pre-computed during bulk load (zero re-reads)
2026-03-14 10:42:34 +01:00
Martin Vogel 522bd5b1fd Expand C/C++ LSP resolver: template substitution, smart pointer chains, 700+ tests
Major improvements to the C/C++ type-aware call resolver:

- Template argument substitution for qualified calls (std::get<T>, std::any_cast<T>,
  std::make_shared<T>) — strip template args from AST, substitute TYPE_PARAMs in
  return types, wrap NAMED→TEMPLATE for downstream smart pointer deduction
- Smart pointer deref uses suffix matching (handles module-prefixed QNs like
  "test.main.std.shared_ptr")
- Fix storage_class_specifier/type_qualifier skipping in c_parse_declaration_type
  (static/const/virtual methods now get correct return types)
- Scope-aware alias resolution in c_resolve_name_to_type (typedef/using)
- Template namespace fallback in c_parse_type_node (resolve types within
  current namespace during template class pre-pass)
- Pending template call resolution emits with correct caller QN
- Add ~330 new tests covering C++17 (structured bindings, if-init, CTAD, optional),
  C++20 (coroutines, concepts, ranges), heavy templates, real-world patterns
  (smart pointers, iterators, RAII, factories), STL completeness, and C patterns
2026-03-13 19:47:36 +01:00
Martin Vogel d201a5faa6 Close C/C++ LSP gaps: overload scoring, lambda/decltype inference, virtual dispatch
Type system improvements:
- Overload resolution by parameter type (score_overload_match with type compatibility)
- Lambda return type inference (trailing return type + shallow body walk)
- Inline namespace normalization (strip __1, __cxx11, __gnu_cxx)
- Implicit conversions in overload scoring (const char* → string, numeric promotions)
- Virtual dispatch: prefer derived override over base method
- CRTP detection: template param → derived class mapping
- Range-for iterator protocol: map element fix + begin()/operator*() fallback
- Default argument support via min_params range matching
- Free function auto deduction: identifier eval order fix (function before type)
- decltype() return type parsing in c_parse_return_type_text
- Trailing return type syncs both return_type and return_types array
2026-03-13 00:49:42 +01:00
Martin Vogel a8daedf759 Add C/C++ hybrid LSP resolver with type-aware call resolution
Implement a tree-sitter-based type evaluator for C/C++ that resolves
method calls, template instantiations, and cross-file references without
requiring a full compiler. Covers ~95% of C and ~93% of moderate C++.

Key features:
- Type-aware overload resolution scoring by parameter types
- Lambda return type inference (trailing return + body deduction)
- Inline namespace normalization (__1, __cxx11, __gnu_cxx)
- Implicit conversions (char*->string, numeric promotions)
- Virtual dispatch with override preference
- CRTP detection and self-type resolution
- Range-for iterator protocol (maps, custom containers)
- Smart pointer arrow dispatch (unique_ptr, shared_ptr)
- Dependent member calls in templates via pending call resolution
- Explicit template argument substitution (make_shared<T>)
- Nested class scope resolution
- C/C++ stdlib type stubs (containers, strings, I/O, smart ptrs)
- Cross-file LSP with compile_commands.json support
- C/C++ parameter extraction via declarator chain traversal

63+ test cases covering all resolution strategies.
2026-03-13 00:07:28 +01:00
Martin Vogel 0c80a37b08 Replace scan-all watcher with explicit watch list to fix #49 OOM
Watcher no longer polls every indexed project via ListProjects(). Instead,
projects are added to an explicit watch list on index/auto-index and removed
on delete. Cross-project tool calls (search_graph, trace_call_path, etc.)
touch the watch list so referenced projects stay fresh.
2026-03-12 16:18:44 +01:00
Martin Vogel fac0c57359 Fix stability: SQLite lock race, stale SHM recovery, OOM guard, CPU reduction
- Fix ref counting race in ListProjects and watcher pollAll: use AcquireStore
  instead of ForProject to prevent evictor from closing stores mid-query (#52)
- Add recoverStaleSHM: remove stale SHM files after SIGKILL to prevent
  deadlock on next connection (#52)
- Increase busy_timeout from 5s to 10s for large databases (#52)
- Default GOMEMLIMIT to 2GB when not configured, preventing unbounded
  memory growth and OOM kills (#49, #46)
- Reduce mmap_size from 256MB to 64MB per database (#49, #46)
- Increase watcher base interval from 1s to 5s and poll interval base
  from 1s to 5s, reducing CPU usage by ~5x (#45)
- Normalize Windows drive letter to lowercase in ProjectNameFromPath,
  preventing duplicate databases for same path (#50)
2026-03-12 15:06:20 +01:00
Martin Vogel 74546edb18 Fix heap-buffer-overflow in Swift tree-sitter scanner
The Swift external scanner called calloc(0, sizeof(ScannerState)) which
returns a 0-or-1-byte allocation per the C standard. The scanner then
writes a uint32_t (4 bytes) to this region via state->ongoing_raw_str_hash_count,
causing a heap-buffer-overflow detected by AddressSanitizer.

Fix: calloc(0, ...) → calloc(1, ...).
2026-03-12 14:03:39 +01:00
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 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 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 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 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 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 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 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 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
ugurtafrali dbaca94366 Add test for R function name resolution 2026-03-03 02:16:20 +03: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 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 02bc3b7352 Release v0.3.0: 25 languages, install/update CLI, skills, benchmark
Language expansion (13 → 25):
  Add Ruby, C, Bash, Zig, Elixir, Haskell, OCaml, HTML, CSS, YAML,
  TOML, HCL with tree-sitter grammars and language specs.
  Restore Erlang and SQL with extraction fixes.

CLI install/update/uninstall commands:
  Auto-detect Claude Code and Codex CLI, register MCP server,
  install task-specific skills, self-update with SHA-256 verification.

Embedded skills (4):
  exploring, tracing, quality, reference — auto-trigger in Claude Code
  for graph-first code discovery.

Pipeline improvements:
  Docstring extraction, enrichment pass for params/returns/complexity,
  graceful context cancellation, improved test detection.

35-language benchmark (BENCHMARK.md):
  12 questions × 35 repos, 91.8% overall score, Linux kernel stress
  test (20K nodes, zero timeouts). Replaces old benchmark artifacts.
2026-03-01 18:01:52 +01:00
Martin Vogel c28052dbf3 Fix update-available notice: goroutine ordering, body limit, UX
Three bugs prevented the update notice from appearing:
- checkForUpdate goroutine launched after blocking sessionOnce.Do,
  so it never ran before tool calls arrived
- 4KB body limit truncated the ~15KB GitHub API response
- Notice was a JSON map key with no guaranteed ordering

Fixes:
- Move go checkForUpdate() before sessionOnce.Do in all handlers
- Increase body read limit to 64KB
- Prepend notice as separate MCP TextContent block (appears first)
- Link to GitHub releases page instead of go install command
2026-02-28 03:17:45 +01:00
Martin Vogel c10d6676ff Fix gofmt: import order and trailing newlines 2026-02-28 02:48:20 +01:00
Martin Vogel a7f1efc675 Bump version to 0.2.1 2026-02-28 02:44:36 +01:00
Martin Vogel 1ff4b70b93 Tighten cache directory permissions from 0755 to 0750
Drop world-read/execute on cache directories created by MkdirAll.
Addresses gosec G301 findings — no functional change.
2026-02-28 02:42:57 +01:00
Gaurav Ratnawat 6d5af59d3e feat: add Kotlin language support
Add Kotlin (.kt, .kts) as the 13th supported language with full
tree-sitter parsing, AST node extraction, call resolution, usage
tracking, and string constant propagation.
Changes:
- internal/lang/kotlin.go: Kotlin LanguageSpec registration
- internal/lang/lang.go: Add Kotlin constant and AllLanguages()
- internal/parser/parser.go: Register tree-sitter-kotlin grammar
- internal/pipeline/pipeline.go: Kotlin in isConstantNode(),
  isExported(), extractCalleeName()
- internal/pipeline/resolve.go: resolveKotlin() for val declarations
- internal/pipeline/usages.go: Kotlin reference node types
- Tests: TestParseKotlin, TestResolveKotlinConcat, extension tests
- go.mod: Add tree-sitter-grammars/tree-sitter-kotlin v1.1.0
- README.md: Update language count to 13
2026-02-28 02:36:50 +01:00
Martin Vogel 27e0707c6d Fix missing trailing newlines in Kotlin PR files 2026-02-28 02:31:11 +01:00
Gaurav Ratnawat 91f50bd95c test: add comprehensive Kotlin tests across all test files
- lang_test.go: TestKotlinSpec validates extensions, function/class node types
- pipeline_test.go: TestPipelineKotlinProject integration test (functions, classes, methods, edges)
- resolve_test.go: TestResolveKotlinChained for 3-level string concat resolution
  Also restore 8 previously deleted tests (CPP, Lua, env vars, JS nullish/logical-or, etc.)
- usages_test.go: TestPassUsagesKotlinCreatesEdges, TestPassUsagesKotlinDoesNotDuplicateCalls
2026-02-28 02:25:24 +01:00