Skip to main content

igrep

面向 Agent 的 filesystem-native retrieval kernel。

igrep 直接在本地代码和文档上做自然语言检索,不需要预建向量索引;返回可定位到文件和行号的证据,也可以继续生成带引用的研究回答。CLI、MCP、Web 管理台和编辑器集成复用同一套检索语义。

igrep search "鉴权失败后在哪里重试" ~/code/my-project
igrep ask "这个项目如何加载配置?" ~/code/my-project

它解决什么问题

  • 代码与文档检索:自然语言查询、文件类型和 glob 过滤、git diff 范围、结构化输出。
  • 无需向量索引:文本和代码直接搜索;PDF、Office 文档和图片按需预处理成项目派生存储里的隐藏文本。
  • Agent 原生接入:为主流编码 Agent 提供一键配置;精确符号导航交给宿主自己的 rg 和原生 LSP。
  • 多种证据源:本地文件、公开 Web、单个公开文档、内部搜索源和已授权网站各自保持清晰边界,不做隐式联邦融合。
  • Local-first:可使用 Apple Silicon 上的本地 oMLX,也可连接自管或云端的 OpenAI-compatible 服务。

igrep 不是通用 RAG 平台。igrep search 是主入口;ask、dig 和 chat 在检索证据之上工作;serve 是本机管理与 host 层,不改变检索语义。

安装

公开 distribution 是 igrep2,安装后的命令和 import 仍是 igrep。需要 Python 3.14。

uv tool install --python 3.14 igrep2    # 推荐:隔离的 uv tool 环境
igrep --version
igrep upgrade                           # 升级已有安装

也可以安装到已有的 Python 3.14 环境:python3.14 -m pip install igrep2。

发行包是按系统和 CPU 构建的原生 wheel,不发布核心实现源码或 sdist;目标平台需要有对应 wheel,安装核心无需 Nuitka 或 C 编译器,第三方依赖按各自的平台支持安装。Linux amd64 使用 manylinux / glibc,不覆盖 Alpine / musl。组织可以用自己的 setup bundle 批量安装内部 source 插件与 Web provider 扩展;igrep2 本身不依赖任何此类 bundle。

选择 AI runtime

场景 命令 说明
自管、外部或云端 OpenAI-compatible 端点 igrep setup 安装轻量系统依赖并创建配置模板,不安装本地模型;端点写进 ~/.igreprc/.env,见配置
Apple Silicon 全本地 igrep setup local 安装或复用 oMLX,下载默认模型并配置本地端点

完成后用 igrep doctor 检查能力状态。它默认只报告问题;CI 或安装脚本需要非零退出码时加 --strict。

5 分钟上手

搜本地代码和文档

igrep search "配置在哪里加载"                          # 当前目录
igrep search "重试策略" ~/code/my-project --type py    # 指定目录和文件类型
igrep search "鉴权逻辑" . -g 'src/**' -g '!**/test_*'  # rg 风格 glob,! 表示排除
igrep search "可能破坏兼容性的改动" . --diff           # 只搜相对 HEAD 的 git 变更文件
igrep search "错误处理" . --format json                # 程序消费:单个 JSON document(jsonl 为逐行)
git diff | igrep search "潜在回归" --stdin-format git  # 搜 Unix pipe 进来的内容

全部选项见 igrep search --help;stdout、退出码与机器输出见 CLI 进程契约。

选择检索强度

模式 适合场景 行为
fast 高频本地检索 本地关键词规划,不调用 LLM 做查询扩展;可使用已配置的 reranker 与 decision judge
normal 日常使用,默认值 增加有界的 query-time LLM 扩展和最终排序
ultra 多跳或复杂问题 增加第二轮证据反馈与 LLM 最终排序,成本和延迟更高
igrep search "请求从入口到持久化的完整流程" . --mode ultra

模式只调整质量、延迟和远端调用量,不改变输出协议。缺少可选后端时,对应通道关闭,基础文件检索仍保留。

