config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config handles loading, saving, and validating user configuration from JSON files, including project settings, plugin options, keymaps, and UI preferences.

Tasks plugin

The embedded Tasks tab is off by default. It is turned on with the "tasks_plugin" feature flag, not with a plugin config key:

{
  "features": { "flags": { "tasks_plugin": true } }
}

Tasks is a tab of the global space — [Agents] [Workspaces] [Tasks], reached with K or the Sidecar brand — not a project plugin, so it is not part of the project tab order and "plugins.tasks.position" no longer moves it. The field is still accepted and validated so older configs keep loading.

There is deliberately no Tasks store or JSONL path here. The embedded Tasks package performs its own normal configuration resolution.

Index

Constants

View Source
const (
	OverviewWorktreeScopeProject  = "project"
	OverviewWorktreeScopeWorktree = "worktree"
)
View Source
const (
	// TasksPositionAfterWorkspaces places the Tasks tab immediately after the
	// workspaces tab. This is the default.
	TasksPositionAfterWorkspaces = "after-workspaces"
	// TasksPositionAfterNotes places the Tasks tab immediately after the notes
	// tab.
	TasksPositionAfterNotes = "after-notes"
)

Tab positions for the Tasks plugin.

View Source
const AllowRealStateEnv = "SIDECAR_ALLOW_REAL_STATE"

AllowRealStateEnv opts a process out of the automatic isolation that applies to every `go test` binary. Set it to "1" only in a test that deliberately proves the ordinary, unisolated path still works — and only with HOME already pointed at a temp dir.

View Source
const IsolationEnv = "SIDECAR_ISOLATED_STATE"

IsolationEnv is the promise a harness makes: this process must never read or write the real user's Sidecar state. Set it to "1".

The promise exists because tmux isolation and state isolation are separate axes (td-8d18de). A proof run can hold a private tmux socket and still share ~/.local/state/sidecar with the developer's live Sidecar, in which case it rewrites a manifest that instance is watching. Asserting isolation turns every path that resolves back into the real tree into a hard error instead of a silent overwrite.

Variables

This section is empty.

Functions

func AssertIsolatedPath added in v0.93.0

func AssertIsolatedPath(path string) error

AssertIsolatedPath returns an error when isolation is asserted and path resolves inside the real user state or config tree. It returns nil otherwise: an ordinary run is never blocked from writing its own real files.

func CheckStateIsolation added in v0.93.0

func CheckStateIsolation() error

CheckStateIsolation validates the paths this process actually resolved.

func ConfigPath

func ConfigPath() string

ConfigPath returns the path to the config file.

func ExpandPath

func ExpandPath(path string) string

ExpandPath expands ~ to home directory.

func IsolationAsserted added in v0.93.0

func IsolationAsserted() bool

IsolationAsserted reports whether this process claims isolated state.

A test binary asserts it by default. Isolation used to be opt-in, which meant the guard was silently inert in every package that had not thought about it, and `go test ./...` went on creating directories in the developer's real ~/.local/state/sidecar/projects tree — the same tree that holds the shell manifest td-8d18de destroyed. Defaulting to on makes forgetting to isolate a loud failure instead of a silent write.

func MoveProject added in v1.0.0

func MoveProject(projectPath string, delta int) error

MoveProject changes a project's position in the list by delta. The list order is what the switcher and the Projects page show, so it is a real setting.

func RealUserConfigDir added in v0.93.0

func RealUserConfigDir() string

RealUserConfigDir returns $HOME/.config/sidecar, likewise unoverridable.

func RealUserStateDir added in v0.93.0

func RealUserStateDir() string

RealUserStateDir returns the state directory an ordinary run would use, ignoring XDG_STATE_HOME and any test override: $HOME/.local/state/sidecar.

It deliberately derives the root from $HOME rather than from the pre-override value of XDG_STATE_HOME. A harness launches Sidecar as a subprocess with the override already in its environment, so the process has no way to observe what XDG_STATE_HOME was before isolation was applied. $HOME is the one anchor that is still visible from inside, and it is what the XDG default expands to.

func RemoveProject added in v1.0.0

