Your app looks AI-generated. Vincent Van Gogh noticed. An agent skill that finds and fixes AI-looking UI and UX in mobile apps, web apps, and websites.
JavaScript accessibilityagent-skillsagent-skills-toolsagentsagentskillsai-slopclaudeclaude-codeclaude-skillsexpoflutterfrontendionicjetpack-composemobilereact-nativeswiftuiuiuxvibe-coding
fix(detect): flag Compose Color component stops in slop-gradient (#174) (#190)
Papito084f4e30b30ee3d
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex 38fc283..68f61fa 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -171,6 +171,31 @@ function swiftRgbColors(snippet) {return out;}+// Jetpack Compose's Color(red = ..., green = ..., blue = ...) in a snippet,+// as uppercase hex, so it goes through the same checks as Color(0xFF7C3AED).+// Components may be ints (0 to 255) or floats (0 to 1, typically ending in f).+// A trailing alpha is skipped; a component that is not a number skips the color.+function composeColors(snippet) {+ const out = [];+ const number = "(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?[fF]?";+ const re = new RegExp(`\\bColor\\(\\s*red\\s*=\\s*(${number})\\s*,\\s*green\\s*=\\s*(${number})\\s*,\\s*blue\\s*=\\s*(${number})\\s*[,)]`, "g");+ let m;+ while ((m = re.exec(snippet))) {+ const raw = [m[1], m[2], m[3]];+ const isFloat = raw.some((c) => /[.fF]/.test(c));+ const hex = raw.map((c) => {+ const num = parseFloat(c);+ if (Number.isNaN(num)) return null;+ if (isFloat) {+ return Math.round(Math.min(1, Math.max(0, num)) * 255).toString(16).padStart(2, "0");+ }+ return Math.round(Math.min(255, Math.max(0, num))).toString(16).padStart(2, "0");+ });+ if (hex.every(Boolean)) out.push(hex.join("").toUpperCase());+ }+ return out;+}+// The purple, indigo, violet and hot-pink band that default AI palettes live in.function isSlopHue(hex) {const { h, s, l } = hexToHsl(hex);@@ -825,7 +850,7 @@ const rules = [if (/^\s*(?:import|export\s+\{|from)\b/.test(code.slice(lineStart, m.index))) continue;// Only the gradient's own stops count, not whatever follows it.const stops = gradientScope(code, m.index, m[0]);- if ([...hexColors(stops, stack), ...cssFunctionColors(stops), ...flutterColors(stops), ...swiftRgbColors(stops)].some(isSlopHue) || SLOP_COLOR_NAME.test(stops)) hits.push(m.index);+ if ([...hexColors(stops, stack), ...cssFunctionColors(stops), ...flutterColors(stops), ...swiftRgbColors(stops), ...composeColors(stops)].some(isSlopHue) || SLOP_COLOR_NAME.test(stops)) hits.push(m.index);}// Tailwind: bg-gradient-to-r from-violet-600 to-fuchsia-500for (const m of matches(/["'`][^"'`\n]*\bbg-(?:gradient|linear|radial|conic)-[^"'`\n]*["'`]/, code)) {diff --git a/test/detect.test.js b/test/detect.test.jsindex f88fd3d..d62fa90 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -1820,3 +1820,28 @@ test("slop-gradient reads UIKit system colors like .systemPurple and .systemPink];for (const stops of quiet) assert.deepStrictEqual(rulesFor(gradient(stops)), [], stops);});++test("slop-gradient reads Compose Color(red = ..., green = ..., blue = ...) stops (issue #174)", () => {+ const rulesFor = (src) => scanSource(src, "Hero.kt").map((f) => f.rule).filter((r) => r === "slop-gradient");+ const gradient = (stops) => `Box(Modifier.background(Brush.linearGradient(listOf(${stops}))))\n`;+ const flagged = [+ "Color(red = 124, green = 58, blue = 237), Color(red = 219, green = 39, blue = 119)",+ "Color(red = 0.49f, green = 0.23f, blue = 0.93f), Color(red = 0.86f, green = 0.15f, blue = 0.47f)",+ "Color(red = 124, green = 58, blue = 237, alpha = 255), Color.White",+ "Color(red = 0.49f, green = 0.23f, blue = 0.93f, alpha = 0.8f), Color.White",+ // Trailing comma+ "Color(red = 124, green = 58, blue = 237,), Color.White",+ // Multiline+ "Color(\n red = 124,\n green = 58,\n blue = 237\n ), Color.White",+ ];+ for (const stops of flagged) assert.deepStrictEqual(rulesFor(gradient(stops)), ["slop-gradient"], stops);++ const quiet = [+ "Color(red = 14, green = 165, blue = 233), Color(red = 34, green = 197, blue = 94)",+ "Color(red = 0.05f, green = 0.65f, blue = 0.91f), Color(red = 0.13f, green = 0.77f, blue = 0.37f)",+ "Color(red = 0, green = 0, blue = 0), Color(red = 255, green = 255, blue = 255)",+ // A component that is a variable cannot be read.+ "Color(red = r, green = g, blue = b), Color(red = redVar, green = 58, blue = 237)",+ ];+ for (const stops of quiet) assert.deepStrictEqual(rulesFor(gradient(stops)), [], stops);+});