config

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 8 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 holds hopsesh's user configuration and state locations.

Index

Constants

View Source
const Schema = 3

Schema is the configuration format. Files in another format are refused, never read: hopsesh keeps no code for older formats.

Variables

View Source
var ErrOldConfig = errors.New("the configuration was written by an older hopsesh")

ErrOldConfig means the configuration file was written by an older hopsesh.

Functions

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 Path

func Path() string

Path is the configuration file.

func Save

func Save(c Config) error

Save writes the configuration atomically with user-only permissions.

func SetAside added in v0.3.0

func SetAside() (string, error)

SetAside renames an older configuration file out of the way (to config.toml.old-<time>) so hopsesh can start fresh; it returns the new name.

func StateDir

func StateDir() string

StateDir holds journals, lineage caches, the audit log, staging and hopsesh's own known_hosts: $XDG_STATE_HOME/hopsesh or ~/.local/state/hopsesh; %LOCALAPPDATA%\hopsesh on Windows.

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"`
}

Agent is per-agent configuration, by module id.

type Config

type Config struct {
	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"`
	// Round trips. MarkMoved and SyncCode default to on (nil); PushSource to off.
	MarkMoved  *bool `toml:"mark_moved,omitempty"`  // mark the copy left behind
	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"`
	// 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"`
	Peer     Peer             `toml:"peer"`
	Hosts    []Host           `toml:"hosts"`
}

Config is the user's configuration file.

func Defaults

func Defaults() Config

Defaults returns the configuration used when no file exists.

func Load

func Load() (Config, error)

Load reads the configuration, filling defaults for missing values. A file in another format is refused with ErrOldConfig.

func (Config) AgentEnabled added in v0.3.0

func (c Config) AgentEnabled(id string) bool

AgentEnabled reports whether an agent module is in use.

func (Config) AppIconsOn added in v0.3.0

func (c Config) AppIconsOn() bool

AppIconsOn reports whether installed desktop apps' icons picture the agents (default on).

func (*Config) FindHost

func (c *Config) FindHost(name string) *Host

FindHost returns the configured host with this name.

func (Config) MarkMovedOn added in v0.2.0

func (c Config) MarkMovedOn() bool

MarkMovedOn reports whether copies left behind are marked (default on).

func (Config) SyncCodeOn added in v0.2.0

func (c Config) SyncCodeOn() bool

SyncCodeOn reports whether the checkout is brought to the session's commit (default on).

func (*Config) UpsertHost

func (c *Config) UpsertHost(h Host)

UpsertHost adds or updates a host by name, keeping consent unless explicitly changed.

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

func (h Host) UsesPassword() bool

UsesPassword reports whether the machine logs in with a password.

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.

Jump to

Keyboard shortcuts

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