conversation

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompactCWD

func CompactCWD(cwd string) string

func CountPlans

func CountPlans(messages []Message) int

func FormatDuration

func FormatDuration(d time.Duration) string

func FormatPlan

func FormatPlan(p Plan) string

func FormatRelativeTime added in v0.2.0

func FormatRelativeTime(t time.Time, now time.Time) string

func FormatToolCounts

func FormatToolCounts(counts map[string]int) string

func IsRejectedToolResultContent added in v0.2.0

func IsRejectedToolResultContent(content string) bool

func ProjectName

func ProjectName(cwd string) string

func SetNowForTesting added in v0.2.0

func SetNowForTesting(now func() time.Time) func()

func Truncate

func Truncate(s string, maxLen int) string

func TruncatePreserveNewlines

func TruncatePreserveNewlines(s string, maxLen int) string

Types

type ActionOutcomeCounts added in v0.2.0

type ActionOutcomeCounts struct {
	Calls      map[string]int
	Errors     map[string]int
	Rejections map[string]int
}

func DeriveActionOutcomeCounts added in v0.2.0

func DeriveActionOutcomeCounts(messages []Message) ActionOutcomeCounts

type ActionTarget added in v0.2.0

type ActionTarget struct {
	Type  ActionTargetType
	Value string
}

type ActionTargetType added in v0.2.0

type ActionTargetType string
const (
	ActionTargetFilePath ActionTargetType = "file_path"
	ActionTargetPattern  ActionTargetType = "pattern"
	ActionTargetQuery    ActionTargetType = "query"
	ActionTargetURL      ActionTargetType = "url"
	ActionTargetCommand  ActionTargetType = "command"
	ActionTargetPlanPath ActionTargetType = "plan_path"
)

type ActivityBucketRow added in v0.3.0

type ActivityBucketRow struct {
	BucketStart           time.Time
	Provider              string
	Version               string
	Model                 string
	Project               string
	SessionCount          int
	MessageCount          int
	UserMessageCount      int
	AssistantMessageCount int
	InputTokens           int
	CacheCreationTokens   int
	CacheReadTokens       int
	OutputTokens          int
	ReasoningOutputTokens int
}

type Conversation

type Conversation struct {
	Ref           Ref
	Name          string
	Project       Project
	Sessions      []SessionMeta
	PlanCount     int
	SearchPreview string
	// contains filtered or unexported fields
}

func (Conversation) CacheKey

func (c Conversation) CacheKey() string

func (Conversation) Description

func (c Conversation) Description() string

func (Conversation) DisplayName

func (c Conversation) DisplayName() string

func (Conversation) Duration

func (c Conversation) Duration() time.Duration

func (Conversation) FilePaths

func (c Conversation) FilePaths() []string

func (Conversation) FilterValue

func (c Conversation) FilterValue() string

func (Conversation) FirstMessage

func (c Conversation) FirstMessage() string

func (Conversation) GitBranch

func (c Conversation) GitBranch() string

func (Conversation) ID

func (c Conversation) ID() string

func (Conversation) IsSubagent

func (c Conversation) IsSubagent() bool

func (Conversation) LatestFilePath

func (c Conversation) LatestFilePath() string

func (Conversation) MainMessageCount

func (c Conversation) MainMessageCount() int

func (Conversation) Model

func (c Conversation) Model() string

func (Conversation) PartCount

func (c Conversation) PartCount() int

func (*Conversation) PrecomputeDisplay

func (c *Conversation) PrecomputeDisplay()

PrecomputeDisplay eagerly caches derived list-display fields for a value conversation. This is the deliberate exception to the value-receiver rule.

func (Conversation) ResumeCWD

func (c Conversation) ResumeCWD() string

func (Conversation) ResumeID

func (c Conversation) ResumeID() string

func (Conversation) ResumeTarget

func (c Conversation) ResumeTarget() ResumeTarget

func (*Conversation) SetSearchPreview

func (c *Conversation) SetSearchPreview(preview string)

func (Conversation) Timestamp

func (c Conversation) Timestamp() time.Time

func (Conversation) Title

