analysis

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package analysis provides analysis, metrics, and reporting commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportPlayground

func ExportPlayground(history []PlaygroundEntry) (string, error)

ExportPlayground exports playground data to JSON.

func FormatMultiPlatformReport

func FormatMultiPlatformReport(report MultiPlatformReport) string

FormatMultiPlatformReport returns a human-readable report string.

func PassthroughArgs

func PassthroughArgs(args []string, skipFlags []string) bool

PassthroughArgs checks if user passed conflicting flags to skip filtering. Inspired by tokf's passthrough args.

func SavePlayground

func SavePlayground(path string, history []PlaygroundEntry) error

SavePlayground saves playground data to file.

Types

type AutoValidationPipeline

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

AutoValidationPipeline implements auto-validation after file changes. Inspired by lean-ctx's auto-validation pipeline.

func NewAutoValidationPipeline

func NewAutoValidationPipeline() *AutoValidationPipeline

NewAutoValidationPipeline creates a new auto-validation pipeline.

func (*AutoValidationPipeline) AddValidator

func (avp *AutoValidationPipeline) AddValidator(name, command string)

AddValidator adds a validation step.

func (*AutoValidationPipeline) Validate

func (avp *AutoValidationPipeline) Validate() []string

Validate runs all validators.

type CodeSummary

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

CodeSummary holds the 2-line summary.

type CommandBreakdown

type CommandBreakdown struct {
	Command string
	Count   int
	Saved   int
	AvgPct  float64
	AvgTime int64
}

CommandBreakdown represents stats for a single command

type Correction

type Correction struct {
	FailedCommand    string  `json:"failed_command"`
	CorrectedCommand string  `json:"corrected_command"`
	Count            int     `json:"count"`
	Confidence       float64 `json:"confidence"`
	Example          string  `json:"example,omitempty"`
	Category         string  `json:"category"`
}

Correction represents a learned correction pattern

type DayBreakdown

type DayBreakdown struct {
	Date     string
	Commands int
	Saved    int
	Original int
}

DayBreakdown represents stats for a single day

type DeveloperPlayground

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

DeveloperPlayground implements a playground for testing prompts through proxy.

func NewDeveloperPlayground

func NewDeveloperPlayground() *DeveloperPlayground

NewDeveloperPlayground creates a new developer playground.

func (*DeveloperPlayground) GetHistory

func (dp *DeveloperPlayground) GetHistory() []PlaygroundEntry

GetHistory returns playground history.

func (*DeveloperPlayground) TestPrompt

func (dp *DeveloperPlayground) TestPrompt(prompt, model string) PlaygroundEntry

TestPrompt tests a prompt and returns cost estimate.

type FileVariant

type FileVariant struct {
	Name    string
	Pattern string
	Filter  string
}

FileVariant represents a file-based filter variant.

type FilterVariants

type FilterVariants struct {
	FileVariants   []FileVariant
	OutputVariants []OutputVariant
}

FilterVariants implements two-phase variant detection. Inspired by tokf's filter variants.

func NewFilterVariants

func NewFilterVariants() *FilterVariants

NewFilterVariants creates a new filter variants system.

func (*FilterVariants) AddFileVariant

func (fv *FilterVariants) AddFileVariant(name, pattern, filter string)

AddFileVariant adds a file-based variant.

func (*FilterVariants) AddOutputVariant

func (fv *FilterVariants) AddOutputVariant(name, pattern, filter string)

AddOutputVariant adds an output-pattern variant.

func (*FilterVariants) MatchFile

func (fv *FilterVariants) MatchFile(filePath string) string

MatchFile finds matching file variant.

func (*FilterVariants) MatchOutput

func (fv *FilterVariants) MatchOutput(output string) string

MatchOutput finds matching output variant.

type GainSummary

type GainSummary struct {
	TotalCommands int
	TotalInput    int
	TotalOutput   int
	TotalSaved    int
	AvgSavingsPct float64
	TotalTimeMs   int64
	AvgTimeMs     int64
	ByCommand     []CommandBreakdown
	ByDay         []DayBreakdown
}

GainSummary represents the summary statistics

type LeaderboardEntry

type LeaderboardEntry struct {
	Rank        int     `json:"rank"`
	User        string  `json:"user"`
	TokensSaved int64   `json:"tokens_saved"`
	CostSaved   float64 `json:"cost_saved"`
	Commands    int     `json:"commands"`
}

LeaderboardEntry represents a leaderboard entry.

type LearnResult

type LearnResult struct {
	Project      string       `json:"project,omitempty"`
	TotalErrors  int          `json:"total_errors"`
	Corrections  []Correction `json:"corrections"`
	RulesWritten bool         `json:"rules_written,omitempty"`
}

LearnResult represents the learning results

type LiveMonitor

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

LiveMonitor implements live htop-style monitoring of API traffic.

func NewLiveMonitor

func NewLiveMonitor() *LiveMonitor

NewLiveMonitor creates a new live monitor.

func (*LiveMonitor) FormatLiveView

func (lm *LiveMonitor) FormatLiveView() string

FormatLiveView formats the live monitoring view.

func (*LiveMonitor) Record

func (lm *LiveMonitor) Record(entry MonitorEntry)

Record records a monitored request.

type MonitorEntry

type MonitorEntry struct {
	Model        string    `json:"model"`
	InputTokens  int       `json:"input_tokens"`
	OutputTokens int       `json:"output_tokens"`
	Cost         float64   `json:"cost"`
	LatencyMs    int64     `json:"latency_ms"`
	Timestamp    time.Time `json:"timestamp"`
}

MonitorEntry represents a monitored request.

type MultiPlatformReport

type MultiPlatformReport struct {
	Platforms     []PlatformUsage `json:"platforms"`
	TotalTokens   int64           `json:"total_tokens"`
	TotalCost     float64         `json:"total_cost"`
	TotalSessions int             `json:"total_sessions"`
}

MultiPlatformReport aggregates usage across platforms.

type OutputVariant

type OutputVariant struct {
	Name    string
	Pattern string
	Filter  string
}

OutputVariant represents an output-pattern filter variant.

type PlatformUsage

type PlatformUsage struct {
	Name       string  `json:"name"`
	Sessions   int     `json:"sessions"`
	TokensUsed int64   `json:"tokens_used"`
	CostUSD    float64 `json:"cost_usd"`
	Model      string  `json:"model,omitempty"`
	LastActive string  `json:"last_active,omitempty"`
}

PlatformUsage tracks usage for a single AI platform.

type PlaygroundEntry

type PlaygroundEntry struct {
	Prompt       string    `json:"prompt"`
	Model        string    `json:"model"`
	InputTokens  int       `json:"input_tokens"`
	OutputTokens int       `json:"output_tokens"`
	Cost         float64   `json:"cost"`
	Timestamp    time.Time `json:"timestamp"`
}

PlaygroundEntry represents a playground test entry.

func LoadPlayground

func LoadPlayground(path string) ([]PlaygroundEntry, error)

LoadPlayground loads playground data from file.

type RemoteGainSync

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

RemoteGainSync syncs gain data across machines via GitHub auth. Inspired by tokf's remote gain sync.

func NewRemoteGainSync

func NewRemoteGainSync(token, endpoint string) *RemoteGainSync

NewRemoteGainSync creates a new remote gain sync.

func (*RemoteGainSync) Sync

func (rgs *RemoteGainSync) Sync(data map[string]any) error

Sync uploads local gain data to remote.

type Validator

type Validator struct {
	Name    string
	Command string
}

Validator represents a validation step.

Jump to

Keyboard shortcuts

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