uilint-core 0.1.0 → 0.1.1
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.
|
@@ -660,7 +660,9 @@ function extractStyleValues(content) {
|
|
|
660
660
|
result.fontSizes.push(match[1]);
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
-
const fontFamilyMatches = content.matchAll(
|
|
663
|
+
const fontFamilyMatches = content.matchAll(
|
|
664
|
+
/font-family:\s*["']?([^"',\n]+)/gi
|
|
665
|
+
);
|
|
664
666
|
for (const match of fontFamilyMatches) {
|
|
665
667
|
const family = match[1].trim();
|
|
666
668
|
if (!result.fontFamilies.includes(family)) {
|
|
@@ -675,7 +677,9 @@ function generateStyleGuideFromStyles(styles) {
|
|
|
675
677
|
const lines = [];
|
|
676
678
|
lines.push("# UI Style Guide");
|
|
677
679
|
lines.push("");
|
|
678
|
-
lines.push(
|
|
680
|
+
lines.push(
|
|
681
|
+
"> Auto-generated by UILint. Edit this file to define your design system."
|
|
682
|
+
);
|
|
679
683
|
lines.push("");
|
|
680
684
|
lines.push("## Colors");
|
|
681
685
|
lines.push("");
|
|
@@ -733,7 +737,10 @@ function generateStyleGuideFromStyles(styles) {
|
|
|
733
737
|
if (gcd >= 4) {
|
|
734
738
|
lines.push(`- **Base unit**: ${gcd}px`);
|
|
735
739
|
}
|
|
736
|
-
const uniqueSpacing = [...new Set(sortedSpacing.map(([v]) => v))].slice(
|
|
740
|
+
const uniqueSpacing = [...new Set(sortedSpacing.map(([v]) => v))].slice(
|
|
741
|
+
0,
|
|
742
|
+
8
|
|
743
|
+
);
|
|
737
744
|
lines.push(`- **Common values**: ${uniqueSpacing.join(", ")}`);
|
|
738
745
|
} else {
|
|
739
746
|
lines.push("- No spacing values detected");
|
|
@@ -831,7 +838,9 @@ function validateCode(code, styleGuide) {
|
|
|
831
838
|
});
|
|
832
839
|
}
|
|
833
840
|
}
|
|
834
|
-
const hardcodedPixels = code.matchAll(
|
|
841
|
+
const hardcodedPixels = code.matchAll(
|
|
842
|
+
/(?:margin|padding|gap)[-:].*?(\d+)px/gi
|
|
843
|
+
);
|
|
835
844
|
for (const match of hardcodedPixels) {
|
|
836
845
|
const value = parseInt(match[1]);
|
|
837
846
|
if (value % 4 !== 0) {
|
|
@@ -1021,4 +1030,4 @@ export {
|
|
|
1021
1030
|
validateCode,
|
|
1022
1031
|
lintSnippet
|
|
1023
1032
|
};
|
|
1024
|
-
//# sourceMappingURL=chunk-
|
|
1033
|
+
//# sourceMappingURL=chunk-P5RPW6PI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ollama/prompts.ts","../src/ollama/client.ts","../src/scanner/style-extractor.ts","../src/styleguide/schema.ts","../src/styleguide/parser.ts","../src/styleguide/generator.ts","../src/validation/validate.ts"],"sourcesContent":["/**\n * LLM prompt builders for UILint analysis\n */\n\n/**\n * Builds a prompt for style analysis\n */\nexport function buildAnalysisPrompt(\n styleSummary: string,\n styleGuide: string | null\n): string {\n const guideSection = styleGuide\n ? `## Current Style Guide\\n${styleGuide}\\n\\n`\n : \"## No Style Guide Found\\nAnalyze the styles and identify inconsistencies.\\n\\n\";\n\n return `You are a UI consistency analyzer. Analyze the following extracted styles and identify inconsistencies.\n\n${guideSection}\n\n${styleSummary}\n\nRespond with a JSON object containing an \"issues\" array. Each issue should have:\n- id: unique string identifier\n- type: one of \"color\", \"typography\", \"spacing\", \"component\", \"responsive\", \"accessibility\"\n- message: human-readable description of the issue\n- currentValue: the problematic value found\n- expectedValue: what it should be (if known from style guide)\n- suggestion: how to fix it\n\nFocus on:\n1. Similar but not identical colors (e.g., #3B82F6 vs #3575E2)\n2. Inconsistent font sizes or weights\n3. Spacing values that don't follow a consistent scale (e.g., 4px base unit)\n4. Mixed border-radius values\n\nBe concise and actionable. Only report significant inconsistencies.\n\nExample response:\n{\n \"issues\": [\n {\n \"id\": \"color-1\",\n \"type\": \"color\",\n \"message\": \"Found similar blue colors that should be consolidated\",\n \"currentValue\": \"#3575E2\",\n \"expectedValue\": \"#3B82F6\",\n \"suggestion\": \"Use the primary blue #3B82F6 consistently\"\n }\n ]\n}`;\n}\n\n/**\n * Builds a prompt for style guide generation\n */\nexport function buildStyleGuidePrompt(styleSummary: string): string {\n return `You are a design system expert. Based on the following detected styles, generate a clean, organized style guide in Markdown format.\n\n${styleSummary}\n\nGenerate a style guide with these sections:\n1. Colors - List the main colors with semantic names (Primary, Secondary, etc.)\n2. Typography - Font families, sizes, and weights\n3. Spacing - Base unit and common spacing values\n4. Components - Common component patterns\n\nUse this format:\n# UI Style Guide\n\n## Colors\n- **Primary**: #HEXCODE (usage description)\n- **Secondary**: #HEXCODE (usage description)\n...\n\n## Typography\n- **Font Family**: FontName\n- **Font Sizes**: list of sizes\n- **Font Weights**: list of weights\n\n## Spacing\n- **Base unit**: Xpx\n- **Common values**: list of values\n\n## Components\n- **Buttons**: styles\n- **Cards**: styles\n...\n\nBe concise and focus on the most used values.`;\n}\n\n/**\n * Builds a prompt for querying the style guide\n */\nexport function buildQueryPrompt(\n query: string,\n styleGuide: string | null\n): string {\n if (!styleGuide) {\n return `The user is asking: \"${query}\"\n\nNo style guide has been created yet. Explain that they should run \"uilint init\" to create a style guide from their existing styles.`;\n }\n\n return `You are a helpful assistant that answers questions about a UI style guide.\n\n## Style Guide\n${styleGuide}\n\n## User Question\n${query}\n\nProvide a clear, concise answer based on the style guide above. If the style guide doesn't contain the information needed, say so and suggest what might be missing.`;\n}\n\n/**\n * Builds a prompt for code validation\n */\nexport function buildValidationPrompt(\n code: string,\n styleGuide: string | null\n): string {\n const guideSection = styleGuide\n ? `## Style Guide\\n${styleGuide}\\n\\n`\n : \"## No Style Guide\\nValidate for general best practices.\\n\\n\";\n\n return `You are a UI code validator. Check the following code against the style guide and best practices.\n\n${guideSection}\n\n## Code to Validate\n\\`\\`\\`tsx\n${code}\n\\`\\`\\`\n\nRespond with a JSON object containing:\n- valid: boolean (true if no errors found)\n- issues: array of issues, each with:\n - type: \"error\" or \"warning\"\n - message: description of the issue\n - suggestion: how to fix it\n\nFocus on:\n1. Colors not in the style guide\n2. Spacing values not following the design system\n3. Typography inconsistencies\n4. Accessibility issues (missing alt text, etc.)\n\nExample response:\n{\n \"valid\": false,\n \"issues\": [\n {\n \"type\": \"warning\",\n \"message\": \"Color #FF0000 is not in the style guide\",\n \"suggestion\": \"Use the error color #EF4444 instead\"\n }\n ]\n}`;\n}\n","/**\n * Ollama API client for LLM interactions\n */\n\nimport type {\n UILintIssue,\n AnalysisResult,\n ValidationResult,\n OllamaClientOptions,\n} from \"../types.js\";\nimport {\n buildAnalysisPrompt,\n buildStyleGuidePrompt,\n buildQueryPrompt,\n buildValidationPrompt,\n} from \"./prompts.js\";\n\nconst DEFAULT_BASE_URL = \"http://localhost:11434\";\nconst DEFAULT_MODEL = \"qwen2.5-coder:7b\";\nconst DEFAULT_TIMEOUT = 60000;\n\nexport class OllamaClient {\n private baseUrl: string;\n private model: string;\n private timeout: number;\n\n constructor(options: OllamaClientOptions = {}) {\n this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;\n this.model = options.model || DEFAULT_MODEL;\n this.timeout = options.timeout || DEFAULT_TIMEOUT;\n }\n\n /**\n * Analyzes styles and returns issues\n */\n async analyzeStyles(\n styleSummary: string,\n styleGuide: string | null\n ): Promise<AnalysisResult> {\n const startTime = Date.now();\n const prompt = buildAnalysisPrompt(styleSummary, styleGuide);\n\n try {\n const response = await this.generate(prompt);\n const issues = this.parseIssuesResponse(response);\n\n return {\n issues,\n analysisTime: Date.now() - startTime,\n };\n } catch (error) {\n console.error(\"[UILint] Analysis failed:\", error);\n return {\n issues: [],\n analysisTime: Date.now() - startTime,\n };\n }\n }\n\n /**\n * Generates a style guide from detected styles\n */\n async generateStyleGuide(styleSummary: string): Promise<string | null> {\n const prompt = buildStyleGuidePrompt(styleSummary);\n\n try {\n const response = await this.generate(prompt, false);\n return response;\n } catch (error) {\n console.error(\"[UILint] Style guide generation failed:\", error);\n return null;\n }\n }\n\n /**\n * Queries the style guide for specific information\n */\n async queryStyleGuide(\n query: string,\n styleGuide: string | null\n ): Promise<string> {\n const prompt = buildQueryPrompt(query, styleGuide);\n\n try {\n const response = await this.generate(prompt, false);\n return response;\n } catch (error) {\n console.error(\"[UILint] Query failed:\", error);\n return \"Failed to query style guide. Please try again.\";\n }\n }\n\n /**\n * Validates code against the style guide\n */\n async validateCode(\n code: string,\n styleGuide: string | null\n ): Promise<ValidationResult> {\n const prompt = buildValidationPrompt(code, styleGuide);\n\n try {\n const response = await this.generate(prompt);\n return this.parseValidationResponse(response);\n } catch (error) {\n console.error(\"[UILint] Validation failed:\", error);\n return { valid: true, issues: [] };\n }\n }\n\n /**\n * Core generate method that calls Ollama API\n */\n private async generate(\n prompt: string,\n jsonFormat: boolean = true\n ): Promise<string> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const response = await fetch(`${this.baseUrl}/api/generate`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n model: this.model,\n prompt,\n stream: false,\n ...(jsonFormat && { format: \"json\" }),\n }),\n signal: controller.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status}`);\n }\n\n const data = await response.json();\n return data.response || \"\";\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Parses issues from LLM response\n */\n private parseIssuesResponse(response: string): UILintIssue[] {\n try {\n const parsed = JSON.parse(response);\n return parsed.issues || [];\n } catch {\n console.warn(\"[UILint] Failed to parse LLM response as JSON\");\n return [];\n }\n }\n\n /**\n * Parses validation result from LLM response\n */\n private parseValidationResponse(response: string): ValidationResult {\n try {\n const parsed = JSON.parse(response);\n return {\n valid: parsed.valid ?? true,\n issues: parsed.issues || [],\n };\n } catch {\n console.warn(\"[UILint] Failed to parse validation response\");\n return { valid: true, issues: [] };\n }\n }\n\n /**\n * Checks if Ollama is available\n */\n async isAvailable(): Promise<boolean> {\n try {\n const response = await fetch(`${this.baseUrl}/api/tags`, {\n method: \"GET\",\n signal: AbortSignal.timeout(5000),\n });\n return response.ok;\n } catch {\n return false;\n }\n }\n\n /**\n * Gets the current model\n */\n getModel(): string {\n return this.model;\n }\n\n /**\n * Sets the model\n */\n setModel(model: string): void {\n this.model = model;\n }\n}\n\n// Default singleton instance\nlet defaultClient: OllamaClient | null = null;\n\nexport function getOllamaClient(options?: OllamaClientOptions): OllamaClient {\n if (!defaultClient || options) {\n defaultClient = new OllamaClient(options);\n }\n return defaultClient;\n}\n","/**\n * Style extraction from DOM elements\n */\n\nimport type { ExtractedStyles, SerializedStyles } from \"../types.js\";\n\n/**\n * Extracts all computed styles from elements in the document\n * Works in both browser and JSDOM environments\n */\nexport function extractStyles(\n root: Element | Document,\n getComputedStyle: (el: Element) => CSSStyleDeclaration\n): ExtractedStyles {\n const styles: ExtractedStyles = {\n colors: new Map(),\n fontSizes: new Map(),\n fontFamilies: new Map(),\n fontWeights: new Map(),\n spacing: new Map(),\n borderRadius: new Map(),\n };\n\n const elements = root.querySelectorAll(\"*\");\n\n elements.forEach((element) => {\n // nodeType === 1 means Element node (works in both browser and JSDOM)\n if (element.nodeType !== 1) return;\n\n const computed = getComputedStyle(element);\n\n // Extract colors\n extractColor(computed.color, styles.colors);\n extractColor(computed.backgroundColor, styles.colors);\n extractColor(computed.borderColor, styles.colors);\n\n // Extract typography\n incrementMap(styles.fontSizes, computed.fontSize);\n incrementMap(styles.fontFamilies, normalizeFontFamily(computed.fontFamily));\n incrementMap(styles.fontWeights, computed.fontWeight);\n\n // Extract spacing\n extractSpacing(computed.margin, styles.spacing);\n extractSpacing(computed.padding, styles.spacing);\n incrementMap(styles.spacing, computed.gap);\n\n // Extract border radius\n incrementMap(styles.borderRadius, computed.borderRadius);\n });\n\n return styles;\n}\n\n/**\n * Extracts styles from browser DOM (uses window.getComputedStyle)\n */\nexport function extractStylesFromDOM(root?: Element | Document): ExtractedStyles {\n const targetRoot = root || document.body;\n return extractStyles(targetRoot, (el) => window.getComputedStyle(el));\n}\n\nfunction extractColor(color: string, map: Map<string, number>): void {\n if (!color || color === \"transparent\" || color === \"rgba(0, 0, 0, 0)\") return;\n\n // Normalize to hex\n const hex = rgbToHex(color);\n if (hex) {\n incrementMap(map, hex);\n }\n}\n\nfunction extractSpacing(value: string, map: Map<string, number>): void {\n if (!value || value === \"0px\") return;\n\n // Split compound values (e.g., \"10px 20px 10px 20px\")\n const values = value.split(\" \").filter((v) => v && v !== \"0px\");\n values.forEach((v) => incrementMap(map, v));\n}\n\nfunction incrementMap(map: Map<string, number>, value: string): void {\n if (!value || value === \"normal\" || value === \"auto\") return;\n map.set(value, (map.get(value) || 0) + 1);\n}\n\nfunction normalizeFontFamily(fontFamily: string): string {\n // Get the primary font (first in the stack)\n const primary = fontFamily.split(\",\")[0].trim();\n return primary.replace(/['\"]/g, \"\");\n}\n\nfunction rgbToHex(rgb: string): string | null {\n // Handle hex values\n if (rgb.startsWith(\"#\")) return rgb.toUpperCase();\n\n // Handle rgb/rgba values\n const match = rgb.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/);\n if (!match) return null;\n\n const [, r, g, b] = match;\n const toHex = (n: string) => parseInt(n).toString(16).padStart(2, \"0\");\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase();\n}\n\n/**\n * Converts ExtractedStyles maps to plain objects for serialization\n */\nexport function serializeStyles(styles: ExtractedStyles): SerializedStyles {\n return {\n colors: Object.fromEntries(styles.colors),\n fontSizes: Object.fromEntries(styles.fontSizes),\n fontFamilies: Object.fromEntries(styles.fontFamilies),\n fontWeights: Object.fromEntries(styles.fontWeights),\n spacing: Object.fromEntries(styles.spacing),\n borderRadius: Object.fromEntries(styles.borderRadius),\n };\n}\n\n/**\n * Converts SerializedStyles back to ExtractedStyles\n */\nexport function deserializeStyles(serialized: SerializedStyles): ExtractedStyles {\n return {\n colors: new Map(Object.entries(serialized.colors)),\n fontSizes: new Map(Object.entries(serialized.fontSizes)),\n fontFamilies: new Map(Object.entries(serialized.fontFamilies)),\n fontWeights: new Map(Object.entries(serialized.fontWeights)),\n spacing: new Map(Object.entries(serialized.spacing)),\n borderRadius: new Map(Object.entries(serialized.borderRadius)),\n };\n}\n\n/**\n * Creates a summary of extracted styles for LLM analysis\n */\nexport function createStyleSummary(styles: ExtractedStyles): string {\n const lines: string[] = [];\n\n lines.push(\"## Detected Styles Summary\\n\");\n\n // Colors\n lines.push(\"### Colors\");\n const sortedColors = [...styles.colors.entries()].sort((a, b) => b[1] - a[1]);\n sortedColors.slice(0, 20).forEach(([color, count]) => {\n lines.push(`- ${color}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Font sizes\n lines.push(\"### Font Sizes\");\n const sortedFontSizes = [...styles.fontSizes.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n sortedFontSizes.forEach(([size, count]) => {\n lines.push(`- ${size}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Font families\n lines.push(\"### Font Families\");\n const sortedFontFamilies = [...styles.fontFamilies.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n sortedFontFamilies.forEach(([family, count]) => {\n lines.push(`- ${family}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Font weights\n lines.push(\"### Font Weights\");\n const sortedFontWeights = [...styles.fontWeights.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n sortedFontWeights.forEach(([weight, count]) => {\n lines.push(`- ${weight}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Spacing\n lines.push(\"### Spacing Values\");\n const sortedSpacing = [...styles.spacing.entries()].sort((a, b) => b[1] - a[1]);\n sortedSpacing.slice(0, 15).forEach(([value, count]) => {\n lines.push(`- ${value}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Border radius\n lines.push(\"### Border Radius\");\n const sortedBorderRadius = [...styles.borderRadius.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n sortedBorderRadius.forEach(([value, count]) => {\n lines.push(`- ${value}: ${count} occurrences`);\n });\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Truncates HTML to a maximum length\n */\nexport function truncateHTML(html: string, maxLength: number = 50000): string {\n if (html.length <= maxLength) return html;\n return html.slice(0, maxLength) + \"<!-- truncated -->\";\n}\n\n","/**\n * Style guide schema and utilities\n */\n\nimport type { StyleGuide, ColorRule, TypographyRule, SpacingRule, ComponentRule } from \"../types.js\";\n\n/**\n * Creates an empty style guide structure\n */\nexport function createEmptyStyleGuide(): StyleGuide {\n return {\n colors: [],\n typography: [],\n spacing: [],\n components: [],\n };\n}\n\n/**\n * Validates a style guide object\n */\nexport function validateStyleGuide(guide: unknown): guide is StyleGuide {\n if (!guide || typeof guide !== \"object\") return false;\n\n const g = guide as Record<string, unknown>;\n\n return (\n Array.isArray(g.colors) &&\n Array.isArray(g.typography) &&\n Array.isArray(g.spacing) &&\n Array.isArray(g.components)\n );\n}\n\n/**\n * Merges detected styles into an existing style guide\n */\nexport function mergeStyleGuides(\n existing: StyleGuide,\n detected: Partial<StyleGuide>\n): StyleGuide {\n return {\n colors: mergeColorRules(existing.colors, detected.colors || []),\n typography: mergeTypographyRules(existing.typography, detected.typography || []),\n spacing: mergeSpacingRules(existing.spacing, detected.spacing || []),\n components: mergeComponentRules(existing.components, detected.components || []),\n };\n}\n\nfunction mergeColorRules(existing: ColorRule[], detected: ColorRule[]): ColorRule[] {\n const merged = [...existing];\n detected.forEach((rule) => {\n const existingIndex = merged.findIndex(\n (e) => e.name === rule.name || e.value === rule.value\n );\n if (existingIndex === -1) {\n merged.push(rule);\n }\n });\n return merged;\n}\n\nfunction mergeTypographyRules(existing: TypographyRule[], detected: TypographyRule[]): TypographyRule[] {\n const merged = [...existing];\n detected.forEach((rule) => {\n const existingIndex = merged.findIndex((e) => e.element === rule.element);\n if (existingIndex === -1) {\n merged.push(rule);\n }\n });\n return merged;\n}\n\nfunction mergeSpacingRules(existing: SpacingRule[], detected: SpacingRule[]): SpacingRule[] {\n const merged = [...existing];\n detected.forEach((rule) => {\n const existingIndex = merged.findIndex(\n (e) => e.name === rule.name || e.value === rule.value\n );\n if (existingIndex === -1) {\n merged.push(rule);\n }\n });\n return merged;\n}\n\nfunction mergeComponentRules(existing: ComponentRule[], detected: ComponentRule[]): ComponentRule[] {\n const merged = [...existing];\n detected.forEach((rule) => {\n const existingIndex = merged.findIndex((e) => e.name === rule.name);\n if (existingIndex === -1) {\n merged.push(rule);\n }\n });\n return merged;\n}\n\n/**\n * Creates a color rule\n */\nexport function createColorRule(\n name: string,\n value: string,\n usage: string = \"\"\n): ColorRule {\n return { name, value: value.toUpperCase(), usage };\n}\n\n/**\n * Creates a typography rule\n */\nexport function createTypographyRule(\n element: string,\n options: Partial<Omit<TypographyRule, \"element\">> = {}\n): TypographyRule {\n return { element, ...options };\n}\n\n/**\n * Creates a spacing rule\n */\nexport function createSpacingRule(name: string, value: string): SpacingRule {\n return { name, value };\n}\n\n/**\n * Creates a component rule\n */\nexport function createComponentRule(name: string, styles: string[]): ComponentRule {\n return { name, styles };\n}\n\n","/**\n * Parse Markdown style guides into structured data\n */\n\nimport type {\n StyleGuide,\n ColorRule,\n TypographyRule,\n SpacingRule,\n ComponentRule,\n ExtractedStyleValues,\n} from \"../types.js\";\nimport { createEmptyStyleGuide } from \"./schema.js\";\n\n/**\n * Parses a Markdown style guide into a structured object\n */\nexport function parseStyleGuide(markdown: string): StyleGuide {\n const guide = createEmptyStyleGuide();\n const sections = splitIntoSections(markdown);\n\n sections.forEach(({ title, content }) => {\n const lowerTitle = title.toLowerCase();\n\n if (lowerTitle.includes(\"color\")) {\n guide.colors = parseColorSection(content);\n } else if (\n lowerTitle.includes(\"typography\") ||\n lowerTitle.includes(\"font\")\n ) {\n guide.typography = parseTypographySection(content);\n } else if (lowerTitle.includes(\"spacing\")) {\n guide.spacing = parseSpacingSection(content);\n } else if (lowerTitle.includes(\"component\")) {\n guide.components = parseComponentSection(content);\n }\n });\n\n return guide;\n}\n\ninterface Section {\n title: string;\n content: string;\n}\n\nfunction splitIntoSections(markdown: string): Section[] {\n const sections: Section[] = [];\n const lines = markdown.split(\"\\n\");\n\n let currentTitle = \"\";\n let currentContent: string[] = [];\n\n lines.forEach((line) => {\n const headerMatch = line.match(/^##\\s+(.+)$/);\n\n if (headerMatch) {\n if (currentTitle) {\n sections.push({\n title: currentTitle,\n content: currentContent.join(\"\\n\"),\n });\n }\n currentTitle = headerMatch[1];\n currentContent = [];\n } else {\n currentContent.push(line);\n }\n });\n\n if (currentTitle) {\n sections.push({\n title: currentTitle,\n content: currentContent.join(\"\\n\"),\n });\n }\n\n return sections;\n}\n\nfunction parseColorSection(content: string): ColorRule[] {\n const colors: ColorRule[] = [];\n const lines = content.split(\"\\n\");\n\n lines.forEach((line) => {\n // Match patterns like: - **Primary**: #3B82F6 (used in buttons)\n const match = line.match(\n /[-*]\\s*\\*?\\*?([^*:]+)\\*?\\*?:\\s*(#[A-Fa-f0-9]{6})\\s*(?:\\(([^)]+)\\))?/\n );\n\n if (match) {\n colors.push({\n name: match[1].trim(),\n value: match[2].toUpperCase(),\n usage: match[3] || \"\",\n });\n }\n });\n\n return colors;\n}\n\nfunction parseTypographySection(content: string): TypographyRule[] {\n const typography: TypographyRule[] = [];\n const lines = content.split(\"\\n\");\n\n lines.forEach((line) => {\n // Match patterns like: - **Headings**: font-family: \"Inter\", font-size: 24px\n const elementMatch = line.match(/[-*]\\s*\\*?\\*?([^*:]+)\\*?\\*?:\\s*(.+)/);\n\n if (elementMatch) {\n const rule: TypographyRule = {\n element: elementMatch[1].trim(),\n };\n\n const props = elementMatch[2];\n\n const fontFamilyMatch = props.match(/font-family:\\s*\"?([^\",]+)\"?/);\n if (fontFamilyMatch) rule.fontFamily = fontFamilyMatch[1].trim();\n\n const fontSizeMatch = props.match(/font-size:\\s*(\\d+px)/);\n if (fontSizeMatch) rule.fontSize = fontSizeMatch[1];\n\n const fontWeightMatch = props.match(/font-weight:\\s*(\\d+)/);\n if (fontWeightMatch) rule.fontWeight = fontWeightMatch[1];\n\n const lineHeightMatch = props.match(/line-height:\\s*([\\d.]+)/);\n if (lineHeightMatch) rule.lineHeight = lineHeightMatch[1];\n\n typography.push(rule);\n }\n });\n\n return typography;\n}\n\nfunction parseSpacingSection(content: string): SpacingRule[] {\n const spacing: SpacingRule[] = [];\n const lines = content.split(\"\\n\");\n\n lines.forEach((line) => {\n // Match patterns like: - **Base unit**: 4px\n const match = line.match(/[-*]\\s*\\*?\\*?([^*:]+)\\*?\\*?:\\s*(.+)/);\n\n if (match) {\n spacing.push({\n name: match[1].trim(),\n value: match[2].trim(),\n });\n }\n });\n\n return spacing;\n}\n\nfunction parseComponentSection(content: string): ComponentRule[] {\n const components: ComponentRule[] = [];\n const lines = content.split(\"\\n\");\n\n lines.forEach((line) => {\n // Match patterns like: - **Buttons**: rounded-lg, px-4 py-2\n const match = line.match(/[-*]\\s*\\*?\\*?([^*:]+)\\*?\\*?:\\s*(.+)/);\n\n if (match) {\n components.push({\n name: match[1].trim(),\n styles: match[2].split(\",\").map((s) => s.trim()),\n });\n }\n });\n\n return components;\n}\n\n/**\n * Parses sections from a Markdown style guide (simpler format)\n */\nexport function parseStyleGuideSections(\n content: string\n): Record<string, string> {\n const sections: Record<string, string> = {};\n const lines = content.split(\"\\n\");\n\n let currentSection = \"intro\";\n let currentContent: string[] = [];\n\n for (const line of lines) {\n const headerMatch = line.match(/^##\\s+(.+)$/);\n\n if (headerMatch) {\n if (currentContent.length > 0) {\n sections[currentSection.toLowerCase()] = currentContent\n .join(\"\\n\")\n .trim();\n }\n\n currentSection = headerMatch[1];\n currentContent = [];\n } else {\n currentContent.push(line);\n }\n }\n\n if (currentContent.length > 0) {\n sections[currentSection.toLowerCase()] = currentContent.join(\"\\n\").trim();\n }\n\n return sections;\n}\n\n/**\n * Extracts specific values from the style guide\n */\nexport function extractStyleValues(content: string): ExtractedStyleValues {\n const result: ExtractedStyleValues = {\n colors: [],\n fontSizes: [],\n fontFamilies: [],\n spacing: [],\n borderRadius: [],\n };\n\n // Extract hex colors\n const colorMatches = content.matchAll(/#[A-Fa-f0-9]{6}\\b/g);\n for (const match of colorMatches) {\n if (!result.colors.includes(match[0].toUpperCase())) {\n result.colors.push(match[0].toUpperCase());\n }\n }\n\n // Extract font sizes (e.g., 16px, 1.5rem)\n const fontSizeMatches = content.matchAll(/\\b(\\d+(?:\\.\\d+)?(?:px|rem|em))\\b/g);\n for (const match of fontSizeMatches) {\n if (!result.fontSizes.includes(match[1])) {\n result.fontSizes.push(match[1]);\n }\n }\n\n // Extract font families (quoted strings in font context)\n const fontFamilyMatches = content.matchAll(\n /font-family:\\s*[\"']?([^\"',\\n]+)/gi\n );\n for (const match of fontFamilyMatches) {\n const family = match[1].trim();\n if (!result.fontFamilies.includes(family)) {\n result.fontFamilies.push(family);\n }\n }\n\n return result;\n}\n","/**\n * Generate Markdown style guides from extracted styles\n */\n\nimport type { ExtractedStyles, StyleGuide } from \"../types.js\";\n\n/**\n * Generates a Markdown style guide from extracted styles\n */\nexport function generateStyleGuideFromStyles(styles: ExtractedStyles): string {\n const lines: string[] = [];\n\n lines.push(\"# UI Style Guide\");\n lines.push(\"\");\n lines.push(\n \"> Auto-generated by UILint. Edit this file to define your design system.\"\n );\n lines.push(\"\");\n\n // Colors section\n lines.push(\"## Colors\");\n lines.push(\"\");\n const sortedColors = [...styles.colors.entries()]\n .sort((a, b) => b[1] - a[1])\n .slice(0, 10);\n\n if (sortedColors.length > 0) {\n const colorNames = [\n \"Primary\",\n \"Secondary\",\n \"Accent\",\n \"Background\",\n \"Text\",\n \"Muted\",\n \"Border\",\n \"Success\",\n \"Warning\",\n \"Error\",\n ];\n sortedColors.forEach(([color, count], index) => {\n const name = colorNames[index] || `Color ${index + 1}`;\n lines.push(`- **${name}**: ${color} (${count} occurrences)`);\n });\n } else {\n lines.push(\"- No colors detected\");\n }\n lines.push(\"\");\n\n // Typography section\n lines.push(\"## Typography\");\n lines.push(\"\");\n\n // Font families\n const sortedFontFamilies = [...styles.fontFamilies.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n\n if (sortedFontFamilies.length > 0) {\n lines.push(`- **Font Family**: ${sortedFontFamilies[0][0]}`);\n }\n\n // Font sizes\n const sortedFontSizes = [...styles.fontSizes.entries()].sort(\n (a, b) => parseFloat(a[0]) - parseFloat(b[0])\n );\n\n if (sortedFontSizes.length > 0) {\n const sizes = sortedFontSizes.map(([size]) => size).join(\", \");\n lines.push(`- **Font Sizes**: ${sizes}`);\n }\n\n // Font weights\n const sortedFontWeights = [...styles.fontWeights.entries()].sort(\n (a, b) => parseInt(a[0]) - parseInt(b[0])\n );\n\n if (sortedFontWeights.length > 0) {\n const weights = sortedFontWeights.map(([weight]) => weight).join(\", \");\n lines.push(`- **Font Weights**: ${weights}`);\n }\n lines.push(\"\");\n\n // Spacing section\n lines.push(\"## Spacing\");\n lines.push(\"\");\n\n const sortedSpacing = [...styles.spacing.entries()]\n .filter(([value]) => value.endsWith(\"px\"))\n .sort((a, b) => parseFloat(a[0]) - parseFloat(b[0]));\n\n if (sortedSpacing.length > 0) {\n // Try to detect base unit\n const spacingValues = sortedSpacing.map(([value]) => parseFloat(value));\n const gcd = findGCD(spacingValues.filter((v) => v > 0));\n\n if (gcd >= 4) {\n lines.push(`- **Base unit**: ${gcd}px`);\n }\n\n const uniqueSpacing = [...new Set(sortedSpacing.map(([v]) => v))].slice(\n 0,\n 8\n );\n lines.push(`- **Common values**: ${uniqueSpacing.join(\", \")}`);\n } else {\n lines.push(\"- No spacing values detected\");\n }\n lines.push(\"\");\n\n // Border radius section\n lines.push(\"## Border Radius\");\n lines.push(\"\");\n\n const sortedBorderRadius = [...styles.borderRadius.entries()]\n .filter(([value]) => value !== \"0px\")\n .sort((a, b) => b[1] - a[1]);\n\n if (sortedBorderRadius.length > 0) {\n sortedBorderRadius.slice(0, 5).forEach(([value, count]) => {\n lines.push(`- ${value} (${count} occurrences)`);\n });\n } else {\n lines.push(\"- No border radius values detected\");\n }\n lines.push(\"\");\n\n // Components section (placeholder)\n lines.push(\"## Components\");\n lines.push(\"\");\n lines.push(\"- **Buttons**: Define button styles here\");\n lines.push(\"- **Cards**: Define card styles here\");\n lines.push(\"- **Inputs**: Define input styles here\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Finds the greatest common divisor of an array of numbers\n */\nfunction findGCD(numbers: number[]): number {\n if (numbers.length === 0) return 0;\n if (numbers.length === 1) return numbers[0];\n\n const gcd = (a: number, b: number): number => {\n a = Math.abs(Math.round(a));\n b = Math.abs(Math.round(b));\n while (b) {\n const t = b;\n b = a % b;\n a = t;\n }\n return a;\n };\n\n return numbers.reduce((acc, n) => gcd(acc, n));\n}\n\n/**\n * Converts a StyleGuide object back to Markdown\n */\nexport function styleGuideToMarkdown(guide: StyleGuide): string {\n const lines: string[] = [];\n\n lines.push(\"# UI Style Guide\");\n lines.push(\"\");\n\n // Colors\n lines.push(\"## Colors\");\n guide.colors.forEach((color) => {\n const usage = color.usage ? ` (${color.usage})` : \"\";\n lines.push(`- **${color.name}**: ${color.value}${usage}`);\n });\n lines.push(\"\");\n\n // Typography\n lines.push(\"## Typography\");\n guide.typography.forEach((typo) => {\n const props: string[] = [];\n if (typo.fontFamily) props.push(`font-family: \"${typo.fontFamily}\"`);\n if (typo.fontSize) props.push(`font-size: ${typo.fontSize}`);\n if (typo.fontWeight) props.push(`font-weight: ${typo.fontWeight}`);\n if (typo.lineHeight) props.push(`line-height: ${typo.lineHeight}`);\n lines.push(`- **${typo.element}**: ${props.join(\", \")}`);\n });\n lines.push(\"\");\n\n // Spacing\n lines.push(\"## Spacing\");\n guide.spacing.forEach((space) => {\n lines.push(`- **${space.name}**: ${space.value}`);\n });\n lines.push(\"\");\n\n // Components\n lines.push(\"## Components\");\n guide.components.forEach((comp) => {\n lines.push(`- **${comp.name}**: ${comp.styles.join(\", \")}`);\n });\n\n return lines.join(\"\\n\");\n}\n","/**\n * Code validation against style guide\n */\n\nimport type {\n ValidationResult,\n ValidationIssue,\n LintResult,\n LintIssue,\n} from \"../types.js\";\nimport { extractStyleValues } from \"../styleguide/parser.js\";\n\n/**\n * Validates code against the style guide\n */\nexport function validateCode(\n code: string,\n styleGuide: string | null\n): ValidationResult {\n const issues: ValidationIssue[] = [];\n\n if (!styleGuide) {\n return {\n valid: true,\n issues: [\n {\n type: \"warning\",\n message:\n \"No style guide found. Create .uilint/styleguide.md to enable validation.\",\n },\n ],\n };\n }\n\n const styleValues = extractStyleValues(styleGuide);\n\n // Check for color violations\n const codeColors = extractColorsFromCode(code);\n for (const color of codeColors) {\n if (!styleValues.colors.includes(color.toUpperCase())) {\n // Check if it's similar to an allowed color\n const similar = findSimilarColor(color, styleValues.colors);\n issues.push({\n type: \"warning\",\n message: `Color ${color} is not in the style guide`,\n suggestion: similar\n ? `Consider using ${similar} instead`\n : `Add ${color} to the style guide if intentional`,\n });\n }\n }\n\n // Check for hardcoded pixel values (potential spacing violations)\n const hardcodedPixels = code.matchAll(\n /(?:margin|padding|gap)[-:].*?(\\d+)px/gi\n );\n for (const match of hardcodedPixels) {\n const value = parseInt(match[1]);\n // Check if it follows a 4px grid\n if (value % 4 !== 0) {\n issues.push({\n type: \"warning\",\n message: `Spacing value ${value}px doesn't follow the 4px grid`,\n suggestion: `Use ${Math.round(value / 4) * 4}px instead`,\n });\n }\n }\n\n // Check for inline styles (often a code smell)\n if (code.includes(\"style={{\") || code.includes(\"style={\")) {\n const inlineStyleCount = (code.match(/style=\\{/g) || []).length;\n if (inlineStyleCount > 2) {\n issues.push({\n type: \"warning\",\n message: `Found ${inlineStyleCount} inline styles. Consider using CSS classes for consistency.`,\n });\n }\n }\n\n return {\n valid: issues.filter((i) => i.type === \"error\").length === 0,\n issues,\n };\n}\n\n/**\n * Lints a code snippet against the style guide\n */\nexport function lintSnippet(\n code: string,\n styleGuide: string | null\n): LintResult {\n const issues: LintIssue[] = [];\n\n // Basic linting even without style guide\n issues.push(...lintBasicPatterns(code));\n\n // Style guide-based linting\n if (styleGuide) {\n issues.push(...lintAgainstStyleGuide(code, styleGuide));\n }\n\n const errorCount = issues.filter((i) => i.severity === \"error\").length;\n const warningCount = issues.filter((i) => i.severity === \"warning\").length;\n\n return {\n issues,\n summary:\n issues.length === 0\n ? \"No issues found\"\n : `Found ${errorCount} errors and ${warningCount} warnings`,\n };\n}\n\nfunction lintBasicPatterns(code: string): LintIssue[] {\n const issues: LintIssue[] = [];\n\n // Check for magic numbers in styling\n const magicNumbers = code.matchAll(\n /(?:width|height|size):\\s*(\\d+)(?!px|rem|em|%)/g\n );\n for (const match of magicNumbers) {\n issues.push({\n severity: \"warning\",\n type: \"spacing\",\n message: `Magic number ${match[1]} found without unit`,\n code: match[0],\n suggestion: `Add a unit like ${match[1]}px or use a design token`,\n });\n }\n\n // Check for hardcoded colors in className strings\n const hardcodedTailwindColors = code.matchAll(\n /className=[\"'][^\"']*(?:bg|text|border)-\\[#[A-Fa-f0-9]+\\][^\"']*/g\n );\n for (const match of hardcodedTailwindColors) {\n issues.push({\n severity: \"warning\",\n type: \"color\",\n message: \"Hardcoded color in Tailwind arbitrary value\",\n code: match[0],\n suggestion: \"Use a color from your Tailwind config or style guide\",\n });\n }\n\n // Check for accessibility issues\n if (code.includes(\"<img\") && !code.includes(\"alt=\")) {\n issues.push({\n severity: \"error\",\n type: \"accessibility\",\n message: \"Image without alt attribute\",\n suggestion: 'Add alt=\"\" for decorative images or descriptive alt text',\n });\n }\n\n if (\n code.includes(\"<button\") &&\n !code.match(/<button[^>]*>.*\\S.*<\\/button>/s)\n ) {\n issues.push({\n severity: \"warning\",\n type: \"accessibility\",\n message: \"Button may be missing accessible text\",\n suggestion: \"Ensure button has visible text or aria-label\",\n });\n }\n\n // Check for inconsistent quote styles\n const singleQuotes = (code.match(/className='/g) || []).length;\n const doubleQuotes = (code.match(/className=\"/g) || []).length;\n if (singleQuotes > 0 && doubleQuotes > 0) {\n issues.push({\n severity: \"info\",\n type: \"component\",\n message: \"Mixed quote styles in className attributes\",\n suggestion: \"Use consistent quote style throughout\",\n });\n }\n\n return issues;\n}\n\nfunction lintAgainstStyleGuide(code: string, styleGuide: string): LintIssue[] {\n const issues: LintIssue[] = [];\n const values = extractStyleValues(styleGuide);\n\n // Check colors\n const codeColors = code.matchAll(/#[A-Fa-f0-9]{6}\\b/g);\n for (const match of codeColors) {\n const color = match[0].toUpperCase();\n if (!values.colors.includes(color)) {\n issues.push({\n severity: \"warning\",\n type: \"color\",\n message: `Color ${color} not in style guide`,\n code: match[0],\n suggestion: `Allowed colors: ${values.colors.slice(0, 5).join(\", \")}${\n values.colors.length > 5 ? \"...\" : \"\"\n }`,\n });\n }\n }\n\n // Check for non-standard spacing (not on 4px grid)\n const spacingValues = code.matchAll(/(?:p|m|gap)-(\\d+)/g);\n for (const match of spacingValues) {\n const value = parseInt(match[1]);\n // Tailwind uses 4px base (1 = 4px, 2 = 8px, etc.)\n // Non-standard would be values like 5, 7, 9, etc. in the 1-12 range\n if (value > 12 && value % 4 !== 0) {\n issues.push({\n severity: \"info\",\n type: \"spacing\",\n message: `Spacing value ${match[0]} might not align with design system`,\n suggestion:\n \"Consider using standard Tailwind spacing values (1-12, 16, 20, 24...)\",\n });\n }\n }\n\n return issues;\n}\n\nfunction extractColorsFromCode(code: string): string[] {\n const colors: string[] = [];\n\n // Match hex colors\n const hexMatches = code.matchAll(/#[A-Fa-f0-9]{6}\\b/g);\n for (const match of hexMatches) {\n colors.push(match[0].toUpperCase());\n }\n\n // Match Tailwind color classes\n const tailwindMatches = code.matchAll(/(?:bg|text|border)-(\\w+)-(\\d+)/g);\n for (const match of tailwindMatches) {\n // Convert Tailwind colors to a normalized form\n colors.push(`tailwind:${match[1]}-${match[2]}`);\n }\n\n return [...new Set(colors)];\n}\n\nfunction findSimilarColor(\n color: string,\n allowedColors: string[]\n): string | null {\n // Simple hex color distance check\n const colorRgb = hexToRgb(color);\n if (!colorRgb) return null;\n\n let closest: string | null = null;\n let closestDistance = Infinity;\n\n for (const allowed of allowedColors) {\n const allowedRgb = hexToRgb(allowed);\n if (!allowedRgb) continue;\n\n const distance = Math.sqrt(\n Math.pow(colorRgb.r - allowedRgb.r, 2) +\n Math.pow(colorRgb.g - allowedRgb.g, 2) +\n Math.pow(colorRgb.b - allowedRgb.b, 2)\n );\n\n if (distance < closestDistance && distance < 50) {\n closestDistance = distance;\n closest = allowed;\n }\n }\n\n return closest;\n}\n\nfunction hexToRgb(hex: string): { r: number; g: number; b: number } | null {\n const match = hex.match(/^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i);\n if (!match) return null;\n\n return {\n r: parseInt(match[1], 16),\n g: parseInt(match[2], 16),\n b: parseInt(match[3], 16),\n };\n}\n"],"mappings":";AAOO,SAAS,oBACd,cACA,YACQ;AACR,QAAM,eAAe,aACjB;AAAA,EAA2B,UAAU;AAAA;AAAA,IACrC;AAEJ,SAAO;AAAA;AAAA,EAEP,YAAY;AAAA;AAAA,EAEZ,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+Bd;AAKO,SAAS,sBAAsB,cAA8B;AAClE,SAAO;AAAA;AAAA,EAEP,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+Bd;AAKO,SAAS,iBACd,OACA,YACQ;AACR,MAAI,CAAC,YAAY;AACf,WAAO,wBAAwB,KAAK;AAAA;AAAA;AAAA,EAGtC;AAEA,SAAO;AAAA;AAAA;AAAA,EAGP,UAAU;AAAA;AAAA;AAAA,EAGV,KAAK;AAAA;AAAA;AAGP;AAKO,SAAS,sBACd,MACA,YACQ;AACR,QAAM,eAAe,aAC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
3
3
|
*/
|
|
4
4
|
interface UILintIssue {
|
|
5
5
|
id: string;
|
|
6
|
-
type:
|
|
6
|
+
type: "color" | "typography" | "spacing" | "component" | "responsive" | "accessibility";
|
|
7
7
|
message: string;
|
|
8
8
|
element?: string;
|
|
9
9
|
selector?: string;
|
|
@@ -69,7 +69,7 @@ interface ValidationResult {
|
|
|
69
69
|
issues: ValidationIssue[];
|
|
70
70
|
}
|
|
71
71
|
interface ValidationIssue {
|
|
72
|
-
type:
|
|
72
|
+
type: "error" | "warning";
|
|
73
73
|
message: string;
|
|
74
74
|
line?: number;
|
|
75
75
|
suggestion?: string;
|
|
@@ -79,8 +79,8 @@ interface LintResult {
|
|
|
79
79
|
summary: string;
|
|
80
80
|
}
|
|
81
81
|
interface LintIssue {
|
|
82
|
-
severity:
|
|
83
|
-
type:
|
|
82
|
+
severity: "error" | "warning" | "info";
|
|
83
|
+
type: "color" | "spacing" | "typography" | "component" | "accessibility";
|
|
84
84
|
message: string;
|
|
85
85
|
line?: number;
|
|
86
86
|
code?: string;
|
package/dist/index.js
CHANGED
package/dist/node.js
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ollama/prompts.ts","../src/ollama/client.ts","../src/scanner/style-extractor.ts","../src/styleguide/schema.ts","../src/styleguide/parser.ts","../src/styleguide/generator.ts","../src/validation/validate.ts"],"sourcesContent":["/**\n * LLM prompt builders for UILint analysis\n */\n\n/**\n * Builds a prompt for style analysis\n */\nexport function buildAnalysisPrompt(\n styleSummary: string,\n styleGuide: string | null\n): string {\n const guideSection = styleGuide\n ? `## Current Style Guide\\n${styleGuide}\\n\\n`\n : \"## No Style Guide Found\\nAnalyze the styles and identify inconsistencies.\\n\\n\";\n\n return `You are a UI consistency analyzer. Analyze the following extracted styles and identify inconsistencies.\n\n${guideSection}\n\n${styleSummary}\n\nRespond with a JSON object containing an \"issues\" array. Each issue should have:\n- id: unique string identifier\n- type: one of \"color\", \"typography\", \"spacing\", \"component\", \"responsive\", \"accessibility\"\n- message: human-readable description of the issue\n- currentValue: the problematic value found\n- expectedValue: what it should be (if known from style guide)\n- suggestion: how to fix it\n\nFocus on:\n1. Similar but not identical colors (e.g., #3B82F6 vs #3575E2)\n2. Inconsistent font sizes or weights\n3. Spacing values that don't follow a consistent scale (e.g., 4px base unit)\n4. Mixed border-radius values\n\nBe concise and actionable. Only report significant inconsistencies.\n\nExample response:\n{\n \"issues\": [\n {\n \"id\": \"color-1\",\n \"type\": \"color\",\n \"message\": \"Found similar blue colors that should be consolidated\",\n \"currentValue\": \"#3575E2\",\n \"expectedValue\": \"#3B82F6\",\n \"suggestion\": \"Use the primary blue #3B82F6 consistently\"\n }\n ]\n}`;\n}\n\n/**\n * Builds a prompt for style guide generation\n */\nexport function buildStyleGuidePrompt(styleSummary: string): string {\n return `You are a design system expert. Based on the following detected styles, generate a clean, organized style guide in Markdown format.\n\n${styleSummary}\n\nGenerate a style guide with these sections:\n1. Colors - List the main colors with semantic names (Primary, Secondary, etc.)\n2. Typography - Font families, sizes, and weights\n3. Spacing - Base unit and common spacing values\n4. Components - Common component patterns\n\nUse this format:\n# UI Style Guide\n\n## Colors\n- **Primary**: #HEXCODE (usage description)\n- **Secondary**: #HEXCODE (usage description)\n...\n\n## Typography\n- **Font Family**: FontName\n- **Font Sizes**: list of sizes\n- **Font Weights**: list of weights\n\n## Spacing\n- **Base unit**: Xpx\n- **Common values**: list of values\n\n## Components\n- **Buttons**: styles\n- **Cards**: styles\n...\n\nBe concise and focus on the most used values.`;\n}\n\n/**\n * Builds a prompt for querying the style guide\n */\nexport function buildQueryPrompt(query: string, styleGuide: string | null): string {\n if (!styleGuide) {\n return `The user is asking: \"${query}\"\n\nNo style guide has been created yet. Explain that they should run \"uilint init\" to create a style guide from their existing styles.`;\n }\n\n return `You are a helpful assistant that answers questions about a UI style guide.\n\n## Style Guide\n${styleGuide}\n\n## User Question\n${query}\n\nProvide a clear, concise answer based on the style guide above. If the style guide doesn't contain the information needed, say so and suggest what might be missing.`;\n}\n\n/**\n * Builds a prompt for code validation\n */\nexport function buildValidationPrompt(code: string, styleGuide: string | null): string {\n const guideSection = styleGuide\n ? `## Style Guide\\n${styleGuide}\\n\\n`\n : \"## No Style Guide\\nValidate for general best practices.\\n\\n\";\n\n return `You are a UI code validator. Check the following code against the style guide and best practices.\n\n${guideSection}\n\n## Code to Validate\n\\`\\`\\`tsx\n${code}\n\\`\\`\\`\n\nRespond with a JSON object containing:\n- valid: boolean (true if no errors found)\n- issues: array of issues, each with:\n - type: \"error\" or \"warning\"\n - message: description of the issue\n - suggestion: how to fix it\n\nFocus on:\n1. Colors not in the style guide\n2. Spacing values not following the design system\n3. Typography inconsistencies\n4. Accessibility issues (missing alt text, etc.)\n\nExample response:\n{\n \"valid\": false,\n \"issues\": [\n {\n \"type\": \"warning\",\n \"message\": \"Color #FF0000 is not in the style guide\",\n \"suggestion\": \"Use the error color #EF4444 instead\"\n }\n ]\n}`;\n}\n\n","/**\n * Ollama API client for LLM interactions\n */\n\nimport type {\n UILintIssue,\n AnalysisResult,\n ValidationResult,\n OllamaClientOptions,\n} from \"../types.js\";\nimport {\n buildAnalysisPrompt,\n buildStyleGuidePrompt,\n buildQueryPrompt,\n buildValidationPrompt,\n} from \"./prompts.js\";\n\nconst DEFAULT_BASE_URL = \"http://localhost:11434\";\nconst DEFAULT_MODEL = \"qwen2.5-coder:7b\";\nconst DEFAULT_TIMEOUT = 60000;\n\nexport class OllamaClient {\n private baseUrl: string;\n private model: string;\n private timeout: number;\n\n constructor(options: OllamaClientOptions = {}) {\n this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;\n this.model = options.model || DEFAULT_MODEL;\n this.timeout = options.timeout || DEFAULT_TIMEOUT;\n }\n\n /**\n * Analyzes styles and returns issues\n */\n async analyzeStyles(\n styleSummary: string,\n styleGuide: string | null\n ): Promise<AnalysisResult> {\n const startTime = Date.now();\n const prompt = buildAnalysisPrompt(styleSummary, styleGuide);\n\n try {\n const response = await this.generate(prompt);\n const issues = this.parseIssuesResponse(response);\n\n return {\n issues,\n analysisTime: Date.now() - startTime,\n };\n } catch (error) {\n console.error(\"[UILint] Analysis failed:\", error);\n return {\n issues: [],\n analysisTime: Date.now() - startTime,\n };\n }\n }\n\n /**\n * Generates a style guide from detected styles\n */\n async generateStyleGuide(styleSummary: string): Promise<string | null> {\n const prompt = buildStyleGuidePrompt(styleSummary);\n\n try {\n const response = await this.generate(prompt, false);\n return response;\n } catch (error) {\n console.error(\"[UILint] Style guide generation failed:\", error);\n return null;\n }\n }\n\n /**\n * Queries the style guide for specific information\n */\n async queryStyleGuide(query: string, styleGuide: string | null): Promise<string> {\n const prompt = buildQueryPrompt(query, styleGuide);\n\n try {\n const response = await this.generate(prompt, false);\n return response;\n } catch (error) {\n console.error(\"[UILint] Query failed:\", error);\n return \"Failed to query style guide. Please try again.\";\n }\n }\n\n /**\n * Validates code against the style guide\n */\n async validateCode(\n code: string,\n styleGuide: string | null\n ): Promise<ValidationResult> {\n const prompt = buildValidationPrompt(code, styleGuide);\n\n try {\n const response = await this.generate(prompt);\n return this.parseValidationResponse(response);\n } catch (error) {\n console.error(\"[UILint] Validation failed:\", error);\n return { valid: true, issues: [] };\n }\n }\n\n /**\n * Core generate method that calls Ollama API\n */\n private async generate(prompt: string, jsonFormat: boolean = true): Promise<string> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const response = await fetch(`${this.baseUrl}/api/generate`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n model: this.model,\n prompt,\n stream: false,\n ...(jsonFormat && { format: \"json\" }),\n }),\n signal: controller.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Ollama API error: ${response.status}`);\n }\n\n const data = await response.json();\n return data.response || \"\";\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Parses issues from LLM response\n */\n private parseIssuesResponse(response: string): UILintIssue[] {\n try {\n const parsed = JSON.parse(response);\n return parsed.issues || [];\n } catch {\n console.warn(\"[UILint] Failed to parse LLM response as JSON\");\n return [];\n }\n }\n\n /**\n * Parses validation result from LLM response\n */\n private parseValidationResponse(response: string): ValidationResult {\n try {\n const parsed = JSON.parse(response);\n return {\n valid: parsed.valid ?? true,\n issues: parsed.issues || [],\n };\n } catch {\n console.warn(\"[UILint] Failed to parse validation response\");\n return { valid: true, issues: [] };\n }\n }\n\n /**\n * Checks if Ollama is available\n */\n async isAvailable(): Promise<boolean> {\n try {\n const response = await fetch(`${this.baseUrl}/api/tags`, {\n method: \"GET\",\n signal: AbortSignal.timeout(5000),\n });\n return response.ok;\n } catch {\n return false;\n }\n }\n\n /**\n * Gets the current model\n */\n getModel(): string {\n return this.model;\n }\n\n /**\n * Sets the model\n */\n setModel(model: string): void {\n this.model = model;\n }\n}\n\n// Default singleton instance\nlet defaultClient: OllamaClient | null = null;\n\nexport function getOllamaClient(options?: OllamaClientOptions): OllamaClient {\n if (!defaultClient || options) {\n defaultClient = new OllamaClient(options);\n }\n return defaultClient;\n}\n\n","/**\n * Style extraction from DOM elements\n */\n\nimport type { ExtractedStyles, SerializedStyles } from \"../types.js\";\n\n/**\n * Extracts all computed styles from elements in the document\n * Works in both browser and JSDOM environments\n */\nexport function extractStyles(\n root: Element | Document,\n getComputedStyle: (el: Element) => CSSStyleDeclaration\n): ExtractedStyles {\n const styles: ExtractedStyles = {\n colors: new Map(),\n fontSizes: new Map(),\n fontFamilies: new Map(),\n fontWeights: new Map(),\n spacing: new Map(),\n borderRadius: new Map(),\n };\n\n const elements = root.querySelectorAll(\"*\");\n\n elements.forEach((element) => {\n // nodeType === 1 means Element node (works in both browser and JSDOM)\n if (element.nodeType !== 1) return;\n\n const computed = getComputedStyle(element);\n\n // Extract colors\n extractColor(computed.color, styles.colors);\n extractColor(computed.backgroundColor, styles.colors);\n extractColor(computed.borderColor, styles.colors);\n\n // Extract typography\n incrementMap(styles.fontSizes, computed.fontSize);\n incrementMap(styles.fontFamilies, normalizeFontFamily(computed.fontFamily));\n incrementMap(styles.fontWeights, computed.fontWeight);\n\n // Extract spacing\n extractSpacing(computed.margin, styles.spacing);\n extractSpacing(computed.padding, styles.spacing);\n incrementMap(styles.spacing, computed.gap);\n\n // Extract border radius\n incrementMap(styles.borderRadius, computed.borderRadius);\n });\n\n return styles;\n}\n\n/**\n * Extracts styles from browser DOM (uses window.getComputedStyle)\n */\nexport function extractStylesFromDOM(root?: Element | Document): ExtractedStyles {\n const targetRoot = root || document.body;\n return extractStyles(targetRoot, (el) => window.getComputedStyle(el));\n}\n\nfunction extractColor(color: string, map: Map<string, number>): void {\n if (!color || color === \"transparent\" || color === \"rgba(0, 0, 0, 0)\") return;\n\n // Normalize to hex\n const hex = rgbToHex(color);\n if (hex) {\n incrementMap(map, hex);\n }\n}\n\nfunction extractSpacing(value: string, map: Map<string, number>): void {\n if (!value || value === \"0px\") return;\n\n // Split compound values (e.g., \"10px 20px 10px 20px\")\n const values = value.split(\" \").filter((v) => v && v !== \"0px\");\n values.forEach((v) => incrementMap(map, v));\n}\n\nfunction incrementMap(map: Map<string, number>, value: string): void {\n if (!value || value === \"normal\" || value === \"auto\") return;\n map.set(value, (map.get(value) || 0) + 1);\n}\n\nfunction normalizeFontFamily(fontFamily: string): string {\n // Get the primary font (first in the stack)\n const primary = fontFamily.split(\",\")[0].trim();\n return primary.replace(/['\"]/g, \"\");\n}\n\nfunction rgbToHex(rgb: string): string | null {\n // Handle hex values\n if (rgb.startsWith(\"#\")) return rgb.toUpperCase();\n\n // Handle rgb/rgba values\n const match = rgb.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/);\n if (!match) return null;\n\n const [, r, g, b] = match;\n const toHex = (n: string) => parseInt(n).toString(16).padStart(2, \"0\");\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase();\n}\n\n/**\n * Converts ExtractedStyles maps to plain objects for serialization\n */\nexport function serializeStyles(styles: ExtractedStyles): SerializedStyles {\n return {\n colors: Object.fromEntries(styles.colors),\n fontSizes: Object.fromEntries(styles.fontSizes),\n fontFamilies: Object.fromEntries(styles.fontFamilies),\n fontWeights: Object.fromEntries(styles.fontWeights),\n spacing: Object.fromEntries(styles.spacing),\n borderRadius: Object.fromEntries(styles.borderRadius),\n };\n}\n\n/**\n * Converts SerializedStyles back to ExtractedStyles\n */\nexport function deserializeStyles(serialized: SerializedStyles): ExtractedStyles {\n return {\n colors: new Map(Object.entries(serialized.colors)),\n fontSizes: new Map(Object.entries(serialized.fontSizes)),\n fontFamilies: new Map(Object.entries(serialized.fontFamilies)),\n fontWeights: new Map(Object.entries(serialized.fontWeights)),\n spacing: new Map(Object.entries(serialized.spacing)),\n borderRadius: new Map(Object.entries(serialized.borderRadius)),\n };\n}\n\n/**\n * Creates a summary of extracted styles for LLM analysis\n */\nexport function createStyleSummary(styles: ExtractedStyles): string {\n const lines: string[] = [];\n\n lines.push(\"## Detected Styles Summary\\n\");\n\n // Colors\n lines.push(\"### Colors\");\n const sortedColors = [...styles.colors.entries()].sort((a, b) => b[1] - a[1]);\n sortedColors.slice(0, 20).forEach(([color, count]) => {\n lines.push(`- ${color}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Font sizes\n lines.push(\"### Font Sizes\");\n const sortedFontSizes = [...styles.fontSizes.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n sortedFontSizes.forEach(([size, count]) => {\n lines.push(`- ${size}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Font families\n lines.push(\"### Font Families\");\n const sortedFontFamilies = [...styles.fontFamilies.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n sortedFontFamilies.forEach(([family, count]) => {\n lines.push(`- ${family}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Font weights\n lines.push(\"### Font Weights\");\n const sortedFontWeights = [...styles.fontWeights.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n sortedFontWeights.forEach(([weight, count]) => {\n lines.push(`- ${weight}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Spacing\n lines.push(\"### Spacing Values\");\n const sortedSpacing = [...styles.spacing.entries()].sort((a, b) => b[1] - a[1]);\n sortedSpacing.slice(0, 15).forEach(([value, count]) => {\n lines.push(`- ${value}: ${count} occurrences`);\n });\n lines.push(\"\");\n\n // Border radius\n lines.push(\"### Border Radius\");\n const sortedBorderRadius = [...styles.borderRadius.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n sortedBorderRadius.forEach(([value, count]) => {\n lines.push(`- ${value}: ${count} occurrences`);\n });\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Truncates HTML to a maximum length\n */\nexport function truncateHTML(html: string, maxLength: number = 50000): string {\n if (html.length <= maxLength) return html;\n return html.slice(0, maxLength) + \"<!-- truncated -->\";\n}\n\n","/**\n * Style guide schema and utilities\n */\n\nimport type { StyleGuide, ColorRule, TypographyRule, SpacingRule, ComponentRule } from \"../types.js\";\n\n/**\n * Creates an empty style guide structure\n */\nexport function createEmptyStyleGuide(): StyleGuide {\n return {\n colors: [],\n typography: [],\n spacing: [],\n components: [],\n };\n}\n\n/**\n * Validates a style guide object\n */\nexport function validateStyleGuide(guide: unknown): guide is StyleGuide {\n if (!guide || typeof guide !== \"object\") return false;\n\n const g = guide as Record<string, unknown>;\n\n return (\n Array.isArray(g.colors) &&\n Array.isArray(g.typography) &&\n Array.isArray(g.spacing) &&\n Array.isArray(g.components)\n );\n}\n\n/**\n * Merges detected styles into an existing style guide\n */\nexport function mergeStyleGuides(\n existing: StyleGuide,\n detected: Partial<StyleGuide>\n): StyleGuide {\n return {\n colors: mergeColorRules(existing.colors, detected.colors || []),\n typography: mergeTypographyRules(existing.typography, detected.typography || []),\n spacing: mergeSpacingRules(existing.spacing, detected.spacing || []),\n components: mergeComponentRules(existing.components, detected.components || []),\n };\n}\n\nfunction mergeColorRules(existing: ColorRule[], detected: ColorRule[]): ColorRule[] {\n const merged = [...existing];\n detected.forEach((rule) => {\n const existingIndex = merged.findIndex(\n (e) => e.name === rule.name || e.value === rule.value\n );\n if (existingIndex === -1) {\n merged.push(rule);\n }\n });\n return merged;\n}\n\nfunction mergeTypographyRules(existing: TypographyRule[], detected: TypographyRule[]): TypographyRule[] {\n const merged = [...existing];\n detected.forEach((rule) => {\n const existingIndex = merged.findIndex((e) => e.element === rule.element);\n if (existingIndex === -1) {\n merged.push(rule);\n }\n });\n return merged;\n}\n\nfunction mergeSpacingRules(existing: SpacingRule[], detected: SpacingRule[]): SpacingRule[] {\n const merged = [...existing];\n detected.forEach((rule) => {\n const existingIndex = merged.findIndex(\n (e) => e.name === rule.name || e.value === rule.value\n );\n if (existingIndex === -1) {\n merged.push(rule);\n }\n });\n return merged;\n}\n\nfunction mergeComponentRules(existing: ComponentRule[], detected: ComponentRule[]): ComponentRule[] {\n const merged = [...existing];\n detected.forEach((rule) => {\n const existingIndex = merged.findIndex((e) => e.name === rule.name);\n if (existingIndex === -1) {\n merged.push(rule);\n }\n });\n return merged;\n}\n\n/**\n * Creates a color rule\n */\nexport function createColorRule(\n name: string,\n value: string,\n usage: string = \"\"\n): ColorRule {\n return { name, value: value.toUpperCase(), usage };\n}\n\n/**\n * Creates a typography rule\n */\nexport function createTypographyRule(\n element: string,\n options: Partial<Omit<TypographyRule, \"element\">> = {}\n): TypographyRule {\n return { element, ...options };\n}\n\n/**\n * Creates a spacing rule\n */\nexport function createSpacingRule(name: string, value: string): SpacingRule {\n return { name, value };\n}\n\n/**\n * Creates a component rule\n */\nexport function createComponentRule(name: string, styles: string[]): ComponentRule {\n return { name, styles };\n}\n\n","/**\n * Parse Markdown style guides into structured data\n */\n\nimport type {\n StyleGuide,\n ColorRule,\n TypographyRule,\n SpacingRule,\n ComponentRule,\n ExtractedStyleValues,\n} from \"../types.js\";\nimport { createEmptyStyleGuide } from \"./schema.js\";\n\n/**\n * Parses a Markdown style guide into a structured object\n */\nexport function parseStyleGuide(markdown: string): StyleGuide {\n const guide = createEmptyStyleGuide();\n const sections = splitIntoSections(markdown);\n\n sections.forEach(({ title, content }) => {\n const lowerTitle = title.toLowerCase();\n\n if (lowerTitle.includes(\"color\")) {\n guide.colors = parseColorSection(content);\n } else if (lowerTitle.includes(\"typography\") || lowerTitle.includes(\"font\")) {\n guide.typography = parseTypographySection(content);\n } else if (lowerTitle.includes(\"spacing\")) {\n guide.spacing = parseSpacingSection(content);\n } else if (lowerTitle.includes(\"component\")) {\n guide.components = parseComponentSection(content);\n }\n });\n\n return guide;\n}\n\ninterface Section {\n title: string;\n content: string;\n}\n\nfunction splitIntoSections(markdown: string): Section[] {\n const sections: Section[] = [];\n const lines = markdown.split(\"\\n\");\n\n let currentTitle = \"\";\n let currentContent: string[] = [];\n\n lines.forEach((line) => {\n const headerMatch = line.match(/^##\\s+(.+)$/);\n\n if (headerMatch) {\n if (currentTitle) {\n sections.push({\n title: currentTitle,\n content: currentContent.join(\"\\n\"),\n });\n }\n currentTitle = headerMatch[1];\n currentContent = [];\n } else {\n currentContent.push(line);\n }\n });\n\n if (currentTitle) {\n sections.push({\n title: currentTitle,\n content: currentContent.join(\"\\n\"),\n });\n }\n\n return sections;\n}\n\nfunction parseColorSection(content: string): ColorRule[] {\n const colors: ColorRule[] = [];\n const lines = content.split(\"\\n\");\n\n lines.forEach((line) => {\n // Match patterns like: - **Primary**: #3B82F6 (used in buttons)\n const match = line.match(\n /[-*]\\s*\\*?\\*?([^*:]+)\\*?\\*?:\\s*(#[A-Fa-f0-9]{6})\\s*(?:\\(([^)]+)\\))?/\n );\n\n if (match) {\n colors.push({\n name: match[1].trim(),\n value: match[2].toUpperCase(),\n usage: match[3] || \"\",\n });\n }\n });\n\n return colors;\n}\n\nfunction parseTypographySection(content: string): TypographyRule[] {\n const typography: TypographyRule[] = [];\n const lines = content.split(\"\\n\");\n\n lines.forEach((line) => {\n // Match patterns like: - **Headings**: font-family: \"Inter\", font-size: 24px\n const elementMatch = line.match(/[-*]\\s*\\*?\\*?([^*:]+)\\*?\\*?:\\s*(.+)/);\n\n if (elementMatch) {\n const rule: TypographyRule = {\n element: elementMatch[1].trim(),\n };\n\n const props = elementMatch[2];\n\n const fontFamilyMatch = props.match(/font-family:\\s*\"?([^\",]+)\"?/);\n if (fontFamilyMatch) rule.fontFamily = fontFamilyMatch[1].trim();\n\n const fontSizeMatch = props.match(/font-size:\\s*(\\d+px)/);\n if (fontSizeMatch) rule.fontSize = fontSizeMatch[1];\n\n const fontWeightMatch = props.match(/font-weight:\\s*(\\d+)/);\n if (fontWeightMatch) rule.fontWeight = fontWeightMatch[1];\n\n const lineHeightMatch = props.match(/line-height:\\s*([\\d.]+)/);\n if (lineHeightMatch) rule.lineHeight = lineHeightMatch[1];\n\n typography.push(rule);\n }\n });\n\n return typography;\n}\n\nfunction parseSpacingSection(content: string): SpacingRule[] {\n const spacing: SpacingRule[] = [];\n const lines = content.split(\"\\n\");\n\n lines.forEach((line) => {\n // Match patterns like: - **Base unit**: 4px\n const match = line.match(/[-*]\\s*\\*?\\*?([^*:]+)\\*?\\*?:\\s*(.+)/);\n\n if (match) {\n spacing.push({\n name: match[1].trim(),\n value: match[2].trim(),\n });\n }\n });\n\n return spacing;\n}\n\nfunction parseComponentSection(content: string): ComponentRule[] {\n const components: ComponentRule[] = [];\n const lines = content.split(\"\\n\");\n\n lines.forEach((line) => {\n // Match patterns like: - **Buttons**: rounded-lg, px-4 py-2\n const match = line.match(/[-*]\\s*\\*?\\*?([^*:]+)\\*?\\*?:\\s*(.+)/);\n\n if (match) {\n components.push({\n name: match[1].trim(),\n styles: match[2].split(\",\").map((s) => s.trim()),\n });\n }\n });\n\n return components;\n}\n\n/**\n * Parses sections from a Markdown style guide (simpler format)\n */\nexport function parseStyleGuideSections(content: string): Record<string, string> {\n const sections: Record<string, string> = {};\n const lines = content.split(\"\\n\");\n\n let currentSection = \"intro\";\n let currentContent: string[] = [];\n\n for (const line of lines) {\n const headerMatch = line.match(/^##\\s+(.+)$/);\n\n if (headerMatch) {\n if (currentContent.length > 0) {\n sections[currentSection.toLowerCase()] = currentContent.join(\"\\n\").trim();\n }\n\n currentSection = headerMatch[1];\n currentContent = [];\n } else {\n currentContent.push(line);\n }\n }\n\n if (currentContent.length > 0) {\n sections[currentSection.toLowerCase()] = currentContent.join(\"\\n\").trim();\n }\n\n return sections;\n}\n\n/**\n * Extracts specific values from the style guide\n */\nexport function extractStyleValues(content: string): ExtractedStyleValues {\n const result: ExtractedStyleValues = {\n colors: [],\n fontSizes: [],\n fontFamilies: [],\n spacing: [],\n borderRadius: [],\n };\n\n // Extract hex colors\n const colorMatches = content.matchAll(/#[A-Fa-f0-9]{6}\\b/g);\n for (const match of colorMatches) {\n if (!result.colors.includes(match[0].toUpperCase())) {\n result.colors.push(match[0].toUpperCase());\n }\n }\n\n // Extract font sizes (e.g., 16px, 1.5rem)\n const fontSizeMatches = content.matchAll(/\\b(\\d+(?:\\.\\d+)?(?:px|rem|em))\\b/g);\n for (const match of fontSizeMatches) {\n if (!result.fontSizes.includes(match[1])) {\n result.fontSizes.push(match[1]);\n }\n }\n\n // Extract font families (quoted strings in font context)\n const fontFamilyMatches = content.matchAll(/font-family:\\s*[\"']?([^\"',\\n]+)/gi);\n for (const match of fontFamilyMatches) {\n const family = match[1].trim();\n if (!result.fontFamilies.includes(family)) {\n result.fontFamilies.push(family);\n }\n }\n\n return result;\n}\n\n","/**\n * Generate Markdown style guides from extracted styles\n */\n\nimport type { ExtractedStyles, StyleGuide } from \"../types.js\";\n\n/**\n * Generates a Markdown style guide from extracted styles\n */\nexport function generateStyleGuideFromStyles(styles: ExtractedStyles): string {\n const lines: string[] = [];\n\n lines.push(\"# UI Style Guide\");\n lines.push(\"\");\n lines.push(\"> Auto-generated by UILint. Edit this file to define your design system.\");\n lines.push(\"\");\n\n // Colors section\n lines.push(\"## Colors\");\n lines.push(\"\");\n const sortedColors = [...styles.colors.entries()]\n .sort((a, b) => b[1] - a[1])\n .slice(0, 10);\n\n if (sortedColors.length > 0) {\n const colorNames = [\n \"Primary\",\n \"Secondary\",\n \"Accent\",\n \"Background\",\n \"Text\",\n \"Muted\",\n \"Border\",\n \"Success\",\n \"Warning\",\n \"Error\",\n ];\n sortedColors.forEach(([color, count], index) => {\n const name = colorNames[index] || `Color ${index + 1}`;\n lines.push(`- **${name}**: ${color} (${count} occurrences)`);\n });\n } else {\n lines.push(\"- No colors detected\");\n }\n lines.push(\"\");\n\n // Typography section\n lines.push(\"## Typography\");\n lines.push(\"\");\n\n // Font families\n const sortedFontFamilies = [...styles.fontFamilies.entries()].sort(\n (a, b) => b[1] - a[1]\n );\n\n if (sortedFontFamilies.length > 0) {\n lines.push(`- **Font Family**: ${sortedFontFamilies[0][0]}`);\n }\n\n // Font sizes\n const sortedFontSizes = [...styles.fontSizes.entries()].sort(\n (a, b) => parseFloat(a[0]) - parseFloat(b[0])\n );\n\n if (sortedFontSizes.length > 0) {\n const sizes = sortedFontSizes.map(([size]) => size).join(\", \");\n lines.push(`- **Font Sizes**: ${sizes}`);\n }\n\n // Font weights\n const sortedFontWeights = [...styles.fontWeights.entries()].sort(\n (a, b) => parseInt(a[0]) - parseInt(b[0])\n );\n\n if (sortedFontWeights.length > 0) {\n const weights = sortedFontWeights.map(([weight]) => weight).join(\", \");\n lines.push(`- **Font Weights**: ${weights}`);\n }\n lines.push(\"\");\n\n // Spacing section\n lines.push(\"## Spacing\");\n lines.push(\"\");\n\n const sortedSpacing = [...styles.spacing.entries()]\n .filter(([value]) => value.endsWith(\"px\"))\n .sort((a, b) => parseFloat(a[0]) - parseFloat(b[0]));\n\n if (sortedSpacing.length > 0) {\n // Try to detect base unit\n const spacingValues = sortedSpacing.map(([value]) => parseFloat(value));\n const gcd = findGCD(spacingValues.filter((v) => v > 0));\n\n if (gcd >= 4) {\n lines.push(`- **Base unit**: ${gcd}px`);\n }\n\n const uniqueSpacing = [...new Set(sortedSpacing.map(([v]) => v))].slice(0, 8);\n lines.push(`- **Common values**: ${uniqueSpacing.join(\", \")}`);\n } else {\n lines.push(\"- No spacing values detected\");\n }\n lines.push(\"\");\n\n // Border radius section\n lines.push(\"## Border Radius\");\n lines.push(\"\");\n\n const sortedBorderRadius = [...styles.borderRadius.entries()]\n .filter(([value]) => value !== \"0px\")\n .sort((a, b) => b[1] - a[1]);\n\n if (sortedBorderRadius.length > 0) {\n sortedBorderRadius.slice(0, 5).forEach(([value, count]) => {\n lines.push(`- ${value} (${count} occurrences)`);\n });\n } else {\n lines.push(\"- No border radius values detected\");\n }\n lines.push(\"\");\n\n // Components section (placeholder)\n lines.push(\"## Components\");\n lines.push(\"\");\n lines.push(\"- **Buttons**: Define button styles here\");\n lines.push(\"- **Cards**: Define card styles here\");\n lines.push(\"- **Inputs**: Define input styles here\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Finds the greatest common divisor of an array of numbers\n */\nfunction findGCD(numbers: number[]): number {\n if (numbers.length === 0) return 0;\n if (numbers.length === 1) return numbers[0];\n\n const gcd = (a: number, b: number): number => {\n a = Math.abs(Math.round(a));\n b = Math.abs(Math.round(b));\n while (b) {\n const t = b;\n b = a % b;\n a = t;\n }\n return a;\n };\n\n return numbers.reduce((acc, n) => gcd(acc, n));\n}\n\n/**\n * Converts a StyleGuide object back to Markdown\n */\nexport function styleGuideToMarkdown(guide: StyleGuide): string {\n const lines: string[] = [];\n\n lines.push(\"# UI Style Guide\");\n lines.push(\"\");\n\n // Colors\n lines.push(\"## Colors\");\n guide.colors.forEach((color) => {\n const usage = color.usage ? ` (${color.usage})` : \"\";\n lines.push(`- **${color.name}**: ${color.value}${usage}`);\n });\n lines.push(\"\");\n\n // Typography\n lines.push(\"## Typography\");\n guide.typography.forEach((typo) => {\n const props: string[] = [];\n if (typo.fontFamily) props.push(`font-family: \"${typo.fontFamily}\"`);\n if (typo.fontSize) props.push(`font-size: ${typo.fontSize}`);\n if (typo.fontWeight) props.push(`font-weight: ${typo.fontWeight}`);\n if (typo.lineHeight) props.push(`line-height: ${typo.lineHeight}`);\n lines.push(`- **${typo.element}**: ${props.join(\", \")}`);\n });\n lines.push(\"\");\n\n // Spacing\n lines.push(\"## Spacing\");\n guide.spacing.forEach((space) => {\n lines.push(`- **${space.name}**: ${space.value}`);\n });\n lines.push(\"\");\n\n // Components\n lines.push(\"## Components\");\n guide.components.forEach((comp) => {\n lines.push(`- **${comp.name}**: ${comp.styles.join(\", \")}`);\n });\n\n return lines.join(\"\\n\");\n}\n\n","/**\n * Code validation against style guide\n */\n\nimport type { ValidationResult, ValidationIssue, LintResult, LintIssue } from \"../types.js\";\nimport { extractStyleValues } from \"../styleguide/parser.js\";\n\n/**\n * Validates code against the style guide\n */\nexport function validateCode(\n code: string,\n styleGuide: string | null\n): ValidationResult {\n const issues: ValidationIssue[] = [];\n\n if (!styleGuide) {\n return {\n valid: true,\n issues: [\n {\n type: \"warning\",\n message:\n \"No style guide found. Create .uilint/styleguide.md to enable validation.\",\n },\n ],\n };\n }\n\n const styleValues = extractStyleValues(styleGuide);\n\n // Check for color violations\n const codeColors = extractColorsFromCode(code);\n for (const color of codeColors) {\n if (!styleValues.colors.includes(color.toUpperCase())) {\n // Check if it's similar to an allowed color\n const similar = findSimilarColor(color, styleValues.colors);\n issues.push({\n type: \"warning\",\n message: `Color ${color} is not in the style guide`,\n suggestion: similar\n ? `Consider using ${similar} instead`\n : `Add ${color} to the style guide if intentional`,\n });\n }\n }\n\n // Check for hardcoded pixel values (potential spacing violations)\n const hardcodedPixels = code.matchAll(/(?:margin|padding|gap)[-:].*?(\\d+)px/gi);\n for (const match of hardcodedPixels) {\n const value = parseInt(match[1]);\n // Check if it follows a 4px grid\n if (value % 4 !== 0) {\n issues.push({\n type: \"warning\",\n message: `Spacing value ${value}px doesn't follow the 4px grid`,\n suggestion: `Use ${Math.round(value / 4) * 4}px instead`,\n });\n }\n }\n\n // Check for inline styles (often a code smell)\n if (code.includes(\"style={{\") || code.includes(\"style={\")) {\n const inlineStyleCount = (code.match(/style=\\{/g) || []).length;\n if (inlineStyleCount > 2) {\n issues.push({\n type: \"warning\",\n message: `Found ${inlineStyleCount} inline styles. Consider using CSS classes for consistency.`,\n });\n }\n }\n\n return {\n valid: issues.filter((i) => i.type === \"error\").length === 0,\n issues,\n };\n}\n\n/**\n * Lints a code snippet against the style guide\n */\nexport function lintSnippet(code: string, styleGuide: string | null): LintResult {\n const issues: LintIssue[] = [];\n\n // Basic linting even without style guide\n issues.push(...lintBasicPatterns(code));\n\n // Style guide-based linting\n if (styleGuide) {\n issues.push(...lintAgainstStyleGuide(code, styleGuide));\n }\n\n const errorCount = issues.filter((i) => i.severity === \"error\").length;\n const warningCount = issues.filter((i) => i.severity === \"warning\").length;\n\n return {\n issues,\n summary:\n issues.length === 0\n ? \"No issues found\"\n : `Found ${errorCount} errors and ${warningCount} warnings`,\n };\n}\n\nfunction lintBasicPatterns(code: string): LintIssue[] {\n const issues: LintIssue[] = [];\n\n // Check for magic numbers in styling\n const magicNumbers = code.matchAll(\n /(?:width|height|size):\\s*(\\d+)(?!px|rem|em|%)/g\n );\n for (const match of magicNumbers) {\n issues.push({\n severity: \"warning\",\n type: \"spacing\",\n message: `Magic number ${match[1]} found without unit`,\n code: match[0],\n suggestion: `Add a unit like ${match[1]}px or use a design token`,\n });\n }\n\n // Check for hardcoded colors in className strings\n const hardcodedTailwindColors = code.matchAll(\n /className=[\"'][^\"']*(?:bg|text|border)-\\[#[A-Fa-f0-9]+\\][^\"']*/g\n );\n for (const match of hardcodedTailwindColors) {\n issues.push({\n severity: \"warning\",\n type: \"color\",\n message: \"Hardcoded color in Tailwind arbitrary value\",\n code: match[0],\n suggestion: \"Use a color from your Tailwind config or style guide\",\n });\n }\n\n // Check for accessibility issues\n if (code.includes(\"<img\") && !code.includes(\"alt=\")) {\n issues.push({\n severity: \"error\",\n type: \"accessibility\",\n message: \"Image without alt attribute\",\n suggestion: 'Add alt=\"\" for decorative images or descriptive alt text',\n });\n }\n\n if (\n code.includes(\"<button\") &&\n !code.match(/<button[^>]*>.*\\S.*<\\/button>/s)\n ) {\n issues.push({\n severity: \"warning\",\n type: \"accessibility\",\n message: \"Button may be missing accessible text\",\n suggestion: \"Ensure button has visible text or aria-label\",\n });\n }\n\n // Check for inconsistent quote styles\n const singleQuotes = (code.match(/className='/g) || []).length;\n const doubleQuotes = (code.match(/className=\"/g) || []).length;\n if (singleQuotes > 0 && doubleQuotes > 0) {\n issues.push({\n severity: \"info\",\n type: \"component\",\n message: \"Mixed quote styles in className attributes\",\n suggestion: \"Use consistent quote style throughout\",\n });\n }\n\n return issues;\n}\n\nfunction lintAgainstStyleGuide(code: string, styleGuide: string): LintIssue[] {\n const issues: LintIssue[] = [];\n const values = extractStyleValues(styleGuide);\n\n // Check colors\n const codeColors = code.matchAll(/#[A-Fa-f0-9]{6}\\b/g);\n for (const match of codeColors) {\n const color = match[0].toUpperCase();\n if (!values.colors.includes(color)) {\n issues.push({\n severity: \"warning\",\n type: \"color\",\n message: `Color ${color} not in style guide`,\n code: match[0],\n suggestion: `Allowed colors: ${values.colors.slice(0, 5).join(\", \")}${values.colors.length > 5 ? \"...\" : \"\"}`,\n });\n }\n }\n\n // Check for non-standard spacing (not on 4px grid)\n const spacingValues = code.matchAll(/(?:p|m|gap)-(\\d+)/g);\n for (const match of spacingValues) {\n const value = parseInt(match[1]);\n // Tailwind uses 4px base (1 = 4px, 2 = 8px, etc.)\n // Non-standard would be values like 5, 7, 9, etc. in the 1-12 range\n if (value > 12 && value % 4 !== 0) {\n issues.push({\n severity: \"info\",\n type: \"spacing\",\n message: `Spacing value ${match[0]} might not align with design system`,\n suggestion:\n \"Consider using standard Tailwind spacing values (1-12, 16, 20, 24...)\",\n });\n }\n }\n\n return issues;\n}\n\nfunction extractColorsFromCode(code: string): string[] {\n const colors: string[] = [];\n\n // Match hex colors\n const hexMatches = code.matchAll(/#[A-Fa-f0-9]{6}\\b/g);\n for (const match of hexMatches) {\n colors.push(match[0].toUpperCase());\n }\n\n // Match Tailwind color classes\n const tailwindMatches = code.matchAll(/(?:bg|text|border)-(\\w+)-(\\d+)/g);\n for (const match of tailwindMatches) {\n // Convert Tailwind colors to a normalized form\n colors.push(`tailwind:${match[1]}-${match[2]}`);\n }\n\n return [...new Set(colors)];\n}\n\nfunction findSimilarColor(\n color: string,\n allowedColors: string[]\n): string | null {\n // Simple hex color distance check\n const colorRgb = hexToRgb(color);\n if (!colorRgb) return null;\n\n let closest: string | null = null;\n let closestDistance = Infinity;\n\n for (const allowed of allowedColors) {\n const allowedRgb = hexToRgb(allowed);\n if (!allowedRgb) continue;\n\n const distance = Math.sqrt(\n Math.pow(colorRgb.r - allowedRgb.r, 2) +\n Math.pow(colorRgb.g - allowedRgb.g, 2) +\n Math.pow(colorRgb.b - allowedRgb.b, 2)\n );\n\n if (distance < closestDistance && distance < 50) {\n closestDistance = distance;\n closest = allowed;\n }\n }\n\n return closest;\n}\n\nfunction hexToRgb(hex: string): { r: number; g: number; b: number } | null {\n const match = hex.match(/^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i);\n if (!match) return null;\n\n return {\n r: parseInt(match[1], 16),\n g: parseInt(match[2], 16),\n b: parseInt(match[3], 16),\n };\n}\n\n"],"mappings":";AAOO,SAAS,oBACd,cACA,YACQ;AACR,QAAM,eAAe,aACjB;AAAA,EAA2B,UAAU;AAAA;AAAA,IACrC;AAEJ,SAAO;AAAA;AAAA,EAEP,YAAY;AAAA;AAAA,EAEZ,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+Bd;AAKO,SAAS,sBAAsB,cAA8B;AAClE,SAAO;AAAA;AAAA,EAEP,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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