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
- func List() []string
- func Register(adapter Adapter)
- type Adapter
- type GenerateError
- type Hook
- type MCPServer
- type ParseError
- type Power
- func (p *Power) AddHook(hook Hook) *Power
- func (p *Power) AddKeyword(keyword string) *Power
- func (p *Power) AddKeywords(keywords ...string) *Power
- func (p *Power) AddMCPServer(name string, server MCPServer) *Power
- func (p *Power) AddSteeringFile(name string, sf SteeringFile) *Power
- func (p *Power) Validate() error
- func (p *Power) WithDisplayName(displayName string) *Power
- func (p *Power) WithInstructions(instructions string) *Power
- func (p *Power) WithOnboarding(onboarding string) *Power
- func (p *Power) WithVersion(version string) *Power
- func (p *Power) WriteTo(dir string) error
- type SteeringFile
- type ValidationError
Constants ¶
const DefaultDirMode = 0755
DefaultDirMode is the default permission for created directories.
const DefaultFileMode = 0644
DefaultFileMode is the default permission for created files.
Variables ¶
This section is empty.
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.
type GenerateError ¶
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 ¶
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 (*Power) AddKeyword ¶
AddKeyword adds an activation keyword to the power.
func (*Power) AddKeywords ¶
AddKeywords adds multiple activation keywords to the power.
func (*Power) AddMCPServer ¶
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) WithDisplayName ¶
WithDisplayName sets the display name.
func (*Power) WithInstructions ¶
WithInstructions sets the main steering instructions.
func (*Power) WithOnboarding ¶
WithOnboarding sets the onboarding instructions.
func (*Power) WithVersion ¶
WithVersion sets the power version.
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 ¶
ValidationError represents a power validation error.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string