driftdetect 0.4.7 → 0.5.0
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/bin/drift.js +27 -1
- package/dist/bin/drift.js.map +1 -1
- package/dist/commands/approve.d.ts +20 -0
- package/dist/commands/approve.d.ts.map +1 -1
- package/dist/commands/approve.js +38 -72
- package/dist/commands/approve.js.map +1 -1
- package/dist/commands/check.d.ts +41 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +21 -11
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/coupling.d.ts +17 -0
- package/dist/commands/coupling.d.ts.map +1 -0
- package/dist/commands/coupling.js +726 -0
- package/dist/commands/coupling.js.map +1 -0
- package/dist/commands/error-handling.d.ts +15 -0
- package/dist/commands/error-handling.d.ts.map +1 -0
- package/dist/commands/error-handling.js +608 -0
- package/dist/commands/error-handling.js.map +1 -0
- package/dist/commands/export.d.ts +16 -0
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +46 -50
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/files.d.ts +15 -0
- package/dist/commands/files.d.ts.map +1 -1
- package/dist/commands/files.js +27 -48
- package/dist/commands/files.js.map +1 -1
- package/dist/commands/ignore.d.ts +20 -0
- package/dist/commands/ignore.d.ts.map +1 -1
- package/dist/commands/ignore.js +25 -48
- package/dist/commands/ignore.js.map +1 -1
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +7 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/migrate-storage.d.ts +23 -0
- package/dist/commands/migrate-storage.d.ts.map +1 -0
- package/dist/commands/migrate-storage.js +337 -0
- package/dist/commands/migrate-storage.js.map +1 -0
- package/dist/commands/report.d.ts +22 -0
- package/dist/commands/report.d.ts.map +1 -1
- package/dist/commands/report.js +19 -10
- package/dist/commands/report.js.map +1 -1
- package/dist/commands/scan.d.ts +2 -0
- package/dist/commands/scan.d.ts.map +1 -1
- package/dist/commands/scan.js +134 -3
- package/dist/commands/scan.js.map +1 -1
- package/dist/commands/skills.d.ts +16 -0
- package/dist/commands/skills.d.ts.map +1 -0
- package/dist/commands/skills.js +409 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/commands/status.d.ts +20 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +74 -72
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/test-topology.d.ts +15 -0
- package/dist/commands/test-topology.d.ts.map +1 -0
- package/dist/commands/test-topology.js +589 -0
- package/dist/commands/test-topology.js.map +1 -0
- package/dist/commands/where.d.ts +15 -0
- package/dist/commands/where.d.ts.map +1 -1
- package/dist/commands/where.js +41 -88
- package/dist/commands/where.js.map +1 -1
- package/dist/commands/wrappers.d.ts +16 -0
- package/dist/commands/wrappers.d.ts.map +1 -0
- package/dist/commands/wrappers.js +181 -0
- package/dist/commands/wrappers.js.map +1 -0
- package/dist/services/pattern-service-factory.d.ts +37 -0
- package/dist/services/pattern-service-factory.d.ts.map +1 -0
- package/dist/services/pattern-service-factory.js +41 -0
- package/dist/services/pattern-service-factory.js.map +1 -0
- package/package.json +4 -4
package/dist/commands/where.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Where Command - Find pattern locations
|
|
3
3
|
*
|
|
4
4
|
* Quickly find where patterns are located in the codebase.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* MIGRATION: Now uses IPatternService for pattern operations.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
9
|
* drift where auth # Find patterns matching "auth"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { Command } from 'commander';
|
|
14
14
|
import chalk from 'chalk';
|
|
15
|
-
import {
|
|
15
|
+
import { createCLIPatternService } from '../services/pattern-service-factory.js';
|
|
16
16
|
export const whereCommand = new Command('where')
|
|
17
17
|
.description('Find pattern locations')
|
|
18
18
|
.argument('<pattern>', 'Pattern name or ID (supports partial matching)')
|
|
@@ -23,105 +23,61 @@ export const whereCommand = new Command('where')
|
|
|
23
23
|
.option('--json', 'Output as JSON')
|
|
24
24
|
.action(async (pattern, options) => {
|
|
25
25
|
const cwd = process.cwd();
|
|
26
|
-
//
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
await patternStore.initialize();
|
|
32
|
-
const allPatterns = patternStore.getAll();
|
|
33
|
-
if (!manifest && allPatterns.length === 0) {
|
|
34
|
-
console.error(chalk.red('No patterns found. Run `drift scan` first.'));
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
// Build query
|
|
38
|
-
const query = {
|
|
39
|
-
pattern,
|
|
40
|
-
limit: parseInt(options.limit, 10),
|
|
26
|
+
// Initialize pattern service
|
|
27
|
+
const service = createCLIPatternService(cwd);
|
|
28
|
+
// Search for patterns using the service
|
|
29
|
+
const searchOptions = {
|
|
30
|
+
limit: 100, // Get more results for filtering
|
|
41
31
|
};
|
|
42
32
|
if (options.category) {
|
|
43
|
-
|
|
33
|
+
searchOptions.categories = [options.category];
|
|
44
34
|
}
|
|
45
35
|
if (options.status) {
|
|
46
|
-
|
|
36
|
+
searchOptions.statuses = [options.status];
|
|
47
37
|
}
|
|
48
38
|
if (options.minConfidence) {
|
|
49
|
-
|
|
39
|
+
searchOptions.minConfidence = parseFloat(options.minConfidence);
|
|
50
40
|
}
|
|
51
|
-
//
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const searchTerm = pattern.toLowerCase();
|
|
57
|
-
const limit = parseInt(options.limit, 10);
|
|
58
|
-
for (const p of allPatterns) {
|
|
59
|
-
// Filter by pattern name/id
|
|
60
|
-
if (!p.id.toLowerCase().includes(searchTerm) &&
|
|
61
|
-
!p.name.toLowerCase().includes(searchTerm) &&
|
|
62
|
-
!p.category.toLowerCase().includes(searchTerm) &&
|
|
63
|
-
!p.subcategory.toLowerCase().includes(searchTerm)) {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
// Filter by category
|
|
67
|
-
if (options.category && p.category !== options.category) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
// Filter by status
|
|
71
|
-
if (options.status && p.status !== options.status) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
// Filter by confidence
|
|
75
|
-
if (options.minConfidence && p.confidence.score < parseFloat(options.minConfidence)) {
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
const locations = p.locations.slice(0, limit).map(loc => ({
|
|
79
|
-
file: loc.file,
|
|
80
|
-
range: { start: loc.line, end: loc.endLine || loc.line },
|
|
81
|
-
type: 'block',
|
|
82
|
-
name: `line-${loc.line}`,
|
|
83
|
-
}));
|
|
84
|
-
patternStoreResults.push({
|
|
85
|
-
patternId: p.id,
|
|
86
|
-
patternName: p.name,
|
|
87
|
-
category: p.category,
|
|
88
|
-
locations,
|
|
89
|
-
totalCount: p.locations.length,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
// Merge results (dedupe by pattern ID)
|
|
93
|
-
const mergedResults = new Map();
|
|
94
|
-
for (const r of manifestResults) {
|
|
95
|
-
mergedResults.set(r.patternId, r);
|
|
96
|
-
}
|
|
97
|
-
for (const r of patternStoreResults) {
|
|
98
|
-
if (!mergedResults.has(r.patternId)) {
|
|
99
|
-
// Add required fields for SemanticLocation compatibility
|
|
100
|
-
const locationsWithHash = r.locations.map(loc => ({
|
|
101
|
-
...loc,
|
|
102
|
-
hash: '',
|
|
103
|
-
confidence: 0.9,
|
|
104
|
-
}));
|
|
105
|
-
mergedResults.set(r.patternId, {
|
|
106
|
-
...r,
|
|
107
|
-
locations: locationsWithHash,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const results = Array.from(mergedResults.values());
|
|
112
|
-
if (results.length === 0) {
|
|
41
|
+
// Use the search method to find matching patterns
|
|
42
|
+
const searchResults = await service.search(pattern, searchOptions);
|
|
43
|
+
if (searchResults.length === 0) {
|
|
44
|
+
// Get all patterns to show available categories
|
|
45
|
+
const allPatternsResult = await service.listPatterns({ limit: 1000 });
|
|
113
46
|
console.log(chalk.yellow(`No patterns found matching "${pattern}"`));
|
|
114
47
|
// Show available categories
|
|
115
|
-
const categories = new Set(
|
|
48
|
+
const categories = new Set(allPatternsResult.items.map(p => p.category));
|
|
116
49
|
if (categories.size > 0) {
|
|
117
50
|
console.log(chalk.dim('\nAvailable categories:'));
|
|
118
51
|
for (const cat of categories) {
|
|
119
|
-
const count =
|
|
52
|
+
const count = allPatternsResult.items.filter(p => p.category === cat).length;
|
|
120
53
|
console.log(chalk.dim(` ${cat}: ${count} patterns`));
|
|
121
54
|
}
|
|
122
55
|
}
|
|
123
56
|
process.exit(0);
|
|
124
57
|
}
|
|
58
|
+
// Fetch full pattern details for results
|
|
59
|
+
const limit = parseInt(options.limit, 10);
|
|
60
|
+
const results = [];
|
|
61
|
+
for (const summary of searchResults) {
|
|
62
|
+
const fullPattern = await service.getPattern(summary.id);
|
|
63
|
+
if (!fullPattern)
|
|
64
|
+
continue;
|
|
65
|
+
const locations = fullPattern.locations.slice(0, limit).map(loc => ({
|
|
66
|
+
file: loc.file,
|
|
67
|
+
hash: '',
|
|
68
|
+
range: { start: loc.line, end: loc.endLine ?? loc.line },
|
|
69
|
+
type: 'block',
|
|
70
|
+
name: `line-${loc.line}`,
|
|
71
|
+
confidence: fullPattern.confidence,
|
|
72
|
+
}));
|
|
73
|
+
results.push({
|
|
74
|
+
patternId: fullPattern.id,
|
|
75
|
+
patternName: fullPattern.name,
|
|
76
|
+
category: fullPattern.category,
|
|
77
|
+
locations,
|
|
78
|
+
totalCount: fullPattern.locations.length,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
125
81
|
// Output
|
|
126
82
|
if (options.json) {
|
|
127
83
|
console.log(JSON.stringify(results, null, 2));
|
|
@@ -140,9 +96,6 @@ export const whereCommand = new Command('where')
|
|
|
140
96
|
if (loc.type !== 'file' && loc.type !== 'block') {
|
|
141
97
|
console.log(` ${chalk.dim(loc.type)}: ${chalk.white(loc.name)}`);
|
|
142
98
|
}
|
|
143
|
-
if (loc.signature) {
|
|
144
|
-
console.log(` ${chalk.dim(loc.signature.substring(0, 60))}`);
|
|
145
|
-
}
|
|
146
99
|
}
|
|
147
100
|
if (result.totalCount > result.locations.length) {
|
|
148
101
|
console.log(chalk.dim(` ... and ${result.totalCount - result.locations.length} more`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"where.js","sourceRoot":"","sources":["../../src/commands/where.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"where.js","sourceRoot":"","sources":["../../src/commands/where.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,wBAAwB,CAAC;KACrC,QAAQ,CAAC,WAAW,EAAE,gDAAgD,CAAC;KACvE,MAAM,CAAC,2BAA2B,EAAE,oBAAoB,CAAC;KACzD,MAAM,CAAC,mBAAmB,EAAE,iDAAiD,CAAC;KAC9E,MAAM,CAAC,2BAA2B,EAAE,8BAA8B,CAAC;KACnE,MAAM,CAAC,sBAAsB,EAAE,iCAAiC,EAAE,IAAI,CAAC;KACvE,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;KAClC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IACj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E,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAChD,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACtE,CAAC;YACH,CAAC;YAED,IAAI,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;gBAChD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC;YAC1F,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrappers Command
|
|
3
|
+
*
|
|
4
|
+
* Detect framework wrapper patterns in the codebase.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* drift wrappers # Scan current directory
|
|
8
|
+
* drift wrappers --json # Output as JSON
|
|
9
|
+
* drift wrappers --verbose # Show detailed output
|
|
10
|
+
* drift wrappers --include-tests # Include test files
|
|
11
|
+
* drift wrappers --min-confidence 0.8 # Filter by confidence
|
|
12
|
+
*/
|
|
13
|
+
import { Command } from 'commander';
|
|
14
|
+
export declare const wrappersCommand: Command;
|
|
15
|
+
export default wrappersCommand;
|
|
16
|
+
//# sourceMappingURL=wrappers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src/commands/wrappers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,eAAO,MAAM,eAAe,SA0DxB,CAAC;AA6IL,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrappers Command
|
|
3
|
+
*
|
|
4
|
+
* Detect framework wrapper patterns in the codebase.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* drift wrappers # Scan current directory
|
|
8
|
+
* drift wrappers --json # Output as JSON
|
|
9
|
+
* drift wrappers --verbose # Show detailed output
|
|
10
|
+
* drift wrappers --include-tests # Include test files
|
|
11
|
+
* drift wrappers --min-confidence 0.8 # Filter by confidence
|
|
12
|
+
*/
|
|
13
|
+
import { Command } from 'commander';
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
import chalk from 'chalk';
|
|
16
|
+
import { createWrapperScanner, } from 'driftdetect-core/wrappers';
|
|
17
|
+
// =============================================================================
|
|
18
|
+
// Command Definition
|
|
19
|
+
// =============================================================================
|
|
20
|
+
export const wrappersCommand = new Command('wrappers')
|
|
21
|
+
.description('Detect framework wrapper patterns in the codebase')
|
|
22
|
+
.option('-d, --dir <path>', 'Project directory', '.')
|
|
23
|
+
.option('-j, --json', 'Output as JSON')
|
|
24
|
+
.option('-v, --verbose', 'Show detailed output')
|
|
25
|
+
.option('--include-tests', 'Include test files in analysis')
|
|
26
|
+
.option('--min-confidence <number>', 'Minimum cluster confidence (0-1)', '0.5')
|
|
27
|
+
.option('--min-cluster-size <number>', 'Minimum cluster size', '2')
|
|
28
|
+
.option('--max-depth <number>', 'Maximum wrapper depth to traverse', '10')
|
|
29
|
+
.option('--category <category>', 'Filter by category')
|
|
30
|
+
.action(async (options) => {
|
|
31
|
+
const rootDir = path.resolve(options.dir);
|
|
32
|
+
const verbose = options.verbose || false;
|
|
33
|
+
const jsonOutput = options.json || false;
|
|
34
|
+
const includeTests = options.includeTests || false;
|
|
35
|
+
const minConfidence = parseFloat(options.minConfidence);
|
|
36
|
+
const minClusterSize = parseInt(options.minClusterSize, 10);
|
|
37
|
+
const maxDepth = parseInt(options.maxDepth, 10);
|
|
38
|
+
const categoryFilter = options.category;
|
|
39
|
+
if (!jsonOutput) {
|
|
40
|
+
console.log(chalk.cyan('\n🔍 Scanning for framework wrappers...\n'));
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const scanner = createWrapperScanner({
|
|
44
|
+
rootDir,
|
|
45
|
+
includeTestFiles: includeTests,
|
|
46
|
+
verbose,
|
|
47
|
+
});
|
|
48
|
+
const result = await scanner.scan({
|
|
49
|
+
minConfidence,
|
|
50
|
+
minClusterSize,
|
|
51
|
+
maxDepth,
|
|
52
|
+
includeTestFiles: includeTests,
|
|
53
|
+
});
|
|
54
|
+
// Filter by category if specified
|
|
55
|
+
if (categoryFilter) {
|
|
56
|
+
result.analysis.clusters = result.analysis.clusters.filter((c) => c.category === categoryFilter);
|
|
57
|
+
}
|
|
58
|
+
if (jsonOutput) {
|
|
59
|
+
console.log(JSON.stringify(result, null, 2));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
printResults(result, verbose);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (jsonOutput) {
|
|
67
|
+
console.log(JSON.stringify({ error: error.message }));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
71
|
+
}
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
// =============================================================================
|
|
76
|
+
// Output Formatting
|
|
77
|
+
// =============================================================================
|
|
78
|
+
function printResults(result, verbose) {
|
|
79
|
+
const { analysis, stats, duration, errors } = result;
|
|
80
|
+
// Summary header
|
|
81
|
+
console.log(chalk.bold('📊 Wrapper Analysis Summary\n'));
|
|
82
|
+
console.log(` Files scanned: ${chalk.cyan(stats.totalFiles)}`);
|
|
83
|
+
console.log(` Functions found: ${chalk.cyan(stats.totalFunctions)}`);
|
|
84
|
+
console.log(` Wrappers detected: ${chalk.green(analysis.summary.totalWrappers)}`);
|
|
85
|
+
console.log(` Clusters found: ${chalk.green(analysis.summary.totalClusters)}`);
|
|
86
|
+
console.log(` Duration: ${chalk.gray(`${duration}ms`)}`);
|
|
87
|
+
console.log();
|
|
88
|
+
// Frameworks detected
|
|
89
|
+
if (analysis.frameworks.length > 0) {
|
|
90
|
+
console.log(chalk.bold('🔧 Frameworks Detected\n'));
|
|
91
|
+
for (const fw of analysis.frameworks) {
|
|
92
|
+
console.log(` ${chalk.cyan(fw.name)} - ${fw.primitiveCount} primitives`);
|
|
93
|
+
}
|
|
94
|
+
console.log();
|
|
95
|
+
}
|
|
96
|
+
// Clusters
|
|
97
|
+
if (analysis.clusters.length > 0) {
|
|
98
|
+
console.log(chalk.bold('📦 Wrapper Clusters\n'));
|
|
99
|
+
for (const cluster of analysis.clusters) {
|
|
100
|
+
printCluster(cluster, verbose);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
console.log(chalk.yellow(' No wrapper clusters found.\n'));
|
|
105
|
+
console.log(chalk.gray(' This could mean:'));
|
|
106
|
+
console.log(chalk.gray(' - No framework primitives are being wrapped'));
|
|
107
|
+
console.log(chalk.gray(' - The codebase uses primitives directly'));
|
|
108
|
+
console.log(chalk.gray(' - Try lowering --min-confidence or --min-cluster-size'));
|
|
109
|
+
console.log();
|
|
110
|
+
}
|
|
111
|
+
// Top wrappers by usage
|
|
112
|
+
if (analysis.wrappers.length > 0 && verbose) {
|
|
113
|
+
console.log(chalk.bold('🏆 Most Used Wrappers\n'));
|
|
114
|
+
const topWrappers = [...analysis.wrappers]
|
|
115
|
+
.sort((a, b) => b.calledBy.length - a.calledBy.length)
|
|
116
|
+
.slice(0, 10);
|
|
117
|
+
for (const wrapper of topWrappers) {
|
|
118
|
+
printWrapper(wrapper);
|
|
119
|
+
}
|
|
120
|
+
console.log();
|
|
121
|
+
}
|
|
122
|
+
// Errors
|
|
123
|
+
if (errors.length > 0) {
|
|
124
|
+
console.log(chalk.yellow(`⚠️ ${errors.length} errors during scan\n`));
|
|
125
|
+
if (verbose) {
|
|
126
|
+
for (const error of errors) {
|
|
127
|
+
console.log(chalk.gray(` ${error}`));
|
|
128
|
+
}
|
|
129
|
+
console.log();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Category breakdown
|
|
133
|
+
const categoryBreakdown = Object.entries(analysis.summary.wrappersByCategory)
|
|
134
|
+
.filter(([, count]) => count > 0)
|
|
135
|
+
.sort((a, b) => b[1] - a[1]);
|
|
136
|
+
if (categoryBreakdown.length > 0) {
|
|
137
|
+
console.log(chalk.bold('📈 Wrappers by Category\n'));
|
|
138
|
+
for (const [category, count] of categoryBreakdown) {
|
|
139
|
+
const numCount = count;
|
|
140
|
+
const bar = '█'.repeat(Math.min(numCount, 30));
|
|
141
|
+
console.log(` ${chalk.cyan(category.padEnd(20))} ${bar} ${numCount}`);
|
|
142
|
+
}
|
|
143
|
+
console.log();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function printCluster(cluster, verbose) {
|
|
147
|
+
const confidenceColor = cluster.confidence >= 0.8
|
|
148
|
+
? chalk.green
|
|
149
|
+
: cluster.confidence >= 0.5
|
|
150
|
+
? chalk.yellow
|
|
151
|
+
: chalk.red;
|
|
152
|
+
console.log(` ${chalk.bold(cluster.name)} ${chalk.gray(`(${cluster.category})`)} ` +
|
|
153
|
+
`${confidenceColor(`${Math.round(cluster.confidence * 100)}%`)}`);
|
|
154
|
+
console.log(chalk.gray(` ${cluster.description}`));
|
|
155
|
+
console.log(chalk.gray(` Primitives: ${cluster.primitiveSignature.slice(0, 5).join(', ')}` +
|
|
156
|
+
(cluster.primitiveSignature.length > 5
|
|
157
|
+
? ` +${cluster.primitiveSignature.length - 5} more`
|
|
158
|
+
: '')));
|
|
159
|
+
console.log(chalk.gray(` ${cluster.wrappers.length} wrappers, avg depth ${cluster.avgDepth.toFixed(1)}, ` +
|
|
160
|
+
`${cluster.totalUsages} usages`));
|
|
161
|
+
if (verbose && cluster.wrappers.length > 0) {
|
|
162
|
+
console.log(chalk.gray(' Members:'));
|
|
163
|
+
for (const wrapper of cluster.wrappers.slice(0, 5)) {
|
|
164
|
+
console.log(chalk.gray(` - ${wrapper.name} (${wrapper.file}:${wrapper.line})`));
|
|
165
|
+
}
|
|
166
|
+
if (cluster.wrappers.length > 5) {
|
|
167
|
+
console.log(chalk.gray(` ... +${cluster.wrappers.length - 5} more`));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
console.log();
|
|
171
|
+
}
|
|
172
|
+
function printWrapper(wrapper) {
|
|
173
|
+
const usageCount = wrapper.calledBy.length;
|
|
174
|
+
const depthIndicator = '→'.repeat(wrapper.depth);
|
|
175
|
+
console.log(` ${chalk.cyan(wrapper.name)} ${chalk.gray(depthIndicator)} ` +
|
|
176
|
+
`${chalk.green(`${usageCount} usages`)}`);
|
|
177
|
+
console.log(chalk.gray(` ${wrapper.file}:${wrapper.line}`));
|
|
178
|
+
console.log(chalk.gray(` Wraps: ${wrapper.primitiveSignature.slice(0, 3).join(', ')}`));
|
|
179
|
+
}
|
|
180
|
+
export default wrappersCommand;
|
|
181
|
+
//# sourceMappingURL=wrappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrappers.js","sourceRoot":"","sources":["../../src/commands/wrappers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,oBAAoB,GAIrB,MAAM,2BAA2B,CAAC;AAEnC,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KACnD,WAAW,CAAC,mDAAmD,CAAC;KACh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AC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAC9E,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Service Factory for CLI
|
|
3
|
+
*
|
|
4
|
+
* Provides a convenient way to create a PatternService from the CLI context.
|
|
5
|
+
* This enables CLI commands to use the new unified pattern system.
|
|
6
|
+
*
|
|
7
|
+
* @module services/pattern-service-factory
|
|
8
|
+
*/
|
|
9
|
+
import { PatternStore, type IPatternService } from 'driftdetect-core';
|
|
10
|
+
/**
|
|
11
|
+
* Create a PatternService for CLI commands.
|
|
12
|
+
*
|
|
13
|
+
* The service auto-initializes on first use, so you don't need to
|
|
14
|
+
* call initialize() manually.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const service = createCLIPatternService(rootDir);
|
|
19
|
+
* const status = await service.getStatus();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param rootDir The project root directory
|
|
23
|
+
* @returns A PatternService instance
|
|
24
|
+
*/
|
|
25
|
+
export declare function createCLIPatternService(rootDir: string): IPatternService;
|
|
26
|
+
/**
|
|
27
|
+
* Create both a PatternStore and PatternService for CLI commands
|
|
28
|
+
* that need access to both (for backward compatibility during migration).
|
|
29
|
+
*
|
|
30
|
+
* @param rootDir The project root directory
|
|
31
|
+
* @returns Both the store and service
|
|
32
|
+
*/
|
|
33
|
+
export declare function createCLIPatternStoreAndService(rootDir: string): {
|
|
34
|
+
store: PatternStore;
|
|
35
|
+
service: IPatternService;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=pattern-service-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-service-factory.d.ts","sourceRoot":"","sources":["../../src/services/pattern-service-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,EAEZ,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAGxE;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG;IAChE,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,eAAe,CAAC;CAC1B,CAIA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Service Factory for CLI
|
|
3
|
+
*
|
|
4
|
+
* Provides a convenient way to create a PatternService from the CLI context.
|
|
5
|
+
* This enables CLI commands to use the new unified pattern system.
|
|
6
|
+
*
|
|
7
|
+
* @module services/pattern-service-factory
|
|
8
|
+
*/
|
|
9
|
+
import { PatternStore, createPatternServiceFromStore, } from 'driftdetect-core';
|
|
10
|
+
/**
|
|
11
|
+
* Create a PatternService for CLI commands.
|
|
12
|
+
*
|
|
13
|
+
* The service auto-initializes on first use, so you don't need to
|
|
14
|
+
* call initialize() manually.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const service = createCLIPatternService(rootDir);
|
|
19
|
+
* const status = await service.getStatus();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param rootDir The project root directory
|
|
23
|
+
* @returns A PatternService instance
|
|
24
|
+
*/
|
|
25
|
+
export function createCLIPatternService(rootDir) {
|
|
26
|
+
const store = new PatternStore({ rootDir });
|
|
27
|
+
return createPatternServiceFromStore(store, rootDir);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create both a PatternStore and PatternService for CLI commands
|
|
31
|
+
* that need access to both (for backward compatibility during migration).
|
|
32
|
+
*
|
|
33
|
+
* @param rootDir The project root directory
|
|
34
|
+
* @returns Both the store and service
|
|
35
|
+
*/
|
|
36
|
+
export function createCLIPatternStoreAndService(rootDir) {
|
|
37
|
+
const store = new PatternStore({ rootDir });
|
|
38
|
+
const service = createPatternServiceFromStore(store, rootDir);
|
|
39
|
+
return { store, service };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=pattern-service-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-service-factory.js","sourceRoot":"","sources":["../../src/services/pattern-service-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,EACZ,6BAA6B,GAE9B,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5C,OAAO,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,+BAA+B,CAAC,OAAe;IAI7D,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "driftdetect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "AI-augmented architectural drift detection - learn and enforce codebase patterns",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Geoffrey Fernald",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"cli-progress": "^3.12.0",
|
|
44
44
|
"cli-table3": "^0.6.5",
|
|
45
45
|
"commander": "^12.1.0",
|
|
46
|
-
"driftdetect-core": "^0.
|
|
47
|
-
"driftdetect-dashboard": "^0.
|
|
48
|
-
"driftdetect-detectors": "^0.
|
|
46
|
+
"driftdetect-core": "^0.5.0",
|
|
47
|
+
"driftdetect-dashboard": "^0.5.0",
|
|
48
|
+
"driftdetect-detectors": "^0.5.0",
|
|
49
49
|
"ora": "^8.1.0",
|
|
50
50
|
"piscina": "^5.1.4"
|
|
51
51
|
},
|