cli

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 154 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 cli implements the subcommands.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Functions

func Defaults added in v0.2.0

func Defaults() config.Config

Defaults is the config a file overrides: config's defaults with the agent and the workspace managers this build picks.

func InstallPlugins added in v0.3.0

func InstallPlugins() error

InstallPlugins finds and installs the plugins, as installPlugins does, for the process's Envs. The command's main calls it once, before NewEnv and before anything reads the configuration or the profile.

func Run

func Run(ctx context.Context, e *Env, args []string) int

Types

type Advice

type Advice struct{ Name, Info, Fix string }

Advice is one doctor line about a manager: what it is, why, and the fix.

type Briefing

type Briefing interface {
	BriefReady(ctx context.Context, u unit.Unit) (intake.Readiness, error)
	OpenIntakes(ctx context.Context) ([]intake.Intake, error)
}

Briefing tells the sweep whether a round's brief is ready and which intakes are open.

type Env

type Env struct {
	Out io.Writer
	Err io.Writer
	// In is the standard input profile add reads its text from.
	In io.Reader

	Git gitx.Git
	// Files is what removals read of the file system; nil reads it directly.
	Files workspaces.Files
	// WS is every enabled workspace manager, in the configured order.
	WS *workspace.Set
	// Sh runs the auxiliary commands of doctor, app install and clone.
	Sh func(ctx context.Context, name string, args ...string) ([]byte, error)
	// Stdout runs a command for its standard output alone.
	Stdout func(ctx context.Context, name string, args ...string) ([]byte, error)
	// Clipboard puts text on the clipboard; nil uses the system's.
	Clipboard func(text string) error

	LoadConfig func() (config.Config, error)
	// Languages are the system's preferred languages a serve shows its texts in when ui.locale is empty;
	// nil detects none, so texts read in English.
	Languages func() []string
	// IntentRecheck is how long the intent registry trusts the profile's stamp; zero rechecks on every read.
	IntentRecheck time.Duration
	// ViewDebounce is how long serve's view sinks gather wakes before they flush; zero is views.FlushDebounce.
	ViewDebounce time.Duration
	ConfigPath   string
	StateDir     string
	Home         string
	// HomeOverride is the session home a round by hand brings; nil reads
	// the caller's from Getenv.
	HomeOverride *string
	Now          func() time.Time
	Rec          Recorder
	// Rounds is the daemon's; a command line process has none.
	Rounds Rounds
	// Store, Turns and Views are the daemon's; a command line process has
	// none, and its rounds keep no turn.
	Store *inventory.Store

	Turns *turns.Service
	Views *views.Service
	// Briefing is the daemon's; nil sends every automatic round without
	// asking for its brief.
	Briefing Briefing

	// Socket is the daemon's; empty means no daemon is reachable.
	Socket string
	// Getenv reads the environment of the agent session that runs hook, turn
	// and instructions.
	Getenv func(string) string
	// Harness reads the hook payloads and the session identity of that session.
	Harness harness.Set
	// Executable is the binary the LaunchAgent runs.
	Executable string
	// ReinstallPlugins installs the plugins' vocabulary again once install
	// placed the release's, which the process read before it; nil skips it.
	ReinstallPlugins func() error

	// The native menu bar and the process exit; tests replace them.
	NativeAvailable func() bool
	// RunNative runs the app's native loop; setup's host is nil when the app
	// shows no window of its own.
	RunNative  func(win config.Window, words *texts.Catalog, setup func(menubar.Tray, menubar.Notifier, window.Host))
	QuitNative func()
	Exit       func(code int)
	// Reexec replaces this process with Executable, same arguments.
	Reexec func() error
	// Agents are the supported agents by name.
	Agents map[string]turns.Agent
	// Usage reads the tokens of each agent's turns by name; a kind
	// without one has no usage.
	Usage map[string]coreusage.Reader
	// Homes are the configuration homes of each agent by name.
	Homes map[string]setup.HomeKind
	// Managers are the supported workspace managers by name; nil keeps WS
	// whatever the config selects.
	Managers map[string]ManagerEntry
	// contains filtered or unexported fields
}

Env groups dependencies so commands can be tested without touching the real environment.

func NewEnv

func NewEnv() *Env

func (*Env) ReadAhead

func (e *Env) ReadAhead(ctx context.Context, ref pr.Ref, full bool) context.Context

ReadAhead reads ref's basics and the viewer and returns ctx carrying them, with those read ahead before, for the action that takes the loop lock next. With full, an open pull request with a review workspace, the one a held round reads in full, is also read in full into the inventory.

type ManagerEntry

type ManagerEntry struct {
	// Display names the manager in messages, such as "Orca".
	Display string
	// Binary is the manager's executable, as doctor looks it up on PATH; "" for none.
	Binary string
	// Control are the command prefixes and ControlPaths the paths that drive
	// the manager: no session the loop starts may run or read them.
	Control      [][]string
	ControlPaths []string
	// SessionVar is the variable the manager sets, in its sessions' agent
	// process, to the handle of the process.
	SessionVar string
	// Session reads the identity the manager gives a session from its environment.
	Session harness.SessionEnv
	// Sink is the view sink whose columns the manager's workspace statuses
	// are, "" for none; Columns are its default columns by semantic status.
	Sink    string
	Columns map[string]string
	New     func() workspace.Manager
	// Ports are the processes and sinks on ws; reloads ws starts on its own run under
	// ctx, and its changes are noted in changes, which may be nil.
	Ports func(ctx context.Context, ws workspace.Manager, prs prrow.ReportedPRs, cfg config.Config, changes *change.Log) (managerSessions, []views.Sink, error)
	// Homes lists agent homes the manager keeps for kind under userHome.
	Homes func(userHome, kind string) []string
	// Available is nil when the manager is installed and this release can
	// drive it, else why not; nil Available is always available.
	Available func(ctx context.Context) error
	// Advice is what doctor tells about an available manager that it cannot check.
	Advice []Advice
}

