Help us shape the future of Go! Take the 2026 Go Developer Survey

factoryplan

package
v0.7.225 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package factoryplan backs the planning screen with factory: the plan and its comments in factory's V3 API (Store), and the long-lived factory session that plans it (Agent).

Index

Constants

This section is empty.

Variables

View Source
var ErrDesignApproved = errors.New("the plan's design is approved already: approve the plan with ctrl+s")

ErrDesignApproved is returned by ApproveDesign for a plan whose flow offers to approve the plan but not its design: the design is approved already.

View Source
var ErrNoUnits = errors.New("the plan has no units yet: approve its design with ctrl+s, so chunk writes them")

ErrNoUnits is returned by Approve for a plan in plan.ReadyState whose design, not the plan, is what waits for approval, as plan.StageOf decides.

View Source
var ErrNotReady = errors.New("the plan is not ready yet: wait for its review to pass")

ErrNotReady is returned by Approve for a plan whose review has not passed: factory has not moved it to plan.ReadyState.

View Source
var ErrQuestionsOpen = errors.New("the plan has open questions: answer 3. Open Questions in comments, then send them")

ErrQuestionsOpen is returned by Approve and ApproveDesign for a plan whose flow offers neither approval, as plan.StageOf decides: its 3. Open Questions wait for answers in comments, sent before either is approved.

View Source
var ErrStopped = errors.New("the planning session has been stopped")

ErrStopped is returned by a Send after Stop.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

Agent is a plan.Agent over a long-lived factory.Agent. The session starts on the first Send, since claude needs a message to start on, and is resumed by the next Send if it ends without being stopped.

func NewAgent

func NewAgent(ctx context.Context, cfg factory.AgentConfig, store *Store) *Agent

NewAgent is the planning session for store's plan, in cfg.Dir, which lives as long as ctx. The caller must Stop it.

func (*Agent) CheckStart

func (p *Agent) CheckStart(check func(context.Context) error)

CheckStart has check run before the session starts or resumes, refusing to start it when check fails, so a plan can be opened and read before what planning needs is in place. It must be called before the first Send.

func (*Agent) Events

func (p *Agent) Events() <-chan plan.Event

func (*Agent) Send

func (p *Agent) Send(ctx context.Context, message string) error

Send delivers message to the session, starting it on the first message and resuming it if it has ended. A message tells the agent to claim the plan when it is the first since the plan was created, or the agent has since lost its claim: factory frees the claims of a session that ends, and an agent can release its plan, after which the daemon hands it no tasks.

func (*Agent) SessionID

func (p *Agent) SessionID() string

SessionID is the factory session the agent claims its plan as: the one recorded as planning the plan on this machine, once a Send has opened the record, so a plan reopened in a new screen is planned by the same session.

func (*Agent) Stop

func (p *Agent) Stop() error

Stop ends the session, if one started, and waits for it. A session still starting is stopped by the Send starting it, once it has started.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a plan.Store backed by factory's V3 plan and comment API, addressed by the plan's ID, which Create sets.

func NewStore

func NewStore(api *circleci.Client, id string) *Store

NewStore is the store for plan id in factory, or for a plan Create makes when id is "".

func (*Store) AddComment

func (s *Store) AddComment(ctx context.Context, quote, body string) (plan.Comment, error)

func (*Store) AddressComments

func (s *Store) AddressComments(ctx context.Context) error

AddressComments sends the plan's flow factory's address-comments event, which moves it out of a Human state at its next poll.

func (*Store) Approve

func (s *Store) Approve(ctx context.Context, session string) error

Approve approves the plan for factory to build, once its review has passed, with the approve-for-building event. The planning session, session, may not edit files, so its claim is released first, for a build session to claim the plan instead. The state and text are read from factory, not the screen's copy, so a plan that moved after the screen last polled is still refused.

func (*Store) ApproveDesign

func (s *Store) ApproveDesign(ctx context.Context) error

ApproveDesign sends the plan's flow factory's approve-for-units event, which approves its design. A flow that does not list the event now is refused without sending it: with ErrDesignApproved when it lists approve-for-building instead, and with ErrQuestionsOpen when it lists neither. A plan with no flow yet sends it.

func (*Store) Comments

func (s *Store) Comments(ctx context.Context) ([]plan.Comment, error)

func (*Store) Create

func (s *Store) Create(ctx context.Context, message string) error

func (*Store) DeleteComment

func (s *Store) DeleteComment(ctx context.Context, id string) error

func (*Store) EditComment

func (s *Store) EditComment(ctx context.Context, id, body string) error

func (*Store) Flow

func (s *Store) Flow(ctx context.Context) (plan.Flow, error)

Flow is the plan's flow as factory has it now; empty before the plan is created or has a flow.

func (*Store) Holder

func (s *Store) Holder(ctx context.Context) (string, error)

Holder is the factory session holding the plan's claim, as its flow references it, or "" when none does or the plan has not been created.

func (*Store) ID

func (s *Store) ID() string

ID is the plan's ID in factory, or "" before Create.

func (*Store) ResolveComment

func (s *Store) ResolveComment(ctx context.Context, id string) error

func (*Store) ResolveConflicts

func (s *Store) ResolveConflicts(ctx context.Context) error

ResolveConflicts sends the plan's flow factory's resolve-conflicts event, which hands a plan whose PR conflicts back to the agent to rebase.

func (*Store) SetText

func (s *Store) SetText(ctx context.Context, text string) error

func (*Store) State

func (s *Store) State(ctx context.Context) (string, error)

State is the plan's flow state; "" before the plan is created, or when it has no flow.

func (*Store) Text

func (s *Store) Text(ctx context.Context) (string, error)

Jump to

Keyboard shortcuts

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