planmode

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package planmode provides a pure interactive plan-mode state machine. It has no I/O; hosts own persistence, prompts, and tool gating.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Snapshot

type Snapshot struct {
	State                State  `json:"state"`
	WasPreviouslyActive  bool   `json:"was_previously_active"`
	ReminderCount        uint32 `json:"reminder_count"`
	PendingExitReminder  bool   `json:"pending_exit_reminder"`
	AwaitingPlanApproval bool   `json:"awaiting_plan_approval"`
}

Snapshot is a persistable view of plan-mode lifecycle state.

type State

type State string

State is the plan-mode lifecycle state.

const (
	StateInactive    State = "inactive"
	StatePending     State = "pending"
	StateActive      State = "active"
	StateExitPending State = "exit_pending"
)

type Tracker

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

Tracker manages plan-mode transitions without SessionActor / I/O deps.

func FromSnapshot

func FromSnapshot(planFilePath string, snap Snapshot) *Tracker

FromSnapshot restores a tracker. Transient Pending/ExitPending collapse on restart: Pending→Inactive, ExitPending→Inactive with exit reminder.

func New

func New(planFilePath string) *Tracker

New creates a tracker. planFilePath is the absolute plan.md path for the session.

func (*Tracker) Activate

func (t *Tracker) Activate() bool

Activate transitions Pending → Active on the first user prompt.

func (*Tracker) AllowsWriteTool

func (t *Tracker) AllowsWriteTool(editPath string) bool

AllowsWriteTool reports whether a write-side-effect tool may run. In Active plan mode only the plan-file write path is allowed; other writes must be blocked by the host.

func (*Tracker) ApproveExit

func (t *Tracker) ApproveExit() bool

ApproveExit completes an approved exit_plan_mode while Active.

func (*Tracker) ClearPendingExitReminder

func (t *Tracker) ClearPendingExitReminder()

func (*Tracker) CompleteExit

func (t *Tracker) CompleteExit() bool

CompleteExit finishes ExitPending after the in-flight turn ends.

func (*Tracker) EnterPending

func (t *Tracker) EnterPending() bool

EnterPending is the client toggle ON. Returns whether state changed.

func (*Tracker) HasPendingExitReminder

func (t *Tracker) HasPendingExitReminder() bool

func (*Tracker) IncrementReminderCount

func (t *Tracker) IncrementReminderCount()

func (*Tracker) IsActive

func (t *Tracker) IsActive() bool

func (*Tracker) IsAwaitingPlanApproval

func (t *Tracker) IsAwaitingPlanApproval() bool

func (*Tracker) PlanFilePath

func (t *Tracker) PlanFilePath() string

func (*Tracker) RequestExit

func (t *Tracker) RequestExit(turnInFlight bool) bool

RequestExit is the client toggle OFF. Idle Active → Inactive; in-flight Active → ExitPending.

func (*Tracker) SetAwaitingPlanApproval

func (t *Tracker) SetAwaitingPlanApproval(awaiting bool)

func (*Tracker) ShouldAutoApproveEdit

func (t *Tracker) ShouldAutoApproveEdit(editPath string) bool

ShouldAutoApproveEdit reports whether an edit path targets the plan file while plan mode is active (hosts may skip write approval for that file).

func (*Tracker) ShouldUseFullReminder

func (t *Tracker) ShouldUseFullReminder() bool

func (*Tracker) Snapshot

func (t *Tracker) Snapshot() Snapshot

func (*Tracker) State

func (t *Tracker) State() State

Jump to

Keyboard shortcuts

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