repo-wrapped 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/SPECS.md ADDED
@@ -0,0 +1,490 @@
1
+ # Feature Specifications: Lead Developer Insights
2
+
3
+ > **Goal**: Enable lead developers to gain data-driven insights on repository health, team velocity, and the impact of management decisions — providing ammunition for stakeholder discussions.
4
+
5
+ ---
6
+
7
+ ## 1. Velocity Timeline Visualization
8
+
9
+ ### Purpose
10
+ Show productivity trends over time to demonstrate slowdowns, speedups, or the impact of events.
11
+
12
+ ### CLI Options
13
+ ```bash
14
+ --velocity # Enable velocity analysis in output
15
+ --velocity-window <weeks> # Rolling average window (default: 4 weeks)
16
+ ```
17
+
18
+ ### Data Structure
19
+ ```typescript
20
+ interface VelocityAnalysis {
21
+ // Time-series data
22
+ timeline: VelocityDataPoint[];
23
+
24
+ // Computed metrics
25
+ overallTrend: 'increasing' | 'stable' | 'decreasing' | 'volatile';
26
+ trendPercentage: number; // e.g., -35% over period
27
+ averageCommitsPerWeek: number;
28
+ peakWeek: { weekStart: Date; commits: number };
29
+ lowestWeek: { weekStart: Date; commits: number };
30
+
31
+ // Anomaly detection
32
+ anomalies: VelocityAnomaly[];
33
+ }
34
+
35
+ interface VelocityDataPoint {
36
+ weekStart: Date;
37
+ weekEnd: Date;
38
+ commits: number;
39
+ linesAdded: number;
40
+ linesDeleted: number;
41
+ filesChanged: number;
42
+ authors: string[];
43
+ rollingAverage: number; // N-week rolling avg
44
+ }
45
+
46
+ interface VelocityAnomaly {
47
+ weekStart: Date;
48
+ type: 'spike' | 'drop' | 'zero-activity';
49
+ severity: 'minor' | 'significant' | 'critical'; // >20%, >40%, >60% deviation
50
+ percentageChange: number;
51
+ possibleCauses: string[]; // Auto-generated hints
52
+ }
53
+ ```
54
+
55
+ ### HTML Output
56
+ - Line chart showing commits per week
57
+ - Overlay line for rolling average
58
+ - Highlighted anomaly zones (red for drops, orange for spikes)
59
+ - Trend arrow with percentage in summary card
60
+
61
+ ### Acceptance Criteria
62
+ - [ ] Weekly aggregation of commits with configurable window
63
+ - [ ] Rolling average calculation
64
+ - [ ] Anomaly detection (>30% deviation from rolling average)
65
+ - [ ] Trend calculation over full period
66
+ - [ ] HTML chart using inline SVG or lightweight charting
67
+
68
+ ---
69
+
70
+ ## 2. Date Range Comparison
71
+
72
+ ### Purpose
73
+ Compare metrics between two arbitrary time periods (e.g., "before reorg" vs "after reorg").
74
+
75
+ ### CLI Options
76
+ ```bash
77
+ --compare "<start1>..<end1>" "<start2>..<end2>"
78
+ # Example: --compare "2025-01-01..2025-06-30" "2025-07-01..2025-12-31"
79
+
80
+ --compare-labels "<label1>" "<label2>"
81
+ # Example: --compare-labels "Before Reorg" "After Reorg"
82
+ ```
83
+
84
+ ### Data Structure
85
+ ```typescript
86
+ interface RangeComparison {
87
+ range1: {
88
+ label: string;
89
+ start: Date;
90
+ end: Date;
91
+ metrics: ComparisonMetrics;
92
+ };
93
+ range2: {
94
+ label: string;
95
+ start: Date;
96
+ end: Date;
97
+ metrics: ComparisonMetrics;
98
+ };
99
+
100
+ // Computed differences
101
+ changes: MetricChanges;
102
+ summary: string; // Auto-generated narrative
103
+ }
104
+
105
+ interface ComparisonMetrics {
106
+ totalCommits: number;
107
+ commitsPerWeek: number;
108
+ totalAuthors: number;
109
+ activeDays: number;
110
+ activeDaysPercentage: number;
111
+ averageCommitsPerDay: number; // On active days
112
+ qualityScore: number;
113
+ streakData: { longest: number; average: number };
114
+
115
+ // Detailed breakdowns
116
+ commitsByType: Record<string, number>; // feat/fix/docs/etc
117
+ commitsByAuthor: Record<string, number>;
118
+ }
119
+
120
+ interface MetricChanges {
121
+ commits: { absolute: number; percentage: number; trend: 'up' | 'down' | 'stable' };
122
+ velocity: { absolute: number; percentage: number; trend: 'up' | 'down' | 'stable' };
123
+ quality: { absolute: number; percentage: number; trend: 'up' | 'down' | 'stable' };
124
+ activeDays: { absolute: number; percentage: number; trend: 'up' | 'down' | 'stable' };
125
+ // ... other metrics
126
+ }
127
+ ```
128
+
129
+ ### HTML Output
130
+ - Side-by-side cards for each period
131
+ - Delta indicators with arrows and colors (green=improvement, red=decline)
132
+ - Summary narrative: "Velocity decreased 35% in Period 2, with 40% fewer active days"
133
+
134
+ ### Acceptance Criteria
135
+ - [ ] Parse date range format `YYYY-MM-DD..YYYY-MM-DD`
136
+ - [ ] Calculate all metrics for each range independently
137
+ - [ ] Compute percentage changes
138
+ - [ ] Generate comparison narrative
139
+ - [ ] Support custom labels for presentation clarity
140
+
141
+ ---
142
+
143
+ ## 3. Gap Detection & Blocker Analysis
144
+
145
+ ### Purpose
146
+ Identify periods of zero or low activity that may indicate blockers, waiting time, or disruptions.
147
+
148
+ ### CLI Options
149
+ ```bash
150
+ --gap-analysis # Enable gap detection
151
+ --gap-threshold <days> # Minimum gap to report (default: 3 days)
152
+ ```
153
+
154
+ ### Data Structure
155
+ ```typescript
156
+ interface GapAnalysis {
157
+ // All detected gaps
158
+ gaps: ActivityGap[];
159
+
160
+ // Summary statistics
161
+ totalGapDays: number;
162
+ percentageOfPeriodInGaps: number;
163
+ longestGap: ActivityGap;
164
+ averageGapLength: number;
165
+ gapFrequency: number; // Gaps per month
166
+
167
+ // Pattern detection
168
+ patterns: GapPattern[];
169
+
170
+ // Risk assessment
171
+ riskLevel: 'low' | 'medium' | 'high' | 'critical';
172
+ riskFactors: string[];
173
+ }
174
+
175
+ interface ActivityGap {
176
+ start: Date;
177
+ end: Date;
178
+ durationDays: number;
179
+
180
+ // Context
181
+ commitBefore: { date: Date; message: string; author: string } | null;
182
+ commitAfter: { date: Date; message: string; author: string } | null;
183
+
184
+ // Analysis
185
+ possibleType: 'weekend' | 'holiday' | 'vacation' | 'blocker' | 'unknown';
186
+ annotation?: string; // From event annotations if matched
187
+ }
188
+
189
+ interface GapPattern {
190
+ type: 'recurring-weekly' | 'end-of-sprint' | 'after-release' | 'random';
191
+ description: string;
192
+ occurrences: number;
193
+ }
194
+ ```
195
+
196
+ ### HTML Output
197
+ - Timeline visualization with gap periods highlighted in red
198
+ - Gap cards showing duration, dates, and surrounding context
199
+ - Pattern summary: "4 gaps >5 days detected, totaling 28 lost days (15% of period)"
200
+
201
+ ### Acceptance Criteria
202
+ - [ ] Detect gaps exceeding threshold (configurable, default 3 days)
203
+ - [ ] Exclude weekends from gap calculation (optional flag)
204
+ - [ ] Identify context (commits before/after gap)
205
+ - [ ] Calculate total lost time
206
+ - [ ] Pattern detection for recurring gaps
207
+
208
+ ---
209
+
210
+ ## 4. Author & Team Filtering
211
+
212
+ ### Purpose
213
+ Filter analysis to specific contributors or teams, enabling team-level vs individual comparisons.
214
+
215
+ ### CLI Options
216
+ ```bash
217
+ --author "<name>" # Filter to single author (supports partial match)
218
+ --authors "<name1>,<name2>" # Filter to multiple authors
219
+ --team <file> # Path to team members file (one name per line)
220
+ --exclude-author "<name>" # Exclude specific author (e.g., bots)
221
+ --exclude-authors "<names>" # Exclude multiple authors
222
+ ```
223
+
224
+ ### Team File Format
225
+ ```text
226
+ # team-frontend.txt
227
+ John Doe
228
+ Jane Smith
229
+ Bob Wilson
230
+ ```
231
+
232
+ ### Data Structure
233
+ ```typescript
234
+ interface AuthorFilter {
235
+ mode: 'include' | 'exclude';
236
+ authors: string[];
237
+ matchType: 'exact' | 'partial'; // Partial allows "John" to match "John Doe"
238
+ }
239
+
240
+ interface TeamAnalysis {
241
+ teamName?: string;
242
+ members: string[];
243
+
244
+ // Aggregated team metrics
245
+ teamMetrics: {
246
+ totalCommits: number;
247
+ commitsPerMember: number;
248
+ activeDays: number;
249
+ velocity: VelocityAnalysis;
250
+ quality: CommitQualityResult;
251
+ };
252
+
253
+ // Individual breakdowns
254
+ memberBreakdown: {
255
+ author: string;
256
+ commits: number;
257
+ percentage: number;
258
+ activeDays: number;
259
+ qualityScore: number;
260
+ topAreas: string[]; // Most contributed directories
261
+ }[];
262
+
263
+ // Distribution analysis
264
+ loadDistribution: {
265
+ giniCoefficient: number; // 0=equal, 1=one person does all
266
+ assessment: 'balanced' | 'moderate-imbalance' | 'high-imbalance';
267
+ insights: string[];
268
+ };
269
+ }
270
+ ```
271
+
272
+ ### HTML Output
273
+ - Team summary card with aggregate metrics
274
+ - Individual member cards with contribution breakdown
275
+ - Load distribution chart (bar chart of commits per member)
276
+ - Insights: "60% of commits come from 1 team member"
277
+
278
+ ### Acceptance Criteria
279
+ - [ ] Filter commits by author name (partial match)
280
+ - [ ] Support team file input
281
+ - [ ] Support exclusion patterns (for bots)
282
+ - [ ] Calculate team aggregate metrics
283
+ - [ ] Individual member breakdown
284
+ - [ ] Load distribution analysis (Gini coefficient)
285
+
286
+ ---
287
+
288
+ ## 5. Executive Summary Mode
289
+
290
+ ### Purpose
291
+ Generate a stakeholder-ready 1-page summary with key metrics, trends, and traffic-light indicators.
292
+
293
+ ### CLI Options
294
+ ```bash
295
+ --executive-summary # Generate summary section/page
296
+ --summary-only # Output ONLY the executive summary
297
+ --pdf # Export as PDF (requires puppeteer or similar)
298
+ ```
299
+
300
+ ### Data Structure
301
+ ```typescript
302
+ interface ExecutiveSummary {
303
+ generatedAt: Date;
304
+ period: { start: Date; end: Date };
305
+ repoName: string;
306
+
307
+ // Key Performance Indicators
308
+ kpis: {
309
+ name: string;
310
+ value: string | number;
311
+ trend: 'up' | 'down' | 'stable';
312
+ trendValue: string; // e.g., "+15%"
313
+ status: 'green' | 'yellow' | 'red';
314
+ benchmark?: string; // e.g., "vs last quarter"
315
+ }[];
316
+
317
+ // Top-level insights (3-5 bullet points)
318
+ keyInsights: {
319
+ type: 'positive' | 'negative' | 'neutral';
320
+ insight: string;
321
+ }[];
322
+
323
+ // Risk summary
324
+ risks: {
325
+ category: string;
326
+ level: 'low' | 'medium' | 'high';
327
+ description: string;
328
+ }[];
329
+
330
+ // Recommendations (auto-generated)
331
+ recommendations: string[];
332
+ }
333
+ ```
334
+
335
+ ### Default KPIs
336
+ 1. **Velocity**: Commits per week (trend vs previous period)
337
+ 2. **Quality Score**: Commit message quality (0-10)
338
+ 3. **Bus Factor**: Knowledge distribution risk
339
+ 4. **Active Contributors**: Unique authors
340
+ 5. **Consistency**: Days with commits / total days
341
+ 6. **Gap Days**: Lost days due to inactivity
342
+
343
+ ### HTML Output
344
+ - Clean, printable single-page layout
345
+ - Traffic light indicators (colored circles)
346
+ - Trend arrows with percentages
347
+ - Bullet point insights
348
+ - Risk table with colored severity
349
+
350
+ ### Acceptance Criteria
351
+ - [ ] Calculate all KPIs with trends
352
+ - [ ] Auto-determine status thresholds (green/yellow/red)
353
+ - [ ] Generate 3-5 key insights from data
354
+ - [ ] Identify top risks
355
+ - [ ] Clean print-friendly HTML
356
+ - [ ] PDF export capability
357
+
358
+ ---
359
+
360
+ ## 6. Event Annotations
361
+
362
+ ### Purpose
363
+ Mark known events (reorgs, departures, releases) to contextualize metrics and correlate with changes.
364
+
365
+ ### CLI Options
366
+ ```bash
367
+ --events <file> # Path to events JSON file
368
+ --events-inline "<json>" # Inline events JSON
369
+ ```
370
+
371
+ ### Events File Format
372
+ ```json
373
+ {
374
+ "events": [
375
+ {
376
+ "date": "2025-07-15",
377
+ "label": "Reorg announced",
378
+ "type": "disruption",
379
+ "description": "Team restructure announced, 2 devs moved to other projects"
380
+ },
381
+ {
382
+ "date": "2025-08-01",
383
+ "label": "Senior dev left",
384
+ "type": "attrition"
385
+ },
386
+ {
387
+ "date": "2025-09-15",
388
+ "label": "v2.0 Release",
389
+ "type": "release"
390
+ },
391
+ {
392
+ "date": "2025-10-01",
393
+ "label": "New team members onboarded",
394
+ "type": "growth"
395
+ }
396
+ ]
397
+ }
398
+ ```
399
+
400
+ ### Event Types
401
+ - `disruption` - Reorgs, process changes, blocking decisions
402
+ - `attrition` - Team member departures
403
+ - `growth` - New hires, team expansion
404
+ - `release` - Major releases, deadlines
405
+ - `incident` - Production issues, firefighting periods
406
+ - `external` - Holidays, company events
407
+ - `custom` - User-defined
408
+
409
+ ### Data Structure
410
+ ```typescript
411
+ interface EventAnnotation {
412
+ date: Date;
413
+ label: string;
414
+ type: EventType;
415
+ description?: string;
416
+
417
+ // Auto-computed correlation
418
+ correlation?: {
419
+ metricsBefore: Partial<ComparisonMetrics>; // 2 weeks before
420
+ metricsAfter: Partial<ComparisonMetrics>; // 2 weeks after
421
+ impact: {
422
+ velocityChange: number;
423
+ qualityChange: number;
424
+ activeAuthorsChange: number;
425
+ };
426
+ assessment: string; // "Velocity dropped 40% after this event"
427
+ };
428
+ }
429
+
430
+ type EventType = 'disruption' | 'attrition' | 'growth' | 'release' | 'incident' | 'external' | 'custom';
431
+ ```
432
+
433
+ ### HTML Output
434
+ - Event markers on timeline/velocity chart
435
+ - Event legend with icons per type
436
+ - Correlation cards: "After 'Reorg announced': velocity -35%, active contributors -2"
437
+ - Event timeline view
438
+
439
+ ### Acceptance Criteria
440
+ - [ ] Parse events JSON file
441
+ - [ ] Display events on velocity timeline
442
+ - [ ] Calculate before/after metrics for each event
443
+ - [ ] Generate correlation assessments
444
+ - [ ] Event filtering by type
445
+
446
+ ---
447
+
448
+ ## Implementation Priority
449
+
450
+ | Feature | Priority | Complexity | Stakeholder Value |
451
+ |---------|----------|------------|-------------------|
452
+ | Velocity Timeline | P0 | Medium | Critical |
453
+ | Date Range Comparison | P0 | Medium | Critical |
454
+ | Gap Detection | P1 | Low | High |
455
+ | Author/Team Filtering | P1 | Medium | High |
456
+ | Executive Summary | P2 | Medium | High |
457
+ | Event Annotations | P2 | Medium | Medium |
458
+
459
+ ---
460
+
461
+ ## Technical Notes
462
+
463
+ ### File Structure for New Features
464
+ ```
465
+ src/
466
+ ├── utils/
467
+ │ ├── velocityAnalyzer.ts # NEW
468
+ │ ├── rangeComparisonAnalyzer.ts # NEW
469
+ │ ├── gapAnalyzer.ts # NEW
470
+ │ ├── teamAnalyzer.ts # NEW
471
+ │ └── executiveSummaryGenerator.ts # NEW
472
+ ├── types/
473
+ │ └── index.ts # Add new interfaces
474
+ ├── generators/html/
475
+ │ ├── templates/
476
+ │ │ ├── velocitySection.ts # NEW
477
+ │ │ ├── comparisonSection.ts # NEW
478
+ │ │ ├── gapSection.ts # NEW
479
+ │ │ ├── teamSection.ts # NEW
480
+ │ │ └── executiveSummary.ts # NEW
481
+ │ └── styles/
482
+ │ └── charts.css # NEW
483
+ └── commands/
484
+ └── generate.ts # Add new CLI options
485
+ ```
486
+
487
+ ### Dependencies to Consider
488
+ - Chart rendering: Consider lightweight SVG generation or inline charts
489
+ - PDF export: `puppeteer` or `playwright` for HTML-to-PDF
490
+ - Date handling: Already using `date-fns`