Documentation
¶
Index ¶
- Variables
- func AddMarketplace(name string, source MarketplaceSource, scope Scope, projectPath string) error
- func AllMarketplaces(projectPath string) (map[string]ExtraMarketplace, error)
- func AtomicRename(tmpPath, finalPath string) error
- func LocalSettingsPath(projectPath string) (string, error)
- func ManagedSettingsPath() (string, error)
- func ProjectSettingsPath(projectPath string) (string, error)
- func RemoveMarketplace(name string, scope Scope, projectPath string) error
- func RemovePluginFromScope(fullName string, scope Scope, projectPath string) error
- func SaveSettings(s *Settings, scope Scope, projectPath string) error
- func ScopePath(scope Scope, projectPath string) (string, error)
- func SetPluginEnabled(fullName string, enabled bool, scope Scope, projectPath string) error
- func UserSettingsPath() (string, error)
- func WithLock(path string, fn func() error) error
- type ExtraMarketplace
- type FileLock
- type MarketplaceSource
- type PluginState
- func FilterByScope(states []PluginState, scope Scope) []PluginState
- func FilterDisabled(states []PluginState) []PluginState
- func FilterEnabled(states []PluginState) []PluginState
- func GetPluginState(pluginFullName string, projectPath string) (*PluginState, error)
- func MergedPluginStates(projectPath string) ([]PluginState, error)
- type Scope
- type Settings
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidScope is returned when an unknown scope is provided ErrInvalidScope = errors.New("invalid scope: must be managed, user, project, or local") // ErrManagedReadOnly is returned when attempting to write to managed scope ErrManagedReadOnly = errors.New("managed scope is read-only") )
Errors for the settings package
Functions ¶
func AddMarketplace ¶
func AddMarketplace(name string, source MarketplaceSource, scope Scope, projectPath string) error
AddMarketplace adds a marketplace to the specified scope
func AllMarketplaces ¶
func AllMarketplaces(projectPath string) (map[string]ExtraMarketplace, error)
AllMarketplaces returns all extra marketplaces from all scopes merged Precedence order applies (higher precedence scope wins on conflicts)
func AtomicRename ¶
AtomicRename performs an atomic rename with Windows fallback Exported for use by other packages (install.go, remove.go)
func LocalSettingsPath ¶
LocalSettingsPath returns the path to local settings.json
func ManagedSettingsPath ¶
ManagedSettingsPath returns the path to managed settings.json
func ProjectSettingsPath ¶
ProjectSettingsPath returns the path to project settings.json
func RemoveMarketplace ¶
RemoveMarketplace removes a marketplace from the specified scope
func RemovePluginFromScope ¶
RemovePluginFromScope removes a plugin entry from a specific scope
func SaveSettings ¶
SaveSettings saves settings to a specific scope Creates the necessary directories if they don't exist
func ScopePath ¶
ScopePath returns the settings.json path for a given scope For project/local scopes, projectPath must be provided
func SetPluginEnabled ¶
SetPluginEnabled sets the enabled state for a plugin in the specified scope
func UserSettingsPath ¶
UserSettingsPath returns the path to user settings.json
Types ¶
type ExtraMarketplace ¶
type ExtraMarketplace struct {
Source MarketplaceSource `json:"source"`
}
ExtraMarketplace represents a marketplace entry in settings
type FileLock ¶
type FileLock struct {
// contains filtered or unexported fields
}
FileLock provides advisory file locking for concurrent access protection
func NewFileLock ¶
NewFileLock creates a new file lock for the given path The lock file will be created at path + ".lock"
type MarketplaceSource ¶
type MarketplaceSource struct {
Source string `json:"source"` // e.g., "github"
Repo string `json:"repo"` // e.g., "owner/repo"
}
MarketplaceSource represents the source of a marketplace
type PluginState ¶
PluginState represents the enabled/disabled state of a plugin with its scope
func FilterByScope ¶
func FilterByScope(states []PluginState, scope Scope) []PluginState
FilterByScope returns plugin states filtered to a specific scope
func FilterDisabled ¶
func FilterDisabled(states []PluginState) []PluginState
FilterDisabled returns only disabled plugin states
func FilterEnabled ¶
func FilterEnabled(states []PluginState) []PluginState
FilterEnabled returns only enabled plugin states
func GetPluginState ¶
func GetPluginState(pluginFullName string, projectPath string) (*PluginState, error)
GetPluginState returns the effective state for a specific plugin Returns the state from the highest precedence scope that has it
func MergedPluginStates ¶
func MergedPluginStates(projectPath string) ([]PluginState, error)
MergedPluginStates loads all scopes and returns plugin states with scope information, respecting precedence order Precedence: Managed > Local > Project > User
type Scope ¶
type Scope string
Scope represents a Claude Code settings scope
const ( // ScopeManaged is the system-wide managed scope (read-only) // Location: /etc/claude-code/settings.json (Unix) or C:\ProgramData\ClaudeCode\settings.json (Windows) ScopeManaged Scope = "managed" // ScopeUser is the user-level scope // Location: ~/.claude/settings.json ScopeUser Scope = "user" // ScopeProject is the project-level scope (checked into git) // Location: <project>/.claude/settings.json ScopeProject Scope = "project" // ScopeLocal is the local project scope (gitignored) // Location: <project>/.claude/settings.local.json ScopeLocal Scope = "local" )
func AllScopes ¶
func AllScopes() []Scope
AllScopes returns all scopes in precedence order (highest to lowest)
func WritableScopes ¶
func WritableScopes() []Scope
WritableScopes returns scopes that can be written to
func (Scope) IsWritable ¶
IsWritable returns true if the scope can be written to
type Settings ¶
type Settings struct {
// EnabledPlugins maps plugin@marketplace to enabled/disabled state
EnabledPlugins map[string]bool `json:"enabledPlugins,omitempty"`
// ExtraKnownMarketplaces stores additional marketplaces configured in this scope
ExtraKnownMarketplaces map[string]ExtraMarketplace `json:"extraKnownMarketplaces,omitempty"`
// contains filtered or unexported fields
}
Settings represents the Claude Code settings.json structure It preserves all unknown fields when reading/writing to avoid destroying user configuration that plum doesn't manage (e.g., permissions, hooks, model)
func LoadSettings ¶
LoadSettings loads settings from a specific scope Returns empty settings (not error) if file doesn't exist
func LoadSettingsFromPath ¶
LoadSettingsFromPath loads settings from a specific file path Returns empty settings (not error) if file doesn't exist
func (*Settings) MarshalJSON ¶
MarshalJSON implements custom JSON marshaling to preserve unknown fields
func (*Settings) UnmarshalJSON ¶
UnmarshalJSON implements custom JSON unmarshaling to preserve unknown fields