Documentation
¶
Overview ¶
Package intel provides analytical intelligence over Claude Code session data. It transforms raw discovery data into actionable summaries and reports.
Index ¶
- Constants
- func CalculateMomentum(metrics DayMetrics) (score float64, components map[string]float64)
- func FormatBrief(summary SessionSummary) string
- func FormatComparison(cmp DayComparison) string
- func FormatCostReport(report CostReport) string
- func FormatDailyBrief(brief DailyBrief) string
- func FormatMomentum(score float64, components map[string]float64) string
- func ParseSinceFlag(value string) (time.Time, error)
- func RunAIBrief()
- func RunCostReport()
- func RunMetricsReport()
- func SummarizeActivities(activities []Activity) []string
- type Activity
- type CostReport
- type DailyBrief
- type DayComparison
- type DayMetrics
- type ProjectBrief
- type ProjectDayMetrics
- type SessionCost
- type SessionSummary
Constants ¶
const ( ActivityUserRequest = "user_request" ActivityFileEdit = "file_edit" ActivityBashCommand = "bash_command" ActivityGitOp = "git_op" ActivityError = "error" ActivityToolCall = "tool_call" )
Activity type constants.
Variables ¶
This section is empty.
Functions ¶
func CalculateMomentum ¶
func CalculateMomentum(metrics DayMetrics) (score float64, components map[string]float64)
CalculateMomentum computes the Momentum score from Codex's recommendation. Four components: Outcome, Validation, Flow, Drag.
func FormatBrief ¶
func FormatBrief(summary SessionSummary) string
FormatBrief renders a single SessionSummary as a human-readable text block.
func FormatComparison ¶
func FormatComparison(cmp DayComparison) string
FormatComparison renders a day comparison as a readable report.
func FormatCostReport ¶ added in v0.5.0
func FormatCostReport(report CostReport) string
FormatCostReport renders a cost report as human-readable text.
func FormatDailyBrief ¶
func FormatDailyBrief(brief DailyBrief) string
FormatDailyBrief renders a DailyBrief as a human-readable plaintext report suitable for stdout or piping into other tools.
func FormatMomentum ¶
FormatMomentum renders the Momentum score as a brief display.
func ParseSinceFlag ¶
ParseSinceFlag parses the --since flag value into a time.Time. Supported formats:
- "" (empty) -> 24 hours ago (default)
- "24h", "12h", "48h" etc -> duration ago
- "yesterday" -> yesterday at 9:00 AM local time
func RunAIBrief ¶ added in v0.5.0
func RunAIBrief()
RunAIBrief generates a structured brief, then uses claude -p to produce a natural language summary. This is opt-in because it costs tokens.
func RunCostReport ¶ added in v0.5.0
func RunCostReport()
RunCostReport is the entrypoint for the `opsdeck costs` subcommand.
func RunMetricsReport ¶
func RunMetricsReport()
RunMetricsReport generates and prints the full metrics comparison report.
func SummarizeActivities ¶
SummarizeActivities condenses a list of raw activities into at most 5 human-readable bullet points suitable for an executive summary.
The algorithm:
- User requests appear verbatim (they are what the user asked for).
- File edits are grouped: "Edited N files (a.go, b.go, ...)"
- Bash commands are grouped: "Ran N commands"
- Git operations are grouped: "Committed and pushed changes" / "Created PR"
- Errors are grouped: "Encountered N errors"
- Tool calls (Grep, Glob, etc.) are omitted -- they are noise.
Results are capped at 5 items with user requests taking priority.
Types ¶
type Activity ¶
type Activity struct {
Timestamp time.Time
Type string // one of the Activity* constants
Description string
}
Activity represents a single discrete event extracted from a transcript.
type CostReport ¶ added in v0.5.0
type CostReport struct {
Sessions []SessionCost
TotalCost float64
TotalTokens int64
Period string
}
CostReport holds the full cost report across all sessions.
func GenerateCostReport ¶ added in v0.5.0
func GenerateCostReport(projectsDir, sessionsDir string, since time.Time) (CostReport, error)
GenerateCostReport scans all sessions and produces a cost report.
type DailyBrief ¶
type DailyBrief struct {
GeneratedAt time.Time
Period string // "Last 24 hours" or "Since yesterday 9am"
Projects []ProjectBrief
TotalSessions int
ActiveSessions int
TotalEdits int
TotalCommands int
Highlights []string // top 3-5 most notable things
Attention []string // things that need the user's attention
}
DailyBrief is the top-level daily report summarizing all Claude Code sessions.
func GenerateBrief ¶
func GenerateBrief(projectsDir, sessionsDir string, since time.Time) (DailyBrief, error)
GenerateBrief scans all sessions and produces a daily brief covering activity since the given time. It reads session files from sessionsDir, locates transcripts under projectsDir, and aggregates per-project summaries.
If directories do not exist, it returns a valid but empty brief.
type DayComparison ¶
type DayComparison struct {
Today DayMetrics
Yesterday DayMetrics
// Deltas (positive = improvement)
EditsDelta int
CommandsDelta int
FilesDelta int
SessionsDelta int
ProjectsDelta int
ErrorsDelta int
// Overall trend
Trend string // "more productive", "similar", "less productive"
}
DayComparison compares two days of metrics.
func CompareDays ¶
func CompareDays(projectsDir, sessionsDir string) DayComparison
CompareDays computes metrics for today and yesterday and returns a comparison.
type DayMetrics ¶
type DayMetrics struct {
Date string // "2026-03-22"
ActiveSessions int // sessions with any activity
TotalEdits int // file edits across all sessions
TotalCommands int // bash commands across all sessions
TotalErrors int // errors encountered
FilesChanged int // unique files touched
GitOps int // git operations (commits, pushes, PRs)
Projects int // unique projects with activity
// Per-project breakdown
ProjectMetrics []ProjectDayMetrics
}
DayMetrics holds quantified productivity metrics for a single day.
func ComputeDayMetrics ¶
func ComputeDayMetrics(projectsDir, sessionsDir string, day time.Time) DayMetrics
ComputeDayMetrics computes metrics for a specific day across all sessions.
type ProjectBrief ¶
type ProjectBrief struct {
Name string
Path string
SessionCount int
ActiveCount int // sessions with activity in period
TotalEdits int
TotalCommands int
FilesChanged []string
KeyActivities []string // top 5 most important activities
NeedsAttention bool // any session stuck/waiting/errored
AttentionReason string
}
ProjectBrief summarizes activity for a single project over a time period.
type ProjectDayMetrics ¶
type ProjectDayMetrics struct {
Name string
Edits int
Commands int
Errors int
Files int
GitOps int
Sessions int // sessions with activity
}
ProjectDayMetrics holds metrics for a single project on a single day.
type SessionCost ¶ added in v0.5.0
type SessionCost struct {
SessionID string
Project string
Model string
InputTokens int64
OutputTokens int64
CacheWrite int64
CacheRead int64
TotalTokens int64
EstCostUSD float64
MessageCount int
}
SessionCost holds token usage and estimated cost for a session.
func ExtractCosts ¶ added in v0.5.0
func ExtractCosts(path string, since time.Time) (SessionCost, error)
ExtractCosts reads a transcript JSONL and returns token usage/cost data.
type SessionSummary ¶
type SessionSummary struct {
SessionID string
Project string
Activities []Activity
FilesChanged []string
LastUserMsg string
LastAssistMsg string
TotalMessages int
ErrorCount int
EditCount int
BashCount int
ReadCount int
}
SessionSummary holds a complete activity summary for a single session.
func ExtractRecent ¶
func ExtractRecent(path string, since time.Time) (SessionSummary, error)
ExtractRecent reads a transcript and returns a summary of activity after `since`. If the file does not exist, returns an empty summary and no error.
func ExtractSummary ¶
func ExtractSummary(path string) (SessionSummary, error)
ExtractSummary reads an entire transcript and returns a full SessionSummary. If the file does not exist or is empty, returns an empty summary and no error.