sugikit 0.0.1 → 0.1.0

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.
Files changed (72) hide show
  1. package/LICENSE +29 -21
  2. package/README.md +45 -0
  3. package/dist/api/browser.d.ts +5 -0
  4. package/dist/api/browser.js +5 -0
  5. package/dist/api/rules.d.ts +12 -0
  6. package/dist/api/rules.js +14 -0
  7. package/dist/auth.d.ts +156 -0
  8. package/dist/auth.js +547 -0
  9. package/dist/browser.d.ts +25 -0
  10. package/dist/browser.js +120 -0
  11. package/dist/check.d.ts +21 -0
  12. package/dist/check.js +89 -0
  13. package/dist/convert-probe.d.ts +21 -0
  14. package/dist/convert-probe.js +647 -0
  15. package/dist/fetch.d.ts +6 -0
  16. package/dist/fetch.js +22 -0
  17. package/dist/framework.d.ts +2 -0
  18. package/dist/framework.js +17 -0
  19. package/dist/gather.d.ts +48 -0
  20. package/dist/gather.js +211 -0
  21. package/dist/html.d.ts +17 -0
  22. package/dist/html.js +43 -0
  23. package/dist/http.d.ts +36 -0
  24. package/dist/http.js +57 -0
  25. package/dist/index.d.ts +2 -0
  26. package/dist/index.js +331 -0
  27. package/dist/links.d.ts +8 -0
  28. package/dist/links.js +69 -0
  29. package/dist/polish-run.d.ts +115 -0
  30. package/dist/polish-run.js +357 -0
  31. package/dist/probe.d.ts +14 -0
  32. package/dist/probe.js +457 -0
  33. package/dist/psi-scores.d.ts +4 -0
  34. package/dist/psi-scores.js +7 -0
  35. package/dist/psi.d.ts +56 -0
  36. package/dist/psi.js +192 -0
  37. package/dist/release.d.ts +1 -0
  38. package/dist/release.js +5 -0
  39. package/dist/render.d.ts +28 -0
  40. package/dist/render.js +270 -0
  41. package/dist/report.d.ts +227 -0
  42. package/dist/report.js +69 -0
  43. package/dist/rules/convert-render.d.ts +100 -0
  44. package/dist/rules/convert-render.js +279 -0
  45. package/dist/rules/convert.d.ts +15 -0
  46. package/dist/rules/convert.js +322 -0
  47. package/dist/rules/fixes.d.ts +16 -0
  48. package/dist/rules/fixes.js +536 -0
  49. package/dist/rules/geo.d.ts +15 -0
  50. package/dist/rules/geo.js +112 -0
  51. package/dist/rules/polish.d.ts +59 -0
  52. package/dist/rules/polish.js +223 -0
  53. package/dist/rules/robots.d.ts +14 -0
  54. package/dist/rules/robots.js +69 -0
  55. package/dist/rules/seo.d.ts +31 -0
  56. package/dist/rules/seo.js +208 -0
  57. package/dist/rules/types.d.ts +55 -0
  58. package/dist/rules/types.js +78 -0
  59. package/dist/score.d.ts +6 -0
  60. package/dist/score.js +23 -0
  61. package/dist/skills.d.ts +9 -0
  62. package/dist/skills.js +22 -0
  63. package/package.json +64 -4
  64. package/skills/INSTALL_PROMPT.md +9 -0
  65. package/skills/sugikit/SKILL.md +147 -0
  66. package/skills/sugikit/references/convert.md +127 -0
  67. package/skills/sugikit/references/geo.md +97 -0
  68. package/skills/sugikit/references/next.md +254 -0
  69. package/skills/sugikit/references/pagespeed.md +94 -0
  70. package/skills/sugikit/references/polish.md +123 -0
  71. package/skills/sugikit/references/seo.md +150 -0
  72. package/skills/sugikit/references/tanstack-start.md +246 -0
