plugin

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildLearnPrompt

func BuildLearnPrompt(ctx LearnContext) string

BuildLearnPrompt creates the LLM prompt for skill recommendation.

func BuildLearnUpdatePrompt

func BuildLearnUpdatePrompt(ctx LearnContext) string

BuildLearnUpdatePrompt creates a prompt to re-analyze installed skills for staleness.

func BuildNewSkillPrompt

func BuildNewSkillPrompt(description string) string

BuildNewSkillPrompt creates an LLM prompt for the skill creator wizard.

func BundledSkillsDir

func BundledSkillsDir() string

BundledSkillsDir returns the directory where bundled skills are extracted.

func BundledSkillsSummary

func BundledSkillsSummary() string

BundledSkillsSummary returns a human-readable list of bundled skills.

func DefaultSkillDirs

func DefaultSkillDirs() []string

DefaultSkillDirs returns directories to scan for SKILL.md files. Includes hawk's own paths plus cross-agent standard paths for interoperability. Follows the agentskills.io spec and supports gh skill install placement.

func ExtractBundledSkills

func ExtractBundledSkills() (int, error)

ExtractBundledSkills extracts bundled skills to the user directory. Returns the number of skills extracted.

func ExtractSkillName

func ExtractSkillName(content string) string

ExtractSkillName tries to extract the skill name from generated SKILL.md content.

func FormatAuditResult

func FormatAuditResult(r AuditResult) string

FormatAuditResult formats audit findings for display.

func FormatLearnSummary

func FormatLearnSummary(ctx LearnContext, deep bool) string

FormatLearnSummary creates a display header for the /learn command.

func FormatRating

func FormatRating(rating int) string

FormatRating returns a star string like "★★★☆☆".

func FormatSkillEntry

func FormatSkillEntry(e SkillEntry) string

FormatSkillEntry formats a registry entry for display.

func FormatSkillInfo

func FormatSkillInfo(s SmartSkill, path string) string

FormatSkillInfo formats detailed skill info for display.

func FormatSkillsForPrompt

func FormatSkillsForPrompt(skills []SmartSkill) string

FormatSkillsForPrompt formats matched skills into text suitable for injection into the system prompt.

func GatherDeepSourceInfo

func GatherDeepSourceInfo(dir string) string

GatherDeepSourceInfo reads key source files to provide richer context.

func Install

func Install(srcDir string) error

Install installs a plugin from a directory.

func Remove

func Remove(name string) error

Remove uninstalls a skill by name from both project and user scope.

func ResolveChainConflicts

func ResolveChainConflicts(candidate SmartSkill, active map[string]SmartSkill) []string

ResolveChainConflicts checks if activating a skill conflicts with already-active skills.

func RunAutoSkill

func RunAutoSkill(dir string) (string, error)

RunAutoSkill analyzes the project and installs recommended skills.

func SaveNewSkill

func SaveNewSkill(name, content string) (string, error)

SaveNewSkill writes a SKILL.md to the project skills directory.

func StripDangerousChars

func StripDangerousChars(content string) string

StripDangerousChars removes dangerous Unicode characters from content.

func SuggestChainSkills

func SuggestChainSkills(skill SmartSkill) (after []string, enhances []string)

SuggestChainSkills returns skill names that should be suggested based on chain declarations.

func Summary

func Summary() string

Summary returns a formatted summary of installed plugins.

func Uninstall

func Uninstall(name string) error

Uninstall removes a plugin.

func Validate

func Validate(manifest *ToolManifest) []string

Validate checks a manifest for issues and returns a list of warnings/errors.

func WriteManifestV2

func WriteManifestV2(pluginDir string, m *ManifestV2) error

WriteManifestV2 writes a ManifestV2 to a plugin directory as plugin.json.

Types

type AuditFinding

type AuditFinding struct {
	File     string
	Line     int
	Column   int
	Severity AuditSeverity
	Category string
	Message  string
	Char     rune
}

