mcp-adr-analysis-server 2.7.30 → 2.7.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/resources/adrs-review-resource.d.ts +0 -82
- package/dist/src/resources/adrs-review-resource.d.ts.map +0 -1
- package/dist/src/resources/adrs-review-resource.js +0 -160
- package/dist/src/resources/adrs-review-resource.js.map +0 -1
- package/dist/src/resources/architectural-context-resource.d.ts +0 -95
- package/dist/src/resources/architectural-context-resource.d.ts.map +0 -1
- package/dist/src/resources/architectural-context-resource.js +0 -428
- package/dist/src/resources/architectural-context-resource.js.map +0 -1
- package/dist/src/resources/memory-expand-resource.d.ts +0 -90
- package/dist/src/resources/memory-expand-resource.d.ts.map +0 -1
- package/dist/src/resources/memory-expand-resource.js +0 -176
- package/dist/src/resources/memory-expand-resource.js.map +0 -1
- package/dist/src/utils/bootstrap-task-integration.d.ts +0 -214
- package/dist/src/utils/bootstrap-task-integration.d.ts.map +0 -1
- package/dist/src/utils/bootstrap-task-integration.js +0 -365
- package/dist/src/utils/bootstrap-task-integration.js.map +0 -1
- package/dist/src/utils/index.d.ts +0 -9
- package/dist/src/utils/index.d.ts.map +0 -1
- package/dist/src/utils/index.js +0 -13
- package/dist/src/utils/index.js.map +0 -1
- package/dist/src/utils/interactive-approval.d.ts +0 -63
- package/dist/src/utils/interactive-approval.d.ts.map +0 -1
- package/dist/src/utils/interactive-approval.js +0 -445
- package/dist/src/utils/interactive-approval.js.map +0 -1
- package/dist/src/utils/llm-artifact-detector.d.ts +0 -76
- package/dist/src/utils/llm-artifact-detector.d.ts.map +0 -1
- package/dist/src/utils/llm-artifact-detector.js +0 -426
- package/dist/src/utils/llm-artifact-detector.js.map +0 -1
- package/dist/src/utils/location-filter.d.ts +0 -104
- package/dist/src/utils/location-filter.d.ts.map +0 -1
- package/dist/src/utils/location-filter.js +0 -593
- package/dist/src/utils/location-filter.js.map +0 -1
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM Artifact Detection System
|
|
3
|
-
*
|
|
4
|
-
* Detects files and content generated by LLMs that may not be suitable for production
|
|
5
|
-
* Focuses on development artifacts, debug scripts, and temporary files
|
|
6
|
-
*/
|
|
7
|
-
import { basename, dirname } from 'path';
|
|
8
|
-
/**
|
|
9
|
-
* Comprehensive LLM artifact patterns
|
|
10
|
-
*/
|
|
11
|
-
export const LLM_ARTIFACT_PATTERNS = [
|
|
12
|
-
// Debug Scripts
|
|
13
|
-
{
|
|
14
|
-
name: 'debug-script',
|
|
15
|
-
description: 'Debug script typically generated for troubleshooting',
|
|
16
|
-
category: 'debug',
|
|
17
|
-
severity: 'warning',
|
|
18
|
-
filePattern: /^debug_.*\.(py|js|ts|sh|rb|go|php|java)$/,
|
|
19
|
-
contentPattern: /print\s*\(\s*["'].*(?:debug|test|trace).*["']\s*\)|console\.log\s*\(\s*["'].*debug.*["']\s*\)|logging\.debug|debugger\s*;/i,
|
|
20
|
-
locationExceptions: ['debug/', 'scripts/', 'tools/', 'dev/', 'utils/'],
|
|
21
|
-
confidence: 0.8,
|
|
22
|
-
},
|
|
23
|
-
// Test Files in Wrong Location
|
|
24
|
-
{
|
|
25
|
-
name: 'misplaced-test',
|
|
26
|
-
description: 'Test file not in proper test directory',
|
|
27
|
-
category: 'testing',
|
|
28
|
-
severity: 'error',
|
|
29
|
-
filePattern: /^test_.*\.(py|js|ts|rb|go|php|java)$|.*\.test\.(js|ts|py)$|.*\.spec\.(js|ts|py)$/,
|
|
30
|
-
locationExceptions: ['tests/', 'test/', '__tests__/', 'spec/', 'specs/'],
|
|
31
|
-
confidence: 0.9,
|
|
32
|
-
},
|
|
33
|
-
// Mock/Fixture Files
|
|
34
|
-
{
|
|
35
|
-
name: 'mock-data',
|
|
36
|
-
description: 'Mock data or fixture files',
|
|
37
|
-
category: 'testing',
|
|
38
|
-
severity: 'info',
|
|
39
|
-
filePattern: /^mock_.*\.(json|js|ts|py|yaml|yml)$|^fixture_.*\.(json|js|ts|py|yaml|yml)$/,
|
|
40
|
-
contentPattern: /mock|fixture|dummy.*data|fake.*data|test.*data/i,
|
|
41
|
-
locationExceptions: ['tests/', 'test/', '__tests__/', 'fixtures/', 'mocks/', 'dev/'],
|
|
42
|
-
confidence: 0.7,
|
|
43
|
-
},
|
|
44
|
-
// Temporary Files
|
|
45
|
-
{
|
|
46
|
-
name: 'temporary-file',
|
|
47
|
-
description: 'Temporary file that should not be committed',
|
|
48
|
-
category: 'temporary',
|
|
49
|
-
severity: 'error',
|
|
50
|
-
filePattern: /^temp_.*|.*\.tmp$|.*\.temp$|.*\.bak$|.*\.orig$|^scratch_.*|^playground_.*/,
|
|
51
|
-
locationExceptions: ['tmp/', 'temp/', 'dev/'],
|
|
52
|
-
confidence: 0.9,
|
|
53
|
-
},
|
|
54
|
-
// Experimental Code
|
|
55
|
-
{
|
|
56
|
-
name: 'experimental-code',
|
|
57
|
-
description: 'Experimental or prototype code',
|
|
58
|
-
category: 'experimental',
|
|
59
|
-
severity: 'warning',
|
|
60
|
-
filePattern: /^experiment_.*|^poc_.*|^prototype_.*|^try_.*|^attempt_.*/,
|
|
61
|
-
contentPattern: /\/\*.*experiment.*\*\/|#.*experiment|\/\/.*experiment|TODO.*experiment/i,
|
|
62
|
-
locationExceptions: ['experiments/', 'poc/', 'prototypes/', 'dev/', 'playground/'],
|
|
63
|
-
confidence: 0.8,
|
|
64
|
-
},
|
|
65
|
-
// Tutorial/Learning Files
|
|
66
|
-
{
|
|
67
|
-
name: 'tutorial-file',
|
|
68
|
-
description: 'Tutorial or learning file with step-by-step instructions',
|
|
69
|
-
category: 'tutorial',
|
|
70
|
-
severity: 'info',
|
|
71
|
-
filePattern: /^tutorial_.*|^learn_.*|^example_.*|^demo_.*|^walkthrough_.*/,
|
|
72
|
-
contentPattern: /step\s+\d+|tutorial|walkthrough|follow.*along|this.*example.*shows/i,
|
|
73
|
-
locationExceptions: ['tutorials/', 'examples/', 'demos/', 'docs/', 'learning/'],
|
|
74
|
-
confidence: 0.7,
|
|
75
|
-
},
|
|
76
|
-
// Documentation Drafts
|
|
77
|
-
{
|
|
78
|
-
name: 'documentation-draft',
|
|
79
|
-
description: 'Draft documentation that may not be ready',
|
|
80
|
-
category: 'documentation',
|
|
81
|
-
severity: 'info',
|
|
82
|
-
filePattern: /^draft_.*\.md$|^notes_.*\.md$|^wip_.*\.md$|^todo_.*\.md$/,
|
|
83
|
-
contentPattern: /\[draft\]|\[wip\]|\[todo\]|work.*in.*progress|need.*to.*update/i,
|
|
84
|
-
locationExceptions: ['docs/', 'documentation/', 'drafts/', 'dev/'],
|
|
85
|
-
confidence: 0.6,
|
|
86
|
-
},
|
|
87
|
-
// LLM Conversation Logs
|
|
88
|
-
{
|
|
89
|
-
name: 'llm-conversation',
|
|
90
|
-
description: 'LLM conversation log or output',
|
|
91
|
-
category: 'temporary',
|
|
92
|
-
severity: 'warning',
|
|
93
|
-
filePattern: /^llm_.*|^ai_.*|^claude_.*|^gpt_.*|^chat_.*\.txt$|^conversation_.*\.txt$/,
|
|
94
|
-
contentPattern: /human:|assistant:|claude:|gpt:|user:|system:|you:|me:|i'll.*help.*you/i,
|
|
95
|
-
locationExceptions: ['dev/', 'logs/', 'temp/'],
|
|
96
|
-
confidence: 0.9,
|
|
97
|
-
},
|
|
98
|
-
// Analysis/Report Files
|
|
99
|
-
{
|
|
100
|
-
name: 'analysis-report',
|
|
101
|
-
description: 'Analysis or report file that may be temporary',
|
|
102
|
-
category: 'temporary',
|
|
103
|
-
severity: 'info',
|
|
104
|
-
filePattern: /^analysis_.*|^report_.*|^output_.*|^results_.*\.(txt|md|json|csv)$/,
|
|
105
|
-
contentPattern: /analysis.*results|generated.*on|report.*summary|output.*from/i,
|
|
106
|
-
locationExceptions: ['reports/', 'analysis/', 'output/', 'dev/'],
|
|
107
|
-
confidence: 0.5,
|
|
108
|
-
},
|
|
109
|
-
// Configuration Experiments
|
|
110
|
-
{
|
|
111
|
-
name: 'config-experiment',
|
|
112
|
-
description: 'Experimental configuration file',
|
|
113
|
-
category: 'experimental',
|
|
114
|
-
severity: 'warning',
|
|
115
|
-
filePattern: /^test_.*\.config\.(js|json|yaml|yml)$|^experiment_.*\.config\.(js|json|yaml|yml)$/,
|
|
116
|
-
contentPattern: /test.*config|experiment.*config|temporary.*config/i,
|
|
117
|
-
locationExceptions: ['configs/', 'dev/', 'experiments/'],
|
|
118
|
-
confidence: 0.7,
|
|
119
|
-
},
|
|
120
|
-
// Utility Scripts
|
|
121
|
-
{
|
|
122
|
-
name: 'utility-script',
|
|
123
|
-
description: 'Utility script that may be temporary',
|
|
124
|
-
category: 'debug',
|
|
125
|
-
severity: 'info',
|
|
126
|
-
filePattern: /^util_.*|^helper_.*|^tool_.*\.(py|js|ts|sh|rb)$/,
|
|
127
|
-
contentPattern: /quick.*script|helper.*function|utility.*tool|one.*time.*use/i,
|
|
128
|
-
locationExceptions: ['utils/', 'helpers/', 'tools/', 'scripts/'],
|
|
129
|
-
confidence: 0.6,
|
|
130
|
-
},
|
|
131
|
-
// Code Generation Artifacts
|
|
132
|
-
{
|
|
133
|
-
name: 'code-generation',
|
|
134
|
-
description: 'Generated code that may need review',
|
|
135
|
-
category: 'experimental',
|
|
136
|
-
severity: 'info',
|
|
137
|
-
filePattern: /^generated_.*|^auto_.*|^codegen_.*/,
|
|
138
|
-
contentPattern: /\/\*.*generated.*\*\/|#.*auto.*generated|\/\/.*generated|@generated/i,
|
|
139
|
-
locationExceptions: ['generated/', 'auto/', 'codegen/', 'build/'],
|
|
140
|
-
confidence: 0.8,
|
|
141
|
-
},
|
|
142
|
-
// Learning/Practice Files
|
|
143
|
-
{
|
|
144
|
-
name: 'learning-file',
|
|
145
|
-
description: 'Learning or practice file',
|
|
146
|
-
category: 'tutorial',
|
|
147
|
-
severity: 'info',
|
|
148
|
-
filePattern: /^practice_.*|^learning_.*|^exercise_.*|^kata_.*/,
|
|
149
|
-
contentPattern: /practice|exercise|kata|learning|studying|following.*tutorial/i,
|
|
150
|
-
locationExceptions: ['practice/', 'learning/', 'exercises/', 'dev/'],
|
|
151
|
-
confidence: 0.7,
|
|
152
|
-
},
|
|
153
|
-
// Verbose Comments (LLM-style)
|
|
154
|
-
{
|
|
155
|
-
name: 'verbose-comments',
|
|
156
|
-
description: 'Unusually verbose comments typical of LLM generation',
|
|
157
|
-
category: 'documentation',
|
|
158
|
-
severity: 'info',
|
|
159
|
-
combinedPattern: (_fileName, content) => {
|
|
160
|
-
// Check for excessive commenting ratio
|
|
161
|
-
const lines = content.split('\n');
|
|
162
|
-
const commentLines = lines.filter(line => line.trim().startsWith('//') ||
|
|
163
|
-
line.trim().startsWith('#') ||
|
|
164
|
-
line.trim().startsWith('/*') ||
|
|
165
|
-
line.trim().startsWith('*') ||
|
|
166
|
-
line.trim().startsWith('"""') ||
|
|
167
|
-
line.trim().startsWith("'''"));
|
|
168
|
-
// If more than 40% of lines are comments, it might be LLM-generated
|
|
169
|
-
const commentRatio = commentLines.length / lines.length;
|
|
170
|
-
return commentRatio > 0.4 && content.length > 500;
|
|
171
|
-
},
|
|
172
|
-
locationExceptions: ['docs/', 'examples/', 'tutorials/'],
|
|
173
|
-
confidence: 0.4,
|
|
174
|
-
},
|
|
175
|
-
];
|
|
176
|
-
/**
|
|
177
|
-
* Detect LLM artifacts in a file
|
|
178
|
-
*/
|
|
179
|
-
export function detectLLMArtifacts(filePath, content, customPatterns = []) {
|
|
180
|
-
const fileName = basename(filePath);
|
|
181
|
-
const dirPath = dirname(filePath);
|
|
182
|
-
const allPatterns = [...LLM_ARTIFACT_PATTERNS, ...customPatterns];
|
|
183
|
-
const matches = [];
|
|
184
|
-
// Check each pattern
|
|
185
|
-
for (const pattern of allPatterns) {
|
|
186
|
-
const patternMatches = checkPattern(pattern, fileName, content, filePath);
|
|
187
|
-
matches.push(...patternMatches);
|
|
188
|
-
}
|
|
189
|
-
// Calculate overall confidence
|
|
190
|
-
const overallConfidence = matches.length > 0
|
|
191
|
-
? matches.reduce((sum, match) => sum + match.confidence, 0) / matches.length
|
|
192
|
-
: 0;
|
|
193
|
-
// Determine severity
|
|
194
|
-
const severity = matches.length > 0
|
|
195
|
-
? matches.reduce((highest, match) => {
|
|
196
|
-
const severityOrder = { error: 3, warning: 2, info: 1 };
|
|
197
|
-
return severityOrder[match.pattern.severity] > severityOrder[highest]
|
|
198
|
-
? match.pattern.severity
|
|
199
|
-
: highest;
|
|
200
|
-
}, 'info')
|
|
201
|
-
: 'info';
|
|
202
|
-
// Check if current location is allowed
|
|
203
|
-
const allowedInCurrentLocation = matches.length === 0 ||
|
|
204
|
-
matches.every(match => match.pattern.locationExceptions.some(exception => dirPath.includes(exception) || dirPath.endsWith(exception.replace('/', ''))));
|
|
205
|
-
// Generate recommendations
|
|
206
|
-
const recommendations = generateRecommendations(matches, filePath, allowedInCurrentLocation);
|
|
207
|
-
return {
|
|
208
|
-
filePath,
|
|
209
|
-
isLLMArtifact: matches.length > 0,
|
|
210
|
-
matches,
|
|
211
|
-
overallConfidence,
|
|
212
|
-
severity,
|
|
213
|
-
recommendations,
|
|
214
|
-
allowedInCurrentLocation,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Check a specific pattern against file and content
|
|
219
|
-
*/
|
|
220
|
-
function checkPattern(pattern, fileName, content, filePath) {
|
|
221
|
-
const matches = [];
|
|
222
|
-
// Check filename pattern
|
|
223
|
-
if (pattern.filePattern && pattern.filePattern.test(fileName)) {
|
|
224
|
-
matches.push({
|
|
225
|
-
pattern,
|
|
226
|
-
matchType: 'filename',
|
|
227
|
-
match: fileName,
|
|
228
|
-
confidence: pattern.confidence,
|
|
229
|
-
suggestions: generateSuggestions(pattern, filePath, 'filename'),
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
// Check content pattern
|
|
233
|
-
if (pattern.contentPattern && content) {
|
|
234
|
-
const contentMatches = content.match(pattern.contentPattern);
|
|
235
|
-
if (contentMatches) {
|
|
236
|
-
const lines = content.split('\n');
|
|
237
|
-
for (let i = 0; i < lines.length; i++) {
|
|
238
|
-
if (pattern.contentPattern.test(lines[i])) {
|
|
239
|
-
matches.push({
|
|
240
|
-
pattern,
|
|
241
|
-
matchType: 'content',
|
|
242
|
-
match: lines[i] || '',
|
|
243
|
-
line: i + 1,
|
|
244
|
-
context: getLineContext(lines, i, 2),
|
|
245
|
-
confidence: pattern.confidence * 0.9, // Slightly lower confidence for content matches
|
|
246
|
-
suggestions: generateSuggestions(pattern, filePath, 'content'),
|
|
247
|
-
});
|
|
248
|
-
break; // Only report first match per pattern
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// Check combined pattern
|
|
254
|
-
if (pattern.combinedPattern && pattern.combinedPattern(fileName, content)) {
|
|
255
|
-
matches.push({
|
|
256
|
-
pattern,
|
|
257
|
-
matchType: 'combined',
|
|
258
|
-
match: 'Pattern detected in file structure and content',
|
|
259
|
-
confidence: pattern.confidence,
|
|
260
|
-
suggestions: generateSuggestions(pattern, filePath, 'combined'),
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
return matches;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Get context around a line
|
|
267
|
-
*/
|
|
268
|
-
function getLineContext(lines, lineIndex, contextSize) {
|
|
269
|
-
const start = Math.max(0, lineIndex - contextSize);
|
|
270
|
-
const end = Math.min(lines.length, lineIndex + contextSize + 1);
|
|
271
|
-
return lines.slice(start, end).join('\n');
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Generate suggestions for handling LLM artifacts
|
|
275
|
-
*/
|
|
276
|
-
function generateSuggestions(pattern, filePath, _matchType) {
|
|
277
|
-
const suggestions = [];
|
|
278
|
-
const fileName = basename(filePath);
|
|
279
|
-
// Category-specific suggestions
|
|
280
|
-
switch (pattern.category) {
|
|
281
|
-
case 'debug':
|
|
282
|
-
suggestions.push(`Move ${fileName} to scripts/ or tools/ directory`);
|
|
283
|
-
suggestions.push("Add to .gitignore if it's temporary");
|
|
284
|
-
suggestions.push('Remove debug logging before commit');
|
|
285
|
-
break;
|
|
286
|
-
case 'testing':
|
|
287
|
-
suggestions.push(`Move ${fileName} to tests/ directory`);
|
|
288
|
-
suggestions.push('Ensure test follows project testing conventions');
|
|
289
|
-
break;
|
|
290
|
-
case 'temporary':
|
|
291
|
-
suggestions.push('Remove file if no longer needed');
|
|
292
|
-
suggestions.push('Add to .gitignore');
|
|
293
|
-
suggestions.push('Move to tmp/ directory if needed');
|
|
294
|
-
break;
|
|
295
|
-
case 'experimental':
|
|
296
|
-
suggestions.push(`Move ${fileName} to experiments/ or dev/ directory`);
|
|
297
|
-
suggestions.push('Add documentation about experimental status');
|
|
298
|
-
suggestions.push('Consider if this should be in version control');
|
|
299
|
-
break;
|
|
300
|
-
case 'tutorial':
|
|
301
|
-
suggestions.push(`Move ${fileName} to examples/ or tutorials/ directory`);
|
|
302
|
-
suggestions.push('Add to documentation structure');
|
|
303
|
-
break;
|
|
304
|
-
case 'documentation':
|
|
305
|
-
suggestions.push(`Move ${fileName} to docs/ directory`);
|
|
306
|
-
suggestions.push('Review and finalize before committing');
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
// Location-specific suggestions
|
|
310
|
-
if (pattern.locationExceptions.length > 0) {
|
|
311
|
-
const allowedDirs = pattern.locationExceptions.join(', ');
|
|
312
|
-
suggestions.push(`Consider moving to: ${allowedDirs}`);
|
|
313
|
-
}
|
|
314
|
-
// Severity-specific suggestions
|
|
315
|
-
if (pattern.severity === 'error') {
|
|
316
|
-
suggestions.push('🚨 This file should not be committed in its current location');
|
|
317
|
-
}
|
|
318
|
-
else if (pattern.severity === 'warning') {
|
|
319
|
-
suggestions.push('⚠️ Review this file before committing');
|
|
320
|
-
}
|
|
321
|
-
return suggestions;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Generate recommendations for the overall result
|
|
325
|
-
*/
|
|
326
|
-
function generateRecommendations(matches, _filePath, allowedInCurrentLocation) {
|
|
327
|
-
const recommendations = [];
|
|
328
|
-
if (matches.length === 0) {
|
|
329
|
-
return ['File appears to be a legitimate source file'];
|
|
330
|
-
}
|
|
331
|
-
if (allowedInCurrentLocation) {
|
|
332
|
-
recommendations.push('✅ File is in an appropriate location for its type');
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
recommendations.push('❌ File should be moved to an appropriate directory');
|
|
336
|
-
// Add specific suggestions from matches
|
|
337
|
-
const uniqueSuggestions = new Set();
|
|
338
|
-
matches.forEach(match => {
|
|
339
|
-
match.suggestions.forEach(suggestion => {
|
|
340
|
-
if (suggestion.includes('Move') ||
|
|
341
|
-
suggestion.includes('scripts/') ||
|
|
342
|
-
suggestion.includes('tests/') ||
|
|
343
|
-
suggestion.includes('tools/')) {
|
|
344
|
-
uniqueSuggestions.add(suggestion);
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
uniqueSuggestions.forEach(suggestion => {
|
|
349
|
-
recommendations.push(suggestion);
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
// Count by severity
|
|
353
|
-
const errorCount = matches.filter(m => m.pattern.severity === 'error').length;
|
|
354
|
-
const warningCount = matches.filter(m => m.pattern.severity === 'warning').length;
|
|
355
|
-
if (errorCount > 0) {
|
|
356
|
-
recommendations.push(`🚨 ${errorCount} critical issue(s) - file should not be committed`);
|
|
357
|
-
}
|
|
358
|
-
if (warningCount > 0) {
|
|
359
|
-
recommendations.push(`⚠️ ${warningCount} warning(s) - review before committing`);
|
|
360
|
-
}
|
|
361
|
-
// Category-specific recommendations
|
|
362
|
-
const categories = [...new Set(matches.map(m => m.pattern.category))];
|
|
363
|
-
if (categories.includes('debug')) {
|
|
364
|
-
recommendations.push('Consider if debug code is needed in repository');
|
|
365
|
-
}
|
|
366
|
-
if (categories.includes('temporary')) {
|
|
367
|
-
recommendations.push('Remove temporary files before committing');
|
|
368
|
-
}
|
|
369
|
-
if (categories.includes('experimental')) {
|
|
370
|
-
recommendations.push('Move experimental code to appropriate directory');
|
|
371
|
-
}
|
|
372
|
-
return recommendations;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Batch analyze multiple files
|
|
376
|
-
*/
|
|
377
|
-
export function batchDetectLLMArtifacts(files, customPatterns = []) {
|
|
378
|
-
return files.map(file => detectLLMArtifacts(file.path, file.content, customPatterns));
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Get summary statistics for LLM artifact detection
|
|
382
|
-
*/
|
|
383
|
-
export function getLLMArtifactSummary(results) {
|
|
384
|
-
const summary = {
|
|
385
|
-
totalFiles: results.length,
|
|
386
|
-
artifactFiles: results.filter(r => r.isLLMArtifact).length,
|
|
387
|
-
allowedFiles: results.filter(r => r.allowedInCurrentLocation).length,
|
|
388
|
-
errorCount: results.filter(r => r.severity === 'error').length,
|
|
389
|
-
warningCount: results.filter(r => r.severity === 'warning').length,
|
|
390
|
-
infoCount: results.filter(r => r.severity === 'info').length,
|
|
391
|
-
categorySummary: {},
|
|
392
|
-
topPatterns: [],
|
|
393
|
-
};
|
|
394
|
-
// Count by category
|
|
395
|
-
const patternCounts = {};
|
|
396
|
-
for (const result of results) {
|
|
397
|
-
for (const match of result.matches) {
|
|
398
|
-
const category = match.pattern.category;
|
|
399
|
-
summary.categorySummary[category] = (summary.categorySummary[category] || 0) + 1;
|
|
400
|
-
const patternName = match.pattern.name;
|
|
401
|
-
patternCounts[patternName] = (patternCounts[patternName] || 0) + 1;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
// Top patterns
|
|
405
|
-
summary.topPatterns = Object.entries(patternCounts)
|
|
406
|
-
.sort((a, b) => b[1] - a[1])
|
|
407
|
-
.slice(0, 5)
|
|
408
|
-
.map(([name, count]) => ({ name, count }));
|
|
409
|
-
return summary;
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Create a custom LLM artifact pattern
|
|
413
|
-
*/
|
|
414
|
-
export function createLLMPattern(name, description, category, severity, options) {
|
|
415
|
-
return {
|
|
416
|
-
name,
|
|
417
|
-
description,
|
|
418
|
-
category,
|
|
419
|
-
severity,
|
|
420
|
-
...(options.filePattern && { filePattern: new RegExp(options.filePattern) }),
|
|
421
|
-
...(options.contentPattern && { contentPattern: new RegExp(options.contentPattern, 'i') }),
|
|
422
|
-
locationExceptions: options.locationExceptions || [],
|
|
423
|
-
confidence: options.confidence || 0.7,
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
//# sourceMappingURL=llm-artifact-detector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"llm-artifact-detector.js","sourceRoot":"","sources":["../../../src/utils/llm-artifact-detector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAkCzC;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAyB;IACzD,gBAAgB;IAChB;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,sDAAsD;QACnE,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,SAAS;QACnB,WAAW,EAAE,0CAA0C;QACvD,cAAc,EACZ,4HAA4H;QAC9H,kBAAkB,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;QACtE,UAAU,EAAE,GAAG;KAChB;IAED,+BAA+B;IAC/B;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,wCAAwC;QACrD,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,OAAO;QACjB,WAAW,EAAE,kFAAkF;QAC/F,kBAAkB,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,CAAC;QACxE,UAAU,EAAE,GAAG;KAChB;IAED,qBAAqB;IACrB;QACE,IAAI,EAAE,WAAW;QACjB,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AC,CAAC,CAAC;SAC3B,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAE7C,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,WAAmB,EACnB,QAAwC,EACxC,QAAwC,EACxC,OAKC;IAED,OAAO;QACL,IAAI;QACJ,WAAW;QACX,QAAQ;QACR,QAAQ;QACR,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5E,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,cAAc,EAAE,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,EAAE,CAAC;QAC1F,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,EAAE;QACpD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,GAAG;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enterprise Location-based filtering system with Tree-sitter intelligence
|
|
3
|
-
*
|
|
4
|
-
* Determines if files are in appropriate locations based on their type and content
|
|
5
|
-
* Enhanced with AI-powered code analysis for multi-language DevOps stacks
|
|
6
|
-
*/
|
|
7
|
-
import { type CodeAnalysisResult } from './tree-sitter-analyzer.js';
|
|
8
|
-
/**
|
|
9
|
-
* Rule for validating file locations based on type and content
|
|
10
|
-
*/
|
|
11
|
-
export interface LocationRule {
|
|
12
|
-
/** Name of the location rule */
|
|
13
|
-
name: string;
|
|
14
|
-
/** Description of what the rule validates */
|
|
15
|
-
description: string;
|
|
16
|
-
/** Pattern to match file names */
|
|
17
|
-
filePattern: RegExp;
|
|
18
|
-
/** Optional pattern to match file content */
|
|
19
|
-
contentPattern?: RegExp;
|
|
20
|
-
/** Paths where files matching this rule are allowed */
|
|
21
|
-
allowedPaths: string[];
|
|
22
|
-
/** Paths where files matching this rule are blocked */
|
|
23
|
-
blockedPaths: string[];
|
|
24
|
-
/** Severity level of violations */
|
|
25
|
-
severity: 'error' | 'warning' | 'info';
|
|
26
|
-
/** Category of the rule */
|
|
27
|
-
category: 'development' | 'security' | 'temporary' | 'testing';
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Result of location validation for a file
|
|
31
|
-
*/
|
|
32
|
-
export interface LocationValidationResult {
|
|
33
|
-
/** Whether the file location is valid */
|
|
34
|
-
isValid: boolean;
|
|
35
|
-
/** Rule that was matched (if any) */
|
|
36
|
-
rule?: LocationRule;
|
|
37
|
-
/** Current path of the file */
|
|
38
|
-
currentPath: string;
|
|
39
|
-
/** Suggested alternative paths */
|
|
40
|
-
suggestedPaths: string[];
|
|
41
|
-
/** Severity of the validation result */
|
|
42
|
-
severity: 'error' | 'warning' | 'info';
|
|
43
|
-
/** Human-readable validation message */
|
|
44
|
-
message: string;
|
|
45
|
-
/** Tree-sitter analysis results (if available) */
|
|
46
|
-
treeSitterAnalysis?: CodeAnalysisResult;
|
|
47
|
-
/** AI-powered intelligent reasons for the validation */
|
|
48
|
-
intelligentReasons?: string[];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Default location rules for common development artifacts
|
|
52
|
-
*/
|
|
53
|
-
export declare const DEFAULT_LOCATION_RULES: LocationRule[];
|
|
54
|
-
/**
|
|
55
|
-
* Enhanced file location validation with tree-sitter intelligence
|
|
56
|
-
*/
|
|
57
|
-
export declare function validateFileLocationIntelligent(filePath: string, content?: string, customRules?: LocationRule[]): Promise<LocationValidationResult>;
|
|
58
|
-
/**
|
|
59
|
-
* Legacy function for backward compatibility
|
|
60
|
-
* Validate file location against rules
|
|
61
|
-
*/
|
|
62
|
-
export declare function validateFileLocation(filePath: string, content?: string, customRules?: LocationRule[]): LocationValidationResult;
|
|
63
|
-
/**
|
|
64
|
-
* Get location suggestions for a file (backward compatible overloads)
|
|
65
|
-
*/
|
|
66
|
-
export declare function getLocationSuggestions(filePath: string, categoryOrDescription?: 'development' | 'security' | 'temporary' | 'testing' | string): string[] | {
|
|
67
|
-
suggestions: string[];
|
|
68
|
-
category: string;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Check if a file should be ignored based on common patterns
|
|
72
|
-
*/
|
|
73
|
-
export declare function shouldIgnoreFile(filePath: string): {
|
|
74
|
-
shouldIgnore: boolean;
|
|
75
|
-
reason: string;
|
|
76
|
-
severity: 'error' | 'warning' | 'info';
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Create a custom location rule
|
|
80
|
-
*/
|
|
81
|
-
export declare function createLocationRule(name: string, description: string, filePattern: string, allowedPaths: string[], blockedPaths?: string[], severity?: 'error' | 'warning' | 'info', category?: 'development' | 'security' | 'temporary' | 'testing', contentPattern?: string): LocationRule;
|
|
82
|
-
/**
|
|
83
|
-
* Load location rules from project configuration
|
|
84
|
-
*/
|
|
85
|
-
export declare function loadLocationRules(_projectPath: string): LocationRule[];
|
|
86
|
-
/**
|
|
87
|
-
* Validate multiple files at once
|
|
88
|
-
*/
|
|
89
|
-
export declare function validateMultipleFiles(filePaths: string[], fileContents?: string[], customRules?: LocationRule[]): LocationValidationResult[];
|
|
90
|
-
/**
|
|
91
|
-
* Get summary statistics for location validation
|
|
92
|
-
*/
|
|
93
|
-
export declare function getLocationValidationSummary(results: Array<LocationValidationResult & {
|
|
94
|
-
filePath: string;
|
|
95
|
-
}>): {
|
|
96
|
-
totalFiles: number;
|
|
97
|
-
validFiles: number;
|
|
98
|
-
invalidFiles: number;
|
|
99
|
-
errorCount: number;
|
|
100
|
-
warningCount: number;
|
|
101
|
-
infoCount: number;
|
|
102
|
-
categorySummary: Record<string, number>;
|
|
103
|
-
};
|
|
104
|
-
//# sourceMappingURL=location-filter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"location-filter.d.ts","sourceRoot":"","sources":["../../../src/utils/location-filter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,uDAAuD;IACvD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mCAAmC;IACnC,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC,2BAA2B;IAC3B,QAAQ,EAAE,aAAa,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;CAChE;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,wCAAwC;IACxC,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,wDAAwD;IACxD,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,YAAY,EA8MhD,CAAC;AAqBF;;GAEG;AACH,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