config

package
v0.0.0-...-a41f257 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigExists

func ConfigExists(root string) bool

ConfigExists reports whether a local or global config file is already present.

func GlobalPath

func GlobalPath() string

GlobalPath returns the global config file path.

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.

func LocalPath

func LocalPath(root string) string

LocalPath returns the project-local config file path.

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 Default

func Default() *Config

Default returns the default configuration.

func Load

func Load(root string) *Config

Load merges default, global, and local config in that order.

func (*Config) ProviderNames

func (c *Config) ProviderNames() []string

ProviderNames returns the ordered list of enabled provider names.

func (*Config) ProviderPreserveScrollback

func (c *Config) ProviderPreserveScrollback(name string) bool

ProviderPreserveScrollback returns whether inline/no-alt-screen mode should be used.

func (*Config) ProviderPriority

func (c *Config) ProviderPriority(name string) int

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

func (c *Config) ProviderResetCycle(name string) string

ProviderResetCycle returns the configured reset cycle for the provider. Returns "" when not configured.

func (*Config) ProviderThreshold

func (c *Config) ProviderThreshold(name string) int

ProviderThreshold returns the effective threshold for the provider.

func (*Config) ProviderWarnThreshold

func (c *Config) ProviderWarnThreshold(name string) int

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

func (c *Config) ProviderWeeklyThreshold(name string) int

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

func (c *Config) ProviderWeeklyWarnThreshold(name string) int

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

func (c *Config) SaveGlobal() error

SaveGlobal writes the config to the user's global config path.

func (*Config) SaveLocal

func (c *Config) SaveLocal(root string) error

SaveLocal writes the config to .tasuki/config.yaml.

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.

Jump to

Keyboard shortcuts

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