execution

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package execution provides execution mode state management.

Pair programming mode: collaborative AI-human coding with real-time feedback. All tools execute normally in this mode; the collaboration logic is handled at the prompt and suggestion level rather than through tool blocking.

Package execution provides execution mode state management.

Plan mode: the agent explores the codebase and writes a plan, which is then presented to the user for approval before any source files are modified.

Index

Constants

View Source
const DefaultSuggestionsDirectory = ".seshat/suggestions"

Variables

View Source
var DefaultPlansDirectory = runtimepath.PlansDir("")

DefaultPlansDirectory is the default location for plan files (~/.config/seshat/plans/).

View Source
var WordList = []string{
	"algorithm", "cascade", "discovery", "element", "focus", "galaxy", "horizon", "insight",
	"journey", "kernel", "launch", "momentum", "seshat", "orbit", "prism", "quest",
	"resonance", "spectrum", "tempo", "unity", "vertex", "wavelength", "zenith", "apex",
	"bridge", "chronicle", "dynamics", "eclipse", "fusion", "genesis", "harmonic", "infinity",
	"junction", "kinesis", "lucid", "meridian", "novel", "origins", "paradigm", "quantum",
	"radian", "symmetry", "threshold", "unity", "vortex", "wanderer", "xenon", "yearning",
}

WordList is used to generate human-readable mode file slugs.

Functions

func ClearAllPairProgrammingStates

func ClearAllPairProgrammingStates()

ClearAllPairProgrammingStates removes all session states (useful for testing).

func ClearAllPlanSlugs

func ClearAllPlanSlugs()

ClearAllPlanSlugs removes all plan slugs (useful for testing).

func ClearAllStates

func ClearAllStates()

ClearAllStates removes all session states (useful for testing).

func ClearAllSuggestionSlugs

func ClearAllSuggestionSlugs()

ClearAllSuggestionSlugs removes all suggestion slugs (useful for testing).

func ClearPairProgrammingState

func ClearPairProgrammingState(sessionID types.SessionID)

ClearPairProgrammingState removes all state for a session.

func ClearPlanSlug

func ClearPlanSlug(sessionID types.SessionID)

ClearPlanSlug removes the plan slug for a session.

func ClearState

func ClearState(sessionID types.SessionID)

ClearState removes the state for a session.

func ClearSuggestionSlug

func ClearSuggestionSlug(sessionID types.SessionID)

ClearSuggestionSlug removes the suggestion slug for a session.

func DeletePlan

func DeletePlan(sessionID types.SessionID, agentID *types.AgentID) error

DeletePlan deletes the plan file for a session.

func DeleteSuggestions

func DeleteSuggestions(sessionID types.SessionID) error

DeleteSuggestions deletes the suggestions file for a session.

func EnterPairProgrammingMode

func EnterPairProgrammingMode(sessionID types.SessionID)

EnterPairProgrammingMode initializes pair programming mode state for a session.

func EnterPlanMode

func EnterPlanMode(sessionID types.SessionID, agentID *types.AgentID)

EnterPlanMode initializes plan mode state for a session.

func ExitPairProgrammingMode

func ExitPairProgrammingMode(sessionID types.SessionID)

ExitPairProgrammingMode applies state changes when leaving pair programming mode.

func ExitPlanMode

func ExitPlanMode(sessionID types.SessionID)

ExitPlanMode applies state changes when leaving plan mode.

func ExtractSlugFromFilePath

func ExtractSlugFromFilePath(filePath string) string

ExtractSlugFromFilePath extracts the slug from a mode file path. E.g. "/path/to/quantum-bridge.md" → "quantum-bridge".

func GetAcceptedSuggestions

func GetAcceptedSuggestions(sessionID types.SessionID) int

func GetCollaborationTurns

func GetCollaborationTurns(sessionID types.SessionID) int

func GetDisplayPath

func GetDisplayPath(planFilePath string) string

GetDisplayPath returns a user-friendly tilde-prefixed path to the plan file.

func GetHasPlanFile

func GetHasPlanFile(sessionID types.SessionID) bool

func GetHasSuggestionsFile

func GetHasSuggestionsFile(sessionID types.SessionID) bool

func GetPlan

func GetPlan(sessionID types.SessionID, agentID *types.AgentID) (string, error)

GetPlan reads the plan content from disk.

func GetPlanFilePath

func GetPlanFilePath(sessionID types.SessionID, agentID *types.AgentID) string

