Documentation
¶
Index ¶
- func ComputeFileHash(path string) (string, error)
- func ComputeHash(r io.Reader) (string, error)
- func FindClaudeSourceFile(projectsDir, sessionID string) string
- func FindCodexSourceFile(sessionsDir, sessionID string) string
- func FindCopilotSourceFile(copilotDir, rawID string) string
- func FindCursorSourceFile(projectsDir, sessionID string) string
- func FindGeminiSourceFile(geminiDir, sessionID string) string
- type DiscoveredFile
- func DiscoverClaudeProjects(projectsDir string) []DiscoveredFile
- func DiscoverCodexSessions(sessionsDir string) []DiscoveredFile
- func DiscoverCopilotSessions(copilotDir string) []DiscoveredFile
- func DiscoverCursorSessions(projectsDir string) []DiscoveredFile
- func DiscoverGeminiSessions(geminiDir string) []DiscoveredFile
- type Engine
- func (e *Engine) FindSourceFile(sessionID string) string
- func (e *Engine) LastSync() time.Time
- func (e *Engine) LastSyncStats() SyncStats
- func (e *Engine) ResyncAll(onProgress ProgressFunc) SyncStats
- func (e *Engine) SyncAll(onProgress ProgressFunc) SyncStats
- func (e *Engine) SyncPaths(paths []string)
- func (e *Engine) SyncSingleSession(sessionID string) error
- type Phase
- type Progress
- type ProgressFunc
- type SyncResult
- type SyncStats
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeFileHash ¶
ComputeFileHash returns the SHA-256 hex digest of the file at path.
func ComputeHash ¶
ComputeHash returns the SHA-256 hex digest of data from r.
func FindClaudeSourceFile ¶
FindClaudeSourceFile finds the original JSONL file for a Claude session ID by searching all project directories.
func FindCodexSourceFile ¶
FindCodexSourceFile finds a Codex session file by UUID. Searches the year/month/day directory structure for files matching rollout-{timestamp}-{uuid}.jsonl.
func FindCopilotSourceFile ¶ added in v0.5.0
FindCopilotSourceFile locates a Copilot session file by UUID. Checks both bare (<uuid>.jsonl) and directory (<uuid>/events.jsonl) layouts.
func FindCursorSourceFile ¶ added in v0.9.0
FindCursorSourceFile finds a Cursor transcript file by session UUID. Searches all project directories for a matching agent-transcripts/<uuid>.{jsonl,txt} file. Prefers .jsonl over .txt (consistent with discovery).
func FindGeminiSourceFile ¶
FindGeminiSourceFile locates a Gemini session file by its session UUID. Searches all project hash directories.
Types ¶
type DiscoveredFile ¶
type DiscoveredFile struct {
Path string
Project string // pre-extracted project name
Agent parser.AgentType // AgentClaude or AgentCodex
}
DiscoveredFile holds a discovered session JSONL file.
func DiscoverClaudeProjects ¶
func DiscoverClaudeProjects(projectsDir string) []DiscoveredFile
DiscoverClaudeProjects finds all project directories under the Claude projects dir and returns their JSONL session files.
func DiscoverCodexSessions ¶
func DiscoverCodexSessions(sessionsDir string) []DiscoveredFile
DiscoverCodexSessions finds all JSONL files under the Codex sessions dir (year/month/day structure).
func DiscoverCopilotSessions ¶ added in v0.5.0
func DiscoverCopilotSessions( copilotDir string, ) []DiscoveredFile
DiscoverCopilotSessions finds all JSONL files under <copilotDir>/session-state/. Supports both bare format (<uuid>.jsonl) and directory format (<uuid>/events.jsonl).
func DiscoverCursorSessions ¶ added in v0.9.0
func DiscoverCursorSessions( projectsDir string, ) []DiscoveredFile
DiscoverCursorSessions finds all agent transcript files under the Cursor projects dir (<projectsDir>/<project>/agent-transcripts/<uuid>.txt). All discovered paths are validated to resolve within the canonical projectsDir, preventing symlink escapes.
func DiscoverGeminiSessions ¶
func DiscoverGeminiSessions( geminiDir string, ) []DiscoveredFile
DiscoverGeminiSessions finds all session JSON files under the Gemini directory (~/.gemini/tmp/*/chats/session-*.json).
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine orchestrates session file discovery and sync.
func NewEngine ¶
func NewEngine( database *db.DB, claudeDirs, codexDirs, copilotDirs, geminiDirs, opencodeDirs []string, cursorDir, machine string, ) *Engine
NewEngine creates a sync engine. It pre-populates the in-memory skip cache from the database so that files skipped in a prior run are not re-parsed on startup.
func (*Engine) FindSourceFile ¶
FindSourceFile locates the original source file for a session ID.
func (*Engine) LastSyncStats ¶
LastSyncStats returns statistics from the last sync.
func (*Engine) ResyncAll ¶ added in v0.6.0
func (e *Engine) ResyncAll( onProgress ProgressFunc, ) SyncStats
ResyncAll builds a fresh database from scratch, syncs all sessions into it, copies insights from the old DB, then atomically swaps the files and reopens the original DB handle. This avoids the per-row trigger overhead of bulk deleting hundreds of thousands of messages in place.
func (*Engine) SyncAll ¶
func (e *Engine) SyncAll(onProgress ProgressFunc) SyncStats
SyncAll discovers and syncs all session files from all agents.
func (*Engine) SyncPaths ¶ added in v0.3.0
SyncPaths syncs only the specified changed file paths instead of discovering and hashing all session files. Paths that don't match known session file patterns are silently ignored.
func (*Engine) SyncSingleSession ¶
SyncSingleSession re-syncs a single session by its ID. Unlike the bulk SyncAll path, this includes exec-originated Codex sessions and uses the existing DB project as fallback.
type Progress ¶
type Progress struct {
Phase Phase `json:"phase"`
CurrentProject string `json:"current_project,omitempty"`
ProjectsTotal int `json:"projects_total"`
ProjectsDone int `json:"projects_done"`
SessionsTotal int `json:"sessions_total"`
SessionsDone int `json:"sessions_done"`
MessagesIndexed int `json:"messages_indexed"`
}
Progress reports sync progress to listeners.
type ProgressFunc ¶
type ProgressFunc func(Progress)
ProgressFunc is called with progress updates during sync.
type SyncResult ¶
type SyncResult struct {
SessionID string `json:"session_id"`
Project string `json:"project"`
Skipped bool `json:"skipped"`
Messages int `json:"messages"`
}
SyncResult describes the outcome of syncing a single session.
type SyncStats ¶
type SyncStats struct {
TotalSessions int `json:"total_sessions"`
Synced int `json:"synced"`
Skipped int `json:"skipped"`
Failed int `json:"failed"`
Warnings []string `json:"warnings,omitempty"`
// contains filtered or unexported fields
}
SyncStats summarizes a full sync run.
TotalSessions counts discovered files plus OpenCode sessions. Synced counts sessions (one file can produce multiple via fork detection; OpenCode adds sessions directly). Failed counts files with hard parse/stat errors. filesOK counts files that produced at least one session — used by ResyncAll to compare against Failed on the same unit.
func (*SyncStats) RecordFailed ¶ added in v0.8.0
func (s *SyncStats) RecordFailed()
RecordFailed increments the hard-failure counter.
func (*SyncStats) RecordSkip ¶
func (s *SyncStats) RecordSkip()
RecordSkip increments the skipped session counter.
func (*SyncStats) RecordSynced ¶
RecordSynced adds n to the synced session counter.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher uses fsnotify to watch session directories for changes and triggers a callback with debouncing.
func NewWatcher ¶
NewWatcher creates a file watcher that calls onChange when files are modified after the debounce period elapses.