名称: project-tree
描述: 生成 ~/projects 文件夹的可视化目录树,并将结果更新到 MEMORY.md 中。当用户想要查看、更新或生成项目树结构,或提及“项目树”、“树状视图”、“文件夹结构”或“显示我的项目”时使用。
生成 ~/projects 目录的可视化树状结构,并自动将当前的项目组织情况更新到 MEMORY.md 中。此树状图仅显示文件夹和 .md 文件,并对连续编号的项进行智能分组。
运行树状图生成脚本:
node ~/clawd/skills/project-tree/scripts/project-tree.js
或使用便捷包装脚本:
~/clawd/scripts/update-tree
script1-video, script2-video...),并将其折叠为 script[1-28]-video/ (28 项) 的形式。PROJECT_TREE 部分。编辑 scripts/project-tree.js 中的以下值:
MAX_DEPTH:要显示的目录层级数(默认值:3)。EXCLUDE_DIRS:要跳过的目录(如 node_modules, .git 等)。ROOT_DIR:要扫描的根目录(默认值:~/projects)。你可以将项目树更新自动化,使其在每次会话执行 /reset 命令时运行。
在你的 clawdbot.json 中添加:
{
"hooks": {
"internal": {
"enabled": true
}
}
}
创建 ~/.clawdbot/hooks/reset-project-tree/HOOK.md:
---
**名称:** reset-project-tree
**描述:** "在会话重置时生成项目树"
**元数据:** {"clawdbot":{"emoji":"🌳","events":["command:reset"],"requires":{"bins":["node"]}}}
---
当执行 /reset 命令时生成项目树。
创建 ~/.clawdbot/hooks/reset-project-tree/handler.ts:
import { execSync } from 'child_process';
import type { HookHandler } from '../../../src/hooks/hooks.js';
const handler: HookHandler = async (event) => {
if (event.type !== 'command' || event.action !== 'reset') return;
try {
const scriptPath = `${event.context.workspaceDir}/skills/project-tree/scripts/project-tree.js`;
execSync(`node ${scriptPath}`, { cwd: event.context.workspaceDir, stdio: 'pipe' });
console.log('[reset-project-tree] Updated');
} catch (err) {
console.error('[reset-project-tree] Failed:', err instanceof Error ? err.message : String(err));
}
};
export default handler;
clawdbot hooks enable reset-project-tree
clawdbot gateway restart
project-tree.js - 主树状图生成脚本,包含智能分组逻辑。