func RemoveProject(projectPath string) error

RemoveProject drops a project from the configured list.

func ResetTestConfigPath

func ResetTestConfigPath()

ResetTestConfigPath clears the test config path override.

func ResetTestStateDir added in v0.75.0

func ResetTestStateDir()

ResetTestStateDir clears the test state directory override.

func Save

func Save(cfg *Config) error

Save writes the config to ~/.config/sidecar/config.json, preserving any keys it doesn't manage (e.g. "prompts").

func SaveCommunityTheme

func SaveCommunityTheme(communityName string, userOverrides map[string]interface{}) error

SaveCommunityTheme saves a community theme reference with optional user overrides. Only the scheme name is stored — the full palette is computed at runtime.

func SaveGlobalTheme

func SaveGlobalTheme(tc ThemeConfig) error

SaveGlobalTheme saves a ThemeConfig as the global UI theme.

func SaveLastOpenInApp added in v0.75.0

func SaveLastOpenInApp(projectPath, appID string) error

SaveLastOpenInApp persists the last-used "open in" app ID. If projectPath matches a configured project, that project's LastOpenInApp is set. The global UI.LastOpenInApp is always set as a fallback.

func SavePlugins added in v1.0.0

func SavePlugins(mutate func(*PluginsConfig)) error

SavePlugins applies a change to the plugins section and writes it. It is the panel-enablement path: which surfaces Sidecar assembles, and the handful of inputs those surfaces read. Like the other helpers it reloads first, so a setting changed in Configuration never overwrites an edit made to the file since Sidecar started, and it validates before writing so an out-of-range interval cannot reach disk.

func SaveProjectTheme

func SaveProjectTheme(projectPath string, theme *ThemeConfig) error

SaveProjectTheme updates a specific project's theme in config and saves.

func SaveTheme

func SaveTheme(themeName string) error

SaveTheme updates only the theme name in config and saves.

func SaveThemeWithOverrides

func SaveThemeWithOverrides(themeName string, overrides map[string]interface{}) error

SaveThemeWithOverrides saves a theme name and full overrides map to config.

func SaveUI added in v1.0.0

func SaveUI(mutate func(*UIConfig)) error

SaveUI applies a change to the ui section and writes it. It reloads first, so a setting changed in Configuration never overwrites an edit made to the file since Sidecar started.

func SaveWorkspace added in v1.0.0

func SaveWorkspace(mutate func(*WorkspacePluginConfig)) error

SaveWorkspace applies a change to the plugins.workspace section and writes it. Like SaveUI it reloads first, so a setting changed in Configuration never overwrites an edit made to the file since Sidecar started.

func SetConfigPath added in v0.93.0

func SetConfigPath(path string)

SetConfigPath records the explicit config path (the -config flag) so that ConfigPath, and everything that derives a directory from it, follow it. Passing "" leaves the default in place.

func SetTestConfigPath

func SetTestConfigPath(path string)

SetTestConfigPath sets a custom config path for testing. Call ResetTestConfigPath() in test cleanup to restore default behavior.

func SetTestStateDir added in v0.75.0

func SetTestStateDir(dir string)

SetTestStateDir sets a custom state directory for testing.

func StateDir added in v0.75.0

func StateDir() string

StateDir returns the directory for sidecar state files. Follows XDG Base Directory Specification: $XDG_STATE_HOME/sidecar (defaults to ~/.local/state/sidecar).

func UpdateProject added in v1.0.0

func UpdateProject(projectPath string, mutate func(*ProjectConfig)) error

UpdateProject applies a change to the project at a path. mutate receives the live entry from a freshly loaded configuration.

Removing or renaming a project deliberately leaves state.json's workdir-keyed entries alone: a stale key is harmless, and rewriting per-surface UI state as a side effect of a settings change is not.

func ValidateProject added in v1.0.0

func ValidateProject(existing []ProjectConfig, name, path string, skipIndex int) string

ValidateProject reports why a name/path pair may not be added, or "" when it is fine. skipIndex excludes one existing entry from the uniqueness checks, so editing a project does not collide with itself; pass -1 when adding.

