@homie-rocks/studio 0.9.0 → 0.11.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 +120 -8
- package/bin/homie-studio.mjs +128 -13
- package/bin/statusline.mjs +41 -0
- package/lib/build.mjs +44 -4
- package/lib/check.mjs +14 -12
- package/lib/chrome.mjs +126 -0
- package/lib/cloudflare.mjs +92 -18
- package/lib/codex.mjs +664 -0
- package/lib/doctor.mjs +279 -0
- package/lib/feed-summary.mjs +88 -0
- package/lib/look.mjs +5 -10
- package/lib/port-check.mjs +5 -11
- package/lib/progress.mjs +122 -6
- package/lib/scaffold.mjs +138 -21
- package/lib/setup.mjs +90 -0
- package/lib/statusline.mjs +155 -0
- package/lib/studio.mjs +11 -0
- package/lib/template-history.json +47 -0
- package/lib/version.mjs +7 -3
- package/package.json +1 -1
- package/worker/codex-script.mjs +6 -0
- package/worker/index.mjs +75 -4
- package/worker/stats-page.mjs +34 -2
- package/worker/version.mjs +1 -1
package/lib/progress.mjs
CHANGED
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
* knows (the plan, money spent, a song's lyric check, a video's shots) with the other `progress` commands.
|
|
20
20
|
* WITHOUT AN OPEN FEED NOTHING CHANGES: every command behaves exactly as before.
|
|
21
21
|
*
|
|
22
|
+
* WHERE A PERSON SEES IT: the Claude app's build card (shared feeds), the Build status tab of the game's codex page
|
|
23
|
+
* (lib/codex.mjs: it redraws itself at every change), and Claude Code's status line (lib/statusline.mjs), all read
|
|
24
|
+
* through lib/feed-summary.mjs so they agree.
|
|
25
|
+
*
|
|
22
26
|
* SHARED (`progress start --share`): the directory named in studio.json (homie.rocks by default) keeps a copy for
|
|
23
27
|
* 24 hours, so the Homie MCP tool `build_progress { build }` can show it in the Claude app, and answers every
|
|
24
28
|
* write with whether the person pressed Stop there. It receives the feed and nothing else: never a key, a file
|
|
@@ -34,12 +38,25 @@
|
|
|
34
38
|
* stop: { requested, at, by },
|
|
35
39
|
* song?: { peaks: [0..1], lyrics: [{ line, sung: true|false|null }] },
|
|
36
40
|
* video?: { shots: [{ id, label, state, image }] },
|
|
41
|
+
* change?: { url, number, title, repo, branch, state: open|merged|closed, files, additions, deletions, preview, mark, at },
|
|
42
|
+
* site?: the studio's live address (for the Claude app's card to tell when a merged change is live),
|
|
37
43
|
* log: [{ at, text }], error, shared?: { build, directory } }
|
|
44
|
+
*
|
|
45
|
+
* A BUILD OPENED IN THE CHAT (`build_open`, the Claude app's "Build it" card): the chat gets the build id first
|
|
46
|
+
* and shows its card; the Claude Code session that does the work attaches to it ONCE with
|
|
47
|
+
* `progress attach <hb_…>`, and the directory hands the write key to that first attach only. No key ever travels
|
|
48
|
+
* in a prompt; a second attach is refused.
|
|
49
|
+
*
|
|
50
|
+
* A CHANGE THAT GOES OUT AS A PULL REQUEST: `progress change "<what it does>"` writes changes/<date>-<mark>.json
|
|
51
|
+
* (committed with the change; the site lists the newest marks in its manifest), and `progress pr --url <pr>` puts
|
|
52
|
+
* the pull request on the card, whose Publish button opens it in GitHub for the person's one-tap merge. When the
|
|
53
|
+
* live site lists the change's mark, Workers Builds has deployed it: the card says Live by itself.
|
|
38
54
|
*/
|
|
39
|
-
import { randomBytes } from 'node:crypto';
|
|
55
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
40
56
|
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
41
57
|
import { extname, join } from 'node:path';
|
|
42
|
-
import {
|
|
58
|
+
import { refreshCodexFile } from './codex.mjs';
|
|
59
|
+
import { readStudio, siteUrl } from './studio.mjs';
|
|
43
60
|
|
|
44
61
|
export const PROGRESS_KIND = 'homie-studio-progress';
|
|
45
62
|
export const PROGRESS_DIR = join('.studio', 'progress');
|
|
@@ -72,6 +89,28 @@ const keyPath = (root, id) => join(dir(root), `${id}.key`);
|
|
|
72
89
|
const currentPath = (root) => join(dir(root), 'current');
|
|
73
90
|
const loopback = (url) => { try { return ['127.0.0.1', 'localhost', '[::1]'].includes(new URL(url).hostname); } catch { return false; } };
|
|
74
91
|
|
|
92
|
+
/*
|
|
93
|
+
* A CLAUDE CODE CLOUD SESSION ON THE DEFAULT NETWORK. Its "Trusted" network reaches package registries and GitHub,
|
|
94
|
+
* not homie.rocks: the session's proxy answers 403 with `x-deny-reason: host_not_allowed`. Say which setting lets
|
|
95
|
+
* the card follow the build, instead of "did not answer"; the build itself goes on with its local feed.
|
|
96
|
+
*/
|
|
97
|
+
export function networkWhy(res, at) {
|
|
98
|
+
if (res?.status === 403 && /host_not_allowed/i.test(res.headers?.get?.('x-deny-reason') ?? '')) {
|
|
99
|
+
let host = at;
|
|
100
|
+
try { host = new URL(at).host; } catch { /* as given */ }
|
|
101
|
+
return `this Claude Code cloud environment's network does not reach ${host}. In claude.ai/code, open the environment's settings, set Network access to Custom, add ${host} (keep "Also include default list of common package managers"), and start a new session; until then the build goes on with its local feed only`;
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The studio's live address for the card: an https origin (or this computer's own dev site), else null. */
|
|
107
|
+
export function liveSite(url) {
|
|
108
|
+
try { const u = new URL(String(url ?? '')); return u.protocol === 'https:' || (u.protocol === 'http:' && loopback(u.href)) ? u.origin : null; } catch { return null; }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A change's mark: what the site lists once the change is live. It names the build without being able to read it. */
|
|
112
|
+
export const changeMark = (build) => createHash('sha256').update(`homie-change\n${build}`).digest('hex').slice(0, 16);
|
|
113
|
+
|
|
75
114
|
function writeAtomic(file, text) {
|
|
76
115
|
const tmp = `${file}.${process.pid}.${randomBytes(3).toString('hex')}.tmp`;
|
|
77
116
|
writeFileSync(tmp, text);
|
|
@@ -120,6 +159,11 @@ async function pushDoc(root, id) {
|
|
|
120
159
|
body: JSON.stringify({ ...body, build: shared.build }),
|
|
121
160
|
signal: AbortSignal.timeout(8000),
|
|
122
161
|
});
|
|
162
|
+
const blocked = networkWhy(res, shared.directory);
|
|
163
|
+
if (blocked) {
|
|
164
|
+
mutateDoc(root, id, (d) => { d.shared = { ...d.shared, ended: true }; pushLog(d, `The Claude app cannot follow this build: ${blocked}`); });
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
123
167
|
if (res.status === 404 || res.status === 410) {
|
|
124
168
|
// The shared copy ended (24 hours, or the directory dropped it): keep the local feed, stop sending.
|
|
125
169
|
mutateDoc(root, id, (d) => { d.shared = { ...d.shared, ended: true }; });
|
|
@@ -206,6 +250,8 @@ export class Feed {
|
|
|
206
250
|
change(fn, { soon = false } = {}) {
|
|
207
251
|
const d = mutateDoc(this.root, this.id, fn);
|
|
208
252
|
if (d) schedule(this.root, this.id, { soon });
|
|
253
|
+
// The game's codex page on this computer (.studio/codex/<id>.html), when there is one, shows the change too.
|
|
254
|
+
if (d?.what === 'game' && d.id) refreshCodexFile(this.root, d.id);
|
|
209
255
|
return d;
|
|
210
256
|
}
|
|
211
257
|
|
|
@@ -309,6 +355,33 @@ export class Feed {
|
|
|
309
355
|
});
|
|
310
356
|
}
|
|
311
357
|
|
|
358
|
+
/** The pull request this build's change went out as: the card's Publish button opens it for the person's merge. */
|
|
359
|
+
pr({ url, number, title, repo, branch, state = 'open', files, additions, deletions, preview, site } = {}) {
|
|
360
|
+
let u;
|
|
361
|
+
try { u = new URL(String(url ?? '')); } catch { throw new Error('--url is the pull request\'s https://github.com/<owner>/<repo>/pull/<n> address'); }
|
|
362
|
+
const m = /^\/([A-Za-z0-9-]{1,39})\/([A-Za-z0-9._-]{1,100})\/pull\/(\d{1,7})\/?$/.exec(u.pathname);
|
|
363
|
+
if (u.protocol !== 'https:' || u.hostname !== 'github.com' || !m) throw new Error('--url is the pull request\'s https://github.com/<owner>/<repo>/pull/<n> address');
|
|
364
|
+
if (!['open', 'merged', 'closed'].includes(state)) throw new Error('a pull request is open, merged or closed');
|
|
365
|
+
const count = (n) => (n === undefined || n === null || n === true ? null : Number.isFinite(Number(n)) && Number(n) >= 0 ? Math.round(Number(n)) : null);
|
|
366
|
+
return this.change((doc) => {
|
|
367
|
+
const before = doc.change ?? {};
|
|
368
|
+
doc.change = {
|
|
369
|
+
url: `https://github.com/${m[1]}/${m[2]}/pull/${m[3]}`, number: Number(m[3]), repo: `${m[1]}/${m[2]}`,
|
|
370
|
+
title: plain(title ?? before.title ?? doc.title, LIMITS.title), branch: branch ? plain(branch, 100) : before.branch ?? null, state,
|
|
371
|
+
files: count(files) ?? before.files ?? null, additions: count(additions) ?? before.additions ?? null, deletions: count(deletions) ?? before.deletions ?? null,
|
|
372
|
+
preview: preview ? String(preview).slice(0, 300) : before.preview ?? null, mark: before.mark ?? null, at: now(),
|
|
373
|
+
};
|
|
374
|
+
// The live address may have been learned after the build was opened (`setup attach`): the card reads it.
|
|
375
|
+
if (liveSite(site)) doc.site = liveSite(site);
|
|
376
|
+
const deploy = doc.stages.find((s) => s.id === 'deploy' || s.id === 'publish');
|
|
377
|
+
if (deploy && state === 'open' && deploy.state === 'pending') { deploy.state = 'running'; deploy.startedAt = now(); deploy.note = 'Waiting for the merge: Publish on the card opens the pull request'; doc.stage = deploy.id; }
|
|
378
|
+
pushLog(doc, `Pull request #${m[3]} ${state}`);
|
|
379
|
+
}, { soon: true });
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** The studio's live address, so the card can read the site's own manifest for the change once it is merged. */
|
|
383
|
+
site(url) { return this.change((doc) => { doc.site = url ? String(url).slice(0, 200) : null; }); }
|
|
384
|
+
|
|
312
385
|
stopRequested() { return Boolean(this.doc?.stop?.requested); }
|
|
313
386
|
|
|
314
387
|
/**
|
|
@@ -362,7 +435,9 @@ export function publicFeed(doc) {
|
|
|
362
435
|
* Open a feed for one build. `share` asks the studio's directory (studio.json `homie.directory`, or `directory`)
|
|
363
436
|
* to keep a copy for the Claude app's widget; if it cannot, the build goes on with the local feed only.
|
|
364
437
|
*/
|
|
365
|
-
export async function startProgress(root, { what = 'game', id, title, budget, unit, share = false, directory } = {}) {
|
|
438
|
+
export async function startProgress(root, { what = 'game', id, title, budget, unit, share = false, directory, attach = null } = {}) {
|
|
439
|
+
if (attach !== null && !REMOTE_ID.test(String(attach))) return { ok: false, command: 'progress attach', why: 'attach to the build id the Claude app showed: hb_ and 32 hex digits' };
|
|
440
|
+
if (attach) share = true;
|
|
366
441
|
if (!STAGES[what]) return { ok: false, command: 'progress start', why: `what is being made: ${Object.keys(STAGES).join(', ')}` };
|
|
367
442
|
if (id !== undefined && id !== null && !SLUG.test(String(id))) return { ok: false, command: 'progress start', why: 'the id is the game, song or video id (lowercase letters, digits and hyphens)' };
|
|
368
443
|
const studio = readStudio(root);
|
|
@@ -384,6 +459,9 @@ export async function startProgress(root, { what = 'game', id, title, budget, un
|
|
|
384
459
|
log: [{ at: now(), text: `Started: ${plain(title || id || what, 100)}` }],
|
|
385
460
|
error: null,
|
|
386
461
|
};
|
|
462
|
+
let live = null;
|
|
463
|
+
try { live = siteUrl(root, studio); } catch { live = null; }
|
|
464
|
+
if (liveSite(live)) doc.site = liveSite(live);
|
|
387
465
|
mkdirSync(dir(root), { recursive: true });
|
|
388
466
|
writeAtomic(docPath(root, build), `${JSON.stringify(doc, null, 1)}\n`);
|
|
389
467
|
writeAtomic(currentPath(root), `${build}\n`);
|
|
@@ -394,12 +472,16 @@ export async function startProgress(root, { what = 'game', id, title, budget, un
|
|
|
394
472
|
if (!/^https:\/\//.test(at) && !(/^http:\/\//.test(at) && loopback(at))) why = `the directory ${at} is not https`;
|
|
395
473
|
else {
|
|
396
474
|
try {
|
|
397
|
-
|
|
475
|
+
// A build the chat opened is attached (once); otherwise a new one is opened here.
|
|
476
|
+
const res = await fetch(attach ? `${at}/api/studio/progress/${attach}/attach` : `${at}/api/studio/progress`, {
|
|
398
477
|
method: 'POST', headers: { 'content-type': 'application/json', 'user-agent': 'homie-studio' },
|
|
399
478
|
body: JSON.stringify({ what, id: id ?? null, title: doc.title, studio: doc.studio }), signal: AbortSignal.timeout(10_000),
|
|
400
479
|
});
|
|
401
480
|
const body = await res.json().catch(() => null);
|
|
402
|
-
if (res.ok &&
|
|
481
|
+
if (!res.ok && networkWhy(res, at)) why = networkWhy(res, at);
|
|
482
|
+
else if (res.ok && body?.ok && REMOTE_ID.test(String(body.build)) && /^hbk_[a-f0-9]{48}$/.test(String(body.key))) {
|
|
483
|
+
// The chat named the build: its title is the one the person saw.
|
|
484
|
+
if (attach && body.title && !title) mutateDoc(root, build, (d) => { d.title = plain(body.title, LIMITS.title); });
|
|
403
485
|
writeFileSync(keyPath(root, build), `${body.key}\n`, { mode: 0o600 });
|
|
404
486
|
try { chmodSync(keyPath(root, build), 0o600); } catch { /* not on this filesystem */ }
|
|
405
487
|
shared = { build: body.build, directory: at, expiresAt: body.expiresAt ?? null };
|
|
@@ -410,11 +492,45 @@ export async function startProgress(root, { what = 'game', id, title, budget, un
|
|
|
410
492
|
} catch (error) { why = `${at} did not answer (${error?.message ?? error})`; }
|
|
411
493
|
}
|
|
412
494
|
}
|
|
495
|
+
if (attach && !shared) {
|
|
496
|
+
// Attaching is the point of `progress attach`: without it, say why and leave no open feed behind.
|
|
497
|
+
rmSync(docPath(root, build), { force: true });
|
|
498
|
+
rmSync(currentPath(root), { force: true });
|
|
499
|
+
return { ok: false, command: 'progress attach', build: attach, why: `could not attach to ${attach}: ${why}` };
|
|
500
|
+
}
|
|
413
501
|
return {
|
|
414
|
-
ok: true, command: 'progress start', build, file: join(PROGRESS_DIR, `${build}.json`), what, id: id ?? null, title: doc.title,
|
|
502
|
+
ok: true, command: attach ? 'progress attach' : 'progress start', build, file: join(PROGRESS_DIR, `${build}.json`), what, id: id ?? null, title: readFeed(root, build)?.title ?? doc.title,
|
|
415
503
|
stages: doc.stages.map((s) => s.id), budget: doc.spend.budget, unit: doc.spend.unit,
|
|
416
504
|
shared: shared ? { build: shared.build, directory: shared.directory, expiresAt: shared.expiresAt } : null,
|
|
417
505
|
...(share && !shared ? { sharedWhy: `not shared: ${why}; the feed is local only` } : {}),
|
|
418
506
|
widget: shared ? `In the Claude app: call the Homie MCP tool build_progress with { "build": "${shared.build}" }` : null,
|
|
419
507
|
};
|
|
420
508
|
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* `progress change "<what it does>"`: the change's mark, as a small file the change commits (changes/<date>-<mark>.json).
|
|
512
|
+
* `homie-studio build` lists the newest marks in the site's manifest; when the live site lists this one, the change
|
|
513
|
+
* is deployed, and the Claude app's card says so. Returns the file, relative to the studio.
|
|
514
|
+
*/
|
|
515
|
+
export function recordChange(root, id, title) {
|
|
516
|
+
const doc = readFeed(root, id);
|
|
517
|
+
if (!doc) throw new Error('no build is open: start or attach one first');
|
|
518
|
+
const mark = changeMark(doc.shared?.build ?? doc.build);
|
|
519
|
+
const folder = join(root, 'changes');
|
|
520
|
+
mkdirSync(folder, { recursive: true });
|
|
521
|
+
if (!existsSync(join(folder, 'README.md'))) writeFileSync(join(folder, 'README.md'), CHANGES_README);
|
|
522
|
+
const rel = join('changes', `${now().slice(0, 10)}-${mark.slice(0, 8)}.json`);
|
|
523
|
+
const text = `${JSON.stringify({ v: 1, change: mark, title: plain(title || doc.title, LIMITS.title), at: now() }, null, 2)}\n`;
|
|
524
|
+
writeFileSync(join(root, rel), text);
|
|
525
|
+
mutateDoc(root, id, (d) => { d.change = { ...(d.change ?? {}), mark }; pushLog(d, `Change recorded: ${plain(title || doc.title, 100)}`); });
|
|
526
|
+
schedule(root, id, { soon: true });
|
|
527
|
+
return { file: rel, mark };
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export const CHANGES_README = `# changes/
|
|
531
|
+
|
|
532
|
+
One small file per change this studio made through a pull request, written by \`homie-studio progress change\`:
|
|
533
|
+
what it does, when, and its mark. \`npm run build\` lists the newest marks in the site's
|
|
534
|
+
\`/.well-known/homie-studio.json\`, so the Claude app's card can tell when a merged change is live. Nothing in
|
|
535
|
+
here is secret; old files may be deleted.
|
|
536
|
+
`;
|
package/lib/scaffold.mjs
CHANGED
|
@@ -25,40 +25,66 @@ import { dirname, join, relative, resolve } from 'node:path';
|
|
|
25
25
|
import { STUDIO_VERSION, packageSpec } from './version.mjs';
|
|
26
26
|
import { STATS_MIGRATION, STATS_MIGRATION_FILE } from '../worker/stats.mjs';
|
|
27
27
|
import { themeFile } from './site.mjs';
|
|
28
|
+
import { PACKAGE_ROOT } from './studio.mjs';
|
|
28
29
|
|
|
29
30
|
export const COMPAT_DATE = '2026-06-01';
|
|
30
|
-
|
|
31
|
+
/** 4.135.0 or later: Worker Previews (`wrangler preview`, a Durable Object namespace per Preview). */
|
|
32
|
+
export const WRANGLER_VERSION = '4.145.0';
|
|
31
33
|
|
|
32
34
|
export function slugify(name) {
|
|
33
35
|
return String(name ?? '').normalize('NFKD').replace(/[̀-ͯ]/g, '').toLowerCase()
|
|
34
36
|
.replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40).replace(/-+$/g, '') || 'studio';
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
/*
|
|
40
|
+
* The Worker config, generated so a later deploy can rewrite exactly what it owns.
|
|
41
|
+
*
|
|
42
|
+
* `layout: 'root'` (every studio from 0.10.0) keeps it at the studio's root, where Cloudflare's Workers Builds and
|
|
43
|
+
* the "Deploy to Cloudflare" button look for it; `'site'` is the older site/wrangler.jsonc.
|
|
44
|
+
*
|
|
45
|
+
* PREVIEWS (Cloudflare Worker Previews, Wrangler 4.135.0+): a branch deploys with `npx wrangler preview` (Workers
|
|
46
|
+
* Builds does it on every push that is not to the production branch) to its own URL, and Cloudflare gives every
|
|
47
|
+
* Preview its OWN Durable Object namespace, so a Preview's public rooms never meet production's. The `previews`
|
|
48
|
+
* block binds the same Table and Lobby classes and names the Preview (HOMIE_PREVIEW). It binds no D1 on purpose:
|
|
49
|
+
* a Preview counts nothing into the studio's stats, records no rounds and never claims itself in the directory;
|
|
50
|
+
* its pages and rooms work without it.
|
|
51
|
+
*
|
|
52
|
+
* No `database_id` until one is known: Wrangler (4.45.0+) and the Deploy to Cloudflare flow create the database
|
|
53
|
+
* the binding names and keep it linked.
|
|
54
|
+
*/
|
|
55
|
+
export function wranglerConfig({ worker, name, d1, d1Id = null, r2 = null, layout = 'root' }) {
|
|
56
|
+
const at = layout === 'site' ? { schema: '../node_modules', main: 'src/worker.mjs', dist: './dist', migrations: 'migrations' }
|
|
57
|
+
: { schema: 'node_modules', main: 'site/src/worker.mjs', dist: './site/dist', migrations: 'site/migrations' };
|
|
58
|
+
const rooms = [{ name: 'TABLE', class_name: 'Table' }, { name: 'LOBBY', class_name: 'Lobby' }];
|
|
39
59
|
const config = {
|
|
40
|
-
$schema:
|
|
60
|
+
$schema: `${at.schema}/wrangler/config-schema.json`,
|
|
41
61
|
name: worker,
|
|
42
|
-
main:
|
|
62
|
+
main: at.main,
|
|
43
63
|
compatibility_date: COMPAT_DATE,
|
|
64
|
+
// The site's own fetches (its directory claim, "played this week") go out as any browser's would, so a studio
|
|
65
|
+
// whose directory is on the same zone (a house studio on *.homie.rocks, or two Workers on one workers.dev
|
|
66
|
+
// subdomain) reaches it instead of failing with 1042.
|
|
67
|
+
compatibility_flags: ['global_fetch_strictly_public'],
|
|
44
68
|
workers_dev: true,
|
|
45
|
-
preview_urls:
|
|
46
|
-
assets: { directory:
|
|
47
|
-
durable_objects: { bindings:
|
|
69
|
+
preview_urls: true,
|
|
70
|
+
assets: { directory: at.dist, binding: 'ASSETS', run_worker_first: true },
|
|
71
|
+
durable_objects: { bindings: rooms },
|
|
48
72
|
migrations: [{ tag: 'v1', new_sqlite_classes: ['Table', 'Lobby'] }],
|
|
49
|
-
d1_databases: [{ binding: 'DB', database_name: d1, ...(d1Id ? { database_id: d1Id } : {}), migrations_dir:
|
|
73
|
+
d1_databases: [{ binding: 'DB', database_name: d1, ...(d1Id ? { database_id: d1Id } : {}), migrations_dir: at.migrations }],
|
|
50
74
|
...(r2 ? { r2_buckets: [{ binding: 'MEDIA', bucket_name: r2 }] } : {}),
|
|
51
75
|
vars: { STUDIO_NAME: name },
|
|
52
76
|
observability: { enabled: true },
|
|
77
|
+
previews: { vars: { STUDIO_NAME: name, HOMIE_PREVIEW: '1' }, durable_objects: { bindings: rooms } },
|
|
53
78
|
};
|
|
54
|
-
return `// This studio's site on its own Cloudflare account (written by homie-studio
|
|
55
|
-
//
|
|
79
|
+
return `// This studio's site on its own Cloudflare account (written by homie-studio). Everything here runs on
|
|
80
|
+
// Cloudflare's Workers Free plan. \`npm run deploy\` (on this computer, or in Workers Builds) puts it live;
|
|
81
|
+
// \`npx wrangler preview\` puts a branch on its own Preview URL with its own rooms. There is no R2 binding
|
|
56
82
|
// until \`homie-studio storage add\` gives the studio storage for large media.
|
|
57
83
|
${JSON.stringify(config, null, 2)}
|
|
58
84
|
`;
|
|
59
85
|
}
|
|
60
86
|
|
|
61
|
-
function agentsMd({ name, slug }) {
|
|
87
|
+
export function agentsMd({ name, slug }) {
|
|
62
88
|
return `# ${name}
|
|
63
89
|
|
|
64
90
|
This folder is a studio: **${name}** (\`${slug}\`). It is one repository.
|
|
@@ -75,7 +101,9 @@ directory lists its games; homie.rocks does not host them.
|
|
|
75
101
|
| \`games/<id>/\` | One game: \`game.json\` (id, name, blurb, players, round length), \`index.html\`, \`src/main.ts\`. |
|
|
76
102
|
| \`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>/\`, served from the site itself (files up to 25 MiB) or, for larger media, from the studio's storage once it has storage (see below; \`npx --no-install homie-studio media put <file>\`). Large files never go into git. The Homie plugin's \`music\` and \`video\` skills make them. |
|
|
77
103
|
| \`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. |
|
|
78
|
-
| \`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\`)
|
|
104
|
+
| \`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. |
|
|
105
|
+
| \`wrangler.jsonc\` | The Worker's Cloudflare config (the Worker, D1, the Table and Lobby Durable Objects, and \`previews\` for branch Previews), at the root, where Cloudflare's Workers Builds reads it. A studio made before 0.10.0 keeps it in \`site/\` and deploys from a computer; every command finds either. |
|
|
106
|
+
| \`changes/\` | One small file per change that went out through a pull request (\`homie-studio progress pr\` writes it): the site lists the newest, so the Claude app can tell when a merged change is live. |
|
|
79
107
|
| \`studio.json\` | The studio's name, slug, Cloudflare resource names, custom domain and stats sharing. \`.studio/\` (git-ignored) is this computer's own state. |
|
|
80
108
|
| \`.claude/skills/\` | Skills only this studio uses. Homie's own skills come from the Homie plugin. |
|
|
81
109
|
|
|
@@ -103,6 +131,11 @@ studio's pinned copy, never a registry lookup of the bare name.
|
|
|
103
131
|
SQLite-backed Durable Objects, all on the free Workers plan (no payment method needed).
|
|
104
132
|
If Wrangler is not signed in, run \`npx wrangler login\`: the person approves once in
|
|
105
133
|
their browser. It never overwrites a Worker or database this studio did not create.
|
|
134
|
+
- **Workers Builds** (Cloudflare's own CI, set up by the "Deploy to Cloudflare" button or in the dashboard): on
|
|
135
|
+
every push to \`main\` it runs \`npm run build\` and \`npm run deploy\`, which in Workers Builds only applies
|
|
136
|
+
the D1 migrations and deploys (it never creates or refuses anything); on every other branch it runs
|
|
137
|
+
\`npm run build\` and \`npx wrangler preview\`, a Preview URL with its own rooms. The live site claims itself
|
|
138
|
+
in the homie.rocks directory the first time it is read, so nothing is stored by hand.
|
|
106
139
|
- \`npx --no-install homie-studio storage add\` — only when the studio needs large media (songs,
|
|
107
140
|
videos): an R2 bucket for \`media put\`, served at \`/media/<key>\`. Cloudflare asks for a
|
|
108
141
|
payment method on the account before R2 works (its first 10 GB a month are free), so this
|
|
@@ -159,6 +192,24 @@ studio's pinned copy, never a registry lookup of the bare name.
|
|
|
159
192
|
- Change a game in small steps, build, and look at it (\`dev\`, then \`check\`).
|
|
160
193
|
- A game's id is its URL (\`/<id>/\`); keep it once published.
|
|
161
194
|
|
|
195
|
+
## The Game Codex and progress
|
|
196
|
+
|
|
197
|
+
- **Every game has a Game Codex:** \`games/<id>/CODEX.md\`, its plan in plain words for everyone who makes it, coder
|
|
198
|
+
or not: concept, world, characters, art direction, controls per device, rooms and players, music and sound,
|
|
199
|
+
milestones, open questions, and under Latest the decisions as they are made, newest first, each with its date.
|
|
200
|
+
It is the source of truth: when a decision changes, change the codex in the same change.
|
|
201
|
+
\`npx --no-install homie-studio codex new <id>\` starts one with every section.
|
|
202
|
+
- \`npx --no-install homie-studio codex <id>\` draws it as a page in the game's own look
|
|
203
|
+
(\`.studio/codex/<id>.html\`, \`--open\` opens it; \`--artifact\` makes a copy to publish as a Claude artifact).
|
|
204
|
+
The site has it too, for the owner only and never listed: \`codex link <id>\` gives the one-time sign-in link.
|
|
205
|
+
- **Progress:** \`npx --no-install homie-studio progress start <id> --title "<what this build does>"\` opens a
|
|
206
|
+
build's progress feed; build, check and deploy report into it. The codex page's Build status tab redraws itself
|
|
207
|
+
as it moves (stages, checks going green, how to try it, spend), and \`homie-studio statusline --install\` puts
|
|
208
|
+
one line of it under the prompt in Claude Code.
|
|
209
|
+
- \`npx --no-install homie-studio setup status\` says what this computer and the person's accounts have (Node,
|
|
210
|
+
Cloudflare, Chrome, ffmpeg, GitHub, ElevenLabs, fal), what each unlocks, and the exact fix. Optional ones never
|
|
211
|
+
block anything.
|
|
212
|
+
|
|
162
213
|
## Rules
|
|
163
214
|
|
|
164
215
|
- Keys stay in the providers' own logins (Wrangler, ElevenLabs, fal) or the OS
|
|
@@ -186,7 +237,7 @@ Claude-only notes go below this line. -->
|
|
|
186
237
|
`;
|
|
187
238
|
}
|
|
188
239
|
|
|
189
|
-
function readme({ name }) {
|
|
240
|
+
export function readme({ name }) {
|
|
190
241
|
return `# ${name}
|
|
191
242
|
|
|
192
243
|
A game studio made with [Homie](https://homie.rocks). Open this folder in Claude Code or Codex
|
|
@@ -249,12 +300,14 @@ anything here wins. The whole list is in \`node_modules/@homie-rocks/studio/site
|
|
|
249
300
|
| \`pages/<path>/index.html\` | A whole page at \`/<path>/\`, instead of the generated one (\`pages/<id>/index.html\` replaces a game's landing) or beside them (\`pages/about/index.html\`). It may borrow \`<!-- homie:style -->\`, \`<!-- homie:header -->\`, \`<!-- homie:footer -->\`, \`<!-- homie:script -->\`. |
|
|
250
301
|
| \`public/\` | Files served as they are, at the same path (\`public/fonts/x.woff2\` is \`/fonts/x.woff2\`). |
|
|
251
302
|
|
|
252
|
-
\`src/worker.mjs
|
|
303
|
+
\`src/worker.mjs\` and \`migrations/\` are the Worker (its config is \`wrangler.jsonc\`, at the studio's root); \`dist/\` is the build (not committed).
|
|
253
304
|
`;
|
|
254
305
|
|
|
255
306
|
const GITIGNORE = `node_modules/
|
|
256
307
|
# This computer's own state: the site's workers.dev address (it names the Cloudflare account, often after its owner).
|
|
257
308
|
.studio/
|
|
309
|
+
# This person's own Claude Code settings for this studio (the status line, for one).
|
|
310
|
+
.claude/settings.local.json
|
|
258
311
|
site/dist/
|
|
259
312
|
site/.wrangler/
|
|
260
313
|
.wrangler/
|
|
@@ -278,10 +331,13 @@ videos/**/*.webm
|
|
|
278
331
|
`;
|
|
279
332
|
|
|
280
333
|
/** Every file a new studio gets, relative to its folder. */
|
|
281
|
-
export function studioFiles({ name, slug, homie }) {
|
|
334
|
+
export function studioFiles({ name, slug, homie, template = false }) {
|
|
282
335
|
const worker = slug;
|
|
283
336
|
const studio = {
|
|
284
337
|
name, slug,
|
|
338
|
+
// A copy of the public template (Deploy to Cloudflare) until `homie-studio setup attach` names it for real:
|
|
339
|
+
// meanwhile its site shows the name the person typed in Cloudflare's form (STUDIO_NAME).
|
|
340
|
+
...(template ? { template: true } : {}),
|
|
285
341
|
homie: { studio: STUDIO_VERSION, directory: homie },
|
|
286
342
|
// r2 stays null until `homie-studio storage add`: a new studio deploys with no R2 at all.
|
|
287
343
|
// `domain`: the studio's own domain once it has one (e.g. "night-owls.example"). The workers.dev address never
|
|
@@ -297,11 +353,20 @@ export function studioFiles({ name, slug, homie }) {
|
|
|
297
353
|
type: 'module',
|
|
298
354
|
scripts: { dev: 'homie-studio dev', build: 'homie-studio build', deploy: 'homie-studio deploy', check: 'homie-studio check', studio: 'homie-studio' },
|
|
299
355
|
devDependencies: { '@homie-rocks/studio': packageSpec(homie), wrangler: WRANGLER_VERSION },
|
|
356
|
+
// What Cloudflare's "Deploy to Cloudflare" form says about each setting (package.json `cloudflare.bindings`).
|
|
357
|
+
cloudflare: {
|
|
358
|
+
label: 'Homie studio',
|
|
359
|
+
products: ['Workers', 'D1', 'Durable Objects'],
|
|
360
|
+
bindings: {
|
|
361
|
+
STUDIO_NAME: { description: 'Your studio\'s name, as its site shows it (for example **Night Owls**). Claude can change it later.' },
|
|
362
|
+
DB: { description: 'The studio\'s own database: finished rounds, the studio\'s own stats (counts, never a visitor) and its claim in the [homie.rocks](https://homie.rocks/studios/) directory. Free plan.' },
|
|
363
|
+
},
|
|
364
|
+
},
|
|
300
365
|
};
|
|
301
|
-
|
|
366
|
+
const files = {
|
|
302
367
|
'AGENTS.md': agentsMd({ name, slug }),
|
|
303
368
|
'CLAUDE.md': claudeMd(),
|
|
304
|
-
'README.md': readme({ name }),
|
|
369
|
+
'README.md': template ? templateReadme() : readme({ name }),
|
|
305
370
|
'studio.json': `${JSON.stringify(studio, null, 2)}\n`,
|
|
306
371
|
'package.json': `${JSON.stringify(pkg, null, 2)}\n`,
|
|
307
372
|
'.gitignore': GITIGNORE,
|
|
@@ -319,9 +384,61 @@ export { default, Table, Lobby } from '@homie-rocks/studio/worker';
|
|
|
319
384
|
`,
|
|
320
385
|
'site/migrations/0001_studio.sql': MIGRATION,
|
|
321
386
|
[`site/migrations/${STATS_MIGRATION_FILE}`]: STATS_MIGRATION,
|
|
322
|
-
'
|
|
387
|
+
'wrangler.jsonc': wranglerConfig({ worker, name, d1: studio.cloudflare.d1, r2: studio.cloudflare.r2, layout: 'root' }),
|
|
323
388
|
'.claude/skills/.gitkeep': '',
|
|
324
389
|
};
|
|
390
|
+
if (template) {
|
|
391
|
+
// A first game, so the site plays the moment Cloudflare deploys it; and a band on Home that connects the new
|
|
392
|
+
// studio to the Claude chat that set it up (`setup attach` removes both once Claude works in the studio).
|
|
393
|
+
for (const [rel, text] of starterFiles('gem-rush')) files[`games/gem-rush/${rel}`] = text;
|
|
394
|
+
files['site/partials/home.html'] = CONNECT_BAND;
|
|
395
|
+
}
|
|
396
|
+
return files;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** A starter's files, as text, relative to its folder. */
|
|
400
|
+
function starterFiles(id) {
|
|
401
|
+
const dir = join(PACKAGE_ROOT, 'starters', id);
|
|
402
|
+
const out = [];
|
|
403
|
+
const walk = (rel) => {
|
|
404
|
+
for (const entry of readdirSync(join(dir, rel), { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
405
|
+
const path = rel ? `${rel}/${entry.name}` : entry.name;
|
|
406
|
+
if (entry.isDirectory()) walk(path);
|
|
407
|
+
else out.push([path, readFileSync(join(dir, path), 'utf8')]);
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
walk('');
|
|
411
|
+
return out;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** The template's first-run band on Home: one link that connects this studio to the Claude chat that set it up. */
|
|
415
|
+
export const CONNECT_BAND = `<!-- A new studio from the Homie template. This band goes away once Claude works in the studio
|
|
416
|
+
(homie-studio setup attach removes it); delete it by hand any time. -->
|
|
417
|
+
<div class="band-in" style="text-align:center">
|
|
418
|
+
<p class="kicker">New studio</p>
|
|
419
|
+
<h2>{{studio.name}} is live</h2>
|
|
420
|
+
<p>It runs on your own Cloudflare account. Connect it to the Claude chat that set it up, and Claude takes it from here.</p>
|
|
421
|
+
<p><a class="btn" href="/_studio/connect">Connect to Claude</a></p>
|
|
422
|
+
</div>
|
|
423
|
+
`;
|
|
424
|
+
|
|
425
|
+
export function templateReadme() {
|
|
426
|
+
return `# A Homie studio
|
|
427
|
+
|
|
428
|
+
This repository is a game studio made with [Homie](https://homie.rocks): its games, music, videos and posts,
|
|
429
|
+
and a site with public multiplayer rooms that runs on **your own Cloudflare account**, on the free plan.
|
|
430
|
+
|
|
431
|
+
[](https://deploy.workers.cloudflare.com/?url=https://github.com/homie-rocks/homie/tree/main/template)
|
|
432
|
+
|
|
433
|
+
The button copies this studio into your GitHub, creates its Worker, database and rooms on your Cloudflare, and
|
|
434
|
+
deploys it with Workers Builds: every push to \`main\` goes live, and every other branch gets its own Preview.
|
|
435
|
+
The site plays a first game the moment it is up.
|
|
436
|
+
|
|
437
|
+
Then open the site and tap **Connect to Claude**, or ask Claude in the Claude app to set up your studio with the
|
|
438
|
+
Homie connector: it makes games, songs and videos here, in a pull request you merge with one tap.
|
|
439
|
+
|
|
440
|
+
\`AGENTS.md\` says how everything here works.
|
|
441
|
+
`;
|
|
325
442
|
}
|
|
326
443
|
|
|
327
444
|
/**
|
|
@@ -352,7 +469,7 @@ function insideGit(dir) {
|
|
|
352
469
|
try { return execFileSync('git', ['rev-parse', '--is-inside-work-tree'], { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() === 'true'; } catch { return false; }
|
|
353
470
|
}
|
|
354
471
|
|
|
355
|
-
export function newStudio(folder, { name, homie, slug: askedSlug, install = true } = {}) {
|
|
472
|
+
export function newStudio(folder, { name, homie, slug: askedSlug, install = true, template = false } = {}) {
|
|
356
473
|
if (typeof folder !== 'string' || !folder.trim()) throw new Error('name the folder for the new studio, e.g. `homie-studio new ~/studios/night-owls --name "Night Owls"`. Nothing was written.');
|
|
357
474
|
if (!name || !String(name).trim()) throw new Error('give the studio a name: --name "Night Owls". Nothing was written.');
|
|
358
475
|
const dir = resolve(folder.replace(/^~(?=\/|$)/, homedir()));
|
|
@@ -367,7 +484,7 @@ export function newStudio(folder, { name, homie, slug: askedSlug, install = true
|
|
|
367
484
|
if (entries.length) throw new Error(`${real} is not empty (${entries.slice(0, 5).join(', ')}${entries.length > 5 ? ', …' : ''}). A new studio goes in a new or empty folder. Nothing was written.`);
|
|
368
485
|
}
|
|
369
486
|
const slug = slugify(askedSlug || name);
|
|
370
|
-
const files = studioFiles({ name: String(name).trim(), slug, homie: homie || 'https://homie.rocks' });
|
|
487
|
+
const files = studioFiles({ name: String(name).trim(), slug, homie: homie || 'https://homie.rocks', template });
|
|
371
488
|
mkdirSync(dir, { recursive: true });
|
|
372
489
|
const wrote = [];
|
|
373
490
|
for (const [rel, content] of Object.entries(files)) {
|
package/lib/setup.mjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `homie-studio setup attach <hs_…>` — this repository is the studio the Claude app's setup card (the Homie MCP
|
|
3
|
+
* tool studio_setup) is making, said once from the Claude Code session that works in it:
|
|
4
|
+
*
|
|
5
|
+
* - the directory records that Claude works in this repository (the card's "Let Claude work in it" goes green),
|
|
6
|
+
* and answers with the studio's live address once its site is connected (the card's Cloudflare step);
|
|
7
|
+
* - a copy of the public template (studio.json `template: true`) gets the name the person chose in the chat:
|
|
8
|
+
* studio.json, the Worker's STUDIO_NAME, and AGENTS.md and README.md while they are untouched; its first-run
|
|
9
|
+
* "Connect to Claude" band goes; studio.json takes the Worker and database names Cloudflare's form chose;
|
|
10
|
+
* - the live address goes into .studio/local.json (git-ignored), so `check --url` and the card know it.
|
|
11
|
+
*
|
|
12
|
+
* It sends the repository's owner/name and the studio's name and slug, nothing else: no key, no path, no code.
|
|
13
|
+
* A setup id is single use per repository: a second attach from the same repository answers the same; another
|
|
14
|
+
* repository is refused.
|
|
15
|
+
*/
|
|
16
|
+
import { spawnSync } from 'node:child_process';
|
|
17
|
+
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { configNames } from './cloudflare.mjs';
|
|
20
|
+
import { networkWhy } from './progress.mjs';
|
|
21
|
+
import { CONNECT_BAND, agentsMd, readme, slugify, templateReadme } from './scaffold.mjs';
|
|
22
|
+
import { configPath, readStudio, writeLocal, writeStudio } from './studio.mjs';
|
|
23
|
+
import { STUDIO_VERSION } from './version.mjs';
|
|
24
|
+
|
|
25
|
+
const SETUP_ID = /^hs_[a-f0-9]{32}$/;
|
|
26
|
+
|
|
27
|
+
/** owner/repo of this checkout's GitHub remote (a Claude Code cloud session's remote goes through its own proxy). */
|
|
28
|
+
export function repoOf(root) {
|
|
29
|
+
const r = spawnSync('git', ['remote', 'get-url', 'origin'], { cwd: root, encoding: 'utf8', timeout: 5000 });
|
|
30
|
+
if (r.status !== 0) return null;
|
|
31
|
+
const url = r.stdout.trim().replace(/\.git$/, '').replace(/\/+$/, '');
|
|
32
|
+
const m = /[/:]([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))\/([A-Za-z0-9._-]{1,100})$/.exec(url);
|
|
33
|
+
return m ? `${m[1]}/${m[2]}` : null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function setupAttach(root, id, { homie } = {}) {
|
|
37
|
+
if (!SETUP_ID.test(String(id ?? ''))) return { ok: false, command: 'setup attach', why: 'attach to the setup id the Claude app\'s setup card showed: hs_ and 32 hex digits' };
|
|
38
|
+
const studio = readStudio(root);
|
|
39
|
+
const directory = String(homie || studio.homie?.directory || 'https://homie.rocks').replace(/\/+$/, '');
|
|
40
|
+
const repo = repoOf(root);
|
|
41
|
+
let res; let body = null;
|
|
42
|
+
try {
|
|
43
|
+
res = await fetch(`${directory}/api/studio/setup/${id}/attach`, {
|
|
44
|
+
method: 'POST', headers: { 'content-type': 'application/json', 'user-agent': `homie-studio/${STUDIO_VERSION}` },
|
|
45
|
+
body: JSON.stringify({ repo, studio: { name: studio.name, slug: studio.slug, template: studio.template === true }, version: STUDIO_VERSION }),
|
|
46
|
+
signal: AbortSignal.timeout(10_000),
|
|
47
|
+
});
|
|
48
|
+
body = await res.json().catch(() => null);
|
|
49
|
+
} catch (error) { return { ok: false, command: 'setup attach', why: `${directory} did not answer (${error?.message ?? error})` }; }
|
|
50
|
+
const blocked = networkWhy(res, directory);
|
|
51
|
+
if (blocked) return { ok: false, command: 'setup attach', needs: 'network', why: blocked };
|
|
52
|
+
if (!res.ok || !body?.ok) return { ok: false, command: 'setup attach', why: body?.message ?? `${directory} answered ${res.status}` };
|
|
53
|
+
|
|
54
|
+
const renamed = [];
|
|
55
|
+
const name = typeof body.name === 'string' && body.name.trim() ? body.name.trim().slice(0, 60) : null;
|
|
56
|
+
if (studio.template === true) {
|
|
57
|
+
const next = { ...readStudio(root) };
|
|
58
|
+
delete next.template;
|
|
59
|
+
const was = { name: next.name, slug: next.slug };
|
|
60
|
+
if (name) { next.name = name; next.slug = slugify(name); }
|
|
61
|
+
// The Worker and database are whatever Cloudflare's form named them: studio.json follows wrangler.jsonc.
|
|
62
|
+
const names = configNames(root);
|
|
63
|
+
next.cloudflare = { ...next.cloudflare, ...(names.worker ? { worker: names.worker } : {}), ...(names.d1 ? { d1: names.d1 } : {}) };
|
|
64
|
+
writeStudio(root, next);
|
|
65
|
+
renamed.push('studio.json');
|
|
66
|
+
if (name) {
|
|
67
|
+
const cfg = configPath(root);
|
|
68
|
+
const text = readFileSync(cfg, 'utf8');
|
|
69
|
+
const fixed = text.replace(/("STUDIO_NAME"\s*:\s*)"(?:[^"\\]|\\.)*"/g, (_, k) => `${k}${JSON.stringify(name)}`);
|
|
70
|
+
if (fixed !== text) { writeFileSync(cfg, fixed); renamed.push('wrangler.jsonc'); }
|
|
71
|
+
const untouched = (file, before, after) => {
|
|
72
|
+
const path = join(root, file);
|
|
73
|
+
if (existsSync(path) && readFileSync(path, 'utf8') === before) { writeFileSync(path, after); renamed.push(file); }
|
|
74
|
+
};
|
|
75
|
+
untouched('AGENTS.md', agentsMd(was), agentsMd({ name: next.name, slug: next.slug }));
|
|
76
|
+
untouched('README.md', templateReadme(), readme({ name: next.name }));
|
|
77
|
+
}
|
|
78
|
+
const band = join(root, 'site', 'partials', 'home.html');
|
|
79
|
+
if (existsSync(band) && readFileSync(band, 'utf8') === CONNECT_BAND) { rmSync(band); renamed.push('site/partials/home.html (removed)'); }
|
|
80
|
+
}
|
|
81
|
+
if (body.site) writeLocal(root, { url: body.site, connectedAt: new Date().toISOString() });
|
|
82
|
+
return {
|
|
83
|
+
ok: true, command: 'setup attach', setup: id, repo, site: body.site ?? null, name: name ?? studio.name, renamed,
|
|
84
|
+
message: body.site ? `This repository is ${name ?? studio.name}, live at ${body.site}. The Claude app's card shows it.` : `This repository is ${name ?? studio.name}. Its site is not connected yet: ${body.connect ?? 'open the site and tap Connect to Claude'}.`,
|
|
85
|
+
next: [
|
|
86
|
+
...(renamed.length ? ['commit the renamed files on a branch and open a pull request (merging it names the live site)'] : []),
|
|
87
|
+
'npm install, then npx --no-install homie-studio progress attach <hb_…> when the chat opened a build',
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
}
|