{"skill":{"slug":"chinese-openclaw-plugin","displayName":"中文 OpenClaw 插件","summary":"创建和管理 OpenClaw 插件使用 before_prompt_build hook。触发词：'create plugin'、'add hook'、'inject context'、'modify gateway'。适用于使用 hook 系统扩展 OpenClaw 功能。","description":"---\nname: openclaw-plugin\ndescription: \"创建和管理 OpenClaw 插件使用 before_prompt_build hook。触发词：'create plugin'、'add hook'、'inject context'、'modify gateway'。适用于使用 hook 系统扩展 OpenClaw 功能。\"\n---\n\n# 🔌 OpenClaw 插件技能\n\n> 使用 before_prompt_build hook 创建和管理插件\n\n| 信息 | 值 |\n|------|-----|\n| **版本** | 1.0.0 — 2026-05-07 |\n| **状态** | 运行中 |\n\n---\n\n## 1. 目的和范围\n\n### 目标\n\n使用 OpenClaw hook 系统创建和管理插件。\n\n### 使用时机\n\n| 触发器 | 行动 |\n|--------|------|\n| \"创建插件\" | 初始化新插件 |\n| \"添加 hook\" | 注册新 hook |\n| \"注入上下文\" | 使用 hook 注入上下文 |\n| \"修改网关\" | 配置网关 |\n\n---\n\n## 2. Hook 系统\n\n### 可用 Hooks\n\n| Hook | 触发时机 | 用途 |\n|------|----------|------|\n| before_prompt_build | 构建提示前 | 注入上下文、修改消息 |\n| after_response | 响应后 | 日志、监控 |\n| on_error | 错误时 | 错误处理 |\n\n### Hook 位置\n\n```\n~/.openclaw/plugins/<plugin-name>/\n├── plugin.json       # 插件配置\n├── hooks/\n│   └── before_prompt_build.js\n└── README.md\n```\n\n---\n\n## 3. 创建插件\n\n### 步骤 1：创建目录\n\n```bash\nmkdir -p ~/.openclaw/plugins/<plugin-name>/hooks\n```\n\n### 步骤 2：创建 plugin.json\n\n```json\n{\n  \"name\": \"plugin-name\",\n  \"version\": \"1.0.0\",\n  \"hooks\": [\n    {\n      \"name\": \"before_prompt_build\",\n      \"file\": \"hooks/before_prompt_build.js\"\n    }\n  ],\n  \"description\": \"插件描述\"\n}\n```\n\n### 步骤 3：创建 Hook 文件\n\n```javascript\n// hooks/before_prompt_build.js\nmodule.exports = async function(context) {\n  // 添加上下文\n  context.systemMessage = \"你的系统消息\";\n  \n  // 或修改用户消息\n  // context.messages[0].content = \"修改后的内容\";\n  \n  return context;\n};\n```\n\n---\n\n## 4. 注册插件\n\n```bash\n# 启用插件\nopenclaw plugin enable <plugin-name>\n\n# 禁用插件\nopenclaw plugin disable <plugin-name>\n\n# 列出所有插件\nopenclaw plugin list\n```\n\n---\n\n## 5. 插件示例\n\n### 上下文注入插件\n\n```javascript\n// hooks/before_prompt_build.js\nmodule.exports = async function(context) {\n  // 添加时间上下文\n  const now = new Date();\n  context.systemMessage += `\\n当前时间：${now.toISOString()}`;\n  \n  return context;\n};\n```\n\n### 消息修改插件\n\n```javascript\nmodule.exports = async function(context) {\n  // 检查用户消息\n  if (context.messages[0].content.includes(\"密码\")) {\n    // 添加安全警告\n    context.messages[0].content += \"\\n\\n⚠️ 安全提示：请勿分享敏感信息\";\n  }\n  \n  return context;\n};\n```\n\n---\n\n## 6. 边缘情况\n\n| 情况 | 处理方法 |\n|------|----------|\n| Hook 抛出错误 | 记录错误，继续执行 |\n| 插件冲突 | 禁用冲突插件 |\n| Hook 无效 | 检查语法和路径 |\n| 插件加载失败 | 检查 plugin.json 格式 |\n\n---\n\n_In Altum Per Plugin._\n🔌 OpenClaw 插件 v1.0","topics":["Prompt"],"tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":342,"installsAllTime":12,"installsCurrent":0,"stars":0,"versions":1},"createdAt":1778204290002,"updatedAt":1778492876503},"latestVersion":{"version":"1.0.0","createdAt":1778204290002,"changelog":"中文版本首次发布","license":"MIT-0"},"metadata":null,"owner":{"handle":"kofna3369","userId":"s170vjwkh0tbnpbsmvn0nj60h183gysr","displayName":"Kofna3369","image":"https://avatars.githubusercontent.com/u/110220070?v=4"},"moderation":null}