钩子
“openclaw hooks”(代理挂钩)的 CLI 参考
列出所有钩子
openclaw hooks list
列出从工作区、托管目录和捆绑目录中发现的所有挂钩。
选项:
- ''--eligible'':仅显示符合条件的挂钩(满足要求)
- ''--json'':输出为 JSON
- ''-v, --verbose'':显示详细信息,包括缺少的要求
输出示例:
示例(详细):
Hooks (4/4 ready) Ready: 🚀 boot-md ✓ - Run BOOT.md on gateway startup 📝 command-logger ✓ - Log all command events to a centralized audit file 💾 session-memory ✓ - Save session context to memory when /new command is issued 😈 soul-evil ✓ - Swap injected SOUL content during a purge window or by random chance
显示不合格挂钩的缺失要求。
openclaw hooks list --verbose
示例(JSON):
返回结构化 JSON 以供编程使用。
openclaw hooks list --json
ReferenceCliHooksPage step 01: P11
获取钩子信息
openclaw hooks info <name>
显示有关特定钩子的详细信息。
参数:
- ''<name>'': Hook name (e.g., ''session-memory'')
选项:
- ''--json'':输出为 JSON
openclaw hooks info session-memory
示例:
💾 session-memory ✓ Ready Save session context to memory when /new command is issued Details: Source: openclaw-bundled Path: /path/to/openclaw/hooks/bundled/session-memory/HOOK.md Handler: /path/to/openclaw/hooks/bundled/session-memory/handler.ts Homepage: https://docs.openclaw.ai/hooks#session-memory Events: command:new Requirements: Config: ✓ workspace.dir
检查 Hooks 资格
openclaw hooks check
显示挂钩资格状态摘要(准备就绪与未准备就绪的数量)。
选项:
- ''--json'':输出为 JSON
Hooks Status Total hooks: 4 Ready: 4 Not ready: 0
启用钩子
openclaw hooks enable <name>
通过将特定挂钩添加到您的配置 (''~/.openclaw/config.json'') 来启用它。
''Note:'' Hooks managed by plugins show ''plugin:<id>'' in ''openclaw hooks list'' and
无法在此处启用/禁用。而是启用/禁用插件。
参数:
- ''<name>'': Hook name (e.g., ''session-memory'')
openclaw hooks enable session-memory
示例:
✓ Enabled hook: 💾 session-memory
输出:
它的作用:
- 检查钩子是否存在并且符合条件
- Updates ''hooks.internal.entries.<name>.enabled = true'' in your configuration
- 将配置保存到磁盘
启用后:
禁用钩子
openclaw hooks disable <name>
通过更新您的配置来禁用特定的挂钩。
参数:
- ''<name>'': Hook name (e.g., ''command-logger'')
openclaw hooks disable command-logger
示例:
⏸ Disabled hook: 📝 command-logger
输出:
禁用后:
安装钩子
openclaw hooks install <path-or-spec>
从本地文件夹/存档或 npm 安装挂钩包。
它的作用:
- Copies hook package to ''~/.openclaw/hooks/<id>''
- 启用 ''hooks.internal.entries.*'' 中安装的挂钩
- 在 ''hooks.internal.installs'' 下记录安装
选项:
- ''-l, --link'':链接本地目录而不是复制(将其添加到 ''hooks.internal.load.extraDirs'')
''支持的档案:'' ''.zip''、''.tgz''、''.tar.gz''、''.tar''
openclaw hooks install ./my-hook-pack openclaw hooks install ./my-hook-pack.zip openclaw hooks install @openclaw/my-hook-pack openclaw hooks install -l ./my-hook-pack
更新挂钩
openclaw hooks update <id> openclaw hooks update --all
更新已安装的钩子包(仅限 npm 安装)。
选项:
- ''--all'':更新所有跟踪的钩子包
- ''--dry-run'':显示无需编写即可更改的内容
捆绑挂钩
#
会话内存
当您发出 ''/new'' 时,将会话上下文保存到内存中。
启用:
openclaw hooks enable session-memory
输出: ~/.openclaw/workspace/memory/YYYY-MM-DD-slug.md
参见: 会话内存文档
#
命令记录器
将所有命令事件记录到集中审核文件中。
启用:
openclaw hooks enable command-logger
输出: ~/.openclaw/logs/commands.log
查看日志:
tail -n 20 ~/.openclaw/logs/commands.log cat ~/.openclaw/logs/commands.log | jq . grep '"action":"new"' ~/.openclaw/logs/commands.log | jq .
参见: 命令记录器文档
###灵魂邪恶
在清除窗口期间或随机地用 ''SOUL_EVIL.md'' 交换注入的 ''SOUL_EVIL.md'' 内容。
openclaw hooks enable soul-evil
参见: 灵魂邪钩文档
#