{"modulePath":"github.com/daemon365/supercode","version":"v0.0.0-20260802105639-f56615fdcfd1","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package session\n\nPackage session stores resumable SuperCode conversations as local JSON.\n\n## Constants\n\n```go\nconst CurrentVersion = 4\n```\n\n## Variables\n\n```go\nvar ErrSessionConflict = errors.New(\"session changed in another process\")\n```\n\n## Types\n\n```go\ntype Checkpoint struct {\n\tBaseMessageCount int                `json:\"base_message_count,omitempty\"`\n\tBaseRevision     uint64             `json:\"base_revision,omitempty\"`\n\tRevision         uint64             `json:\"revision,omitempty\"`\n\tReplace          bool               `json:\"replace,omitempty\"`\n\tMessages         []provider.Message `json:\"messages\"`\n\tPlan             taskstate.Plan     `json:\"plan,omitempty\"`\n\tGoal             *taskstate.Goal    `json:\"goal,omitempty\"`\n\tAgents           json.RawMessage    `json:\"agents,omitempty\"`\n\tTitle            string             `json:\"title,omitempty\"`\n\tMode             string             `json:\"mode,omitempty\"`\n}\n```\n\n```go\ntype Event struct {\n\tSequence uint64          `json:\"sequence,omitempty\"`\n\tRevision uint64          `json:\"revision,omitempty\"`\n\tAt       time.Time       `json:\"at\"`\n\tType     string          `json:\"type\"`\n\tPayload  json.RawMessage `json:\"payload,omitempty\"`\n}\n```\nEvent is an append-only record used for diagnostics and crash recovery.\n\n```go\ntype Metadata struct {\n\tID           string\n\tParentID     string\n\tTitle        string\n\tWorkspace    string\n\tModel        string\n\tSearchText   string\n\tUpdatedAt    time.Time\n\tArchivedAt   *time.Time\n\tMessageCount int\n}\n```\nMetadata is the lightweight session-picker/search representation. It never hydrates messages or image assets; Load resolves the selected session.\n\n```go\ntype RepairReport struct {\n\tScanned int      `json:\"scanned\"`\n\tIndexed int      `json:\"indexed\"`\n\tInvalid []string `json:\"invalid,omitempty\"`\n}\n```\n\n```go\ntype Session struct {\n\tVersion           int                `json:\"version,omitempty\"`\n\tID                string             `json:\"id\"`\n\tParentID          string             `json:\"parent_id,omitempty\"`\n\tTitle             string             `json:\"title,omitempty\"`\n\tWorkspace         string             `json:\"workspace\"`\n\tModel             string             `json:\"model\"`\n\tMode              string             `json:\"mode,omitempty\"`\n\tCreatedAt         time.Time          `json:\"created_at\"`\n\tUpdatedAt         time.Time          `json:\"updated_at\"`\n\tRevision          uint64             `json:\"revision,omitempty\"`\n\tLastEventSequence uint64             `json:\"last_event_sequence,omitempty\"`\n\tMessages          []provider.Message `json:\"messages\"`\n\tPlan              taskstate.Plan     `json:\"plan,omitempty\"`\n\tGoal              *taskstate.Goal    `json:\"goal,omitempty\"`\n\tAgents            json.RawMessage    `json:\"agents,omitempty\"`\n\tArchivedAt        *time.Time         `json:\"archived_at,omitempty\"`\n}\n```\n\n```go\ntype Store struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewStore(directory string) (*Store, error)\n```\n\n```go\nfunc (s *Store) Append(id, eventType string, payload any) error\n```\nAppend writes and fsyncs one event without rewriting the session snapshot.\n\n```go\nfunc (s *Store) Archive(id string) (Session, error)\n```\n\n```go\nfunc (s *Store) Commit(value Session) error\n```\nCommit durably records a completed turn without rewriting the full session history every time. A full snapshot is written on the first commit and then periodically; intervening commits append only the new messages and update the lightweight search index. Load replays those deltas after the snapshot.\n\n```go\nfunc (s *Store) Delete(id string) error\n```\n\n```go\nfunc (s *Store) Events(id string) ([]Event, error)\n```\n\n```go\nfunc (s *Store) Fork(id string) (Session, error)\n```\n\n```go\nfunc (s *Store) Latest(workspace string) (Session, error)\n```\n\n```go\nfunc (s *Store) List(workspace string, limit int) ([]Session, error)\n```\n\n```go\nfunc (s *Store) ListAll(workspace string, limit int, includeArchived bool) ([]Session, error)\n```\nListAll is the session picker backend when archived threads should be shown.\n\n```go\nfunc (s *Store) ListMetadata(workspace, query string, limit int, includeArchived bool) (items []Metadata, warnings []string, err error)\n```\nListMetadata performs index-only filtering and sorting. warnings contains corrupt snapshot names skipped by an automatic repair.\n\n```go\nfunc (s *Store) Load(id string) (Session, error)\n```\n\n```go\nfunc (s *Store) New(workspace, model string) (Session, error)\n```\n\n```go\nfunc (s *Store) Rename(id, title string) (Session, error)\n```\n\n```go\nfunc (s *Store) Repair() (RepairReport, error)\n```\nRepair rebuilds index.json from authoritative snapshots plus every newer recovery event. Invalid sessions are reported and left untouched.\n\n```go\nfunc (s *Store) Save(value Session) error\n```\n\n```go\nfunc (s *Store) Search(workspace, query string, limit int, includeArchived bool) ([]Session, error)\n```\nSearch uses the file-backed index and includes message text in addition to title, ID, model, and workspace metadata.\n\n","path":"github.com/daemon365/supercode/internal/session","name":"session","synopsis":"Package session stores resumable SuperCode conversations as local JSON.","isRedistributable":true}
