screw-bugs 0.1.1-next.7.g9faa064 → 0.1.1
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 +125 -20
- package/dist/browser-playwright/launch.d.ts +5 -0
- package/dist/browser-playwright/launch.js +10 -0
- package/dist/build-info.json +3 -3
- package/dist/cli/app.d.ts +11 -5
- package/dist/cli/app.js +29 -10
- package/dist/cli/commands.d.ts +2 -1
- package/dist/cli/commands.js +74 -0
- package/dist/cli/exit-codes.d.ts +5 -0
- package/dist/cli/exit-codes.js +5 -0
- package/dist/cli/install-method.d.ts +1 -1
- package/dist/cli/main.js +5 -3
- package/dist/cli/report-server.d.ts +5 -2
- package/dist/cli/report-server.js +23 -4
- package/dist/cli/setup.d.ts +169 -0
- package/dist/cli/setup.js +539 -0
- package/dist/cli/share.d.ts +82 -0
- package/dist/cli/share.js +381 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/share.d.ts +37 -0
- package/dist/core/share.js +179 -0
- package/dist/report/html.d.ts +1 -1
- package/dist/report/html.js +1 -1
- package/dist/report/icons.d.ts +6 -0
- package/dist/report/icons.js +8 -1
- package/dist/report/index.d.ts +1 -0
- package/dist/report/index.js +1 -0
- package/dist/report/markup.d.ts +7 -2
- package/dist/report/markup.js +20 -3
- package/dist/report/player.d.ts +7 -3
- package/dist/report/player.js +11 -5
- package/dist/report/styles.js +7 -0
- package/dist/report/walkthrough.d.ts +5 -2
- package/dist/report/walkthrough.js +79 -12
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/share.d.ts +38 -0
- package/dist/schema/share.js +42 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,80 @@ screw-bugs has no AI of its own and never calls a model. Your coding agent (or y
|
|
|
6
6
|
test and writes the cases as structured steps. screw-bugs runs them in a real headless browser,
|
|
7
7
|
saves screenshots, and reports a status for each case.
|
|
8
8
|
|
|
9
|
-
> **Status: early.** `doctor`, `init`, `run`, `status`, `report` and `runs` work. `answer`,
|
|
9
|
+
> **Status: early.** `setup`, `doctor`, `init`, `run`, `status`, `report` and `runs` work. `answer`,
|
|
10
10
|
> `accounts`, `share` and `analytics on|off` exit with code 5 and say they are not implemented yet.
|
|
11
11
|
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
In your project folder, run:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx -y screw-bugs@latest setup
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
That one command:
|
|
21
|
+
|
|
22
|
+
- adds the screw-bugs MCP server (`npx -y screw-bugs@latest mcp`) to the project config of each
|
|
23
|
+
coding agent it finds, in this project (`.claude/`, `CLAUDE.md`, `.cursor/`, `.opencode/`, …)
|
|
24
|
+
or on the PATH: Claude Code (`.mcp.json`), Codex (`.codex/config.toml`), Cursor
|
|
25
|
+
(`.cursor/mcp.json`), VS Code (`.vscode/mcp.json`) and OpenCode (`opencode.json`). With none
|
|
26
|
+
found, Claude Code. Choose them yourself with `--agent claude`, `--agent codex`, `--agent cursor`,
|
|
27
|
+
`--agent vscode` or `--agent opencode` (repeatable). Other servers and settings in
|
|
28
|
+
those files are kept. A file it cannot edit safely (JSON with comments, say) is left as it is,
|
|
29
|
+
and it prints the entry to add yourself (exit code 8);
|
|
30
|
+
- writes `screw-bugs.json` when there is none (`--url <url>` sets its default URL; exit code 3
|
|
31
|
+
when it cannot);
|
|
32
|
+
- downloads Playwright's ffmpeg when it is missing, and Playwright's Chromium when there is no
|
|
33
|
+
Chrome, Edge or Chromium (`--no-downloads` skips both);
|
|
34
|
+
- ends with `doctor`'s report (exit code 4 when something is still missing).
|
|
35
|
+
|
|
36
|
+
It never asks anything, and running it again changes only what is out of date. Then restart your
|
|
37
|
+
agent in the project. Claude Code asks once to approve the servers in `.mcp.json`; Codex reads
|
|
38
|
+
`.codex/config.toml` only in a project it trusts. Run `npx -y screw-bugs@next setup` to set the
|
|
39
|
+
project up with the `next` channel instead (see below).
|
|
40
|
+
|
|
41
|
+
### Or ask your coding agent to do it
|
|
42
|
+
|
|
43
|
+
Paste this into your coding agent, in your project. It runs `setup` for itself, handles what
|
|
44
|
+
`setup` could not do, and tells you how to start the server.
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
Set up screw-bugs (local browser QA for coding agents, over MCP) in this project.
|
|
48
|
+
|
|
49
|
+
1. In the project's root folder, run: npx -y screw-bugs@latest setup --agent <id>
|
|
50
|
+
where <id> is the coding agent you are:
|
|
51
|
+
- Claude Code: claude (config file: .mcp.json, entry under "mcpServers")
|
|
52
|
+
- Codex: codex (config file: .codex/config.toml)
|
|
53
|
+
- Cursor: cursor (config file: .cursor/mcp.json, entry under "mcpServers")
|
|
54
|
+
- VS Code / Copilot: vscode (config file: .vscode/mcp.json, entry under "servers")
|
|
55
|
+
- OpenCode: opencode (config file: opencode.json or opencode.jsonc, entry under "mcp",
|
|
56
|
+
or under "mcp.servers" if the file already uses that)
|
|
57
|
+
If you are none of these, stop and tell me.
|
|
58
|
+
Run it outside any sandbox (ask me to approve that): it needs network access for npx and its
|
|
59
|
+
downloads, writes your config file (which sandboxes often make read-only) and starts a
|
|
60
|
+
browser to check this machine. In a sandbox it can hang or report a missing browser.
|
|
61
|
+
If you can tell this app's local dev server URL (from package.json scripts or the README),
|
|
62
|
+
add --url <that URL>.
|
|
63
|
+
2. Read all of its output, whatever the exit code, and act on every line of these kinds:
|
|
64
|
+
- "Add this to <file> yourself:": setup left your config file alone. Add the entry printed
|
|
65
|
+
under it to that file yourself, keeping everything else in it (comments included) as it is.
|
|
66
|
+
- A line marked ✗ or ! with "Fix:" (and often "Run:") under it: something this machine needs
|
|
67
|
+
is missing or out of date. Show these to me, and ask me before running any command.
|
|
68
|
+
- "✗ screw-bugs.json …": the project file could not be written. Tell me why.
|
|
69
|
+
- Any other line marked ✗ (such as a download that failed): tell me what it says.
|
|
70
|
+
It is all done only when no line is marked ✗.
|
|
71
|
+
Install nothing else, and do not edit any other files.
|
|
72
|
+
3. Tell me what changed, and how to start the server in you:
|
|
73
|
+
- Claude Code: run /mcp (or restart in this project) and approve "screw-bugs" from .mcp.json.
|
|
74
|
+
- Codex: restart in this project, and trust this folder if asked (Codex loads
|
|
75
|
+
.codex/config.toml only in a trusted project).
|
|
76
|
+
- Cursor: open Cursor Settings > MCP and check "screw-bugs" is listed and turned on (reload
|
|
77
|
+
the window if it is not there yet).
|
|
78
|
+
- VS Code: open .vscode/mcp.json and click "Start" above "screw-bugs" (or run "MCP: List
|
|
79
|
+
Servers"), then use it from Copilot Chat in Agent mode.
|
|
80
|
+
- OpenCode: restart in this project.
|
|
81
|
+
```
|
|
82
|
+
|
|
12
83
|
## Requirements
|
|
13
84
|
|
|
14
85
|
Node.js 22.13 or newer, and Google Chrome or Microsoft Edge (or Playwright's Chromium). Check with:
|
|
@@ -26,13 +97,16 @@ Without it no run starts: `start_run` and `screw-bugs run` reply with the same c
|
|
|
26
97
|
|
|
27
98
|
## Use from a coding agent (MCP)
|
|
28
99
|
|
|
100
|
+
`setup` (see [Install](#install)) registers the server for you. To add it by hand instead, for
|
|
101
|
+
Claude Code across all your projects:
|
|
102
|
+
|
|
29
103
|
```sh
|
|
30
104
|
claude mcp add screw-bugs -- npx -y screw-bugs@latest mcp
|
|
31
105
|
```
|
|
32
106
|
|
|
33
|
-
To try
|
|
34
|
-
|
|
35
|
-
names its commit), with `npx -y screw-bugs@next mcp`. `doctor` shows the version and commit that is
|
|
107
|
+
To try a newer build of `main` instead, use the `next` channel: builds of `main` are published
|
|
108
|
+
from time to time as prereleases under the npm tag `next` (for example `0.1.1-next.57.gfa82ee8`,
|
|
109
|
+
which names its commit), with `npx -y screw-bugs@next mcp`. `doctor` shows the version and commit that is
|
|
36
110
|
running. A `next` build checks for, and suggests, newer `next` builds only.
|
|
37
111
|
|
|
38
112
|
Tools: `doctor`, `start_run` (returns a job ID right away; the run continues inside the MCP
|
|
@@ -600,22 +674,23 @@ navigation to a `data:` URL; nothing happens then.
|
|
|
600
674
|
|
|
601
675
|
## CLI
|
|
602
676
|
|
|
603
|
-
| Command
|
|
604
|
-
|
|
|
605
|
-
| `doctor`
|
|
606
|
-
| `run [--spec job.json] [--url <url>]`
|
|
607
|
-
| `status <job-id>`
|
|
608
|
-
| `answer <job-id> <question-id>`
|
|
609
|
-
| `mcp`
|
|
610
|
-
| `
|
|
611
|
-
| `
|
|
612
|
-
| `
|
|
613
|
-
| `report <job-id>
|
|
614
|
-
| `
|
|
615
|
-
| `
|
|
616
|
-
| `
|
|
617
|
-
| `
|
|
618
|
-
| `
|
|
677
|
+
| Command | What it does |
|
|
678
|
+
| ----------------------------------------- | ---------------------------------------------- |
|
|
679
|
+
| `doctor` | Check Node, browser, video, disk and updates |
|
|
680
|
+
| `run [--spec job.json] [--url <url>]` | Run cases and wait; exit 1 unless all passed |
|
|
681
|
+
| `status <job-id>` | State and case results of a run |
|
|
682
|
+
| `answer <job-id> <question-id>` | Answer a question a waiting run asked |
|
|
683
|
+
| `mcp` | Serve the MCP server over stdio |
|
|
684
|
+
| `setup [--agent <name>] [--no-downloads]` | Set up this project in one command (above) |
|
|
685
|
+
| `init` | Write `screw-bugs.json` for this project |
|
|
686
|
+
| `accounts` | Manage test accounts for logins |
|
|
687
|
+
| `report <job-id> [--format markdown]` | Write the report, or print a PR summary |
|
|
688
|
+
| `report <job-id> --serve [--port N]` | Serve the report at a `http://127.0.0.1` URL |
|
|
689
|
+
| `walkthrough <job-id> [--serve]` | Write (or serve) the run's video walkthrough |
|
|
690
|
+
| `findings <job-id> <file\|->` | Submit an agent's write-up of an ended run |
|
|
691
|
+
| `share <job-id>` | Share a report through screw-bugs Cloud |
|
|
692
|
+
| `runs` | List recent runs |
|
|
693
|
+
| `analytics` | Show whether analytics are on (off by default) |
|
|
619
694
|
|
|
620
695
|
Every command accepts `--json`. `run --url <url>` alone checks that the page loads. `init --url
|
|
621
696
|
<url>` saves a default URL, so a bare `run` uses it.
|
|
@@ -853,6 +928,35 @@ serve only the project's run folders, read-only: reports, screenshots, videos an
|
|
|
853
928
|
never list folders or serve dotfiles, anything outside `.screw-bugs/runs` or symlinks out of it.
|
|
854
929
|
Videos are served with HTTP range requests, so they play and seek (unlike `python3 -m
|
|
855
930
|
http.server`). A URL works as long as some process serves the project on its port.
|
|
931
|
+
The one other thing they answer is the Share button's routes, under `/.screw-bugs/share/` (below).
|
|
932
|
+
|
|
933
|
+
### Sharing
|
|
934
|
+
|
|
935
|
+
A report or walkthrough opened through the report server (its `http://127.0.0.1` URL) has a
|
|
936
|
+
**Share** button that puts the run on screw-bugs Cloud: a link anyone can open for 7 days. Opened
|
|
937
|
+
from disk, or on Cloud itself, the page has no server to share it, so the button is not there.
|
|
938
|
+
|
|
939
|
+
1. Share sends the browser to `screwbugs.dev`, which signs you in with GitHub and shows what will
|
|
940
|
+
be uploaded. Nothing has left your machine yet.
|
|
941
|
+
2. When you confirm, Cloud sends the browser back to the report server with a one-time ticket. The
|
|
942
|
+
server uploads the run's report data, screenshots and videos (no HTML or other JSON), showing
|
|
943
|
+
its progress, then sends the browser to the share's page on Cloud: its link, when it expires,
|
|
944
|
+
and a button to delete it.
|
|
945
|
+
|
|
946
|
+
Only a person can share: it takes a click in the report and a confirmation on Cloud. The share
|
|
947
|
+
starts only from a click in a page of the same server, the ticket goes only to the Cloud the
|
|
948
|
+
server was set up with, and a ticket works once, for the share it was made for. The `share`
|
|
949
|
+
command is not implemented; there is no agent or CLI path.
|
|
950
|
+
|
|
951
|
+
Before uploading, the server takes out what it can tell is a secret: what was typed into a field
|
|
952
|
+
named like a password, code, PIN, token, key or card number (shown as `hidden`), and the user name,
|
|
953
|
+
password and secret-looking parameters (`token`, `key`, `code`, `session`, `sig`, …) of every URL
|
|
954
|
+
in the report. It cannot tell a secret in a URL's path or in free text, or one typed into a field
|
|
955
|
+
named like any other, and it never changes the screenshots or video: check what they show before
|
|
956
|
+
you share.
|
|
957
|
+
|
|
958
|
+
`SCREW_BUGS_CLOUD_URL` sets where Cloud is (default `https://screwbugs.dev`; `http:` only on this
|
|
959
|
+
machine, for developing Cloud).
|
|
856
960
|
|
|
857
961
|
### CI
|
|
858
962
|
|
|
@@ -869,6 +973,7 @@ error, not a prompt. Exit codes:
|
|
|
869
973
|
| 5 | Not implemented yet |
|
|
870
974
|
| 6 | Findings do not fit the run |
|
|
871
975
|
| 7 | Upload files missing or unusable |
|
|
976
|
+
| 8 | `setup` left an agent's config alone |
|
|
872
977
|
| 70 | Internal error (please report it) |
|
|
873
978
|
| 130 | Stopped by Ctrl+C or SIGTERM |
|
|
874
979
|
|
|
@@ -12,6 +12,11 @@ export declare const BrowserPlaywright: Layer.Layer<Browser, never, FileSystem.F
|
|
|
12
12
|
export declare const installBrowserCommand: Effect.Effect<string, never, FileSystem.FileSystem | Path.Path>;
|
|
13
13
|
/** Downloads the ffmpeg build that the bundled Playwright records videos with. */
|
|
14
14
|
export declare const installFfmpegCommand: Effect.Effect<string, never, FileSystem.FileSystem | Path.Path>;
|
|
15
|
+
/**
|
|
16
|
+
* The bundled Playwright's own CLI (`cli.js` beside its package.json), which `setup` runs with
|
|
17
|
+
* this Node to download ffmpeg or Chromium: the exact Playwright screw-bugs uses, with no npx.
|
|
18
|
+
*/
|
|
19
|
+
export declare const playwrightCli: Effect.Effect<string, never, Path.Path>;
|
|
15
20
|
/** Where Playwright's ffmpeg is, and whether it is there. `path` is undefined when unknown. */
|
|
16
21
|
export interface FfmpegLookup {
|
|
17
22
|
readonly found: boolean;
|
|
@@ -86,6 +86,16 @@ const playwrightVersion = Effect.gen(function* () {
|
|
|
86
86
|
export const installBrowserCommand = playwrightVersion.pipe(Effect.map((version) => `npx -y playwright-core@${version} install chromium`));
|
|
87
87
|
/** Downloads the ffmpeg build that the bundled Playwright records videos with. */
|
|
88
88
|
export const installFfmpegCommand = playwrightVersion.pipe(Effect.map((version) => `npx -y playwright-core@${version} install ffmpeg`));
|
|
89
|
+
/**
|
|
90
|
+
* The bundled Playwright's own CLI (`cli.js` beside its package.json), which `setup` runs with
|
|
91
|
+
* this Node to download ffmpeg or Chromium: the exact Playwright screw-bugs uses, with no npx.
|
|
92
|
+
*/
|
|
93
|
+
export const playwrightCli = Effect.gen(function* () {
|
|
94
|
+
const path = yield* Path.Path;
|
|
95
|
+
const file = yield* path.fromFileUrl(new URL(import.meta.resolve('playwright-core/package.json')));
|
|
96
|
+
return path.join(path.dirname(file), 'cli.js');
|
|
97
|
+
// Playwright is part of the install; failing to find it is a defect.
|
|
98
|
+
}).pipe(Effect.orDie);
|
|
89
99
|
/** What is wrong when Playwright's ffmpeg is not found, as a clause: no full stop. */
|
|
90
100
|
export const ffmpegProblem = (lookup) => lookup.path === undefined
|
|
91
101
|
? "Playwright's ffmpeg could not be looked up"
|
package/dist/build-info.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "2026-11-
|
|
3
|
-
"builtAt": "2026-11-
|
|
4
|
-
"commit": "
|
|
2
|
+
"id": "2026-11-12T23:03:45.746Z-3e69166f",
|
|
3
|
+
"builtAt": "2026-11-12T23:03:45.746Z",
|
|
4
|
+
"commit": "03c1d38f8dc97cafd0094c71661f8aa9f30de50b"
|
|
5
5
|
}
|
package/dist/cli/app.d.ts
CHANGED
|
@@ -6,15 +6,21 @@ import { PackageInfo } from './package-info.js';
|
|
|
6
6
|
import { RunningBuild } from './build-info.js';
|
|
7
7
|
import { ReportLinks } from './report-links.js';
|
|
8
8
|
import { ReportServer } from './report-server.js';
|
|
9
|
+
import { Setup } from './setup.js';
|
|
10
|
+
import { ShareSource } from './share.js';
|
|
9
11
|
import { UpdateCheck } from './update-check.js';
|
|
10
12
|
/**
|
|
11
|
-
* The production wiring: the engine on top of the local adapters,
|
|
12
|
-
* project folder. It
|
|
13
|
-
* needs the platform (`FileSystem`, `Path`) from outside: `NodeServices` in production and tests.
|
|
13
|
+
* The production wiring: the engine on top of the local adapters, the report server and `setup`,
|
|
14
|
+
* for one project folder. It needs the platform (`FileSystem`, `Path`) from outside: `NodeServices` in production and tests.
|
|
14
15
|
*/
|
|
15
|
-
export declare const appLayer: (projectRoot: string) => Layer.Layer<Operations | PackageInfo | ReportLinks | ReportServer | RunningBuild | UpdateCheck, import("effect/PlatformError").BadArgument, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | Path.Path | import("effect/Stdio").Stdio>;
|
|
16
|
+
export declare const appLayer: (projectRoot: string) => Layer.Layer<Operations | PackageInfo | ReportLinks | ReportServer | RunningBuild | Setup | ShareSource | UpdateCheck, import("effect/PlatformError").BadArgument, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | Path.Path | import("effect/Stdio").Stdio>;
|
|
17
|
+
/**
|
|
18
|
+
* What the detached report server (`serveDetached`) shares runs with: the engine of the project whose
|
|
19
|
+
* folder is `projectRoot`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const detachedShareLayer: (projectRoot: string) => Layer.Layer<ShareSource, never, import("effect/FileSystem").FileSystem | Path.Path>;
|
|
16
22
|
/**
|
|
17
23
|
* Runs the CLI and resolves to the process exit code. A due update check started with it gets
|
|
18
24
|
* the rest of its time after the command has written everything; it never changes the code.
|
|
19
25
|
*/
|
|
20
|
-
export declare const runCli: (args: ReadonlyArray<string>) => Effect.Effect<ExitCode, never, Operations | PackageInfo | Command.Environment>;
|
|
26
|
+
export declare const runCli: (args: ReadonlyArray<string>) => Effect.Effect<ExitCode, never, Operations | PackageInfo | Setup | Command.Environment>;
|
package/dist/cli/app.js
CHANGED
|
@@ -12,6 +12,8 @@ import { PackageInfo } from './package-info.js';
|
|
|
12
12
|
import { RunningBuild, short } from './build-info.js';
|
|
13
13
|
import { ReportLinks, ReportServerLauncher, SERVE_REPORTS_COMMAND } from './report-links.js';
|
|
14
14
|
import { ReportServer } from './report-server.js';
|
|
15
|
+
import { PlaywrightDownloads, Setup } from './setup.js';
|
|
16
|
+
import { ShareSource } from './share.js';
|
|
15
17
|
import { CLI_WAIT, UpdateCheck } from './update-check.js';
|
|
16
18
|
/** Progress goes nowhere yet; the terminal and MCP notifiers come with real runs. */
|
|
17
19
|
const NotifierSilent = Layer.succeed(Notifier, { notify: () => Effect.void });
|
|
@@ -31,17 +33,34 @@ const UpdateCheckLive = UpdateCheck.layer(process.platform).pipe(Layer.provide(N
|
|
|
31
33
|
*/
|
|
32
34
|
const ReportServerLauncherLive = Layer.unwrap(Path.Path.use((path) => path.fromFileUrl(new URL('./main.js', import.meta.url))).pipe(Effect.map((main) => ReportServerLauncher.layer(process.execPath, [main, SERVE_REPORTS_COMMAND]))));
|
|
33
35
|
/**
|
|
34
|
-
* The production wiring: the engine on top of the local adapters,
|
|
35
|
-
* project folder. It
|
|
36
|
-
* needs the platform (`FileSystem`, `Path`) from outside: `NodeServices` in production and tests.
|
|
36
|
+
* The production wiring: the engine on top of the local adapters, the report server and `setup`,
|
|
37
|
+
* for one project folder. It needs the platform (`FileSystem`, `Path`) from outside: `NodeServices` in production and tests.
|
|
37
38
|
*/
|
|
38
|
-
export const appLayer = (projectRoot) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// Starts nothing until
|
|
44
|
-
Layer.merge(
|
|
39
|
+
export const appLayer = (projectRoot) => {
|
|
40
|
+
const engine = engineLayer(projectRoot);
|
|
41
|
+
// What the report servers share runs with: the same engine as everything else.
|
|
42
|
+
const share = ShareSource.layer.pipe(Layer.provide(engine));
|
|
43
|
+
const operations = Operations.layer(projectRoot).pipe(Layer.provide(engine),
|
|
44
|
+
// Starts nothing until the MCP server first gives a report URL.
|
|
45
|
+
Layer.merge(ReportServer.layer(projectRoot).pipe(Layer.provide(share))),
|
|
46
|
+
// For `report --serve` and `walkthrough --serve`.
|
|
47
|
+
Layer.merge(share),
|
|
48
|
+
// Built first, so `RunningBuild` records the build this process started with.
|
|
49
|
+
Layer.provideMerge(UpdateCheckLive), Layer.provideMerge(PackageInfo.layer),
|
|
50
|
+
// Starts nothing until a CLI command first gives a report URL.
|
|
51
|
+
Layer.merge(ReportLinks.layer(projectRoot).pipe(Layer.provide(ReportServerLauncherLive))));
|
|
52
|
+
return Setup.layer(projectRoot).pipe(Layer.provide(PlaywrightDownloads.layer), Layer.provideMerge(operations));
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The engine on top of the local adapters (which it gives too), for one project folder; it needs
|
|
56
|
+
* `PackageInfo` (for the version) and the platform from outside.
|
|
57
|
+
*/
|
|
58
|
+
const engineLayer = (projectRoot) => Engine.layer.pipe(Layer.provideMerge(Layer.mergeAll(BrowserPlaywright, StorageLocal(projectRoot), AccountBookLocal(projectRoot), NotifierSilent, ReportRendererHtml, ProcessIdLive, AppVersionLive)));
|
|
59
|
+
/**
|
|
60
|
+
* What the detached report server (`serveDetached`) shares runs with: the engine of the project whose
|
|
61
|
+
* folder is `projectRoot`.
|
|
62
|
+
*/
|
|
63
|
+
export const detachedShareLayer = (projectRoot) => ShareSource.layer.pipe(Layer.provide(engineLayer(projectRoot)), Layer.provide(PackageInfo.layer));
|
|
45
64
|
/**
|
|
46
65
|
* Before a command: the line about a newer version (when one is known and due), and, when a check
|
|
47
66
|
* is due, a check of the registry in the background. Returns the wait for that check, which the
|
package/dist/cli/commands.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Path } from 'effect';
|
|
|
2
2
|
import { Command } from 'effect/cli';
|
|
3
3
|
import { ExitCode } from './exit-codes.js';
|
|
4
4
|
import { Operations } from './operations.js';
|
|
5
|
+
import { Setup } from './setup.js';
|
|
5
6
|
declare const ExitWith_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
6
7
|
readonly _tag: "ExitWith";
|
|
7
8
|
} & Readonly<A>;
|
|
@@ -10,5 +11,5 @@ export declare class ExitWith extends ExitWith_base<{
|
|
|
10
11
|
readonly code: ExitCode;
|
|
11
12
|
}> {
|
|
12
13
|
}
|
|
13
|
-
export declare const root: Command.Command<"screw-bugs", {}, {}, ExitWith, import("effect/FileSystem").FileSystem | Operations | import("./package-info.js").PackageInfo | Path.Path | import("effect/Stdio").Stdio>;
|
|
14
|
+
export declare const root: Command.Command<"screw-bugs", {}, {}, ExitWith, import("effect/FileSystem").FileSystem | Operations | import("./package-info.js").PackageInfo | Path.Path | Setup | import("effect/Stdio").Stdio>;
|
|
14
15
|
export {};
|
package/dist/cli/commands.js
CHANGED
|
@@ -10,6 +10,7 @@ import { allPassed, countsSentence, formatEvidence, formatFindings, serveMcp, }
|
|
|
10
10
|
import { Operations } from './operations.js';
|
|
11
11
|
import { ReportLinks } from './report-links.js';
|
|
12
12
|
import { fileUrl, startReportServer } from './report-server.js';
|
|
13
|
+
import { AGENT_IDS, DOWNLOAD_NAMES, Setup } from './setup.js';
|
|
13
14
|
/** Ends the command with this exit code; anything worth saying has already been printed. */
|
|
14
15
|
export class ExitWith extends Data.TaggedError('ExitWith') {
|
|
15
16
|
}
|
|
@@ -288,6 +289,78 @@ const init = Command.make('init', {
|
|
|
288
289
|
});
|
|
289
290
|
yield* flags.json ? printJson({ ok: true, path }) : Console.log(`Wrote ${path}`);
|
|
290
291
|
}))).pipe(Command.withDescription('Set up screw-bugs in this project (writes screw-bugs.json)'));
|
|
292
|
+
const changeText = {
|
|
293
|
+
added: (file) => `added to ${file}`,
|
|
294
|
+
updated: (file) => `updated in ${file}`,
|
|
295
|
+
unchanged: (file) => `already in ${file}`,
|
|
296
|
+
unreadable: (file) => `${file} left alone: setup cannot edit it safely (comments, or an unusual layout)`,
|
|
297
|
+
failed: (file) => `${file} could not be read or written`,
|
|
298
|
+
};
|
|
299
|
+
/** Agents named in the closing hint, joined as a list. */
|
|
300
|
+
const listed = (names) => names.length <= 1
|
|
301
|
+
? (names[0] ?? '')
|
|
302
|
+
: `${names.slice(0, -1).join(', ')} and ${names.at(-1) ?? ''}`;
|
|
303
|
+
const formatSetupHuman = (result) => {
|
|
304
|
+
const width = Math.max(...result.agents.map((agent) => agent.name.length), 'screw-bugs.json'.length);
|
|
305
|
+
const set = result.agents.filter((agent) => agent.entry === undefined);
|
|
306
|
+
return [
|
|
307
|
+
`MCP server: ${result.launch}`,
|
|
308
|
+
...result.agents.flatMap((agent) => [
|
|
309
|
+
`${agent.entry === undefined ? '✓' : '✗'} ${agent.name.padEnd(width)} ${changeText[agent.change](agent.file)}`,
|
|
310
|
+
...(agent.entry === undefined
|
|
311
|
+
? []
|
|
312
|
+
: [
|
|
313
|
+
` Add this to ${agent.file} yourself:`,
|
|
314
|
+
...agent.entry.split('\n').map((l) => ` ${l}`),
|
|
315
|
+
]),
|
|
316
|
+
]),
|
|
317
|
+
result.config.change === 'failed'
|
|
318
|
+
? `✗ ${'screw-bugs.json'.padEnd(width)} ${result.config.message ?? 'could not be written'}`
|
|
319
|
+
: `✓ ${'screw-bugs.json'.padEnd(width)} ${result.config.change === 'written' ? 'written' : 'already there, kept'}`,
|
|
320
|
+
...result.downloads.map((download) => `${download.ok ? '✓' : '✗'} Downloaded ${DOWNLOAD_NAMES[download.what]}${download.ok ? '' : ': failed'}`),
|
|
321
|
+
'',
|
|
322
|
+
formatDoctorHuman(result.doctor),
|
|
323
|
+
...(set.length > 0
|
|
324
|
+
? [
|
|
325
|
+
'',
|
|
326
|
+
`Restart ${listed(set.map((agent) => agent.name))} in this project (or reload their MCP servers) so they start screw-bugs.` +
|
|
327
|
+
(set.some((agent) => agent.id === 'claude')
|
|
328
|
+
? ' Claude Code asks once to approve the servers in .mcp.json.'
|
|
329
|
+
: '') +
|
|
330
|
+
(set.some((agent) => agent.id === 'codex')
|
|
331
|
+
? ' Codex reads .codex/config.toml only in a project it trusts.'
|
|
332
|
+
: ''),
|
|
333
|
+
]
|
|
334
|
+
: []),
|
|
335
|
+
...(result.detected
|
|
336
|
+
? [`To choose the agents yourself: setup --agent <${AGENT_IDS.join('|')}>, repeatable.`]
|
|
337
|
+
: []),
|
|
338
|
+
].join('\n');
|
|
339
|
+
};
|
|
340
|
+
const setup = Command.make('setup', {
|
|
341
|
+
json,
|
|
342
|
+
agent: Flag.ChoiceWithValue('agent', AGENT_IDS.map((id) => [id, id])).pipe(Flag.withDescription('An agent to set up (repeatable). Default: the ones found in this project or on the PATH'), Flag.atLeast(0)),
|
|
343
|
+
url: Flag.String('url').pipe(Flag.withDescription('Default URL to test, for a new screw-bugs.json'), Flag.optional),
|
|
344
|
+
noDownloads: Flag.Boolean('no-downloads').pipe(Flag.withDescription("Download nothing; doctor's report says what is missing"), Flag.withDefault(false)),
|
|
345
|
+
}, (flags) => Effect.gen(function* () {
|
|
346
|
+
const result = yield* (yield* Setup).run({
|
|
347
|
+
agents: flags.agent,
|
|
348
|
+
baseUrl: Option.getOrUndefined(flags.url),
|
|
349
|
+
downloads: !flags.noDownloads,
|
|
350
|
+
quiet: flags.json,
|
|
351
|
+
});
|
|
352
|
+
const incomplete = result.agents.some((agent) => agent.entry !== undefined);
|
|
353
|
+
const configFailed = result.config.change === 'failed';
|
|
354
|
+
yield* flags.json
|
|
355
|
+
? printJson({ ok: result.doctor.ok && !incomplete && !configFailed, ...result })
|
|
356
|
+
: Console.log(formatSetupHuman(result));
|
|
357
|
+
if (!result.doctor.ok)
|
|
358
|
+
return yield* new ExitWith({ code: ExitCode.NotReady });
|
|
359
|
+
if (configFailed)
|
|
360
|
+
return yield* new ExitWith({ code: ExitCode.Config });
|
|
361
|
+
if (incomplete)
|
|
362
|
+
return yield* new ExitWith({ code: ExitCode.SetupIncomplete });
|
|
363
|
+
})).pipe(Command.withDescription("Set up screw-bugs in this project with one command: registers the MCP server with the project's coding agents (Claude Code, Codex, Cursor, VS Code, OpenCode), writes screw-bugs.json and downloads Playwright's ffmpeg when missing"));
|
|
291
364
|
const runs = Command.make('runs', {
|
|
292
365
|
json,
|
|
293
366
|
limit: Flag.Int('limit').pipe(Flag.withDescription('How many runs to show'), Flag.withDefault(10)),
|
|
@@ -340,6 +413,7 @@ export const root = Command.make('screw-bugs').pipe(Command.withDescription('Loc
|
|
|
340
413
|
status,
|
|
341
414
|
answer,
|
|
342
415
|
mcp,
|
|
416
|
+
setup,
|
|
343
417
|
init,
|
|
344
418
|
stub('accounts', 'Manage the test accounts runs can log in with'),
|
|
345
419
|
report,
|
package/dist/cli/exit-codes.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export declare const ExitCode: {
|
|
|
21
21
|
* message (and `--json`) lists each with why; create them and start the run again.
|
|
22
22
|
*/
|
|
23
23
|
readonly FilesNeeded: 7;
|
|
24
|
+
/**
|
|
25
|
+
* `setup` could not add the MCP server to an agent's config (not plain JSON or TOML it can edit
|
|
26
|
+
* safely, or not writable), so it left the file alone. The output gives the entry to add.
|
|
27
|
+
*/
|
|
28
|
+
readonly SetupIncomplete: 8;
|
|
24
29
|
/** A bug in screw-bugs. */
|
|
25
30
|
readonly Internal: 70;
|
|
26
31
|
/**
|
package/dist/cli/exit-codes.js
CHANGED
|
@@ -21,6 +21,11 @@ export const ExitCode = {
|
|
|
21
21
|
* message (and `--json`) lists each with why; create them and start the run again.
|
|
22
22
|
*/
|
|
23
23
|
FilesNeeded: 7,
|
|
24
|
+
/**
|
|
25
|
+
* `setup` could not add the MCP server to an agent's config (not plain JSON or TOML it can edit
|
|
26
|
+
* safely, or not writable), so it left the file alone. The output gives the entry to add.
|
|
27
|
+
*/
|
|
28
|
+
SetupIncomplete: 8,
|
|
24
29
|
/** A bug in screw-bugs. */
|
|
25
30
|
Internal: 70,
|
|
26
31
|
/**
|
|
@@ -94,7 +94,7 @@ export interface UpdateCommand {
|
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* The npm dist-tag a copy follows: `next` for a prerelease of the `next` channel (a version like
|
|
97
|
-
* `0.1.1-next.57.gfa82ee8`, published
|
|
97
|
+
* `0.1.1-next.57.gfa82ee8`, published from main by `next.yml`), else `latest`.
|
|
98
98
|
*/
|
|
99
99
|
export type Channel = 'latest' | 'next';
|
|
100
100
|
/** The channel of `version`: `next` when its prerelease starts with `next`, else `latest`. */
|
package/dist/cli/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeServices } from '@effect/platform-node';
|
|
2
2
|
import { Effect, Option, Path, Schema, Stdio } from 'effect';
|
|
3
|
-
import { appLayer, runCli } from './app.js';
|
|
3
|
+
import { appLayer, detachedShareLayer, runCli } from './app.js';
|
|
4
4
|
import { ExitCode } from './exit-codes.js';
|
|
5
5
|
import { SERVE_REPORTS_COMMAND, serveDetached } from './report-links.js';
|
|
6
6
|
import { runMain } from './signals.js';
|
|
@@ -8,7 +8,8 @@ runMain(Effect.gen(function* () {
|
|
|
8
8
|
const args = yield* Stdio.Stdio.use((stdio) => stdio.args);
|
|
9
9
|
const path = yield* Path.Path;
|
|
10
10
|
// The hidden command a CLI command starts its detached report server with (see
|
|
11
|
-
// `ReportLinks`): the absolute path of the runs folder, nothing else; no app layer
|
|
11
|
+
// `ReportLinks`): the absolute path of the runs folder, nothing else; no app layer, only the
|
|
12
|
+
// engine to share runs with (the runs folder is `<project>/.screw-bugs/runs`).
|
|
12
13
|
if (args[0] === SERVE_REPORTS_COMMAND) {
|
|
13
14
|
const ServeReportsArgs = Schema.Tuple([
|
|
14
15
|
Schema.Literal(SERVE_REPORTS_COMMAND),
|
|
@@ -17,7 +18,8 @@ runMain(Effect.gen(function* () {
|
|
|
17
18
|
const decoded = yield* Schema.decodeUnknownEffect(ServeReportsArgs)(args).pipe(Effect.option);
|
|
18
19
|
if (Option.isNone(decoded))
|
|
19
20
|
return ExitCode.Usage;
|
|
20
|
-
|
|
21
|
+
const runs = decoded.value[1];
|
|
22
|
+
yield* serveDetached(runs).pipe(Effect.provide(detachedShareLayer(path.dirname(path.dirname(runs)))));
|
|
21
23
|
return ExitCode.Ok;
|
|
22
24
|
}
|
|
23
25
|
// With no arguments, `resolve` is the working directory: the project screw-bugs runs in.
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Context, Duration, Effect, FileSystem, Layer, Option, Path, Schema, Scope } from 'effect';
|
|
2
2
|
import { HttpServerRequest, HttpServerResponse, type HttpServerError } from 'effect/http';
|
|
3
|
+
import { type ShareRoutes } from './share.js';
|
|
3
4
|
import { Failure } from './failure.js';
|
|
4
5
|
/**
|
|
5
6
|
* A local HTTP server for reports, for browsers that cannot open `file://` (the ones built into
|
|
6
7
|
* coding tools). It binds 127.0.0.1 only and serves the runs folder read-only: only files with
|
|
7
8
|
* the extensions a report uses, never a directory listing, a dotfile, or anything outside the
|
|
8
9
|
* folder (also through symlinks). Range requests (206, 416) come from `HttpStaticServer`, so
|
|
9
|
-
* videos seek and play.
|
|
10
|
+
* videos seek and play. In a process that can share (see `ShareSource`), it also answers the
|
|
11
|
+
* Share button's routes (`src/cli/share.ts`), which put a run on screw-bugs Cloud after the person
|
|
12
|
+
* confirms it there.
|
|
10
13
|
*/
|
|
11
14
|
export declare const REPORT_HOST = "127.0.0.1";
|
|
12
15
|
/**
|
|
@@ -70,7 +73,7 @@ export declare const SERVED_TYPES: Readonly<Record<string, string>>;
|
|
|
70
73
|
* name (a Host check, so a web page cannot reach it through DNS rebinding). `port` may be a
|
|
71
74
|
* function, read per request, so the handler can be made before the server knows its port.
|
|
72
75
|
*/
|
|
73
|
-
export declare const makeReportApp: (root: string, port: number | (() => number), secret?: Uint8Array<ArrayBufferLike> | undefined) => Effect.Effect<Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest>, import("effect/PlatformError").PlatformError, FileSystem.FileSystem | import("effect/http/HttpPlatform").HttpPlatform | Path.Path>;
|
|
76
|
+
export declare const makeReportApp: (root: string, port: number | (() => number), secret?: Uint8Array<ArrayBufferLike> | undefined, share?: ShareRoutes | undefined) => Effect.Effect<Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest>, import("effect/PlatformError").PlatformError, FileSystem.FileSystem | import("effect/http/HttpPlatform").HttpPlatform | Path.Path>;
|
|
74
77
|
/** The URL of `file` (an absolute path inside `root`) on a server at `base`, or undefined. */
|
|
75
78
|
export declare const fileUrl: (path: Path.Path, base: string, root: string, file: string) => string | undefined;
|
|
76
79
|
/**
|
|
@@ -7,13 +7,16 @@ import { SecureRandom } from 'effect/crypto';
|
|
|
7
7
|
import { hex, hmacSha256, sha256 } from '../report/index.js';
|
|
8
8
|
import { runsDir } from '../store-local/index.js';
|
|
9
9
|
import { ExitCode } from './exit-codes.js';
|
|
10
|
+
import { makeShareRoutes, ShareSource } from './share.js';
|
|
10
11
|
import { Failure } from './failure.js';
|
|
11
12
|
/**
|
|
12
13
|
* A local HTTP server for reports, for browsers that cannot open `file://` (the ones built into
|
|
13
14
|
* coding tools). It binds 127.0.0.1 only and serves the runs folder read-only: only files with
|
|
14
15
|
* the extensions a report uses, never a directory listing, a dotfile, or anything outside the
|
|
15
16
|
* folder (also through symlinks). Range requests (206, 416) come from `HttpStaticServer`, so
|
|
16
|
-
* videos seek and play.
|
|
17
|
+
* videos seek and play. In a process that can share (see `ShareSource`), it also answers the
|
|
18
|
+
* Share button's routes (`src/cli/share.ts`), which put a run on screw-bugs Cloud after the person
|
|
19
|
+
* confirms it there.
|
|
17
20
|
*/
|
|
18
21
|
export const REPORT_HOST = '127.0.0.1';
|
|
19
22
|
/**
|
|
@@ -154,7 +157,7 @@ const requestSegments = (url) => {
|
|
|
154
157
|
* name (a Host check, so a web page cannot reach it through DNS rebinding). `port` may be a
|
|
155
158
|
* function, read per request, so the handler can be made before the server knows its port.
|
|
156
159
|
*/
|
|
157
|
-
export const makeReportApp = Effect.fnUntraced(function* (root, port, secret) {
|
|
160
|
+
export const makeReportApp = Effect.fnUntraced(function* (root, port, secret, share) {
|
|
158
161
|
const portNow = typeof port === 'number' ? () => port : port;
|
|
159
162
|
const fs = yield* FileSystem.FileSystem;
|
|
160
163
|
const path = yield* Path.Path;
|
|
@@ -210,6 +213,15 @@ export const makeReportApp = Effect.fnUntraced(function* (root, port, secret) {
|
|
|
210
213
|
const proof = identity(request.url);
|
|
211
214
|
if (proof)
|
|
212
215
|
return proof;
|
|
216
|
+
if (share && request.method === 'GET') {
|
|
217
|
+
const shared = yield* share({
|
|
218
|
+
url: request.url,
|
|
219
|
+
headers: request.headers,
|
|
220
|
+
base: `http://${host}`,
|
|
221
|
+
});
|
|
222
|
+
if (shared)
|
|
223
|
+
return shared;
|
|
224
|
+
}
|
|
213
225
|
const file = yield* canonical(request.url);
|
|
214
226
|
if (!file)
|
|
215
227
|
return notFound;
|
|
@@ -267,7 +279,9 @@ const holdingServer = () => {
|
|
|
267
279
|
*/
|
|
268
280
|
export const listen = (root, port, secret, options = {}) => Effect.gen(function* () {
|
|
269
281
|
let bound = port;
|
|
270
|
-
|
|
282
|
+
// The Share button's routes, when this process can share (see `ShareSource`).
|
|
283
|
+
const share = yield* makeShareRoutes(root);
|
|
284
|
+
const app = yield* makeReportApp(root, () => bound, secret, share);
|
|
271
285
|
// Requests that arrive before the handler is attached are held.
|
|
272
286
|
const holding = holdingServer();
|
|
273
287
|
const server = yield* NodeHttpServer.make(() => holding.server, { port, host: REPORT_HOST });
|
|
@@ -388,7 +402,12 @@ export class ReportServer extends Context.Service()('screw-bugs/ReportServer') {
|
|
|
388
402
|
return { urlOf: () => Effect.succeed(undefined) };
|
|
389
403
|
const scope = yield* Scope.Scope;
|
|
390
404
|
const fs = yield* FileSystem.FileSystem;
|
|
391
|
-
|
|
405
|
+
// The share source too, when the app has one, so its servers answer the Share button.
|
|
406
|
+
const share = yield* Effect.serviceOption(ShareSource);
|
|
407
|
+
const platform = yield* Effect.context();
|
|
408
|
+
const services = Option.isSome(share)
|
|
409
|
+
? Context.add(platform, ShareSource, share.value)
|
|
410
|
+
: platform;
|
|
392
411
|
const lock = yield* Semaphore.make(1);
|
|
393
412
|
/** This process's server on the preferred port, once it has one. */
|
|
394
413
|
let preferred;
|