AuditFinding is a single security issue found in a skill file.

func AuditSkillFile

func AuditSkillFile(path string) ([]AuditFinding, error)

AuditSkillFile scans a single file for dangerous Unicode characters.

type AuditResult

type AuditResult struct {
	Findings []AuditFinding
	Files    int
}

AuditResult is the result of scanning one or more skill files.

func AuditAllSkills

func AuditAllSkills() AuditResult

AuditAllSkills scans all skill directories.

func AuditSkillDir

func AuditSkillDir(dir string) AuditResult

AuditSkillDir scans all SKILL.md files in a directory tree.

type AuditSeverity

type AuditSeverity string

AuditSeverity indicates how dangerous a finding is.

const (
	SeverityCritical AuditSeverity = "CRITICAL"
	SeverityWarning  AuditSeverity = "WARNING"
	SeverityInfo     AuditSeverity = "INFO"
)

type BundledSkill

type BundledSkill struct {
	Name        string
	Description string
	Category    string
	Content     string
	Files       map[string]string // additional files beyond SKILL.md
}

BundledSkill defines a skill that ships with hawk.

type CommandDef

type CommandDef struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Script      string `json:"script,omitempty"`
}

CommandDef defines a plugin-provided command.

type DynamicPlugin

type DynamicPlugin struct {
	Plugin      // embed existing Plugin
	State       PluginState
	Error       string // last error message
	ActivatedAt time.Time
	Process     *PluginProcess // running process (for long-lived plugins)
	HookIDs     []string       // registered hook IDs (for cleanup on deactivate)
	ManifestV2  *ManifestV2    // extended manifest if available
}

DynamicPlugin extends the base Plugin with lifecycle management.

type DynamicPluginManager

type DynamicPluginManager struct {
	// contains filtered or unexported fields
}

DynamicPluginManager manages dynamic plugin lifecycle.

func NewDynamicPluginManager

func NewDynamicPluginManager(dirs []string, tools ToolRegistrar, hooks HookRegistrar) *DynamicPluginManager

NewDynamicPluginManager creates a new DynamicPluginManager with the given directories and registries.

func (*DynamicPluginManager) Activate

func (dm *DynamicPluginManager) Activate(name string) error

Activate loads a plugin, starts its process (if daemon mode), and registers tools + hooks.

func (*DynamicPluginManager) Deactivate

func (dm *DynamicPluginManager) Deactivate(name string) error

Deactivate unregisters hooks, removes tools, stops process, and sets state to Disabled.

func (*DynamicPluginManager) DiscoverAll

func (dm *DynamicPluginManager) DiscoverAll() error

DiscoverAll scans all plugin directories and registers discovered plugins.

func (*DynamicPluginManager) Events

func (dm *DynamicPluginManager) Events() <-chan PluginEvent

Events returns a channel for subscribing to plugin lifecycle events.

func (*DynamicPluginManager) ExecuteTool

func (dm *DynamicPluginManager) ExecuteTool(ctx context.Context, pluginName, toolName string, input json.RawMessage) (string, error)

ExecuteTool executes a specific tool on a plugin, using the daemon if available.

func (*DynamicPluginManager) Get

func (dm *DynamicPluginManager) Get(name string) (*DynamicPlugin, bool)

Get returns a specific plugin by name.

func (*DynamicPluginManager) InstallFromGitHub

func (dm *DynamicPluginManager) InstallFromGitHub(repo string) error

InstallFromGitHub clones a repo into the plugins directory.

func (*DynamicPluginManager) Reload

func (dm *DynamicPluginManager) Reload(name string) error

Reload deactivates and then reactivates a plugin.

func (*DynamicPluginManager) Status

func (dm *DynamicPluginManager) Status() []PluginStatus

Status returns the status of all known plugins.

func (*DynamicPluginManager) Uninstall