The returned string is the message a user reads, so it says what is wrong in plain language rather than naming a field.

func ValidateProjectName added in v1.0.0

func ValidateProjectName(existing []ProjectConfig, name string, skipIndex int) string

ValidateProjectName is the rename check: the path is already known good, so only the name is questioned.

Types

type Config

type Config struct {
	Projects ProjectsConfig `json:"projects"`
	Plugins  PluginsConfig  `json:"plugins"`
	Keymap   KeymapConfig   `json:"keymap"`
	UI       UIConfig       `json:"ui"`
	Features FeaturesConfig `json:"features"`
}

Config is the root configuration structure.

func Default

func Default() *Config

Default returns the default configuration.

func Load

func Load() (*Config, error)

Load loads configuration from the path Sidecar is actually using — the -config flag's file, a test's fixture, or the default location. Every read-modify-write helper below goes through it, so a save can never merge against a different file than the one it is about to write.

func LoadFrom

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

LoadFrom loads configuration from a specific path. If path is empty, uses ~/.config/sidecar/config.json

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration for errors.

func (*Config) WorktreeSetupForProject added in v0.94.0

func (c *Config) WorktreeSetupForProject(projectPath string) WorktreeSetupConfig

WorktreeSetupForProject returns the project override when present, otherwise the workspace-wide default.

type ConversationsPluginConfig

type ConversationsPluginConfig struct {
	Enabled       bool   `json:"enabled"`
	ClaudeDataDir string `json:"claudeDataDir"`
	// DefaultCategoryFilter sets the default session category filter on startup.
	// Example: ["interactive"] hides cron/system sessions by default.
	// Empty or omitted means show all sessions (no filter).
	DefaultCategoryFilter []string `json:"defaultCategoryFilter,omitempty"`
}

ConversationsPluginConfig configures the conversations plugin.

type FeaturesConfig

type FeaturesConfig struct {
	Flags map[string]bool `json:"flags"`
}

FeaturesConfig holds feature flag settings.

type FileBrowserPluginConfig added in v0.81.0

type FileBrowserPluginConfig struct {
	// Enabled controls whether the file browser plugin is loaded. Default: true.
	Enabled bool `json:"enabled"`
}

FileBrowserPluginConfig configures the file browser plugin.

type GitStatusPluginConfig

type GitStatusPluginConfig struct {
	Enabled         bool          `json:"enabled"`
	RefreshInterval time.Duration `json:"refreshInterval"`
}

GitStatusPluginConfig configures the git status plugin.

type KeymapConfig

type KeymapConfig struct {
	Overrides map[string]string `json:"overrides"`
}

KeymapConfig holds key binding overrides.

type NotesPluginConfig

type NotesPluginConfig struct {
	// DefaultEditor sets the default editor mode when pressing Enter on a note.
	// Values: "builtin" (default), "vim", "nvim", or any $EDITOR value.
	// When set to "vim"/"nvim", Enter opens the note in inline vim instead of built-in editor.
	DefaultEditor string `json:"defaultEditor,omitempty"`
}

NotesPluginConfig configures the notes plugin.

type PluginsConfig

type PluginsConfig struct {
	GitStatus     GitStatusPluginConfig     `json:"git-status"`
	TDMonitor     TDMonitorPluginConfig     `json:"td-monitor"`
	FileBrowser   FileBrowserPluginConfig   `json:"file-browser"`
	Conversations ConversationsPluginConfig `json:"conversations"`
	Workspace     WorkspacePluginConfig     `json:"workspace"`
	Notes         NotesPluginConfig         `json:"notes"`
	Tasks         TasksPluginConfig         `json:"tasks"`
}

PluginsConfig holds per-plugin configuration.

type ProjectConfig

type ProjectConfig struct {
	Name          string               `json:"name"`                    // display name for the project
	Path          string               `json:"path"`                    // absolute path to project root (supports ~ expansion)
	Theme         *ThemeConfig         `json:"theme,omitempty"`         // per-project theme (nil = use global)
	LastOpenInApp string               `json:"lastOpenInApp,omitempty"` // last app used to open this project (e.g. "vscode", "goland")
	OpenIn        string               `json:"openIn,omitempty"`        // preferred "open in" app for this project; last-used is the fallback
	WorktreeSetup *WorktreeSetupConfig `json:"worktreeSetup,omitempty"` // optional per-project setup policy
}

