@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.3

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 (120) hide show
  1. package/README.md +44 -54
  2. package/bin/cli.js +1 -115
  3. package/bin/loxia-terminal-v2.js +3 -0
  4. package/bin/loxia-terminal.js +3 -0
  5. package/bin/start-with-terminal.js +3 -0
  6. package/package.json +14 -15
  7. package/scripts/install-scanners.js +1 -235
  8. package/src/analyzers/CSSAnalyzer.js +1 -297
  9. package/src/analyzers/ConfigValidator.js +1 -690
  10. package/src/analyzers/ESLintAnalyzer.js +1 -320
  11. package/src/analyzers/JavaScriptAnalyzer.js +1 -261
  12. package/src/analyzers/PrettierFormatter.js +1 -247
  13. package/src/analyzers/PythonAnalyzer.js +1 -266
  14. package/src/analyzers/SecurityAnalyzer.js +1 -729
  15. package/src/analyzers/TypeScriptAnalyzer.js +1 -247
  16. package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
  17. package/src/analyzers/codeCloneDetector/detector.js +1 -203
  18. package/src/analyzers/codeCloneDetector/index.js +1 -160
  19. package/src/analyzers/codeCloneDetector/parser.js +1 -199
  20. package/src/analyzers/codeCloneDetector/reporter.js +1 -148
  21. package/src/analyzers/codeCloneDetector/scanner.js +1 -59
  22. package/src/core/agentPool.js +1 -1474
  23. package/src/core/agentScheduler.js +1 -2147
  24. package/src/core/contextManager.js +1 -709
  25. package/src/core/messageProcessor.js +1 -732
  26. package/src/core/orchestrator.js +1 -548
  27. package/src/core/stateManager.js +1 -877
  28. package/src/index.js +1 -631
  29. package/src/interfaces/cli.js +1 -549
  30. package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
  31. package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
  32. package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
  33. package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
  34. package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
  35. package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
  36. package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
  37. package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
  38. package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
  39. package/src/interfaces/terminal/api/apiClient.js +1 -0
  40. package/src/interfaces/terminal/api/messageRouter.js +1 -0
  41. package/src/interfaces/terminal/api/session.js +1 -0
  42. package/src/interfaces/terminal/api/websocket.js +1 -0
  43. package/src/interfaces/terminal/components/AgentCreator.js +1 -0
  44. package/src/interfaces/terminal/components/AgentEditor.js +1 -0
  45. package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
  46. package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
  47. package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
  48. package/src/interfaces/terminal/components/Header.js +1 -0
  49. package/src/interfaces/terminal/components/HelpPanel.js +1 -0
  50. package/src/interfaces/terminal/components/InputBox.js +1 -0
  51. package/src/interfaces/terminal/components/Layout.js +1 -0
  52. package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
  53. package/src/interfaces/terminal/components/MessageList.js +1 -0
  54. package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
  55. package/src/interfaces/terminal/components/SearchPanel.js +1 -0
  56. package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
  57. package/src/interfaces/terminal/components/StatusBar.js +1 -0
  58. package/src/interfaces/terminal/components/TextInput.js +1 -0
  59. package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
  60. package/src/interfaces/terminal/config/constants.js +1 -0
  61. package/src/interfaces/terminal/index.js +1 -0
  62. package/src/interfaces/terminal/state/useAgentControl.js +1 -0
  63. package/src/interfaces/terminal/state/useAgents.js +1 -0
  64. package/src/interfaces/terminal/state/useConnection.js +1 -0
  65. package/src/interfaces/terminal/state/useMessages.js +1 -0
  66. package/src/interfaces/terminal/state/useTools.js +1 -0
  67. package/src/interfaces/terminal/utils/debugLogger.js +1 -0
  68. package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
  69. package/src/interfaces/terminal/utils/theme.js +1 -0
  70. package/src/interfaces/webServer.js +1 -2162
  71. package/src/modules/fileExplorer/controller.js +1 -280
  72. package/src/modules/fileExplorer/index.js +1 -37
  73. package/src/modules/fileExplorer/middleware.js +1 -92
  74. package/src/modules/fileExplorer/routes.js +1 -125
  75. package/src/modules/fileExplorer/types.js +1 -44
  76. package/src/services/aiService.js +1 -1232
  77. package/src/services/apiKeyManager.js +1 -164
  78. package/src/services/benchmarkService.js +1 -366
  79. package/src/services/budgetService.js +1 -539
  80. package/src/services/contextInjectionService.js +1 -247
  81. package/src/services/conversationCompactionService.js +1 -637
  82. package/src/services/errorHandler.js +1 -810
  83. package/src/services/fileAttachmentService.js +1 -544
  84. package/src/services/modelRouterService.js +1 -366
  85. package/src/services/modelsService.js +1 -322
  86. package/src/services/qualityInspector.js +1 -796
  87. package/src/services/tokenCountingService.js +1 -536
  88. package/src/tools/agentCommunicationTool.js +1 -1344
  89. package/src/tools/agentDelayTool.js +1 -485
  90. package/src/tools/asyncToolManager.js +1 -604
  91. package/src/tools/baseTool.js +1 -800
  92. package/src/tools/browserTool.js +1 -920
  93. package/src/tools/cloneDetectionTool.js +1 -621
  94. package/src/tools/dependencyResolverTool.js +1 -1215
  95. package/src/tools/fileContentReplaceTool.js +1 -875
  96. package/src/tools/fileSystemTool.js +1 -1107
  97. package/src/tools/fileTreeTool.js +1 -853
  98. package/src/tools/imageTool.js +1 -901
  99. package/src/tools/importAnalyzerTool.js +1 -1060
  100. package/src/tools/jobDoneTool.js +1 -248
  101. package/src/tools/seekTool.js +1 -956
  102. package/src/tools/staticAnalysisTool.js +1 -1778
  103. package/src/tools/taskManagerTool.js +1 -2873
  104. package/src/tools/terminalTool.js +1 -2304
  105. package/src/tools/webTool.js +1 -1430
  106. package/src/types/agent.js +1 -519
  107. package/src/types/contextReference.js +1 -972
  108. package/src/types/conversation.js +1 -730
  109. package/src/types/toolCommand.js +1 -747
  110. package/src/utilities/attachmentValidator.js +1 -292
  111. package/src/utilities/configManager.js +1 -582
  112. package/src/utilities/constants.js +1 -722
  113. package/src/utilities/directoryAccessManager.js +1 -535
  114. package/src/utilities/fileProcessor.js +1 -307
  115. package/src/utilities/logger.js +1 -436
  116. package/src/utilities/tagParser.js +1 -1246
  117. package/src/utilities/toolConstants.js +1 -317
  118. package/web-ui/build/index.html +2 -2
  119. package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
  120. package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
