Commit Graph
28 Commits
Author SHA1 Message Date
Andrew Hundt 67bb858edd docs: clarify refresh policy claims
Update README, generated docs, and bundled skills so auto-index and watcher text no longer implies incremental refresh is the default path.

Keep the wording aligned with the current config-backed default: full atomic rebuild unless incremental_reindex is explicitly enabled for benchmarking or canary coverage.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 12:36:09 -04:00
Andrew Hundt 794e25cb06 docs: correct MCP tool references
Update generated CLI skill text, packaged skill docs, and npm README examples for the current MCP surface: trace_path is the canonical trace tool, index_dependencies is present, and the streamlined/default surface should not be described as exactly 14 tools.

Replace unsupported search_graph direction examples with supported query_graph degree queries and fix stale query/result-limit wording in generated help. Keep measured performance/preprint claims unchanged.

Verified with: make -f Makefile.cbm cbm; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=cli build/c/test-runner; git diff --check.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 09:46:39 -04:00
Andrew Hundt 2ecedbeb80 Merge remote-tracking branch 'origin/main' into api-consolidation
# Conflicts:
#	.gitignore
#	.mcp.json
#	Makefile.cbm
#	cmd/codebase-memory-mcp/assets/skills/codebase-memory-exploring/SKILL.md
#	cmd/codebase-memory-mcp/assets/skills/codebase-memory-quality/SKILL.md
#	cmd/codebase-memory-mcp/assets/skills/codebase-memory-reference/SKILL.md
#	cmd/codebase-memory-mcp/assets/skills/codebase-memory-tracing/SKILL.md
#	internal/cbm/extract_imports.c
#	internal/cbm/lang_specs.c
#	src/discover/language.c
#	src/foundation/compat_fs.c
#	src/foundation/compat_fs.h
#	src/foundation/str_util.h
#	src/graph_buffer/graph_buffer.c
#	src/graph_buffer/graph_buffer.h
#	src/main.c
#	src/mcp/mcp.c
#	src/pipeline/pipeline.c
#	src/pipeline/pipeline.h
#	src/pipeline/pipeline_incremental.c
#	src/pipeline/pipeline_internal.h
#	src/store/store.c
#	src/store/store.h
#	src/watcher/watcher.c
#	tests/test_main.c
#	tests/test_pipeline.c
#	tests/test_store_bulk.c
#	tests/test_store_search.c
2026-04-10 22:13:18 -04:00
Martin Vogel c38853f999 Remove Go-era cruft, update THIRD_PARTY.md for pure C project
- Delete cmd/codebase-memory-mcp/assets/ — skills and codex instructions
  are embedded as C string literals in src/cli/cli.c since v0.5.0
- Move BENCHMARK.md to docs/ to reduce root clutter
- Fix setup scripts: replace stale go build with scripts/build.sh
- THIRD_PARTY.md: replace Go module dependencies with vendored C
  libraries (sqlite3, mimalloc, mongoose, yyjson, xxhash, tre),
  fix CGo reference to static compilation
2026-03-22 01:09:12 +01:00
Andrew Hundt 8775edc071 skills: document token reduction parameters in all 4 SKILL.md files
codebase-memory-reference/SKILL.md:
- Update search_graph, trace_call_path, query_graph, get_code_snippet
  tool descriptions with new parameters
- Remove read_file/list_directory (not in TOOLS[] array)
- Add "Token Reduction Parameters" section with mode, compact,
  max_lines, max_output_bytes, max_results documentation
- Add config key reference for runtime overrides
- Update Critical Pitfalls for new defaults
- Add decision matrix entries for summary, signature, head_tail

codebase-memory-tracing/SKILL.md:
- Add mode=signature example, max_results default, compact=true tip

codebase-memory-exploring/SKILL.md:
- Add mode=summary to Step 2, update default to 50, add compact tip

codebase-memory-quality/SKILL.md:
- Add mode=summary, compact=true, pagination_hint tips

Tests: 2052 passed, 0 failed
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-03-20 15:04:35 -04: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 ba626aac50 Use dynamic GOMEMLIMIT: 25% of system RAM, clamped to [2GB, 8GB]
Replace static 2GB default with platform-aware auto-detection:
- Linux: syscall.Sysinfo
- macOS: sysctl hw.memsize
- Windows: GlobalMemoryStatusEx

