Documentation
¶
Overview ¶
Package core provides canonical types for AI assistant command/prompt definitions.
Index ¶
- Constants
- Variables
- func AdapterNames() []string
- func Convert(data []byte, from, to string) ([]byte, error)
- func Register(adapter Adapter)
- func WriteCanonicalFile(cmd *Command, path string) error
- func WriteCommandsToDir(commands []*Command, dir string, adapterName string) error
- type Adapter
- type Argument
- type Command
- func (c *Command) AddArgument(arg Argument)
- func (c *Command) AddDependency(dep string)
- func (c *Command) AddExample(description, input, output string)
- func (c *Command) AddOptionalArgument(name, description, defaultValue string)
- func (c *Command) AddProcessStep(step string)
- func (c *Command) AddRequiredArgument(name, description, hint string)
- type Example
- 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 WriteCanonicalFile ¶
WriteCanonicalFile writes a canonical command.json file.
Types ¶
type Adapter ¶
type Adapter interface {
// Name returns the adapter identifier (e.g., "claude", "gemini", "codex").
Name() string
// FileExtension returns the file extension for this format (e.g., ".md", ".toml").
FileExtension() string
// DefaultDir returns the default directory name for commands.
DefaultDir() string
// Parse converts tool-specific bytes to canonical Command.
Parse(data []byte) (*Command, error)
// Marshal converts canonical Command to tool-specific bytes.
Marshal(cmd *Command) ([]byte, error)
// ReadFile reads from path and returns canonical Command.
ReadFile(path string) (*Command, error)
// WriteFile writes canonical Command to path.
WriteFile(cmd *Command, path string) error
}
Adapter converts between canonical Command and tool-specific formats.
func GetAdapter ¶
GetAdapter returns an adapter from the default registry.
type Argument ¶
type Argument struct {
Name string `json:"name"`
Type string `json:"type"` // string, number, boolean
Required bool `json:"required,omitempty"` // If true, argument is required
Default string `json:"default,omitempty"` // Default value
Pattern string `json:"pattern,omitempty"` // Regex validation pattern
Hint string `json:"hint,omitempty"` // User-facing hint
Description string `json:"description,omitempty"` // Detailed description
}
Argument represents a command argument.
type Command ¶
type Command struct {
// Metadata
Name string `json:"name"`
Description string `json:"description"`
// Arguments
Arguments []Argument `json:"arguments,omitempty"`
// Content
Instructions string `json:"instructions"` // The prompt/instructions content
// Process steps (for documentation)
Process []string `json:"process,omitempty"`
// Dependencies required to run this command
Dependencies []string `json:"dependencies,omitempty"`
// Examples of usage
Examples []Example `json:"examples,omitempty"`
}
Command represents a canonical command/prompt definition that can be converted to tool-specific formats (Claude, Gemini, Codex).
func NewCommand ¶
NewCommand creates a new Command with the given name and description.
func ParseCommandMarkdown ¶ added in v0.8.0
ParseCommandMarkdown parses a Markdown file with YAML frontmatter into a Command. The frontmatter should contain: name, description, arguments, dependencies, process. The body becomes the instructions.
func ReadCanonicalDir ¶
ReadCanonicalDir reads all command files (.json or .md) from a directory.
func ReadCanonicalFile ¶
ReadCanonicalFile reads a canonical command file (JSON or Markdown with YAML frontmatter). The format is auto-detected based on file extension or content.
func (*Command) AddArgument ¶
AddArgument adds an argument to the command.
func (*Command) AddDependency ¶
AddDependency adds a dependency to the command.
func (*Command) AddExample ¶
AddExample adds a usage example.
func (*Command) AddOptionalArgument ¶
AddOptionalArgument adds an optional string argument with a default value.
func (*Command) AddProcessStep ¶
AddProcessStep adds a step to the process list.
func (*Command) AddRequiredArgument ¶
AddRequiredArgument adds a required string argument.
type Example ¶
type Example struct {
Description string `json:"description,omitempty"`
Input string `json:"input"`
Output string `json:"output,omitempty"`
}
Example represents a usage example.
type MarshalError ¶
MarshalError occurs when marshaling to tool-specific format fails.
func (*MarshalError) Error ¶
func (e *MarshalError) Error() string
func (*MarshalError) Unwrap ¶
func (e *MarshalError) Unwrap() error
type ParseError ¶
ParseError occurs when parsing tool-specific format fails.
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 occurs when writing a file fails.
func (*WriteError) Error ¶
func (e *WriteError) Error() string
func (*WriteError) Unwrap ¶
func (e *WriteError) Unwrap() error