@goshenkata/dryscan-core 1.0.0 → 1.0.8
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 +96 -0
- package/package.json +8 -4
- package/src/DryScan.ts +1 -0
- package/src/types.ts +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# @goshenkata/dryscan-core
|
|
2
|
+
|
|
3
|
+
Core library for DryScan - semantic code duplication analyzer using embeddings.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @goshenkata/dryscan-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Basic Example
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { DryScan } from '@goshenkata/dryscan-core';
|
|
17
|
+
|
|
18
|
+
const scanner = new DryScan('/path/to/your/repository');
|
|
19
|
+
|
|
20
|
+
// Initialize repository index
|
|
21
|
+
await scanner.init();
|
|
22
|
+
|
|
23
|
+
// Build duplicate analysis report
|
|
24
|
+
const report = await scanner.buildDuplicateReport();
|
|
25
|
+
|
|
26
|
+
console.log(`Duplication Score: ${report.score.score}`);
|
|
27
|
+
console.log(`Found ${report.duplicates.length} duplicate pairs`);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### API
|
|
31
|
+
|
|
32
|
+
Initializes the repository with a 3-phase analysis:
|
|
33
|
+
1. Extract and index all code units (functions, methods, blocks)
|
|
34
|
+
2. Resolve internal dependencies
|
|
35
|
+
3. Compute semantic embeddings
|
|
36
|
+
|
|
37
|
+
#### `async updateIndex(): Promise<void>`
|
|
38
|
+
|
|
39
|
+
Incrementally updates the index by detecting changed, new, and deleted files. Only reprocesses modified units for efficiency.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
await scanner.updateIndex();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### `async buildDuplicateReport(): Promise<DuplicateReport>`
|
|
46
|
+
|
|
47
|
+
Runs duplicate detection and returns a comprehensive report with similarity scores and duplication metrics.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
const report = await scanner.buildDuplicateReport();
|
|
51
|
+
|
|
52
|
+
report.duplicates.forEach(dup => {
|
|
53
|
+
console.log(`${dup.similarity.toFixed(2)} - ${dup.left.name} ↔ ${dup.right.name}`);
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### `async cleanExclusions(): Promise<{ removed: number; kept: number }>`
|
|
58
|
+
|
|
59
|
+
Removes stale exclusion rules that no longer match any indexed units.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const result = await scanner.cleanExclusions();
|
|
63
|
+
console.log(`Cleaned ${result.removed} stale exclusions`);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Configuration
|
|
67
|
+
|
|
68
|
+
Place a `dryconfig.json` in your repository root:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"threshold": 0.88,
|
|
73
|
+
"minLines": 5,
|
|
74
|
+
"minBlockLines": 8,
|
|
75
|
+
"embeddingModel": "embeddinggemma",
|
|
76
|
+
"embeddingSource": "http://localhost:11434",
|
|
77
|
+
"excludedPaths": ["**/test/**", "**/node_modules/**"],
|
|
78
|
+
"excludedPairs": []
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Supported Embedding Providers:**
|
|
83
|
+
- **Ollama** (default): Set `embeddingSource` to `"http://localhost:11434"` and `embeddingModel` to `"embeddinggemma"`
|
|
84
|
+
- **Google Gemini**: Set `embeddingSource` to `"google"` and `embeddingModel` to `"gemini-embedding-001"` (requires `GOOGLE_API_KEY` env var)
|
|
85
|
+
|
|
86
|
+
## Requirements
|
|
87
|
+
|
|
88
|
+
- Node.js >= 18.0.0
|
|
89
|
+
- Ollama running locally (default) or Google API key for embeddings
|
|
90
|
+
|
|
91
|
+
## Supported languages**
|
|
92
|
+
|
|
93
|
+
Just java for now
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goshenkata/dryscan-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Core library for DryScan - semantic code duplication analyzer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
],
|
|
28
28
|
"author": "Goshenkata",
|
|
29
29
|
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/Goshenkata/DryScan.git"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
30
37
|
"devDependencies": {
|
|
31
38
|
"@types/better-sqlite3": "^7.6.13",
|
|
32
39
|
"@types/debug": "^4.1.12",
|
|
@@ -56,8 +63,5 @@
|
|
|
56
63
|
"tree-sitter-python": "^0.25.0",
|
|
57
64
|
"typeorm": "^0.3.28",
|
|
58
65
|
"upath": "^2.0.1"
|
|
59
|
-
},
|
|
60
|
-
"publishConfig": {
|
|
61
|
-
"access": "public"
|
|
62
66
|
}
|
|
63
67
|
}
|
package/src/DryScan.ts
CHANGED