Documentation
¶
Overview ¶
Package insights provides AI-powered project analytics and recommendations. It analyzes task completion patterns, velocity, risk, and generates actionable insights.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CrossInsightPrompt ¶
func CrossInsightPrompt(m *CrossMetrics) string
CrossInsightPrompt builds the AI prompt for cross-project analysis.
Types ¶
type CrossInsightReport ¶
type CrossInsightReport struct {
Metrics *CrossMetrics
VelocityTrends string
FailurePatterns string
ProviderPerf string
Recommendations string
GeneratedAt time.Time
}
CrossInsightReport is the full result of a cross-project analysis.
func GenerateCross ¶
func GenerateCross(ctx context.Context, p provider.Provider, model string, timeout time.Duration, snaps []*ProjectSnapshot) (*CrossInsightReport, error)
GenerateCross runs AI analysis on cross-project metrics and returns a structured report.
type CrossMetrics ¶
type CrossMetrics struct {
Projects []ProjectSnapshot
TotalProjects int
ActiveProjects int // projects with at least one task
TotalTasksAcross int
TotalDoneAcross int
TotalFailedAcross int
AvgCompletionRate float64 // mean completion % across projects
TopTags []TagCount
TopRoles []TagCount
TopFailureKeywords []TagCount
ProviderCounts map[string]int
VelocityMin float64
VelocityMax float64
VelocityMean float64
}
CrossMetrics aggregates metrics across multiple projects.
func AggregateProjects ¶
func AggregateProjects(snaps []*ProjectSnapshot) *CrossMetrics
AggregateProjects computes cross-project metrics from a list of snapshots.
type InsightReport ¶
InsightReport is the full AI-generated analysis.
type Metrics ¶
type Metrics struct {
TotalTasks int
DoneTasks int
FailedTasks int
SkippedTasks int
InProgressTasks int
PendingTasks int
BlockedTasks int // permanently blocked by failed deps
// Velocity: tasks completed per day (based on CompletedAt timestamps)
VelocityPerDay float64
// AvgTaskDuration is the mean duration of completed tasks.
AvgTaskDuration time.Duration
// EstimatedDaysRemaining is a rough forecast based on velocity.
// -1 means not enough data.
EstimatedDaysRemaining float64
// RiskScore is 0-100 (0 = low risk, 100 = critical).
RiskScore int
// RiskFactors lists what contributed to the risk score.
RiskFactors []string
// RoleBreakdown maps role name to counts {done, total}.
RoleBreakdown map[string][2]int
// TokenCost tracks session token usage.
InputTokens int
OutputTokens int
}
Metrics holds computed project health metrics.
func Analyze ¶
func Analyze(s *state.ProjectState) *Metrics
Analyze computes metrics from the current project state.
func (*Metrics) CompletionPct ¶
CompletionPct returns percentage of tasks done or skipped.
type ProjectSnapshot ¶
type ProjectSnapshot struct {
Name string
Path string
Goal string
Provider string
TotalTasks int
DoneTasks int
FailedTasks int
SkippedTasks int
PendingTasks int
CompletionPct float64
Tags []string // deduplicated tags from all tasks
Roles []string // deduplicated roles from all tasks
FailureReasons []string // short failure summaries from task results
VelocityPerDay float64
AvgTaskDuration time.Duration
LastUpdated time.Time
Error string // non-empty if loading failed
}
ProjectSnapshot holds the metrics collected from a single project.
func CollectFromProject ¶
func CollectFromProject(name, path string) *ProjectSnapshot
CollectFromProject reads one project's state and builds a ProjectSnapshot. Returns a snapshot with Error set if loading failed (non-fatal).
func CollectFromWorkspaces ¶
func CollectFromWorkspaces(wsFile string) ([]*ProjectSnapshot, error)
CollectFromWorkspaces loads all registered workspaces and returns per-project snapshots. Uses wsFile if non-empty, otherwise the global workspace registry.