Documentation
¶
Index ¶
- func CurrentWorkspacePath() string
- func DefaultDir() (string, error)
- func ExportSessionMarkdown(ses *Session) string
- func NormalizeWorkspacePath(path string) string
- type JSONLStore
- func (s *JSONLStore) AppendCheckpoint(ses *Session, compactedMessages []provider.Message, tokenCount int) error
- func (s *JSONLStore) AppendMessage(ses *Session, msg provider.Message) error
- func (s *JSONLStore) CleanupOlderThan(before time.Time) (int, error)
- func (s *JSONLStore) Delete(id string) error
- func (s *JSONLStore) Dir() string
- func (s *JSONLStore) EnsureMeta(ses *Session) error
- func (s *JSONLStore) ExportMarkdown(id string) (string, error)
- func (s *JSONLStore) List() ([]*Session, error)
- func (s *JSONLStore) Load(id string) (*Session, error)
- func (s *JSONLStore) Save(ses *Session) error
- type Session
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentWorkspacePath ¶ added in v1.0.23
func CurrentWorkspacePath() string
func DefaultDir ¶
DefaultDir returns the default session directory.
func ExportSessionMarkdown ¶
ExportSessionMarkdown renders a Session to markdown.
func NormalizeWorkspacePath ¶ added in v1.0.23
Types ¶
type JSONLStore ¶
type JSONLStore struct {
// contains filtered or unexported fields
}
JSONLStore implements Store using JSONL files.
func NewDefaultStore ¶
func NewDefaultStore() (*JSONLStore, error)
NewDefaultStore creates a store in the default directory.
func NewJSONLStore ¶
func NewJSONLStore(dir string) (*JSONLStore, error)
NewJSONLStore creates a store rooted at dir (creates dir if needed).
func (*JSONLStore) AppendCheckpoint ¶ added in v1.1.43
func (s *JSONLStore) AppendCheckpoint(ses *Session, compactedMessages []provider.Message, tokenCount int) error
AppendCheckpoint appends a checkpoint record to the session JSONL file. The checkpoint captures the compacted messages state after a summarize operation, so that future --resume operations can skip re-compacting old history.
func (*JSONLStore) AppendMessage ¶
func (s *JSONLStore) AppendMessage(ses *Session, msg provider.Message) error
AppendMessage atomically appends a single message to the session's JSONL file. This is more efficient than Save() for incremental updates.
func (*JSONLStore) CleanupOlderThan ¶
func (s *JSONLStore) CleanupOlderThan(before time.Time) (int, error)
CleanupOlderThan removes sessions older than the given time. Returns count removed.
func (*JSONLStore) Delete ¶
func (s *JSONLStore) Delete(id string) error
Delete removes a session file and its index entry.
func (*JSONLStore) EnsureMeta ¶
func (s *JSONLStore) EnsureMeta(ses *Session) error
EnsureMeta writes the meta record if the session file doesn't exist yet. If the session has no user interaction, no file is created.
func (*JSONLStore) ExportMarkdown ¶
func (s *JSONLStore) ExportMarkdown(id string) (string, error)
ExportMarkdown renders a session as a markdown document.
func (*JSONLStore) List ¶
func (s *JSONLStore) List() ([]*Session, error)
List returns all sessions sorted by UpdatedAt descending (uses index for speed).
func (*JSONLStore) Load ¶
func (s *JSONLStore) Load(id string) (*Session, error)
Load reads a session from its JSONL file.
func (*JSONLStore) Save ¶
func (s *JSONLStore) Save(ses *Session) error
Save writes the full session as a JSONL file (atomic). If the session has no user interaction, the file is deleted instead.
type Session ¶
type Session struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Title string `json:"title"`
Workspace string `json:"workspace,omitempty"`
Vendor string `json:"vendor"`
Endpoint string `json:"endpoint"`
Model string `json:"model"`
Messages []provider.Message `json:"messages,omitempty"`
// Cost data stored as opaque JSON to avoid circular dependency with cost package.
CostJSON []byte `json:"cost,omitempty"`
}
Session represents a single conversation session.
func NewSession ¶
NewSession creates a new Session with a generated ID.
func (*Session) HasUserInteraction ¶ added in v1.1.50
HasUserInteraction returns true if the session contains at least one user message with actual text content. Sessions without user interaction (e.g., created then immediately closed) should not be persisted to avoid accumulating empty session files.
type Store ¶
type Store interface {
// Save persists the current state of a session (atomic write).
Save(s *Session) error
// Load retrieves a session by ID.
Load(id string) (*Session, error)
// List returns all sessions, sorted by UpdatedAt descending.
List() ([]*Session, error)
// Delete removes a session by ID.
Delete(id string) error
// ExportMarkdown renders a session as a markdown document.
ExportMarkdown(id string) (string, error)
// CleanupOlderThan removes sessions whose UpdatedAt is before the given time.
CleanupOlderThan(before time.Time) (int, error)
// AppendCheckpoint persists a checkpoint of compacted messages after summarize.
// The checkpoint allows --resume to skip re-compacting old history.
AppendCheckpoint(s *Session, compactedMessages []provider.Message, tokenCount int) error
}
Store is the interface for session persistence.