ports

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 2 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 ports declares the interfaces through which use cases reach every external system, and the operational data they exchange. Nothing here carries GTT methodology: these are operational abstractions only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ADE

type ADE struct {
	ID          string
	Name        string
	DetectPaths []string
	Binary      string
	Entry       string
	Enforcement string
	OwnedPaths  []string // project paths the Bootstrap declares as this ADE's
	Version     int      // version of the registry entry
}

ADE is one entry of the Bootstrap ADE registry, reduced to what the CLI operates on.

type ADEExecutor

type ADEExecutor interface {
	ID() string
	Available() bool
	BuildCommand(contract HandoffContract) Command
	Execute(ctx context.Context, contract HandoffContract) error
}

ADEExecutor knows how to detect and start one ADE. It knows no methodology.

type AgentAdapter

type AgentAdapter interface {
	ID() string
	Name() string
	// Version is the version of the adapter's registry entry.
	Version() int
	// Detect returns the signals observed in the project or on the machine.
	// A signal makes the agent a candidate and nothing more.
	Detect(projectRoot string, runner Runner) []string
	// ContextLocations are the project paths the adapter manages.
	ContextLocations() []string
	// InstructionEntry is the file the agent reads first.
	InstructionEntry() string
}

AgentAdapter is the integration of one ADE/agent as the CLI operates it: how it is detected and which project locations hold its context. Every name and path comes from the Bootstrap ADE registry, so a new ADE needs a registry entry and no CLI change. Validating and synchronising the context are Bootstrap operations, not adapter methods.

type AgentRegistry

type AgentRegistry interface {
	Adapters() []AgentAdapter
	Adapter(id string) (AgentAdapter, bool)
}

AgentRegistry is the set of agents GTT has an integration for.

type Bootstrap

type Bootstrap interface {
	Root() string
	Release(ctx context.Context) (Release, error)
	// Negotiate fails closed: any doubt is an incompatibility.
	Negotiate(ctx context.Context) (Negotiation, error)
	Capabilities(ctx context.Context) ([]Capability, error)
	Operations(ctx context.Context) (map[string]Operation, error)
	Show(ctx context.Context, contract string) (json.RawMessage, error)
	CheckContracts(ctx context.Context) ([]string, error)
	Execute(ctx context.Context, req OperationRequest) (OperationResult, error)
}

Bootstrap is the runtime boundary to one Bootstrap tree (an installed project or a catalog). Implementations hide every Bootstrap detail.

type BootstrapFactory

type BootstrapFactory interface {
	At(root string) Bootstrap
	// Installed reports whether root holds a Bootstrap contract surface.
	Installed(root string) bool
}

BootstrapFactory binds a runtime to a directory.

type Candidate

type Candidate struct {
	ADE
	Signals []string
	Status  string // Bootstrap-reported status when installed, else ""
}

Candidate is a detected ADE: an observation, never a choice.

type Capability

type Capability struct {
	ID         string   `json:"id"`
	Version    int      `json:"version"`
	Operations []string `json:"operations"`
	Summary    string   `json:"summary"`
}

Capability is one entry of the Bootstrap capability registry.

type Command

type Command struct {
	Path        string
	Args        []string
	Dir         string
	Env         []string
	Interactive bool // attach the terminal instead of capturing output
}

Command is one structured process invocation: a trusted executable, its arguments, environment additions and working directory.

type CoreLayout

type CoreLayout struct {
	Paths []string // every top-level file and directory, slash separated
	// Package are the paths that hold Bootstrap package content (the engine
	// and the entry points); the governed domain is never among them.
	Package []string
	// Rewritten are the engine paths the manifest declares as derived or as
	// state (a trailing slash names a directory): the Bootstrap's own scripts
	// rewrite them, so a difference there is never a local customization.
	Rewritten []string
	// State are the engine paths the manifest declares as per-project state
	// (a trailing slash names a directory). A package never ships them: a
	// local catalog that happens to hold them is not copied into a project.
	State []string
	// Tracking is where the Bootstrap declares the initial-source tracking
	// record (manifest section `tracking:`); empty when it declares none.
	Tracking string
}

