@boshu2/vibe-check 1.5.0 → 1.6.0

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.
Files changed (147) hide show
  1. package/.agents/bundles/insight-mining-dashboard-research-2025-11-30.md +400 -0
  2. package/.agents/bundles/storage-enhancement-research-2025-11-30.md +292 -0
  3. package/.agents/bundles/timeline-feature-research-complete-2025-11-30.md +301 -0
  4. package/.agents/plans/insight-dashboard-plan-2025-11-30.md +1130 -0
  5. package/.agents/plans/json-storage-enhancement-plan.md +717 -0
  6. package/.agents/plans/storage-hardening-and-cache-plan.md +592 -0
  7. package/.agents/plans/test-coverage-gaps-plan.md +1117 -0
  8. package/.agents/plans/timeline-feature-plan.md +193 -0
  9. package/.agents/plans/vibe_timeline_research_findings.md +553 -0
  10. package/.claude/settings.local.json +1 -0
  11. package/.vibe-check/.gitignore +6 -0
  12. package/CHANGELOG.md +46 -0
  13. package/CLAUDE.md +24 -0
  14. package/CONTRIBUTING.md +227 -0
  15. package/README.md +200 -143
  16. package/claude-progress.json +191 -9
  17. package/claude-progress.txt +257 -0
  18. package/dashboard/app.js +75 -2
  19. package/dashboard/dashboard-data.json +653 -0
  20. package/dashboard/index.html +13 -0
  21. package/dashboard/styles.css +61 -0
  22. package/dist/analysis/cross-session-analysis.d.ts +68 -0
  23. package/dist/analysis/cross-session-analysis.d.ts.map +1 -0
  24. package/dist/analysis/cross-session-analysis.js +174 -0
  25. package/dist/analysis/cross-session-analysis.js.map +1 -0
  26. package/dist/analysis/index.d.ts +2 -0
  27. package/dist/analysis/index.d.ts.map +1 -0
  28. package/dist/analysis/index.js +12 -0
  29. package/dist/analysis/index.js.map +1 -0
  30. package/dist/cli.js +10 -1
  31. package/dist/cli.js.map +1 -1
  32. package/dist/commands/analyze.d.ts +2 -0
  33. package/dist/commands/analyze.d.ts.map +1 -1
  34. package/dist/commands/analyze.js +105 -2
  35. package/dist/commands/analyze.js.map +1 -1
  36. package/dist/commands/cache.d.ts +6 -0
  37. package/dist/commands/cache.d.ts.map +1 -0
  38. package/dist/commands/cache.js +168 -0
  39. package/dist/commands/cache.js.map +1 -0
  40. package/dist/commands/dashboard.d.ts +8 -0
  41. package/dist/commands/dashboard.d.ts.map +1 -0
  42. package/dist/commands/dashboard.js +109 -0
  43. package/dist/commands/dashboard.js.map +1 -0
  44. package/dist/commands/index.d.ts +3 -0
  45. package/dist/commands/index.d.ts.map +1 -1
  46. package/dist/commands/index.js +8 -1
  47. package/dist/commands/index.js.map +1 -1
  48. package/dist/commands/timeline.d.ts +14 -0
  49. package/dist/commands/timeline.d.ts.map +1 -0
  50. package/dist/commands/timeline.js +462 -0
  51. package/dist/commands/timeline.js.map +1 -0
  52. package/dist/git.d.ts +24 -0
  53. package/dist/git.d.ts.map +1 -1
  54. package/dist/git.js +94 -0
  55. package/dist/git.js.map +1 -1
  56. package/dist/insights/generators.d.ts +44 -0
  57. package/dist/insights/generators.d.ts.map +1 -0
  58. package/dist/insights/generators.js +289 -0
  59. package/dist/insights/generators.js.map +1 -0
  60. package/dist/insights/index.d.ts +16 -0
  61. package/dist/insights/index.d.ts.map +1 -0
  62. package/dist/insights/index.js +171 -0
  63. package/dist/insights/index.js.map +1 -0
  64. package/dist/insights/types.d.ts +93 -0
  65. package/dist/insights/types.d.ts.map +1 -0
  66. package/dist/insights/types.js +6 -0
  67. package/dist/insights/types.js.map +1 -0
  68. package/dist/output/timeline-html.d.ts +6 -0
  69. package/dist/output/timeline-html.d.ts.map +1 -0
  70. package/dist/output/timeline-html.js +389 -0
  71. package/dist/output/timeline-html.js.map +1 -0
  72. package/dist/output/timeline-markdown.d.ts +6 -0
  73. package/dist/output/timeline-markdown.d.ts.map +1 -0
  74. package/dist/output/timeline-markdown.js +167 -0
  75. package/dist/output/timeline-markdown.js.map +1 -0
  76. package/dist/output/timeline.d.ts +9 -0
  77. package/dist/output/timeline.d.ts.map +1 -0
  78. package/dist/output/timeline.js +318 -0
  79. package/dist/output/timeline.js.map +1 -0
  80. package/dist/patterns/detour.d.ts +32 -0
  81. package/dist/patterns/detour.d.ts.map +1 -0
  82. package/dist/patterns/detour.js +137 -0
  83. package/dist/patterns/detour.js.map +1 -0
  84. package/dist/patterns/flow-state.d.ts +16 -0
  85. package/dist/patterns/flow-state.d.ts.map +1 -0
  86. package/dist/patterns/flow-state.js +40 -0
  87. package/dist/patterns/flow-state.js.map +1 -0
  88. package/dist/patterns/index.d.ts +8 -0
  89. package/dist/patterns/index.d.ts.map +1 -0
  90. package/dist/patterns/index.js +22 -0
  91. package/dist/patterns/index.js.map +1 -0
  92. package/dist/patterns/intervention-effectiveness.d.ts +42 -0
  93. package/dist/patterns/intervention-effectiveness.d.ts.map +1 -0
  94. package/dist/patterns/intervention-effectiveness.js +196 -0
  95. package/dist/patterns/intervention-effectiveness.js.map +1 -0
  96. package/dist/patterns/late-night.d.ts +30 -0
  97. package/dist/patterns/late-night.d.ts.map +1 -0
  98. package/dist/patterns/late-night.js +141 -0
  99. package/dist/patterns/late-night.js.map +1 -0
  100. package/dist/patterns/post-delete-sprint.d.ts +28 -0
  101. package/dist/patterns/post-delete-sprint.d.ts.map +1 -0
  102. package/dist/patterns/post-delete-sprint.js +85 -0
  103. package/dist/patterns/post-delete-sprint.js.map +1 -0
  104. package/dist/patterns/spiral-regression.d.ts +49 -0
  105. package/dist/patterns/spiral-regression.d.ts.map +1 -0
  106. package/dist/patterns/spiral-regression.js +219 -0
  107. package/dist/patterns/spiral-regression.js.map +1 -0
  108. package/dist/patterns/thrashing.d.ts +25 -0
  109. package/dist/patterns/thrashing.d.ts.map +1 -0
  110. package/dist/patterns/thrashing.js +111 -0
  111. package/dist/patterns/thrashing.js.map +1 -0
  112. package/dist/storage/atomic.d.ts +40 -0
  113. package/dist/storage/atomic.d.ts.map +1 -0
  114. package/dist/storage/atomic.js +155 -0
  115. package/dist/storage/atomic.js.map +1 -0
  116. package/dist/storage/commit-log.d.ts +35 -0
  117. package/dist/storage/commit-log.d.ts.map +1 -0
  118. package/dist/storage/commit-log.js +128 -0
  119. package/dist/storage/commit-log.js.map +1 -0
  120. package/dist/storage/index.d.ts +5 -0
  121. package/dist/storage/index.d.ts.map +1 -0
  122. package/dist/storage/index.js +33 -0
  123. package/dist/storage/index.js.map +1 -0
  124. package/dist/storage/schema.d.ts +32 -0
  125. package/dist/storage/schema.d.ts.map +1 -0
  126. package/dist/storage/schema.js +37 -0
  127. package/dist/storage/schema.js.map +1 -0
  128. package/dist/storage/timeline-store.d.ts +117 -0
  129. package/dist/storage/timeline-store.d.ts.map +1 -0
  130. package/dist/storage/timeline-store.js +438 -0
  131. package/dist/storage/timeline-store.js.map +1 -0
  132. package/dist/types.d.ts +96 -0
  133. package/dist/types.d.ts.map +1 -1
  134. package/docs/ARCHITECTURE.md +458 -0
  135. package/docs/DATA-ARCHITECTURE.md +565 -0
  136. package/docs/GAMIFICATION.md +564 -0
  137. package/docs/JSON-STORAGE-PATTERNS.md +512 -0
  138. package/docs/METRICS-EXPLAINED.md +394 -0
  139. package/docs/UNIFIED-ECOSYSTEM.md +560 -0
  140. package/docs/VIBE-ECOSYSTEM.md +406 -0
  141. package/feature-list.json +48 -0
  142. package/package.json +2 -1
  143. package/vitest.config.ts +1 -5
  144. package/.vibe-check/calibration.json +0 -38
  145. package/.vibe-check/latest.json +0 -114
  146. package/.vibe-check/sessions.json +0 -44
  147. package/PLAN-ultimate-game.md +0 -1362
