SuperAPI AI 工具集

grepai-quickstart

编程与开发

查看项目

更新于 10-15 18:08

技能介绍

GrepAI Quickstart 是一份完整的从安装到首次搜索的操作指引,目标是在 5 分钟内让 GrepAI 运行起来并开始检索代码。

一、用途与适用时机 该技能适用于以下场景:第一次使用 GrepAI;需要快速复习基本工作流;在新项目中配置 GrepAI;向他人演示 GrepAI。

二、前置条件 需要具备终端访问权限;需要有一个用于索引的代码项目。

三、安装 GrepAI macOS: brew install yoanbernabeu/tap/grepai

Linux/macOS(替代方式): curl -sSL https://raw.githubusercontent.com/yoanbernabeu/grepai/main/install.sh | sh

Windows: irm https://raw.githubusercontent.com/yoanbernabeu/grepai/main/install.ps1 | iex

验证安装:grepai version

四、安装 Ollama(本地嵌入) macOS: brew install ollama ollama serve & ollama pull nomic-embed-text

Linux: curl -fsSL https://ollama.com/install.sh | sh ollama serve & ollama pull nomic-embed-text

验证:curl http://localhost:11434/api/tags

五、初始化项目 进入项目目录并初始化: cd /path/to/your/project grepai init

该命令会创建 .grepai/config.yaml,默认设置包括:以 Ollama 作为嵌入提供方、使用 nomic-embed-text 模型、GOB 文件存储、标准忽略规则。

六、开始索引 启动 watch 守护进程来索引代码: grepai watch

执行过程:扫描所有源文件(遵循 .gitignore);将代码按约 512 token 分块;通过 Ollama 生成嵌入;将向量存入 .grepai/index.gob。

首次索引输出示例: 🔍 GrepAI Watch Scanning files... Found 245 files Processing chunks... ████████████████████████████████ 100% Indexed 1,234 chunks Watching for changes...

后台模式(适合长期运行的项目): 启动后台运行:grepai watch --background 查看状态:grepai watch --status 停止:grepai watch --stop

七、搜索代码 支持语义化搜索: 基础搜索:grepai search "authentication flow" 限制结果数量:grepai search "error handling" --limit 5 JSON 输出(供脚本使用):grepai search "database queries" --json

输出示例(含匹配分数、文件位置与代码片段): Score: 0.89 | src/auth/middleware.go:15-45 ────────────────────────────────────────── func AuthMiddleware() gin.HandlerFunc { return func(c *gin.Context) { token := c.GetHeader("Authorization") if token == "" { c.AbortWithStatus(401) return } // Validate JWT token... } }

Score: 0.82 | src/auth/jwt.go:23-55 ────────────────────────────────────────── func ValidateToken(tokenString string) (*Claims, error) { token, err := jwt.Parse(tokenString, func(t *jwt.Token) (interface{}, error) { return []byte(secretKey), nil }) // ... }

八、分析调用图(可选) 追踪函数关系: 查找调用者:grepai trace callers "Login" 查找被调用者:grepai trace callees "ProcessPayment" 完整依赖图:grepai trace graph "ValidateToken" --depth 3

九、完整工作流汇总

  1. 安装(一次): brew install yoanbernabeu/tap/grepai brew install ollama && ollama serve & && ollama pull nomic-embed-text

  2. 项目设置(每个项目一次): cd /your/project grepai init

  3. 索引(后台运行): grepai watch --background

  4. 搜索(按需): grepai search "your query here"

  5. 追踪(按需): grepai trace callers "FunctionName"

十、命令速查

  • grepai init:初始化项目配置
  • grepai watch:启动索引守护进程
  • grepai watch --background:后台运行守护进程
  • grepai watch --status:查看守护进程状态
  • grepai watch --stop:停止守护进程
  • grepai search "query":语义搜索
  • grepai search --json:JSON 输出
  • grepai trace callers "fn":查找调用者
  • grepai trace callees "fn":查找被调用者
  • grepai status:索引统计信息
  • grepai version:显示版本

十一、搜索技巧 描述性而非字面化: ✅ "user authentication and session management" ❌ "auth"

描述意图: ✅ "where errors are logged to the console" ❌ "console.error"

使用英文:模型主要以英文文本训练,英文查询效果最佳。

十二、后续步骤 掌握基础后,可进一步查阅:grepai-embeddings-* 配置嵌入、grepai-storage-* 配置存储、grepai-search-* 高级搜索、grepai-mcp-* MCP 集成。

十三、成功输出示例 ✅ GrepAI Quickstart Complete

Project: /path/to/your/project Files indexed: 245 Chunks created: 1,234 Embedder: Ollama (nomic-embed-text) Storage: GOB (local file)

Try these searches:

  • grepai search "main entry point"
  • grepai search "database connection"
  • grepai search "error handling"

十四、限制说明 该技能未提供关于 GrepAI 的收费、价格、平台兼容范围、索引性能上限或效果保证等信息,相关事实暂未提供。