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
- Variables
- func AppendFlags(argv []string, flags ...FlagValue) ([]string, error)
- func DriveNumber(s string) (int, error)
- func MarkFinished(root string, n int, match func(drivestore.Task) bool) error
- func RefusePairs(flow, mode, after, base string) error
- func RowDone(t drivestore.Task) bool
- func SetFinished(t *drivestore.Task)
- func StoppedRun(r *state.Run) bool
- type DriveArgs
- type DriveFlag
- type FlagValue
- type OnceArgs
- type PlanArgs
- type StartArgs
- type StartKind
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 = 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.
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.
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
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 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 RefusePairs ¶ added in v0.65.0
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 ¶
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 ParseDrivePlan ¶ added in v0.65.0
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 OnceFlagNamed ¶ added in v0.65.0
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
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.
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 )