workspaceinventory

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workspaceinventory provides the narrow, read-only inventory used by cross-project surfaces. It never creates or reconciles Sidecar state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalPath

func CanonicalPath(path string) string

func CanonicalProjectPath

func CanonicalProjectPath(path string) string

CanonicalProjectPath resolves a configured checkout to its canonical main worktree when Git's linked-worktree metadata is available. Missing and non-Git paths retain their canonical configured identity so they can still produce an independent error result.

Types

type CaptureFunc added in v0.98.0

type CaptureFunc func(target string, lines int) (string, tty.PaneState, error)

CaptureFunc reads one pane: its capture text and the geometry observed with it. The geometry travels with the capture because a capture's rows alone cannot say where the live grid starts, and a consumer that has to ask separately pairs rows from one instant with a height from another.

type Collector

type Collector struct {
	Runner  Runner
	Capture CaptureFunc
	Now     func() time.Time
	DoneTTL time.Duration
	// contains filtered or unexported fields
}

func (Collector) CollectProject

func (c Collector) CollectProject(ctx context.Context, name, root string, allRoots []string, panes []Pane) ProjectResult

CollectProject reads one Git inventory and already-existing Sidecar metadata.

func (Collector) CollectProjectInventory

func (c Collector) CollectProjectInventory(ctx context.Context, name, root string) ProjectResult

CollectProjectInventory reads one project's lightweight Git and existing Sidecar metadata without inspecting tmux or capturing panes. Callers can therefore fan this stage out with the same project bound as the rest of a refresh and paint each result before global shell collision resolution.

func (Collector) CommitTrackers

func (c Collector) CommitTrackers()

CommitTrackers promotes a completed refresh's generation-local activity state. Canceled/stale refreshes are simply never committed.

func (Collector) ForRefresh

func (c Collector) ForRefresh(maxCaptures int, claims ...ShellClaims) Collector

ForRefresh returns a collector sharing provider history with its parent while independently bounding pane captures for one refresh generation.

func (Collector) HostPane added in v1.4.0

func (c Collector) HostPane(id string) Collector

HostPane overrides which pane ID counts as the pane hosting this process. The default comes from TMUX_PANE; tests set a fake one so the exclusion can be exercised against a scripted pane list.

func (Collector) ListPanes

func (c Collector) ListPanes(ctx context.Context) ([]Pane, error)

ListPanes takes the single global tmux inventory used by an Overview refresh.

func (Collector) Metrics

func (c Collector) Metrics() MetricsSnapshot

func (Collector) RefreshProjectStatus

func (c Collector) RefreshProjectStatus(ctx context.Context, previous ProjectResult, allRoots []string, panes []Pane) ProjectResult

RefreshProjectStatus reuses an immutable successful project inventory and refreshes only live tmux/provider evidence. It performs no Git or metadata reads, allowing visible polling to stay cheaper than explicit inventory refreshes.

func (Collector) SeedTrackers added in v0.96.0

func (c Collector) SeedTrackers(seed map[string]agentactivity.Tracker) Collector

SeedTrackers installs persisted activity as the collector's starting state. Entries already observed in this process win: a live reading is always better evidence than a restored one.

func (Collector) TrackerSnapshot added in v0.96.0

func (c Collector) TrackerSnapshot() map[string]agentactivity.Tracker

TrackerSnapshot copies committed activity for persistence.

func (Collector) ValidateWorkspace

func (c Collector) ValidateWorkspace(ctx context.Context, workspace Workspace) error

ValidateWorkspace rechecks a card's exact durable identity without creating, migrating, reconciling, or mutating project state.

func (Collector) WithDefaults

func (c Collector) WithDefaults() Collector

func (Collector) WithShellClaims

func (c Collector) WithShellClaims(claims ShellClaims) Collector

type ExecRunner

type ExecRunner struct{}

func (ExecRunner) Output

func (ExecRunner) Output(ctx context.Context, name string, args ...string) ([]byte, error)

type Item added in v0.98.0

