技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
directory-index【数据与研究】Generate local directory indexes as Markdown or interactive HTML. Use when the user asks to create a folder index, file list, searchable/collapsible directory page, clickable local file opener, Finder/Explorer reveal page, data room index, due diligence file index, or structured inventory of a local directory. Supports Markdown output, HTML with loca…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
对任意本地目录生成文件索引。支持两种输出模式,兼容 macOS / Windows / Linux:
.md 文件,按目录层级递进标题(##→###→####),适合嵌入笔记/文档/Wiki.html 页面 + 本地 HTTP 服务器,可折叠树形结构,点击文件名用系统默认应用打开,支持搜索过滤ask_followup_question 询问用户:
python3 "$SKILL_DIR/scripts/generate_index.py" "/path/to/target/directory" --format md
输出:目标目录下生成 INDEX_<目录名>.md
python3 "$SKILL_DIR/scripts/generate_index.py" "/path/to/target/directory" --format html
输出:目标目录下生成 INDEX_<目录名>.html + INDEX_<目录名>_server.py,自动启动服务器并打开浏览器
--format(必填):输出格式,md 或 html--max-depth(可选):最大递归深度,默认不限制。深层目录推荐 --max-depth 3--port(可选,仅 html):服务器端口,默认 8427--no-open(可选,仅 html):不自动打开浏览器--tags(可选):自定义标签规则 JSON,格式见下方扫描时会自动跳过 node_modules、.git、__pycache__、venv、dist、build、.cache 等大型/无意义目录。所有跳过信息都会明确提示:
跳过原因分两类:
node_modules、.git 等已知无意义目录--max-depth 设置而未展开的子目录面对多层嵌套 + 数百文件的复杂目录,做了以下优化:
node_modules、.git、__pycache__、venv、dist、build、.cache 等常见大型/无意义目录--max-depth 控制递归深度,避免过深的目录树10.0 排在 2.0 前面##/###/#### 区分层级,深层文件自动缩进示例:
# 深层项目目录,限制 3 层
python3 "$SKILL_DIR/scripts/generate_index.py" "/path/to/project" --format html --max-depth 3
脚本兼容 macOS / Windows / Linux:
| 功能 | macOS | Windows | Linux |
|---|---|---|---|
| 打开文件 | open | os.startfile | xdg-open |
| 定位文件 | open -R | explorer /select, | xdg-open (打开所在目录) |
| 打开浏览器 | open | start | xdg-open |
| 杀端口进程 | lsof + kill | netstat + taskkill | lsof + kill |
HTML 模式生成的服务器脚本(INDEX_xxx_server.py)同样跨平台,可在任意系统上独立运行。
通过 --tags 参数为特定文件或目录添加标签:
python3 "$SKILL_DIR/scripts/generate_index.py" "/path/to/dir" \
--format html \
--tags '{"readonly": ["report_*.xlsx", "*/archive/*"], "main": ["main_*.xlsx"], "backup": ["*backup*"]}'
支持的标签类型:
readonly — 只读main — 主文件backup — 备份pending — 待确认INDEX_<目录名>.md 到目标目录INDEX_<目录名>.html 到目标目录/health(状态检查)、/open?path=xxx(打开文件)和 /reveal?path=xxx(资源管理器/Finder 定位)http://localhost:<port>/file:// 直接打开 HTML,页面会在服务器已运行时自动跳转到本地服务器;服务器未运行时显示明确提示http.server,无需 pip install)面向大型资料室、尽调文件夹、项目交割材料等目录时,优先使用 HTML 模式。脚本已针对实际使用中常见问题做了防护:默认折叠大型目录树、自然排序编号目录、点击文件名不使用 <a> 默认导航、检测 file:// 误打开并自动跳转服务器地址、服务器返回 no-cache 头避免旧页面缓存。
http://localhost:<port>/ 使用,不能直接依赖 file:// 本地打开;脚本会自动打开服务器地址INDEX_<目录名>_server.pynetstat -ano | findstr :端口号 → taskkill /F /PID <pid>INDEX_<目录名>.md — 索引页面INDEX_<目录名>.html — 索引页面INDEX_<目录名>_server.py — 服务器脚本(可独立启动:python3 INDEX_xxx_server.py)