ProjectConfig represents a single project in the project switcher.

func AddProject added in v1.0.0

func AddProject(project ProjectConfig) (ProjectConfig, error)

AddProject appends a project to the configuration on disk and returns the saved entry. It reloads first, so a project added here never clobbers a change made to the file since Sidecar started.

type ProjectsConfig

type ProjectsConfig struct {
	Mode string          `json:"mode"` // "single" for now
	Root string          `json:"root"` // "." default
	List []ProjectConfig `json:"list"` // list of configured projects for switcher
}

ProjectsConfig configures project detection and layout.

type SidebarDisplayConfig added in v0.81.0

type SidebarDisplayConfig struct {
	// HideRepoPrefix strips the repo name prefix from worktree names (e.g., "myrepo-feature" → "feature").
	// Default: false (show full name).
	HideRepoPrefix bool `json:"hideRepoPrefix"`
	// HideAgent hides the agent type label (e.g., "claude") on the second line. Default: false.
	HideAgent bool `json:"hideAgent"`
	// HideTask hides the linked task ID (e.g., "td-abc123") on the second line. Default: false.
	HideTask bool `json:"hideTask"`
	// HideStats hides the +/- line change stats on the second line. Default: false.
	HideStats bool `json:"hideStats"`
}

SidebarDisplayConfig controls visibility of workspace sidebar entry elements.

type TDMonitorPluginConfig

type TDMonitorPluginConfig struct {
	Enabled         bool          `json:"enabled"`
	RefreshInterval time.Duration `json:"refreshInterval"`
	DBPath          string        `json:"dbPath"`
}

TDMonitorPluginConfig configures the TD monitor plugin.

type TasksPluginConfig added in v0.95.0

type TasksPluginConfig struct {
	// Position was the anchor the Tasks tab was inserted after while Tasks was
	// a project plugin. Tasks is now a tab of the global space (Agents,
	// Workspaces, Tasks), whose order is fixed, so the value is accepted,
	// validated, and preserved for older configs but no longer moves anything.
	// One of TasksPositionAfterWorkspaces (default) or TasksPositionAfterNotes;
	// unknown values are coerced back to the default by Validate.
	Position string `json:"position,omitempty"`
}

TasksPluginConfig configures the embedded Tasks plugin.

Whether the plugin loads at all is governed by the "tasks_plugin" feature flag (default off), not by a field here — that keeps enablement on the same lever as the other opt-in surfaces (see internal/features).

There is deliberately no store/JSONL path: the embedded Tasks package uses Tasks' own configuration resolution.

type ThemeConfig

type ThemeConfig struct {
	Name      string                 `json:"name"`
	Community string                 `json:"community,omitempty"` // community scheme name (resolved at runtime)
	Overrides map[string]interface{} `json:"overrides,omitempty"` // user customizations on top
}

ThemeConfig configures the color theme.

type UIConfig

type UIConfig struct {
	ShowClock        bool        `json:"showClock"`
	Theme            ThemeConfig `json:"theme"`
	NerdFontsEnabled bool        `json:"nerdFontsEnabled"`        // enables Nerd Font glyphs (pill tabs, icons, etc.)
	LastOpenInApp    string      `json:"lastOpenInApp,omitempty"` // global fallback for last app used to open projects
	// TerminalTitle templates the terminal window/tab title. Supported
	// variables: {project} {worktree} {plugin} {dir}. Empty disables retitling.
	TerminalTitle string `json:"terminalTitle"`
}

UIConfig configures UI appearance.

type WorkspacePluginConfig

