core

package
v1.23.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 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 core holds the CLI's own identity and its exit and error contract. It depends on nothing but the standard library.

Index

Constants

View Source
const BootstrapID = "gtt-bootstrap"

BootstrapID is the only Bootstrap identity this CLI operates.

View Source
const BootstrapPin = "1.23.1"

BootstrapPin is the exact GTT Bootstrap release this CLI release ships with. Pinning the CLI therefore pins the Bootstrap. It is resolved from its release tag (BootstrapTag), never from a branch head; another release is used only when the human names it explicitly.

View Source
const OutputSchema = 1

OutputSchema is the version of every JSON document the CLI emits.

View Source
const StaleAfterDays = 21

StaleAfterDays is how old a CLI build may be before it says so. GTT releases often; a CLI that is weeks old runs a Bootstrap that lacks what the newer ones carry.

Variables

View Source
var BootstrapSchemas = []int{1}

BootstrapSchemas are the Bootstrap schema versions this CLI understands.

View Source
var BuildDate = ""

BuildDate is the day this binary was built (YYYY-MM-DD). Release builds set it with -ldflags; a plain source build leaves it empty and falls back to the VCS time Go recorded, if any.

View Source
var CLICapabilities = []string{"contract.negotiate.v1", "operation.execute.v1", "delivery.v1"}

CLICapabilities are the capability ids this CLI declares to a Bootstrap during negotiation.

View Source
var ErrCancelled = &Error{Code: ExitCancelled, What: "Cancelled."}

ErrCancelled is returned when the human declines.

View Source
var SupportedCapabilities = map[string]int{
	"project.detect":       1,
	"ade.detect":           1,
	"ade.install":          1,
	"template.materialize": 1,
	"methodology.profile":  1,
	"source.select":        1,
	"validation":           1,
	"status":               1,
	"freeze":               1,
	"session-context":      1,
	"export-policy":        1,
	"recovery":             1,
	"guard":                1,
	"retrieval":            1,
	"developer-experience": 1,
	"inbox.v1":             1,
}

SupportedCapabilities maps each Bootstrap capability this CLI consumes to the version it implements. A Bootstrap that offers one of these at another version is refused; a capability not listed here is simply not used.

View Source
var Version = baseVersion

Version is the CLI release. Each release pins one Bootstrap release (BootstrapPin) with the same number: GTT is released as a suite (ADR-005), and compatibility is still negotiated, never assumed. Release builds set it with -ldflags; `go install module@vX.Y.Z` takes it from the module version; a plain source build keeps this base value.

Functions

func BootstrapTag added in v1.1.0

func BootstrapTag(version string) string

BootstrapTag is the release tag of a Bootstrap version.

func CompareSemver

func CompareSemver(a, b [3]int) int

CompareSemver returns -1, 0 or 1.

func ParseSemver

func ParseSemver(s string) (v [3]int, ok bool)

ParseSemver parses MAJOR.MINOR.PATCH; ok is false for anything else.

func StaleDays added in v1.18.0

func StaleDays(now time.Time) (int, bool)

StaleDays reports how many days old this build is, and whether that is past StaleAfterDays. It uses no network: the age of the binary is a fact the binary knows.

Types

type Error

type Error struct {
	Code       ExitCode
	What       string
	Why        string
	Next       string
	Unmodified bool // true when the project is known to be untouched
	Err        error
}

Error is a user-facing error: what happened, why, and what to do next.

func Errorf

func Errorf(code ExitCode, format string, args ...any) *Error

Errorf builds an Error with only a code and a message.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Render added in v1.8.0

func (e *Error) Render(l interface{ T(string) string }) string

Render writes the error for a human in a language; nil is English.

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ExitCode

type ExitCode int

ExitCode is the v1.0 exit contract.

const (
	ExitOK           ExitCode = 0
	ExitFailure      ExitCode = 1 // validation / operational failure
	ExitIncompatible ExitCode = 2 // CLI/Bootstrap incompatibility
	ExitUsage        ExitCode = 3 // invalid invocation
	ExitCancelled    ExitCode = 4 // user cancellation
	ExitConflict     ExitCode = 5 // project state conflict
	ExitIntegrity    ExitCode = 6 // Bootstrap integrity failure
	ExitUnavailable  ExitCode = 7 // external dependency unavailable
)

func CodeOf

func CodeOf(err error) ExitCode

CodeOf maps any error to its exit code.

type LangSource added in v1.8.0

type LangSource int

LangSource ranks where a language choice came from: a lower one wins.

const (
	// LangExplicit is --language, or the human's answer in init.
	LangExplicit LangSource = iota
	// LangProject is the language the project recorded.
	LangProject
	// LangEnv is GTT_LANG. The locale (LANG, LC_*) is never read: the
	// output must not depend on the machine it runs on.
	LangEnv
)

type Language added in v1.8.0

type Language struct {
	// contains filtered or unexported fields
}

Language is the interaction language of one invocation. English strings in the code are the keys; a catalog translates them at the output boundary. A string without a translation is shown in English. The zero value and a nil *Language speak English.

func (*Language) Code added in v1.8.0

func (l *Language) Code() string

Code is the language in force: the first choice by rank, else English.

func (*Language) Set added in v1.8.0

func (l *Language) Set(from LangSource, code string)

Set records a language choice from one source; "" clears it.

func (*Language) Sprintf added in v1.8.0

func (l *Language) Sprintf(format string, args ...any) string

Sprintf translates format before formatting, so its arguments survive. A string argument that is itself a known message is translated too (none, yes, a reason...). A format without a translation is formatted in English and then matched as a whole message (see T).

func (*Language) T added in v1.8.0

func (l *Language) T(s string) string

T translates one complete message: an exact catalog entry, else an entry whose %s/%d slots match the message (messages built by concatenation). Surrounding blank space is kept; anything unknown stays English.

Jump to

Keyboard shortcuts

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