func (dm *DynamicPluginManager) Uninstall(name string) error

Uninstall deactivates a plugin and removes it from disk.

type FeedbackStore

type FeedbackStore struct {
	// contains filtered or unexported fields
}

FeedbackStore manages skill ratings persisted to disk.

func NewFeedbackStore

func NewFeedbackStore() *FeedbackStore

NewFeedbackStore creates a store at ~/.hawk/feedback.json.

func NewFeedbackStoreAt

func NewFeedbackStoreAt(path string) *FeedbackStore

NewFeedbackStoreAt creates a store at a custom path (for testing).

func (*FeedbackStore) Get

func (fs *FeedbackStore) Get(skill string) (SkillRating, bool)

Get returns the rating for a skill, or 0 if not rated.

func (*FeedbackStore) List

func (fs *FeedbackStore) List() []SkillRating

List returns all ratings.

func (*FeedbackStore) Rate

func (fs *FeedbackStore) Rate(skill string, rating int, comment string) error

Rate adds or updates a rating for a skill.

type HookDef

type HookDef struct {
	Event   string `json:"event"`
	Command string `json:"command"`
}

HookDef defines a plugin hook.

type HookRegistrar

type HookRegistrar interface {
	RegisterHook(id string, event string, fn func(ctx context.Context, data map[string]interface{}) error)
	UnregisterHook(id string)
}

HookRegistrar allows plugins to add/remove hooks.

type LearnContext

type LearnContext struct {
	Signals    []ProjectSignal
	Installed  []SmartSkill
	Registry   []SkillEntry
	SourceInfo string // populated by /learn deep
}

LearnContext holds project analysis data for the LLM advisor.

func GatherLearnContext

func GatherLearnContext(dir string) LearnContext

GatherLearnContext collects project info for the advisor.

type MalwareCheckResult

type MalwareCheckResult struct {
	Safe     bool
	Warnings []string
	Blocked  []string
}

MalwareCheckResult holds the result of scanning an extension for malicious patterns.

func CheckExtensionMalware

func CheckExtensionMalware(dir string) (*MalwareCheckResult, error)

CheckExtensionMalware scans an extension directory for malicious patterns.

type Manifest

type Manifest struct {
	Name        string       `json:"name"`
	Version     string       `json:"version"`
	Description string       `json:"description,omitempty"`
	Author      string       `json:"author,omitempty"`
	Commands    []CommandDef `json:"commands,omitempty"`
	Skills      []string     `json:"skills,omitempty"`
	Hooks       []HookDef    `json:"hooks,omitempty"`
}

Manifest defines a hawk plugin.

func List

func List() ([]*Manifest, error)

List returns all installed plugins.

func LoadManifest

func LoadManifest(dir string) (*Manifest, error)

LoadManifest loads a plugin manifest from a directory.

func (*Manifest) Validate

func (m *Manifest) Validate() error

Validate checks if a manifest is valid.

type ManifestHook

type ManifestHook struct {
	Event    string `json:"event"`              // hook event type (e.g. "pre_tool", "post_query")
	Command  string `json:"command"`            // shell command to run
	Async    bool   `json:"async,omitempty"`    // fire-and-forget
	Priority int    `json:"priority,omitempty"` // lower = earlier (default 100)
}

ManifestHook defines an event hook provided by a plugin.

type ManifestTool

type ManifestTool struct {
	Name           string                 `json:"name"`
	Description    string                 `json:"description"`
	Command        string                 `json:"command"`
	Args           []string               `json:"args"`
	InputSchema    map[string]interface{} `json:"input_schema"`
	TimeoutSeconds int                    `json:"timeout_seconds"`
}

ManifestTool defines a tool in the manifest file.

type ManifestV2

