@dependabit/detector 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/detector.d.ts +64 -0
- package/dist/detector.d.ts.map +1 -0
- package/dist/detector.js +578 -0
- package/dist/detector.js.map +1 -0
- package/dist/diff-parser.d.ts +53 -0
- package/dist/diff-parser.d.ts.map +1 -0
- package/dist/diff-parser.js +203 -0
- package/dist/diff-parser.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/client.d.ts +65 -0
- package/dist/llm/client.d.ts.map +1 -0
- package/dist/llm/client.js +12 -0
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/copilot.d.ts +15 -0
- package/dist/llm/copilot.d.ts.map +1 -0
- package/dist/llm/copilot.js +119 -0
- package/dist/llm/copilot.js.map +1 -0
- package/dist/llm/prompts.d.ts +10 -0
- package/dist/llm/prompts.d.ts.map +1 -0
- package/dist/llm/prompts.js +94 -0
- package/dist/llm/prompts.js.map +1 -0
- package/dist/parsers/code-comments.d.ts +23 -0
- package/dist/parsers/code-comments.d.ts.map +1 -0
- package/dist/parsers/code-comments.js +139 -0
- package/dist/parsers/code-comments.js.map +1 -0
- package/dist/parsers/package-files.d.ts +31 -0
- package/dist/parsers/package-files.d.ts.map +1 -0
- package/dist/parsers/package-files.js +130 -0
- package/dist/parsers/package-files.js.map +1 -0
- package/dist/parsers/readme.d.ts +23 -0
- package/dist/parsers/readme.d.ts.map +1 -0
- package/dist/parsers/readme.js +151 -0
- package/dist/parsers/readme.js.map +1 -0
- package/package.json +41 -0
- package/src/detector.ts +746 -0
- package/src/diff-parser.ts +257 -0
- package/src/index.ts +43 -0
- package/src/llm/client.ts +85 -0
- package/src/llm/copilot.ts +147 -0
- package/src/llm/prompts.ts +102 -0
- package/src/parsers/code-comments.ts +178 -0
- package/src/parsers/package-files.ts +156 -0
- package/src/parsers/readme.ts +185 -0
- package/test/detector.test.ts +102 -0
- package/test/diff-parser.test.ts +187 -0
- package/test/llm/client.test.ts +31 -0
- package/test/llm/copilot.test.ts +55 -0
- package/test/parsers/code-comments.test.ts +98 -0
- package/test/parsers/package-files.test.ts +52 -0
- package/test/parsers/readme.test.ts +52 -0
- package/tsconfig.json +10 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/detector.js
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detector Orchestrator
|
|
3
|
+
* Coordinates content parsers and LLM analysis to detect external dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
6
|
+
import { join, relative, resolve, normalize, sep } from 'node:path';
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { createClassificationPrompt } from './llm/prompts.js';
|
|
9
|
+
import { parseReadme } from './parsers/readme.js';
|
|
10
|
+
import { parseCodeComments } from './parsers/code-comments.js';
|
|
11
|
+
import { parsePackageJson, parseRequirementsTxt, parseCargoToml, parseGoMod } from './parsers/package-files.js';
|
|
12
|
+
const DEFAULT_IGNORE_PATTERNS = [
|
|
13
|
+
'node_modules',
|
|
14
|
+
'.git',
|
|
15
|
+
'dist',
|
|
16
|
+
'build',
|
|
17
|
+
'target',
|
|
18
|
+
'vendor',
|
|
19
|
+
'.venv',
|
|
20
|
+
'venv',
|
|
21
|
+
'__pycache__',
|
|
22
|
+
'coverage',
|
|
23
|
+
'.next',
|
|
24
|
+
'.nuxt'
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Main detector class
|
|
28
|
+
*/
|
|
29
|
+
export class Detector {
|
|
30
|
+
options;
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this.options = {
|
|
33
|
+
...options,
|
|
34
|
+
ignorePatterns: options.ignorePatterns || DEFAULT_IGNORE_PATTERNS
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Detect all external dependencies in the repository
|
|
39
|
+
*
|
|
40
|
+
* Implementation follows a hybrid approach:
|
|
41
|
+
* 1. Programmatic parsing of repository files (README, code comments, package files)
|
|
42
|
+
* 2. LLM analysis only for documents not fully parsed in step 1 (future enhancement)
|
|
43
|
+
* 3. Programmatic type categorization based on URL patterns and context
|
|
44
|
+
* 4. LLM fallback for uncategorized dependencies
|
|
45
|
+
* 5. Programmatic access method determination based on URL patterns
|
|
46
|
+
* 6. LLM fallback for access methods that can't be determined (future enhancement)
|
|
47
|
+
* 7. Manifest entry creation with references and versioning
|
|
48
|
+
*/
|
|
49
|
+
async detectDependencies() {
|
|
50
|
+
const allReferences = new Map();
|
|
51
|
+
let filesScanned = 0;
|
|
52
|
+
let llmCalls = 0;
|
|
53
|
+
let totalTokens = 0;
|
|
54
|
+
let totalLatencyMs = 0;
|
|
55
|
+
// Step 1: Parse repository for dependencies (programmatic)
|
|
56
|
+
// 1a. Parse README files
|
|
57
|
+
const readmeFiles = await this.findFiles(this.options.repoPath, /^README/i);
|
|
58
|
+
for (const file of readmeFiles) {
|
|
59
|
+
const content = await readFile(file, 'utf-8');
|
|
60
|
+
const references = parseReadme(content, relative(this.options.repoPath, file));
|
|
61
|
+
for (const ref of references) {
|
|
62
|
+
this.addReference(allReferences, ref.url, {
|
|
63
|
+
file: relative(this.options.repoPath, file),
|
|
64
|
+
...(ref.line !== undefined && { line: ref.line }),
|
|
65
|
+
text: ref.context
|
|
66
|
+
}, 'llm-analysis');
|
|
67
|
+
}
|
|
68
|
+
filesScanned++;
|
|
69
|
+
}
|
|
70
|
+
// 1b. Parse package files for metadata (NOT dependencies)
|
|
71
|
+
const packageFiles = await this.findPackageFiles(this.options.repoPath);
|
|
72
|
+
for (const file of packageFiles) {
|
|
73
|
+
const content = await readFile(file, 'utf-8');
|
|
74
|
+
const metadata = this.parsePackageFile(file, content);
|
|
75
|
+
for (const url of [
|
|
76
|
+
...(metadata.urls || []),
|
|
77
|
+
metadata.repository,
|
|
78
|
+
metadata.homepage,
|
|
79
|
+
metadata.documentation
|
|
80
|
+
].filter(Boolean)) {
|
|
81
|
+
this.addReference(allReferences, url, {
|
|
82
|
+
file: relative(this.options.repoPath, file),
|
|
83
|
+
text: 'Package metadata'
|
|
84
|
+
}, 'package-json');
|
|
85
|
+
}
|
|
86
|
+
filesScanned++;
|
|
87
|
+
}
|
|
88
|
+
// 1c. Parse code comments from source files
|
|
89
|
+
const sourceFiles = await this.findSourceFiles(this.options.repoPath);
|
|
90
|
+
for (const file of sourceFiles.slice(0, 50)) {
|
|
91
|
+
// Limit to 50 files for performance
|
|
92
|
+
const content = await readFile(file, 'utf-8');
|
|
93
|
+
const references = parseCodeComments(content, relative(this.options.repoPath, file));
|
|
94
|
+
for (const ref of references) {
|
|
95
|
+
this.addReference(allReferences, ref.url, {
|
|
96
|
+
file: ref.file,
|
|
97
|
+
line: ref.line,
|
|
98
|
+
text: ref.context
|
|
99
|
+
}, 'code-comment');
|
|
100
|
+
}
|
|
101
|
+
filesScanned++;
|
|
102
|
+
}
|
|
103
|
+
// Step 2: LLM 2nd pass for documents not fully parsed in step 1
|
|
104
|
+
// Analyze README files for dependency context that parsers might have missed
|
|
105
|
+
const llmEnhancedReferences = new Set();
|
|
106
|
+
for (const file of readmeFiles.slice(0, 5)) {
|
|
107
|
+
// Limit to 5 READMEs for LLM analysis
|
|
108
|
+
try {
|
|
109
|
+
const content = await readFile(file, 'utf-8');
|
|
110
|
+
const relPath = relative(this.options.repoPath, file);
|
|
111
|
+
// Use LLM to extract additional context from README
|
|
112
|
+
const detectionPrompt = `Analyze this README file and identify any external dependencies or resources that might be referenced but not explicitly linked:
|
|
113
|
+
|
|
114
|
+
File: ${relPath}
|
|
115
|
+
Content:
|
|
116
|
+
${content.slice(0, 5000)}
|
|
117
|
+
|
|
118
|
+
Identify:
|
|
119
|
+
1. Documentation sites mentioned but not linked
|
|
120
|
+
2. Tools or libraries referenced in text
|
|
121
|
+
3. API services mentioned
|
|
122
|
+
4. Research papers or specifications cited
|
|
123
|
+
|
|
124
|
+
Return as JSON with "dependencies" array.`;
|
|
125
|
+
const response = await this.options.llmProvider.analyze(content, detectionPrompt);
|
|
126
|
+
llmCalls++;
|
|
127
|
+
totalTokens += response.usage.totalTokens;
|
|
128
|
+
totalLatencyMs += response.usage.latencyMs;
|
|
129
|
+
// Add LLM-discovered references
|
|
130
|
+
for (const dep of response.dependencies) {
|
|
131
|
+
if (dep.url && !allReferences.has(dep.url)) {
|
|
132
|
+
llmEnhancedReferences.add(dep.url);
|
|
133
|
+
this.addReference(allReferences, dep.url, {
|
|
134
|
+
file: relPath,
|
|
135
|
+
text: dep.description || 'Discovered by LLM analysis'
|
|
136
|
+
}, 'llm-analysis');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
console.error(`LLM document analysis failed for ${file}:`, error);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Steps 3-6: Categorize dependencies (programmatic first, LLM fallback)
|
|
145
|
+
const dependencies = [];
|
|
146
|
+
const now = new Date().toISOString();
|
|
147
|
+
for (const [url, data] of allReferences) {
|
|
148
|
+
// Prepare context for potential LLM use
|
|
149
|
+
const context = data.contexts
|
|
150
|
+
.map((c) => `${c.file}${c.line ? `:${c.line}` : ''}: ${c.text}`)
|
|
151
|
+
.join('\n');
|
|
152
|
+
const firstContext = data.contexts[0]?.text || '';
|
|
153
|
+
// Step 3: Try programmatic type categorization
|
|
154
|
+
let type = this.determineDependencyType(url, firstContext);
|
|
155
|
+
let typeConfidence = type ? 0.9 : 0.5; // High confidence for programmatic
|
|
156
|
+
// Step 4: If type couldn't be determined, use LLM fallback
|
|
157
|
+
if (!type) {
|
|
158
|
+
try {
|
|
159
|
+
const classificationPrompt = createClassificationPrompt(url, context);
|
|
160
|
+
const response = await this.options.llmProvider.analyze('', classificationPrompt);
|
|
161
|
+
llmCalls++;
|
|
162
|
+
totalTokens += response.usage.totalTokens;
|
|
163
|
+
totalLatencyMs += response.usage.latencyMs;
|
|
164
|
+
if (response.dependencies.length > 0) {
|
|
165
|
+
const dep = response.dependencies[0];
|
|
166
|
+
if (dep) {
|
|
167
|
+
type = dep.type;
|
|
168
|
+
typeConfidence = dep.confidence;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
console.error(`LLM classification failed for ${url}:`, error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// Default to 'other' if still not determined
|
|
177
|
+
if (!type) {
|
|
178
|
+
type = 'other';
|
|
179
|
+
typeConfidence = 0.3;
|
|
180
|
+
}
|
|
181
|
+
// Step 5: Try programmatic access method determination
|
|
182
|
+
let accessMethod = this.determineAccessMethod(url);
|
|
183
|
+
// Step 6: If access method couldn't be determined, use LLM fallback
|
|
184
|
+
if (!accessMethod) {
|
|
185
|
+
try {
|
|
186
|
+
const accessMethodPrompt = `Determine the best access method for this URL: ${url}
|
|
187
|
+
|
|
188
|
+
Context: ${firstContext}
|
|
189
|
+
|
|
190
|
+
Choose ONE of these access methods:
|
|
191
|
+
- "github-api": For GitHub repositories
|
|
192
|
+
- "arxiv": For arXiv papers
|
|
193
|
+
- "openapi": For API specifications
|
|
194
|
+
- "context7": For Context7 documentation
|
|
195
|
+
- "http": For general web resources
|
|
196
|
+
|
|
197
|
+
Return as JSON: {"accessMethod": "...", "confidence": 0.0-1.0}`;
|
|
198
|
+
const response = await this.options.llmProvider.analyze('', accessMethodPrompt);
|
|
199
|
+
llmCalls++;
|
|
200
|
+
totalTokens += response.usage.totalTokens;
|
|
201
|
+
totalLatencyMs += response.usage.latencyMs;
|
|
202
|
+
// Parse LLM response for access method
|
|
203
|
+
const content = response.rawResponse || '{}';
|
|
204
|
+
try {
|
|
205
|
+
const parsed = JSON.parse(content);
|
|
206
|
+
if (parsed.accessMethod) {
|
|
207
|
+
accessMethod = parsed.accessMethod;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
// If parsing fails, fall back to http
|
|
212
|
+
accessMethod = 'http';
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
console.error(`LLM access method determination failed for ${url}:`, error);
|
|
217
|
+
accessMethod = 'http';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// Ensure we have a valid access method
|
|
221
|
+
if (!accessMethod) {
|
|
222
|
+
accessMethod = 'http';
|
|
223
|
+
}
|
|
224
|
+
// Step 7: Create manifest entry with references and versioning
|
|
225
|
+
const entry = {
|
|
226
|
+
id: randomUUID(),
|
|
227
|
+
url,
|
|
228
|
+
type,
|
|
229
|
+
accessMethod,
|
|
230
|
+
name: this.extractName(url),
|
|
231
|
+
description: firstContext,
|
|
232
|
+
currentVersion: undefined,
|
|
233
|
+
currentStateHash: '', // Will be populated by monitor
|
|
234
|
+
detectionMethod: data.detectionMethod,
|
|
235
|
+
detectionConfidence: typeConfidence,
|
|
236
|
+
detectedAt: now,
|
|
237
|
+
lastChecked: now,
|
|
238
|
+
auth: undefined,
|
|
239
|
+
monitoring: {
|
|
240
|
+
enabled: true,
|
|
241
|
+
checkFrequency: 'daily',
|
|
242
|
+
ignoreChanges: false
|
|
243
|
+
},
|
|
244
|
+
referencedIn: data.contexts.map((c) => ({
|
|
245
|
+
file: c.file,
|
|
246
|
+
line: c.line,
|
|
247
|
+
context: c.text
|
|
248
|
+
})),
|
|
249
|
+
changeHistory: []
|
|
250
|
+
};
|
|
251
|
+
dependencies.push(entry);
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
dependencies,
|
|
255
|
+
statistics: {
|
|
256
|
+
filesScanned,
|
|
257
|
+
urlsFound: allReferences.size,
|
|
258
|
+
llmCalls,
|
|
259
|
+
totalTokens,
|
|
260
|
+
totalLatencyMs
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
addReference(map, url, context, detectionMethod) {
|
|
265
|
+
if (!map.has(url)) {
|
|
266
|
+
map.set(url, {
|
|
267
|
+
url,
|
|
268
|
+
contexts: [],
|
|
269
|
+
detectionMethod
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
map.get(url).contexts.push(context);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Programmatically determine access method based on URL patterns
|
|
276
|
+
* Returns null if cannot be determined programmatically
|
|
277
|
+
*/
|
|
278
|
+
determineAccessMethod(url) {
|
|
279
|
+
// GitHub URLs
|
|
280
|
+
if (url.includes('github.com'))
|
|
281
|
+
return 'github-api';
|
|
282
|
+
// arXiv papers
|
|
283
|
+
if (url.includes('arxiv.org'))
|
|
284
|
+
return 'arxiv';
|
|
285
|
+
// OpenAPI/Swagger specs
|
|
286
|
+
if (url.includes('openapi') ||
|
|
287
|
+
url.includes('swagger') ||
|
|
288
|
+
url.endsWith('.yaml') ||
|
|
289
|
+
url.endsWith('.json') ||
|
|
290
|
+
url.includes('/api/spec') ||
|
|
291
|
+
url.includes('/api-docs')) {
|
|
292
|
+
return 'openapi';
|
|
293
|
+
}
|
|
294
|
+
// Context7 documentation
|
|
295
|
+
if (url.includes('context7'))
|
|
296
|
+
return 'context7';
|
|
297
|
+
// Cannot determine programmatically - needs LLM
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Programmatically determine dependency type based on URL patterns and context
|
|
302
|
+
* Returns null if cannot be determined programmatically
|
|
303
|
+
*/
|
|
304
|
+
determineDependencyType(url, context) {
|
|
305
|
+
const lowerUrl = url.toLowerCase();
|
|
306
|
+
const lowerContext = context.toLowerCase();
|
|
307
|
+
// Research papers
|
|
308
|
+
if (lowerUrl.includes('arxiv.org') ||
|
|
309
|
+
lowerContext.includes('paper') ||
|
|
310
|
+
lowerContext.includes('research')) {
|
|
311
|
+
return 'research-paper';
|
|
312
|
+
}
|
|
313
|
+
// Schemas
|
|
314
|
+
if (lowerUrl.includes('schema') ||
|
|
315
|
+
lowerUrl.includes('openapi') ||
|
|
316
|
+
lowerUrl.includes('swagger') ||
|
|
317
|
+
lowerUrl.includes('graphql') ||
|
|
318
|
+
lowerUrl.includes('protobuf')) {
|
|
319
|
+
return 'schema';
|
|
320
|
+
}
|
|
321
|
+
// Documentation
|
|
322
|
+
if (lowerUrl.includes('/docs') ||
|
|
323
|
+
lowerUrl.includes('/documentation') ||
|
|
324
|
+
lowerUrl.includes('/guide') ||
|
|
325
|
+
lowerUrl.includes('/tutorial') ||
|
|
326
|
+
lowerUrl.includes('/reference') ||
|
|
327
|
+
lowerContext.includes('documentation') ||
|
|
328
|
+
lowerContext.includes('docs')) {
|
|
329
|
+
return 'documentation';
|
|
330
|
+
}
|
|
331
|
+
// Reference implementations (GitHub repos)
|
|
332
|
+
if (lowerUrl.includes('github.com') &&
|
|
333
|
+
(lowerContext.includes('example') ||
|
|
334
|
+
lowerContext.includes('implementation') ||
|
|
335
|
+
lowerContext.includes('reference'))) {
|
|
336
|
+
return 'reference-implementation';
|
|
337
|
+
}
|
|
338
|
+
// API examples
|
|
339
|
+
if (lowerContext.includes('example') &&
|
|
340
|
+
(lowerContext.includes('api') || lowerContext.includes('endpoint'))) {
|
|
341
|
+
return 'api-example';
|
|
342
|
+
}
|
|
343
|
+
// Cannot determine programmatically - needs LLM
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
extractName(url) {
|
|
347
|
+
// Extract a reasonable name from URL
|
|
348
|
+
try {
|
|
349
|
+
const urlObj = new URL(url);
|
|
350
|
+
const pathParts = urlObj.pathname.split('/').filter(Boolean);
|
|
351
|
+
if (pathParts.length > 0) {
|
|
352
|
+
const lastPart = pathParts[pathParts.length - 1];
|
|
353
|
+
if (lastPart) {
|
|
354
|
+
return lastPart.replace(/\.[^.]+$/, '');
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return urlObj.hostname;
|
|
358
|
+
}
|
|
359
|
+
catch {
|
|
360
|
+
return url;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
parsePackageFile(filePath, content) {
|
|
364
|
+
const fileName = filePath.split('/').pop() || '';
|
|
365
|
+
if (fileName === 'package.json') {
|
|
366
|
+
return parsePackageJson(content);
|
|
367
|
+
}
|
|
368
|
+
if (fileName === 'requirements.txt') {
|
|
369
|
+
return parseRequirementsTxt(content);
|
|
370
|
+
}
|
|
371
|
+
if (fileName === 'Cargo.toml') {
|
|
372
|
+
return parseCargoToml(content);
|
|
373
|
+
}
|
|
374
|
+
if (fileName === 'go.mod') {
|
|
375
|
+
return parseGoMod(content);
|
|
376
|
+
}
|
|
377
|
+
return { urls: [] };
|
|
378
|
+
}
|
|
379
|
+
async findFiles(dir, pattern) {
|
|
380
|
+
const files = [];
|
|
381
|
+
try {
|
|
382
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
383
|
+
for (const entry of entries) {
|
|
384
|
+
const fullPath = join(dir, entry.name);
|
|
385
|
+
if (this.shouldIgnore(entry.name)) {
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
if (entry.isDirectory()) {
|
|
389
|
+
const subFiles = await this.findFiles(fullPath, pattern);
|
|
390
|
+
files.push(...subFiles);
|
|
391
|
+
}
|
|
392
|
+
else if (pattern.test(entry.name)) {
|
|
393
|
+
files.push(fullPath);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
catch {
|
|
398
|
+
// Ignore errors (permission denied, etc.)
|
|
399
|
+
}
|
|
400
|
+
return files;
|
|
401
|
+
}
|
|
402
|
+
async findPackageFiles(dir) {
|
|
403
|
+
return this.findFiles(dir, /^(package\.json|requirements\.txt|Cargo\.toml|go\.mod)$/);
|
|
404
|
+
}
|
|
405
|
+
async findSourceFiles(dir) {
|
|
406
|
+
return this.findFiles(dir, /\.(ts|js|tsx|jsx|py|rs|go|java|kt|cs|rb|php)$/);
|
|
407
|
+
}
|
|
408
|
+
shouldIgnore(name) {
|
|
409
|
+
return this.options.ignorePatterns.some((pattern) => name.includes(pattern));
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Analyze only specific files for dependencies (for incremental updates)
|
|
413
|
+
* This is more efficient than full repository scan when only few files changed
|
|
414
|
+
*/
|
|
415
|
+
async analyzeFiles(filePaths) {
|
|
416
|
+
const allReferences = new Map();
|
|
417
|
+
let filesScanned = 0;
|
|
418
|
+
let llmCalls = 0;
|
|
419
|
+
let totalTokens = 0;
|
|
420
|
+
let totalLatencyMs = 0;
|
|
421
|
+
for (const filePath of filePaths) {
|
|
422
|
+
// Validate that the file path is safe before joining
|
|
423
|
+
const normalizedRepoPath = resolve(normalize(this.options.repoPath));
|
|
424
|
+
const normalizedFilePath = normalize(filePath);
|
|
425
|
+
const fullPath = resolve(normalizedRepoPath, normalizedFilePath);
|
|
426
|
+
// Ensure the resolved path is within the repository boundaries
|
|
427
|
+
// Use path.sep for cross-platform compatibility
|
|
428
|
+
const repoPathWithSep = normalizedRepoPath.endsWith(sep)
|
|
429
|
+
? normalizedRepoPath
|
|
430
|
+
: normalizedRepoPath + sep;
|
|
431
|
+
if (!fullPath.startsWith(repoPathWithSep) && fullPath !== normalizedRepoPath) {
|
|
432
|
+
// Skip files outside the repository to prevent path traversal
|
|
433
|
+
if (process.env['DEBUG']) {
|
|
434
|
+
console.warn(`Skipping file outside repository: ${filePath}`);
|
|
435
|
+
}
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
try {
|
|
439
|
+
const content = await readFile(fullPath, 'utf-8');
|
|
440
|
+
const relativePath = relative(this.options.repoPath, fullPath);
|
|
441
|
+
const fileName = filePath.split('/').pop() || '';
|
|
442
|
+
// Parse based on file type
|
|
443
|
+
if (/^README/i.test(fileName)) {
|
|
444
|
+
// README file
|
|
445
|
+
const references = parseReadme(content, relativePath);
|
|
446
|
+
for (const ref of references) {
|
|
447
|
+
this.addReference(allReferences, ref.url, {
|
|
448
|
+
file: relativePath,
|
|
449
|
+
...(ref.line !== undefined && { line: ref.line }),
|
|
450
|
+
text: ref.context
|
|
451
|
+
}, 'llm-analysis');
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
else if (/^(package\.json|requirements\.txt|Cargo\.toml|go\.mod)$/i.test(fileName)) {
|
|
455
|
+
// Package file
|
|
456
|
+
const metadata = this.parsePackageFile(fullPath, content);
|
|
457
|
+
for (const url of [
|
|
458
|
+
...(metadata.urls || []),
|
|
459
|
+
metadata.repository,
|
|
460
|
+
metadata.homepage,
|
|
461
|
+
metadata.documentation
|
|
462
|
+
].filter(Boolean)) {
|
|
463
|
+
this.addReference(allReferences, url, {
|
|
464
|
+
file: relativePath,
|
|
465
|
+
text: 'Package metadata'
|
|
466
|
+
}, 'package-json');
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
else if (/\.(ts|js|tsx|jsx|py|rs|go|java|kt|cs|rb|php)$/.test(fileName)) {
|
|
470
|
+
// Source file
|
|
471
|
+
const references = parseCodeComments(content, relativePath);
|
|
472
|
+
for (const ref of references) {
|
|
473
|
+
this.addReference(allReferences, ref.url, {
|
|
474
|
+
file: ref.file,
|
|
475
|
+
line: ref.line,
|
|
476
|
+
text: ref.context
|
|
477
|
+
}, 'code-comment');
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
else if (/\.(md|txt|rst|adoc)$/.test(fileName)) {
|
|
481
|
+
// Documentation file
|
|
482
|
+
const references = parseReadme(content, relativePath);
|
|
483
|
+
for (const ref of references) {
|
|
484
|
+
this.addReference(allReferences, ref.url, {
|
|
485
|
+
file: relativePath,
|
|
486
|
+
...(ref.line !== undefined && { line: ref.line }),
|
|
487
|
+
text: ref.context
|
|
488
|
+
}, 'llm-analysis');
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
filesScanned++;
|
|
492
|
+
}
|
|
493
|
+
catch (error) {
|
|
494
|
+
// Skip files that can't be read - log but don't throw
|
|
495
|
+
// Using console.warn since we don't have a logger instance here
|
|
496
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
497
|
+
console.warn(`Failed to analyze ${filePath}: ${message}`);
|
|
498
|
+
if (process.env['DEBUG']) {
|
|
499
|
+
// Log full error details when DEBUG is enabled
|
|
500
|
+
console.debug('Full error while analyzing %s:', filePath, error);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
// Create dependency entries
|
|
505
|
+
const dependencies = [];
|
|
506
|
+
for (const [url, refData] of allReferences.entries()) {
|
|
507
|
+
const contextText = refData.contexts.map((c) => c.text).join(' ');
|
|
508
|
+
// Step 3: Programmatic type categorization
|
|
509
|
+
let type = this.determineDependencyType(url, contextText);
|
|
510
|
+
// Step 4: LLM fallback for type categorization (if needed)
|
|
511
|
+
if (!type && refData.contexts.length > 0) {
|
|
512
|
+
const startTime = Date.now();
|
|
513
|
+
try {
|
|
514
|
+
const prompt = createClassificationPrompt(url, contextText);
|
|
515
|
+
const response = await this.options.llmProvider.analyze('', prompt);
|
|
516
|
+
llmCalls++;
|
|
517
|
+
totalTokens += response.usage?.totalTokens || 0;
|
|
518
|
+
totalLatencyMs += Date.now() - startTime;
|
|
519
|
+
// Use rawResponse for classification
|
|
520
|
+
const responseText = (response.rawResponse || '').toLowerCase();
|
|
521
|
+
type = (responseText.includes('schema')
|
|
522
|
+
? 'schema'
|
|
523
|
+
: responseText.includes('documentation')
|
|
524
|
+
? 'documentation'
|
|
525
|
+
: responseText.includes('research') || responseText.includes('paper')
|
|
526
|
+
? 'research-paper'
|
|
527
|
+
: responseText.includes('implementation')
|
|
528
|
+
? 'reference-implementation'
|
|
529
|
+
: responseText.includes('example')
|
|
530
|
+
? 'api-example'
|
|
531
|
+
: 'other');
|
|
532
|
+
}
|
|
533
|
+
catch {
|
|
534
|
+
type = 'other';
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (!type) {
|
|
538
|
+
type = 'other';
|
|
539
|
+
}
|
|
540
|
+
// Step 5: Programmatic access method determination
|
|
541
|
+
let accessMethod = this.determineAccessMethod(url);
|
|
542
|
+
if (!accessMethod) {
|
|
543
|
+
accessMethod = 'http'; // Default fallback
|
|
544
|
+
}
|
|
545
|
+
const dependency = {
|
|
546
|
+
id: randomUUID(),
|
|
547
|
+
url,
|
|
548
|
+
type,
|
|
549
|
+
accessMethod,
|
|
550
|
+
name: this.extractName(url),
|
|
551
|
+
currentStateHash: `sha256:pending`,
|
|
552
|
+
detectionMethod: refData.detectionMethod,
|
|
553
|
+
detectionConfidence: refData.detectionMethod === 'manual' ? 1.0 : 0.85,
|
|
554
|
+
detectedAt: new Date().toISOString(),
|
|
555
|
+
lastChecked: new Date().toISOString(),
|
|
556
|
+
auth: undefined,
|
|
557
|
+
referencedIn: refData.contexts.map((ctx) => ({
|
|
558
|
+
file: ctx.file,
|
|
559
|
+
line: ctx.line,
|
|
560
|
+
context: ctx.text
|
|
561
|
+
})),
|
|
562
|
+
changeHistory: []
|
|
563
|
+
};
|
|
564
|
+
dependencies.push(dependency);
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
dependencies,
|
|
568
|
+
statistics: {
|
|
569
|
+
filesScanned,
|
|
570
|
+
urlsFound: allReferences.size,
|
|
571
|
+
llmCalls,
|
|
572
|
+
totalTokens,
|
|
573
|
+
totalLatencyMs
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
//# sourceMappingURL=detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,0BAA0B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C,UAAU,CAAC,CAAC;QAChC,CAAC;QAED,OAAO;YACL,YAAY;YACZ,UAAU,EAAE;gBACV,YAAY;gBACZ,SAAS,EAAE,aAAa,CAAC,IAAI;gBAC7B,QAAQ;gBACR,WAAW;gBACX,cAAc;aACf;SACF,CAAC;IAAA,CACH;CACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diff Parser
|
|
3
|
+
* Parse git diffs to extract meaningful changes for dependency analysis
|
|
4
|
+
*/
|
|
5
|
+
import type { CommitFile } from '@dependabit/github-client';
|
|
6
|
+
export interface DiffParseResult {
|
|
7
|
+
additions: string[];
|
|
8
|
+
deletions: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface ExtractedContent {
|
|
11
|
+
urls: string[];
|
|
12
|
+
packageDeps: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface ChangedFilesResult {
|
|
15
|
+
relevantFiles: string[];
|
|
16
|
+
packageFiles: string[];
|
|
17
|
+
documentationFiles: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Parse a unified diff and extract additions and deletions
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseDiff(patch: string): DiffParseResult;
|
|
23
|
+
/**
|
|
24
|
+
* Extract meaningful content from added lines
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractAddedContent(additions: string[], filename?: string): ExtractedContent;
|
|
27
|
+
/**
|
|
28
|
+
* Extract meaningful content from removed lines
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractRemovedContent(deletions: string[], filename?: string): ExtractedContent;
|
|
31
|
+
/**
|
|
32
|
+
* Identify files relevant for dependency analysis
|
|
33
|
+
*
|
|
34
|
+
* Note: Filenames in relevantFiles preserve their original case from the commit.
|
|
35
|
+
* Case-insensitive matching is used for identification, but original casing is maintained
|
|
36
|
+
* for consistency with file system operations.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getChangedFiles(files: CommitFile[]): ChangedFilesResult;
|
|
39
|
+
/**
|
|
40
|
+
* Parse all diffs from commit files
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseCommitDiffs(files: CommitFile[]): Map<string, DiffParseResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Extract all dependency-related content from commit diffs
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractDependencyChanges(files: CommitFile[]): {
|
|
47
|
+
addedUrls: string[];
|
|
48
|
+
removedUrls: string[];
|
|
49
|
+
addedPackages: string[];
|
|
50
|
+
removedPackages: string[];
|
|
51
|
+
changedFiles: ChangedFilesResult;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=diff-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-parser.d.ts","sourceRoot":"","sources":["../src/diff-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAgDD;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAsBxD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAqC5F;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,gBAAgB,CA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