← Back to Skills Marketplace
trylovecatch

Dir Text Search

by TryLoveCatch · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ✓ Security Clean
89
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install dir-text-search
Description
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...
README (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
Usage Guidance
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.
Capability Analysis
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.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install dir-text-search
  3. After installation, invoke the skill by name or use /dir-text-search
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
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.
Metadata
Slug dir-text-search
Version 1.1.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is 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... It is an AI Agent Skill for Claude Code / OpenClaw, with 89 downloads so far.

How do I install Dir Text Search?

Run "/install dir-text-search" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Dir Text Search free?

Yes, Dir Text Search is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Dir Text Search support?

Dir Text Search is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Dir Text Search?

It is built and maintained by TryLoveCatch (@trylovecatch); the current version is v1.1.0.

💬 Comments