{"id":61,"date":"2026-03-21T22:47:15","date_gmt":"2026-03-21T14:47:15","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/cli-hooks\/"},"modified":"2026-03-21T23:09:26","modified_gmt":"2026-03-21T15:09:26","slug":"cli-hooks","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/cli-hooks\/","title":{"rendered":"hooks"},"content":{"rendered":"<h1>hooks<\/h1>\n<h1><code>openclaw hooks<\/code><\/h1>\n<p>\u7ba1\u7406\u667a\u80fd\u4f53\u94a9\u5b50\uff08\u9488\u5bf9 <code>\/new<\/code>\u3001<code>\/reset<\/code> \u7b49\u547d\u4ee4\u4ee5\u53ca Gateway \u7f51\u5173\u542f\u52a8\u7684\u4e8b\u4ef6\u9a71\u52a8\u81ea\u52a8\u5316\uff09\u3002<\/p>\n<p>\u76f8\u5173\u5185\u5bb9\uff1a<\/p>\n<ul>\n<li>\u94a9\u5b50\uff1a<a href=\"\/automation\/hooks\">\u94a9\u5b50<\/a><\/li>\n<li>\u63d2\u4ef6\u94a9\u5b50\uff1a<a href=\"\/tools\/plugin#plugin-hooks\">\u63d2\u4ef6<\/a><\/li>\n<\/ul>\n<h2>\u5217\u51fa\u6240\u6709\u94a9\u5b50<\/h2>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw hooks list<\/p>\n<pre><code>\n\u5217\u51fa\u4ece\u5de5\u4f5c\u533a\u3001\u6258\u7ba1\u76ee\u5f55\u548c\u5185\u7f6e\u76ee\u5f55\u4e2d\u53d1\u73b0\u7684\u6240\u6709\u94a9\u5b50\u3002\n\n**\u9009\u9879\uff1a**\n\n* `--eligible`\uff1a\u4ec5\u663e\u793a\u7b26\u5408\u6761\u4ef6\u7684\u94a9\u5b50\uff08\u6ee1\u8db3\u8981\u6c42\uff09\n* `--json`\uff1a\u4ee5 JSON \u683c\u5f0f\u8f93\u51fa\n* `-v, --verbose`\uff1a\u663e\u793a\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u7f3a\u5931\u7684\u8981\u6c42\n\n**\u793a\u4f8b\u8f93\u51fa\uff1a**\n\n<\/code><\/pre>\n<p>Hooks (3\/3 ready)<\/p>\n<p>Ready:<br \/>\n  \ud83d\ude80 boot-md \u2713 &#8211; Run BOOT.md on gateway startup<br \/>\n  \ud83d\udcdd command-logger \u2713 &#8211; Log all command events to a centralized audit file<br \/>\n  \ud83d\udcbe session-memory \u2713 &#8211; Save session context to memory when \/new command is issued<\/p>\n<pre><code>\n**\u793a\u4f8b\uff08\u8be6\u7ec6\u6a21\u5f0f\uff09\uff1a**\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw hooks list --verbose\n<\/code><\/pre>\n<p>\u663e\u793a\u4e0d\u7b26\u5408\u6761\u4ef6\u7684\u94a9\u5b50\u7f3a\u5931\u7684\u8981\u6c42\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff08JSON\uff09\uff1a<\/strong><\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw hooks list &#8211;json<\/p>\n<pre><code>\n\u8fd4\u56de\u7ed3\u6784\u5316 JSON\uff0c\u4f9b\u7a0b\u5e8f\u5316\u4f7f\u7528\u3002\n\n## \u83b7\u53d6\u94a9\u5b50\u4fe1\u606f\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw hooks info &lt;name&gt;\n<\/code><\/pre>\n<p>\u663e\u793a\u7279\u5b9a\u94a9\u5b50\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<p><strong>\u53c2\u6570\uff1a<\/strong><\/p>\n<ul>\n<li><code>&lt;name&gt;<\/code>\uff1a\u94a9\u5b50\u540d\u79f0\uff08\u4f8b\u5982 <code>session-memory<\/code>\uff09<\/li>\n<\/ul>\n<p><strong>\u9009\u9879\uff1a<\/strong><\/p>\n<ul>\n<li><code>--json<\/code>\uff1a\u4ee5 JSON \u683c\u5f0f\u8f93\u51fa<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw hooks info session-memory<\/p>\n<pre><code>\n**\u8f93\u51fa\uff1a**\n\n<\/code><\/pre>\n<p>\ud83d\udcbe session-memory \u2713 Ready<\/p>\n<p>Save session context to memory when \/new command is issued<\/p>\n<p>Details:<br \/>\n  Source: openclaw-bundled<br \/>\n  Path: \/path\/to\/openclaw\/hooks\/bundled\/session-memory\/HOOK.md<br \/>\n  Handler: \/path\/to\/openclaw\/hooks\/bundled\/session-memory\/handler.ts<br \/>\n  Homepage: https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/automation-hooks\/#session-memory<br \/>\n  Events: command:new<\/p>\n<p>Requirements:<br \/>\n  Config: \u2713 workspace.dir<\/p>\n<pre><code>\n## \u68c0\u67e5\u94a9\u5b50\u8d44\u683c\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw hooks check\n<\/code><\/pre>\n<p>\u663e\u793a\u94a9\u5b50\u8d44\u683c\u72b6\u6001\u6458\u8981\uff08\u6709\u591a\u5c11\u5df2\u5c31\u7eea\uff0c\u6709\u591a\u5c11\u672a\u5c31\u7eea\uff09\u3002<\/p>\n<p><strong>\u9009\u9879\uff1a<\/strong><\/p>\n<ul>\n<li><code>--json<\/code>\uff1a\u4ee5 JSON \u683c\u5f0f\u8f93\u51fa<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\u8f93\u51fa\uff1a<\/strong><\/p>\n<pre><code>Hooks Status\n\nTotal hooks: 4\nReady: 4\nNot ready: 0\n<\/code><\/pre>\n<h2>\u542f\u7528\u94a9\u5b50<\/h2>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw hooks enable <\/p>\n<pre><code>\n\u901a\u8fc7\u5c06\u7279\u5b9a\u94a9\u5b50\u6dfb\u52a0\u5230\u914d\u7f6e\uff08`~\/.openclaw\/config.json`\uff09\u6765\u542f\u7528\u5b83\u3002\n\n**\u6ce8\u610f\uff1a** \u7531\u63d2\u4ef6\u7ba1\u7406\u7684\u94a9\u5b50\u5728 `openclaw hooks list` \u4e2d\u663e\u793a `plugin:&lt;id&gt;`\uff0c\n\u65e0\u6cd5\u5728\u6b64\u5904\u542f\u7528\/\u7981\u7528\u3002\u8bf7\u6539\u4e3a\u542f\u7528\/\u7981\u7528\u8be5\u63d2\u4ef6\u3002\n\n**\u53c2\u6570\uff1a**\n\n* `&lt;name&gt;`\uff1a\u94a9\u5b50\u540d\u79f0\uff08\u4f8b\u5982 `session-memory`\uff09\n\n**\u793a\u4f8b\uff1a**\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw hooks enable session-memory\n<\/code><\/pre>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<pre><code>\u2713 Enabled hook: \ud83d\udcbe session-memory\n<\/code><\/pre>\n<p><strong>\u6267\u884c\u64cd\u4f5c\uff1a<\/strong><\/p>\n<ul>\n<li>\u68c0\u67e5\u94a9\u5b50\u662f\u5426\u5b58\u5728\u4e14\u7b26\u5408\u6761\u4ef6<\/li>\n<li>\u5728\u914d\u7f6e\u4e2d\u66f4\u65b0 <code>hooks.internal.entries.&lt;name&gt;.enabled = true<\/code><\/li>\n<li>\u5c06\u914d\u7f6e\u4fdd\u5b58\u5230\u78c1\u76d8<\/li>\n<\/ul>\n<p><strong>\u542f\u7528\u540e\uff1a<\/strong><\/p>\n<ul>\n<li>\u91cd\u542f Gateway \u7f51\u5173\u4ee5\u91cd\u65b0\u52a0\u8f7d\u94a9\u5b50\uff08macOS \u4e0a\u91cd\u542f\u83dc\u5355\u680f\u5e94\u7528\uff0c\u6216\u5728\u5f00\u53d1\u73af\u5883\u4e2d\u91cd\u542f Gateway \u7f51\u5173\u8fdb\u7a0b\uff09\u3002<\/li>\n<\/ul>\n<h2>\u7981\u7528\u94a9\u5b50<\/h2>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw hooks disable <\/p>\n<pre><code>\n\u901a\u8fc7\u66f4\u65b0\u914d\u7f6e\u6765\u7981\u7528\u7279\u5b9a\u94a9\u5b50\u3002\n\n**\u53c2\u6570\uff1a**\n\n* `&lt;name&gt;`\uff1a\u94a9\u5b50\u540d\u79f0\uff08\u4f8b\u5982 `command-logger`\uff09\n\n**\u793a\u4f8b\uff1a**\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw hooks disable command-logger\n<\/code><\/pre>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<pre><code>\u23f8 Disabled hook: \ud83d\udcdd command-logger\n<\/code><\/pre>\n<p><strong>\u7981\u7528\u540e\uff1a<\/strong><\/p>\n<ul>\n<li>\u91cd\u542f Gateway \u7f51\u5173\u4ee5\u91cd\u65b0\u52a0\u8f7d\u94a9\u5b50<\/li>\n<\/ul>\n<h2>\u5b89\u88c5\u94a9\u5b50<\/h2>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw hooks install <\/p>\n<pre><code>\n\u4ece\u672c\u5730\u6587\u4ef6\u5939\/\u538b\u7f29\u5305\u6216 npm \u5b89\u88c5\u94a9\u5b50\u5305\u3002\n\n**\u6267\u884c\u64cd\u4f5c\uff1a**\n\n* \u5c06\u94a9\u5b50\u5305\u590d\u5236\u5230 `~\/.openclaw\/hooks\/&lt;id&gt;`\n* \u5728 `hooks.internal.entries.*` \u4e2d\u542f\u7528\u5df2\u5b89\u88c5\u7684\u94a9\u5b50\n* \u5728 `hooks.internal.installs` \u4e0b\u8bb0\u5f55\u5b89\u88c5\u4fe1\u606f\n\n**\u9009\u9879\uff1a**\n\n* `-l, --link`\uff1a\u94fe\u63a5\u672c\u5730\u76ee\u5f55\u800c\u4e0d\u662f\u590d\u5236\uff08\u5c06\u5176\u6dfb\u52a0\u5230 `hooks.internal.load.extraDirs`\uff09\n\n**\u652f\u6301\u7684\u538b\u7f29\u5305\u683c\u5f0f\uff1a** `.zip`\u3001`.tgz`\u3001`.tar.gz`\u3001`.tar`\n\n**\u793a\u4f8b\uff1a**\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n# \u672c\u5730\u76ee\u5f55\nopenclaw hooks install .\/my-hook-pack\n\n# \u672c\u5730\u538b\u7f29\u5305\nopenclaw hooks install .\/my-hook-pack.zip\n\n# NPM \u5305\nopenclaw hooks install @openclaw\/my-hook-pack\n\n# \u94fe\u63a5\u672c\u5730\u76ee\u5f55\u800c\u4e0d\u590d\u5236\nopenclaw hooks install -l .\/my-hook-pack\n<\/code><\/pre>\n<h2>\u66f4\u65b0\u94a9\u5b50<\/h2>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw hooks update<br \/>\nopenclaw hooks update &#8211;all<\/p>\n<pre><code>\n\u66f4\u65b0\u5df2\u5b89\u88c5\u7684\u94a9\u5b50\u5305\uff08\u4ec5\u9650 npm \u5b89\u88c5\uff09\u3002\n\n**\u9009\u9879\uff1a**\n\n* `--all`\uff1a\u66f4\u65b0\u6240\u6709\u5df2\u8ddf\u8e2a\u7684\u94a9\u5b50\u5305\n* `--dry-run`\uff1a\u663e\u793a\u5c06\u8981\u8fdb\u884c\u7684\u66f4\u6539\uff0c\u4f46\u4e0d\u5199\u5165\n\n## \u5185\u7f6e\u94a9\u5b50\n\n### session-memory\n\n\u5728\u4f60\u6267\u884c `\/new` \u65f6\u5c06\u4f1a\u8bdd\u4e0a\u4e0b\u6587\u4fdd\u5b58\u5230\u8bb0\u5fc6\u4e2d\u3002\n\n**\u542f\u7528\uff1a**\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw hooks enable session-memory\n<\/code><\/pre>\n<p><strong>\u8f93\u51fa\uff1a<\/strong> <code>~\/.openclaw\/workspace\/memory\/YYYY-MM-DD-slug.md<\/code><\/p>\n<p><strong>\u53c2\u89c1\uff1a<\/strong> <a href=\"\/automation\/hooks#session-memory\">session-memory \u6587\u6863<\/a><\/p>\n<h3>command-logger<\/h3>\n<p>\u5c06\u6240\u6709\u547d\u4ee4\u4e8b\u4ef6\u8bb0\u5f55\u5230\u96c6\u4e2d\u7684\u5ba1\u8ba1\u6587\u4ef6\u4e2d\u3002<\/p>\n<p><strong>\u542f\u7528\uff1a<\/strong><\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw hooks enable command-logger<\/p>\n<pre><code>\n**\u8f93\u51fa\uff1a** `~\/.openclaw\/logs\/commands.log`\n\n**\u67e5\u770b\u65e5\u5fd7\uff1a**\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n# \u6700\u8fd1\u7684\u547d\u4ee4\ntail -n 20 ~\/.openclaw\/logs\/commands.log\n\n# \u683c\u5f0f\u5316\u8f93\u51fa\ncat ~\/.openclaw\/logs\/commands.log | jq .\n\n# \u6309\u64cd\u4f5c\u8fc7\u6ee4\ngrep '&quot;action&quot;:&quot;new&quot;' ~\/.openclaw\/logs\/commands.log | jq .\n<\/code><\/pre>\n<p><strong>\u53c2\u89c1\uff1a<\/strong> <a href=\"\/automation\/hooks#command-logger\">command-logger \u6587\u6863<\/a><\/p>\n<h3>boot-md<\/h3>\n<p>\u5728 Gateway \u7f51\u5173\u542f\u52a8\u65f6\uff08\u6e20\u9053\u542f\u52a8\u540e\uff09\u8fd0\u884c <code>BOOT.md<\/code>\u3002<\/p>\n<p><strong>\u4e8b\u4ef6<\/strong>\uff1a<code>gateway:startup<\/code><\/p>\n<p><strong>\u542f\u7528<\/strong>\uff1a<\/p>\n<p><code>bash  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}<br \/>\nopenclaw hooks enable boot-md<\/code><\/p>\n<p><strong>\u53c2\u89c1\uff1a<\/strong> <a href=\"\/automation\/hooks#boot-md\">boot-md \u6587\u6863<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>hooks openclaw hooks \u7ba1\u7406\u667a\u80fd\u4f53\u94a9\u5b50\uff08\u9488\u5bf9 \/new\u3001\/reset \u7b49\u547d\u4ee4\u4ee5\u53ca Gatew [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":2,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":764,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions\/764"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}