plan

package
v0.0.362 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package plan owns the shared update_plan snapshot model, validation, history extraction, and bounded rendering helpers.

Index

Constants

View Source
const (
	// ToolName is the model-facing name of the execution plan snapshot tool.
	ToolName = "update_plan"

	MaxSteps            = 20
	MaxStepRunes        = 240
	MaxExplanationRunes = 500
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Snapshot

type Snapshot struct {
	Explanation string `json:"explanation,omitempty"`
	Plan        []Step `json:"plan"`
}

Snapshot is the complete model-controlled update_plan state. Every tool call replaces the previous snapshot atomically.

func LatestSuccessfulSnapshot

func LatestSuccessfulSnapshot(messages []llm.Message) (Snapshot, bool)

LatestSuccessfulSnapshot extracts the newest valid update_plan call with a matching successful tool result from active message history.

func Parse

func Parse(raw json.RawMessage) (Snapshot, error)

Parse decodes, normalizes, and validates a complete update_plan snapshot.

func (Snapshot) CanonicalJSON

func (s Snapshot) CanonicalJSON() ([]byte, error)

CanonicalJSON returns a stable JSON representation of a valid snapshot.

func (Snapshot) ChecklistText

func (s Snapshot) ChecklistText(running bool) string

ChecklistText formats a valid snapshot for transcript and terminal rendering.

func (Snapshot) ContextMessage

func (s Snapshot) ContextMessage() string

ContextMessage formats an active snapshot as bounded developer context. The validation limits bound the output to roughly 5.5K Unicode code points.

func (Snapshot) Equal

func (s Snapshot) Equal(other Snapshot) bool

Equal reports whether two normalized snapshots have the same canonical data.

func (Snapshot) IsActive

func (s Snapshot) IsActive() bool

IsActive reports whether a non-empty snapshot still has unfinished work.

func (*Snapshot) NormalizeAndValidate

func (s *Snapshot) NormalizeAndValidate() error

NormalizeAndValidate trims model text and enforces all update_plan invariants.

func (Snapshot) Summary

func (s Snapshot) Summary() SnapshotSummary

Summary derives completed/total/current-step status without mutating the plan.

type SnapshotSummary

type SnapshotSummary struct {
	Completed   int
	Total       int
	CurrentStep string
}

SnapshotSummary is compact rendering/status data derived from a snapshot.

type Step

type Step struct {
	Step   string     `json:"step"`
	Status StepStatus `json:"status"`
}

Step is one ordered item in an execution plan.

type StepStatus

type StepStatus string

StepStatus is the lifecycle state of one execution-plan step.

const (
	StatusPending    StepStatus = "pending"
	StatusInProgress StepStatus = "in_progress"
	StatusCompleted  StepStatus = "completed"
)

Jump to

Keyboard shortcuts

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