type ManifestV2 struct {
	// V1 fields (backward compatible)
	Name           string         `json:"name"`
	Version        string         `json:"version"`
	Description    string         `json:"description"`
	Author         string         `json:"author"`
	Tools          []ManifestTool `json:"tools"`
	Permissions    []string       `json:"permissions"`
	MinHawkVersion string         `json:"min_hawk_version"`

	// V2 extensions
	Mode         string                 `json:"mode,omitempty"`         // "subprocess" (default) or "daemon"
	Hooks        []ManifestHook         `json:"hooks,omitempty"`        // event hooks
	Config       map[string]interface{} `json:"config,omitempty"`       // plugin configuration
	Dependencies []string               `json:"dependencies,omitempty"` // other plugin names required
	Repository   string                 `json:"repository,omitempty"`   // git repo URL
	License      string                 `json:"license,omitempty"`
	Entrypoint   string                 `json:"entrypoint,omitempty"` // main binary (for daemon mode)
}

ManifestV2 is the extended manifest format for dynamic plugins. It is backward compatible with the original ToolManifest (V1) format.

func ParseManifestV2

func ParseManifestV2(pluginDir string) (*ManifestV2, error)

ParseManifestV2 reads and parses a plugin.json file from the given plugin directory using the V2 manifest format. It is backward compatible with V1 manifests.

func (*ManifestV2) IsV2

func (m *ManifestV2) IsV2() bool

IsV2 returns true if any V2-specific fields are populated.

func (*ManifestV2) ToV1

func (m *ManifestV2) ToV1() *ToolManifest

ToV1 converts a V2 manifest back to the original V1 ToolManifest format. V2-only fields are lost in this conversion.

func (*ManifestV2) ValidateV2

func (m *ManifestV2) ValidateV2() []string

ValidateV2 performs extended validation on a V2 manifest.

type Plugin

type Plugin struct {
	Name        string
	Version     string
	Description string
	Author      string
	Tools       []PluginTool
	Path        string
	Manifest    *ToolManifest
}

Plugin represents a loaded plugin with its tools and metadata.

type PluginEvent

type PluginEvent struct {
	Type       string // "activated", "deactivated", "failed", "installed"
	PluginName string
	Timestamp  time.Time
	Error      string
}

PluginEvent represents a lifecycle event for a plugin.

type PluginManager

type PluginManager struct {
	PluginDirs []string
	Loaded     map[string]*Plugin
	// contains filtered or unexported fields
}

PluginManager manages discovery, loading, and execution of subprocess-based plugins.

func NewPluginManager

func NewPluginManager(dirs ...string) *PluginManager

NewPluginManager creates a new PluginManager with the given directories. If no directories are provided, defaults to ~/.hawk/plugins/ and .hawk/plugins/.

func (*PluginManager) Discover

func (pm *PluginManager) Discover() ([]*Plugin, error)

Discover walks plugin directories, reads manifests, and returns available plugins.

func (*PluginManager) Execute

func (pm *PluginManager) Execute(ctx context.Context, pluginName, toolName string, input json.RawMessage) (string, error)

Execute runs a tool from a loaded plugin by passing input as JSON via stdin and capturing stdout as the result. It enforces timeouts and captures stderr for errors.

func (*PluginManager) ListTools

func (pm *PluginManager) ListTools() []PluginTool

ListTools returns all tools from all loaded plugins, namespaced by plugin name.

func (*PluginManager) Load

func (pm *PluginManager) Load(name string) (*Plugin, error)

Load loads a specific plugin by name from the plugin directories.

func (*PluginManager) LoadAll

func (pm *PluginManager) LoadAll() error

LoadAll discovers and loads all available plugins.

type PluginProcess

type PluginProcess struct {
	// contains filtered or unexported fields
}

PluginProcess represents a long-lived plugin daemon process.

func (*PluginProcess) Send

func (pp *PluginProcess) Send(request map[string]interface{}) (map[string]interface{}, error)

Send sends a JSON-RPC request to the daemon process and reads the response.

func (*PluginProcess) Stop