CoreLayout is what the scaffold manifest says the portable core is.

type Git

type Git interface {
	Available() bool
	Root(ctx context.Context, dir string) (string, bool)
}

Git answers read-only questions about the repository.

type HandoffContract

type HandoffContract struct {
	ProjectRoot      string
	InstructionEntry string
	ReadFirst        []string
}

HandoffContract is what the CLI delivers to an ADE. Its content comes from the Bootstrap; the CLI never authors instructions.

type Installer

type Installer interface {
	Layout(pkg Package) (CoreLayout, error)
	Conflicts(pkg Package, projectRoot string) ([]string, error)
	// Install copies the core and returns the ledger path -> sha256.
	Install(pkg Package, projectRoot string) (map[string]string, error)
	Remove(projectRoot string, layout CoreLayout) error
}

Installer stages and commits the portable core into a project.

type KeyPair

type KeyPair struct {
	ID      string `json:"key_id"`
	Private string `json:"private_key"`
	Public  string `json:"public_key"`
}

KeyPair names the files of a release signing key.

type Logger

type Logger interface {
	Log(level, format string, args ...any)
}

Logger receives internal log lines (error, warn, info, debug). They go to stderr, never to the result, and must never carry tokens, credentials or environment values.

type Negotiation

type Negotiation struct {
	Compatible bool     `json:"compatible"`
	Reasons    []string `json:"reasons"`
}

Negotiation is the compatibility decision. Compatible false means the project must not be touched.

type Operation

type Operation struct {
	Version        int            `json:"version"`
	Args           []OperationArg `json:"args"`
	Mutates        bool           `json:"mutates"`
	HumanAuthority bool           `json:"human_authority"`
	Outputs        struct {
		Format   string `json:"format"`
		Contract string `json:"contract"`
	} `json:"outputs"`
}

Operation is one entry of the Bootstrap operation registry.

func (Operation) HasArg

func (o Operation) HasArg(name string) bool

HasArg reports whether the operation declares an argument.

type OperationArg

type OperationArg struct {
	Name     string   `json:"name"`
	Type     string   `json:"type"`
	Required bool     `json:"required"`
	Values   []string `json:"values"`
}

OperationArg is one declared argument of an operation.

type OperationRequest

type OperationRequest struct {
	Operation string
	Args      map[string]string
	// Apply performs the change; without it a mutating operation is a dry run.
	Apply bool
	// ConfirmedByHuman must be set only after the human actually confirmed.
	ConfirmedByHuman bool
}

OperationRequest asks the Bootstrap to run one declared operation.

type OperationResult

type OperationResult struct {
	Operation string
	ExitCode  int
	Stdout    string
	Stderr    string
	Format    string
	Applied   bool
}

OperationResult is the envelope the Bootstrap returns.

func (OperationResult) JSON

func (r OperationResult) JSON(v any) error

JSON decodes a JSON-format result into v.

func (OperationResult) OK

func (r OperationResult) OK() bool

OK reports a zero exit of the implementation.

type Option

type Option struct {
	Label  string
	Detail string
}

Option is one selectable entry.

type Package

type Package struct {
	Root     string
	Source   string // local | recorded | cache | remote
	Origin   string // path or URL it came from
	Checksum string
	Release  Release
	// Integrity and Signature are the verification results, recorded as-is.
	Integrity string
	Signature string
}

Package is a resolved Bootstrap catalog on disk.

type Prompter

type Prompter interface {
	Interactive() bool
	Confirm(question string, def bool) (bool, error)
	Select(title string, options []Option) (int, error)
	MultiSelect(title string, options []Option) ([]int, error)
	// Ask reads one line of free text; an empty answer is "" (never a default).
	Ask(question string) (string, error)
}

