← 返回 Skills 市场
Dir Text Search
作者
TryLoveCatch
· GitHub ↗
· v1.1.0
· MIT-0
89
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install dir-text-search
功能描述
This skill should be used when the user wants to search for text or regex patterns inside a directory, including inside ZIP / RAR / TAR / 7z archives recursi...
使用说明 (SKILL.md)
\r \r
dir-text-search — 目录文本搜索技能\r
\r
功能概述\r
\r 在指定目录下递归搜索文本或正则表达式,支持:\r \r
- 文本文件(
.txt.log.cfg.conf.ini.md.json.xml.py.java等)\r - 压缩包递归解压搜索(
.zip.rar.tar.tar.gz.tar.bz2.7z)\r - 嵌套压缩包(解压后继续递归扫描)\r
- 多编码自动探测(UTF-8 → GBK → latin-1)\r
- 超大文件(> 100 MB)自动跳过并警告\r
- 结果按时间戳自动命名,保存在
search_results/子目录,不会覆盖旧结果\r \r
触发场景\r
\r 以下用户请求应加载本 Skill:\r \r
- "在
X目录下查找Y"\r - "搜索所有日志中包含
error的行"\r - "在压缩包里找
Account_Main"\r - "帮我 grep
\d{4}-\d{2}-\d{2}这个模式"\r - 任何需要在文件/压缩包中批量搜索字符串或正则的请求\r \r
核心脚本\r
\r
脚本路径:scripts/search_tool.py\r
\r
标准调用方式\r
\r
python scripts/search_tool.py --path \x3C目标目录> --pattern "\x3C搜索文本或正则>"\r
```\r
\r
### 参数说明\r
\r
| 参数 | 简写 | 说明 | 默认值 |\r
|------|------|------|--------|\r
| `--path` | `-p` | 要搜索的目标目录路径 | 交互式输入 |\r
| `--pattern` | `-t` | 搜索文本或正则表达式 | 交互式输入 |\r
| `--output` | `-o` | 结果保存目录(非文件名) | 脚本所在目录下的 `search_results/` |\r
| `--no-regex` | — | 将 pattern 作为普通字符串(自动转义元字符) | 否(默认正则模式) |\r
\r
### 结果文件位置\r
\r
每次执行自动生成:\r
```\r
search_results/\r
20260415_101252_Account_Main.txt\r
20260415_110000_error.txt\r
```\r
\r
## 执行流程\r
\r
1. **收集参数**:从用户消息中提取目标目录和搜索关键词。\r
2. **运行脚本**:调用 `scripts/search_tool.py`,传入 `--path` 和 `--pattern`。\r
3. **展示结果**:\r
- 告知用户结果文件路径。\r
- 读取结果文件,汇总每个命中文件的匹配行数。\r
- 如有特别关键的匹配内容,摘要呈现给用户。\r
\r
## 依赖安装\r
\r
脚本使用 Python 标准库,可选依赖:\r
\r
```bash\r
pip install rarfile # 支持 .rar 文件(还需系统安装 unrar)\r
pip install py7zr # 支持 .7z 文件\r
```\r
\r
RAR 所需系统工具:\r
- **Windows**:下载 unrar.exe → https://www.rarlab.com/rar_add.htm\r
- **macOS**:`brew install unrar`\r
- **Linux**:`sudo apt install unrar`\r
\r
若用户未安装上述依赖,脚本会给出友好提示,ZIP/TAR 等格式不受影响仍可正常使用。\r
\r
## 注意事项\r
\r
- 不修改原始文件,只读。\r
- 解压到系统临时目录,搜索完成后自动清理。\r
- 防路径遍历攻击(对 ZIP/TAR 安全提取,拒绝含 `..` 的路径)。\r
- 对用户提供的 pattern,若不确定是否为正则,可加 `--no-regex` 参数安全处理。\r
安全使用建议
This skill appears coherent and matches its description, but before installing or running it on sensitive data: (1) provide the rest of scripts/search_tool.py for a full audit (the file listing you supplied is truncated); (2) run the script in a sandbox or on non-sensitive copies first; (3) do not run it as root — run it as a low-privilege user; (4) confirm optional dependencies (rarfile/py7zr) are installed intentionally; (5) if you plan to scan untrusted archives, review or test the archive-extraction code for symlink/absolute-path extraction edge-cases to ensure it truly prevents path traversal and symlink escapes. If you can supply the full script contents I will re-evaluate and raise the confidence level.
功能分析
Type: OpenClaw Skill
Name: dir-text-search
Version: 1.1.0
The skill bundle provides a legitimate utility for searching text and regex patterns within directories and compressed archives (ZIP, TAR, RAR, 7z). The core script `scripts/search_tool.py` includes explicit security measures such as path traversal protection during archive extraction and file size limits to prevent resource exhaustion. No evidence of data exfiltration, unauthorized execution, or malicious prompt injection was found.
能力评估
Purpose & Capability
Name/description ask for directory and archive text searching and the repository includes a dedicated Python script (scripts/search_tool.py) that implements recursive file traversal, archive extraction, encoding fallbacks, and pattern matching. No unrelated binaries, env vars, or external services are requested.
Instruction Scope
SKILL.md instructs the agent only to collect path and pattern parameters, run the bundled script, and present results — all within the declared purpose. The script extracts archives to a temporary directory and cleans up. However, the provided script listing is truncated so the tail of the logic (final scanning/writing/reporting) couldn't be fully reviewed. The script attempts to mitigate path traversal when extracting ZIP and TAR members, but the TAR extraction branch contains an odd use of extractall(filter="data") (likely incorrect API use) and the manual filtering checks are simple (reject names with '..' or leading '/'); edge-cases such as symlink entries or more subtle archive attacks may not be fully handled. This is an implementation detail rather than a purpose mismatch, but worth reviewing before use on sensitive data.
Install Mechanism
No install spec is provided (instruction-only skill plus a local script). Optional Python deps (rarfile, py7zr, chardet) are documented and installed via pip if the user chooses; there are no downloads from untrusted URLs or opaque installers.
Credentials
The skill declares no required environment variables, no credentials, and no config paths. The SKILL.md and visible script do not attempt to read environment secrets or unrelated system configuration.
Persistence & Privilege
always is false and the skill does not request persistent or privileged platform presence. It does not modify other skills or system-wide settings in the visible parts of SKILL.md or the script.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install dir-text-search - 安装完成后,直接呼叫该 Skill 的名称或使用
/dir-text-search触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
dir-text-search 1.1.0
- Updated scripts/search_tool.py (details not shown).
- No changes to user-facing features or documentation.
v1.0.0
Initial release of dir-text-search skill:
- Enables recursive search for text or regex patterns in directories, including inside ZIP, RAR, TAR, and 7z archives (with nested archive support).
- Handles multiple file encodings automatically (UTF-8, GBK, latin-1).
- Skips very large files (>100 MB) with a warning.
- Search results are organized by timestamp in a dedicated search_results/ folder.
- Includes safe extraction methods to prevent path traversal in archives.
- Provides friendly dependency checks and instructions for extended archive support.
元数据
常见问题
Dir Text Search 是什么?
This skill should be used when the user wants to search for text or regex patterns inside a directory, including inside ZIP / RAR / TAR / 7z archives recursi... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 89 次。
如何安装 Dir Text Search?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install dir-text-search」即可一键安装,无需额外配置。
Dir Text Search 是免费的吗?
是的,Dir Text Search 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Dir Text Search 支持哪些平台?
Dir Text Search 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Dir Text Search?
由 TryLoveCatch(@trylovecatch)开发并维护,当前版本 v1.1.0。
推荐 Skills