@vibe-validate/extractors 0.17.0-rc2 → 0.17.0-rc4
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/extractor-registry.d.ts +72 -0
- package/dist/extractor-registry.d.ts.map +1 -0
- package/dist/extractor-registry.js +243 -0
- package/dist/extractor-registry.js.map +1 -0
- package/dist/extractors/ava/index.d.ts +23 -0
- package/dist/extractors/ava/index.d.ts.map +1 -0
- package/dist/extractors/ava/index.js +507 -0
- package/dist/extractors/ava/index.js.map +1 -0
- package/dist/extractors/ava/index.test.d.ts +7 -0
- package/dist/extractors/ava/index.test.d.ts.map +1 -0
- package/dist/extractors/ava/index.test.js +408 -0
- package/dist/extractors/ava/index.test.js.map +1 -0
- package/dist/extractors/eslint/index.d.ts +18 -0
- package/dist/extractors/eslint/index.d.ts.map +1 -0
- package/dist/extractors/eslint/index.js +206 -0
- package/dist/extractors/eslint/index.js.map +1 -0
- package/dist/extractors/eslint/index.test.d.ts +9 -0
- package/dist/extractors/eslint/index.test.d.ts.map +1 -0
- package/dist/extractors/eslint/index.test.js +191 -0
- package/dist/extractors/eslint/index.test.js.map +1 -0
- package/dist/extractors/generic/index.d.ts +30 -0
- package/dist/extractors/generic/index.d.ts.map +1 -0
- package/dist/extractors/generic/index.js +140 -0
- package/dist/extractors/generic/index.js.map +1 -0
- package/dist/extractors/generic/index.test.d.ts +7 -0
- package/dist/extractors/generic/index.test.d.ts.map +1 -0
- package/dist/extractors/generic/index.test.js +61 -0
- package/dist/extractors/generic/index.test.js.map +1 -0
- package/dist/extractors/jasmine/index.d.ts +17 -0
- package/dist/extractors/jasmine/index.d.ts.map +1 -0
- package/dist/extractors/jasmine/index.js +242 -0
- package/dist/extractors/jasmine/index.js.map +1 -0
- package/dist/extractors/jasmine/index.test.d.ts +7 -0
- package/dist/extractors/jasmine/index.test.d.ts.map +1 -0
- package/dist/extractors/jasmine/index.test.js +318 -0
- package/dist/extractors/jasmine/index.test.js.map +1 -0
- package/dist/extractors/jest/index.d.ts +17 -0
- package/dist/extractors/jest/index.d.ts.map +1 -0
- package/dist/extractors/jest/index.js +273 -0
- package/dist/extractors/jest/index.js.map +1 -0
- package/dist/extractors/jest/index.test.d.ts +9 -0
- package/dist/extractors/jest/index.test.d.ts.map +1 -0
- package/dist/extractors/jest/index.test.js +338 -0
- package/dist/extractors/jest/index.test.js.map +1 -0
- package/dist/extractors/junit/index.d.ts +18 -0
- package/dist/extractors/junit/index.d.ts.map +1 -0
- package/dist/extractors/junit/index.js +259 -0
- package/dist/extractors/junit/index.js.map +1 -0
- package/dist/extractors/junit/index.test.d.ts +7 -0
- package/dist/extractors/junit/index.test.d.ts.map +1 -0
- package/dist/extractors/junit/index.test.js +341 -0
- package/dist/extractors/junit/index.test.js.map +1 -0
- package/dist/extractors/maven-checkstyle/index.d.ts +23 -0
- package/dist/extractors/maven-checkstyle/index.d.ts.map +1 -0
- package/dist/extractors/maven-checkstyle/index.js +263 -0
- package/dist/extractors/maven-checkstyle/index.js.map +1 -0
- package/dist/extractors/maven-checkstyle/index.test.d.ts +2 -0
- package/dist/extractors/maven-checkstyle/index.test.d.ts.map +1 -0
- package/dist/extractors/maven-checkstyle/index.test.js +197 -0
- package/dist/extractors/maven-checkstyle/index.test.js.map +1 -0
- package/dist/extractors/maven-compiler/index.d.ts +23 -0
- package/dist/extractors/maven-compiler/index.d.ts.map +1 -0
- package/dist/extractors/maven-compiler/index.js +271 -0
- package/dist/extractors/maven-compiler/index.js.map +1 -0
- package/dist/extractors/maven-compiler/index.test.d.ts +2 -0
- package/dist/extractors/maven-compiler/index.test.d.ts.map +1 -0
- package/dist/extractors/maven-compiler/index.test.js +189 -0
- package/dist/extractors/maven-compiler/index.test.js.map +1 -0
- package/dist/extractors/maven-surefire/index.d.ts +23 -0
- package/dist/extractors/maven-surefire/index.d.ts.map +1 -0
- package/dist/extractors/maven-surefire/index.js +292 -0
- package/dist/extractors/maven-surefire/index.js.map +1 -0
- package/dist/extractors/maven-surefire/index.test.d.ts +2 -0
- package/dist/extractors/maven-surefire/index.test.d.ts.map +1 -0
- package/dist/extractors/maven-surefire/index.test.js +163 -0
- package/dist/extractors/maven-surefire/index.test.js.map +1 -0
- package/dist/extractors/mocha/index.d.ts +17 -0
- package/dist/extractors/mocha/index.d.ts.map +1 -0
- package/dist/extractors/mocha/index.js +241 -0
- package/dist/extractors/mocha/index.js.map +1 -0
- package/dist/extractors/mocha/index.test.d.ts +7 -0
- package/dist/extractors/mocha/index.test.d.ts.map +1 -0
- package/dist/extractors/mocha/index.test.js +300 -0
- package/dist/extractors/mocha/index.test.js.map +1 -0
- package/dist/extractors/playwright/index.d.ts +17 -0
- package/dist/extractors/playwright/index.d.ts.map +1 -0
- package/dist/extractors/playwright/index.js +320 -0
- package/dist/extractors/playwright/index.js.map +1 -0
- package/dist/extractors/playwright/index.test.d.ts +7 -0
- package/dist/extractors/playwright/index.test.d.ts.map +1 -0
- package/dist/extractors/playwright/index.test.js +274 -0
- package/dist/extractors/playwright/index.test.js.map +1 -0
- package/dist/extractors/tap/index.d.ts +23 -0
- package/dist/extractors/tap/index.d.ts.map +1 -0
- package/dist/extractors/tap/index.js +352 -0
- package/dist/extractors/tap/index.js.map +1 -0
- package/dist/extractors/tap/index.test.d.ts +7 -0
- package/dist/extractors/tap/index.test.d.ts.map +1 -0
- package/dist/extractors/tap/index.test.js +100 -0
- package/dist/extractors/tap/index.test.js.map +1 -0
- package/dist/extractors/typescript/index.d.ts +17 -0
- package/dist/extractors/typescript/index.d.ts.map +1 -0
- package/dist/extractors/typescript/index.js +150 -0
- package/dist/extractors/typescript/index.js.map +1 -0
- package/dist/extractors/typescript/index.test.d.ts +9 -0
- package/dist/extractors/typescript/index.test.d.ts.map +1 -0
- package/dist/extractors/typescript/index.test.js +177 -0
- package/dist/extractors/typescript/index.test.js.map +1 -0
- package/dist/extractors/vitest/index.d.ts +17 -0
- package/dist/extractors/vitest/index.d.ts.map +1 -0
- package/dist/extractors/vitest/index.js +564 -0
- package/dist/extractors/vitest/index.js.map +1 -0
- package/dist/extractors/vitest/index.test.d.ts +9 -0
- package/dist/extractors/vitest/index.test.d.ts.map +1 -0
- package/dist/extractors/vitest/index.test.js +373 -0
- package/dist/extractors/vitest/index.test.js.map +1 -0
- package/dist/index.d.ts +27 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -13
- package/dist/index.js.map +1 -1
- package/dist/maven-checkstyle-extractor.d.ts.map +1 -1
- package/dist/maven-checkstyle-extractor.js +2 -17
- package/dist/maven-checkstyle-extractor.js.map +1 -1
- package/dist/maven-compiler-extractor.d.ts +20 -0
- package/dist/maven-compiler-extractor.d.ts.map +1 -0
- package/dist/maven-compiler-extractor.js +218 -0
- package/dist/maven-compiler-extractor.js.map +1 -0
- package/dist/maven-utils.d.ts +24 -0
- package/dist/maven-utils.d.ts.map +1 -0
- package/dist/maven-utils.js +36 -0
- package/dist/maven-utils.js.map +1 -0
- package/dist/plugin-loader.d.ts +82 -0
- package/dist/plugin-loader.d.ts.map +1 -0
- package/dist/plugin-loader.js +200 -0
- package/dist/plugin-loader.js.map +1 -0
- package/dist/sandbox.d.ts +161 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +254 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/sandbox.test.d.ts +8 -0
- package/dist/sandbox.test.d.ts.map +1 -0
- package/dist/sandbox.test.js +395 -0
- package/dist/sandbox.test.js.map +1 -0
- package/dist/sandboxed-extractor.d.ts +51 -0
- package/dist/sandboxed-extractor.d.ts.map +1 -0
- package/dist/sandboxed-extractor.js +172 -0
- package/dist/sandboxed-extractor.js.map +1 -0
- package/dist/sandboxed-extractor.test.d.ts +5 -0
- package/dist/sandboxed-extractor.test.d.ts.map +1 -0
- package/dist/sandboxed-extractor.test.js +346 -0
- package/dist/sandboxed-extractor.test.js.map +1 -0
- package/dist/smart-extractor.d.ts +22 -10
- package/dist/smart-extractor.d.ts.map +1 -1
- package/dist/smart-extractor.js +116 -186
- package/dist/smart-extractor.js.map +1 -1
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maven Compiler error extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts Java compilation errors from Maven compiler plugin output.
|
|
5
|
+
* Supports output from `mvn compile` and `mvn test` when compilation fails.
|
|
6
|
+
*/
|
|
7
|
+
import { MAX_ERRORS_IN_ARRAY } from './result-schema.js';
|
|
8
|
+
import { extractRelativePath } from './maven-utils.js';
|
|
9
|
+
const COMPILER_PATTERNS = {
|
|
10
|
+
// [ERROR] /path/to/File.java:[line,column] error message
|
|
11
|
+
// eslint-disable-next-line sonarjs/slow-regex -- Safe: Maven compiler output is structured, limited line length
|
|
12
|
+
errorLine: /^\[ERROR\]\s+([^:]+):\[(\d+)(?:,(\d+))?\]\s+(.+)$/,
|
|
13
|
+
// Markers for high-confidence detection
|
|
14
|
+
compilationErrorMarker: /^\[ERROR\]\s+COMPILATION ERROR\s*:/,
|
|
15
|
+
compilerPluginMarker: /maven-compiler-plugin/,
|
|
16
|
+
errorCountMarker: /^\[INFO\]\s+(\d+)\s+errors?\s*$/,
|
|
17
|
+
// Common Java compiler error patterns
|
|
18
|
+
compilerErrorPatterns: [
|
|
19
|
+
'cannot find symbol',
|
|
20
|
+
'incompatible types',
|
|
21
|
+
'class, interface, or enum expected',
|
|
22
|
+
'illegal start of expression',
|
|
23
|
+
'reached end of file while parsing',
|
|
24
|
+
'package .* does not exist',
|
|
25
|
+
'method .* cannot be applied',
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Detects if output is from Maven compiler plugin
|
|
30
|
+
*/
|
|
31
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity -- Complexity 22 acceptable for detection (sequentially checks 5 distinct Maven compiler output patterns for accurate detection)
|
|
32
|
+
export function detectMavenCompiler(output) {
|
|
33
|
+
const lines = output.split('\n');
|
|
34
|
+
let score = 0;
|
|
35
|
+
const foundPatterns = [];
|
|
36
|
+
// Look for compilation error markers
|
|
37
|
+
let hasErrorLineFormat = false;
|
|
38
|
+
let hasCompilerErrorPattern = false;
|
|
39
|
+
for (const line of lines) {
|
|
40
|
+
// High-value markers (30 points each)
|
|
41
|
+
if (COMPILER_PATTERNS.compilationErrorMarker.test(line)) {
|
|
42
|
+
score += 30;
|
|
43
|
+
foundPatterns.push('[ERROR] COMPILATION ERROR marker');
|
|
44
|
+
}
|
|
45
|
+
if (COMPILER_PATTERNS.compilerPluginMarker.test(line)) {
|
|
46
|
+
score += 30;
|
|
47
|
+
foundPatterns.push('maven-compiler-plugin reference');
|
|
48
|
+
}
|
|
49
|
+
// Medium-value markers (20 points)
|
|
50
|
+
if (COMPILER_PATTERNS.errorCountMarker.test(line)) {
|
|
51
|
+
score += 20;
|
|
52
|
+
foundPatterns.push('error count summary');
|
|
53
|
+
}
|
|
54
|
+
if (!hasErrorLineFormat && COMPILER_PATTERNS.errorLine.test(line)) {
|
|
55
|
+
score += 20;
|
|
56
|
+
foundPatterns.push('file:[line,column] format');
|
|
57
|
+
hasErrorLineFormat = true;
|
|
58
|
+
}
|
|
59
|
+
// Low-value markers (10 points for first match)
|
|
60
|
+
if (!hasCompilerErrorPattern) {
|
|
61
|
+
for (const pattern of COMPILER_PATTERNS.compilerErrorPatterns) {
|
|
62
|
+
if (line.includes(pattern)) {
|
|
63
|
+
score += 10;
|
|
64
|
+
foundPatterns.push('Java compiler error pattern');
|
|
65
|
+
hasCompilerErrorPattern = true;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Determine reason based on score
|
|
72
|
+
let reason;
|
|
73
|
+
if (score >= 70) {
|
|
74
|
+
reason = 'Maven compiler plugin output detected';
|
|
75
|
+
}
|
|
76
|
+
else if (score >= 40) {
|
|
77
|
+
reason = 'Possible Maven compiler output';
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
reason = 'Not Maven compiler output';
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
confidence: Math.min(score, 100),
|
|
84
|
+
patterns: foundPatterns,
|
|
85
|
+
reason,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Extracts compilation errors from Maven compiler output
|
|
90
|
+
*/
|
|
91
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity -- Complexity 21 acceptable for extraction (parses Maven compiler output with context lines, deduplication, and error formatting)
|
|
92
|
+
export function extractMavenCompiler(output, command) {
|
|
93
|
+
const detection = detectMavenCompiler(output);
|
|
94
|
+
if (detection.confidence < 40) {
|
|
95
|
+
return {
|
|
96
|
+
summary: 'Not Maven compiler output',
|
|
97
|
+
totalErrors: 0,
|
|
98
|
+
errors: [],
|
|
99
|
+
metadata: {
|
|
100
|
+
detection: {
|
|
101
|
+
extractor: 'maven-compiler',
|
|
102
|
+
confidence: detection.confidence,
|
|
103
|
+
patterns: detection.patterns,
|
|
104
|
+
reason: detection.reason,
|
|
105
|
+
},
|
|
106
|
+
confidence: detection.confidence,
|
|
107
|
+
completeness: 100,
|
|
108
|
+
issues: [],
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const compilationErrors = [];
|
|
113
|
+
const lines = output.split('\n');
|
|
114
|
+
// Parse error lines
|
|
115
|
+
for (let i = 0; i < lines.length; i++) {
|
|
116
|
+
const line = lines[i];
|
|
117
|
+
const match = COMPILER_PATTERNS.errorLine.exec(line);
|
|
118
|
+
if (match) {
|
|
119
|
+
const [, filePath, lineStr, colStr, message] = match;
|
|
120
|
+
// Collect additional context (symbol, location) from next lines
|
|
121
|
+
const contextLines = [];
|
|
122
|
+
for (let j = i + 1; j < Math.min(i + 5, lines.length); j++) {
|
|
123
|
+
const nextLine = lines[j]?.trim();
|
|
124
|
+
if (nextLine && !nextLine.startsWith('[') && (nextLine.startsWith('symbol:') || nextLine.startsWith('location:'))) {
|
|
125
|
+
contextLines.push(nextLine);
|
|
126
|
+
}
|
|
127
|
+
else if (nextLine?.startsWith('[')) {
|
|
128
|
+
// Hit next Maven log line
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const fullMessage = contextLines.length > 0
|
|
133
|
+
? `${message}\n${contextLines.join('\n')}`
|
|
134
|
+
: message;
|
|
135
|
+
compilationErrors.push({
|
|
136
|
+
file: extractRelativePath(filePath),
|
|
137
|
+
line: Number.parseInt(lineStr, 10),
|
|
138
|
+
column: colStr ? Number.parseInt(colStr, 10) : undefined,
|
|
139
|
+
message: fullMessage.trim(),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Remove duplicates (Maven sometimes reports errors twice)
|
|
144
|
+
const uniqueErrors = deduplicateErrors(compilationErrors);
|
|
145
|
+
// Convert to FormattedError format
|
|
146
|
+
const errors = uniqueErrors.slice(0, MAX_ERRORS_IN_ARRAY).map((e) => ({
|
|
147
|
+
file: e.file,
|
|
148
|
+
line: e.line,
|
|
149
|
+
column: e.column,
|
|
150
|
+
message: e.message,
|
|
151
|
+
}));
|
|
152
|
+
// Group by file for summary
|
|
153
|
+
const fileGroups = groupByFile(uniqueErrors);
|
|
154
|
+
const summary = `${uniqueErrors.length} compilation error(s) in ${fileGroups.size} file(s)`;
|
|
155
|
+
// Generate guidance
|
|
156
|
+
const guidance = uniqueErrors.length > 0
|
|
157
|
+
? `Fix Java compilation errors. Run ${command ?? 'mvn compile'} to see all details.`
|
|
158
|
+
: undefined;
|
|
159
|
+
// Create error summary
|
|
160
|
+
const errorSummary = errors.length > 0
|
|
161
|
+
? errors.map((e, i) => {
|
|
162
|
+
const location = e.column ? `${e.file}:${e.line}:${e.column}` : `${e.file}:${e.line}`;
|
|
163
|
+
return `[Error ${i + 1}/${errors.length}] ${location}\n${e.message}`;
|
|
164
|
+
}).join('\n\n')
|
|
165
|
+
: undefined;
|
|
166
|
+
return {
|
|
167
|
+
summary,
|
|
168
|
+
totalErrors: uniqueErrors.length,
|
|
169
|
+
errors,
|
|
170
|
+
guidance,
|
|
171
|
+
errorSummary,
|
|
172
|
+
metadata: {
|
|
173
|
+
detection: {
|
|
174
|
+
extractor: 'maven-compiler',
|
|
175
|
+
confidence: detection.confidence,
|
|
176
|
+
patterns: detection.patterns,
|
|
177
|
+
reason: detection.reason,
|
|
178
|
+
},
|
|
179
|
+
confidence: 100,
|
|
180
|
+
completeness: 100,
|
|
181
|
+
issues: [],
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
// Relative path extraction moved to maven-utils.ts (shared with maven-checkstyle-extractor)
|
|
186
|
+
/**
|
|
187
|
+
* Deduplicate compilation errors
|
|
188
|
+
*/
|
|
189
|
+
function deduplicateErrors(errors) {
|
|
190
|
+
const seen = new Set();
|
|
191
|
+
const unique = [];
|
|
192
|
+
for (const e of errors) {
|
|
193
|
+
const key = `${e.file}:${e.line}:${e.column}:${e.message.split('\n')[0]}`;
|
|
194
|
+
if (!seen.has(key)) {
|
|
195
|
+
seen.add(key);
|
|
196
|
+
unique.push(e);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return unique;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Group errors by file
|
|
203
|
+
*/
|
|
204
|
+
function groupByFile(errors) {
|
|
205
|
+
const groups = new Map();
|
|
206
|
+
for (const error of errors) {
|
|
207
|
+
const file = error.file || 'unknown';
|
|
208
|
+
if (!groups.has(file)) {
|
|
209
|
+
groups.set(file, []);
|
|
210
|
+
}
|
|
211
|
+
const group = groups.get(file);
|
|
212
|
+
if (group) {
|
|
213
|
+
group.push(error);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return groups;
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=maven-compiler-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maven Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utility functions for Maven extractors (Checkstyle, Surefire, Compiler)
|
|
5
|
+
*
|
|
6
|
+
* @package @vibe-validate/extractors
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Extract relative path from absolute path
|
|
10
|
+
*
|
|
11
|
+
* Attempts to extract the meaningful source path from absolute file paths
|
|
12
|
+
* by finding common Java/Kotlin source roots.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* extractRelativePath('/Users/name/project/src/main/java/com/example/Foo.java')
|
|
17
|
+
* // => 'src/main/java/com/example/Foo.java'
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param absolutePath - Absolute file path
|
|
21
|
+
* @returns Relative path from source root, or fallback to last few segments
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractRelativePath(absolutePath: string): string;
|
|
24
|
+
//# sourceMappingURL=maven-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maven-utils.d.ts","sourceRoot":"","sources":["../src/maven-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAchE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maven Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utility functions for Maven extractors (Checkstyle, Surefire, Compiler)
|
|
5
|
+
*
|
|
6
|
+
* @package @vibe-validate/extractors
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Extract relative path from absolute path
|
|
10
|
+
*
|
|
11
|
+
* Attempts to extract the meaningful source path from absolute file paths
|
|
12
|
+
* by finding common Java/Kotlin source roots.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* extractRelativePath('/Users/name/project/src/main/java/com/example/Foo.java')
|
|
17
|
+
* // => 'src/main/java/com/example/Foo.java'
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param absolutePath - Absolute file path
|
|
21
|
+
* @returns Relative path from source root, or fallback to last few segments
|
|
22
|
+
*/
|
|
23
|
+
export function extractRelativePath(absolutePath) {
|
|
24
|
+
// Common Java/Kotlin source roots in Maven projects
|
|
25
|
+
const sourceRoots = ['src/main/java', 'src/test/java', 'src/main/kotlin', 'src/test/kotlin'];
|
|
26
|
+
for (const root of sourceRoots) {
|
|
27
|
+
const index = absolutePath.indexOf(root);
|
|
28
|
+
if (index !== -1) {
|
|
29
|
+
return absolutePath.slice(index);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Fallback: return last few path segments (enough to identify the file)
|
|
33
|
+
const segments = absolutePath.split('/');
|
|
34
|
+
return segments.slice(-3).join('/');
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=maven-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maven-utils.js","sourceRoot":"","sources":["../src/maven-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAAoB;IACtD,oDAAoD;IACpD,MAAM,WAAW,GAAG,CAAC,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAE7F,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,wEAAwE;IACxE,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzC,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Loader
|
|
3
|
+
*
|
|
4
|
+
* Discovers and loads external extractor plugins from filesystem and npm packages.
|
|
5
|
+
* Provides security validation and interface compliance checking.
|
|
6
|
+
*
|
|
7
|
+
* @package @vibe-validate/extractors
|
|
8
|
+
*/
|
|
9
|
+
import type { ExtractorPlugin } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Plugin source configuration
|
|
12
|
+
*/
|
|
13
|
+
export type PluginSource = {
|
|
14
|
+
type: 'path';
|
|
15
|
+
path: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'package';
|
|
18
|
+
package: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Plugin discovery configuration
|
|
22
|
+
*/
|
|
23
|
+
export interface PluginDiscoveryConfig {
|
|
24
|
+
/** Explicit plugin sources from config */
|
|
25
|
+
extractors?: PluginSource[];
|
|
26
|
+
/** Base directory for auto-discovery (default: process.cwd()) */
|
|
27
|
+
baseDir?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Plugin validation error
|
|
31
|
+
*/
|
|
32
|
+
export declare class PluginValidationError extends Error {
|
|
33
|
+
readonly _pluginSource: string;
|
|
34
|
+
constructor(message: string, _pluginSource: string);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Load a single plugin from a source
|
|
38
|
+
*
|
|
39
|
+
* @param source - Plugin source (file path or npm package)
|
|
40
|
+
* @returns Validated extractor plugin
|
|
41
|
+
* @throws PluginValidationError if plugin is invalid
|
|
42
|
+
*/
|
|
43
|
+
export declare function loadPlugin(source: PluginSource): Promise<ExtractorPlugin>;
|
|
44
|
+
/**
|
|
45
|
+
* Discover and load all plugins
|
|
46
|
+
*
|
|
47
|
+
* - Loads explicitly configured plugins from config
|
|
48
|
+
* - Auto-discovers plugins from vibe-validate-local-plugins/ directory
|
|
49
|
+
* - Skips invalid plugins with warnings (fail-safe)
|
|
50
|
+
*
|
|
51
|
+
* @param config - Plugin discovery configuration
|
|
52
|
+
* @returns Array of validated plugins
|
|
53
|
+
*/
|
|
54
|
+
export declare function discoverPlugins(config?: PluginDiscoveryConfig): Promise<ExtractorPlugin[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Validate that an object conforms to ExtractorPlugin interface
|
|
57
|
+
*
|
|
58
|
+
* @param plugin - Object to validate
|
|
59
|
+
* @param source - Plugin source (for error messages)
|
|
60
|
+
* @throws PluginValidationError if validation fails
|
|
61
|
+
*/
|
|
62
|
+
export declare function validatePluginInterface(plugin: unknown, source: string): asserts plugin is ExtractorPlugin;
|
|
63
|
+
/**
|
|
64
|
+
* Register plugins dynamically with the extractor registry
|
|
65
|
+
*
|
|
66
|
+
* This function will be used to add external plugins to EXTRACTOR_REGISTRY
|
|
67
|
+
* at runtime after discovery.
|
|
68
|
+
*
|
|
69
|
+
* @param plugins - Array of validated plugins to register
|
|
70
|
+
* @returns Array of extractor descriptors added to registry
|
|
71
|
+
*/
|
|
72
|
+
export declare function registerPlugins(plugins: ExtractorPlugin[]): Array<{
|
|
73
|
+
name: string;
|
|
74
|
+
priority: number;
|
|
75
|
+
detect: (_output: string) => {
|
|
76
|
+
confidence: number;
|
|
77
|
+
patterns: string[];
|
|
78
|
+
reason: string;
|
|
79
|
+
};
|
|
80
|
+
extract: (_output: string) => unknown;
|
|
81
|
+
}>;
|
|
82
|
+
//# sourceMappingURL=plugin-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loader.d.ts","sourceRoot":"","sources":["../src/plugin-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,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 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Loader
|
|
3
|
+
*
|
|
4
|
+
* Discovers and loads external extractor plugins from filesystem and npm packages.
|
|
5
|
+
* Provides security validation and interface compliance checking.
|
|
6
|
+
*
|
|
7
|
+
* @package @vibe-validate/extractors
|
|
8
|
+
*/
|
|
9
|
+
import { pathToFileURL } from 'node:url';
|
|
10
|
+
import { access, readdir } from 'node:fs/promises';
|
|
11
|
+
import { join, resolve } from 'node:path';
|
|
12
|
+
/**
|
|
13
|
+
* Plugin validation error
|
|
14
|
+
*/
|
|
15
|
+
export class PluginValidationError extends Error {
|
|
16
|
+
_pluginSource;
|
|
17
|
+
constructor(message, _pluginSource) {
|
|
18
|
+
super(message);
|
|
19
|
+
this._pluginSource = _pluginSource;
|
|
20
|
+
this.name = 'PluginValidationError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Load a single plugin from a source
|
|
25
|
+
*
|
|
26
|
+
* @param source - Plugin source (file path or npm package)
|
|
27
|
+
* @returns Validated extractor plugin
|
|
28
|
+
* @throws PluginValidationError if plugin is invalid
|
|
29
|
+
*/
|
|
30
|
+
export async function loadPlugin(source) {
|
|
31
|
+
let plugin;
|
|
32
|
+
let pluginPath;
|
|
33
|
+
try {
|
|
34
|
+
if (source.type === 'path') {
|
|
35
|
+
// Load from file path
|
|
36
|
+
pluginPath = resolve(source.path);
|
|
37
|
+
const fileUrl = pathToFileURL(pluginPath).href;
|
|
38
|
+
const module = await import(fileUrl);
|
|
39
|
+
plugin = module.default ?? module;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Load from npm package
|
|
43
|
+
pluginPath = source.package;
|
|
44
|
+
const module = await import(source.package);
|
|
45
|
+
plugin = module.default ?? module;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new PluginValidationError(`Failed to load plugin: ${error instanceof Error ? error.message : String(error)}`, source.type === 'path' ? source.path : source.package);
|
|
50
|
+
}
|
|
51
|
+
// Validate plugin interface
|
|
52
|
+
validatePluginInterface(plugin, pluginPath);
|
|
53
|
+
return plugin;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Discover and load all plugins
|
|
57
|
+
*
|
|
58
|
+
* - Loads explicitly configured plugins from config
|
|
59
|
+
* - Auto-discovers plugins from vibe-validate-local-plugins/ directory
|
|
60
|
+
* - Skips invalid plugins with warnings (fail-safe)
|
|
61
|
+
*
|
|
62
|
+
* @param config - Plugin discovery configuration
|
|
63
|
+
* @returns Array of validated plugins
|
|
64
|
+
*/
|
|
65
|
+
export async function discoverPlugins(config = {}) {
|
|
66
|
+
const plugins = [];
|
|
67
|
+
const errors = [];
|
|
68
|
+
// 1. Load explicitly configured plugins
|
|
69
|
+
await loadConfiguredPlugins(config, plugins, errors);
|
|
70
|
+
// 2. Auto-discover from local plugins directory
|
|
71
|
+
await autoDiscoverLocalPlugins(config, plugins, errors);
|
|
72
|
+
// Log warnings for failed plugins (fail-safe behavior)
|
|
73
|
+
logPluginErrors(errors);
|
|
74
|
+
return plugins;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Load plugins explicitly configured in config
|
|
78
|
+
*/
|
|
79
|
+
async function loadConfiguredPlugins(config, plugins, errors) {
|
|
80
|
+
if (!config.extractors || config.extractors.length === 0) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for (const source of config.extractors) {
|
|
84
|
+
try {
|
|
85
|
+
const plugin = await loadPlugin(source);
|
|
86
|
+
plugins.push(plugin);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const sourceStr = source.type === 'path' ? source.path : source.package;
|
|
90
|
+
errors.push({
|
|
91
|
+
source: sourceStr,
|
|
92
|
+
error: error instanceof Error ? error.message : String(error),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Auto-discover plugins from local plugins directory
|
|
99
|
+
*/
|
|
100
|
+
async function autoDiscoverLocalPlugins(config, plugins, errors) {
|
|
101
|
+
const baseDir = config.baseDir ?? process.cwd();
|
|
102
|
+
const localPluginsDir = join(baseDir, 'vibe-validate-local-plugins');
|
|
103
|
+
try {
|
|
104
|
+
await access(localPluginsDir);
|
|
105
|
+
const entries = await readdir(localPluginsDir, { withFileTypes: true });
|
|
106
|
+
for (const entry of entries) {
|
|
107
|
+
if (entry.isFile() && (entry.name.endsWith('.js') || entry.name.endsWith('.mjs'))) {
|
|
108
|
+
const pluginPath = join(localPluginsDir, entry.name);
|
|
109
|
+
try {
|
|
110
|
+
const plugin = await loadPlugin({ type: 'path', path: pluginPath });
|
|
111
|
+
plugins.push(plugin);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
errors.push({
|
|
115
|
+
source: pluginPath,
|
|
116
|
+
error: error instanceof Error ? error.message : String(error),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// Directory doesn't exist - that's fine, just skip auto-discovery
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Log plugin loading errors
|
|
128
|
+
*/
|
|
129
|
+
function logPluginErrors(errors) {
|
|
130
|
+
if (errors.length === 0) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
console.warn('⚠️ Some plugins failed to load:');
|
|
134
|
+
for (const { source, error } of errors) {
|
|
135
|
+
console.warn(` - ${source}: ${error}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Validate that an object conforms to ExtractorPlugin interface
|
|
140
|
+
*
|
|
141
|
+
* @param plugin - Object to validate
|
|
142
|
+
* @param source - Plugin source (for error messages)
|
|
143
|
+
* @throws PluginValidationError if validation fails
|
|
144
|
+
*/
|
|
145
|
+
export function validatePluginInterface(plugin, source) {
|
|
146
|
+
if (!plugin || typeof plugin !== 'object') {
|
|
147
|
+
throw new PluginValidationError('Plugin must be an object', source);
|
|
148
|
+
}
|
|
149
|
+
const p = plugin;
|
|
150
|
+
// Validate metadata
|
|
151
|
+
if (!p.metadata || typeof p.metadata !== 'object') {
|
|
152
|
+
throw new PluginValidationError('Plugin missing required metadata field', source);
|
|
153
|
+
}
|
|
154
|
+
const metadata = p.metadata;
|
|
155
|
+
if (!metadata.name || typeof metadata.name !== 'string') {
|
|
156
|
+
throw new PluginValidationError('Plugin metadata missing name', source);
|
|
157
|
+
}
|
|
158
|
+
if (!metadata.version || typeof metadata.version !== 'string') {
|
|
159
|
+
throw new PluginValidationError('Plugin metadata missing version', source);
|
|
160
|
+
}
|
|
161
|
+
if (!metadata.description || typeof metadata.description !== 'string') {
|
|
162
|
+
throw new PluginValidationError('Plugin metadata missing description', source);
|
|
163
|
+
}
|
|
164
|
+
// Validate required functions
|
|
165
|
+
if (typeof p.detect !== 'function') {
|
|
166
|
+
throw new PluginValidationError('Plugin missing required detect function', source);
|
|
167
|
+
}
|
|
168
|
+
if (typeof p.extract !== 'function') {
|
|
169
|
+
throw new PluginValidationError('Plugin missing required extract function', source);
|
|
170
|
+
}
|
|
171
|
+
// Validate priority
|
|
172
|
+
if (typeof p.priority !== 'number') {
|
|
173
|
+
throw new PluginValidationError('Plugin missing required priority field', source);
|
|
174
|
+
}
|
|
175
|
+
if (p.priority < 0 || p.priority > 100) {
|
|
176
|
+
throw new PluginValidationError('Priority must be between 0 and 100', source);
|
|
177
|
+
}
|
|
178
|
+
// Validate samples array
|
|
179
|
+
if (!Array.isArray(p.samples)) {
|
|
180
|
+
throw new PluginValidationError('Plugin missing required samples array', source);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Register plugins dynamically with the extractor registry
|
|
185
|
+
*
|
|
186
|
+
* This function will be used to add external plugins to EXTRACTOR_REGISTRY
|
|
187
|
+
* at runtime after discovery.
|
|
188
|
+
*
|
|
189
|
+
* @param plugins - Array of validated plugins to register
|
|
190
|
+
* @returns Array of extractor descriptors added to registry
|
|
191
|
+
*/
|
|
192
|
+
export function registerPlugins(plugins) {
|
|
193
|
+
return plugins.map(plugin => ({
|
|
194
|
+
name: plugin.metadata.name,
|
|
195
|
+
priority: plugin.priority,
|
|
196
|
+
detect: plugin.detect,
|
|
197
|
+
extract: plugin.extract,
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=plugin-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loader.js","sourceRoot":"","sources":["../src/plugin-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoB1C;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAG5B;IAFlB,YACE,OAAe,EACC,aAAqB;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,kBAAa,GAAb,aAAa,CAAQ;QAGrC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAoB;IACnD,IAAI,MAAe,CAAC;IACpB,IAAI,UAAkB,CAAC;IAEvB,IAAI,CAAC;QACH,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC3B,sBAAsB;YACtB,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;YAC/C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;YACrC,MAAM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