sessions

package
v0.0.76 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatInfoText

func FormatInfoText(info *SessionInfo, home string, now time.Time) string

func FormatListTable

func FormatListTable(sessions []Session, home string, now time.Time) string

func FormatListTableWithHits added in v0.0.59

func FormatListTableWithHits(matches []SessionMatch, home string, now time.Time, colorMode string) string

FormatListTableWithHits formats matching sessions like FormatListTable, with indented hit lines under each row. colorMode is "never" | "always" | "auto". Output has no trailing newline (same TrimRight style as FormatListTable).

Types

type MatchHit added in v0.0.59

type MatchHit struct {
	File       string // "summary.json", "chat_history.jsonl"
	Line       int    // 1-based
	Part       string // title, session_summary, cwd, user, assistant, ...
	Snippet    string // one-line excerpt
	MatchStart int    // byte offset into Snippet
	MatchLen   int    // length of match in Snippet
}

MatchHit is one content match inside a session file.

type RelocateCWDOptions added in v0.0.62

type RelocateCWDOptions struct {
	// GrokHome is the Grok home directory. Empty → $GROK_HOME or ~/.grok.
	GrokHome string
}

RelocateCWDOptions configures RelocateCWD.

type RelocateCWDResult added in v0.0.62

type RelocateCWDResult struct {
	OldCWD, NewCWD, OldSessionDir, NewSessionDir string
	FilesTouched                                 []string // optional
}

RelocateCWDResult reports paths after a successful relocate.

func RelocateCWD added in v0.0.62

func RelocateCWD(sessionID, targetDir string, opts *RelocateCWDOptions) (*RelocateCWDResult, error)

RelocateCWD relocates a Grok session's workspace cwd by updating explicit JSON fields and moving the session directory under the URL-encoded new cwd key.

Call shape: sessionID first (required), targetDir second (required), opts last (nil OK).

type Session

type Session struct {
	ID              string
	LastActiveAt    time.Time
	CWD             string
	Title           string
	Path            string
	NumChatMessages int
}

func Find

func Find(grokHome, sessionID string) (Session, error)

func List

func List(grokHome string, limit int) ([]Session, error)

type SessionInfo

type SessionInfo struct {
	Session
	CreatedAt, UpdatedAt        time.Time
	NumMessages                 int
	CurrentModelID              string
	AgentName                   string
	SandboxProfile              string
	GitRootDir                  string
	HeadBranch                  string
	HeadCommit                  string
	SessionDir                  string
	SummaryPath                 string
	UpdatesPath                 string
	SignalsPath                 string
	PromptContextPath           string
	UpdatesExists               bool
	SignalsExists               bool
	PromptContextExists         bool
	ContextTokensUsed           int
	ContextWindowTokens         int
	ContextWindowUsage          int
	TotalTokensBeforeCompaction int
}

func Info

func Info(grokHome, sessionID string) (*SessionInfo, error)

type SessionMatch added in v0.0.59

type SessionMatch struct {
	Session
	Hits []MatchHit // full hit list; formatter caps display at 5
}

SessionMatch is a session that matched a grep pattern, with all hits.

func ListWithGrep added in v0.0.59

func ListWithGrep(grokHome string, limit int, pattern string) ([]SessionMatch, error)

ListWithGrep discovers sessions, keeps those with ≥1 case-insensitive literal hit in summary.json or chat_history.jsonl, sorts by last_active_at desc, then applies limit.

Jump to

Keyboard shortcuts

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