start

package
v0.70.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 37 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 start opens a task: its checkout, its workspace and its agent, prompted, or a PR picked up to continue.

Index

Constants

This section is empty.

Variables

View Source
var ClosedStart = func(ctx context.Context, t *target.Target, ids []string) []string {
	return closedCheckFor(t).all(ctx, ids)
}

ClosedStart is the labels of the closed tasks when the start should open a discussion instead, else nil. It switches when every task is closed with no branch, or when a bundle has a closed member, because the drive judges a bundle by its lead and would ship that member again. A failed read counts as open, so the check never blocks a start. A var, so a test of a caller fakes the tracker's answer.

Functions

func AfterFromBody

func AfterFromBody(ctx context.Context, tr stack.Tracker, main string, task ref.Ref) (string, []string, error)

AfterFromBody reads the task's body for an After: line. A body that cannot be read is a note, never a refusal: --after stays the explicit way.

func AgentArgs

func AgentArgs(p agentctl.Profile, root storage.Root, worktree string) []string

AgentArgs is the agent's command line: the profile's flags through its kind, and each task-file dir of the storage root when that root sits outside the worktree, so writing plans and findings there asks no permission.

func Discussing added in v0.64.0

func Discussing(ctx context.Context, t *target.Target) (string, error)

Discussing is the branch of t's checkout when a discussion opened it, else "": a start run there hands the worktree on.

func FetchPickup

func FetchPickup(ctx context.Context, main string, pick *hostops.Pickup) error

FetchPickup: a handover has not fetched the request's branch yet. A landed request's commit must be here before its worktree is made, and a closed request's head comes only through the host's own ref for it.

func LaunchArgs added in v0.68.0

func LaunchArgs(p agentctl.Profile, root storage.Root, worktree string, driven bool) []string

LaunchArgs is AgentArgs for a launch, marked as a drive's when driven: the mark goes first, because --add-dir takes every argument after it.

func MarkStarted

func MarkStarted(ctx context.Context, started func(context.Context, ref.Ref) error, task ref.Ref) []string

MarkStarted moves every member to its started status. The worktree is the result, so a failure is a note, never a refusal.

func PickedTask

func PickedTask(prefix string, hostIssues bool, pick *hostops.Pickup, pr forge.PR, task string) (string, error)

PickedTask is the task id for a picked-up PR: --task, else the one the PR names. A PR naming none exits with ui.ExitDeclined, which the start skill turns into a question; --task with no PR is a refusal.

func PickupFor

func PickupFor(ctx context.Context, t *target.Target, token string) (*hostops.Pickup, forge.PR, error)

PickupFor is the PR the start argument names, or nil for a task id; a bare #n the host knows as no PR is a task id.

func RefuseFlags added in v0.62.0

func RefuseFlags(req Request) error

RefuseFlags refuses the exclusive pairs before anything is looked up.

func RefuseLandedPlan added in v0.62.0

func RefuseLandedPlan(mode string, pick *hostops.Pickup) error

RefuseLandedPlan stops --plan on a merged or closed PR: its diff is no starting point once it landed, and going on from it is a task of its own.

func RefuseNote added in v0.62.0

func RefuseNote(mode string, pick *hostops.Pickup, note string) error

RefuseNote stops a note no prompt can carry: only the prompts that stop and wait are plain text, and a driven chain's arguments belong to its skills.

func RefusePickupFlags added in v0.62.0

func RefusePickupFlags(flow, after, base string) error

RefusePickupFlags stops the flags a picked-up PR has no use for: its branch and base are the PR's, and nobody ships someone else's PR unread.

func RefuseStalled

func RefuseStalled(in StallCheck, ws *agentctl.Workspace, agent, root string) error

RefuseStalled stops a drive's prompt to an agent idle while its run says running: it may sit on a permission dialog, and a new skill prompt typed there could answer it. Forward reads the screen instead (forwardReady).

func Start

func Start(ctx context.Context, w io.Writer, in StartInput) error

Start runs the flow: the checkout and its agent, the prompt, the report. A workspace Herdr already showed keeps its agent, and nothing is prompted twice; one left with no agent gets its agent and its prompt.

func StartedMove

func StartedMove(t *target.Target) func(context.Context, ref.Ref) error

StartedMove moves a task to tracker.status's started word, or is nil when none is declared.

func SwitchNote added in v0.65.0

