From bc1a005885021ad04fdf8b60c3e82cb3b5f74b15 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 31 Jul 2026 13:00:09 +0800 Subject: [PATCH] docs: fix plugindev install endpoint and build output; examples table; fix NewPluginFactory in bridge template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - README 构建与安装:输出目录为 dist/,安装端点为 pluginmgr POST /plugins(JSON 或 raw body),删除不存在的 /api/plugins/install - 示例表:weather/luademo 新增、qq 更新 17 工具(补入 2b54814 未提交部分) - templates.go: go_init_plugin 调用 NewPluginFactory(模板插件仅导出该函数) --- README.md | 49 ++++++++++++++++++++---------------- README_EN.md | 45 ++++++++++++++++++++------------- tools/plugindev/templates.go | 4 +-- 3 files changed, 58 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index c00f77e..78c7fc3 100644 --- a/README.md +++ b/README.md @@ -270,22 +270,23 @@ enabled := sdk.AutoRestart() ## 示例插件 -| 插件 | 说明 | -|------|------| -| a2a | Agent-to-Agent 协议通信 | -| ai_image | AI 图片生成 | -| bili | Bilibili 视频下载 | -| browser | 网络搜索、网页抓取、浏览器渲染 | -| calendar | 日历管理 | -| editdoc | 文档编辑 | -| files | 文件管理 | -| memo | 备忘录 | -| music | 音乐播放 | -| ocr | 光学字符识别 | -| qq | QQ 消息集成(NapCat webhook,15 个工具) | -| rss | RSS 订阅 | -| sanitizer | 内容清洗/安全过滤 | -| weather | 天气查询(wttr.in) | +| 插件 | 类型 | 说明 | +|------|------|------| +| [weather](example/weather) | Go | 天气查询(wttr.in),演示 NoMemory/Cleaner/阶段钩子/通道/文本记忆 | +| [luademo](example/luademo) | Lua | Lua 全功能示例,覆盖 v0.8.0 Lua SDK 全部 API 面 | +| [qq](example/qq) | Go | QQ 消息集成(NapCat),17 个工具,输入/输出通道完整对接 | +| [a2a](example/a2a) | Go | Agent-to-Agent 协议通信 | +| [ai_image](example/ai_image) | Go | AI 图片生成 | +| [bili](example/bili) | Go | Bilibili 视频下载 | +| [browser](example/browser) | Go | 网络搜索、网页抓取、浏览器渲染 | +| [calendar](example/calendar) | Go | 日历管理 | +| [editdoc](example/editdoc) | Go | 文档编辑 | +| [files](example/files) | Go | 文件管理 | +| [memo](example/memo) | Go | 备忘录(PreAction 注入 + 定时提醒) | +| [music](example/music) | Go | 音乐播放 | +| [ocr](example/ocr) | Go | 光学字符识别 | +| [rss](example/rss) | Go | RSS 订阅 | +| [sanitizer](example/sanitizer) | Go | 内容清洗/安全过滤 | ## 构建与安装 @@ -295,15 +296,21 @@ enabled := sdk.AutoRestart() plugindev build ``` -输出 `.hmap` 包到项目目录。 +输出 `.hmap` 包到 `dist/` 目录(默认 bundle 多平台合集;单平台构建使用 `plugindev build --no-bundle`)。 ### 安装 -通过 pluginmgr HTTP API 安装: +通过 pluginmgr HTTP API 安装(端口默认 9876,仅监听 127.0.0.1,无鉴权): ```bash -curl -X POST http://:/api/plugins/install \ - -F "package=@my-plugin.hmap" +# 本地路径 +curl -X POST http://127.0.0.1:9876/plugins \ + -H "Content-Type: application/json" \ + -d '{"path": "/path/to/my-plugin.hmap"}' + +# 直接上传二进制 +curl -X POST http://127.0.0.1:9876/plugins \ + --data-binary @dist/my-plugin.hmap ``` -或手动将 `.hmap` 放入插件目录后重启平台。 +或通过 WebUI 插件管理页面上传,也可手动将 `.hmap` 放入插件目录后重启平台。 diff --git a/README_EN.md b/README_EN.md index 4995aaa..1f13a67 100644 --- a/README_EN.md +++ b/README_EN.md @@ -232,18 +232,23 @@ Internal plugins (platform built-in) have full SDK access including SocialAPI wr ## Example Plugins -| Plugin | Description | -|--------|-------------| -| a2a | Agent-to-Agent protocol communication | -| bili | Bilibili data fetching | -| editdoc | Document editing | -| files | File management | -| memo | Memo/notes | -| ocr | Optical character recognition | -| qq | QQ messaging integration | -| sanitizer | Content sanitization/safety filtering | -| web | Web browsing and interaction | -| webfetch | Web content fetching | +| Plugin | Type | Description | +|--------|------|-------------| +| [weather](example/weather) | Go | Weather queries (wttr.in); demonstrates NoMemory/Cleaner/stage hooks/channels/text memory | +| [luademo](example/luademo) | Lua | Full-featured Lua example covering the whole v0.8.0 Lua SDK surface | +| [qq](example/qq) | Go | QQ messaging integration (NapCat), 17 tools, full input/output channel wiring | +| [a2a](example/a2a) | Go | Agent-to-Agent protocol communication | +| [ai_image](example/ai_image) | Go | AI image generation | +| [bili](example/bili) | Go | Bilibili video downloading | +| [browser](example/browser) | Go | Web search, page fetching, browser rendering | +| [calendar](example/calendar) | Go | Calendar management | +| [editdoc](example/editdoc) | Go | Document editing | +| [files](example/files) | Go | File management | +| [memo](example/memo) | Go | Memos (PreAction injection + scheduled reminders) | +| [music](example/music) | Go | Music playback | +| [ocr](example/ocr) | Go | Optical character recognition | +| [rss](example/rss) | Go | RSS subscriptions | +| [sanitizer](example/sanitizer) | Go | Content sanitization / safety filtering | ## Building & Installing @@ -253,15 +258,21 @@ Internal plugins (platform built-in) have full SDK access including SocialAPI wr plugindev build ``` -Outputs a `.hmap` package to the project directory. +Outputs a `.hmap` package to the `dist/` directory (default is the multi-platform bundle; use `plugindev build --no-bundle` for a single-target build). ### Install -Via pluginmgr HTTP API: +Via the pluginmgr HTTP API (default port 9876, listening on 127.0.0.1 only, no auth): ```bash -curl -X POST http://:/api/plugins/install \ - -F "package=@my-plugin.hmap" +# Local path +curl -X POST http://127.0.0.1:9876/plugins \ + -H "Content-Type: application/json" \ + -d '{"path": "/path/to/my-plugin.hmap"}' + +# Upload binary directly +curl -X POST http://127.0.0.1:9876/plugins \ + --data-binary @dist/my-plugin.hmap ``` -Or manually place the `.hmap` in the plugin directory and restart the platform. +Or upload via the WebUI plugin management page, or manually place the `.hmap` in the plugin directory and restart the platform. diff --git a/tools/plugindev/templates.go b/tools/plugindev/templates.go index 42f18f2..3285a10 100644 --- a/tools/plugindev/templates.go +++ b/tools/plugindev/templates.go @@ -615,9 +615,9 @@ func (d *dispatchSettings) Plugins() []string { //export go_init_plugin func go_init_plugin(name *C.char, configJSON *C.char, errorOut **C.char) C.int { - plg, err := NewPlugin(C.GoString(name), nil) + plg, err := NewPluginFactory(C.GoString(name), nil) if err != nil || plg == nil { - if err != nil { *errorOut = C.CString(err.Error()) } else { *errorOut = C.CString("NewPlugin returned nil") } + if err != nil { *errorOut = C.CString(err.Error()) } else { *errorOut = C.CString("NewPluginFactory returned nil") } return 1 } mu.Lock(); currentPlg = plg; mu.Unlock()