engine

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package engine provides the core analysis engine for agenttrace. Pure Go. Supports 14 agent sources: Hermes Agent, Claude Code, Codex CLI, Gemini CLI, Qwen Code, OpenCode, OpenClaw, Copilot CLI, Kimi CLI, Pi, Oh My Pi, Aider, Cursor, Cline.

Package engine — dynamic model pricing backed by LiteLLM community data. Runtime download + 24h cache + built-in fallback. Fuzzy model name matching.

Index

Constants

View Source
const (
	SeverityHigh   = "high"
	SeverityMedium = "medium"
	SeverityLow    = "low"
)

Severity constants for anomaly severity (internal, not i18n).

View Source
const Version = "0.4.6"

Variables

View Source
var BuiltinPricing = map[string]Price{

	"claude-opus-4.7":   {5.00, 25.00, 6.25, 0.50},
	"claude-opus-4.6":   {5.00, 25.00, 6.25, 0.50},
	"claude-opus-4-7":   {5.00, 25.00, 6.25, 0.50},
	"claude-opus-4-6":   {5.00, 25.00, 6.25, 0.50},
	"claude-opus-4.5":   {5.00, 25.00, 6.25, 0.50},
	"claude-opus-4":     {15.00, 75.00, 18.75, 1.50},
	"claude-sonnet-4.6": {3.00, 15.00, 3.75, 0.30},
	"claude-sonnet-4-6": {3.00, 15.00, 3.75, 0.30},
	"claude-sonnet-4.5": {3.00, 15.00, 3.75, 0.30},
	"claude-sonnet-4-5": {3.00, 15.00, 3.75, 0.30},
	"claude-sonnet-4":   {3.00, 15.00, 3.75, 0.30},
	"claude-haiku-4-5":  {1.00, 5.00, 1.25, 0.10},
	"claude-haiku-4.5":  {1.00, 5.00, 1.25, 0.10},
	"claude-haiku-3.5":  {0.80, 4.00, 1.00, 0.08},

	"gemini-3.1-pro-preview": {2.00, 12.00, 0, 0.20},
	"gemini-3-flash-preview": {0.50, 3.00, 0, 0.05},
	"gemini-2.5-pro":         {1.25, 10.00, 0, 0},
	"gemini-2.5-flash":       {0.15, 0.60, 0, 0},

	"gpt-5.5":            {5.00, 30.00, 0, 0.50},
	"gpt-5.4":            {2.50, 15.00, 0, 0.25},
	"pa/gpt-5.4":         {0, 0, 0, 0},
	"gpt-5.4-mini":       {0.75, 4.50, 0, 0.075},
	"gpt-5.3-codex":      {1.75, 14.00, 0, 0.175},
	"gpt-5.2-codex":      {1.75, 14.00, 0, 0.175},
	"gpt-5.1":            {1.25, 10.00, 0, 0},
	"gpt-5.1-mini":       {0.25, 2.00, 0, 0},
	"gpt-5.1-codex-mini": {0.25, 2.00, 0, 0.025},
	"gpt-4.1":            {2.00, 8.00, 0, 0},
	"gpt-4.1-mini":       {0.40, 1.60, 0, 0},
	"gpt-4.1-nano":       {0.10, 0.40, 0, 0},

	"deepseek-v4-pro":   {0.435, 0.87, 0, 0.003625},
	"deepseek-v4-flash": {0.14, 0.28, 0, 0.0028},
	"deepseek-chat":     {0.27, 1.10, 0.07, 0.014},
	"deepseek-reasoner": {0.55, 2.19, 0.14, 0.028},

	"glm-5":                        {1.00, 3.20, 0, 0.20},
	"glm-5-turbo":                  {1.20, 4.00, 0, 0.24},
	"glm-5.1":                      {1.40, 4.40, 0, 0.26},
	"kimi-k2.5":                    {0.60, 3.00, 0, 0.10},
	"kimi-k2.6":                    {0.95, 4.00, 0, 0.16},
	"mimo-v2-pro":                  {0.10, 0.30, 0, 0.02},
	"mimo-v2.5-pro":                {0, 0, 0, 0},
	"minimax-2.5":                  {0.30, 2.40, 0.375, 0.03},
	"minimax-2.7":                  {0.30, 2.40, 0.375, 0.03},
	"minimax-2.7-highspeed":        {0.30, 2.40, 0.375, 0.03},
	"minimax-m2.5":                 {0.30, 1.20, 0.375, 0.03},
	"minimax-m2.5-free":            {0.30, 2.40, 0.375, 0.03},
	"minimax-m2.7":                 {0.30, 2.40, 0.375, 0.03},
	"qwen/qwen3.6-plus-04-02:free": {0.325, 1.95, 0.40625, 0},
	"qwen3.6-plus":                 {0.325, 1.95, 0.40625, 0},
	"qwen3.5-plus":                 {0.40, 2.40, 0, 0},
	"qwen3.6:35b-a3b-coding-nvfp4": {0, 0, 0, 0},
	"doubao-seed-2-0-pro":          {0, 0, 0, 0},
	"stepfun/step-3.5-flash:free":  {0, 0, 0, 0},
	"grok-code-fast-1":             {0.20, 1.50, 0, 0.02},
	"x-ai/grok-code-fast-1":        {0.20, 1.50, 0, 0.02},
	"<synthetic>":                  {0, 0, 0, 0},

	"grok-3": {3.00, 15.00, 0, 0},

	"default": {3.00, 15.00, 0, 0},
}
View Source
var Pricing = BuiltinPricing