func SwitchNote(labels, dropped []string, profile string) string

SwitchNote is the line a start that became a discussion prints, naming the flags a discussion has no use for.

func WriteLaunched added in v0.62.0

func WriteLaunched(ctx context.Context, w io.Writer, in StartInput, l Launched) error

WriteLaunched is start's report on l.

Types

type ForwardInput added in v0.62.0

type ForwardInput struct {
	Main     string                // the main checkout: worktrees are its siblings
	Here     string                // the checkout the caller answers for: a task here is not forwarded
	Driver   *trackerdriver.Driver // nil without one
	Task     ref.Ref
	Suffix   string
	Text     string        // what the agent is told, before the marker
	StateDir string        // where run state lives, for the note on where the text lands
	Ttl      time.Duration // how long a run counts as live
	Now      time.Time
	Since    time.Time // runs last updated before it are not read: the agent that wrote them is gone
}

ForwardInput is everything forward needs once the target is settled, so the flow can be tested without a checkout.

type Forwarded added in v0.62.0

type Forwarded struct {
	Workspace string
	Sent      string
	Note      string
}

Forwarded is where a forward went: the workspace, the text as sent, and the notes: where the text lands and what the Enter check saw.

func Forward added in v0.62.0

func Forward(ctx context.Context, in ForwardInput) (Forwarded, error)

Forward hands text to the agent working on in.Task in another checkout. Every refusal comes before the one thing that leaves this process.

func ForwardReport added in v0.62.0

func ForwardReport(ctx context.Context, w io.Writer, in ForwardInput) (Forwarded, error)

ForwardReport hands the text on and reports where it went, as f10 forward prints it.

type HandOver added in v0.64.0

type HandOver struct {
	Main, Path string // the main checkout, and the discussion's worktree
	Branch     string // the discussion's branch
	Task       ref.Ref
	Suffix     string
	Name       string // the branch name a start for Task gives
	Tracker    stack.Tracker
}

A HandOver is a discussion's worktree given to the first group of the start that ends it: the branch and the agent take the lead's names, so the drive finds both as that task's.

func PrepareHandOver added in v0.64.0

func PrepareHandOver(ctx context.Context, t *target.Target, branch, first string) (HandOver, error)

PrepareHandOver settles the hand-off of the discussion's branch to the start's first token; every refusal happens here, before anything moves.

func (HandOver) Run added in v0.64.0

func (h HandOver) Run(ctx context.Context) ([]string, func(context.Context) error, error)

Run renames the agent, the workspace and then the branch, and records the group's lead. A failure puts back what it changed; the returned func undoes the whole hand-off, for a drive the daemon refuses.

type LandedLookup added in v0.67.0

type LandedLookup func(ctx context.Context, branch string) (forge.PR, bool, error)

A LandedLookup is the request that decides branch (forge.Deciding), when it is merged or closed, and false when there is none or one is open.

func LandedFor added in v0.67.0

func LandedFor(t *target.Target) LandedLookup

LandedFor is LandedVia on the target's host, nil with no host CLI, which skips the check: start --plan runs without one.

func LandedVia added in v0.67.0

func LandedVia(h forge.Host) LandedLookup

LandedVia asks the host which request decides the head: an open one means the branch is in use, whatever landed on it before.

type Launched added in v0.62.0

type Launched struct {
	OpenedTask

	Agent string
}

Launched is a started task: what OpenTask opened, and the agent that works on it.

func Launch added in v0.62.0

func Launch(ctx context.Context, in StartInput) (Launched, error)

Launch opens the task and prompts its agent when the open was fresh.

type OpenedTask

type OpenedTask struct {
	Task   ref.Ref // the task, with the riders its branch ships
	Branch string
	Path   string
	Ws     agentctl.Opened
	Dep    *launch.Dependency
	Plan   string // the task's plan the worktree reads, or "" when none was saved or no agent was started
	Fresh  bool
	// NewBranch says this start created the branch, so nothing rooted at
	// its path (a run state, a record) is a turn on it
	NewBranch bool
	Notes     []string
	// Profile is what the agent was started on, when fresh; a report names
	// it when it is not the kind's default
	Profile agentctl.Profile
	// contains filtered or unexported fields
}

An OpenedTask is what OpenTask leaves behind; fresh says this call is to start the agent, which deliver does with its first prompt.

func OpenTask

