plugin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 13 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 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 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 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 Summary

func Summary() string

Summary returns a formatted summary of installed plugins.

func Uninstall

func Uninstall(name string) error

Uninstall removes a plugin.

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 CommandDef

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

CommandDef defines a plugin-provided command.

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 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 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 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 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
}

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.

Jump to

Keyboard shortcuts

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