Documentation
¶
Overview ¶
Package session provides read-only SQLite access to opencode's local session store at $XDG_DATA_HOME/opencode/opencode.db. It is used by the public StatSession helper to surface session metadata without spinning up a Client.
Index ¶
Constants ¶
const DatabaseFile = "opencode.db"
DatabaseFile is the filename opencode writes its SQLite store to, relative to the opencode data directory ($XDG_DATA_HOME/opencode).
Variables ¶
var ErrNotFound = errors.New("session not found")
ErrNotFound is returned when a session row is missing or the database file does not exist on disk.
Functions ¶
func DatabasePath ¶
DatabasePath returns the opencode DB path given the opencode data directory (the directory that would contain opencode.db).
Types ¶
type ListOptions ¶
type ListOptions struct {
// Cwd, when non-empty, restricts rows to those whose directory
// matches exactly.
Cwd string
// IncludeArchived, when false, excludes rows with a non-null
// time_archived.
IncludeArchived bool
// Limit caps the number of returned rows. Zero or negative means
// no limit.
Limit int
}
ListOptions controls the shape of a List result.
type Row ¶
type Row struct {
ID string
ProjectID string
ParentID string
Slug string
Directory string
Title string
Version string
SummaryAdditions *int64
SummaryDeletions *int64
SummaryFiles *int64
CreatedAt time.Time
UpdatedAt time.Time
CompactingAt *time.Time
ArchivedAt *time.Time
WorkspaceID string
MessageCount int64
}
Row mirrors the subset of opencode's `session` table that the SDK surfaces to callers, plus a joined message count.
func List ¶
List reads every session row from the local SQLite store, subject to opts. Rows are ordered by time_updated DESC so the most recently touched sessions come first. Missing database files yield ErrNotFound to mirror Lookup's semantics.