mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-22 09:58:06 +00:00
chore: replace hack with tools and remove obsolete artifacts
- Rename hack/ to tools/ for formal naming - Update plugin development and deployment script references - Remove obsolete DESIGN/MILESTONE/PLAN docs now superseded by docs/ - Remove abandoned internal/onebot implementation - Ignore stray local qq binary artifact
This commit is contained in:
21
tools/plugin-dev/templates/Makefile.tmpl
Normal file
21
tools/plugin-dev/templates/Makefile.tmpl
Normal file
@ -0,0 +1,21 @@
|
||||
# Build external Go plugin for HomeAgent
|
||||
# Usage: make # build plugin.so
|
||||
# make clean # remove plugin.so
|
||||
# make package # build + create .hmap package
|
||||
|
||||
PLUGIN_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
PROJECT_ROOT := $(realpath $(PLUGIN_DIR)../..)
|
||||
PLUGIN_NAME := $(notdir $(realpath $(PLUGIN_DIR)))
|
||||
|
||||
.PHONY: all clean package
|
||||
|
||||
all: plugin.so
|
||||
|
||||
plugin.so:
|
||||
cd $(PROJECT_ROOT) && go build -buildmode=plugin -o $(PLUGIN_DIR)plugin.so $(PLUGIN_DIR)
|
||||
|
||||
clean:
|
||||
rm -f $(PLUGIN_DIR)plugin.so $(PLUGIN_DIR)$(PLUGIN_NAME).hmap
|
||||
|
||||
package: plugin.so
|
||||
cd $(PLUGIN_DIR) && zip -r $(PLUGIN_NAME).hmap plugin.json plugin.so
|
||||
2
tools/plugin-dev/templates/gitignore.tmpl
Normal file
2
tools/plugin-dev/templates/gitignore.tmpl
Normal file
@ -0,0 +1,2 @@
|
||||
plugin.so
|
||||
*.hmap
|
||||
56
tools/plugin-dev/templates/plugin.go.tmpl
Normal file
56
tools/plugin-dev/templates/plugin.go.tmpl
Normal file
@ -0,0 +1,56 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"gitcode.com/JianFeeeee/HomeAgent/internal/sdk"
|
||||
)
|
||||
|
||||
type Plugin struct {
|
||||
name string
|
||||
sdk *sdk.PluginSDK
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func NewPlugin(name string, config map[string]interface{}) (sdk.Plugin, error) {
|
||||
return &Plugin{
|
||||
name: name,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *Plugin) Name() string { return p.name }
|
||||
|
||||
func (p *Plugin) Start(s *sdk.PluginSDK) error {
|
||||
p.sdk = s
|
||||
|
||||
tp := p.name + "_"
|
||||
|
||||
s.RegisterTool(tp+"example", sdk.ToolDef{
|
||||
Name: tp + "example",
|
||||
Description: "示例工具 - 请替换为实现",
|
||||
Parameters: map[string]interface{}{
|
||||
"type": "object",
|
||||
"properties": map[string]interface{}{
|
||||
"input": map[string]interface{}{"type": "string", "description": "输入参数"},
|
||||
},
|
||||
"required": []string{"input"},
|
||||
},
|
||||
}, p.handleExample)
|
||||
|
||||
log.Printf("[%s] plugin started", p.name)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Plugin) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Plugin) handleExample(args map[string]interface{}) (interface{}, error) {
|
||||
input, _ := args["input"].(string)
|
||||
return map[string]interface{}{
|
||||
"echo": input,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func main() {}
|
||||
10
tools/plugin-dev/templates/plugin.json.tmpl
Normal file
10
tools/plugin-dev/templates/plugin.json.tmpl
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "{{.Name}}",
|
||||
"version": "{{.Version}}",
|
||||
"description": "{{.Description}}",
|
||||
"author": "{{.Author}}",
|
||||
"license": "MIT",
|
||||
"entry": "plugin.so",
|
||||
"min_version": "1.0.0",
|
||||
"tags": ["{{.Name}}"]
|
||||
}
|
||||
Reference in New Issue
Block a user