glitchless-playtest 0.2.0 → 0.4.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.
package/README.md CHANGED
@@ -1,16 +1,103 @@
1
1
  # glitchless-playtest
2
2
 
3
- Playtest every change. Autoplay bots play your web game (Three.js, Phaser or plain WebGL) on a saved
4
- baseline and on the current code, and [Glitchless](https://github.com/glitchless-gg/glitchless) compares
5
- the two runs: slow frames, render and update time, draw calls, hitches, errors, deaths and level
6
- completion. A regression exits with code 1, so it can gate a pull request.
3
+ Playtest every change, and check any web game. Your game's autoplay bot plays it on a saved baseline and on the current code, and
4
+ [Glitchless](https://github.com/glitchless-gg/glitchless) compares the two: slow frames, frame time, render and
5
+ update time, draw calls, hitches, errors and crashes. A regression exits with code 1, so it can gate a pull request.
6
+ It plays Unity, Godot, Unreal and GameMaker builds from their command line ([engine builds](#engine-builds)), Roblox
7
+ games in Roblox Studio ([Roblox](#roblox)), and web games (Three.js, Phaser, Babylon.js, PlayCanvas or plain WebGL) in
8
+ Chrome.
7
9
 
8
10
  ```bash
9
11
  npx glitchless-playtest --save baseline # before changing the code
10
12
  npx glitchless-playtest # after: compares with "baseline"
11
13
  ```
12
14
 
13
- ## What it needs
15
+ It also checks any web game someone posted, with nothing installed in it ([game checks](#game-checks)):
16
+
17
+ ```bash
18
+ npx glitchless-playtest --check https://someone.itch.io/their-game
19
+ ```
20
+
21
+ ## Engine builds
22
+
23
+ A Unity, Godot, Unreal or GameMaker build with the Glitchless SDK measures itself: started with
24
+ `--glitchless-measure=SECONDS`, it times every frame for that long, prints the numbers as one line of JSON and quits.
25
+ Give the playtest the command that starts the build, an exported build or the engine with the project path, in
26
+ `glitchless.playtest.json`:
27
+
28
+ ```json
29
+ {
30
+ "command": ["godot", "--path", "."],
31
+ "scenarios": [
32
+ { "name": "seed 7", "params": { "autoplay": true, "seed": 7 }, "seconds": 10 },
33
+ { "name": "seed 21", "params": { "autoplay": true, "seed": 21, "level": 2 }, "seconds": 10 }
34
+ ]
35
+ }
36
+ ```
37
+
38
+ Each scenario starts the build once, one at a time, with its `params` as the game's own flags
39
+ (`--autoplay --seed=7`; `-autoplay -seed=7` in Unreal and GameMaker; after a `--` in Godot), its `args` as they are,
40
+ and the measure flags. No browser and no Glitchless server are needed. Without `scenarios`, it runs
41
+ `--autoplay --seed=7`, then `--autoplay --seed=21`.
42
+
43
+ - **The game needs an autoplay mode**: a bot that starts when the game is given `--autoplay`, plays the same way for
44
+ the same `--seed`, starts levels as it goes, and keeps playing for the whole measure. A game that quits sooner
45
+ prints no measurement, and the error says to lower `seconds` or let the bot keep playing. With the default
46
+ scenarios, a game that starts no level is taken to have no autoplay mode, and the error says how to add one for
47
+ its engine. The Godot demo in the Glitchless repo, `godot/demo/demo.gd`, is a working example with its
48
+ `godot/glitchless.playtest.json`.
49
+ - **Run it with a window.** A headless run draws nothing and runs frames uncapped, so its frame times mean little.
50
+ When the build says it ran headless (Godot's `--headless`, GameMaker), frame times only warn; update time, errors,
51
+ crashes and growth still count.
52
+ - `command` is a list or one string (`"godot --path ."`). Paths are from the project folder; a macOS `.app` runs the
53
+ executable inside it. The engine is told from the command and from what an export leaves beside it; set `engine`
54
+ (`godot`, `unity`, `unreal`, `gamemaker`) when it can't be.
55
+ - `seconds` (default 10) and `warmup` (seconds before measuring: default 0, so errors and stutter while loading count;
56
+ Unity 1, since its memory counters read nothing on the first frames) can be set per scenario or for all. `max_s`
57
+ (default warmup + seconds + 120) kills a build that froze; that run counts as crashed.
58
+ - The build writes its measurement to a file the playtest passes (`--glitchless-out`) too, which is how a Unity player
59
+ on macOS, whose output goes to its log, is read. If a build's file sandbox keeps it from writing there, set
60
+ `measure_file` to where it saves it (GameMaker: `glitchless/measure.json` in its save area).
61
+
62
+ On top of the web checks, an engine build compares frame time p99, GPU time (Unity, Unreal, Godot off Metal), Unreal's
63
+ RHI thread, Unity's physics, garbage collection and what grew over a run (objects, nodes, instances, MB: a leak), and
64
+ with two or more scenarios, each run against the same run of the baseline, and the level each run ended on. Errors
65
+ match across builds even when their numbers or line numbers moved. A crashed run is listed with the last lines it
66
+ printed. For CI, `--baseline-command` runs the other build as the baseline first.
67
+
68
+ ## Roblox
69
+
70
+ A Roblox game has no command line, so its runs are play tests in the open Roblox Studio, driven over Studio's own MCP
71
+ server (Assistant → … → Manage MCP Servers → **Enable Studio as MCP server**):
72
+
73
+ ```json
74
+ {
75
+ "engine": "roblox",
76
+ "studio": "My Obby",
77
+ "scenarios": [
78
+ { "name": "seed 7", "params": { "autoplay": true, "seed": 7 }, "max_s": 90 },
79
+ { "name": "seed 21", "params": { "autoplay": true, "seed": 21 }, "max_s": 90 }
80
+ ]
81
+ }
82
+ ```
83
+
84
+ Each scenario sets its `params` as attributes of Workspace, starts a play test, waits until `done_when` (Luau, run on
85
+ the play test's server; by default `workspace:GetAttribute("GlitchlessPlaytestDone") == true`) or `max_s`, stops it,
86
+ and puts the attributes back as they were. The SDK sends the play test's sessions where the game's `Glitchless.init`
87
+ says, and the playtest reads them back from that Glitchless server (`--server`): the players' sessions, and the
88
+ server's own for its script errors. So the game needs an autoplay mode that reads those attributes, marks its sessions
89
+ `sessionType = "synthetic"` and says when it's done; [the Roblox SDK's README](https://github.com/glitchless-gg/glitchless/tree/main/roblox#ask-your-agent)
90
+ has the code.
91
+
92
+ - `studio` is part of the open Studio's place name. With one Studio open it can be left out; with several, the
93
+ playtest refuses to guess, so it never plays another place.
94
+ - `service` is read from the place's `Glitchless.init`; set it when that can't be read.
95
+ - `luau` runs in Edit before each play test, for anything an attribute can't do (pointing a test place at a server).
96
+ - `studio_mcp` is StudioMCP's command, when Studio isn't installed where it usually is.
97
+ - It stops with what to do when Studio isn't reachable, is already in a play test, the place has no Glitchless module
98
+ or has Allow HTTP Requests off, or no session arrives.
99
+
100
+ ## Web games
14
101
 
15
102
  - **Your game running**, by default at `http://localhost:5173/`, with the Glitchless SDK
16
103
  ([`glitchless`](https://www.npmjs.com/package/glitchless)) reporting to a Glitchless server.
@@ -29,6 +116,44 @@ hide it, so they fail a run on their own: update CPU is the game's update code,
29
116
  where the engine lets it (Phaser's scene updates and physics). The Phaser demo in the Glitchless repo,
30
117
  `apps/phaser-demo`, has a working `glitchless.playtest.json`.
31
118
 
119
+ ## Game checks
120
+
121
+ A game check shows a game's maker what Glitchless would do for their game, before they install anything. Glitchless's
122
+ bots play any web game, an itch.io page, a github.io, Vercel or Netlify page or any address, and make a report in
123
+ plain words, a dashboard made for that game and, on Glitchless Cloud, an unlisted link to it, with three sentences to
124
+ send its maker.
125
+
126
+ ```bash
127
+ GLITCHLESS_URL=https://api.glitchless.gg GLITCHLESS_API_KEY=gl_ws_… npx glitchless-playtest --check https://someone.itch.io/their-game
128
+ ```
129
+
130
+ - **Nothing in the game.** The browser SDK is added to the page before it runs, its sessions marked as bots
131
+ (synthetic), so they never count as players. The engine is named where it can be (Three.js, Phaser, Babylon.js,
132
+ PlayCanvas, Unity, Godot, GameMaker, Construct, GDevelop, Defold, PixiJS and others, or plain canvas and WebGL), and
133
+ Three.js, Phaser, Babylon.js and PlayCanvas are handed to their Glitchless adapters, as installing it would.
134
+ - **Two ways of playing**, one after the other, in real Chrome: desktop on this computer's GPU (90 s by default,
135
+ `--seconds`, at most 240), then a throttled phone: the same computer with its CPU slowed 4×, a phone's touch screen
136
+ (sideways for a wide game) and a 4G-like connection, for two thirds as long. With loading, 3 to 6 minutes.
137
+ - **A player that needs no help.** It clicks Play, then tries the arrow keys, WASD, the mouse, click and drag and the
138
+ usual action keys (taps, holds and swipes on the phone), and spends its time on what changes the screen. With
139
+ `--ai` and an `ANTHROPIC_API_KEY`, a Claude model (Haiku) picks the inputs from screenshots instead
140
+ (`npm install @anthropic-ai/sdk`; at most 40 screenshots a profile). Each step is kept with the frames, memory,
141
+ errors and level of that moment, so the report can say when a freeze came.
142
+ - **Where it goes.** With a workspace key (`gl_ws_…`, from `npx glitchless-mcp login`) on Glitchless Cloud, it makes a
143
+ game named after the page (`--name` to choose; an existing game by that name is reused), its dashboard and a share
144
+ link that shows the check's bot runs, for 30 days. On the open-source server it saves the dashboard there, with no
145
+ link. The report, `message.txt` (the link and three sentences), `check.json` and screenshots go in
146
+ `.glitchless/checks/<game>-<time>/`. Check a game on a public site against a public server: Chrome keeps a public
147
+ page from sending to a server on your own computer or network, and the report says so when that happens.
148
+ - **It asks first.** It reads the site's robots.txt (as `GlitchlessCheck`) and stops where bots are asked to stay out,
149
+ stops on a 401, 403 or 429 or a page that checks for a human, never plays more than a few minutes from one computer,
150
+ closes popups and comes back from links that leave the game. A game that already sends to Glitchless has its own
151
+ sends held back during the check.
152
+ - **Private.** The check's game and board are in your workspace. Don't use it to rank games.
153
+
154
+ The numbers come from this computer, not from the game's players, and the report says so. Running checks for anyone
155
+ on the web would need a GPU machine in the cloud; this runs where you run it.
156
+
32
157
  ## Options
33
158
 
34
159
  ```
@@ -37,14 +162,30 @@ where the engine lets it (Phaser's scene updates and physics). The Phaser demo i
37
162
  --compare-only A B compare two saved runs without playing
38
163
  --baseline-url URL play another running build as the baseline first (for CI)
39
164
  --game URL game to play (default http://localhost:5173/)
165
+ --command CMD run an engine build instead (Unity, Godot, Unreal, GameMaker): an exported
166
+ build, or the engine with the project path, e.g. "godot --path ."
167
+ --baseline-command CMD run another engine build as the baseline first (for CI)
168
+ --engine NAME godot, unity, unreal or gamemaker, when the command's name doesn't say;
169
+ roblox plays the place open in Roblox Studio, over Studio's MCP server
170
+ --studio NAME Roblox: which open Studio (part of its place's name), when several are open
40
171
  --server URL Glitchless server (default $GLITCHLESS_URL or http://localhost:7777)
41
172
  --service NAME game service name (default: read from the page)
42
173
  --api-key KEY Glitchless API key (default $GLITCHLESS_API_KEY)
43
174
  --quick play only the first scenario
44
- --max SECONDS cap each run
175
+ --max SECONDS cap each run (an engine build: the seconds it measures)
45
176
  --channel NAME browser: chrome (default) or chromium
46
177
  --headed show the browser windows
47
178
  --json print the full result as JSON instead of markdown
179
+
180
+ Game check (any web game, with nothing installed in it):
181
+ --check URL play the game at URL on a desktop and a throttled phone, then make its
182
+ report, dashboard and (Glitchless Cloud) share link
183
+ --name NAME the game's name in Glitchless (default: its page's title)
184
+ --seconds N seconds of desktop play (default 90, at most 240; the phone plays 2/3 as long)
185
+ --profiles LIST desktop, phone or desktop,phone (default)
186
+ --ai a Claude model picks the inputs (ANTHROPIC_API_KEY, @anthropic-ai/sdk)
187
+ --out DIR where the report goes (default .glitchless/checks/<game>-<time>)
188
+ --no-share no share link
48
189
  ```
49
190
 
50
191
  Saved runs go in `.glitchless/playtest/` (add it to `.gitignore`).
@@ -53,7 +194,8 @@ Saved runs go in `.glitchless/playtest/` (add it to `.gitignore`).
53
194
 
54
195
  A `glitchless.playtest.json` in the project root can set any default: `game`, `server`, `scenarios`,
55
196
  `thresholds`, `done_when` (a JavaScript expression that ends a run when it's true), `viewport` and
56
- `runs_dir`.
197
+ `runs_dir`; for an engine build, `command`, `engine`, `seconds`, `warmup` and `measure_file`; for Roblox, `engine`,
198
+ `studio`, `luau` and `studio_mcp`.
57
199
 
58
200
  ```json
59
201
  {
@@ -70,12 +212,13 @@ on a fast machine doesn't fail a build.
70
212
  ## From code or an agent
71
213
 
72
214
  ```js
73
- import { playtest } from 'glitchless-playtest';
215
+ import { playtest, gameCheck } from 'glitchless-playtest';
74
216
  const result = await playtest({ saveAs: 'baseline' }); // later: playtest({ compareTo: 'baseline' })
217
+ const check = await gameCheck({ url: 'https://someone.itch.io/their-game', server, apiKey }); // → { report, dm, share, files }
75
218
  ```
76
219
 
77
220
  The [glitchless-mcp](https://www.npmjs.com/package/glitchless-mcp) server exposes the same thing to
78
- coding agents as the `glitchless_playtest` tool.
221
+ coding agents as the `glitchless_playtest` tool, and a game check as its `check_url`.
79
222
 
80
223
  ## License
81
224
 
@@ -5,10 +5,17 @@
5
5
  // glitchless-playtest # after: compares with "baseline", exits 1 on a regression
6
6
  // glitchless-playtest --compare-only baseline latest
7
7
  // glitchless-playtest --baseline-url http://localhost:5174/ # CI: main build vs this branch's build
8
+ // glitchless-playtest --command "godot --path ." --save baseline # an engine build instead of a web game
9
+ // glitchless-playtest --engine roblox --studio "My Obby" --save baseline # a play test in Roblox Studio
10
+ // glitchless-playtest --check https://someone.itch.io/their-game # a game check: any web game, nothing installed
8
11
  //
9
- // Needs the game and a Glitchless server running, and Playwright installed in the game project.
12
+ // A web game needs the game and a Glitchless server running, and Playwright installed in the game project.
13
+ // An engine build (Unity, Godot, Unreal, GameMaker) needs only the build, with the Glitchless SDK in it.
14
+ // A Roblox game needs its place open in Roblox Studio with Studio's MCP server on, and the Glitchless server it sends to.
15
+ // A game check needs Playwright and a Glitchless server; with a workspace key (gl_ws_…) on Glitchless Cloud it also makes
16
+ // the game and an unlisted share link.
10
17
 
11
- import { playtest, compareSaved } from '../src/index.js';
18
+ import { playtest, compareSaved, gameCheck } from '../src/index.js';
12
19
 
13
20
  const HELP = `Usage: glitchless-playtest [options]
14
21
 
@@ -17,16 +24,32 @@ const HELP = `Usage: glitchless-playtest [options]
17
24
  --compare-only A B compare two saved runs without playing
18
25
  --baseline-url URL play another running build as the baseline first (for CI)
19
26
  --game URL game to play (default http://localhost:5173/)
27
+ --command CMD run an engine build instead (Unity, Godot, Unreal, GameMaker): an exported
28
+ build, or the engine with the project path, e.g. "godot --path ."
29
+ --baseline-command CMD run another engine build as the baseline first (for CI)
30
+ --engine NAME godot, unity, unreal or gamemaker, when the command's name doesn't say;
31
+ roblox plays the place open in Roblox Studio, over Studio's MCP server
32
+ --studio NAME Roblox: which open Studio (part of its place's name), when several are open
20
33
  --server URL Glitchless server (default $GLITCHLESS_URL or http://localhost:7777)
21
34
  --service NAME game service name (default: read from the page)
22
35
  --api-key KEY Glitchless API key (default $GLITCHLESS_API_KEY)
23
36
  --quick play only the first scenario
24
- --max SECONDS cap each run
37
+ --max SECONDS cap each run (an engine build: the seconds it measures)
25
38
  --channel NAME browser: chrome (default, uses your real GPU) or chromium
26
39
  --headed show the browser windows
27
40
  --json print the full result as JSON instead of markdown
28
41
 
29
- Scenarios, thresholds and URLs can also be set in glitchless.playtest.json.
42
+ Game check (any web game, with nothing installed in it):
43
+ --check URL play the game at URL (an itch.io page, github.io, Vercel, Netlify…) on a
44
+ desktop and a throttled phone, then make its report, dashboard and share link
45
+ --name NAME the game's name in Glitchless (default: its page's title)
46
+ --seconds N seconds of desktop play (default 90, at most 240; the phone plays 2/3 as long)
47
+ --profiles LIST desktop, phone or desktop,phone (default)
48
+ --ai a Claude model picks the inputs from screenshots (ANTHROPIC_API_KEY, @anthropic-ai/sdk)
49
+ --out DIR where the report and screenshots go (default .glitchless/checks/<game>-<time>)
50
+ --no-share no share link
51
+
52
+ Scenarios, thresholds, URLs and the command can also be set in glitchless.playtest.json.
30
53
  Exit code: 0 pass (or nothing to compare), 1 regression, 2 error.`;
31
54
 
32
55
  const argv = process.argv.slice(2);
@@ -42,17 +65,36 @@ if (has('help') || has('h')) {
42
65
  }
43
66
 
44
67
  const log = (msg) => process.stderr.write(`${msg}\n`);
45
- const config = { game: val('game'), server: val('server'), service: val('service'), api_key: val('api-key'), channel: val('channel'), headed: has('headed') || undefined };
68
+ const config = { game: val('game'), command: val('command'), engine: val('engine'), studio: val('studio'), server: val('server'), service: val('service'), api_key: val('api-key'), channel: val('channel'), headed: has('headed') || undefined };
46
69
 
47
70
  try {
48
71
  let result;
49
72
  const only = argv.indexOf('--compare-only');
73
+ if (val('check')) {
74
+ const r = await gameCheck({
75
+ url: val('check'),
76
+ server: config.server,
77
+ apiKey: config.api_key,
78
+ name: val('name'),
79
+ seconds: val('seconds') ? Number(val('seconds')) : undefined,
80
+ profiles: val('profiles') ? val('profiles').split(',').map((s) => s.trim()) : undefined,
81
+ ai: has('ai'),
82
+ outDir: val('out'),
83
+ share: !has('no-share'),
84
+ channel: config.channel,
85
+ headed: config.headed,
86
+ log,
87
+ });
88
+ if (has('json')) console.log(JSON.stringify(r, null, 2));
89
+ else console.log(`${r.report}\n\n---\nTo send its maker:\n\n${r.dm}\n\nSaved in ${r.dir}`);
90
+ process.exit(0);
91
+ }
50
92
  if (only >= 0) {
51
93
  const [a, b] = argv.slice(only + 1, only + 3);
52
94
  if (!a || !b) throw new Error('--compare-only needs two saved run names, e.g. --compare-only baseline latest');
53
95
  result = compareSaved(a, b, { config });
54
96
  } else {
55
- result = await playtest({ saveAs: val('save'), compareTo: val('compare'), baselineUrl: val('baseline-url'), quick: has('quick'), maxSeconds: val('max') ? Number(val('max')) : undefined, config, log });
97
+ result = await playtest({ saveAs: val('save'), compareTo: val('compare'), baselineUrl: val('baseline-url'), baselineCommand: val('baseline-command'), quick: has('quick'), maxSeconds: val('max') ? Number(val('max')) : undefined, config, log });
56
98
  }
57
99
  if (has('json')) console.log(JSON.stringify(result, null, 2));
58
100
  else console.log(result.report);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "glitchless-playtest",
3
- "version": "0.2.0",
4
- "description": "Playtest bots for game observability: autoplay bots play your web game (Three.js, Phaser) on the current code and on a saved baseline, and Glitchless flags what got slower or started breaking.",
3
+ "version": "0.4.0",
4
+ "description": "Playtest bots for game observability: your game's autoplay bot plays a Unity, Godot, Unreal or GameMaker build, a Roblox game in Roblox Studio, or a web game (Three.js, Phaser, Babylon.js, PlayCanvas) in Chrome, on the current code and on a saved baseline, and Glitchless flags what got slower or started breaking.",
5
5
  "keywords": [
6
6
  "playtesting",
7
7
  "playtest",
@@ -13,6 +13,11 @@
13
13
  "performance",
14
14
  "regression-testing",
15
15
  "playwright",
16
+ "unity",
17
+ "godot",
18
+ "unreal-engine",
19
+ "gamemaker",
20
+ "roblox",
16
21
  "threejs",
17
22
  "phaser",
18
23
  "web-games",