func (pp *PluginProcess) Stop()

Stop terminates the daemon process.

type PluginState

type PluginState string

PluginState represents the lifecycle state of a dynamic plugin.

const (
	StateDiscovered PluginState = "discovered"
	StateLoaded     PluginState = "loaded"
	StateActive     PluginState = "active"
	StateFailed     PluginState = "failed"
	StateDisabled   PluginState = "disabled"
)

type PluginStatus

type PluginStatus struct {
	Name        string
	Version     string
	State       PluginState
	ToolCount   int
	HookCount   int
	Error       string
	ActivatedAt time.Time
}

PluginStatus provides a snapshot of a plugin's state.

type PluginTool

type PluginTool struct {
	Name        string
	Description string
	InputSchema map[string]interface{}
	Command     string
	Timeout     time.Duration
	PluginName  string // namespaced: which plugin owns this tool
}

PluginTool represents a single tool provided by a plugin.

type PluginToolAdapter

type PluginToolAdapter struct {
	// contains filtered or unexported fields
}

PluginToolAdapter wraps a PluginTool as a tool.Tool interface so it can be registered in the main tool registry.

func (*PluginToolAdapter) Aliases

func (a *PluginToolAdapter) Aliases() []string

Aliases returns alternative names for this tool.

func (*PluginToolAdapter) Description

func (a *PluginToolAdapter) Description() string

Description returns the tool description.

func (*PluginToolAdapter) Execute

func (a *PluginToolAdapter) Execute(ctx context.Context, input json.RawMessage) (string, error)

Execute runs the tool via the plugin manager.

func (*PluginToolAdapter) Name

func (a *PluginToolAdapter) Name() string

Name returns the fully qualified tool name (plugin__pluginName__toolName).

func (*PluginToolAdapter) Parameters

func (a *PluginToolAdapter) Parameters() map[string]interface{}

Parameters returns the JSON schema for tool input.

func (*PluginToolAdapter) PluginName

func (a *PluginToolAdapter) PluginName() string

PluginName returns the name of the owning plugin.

func (*PluginToolAdapter) RiskLevel

func (a *PluginToolAdapter) RiskLevel() string

RiskLevel returns the risk classification for this plugin tool. Daemon plugins are considered lower risk since they run in a controlled process. Subprocess plugins default to medium risk.

func (*PluginToolAdapter) ToolName

func (a *PluginToolAdapter) ToolName() string

ToolName returns the unqualified tool name.

type ProjectSignal

type ProjectSignal struct {
	Category string // language, framework, pattern, tool
	Name     string // e.g. "go", "react", "docker"
}

ProjectSignal represents a detected project characteristic.

func AnalyzeProject

func AnalyzeProject(dir string) []ProjectSignal

AnalyzeProject scans the current directory for project signals.

type RegistryClient

type RegistryClient struct {
	IndexURL string
	CacheDir string
	// contains filtered or unexported fields
}

RegistryClient fetches and queries the community skill registry.

func NewRegistryClient

func NewRegistryClient() *RegistryClient

NewRegistryClient creates a registry client with sensible defaults.

func (*RegistryClient) FetchIndex

func (rc *RegistryClient) FetchIndex() (*SkillIndex, error)

FetchIndex downloads the registry index, using a local cache when fresh.

func (*RegistryClient) Info

func (rc *RegistryClient) Info(name string) (*SkillEntry, error)

Info returns detailed information about a specific skill.

func (*RegistryClient) Install

func (rc *RegistryClient) Install(repo, skillName, scope string) (string, error)

Install clones a specific skill from a GitHub repo into the skills directory. If skillName is empty, all skills in the repo are installed.

func (*RegistryClient) Search

func (rc *RegistryClient) Search(query, category string) ([]SkillEntry, error)

Search filters skills by query string and optional category.

func (*RegistryClient) Trending

