refscout.mjs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. #!/usr/bin/env node
  2. /**
  3. * refscout.mjs — reference scouting: find live award-level sites, then take them apart.
  4. *
  5. * Usage:
  6. * node scripts/refscout.mjs <url> [<url>...] analyse specific sites
  7. * node scripts/refscout.mjs --from awwwards harvest the current gallery
  8. * node scripts/refscout.mjs --from awwwards:scrolling --limit 6
  9. * node scripts/refscout.mjs --from awwwards --search "coffee brand" --limit 5
  10. *
  11. * Options:
  12. * --limit N how many sites (default 6, hard cap 15)
  13. * --out DIR output dir (default design/refs)
  14. * --shots N screenshots per site (default 3: hero + 2 scroll stops)
  15. * --no-shots fingerprint only, no browser screenshots
  16. * --width N viewport width for shots (default 1440)
  17. *
  18. * Writes DIR/REFERENCES.md (read this), DIR/refs.json, DIR/shots/*.png.
  19. * Exits 0 if at least one site was profiled, 1 otherwise.
  20. */
  21. import { mkdir, writeFile } from 'fs/promises';
  22. import { resolve, join } from 'path';
  23. const args = process.argv.slice(2);
  24. if (!args.length || args.includes('--help')) {
  25. console.log(`refscout.mjs — scout live website references and fingerprint their mechanics
  26. node scripts/refscout.mjs <url> [<url>...]
  27. node scripts/refscout.mjs --from awwwards[:<tag>] [--search "<text>"] [--limit 6]
  28. --limit N --out DIR --shots N --no-shots --width N`);
  29. process.exit(0);
  30. }
  31. const get = (f, d) => { const i = args.indexOf(f); return i !== -1 ? args[i + 1] : d; };
  32. const has = f => args.includes(f);
  33. const limit = Math.min(parseInt(get('--limit', '6'), 10) || 6, 15);
  34. const outDir = resolve(get('--out', 'design/refs'));
  35. const shotsN = has('--no-shots') ? 0 : (parseInt(get('--shots', '3'), 10) || 3);
  36. const width = parseInt(get('--width', '1440'), 10) || 1440;
  37. const from = get('--from', null);
  38. const search = get('--search', null);
  39. const urls = args.filter(a => /^https?:\/\//.test(a));
  40. let chromium;
  41. try { ({ chromium } = await import('playwright')); }
  42. catch { console.error('playwright not found. Install: npm i -D playwright && npx playwright install chromium'); process.exit(2); }
  43. const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
  44. /**
  45. * Award-level sites are heavy streaming-SSR / WebGL pages: 'load' and 'networkidle'
  46. * frequently never fire. Commit + a timed settle is the only navigation that survives them.
  47. * Returns false when DOMContentLoaded never fired — those pages need freeze() before capture.
  48. */
  49. async function open(page, url, settle = 7000, onStatus) {
  50. const resp = await page.goto(url, { waitUntil: 'commit', timeout: 30_000 });
  51. onStatus?.(resp?.status?.() ?? 0);
  52. const dcl = await page.waitForLoadState('domcontentloaded', { timeout: 12_000 }).then(() => true).catch(() => false);
  53. await page.waitForTimeout(dcl ? settle : settle + 5000); // no DCL → give hydration longer
  54. return dcl;
  55. }
  56. /**
  57. * A page whose HTML stream never closes never yields a compositor frame either, so every
  58. * screenshot on it times out (measured on basement.studio and lusion.co). `window.stop()`
  59. * ends the stream and capture drops to ~40ms. Call it only AFTER the settle wait — stopping
  60. * early aborts the CSS/JS the fingerprint needs and leaves you reading Times-New-Roman
  61. * defaults off a half-loaded page.
  62. */
  63. async function freeze(page, dcl) {
  64. if (!dcl) await page.evaluate(() => window.stop()).catch(() => {});
  65. }
  66. // --- library signatures, matched against the concatenated JS the page actually loaded ---
  67. // Bundlers hide globals (window.gsap is empty on virtually every modern site), but
  68. // minifiers keep string literals and class names, so the bundle text still tells the truth.
  69. const LIBS = [
  70. ['GSAP', /gsap\.registerPlugin|GreenSock|_gsap|gsap\.timeline|gsap\.to\(/],
  71. ['ScrollTrigger', /ScrollTrigger/],
  72. ['ScrollSmoother', /ScrollSmoother/],
  73. ['SplitText', /SplitText|SplitType/],
  74. ['Lenis', /\blenis\b|new Lenis|lenis-smooth/i],
  75. ['Locomotive', /locomotive-scroll|LocomotiveScroll|has-scroll-smooth/],
  76. ['three.js', /THREE\.WebGLRenderer|WebGLRenderer|three\.module|\bTHREE\b/],
  77. ['R3F', /react-three|@react-three\/fiber|useFrame/],
  78. ['OGL', /\bogl\b|new Renderer\(\{.*dpr/],
  79. ['PixiJS', /PIXI\.|pixi\.js/],
  80. ['Framer Motion', /framer-motion|motion-dom|framerAppearId/],
  81. ['Motion One', /@motionone|motion\.dev/],
  82. ['Barba', /barba\.init|@barba|new Barba/],
  83. ['Swup', /new Swup|@swup/],
  84. ['Matter.js', /Matter\.Engine/],
  85. ['Rive', /@rive-app|rive\.wasm/],
  86. ['Lottie', /lottie-web|bodymovin/],
  87. ['Spline', /splinetool|spline-viewer/],
  88. ['Theatre.js', /@theatre\/core/],
  89. ['Swiper', /new Swiper|swiper-bundle/],
  90. ['Splitting', /Splitting\(/],
  91. ];
  92. function classifyPeak(f) {
  93. const out = [];
  94. if (f.videos.some(v => !v.autoplay && v.preload !== 'none') && f.scrollRatio > 4) out.push('likely scroll-scrubbed video');
  95. if (f.webgl && f.scrollRatio > 3) out.push('WebGL scene driven by scroll');
  96. else if (f.webgl) out.push('WebGL hero');
  97. if (f.pinSpacers > 0) out.push(`${f.pinSpacers} pinned scene(s) (GSAP ScrollTrigger)`);
  98. if (f.stickies > 2) out.push(`${f.stickies} sticky layers (stack/pin effect)`);
  99. if (f.cssTimeline) out.push('CSS scroll-driven animations (animation-timeline)');
  100. if (f.libs.includes('Lenis') || f.libs.includes('Locomotive') || f.libs.includes('ScrollSmoother')) out.push('smoothed/virtualised scroll');
  101. if (f.mixBlend > 0) out.push(`${f.mixBlend} mix-blend-mode layer(s)`);
  102. if (f.cursorNone) out.push('custom cursor');
  103. if (f.videos.length && !out.length) out.push('looping video texture');
  104. return out;
  105. }
  106. async function fingerprint(ctx, url) {
  107. const page = await ctx.newPage();
  108. const js = [];
  109. let jsBytes = 0;
  110. page.on('response', async res => {
  111. if (jsBytes > 4_000_000) return;
  112. const ct = res.headers()['content-type'] || '';
  113. if (!/javascript|ecmascript/.test(ct)) return;
  114. try { const t = await res.text(); jsBytes += t.length; js.push(t); } catch {}
  115. });
  116. let httpStatus = 0;
  117. try {
  118. const dcl = await open(page, url, 8000, s => { httpStatus = s; });
  119. // one scroll pass so pinning / lazy scenes actually initialise before we look
  120. await page.evaluate(() => window.scrollTo({ top: innerHeight * 1.6, behavior: 'instant' }));
  121. await page.waitForTimeout(2500);
  122. const dom = await page.evaluate(() => {
  123. const cs = getComputedStyle;
  124. // A blocked / challenge / download navigation can leave us with no body at all.
  125. // Bail with an explicitly empty reading rather than throwing away the whole site.
  126. if (!document.body) return { title: (document.title || '').slice(0, 90), sheets: 0, readyState: document.readyState, globals: [], htmlClass: '', pinSpacers: 0, stickies: 0, canvases: 0, webgl: false, videos: [], mixBlend: 0, cursorNone: false, cssTimeline: false, fontFaces: [], display: null, bodyFont: '', bg: '', palette: [], sections: 0, scrollH: 0, vh: window.innerHeight, framework: 'unknown' };
  127. const all = [...document.querySelectorAll('*')].slice(0, 4000);
  128. const canvases = [...document.querySelectorAll('canvas')];
  129. let cssTimeline = false;
  130. const faces = new Set();
  131. for (const ss of document.styleSheets) {
  132. try {
  133. for (const r of ss.cssRules) {
  134. const t = r.cssText || '';
  135. if (t.includes('animation-timeline') || t.includes('view-timeline')) cssTimeline = true;
  136. if (r.style && r.constructor.name === 'CSSFontFaceRule') faces.add((r.style.fontFamily || '').replace(/["']/g, ''));
  137. }
  138. } catch {}
  139. }
  140. // Chromium reports modern colour syntaxes verbatim (`lab(48.5 0 0)`, `oklch(...)`), which is
  141. // unreadable as a palette. Round-trip every value through a canvas so the report shows a
  142. // colour a human can picture, keeping the original alongside.
  143. const cx = document.createElement('canvas').getContext('2d', { willReadFrequently: true });
  144. const toHex = v => {
  145. try {
  146. cx.clearRect(0, 0, 1, 1); cx.fillStyle = '#000'; cx.fillStyle = v;
  147. cx.fillRect(0, 0, 1, 1);
  148. const [r, g, b, a] = cx.getImageData(0, 0, 1, 1).data;
  149. const hex = '#' + [r, g, b].map(n => n.toString(16).padStart(2, '0')).join('');
  150. return a < 250 ? `${hex}@${(a / 255).toFixed(2)}` : hex;
  151. } catch { return null; }
  152. };
  153. // sample the real palette from what is painted, not from the token file
  154. const colors = {};
  155. for (const el of all) {
  156. const s = cs(el);
  157. for (const c of [s.backgroundColor, s.color]) {
  158. if (!c || c === 'rgba(0, 0, 0, 0)') continue;
  159. colors[c] = (colors[c] || 0) + 1;
  160. }
  161. }
  162. const palette = Object.entries(colors).sort((a, b) => b[1] - a[1]).slice(0, 6).map(([c, n]) => {
  163. const hex = toHex(c);
  164. return hex && !/^(#|rgb)/.test(c) ? `${hex} (${c}) ×${n}` : `${hex || c} ×${n}`;
  165. });
  166. // The display face is the biggest thing actually painted, not the first h1 — a hidden or
  167. // fallback-styled heading reports whatever the CSS cascade left there and will happily
  168. // claim an awwwards winner ships Inter. Measure instead: largest visible rendered text.
  169. let display = null, bestPx = 0;
  170. for (const e of all) {
  171. if (e.children.length || (e.textContent || '').trim().length < 2) continue;
  172. const s = cs(e);
  173. if (s.visibility === 'hidden' || s.display === 'none' || +s.opacity === 0) continue;
  174. const r = e.getBoundingClientRect();
  175. if (r.width < 4 || r.height < 4) continue;
  176. const px = parseFloat(s.fontSize) || 0;
  177. if (px > bestPx) { bestPx = px; display = { font: s.fontFamily.slice(0, 60), px: Math.round(px), weight: s.fontWeight, sample: e.textContent.trim().replace(/\s+/g, ' ').slice(0, 28) }; }
  178. }
  179. return {
  180. title: (document.title || '').slice(0, 90),
  181. sheets: document.styleSheets.length,
  182. readyState: document.readyState,
  183. globals: ['gsap', 'ScrollTrigger', 'Lenis', 'THREE', 'locomotiveScroll', 'barba', 'Swup', 'PIXI'].filter(k => k in window),
  184. htmlClass: document.documentElement.className.slice(0, 100),
  185. pinSpacers: document.querySelectorAll('.pin-spacer').length,
  186. stickies: all.filter(e => cs(e).position === 'sticky').length,
  187. canvases: canvases.length,
  188. webgl: canvases.some(c => { try { return !!(c.getContext('webgl2') || c.getContext('webgl')); } catch { return false; } }),
  189. videos: [...document.querySelectorAll('video')].slice(0, 4).map(v => ({
  190. autoplay: v.autoplay, loop: v.loop, muted: v.muted, preload: v.preload,
  191. src: (v.currentSrc || v.src || '').split('/').pop().slice(0, 40),
  192. })),
  193. mixBlend: all.filter(e => cs(e).mixBlendMode !== 'normal').length,
  194. cursorNone: cs(document.body).cursor === 'none',
  195. cssTimeline,
  196. fontFaces: [...faces].filter(Boolean).slice(0, 8),
  197. display,
  198. bodyFont: cs(document.body).fontFamily.slice(0, 70),
  199. bg: cs(document.body).backgroundColor,
  200. palette,
  201. sections: document.querySelectorAll('section, main > div, [class*="section"]').length,
  202. scrollH: document.documentElement.scrollHeight,
  203. vh: window.innerHeight,
  204. framework:
  205. document.querySelector('[data-framer-name],[data-framer-root]') ? 'Framer' :
  206. document.querySelector('[data-wf-page]') ? 'Webflow' :
  207. document.querySelector('#__next,[id^=__next]') ? 'Next.js' :
  208. document.querySelector('astro-island,[data-astro-cid]') ? 'Astro' :
  209. document.querySelector('[data-sveltekit-preload-data]') ? 'SvelteKit' :
  210. document.querySelector('#app,[data-v-app]') ? 'Vue/Nuxt' :
  211. document.querySelector('[data-shopify],[id^=shopify]') ? 'Shopify' : 'unknown',
  212. };
  213. });
  214. const blob = js.join('\n');
  215. const libs = LIBS.filter(([, re]) => re.test(blob)).map(([n]) => n);
  216. for (const g of dom.globals) if (!libs.some(l => l.toLowerCase().includes(g.toLowerCase().slice(0, 5)))) libs.push(`${g} (global)`);
  217. const f = { url, ...dom, libs, jsBytes, scrollRatio: +(dom.scrollH / Math.max(dom.vh, 1)).toFixed(1) };
  218. f.mechanics = classifyPeak(f);
  219. // Some sites (Vercel-edge streamers, bot-walled studios) hand a headless client the SSR
  220. // HTML and then never deliver CSS or JS. Everything we'd read off that page — fonts,
  221. // palette, libs — is browser default, i.e. a confident lie. Detect it and say so.
  222. // Chrome's unstyled body is Times New Roman with zero web fonts loaded; a real site that
  223. // merely leaves body at the default still has @font-face rules from its stylesheet.
  224. const unstyled = /^"?Times New Roman/.test(dom.bodyFont) && !dom.fontFaces.length;
  225. // An error page has a title, a palette and a page shape, and will happily be written up as a
  226. // reference with a blank `steal:` line waiting to be filled. It is not a design.
  227. f.httpStatus = httpStatus;
  228. f.errorPage = httpStatus >= 400 || /^\s*(4\d\d|5\d\d)|bad gateway|not found|forbidden|service unavailable|internal server error/i.test(dom.title || '');
  229. f.thin = dom.sheets === 0 || unstyled || f.errorPage;
  230. // Screenshots are best-effort on purpose: a capture that fails must never throw away
  231. // a fingerprint we already paid for.
  232. f.shots = [];
  233. // A site that never got its CSS has nothing to photograph: take one frame as evidence the
  234. // capture failed, not a full journey of identical unstyled pages.
  235. const n = f.thin ? Math.min(1, shotsN) : shotsN;
  236. if (n > 0) {
  237. await freeze(page, dcl);
  238. const slug = url.replace(/^https?:\/\//, '').replace(/[^\w.-]+/g, '_').slice(0, 40);
  239. const max = Math.max(0, dom.scrollH - dom.vh);
  240. for (let i = 0; i < n; i++) {
  241. const y = n === 1 ? 0 : Math.round((i / (n - 1)) * max);
  242. const name = `${slug}-${String(i).padStart(2, '0')}.png`;
  243. try {
  244. await page.evaluate(t => window.scrollTo({ top: t, behavior: 'instant' }), y);
  245. await page.waitForTimeout(1600);
  246. await page.screenshot({ path: join(outDir, 'shots', name), timeout: 20_000 });
  247. f.shots.push(`shots/${name}`);
  248. } catch (e) {
  249. (f.shotErrors ??= []).push(`stop ${i}: ${e.message.split('\n')[0]}`);
  250. }
  251. }
  252. f.shotsWanted = n;
  253. }
  254. return f;
  255. } catch (e) {
  256. return { url, error: e.message.split('\n')[0] };
  257. } finally {
  258. await page.close();
  259. }
  260. }
  261. // --- gallery harvesting -------------------------------------------------------
  262. // awwwards is the one gallery whose listing AND detail pages both render reliably headless
  263. // and expose the outbound site URL. Other galleries either need JS we can't wait out or bury
  264. // the real URL behind affiliate redirects — for those, find URLs with web_search and pass them
  265. // positionally.
  266. async function harvestAwwwards(ctx, tag, text, n) {
  267. const page = await ctx.newPage();
  268. const base = 'https://www.awwwards.com/websites/';
  269. const url = text ? `${base}?text=${encodeURIComponent(text)}` : tag ? `${base}${tag}/` : base;
  270. const found = [];
  271. try {
  272. await open(page, url, 6000);
  273. const slugs = await page.evaluate(() =>
  274. [...new Set([...document.querySelectorAll('a[href*="/sites/"]')].map(a => a.getAttribute('href')).filter(h => h && h.startsWith('/sites/')))]);
  275. if (!slugs.length) console.error(`[refscout] awwwards listing returned no cards for ${url}`);
  276. for (const slug of slugs.slice(0, n)) {
  277. try {
  278. await open(page, 'https://www.awwwards.com' + slug, 3500);
  279. const d = await page.evaluate(() => {
  280. const visit = [...document.querySelectorAll('a[href^="http"]')]
  281. .find(a => /visit site/i.test(a.innerText) || /button/.test(a.className));
  282. const ext = visit?.href || [...document.querySelectorAll('a[href^="http"]')]
  283. .map(a => a.href).find(h => !/awwwards|twitter|x\.com|facebook|instagram|linkedin|behance|dribbble/i.test(h));
  284. return {
  285. site: ext,
  286. name: (document.querySelector('h1')?.innerText || document.title).trim().slice(0, 60),
  287. };
  288. });
  289. if (d.site) found.push({ ...d, via: 'awwwards' + slug });
  290. } catch {}
  291. }
  292. } catch (e) {
  293. console.error(`[refscout] awwwards harvest failed: ${e.message.split('\n')[0]}`);
  294. } finally { await page.close(); }
  295. return found;
  296. }
  297. // --- run ----------------------------------------------------------------------
  298. await mkdir(join(outDir, 'shots'), { recursive: true });
  299. const browser = await chromium.launch({ headless: true });
  300. const ctx = await browser.newContext({ userAgent: UA, viewport: { width, height: 900 }, ignoreHTTPSErrors: true });
  301. let targets = urls.map(u => ({ site: u, name: null, via: 'direct' }));
  302. if (from) {
  303. const [gallery, tag] = from.split(':');
  304. if (gallery === 'awwwards') targets = targets.concat(await harvestAwwwards(ctx, tag, search, limit));
  305. else console.error(`[refscout] unknown gallery "${gallery}" — supported: awwwards. Pass URLs directly instead (find them with web_search).`);
  306. }
  307. targets = targets.slice(0, limit);
  308. if (!targets.length) {
  309. console.error('[refscout] no targets. Pass URLs, or --from awwwards.');
  310. await browser.close();
  311. process.exit(1);
  312. }
  313. const results = [];
  314. for (const t of targets) {
  315. process.stderr.write(`[refscout] profiling ${t.site} …\n`);
  316. const f = await fingerprint(ctx, t.site);
  317. results.push({ ...t, ...f });
  318. }
  319. await browser.close();
  320. // --- report -------------------------------------------------------------------
  321. const ok = results.filter(r => !r.error);
  322. const lines = [];
  323. lines.push('# REFERENCES — scouted ' + new Date().toISOString().slice(0, 10));
  324. lines.push('');
  325. lines.push('Mechanics, not skins. For each reference name the ONE idea you are taking and how it');
  326. lines.push('changes for this brand. Copying a reference wholesale is slop with better taste.');
  327. lines.push('');
  328. lines.push('| # | site | stack detected | page shape | mechanics |');
  329. lines.push('|---|---|---|---|---|');
  330. ok.forEach((r, i) => {
  331. const cell = r.errorPage ? '_error page — not a design_' : r.thin ? '_no capture — see below_' : null;
  332. lines.push(`| ${i + 1} | [${r.name || r.url.replace(/^https?:\/\//, '')}](${r.url}) | ${cell ?? (r.libs.slice(0, 4).join(', ') || '—')} | ${cell ?? `${r.scrollRatio}× vh, ${r.sections} sections`} | ${cell ?? (r.mechanics.slice(0, 3).join('; ') || '—')} |`);
  333. });
  334. lines.push('');
  335. ok.forEach((r, i) => {
  336. lines.push(`## ${i + 1}. ${r.name || r.title || r.url}`);
  337. lines.push(`- url: ${r.url}${r.via && r.via !== 'direct' ? ` · via ${r.via}` : ''}`);
  338. if (r.errorPage) {
  339. lines.push(`- ⚠ **NOT A DESIGN** — this URL returned an error page${r.httpStatus >= 400 ? ` (HTTP ${r.httpStatus})` : ''}, title "${r.title}". Nothing here is a reference. Drop it, or find the site's real address.`);
  340. lines.push('');
  341. return;
  342. }
  343. if (r.thin) {
  344. lines.push(`- ⚠ **NO CAPTURE** — this site served the headless browser bare HTML and never delivered its CSS/JS (${r.sheets} stylesheets, readyState \`${r.readyState}\`). Any font, colour or stack reading here would be the browser's defaults, so none is reported. Open the URL yourself, or describe it from the gallery write-up — and check the page title above, a dead link from the gallery lands here too.`);
  345. if (r.shots.length) lines.push(`- unstyled shots (evidence that the capture failed, not a look at the design): ${r.shots.map(s => `\`${s}\``).join(' ')}`);
  346. lines.push('');
  347. return;
  348. }
  349. lines.push(`- stack: ${r.libs.join(', ') || 'nothing detected'}${r.framework !== 'unknown' ? ` · built with ${r.framework}` : ''}`);
  350. lines.push(`- mechanics: ${r.mechanics.join('; ') || '—'}`);
  351. lines.push(`- page: ${r.scrollRatio}× viewport tall · ${r.sections} sections · ${r.canvases} canvas${r.webgl ? ' (WebGL live)' : ''} · ${r.videos.length} video`);
  352. lines.push(`- type: display \`${r.display ? `${r.display.font} ${r.display.px}px/${r.display.weight}` : '?'}\`${r.display ? ` (largest painted text: "${r.display.sample}")` : ''} · body \`${r.bodyFont}\`${r.fontFaces.length ? ` · @font-face: ${r.fontFaces.join(', ')}` : ''}`);
  353. lines.push(`- palette (most painted): ${r.palette.join(' · ')}`);
  354. if (r.shots.length) lines.push(`- shots: ${r.shots.map(s => `\`${s}\``).join(' ')} ← look at the hero; look at the rest only if you take a steal from this one`);
  355. if (r.shotErrors?.length) lines.push(`- ⚠ ${r.shotErrors.length} of ${r.shotsWanted} shots failed (${r.shotErrors.join('; ')}) — the fingerprint above still holds.`);
  356. lines.push('- **steal:** _<one mechanic, one line — fill this in>_');
  357. lines.push('');
  358. });
  359. const failed = results.filter(r => r.error);
  360. if (failed.length) {
  361. lines.push('## Not reached');
  362. failed.forEach(r => lines.push(`- ${r.url} — ${r.error}`));
  363. lines.push('');
  364. }
  365. await writeFile(join(outDir, 'REFERENCES.md'), lines.join('\n'), 'utf8');
  366. await writeFile(join(outDir, 'refs.json'), JSON.stringify(results, null, 2), 'utf8');
  367. console.log(`\n=== refscout ===`);
  368. console.log(`profiled : ${ok.filter(r => !r.thin).length}/${results.length} usable`);
  369. if (ok.some(r => r.thin)) console.log(`no-css : ${ok.filter(r => r.thin).length} (site withheld CSS/JS from headless — reported as unknown, not guessed)`);
  370. if (failed.length) console.log(`failed : ${failed.length} — ${failed.map(r => r.url).join(', ')}`);
  371. const lostShots = ok.reduce((n, r) => n + (r.shotErrors?.length || 0), 0);
  372. if (lostShots) console.log(`shots : ${lostShots} capture(s) failed — flagged per site in the report`);
  373. console.log(`report : ${join(outDir, 'REFERENCES.md')}`);
  374. console.log(`shots : ${ok.reduce((n, r) => n + r.shots.length, 0)} in ${join(outDir, 'shots')}`);
  375. process.exit(ok.length ? 0 : 1);