install

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 11 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 install implements `panda install` / `panda uninstall` / `panda doctor`: placing the binary on PATH (persistently, per-OS), and a whitelist-based uninstall that backs up and removes only OpenPanda-owned state while preserving user assets (projects, memory, skills, work) — unless the user passes --purge and survives its second confirmation.

Safety model: uninstall never walks the filesystem looking for things to delete. Every deletion candidate is derived from explicit inputs (the running executable, the install dir, the loaded config's storage paths) and validated against guardrails in Scan — a candidate that is empty, a filesystem root, the user's home, or overlaps a user-asset directory is flipped to "keep" with a reason. The user sees the full plan and must type `confirm` before anything is touched.

Index

Constants

View Source
const (
	KindBinary  = "binary"
	KindData    = "data"
	KindConfig  = "config"
	KindPath    = "path" // PATH persistence entry (rc file / registry) — informational
	KindMemory  = "memory"
	KindProject = "projects"
	KindSkill   = "skills"
	KindWork    = "work"
)

Target kinds. "binary"/"data"/"config"/"path" are OpenPanda-owned; the asset kinds mark user trees that are always kept.

View Source
const (
	WebServiceLabel    = "com.openpanda.web"
	WebServiceUnitName = "openpanda-web.service"
	WebServiceTaskName = "OpenPandaWeb"

	// The daemon's names, for callers that need to tell "the daemon owns the
	// node row" from "the console does" without hard-coding a second copy.
	NodeServiceLabel    = "com.openpanda.node"
	NodeServiceUnitName = "openpanda.service"
	NodeTaskName        = "OpenPandaNode"
)

The console runs as its own user-level service (`panda service install`), separate from the daemon's units. The names live here so the installer, the updater and `panda service` all speak one spelling: they were duplicated once already, and a stop that names a unit nobody registered is invisible until a logon launches a deleted binary.

Variables

This section is empty.

Functions

func AddToPATH

func AddToPATH(dir string) ([]string, error)

AddToPATH appends the marked export block to every existing rc file (or creates ~/.profile when none exist — rare, but a fresh minimal box should still work). Returns the files it touched; an empty slice with nil error means the marker is already present (idempotent re-install).

func BackupZip

func BackupZip(dest string, targets []Target) (int, error)

BackupZip archives the given targets into a zip so an uninstall is reversible. Which items land in the archive is the caller's decision: a normal uninstall passes the delete-kind targets (data/config), a --purge run also passes the user-asset targets that are about to die. The binary and PATH entries are never archived; files that vanished between Scan and execution are skipped silently. Returns the number of files archived.

func BundledDir added in v0.0.11

func BundledDir(name string) string

BundledDir locates a shipped sidecar directory by name ("adapters", "drivers", "extensions/voice", …) the way the packaged layouts place it: the working directory first (run-from-repo-root), then beside the real executable — PATH installs symlink the binary, so the link is followed to the packaged prefix — and finally the per-user config/home dirs an install step copies into. Returns an absolute path, "" when not found.

func CopySelf

func CopySelf(dst string) error

CopySelf copies the running executable to dst (creating parent dirs). The copy goes through a temp file + rename so a half-written binary never sits at the destination. A pre-existing dst is replaced — that is the update path (`panda install` over an older install).

func Dir

func Dir() (string, error)

Dir returns the default install directory: ~/.local/bin on unix (XDG convention, preconfigured on most Linux distros), %LOCALAPPDATA%\OpenPanda \bin on Windows (per-user, no elevation needed).

func ExeName

func ExeName() string

ExeName is the installed binary's file name ("panda" / "panda.exe").

func InPATH

func InPATH(dir string) bool

InPATH reports whether dir is on the current process's PATH. The install flow uses it to decide whether to touch shell startup files at all.

func PathPersistedAt

func PathPersistedAt(dir string) []string

PathPersistedAt reports which rc files currently carry the marker — doctor shows this as the "will survive reboot" state.

func RemoveOne

func RemoveOne(path string) error

RemoveOne deletes a single target. Symlinks remove the link only — never anything they point at. Directories go recursively.

func RemovePATHPersistence

func RemovePATHPersistence(_ string) ([]string, error)

RemovePATHPersistence strips our marked blocks from every rc file. The dir argument is unused on unix (markers identify our lines); it exists so both platforms share one signature. Returns the files that changed; user-authored lines are never touched.

func RestartDaemon added in v0.0.10

func RestartDaemon()

RestartDaemon best-effort bounces a registered node daemon so it picks up a freshly swapped binary (self-update replaces the file on disk, but a running daemon keeps its old image until the service manager restarts it).

It only ever touches services that are already running: launchd kickstart -k runs only when the agent is loaded and reports "state = running", and systemctl's try-restart is a no-op for inactive or absent units. A daemon started by hand in a terminal is intentionally left alone — there is no service to bounce — so the update surfaces the restart hint instead. Failures are ignored for the same reason as StopServices.

func RestartWebService added in v0.1.4

func RestartWebService()

RestartWebService bounces the console's own unit after a binary swap. Without it an updated install keeps serving the old image from the panel process, and the version that answers the browser is not the version on disk. Same running-only contract as RestartDaemon.

func StopServices

func StopServices()

StopServices best-effort stops a user-level daemon if one is registered (LaunchAgent on macOS, user systemd unit on Linux — the units ship in scripts/ and deploy/). The console's own unit, written by `panda service install`, is stopped and removed as well: it is this binary's artifact, and leaving it registered would relaunch a binary that uninstall is about to delete at every login. Failures are ignored: an unregistered service, a different init system, or no daemon running are all normal states during uninstall, and the daemon's unit files belong to the OS packaging, not to this binary.

func SweepablePrefix added in v0.0.4

func SweepablePrefix(exePath string) (string, bool)

SweepablePrefix reports the distribution prefix when it is safe for the uninstall to sweep it: not a Homebrew Cellar (brew owns those files) and not a source checkout (go.mod / .git beside a locally built bin/panda — the dev repo layout, where adapters/ belongs to git, not to us).

func Verify

func Verify(bin string) (string, error)

Verify runs `<bin> version` and returns its trimmed output. This is the post-install self-check the user asked for: proof the installed copy executes, not just that a file landed.

Types

type PlanInput

type PlanInput struct {
	Storage            *StoragePaths
	ConfigFileUsed     string // the config file the run resolved to (may not exist)
	CapabilityCardUsed string // the capability card the run resolved to (may not exist)
	ExePath            string
	InstallDir         string
}

PlanInput collects everything Scan derives deletions from. Storage may be nil (config unreadable) — the binary and PATH entries are still actionable.

type StoragePaths

type StoragePaths struct {
	DBPath       string
	ContextPath  string
	MemoryPath   string
	ProjectsPath string
	SkillsPath   string
	WorkPath     string
	VAPIDKeyPath string
}

StoragePaths mirrors the subset of config.StorageConfig the uninstall needs, decoupled so config changes don't ripple into this package.

type Target

type Target struct {
	Path   string
	Kind   string
	Delete bool
	Reason string // why a kept item is kept; ignored for delete items
	Bytes  int64
	Exists bool
}

Target is one line of the uninstall plan.

func Scan

func Scan(in PlanInput) []Target

Scan builds the full uninstall plan. Deletion candidates outside the whitelist, or overlapping home / user assets, are downgraded to keep — the function never upgrades anything to Delete, so it cannot manufacture a deletion the inputs did not explicitly name.

type UninstallOptions added in v0.0.4

type UninstallOptions struct {
	// BackupPath is where the backup zip is written; empty skips the backup.
	BackupPath string
	// Purge additionally deletes the user-asset targets (memory/projects/
	// skills/work). The caller owns the double confirmation — this field is
	// the result of the second prompt, never a default.
	Purge bool
	// BackupOnly writes the backup and returns without deleting anything.
	BackupOnly bool
}

UninstallOptions drives ExecuteUninstall.

type UninstallOutcome added in v0.0.4

type UninstallOutcome struct {
	BackupFiles int
	BackupErr   error
	Deleted     []Target // OpenPanda-owned items removed
	Purged      []Target // user-asset dirs removed (--purge)
	Kept        []Target // items the run left on disk
	Failed      []string // "path (error)" entries
}

UninstallOutcome reports what an ExecuteUninstall run did. Individual failures are collected in Failed rather than aborting the run — the uninstall report surfaces them at the end.

func ExecuteUninstall added in v0.0.4

func ExecuteUninstall(targets []Target, opt UninstallOptions) UninstallOutcome

ExecuteUninstall runs the backup + deletion phases of an uninstall over a scanned plan. It deletes exactly what the plan marked Delete — minus the PATH entries, which the caller removes through the per-OS rc editors — and, when Purge is set, the user-asset targets. Purge candidates are guarded here as well: an asset path that is empty, a filesystem root, the home directory, or an ancestor of it is kept regardless of the flag. BackupOnly stops after the backup so nothing is removed.

Jump to

Keyboard shortcuts

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