cuxdata

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package cuxdata reads cux's on-disk state. cuxdeck never links cux (its packages are internal); the JSON files under ~/.cux are the contract, and mutations go through the cux CLI so business rules stay in one place.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaudeProjectsDir

func ClaudeProjectsDir() string

ClaudeProjectsDir is where Claude Code stores session transcripts.

func FindTranscript

func FindTranscript(id string) string

FindTranscript resolves a conversation id to its transcript path, or "" if no project holds it. IDs are validated by the caller.

func LoadUsage

func LoadUsage() map[string]AccountUsage

func Root

func Root() string

Root returns cux's data directory (~/.cux on macOS/Windows, $XDG_DATA_HOME/cux on Linux).

func TasksDir

func TasksDir() string

TasksDir is where Claude Code keeps per-conversation task files.

Types

type Account

type Account struct {
	Slot    int    `json:"slot"`
	Email   string `json:"email"`
	UUID    string `json:"uuid"`
	OrgUUID string `json:"orgUuid,omitempty"`
	Alias   string `json:"alias,omitempty"`
}

func (Account) CacheKey

func (a Account) CacheKey() string

CacheKey mirrors cux's per-seat usage-cache key.

type AccountUsage

type AccountUsage struct {
	FiveHour     *Window   `json:"five_hour,omitempty"`
	SevenDay     *Window   `json:"seven_day,omitempty"`
	PolledAt     time.Time `json:"polled_at"`
	TokenExpired bool      `json:"token_expired,omitempty"`
}

type Conversation

type Conversation struct {
	ID        string    `json:"id"`
	CWD       string    `json:"cwd"`
	Title     string    `json:"title"`
	UpdatedAt time.Time `json:"updatedAt"`
	Active    bool      `json:"active"` // transcript written within the last 2 minutes
	Path      string    `json:"-"`
}

Conversation is one Claude Code transcript on disk. Unlike Session it does not depend on the cux registry at all — it is discovered straight from ~/.claude/projects, so conversations started outside cux (desktop app tabs, plain `claude`) show up too, and a dead wrapper can never leave a ghost behind.

func LoadConversations

func LoadConversations(limit int) []Conversation

LoadConversations returns the most recently touched transcripts across every project, newest first.

type Deck

type Deck struct {
	DeckID    string    `json:"deckId"`   // stable machine+install identifier
	Hostname  string    `json:"hostname"` // human label in the fleet view
	OS        string    `json:"os"`
	Version   string    `json:"version"` // cuxdeck version serving this deck
	SnappedAt time.Time `json:"snappedAt"`

	Sessions   []Session               `json:"sessions"`
	Accounts   map[string]Account      `json:"accounts"`
	Usage      map[string]AccountUsage `json:"usage"`
	Projects   map[string]Project      `json:"projects,omitempty"`
	ActiveSlot int                     `json:"activeSlot"`
}

Deck is the identity and full snapshot of one machine's cux state. Every API response carries a Deck so the phone can namespace it: the fleet view is assembled client-side by merging the snapshots from several decks, with no central server holding them. DeckID is stable per machine+install so a deck keeps its identity across restarts and tunnel-address changes.

func Snapshot

func Snapshot(version string, clock func() time.Time) Deck

Snapshot reads everything the panel needs in one pass and stamps it with this machine's identity. The zero values of missing pieces (no projects, empty usage) are valid — a fresh cux install snapshots cleanly. version is the caller's build string.

clock is injected so callers/tests control SnappedAt; pass time.Now.

type Project

type Project struct {
	Name  string `json:"name"`
	Dir   string `json:"dir"`
	Slots []int  `json:"slots,omitempty"`
}

type Session

type Session struct {
	PID        int       `json:"pid"`
	CWD        string    `json:"cwd"`
	SessionID  string    `json:"sessionId,omitempty"`
	Seat       string    `json:"seat,omitempty"`
	State      string    `json:"state"`
	Attachable bool      `json:"attachable,omitempty"`
	Detail     string    `json:"detail,omitempty"`
	StartedAt  time.Time `json:"startedAt"`
	UpdatedAt  time.Time `json:"updatedAt"`
}

Session is one running cux wrapper, from the heartbeat registry.

func LoadSessions

func LoadSessions() []Session

type State

type State struct {
	ActiveSlot int                `json:"activeSlot"`
	Accounts   map[string]Account `json:"accounts"`
	Projects   map[string]Project `json:"projects,omitempty"`
}

func LoadState

func LoadState() (State, error)

type Task

type Task struct {
	ID      string `json:"id"`
	Subject string `json:"subject"`
	Status  string `json:"status"`
}

Task is one entry in Claude Code's on-disk task store (~/.claude/tasks/<session-id>/<n>.json). This store is the live, authoritative state: every session that resumes the conversation — including under a different account after a cux seat swap — updates these files. Reconstructing task state from a single transcript goes stale the moment another session touches the list; this never does.

func LoadTasks

func LoadTasks(id string) (tasks []Task, ok bool)

LoadTasks reads the current task list for a conversation. ok reports whether the store exists for this id at all — an existing-but-empty dir means "no open tasks" (show nothing), while a missing dir means the CLI never wrote one (callers may fall back to transcript data).

type Window

type Window struct {
	Utilization float64    `json:"utilization"`
	ResetsAt    *time.Time `json:"resets_at,omitempty"`
}

Jump to

Keyboard shortcuts

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