Skip to content

Commit ec5f454

Browse files
committed
fix: gofumpt formatting + go mod tidy for v0.2.0 deps
1 parent 1722d76 commit ec5f454

410 files changed

Lines changed: 3086 additions & 2874 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

agents/persona.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,26 @@ func BuildSystemPrompt(persona *Persona, projectContext string) string {
238238

239239
// expertiseKeywords maps expertise domains to keywords for task matching.
240240
var expertiseKeywords = map[string][]string{
241-
"security": {"security", "vulnerability", "cve", "injection", "xss", "csrf", "auth", "authentication",
242-
"authorization", "encrypt", "secret", "owasp", "penetration", "exploit"},
243-
"testing": {"test", "spec", "assert", "mock", "stub", "coverage", "unit test", "integration test",
244-
"e2e", "benchmark", "fuzzing", "fixture"},
245-
"frontend": {"css", "html", "react", "vue", "angular", "component", "ui", "ux", "style",
246-
"responsive", "accessibility", "a11y", "dom", "browser", "tailwind"},
247-
"backend": {"api", "database", "sql", "server", "endpoint", "middleware", "rest", "grpc",
248-
"microservice", "cache", "queue", "migration"},
249-
"devops": {"deploy", "kubernetes", "k8s", "docker", "ci", "cd", "pipeline", "terraform",
250-
"ansible", "helm", "monitoring", "infrastructure", "aws", "gcp", "azure", "nginx"},
241+
"security": {
242+
"security", "vulnerability", "cve", "injection", "xss", "csrf", "auth", "authentication",
243+
"authorization", "encrypt", "secret", "owasp", "penetration", "exploit",
244+
},
245+
"testing": {
246+
"test", "spec", "assert", "mock", "stub", "coverage", "unit test", "integration test",
247+
"e2e", "benchmark", "fuzzing", "fixture",
248+
},
249+
"frontend": {
250+
"css", "html", "react", "vue", "angular", "component", "ui", "ux", "style",
251+
"responsive", "accessibility", "a11y", "dom", "browser", "tailwind",
252+
},
253+
"backend": {
254+
"api", "database", "sql", "server", "endpoint", "middleware", "rest", "grpc",
255+
"microservice", "cache", "queue", "migration",
256+
},
257+
"devops": {
258+
"deploy", "kubernetes", "k8s", "docker", "ci", "cd", "pipeline", "terraform",
259+
"ansible", "helm", "monitoring", "infrastructure", "aws", "gcp", "azure", "nginx",
260+
},
251261
}
252262

253263
// SelectPersona automatically selects the best persona for a given task

agents/persona_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,10 @@ func TestCreateGetDelete_Lifecycle(t *testing.T) {
362362

363363
// Create
364364
p := &Persona{
365-
Name: "lifecycle-test",
366-
Description: "Test persona for lifecycle",
367-
Model: "claude-sonnet-4-6",
368-
Expertise: []string{"testing"},
365+
Name: "lifecycle-test",
366+
Description: "Test persona for lifecycle",
367+
Model: "claude-sonnet-4-6",
368+
Expertise: []string{"testing"},
369369
SystemPrompt: "You are a lifecycle test.",
370370
}
371371
if err := r.Create(p); err != nil {
@@ -457,12 +457,12 @@ func TestBuiltinPersonas_AreValid(t *testing.T) {
457457
builtins := BuiltinPersonas()
458458

459459
expectedNames := map[string]bool{
460-
"default": false,
461-
"reviewer": false,
460+
"default": false,
461+
"reviewer": false,
462462
"architect": false,
463-
"debugger": false,
464-
"teacher": false,
465-
"speed": false,
463+
"debugger": false,
464+
"teacher": false,
465+
"speed": false,
466466
}
467467

468468
for _, p := range builtins {

analytics/activity.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ func (a *ActivityTracker) Summary() string {
113113
ratio = float64(execTime) / float64(userTime)
114114
}
115115

116-
return fmt.Sprintf("User: %s | Agent: %s | Ratio: %.1fx",
116+
return fmt.Sprintf(
117+
"User: %s | Agent: %s | Ratio: %.1fx",
117118
formatDurationCompact(userTime),
118119
formatDurationCompact(execTime),
119120
ratio,

analytics/classify.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ func ClassifyTurn(toolNames []string, userMessage string) TurnCategory {
8383

8484
// OneShotTracker tracks the percentage of edit turns that succeed without retries.
8585
type OneShotTracker struct {
86-
mu sync.Mutex
87-
totalEdits int
88-
retriedEdits int
89-
lastWasEdit bool
86+
mu sync.Mutex
87+
totalEdits int
88+
retriedEdits int
89+
lastWasEdit bool
9090
}
9191

9292
// RecordTurn records a turn's tool usage for one-shot rate calculation.

analytics/classify_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ func TestClassifyTurn_Refactoring(t *testing.T) {
4949

5050
func TestOneShotTracker_AllFirstTry(t *testing.T) {
5151
tr := &OneShotTracker{}
52-
tr.RecordTurn([]string{"Edit"}) // edit
53-
tr.RecordTurn([]string{"Bash"}) // non-edit → previous was one-shot
54-
tr.RecordTurn([]string{"Edit"}) // edit
55-
tr.RecordTurn([]string{"Read"}) // non-edit → previous was one-shot
52+
tr.RecordTurn([]string{"Edit"}) // edit
53+
tr.RecordTurn([]string{"Bash"}) // non-edit → previous was one-shot
54+
tr.RecordTurn([]string{"Edit"}) // edit
55+
tr.RecordTurn([]string{"Read"}) // non-edit → previous was one-shot
5656
rate := tr.Rate()
5757
if rate != 100.0 {
5858
t.Errorf("got %.1f%%, want 100%%", rate)
@@ -61,9 +61,9 @@ func TestOneShotTracker_AllFirstTry(t *testing.T) {
6161

6262
func TestOneShotTracker_WithRetries(t *testing.T) {
6363
tr := &OneShotTracker{}
64-
tr.RecordTurn([]string{"Edit"}) // edit 1
65-
tr.RecordTurn([]string{"Edit"}) // retry → edit 1 was NOT one-shot
66-
tr.RecordTurn([]string{"Bash"}) // non-edit → edit 2 was one-shot
64+
tr.RecordTurn([]string{"Edit"}) // edit 1
65+
tr.RecordTurn([]string{"Edit"}) // retry → edit 1 was NOT one-shot
66+
tr.RecordTurn([]string{"Bash"}) // non-edit → edit 2 was one-shot
6767
total, firstTry := tr.Stats()
6868
if total != 2 {
6969
t.Errorf("total: got %d, want 2", total)

analytics/dashboard.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
// Dashboard provides a local telemetry dashboard for hawk showing usage analytics,
1212
// performance metrics, and session history in a terminal-friendly format.
1313
type Dashboard struct {
14-
Sessions []SessionSummary `json:"sessions"`
15-
DailyStats []DayStat `json:"daily_stats"`
16-
ModelUsage map[string]DashModelStats `json:"model_usage"`
17-
ToolUsage map[string]int `json:"tool_usage"`
14+
Sessions []SessionSummary `json:"sessions"`
15+
DailyStats []DayStat `json:"daily_stats"`
16+
ModelUsage map[string]DashModelStats `json:"model_usage"`
17+
ToolUsage map[string]int `json:"tool_usage"`
1818
TotalCostUSD float64 `json:"total_cost_usd"`
19-
TotalTokens int `json:"total_tokens"`
20-
ActiveDays int `json:"active_days"`
19+
TotalTokens int `json:"total_tokens"`
20+
ActiveDays int `json:"active_days"`
2121
}
2222

2323
// SessionSummary captures key metrics for a single session.

analytics/insights.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ type InsightsFacet struct {
1818

1919
// InsightsReport holds a complete cross-session analysis.
2020
type InsightsReport struct {
21-
GeneratedAt time.Time `json:"generated_at"`
22-
SessionsScanned int `json:"sessions_scanned"`
23-
DateRange DateRange `json:"date_range"`
24-
Facets []InsightsFacet `json:"facets"`
25-
TopPatterns []string `json:"top_patterns"`
26-
Recommendations []string `json:"recommendations"`
27-
Stats *SessionStats `json:"stats,omitempty"`
21+
GeneratedAt time.Time `json:"generated_at"`
22+
SessionsScanned int `json:"sessions_scanned"`
23+
DateRange DateRange `json:"date_range"`
24+
Facets []InsightsFacet `json:"facets"`
25+
TopPatterns []string `json:"top_patterns"`
26+
Recommendations []string `json:"recommendations"`
27+
Stats *SessionStats `json:"stats,omitempty"`
2828
}
2929

3030
// GenerateInsights analyzes session transcripts to extract patterns and recommendations.

analytics/optimize.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
type CostEntry struct {
1212
SessionID string `json:"session_id"`
1313
Model string `json:"model"`
14-
TaskType string `json:"task_type"` // "simple", "generation", "debug", "refactor", "review", "chat"
14+
TaskType string `json:"task_type"` // "simple", "generation", "debug", "refactor", "review", "chat"
1515
InputTokens int `json:"input_tokens"`
1616
OutputTokens int `json:"output_tokens"`
1717
CostUSD float64 `json:"cost_usd"`
@@ -50,7 +50,7 @@ type TaskSpend struct {
5050

5151
// Recommendation represents a cost optimization suggestion.
5252
type Recommendation struct {
53-
Type string `json:"type"` // "downgrade", "batch", "cache"
53+
Type string `json:"type"` // "downgrade", "batch", "cache"
5454
Description string `json:"description"`
5555
Savings float64 `json:"savings"` // estimated USD savings
5656
}
@@ -65,10 +65,10 @@ var modelPricing = map[string]float64{
6565
"sonnet": 3.0,
6666
"haiku": 0.25,
6767
// OpenAI
68-
"gpt-4": 30.0,
69-
"gpt-4-turbo": 10.0,
70-
"gpt-4o": 2.5,
71-
"gpt-4o-mini": 0.15,
68+
"gpt-4": 30.0,
69+
"gpt-4-turbo": 10.0,
70+
"gpt-4o": 2.5,
71+
"gpt-4o-mini": 0.15,
7272
"gpt-3.5-turbo": 0.5,
7373
// Fallback tiers
7474
"expensive": 15.0,
@@ -211,7 +211,8 @@ func generateOptimizationRecs(entries []CostEntry, report *OptimizationReport) [
211211
Description: fmt.Sprintf(
212212
"%d simple tasks were sent to expensive models (total $%.4f). "+
213213
"Route simple questions to a cheaper model (haiku/gpt-4o-mini) to save ~$%.4f.",
214-
simpleOnExpensive, simpleExpensiveCost, savings),
214+
simpleOnExpensive, simpleExpensiveCost, savings,
215+
),
215216
Savings: savings,
216217
})
217218
}
@@ -235,7 +236,8 @@ func generateOptimizationRecs(entries []CostEntry, report *OptimizationReport) [
235236
Description: fmt.Sprintf(
236237
"%d chat/conversational tasks used expensive models ($%.4f). "+
237238
"Consider using sonnet/gpt-4o for general conversation to save ~$%.4f.",
238-
chatCount, chatExpensiveCost, savings),
239+
chatCount, chatExpensiveCost, savings,
240+
),
239241
Savings: savings,
240242
})
241243
}
@@ -261,7 +263,8 @@ func generateOptimizationRecs(entries []CostEntry, report *OptimizationReport) [
261263
Description: fmt.Sprintf(
262264
"High call volume (avg %d calls/task-type). "+
263265
"Enable prompt caching to reduce redundant token costs by ~$%.4f.",
264-
avgCallsPerType, savings),
266+
avgCallsPerType, savings,
267+
),
265268
Savings: savings,
266269
})
267270
}
@@ -276,7 +279,8 @@ func generateOptimizationRecs(entries []CostEntry, report *OptimizationReport) [
276279
Description: fmt.Sprintf(
277280
"%.0f%% of spend ($%.4f) was on abandoned/discarded outputs. "+
278281
"Consider iterating with cheaper models first, then upgrading for final output.",
279-
abandonRate, report.AbandonedSpend),
282+
abandonRate, report.AbandonedSpend,
283+
),
280284
Savings: report.AbandonedSpend * 0.50,
281285
})
282286
}

analytics/session_analytics.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ func (sa *SessionAnalytics) WeeklyTrend() string {
179179
if d.sessions > 0 {
180180
successPct = fmt.Sprintf("%.0f%%", float64(d.success)/float64(d.sessions)*100)
181181
}
182-
sb.WriteString(fmt.Sprintf("%-12s %8d %7s %8s\n",
182+
sb.WriteString(fmt.Sprintf(
183+
"%-12s %8d %7s %8s\n",
183184
d.date.Format("Mon 01/02"),
184185
d.sessions,
185186
fmt.Sprintf("$%.2f", d.cost),
@@ -251,7 +252,8 @@ func (sa *SessionAnalytics) ModelComparison() string {
251252
successRate := float64(e.stats.successes) / float64(e.stats.sessions) * 100
252253
avgDur := e.stats.totalDur / time.Duration(e.stats.sessions)
253254
avgCost := e.stats.totalCost / float64(e.stats.sessions)
254-
sb.WriteString(fmt.Sprintf("%-25s %7.0f%% %10s %9s\n",
255+
sb.WriteString(fmt.Sprintf(
256+
"%-25s %7.0f%% %10s %9s\n",
255257
e.name,
256258
successRate,
257259
fmtSessionDuration(avgDur),

analytics/stats.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ import (
1212

1313
// SessionStats holds aggregated statistics for a user's sessions.
1414
type SessionStats struct {
15-
TotalSessions int `json:"total_sessions"`
16-
TotalMessages int `json:"total_messages"`
17-
TotalDuration time.Duration `json:"total_duration"`
18-
TotalTokens int64 `json:"total_tokens"`
19-
TotalCost float64 `json:"total_cost"`
20-
ToolUsage map[string]int `json:"tool_usage"`
21-
ModelUsage map[string]ModelStats `json:"model_usage"`
22-
LanguageStats map[string]int `json:"language_stats"`
23-
GitCommits int `json:"git_commits"`
24-
ActivityHeatmap [7][24]int `json:"activity_heatmap"` // [weekday][hour]
25-
PeakDay time.Weekday `json:"peak_day"`
26-
PeakHour int `json:"peak_hour"`
27-
DateRange DateRange `json:"date_range"`
15+
TotalSessions int `json:"total_sessions"`
16+
TotalMessages int `json:"total_messages"`
17+
TotalDuration time.Duration `json:"total_duration"`
18+
TotalTokens int64 `json:"total_tokens"`
19+
TotalCost float64 `json:"total_cost"`
20+
ToolUsage map[string]int `json:"tool_usage"`
21+
ModelUsage map[string]ModelStats `json:"model_usage"`
22+
LanguageStats map[string]int `json:"language_stats"`
23+
GitCommits int `json:"git_commits"`
24+
ActivityHeatmap [7][24]int `json:"activity_heatmap"` // [weekday][hour]
25+
PeakDay time.Weekday `json:"peak_day"`
26+
PeakHour int `json:"peak_hour"`
27+
DateRange DateRange `json:"date_range"`
2828
}
2929

3030
// ModelStats tracks usage per model.
3131
type ModelStats struct {
32-
Model string `json:"model"`
33-
Tokens int64 `json:"tokens"`
34-
Requests int `json:"requests"`
35-
AvgLatency float64 `json:"avg_latency_ms"`
36-
Cost float64 `json:"cost"`
32+
Model string `json:"model"`
33+
Tokens int64 `json:"tokens"`
34+
Requests int `json:"requests"`
35+
AvgLatency float64 `json:"avg_latency_ms"`
36+
Cost float64 `json:"cost"`
3737
}
3838

3939
// DateRange represents the time span of statistics.

0 commit comments

Comments
 (0)