Documentation
¶
Overview ¶
Package clientcfg persists client-side settings (things the CLI/TUI need that the daemon doesn't), stored at ~/.dejima/client.json. It is intentionally separate from per-island project configs and from daemon state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddProfile ¶ added in v0.6.0
AddProfile saves a new connection target and persists it. It is the store half of the TUI add-flow, factored out so the CLI (`dejima profile add`) and the TUI share one code path. A duplicate name is rejected so two profiles can't shadow each other in lookups.
func Path ¶ added in v0.8.34
Path returns the client config file location (~/.dejima/client.json) without creating it — for a client uninstall that removes it.
func RemoveProfile ¶ added in v0.6.9
RemoveProfile deletes a saved profile by name and persists. If it was the active profile, ActiveProfile is cleared (back to the local socket) so no dangling reference is left. It's the store half of both the TUI delete and the CLI `dejima profile rm`, so the two share one code path. "local" can't be removed (it's the synthetic socket target), and an unknown name errors loudly rather than silently no-op'ing.
func RenameProfile ¶ added in v0.8.50
RenameProfile changes a saved profile's display name, keeping its host/token intact, and follows the rename into ActiveProfile so the active selection isn't orphaned. "local" is the synthetic socket target and can't be renamed; an unknown old name, an empty/"local" new name, or a collision with another profile errors rather than corrupting the store.
func SaveInvite ¶ added in v0.8.0
SaveInvite persists a decoded team invite as a connection profile and makes it active, so the teammate is connected on the next command with no env vars. The profile name defaults to the invite's Name, else the host's first DNS label; a name clash updates that profile in place (re-joining rotates the saved token rather than erroring). Returns the resolved profile name. The bearer secret lands in client.json, which Save writes 0600.
func SwitchProfile ¶ added in v0.6.0
SwitchProfile persists name as the active profile — the same write the TUI switcher makes. Unlike LookupProfile (ephemeral), this *does* mutate active_profile in client.json, which is the whole point of `switch` vs `-p`. The synthetic "local" clears the active profile (back to the Unix socket). An unknown name is rejected so `switch` can't leave a dangling reference.
Types ¶
type Config ¶
type Config struct {
// RepoRoot is the directory the TUI repo picker scans for git repos.
// Empty means the user hasn't chosen one yet (first-load prompt pending).
RepoRoot string `json:"repo_root,omitempty"`
// Profiles are saved connection targets (local + remote daemons), switchable
// from the TUI. ActiveProfile records the last one selected.
Profiles []Profile `json:"profiles,omitempty"`
ActiveProfile string `json:"active_profile,omitempty"`
// Editor is the CLI command for the user's preferred Remote-SSH editor
// (e.g. "code", "cursor", "windsurf", "antigravity"). Empty means auto-detect
// the first one on PATH. Set from the TUI settings (',').
Editor string `json:"editor,omitempty"`
}
Config holds client-side preferences.
func (Config) ActiveHost ¶
ActiveHost resolves the currently-active profile to its daemon host. ok is false when the active profile is the local socket, unset, or *dangling* — i.e. ActiveProfile names a profile that no longer exists (e.g. it was deleted while still selected). A dangling reference resolves to local rather than wedging the client on a target it can't look up.
func (Config) LookupProfile ¶ added in v0.6.0
LookupProfile resolves a profile by name to its daemon host, reading nothing but the in-memory config. The synthetic "local" name (and "") resolve to the empty host (the local Unix socket). This is the *ephemeral* lookup behind the `-p/--profile` launch flag: it never touches ActiveProfile, so selecting a profile for one invocation can't stomp the persistent choice shared by concurrent TUIs. An unknown name is an error (vs ActiveHost's silent fall-back), because an explicit `-p typo` should fail loudly, not connect somewhere unexpected.
func (Config) TokenForHost ¶ added in v0.8.0
TokenForHost returns the bearer token saved for a connection host, preferring the active profile when it matches (so two profiles on the same host don't race). It is the no-env-token default behind the connection path: an explicit DEJIMA_TOKEN still wins upstream. Empty when no saved profile carries a token for that host (e.g. the local socket, or a host added without one).
type Profile ¶
type Profile struct {
Name string `json:"name"`
Host string `json:"host,omitempty"`
Token string `json:"token,omitempty"`
Role string `json:"role,omitempty"`
Islands []string `json:"islands,omitempty"`
}
Profile is a saved connection target. Host is "" for the local Unix socket, or "host:port" for a remote daemon reached over TCP. Token is the bearer secret for that target — a team invite persists it here so the teammate doesn't re-export DEJIMA_TOKEN every session; Role/Islands are the invite's echo, kept for display only (the daemon enforces the real scope). The file is written 0600 (see Save), matching the per-island token files' posture.