screw-bugs 0.1.8 → 0.1.10

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 (107) hide show
  1. package/README.md +49 -34
  2. package/dist/browser-playwright/capture.js +1 -1
  3. package/dist/browser-playwright/launch.js +27 -10
  4. package/dist/browser-playwright/page.d.ts +48 -26
  5. package/dist/browser-playwright/page.js +86 -89
  6. package/dist/browser-playwright/recorder.d.ts +154 -0
  7. package/dist/browser-playwright/recorder.js +382 -0
  8. package/dist/build-info.json +3 -3
  9. package/dist/cli/app.js +6 -2
  10. package/dist/cli/commands.js +4 -3
  11. package/dist/cli/doctor.d.ts +17 -2
  12. package/dist/cli/doctor.js +62 -4
  13. package/dist/cli/mcp.js +2 -2
  14. package/dist/cli/report-server.d.ts +19 -10
  15. package/dist/cli/report-server.js +43 -18
  16. package/dist/cli/share.js +2 -2
  17. package/dist/cli/sign-in.d.ts +9 -3
  18. package/dist/cli/sign-in.js +12 -9
  19. package/dist/cli/tailnet.d.ts +57 -0
  20. package/dist/cli/tailnet.js +82 -0
  21. package/dist/core/index.d.ts +1 -14
  22. package/dist/core/index.js +3 -14
  23. package/dist/report/index.d.ts +1 -10
  24. package/dist/report/index.js +3 -10
  25. package/dist/schema/index.d.ts +1 -9
  26. package/dist/schema/index.js +3 -9
  27. package/package.json +14 -14
  28. package/dist/core/accounts.d.ts +0 -40
  29. package/dist/core/accounts.js +0 -95
  30. package/dist/core/css.d.ts +0 -95
  31. package/dist/core/css.js +0 -436
  32. package/dist/core/engine.d.ts +0 -75
  33. package/dist/core/engine.js +0 -554
  34. package/dist/core/errors.d.ts +0 -85
  35. package/dist/core/errors.js +0 -36
  36. package/dist/core/evidence.d.ts +0 -14
  37. package/dist/core/evidence.js +0 -131
  38. package/dist/core/labels.d.ts +0 -47
  39. package/dist/core/labels.js +0 -199
  40. package/dist/core/liveness.d.ts +0 -45
  41. package/dist/core/liveness.js +0 -66
  42. package/dist/core/marks.d.ts +0 -63
  43. package/dist/core/marks.js +0 -410
  44. package/dist/core/services.d.ts +0 -574
  45. package/dist/core/services.js +0 -25
  46. package/dist/core/share.d.ts +0 -68
  47. package/dist/core/share.js +0 -318
  48. package/dist/core/steps.d.ts +0 -106
  49. package/dist/core/steps.js +0 -722
  50. package/dist/core/uploads.d.ts +0 -49
  51. package/dist/core/uploads.js +0 -133
  52. package/dist/core/video.d.ts +0 -47
  53. package/dist/core/video.js +0 -233
  54. package/dist/core/viewport.d.ts +0 -28
  55. package/dist/core/viewport.js +0 -50
  56. package/dist/report/assets.d.ts +0 -34
  57. package/dist/report/assets.js +0 -105
  58. package/dist/report/bug.d.ts +0 -11
  59. package/dist/report/bug.js +0 -20
  60. package/dist/report/html.d.ts +0 -47
  61. package/dist/report/html.js +0 -923
  62. package/dist/report/icons.d.ts +0 -51
  63. package/dist/report/icons.js +0 -93
  64. package/dist/report/live.d.ts +0 -7
  65. package/dist/report/live.js +0 -135
  66. package/dist/report/logos.d.ts +0 -4
  67. package/dist/report/logos.js +0 -19
  68. package/dist/report/markup.d.ts +0 -50
  69. package/dist/report/markup.js +0 -156
  70. package/dist/report/menu-bar.d.ts +0 -60
  71. package/dist/report/menu-bar.js +0 -157
  72. package/dist/report/player.d.ts +0 -102
  73. package/dist/report/player.js +0 -315
  74. package/dist/report/pr-summary.d.ts +0 -11
  75. package/dist/report/pr-summary.js +0 -119
  76. package/dist/report/sha256.d.ts +0 -9
  77. package/dist/report/sha256.js +0 -97
  78. package/dist/report/share-page.d.ts +0 -48
  79. package/dist/report/share-page.js +0 -291
  80. package/dist/report/shots.d.ts +0 -59
  81. package/dist/report/shots.js +0 -280
  82. package/dist/report/sign-in.d.ts +0 -41
  83. package/dist/report/sign-in.js +0 -568
  84. package/dist/report/styles.d.ts +0 -3
  85. package/dist/report/styles.js +0 -274
  86. package/dist/report/view.d.ts +0 -296
  87. package/dist/report/view.js +0 -702
  88. package/dist/report/walkthrough.d.ts +0 -93
  89. package/dist/report/walkthrough.js +0 -716
  90. package/dist/schema/accounts.d.ts +0 -137
  91. package/dist/schema/accounts.js +0 -121
  92. package/dist/schema/config.d.ts +0 -7
  93. package/dist/schema/config.js +0 -6
  94. package/dist/schema/doctor.d.ts +0 -46
  95. package/dist/schema/doctor.js +0 -30
  96. package/dist/schema/evidence.d.ts +0 -1115
  97. package/dist/schema/evidence.js +0 -565
  98. package/dist/schema/findings.d.ts +0 -161
  99. package/dist/schema/findings.js +0 -82
  100. package/dist/schema/job.d.ts +0 -1905
  101. package/dist/schema/job.js +0 -577
  102. package/dist/schema/ledger.d.ts +0 -1124
  103. package/dist/schema/ledger.js +0 -285
  104. package/dist/schema/share.d.ts +0 -55
  105. package/dist/schema/share.js +0 -64
  106. package/dist/schema/status.d.ts +0 -7
  107. package/dist/schema/status.js +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screw-bugs",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Local browser QA for coding agents (MCP), people and CI.",
