@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/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Pradeep Mouli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @dependabit/detector
|
|
2
|
+
|
|
3
|
+
LLM-based dependency detection for external resources.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides intelligent dependency detection using Large Language Models (LLMs) to analyze codebases and identify external dependencies, APIs, and resources.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- LLM-powered dependency detection
|
|
12
|
+
- README parser for extracting references
|
|
13
|
+
- Code comment parser for inline documentation
|
|
14
|
+
- Package file parser for standard dependency files
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @dependabit/detector
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { detect } from '@dependabit/detector';
|
|
26
|
+
|
|
27
|
+
// Coming soon in Phase 3
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detector Orchestrator
|
|
3
|
+
* Coordinates content parsers and LLM analysis to detect external dependencies
|
|
4
|
+
*/
|
|
5
|
+
import type { LLMProvider } from './llm/client.js';
|
|
6
|
+
import type { DependencyEntry } from '@dependabit/manifest';
|
|
7
|
+
export interface DetectorOptions {
|
|
8
|
+
repoPath: string;
|
|
9
|
+
llmProvider: LLMProvider;
|
|
10
|
+
ignorePatterns?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface DetectionResult {
|
|
13
|
+
dependencies: DependencyEntry[];
|
|
14
|
+
statistics: {
|
|
15
|
+
filesScanned: number;
|
|
16
|
+
urlsFound: number;
|
|
17
|
+
llmCalls: number;
|
|
18
|
+
totalTokens: number;
|
|
19
|
+
totalLatencyMs: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Main detector class
|
|
24
|
+
*/
|
|
25
|
+
export declare class Detector {
|
|
26
|
+
private options;
|
|
27
|
+
constructor(options: DetectorOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Detect all external dependencies in the repository
|
|
30
|
+
*
|
|
31
|
+
* Implementation follows a hybrid approach:
|
|
32
|
+
* 1. Programmatic parsing of repository files (README, code comments, package files)
|
|
33
|
+
* 2. LLM analysis only for documents not fully parsed in step 1 (future enhancement)
|
|
34
|
+
* 3. Programmatic type categorization based on URL patterns and context
|
|
35
|
+
* 4. LLM fallback for uncategorized dependencies
|
|
36
|
+
* 5. Programmatic access method determination based on URL patterns
|
|
37
|
+
* 6. LLM fallback for access methods that can't be determined (future enhancement)
|
|
38
|
+
* 7. Manifest entry creation with references and versioning
|
|
39
|
+
*/
|
|
40
|
+
detectDependencies(): Promise<DetectionResult>;
|
|
41
|
+
private addReference;
|
|
42
|
+
/**
|
|
43
|
+
* Programmatically determine access method based on URL patterns
|
|
44
|
+
* Returns null if cannot be determined programmatically
|
|
45
|
+
*/
|
|
46
|
+
private determineAccessMethod;
|
|
47
|
+
/**
|
|
48
|
+
* Programmatically determine dependency type based on URL patterns and context
|
|
49
|
+
* Returns null if cannot be determined programmatically
|
|
50
|
+
*/
|
|
51
|
+
private determineDependencyType;
|
|
52
|
+
private extractName;
|
|
53
|
+
private parsePackageFile;
|
|
54
|
+
private findFiles;
|
|
55
|
+
private findPackageFiles;
|
|
56
|
+
private findSourceFiles;
|
|
57
|
+
private shouldIgnore;
|
|
58
|
+
/**
|
|
59
|
+
* Analyze only specific files for dependencies (for incremental updates)
|
|
60
|
+
* This is more efficient than full repository scan when only few files changed
|
|
61
|
+
*/
|
|
62
|
+
analyzeFiles(filePaths: string[]): Promise<DetectionResult>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAUnD,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,UAAU,EAAE;QACV,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAiBD;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAA4B;IAE3C,YAAY,OAAO,EAAE,eAAe,EAKnC;IAED;;;;;;;;;;;OAWG;IACG,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC,CA0QnD;IAED,OAAO,CAAC,YAAY;IAgBpB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IA0B7B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IA2D/B,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,gBAAgB;YAsBV,SAAS;YA2BT,gBAAgB;YAIhB,eAAe;IAI7B,OAAO,CAAC,YAAY;IAIpB;;;OAGG;IACG,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CA2MhE;CACF"}
|