Documentation
¶
Overview ¶
Package profiles discovers the user's coding-agent profiles and serves them to the UI.
A profile is a config directory one coding agent can run with. Each agent's default directory (~/.claude for Claude Code, ~/.codex for Codex) becomes that agent's "default" profile, which runs without the agent's config variable (CLAUDE_CONFIG_DIR, CODEX_HOME) so its own default login is used; every ~/.<dir>_<name> or ~/.<dir>-<name> directory that holds that agent's config becomes the agent's profile <name>, run with the variable set to that directory. Other tools name their own folders the same way (~/.codexbar, ~/.claude-<name>), so a directory counts only when it holds what the agent writes into a config directory (see agent.Agent.Markers).
Discovery runs on every start and never changes a stored profile: one the user edited keeps its settings, and one whose directory disappeared keeps its row. Prune removes only rows that hold nothing worth keeping: unedited profiles whose directory is still there but holds no agent config.
The Store owns the stored profiles; every other package reads them through it, or through a narrow interface it satisfies. The Service is what the window binds.
Index ¶
Constants ¶
const ( // DefaultName is the profile backed by an agent's default config directory. DefaultName = "default" // PermissionFull means the profile starts with full access (Claude's // --dangerously-skip-permissions, Codex's --dangerously-bypass-approvals-and-sandbox). PermissionFull = "full" )
Variables ¶
var ErrProfileNotFound = errors.New("profile not found")
ErrProfileNotFound is returned when the agent has no profile with the requested name.
Functions ¶
func SyncHome ¶ added in v0.3.0
SyncHome brings the stored agent profiles in line with home. It first removes unedited profiles whose directory holds no agent config (another tool's folder that happens to be named ~/.claude-<name>), then records every profile discovered under home. It never changes a stored profile, and keeps any that was edited or whose directory is gone. Pruning comes first so a name freed by a removed row can be taken by the directory that now owns it. A home directory that cannot be read only skips discovery, with a warning: the profiles already stored still work, and the inbox does not need them.
Types ¶
type AgentInfo ¶ added in v0.2.0
type AgentInfo struct {
agent.Agent
// Installed reports that the agent's program was found.
Installed bool `json:"installed"`
// Path is where the program was found, or "".
Path string `json:"path"`
}
AgentInfo is a coding agent as Settings and the launch menu show it: what it is, and whether this machine has its program. Every field is a plain value.
type Option ¶ added in v0.3.0
type Option func(*Service)
Option configures a Service.
func WithLogger ¶ added in v0.3.0
WithLogger has a Service log what Rediscover skips or removes. Without it nothing is logged.
type Profile ¶
type Profile struct {
// Agent is the coding agent the profile runs.
Agent agent.ID `json:"agent"`
// Name identifies the profile among the agent's profiles.
Name string `json:"name"`
// ConfigDir is the absolute config directory, or "" for the default profile.
ConfigDir string `json:"configDir"`
// Model is the model the profile runs ("" for the agent's default).
Model string `json:"model"`
// Effort is the effort level ("" for the agent's default).
Effort string `json:"effort"`
// PermissionMode is "full", one of the agent's permission modes, or "" for the
// agent's default.
PermissionMode string `json:"permissionMode"`
// PlanMode starts the session planning only: Claude's plan mode, Codex's read-only
// sandbox.
PlanMode bool `json:"planMode"`
// AddDirs are extra directories passed with --add-dir.
AddDirs []string `json:"addDirs"`
// ExtraArgs are extra arguments, one argv element each.
ExtraArgs []string `json:"extraArgs"`
// Env holds extra environment variables for the session.
Env map[string]string `json:"env"`
// Folder is the profile's config directory as shown to people, with ~ for the home
// directory: "~/.claude" for Claude's default profile. Only List sets it.
Folder string `json:"folder"`
// Missing reports that the config directory no longer exists. Only List sets it.
Missing bool `json:"missing"`
// SignedIn reports that the agent can sign in with the profile: its sign-in file is in
// the config directory, or its env sets a key the agent signs in with. It is always
// true for an agent whose sign-in the app does not check. Only List sets it.
SignedIn bool `json:"signedIn"`
}
Profile is one launch profile as the UI shows it. Every field is a plain value.
func Discover ¶
Discover lists the profile directories of every agent directly under home. Each agent's default directory (~/.claude, ~/.codex) is its default profile; each ~/.<dir>_<name> or ~/.<dir>-<name> directory that holds the agent's config is its profile <name>. Files, names that do not match the name pattern, and directories with no agent config (another tool's folder, or one the agent has never run with) are ignored. When two of an agent's directories map to the same name, the default directory beats ~/.<dir>_<name>, which beats ~/.<dir>-<name>; the loser is skipped with a warning logged to log (nil discards it). Discovered profiles start with full access, no model or effort flag, and plan mode off.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service serves the stored profiles and the agents they run.
func NewService ¶
NewService returns a Service over the profiles in store. home is where each agent's default profile directory lives, and is shown as ~ in each profile's Folder. finder finds each agent's program for Agents; nil reports every agent as not installed.
func (*Service) Agents ¶ added in v0.2.0
Agents returns every coding agent, the default first, with whether its program is installed. An agent that keeps a cache of the models it offers (Codex's models_cache.json) has its Models read from there, from its default profile's directory or else the first of its other profiles' that has one; reading it asks no server.
func (*Service) List ¶
List returns every stored profile, grouped by agent in the agents' order, each agent's default first and the rest by name, each with its Folder, whether that folder is missing, and whether it is signed in.
func (*Service) Rediscover ¶ added in v0.3.0
Rediscover looks for the agents' profiles in the home directory again, as every start does (SyncHome), so a profile directory made, or an agent installed and run, since the app started shows without a restart, and returns every stored profile as List does. It never changes a stored profile, and keeps one whose directory is gone.
type Store ¶ added in v0.2.0
type Store struct {
// contains filtered or unexported fields
}
Store reads and writes the stored profiles of every agent: the agent_profiles table, which no other package touches.
func NewStore ¶ added in v0.2.0
NewStore returns a Store over the pool db. Sync stamps the rows it adds from c; a nil c is the system clock.
func (*Store) All ¶ added in v0.2.0
All returns every stored profile, grouped by agent in the agents' order, each agent's default first and the rest by name. Folder, Missing, and SignedIn are left unset; the Service's List fills them in.
func (*Store) Lookup ¶ added in v0.2.0
Lookup returns the agent's stored profile named name, or ErrProfileNotFound.
func (*Store) Prune ¶ added in v0.2.0
Prune removes the stored profiles that hold nothing worth keeping: named profiles whose directory is still there but holds no agent config, and whose settings are still the ones discovery gave them, so nobody edited them. Removing such a row loses nothing, and discovery adds it back if the directory later becomes an agent config. The default profile, edited profiles, and profiles whose directory is gone or cannot be read are kept, as is every profile of an agent this build does not know; an edited one is logged to log (nil discards it) as a warning. It returns the names it removed, as "<agent>/<name>", sorted.