@@ -0,0 +1,565 @@
1
+ # vibe-check Data Architecture
2
+
3
+ ## Overview
4
+
5
+ vibe-check transforms **git history** into **developer productivity insights** through a multi-stage data pipeline. This document maps the complete data flow, entity relationships, and storage architecture.
6
+
7
+ ---
8
+
9
+ ## Data Flow Diagram
10
+
11
+ ```
12
+ ┌─────────────────────────────────────────────────────────────────────────────┐
13
+ │ DATA SOURCES │
14
+ ├─────────────────────────────────────────────────────────────────────────────┤
15
+ │ │
16
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
17
+ │ │ Git Log │ │ Git Diff │ │ Git Status │ │
18
+ │ │ (commits) │ │ (changes) │ │ (state) │ │
19
+ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
20
+ │ │ │ │ │
21
+ └─────────┼────────────────────┼────────────────────┼─────────────────────────┘
22
+ │ │ │
23
+ ▼ ▼ ▼
24
+ ┌─────────────────────────────────────────────────────────────────────────────┐
25
+ │ EXTRACTION LAYER │
26
+ │ (git.ts) │
27
+ ├─────────────────────────────────────────────────────────────────────────────┤
28
+ │ │
29
+ │ ┌─────────────────────────────────────────────────────────────────────┐ │
30
+ │ │ getCommits(repoPath, since?, until?) │ │
31
+ │ │ → Commit[] │ │
32
+ │ │ Parses: hash, date, message, type, scope, author │ │
33
+ │ └─────────────────────────────────────────────────────────────────────┘ │
34
+ │ │
35
+ │ ┌─────────────────────────────────────────────────────────────────────┐ │
36
+ │ │ getCommitStats(repoPath, since?, until?) │ │
37
+ │ │ → CommitStats { filesPerCommit, lineStatsPerCommit } │ │
38
+ │ │ Parses: files changed, additions, deletions per commit │ │
39
+ │ └─────────────────────────────────────────────────────────────────────┘ │
40
+ │ │
41
+ └─────────────────────────────────────────────────────────────────────────────┘
42
+
43
+
44
+ ┌─────────────────────────────────────────────────────────────────────────────┐
45
+ │ TRANSFORMATION LAYER │
46
+ ├─────────────────────────────────────────────────────────────────────────────┤
47
+ │ │
48
+ │ ┌─────────────────────┐ │
49
+ │ │ SESSION DETECTION │ (timeline.ts:detectSessions) │
50
+ │ │ │ │
51
+ │ │ Commit[] ──────────┼──► TimelineSession[] │
52
+ │ │ │ │
53
+ │ │ Algorithm: │ │
54
+ │ │ • Sort by date │ │
55
+ │ │ • 60-min gap = new │ │
56
+ │ │ session │ │
57
+ │ └─────────────────────┘ │
58
+ │ │ │
59
+ │ ▼ │
60
+ │ ┌─────────────────────┐ ┌─────────────────────────────────────────┐ │
61
+ │ │ METRICS ANALYSIS │ │ PATTERN DETECTION │ │
62
+ │ │ (metrics/*) │ │ (patterns/*) │ │
63
+ │ │ │ │ │ │
64
+ │ │ Per session: │ │ • Flow State (5+ non-fix, <30m gaps) │ │
65
+ │ │ • Trust Pass Rate │ │ • Debug Spirals (3+ fix same scope) │ │
66
+ │ │ • Rework Ratio │ │ • Post-Delete Sprint (velocity ↑) │ │
67
+ │ │ • Iteration Vel. │ │ • Thrashing (5+ touches, low net) │ │
68
+ │ │ • Flow Efficiency │ │ • Detours (add→delete same scope) │ │
69
+ │ │ │ │ • Late Night (spiral after 22:00) │ │
70
+ │ └─────────────────────┘ └─────────────────────────────────────────┘ │
71
+ │ │ │ │
72
+ │ └───────────┬───────────────┘ │
73
+ │ ▼ │
74
+ │ ┌─────────────────────────────────────────────────────────────────────┐ │
75
+ │ │ AGGREGATION │ │
76
+ │ │ │ │
77
+ │ │ TimelineSession[] ──► TimelineDay[] ──► TimelineResult │ │
78
+ │ │ │ │
79
+ │ │ Aggregates: │ │
80
+ │ │ • Day grouping (by date) │ │
81
+ │ │ • Rating calculation (majority voting) │ │
82
+ │ │ • XP calculation (quality + commits - spirals) │ │
83
+ │ │ • Trend sparkline (per-day scores) │ │
84
+ │ └─────────────────────────────────────────────────────────────────────┘ │
85
+ │ │
86
+ └─────────────────────────────────────────────────────────────────────────────┘
87
+
88
+
89
+ ┌─────────────────────────────────────────────────────────────────────────────┐
90
+ │ PERSISTENCE LAYER │
91
+ │ (storage/timeline-store.ts) │
92
+ ├─────────────────────────────────────────────────────────────────────────────┤
93
+ │ │
94
+ │ Location: .vibe-check/timeline.json (per-repository) │
95
+ │ │
96
+ │ ┌─────────────────────────────────────────────────────────────────────┐ │
97
+ │ │ TimelineStore │ │
98
+ │ │ ├── version: string │ │
99
+ │ │ ├── lastUpdated: ISO timestamp │ │
100
+ │ │ ├── lastCommitHash: string (for incremental sync) │ │
101
+ │ │ │ │ │
102
+ │ │ ├── sessions: StoredSession[] (last 500) │ │
103
+ │ │ │ └── Deduplicated by 80% commit hash overlap │ │
104
+ │ │ │ │ │
105
+ │ │ ├── insights: StoredInsight[] (max 20) │ │
106
+ │ │ │ └── Compounding learnings (3+ occurrences trigger) │ │
107
+ │ │ │ │ │
108
+ │ │ ├── patterns: PatternStats │ │
109
+ │ │ │ ├── Flow: total, avgDuration, peakHour │ │
110
+ │ │ │ ├── Spirals: total, avgDuration, byComponent, byHour │ │
111
+ │ │ │ ├── Late Night: count, avgDuration │ │
112
+ │ │ │ ├── Detours: total, timeLost │ │
113
+ │ │ │ └── Post-Delete: count, avgVelocityIncrease │ │
114
+ │ │ │ │ │
115
+ │ │ └── trends: TrendData │ │
116
+ │ │ ├── weekly: WeekTrend[] (last 12 weeks) │ │
117
+ │ │ ├── monthly: MonthTrend[] (last 6 months) │ │
118
+ │ │ └── improvements: week-over-week changes │ │
119
+ │ └─────────────────────────────────────────────────────────────────────┘ │
120
+ │ │
121
+ └─────────────────────────────────────────────────────────────────────────────┘
122
+
123
+
124
+ ┌─────────────────────────────────────────────────────────────────────────────┐
125
+ │ PRESENTATION LAYER │
126
+ │ (output/*) │
127
+ ├─────────────────────────────────────────────────────────────────────────────┤
128
+ │ │
129
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
130
+ │ │ Terminal │ │ JSON │ │ Markdown │ │ HTML │ │
131
+ │ │ (default) │ │ (--json) │ │ (--md) │ │ (--html) │ │
132
+ │ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
133
+ │ │ │ │ │ │
134
+ │ ▼ ▼ ▼ ▼ │
135
+ │ ┌──────────────────────────────────────────────────────────────────────┐ │
136
+ │ │ CONSUMERS │ │
137
+ │ │ │ │
138
+ │ │ • CLI (human) • Dashboard • Reports • Sharing │ │
139
+ │ │ • CI pipelines • IDE plugins • Documentation • Embeds │ │
140
+ │ └──────────────────────────────────────────────────────────────────────┘ │
141
+ │ │
142
+ └─────────────────────────────────────────────────────────────────────────────┘
143
+ ```
144
+
145
+ ---
146
+
147
+ ## Entity Relationship Diagram
148
+
149
+ ```
150
+ ┌─────────────────────────────────────────────────────────────────────────────┐
151
+ │ ENTITY RELATIONSHIPS │
152
+ └─────────────────────────────────────────────────────────────────────────────┘
153
+
154
+ ┌─────────────┐
155
+ │ Commit │
156
+ │ (Source) │
157
+ ├─────────────┤
158
+ │ hash │
159
+ │ date │
160
+ │ message │
161
+ │ type │
162
+ │ scope │
163
+ │ author │
164
+ └──────┬──────┘
165
+
166
+ enriched with file stats
167
+
168
+
169
+ ┌─────────────────┐
170
+ │ TimelineEvent │
171
+ │ (Enriched) │
172
+ ├─────────────────┤
173
+ │ ...commit fields│
174
+ │ sessionId │
175
+ │ sessionPosition │
176
+ │ gapMinutes │
177
+ │ spiralDepth │
178
+ │ isRefactor │
179
+ └────────┬────────┘
180
+
181
+ belongs to
182
+
183
+
184
+ ┌──────────────┐ ┌─────────────────┐ ┌──────────────┐
185
+ │ FixChain │◄─────────│ TimelineSession │─────────►│ FlowState │
186
+ │ (Spiral) │ detected │ (Session) │ detected │ (Pattern) │
187
+ ├──────────────┤ in ├─────────────────┤ in ├──────────────┤
188
+ │ component │ │ id │ │ detected │
189
+ │ commits │ │ start │ │ duration │
190
+ │ duration │ │ end │ │ commits │
191
+ │ isSpiral │ │ duration │ │ avgGap │
192
+ │ pattern │ │ commits[] │ └──────────────┘
193
+ └──────────────┘ │ overall │
194
+ │ trustPassRate │
195
+ │ reworkRatio │
196
+ │ flowState │
197
+ │ spirals[] │
198
+ │ xpEarned │
199
+ └────────┬────────┘
200
+
201
+ grouped by date
202
+
203
+
204
+ ┌─────────────────┐
205
+ │ TimelineDay │
206
+ │ (Day) │
207
+ ├─────────────────┤
208
+ │ date │
209
+ │ displayDate │
210
+ │ sessions[] │
211
+ │ dayScore │
212
+ │ dayRating │
213
+ │ totalCommits │
214
+ │ totalDuration │
215
+ │ totalXp │
216
+ │ spiralCount │
217
+ └────────┬────────┘
218
+
219
+ aggregated into
220
+
221
+
222
+ ┌──────────────────────────────────────────────────────────────────────┐
223
+ │ TimelineResult │
224
+ │ (Analysis Output) │
225
+ ├──────────────────────────────────────────────────────────────────────┤
226
+ │ from, to │ Date range │
227
+ │ activeDays, totalDays │ Coverage │
228
+ │ days[] │ Per-day breakdown │
229
+ │ sessions[] │ All sessions │
230
+ │ totalCommits │ Aggregate counts │
231
+ │ totalActiveMinutes │ │
232
+ │ totalFeatures, totalFixes │ │
233
+ │ totalSpirals, flowStates │ Pattern counts │
234
+ │ postDeleteSprint │ Phase 2 patterns │
235
+ │ thrashing │ │
236
+ │ detours │ Phase 3 patterns │
237
+ │ lateNightSpirals │ │
238
+ │ totalXp │ Gamification │
239
+ │ trend[] │ Sparkline data │
240
+ └──────────────────────────────────────────────────────────────────────┘
241
+
242
+ persisted to
243
+
244
+
245
+ ┌──────────────────────────────────────────────────────────────────────┐
246
+ │ TimelineStore │
247
+ │ (Persistent Storage) │
248
+ ├──────────────────────────────────────────────────────────────────────┤
249
+ │ │
250
+ │ sessions[] ◄────── StoredSession (compressed, deduplicated) │
251
+ │ • 500 session limit │
252
+ │ • 80% hash overlap = duplicate │
253
+ │ │
254
+ │ insights[] ◄────── StoredInsight (compounding learnings) │
255
+ │ • Generated at 3+ occurrences │
256
+ │ • 20 insight limit │
257
+ │ • Categories: pattern, trend, recommendation │
258
+ │ │
259
+ │ patterns ◄────── PatternStats (aggregated statistics) │
260
+ │ • Running averages │
261
+ │ • Peak hour tracking │
262
+ │ • Component breakdown │
263
+ │ │
264
+ │ trends ◄────── TrendData (time-series analysis) │
265
+ │ • 12 weeks history │
266
+ │ • 6 months history │
267
+ │ • Week-over-week improvements │
268
+ │ │
269
+ └──────────────────────────────────────────────────────────────────────┘
270
+ ```
271
+
272
+ ---
273
+
274
+ ## Data Schemas
275
+
276
+ ### Source Layer (Git)
277
+
278
+ ```typescript
279
+ // Raw git data - read-only, external source
280
+ interface GitCommit {
281
+ hash: string; // Full SHA
282
+ date: string; // ISO timestamp
283
+ message: string; // Full commit message
284
+ author_name: string; // Committer
285
+ }
286
+
287
+ interface GitDiffStat {
288
+ additions: number; // Lines added
289
+ deletions: number; // Lines removed
290
+ file: string; // File path
291
+ }
292
+ ```
293
+
294
+ ### Domain Layer (Core Types)
295
+
296
+ ```typescript
297
+ // Parsed commit with semantic meaning
298
+ interface Commit {
299
+ hash: string; // 7-char short SHA
300
+ date: Date; // Parsed timestamp
301
+ message: string; // First line only
302
+ type: CommitType; // feat|fix|docs|chore|refactor|test|style|other
303
+ scope: string | null; // Conventional commit scope
304
+ author: string;
305
+ }
306
+
307
+ type CommitType = 'feat' | 'fix' | 'docs' | 'chore' | 'refactor' | 'test' | 'style' | 'other';
308
+
309
+ // Enriched commit with session context
310
+ interface TimelineEvent extends Omit<Commit, 'date' | 'message'> {
311
+ timestamp: Date; // Renamed for clarity
312
+ subject: string; // Renamed for clarity
313
+ sessionId: string; // Parent session
314
+ sessionPosition: number; // Order within session
315
+ gapMinutes: number; // Time since previous commit
316
+ isRefactor: boolean; // Quick type check
317
+ spiralDepth: number; // 0 = not in spiral, 1+ = depth in fix chain
318
+ }
319
+ ```
320
+
321
+ ### Analysis Layer (Computed)
322
+
323
+ ```typescript
324
+ // Session: Unit of focused work
325
+ interface TimelineSession {
326
+ id: string;
327
+ start: Date;
328
+ end: Date;
329
+ duration: number; // minutes
330
+ commits: TimelineEvent[];
331
+
332
+ // Computed metrics
333
+ vibeScore: number | null;
334
+ overall: OverallRating;
335
+ trustPassRate: number; // 0-100
336
+ reworkRatio: number; // 0-100
337
+
338
+ // Detected patterns
339
+ flowState: boolean;
340
+ spirals: FixChain[];
341
+
342
+ // Gamification
343
+ xpEarned: number;
344
+ }
345
+
346
+ // Day: Calendar grouping of sessions
347
+ interface TimelineDay {
348
+ date: string; // YYYY-MM-DD
349
+ displayDate: string; // "Thu Nov 28"
350
+ sessions: TimelineSession[];
351
+ dayScore: number | null;
352
+ dayRating: OverallRating;
353
+
354
+ // Aggregates
355
+ totalCommits: number;
356
+ totalDuration: number;
357
+ totalXp: number;
358
+ spiralCount: number;
359
+ }
360
+
361
+ // Pattern detection results
362
+ interface FixChain {
363
+ component: string; // Scope that's being fixed
364
+ commits: number; // Fix count
365
+ duration: number; // minutes
366
+ isSpiral: boolean; // 3+ commits = spiral
367
+ pattern: string | null; // Classified pattern type
368
+ firstCommit: Date;
369
+ lastCommit: Date;
370
+ }
371
+ ```
372
+
373
+ ### Storage Layer (Persistence)
374
+
375
+ ```typescript
376
+ // Compressed session for storage
377
+ interface StoredSession {
378
+ id: string;
379
+ date: string; // YYYY-MM-DD (denormalized for queries)
380
+ start: string; // ISO timestamp
381
+ end: string;
382
+ duration: number;
383
+ commitCount: number;
384
+ commitHashes: string[]; // For deduplication
385
+
386
+ // Key metrics only
387
+ overall: string;
388
+ trustPassRate: number;
389
+ reworkRatio: number;
390
+ xpEarned: number;
391
+
392
+ // Pattern flags
393
+ flowState: boolean;
394
+ spiralCount: number;
395
+ spiralComponents: string[];
396
+ }
397
+
398
+ // Compounding insight
399
+ interface StoredInsight {
400
+ id: string;
401
+ type: 'pattern' | 'trend' | 'recommendation';
402
+ category: string;
403
+ message: string;
404
+ firstSeen: string; // ISO timestamp
405
+ lastSeen: string;
406
+ occurrences: number;
407
+ metadata?: Record<string, unknown>;
408
+ }
409
+
410
+ // Aggregated pattern statistics
411
+ interface PatternStats {
412
+ // Flow state stats
413
+ totalFlowStates: number;
414
+ avgFlowDuration: number;
415
+ peakFlowHour: number; // 0-23
416
+
417
+ // Spiral stats
418
+ totalSpirals: number;
419
+ avgSpiralDuration: number;
420
+ spiralsByComponent: Record<string, number>;
421
+ spiralsByHour: Record<number, number>;
422
+
423
+ // Late night stats
424
+ lateNightSessions: number;
425
+ lateNightAvgDuration: number;
426
+
427
+ // Detour stats
428
+ totalDetours: number;
429
+ totalTimeLostToDetours: number;
430
+
431
+ // Post-delete sprints
432
+ postDeleteSprints: number;
433
+ avgVelocityIncrease: number;
434
+ }
435
+ ```
436
+
437
+ ---
438
+
439
+ ## Data Flow by Command
440
+
441
+ ### `vibe-check analyze`
442
+
443
+ ```
444
+ Git ──► Commits ──► Metrics Analysis ──► VibeCheckResult ──► Output
445
+
446
+ No persistence
447
+ ```
448
+
449
+ ### `vibe-check timeline`
450
+
451
+ ```
452
+ Git ──► Commits ──► CommitStats ──► Sessions ──► Days ──► TimelineResult
453
+ │ │
454
+ Patterns ┌────┴────┐
455
+ detected ▼ ▼
456
+ │ Terminal Storage
457
+ ▼ (cache)
458
+ TimelineStore ◄─── updateStore()
459
+ ```
460
+
461
+ ### `vibe-check profile`
462
+
463
+ ```
464
+ Storage ──► Profile.json ──► XP/Streaks/Achievements ──► Terminal
465
+ ▲ │
466
+ │ Updates
467
+ └───────────────────────────────┘
468
+ ```
469
+
470
+ ---
471
+
472
+ ## Storage Strategy
473
+
474
+ ### Current: JSON Files
475
+
476
+ ```
477
+ .vibe-check/
478
+ ├── timeline.json # Session history + insights + trends
479
+ ├── profile.json # XP, streaks, achievements (gamification)
480
+ └── calibration.json # Level calibration samples
481
+ ```
482
+
483
+ **Pros:**
484
+ - Zero dependencies
485
+ - Git-friendly (diffable)
486
+ - Human-readable
487
+ - Works offline
488
+
489
+ **Cons:**
490
+ - No cross-repo aggregation
491
+ - Limited query capability
492
+ - File size grows unbounded (mitigated by 500 session limit)
493
+ - No concurrent access handling
494
+
495
+ ### Future: SQLite
496
+
497
+ ```sql
498
+ -- Cross-repo aggregation possible
499
+ -- Rich queries (WHERE, GROUP BY, etc.)
500
+ -- Proper indexing for time-range queries
501
+
502
+ ~/.vibe-check/
503
+ ├── vibe-check.db # Central database
504
+ └── repos/ # Per-repo caches
505
+ ```
506
+
507
+ ---
508
+
509
+ ## Enhancement Opportunities
510
+
511
+ ### 1. **Event Sourcing Pattern**
512
+ Store raw events, compute views on demand:
513
+ ```
514
+ commits.ndjson → Append-only log
515
+ sessions/ → Computed views (regenerable)
516
+ ```
517
+
518
+ ### 2. **Cross-Repo Aggregation**
519
+ Central store for multi-repo insights:
520
+ ```typescript
521
+ interface GlobalStore {
522
+ repos: Map<string, RepoMetadata>;
523
+ globalInsights: StoredInsight[];
524
+ globalTrends: TrendData;
525
+ }
526
+ ```
527
+
528
+ ### 3. **Real-time Streaming**
529
+ WebSocket API for live dashboard:
530
+ ```
531
+ Git hooks → vibe-check watch → WebSocket → Dashboard
532
+ ```
533
+
534
+ ### 4. **Query API**
535
+ SQL-like queries for custom analysis:
536
+ ```bash
537
+ vibe-check query "sessions WHERE flowState = true AND date > '2025-11-01'"
538
+ ```
539
+
540
+ ---
541
+
542
+ ## Key Design Decisions
543
+
544
+ | Decision | Choice | Rationale |
545
+ |----------|--------|-----------|
546
+ | Session gap | 60 minutes | Based on analysis: 69% of gaps <30m, 19% >1hr |
547
+ | Spiral threshold | 3+ fixes | Industry standard for "debug loop" |
548
+ | Storage format | JSON | Zero dependencies, git-friendly |
549
+ | Session limit | 500 | ~1 year of daily coding |
550
+ | Insight threshold | 3+ occurrences | Reduces noise, surfaces patterns |
551
+ | Dedup strategy | 80% hash overlap | Handles partial overlaps |
552
+
553
+ ---
554
+
555
+ ## File Locations
556
+
557
+ | Component | File | Responsibility |
558
+ |-----------|------|----------------|
559
+ | Extraction | `src/git.ts` | Git operations |
560
+ | Types | `src/types.ts` | All interfaces |
561
+ | Session detection | `src/commands/timeline.ts` | Session/day grouping |
562
+ | Metrics | `src/metrics/*.ts` | Core 5 metrics |
563
+ | Patterns | `src/patterns/*.ts` | 6 pattern detectors |
564
+ | Storage | `src/storage/*.ts` | Persistence |
565
+ | Output | `src/output/*.ts` | Formatting |