diff --git a/demo-site/DEMO-SCRIPT.md b/demo-site/DEMO-SCRIPT.md index 6a909071..2aead21f 100644 --- a/demo-site/DEMO-SCRIPT.md +++ b/demo-site/DEMO-SCRIPT.md @@ -9,9 +9,10 @@ compatibility date and `ASSETS` binding), and `functions/api/` for the school bo One take, two windows side by side on one screen: **Chrome on the left** (the site, genclass.dev), **VS Code on the right** (the site's folder, Claude Code in the integrated terminal). The story: the broken site, live → one prompt adds GenClass and deploys → the same site, fixed on the user's screen → the dashboard → the agent closes the loop. -About 12 minutes raw; sped up afterwards to 2–3 minutes (only speed changes, no cuts, no zoom). Every prompt you type -into Claude Code is in a box below: copy it. No localhost ever shows: the one act that needs a dev page runs it in a -Chrome app window, which has no address bar. +About 12 minutes raw; sped up afterwards to 2–3 minutes (only speed changes, no cuts, no zoom). **Nothing is typed on +camera** except the site's address in the page check and what a visitor types on the site: every prompt comes from a +Copy button on genclass.dev, and Claude Code starts from the Claude logo in VS Code. No localhost ever shows: the one +act that needs a dev page runs it in a Chrome app window, which has no address bar. ## What GenClass does about the five bugs (tested, see the last section) @@ -29,34 +30,65 @@ the page loads, the stale response, the dropped write and the duplicate, and the ## 0. Before you record (15 minutes, not recorded) -1. **Quit the other Claude Code session** on this Mac (the desktop app's Code tab): its GenClass MCP server owns the - bridge port, and the Claude in VS Code must own it so the dashboard mirror and the replays work. -2. **Reset the code** to its broken state and **deploy it to snowday-predictor.ca**, right before you start recording - (real visitors see the five bugs from now until act 3's deploy): +1. **One GenClass MCP server on this Mac, the one act 6 starts**: it must own the bridge port so the dashboard mirror and + the replays work. Quit other Claude Code sessions that run one (or stop their genclass server). The repo's own + `.mcp.json` is set aside as `.mcp.json.off` for the recording. +2. **Reset the code** to its broken state, forget the last take's MCP entry (Claude may save it for this folder or, since + the folder sits inside the GenClass repository, for every project), and **deploy it to snowday-predictor.ca**, + right before you start recording (real visitors see the five bugs from now until act 3's deploy): ```bash - cd ~/GenClass-lib-main/demo-site/snowday-before && git checkout -- . && git clean -fdqx . && XDG_CONFIG_HOME=~/.config-dizon CLOUDFLARE_ACCOUNT_ID=4daefdf7440d182204be114a9c9f5074 npx --yes wrangler@4 deploy + cd ~/GenClass-lib-main/demo-site/snowday-before && git checkout -- . && git clean -fdqx . && (claude mcp remove genclass -s local; claude mcp remove genclass -s user; true) 2>/dev/null && npm run deploy ``` - (`XDG_CONFIG_HOME=~/.config-dizon` is a separate wrangler login, so Mehar's default login stays as it is; it reaches - both the Dizon and Daybot accounts, so `CLOUDFLARE_ACCOUNT_ID` picks Dizon.) Open https://snowday-predictor.ca once - (⌘⇧R, so the cached page goes). -3. **The dev server**, for act 6 only: `npx --yes wrangler@4 dev --port 8788` in the same folder, in a terminal you - will not show. Leave it running. -4. **Chrome**: one window, signed in to Google, no other tabs. Bookmark bar hidden (⌘⇧B). Put it on the left half. -5. **VS Code**: `code ~/GenClass-lib-main/demo-site/snowday-before`, open `index.html`. Open the integrated terminal (⌃`) - and drag it up to about half the window. Close the chat side bar. Put the window on the right half. In the terminal: + (`npm run deploy` is the folder's own deploy script: wrangler with the Dizon login, `XDG_CONFIG_HOME=~/.config-dizon`, + so Mehar's default login stays as it is. `git clean -fdqx` also removes a practice run's `.mcp.json`; the folder's + `.vscode` and `.claude` settings are committed, so they stay.) Open https://snowday-predictor.ca once (⌘⇧R, so the cached page + goes). +3. **The dev server and the dev page**, for act 6 only, in a terminal you will not show: `npx --yes wrangler@4 dev + --port 8788` in the same folder, then the dev page in a Chrome app window (no address bar), minimized with ⌘M: ```bash - claude --model opus + open -na "Google Chrome" --args --app="http://localhost:8788/?genclass=observe" --window-size=760,952 --window-position=0,30 ``` +4. **Chrome**: one window, signed in to Google, **signed out of genclass.dev** (if you are signed in: your account + menu at the top right of genclass.dev → Sign out), so act 2 shows the sign-in. Exactly two tabs: **tab 1** + https://genclass.dev (the home page), **tab 2** https://snowday-predictor.ca. Leave tab 1 in front. Bookmark bar + hidden (⌘⇧B). Put the window on the left half. From here on the recording never types an address: every page is a + click from these two tabs. +5. **VS Code**: open the folder `~/GenClass-lib-main/demo-site/snowday-before` (File → Open Folder), open `index.html`, + close every terminal. Put the window on the right half. Do not start Claude: act 3 starts it with the **Claude logo + at the top right of the editor**, which opens Claude Code in a new terminal (the folder's `.vscode/settings.json`). + The folder's `.claude/settings.json` picks Opus and lets Claude edit files without asking; it still asks before a + deploy (press Enter on **Yes**). 6. **Rehearse the fast typing once**: in "Find your school board", type `halton` fast (under a second). The list ends on five boards (the answer for "h") while the box says halton. That is the first bug. +## 0b. The page check first (30 s) + +Chrome, tab 1, the genclass.dev home page. Scroll down one screen to **Check any page.**, click the box that says +`your-site.com`, type `snowday-predictor.ca` and click **Scan**. A cached result comes back in a few seconds (a fresh +scan takes about 40 s; results are cached for 6 hours, so run it once before recording). Show: + +- **50/100 without GenClass, 56 with GenClass on.** Scroll the categories: Visual bugs 75, Accessibility 56, Phone + 75, Speed 84, Security 46, Search and sharing 82, **Races 75**. +- **Text that is almost invisible on its background**: the white banner, measured at 1.00:1, with the CSS fix, and + "With GenClass on: fixed". +- **Search results for an older query stayed on the page**: the page check typed `a`, `ab`, `abc` into the board + finder, the answers came back out of order, and the page showed seven boards where the last query alone shows none. +- The rest, each with its element and a one-line fix: low-contrast buttons, a small tap target, missing security + headers, "read more" links. + +Say: *"Before touching any code: a free page check on genclass.dev. It already finds the invisible banner and the +search race, each with the fix. What a scan can't do is click through the page the way people do: the stuck scroll, +the frozen page, the double vote. That's what GenClass in the page is for."* Stay on this page: act 2 starts from its +**Fix it with GenClass** button. + ## 1. The broken site, live (60 s) -Chrome: https://snowday-predictor.ca. Open DevTools docked at the bottom (⌥⌘I), **Network** tab, filter `boards`. +Chrome: click **tab 2** (snowday-predictor.ca) and reload it (⌘R). Open DevTools docked at the bottom (⌥⌘I), **Network** +tab, type `boards` in its filter box. Five bugs, in this order (the last one freezes the page, so it goes last): 1. Point at the white strip under the menu. Say: *"There is a storm-watch banner there. White on white."* @@ -66,54 +98,46 @@ Five bugs, in this order (the last one freezes the page, so it goes last): for the first letter lands last and wins. A race condition: every autocomplete has one."* 4. In "Will schools close tomorrow?", double-click **Snow day** at a normal pace: the count goes **124 → 126**. Say: *"One person, two votes."* -5. Click **OK** on the notice at the bottom left, then scroll with the wheel: **the page does not move**. Say: *"The - notice locked scrolling and forgot to unlock it."* +5. Click **OK** on the notice at the bottom left, then scroll with the wheel: **the page does not move**. Point out + that there is not one ad on screen: the site runs Google ads, and the first one sits in the cards just below the + bottom of the window. Say: *"The notice locked scrolling and forgot to unlock it. And this site lives on ads: every + one of them is below this line, and nobody can scroll to them. This bug costs money."* 6. Mistype the postal code, `L6H`, and Predict: the error shows, then click anything: **nothing responds**. Say: *"Predict blocks clicks while it works and only unblocks when it succeeds. One typo and the page is dead. Five bugs, live."* -## 2. Sign in and get the prompt (40 s) - -Chrome: https://genclass.dev/login → **Continue with Google** → **New project**, name `snowday`, **Create new project**. -The project opens on its **Connect** dialog. Click **Copy the prompt for your coding agent**. Say: *"That's the whole -setup. One prompt."* Then the **MCP** tab → **Create agent link** (you copy it in 3b). - -## 3. Claude adds GenClass and deploys (3–4 minutes of Claude working; this stretch gets sped up) - -VS Code terminal. Nothing to show in Chrome during this act. - -- **3a.** Paste the copied prompt and add one line at the end before Enter: - - ```text - This is a static site with no build step (index.html served by a Cloudflare Worker, worker.js): use the script tag from the dashboard, and load the agent link from the same CDN version only when the page is on localhost. - ``` +## 2. Sign in and pick what GenClass does (40 s) - Claude adds the script tag with the key, connects the store, adds the agent link for local pages and the MCP - server, and reports. Keep `index.html` open so the edit shows. Say: *"No docs read. The dashboard told the agent what - to do."* -- **3b.** The agent link for the dashboard mirror (paste yours): +Chrome, tab 1, the page check's result. Every step is a click: - ```text - Add to the genclass server in .mcp.json the env GENCLASS_DASHBOARD = and GENCLASS_REPORT = on, then tell me to restart you. - ``` +1. **Fix it with GenClass**, under the score. +2. **Continue with Google** → pick your Google account (a first sign-in creates the account). +3. **Create a new project** opens with the name already filled in, `snowday-predictor.ca`. Click **Create new + project**. +4. The project opens on the **Connect to your project** dialog, **Framework** tab. Tick, top to bottom: + **Guard**, **Eager**, **Badge on the live site**, **Connect my coding agent to production**, **Deploy when done**. + Say: *"Guard: fix what it's sure of. The badge, so you can see it. My agent gets production. And deploy."* +5. **Copy the prompt for your coding agent**. Say: *"That's the whole setup. One prompt."* +6. Close the dialog with the **×** at its top right. The project's overview stays open in tab 1, waiting for its + first event. - Then `/exit` and `claude --model opus --continue`; approve the project's MCP server once. -- **3c.** The demo settings: +## 3. Claude adds GenClass and deploys (3–4 minutes of Claude working; this stretch gets sped up) - ```text - Three small changes for this demo. (1) On the GenClass script tag, or in window.GENCLASS_CONFIG, set mode "guard", aggressiveness "eager" and visual { on: true, fix: true }. (2) Show the devtools overlay on every host, not only locally, so the audience sees what GenClass does. (3) Keep the board search state in one GenClass atom instead of the two store keys: const boards = GenClass.runtime.atom("boards", { query: "", results: [] }); the input handler writes it once per response with boards.set((s) => ({ ...s, results: data.results, query: data.q })), and the list renders from boards.subscribe. Keep everything else as it is. Tell me the lines you changed. - ``` +VS Code on the right. - Say: *"Guard mode. GenClass may now act, with minimal reversible actions, when it is sure."* -- **3d.** Deploy: +1. Click the **Claude logo** at the top right of the editor: Claude Code opens in a terminal. +2. Click in its input box and paste (⌘V): Claude Code shows the prompt folded as *[Pasted text …]*. Press Enter. +3. Claude puts the script tags on every page (guard, eager, the visual fixes, the badge), keeps the board search in one + atom, adds the agent link for local pages and its own GenClass MCP server with the agent link, checks the site + locally, then asks to run `npm run deploy`: press Enter on **Yes**. Keep `index.html` open: the edits show as Claude + makes them. - ```text - Deploy this to production with XDG_CONFIG_HOME=~/.config-dizon CLOUDFLARE_ACCOUNT_ID=4daefdf7440d182204be114a9c9f5074 npx --yes wrangler@4 deploy, and tell me when https://snowday-predictor.ca serves it. - ``` +Say: *"No docs read, nothing typed. The dashboard told the agent what to do."* When Claude says the site is deployed, +go to act 4. ## 4. The same site, fixed on the user's screen (75 s) -Chrome: https://snowday-predictor.ca, reloaded (⌘⇧R). DevTools stays open, now on the **Console** tab: every line +Chrome: click **tab 2** (snowday-predictor.ca) and reload it with ⌘⇧R. DevTools stays open, now on the **Console** tab: every line GenClass prints starts with `[GenClass]`. Wait for the badge at the bottom right to say **guard** and the model to be ready (about 5 s). The same things, same order: @@ -125,52 +149,47 @@ ready (about 5 s). The same things, same order: 3. Double-click **Snow day**: the count still goes up by 2. Console: *Flagged a duplicate request … Not acted on*. Say: *"Not everything is safe to fix on the fly. This one it reports, and the agent fixes it in the code."* 4. Click OK on the notice, scroll: **the page scrolls** a second later. Console: *the page cannot scroll: html has - overflow-y: hidden…*, then *Applied a CSS fix: removed the inline overflow: hidden*. + overflow-y: hidden…*, then *Applied a CSS fix: removed the inline overflow: hidden*. Keep scrolling, slowly, down + the page: **the ads load** in the cards, the FAQ and the article list as each comes into view. Say: *"And there + are the ads. One CSS fix on the user's screen, and the site's revenue is back."* Scroll back to the top for the last + one. 5. Mistype `L6H`, Predict: the error shows, and a second later **clicks work**. Console: *pointer-events: none has been left on body…*, then *Applied a CSS fix: removed the inline pointer-events: none on body*. -Badge → **Interventions**: *"Prevented a stale response … discard · guard"* with **Undo**. **Checks**: the banner's +Click the GenClass badge at the bottom right → **Interventions**: *"Prevented a stale response … discard · guard"* with **Undo**. **Checks**: the banner's contrast, the scroll lock and the click block, each with *"Runtime fix: applied"* and its CSS. Say: *"Nothing in the site's code changed. GenClass fixed four of five on the user's screen, reversibly, and reported the fifth."* ## 5. The dashboard (45 s) -Chrome: the project on genclass.dev (wait about 10 s after act 4). Slowly, scroll a little on each: **Overview** -(page loads, problems, stopped by GenClass, model loaded), **Problems** (stale responses, double submits, each with a -**Copy prompt**), **What GenClass did**, **Pages**. Say: *"Everything production saw, with a prompt per problem."* +Chrome: click **tab 1** (the project), about 10 s after act 4, and click **Refresh** at the top right. Then the left +sidebar, one item at a time, scrolling a little on each: -## 6. The agent closes the loop (3 minutes; Claude's thinking gets sped up) +1. **Project overview**: page loads, problems found, stopped by GenClass, the model loaded. +2. **Problems**: *What GenClass found*, the stale responses and the double submits, each with a **Copy prompt**. +3. **Actions**: *What GenClass did*, the reverted write and the CSS fixes. +4. **Pages**: which pages had them. -The dev build on this Mac, in a Chrome app window (no address bar): +Say: *"Everything production saw, with a prompt per problem."* Back on **Problems**, click **Fix them all: copy one +prompt**. -```bash -open -na "Google Chrome" --args --app="http://localhost:8788/?genclass=observe" --window-size=760,952 --window-position=0,30 -``` +## 6. The agent closes the loop (3 minutes; Claude's thinking gets sped up) -Type `halton` fast once. Say: *"The dev build, where the agent can replay the network."* Then, one prompt at a time -(close the app window with ⌘W while Claude edits; reopen it with the command above when a prompt asks for a load): +1. VS Code: click the **Claude logo** again. A new conversation opens in a new terminal: it has the GenClass MCP server + act 3 added. Paste (⌘V), Enter. +2. Click the dev page's window in the Dock (Chrome, minimized in section 0: the dev build, no address bar). Say: *"The + dev build, where the agent can replay the network."* +3. Claude checks the page is connected, then says in one line what to do on the page each time it needs a load + (reload, type `halton` fast; double-click **Snow day**; and so on). Do it; Claude waits and goes on by itself. Leave + the window alone while Claude edits. -1. ```text - The board search on the dev page shows boards for the wrong query sometimes. Use genclass_status to check the page is connected, then start an explore with genclass_explore (3 runs) on that page; I will load it five times and type the same search. Do not report yet. - ``` - Five loads: reload (⌘R), wait 3 s, type `halton` fast, wait 3 s. -2. ```text - Report the explore with genclass_explore and explain the top race finding with genclass_explain, briefly. Then arm a replay of that finding with genclass_replay; I will load the page and type the same search. Do not fix anything yet and do not check the result yet. - ``` - One load with `halton`. Close the window. -3. ```text - Check the replay result with genclass_replay. If it reproduced, fix the bug in index.html the simplest way (a sequence number per search request so an older response that arrives later is ignored), save the regression test genclass_explain generates under test/, then arm the replay again. I will load the page and type the same search; do not check the result yet. - ``` - Say at **REPRODUCED**: *"Proven, not guessed."* One load with `halton`. Close the window. -4. ```text - Check the replay result with genclass_replay. Then the other four problems GenClass found on this page: the double vote in the poll, the alert bar's contrast, the click block after a mistyped postal code and the scroll lock after the notice. Use genclass_findings and genclass_explain on each, fix the cause in index.html (small, idiomatic fixes), and sum up in five lines what you found, proved and fixed. - ``` - Say at **not reproduced**: *"Same order, no bug."* Then: *"And the other four, from GenClass's own measurements, a - line each. Deploy, and GenClass keeps watching."* +Say at **REPRODUCED**: *"Proven, not guessed."* At **not reproduced**: *"Same order, no bug."* At the summary: +*"Every problem, one line each: found, proven, fixed. Deploy, and GenClass keeps watching."* ## 7. The closed loop on the dashboard (20 s) -The project's **Loop**: **Issue found → Reproduced → Fix proven → Closed**, then **What your agent did**. Say: +Chrome's main window, **tab 1** (the project), left sidebar: **Closed loop**. It shows **Issue found → Reproduced → +Fix proven → Closed**; scroll to **What your agent did**. Say: *"Everything the agent did, mirrored here. A person reads the test and ships."* Stop the recording. ## 8. After the recording: the real site back, GenClass on @@ -183,7 +202,9 @@ cd ~/GenClass-lib-main/demo-site/snowday-before && XDG_CONFIG_HOME=~/.config-diz `3b0ff5e1-…` is the version Mehar deployed on 2026-10-25, live when the demo was prepared. The demo's board finder and poll are demo data and must not stay on the real site; the agent's fixes from act 6 stay in the -folder as the record of the demo. Then `git checkout -- . && git clean -fdqx .` resets the folder for the next take. +folder as the record of the demo. Section 0, step 2 resets the folder for the next take and removes the take's GenClass +MCP entry (it holds the agent link); the project from this take can go with **Project Settings → Delete project** on +genclass.dev. ## After: the 2–3 minute cut @@ -195,6 +216,7 @@ waits. ```bash npm run build -w @genclass/runtime +node demo-site/record/rehearse-act3.mjs # act 3 from genclass.dev's own copied prompt (Guard, Eager, Badge ticked): guard 4/5 on what Claude wrote node demo-site/record/verify-snowday.mjs --keep # observe: 5/5 bugs show; guard: 4/5 fixed, the double vote flagged node demo-site/record/agent-fix-snowday.mjs # Claude (Opus) fixes all five in index.html from GenClass's findings node demo-site/record/dashboard-e2e.mjs # a real genclass.dev project: events, problems, the Loop log mirrored @@ -205,9 +227,16 @@ from hit testing, and while it is out of view). It is published and the dashboar ## If something does not fire +- A full-screen Google ad after a reload, or an ad bar pinned to the bottom over the notice or the badge: close it + with its × or its arrow tab. They are Google's, not the bugs; Google shows them less often to someone who has + loaded the site many times, so a few may come up and then stop. +- After the scroll fix some ad slots stay empty (a gap in the card): Google fills most slots, not every one. - The race needs the six letters within about a second: type fast. - Wait for the badge's model before typing (the first seconds after a load). -- The board search must be the atom from 3c, or guard cannot drop the stale write. +- Guard drops the stale search only when the board search is one atom (the prompt's step 4 asks for it) and Eager is + ticked: guard's default margin lets this site's stale answer through. +- Claude stops with a question instead of going on: press Enter on its suggested answer; the prompts are written so + it needs no typed reply. - `genclass_status` says no page: load the dev page after Claude's MCP server started. - A replay says the armed load recorded nothing: a reload used it up. Arm again, then load once. - The shop (`demo-site/tiny-shop-before`, `DEMO.md`) is the fallback demo: five bugs, all five fixed in guard. diff --git a/demo-site/record/rehearse-act3.mjs b/demo-site/record/rehearse-act3.mjs index 3ba8cc77..c7e581bb 100644 --- a/demo-site/record/rehearse-act3.mjs +++ b/demo-site/record/rehearse-act3.mjs @@ -1,10 +1,12 @@ -// A rehearsal of the demo's act 3 on a copy of demo-site/snowday-before: a fresh genclass.dev project (/start), its real -// Connect prompt plus the script's static-site line, then the script's three-change prompt (3c), both through Claude -// Code on Opus exactly as the recording does; then what Claude wrote is checked, and the five bugs are played on the -// result in guard (verify-snowday.mjs --src). No deploy: the copy stays in out/rehearsal-snowday. +// A rehearsal of the demo's act 3 on a copy of demo-site/snowday-before: a fresh genclass.dev project (/start), its +// Connect dialog with the act's choices ticked (Guard, Eager, Badge on the live site, Connect my coding agent to +// production; never Deploy), the prompt its Copy button holds, given to Claude Code on Opus exactly as the recording +// pastes it; then what Claude wrote is checked, and the five bugs are played on it in guard (verify-snowday.mjs --src, +// on port 8791 so the demo's dev server on 8788 keeps running). No deploy: the copy stays in out/rehearsal-snowday, and +// the MCP entry Claude adds for the agent link is removed at the end. // Usage: node demo-site/record/rehearse-act3.mjs import { spawnSync } from "node:child_process"; -import { readFileSync, rmSync, writeFileSync } from "node:fs"; +import { copyFileSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; import { chromium } from "playwright"; @@ -13,10 +15,6 @@ const REC = dirname(fileURLToPath(import.meta.url)); const ROOT = join(REC, "..", ".."); const WORK = join(REC, "out", "rehearsal-snowday"); const sh = (cmd, cwd = ROOT) => spawnSync("bash", ["-lc", cmd], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], maxBuffer: 50 * 1024 * 1024 }); -const SCRIPT = readFileSync(join(ROOT, "demo-site", "DEMO-SCRIPT.md"), "utf8"); -const block = (after) => { const i = SCRIPT.indexOf(after); const a = SCRIPT.indexOf("```text\n", i) + 8; return SCRIPT.slice(a, SCRIPT.indexOf("\n ```", a)).trim(); }; -const STATIC_LINE = block("- **3a.**"); -const PROMPT_3C = block("- **3c.**"); // ---------------------------------------------------------------------------------------------------- the project and its prompt const browser = await chromium.launch({ headless: true }); @@ -27,41 +25,45 @@ await page.click("#go"); await page.waitForSelector("#dash", { state: "visible", timeout: 30000 }); const link = (await page.$eval("#dash", (a) => a.textContent)).trim(); await page.goto(`${link}#connect`, { waitUntil: "domcontentloaded" }); -await page.waitForTimeout(3000); -const copied = (await page.locator('button:has-text("Copy the prompt for your coding agent")').first().getAttribute("data-copy")) ?? ""; +await page.waitForSelector("#cchoices", { state: "visible", timeout: 15000 }); +for (const k of ["guard", "eager", "badge", "agent"]) await page.check(`#cchoices [data-choice="${k}"]`); +const copied = (await page.getAttribute("#cpinstall", "data-copy")) ?? ""; await browser.close(); const token = (copied.match(/gc_[A-Za-z0-9]{22}/) ?? [""])[0]; -console.log(`project: key ${token ? "found" : "MISSING"}, prompt ${copied.length} chars, overlay line ${copied.includes("mountDevtools") ? "yes" : "no"}`); +console.log(`project: key ${token ? "found" : "MISSING"}, prompt ${copied.length} chars, guard ${copied.includes('data-mode="guard"') ? "yes" : "no"}, agent link ${copied.includes("GENCLASS_DASHBOARD=") ? "yes" : "no"}, deploy ${copied.includes("Deploy it") ? "YES (should not be)" : "no"}`); -// ---------------------------------------------------------------------------------------------------- Claude, twice +// ---------------------------------------------------------------------------------------------------- Claude, once, with the copied prompt rmSync(WORK, { recursive: true, force: true }); -sh(`rsync -a --exclude .wrangler --exclude node_modules "${join(ROOT, "demo-site", "snowday-before")}/" "${WORK}/"`); -const claude = (prompt, cont) => { - const t0 = Date.now(); - const r = sh(`export PATH="$HOME/.local/bin:$PATH"; claude -p ${JSON.stringify(prompt)} ${cont ? "--continue" : ""} --model opus --output-format json --permission-mode acceptEdits --allowedTools "Bash,Edit,Write,Read,Glob,Grep,WebFetch,mcp__genclass__*"`, WORK); - let out = ""; try { out = JSON.parse(r.stdout).result ?? r.stdout; } catch { out = r.stdout || r.stderr; } - console.log(`\n--- Claude (${Math.round((Date.now() - t0) / 1000)} s):\n${out.slice(0, 1800)}`); -}; -claude(`${copied}\n\n${STATIC_LINE}`, false); -claude(PROMPT_3C, true); -for (const p of [8788, 8787, 5173]) sh(`lsof -nP -iTCP:${p} -sTCP:LISTEN -t | xargs -r kill 2>/dev/null; true`); +mkdirSync(WORK, { recursive: true }); +sh(`git archive HEAD demo-site/snowday-before | tar -x -C "${WORK}" --strip-components=2`); +copyFileSync(join(ROOT, "demo-site", "snowday-before", "package.json"), join(WORK, "package.json")); +const t0 = Date.now(); +const r = sh(`export PATH="$HOME/.local/bin:$PATH"; claude -p ${JSON.stringify(copied)} --model opus --output-format json --permission-mode acceptEdits --allowedTools "Bash,Edit,Write,Read,Glob,Grep,WebFetch"`, WORK); +let out = ""; +try { out = JSON.parse(r.stdout).result ?? r.stdout; } catch { out = r.stdout || r.stderr; } +console.log(`\n--- Claude (${Math.round((Date.now() - t0) / 1000)} s):\n${out.slice(0, 1800)}`); +// leave nothing behind: the MCP entry with the agent link, servers started from the copy +// Claude saves it for this folder (under the repository's root) or, seeing that, for every project: remove both +sh(`export PATH="$HOME/.local/bin:$PATH"; claude mcp remove genclass -s local; claude mcp remove genclass -s user`, WORK); +for (const pid of sh("lsof -nP -iTCP -sTCP:LISTEN -Fp | tr -d p").stdout.split("\n").filter(Boolean)) { + if (sh(`lsof -a -p ${pid} -d cwd -Fn | grep ^n | cut -c2-`).stdout.trim().startsWith(WORK)) sh(`kill ${pid}`); +} // ---------------------------------------------------------------------------------------------------- what Claude wrote const html = readFileSync(join(WORK, "index.html"), "utf8"); const has = (name, ok) => console.log(` ${ok ? "ok " : "MISSING"} ${name}`); console.log("\nindex.html:"); -has("the project key", html.includes(token)); +has("the project key", !!token && html.includes(token)); has("the GenClass runtime from the CDN", /cdn\.jsdelivr\.net\/npm\/@genclass\/runtime@/.test(html)); -has("guard mode", /guard/.test(html)); +has("guard mode", /data-mode="guard"|mode:\s*["']guard/.test(html)); has("eager", /eager/.test(html)); -has("visual fixes", /fix:\s*true|data-visual|visual/.test(html)); -has("the devtools overlay", /devtools/.test(html)); -has("the boards atom", /atom\(\s*["']boards["']/.test(html)); -has("the agent link for localhost", /connectAgent/.test(html)); -has(".mcp.json", (() => { try { return readFileSync(join(WORK, ".mcp.json"), "utf8").includes("@genclass/mcp"); } catch { return false; } })()); -writeFileSync(join(REC, "out", "rehearsal-head.txt"), html.slice(0, html.indexOf(""))); +has("visual fixes", /data-visual="fix"|fix:\s*true/.test(html)); +has("the overlay on every host", /data-devtools(?!="local")|mountDevtools|devtools:\s*true/.test(html)); +has("the board search as one value (no separate boards.query key; an atom or one guarded key)", /\b(atom|guard)\(/.test(html) && !/boards\.query/.test(html)); +has("the agent link for local hosts", /connectAgent/.test(html)); +writeFileSync(join(REC, "out", "rehearsal-head.txt"), html.slice(0, html.indexOf(' /^==|fixed|BROKEN|raw/.test(l)).join("\n")); +const v = spawnSync(process.execPath, [join(REC, "verify-snowday.mjs"), "--src", WORK, "--keep", "--port", "8791"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }); +console.log(v.stdout.split("\n").filter((l) => /^==|fixed|BROKEN|guard:/.test(l)).join("\n")); diff --git a/demo-site/record/verify-snowday.mjs b/demo-site/record/verify-snowday.mjs index e2d97f25..cf7931f6 100644 --- a/demo-site/record/verify-snowday.mjs +++ b/demo-site/record/verify-snowday.mjs @@ -4,8 +4,9 @@ // five bugs in observe (they must show) and in guard (they must not): // 1 stale board search (the first letter's answer lands last) 2 double vote 3 white text on white // 4 click block Predict leaves after a mistyped postal code 5 scroll lock the notice leaves behind -// Usage: node demo-site/record/verify-snowday.mjs [--keep] [--src ] (--src: an already integrated copy, e.g. -// after the agent's fixes; the bugs are then expected fixed in observe too). Build the runtime first. +// Usage: node demo-site/record/verify-snowday.mjs [--keep] [--src ] [--port ] (--src: an already integrated copy, e.g. +// after the agent's fixes; the bugs are then expected fixed in observe too; --port: not 8788, while the demo's dev server +// runs there). Build the runtime first. import { spawn, spawnSync } from "node:child_process"; import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { dirname, join } from "node:path"; @@ -18,7 +19,7 @@ const args = process.argv.slice(2); const SRC = args.includes("--src") ? args[args.indexOf("--src") + 1] : join(ROOT, "demo-site", "snowday-before"); const integrated = args.includes("--src"); const WORK = join(REC, "out", "verify-snowday"); -const PORT = 8788; +const PORT = args.includes("--port") ? Number(args[args.indexOf("--port") + 1]) : 8788; const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); const sh = (cmd, cwd = ROOT) => spawnSync("bash", ["-lc", cmd], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }); diff --git a/demo-site/snowday-before/.assetsignore b/demo-site/snowday-before/.assetsignore index 1dbed2b9..5ab48ae9 100644 --- a/demo-site/snowday-before/.assetsignore +++ b/demo-site/snowday-before/.assetsignore @@ -13,3 +13,4 @@ test .mcp.json .genclass .vscode +.claude diff --git a/demo-site/snowday-before/.claude/settings.json b/demo-site/snowday-before/.claude/settings.json new file mode 100644 index 00000000..6f4f7287 --- /dev/null +++ b/demo-site/snowday-before/.claude/settings.json @@ -0,0 +1,15 @@ +{ + "model": "opus", + "permissions": { + "defaultMode": "acceptEdits", + "allow": [ + "Bash(npx --yes wrangler@4 dev:*)", + "Bash(npx wrangler dev:*)", + "Bash(curl:*)", + "Bash(claude mcp add:*)", + "Bash(claude mcp get:*)", + "Bash(claude mcp list:*)", + "Bash(sleep:*)" + ] + } +} diff --git a/demo-site/snowday-before/.vscode/settings.json b/demo-site/snowday-before/.vscode/settings.json new file mode 100644 index 00000000..5e1df1af --- /dev/null +++ b/demo-site/snowday-before/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + // The demo: the Claude logo at the top right of the editor opens Claude Code in a new terminal, a new conversation + // that loads the MCP servers added since (DEMO-SCRIPT.md, acts 3 and 6). + "claudeCode.useTerminal": true +} diff --git a/demo-site/snowday-before/package.json b/demo-site/snowday-before/package.json index 28193f64..9a9a11a9 100644 --- a/demo-site/snowday-before/package.json +++ b/demo-site/snowday-before/package.json @@ -4,6 +4,7 @@ "description": "Predict whether there is going to be a snow day at Halton District School Board or not? This is for complete school closure. I want the community to come together and build this the best snow day predictor ever! If you want to add more data you can go here: https://toronto.weatherstats.ca/metrics/snow.html", "main": "index.js", "scripts": { + "deploy": "XDG_CONFIG_HOME=$HOME/.config-dizon CLOUDFLARE_ACCOUNT_ID=4daefdf7440d182204be114a9c9f5074 npx --yes wrangler@4 deploy", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/demo-site/snowday-before/wrangler.jsonc b/demo-site/snowday-before/wrangler.jsonc index dc6fa8a7..649a9df6 100644 --- a/demo-site/snowday-before/wrangler.jsonc +++ b/demo-site/snowday-before/wrangler.jsonc @@ -1,5 +1,5 @@ // The live Worker behind snowday-predictor.ca (Dizon account): same name, compatibility date and ASSETS binding. -// Deploy with XDG_CONFIG_HOME=~/.config-dizon CLOUDFLARE_ACCOUNT_ID=4daefdf7440d182204be114a9c9f5074 npx wrangler@4 deploy +// Deploy with npm run deploy (package.json: wrangler with the Dizon login, XDG_CONFIG_HOME=~/.config-dizon). { "name": "snowday-predictor", "main": "worker.js",