其他
需要在大代码库中快速搜索文本/正则模式或程序化编辑文件时…
适用于需要在大代码库中快速搜索代码模式、函数名、变量,或按路径程序化编辑文件,且已配置 Morph/WarpGrep 的场景。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 59/100 ×0.15
适用场景
需要在大代码库中快速搜索文本/正则模式或特定
解决思路
- 搜索代码模式:运行 `uv run python -m runtime.harness scripts/mcp/morph_search.py --search "authentication" --path "."`。
- 使用正则搜索:运行 `uv run python -m runtime.harness scripts/mcp/morph_search.py --search "def.*login" --path "./src"`。
- 编辑文件:运行 `uv run python -m runtime.harness scripts/mcp/morph_search.py --edit "/path/to/file.py" --content "new content"`。
- 参数 `--search`:指定搜索查询/模式。
- 参数 `--path`:指定要搜索的目录,默认值为 `.`。
- 参数 `--edit`:指定要编辑的文件路径。
- 参数 `--content`:指定文件的新内容,需与 `--edit` 一起使用。
- 示例:查找所有 async 函数:运行 `uv run python -m runtime.harness scripts/mcp/morph_search.py --search "async def" --path "./src"`。
- 示例:搜索 imports:运行 `uv run python -m runtime.harness scripts/mcp/morph_search.py --search "from fastapi import" --path "."`。
- 选型:快速文本/正则搜索用 morph/warpgrep(比 grep 快 20 倍);结构化代码搜索用 ast-grep(能理解语法)。
适用边界 · 注意事项
- 需要结构化代码搜索、理解语法结构时,不要用 morph/warpgrep,应使用 ast-grep。
- 未在 `mcp_config.json` 中配置 `morph` server 或未提供 `MORPH_API_KEY` 时,不能使用该技能。