@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.4
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/README.md +44 -54
- package/bin/cli.js +1 -115
- package/bin/loxia-terminal-v2.js +3 -0
- package/bin/loxia-terminal.js +3 -0
- package/bin/start-with-terminal.js +3 -0
- package/package.json +15 -15
- package/scripts/install-scanners.js +1 -235
- package/src/analyzers/CSSAnalyzer.js +1 -297
- package/src/analyzers/ConfigValidator.js +1 -690
- package/src/analyzers/ESLintAnalyzer.js +1 -320
- package/src/analyzers/JavaScriptAnalyzer.js +1 -261
- package/src/analyzers/PrettierFormatter.js +1 -247
- package/src/analyzers/PythonAnalyzer.js +1 -266
- package/src/analyzers/SecurityAnalyzer.js +1 -729
- package/src/analyzers/TypeScriptAnalyzer.js +1 -247
- package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
- package/src/analyzers/codeCloneDetector/detector.js +1 -203
- package/src/analyzers/codeCloneDetector/index.js +1 -160
- package/src/analyzers/codeCloneDetector/parser.js +1 -199
- package/src/analyzers/codeCloneDetector/reporter.js +1 -148
- package/src/analyzers/codeCloneDetector/scanner.js +1 -59
- package/src/core/agentPool.js +1 -1474
- package/src/core/agentScheduler.js +1 -2147
- package/src/core/contextManager.js +1 -709
- package/src/core/messageProcessor.js +1 -732
- package/src/core/orchestrator.js +1 -548
- package/src/core/stateManager.js +1 -877
- package/src/index.js +1 -631
- package/src/interfaces/cli.js +1 -549
- package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
- package/src/interfaces/terminal/api/apiClient.js +1 -0
- package/src/interfaces/terminal/api/messageRouter.js +1 -0
- package/src/interfaces/terminal/api/session.js +1 -0
- package/src/interfaces/terminal/api/websocket.js +1 -0
- package/src/interfaces/terminal/components/AgentCreator.js +1 -0
- package/src/interfaces/terminal/components/AgentEditor.js +1 -0
- package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
- package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
- package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
- package/src/interfaces/terminal/components/Header.js +1 -0
- package/src/interfaces/terminal/components/HelpPanel.js +1 -0
- package/src/interfaces/terminal/components/InputBox.js +1 -0
- package/src/interfaces/terminal/components/Layout.js +1 -0
- package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
- package/src/interfaces/terminal/components/MessageList.js +1 -0
- package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
- package/src/interfaces/terminal/components/SearchPanel.js +1 -0
- package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
- package/src/interfaces/terminal/components/StatusBar.js +1 -0
- package/src/interfaces/terminal/components/TextInput.js +1 -0
- package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
- package/src/interfaces/terminal/config/constants.js +1 -0
- package/src/interfaces/terminal/index.js +1 -0
- package/src/interfaces/terminal/state/useAgentControl.js +1 -0
- package/src/interfaces/terminal/state/useAgents.js +1 -0
- package/src/interfaces/terminal/state/useConnection.js +1 -0
- package/src/interfaces/terminal/state/useMessages.js +1 -0
- package/src/interfaces/terminal/state/useTools.js +1 -0
- package/src/interfaces/terminal/utils/debugLogger.js +1 -0
- package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
- package/src/interfaces/terminal/utils/theme.js +1 -0
- package/src/interfaces/webServer.js +1 -2162
- package/src/modules/fileExplorer/controller.js +1 -280
- package/src/modules/fileExplorer/index.js +1 -37
- package/src/modules/fileExplorer/middleware.js +1 -92
- package/src/modules/fileExplorer/routes.js +1 -125
- package/src/modules/fileExplorer/types.js +1 -44
- package/src/services/aiService.js +1 -1232
- package/src/services/apiKeyManager.js +1 -164
- package/src/services/benchmarkService.js +1 -366
- package/src/services/budgetService.js +1 -539
- package/src/services/contextInjectionService.js +1 -247
- package/src/services/conversationCompactionService.js +1 -637
- package/src/services/errorHandler.js +1 -810
- package/src/services/fileAttachmentService.js +1 -544
- package/src/services/modelRouterService.js +1 -366
- package/src/services/modelsService.js +1 -322
- package/src/services/qualityInspector.js +1 -796
- package/src/services/tokenCountingService.js +1 -536
- package/src/tools/agentCommunicationTool.js +1 -1344
- package/src/tools/agentDelayTool.js +1 -485
- package/src/tools/asyncToolManager.js +1 -604
- package/src/tools/baseTool.js +1 -800
- package/src/tools/browserTool.js +1 -920
- package/src/tools/cloneDetectionTool.js +1 -621
- package/src/tools/dependencyResolverTool.js +1 -1215
- package/src/tools/fileContentReplaceTool.js +1 -875
- package/src/tools/fileSystemTool.js +1 -1107
- package/src/tools/fileTreeTool.js +1 -853
- package/src/tools/imageTool.js +1 -901
- package/src/tools/importAnalyzerTool.js +1 -1060
- package/src/tools/jobDoneTool.js +1 -248
- package/src/tools/seekTool.js +1 -956
- package/src/tools/staticAnalysisTool.js +1 -1778
- package/src/tools/taskManagerTool.js +1 -2873
- package/src/tools/terminalTool.js +1 -2304
- package/src/tools/webTool.js +1 -1430
- package/src/types/agent.js +1 -519
- package/src/types/contextReference.js +1 -972
- package/src/types/conversation.js +1 -730
- package/src/types/toolCommand.js +1 -747
- package/src/utilities/attachmentValidator.js +1 -292
- package/src/utilities/configManager.js +1 -582
- package/src/utilities/constants.js +1 -722
- package/src/utilities/directoryAccessManager.js +1 -535
- package/src/utilities/fileProcessor.js +1 -307
- package/src/utilities/logger.js +1 -436
- package/src/utilities/tagParser.js +1 -1246
- package/src/utilities/toolConstants.js +1 -317
- package/web-ui/build/index.html +2 -2
- package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
- package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
|
@@ -1,972 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context Reference Data Model - Type definitions and validation for context references
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Define the structure and properties of context references
|
|
6
|
-
* - Provide validation functions for context reference data
|
|
7
|
-
* - Handle context reference resolution and management
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { CONTEXT_REFERENCE_TYPES, FILE_EXTENSIONS, CONTEXT_ICONS } from '../utilities/constants.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Context Reference data model
|
|
14
|
-
* @typedef {Object} ContextReference
|
|
15
|
-
* @property {string} id - Unique reference identifier
|
|
16
|
-
* @property {string} type - Reference type (file, component, selection, directory)
|
|
17
|
-
* @property {string} path - Path or identifier of referenced item
|
|
18
|
-
* @property {string} name - Human-readable name
|
|
19
|
-
* @property {string} [content] - Referenced content (if loaded)
|
|
20
|
-
* @property {ReferenceMetadata} metadata - Reference metadata
|
|
21
|
-
* @property {ReferenceScope} scope - Reference scope and boundaries
|
|
22
|
-
* @property {string} createdAt - ISO timestamp of creation
|
|
23
|
-
* @property {string} [lastAccessed] - ISO timestamp of last access
|
|
24
|
-
* @property {string} [lastModified] - ISO timestamp of last modification
|
|
25
|
-
* @property {boolean} isValid - Whether reference is still valid
|
|
26
|
-
* @property {string} [invalidReason] - Reason for invalidity
|
|
27
|
-
* @property {number} accessCount - Number of times accessed
|
|
28
|
-
* @property {Object} tags - Reference tags and labels
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Reference metadata
|
|
33
|
-
* @typedef {Object} ReferenceMetadata
|
|
34
|
-
* @property {string} [language] - Programming language (for code files)
|
|
35
|
-
* @property {string} [encoding] - File encoding
|
|
36
|
-
* @property {number} [size] - Content size in bytes
|
|
37
|
-
* @property {string} [mimeType] - MIME type
|
|
38
|
-
* @property {string} [checksum] - Content checksum for integrity
|
|
39
|
-
* @property {string[]} [keywords] - Extracted keywords
|
|
40
|
-
* @property {string} [description] - Reference description
|
|
41
|
-
* @property {Object} [customFields] - Custom metadata fields
|
|
42
|
-
* @property {string} [icon] - Display icon identifier
|
|
43
|
-
* @property {Object} [permissions] - Access permissions
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Reference scope and boundaries
|
|
48
|
-
* @typedef {Object} ReferenceScope
|
|
49
|
-
* @property {number} [startLine] - Start line number (for selections)
|
|
50
|
-
* @property {number} [endLine] - End line number (for selections)
|
|
51
|
-
* @property {number} [startColumn] - Start column number
|
|
52
|
-
* @property {number} [endColumn] - End column number
|
|
53
|
-
* @property {string} [functionName] - Function/method name (for code)
|
|
54
|
-
* @property {string} [className] - Class name (for code)
|
|
55
|
-
* @property {string} [namespace] - Namespace or module (for code)
|
|
56
|
-
* @property {string[]} [includePaths] - Included sub-paths (for directories)
|
|
57
|
-
* @property {string[]} [excludePaths] - Excluded sub-paths (for directories)
|
|
58
|
-
* @property {number} [maxDepth] - Maximum directory depth
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* File Reference (extends ContextReference)
|
|
63
|
-
* @typedef {Object} FileReference
|
|
64
|
-
* @property {string} absolutePath - Absolute file path
|
|
65
|
-
* @property {string} relativePath - Relative file path from workspace
|
|
66
|
-
* @property {string} extension - File extension
|
|
67
|
-
* @property {boolean} exists - Whether file exists on filesystem
|
|
68
|
-
* @property {FileStats} [stats] - File system statistics
|
|
69
|
-
* @property {string} [gitStatus] - Git status of file
|
|
70
|
-
* @property {DependencyInfo} [dependencies] - File dependencies
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Directory Reference (extends ContextReference)
|
|
75
|
-
* @typedef {Object} DirectoryReference
|
|
76
|
-
* @property {string} absolutePath - Absolute directory path
|
|
77
|
-
* @property {string} relativePath - Relative directory path from workspace
|
|
78
|
-
* @property {FileSystemTree} [tree] - Directory tree structure
|
|
79
|
-
* @property {number} [fileCount] - Number of files in directory
|
|
80
|
-
* @property {number} [totalSize] - Total size of directory contents
|
|
81
|
-
* @property {string[]} [fileTypes] - File types present in directory
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Selection Reference (extends ContextReference)
|
|
86
|
-
* @typedef {Object} SelectionReference
|
|
87
|
-
* @property {string} sourceFile - Source file path
|
|
88
|
-
* @property {string} selectedText - Selected text content
|
|
89
|
-
* @property {SyntaxInfo} [syntax] - Syntax information
|
|
90
|
-
* @property {ContextInfo} [context] - Surrounding context
|
|
91
|
-
* @property {string} [purpose] - Purpose of selection
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Component Reference (extends ContextReference)
|
|
96
|
-
* @typedef {Object} ComponentReference
|
|
97
|
-
* @property {string} componentType - Type of component
|
|
98
|
-
* @property {string} [sourceFile] - Source file containing component
|
|
99
|
-
* @property {Object} [properties] - Component properties
|
|
100
|
-
* @property {string[]} [dependencies] - Component dependencies
|
|
101
|
-
* @property {string} [documentation] - Component documentation
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* File system statistics
|
|
106
|
-
* @typedef {Object} FileStats
|
|
107
|
-
* @property {number} size - File size in bytes
|
|
108
|
-
* @property {string} created - Creation timestamp
|
|
109
|
-
* @property {string} modified - Last modification timestamp
|
|
110
|
-
* @property {string} accessed - Last access timestamp
|
|
111
|
-
* @property {boolean} isDirectory - Whether item is directory
|
|
112
|
-
* @property {boolean} isFile - Whether item is file
|
|
113
|
-
* @property {number} mode - File permissions mode
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* File system tree structure
|
|
118
|
-
* @typedef {Object} FileSystemTree
|
|
119
|
-
* @property {string} name - Item name
|
|
120
|
-
* @property {string} path - Item path
|
|
121
|
-
* @property {string} type - Item type (file, directory)
|
|
122
|
-
* @property {FileSystemTree[]} [children] - Child items (for directories)
|
|
123
|
-
* @property {number} [size] - Item size
|
|
124
|
-
* @property {string} [extension] - File extension
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Syntax information
|
|
129
|
-
* @typedef {Object} SyntaxInfo
|
|
130
|
-
* @property {string} language - Programming language
|
|
131
|
-
* @property {string[]} [symbols] - Identified symbols
|
|
132
|
-
* @property {string[]} [imports] - Import statements
|
|
133
|
-
* @property {string[]} [functions] - Function definitions
|
|
134
|
-
* @property {string[]} [classes] - Class definitions
|
|
135
|
-
* @property {string[]} [variables] - Variable definitions
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Context information
|
|
140
|
-
* @typedef {Object} ContextInfo
|
|
141
|
-
* @property {string} [beforeText] - Text before selection
|
|
142
|
-
* @property {string} [afterText] - Text after selection
|
|
143
|
-
* @property {number} [indentLevel] - Indentation level
|
|
144
|
-
* @property {string[]} [surroundingFunctions] - Surrounding function names
|
|
145
|
-
* @property {string[]} [surroundingClasses] - Surrounding class names
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Dependency information
|
|
150
|
-
* @typedef {Object} DependencyInfo
|
|
151
|
-
* @property {string[]} imports - Imported modules/files
|
|
152
|
-
* @property {string[]} exports - Exported items
|
|
153
|
-
* @property {string[]} dependencies - External dependencies
|
|
154
|
-
* @property {string[]} dependents - Files that depend on this file
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Context Reference validation functions
|
|
159
|
-
*/
|
|
160
|
-
export class ContextReferenceValidator {
|
|
161
|
-
/**
|
|
162
|
-
* Validate context reference data structure
|
|
163
|
-
* @param {Object} reference - Context reference to validate
|
|
164
|
-
* @returns {Object} Validation result
|
|
165
|
-
*/
|
|
166
|
-
static validate(reference) {
|
|
167
|
-
const errors = [];
|
|
168
|
-
const warnings = [];
|
|
169
|
-
|
|
170
|
-
// Required fields
|
|
171
|
-
if (!reference.id || typeof reference.id !== 'string') {
|
|
172
|
-
errors.push('Reference ID is required and must be a string');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (!reference.type || typeof reference.type !== 'string') {
|
|
176
|
-
errors.push('Reference type is required and must be a string');
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!reference.path || typeof reference.path !== 'string') {
|
|
180
|
-
errors.push('Reference path is required and must be a string');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!reference.name || typeof reference.name !== 'string') {
|
|
184
|
-
errors.push('Reference name is required and must be a string');
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Type validation
|
|
188
|
-
if (reference.type && !Object.values(CONTEXT_REFERENCE_TYPES).includes(reference.type)) {
|
|
189
|
-
errors.push(`Invalid reference type: ${reference.type}`);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Content validation
|
|
193
|
-
if (reference.content && typeof reference.content !== 'string') {
|
|
194
|
-
errors.push('Reference content must be a string');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (reference.content && reference.content.length > 1000000) { // 1MB
|
|
198
|
-
warnings.push('Reference content is very large (>1MB)');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Metadata validation
|
|
202
|
-
if (reference.metadata) {
|
|
203
|
-
const metadataValidation = this.validateMetadata(reference.metadata);
|
|
204
|
-
errors.push(...metadataValidation.errors);
|
|
205
|
-
warnings.push(...metadataValidation.warnings);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Scope validation
|
|
209
|
-
if (reference.scope) {
|
|
210
|
-
const scopeValidation = this.validateScope(reference.scope);
|
|
211
|
-
errors.push(...scopeValidation.errors);
|
|
212
|
-
warnings.push(...scopeValidation.warnings);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Access count validation
|
|
216
|
-
if (reference.accessCount !== undefined && typeof reference.accessCount !== 'number') {
|
|
217
|
-
errors.push('Access count must be a number');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Timestamp validation
|
|
221
|
-
const timestampFields = ['createdAt', 'lastAccessed', 'lastModified'];
|
|
222
|
-
timestampFields.forEach(field => {
|
|
223
|
-
if (reference[field] && !this.isValidTimestamp(reference[field])) {
|
|
224
|
-
errors.push(`Invalid timestamp for ${field}: ${reference[field]}`);
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// Type-specific validation
|
|
229
|
-
switch (reference.type) {
|
|
230
|
-
case CONTEXT_REFERENCE_TYPES.FILE:
|
|
231
|
-
const fileValidation = this.validateFileReference(reference);
|
|
232
|
-
errors.push(...fileValidation.errors);
|
|
233
|
-
warnings.push(...fileValidation.warnings);
|
|
234
|
-
break;
|
|
235
|
-
case CONTEXT_REFERENCE_TYPES.SELECTION:
|
|
236
|
-
const selectionValidation = this.validateSelectionReference(reference);
|
|
237
|
-
errors.push(...selectionValidation.errors);
|
|
238
|
-
warnings.push(...selectionValidation.warnings);
|
|
239
|
-
break;
|
|
240
|
-
case CONTEXT_REFERENCE_TYPES.DIRECTORY:
|
|
241
|
-
const directoryValidation = this.validateDirectoryReference(reference);
|
|
242
|
-
errors.push(...directoryValidation.errors);
|
|
243
|
-
warnings.push(...directoryValidation.warnings);
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return {
|
|
248
|
-
isValid: errors.length === 0,
|
|
249
|
-
errors,
|
|
250
|
-
warnings
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Validate reference metadata
|
|
256
|
-
* @param {Object} metadata - Metadata to validate
|
|
257
|
-
* @returns {Object} Validation result
|
|
258
|
-
*/
|
|
259
|
-
static validateMetadata(metadata) {
|
|
260
|
-
const errors = [];
|
|
261
|
-
const warnings = [];
|
|
262
|
-
|
|
263
|
-
if (metadata.size !== undefined && (typeof metadata.size !== 'number' || metadata.size < 0)) {
|
|
264
|
-
errors.push('Metadata size must be a non-negative number');
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (metadata.language && typeof metadata.language !== 'string') {
|
|
268
|
-
errors.push('Metadata language must be a string');
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (metadata.encoding && typeof metadata.encoding !== 'string') {
|
|
272
|
-
errors.push('Metadata encoding must be a string');
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (metadata.keywords && !Array.isArray(metadata.keywords)) {
|
|
276
|
-
errors.push('Metadata keywords must be an array');
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (metadata.mimeType && typeof metadata.mimeType !== 'string') {
|
|
280
|
-
errors.push('Metadata MIME type must be a string');
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return { errors, warnings };
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Validate reference scope
|
|
288
|
-
* @param {Object} scope - Scope to validate
|
|
289
|
-
* @returns {Object} Validation result
|
|
290
|
-
*/
|
|
291
|
-
static validateScope(scope) {
|
|
292
|
-
const errors = [];
|
|
293
|
-
const warnings = [];
|
|
294
|
-
|
|
295
|
-
const numericFields = ['startLine', 'endLine', 'startColumn', 'endColumn', 'maxDepth'];
|
|
296
|
-
numericFields.forEach(field => {
|
|
297
|
-
if (scope[field] !== undefined && (typeof scope[field] !== 'number' || scope[field] < 0)) {
|
|
298
|
-
errors.push(`Scope ${field} must be a non-negative number`);
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
// Line range validation
|
|
303
|
-
if (scope.startLine !== undefined && scope.endLine !== undefined) {
|
|
304
|
-
if (scope.startLine > scope.endLine) {
|
|
305
|
-
errors.push('Start line must be <= end line');
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// Column range validation
|
|
310
|
-
if (scope.startColumn !== undefined && scope.endColumn !== undefined) {
|
|
311
|
-
if (scope.startColumn > scope.endColumn) {
|
|
312
|
-
errors.push('Start column must be <= end column');
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const arrayFields = ['includePaths', 'excludePaths'];
|
|
317
|
-
arrayFields.forEach(field => {
|
|
318
|
-
if (scope[field] && !Array.isArray(scope[field])) {
|
|
319
|
-
errors.push(`Scope ${field} must be an array`);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
return { errors, warnings };
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Validate file reference specific fields
|
|
328
|
-
* @param {Object} reference - File reference to validate
|
|
329
|
-
* @returns {Object} Validation result
|
|
330
|
-
*/
|
|
331
|
-
static validateFileReference(reference) {
|
|
332
|
-
const errors = [];
|
|
333
|
-
const warnings = [];
|
|
334
|
-
|
|
335
|
-
if (reference.absolutePath && typeof reference.absolutePath !== 'string') {
|
|
336
|
-
errors.push('Absolute path must be a string');
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (reference.relativePath && typeof reference.relativePath !== 'string') {
|
|
340
|
-
errors.push('Relative path must be a string');
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (reference.extension && typeof reference.extension !== 'string') {
|
|
344
|
-
errors.push('File extension must be a string');
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (reference.exists !== undefined && typeof reference.exists !== 'boolean') {
|
|
348
|
-
errors.push('File exists flag must be a boolean');
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
return { errors, warnings };
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Validate selection reference specific fields
|
|
356
|
-
* @param {Object} reference - Selection reference to validate
|
|
357
|
-
* @returns {Object} Validation result
|
|
358
|
-
*/
|
|
359
|
-
static validateSelectionReference(reference) {
|
|
360
|
-
const errors = [];
|
|
361
|
-
const warnings = [];
|
|
362
|
-
|
|
363
|
-
if (!reference.scope || (!reference.scope.startLine && !reference.scope.endLine)) {
|
|
364
|
-
warnings.push('Selection reference should have line scope defined');
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (reference.selectedText && typeof reference.selectedText !== 'string') {
|
|
368
|
-
errors.push('Selected text must be a string');
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (reference.sourceFile && typeof reference.sourceFile !== 'string') {
|
|
372
|
-
errors.push('Source file must be a string');
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return { errors, warnings };
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Validate directory reference specific fields
|
|
380
|
-
* @param {Object} reference - Directory reference to validate
|
|
381
|
-
* @returns {Object} Validation result
|
|
382
|
-
*/
|
|
383
|
-
static validateDirectoryReference(reference) {
|
|
384
|
-
const errors = [];
|
|
385
|
-
const warnings = [];
|
|
386
|
-
|
|
387
|
-
if (reference.fileCount !== undefined && (typeof reference.fileCount !== 'number' || reference.fileCount < 0)) {
|
|
388
|
-
errors.push('File count must be a non-negative number');
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
if (reference.totalSize !== undefined && (typeof reference.totalSize !== 'number' || reference.totalSize < 0)) {
|
|
392
|
-
errors.push('Total size must be a non-negative number');
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
if (reference.fileTypes && !Array.isArray(reference.fileTypes)) {
|
|
396
|
-
errors.push('File types must be an array');
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
return { errors, warnings };
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Check if a timestamp is valid ISO string
|
|
404
|
-
* @param {string} timestamp - Timestamp to validate
|
|
405
|
-
* @returns {boolean} True if valid
|
|
406
|
-
*/
|
|
407
|
-
static isValidTimestamp(timestamp) {
|
|
408
|
-
if (typeof timestamp !== 'string') return false;
|
|
409
|
-
const date = new Date(timestamp);
|
|
410
|
-
return date instanceof Date && !isNaN(date.getTime());
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Context Reference factory functions
|
|
416
|
-
*/
|
|
417
|
-
export class ContextReferenceFactory {
|
|
418
|
-
/**
|
|
419
|
-
* Create a new context reference
|
|
420
|
-
* @param {string} type - Reference type
|
|
421
|
-
* @param {string} path - Reference path
|
|
422
|
-
* @param {string} name - Reference name
|
|
423
|
-
* @param {Object} options - Additional options
|
|
424
|
-
* @returns {ContextReference} New context reference
|
|
425
|
-
*/
|
|
426
|
-
static create(type, path, name, options = {}) {
|
|
427
|
-
const now = new Date().toISOString();
|
|
428
|
-
const referenceId = this.generateReferenceId();
|
|
429
|
-
|
|
430
|
-
return {
|
|
431
|
-
id: referenceId,
|
|
432
|
-
type,
|
|
433
|
-
path,
|
|
434
|
-
name,
|
|
435
|
-
content: options.content || null,
|
|
436
|
-
metadata: this.createDefaultMetadata(type, path, options.metadata),
|
|
437
|
-
scope: options.scope || {},
|
|
438
|
-
createdAt: now,
|
|
439
|
-
lastAccessed: null,
|
|
440
|
-
lastModified: options.lastModified || null,
|
|
441
|
-
isValid: true,
|
|
442
|
-
invalidReason: null,
|
|
443
|
-
accessCount: 0,
|
|
444
|
-
tags: options.tags || {}
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* Create a file reference
|
|
450
|
-
* @param {string} absolutePath - Absolute file path
|
|
451
|
-
* @param {string} relativePath - Relative file path
|
|
452
|
-
* @param {Object} options - Additional options
|
|
453
|
-
* @returns {FileReference} File reference
|
|
454
|
-
*/
|
|
455
|
-
static createFileReference(absolutePath, relativePath, options = {}) {
|
|
456
|
-
const name = options.name || this.extractFileName(absolutePath);
|
|
457
|
-
const extension = this.extractFileExtension(absolutePath);
|
|
458
|
-
|
|
459
|
-
const reference = this.create(CONTEXT_REFERENCE_TYPES.FILE, relativePath, name, options);
|
|
460
|
-
|
|
461
|
-
return {
|
|
462
|
-
...reference,
|
|
463
|
-
absolutePath,
|
|
464
|
-
relativePath,
|
|
465
|
-
extension,
|
|
466
|
-
exists: options.exists !== undefined ? options.exists : true,
|
|
467
|
-
stats: options.stats || null,
|
|
468
|
-
gitStatus: options.gitStatus || null,
|
|
469
|
-
dependencies: options.dependencies || null
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Create a selection reference
|
|
475
|
-
* @param {string} sourceFile - Source file path
|
|
476
|
-
* @param {string} selectedText - Selected text
|
|
477
|
-
* @param {Object} scope - Selection scope
|
|
478
|
-
* @param {Object} options - Additional options
|
|
479
|
-
* @returns {SelectionReference} Selection reference
|
|
480
|
-
*/
|
|
481
|
-
static createSelectionReference(sourceFile, selectedText, scope, options = {}) {
|
|
482
|
-
const name = options.name || this.generateSelectionName(sourceFile, scope);
|
|
483
|
-
|
|
484
|
-
const reference = this.create(CONTEXT_REFERENCE_TYPES.SELECTION, sourceFile, name, {
|
|
485
|
-
...options,
|
|
486
|
-
scope,
|
|
487
|
-
content: selectedText
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
return {
|
|
491
|
-
...reference,
|
|
492
|
-
sourceFile,
|
|
493
|
-
selectedText,
|
|
494
|
-
syntax: options.syntax || null,
|
|
495
|
-
context: options.context || null,
|
|
496
|
-
purpose: options.purpose || null
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Create a directory reference
|
|
502
|
-
* @param {string} absolutePath - Absolute directory path
|
|
503
|
-
* @param {string} relativePath - Relative directory path
|
|
504
|
-
* @param {Object} options - Additional options
|
|
505
|
-
* @returns {DirectoryReference} Directory reference
|
|
506
|
-
*/
|
|
507
|
-
static createDirectoryReference(absolutePath, relativePath, options = {}) {
|
|
508
|
-
const name = options.name || this.extractDirectoryName(absolutePath);
|
|
509
|
-
|
|
510
|
-
const reference = this.create(CONTEXT_REFERENCE_TYPES.DIRECTORY, relativePath, name, options);
|
|
511
|
-
|
|
512
|
-
return {
|
|
513
|
-
...reference,
|
|
514
|
-
absolutePath,
|
|
515
|
-
relativePath,
|
|
516
|
-
tree: options.tree || null,
|
|
517
|
-
fileCount: options.fileCount || null,
|
|
518
|
-
totalSize: options.totalSize || null,
|
|
519
|
-
fileTypes: options.fileTypes || null
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Create a component reference
|
|
525
|
-
* @param {string} componentType - Component type
|
|
526
|
-
* @param {string} path - Component path/identifier
|
|
527
|
-
* @param {string} name - Component name
|
|
528
|
-
* @param {Object} options - Additional options
|
|
529
|
-
* @returns {ComponentReference} Component reference
|
|
530
|
-
*/
|
|
531
|
-
static createComponentReference(componentType, path, name, options = {}) {
|
|
532
|
-
const reference = this.create(CONTEXT_REFERENCE_TYPES.COMPONENT, path, name, options);
|
|
533
|
-
|
|
534
|
-
return {
|
|
535
|
-
...reference,
|
|
536
|
-
componentType,
|
|
537
|
-
sourceFile: options.sourceFile || null,
|
|
538
|
-
properties: options.properties || null,
|
|
539
|
-
dependencies: options.dependencies || null,
|
|
540
|
-
documentation: options.documentation || null
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Create default metadata for reference type
|
|
546
|
-
* @param {string} type - Reference type
|
|
547
|
-
* @param {string} path - Reference path
|
|
548
|
-
* @param {Object} overrides - Metadata overrides
|
|
549
|
-
* @returns {ReferenceMetadata} Default metadata
|
|
550
|
-
*/
|
|
551
|
-
static createDefaultMetadata(type, path, overrides = {}) {
|
|
552
|
-
const metadata = {
|
|
553
|
-
language: null,
|
|
554
|
-
encoding: 'utf-8',
|
|
555
|
-
size: null,
|
|
556
|
-
mimeType: null,
|
|
557
|
-
checksum: null,
|
|
558
|
-
keywords: [],
|
|
559
|
-
description: '',
|
|
560
|
-
customFields: {},
|
|
561
|
-
icon: this.getDefaultIcon(type, path),
|
|
562
|
-
permissions: {},
|
|
563
|
-
...overrides
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
// Set language for file references
|
|
567
|
-
if (type === CONTEXT_REFERENCE_TYPES.FILE) {
|
|
568
|
-
const extension = this.extractFileExtension(path);
|
|
569
|
-
metadata.language = this.getLanguageFromExtension(extension);
|
|
570
|
-
metadata.mimeType = this.getMimeTypeFromExtension(extension);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
return metadata;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Generate unique reference ID
|
|
578
|
-
* @returns {string} Unique reference ID
|
|
579
|
-
*/
|
|
580
|
-
static generateReferenceId() {
|
|
581
|
-
const timestamp = Date.now().toString(36);
|
|
582
|
-
const random = Math.random().toString(36).substr(2, 9);
|
|
583
|
-
return `ref_${timestamp}_${random}`;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Extract file name from path
|
|
588
|
-
* @param {string} path - File path
|
|
589
|
-
* @returns {string} File name
|
|
590
|
-
*/
|
|
591
|
-
static extractFileName(path) {
|
|
592
|
-
return path.split(/[/\\]/).pop() || path;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* Extract directory name from path
|
|
597
|
-
* @param {string} path - Directory path
|
|
598
|
-
* @returns {string} Directory name
|
|
599
|
-
*/
|
|
600
|
-
static extractDirectoryName(path) {
|
|
601
|
-
const parts = path.split(/[/\\]/).filter(Boolean);
|
|
602
|
-
return parts[parts.length - 1] || 'Root';
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Extract file extension from path
|
|
607
|
-
* @param {string} path - File path
|
|
608
|
-
* @returns {string} File extension
|
|
609
|
-
*/
|
|
610
|
-
static extractFileExtension(path) {
|
|
611
|
-
const fileName = this.extractFileName(path);
|
|
612
|
-
const lastDot = fileName.lastIndexOf('.');
|
|
613
|
-
return lastDot !== -1 ? fileName.substring(lastDot) : '';
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
/**
|
|
617
|
-
* Generate selection name from file and scope
|
|
618
|
-
* @param {string} sourceFile - Source file path
|
|
619
|
-
* @param {Object} scope - Selection scope
|
|
620
|
-
* @returns {string} Selection name
|
|
621
|
-
*/
|
|
622
|
-
static generateSelectionName(sourceFile, scope) {
|
|
623
|
-
const fileName = this.extractFileName(sourceFile);
|
|
624
|
-
|
|
625
|
-
if (scope.startLine && scope.endLine) {
|
|
626
|
-
if (scope.startLine === scope.endLine) {
|
|
627
|
-
return `${fileName}:${scope.startLine}`;
|
|
628
|
-
} else {
|
|
629
|
-
return `${fileName}:${scope.startLine}-${scope.endLine}`;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
if (scope.functionName) {
|
|
634
|
-
return `${fileName}:${scope.functionName}()`;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
if (scope.className) {
|
|
638
|
-
return `${fileName}:${scope.className}`;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
return `${fileName} (selection)`;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* Get default icon for reference type and path
|
|
646
|
-
* @param {string} type - Reference type
|
|
647
|
-
* @param {string} path - Reference path
|
|
648
|
-
* @returns {string} Icon identifier
|
|
649
|
-
*/
|
|
650
|
-
static getDefaultIcon(type, path) {
|
|
651
|
-
if (type === CONTEXT_REFERENCE_TYPES.FILE) {
|
|
652
|
-
const extension = this.extractFileExtension(path);
|
|
653
|
-
return FILE_ICONS[extension] || CONTEXT_ICONS.DEFAULT;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
return CONTEXT_ICONS[type] || CONTEXT_ICONS.DEFAULT;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
/**
|
|
660
|
-
* Get programming language from file extension
|
|
661
|
-
* @param {string} extension - File extension
|
|
662
|
-
* @returns {string|null} Programming language
|
|
663
|
-
*/
|
|
664
|
-
static getLanguageFromExtension(extension) {
|
|
665
|
-
const languageMap = {
|
|
666
|
-
'.js': 'javascript',
|
|
667
|
-
'.jsx': 'javascript',
|
|
668
|
-
'.ts': 'typescript',
|
|
669
|
-
'.tsx': 'typescript',
|
|
670
|
-
'.py': 'python',
|
|
671
|
-
'.java': 'java',
|
|
672
|
-
'.cpp': 'cpp',
|
|
673
|
-
'.c': 'c',
|
|
674
|
-
'.cs': 'csharp',
|
|
675
|
-
'.php': 'php',
|
|
676
|
-
'.rb': 'ruby',
|
|
677
|
-
'.go': 'go',
|
|
678
|
-
'.rs': 'rust',
|
|
679
|
-
'.html': 'html',
|
|
680
|
-
'.css': 'css',
|
|
681
|
-
'.scss': 'scss',
|
|
682
|
-
'.json': 'json',
|
|
683
|
-
'.yml': 'yaml',
|
|
684
|
-
'.yaml': 'yaml',
|
|
685
|
-
'.xml': 'xml',
|
|
686
|
-
'.sql': 'sql',
|
|
687
|
-
'.md': 'markdown'
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
return languageMap[extension.toLowerCase()] || null;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Get MIME type from file extension
|
|
695
|
-
* @param {string} extension - File extension
|
|
696
|
-
* @returns {string|null} MIME type
|
|
697
|
-
*/
|
|
698
|
-
static getMimeTypeFromExtension(extension) {
|
|
699
|
-
const mimeMap = {
|
|
700
|
-
'.js': 'application/javascript',
|
|
701
|
-
'.jsx': 'application/javascript',
|
|
702
|
-
'.ts': 'application/typescript',
|
|
703
|
-
'.tsx': 'application/typescript',
|
|
704
|
-
'.py': 'text/x-python',
|
|
705
|
-
'.java': 'text/x-java-source',
|
|
706
|
-
'.cpp': 'text/x-c++src',
|
|
707
|
-
'.c': 'text/x-csrc',
|
|
708
|
-
'.cs': 'text/x-csharp',
|
|
709
|
-
'.php': 'application/x-php',
|
|
710
|
-
'.rb': 'application/x-ruby',
|
|
711
|
-
'.go': 'text/x-go',
|
|
712
|
-
'.rs': 'text/x-rust',
|
|
713
|
-
'.html': 'text/html',
|
|
714
|
-
'.css': 'text/css',
|
|
715
|
-
'.scss': 'text/x-scss',
|
|
716
|
-
'.json': 'application/json',
|
|
717
|
-
'.yml': 'application/x-yaml',
|
|
718
|
-
'.yaml': 'application/x-yaml',
|
|
719
|
-
'.xml': 'application/xml',
|
|
720
|
-
'.sql': 'application/sql',
|
|
721
|
-
'.md': 'text/markdown',
|
|
722
|
-
'.txt': 'text/plain'
|
|
723
|
-
};
|
|
724
|
-
|
|
725
|
-
return mimeMap[extension.toLowerCase()] || 'text/plain';
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* Context Reference utility functions
|
|
731
|
-
*/
|
|
732
|
-
export class ContextReferenceUtils {
|
|
733
|
-
/**
|
|
734
|
-
* Check if reference is still valid
|
|
735
|
-
* @param {ContextReference} reference - Reference to check
|
|
736
|
-
* @returns {boolean} True if valid
|
|
737
|
-
*/
|
|
738
|
-
static isValid(reference) {
|
|
739
|
-
return reference.isValid && !reference.invalidReason;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* Mark reference as accessed
|
|
744
|
-
* @param {ContextReference} reference - Reference to mark
|
|
745
|
-
* @returns {ContextReference} Updated reference
|
|
746
|
-
*/
|
|
747
|
-
static markAccessed(reference) {
|
|
748
|
-
return {
|
|
749
|
-
...reference,
|
|
750
|
-
lastAccessed: new Date().toISOString(),
|
|
751
|
-
accessCount: reference.accessCount + 1
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
/**
|
|
756
|
-
* Mark reference as invalid
|
|
757
|
-
* @param {ContextReference} reference - Reference to invalidate
|
|
758
|
-
* @param {string} reason - Reason for invalidation
|
|
759
|
-
* @returns {ContextReference} Updated reference
|
|
760
|
-
*/
|
|
761
|
-
static markInvalid(reference, reason) {
|
|
762
|
-
return {
|
|
763
|
-
...reference,
|
|
764
|
-
isValid: false,
|
|
765
|
-
invalidReason: reason
|
|
766
|
-
};
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
* Get reference display name with context
|
|
771
|
-
* @param {ContextReference} reference - Reference to format
|
|
772
|
-
* @returns {string} Display name
|
|
773
|
-
*/
|
|
774
|
-
static getDisplayName(reference) {
|
|
775
|
-
if (reference.type === CONTEXT_REFERENCE_TYPES.SELECTION && reference.scope) {
|
|
776
|
-
return ContextReferenceFactory.generateSelectionName(reference.path, reference.scope);
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
return reference.name;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Get reference description
|
|
784
|
-
* @param {ContextReference} reference - Reference to describe
|
|
785
|
-
* @returns {string} Description
|
|
786
|
-
*/
|
|
787
|
-
static getDescription(reference) {
|
|
788
|
-
if (reference.metadata?.description) {
|
|
789
|
-
return reference.metadata.description;
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
switch (reference.type) {
|
|
793
|
-
case CONTEXT_REFERENCE_TYPES.FILE:
|
|
794
|
-
return `File: ${reference.path}`;
|
|
795
|
-
case CONTEXT_REFERENCE_TYPES.DIRECTORY:
|
|
796
|
-
return `Directory: ${reference.path}`;
|
|
797
|
-
case CONTEXT_REFERENCE_TYPES.SELECTION:
|
|
798
|
-
return `Selection from ${reference.path}`;
|
|
799
|
-
case CONTEXT_REFERENCE_TYPES.COMPONENT:
|
|
800
|
-
return `Component: ${reference.name}`;
|
|
801
|
-
default:
|
|
802
|
-
return reference.path;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
* Calculate reference relevance score
|
|
808
|
-
* @param {ContextReference} reference - Reference to score
|
|
809
|
-
* @param {Object} context - Scoring context
|
|
810
|
-
* @returns {number} Relevance score (0-1)
|
|
811
|
-
*/
|
|
812
|
-
static calculateRelevance(reference, context = {}) {
|
|
813
|
-
let score = 0.5; // Base score
|
|
814
|
-
|
|
815
|
-
// Recent access bonus
|
|
816
|
-
if (reference.lastAccessed) {
|
|
817
|
-
const daysSinceAccess = (Date.now() - new Date(reference.lastAccessed)) / (1000 * 60 * 60 * 24);
|
|
818
|
-
score += Math.max(0, 0.2 * (1 - daysSinceAccess / 30)); // Decay over 30 days
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
// Access frequency bonus
|
|
822
|
-
if (reference.accessCount > 0) {
|
|
823
|
-
score += Math.min(0.2, reference.accessCount * 0.01);
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
// Type-specific scoring
|
|
827
|
-
switch (reference.type) {
|
|
828
|
-
case CONTEXT_REFERENCE_TYPES.FILE:
|
|
829
|
-
if (context.fileTypes && reference.metadata?.language) {
|
|
830
|
-
if (context.fileTypes.includes(reference.metadata.language)) {
|
|
831
|
-
score += 0.2;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
break;
|
|
835
|
-
case CONTEXT_REFERENCE_TYPES.SELECTION:
|
|
836
|
-
score += 0.1; // Selections are often more relevant
|
|
837
|
-
break;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
// Keyword matching
|
|
841
|
-
if (context.keywords && reference.metadata?.keywords) {
|
|
842
|
-
const matches = context.keywords.filter(k =>
|
|
843
|
-
reference.metadata.keywords.includes(k)
|
|
844
|
-
).length;
|
|
845
|
-
score += Math.min(0.3, matches * 0.1);
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
// Invalid references get heavy penalty
|
|
849
|
-
if (!reference.isValid) {
|
|
850
|
-
score *= 0.1;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
return Math.min(1, Math.max(0, score));
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
/**
|
|
857
|
-
* Group references by type
|
|
858
|
-
* @param {ContextReference[]} references - References to group
|
|
859
|
-
* @returns {Object} Grouped references
|
|
860
|
-
*/
|
|
861
|
-
static groupByType(references) {
|
|
862
|
-
return references.reduce((groups, reference) => {
|
|
863
|
-
const type = reference.type;
|
|
864
|
-
if (!groups[type]) {
|
|
865
|
-
groups[type] = [];
|
|
866
|
-
}
|
|
867
|
-
groups[type].push(reference);
|
|
868
|
-
return groups;
|
|
869
|
-
}, {});
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Sort references by relevance
|
|
874
|
-
* @param {ContextReference[]} references - References to sort
|
|
875
|
-
* @param {Object} context - Sorting context
|
|
876
|
-
* @returns {ContextReference[]} Sorted references
|
|
877
|
-
*/
|
|
878
|
-
static sortByRelevance(references, context = {}) {
|
|
879
|
-
return [...references].sort((a, b) => {
|
|
880
|
-
const scoreA = this.calculateRelevance(a, context);
|
|
881
|
-
const scoreB = this.calculateRelevance(b, context);
|
|
882
|
-
return scoreB - scoreA;
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
/**
|
|
887
|
-
* Filter references by criteria
|
|
888
|
-
* @param {ContextReference[]} references - References to filter
|
|
889
|
-
* @param {Object} criteria - Filter criteria
|
|
890
|
-
* @returns {ContextReference[]} Filtered references
|
|
891
|
-
*/
|
|
892
|
-
static filter(references, criteria = {}) {
|
|
893
|
-
return references.filter(reference => {
|
|
894
|
-
// Type filter
|
|
895
|
-
if (criteria.types && !criteria.types.includes(reference.type)) {
|
|
896
|
-
return false;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
// Valid filter
|
|
900
|
-
if (criteria.validOnly && !reference.isValid) {
|
|
901
|
-
return false;
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
// Language filter
|
|
905
|
-
if (criteria.languages && reference.metadata?.language) {
|
|
906
|
-
if (!criteria.languages.includes(reference.metadata.language)) {
|
|
907
|
-
return false;
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
// Path filter
|
|
912
|
-
if (criteria.pathPattern) {
|
|
913
|
-
const regex = new RegExp(criteria.pathPattern, 'i');
|
|
914
|
-
if (!regex.test(reference.path)) {
|
|
915
|
-
return false;
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
// Keyword filter
|
|
920
|
-
if (criteria.keywords && reference.metadata?.keywords) {
|
|
921
|
-
const hasKeyword = criteria.keywords.some(keyword =>
|
|
922
|
-
reference.metadata.keywords.includes(keyword)
|
|
923
|
-
);
|
|
924
|
-
if (!hasKeyword) {
|
|
925
|
-
return false;
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
// Date range filter
|
|
930
|
-
if (criteria.createdAfter) {
|
|
931
|
-
if (new Date(reference.createdAt) < new Date(criteria.createdAfter)) {
|
|
932
|
-
return false;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
if (criteria.createdBefore) {
|
|
937
|
-
if (new Date(reference.createdAt) > new Date(criteria.createdBefore)) {
|
|
938
|
-
return false;
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
return true;
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
/**
|
|
947
|
-
* Format reference for display
|
|
948
|
-
* @param {ContextReference} reference - Reference to format
|
|
949
|
-
* @returns {Object} Formatted reference
|
|
950
|
-
*/
|
|
951
|
-
static formatForDisplay(reference) {
|
|
952
|
-
return {
|
|
953
|
-
id: reference.id,
|
|
954
|
-
type: reference.type,
|
|
955
|
-
name: this.getDisplayName(reference),
|
|
956
|
-
description: this.getDescription(reference),
|
|
957
|
-
path: reference.path,
|
|
958
|
-
icon: reference.metadata?.icon || CONTEXT_ICONS[reference.type] || CONTEXT_ICONS.DEFAULT,
|
|
959
|
-
isValid: reference.isValid,
|
|
960
|
-
lastAccessed: reference.lastAccessed,
|
|
961
|
-
accessCount: reference.accessCount,
|
|
962
|
-
size: reference.metadata?.size || null,
|
|
963
|
-
language: reference.metadata?.language || null
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
export default {
|
|
969
|
-
ContextReferenceValidator,
|
|
970
|
-
ContextReferenceFactory,
|
|
971
|
-
ContextReferenceUtils
|
|
972
|
-
};
|
|
1
|
+
const a0_0x1f23c1=a0_0x43d8;(function(_0xb185bb,_0x137b4e){const _0x1e21c1=a0_0x43d8,_0x39319b=_0xb185bb();while(!![]){try{const _0x1150a8=-parseInt(_0x1e21c1(0x163))/0x1+-parseInt(_0x1e21c1(0x17d))/0x2*(parseInt(_0x1e21c1(0x15e))/0x3)+-parseInt(_0x1e21c1(0x1c4))/0x4*(parseInt(_0x1e21c1(0x181))/0x5)+-parseInt(_0x1e21c1(0x15d))/0x6*(parseInt(_0x1e21c1(0x15f))/0x7)+parseInt(_0x1e21c1(0x1a5))/0x8+-parseInt(_0x1e21c1(0x16e))/0x9*(-parseInt(_0x1e21c1(0x195))/0xa)+-parseInt(_0x1e21c1(0x180))/0xb*(-parseInt(_0x1e21c1(0x174))/0xc);if(_0x1150a8===_0x137b4e)break;else _0x39319b['push'](_0x39319b['shift']());}catch(_0x1f6f88){_0x39319b['push'](_0x39319b['shift']());}}}(a0_0x2e50,0xa0190));import{CONTEXT_REFERENCE_TYPES,FILE_EXTENSIONS,CONTEXT_ICONS}from'../utilities/constants.js';function a0_0x2e50(){const _0x2d008d=['mtm0mJbcBLfSs1y','C3rHDhm','y3jLyxrLzejLzM9Yzq','z2vUzxjHDgvszwzLCMvUy2vjza','C3rHCNrmAw5L','DMfSAwrpBMX5','vg90ywWGC2L6zsbTDxn0igjLigeGBM9Ulw5Lz2f0AxzLig51BwjLCG','C2vSzwn0zwruzxH0','zxH0CMfJDezPBgvoyw1L','rMLSzsbLEgLZDhmGzMXHzYbTDxn0igjLigeGyM9VBgvHBG','Dg90ywXtAxPL','CMvKDwnL','Bwv0ywrHDge','z2v0rgvMyxvSDeLJB24','zxH0CMfJDezPBgvfEhrLBNnPB24','u0vmrunusu9o','y3jLyxrLrgvMyxvSDe1LDgfKyxrH','A2v5D29Yzhm','twv0ywrHDgeGzw5JB2rPBMCGBxvZDcbIzsbHihn0CMLUzW','u291CMnLigzPBguGBxvZDcbIzsbHihn0CMLUzW','mtb3CxHYyKG','AxnbCNjHEq','zxH0zw5ZAw9U','y3jLyxrLrgLYzwn0B3j5uMvMzxjLBMnL','C3bSAxq','y3jLyxrLzefMDgvY','rMLSzsbJB3vUDcbTDxn0igjLigeGBM9Ulw5Lz2f0AxzLig51BwjLCG','twv0ywrHDgeGC2L6zsbTDxn0igjLigeGBM9Ulw5Lz2f0AxzLig51BwjLCG','C2nZCW','zMLSzunVDw50','Cgf0Aa','z2v0rgvZy3jPChrPB24','CMvSyxrPDMvqyxrO','Dgv4Dc94lxnJC3m','ywjZB2X1DgvqyxrO','C3vIC3rYAw5N','nty5odCYog5xu3vJza','EwfTBa','uMvMzxjLBMnLihbHDgGGAxmGCMvXDwLYzwqGyw5Kig11C3qGyMuGysbZDhjPBMC','ChL0Ag9U','zNvUy3rPB25oyw1L','C29Tzq','sw52ywXPzcbYzwzLCMvUy2uGDhLWztOG','sw52ywXPzcb0Aw1LC3rHBxaGzM9Yia','zMLSzvr5CgvZ','C2nVCgu','BgfUz3vHz2vZ','CNvIEq','yxbWBgLJyxrPB24VEc15yw1S','zxHJBhvKzvbHDgHZ','zMLSDgvY','zM9YrwfJAa','rMLSzsbLEhrLBNnPB24GBxvZDcbIzsbHihn0CMLUzW','BgfZDe1VzgLMAwvK','BgfZDefJy2vZC2vK','yxbWBgLJyxrPB24VANnVBG','z2L0u3rHDhvZ','Dgv4Dc94lwPHDMeTC291CMnL','DMfSAwrHDgvnzxrHzgf0yq','ig11C3qGyMuGysbUB24TBMvNyxrPDMuGBNvTyMvY','BM93','uMvMzxjLBMnLig5HBwuGAxmGCMvXDwLYzwqGyw5Kig11C3qGyMuGysbZDhjPBMC','y3jLyxrLrMLSzvjLzMvYzw5Jzq','AwnVBG','ig11C3qGyMuGyw4GyxjYyxK','DxrMltG','ChvYCg9Zzq','ntu2DgX0su51','Dg9ju09tDhjPBMC','rMLSztOG','CMvMxW','AxnwywXPza','Cgf0AfbHDhrLCM4','z2v0rgLZCgXHEu5HBwu','DhLWzxm','uMvMzxjLBMnLihr5CguGAxmGCMvXDwLYzwqGyw5Kig11C3qGyMuGysbZDhjPBMC','BNvTyMvY','icHZzwXLy3rPB24P','yxbWBgLJyxrPB24VAMf2yxnJCMLWDa','BwfYA0LUDMfSAwq','u2nVCguG','DhjLzq','BgfUz3vHz2u','AMf2yq','z2v0tgfUz3vHz2vgCM9TrxH0zw5ZAw9U','z2v0vgLTzq','u3rHCNqGy29SDw1Uig11C3qGyMuGpd0Gzw5KignVBhvTBG','AMf2yxnJCMLWDa','yxbWBgLJyxrPB24VC3fS','zw5JB2rPBMC','y2XHC3noyw1L','Dgv4Dc94lxb5DgHVBG','uMvMzxjLBMnLignVBNrLBNqGAxmGDMvYEsbSyxjNzsaOpJfnqIK','Aw5JBhvKzxm','ChvZAa','y3jLyxrLzef0','zgvZy3jPChrPB24','zxjYB3jZ','BMfTzq','ywnJzxnZq291BNq','rKLmrq','Dg9tDhjPBMC','zxH0CMfJDerPCMvJDg9YEu5HBwu','ndKYDenysMvM','odi5ofHHAMDzwG','mJm3nZLcEg9LEKG','zgvWzw5Kzw5JAwvZ','z2v0twLTzvr5CgvgCM9TrxH0zw5ZAw9U','C2L6zq','ntq3mtzcvLzSzM8','u2vSzwn0Aw9UigzYB20G','C3rHCNrdB2X1Bw4','C3LUDgf4','y29UDgvUDa','C3rYAw5N','C3vIC3rY','BgvUz3rO','zw5KtgLUzq','yxbWBgLJyxrPB24VDhLWzxnJCMLWDa','Aw52ywXPzfjLyxnVBG','mtaXmJG4mZrjqMvqz1G','DMfSAwrHDgvty29Wzq','Dgv4Dc9WBgfPBG','Bwf4','DhLWzq','y2fSy3vSyxrLuMvSzxzHBMnL','ode5otuXnMjNy2L3vW','DMfSAwrHDgu','zxHPC3rZ','DhLWzxnJCMLWDa','D2fYBMLUz3m','BwLU','AxnwywXPzfrPBwvZDgfTCa','rgLYzwn0B3j5oIa','y3jLyxrL','odm4vwrrvKvT','CMfUzg9T','Aw5JBhvKzvbHDgHZ','mtfMtunpywO'];a0_0x2e50=function(){return _0x2d008d;};return a0_0x2e50();}export class ContextReferenceValidator{static[a0_0x1f23c1(0x175)](_0x220c7e){const _0xd86893=a0_0x1f23c1,_0x216ebe=[],_0x5150a5=[];(!_0x220c7e['id']||typeof _0x220c7e['id']!=='string')&&_0x216ebe[_0xd86893(0x1df)]('Reference\x20ID\x20is\x20required\x20and\x20must\x20be\x20a\x20string');(!_0x220c7e[_0xd86893(0x172)]||typeof _0x220c7e['type']!==_0xd86893(0x168))&&_0x216ebe[_0xd86893(0x1df)](_0xd86893(0x1cc));(!_0x220c7e['path']||typeof _0x220c7e['path']!==_0xd86893(0x168))&&_0x216ebe['push'](_0xd86893(0x1a7));(!_0x220c7e['name']||typeof _0x220c7e[_0xd86893(0x1e3)]!=='string')&&_0x216ebe[_0xd86893(0x1df)](_0xd86893(0x1be));_0x220c7e['type']&&!Object['values'](CONTEXT_REFERENCE_TYPES)[_0xd86893(0x1de)](_0x220c7e['type'])&&_0x216ebe[_0xd86893(0x1df)](_0xd86893(0x1ab)+_0x220c7e['type']);_0x220c7e[_0xd86893(0x167)]&&typeof _0x220c7e[_0xd86893(0x167)]!==_0xd86893(0x168)&&_0x216ebe[_0xd86893(0x1df)]('Reference\x20content\x20must\x20be\x20a\x20string');_0x220c7e['content']&&_0x220c7e[_0xd86893(0x167)]['length']>0xf4240&&_0x5150a5[_0xd86893(0x1df)](_0xd86893(0x1dd));if(_0x220c7e[_0xd86893(0x18d)]){const _0x475b03=this[_0xd86893(0x1bb)](_0x220c7e[_0xd86893(0x18d)]);_0x216ebe[_0xd86893(0x1df)](..._0x475b03[_0xd86893(0x1e2)]),_0x5150a5['push'](..._0x475b03['warnings']);}if(_0x220c7e[_0xd86893(0x1ae)]){const _0x45194b=this[_0xd86893(0x16f)](_0x220c7e['scope']);_0x216ebe['push'](..._0x45194b[_0xd86893(0x1e2)]),_0x5150a5[_0xd86893(0x1df)](..._0x45194b[_0xd86893(0x178)]);}_0x220c7e[_0xd86893(0x1e4)]!==undefined&&typeof _0x220c7e['accessCount']!=='number'&&_0x216ebe[_0xd86893(0x1df)]('Access\x20count\x20must\x20be\x20a\x20number');const _0x2191b4=['createdAt',_0xd86893(0x1b7),_0xd86893(0x1b6)];_0x2191b4['forEach'](_0x4580ca=>{const _0x3676a7=_0xd86893;_0x220c7e[_0x4580ca]&&!this[_0x3676a7(0x17a)](_0x220c7e[_0x4580ca])&&_0x216ebe['push'](_0x3676a7(0x1ac)+_0x4580ca+':\x20'+_0x220c7e[_0x4580ca]);});switch(_0x220c7e[_0xd86893(0x172)]){case CONTEXT_REFERENCE_TYPES[_0xd86893(0x1e5)]:const _0x31d4cc=this['validateFileReference'](_0x220c7e);_0x216ebe['push'](..._0x31d4cc[_0xd86893(0x1e2)]),_0x5150a5['push'](..._0x31d4cc[_0xd86893(0x178)]);break;case CONTEXT_REFERENCE_TYPES[_0xd86893(0x190)]:const _0x9541c=this['validateSelectionReference'](_0x220c7e);_0x216ebe[_0xd86893(0x1df)](..._0x9541c['errors']),_0x5150a5[_0xd86893(0x1df)](..._0x9541c['warnings']);break;case CONTEXT_REFERENCE_TYPES['DIRECTORY']:const _0x177281=this['validateDirectoryReference'](_0x220c7e);_0x216ebe['push'](..._0x177281['errors']),_0x5150a5['push'](..._0x177281[_0xd86893(0x178)]);break;}return{'isValid':_0x216ebe[_0xd86893(0x16a)]===0x0,'errors':_0x216ebe,'warnings':_0x5150a5};}static['validateMetadata'](_0x54fcd2){const _0x11c2cf=a0_0x1f23c1,_0xd7e7df=[],_0x2ee065=[];return _0x54fcd2[_0x11c2cf(0x162)]!==undefined&&(typeof _0x54fcd2['size']!=='number'||_0x54fcd2[_0x11c2cf(0x162)]<0x0)&&_0xd7e7df[_0x11c2cf(0x1df)](_0x11c2cf(0x19c)),_0x54fcd2[_0x11c2cf(0x1d3)]&&typeof _0x54fcd2[_0x11c2cf(0x1d3)]!=='string'&&_0xd7e7df[_0x11c2cf(0x1df)]('Metadata\x20language\x20must\x20be\x20a\x20string'),_0x54fcd2['encoding']&&typeof _0x54fcd2[_0x11c2cf(0x1da)]!==_0x11c2cf(0x168)&&_0xd7e7df['push'](_0x11c2cf(0x193)),_0x54fcd2[_0x11c2cf(0x192)]&&!Array['isArray'](_0x54fcd2['keywords'])&&_0xd7e7df[_0x11c2cf(0x1df)]('Metadata\x20keywords\x20must\x20be\x20an\x20array'),_0x54fcd2['mimeType']&&typeof _0x54fcd2['mimeType']!=='string'&&_0xd7e7df[_0x11c2cf(0x1df)]('Metadata\x20MIME\x20type\x20must\x20be\x20a\x20string'),{'errors':_0xd7e7df,'warnings':_0x2ee065};}static['validateScope'](_0xe5469b){const _0x468ee9=a0_0x1f23c1,_0x2acac5=[],_0x59c5ec=[],_0x2765aa=[_0x468ee9(0x185),'endLine',_0x468ee9(0x165),'endColumn','maxDepth'];_0x2765aa[_0x468ee9(0x1b4)](_0x353178=>{const _0x14ce82=_0x468ee9;_0xe5469b[_0x353178]!==undefined&&(typeof _0xe5469b[_0x353178]!=='number'||_0xe5469b[_0x353178]<0x0)&&_0x2acac5['push'](_0x14ce82(0x1d1)+_0x353178+_0x14ce82(0x1bc));});_0xe5469b[_0x468ee9(0x185)]!==undefined&&_0xe5469b['endLine']!==undefined&&(_0xe5469b['startLine']>_0xe5469b['endLine']&&_0x2acac5['push']('Start\x20line\x20must\x20be\x20<=\x20end\x20line'));_0xe5469b[_0x468ee9(0x165)]!==undefined&&_0xe5469b['endColumn']!==undefined&&(_0xe5469b['startColumn']>_0xe5469b['endColumn']&&_0x2acac5['push'](_0x468ee9(0x1d7)));const _0x3e76ad=[_0x468ee9(0x17f),_0x468ee9(0x1b2)];return _0x3e76ad[_0x468ee9(0x1b4)](_0x20a266=>{const _0x1eb042=_0x468ee9;_0xe5469b[_0x20a266]&&!Array[_0x1eb042(0x196)](_0xe5469b[_0x20a266])&&_0x2acac5['push']('Scope\x20'+_0x20a266+_0x1eb042(0x1c1));}),{'errors':_0x2acac5,'warnings':_0x59c5ec};}static['validateFileReference'](_0xf2a16e){const _0xf9963=a0_0x1f23c1,_0x58f7e0=[],_0x229e7a=[];return _0xf2a16e['absolutePath']&&typeof _0xf2a16e[_0xf9963(0x1a3)]!==_0xf9963(0x168)&&_0x58f7e0[_0xf9963(0x1df)]('Absolute\x20path\x20must\x20be\x20a\x20string'),_0xf2a16e['relativePath']&&typeof _0xf2a16e[_0xf9963(0x1a1)]!==_0xf9963(0x168)&&_0x58f7e0['push']('Relative\x20path\x20must\x20be\x20a\x20string'),_0xf2a16e['extension']&&typeof _0xf2a16e[_0xf9963(0x197)]!=='string'&&_0x58f7e0[_0xf9963(0x1df)](_0xf9963(0x1b5)),_0xf2a16e['exists']!==undefined&&typeof _0xf2a16e[_0xf9963(0x176)]!=='boolean'&&_0x58f7e0['push'](_0xf9963(0x18a)),{'errors':_0x58f7e0,'warnings':_0x229e7a};}static['validateSelectionReference'](_0x37aa23){const _0x3d94f3=a0_0x1f23c1,_0x3e3673=[],_0xd701ac=[];return(!_0x37aa23[_0x3d94f3(0x1ae)]||!_0x37aa23['scope'][_0x3d94f3(0x185)]&&!_0x37aa23[_0x3d94f3(0x1ae)][_0x3d94f3(0x16b)])&&_0xd701ac[_0x3d94f3(0x1df)]('Selection\x20reference\x20should\x20have\x20line\x20scope\x20defined'),_0x37aa23[_0x3d94f3(0x188)]&&typeof _0x37aa23[_0x3d94f3(0x188)]!=='string'&&_0x3e3673['push']('Selected\x20text\x20must\x20be\x20a\x20string'),_0x37aa23['sourceFile']&&typeof _0x37aa23['sourceFile']!=='string'&&_0x3e3673[_0x3d94f3(0x1df)](_0x3d94f3(0x194)),{'errors':_0x3e3673,'warnings':_0xd701ac};}static['validateDirectoryReference'](_0x5a9f21){const _0x2d63db=a0_0x1f23c1,_0x58e578=[],_0x379d1e=[];return _0x5a9f21['fileCount']!==undefined&&(typeof _0x5a9f21[_0x2d63db(0x19e)]!==_0x2d63db(0x1cd)||_0x5a9f21['fileCount']<0x0)&&_0x58e578['push'](_0x2d63db(0x19b)),_0x5a9f21[_0x2d63db(0x18b)]!==undefined&&(typeof _0x5a9f21[_0x2d63db(0x18b)]!=='number'||_0x5a9f21['totalSize']<0x0)&&_0x58e578[_0x2d63db(0x1df)](_0x2d63db(0x187)),_0x5a9f21['fileTypes']&&!Array[_0x2d63db(0x196)](_0x5a9f21['fileTypes'])&&_0x58e578['push']('File\x20types\x20must\x20be\x20an\x20array'),{'errors':_0x58e578,'warnings':_0x379d1e};}static[a0_0x1f23c1(0x17a)](_0x1bee36){const _0x5bfeea=a0_0x1f23c1;if(typeof _0x1bee36!==_0x5bfeea(0x168))return![];const _0x291dbc=new Date(_0x1bee36);return _0x291dbc instanceof Date&&!isNaN(_0x291dbc[_0x5bfeea(0x1d6)]());}}export class ContextReferenceFactory{static[a0_0x1f23c1(0x17c)](_0x3921d0,_0x3d4b8e,_0x1859dd,_0x3d4adc={}){const _0x322135=a0_0x1f23c1,_0x26e952=new Date()[_0x322135(0x1c5)](),_0x3b0044=this[_0x322135(0x184)]();return{'id':_0x3b0044,'type':_0x3921d0,'path':_0x3d4b8e,'name':_0x1859dd,'content':_0x3d4adc['content']||null,'metadata':this[_0x322135(0x191)](_0x3921d0,_0x3d4b8e,_0x3d4adc['metadata']),'scope':_0x3d4adc['scope']||{},'createdAt':_0x26e952,'lastAccessed':null,'lastModified':_0x3d4adc[_0x322135(0x1b6)]||null,'isValid':!![],'invalidReason':null,'accessCount':0x0,'tags':_0x3d4adc['tags']||{}};}static[a0_0x1f23c1(0x1bf)](_0x5b1aa4,_0x1a945e,_0x645da2={}){const _0x13d91e=a0_0x1f23c1,_0x4aad87=_0x645da2['name']||this[_0x13d91e(0x189)](_0x5b1aa4),_0x227e23=this['extractFileExtension'](_0x5b1aa4),_0x23b58d=this['create'](CONTEXT_REFERENCE_TYPES[_0x13d91e(0x1e5)],_0x1a945e,_0x4aad87,_0x645da2);return{..._0x23b58d,'absolutePath':_0x5b1aa4,'relativePath':_0x1a945e,'extension':_0x227e23,'exists':_0x645da2[_0x13d91e(0x176)]!==undefined?_0x645da2[_0x13d91e(0x176)]:!![],'stats':_0x645da2[_0x13d91e(0x182)]||null,'gitStatus':_0x645da2[_0x13d91e(0x1b9)]||null,'dependencies':_0x645da2[_0x13d91e(0x160)]||null};}static['createSelectionReference'](_0x505661,_0x4b26ca,_0x4eb653,_0x2ce386={}){const _0xf827a2=a0_0x1f23c1,_0x4a64f7=_0x2ce386[_0xf827a2(0x1e3)]||this['generateSelectionName'](_0x505661,_0x4eb653),_0x1b1cde=this['create'](CONTEXT_REFERENCE_TYPES[_0xf827a2(0x190)],_0x505661,_0x4a64f7,{..._0x2ce386,'scope':_0x4eb653,'content':_0x4b26ca});return{..._0x1b1cde,'sourceFile':_0x505661,'selectedText':_0x4b26ca,'syntax':_0x2ce386[_0xf827a2(0x166)]||null,'context':_0x2ce386['context']||null,'purpose':_0x2ce386[_0xf827a2(0x1c3)]||null};}static[a0_0x1f23c1(0x198)](_0x261fe4,_0x359de9,_0x44405f={}){const _0x3d0ae0=a0_0x1f23c1,_0x1b9eba=_0x44405f[_0x3d0ae0(0x1e3)]||this['extractDirectoryName'](_0x261fe4),_0x4267a0=this['create'](CONTEXT_REFERENCE_TYPES['DIRECTORY'],_0x359de9,_0x1b9eba,_0x44405f);return{..._0x4267a0,'absolutePath':_0x261fe4,'relativePath':_0x359de9,'tree':_0x44405f[_0x3d0ae0(0x1d2)]||null,'fileCount':_0x44405f[_0x3d0ae0(0x19e)]||null,'totalSize':_0x44405f[_0x3d0ae0(0x18b)]||null,'fileTypes':_0x44405f[_0x3d0ae0(0x1ad)]||null};}static['createComponentReference'](_0xe4e474,_0x281dd9,_0x5cbd68,_0x1da01d={}){const _0x27bdaf=a0_0x1f23c1,_0x4ef957=this['create'](CONTEXT_REFERENCE_TYPES['COMPONENT'],_0x281dd9,_0x5cbd68,_0x1da01d);return{..._0x4ef957,'componentType':_0xe4e474,'sourceFile':_0x1da01d['sourceFile']||null,'properties':_0x1da01d['properties']||null,'dependencies':_0x1da01d[_0x27bdaf(0x160)]||null,'documentation':_0x1da01d['documentation']||null};}static['createDefaultMetadata'](_0x5531e0,_0x4c6df1,_0x4afd4e={}){const _0x20ea3e=a0_0x1f23c1,_0x35d777={'language':null,'encoding':_0x20ea3e(0x1c2),'size':null,'mimeType':null,'checksum':null,'keywords':[],'description':'','customFields':{},'icon':this[_0x20ea3e(0x18e)](_0x5531e0,_0x4c6df1),'permissions':{},..._0x4afd4e};if(_0x5531e0===CONTEXT_REFERENCE_TYPES[_0x20ea3e(0x1e5)]){const _0x409c74=this[_0x20ea3e(0x18f)](_0x4c6df1);_0x35d777[_0x20ea3e(0x1d3)]=this['getLanguageFromExtension'](_0x409c74),_0x35d777['mimeType']=this[_0x20ea3e(0x161)](_0x409c74);}return _0x35d777;}static['generateReferenceId'](){const _0x4e261e=a0_0x1f23c1,_0x73090=Date[_0x4e261e(0x1bd)]()[_0x4e261e(0x1e6)](0x24),_0x4996b2=Math[_0x4e261e(0x17e)]()[_0x4e261e(0x1e6)](0x24)[_0x4e261e(0x169)](0x2,0x9);return _0x4e261e(0x1c7)+_0x73090+'_'+_0x4996b2;}static['extractFileName'](_0x2cb158){return _0x2cb158['split'](/[/\\]/)['pop']()||_0x2cb158;}static[a0_0x1f23c1(0x1e7)](_0x4d267d){const _0x3d1662=a0_0x1f23c1,_0x17384e=_0x4d267d[_0x3d1662(0x199)](/[/\\]/)['filter'](Boolean);return _0x17384e[_0x17384e[_0x3d1662(0x16a)]-0x1]||'Root';}static[a0_0x1f23c1(0x18f)](_0x50140b){const _0x17f08e=a0_0x1f23c1,_0x535f05=this['extractFileName'](_0x50140b),_0x4acb11=_0x535f05['lastIndexOf']('.');return _0x4acb11!==-0x1?_0x535f05[_0x17f08e(0x1a4)](_0x4acb11):'';}static['generateSelectionName'](_0x201ecf,_0x33e8d6){const _0x5b7da0=a0_0x1f23c1,_0x14ca49=this[_0x5b7da0(0x189)](_0x201ecf);if(_0x33e8d6[_0x5b7da0(0x185)]&&_0x33e8d6[_0x5b7da0(0x16b)])return _0x33e8d6[_0x5b7da0(0x185)]===_0x33e8d6[_0x5b7da0(0x16b)]?_0x14ca49+':'+_0x33e8d6['startLine']:_0x14ca49+':'+_0x33e8d6['startLine']+'-'+_0x33e8d6['endLine'];if(_0x33e8d6[_0x5b7da0(0x1a9)])return _0x14ca49+':'+_0x33e8d6['functionName']+'()';if(_0x33e8d6[_0x5b7da0(0x1db)])return _0x14ca49+':'+_0x33e8d6['className'];return _0x14ca49+_0x5b7da0(0x1ce);}static['getDefaultIcon'](_0x1655cc,_0x4f4b9e){if(_0x1655cc===CONTEXT_REFERENCE_TYPES['FILE']){const _0x220bf8=this['extractFileExtension'](_0x4f4b9e);return FILE_ICONS[_0x220bf8]||CONTEXT_ICONS['DEFAULT'];}return CONTEXT_ICONS[_0x1655cc]||CONTEXT_ICONS['DEFAULT'];}static[a0_0x1f23c1(0x1d5)](_0x51c572){const _0x17cc6e=a0_0x1f23c1,_0x2a0e17={'.js':'javascript','.jsx':_0x17cc6e(0x1d8),'.ts':'typescript','.tsx':_0x17cc6e(0x177),'.py':_0x17cc6e(0x1a8),'.java':_0x17cc6e(0x1d4),'.cpp':'cpp','.c':'c','.cs':'csharp','.php':'php','.rb':_0x17cc6e(0x1b0),'.go':'go','.rs':'rust','.html':'html','.css':'css','.scss':_0x17cc6e(0x19d),'.json':'json','.yml':'yaml','.yaml':_0x17cc6e(0x1a6),'.xml':'xml','.sql':'sql','.md':'markdown'};return _0x2a0e17[_0x51c572['toLowerCase']()]||null;}static[a0_0x1f23c1(0x161)](_0x5195b){const _0xe648e7=a0_0x1f23c1,_0x59d092={'.js':'application/javascript','.jsx':_0xe648e7(0x1cf),'.ts':'application/typescript','.tsx':_0xe648e7(0x16c),'.py':_0xe648e7(0x1dc),'.java':_0xe648e7(0x1ba),'.cpp':'text/x-c++src','.c':'text/x-csrc','.cs':'text/x-csharp','.php':'application/x-php','.rb':'application/x-ruby','.go':'text/x-go','.rs':'text/x-rust','.html':'text/html','.css':'text/css','.scss':_0xe648e7(0x1a2),'.json':_0xe648e7(0x1b8),'.yml':_0xe648e7(0x1b1),'.yaml':_0xe648e7(0x1b1),'.xml':'application/xml','.sql':_0xe648e7(0x1d9),'.md':'text/markdown','.txt':_0xe648e7(0x170)};return _0x59d092[_0x5195b['toLowerCase']()]||'text/plain';}}export class ContextReferenceUtils{static[a0_0x1f23c1(0x1c8)](_0xfcca57){const _0x34d5da=a0_0x1f23c1;return _0xfcca57['isValid']&&!_0xfcca57[_0x34d5da(0x16d)];}static['markAccessed'](_0x27385b){return{..._0x27385b,'lastAccessed':new Date()['toISOString'](),'accessCount':_0x27385b['accessCount']+0x1};}static[a0_0x1f23c1(0x1d0)](_0x43bc13,_0x49c2d5){return{..._0x43bc13,'isValid':![],'invalidReason':_0x49c2d5};}static[a0_0x1f23c1(0x1ca)](_0x7c52d2){const _0x1f135f=a0_0x1f23c1;if(_0x7c52d2['type']===CONTEXT_REFERENCE_TYPES[_0x1f135f(0x190)]&&_0x7c52d2[_0x1f135f(0x1ae)])return ContextReferenceFactory['generateSelectionName'](_0x7c52d2[_0x1f135f(0x19f)],_0x7c52d2[_0x1f135f(0x1ae)]);return _0x7c52d2['name'];}static['getDescription'](_0x4a9805){const _0x2da584=a0_0x1f23c1;if(_0x4a9805[_0x2da584(0x18d)]?.['description'])return _0x4a9805[_0x2da584(0x18d)][_0x2da584(0x1e1)];switch(_0x4a9805['type']){case CONTEXT_REFERENCE_TYPES[_0x2da584(0x1e5)]:return _0x2da584(0x1c6)+_0x4a9805['path'];case CONTEXT_REFERENCE_TYPES['DIRECTORY']:return _0x2da584(0x17b)+_0x4a9805[_0x2da584(0x19f)];case CONTEXT_REFERENCE_TYPES['SELECTION']:return _0x2da584(0x164)+_0x4a9805['path'];case CONTEXT_REFERENCE_TYPES['COMPONENT']:return'Component:\x20'+_0x4a9805['name'];default:return _0x4a9805[_0x2da584(0x19f)];}}static[a0_0x1f23c1(0x173)](_0x560429,_0x344724={}){const _0xcf35db=a0_0x1f23c1;let _0x3710ee=0.5;if(_0x560429[_0xcf35db(0x1b7)]){const _0x3fa585=(Date['now']()-new Date(_0x560429['lastAccessed']))/(0x3e8*0x3c*0x3c*0x18);_0x3710ee+=Math[_0xcf35db(0x171)](0x0,0.2*(0x1-_0x3fa585/0x1e));}_0x560429['accessCount']>0x0&&(_0x3710ee+=Math[_0xcf35db(0x179)](0.2,_0x560429['accessCount']*0.01));switch(_0x560429['type']){case CONTEXT_REFERENCE_TYPES['FILE']:_0x344724[_0xcf35db(0x1ad)]&&_0x560429['metadata']?.[_0xcf35db(0x1d3)]&&(_0x344724['fileTypes']['includes'](_0x560429[_0xcf35db(0x18d)][_0xcf35db(0x1d3)])&&(_0x3710ee+=0.2));break;case CONTEXT_REFERENCE_TYPES['SELECTION']:_0x3710ee+=0.1;break;}if(_0x344724['keywords']&&_0x560429[_0xcf35db(0x18d)]?.[_0xcf35db(0x192)]){const _0x417598=_0x344724[_0xcf35db(0x192)][_0xcf35db(0x1b3)](_0x2de7fa=>_0x560429[_0xcf35db(0x18d)]['keywords'][_0xcf35db(0x1de)](_0x2de7fa))[_0xcf35db(0x16a)];_0x3710ee+=Math['min'](0.3,_0x417598*0.1);}return!_0x560429[_0xcf35db(0x1c8)]&&(_0x3710ee*=0.1),Math[_0xcf35db(0x179)](0x1,Math['max'](0x0,_0x3710ee));}static['groupByType'](_0x3d94b1){const _0x1e3068=a0_0x1f23c1;return _0x3d94b1[_0x1e3068(0x18c)]((_0xf4003,_0x1ec588)=>{const _0x3e6fae=_0x1ec588['type'];return!_0xf4003[_0x3e6fae]&&(_0xf4003[_0x3e6fae]=[]),_0xf4003[_0x3e6fae]['push'](_0x1ec588),_0xf4003;},{});}static['sortByRelevance'](_0x469b94,_0x193c0b={}){return[..._0x469b94]['sort']((_0x594006,_0xee3e76)=>{const _0x37feb8=a0_0x43d8,_0x3e8b31=this[_0x37feb8(0x173)](_0x594006,_0x193c0b),_0x5e36c1=this[_0x37feb8(0x173)](_0xee3e76,_0x193c0b);return _0x5e36c1-_0x3e8b31;});}static['filter'](_0x5b3518,_0x149a44={}){const _0xa55411=a0_0x1f23c1;return _0x5b3518[_0xa55411(0x1b3)](_0x2ad36b=>{const _0x3561b7=_0xa55411;if(_0x149a44['types']&&!_0x149a44[_0x3561b7(0x1cb)][_0x3561b7(0x1de)](_0x2ad36b['type']))return![];if(_0x149a44[_0x3561b7(0x186)]&&!_0x2ad36b['isValid'])return![];if(_0x149a44[_0x3561b7(0x1af)]&&_0x2ad36b['metadata']?.['language']){if(!_0x149a44['languages']['includes'](_0x2ad36b[_0x3561b7(0x18d)][_0x3561b7(0x1d3)]))return![];}if(_0x149a44['pathPattern']){const _0x48f147=new RegExp(_0x149a44[_0x3561b7(0x1c9)],'i');if(!_0x48f147['test'](_0x2ad36b[_0x3561b7(0x19f)]))return![];}if(_0x149a44[_0x3561b7(0x192)]&&_0x2ad36b['metadata']?.[_0x3561b7(0x192)]){const _0x46d6b0=_0x149a44['keywords'][_0x3561b7(0x1aa)](_0x41722b=>_0x2ad36b['metadata']['keywords']['includes'](_0x41722b));if(!_0x46d6b0)return![];}if(_0x149a44[_0x3561b7(0x19a)]){if(new Date(_0x2ad36b[_0x3561b7(0x1e0)])<new Date(_0x149a44[_0x3561b7(0x19a)]))return![];}if(_0x149a44['createdBefore']){if(new Date(_0x2ad36b[_0x3561b7(0x1e0)])>new Date(_0x149a44[_0x3561b7(0x183)]))return![];}return!![];});}static['formatForDisplay'](_0x32fd9e){const _0x2f3a34=a0_0x1f23c1;return{'id':_0x32fd9e['id'],'type':_0x32fd9e['type'],'name':this[_0x2f3a34(0x1ca)](_0x32fd9e),'description':this[_0x2f3a34(0x1a0)](_0x32fd9e),'path':_0x32fd9e[_0x2f3a34(0x19f)],'icon':_0x32fd9e[_0x2f3a34(0x18d)]?.[_0x2f3a34(0x1c0)]||CONTEXT_ICONS[_0x32fd9e[_0x2f3a34(0x172)]]||CONTEXT_ICONS['DEFAULT'],'isValid':_0x32fd9e[_0x2f3a34(0x1c8)],'lastAccessed':_0x32fd9e['lastAccessed'],'accessCount':_0x32fd9e[_0x2f3a34(0x1e4)],'size':_0x32fd9e['metadata']?.[_0x2f3a34(0x162)]||null,'language':_0x32fd9e[_0x2f3a34(0x18d)]?.['language']||null};}}function a0_0x43d8(_0x167d0e,_0x2448c8){_0x167d0e=_0x167d0e-0x15d;const _0x2e505a=a0_0x2e50();let _0x43d89a=_0x2e505a[_0x167d0e];if(a0_0x43d8['unCQsI']===undefined){var _0x1dc41c=function(_0x4a469d){const _0x12c093='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x220c7e='',_0x216ebe='';for(let _0x5150a5=0x0,_0x2191b4,_0x475b03,_0x45194b=0x0;_0x475b03=_0x4a469d['charAt'](_0x45194b++);~_0x475b03&&(_0x2191b4=_0x5150a5%0x4?_0x2191b4*0x40+_0x475b03:_0x475b03,_0x5150a5++%0x4)?_0x220c7e+=String['fromCharCode'](0xff&_0x2191b4>>(-0x2*_0x5150a5&0x6)):0x0){_0x475b03=_0x12c093['indexOf'](_0x475b03);}for(let _0x4580ca=0x0,_0x31d4cc=_0x220c7e['length'];_0x4580ca<_0x31d4cc;_0x4580ca++){_0x216ebe+='%'+('00'+_0x220c7e['charCodeAt'](_0x4580ca)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x216ebe);};a0_0x43d8['sWJkik']=_0x1dc41c,a0_0x43d8['tAPToj']={},a0_0x43d8['unCQsI']=!![];}const _0x46dde0=_0x2e505a[0x0],_0x11a4e5=_0x167d0e+_0x46dde0,_0x210f7c=a0_0x43d8['tAPToj'][_0x11a4e5];return!_0x210f7c?(_0x43d89a=a0_0x43d8['sWJkik'](_0x43d89a),a0_0x43d8['tAPToj'][_0x11a4e5]=_0x43d89a):_0x43d89a=_0x210f7c,_0x43d89a;}export default{'ContextReferenceValidator':ContextReferenceValidator,'ContextReferenceFactory':ContextReferenceFactory,'ContextReferenceUtils':ContextReferenceUtils};
|