@@ -1,709 +1 @@
1
- /**
2
- * ContextManager - Handles context reference processing and file context integration
3
- *
4
- * Purpose:
5
- * - Process context references (files, components, selections)
6
- * - Load and validate file content
7
- * - Generate context prompts for AI models
8
- * - Manage context size limits
9
- * - Handle context reference caching
10
- */
11
-
12
- import { promises as fs } from 'fs';
13
- import path from 'path';
14
- import crypto from 'crypto';
15
-
16
- class ContextManager {
17
- constructor(config, logger) {
18
- this.config = config;
19
- this.logger = logger;
20
-
21
- this.maxContextSize = config.context?.maxSize || 50000; // characters
22
- this.maxReferences = config.context?.maxReferences || 10;
23
- this.autoValidation = config.context?.autoValidation || true;
24
- this.cacheExpiry = config.context?.cacheExpiry || 3600; // seconds
25
-
26
- // Context cache
27
- this.contextCache = new Map();
28
-
29
- // File watchers for context validation
30
- this.fileWatchers = new Map();
31
- }
32
-
33
- /**
34
- * Process message with context references
35
- * @param {Object} message - Message object with contextReferences
36
- * @param {string} projectDir - Project directory path
37
- * @returns {Promise<Object>} Enhanced message with context
38
- */
39
- async processMessageWithContext(message, projectDir) {
40
- if (!message.contextReferences || message.contextReferences.length === 0) {
41
- return message;
42
- }
43
-
44
- try {
45
- // Load and process context references
46
- const processedReferences = await this.loadContextReferences(
47
- message.contextReferences,
48
- projectDir
49
- );
50
-
51
- // Generate context prompt
52
- const contextPrompt = this.generateContextPrompt(processedReferences);
53
-
54
- // Combine context with original message
55
- const enhancedMessage = {
56
- ...message,
57
- content: contextPrompt + '\n\n' + message.content,
58
- originalContent: message.content,
59
- processedContextReferences: processedReferences,
60
- contextSize: contextPrompt.length
61
- };
62
-
63
- this.logger.info('Message enhanced with context', {
64
- originalLength: message.content.length,
65
- contextSize: contextPrompt.length,
66
- referencesCount: processedReferences.length,
67
- totalSize: enhancedMessage.content.length
68
- });
69
-
70
- return enhancedMessage;
71
-
72
- } catch (error) {
73
- this.logger.error(`Context processing failed: ${error.message}`, {
74
- referencesCount: message.contextReferences.length,
75
- error: error.stack
76
- });
77
-
78
- // Return original message with error info
79
- return {
80
- ...message,
81
- contextProcessingError: error.message,
82
- processedContextReferences: []
83
- };
84
- }
85
- }
86
-
87
- /**
88
- * Load and validate context references
89
- * @param {Array} references - Array of context reference objects
90
- * @param {string} projectDir - Project directory path
91
- * @returns {Promise<Array>} Array of processed context references
92
- */
93
- async loadContextReferences(references, projectDir) {
94
- const loaded = [];
95
- let totalSize = 0;
96
-
97
- // Sort references by priority (file > component > selection)
98
- const sortedReferences = this.sortReferencesByPriority(references);
99
-
100
- for (const ref of sortedReferences.slice(0, this.maxReferences)) {
101
- try {
102
- const cacheKey = this.generateCacheKey(ref, projectDir);
103
-
104
- // Check cache first
105
- let loadedRef = this.getFromCache(cacheKey);
106
-
107
- if (!loadedRef || this.shouldRefreshCache(loadedRef)) {
108
- loadedRef = await this.loadSingleReference(ref, projectDir);
109
- this.addToCache(cacheKey, loadedRef);
110
- }
111
-
112
- // Check size limits
113
- if (totalSize + loadedRef.content.length > this.maxContextSize) {
114
- loadedRef.content = loadedRef.content.substring(
115
- 0,
116
- this.maxContextSize - totalSize
117
- ) + '\n... [context truncated due to size limit]';
118
- loadedRef.truncated = true;
119
- }
120
-
121
- loaded.push(loadedRef);
122
- totalSize += loadedRef.content.length;
123
-
124
- if (totalSize >= this.maxContextSize) {
125
- this.logger.warn('Context size limit reached, stopping reference loading');
126
- break;
127
- }
128
-
129
- } catch (error) {
130
- this.logger.warn(`Failed to load context reference: ${error.message}`, {
131
- referenceType: ref.type,
132
- referencePath: ref.path || ref.name
133
- });
134
-
135
- loaded.push({
136
- ...ref,
137
- error: error.message,
138
- content: `[Error loading reference: ${error.message}]`,
139
- exists: false
140
- });
141
- }
142
- }
143
-
144
- return loaded;
145
- }
146
-
147
- /**
148
- * Load a single context reference
149
- * @param {Object} ref - Context reference object
150
- * @param {string} projectDir - Project directory path
151
- * @returns {Promise<Object>} Processed reference object
152
- */
153
- async loadSingleReference(ref, projectDir) {
154
- const startTime = Date.now();
155
-
156
- try {
157
- switch (ref.type) {
158
- case 'file':
159
- return await this.loadFileReference(ref, projectDir);
160
-
161
- case 'component':
162
- return await this.loadComponentReference(ref, projectDir);
163
-
164
- case 'selection':
165
- return await this.loadSelectionReference(ref, projectDir);
166
-
167
- case 'directory':
168
- return await this.loadDirectoryReference(ref, projectDir);
169
-
170
- default:
171
- throw new Error(`Unknown reference type: ${ref.type}`);
172
- }
173
-
174
- } finally {
175
- const loadTime = Date.now() - startTime;
176
- this.logger.debug(`Reference loaded in ${loadTime}ms`, {
177
- type: ref.type,
178
- path: ref.path || ref.name
179
- });
180
- }
181
- }
182
-
183
- /**
184
- * Load file reference
185
- * @private
186
- */
187
- async loadFileReference(ref, projectDir) {
188
- const fullPath = path.resolve(projectDir, ref.path);
189
-
190
- // Check file exists and get stats
191
- let stats;
192
- try {
193
- stats = await fs.stat(fullPath);
194
- if (!stats.isFile()) {
195
- throw new Error('Path is not a file');
196
- }
197
- } catch {
198
- throw new Error('File not found');
199
- }
200
-
201
- // Read file content
202
- let content = await fs.readFile(fullPath, 'utf8');
203
-
204
- // Apply line range if specified
205
- if (ref.lines && ref.lines.length > 0) {
206
- const lines = content.split('\n');
207
- const startLine = Math.max(0, (ref.lines[0] || 1) - 1);
208
- const endLine = Math.min(lines.length, ref.lines[1] || ref.lines[0] || lines.length);
209
-
210
- content = lines.slice(startLine, endLine).join('\n');
211
- }
212
-
213
- // Calculate checksum for change detection
214
- const checksum = this.calculateChecksum(content);
215
-
216
- return {
217
- ...ref,
218
- content,
219
- exists: true,
220
- lastModified: stats.mtime.toISOString(),
221
- fileSize: stats.size,
222
- checksum,
223
- hasChanged: ref.checksum && ref.checksum !== checksum,
224
- loadedAt: new Date().toISOString()
225
- };
226
- }
227
-
228
- /**
229
- * Load component reference
230
- * @private
231
- */
232
- async loadComponentReference(ref, projectDir) {
233
- const fullPath = path.resolve(projectDir, ref.file);
234
-
235
- try {
236
- const fileContent = await fs.readFile(fullPath, 'utf8');
237
- const componentInfo = await this.extractComponent(fileContent, ref.name, ref.startLine, ref.endLine);
238
-
239
- return {
240
- ...ref,
241
- content: componentInfo.content,
242
- exists: true,
243
- signature: componentInfo.signature,
244
- dependencies: componentInfo.dependencies,
245
- actualStartLine: componentInfo.startLine,
246
- actualEndLine: componentInfo.endLine,
247
- loadedAt: new Date().toISOString()
248
- };
249
-
250
- } catch (error) {
251
- throw new Error(`Component extraction failed: ${error.message}`);
252
- }
253
- }
254
-
255
- /**
256
- * Load selection reference
257
- * @private
258
- */
259
- async loadSelectionReference(ref, projectDir) {
260
- // Selection content is provided by user, validate against file if possible
261
- if (ref.file) {
262
- const fullPath = path.resolve(projectDir, ref.file);
263
-
264
- try {
265
- const fileContent = await fs.readFile(fullPath, 'utf8');
266
- const lines = fileContent.split('\n');
267
-
268
- if (ref.lines && ref.lines.length >= 2) {
269
- const startLine = Math.max(0, ref.lines[0] - 1);
270
- const endLine = Math.min(lines.length, ref.lines[1]);
271
- const fileSelection = lines.slice(startLine, endLine).join('\n');
272
-
273
- const selectionValid = this.compareSelections(ref.content, fileSelection);
274
-
275
- return {
276
- ...ref,
277
- exists: true,
278
- validated: selectionValid,
279
- currentFileContent: selectionValid ? null : fileSelection,
280
- loadedAt: new Date().toISOString()
281
- };
282
- }
283
- } catch {
284
- // File validation failed, use provided content
285
- }
286
- }
287
-
288
- return {
289
- ...ref,
290
- exists: true,
291
- validated: false,
292
- loadedAt: new Date().toISOString()
293
- };
294
- }
295
-
296
- /**
297
- * Load directory reference
298
- * @private
299
- */
300
- async loadDirectoryReference(ref, projectDir) {
301
- const fullPath = path.resolve(projectDir, ref.path);
302
-
303
- try {
304
- const stats = await fs.stat(fullPath);
305
- if (!stats.isDirectory()) {
306
- throw new Error('Path is not a directory');
307
- }
308
-
309
- const files = await fs.readdir(fullPath, { withFileTypes: true });
310
- const structure = files.map(file => ({
311
- name: file.name,
312
- type: file.isDirectory() ? 'directory' : 'file',
313
- isSymbolicLink: file.isSymbolicLink()
314
- }));
315
-
316
- // Generate directory listing content
317
- const content = this.generateDirectoryListing(ref.path, structure);
318
-
319
- return {
320
- ...ref,
321
- content,
322
- exists: true,
323
- structure,
324
- fileCount: files.filter(f => f.isFile()).length,
325
- directoryCount: files.filter(f => f.isDirectory()).length,
326
- loadedAt: new Date().toISOString()
327
- };
328
-
329
- } catch (error) {
330
- throw new Error(`Directory reading failed: ${error.message}`);
331
- }
332
- }
333
-
334
- /**
335
- * Generate context prompt from processed references
336
- * @param {Array} references - Array of processed context references
337
- * @returns {string} Generated context prompt
338
- */
339
- generateContextPrompt(references) {
340
- if (!references.length) return '';
341
-
342
- let prompt = '\n=== PROJECT CONTEXT REFERENCES ===\n';
343
-
344
- for (const ref of references) {
345
- if (ref.error) {
346
- prompt += `❌ ${ref.type.toUpperCase()}: ${ref.path || ref.name}\n`;
347
- prompt += ` Error: ${ref.error}\n\n`;
348
- continue;
349
- }
350
-
351
- const icon = this.getContextIcon(ref.type);
352
- prompt += `${icon} ${ref.type.toUpperCase()}: ${ref.path || ref.name}\n`;
353
-
354
- // Add metadata
355
- if (ref.lines && ref.lines.length > 0) {
356
- const lineRange = ref.lines.length === 1
357
- ? `Line ${ref.lines[0]}`
358
- : `Lines ${ref.lines[0]}-${ref.lines[1]}`;
359
- prompt += ` ${lineRange}\n`;
360
- }
361
-
362
- if (ref.description) {
363
- prompt += ` Description: ${ref.description}\n`;
364
- }
365
-
366
- if (ref.hasChanged) {
367
- prompt += ` ⚠️ File has changed since reference was created\n`;
368
- }
369
-
370
- if (ref.truncated) {
371
- prompt += ` ⚠️ Content truncated due to size limits\n`;
372
- }
373
-
374
- // Add content with appropriate syntax highlighting
375
- const language = this.getLanguageFromPath(ref.path || ref.file);
376
- prompt += `\n\`\`\`${language}\n`;
377
- prompt += ref.content;
378
- prompt += '\n```\n\n';
379
- }
380
-
381
- prompt += '=== END CONTEXT REFERENCES ===\n';
382
- return prompt;
383
- }
384
-
385
- /**
386
- * Extract component from file content
387
- * @private
388
- */
389
- async extractComponent(fileContent, componentName, startLine, endLine) {
390
- const lines = fileContent.split('\n');
391
-
392
- if (startLine && endLine) {
393
- // Use provided line range
394
- const content = lines.slice(startLine - 1, endLine).join('\n');
395
- return {
396
- content,
397
- startLine,
398
- endLine,
399
- signature: this.extractSignature(content, componentName),
400
- dependencies: this.extractDependencies(content)
401
- };
402
- }
403
-
404
- // Search for component by name
405
- const componentRegex = new RegExp(
406
- `(class\\s+${componentName}|function\\s+${componentName}|const\\s+${componentName}|export.*${componentName})`,
407
- 'i'
408
- );
409
-
410
- let foundStartLine = -1;
411
- let foundEndLine = -1;
412
- let braceCount = 0;
413
- let inComponent = false;
414
-
415
- for (let i = 0; i < lines.length; i++) {
416
- const line = lines[i];
417
-
418
- if (!inComponent && componentRegex.test(line)) {
419
- foundStartLine = i + 1;
420
- inComponent = true;
421
-
422
- // Count opening braces in this line
423
- braceCount += (line.match(/\{/g) || []).length;
424
- braceCount -= (line.match(/\}/g) || []).length;
425
-
426
- if (braceCount === 0 && line.includes(';')) {
427
- // Single line declaration
428
- foundEndLine = i + 1;
429
- break;
430
- }
431
-
432
- continue;
433
- }
434
-
435
- if (inComponent) {
436
- braceCount += (line.match(/\{/g) || []).length;
437
- braceCount -= (line.match(/\}/g) || []).length;
438
-
439
- if (braceCount <= 0) {
440
- foundEndLine = i + 1;
441
- break;
442
- }
443
- }
444
- }
445
-
446
- if (foundStartLine === -1) {
447
- throw new Error(`Component '${componentName}' not found in file`);
448
- }
449
-
450
- const content = lines.slice(foundStartLine - 1, foundEndLine).join('\n');
451
-
452
- return {
453
- content,
454
- startLine: foundStartLine,
455
- endLine: foundEndLine,
456
- signature: this.extractSignature(content, componentName),
457
- dependencies: this.extractDependencies(content)
458
- };
459
- }
460
-
461
- /**
462
- * Extract function/class signature
463
- * @private
464
- */
465
- extractSignature(content, name) {
466
- const lines = content.split('\n');
467
- const firstLine = lines[0].trim();
468
-
469
- // Try to extract a meaningful signature
470
- const signatureRegex = new RegExp(`(.*${name}[^{;]*)[{;]?`);
471
- const match = firstLine.match(signatureRegex);
472
-
473
- return match ? match[1].trim() : firstLine;
474
- }
475
-
476
- /**
477
- * Extract dependencies from content
478
- * @private
479
- */
480
- extractDependencies(content) {
481
- const dependencies = [];
482
-
483
- // Extract import statements
484
- const importRegex = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
485
- let match;
486
- while ((match = importRegex.exec(content)) !== null) {
487
- dependencies.push(match[1]);
488
- }
489
-
490
- // Extract require statements
491
- const requireRegex = /require\(['"]([^'"]+)['"]\)/g;
492
- while ((match = requireRegex.exec(content)) !== null) {
493
- dependencies.push(match[1]);
494
- }
495
-
496
- return [...new Set(dependencies)]; // Remove duplicates
497
- }
498
-
499
- /**
500
- * Generate directory listing content
501
- * @private
502
- */
503
- generateDirectoryListing(dirPath, structure) {
504
- let content = `Directory: ${dirPath}\n\n`;
505
-
506
- const directories = structure.filter(item => item.type === 'directory');
507
- const files = structure.filter(item => item.type === 'file');
508
-
509
- if (directories.length > 0) {
510
- content += 'Directories:\n';
511
- for (const dir of directories) {
512
- content += ` 📁 ${dir.name}${dir.isSymbolicLink ? ' (symlink)' : ''}\n`;
513
- }
514
- content += '\n';
515
- }
516
-
517
- if (files.length > 0) {
518
- content += 'Files:\n';
519
- for (const file of files) {
520
- const icon = this.getFileIcon(file.name);
521
- content += ` ${icon} ${file.name}${file.isSymbolicLink ? ' (symlink)' : ''}\n`;
522
- }
523
- }
524
-
525
- if (structure.length === 0) {
526
- content += '(empty directory)\n';
527
- }
528
-
529
- return content;
530
- }
531
-
532
- /**
533
- * Sort references by priority
534
- * @private
535
- */
536
- sortReferencesByPriority(references) {
537
- const priorityOrder = { file: 1, component: 2, selection: 3, directory: 4 };
538
-
539
- return [...references].sort((a, b) => {
540
- const aPriority = priorityOrder[a.type] || 999;
541
- const bPriority = priorityOrder[b.type] || 999;
542
- return aPriority - bPriority;
543
- });
544
- }
545
-
546
- /**
547
- * Get context icon for reference type
548
- * @private
549
- */
550
- getContextIcon(type) {
551
- const icons = {
552
- file: '📄',
553
- component: '🔧',
554
- selection: '✂️',
555
- directory: '📁'
556
- };
557
- return icons[type] || '📎';
558
- }
559
-
560
- /**
561
- * Get file icon based on extension
562
- * @private
563
- */
564
- getFileIcon(filename) {
565
- const ext = path.extname(filename).toLowerCase();
566
- const icons = {
567
- '.js': '📜',
568
- '.jsx': '⚛️',
569
- '.ts': '📘',
570
- '.tsx': '⚛️',
571
- '.py': '🐍',
572
- '.java': '☕',
573
- '.html': '🌐',
574
- '.css': '🎨',
575
- '.json': '📋',
576
- '.md': '📝',
577
- '.yml': '⚙️',
578
- '.yaml': '⚙️'
579
- };
580
- return icons[ext] || '📄';
581
- }
582
-
583
- /**
584
- * Get language identifier from file path
585
- * @private
586
- */
587
- getLanguageFromPath(filePath) {
588
- if (!filePath) return '';
589
-
590
- const ext = path.extname(filePath).toLowerCase();
591
- const langMap = {
592
- '.js': 'javascript',
593
- '.jsx': 'jsx',
594
- '.ts': 'typescript',
595
- '.tsx': 'tsx',
596
- '.py': 'python',
597
- '.java': 'java',
598
- '.cpp': 'cpp',
599
- '.c': 'c',
600
- '.cs': 'csharp',
601
- '.php': 'php',
602
- '.rb': 'ruby',
603
- '.go': 'go',
604
- '.rs': 'rust',
605
- '.html': 'html',
606
- '.css': 'css',
607
- '.scss': 'scss',
608
- '.json': 'json',
609
- '.yml': 'yaml',
610
- '.yaml': 'yaml',
611
- '.md': 'markdown',
612
- '.xml': 'xml',
613
- '.sql': 'sql'
614
- };
615
-
616
- return langMap[ext] || '';
617
- }
618
-
619
- /**
620
- * Calculate content checksum
621
- * @private
622
- */
623
- calculateChecksum(content) {
624
- return crypto.createHash('sha256').update(content).digest('hex').substring(0, 16);
625
- }
626
-
627
- /**
628
- * Compare two code selections
629
- * @private
630
- */
631
- compareSelections(selection1, selection2) {
632
- // Normalize whitespace and compare
633
- const normalize = str => str.replace(/\s+/g, ' ').trim();
634
- return normalize(selection1) === normalize(selection2);
635
- }
636
-
637
- /**
638
- * Generate cache key for reference
639
- * @private
640
- */
641
- generateCacheKey(ref, projectDir) {
642
- const keyData = {
643
- type: ref.type,
644
- path: ref.path || ref.file,
645
- lines: ref.lines,
646
- name: ref.name,
647
- projectDir
648
- };
649
-
650
- return crypto.createHash('md5').update(JSON.stringify(keyData)).digest('hex');
651
- }
652
-
653
- /**
654
- * Get reference from cache
655
- * @private
656
- */
657
- getFromCache(cacheKey) {
658
- const cached = this.contextCache.get(cacheKey);
659
- if (!cached) return null;
660
-
661
- return cached.data;
662
- }
663
-
664
- /**
665
- * Add reference to cache
666
- * @private
667
- */
668
- addToCache(cacheKey, data) {
669
- this.contextCache.set(cacheKey, {
670
- data,
671
- timestamp: Date.now()
672
- });
673
-
674
- // Clean up old cache entries
675
- this.cleanupCache();
676
- }
677
-
678
- /**
679
- * Check if cached reference should be refreshed
680
- * @private
681
- */
682
- shouldRefreshCache(cachedRef) {
683
- if (!this.autoValidation) return false;
684
-
685
- const age = (Date.now() - new Date(cachedRef.loadedAt).getTime()) / 1000;
686
- return age > this.cacheExpiry;
687
- }
688
-
689
- /**
690
- * Clean up expired cache entries
691
- * @private
692
- */
693
- cleanupCache() {
694
- const now = Date.now();
695
- const expiredKeys = [];
696
-
697
- for (const [key, cached] of this.contextCache.entries()) {
698
- if (now - cached.timestamp > this.cacheExpiry * 1000) {
699
- expiredKeys.push(key);
700
- }
701
- }
702
-
703
- for (const key of expiredKeys) {
704
- this.contextCache.delete(key);
705
- }
706
- }
707
- }
708
-
709
- export default ContextManager;
1
+ const a0_0x3f7832=a0_0x3d02;(function(_0x4fb8b9,_0x3c9c8b){const _0x568891=a0_0x3d02,_0x4e0766=_0x4fb8b9();while(!![]){try{const _0x254811=-parseInt(_0x568891(0x1ae))/0x1+-parseInt(_0x568891(0x15e))/0x2*(parseInt(_0x568891(0x168))/0x3)+-parseInt(_0x568891(0x18e))/0x4+-parseInt(_0x568891(0x170))/0x5*(-parseInt(_0x568891(0x19d))/0x6)+parseInt(_0x568891(0x173))/0x7+parseInt(_0x568891(0x16d))/0x8*(parseInt(_0x568891(0x13b))/0x9)+-parseInt(_0x568891(0x156))/0xa;if(_0x254811===_0x3c9c8b)break;else _0x4e0766['push'](_0x4e0766['shift']());}catch(_0x426e27){_0x4e0766['push'](_0x4e0766['shift']());}}}(a0_0x3952,0x7caa8));import{promises as a0_0x57333b}from'fs';import a0_0x4f216a from'path';import a0_0x4efa92 from'crypto';function a0_0x3d02(_0x533065,_0x531cd5){_0x533065=_0x533065-0x13b;const _0x39529b=a0_0x3952();let _0x3d026a=_0x39529b[_0x533065];if(a0_0x3d02['mbBwah']===undefined){var _0x47f43a=function(_0x499e87){const _0x53d6a5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x57333b='',_0x4f216a='';for(let _0x4efa92=0x0,_0x203ec2,_0x200fed,_0x191979=0x0;_0x200fed=_0x499e87['charAt'](_0x191979++);~_0x200fed&&(_0x203ec2=_0x4efa92%0x4?_0x203ec2*0x40+_0x200fed:_0x200fed,_0x4efa92++%0x4)?_0x57333b+=String['fromCharCode'](0xff&_0x203ec2>>(-0x2*_0x4efa92&0x6)):0x0){_0x200fed=_0x53d6a5['indexOf'](_0x200fed);}for(let _0x4648bc=0x0,_0x4c3056=_0x57333b['length'];_0x4648bc<_0x4c3056;_0x4648bc++){_0x4f216a+='%'+('00'+_0x57333b['charCodeAt'](_0x4648bc)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4f216a);};a0_0x3d02['onVZpj']=_0x47f43a,a0_0x3d02['cRetjB']={},a0_0x3d02['mbBwah']=!![];}const _0x2606fa=_0x39529b[0x0],_0x44593a=_0x533065+_0x2606fa,_0x163ea0=a0_0x3d02['cRetjB'][_0x44593a];return!_0x163ea0?(_0x3d026a=a0_0x3d02['onVZpj'](_0x3d026a),a0_0x3d02['cRetjB'][_0x44593a]=_0x3d026a):_0x3d026a=_0x163ea0,_0x3d026a;}class ContextManager{constructor(_0x203ec2,_0x200fed){const _0x14776f=a0_0x3d02;this[_0x14776f(0x13c)]=_0x203ec2,this[_0x14776f(0x181)]=_0x200fed,this[_0x14776f(0x195)]=_0x203ec2['context']?.[_0x14776f(0x154)]||0xc350,this['maxReferences']=_0x203ec2['context']?.['maxReferences']||0xa,this['autoValidation']=_0x203ec2['context']?.['autoValidation']||!![],this['cacheExpiry']=_0x203ec2['context']?.[_0x14776f(0x1a5)]||0xe10,this['contextCache']=new Map(),this[_0x14776f(0x17c)]=new Map();}async[a0_0x3f7832(0x188)](_0x191979,_0x4648bc){const _0x359d1d=a0_0x3f7832;if(!_0x191979['contextReferences']||_0x191979['contextReferences'][_0x359d1d(0x16b)]===0x0)return _0x191979;try{const processedReferences=await this[_0x359d1d(0x166)](_0x191979['contextReferences'],_0x4648bc),_0x4c3056=this['generateContextPrompt'](processedReferences),_0x326d00={..._0x191979,'content':_0x4c3056+'\x0a\x0a'+_0x191979[_0x359d1d(0x19a)],'originalContent':_0x191979[_0x359d1d(0x19a)],'processedContextReferences':processedReferences,'contextSize':_0x4c3056[_0x359d1d(0x16b)]};return this['logger'][_0x359d1d(0x15d)]('Message\x20enhanced\x20with\x20context',{'originalLength':_0x191979['content'][_0x359d1d(0x16b)],'contextSize':_0x4c3056['length'],'referencesCount':processedReferences['length'],'totalSize':_0x326d00['content'][_0x359d1d(0x16b)]}),_0x326d00;}catch(_0x3c5835){return this['logger']['error'](_0x359d1d(0x17b)+_0x3c5835['message'],{'referencesCount':_0x191979[_0x359d1d(0x1a2)][_0x359d1d(0x16b)],'error':_0x3c5835[_0x359d1d(0x1a7)]}),{..._0x191979,'contextProcessingError':_0x3c5835['message'],'processedContextReferences':[]};}}async[a0_0x3f7832(0x166)](_0x3771d5,_0x26274c){const _0x4017a2=a0_0x3f7832,_0x2af6ea=[];let _0x2bd102=0x0;const _0x125974=this[_0x4017a2(0x142)](_0x3771d5);for(const _0x3700aa of _0x125974['slice'](0x0,this[_0x4017a2(0x147)])){try{const _0x134f2b=this['generateCacheKey'](_0x3700aa,_0x26274c);let _0x2c5650=this['getFromCache'](_0x134f2b);(!_0x2c5650||this[_0x4017a2(0x141)](_0x2c5650))&&(_0x2c5650=await this[_0x4017a2(0x16f)](_0x3700aa,_0x26274c),this['addToCache'](_0x134f2b,_0x2c5650));_0x2bd102+_0x2c5650['content'][_0x4017a2(0x16b)]>this['maxContextSize']&&(_0x2c5650[_0x4017a2(0x19a)]=_0x2c5650['content'][_0x4017a2(0x16a)](0x0,this[_0x4017a2(0x195)]-_0x2bd102)+'\x0a...\x20[context\x20truncated\x20due\x20to\x20size\x20limit]',_0x2c5650['truncated']=!![]);_0x2af6ea[_0x4017a2(0x14c)](_0x2c5650),_0x2bd102+=_0x2c5650['content'][_0x4017a2(0x16b)];if(_0x2bd102>=this[_0x4017a2(0x195)]){this['logger']['warn'](_0x4017a2(0x183));break;}}catch(_0x17156c){this['logger']['warn'](_0x4017a2(0x143)+_0x17156c[_0x4017a2(0x160)],{'referenceType':_0x3700aa[_0x4017a2(0x153)],'referencePath':_0x3700aa['path']||_0x3700aa[_0x4017a2(0x1ab)]}),_0x2af6ea['push']({..._0x3700aa,'error':_0x17156c['message'],'content':'[Error\x20loading\x20reference:\x20'+_0x17156c['message']+']','exists':![]});}}return _0x2af6ea;}async[a0_0x3f7832(0x16f)](_0x3ca3b6,_0x40a7cb){const _0x4cd66a=a0_0x3f7832,_0x29e16b=Date[_0x4cd66a(0x18b)]();try{switch(_0x3ca3b6[_0x4cd66a(0x153)]){case'file':return await this['loadFileReference'](_0x3ca3b6,_0x40a7cb);case'component':return await this[_0x4cd66a(0x14e)](_0x3ca3b6,_0x40a7cb);case'selection':return await this['loadSelectionReference'](_0x3ca3b6,_0x40a7cb);case'directory':return await this[_0x4cd66a(0x18c)](_0x3ca3b6,_0x40a7cb);default:throw new Error('Unknown\x20reference\x20type:\x20'+_0x3ca3b6[_0x4cd66a(0x153)]);}}finally{const _0x1a774b=Date[_0x4cd66a(0x18b)]()-_0x29e16b;this[_0x4cd66a(0x181)]['debug'](_0x4cd66a(0x13f)+_0x1a774b+'ms',{'type':_0x3ca3b6[_0x4cd66a(0x153)],'path':_0x3ca3b6[_0x4cd66a(0x18f)]||_0x3ca3b6['name']});}}async[a0_0x3f7832(0x189)](_0x4a222e,_0x127666){const _0x1edfb6=a0_0x3f7832,_0x58293e=a0_0x4f216a['resolve'](_0x127666,_0x4a222e['path']);let _0x59f744;try{_0x59f744=await a0_0x57333b['stat'](_0x58293e);if(!_0x59f744[_0x1edfb6(0x159)]())throw new Error(_0x1edfb6(0x164));}catch{throw new Error(_0x1edfb6(0x14d));}let _0x1416f8=await a0_0x57333b[_0x1edfb6(0x199)](_0x58293e,_0x1edfb6(0x17e));if(_0x4a222e['lines']&&_0x4a222e[_0x1edfb6(0x1ac)][_0x1edfb6(0x16b)]>0x0){const _0x478be6=_0x1416f8['split']('\x0a'),_0x8756f9=Math['max'](0x0,(_0x4a222e['lines'][0x0]||0x1)-0x1),_0x3999d6=Math[_0x1edfb6(0x150)](_0x478be6['length'],_0x4a222e['lines'][0x1]||_0x4a222e['lines'][0x0]||_0x478be6['length']);_0x1416f8=_0x478be6[_0x1edfb6(0x1ad)](_0x8756f9,_0x3999d6)['join']('\x0a');}const _0xe4d9d1=this['calculateChecksum'](_0x1416f8);return{..._0x4a222e,'content':_0x1416f8,'exists':!![],'lastModified':_0x59f744['mtime'][_0x1edfb6(0x1a0)](),'fileSize':_0x59f744['size'],'checksum':_0xe4d9d1,'hasChanged':_0x4a222e[_0x1edfb6(0x146)]&&_0x4a222e[_0x1edfb6(0x146)]!==_0xe4d9d1,'loadedAt':new Date()['toISOString']()};}async[a0_0x3f7832(0x14e)](_0x591e86,_0x257dfe){const _0x194345=a0_0x3f7832,_0x65ae0f=a0_0x4f216a[_0x194345(0x14b)](_0x257dfe,_0x591e86['file']);try{const _0x475ed2=await a0_0x57333b[_0x194345(0x199)](_0x65ae0f,_0x194345(0x17e)),_0x488ee2=await this['extractComponent'](_0x475ed2,_0x591e86['name'],_0x591e86['startLine'],_0x591e86[_0x194345(0x152)]);return{..._0x591e86,'content':_0x488ee2[_0x194345(0x19a)],'exists':!![],'signature':_0x488ee2[_0x194345(0x1a9)],'dependencies':_0x488ee2['dependencies'],'actualStartLine':_0x488ee2['startLine'],'actualEndLine':_0x488ee2[_0x194345(0x152)],'loadedAt':new Date()['toISOString']()};}catch(_0x3e2eb8){throw new Error(_0x194345(0x162)+_0x3e2eb8['message']);}}async[a0_0x3f7832(0x1aa)](_0x2b1dd2,_0x42b80a){const _0x36d9a1=a0_0x3f7832;if(_0x2b1dd2['file']){const _0x4273ab=a0_0x4f216a[_0x36d9a1(0x14b)](_0x42b80a,_0x2b1dd2[_0x36d9a1(0x187)]);try{const _0x2e5559=await a0_0x57333b['readFile'](_0x4273ab,_0x36d9a1(0x17e)),_0x2cf357=_0x2e5559[_0x36d9a1(0x167)]('\x0a');if(_0x2b1dd2['lines']&&_0x2b1dd2[_0x36d9a1(0x1ac)][_0x36d9a1(0x16b)]>=0x2){const _0x3e27b8=Math['max'](0x0,_0x2b1dd2['lines'][0x0]-0x1),_0x27d4cb=Math['min'](_0x2cf357['length'],_0x2b1dd2[_0x36d9a1(0x1ac)][0x1]),_0x1e7c5c=_0x2cf357[_0x36d9a1(0x1ad)](_0x3e27b8,_0x27d4cb)[_0x36d9a1(0x182)]('\x0a'),_0x2efdd9=this['compareSelections'](_0x2b1dd2['content'],_0x1e7c5c);return{..._0x2b1dd2,'exists':!![],'validated':_0x2efdd9,'currentFileContent':_0x2efdd9?null:_0x1e7c5c,'loadedAt':new Date()[_0x36d9a1(0x1a0)]()};}}catch{}}return{..._0x2b1dd2,'exists':!![],'validated':![],'loadedAt':new Date()['toISOString']()};}async[a0_0x3f7832(0x18c)](_0x4ebf8d,_0x58fb55){const _0x2b3bad=a0_0x3f7832,_0xd18c1c=a0_0x4f216a[_0x2b3bad(0x14b)](_0x58fb55,_0x4ebf8d[_0x2b3bad(0x18f)]);try{const _0x728b8c=await a0_0x57333b[_0x2b3bad(0x17f)](_0xd18c1c);if(!_0x728b8c['isDirectory']())throw new Error(_0x2b3bad(0x174));const _0x5749d4=await a0_0x57333b[_0x2b3bad(0x197)](_0xd18c1c,{'withFileTypes':!![]}),_0x21af11=_0x5749d4['map'](_0x209e52=>({'name':_0x209e52['name'],'type':_0x209e52[_0x2b3bad(0x158)]()?_0x2b3bad(0x178):'file','isSymbolicLink':_0x209e52[_0x2b3bad(0x198)]()})),_0x33e844=this['generateDirectoryListing'](_0x4ebf8d[_0x2b3bad(0x18f)],_0x21af11);return{..._0x4ebf8d,'content':_0x33e844,'exists':!![],'structure':_0x21af11,'fileCount':_0x5749d4[_0x2b3bad(0x16e)](_0x47b07a=>_0x47b07a['isFile']())[_0x2b3bad(0x16b)],'directoryCount':_0x5749d4['filter'](_0x1c9abf=>_0x1c9abf['isDirectory']())[_0x2b3bad(0x16b)],'loadedAt':new Date()['toISOString']()};}catch(_0x1afede){throw new Error('Directory\x20reading\x20failed:\x20'+_0x1afede[_0x2b3bad(0x160)]);}}['generateContextPrompt'](_0x560253){const _0xf8e781=a0_0x3f7832;if(!_0x560253[_0xf8e781(0x16b)])return'';let _0x497dd2='\x0a===\x20PROJECT\x20CONTEXT\x20REFERENCES\x20===\x0a';for(const _0x4a1983 of _0x560253){if(_0x4a1983['error']){_0x497dd2+='❌\x20'+_0x4a1983['type'][_0xf8e781(0x19f)]()+':\x20'+(_0x4a1983[_0xf8e781(0x18f)]||_0x4a1983['name'])+'\x0a',_0x497dd2+=_0xf8e781(0x163)+_0x4a1983['error']+'\x0a\x0a';continue;}const _0x531c4d=this['getContextIcon'](_0x4a1983[_0xf8e781(0x153)]);_0x497dd2+=_0x531c4d+'\x20'+_0x4a1983[_0xf8e781(0x153)][_0xf8e781(0x19f)]()+':\x20'+(_0x4a1983[_0xf8e781(0x18f)]||_0x4a1983[_0xf8e781(0x1ab)])+'\x0a';if(_0x4a1983['lines']&&_0x4a1983[_0xf8e781(0x1ac)][_0xf8e781(0x16b)]>0x0){const _0x12e9ed=_0x4a1983['lines'][_0xf8e781(0x16b)]===0x1?_0xf8e781(0x171)+_0x4a1983['lines'][0x0]:_0xf8e781(0x140)+_0x4a1983['lines'][0x0]+'-'+_0x4a1983[_0xf8e781(0x1ac)][0x1];_0x497dd2+='\x20\x20\x20'+_0x12e9ed+'\x0a';}_0x4a1983[_0xf8e781(0x191)]&&(_0x497dd2+='\x20\x20\x20Description:\x20'+_0x4a1983[_0xf8e781(0x191)]+'\x0a');_0x4a1983['hasChanged']&&(_0x497dd2+=_0xf8e781(0x190));_0x4a1983[_0xf8e781(0x13d)]&&(_0x497dd2+=_0xf8e781(0x177));const _0x3fd453=this[_0xf8e781(0x185)](_0x4a1983['path']||_0x4a1983['file']);_0x497dd2+='\x0a```'+_0x3fd453+'\x0a',_0x497dd2+=_0x4a1983[_0xf8e781(0x19a)],_0x497dd2+=_0xf8e781(0x15a);}return _0x497dd2+=_0xf8e781(0x180),_0x497dd2;}async['extractComponent'](_0x57fe0d,_0x25d0e8,_0xb768fa,_0x458347){const _0x49bc57=a0_0x3f7832,_0x16a106=_0x57fe0d[_0x49bc57(0x167)]('\x0a');if(_0xb768fa&&_0x458347){const _0x4348f8=_0x16a106[_0x49bc57(0x1ad)](_0xb768fa-0x1,_0x458347)['join']('\x0a');return{'content':_0x4348f8,'startLine':_0xb768fa,'endLine':_0x458347,'signature':this['extractSignature'](_0x4348f8,_0x25d0e8),'dependencies':this[_0x49bc57(0x193)](_0x4348f8)};}const _0x484ee7=new RegExp('(class\x5cs+'+_0x25d0e8+'|function\x5cs+'+_0x25d0e8+'|const\x5cs+'+_0x25d0e8+'|export.*'+_0x25d0e8+')','i');let _0x10cfc1=-0x1,_0x1f30f9=-0x1,_0x12c960=0x0,_0x4dbd0a=![];for(let _0x55ee0c=0x0;_0x55ee0c<_0x16a106['length'];_0x55ee0c++){const _0x1850f6=_0x16a106[_0x55ee0c];if(!_0x4dbd0a&&_0x484ee7[_0x49bc57(0x184)](_0x1850f6)){_0x10cfc1=_0x55ee0c+0x1,_0x4dbd0a=!![],_0x12c960+=(_0x1850f6['match'](/\{/g)||[])['length'],_0x12c960-=(_0x1850f6[_0x49bc57(0x145)](/\}/g)||[])[_0x49bc57(0x16b)];if(_0x12c960===0x0&&_0x1850f6[_0x49bc57(0x14a)](';')){_0x1f30f9=_0x55ee0c+0x1;break;}continue;}if(_0x4dbd0a){_0x12c960+=(_0x1850f6[_0x49bc57(0x145)](/\{/g)||[])[_0x49bc57(0x16b)],_0x12c960-=(_0x1850f6['match'](/\}/g)||[])[_0x49bc57(0x16b)];if(_0x12c960<=0x0){_0x1f30f9=_0x55ee0c+0x1;break;}}}if(_0x10cfc1===-0x1)throw new Error(_0x49bc57(0x194)+_0x25d0e8+'\x27\x20not\x20found\x20in\x20file');const _0x790dcb=_0x16a106['slice'](_0x10cfc1-0x1,_0x1f30f9)['join']('\x0a');return{'content':_0x790dcb,'startLine':_0x10cfc1,'endLine':_0x1f30f9,'signature':this[_0x49bc57(0x15b)](_0x790dcb,_0x25d0e8),'dependencies':this['extractDependencies'](_0x790dcb)};}[a0_0x3f7832(0x15b)](_0x1e729c,_0x418d99){const _0x1fc5e8=a0_0x3f7832,_0x4650ce=_0x1e729c[_0x1fc5e8(0x167)]('\x0a'),_0x3f8ab6=_0x4650ce[0x0][_0x1fc5e8(0x13e)](),_0x5efabf=new RegExp(_0x1fc5e8(0x196)+_0x418d99+'[^{;]*)[{;]?'),_0x2d66db=_0x3f8ab6[_0x1fc5e8(0x145)](_0x5efabf);return _0x2d66db?_0x2d66db[0x1][_0x1fc5e8(0x13e)]():_0x3f8ab6;}['extractDependencies'](_0x2b910e){const _0x9dc6d=a0_0x3f7832,_0x22cb88=[],importRegex=/import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;let _0x3e81ea;while((_0x3e81ea=importRegex[_0x9dc6d(0x1a8)](_0x2b910e))!==null){_0x22cb88[_0x9dc6d(0x14c)](_0x3e81ea[0x1]);}const requireRegex=/require\(['"]([^'"]+)['"]\)/g;while((_0x3e81ea=requireRegex['exec'](_0x2b910e))!==null){_0x22cb88['push'](_0x3e81ea[0x1]);}return[...new Set(_0x22cb88)];}[a0_0x3f7832(0x15c)](_0x4fac6c,_0x2225fe){const _0x1ed5d5=a0_0x3f7832;let _0x17bfad=_0x1ed5d5(0x175)+_0x4fac6c+'\x0a\x0a';const _0x57206f=_0x2225fe['filter'](_0x27d9e2=>_0x27d9e2['type']==='directory'),_0x3b7725=_0x2225fe[_0x1ed5d5(0x16e)](_0x15b09c=>_0x15b09c[_0x1ed5d5(0x153)]==='file');if(_0x57206f['length']>0x0){_0x17bfad+='Directories:\x0a';for(const _0x34e1ce of _0x57206f){_0x17bfad+='\x20\x20📁\x20'+_0x34e1ce[_0x1ed5d5(0x1ab)]+(_0x34e1ce['isSymbolicLink']?_0x1ed5d5(0x179):'')+'\x0a';}_0x17bfad+='\x0a';}if(_0x3b7725['length']>0x0){_0x17bfad+=_0x1ed5d5(0x165);for(const _0x1bfbae of _0x3b7725){const _0x4b20d4=this['getFileIcon'](_0x1bfbae['name']);_0x17bfad+='\x20\x20'+_0x4b20d4+'\x20'+_0x1bfbae[_0x1ed5d5(0x1ab)]+(_0x1bfbae[_0x1ed5d5(0x198)]?_0x1ed5d5(0x179):'')+'\x0a';}}return _0x2225fe['length']===0x0&&(_0x17bfad+='(empty\x20directory)\x0a'),_0x17bfad;}[a0_0x3f7832(0x142)](_0x35cc46){const _0x28c617=a0_0x3f7832,_0x48b1ef={'file':0x1,'component':0x2,'selection':0x3,'directory':0x4};return[..._0x35cc46][_0x28c617(0x172)]((_0x37c9b8,_0x52642d)=>{const _0x1f381=_0x28c617,_0x1877fb=_0x48b1ef[_0x37c9b8['type']]||0x3e7,_0xa60266=_0x48b1ef[_0x52642d[_0x1f381(0x153)]]||0x3e7;return _0x1877fb-_0xa60266;});}[a0_0x3f7832(0x1a6)](_0x1c64e2){const _0x5a4cee={'file':'📄','component':'🔧','selection':'✂️','directory':'📁'};return _0x5a4cee[_0x1c64e2]||'📎';}['getFileIcon'](_0xa5fc31){const _0x57c7aa=a0_0x4f216a['extname'](_0xa5fc31)['toLowerCase'](),_0x6fce17={'.js':'📜','.jsx':'⚛️','.ts':'📘','.tsx':'⚛️','.py':'🐍','.java':'☕','.html':'🌐','.css':'🎨','.json':'📋','.md':'📝','.yml':'⚙️','.yaml':'⚙️'};return _0x6fce17[_0x57c7aa]||'📄';}[a0_0x3f7832(0x185)](_0x38b079){const _0x13d046=a0_0x3f7832;if(!_0x38b079)return'';const _0x5cb4fa=a0_0x4f216a['extname'](_0x38b079)['toLowerCase'](),_0x7b6714={'.js':'javascript','.jsx':'jsx','.ts':'typescript','.tsx':_0x13d046(0x1a4),'.py':_0x13d046(0x148),'.java':'java','.cpp':_0x13d046(0x17a),'.c':'c','.cs':_0x13d046(0x169),'.php':_0x13d046(0x144),'.rb':'ruby','.go':'go','.rs':'rust','.html':'html','.css':'css','.scss':_0x13d046(0x16c),'.json':_0x13d046(0x1a3),'.yml':_0x13d046(0x19b),'.yaml':'yaml','.md':_0x13d046(0x18d),'.xml':'xml','.sql':_0x13d046(0x17d)};return _0x7b6714[_0x5cb4fa]||'';}[a0_0x3f7832(0x18a)](_0x2a4765){const _0x522d36=a0_0x3f7832;return a0_0x4efa92[_0x522d36(0x161)](_0x522d36(0x15f))['update'](_0x2a4765)[_0x522d36(0x157)](_0x522d36(0x176))['substring'](0x0,0x10);}['compareSelections'](_0x8f65cd,_0x3ace12){const _0x43efab=a0_0x3f7832,_0x10f108=_0x348dd9=>_0x348dd9['replace'](/\s+/g,'\x20')[_0x43efab(0x13e)]();return _0x10f108(_0x8f65cd)===_0x10f108(_0x3ace12);}['generateCacheKey'](_0x364c3f,_0x160871){const _0x27aa49=a0_0x3f7832,_0x332054={'type':_0x364c3f[_0x27aa49(0x153)],'path':_0x364c3f['path']||_0x364c3f[_0x27aa49(0x187)],'lines':_0x364c3f[_0x27aa49(0x1ac)],'name':_0x364c3f[_0x27aa49(0x1ab)],'projectDir':_0x160871};return a0_0x4efa92[_0x27aa49(0x161)](_0x27aa49(0x192))['update'](JSON[_0x27aa49(0x151)](_0x332054))['digest'](_0x27aa49(0x176));}[a0_0x3f7832(0x186)](_0x47944f){const _0x553559=a0_0x3f7832,_0x37bec7=this['contextCache'][_0x553559(0x155)](_0x47944f);if(!_0x37bec7)return null;return _0x37bec7['data'];}['addToCache'](_0x1fb678,_0x21b33e){const _0x873a0a=a0_0x3f7832;this[_0x873a0a(0x1a1)][_0x873a0a(0x19e)](_0x1fb678,{'data':_0x21b33e,'timestamp':Date[_0x873a0a(0x18b)]()}),this[_0x873a0a(0x19c)]();}['shouldRefreshCache'](_0x9934ba){const _0x40dff8=a0_0x3f7832;if(!this['autoValidation'])return![];const _0xe85dd0=(Date['now']()-new Date(_0x9934ba[_0x40dff8(0x14f)])['getTime']())/0x3e8;return _0xe85dd0>this['cacheExpiry'];}[a0_0x3f7832(0x19c)](){const _0x4367b9=a0_0x3f7832,_0x5f04b6=Date['now'](),_0x1a7113=[];for(const [_0x9dc555,_0x31b404]of this['contextCache']['entries']()){_0x5f04b6-_0x31b404['timestamp']>this[_0x4367b9(0x1a5)]*0x3e8&&_0x1a7113['push'](_0x9dc555);}for(const _0x55e14b of _0x1a7113){this['contextCache'][_0x4367b9(0x149)](_0x55e14b);}}}export default ContextManager;function a0_0x3952(){const _0x175e5b=['y29UDgvUDa','EwfTBa','y2XLyw51CenHy2HL','mtjdwhjjr24','C2v0','Dg9vChbLCKnHC2u','Dg9ju09tDhjPBMC','y29UDgv4DenHy2HL','y29UDgv4DfjLzMvYzw5Jzxm','ANnVBG','Dhn4','y2fJAgvfEhbPCNK','z2v0q29UDgv4DeLJB24','C3rHy2S','zxHLyW','C2LNBMf0DxjL','Bg9HzfnLBgvJDgLVBLjLzMvYzw5Jzq','BMfTzq','BgLUzxm','C2XPy2u','ode0ote5A3bWrg9b','ndi1nJu1own1t3LUAa','y29UzMLN','Dhj1BMnHDgvK','DhjPBq','uMvMzxjLBMnLigXVywrLzcbPBIa','tgLUzxmG','C2HVDwXKuMvMCMvZAenHy2HL','C29YDfjLzMvYzw5JzxncEvbYAw9YAxr5','rMfPBgvKihrVigXVywqGy29UDgv4DcbYzwzLCMvUy2u6ia','CgHW','Bwf0y2G','y2HLy2TZDw0','Bwf4uMvMzxjLBMnLCW','ChL0Ag9U','zgvSzxrL','Aw5JBhvKzxm','CMvZB2X2zq','ChvZAa','rMLSzsbUB3qGzM91BMq','Bg9HzenVBxbVBMvUDfjLzMvYzw5Jzq','Bg9HzgvKqxq','BwLU','C3rYAw5NAwz5','zw5KtgLUzq','DhLWzq','Bwf4u2L6zq','z2v0','mtmYmda5mhj0CvLrwq','zgLNzxn0','AxneAxjLy3rVCNK','AxngAwXL','cMbGyaOk','zxH0CMfJDfnPz25HDhvYzq','z2vUzxjHDgveAxjLy3rVCNLmAxn0Aw5N','Aw5MBW','mJmXntyYvhHkzvnP','C2HHmJu2','BwvZC2fNzq','y3jLyxrLsgfZAa','q29TCg9Uzw50igv4DhjHy3rPB24GzMfPBgvKoIa','icaGrxjYB3i6ia','ugf0AcbPCYbUB3qGysbMAwXL','rMLSzxm6cG','Bg9HzenVBNrLEhrszwzLCMvUy2vZ','C3bSAxq','mJfdBvPxuwu','y3nOyxjW','C3vIC3rYAw5N','BgvUz3rO','C2nZCW','mtz4zuPLC2m','zMLSDgvY','Bg9HzfnPBMDSzvjLzMvYzw5Jzq','mJa0nJm0mgDuvhbqAa','tgLUzsa','C29YDa','mZKXmZy5m1zXAunNtG','ugf0AcbPCYbUB3qGysbKAxjLy3rVCNK','rgLYzwn0B3j5oIa','Agv4','icaG4PQG77IpicbdB250zw50ihrYDw5JyxrLzcbKDwuGDg8GC2L6zsbSAw1PDhmk','zgLYzwn0B3j5','icHZEw1SAw5Rkq','y3bW','q29UDgv4DcbWCM9JzxnZAw5NigzHAwXLzdOG','zMLSzvDHDgnOzxjZ','C3fS','DxrMoa','C3rHDa','pt09ievorcbdt05urvHuifjfrKvsru5drvmGpt09cG','Bg9Nz2vY','AM9PBG','q29UDgv4DcbZAxPLigXPBwL0ihjLywnOzwqSihn0B3bWAw5NihjLzMvYzw5JzsbSB2fKAw5N','DgvZDa','z2v0tgfUz3vHz2vgCM9Tugf0Aa','z2v0rNjVBunHy2HL','zMLSzq','ChjVy2vZC01LC3nHz2vxAxrOq29UDgv4Da','Bg9HzezPBgvszwzLCMvUy2u','y2fSy3vSyxrLq2HLy2TZDw0','BM93','Bg9HzerPCMvJDg9YEvjLzMvYzw5Jzq','BwfYA2rVD24','mJiYmdqWqNfiz3rU','Cgf0Aa','icaG4PQG77IpicbgAwXLigHHCYbJAgfUz2vKihnPBMnLihjLzMvYzw5Jzsb3yxmGy3jLyxrLzaO','zgvZy3jPChrPB24','Bwq1','zxH0CMfJDerLCgvUzgvUy2LLCW','q29TCg9Uzw50icC','Bwf4q29UDgv4DfnPEMu','kc4Q','CMvHzgrPCG','AxntEw1IB2XPy0XPBMS','CMvHzezPBgu'];a0_0x3952=function(){return _0x175e5b;};return a0_0x3952();}