Prompter asks the human. Every method returns core.ErrCancelled-compatible errors when input ends, and must not be used when Interactive is false.

type Release

type Release struct {
	Bootstrap struct {
		ID            string `json:"id"`
		Version       string `json:"version"`
		SchemaVersion int    `json:"schema_version"`
		Channel       string `json:"channel"`
	} `json:"bootstrap"`
	Scaffold struct {
		Version  int    `json:"version"`
		Manifest string `json:"manifest"`
	} `json:"scaffold"`
	Canon         string `json:"canon"`
	Compatibility struct {
		CLI struct {
			MinVersion string  `json:"min_version"`
			MaxVersion *string `json:"max_version"`
		} `json:"cli"`
		Schema struct {
			Version int `json:"version"`
		} `json:"schema"`
	} `json:"compatibility"`
	RequiresCLICapabilities []string       `json:"requires_cli_capabilities"`
	SupportedLanguages      []string       `json:"supported_languages"`
	Contracts               map[string]int `json:"contracts"`
}

Release is the Bootstrap release descriptor.

type ReleaseSigner

type ReleaseSigner interface {
	Keygen(dir, id string) (KeyPair, error)
	Sign(ctx context.Context, root, keyFile string) (SignResult, error)
}

ReleaseSigner creates release keys and signs Bootstrap packages. It is for whoever publishes a Bootstrap release; verification never uses it.

type Reporter

type Reporter interface {
	Info(format string, args ...any)
	// Detail is shown only when the human asked for detail.
	Detail(text string)
}

Reporter receives progress lines meant for a human. Implementations stay silent when machine-readable output was requested.

type ResolveRequest

type ResolveRequest struct {
	Path     string // explicit --bootstrap
	Version  string // --bootstrap-version
	Offline  bool
	Recorded string // source recorded by the project, if any
	Refresh  bool   // look for a newer release instead of reusing the cache
	Checksum string // expected checksum, if the caller has one
}

ResolveRequest states how the human asked for a Bootstrap.

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, req ResolveRequest) (Package, error)
	Verify(ctx context.Context, pkg *Package) error
}

Resolver finds and verifies a Bootstrap catalog.

type Result

type Result struct {
	Stdout   []byte
	Stderr   []byte
	ExitCode int
}

Result is the outcome of a Command.

type Runner

type Runner interface {
	Run(ctx context.Context, c Command) (Result, error)
	LookPath(name string) (string, error)
}

Runner executes processes.

type SelfUpgrader added in v1.23.0

type SelfUpgrader interface {
	// Latest is the newest published release, as MAJOR.MINOR.PATCH.
	Latest(ctx context.Context) (string, error)
	// Plan decides how the running binary would be replaced by the target release.
	Plan(target string) UpgradePlan
	// Apply replaces the binary. On failure the previous binary is back in place.
	Apply(ctx context.Context, plan UpgradePlan) error
}

SelfUpgrader replaces the gtt binary with another release. Only this port touches the network for the CLI's own sake; it never touches a project.

type SignResult

type SignResult struct {
	Path     string `json:"signature"`
	KeyID    string `json:"key_id"`
	Version  string `json:"bootstrap_version"`
	Checksum string `json:"checksum"`
}

SignResult describes a signed Bootstrap package.

type UpgradePlan added in v1.23.0

type UpgradePlan struct {
	Channel string   `json:"channel"`           // npm, uv, pipx, go or direct
	Exe     string   `json:"executable"`        // the binary being replaced
	Target  string   `json:"target"`            // the release to install
	Command []string `json:"command,omitempty"` // the package manager command it would run
	// Manual is set when the CLI cannot or should not do it itself; Hint is the exact command a human runs.
	Manual bool   `json:"manual,omitempty"`
	Hint   string `json:"hint,omitempty"`
	Reason string `json:"reason,omitempty"`
}

UpgradePlan is what replacing this binary with another release would do.

Jump to

Keyboard shortcuts

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