history

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeStorage added in v0.29.0

type ChangeStorage struct {
	// contains filtered or unexported fields
}

ChangeStorage は変更履歴のストレージ

func NewChangeStorage added in v0.29.0

func NewChangeStorage() (*ChangeStorage, error)

NewChangeStorage は新しいChangeStorageを作成

func (*ChangeStorage) AppendChange added in v0.29.0

func (cs *ChangeStorage) AppendChange(sessionID string, change tools.FileChange) error

AppendChange はセッションの変更履歴にエントリを追加

func (*ChangeStorage) CleanupOldChanges added in v0.29.0

func (cs *ChangeStorage) CleanupOldChanges(daysToKeep int) (int, error)

CleanupOldChanges は古い変更履歴を削除(デフォルト30日以上前)

func (*ChangeStorage) ListSessions added in v0.29.0

func (cs *ChangeStorage) ListSessions() ([]SessionInfo, error)

ListSessions は全セッションの変更履歴を取得

func (*ChangeStorage) LoadSessionChanges added in v0.29.0

func (cs *ChangeStorage) LoadSessionChanges(sessionID string) ([]PersistentChange, error)

LoadSessionChanges は指定セッションの変更履歴を読み込み

func (*ChangeStorage) UndoSessionChange added in v0.29.0

func (cs *ChangeStorage) UndoSessionChange(change PersistentChange) error

UndoSessionChange は指定セッションの指定変更を取り消す

type CompactedItem added in v0.31.0

type CompactedItem struct {
	Type    string      `json:"type"`              // "message" or "compacted"
	Role    string      `json:"role,omitempty"`    // "user", "assistant"
	Content interface{} `json:"content,omitempty"` // string or structured content
	ID      string      `json:"id,omitempty"`      // アシスタント応答のID
	Status  string      `json:"status,omitempty"`  // "completed"
	Data    string      `json:"data,omitempty"`    // 暗号化データ(type="compacted"の場合)
}

CompactedItem は Compact API の圧縮済みアイテム(セッション保存用) api.InputItem と同一構造

type MessageEntry

type MessageEntry struct {
	Timestamp  time.Time `json:"timestamp"`
	Role       string    `json:"role"`
	Content    string    `json:"content"`
	Model      string    `json:"model,omitempty"`
	ResponseID string    `json:"response_id,omitempty"` // OpenAI Responses API の ID
}

MessageEntry はタイムスタンプ付きメッセージ

type PersistentChange added in v0.29.0

type PersistentChange struct {
	SessionID   string    `json:"session_id"`
	Timestamp   time.Time `json:"timestamp"`
	Tool        string    `json:"tool"`
	FilePath    string    `json:"file_path"`
	BackupPath  string    `json:"backup_path"`
	Description string    `json:"description"`
}

PersistentChange は永続化される変更履歴

type Session

type Session struct {
	ID              string
	Model           string
	StartTime       time.Time
	LastModified    time.Time
	Messages        []MessageEntry
	CompactedItems  []CompactedItem `json:"compacted_items,omitempty"`   // Compact API 圧縮済みアイテム
	IsCompactedMode bool            `json:"is_compacted_mode,omitempty"` // 圧縮モードフラグ
}

Session は会話セッションを表す

func NewSession

func NewSession(model string) *Session

NewSession は新しいセッションを作成

func (*Session) AddMessage

func (s *Session) AddMessage(role, content, model string)

AddMessage はメッセージをセッションに追加

func (*Session) ToAPIMessages

func (s *Session) ToAPIMessages() []api.Message

ToAPIMessages はAPI形式に変換

type SessionInfo added in v0.29.0

type SessionInfo struct {
	SessionID    string
	ChangeCount  int
	FirstChange  time.Time
	LastChange   time.Time
	FilesChanged map[string]int // ファイルパス → 変更回数
}

SessionInfo はセッション情報(変更履歴表示用)

type SessionMetadata

type SessionMetadata struct {
	ID           string    `json:"session_id"`
	Model        string    `json:"model"`
	StartTime    time.Time `json:"start_time"`
	LastModified time.Time `json:"last_modified"`
	MessageCount int       `json:"message_count"`
	Preview      string    `json:"preview"`
}

SessionMetadata はセッション一覧用のメタデータ

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage は履歴の永続化を管理

func NewStorage

func NewStorage() (*Storage, error)

NewStorage はストレージインスタンスを作成

func (*Storage) GetLastSession

func (st *Storage) GetLastSession() (string, error)

GetLastSession は最新のセッションIDを返す

func (*Storage) ListSessions

func (st *Storage) ListSessions() ([]SessionMetadata, error)

ListSessions は全セッションを新しい順で返す

func (*Storage) Load

func (st *Storage) Load(sessionID string) (*Session, error)

Load はセッションファイルから読み込み

func (*Storage) Save

func (st *Storage) Save(session *Session) error

Save はメッセージをJSONLファイルに追記

Jump to

Keyboard shortcuts

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