@@ -0,0 +1,21 @@
1
+ import { resolveSitemap as resolveSitemapWith, type GatherOptions } from "./gather.js";
2
+ import { type PsiOptions } from "./psi.js";
3
+ import type { Framework, PageType, Report } from "./report.js";
4
+ import { type TextResource } from "./rules/types.js";
5
+ export { httpStatusResult, runRules, toFinding } from "./gather.js";
6
+ export interface CheckOptions {
7
+ projectDir?: string;
8
+ browser?: boolean;
9
+ outDir?: string;
10
+ shotsDir?: string;
11
+ psi?: boolean | PsiOptions;
12
+ isLocalRun?: (pageUrl: string) => boolean;
13
+ pageType?: PageType;
14
+ budgetSeconds?: number;
15
+ }
16
+ export declare const DEFAULT_BUDGET_SECONDS = 120;
17
+ export declare const DEFAULT_SHOTS_DIR = "report-shots";
18
+ export declare function shotsDirFor(reportPath: string): string;
19
+ export declare function resolveSitemap(robots: TextResource | undefined, pageUrl: string, framework?: Framework, options?: Pick<GatherOptions, "isLocalRun">): ReturnType<typeof resolveSitemapWith>;
20
+ export declare function runStaticChecks(url: string, options?: CheckOptions): Promise<Report>;
21
+ export declare function runChecks(url: string, options?: CheckOptions): Promise<Report>;
package/dist/check.js ADDED
@@ -0,0 +1,89 @@
1
+ import { basename, extname } from "node:path";
2
+ import { fetchWithBrowser, launchBrowser, runBrowserChecks } from "./browser.js";
3
+ import { cliFetch, fetchText, isBlockedResponse, isChallengePage } from "./fetch.js";
4
+ import { detectFramework } from "./framework.js";
5
+ import { gatherPage, isPageError, resolveSitemap as resolveSitemapWith, runStaticRules, toReport, } from "./gather.js";
6
+ import { runPsi } from "./psi.js";
7
+ import { verifyPricingLink } from "./rules/convert.js";
8
+ import { heroLcpResult } from "./rules/convert-render.js";
9
+ import { result } from "./rules/types.js";
10
+ export { httpStatusResult, runRules, toFinding } from "./gather.js";
11
+ export const DEFAULT_BUDGET_SECONDS = 120;
12
+ export const DEFAULT_SHOTS_DIR = "report-shots";
13
+ export function shotsDirFor(reportPath) {
14
+ return `${basename(reportPath, extname(reportPath))}-shots`;
15
+ }
16
+ export function resolveSitemap(robots, pageUrl, framework = "unknown", options = {}) {
17
+ return resolveSitemapWith(robots, pageUrl, framework, { fetch: cliFetch, ...options });
18
+ }
19
+ function fetchBlockedResult(blocked, url) {
20
+ const got = isChallengePage(blocked.body) ? `a bot challenge page (HTTP ${blocked.status})` : `HTTP ${blocked.status}`;
21
+ return result("seo/fetch-blocked", "info", false, `The plain HTTP request got ${got}; checked the page through the browser instead. Search and AI crawlers may be blocked the same way.`, { url });
22
+ }
23
+ // Bot protection often blocks a plain request but lets a real browser through. Retry in the browser then.
24
+ // A browser error never fails the run: the plain fetch result stands and the browser is closed.
25
+ async function unblockPage(page, url, options) {
26
+ if (options.browser === false || !isBlockedResponse(page))
27
+ return { page };
28
+ const launched = await launchBrowser();
29
+ if ("error" in launched)
30
+ return { page };
31
+ try {
32
+ const viaBrowser = await fetchWithBrowser(launched.browser, url);
33
+ if (!viaBrowser || isBlockedResponse(viaBrowser))
34
+ return { page, browser: launched.browser };
35
+ return { page: viaBrowser, browser: launched.browser, note: fetchBlockedResult(page, viaBrowser.finalUrl) };
36
+ }
37
+ catch {
38
+ await launched.browser.close().catch(() => undefined);
39
+ return { page };
40
+ }
41
+ }
42
+ export async function runStaticChecks(url, options = {}) {
43
+ return runChecks(url, { ...options, browser: false });
44
+ }
45
+ export async function runChecks(url, options = {}) {
46
+ const startedAt = new Date().toISOString();
47
+ const seconds = options.budgetSeconds ?? DEFAULT_BUDGET_SECONDS;
48
+ const budget = { seconds, deadline: Date.now() + seconds * 1000 };
49
+ const frameworkPromise = detectFramework(options.projectDir ?? process.cwd());
50
+ const unblocked = await unblockPage(await fetchText(url), url, options);
51
+ try {
52
+ return await checkPage(url, options, startedAt, frameworkPromise, unblocked.page, unblocked.browser, unblocked.note, budget);
53
+ }
54
+ finally {
55
+ await unblocked.browser?.close();
56
+ }
57
+ }
58
+ async function checkPage(url, options, startedAt, frameworkPromise, page, sharedBrowser, blockedNote, budget) {
59
+ const psiOptions = options.psi === true ? {} : options.psi || undefined;
60
+ const psiPromise = psiOptions
61
+ ? frameworkPromise.then((framework) => runPsi(url, { framework, ...psiOptions }))
62
+ : undefined;
63
+ const ctx = await gatherPage(url, {
64
+ fetch: cliFetch,
65
+ framework: frameworkPromise,
66
+ page,
67
+ ...(options.isLocalRun ? { isLocalRun: options.isLocalRun } : {}),
68
+ ...(options.pageType ? { pageType: options.pageType } : {}),
69
+ });
70
+ const shots = options.outDir ? { outDir: options.outDir, dir: options.shotsDir ?? DEFAULT_SHOTS_DIR } : undefined;
71
+ const browser = options.browser === false || isPageError(ctx) ? undefined : await runBrowserChecks(ctx.url, shots, sharedBrowser, options.isLocalRun?.(ctx.url), budget);
72
+ const psi = psiPromise ? await psiPromise : undefined;
73
+ const convert = browser?.convert;
74
+ const staticResults = await Promise.all(runStaticRules(ctx, { notes: blockedNote ? [blockedNote] : [] }).map((item) => convert ? verifyPricingLink(ctx, item, cliFetch, convert.hero["desktop-light"]?.price) : item));
75
+ // PageSpeed mobile LCP (field, else lab) replaces the local lab timing in convert/hero-lcp.
76
+ const browserResults = (browser?.results ?? []).map((item) => convert && psi?.lcp && item.id === "convert/hero-lcp" ? heroLcpResult(convert.lcp, convert.local, psi.lcp) : item);
77
+ const results = [...staticResults, ...browserResults, ...(psi?.results ?? [])];
78
+ return toReport({
79
+ target: url,
80
+ url: ctx.url,
81
+ framework: ctx.framework,
82
+ ...(ctx.pageType ? { pageType: ctx.pageType } : {}),
83
+ startedAt,
84
+ results,
85
+ ...(psi?.pagespeed ? { pagespeed: psi.pagespeed } : {}),
86
+ ...(browser?.states ? { states: browser.states } : {}),
87
+ ...(browser?.screenshots ? { screenshots: browser.screenshots } : {}),
88
+ });
89
+ }
@@ -0,0 +1,21 @@
1
+ import type { HeroProbe, LcpProbe, OverlayHit } from "./rules/convert-render.js";
2
+ export declare function heroProbe(): HeroProbe;
3
+ export declare function overlayProbe(): OverlayHit[];
4
+ export declare function sinceLoad(): number;
5
+ export declare function lcpProbe(): Promise<LcpProbe | undefined>;
6
+ export declare function guardSubmits(): void;
7
+ export declare const CLICK_BASELINE_MS = 1000;
8
+ export declare function armClick(arg: {
9
+ index: number;
10
+ label: string;
11
+ baselineMs: number;
12
+ }): Promise<{
13
+ armed: boolean;
14
+ reason?: string;
15
+ }>;
16
+ export declare function fireClick(): boolean;
17
+ export declare function clickOutcome(ms: number): Promise<{
18
+ effects: string[];
19
+ errors: string[];
20
+ navigated: boolean;
21
+ }>;