Pricing is the built-in model pricing fallback (USD per 1M tokens). Deprecated: use LookupPrice() which merges dynamic + fallback pricing.

View Source
var ToolDisplayNames = map[string]string{
	"hermes_jsonl":      "Hermes Agent (JSONL)",
	"hermes_json":       "Hermes Agent (.json)",
	"hermes_db":         "Hermes Agent (DB)",
	"claude_code":       "Claude Code",
	"claude_code_jsonl": "Claude Code (JSONL)",
	"codex_cli":         "Codex CLI",
	"codex_rollout":     "Codex CLI (Rollout)",
	"gemini_cli":        "Gemini CLI",
	"qwen_code":         "Qwen Code",
	"opencode":          "OpenCode",
	"opencode_db":       "OpenCode (DB)",
	"openclaw":          "OpenClaw",
	"copilot_cli":       "Copilot CLI",
	"kimi_cli":          "Kimi CLI",
	"pi":                "Pi",
	"oh_my_pi":          "Oh My Pi",
	"aider":             "Aider",
	"cursor":            "Cursor",
	"cline":             "Cline",
	"generic":           "Generic JSON/JSONL",
}

Functions

func CachePath

func CachePath() string

CachePath returns the file path where pricing cache is stored.

func ClampLoopWaste added in v0.4.0

func ClampLoopWaste(loopCost, totalCost float64) float64

func ClearSessionCache

func ClearSessionCache() error

ClearSessionCache removes the session cache file.

func DiscoverSessionDirs

func DiscoverSessionDirs() []string

DiscoverSessionDirs returns all well-known agent session directories found on this machine.

func FindReportableSessionFilesCached added in v0.4.0

func FindReportableSessionFilesCached(dir string, cache SessionCache) []string

FindReportableSessionFilesCached 返回与 overview 默认数据源一致的文件列表: SQLite 托管的数据源存在时,跳过对应的旧文件目录。

func FindSessionFiles

func FindSessionFiles(dir string) []string

func FindSessionFilesCached

func FindSessionFilesCached(dir string, cache SessionCache) []string

FindSessionFilesCached discovers session files using cached directory listings. It still checks directory mtimes so newly written sessions are picked up incrementally, but unchanged directories do not need ReadDir.

func FmtDuration

func FmtDuration(sec float64) string

func HealthBar

func HealthBar(h int) string

func HealthEmoji

func HealthEmoji(h int) string

func HealthScore

func HealthScore(m Metrics, anoms []Anomaly) int

func ListPricing

func ListPricing() map[string]Price

ListPricing returns all pricing entries (for --list-models display).

func LoopCostSection

func LoopCostSection(lc LoopCost) string

LoopCostSection generates the loop cost breakdown section for text reports.

func LoopWastePercent added in v0.4.0

func LoopWastePercent(loopCost, totalCost float64) float64

func PricingSource

func PricingSource() string

PricingSource returns a human-readable description of active pricing.

func ReportCompare

func ReportCompare(sessions []Session, model string) string

ReportCompare generates multi-session comparison text.

func ReportCompareJSON

func ReportCompareJSON(sessions []Session, model string) string

ReportCompareJSON generates multi-session comparison JSON.

func ReportJSON

func ReportJSON(m Metrics, anoms []Anomaly, h int) string

