* Validate spec content from a string (used for pre-write validation of rebuilt specs)
(specName: string, content: string)
| 55 | * Validate spec content from a string (used for pre-write validation of rebuilt specs) |
| 56 | */ |
| 57 | async validateSpecContent(specName: string, content: string): Promise<ValidationReport> { |
| 58 | const issues: ValidationIssue[] = []; |
| 59 | try { |
| 60 | const parser = new MarkdownParser(content); |
| 61 | const spec = parser.parseSpec(specName); |
| 62 | const result = SpecSchema.safeParse(spec); |
| 63 | if (!result.success) { |
| 64 | issues.push(...this.convertZodErrors(result.error)); |
| 65 | } |
| 66 | issues.push(...this.applySpecRules(spec, content)); |
| 67 | } catch (error) { |
| 68 | const baseMessage = error instanceof Error ? error.message : 'Unknown error'; |
| 69 | const enriched = this.enrichTopLevelError(specName, baseMessage); |
| 70 | issues.push({ level: 'ERROR', path: 'file', message: enriched }); |
| 71 | } |
| 72 | return this.createReport(issues); |
| 73 | } |
| 74 | |
| 75 | async validateChange(filePath: string): Promise<ValidationReport> { |
| 76 | const issues: ValidationIssue[] = []; |
no test coverage detected