- Fix remaining 187 pkg/ files referencing core/cli → core/go - Move SDK library code from internal/cmd/sdk/ → pkg/sdk/ (new package) - Create pkg/rag/helpers.go with convenience functions from internal/cmd/rag/ - Fix pkg/mcp/tools_rag.go to use pkg/rag instead of internal/cmd/rag - Fix pkg/build/buildcmd/cmd_sdk.go and pkg/release/sdk.go to use pkg/sdk - Remove all non-library content: main.go, internal/, cmd/, docker/, scripts/, tasks/, tools/, .core/, .forgejo/, .woodpecker/, Taskfile.yml - Run go mod tidy to trim unused dependencies core/go is now a pure Go package suite (library only). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Claude <developers@lethean.io> Reviewed-on: #3
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package plugin
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
core "forge.lthn.ai/core/go/pkg/framework/core"
|
|
"forge.lthn.ai/core/go/pkg/io"
|
|
)
|
|
|
|
// Manifest represents a plugin.json manifest file.
|
|
// Each plugin repository must contain a plugin.json at its root.
|
|
type Manifest struct {
|
|
Name string `json:"name"`
|
|
Version string `json:"version"`
|
|
Description string `json:"description"`
|
|
Author string `json:"author"`
|
|
Entrypoint string `json:"entrypoint"`
|
|
Dependencies []string `json:"dependencies,omitempty"`
|
|
MinVersion string `json:"min_version,omitempty"`
|
|
}
|
|
|
|
// LoadManifest reads and parses a plugin.json file from the given path.
|
|
func LoadManifest(m io.Medium, path string) (*Manifest, error) {
|
|
content, err := m.Read(path)
|
|
if err != nil {
|
|
return nil, core.E("plugin.LoadManifest", "failed to read manifest", err)
|
|
}
|
|
|
|
var manifest Manifest
|
|
if err := json.Unmarshal([]byte(content), &manifest); err != nil {
|
|
return nil, core.E("plugin.LoadManifest", "failed to parse manifest JSON", err)
|
|
}
|
|
|
|
return &manifest, nil
|
|
}
|
|
|
|
// Validate checks the manifest for required fields.
|
|
// Returns an error if name, version, or entrypoint are missing.
|
|
func (m *Manifest) Validate() error {
|
|
if m.Name == "" {
|
|
return core.E("plugin.Manifest.Validate", "name is required", nil)
|
|
}
|
|
if m.Version == "" {
|
|
return core.E("plugin.Manifest.Validate", "version is required", nil)
|
|
}
|
|
if m.Entrypoint == "" {
|
|
return core.E("plugin.Manifest.Validate", "entrypoint is required", nil)
|
|
}
|
|
return nil
|
|
}
|