Documentation
¶
Index ¶
- func ConfigExists(root string) bool
- func GlobalPath() string
- func InteractiveInit(opts InitOptions) (string, error)
- func LocalPath(root string) string
- type Config
- func (c *Config) ProviderNames() []string
- func (c *Config) ProviderPreserveScrollback(name string) bool
- func (c *Config) ProviderPriority(name string) int
- func (c *Config) ProviderResetCycle(name string) string
- func (c *Config) ProviderThreshold(name string) int
- func (c *Config) ProviderWarnThreshold(name string) int
- func (c *Config) ProviderWeeklyThreshold(name string) int
- func (c *Config) ProviderWeeklyWarnThreshold(name string) int
- func (c *Config) SaveGlobal() error
- func (c *Config) SaveLocal(root string) error
- type DetectedTool
- type InitOptions
- type ProviderConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigExists ¶
ConfigExists reports whether a local or global config file is already present.
func InteractiveInit ¶
func InteractiveInit(opts InitOptions) (string, error)
InteractiveInit walks the user through detecting installed CLIs and selecting which providers to enable, then writes the resulting config. Returns the path that was written.
Types ¶
type Config ¶
type Config struct {
SwitchThreshold int `yaml:"switch_threshold,omitempty"`
WarnThreshold int `yaml:"warn_threshold,omitempty"`
// WeeklySwitchThreshold applies to the weekly (7-day) rate-limit window.
// 0 disables weekly monitoring — detectors ignore "7d" / "weekly" signals.
// Per-provider overrides (ProviderConfig.WeeklySwitchThreshold) take
// precedence when set.
WeeklySwitchThreshold int `yaml:"weekly_switch_threshold,omitempty"`
WeeklyWarnThreshold int `yaml:"weekly_warn_threshold,omitempty"`
PreserveScrollback bool `yaml:"preserve_scrollback,omitempty"`
// Yolo enables each provider's permission/sandbox bypass flag when true.
Yolo bool `yaml:"yolo,omitempty"`
Providers []ProviderConfig `yaml:"providers"`
WorkDir string `yaml:"-"` // set at runtime, not serialized
}
Config is the top-level relay configuration.
func (*Config) ProviderNames ¶
ProviderNames returns the ordered list of enabled provider names.
func (*Config) ProviderPreserveScrollback ¶
ProviderPreserveScrollback returns whether inline/no-alt-screen mode should be used.
func (*Config) ProviderPriority ¶
ProviderPriority returns the effective priority for a provider. Lower values sort first. Resolution order: explicit Priority > derived from ResetCycle (5h=10, weekly=50, monthly=90) > array position * 100.
func (*Config) ProviderResetCycle ¶
ProviderResetCycle returns the configured reset cycle for the provider. Returns "" when not configured.
func (*Config) ProviderThreshold ¶
ProviderThreshold returns the effective threshold for the provider.
func (*Config) ProviderWarnThreshold ¶
ProviderWarnThreshold returns the effective warning (pre-switch) threshold for the provider. It always sits strictly below the switch threshold; when callers haven't configured one, it's derived as switch - 15 (floor 50).
func (*Config) ProviderWeeklyThreshold ¶
ProviderWeeklyThreshold returns the effective weekly-window switch threshold for the provider. Returns 0 when weekly monitoring is disabled (i.e. neither the provider nor the top-level config sets a positive value).
func (*Config) ProviderWeeklyWarnThreshold ¶
ProviderWeeklyWarnThreshold returns the effective weekly warn threshold. When weekly monitoring is disabled (ProviderWeeklyThreshold == 0) this also returns 0. Otherwise it mirrors ProviderWarnThreshold's fallback logic against the weekly switch threshold.
func (*Config) SaveGlobal ¶
SaveGlobal writes the config to the user's global config path.
type DetectedTool ¶
type DetectedTool struct {
Name string // provider key: claude / codex / copilot
Display string // human-friendly label shown in prompts
Available bool
Path string // resolved binary path when available
ResetCycle string // default subscription cycle for this tool
Priority int // default failover priority (lower wins)
}
DetectedTool represents the result of probing one AI CLI.
func DetectTools ¶
func DetectTools() []DetectedTool
DetectTools probes every supported AI CLI and returns their availability. The slice order doubles as the default failover priority (claude first).
type InitOptions ¶
type InitOptions struct {
In io.Reader
Out io.Writer
Root string
Global bool // when true, skip the save-location question and write to the global path
NonTTY bool // when true, skip prompts and enable every detected tool
Threshold int // switch threshold percentage; 0 falls back to 80
}
InitOptions controls how InteractiveInit behaves.
type ProviderConfig ¶
type ProviderConfig struct {
Name string `yaml:"name"`
Enabled bool `yaml:"enabled"`
SwitchThreshold int `yaml:"switch_threshold,omitempty"`
WarnThreshold int `yaml:"warn_threshold,omitempty"`
// WeeklySwitchThreshold configures the switch threshold for the weekly
// (7-day) rate-limit window. 0 disables weekly monitoring for this
// provider, falling back to the top-level value.
WeeklySwitchThreshold int `yaml:"weekly_switch_threshold,omitempty"`
// WeeklyWarnThreshold mirrors WarnThreshold for the weekly window.
WeeklyWarnThreshold int `yaml:"weekly_warn_threshold,omitempty"`
PreserveScrollback *bool `yaml:"preserve_scrollback,omitempty"`
// ResetCycle is the subscription reset window for this provider.
// Accepted values: "5h", "weekly", "monthly". Empty means unknown.
ResetCycle string `yaml:"reset_cycle,omitempty"`
// Priority controls provider selection order. Lower value = higher priority.
// When nil, priority is derived from ResetCycle (5h < weekly < monthly),
// falling back to the position in the providers array.
Priority *int `yaml:"priority,omitempty"`
}
ProviderConfig holds per-provider settings.