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

1.3 KiB
Raw Permalink Blame History

第三方插件目录

将插件文件夹放入此目录,运行代码生成器即可自动注册——无需手动编辑 plugins.json

目录结构

plugins/
  my-hello/
    go.mod          # Go 模块声明(module xxx
    plugin.json     # 插件声明(name, struct
    main.go         # 插件入口
    ...

注册(2 步)

1. 放入插件:将插件目录复制到 backend/plugins/ 下。

2. 运行生成器

cd backend/ai-core/cmd && go run gen_plugins.go

生成器会自动:

  • 扫描 plugins/ 下所有子目录
  • 读取每个目录的 plugin.jsongo.mod
  • 生成 plugins_gen.go(含 import + 注册代码)
  • 自动向 go.mod 添加 require + replace 指令

3. 重新编译

cd backend/ai-core && go build -o main.exe ./cmd/

或使用 go generate

cd backend/ai-core && go generate ./cmd/...

plugin.json 格式

{
  "name": "my-hello",
  "struct": "HelloPlugin"
}
字段 必填 说明
name 插件唯一名称
struct 插件结构体名(实现 Plugin 接口的那个类型)

import 路径自动从 go.modmodule 声明读取,无需手写。

插件开发

详见 docs/api/plugin-development.md