This repository has been archived on 2026-08-12. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Cyrene/backend/plugins/README.md
T

55 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 第三方插件目录
在此目录下创建子文件夹,每个文件夹一个插件。
## 目录结构
```
plugins/
my-hello/
plugin.json # 插件声明
main.go # 插件入口
...
```
## 注册插件(3 步)
Go 不支持运行时动态加载,需要通过代码生成注册:
**1. 编辑 `ai-core/plugins.json`**,添加插件条目:
```json
{ "name": "my-hello", "import": "你的模块路径", "struct": "HelloPlugin" }
```
**2. 运行代码生成器**
```bash
cd backend/ai-core && go run cmd/gen_plugins.go
```
这会生成 `cmd/plugins_gen.go`,自动包含所有插件的 import 和注册代码。
**3. 重新编译 ai-core**
```bash
cd backend/ai-core && go build -o main.exe ./cmd/
```
## plugin.json 格式
每个插件目录下的声明文件:
```json
{
"name": "my-hello",
"version": "1.0.0",
"author": "your-name",
"description": "我的第一个插件"
}
```
## 插件开发
详见 [docs/api/plugin-development.md](../../docs/api/plugin-development.md)