grepai-quickstart

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GrepAI Quickstart

GrepAI 快速入门

This skill provides a complete walkthrough to get GrepAI running and searching your code in 5 minutes.
本指南提供完整流程,帮助你在5分钟内启动GrepAI并搜索你的代码。

When to Use This Skill

何时使用本指南

  • First time using GrepAI
  • Need a quick refresher on basic workflow
  • Setting up GrepAI on a new project
  • Demonstrating GrepAI to someone
  • 首次使用GrepAI
  • 需要快速回顾基础工作流程
  • 在新项目中配置GrepAI
  • 向他人演示GrepAI

Prerequisites

前置要求

  • Terminal access
  • A code project to index
  • 终端访问权限
  • 一个需要索引的代码项目

Step 1: Install GrepAI

步骤1:安装GrepAI

macOS

macOS

bash
brew install yoanbernabeu/tap/grepai
bash
brew install yoanbernabeu/tap/grepai

Linux/macOS (Alternative)

Linux/macOS(替代方案)

bash
curl -sSL https://raw.githubusercontent.com/yoanbernabeu/grepai/main/install.sh | sh
bash
curl -sSL https://raw.githubusercontent.com/yoanbernabeu/grepai/main/install.sh | sh

Windows

Windows

powershell
irm https://raw.githubusercontent.com/yoanbernabeu/grepai/main/install.ps1 | iex
Verify:
grepai version
powershell
irm https://raw.githubusercontent.com/yoanbernabeu/grepai/main/install.ps1 | iex
验证:
grepai version

Step 2: Install Ollama (Local Embeddings)

步骤2:安装Ollama(本地嵌入模型)

macOS

macOS

bash
brew install ollama
ollama serve &
ollama pull nomic-embed-text
bash
brew install ollama
ollama serve &
ollama pull nomic-embed-text

Linux

Linux

bash
curl -fsSL https://ollama.com/install.sh | sh
ollama serve &
ollama pull nomic-embed-text
Verify:
curl http://localhost:11434/api/tags
bash
curl -fsSL https://ollama.com/install.sh | sh
ollama serve &
ollama pull nomic-embed-text
验证:
curl http://localhost:11434/api/tags

Step 3: Initialize Your Project

步骤3:初始化你的项目

Navigate to your project and initialize GrepAI:
bash
cd /path/to/your/project
grepai init
This creates
.grepai/config.yaml
with default settings:
  • Ollama as embedding provider
  • nomic-embed-text
    model
  • GOB file storage
  • Standard ignore patterns
导航到你的项目并初始化GrepAI:
bash
cd /path/to/your/project
grepai init
这会创建
.grepai/config.yaml
文件,包含默认设置:
  • 使用Ollama作为嵌入模型提供商
  • nomic-embed-text
    模型
  • GOB文件存储
  • 标准忽略规则

Step 4: Start Indexing

步骤4:开始索引

Start the watch daemon to index your code:
bash
grepai watch
What happens:
  1. Scans all source files (respects
    .gitignore
    )
  2. Chunks code into ~512 token segments
  3. Generates embeddings via Ollama
  4. Stores vectors in
    .grepai/index.gob
First indexing output:
🔍 GrepAI Watch
   Scanning files...
   Found 245 files
   Processing chunks...
   ████████████████████████████████ 100%
   Indexed 1,234 chunks
   Watching for changes...
启动监控守护进程以索引你的代码:
bash
grepai watch
执行过程:
  1. 扫描所有源文件(遵循
    .gitignore
    规则)
  2. 将代码分割为约512个token的片段
  3. 通过Ollama生成嵌入向量
  4. 将向量存储在
    .grepai/index.gob
首次索引输出示例:
🔍 GrepAI Watch
   Scanning files...
   Found 245 files
   Processing chunks...
   ████████████████████████████████ 100%
   Indexed 1,234 chunks
   Watching for changes...

Background Mode

后台模式

For long-running projects:
bash
undefined
针对长期运行的项目:
bash
undefined

Start in background

