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 JoinPlanned(planOnly bool, root string) func(string) bool
- func JoinWaitPhrase(waits []string, planOnly bool) string
- func JoinWaits(t drivestore.Task, tasks []drivestore.Task, planned func(string) bool) []string
- func JoinWhat(planOnly bool) string
- func MarkFinished(root string, n int, match func(drivestore.Task) bool) error
- func OldNumber(token string) (int, bool)
- func PlanOnly(rec *drivestore.Record) bool
- func Proposes(args []string) (bool, error)
- func RefusePairs(flow, mode, after, base string) error
- func Renamed(old, now string) string
- func RowDone(t drivestore.Task) bool
- func SetFinished(t *drivestore.Task)
- func StoppedRun(r *state.Run) bool
- type BaseStanding
- type DriveArgs
- type DriveFlag
- type FlagValue
- type OnceArgs
- type PlanArgs
- type ResumeArgs
- 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, Proposal: true}, {Name: "--local", Alt: "--flow", Once: true, Proposal: true}, {Name: "--pace", Value: "NAME", Resume: true, Once: true, Proposal: true}, {Name: "--agent", Value: "PROFILE", Once: true, Proposal: true}, {Name: "--model", Value: "MODEL", Alt: "--agent", Once: true, Proposal: 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, Proposal: true}, {Name: "--resume", Value: "N", Resume: true, Tunes: true, Internal: 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.BatchEnv), ) 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 JoinPlanned ¶ added in v0.71.0
JoinPlanned is what JoinWaits takes for a batch. Under --plan it reports a base's plan saved under root. Otherwise it is nil, as the join waits for merges.
func JoinWaitPhrase ¶ added in v0.71.0
JoinWaitPhrase is what a waiting join is said to wait for, after the word waiting: "for A and B to merge". The ids come as the caller shows them.
func JoinWaits ¶ added in v0.71.0
func JoinWaits(t drivestore.Task, tasks []drivestore.Task, planned func(string) bool) []string
JoinWaits is a join's bases its batch's record has not seen through, nil for a task that is no join. A base outside the record was through when the batch started, since a join refuses any other. planned is non-nil for a --plan batch, whose join waits for saved plans, not merges.
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 OldNumber ¶ added in v0.71.0
OldNumber reads a token as a batch number, the old way to name a batch. A task id names it now, so a positive integer is read this way for one more release only.
one-release alias: a batch named by its number
func PlanOnly ¶ added in v0.71.0
func PlanOnly(rec *drivestore.Record) bool
PlanOnly reports a batch started with --plan: its record's field, or its command line for a record written before the field.
func Proposes ¶ added in v0.71.0
Proposes reports a command line asking for a proposal, which starts nothing: --propose asks for one, and --hint alone for its one line. --facts and --json alone are refused, because they shape a proposal nobody asked for.
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 Renamed ¶ added in v0.71.0
Renamed is the one line an old spelling prints on stderr, for the one release it still works. Every site that serves an old spelling carries the comment "one-release alias:", so one search finds what to remove.
func RowDone ¶
func RowDone(t drivestore.Task) bool
func SetFinished ¶
func SetFinished(t *drivestore.Task)
func StoppedRun ¶
Types ¶
type BaseStanding ¶ added in v0.71.0
type BaseStanding struct {
Finished bool // its code is in the default branch: this batch finished it, or it was finished before
Listed bool // the batch holds it, so the batch itself moves it on
Opened bool // a listed base has its worktree and its agent
Planned bool // its lead's plan is saved
}
A BaseStanding is what is known of one base of a join. Every reader of a join fills one from its own reads, and Through is the one rule over them.
func (BaseStanding) Through ¶ added in v0.71.0
func (b BaseStanding) Through(planOnly bool) bool
Through reports a base its join no longer waits for. A join waits for merges, and under --plan for saved plans instead. There a listed base must also have opened, because a dependent opened first finds no base branch. A base outside the batch needs only its plan, because nothing here opens it.
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
// Bases are each task's typed bases, indexed like tasks, nil for none.
// They are the entry before it in a chain, then each @base, as typed.
Bases [][]string
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 ParsePropose ¶ added in v0.71.0
ParsePropose reads a proposal's command line: ids or a parent, the start flags that shape the proposed command, and the proposal's own flags.
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
// Internal is set for a flag no user types: f10 resume, the API and the
// daemon's child pass it. No usage, help or refusal lists it.
Internal bool
// Proposal is set for a flag that shapes a start, which start --propose
// takes and carries onto the command it prints
Proposal 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 a resume takes to change a batch: 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 start flags to carry onto the proposed command
}
PlanArgs is `start --propose`'s own flags; the rest parse as a start's.
type ResumeArgs ¶ added in v0.71.0
type ResumeArgs struct {
Token string // "" for the one stopped batch
Flags []string // as typed, to put after --resume N
Fore bool
}
ResumeArgs is `f10 resume`'s command line. A task id names the batch, and for one more release so does its number.
func ParseResume ¶ added in v0.71.0
func ParseResume(args []string) (ResumeArgs, error)
ParseResume reads `f10 resume`'s arguments. It takes the flags --resume took, so the two never drift.
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 // ProposeStart prints a proposal for the tasks and starts nothing. ProposeStart )