update

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 20 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(target string)

CleanupOld removes the previous Windows executable when the next process can.

func CleanupOldRunning

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

CleanupOldRunning removes the backup left by the previous Windows update. Resolution is platform-specific so other launches never pay for this read.

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 ExecutableTarget

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

ExecutableTarget resolves the running binary before an installer replaces it.

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 Restart

func Restart(plan Plan) error

Restart starts the replacement process with this process's terminal streams.

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
}

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

func CheckLaunch

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

CheckLaunch silently checks the newest stable release when this build is a stable or release-candidate build. Every failure is absence at this surface.

func (Available) Newer

func (a Available) Newer() bool

Newer reports whether the selected stable 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
}

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

type Choice

type Choice struct {
	Channel string
	Version 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
	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
}

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