Change module path from forge.lthn.ai/core/go-scm to dappco.re/go/core/scm. Update all Go source imports for migrated packages: - go-log -> dappco.re/go/core/log - go-io -> dappco.re/go/core/io - go-i18n -> dappco.re/go/core/i18n - go-ws -> dappco.re/go/core/ws - api -> dappco.re/go/core/api Non-migrated packages (cli, config) left on forge.lthn.ai paths. Replace directives use local paths (../go, ../go-io, etc.) until the dappco.re vanity URL server resolves these modules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package plugin
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
coreerr "dappco.re/go/core/log"
|
|
"dappco.re/go/core/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, coreerr.E("plugin.LoadManifest", "failed to read manifest", err)
|
|
}
|
|
|
|
var manifest Manifest
|
|
if err := json.Unmarshal([]byte(content), &manifest); err != nil {
|
|
return nil, coreerr.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 coreerr.E("plugin.Manifest.Validate", "name is required", nil)
|
|
}
|
|
if m.Version == "" {
|
|
return coreerr.E("plugin.Manifest.Validate", "version is required", nil)
|
|
}
|
|
if m.Entrypoint == "" {
|
|
return coreerr.E("plugin.Manifest.Validate", "entrypoint is required", nil)
|
|
}
|
|
return nil
|
|
}
|