Files
HomeAgent/internal/plugin/manifest.go
root 8cec92d947 feat: 路径配置化 + 裸二进制启动 + pluginmgr 内置插件
- types.go: 新增 PluginDirConfig 结构体嵌入 Config
- config/registry.go: 新增7个路径配置项 (core.plugin.dir 等) + ConfigDef 元数据
- cmd/homed/main.go: -data 默认自动检测二进制同级目录,使用 cfg.Plugin.Dir
- internal/plugins/pluginmgr/: 内置插件实现 (4工具 + HTTP API + 包校验)
- all.go: 注册 pluginmgr
- manifest.go: 扩展 PluginManifest 字段
- sdk/settings.go: RegisterDef / Defs 接口
- webui: 设置页自动发现 ConfigDef 元数据
- config/config.go, config/config.yaml: 清理 YAML 死代码
- sdk/plugin.go: IO 通道泛型化支持非文本类型
- waiter: CLI 支持 socket 发现和交互模式
2026-07-04 16:56:32 +08:00

43 lines
1.2 KiB
Go
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.

package plugin
import (
"encoding/json"
"os"
"path/filepath"
)
const PackageExt = ".hmap"
// PluginManifest 每个插件目录中的 plugin.json 元数据。
type PluginManifest struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
License string `json:"license,omitempty"`
Homepage string `json:"homepage,omitempty"`
Repository string `json:"repository,omitempty"`
Entry string `json:"entry"` // "plugin.so" | "main.lua" | "SKILL.md"
MinVersion string `json:"min_version,omitempty"`
Tags []string `json:"tags,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
}
func ReadManifest(dir string) (*PluginManifest, error) {
data, err := os.ReadFile(filepath.Join(dir, "plugin.json"))
if err != nil {
return nil, err
}
var m PluginManifest
if err := json.Unmarshal(data, &m); err != nil {
return nil, err
}
return &m, nil
}
// IsPluginDir 判断目录是否为有效的插件目录(包含 plugin.json
func IsPluginDir(dir string) bool {
_, err := os.Stat(filepath.Join(dir, "plugin.json"))
return err == nil
}