ReportJSON generates the JSON report.

func ReportOverview

func ReportOverview(ov Overview, sessions []Session) string

ReportOverview generates the CLI overview dashboard text.

func ReportOverviewHTML

func ReportOverviewHTML(ov Overview, sessions []Session) string

ReportOverviewHTML generates a self-contained HTML report for CI artifacts and sharing.

func ReportOverviewJSON

func ReportOverviewJSON(ov Overview, sessions []Session) string

ReportOverviewJSON generates machine-readable global overview data.

func ReportOverviewMarkdown

func ReportOverviewMarkdown(ov Overview, sessions []Session) string

ReportOverviewMarkdown generates a human-readable Markdown overview for PR comments and CI artifacts.

func ReportText

func ReportText(m Metrics, anoms []Anomaly, h int) string

ReportText generates the formatted text report.

func SaveSessionCache

func SaveSessionCache(sc SessionCache) error

SaveSessionCache atomically writes the session cache to disk.

func SessionCachePath

func SessionCachePath() string

SessionCachePath returns the on-disk session cache path.

func SuccessRate

func SuccessRate(ok, total int) string

func UpdatePricing

func UpdatePricing() (int, error)

UpdatePricing downloads the latest LiteLLM pricing and caches it. Returns the number of chat models loaded.

func ValidCachedSessionCount added in v0.4.0

func ValidCachedSessionCount(paths []string, cache SessionCache) int

func WasteReportText

func WasteReportText(wr WasteReport) string

Types

type AgentOverview

type AgentOverview struct {
	Sessions int
	Cost     float64
}

AgentOverview holds per-agent aggregate stats.

type AggregateStats

type AggregateStats struct {
	TotalSessions int
	Healthy       int
	Warning       int
	Critical      int
	AvgHealth     float64
	TotalCost     float64
}

AggregateStats holds aggregate metrics for the health panel.

func ComputeAggregateStats

func ComputeAggregateStats(sessions []Session) AggregateStats

ComputeAggregateStats computes AggregateStats from sessions.

type Anomaly

type Anomaly struct {
	Type     string `json:"type"`
	Severity string `json:"severity"`
	Emoji    string `json:"emoji"`
	Detail   string `json:"detail"`
}

func DetectAnomalies

func DetectAnomalies(m Metrics) []Anomaly

type AnomalyTop

type AnomalyTop struct {
	Session  string
	Type     string
	Age      string // human-readable relative time
	Severity string `json:"-"`
}

AnomalyTop is a lightweight anomaly reference for the overview.

type CacheEfficiency

type CacheEfficiency struct {
	CacheWriteTokens int
	CacheReadTokens  int
	TotalInputTokens int
	HitRate          float64
	WastedTokens     int
	WastedCost       float64
	Rating           string
	Suggestion       string
}

func AnalyzeCacheEfficiency

func AnalyzeCacheEfficiency(m Metrics) CacheEfficiency

type CacheEntry

type CacheEntry struct {
	ModTime int64   `json:"mod_time"`
	Size    int64   `json:"size"`
	Session Session `json:"session"`
}

CacheEntry pairs a session file's mtime+size with its parsed Session.

type ContextUtilization

type ContextUtilization struct {
	EstimatedTotal   int
	ToolDefinitions  int
	ConversationHist int
	SystemPrompt     int
	AvailableForTask int
	UtilizationPct   float64
	RiskLevel        string // "critical"/"warning"/"good"
	Suggestion       string
}

func AnalyzeContextUtilization

func AnalyzeContextUtilization(events []Event, model string, mcpToolCount int) ContextUtilization

type CostAlert

type CostAlert struct {
	Triggered bool
	Level     string  // "critical"/"warning"/"info"
	Message   string  // 预警消息
	Current   float64 // 当前值
	Baseline  float64 // 基线值
	Ratio     float64 // 比值
}

CostAlert 成本预警

func PredictCostAnomaly

func PredictCostAnomaly(sessions []Session, current Session) CostAlert

PredictCostAnomaly 预测当前会话是否存在成本异常。 sessions: 历史会话列表(用于计算基线),current: 当前会话。

type CostSummary

type CostSummary struct {
	TotalSessions   int
	TotalCost       float64
	TotalTokensIn   int
	TotalTokensOut  int
	TotalCacheRead  int
	TotalCacheWrite int
	AvgCostPerTurn  float64
	CostliestModel  string
	CostliestCost   float64
}