GetPlanFilePath returns the full path to the plan file for a session. Plans are stored under sessions/{sessionID}/plans/ so that deleting a session directory removes all its plans in one shot. When agentID is non-nil the filename includes the agent identifier, allowing separate plan files per sub-agent within the same session.

func GetPlanSlug

func GetPlanSlug(sessionID types.SessionID) string

GetPlanSlug returns the slug for a session's plan file.

func GetPlanWasEdited

func GetPlanWasEdited(sessionID types.SessionID) bool

func GetPlansDirectory

func GetPlansDirectory() string

GetPlansDirectory returns the directory where plan files are stored.

func GetSuggestionFilePath

func GetSuggestionFilePath(sessionID types.SessionID) string

GetSuggestionFilePath returns the full path to the suggestions file for a session.

func GetSuggestionSlug

func GetSuggestionSlug(sessionID types.SessionID) string

GetSuggestionSlug returns the suggestion slug for a session.

func GetSuggestions

func GetSuggestions(sessionID types.SessionID) (string, error)

GetSuggestions reads the suggestions content from disk.

func GetSuggestionsCount

func GetSuggestionsCount(sessionID types.SessionID) int

func GetSuggestionsDirectory

func GetSuggestionsDirectory() string

GetSuggestionsDirectory returns the directory where suggestion files are stored.

func GetSuggestionsDisplayPath

func GetSuggestionsDisplayPath(suggestionFilePath string) string

GetSuggestionsDisplayPath returns a user-friendly relative path to the suggestions file.

func GetSuggestionsWereReviewed

func GetSuggestionsWereReviewed(sessionID types.SessionID) bool

func HasActiveCollaboration

func HasActiveCollaboration(sessionID types.SessionID) bool

func HasExitedPlanMode

func HasExitedPlanMode(sessionID types.SessionID) bool

func IncrementAcceptedSuggestions

func IncrementAcceptedSuggestions(sessionID types.SessionID)

func IncrementCollaborationTurns

func IncrementCollaborationTurns(sessionID types.SessionID)

func IncrementSuggestionsCount

func IncrementSuggestionsCount(sessionID types.SessionID)

func NeedsPlanModeExitAttachment

func NeedsPlanModeExitAttachment(sessionID types.SessionID) bool

func NeedsUserConfirmation

func NeedsUserConfirmation(sessionID types.SessionID) bool

func PlanExists

func PlanExists(sessionID types.SessionID, agentID *types.AgentID) bool

PlanExists checks if a plan file exists for the session.

func SetHasActiveCollaboration

func SetHasActiveCollaboration(sessionID types.SessionID, v bool)

func SetHasExitedPlanMode

func SetHasExitedPlanMode(sessionID types.SessionID, v bool)

func SetHasPlanFile

func SetHasPlanFile(sessionID types.SessionID, v bool)

func SetHasSuggestionsFile

func SetHasSuggestionsFile(sessionID types.SessionID, v bool)

func SetNeedsPlanModeExitAttachment

func SetNeedsPlanModeExitAttachment(sessionID types.SessionID, v bool)

func SetNeedsUserConfirmation

func SetNeedsUserConfirmation(sessionID types.SessionID, v bool)

func SetPairProgrammingState

func SetPairProgrammingState(sessionID types.SessionID, state *PairProgrammingState)

SetPairProgrammingState explicitly sets the state for a session (useful for testing).

func SetPlan

func SetPlan(sessionID types.SessionID, agentID *types.AgentID, content string) error

SetPlan writes the plan content to disk.

func SetPlanSlug

func SetPlanSlug(sessionID types.SessionID, slug string)

SetPlanSlug sets the plan slug for a session (useful for testing).

func SetPlanWasEdited

func SetPlanWasEdited(sessionID types.SessionID, v bool)

func SetPlansDirectory

func SetPlansDirectory(dir string) error

SetPlansDirectory sets a custom directory for plan files.

func SetState

func SetState(sessionID types.SessionID, state *State)

SetState explicitly sets the state for a session (useful for testing).

func SetSuggestionSlug

func SetSuggestionSlug(sessionID types.SessionID, slug string)

SetSuggestionSlug sets the suggestion slug for a session (useful for testing).

func SetSuggestions

func SetSuggestions(sessionID types.SessionID, content string) error

SetSuggestions writes the suggestions content to disk.

func SetSuggestionsDirectory

func SetSuggestionsDirectory(dir string) error

SetSuggestionsDirectory sets a custom directory for suggestion files.

func SetSuggestionsWereReviewed

func SetSuggestionsWereReviewed(sessionID types.SessionID, v bool)

