/** * Archive analytics — rich reporting and insights from archived tasks. * * Moved from CLI archive-stats command to core for reuse across * CLI and programmatic consumers. * * @task T4555 * @epic T4545 */ import type { DataAccessor } from '../store/data-accessor.js'; /** Archive metadata that may be attached to archived task records. */ export interface ArchiveMetadata { archivedAt?: string; cycleTimeDays?: number; archiveSource?: string; } /** Archived task shape used internally for analytics. */ export interface AnalyticsTask { id: string; title: string; status: string; priority?: string; phase?: string; labels?: string[]; archive: ArchiveMetadata; } export type ArchiveReportType = 'summary' | 'by-phase' | 'by-label' | 'by-priority' | 'cycle-times' | 'trends'; /** Summary report result. */ export interface SummaryReportData { totalArchived: number; byStatus: Record; byPriority: Record; averageCycleTime: number | null; oldestArchived: string | null; newestArchived: string | null; archiveSourceBreakdown: Record; } /** Phase group entry. */ export interface PhaseGroupEntry { phase: string; count: number; avgCycleTime: number | null; } /** Label frequency entry. */ export interface LabelFrequencyEntry { label: string; count: number; } /** Priority group entry. */ export interface PriorityGroupEntry { priority: string; count: number; avgCycleTime: number | null; } /** Cycle time distribution buckets. */ export interface CycleTimeDistribution { '0-1 days': number; '2-7 days': number; '8-30 days': number; '30+ days': number; } /** Cycle time percentiles. */ export interface CycleTimePercentiles { p25: number | null; p50: number | null; p75: number | null; p90: number | null; } /** Cycle times report result. */ export interface CycleTimesReportData { count: number; min: number | null; max: number | null; avg: number | null; median: number | null; distribution: CycleTimeDistribution; percentiles?: CycleTimePercentiles; } /** Daily archive entry. */ export interface DailyArchiveEntry { date: string; count: number; } /** Monthly archive entry. */ export interface MonthlyArchiveEntry { month: string; count: number; } /** Trends report result. */ export interface TrendsReportData { byDay: DailyArchiveEntry[]; byMonth: MonthlyArchiveEntry[]; totalPeriod: number; averagePerDay: number; } /** Empty archive sentinel (when totalArchived is 0). */ export interface EmptyArchiveData { totalArchived: 0; message: string; } /** Union type mapping report types to their data shapes. */ export type ArchiveReportDataMap = { summary: SummaryReportData; 'by-phase': PhaseGroupEntry[]; 'by-label': LabelFrequencyEntry[]; 'by-priority': PriorityGroupEntry[]; 'cycle-times': CycleTimesReportData; trends: TrendsReportData; }; /** The envelope returned by analyzeArchive. */ export interface ArchiveAnalyticsResult { report: R; filters: { since: string | null; until: string | null; } | null; data: ArchiveReportDataMap[R] | EmptyArchiveData; } /** Options for analyzeArchive. */ export interface AnalyzeArchiveOptions { report?: ArchiveReportType; since?: string; until?: string; cwd?: string; } /** Filter tasks by date range on archivedAt. */ export declare function filterByDate(tasks: AnalyticsTask[], since?: string, until?: string): AnalyticsTask[]; /** Generate summary statistics. */ export declare function summaryReport(tasks: AnalyticsTask[]): SummaryReportData; /** Group tasks by phase with cycle time averages. */ export declare function byPhaseReport(tasks: AnalyticsTask[]): PhaseGroupEntry[]; /** Group tasks by label frequency. */ export declare function byLabelReport(tasks: AnalyticsTask[]): LabelFrequencyEntry[]; /** Group tasks by priority with cycle time averages. */ export declare function byPriorityReport(tasks: AnalyticsTask[]): PriorityGroupEntry[]; /** Compute cycle time statistics with distribution buckets. */ export declare function cycleTimesReport(tasks: AnalyticsTask[]): CycleTimesReportData; /** Compute archive trends by day and month. */ export declare function trendsReport(tasks: AnalyticsTask[]): TrendsReportData; /** * Analyze archived tasks and produce a report. * * This is the primary entry point for archive analytics. It loads archive * data from the DataAccessor, normalizes task records, applies date filters, * and delegates to the appropriate report function. */ export declare function analyzeArchive(opts: AnalyzeArchiveOptions, accessor?: DataAccessor): Promise; //# sourceMappingURL=archive-analytics.d.ts.map