5
5
  "keywords": [
6
6
  "browser",
@@ -43,20 +43,10 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "scripts": {
47
- "build": "tsc -p tsconfig.build.json && node dist/cli/stamp-build.js",
48
- "typecheck": "tsc -p tsconfig.json",
49
- "lint": "oxlint --deny-warnings",
50
- "format": "oxfmt",
51
- "format:check": "oxfmt --check",
52
- "test": "vitest run",
53
- "check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test",
54
- "e2e": "tsc -p e2e && node e2e/run.ts",
55
- "prepack": "node -e \"process.getBuiltinModule('fs').rmSync('dist',{recursive:true,force:true})\" && pnpm build"
56
- },
57
46
  "dependencies": {
58
47
  "@effect/platform-node": "^4.1.0",
59
48
  "@modelcontextprotocol/server": "2.4.0",
49
+ "@screw-bugs/core": "0.1.10",
60
50
  "effect": "^4.1.0",
61
51
  "playwright-core": "1.64.1"
62
52
  },
@@ -71,5 +61,15 @@
71
61
  "engines": {
72
62
  "node": ">=22.19.0"
73
63
  },
74
- "packageManager": "pnpm@12.9.1"
75
- }
64
+ "scripts": {
65
+ "build": "pnpm --filter @screw-bugs/core build && tsc -p tsconfig.build.json && node dist/cli/stamp-build.js",
66
+ "typecheck": "pnpm --filter @screw-bugs/core typecheck && tsc -p tsconfig.json",
67
+ "lint": "oxlint --deny-warnings",
68
+ "format": "oxfmt",
69
+ "format:check": "oxfmt --check",
70
+ "test": "vitest run",
71
+ "check:workers": "pnpm --filter @screw-bugs/core check:workers",
72
+ "check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm check:workers",
73
+ "e2e": "tsc -p e2e && node e2e/run.ts"
74
+ }
75
+ }
@@ -1,40 +0,0 @@
1
- import type { SavedAccount } from './services.js';
2
- import { type JobAccount, type SavedSession, type SignInWhy } from '../schema/index.js';
3
- /** How recent a session counts as just signed in, so `renew` does not ask for it again. */
4
- export declare const RENEW_GRACE_MS: number;
5
- /**
6
- * Whether the browser sends a cookie of `domain` (as Playwright gives it) to `origin`'s host. A
7
- * host-only cookie (no leading dot) goes to its own host alone; a domain cookie (`.acme.dev`) to
8
- * that host and every name under it (RFC 6265 domain matching). Browsers never keep a cookie for
9
- * a public suffix (`co.uk`, `github.io`), so this never takes in another site that shares one;
10
- * a sibling's cookie (`api.acme.dev` for `app.acme.dev`), or the parent's own host-only one, is
11
- * not kept either.
12
- */
13
- export declare const sentTo: (origin: string, domain: string) => boolean;
14
- /** The origin of a job URL, such as `http://localhost:3000`; undefined for one that is not a URL. */
15
- export declare const originOf: (url: string) => string | undefined;
16
- /**
17
- * Whether every cookie of the session has an expiry and it has passed: then the browser would
18
- * start with none of them, and the session cannot work. A session with no cookies at all may
19
- * live in storage, so it counts as working.
20
- */
21
- export declare const sessionExpired: (session: Pick<SavedSession, 'cookies'>, nowMs: number) => boolean;
22
- /**
23
- * Why a run of a job with `account` at `url` cannot start from its saved session yet (a person has
24
- * to sign in to it first), or undefined when it can.
25
- */
26
- export declare const needsSignIn: (account: JobAccount, url: string, saved: SavedAccount | undefined, nowMs: number) => SignInWhy | undefined;
27
- /** What kind of user the account is: what the job says, else what was saved. */
28
- export declare const aboutOf: (account: JobAccount, saved: SavedAccount | undefined) => string | undefined;
29
- /** Why the account needs signing in, as the end of a sentence about it. */
30
- export declare const describeSignInWhy: (why: SignInWhy) => string;
31
- /** At most this long, the app's title as the live view shows it. */
32
- export declare const SITE_TITLE_MAX = 120;
33
- /** A page title on one line, cut to `SITE_TITLE_MAX`; undefined when blank. */
34
- export declare const siteTitle: (raw: string) => string | undefined;
35
- /** At most this many icon addresses are tried, best first. */
36
- export declare const SITE_ICONS_MAX = 4;
37
- /** The largest icon the live view shows, in bytes. */
38
- export declare const SITE_ICON_BYTES_MAX: number;
39
- /** The image type of an icon from its `Content-Type`, or undefined when it is not one shown. */
40
- export declare const siteIconType: (contentType: string | undefined) => string | undefined;
@@ -1,95 +0,0 @@
1
- import { DateTime, Option } from 'effect';
2
- import { accountAboutOf, } from '../schema/index.js';
3
- /** How recent a session counts as just signed in, so `renew` does not ask for it again. */
4
- export const RENEW_GRACE_MS = 10 * 60_000;
5
- /**
6
- * Whether the browser sends a cookie of `domain` (as Playwright gives it) to `origin`'s host. A
7
- * host-only cookie (no leading dot) goes to its own host alone; a domain cookie (`.acme.dev`) to
8
- * that host and every name under it (RFC 6265 domain matching). Browsers never keep a cookie for
9
- * a public suffix (`co.uk`, `github.io`), so this never takes in another site that shares one;
10
- * a sibling's cookie (`api.acme.dev` for `app.acme.dev`), or the parent's own host-only one, is
11
- * not kept either.
12
- */
13
- export const sentTo = (origin, domain) => {
14
- const host = URL.parse(origin)
15
- ?.hostname.toLowerCase()
16
- .replace(/^\[|\]$/g, '');
17
- const lower = domain.toLowerCase().replace(/\.$/, '');
18
- const bare = lower.replace(/^\./, '');
19
- if (host === undefined || bare === '')
20
- return false;
21
- return host === bare || (lower.startsWith('.') && host.endsWith(`.${bare}`));
22
- };
23
- /** The origin of a job URL, such as `http://localhost:3000`; undefined for one that is not a URL. */
24
- export const originOf = (url) => {
25
- const parsed = URL.parse(url);
26
- return parsed === null ? undefined : parsed.origin;
27
- };
28
- /**
29
- * Whether every cookie of the session has an expiry and it has passed: then the browser would
30
- * start with none of them, and the session cannot work. A session with no cookies at all may
31
- * live in storage, so it counts as working.
32
- */
33
- export const sessionExpired = (session, nowMs) => session.cookies.length > 0 &&
34
- session.cookies.every((c) => c.expires > 0 && c.expires * 1000 <= nowMs);
35
- /**
36
- * Why a run of a job with `account` at `url` cannot start from its saved session yet (a person has
37
- * to sign in to it first), or undefined when it can.
38
- */
39
- export const needsSignIn = (account, url, saved, nowMs) => {
40
- if (saved === undefined || saved.session === undefined)
41
- return { _tag: 'none' };
42
- if (saved.entry.origin !== originOf(url))
43
- return { _tag: 'origin', saved: saved.entry.origin };
44
- if (sessionExpired(saved.session, nowMs))
45
- return { _tag: 'expired' };
46
- const savedAt = Option.map(DateTime.make(saved.entry.savedAt), DateTime.toEpochMillis);
47
- const renew = typeof account !== 'string' && account.renew === true;
48
- const justSaved = Option.exists(savedAt, (at) => nowMs - at < RENEW_GRACE_MS);
49
- if (renew && !justSaved)
50
- return { _tag: 'renew' };
51
- return undefined;
52
- };
53
- /** What kind of user the account is: what the job says, else what was saved. */
54
- export const aboutOf = (account, saved) => accountAboutOf(account) ?? saved?.entry.about;
55
- /** Why the account needs signing in, as the end of a sentence about it. */
56
- export const describeSignInWhy = (why) => {
57
- switch (why._tag) {
58
- case 'none':
59
- return 'has no saved sign-in yet';
60
- case 'origin':
61
- return `is signed in on ${why.saved}, not here`;
62
- case 'expired':
63
- return 'has a saved sign-in whose cookies have all expired';
64
- case 'renew':
65
- return 'was asked to sign in again';
66
- }
67
- };
68
- /** At most this long, the app's title as the live view shows it. */
69
- export const SITE_TITLE_MAX = 120;
70
- /** A page title on one line, cut to `SITE_TITLE_MAX`; undefined when blank. */
71
- export const siteTitle = (raw) => {
72
- const line = raw.replace(/\s+/g, ' ').trim();
73
- if (line === '')
74
- return undefined;
75
- return line.length > SITE_TITLE_MAX ? `${line.slice(0, SITE_TITLE_MAX - 1)}…` : line;
76
- };
77
- /** At most this many icon addresses are tried, best first. */
78
- export const SITE_ICONS_MAX = 4;
79
- /** The largest icon the live view shows, in bytes. */
80
- export const SITE_ICON_BYTES_MAX = 64 * 1024;
81
- /** Image types an icon is shown as. It goes in an `<img>`, where even an SVG runs no script. */
82
- const SITE_ICON_TYPES = new Set([
83
- 'image/png',
84
- 'image/x-icon',
85
- 'image/vnd.microsoft.icon',
86
- 'image/svg+xml',
87
- 'image/gif',
88
- 'image/jpeg',
89
- 'image/webp',
90
- ]);
91
- /** The image type of an icon from its `Content-Type`, or undefined when it is not one shown. */
92
- export const siteIconType = (contentType) => {
93
- const type = contentType?.split(';')[0]?.trim().toLowerCase();
94
- return type !== undefined && SITE_ICON_TYPES.has(type) ? type : undefined;
95
- };
@@ -1,95 +0,0 @@
1
- /** An attribute selector, such as `[data-test="preview"]` or `[href*=linkedin i]`. */
2
- export interface AttributeTest {
3
- readonly name: string;
4
- /** Undefined for `[name]`: the attribute is there, whatever its value. */
5
- readonly op?: '=' | '~=' | '|=' | '^=' | '$=' | '*=';
6
- readonly value?: string;
7
- /** `i` compares ignoring ASCII case, `s` with it; without one, as HTML says for the attribute. */
8
- readonly flag?: 'i' | 's';
9
- }
10
- /** One compound selector: everything about one element, such as `iframe.preview[title=Hi]`. */
11
- export interface Compound {
12
- /** Lower case; undefined for `*` or none. */
13
- readonly tag?: string;
14
- readonly ids: ReadonlyArray<string>;
15
- readonly classes: ReadonlyArray<string>;
16
- readonly attributes: ReadonlyArray<AttributeTest>;
17
- readonly not: ReadonlyArray<Compound>;
18
- }
19
- /** A compound and how it relates to the one before it: inside it anywhere, or right inside it. */
20
- export interface Part {
21
- readonly compound: Compound;
22
- /** How this part relates to the one before it; undefined for the first. */
23
- readonly combinator?: 'descendant' | 'child';
24
- }
25
- /** A selector list: an element matches when it matches any of them, judged by its last part. */
26
- export type Selector = ReadonlyArray<ReadonlyArray<Part>>;
27
- /** A selector, or why it cannot be matched against saved page state, in words. */
28
- export type Parsed = {
29
- readonly _tag: 'selector';
30
- readonly selector: Selector;
31
- } | {
32
- readonly _tag: 'unsupported';
33
- readonly reason: string;
34
- };
35
- /** What a highlight's CSS can check, besides the element itself and the frame it is in. */
36
- export declare const SUPPORTED_CSS: string;
37
- /**
38
- * Parses `css` into the selectors `matches` takes, or says in words what of it cannot be matched
39
- * against saved page state (see `SUPPORTED_CSS`).
40
- */
41
- export declare const parseSelector: (css: string) => Parsed;
42
- /**
43
- * An attribute's value as saved: `cut` when only its start was kept, so it is longer than `value`.
44
- */
45
- export interface AttributeValue {
46
- readonly value: string;
47
- readonly cut?: boolean | undefined;
48
- }
49
- /**
50
- * An element as a selector sees it: its own attributes, and the element it is in. What was not
51
- * saved whole is said, so a selector that depends on it is not taken as matching or not.
52
- */
53
- export interface CssElement {
54
- readonly tag: string;
55
- readonly id?: string | undefined;
56
- readonly classes?: ReadonlyArray<string> | undefined;
57
- /** More classes than `classes` holds. */
58
- readonly classesCut?: boolean | undefined;
59
- /**
60
- * An attribute's value, undefined when it does not have it (as far as was saved), or `unsaved`
61
- * when it has it but its value was not saved.
62
- */
63
- readonly attribute: (name: string) => AttributeValue | 'unsaved' | undefined;
64
- /** More attributes than were saved, so one `attribute` does not give may still be there. */
65
- readonly attributesCut?: boolean | undefined;
66
- /** Not an HTML element (such as an `<svg>`), whose attribute values HTML never folds. */
67
- readonly foreign?: boolean | undefined;
68
- /** The element it is in; undefined at the top of its document, or when that was not saved. */
69
- readonly parent: () => CssElement | undefined;
70
- /** It is in an element that was not saved, so `parent` stops short of the top. */
71
- readonly parentCut?: boolean | undefined;
72
- }
73
- /**
74
- * Whether something holds: true, false, or undefined when it depends on what was not saved (an
75
- * attribute value cut short, attributes, classes or ancestors left out).
76
- */
77
- export type Maybe = boolean | undefined;
78
- /**
79
- * Attributes whose values HTML compares ignoring ASCII case in selectors, on HTML elements, unless
80
- * the selector says `s` (HTML's list of case-insensitive attribute values).
81
- */
82
- export declare const CASE_INSENSITIVE_ATTRIBUTES: ReadonlySet<string>;
83
- /** Whether `el` matches any selector of the list; undefined when that depends on what was not saved. */
84
- export declare const selectorMatches: (selector: Selector, el: CssElement) => Maybe;
85
- /** Whether the selector looks at an element's ancestors at all. */
86
- export declare const usesAncestors: (selector: Selector) => boolean;
87
- /**
88
- * The ID or test ID that every element matching `selector` exactly has, when it is one compound
89
- * with one: what `Truncated.unsaved` can count.
90
- */
91
- export declare const selectorKey: (selector: Selector) => {
92
- readonly id: string;
93
- } | {
94
- readonly testId: string;
95
- } | undefined;