Documentation
¶
Overview ¶
Package update tells the operator a newer orch is out, and replaces the binary on request (`orch upgrade`).
Releases ship daily at times, so a user has to be told. The check is one unauthenticated read of GitHub's releases API at most once a day, cached in ~/.orch; nothing about the user or the project is sent. A release whose notes carry CriticalMarker is critical: `orch run` and `orch dashboard` refuse to start on an older version until the user upgrades or says to go ahead anyway.
Index ¶
- Constants
- func AssetName(tag, goos, goarch string) string
- func CLIBehind(installed, latest string) bool
- func CLIVersionsPath() (string, error)
- func CachePath() (string, error)
- func Highlights(body string, max int) []string
- func IsRelease(version string) bool
- func LatestCLI(ctx context.Context, r Registry, path, pkg string, now time.Time) (string, error)
- func Less(a, b string) bool
- func LooseVersion(s string) (string, bool)
- func ManagedBy(path string) string
- func Notice(current string, newer []Release) string
- func Replace(target string, binary []byte) error
- type Client
- type Downloader
- type Registry
- type Release
Constants ¶
const ( // Repo is where orch is released. Repo = "Guria-Studio/orch" // CriticalMarker, anywhere in a release's notes, makes it critical. CriticalMarker = "<!-- orch:critical -->" // DisableEnv turns the check, the notice and the critical gate off. DisableEnv = "ORCH_NO_UPDATE_CHECK" // MaxAge is how long a check is trusted before GitHub is asked again. MaxAge = 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func CLIBehind ¶
CLIBehind reports whether installed is older than latest; either one without a version in it is not behind.
func CLIVersionsPath ¶
CLIVersionsPath is where the CLIs' latest versions are remembered: ~/.orch/cli-versions.json.
func Highlights ¶
Highlights returns the first max list items of release notes, as plain one-line text: emphasis dropped, GitHub's generated "by @x in <PR URL>" shortened to "(#N)", long items cut. Notes with no list give none.
func LatestCLI ¶
LatestCLI is pkg's latest version, from the cache at path while it is younger than MaxAge and from the registry otherwise. Like Check, a failed read returns the last known version with the error and is still recorded, so an offline machine waits out the timeout once a day, not every command.
func LooseVersion ¶
LooseVersion is the first x.y.z in s, whatever surrounds it: a CLI's `--version` says "codex-cli 0.154.0" or "2.1.310 (Claude Code)".
func ManagedBy ¶
ManagedBy names the package manager that owns the binary at path, or "" when orch was installed by hand or by install.sh. A managed binary is upgraded through its manager; replacing it underneath would desync it.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
// API is GitHub's API root; empty means api.github.com.
API string
}
Client reads orch's releases.
type Downloader ¶
type Downloader struct {
HTTP *http.Client
// Base is where release files are served from; empty means GitHub.
Base string
}
Downloader fetches release archives.
type Registry ¶
type Registry struct {
HTTP *http.Client
// URL is the registry's root; empty means registry.npmjs.org.
URL string
}
Registry reads the latest version of an npm package.
type Release ¶
type Release struct {
Tag string `json:"tag"`
URL string `json:"url"`
Critical bool `json:"critical"`
// Highlights are the first items of the release notes, one line each.
Highlights []string `json:"highlights"`
// Notes are the release notes whole, as Markdown, and PublishedAt when
// the release went out: what the dashboard's What's new page shows.
Notes string `json:"notes"`
PublishedAt string `json:"published_at"`
}
Release is one Go release of orch, as the notice needs it.
func Check ¶
Check returns orch's releases, from the cache at path while it is younger than MaxAge and from GitHub otherwise. When GitHub cannot be reached the last known releases are returned with the error, and the attempt is still recorded: offline, every command would otherwise wait out the timeout.