@cs4alhaider/screenbook 0.1.0 → 0.2.1

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.
Files changed (66) hide show
  1. package/AGENTS.md +147 -0
  2. package/CLAUDE.md +4 -184
  3. package/README.md +146 -163
  4. package/bridge.js +16 -2
  5. package/cli/postinstall.js +34 -0
  6. package/cli/screenbook.js +84 -34
  7. package/cli/templates.js +54 -1
  8. package/core/browser.js +22 -7
  9. package/core/project.js +28 -7
  10. package/core/serve.js +22 -7
  11. package/docs/README.md +25 -14
  12. package/docs/brand/logo-mark.png +0 -0
  13. package/docs/brand/logo-transparent.png +0 -0
  14. package/docs/brand/logo.png +0 -0
  15. package/docs/brand/readme-header.png +0 -0
  16. package/docs/contributing/architecture.md +153 -0
  17. package/{TESTING.md → docs/contributing/testing.md} +13 -8
  18. package/docs/{app-mode-guide.md → guides/app-mode.md} +17 -10
  19. package/docs/{authoring-guide.md → guides/authoring.md} +43 -17
  20. package/docs/guides/getting-started.md +84 -0
  21. package/docs/{studio-guide.md → guides/studio.md} +3 -2
  22. package/docs/{troubleshooting.md → guides/troubleshooting.md} +11 -8
  23. package/docs/{cli.md → reference/cli.md} +15 -10
  24. package/docs/{mcp-agents.md → reference/mcp-agents.md} +3 -3
  25. package/docs/shots/android-dark.png +0 -0
  26. package/docs/shots/android-light.png +0 -0
  27. package/docs/shots/app-mode-dark.png +0 -0
  28. package/docs/shots/app-mode-light.png +0 -0
  29. package/docs/shots/hero-studio-dark.png +0 -0
  30. package/docs/shots/hero-studio-light.png +0 -0
  31. package/docs/shots/review-mode-dark.png +0 -0
  32. package/docs/shots/review-mode-light.png +0 -0
  33. package/docs/shots/rtl-arabic-dark.png +0 -0
  34. package/docs/shots/rtl-arabic-light.png +0 -0
  35. package/docs/shots/theme-lab-dark.png +0 -0
  36. package/docs/shots/theme-lab-light.png +0 -0
  37. package/docs/shots/theming-noir-dark.png +0 -0
  38. package/docs/shots/theming-noir-light.png +0 -0
  39. package/docs/shots/web-dashboard-dark.png +0 -0
  40. package/docs/shots/web-dashboard-light.png +0 -0
  41. package/examples/qahwa/features/order/screens/010-menu.html +1 -1
  42. package/examples/qahwa/features/order/screens/020-drink.html +1 -1
  43. package/examples/qahwa/features/order/screens/030-cart.html +1 -1
  44. package/examples/qahwa/features/order/screens/040-status.html +1 -1
  45. package/examples/qahwa/features/order/screens/050-status-android.html +1 -1
  46. package/examples/qahwa/features/roastery/screens/010-orders.html +1 -1
  47. package/examples/qahwa/features/roastery/screens/020-menu-editor.html +1 -1
  48. package/examples/spa-demo/app/index.html +1 -1
  49. package/examples/tokens-lab/features/lab/screens/010-swatches.html +1 -1
  50. package/examples/tokens-lab/features/lab/screens/020-typography.html +1 -1
  51. package/mcp/server.js +4 -2
  52. package/package.json +7 -6
  53. package/shell/screenhost.js +4 -1
  54. package/shell/selftest.js +18 -2
  55. package/shell/shell.css +17 -9
  56. package/shell/store.js +2 -0
  57. package/skill/SKILL.md +1 -1
  58. package/skill/references/cli-mcp.md +1 -1
  59. package/skill/references/screen-contract.md +1 -1
  60. package/docs/getting-started.md +0 -88
  61. package/docs/shots/app-mode.png +0 -0
  62. package/docs/shots/hero-studio.png +0 -0
  63. package/docs/shots/rtl-arabic.png +0 -0
  64. package/docs/shots/theme-lab.png +0 -0
  65. package/docs/shots/theming-noir.png +0 -0
  66. package/docs/shots/web-dashboard.png +0 -0
