Documentation
¶
Overview ¶
Package planmode owns the plan-mode state machine, the session-bound plan file, and the model-facing reminder text.
Index ¶
- Constants
- Variables
- func ApprovalResult(comments []string) string
- func EditRejection(planPath string) string
- func IterationGuidance(ask string) string
- func PlanReminder(planPath string, hasContent bool, names ReminderNames) string
- func ReturningReminder(planPath string, names ReminderNames) string
- func RevisionResult(notes string) string
- type Document
- type Limits
- type ReminderNames
- type State
- func (s State) Activate() (State, error)
- func (s State) Durable() State
- func (s State) EnterApproved() (State, error)
- func (s State) ExitApproved() (State, error)
- func (s State) GateArmed() bool
- func (s State) Plan() bool
- func (s State) ToggleOff(inFlight bool) (State, error)
- func (s State) ToggleOn() (State, error)
- func (s State) TurnComplete() (State, error)
- func (s State) Valid() bool
- type Store
- func (s *Store) CopyTo(ctx context.Context, target *Store) error
- func (s *Store) Dir() string
- func (s *Store) LoadState(ctx context.Context) (State, error)
- func (s *Store) Path() string
- func (s *Store) Read(ctx context.Context) (Document, error)
- func (s *Store) Replace(ctx context.Context, content string) (Document, error)
- func (s *Store) SaveState(ctx context.Context, state State) error
- func (s *Store) Seed(ctx context.Context) (bool, error)
- func (s *Store) SessionID() string
Constants ¶
const AgentModeReminder = "You are now in Agent mode. Continue with the task in the new mode."
AgentModeReminder is injected when the session returns to agent mode.
const ApprovalCommentsPrefix = "The user approved the plan with the following review comments:"
ApprovalCommentsPrefix introduces review comments attached to an approval.
const DeclineResult = "The user declined to enter plan mode. Continue in normal mode without it."
DeclineResult is returned when the user declines to enter plan mode.
const EnterDescription = "Use this tool when a task has ambiguity about the right approach " +
"or when the user asks you to write a plan. This tool enables a read-only plan mode " +
"where you explore the codebase and create an implementation plan for the user."
EnterDescription is the enter_plan_mode tool description.
const EnterResult = "You have entered plan mode. You should now focus on exploring the codebase " +
"and creating an implementation plan."
EnterResult is returned after an approved enter_plan_mode call.
const EnterToolName = "enter_plan_mode"
EnterToolName is the model-facing entry gate.
const ExitApprovedEmptyResult = "Plan mode exit approved. No plan content was found - you can proceed."
ExitApprovedEmptyResult is returned when the user approves without a plan.
const ExitApprovedResult = "Your plan has been approved. You can now start coding."
ExitApprovedResult is returned when the user approves the plan.
const ExitDescription = "Exit plan mode and present your plan to the user.\n\n" +
"Use this after you have finished writing your plan to the plan file in plan mode."
ExitDescription is the exit_plan_mode tool description.
const ExitQuitResult = "The user chose to abandon the plan entirely (via the Abandon option in " + "the plan approval dialog). Plan mode has been disabled. Do not call " + ExitToolName + " again unless the user explicitly asks to re-enter plan mode."
ExitQuitResult is returned when the user abandons the plan.
const ExitReviseResult = "The user does not want to exit plan mode. Continue planning and ask " +
"the user what they would like to do."
ExitReviseResult is returned when the user requests changes instead of approving.
const ExitToolName = "exit_plan_mode"
ExitToolName is the model-facing exit gate.
const ExitedReminder = "You have exited plan mode. You can now make edits, run tools, and take actions."
ExitedReminder is injected on the first request after plan mode is turned off while a turn is still in flight.
const RevisionPrefix = "User revision notes:"
RevisionPrefix introduces freeform revision notes requested from the user.
const StillActiveReminder = "Plan mode is still active. Do not make any edits or writes to the " +
"system except for the plan file."
StillActiveReminder is the short reminder for follow-up requests.
Variables ¶
var ( // ErrNotFound means the session has no plan file yet. ErrNotFound = errors.New("coding plan file: not found") // ErrUnsafe means a filesystem object violates the private-file contract. ErrUnsafe = errors.New("coding plan file: unsafe filesystem object") // ErrUnsupported means the platform cannot provide the required guarantees. ErrUnsupported = errors.New("coding plan file: unsupported platform") )
var ErrInvalid = errors.New("coding plan mode: invalid value")
ErrInvalid reports a malformed state or transition.
Functions ¶
func ApprovalResult ¶
ApprovalResult renders the approval tool result, including pending review comments when present.
func EditRejection ¶
EditRejection is the model-facing rejection for edits outside the plan file.
func IterationGuidance ¶
IterationGuidance renders the plan-iteration-versus-execution guidance injected on user turns while plan mode is still active.
func PlanReminder ¶
func PlanReminder(planPath string, hasContent bool, names ReminderNames) string
PlanReminder renders the plan-mode reminder injected with each request while plan mode is active.
func ReturningReminder ¶
func ReturningReminder(planPath string, names ReminderNames) string
ReturningReminder renders the reminder used when plan mode is entered again while a plan file from the previous planning session still exists.
func RevisionResult ¶
RevisionResult renders the request-changes tool result with revision notes.
Types ¶
type Limits ¶
type Limits struct {
MaxBytes int64
}
Limits bound private plan storage.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits returns production plan storage limits.
type ReminderNames ¶
ReminderNames are the tool names interpolated into the plan-mode reminder.
type State ¶
type State string
State is the plan-mode state machine value.
Inactive -- normal operating mode; no gate
Pending -- the user toggled plan mode on; no prompt has been sent yet
Active -- the edit gate is armed and the plan reminder is injected
ExitPending -- the user toggled plan mode off while a turn is in flight;
the gate holds until the turn completes
const ( StateInactive State = "inactive" StatePending State = "pending" StateActive State = "active" StateExitPending State = "exit_pending" )
Plan-mode states.
func (State) Activate ¶
Activate promotes Pending to Active when the first prompt of the plan-mode interaction starts. Other states pass through unchanged.
func (State) Durable ¶
Durable returns the state persisted across restarts. Transient states (Pending, ExitPending) collapse to Inactive because they depend on in-flight interactions.
func (State) EnterApproved ¶
EnterApproved applies an approved enter_plan_mode call, which skips Pending.
func (State) ExitApproved ¶
ExitApproved applies an approved or abandoned exit_plan_mode call. Plan mode is disabled immediately, even mid-turn.
func (State) Plan ¶
Plan reports whether the state is reported as the plan operating mode. Pending and ExitPending both keep the plan flag while they are observable.
func (State) ToggleOff ¶
ToggleOff is the user-initiated exit transition. inFlight marks that a turn is currently running, which defers the exit to the end of the turn.
func (State) ToggleOn ¶
ToggleOn is the user-initiated entry transition (/plan, Shift+Tab, ACP set_mode plan). From ExitPending it re-arms the active state.
func (State) TurnComplete ¶
TurnComplete settles ExitPending once its in-flight turn finishes.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns one session's private plan directory: the plan file the model edits plus the durable plan-mode state.
func NewStore ¶
NewStore opens (creating when needed) the private plan directory of one conversation session under the Harness sessions directory.
func (*Store) CopyTo ¶
CopyTo copies the plan file and durable state into another session store. A source without a plan is a successful no-op.
func (*Store) LoadState ¶
LoadState reads the durable plan-mode state. Missing state is Inactive and transient states collapse to Inactive because they depend on in-flight interactions that did not survive the restart.
func (*Store) Path ¶
Path returns the absolute plan file path disclosed to the model and the frontend. It never creates or reads the file.