func ComputeCostSummary

func ComputeCostSummary(sessions []Session) CostSummary

type DiffEntry

type DiffEntry struct {
	Field  string // 字段名
	ValueA string // 会话A的值
	ValueB string // 会话B的值
	Delta  string // 变化方向 "↑"/"↓"/"→"
	Better string // "A"/"B"/"same" 哪个更好
}

DiffEntry 单条差异

type DirCacheEntry

type DirCacheEntry struct {
	ModTime int64    `json:"mod_time"`
	Files   []string `json:"files"`
	Dirs    []string `json:"dirs"`
}

DirCacheEntry stores one directory listing so startup can stat directories and only re-read directories whose mtime changed.

type Event

type Event struct {
	Role       string
	Content    string
	Timestamp  string
	Reasoning  string
	Redacted   bool
	ToolCalls  []ToolCall `json:"tool_calls"`
	ToolCallID string     `json:"tool_call_id"`
	IsError    bool       `json:"is_error"`
	Usage      map[string]int
	ModelUsed  string
	SourceTool string // which tool produced this session
}

func Parse

func Parse(path string) ([]Event, error)

type FixSuggestion

type FixSuggestion struct {
	Title       string // 标题 e.g. "添加工具超时"
	Description string // 描述 e.g. "检测到 %d 个间隔 >60s"
	Action      string // 可操作的建议 e.g. "为长时间运行的工具添加 timeout 参数"
	Severity    string // "high"/"medium"/"low"
	Category    string // "hanging"/"tool_failure"/"thinking"/"redaction"/"no_tools"
}

FixSuggestion 修复建议

func GenerateFixes

func GenerateFixes(m Metrics, anomalies []Anomaly) []FixSuggestion

GenerateFixes builds a list of actionable fix suggestions from anomalies and metrics.

type FormatInfo

type FormatInfo struct {
	Format string
	Raw    []byte                 // full file content, shared with Parse() to avoid re-reading
	Doc    map[string]interface{} // parsed top-level JSON if single blob
	Arr    []interface{}          // parsed top-level JSON array
}

FormatInfo holds detected format + the parsed top-level data (to avoid re-reading).

func DetectFormat

func DetectFormat(path string) FormatInfo

type HealthTrend

type HealthTrend struct {
	Points     []TrendPoint // 最近10个session的趋势点
	Direction  string       // "up"/"down"/"stable"
	AvgHealth  float64
	Regressing bool   // 是否在退化
	Message    string // 趋势描述
}

HealthTrend 健康趋势分析

func AnalyzeHealthTrend

func AnalyzeHealthTrend(sessions []Session) HealthTrend

AnalyzeHealthTrend 分析最近 10 个 session 的健康趋势。 使用 3 点移动平均平滑数据,检测退化信号。

type KnownSessionDir

type KnownSessionDir struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

KnownSessionDir describes a well-known local agent session directory.

func KnownSessionDirs

func KnownSessionDirs() []KnownSessionDir

KnownSessionDirs returns the well-known agent session directory candidates.

type LargeParamCall

type LargeParamCall struct {
	ToolName  string
	ParamSize int
	Timestamp string
	Risk      string // "high" (>50KB), "medium" (>10KB)
	Detail    string
}

func DetectLargeParams

func DetectLargeParams(events []Event) []LargeParamCall

type LiteLLMModel

type LiteLLMModel struct {
	InputCost  float64 `json:"input_cost_per_token"`
	OutputCost float64 `json:"output_cost_per_token"`
	CacheWCost float64 `json:"cache_creation_input_token_cost"`
	CacheRCost float64 `json:"cache_read_input_token_cost"`
	Mode       string  `json:"mode"`
	Provider   string  `json:"litellm_provider"`
}

LiteLLMModel is the raw LiteLLM JSON entry for a chat model.

type LoopCost

type LoopCost struct {
	RetryCost       float64 `json:"retry_cost"`
	ToolLoopCost    float64 `json:"tool_loop_cost"`
	FormatRetryCost float64 `json:"format_retry_cost"`
	TotalLoopCost   float64 `json:"total_loop_cost"`
	RetryEvents     int     `json:"retry_events"`
	LoopGroups      int     `json:"loop_groups"`
}

func ClampLoopCostToTotal added in v0.4.0

func ClampLoopCostToTotal(lc LoopCost, totalCost float64) LoopCost

func ComputeLoopCost

func ComputeLoopCost(events []Event) LoopCost

