grepai-init
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGrepAI Init
GrepAI 初始化
This skill covers the command and project initialization.
grepai init本技能介绍命令及项目初始化流程。
grepai initWhen to Use This Skill
何时使用本技能
- Setting up GrepAI in a new project
- Understanding what creates
grepai init - Customizing initial configuration
- Troubleshooting initialization issues
- 在新项目中设置GrepAI
- 了解会创建哪些内容
grepai init - 自定义初始配置
- 排查初始化问题
Basic Usage
基本用法
bash
cd /path/to/your/project
grepai initbash
cd /path/to/your/project
grepai initWhat Init Creates
初始化会创建的内容
Running creates the directory with:
grepai init.grepai/.grepai/
├── config.yaml # Configuration file
├── index.gob # Vector index (created by watch)
└── symbols.gob # Symbol index for trace (created by watch)运行会创建目录,包含以下文件:
grepai init.grepai/.grepai/
├── config.yaml # 配置文件
├── index.gob # 向量索引(由watch命令创建)
└── symbols.gob # 用于追踪的符号索引(由watch命令创建)Default Configuration
默认配置
The generated :
config.yamlyaml
version: 1
embedder:
provider: ollama
model: nomic-embed-text
endpoint: http://localhost:11434
store:
backend: gob
chunking:
size: 512
overlap: 50
watch:
debounce_ms: 500
trace:
mode: fast
enabled_languages:
- .go
- .js
- .ts
- .jsx
- .tsx
- .py
- .php
- .c
- .h
- .cpp
- .hpp
- .cc
- .cxx
- .rs
- .zig
- .cs
- .pas
- .dpr
ignore:
- .git
- .grepai
- node_modules
- vendor
- target
- __pycache__
- dist
- build生成的内容如下:
config.yamlyaml
version: 1
embedder:
provider: ollama
model: nomic-embed-text
endpoint: http://localhost:11434
store:
backend: gob
chunking:
size: 512
overlap: 50
watch:
debounce_ms: 500
trace:
mode: fast
enabled_languages:
- .go
- .js
- .ts
- .jsx
- .tsx
- .py
- .php
- .c
- .h
- .cpp
- .hpp
- .cc
- .cxx
- .rs
- .zig
- .cs
- .pas
- .dpr
ignore:
- .git
- .grepai
- node_modules
- vendor
- target
- __pycache__
- dist
- buildUnderstanding Default Settings
理解默认设置
Embedder Settings
嵌入模型设置
| Setting | Default | Purpose |
|---|---|---|
| | Local embedding generation |
| | 768-dimension model |
| | Ollama API URL |
| 设置项 | 默认值 | 用途 |
|---|---|---|
| | 本地嵌入模型生成 |
| | 768维度模型 |
| | Ollama API地址 |
Store Settings
存储设置
| Setting | Default | Purpose |
|---|---|---|
| | Local file storage |
| 设置项 | 默认值 | 用途 |
|---|---|---|
| | 本地文件存储 |
Chunking Settings
分块设置
| Setting | Default | Purpose |
|---|---|---|
| | Tokens per chunk |
| | Overlap for context |
| 设置项 | 默认值 | 用途 |
|---|---|---|
| | 每个分块的Token数量 |
| | 分块间的重叠长度(用于上下文关联) |
Watch Settings
监听设置
| Setting | Default | Purpose |
|---|---|---|
| | Wait time before re-indexing |
| 设置项 | 默认值 | 用途 |
|---|---|---|
| | 重新索引前的等待时间 |
Ignore Patterns
忽略规则
Default patterns exclude:
- Version control:
.git - GrepAI data:
.grepai - Dependencies: ,
node_modulesvendor - Build outputs: ,
target,distbuild - Cache:
__pycache__
默认忽略以下内容:
- 版本控制目录:
.git - GrepAI数据目录:
.grepai - 依赖目录:,
node_modulesvendor - 构建输出目录:,
target,distbuild - 缓存目录:
__pycache__
Customizing After Init
初始化后的自定义配置
Edit to customize:
.grepai/config.yaml编辑进行自定义:
.grepai/config.yamlChange Embedding Provider
更换嵌入模型提供商
yaml
embedder:
provider: openai
model: text-embedding-3-small
api_key: ${OPENAI_API_KEY}yaml
embedder:
provider: openai
model: text-embedding-3-small
api_key: ${OPENAI_API_KEY}Change Storage Backend
更换存储后端
yaml
store:
backend: postgres
postgres:
dsn: postgres://user:pass@localhost:5432/grepaiyaml
store:
backend: postgres
postgres:
dsn: postgres://user:pass@localhost:5432/grepaiAdd Custom Ignore Patterns
添加自定义忽略规则
yaml
ignore:
- .git
- .grepai
- node_modules
- "*.min.js"
- "*.bundle.js"
- coverage/
- .nyc_output/yaml
ignore:
- .git
- .grepai
- node_modules
- "*.min.js"
- "*.bundle.js"
- coverage/
- .nyc_output/Init in Monorepos
单体仓库(Monorepo)中的初始化
For monorepos, init at the root:
bash
cd /path/to/monorepo
grepai initOr use workspaces for separate indices:
bash
grepai workspace create my-workspace
grepai workspace add my-workspace /path/to/project1
grepai workspace add my-workspace /path/to/project2对于单体仓库,在根目录执行初始化:
bash
cd /path/to/monorepo
grepai init或者使用工作区来创建独立的索引:
bash
grepai workspace create my-workspace
grepai workspace add my-workspace /path/to/project1
grepai workspace add my-workspace /path/to/project2Re-Initialization
重新初始化
If you need to reset:
bash
undefined如果你需要重置配置:
bash
undefinedRemove existing config
删除现有配置
rm -rf .grepai
rm -rf .grepai
Re-initialize
重新初始化
grepai init
**Warning:** This deletes your index. You'll need to re-run `grepai watch`.grepai init
**警告:** 此操作会删除你的索引。你需要重新运行`grepai watch`来重建索引。Verifying Initialization
验证初始化结果
After init, verify with:
bash
undefined初始化完成后,通过以下命令验证:
bash
undefinedCheck config exists
检查配置文件是否存在
cat .grepai/config.yaml
cat .grepai/config.yaml
Check status (will show no index yet)
检查状态(此时会显示尚未创建索引)
grepai status
undefinedgrepai status
undefinedCommon Issues
常见问题
❌ Problem: already exists
✅ Solution: Delete it first or edit existing config:
.grepaibash
rm -rf .grepai && grepai init❌ Problem: Config created but Ollama not running
✅ Solution: Start Ollama before running :
grepai watchbash
ollama serve❌ Problem: Wrong directory initialized
✅ Solution: Remove and init in correct directory
.grepai❌ 问题: 目录已存在
✅ 解决方案: 先删除该目录或编辑现有配置:
.grepaibash
rm -rf .grepai && grepai init❌ 问题: 配置文件已创建,但Ollama未运行
✅ 解决方案: 在运行前启动Ollama:
grepai watchbash
ollama serve❌ 问题: 在错误的目录中执行了初始化
✅ 解决方案: 删除目录并在正确的目录中重新初始化
.grepaiBest Practices
最佳实践
- Init at project root: Where your main code lives
- Add to
.grepai/: Index is machine-specific.gitignore - Customize ignore patterns: Exclude generated/vendored code
- Review config after init: Adjust for your stack
- 在项目根目录初始化: 即你的主代码所在目录
- 将添加到
.grepai/: 索引文件是机器特定的,无需提交到版本控制.gitignore - 自定义忽略规则: 排除生成的代码或第三方依赖代码
- 初始化后检查配置: 根据你的技术栈调整配置
Example .gitignore Addition
.gitignore 添加示例
gitignore
undefinedgitignore
undefinedGrepAI
GrepAI
.grepai/
undefined.grepai/
undefinedOutput Format
输出格式
After successful initialization:
✅ GrepAI Initialized
Config: .grepai/config.yaml
Default settings:
- Embedder: Ollama (nomic-embed-text)
- Storage: GOB (local file)
- Chunking: 512 tokens, 50 overlap
Next steps:
1. Ensure Ollama is running: ollama serve
2. Start indexing: grepai watch初始化成功后的输出如下:
✅ GrepAI Initialized
Config: .grepai/config.yaml
Default settings:
- Embedder: Ollama (nomic-embed-text)
- Storage: GOB (local file)
- Chunking: 512 tokens, 50 overlap
Next steps:
1. Ensure Ollama is running: ollama serve
2. Start indexing: grepai watch