session

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePath added in v0.3.0

func DecodePath(dirName string) string

DecodePath converts a Claude Code project directory name back to a filesystem path. -Users-name-dev-project → /Users/name/dev/project Note: this is ambiguous when directory names contain literal hyphens. Use ValidateDecodedPath to check if the result exists on disk.

func DefaultClaudeDir

func DefaultClaudeDir() string

DefaultClaudeDir returns the default ~/.claude path.

func EncodePath added in v0.3.0

func EncodePath(fsPath string) string

EncodePath converts a filesystem path to Claude Code's project directory name. /Users/name/dev/project → -Users-name-dev-project

Types

type Discoverer

type Discoverer struct {
	ClaudeDir string
}

Discoverer finds sessions across Claude project directories.

func (*Discoverer) ListAllSessions

func (d *Discoverer) ListAllSessions() ([]Info, error)

ListAllSessions returns sessions across all projects, sorted by modification time.

func (*Discoverer) ListProjects

func (d *Discoverer) ListProjects() ([]string, error)

ListProjects returns all project directory paths under the claude dir.

func (*Discoverer) ListSessions

func (d *Discoverer) ListSessions(projectDir string) ([]Info, error)

ListSessions returns sessions for a specific project directory.

type Info

type Info struct {
	SessionID    string
	FullPath     string
	FirstPrompt  string
	MessageCount int
	Created      time.Time
	Modified     time.Time
	GitBranch    string
	ProjectPath  string
	ProjectName  string
	FileSizeMB   float64
	IsSidechain  bool
	ContextStats *QuickStats
}

Info holds metadata about a single conversation session.

func (Info) IsActive

func (i Info) IsActive() bool

IsActive returns true if the session was modified within the last 60 seconds.

type OrphanedProject added in v0.3.0

type OrphanedProject struct {
	DirName       string // directory name under projects/
	DecodedPath   string // decoded filesystem path
	FullDirPath   string // full path to the project directory
	SessionCount  int    // number of JSONL files
	TotalMessages int    // total messages across all sessions
}

OrphanedProject represents a project directory whose decoded path no longer exists.

func FindOrphans added in v0.3.0

func FindOrphans(claudeDir string) ([]OrphanedProject, error)

FindOrphans scans all project directories and returns those whose decoded filesystem path no longer exists on disk.

type QuickStats

type QuickStats struct {
	ContextTokens        int
	ContextPct           float64
	ImageCount           int
	CompactionCount      int
	LastCompactionBefore int
	LastCompactionAfter  int
	EstimatedCost        float64
	Model                string
}

QuickStats holds lightweight context stats for the session browser.

type RelocatePlan added in v0.3.0

type RelocatePlan struct {
	OldPath      string
	NewPath      string
	OldDirName   string
	NewDirName   string
	SessionCount int
	IndexEntries int
	OldDirExists bool
	NewDirExists bool
}

RelocatePlan describes what a relocation would do without executing it.

func PlanRelocate added in v0.3.0

func PlanRelocate(claudeDir, fromPath, toPath string) (*RelocatePlan, error)

PlanRelocate creates a dry-run plan for relocating sessions.

type RelocateResult added in v0.3.0

type RelocateResult struct {
	OldDirName    string
	NewDirName    string
	SessionsFound int
	IndexUpdated  bool
	CWDUpdated    int // entries with CWD rewritten
	DryRun        bool
}

RelocateResult holds the result of a session relocation operation.

func Relocate added in v0.3.0

func Relocate(claudeDir, fromPath, toPath string, updateCWD bool) (*RelocateResult, error)

Relocate moves sessions from one project path to another. This renames the project directory and updates sessions-index.json. If updateCWD is true, also rewrites CWD fields in JSONL entries.

Jump to

Keyboard shortcuts

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