ManagerEntry is what the loop runs on one workspace manager.

type Recorder

type Recorder interface {
	Record(ctx context.Context, ev dinv.Event) error
	// RecordUnit is Record for an event on any unit.
	RecordUnit(ctx context.Context, ev port.Event) error
	Overrides(ctx context.Context) (map[pr.Ref]dinv.Override, error)
	// FirstRoundBlocks maps each unit whose round is blocked to its
	// round_blocked event.
	FirstRoundBlocks(ctx context.Context) (map[unit.Unit]port.Event, error)
	KeepNextGuidance(ctx context.Context, ref pr.Ref, guidance string) error
	TakeNextGuidance(ctx context.Context, ref pr.Ref) (string, error)
	// OpenQuestions maps each pull request to the intents whose newest turn
	// is asked.
	OpenQuestions(books map[unit.Unit]dturn.Book) map[pr.Ref]map[string]bool
}

Recorder receives the loop's own events; nil records nothing.

type Rounds

type Rounds interface {
	coresweep.Rounds
	Save(ctx context.Context, st *round.Store) error
	AgentHome(ctx context.Context, ref pr.Ref) (string, error)
	SetPause(ctx context.Context, p round.Pause) error
}

Rounds is the round state's repository and the pause, in the daemon's store.

type TestDaemon added in v0.5.0

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

TestDaemon is a daemon serve composed over a temporary home, with no collector, sweep loop or sender of its own: a test runs them with Sweep and Send.

func ServeForTest added in v0.5.0

func ServeForTest(t testing.TB, o TestOptions) *TestDaemon

ServeForTest serves, until t ends, the daemon's composition root over a store in a temporary directory, the plugins' publishers replaced by o.Publishers, and returns it.

func (*TestDaemon) Action added in v0.5.0

func (d *TestDaemon) Action(ctx context.Context, u unit.Unit, action string) (json.RawMessage, error)

Action runs action of u's plugin, running in the test daemon, as the host calls it, such as a read that keeps u in the store as the plugin's ingestion does.

func (*TestDaemon) Book added in v0.5.0

func (d *TestDaemon) Book(t testing.TB, u unit.Unit) dturn.Book

Book is u's turn book.

func (*TestDaemon) Client added in v0.5.0

func (d *TestDaemon) Client() *client.Client

Client is the daemon's client, as a person's clients speak to it.

func (*TestDaemon) EndTurn added in v0.5.0

EndTurn records the end of s's turn, as the agent's turn_end call does.

func (*TestDaemon) Launched added in v0.5.0

func (d *TestDaemon) Launched(t testing.TB, u unit.Unit) TestSession

Launched is the session the daemon last launched a turn of u in, as its workspace manager typed the turn's prompt there: the handle the scripted agent calls the daemon with, and u's newest turn.

func (*TestDaemon) Send added in v0.5.0

func (d *TestDaemon) Send(ctx context.Context) error

Send sends the approved drafts once, as the daemon's sender does.

func (*TestDaemon) Start added in v0.5.0

func (d *TestDaemon) Start(t testing.TB, u unit.Unit, intent string) TestSession

Start is a turn of intent on u that a new agent session started by hand, as a session asking for a round does.

func (*TestDaemon) Sweep added in v0.5.0

func (d *TestDaemon) Sweep(ctx context.Context) error

Sweep runs the workflows once, as the daemon's sweep does.

type TestOptions added in v0.5.0

type TestOptions struct {
	// Publishers stand, by provider, for the Publisher of the plugin module serve builds, pinned to their turns
	// as serve pins a plugin's; one that is a port.Basis reads its units' live basis.
	Publishers map[unit.ProviderID]port.Effects
	// Now is the daemon's clock; nil is a fixed instant.
	Now func() time.Time
	// Config edits the default configuration the daemon serves.
	Config func(*config.Config)
	// Repos are the repositories the test daemon's workspace manager holds, which a resumed or a new round's
	// workspace checks out; ProjectsDir is the configuration's projects_dir, a temporary one when empty.
	Repos       []wsdomain.Repo
	ProjectsDir string
	// Git runs the test daemon's git; nil runs none, and every git call fails.
	Git gitx.Runner
	// Plugins run, by plugin id, as serve runs that bundled plugin's process, such as the GitHub plugin over a
	// fake GitHub; a plugin left out does not run.
	Plugins map[string]src.Source
}

TestOptions are what ServeForTest puts in place of the outside world in the daemon serve composes.

type TestSession added in v0.5.0

type TestSession struct {
	Handle, Round string
	Unit          unit.Unit
}

TestSession is an agent session that runs a turn: the handle it calls the daemon with, and the turn's id.

Source Files

Jump to

Keyboard shortcuts

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