grepai-workspaces
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGrepAI Workspaces
GrepAI 工作区
This skill covers using GrepAI workspaces to manage multiple related projects with a unified search index.
本技能介绍如何使用GrepAI工作区,通过统一的搜索索引管理多个相关项目。
When to Use This Skill
何时使用此技能
- Working with monorepos
- Searching across multiple related projects
- Managing microservices architecture
- Organizing large codebases
- 处理monorepo项目
- 在多个相关项目中进行搜索
- 管理微服务架构
- 组织大型代码库
What are Workspaces?
什么是工作区?
Workspaces allow you to:
- Group multiple projects together
- Search across all projects at once
- Or search specific projects within the workspace
- Share configuration across projects
工作区允许您:
- 将多个项目分组
- 一次性搜索所有项目
- 或搜索工作区内的特定项目
- 在项目间共享配置
Creating a Workspace
创建工作区
bash
grepai workspace create my-workspaceOutput:
✅ Workspace 'my-workspace' created
Location: ~/.grepai/workspaces/my-workspace/
Next: Add projects with 'grepai workspace add'bash
grepai workspace create my-workspace输出:
✅ Workspace 'my-workspace' created
Location: ~/.grepai/workspaces/my-workspace/
Next: Add projects with 'grepai workspace add'Adding Projects
添加项目
bash
undefinedbash
undefinedAdd first project
Add first project
grepai workspace add my-workspace /path/to/frontend
grepai workspace add my-workspace /path/to/frontend
Add more projects
Add more projects
grepai workspace add my-workspace /path/to/backend
grepai workspace add my-workspace /path/to/shared-lib
Output:✅ Added '/path/to/frontend' to workspace 'my-workspace'
Projects in workspace:
- frontend (/path/to/frontend)
Run 'grepai watch --workspace my-workspace' to index all projects.
undefinedgrepai workspace add my-workspace /path/to/backend
grepai workspace add my-workspace /path/to/shared-lib
输出:✅ Added '/path/to/frontend' to workspace 'my-workspace'
Projects in workspace:
- frontend (/path/to/frontend)
Run 'grepai watch --workspace my-workspace' to index all projects.
undefinedListing Workspaces
列出工作区
bash
grepai workspace listOutput:
📁 Workspaces
1. my-workspace
- Projects: 3
- Status: Not indexed
2. work-projects
- Projects: 5
- Status: Indexed (updated 2h ago)bash
grepai workspace list输出:
📁 Workspaces
1. my-workspace
- Projects: 3
- Status: Not indexed
2. work-projects
- Projects: 5
- Status: Indexed (updated 2h ago)Viewing Workspace Details
查看工作区详情
bash
grepai workspace show my-workspaceOutput:
📁 Workspace: my-workspace
Projects:
1. frontend
Path: /path/to/frontend
Files: 450
Last indexed: 2025-01-28 10:30
2. backend
Path: /path/to/backend
Files: 320
Last indexed: 2025-01-28 10:30
3. shared-lib
Path: /path/to/shared-lib
Files: 85
Last indexed: 2025-01-28 10:30
Total: 855 files, 4,200 chunksbash
grepai workspace show my-workspace输出:
📁 Workspace: my-workspace
Projects:
1. frontend
Path: /path/to/frontend
Files: 450
Last indexed: 2025-01-28 10:30
2. backend
Path: /path/to/backend
Files: 320
Last indexed: 2025-01-28 10:30
3. shared-lib
Path: /path/to/shared-lib
Files: 85
Last indexed: 2025-01-28 10:30
Total: 855 files, 4,200 chunksIndexing a Workspace
为工作区建立索引
bash
undefinedbash
undefinedIndex all projects in workspace
Index all projects in workspace
grepai watch --workspace my-workspace
Output:🔍 Indexing workspace 'my-workspace'
[1/3] frontend...
Found 450 files, 2,100 chunks
[2/3] backend...
Found 320 files, 1,500 chunks
[3/3] shared-lib...
Found 85 files, 600 chunks
Total: 855 files, 4,200 chunks indexed
Watching for changes...
undefinedgrepai watch --workspace my-workspace
输出:🔍 Indexing workspace 'my-workspace'
[1/3] frontend...
Found 450 files, 2,100 chunks
[2/3] backend...
Found 320 files, 1,500 chunks
[3/3] shared-lib...
Found 85 files, 600 chunks
Total: 855 files, 4,200 chunks indexed
Watching for changes...
undefinedBackground Indexing
后台索引
bash
grepai watch --workspace my-workspace --backgroundbash
grepai watch --workspace my-workspace --backgroundSearching Workspaces
搜索工作区
Search All Projects
搜索所有项目
bash
grepai search --workspace my-workspace "user authentication"Results include project context:
Score: 0.89 | [backend] src/auth/middleware.go:15-45
──────────────────────────────────────────
func AuthMiddleware() ...
Score: 0.85 | [frontend] src/hooks/useAuth.ts:10-30
──────────────────────────────────────────
export function useAuth() ...
Score: 0.78 | [shared-lib] src/types/auth.ts:5-25
──────────────────────────────────────────
export interface AuthState ...bash
grepai search --workspace my-workspace "user authentication"结果包含项目上下文:
Score: 0.89 | [backend] src/auth/middleware.go:15-45
──────────────────────────────────────────
func AuthMiddleware() ...
Score: 0.85 | [frontend] src/hooks/useAuth.ts:10-30
──────────────────────────────────────────
export function useAuth() ...
Score: 0.78 | [shared-lib] src/types/auth.ts:5-25
──────────────────────────────────────────
export interface AuthState ...Search Specific Project
搜索特定项目
bash
grepai search --workspace my-workspace --project frontend "form validation"Only searches the frontend project.
bash
grepai search --workspace my-workspace --project frontend "form validation"仅搜索frontend项目。
Workspace Status
工作区状态
bash
grepai workspace status my-workspaceOutput:
📊 Workspace Status: my-workspace
Projects: 3
Total files: 855
Total chunks: 4,200
Index size: 45 MB
Per-project breakdown:
┌─────────────┬───────┬────────┬──────────┐
│ Project │ Files │ Chunks │ Updated │
├─────────────┼───────┼────────┼──────────┤
│ frontend │ 450 │ 2,100 │ 2h ago │
│ backend │ 320 │ 1,500 │ 2h ago │
│ shared-lib │ 85 │ 600 │ 2h ago │
└─────────────┴───────┴────────┴──────────┘
Daemon: Running (PID 12345)bash
grepai workspace status my-workspace输出:
📊 Workspace Status: my-workspace
Projects: 3
Total files: 855
Total chunks: 4,200
Index size: 45 MB
Per-project breakdown:
┌─────────────┬───────┬────────┬──────────┐
│ Project │ Files │ Chunks │ Updated │
├─────────────┼───────┼────────┼──────────┤
│ frontend │ 450 │ 2,100 │ 2h ago │
│ backend │ 320 │ 1,500 │ 2h ago │
│ shared-lib │ 85 │ 600 │ 2h ago │
└─────────────┴───────┴────────┴──────────┘
Daemon: Running (PID 12345)Removing Projects from Workspace
从工作区移除项目
bash
grepai workspace remove my-workspace /path/to/old-projectbash
grepai workspace remove my-workspace /path/to/old-projectDeleting a Workspace
删除工作区
bash
grepai workspace delete my-workspaceThis removes the workspace configuration but NOT the project files.
bash
grepai workspace delete my-workspace此操作会移除工作区配置,但不会删除项目文件。
Workspace Configuration
工作区配置
Workspaces store config in :
~/.grepai/workspaces/<name>/~/.grepai/workspaces/my-workspace/
├── workspace.yaml # Workspace config
├── index.gob # Combined index
└── symbols.gob # Combined symbols工作区配置存储在 目录下:
~/.grepai/workspaces/<name>/~/.grepai/workspaces/my-workspace/
├── workspace.yaml # Workspace config
├── index.gob # Combined index
└── symbols.gob # Combined symbolsworkspace.yaml
workspace.yaml
yaml
name: my-workspace
created: 2025-01-28T10:00:00Z
projects:
- name: frontend
path: /path/to/frontend
- name: backend
path: /path/to/backend
- name: shared-lib
path: /path/to/shared-libyaml
name: my-workspace
created: 2025-01-28T10:00:00Z
projects:
- name: frontend
path: /path/to/frontend
- name: backend
path: /path/to/backend
- name: shared-lib
path: /path/to/shared-libOptional: override global config per workspace
Optional: override global config per workspace
embedder:
provider: ollama
model: nomic-embed-text
ignore:
- node_modules
- dist
undefinedembedder:
provider: ollama
model: nomic-embed-text
ignore:
- node_modules
- dist
undefinedMCP with Workspaces
结合MCP使用工作区
Use workspaces with MCP servers:
json
{
"mcpServers": {
"grepai": {
"command": "grepai",
"args": ["mcp-serve", "--workspace", "my-workspace"]
}
}
}将工作区与MCP服务器配合使用:
json
{
"mcpServers": {
"grepai": {
"command": "grepai",
"args": ["mcp-serve", "--workspace", "my-workspace"]
}
}
}Use Cases
使用场景
Monorepo
Monorepo
bash
undefinedbash
undefinedFull monorepo
Full monorepo
grepai workspace create monorepo
grepai workspace add monorepo /path/to/monorepo/apps/web
grepai workspace add monorepo /path/to/monorepo/apps/mobile
grepai workspace add monorepo /path/to/monorepo/packages/ui
grepai workspace add monorepo /path/to/monorepo/packages/core
undefinedgrepai workspace create monorepo
grepai workspace add monorepo /path/to/monorepo/apps/web
grepai workspace add monorepo /path/to/monorepo/apps/mobile
grepai workspace add monorepo /path/to/monorepo/packages/ui
grepai workspace add monorepo /path/to/monorepo/packages/core
undefinedMicroservices
微服务
bash
undefinedbash
undefinedRelated microservices
Related microservices
grepai workspace create services
grepai workspace add services /path/to/user-service
grepai workspace add services /path/to/order-service
grepai workspace add services /path/to/payment-service
grepai workspace add services /path/to/notification-service
undefinedgrepai workspace create services
grepai workspace add services /path/to/user-service
grepai workspace add services /path/to/order-service
grepai workspace add services /path/to/payment-service
grepai workspace add services /path/to/notification-service
undefinedFrontend + Backend
前端+后端
bash
undefinedbash
undefinedFull stack
Full stack
grepai workspace create fullstack
grepai workspace add fullstack /path/to/frontend
grepai workspace add fullstack /path/to/backend
grepai workspace add fullstack /path/to/shared-types
undefinedgrepai workspace create fullstack
grepai workspace add fullstack /path/to/frontend
grepai workspace add fullstack /path/to/backend
grepai workspace add fullstack /path/to/shared-types
undefinedCross-Project Search Examples
跨项目搜索示例
Find All API Endpoints
查找所有API端点
bash
grepai search --workspace services "REST API endpoint handler"bash
grepai search --workspace services "REST API endpoint handler"Find Shared Type Usage
查找共享类型的使用
bash
grepai search --workspace fullstack "User interface definition"bash
grepai search --workspace fullstack "User interface definition"Find Cross-Project Dependencies
查找跨项目依赖
bash
undefinedbash
undefinedWhat calls the shared auth library?
What calls the shared auth library?
grepai trace callers --workspace fullstack "validateToken"
undefinedgrepai trace callers --workspace fullstack "validateToken"
undefinedBest Practices
最佳实践
- Name descriptively: not
ecommerce-stackws1 - Group related projects: Only projects that you'd search together
- One daemon per workspace: Run
grepai watch --workspace - Use project filter: When you know which project to search
- Update after major changes: Re-index after adding/removing files
- 命名要有描述性: 使用而非
ecommerce-stackws1 - 分组相关项目: 仅将需要一起搜索的项目分组
- 每个工作区一个守护进程: 运行
grepai watch --workspace - 使用项目过滤器: 当您明确要搜索哪个项目时
- 重大变更后更新索引: 添加/删除文件后重新建立索引
Common Issues
常见问题
❌ Problem: Workspace not found
✅ Solution: Check workspace exists:
grepai workspace list❌ Problem: Project paths changed
✅ Solution: Remove old path, add new path:
bash
grepai workspace remove my-workspace /old/path
grepai workspace add my-workspace /new/path❌ Problem: Search returns mixed results
✅ Solution: Use flag to filter:
--projectbash
grepai search --workspace ws --project backend "query"❌ 问题: 找不到工作区
✅ 解决方案: 检查工作区是否存在:
grepai workspace list❌ 问题: 项目路径已更改
✅ 解决方案: 移除旧路径,添加新路径:
bash
grepai workspace remove my-workspace /old/path
grepai workspace add my-workspace /new/path❌ 问题: 搜索结果混杂
✅ 解决方案: 使用标志进行过滤:
--projectbash
grepai search --workspace ws --project backend "query"Output Format
输出格式
Workspace overview:
📁 Workspace: my-workspace
Configuration:
- Location: ~/.grepai/workspaces/my-workspace/
- Created: 2025-01-28
Projects (3):
┌─────────────┬──────────────────────────┬───────┐
│ Name │ Path │ Files │
├─────────────┼──────────────────────────┼───────┤
│ frontend │ /path/to/frontend │ 450 │
│ backend │ /path/to/backend │ 320 │
│ shared-lib │ /path/to/shared-lib │ 85 │
└─────────────┴──────────────────────────┴───────┘
Commands:
- Index: grepai watch --workspace my-workspace
- Search: grepai search --workspace my-workspace "query"
- Status: grepai workspace status my-workspace工作区概览:
📁 Workspace: my-workspace
Configuration:
- Location: ~/.grepai/workspaces/my-workspace/
- Created: 2025-01-28
Projects (3):
┌─────────────┬──────────────────────────┬───────┐
│ Name │ Path │ Files │
├─────────────┼──────────────────────────┼───────┤
│ frontend │ /path/to/frontend │ 450 │
│ backend │ /path/to/backend │ 320 │
│ shared-lib │ /path/to/shared-lib │ 85 │
└─────────────┴──────────────────────────┴───────┘
Commands:
- Index: grepai watch --workspace my-workspace
- Search: grepai search --workspace my-workspace "query"
- Status: grepai workspace status my-workspace