install

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 9 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).

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.

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 writes the existing delete-kind targets (data/config — never the binary, never rc entries) into a zip so an uninstall is reversible. Files that vanished between Scan and execution are skipped silently. Returns the number of files archived.

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 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/). Failures are ignored: an unregistered service, a different init system, or no daemon running are all normal states during uninstall, and the unit files themselves belong to the OS packaging, not to this binary.

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)
	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.

Jump to

Keyboard shortcuts

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