/** * Analytics Module v3 * * Manages repository-wide analytics stored as a git note on the root commit. * Provides aggregated stats and time-series data for trending. * * Storage: refs/notes/agentblame-analytics (attached to root commit) */ import type { AnalyticsNote, AnalyticsSummary, ContributorStats, PREntry, AgentBreakdown, ModelBreakdown, SessionMetadata, HourlyDataPoint, DailyDataPoint } from "./types"; /** * Get the analytics anchor commit (root commit) */ export declare function getAnalyticsAnchor(repoRoot: string): Promise; /** * Read the analytics note */ export declare function readAnalyticsNote(repoRoot: string): Promise; /** * Write the analytics note */ export declare function writeAnalyticsNote(repoRoot: string, analytics: AnalyticsNote): Promise; /** * Stats for a single commit */ export interface CommitStats { aiLines: number; humanLines: number; byAgent: AgentBreakdown; byModel: ModelBreakdown; sessions: string[]; } /** * Compute stats from a commit's attribution */ export declare function computeCommitStats(sessions: Record, fileAttributions: Record; humanRanges: Array<{ startLine: number; endLine: number; }>; }>): CommitStats; /** * Merge commit stats into existing analytics */ export declare function mergeAnalytics(existing: AnalyticsNote | null, commitStats: CommitStats, commitAuthor?: string): AnalyticsNote; /** * Add a PR entry to analytics */ export declare function addPREntry(analytics: AnalyticsNote, pr: PREntry): AnalyticsNote; /** * Update analytics after a commit is processed */ export declare function updateAnalytics(repoRoot: string, commitStats: CommitStats, commitAuthor?: string): Promise; /** * Supported time ranges for analytics */ export type TimeRange = "24h" | "3d" | "1w" | "1m" | "all"; /** * Unified data point for trend queries */ export interface TrendDataPoint { label: string; aiLines: number; humanLines: number; byAgent: AgentBreakdown; byModel: ModelBreakdown; commits: number; } /** * Get hourly trend data for a specific number of hours */ export declare function getHourlyTrend(analytics: AnalyticsNote, hours?: number): HourlyDataPoint[]; /** * Get daily trend data for a specific number of days */ export declare function getDailyTrend(analytics: AnalyticsNote, days?: number): DailyDataPoint[]; /** * Get trend data for a specific time range * Returns unified TrendDataPoint array */ export declare function getTrendForRange(analytics: AnalyticsNote, range: TimeRange): TrendDataPoint[]; /** * Calculate AI percentage trend for a time range */ export declare function getAIPercentTrend(analytics: AnalyticsNote, range?: TimeRange): Array<{ label: string; percent: number; }>; /** * Get tool (agent) usage trend for a time range */ export declare function getToolTrend(analytics: AnalyticsNote, range?: TimeRange): Array<{ label: string; cursor: number; claude: number; opencode: number; }>; /** * Get model usage trend (top N models) for a time range */ export declare function getModelTrend(analytics: AnalyticsNote, range?: TimeRange, topN?: number): Array<{ label: string; models: Record; }>; /** * Get commit activity trend for a time range */ export declare function getCommitTrend(analytics: AnalyticsNote, range?: TimeRange): Array<{ label: string; commits: number; aiLines: number; humanLines: number; }>; /** * Get summary stats for a time range */ export declare function getRangeSummary(analytics: AnalyticsNote, range: TimeRange): { aiLines: number; humanLines: number; commits: number; byAgent: AgentBreakdown; byModel: ModelBreakdown; }; /** * Get summary statistics */ export declare function getSummary(repoRoot: string): Promise; /** * Get contributor statistics */ export declare function getContributorStats(repoRoot: string, email: string): Promise; /** * Get recent PRs */ export declare function getRecentPRs(repoRoot: string, limit?: number): Promise; /** * Calculate AI percentage */ export declare function calculateAIPercentage(summary: AnalyticsSummary): number; /** * Format analytics summary for display */ export declare function formatSummary(summary: AnalyticsSummary): string; /** * Format contributor stats for display */ export declare function formatContributorStats(email: string, stats: ContributorStats): string; /** * Format trend data as ASCII sparkline */ export declare function formatSparkline(values: number[], width?: number): string; /** * Format trend summary for display */ export declare function formatTrendSummary(analytics: AnalyticsNote, range?: TimeRange): string; /** * Initialize analytics note if it doesn't exist */ export declare function initAnalytics(repoRoot: string): Promise; /** * Reset analytics to initial state */ export declare function resetAnalytics(repoRoot: string): Promise; /** * Configure git to push analytics notes */ export declare function configureAnalyticsSync(repoRoot: string): Promise; /** * Fetch analytics notes from remote */ export declare function fetchAnalyticsNotes(repoRoot: string): Promise; /** * Push analytics notes to remote */ export declare function pushAnalyticsNotes(repoRoot: string): Promise;