screw-bugs 0.1.1 → 0.1.3
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.
- package/README.md +70 -20
- package/dist/browser-playwright/launch.js +3 -1
- package/dist/browser-playwright/page.d.ts +3 -11
- package/dist/browser-playwright/page.js +17 -1
- package/dist/browser-playwright/sign-in.d.ts +77 -0
- package/dist/browser-playwright/sign-in.js +217 -0
- package/dist/build-info.json +3 -3
- package/dist/cli/app.js +4 -1
- package/dist/cli/commands.js +68 -3
- package/dist/cli/exit-codes.d.ts +6 -0
- package/dist/cli/exit-codes.js +6 -0
- package/dist/cli/mcp.js +17 -3
- package/dist/cli/operations.d.ts +31 -3
- package/dist/cli/operations.js +95 -3
- package/dist/cli/sign-in.d.ts +79 -0
- package/dist/cli/sign-in.js +305 -0
- package/dist/core/accounts.d.ts +40 -0
- package/dist/core/accounts.js +95 -0
- package/dist/core/engine.d.ts +8 -4
- package/dist/core/engine.js +39 -9
- package/dist/core/errors.d.ts +19 -0
- package/dist/core/errors.js +6 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/services.d.ts +77 -8
- package/dist/core/services.js +4 -1
- package/dist/report/bug.d.ts +2 -2
- package/dist/report/bug.js +5 -4
- package/dist/report/html.d.ts +1 -1
- package/dist/report/html.js +3 -2
- package/dist/report/icons.d.ts +2 -0
- package/dist/report/icons.js +4 -3
- package/dist/report/index.d.ts +2 -1
- package/dist/report/index.js +2 -1
- package/dist/report/markup.d.ts +2 -13
- package/dist/report/markup.js +8 -62
- package/dist/report/menu-bar.d.ts +60 -0
- package/dist/report/menu-bar.js +153 -0
- package/dist/report/player.d.ts +9 -4
- package/dist/report/player.js +24 -13
- package/dist/report/sign-in.d.ts +41 -0
- package/dist/report/sign-in.js +539 -0
- package/dist/report/styles.js +10 -34
- package/dist/report/walkthrough.d.ts +3 -2
- package/dist/report/walkthrough.js +50 -40
- package/dist/schema/accounts.d.ts +137 -0
- package/dist/schema/accounts.js +112 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/job.d.ts +27 -6
- package/dist/schema/job.js +12 -2
- package/dist/schema/ledger.d.ts +5 -1
- package/dist/store-local/accounts.d.ts +8 -4
- package/dist/store-local/accounts.js +82 -7
- package/dist/store-local/paths.d.ts +4 -1
- package/dist/store-local/paths.js +4 -1
- package/package.json +2 -2
package/dist/schema/job.d.ts
CHANGED
|
@@ -1059,8 +1059,15 @@ export declare const JobSpec: Schema.Struct<{
|
|
|
1059
1059
|
readonly success: Schema.optionalKey<Schema.String>;
|
|
1060
1060
|
}>>>;
|
|
1061
1061
|
readonly device: Schema.optionalKey<Schema.Literals<readonly ["desktop", "mobile"]>>;
|
|
1062
|
-
/**
|
|
1063
|
-
|
|
1062
|
+
/**
|
|
1063
|
+
* The test account the session starts signed in as (see `JobAccount`): a session a person saved
|
|
1064
|
+
* once for this origin. Its cases run signed in from the first step.
|
|
1065
|
+
*/
|
|
1066
|
+
readonly account: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
1067
|
+
readonly label: Schema.String;
|
|
1068
|
+
readonly about: Schema.optionalKey<Schema.String>;
|
|
1069
|
+
readonly renew: Schema.optionalKey<Schema.Boolean>;
|
|
1070
|
+
}>]>>;
|
|
1064
1071
|
}>;
|
|
1065
1072
|
export type JobSpec = typeof JobSpec.Type;
|
|
1066
1073
|
/**
|
|
@@ -1387,8 +1394,15 @@ export declare const NewJobSpec: Schema.Struct<{
|
|
|
1387
1394
|
readonly success: Schema.optionalKey<Schema.String>;
|
|
1388
1395
|
}>>>;
|
|
1389
1396
|
readonly device: Schema.optionalKey<Schema.Literals<readonly ["desktop", "mobile"]>>;
|
|
1390
|
-
/**
|
|
1391
|
-
|
|
1397
|
+
/**
|
|
1398
|
+
* The test account the session starts signed in as (see `JobAccount`): a session a person saved
|
|
1399
|
+
* once for this origin. Its cases run signed in from the first step.
|
|
1400
|
+
*/
|
|
1401
|
+
readonly account: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
1402
|
+
readonly label: Schema.String;
|
|
1403
|
+
readonly about: Schema.optionalKey<Schema.String>;
|
|
1404
|
+
readonly renew: Schema.optionalKey<Schema.Boolean>;
|
|
1405
|
+
}>]>>;
|
|
1392
1406
|
}>;
|
|
1393
1407
|
/** What `job.json` in a run folder holds. */
|
|
1394
1408
|
export declare const JobRecord: Schema.Struct<{
|
|
@@ -1712,8 +1726,15 @@ export declare const JobRecord: Schema.Struct<{
|
|
|
1712
1726
|
readonly success: Schema.optionalKey<Schema.String>;
|
|
1713
1727
|
}>>>;
|
|
1714
1728
|
readonly device: Schema.optionalKey<Schema.Literals<readonly ["desktop", "mobile"]>>;
|
|
1715
|
-
/**
|
|
1716
|
-
|
|
1729
|
+
/**
|
|
1730
|
+
* The test account the session starts signed in as (see `JobAccount`): a session a person saved
|
|
1731
|
+
* once for this origin. Its cases run signed in from the first step.
|
|
1732
|
+
*/
|
|
1733
|
+
readonly account: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
1734
|
+
readonly label: Schema.String;
|
|
1735
|
+
readonly about: Schema.optionalKey<Schema.String>;
|
|
1736
|
+
readonly renew: Schema.optionalKey<Schema.Boolean>;
|
|
1737
|
+
}>]>>;
|
|
1717
1738
|
}>;
|
|
1718
1739
|
readonly createdAt: Schema.String;
|
|
1719
1740
|
}>;
|
package/dist/schema/job.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
+
import { JobAccount } from './accounts.js';
|
|
2
3
|
/** Sortable by creation time and safe as a folder name, for example `20261029-104857-3f9a01c2`. */
|
|
3
4
|
export const JobId = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9-]*$/, {
|
|
4
5
|
message: 'A job ID has only letters, digits and dashes',
|
|
@@ -441,8 +442,17 @@ export const JobSpec = Schema.Struct({
|
|
|
441
442
|
description: 'Cases to run in order. Without cases, one "page loads" case runs.',
|
|
442
443
|
})),
|
|
443
444
|
device: Schema.optionalKey(Device),
|
|
444
|
-
/**
|
|
445
|
-
|
|
445
|
+
/**
|
|
446
|
+
* The test account the session starts signed in as (see `JobAccount`): a session a person saved
|
|
447
|
+
* once for this origin. Its cases run signed in from the first step.
|
|
448
|
+
*/
|
|
449
|
+
account: Schema.optionalKey(JobAccount.annotate({
|
|
450
|
+
description: 'Omit to run signed out (a fresh browser with no cookies or storage, whatever accounts ' +
|
|
451
|
+
'are saved). A test account to run signed in as: a label from .screw-bugs/accounts.json whose about ' +
|
|
452
|
+
'fits what the cases need (such as a user on a trial, or a paying one), or a new ' +
|
|
453
|
+
'{"label":"paid-user","about":"Pro plan, paying monthly"} for the user to sign in to. ' +
|
|
454
|
+
'Without a saved session nothing starts and the reply gives a link for the user.',
|
|
455
|
+
})),
|
|
446
456
|
});
|
|
447
457
|
/**
|
|
448
458
|
* A job as a caller submits it: a {@link JobSpec} whose case IDs are also unique ignoring case,
|
package/dist/schema/ledger.d.ts
CHANGED
|
@@ -667,7 +667,11 @@ export declare const ReportBundle: Schema.Struct<{
|
|
|
667
667
|
readonly success: Schema.optionalKey<Schema.String>;
|
|
668
668
|
}>>>;
|
|
669
669
|
readonly device: Schema.optionalKey<Schema.Literals<readonly ["desktop", "mobile"]>>;
|
|
670
|
-
readonly account: Schema.optionalKey<Schema.
|
|
670
|
+
readonly account: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
671
|
+
readonly label: Schema.String;
|
|
672
|
+
readonly about: Schema.optionalKey<Schema.String>;
|
|
673
|
+
readonly renew: Schema.optionalKey<Schema.Boolean>;
|
|
674
|
+
}>]>>;
|
|
671
675
|
}>;
|
|
672
676
|
readonly ledger: Schema.Struct<{
|
|
673
677
|
readonly jobId: Schema.brand<Schema.String, "JobId">;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { Layer } from 'effect';
|
|
1
|
+
import { FileSystem, Layer, Path } from 'effect';
|
|
2
2
|
import { AccountBook } from '../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* The account book on disk: `.screw-bugs/accounts.json` lists the accounts (no secrets), and
|
|
5
|
+
* `.screw-bugs/accounts/<label>.json` holds each one's session, written with mode 0600 in a folder
|
|
6
|
+
* with mode 0700, so only the user can read them. (On Windows modes do not apply; the files get
|
|
7
|
+
* the folder's access, like everything else in `.screw-bugs/`.) The whole folder ignores itself
|
|
8
|
+
* for git. Changes in this process are one at a time; a change in another process at the same
|
|
9
|
+
* moment may be lost, never half written.
|
|
6
10
|
*/
|
|
7
|
-
export declare const AccountBookLocal: (
|
|
11
|
+
export declare const AccountBookLocal: (projectRoot: string) => Layer.Layer<AccountBook, never, FileSystem.FileSystem | Path.Path>;
|
|
@@ -1,9 +1,84 @@
|
|
|
1
|
-
import { Effect, Layer } from 'effect';
|
|
2
|
-
import { AccountBook,
|
|
1
|
+
import { Effect, FileSystem, Layer, Path, PlatformError, Random, Schema, Semaphore } from 'effect';
|
|
2
|
+
import { AccountBook, StorageFailed } from '../core/index.js';
|
|
3
|
+
import { AccountsFile, SavedSession } from '../schema/index.js';
|
|
4
|
+
import { accountsDir, accountsFile, ensureDataDir } from './paths.js';
|
|
5
|
+
const isMissing = (error) => error instanceof PlatformError.PlatformError && error.reason._tag === 'NotFound';
|
|
6
|
+
const randomHex = Random.nextIntBetween(0, 2 ** 32 - 1).pipe(Effect.map((n) => n.toString(16).padStart(8, '0')));
|
|
7
|
+
const decodeFile = Schema.decodeUnknownEffect(Schema.fromJsonString(AccountsFile));
|
|
8
|
+
const decodeSession = Schema.decodeUnknownEffect(Schema.fromJsonString(SavedSession));
|
|
9
|
+
const decodeObject = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown)));
|
|
3
10
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
11
|
+
* The account book on disk: `.screw-bugs/accounts.json` lists the accounts (no secrets), and
|
|
12
|
+
* `.screw-bugs/accounts/<label>.json` holds each one's session, written with mode 0600 in a folder
|
|
13
|
+
* with mode 0700, so only the user can read them. (On Windows modes do not apply; the files get
|
|
14
|
+
* the folder's access, like everything else in `.screw-bugs/`.) The whole folder ignores itself
|
|
15
|
+
* for git. Changes in this process are one at a time; a change in another process at the same
|
|
16
|
+
* moment may be lost, never half written.
|
|
6
17
|
*/
|
|
7
|
-
export const AccountBookLocal = (
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
export const AccountBookLocal = (projectRoot) => Layer.effect(AccountBook, Effect.gen(function* () {
|
|
19
|
+
const fs = yield* FileSystem.FileSystem;
|
|
20
|
+
const path = yield* Path.Path;
|
|
21
|
+
const file = yield* accountsFile(projectRoot);
|
|
22
|
+
const dir = yield* accountsDir(projectRoot);
|
|
23
|
+
const lock = yield* Semaphore.make(1);
|
|
24
|
+
const sessionPath = (label) => path.join(dir, `${label}.json`);
|
|
25
|
+
const failed = (message) => (cause) => new StorageFailed({ message, cause });
|
|
26
|
+
/** Writes through a temporary file and a rename; `mode` is the new file's. */
|
|
27
|
+
const writeAtomic = (target, text, mode) => Effect.gen(function* () {
|
|
28
|
+
const temporary = `${target}.${yield* randomHex}.tmp`;
|
|
29
|
+
yield* fs.writeFileString(temporary, text, { flag: 'wx', mode });
|
|
30
|
+
yield* fs.rename(temporary, target);
|
|
31
|
+
}).pipe(Effect.mapError(failed(`Could not write ${target}.`)));
|
|
32
|
+
const read = fs.readFileString(file).pipe(Effect.flatMap(decodeFile), Effect.catchIf(isMissing, () => Effect.succeed({ version: 1, accounts: [] })), Effect.mapError(failed(`${file} is unreadable or not valid.`)));
|
|
33
|
+
const write = (accounts) => Effect.gen(function* () {
|
|
34
|
+
yield* ensureDataDir(projectRoot).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path), Effect.mapError(failed(`Could not create the folder of ${file}.`)));
|
|
35
|
+
const sorted = [...accounts].sort((a, b) => a.label.localeCompare(b.label));
|
|
36
|
+
const value = { version: 1, accounts: sorted };
|
|
37
|
+
yield* writeAtomic(file, `${JSON.stringify(value, null, 2)}\n`, 0o644);
|
|
38
|
+
});
|
|
39
|
+
return AccountBook.of({
|
|
40
|
+
file,
|
|
41
|
+
list: read.pipe(Effect.map((book) => book.accounts)),
|
|
42
|
+
find: (label) => Effect.gen(function* () {
|
|
43
|
+
const listed = (yield* read).accounts.find((a) => a.label === label);
|
|
44
|
+
if (listed === undefined)
|
|
45
|
+
return undefined;
|
|
46
|
+
const file = yield* fs.readFileString(sessionPath(label)).pipe(Effect.flatMap((text) => decodeSession(text).pipe(Effect.map((session) => ({ text, session })))), Effect.orElseSucceed(() => undefined));
|
|
47
|
+
// Where and when come from the session file itself, written with it in one rename:
|
|
48
|
+
// the list may be behind (a save in progress, or one whose list write failed).
|
|
49
|
+
const own = file?.session.account.label === label ? file : undefined;
|
|
50
|
+
return {
|
|
51
|
+
entry: own === undefined
|
|
52
|
+
? listed
|
|
53
|
+
: {
|
|
54
|
+
...listed,
|
|
55
|
+
origin: own.session.account.origin,
|
|
56
|
+
savedAt: own.session.account.savedAt,
|
|
57
|
+
},
|
|
58
|
+
sessionPath: sessionPath(label),
|
|
59
|
+
session: own?.session,
|
|
60
|
+
sessionText: own?.text,
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
save: (entry, session) => Effect.gen(function* () {
|
|
64
|
+
yield* fs
|
|
65
|
+
.makeDirectory(dir, { recursive: true, mode: 0o700 })
|
|
66
|
+
.pipe(Effect.mapError(failed(`Could not create ${dir}.`)));
|
|
67
|
+
// A folder made by an older copy, or by hand, is made private too.
|
|
68
|
+
yield* fs.chmod(dir, 0o700).pipe(Effect.ignore);
|
|
69
|
+
const state = yield* decodeObject(session).pipe(Effect.mapError(failed('The session to save is not a JSON object.')));
|
|
70
|
+
const account = { label: entry.label, origin: entry.origin, savedAt: entry.savedAt };
|
|
71
|
+
yield* writeAtomic(sessionPath(entry.label), `${JSON.stringify({ ...state, account }, null, 2)}\n`, 0o600);
|
|
72
|
+
const others = (yield* read).accounts.filter((a) => a.label !== entry.label);
|
|
73
|
+
yield* write([...others, entry]);
|
|
74
|
+
}).pipe(Semaphore.withPermit(lock)),
|
|
75
|
+
remove: (label) => Effect.gen(function* () {
|
|
76
|
+
const book = yield* read;
|
|
77
|
+
const found = book.accounts.some((a) => a.label === label);
|
|
78
|
+
if (found)
|
|
79
|
+
yield* write(book.accounts.filter((a) => a.label !== label));
|
|
80
|
+
const removed = yield* fs.remove(sessionPath(label)).pipe(Effect.as(true), Effect.catchIf(isMissing, () => Effect.succeed(false)), Effect.mapError(failed(`Could not remove ${sessionPath(label)}.`)));
|
|
81
|
+
return found || removed;
|
|
82
|
+
}).pipe(Semaphore.withPermit(lock)),
|
|
83
|
+
});
|
|
84
|
+
}));
|
|
@@ -6,5 +6,8 @@ import { Effect, FileSystem, Path } from 'effect';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const dataDir: (projectRoot: string) => Effect.Effect<string, never, Path.Path>;
|
|
8
8
|
export declare const runsDir: (projectRoot: string) => Effect.Effect<string, never, Path.Path>;
|
|
9
|
-
|
|
9
|
+
/** The saved test accounts, for agents to pick from: labels and what each user is, no secrets. */
|
|
10
|
+
export declare const accountsFile: (projectRoot: string) => Effect.Effect<string, never, Path.Path>;
|
|
11
|
+
/** One session file per account, readable by the user alone. */
|
|
12
|
+
export declare const accountsDir: (projectRoot: string) => Effect.Effect<string, never, Path.Path>;
|
|
10
13
|
export declare const ensureDataDir: (projectRoot: string) => Effect.Effect<string, import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
@@ -6,7 +6,10 @@ import { Effect, FileSystem, Path } from 'effect';
|
|
|
6
6
|
*/
|
|
7
7
|
export const dataDir = (projectRoot) => Path.Path.useSync((path) => path.join(projectRoot, '.screw-bugs'));
|
|
8
8
|
export const runsDir = (projectRoot) => Path.Path.useSync((path) => path.join(projectRoot, '.screw-bugs', 'runs'));
|
|
9
|
-
|
|
9
|
+
/** The saved test accounts, for agents to pick from: labels and what each user is, no secrets. */
|
|
10
|
+
export const accountsFile = (projectRoot) => Path.Path.useSync((path) => path.join(projectRoot, '.screw-bugs', 'accounts.json'));
|
|
11
|
+
/** One session file per account, readable by the user alone. */
|
|
12
|
+
export const accountsDir = (projectRoot) => Path.Path.useSync((path) => path.join(projectRoot, '.screw-bugs', 'accounts'));
|
|
10
13
|
export const ensureDataDir = (projectRoot) => Effect.gen(function* () {
|
|
11
14
|
const fs = yield* FileSystem.FileSystem;
|
|
12
15
|
const path = yield* Path.Path;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screw-bugs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Local browser QA for coding agents (MCP), people and CI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"vitest": "5.0.5"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
|
-
"node": ">=22.
|
|
72
|
+
"node": ">=22.19.0"
|
|
73
73
|
},
|
|
74
74
|
"packageManager": "pnpm@12.9.1"
|
|
75
75
|
}
|