func (c Conversation) Title() string

func (Conversation) TotalMessageCount

func (c Conversation) TotalMessageCount() int

func (Conversation) TotalTokenUsage

func (c Conversation) TotalTokenUsage() TokenUsage

func (Conversation) TotalToolCounts

func (c Conversation) TotalToolCounts() map[string]int

func (Conversation) Version

func (c Conversation) Version() string

type DiffHunk

type DiffHunk struct {
	OldStart int
	OldLines int
	NewStart int
	NewLines int
	Lines    []string
}

type Message

type Message struct {
	Role              Role
	Text              string
	Thinking          string
	HasHiddenThinking bool
	ToolCalls         []ToolCall
	ToolResults       []ToolResult
	Plans             []Plan
	Visibility        MessageVisibility
	IsSidechain       bool
	IsAgentDivider    bool
	Usage             TokenUsage
	Performance       MessagePerformanceMeta
	Timestamp         time.Time
}

func (Message) HasThinking

func (m Message) HasThinking() bool

func (Message) IsVisible

func (m Message) IsVisible() bool

type MessagePerformanceMeta added in v0.2.0

type MessagePerformanceMeta struct {
	ReasoningBlockCount     int
	ReasoningRedactionCount int
	StopReason              string
	Phase                   string
	Effort                  string
}

type MessageVisibility

type MessageVisibility string
const (
	MessageVisibilityVisible      MessageVisibility = ""
	MessageVisibilityHiddenSystem MessageVisibility = "hidden_system"
)

type NormalizedAction added in v0.2.0

type NormalizedAction struct {
	Type    NormalizedActionType
	Targets []ActionTarget
}

func (NormalizedAction) IsZero added in v0.2.0

func (a NormalizedAction) IsZero() bool

type NormalizedActionType added in v0.2.0

type NormalizedActionType string
const (
	NormalizedActionRead     NormalizedActionType = "read"
	NormalizedActionSearch   NormalizedActionType = "search"
	NormalizedActionMutate   NormalizedActionType = "mutate"
	NormalizedActionRewrite  NormalizedActionType = "rewrite"
	NormalizedActionExecute  NormalizedActionType = "execute"
	NormalizedActionTest     NormalizedActionType = "test"
	NormalizedActionBuild    NormalizedActionType = "build"
	NormalizedActionWeb      NormalizedActionType = "web"
	NormalizedActionPlan     NormalizedActionType = "plan"
	NormalizedActionDelegate NormalizedActionType = "delegate"
	NormalizedActionOther    NormalizedActionType = "other"
)

type PerformanceSequenceSession added in v0.3.0

type PerformanceSequenceSession struct {
	Timestamp                    time.Time
	Mutated                      bool
	MutationCount                int
	RewriteCount                 int
	TargetedMutationCount        int
	BlindMutationCount           int
	DistinctMutationTargets      int
	PatchHunkCount               int
	VerificationPassed           bool
	FirstPassResolved            bool
	CorrectionFollowups          int
	ReasoningLoopCount           int
	ActionCount                  int
	ActionsBeforeFirstMutation   int
	TokensBeforeFirstMutation    int
	UserTurnsBeforeFirstMutation int
	AssistantTurns               int
	VisibleReasoningChars        int
	HiddenThinkingTurns          int
}

type Plan

type Plan struct {
	FilePath  string
	Content   string
	Timestamp time.Time
}

func AllPlans

func AllPlans(messages []Message) []Plan

func LastPlan

func LastPlan(messages []Message) (Plan, bool)

type Project

type Project struct {
	DisplayName string
}

type Provider

type Provider string
const (
	ProviderClaude Provider = "claude"
	ProviderCodex  Provider = "codex"
)

func (Provider) Label

func (p Provider) Label() string

type Ref

type Ref struct {
	Provider Provider
	ID       string
}

func (Ref) CacheKey

func (r Ref) CacheKey() string

type ResumeTarget

type ResumeTarget struct {
	Provider Provider
	ID       string
	CWD      string
}

type Role

type Role string
const (
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleSystem    Role = "system"

	ContentTypeToolResult = "tool_result"
)