func SuggestionsExist

func SuggestionsExist(sessionID types.SessionID) bool

SuggestionsExist checks if a suggestions file exists for the session.

Types

type ModeCache

type ModeCache[S any] struct {
	// contains filtered or unexported fields
}

ModeCache manages per-session state, slug, and file artifact for a single mode. S is the mode-specific state type.

func NewModeCache

func NewModeCache[S any](subDir string, newState func() *S) *ModeCache[S]

NewModeCache creates a new ModeCache. subDir is the path relative to cwd (e.g. ".seshat/plans"). newState returns a fresh zero state for new sessions.

func (*ModeCache[S]) ClearAllSlugs

func (c *ModeCache[S]) ClearAllSlugs()

ClearAllSlugs removes all slugs.

func (*ModeCache[S]) ClearAllStates

func (c *ModeCache[S]) ClearAllStates()

ClearAllStates removes all session states.

func (*ModeCache[S]) ClearSlug

func (c *ModeCache[S]) ClearSlug(sessionID types.SessionID)

ClearSlug removes the slug for a session.

func (*ModeCache[S]) ClearState

func (c *ModeCache[S]) ClearState(sessionID types.SessionID)

ClearState removes the state for a session.

func (*ModeCache[S]) DeleteFile

func (c *ModeCache[S]) DeleteFile(sessionID types.SessionID) error

DeleteFile deletes the mode file for a session.

func (*ModeCache[S]) FileExists

func (c *ModeCache[S]) FileExists(sessionID types.SessionID) bool

FileExists checks if the mode file exists for a session.

func (*ModeCache[S]) GetDirectory

func (c *ModeCache[S]) GetDirectory() string

GetDirectory returns the mode's file directory, creating it lazily on first call.

func (*ModeCache[S]) GetDisplayPath

func (c *ModeCache[S]) GetDisplayPath(filePath string) string

GetDisplayPath returns a user-friendly path relative to the current working directory.

func (*ModeCache[S]) GetFilePath

func (c *ModeCache[S]) GetFilePath(sessionID types.SessionID) string

GetFilePath returns the full path to the mode file for a session.

func (*ModeCache[S]) GetSlug

func (c *ModeCache[S]) GetSlug(sessionID types.SessionID) string

GetSlug returns the slug for a session, generating one if it does not exist.

func (*ModeCache[S]) GetState

func (c *ModeCache[S]) GetState(sessionID types.SessionID) *S

GetState returns the state for a session, creating it if it does not exist.

func (*ModeCache[S]) ReadFile

func (c *ModeCache[S]) ReadFile(sessionID types.SessionID) (string, error)

ReadFile reads the mode file content for a session.

func (*ModeCache[S]) SetDirectory

func (c *ModeCache[S]) SetDirectory(dir string) error

SetDirectory sets a custom directory for mode files.

func (*ModeCache[S]) SetSlug

func (c *ModeCache[S]) SetSlug(sessionID types.SessionID, slug string)

SetSlug sets the slug for a session.

func (*ModeCache[S]) SetState

func (c *ModeCache[S]) SetState(sessionID types.SessionID, state *S)

SetState explicitly sets the state for a session.

func (*ModeCache[S]) WriteFile

func (c *ModeCache[S]) WriteFile(sessionID types.SessionID, content string) error

WriteFile writes content to the mode file for a session.

type PairProgrammingState

type PairProgrammingState struct {
	HasActiveCollaboration  bool
	NeedsUserConfirmation   bool
	HasSuggestionsFile      bool
	SuggestionsWereReviewed bool
	CollaborationTurns      int
	SuggestionsCount        int
	AcceptedSuggestions     int
}

PairProgrammingState represents the pair programming mode state for a session.

func ClonePairProgrammingState

func ClonePairProgrammingState(sessionID types.SessionID) *PairProgrammingState

ClonePairProgrammingState returns a copy of the current state.

func GetPairProgrammingState

func GetPairProgrammingState(sessionID types.SessionID) *PairProgrammingState

GetPairProgrammingState returns the pair programming state for a session.

type State

type State struct {
	HasExitedPlanMode           bool
	NeedsPlanModeExitAttachment bool
	HasPlanFile                 bool
	PlanWasEdited               bool
}

State represents the current plan mode state for a session.

func CloneState

func CloneState(sessionID types.SessionID) *State

CloneState returns a copy of the current plan state.

func GetState

func GetState(sessionID types.SessionID) *State

GetState returns the plan mode state for a session, creating it if needed.

Jump to

Keyboard shortcuts

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