自动化与脚本
需要低 Token 探索代码库时,用 RepoPrompt…
已运行 RepoPrompt 并启用 MCP Server 时,通过 CLI 高效探索代码库、搜索代码、读取文件片段和管理工作区上下文。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 60/100 ×0.15
适用场景
需要低 Token 探索代码库时,用 R特定
解决思路
- 用 `structure` 只获取代码签名而非完整内容,以节省 token。
- 用 `read --start-line --limit` 读取文件切片而非完整文件,以节省 token。
- 用 `search --context-lines` 获取带上下文的相关匹配,以节省 token。
- 若已安装到 PATH(Settings → MCP Server → Install CLI to PATH),用 `rp-cli -e 'command'` 执行命令;或配置 shell alias 后使用 `repoprompt_cli -e 'command'`。
- 用 `rp-cli -e 'tree'` 查看完整文件树。
- 用 `rp-cli -e 'tree --mode folders'` 只查看文件夹。
- 用 `rp-cli -e 'tree --mode selected'` 只查看选中文件。
- 用 `rp-cli -e 'structure src/auth/'` 获取指定路径的代码结构(codemap)。
- 用 `rp-cli -e 'structure --scope selected'` 获取选中文件的代码结构。
- 用 `rp-cli -e 'structure src/ --max-results 10'` 限制代码结构结果数量。
- 用 `rp-cli -e 'search "pattern"'` 执行基础搜索。
- 用 `rp-cli -e 'search "error" --context-lines 3'` 搜索并显示上下文行。
- 用 `rp-cli -e 'search "TODO" --extensions .ts,.tsx'` 按扩展名过滤搜索。
- 用 `rp-cli -e 'search "function" --max-results 20'` 限制搜索结果数量。
- 用 `rp-cli -e 'read path/to/file.ts'` 读取完整文件。
- 用 `rp-cli -e 'read path/to/file.ts --start-line 50 --limit 30'` 读取指定行范围。
- 用 `rp-cli -e 'read path/to/file.ts --start-line -20'` 读取最后 N 行(tail)。
- 用 `rp-cli -e 'select add src/auth/'` 添加文件到选择。
- 用 `rp-cli -e 'select set src/api/ src/types/'` 设置选择(替换)。
- 用 `rp-cli -e 'select clear'` 清空选择。
- 用 `rp-cli -e 'select get'` 查看当前选择。
- 用 `rp-cli -e 'context'` 获取完整工作区上下文。
- 用 `rp-cli -e 'context --include prompt,selection,tree'` 获取指定包含项的上下文。
- 用 `rp-cli -e 'select set src/auth/ && structure --scope selected && context'` 链式执行多个操作。
- 用 `rp-cli -e 'workspace list'` 列出工作区。
- 用 `rp-cli -e 'workspace tabs'` 列出标签页。
- 用 `rp-cli -e 'workspace switch "ProjectName"'` 切换工作区。
- 用 `rp-cli -e 'chat "How does the auth system work?"'` 发送到 AI Chat(使用 RepoPrompt 的模型)。
- 用 `rp-cli -e 'chat "Design a new feature" --mode plan'` 以 plan 模式使用 AI Chat。
- 用 `rp-cli -e 'builder "implement user authentication"'` 使用 AI 自动为任务选择相关文件(Context Builder)。
- 使用工作流简写参数:`rp-cli --workspace MyProject --select-set src/ --export-context ~/out.md`。
- 使用工作流简写参数:`rp-cli --chat "How does auth work?"`。
- 使用工作流简写参数:`rp-cli --builder "implement user authentication"`。
- 为可重复工作流保存命令到 `.rp` 脚本,例如 `daily-export.rp` 中写入 `workspace switch Frontend`、`select set src/components/`、`context --all > ~/exports/frontend.md`。
- 用 `rp-cli --exec-file ~/scripts/daily-export.rp` 运行 `.rp` 脚本。
- 用 `-e 'cmd'` 执行命令。
- 用 `-w <id>` 指定目标窗口 ID。
- 用 `-q` 启用安静模式。
- 用 `-d <cmd>` 查看命令的详细帮助。
- 用 `--wait-for-server 5` 在脚本中等待连接。
- 对 `builder` 等长运行操作,用 `uv run python -m runtime.harness scripts/repoprompt_async.py --action start --task "understand the auth system"` 异步启动。
- 异步启动时可切工作区:`uv run python -m runtime.harness scripts/repoprompt_async.py --action start --workspace "MyProject" --task "explore API patterns"`。
- 用 `uv run python -m runtime.harness scripts/repoprompt_async.py --action status` 检查异步状态。
- 用 `uv run python -m runtime.harness scripts/repoprompt_async.py --action result` 在完成后获取结果。
- 用 `uv run python -m runtime.harness scripts/repoprompt_async.py --action kill` 在需要时终止异步操作。
适用边界 · 注意事项
- 未运行 RepoPrompt app 或未启用 MCP Server 时不适用。
- 未安装或无法使用 RepoPrompt CLI(或 alias)时不适用。