core

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package core provides canonical power definition types.

Powers are capability packages that bundle MCP servers, steering files, and hooks into a single installable unit for AI coding assistants.

The canonical Power type maps to platform-specific formats like Kiro IDE Powers.

Index

Constants

View Source
const DefaultDirMode = 0755

DefaultDirMode is the default permission for created directories.

View Source
const DefaultFileMode = 0600

DefaultFileMode is the default permission for created files.

Variables

This section is empty.

Functions

func List

func List() []string

List returns all registered adapter names.

func Register

func Register(adapter Adapter)

Register registers an adapter with the global registry. This is typically called from adapter init() functions.

Types

type Adapter

type Adapter interface {
	// Name returns the adapter identifier (e.g., "kiro").
	Name() string

	// GeneratePowerDir creates a complete power directory structure.
	// Returns the paths of all created files.
	GeneratePowerDir(power *Power, outputDir string) ([]string, error)

	// ParsePowerDir reads a power directory and returns a canonical Power.
	ParsePowerDir(dir string) (*Power, error)
}

Adapter defines the interface for power format adapters. Each platform (Kiro, etc.) implements this interface to convert between canonical Power and platform-specific formats.

func Get

func Get(name string) (Adapter, error)

Get returns an adapter by name.

type GenerateError

type GenerateError struct {
	Format  string
	Path    string
	Message string
	Err     error
}

GenerateError represents an error during power generation.

func (*GenerateError) Error

func (e *GenerateError) Error() string

func (*GenerateError) Unwrap

func (e *GenerateError) Unwrap() error

type Hook

type Hook struct {
	// Name is the hook identifier.
	Name string `json:"name" yaml:"name"`

	// Event is the trigger event (e.g., "pre-commit", "on-save").
	Event string `json:"event" yaml:"event"`

	// Command is the action to execute.
	Command string `json:"command,omitempty" yaml:"command,omitempty"`

	// Prompt is the AI prompt to execute.
	Prompt string `json:"prompt,omitempty" yaml:"prompt,omitempty"`

	// Condition determines when the hook runs.
	Condition string `json:"condition,omitempty" yaml:"condition,omitempty"`
}

Hook defines an automation trigger.

type MCPServer

type MCPServer struct {
	// Command is the executable to launch for stdio servers.
	Command string `json:"command,omitempty" yaml:"command,omitempty"`

	// Args are command-line arguments for the server.
	Args []string `json:"args,omitempty" yaml:"args,omitempty"`

	// Env contains environment variables for the server process.
	// Use ${VAR_NAME} syntax for user-provided values.
	Env map[string]string `json:"env,omitempty" yaml:"env,omitempty"`

	// URL is the endpoint for remote HTTP/SSE servers.
	URL string `json:"url,omitempty" yaml:"url,omitempty"`

	// Description explains what tools this server provides.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

MCPServer defines an MCP server configuration.

type ParseError

type ParseError struct {
	Format string
	Path   string
	Err    error
}

ParseError represents an error during power parsing.

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

type Power

type Power struct {
	// Name is the unique identifier for the power (e.g., "prdtool").
	Name string `json:"name" yaml:"name"`

	// DisplayName is the user-facing title (e.g., "PRD Tool").
	DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"`

	// Description explains what the power provides.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Version is the semantic version (e.g., "1.0.0").
	Version string `json:"version,omitempty" yaml:"version,omitempty"`

	// Keywords trigger power activation when mentioned in conversation.
	// These should be developer-relevant terms (e.g., "database", "auth").
	Keywords []string `json:"keywords,omitempty" yaml:"keywords,omitempty"`

	// MCPServers defines the MCP server configurations for this power.
	MCPServers map[string]MCPServer `json:"mcpServers,omitempty" yaml:"mcpServers,omitempty"`

	// Onboarding contains setup instructions run when the power is first activated.
	// This can include dependency checks, configuration steps, and hook creation.
	Onboarding string `json:"onboarding,omitempty" yaml:"onboarding,omitempty"`

	// Instructions are the main steering content for the power.
	// For simple powers, this contains all guidance.
	Instructions string `json:"instructions,omitempty" yaml:"instructions,omitempty"`

	// SteeringFiles maps workflow names to steering file paths.
	// These are loaded conditionally based on the current task.
	SteeringFiles map[string]SteeringFile `json:"steeringFiles,omitempty" yaml:"steeringFiles,omitempty"`

	// Hooks defines automation triggers for IDE events.
	Hooks []Hook `json:"hooks,omitempty" yaml:"hooks,omitempty"`

	// Repository is the GitHub URL for distribution.
	Repository string `json:"repository,omitempty" yaml:"repository,omitempty"`

	// Author is the power creator.
	Author string `json:"author,omitempty" yaml:"author,omitempty"`

	// License specifies the distribution license.
	License string `json:"license,omitempty" yaml:"license,omitempty"`
}

Power represents a canonical power definition. Powers bundle MCP servers, steering files, and optional hooks into a package that can be dynamically activated based on keywords.

func NewPower

func NewPower(name, description string) *Power

NewPower creates a new Power with the given name and description.

func (*Power) AddHook

func (p *Power) AddHook(hook Hook) *Power

AddHook adds an automation hook.

func (*Power) AddKeyword

func (p *Power) AddKeyword(keyword string) *Power

AddKeyword adds an activation keyword to the power.

func (*Power) AddKeywords

func (p *Power) AddKeywords(keywords ...string) *Power

AddKeywords adds multiple activation keywords to the power.

func (*Power) AddMCPServer

func (p *Power) AddMCPServer(name string, server MCPServer) *Power

AddMCPServer adds an MCP server configuration.

func (*Power) AddSteeringFile

func (p *Power) AddSteeringFile(name string, sf SteeringFile) *Power

AddSteeringFile adds a conditional steering file.

func (*Power) Validate

func (p *Power) Validate() error

Validate checks if the power has required fields.

func (*Power) WithDisplayName

func (p *Power) WithDisplayName(displayName string) *Power

WithDisplayName sets the display name.

func (*Power) WithInstructions

func (p *Power) WithInstructions(instructions string) *Power

WithInstructions sets the main steering instructions.

func (*Power) WithOnboarding

func (p *Power) WithOnboarding(onboarding string) *Power

WithOnboarding sets the onboarding instructions.

func (*Power) WithVersion

func (p *Power) WithVersion(version string) *Power

WithVersion sets the power version.

func (*Power) WriteTo

func (p *Power) WriteTo(dir string) error

WriteTo writes the power to a directory in the platform-specific format. This is a convenience method that uses the default Kiro format.

type SteeringFile

type SteeringFile struct {
	// Path is the relative path to the steering file.
	Path string `json:"path" yaml:"path"`

	// Keywords trigger loading of this specific steering file.
	Keywords []string `json:"keywords,omitempty" yaml:"keywords,omitempty"`

	// Description explains when this steering file is used.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Content is the inline steering content (alternative to Path).
	Content string `json:"content,omitempty" yaml:"content,omitempty"`
}

SteeringFile represents a conditional steering file.

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a power validation error.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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