session

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AgentConfigs = map[AgentType]AgentConfig{
	AgentClaude: {
		Command:         "claude",
		SupportsResume:  true,
		SupportsAutoYes: true,
		AutoYesFlag:     "--dangerously-skip-permissions",
		ResumeFlag:      "--resume",
	},
	AgentGemini: {
		Command:         "gemini",
		SupportsResume:  true,
		SupportsAutoYes: false,
		ResumeFlag:      "--resume",
	},
	AgentAider: {
		Command:         "aider",
		SupportsResume:  false,
		SupportsAutoYes: true,
		AutoYesFlag:     "--yes",
	},
	AgentCodex: {
		Command:            "codex",
		SupportsResume:     true,
		SupportsAutoYes:    true,
		AutoYesFlag:        "--full-auto",
		ResumeFlag:         "resume",
		ResumeIsSubcommand: true,
	},
	AgentAmazonQ: {
		Command:            "q",
		SupportsResume:     true,
		SupportsAutoYes:    true,
		AutoYesFlag:        "--trust-all-tools",
		ResumeFlag:         "chat --resume",
		ResumeIsSubcommand: true,
	},
	AgentOpenCode: {
		Command:         "opencode",
		SupportsResume:  true,
		SupportsAutoYes: false,
		ResumeFlag:      "--session",
	},
	AgentCustom: {
		Command:         "",
		SupportsResume:  false,
		SupportsAutoYes: false,
	},
}

AgentConfigs maps agent types to their configurations

Functions

func CheckAgentCommand

func CheckAgentCommand(inst *Instance) error

CheckAgentCommand verifies that the agent command exists in PATH

func GetClaudeProjectDir

func GetClaudeProjectDir(projectPath string) string

func GetClaudeStatusLine added in v0.4.0

func GetClaudeStatusLine(lines []string, stripANSIFunc func(string) string) string

GetClaudeStatusLine handles Claude Code's special UI with horizontal separator lines. If the input area (between two horizontal lines) has only 1 line (the prompt), it returns the content above the top separator instead of the prompt line.

Types

type AgentConfig

type AgentConfig struct {
	Command            string // Base command to run
	SupportsResume     bool   // Whether agent supports session resume
	SupportsAutoYes    bool   // Whether agent has auto-approve flag
	AutoYesFlag        string // The flag for auto-approve (e.g., "--dangerously-skip-permissions")
	ResumeFlag         string // The flag for resume (e.g., "--resume")
	ResumeIsSubcommand bool   // If true, resume is a subcommand (e.g., "codex resume") not a flag
}

AgentConfig contains configuration for each agent type

type AgentSession added in v0.3.5

type AgentSession struct {
	SessionID    string    `json:"session_id"`
	FirstPrompt  string    `json:"first_prompt"`
	LastPrompt   string    `json:"last_prompt"`
	MessageCount int       `json:"message_count"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	AgentType    AgentType `json:"agent_type"`
}

AgentSession is a generic session structure for any agent type

func ListAgentSessions added in v0.3.5

func ListAgentSessions(projectPath string) ([]AgentSession, error)

func ListAmazonQSessions added in v0.3.5

func ListAmazonQSessions(projectPath string) ([]AgentSession, error)

ListAmazonQSessions lists all Amazon Q sessions for the given project path Note: Amazon Q automatically saves conversations by working directory and resumes with "q chat --resume" without needing session IDs

func ListCodexSessions added in v0.3.5

func ListCodexSessions(projectPath string) ([]AgentSession, error)

ListCodexSessions lists all Codex sessions for the given project path

func ListGeminiSessions added in v0.3.5

func ListGeminiSessions(projectPath string) ([]AgentSession, error)

ListGeminiSessions lists all Gemini sessions for the given project path

func ListOpenCodeSessions added in v0.3.5

func ListOpenCodeSessions(projectPath string) ([]AgentSession, error)

ListOpenCodeSessions lists all OpenCode sessions for the given project path

type AgentType

type AgentType string

AgentType represents the type of AI agent

const (
	AgentClaude   AgentType = "claude"
	AgentGemini   AgentType = "gemini"
	AgentAider    AgentType = "aider"
	AgentCodex    AgentType = "codex"
	AgentAmazonQ  AgentType = "amazonq"
	AgentOpenCode AgentType = "opencode"
	AgentCustom   AgentType = "custom"
)

type Group

type Group struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Collapsed    bool   `json:"collapsed"`
	Color        string `json:"color,omitempty"`          // Group name color
	BgColor      string `json:"bg_color,omitempty"`       // Background color
	FullRowColor bool   `json:"full_row_color,omitempty"` // Extend background to full row
}

Group represents a session group for organizing sessions

type Instance

type Instance struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	Path            string    `json:"path"`
	Status          Status    `json:"status"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	AutoYes         bool      `json:"auto_yes"`
	ResumeSessionID string    `json:"resume_session_id,omitempty"` // Claude session ID to resume
	Color           string    `json:"color,omitempty"`             // Foreground color
	BgColor         string    `json:"bg_color,omitempty"`          // Background color
	FullRowColor    bool      `json:"full_row_color,omitempty"`    // Extend background to full row
	GroupID         string    `json:"group_id,omitempty"`          // Session group ID
	Agent           AgentType `json:"agent,omitempty"`             // Agent type (claude, gemini, aider, custom)
	CustomCommand   string    `json:"custom_command,omitempty"`    // Custom command for AgentCustom
	Notes           string    `json:"notes,omitempty"`             // User notes/comments for this session
}