搜索后继续研究

igrep ask "配置优先级是什么?" .                # 单次、有界、带引用的回答
igrep dig "一次搜索请求经过哪些模块?" .        # 分阶段深度研究,stdout 只有最终答案
igrep chat                                      # 交互式多轮 REPL

多格式文件

代码、Markdown 和普通文本无需准备即可搜索。PDF、Office、EPUB 等文档要先转换,图片内容还需要 OCR/VLM:

igrep index build ~/Documents              # 转换后立即可搜;向量与图片描述交给 igrep serve(需 igrep project add)
igrep index build ~/Documents --full       # 在本进程跑完向量与 OCR/VLM 再返回
igrep prepare report.pdf --only convert    # 单文件或单阶段
igrep status ~/Documents                   # 准备欠账与存储占用
igrep clean ~/Documents --unserved         # 只删孤儿和被忽略文档的条目(预览,--yes 才删)
igrep store trust ~/Documents              # 信任从别的机器克隆或同步来的派生存储

派生产物写进项目的 .igrep/derived/(自带 ignore 文件,git status 看不到),不修改源目录和用户原始 Markdown,之后仍用普通的 igrep search 查询。$HOME 及其祖先不当项目根,此时先 igrep init <dir>。

每个根准备到哪一步由档位 IGREP_INDEX_LEVEL 决定(none < lexical < vectors < augment,默认 augment;igrep index build --level 写入项目 .igrep/.env),搜索在每一档、每个阶段建到一半时都可用。词法 store 只为 rg 提名文件,结果与无 store 时相同;igrep index build 负责构建,igrep serve 维护新鲜度,没有有效维护租约时走 rg 全扫。档位含义见 igrep index build --help,命令边界见 CLI 进程契约 §1.1。

Web、内部源与网站源

igrep setup web-search                                     # 配置 SearXNG / Tavily / Serper / Exa 等 provider
igrep web-search "Python 3.14 release notes"
igrep web-dig "比较 Python 3.13 与 3.14 的并发变化"
igrep page-search https://example.com/spec.pdf "timeout policy"   # 在调用方给定的一个公开文档内找证据

igrep source list                                          # 查看已配置的内部只读 source
igrep isearch "支付失败如何重试" --source <installed-plugin-source>

igrep isearch 还支持单文件 Python 插件和 command-backed source;安装插件前必须用 3–5 条真实查询通过资质验证,协议见内部搜索插件指南。

只有你登录后的 Chrome 才能搜到的网站(公司 wiki、内网工具、个人账号应用)用网站源:它借用已登录的浏览器身份,把站点自己的搜索变成 isearch 来源。公开内容走 web-search,有 API/token 的系统写插件。

igrep serve start
igrep setup chrome
igrep source site list
igrep isearch "query" --site <source-id>

网站源只重放用户审核并启用的搜索请求,不跟随结果 URL 抓取正文,也不保存 cookie/token。网站改版导致搜索失效时,失败信息会给出修复命令(igrep source site repair)。上手与修复流程见网站搜索源指南。

接入编码 Agent

igrep setup claude-code     # 同样:codex codebuddy workbuddy opencode cursor gemini copilot pi deepseek-harness
igrep setup openclaw --flavor search
igrep setup hermes --enable-plugin

各平台的接入面、替换宿主 memory 的显式选项、体检与回报流程见 Agent 安装指南。

Claude Code 和 Codex 默认使用窄的 code toolset,只有 semantic_search;其余 MCP 宿主默认 agent toolset,按配置追加 web 与 isearch;repo 可显式选择。igrep 不提供符号 / LSP 导航:按名字查定义和引用用宿主的 rg,按光标的语义导航用宿主原生 LSP。

Agent 记忆

igrep mem 是给 Agent 宿主用的 file-backed 记忆,存在 <workspace>/.igrep/mem:

igrep mem ingest --workspace ~/agent-ws --transcript turns.jsonl --session-id s1   # 增量、只追加,不必每轮调
igrep mem maintain --workspace ~/agent-ws                                          # 维护派生视图、处理遗忘
igrep mem wake --workspace ~/agent-ws --format markdown                            # session 开始读取记忆上下文
igrep mem recall "用户偏好什么 Python 工具" --workspace ~/agent-ws                  # 模型随时按问题检索

用户 profile 默认关闭;IGREP_MEM_PROFILE=1 让 maintain 抽取并发布供 wake 读取的 profile,关闭后由下一次 maintain 清理用户信息卡。Agent 自己保存的记忆由 igrep mem record 写入 MEMORY.md。

workspace 目录就是隔离单元。一个 agent 服务很多人时,用 --store ROOT --user U [--tenant T] 代替 --workspace。现成接入见 Agent 安装指南,自己的宿主按记忆宿主接入指南接入。

管理台与项目

igrep project add ~/code/my-project
igrep serve run      # 前台运行;后台用 igrep serve start / status / stop
igrep serve open     # 在浏览器中打开 Web UI

serve 是唯一管理入口,提供项目、搜索、聊天、后端状态和诊断界面;igrep serve install 注册为 OS service。本机 Web UI 直接访问 http://127.0.0.1:16800,无需 token;对外监听时的鉴权见管理生命周期规范。

配置

优先级从高到低:

  1. 当前进程的 IGREP_* 环境变量
  2. <project>/.igrep/.env
  3. ~/.igreprc/.env
  4. OPENAI_*(只作为 LLM fallback,OPENAI_API_KEY 是激活锚点;embedding、rerank 和 OCR 不读取)
  5. 代码默认值

连接自管端点的最小示例:

IGREP_EMBEDDING_URL=http://localhost:8000/v1
IGREP_EMBED_MODEL=your-embedding-model

IGREP_LLM_URL=http://localhost:8000/v1
IGREP_LLM_MODEL=your-chat-model

IGREP_RERANK_URL=http://localhost:8000/v1
IGREP_RERANK_MODEL=your-reranker

凭证只放环境变量或 .env,不要写入 profile 或提交到仓库。IGREP_API_KEY 是全局 fallback,能力级 IGREP_*_API_KEY 可单独覆盖。

能力矩阵、凭证规则、显式空值语义、ask / final-sort 路由、图片向量与网关设置见本地服务协议;带注释的配置模板是 env.sample。

文档

License

MIT

Metadata

Release files for igrep2 0.1.166

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for igrep2 0.1.166
File Interpreter ABI Platform Actions
igrep2-0.1.166-cp314-cp314-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64 Details for igrep2-0.1.166-cp314-cp314-manylinux_2_28_x86_64.whl
igrep2-0.1.166-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for igrep2-0.1.166-cp314-cp314-macosx_11_0_arm64.whl

Total release size: 61.2 MB

Release files / igrep2-0.1.166-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL igrep2-0.1.166-cp314-cp314-manylinux_2_28_x86_64.whl
Size 35.0 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
271137c54664c0b7750181632cfa3f656f51fc42d78d3e7d7f8f5a335d07c48b
BLAKE2b-256 checksum
How to use checksums
3cbd7f423afc1c990cdb3cd1707ad96cc74513167bd82468f955d94b5a258679
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / igrep2-0.1.166-cp314-cp314-macosx_11_0_arm64.whl

Download URL igrep2-0.1.166-cp314-cp314-macosx_11_0_arm64.whl
Size 26.2 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aa78ace382d0c391acf85cd5444ec7c6d245ea038a3f1e5544043bd9327d3cbd
BLAKE2b-256 checksum
How to use checksums
6c383ff65263b214971befa2c7e8aadd332dc0c9c32c62e7e1d2cf5a355c8ad2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for igrep2 0.1.166

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page