package/README.md CHANGED
@@ -1,208 +1,191 @@
1
- # ⧉ ScreenBook
1
+ <p align="center">
2
+ <a href="https://cs4alhaider.github.io/screenbook/">
3
+ <img src="docs/brand/readme-header.png" alt="ScreenBook — plain-file screens built by AI agents, reviewed by humans. Offline. Versioned. Owned by you." width="100%">
4
+ </a>
5
+ </p>
2
6
 
3
- **A static, no-build prototype studio — built for AI agents to author, humans to review.**
7
+ **A design workspace for AI agents to present to humans fully offline, agent-agnostic, and owned by you.**
4
8
 
5
- Drop folders of plain HTML screens plus small JSON files into a project and get a navigable,
6
- device-framed design gallery: iPhone / Android / browser frames, mock-data scenarios, design-token
7
- themes, dark/light and LTR/RTL toggles, guided demo flows, pinned review comments, and a
8
- machine-verified self-test plus a CLI and an MCP server so agents can build screens
9
- **without ever holding the engine's implementation in context**.
9
+ ScreenBook turns a folder on your machine into the design workspace your AI agents work in: every screen
10
+ of your product rendered inside real device frames iPhone, Android, browser with live mock
11
+ data, dark mode, right-to-left languages, guided demo walkthroughs, and a built-in design-review
12
+ workflow. AI agents build and revise the screens through a standard interface; you and your
13
+ stakeholders review, comment, and approve. When a screen is final, you hand that same file to
14
+ your agent and say: *now build the native version.*
10
15
 
11
- ![The ScreenBook studio — Qahwa demo project](docs/shots/hero-studio.png)
16
+ ![The ScreenBook studio](docs/shots/hero-studio-light.png)
12
17
 
13
- ## Why this exists
14
-
15
- Prototyping with AI agents has a failure mode: the prototype starts as "just an HTML file,"
16
- grows into a hand-rolled single-page app, and after a month you have a 20k-line runtime where
17
- **an agent can't touch one screen without reading the whole world** — and neither can you.
18
+ ```bash
19
+ npm install -g @cs4alhaider/screenbook
20
+ ```
18
21
 
19
- ScreenBook inverts every cause of that rot:
22
+ ## Why I built this
20
23
 
21
- | Instead of… | ScreenBook does… |
22
- |---|---|
23
- | One growing SPA runtime | **One file = one screen.** Full standalone HTML documents; each opens alone in a browser. |
24
- | Metadata trapped in code | **Metadata as data.** A JSON block inside each screen; indexes are derived, never hand-kept. |
25
- | App code and viewer code tangled | **A hard engine/app boundary.** Screens know one include (`bridge.js`) and a tiny API. |
26
- | Hard-coded demo data | **Seed + scenario overlays** with `{{today±N}}` date tokens — "mid-trip today" is literally today. |
27
- | CSS forks per restyle | **Design tokens as JSON themes**, flattened to CSS variables, dark mode as a delta. |
28
- | "Trust me, it works" | **A self-test gate**: every screen × theme × light/dark × LTR/RTL must render with zero console errors. |
24
+ I design and ship products with AI agents every day. The prototyping phase kept failing me in
25
+ the same way: designs lived inside chat windows. A concept would look great in a conversation,
26
+ and then reality arrived I needed *forty* screens, not one. I needed to see the empty state
27
+ and the busy state. I needed Arabic right-to-left and dark mode. I needed my co-founder to
28
+ point at a button and say "this one, move it." I needed all of it next week, again, revised.
29
29
 
30
- | | | |
31
- |---|---|---|
32
- | ![Web dashboard frame](docs/shots/web-dashboard.png) | ![Android frame, dark](docs/shots/android-dark.png) | ![Two-theme re-skin](docs/shots/theming-noir.png) |
33
- | Browser-chrome frame, scenario-driven data | Android frame, dark mode | Same screens, different theme JSON |
30
+ Chat canvases aren't built for that. Every iteration re-generates a wall of code inside a
31
+ conversation that will eventually scroll away. Nothing is versioned. Nothing runs offline.
32
+ Reviews happen in screenshots over WhatsApp. And when the design is finally "done," it's
33
+ trapped there's no clean way to hand it to the next stage of work.
34
34
 
35
- ## Setup
35
+ So I built the thing I needed: a studio where **screens are plain files on my disk**, agents
36
+ do the labor, humans do the taste, and the finished prototype becomes the specification for
37
+ the real app.
36
38
 
