config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransportHTTP  = "http"
	TransportStdio = "stdio"
)

MCP transport type constants.

View Source
const BuiltinRepoRootEnvVar = "AL_REPO_ROOT"

BuiltinRepoRootEnvVar is the built-in placeholder for the repo root path.

Variables

This section is empty.

Functions

func ExpandPath added in v0.5.6

func ExpandPath(value string, repoRoot string) (string, error)

ExpandPath expands "~" and resolves relative paths against repoRoot. value is the resolved string (placeholders already substituted).

func ExpandPathIfNeeded added in v0.5.6

func ExpandPathIfNeeded(raw string, value string, repoRoot string) (string, error)

ExpandPathIfNeeded expands value when the raw input signals a path placeholder.

func ExtractEnvVarNames

func ExtractEnvVarNames(input string) []string

ExtractEnvVarNames returns env var names referenced by ${VAR} placeholders. input is a string that may contain placeholders; returns names in scan order.

func IsBuiltInEnvVar added in v0.5.6

func IsBuiltInEnvVar(name string) bool

IsBuiltInEnvVar reports whether name is reserved for built-in placeholders.

func LoadCommandsAllow

func LoadCommandsAllow(path string) ([]string, error)

LoadCommandsAllow reads .agent-layer/commands.allow into a slice of prefixes.

func LoadCommandsAllowFS added in v0.5.7

func LoadCommandsAllowFS(fsys fs.FS, root string, path string) ([]string, error)

LoadCommandsAllowFS reads .agent-layer/commands.allow from fsys into a slice of prefixes. root is used for path resolution when path is absolute; path is used for error messages.

func LoadEnv

func LoadEnv(path string) (map[string]string, error)

LoadEnv reads .agent-layer/.env into a key-value map.

func LoadEnvFS added in v0.5.7

func LoadEnvFS(fsys fs.FS, root string, path string) (map[string]string, error)

LoadEnvFS reads .agent-layer/.env from fsys into a key-value map. root is used for path resolution when path is absolute; path is used for error messages.

func RequiredEnvVarsForMCPServer

func RequiredEnvVarsForMCPServer(server MCPServer) []string

RequiredEnvVarsForMCPServer returns required env var names for a single MCP server. server is the MCP server definition; returns a sorted list of unique names.

func RequiredEnvVarsForMCPServers

func RequiredEnvVarsForMCPServers(servers []MCPServer) []string

RequiredEnvVarsForMCPServers returns required env var names across all MCP servers. servers is a list of MCP server definitions; returns a sorted list of unique names.

func ShouldExpandPath added in v0.5.6

func ShouldExpandPath(value string) bool

ShouldExpandPath reports whether value requests path expansion. Path expansion is enabled when the value starts with "~" or "${AL_REPO_ROOT}".

func SubstituteEnvVars

func SubstituteEnvVars(input string, env map[string]string) (string, error)

SubstituteEnvVars replaces ${VAR} placeholders using env values.

func SubstituteEnvVarsWith

func SubstituteEnvVarsWith(input string, env map[string]string, replacer EnvVarReplacer) (string, error)

SubstituteEnvVarsWith replaces ${VAR} placeholders using env values and a replacer.

func WalkInstructionFiles

func WalkInstructionFiles(dir string, fn func(path string, entry fs.DirEntry) error) error

WalkInstructionFiles is a helper to walk instruction files in a directory.

func WithBuiltInEnv added in v0.5.6

func WithBuiltInEnv(env map[string]string, repoRoot string) map[string]string

WithBuiltInEnv returns a copy of env with built-in values added. env is the parsed .env map; repoRoot should be the absolute repo root path.

Types

type AgentConfig

type AgentConfig struct {
	Enabled *bool  `toml:"enabled"`
	Model   string `toml:"model"`
}

AgentConfig is shared by agents that only need enablement and model selection.

type AgentsConfig

type AgentsConfig struct {
	Gemini      AgentConfig `toml:"gemini"`
	Claude      AgentConfig `toml:"claude"`
	Codex       CodexConfig `toml:"codex"`
	VSCode      AgentConfig `toml:"vscode"`
	Antigravity AgentConfig `toml:"antigravity"`
}

AgentsConfig holds per-client enablement and model selection.

type ApprovalsConfig

type ApprovalsConfig struct {
	Mode string `toml:"mode"`
}

ApprovalsConfig controls auto-approval behavior per client.

type CodexConfig

type CodexConfig struct {
	Enabled         *bool  `toml:"enabled"`
	Model           string `toml:"model"`
	ReasoningEffort string `toml:"reasoning_effort"`
}

CodexConfig extends AgentConfig with Codex-specific settings.

type Config

type Config struct {
	Approvals ApprovalsConfig `toml:"approvals"`
	Agents    AgentsConfig    `toml:"agents"`
	MCP       MCPConfig       `toml:"mcp"`
	Warnings  WarningsConfig  `toml:"warnings"`
}

Config is the root configuration loaded from .agent-layer/config.toml.

func LoadConfig

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

