config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCacheDir

func DefaultCacheDir() string

DefaultCacheDir returns the default cache directory

func DefaultConfigDir

func DefaultConfigDir() string

DefaultConfigDir returns the default configuration directory

func FindProjectConfig

func FindProjectConfig(dir string) (string, bool)

FindProjectConfig walks up from dir looking for .agentctl.json

func HasProjectConfig

func HasProjectConfig() bool

HasProjectConfig checks if current directory has a project config

Types

type AutoUpdateConfig

type AutoUpdateConfig struct {
	Enabled  bool              `json:"enabled"`
	Interval string            `json:"interval,omitempty"` // e.g., "24h"
	Servers  map[string]string `json:"servers,omitempty"`  // "auto" or "notify" per server
}

AutoUpdateConfig configures automatic update behavior

type Config

type Config struct {
	Version  string                 `json:"version"`
	Servers  map[string]*mcp.Server `json:"servers,omitempty"`
	Commands []string               `json:"commands,omitempty"` // Command names to include
	Rules    []string               `json:"rules,omitempty"`    // Rule names to include
	Skills   []string               `json:"skills,omitempty"`   // Skill names to include
	Disabled []string               `json:"disabled,omitempty"` // Resources to disable
	Profile  string                 `json:"profile,omitempty"`  // Active profile (for project configs)
	Settings Settings               `json:"settings,omitempty"`

	// Loaded resources (not serialized)
	LoadedCommands []*command.Command `json:"-"`
	LoadedRules    []*rule.Rule       `json:"-"`
	LoadedSkills   []*skill.Skill     `json:"-"`

	// Path info (not serialized)
	Path        string `json:"-"` // Path to config file
	ConfigDir   string `json:"-"` // Config directory
	ProjectPath string `json:"-"` // Path to project config (if loaded from project)
}

Config represents the main agentctl configuration

func InitProjectConfig

func InitProjectConfig(dir string) (*Config, error)

InitProjectConfig creates a .agentctl.json in the given directory

func Load

func Load() (*Config, error)

Load loads the configuration from the default location

func LoadFrom

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

LoadFrom loads configuration from a specific path

func LoadProjectConfig

func LoadProjectConfig(projectDir string) (*Config, error)

LoadProjectConfig loads a project-local configuration and merges with global

func LoadScoped

func LoadScoped(scope Scope) (*Config, error)

LoadScoped loads configuration for a specific scope only

func LoadWithProject

func LoadWithProject() (*Config, error)

LoadWithProject loads global config merged with any project config in cwd

func (*Config) ActiveServers

func (c *Config) ActiveServers() []*mcp.Server

ActiveServers returns the list of non-disabled servers

func (*Config) CacheDir

func (c *Config) CacheDir() string

CacheDir returns the cache directory for this config

func (*Config) CommandsForScope

func (c *Config) CommandsForScope(scope Scope) []*command.Command

CommandsForScope returns commands that belong to a specific scope

func (*Config) GetServerScope

func (c *Config) GetServerScope(name string) Scope

GetServerScope returns the scope of a specific server

func (*Config) LocalResourceDir

func (c *Config) LocalResourceDir() string

LocalResourceDir returns the local resource directory path for the project

func (*Config) Merge

func (c *Config) Merge(other *Config) *Config

Merge merges another config into this one (other takes precedence) Servers from the base config are marked as "global", servers from other are marked as "local"

func (*Config) ProjectDir

func (c *Config) ProjectDir() string

ProjectDir returns the project directory if a project config is loaded

func (*Config) ReloadResources

func (c *Config) ReloadResources() error

ReloadResources reloads all resources from disk (global and local) This should be called after creating, editing, or deleting resources

func (*Config) RulesForScope

func (c *Config) RulesForScope(scope Scope) []*rule.Rule

RulesForScope returns rules that belong to a specific scope

func (*Config) Save

func (c *Config) Save() error

Save saves the configuration to disk

func (*Config) SaveScoped

func (c *Config) SaveScoped(scope Scope) error

SaveScoped saves the configuration to the appropriate location based on scope

func (*Config) SaveTo

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

SaveTo saves the configuration to a specific path

func (*Config) ServersForScope

func (c *Config) ServersForScope(scope Scope) []*mcp.Server

ServersForScope returns servers that belong to a specific scope

func (*Config) SkillsForScope

func (c *Config) SkillsForScope(scope Scope) []*skill.Skill

SkillsForScope returns skills that belong to a specific scope

type Scope

type Scope string

Scope represents the configuration scope (local/project vs global/user)

const (
	// ScopeLocal represents project-specific configuration (.agentctl.json)
	ScopeLocal Scope = "local"

	// ScopeGlobal represents user-wide configuration (~/.config/agentctl/agentctl.json)
	ScopeGlobal Scope = "global"

	// ScopeAll represents both scopes (used for sync operations)
	ScopeAll Scope = "all"
)

func ParseScope

func ParseScope(s string) (Scope, error)

ParseScope parses a string into a Scope value Accepts aliases: "project" for "local", "user" for "global"

func (Scope) Description

func (s Scope) Description() string

Description returns a human-readable description of the scope

func (Scope) IsValid

func (s Scope) IsValid() bool

IsValid returns true if the scope is a valid value

func (Scope) ShortString

func (s Scope) ShortString() string

ShortString returns a short indicator for display (e.g., [G] or [L])

func (Scope) String

func (s Scope) String() string

String returns the string representation of the scope

type Settings

type Settings struct {
	DefaultProfile string                `json:"defaultProfile,omitempty"`
	AutoUpdate     AutoUpdateConfig      `json:"autoUpdate,omitempty"`
	Tools          map[string]ToolConfig `json:"tools,omitempty"`
}

Settings contains global settings

type ToolConfig

type ToolConfig struct {
	Enabled   bool           `json:"enabled"`
	Overrides map[string]any `json:"overrides,omitempty"`
}

ToolConfig configures a specific tool

Jump to

Keyboard shortcuts

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