type Session

type Session struct {
	Meta     SessionMeta
	Messages []Message
}

type SessionMeta

type SessionMeta struct {
	ID                    string
	Provider              Provider
	Project               Project
	Slug                  string
	Timestamp             time.Time
	LastTimestamp         time.Time
	CWD                   string
	GitBranch             string
	Version               string
	Model                 string
	FirstMessage          string
	MessageCount          int
	MainMessageCount      int
	UserMessageCount      int
	AssistantMessageCount int
	FilePath              string
	TotalUsage            TokenUsage
	ToolCounts            map[string]int
	ToolErrorCounts       map[string]int
	ToolRejectCounts      map[string]int
	ActionCounts          map[string]int
	ActionErrorCounts     map[string]int
	ActionRejectCounts    map[string]int
	Performance           SessionPerformanceMeta
	IsSubagent            bool
}

func (SessionMeta) Description

func (s SessionMeta) Description() string

func (SessionMeta) DisplaySlug

func (s SessionMeta) DisplaySlug() string

func (SessionMeta) Duration

func (s SessionMeta) Duration() time.Duration

func (SessionMeta) FilterValue

func (s SessionMeta) FilterValue() string

func (SessionMeta) Title

func (s SessionMeta) Title() string

type SessionPerformanceMeta added in v0.2.0

type SessionPerformanceMeta struct {
	ReasoningBlockCount     int
	ReasoningRedactionCount int
	MaxThinkingTokens       int
	ModelContextWindow      int
	DurationMS              int
	RetryAttemptCount       int
	RetryDelayMS            int
	MaxRetries              int
	AbortCount              int
	CompactionCount         int
	MicroCompactionCount    int
	TaskStartedCount        int
	TaskCompleteCount       int
	ContextCompactedCount   int
	RateLimitSnapshotCount  int
	APIErrorCounts          map[string]int
	StopReasonCounts        map[string]int
	PhaseCounts             map[string]int
	EffortCounts            map[string]int
	ServerToolUseCounts     map[string]int
	ServiceTierCounts       map[string]int
	SpeedCounts             map[string]int
}

type SessionStatsData added in v0.3.0

type SessionStatsData struct {
	PerformanceSequence PerformanceSequenceSession
	TurnMetrics         SessionTurnMetrics
}

type SessionTurnMetrics added in v0.3.0

type SessionTurnMetrics struct {
	Provider  Provider
	Version   string
	Timestamp time.Time
	Turns     []TurnTokens
}

type TokenUsage

type TokenUsage struct {
	InputTokens              int
	CacheCreationInputTokens int
	CacheReadInputTokens     int
	OutputTokens             int
	ReasoningOutputTokens    int
}

func (TokenUsage) PromptTokens added in v0.3.0

func (u TokenUsage) PromptTokens() int

func (TokenUsage) TotalTokens

func (u TokenUsage) TotalTokens() int

type ToolCall

type ToolCall struct {
	Name    string
	Summary string
	Action  NormalizedAction
}

type ToolOutcomeCounts added in v0.2.0

type ToolOutcomeCounts struct {
	Calls      map[string]int
	Errors     map[string]int
	Rejections map[string]int
}

func DeriveToolOutcomeCounts added in v0.2.0

func DeriveToolOutcomeCounts(messages []Message) ToolOutcomeCounts

type ToolResult

type ToolResult struct {
	ToolName        string
	ToolSummary     string
	Content         string
	IsError         bool
	StructuredPatch []DiffHunk
	Action          NormalizedAction
}

func (ToolResult) IsRejected added in v0.2.0

func (r ToolResult) IsRejected() bool

type TurnTokens added in v0.3.0

type TurnTokens struct {
	PromptTokens        int `json:"prompt_tokens"`
	TurnTokens          int `json:"turn_tokens"`
	CacheReadTokens     int `json:"cache_read_tokens,omitempty"`
	CacheCreationTokens int `json:"cache_creation_tokens,omitempty"`
	MemoryWriteCount    int `json:"memory_write_count,omitempty"`
}

Jump to

Keyboard shortcuts

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