type WorkspacePluginConfig struct {
	// DirPrefix prefixes workspace directory names with the repo name (e.g., 'myrepo-feature-auth')
	// This helps associate conversations with the repo after workspace deletion. Default: true.
	DirPrefix bool `json:"dirPrefix"`
	// DefaultAgentType sets the default agent family selected when creating a workspace.
	// Uses workspace.AgentType values (e.g. "claude", "codex", "opencode", "grok").
	DefaultAgentType string `json:"defaultAgentType,omitempty"`
	// Agents is an ordered allowlist of agent type IDs shown in Create Shell, Create Worktree,
	// and Start Agent pickers (e.g. ["claude","codex","grok"]). Empty/omitted shows all
	// built-in UI agents. Unknown IDs are ignored. "None (attach only)" is always offered
	// in pickers regardless of this list. Stored agent types on existing workspaces still
	// resolve even if hidden from pickers.
	Agents []string `json:"agents,omitempty"`
	// AgentStart maps agent family (AgentType string) to default startup command.
	// Example: {"claude":"claude", "opencode":"opencode --profile fast", "grok":"grok"}.
	// Per-workspace .sidecar-agent-start still takes precedence when present.
	AgentStart map[string]string `json:"agentStart,omitempty"`
	// TmuxCaptureMaxBytes caps tmux pane capture size for the preview pane. Default: 2MB.
	TmuxCaptureMaxBytes int `json:"tmuxCaptureMaxBytes"`
	// ResizeDebounceMs is the shared interval for live-pane SIGWINCH during
	// layout motion (divider drag, interactive correction). Default: 300.
	// 0 restores per-event paint and poll-driven resize. Negative values
	// become 300. Unlike TmuxCaptureMaxBytes, 0 is not treated as unset.
	ResizeDebounceMs int `json:"resizeDebounceMs"`
	// AutoCreateShell creates a shell session the first time the workspaces tab is
	// focused in a session, when no shell sessions exist yet. The shell honors
	// DefaultAgentType; with none set it is a plain shell. Default: false.
	AutoCreateShell bool `json:"autoCreateShell"`
	// InteractiveExitKey is the keybinding to exit interactive mode. Default: "ctrl+\".
	// Examples: "ctrl+]", "ctrl+\\", "ctrl+x"
	InteractiveExitKey string `json:"interactiveExitKey,omitempty"`
	// InteractiveAttachKey is the keybinding to attach from interactive mode. Default: "ctrl+]".
	// When pressed in interactive mode, exits interactive and attaches to the tmux session.
	InteractiveAttachKey string `json:"interactiveAttachKey,omitempty"`
	// InteractiveCopyKey is the keybinding to copy selection in interactive mode. Default: "alt+c".
	InteractiveCopyKey string `json:"interactiveCopyKey,omitempty"`
	// InteractivePasteKey is the keybinding to paste clipboard in interactive mode. Default: "alt+v".
	InteractivePasteKey string `json:"interactivePasteKey,omitempty"`
	// CopyOnSelect copies terminal selections when a drag completes. Default: false.
	CopyOnSelect bool `json:"copyOnSelect,omitempty"`
	// OverviewWorktreeScope controls whether activating a worktree on the cross-project
	// Overview enters the project root or scopes Sidecar to that worktree. Valid values
	// are "project" (the default) and "worktree".
	OverviewWorktreeScope string `json:"overviewWorktreeScope,omitempty"`
	// SidebarDisplay controls what information is shown in the workspace sidebar entries.
	SidebarDisplay SidebarDisplayConfig `json:"sidebarDisplay"`
	// WorktreeSetup controls repository artifacts Sidecar may copy or execute when
	// creating a worktree. The creation confirmation always names the discovered
	// files and hook and requires an explicit per-operation selection.
	WorktreeSetup WorktreeSetupConfig `json:"worktreeSetup"`
}

WorkspacePluginConfig configures the workspace plugin.

type WorktreeSetupConfig added in v0.94.0

type WorktreeSetupConfig struct {
	CopyEnvFiles bool     `json:"copyEnvFiles"`
	EnvFiles     []string `json:"envFiles,omitempty"`
	RunHook      bool     `json:"runHook"`
	HookPath     string   `json:"hookPath,omitempty"`
	HookRequired bool     `json:"hookRequired"`
}

WorktreeSetupConfig configures the optional setup phase after git creates a worktree. Paths are relative to the canonical main worktree.

Jump to

Keyboard shortcuts

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