func NewInstance

func NewInstance(name, path string, autoYes bool, agent AgentType) (*Instance, error)

func (*Instance) Attach

func (i *Instance) Attach() error

func (*Instance) DetectActivity added in v0.4.0

func (i *Instance) DetectActivity() SessionActivity

DetectActivity analyzes tmux pane content to determine session activity

func (*Instance) GetAgentConfig

func (i *Instance) GetAgentConfig() AgentConfig

GetAgentConfig returns the agent configuration for this instance

func (*Instance) GetLastLine

func (i *Instance) GetLastLine() string

GetLastLine returns the last non-empty line of output (for status display)

func (*Instance) GetPreview

func (i *Instance) GetPreview(lines int) (string, error)

func (*Instance) GetSuggestion added in v0.4.0

func (i *Instance) GetSuggestion() string

GetSuggestion extracts the autocomplete suggestion from the agent's prompt area

func (*Instance) IsAlive

func (i *Instance) IsAlive() bool

func (*Instance) ResizePane

func (i *Instance) ResizePane(width, height int) error

ResizePane resizes the tmux pane to the specified dimensions

func (*Instance) SendKeys

func (i *Instance) SendKeys(keys string) error

func (*Instance) SendPrompt added in v0.3.5

func (i *Instance) SendPrompt(text string) error

SendPrompt sends a prompt text followed by Enter key

func (*Instance) SendText added in v0.3.5

func (i *Instance) SendText(text string) error

SendText sends text literally (not interpreted as key names)

func (*Instance) Start

func (i *Instance) Start() error

func (*Instance) StartWithResume

func (i *Instance) StartWithResume(resumeID string) error

func (*Instance) Stop

func (i *Instance) Stop() error

func (*Instance) TmuxSessionName

func (i *Instance) TmuxSessionName() string

func (*Instance) UpdateDetachBinding

func (i *Instance) UpdateDetachBinding(previewWidth, previewHeight int)

UpdateDetachBinding updates Ctrl+Q to resize to preview size before detaching

func (*Instance) UpdateStatus

func (i *Instance) UpdateStatus()

type Project added in v0.3.0

