config

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateConfigFile added in v0.0.4

func ValidateConfigFile(configPath string) error

ValidateConfigFile validates the provided YAML configuration file against the JSON Schema.

Behavior: 1) Resolves configPath to a concrete YAML file (if a directory, probes agent-sync.yml then agent-sync.yaml) 2) Resolves schemaPath if empty via default locations (repo CWD, then alongside config file) 3) Loads schema via jsonschema/v5 and validates YAML (converted to JSON) against it

Returns nil on success. Returns *ValidationError on schema violations. Returns other error types for I/O or setup errors.

Types

type Config

type Config struct {
	// ConfigVersion defines the schema version of agent-sync.yml
	ConfigVersion string `yaml:"configVersion"`
	// Projects holds named project configurations
	Projects map[string]Project `yaml:"projects"`
	// New fields for top-level project config
	OutputDirs []string `yaml:"outputDirs,omitempty"`
	Tasks      []Task   `yaml:"tasks,omitempty"`
	// User holds global user-level configuration
	User UserConfig `yaml:"user"`
}

Config represents the root configuration for agent-sync

func LoadConfig

func LoadConfig(path string) (*Config, string, error)

LoadConfig reads and parses the agent-sync YAML configuration from the given path. If the provided path is a directory, it looks for "agent-sync.yml" or "agent-sync.yaml" in that directory.

func (*Config) SetDefaultNames

func (c *Config) SetDefaultNames()

SetDefaultNames sets default names for all tasks across all projects and user config

type Output

type Output struct {
	// Agent is the target AI agent (e.g., "roo", "claude")
	Agent string `yaml:"agent"`
	// OutputPath is an optional custom output path
	// The path format determines concatenation behavior:
	// - If path ends with "/", it will be treated as a directory (non-concatenated outputs)
	// - If path doesn't end with "/", it will be treated as a file (concatenated outputs)
	OutputPath string `yaml:"outputPath,omitempty"`
}

Output represents an output destination for a task

type Project

type Project struct {
	// OutputDirs are the output directories for generated files
	// Supports tilde (~) expansion for home directory.
	OutputDirs []string `yaml:"outputDirs"`
	// Tasks is the list of generation tasks for this project
	Tasks []Task `yaml:"tasks"`
}

Project represents a project-specific configuration block

func (*Project) SetDefaultNames

func (p *Project) SetDefaultNames(projectName string)

SetDefaultNames sets default names for all tasks in this project

type Task

type Task struct {
	// Name is an optional identifier for the task
	Name string `yaml:"name,omitempty"`
	// Type is either "command", "memory", or "mode"
	Type string `yaml:"type"`
	// Inputs are file or directory paths relative to config directory
	Inputs []string `yaml:"inputs"`
	// Outputs define the output agents and paths
	Outputs []Output `yaml:"outputs"`
}

Task represents a single generation task (command, memory, or mode)

func (*Task) SetDefaultName

func (t *Task) SetDefaultName(prefix string)

SetDefaultName sets a default name for a task if one is not provided

type UserConfig

type UserConfig struct {
	// Tasks is the list of generation tasks for user scope
	Tasks []Task `yaml:"tasks"`
	// Home is an optional override for the user's home directory, primarily for debugging purposes
	Home string `yaml:"home,omitempty"`
}

UserConfig represents global user-level configuration

func (*UserConfig) SetDefaultNames

func (u *UserConfig) SetDefaultNames()

SetDefaultNames sets default names for all tasks in user config

type ValidationError added in v0.0.4

type ValidationError struct {
	SourcePath string
	Issues     []ValidationIssue
}

ValidationError aggregates JSON Schema validation issues for a config file.

func (*ValidationError) Error added in v0.0.4

func (e *ValidationError) Error() string

type ValidationIssue added in v0.0.4

type ValidationIssue struct {
	InstancePath string
	Message      string
}

ValidationIssue represents a single schema validation issue.

Jump to

Keyboard shortcuts

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