Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
chore(ui-lint): add lintapple route and docs checks
IGECT206a05e93a30
diff --git a/.agents/skills/ui-lint/SKILL.md b/.agents/skills/ui-lint/SKILL.mdnew file mode 100644index 00000000..4d217f60--- /dev/null+++ b/.agents/skills/ui-lint/SKILL.md@@ -0,0 +1,39 @@+---+name: ui-lint+description: Run targeted rendered UI verification with lintapple (`pnpm lint:ui <target>`). Use whenever modifying Svelte routes (`src/routes/`), UI components (`src/components/`), CSS stylesheets (`src/app.css`, `src/lib/style/`), the landing page (`index.html`, `preview.html`), or documentation pages (`docs/`).+---++# Targeted UI Lint (`lintapple`)++Verify rendered layout, typography scale, concentric border radii, contrast, and accessibility on the exact surface you modified before completing any UI or documentation task.++## Workflow++1. Identify the target route or page matching the files you modified using the table below.+2. Run `pnpm lint:ui <target>` (add `--json` to inspect full DOM selectors and suggested fixes).+3. Fix every new finding reported against your changes and re-run `pnpm lint:ui <target>` until it exits `0`.++## File-to-Target Mapping++| Modified Path | Command to Run | Policy Applied |+| :--- | :--- | :--- |+| `src/routes/<feature>/**` | `pnpm lint:ui /<feature>` | `ui-policy.app.json` + baseline |+| `src/routes/+page.svelte` | `pnpm lint:ui /` | `ui-policy.app.json` + durable baseline |+| `src/lib/style/settings.css` | `pnpm lint:ui /settings` | `ui-policy.app.json` + baseline |+| `src/lib/style/queue-kinds.css` | `pnpm lint:ui /downloads` | `ui-policy.app.json` + baseline |+| `src/lib/style/notes.css` | `pnpm lint:ui /study` | `ui-policy.app.json` + baseline |+| `src/routes/+layout.svelte`, `src/components/shell/**`, `src/lib/style/buttons.css`, `src/lib/style/primitives.css` | `pnpm lint:ui --shell` | `ui-policy.app.json` + baseline |+| `src/app.css` | `pnpm lint:ui /settings --all-themes` | `ui-policy.app.json` across all 14 themes |+| `index.html`, `preview.html` | `pnpm lint:ui index.html` | `ui-policy.docs.json` (0 findings required) |+| `docs/<section>/index.html` | `pnpm lint:ui docs/<section>/index.html` | `ui-policy.docs.json` (0 findings required) |++## Policies & Baseline Rules++- **Desktop App ([`ui-policy.app.json`](../../../ui-policy.app.json))**:+ - Enforces [src/app.css](../../../src/app.css) typography, control sizing, spacing, and third-party canvas exceptions across default and minimum Tauri window viewports.+ - Compares per-theme rule counts against [`scripts/ui-lint-baseline.json`](../../../scripts/ui-lint-baseline.json). The check exits `0` when no rule count increases on the target route.+ - When adding a new token size to `src/app.css`, update `ui-policy.app.json` in the same commit.+ - When cleaning up pre-existing UI findings on a route, ratchet its baseline down with `pnpm lint:ui:update /<feature>`.+- **Landing Page & Docs ([`ui-policy.docs.json`](../../../ui-policy.docs.json))**:+ - Enforces desktop and mobile viewports across `dark` and `light` themes, including `bannedCopy` rules.+ - Requires strict zero findings (`0` tolerance).diff --git a/AGENTS.md b/AGENTS.mdindex 3dd07e13..883a8a85 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -77,3 +77,5 @@ Welcome to OmniGet. This file serves as the definitive reference and operating mBefore finishing any task or committing changes:- `pnpm test` : Runs full Vitest suite (must pass 100%).- `node scripts/e2e_verify.mjs` : Validates documentation suite routes, links, and accessibility.+- `pnpm lint:ui <target>` : Required whenever modifying Svelte routes, UI components, stylesheets, `index.html`, or `docs/` — see [.agents/skills/ui-lint/SKILL.md](.agents/skills/ui-lint/SKILL.md).+diff --git a/package.json b/package.jsonindex 7555ca49..71a8cafd 100644--- a/package.json+++ b/package.json@@ -17,6 +17,8 @@"check:i18n": "node scripts/generate-i18n-keys.js --strict","check:clippy-baseline": "node scripts/clippy-baseline.mjs --check","update:clippy-baseline": "node scripts/clippy-baseline.mjs --update",+ "lint:ui": "node scripts/lint-ui.mjs",+ "lint:ui:update": "node scripts/lint-ui.mjs --update","plugins:deploy": "node scripts/deploy-plugins-local.mjs","extension:sync": "node browser-extension/sync.mjs","test": "vitest run",@@ -79,6 +81,7 @@"@types/katex": "^0.16.7","@types/marked": "^6.0.0","@types/node": "^25.6.0",+ "lintapple": "^0.1.20","playwright": "^1.62.0","svelte": "^5.0.0","svelte-check": "^4.0.0",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 90b84c59..be343b84 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -168,6 +168,9 @@ importers:'@types/node':specifier: ^25.6.0version: 25.6.0+ lintapple:+ specifier: ^0.1.20+ version: 0.1.20playwright:specifier: ^1.62.0version: 1.62.0@@ -1270,6 +1273,10 @@ packages:resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}engines: {node: '>=12'}+ resolution: {integrity: sha512-9WTZxEjsZ7b13TH8JPmbV2z8CHbl80/2hm3XPEG4JgNdQLK81IBRXmSxHfMAOkSqQeRxT/0dwNDz2GOm3zzpcQ==}+ engines: {node: '>=4'}+resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}engines: {node: '>= 0.4'}@@ -1657,6 +1664,11 @@ packages:resolution: {integrity: sha512-NT1CJtq3hHIreOianA8aSXn6Cw0JzYOuDQbOrSPe7gqFnCpKP++MQe3ODgO3oh2GJFORkAAdqredOa60z63GbA==}+ resolution: {integrity: sha512-n5wXJQci3ygYTvTI5eyX4otVVkOzEpkZnH5b+PBtciivnROaH4ZhDmb4nBeJ8Nhbm+SXggRLrccIShmqOSHV8w==}+ engines: {node: '>=22'}+ hasBin: true+resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==}@@ -1788,11 +1800,21 @@ packages:engines: {node: '>=20'}hasBin: true+ resolution: {integrity: sha512-rYCsBF/M5HjUch52bbtVONEFjv6Xu8sm8h72dNlR5bzIE1fvC/bxgspzkjSfU+MweEMmPM8KJebG6nnyxo5mCg==}+ engines: {node: '>=20'}+ hasBin: true+resolution: {integrity: sha512-Z14dG305dgaLu6foB1TXQagFiW8JfSUIUaUuPaKQ6NtBPKF1P/qXcqfh6c6K/icPqdy37JmjbiBXf6JNg6Sylw==}engines: {node: '>=20'}hasBin: true+ resolution: {integrity: sha512-+7ziBLidS4NaNCdt57SUDT+wYmmd5fmiQejUic/kb+YsYSCPyOOE9sebzMjNmQrsnNpDJqd4WHvV/8lfKfUDUg==}+ engines: {node: '>=20'}+ hasBin: true+resolution: {integrity: sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A==}@@ -3040,6 +3062,8 @@ snapshots:+ [email protected]: {}+@@ -3468,6 +3492,11 @@ snapshots:+ dependencies:+ axe-core: 4.14.0+ playwright: 1.63.0+@@ -3616,12 +3645,18 @@ snapshots:+ [email protected]: {}+dependencies:playwright-core: 1.62.0optionalDependencies:fsevents: 2.3.2+ dependencies:+ playwright-core: 1.63.0+diff --git a/scripts/lint-ui.mjs b/scripts/lint-ui.mjsnew file mode 100644index 00000000..4e6a862d--- /dev/null+++ b/scripts/lint-ui.mjs@@ -0,0 +1,777 @@+#!/usr/bin/env node+// @ts-nocheck+/**+ * OmniGet Targeted UI Linter (powered by lintapple + Playwright)+ *+ * Audits rendered UI against explicit design policies:+ * - ui-policy.app.json : Svelte 5 desktop routes (1100x720 & 800x560, 28px controls, baseline diffing)+ * - ui-policy.docs.json : Landing page & docs suite (1280x800 & 375x812, strict zero-findings)+ *+ * Usage:+ * pnpm lint:ui /settings # Lint a single Svelte route (dark + light)+ * pnpm lint:ui /courses # Lint an embedded plugin route+ * pnpm lint:ui docs/mcp/index.html # Lint a single documentation page+ * pnpm lint:ui index.html # Lint the root landing page+ * pnpm lint:ui --shell # Lint all core desktop routes+ * pnpm lint:ui --docs # Lint landing page + all 7 doc pages+ * pnpm lint:ui /settings --all-themes # Lint across all 14 themes in src/app.css+ * pnpm lint:ui:update [target] # Record/refresh baseline in scripts/ui-lint-baseline.json+ */++import { spawn } from "node:child_process";+import fs from "node:fs";+import http from "node:http";+import path from "node:path";+import { fileURLToPath } from "node:url";+import { chromium } from "playwright";+import { checkPage, validatePolicy } from "lintapple";++const __dirname = path.dirname(fileURLToPath(import.meta.url));+export const ROOT_DIR = path.resolve(__dirname, "..");+export const APP_POLICY_PATH = path.join(ROOT_DIR, "ui-policy.app.json");+export const DOCS_POLICY_PATH = path.join(ROOT_DIR, "ui-policy.docs.json");+export const BASELINE_PATH = path.join(ROOT_DIR, "scripts", "ui-lint-baseline.json");++export const ALL_APP_THEMES = [+ "dark",+ "light",+ "catppuccin-mocha",+ "catppuccin-macchiato",+ "catppuccin-frappe",+ "catppuccin-latte",+ "one-dark-pro",+ "dracula",+ "nyxvamp-veil",+ "nyxvamp-obsidian",+ "nyxvamp-radiance",+ "eink-day",+ "eink-sepia",+ "eink-night",+];++export const LIGHT_SCHEME_THEMES = new Set([+ "light",+ "catppuccin-latte",+ "nyxvamp-radiance",+ "eink-day",+ "eink-sepia",+]);++export const SHELL_ROUTES = [+ "/",+ "/downloads",+ "/omnidisc",+ "/settings",+ "/marketplace",+ "/about",+ "/open-nami",+ "/league",+ "/tools",+];++export const PLUGIN_ROUTES = [+ "/courses",+ "/convert",+ "/telegram",+ "/study",+];++export const CANONICAL_DOCS = [+ "index.html",+ "docs/index.html",+ "docs/installation/index.html",+ "docs/mcp/index.html",+ "docs/courses/index.html",+ "docs/opennami/index.html",+ "docs/troubleshooting/index.html",+ "docs/changelog/index.html",+];++function normalizeDocTarget(raw) {+ const cleaned = raw.replace(/\\/g, "/").replace(/^\.\//, "");+ if (cleaned.endsWith(".html")) return cleaned;+ return `${cleaned.replace(/\/$/, "")}/index.html`;+}++export function resolveTargets(argv = []) {+ const mode = argv.includes("--update") ? "update" : "check";+ const json = argv.includes("--json");+ const allThemes = argv.includes("--all-themes");+ const isShell = argv.includes("--shell");+ const isDocs = argv.includes("--docs");++ const positional = argv.filter((a) => !a.startsWith("--"));++ if (isDocs) {+ return {+ surface: "docs",+ targets: CANONICAL_DOCS,+ themes: ["dark", "light"],+ mode,+ json,+ };+ }++ if (isShell) {+ return {+ surface: "app",+ targets: SHELL_ROUTES,+ themes: allThemes ? ALL_APP_THEMES : ["dark", "light"],+ mode,+ json,+ };+ }++ if (positional.length === 0) {+ return {+ surface: "app",+ targets: allThemes ? ["/", "/settings"] : ["/"],+ themes: allThemes ? ALL_APP_THEMES : ["dark", "light"],+ mode,+ json,+ };+ }++ const primaryTarget = positional[0].replace(/\\/g, "/");+ const isDocTarget =+ primaryTarget === "index.html" ||+ primaryTarget === "preview.html" ||+ primaryTarget.startsWith("docs/") ||+ primaryTarget === "docs" ||+ primaryTarget.endsWith(".html");++ if (isDocTarget) {+ return {+ surface: "docs",+ targets: positional.map(normalizeDocTarget),+ themes: ["dark", "light"],+ mode,+ json,+ };+ }++ return {+ surface: "app",+ targets: positional.map((t) => (t.startsWith("/") ? t : `/${t}`)),+ themes: allThemes ? ALL_APP_THEMES : ["dark", "light"],+ mode,+ json,+ };+}++/**+ * Computes per-rule counts for a target. When findings carry a `theme` tag,+ * takes the maximum count per rule across audited themes so `--all-themes`+ * (14 themes) compares on the same scale as the 2-theme baseline while still+ * catching any theme-specific regression.+ */+export function tallyFindings(findings = []) {+ const perTheme = new Map();+ for (const f of findings) {+ if (!f || !f.rule) continue;+ const themeKey = f.theme ?? "default";+ let counts = perTheme.get(themeKey);+ if (!counts) {+ counts = {};+ perTheme.set(themeKey, counts);+ }+ counts[f.rule] = (counts[f.rule] ?? 0) + 1;+ }++ const maxByRule = {};+ for (const counts of perTheme.values()) {+ for (const [rule, count] of Object.entries(counts)) {+ maxByRule[rule] = Math.max(maxByRule[rule] ?? 0, count);+ }+ }++ return Object.fromEntries(+ Object.entries(maxByRule).sort(([a], [b]) => a.localeCompare(b))+ );+}++export function compareTargetBaseline(surface, currentCounts = {}, baselineCounts = {}) {+ const worse = [];+ const better = [];++ if (surface === "docs") {+ for (const [rule, now] of Object.entries(currentCounts)) {+ if (now > 0) {+ worse.push({ rule, was: 0, now });+ }+ }+ return { passed: worse.length === 0, worse, better };+ }++ const allRules = new Set([+ ...Object.keys(baselineCounts),+ ...Object.keys(currentCounts),+ ]);+ for (const rule of allRules) {+ const was = baselineCounts[rule] ?? 0;+ const now = currentCounts[rule] ?? 0;+ if (now > was) worse.push({ rule, was, now });+ if (now < was) better.push({ rule, was, now });+ }++ return { passed: worse.length === 0, worse, better };+}++/**+ * Generates the Playwright init script that mocks window.__TAURI_INTERNALS__+ * with populated fixture data for Core and Embedded Plugin routes.+ */+export function buildTauriMockInitScript(theme = "dark") {+ return `+ (() => {+ window.__OMNIGET_LINT_THEME__ = ${JSON.stringify(theme)};+ try {+ localStorage.setItem("omniget_last_seen_version", "0.12.0");+ localStorage.setItem("omniget_docs_theme", ${JSON.stringify(theme)});+ localStorage.setItem("theme", ${JSON.stringify(theme)});+ } catch {}++ const mockSettings = {+ schema_version: 1,+ appearance: { theme: ${JSON.stringify(theme)}, language: "en" },+ download: {+ default_output_dir: "C:\\\\Users\\\\user\\\\Downloads\\\\OmniGet",+ always_ask_path: false,+ video_quality: "1080p",+ skip_existing: true,+ download_attachments: true,+ download_descriptions: false,+ embed_metadata: true,+ embed_thumbnail: true,+ write_nfo_sidecar: false,+ clipboard_detection: false,+ auto_download_on_paste: false,+ filename_template: "%(title)s.%(ext)s",+ organize_by_platform: true,+ download_subtitles: true,+ include_auto_subtitles: false,+ caption_locale: "en",+ keep_vtt: false,+ continuous_lecture_numbers: true,+ translate_metadata: false,+ youtube_sponsorblock: false,+ sponsorblock_mode: "mark",+ sponsorblock_categories: ["sponsor"],+ split_by_chapters: false,+ live_from_start: false,+ speed_limit: "",+ hotkey_enabled: false,+ hotkey_binding: "CommandOrControl+Shift+D",+ music_hotkey_enabled: false,+ music_hotkey_binding: "CommandOrControl+Shift+M",+ music_audio_format: "mp3",+ copy_to_clipboard_on_hotkey: false,+ cookie_file: "",+ always_use_managed_cookies: false,+ bilibili_danmaku_enabled: false,+ bilibili_danmaku_format: "xml",+ bilibili_container: "mp4",+ bilibili_nfo_enabled: false,+ bilibili_cover_sidecar: false,+ bilibili_cover_format: "jpg",+ bilibili_naming_video: "{title}",+ bilibili_naming_multi_part: "{title} - P{part}",+ bilibili_naming_bangumi: "{title}",+ bilibili_naming_cheese: "{title}",+ bilibili_naming_collection: "{title}",+ bilibili_cdn_hosts: "",+ bilibili_cdn_prefer_alternatives: false,+ bilibili_preferred_qn: 80,+ bilibili_preferred_codec: 7,+ bilibili_preferred_audio_qn: 30280+ },+ advanced: {+ max_concurrent_segments: 4,+ max_retries: 3,+ max_concurrent_downloads: 3,+ concurrent_fragments: 4,+ stagger_delay_ms: 200,+ torrent_listen_port: 6881,+ torrent_auto_trackers: true,+ torrent_upnp: true,+ prevent_sleep: false,+ cookies_from_browser: "none",+ twitter_manual_cookie: "",+ user_agent: "Mozilla/5.0"+ },+ telegram: { concurrent_downloads: 2, fix_file_extensions: true },+ rpc: { enabled: false, app_id: "", large_image_key: "" },+ omnidisc: { enabled: true },+ league: { enabled: true, auto_accept: false },+ onboarding_completed: true,+ start_with_system: false,+ start_minimized: false,+ legal_acknowledged: true,+ typography: {+ font_display: "System",+ font_body: "System",+ font_mono: "IBM Plex Mono",+ line_height_base: 1.5,+ spacing_scale: 1.0,+ preset_name: "system"+ }+ };++ const mockPlugins = [+ {+ id: "courses",+ name: "Courses",+ version: "0.12.0",+ enabled: true,+ nav: [{ route: "/courses", label: { en: "Courses" }, icon_svg: null, group: "plugins", order: 10 }]+ },+ {+ id: "telegram",+ name: "Telegram",+ version: "0.12.0",+ enabled: true,+ nav: [{ route: "/telegram", label: { en: "Telegram" }, icon_svg: null, group: "plugins", order: 20 }]+ },+ {+ id: "convert",+ name: "Convert",+ version: "0.12.0",+ enabled: true,+ nav: [{ route: "/convert", label: { en: "Convert" }, icon_svg: null, group: "plugins", order: 30 }]+ },+ {+ id: "study",+ name: "Study",+ version: "0.12.0",+ enabled: true,+ nav: [{ route: "/study", label: { en: "Study" }, icon_svg: null, group: "plugins", order: 40 }]+ }+ ];++ const mockQueue = [+ {+ id: "dl-1",+ url: "https://example.com/lecture-01.mp4",+ title: "01. Introduction to Distributed Systems",+ platform: "YouTube",+ status: "downloading",+ progress: 64.5,+ speed: "8.4 MB/s",+ eta: "00:18",+ total_bytes: 157286400,+ downloaded_bytes: 101449728,+ output_path: "C:\\\\Users\\\\user\\\\Downloads\\\\OmniGet\\\\lecture-01.mp4"+ }+ ];++ let callbackId = 1;+ const callbacks = new Map();++ window.__TAURI_INTERNALS__ = {+ metadata: {+ currentWindow: { label: "main" },+ currentWebview: { windowLabel: "main", label: "main" }+ },+ transformCallback(fn, once) {+ const id = callbackId++;+ callbacks.set(id, { fn, once });+ return id;+ },+ unregisterCallback(id) {+ callbacks.delete(id);+ },+ convertFileSrc(filePath) {+ return filePath;+ },+ async invoke(cmd, args = {}) {+ switch (cmd) {+ case "get_settings":+ case "update_settings":+ case "reset_settings":+ return mockSettings;+ case "list_plugins":+ case "get_marketplace_plugins":+ return mockPlugins;+ case "get_queue":+ case "list_downloads":+ return mockQueue;+ case "check_ytdlp":+ case "is_ytdlp_available":+ return { available: true, version: "2026.10.01", path: "yt-dlp" };+ case "omnidisc_connect":+ return {+ url: args?.url || "https://chat.tonho.wtf",+ instance: { name: "OmniDisc", registration_open: true },+ insecure: false,+ };+ case "omnidisc_has_session":+ return { has_session: false };+ case "omnidisc_voice_status":+ return { connected: false, muted: false, deafened: false, speaking: [] };+ case "omnidisc_voice_devices":+ return { inputs: [], outputs: [] };+ case "omnidisc_voice_ptt_status":+ return { binding: "Control+Shift+M", registered: false };+ case "plugin:courses|courses_list_platforms":+ return [+ { id: "udemy", name: "Udemy", auth_type: "token" },+ { id: "coursera", name: "Coursera", auth_type: "cookie" },+ ];+ case "plugin:telegram|telegram_get_auth_state":+ return { state: "authorized", phone: "+1 555 0100" };+ case "plugin:convert|convert_list_presets":+ return [{ id: "mp4-1080p", label: "MP4 1080p (H.264)" }];+ case "study_list_notebooks":+ case "study_list_decks":+ return [];+ case "plugin:app|version":+ return "0.12.0";+ case "plugin:app|name":+ return "OmniGet";+ case "plugin:event|listen":+ return callbackId++;+ case "plugin:event|unlisten":+ return null;+ case "plugin:clipboard-manager|read_text":+ return "";+ default:+ return null;+ }+ }+ };++ window.__TAURI_EVENT_PLUGIN_INTERNALS__ = {+ unregisterListener() {}+ };+ })();+ `;+}++async function checkTcpPort(host, port) {+ const net = await import("node:net");+ return new Promise((resolve) => {+ const socket = net.createConnection({ host, port });+ socket.setTimeout(800);+ socket.on("connect", () => {+ socket.destroy();+ resolve(true);+ });+ socket.on("timeout", () => {+ socket.destroy();+ resolve(false);+ });+ socket.on("error", () => {+ socket.destroy();+ resolve(false);+ });+ });+}++async function isPortOpen(port) {+ if (await checkTcpPort("127.0.0.1", port)) return "http://127.0.0.1:" + port;+ if (await checkTcpPort("::1", port)) return "http://localhost:" + port;+ return null;+}++async function ensureViteServer(port = 1420) {+ const existingUrl = await isPortOpen(port);+ if (existingUrl) {+ return { url: existingUrl, close: async () => {} };+ }++ const child = spawn(+ process.execPath,+ [+ path.join(ROOT_DIR, "node_modules", "vite", "bin", "vite.js"),+ "dev",+ "--host",+ "127.0.0.1",+ "--port",+ String(port),+ ],+ {+ cwd: ROOT_DIR,+ stdio: ["ignore", "pipe", "pipe"],+ env: { ...process.env, OMNIGET_I18N_STRICT: "0" },+ }+ );++ let logs = "";+ child.stdout.on("data", (d) => {+ logs += d.toString();+ });+ child.stderr.on("data", (d) => {+ logs += d.toString();+ });++ const deadline = Date.now() + 45000;+ while (Date.now() < deadline) {+ const openUrl = await isPortOpen(port);+ if (openUrl) {+ return {+ url: openUrl,+ close: async () => {+ child.kill();+ },+ };+ }+ await new Promise((r) => setTimeout(r, 400));+ }++ child.kill();+ throw new Error(`Timed out waiting for Vite dev server on port ${port}.\nLogs:\n${logs}`);+}++const MIME_TYPES = {+ ".html": "text/html; charset=utf-8",+ ".css": "text/css; charset=utf-8",+ ".js": "application/javascript; charset=utf-8",+ ".mjs": "application/javascript; charset=utf-8",+ ".json": "application/json; charset=utf-8",+ ".png": "image/png",+ ".jpg": "image/jpeg",+ ".jpeg": "image/jpeg",+ ".svg": "image/svg+xml",+ ".ico": "image/x-icon",+ ".woff2": "font/woff2",+};++async function detectExistingDocsServer(candidatePorts = [8080, 4173, 3000, 5500]) {+ if (process.env.UI_LINT_DOCS_URL) {+ return process.env.UI_LINT_DOCS_URL.replace(/\/$/, "");+ }+ for (const port of candidatePorts) {+ const openUrl = await isPortOpen(port);+ if (!openUrl) continue;+ try {+ const res = await fetch(`${openUrl}/index.html`, { signal: AbortSignal.timeout(1000) });+ if (res.ok) {+ const text = await res.text();+ if (text.includes("OmniGet") && text.includes("docs/")) {+ return openUrl;+ }+ }+ } catch {+ // Ignore non-docs server on candidate port+ }+ }+ return null;+}++async function ensureStaticDocsServer() {+ const existingUrl = await detectExistingDocsServer();+ if (existingUrl) {+ return { url: existingUrl, close: async () => {} };+ }++ const server = http.createServer((req, res) => {+ const urlPath = decodeURIComponent((req.url || "/").split("?")[0]);+ let relPath = urlPath.replace(/^\/+/, "");+ if (!relPath || relPath.endsWith("/")) {+ relPath = `${relPath}index.html`;+ }+ const absPath = path.resolve(ROOT_DIR, relPath);+ if (!absPath.startsWith(ROOT_DIR) || !fs.existsSync(absPath) || fs.statSync(absPath).isDirectory()) {+ res.writeHead(404);+ res.end("Not found");+ return;+ }+ const ext = path.extname(absPath).toLowerCase();+ res.writeHead(200, { "Content-Type": MIME_TYPES[ext] || "application/octet-stream" });+ fs.createReadStream(absPath).pipe(res);+ });++ return new Promise((resolve, reject) => {+ server.on("error", reject);+ server.listen(0, "127.0.0.1", () => {+ const address = server.address();+ const port = typeof address === "object" && address ? address.port : 0;+ resolve({+ url: `http://127.0.0.1:${port}`,+ close: () => new Promise((r) => server.close(() => r())),+ });+ });+ });+}++async function launchChromiumBrowser() {+ for (const opts of [{}, { channel: "chrome" }, { channel: "msedge" }]) {+ try {+ return await chromium.launch(opts);+ } catch {+ // Try next channel+ }+ }+ throw new Error(+ "No Chromium/Chrome/Edge browser found. Run `npx playwright install chromium --only-shell`."+ );+}++async function auditTarget(browser, baseUrl, surface, target, themes, policy) {+ const findings = [];++ for (const viewport of policy.viewports) {+ for (const theme of themes) {+ const isDarkScheme = !LIGHT_SCHEME_THEMES.has(theme);+ const colorScheme = isDarkScheme ? "dark" : "light";+ const context = await browser.newContext({+ viewport,+ colorScheme,+ reducedMotion: "reduce",+ locale: "en-US",+ timezoneId: "UTC",+ deviceScaleFactor: 1,+ });++ try {+ if (surface === "app") {+ await context.addInitScript(buildTauriMockInitScript(theme));+ } else {+ await context.addInitScript((t) => {+ try {+ localStorage.setItem("omniget_docs_theme", t);+ localStorage.setItem("theme", t);+ } catch {}+ }, theme);+ }++ const page = await context.newPage();+ page.setDefaultTimeout(60000);+ const url =+ surface === "app"+ ? `${baseUrl}${target}`+ : `${baseUrl}/${target.replace(/^\/+/, "")}`;++ await page.goto(url, { waitUntil: "load", timeout: 60000 });+ if (surface === "app") {+ await page+ .locator("#main-content, .stream-popout")+ .first()+ .waitFor({ state: "visible", timeout: 60000 });+ }+ await page.evaluate(+ ({ t, isDark }) => {+ document.documentElement.setAttribute("data-theme", t);+ document.documentElement.classList.toggle("dark", isDark);+ },+ { t: theme, isDark: isDarkScheme }+ );+ await page.waitForTimeout(200);++ const result = await checkPage(page, policy);+ for (const f of result.findings) {+ findings.push({+ ...f,+ target,+ theme,+ viewport: `${viewport.width}x${viewport.height}`,+ });+ }+ } finally {+ await context.close();+ }+ }+ }++ return findings;+}++async function main() {+ const plan = resolveTargets(process.argv.slice(2));+ const policyPath = plan.surface === "app" ? APP_POLICY_PATH : DOCS_POLICY_PATH;+ const policy = validatePolicy(JSON.parse(fs.readFileSync(policyPath, "utf-8")));++ const existingBaseline = fs.existsSync(BASELINE_PATH)+ ? JSON.parse(fs.readFileSync(BASELINE_PATH, "utf-8"))+ : { targets: {} };++ const server =+ plan.surface === "app"+ ? await ensureViteServer(1420)+ : await ensureStaticDocsServer();++ const browser = await launchChromiumBrowser();+ const targetFindings = {};+ const targetCounts = {};++ try {+ for (const target of plan.targets) {+ const findings = await auditTarget(+ browser,+ server.url,+ plan.surface,+ target,+ plan.themes,+ policy+ );+ targetFindings[target] = findings;+ targetCounts[target] = tallyFindings(findings);+ }+ } finally {+ await browser.close();+ await server.close();+ }++ if (plan.mode === "update") {+ const mergedTargets = { ...(existingBaseline.targets ?? {}), ...targetCounts };+ const updated = {+ updated_at: new Date().toISOString().split("T")[0],+ targets: Object.fromEntries(+ Object.entries(mergedTargets).sort(([a], [b]) => a.localeCompare(b))+ ),+ };+ fs.writeFileSync(BASELINE_PATH, JSON.stringify(updated, null, 2) + "\n");+ console.log(+ `UI lint baseline updated for ${plan.targets.join(", ")} -> ${path.relative(ROOT_DIR, BASELINE_PATH)}`+ );+ process.exit(0);+ }++ if (plan.json) {+ console.log(JSON.stringify({ plan, counts: targetCounts, findings: targetFindings }, null, 2));+ }++ let hasRegression = false;+ for (const target of plan.targets) {+ const counts = targetCounts[target];+ const baselineForTarget = existingBaseline.targets?.[target] ?? {};+ const comparison = compareTargetBaseline(plan.surface, counts, baselineForTarget);++ if (!comparison.passed) {+ hasRegression = true;+ console.error(`\n[FAIL] UI lint regression on ${target}:`);+ for (const { rule, was, now } of comparison.worse) {+ console.error(` ${rule}: ${was} -> ${now} (+${now - was})`);+ const examples = targetFindings[target]+ .filter((f) => f.rule === rule)+ .slice(0, 3);+ for (const ex of examples) {+ console.error(+ ` - [${ex.theme} @ ${ex.viewport}] ${ex.selector}: ${ex.message} (Fix: ${ex.fix})`+ );+ }+ }+ } else {+ const total = Object.values(counts).reduce((a, b) => a + b, 0);+ console.log(`[PASS] ${target} (${total} baselined findings, 0 new)`);+ if (comparison.better.length > 0) {+ console.log(+ ` (${comparison.better.length} rule(s) improved on ${target} — run \`pnpm lint:ui:update ${target}\` to ratchet baseline down)`+ );+ }+ }+ }++ process.exit(hasRegression ? 1 : 0);+}++const isDirectRun =+ process.argv[1] &&+ path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));++if (isDirectRun) {+ main().catch((err) => {+ console.error(err);+ process.exit(2);+ });+}diff --git a/scripts/ui-lint-baseline.json b/scripts/ui-lint-baseline.jsonnew file mode 100644index 00000000..5c153d5b--- /dev/null+++ b/scripts/ui-lint-baseline.json@@ -0,0 +1,87 @@+{+ "updated_at": "2026-10-12",+ "targets": {+ "/": {+ "control-gap": 6,+ "control-size": 16,+ "label-consistency": 5,+ "text-contrast": 27+ },+ "/about": {+ "control-size": 2,+ "label-consistency": 3,+ "text-contrast": 2+ },+ "/convert": {+ "control-size": 2,+ "font-size": 4,+ "label-consistency": 3,+ "text-contrast": 2+ },+ "/courses": {+ "control-size": 2,+ "font-size": 4,+ "label-consistency": 3,+ "text-contrast": 2+ },+ "/downloads": {+ "control-gap": 2,+ "control-size": 9,+ "label-consistency": 3,+ "text-contrast": 2+ },+ "/league": {+ "control-size": 2,+ "font-size": 6,+ "label-consistency": 3,+ "text-contrast": 2+ },+ "/marketplace": {+ "control-gap": 1,+ "control-size": 20,+ "label-consistency": 3,+ "text-contrast": 20+ },+ "/omnidisc": {+ "control-gap": 2,+ "control-size": 2,+ "label-consistency": 3,+ "text-contrast": 2+ },+ "/open-nami": {+ "aria-reference": 4,+ "control-gap": 8,+ "control-size": 6,+ "font-size": 10,+ "label-consistency": 3,+ "text-contrast": 6+ },+ "/settings": {+ "control-gap": 18,+ "control-size": 2,+ "font-size": 10,+ "label-consistency": 3,+ "text-contrast": 6+ },+ "/study": {+ "control-gap": 4,+ "control-size": 7,+ "font-size": 4,+ "label-consistency": 3,+ "text-contrast": 3+ },+ "/telegram": {+ "control-size": 2,+ "font-size": 4,+ "label-consistency": 3,+ "text-contrast": 2+ },+ "/tools": {+ "content-clipping": 2,+ "control-gap": 8,+ "control-size": 12,+ "label-consistency": 17,+ "text-contrast": 6+ }+ }+}diff --git a/src/lib/ui-lint.test.ts b/src/lib/ui-lint.test.tsnew file mode 100644index 00000000..f20e57dc--- /dev/null+++ b/src/lib/ui-lint.test.ts@@ -0,0 +1,169 @@+import { describe, it, expect } from "vitest";+import fs from "node:fs";+import path from "node:path";+// @ts-expect-error lintapple ships untyped ESM root export+import { validatePolicy } from "lintapple";++describe("UI Lint Policies & Target Runner", () => {+ const rootDir = path.resolve(__dirname, "../..");+ const appPolicyPath = path.join(rootDir, "ui-policy.app.json");+ const docsPolicyPath = path.join(rootDir, "ui-policy.docs.json");++ it("validates ui-policy.app.json against lintapple and OmniGet desktop tokens", () => {+ const raw = JSON.parse(fs.readFileSync(appPolicyPath, "utf-8"));+ const validated = validatePolicy(raw);++ expect(validated.minControlSize).toBe(28);+ expect(validated.fontSizes).toEqual([10, 11, 12, 13, 15, 17, 22, 26, 32, 40]);+ expect(validated.viewports).toEqual([+ { width: 1100, height: 720 },+ { width: 800, height: 560 },+ ]);+ expect(validated.colorSchemes).toEqual(["dark", "light"]);+ });++ it("validates ui-policy.docs.json against lintapple and includes anti-slop banned copy", () => {+ const raw = JSON.parse(fs.readFileSync(docsPolicyPath, "utf-8"));+ const validated = validatePolicy(raw);++ expect(validated.viewports).toEqual([+ { width: 1280, height: 800 },+ { width: 375, height: 812 },+ ]);+ expect(validated.colorSchemes).toEqual(["dark", "light"]);+ expect(validated.bannedCopy).toEqual(+ expect.arrayContaining([+ "seamlessly",+ "seamless",+ "comprehensive",+ "empowering",+ "half the battle",+ "revolutionize",+ "delve",+ "testament",+ "elevate",+ "comprehensive suite",+ "robust powerhouse",+ "powerhouse",+ "supercharge",+ "cutting-edge",+ "game-changer",+ "unleash",+ "tapestry",+ "multifaceted",+ "unparalleled",+ ])+ );+ });++ it("resolves single Svelte routes, doc paths, --shell, and --all-themes", async () => {+ const { resolveTargets, ALL_APP_THEMES, SHELL_ROUTES, buildTauriMockInitScript } = await import(+ "../../scripts/lint-ui.mjs"+ );++ const singleRoute = resolveTargets(["/settings"]);+ expect(singleRoute.surface).toBe("app");+ expect(singleRoute.targets).toEqual(["/settings"]);+ expect(singleRoute.themes).toEqual(["dark", "light"]);++ const shellPlan = resolveTargets(["--shell"]);+ expect(shellPlan.targets).toEqual(SHELL_ROUTES);+ expect(SHELL_ROUTES).toContain("/omnidisc");++ const docShort = resolveTargets(["docs/mcp"]);+ expect(docShort.surface).toBe("docs");+ expect(docShort.targets).toEqual(["docs/mcp/index.html"]);+ expect(docShort.themes).toEqual(["dark", "light"]);++ const allThemes = resolveTargets(["/settings", "--all-themes"]);+ expect(allThemes.surface).toBe("app");+ expect(allThemes.targets).toEqual(["/settings"]);+ expect(allThemes.themes).toEqual(ALL_APP_THEMES);+ expect(ALL_APP_THEMES.length).toBe(14);++ const mockScript = buildTauriMockInitScript("dark");+ expect(mockScript).toContain("omnidisc_connect");+ expect(mockScript).toContain("plugin:courses|courses_list_platforms");+ });++ it("enforces strict zero-findings on docs, baseline diffing on app routes, and per-theme max normalization", async () => {+ const { tallyFindings, compareTargetBaseline } = await import("../../scripts/lint-ui.mjs");++ const sampleFindings = [+ { rule: "control-size", selector: "button.a" },+ { rule: "control-size", selector: "button.b" },+ { rule: "icon-button-tooltip", selector: "button.icon" },+ ];++ const counts = tallyFindings(sampleFindings);+ expect(counts).toEqual({+ "control-size": 2,+ "icon-button-tooltip": 1,+ });++ // Multi-theme findings take the max per rule across themes so --all-themes doesn't falsely multiply layout counts+ const multiThemeFindings = [+ { rule: "control-size", theme: "dark" },+ { rule: "control-size", theme: "dark" },+ { rule: "control-size", theme: "light" },+ { rule: "control-size", theme: "light" },+ { rule: "text-contrast", theme: "eink-sepia" },+ { rule: "text-contrast", theme: "eink-sepia" },+ { rule: "text-contrast", theme: "eink-sepia" },+ ];+ expect(tallyFindings(multiThemeFindings)).toEqual({+ "control-size": 2,+ "text-contrast": 3,+ });++ // App surface: passes if counts <= baseline, fails if any rule count increased+ const appPass = compareTargetBaseline("app", counts, {+ "control-size": 2,+ "icon-button-tooltip": 1,+ });+ expect(appPass.passed).toBe(true);+ expect(appPass.worse).toEqual([]);++ const appRegress = compareTargetBaseline("app", counts, {+ "control-size": 1,+ "icon-button-tooltip": 1,+ });+ expect(appRegress.passed).toBe(false);+ expect(appRegress.worse).toEqual([{ rule: "control-size", was: 1, now: 2 }]);++ // Docs surface: strict zero-findings even if a baseline object was passed+ const docsFail = compareTargetBaseline("docs", counts, {+ "control-size": 5,+ "icon-button-tooltip": 5,+ });+ expect(docsFail.passed).toBe(false);+ expect(docsFail.worse.length).toBe(2);+ });++ it("registers lint:ui and lint:ui:update in package.json and ships scripts/ui-lint-baseline.json", () => {+ const pkg = JSON.parse(fs.readFileSync(path.join(rootDir, "package.json"), "utf-8"));+ expect(pkg.scripts?.["lint:ui"]).toBe("node scripts/lint-ui.mjs");+ expect(pkg.scripts?.["lint:ui:update"]).toBe("node scripts/lint-ui.mjs --update");++ const baselinePath = path.join(rootDir, "scripts", "ui-lint-baseline.json");+ expect(fs.existsSync(baselinePath)).toBe(true);+ const baseline = JSON.parse(fs.readFileSync(baselinePath, "utf-8"));+ expect(typeof baseline.targets).toBe("object");+ });++ it("documents targeted pnpm lint:ui workflow in AGENTS.md and .agents/skills/ui-lint/SKILL.md", () => {+ const agentsMd = fs.readFileSync(path.join(rootDir, "AGENTS.md"), "utf-8");+ expect(agentsMd).toContain("pnpm lint:ui");+ expect(agentsMd).toContain(".agents/skills/ui-lint/SKILL.md");++ const skillPath = path.join(rootDir, ".agents", "skills", "ui-lint", "SKILL.md");+ expect(fs.existsSync(skillPath)).toBe(true);+ const skillMd = fs.readFileSync(skillPath, "utf-8");+ expect(skillMd).toContain("name: ui-lint");+ expect(skillMd).toContain("ui-policy.app.json");+ expect(skillMd).toContain("ui-policy.docs.json");+ });+});+++diff --git a/ui-policy.app.json b/ui-policy.app.jsonnew file mode 100644index 00000000..59306b2f--- /dev/null+++ b/ui-policy.app.json@@ -0,0 +1,101 @@+{+ "fonts": [+ "OmniGet Lao",+ "-apple-system",+ "BlinkMacSystemFont",+ "SF Pro Text",+ "SF Pro Display",+ "SF Pro",+ "system-ui",+ "Segoe UI Variable Display",+ "Segoe UI Variable Text",+ "Segoe UI",+ "sans-serif",+ "ui-monospace",+ "SF Mono",+ "Menlo",+ "Cascadia Mono",+ "Consolas",+ "DejaVu Sans Mono",+ "monospace",+ "Bricolage Grotesque Variable",+ "Bricolage Grotesque",+ "DM Sans",+ "Inter",+ "IBM Plex Mono"+ ],+ "fontSizes": [10, 11, 12, 13, 15, 17, 22, 26, 32, 40],+ "typeRules": [],+ "minControlSize": 28,+ "controlSizeRules": [],+ "minControlGap": 4,+ "minControlInset": 4,+ "controlContainers": ["[data-ui-container]"],+ "minLayoutGap": 4,+ "bannedCopy": [+ "seamlessly",+ "seamless",+ "comprehensive",+ "empowering",+ "half the battle",+ "revolutionize",+ "delve",+ "testament",+ "elevate",+ "comprehensive suite",+ "robust powerhouse",+ "powerhouse",+ "supercharge",+ "cutting-edge",+ "game-changer",+ "unleash",+ "tapestry",+ "multifaceted",+ "unparalleled"+ ],+ "viewports": [+ { "width": 1100, "height": 720 },+ { "width": 800, "height": 560 }+ ],+ "colorSchemes": ["dark", "light"],+ "exceptions": [+ {+ "selector": ".ProseMirror, .ProseMirror *, .tiptap, .tiptap *",+ "rules": [+ "font-family",+ "font-size",+ "control-size",+ "target-size",+ "accessible-name",+ "icon-button-tooltip"+ ],+ "reason": "TipTap rich-text editor internal DOM"+ },+ {+ "selector": ".mermaid, .mermaid *, [data-cy], canvas",+ "rules": [+ "font-family",+ "font-size",+ "text-contrast",+ "accessible-name"+ ],+ "reason": "Third-party diagram and graph canvas internals (Mermaid, Cytoscape)"+ },+ {+ "selector": "media-player, media-player *, .vds-player, .vds-player *",+ "rules": [+ "font-family",+ "font-size",+ "control-size",+ "target-size",+ "icon-button-tooltip"+ ],+ "reason": "Vidstack media player internal controls"+ },+ {+ "selector": "button[aria-label], button[title], a[aria-label], a[title], [role=button][aria-label], [role=button][title]",+ "rules": ["icon-button-tooltip"],+ "reason": "OmniGet uses native aria-label and title attributes on icon buttons; accessible-name rule enforces labeling"+ }+ ]+}diff --git a/ui-policy.docs.json b/ui-policy.docs.jsonnew file mode 100644index 00000000..b2fe5e0d--- /dev/null+++ b/ui-policy.docs.json@@ -0,0 +1,73 @@+{+ "fonts": [+ "Geist",+ "Geist Mono",+ "-apple-system",+ "BlinkMacSystemFont",+ "Segoe UI Variable Text",+ "Segoe UI Variable Display",+ "Segoe UI",+ "system-ui",+ "sans-serif",+ "ui-monospace",+ "SF Mono",+ "Menlo",+ "Consolas",+ "monospace"+ ],+ "fontSizes": [+ 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15, 15.5, 16,+ 16.5, 17, 17.5, 18, 19, 20, 21, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40,+ 42, 44, 48, 52, 56, 60, 64, 67.2+ ],+ "typeRules": [],+ "minControlSize": 24,+ "controlSizeRules": [],+ "minControlGap": 4,+ "minControlInset": 4,+ "controlContainers": ["[data-ui-container]"],+ "minLayoutGap": 4,+ "bannedCopy": [+ "seamlessly",+ "seamless",+ "comprehensive",+ "empowering",+ "half the battle",+ "revolutionize",+ "delve",+ "testament",+ "elevate",+ "comprehensive suite",+ "robust powerhouse",+ "powerhouse",+ "supercharge",+ "cutting-edge",+ "game-changer",+ "unleash",+ "tapestry",+ "multifaceted",+ "unparalleled"+ ],+ "viewports": [+ { "width": 1280, "height": 800 },+ { "width": 375, "height": 812 }+ ],+ "colorSchemes": ["dark", "light"],+ "exceptions": [+ {+ "selector": "html",+ "rules": ["root-background"],+ "reason": "Docs and landing pages set the active theme background color on body"+ },+ {+ "selector": "aside, .sidebar, .mobile-menu",+ "rules": ["viewport-bounds"],+ "reason": "Off-canvas navigation drawer is translated outside the horizontal viewport when closed on mobile"+ },+ {+ "selector": "button[aria-label], button[title], a[aria-label], a[title], [role=button][aria-label], [role=button][title]",+ "rules": ["icon-button-tooltip"],+ "reason": "Docs and landing pages use aria-label and title on icon controls; accessible-name enforces labeling"+ }+ ]+}