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 ¶
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.
const DefaultEvery = 30 * time.Second
Variables ¶
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}, {Name: "--planned", Value: "ARGS", Tunes: true}, }
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 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 case info.Legacy || daemon.APIError(info, buildinfo.Version()) != nil: fmt.Fprintf(w, "watch: the f10 daemon runs %s: the next f10 drive 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 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 MarkFinished ¶
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 ¶
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>`
Planned string // --planned: the planning arguments this command was agreed from
Plan *PlanArgs
// contains filtered or unexported fields
}
DriveArgs is the command line, parsed by hand so `--` survives.
func ParseDriveArgs ¶
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 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 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
Key string // the planning arguments, as --planned records them
}
PlanArgs is `drive plan`'s own flags; the rest parse as a drive's.