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
- func CodexDayDir(root string, day time.Time) string
- func CodexDays(root string, now time.Time, n int) []string
- func CodexFirstLine(path string) (id any, ok bool)
- func ForkIDs() map[string]bool
- func ProjectName(dir string) string
- type AntigravityLister
- type ClaudeLister
- type ClaudeMeta
- type CodexEntry
- type CodexLister
- type Recent
Constants ¶
const RecentDays = 30
RecentDays is how far back Codex's day folders are looked into.
Variables ¶
This section is empty.
Functions ¶
func CodexDayDir ¶
CodexDayDir is the folder Codex keeps one local day's sessions in: <root>/YYYY/MM/DD.
func CodexFirstLine ¶
CodexFirstLine is the session id a Codex transcript's first line names (its session_meta), or nil.
func ForkIDs ¶
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 ¶
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
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.
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.
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.