sessions

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 21 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 sessions lists the conversations Claude Code and Codex keep on disk for a working folder, as the runtime's conversation lists show them.

Index

Constants

View Source
const RecentDays = 30

RecentDays is how far back Codex's day folders are looked into.

Variables

This section is empty.

Functions

func CodexDayDir

func CodexDayDir(root string, day time.Time) string

CodexDayDir is the folder Codex keeps one local day's sessions in: <root>/YYYY/MM/DD.

func CodexDays

func CodexDays(root string, now time.Time, n int) []string

CodexDays are the day folders of the last n local days, today first.

func CodexFirstLine

func CodexFirstLine(path string) (id any, ok bool)

CodexFirstLine is the session id a Codex transcript's first line names (its session_meta), or nil.

func ForkIDs

func ForkIDs() map[string]bool

ForkIDs are the session ids of the conversation forks running on this machine right now (`--fork-session` with `--session-id <id>`): a fork answering a side question about a conversation is not a conversation of its own and stays out of the lists.

func ProjectName

func ProjectName(dir string) string

ProjectName is the folder Claude Code keeps a working folder's transcripts in: every UTF-16 unit that is not an ASCII letter or digit becomes "-", and a name longer than 200 is cut and gets a hash of the path.

Types

type AntigravityLister

type AntigravityLister struct{ Root string }

AntigravityLister lists verified native brain session directories. It never selects a session merely because it is newest, or treats an artifact as a transcript.

func NewAntigravityLister

func NewAntigravityLister(home string) *AntigravityLister

func (*AntigravityLister) Find

func (l *AntigravityLister) Find(id string) (Recent, bool)

Find accepts only a UUID and the exact native transcript filename. Cwd remains unknown: the native JSONL records do not establish a working directory.

func (*AntigravityLister) Recent

func (l *AntigravityLister) Recent(skip func(string) bool, limit int) []Recent

type ClaudeLister

type ClaudeLister struct {
	ProjectsDir string
	// Workers bounds the transcripts read at once.
	Workers int
	// Lines, when set, gives what a transcript a conversation is live on gained, read once for all its readers, and
	// a transcript that did not grow is not opened at all; nil opens every transcript at every list.
	Lines *transcriptindex.Follower
	// contains filtered or unexported fields
}

ClaudeLister lists the transcripts of a working folder, remembering how far it read each.

func NewClaudeLister

func NewClaudeLister(home string) *ClaudeLister

NewClaudeLister lists under the projects folder of $CLAUDE_CONFIG_DIR, else <home>/.claude.

func (*ClaudeLister) Find added in v0.15.40

func (l *ClaudeLister) Find(id string) (Recent, bool)

Find is the Claude session with this id wherever it ran, false when no transcript of it is kept. id must be a plain session id (no path in it).

func (*ClaudeLister) List

func (l *ClaudeLister) List(cwd string, skip func(id string) bool) []ClaudeMeta

List is every conversation of cwd, the most recently active first. skip leaves out ids that are not conversations (forks answering a side question).

func (*ClaudeLister) ProjectDir

func (l *ClaudeLister) ProjectDir(cwd string) string

ProjectDir is the transcripts folder of a working folder.

func (*ClaudeLister) Recent added in v0.15.40

func (l *ClaudeLister) Recent(skip func(id string) bool, limit int) []Recent

Recent is the newest sessions in every folder, most recently active first, at most limit, leaving out the ones skip names and the ones nobody has said anything in.

type ClaudeMeta

type ClaudeMeta struct {
	SessionID      string `json:"sessionId"`
	StartedAt      string `json:"startedAt"`
	LastActivityAt string `json:"lastActivityAt"`
	FirstMessage   string `json:"firstMessage"`
	TurnCount      int    `json:"turnCount"`
	// contains filtered or unexported fields
}

ClaudeMeta is one conversation in a working folder's list.

type CodexEntry

type CodexEntry struct {
	SessionID        any      `json:"sessionId"`
	JSONLPath        string   `json:"jsonlPath"`
	StartedAt        float64  `json:"startedAt"`
	LastActivityAt   float64  `json:"lastActivityAt"`
	Cwd              any      `json:"cwd"`
	Model            any      `json:"model"`
	FirstUserMessage *string  `json:"firstUserMessage"`
	TurnCount        int      `json:"turnCount"`
	TotalTokens      *float64 `json:"totalTokens"`
}

CodexEntry is one Codex session in a working folder's list.

type CodexLister

type CodexLister struct {
	Root string
	Now  func() time.Time
	// contains filtered or unexported fields
}

CodexLister lists Codex sessions, keeping what it read of each file until the file changes.

func NewCodexLister

func NewCodexLister(home string) *CodexLister

NewCodexLister lists under <home>/.codex/sessions.

func (*CodexLister) Find added in v0.15.40

func (l *CodexLister) Find(id string) (Recent, bool)

Find is the Codex session with this id among those of the last RecentDays days.

func (*CodexLister) List

func (l *CodexLister) List(cwd string, daysBack int) (sessions []CodexEntry, scannedDirs, scannedFiles int)

List is the sessions of the last daysBack days started in cwd, the most recently active first, with how many day folders and files were looked at.

func (*CodexLister) Recent added in v0.15.40

func (l *CodexLister) Recent(skip func(id string) bool, limit int) []Recent

Recent is the newest Codex sessions of the last RecentDays days in every folder, most recently active first, at most limit, leaving out the ones skip names.

type Recent added in v0.15.40

type Recent struct {
	SessionID string
	// Title is the agent's own name for the session, else the first thing the person asked.
	Title string
	Cwd   string
	// Path is the session's transcript.
	Path      string
	UpdatedAt time.Time
	Turns     int
}

Recent is one agent session found on the machine without asking for a folder: what "continue a session from the terminal" lists.

Jump to

Keyboard shortcuts

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