37
- Requirements: **Node 18**. For headless validation/screenshots: Google Chrome (or see below).
39
+ ## Why not just design in Claude?
38
40
 
39
- Full guides live in **[docs/](docs/README.md)** getting started & prerequisites, the
40
- studio tour, the authoring guide, CLI/MCP references, app mode, troubleshooting.
41
+ Keep using Claude that's the point. ScreenBook isn't a competitor to your AI; it's the
42
+ **workspace your AI works in**. The difference is where the output lives and what you can do
43
+ with it:
41
44
 
42
- ```bash
43
- # 1. Put the engine into your project (this repo IS the engine — folder name matters):
44
- git clone https://github.com/cs4alhaider/screenbook my-prototypes/engine
45
- # (npm: @cs4alhaider/screenbookafter first publish)
45
+ | Designing in a chat window | Designing in ScreenBook |
46
+ |---|---|
47
+ | One artifact per conversation; multi-screen products fall apart | A whole product: features → screens, organized like your app actually is |
48
+ | Output trapped in the thread; gone when context resets | Plain HTML + JSON files in **your git repo** diff, branch, revert, forever |
49
+ | Needs the vendor's website, account, and connection | Runs from a folder on your machine — **works fully offline** |
50
+ | Tied to one AI vendor's canvas | **Any agent** that speaks MCP (Claude Code today; the protocol is open) — or no agent at all, it's just files |
51
+ | One rendering, usually desktop-ish | Real device frames: iPhone, Android, browser — plus dark/light, LTR/RTL, and named data states you switch live |
52
+ | "Looks right" is the only test | A machine gate: every screen must render in every theme × mode × direction with **zero console errors** |
53
+ | Feedback = screenshots and paragraphs | **Pin comments on the screen itself**; your agent reads them, fixes, and marks them resolved |
54
+ | Regenerates everything each round | Agent edits one small file per screen — faster, cheaper, and nothing else breaks |
46
55
 
47
- # 2. Scaffold the project around it:
48
- cd my-prototypes
49
- node engine/cli/screenbook.js init .
56
+ ## What working in it feels like
50
57
 
51
- # 3. Run the studio:
52
- node engine/cli/screenbook.js serve .
53
- # → http://127.0.0.1:4600 · live reload · manifests auto-regenerate · no cache, ever
54
- ```
58
+ A concrete example a specialty-coffee ordering app (it ships in `examples/qahwa`, so you can
59
+ open exactly this):
55
60
 
56
- `init` creates `app.config.json`, a starter theme, a `welcome` feature with one screen — and
57
- drops **`CLAUDE.md`** (the authoring contract) plus a **packaged agent skill** into the project,
58
- so any AI agent that opens it immediately knows the rules.
61
+ **1. You brief your agent, it builds screens.**
59
62
 
60
- For headless `validate` / `screenshot`, install the one dev dependency once:
63
+ > *"Create an ordering feature: menu with our drinks from the seed data, a drink detail screen
64
+ > with a size/milk customization sheet, a cart, and a live order-status screen. iPhone frames,
65
+ > match our warm theme."*
61
66
 
62
- ```bash
63
- cd engine && npm i # playwright-core drives your installed Chrome
64
- # no Chrome? use: npm i -D playwright && npx playwright install chromium
65
- ```
67
+ The agent creates each screen as its own small HTML file. They appear in your studio's sidebar
68
+ as they land framed in an iPhone, styled by your design tokens, wired to your mock data.
66
69
 
67
- Try the shipped examples first:
70
+ **2. You review like it's a real app.** Click through the flow. Flip the 🎭 scenario dropdown
71
+ from *Regular morning* to *First visit* — the same screens now show the empty state honestly.
72
+ Toggle dark mode. Switch to Arabic and watch the layout mirror right-to-left. Nothing is
73
+ staged; the "order ready by 08:44" timestamp is computed from *today* every time you demo.
68
74
 
69
- ```bash
70
- node engine/cli/screenbook.js serve engine/examples/qahwa # ☕ coffee app: iOS + Android + web
71
- node engine/cli/screenbook.js serve engine/examples/tokens-lab # 🎨 two themes, live token lab
72
- ```
75
+ ![Scenario-driven data on a real dashboard frame](docs/shots/web-dashboard-light.png)
73
76
 
