logs.gokuls.in

5 pull requests merged across 1 repo

bahdotsh/indxr

  • New src/dep_graph.rs module with heuristic import resolution across languages (Rust crate::, JS/TS relative .//../, Python dot-paths, generic segment matching)
  • File-level graph: resolves imports to indexed files, builds file-to-file dependency edges with deduplication and path scoping
  • Symbol-level graph: edges from extends/implements relationships + word-boundary signature matching for type references
  • Output formats: DOT (Graphviz), Mermaid (renders in GitHub markdown), and JSON
  • MCP tool get_dependency_graph with params: path (scope), level (file/symbol), format (dot/mermaid/json), depth (hop limit)
  • CLI flag --graph [dot|mermaid] combinable with --filter-path for scoped output
  • 24 new tests (18 unit + 6 MCP integration), 0 clippy warnings

Usage

# CLI
indxr --graph mermaid                          # full codebase mermaid graph
indxr --graph dot --filter-path src/mcp        # scoped DOT graph
indxr --graph mermaid -o deps.md               # write to file

# MCP tool
get_dependency_graph { "format": "mermaid" }
get_dependency_graph { "path": "src/mcp", "level": "symbol", "format": "dot" }
get_dependency_graph { "format": "json", "depth": 2 }

Test plan

  • cargo test — 146 tests pass (24 new)
  • cargo clippy — 0 warnings
  • Self-tested on the indxr codebase with --graph mermaid and --graph dot --filter-path src/mcp — produces accurate dependency graphs
  • Verify MCP tool via indxr serve and calling get_dependency_graph with various params
  • Add indxr watch standalone command that monitors source files and auto-regenerates INDEX.md on changes
  • Add --watch flag to indxr serve for MCP server auto-reindexing without agents calling regenerate_index
  • Refactor MCP server loop from blocking stdin to channel-based event loop (ServerEvent enum) to support concurrent stdin + watcher events
  • Uses notify + notify-debouncer-mini (300ms default debounce) — no async runtime, stays fully synchronous with threads/channels
  • Lightweight pre-filter skips INDEX.md, cache dir, hidden files, and non-source files to avoid spurious rebuilds
  • 6 new unit tests for the trigger filter logic

Usage

# Standalone watch mode
indxr watch ./project              # watches and updates INDEX.md
indxr watch ./project -o out.md    # custom output path
indxr watch --debounce-ms 500      # custom debounce

# MCP server with auto-reindex
indxr serve --watch ./project      # MCP + file watching

Test plan

  • cargo build — compiles cleanly
  • cargo test — all 115 tests pass (including 6 new watch tests)
  • cargo clippy — no warnings
  • cargo fmt — clean
  • Manual: indxr watch . → edit a .rs file → verify INDEX.md updates with "Change detected" on stderr
  • Manual: indxr serve --watch . → verify MCP tools work normally + auto-reindex on file changes
  • Adds indxr init subcommand that scaffolds all configuration files for AI agent integration in a single command
  • Supports Claude Code (--claude), Cursor (--cursor), Windsurf (--windsurf), or all at once (default)
  • Generates MCP configs, agent instruction files (CLAUDE.md, .cursorrules, .windsurfrules), PreToolUse hooks, INDEX.md, and .gitignore entry
  • Safe by default: skips existing files with a warning, --force to overwrite
  • Includes 17 unit tests covering templates, file conflict handling, and gitignore logic
  • Updates all documentation: README, CLAUDE.md, CLI reference, agent integration guide, MCP server docs

Files created per agent

FlagFiles
--claude.mcp.json, CLAUDE.md, .claude/settings.json
--cursor.cursor/mcp.json, .cursorrules
--windsurf.windsurf/mcp.json, .windsurfrules
Always.gitignore (append), INDEX.md (unless --no-index)

Usage

indxr init                          # all agents
indxr init --claude                 # Claude Code only
indxr init --cursor --windsurf      # Cursor + Windsurf
indxr init --no-index --no-hooks    # skip INDEX.md and hooks
indxr init --force                  # overwrite existing files

Test plan

  • cargo build compiles without errors
  • cargo test — all 109 tests pass (17 new init tests)
  • Manual smoke test: indxr init --claude --no-index in temp directory creates expected files
  • Re-running indxr init skips existing files with correct warnings
  • Verify indxr init with INDEX.md generation on a real project
  • Verify generated .mcp.json works with indxr serve
  • Split the 2,387-line src/mcp.rs into a src/mcp/ module tree with 4 focused files:
  • mod.rs (192 lines) — JSON-RPC types, protocol handlers, server loop
  • helpers.rs (831 lines) — extracted utility functions (compile_glob_matcher, split_identifier, bigram_similarity, collapse_nested_bodies, contains_word_boundary, is_compact, serialize_compact, to_compact_rows, etc.), types (SymbolMatch, SignatureMatch, ShallowDeclaration, RelevanceMatch), and constants
  • tools.rs (1,467 lines) — tool definitions, dispatcher, and all 18 tool implementations
  • tests.rs (1,196 lines) — all unit and integration tests
  • No functional changes — pure structural refactor
  • Addresses review feedback from PR #1 about file size and helper extraction

Test plan

  • cargo build compiles with zero warnings
  • All 93 tests pass (cargo test)
  • Public API unchanged (mcp::run_mcp_server is the only export)

Adds 13 token-saving features to the MCP server, growing it from 12 to 18 tools. All changes are additive and backward-compatible.

6 New Tools

  • get_diff_summary — Structural diff against a git ref (branch/tag/commit). Shows added/removed/modified declarations instead of raw diffs. Reuses existing diff.rs engine.
  • batch_file_summaries — Summarize multiple files in one call via paths array or glob pattern (cap: 30 files). Eliminates 5-10 sequential get_file_summary round-trips.
  • get_callers — Find who references a symbol by searching imports and signatures across all files. Approximate but far cheaper than agents grepping manually.
  • get_public_api — Public API surface of a file or directory. Only public declarations with signatures — no bodies, no privates, no counts.
  • explain_symbol — Full interface metadata (signature, doc comment, relationships, async/test/deprecated flags) without reading body source.
  • get_related_tests — Find test functions for a symbol by naming convention (test_*, *_test, etc.) and file association.

7 Enhancements to Existing Tools

  • read_source — New symbols: [...] array for multi-symbol reads (500 line cap) and collapse: true to fold nested block bodies to { ... }
  • search_relevant — New kind: "fn" filter and improved scoring with camelCase/snake_case-aware identifier splitting + bigram fuzzy fallback
  • get_token_estimate — New directory/glob params for bulk token estimation across file sets
  • regenerate_index — Now delta-aware: returns changes field showing files added/removed/modified
  • lookup_symbol, list_declarations, search_signatures, search_relevant — New compact: true param for columnar {columns, rows} output (~30% token savings)

Shared Helpers Added

simple_glob_match, split_identifier, bigram_similarity, collapse_nested_bodies, to_compact_rows, collect_public_decls, find_tests_for_symbol, explain_decl

Test plan

  • cargo build — compiles cleanly
  • cargo test — all 37 tests pass (28 existing + 9 new/updated)
  • New tests: test_score_match_camel_case_aware, test_split_identifier, test_simple_glob_match
  • Updated tests: score_match expectations adjusted for identifier-part scoring, tool count updated to 18
  • INDEX.md regenerated
  • CLAUDE.md updated with new tools in exploration workflow and token savings table