Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateName(name string) error
- type FileStore
- func (fs *FileStore) Create(session *Session) error
- func (fs *FileStore) Delete(name string) error
- func (fs *FileStore) Exists(name string) bool
- func (fs *FileStore) Get(name string) (*Session, error)
- func (fs *FileStore) List() ([]*Session, error)
- func (fs *FileStore) LoadSettings(name string) (*Settings, error)
- func (fs *FileStore) LoadSystemPrompt(name string) (string, error)
- func (fs *FileStore) SaveSettings(name string, settings *Settings) error
- func (fs *FileStore) SaveSystemPrompt(name string, content string) error
- func (fs *FileStore) Update(session *Session) error
- type Metadata
- type Permissions
- type Session
- type Settings
- type Store
Constants ¶
const ( // MinNameLength is the minimum allowed session name length MinNameLength = 2 // MaxNameLength is the maximum allowed session name length MaxNameLength = 64 )
Variables ¶
var ( // ErrInvalidName is returned when session name validation fails ErrInvalidName = errors.New("invalid session name") )
Functions ¶
func ValidateName ¶
ValidateName checks if a session name is valid. Returns an error if the name is invalid, with details about why.
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore implements Store using the filesystem.
func NewFileStore ¶
NewFileStore creates a new FileStore.
func (*FileStore) LoadSettings ¶
LoadSettings loads settings.json for a session (returns nil if not exists).
func (*FileStore) LoadSystemPrompt ¶
LoadSystemPrompt loads system-prompt.md for a session (returns empty if not exists).
func (*FileStore) SaveSettings ¶
SaveSettings saves settings.json for a session.
func (*FileStore) SaveSystemPrompt ¶
SaveSystemPrompt saves system-prompt.md for a session.
type Metadata ¶
type Metadata struct {
Name string `json:"name"`
SessionID string `json:"sessionId"`
TranscriptPath string `json:"transcriptPath,omitempty"`
Created time.Time `json:"created"`
LastAccessed time.Time `json:"lastAccessed"`
ParentSession string `json:"parentSession,omitempty"`
IsForkedSession bool `json:"isForkedSession"`
IsIncognito bool `json:"isIncognito"`
PreviousSessionIDs []string `json:"previousSessionIds,omitempty"`
SystemPromptMode string `json:"systemPromptMode,omitempty"` // "append" (default) or "replace"
HasCustomOutputStyle bool `json:"hasCustomOutputStyle,omitempty"`
}
Metadata represents the session metadata stored in metadata.json.
func (*Metadata) GetSystemPromptMode ¶
GetSystemPromptMode returns the system prompt mode ("append" or "replace"). Returns empty string if not set.
type Permissions ¶
type Permissions struct {
Allow []string `json:"allow,omitempty"`
Ask []string `json:"ask,omitempty"`
Deny []string `json:"deny,omitempty"`
AdditionalDirectories []string `json:"additionalDirectories,omitempty"`
DefaultMode string `json:"defaultMode,omitempty"`
DisableBypassPermissionsMode string `json:"disableBypassPermissionsMode,omitempty"`
}
Permissions represents the permissions configuration for a session.
type Session ¶
Session represents a named Claude Code session.
func NewForkedSession ¶
NewForkedSession creates a new forked session with empty sessionId. The sessionId will be filled in later by the session-start hook.
func NewIncognitoSession ¶
NewIncognitoSession creates a new incognito session that will auto-delete on exit.
func NewSession ¶
NewSession creates a new session with the given name and UUID.
func (*Session) AddPreviousSessionID ¶
AddPreviousSessionID appends the current session ID to the history and updates to the new ID. This is idempotent - won't add duplicates.
func (*Session) UpdateLastAccessed ¶
func (s *Session) UpdateLastAccessed()
UpdateLastAccessed updates the lastAccessed timestamp to now.
type Settings ¶
type Settings struct {
Model string `json:"model,omitempty"`
OutputStyle string `json:"outputStyle,omitempty"`
Permissions Permissions `json:"permissions,omitempty"`
}
Settings represents Claude Code session-specific settings stored in settings.json.
type Store ¶
type Store interface {
// List returns all sessions, sorted by lastAccessed (most recent first)
List() ([]*Session, error)
// Get retrieves a session by name
Get(name string) (*Session, error)
// Create creates a new session folder structure with metadata
Create(session *Session) error
// Update updates session metadata
Update(session *Session) error
// Delete removes a session folder and all its contents
Delete(name string) error
// Exists checks if a session exists
Exists(name string) bool
// LoadSettings loads settings.json for a session (returns nil if not exists)
LoadSettings(name string) (*Settings, error)
// SaveSettings saves settings.json for a session
SaveSettings(name string, settings *Settings) error
// LoadSystemPrompt loads system-prompt.md for a session (returns empty if not exists)
LoadSystemPrompt(name string) (string, error)
// SaveSystemPrompt saves system-prompt.md for a session
SaveSystemPrompt(name string, content string) error
}
Store defines the interface for session storage operations.