Documentation
¶
Index ¶
- type Manager
- func (m *Manager) CheckAllIdle(teamName string, expectedMembers []string) (bool, error)
- func (m *Manager) ClaimAllIdle(teamName string, expectedMembers []string) (bool, error)
- func (m *Manager) Cleanup(maxAgeSec int64)
- func (m *Manager) DetectTeamByName(teamName string) *TeamInfo
- func (m *Manager) DetectTeamLead(sessionID string) *TeamInfo
- func (m *Manager) LoadState(teamName string) (*State, error)
- func (m *Manager) MarkNotified(teamName string) error
- func (m *Manager) RecordLeadStopped(teamName string) error
- func (m *Manager) RecordTeammateIdle(teamName, teammateName string) error
- func (m *Manager) SaveState(s *State) error
- type State
- type TeamInfo
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 ¶
NewManager creates a new team state manager. claudeDir can be empty to use the default (~/.claude).
func (*Manager) CheckAllIdle ¶
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) ClaimAllIdle ¶ added in v1.45.17
ClaimAllIdle atomically checks readiness and claims the team's completion. Only the caller that persists the claim may send a wait-all notification.
func (*Manager) DetectTeamByName ¶
DetectTeamByName finds team info by team name. Returns team info if found, nil otherwise.
func (*Manager) DetectTeamLead ¶
DetectTeamLead checks if the given session ID is a team lead. Returns team info if found, nil otherwise.
func (*Manager) MarkNotified ¶
MarkNotified records that a notification was sent and resets state for next cycle. Uses file locking for atomic read-modify-write.
func (*Manager) RecordLeadStopped ¶
RecordLeadStopped marks the team lead as stopped and persists state. Uses file locking to prevent races with concurrent TeammateIdle hooks.
func (*Manager) RecordTeammateIdle ¶
RecordTeammateIdle marks a teammate as idle and persists state. Uses file locking to prevent races with concurrent Stop hooks.
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)