@vibe-validate/extractors 0.16.1 → 0.17.0-rc.5
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 +104 -0
- package/dist/extractor-registry.d.ts.map +1 -0
- package/dist/extractor-registry.js +278 -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 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/dist/maven-checkstyle-extractor.d.ts +20 -0
- package/dist/maven-checkstyle-extractor.d.ts.map +1 -0
- package/dist/maven-checkstyle-extractor.js +193 -0
- package/dist/maven-checkstyle-extractor.js.map +1 -0
- 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-surefire-extractor.d.ts +20 -0
- package/dist/maven-surefire-extractor.d.ts.map +1 -0
- package/dist/maven-surefire-extractor.js +228 -0
- package/dist/maven-surefire-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 +46 -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 -163
- 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,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for Sandboxed Extractor Wrapper
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import { createSandboxedExtractor } from './sandboxed-extractor.js';
|
|
6
|
+
// Mock extractor plugin for testing
|
|
7
|
+
const createMockPlugin = (extractFn) => ({
|
|
8
|
+
metadata: {
|
|
9
|
+
name: 'test-extractor',
|
|
10
|
+
version: '1.0.0',
|
|
11
|
+
description: 'Test extractor for sandboxing',
|
|
12
|
+
},
|
|
13
|
+
priority: 50,
|
|
14
|
+
detect: () => ({ confidence: 100, patterns: ['test'], reason: 'Test' }),
|
|
15
|
+
extract: extractFn,
|
|
16
|
+
samples: [],
|
|
17
|
+
});
|
|
18
|
+
describe('createSandboxedExtractor', () => {
|
|
19
|
+
describe('trust: full (no sandbox)', () => {
|
|
20
|
+
it('should execute extractor directly without sandboxing', async () => {
|
|
21
|
+
const plugin = createMockPlugin((output) => ({
|
|
22
|
+
errors: [{ file: 'test.ts', line: 1, message: output }],
|
|
23
|
+
totalErrors: 1,
|
|
24
|
+
summary: '1 error',
|
|
25
|
+
guidance: 'Fix it',
|
|
26
|
+
metadata: {
|
|
27
|
+
detection: {
|
|
28
|
+
extractor: 'test-extractor',
|
|
29
|
+
confidence: 100,
|
|
30
|
+
patterns: ['test'],
|
|
31
|
+
reason: 'Test',
|
|
32
|
+
},
|
|
33
|
+
confidence: 100,
|
|
34
|
+
completeness: 100,
|
|
35
|
+
issues: [],
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'full' });
|
|
39
|
+
const result = await wrappedExtract('error: test failed');
|
|
40
|
+
expect(result.errors).toHaveLength(1);
|
|
41
|
+
expect(result.errors[0].message).toBe('error: test failed');
|
|
42
|
+
expect(result.summary).toBe('1 error');
|
|
43
|
+
});
|
|
44
|
+
it('should pass command parameter to extractor', async () => {
|
|
45
|
+
const plugin = createMockPlugin((output, command) => ({
|
|
46
|
+
errors: [{ file: 'test.ts', line: 1, message: `${command}: ${output}` }],
|
|
47
|
+
totalErrors: 1,
|
|
48
|
+
summary: '1 error',
|
|
49
|
+
guidance: 'Fix it',
|
|
50
|
+
metadata: {
|
|
51
|
+
detection: {
|
|
52
|
+
extractor: 'test-extractor',
|
|
53
|
+
confidence: 100,
|
|
54
|
+
patterns: ['test'],
|
|
55
|
+
reason: 'Test',
|
|
56
|
+
},
|
|
57
|
+
confidence: 100,
|
|
58
|
+
completeness: 100,
|
|
59
|
+
issues: [],
|
|
60
|
+
},
|
|
61
|
+
}));
|
|
62
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'full' });
|
|
63
|
+
const result = await wrappedExtract('error', 'npm test');
|
|
64
|
+
expect(result.errors[0].message).toBe('npm test: error');
|
|
65
|
+
});
|
|
66
|
+
it('should handle extractors that return no errors', async () => {
|
|
67
|
+
const plugin = createMockPlugin(() => ({
|
|
68
|
+
errors: [],
|
|
69
|
+
totalErrors: 0,
|
|
70
|
+
summary: 'No errors',
|
|
71
|
+
guidance: 'All good',
|
|
72
|
+
metadata: {
|
|
73
|
+
detection: {
|
|
74
|
+
extractor: 'test-extractor',
|
|
75
|
+
confidence: 100,
|
|
76
|
+
patterns: ['test'],
|
|
77
|
+
reason: 'Test',
|
|
78
|
+
},
|
|
79
|
+
confidence: 100,
|
|
80
|
+
completeness: 100,
|
|
81
|
+
issues: [],
|
|
82
|
+
},
|
|
83
|
+
}));
|
|
84
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'full' });
|
|
85
|
+
const result = await wrappedExtract('clean output');
|
|
86
|
+
expect(result.errors).toHaveLength(0);
|
|
87
|
+
expect(result.summary).toBe('No errors');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
describe('trust: sandbox (with isolation)', () => {
|
|
91
|
+
it('should execute extractor in sandbox', async () => {
|
|
92
|
+
const plugin = createMockPlugin((output) => ({
|
|
93
|
+
errors: [{ file: 'test.ts', line: 1, message: output }],
|
|
94
|
+
totalErrors: 1,
|
|
95
|
+
summary: '1 error',
|
|
96
|
+
guidance: 'Fix it',
|
|
97
|
+
metadata: {
|
|
98
|
+
detection: {
|
|
99
|
+
extractor: 'test-extractor',
|
|
100
|
+
confidence: 100,
|
|
101
|
+
patterns: ['test'],
|
|
102
|
+
reason: 'Test',
|
|
103
|
+
},
|
|
104
|
+
confidence: 100,
|
|
105
|
+
completeness: 100,
|
|
106
|
+
issues: [],
|
|
107
|
+
},
|
|
108
|
+
}));
|
|
109
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'sandbox' });
|
|
110
|
+
const result = await wrappedExtract('error: test failed');
|
|
111
|
+
expect(result.errors).toHaveLength(1);
|
|
112
|
+
expect(result.errors[0].message).toBe('error: test failed');
|
|
113
|
+
});
|
|
114
|
+
it('should use default trust level (sandbox) when not specified', async () => {
|
|
115
|
+
const plugin = createMockPlugin((output) => ({
|
|
116
|
+
errors: [{ file: 'test.ts', line: 1, message: output }],
|
|
117
|
+
totalErrors: 1,
|
|
118
|
+
summary: '1 error',
|
|
119
|
+
guidance: 'Fix it',
|
|
120
|
+
metadata: {
|
|
121
|
+
detection: {
|
|
122
|
+
extractor: 'test-extractor',
|
|
123
|
+
confidence: 100,
|
|
124
|
+
patterns: ['test'],
|
|
125
|
+
reason: 'Test',
|
|
126
|
+
},
|
|
127
|
+
confidence: 100,
|
|
128
|
+
completeness: 100,
|
|
129
|
+
issues: [],
|
|
130
|
+
},
|
|
131
|
+
}));
|
|
132
|
+
// No trust specified - should default to sandbox
|
|
133
|
+
const wrappedExtract = createSandboxedExtractor(plugin);
|
|
134
|
+
const result = await wrappedExtract('error: test failed');
|
|
135
|
+
expect(result.errors).toHaveLength(1);
|
|
136
|
+
});
|
|
137
|
+
it('should handle extractors with multiple errors', async () => {
|
|
138
|
+
const plugin = createMockPlugin(() => ({
|
|
139
|
+
errors: [
|
|
140
|
+
{ file: 'test1.ts', line: 1, message: 'Error 1' },
|
|
141
|
+
{ file: 'test2.ts', line: 2, message: 'Error 2' },
|
|
142
|
+
{ file: 'test3.ts', line: 3, message: 'Error 3' },
|
|
143
|
+
],
|
|
144
|
+
totalErrors: 3,
|
|
145
|
+
summary: '3 errors',
|
|
146
|
+
guidance: 'Fix them',
|
|
147
|
+
metadata: {
|
|
148
|
+
detection: {
|
|
149
|
+
extractor: 'test-extractor',
|
|
150
|
+
confidence: 100,
|
|
151
|
+
patterns: ['test'],
|
|
152
|
+
reason: 'Test',
|
|
153
|
+
},
|
|
154
|
+
confidence: 100,
|
|
155
|
+
completeness: 100,
|
|
156
|
+
issues: [],
|
|
157
|
+
},
|
|
158
|
+
}));
|
|
159
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'sandbox' });
|
|
160
|
+
const result = await wrappedExtract('multiple errors');
|
|
161
|
+
expect(result.errors).toHaveLength(3);
|
|
162
|
+
expect(result.summary).toBe('3 errors');
|
|
163
|
+
});
|
|
164
|
+
it('should handle extractors that use string manipulation', async () => {
|
|
165
|
+
const plugin = createMockPlugin((output) => {
|
|
166
|
+
const lines = output.split('\n');
|
|
167
|
+
const errors = lines
|
|
168
|
+
.filter(line => line.includes('ERROR'))
|
|
169
|
+
.map((line, idx) => ({
|
|
170
|
+
file: 'test.ts',
|
|
171
|
+
line: idx + 1,
|
|
172
|
+
message: line.trim(),
|
|
173
|
+
}));
|
|
174
|
+
return {
|
|
175
|
+
errors,
|
|
176
|
+
totalErrors: errors.length,
|
|
177
|
+
summary: `${errors.length} errors`,
|
|
178
|
+
guidance: 'Fix errors',
|
|
179
|
+
metadata: {
|
|
180
|
+
detection: {
|
|
181
|
+
extractor: 'test-extractor',
|
|
182
|
+
confidence: 100,
|
|
183
|
+
patterns: ['ERROR'],
|
|
184
|
+
reason: 'Found ERROR keyword',
|
|
185
|
+
},
|
|
186
|
+
confidence: 100,
|
|
187
|
+
completeness: 100,
|
|
188
|
+
issues: [],
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'sandbox' });
|
|
193
|
+
const result = await wrappedExtract('INFO: Starting\nERROR: Failed\nINFO: Done');
|
|
194
|
+
expect(result.errors).toHaveLength(1);
|
|
195
|
+
expect(result.errors[0].message).toBe('ERROR: Failed');
|
|
196
|
+
});
|
|
197
|
+
it('should handle extractors that use regex', async () => {
|
|
198
|
+
const plugin = createMockPlugin((output) => {
|
|
199
|
+
const errorRegex = /Error at line (\d+): (.+)/g;
|
|
200
|
+
const errors = [];
|
|
201
|
+
let match;
|
|
202
|
+
while ((match = errorRegex.exec(output)) !== null) {
|
|
203
|
+
errors.push({
|
|
204
|
+
file: 'test.ts',
|
|
205
|
+
line: Number.parseInt(match[1], 10),
|
|
206
|
+
message: match[2],
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
errors,
|
|
211
|
+
totalErrors: errors.length,
|
|
212
|
+
summary: `${errors.length} errors`,
|
|
213
|
+
guidance: 'Fix errors',
|
|
214
|
+
metadata: {
|
|
215
|
+
detection: {
|
|
216
|
+
extractor: 'test-extractor',
|
|
217
|
+
confidence: 100,
|
|
218
|
+
patterns: ['Error at line'],
|
|
219
|
+
reason: 'Regex match',
|
|
220
|
+
},
|
|
221
|
+
confidence: 100,
|
|
222
|
+
completeness: 100,
|
|
223
|
+
issues: [],
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
});
|
|
227
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'sandbox' });
|
|
228
|
+
const result = await wrappedExtract('Error at line 5: undefined variable\nError at line 10: syntax error');
|
|
229
|
+
expect(result.errors).toHaveLength(2);
|
|
230
|
+
expect(result.errors[0].line).toBe(5);
|
|
231
|
+
expect(result.errors[1].line).toBe(10);
|
|
232
|
+
});
|
|
233
|
+
it('should handle extractors that return no errors', async () => {
|
|
234
|
+
const plugin = createMockPlugin(() => ({
|
|
235
|
+
errors: [],
|
|
236
|
+
totalErrors: 0,
|
|
237
|
+
summary: 'No errors',
|
|
238
|
+
guidance: 'All good',
|
|
239
|
+
metadata: {
|
|
240
|
+
detection: {
|
|
241
|
+
extractor: 'test-extractor',
|
|
242
|
+
confidence: 100,
|
|
243
|
+
patterns: ['test'],
|
|
244
|
+
reason: 'Test',
|
|
245
|
+
},
|
|
246
|
+
confidence: 100,
|
|
247
|
+
completeness: 100,
|
|
248
|
+
issues: [],
|
|
249
|
+
},
|
|
250
|
+
}));
|
|
251
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'sandbox' });
|
|
252
|
+
const result = await wrappedExtract('clean output');
|
|
253
|
+
expect(result.errors).toHaveLength(0);
|
|
254
|
+
expect(result.summary).toBe('No errors');
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
describe('error handling', () => {
|
|
258
|
+
it('should handle syntax errors in extractor code', async () => {
|
|
259
|
+
// Create plugin with syntax error
|
|
260
|
+
const plugin = createMockPlugin(() => {
|
|
261
|
+
throw new Error('Syntax error: unexpected token');
|
|
262
|
+
});
|
|
263
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'sandbox' });
|
|
264
|
+
const result = await wrappedExtract('some output');
|
|
265
|
+
// Should return empty errors with error in metadata
|
|
266
|
+
expect(result.errors).toHaveLength(0);
|
|
267
|
+
expect(result.summary).toContain('Sandbox execution failed');
|
|
268
|
+
expect(result.metadata?.issues).toHaveLength(1);
|
|
269
|
+
expect(result.metadata?.issues[0]).toContain('Syntax error');
|
|
270
|
+
});
|
|
271
|
+
it('should handle extractors that throw errors', async () => {
|
|
272
|
+
const plugin = createMockPlugin(() => {
|
|
273
|
+
throw new Error('Extractor failed');
|
|
274
|
+
});
|
|
275
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'sandbox' });
|
|
276
|
+
const result = await wrappedExtract('some output');
|
|
277
|
+
expect(result.errors).toHaveLength(0);
|
|
278
|
+
expect(result.summary).toContain('Sandbox execution failed');
|
|
279
|
+
expect(result.metadata?.confidence).toBe(0);
|
|
280
|
+
});
|
|
281
|
+
it('should handle extractors that return invalid results', async () => {
|
|
282
|
+
const plugin = createMockPlugin(() => {
|
|
283
|
+
// Return invalid result (missing required fields)
|
|
284
|
+
return { invalid: 'result' };
|
|
285
|
+
});
|
|
286
|
+
const wrappedExtract = createSandboxedExtractor(plugin, { trust: 'sandbox' });
|
|
287
|
+
const result = await wrappedExtract('some output');
|
|
288
|
+
// Sandbox should handle this and return error metadata
|
|
289
|
+
expect(result).toBeDefined();
|
|
290
|
+
expect(result.errors).toBeDefined();
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
describe('performance options', () => {
|
|
294
|
+
it('should respect custom memory limit', async () => {
|
|
295
|
+
const plugin = createMockPlugin(() => ({
|
|
296
|
+
errors: [],
|
|
297
|
+
totalErrors: 0,
|
|
298
|
+
summary: 'No errors',
|
|
299
|
+
guidance: '',
|
|
300
|
+
metadata: {
|
|
301
|
+
detection: {
|
|
302
|
+
extractor: 'test-extractor',
|
|
303
|
+
confidence: 100,
|
|
304
|
+
patterns: [],
|
|
305
|
+
reason: 'Test',
|
|
306
|
+
},
|
|
307
|
+
confidence: 100,
|
|
308
|
+
completeness: 100,
|
|
309
|
+
issues: [],
|
|
310
|
+
},
|
|
311
|
+
}));
|
|
312
|
+
const wrappedExtract = createSandboxedExtractor(plugin, {
|
|
313
|
+
trust: 'sandbox',
|
|
314
|
+
memoryLimitMB: 64,
|
|
315
|
+
});
|
|
316
|
+
const result = await wrappedExtract('test');
|
|
317
|
+
expect(result).toBeDefined();
|
|
318
|
+
});
|
|
319
|
+
it('should respect custom timeout', async () => {
|
|
320
|
+
const plugin = createMockPlugin(() => ({
|
|
321
|
+
errors: [],
|
|
322
|
+
totalErrors: 0,
|
|
323
|
+
summary: 'No errors',
|
|
324
|
+
guidance: '',
|
|
325
|
+
metadata: {
|
|
326
|
+
detection: {
|
|
327
|
+
extractor: 'test-extractor',
|
|
328
|
+
confidence: 100,
|
|
329
|
+
patterns: [],
|
|
330
|
+
reason: 'Test',
|
|
331
|
+
},
|
|
332
|
+
confidence: 100,
|
|
333
|
+
completeness: 100,
|
|
334
|
+
issues: [],
|
|
335
|
+
},
|
|
336
|
+
}));
|
|
337
|
+
const wrappedExtract = createSandboxedExtractor(plugin, {
|
|
338
|
+
trust: 'sandbox',
|
|
339
|
+
timeoutMs: 10000,
|
|
340
|
+
});
|
|
341
|
+
const result = await wrappedExtract('test');
|
|
342
|
+
expect(result).toBeDefined();
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
//# sourceMappingURL=sandboxed-extractor.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandboxed-extractor.test.js","sourceRoot":"","sources":["../src/sandboxed-extractor.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,oCAAoC;AACpC,MAAM,gBAAgB,GAAG,CACvB,SAgBC,EACgB,EAAE,CAAC,CAAC;IACrB,QAAQ,EAAE;QACR,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,+BAA+B;KAC7C;IACD,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE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EAAE,EAAE;gBACZ,QAAQ,EAAE;oBACR,SAAS,EAAE;wBACT,SAAS,EAAE,gBAAgB;wBAC3B,UAAU,EAAE,GAAG;wBACf,QAAQ,EAAE,EAAE;wBACZ,MAAM,EAAE,MAAM;qBACf;oBACD,UAAU,EAAE,GAAG;oBACf,YAAY,EAAE,GAAG;oBACjB,MAAM,EAAE,EAAE;iBACX;aACF,CAAC,CAAC,CAAC;YAEJ,MAAM,cAAc,GAAG,wBAAwB,CAAC,MAAM,EAAE;gBACtD,KAAK,EAAE,SAAS;gBAChB,SAAS,EAAE,KAAK;aACjB,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -12,18 +12,27 @@ import type { ErrorExtractorResult, ExtractorInput } from './types.js';
|
|
|
12
12
|
* Detection is 100% pattern-based from output analysis only.
|
|
13
13
|
* This ensures robust detection regardless of how users name their validation steps.
|
|
14
14
|
*
|
|
15
|
+
* **Multi-Extractor Fallback Strategy** (new in v0.17.0-rc4):
|
|
16
|
+
* When exitCode != 0 but primary extractor finds 0 errors, tries other extractors
|
|
17
|
+
* until one produces results. This prevents false positives (e.g., Checkstyle
|
|
18
|
+
* detecting compiler errors with 70% confidence but extracting nothing).
|
|
19
|
+
*
|
|
15
20
|
* Auto-detection rules (checked in order):
|
|
16
21
|
* 1. **TypeScript**: `error TS####:` pattern (e.g., `error TS2322:`)
|
|
17
22
|
* 2. **ESLint**: `✖ X problems` summary or `line:col error/warning` format
|
|
18
|
-
* 3. **
|
|
19
|
-
* 4. **
|
|
20
|
-
* 5. **
|
|
21
|
-
* 6. **
|
|
22
|
-
* 7. **
|
|
23
|
-
* 8. **
|
|
24
|
-
* 9. **
|
|
23
|
+
* 3. **Maven Checkstyle**: Checkstyle plugin markers
|
|
24
|
+
* 4. **Maven Surefire**: Test plugin markers
|
|
25
|
+
* 5. **Maven Compiler**: Compilation error markers
|
|
26
|
+
* 6. **JUnit XML**: `<?xml` + `<testsuite>` tags
|
|
27
|
+
* 7. **Jasmine**: `Failures:` header + numbered list (`1) test name`)
|
|
28
|
+
* 8. **Jest**: `●` bullets or `Test Suites:` summary (checked before Mocha)
|
|
29
|
+
* 9. **Mocha**: `X passing`/`X failing` summary + numbered list
|
|
30
|
+
* 10. **Playwright**: `.spec.ts` files + numbered failures with `›` separator
|
|
31
|
+
* 11. **Vitest**: `×`/`❯`/`❌` symbols + `Test Files` summary
|
|
32
|
+
* 12. **Generic**: Fallback for all other formats
|
|
25
33
|
*
|
|
26
34
|
* @param input - Raw command output (string) or separated streams (ExtractorInput)
|
|
35
|
+
* @param exitCode - Optional exit code from command (enables fallback logic)
|
|
27
36
|
* @returns Structured error information from appropriate extractor
|
|
28
37
|
*
|
|
29
38
|
* @example
|
|
@@ -31,13 +40,16 @@ import type { ErrorExtractorResult, ExtractorInput } from './types.js';
|
|
|
31
40
|
* // Legacy usage (string)
|
|
32
41
|
* const result1 = autoDetectAndExtract(tscOutput);
|
|
33
42
|
*
|
|
43
|
+
* // New usage with exit code (enables fallback)
|
|
44
|
+
* const result2 = autoDetectAndExtract(output, 1);
|
|
45
|
+
*
|
|
34
46
|
* // New usage (separated streams)
|
|
35
|
-
* const
|
|
47
|
+
* const result3 = autoDetectAndExtract({
|
|
36
48
|
* stdout: stdoutString,
|
|
37
49
|
* stderr: stderrString,
|
|
38
50
|
* combined: combinedString
|
|
39
|
-
* });
|
|
51
|
+
* }, 0);
|
|
40
52
|
* ```
|
|
41
53
|
*/
|
|
42
|
-
export declare function autoDetectAndExtract(input: string | ExtractorInput): ErrorExtractorResult;
|
|
54
|
+
export declare function autoDetectAndExtract(input: string | ExtractorInput, exitCode?: number): ErrorExtractorResult;
|
|
43
55
|
//# sourceMappingURL=smart-extractor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-extractor.d.ts","sourceRoot":"","sources":["../src/smart-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"smart-extractor.d.ts","sourceRoot":"","sources":["../src/smart-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,oBAAoB,CA6B5G"}
|