func (rc *RegistryClient) Trending(limit int) ([]SkillEntry, error)

Trending returns the most-installed skills.

type Runtime

type Runtime struct {
	SmartSkills []SmartSkill
	// contains filtered or unexported fields
}

Runtime manages loaded plugins and their execution.

func NewRuntime

func NewRuntime() *Runtime

NewRuntime creates a new plugin runtime.

func (*Runtime) CommandList

func (r *Runtime) CommandList() []CommandDef

CommandList returns all available plugin commands.

func (*Runtime) ExecuteCommand

func (r *Runtime) ExecuteCommand(name string, args []string) (string, error)

ExecuteCommand runs a plugin command.

func (*Runtime) IsCommand

func (r *Runtime) IsCommand(name string) bool

IsCommand checks if a name is a plugin command.

func (*Runtime) ListPlugins

func (r *Runtime) ListPlugins() []*Manifest

ListPlugins returns all loaded plugin manifests.

func (*Runtime) LoadAll

func (r *Runtime) LoadAll() error

LoadAll loads all installed plugins.

func (*Runtime) RegisterHooks

func (r *Runtime) RegisterHooks()

RegisterHooks registers all plugin hooks with the hook registry.

type SecurityIssue

type SecurityIssue struct {
	Severity string
	Message  string
	File     string
	Line     int
}

SecurityIssue represents a security concern found during plugin scanning.

func ScanPlugin

func ScanPlugin(pluginDir string) []SecurityIssue

ScanPlugin checks a plugin directory for suspicious content and security issues.

type Skill

type Skill struct {
	Name        string
	Description string
	Content     string
}

Skill represents a project-local skill loaded from a markdown file with YAML front-matter metadata (name, description) and body content.

func LoadSkillsFromDir

func LoadSkillsFromDir(dir string) ([]Skill, error)

LoadSkillsFromDir reads all .md files from a directory, parsing YAML front-matter (name, description) and body content. Returns an empty slice (not an error) if the directory does not exist.

type SkillChain

type SkillChain struct {
	After     []string // skills that should run before this one
	Before    []string // skills to suggest after this one completes
	Conflicts []string // skills that cannot be active simultaneously
	Enhances  []string // skills that work well together (advisory)
}

SkillChain declares relationships between skills.

type SkillEntry

type SkillEntry struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Author      string   `json:"author"`
	Repo        string   `json:"repo"`
	Path        string   `json:"path"`
	Category    string   `json:"category"`
	Tags        []string `json:"tags"`
	Version     string   `json:"version"`
	License     string   `json:"license"`
	Agents      []string `json:"agents"`
	Installs    int      `json:"installs"`
	UpdatedAt   string   `json:"updated_at"`
}

SkillEntry is a single skill in the registry index.

func RecommendSkills

func RecommendSkills(signals []ProjectSignal, skills []SkillEntry) []SkillEntry

RecommendSkills matches project signals against the registry index.

type SkillIndex

type SkillIndex struct {
	Version   int          `json:"version"`
	UpdatedAt string       `json:"updated_at"`
	Skills    []SkillEntry `json:"skills"`
}

SkillIndex is the full registry index.

type SkillRating

type SkillRating struct {
	Skill   string    `json:"skill"`
	Rating  int       `json:"rating"` // 1-5
	Comment string    `json:"comment,omitempty"`
	Date    time.Time `json:"date"`
}

SkillRating stores a user's rating for a skill.

type SkillSource

type SkillSource struct {
	Repo        string `json:"repo,omitempty"`
	Ref         string `json:"ref,omitempty"`
	InstalledAt string `json:"installed_at,omitempty"`
}

SkillSource tracks where an installed skill came from.

type SmartSkill

