Documentation
¶
Overview ¶
Package extension implements grut's plugin system. Extensions are small programs (Lua scripts, WASM modules, or MCP servers) installed from https:// git URLs or local directories. Each extension declares a manifest (extension.toml) that specifies its runtime, entry point, and required permissions. The Manager handles install, remove, enable/disable, and state persistence.
Index ¶
- func CheckPermission(ext *ExtensionInfo, perm Permission) bool
- func Scaffold(dir, name, templateName string) error
- func ValidPermission(p string) bool
- type ExtensionInfo
- type Manager
- func (m *Manager) Disable(name string) error
- func (m *Manager) Enable(name string) error
- func (m *Manager) Get(name string) (*ExtensionInfo, error)
- func (m *Manager) Install(ctx context.Context, source string) error
- func (m *Manager) List() []ExtensionInfo
- func (m *Manager) LoadAll() error
- func (m *Manager) Remove(name string) error
- type Manifest
- type Permission
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPermission ¶
func CheckPermission(ext *ExtensionInfo, perm Permission) bool
CheckPermission reports whether ext has been granted perm.
func ValidPermission ¶
ValidPermission reports whether p is a recognised permission name.
Types ¶
type ExtensionInfo ¶
type ExtensionInfo struct {
InstalledAt time.Time `toml:"installed_at"`
Manifest Manifest `toml:"manifest"`
Dir string `toml:"-"`
Enabled bool `toml:"enabled"`
}
ExtensionInfo holds runtime state for an installed extension.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles extension installation, removal, and state tracking.
func NewManager ¶
NewManager creates a Manager rooted at extDir, creating the directory if needed. It does NOT scan for installed extensions — call LoadAll explicitly.
func (*Manager) Get ¶
func (m *Manager) Get(name string) (*ExtensionInfo, error)
Get returns a single extension by name.
func (*Manager) Install ¶
Install adds an extension from a git URL (https:// only) or local path. The manifest inside the source is validated before the installation is considered successful.
func (*Manager) List ¶
func (m *Manager) List() []ExtensionInfo
List returns all installed extensions. The returned slice is a snapshot; callers may iterate without holding a lock.
type Manifest ¶
type Manifest struct {
Name string `toml:"name"`
Version string `toml:"version"`
Description string `toml:"description"`
Author string `toml:"author"`
License string `toml:"license"`
Runtime string `toml:"runtime"`
EntryPoint string `toml:"entry_point"`
MinGrut string `toml:"min_grut"`
Permissions []string `toml:"permissions"`
}
Manifest describes an extension's metadata, loaded from extension.toml.
func LoadManifest ¶
LoadManifest reads extension.toml from dir and returns the parsed manifest.
func ParseManifest ¶
ParseManifest decodes TOML bytes into a Manifest and validates it.
type Permission ¶
type Permission string
Permission represents a capability an extension can request.
const ( PermFileRead Permission = "file_read" PermFileWrite Permission = "file_write" PermGitRead Permission = "git_read" PermGitWrite Permission = "git_write" PermNetwork Permission = "network" PermProcess Permission = "process" PermClipboard Permission = "clipboard" PermNotify Permission = "notify" )
Valid extension permissions.
func AllPermissions ¶
func AllPermissions() []Permission
AllPermissions returns every valid permission value.
type Template ¶
type Template struct {
Files map[string]string // relative path → content (may contain {{.Name}})
Name string
Description string
Runtime string
}
Template describes a scaffold template for creating new extensions.
func ListTemplates ¶
func ListTemplates() []Template
ListTemplates returns all available scaffold templates.