@noyrax/5d-database-plugin 0.1.6 → 0.1.8-beta.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.
Files changed (52) hide show
  1. package/MCP_SERVER_SETUP.md +14 -0
  2. package/README.md +49 -3
  3. package/SETUP_NEW_PROJECT.md +245 -14
  4. package/out/cli/merge-workspaces-cli.d.ts +3 -0
  5. package/out/cli/merge-workspaces-cli.d.ts.map +1 -0
  6. package/out/cli/merge-workspaces-cli.js +199 -0
  7. package/out/cli/merge-workspaces-cli.js.map +1 -0
  8. package/out/cli/tool-cli.js +59 -4
  9. package/out/cli/tool-cli.js.map +1 -1
  10. package/out/core/chromadb-vector-database.d.ts.map +1 -1
  11. package/out/core/chromadb-vector-database.js +6 -2
  12. package/out/core/chromadb-vector-database.js.map +1 -1
  13. package/out/mcp/server.d.ts +3 -0
  14. package/out/mcp/server.d.ts.map +1 -1
  15. package/out/mcp/server.js +141 -0
  16. package/out/mcp/server.js.map +1 -1
  17. package/out/mcp/tools/adr-generator.d.ts +123 -0
  18. package/out/mcp/tools/adr-generator.d.ts.map +1 -0
  19. package/out/mcp/tools/adr-generator.js +1113 -0
  20. package/out/mcp/tools/adr-generator.js.map +1 -0
  21. package/out/mcp/tools/gap-analysis.d.ts +6 -2
  22. package/out/mcp/tools/gap-analysis.d.ts.map +1 -1
  23. package/out/mcp/tools/gap-analysis.js +32 -5
  24. package/out/mcp/tools/gap-analysis.js.map +1 -1
  25. package/out/services/adr-context-builder.d.ts +70 -0
  26. package/out/services/adr-context-builder.d.ts.map +1 -0
  27. package/out/services/adr-context-builder.js +141 -0
  28. package/out/services/adr-context-builder.js.map +1 -0
  29. package/out/services/adr-pattern-analyzer.d.ts +75 -0
  30. package/out/services/adr-pattern-analyzer.d.ts.map +1 -0
  31. package/out/services/adr-pattern-analyzer.js +339 -0
  32. package/out/services/adr-pattern-analyzer.js.map +1 -0
  33. package/out/services/adr-reasoning-service.d.ts +63 -0
  34. package/out/services/adr-reasoning-service.d.ts.map +1 -0
  35. package/out/services/adr-reasoning-service.js +760 -0
  36. package/out/services/adr-reasoning-service.js.map +1 -0
  37. package/out/services/noyrax-integration-service.d.ts +51 -0
  38. package/out/services/noyrax-integration-service.d.ts.map +1 -0
  39. package/out/services/noyrax-integration-service.js +215 -0
  40. package/out/services/noyrax-integration-service.js.map +1 -0
  41. package/out/services/semantic-pattern-matcher.d.ts +61 -0
  42. package/out/services/semantic-pattern-matcher.d.ts.map +1 -0
  43. package/out/services/semantic-pattern-matcher.js +183 -0
  44. package/out/services/semantic-pattern-matcher.js.map +1 -0
  45. package/out/services/workflow-orchestrator.d.ts +63 -0
  46. package/out/services/workflow-orchestrator.d.ts.map +1 -0
  47. package/out/services/workflow-orchestrator.js +111 -0
  48. package/out/services/workflow-orchestrator.js.map +1 -0
  49. package/out/ui/commands.d.ts.map +1 -1
  50. package/out/ui/commands.js +112 -1
  51. package/out/ui/commands.js.map +1 -1
  52. package/package.json +22 -5
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AdrPatternAnalyzer = void 0;
37
+ const adr_repository_1 = require("../repositories/adr-repository");
38
+ const module_repository_1 = require("../repositories/module-repository");
39
+ const path = __importStar(require("path"));
40
+ /**
41
+ * Analyzes existing ADRs to extract patterns and create structure templates.
42
+ * Used for deterministic ADR reconstruction.
43
+ */
44
+ class AdrPatternAnalyzer {
45
+ constructor(dbManager) {
46
+ this.dbManager = dbManager;
47
+ }
48
+ /**
49
+ * Analyzes all ADRs and extracts patterns.
50
+ */
51
+ async analyzeAdrPatterns(pluginId) {
52
+ const adrDb = await this.dbManager.getDatabase('W');
53
+ const moduleDb = await this.dbManager.getDatabase('X');
54
+ const adrRepo = new adr_repository_1.AdrRepository(adrDb);
55
+ const moduleRepo = new module_repository_1.ModuleRepository(moduleDb);
56
+ const allAdrs = await adrRepo.getAll(pluginId);
57
+ const allModules = await moduleRepo.getAll(pluginId);
58
+ const patterns = [];
59
+ // Extract patterns from each ADR
60
+ for (const adr of allAdrs) {
61
+ const fileMappings = await adrRepo.getAdrFileMappings(adr.id);
62
+ // Find modules referenced by this ADR
63
+ for (const mapping of fileMappings) {
64
+ const module = allModules.find(m => m.file_path === mapping.file_path);
65
+ if (module) {
66
+ const pattern = this.extractPatternsFromAdr(adr, module);
67
+ patterns.push(pattern);
68
+ }
69
+ }
70
+ }
71
+ // Group patterns by type
72
+ const patternMap = new Map();
73
+ for (const pattern of patterns) {
74
+ if (!patternMap.has(pattern.patternType)) {
75
+ patternMap.set(pattern.patternType, []);
76
+ }
77
+ patternMap.get(pattern.patternType).push(pattern);
78
+ }
79
+ // Build structure templates for each pattern type
80
+ const structureTemplates = new Map();
81
+ for (const [patternType, patternList] of patternMap.entries()) {
82
+ const structure = this.buildPatternTemplate(patternList);
83
+ structureTemplates.set(patternType, structure);
84
+ }
85
+ return {
86
+ patterns: patternMap,
87
+ structureTemplates
88
+ };
89
+ }
90
+ /**
91
+ * Extracts patterns from an ADR and its associated module.
92
+ */
93
+ extractPatternsFromAdr(adr, module) {
94
+ const patternType = this.detectPatternType(module.file_path);
95
+ const sections = this.extractSections(adr.content_markdown);
96
+ const structure = this.analyzeStructure(adr.content_markdown);
97
+ return {
98
+ patternType,
99
+ modulePath: module.file_path,
100
+ adrNumber: adr.adr_number,
101
+ adrTitle: adr.title,
102
+ sections,
103
+ structure
104
+ };
105
+ }
106
+ /**
107
+ * Finds similar ADR patterns for a target module.
108
+ */
109
+ async findSimilarAdrPatterns(targetModule, pluginId) {
110
+ const patternMap = await this.analyzeAdrPatterns(pluginId);
111
+ const targetPatternType = this.detectPatternType(targetModule.file_path);
112
+ // Find patterns of the same type
113
+ const sameTypePatterns = patternMap.patterns.get(targetPatternType) || [];
114
+ // Also include similar pattern types
115
+ const similarPatterns = [];
116
+ // Repository patterns are similar to each other
117
+ if (targetPatternType === 'Repository') {
118
+ const repoPatterns = patternMap.patterns.get('Repository') || [];
119
+ similarPatterns.push(...repoPatterns);
120
+ }
121
+ // API patterns are similar to each other
122
+ if (targetPatternType === 'API Layer') {
123
+ const apiPatterns = patternMap.patterns.get('API Layer') || [];
124
+ similarPatterns.push(...apiPatterns);
125
+ }
126
+ // Service patterns are similar to each other
127
+ if (targetPatternType === 'Service Layer') {
128
+ const servicePatterns = patternMap.patterns.get('Service Layer') || [];
129
+ similarPatterns.push(...servicePatterns);
130
+ }
131
+ // Combine and deduplicate
132
+ const allPatterns = [...sameTypePatterns, ...similarPatterns];
133
+ const uniquePatterns = Array.from(new Map(allPatterns.map(p => [p.adrNumber, p])).values());
134
+ return uniquePatterns;
135
+ }
136
+ /**
137
+ * Builds a structure template from a list of patterns.
138
+ */
139
+ buildPatternTemplate(patterns) {
140
+ if (patterns.length === 0) {
141
+ return {
142
+ requiredSections: ['Status', 'Kontext', 'Entscheidung', 'Konsequenzen'],
143
+ optionalSections: ['Alternativen', 'Verweise', 'Implementierung'],
144
+ sectionOrder: ['Status', 'Kontext', 'Entscheidung', 'Konsequenzen', 'Verweise'],
145
+ commonPatterns: []
146
+ };
147
+ }
148
+ // Collect all sections from all patterns
149
+ const allSections = new Set();
150
+ const sectionFrequency = new Map();
151
+ for (const pattern of patterns) {
152
+ for (const sectionName of pattern.structure.requiredSections) {
153
+ allSections.add(sectionName);
154
+ sectionFrequency.set(sectionName, (sectionFrequency.get(sectionName) || 0) + 1);
155
+ }
156
+ for (const sectionName of pattern.structure.optionalSections) {
157
+ allSections.add(sectionName);
158
+ sectionFrequency.set(sectionName, (sectionFrequency.get(sectionName) || 0) + 1);
159
+ }
160
+ }
161
+ // Required sections appear in >80% of patterns
162
+ const requiredSections = [];
163
+ const optionalSections = [];
164
+ const threshold = patterns.length * 0.8;
165
+ for (const section of allSections) {
166
+ const frequency = sectionFrequency.get(section) || 0;
167
+ if (frequency >= threshold) {
168
+ requiredSections.push(section);
169
+ }
170
+ else {
171
+ optionalSections.push(section);
172
+ }
173
+ }
174
+ // Determine section order (most common order)
175
+ const sectionOrder = this.determineSectionOrder(patterns);
176
+ // Extract common patterns from section content
177
+ const commonPatterns = this.extractCommonPatterns(patterns);
178
+ return {
179
+ requiredSections,
180
+ optionalSections,
181
+ sectionOrder,
182
+ commonPatterns
183
+ };
184
+ }
185
+ /**
186
+ * Detects pattern type from file path.
187
+ */
188
+ detectPatternType(filePath) {
189
+ const fileName = path.basename(filePath, path.extname(filePath)).toLowerCase();
190
+ const dirName = path.dirname(filePath).toLowerCase();
191
+ // Repository Pattern
192
+ if (fileName.includes('repository') || dirName.includes('repositories')) {
193
+ return 'Repository';
194
+ }
195
+ // API Layer Pattern
196
+ if (fileName.includes('api') || dirName.includes('/api/')) {
197
+ return 'API Layer';
198
+ }
199
+ // Service Layer Pattern
200
+ if (dirName.includes('/services/')) {
201
+ return 'Service Layer';
202
+ }
203
+ // Builder Pattern
204
+ if (fileName.includes('builder') || fileName.includes('build')) {
205
+ return 'Builder';
206
+ }
207
+ // Ingestor Pattern
208
+ if (fileName.includes('ingestor') || dirName.includes('ingestors')) {
209
+ return 'Ingestor';
210
+ }
211
+ // CLI Pattern
212
+ if (fileName.includes('cli') || dirName.includes('/cli/')) {
213
+ return 'CLI';
214
+ }
215
+ // Core Pattern
216
+ if (dirName.includes('/core/')) {
217
+ return 'Core';
218
+ }
219
+ // Default: Generic
220
+ return 'Generic';
221
+ }
222
+ /**
223
+ * Extracts sections from ADR markdown content.
224
+ */
225
+ extractSections(content) {
226
+ const sections = new Map();
227
+ const lines = content.split('\n');
228
+ let currentSection = null;
229
+ let currentContent = [];
230
+ for (const line of lines) {
231
+ // Check for section headers (## or ###)
232
+ const sectionMatch = line.match(/^##+\s+(.+)$/);
233
+ if (sectionMatch) {
234
+ // Save previous section
235
+ if (currentSection) {
236
+ sections.set(currentSection, currentContent.join('\n').trim());
237
+ }
238
+ // Start new section
239
+ currentSection = sectionMatch[1].trim();
240
+ currentContent = [];
241
+ }
242
+ else if (currentSection) {
243
+ currentContent.push(line);
244
+ }
245
+ }
246
+ // Save last section
247
+ if (currentSection) {
248
+ sections.set(currentSection, currentContent.join('\n').trim());
249
+ }
250
+ return sections;
251
+ }
252
+ /**
253
+ * Analyzes ADR structure from markdown content.
254
+ */
255
+ analyzeStructure(content) {
256
+ const sections = this.extractSections(content);
257
+ const sectionNames = Array.from(sections.keys());
258
+ // Common required sections
259
+ const commonRequired = ['Status', 'Kontext', 'Context', 'Entscheidung', 'Decision', 'Konsequenzen', 'Consequences'];
260
+ const requiredSections = sectionNames.filter(name => commonRequired.some(req => name.toLowerCase().includes(req.toLowerCase())));
261
+ // Optional sections are the rest
262
+ const optionalSections = sectionNames.filter(name => !requiredSections.includes(name));
263
+ // Section order is the order they appear in the document
264
+ const sectionOrder = sectionNames;
265
+ return {
266
+ requiredSections,
267
+ optionalSections,
268
+ sectionOrder,
269
+ commonPatterns: []
270
+ };
271
+ }
272
+ /**
273
+ * Determines the most common section order from patterns.
274
+ */
275
+ determineSectionOrder(patterns) {
276
+ if (patterns.length === 0) {
277
+ return ['Status', 'Kontext', 'Entscheidung', 'Konsequenzen'];
278
+ }
279
+ // Count section positions
280
+ const positionCounts = new Map();
281
+ for (const pattern of patterns) {
282
+ pattern.structure.sectionOrder.forEach((section, index) => {
283
+ if (!positionCounts.has(section)) {
284
+ positionCounts.set(section, new Map());
285
+ }
286
+ const counts = positionCounts.get(section);
287
+ counts.set(index, (counts.get(index) || 0) + 1);
288
+ });
289
+ }
290
+ // Find most common position for each section
291
+ const sectionPositions = new Map();
292
+ for (const [section, positions] of positionCounts.entries()) {
293
+ let maxCount = 0;
294
+ let bestPosition = 0;
295
+ for (const [position, count] of positions.entries()) {
296
+ if (count > maxCount) {
297
+ maxCount = count;
298
+ bestPosition = position;
299
+ }
300
+ }
301
+ sectionPositions.set(section, bestPosition);
302
+ }
303
+ // Sort sections by their most common position
304
+ const sortedSections = Array.from(sectionPositions.entries())
305
+ .sort((a, b) => a[1] - b[1])
306
+ .map(([section]) => section);
307
+ return sortedSections.length > 0 ? sortedSections : ['Status', 'Kontext', 'Entscheidung', 'Konsequenzen'];
308
+ }
309
+ /**
310
+ * Extracts common patterns from pattern content.
311
+ */
312
+ extractCommonPatterns(patterns) {
313
+ const commonPatterns = [];
314
+ // Analyze section content for common phrases
315
+ const phraseFrequency = new Map();
316
+ for (const pattern of patterns) {
317
+ for (const [sectionName, content] of pattern.sections.entries()) {
318
+ // Extract key phrases (simple heuristic: words in quotes or code blocks)
319
+ const phrases = content.match(/`([^`]+)`|"([^"]+)"/g) || [];
320
+ for (const phrase of phrases) {
321
+ const cleanPhrase = phrase.replace(/[`"]/g, '').trim();
322
+ if (cleanPhrase.length > 5) {
323
+ phraseFrequency.set(cleanPhrase, (phraseFrequency.get(cleanPhrase) || 0) + 1);
324
+ }
325
+ }
326
+ }
327
+ }
328
+ // Find phrases that appear in >50% of patterns
329
+ const threshold = patterns.length * 0.5;
330
+ for (const [phrase, count] of phraseFrequency.entries()) {
331
+ if (count >= threshold) {
332
+ commonPatterns.push(phrase);
333
+ }
334
+ }
335
+ return commonPatterns;
336
+ }
337
+ }
338
+ exports.AdrPatternAnalyzer = AdrPatternAnalyzer;
339
+ //# sourceMappingURL=adr-pattern-analyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adr-pattern-analyzer.js","sourceRoot":"","sources":["../../src/services/adr-pattern-analyzer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mEAA+D;AAC/D,yEAAqE;AAGrE,2CAA6B;AAgC7B;;;GAGG;AACH,MAAa,kBAAkB;IAG3B,YAAY,SAAyB;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,kBAAkB,CAAC,QAAgB;QAC5C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAEvD,MAAM,OAAO,GAAG,IAAI,8BAAa,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,UAAU,GAAG,IAAI,oCAAgB,CAAC,QAAQ,CAAC,CAAC;QAElD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAErD,MAAM,QAAQ,GAAiB,EAAE,CAAC;QAElC,iCAAiC;QACjC,KAAK,MAAM,GAAG,IAAI,OAAO,EA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AAM,cAAc,GAAa,EAAE,CAAC;QAEpC,6CAA6C;QAC7C,MAAM,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;QAElD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,KAAK,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC9D,yEAAyE;gBACzE,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC;gBAC5D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;oBAC3B,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;oBACvD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACzB,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBAClF,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QAED,+CAA+C;QAC/C,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC;QACxC,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;YACtD,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;gBACrB,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;QACL,CAAC;QAED,OAAO,cAAc,CAAC;IAC1B,CAAC;CACJ;AAxWD,gDAwWC"}
@@ -0,0 +1,63 @@
1
+ import { ModuleContext } from './adr-context-builder';
2
+ import { Adr } from '../models/adr';
3
+ import { ArchitecturalPattern } from './semantic-pattern-matcher';
4
+ /**
5
+ * ADR Reasoning result from LLM
6
+ */
7
+ export interface AdrReasoning {
8
+ problems: string[];
9
+ decision: string;
10
+ rationale: string;
11
+ alternatives: string[];
12
+ tradeoffs: {
13
+ positive: string[];
14
+ negative: string[];
15
+ };
16
+ refactoring_recommendations?: string[];
17
+ }
18
+ /**
19
+ * Service for reconstructing "Why" (rationale) from module context using LLM.
20
+ * Uses OpenAI API to generate structured reasoning about architectural decisions.
21
+ */
22
+ export declare class AdrReasoningService {
23
+ private openai;
24
+ private readonly defaultModel;
25
+ private readonly temperature;
26
+ constructor(apiKey?: string);
27
+ /**
28
+ * Checks if LLM is available.
29
+ */
30
+ isAvailable(): boolean;
31
+ /**
32
+ * Reconstructs complete reasoning (problems, decision, rationale, alternatives, trade-offs).
33
+ */
34
+ reconstructWhy(context: ModuleContext, similarAdrs: Adr[], patterns: ArchitecturalPattern[], complexity?: 'simple' | 'medium' | 'complex'): Promise<AdrReasoning>;
35
+ /**
36
+ * Reconstructs problems that this module solves.
37
+ */
38
+ reconstructProblems(context: ModuleContext, similarAdrs: Adr[]): Promise<string[]>;
39
+ /**
40
+ * Reconstructs decision with rationale.
41
+ */
42
+ reconstructDecision(context: ModuleContext, similarAdrs: Adr[], patterns: ArchitecturalPattern[]): Promise<{
43
+ decision: string;
44
+ rationale: string;
45
+ }>;
46
+ /**
47
+ * Reconstructs alternatives that were considered.
48
+ */
49
+ reconstructAlternatives(context: ModuleContext, similarAdrs: Adr[]): Promise<string[]>;
50
+ /**
51
+ * Builds structured prompt for reasoning.
52
+ */
53
+ private buildReasoningPrompt;
54
+ /**
55
+ * Parses module documentation markdown to extract structured information.
56
+ */
57
+ private parseModuleDocumentation;
58
+ /**
59
+ * Validates reasoning structure and checks for generic phrases.
60
+ */
61
+ private validateReasoning;
62
+ }
63
+ //# sourceMappingURL=adr-reasoning-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adr-reasoning-service.d.ts","sourceRoot":"","sources":["../../src/services/adr-reasoning-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MA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