Skip to content

hholk/igrep

Repository files navigation

igrep

Local codebase indexing + remote GLM (Z.AI) via OpenAI-compatible API + Claude plugin hooks.

Quick start

  1. Install the Claude plugin by pointing Claude Code to claude-plugin/.
  2. On first session start, the plugin will run scripts/bootstrap.sh.
  3. Set IGREP_API_KEY, then run claude-plugin/scripts/server_up.sh; index updates on file write/edit.

Claude Code Skill

This repo includes a public Claude Code skill at:

claude-code-skill/igrep-claude-code

Install it by copying that folder into your Claude Code skills directory (e.g. ~/.claude/skills/) or by pointing Claude Code at the folder directly.

Optional: Hook Grep -> igrep

If you want Claude Code Grep usage to be routed through igrep, add a PreToolUse hook in your project .claude/settings.local.json. See claude-code-skill/igrep-claude-code/references/claude-hooks.md for the ready-to-paste JSON.

Manual bootstrap:

bash scripts/bootstrap.sh

Manual server start:

export IGREP_API_KEY="<your-zai-key>"
uv run python server/provider_runtime.py --profile glm_47_flash_zai

The Claude plugin helper claude-plugin/scripts/server_up.sh now starts the provider in the background by default (set IGREP_SERVER_BACKGROUND=0 to keep it in the foreground).

Performance eval (MVP)

export IGREP_API_KEY="<your-zai-key>"
uv run python eval/chat_perf.py --model glm-4.7-flash

This prints a simple tokens-per-second stat for a single request.

Search pipeline (overhauled)

Build the hierarchical index (files + section nodes):

uv run igrep index-build

By default this performs a fast, non-LLM pass. If an API key is configured, igrep will spawn a background LLM enrichment build and swap it in once ready. Disable with --no-llm-background or IGREP_LLM_BACKGROUND=0. Use --llm-index to run the LLM pass in the foreground.

Build an index for a different repo root:

uv run igrep index-build --repo-root test-codebase/stitchcraft/backend --store indexer/store/test-backend-fast.sqlite3 --no-llm-index

For new repos with LLM enrichment, igrep asks the LLM which top-level runtime / external dirs to ignore and writes them to indexer/store/llm-runtime-ignores.md. Code is prioritized by default; runtime dirs are only included when explicitly requested:

export IGREP_API_KEY="<your-zai-key>"
IGREP_CODE_ONLY=1 IGREP_PROGRESS=1 \
uv run igrep index-build \
  --repo-root test-codebase/stitchcraft \
  --store indexer/store/test-stitchcraft-llm-code.sqlite3 \
  --llm-index --llm-max-nodes 6

To refresh the LLM-generated ignore list:

IGREP_LLM_IGNORES_REFRESH=1 uv run igrep index-build ...

To include runtime/environment-heavy dirs, set:

IGREP_INCLUDE_RUNTIME=1 uv run igrep index-build ...

Important app dirs (like frontend and backend) are protected from being ignored. You can add more via:

IGREP_PROTECT_DIRS="frontend,backend,packages" uv run igrep index-build ...

To push LLM enrichment up to the provider rate limit, increase concurrency and retries:

IGREP_LLM_CONCURRENCY=16 IGREP_LLM_MAX_RETRIES=8 uv run igrep index-build --llm-index ...

Incrementally update it (fast pass + optional background LLM update):

uv run igrep index-update

Parallelize updates (changed files are processed concurrently):

IGREP_UPDATE_WORKERS=32 uv run igrep index-update

Skip huge directories during indexing (also applied to the RG baseline):

IGREP_EXTRA_IGNORE_DIRS="some-big-dir,another-one" uv run igrep index-build ...

Search with complete section context:

uv run igrep search "bootstrap submodules" --window 1

Target a specific index file (useful for test codebases):

uv run igrep search "createApp" --store indexer/store/test-backend-fast.sqlite3 --no-rlm --limit 0 --window 0

By default, search uses two-stage retrieval (RLM) and no Stage-1 limit. To disable Stage 2 and use only the index:

uv run igrep search "bootstrap submodules" --no-rlm --limit 0

Two-stage search with RLM (Stage 1 index + Stage 2 refinement, run in parallel):

export IGREP_API_KEY="<your-zai-key>"
uv run igrep search "bootstrap submodules" --rlm --model glm-4.7-flash --max-iterations 8 --rlm-timeout 15 --seed-limit 8

Mismatch-first view (RG vs. index differences “in your face”):

export IGREP_API_KEY="<your-zai-key>"
uv run igrep search "mySymbol" --rlm --model glm-4.7-flash --mismatch-only --rlm-timeout 15

Symbol / Dependency View

Line-based hits are now part of the index (symbols, refs, imports, calls, line hits) and are mapped back to PageIndex nodes for compact context.

Find where a symbol is used:

uv run igrep uses build_index

Show dependencies for a file or symbol:

uv run igrep deps indexer/tree_index.py
uv run igrep deps build_index

These default to a thin output (no full context blocks). If your project needs noise filtering, set IGREP_NOISE_PREFIXES (or a noise-prefixes.md file) and the skill will enable it. Add --context for larger context, and --window to include neighbor sections. Use --include-noise to override the filter.

LLM-Enriched Index (Optional)

Run LLM enrichment in the foreground (blocking) for better titles, summaries, and tags:

export IGREP_API_KEY="<your-zai-key>"
IGREP_LLM_INDEX_MAX_NODES=8 uv run igrep index-build --llm-index

You can also use it on update:

export IGREP_API_KEY="<your-zai-key>"
uv run igrep index-update --llm-index --llm-max-nodes 6

To disable background LLM processing entirely:

IGREP_LLM_BACKGROUND=0 uv run igrep index-build

PageIndex Thinning (Markdown)

Markdown sections are parsed with PageIndex and then token-thinned to reduce section count while keeping context. Tune the minimum token budget per node:

IGREP_PAGEINDEX_MIN_TOKENS=160 uv run igrep index-build

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors