@homie-rocks/studio 0.19.2 → 0.20.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/lib/scaffold.mjs CHANGED
@@ -104,7 +104,7 @@ directory lists its games; homie.rocks does not host them.
104
104
 
105
105
  | Path | What it is |
106
106
  | --- | --- |
107
- | \`games/<id>/\` | One game: \`game.json\` (id, name, blurb, players, round length), \`index.html\`, \`src/main.ts\`. |
107
+ | \`games/<id>/\` | One game: \`game.json\` (id, name, blurb, players, round length), \`index.html\`, \`src/main.ts\`; and, when it has them, \`tunables.json\` (the numbers that shape how it feels: the Game Lab's sliders, kept values written back) and \`lab.json\` (the Game Lab's takes). |
108
108
  | \`music/\`, \`videos/\` | Songs, scores, loops; trailers, music videos, cutscenes. \`manifest.json\` lists each one (\`node_modules/@homie-rocks/studio/media/MEDIA.md\`); a published entry gets a page at \`/music/<slug>/\` or \`/videos/<slug>/\`. Without storage the site serves each file itself (up to 25 MiB). Once the studio has storage (see below), its big media (over 1 MiB, or left out of git) lives in its own R2: every deploy uploads it, checks it by SHA-256 and serves it from R2 at the same address. Large files never go into git. The Homie plugin's \`music\` and \`video\` skills make them. |
109
109
  | \`posts/\` | The studio's news and drops: one markdown file each (\`posts/2026-09-30-we-are-live.md\`: \`title:\`, \`date:\`, \`summary:\`, and \`game:\` / \`song:\` / \`video:\` to link one). They are the site's Posts, with Atom and JSON feeds. |
110
110
  | \`site/\` | The studio's site: its look (\`theme.json\`), and anything of its own that wins over the generated pages (\`site/README.md\`); the Worker (\`src/worker.mjs\`) and its D1 migrations. |
@@ -140,6 +140,12 @@ studio's pinned copy, never a registry lookup of the bare name.
140
140
  per frame, time to playable, what it downloads, the heap, netplay messages a second (files under \`.perf/\`). The
141
141
  Homie plugin's \`perf\` skill runs the whole loop: one change at a time, kept only when it is better beyond the noise
142
142
  and \`check\` still passes, and a report in \`perf/<id>/\`.
143
+ - \`npx --no-install homie-studio lab <id>\` — the Game Lab, on this computer (run it in the background; stop it with
144
+ \`lab --stop\`): one take of a move (\`games/<id>/lab.json\`) played in the working tree beside the last commit, on
145
+ one clock, slowed down or a frame at a time, with the phases, graphs and tunables the game reports
146
+ (\`@homie-rocks/studio/lab\`). \`lab check <id>\` plays it headless and writes the numbers and a contact sheet. The
147
+ Homie plugin's \`lab\` skill runs the whole loop: instrument and commit first, change how it feels, keep what the
148
+ person likes.
143
149
  - \`npx --no-install homie-studio deploy --plan\` — says what deploy will create on Cloudflare and what it
144
150
  costs, and changes nothing. Tell the person before the first deploy.
145
151
  - \`npm run deploy\` — the site on this studio's Cloudflare: one Worker, one D1 database, two
package/lib/studio.mjs CHANGED
@@ -103,6 +103,18 @@ export function starters() {
103
103
  });
104
104
  }
105
105
 
106
+ /**
107
+ * A game's Game Lab takes (lab.json) seed its saves by the game's id (`homie-saves.local.<id>`, saves/saves.ts): a copy
108
+ * under a new id renames them, so a take's saved hero is still found.
109
+ */
110
+ function renameTakeSaves(dir, from, id) {
111
+ const file = join(dir, 'lab.json');
112
+ if (!existsSync(file) || from === id) return;
113
+ const text = readFileSync(file, 'utf8');
114
+ const next = text.split(`"homie-saves.local.${from}"`).join(`"homie-saves.local.${id}"`);
115
+ if (next !== text) writeFileSync(file, next);
116
+ }
117
+
106
118
  /** `homie-studio game new <id> --from <starter> --name "<Name>"`: a starter copied in as this studio's own game. */
107
119
  export function newGame(root, id, { from = 'gem-rush', name } = {}) {
108
120
  if (!GAME_ID.test(String(id ?? '')) || RESERVED_IDS.has(id)) throw new Error(`a game id is lowercase letters, digits and hyphens, up to 40, and not one of ${[...RESERVED_IDS].join(', ')} (got ${JSON.stringify(id)})`);
@@ -121,6 +133,7 @@ export function newGame(root, id, { from = 'gem-rush', name } = {}) {
121
133
  writeFileSync(join(dest, 'game.json'), `${JSON.stringify(meta, null, 2)}\n`);
122
134
  const main = join(dest, meta.entry ?? 'src/main.ts');
123
135
  if (existsSync(main)) writeFileSync(main, readFileSync(main, 'utf8').replace(new RegExp(`game: '${from}'`, 'g'), `game: '${id}'`));
136
+ renameTakeSaves(dest, from, id);
124
137
  const html = join(dest, 'index.html');
125
138
  if (name && existsSync(html)) writeFileSync(html, readFileSync(html, 'utf8').replace(/<title>[^<]*<\/title>/, `<title>${String(name).replace(/[<&]/g, '')}</title>`));
126
139
  return { ok: true, command: 'game new', id, from, dir: dest, files: readdirSync(dest, { recursive: true }).map(String) };
@@ -174,5 +187,6 @@ export async function remixGame(root, source, id, { name } = {}) {
174
187
  writeFileSync(join(dest, 'game.json'), `${JSON.stringify(meta, null, 2)}\n`);
175
188
  const main = join(dest, meta.entry ?? 'src/main.ts');
176
189
  if (existsSync(main) && from) writeFileSync(main, readFileSync(main, 'utf8').replace(new RegExp(`game: '${from}'`, 'g'), `game: '${id}'`));
190
+ if (from) renameTakeSaves(dest, from, id);
177
191
  return { ok: true, command: 'game remix', id, from: String(url), credit: meta.remixOf.credit, page: meta.remixOf.page, license, files: wrote };
178
192
  }
@@ -850,6 +850,43 @@
850
850
  }
851
851
  }
852
852
  }
853
+ },
854
+ "0.20.0": {
855
+ "files": {
856
+ "CLAUDE.md": "ddf2b2a0376202f6",
857
+ "README.md": "684b3cca8001673c",
858
+ "HANDOFF.md": "ce7a8fd91c6bbee2",
859
+ "games/README.md": "5ad32fe80c61f117",
860
+ "music/README.md": "a3dc042dadd39df8",
861
+ "videos/README.md": "16babc3437d5545b",
862
+ "posts/README.md": "37841aae476bd540",
863
+ "site/README.md": "ca131cd0472464fb",
864
+ "site/src/worker.mjs": "ca3f1630f2420ad3"
865
+ },
866
+ "sections": {
867
+ "AGENTS.md": {
868
+ "(intro)": "214aa46eb3a895d5",
869
+ "## Layout": "43a4c5bf07db36f9",
870
+ "## Commands (all through the pinned CLI in node_modules)": "d80ec56e4b4fc4c6",
871
+ "## The site": "ab922bb6bde23293",
872
+ "## Making games": "a8a893eeada33bf5",
873
+ "## The Game Codex and progress": "0738ef719cef3a4c",
874
+ "## Running live games (the back office)": "f0566f07cff04113",
875
+ "## Servers and AI seats": "0a332b07e22d3fce",
876
+ "## Continuing a build from the Claude app": "0d68081e924ca419",
877
+ "## Rules": "969318425c99f5a5",
878
+ "## Beta": "9d02638207a26e73"
879
+ }
880
+ },
881
+ "named": {
882
+ "Homie Arcade": {
883
+ "sections": {
884
+ "AGENTS.md": {
885
+ "## Commands (all through the pinned CLI in node_modules)": "b35df2c19cd4b534"
886
+ }
887
+ }
888
+ }
889
+ }
853
890
  }
854
891
  }
855
892
  }
package/mcp/ui/lab.js ADDED
@@ -0,0 +1,67 @@
1
+ /* The Game Lab card: one take of a game's mechanic, New (the working tree) beside Today (the last commit). A still of
2
+ * both at the take's busiest moment, the phases of each as a timing strip, whether replays match, the game's
3
+ * JavaScript per frame, and Open (the lab runs on this computer). */
4
+ (function () {
5
+ var C = Card;
6
+ var COLOURS = ['#a374ff', '#17c3b2', '#f5a524', '#ff6fb5', '#8bd346', '#4dd2ff', '#ffd84a', '#e58cff'];
7
+ function strip(rows, frames) {
8
+ // rows: { label, phases: [{ name, from, to }] }: blocks at their frames on the take's own axis; colours by name, shared.
9
+ var names = [];
10
+ rows.forEach(function (r) { (r.phases || []).forEach(function (p) { if (names.indexOf(p.name) < 0) names.push(p.name); }); });
11
+ var box = C.el('div');
12
+ box.style.cssText = 'display:grid;gap:6px;margin:12px 0 4px';
13
+ rows.forEach(function (r) {
14
+ var line = C.el('div');
15
+ line.style.cssText = 'display:grid;grid-template-columns:52px 1fr;gap:8px;align-items:center';
16
+ var label = C.el('span', '', r.label);
17
+ label.style.cssText = 'font:700 11px/1 var(--f-mono);letter-spacing:.08em;color:' + r.colour;
18
+ var bar = C.el('div');
19
+ bar.style.cssText = 'position:relative;height:20px;border-radius:4px;overflow:hidden;background:var(--c-bg2)';
20
+ (r.phases || []).forEach(function (p) {
21
+ var b = C.el('span', '', p.name);
22
+ var colour = COLOURS[names.indexOf(p.name) % COLOURS.length];
23
+ b.title = p.name + ': frames ' + p.from + ' to ' + p.to;
24
+ b.style.cssText = 'position:absolute;top:0;bottom:0;left:' + ((p.from - 1) / frames) * 100 + '%;width:calc(' + ((p.to - p.from + 1) / frames) * 100 + '% - 1px);background:' + colour + ';color:#0b0d14;font:700 10px/20px var(--f-mono);padding:0 4px;white-space:nowrap;overflow:hidden;text-overflow:clip';
25
+ bar.appendChild(b);
26
+ });
27
+ if (!(r.phases || []).length) { var e = C.el('span', 'fine', r.empty || 'no phases'); e.style.cssText = 'margin:0;line-height:20px;padding:0 8px'; bar.appendChild(e); }
28
+ line.appendChild(label); line.appendChild(bar);
29
+ box.appendChild(line);
30
+ });
31
+ return box;
32
+ }
33
+ function render(sc) {
34
+ var card = C.el('main', 'card');
35
+ var det = sc.deterministic || {};
36
+ var same = det.new === null && (det.today === null || det.today === undefined);
37
+ var head = sc.running ? C.pill('Checking', 'live', true) : same ? C.pill('Replays match', 'ok') : C.pill('Replays differ', 'bad');
38
+ C.add(card, C.top('Game Lab', C.add(C.el('div', 'actions'), head, C.fullscreenButton())), C.el('h1', '', (sc.name || sc.game) + (sc.take ? ' · ' + sc.take : '')),
39
+ C.el('p', 'sub', sc.running ? 'The lab is open on this computer; its first check is still running.' : 'New (the working tree) beside Today' + (sc.today ? ' (' + sc.today + ')' : '') + ' · ' + sc.frames + ' frames at ' + sc.fps + ' fps'));
40
+ if (sc.still) {
41
+ var box = C.el('div', 'preview');
42
+ var pic = C.img(sc.still, 'New beside Today at the take\'s busiest moment');
43
+ if (pic) { pic.style.maxHeight = 'none'; pic.style.objectFit = 'contain'; box.appendChild(pic); }
44
+ card.appendChild(box);
45
+ }
46
+ if (sc.timeline && sc.frames) {
47
+ card.appendChild(strip([
48
+ { label: 'NEW', colour: '#e08a12', phases: sc.timeline.new },
49
+ { label: 'TODAY', colour: '#2f8fd8', phases: sc.timeline.today || [], empty: sc.todayNote || 'no phases' },
50
+ ], sc.frames));
51
+ card.appendChild(C.el('p', 'fine', 'Phases on the take\'s ' + sc.frames + ' frames (' + (sc.frames / sc.fps).toFixed(2) + ' s).'));
52
+ }
53
+ if (sc.cost && sc.cost.new) {
54
+ card.appendChild(C.el('p', 'fine', 'The game\'s JavaScript a frame, on average: New ' + sc.cost.new.mean + ' ms (p95 ' + sc.cost.new.p95 + ')' + (sc.cost.today ? ', Today ' + sc.cost.today.mean + ' ms (p95 ' + sc.cost.today.p95 + ')' : '') + '.'));
55
+ }
56
+ if (!same && !sc.running) card.appendChild(C.el('p', 'note bad', 'The same build played the take differently' + (det.new !== null ? ' (New from frame ' + det.new + ')' : '') + (det.today ? ' (Today from frame ' + det.today + ')' : '') + ': something in the game reads a clock or dice the lab does not drive.'));
57
+ (sc.errors || []).slice(0, 3).forEach(function (e) { card.appendChild(C.el('p', 'note bad', e)); });
58
+ var foot = C.el('div', 'foot');
59
+ foot.appendChild(C.el('span', 'when', 'Runs on this computer'));
60
+ var acts = C.el('div', 'actions');
61
+ if (sc.url) acts.appendChild(C.btn('Open the lab', '', function () { C.open(sc.url); C.tell('lab-open', 'The person opened the Game Lab for ' + (sc.name || sc.game) + ' from the card.'); }));
62
+ foot.appendChild(acts);
63
+ card.appendChild(foot);
64
+ return card;
65
+ }
66
+ C.start({ kind: 'lab', label: 'Game Lab', fullscreen: true, render: render, poll: null });
67
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homie-rocks/studio",
3
- "version": "0.19.2",
3
+ "version": "0.20.0",
4
4
  "description": "A studio for games, music and video on its own Cloudflare: scaffold, multiplayer starters on the netplay contract, a port toolkit that makes existing single-player web games multiplayer, the site Worker with public rooms (Table/Lobby Durable Objects and D1, all on the free Workers plan, no payment method), a site with the hub's sections (Home, Games, Music, Videos, Rooms, Posts with feeds) in the studio's own look, an epic landing page for every game, big songs and videos in the studio's own R2 once it has storage (uploaded, checked by SHA-256, served at the same addresses), deploy, and the homie.rocks directory.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -34,6 +34,10 @@
34
34
  "types": "./agents/agents.ts",
35
35
  "default": "./agents/agents.ts"
36
36
  },
37
+ "./lab": {
38
+ "types": "./lab/lab.ts",
39
+ "default": "./lab/lab.ts"
40
+ },
37
41
  "./worker": "./worker/index.mjs",
38
42
  "./package.json": "./package.json"
39
43
  },
@@ -46,6 +50,7 @@
46
50
  "mcp/",
47
51
  "saves/",
48
52
  "agents/",
53
+ "lab/",
49
54
  "starters/",
50
55
  "media/",
51
56
  "site/",
package/port/index.ts CHANGED
@@ -18,6 +18,7 @@
18
18
  * jitter, engages, standoff
19
19
  * the dial for the rest of a bot's decisions (port/skill.ts)
20
20
  * createSaves player accounts and cloud saves (a character that lasts days, on every device; saves/SAVES.md)
21
+ * lab the Game Lab's calls (@homie-rocks/studio/lab): tracks, phases, tunables, overlays, views
21
22
  * and everything from @homie-rocks/studio/netplay.
22
23
  */
23
24
  import './early';
@@ -35,4 +36,5 @@ export { createRoom, type Room, type RoomOptions, type BodyBase, type RoomSnap,
35
36
  export { createHud, type HudOptions } from './hud';
36
37
  export { BotBrain, brainOf, seek, flee, wanderer, nearest, rubberBand, protectedNewcomer, type V2 } from './bots';
37
38
  export { jitter, engages, standoff } from './skill';
39
+ export { lab, type TunableSpec, type TunableFile, type Tuned } from '../lab/lab';
38
40
  export { createSaves, SAVES_VERSION, type Saves, type SavesOptions, type Player, type SaveEntry, type SetResult, type Memorial, type SavesStatus, type Conflict } from '../saves/saves';
@@ -0,0 +1,22 @@
1
+ {
2
+ "v": 1,
3
+ "default": "strike",
4
+ "takes": {
5
+ "strike": {
6
+ "note": "Three strikes on a big training slime",
7
+ "seconds": 2.6,
8
+ "seed": 11,
9
+ "stage": "dummy",
10
+ "device": "desk",
11
+ "fps": 60,
12
+ "view": "close",
13
+ "track": "slime squash",
14
+ "storage": { "homie-saves.local.ember-vale": { "saves": { "hero": { "v": { "v": 1, "name": "Wren", "level": 1, "xp": 0, "gold": 0, "hardcore": false, "kills": 0, "deaths": 0, "born": 1767225600000 }, "ver": 1, "at": 1767225600000 } }, "stats": {}, "fallen": [] } },
15
+ "inputs": [
16
+ { "at": 0.4, "key": "Space", "hold": 0.08 },
17
+ { "at": 1.0, "key": "Space", "hold": 0.08 },
18
+ { "at": 1.6, "key": "Space", "hold": 0.08 }
19
+ ]
20
+ }
21
+ }
22
+ }