models

package
v1.50.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package models defines the data objects shared across lazyworktree packages.

Index

Constants

View Source
const (
	AgentHookSessionStart     = "SessionStart"
	AgentHookSessionEnd       = "SessionEnd"
	AgentHookStop             = "Stop"
	AgentHookUserPromptSubmit = "UserPromptSubmit"
	AgentHookWaitingForUser   = "WaitingForUser"
	AgentHookCwdChanged       = "CwdChanged"
)

Hook event names shared by the Claude Code, Codex CLI, and Copilot CLI hook systems. Copilot CLI emits these when its hooks are configured with the PascalCase (VS Code compatible) event names.

View Source
const (
	ReviewStateApproved         = "APPROVED"
	ReviewStateChangesRequested = "CHANGES_REQUESTED"
	ReviewStateCommented        = "COMMENTED"
	ReviewStateDismissed        = "DISMISSED"
)

Review states reported for a PR/MR reviewer.

View Source
const (
	// LastSelectedFilename stores the last worktree selection for a repo.
	LastSelectedFilename = ".last-selected"
	// CacheFilename stores cached worktree metadata for faster loads.
	CacheFilename = ".worktree-cache.json"
	// CommandHistoryFilename stores the command history for the ! command.
	CommandHistoryFilename = ".command-history.json"
	// AccessHistoryFilename stores worktree access timestamps for sorting.
	AccessHistoryFilename = ".worktree-access.json"
	// CommandPaletteHistoryFilename stores command palette usage history for MRU sorting.
	CommandPaletteHistoryFilename = ".command-palette-history.json"
	// WorktreeNotesFilename stores per-worktree annotations.
	WorktreeNotesFilename = ".worktree-notes.json"
)
View Source
const (
	PRFetchStatusNotFetched = "not_fetched" // PR data has not been fetched yet
	PRFetchStatusFetching   = "fetching"    // PR data is currently being fetched
	PRFetchStatusLoaded     = "loaded"      // PR data was successfully loaded
	PRFetchStatusError      = "error"       // PR fetch encountered an error
	PRFetchStatusNoPR       = "no_pr"       // No PR exists for this branch
)

PR fetch status values for WorktreeInfo.PRFetchStatus field.

View Source
const AgentHookEventSchemaVersion = "lazyworktree-agent-hook-event-v1"

AgentHookEventSchemaVersion identifies the spool event format.

Variables

This section is empty.

Functions

func NormalizeTags added in v1.43.0

func NormalizeTags(tags []string) []string

NormalizeTags trims tags and drops empty entries whilst preserving order.

Types

type AgentActivity added in v1.43.0

type AgentActivity string

AgentActivity is the human-friendly label shown in the TUI.

const (
	// AgentActivityIdle shows no recent activity.
	AgentActivityIdle AgentActivity = "idle"
	// AgentActivityWaiting shows the agent waiting for the user.
	AgentActivityWaiting AgentActivity = "waiting"
	// AgentActivityApproval shows the agent waiting for a tool approval/result.
	AgentActivityApproval AgentActivity = "approval"
	// AgentActivityThinking shows the agent reasoning about a response.
	AgentActivityThinking AgentActivity = "thinking"
	// AgentActivityCompacting shows the agent compacting session context.
	AgentActivityCompacting AgentActivity = "compacting"
	// AgentActivityReading shows the agent reading files or data.
	AgentActivityReading AgentActivity = "reading"
	// AgentActivityWriting shows the agent editing files.
	AgentActivityWriting AgentActivity = "writing"
	// AgentActivityRunning shows the agent running a command.
	AgentActivityRunning AgentActivity = "running"
	// AgentActivitySearching shows the agent searching the workspace.
	AgentActivitySearching AgentActivity = "searching"
	// AgentActivityBrowsing shows the agent browsing external or local resources.
	AgentActivityBrowsing AgentActivity = "browsing"
	// AgentActivitySpawning shows the agent launching a sub-agent.
	AgentActivitySpawning AgentActivity = "spawning"
)

type AgentHookEvent added in v1.49.0

type AgentHookEvent struct {
	SchemaVersion  string    `json:"schema_version"`
	Agent          AgentKind `json:"agent"`
	HookEventName  string    `json:"hook_event_name"`
	SessionID      string    `json:"session_id"`
	TranscriptPath string    `json:"transcript_path,omitempty"`
	CWD            string    `json:"cwd,omitempty"`
	Model          string    `json:"model,omitempty"`
	Source         string    `json:"source,omitempty"`
	PID            int       `json:"pid,omitempty"`
	Timestamp      time.Time `json:"timestamp"`
}

AgentHookEvent is a normalised agent lifecycle event written to the spool directory by the hidden `agent-event` hook shim and consumed by the TUI.

type AgentKind added in v1.43.0

type AgentKind string

AgentKind identifies the coding agent that owns a transcript.