LoadConfig reads .agent-layer/config.toml and validates it.

func LoadConfigFS added in v0.5.7

func LoadConfigFS(fsys fs.FS, root string, path string) (*Config, error)

LoadConfigFS reads .agent-layer/config.toml from fsys and validates it. root is used for path resolution when path is absolute; path is used for error messages.

func LoadTemplateConfig

func LoadTemplateConfig() (*Config, error)

LoadTemplateConfig returns the embedded default config template as a validated Config.

func ParseConfig

func ParseConfig(data []byte, source string) (*Config, error)

ParseConfig parses and validates config TOML data from a source identifier. data is the TOML content; source is used in error messages.

func (*Config) Validate

func (c *Config) Validate(path string) error

Validate ensures the config is complete and consistent.

type EnvVarReplacer

type EnvVarReplacer func(name string, value string) string

EnvVarReplacer returns a replacement string for a resolved env var.

type InstructionFile

type InstructionFile struct {
	Name    string
	Content string
}

InstructionFile holds a single instruction fragment.

func LoadInstructions

func LoadInstructions(dir string) ([]InstructionFile, error)

LoadInstructions reads .agent-layer/instructions/*.md in lexicographic order.

func LoadInstructionsFS added in v0.5.7

func LoadInstructionsFS(fsys fs.FS, root string, dir string) ([]InstructionFile, error)

LoadInstructionsFS reads .agent-layer/instructions/*.md from fsys in lexicographic order. root is used for path resolution when dir is absolute; dir is used for error messages.

type MCPConfig

type MCPConfig struct {
	Servers []MCPServer `toml:"servers"`
}

MCPConfig contains the external MCP servers configuration.

type MCPServer

type MCPServer struct {
	ID            string            `toml:"id"`
	Enabled       *bool             `toml:"enabled"`
	Clients       []string          `toml:"clients"`
	Transport     string            `toml:"transport"`
	HTTPTransport string            `toml:"http_transport"`
	URL           string            `toml:"url"`
	Headers       map[string]string `toml:"headers"`
	Command       string            `toml:"command"`
	Args          []string          `toml:"args"`
	Env           map[string]string `toml:"env"`
}

MCPServer defines a single MCP server entry.

func (MCPServer) AppliesToClient

func (s MCPServer) AppliesToClient(client string) bool

AppliesToClient reports whether the server is enabled for the given client.

type Paths

type Paths struct {
	Root             string
	ConfigPath       string
	EnvPath          string
	InstructionsDir  string
	SlashCommandsDir string
	CommandsAllow    string
}

Paths holds resolved paths for config files and directories.

func DefaultPaths

func DefaultPaths(root string) Paths

DefaultPaths returns the default config paths for a repo root.

type ProjectConfig

type ProjectConfig struct {
	Config        Config
	Env           map[string]string
	Instructions  []InstructionFile
	SlashCommands []SlashCommand
	CommandsAllow []string
	Root          string
}

ProjectConfig is the fully loaded configuration state for sync and launch.

func LoadProjectConfig

func LoadProjectConfig(root string) (*ProjectConfig, error)

LoadProjectConfig reads and validates the full Agent Layer config from disk.

func LoadProjectConfigFS added in v0.5.7

func LoadProjectConfigFS(fsys fs.FS, root string) (*ProjectConfig, error)

LoadProjectConfigFS reads and validates the full Agent Layer config from an fs.FS rooted at repo root. fsys is the filesystem to read from; root is used for error messages and built-in env values.

type SlashCommand

type SlashCommand struct {
	Name        string
	Description string
	Body        string
	SourcePath  string
}

SlashCommand represents a parsed slash command with metadata and body.

func LoadSlashCommands

func LoadSlashCommands(dir string) ([]SlashCommand, error)

LoadSlashCommands reads .agent-layer/slash-commands/*.md in lexicographic order.

func LoadSlashCommandsFS added in v0.5.7

func LoadSlashCommandsFS(fsys fs.FS, root string, dir string) ([]SlashCommand, error)

LoadSlashCommandsFS reads .agent-layer/slash-commands/*.md from fsys in lexicographic order. root is used for path resolution when dir is absolute; dir is used for error messages.

type WarningsConfig

type WarningsConfig struct {
	VersionUpdateOnSync            *bool `toml:"version_update_on_sync"`
	InstructionTokenThreshold      *int  `toml:"instruction_token_threshold"`
	MCPServerThreshold             *int  `toml:"mcp_server_threshold"`
	MCPToolsTotalThreshold         *int  `toml:"mcp_tools_total_threshold"`
	MCPServerToolsThreshold        *int  `toml:"mcp_server_tools_threshold"`
	MCPSchemaTokensTotalThreshold  *int  `toml:"mcp_schema_tokens_total_threshold"`
	MCPSchemaTokensServerThreshold *int  `toml:"mcp_schema_tokens_server_threshold"`
}

WarningsConfig configures optional warning thresholds. Nil fields disable their warnings.

Jump to

Keyboard shortcuts

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