Documentation
¶
Overview ¶
Package planreview coordinates the explicit plan-mode decisions surfaced to the user: the enter approval and the exit review.
Index ¶
- Variables
- func ValidDecision(kind Kind, decision Decision) bool
- func ValidateRequest(request Request) error
- func ValidateResolution(request Request, resolution Resolution) error
- func ValidateResolutionShape(kind Kind, resolution Resolution, requestID string) error
- type Controller
- func (c *Controller) BeforeTool(_ context.Context, info agent.ToolCallInfo) agent.ToolDecision
- func (c *Controller) Catalog() (*catalog.Catalog, error)
- func (c *Controller) Pending() *Request
- func (c *Controller) Reconcile(ctx context.Context, pending []ai.ToolCallPart) (*Request, error)
- func (c *Controller) Resolve(resolution Resolution) (Outcome, error)
- type Decision
- type Kind
- type Outcome
- type Request
- type Resolution
- type Resolver
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalid means a request or resolution violates the plan review protocol. ErrInvalid = errors.New("coding plan review: invalid value") // ErrNoPending means no plan decision is waiting for a resolution. ErrNoPending = errors.New("coding plan review: no pending request") // ErrMismatch means a resolution does not identify the pending request exactly. ErrMismatch = errors.New("coding plan review: request mismatch") )
Functions ¶
func ValidDecision ¶
ValidDecision reports whether one decision is well-formed for a request kind. It validates the shape only; comments and notes are bounded by ValidateResolutionShape.
func ValidateRequest ¶
ValidateRequest verifies a request's deterministic identity and bounds.
func ValidateResolution ¶
func ValidateResolution(request Request, resolution Resolution) error
ValidateResolution verifies one decision against the exact pending request.
func ValidateResolutionShape ¶
func ValidateResolutionShape(kind Kind, resolution Resolution, requestID string) error
ValidateResolutionShape verifies bounded fields for one request kind.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller owns the enter/exit plan-mode pause protocol.
func NewController ¶
func NewController( store *planmode.Store, service Service, resolver Resolver, ) (*Controller, error)
NewController constructs one plan-mode decision coordinator.
func (*Controller) BeforeTool ¶
func (c *Controller) BeforeTool(_ context.Context, info agent.ToolCallInfo) agent.ToolDecision
BeforeTool turns enter/exit calls into pauses and rejects malformed calls.
func (*Controller) Catalog ¶
func (c *Controller) Catalog() (*catalog.Catalog, error)
Catalog returns both local plan-mode tool registrations.
func (*Controller) Pending ¶
func (c *Controller) Pending() *Request
Pending reports the currently displayed request, when any.
func (*Controller) Reconcile ¶
func (c *Controller) Reconcile(ctx context.Context, pending []ai.ToolCallPart) (*Request, error)
Reconcile reconstructs a pending plan-mode decision from the first durable pending call. The exit request reads the plan file from disk; content is never taken from tool arguments.
func (*Controller) Resolve ¶
func (c *Controller) Resolve(resolution Resolution) (Outcome, error)
Resolve persists the exact decision and reports the outcome to the runtime.
type Decision ¶
type Decision string
Decision is the user's explicit disposition of a plan-mode request.
const ( // DecisionApprove accepts the exit revision (or approves entering plan mode). DecisionApprove Decision = "approve" // DecisionDecline refuses to enter plan mode. DecisionDecline Decision = "decline" // DecisionRevise sends the plan back for another revision. DecisionRevise Decision = "revise" // DecisionQuit abandons the plan and turns plan mode off. DecisionQuit Decision = "quit" )
Plan-mode decisions.
type Kind ¶
type Kind string
Kind distinguishes the two plan-mode decisions.
type Request ¶
type Request struct {
Kind Kind `json:"kind"`
ID string `json:"id"`
ToolCallID string `json:"tool_call_id"`
Content string `json:"content,omitempty"`
HasContent bool `json:"has_content"`
Size int64 `json:"size"`
}
Request is one content-bound plan-mode decision identity. The plan content is read from disk when the request is created; it is never passed as a tool argument.
func CloneRequest ¶
CloneRequest returns an independent request value.
type Resolution ¶
type Resolution struct {
RequestID string `json:"request_id"`
Decision Decision `json:"decision"`
Comments []string `json:"comments,omitempty"`
Notes string `json:"notes,omitempty"`
}
Resolution is one exact user decision for a pending request.
func CloneResolution ¶
func CloneResolution(resolution Resolution) Resolution
CloneResolution returns an independent resolution value.
type Resolver ¶
type Resolver interface {
ResolveToolCalls(...agent.ToolResolution) error
}
Resolver durably records one result for a paused Tool call.
type Service ¶
type Service interface {
// PlanState reports the current plan-mode state.
PlanState() planmode.State
// EnterPlanMode executes an enter_plan_mode call that needs no approval.
EnterPlanMode(context.Context) (string, error)
// ExitPlanMode executes an exit_plan_mode call in a state without a gate.
ExitPlanMode(context.Context) (string, error)
}
Service exposes the runtime-owned plan-mode state and direct tool execution to the controller.