后台启动

grepai watch --background
grepai watch --background

Check status

检查状态

grepai watch --status
grepai watch --status

Stop when done

停止进程

grepai watch --stop
undefined
grepai watch --stop
undefined

Step 5: Search Your Code

步骤5:搜索你的代码

Now search semantically:
bash
undefined
现在进行语义搜索:
bash
undefined

Basic search

基础搜索

grepai search "authentication flow"
grepai search "authentication flow"

Limit results

限制结果数量

grepai search "error handling" --limit 5
grepai search "error handling" --limit 5

JSON output for scripts

输出JSON格式用于脚本

grepai search "database queries" --json
undefined
grepai search "database queries" --json
undefined

Example Output

示例输出

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
    })
    // ...
}
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
    })
    // ...
}

Step 6: Analyze Call Graphs (Optional)

步骤6:分析调用图(可选)

Trace function relationships:
bash
undefined
追踪函数关系:
bash
undefined

Who calls this function?

哪些函数调用了该函数?

grepai trace callers "Login"
grepai trace callers "Login"

What does this function call?

该函数调用了哪些函数?

grepai trace callees "ProcessPayment"
grepai trace callees "ProcessPayment"

Full dependency graph

完整依赖图

grepai trace graph "ValidateToken" --depth 3
undefined
grepai trace graph "ValidateToken" --depth 3
undefined

Complete Workflow Summary

完整工作流程总结

bash
undefined
bash
undefined

1. Install (once)

1. 安装(仅需一次)

brew install yoanbernabeu/tap/grepai brew install ollama && ollama serve & && ollama pull nomic-embed-text
brew install yoanbernabeu/tap/grepai brew install ollama && ollama serve & && ollama pull nomic-embed-text

2. Setup project (once per project)

2. 项目配置(每个项目仅需一次)

cd /your/project grepai init
cd /your/project grepai init

3. Index (run in background)

3. 启动索引(后台运行)

grepai watch --background
grepai watch --background

4. Search (as needed)

4. 搜索(按需使用)

grepai search "your query here"
grepai search "your query here"

5. Trace (as needed)

5. 追踪(按需使用)

grepai trace callers "FunctionName"
undefined
grepai trace callers "FunctionName"
undefined

Quick Command Reference

快速命令参考

CommandPurpose
grepai init
Initialize project config
grepai watch
Start indexing daemon
grepai watch --background
Run daemon in background
grepai watch --status
Check daemon status
grepai watch --stop
Stop daemon
grepai search "query"
Semantic search
grepai search --json
JSON output
grepai trace callers "fn"
Find callers
grepai trace callees "fn"
Find callees
grepai status
Index statistics
grepai version
Show version
命令用途
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
显示版本信息

Search Tips

搜索技巧

Be descriptive, not literal:
  • ✅ "user authentication and session management"
  • ❌ "auth"
Describe intent:
  • ✅ "where errors are logged to the console"
  • ❌ "console.error"
Use English:
  • Models are trained primarily on English text
  • Works best with English queries
描述性而非字面化:
  • ✅ "user authentication and session management"
  • ❌ "auth"
描述意图:
  • ✅ "where errors are logged to the console"
  • ❌ "console.error"
使用英文:
  • 模型主要基于英文文本训练
  • 英文查询效果最佳

Next Steps

后续步骤

After mastering the basics:
  1. Configure embeddings: See
    grepai-embeddings-*
    skills
  2. Setup storage: See
    grepai-storage-*
    skills
  3. Advanced search: See
    grepai-search-*
    skills
  4. MCP integration: See
    grepai-mcp-*
    skills
掌握基础操作后:
  1. 配置嵌入模型: 查看
    grepai-embeddings-*
    相关指南
  2. 配置存储: 查看
    grepai-storage-*
    相关指南
  3. 高级搜索: 查看
    grepai-search-*
    相关指南
  4. MCP集成: 查看
    grepai-mcp-*
    相关指南

Output Format

输出格式

Successful quickstart:
✅ 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 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"