drivectl

package
v0.68.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 21 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 drivectl is a drive's record as other commands use it: the arguments a drive started with, a task's row marked finished, and the watcher asked to take a project on.

Index

Constants

View Source
const (
	RowFinished        = "finished"
	RowAlreadyFinished = "already finished"
)

The rows a finished task ends on: finished by the drive or outside it, or found finished when the drive started.

View Source
const DefaultEvery = 30 * time.Second

Variables

View Source
var DriveFlags = slices.DeleteFunc(slices.Clone(StartFlags), func(f DriveFlag) bool { return f.OnceOnly })

DriveFlags are the flags a flow start takes: StartFlags less the ones only a discussion or a pickup takes.

View Source
var StartFlags = []DriveFlag{
	{Name: "--flow", Value: "NAME", Once: true},
	{Name: "--local", Alt: "--flow", Once: true},
	{Name: "--pace", Value: "NAME", Resume: true, Once: true},
	{Name: "--agent", Value: "PROFILE", Once: true},
	{Name: "--model", Value: "MODEL", Alt: "--agent", Once: true},
	{Name: "--plan", Once: true},
	{Name: "--after", Value: "TASK-ID", Once: true},
	{Name: "--base", Value: "BRANCH", Alt: "--after", Once: true},
	{Name: "--answer", Value: "[ID=]TEXT", Resume: true, Tunes: true, Many: true},
	{Name: "--every", Value: "DURATION", Resume: true, Tunes: true},
	{Name: "--parallel", Value: "N", Resume: true, Tunes: true},
	{Name: "--resume", Value: "N", Resume: true, Tunes: true},
	{Name: "--foreground", Resume: true, Tunes: true},
	{Name: "--discuss", Once: true, OnceOnly: true},
	{Name: "--task", Value: "TASK-ID", Once: true, OnceOnly: true},
}

StartFlags is every flag f10 start takes.

View Source
var WatchProject = func(ctx context.Context, w io.Writer, t *target.Target) {
	if !daemon.Supported || t.Effective.Watch == "off" {
		return
	}

	ctx, cancel := context.WithTimeout(ctx, watchHandWait)
	defer cancel()

	dir := daemon.RunDir()

	info, err := daemon.Hello(ctx, dir, buildinfo.Version())

	switch {
	case err == nil && info.Stopping:
		fmt.Fprintln(w, "watch: the f10 daemon is stopping: the next f10 start hands this project over")

		return
	case errors.Is(err, daemon.ErrNotRunning):
		if _, err := (&daemon.Ensurer{Dir: dir, Version: buildinfo.Version()}).Ensure(ctx); err != nil {
			fmt.Fprintf(w, "watch: warning: %v\n", err)

			return
		}
	case err != nil:
		fmt.Fprintf(w, "watch: warning: %v\n", err)

		return
	case info.Legacy || daemon.APIError(info, buildinfo.Version()) != nil:

		fmt.Fprintf(w, "watch: the f10 daemon runs %s: the next f10 start replaces it and hands this project over\n",
			info.Version)

		return
	}

	_, err = daemon.WatchProject(
		ctx,
		dir,
		t.Layout.StorageRoot.Path(),
		cmp.Or(t.Layout.MainRoot, t.Layout.CheckoutRoot),
		daemon.DriveEnv(os.Environ(), t.Effective.DriveEnv),
	)
	if err != nil {
		fmt.Fprintf(w, "watch: warning: %v\n", err)
	}
}

WatchProject hands the project to this user's daemon, starting one when none runs. It never replaces or waits out a running daemon (f10 start's job, which can tell the user), and an error is one warning, never a failed command. A variable so tests start no daemon.

Functions

func AppendFlags added in v0.65.0

func AppendFlags(argv []string, flags ...FlagValue) ([]string, error)

AppendFlags appends flags to argv in the order given, each checked against StartFlags, so a caller building a start from fields keeps no table of its own. The order is the caller's because the drive record's key is the command line as written, and a rerun attaches to its drive by that key.

func DriveNumber

func DriveNumber(s string) (int, error)

func MarkFinished

func MarkFinished(root string, n int, match func(drivestore.Task) bool) error

MarkFinished moves drive n's open rows that match to finished, under the drive's own lease: a held one is a running drive, which owns its record, so nothing is written. A row only ever moves to finished, since only a rerun knows a drive's next step for a halt settled halfway.

func RefusePairs added in v0.65.0

func RefusePairs(flow, mode, after, base string) error

RefusePairs refuses the exclusive pairs every start shares, worded once: a mode that stops before ship beside a flow, and a base given two ways.

func RowDone

func RowDone(t drivestore.Task) bool

func SetFinished

func SetFinished(t *drivestore.Task)

func StoppedRun

func StoppedRun(r *state.Run) bool

Types

type DriveArgs

