update

package
v0.5.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package update finds, installs, and restarts onto codeaf releases.

Index

Constants

View Source
const (
	// CurlCommand is the independent installation road shown at launch beside
	// /update and after a failed or unavailable in-place update. IT IS THE
	// SUPPORTED LINE, NOT THE SCRIPT UNDER IT: agentfield.ai/get/codeaf serves
	// scripts/install.sh from main, and the address is the one a person can
	// remember and the one every other place codeaf documents spells, so a
	// launch line and the README can never hand out two different roads.
	CurlCommand = "curl -fsSL https://agentfield.ai/get/codeaf | bash"

	NoUpdateCheckEnv  = "CODEAF_NO_UPDATE_CHECK"
	GitHubAPIEnv      = "CODEAF_GITHUB_API"
	GitHubDownloadEnv = "CODEAF_GITHUB_DOWNLOAD"
)
View Source
const (
	// CheckTimeout is the whole-exchange budget for a launch check and for
	// `codeaf update --check`. THE CHECK CLOCK NEVER COVERS AN INSTALL: a
	// release asset is allowed to make steady progress for much longer.
	CheckTimeout = 3 * time.Second
)

Variables

This section is empty.

Functions

func ChannelTag

func ChannelTag(channel, date, sha string) (string, error)

ChannelTag forms a dev or staging tag from a date and revision.

func CleanupOld

func CleanupOld(string)

CleanupOld removes nothing on systems where the running executable can be replaced directly.

func CleanupOldRunning

func CleanupOldRunning(func() (string, error))

CleanupOldRunning does nothing where replacing a running executable leaves no backup. In particular, it does not resolve the executable during launch.

func CompareChannelBuilds added in v0.4.0

func CompareChannelBuilds(running string, runningPublished time.Time, selected string, selectedPublished time.Time) (int, bool)

CompareChannelBuilds compares a running build with the release selected by the API from the same channel. A negative result means the selected release is newer; a positive result means the running build is ahead.

func CompareSemverTags

func CompareSemverTags(left, right string) (int, bool)

CompareSemverTags orders stable and release-candidate tags. A stable tag follows every release candidate on its own version line.

func CurlLine added in v0.4.0

func CurlLine(executable, channel string) string

CurlLine returns the independent installation road for the running file and release channel. The product remains codeaf; only the destination file name changes when a differently named executable asks for its own road back.

func ExecutableTarget

func ExecutableTarget(executable func() (string, error)) (string, error)

ExecutableTarget resolves the running binary before an installer replaces it.

func FollowedChannel added in v0.4.0

func FollowedChannel(running string) string

FollowedChannel names the release channel a build takes its updates from. IT IS NOT ALWAYS THE CHANNEL THE TAG WAS CUT ON: a release candidate follows STABLE, because its launch line, its bare /update and its bare `codeaf update` all speak about the stable release its line is heading for. A build from source follows stable too, so the road it is offered is the ordinary one. Only dev and staging follow themselves. Every place that has to answer "which channel is this build on" asks here, so the launch notice and the curl line under it can never name two different roads.

func Kind

func Kind(tag string) string

Kind names the release channel encoded by a tag.

func NextSemverTag

func NextSemverTag(tags []string, channel, component string) (string, error)

NextSemverTag returns the next stable or release-candidate tag.

func ParseChannel added in v0.4.0

func ParseChannel(tag string) (channel, date string, ok bool)

ParseChannel returns the channel and calendar date carried by a dev or staging tag. The date is kept as YYYYMMDD because that spelling sorts in the same order as the days it names.

func Restart

func Restart(plan Plan) error

Restart replaces this process after the terminal has been restored.

func RestartArgs

func RestartArgs(original []string, transcript string) []string

RestartArgs keeps the original launch shape and points it at this transcript.

func ValidDate

func ValidDate(value string) bool

ValidDate reports whether a date has the channel tag's YYYYMMDD shape.

func ValidSHA

func ValidSHA(value string) bool

ValidSHA reports whether a revision can form a channel tag.

Types

type Available

type Available struct {
	Latest           string
	Running          string
	LatestPublished  time.Time
	RunningPublished time.Time
	Curl             string
}

Available is the release comparison shown at launch or by --check.

func CheckLaunch

func CheckLaunch(ctx context.Context, options CheckOptions) (Available, bool)

CheckLaunch silently checks the release channel this build follows. Every failure is absence at this surface.

func (Available) Ahead added in v0.4.0

func (a Available) Ahead() bool

Ahead reports whether this build is newer than the release selected from its own channel. Source builds and incomparable channels are never called ahead.

func (Available) Newer

func (a Available) Newer() bool

Newer reports whether the selected release supersedes this build.

func (Available) Notice

func (a Available) Notice() string

Notice is the one launch line carrying both update roads.

type CheckOptions

type CheckOptions struct {
	Running    string
	ProfileDir string
	Client     *Client
	Now        func() time.Time
	Disabled   bool
	Executable string
}

CheckOptions supplies the launch policy's disk, clock, and release client.

type Choice

type Choice struct {
	Channel string
	Version string
	Running string
}

Choice selects one release channel or one exact tag.

type Client

type Client struct {
	HTTP            *http.Client
	APIBase         string
	DownloadBase    string
	Token           string
	Revision        string
	CheckWindow     time.Duration
	APIWindow       time.Duration
	StallWindow     time.Duration
	DownloadCeiling time.Duration
}

Client talks to the release API and release asset host.

func NewClient

func NewClient(revision string, timeout time.Duration) *Client

NewClient builds the release client from the same mirror and token inputs as the shell installer. The timeout belongs only to the small release check; every install request carries the clock for the particular thing it reads.

func (*Client) Check

func (c *Client) Check(ctx context.Context, choice Choice) (Release, error)

Check selects one release inside the short whole-exchange window shared by the launch notice and the terminal's explicit check. Installation calls Select directly, where each metadata request receives its own API window.

func (*Client) Select

func (c *Client) Select(ctx context.Context, choice Choice) (Release, error)

Select resolves a channel with the same timestamp law as the shell installer.

type InstallOptions

type InstallOptions struct {
	Client  *Client
	Release Release
	Target  string
	Curl    string
	GOOS    string
	GOARCH  string
}

InstallOptions describes one in-place replacement.

type InstallResult

type InstallResult struct {
	Release Release
	Path    string
}

InstallResult is the release and executable path that are ready to restart.

func Install

func Install(ctx context.Context, options InstallOptions) (InstallResult, error)

Install downloads, checks, and atomically replaces one executable.

type Plan

type Plan struct {
	Path string
	Args []string
}

Plan is the executable and arguments a restored terminal restarts with.

type RCTag

type RCTag struct {
	Base    Version
	Counter int
}

RCTag is a release candidate and the stable line it belongs to.

func ParseRC

func ParseRC(tag string) (RCTag, bool)

ParseRC parses a release-candidate tag.

type Release

type Release struct {
	Tag                string
	Repository         string
	PublishedAt        time.Time
	RunningPublishedAt time.Time
}

Release is one selected GitHub release and the repository that answered.

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

Version is the stable semantic part of a release tag.

func ParseStable

func ParseStable(tag string) (Version, bool)

ParseStable parses a stable release tag.

func (Version) Bump

func (v Version) Bump(component string) (Version, error)

Bump advances one semantic component.

func (Version) Compare

func (v Version) Compare(other Version) int

Compare orders stable semantic versions.

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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