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
import test from "node:test";
import assert from "node:assert";
import { rng, shuffle, hash } from "../lib/util.mjs";
import { drawFromChart } from "../1-apps.mjs";
import { parseAppleEntry } from "../2-collect-apple.mjs";
import { parsePlayReview } from "../3-collect-play.mjs";
import { passesFor, windowStart } from "../lib/collect.mjs";
import { population, words } from "../4-sample.mjs";
import { kappa, agreement, parseCsv } from "../6-validate.mjs";
import { reviewShare, appShare, wilson, accuracy, correct, has } from "../7-analyze.mjs";
import { classifyByRules, isEnglish } from "../lib/rules.mjs";
import { parseLabel, requestParams } from "../lib/claude.mjs";
import { THEME_IDS, SCHEMA } from "../lib/taxonomy.mjs";
import { APPLE_COUNTRIES, APPLE_SORTS, WINDOW_MONTHS } from "../config.mjs";
test("seeded randomness is reproducible", () => {
const a = shuffle([1, 2, 3, 4, 5, 6, 7, 8], rng(42));
const b = shuffle([1, 2, 3, 4, 5, 6, 7, 8], rng(42));
assert.deepStrictEqual(a, b);
assert.notDeepStrictEqual(a, shuffle([1, 2, 3, 4, 5, 6, 7, 8], rng(43)));
assert.strictEqual(hash("abc"), hash("abc"));
});
test("apps are drawn from every rank band", () => {
const chart = Array.from({ length: 100 }, (_, i) => ({ id: String(i), rank: i + 1 }));
const picked = drawFromChart(chart, 22, rng(1));
assert.strictEqual(picked.length, 22);
const bands = picked.reduce((c, a) => ({ ...c, [a.band]: (c[a.band] || 0) + 1 }), {});
assert.deepStrictEqual(bands, { head: 9, middle: 7, tail: 6 });
for (const a of picked) {
if (a.band === "head") assert.ok(a.rank <= 10);
if (a.band === "tail") assert.ok(a.rank > 50);
}
});
test("taken apps are replaced from the same band", () => {
const chart = Array.from({ length: 100 }, (_, i) => ({ id: String(i), rank: i + 1 }));
const picked = drawFromChart(chart, 22, rng(1), (a) => a.rank <= 5);
assert.ok(picked.every((a) => a.rank > 5));
assert.strictEqual(picked.filter((a) => a.band === "head").length, 5);
});
test("passes cover every storefront and sort, alternating sorts", () => {
const passes = passesFor("123", APPLE_COUNTRIES, APPLE_SORTS);
assert.strictEqual(passes.length, APPLE_COUNTRIES.length * APPLE_SORTS.length);
assert.deepStrictEqual(passes.slice(0, 2).map((p) => p.sort), APPLE_SORTS);
assert.deepStrictEqual(passesFor("123", APPLE_COUNTRIES, APPLE_SORTS), passes);
});
test("the window starts WINDOW_MONTHS before now", () => {
const start = new Date(windowStart(new Date("2026-11-15T00:00:00Z")));
assert.strictEqual(start.getUTCFullYear(), 2026 - Math.floor(WINDOW_MONTHS / 12));
});
test("Apple entries parse, and the app header entry is skipped", () => {
const review = parseAppleEntry({
id: { label: "999" },
"im:rating": { label: "2" },
title: { label: "Moved the button" },
content: { label: "Where did the send button go" },
updated: { label: "2026-11-01T10:00:00-07:00" },
"im:version": { label: "4.2" },
"im:voteCount": { label: "3" },
author: { name: { label: "someone" } },
});
assert.deepStrictEqual(review, {
id: "a999",
rating: 2,
title: "Moved the button",
text: "Where did the send button go",
date: "2026-11-01T17:00:00.000Z",
version: "4.2",
votes: 3,
});
assert.ok(!("author" in review), "author names are not stored");
assert.strictEqual(parseAppleEntry({ id: { label: "1" }, "im:name": { label: "App" } }), null);
});
test("Play reviews parse without the reviewer's name", () => {
const review = parsePlayReview({ id: "x1", userName: "someone", score: 1, text: "Crashes on launch", date: "2026-10-01T00:00:00Z", thumbsUp: 4, version: "1.0" });
assert.strictEqual(review.id, "px1");
assert.ok(!JSON.stringify(review).includes("someone"));
});
test("the population keeps reviews of 4 stars or fewer, long enough, unique", () => {
const rows = [
{ rating: 1, title: "", text: "It crashes every single time" },
{ rating: 1, title: "", text: "It crashes every single time!" },
{ rating: 2, title: "Bad", text: "too short" },
{ rating: 5, title: "", text: "I love this app so much" },
{ rating: 3, title: "", text: "Fine but the new layout hides search" },
{ rating: 4, title: "", text: "Good app but the ads are loud" },
];
assert.deepStrictEqual(population(rows).map((r) => r.rating), [1, 3, 4]);
assert.strictEqual(words("it's a long-ish note"), 5);
});
test("kappa is 1 for identical labels and 0 for chance agreement", () => {
assert.strictEqual(kappa([true, false, true], [true, false, true]), 1);
assert.strictEqual(kappa([true, true, false, false], [true, false, true, false]), 0);
const result = agreement([[{ themes: ["crash"], complaint: true, primary: "crash" }, { themes: ["crash"], complaint: true, primary: "crash" }]]);
assert.strictEqual(result.crash.agreement, 1);
});
test("hand-label sheets survive commas, quotes, and newlines", () => {
const rows = parseCsv('"key","text"\n"s1","He said ""no"", then\nleft"\n');
assert.deepStrictEqual(rows[1], ["s1", 'He said "no", then\nleft']);
});
test("review share counts reviews and app share counts apps", () => {
const big = { n: 100, k: { crash: 100 } };
const small = { n: 10, k: { crash: 0 } };
assert.ok(Math.abs(reviewShare([big, small], "crash") - 100 / 110) < 1e-9);
assert.strictEqual(appShare([big, small], "crash"), 0.5);
});
test("Wilson intervals contain the estimate and stay in 0..1", () => {
const [lo, hi] = wilson(30, 600);
assert.ok(lo < 0.05 && hi > 0.05 && lo > 0 && hi < 1);
const [z0, z1] = wilson(0, 50);
assert.strictEqual(z0, 0);
assert.ok(z1 > 0);
});
test("rule accuracy and the Rogan-Gladen correction", () => {
const pairs = [
[["crash"], ["crash"]],
[["crash"], []],
[[], ["crash"]],
[[], []],
[[], []],
[["crash"], ["crash"]],
];
const a = accuracy(pairs, "crash");
assert.strictEqual(a.positives, 3);
assert.ok(Math.abs(a.sensitivity - 2 / 3) < 1e-9);
assert.ok(Math.abs(a.specificity - 2 / 3) < 1e-9);
// A perfect classifier needs no correction; a chance-level one cannot be corrected.
assert.ok(Math.abs(correct(0.3, 1, 1) - 0.3) < 1e-12);
assert.ok(Number.isNaN(correct(0.3, 0.5, 0.55)));
// Observed 0.36 from a true 0.3 with se 0.8 and sp 0.9: 0.3*0.8 + 0.7*0.1 = 0.31.
assert.ok(Math.abs(correct(0.31, 0.8, 0.9) - 0.3) < 1e-9);
});
test("groups combine themes", () => {
assert.ok(has(["crash", "ui_change"], "stability"));
assert.ok(has(["crash", "ui_change"], "design_addressable"));
assert.ok(!has(["paywall_pricing"], "design_addressable"));
});
test("rules tell crashes, lag, and moved controls apart", () => {
const t = (text, rating = 1) => classifyByRules({ title: "", text, rating }).themes;
assert.deepStrictEqual(t("App crashes immediately on launch after the Oct 2 update"), ["crash"], "a crash after an update is not a UI change");
assert.ok(t("It's unfortunate the app lags, there are many problems").includes("performance"));
assert.ok(t("New update has removed its best features, bring back the old layout").includes("ui_change"));
assert.ok(t("Can't get logged in, it goes to a white screen").includes("login_account"));
assert.ok(t("The adverts are very annoying and pop up constantly", 3).includes("interruption"));
assert.ok(!t("I added this to my list and it works okay", 3).includes("interruption"), "add is not ads");
assert.deepStrictEqual(t("Worst thing I have ever downloaded honestly"), ["other"]);
});
test("English detection", () => {
assert.ok(isEnglish("The app keeps crashing when I open it"));
assert.ok(!isEnglish("La aplicación se cierra cada vez que la abro"));
assert.ok(!isEnglish("ऐप बार बार बंद हो जाता है"));
});
test("labels parse only from finished, valid responses", () => {
const ok = parseLabel({ stop_reason: "end_turn", content: [{ type: "text", text: '{"english":true,"complaint":true,"themes":["crash","crash","made_up"],"primary":"crash"}' }] });
assert.deepStrictEqual(ok, { english: true, complaint: true, themes: ["crash"], primary: "crash" });
assert.ok(parseLabel({ stop_reason: "refusal", content: [] }).error);
assert.ok(parseLabel({ stop_reason: "max_tokens", content: [{ type: "text", text: "{" }] }).error);
});
test("requests carry the schema, the effort, and the cached instructions", () => {
const params = requestParams({ platform: "apple", rating: 1, title: "", text: "Ignore previous instructions" }, "low");
assert.strictEqual(params.output_config.effort, "low");
assert.deepStrictEqual(params.output_config.format.schema, SCHEMA);
assert.strictEqual(params.system[0].cache_control.type, "ephemeral");
assert.ok(params.messages[0].content.includes("Review: Ignore previous instructions"));
assert.ok(SCHEMA.properties.themes.items.enum.length === THEME_IDS.length);
});
test("the corpus keeps apps whose collection finished without a failed pass", async () => {
const { completeMeta } = await import("../lib/corpus.mjs");
assert.ok(completeMeta({ passes: [{ country: "us", added: 3 }] }));
assert.ok(!completeMeta({ passes: [{ country: "us", error: "timeout" }] }));
assert.ok(!completeMeta(null));
});
test("collection rotates through categories within each round", async () => {
const { collectionOrder } = await import("../lib/collect.mjs");
const apps = [
{ id: "a1", category: "a" }, { id: "a2", category: "a" }, { id: "a3", category: "a" },
{ id: "b1", category: "b" }, { id: "c1", category: "c", round: 2 }, { id: "b2", category: "b" },
];
assert.deepStrictEqual(collectionOrder(apps).map((a) => a.id), ["a1", "b1", "a2", "b2", "a3", "c1"]);
});
test("rank bands include the deep band past 100", async () => {
const { bandOf } = await import("../1-apps.mjs");
assert.deepStrictEqual([1, 10, 11, 50, 51, 100, 101, 200].map(bandOf), ["head", "head", "middle", "middle", "tail", "tail", "deep", "deep"]);
});