74
- ## How it helps a five-minute story
75
-
76
- **1. A screen is one honest file.** No framework, no build, one conventional include:
77
-
78
- ```html
79
- <!DOCTYPE html>
80
- <html lang="en">
81
- <head>
82
- <script type="application/json" id="screen-meta">
83
- { "title": "Cart", "description": "Lines, totals, checkout.",
84
- "order": 30, "device": "ios", "status": "wip" }
85
- </script>
86
- <script src="../../../engine/bridge.js"></script>
87
- </head>
88
- <body>
89
- <button data-go="040-checkout">Checkout</button>
90
- <script>
91
- Engine.ready(function (data) { /* seed ⊕ active scenario, dates resolved */ });
92
- </script>
93
- </body>
94
- </html>
95
- ```
77
+ **3. Your team comments on the pixels, not around them.** Turn on 📌 Review Mode and click
78
+ anywhere: each pin captures the screen, the data state, the theme, the mode, the direction,
79
+ and the exact element under the cursor. Then:
96
80
 
97
- Save it under `features/shop/screens/030-cart.html` it's already in the sidebar, framed as an
98
- iPhone, styled by your tokens (`var(--color-accent)`), live-reloading on every save.
81
+ > *"Read the open review comments, apply the fixes, and resolve them."*
99
82
 
100
- **2. Colors are a panel, not a hunt.** The 🎨 **Theme Lab** shows every token the active theme
101
- defines and edits them **live against the hosted screens** — color pickers for hex values,
102
- plain fields for fonts/radii/spacing, a theme switcher, Export, and one-click **Save** straight
103
- back to `themes/<id>.json` while `serve` runs:
83
+ Your agent does exactly that it has tools for reading pins and marking them resolved.
104
84
 
105
- ![Theme Lab live token editing](docs/shots/theme-lab.png)
85
+ **4. The finished screen becomes the spec for the real app.** This is the step that pays for
86
+ everything. When a screen survives review, it's a complete, self-contained HTML file: exact
87
+ layout and spacing, your design tokens, final copy in both languages, all interaction states.
88
+ Now point your agent at it:
106
89
 
107
- **3. States are data, not branches.** Add a scenario and the 🎭 dropdown demos your empty state:
90
+ > *"Take `features/order/screens/030-cart.html` and build it as a SwiftUI view. Use our design
91
+ > tokens for colors and spacing. Preserve the empty state exactly as the `first-visit` scenario
92
+ > shows it."*
108
93
 
109
- ```json
110
- { "id": "first-visit", "icon": "🆕", "title": "First visit",
111
- "remove": ["order"], "patch": { "user": { "isNew": true } } }
112
- ```
94
+ The prototype you approved *is* the design document — no Figma-to-code guesswork, no "it looked
95
+ different in the mockup." The same works for Jetpack Compose, React Native, Flutter, or web
96
+ components.
113
97
 
114
- **4. Demos tell themselves.** A `flows.json` walkthrough gives stakeholders a guided,
115
- captioned story — each step can pin its own scenario, and every state is a shareable URL:
116
- `…#shop/030-cart?scenario=first-visit&mode=dark&dir=rtl`.
98
+ ![One toggle from LTR light to RTL dark](docs/shots/rtl-arabic-dark.png)
117
99
 
118
- **5. Review closes the loop.** Reviewers pin comments directly on screens; each pin captures
119
- screen, scenario, theme, mode, direction and the exact element clicked, and syncs to
120
- `review/comments.json` — where agents read and resolve them.
100
+ ## Two commands to your own studio
121
101
 
122
- **6. The machine decides "done".**
102
+ Requirements: Node ≥ 18. Nothing else no cloning, no per-project installs. (The automated
103
+ screen checks use your installed Chrome, or download a headless browser once by themselves.)
123
104
 
124
105
  ```bash
125
- node engine/cli/screenbook.js validate .
126
- # ✓ static contract checks
127
- # ✓ 28/28 render checks green across 7 screens (× themes × dark/light × ltr/rtl, zero console errors)
106
+ npm install -g @cs4alhaider/screenbook # once, ever
107
+
108
+ cd any-project-you-are-working-on
109
+ screenbook init # creates .screenbook/ — that's the whole setup
110
+ screenbook serve # → http://127.0.0.1:4600 — live reload, no cache headaches
128
111
  ```
129
112
 