type DriveArgs struct {
	Tasks    []string // as typed, any :profile cut off; with span, the two ends of a range
	Profiles []string // each task's :profile as typed, indexed like tasks, "" for none
	Agent    string   // --agent as typed, or --model as a model-only profile: every task's unless its own names one

	Span     bool
	Flow     string   // --flow, or local for --local; "" for default
	Pace     string   // --pace, "" for the branch's or the project's
	Answers  []string // each --answer as typed: `GH-1=text` for one task, or bare text
	Every    time.Duration
	Parallel int    // --parallel: the cap on tasks running a skill at once, 0 for the record's or the default
	Resume   int    // --resume: the record to pick up
	Fore     bool   // --foreground: run the loop in this process, not the daemon
	PlanOnly bool   // --plan: every task is planned and none implemented
	After    string // --after: the one task's base task, over its body's After: line
	Base     string // --base: the one task's base branch
	Plan     *PlanArgs
	// contains filtered or unexported fields
}

DriveArgs is the command line, parsed by hand so `--` survives.

func ParseDriveArgs

func ParseDriveArgs(args []string) (DriveArgs, error)

func ParseDrivePlan added in v0.65.0

func ParseDrivePlan(args []string) (DriveArgs, error)

ParseDrivePlan reads `drive plan`'s arguments after the word plan: ids or a parent, the drive flags that shape the proposed command, and the plan's own flags. f10 start never parses them, so `f10 start plan` is a task word.

type DriveFlag

type DriveFlag struct {
	Name  string
	Value string // the value's word in the usage, "" for a switch
	// Alt is the flag this one is the other form of, shown as one choice
	Alt string
	// Resume is set when --resume takes the flag: it names none of the
	// drive's tasks, flow or agent profiles
	Resume bool
	// Tunes is set when the flag changes how a drive runs, not what it runs,
	// so a record is matched without it
	Tunes bool
	Many  bool // given once per value
	// Once is set when a discussion or a PR pickup takes the flag too
	Once bool
	// OnceOnly is set for a flag only a discussion or a pickup takes
	OnceOnly bool
}

A DriveFlag is one of start's flags. Every parse of start's command line reads StartFlags, so a new flag is one row. A flow start reads it through DriveFlags, and a discussion or a pickup through the rows marked Once.

func DriveFlagNamed

func DriveFlagNamed(name string) (DriveFlag, bool)

func OnceFlagNamed added in v0.65.0

func OnceFlagNamed(name string) (DriveFlag, bool)

OnceFlagNamed is the row of a flag a discussion or a pickup takes.

func ResumeTunes

func ResumeTunes() []DriveFlag

ResumeTunes are the flags --resume N takes to change a drive: the ones that tune it and take a value.

type FlagValue added in v0.65.0

type FlagValue struct{ Name, Value string }

A FlagValue is one flag a caller builds a start from: a switch when its value is "true", else the name and the value, and left out when empty.

type OnceArgs added in v0.65.0

type OnceArgs struct {
	Mode  string   // launch.ModeDiscuss, launch.ModePlan, or "" for a pickup that ships
	Token string   // the first id, or the PR
	Tasks []string // a discussion's other ids
	Note  string
	Flow  string
	Pace  string
	After string
	Base  string
	Task  string // the task a picked-up PR is for
	Agent string
	Model string
}

OnceArgs is a discussion's or a pickup's command line.

type PlanArgs added in v0.61.0

type PlanArgs struct {
	Facts string   // --facts: the facts sheet the skill wrote
	JSON  bool     // --json
	Hint  bool     // --hint: one line, or nothing
	Pass  []string // the drive flags to carry onto the proposed command
}

PlanArgs is `drive plan`'s own flags; the rest parse as a drive's.

type StartArgs added in v0.65.0

type StartArgs struct {
	Kind  StartKind
	Once  OnceArgs  // a discussion's, a pickup's, or a MaybePickup's
	Drive DriveArgs // a flow start's
	// contains filtered or unexported fields
}

StartArgs is start's command line, parsed once: its kind, and the arguments of that kind.

func ParseStart added in v0.65.0

func ParseStart(argv []string) (StartArgs, error)

ParseStart reads start's command line. --discuss, --task or a first word naming a PR make a one-shot start. Anything else is a flow start, which takes ids, a range and the drive's flags.

func (StartArgs) Flow added in v0.65.0

func (s StartArgs) Flow() (DriveArgs, error)

Flow is the command line read as a flow start, for a MaybePickup the host named a task.

type StartKind added in v0.65.0

type StartKind int

StartKind is what a start's command line runs.

const (
	// FlowStart runs tasks through their flow in a drive.
	FlowStart StartKind = iota
	// DiscussStart opens one agent that reads the tasks and waits.
	DiscussStart
	// PickupStart picks up a PR named by url, by !n, or with --task.
	PickupStart
	// MaybePickup is a bare #n, a PR or a task: the host decides, and a
	// task runs as FlowStart.
	MaybePickup
)

Jump to

Keyboard shortcuts

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