func OpenTask(ctx context.Context, in StartInput) (OpenedTask, error)

OpenTask runs everything start does short of starting and prompting the agent, which deliver does with the first text. Every lookup that can refuse runs before the first thing is created, the worktree; drive adopts main's plan too but prompts the agent itself, skill by skill.

func (*OpenedTask) Deliver

func (o *OpenedTask) Deliver(ctx context.Context, id, suffix, text string) (string, bool, error)

Deliver sends text to the task's agent, starting it when its launch is pending: on its command line when the kind takes a first prompt, else typed right after. It names the agent that took the text, and typed says the text went through the input box, where its Enter can be lost.

type Request added in v0.62.0

type Request struct {
	Token string // the task id, with an optional suffix, or a PR url or #n
	Mode  string // "" ships; launch.ModePlan or launch.ModeDiscuss stop earlier
	Flow  string
	Pace  string
	After string // the task this one builds on
	Base  string // a branch to start from
	Task  string // the task a picked-up PR is for
	Agent string
	Model string
	Note  string
	Also  []string // the other tasks a discussion covers, after Token
}

A Request is a start as its caller words it: the task or PR, how far the agent runs, and the flow, pace, base and agent profile, any of them empty.

type StallCheck

type StallCheck struct {
	StateDir   string
	Ttl        time.Duration
	Now, Since time.Time
}

A StallCheck is what RefuseStalled reads run state with: runs updated before since were written by an agent that is gone.

type StartInput

type StartInput struct {
	Main     string                // the main checkout: worktrees are its siblings
	Driver   *trackerdriver.Driver // nil without one
	Task     ref.Ref
	Suffix   string
	Mode     string
	Flow     runplan.ShipFlow                      // the flow ship runs; zero for default
	FlowKept bool                                  // drive records the flow and the pace itself, keeping what the branch has
	Driven   bool                                  // a drive runs the agent, so its hooks are marked (launch.DrivenEnv)
	Pace     string                                // the --pace typed, recorded on the branch; "" records none
	After    string                                // task id whose branch is the base and whose plan is the contract, or ""
	Base     string                                // branch whose ref is the base, or ""
	Storage  storage.Root                          // the storage root every checkout shares
	Title    func(context.Context) (string, error) // the task's title, for the default branch's slug; nil when nothing answers
	Notes    []string                              // notes settled before the flow, printed beneath the report
	// Profile is what the agent starts on, resolved; profileFlagged says a
	// flag chose it, which wins over the profile the branch recorded
	Profile        agentctl.Profile
	ProfileFlagged bool
	Progress       io.Writer       // where a wait in progress is reported, or nil for nowhere
	Pick           *hostops.Pickup // the PR picked up, or nil for a task started by its id
	Note           string          // the user's words after the id, for the agent before it waits, or ""
	// Discussion is what a discussion of a parent or of several tasks
	// covers, nil for any other start
	Discussion *launch.Discussion
	// Closed is the discussed tasks the tracker already closed, each with
	// what shipped it
	Closed []launch.Closed
	// Started moves a task to tracker.status's started word; nil when none
	// is declared, or for a PR picked up, whose task someone else started
	Started func(ctx context.Context, task ref.Ref) error
	// Landed reads the landed request a branch name was the head of. Nil
	// skips the check.
	Landed LandedLookup
}

StartInput is everything start needs once the target is settled, so the flow can be tested without a checkout.

func Prepare added in v0.62.0

func Prepare(ctx context.Context, t *target.Target, req Request) (StartInput, error)

Prepare settles everything a start needs before anything is created: every refusal a request can meet happens here.

type Switch added in v0.65.0

type Switch struct {
	Note  string // what the user is told first
	Token string
	Tasks []string // the other ids, after Token
	After string
	Base  string
	Agent string
}

A Switch is a flow start turned into a discussion, because every task it names is closed.

func ClosedSwitch added in v0.65.0

func ClosedSwitch(ctx context.Context, t *target.Target, a drivectl.DriveArgs) *Switch

ClosedSwitch is the discussion the flow start a becomes when every task it names is closed, nil otherwise. The CLI and the API both call it, so the switch reads one way wherever a start comes from. A resume, a range or an answer goes on with a drive already agreed, so it is never switched. The daemon's own drive process is not switched either, because its caller already checked.

Jump to

Keyboard shortcuts

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