Documentation
¶
Overview ¶
Package core provides the canonical agent definition types. Agent definitions use Description/Instructions as the canonical form, which maps losslessly to Claude Code, Kiro CLI, and OpenAI Codex.
Index ¶
- Constants
- Variables
- func AdapterNames() []string
- func MarshalMarkdownAgent(agent *Agent) []byte
- func Register(adapter Adapter)
- func WriteAgentsToDir(agents []*Agent, dir string, adapterName string) error
- func WriteCanonicalFile(agent *Agent, path string) error
- func WriteCanonicalJSON(agent *Agent, path string) error
- type Adapter
- type AdapterError
- type Agent
- func (a *Agent) AddDependency(dep string)
- func (a *Agent) AddSkill(skill string)
- func (a *Agent) AddSkills(skills ...string)
- func (a *Agent) AddTool(tool string)
- func (a *Agent) AddTools(tools ...string)
- func (a *Agent) SetModel(model string)
- func (a *Agent) WithInstructions(instructions string) *Agent
- func (a *Agent) WithModel(model string) *Agent
- func (a *Agent) WithSkills(skills ...string) *Agent
- func (a *Agent) WithTools(tools ...string) *Agent
- type MarshalError
- type ParseError
- type ReadError
- type Registry
- type WriteError
Constants ¶
const DefaultDirMode fs.FileMode = 0700
DefaultDirMode is the default permission for generated directories.
const DefaultFileMode fs.FileMode = 0600
DefaultFileMode is the default permission for generated files.
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry is the global adapter registry.
Functions ¶
func AdapterNames ¶
func AdapterNames() []string
AdapterNames returns adapter names from the default registry.
func MarshalMarkdownAgent ¶
MarshalMarkdownAgent converts an Agent to Markdown + YAML frontmatter bytes.
func WriteAgentsToDir ¶
WriteAgentsToDir writes multiple agents to a directory using the specified adapter.
func WriteCanonicalFile ¶
WriteCanonicalFile writes a canonical agent file in Markdown + YAML frontmatter format.
func WriteCanonicalJSON ¶
WriteCanonicalJSON writes a canonical agent.json file (for validation/schema compatibility).
Types ¶
type Adapter ¶
type Adapter interface {
// Name returns the adapter identifier (e.g., "claude", "gemini").
Name() string
// FileExtension returns the file extension for agent files.
FileExtension() string
// DefaultDir returns the default directory name for agents.
DefaultDir() string
// Parse converts tool-specific bytes to canonical Agent.
Parse(data []byte) (*Agent, error)
// Marshal converts canonical Agent to tool-specific bytes.
Marshal(agent *Agent) ([]byte, error)
// ReadFile reads from path and returns canonical Agent.
ReadFile(path string) (*Agent, error)
// WriteFile writes canonical Agent to path.
WriteFile(agent *Agent, path string) error
}
Adapter converts between canonical Agent definitions and tool-specific formats.
func GetAdapter ¶
GetAdapter returns an adapter from the default registry.
type AdapterError ¶
type AdapterError struct {
Name string
}
AdapterError indicates an unknown adapter was requested.
func (*AdapterError) Error ¶
func (e *AdapterError) Error() string
type Agent ¶
type Agent struct {
// Name is the unique identifier for the agent (e.g., "release-coordinator").
Name string `json:"name"`
// Description is a brief summary of what the agent does and when to use it.
// Example: "Orchestrates software releases including versioning and tagging."
Description string `json:"description,omitempty"`
// Instructions are the detailed system prompt for the agent.
// This is the full guidance on how the agent should behave.
Instructions string `json:"instructions,omitempty"`
// Model is the preferred AI model (e.g., "haiku", "sonnet", "opus").
Model string `json:"model,omitempty"`
// Tools are the tools available to the agent (e.g., "Read", "Write", "Bash").
Tools []string `json:"tools,omitempty"`
// Skills are capabilities or skills the agent can invoke.
Skills []string `json:"skills,omitempty"`
// Dependencies are external CLI tools required by this agent.
Dependencies []string `json:"dependencies,omitempty"`
}
Agent represents a canonical agent/subagent definition. This structure maps directly to Claude Code, Kiro CLI, and Codex agents.
func ParseMarkdownAgent ¶
ParseMarkdownAgent parses a Markdown file with YAML frontmatter into an Agent.
func ReadCanonicalDir ¶
ReadCanonicalDir reads all agent files (.md or .json) from a directory.
func ReadCanonicalFile ¶
ReadCanonicalFile reads a canonical agent file (Markdown + YAML frontmatter or JSON). The format is auto-detected based on file extension or content.
func (*Agent) AddDependency ¶
AddDependency adds a dependency to the agent.
func (*Agent) WithInstructions ¶
WithInstructions sets the agent's instructions and returns the agent for chaining.
func (*Agent) WithModel ¶
WithModel sets the agent's preferred model and returns the agent for chaining.
func (*Agent) WithSkills ¶
WithSkills sets the agent's skills and returns the agent for chaining.
type MarshalError ¶
MarshalError indicates a failure to marshal agent data.
func (*MarshalError) Error ¶
func (e *MarshalError) Error() string
func (*MarshalError) Unwrap ¶
func (e *MarshalError) Unwrap() error
type ParseError ¶
ParseError indicates a failure to parse agent data.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages adapter registration and lookup.
func (*Registry) AdapterNames ¶
AdapterNames returns all registered adapter names sorted alphabetically.
func (*Registry) GetAdapter ¶
GetAdapter returns an adapter by name.
type WriteError ¶
WriteError indicates a failure to write a file.
func (*WriteError) Error ¶
func (e *WriteError) Error() string
func (*WriteError) Unwrap ¶
func (e *WriteError) Unwrap() error