integrate

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 15 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 integrate connects hopsesh to the rest of the user's machine: the command-line tool on PATH (for app installs), the user's login environment, and the hopsesh skill for every agent. All are opt-in and reversible, and none ever replaces something hopsesh did not create.

Index

Constants

View Source
const (
	CLIMissing    = "missing"    // nothing there
	CLIOurs       = "ours"       // a link to this app's tool
	CLIOtherApp   = "other-app"  // a link into another copy of hopsesh.app
	CLIDangling   = "dangling"   // a link whose target is gone (the app moved or was deleted)
	CLIStandalone = "standalone" // a regular file (install script, go install)
	CLIForeign    = "foreign"    // a link somewhere else (e.g. Homebrew)
)

States of the hopsesh command: on macOS and Linux a link at ~/.local/bin/hopsesh; on Windows the app's folder (with hopsesh.exe beside the app) on the user's PATH.

View Source
const (
	Absent   = "absent"
	Current  = "current"
	Stale    = "stale"
	Modified = "modified"
	Foreign  = "foreign"
	Broken   = "broken"
)

States of a skill copy.

View Source
const SkillName = "hopsesh"

SkillName is the skill's name and folder.

Variables

View Source
var ErrForeign = errors.New("a skill called hopsesh already exists and was not installed by hopsesh")

ErrForeign means a skill called hopsesh exists that hopsesh did not install.

View Source
var ErrModified = errors.New("the hopsesh skill was edited after hopsesh installed it")

ErrModified means a copy of the skill was edited by the user.

Functions

func AddToPath

func AddToPath() (string, error)

AddToPath appends a marked block that puts ~/.local/bin on PATH to the login-shell profile (only when the user asks). It returns the file it changed.

func AdoptLoginEnv

func AdoptLoginEnv()

AdoptLoginEnv sets each SetLoginVars variable in this process from the login shell when the process does not have it (an app started from Finder), so every part of hopsesh, and the agents it starts, use the folders the user's shell would.

func AppCLI

func AppCLI() (string, error)

AppCLI is the command-line tool inside the running app bundle, or an error explaining why it cannot be linked (not an app, running from a disk image or a translocated copy).

func LinkPath

func LinkPath() string

LinkPath is where the command-line tool is linked.

func LoginEnv

func LoginEnv() map[string]string

LoginEnv returns PATH and the SetLoginVars variables as an interactive login shell sets them (cached; empty values when it cannot be read).

func LoginPathHas

func LoginPathHas(dir string) bool

LoginPathHas reports whether dir is on the PATH a new terminal gets.

func LookLoginPath

func LookLoginPath(name string) string

LookLoginPath finds a command on the PATH a new terminal gets.

func MergeShared

func MergeShared(path string, merge func([]byte) ([]byte, error)) error

MergeShared rewrites a shared settings file through merge, keeping a backup of what it replaced (path.hopsesh-backup).

func RemovePathBlock

func RemovePathBlock() error

RemovePathBlock removes the block AddToPath added, if present.

func RemoveSkill

func RemoveSkill(dir string, files map[string][]byte, force bool) error

RemoveSkill deletes a copy hopsesh owns unchanged, or any copy with force.

func SetLoginVars

func SetLoginVars(vars []string)

SetLoginVars names the variables (besides PATH) LoginEnv reads; call once at start-up, before the first LoginEnv.

func SkillBin

func SkillBin() string

SkillBin is how agents should run hopsesh: plain "hopsesh" when the user's login shell finds it, otherwise an absolute path (the linked tool, the app's tool, or this program).

func UninstallCLI

func UninstallCLI() error

UninstallCLI removes the link when it points into a hopsesh.app (or is broken), and the PATH block hopsesh added, if any.

func WriteOwned

func WriteOwned(path string, b []byte) error

WriteOwned writes a file hopsesh owns outright (an agent's rules file).

Types

type CLIStatus

type CLIStatus struct {
	State      string `json:"state"`
	Path       string `json:"path"`             // ~/.local/bin/hopsesh; Windows: the app's hopsesh.exe
	Target     string `json:"target,omitempty"` // where the link points
	AppCLI     string `json:"appCli,omitempty"` // the tool inside this app
	DirOnPath  bool   `json:"dirOnPath"`        // ~/.local/bin (Windows: the app's folder) is on the login PATH
	Resolves   string `json:"resolves,omitempty"`
	Profile    string `json:"profile,omitempty"`   // file "Add to PATH" would change
	PathLine   string `json:"pathLine"`            // the line to add to Profile; Windows: the folder
	PathAdded  bool   `json:"pathAdded,omitempty"` // hopsesh's block is in the profile
	CanInstall string `json:"cannotInstall,omitempty"`
}

CLIStatus describes the command-line tool link.

func CheckCLI

func CheckCLI() CLIStatus

CheckCLI reports the state of ~/.local/bin/hopsesh without following it.

func InstallCLI

func InstallCLI(force bool) (CLIStatus, error)

InstallCLI links ~/.local/bin/hopsesh to this app's tool. It replaces only links that hopsesh made (into a hopsesh.app, or broken ones); a standalone copy or someone else's link is replaced only with force, and kept as hopsesh.bak-<time>.

type Record

type Record struct {
	Version string            `json:"hopseshVersion"`
	Files   map[string]string `json:"files"` // name → sha256
}

Record is the install record.

type SkillStatus

type SkillStatus struct {
	State   string   `json:"state"`
	Dir     string   `json:"dir"`
	Version string   `json:"installedVersion,omitempty"`
	Changed []string `json:"changedFiles,omitempty"` // files the user edited
}

SkillStatus is one copy of the skill.

func CheckSkill

func CheckSkill(dir string, files map[string][]byte) SkillStatus

CheckSkill compares the skill in dir with the files this build would write.

func InstallSkill

func InstallSkill(dir, version string, files map[string][]byte, force bool) (SkillStatus, error)

InstallSkill writes the files to dir. An edited copy, or one hopsesh did not write, is replaced only with force (the old folder is kept as hopsesh.bak-N).

Jump to

Keyboard shortcuts

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