session

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package session contains structures to track llm calls

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionExists              = errors.New("session already in progress")
	ErrNoActiveSession            = errors.New("no active session found")
	ErrSessionWriteFail           = errors.New("failed to write session file")
	ErrSessionReadFail            = errors.New("failed to read session file")
	ErrSessionParseFail           = errors.New("failed to parse session file")
	ErrSessionArchive             = errors.New("failed to archive session file")
	ErrSessionDelete              = errors.New("failed to delete session file")
	ErrSessionMkdir               = errors.New("failed to create session history directory")
	ErrSessionRootCreate          = errors.New("failed to create session root directory")
	ErrSessionHistoryCreate       = errors.New("failed to create session history directory")
	ErrSessionFileExistanceFailed = errors.New("failed to check if current session file exists")
	ErrSessionDirNotSpecified     = errors.New("failed as the session dir was not specified")
	ErrSessionNameSpecified       = errors.New("failed as the session name was not specified")
)

Custom session errors.

Functions

func BuildCurrentSessionFilePath

func BuildCurrentSessionFilePath(path string) string

BuildCurrentSessionFilePath is the path to current session file path.

func BuildSessionHistoryPath

func BuildSessionHistoryPath(path string) string

BuildSessionHistoryPath is the path to all history sessions.

func CreateOrCheckSessionDir

func CreateOrCheckSessionDir(path string) (currentSessionExists bool, err error)

CreateOrCheckSessionDir initializes the session root directory and history dir for storage if they don't exist, returns whether the current session file exists.

func EndSession

func EndSession(sessionDir string) error

EndSession ends the current session and archives it.

func SaveCurrentSession added in v1.1.1

func SaveCurrentSession(currentSessionDir string, session *Session) error

SaveCurrentSession will save session data.

func StartSession

func StartSession(startSession *StartSessionRequest) error

StartSession starts a new coding session.

Types

type Command

type Command struct {
	Prompt string   `json:"prompt"`
	Files  []string `json:"files"`
}

Command represents the command details associated with a step.

type FilesDiff

type FilesDiff struct {
	Created  []string `json:"created"`
	Modified []string `json:"modified"`
	Deleted  []string `json:"deleted"`
}

FilesDiff represents the differences in files during the step.

type Git

type Git struct {
	Pre  GitState `json:"pre"`
	Post GitState `json:"post"`
}

Git represents the Git information before and after the step.

type GitState

type GitState struct {
	Commit            string   `json:"commit"`
	StateBeforeChange string   `json:"state_before_change,omitempty"`
	UncommittedFiles  []string `json:"uncommitted_files,omitempty"`
}

GitState represents the state of the Git repository at a specific point.

type Session

type Session struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	CreatedAt   time.Time `json:"created_at"`
	CompletedAt time.Time `json:"completed_at"`
	Steps       []*Step   `json:"steps"`
}

Session represents a user session with an llm.

func LoadCurrentSession added in v1.1.1

func LoadCurrentSession(currentSessionDir string) (*Session, error)

LoadCurrentSession will load existing session from the current location.

type StartSessionRequest

type StartSessionRequest struct {
	Name string
	Dir  string
}

type Step

type Step struct {
	ID        int       `json:"id"`
	Command   Command   `json:"command"`
	Timestamp time.Time `json:"timestamp"`
	FilesDiff FilesDiff `json:"files_diff"`
	Git       Git       `json:"git"`
}

Step represents an individual step within a session.

Jump to

Keyboard shortcuts

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