type Item struct {
	ID                      string
	ProjectKey, ProjectName string
	ProjectRoot             string
	Kind                    Kind
	Key, Name, Path, Branch string
	TaskID                  string
	Provider                string
	PaneID, TmuxName        string
	Live, Ambiguous         bool
	IsMain                  bool
	Agent                   *agentstatus.Presentation
	ObservedAt              time.Time
}

Item is the read-only catalog row shared by the Agents board and the global Workspaces browser. Agent is nil for plain shells and worktrees: they are given presentation buckets by the list projection rather than a fabricated semantic state.

func Catalog added in v0.98.0

func Catalog(result ProjectResult) []Item

Catalog projects a whole project result: every durable shell and Git worktree it holds, agent-backed or not.

type Kind

type Kind string
const (
	KindWorktree Kind = "worktree"
	KindShell    Kind = "shell"
)

type MetricsSnapshot

type MetricsSnapshot struct {
	ProjectOps, Captures, MaxCaptures, TrackerCommits int64
}

type Pane

type Pane struct {
	ID, Session, Path, Command, Title string
	PID                               int
	Dead                              bool
}

type ProjectResult

type ProjectResult struct {
	ProjectKey, ProjectName, ProjectRoot string
	Workspaces                           []Workspace
	ObservedAt                           time.Time
	Err                                  error
}

type RefreshMetrics

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

RefreshMetrics contains privacy-safe operation and concurrency counters for an in-memory refresh. It never includes project paths, pane IDs, or output.

type Runner

type Runner interface {
	Output(context.Context, string, ...string) ([]byte, error)
}

type ShellClaims

type ShellClaims struct {
	Sessions map[string]bool
	Owners   map[string]string
}

ShellClaims records globally reserved agent-shell sessions and their unique owning project. An empty owner marks a collision that no project may claim.

func BuildShellClaims

func BuildShellClaims(results []ProjectResult) ShellClaims

type Workspace

type Workspace struct {
	ID, ProjectKey, ProjectName, ProjectRoot string
	Kind                                     Kind
	Key, Name, Path, Branch, TaskID          string
	TmuxName, PaneID, Provider, Namespace    string
	// Plain marks a workspace collected with no agent evidence at all: a Git
	// worktree with no recorded agent. It is the catalog's honest answer to
	// "is there an agent here?", and it is what keeps the Agents projection
	// identical to what it collected before the catalog carried plain rows.
	Plain bool
	// IsMain is explicit inventory identity, resolved while collecting Git's
	// worktree list. Presentation callers must not guess it from a name.
	IsMain bool
	// The remaining worktree state git reports. They exist so a presentation
	// surface can refuse an action for the same reasons the project surface
	// refuses it: a locked worktree cannot be removed, a bare or detached one
	// has no branch to act on, and a prunable or missing one is only
	// metadata. IsMissing means the directory is gone, whether git has noticed
	// (prunable) or not.
	IsBare, IsDetached, IsLocked, IsPrunable, IsMissing bool
	// Live and Ambiguous describe session health, which is not the same
	// question as agent activity: a plain shell or an agentless worktree can
	// own a live pane while having no agent semantics at all. Keeping them
	// separate is what lets the catalog carry plain workspaces without
	// fabricating an agentstatus value for them.
	Live, Ambiguous bool
	Presentation    agentstatus.Presentation
	ObservedAt      time.Time
	// CreatedAt is the shell manifest's record of when this identity was
	// written. Empty for worktrees, which have no such record.
	CreatedAt time.Time
}

func AgentWorkspaces added in v0.98.0

func AgentWorkspaces(workspaces []Workspace) []Workspace

AgentWorkspaces is the agent-only projection the Kanban board consumes. It excludes exactly the items with no agent evidence and changes nothing else, so the board keeps the full shared semantic matrix it had before the catalog carried plain workspaces.

func (Workspace) HasAgent added in v0.98.0

func (w Workspace) HasAgent() bool

HasAgent reports durable or detected agent evidence. A worktree earns it from its recorded `agent` file; a shell earns it from a configured agent type or from live identification, which is why an unidentified shell can still become an agent on a later status poll. Everything else is plain.

func (Workspace) Item added in v0.98.0

func (w Workspace) Item() Item

Item projects one collected workspace into its catalog row.

Jump to

Keyboard shortcuts

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