Documentation
¶
Overview ¶
Package config holds hopsesh's user configuration and state locations.
Index ¶
- Constants
- Variables
- func CheckAppearance(mode string) error
- func DefaultDir() string
- func DefaultStateDir() string
- func Dir() string
- func Path() string
- func SameDir(a, b string) bool
- func Save(c Config) error
- func SetAside() (string, error)
- func StateDir() string
- type Agent
- type Cloud
- type Config
- func (c Config) AgentEnabled(id string) bool
- func (c Config) AppIconsOn() bool
- func (c Config) AppResume() string
- func (c Config) AppearanceMode() string
- func (c Config) Check() error
- func (c Config) Clone() Config
- func (c Config) CloseEndedOn() bool
- func (c Config) CloudAllowed(name string) bool
- func (c Config) CloudSettings(name string) Cloud
- func (c *Config) FindHost(name string) *Host
- func (c Config) KeepTabsOn() bool
- func (c Config) MovementNoticesOn() bool
- func (c Config) NotifyOn() bool
- func (c Config) OriginalGuard() string
- func (c Config) PreviewsOn() bool
- func (c Config) ResumeIn() string
- func (c *Config) SetCloudAllowed(name string, allowed bool)
- func (c *Config) SetCloudEnvironment(name, repo, env string)
- func (c Config) SyncCodeOn() bool
- func (c Config) TerminalFont() int
- func (c Config) TerminalLines() int
- func (c *Config) UpsertHost(h Host)
- type Desktop
- type History
- type Host
- type Inspector
- type List
- type ListFilter
- type Peer
- type Terminal
- type Window
Constants ¶
const ( CloudCodeBranch = "branch" CloudCodeBundle = "bundle" DefaultBranchPrefix = "hopsesh/handoff/" DeleteNever = "never" DeleteAfterMerge = "after-merge" DeleteOnUndo = "on-undo" )
Defaults of a cloud's settings.
const (
SidebarWidth, SidebarMin, SidebarMax = 220, 180, 320
InspectorMin, InspectorMax = 300, 960
)
The app window's pane widths: defaults and limits. The inspector's default width is the window's to work out (a share of its width); InspectorMax is the most it may be.
const ( PlaceHere = ResumeHere PlaceTerminal = ResumeTerminal PlaceApp = "app" )
Places a session resumes in, in the app (Agent.Place).
const ( TerminalFontSize = 13 TerminalScrollback = 5000 )
Terminal font sizes and scrollback lengths.
const ( TerminalITerm2 = "iterm2" TerminalApp = "terminal-app" TerminalWindowsTerminal = "windows-terminal" TerminalLinux = "linux" ResumeHere = "here" ResumeTerminal = "terminal" ResumeAsk = "ask" )
Terminal apps and resume choices.
const ( OriginalBlock = "block" OriginalAdvise = "advise" OriginalOff = "off" )
Protection choices for the copy left behind (config "original").
const AppResumeDefault = ResumeHere
AppResumeDefault is where the desktop app resumes sessions and runs hand-off and bring-back steps until the user chooses: in its own Terminal window. It is the release gate of the app's terminal: a release whose nightly terminal checks are not green on macOS and Windows ships ResumeTerminal here instead (only this constant changes).
const ListKeysMax = 300
ListKeysMax is how many collapsed and expanded groups the list remembers (the oldest choices go first).
const Schema = 4
Schema is the configuration format. Files in another format are refused, never read: hopsesh keeps no code for older formats.
Variables ¶
var ( ErrOldConfig = errors.New("the configuration was written by an older hopsesh") ErrNewConfig = errors.New("the configuration was written by a newer hopsesh") )
ErrOldConfig means the configuration file was written by an older hopsesh; ErrNewConfig, by a newer one (after a downgrade), which this one must not set aside as if it were old.
var ( ListGroups = []string{"family", "repository", "location", "agent", "account", "tag", "status", "last-active", "none"} ListSorts = []string{"last-active", "title", "status", "size"} ListDensities = []string{"comfortable", "compact"} ListStatuses = []string{"needs", "working", "idle", "moved", "ended", "unknown"} ListLocations = []string{"here", "machines", "clouds"} ListLastActive = []string{"today", "7d", "30d"} ListHas = []string{"tab", "mirror", "unpushed"} )
The list's choices.
var ( HistoryContextBudgets = []int{0, 16_000, 32_000, 64_000, 128_000, 256_000} HistoryReadMemoryMBs = []int{256, 512, 1024, 2048, 4096} HistoryRecordMBs = []int{32, 64, 128, 256} HistoryLineageMBs = []int{16, 32, 64, 128, 256, 512} HistoryArchiveMBs = []int{256, 512, 1024, 2048, 4096, 8192} HistoryNativeFileMBs = []int{1024, 2048, 4096, 8192} )
History choices offered by the app (any value within the ceilings is valid in the file).
var InspectorSections = []string{"conversation", "repository", "copies", "details"}
InspectorSections are the inspector's sections that open and close.
var TerminalScrollbacks = []int{1000, 5000, 10000, 50000}
TerminalScrollbacks are the scrollback lengths the app offers.
Functions ¶
func CheckAppearance ¶ added in v0.4.0
func DefaultDir ¶ added in v0.4.4
func DefaultDir() string
DefaultDir is the configuration directory when HOPSESH_CONFIG_DIR is not set.
func DefaultStateDir ¶ added in v0.4.4
func DefaultStateDir() string
DefaultStateDir is the state directory when HOPSESH_STATE_DIR is not set.
func Dir ¶
func Dir() string
Dir is the configuration directory: $XDG_CONFIG_HOME/hopsesh or ~/.config/hopsesh on macOS and Linux, %APPDATA%\hopsesh on Windows.
func SameDir ¶ added in v0.4.4
SameDir reports whether two folder paths name the same folder (cleaned, links resolved when they exist).
Types ¶
type Agent ¶ added in v0.3.0
type Agent struct {
// Disabled leaves the agent out of scans and moves.
Disabled bool `toml:"disabled,omitempty"`
// RemoteControl turns the agent's own remote control on for continued sessions.
RemoteControl bool `toml:"remote_control,omitempty"`
// Import has the agent's own importer convert sessions continued in it, by default.
Import bool `toml:"import,omitempty"`
// Place is where the app resumes the agent's sessions, as the user last chose from a
// session's Resume menu: "here" (the hopsesh Terminal window), "terminal" (the
// terminal app) or "app" (the agent's desktop app). "" follows [terminal] resume.
Place string `toml:"place,omitempty"`
}
Agent is per-agent configuration, by module id.
type Cloud ¶ added in v0.4.0
type Cloud struct {
// Allowed: the user consented to hopsesh running the agent's cloud commands.
Allowed bool `toml:"allowed"`
// Code is how code goes up: "branch" (a pushed handoff branch, the default) or "bundle"
// (the agent uploads the repository itself, where it can).
Code string `toml:"code,omitempty"`
// HistoryFile commits the conversation as .hopsesh/handoff.md on the handoff branch
// (off by default: it puts conversation text on the repository's host).
HistoryFile bool `toml:"history_file,omitempty"`
// Untracked are untracked files (globs) carried up by default; credential-like files
// are never carried, whatever this says.
Untracked []string `toml:"untracked,omitempty"`
// BranchPrefix starts the handoff branches' names (default "hopsesh/handoff/").
BranchPrefix string `toml:"branch_prefix,omitempty"`
// DeleteBranch is when a handoff branch is deleted: "never", "after-merge" (the
// default) or "on-undo".
DeleteBranch string `toml:"delete_branch,omitempty"`
// RenameVendorBranches brings a cloud's own branches (claude/…) home under
// hopsesh/from/<cloud>/… (default on).
RenameVendorBranches *bool `toml:"rename_vendor_branches,omitempty"`
// Environments are the vendor's environment ids by repository identity
// ("github.com/acme/api" = "env_…"), for clouds that need one.
Environments map[string]string `toml:"environments,omitempty"`
}
Cloud is per-cloud configuration, by the cloud's name ("codex-cloud"). Like a machine, a cloud is left alone until the user allows it.
type Config ¶
type Config struct {
FamilyNames map[string]string `toml:"family_names,omitempty"`
// Appearance is system (also the empty default), light or dark for app windows.
Appearance string `toml:"appearance,omitempty"`
Desktop Desktop `toml:"desktop,omitempty"`
Schema int `toml:"schema"`
ReposDir string `toml:"repos_dir"` // where clones go; default ~/git
Layout string `toml:"layout"` // flat | ghq
// UpdateCheck is "on" or "off" once the person has answered whether the app may
// look for new releases once a day ("" = not asked yet).
UpdateCheck string `toml:"update_check,omitempty"`
// Original is how the copy left behind by a move is protected until the session moves
// back: "block" (the default, ""), "advise" or "off". SyncCode defaults to on (nil),
// PushSource to off.
Original string `toml:"original,omitempty"`
SyncCode *bool `toml:"sync_code,omitempty"` // fetch and fast-forward the checkout here
PushSource bool `toml:"push_source,omitempty"` // push unpushed commits on the source first
// SkillPrompt remembers the answer to "let your agents use hopsesh?": "" (not asked),
// "declined", or the skill revision last offered.
SkillPrompt string `toml:"skill_prompt,omitempty"`
// CLIPrompt is "declined" once the user said not now to linking the command-line tool
// from the app.
CLIPrompt string `toml:"cli_prompt,omitempty"`
// SetupPrompt is "declined" once the user closed the app's "Finish setting up" line.
SetupPrompt string `toml:"setup_prompt,omitempty"`
// AppIcons shows an agent's installed desktop app icon in the app (default on).
AppIcons *bool `toml:"app_icons,omitempty"`
Agents map[string]Agent `toml:"agents,omitempty"`
// Clouds are the vendor clouds the user allowed or set up, by name.
Clouds map[string]Cloud `toml:"clouds,omitempty"`
Peer Peer `toml:"peer"`
// Terminal is the terminal app hopsesh opens launches in.
Terminal Terminal `toml:"terminal,omitempty"`
// Window is the app window's layout, and Inspector its inspector's sections.
Window Window `toml:"window,omitempty"`
Inspector Inspector `toml:"inspector,omitempty"`
// List is how the app's session list shows sessions.
List List `toml:"list,omitempty"`
// Previews shows the end of a session's conversation in the app's inspector (default
// on; off for people who share their screen).
Previews *bool `toml:"previews,omitempty"`
// History is how much history a transfer carries and the resources it may use.
History History `toml:"history,omitempty"`
Hosts []Host `toml:"hosts"`
}
Config is the user's configuration file.
func Load ¶
Load reads the configuration, filling defaults for missing values. A file in another format is refused with ErrOldConfig (an older one, or one that is not hopsesh's) or ErrNewConfig (a newer one).
func (Config) AgentEnabled ¶ added in v0.3.0
AgentEnabled reports whether an agent module is in use.
func (Config) AppIconsOn ¶ added in v0.3.0
AppIconsOn reports whether installed desktop apps' icons picture the agents (default on).
func (Config) AppResume ¶ added in v0.4.0
AppResume is where the desktop app resumes sessions and runs steps (default AppResumeDefault).
func (Config) AppearanceMode ¶ added in v0.4.0
AppearanceMode fills in the default without pinning System to today's OS color.
func (Config) Clone ¶ added in v0.4.1
Clone gives a background operation its own settings. Config contains only JSON-compatible data. Decode into an empty value: decoding into a shallow copy reuses its maps, slices and pointers, racing with other readers of those values. Callers must hold their configuration lock while capturing the copy.
func (Config) CloseEndedOn ¶ added in v0.4.0
CloseEndedOn reports whether a tab closes once its program ended well.
func (Config) CloudAllowed ¶ added in v0.4.0
CloudAllowed reports whether the user allowed a cloud.
func (Config) CloudSettings ¶ added in v0.4.0
CloudSettings returns a cloud's settings with the defaults filled in.
func (Config) KeepTabsOn ¶ added in v0.4.0
KeepTabsOn reports whether closing the app's window keeps its tabs' programs running.
func (Config) MovementNoticesOn ¶ added in v0.4.0
MovementNoticesOn reports whether moves record a notice for the copy left behind (the block or the advice needs one); independent of lineage, which is always kept.
func (Config) NotifyOn ¶ added in v0.4.0
NotifyOn reports whether a waiting tab may raise a desktop notification.
func (Config) OriginalGuard ¶ added in v0.4.2
OriginalGuard is how the copy left behind is protected: block (default), advise or off.
func (Config) PreviewsOn ¶ added in v0.4.0
PreviewsOn reports whether the app shows conversation previews (default on).
func (*Config) SetCloudAllowed ¶ added in v0.4.0
SetCloudAllowed records consent for a cloud, keeping its other settings.
func (*Config) SetCloudEnvironment ¶ added in v0.4.0
SetCloudEnvironment records the cloud environment a repository's hand-offs run in ("" forgets it), keeping the cloud's other settings.
func (Config) SyncCodeOn ¶ added in v0.2.0
SyncCodeOn reports whether the checkout is brought to the session's commit (default on).
func (Config) TerminalFont ¶ added in v0.4.0
TerminalFont is the app's terminal font size in points.
func (Config) TerminalLines ¶ added in v0.4.0
TerminalLines is how many lines a tab keeps.
func (*Config) UpsertHost ¶
UpsertHost adds or updates a host by name, keeping consent unless explicitly changed.
type Desktop ¶ added in v0.4.0
type Desktop struct {
Mode string `toml:"mode,omitempty" json:"mode"` // app | tray | both
Close string `toml:"close,omitempty" json:"close"` // keep | quit; empty keeps running in the background
Attention *bool `toml:"attention,omitempty" json:"attention"`
Previews *bool `toml:"previews,omitempty" json:"previews"`
}
Desktop controls application presence, independently of terminal preferences. Empty Mode preserves the behavior of an existing installation.
func (Desktop) AttentionOn ¶ added in v0.4.0
func (Desktop) KeepInBackground ¶ added in v0.4.0
func (Desktop) PreviewsOn ¶ added in v0.4.0
type History ¶ added in v0.4.2
type History struct {
// ContextBudget optionally lowers the receiving context (0: automatic, from the
// destination model). It can never raise what the model allows.
ContextBudget int `toml:"context_budget,omitempty" json:"contextBudget"`
// Older is how history older than the recent turns is carried: "extract" (default)
// or "recent" (recent turns only).
Older string `toml:"older,omitempty" json:"older"`
// Advanced resource budgets, in MiB.
ReadMemoryMB int `toml:"read_memory_mb,omitempty" json:"readMemoryMB"`
RecordMB int `toml:"record_mb,omitempty" json:"recordMB"`
ArchiveMB int `toml:"archive_mb,omitempty" json:"archiveMB"`
LineageMB int `toml:"lineage_mb,omitempty" json:"lineageMB"`
NativeFileMB int `toml:"native_file_mb,omitempty" json:"nativeFileMB"`
}
History limits. Zero means automatic or the default; see ir.Limits. Canonical history is never truncated: reaching a resource limit stops the transfer with the setting named, and only the receiving context keeps a labeled subset (the rest stays in the portable archive).
type Host ¶
type Host struct {
Name string `toml:"name"` // label shown to the user, e.g. "studio"
Destination string `toml:"destination"` // what to pass to ssh: alias, user@host or host
Via string `toml:"via"` // tailscale | ssh-config | manual (or a "+" combination)
Allowed bool `toml:"allowed"` // the user consented to hopsesh connecting
OS string `toml:"os,omitempty"`
// TailscaleName is the machine's MagicDNS name, used when Destination's own host
// name does not resolve (e.g. an alias pointing at a .local name on another network).
TailscaleName string `toml:"tailscale_name,omitempty"`
// Auth is "password" for a machine that logs in with a password (asked for, never
// stored in this file); "" means keys or the SSH agent.
Auth string `toml:"auth,omitempty"`
// Keychain: remember this machine's password in the macOS Keychain.
Keychain bool `toml:"keychain,omitempty"`
}
Host is one machine hopsesh knows about.
func (Host) UsesPassword ¶ added in v0.2.0
UsesPassword reports whether the machine logs in with a password.
type Inspector ¶ added in v0.4.0
type Inspector struct {
Open []string `toml:"open,omitempty"` // InspectorSections
Closed []string `toml:"closed,omitempty"` // InspectorSections
}
Inspector is the app inspector's sections the user opened or closed (explicit choices only: the others keep their defaults), app-wide rather than per session.
type List ¶ added in v0.4.0
type List struct {
TerminalCollapsed []string `toml:"terminal_collapsed,omitempty"`
GroupBy string `toml:"group_by,omitempty"` // ListGroups ("": repository)
SortBy string `toml:"sort_by,omitempty"` // ListSorts ("": last-active)
SortReverse bool `toml:"sort_reverse,omitempty"` // oldest, Z–A or smallest first
Density string `toml:"density,omitempty"` // comfortable | compact
// CollapseInactive starts groups whose newest session is more than 14 days old
// collapsed, unless the user expanded them.
CollapseInactive bool `toml:"collapse_inactive,omitempty"`
Collapsed []string `toml:"collapsed,omitempty"`
Expanded []string `toml:"expanded,omitempty"`
Filter ListFilter `toml:"filter,omitempty"`
}
List is how the app's session list shows sessions: grouped by one property, sorted within the groups, comfortable or compact rows, the groups the user collapsed or expanded (by "grouping:name", explicit choices only), and the filters. An empty List means the app has not chosen yet (it picks once, by how many sessions the first scan finds).
type ListFilter ¶ added in v0.4.0
type ListFilter struct {
Account []string `toml:"account,omitempty"`
AccountNot bool `toml:"account_not,omitempty"`
Tag []string `toml:"tag,omitempty"`
TagNot bool `toml:"tag_not,omitempty"`
Status []string `toml:"status,omitempty"` // ListStatuses
StatusNot bool `toml:"status_not,omitempty"`
Location []string `toml:"location,omitempty"` // here | machines | clouds
LocationNot bool `toml:"location_not,omitempty"`
Agent []string `toml:"agent,omitempty"` // agent ids
AgentNot bool `toml:"agent_not,omitempty"`
Repository []string `toml:"repository,omitempty"` // repository identities or names
RepositoryNot bool `toml:"repository_not,omitempty"`
LastActive string `toml:"last_active,omitempty"` // today | 7d | 30d
Has []string `toml:"has,omitempty"` // tab | mirror | unpushed
HasNot bool `toml:"has_not,omitempty"`
}
ListFilter is the list's saved filters: within a facet the values combine with OR (or, with its _not set, none of them), and facets combine with AND. Empty: no filter.
type Peer ¶ added in v0.3.0
type Peer struct {
// Receive lets hopsesh on another machine send sessions here (off by default).
Receive bool `toml:"receive,omitempty"`
}
Peer is how this machine works with hopsesh on other machines.
type Terminal ¶ added in v0.4.0
type Terminal struct {
Placement string `toml:"placement,omitempty"` // separate (default), bottom, right
Grouping string `toml:"grouping,omitempty"` // family (default), session, none
// App is the terminal app launches open in: "iterm2", "terminal-app" (macOS),
// "windows-terminal", "linux"; "" picks the best installed one (iTerm2 before
// Terminal on macOS).
App string `toml:"app,omitempty"`
// Resume is where sessions resume and the app's hand-off and bring-back steps run:
// "here" (the app's own Terminal window; the command line: this terminal), "terminal"
// (in App), "ask" (each time). "" is AppResumeDefault in the app and "terminal" on the
// command line.
Resume string `toml:"resume,omitempty"`
// Font is its font family ("": the system's monospace font).
Font string `toml:"font,omitempty"`
// FontSize is its font size in points, 9 to 24 (0: 13).
FontSize int `toml:"font_size,omitempty"`
// Scrollback is how many lines each tab keeps, in memory only: 1000, 5000, 10000 or
// 50000 (0: 5000).
Scrollback int `toml:"scrollback,omitempty"`
// KeepTabs: closing the app's window hides it while programs run in tabs (nil: on).
KeepTabs *bool `toml:"keep_tabs,omitempty"`
// Notify: a desktop notification when a tab the user cannot see waits for them (nil:
// on).
Notify *bool `toml:"notify,omitempty"`
// KeepEnded keeps a tab open after its program ended well (exit code 0; a hand-off's
// step once its link is known). nil or false: such a tab closes (a failed one stays,
// so its output can be read).
KeepEnded *bool `toml:"keep_ended,omitempty"`
// ScreenReader is the terminal's screen reader mode: "" (on while the system's screen
// reader runs), "on" or "off".
ScreenReader string `toml:"screen_reader,omitempty"`
// SystemConsole (Windows): tabs use the system's pseudoconsole instead of the newer one
// the app carries.
SystemConsole bool `toml:"system_console,omitempty"`
}
Terminal is how hopsesh opens sessions and steps in a terminal app.
type Window ¶ added in v0.4.0
type Window struct {
SidebarWidth int `toml:"sidebar_width,omitempty"`
SidebarHidden bool `toml:"sidebar_hidden,omitempty"`
InspectorWidth int `toml:"inspector_width,omitempty"`
InspectorHidden bool `toml:"inspector_hidden,omitempty"`
}
Window is the app window's layout on the Sessions screen: the sidebar's and the inspector's widths in CSS pixels (0: the default; the inspector's default follows the window's width) and whether the user hid them. A pane the window hides because it is narrow is not saved.