type SmartSkill struct {
	Name          string
	Description   string   // used for auto-matching against user prompts
	Paths         []string // glob patterns that trigger this skill
	Content       string   // skill prompt content (body of SKILL.md)
	AutoInvoke    bool     // if true, model can trigger without user /command
	Compatibility string   // environment requirements (per spec)
	AllowedTools  string   // pre-approved tools, space-separated (per spec)
	Version       string   // semver for update tracking
	Author        string   // skill author
	License       string   // license identifier (MIT, Apache-2.0, etc.)
	Category      string   // engineering, ops, testing, security, devtools, workflow
	Tags          []string // discovery tags
	Agents        []string // cross-agent compatibility (hawk, claude-code, etc.)
	Source        SkillSource
	Invoke        string   // namespaced invocation pattern (e.g. "/vendor:skill")
	Refs          []string // declared @ref() references in SKILL.md
	RefDir        string   // path to references/ directory
	Chain         SkillChain
}

SmartSkill is a skill that can be auto-invoked based on file paths or user prompt context. Follows the Agent Skills spec (agentskills.io).

func InstalledSkillInfo

func InstalledSkillInfo(name string) (SmartSkill, string, bool)

InstalledSkillInfo returns source metadata for an installed skill.

func LoadSmartSkills

func LoadSmartSkills(dirs []string) []SmartSkill

LoadSmartSkills scans the given directories for SKILL.md files with YAML frontmatter and returns the parsed skills.

Frontmatter format:

---
name: api-review
description: Reviews API endpoints for consistency
paths: ["src/api/**", "routes/**"]
auto-invoke: true
---

func MatchSkillsByContext

func MatchSkillsByContext(skills []SmartSkill, userPrompt string) []SmartSkill

MatchSkillsByContext returns skills whose Description keywords appear in the user prompt. Uses simple case-insensitive word overlap.

func MatchSkillsByPath

func MatchSkillsByPath(skills []SmartSkill, activePath string) []SmartSkill

MatchSkillsByPath returns skills whose Paths glob patterns match activePath.

func ParseSmartSkillPublic

func ParseSmartSkillPublic(content string) SmartSkill

ParseSmartSkillPublic is the exported version of parseSmartSkill.

func (*SmartSkill) LoadRef

func (s *SmartSkill) LoadRef(name string) (string, error)

LoadRef loads a reference document on-demand from the skill's references/ dir.

type ToolManifest

type ToolManifest struct {
	Name           string         `json:"name"`
	Version        string         `json:"version"`
	Description    string         `json:"description"`
	Author         string         `json:"author"`
	Tools          []ManifestTool `json:"tools"`
	Permissions    []string       `json:"permissions"`
	MinHawkVersion string         `json:"min_hawk_version"`
}

ToolManifest is the manifest loaded from plugin.json for subprocess-based plugins.

func ParseManifest

func ParseManifest(pluginDir string) (*ToolManifest, error)

ParseManifest reads and parses a plugin.json file from the given plugin directory.

type ToolRegistrar

type ToolRegistrar interface {
	AddTool(name string, t interface{})
	RemoveTool(name string)
}

ToolRegistrar allows plugins to add/remove tools from the main registry.

type WasmPluginRuntime

type WasmPluginRuntime struct {
	// contains filtered or unexported fields
}

WasmPluginRuntime runs WASM-compiled plugins using wazero (pure Go, no CGO). WASM plugins are faster than subprocess plugins (no process spawn overhead) and more secure (capability-based sandboxing by default).

func NewWasmPluginRuntime

func NewWasmPluginRuntime(manifestPath string) (*WasmPluginRuntime, error)

NewWasmPluginRuntime creates a WASM plugin runtime from a manifest.

func (*WasmPluginRuntime) ExecuteTool

func (w *WasmPluginRuntime) ExecuteTool(ctx context.Context, toolName string, input json.RawMessage) (string, error)

ExecuteTool runs a WASM plugin tool with the given input and returns the output.

func (*WasmPluginRuntime) Name

func (w *WasmPluginRuntime) Name() string

Name returns the plugin name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL