Skip to main content

igrep

igrep 为 Agent 在本地代码和文档里检索证据,结果可定位到文件和行。普通文本无需先建索引。公开 Web 与内部源也有各自的检索入口。

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

安装

公开 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。

安装需要目标平台的 Python 3.14 原生 wheel。Linux amd64 wheel 以 glibc 为基线。

选择 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 index build ~/Documents --full       # 在本进程运行档位允许且已配置的模型车道
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。后台准备需要先注册项目。词法索引在有效维护租约下只为 ripgrep 提名文件。档位见 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 auto               # 按源内容自动选源,回执列出下一批候选
igrep isearch "支付失败如何重试" --source team-docs        # 换成 source list 中的来源 ID

内部源有两种接入方式:任何能输出 JSONL 命中的 CLI 用 command-backed source 桥接,单文件 Python 插件实现 igrep.plugin_api 的 Source 契约。安装插件必须用 3–5 条真实查询通过资质验证:

igrep source cmd check --cmd '<输出 JSONL 的命令>'           # 校验协议(查询经 $IGREP_QUERY 传入)
igrep source cmd add team-wiki --cmd '<输出 JSONL 的命令>'   # 之后 igrep isearch "…" -s team-wiki
igrep source plugin test my_source.py --queries 词1,词2,词3  # 先看资质验证结果
igrep source plugin install my_source.py --queries 词1,词2,词3

JSONL 字段见 igrep source cmd --help;插件契约与插件配置见内部搜索插件指南。

接入编码 Agent

igrep setup claude-code      # MCP(semantic_search)+ CLI skill + CLAUDE.md 路由块 + SessionStart hook
igrep setup codex            # 同类组合,写 ~/.codex/config.toml、~/.agents/skills/{igrep,igrep-deep-research}、~/.codex/AGENTS.md

MCP server 是 igrep-mcp,本地检索只暴露一个工具 semantic_search;agent toolset 在配置了 Web provider 或内部源时再追加 web_search 与 isearch。只装其中一部分时:

igrep mcp install --target cursor --scope project   # 只注册 MCP;--toolset code|repo|agent 显式选工具集
igrep skill install --target claude                 # 只装 CLI skill(教 Agent 何时、如何调用 igrep 命令)
igrep skill render --format agents-md >> AGENTS.md  # 其他宿主:渲染路由块或 SKILL.md

各平台的命令、默认工具集、写入位置与宿主记忆接入见 Agent 安装指南。

按名字查定义和引用用宿主的 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                  # 模型随时按问题检索

宿主通过 wake 注入笔记和遗忘约束。单用户用 workspace 隔离,多用户按 --store ROOT --user U [--tenant T] 寻址。Pi、DeepSeek Harness、Hermes、OpenClaw 已有现成插件,由 igrep setup <宿主> 安装(见 Agent 安装指南);自己接入笔记、遗忘与可选的 Dream 见 记忆宿主接入指南,存储模型见记忆设计。

管理台与项目

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;对外监听时的鉴权见管理生命周期规范。

配置

把自管端点写入 ~/.igreprc/.env。以下示例使用同一个 HTTP 服务。

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.170

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.170
File Interpreter ABI Platform Actions
igrep2-0.1.170-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.170-cp314-cp314-manylinux_2_28_x86_64.whl
igrep2-0.1.170-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for igrep2-0.1.170-cp314-cp314-macosx_11_0_arm64.whl

Total release size: 57.0 MB

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

Download URL igrep2-0.1.170-cp314-cp314-manylinux_2_28_x86_64.whl
Size 32.6 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0c4bee6829c1c837c251468ab739f3543b8cd67a576c48d223fe0a71325b5170
BLAKE2b-256 checksum
How to use checksums
ed4e216cfd1810bf60609e1cf3c6c8d53c41febe3fede3cab8c41ec645bd84f0
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.170-cp314-cp314-macosx_11_0_arm64.whl

Download URL igrep2-0.1.170-cp314-cp314-macosx_11_0_arm64.whl
Size 24.3 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d734b588377e0902f313350cbe60e7fb0ac7d7d809f7ede390a64f9866e29d80
BLAKE2b-256 checksum
How to use checksums
b04a2f0f6f93c8ccbe4d83a1d91c8704be55d8120df26e53a31daa0ca9058a16
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.170

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