const (
	// AgentKindClaude marks a transcript produced by Claude.
	AgentKindClaude AgentKind = "claude"
	// AgentKindPi marks a transcript produced by pi.
	AgentKindPi AgentKind = "pi"
	// AgentKindCodex marks a session produced by the OpenAI Codex CLI.
	AgentKindCodex AgentKind = "codex"
	// AgentKindCopilot marks a session produced by the GitHub Copilot CLI.
	AgentKindCopilot AgentKind = "copilot"
)

type AgentOpenConfidence added in v1.43.0

type AgentOpenConfidence string

AgentOpenConfidence describes how confidently a live process was matched to a session.

const (
	// AgentOpenConfidenceNone means no live process match was found.
	AgentOpenConfidenceNone AgentOpenConfidence = "none"
	// AgentOpenConfidenceExact means a live process had the session transcript open.
	AgentOpenConfidenceExact AgentOpenConfidence = "exact"
	// AgentOpenConfidenceCWD means the live process matched by working directory only.
	AgentOpenConfidenceCWD AgentOpenConfidence = "cwd"
)

type AgentSession added in v1.43.0

type AgentSession struct {
	ID             string
	SessionKey     string
	Agent          AgentKind
	JSONLPath      string
	CWD            string
	Model          string
	GitBranch      string
	DisplayName    string
	Title          string
	LastPromptText string
	LastReplyText  string
	LastTargetPath string
	LastCommand    string
	TaskLabel      string
	CurrentTool    string
	LastToolName   string
	LastToolAt     time.Time
	LastSummaryAt  time.Time
	LastActivity   time.Time
	LastObservedAt time.Time
	Status         AgentSessionStatus
	Activity       AgentActivity
	LivenessState  AgentSessionLiveness
	LivenessSource AgentSessionLivenessSource
	ResumeHint     string
	SchemaVersion  string
	// PID is the agent process id reported by a lifecycle hook, when known.
	PID            int
	IsOpen         bool
	OpenConfidence AgentOpenConfidence
}

AgentSession summarises a coding-agent session attached to a worktree.

type AgentSessionLiveness added in v1.46.0

type AgentSessionLiveness string

AgentSessionLiveness describes how strongly the session appears to still be alive.

const (
	// AgentSessionLivenessActive means there is current strong proof the session is live.
	AgentSessionLivenessActive AgentSessionLiveness = "active"
	// AgentSessionLivenessRecent means the session was observed recently but is not confirmed active.
	AgentSessionLivenessRecent AgentSessionLiveness = "recent"
	// AgentSessionLivenessSuspect means only heuristic evidence suggests the session may still be live.
	AgentSessionLivenessSuspect AgentSessionLiveness = "suspect"
	// AgentSessionLivenessInactive means there is no current evidence the session is live.
	AgentSessionLivenessInactive AgentSessionLiveness = "inactive"
)

type AgentSessionLivenessSource added in v1.46.0

type AgentSessionLivenessSource string

AgentSessionLivenessSource identifies where the current liveness evidence came from.

const (
	// AgentSessionLivenessSourceNative means the agent itself exposed explicit liveness metadata.
	AgentSessionLivenessSourceNative AgentSessionLivenessSource = "native"
	// AgentSessionLivenessSourceRegistry means the persisted registry supplied the best recent evidence.
	AgentSessionLivenessSourceRegistry AgentSessionLivenessSource = "registry"
	// AgentSessionLivenessSourceExactFile means a live process has the transcript file open.
	AgentSessionLivenessSourceExactFile AgentSessionLivenessSource = "exact_file"
	// AgentSessionLivenessSourceCWDHeuristic means the match came only from a working-directory heuristic.
	AgentSessionLivenessSourceCWDHeuristic AgentSessionLivenessSource = "cwd_heuristic"
	// AgentSessionLivenessSourceHook means an agent lifecycle hook reported the session.
	AgentSessionLivenessSourceHook AgentSessionLivenessSource = "hook"
	// AgentSessionLivenessSourceNone means no evidence was available.
	AgentSessionLivenessSourceNone AgentSessionLivenessSource = "none"
)

type AgentSessionStatus added in v1.43.0

type AgentSessionStatus string

AgentSessionStatus describes the last observable state of a transcript.

const (
	// AgentSessionStatusUnknown means no recent state could be inferred.
	AgentSessionStatusUnknown AgentSessionStatus = "unknown"
	// AgentSessionStatusWaitingForUser means the agent is waiting on input.
	AgentSessionStatusWaitingForUser AgentSessionStatus = "waiting"
	// AgentSessionStatusWaitingApproval means a delegated tool call is waiting for approval or a result.
	AgentSessionStatusWaitingApproval AgentSessionStatus = "approval"
	// AgentSessionStatusThinking means the agent is reasoning about the next step.
	AgentSessionStatusThinking AgentSessionStatus = "thinking"
	// AgentSessionStatusExecutingTool means the agent is currently invoking a tool.
	AgentSessionStatusExecutingTool AgentSessionStatus = "tool"
	// AgentSessionStatusProcessingResult means the agent is digesting a tool result.
	AgentSessionStatusProcessingResult AgentSessionStatus = "processing"
	// AgentSessionStatusIdle means the transcript has gone quiet.
	AgentSessionStatusIdle AgentSessionStatus = "idle"
)