130
- ## The agent workflow (the actual point)
113
+ `init` creates a single **`.screenbook/`** folder in your project — the self-contained source
114
+ of truth for the prototype: your **`brief.md`** (requirements — agents read it first), screens,
115
+ mock data, scenarios, themes, review comments, and the agent authoring contract. Commit it or
116
+ gitignore it; that's your call. The studio itself always runs from the installed package —
117
+ your project never carries runtime code.
131
118
 
132
- Register the MCP server with your agent for Claude Code:
119
+ Connect your agent (Claude Code shown; any MCP client works):
133
120
 
134
121
  ```bash
135
122
  claude mcp add screenbook -- npx -y @cs4alhaider/screenbook mcp --root .
136
- # or from a checkout: claude mcp add screenbook -- node engine/cli/screenbook.js mcp --root .
137
123
  ```
138
124
 
139
- Then ask for work in plain language:
140
-
141
- > *"Add a checkout screen to the shop feature: summary card, payment method list from the seed,
142
- > a pay button that toasts. Match the existing screens. Validate and show me a screenshot."*
143
-
144
- The agent never opens `engine/` — it calls `list_screens` → `get_screen` (steals an existing
145
- screen's idioms) → `add_screen` (which **lints the contract, stamps the date, regenerates the
146
- manifest, writes atomically**) → `validate` (full headless render matrix) → `screenshot`
147
- (a PNG inside the real device frame). Human taste, machine discipline.
148
-
149
- 18 tools: `list_features · list_screens · get_screen · add_screen · update_screen ·
150
- remove_screen · add_feature · get_data · set_data · get_theme · set_theme · get_flows ·
151
- set_flows · get_review_comments · resolve_comment · validate · screenshot · add_app`.
152
-
153
- ## CLI
154
-
155
- | Command | Does |
156
- |---|---|
157
- | `init [dir] [--name X]` | Scaffold a project + authoring contract + agent skill |
158
- | `serve [dir] [--port]` | Studio server: live reload, auto-manifests, review sync, `/engine/*` mounted from this package, no-cache always |
159
- | `manifest [dir]` | Rescan screens → regenerate derived `manifest.json` per feature |
160
- | `validate [dir] [--static] [--json]` | Contract checks + headless render of every screen × theme × mode × direction |
161
- | `screenshot [dir] --screen f/s [--mode light,dark] [--dir ltr,rtl] [--scenario id] [--theme id]` | Device-framed PNGs (comma lists = matrix) |
162
-
163
- ## What's in this repo
164
-
165
- ```
166
- bridge.js the ONLY file screens include (dual-mode: shell-driven / standalone)
167
- index.html + shell/ the studio: frames, dropdowns, flows, review mode, selftest
168
- core/ shared project API (scan, manifests, atomic writes, validate, serve, browser)
169
- cli/ · mcp/ two thin faces over the same core
170
- CLAUDE.md the authoring contract agents follow (scaffolded into projects)
171
- skill/ packaged agent skill + reference docs (scaffolded into projects)
172
- examples/ qahwa (☕ 3-device demo app) · tokens-lab (🎨 multi-theme lab)
173
- test/ 42-test suite: unit + serve E2E + CLI E2E → npm test
174
- TESTING.md the full test map and gaps
175
- ```
176
-
177
- RTL and Arabic are first-class (`dir` flipping, per-screen language dictionaries):
178
-
179
- <img src="docs/shots/rtl-arabic.png" width="320" alt="RTL Arabic screen in dark mode">
180
-
181
- ## App mode — embed entire existing apps
182
-
183
- Already have a single-page prototype? Don't rewrite it — **embed it**:
125
+ Want to explore first? Complete demo projects ship inside the package:
184
126
 
185
127
  ```bash
186
- node engine/cli/screenbook.js app add legacy/index.html --device ios --chrome self
128
+ screenbook serve "$(npm root -g)/@cs4alhaider/screenbook/examples/qahwa" # iPhone + Android + web
129
+ screenbook serve "$(npm root -g)/@cs4alhaider/screenbook/examples/tokens-lab" # 🎨 two themes, edited live
187
130
  ```
188
131
 
