@boshu2/vibe-check 1.6.1 → 1.7.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.
- package/.agents/bundles/automatic-learning-cadence-plan-2025-12-02.md +1297 -0
- package/.agents/bundles/automatic-learning-cadence-research-2025-12-02.md +481 -0
- package/.agents/bundles/dashboard-data-quality-plan.md +458 -0
- package/.agents/bundles/rating-scoring-alignment-plan.md +427 -0
- package/.agents/bundles/rpi-session-capture-plan-2025-12-02.md +693 -0
- package/.agents/bundles/rpi-session-capture-research-2025-12-02.md +433 -0
- package/.agents/bundles/session-integration-plan-2025-12-02.md +144 -0
- package/CHANGELOG.md +17 -0
- package/CLAUDE.md +74 -2
- package/Makefile +173 -0
- package/README.md +35 -2
- package/claude-progress.json +34 -5
- package/claude-progress.txt +66 -0
- package/dashboard/app.js +699 -66
- package/dashboard/chart.min.js +20 -0
- package/dashboard/dashboard-data.js +764 -0
- package/dashboard/dashboard-data.json +182 -71
- package/dashboard/index.html +139 -14
- package/dashboard/styles.css +579 -4
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +38 -2
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/dashboard.js +4 -1
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/learn.d.ts +3 -0
- package/dist/commands/learn.d.ts.map +1 -0
- package/dist/commands/learn.js +161 -0
- package/dist/commands/learn.js.map +1 -0
- package/dist/commands/lesson.d.ts +8 -0
- package/dist/commands/lesson.d.ts.map +1 -0
- package/dist/commands/lesson.js +206 -0
- package/dist/commands/lesson.js.map +1 -0
- package/dist/commands/profile.d.ts.map +1 -1
- package/dist/commands/profile.js +3 -202
- package/dist/commands/profile.js.map +1 -1
- package/dist/commands/session.d.ts +51 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +561 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/gamification/index.d.ts +1 -3
- package/dist/gamification/index.d.ts.map +1 -1
- package/dist/gamification/index.js +2 -5
- package/dist/gamification/index.js.map +1 -1
- package/dist/gamification/pattern-memory.d.ts +1 -1
- package/dist/gamification/pattern-memory.d.ts.map +1 -1
- package/dist/gamification/pattern-memory.js.map +1 -1
- package/dist/gamification/profile.d.ts +2 -2
- package/dist/gamification/profile.d.ts.map +1 -1
- package/dist/gamification/profile.js +2 -15
- package/dist/gamification/profile.js.map +1 -1
- package/dist/gamification/types.d.ts +8 -2
- package/dist/gamification/types.d.ts.map +1 -1
- package/dist/gamification/types.js.map +1 -1
- package/dist/insights/index.d.ts.map +1 -1
- package/dist/insights/index.js +16 -4
- package/dist/insights/index.js.map +1 -1
- package/dist/insights/types.d.ts +14 -0
- package/dist/insights/types.d.ts.map +1 -1
- package/dist/learning/cadence.d.ts +15 -0
- package/dist/learning/cadence.d.ts.map +1 -0
- package/dist/learning/cadence.js +130 -0
- package/dist/learning/cadence.js.map +1 -0
- package/dist/learning/index.d.ts +19 -0
- package/dist/learning/index.d.ts.map +1 -0
- package/dist/learning/index.js +35 -0
- package/dist/learning/index.js.map +1 -0
- package/dist/learning/lessons-storage.d.ts +48 -0
- package/dist/learning/lessons-storage.d.ts.map +1 -0
- package/dist/learning/lessons-storage.js +266 -0
- package/dist/learning/lessons-storage.js.map +1 -0
- package/dist/learning/lessons-types.d.ts +83 -0
- package/dist/learning/lessons-types.d.ts.map +1 -0
- package/dist/learning/lessons-types.js +15 -0
- package/dist/learning/lessons-types.js.map +1 -0
- package/dist/learning/nudges.d.ts +20 -0
- package/dist/learning/nudges.d.ts.map +1 -0
- package/dist/learning/nudges.js +68 -0
- package/dist/learning/nudges.js.map +1 -0
- package/dist/learning/retrospective.d.ts +27 -0
- package/dist/learning/retrospective.d.ts.map +1 -0
- package/dist/learning/retrospective.js +184 -0
- package/dist/learning/retrospective.js.map +1 -0
- package/dist/learning/storage.d.ts +44 -0
- package/dist/learning/storage.d.ts.map +1 -0
- package/dist/learning/storage.js +194 -0
- package/dist/learning/storage.js.map +1 -0
- package/dist/learning/surfacing.d.ts +36 -0
- package/dist/learning/surfacing.d.ts.map +1 -0
- package/dist/learning/surfacing.js +255 -0
- package/dist/learning/surfacing.js.map +1 -0
- package/dist/learning/synthesis.d.ts +17 -0
- package/dist/learning/synthesis.d.ts.map +1 -0
- package/dist/learning/synthesis.js +293 -0
- package/dist/learning/synthesis.js.map +1 -0
- package/dist/learning/types.d.ts +60 -0
- package/dist/learning/types.d.ts.map +1 -0
- package/dist/learning/types.js +17 -0
- package/dist/learning/types.js.map +1 -0
- package/docs/METRICS.md +528 -0
- package/feature-list.json +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Lesson Surfacing
|
|
4
|
+
*
|
|
5
|
+
* Finds and formats relevant lessons to display based on current context.
|
|
6
|
+
* This is the "proactive" part - surfacing learnings at the right time.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.surfaceLessonsForPattern = surfaceLessonsForPattern;
|
|
13
|
+
exports.surfaceLessonsForComponent = surfaceLessonsForComponent;
|
|
14
|
+
exports.getTopLessons = getTopLessons;
|
|
15
|
+
exports.formatSurfacedLesson = formatSurfacedLesson;
|
|
16
|
+
exports.formatLessonDetail = formatLessonDetail;
|
|
17
|
+
exports.formatLessonsSummary = formatLessonsSummary;
|
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
+
const lessons_storage_1 = require("./lessons-storage");
|
|
20
|
+
const intervention_memory_1 = require("../gamification/intervention-memory");
|
|
21
|
+
/**
|
|
22
|
+
* Get lessons relevant to a detected pattern
|
|
23
|
+
*
|
|
24
|
+
* Called from analyze.ts when spirals are detected
|
|
25
|
+
*/
|
|
26
|
+
function surfaceLessonsForPattern(pattern) {
|
|
27
|
+
const db = (0, lessons_storage_1.loadLessons)();
|
|
28
|
+
const lessons = (0, lessons_storage_1.getLessonsForPattern)(db, pattern);
|
|
29
|
+
if (lessons.length === 0) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
return lessons
|
|
33
|
+
.map(lesson => ({
|
|
34
|
+
lesson,
|
|
35
|
+
relevanceScore: calculateRelevance(lesson, pattern),
|
|
36
|
+
reason: `You've seen ${lesson.pattern} ${lesson.evidenceCount} times before`,
|
|
37
|
+
suggestedIntervention: getBestIntervention(lesson),
|
|
38
|
+
}))
|
|
39
|
+
.sort((a, b) => b.relevanceScore - a.relevanceScore)
|
|
40
|
+
.slice(0, 2); // Top 2 most relevant
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get lessons relevant to a component being modified
|
|
44
|
+
*
|
|
45
|
+
* Called when we detect work in a historically problematic area
|
|
46
|
+
*/
|
|
47
|
+
function surfaceLessonsForComponent(component) {
|
|
48
|
+
const db = (0, lessons_storage_1.loadLessons)();
|
|
49
|
+
const activeLessons = (0, lessons_storage_1.getActiveLessons)(db);
|
|
50
|
+
// Find lessons that mention this component
|
|
51
|
+
const relevant = activeLessons.filter(l => l.components.some(c => c.toLowerCase().includes(component.toLowerCase()) ||
|
|
52
|
+
component.toLowerCase().includes(c.toLowerCase())));
|
|
53
|
+
if (relevant.length === 0) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
return relevant
|
|
57
|
+
.map(lesson => ({
|
|
58
|
+
lesson,
|
|
59
|
+
relevanceScore: calculateRelevance(lesson, lesson.pattern),
|
|
60
|
+
reason: `${component} has caused ${lesson.pattern} spirals before`,
|
|
61
|
+
suggestedIntervention: getBestIntervention(lesson),
|
|
62
|
+
}))
|
|
63
|
+
.sort((a, b) => b.relevanceScore - a.relevanceScore)
|
|
64
|
+
.slice(0, 2);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get top lessons to show in profile/status
|
|
68
|
+
*/
|
|
69
|
+
function getTopLessons(limit = 3) {
|
|
70
|
+
const db = (0, lessons_storage_1.loadLessons)();
|
|
71
|
+
const activeLessons = (0, lessons_storage_1.getActiveLessons)(db);
|
|
72
|
+
return activeLessons
|
|
73
|
+
.sort((a, b) => {
|
|
74
|
+
// Sort by: severity, confidence, evidence count
|
|
75
|
+
const severityOrder = { critical: 4, high: 3, medium: 2, low: 1 };
|
|
76
|
+
const severityDiff = severityOrder[b.severity] - severityOrder[a.severity];
|
|
77
|
+
if (severityDiff !== 0)
|
|
78
|
+
return severityDiff;
|
|
79
|
+
if (a.confidence !== b.confidence)
|
|
80
|
+
return b.confidence - a.confidence;
|
|
81
|
+
return b.evidenceCount - a.evidenceCount;
|
|
82
|
+
})
|
|
83
|
+
.slice(0, limit);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Format a surfaced lesson for CLI display
|
|
87
|
+
*/
|
|
88
|
+
function formatSurfacedLesson(surfaced) {
|
|
89
|
+
const { lesson, suggestedIntervention } = surfaced;
|
|
90
|
+
const lines = [];
|
|
91
|
+
// Color based on severity
|
|
92
|
+
const severityColor = lesson.severity === 'critical' ? chalk_1.default.red :
|
|
93
|
+
lesson.severity === 'high' ? chalk_1.default.yellow :
|
|
94
|
+
chalk_1.default.cyan;
|
|
95
|
+
const severityIcon = lesson.severity === 'critical' ? '🚨' :
|
|
96
|
+
lesson.severity === 'high' ? '⚠️' :
|
|
97
|
+
lesson.severity === 'medium' ? '💡' : '📝';
|
|
98
|
+
lines.push(severityColor(` ${severityIcon} LESSON: ${lesson.title}`));
|
|
99
|
+
lines.push(chalk_1.default.gray(` Pattern: ${lesson.pattern} (${lesson.evidenceCount}x, ${lesson.totalTimeWasted} min wasted)`));
|
|
100
|
+
// Show best intervention if available
|
|
101
|
+
if (suggestedIntervention) {
|
|
102
|
+
const icon = (0, intervention_memory_1.getInterventionIcon)(suggestedIntervention);
|
|
103
|
+
const name = (0, intervention_memory_1.getInterventionDisplayName)(suggestedIntervention);
|
|
104
|
+
const intervention = lesson.interventions.find(i => i.type === suggestedIntervention);
|
|
105
|
+
const effectiveness = intervention ? `${intervention.effectiveness}%` : '';
|
|
106
|
+
lines.push(chalk_1.default.green(` What worked: ${icon} ${name} ${effectiveness}`));
|
|
107
|
+
}
|
|
108
|
+
// Show top prevention tip
|
|
109
|
+
if (lesson.prevention.length > 0) {
|
|
110
|
+
lines.push(chalk_1.default.gray(` Prevention: ${lesson.prevention[0]}`));
|
|
111
|
+
}
|
|
112
|
+
lines.push(chalk_1.default.gray(` Run: vibe-check lesson ${lesson.id}`));
|
|
113
|
+
return lines;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Format a lesson for detailed view
|
|
117
|
+
*/
|
|
118
|
+
function formatLessonDetail(lesson) {
|
|
119
|
+
const lines = [];
|
|
120
|
+
const severityColor = lesson.severity === 'critical' ? chalk_1.default.red :
|
|
121
|
+
lesson.severity === 'high' ? chalk_1.default.yellow :
|
|
122
|
+
chalk_1.default.cyan;
|
|
123
|
+
lines.push('');
|
|
124
|
+
lines.push(severityColor('='.repeat(64)));
|
|
125
|
+
lines.push(severityColor(` LESSON: ${lesson.title}`));
|
|
126
|
+
lines.push(severityColor('='.repeat(64)));
|
|
127
|
+
lines.push('');
|
|
128
|
+
// Pattern info
|
|
129
|
+
lines.push(chalk_1.default.bold.white(' PATTERN'));
|
|
130
|
+
lines.push(` ${lesson.pattern}`);
|
|
131
|
+
lines.push(` Occurrences: ${lesson.evidenceCount}`);
|
|
132
|
+
lines.push(` Time wasted: ${lesson.totalTimeWasted} min`);
|
|
133
|
+
lines.push(` Severity: ${lesson.severity}`);
|
|
134
|
+
lines.push(` Confidence: ${lesson.confidence}%`);
|
|
135
|
+
lines.push('');
|
|
136
|
+
// Components
|
|
137
|
+
if (lesson.components.length > 0) {
|
|
138
|
+
lines.push(chalk_1.default.bold.white(' COMPONENTS AFFECTED'));
|
|
139
|
+
for (const comp of lesson.components) {
|
|
140
|
+
lines.push(` - ${comp}`);
|
|
141
|
+
}
|
|
142
|
+
lines.push('');
|
|
143
|
+
}
|
|
144
|
+
// Root cause
|
|
145
|
+
if (lesson.rootCause) {
|
|
146
|
+
lines.push(chalk_1.default.bold.white(' ROOT CAUSE'));
|
|
147
|
+
lines.push(` ${lesson.rootCause}`);
|
|
148
|
+
lines.push('');
|
|
149
|
+
}
|
|
150
|
+
// Prevention
|
|
151
|
+
if (lesson.prevention.length > 0) {
|
|
152
|
+
lines.push(chalk_1.default.bold.white(' PREVENTION'));
|
|
153
|
+
for (const step of lesson.prevention) {
|
|
154
|
+
lines.push(` - ${step}`);
|
|
155
|
+
}
|
|
156
|
+
lines.push('');
|
|
157
|
+
}
|
|
158
|
+
// What worked
|
|
159
|
+
if (lesson.interventions.length > 0) {
|
|
160
|
+
lines.push(chalk_1.default.bold.white(' WHAT WORKED'));
|
|
161
|
+
for (const int of lesson.interventions) {
|
|
162
|
+
const icon = (0, intervention_memory_1.getInterventionIcon)(int.type);
|
|
163
|
+
const name = (0, intervention_memory_1.getInterventionDisplayName)(int.type);
|
|
164
|
+
lines.push(` ${icon} ${name}: ${int.effectiveness}% effective (${int.successCount}/${int.totalCount})`);
|
|
165
|
+
}
|
|
166
|
+
lines.push('');
|
|
167
|
+
}
|
|
168
|
+
// Status
|
|
169
|
+
lines.push(chalk_1.default.bold.white(' STATUS'));
|
|
170
|
+
if (lesson.applied) {
|
|
171
|
+
lines.push(chalk_1.default.green(` ✓ Applied on ${lesson.appliedDate}`));
|
|
172
|
+
if (lesson.userEffectiveness !== undefined) {
|
|
173
|
+
lines.push(` User effectiveness rating: ${lesson.userEffectiveness}%`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else if (lesson.dismissed) {
|
|
177
|
+
lines.push(chalk_1.default.gray(' ✗ Dismissed'));
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
lines.push(chalk_1.default.yellow(' ○ Not yet applied'));
|
|
181
|
+
}
|
|
182
|
+
lines.push('');
|
|
183
|
+
// Actions
|
|
184
|
+
lines.push(chalk_1.default.bold.white(' ACTIONS'));
|
|
185
|
+
lines.push(chalk_1.default.gray(` vibe-check lesson ${lesson.id} --apply 80 # Mark as applied with 80% effectiveness`));
|
|
186
|
+
lines.push(chalk_1.default.gray(` vibe-check lesson ${lesson.id} --dismiss # Dismiss if not relevant`));
|
|
187
|
+
lines.push('');
|
|
188
|
+
lines.push(severityColor('='.repeat(64)));
|
|
189
|
+
lines.push('');
|
|
190
|
+
return lines;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Format lessons summary for learn --status
|
|
194
|
+
*/
|
|
195
|
+
function formatLessonsSummary() {
|
|
196
|
+
const db = (0, lessons_storage_1.loadLessons)();
|
|
197
|
+
const lines = [];
|
|
198
|
+
if (db.lessons.length === 0) {
|
|
199
|
+
lines.push(chalk_1.default.gray(' No lessons learned yet (run a retrospective to generate)'));
|
|
200
|
+
return lines;
|
|
201
|
+
}
|
|
202
|
+
lines.push(chalk_1.default.bold.white(` LESSONS LEARNED (${db.stats.activeLessons} active)`));
|
|
203
|
+
lines.push(` Total time wasted on patterns: ${db.stats.totalTimeWastedMinutes} min`);
|
|
204
|
+
lines.push(` Average confidence: ${db.stats.averageConfidence}%`);
|
|
205
|
+
lines.push('');
|
|
206
|
+
// Top lessons
|
|
207
|
+
const topLessons = getTopLessons(3);
|
|
208
|
+
if (topLessons.length > 0) {
|
|
209
|
+
lines.push(chalk_1.default.bold.white(' TOP LESSONS'));
|
|
210
|
+
for (const lesson of topLessons) {
|
|
211
|
+
const severityIcon = lesson.severity === 'critical' ? '🚨' :
|
|
212
|
+
lesson.severity === 'high' ? '⚠️' :
|
|
213
|
+
lesson.severity === 'medium' ? '💡' : '📝';
|
|
214
|
+
lines.push(` ${severityIcon} ${lesson.title}`);
|
|
215
|
+
lines.push(chalk_1.default.gray(` ${lesson.pattern}: ${lesson.evidenceCount}x, ${lesson.totalTimeWasted} min`));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return lines;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Calculate relevance score for a lesson
|
|
222
|
+
*/
|
|
223
|
+
function calculateRelevance(lesson, pattern) {
|
|
224
|
+
let score = 0;
|
|
225
|
+
// Base score from confidence
|
|
226
|
+
score += lesson.confidence * 0.4;
|
|
227
|
+
// Bonus for exact pattern match
|
|
228
|
+
if (lesson.pattern === pattern) {
|
|
229
|
+
score += 30;
|
|
230
|
+
}
|
|
231
|
+
// Bonus for high evidence count
|
|
232
|
+
score += Math.min(20, lesson.evidenceCount * 4);
|
|
233
|
+
// Bonus for recent updates (within 7 days)
|
|
234
|
+
const daysSinceUpdate = Math.floor((Date.now() - new Date(lesson.updatedAt).getTime()) / (1000 * 60 * 60 * 24));
|
|
235
|
+
if (daysSinceUpdate < 7) {
|
|
236
|
+
score += 10;
|
|
237
|
+
}
|
|
238
|
+
// Penalty if already applied (user knows about it)
|
|
239
|
+
if (lesson.applied) {
|
|
240
|
+
score -= 20;
|
|
241
|
+
}
|
|
242
|
+
return Math.max(0, Math.min(100, score));
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Get the best intervention for a lesson
|
|
246
|
+
*/
|
|
247
|
+
function getBestIntervention(lesson) {
|
|
248
|
+
if (lesson.interventions.length === 0) {
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
// Return intervention with highest effectiveness
|
|
252
|
+
const best = lesson.interventions.reduce((a, b) => a.effectiveness > b.effectiveness ? a : b);
|
|
253
|
+
return best.effectiveness > 50 ? best.type : undefined;
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=surfacing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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QACtC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,iDAAiD;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAChD,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC1C,CAAC;IAEF,OAAO,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lesson Synthesis Engine
|
|
3
|
+
*
|
|
4
|
+
* Automatically extracts lessons from pattern + intervention memory.
|
|
5
|
+
* Runs during retrospectives to keep the lessons database current.
|
|
6
|
+
*/
|
|
7
|
+
import { PatternMemory, InterventionMemory } from '../gamification/types';
|
|
8
|
+
/**
|
|
9
|
+
* Synthesize lessons from pattern and intervention memory
|
|
10
|
+
*
|
|
11
|
+
* Called from retrospective to update the lessons database
|
|
12
|
+
*/
|
|
13
|
+
export declare function synthesizeLessons(patternMemory: PatternMemory | undefined, interventionMemory: InterventionMemory | undefined): {
|
|
14
|
+
lessonsCreated: number;
|
|
15
|
+
lessonsUpdated: number;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=synthesis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthesis.d.ts","sourceRoot":"","sources":["../../src/learning/synthesis.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAoB,MAAM,uBAAuB,CAAC;AAI5F;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,GAAG,SAAS,EACxC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,GACjD;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAuDpD"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Lesson Synthesis Engine
|
|
4
|
+
*
|
|
5
|
+
* Automatically extracts lessons from pattern + intervention memory.
|
|
6
|
+
* Runs during retrospectives to keep the lessons database current.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.synthesizeLessons = synthesizeLessons;
|
|
10
|
+
const lessons_types_1 = require("./lessons-types");
|
|
11
|
+
const lessons_storage_1 = require("./lessons-storage");
|
|
12
|
+
const pattern_memory_1 = require("../gamification/pattern-memory");
|
|
13
|
+
/**
|
|
14
|
+
* Synthesize lessons from pattern and intervention memory
|
|
15
|
+
*
|
|
16
|
+
* Called from retrospective to update the lessons database
|
|
17
|
+
*/
|
|
18
|
+
function synthesizeLessons(patternMemory, interventionMemory) {
|
|
19
|
+
if (!patternMemory || patternMemory.records.length === 0) {
|
|
20
|
+
return { lessonsCreated: 0, lessonsUpdated: 0 };
|
|
21
|
+
}
|
|
22
|
+
let db = (0, lessons_storage_1.loadLessons)();
|
|
23
|
+
let lessonsCreated = 0;
|
|
24
|
+
let lessonsUpdated = 0;
|
|
25
|
+
// Process each pattern that meets threshold
|
|
26
|
+
for (const [pattern, count] of Object.entries(patternMemory.patternCounts)) {
|
|
27
|
+
if (count < lessons_types_1.SYNTHESIS_THRESHOLD)
|
|
28
|
+
continue;
|
|
29
|
+
const existingLesson = db.lessons.find(l => l.pattern === pattern && !l.dismissed);
|
|
30
|
+
if (existingLesson) {
|
|
31
|
+
// Update existing lesson
|
|
32
|
+
const updated = updateLessonFromMemory(existingLesson, pattern, patternMemory, interventionMemory);
|
|
33
|
+
db = (0, lessons_storage_1.upsertLesson)(db, updated);
|
|
34
|
+
lessonsUpdated++;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// Create new lesson
|
|
38
|
+
const newLesson = createLessonFromMemory(pattern, patternMemory, interventionMemory);
|
|
39
|
+
db = (0, lessons_storage_1.upsertLesson)(db, newLesson);
|
|
40
|
+
lessonsCreated++;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Log synthesis
|
|
44
|
+
const logEntry = {
|
|
45
|
+
timestamp: new Date().toISOString(),
|
|
46
|
+
lessonsCreated,
|
|
47
|
+
lessonsUpdated,
|
|
48
|
+
patternsProcessed: Object.keys(patternMemory.patternCounts).length,
|
|
49
|
+
};
|
|
50
|
+
db.synthesisLog.push(logEntry);
|
|
51
|
+
// Keep only last 10 log entries
|
|
52
|
+
if (db.synthesisLog.length > 10) {
|
|
53
|
+
db.synthesisLog = db.synthesisLog.slice(-10);
|
|
54
|
+
}
|
|
55
|
+
db.lastSynthesis = new Date().toISOString();
|
|
56
|
+
(0, lessons_storage_1.saveLessons)(db);
|
|
57
|
+
return { lessonsCreated, lessonsUpdated };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a new lesson from pattern memory data
|
|
61
|
+
*/
|
|
62
|
+
function createLessonFromMemory(pattern, patternMemory, interventionMemory) {
|
|
63
|
+
const now = new Date().toISOString();
|
|
64
|
+
const displayName = (0, pattern_memory_1.getPatternDisplayName)(pattern);
|
|
65
|
+
const advice = (0, pattern_memory_1.getPatternAdvice)(pattern);
|
|
66
|
+
// Get components associated with this pattern
|
|
67
|
+
const components = getComponentsForPattern(pattern, patternMemory);
|
|
68
|
+
// Get interventions that worked for this pattern
|
|
69
|
+
const interventions = getInterventionsForPattern(pattern, interventionMemory);
|
|
70
|
+
// Calculate time wasted
|
|
71
|
+
const totalTimeWasted = patternMemory.patternDurations[pattern] || 0;
|
|
72
|
+
const evidenceCount = patternMemory.patternCounts[pattern] || 0;
|
|
73
|
+
// Calculate initial confidence
|
|
74
|
+
const confidence = calculateConfidence(evidenceCount, interventions, false);
|
|
75
|
+
// Determine severity based on time wasted
|
|
76
|
+
const severity = totalTimeWasted > 120 ? 'critical' :
|
|
77
|
+
totalTimeWasted > 60 ? 'high' :
|
|
78
|
+
totalTimeWasted > 30 ? 'medium' : 'low';
|
|
79
|
+
return {
|
|
80
|
+
id: generateLessonId(pattern),
|
|
81
|
+
version: 1,
|
|
82
|
+
createdAt: now,
|
|
83
|
+
updatedAt: now,
|
|
84
|
+
pattern,
|
|
85
|
+
components,
|
|
86
|
+
title: `${displayName} causes recurring spirals`,
|
|
87
|
+
description: `You've encountered ${displayName} issues ${evidenceCount} times, ` +
|
|
88
|
+
`wasting ${totalTimeWasted} minutes total. ${advice}`,
|
|
89
|
+
rootCause: getRootCauseForPattern(pattern),
|
|
90
|
+
prevention: getPreventionForPattern(pattern),
|
|
91
|
+
interventions,
|
|
92
|
+
confidence,
|
|
93
|
+
evidenceCount,
|
|
94
|
+
totalTimeWasted,
|
|
95
|
+
dismissed: false,
|
|
96
|
+
applied: false,
|
|
97
|
+
severity,
|
|
98
|
+
tags: getTagsForPattern(pattern),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Update an existing lesson with new data
|
|
103
|
+
*/
|
|
104
|
+
function updateLessonFromMemory(lesson, pattern, patternMemory, interventionMemory) {
|
|
105
|
+
const newComponents = getComponentsForPattern(pattern, patternMemory);
|
|
106
|
+
const newInterventions = getInterventionsForPattern(pattern, interventionMemory);
|
|
107
|
+
const newEvidenceCount = patternMemory.patternCounts[pattern] || 0;
|
|
108
|
+
const newTimeWasted = patternMemory.patternDurations[pattern] || 0;
|
|
109
|
+
// Merge components
|
|
110
|
+
const components = [...new Set([...lesson.components, ...newComponents])];
|
|
111
|
+
// Merge interventions (update effectiveness)
|
|
112
|
+
const interventions = mergeInterventions(lesson.interventions, newInterventions);
|
|
113
|
+
// Recalculate confidence
|
|
114
|
+
const confidence = calculateConfidence(newEvidenceCount, interventions, lesson.applied);
|
|
115
|
+
// Update severity if time wasted increased significantly
|
|
116
|
+
const severity = newTimeWasted > 120 ? 'critical' :
|
|
117
|
+
newTimeWasted > 60 ? 'high' :
|
|
118
|
+
newTimeWasted > 30 ? 'medium' : 'low';
|
|
119
|
+
return {
|
|
120
|
+
...lesson,
|
|
121
|
+
components,
|
|
122
|
+
interventions,
|
|
123
|
+
confidence,
|
|
124
|
+
evidenceCount: newEvidenceCount,
|
|
125
|
+
totalTimeWasted: newTimeWasted,
|
|
126
|
+
severity,
|
|
127
|
+
description: `You've encountered ${(0, pattern_memory_1.getPatternDisplayName)(pattern)} issues ${newEvidenceCount} times, ` +
|
|
128
|
+
`wasting ${newTimeWasted} minutes total. ${(0, pattern_memory_1.getPatternAdvice)(pattern)}`,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get components where a pattern occurs
|
|
133
|
+
*/
|
|
134
|
+
function getComponentsForPattern(pattern, patternMemory) {
|
|
135
|
+
const components = new Set();
|
|
136
|
+
for (const record of patternMemory.records) {
|
|
137
|
+
if (record.pattern === pattern && record.component) {
|
|
138
|
+
components.add(record.component);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return Array.from(components).slice(0, 5); // Top 5 components
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get interventions that worked for a pattern
|
|
145
|
+
*/
|
|
146
|
+
function getInterventionsForPattern(pattern, interventionMemory) {
|
|
147
|
+
if (!interventionMemory || interventionMemory.records.length === 0) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
// Count interventions for this pattern
|
|
151
|
+
const counts = {};
|
|
152
|
+
for (const record of interventionMemory.records) {
|
|
153
|
+
if (record.spiralPattern === pattern) {
|
|
154
|
+
if (!counts[record.type]) {
|
|
155
|
+
counts[record.type] = { success: 0, total: 0 };
|
|
156
|
+
}
|
|
157
|
+
counts[record.type].total++;
|
|
158
|
+
// Assume any recorded intervention was successful (broke the spiral)
|
|
159
|
+
counts[record.type].success++;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return Object.entries(counts)
|
|
163
|
+
.map(([type, data]) => ({
|
|
164
|
+
type: type,
|
|
165
|
+
successCount: data.success,
|
|
166
|
+
totalCount: data.total,
|
|
167
|
+
effectiveness: Math.round((data.success / data.total) * 100),
|
|
168
|
+
}))
|
|
169
|
+
.sort((a, b) => b.effectiveness - a.effectiveness);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Merge intervention data from existing and new
|
|
173
|
+
*/
|
|
174
|
+
function mergeInterventions(existing, incoming) {
|
|
175
|
+
const merged = new Map();
|
|
176
|
+
// Start with existing
|
|
177
|
+
for (const int of existing) {
|
|
178
|
+
merged.set(int.type, { ...int });
|
|
179
|
+
}
|
|
180
|
+
// Add/update with incoming
|
|
181
|
+
for (const int of incoming) {
|
|
182
|
+
const current = merged.get(int.type);
|
|
183
|
+
if (current) {
|
|
184
|
+
current.successCount += int.successCount;
|
|
185
|
+
current.totalCount += int.totalCount;
|
|
186
|
+
current.effectiveness = Math.round((current.successCount / current.totalCount) * 100);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
merged.set(int.type, { ...int });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return Array.from(merged.values())
|
|
193
|
+
.sort((a, b) => b.effectiveness - a.effectiveness);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Calculate confidence score for a lesson
|
|
197
|
+
*/
|
|
198
|
+
function calculateConfidence(evidenceCount, interventions, applied) {
|
|
199
|
+
let confidence = lessons_types_1.CONFIDENCE_BASE;
|
|
200
|
+
// +5 per evidence (up to +25)
|
|
201
|
+
confidence += Math.min(25, evidenceCount * 5);
|
|
202
|
+
// +15 if an intervention has >70% effectiveness
|
|
203
|
+
if (interventions.some(i => i.effectiveness > 70)) {
|
|
204
|
+
confidence += 15;
|
|
205
|
+
}
|
|
206
|
+
// +10 if user has applied and confirmed
|
|
207
|
+
if (applied) {
|
|
208
|
+
confidence += 10;
|
|
209
|
+
}
|
|
210
|
+
return Math.min(100, Math.max(0, confidence));
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Generate a unique lesson ID
|
|
214
|
+
*/
|
|
215
|
+
function generateLessonId(pattern) {
|
|
216
|
+
const timestamp = Date.now().toString(36);
|
|
217
|
+
const patternSlug = pattern.toLowerCase().replace(/_/g, '-');
|
|
218
|
+
return `lesson-${patternSlug}-${timestamp}`;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get root cause explanation for a pattern
|
|
222
|
+
*/
|
|
223
|
+
function getRootCauseForPattern(pattern) {
|
|
224
|
+
const causes = {
|
|
225
|
+
SECRETS_AUTH: 'Authentication configs often fail silently or have environment-specific behavior',
|
|
226
|
+
VOLUME_CONFIG: 'Volume mounts have complex permission and path requirements that vary by platform',
|
|
227
|
+
API_MISMATCH: 'API contracts change without notice or documentation lags behind implementation',
|
|
228
|
+
SSL_TLS: 'Certificate chains are complex and expiration/rotation is easy to miss',
|
|
229
|
+
IMAGE_REGISTRY: 'Container registries have authentication and tagging edge cases',
|
|
230
|
+
GITOPS_DRIFT: 'Manual changes bypass GitOps and cause state divergence',
|
|
231
|
+
OTHER: 'Complex interactions between components cause unexpected behavior',
|
|
232
|
+
};
|
|
233
|
+
return causes[pattern] || causes.OTHER;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get prevention strategies for a pattern
|
|
237
|
+
*/
|
|
238
|
+
function getPreventionForPattern(pattern) {
|
|
239
|
+
const prevention = {
|
|
240
|
+
SECRETS_AUTH: [
|
|
241
|
+
'Add secret validation to CI pipeline',
|
|
242
|
+
'Use secret scanning tools',
|
|
243
|
+
'Test auth flows in staging before prod',
|
|
244
|
+
],
|
|
245
|
+
VOLUME_CONFIG: [
|
|
246
|
+
'Add volume mount tests to CI',
|
|
247
|
+
'Validate paths exist before mount',
|
|
248
|
+
'Document platform-specific requirements',
|
|
249
|
+
],
|
|
250
|
+
API_MISMATCH: [
|
|
251
|
+
'Use schema validation (OpenAPI, JSON Schema)',
|
|
252
|
+
'Version APIs explicitly',
|
|
253
|
+
'Add contract tests between services',
|
|
254
|
+
],
|
|
255
|
+
SSL_TLS: [
|
|
256
|
+
'Automate certificate renewal',
|
|
257
|
+
'Test certificate chains in staging',
|
|
258
|
+
'Set up expiration monitoring',
|
|
259
|
+
],
|
|
260
|
+
IMAGE_REGISTRY: [
|
|
261
|
+
'Use digest-based pulls instead of tags',
|
|
262
|
+
'Verify images exist before deploy',
|
|
263
|
+
'Cache images locally for reliability',
|
|
264
|
+
],
|
|
265
|
+
GITOPS_DRIFT: [
|
|
266
|
+
'Enable drift detection in CI',
|
|
267
|
+
'Block manual kubectl/oc commands',
|
|
268
|
+
'Set reconciliation timeouts',
|
|
269
|
+
],
|
|
270
|
+
OTHER: [
|
|
271
|
+
'Add integration tests for the component',
|
|
272
|
+
'Document failure modes',
|
|
273
|
+
'Create runbook for common issues',
|
|
274
|
+
],
|
|
275
|
+
};
|
|
276
|
+
return prevention[pattern] || prevention.OTHER;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Get tags for a pattern
|
|
280
|
+
*/
|
|
281
|
+
function getTagsForPattern(pattern) {
|
|
282
|
+
const tags = {
|
|
283
|
+
SECRETS_AUTH: ['security', 'auth', 'secrets'],
|
|
284
|
+
VOLUME_CONFIG: ['infrastructure', 'storage', 'kubernetes'],
|
|
285
|
+
API_MISMATCH: ['api', 'integration', 'contracts'],
|
|
286
|
+
SSL_TLS: ['security', 'certificates', 'networking'],
|
|
287
|
+
IMAGE_REGISTRY: ['containers', 'docker', 'registry'],
|
|
288
|
+
GITOPS_DRIFT: ['gitops', 'kubernetes', 'drift'],
|
|
289
|
+
OTHER: ['general'],
|
|
290
|
+
};
|
|
291
|
+
return tags[pattern] || tags.OTHER;
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=synthesis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthesis.js","sourceRoot":"","sources":["../../src/learning/synthesis.ts"],"names":[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AAwC;SACzC;QACD,aAAa,EAAE;YACb,8BAA8B;YAC9B,mCAAmC;YACnC,yCAAyC;SAC1C;QACD,YAAY,EAAE;YACZ,8CAA8C;YAC9C,yBAAyB;YACzB,qCAAqC;SACtC;QACD,OAAO,EAAE;YACP,8BAA8B;YAC9B,oCAAoC;YACpC,8BAA8B;SAC/B;QACD,cAAc,EAAE;YACd,wCAAwC;YACxC,mCAAmC;YACnC,sCAAsC;SACvC;QACD,YAAY,EAAE;YACZ,8BAA8B;YAC9B,kCAAkC;YAClC,6BAA6B;SAC9B;QACD,KAAK,EAAE;YACL,yCAAyC;YACzC,wBAAwB;YACxB,kCAAkC;SACnC;KACF,CAAC;IACF,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,OAAe;IACxC,MAAM,IAAI,GAA6B;QACrC,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC;QAC7C,aAAa,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,YAAY,CAAC;QAC1D,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,CAAC;QACjD,OAAO,EAAE,CAAC,UAAU,EAAE,cAAc,EAAE,YAAY,CAAC;QACnD,cAAc,EAAE,CAAC,YAAY,EAAE,QAAQ,EAAE,UAAU,CAAC;QACpD,YAAY,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC;QAC/C,KAAK,EAAE,CAAC,SAAS,CAAC;KACnB,CAAC;IACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Learning System Types
|
|
3
|
+
*
|
|
4
|
+
* Types for the automatic learning cadence system including:
|
|
5
|
+
* - Learning state persistence
|
|
6
|
+
* - Nudge queue management
|
|
7
|
+
* - Retrospective summaries
|
|
8
|
+
*/
|
|
9
|
+
export type NudgeType = 'pattern' | 'intervention' | 'retro' | 'achievement' | 'learning';
|
|
10
|
+
export interface Nudge {
|
|
11
|
+
id: string;
|
|
12
|
+
type: NudgeType;
|
|
13
|
+
icon: string;
|
|
14
|
+
title: string;
|
|
15
|
+
message: string;
|
|
16
|
+
action?: string;
|
|
17
|
+
priority: number;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
expiresAt?: string;
|
|
20
|
+
dismissed?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface RetroSummary {
|
|
23
|
+
date: string;
|
|
24
|
+
periodStart: string;
|
|
25
|
+
periodEnd: string;
|
|
26
|
+
sessionsCount: number;
|
|
27
|
+
commitsCount: number;
|
|
28
|
+
activeMinutes: number;
|
|
29
|
+
topPattern?: string;
|
|
30
|
+
topIntervention?: string;
|
|
31
|
+
keyInsight: string;
|
|
32
|
+
trustPassRateChange?: number;
|
|
33
|
+
spiralRateChange?: number;
|
|
34
|
+
actionTaken?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface LearningState {
|
|
37
|
+
version: string;
|
|
38
|
+
lastDailyCheck: string;
|
|
39
|
+
lastWeeklyRetro: string;
|
|
40
|
+
lastMonthlyReview: string;
|
|
41
|
+
pendingNudges: Nudge[];
|
|
42
|
+
retroDue: boolean;
|
|
43
|
+
retroDueReason: string;
|
|
44
|
+
lastRetroSummary?: RetroSummary;
|
|
45
|
+
totalRetrosCompleted: number;
|
|
46
|
+
nudgesDisplayed: number;
|
|
47
|
+
nudgesDismissed: number;
|
|
48
|
+
}
|
|
49
|
+
export interface CadenceResult {
|
|
50
|
+
nudges: Nudge[];
|
|
51
|
+
retroDue: boolean;
|
|
52
|
+
retroDueReason?: string;
|
|
53
|
+
learningState: LearningState;
|
|
54
|
+
}
|
|
55
|
+
export declare const NUDGE_TTL_DAYS = 7;
|
|
56
|
+
export declare const MAX_PENDING_NUDGES = 5;
|
|
57
|
+
export declare const RETRO_CADENCE_DAYS = 7;
|
|
58
|
+
export declare const PATTERN_REPEAT_THRESHOLD = 3;
|
|
59
|
+
export declare const PATTERN_WINDOW_DAYS = 7;
|
|
60
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/learning/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,cAAc,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,CAAC;AAE1F,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAGhB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,M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