ComputeLoopCost computes a detailed LoopCost breakdown from events.

type LoopFingerprint

type LoopFingerprint struct {
	ToolName   string
	ResultHash string
	Count      int
	FirstIndex int
	LastIndex  int
	Severity   string
	Detail     string
}

func DetectFingerprintLoops

func DetectFingerprintLoops(events []Event) []LoopFingerprint

type LoopResult

type LoopResult struct {
	HasLoop  bool
	LoopType string // "retry", "tool_loop", etc.
	Turns    int
	LoopCost float64
}

LoopResult is the result of analyzing events for loops.

func AnalyzeLoops

func AnalyzeLoops(events []Event) LoopResult

AnalyzeLoops detects redundant/looping behavior in events. It looks for patterns of repeated tool calls with the same name.

func ClampLoopResultToTotal added in v0.4.0

func ClampLoopResultToTotal(lr LoopResult, totalCost float64) LoopResult

type Metrics

type Metrics struct {
	EventsTotal     int
	UserMessages    int
	AssistantTurns  int
	ToolResults     int
	ToolCallsTotal  int
	ToolCallsOK     int
	ToolCallsFail   int
	ToolUsage       map[string]int
	ReasoningBlocks int
	ReasoningChars  int
	ReasoningLens   []int
	ReasoningRedact int
	TokensInput     int
	TokensOutput    int
	TokensCacheW    int
	TokensCacheR    int
	Timestamps      []time.Time
	GapsSec         []float64
	ModelUsed       string
	SourceTool      string
	SessionStart    string
	SessionEnd      string
	DurationSec     float64
	CostEstimated   float64
	LoopRetryEvents int     `json:"-"`
	LoopGroups      int     `json:"-"`
	LoopCostEst     float64 `json:"-"`
}

func Analyze

func Analyze(events []Event, model string) Metrics

type ModelOverview

type ModelOverview struct {
	Sessions int
	Cost     float64
}

ModelOverview holds per-model aggregate stats.

type Overview

type Overview struct {
	TotalSessions int
	Healthy       int
	Warning       int
	Critical      int
	TotalCost     float64
	AnomaliesTop  []AnomalyTop
	ByAgent       map[string]AgentOverview
	ByModel       map[string]ModelOverview
}

Overview aggregates all sessions for the dashboard.

func ComputeOverview

func ComputeOverview(sessions []Session) Overview

ComputeOverview builds the global dashboard overview from loaded sessions.

type Price

type Price struct {
	Input  float64
	Output float64
	CW     float64
	CR     float64
}

func LookupPrice

func LookupPrice(model string) Price

LookupPrice finds the best matching price for a raw model name. Tries: exact match → normalized → fuzzy variants → builtin → default.

type PromptChange

type PromptChange struct {
	SessionName string
	Before      string // 变更前摘要
	After       string // 变更后摘要
	Impact      string // 影响描述
	HealthDelta int
	CostDelta   float64
}

PromptChange 一次 prompt 变更

type PromptImpact

type PromptImpact struct {
	Changes    []PromptChange
	Trend      string // "improving"/"worsening"/"mixed"
	Suggestion string
}

PromptImpact 变更影响分析

func AnalyzePromptImpact

func AnalyzePromptImpact(sessions []Session) PromptImpact

AnalyzePromptImpact 分析同名 agent 的连续 session,评估 prompt 变更的影响。 名称前缀相同的 session 视为同一 agent 的多次运行。

type Session

type Session struct {
	Name      string
	Path      string
	Metrics   Metrics
	Anomalies []Anomaly
	Health    int
	LoopCost  LoopCost

	// v0.2: community-driven diagnostics (pre-computed in LoadSession)
	LoopFingerprints   []LoopFingerprint
	ToolLatencies      []ToolLatencyItem
	ContextUtil        ContextUtilization
	LargeParams        []LargeParamCall
	UnusedTools        []UnusedToolInfo
	StuckPatternsExtra []StuckPattern
	LoopResultData     LoopResult
	ToolWarnings       []ToolWarning
}

func CachedSession

func CachedSession(path string, cache SessionCache) (Session, bool)

CachedSession returns a parsed session only when file metadata still matches.

func FilterSessions

func FilterSessions(sessions []Session, query string) []Session

FilterSessions filters sessions by a text query (case-insensitive match on Name and SourceTool).

func LoadAll

func LoadAll(dir string) []Session