189
- The app's views appear in the sidebar as screens, deep links work, dark/RTL/scenario toggles
190
- drive it live. Cooperative apps include `engine/app-bridge.js` and register themselves
191
- (`examples/spa-demo`); sealed apps get a small project-owned **driver** injected at runtime
192
- **zero changes to the app's own files**. `validate` boots each app and visits every screen it
193
- reports, still demanding zero console errors.
132
+ ## What's in the box
133
+
134
+ - **Device frames** iPhone (Dynamic Island, status bar), Android (punch-hole), browser
135
+ chrome, or bare; scaled to fit, screenshot-ready.
136
+ - **Data scenarios** named states over your mock data (*brand-new user*, *mid-trip*,
137
+ *after close*) with date tokens like `{{today+3}}`, so time-based demos are always true.
138
+ - **Theme Lab** — every design token visible and editable live against your screens; save
139
+ writes the JSON back to disk. Dark mode is a delta, not a fork.
140
+
141
+ ![Theme Lab](docs/shots/theme-lab-light.png)
142
+ - **Flows** — guided, captioned walkthroughs for stakeholder demos; every step is a shareable
143
+ URL that opens in the exact state (screen, data, theme, direction).
144
+ - **Review Mode** — pinned comments with full context, synced to a JSON file your agent reads
145
+ and resolves.
146
+ - **Multilingual by design** — per-feature strings files with side-by-side translations;
147
+ right-to-left is a first-class toggle, not an afterthought.
148
+ - **Embed existing prototypes** — already have a working single-page prototype? One command
149
+ mounts the *whole app* inside the studio without touching its files
150
+ (`screenbook app add legacy/index.html`) — see [App mode](docs/guides/app-mode.md).
151
+ - **A machine-verified quality gate** — `screenbook validate` renders every screen in every
152
+ theme × light/dark × LTR/RTL and fails on any console error. Green means done — for humans
153
+ and agents alike.
154
+ - **CLI + 18 agent tools** — everything above is scriptable and agent-operable:
155
+ create screens, update data, restyle themes, take device-framed screenshots, run the gate.
156
+
157
+ Full guides: **[docs/](docs/README.md)** — getting started, the studio tour, the authoring
158
+ contract, CLI and agent references, troubleshooting — or browse them on the website:
159
+ **[cs4alhaider.github.io/screenbook](https://cs4alhaider.github.io/screenbook/)**.
160
+
161
+ ## The shape of a project
194
162
 
195
- ![A sealed legacy app running inside the studio](docs/shots/app-mode.png)
196
-
197
- ## Status
163
+ ```
164
+ my-product/ ← your real project, any stack, untouched
165
+ └── .screenbook/ ← everything ScreenBook, in one folder
166
+ ├── brief.md your requirements — agents read this FIRST
167
+ ├── app.config.json product name · features · devices · themes · languages
168
+ ├── CLAUDE.md the authoring contract agents follow
169
+ ├── themes/default.json design tokens (light + dark)
170
+ ├── features/
171
+ │ └── order/
172
+ │ ├── feature.json title, icon, order
173
+ │ ├── flows.json demo walkthroughs
174
+ │ ├── i18n.json strings, side-by-side languages
175
+ │ ├── data/seed.json mock data
176
+ │ ├── data/scenarios.json named data states
177
+ │ └── screens/
178
+ │ ├── 010-menu.html ← one file = one screen
179
+ │ └── 020-drink.html
180
+ └── review/comments.json pinned feedback, read by your agent
181
+ ```
198
182
 
199
- **v1 complete and machine-verified** (studio, 4 frames, scenarios, flows, Theme Lab,
200
- review mode, selftest, CLI, MCP, agent onboarding, example projects, 44-test suite).
201
- **v2 in progress**: app mode shipped (above) · theme write-back (Theme Lab Save) ·
202
- i18n strings ✓ (`Engine.t` + key-first per-feature `i18n.json`, fallback chain, validate
203
- warnings on gaps) · npm packaging next.
183
+ Everything is a plain file an intern could read. That's the whole trick: it's why agents stay
184
+ fast and cheap (they touch one small file at a time), why git can review every change, why it
185
+ works on a plane, and why the approved prototype can walk straight into production.
204
186
 
205
- Born inside [Rahhal](https://github.com/cs4alhaider)'s product lab, where the predecessor
206
- prototypes grew to ~22k lines and taught every lesson this engine inverts.
187
+ ## Status & license
207
188
 
208
- License: MIT.
189
+ v0.2.0 — studio, frames, scenarios, themes, flows, review, i18n, app mode, self-test gate,
190
+ CLI, MCP server, docs, and a 64-test suite; built and verified end-to-end with AI agents,
191
+ reviewed by a human with taste. MIT © [Abdullah Alhaider](https://github.com/cs4alhaider).
package/bridge.js CHANGED
@@ -12,7 +12,7 @@
12
12
  (function () {
13
13
  'use strict';
14
14
 
15
- var VERSION = '0.1.0';
15
+ var VERSION = '0.2.1';
16
16
 
17
17
  /* ------------------------------------------------------------------ *
18
18
  * EngineKit — pure helpers shared by bridge (screens) and shell
@@ -139,7 +139,16 @@
139
139
  none: { top: '0px', bottom: '0px' }
140
140
  };
141
141
 
142
- /* Compact, stable-ish CSS path for review pins ("#cart > button.buy:nth-of-type(2)"). */
142
+ /*
143
+ * Compact, stable-ish CSS path for review pins ("#cart > button.buy:nth-of-type(2)").
144
+ * Walks from the clicked element up towards <html>, one selector segment per hop:
145
+ * 1. An id ends the walk immediately — "#cart" is unique enough on its own.
146
+ * 2. Otherwise use the tag name plus at most two classes ("button.buy") so the
147
+ * segment stays readable even on utility-class-heavy markup.
148
+ * 3. If siblings share the tag, disambiguate with :nth-of-type(n).
149
+ * 4. Stop after 6 segments — deeper paths add noise, not identity; the pin also
150
+ * stores x/y percentages, so the path is a hint for humans/agents, not an address.
151
+ */
143
152
  function cssPath(el) {
144
153
  var parts = [];
145
154
  while (el && el.nodeType === 1 && el !== document.documentElement && parts.length < 6) {
@@ -317,6 +326,9 @@
317
326
  });
318
327
  }
319
328
 
329
+ /* Cross-screen sync: `storage` fires in every OTHER document on the origin
330
+ when one screen writes. e.key === null means localStorage.clear() — the
331
+ shell's ↺ reset — so every subscriber gets told its key is gone. */
320
332
  window.addEventListener('storage', function (e) {
321
333
  if (!e.key || e.key.indexOf(PREFIX) !== 0) {
322
334
  if (e.key === null) Object.keys(stateEmitter).forEach(function (k) { emit(k, undefined); });
@@ -543,6 +555,8 @@
543
555
 
544
556
  function standaloneInit() {
545
557
  if (initDone) return;
558
+ /* Screens live at features/<feature>/screens/<id>.html — three levels below
559
+ the project root, so app.config.json and themes/ resolve from ../../.. */
546
560
  var root = '../../..';
547
561
  var config = null;
548
562
 
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ /* Printed by npm right after `npm install -g` — the one moment a new user is
3
+ guaranteed to be looking at the terminal and ready for instructions.
4
+ Must NEVER fail an install: everything is wrapped, exit code is always 0.
5
+ Skipped in CI (and via SCREENBOOK_SKIP_BANNER=1). */
6
+
7
+ try {
8
+ if (!process.env.CI && !process.env.SCREENBOOK_SKIP_BANNER) {
9
+ const tty = !!process.stdout.isTTY;
10
+ const paint = (code) => (s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : s);
11
+ const bold = paint('1');
12
+ const dim = paint('2');
13
+ const green = paint('32');
14
+ const accent = paint('36');
15
+
16
+ console.log(`
17
+ ${bold('⧉ ScreenBook')} ${green('installed')} — a design workspace for AI agents, to present to humans.
18
+
19
+ ${bold('Start in any project:')}
20
+ ${accent('screenbook init')} ${dim('scaffolds .screenbook/ — brief.md, theme, starter screen, agent skill')}
21
+ ${accent('screenbook serve')} ${dim('opens your studio at')} http://127.0.0.1:4600
22
+
23
+ ${bold('Connect your AI agent')} ${dim('(Claude Code shown — any MCP client works):')}
24
+ claude mcp add screenbook -- npx -y @cs4alhaider/screenbook mcp --root .
25
+
26
+ ${bold('Or explore a finished demo first:')}
27
+ screenbook serve "$(npm root -g)/@cs4alhaider/screenbook/examples/qahwa"
28
+
29
+ ${dim('Docs & guides')} https://cs4alhaider.github.io/screenbook/
30
+ ${dim('Bugs & ideas')} https://github.com/cs4alhaider/screenbook/issues
31
+ `);
32
+ }
33
+ } catch { /* a banner must never break an install */ }
34
+ process.exit(0);