type Project struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Path      string    `json:"path,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	Color     string    `json:"color,omitempty"`
}

Project represents a workspace containing sessions and groups

func NewProject added in v0.3.0

func NewProject(name string) *Project

NewProject creates a new project with the given name

type ProjectsData added in v0.3.0

type ProjectsData struct {
	Projects    []*Project `json:"projects"`
	LastProject string     `json:"last_project,omitempty"`
}

ProjectsData contains the list of projects and metadata

type SessionActivity added in v0.4.0

type SessionActivity int

SessionActivity represents the activity state of a session

const (
	ActivityIdle    SessionActivity = iota // No activity, no prompt
	ActivityBusy                           // Agent is working
	ActivityWaiting                        // Agent needs user input/permission
)

type Settings

type Settings struct {
	CompactList     bool   `json:"compact_list"`
	HideStatusLines bool   `json:"hide_status_lines"`
	ShowAgentIcons  bool   `json:"show_agent_icons,omitempty"`
	SplitView       bool   `json:"split_view,omitempty"`
	MarkedSessionID string `json:"marked_session_id,omitempty"`
	Cursor          int    `json:"cursor,omitempty"`
	SplitFocus      int    `json:"split_focus,omitempty"`
}

Settings stores UI preferences

type Status

type Status string
const (
	StatusRunning Status = "running"
	StatusPaused  Status = "paused"
	StatusStopped Status = "stopped"
)

type Storage

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

func NewStorage

func NewStorage() (*Storage, error)

func (*Storage) AddGroup

func (s *Storage) AddGroup(name string) (*Group, error)

AddGroup adds a new group

func (*Storage) AddInstance

func (s *Storage) AddInstance(instance *Instance) error

func (*Storage) AddProject added in v0.3.0

func (s *Storage) AddProject(name string) (*Project, error)

AddProject creates a new project

func (*Storage) GetActiveProjectID added in v0.3.0

func (s *Storage) GetActiveProjectID() string

GetActiveProjectID returns the currently active project ID

func (*Storage) GetGroups

func (s *Storage) GetGroups() ([]*Group, error)

GetGroups returns all groups

func (*Storage) GetInstance

func (s *Storage) GetInstance(id string) (*Instance, error)

func (*Storage) GetInstanceByName

func (s *Storage) GetInstanceByName(name string) (*Instance, error)

func (*Storage) GetProject added in v0.3.0

func (s *Storage) GetProject(id string) (*Project, error)

GetProject returns a project by ID

func (*Storage) GetProjectSessionCount added in v0.3.0

func (s *Storage) GetProjectSessionCount(projectID string) int

GetSessionCount returns the number of sessions in a project This requires loading the project's sessions file

func (*Storage) ImportDefaultSessions added in v0.3.0

func (s *Storage) ImportDefaultSessions(projectID string) (int, error)

ImportDefaultSessions moves sessions from default storage to a project

func (*Storage) IsProjectLocked added in v0.3.0

func (s *Storage) IsProjectLocked(projectID string) (bool, int)

IsProjectLocked checks if a project is already running

func (*Storage) Load

func (s *Storage) Load() ([]*Instance, error)

func (*Storage) LoadAll

func (s *Storage) LoadAll() ([]*Instance, []*Group, error)

LoadAll loads instances, groups, and settings

func (*Storage) LoadAllWithSettings

func (s *Storage) LoadAllWithSettings() ([]*Instance, []*Group, *Settings, error)

LoadAllWithSettings loads instances, groups, and settings

func (*Storage) LoadProjects added in v0.3.0

func (s *Storage) LoadProjects() (*ProjectsData, error)

LoadProjects loads the list of projects

func (*Storage) LockProject added in v0.3.0

func (s *Storage) LockProject(projectID string) error

LockProject creates a lock file for the current project

func (*Storage) RemoveGroup

func (s *Storage) RemoveGroup(id string) error

RemoveGroup removes a group (sessions become ungrouped)

func (*Storage) RemoveInstance

func (s *Storage) RemoveInstance(id string) error

func (*Storage) RemoveProject added in v0.3.0

func (s *Storage) RemoveProject(id string) error

RemoveProject removes a project and its data

func (*Storage) RenameGroup

func (s *Storage) RenameGroup(id, name string) error

RenameGroup renames a group

func (*Storage) RenameProject added in v0.3.0

func (s *Storage) RenameProject(id, name string) error

RenameProject renames a project

func (*Storage) Save

func (s *Storage) Save(instances []*Instance) error

func (*Storage) SaveAll

func (s *Storage) SaveAll(instances []*Instance, groups []*Group, settings *Settings) error

SaveAll saves instances, groups, and settings

func (*Storage) SaveProjects added in v0.3.0

func (s *Storage) SaveProjects(projectsData *ProjectsData) error

SaveProjects saves the list of projects

func (*Storage) SaveSettings

func (s *Storage) SaveSettings(settings *Settings) error

SaveSettings saves only the settings (preserves instances and groups)

func (*Storage) SaveWithGroups

func (s *Storage) SaveWithGroups(instances []*Instance, groups []*Group) error

SaveWithGroups saves instances and groups (preserves settings)

func (*Storage) SetActiveProject added in v0.3.0

func (s *Storage) SetActiveProject(projectID string) error

SetActiveProject switches to a different project

func (*Storage) SetInstanceGroup

func (s *Storage) SetInstanceGroup(instanceID, groupID string) error

SetInstanceGroup assigns an instance to a group

func (*Storage) ToggleGroupCollapsed

func (s *Storage) ToggleGroupCollapsed(id string) error

ToggleGroupCollapsed toggles the collapsed state of a group

func (*Storage) UnlockProject added in v0.3.0

func (s *Storage) UnlockProject()

UnlockProject removes the lock file

func (*Storage) UpdateInstance

func (s *Storage) UpdateInstance(instance *Instance) error

type StorageData

type StorageData struct {
	Instances []*Instance `json:"instances"`
	Groups    []*Group    `json:"groups,omitempty"`
	Settings  *Settings   `json:"settings,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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