session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 11 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:  false,
		SupportsAutoYes: false,
	},
	AgentAider: {
		Command:         "aider",
		SupportsResume:  false,
		SupportsAutoYes: true,
		AutoYesFlag:     "--yes",
	},
	AgentCodex: {
		Command:         "codex",
		SupportsResume:  false,
		SupportsAutoYes: true,
		AutoYesFlag:     "--full-auto",
	},
	AgentAmazonQ: {
		Command:         "q",
		SupportsResume:  false,
		SupportsAutoYes: true,
		AutoYesFlag:     "--trust-all-tools",
	},
	AgentOpenCode: {
		Command:         "opencode",
		SupportsResume:  false,
		SupportsAutoYes: false,
	},
	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

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")
}

AgentConfig contains configuration for each agent type

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 ClaudeSession

type ClaudeSession 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"`
}

func ListClaudeSessions

func ListClaudeSessions(projectPath string) ([]ClaudeSession, error)

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

}

func NewInstance

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

func (*Instance) Attach

func (i *Instance) Attach() error

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) 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) 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 Settings

type Settings struct {
	CompactList     bool `json:"compact_list"`
	HideStatusLines bool `json:"hide_status_lines"`
}

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) 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) 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) 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) RenameGroup

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

RenameGroup renames a group

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) 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) 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) 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