logs.gokuls.in

4 pull requests merged across 1 repo

bahdotsh/indxr

  • Add get_type_flow MCP tool that tracks where types flow across function boundaries — shows which functions produce (return) and consume (accept as parameters) a given type
  • Language-aware type extraction from signatures for Rust, Go, TS/JS, Python, Java/Kotlin/C#, and Swift
  • Query-time analysis with no data model or cache changes — same O(declarations) scan pattern as get_callers
  • Supports path filter, include_fields, limit, and compact columnar output

Test plan

  • 13 unit tests for per-language type extraction (Rust, Go, TS, Python, Java, Kotlin, Swift, Ruby, edge cases)
  • 8 integration tests for the tool (producers, consumers, case-insensitivity, compact, path filter, limit, error handling)
  • Tool count assertion updated (21 → 22)
  • cargo fmt and cargo clippy clean
  • All 249 tests pass
  • Add indxr diff --pr <N> CLI command that resolves a GitHub PR's base branch via the API, then runs the existing structural diff pipeline — showing added/removed/modified declarations without reading raw diffs
  • Extend the MCP get_diff_summary tool with an optional pr parameter so AI agents can diff PRs without knowing the base ref
  • Add src/github.rs module: thin GitHub API client handling token auth (GITHUB_TOKEN/GH_TOKEN/gh CLI fallback), remote URL parsing (HTTPS + SSH), and PR metadata fetching via ureq

Test plan

  • cargo build — compiles cleanly (one expected warning for PrInfo.state field reserved for future use)
  • cargo test — all 214 tests pass, including 6 new URL parsing tests in github.rs
  • Manual: indxr diff --pr <N> against a real PR in a GitHub-hosted repo
  • Manual: indxr diff --since main via the new subcommand (parity with global --since flag)
  • Manual: verify error messages for missing token, non-GitHub remote, invalid PR number
  • Manual: MCP get_diff_summary with {"pr": 7} via indxr serve
  • Adds per-function complexity metrics (cyclomatic complexity, max nesting depth, parameter count) using tree-sitter AST analysis across all 8 tree-sitter languages (Rust, Python, TS, JS, Go, Java, C, C++)
  • New get_hotspots MCP tool returns top N most complex functions ranked by composite score, with path filtering, sort options, and compact mode
  • New get_health MCP tool returns aggregate codebase health metrics (avg/median/p90 complexity, documentation %, test count, hottest files)
  • New --hotspots CLI flag outputs a formatted complexity table to stdout

Design

  • Complexity is computed as a post-processing pass in src/parser/complexity.rs after extraction — zero changes to any of the 8 language extractors
  • ComplexityMetrics is an Option field on Declaration with #[serde(default)] for full backward compatibility
  • Per-language branch node tables cover: if/else, loops, match/switch arms, &&/||/??, catch, ternary
  • Cache version bumped from 2 → 3 (one-time re-parse on upgrade)

Test plan

  • 7 new unit tests in complexity.rs covering Rust, Python, Go, C, and bodyless declarations
  • Tool definition count test updated (19 → 21)
  • All 188 tests pass
  • cargo clippy -- -D warnings clean
  • cargo fmt clean
  • indxr --hotspots verified on indxr's own codebase — produces reasonable rankings
  • --filter-path scoping verified
  • indxr init now auto-detects RTK on PATH and configures its PreToolUse hooks alongside indxr's existing hooks
  • Writes .claude/hooks/rtk-rewrite.sh (executable) that delegates to rtk rewrite with proper exit code handling (rewrite/deny/ask/passthrough)
  • Settings.json gains a third PreToolUse entry for RTK's Bash command rewriting, placed before indxr's git-diff reminder hook
  • CLAUDE.md, .cursorrules, and .windsurfrules get an RTK awareness section when detected
  • --no-rtk flag to skip RTK setup; --no-hooks continues to skip all hooks as before
  • Graceful degradation: silently skips if rtk/jq not on PATH, no new dependencies added

Motivation

indxr saves tokens on the code-reading side (MCP tools instead of full file reads), but raw shell command output (git, cargo test, npm, etc.) is the other major token sink. RTK compresses that output by 60-90%. Together they cover both sources of context waste, and indxr init becomes the single setup command for both.

Test plan

  • cargo build compiles cleanly
  • cargo test — all 181 tests pass (8 new tests for RTK integration)
  • Manual: indxr init --claude with rtk installed → verify .claude/hooks/rtk-rewrite.sh created + executable, settings.json has 3 PreToolUse entries
  • Manual: indxr init --claude without rtk → verify silent skip, settings.json has 2 entries
  • Manual: indxr init --claude --no-rtk with rtk installed → verify rtk skipped
  • Manual: indxr init --claude --no-hooks → no settings.json or hook script created