cmp-standards 3.7.0 → 3.7.1
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/dist/hooks/auto-learning-hook.d.ts +48 -0
- package/dist/hooks/auto-learning-hook.d.ts.map +1 -0
- package/dist/hooks/auto-learning-hook.js +258 -0
- package/dist/hooks/auto-learning-hook.js.map +1 -0
- package/dist/hooks/fast-session-start.d.ts +24 -0
- package/dist/hooks/fast-session-start.d.ts.map +1 -0
- package/dist/hooks/fast-session-start.js +354 -0
- package/dist/hooks/fast-session-start.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/services/auto-evolution-trigger.d.ts +101 -0
- package/dist/services/auto-evolution-trigger.d.ts.map +1 -0
- package/dist/services/auto-evolution-trigger.js +359 -0
- package/dist/services/auto-evolution-trigger.js.map +1 -0
- package/dist/services/cloud-memory-service.d.ts +101 -0
- package/dist/services/cloud-memory-service.d.ts.map +1 -0
- package/dist/services/cloud-memory-service.js +363 -0
- package/dist/services/cloud-memory-service.js.map +1 -0
- package/dist/services/memory-keeper-client.d.ts +106 -0
- package/dist/services/memory-keeper-client.d.ts.map +1 -0
- package/dist/services/memory-keeper-client.js +319 -0
- package/dist/services/memory-keeper-client.js.map +1 -0
- package/dist/services/skill-learning-bridge.d.ts +100 -0
- package/dist/services/skill-learning-bridge.d.ts.map +1 -0
- package/dist/services/skill-learning-bridge.js +331 -0
- package/dist/services/skill-learning-bridge.js.map +1 -0
- package/dist/services/unified-memory-router.d.ts +123 -0
- package/dist/services/unified-memory-router.d.ts.map +1 -0
- package/dist/services/unified-memory-router.js +555 -0
- package/dist/services/unified-memory-router.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Auto-Learning PostToolUse Hook
|
|
3
|
+
* @description Automatically detects and records learnings from code changes
|
|
4
|
+
*
|
|
5
|
+
* ## What It Detects
|
|
6
|
+
*
|
|
7
|
+
* 1. **Type Safety Improvements**
|
|
8
|
+
* - `any` → specific type
|
|
9
|
+
* - Type assertions removed
|
|
10
|
+
* - Zod schemas added
|
|
11
|
+
*
|
|
12
|
+
* 2. **Pattern Corrections**
|
|
13
|
+
* - useEffect optimizations
|
|
14
|
+
* - Component structure fixes
|
|
15
|
+
* - API pattern standardization
|
|
16
|
+
*
|
|
17
|
+
* 3. **Bug Fixes**
|
|
18
|
+
* - Error handling added
|
|
19
|
+
* - Null checks added
|
|
20
|
+
* - Logic corrections
|
|
21
|
+
*
|
|
22
|
+
* ## Integration Points
|
|
23
|
+
*
|
|
24
|
+
* - Writes to memory-keeper MCP (local)
|
|
25
|
+
* - Updates skills/learnings.md files
|
|
26
|
+
* - Syncs to cmp-standards cloud (async)
|
|
27
|
+
*
|
|
28
|
+
* @version 1.0.0
|
|
29
|
+
*/
|
|
30
|
+
interface ToolUseEvent {
|
|
31
|
+
tool: string;
|
|
32
|
+
params: Record<string, unknown>;
|
|
33
|
+
result?: string;
|
|
34
|
+
timestamp: string;
|
|
35
|
+
}
|
|
36
|
+
interface DetectedLearning {
|
|
37
|
+
type: 'type-safety' | 'pattern' | 'bugfix' | 'architecture' | 'performance';
|
|
38
|
+
skill: string;
|
|
39
|
+
context: string;
|
|
40
|
+
problem: string;
|
|
41
|
+
solution: string;
|
|
42
|
+
file: string;
|
|
43
|
+
confidence: number;
|
|
44
|
+
}
|
|
45
|
+
export declare function onPostToolUse(event: ToolUseEvent): Promise<void>;
|
|
46
|
+
export declare function processEditEvent(filePath: string, oldContent: string, newContent: string): Promise<DetectedLearning[]>;
|
|
47
|
+
export default onPostToolUse;
|
|
48
|
+
//# sourceMappingURL=auto-learning-hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-learning-hook.d.ts","sourceRoot":"","sources":["../../src/hooks/auto-learning-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAUH,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,cAAc,GAAG,aAAa,CAAA;IAC3E,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB;AAsOD,wBAAsB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCtE;AAMD,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAQ7B;AAiBD,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Auto-Learning PostToolUse Hook
|
|
3
|
+
* @description Automatically detects and records learnings from code changes
|
|
4
|
+
*
|
|
5
|
+
* ## What It Detects
|
|
6
|
+
*
|
|
7
|
+
* 1. **Type Safety Improvements**
|
|
8
|
+
* - `any` → specific type
|
|
9
|
+
* - Type assertions removed
|
|
10
|
+
* - Zod schemas added
|
|
11
|
+
*
|
|
12
|
+
* 2. **Pattern Corrections**
|
|
13
|
+
* - useEffect optimizations
|
|
14
|
+
* - Component structure fixes
|
|
15
|
+
* - API pattern standardization
|
|
16
|
+
*
|
|
17
|
+
* 3. **Bug Fixes**
|
|
18
|
+
* - Error handling added
|
|
19
|
+
* - Null checks added
|
|
20
|
+
* - Logic corrections
|
|
21
|
+
*
|
|
22
|
+
* ## Integration Points
|
|
23
|
+
*
|
|
24
|
+
* - Writes to memory-keeper MCP (local)
|
|
25
|
+
* - Updates skills/learnings.md files
|
|
26
|
+
* - Syncs to cmp-standards cloud (async)
|
|
27
|
+
*
|
|
28
|
+
* @version 1.0.0
|
|
29
|
+
*/
|
|
30
|
+
import { existsSync, readFileSync, appendFileSync, mkdirSync } from 'fs';
|
|
31
|
+
import { join, dirname, basename, extname } from 'path';
|
|
32
|
+
import { homedir } from 'os';
|
|
33
|
+
// =============================================================================
|
|
34
|
+
// Constants
|
|
35
|
+
// =============================================================================
|
|
36
|
+
const SKILLS_DIR = join(homedir(), '.claude', 'skills');
|
|
37
|
+
const MIN_CONFIDENCE = 0.7;
|
|
38
|
+
// Skill mappings for detected patterns
|
|
39
|
+
const SKILL_MAPPINGS = {
|
|
40
|
+
'type-safety': 'quality/type-safety-enforcer',
|
|
41
|
+
'pattern': 'architecture/domain-structure-guardian',
|
|
42
|
+
'bugfix': 'quality/systematic-debugging',
|
|
43
|
+
'architecture': 'architecture/simplification-cascades',
|
|
44
|
+
'performance': 'quality/useeffect-reducer'
|
|
45
|
+
};
|
|
46
|
+
function analyzeDiff(oldContent, newContent) {
|
|
47
|
+
return {
|
|
48
|
+
hadAny: /:\s*any\b|<any>|as\s+any/.test(oldContent),
|
|
49
|
+
hasAny: /:\s*any\b|<any>|as\s+any/.test(newContent),
|
|
50
|
+
addedTypes: !oldContent.includes('interface ') && newContent.includes('interface ') ||
|
|
51
|
+
!oldContent.includes('type ') && newContent.includes('type '),
|
|
52
|
+
addedZod: !oldContent.includes('z.object') && newContent.includes('z.object'),
|
|
53
|
+
addedNullCheck: (newContent.match(/\?\./g) || []).length > (oldContent.match(/\?\./g) || []).length,
|
|
54
|
+
addedErrorHandling: !oldContent.includes('try {') && newContent.includes('try {') ||
|
|
55
|
+
!oldContent.includes('catch (') && newContent.includes('catch ('),
|
|
56
|
+
removedUseEffect: (oldContent.match(/useEffect/g) || []).length > (newContent.match(/useEffect/g) || []).length,
|
|
57
|
+
optimizedRender: !oldContent.includes('useMemo') && newContent.includes('useMemo') ||
|
|
58
|
+
!oldContent.includes('useCallback') && newContent.includes('useCallback'),
|
|
59
|
+
fixedImport: oldContent.includes('from "') && newContent.includes('from "') &&
|
|
60
|
+
oldContent.split('from "').length !== newContent.split('from "').length
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function detectLearnings(file, oldContent, newContent) {
|
|
64
|
+
const learnings = [];
|
|
65
|
+
const analysis = analyzeDiff(oldContent, newContent);
|
|
66
|
+
const ext = extname(file);
|
|
67
|
+
// Only analyze TypeScript/JavaScript files
|
|
68
|
+
if (!['.ts', '.tsx', '.js', '.jsx'].includes(ext)) {
|
|
69
|
+
return learnings;
|
|
70
|
+
}
|
|
71
|
+
// Type Safety: any → specific type
|
|
72
|
+
if (analysis.hadAny && !analysis.hasAny) {
|
|
73
|
+
learnings.push({
|
|
74
|
+
type: 'type-safety',
|
|
75
|
+
skill: 'type-safety-enforcer',
|
|
76
|
+
context: basename(file),
|
|
77
|
+
problem: 'Code contained `any` type annotations',
|
|
78
|
+
solution: 'Replaced with specific types or Zod schemas',
|
|
79
|
+
file,
|
|
80
|
+
confidence: 0.9
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// Type Safety: Added Zod validation
|
|
84
|
+
if (analysis.addedZod) {
|
|
85
|
+
learnings.push({
|
|
86
|
+
type: 'type-safety',
|
|
87
|
+
skill: 'type-safety-enforcer',
|
|
88
|
+
context: basename(file),
|
|
89
|
+
problem: 'Missing runtime type validation',
|
|
90
|
+
solution: 'Added Zod schema for runtime validation',
|
|
91
|
+
file,
|
|
92
|
+
confidence: 0.85
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// Performance: Removed useEffect
|
|
96
|
+
if (analysis.removedUseEffect) {
|
|
97
|
+
learnings.push({
|
|
98
|
+
type: 'performance',
|
|
99
|
+
skill: 'useeffect-reducer',
|
|
100
|
+
context: basename(file),
|
|
101
|
+
problem: 'Unnecessary useEffect causing re-renders',
|
|
102
|
+
solution: 'Removed useEffect, derived state or used event handler instead',
|
|
103
|
+
file,
|
|
104
|
+
confidence: 0.8
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
// Performance: Added memoization
|
|
108
|
+
if (analysis.optimizedRender) {
|
|
109
|
+
learnings.push({
|
|
110
|
+
type: 'performance',
|
|
111
|
+
skill: 'useeffect-reducer',
|
|
112
|
+
context: basename(file),
|
|
113
|
+
problem: 'Expensive computation or callback recreated on every render',
|
|
114
|
+
solution: 'Added useMemo/useCallback for optimization',
|
|
115
|
+
file,
|
|
116
|
+
confidence: 0.75
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
// Bug Fix: Added error handling
|
|
120
|
+
if (analysis.addedErrorHandling) {
|
|
121
|
+
learnings.push({
|
|
122
|
+
type: 'bugfix',
|
|
123
|
+
skill: 'systematic-debugging',
|
|
124
|
+
context: basename(file),
|
|
125
|
+
problem: 'Missing error handling could cause uncaught exceptions',
|
|
126
|
+
solution: 'Added try-catch block for proper error handling',
|
|
127
|
+
file,
|
|
128
|
+
confidence: 0.8
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// Bug Fix: Added null checks
|
|
132
|
+
if (analysis.addedNullCheck) {
|
|
133
|
+
learnings.push({
|
|
134
|
+
type: 'bugfix',
|
|
135
|
+
skill: 'systematic-debugging',
|
|
136
|
+
context: basename(file),
|
|
137
|
+
problem: 'Potential null/undefined access',
|
|
138
|
+
solution: 'Added optional chaining for safe property access',
|
|
139
|
+
file,
|
|
140
|
+
confidence: 0.7
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return learnings.filter(l => l.confidence >= MIN_CONFIDENCE);
|
|
144
|
+
}
|
|
145
|
+
// =============================================================================
|
|
146
|
+
// Skills Integration
|
|
147
|
+
// =============================================================================
|
|
148
|
+
function formatLearningEntry(learning) {
|
|
149
|
+
const date = new Date().toISOString().split('T')[0];
|
|
150
|
+
return `
|
|
151
|
+
### Learning ${date}
|
|
152
|
+
|
|
153
|
+
**Context:** ${learning.context}
|
|
154
|
+
**Problem:** ${learning.problem}
|
|
155
|
+
**Solution:** ${learning.solution}
|
|
156
|
+
**Confidence:** ${Math.round(learning.confidence * 100)}%
|
|
157
|
+
**File:** ${learning.file}
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
function appendToSkillLearnings(learning) {
|
|
163
|
+
try {
|
|
164
|
+
const skillPath = SKILL_MAPPINGS[learning.type];
|
|
165
|
+
if (!skillPath)
|
|
166
|
+
return false;
|
|
167
|
+
const learningsFile = join(SKILLS_DIR, skillPath, 'learnings.md');
|
|
168
|
+
if (!existsSync(learningsFile)) {
|
|
169
|
+
// Create directory if needed
|
|
170
|
+
mkdirSync(dirname(learningsFile), { recursive: true });
|
|
171
|
+
}
|
|
172
|
+
const entry = formatLearningEntry(learning);
|
|
173
|
+
// Read current content to update stats
|
|
174
|
+
let content = '';
|
|
175
|
+
if (existsSync(learningsFile)) {
|
|
176
|
+
content = readFileSync(learningsFile, 'utf-8');
|
|
177
|
+
}
|
|
178
|
+
// Update learning count in header
|
|
179
|
+
const countMatch = content.match(/\*\*Learnings Totales:\*\* (\d+)/);
|
|
180
|
+
if (countMatch) {
|
|
181
|
+
const currentCount = parseInt(countMatch[1], 10);
|
|
182
|
+
content = content.replace(/\*\*Learnings Totales:\*\* \d+/, `**Learnings Totales:** ${currentCount + 1}`);
|
|
183
|
+
}
|
|
184
|
+
// Append new learning after "## Learnings" section
|
|
185
|
+
const learningsSection = content.indexOf('## Learnings');
|
|
186
|
+
if (learningsSection !== -1) {
|
|
187
|
+
const insertPoint = content.indexOf('\n', learningsSection) + 1;
|
|
188
|
+
content = content.slice(0, insertPoint) + entry + content.slice(insertPoint);
|
|
189
|
+
// Write back
|
|
190
|
+
const { writeFileSync } = require('fs');
|
|
191
|
+
writeFileSync(learningsFile, content);
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
// Fallback: append to end
|
|
196
|
+
appendFileSync(learningsFile, entry);
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
console.error('[auto-learning] Failed to write to skills:', error);
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// =============================================================================
|
|
206
|
+
// Main Hook
|
|
207
|
+
// =============================================================================
|
|
208
|
+
export async function onPostToolUse(event) {
|
|
209
|
+
// Only process Edit tool
|
|
210
|
+
if (event.tool !== 'Edit')
|
|
211
|
+
return;
|
|
212
|
+
const params = event.params;
|
|
213
|
+
if (!params.file_path || !params.old_string || !params.new_string)
|
|
214
|
+
return;
|
|
215
|
+
// Detect learnings from the edit
|
|
216
|
+
const learnings = detectLearnings(params.file_path, params.old_string, params.new_string);
|
|
217
|
+
if (learnings.length === 0)
|
|
218
|
+
return;
|
|
219
|
+
// Process each learning
|
|
220
|
+
for (const learning of learnings) {
|
|
221
|
+
// 1. Write to skills/learnings.md
|
|
222
|
+
const written = appendToSkillLearnings(learning);
|
|
223
|
+
if (written) {
|
|
224
|
+
console.log(`[auto-learning] Recorded: ${learning.type} in ${learning.skill}`);
|
|
225
|
+
}
|
|
226
|
+
// 2. TODO: Write to memory-keeper MCP
|
|
227
|
+
// This would require MCP client integration
|
|
228
|
+
// 3. TODO: Sync to cmp-standards cloud
|
|
229
|
+
// This would require cloud client integration
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// =============================================================================
|
|
233
|
+
// Standalone Execution
|
|
234
|
+
// =============================================================================
|
|
235
|
+
export async function processEditEvent(filePath, oldContent, newContent) {
|
|
236
|
+
const learnings = detectLearnings(filePath, oldContent, newContent);
|
|
237
|
+
for (const learning of learnings) {
|
|
238
|
+
appendToSkillLearnings(learning);
|
|
239
|
+
}
|
|
240
|
+
return learnings;
|
|
241
|
+
}
|
|
242
|
+
// CLI entry point
|
|
243
|
+
if (process.argv[1]?.includes('auto-learning-hook')) {
|
|
244
|
+
// Read from stdin for hook mode
|
|
245
|
+
let input = '';
|
|
246
|
+
process.stdin.on('data', chunk => { input += chunk; });
|
|
247
|
+
process.stdin.on('end', async () => {
|
|
248
|
+
try {
|
|
249
|
+
const event = JSON.parse(input);
|
|
250
|
+
await onPostToolUse(event);
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
console.error('[auto-learning] Error processing event:', error);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
export default onPostToolUse;
|
|
258
|
+
//# sourceMappingURL=auto-learning-hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-learning-hook.js","sourceRoot":"","sources":["../../src/hooks/auto-learning-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AACxE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAgC5B,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;AACvD,MAAM,cAAc,GAAG,GAAG,CAAA;AAE1B,uCAAuC;AACvC,MAAM,cAAc,GAA2B;IAC7C,aAAa,EAAE,8BAA8B;IAC7C,SAAS,EAAE,wCAAwC;IACnD,QAAQ,EAAE,8BAA8B;IACxC,cAAc,EAAE,sCAAsC;IACtD,aAAa,EAAE,2BAA2B;CAC3C,CAAA;AAkBD,SAAS,WAAW,CAAC,UAAkB,EAAE,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D,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;QACjC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAiB,CAAA;YAC/C,MAAM,aAAa,CAAC,KAAK,CAAC,CAAA;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAA;QACjE,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Fast Session Start Hook v1.0.0
|
|
3
|
+
* @description Optimized session start with <500ms latency target
|
|
4
|
+
*
|
|
5
|
+
* ## Performance Strategy
|
|
6
|
+
*
|
|
7
|
+
* 1. **Immediate Output**: Return minimal context within 100ms
|
|
8
|
+
* 2. **Lazy Initialization**: Cloud/DB init happens in background
|
|
9
|
+
* 3. **Cached Checks**: Skip expensive checks if recently passed
|
|
10
|
+
* 4. **Two-Phase Loading**: Basic → Enhanced context
|
|
11
|
+
*
|
|
12
|
+
* ## Optimization Techniques
|
|
13
|
+
*
|
|
14
|
+
* - Worker health check: Cached for 5 minutes
|
|
15
|
+
* - Install check: Cached via version marker file
|
|
16
|
+
* - Context injection: Immediate minimal, enhanced async
|
|
17
|
+
* - Git detection: Skipped if no .git directory
|
|
18
|
+
*
|
|
19
|
+
* @version 1.0.0
|
|
20
|
+
*/
|
|
21
|
+
declare function runFastSessionStart(): Promise<void>;
|
|
22
|
+
export { runFastSessionStart };
|
|
23
|
+
export default runFastSessionStart;
|
|
24
|
+
//# sourceMappingURL=fast-session-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-session-start.d.ts","sourceRoot":"","sources":["../../src/hooks/fast-session-start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAkVH,iBAAe,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAoClD;AA2CD,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAC9B,eAAe,mBAAmB,CAAA"}
|