关于 morph-search
使用 Morph 的 WarpGrep 搜索代码库并编辑文件的技能,支持目录中的文本和正则表达式搜索,也可替换文件内容。
主要功能
- 01搜索代码模式
- 02使用正则表达式搜索
- 03指定搜索目录
- 04替换文件内容
- 05对比文本搜索与 ast-grep
适用场景
- 01在代码库中查找函数或变量
- 02定位导入语句或异步函数
- 03替换文件内容
MCP 相关
需要在 `mcp_config.json` 中配置 `morph` MCP 服务及 `MORPH_API_KEY`。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ parcadei/ continuous-claude-v3 --skill morph-search安装后在 Claude Code 中输入/morph-search确认已加载。
详细介绍
Morph 代码库搜索
使用 WarpGrep 进行快速、AI 驱动的代码库搜索。速度比传统 grep 快 20 倍。
适用场景
- 搜索代码库中的模式、函数名和变量
- 快速在大型代码库中查找代码
- 以编程方式编辑文件
用法
搜索代码模式
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 一起使用) |
示例
# Find all async functions
uv run python -m runtime.harness scripts/mcp/morph_search.py \
--search "async def" --path "./src"
# Search for imports
uv run python -m runtime.harness scripts/mcp/morph_search.py \
--search "from fastapi import" --path "."
与 ast-grep 对比
| 工具 | 最适用于 |
|---|---|
| morph/warpgrep | 快速文本/正则表达式搜索(速度快 20 倍) |
| ast-grep | 结构化代码搜索(理解语法) |
所需 MCP 服务
需要在 mcp_config.json 中配置 morph 服务,并提供 MORPH_API_KEY。
评论
支持 Markdown