@vibe-validate/extractors 0.12.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/README.md +121 -0
- package/dist/eslint-extractor.d.ts +25 -0
- package/dist/eslint-extractor.d.ts.map +1 -0
- package/dist/eslint-extractor.js +143 -0
- package/dist/eslint-extractor.js.map +1 -0
- package/dist/generic-extractor.d.ts +29 -0
- package/dist/generic-extractor.d.ts.map +1 -0
- package/dist/generic-extractor.js +51 -0
- package/dist/generic-extractor.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi-extractor.d.ts +25 -0
- package/dist/openapi-extractor.d.ts.map +1 -0
- package/dist/openapi-extractor.js +37 -0
- package/dist/openapi-extractor.js.map +1 -0
- package/dist/smart-extractor.d.ts +33 -0
- package/dist/smart-extractor.d.ts.map +1 -0
- package/dist/smart-extractor.js +52 -0
- package/dist/smart-extractor.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/typescript-extractor.d.ts +25 -0
- package/dist/typescript-extractor.d.ts.map +1 -0
- package/dist/typescript-extractor.js +93 -0
- package/dist/typescript-extractor.js.map +1 -0
- package/dist/utils.d.ts +39 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +64 -0
- package/dist/utils.js.map +1 -0
- package/dist/vitest-extractor.d.ts +30 -0
- package/dist/vitest-extractor.d.ts.map +1 -0
- package/dist/vitest-extractor.js +245 -0
- package/dist/vitest-extractor.js.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @vibe-validate/extractors
|
|
2
|
+
|
|
3
|
+
LLM-optimized error extractors for validation output.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Intelligent Error Extraction**: Automatically detects tool type and applies appropriate extractor
|
|
8
|
+
- **Token-Efficient Output**: Limits errors to first 10, removes noise, focuses on actionable info
|
|
9
|
+
- **Actionable Guidance**: Provides tool-specific fixing suggestions
|
|
10
|
+
- **Zero Dependencies**: Pure TypeScript implementation
|
|
11
|
+
|
|
12
|
+
## Supported Extractors
|
|
13
|
+
|
|
14
|
+
- **TypeScript (tsc)**: Parses `file(line,col): error TSxxxx: message` format
|
|
15
|
+
- **ESLint**: Parses `file:line:col - severity message [rule]` format
|
|
16
|
+
- **Vitest/Jest**: Extracts test hierarchy, assertion errors, expected vs actual
|
|
17
|
+
- **OpenAPI**: Filters validation errors from specification validators
|
|
18
|
+
- **Generic**: Fallback for unknown tools (removes npm noise)
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @vibe-validate/extractors
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Smart Extractor (Recommended)
|
|
29
|
+
|
|
30
|
+
Auto-detects tool type from step name:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { extractByStepName } from '@vibe-validate/extractors';
|
|
34
|
+
|
|
35
|
+
const result = extractByStepName('TypeScript Type Checking', tscOutput);
|
|
36
|
+
|
|
37
|
+
console.log(result.summary); // "3 type error(s), 0 warning(s)"
|
|
38
|
+
console.log(result.guidance); // "Type mismatch - check variable/parameter types"
|
|
39
|
+
console.log(result.cleanOutput); // Clean, formatted error list
|
|
40
|
+
console.log(result.errors); // Structured error array
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Direct Extractor Usage
|
|
44
|
+
|
|
45
|
+
For explicit control:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import {
|
|
49
|
+
extractTypeScriptErrors,
|
|
50
|
+
extractESLintErrors,
|
|
51
|
+
extractVitestErrors,
|
|
52
|
+
formatOpenAPIErrors,
|
|
53
|
+
formatGenericErrors
|
|
54
|
+
} from '@vibe-validate/extractors';
|
|
55
|
+
|
|
56
|
+
const result = extractTypeScriptErrors(tscOutput);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Utilities
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { stripAnsiCodes, extractErrorLines } from '@vibe-validate/extractors';
|
|
63
|
+
|
|
64
|
+
const clean = stripAnsiCodes(colorfulOutput);
|
|
65
|
+
const errorLines = extractErrorLines(verboseOutput);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API
|
|
69
|
+
|
|
70
|
+
### `extractByStepName(stepName: string, output: string): ErrorExtractorResult`
|
|
71
|
+
|
|
72
|
+
Smart extractor with auto-detection.
|
|
73
|
+
|
|
74
|
+
**Detection rules:**
|
|
75
|
+
- TypeScript: Step name contains "TypeScript" or "typecheck"
|
|
76
|
+
- ESLint: Step name contains "ESLint" or "lint"
|
|
77
|
+
- Vitest/Jest: Step name contains "test" (but not "OpenAPI")
|
|
78
|
+
- OpenAPI: Step name contains "OpenAPI"
|
|
79
|
+
- Generic: Fallback for unknown types
|
|
80
|
+
|
|
81
|
+
### Type Definitions
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
interface FormattedError {
|
|
85
|
+
file: string;
|
|
86
|
+
line?: number;
|
|
87
|
+
column?: number;
|
|
88
|
+
message: string;
|
|
89
|
+
code?: string;
|
|
90
|
+
severity?: 'error' | 'warning';
|
|
91
|
+
context?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface ErrorExtractorResult {
|
|
95
|
+
errors: FormattedError[]; // First 10 errors (structured)
|
|
96
|
+
summary: string; // Human-readable summary
|
|
97
|
+
totalCount: number; // Total error count
|
|
98
|
+
guidance?: string; // Actionable fixing guidance
|
|
99
|
+
cleanOutput: string; // Clean formatted output for YAML/JSON
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Why LLM-Optimized?
|
|
104
|
+
|
|
105
|
+
1. **Token Efficiency**: Limits output to first 10 errors (most relevant)
|
|
106
|
+
2. **Noise Removal**: Strips ANSI codes, npm headers, stack traces
|
|
107
|
+
3. **Structured Data**: Provides parseable error objects with file:line:col
|
|
108
|
+
4. **Actionable Guidance**: Suggests specific fixes based on error codes
|
|
109
|
+
5. **Clean Embedding**: `cleanOutput` ready for YAML/JSON state files
|
|
110
|
+
|
|
111
|
+
## Design Philosophy
|
|
112
|
+
|
|
113
|
+
**Agent-First**: Designed for consumption by AI assistants (Claude Code, Cursor, etc.), not just humans.
|
|
114
|
+
|
|
115
|
+
**Deterministic**: Same input always produces same output (no timestamps, no randomness).
|
|
116
|
+
|
|
117
|
+
**Minimal**: Zero runtime dependencies, pure TypeScript.
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Error Extractor
|
|
3
|
+
*
|
|
4
|
+
* Parses and formats ESLint error output for LLM consumption.
|
|
5
|
+
*
|
|
6
|
+
* @package @vibe-validate/extractors
|
|
7
|
+
*/
|
|
8
|
+
import type { ErrorExtractorResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Format ESLint errors
|
|
11
|
+
*
|
|
12
|
+
* Parses ESLint output format: `file:line:col - severity message [rule-name]`
|
|
13
|
+
*
|
|
14
|
+
* @param output - Raw ESLint command output
|
|
15
|
+
* @returns Structured error information with ESLint-specific guidance
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const result = extractESLintErrors(eslintOutput);
|
|
20
|
+
* console.log(result.summary); // "5 ESLint error(s), 2 warning(s)"
|
|
21
|
+
* console.log(result.guidance); // "Remove or prefix unused variables with underscore"
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractESLintErrors(output: string): ErrorExtractorResult;
|
|
25
|
+
//# sourceMappingURL=eslint-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint-extractor.d.ts","sourceRoot":"","sources":["../src/eslint-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAkB,MAAM,YAAY,CAAC;AA+CvE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAiExE"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint Error Extractor
|
|
3
|
+
*
|
|
4
|
+
* Parses and formats ESLint error output for LLM consumption.
|
|
5
|
+
*
|
|
6
|
+
* @package @vibe-validate/extractors
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Deduplicate ESLint errors by file:line:column
|
|
10
|
+
*
|
|
11
|
+
* When multiple rules report the same error at the same location,
|
|
12
|
+
* prefer @typescript-eslint/* rules over base ESLint rules.
|
|
13
|
+
*
|
|
14
|
+
* @param errors - Array of parsed ESLint errors
|
|
15
|
+
* @returns Deduplicated array of errors
|
|
16
|
+
*/
|
|
17
|
+
function deduplicateESLintErrors(errors) {
|
|
18
|
+
// Group errors by file:line:column
|
|
19
|
+
const errorMap = new Map();
|
|
20
|
+
for (const error of errors) {
|
|
21
|
+
const key = `${error.file}:${error.line}:${error.column}`;
|
|
22
|
+
if (!errorMap.has(key)) {
|
|
23
|
+
errorMap.set(key, []);
|
|
24
|
+
}
|
|
25
|
+
const locationErrors = errorMap.get(key);
|
|
26
|
+
if (locationErrors) {
|
|
27
|
+
locationErrors.push(error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// For each location, pick the best error
|
|
31
|
+
const deduplicated = [];
|
|
32
|
+
for (const [_key, locationErrors] of errorMap) {
|
|
33
|
+
if (locationErrors.length === 1) {
|
|
34
|
+
deduplicated.push(locationErrors[0]);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// Prefer @typescript-eslint/* rules over base ESLint rules
|
|
38
|
+
const typescriptEslintError = locationErrors.find(e => e.code?.startsWith('@typescript-eslint/'));
|
|
39
|
+
if (typescriptEslintError) {
|
|
40
|
+
deduplicated.push(typescriptEslintError);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// No typescript-eslint rule, just take the first one
|
|
44
|
+
deduplicated.push(locationErrors[0]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return deduplicated;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Format ESLint errors
|
|
51
|
+
*
|
|
52
|
+
* Parses ESLint output format: `file:line:col - severity message [rule-name]`
|
|
53
|
+
*
|
|
54
|
+
* @param output - Raw ESLint command output
|
|
55
|
+
* @returns Structured error information with ESLint-specific guidance
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const result = extractESLintErrors(eslintOutput);
|
|
60
|
+
* console.log(result.summary); // "5 ESLint error(s), 2 warning(s)"
|
|
61
|
+
* console.log(result.guidance); // "Remove or prefix unused variables with underscore"
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export function extractESLintErrors(output) {
|
|
65
|
+
const errors = [];
|
|
66
|
+
const lines = output.split('\n');
|
|
67
|
+
let currentFile = '';
|
|
68
|
+
for (const line of lines) {
|
|
69
|
+
// Try modern format first: file:line:col: severity message [rule-name]
|
|
70
|
+
const modernMatch = line.match(/^(.+?):(\d+):(\d+):\s+(error|warning)\s+(.+?)\s+(\S+)$/);
|
|
71
|
+
if (modernMatch) {
|
|
72
|
+
const ruleMessage = modernMatch[5].trim();
|
|
73
|
+
const ruleName = modernMatch[6].replace(/[[\]]/g, ''); // Remove brackets if present
|
|
74
|
+
errors.push({
|
|
75
|
+
file: modernMatch[1].trim(),
|
|
76
|
+
line: parseInt(modernMatch[2]),
|
|
77
|
+
column: parseInt(modernMatch[3]),
|
|
78
|
+
severity: modernMatch[4],
|
|
79
|
+
message: `${ruleMessage} (${ruleName})`,
|
|
80
|
+
code: ruleName
|
|
81
|
+
});
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
// Stylish format: spaces + line:col + spaces + severity + spaces + message + spaces + rule
|
|
85
|
+
const stylishMatch = line.match(/^\s+(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)\s*$/);
|
|
86
|
+
if (stylishMatch && currentFile) {
|
|
87
|
+
const ruleMessage = stylishMatch[4].trim();
|
|
88
|
+
const ruleName = stylishMatch[5];
|
|
89
|
+
errors.push({
|
|
90
|
+
file: currentFile,
|
|
91
|
+
line: parseInt(stylishMatch[1]),
|
|
92
|
+
column: parseInt(stylishMatch[2]),
|
|
93
|
+
severity: stylishMatch[3],
|
|
94
|
+
message: `${ruleMessage} (${ruleName})`,
|
|
95
|
+
code: ruleName
|
|
96
|
+
});
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
// Check if this is a file path line for stylish format (no colons, just a path)
|
|
100
|
+
if (line && !line.includes(':') && !line.startsWith(' ') && !line.startsWith('\t') && (line.includes('/') || line.includes('\\'))) {
|
|
101
|
+
// Potential file path for stylish format
|
|
102
|
+
currentFile = line.trim();
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Deduplicate errors (prefer @typescript-eslint/* rules over base ESLint rules)
|
|
107
|
+
const deduplicatedErrors = deduplicateESLintErrors(errors);
|
|
108
|
+
const errorCount = deduplicatedErrors.filter(e => e.severity === 'error').length;
|
|
109
|
+
const warningCount = deduplicatedErrors.filter(e => e.severity === 'warning').length;
|
|
110
|
+
// Build clean output (limit to first 10 for token efficiency)
|
|
111
|
+
const cleanOutput = deduplicatedErrors
|
|
112
|
+
.slice(0, 10)
|
|
113
|
+
.map(e => `${e.file}:${e.line}:${e.column} - ${e.message} [${e.code}]`)
|
|
114
|
+
.join('\n');
|
|
115
|
+
return {
|
|
116
|
+
errors: deduplicatedErrors.slice(0, 10),
|
|
117
|
+
summary: `${errorCount} ESLint error(s), ${warningCount} warning(s)`,
|
|
118
|
+
totalCount: deduplicatedErrors.length,
|
|
119
|
+
guidance: getESLintGuidance(deduplicatedErrors),
|
|
120
|
+
cleanOutput
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Generate ESLint-specific guidance based on rule violations
|
|
125
|
+
*
|
|
126
|
+
* @param errors - Parsed ESLint errors
|
|
127
|
+
* @returns Actionable guidance string
|
|
128
|
+
*/
|
|
129
|
+
function getESLintGuidance(errors) {
|
|
130
|
+
const rules = new Set(errors.map(e => e.code));
|
|
131
|
+
const guidance = [];
|
|
132
|
+
if (rules.has('@typescript-eslint/no-unused-vars')) {
|
|
133
|
+
guidance.push('Remove or prefix unused variables with underscore');
|
|
134
|
+
}
|
|
135
|
+
if (rules.has('no-console')) {
|
|
136
|
+
guidance.push('Replace console.log with logger');
|
|
137
|
+
}
|
|
138
|
+
if (guidance.length === 0) {
|
|
139
|
+
return 'Fix ESLint errors - run with --fix to auto-fix some issues';
|
|
140
|
+
}
|
|
141
|
+
return guidance.join('. ');
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=eslint-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint-extractor.js","sourceRoot":"","sources":["../src/eslint-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;GAQG;AACH,SAAS,uBAAuB,CAAC,MAAwB;IACvD,mCAAmC;IACnC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAC;IAErD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,QAAQ,CA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ED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,MAAwB;IACjD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,KAAK,CAAC,GAAG,CAAC,mCAAmC,CAAC,EAAE,CAAC;QACnD,QAAQ,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;QAC5B,QAAQ,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,4DAA4D,CAAC;IACtE,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Error Extractor
|
|
3
|
+
*
|
|
4
|
+
* Fallback extractor for unknown validation step types.
|
|
5
|
+
* Removes npm noise and extracts meaningful error lines.
|
|
6
|
+
*
|
|
7
|
+
* @package @vibe-validate/extractors
|
|
8
|
+
*/
|
|
9
|
+
import type { ErrorExtractorResult } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Generic error extractor (fallback)
|
|
12
|
+
*
|
|
13
|
+
* Cleans up command output by:
|
|
14
|
+
* - Removing npm script headers
|
|
15
|
+
* - Filtering out npm error lines
|
|
16
|
+
* - Limiting output to 20 lines for token efficiency
|
|
17
|
+
*
|
|
18
|
+
* @param output - Raw command output
|
|
19
|
+
* @param stepName - Name of validation step (for context)
|
|
20
|
+
* @returns Structured error information
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const result = extractGenericErrors(buildOutput, 'Build');
|
|
25
|
+
* console.log(result.summary); // "Build failed - see output"
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractGenericErrors(output: string, stepName: string): ErrorExtractorResult;
|
|
29
|
+
//# sourceMappingURL=generic-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-extractor.d.ts","sourceRoot":"","sources":["../src/generic-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,oBAAoB,CAqB3F"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Error Extractor
|
|
3
|
+
*
|
|
4
|
+
* Fallback extractor for unknown validation step types.
|
|
5
|
+
* Removes npm noise and extracts meaningful error lines.
|
|
6
|
+
*
|
|
7
|
+
* @package @vibe-validate/extractors
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Generic error extractor (fallback)
|
|
11
|
+
*
|
|
12
|
+
* Cleans up command output by:
|
|
13
|
+
* - Removing npm script headers
|
|
14
|
+
* - Filtering out npm error lines
|
|
15
|
+
* - Limiting output to 20 lines for token efficiency
|
|
16
|
+
*
|
|
17
|
+
* @param output - Raw command output
|
|
18
|
+
* @param stepName - Name of validation step (for context)
|
|
19
|
+
* @returns Structured error information
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const result = extractGenericErrors(buildOutput, 'Build');
|
|
24
|
+
* console.log(result.summary); // "Build failed - see output"
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function extractGenericErrors(output, stepName) {
|
|
28
|
+
// Remove npm script headers and noise
|
|
29
|
+
const cleaned = output
|
|
30
|
+
.split('\n')
|
|
31
|
+
.filter(line => {
|
|
32
|
+
// Remove npm script noise
|
|
33
|
+
if (line.startsWith('>'))
|
|
34
|
+
return false;
|
|
35
|
+
if (line.includes('npm ERR!'))
|
|
36
|
+
return false;
|
|
37
|
+
if (line.trim() === '')
|
|
38
|
+
return false;
|
|
39
|
+
return true;
|
|
40
|
+
})
|
|
41
|
+
.slice(0, 20) // Limit to 20 lines for token efficiency
|
|
42
|
+
.join('\n');
|
|
43
|
+
return {
|
|
44
|
+
errors: [],
|
|
45
|
+
summary: `${stepName} failed - see output`,
|
|
46
|
+
totalCount: 1,
|
|
47
|
+
guidance: 'Review the output above and fix the errors',
|
|
48
|
+
cleanOutput: cleaned
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=generic-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-extractor.js","sourceRoot":"","sources":["../src/generic-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,QAAgB;IACnE,sCAAsC;IACtC,MAAM,OAAO,GAAG,MAAM;SACnB,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,IAAI,CAAC,EAAE;QACb,0BAA0B;QAC1B,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YAAE,OAAO,KAAK,CAAC;QAC5C,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,KAAK,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAE,yCAAyC;SACvD,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;QACL,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,GAAG,QAAQ,sBAAsB;QAC1C,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,4CAA4C;QACtD,WAAW,EAAE,OAAO;KACrB,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vibe-validate/extractors
|
|
3
|
+
*
|
|
4
|
+
* LLM-optimized error extractors for validation output.
|
|
5
|
+
*
|
|
6
|
+
* Provides intelligent error parsing and formatting for common development tools:
|
|
7
|
+
* - TypeScript (tsc)
|
|
8
|
+
* - ESLint
|
|
9
|
+
* - Vitest/Jest
|
|
10
|
+
* - OpenAPI validators
|
|
11
|
+
* - Generic fallback
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { extractByStepName } from '@vibe-validate/extractors';
|
|
16
|
+
*
|
|
17
|
+
* const result = extractByStepName('TypeScript Type Checking', tscOutput);
|
|
18
|
+
* console.log(result.summary); // "3 type error(s), 0 warning(s)"
|
|
19
|
+
* console.log(result.guidance); // "Type mismatch - check variable/parameter types"
|
|
20
|
+
* console.log(result.cleanOutput); // Clean, formatted error list
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @package @vibe-validate/extractors
|
|
24
|
+
* @version 0.1.0
|
|
25
|
+
*/
|
|
26
|
+
export type { FormattedError, ErrorExtractorResult, ErrorExtractor } from './types.js';
|
|
27
|
+
export { extractTypeScriptErrors } from './typescript-extractor.js';
|
|
28
|
+
export { extractESLintErrors } from './eslint-extractor.js';
|
|
29
|
+
export { extractVitestErrors } from './vitest-extractor.js';
|
|
30
|
+
export { extractOpenAPIErrors } from './openapi-extractor.js';
|
|
31
|
+
export { extractGenericErrors } from './generic-extractor.js';
|
|
32
|
+
export { extractByStepName } from './smart-extractor.js';
|
|
33
|
+
export { stripAnsiCodes, extractErrorLines } from './utils.js';
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vibe-validate/extractors
|
|
3
|
+
*
|
|
4
|
+
* LLM-optimized error extractors for validation output.
|
|
5
|
+
*
|
|
6
|
+
* Provides intelligent error parsing and formatting for common development tools:
|
|
7
|
+
* - TypeScript (tsc)
|
|
8
|
+
* - ESLint
|
|
9
|
+
* - Vitest/Jest
|
|
10
|
+
* - OpenAPI validators
|
|
11
|
+
* - Generic fallback
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { extractByStepName } from '@vibe-validate/extractors';
|
|
16
|
+
*
|
|
17
|
+
* const result = extractByStepName('TypeScript Type Checking', tscOutput);
|
|
18
|
+
* console.log(result.summary); // "3 type error(s), 0 warning(s)"
|
|
19
|
+
* console.log(result.guidance); // "Type mismatch - check variable/parameter types"
|
|
20
|
+
* console.log(result.cleanOutput); // Clean, formatted error list
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @package @vibe-validate/extractors
|
|
24
|
+
* @version 0.1.0
|
|
25
|
+
*/
|
|
26
|
+
// Individual extractors (for direct use)
|
|
27
|
+
export { extractTypeScriptErrors } from './typescript-extractor.js';
|
|
28
|
+
export { extractESLintErrors } from './eslint-extractor.js';
|
|
29
|
+
export { extractVitestErrors } from './vitest-extractor.js';
|
|
30
|
+
export { extractOpenAPIErrors } from './openapi-extractor.js';
|
|
31
|
+
export { extractGenericErrors } from './generic-extractor.js';
|
|
32
|
+
// Smart extractor (auto-detection - recommended)
|
|
33
|
+
export { extractByStepName } from './smart-extractor.js';
|
|
34
|
+
// Utilities
|
|
35
|
+
export { stripAnsiCodes, extractErrorLines } from './utils.js';
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH,yCAAyC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,iDAAiD;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI Error Extractor
|
|
3
|
+
*
|
|
4
|
+
* Parses and formats OpenAPI specification validation errors for LLM consumption.
|
|
5
|
+
*
|
|
6
|
+
* @package @vibe-validate/extractors
|
|
7
|
+
*/
|
|
8
|
+
import type { ErrorExtractorResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Format OpenAPI validation errors
|
|
11
|
+
*
|
|
12
|
+
* Extracts error lines from OpenAPI validator output (like Redocly CLI).
|
|
13
|
+
*
|
|
14
|
+
* @param output - Raw OpenAPI validator output
|
|
15
|
+
* @returns Structured error information with OpenAPI-specific guidance
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const result = extractOpenAPIErrors(validatorOutput);
|
|
20
|
+
* console.log(result.summary); // "5 OpenAPI validation error(s)"
|
|
21
|
+
* console.log(result.guidance); // "Check openapi.yaml against OpenAPI 3.1 specification"
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractOpenAPIErrors(output: string): ErrorExtractorResult;
|
|
25
|
+
//# sourceMappingURL=openapi-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-extractor.d.ts","sourceRoot":"","sources":["../src/openapi-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAezE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI Error Extractor
|
|
3
|
+
*
|
|
4
|
+
* Parses and formats OpenAPI specification validation errors for LLM consumption.
|
|
5
|
+
*
|
|
6
|
+
* @package @vibe-validate/extractors
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Format OpenAPI validation errors
|
|
10
|
+
*
|
|
11
|
+
* Extracts error lines from OpenAPI validator output (like Redocly CLI).
|
|
12
|
+
*
|
|
13
|
+
* @param output - Raw OpenAPI validator output
|
|
14
|
+
* @returns Structured error information with OpenAPI-specific guidance
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const result = extractOpenAPIErrors(validatorOutput);
|
|
19
|
+
* console.log(result.summary); // "5 OpenAPI validation error(s)"
|
|
20
|
+
* console.log(result.guidance); // "Check openapi.yaml against OpenAPI 3.1 specification"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function extractOpenAPIErrors(output) {
|
|
24
|
+
// OpenAPI errors typically include location in schema
|
|
25
|
+
const lines = output.split('\n')
|
|
26
|
+
.filter(line => line.includes('error') || line.includes('Error'))
|
|
27
|
+
.slice(0, 10);
|
|
28
|
+
const cleanOutput = lines.join('\n');
|
|
29
|
+
return {
|
|
30
|
+
errors: [],
|
|
31
|
+
summary: `${lines.length} OpenAPI validation error(s)`,
|
|
32
|
+
totalCount: lines.length,
|
|
33
|
+
guidance: 'Check openapi.yaml against OpenAPI 3.1 specification',
|
|
34
|
+
cleanOutput
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=openapi-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-extractor.js","sourceRoot":"","sources":["../src/openapi-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,sDAAsD;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;SAC7B,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;SAChE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEhB,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAErC,OAAO;QACL,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,GAAG,KAAK,CAAC,MAAM,8BAA8B;QACtD,UAAU,EAAE,KAAK,CAAC,MAAM;QACxB,QAAQ,EAAE,sDAAsD;QAChE,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Error Extractor
|
|
3
|
+
*
|
|
4
|
+
* Auto-detects validation step type and applies appropriate extractor.
|
|
5
|
+
*
|
|
6
|
+
* @package @vibe-validate/extractors
|
|
7
|
+
*/
|
|
8
|
+
import type { ErrorExtractorResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Smart extractor - detects step type and applies appropriate formatting
|
|
11
|
+
*
|
|
12
|
+
* Auto-detection rules:
|
|
13
|
+
* - TypeScript: Step name contains "TypeScript" or "typecheck"
|
|
14
|
+
* - ESLint: Step name contains "ESLint" or "lint"
|
|
15
|
+
* - Vitest/Jest: Step name contains "test" (but not "OpenAPI")
|
|
16
|
+
* - OpenAPI: Step name contains "OpenAPI"
|
|
17
|
+
* - Generic: Fallback for unknown step types
|
|
18
|
+
*
|
|
19
|
+
* @param stepName - Name of validation step (used for detection)
|
|
20
|
+
* @param output - Raw command output
|
|
21
|
+
* @returns Structured error information from appropriate extractor
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const result = extractByStepName('TypeScript Type Checking', tscOutput);
|
|
26
|
+
* // Uses extractTypeScriptErrors automatically
|
|
27
|
+
*
|
|
28
|
+
* const result2 = extractByStepName('ESLint', eslintOutput);
|
|
29
|
+
* // Uses extractESLintErrors automatically
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function extractByStepName(stepName: string, output: string): ErrorExtractorResult;
|
|
33
|
+
//# sourceMappingURL=smart-extractor.d.ts.map
|
|
@@ -0,0 +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,MAAM,YAAY,CAAC;AAOvD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAoBxF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Error Extractor
|
|
3
|
+
*
|
|
4
|
+
* Auto-detects validation step type and applies appropriate extractor.
|
|
5
|
+
*
|
|
6
|
+
* @package @vibe-validate/extractors
|
|
7
|
+
*/
|
|
8
|
+
import { extractTypeScriptErrors } from './typescript-extractor.js';
|
|
9
|
+
import { extractESLintErrors } from './eslint-extractor.js';
|
|
10
|
+
import { extractVitestErrors } from './vitest-extractor.js';
|
|
11
|
+
import { extractOpenAPIErrors } from './openapi-extractor.js';
|
|
12
|
+
import { extractGenericErrors } from './generic-extractor.js';
|
|
13
|
+
/**
|
|
14
|
+
* Smart extractor - detects step type and applies appropriate formatting
|
|
15
|
+
*
|
|
16
|
+
* Auto-detection rules:
|
|
17
|
+
* - TypeScript: Step name contains "TypeScript" or "typecheck"
|
|
18
|
+
* - ESLint: Step name contains "ESLint" or "lint"
|
|
19
|
+
* - Vitest/Jest: Step name contains "test" (but not "OpenAPI")
|
|
20
|
+
* - OpenAPI: Step name contains "OpenAPI"
|
|
21
|
+
* - Generic: Fallback for unknown step types
|
|
22
|
+
*
|
|
23
|
+
* @param stepName - Name of validation step (used for detection)
|
|
24
|
+
* @param output - Raw command output
|
|
25
|
+
* @returns Structured error information from appropriate extractor
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const result = extractByStepName('TypeScript Type Checking', tscOutput);
|
|
30
|
+
* // Uses extractTypeScriptErrors automatically
|
|
31
|
+
*
|
|
32
|
+
* const result2 = extractByStepName('ESLint', eslintOutput);
|
|
33
|
+
* // Uses extractESLintErrors automatically
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function extractByStepName(stepName, output) {
|
|
37
|
+
const lowerStepName = stepName.toLowerCase();
|
|
38
|
+
if (lowerStepName.includes('typescript') || lowerStepName.includes('typecheck') || lowerStepName.includes('tsc')) {
|
|
39
|
+
return extractTypeScriptErrors(output);
|
|
40
|
+
}
|
|
41
|
+
if (lowerStepName.includes('eslint') || lowerStepName.includes('lint')) {
|
|
42
|
+
return extractESLintErrors(output);
|
|
43
|
+
}
|
|
44
|
+
if (lowerStepName.includes('test') && !lowerStepName.includes('openapi')) {
|
|
45
|
+
return extractVitestErrors(output);
|
|
46
|
+
}
|
|
47
|
+
if (lowerStepName.includes('openapi')) {
|
|
48
|
+
return extractOpenAPIErrors(output);
|
|
49
|
+
}
|
|
50
|
+
return extractGenericErrors(output, stepName);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=smart-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-extractor.js","sourceRoot":"","sources":["../src/smart-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,MAAc;IAChE,MAAM,aAAa,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAE7C,IAAI,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACj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