type CICheck

type CICheck struct {
	Name       string    // Name of the check/job
	Status     string    // Status: "completed", "in_progress", "queued", "pending"
	Conclusion string    // Conclusion: "success", "failure", "skipped", "cancelled", etc.
	Link       string    // URL to the check details page
	StartedAt  time.Time // When the check started (zero if not available)
}

CICheck represents a single CI check/job status.

type CommitFile added in v1.17.0

type CommitFile struct {
	Filename   string
	ChangeType string // A=Added, M=Modified, D=Deleted, R=Renamed, C=Copied
	OldPath    string // For renames: the original path
}

CommitFile represents a file changed in a commit.

type IssueInfo added in v1.20.0

type IssueInfo struct {
	Number      int
	State       string
	Title       string
	Body        string // For branch_name_script input
	URL         string
	Author      string // Issue author username
	AuthorName  string // Issue author full name
	AuthorIsBot bool   // Whether the author is a bot
}

IssueInfo captures the relevant metadata for an issue.

type PRInfo

type PRInfo struct {
	Number          int
	State           string
	Title           string
	Body            string // For branch_name_script input
	URL             string
	Branch          string // Branch name (headRefName for GitHub, source_branch for GitLab)
	BaseBranch      string // Base branch name (baseRefName for GitHub, target_branch for GitLab)
	Author          string // PR/MR author username
	AuthorName      string // PR/MR author full name
	AuthorAvatarURL string // PR/MR author avatar URL
	AuthorIsBot     bool   // Whether the author is a bot
	IsDraft         bool   // Whether the PR is a draft
	CIStatus        string // Computed CI status: "success", "failure", "pending", "none"
}

PRInfo captures the relevant metadata for a pull request.

func (*PRInfo) EnsureAuthorAvatarURL added in v1.48.0

func (p *PRInfo) EnsureAuthorAvatarURL()

EnsureAuthorAvatarURL backfills AuthorAvatarURL from the author login for github.com pull requests when it is missing. This recovers PR data restored from an older on-disk cache written before avatar URLs were persisted.

type PRReviewer added in v1.50.0

type PRReviewer struct {
	Login     string
	Name      string
	AvatarURL string
	IsBot     bool
	State     string
}

PRReviewer captures a reviewer who submitted a review on a PR/MR.

type PRReviewerSummary added in v1.50.0

type PRReviewerSummary struct {
	Total     int
	Reviewers []*PRReviewer
}

PRReviewerSummary pairs the reviewer count reported by the forge with the reviewers whose identity could be resolved. The two differ when a review was submitted by a since-deleted account, or when the forge reports more reviews than the page we requested.

type StatusFile added in v1.29.0

type StatusFile struct {
	Filename    string
	Status      string // XY status code (e.g., ".M", "M.", " ?")
	IsUntracked bool
}

StatusFile represents a file entry from git status.

type WorktreeInfo

type WorktreeInfo struct {
	Path           string
	Branch         string
	IsMain         bool
	Dirty          bool
	Ahead          int
	Behind         int
	Unpushed       int // Commits not on any remote (for branches without upstream)
	HasUpstream    bool
	UpstreamBranch string // The upstream branch name (e.g., "origin/main" or "chmouel/feature-branch")
	LastActive     string
	LastActiveTS   int64
	LastSwitchedTS int64 // Unix timestamp of last UI access/switch
	PR             *PRInfo
	PRFetchError   string // Stores error message if PR fetch failed
	PRFetchStatus  string // "not_fetched", "fetching", "loaded", "error", "no_pr"
	Untracked      int
	Modified       int
	Staged         int
	Divergence     string
}

WorktreeInfo summarizes the information for a git worktree.

type WorktreeNote added in v1.35.0

type WorktreeNote struct {
	Note        string   `json:"note,omitempty"`
	Icon        string   `json:"icon,omitempty"`
	Color       string   `json:"color,omitempty"`
	Bold        bool     `json:"bold,omitempty"`
	Description string   `json:"description,omitempty"`
	Tags        []string `json:"tags,omitempty"`
	UpdatedAt   int64    `json:"updated_at"`
}

WorktreeNote stores user-authored metadata for a worktree.

func (WorktreeNote) IsEmpty added in v1.42.0

func (w WorktreeNote) IsEmpty() bool

IsEmpty returns true when every user-visible field is blank (after trimming whitespace).

Jump to

Keyboard shortcuts

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