Documentation
¶
Overview ¶
Package config contains configuration types for agnt.
Package config provides port detection for auto-started scripts.
Index ¶
- Constants
- func FindAgntConfigFile(dir string) string
- func GlobalConfigPath() string
- func WriteDefaultAgntConfig(path string) error
- func WriteDefaultConfig(path string) error
- type AgntConfig
- type AgntProjectMeta
- type CommandConfig
- type Config
- type HooksConfig
- type KDLCommand
- type KDLConfig
- type KDLLanguage
- type KDLLanguages
- type KDLProjectConfig
- type KDLSettings
- type LanguageConfig
- type PortDetector
- type ProjectConfig
- type ProxyConfig
- type ResponseHookConfig
- type ScriptConfig
- type Settings
- type ToastConfig
Constants ¶
const ( GlobalConfigFile = "config.kdl" ProjectConfigFile = ".agnt.kdl" )
KDL configuration file names
const AgntConfigFileName = ".agnt.kdl"
AgntConfigFileName is the name of the agnt configuration file.
Variables ¶
This section is empty.
Functions ¶
func FindAgntConfigFile ¶ added in v0.7.8
FindAgntConfigFile searches for .agnt.kdl starting from dir and walking up.
func GlobalConfigPath ¶
func GlobalConfigPath() string
GlobalConfigPath returns the path to the global config file.
func WriteDefaultAgntConfig ¶ added in v0.7.8
WriteDefaultAgntConfig writes a default configuration file with documentation.
func WriteDefaultConfig ¶
WriteDefaultConfig writes a default config file with documentation.
Types ¶
type AgntConfig ¶ added in v0.7.8
type AgntConfig struct {
// Project metadata (optional, for documentation/info only)
Project *AgntProjectMeta `kdl:"project"`
// Scripts to manage
Scripts map[string]*ScriptConfig `kdl:"scripts"`
// Proxies to manage
Proxies map[string]*ProxyConfig `kdl:"proxies"`
// Hooks configuration
Hooks *HooksConfig `kdl:"hooks"`
// Toast notification settings
Toast *ToastConfig `kdl:"toast"`
}
AgntConfig represents the agnt configuration. All fields use standard KDL format with child nodes.
func DefaultAgntConfig ¶ added in v0.7.8
func DefaultAgntConfig() *AgntConfig
DefaultAgntConfig returns a config with sensible defaults.
func LoadAgntConfig ¶ added in v0.7.8
func LoadAgntConfig(dir string) (*AgntConfig, error)
LoadAgntConfig loads configuration from the specified directory. It looks for .agnt.kdl in the directory and its parents.
func LoadAgntConfigFile ¶ added in v0.7.8
func LoadAgntConfigFile(path string) (*AgntConfig, error)
LoadAgntConfigFile loads configuration from a specific file.
func ParseAgntConfig ¶ added in v0.7.8
func ParseAgntConfig(data string) (*AgntConfig, error)
ParseAgntConfig parses KDL configuration data using the official kdl-go parser. Only standard KDL format is supported.
func (*AgntConfig) GetAutostartProxies ¶ added in v0.7.8
func (c *AgntConfig) GetAutostartProxies() map[string]*ProxyConfig
GetAutostartProxies returns proxies configured for autostart.
func (*AgntConfig) GetAutostartScripts ¶ added in v0.7.8
func (c *AgntConfig) GetAutostartScripts() map[string]*ScriptConfig
GetAutostartScripts returns scripts configured for autostart.
type AgntProjectMeta ¶ added in v0.11.1
AgntProjectMeta contains optional project metadata in .agnt.kdl. This is informational only and doesn't affect behavior.
type CommandConfig ¶
type CommandConfig struct {
// Command is the executable name.
Command string `json:"command"`
// Args are the default arguments.
Args []string `json:"args"`
// Description is a human-readable description.
Description string `json:"description,omitempty"`
// Timeout is the command timeout in seconds.
Timeout int `json:"timeout,omitempty"`
// Persistent indicates this is a long-running process.
Persistent bool `json:"persistent,omitempty"`
// Env holds environment variables to set.
Env map[string]string `json:"env,omitempty"`
}
CommandConfig holds configuration for a single command.
func (*CommandConfig) ToCommandDef ¶
func (c *CommandConfig) ToCommandDef(name string) project.CommandDef
ToCommandDef converts a CommandConfig to a project.CommandDef.
type Config ¶
type Config struct {
// Version is the config file version.
Version string `json:"version"`
// Settings are global server settings.
Settings Settings `json:"settings"`
// Languages holds language-specific configurations.
Languages map[string]LanguageConfig `json:"languages"`
}
Config holds the complete server configuration.
func LoadConfigFile ¶
LoadConfigFile loads configuration from a specific file path.
func LoadGlobalConfig ¶
LoadGlobalConfig loads the global configuration from the default location.
func ParseKDLConfig ¶
ParseKDLConfig parses KDL configuration data.
func (*Config) GetLanguageCommands ¶
func (c *Config) GetLanguageCommands(lang string) []project.CommandDef
GetLanguageCommands returns command definitions for a language.
func (*Config) MergeProjectConfig ¶
func (c *Config) MergeProjectConfig(projConfig *ProjectConfig) *Config
MergeProjectConfig merges per-project config with global config.
type HooksConfig ¶ added in v0.7.8
type HooksConfig struct {
// OnResponse controls what happens when Claude responds
OnResponse *ResponseHookConfig `kdl:"on-response"`
}
HooksConfig defines hook behavior.
type KDLCommand ¶
type KDLCommand struct {
Command string `kdl:"cmd"`
Args []string `kdl:"args"`
Timeout int `kdl:"timeout"`
Persistent bool `kdl:"persistent"`
Env map[string]string `kdl:"env"`
}
KDLCommand holds a command configuration.
type KDLConfig ¶
type KDLConfig struct {
Version string `kdl:"version"`
Settings KDLSettings `kdl:"settings"`
Languages KDLLanguages `kdl:"languages"`
}
KDLConfig represents the KDL configuration structure. Uses kdl struct tags for unmarshaling.
type KDLLanguage ¶
type KDLLanguage struct {
Markers []string `kdl:"markers"`
Priority int `kdl:"priority"`
PackageManagerDetect bool `kdl:"package-manager-detect"`
Commands map[string]*KDLCommand `kdl:"commands"`
}
KDLLanguage holds configuration for a specific language.
type KDLLanguages ¶
type KDLLanguages struct {
Go *KDLLanguage `kdl:"go"`
Node *KDLLanguage `kdl:"node"`
Python *KDLLanguage `kdl:"python"`
}
KDLLanguages holds language configurations.
type KDLProjectConfig ¶
type KDLProjectConfig struct {
Language string `kdl:"language"`
PackageManager string `kdl:"package-manager"`
Commands map[string]*KDLCommand `kdl:"commands"`
}
KDLProjectConfig holds per-project configuration.
type KDLSettings ¶
type KDLSettings struct {
DefaultTimeout int `kdl:"default-timeout"`
MaxOutputBuffer int `kdl:"max-output-buffer"`
GracefulTimeout int `kdl:"graceful-timeout"`
}
KDLSettings holds global settings from KDL.
type LanguageConfig ¶
type LanguageConfig struct {
// Markers are files that identify this project type.
Markers []string `json:"markers"`
// Priority determines detection order (higher = first).
Priority int `json:"priority"`
// Commands are the available commands for this language.
Commands map[string]CommandConfig `json:"commands"`
// PackageManagerDetect enables automatic package manager detection (Node.js).
PackageManagerDetect bool `json:"package_manager_detect,omitempty"`
}
LanguageConfig holds configuration for a specific language.
type PortDetector ¶ added in v0.7.8
type PortDetector struct {
// contains filtered or unexported fields
}
PortDetector detects listening ports from processes.
func NewPortDetector ¶ added in v0.7.8
func NewPortDetector() *PortDetector
NewPortDetector creates a new port detector with common patterns.
func (*PortDetector) DetectFromOutput ¶ added in v0.7.8
func (pd *PortDetector) DetectFromOutput(output string) int
DetectFromOutput scans output text for port patterns. Returns the first port found, or 0 if none detected.
func (*PortDetector) DetectFromPID ¶ added in v0.7.8
func (pd *PortDetector) DetectFromPID(ctx context.Context, pid int) []int
DetectFromPID finds listening TCP ports for a process using ss or lsof. Returns all detected ports.
func (*PortDetector) WaitForPort ¶ added in v0.7.8
func (pd *PortDetector) WaitForPort(ctx context.Context, pid int, getOutput func() string, timeout time.Duration) int
WaitForPort waits for a port to be detected, either from output or PID. Returns the detected port or 0 if timeout expires.
type ProjectConfig ¶
type ProjectConfig struct {
// Language overrides the detected language.
Language string `json:"language,omitempty"`
// PackageManager overrides the detected package manager.
PackageManager string `json:"package_manager,omitempty"`
// Commands override default commands.
Commands map[string]CommandConfig `json:"commands,omitempty"`
}
ProjectConfig holds per-project configuration from .agnt.kdl.
func LoadProjectConfig ¶
func LoadProjectConfig(projectPath string) (*ProjectConfig, error)
LoadProjectConfig loads per-project configuration from .agnt.kdl.
func ParseProjectConfig ¶
func ParseProjectConfig(data string) (*ProjectConfig, error)
ParseProjectConfig parses per-project KDL configuration.
type ProxyConfig ¶ added in v0.7.8
type ProxyConfig struct {
// Autostart starts the proxy when session opens
Autostart bool `kdl:"autostart"`
// MaxLogSize is the max number of log entries to keep
MaxLogSize int `kdl:"max-log-size"`
// Script links this proxy to a script for URL detection from output
Script string `kdl:"script"`
// URLPattern filters which detected URLs should trigger this proxy.
// Regex pattern matched against detected URLs. Use to select specific ports
// when a script outputs multiple URLs (e.g., ":34115" to match Wails backend).
URLPattern string `kdl:"url-pattern"`
// URL is the full target URL (e.g., "http://localhost:3000")
URL string `kdl:"url"`
// Target is the backend URL (deprecated, use URL instead)
Target string `kdl:"target"`
// Port is the target port - shorthand for http://localhost:PORT
Port int `kdl:"port"`
// FallbackPort is used when script URL detection fails
FallbackPort int `kdl:"fallback-port"`
// Host is the target host (default: localhost)
Host string `kdl:"host"`
// Bind is the address the proxy listens on
// "127.0.0.1" (default) or "0.0.0.0" (all interfaces)
Bind string `kdl:"bind"`
// Websocket enables WebSocket proxying
Websocket bool `kdl:"websocket"`
}
ProxyConfig defines a reverse proxy to start.
type ResponseHookConfig ¶ added in v0.7.8
type ResponseHookConfig struct {
// Toast shows a toast notification in the browser
Toast bool `kdl:"toast"`
// Indicator updates the bug indicator
Indicator bool `kdl:"indicator"`
// Sound plays a notification sound
Sound bool `kdl:"sound"`
}
ResponseHookConfig controls response notification behavior.
type ScriptConfig ¶ added in v0.7.8
type ScriptConfig struct {
// Run is a shell command string (executed via sh -c)
Run string `kdl:"run"`
// Command is the executable name (used with Args)
Command string `kdl:"command"`
// Args are command arguments (used with Command)
Args []string `kdl:"args"`
// Autostart starts the script when session opens
Autostart bool `kdl:"autostart"`
// URLMatchers are patterns for URL detection in output
URLMatchers []string `kdl:"url-matchers"`
// Env are environment variables for the script
Env map[string]string `kdl:"env"`
// Cwd is the working directory for the script
Cwd string `kdl:"cwd"`
}
ScriptConfig defines a script to run.
type Settings ¶
type Settings struct {
// DefaultTimeout is the default process timeout.
DefaultTimeout time.Duration `json:"default_timeout"`
// MaxOutputBuffer is the per-stream output buffer size.
MaxOutputBuffer int `json:"max_output_buffer"`
// GracefulTimeout is the graceful shutdown timeout.
GracefulTimeout time.Duration `json:"graceful_timeout"`
}
Settings holds global configuration settings.
type ToastConfig ¶ added in v0.7.8
type ToastConfig struct {
// Duration in milliseconds (default 4000)
Duration int `kdl:"duration"`
// Position: "top-right", "top-left", "bottom-right", "bottom-left"
Position string `kdl:"position"`
// MaxVisible is the max number of visible toasts (default 3)
MaxVisible int `kdl:"max-visible"`
}
ToastConfig configures toast notifications.