Falls back to 4GB if detection fails. User config still overrides.
Prevents both OOM kills (upper clamp) and excessive GC pressure (lower clamp).
2026-03-12 15:29:22 +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 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 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 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 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 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 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 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 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 fb30ca61d6 v0.2.0: Multi-DB router, enrichment pipeline, update-available notification, enhanced language support
Major changes:
- Store router: per-project SQLite databases with automatic migration
- Pipeline enrichment: community detection, inheritance, decorators, read/write tracking, test detection, type usage, exception flows, configuration relationships
- Update checker: lightweight GitHub release check on startup, injects update_available into first tool response
- Language support: enhanced extraction for C++, C#, Go, Java, JavaScript, Lua, PHP, Python, Rust, Scala, TSX, TypeScript
- Cypher executor: improved query execution with better aggregation and pattern matching
- HTTP link detection: cross-service HTTP call inference
- CLI mode: extended with --raw flag, human-friendly summaries for all tools
- Search: sort_by support, exclude_labels, glob matching improvements
- AST debug tool for parser development
2026-02-28 01:58:47 +01:00
Martin Vogel b5aded4eed Fix lint violations: extract helpers, use defer, prealloc slices
- Extract schema query helpers to reduce GetSchema cognitive complexity
- Add scanDegrees helper for batch degree counting with proper defer
- Fix errcheck, rowserrcheck, sqlclosecheck, prealloc, nestingReduce
- Suppress gocognit for Cypher step dispatch (inherently branchy)
2026-02-26 20:26:09 +01:00
Martin Vogel f932e87b6e v0.1.4: CLI mode, query performance optimizations, Go 1.26
Add CLI mode for direct tool invocation from the shell — every MCP tool
can now be called without an MCP client. Useful for testing, scripting,
and CI pipelines.

Query engine rewrite: SQL LIKE pre-filtering extracts literal substrings
from regex patterns before scanning, batch degree counting replaces
per-node queries, and schema queries use id→label maps instead of 3-way
JOINs. Cypher relationship queries up to 600x faster on large graphs.

Incremental reindex 4x faster via content-hash skip optimization.

Upgrade to Go 1.26 (Green Tea GC) and SQLite v1.46.1.
2026-02-26 19:27:27 +01:00
Martin Vogel 860e80c88f Add auto-sync watcher, fix WithTransaction data race, add infra file indexing
Auto-sync: background watcher polls indexed projects for file changes
(mtime+size) and triggers incremental re-indexing automatically. Adaptive
polling interval scales with repo size (1s-60s). Non-blocking — uses
TryLock to skip if manual index_repository is in progress.

WithTransaction: changed signature to return a transaction-scoped Store
instead of mutating the shared querier field. Eliminates a data race
where concurrent read handlers could use a committed transaction.

Infrastructure file indexing: new pipeline pass indexes Dockerfiles,
docker-compose, cloudbuild, .env, Terraform, and YAML config files as
InfraFile nodes with structured properties.

Also includes: indexMu mutex on Server for safe concurrent access,
Claude Code skill file in repo, updated README with auto-sync docs.
2026-02-25 16:05:34 +01:00
Martin Vogel 97284a35fa v0.1.0: Performance, incremental indexing, async boundary detection
Performance & quality:
- Transaction wrapping (Querier interface, single tx per index run)
- Composite indexes on edges table for faster traversals
- Cypher WHERE push-down (=, CONTAINS, STARTS WITH → SQL)
- golangci-lint with 25 linters, zero violations
- 11 benchmarks for pipeline, search, and BFS

Incremental indexing:
- Content-hash based file change detection
- Dependency-aware two-level invalidation (changed + dependents)
- Stale file cleanup for deleted files

Async boundary detection:
- Project-wide env var URL scanner (Dockerfile, YAML, .tf, .sh, .env,
  TOML, properties files) with 3-layer secret exclusion
- Env var default extraction in constant propagation (getEnv, os.environ.get,
  process.env with ||/?? fallback)
- ASYNC_CALLS edge type for Cloud Tasks, Pub/Sub, SQS/SNS, RabbitMQ, Kafka
  dispatch patterns, separate from synchronous HTTP_CALLS
- Tool descriptions updated with all edge types

Other improvements:
- Type inference for method dispatch resolution
- Interface implementation detection (IMPLEMENTS edges)
- Improved tool descriptions for discoverability
2026-02-25 13:43:57 +01:00
Martin Vogel fa444b0ce7 Fix .gitignore to not block cmd/ subdirectory
Anchor the binary ignore pattern to the repo root so it does not
match cmd/codebase-memory-mcp/.
2026-02-25 10:07:23 +01:00
Martin Vogel f63c70865e Initial release: codebase-memory-mcp v0.0.1
MCP server that indexes codebases into a queryable knowledge graph.
Single Go binary, SQLite storage, 12 languages via tree-sitter.

Features: call graph, cross-service HTTP linking, dead code detection,
route nodes, Cypher queries, incremental reindex, JSON config scanning.
2026-02-25 00:10:39 +01:00