install

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package install owns the SOUL.md install conventions: harness detection, the per-framework target table, the overwrite gate, and the install receipt written by install.sh. Paths are injected so everything is testable without touching the real home directory.

Index

Constants

View Source
const ReceiptName = "positronick-install-receipt.json"

ReceiptName is the filename install.sh writes next to the binary — a cross-repo contract with install.sh and positronick.com/install.sh.

Variables

View Source
var Targets = []string{"hermes", "claude", "cursor", "openclaw"}

Targets are the supported install targets, in detection-priority order.

Functions

func DetectHarness

func DetectHarness(cwd, home string) string

DetectHarness returns the install target for the first harness marker directory found — all markers are checked in cwd first (a project-local harness wins), then in home — or "" when none exists. Only directories count; an empty cwd/home is skipped.

func TargetPath

func TargetPath(target, cwd, home string) (string, error)

TargetPath returns the conventional SOUL.md location for a target. hermes, claude and openclaw are home-anchored; cursor is project-local (its rules live inside the repository).

func WriteReceipt

func WriteReceipt(binPath string, r Receipt) error

WriteReceipt writes the receipt next to the binary at binPath, in the same shape install.sh produces.

Types

type Options

type Options struct {
	// Target is one of Targets. It picks the destination (when Path is
	// empty) and the formatting (cursor wraps the body in mdc frontmatter).
	// An empty Target with a Path writes the body verbatim to Path.
	Target string
	// Path, when set, overrides the target's conventional destination.
	Path string
	// SoulName fills the cursor frontmatter description.
	SoulName string
	// Cwd and Home anchor the conventional paths (injected for tests).
	Cwd, Home string
	// Force overwrites an existing file without asking.
	Force bool
	// Link, with Target "claude", appends the @-import line to
	// ~/.claude/CLAUDE.md when not already present.
	Link bool
	// Interactive enables the Confirm prompt for overwrites.
	Interactive bool
	// Confirm asks the user to approve overwriting the named file. Required
	// when Interactive and the destination exists.
	Confirm func(prompt string) (bool, error)
	// OverwriteHint names the flag suggested when refusing to overwrite
	// non-interactively; defaults to "--force".
	OverwriteHint string
	// Fetch returns the verbatim SOUL.md body. It is called only after the
	// overwrite gate passes: the server's .md endpoint bumps the public
	// download counter, and a refused install is not a download.
	Fetch func() (string, error)
}

Options configures one SOUL.md install.

type Receipt

type Receipt struct {
	Method  string `json:"method"`
	Version string `json:"version"`
}

Receipt records how the binary was installed. install.sh writes {"method":"installer","version":"..."}; `self update` rewrites it after a successful in-place update.

func ReadReceipt

func ReadReceipt(binPath string) Receipt

ReadReceipt reads the receipt next to the resolved binary at binPath. A missing, unreadable or malformed receipt yields method "unknown" — the binary is then treated like a package-manager install, which `self update` must never replace in place.

type Result

type Result struct {
	Path  string
	Bytes int
}

Result reports where an install landed and how many bytes were written.

func Install

func Install(opts Options) (*Result, error)

Install resolves the destination, gates overwrites (prompt when Interactive, Force otherwise), fetches the body, writes it (creating parent directories), and runs the claude CLAUDE.md link when asked.

Jump to

Keyboard shortcuts

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