Documentation
¶
Overview ¶
Package session parses Claude Code session JSONL files to extract tool usage patterns for adoption and discovery analytics.
Index ¶
- func EncodedPath(repoRoot string) string
- func FormatDiscoverSummary(result *DiscoverResult) string
- func FormatSessionSummary(sessions []SessionInfo) string
- func ListSessions(repoRoot string, since time.Time, limit int) ([]string, error)
- func ParseSession(path string, repoRoot string) ([]EditEvent, []ContextEvent, error)
- func SessionDir() string
- type ContextEvent
- type DiscoverResult
- type EditEvent
- type MissedFile
- type SessionInfo
- type UsageLogQuerier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodedPath ¶
EncodedPath converts a repo path to Claude Code's encoded directory name. "/Users/kehoe/Repositories/myproject" -> "-Users-kehoe-Repositories-myproject"
func FormatDiscoverSummary ¶
func FormatDiscoverSummary(result *DiscoverResult) string
FormatDiscoverSummary produces the human-readable discover output.
func FormatSessionSummary ¶
func FormatSessionSummary(sessions []SessionInfo) string
FormatSessionSummary produces the human-readable session adoption output.
func ListSessions ¶
ListSessions returns session JSONL files for the given repo, sorted by modification time (newest first).
func ParseSession ¶
func ParseSession(path string, repoRoot string) ([]EditEvent, []ContextEvent, error)
ParseSession extracts edit and context events from a session JSONL file.
Types ¶
type ContextEvent ¶
ContextEvent represents a get_context call from a session.
type DiscoverResult ¶
type DiscoverResult struct {
SessionsScanned int `json:"sessions_scanned"`
FilesEdited int `json:"files_edited"`
ContextRequested int `json:"context_requested"`
Coverage float64 `json:"coverage"`
MissedFiles []MissedFile `json:"missed_files,omitempty"`
}
DiscoverResult contains the output of the discover analysis.
func Discover ¶
func Discover(repoRoot string, since time.Time, includeTests bool, isSupportedExt func(string) bool, usageLog ...UsageLogQuerier) (*DiscoverResult, error)
Discover analyzes sessions to find files edited without get_context being called. If usageLog is non-nil, it also checks the usage_log table for hook-injected context that doesn't appear in session JSONL files.
type MissedFile ¶
type MissedFile struct {
File string `json:"file"`
EditCount int `json:"edit_count"`
ContextCount int `json:"context_count"`
IsTest bool `json:"is_test,omitempty"`
}
MissedFile represents a file edited without get_context being called.
type SessionInfo ¶
type SessionInfo struct {
ID string `json:"id"`
Date time.Time `json:"date"`
Edits int `json:"edits"`
Contexts int `json:"contexts"`
Coverage float64 `json:"coverage"` // contexts / editable files edited
}
SessionInfo contains metadata about a parsed session.
func GetSessionStats ¶
func GetSessionStats(repoRoot string, since time.Time, limit int, isSupportedExt func(string) bool, usageLog ...UsageLogQuerier) ([]SessionInfo, error)
GetSessionStats returns adoption stats per session. If usageLog is provided, it also checks the usage_log table for hook-injected context.