func LoadSQLiteBackedSessions added in v0.4.0

func LoadSQLiteBackedSessions() []Session

LoadSQLiteBackedSessions 返回以本地 SQLite 为权威来源的会话。

func LoadSession

func LoadSession(path string) (*Session, error)

func LocalizeSession added in v0.3.43

func LocalizeSession(s Session) Session

LocalizeSession 为缓存命中的会话重建当前语言下的诊断文案。

func ScanAllDirs

func ScanAllDirs() []Session

ScanAllDirs discovers and loads sessions from all known agent directories.

type SessionCache

type SessionCache struct {
	Entries map[string]CacheEntry    `json:"entries"`
	Dirs    map[string]DirCacheEntry `json:"dirs,omitempty"`
	// contains filtered or unexported fields
}

SessionCache holds all cached session entries.

func LoadSessionCache

func LoadSessionCache() SessionCache

LoadSessionCache 从磁盘读取会话缓存,完整 Session 会按需解码。

func (SessionCache) EntryCount added in v0.3.47

func (sc SessionCache) EntryCount() int

EntryCount 返回缓存文件中的唯一会话条目数。

type SessionDiff

type SessionDiff struct {
	SessionA string
	SessionB string
	Entries  []DiffEntry
	Summary  string // 一句话总结
}

SessionDiff 会话差异报告

func DiffSessions

func DiffSessions(a, b Session) SessionDiff

DiffSessions 逐字段对比两个会话并生成差异报告。

type StuckPattern

type StuckPattern struct {
	Pattern     string
	Description string
	Severity    string
}

func DetectStuckPatterns

func DetectStuckPatterns(events []Event) []StuckPattern

func DetectStuckPatternsEnhanced

func DetectStuckPatternsEnhanced(events []Event) []StuckPattern

type ToolBloatAnalysis

type ToolBloatAnalysis struct {
	ToolsPerTurn   float64
	TotalToolCost  float64
	RedundantCalls int
	BloatScore     int
	BloatLevel     string
	Suggestion     string
	TopBloat       []ToolBloatItem
}

func AnalyzeToolBloat

func AnalyzeToolBloat(m Metrics) ToolBloatAnalysis

type ToolBloatItem

type ToolBloatItem struct {
	ToolName    string
	CallCount   int
	TotalCost   float64
	IsRedundant bool
}

ToolBloatItem tracks per-tool usage metrics.

type ToolCall

type ToolCall struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Args string `json:"args,omitempty"`
}

type ToolLatencyItem

type ToolLatencyItem struct {
	ToolName string
	Count    int
	AvgSec   float64
	P95Sec   float64
	MaxSec   float64
	MinSec   float64
	Timeouts int
	IsSlow   bool // p95 > 30s
}

func AnalyzeToolLatency

func AnalyzeToolLatency(events []Event) []ToolLatencyItem

type ToolWarning

type ToolWarning struct {
	ToolName string
	Pattern  string // "dead_loop"/"empty_args"/"invalid_args"/"fail_retry_chain"/"redundant"
	Count    int    // 出现次数
	Detail   string // 详细描述
	Severity string
}

ToolWarning 工具使用警告

func ValidateToolPatterns

func ValidateToolPatterns(events []Event) []ToolWarning

ValidateToolPatterns 分析事件流中的工具调用模式,检测异常使用模式。

type TrendPoint

type TrendPoint struct {
	Name   string
	Health int
	Cost   float64
}

TrendPoint 趋势数据点

type UnusedToolInfo

type UnusedToolInfo struct {
	ToolName  string
	CallCount int
	Level     string // "rare"/"normal"
	Detail    string
}

func DetectUnusedTools

func DetectUnusedTools(events []Event) []UnusedToolInfo

type WasteReport

type WasteReport struct {
	Cache       CacheEfficiency
	Bloat       ToolBloatAnalysis
	Stuck       []StuckPattern
	LoopCost    float64
	LoopPercent float64
	WasteScore  int
	WasteLevel  string
	TotalWasted float64
	Summary     string
	TopActions  []string
}

func ComputeWasteReport

func ComputeWasteReport(m Metrics, events []Event, loopResult LoopResult) WasteReport

func ComputeWasteReportFromSession

func ComputeWasteReportFromSession(s *Session) WasteReport

ComputeWasteReportFromSession computes the waste report using a pre-loaded Session's diagnostics. Avoids re-parsing the session file.

Jump to

Keyboard shortcuts

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