diff --git a/.gitignore b/.gitignore index ce82bf47..336000aa 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,9 @@ backend/npm-servers/*/node_modules/ frontend/dist/ # Bundled uv binaries (downloaded during build) backend/uv-bin/ +# Pre-built webapp-template node_modules archive (generated by +# scripts/build-template-archive.sh, optionally bundled into the DMG). +backend/apps/outputs/webapp_template_cache/ # Backend Python venv (created by run.ps1 / backend/run.sh) backend/.venv/ .account-factory diff --git a/backend/apps/outputs/app_builder_skill.md b/backend/apps/outputs/app_builder_skill.md index cc18beb3..bd26fc7c 100644 --- a/backend/apps/outputs/app_builder_skill.md +++ b/backend/apps/outputs/app_builder_skill.md @@ -6,8 +6,64 @@ backend you can opt into on demand). It's served live to a webview, so it behaves like a real browser tab — cross-origin `fetch`, popups, mic/camera, clipboard, anything a normal web page does. -You are **NOT** writing a single HTML file or vanilla JS. Match the -codebase's patterns. +--- + +## STEP 0 — pick the right shape for the app + +Before writing any code, decide whether this app should be **workspace** +(full React/MUI, the default) or **lightweight** (one self-contained +`index.html`). Picking wrong wastes the user's time: the workspace path +spends ~10-30 s pre-bundling MUI and React on first preview, which is +pointless when the app is a 200-line Three.js demo. + +**Lightweight** when ALL apply: +- One page, no route navigation +- No persisted server state (no DB-shaped data the user comes back to) +- No real backend logic (just CDN libraries, in-memory state) +- The whole UI is essentially one of: canvas/WebGL scene, single-file + visualization (D3/Plotly/Chart.js), single-purpose tool (formatter, + calculator, color picker), tiny game or simulator + +**Workspace** (this document's default) when ANY apply: +- Multiple pages with sidebar/route navigation +- Multiple distinct UI sections with their own state +- Real backend (FastAPI endpoints, file uploads with server processing, + auth, persisted user data) +- Real-time updates (WS/SSE) +- The user is likely to ask for more features later (chat, dashboards, + CRUD apps — these grow) + +**Examples — lightweight:** "rotating Three.js cube", "Pomodoro timer", +"JSON formatter", "Mandelbrot explorer", "CSV → bar chart (no save)", +"first-person Minecraft-style demo", "color picker", "regex tester". + +**Examples — workspace:** "chat app", "PDF previewer with annotations", +"task manager with categories", "recipe app", "weather dashboard with +saved cities", "Slack-style team chat with channels". + +If you're unsure, lean **workspace** — it's strictly more capable and the +boot cost only hits once per app, then warm cache makes subsequent boots +fast. + +### Lightweight — how + +1. Delete everything under `frontend/src/` (`index.tsx`, `app/`, `pages/`, + `shared/`). Vite serves `frontend/index.html` directly when there's no + module graph to crawl, so the pre-bundle step is skipped entirely. +2. Replace `frontend/index.html` with a single self-contained document. + Inline `