glitchless-mcp 0.17.0 → 0.19.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 +3 -3
- package/package.json +2 -2
- package/src/context.js +27 -10
- package/src/setup-guide.js +249 -0
- package/src/skills.js +18 -0
- package/src/tools/core.js +18 -13
- package/src/tools/dashboard.js +12 -6
- package/src/tools/playtest.js +11 -8
- package/src/tools/workspace.js +82 -10
package/README.md
CHANGED
|
@@ -92,7 +92,7 @@ above go in its environment.
|
|
|
92
92
|
| --- | --- |
|
|
93
93
|
| `glitchless_list_games` | Which games report to the server, with their versions and environments; signed in to a workspace, every game in it with its client token |
|
|
94
94
|
| `glitchless_sign_in` | Connect to a Glitchless Cloud workspace: a link and a code for the person to approve |
|
|
95
|
-
| `glitchless_create_game` | A new game in the workspace, with its client token and intake URL; `demo: true` makes the demo game (a week of sample play); `rename` (with `game`) renames one instead, its client token, service and data unchanged |
|
|
95
|
+
| `glitchless_create_game` | A new game in the workspace, with its client token and intake URL (a name already there returns that game); with `engine`, or `files` (what's in the game's folder), also the steps that add Glitchless to the game's code for its engine, for a new game (`name`) or one already there (`game`): the instrument skill, for an agent without it; `demo: true` makes the demo game (a week of sample play); `rename` (with `game`) renames one instead, its client token, service and data unchanged |
|
|
96
96
|
| `glitchless_share_links` | A read-only link to one board page, for a dev log, Discord or a game's "Live stats" link (`page`); lists them, and revokes one (`revoke`) |
|
|
97
97
|
| `glitchless_triage` | The headline numbers (sessions, players, crash-free sessions, frame time, rage quits), then ranked findings: stutter per level and what it correlates with, leaks, top errors, difficulty spikes. Start here |
|
|
98
98
|
| `glitchless_mark_known` | Mark a finding the game's owner accepts as known, so the weekly summary stops listing it (triage shows it last, with the note); with `player` or `session` instead, the team's own play, read as testers in every tool; `clear: true` removes the mark |
|
|
@@ -102,7 +102,7 @@ above go in its environment.
|
|
|
102
102
|
| `glitchless_get_error` | One error issue, with its stack and the gameplay before it |
|
|
103
103
|
| `glitchless_player_funnel` | Per level: starts, completions, deaths and their causes, disconnects, rage quits; split by what describes the attempt (tier, party size, class), runs per level, and retention; with `hotspots`, where players die on a level, in a zone or anywhere in the game (a hub with no levels), clustered in world coordinates |
|
|
104
104
|
| `glitchless_events` | The game's own events (whatever it sends with `track`, and the streams it counts with `count`): counts, attribute breakdowns, rates, distributions and funnels, and the session properties it sets |
|
|
105
|
-
| `glitchless_dashboard` | The game's dashboard: its pages, and one board's panels with their numbers |
|
|
105
|
+
| `glitchless_dashboard` | The game's dashboard: its pages, and one board's panels with their numbers; with `guide: true`, how to design one for the game (the dashboard skill, for an agent without it) |
|
|
106
106
|
| `glitchless_set_dashboard` | Save the game's pages: boards of panels in its own words, and the built-in views it keeps; and, each alone if you like, the boards' accent, logo and banner (the header behind each board's title) and a level's, zone's or the whole game's heatmap background (a picture from a file or base64 and its world bounds; over the hosted server a file is answered with a 10-minute, single-use upload link to send it to with one curl). Needs a key with the dashboard scope |
|
|
107
107
|
| `glitchless_compare_versions` | Two or more versions side by side, in the game's own stats first, to confirm a fix with real players |
|
|
108
108
|
| `glitchless_session` | One play session in detail, with its whole event timeline |
|
|
@@ -112,7 +112,7 @@ above go in its environment.
|
|
|
112
112
|
| `glitchless_match` | A multiplayer game's matches (the worst by lag or disconnects on request), or one match from every side, 30 seconds at a time: each player's ping, frame time and outcome, the server's ticks, and whether the whole lobby lagged at once (the server) or one player did (their connection) |
|
|
113
113
|
| `glitchless_network` | Ping, lag (play over 150 ms), packet loss and disconnects by level, version, platform, kind of connection and region, with the worst matches and the network findings |
|
|
114
114
|
| `glitchless_servers` | A game's dedicated servers in server mode: servers running now and their players, tick time against its budget by players connected, map and version, crashes with the matches they ended, and memory that climbs. Every other tool reads them with service `<game>.server` |
|
|
115
|
-
| `glitchless_playtest` |
|
|
115
|
+
| `glitchless_playtest` | The game's autoplay bot plays it and the run is compared with a saved baseline ([glitchless-playtest](https://www.npmjs.com/package/glitchless-playtest)): a Unity, Godot, Unreal or GameMaker build from its `command`, a Roblox game in the open Roblox Studio (`engine: "roblox"`, over Studio's MCP server), or a web game in Chrome (needs Playwright in the game project) |
|
|
116
116
|
| `glitchless_deck` | Build the game, send it to the paired Steam Deck, add it to the Deck's library and optionally start it ([glitchless-deck](https://www.npmjs.com/package/glitchless-deck); pair once with `npx glitchless-deck pair`); with `measure: true`, measure a Unity, Godot or Unreal build there and compare it with a saved run |
|
|
117
117
|
|
|
118
118
|
The reads take `hours`, `version`, `env` (e.g. `prod`), `session_type` (`user` for players only, `tester` for people on TestFlight and other test builds, `synthetic` for bots, playtests and store test devices, `all`) and `props`, the session properties the game sets (`{ rank: "diamond" }`, or a list of values). Unless `env` or `session_type` is given, findings read the production sessions of players and say so; the other numbers count every session in the window.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glitchless-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"mcpName": "io.github.glitchless-gg/glitchless",
|
|
5
5
|
"description": "Coding agents can build a game. They can't see anyone play it. Glitchless lets them. The MCP server for Glitchless, game observability for coding agents: Claude Code, Codex, Cursor and others read real players' stutters, crashes, custom metrics and ranked findings in Unity, Godot, Unreal, Three.js, Roblox, Phaser and GameMaker games, build the game's own dashboard, and run playtest bots.",
|
|
6
6
|
"keywords": [
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@modelcontextprotocol/server": "^2.4.0",
|
|
69
69
|
"zod": "^4.6.7",
|
|
70
|
-
"glitchless-playtest": "^0.
|
|
70
|
+
"glitchless-playtest": "^0.3.0",
|
|
71
71
|
"glitchless-deck": "^0.1.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
package/src/context.js
CHANGED
|
@@ -9,7 +9,7 @@ import path from 'node:path';
|
|
|
9
9
|
import { McpServer } from '@modelcontextprotocol/server';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
|
|
12
|
-
export const VERSION = '0.
|
|
12
|
+
export const VERSION = '0.19.0';
|
|
13
13
|
|
|
14
14
|
// Where `glitchless-mcp login` keeps its workspace key: { url, token, workspace: { id, name }, scopes }.
|
|
15
15
|
export const CREDENTIALS_FILE = path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'glitchless', 'credentials.json');
|
|
@@ -88,9 +88,22 @@ export async function workspaceGames(fresh = false) {
|
|
|
88
88
|
// The intake address games send to, as the last game list gave it.
|
|
89
89
|
export const workspaceIntake = () => conn().games?.intake ?? null;
|
|
90
90
|
|
|
91
|
-
// How to add Glitchless to a game, in any engine: the setup steps a coding agent follows (docs/agent-setup-prompt.md)
|
|
91
|
+
// How to add Glitchless to a game, in any engine: the setup steps a coding agent follows (docs/agent-setup-prompt.md),
|
|
92
|
+
// for a connection without glitchless_create_game, which hands over the steps for the game's engine itself.
|
|
92
93
|
export const SETUP_URL = 'https://raw.githubusercontent.com/glitchless-gg/glitchless/main/docs/agent-setup-prompt.md';
|
|
93
94
|
|
|
95
|
+
// Whether this call's connection shows the tools that need the manage scope (over HTTP, by the scopes the person gave
|
|
96
|
+
// it; on stdio every tool shows).
|
|
97
|
+
export const canManage = () => {
|
|
98
|
+
const scopes = calls.getStore()?.scopes;
|
|
99
|
+
return !scopes || scopes.includes('manage');
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Where an agent gets the steps that add Glitchless to a game's code, as the end of a sentence: from
|
|
103
|
+
// glitchless_create_game (setup-guide.js) where the connection has it, else the setup prompt.
|
|
104
|
+
export const setupSteps = () =>
|
|
105
|
+
canManage() ? "glitchless_create_game with the game's name and its engine (or files: what's in the game's folder) returns the steps for that engine" : `the setup steps are at ${SETUP_URL}`;
|
|
106
|
+
|
|
94
107
|
export async function projectFor(game) {
|
|
95
108
|
const c = conn();
|
|
96
109
|
const want = game || c.game;
|
|
@@ -101,7 +114,7 @@ export async function projectFor(game) {
|
|
|
101
114
|
list = await workspaceGames(true);
|
|
102
115
|
hit = find();
|
|
103
116
|
}
|
|
104
|
-
if (!list.length) throw new Error(`This workspace has no games yet: glitchless_list_games says how to make one (or the demo game, with a week of sample play)
|
|
117
|
+
if (!list.length) throw new Error(`This workspace has no games yet: glitchless_list_games says how to make one (or the demo game, with a week of sample play). To add Glitchless to a game: ${setupSteps()}.`);
|
|
105
118
|
if (!hit) throw new Error(want ? `No game called "${want}" in this workspace. Games: ${list.map((g) => g.name).join(', ')}.` : `Name the game this is about (game: "<name>"): ${list.map((g) => g.name).join(', ')}.`);
|
|
106
119
|
c.game = hit.id;
|
|
107
120
|
return hit.id;
|
|
@@ -140,8 +153,8 @@ export async function query(name, params = {}) {
|
|
|
140
153
|
return data;
|
|
141
154
|
}
|
|
142
155
|
|
|
143
|
-
// The tool call being answered: the game it names, the server answering it,
|
|
144
|
-
// windowNote().
|
|
156
|
+
// The tool call being answered: the game it names, the server answering it, the scopes its connection shows tools for
|
|
157
|
+
// (over HTTP), and the meta of its last query, for windowNote().
|
|
145
158
|
const calls = new AsyncLocalStorage();
|
|
146
159
|
|
|
147
160
|
// How the window was answered, when an agent should know: by day past 31 days, what is estimated, what a
|
|
@@ -186,7 +199,7 @@ export async function resolveService(service) {
|
|
|
186
199
|
if (service) return service;
|
|
187
200
|
if (defaultService()) return defaultService();
|
|
188
201
|
const { services } = await query('services');
|
|
189
|
-
if (!services?.length) throw new Error(`No game has sent Glitchless any data yet. glitchless_list_games gives each game's client token and what to do next
|
|
202
|
+
if (!services?.length) throw new Error(`No game has sent Glitchless any data yet. glitchless_list_games gives each game's client token and what to do next. To add the SDK: ${setupSteps()}. Data shows a few minutes after a level is played.`);
|
|
190
203
|
return services.sort((a, b) => b.last_seen - a.last_seen)[0].service;
|
|
191
204
|
}
|
|
192
205
|
|
|
@@ -273,14 +286,14 @@ const gameField = z.string().optional().describe('The game, by name or id, when
|
|
|
273
286
|
export function createServer({ remote = false, scopes = null, connection: c = null } = {}) {
|
|
274
287
|
const server = new McpServer(
|
|
275
288
|
{ name: 'glitchless', title: 'Glitchless', version: VERSION, websiteUrl: 'https://www.glitchless.gg', icons: [{ src: 'https://app.glitchless.gg/brand/glitchless-icon-512.png', mimeType: 'image/png', sizes: ['512x512'] }] },
|
|
276
|
-
{ instructions: instructions(remote) },
|
|
289
|
+
{ instructions: instructions(remote, !scopes || scopes.includes('manage')) },
|
|
277
290
|
);
|
|
278
291
|
for (const t of tools) {
|
|
279
292
|
if ((remote && t.local) || (scopes && !scopes.includes(t.scope))) continue;
|
|
280
293
|
const { inputSchema = {}, ...config } = t.config;
|
|
281
294
|
server.registerTool(t.name, { ...config, title: titleOf(t), inputSchema: z.object({ game: gameField, ...inputSchema }) }, (args = {}, ctx) => {
|
|
282
295
|
const run = () =>
|
|
283
|
-
calls.run({ game: args.game, server, remote }, async () => {
|
|
296
|
+
calls.run({ game: args.game, server, remote, scopes }, async () => {
|
|
284
297
|
try {
|
|
285
298
|
return await t.handler(args, ctx);
|
|
286
299
|
} catch (err) {
|
|
@@ -293,9 +306,13 @@ export function createServer({ remote = false, scopes = null, connection: c = nu
|
|
|
293
306
|
return server;
|
|
294
307
|
}
|
|
295
308
|
|
|
296
|
-
|
|
309
|
+
// manage: whether the connection shows glitchless_create_game, which hands over the steps that add Glitchless to a game.
|
|
310
|
+
function instructions(remote, manage = true) {
|
|
297
311
|
return [
|
|
298
312
|
'Glitchless is observability for games made with Unity, Godot, Unreal, Three.js, Roblox, Phaser, Babylon.js, PlayCanvas or GameMaker.',
|
|
313
|
+
manage
|
|
314
|
+
? "To add Glitchless to a game (the person asks you to set it up, or for performance monitoring, analytics or telemetry in their game), call glitchless_create_game first, before changing the game's code, with the game's name and its engine, or files: what you find in the game's folder. It makes the game, or finds the one already here by that name, and returns that engine's steps with where the game sends and its client token in them."
|
|
315
|
+
: `To add Glitchless to a game, follow the setup steps at ${SETUP_URL}: this connection may only read, so the person makes the game in Glitchless, and glitchless_list_games then has its client token.`,
|
|
299
316
|
remote
|
|
300
317
|
? "You're connected to the person's Glitchless workspace: glitchless_list_games lists every game (and says what to do when there is none, or a game has no data yet), glitchless_create_game makes one and hands back its client token (demo: true makes the demo game, Zoomies with a week of sample play, to try every tool on before a real game sends data), every tool takes game (by name), and glitchless_share_links makes a read-only link to a board. If a game hasn't sent data yet, say so first and give the person its next step (glitchless_list_games has it) before answering anything else."
|
|
301
318
|
: "On Glitchless Cloud, glitchless_sign_in connects you to the person's whole workspace (they approve a code in the browser): then glitchless_list_games lists every game, glitchless_create_game makes one and hands back its client token, every tool takes game (by name), and glitchless_share_links makes a read-only link to a board.",
|
|
@@ -309,7 +326,7 @@ function instructions(remote) {
|
|
|
309
326
|
...(remote
|
|
310
327
|
? ['After shipping a fix (bump the version passed to Glitchless.init), use glitchless_compare_versions to confirm it with real players.']
|
|
311
328
|
: [
|
|
312
|
-
'Before changing game code, run glitchless_playtest with save_as "baseline"; after the change, run glitchless_playtest again to compare, and treat a FAIL as unfinished work. After shipping a fix (bump the version passed to Glitchless.init), use glitchless_compare_versions to confirm it with real players.',
|
|
329
|
+
'Before changing game code, run glitchless_playtest with save_as "baseline"; after the change, run glitchless_playtest again to compare, and treat a FAIL as unfinished work. It plays a web game in Chrome, runs a Unity, Godot, Unreal or GameMaker build from its command (command, e.g. ["godot", "--path", "."]) with the game\'s autoplay flags, or plays a Roblox game (engine "roblox") in the open Roblox Studio, which needs Studio\'s MCP server on. After shipping a fix (bump the version passed to Glitchless.init), use glitchless_compare_versions to confirm it with real players.',
|
|
313
330
|
'If the game is running in a browser with WebMCP connected, its live tools (glitchless_live_performance, glitchless_measure, glitchless_inspect_scene, and game tools such as zoomies_load_level) let you reproduce and measure issues directly. Unity, Godot, Unreal and GameMaker builds measure themselves when run with --glitchless-measure=SECONDS (-glitchless-measure in Unreal and GameMaker); in the Unreal editor, Unreal MCP with the Glitchless Toolset has a Measure tool.',
|
|
314
331
|
]),
|
|
315
332
|
].join(' ');
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// How to add Glitchless to a game, for an agent that has this MCP server (the hosted one at api.glitchless.gg/mcp, or
|
|
2
|
+
// glitchless-mcp) and no Glitchless skill: someone who connected Glitchless in claude.ai or ChatGPT, opened a coding
|
|
3
|
+
// agent in their game's folder and said "Set up Glitchless for my game in this folder". glitchless_create_game's
|
|
4
|
+
// engine and files (tools/workspace.js) answer with the instrument skill cut to the game's engine: where the game
|
|
5
|
+
// sends, the skill's settings, that engine's reference with the sections of other references it points to, and the
|
|
6
|
+
// game's own metrics. glitchless_dashboard's guide (tools/dashboard.js) answers with the dashboard skill. The text is
|
|
7
|
+
// skills.js, the copy scripts/sync-agent-plugin.mjs writes from plugin/glitchless/skills, so every server carries it
|
|
8
|
+
// and nothing is fetched. This file only shapes text: the tools look up the game and the connection.
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { TEXTS } from './skills.js';
|
|
11
|
+
|
|
12
|
+
const INSTRUMENT = 'plugin/glitchless/skills/instrument/SKILL.md';
|
|
13
|
+
const REFS = 'plugin/glitchless/skills/instrument/references/';
|
|
14
|
+
const DASHBOARD = 'plugin/glitchless/skills/dashboard/SKILL.md';
|
|
15
|
+
const REPO = 'https://github.com/glitchless-gg/glitchless';
|
|
16
|
+
const KIT = 'git clone --depth 1 https://github.com/glitchless-gg/glitchless ~/.glitchless';
|
|
17
|
+
|
|
18
|
+
// The engines, one per reference, in the order of the skill's own table: { id: 'godot', name: 'Godot', ref }.
|
|
19
|
+
export const ENGINES = [...new Set([...TEXTS[INSTRUMENT].matchAll(/\]\(references\/(\w+)\.md\)/g)].map((m) => m[1]))]
|
|
20
|
+
.filter((id) => TEXTS[`${REFS}${id}.md`])
|
|
21
|
+
.map((id) => ({ id, name: TEXTS[`${REFS}${id}.md`].match(/^# (.+)$/m)[1], ref: `${REFS}${id}.md` }));
|
|
22
|
+
|
|
23
|
+
// What an engine's steps need beyond its reference: where its SDK is in the agent kit (a clone of the Glitchless repo
|
|
24
|
+
// the references copy from), and for Godot the parts of the addon's README its reference sends the agent to (not
|
|
25
|
+
// "Web exports": the reference has what differs there, and the kit has the whole README).
|
|
26
|
+
const EXTRAS = {
|
|
27
|
+
godot: { kit: 'godot/addons/glitchless', readme: { path: 'godot/addons/glitchless/README.md', parts: ['Install', 'Use', 'Off in debug builds', "The player's off switch", 'For agents: `--glitchless-measure`'] } },
|
|
28
|
+
unreal: { kit: 'unreal/Plugins/Glitchless' },
|
|
29
|
+
roblox: { kit: 'roblox' },
|
|
30
|
+
gamemaker: { kit: 'gamemaker' },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// The signs of each engine in a project's files and package.json dependencies, a native engine's first: its project
|
|
34
|
+
// file wins over a package.json kept for tooling.
|
|
35
|
+
const SIGNS = [
|
|
36
|
+
['unreal', /\.uproject$/],
|
|
37
|
+
['godot', /(^|\/)project\.godot$/],
|
|
38
|
+
['gamemaker', /\.yyp$/],
|
|
39
|
+
['unity', /(^|\/)(projectsettings(\/projectversion\.txt)?|projectversion\.txt|packages\/manifest\.json|assembly-csharp\.csproj)$|\.unity$/],
|
|
40
|
+
['roblox', /\.project\.json$|(^|\/)wally\.toml$|\.rbxlx?$|\.(server|client)\.luau?$/],
|
|
41
|
+
['threejs', /^(three|@react-three\/fiber|three(\.module)?(\.min)?\.js)$/],
|
|
42
|
+
['phaser', /^phaser((\.min)?\.js)?$/],
|
|
43
|
+
['babylon', /^(@babylonjs\/core|babylonjs|babylon(\.max)?\.js)$/],
|
|
44
|
+
['playcanvas', /^playcanvas((-stable)?(\.min)?\.js)?$/],
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
// → { engine, sign, also }: the engine a list of files and dependencies names, the entry that named it, and any other
|
|
48
|
+
// engine they name too.
|
|
49
|
+
export function engineFrom(files = []) {
|
|
50
|
+
const found = new Map();
|
|
51
|
+
for (const raw of files) {
|
|
52
|
+
const file = String(raw).trim().toLowerCase().replace(/\\/g, '/').replace(/^["'`]+|["'`,]+$/g, '');
|
|
53
|
+
const dep = file.match(/^(@?[^@\s:"']+)/)?.[1] ?? file;
|
|
54
|
+
for (const [id, sign] of SIGNS) if (!found.has(id) && [file, dep, path.posix.basename(dep)].some((f) => sign.test(f))) found.set(id, String(raw).trim());
|
|
55
|
+
}
|
|
56
|
+
const [engine, ...also] = SIGNS.map(([id]) => id).filter((id) => found.has(id));
|
|
57
|
+
return { engine: engine ?? null, sign: engine ? found.get(engine) : null, also };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// The engine a call names (engine) or its files do: { engine: one of ENGINES or null, sign, also: other engines' names }.
|
|
61
|
+
export function pickEngine({ engine, files } = {}) {
|
|
62
|
+
const found = engine ? { engine, sign: null, also: [] } : engineFrom(files);
|
|
63
|
+
return { engine: ENGINES.find((e) => e.id === found.engine) ?? null, sign: found.sign, also: found.also.map((id) => ENGINES.find((e) => e.id === id)).filter(Boolean) };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ── Markdown ──────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
const LINK = /\[([^\]]+)\]\(([^)\s]+)\)/g;
|
|
69
|
+
const slug = (title) => title.toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, '').replace(/\s/g, '-');
|
|
70
|
+
const body = (md) => md.replace(/^---\n[\s\S]*?\n---\n+/, '');
|
|
71
|
+
const nameOf = (p) => TEXTS[p].match(/^# (.+)$/m)?.[1] ?? p;
|
|
72
|
+
const resolve = (from, href) => path.posix.normalize(path.posix.join(path.posix.dirname(from), href));
|
|
73
|
+
|
|
74
|
+
// A file's sections, one per heading outside code: { level, title, slug, text (to the next heading at its level or
|
|
75
|
+
// above), intro (to the next heading of any level) }.
|
|
76
|
+
function sections(md) {
|
|
77
|
+
const lines = md.split('\n');
|
|
78
|
+
const heads = [];
|
|
79
|
+
let code = false;
|
|
80
|
+
lines.forEach((line, i) => {
|
|
81
|
+
if (/^\s*(```|~~~)/.test(line)) code = !code;
|
|
82
|
+
const m = !code && line.match(/^(#{1,6}) (.+)$/);
|
|
83
|
+
if (m) heads.push({ i, level: m[1].length, title: m[2].trim() });
|
|
84
|
+
});
|
|
85
|
+
return heads.map((h, n) => ({
|
|
86
|
+
level: h.level,
|
|
87
|
+
title: h.title,
|
|
88
|
+
slug: slug(h.title),
|
|
89
|
+
text: lines.slice(h.i, heads.slice(n + 1).find((x) => x.level <= h.level)?.i ?? lines.length).join('\n').trimEnd(),
|
|
90
|
+
intro: lines.slice(h.i, heads[n + 1]?.i ?? lines.length).join('\n').trimEnd(),
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// The sections of other files a text points to (Phaser's "as for Three.js, step 4b"), and the ones those point to:
|
|
95
|
+
// [{ file, sections }] in each file's own order. `own` are the files the guide carries whole.
|
|
96
|
+
function borrowed(from, text, own) {
|
|
97
|
+
const want = new Map();
|
|
98
|
+
const queue = [[from, text]];
|
|
99
|
+
while (queue.length) {
|
|
100
|
+
const [src, md] = queue.shift();
|
|
101
|
+
for (const [, , href] of md.matchAll(LINK)) {
|
|
102
|
+
const [file, hash] = href.split('#');
|
|
103
|
+
if (!file || !hash || /^[a-z]+:/i.test(href)) continue;
|
|
104
|
+
const target = resolve(src, file);
|
|
105
|
+
if (own.has(target) || !TEXTS[target] || want.get(target)?.has(hash)) continue;
|
|
106
|
+
const s = sections(TEXTS[target]).find((x) => x.slug === hash);
|
|
107
|
+
if (!s) continue;
|
|
108
|
+
want.set(target, (want.get(target) ?? new Set()).add(hash));
|
|
109
|
+
queue.push([target, s.text]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return [...want].map(([file, slugs]) => ({ file, sections: sections(TEXTS[file]).filter((s) => slugs.has(s.slug)) }));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Links in a text from `from`: one to a file or section the guide carries becomes its words ("As for Three.js"), or
|
|
116
|
+
// its heading where the words are a file name; any other goes to GitHub (the agent has no copy of the repo to follow a
|
|
117
|
+
// relative link into).
|
|
118
|
+
function relink(text, from, carried) {
|
|
119
|
+
return text.replace(LINK, (all, label, href) => {
|
|
120
|
+
if (/^[a-z]+:/i.test(href)) return all;
|
|
121
|
+
const [file, hash = ''] = href.split('#');
|
|
122
|
+
const target = file ? resolve(from, file) : from;
|
|
123
|
+
if (!carried.has(target) && !carried.has(`${target}#${hash}`)) return `[${label}](${REPO}/blob/main/${target}${hash ? `#${hash}` : ''})`;
|
|
124
|
+
if (!/\.md$/.test(label)) return label;
|
|
125
|
+
return `the "${(hash && sections(TEXTS[target]).find((s) => s.slug === hash)?.title) || nameOf(target)}" part of this guide`;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ── The guides ────────────────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
// Where the game sends, as the tool found it for this connection:
|
|
132
|
+
// { cloud: true, workspace, intake, game: { name, client_token } or null, others: [names], can_make, blocked, dashboard }
|
|
133
|
+
// Glitchless Cloud, signed in to a workspace: the game the call made or named, or how to get one (blocked: why
|
|
134
|
+
// the game the call named couldn't be made, such as a plan with no room for another);
|
|
135
|
+
// { server: url } a Glitchless server somewhere else, which this MCP server reads with no workspace;
|
|
136
|
+
// { local: url } a Glitchless server on this computer.
|
|
137
|
+
function sending(where, engine) {
|
|
138
|
+
const head = '## Where this game sends\n\nThese go where the steps below put the intake URL and client token (their examples show a local server, http://localhost:7777 and gl_pub_dev).';
|
|
139
|
+
const pub = "It's public and can only send data, so it may live in the game's source. A key that starts gl_sk_ or gl_ws_ never goes in the game.";
|
|
140
|
+
if (where.cloud) {
|
|
141
|
+
const here = where.others?.length ? ` Games already here: ${where.others.join(', ')}; to set one of those up, pass game with its name instead.` : '';
|
|
142
|
+
const token = where.game
|
|
143
|
+
? where.game.client_token
|
|
144
|
+
? `${where.game.client_token} (${where.game.name}'s). ${pub}`
|
|
145
|
+
: `${where.game.name} has no active client token: ask the person to make one in Glitchless (${where.dashboard ?? 'the dashboard'}, Settings → Keys & access).`
|
|
146
|
+
: where.blocked
|
|
147
|
+
? `none yet: the game wasn't made (${where.blocked.replace(/\.$/, '')}).${where.others?.length ? ` If this game is one already here (${where.others.join(', ')}), call glitchless_create_game again with game set to its name and engine: "${engine.id}", and the steps come with its client token. Otherwise tell the person why, and ask which they want.` : ' Tell the person why.'}`
|
|
148
|
+
: where.can_make
|
|
149
|
+
? `none yet. Call glitchless_create_game again with name (the game's name, as players know it) and engine: "${engine.id}": it makes the game and returns these steps with its client token.${here}`
|
|
150
|
+
: `none yet, and this connection may only read, so it can't make the game: ask the person to add it in Glitchless (${where.dashboard ?? 'the dashboard'}), then call this again with game set to its name. Or they connect again with "Create games and share links" ticked.${here}`;
|
|
151
|
+
return [
|
|
152
|
+
head,
|
|
153
|
+
'',
|
|
154
|
+
`Glitchless Cloud${where.workspace ? `, workspace ${where.workspace}` : ''}:`,
|
|
155
|
+
`- intake URL: ${where.intake}`,
|
|
156
|
+
`- client token: ${token}`,
|
|
157
|
+
`- In this server's tools, name the game: game: "${where.game?.name ?? "<the game's name>"}".`,
|
|
158
|
+
].join('\n');
|
|
159
|
+
}
|
|
160
|
+
if (where.server) {
|
|
161
|
+
return [head, '', `- intake URL: ${where.server}, the Glitchless server this MCP server reads`, `- client token: the game's public one (gl_pub_…): one of that server's GLITCHLESS_CLIENT_TOKENS, or on Glitchless Cloud the one on the game's page in Glitchless. Ask the person for it. ${pub}`].join('\n');
|
|
162
|
+
}
|
|
163
|
+
return [
|
|
164
|
+
head,
|
|
165
|
+
'',
|
|
166
|
+
`This MCP server reads a Glitchless server on this computer (${where.local}) and isn't signed in to Glitchless Cloud.`,
|
|
167
|
+
"- If the person uses Glitchless Cloud (app.glitchless.gg), sign this server in first: glitchless_sign_in (they approve a code in the browser), or `npx -y glitchless-mcp login` in a terminal. Then call glitchless_create_game again, with the game's name and the engine, for the cloud's intake URL and the game's client token.",
|
|
168
|
+
`- Otherwise: intake URL ${where.local}, client token gl_pub_dev. Check that ${where.local}/v1/health answers. If it doesn't, start a server: with Docker, \`docker run -d --name glitchless -p 7777:7777 -v glitchless-data:/data ghcr.io/glitchless-gg/glitchless\` (\`docker start glitchless\` if that container exists); without, in the agent kit (\`${KIT}\`), \`npm install && npm run build\`, then \`npm run server\` in the background.`,
|
|
169
|
+
].join('\n');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// An engine's steps: where the game sends, getting the SDK, the skill's opening and settings with the engine table
|
|
173
|
+
// cut to this game, the engine's own reference (with, for Godot, the README parts it sends the agent to), what it
|
|
174
|
+
// borrows from other references, and the skill's last sections (the game's own metrics, a jam room, the report).
|
|
175
|
+
// picked: what pickEngine answered; where: sending()'s.
|
|
176
|
+
export function instrumentGuide({ engine, sign, also = [] }, where) {
|
|
177
|
+
const extras = EXTRAS[engine.id] ?? {};
|
|
178
|
+
const [top, settings, ...rest] = sections(body(TEXTS[INSTRUMENT])).filter((s) => s.level <= 2);
|
|
179
|
+
const ref = body(TEXTS[engine.ref]);
|
|
180
|
+
const readme = extras.readme ? sections(TEXTS[extras.readme.path]).filter((s) => extras.readme.parts.includes(s.title)) : [];
|
|
181
|
+
const lent = borrowed(engine.ref, ref, new Set([INSTRUMENT, engine.ref]));
|
|
182
|
+
const carried = new Set([INSTRUMENT, engine.ref, ...readme.map((s) => `${extras.readme.path}#${s.slug}`), ...lent.flatMap((b) => b.sections.map((s) => `${b.file}#${s.slug}`))]);
|
|
183
|
+
|
|
184
|
+
// The skill's table of every engine becomes the one line about this game.
|
|
185
|
+
const lines = settings.text.split('\n');
|
|
186
|
+
const table = lines.findIndex((l) => l.startsWith('|'));
|
|
187
|
+
const end = lines.findIndex((l, i) => i > table && !l.startsWith('|'));
|
|
188
|
+
if (table >= 0) lines.splice(table, end - table, `This game: ${engine.name}${sign ? ` (${sign})` : ''}. Its steps follow these settings${readme.length ? `: the addon's README first, then "${nameOf(engine.ref)}"` : `, under "${nameOf(engine.ref)}"`}.`);
|
|
189
|
+
|
|
190
|
+
const out = [
|
|
191
|
+
`# Add Glitchless to this ${engine.name} game`,
|
|
192
|
+
'',
|
|
193
|
+
`These are the steps of Glitchless's instrument skill, the one in the Glitchless plugin for Claude Code, Codex and Cursor, cut to ${engine.name}. Work through them in order, in the game's folder. Where they say to follow the \`dashboard\` skill, call glitchless_dashboard with guide: true.`,
|
|
194
|
+
'',
|
|
195
|
+
sending(where, engine),
|
|
196
|
+
];
|
|
197
|
+
if (extras.kit) {
|
|
198
|
+
out.push('', '## Get the SDK', '', `The ${engine.name} steps copy files from the Glitchless agent kit, a copy of the Glitchless repo kept outside the game's folder so it never gets committed. Get it first:`, '', '```bash', KIT, '```', '', `If ~/.glitchless is already there, run \`git -C ~/.glitchless pull\` instead. The ${engine.name} SDK is at ~/.glitchless/${extras.kit}${extras.readme ? `, with its whole README, which the ${engine.name} steps quote below` : ''}.`);
|
|
199
|
+
}
|
|
200
|
+
out.push('', relink(top.intro, INSTRUMENT, carried), '', relink(lines.join('\n'), INSTRUMENT, carried));
|
|
201
|
+
// The README comes before the reference, as the skill's table orders them: it installs the addon and wires the game.
|
|
202
|
+
if (readme.length) {
|
|
203
|
+
out.push('', `# From the ${engine.name} addon's README`, '', `Start here: the parts of ~/.glitchless/${extras.readme.path} that install the addon and wire it into the game. The "${nameOf(engine.ref)}" steps after them add the rest; the file itself has more (Steam, flags, errors, phones).`);
|
|
204
|
+
// "Use" without its subsections: the reference below has the ones that matter, in fewer words.
|
|
205
|
+
for (const s of readme) out.push('', relink(s.title === 'Use' ? s.intro : s.text, extras.readme.path, carried));
|
|
206
|
+
}
|
|
207
|
+
out.push('', relink(ref, engine.ref, carried));
|
|
208
|
+
for (const b of lent) {
|
|
209
|
+
out.push('', `# From the ${nameOf(b.file)} steps`, '', `The ${engine.name} steps above point here.`);
|
|
210
|
+
for (const s of b.sections) out.push('', relink(s.text, b.file, carried));
|
|
211
|
+
}
|
|
212
|
+
for (const s of rest) out.push('', relink(s.text, INSTRUMENT, carried));
|
|
213
|
+
if (also.length) out.push('', `(The files also name ${also.map((e) => e.name).join(' and ')}. If this game is made with that instead, call glitchless_create_game again with engine: "${also[0].id}".)`);
|
|
214
|
+
return out.join('\n');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Before the engine is known: the skill's table of what to look for, with each engine's id.
|
|
218
|
+
export function findEngine(files) {
|
|
219
|
+
const rows = sections(body(TEXTS[INSTRUMENT])).find((s) => s.level === 2).text.split('\n').filter((l) => l.startsWith('|'));
|
|
220
|
+
const table = rows.map((row, i) => {
|
|
221
|
+
const cells = row.split('|').slice(1, -1).map((c) => c.trim());
|
|
222
|
+
const id = i === 0 ? 'engine:' : i === 1 ? '---' : `\`${cells[2].match(/references\/(\w+)\.md/)?.[1]}\``;
|
|
223
|
+
return `| ${cells[0]} | ${cells[1]} | ${id} |`;
|
|
224
|
+
});
|
|
225
|
+
return [
|
|
226
|
+
files?.length ? `None of these names an engine Glitchless has an SDK for: ${files.slice(0, 20).join(', ')}${files.length > 20 ? ', …' : ''}. Nothing was made.\n` : '',
|
|
227
|
+
"To add Glitchless to a game, find its engine first. In the game's folder, look for:",
|
|
228
|
+
'',
|
|
229
|
+
...table,
|
|
230
|
+
'',
|
|
231
|
+
'Then call glitchless_create_game again with engine, or with files: the names of the files at the project\'s root and its package.json dependencies (for example ["project.godot"], or ["package.json", "phaser", "vite"]).',
|
|
232
|
+
'',
|
|
233
|
+
`Glitchless has SDKs for these engines only. For a game made with something else, tell the person so; a game can still send the wire format itself (${REPO}/blob/main/docs/SPEC.md#2-wire-format).`,
|
|
234
|
+
].join('\n').trimStart();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// The dashboard skill, with the references it sends the agent to.
|
|
238
|
+
export function dashboardGuide() {
|
|
239
|
+
const refs = Object.keys(TEXTS).filter((p) => p.startsWith(`${path.posix.dirname(DASHBOARD)}/references/`));
|
|
240
|
+
const carried = new Set([DASHBOARD, ...refs]);
|
|
241
|
+
return [
|
|
242
|
+
"# Design this game's Glitchless dashboard",
|
|
243
|
+
'',
|
|
244
|
+
"These are the steps of Glitchless's dashboard skill, the one in the Glitchless plugin, with its references after it. The game should send data first: if it doesn't, call glitchless_create_game with game and engine for the steps that add Glitchless to it.",
|
|
245
|
+
'',
|
|
246
|
+
relink(body(TEXTS[DASHBOARD]), DASHBOARD, carried),
|
|
247
|
+
...refs.flatMap((p) => ['', relink(body(TEXTS[p]), p, carried)]),
|
|
248
|
+
].join('\n');
|
|
249
|
+
}
|