teamstate

package
v1.45.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager handles team detection and state tracking. All state mutations use file-level locking (flock) for cross-process safety, since Stop and TeammateIdle hooks run as separate OS processes.

func NewManager

func NewManager(claudeDir string) *Manager

NewManager creates a new team state manager. claudeDir can be empty to use the default (~/.claude).

func (*Manager) CheckAllIdle

func (m *Manager) CheckAllIdle(teamName string, expectedMembers []string) (bool, error)

CheckAllIdle checks if the lead has stopped AND all expected members are idle. Returns true if a notification should be sent. Uses file locking for consistent reads.

func (*Manager) Cleanup

func (m *Manager) Cleanup(maxAgeSec int64)

Cleanup removes state and lock files older than maxAge seconds.

func (*Manager) DetectTeamByName

func (m *Manager) DetectTeamByName(teamName string) *TeamInfo

DetectTeamByName finds team info by team name. Returns team info if found, nil otherwise.

func (*Manager) DetectTeamLead

func (m *Manager) DetectTeamLead(sessionID string) *TeamInfo

DetectTeamLead checks if the given session ID is a team lead. Returns team info if found, nil otherwise.

func (*Manager) LoadState

func (m *Manager) LoadState(teamName string) (*State, error)

LoadState loads team state from disk (for read-only access / tests).

func (*Manager) MarkNotified

func (m *Manager) MarkNotified(teamName string) error

MarkNotified records that a notification was sent and resets state for next cycle. Uses file locking for atomic read-modify-write.

func (*Manager) RecordLeadStopped

func (m *Manager) RecordLeadStopped(teamName string) error

RecordLeadStopped marks the team lead as stopped and persists state. Uses file locking to prevent races with concurrent TeammateIdle hooks.

func (*Manager) RecordTeammateIdle

func (m *Manager) RecordTeammateIdle(teamName, teammateName string) error

RecordTeammateIdle marks a teammate as idle and persists state. Uses file locking to prevent races with concurrent Stop hooks.

func (*Manager) SaveState

func (m *Manager) SaveState(s *State) error

SaveState persists team state to disk (for tests).

type State

type State struct {
	TeamName    string           `json:"team_name"`
	LeadStopped bool             `json:"lead_stopped"`
	LeadStopAt  int64            `json:"lead_stop_at,omitempty"`
	IdleMembers map[string]int64 `json:"idle_members"` // member name → unix timestamp
	NotifiedAt  int64            `json:"notified_at,omitempty"`
}

State tracks team notification state (persisted to /tmp)

type TeamInfo

type TeamInfo struct {
	TeamName   string
	Members    []string // non-lead member names
	ConfigPath string
}

TeamInfo holds detected team information for the current session

Jump to

Keyboard shortcuts

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