core

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 9 Imported by: 0

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

View Source
const DefaultDirMode fs.FileMode = 0700

DefaultDirMode is the default permission for generated directories.

View Source
const DefaultFileMode fs.FileMode = 0600

DefaultFileMode is the default permission for generated files.

Variables

View Source
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

func MarshalMarkdownAgent(agent *Agent) []byte

MarshalMarkdownAgent converts an Agent to Markdown + YAML frontmatter bytes.

func Register

func Register(adapter Adapter)

Register adds an adapter to the default registry.

func WriteAgentsToDir

func WriteAgentsToDir(agents []*Agent, dir string, adapterName string) error

WriteAgentsToDir writes multiple agents to a directory using the specified adapter.

func WriteCanonicalFile

func WriteCanonicalFile(agent *Agent, path string) error

WriteCanonicalFile writes a canonical agent file in Markdown + YAML frontmatter format.

func WriteCanonicalJSON

func WriteCanonicalJSON(agent *Agent, path string) error

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

func GetAdapter(name string) (Adapter, bool)

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 NewAgent

func NewAgent(name, description string) *Agent

NewAgent creates a new Agent with the given name and description.

func ParseMarkdownAgent

func ParseMarkdownAgent(data []byte, path string) (*Agent, error)

ParseMarkdownAgent parses a Markdown file with YAML frontmatter into an Agent.

func ReadCanonicalDir

func ReadCanonicalDir(dir string) ([]*Agent, error)

ReadCanonicalDir reads all agent files (.md or .json) from a directory.

func ReadCanonicalFile

func ReadCanonicalFile(path string) (*Agent, error)

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

func (a *Agent) AddDependency(dep string)

AddDependency adds a dependency to the agent.

func (*Agent) AddSkill

func (a *Agent) AddSkill(skill string)

AddSkill adds a skill to the agent.

func (*Agent) AddSkills

func (a *Agent) AddSkills(skills ...string)

AddSkills adds multiple skills to the agent.

func (*Agent) AddTool

func (a *Agent) AddTool(tool string)

AddTool adds a tool to the agent's allowed tools list.

func (*Agent) AddTools

func (a *Agent) AddTools(tools ...string)

AddTools adds multiple tools to the agent's allowed tools list.

func (*Agent) SetModel

func (a *Agent) SetModel(model string)

SetModel sets the model for the agent.

func (*Agent) WithInstructions

func (a *Agent) WithInstructions(instructions string) *Agent

WithInstructions sets the agent's instructions and returns the agent for chaining.

func (*Agent) WithModel

func (a *Agent) WithModel(model string) *Agent

WithModel sets the agent's preferred model and returns the agent for chaining.

func (*Agent) WithSkills

func (a *Agent) WithSkills(skills ...string) *Agent

WithSkills sets the agent's skills and returns the agent for chaining.

func (*Agent) WithTools

func (a *Agent) WithTools(tools ...string) *Agent

WithTools sets the agent's tools and returns the agent for chaining.

type MarshalError

type MarshalError struct {
	Format string
	Err    error
}

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

type ParseError struct {
	Format string
	Path   string
	Err    error
}

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 ReadError

type ReadError struct {
	Path string
	Err  error
}

ReadError indicates a failure to read a file.

func (*ReadError) Error

func (e *ReadError) Error() string

func (*ReadError) Unwrap

func (e *ReadError) Unwrap() error

type Registry

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

Registry manages adapter registration and lookup.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new adapter registry.

func (*Registry) AdapterNames

func (r *Registry) AdapterNames() []string

AdapterNames returns all registered adapter names sorted alphabetically.

func (*Registry) GetAdapter

func (r *Registry) GetAdapter(name string) (Adapter, bool)

GetAdapter returns an adapter by name.

func (*Registry) Register

func (r *Registry) Register(adapter Adapter)

Register adds an adapter to the registry.

type WriteError

type WriteError struct {
	Path string
	Err  error
}

WriteError indicates a failure to write a file.

func (*WriteError) Error

func (e *WriteError) Error() string

func (*WriteError) Unwrap

func (e *WriteError) Unwrap() error

Jump to

Keyboard shortcuts

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