mgrep-code-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemgrep Code Search
mgrep代码搜索
Overview
概述
mgrep is a semantic search tool that enables natural language queries across code, text, PDFs, and images. It is particularly effective for exploring larger or complex codebases where traditional pattern matching falls short.
mgrep是一款语义搜索工具,支持对代码、文本、PDF和图片进行自然语言查询。在探索大型或复杂代码库时,它的表现尤为出色,而传统的模式匹配工具在这类场景中往往力有不逮。
When to Use This Skill
何时使用该技能
Use mgrep when:
- The codebase contains more than 30 non-gitignored files
- There are nested directory structures
- Searching for concepts, features, or intent rather than exact strings
- Exploring an unfamiliar codebase
- Need to understand "where" or "how" something is implemented
Use traditional grep/ripgrep when:
- Searching for exact patterns or symbols
- Regex-based refactoring
- Tracing specific function or variable names
在以下场景使用mgrep:
- 代码库包含30个以上未被git忽略的文件
- 存在嵌套目录结构
- 搜索概念、功能或意图,而非精确字符串
- 探索不熟悉的代码库
- 需要了解某项功能的“实现位置”或“实现方式”
在以下场景使用传统grep/ripgrep:
- 搜索精确模式或符号
- 基于正则表达式的重构
- 追踪特定函数或变量名称
Quick Start
快速开始
Indexing
索引
Before searching, start the watcher to index the repository:
bash
bunx @mixedbread/mgrep watchThe command indexes the repository and maintains synchronisation with file changes. It respects and patterns.
watch.gitignore.mgrepignore搜索前,启动观察器以索引代码库:
bash
bunx @mixedbread/mgrep watchwatch.gitignore.mgrepignoreSearching
搜索
bash
bunx @mixedbread/mgrep "your natural language query" [path]bash
bunx @mixedbread/mgrep "你的自然语言查询" [路径]Search Commands
搜索命令
Basic Search
基础搜索
bash
bunx @mixedbread/mgrep "where is authentication configured?"
bunx @mixedbread/mgrep "how do we handle errors in API calls?" src/
bunx @mixedbread/mgrep "database connection setup" src/libbash
bunx @mixedbread/mgrep "认证配置在哪里?"
bunx @mixedbread/mgrep "我们如何处理API调用中的错误?" src/
bunx @mixedbread/mgrep "数据库连接设置" src/libSearch Options
搜索选项
| Option | Description |
|---|---|
| Maximum results (default: 10) |
| Display full result content |
| Generate AI-powered synthesis of results |
| Update index before searching |
| Disable relevance optimisation |
| 选项 | 描述 |
|---|---|
| 最大结果数(默认:10) |
| 显示完整结果内容 |
| 生成AI驱动的结果摘要 |
| 搜索前更新索引 |
| 禁用相关性优化 |
Examples with Options
带选项的示例
bash
undefinedbash
undefinedGet more results
获取更多结果
bunx @mixedbread/mgrep -m 25 "user authentication flow"
bunx @mixedbread/mgrep -m 25 "用户认证流程"
Show full content of matches
显示匹配结果的完整内容
bunx @mixedbread/mgrep -c "error handling patterns"
bunx @mixedbread/mgrep -c "错误处理模式"
Get an AI-synthesised answer
获取AI生成的摘要答案
bunx @mixedbread/mgrep -a "how does the caching layer work?"
bunx @mixedbread/mgrep -a "缓存层如何工作?"
Sync index before searching
搜索前同步索引
bunx @mixedbread/mgrep -s "payment processing" src/services
undefinedbunx @mixedbread/mgrep -s "支付处理" src/services
undefinedWorkflow
工作流程
-
Start watcher (once per session or when files change significantly):bash
bunx @mixedbread/mgrep watch -
Search semantically:bash
bunx @mixedbread/mgrep "what you're looking for" [optional/path] -
Refine as needed using path constraints or options:bash
bunx @mixedbread/mgrep -m 20 -c "refined query" src/specific/directory
-
启动观察器(每次会话启动一次,或在文件大幅变更时启动):bash
bunx @mixedbread/mgrep watch -
进行语义搜索:bash
bunx @mixedbread/mgrep "你要查找的内容" [可选/路径] -
根据需要优化:使用路径约束或选项:bash
bunx @mixedbread/mgrep -m 20 -c "优化后的查询" src/specific/directory
Environment Variables
环境变量
Configure defaults via environment variables:
| Variable | Purpose |
|---|---|
| Default result limit |
| Enable content display (1/true) |
| Enable AI synthesis (1/true) |
| Pre-search sync (1/true) |
可通过环境变量配置默认值:
| 变量 | 用途 |
|---|---|
| 默认结果限制数 |
| 启用内容显示(1/true) |
| 启用AI摘要生成(1/true) |
| 搜索前同步索引(1/true) |
Important Notes
重要说明
- Always use to run commands (not npm/npx or direct installation)
bunx @mixedbread/mgrep - Run before searching to ensure the index is current
bunx @mixedbread/mgrep watch - mgrep respects patterns automatically
.gitignore - Create for additional exclusions
.mgrepignore
- 请始终使用运行命令(不要使用npm/npx或直接安装)
bunx @mixedbread/mgrep - 搜索前运行以确保索引是最新的
bunx @mixedbread/mgrep watch - mgrep会自动遵循规则
.gitignore - 可创建文件添加额外的排除规则
.mgrepignore