drivectl

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 17 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 = []DriveFlag{
	{Name: "--flow", Value: "NAME"},
	{Name: "--local", Alt: "--flow"},
	{Name: "--pace", Value: "NAME", Resume: true},
	{Name: "--agent", Value: "PROFILE"},
	{Name: "--model", Value: "MODEL", Alt: "--agent"},
	{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},
}
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()

	rep, err := daemon.Call(ctx, dir, daemon.Request{Op: daemon.OpHello}, 0)

	switch {
	case err == nil && rep.Stopping:
		fmt.Fprintln(w, "watch: the f10 daemon is stopping: the next f10 start or f10 drive 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
	}

	_, err = daemon.Call(ctx, dir, daemon.Request{
		Op:   daemon.OpWatch,
		Root: t.Layout.StorageRoot.Path(),
		Dir:  cmp.Or(t.Layout.MainRoot, t.Layout.CheckoutRoot),
		Env:  daemon.DriveEnv(os.Environ(), t.Effective.DriveEnv),
	}, 0)
	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 drive'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 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 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
	List     bool // `drive list`
	All      bool // `drive list --all`
	Cancel   int  // `drive cancel <n>`
	// contains filtered or unexported fields
}

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

func ParseDriveArgs

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

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
}

A DriveFlag is one of drive's flags. The parser, its refusals, the record match and the usage line all read DriveFlags, so a new flag is one row.

func DriveFlagNamed

func DriveFlagNamed(name string) (DriveFlag, bool)

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.

Jump to

Keyboard shortcuts

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