@scenar/mcp-server 0.2.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/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Scenar Contributors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # @scenar/mcp-server
2
+
3
+ The [Model Context Protocol](https://modelcontextprotocol.io) server for
4
+ [Scenar](https://github.com/stigmer/scenar) — it lets AI editors (Cursor, Claude
5
+ Desktop, etc.) scan a React app, author a scenario tour, narrate it, pack it, and
6
+ serve or publish the embed. A thin, type-safe wrapper over the `@scenar/cli`
7
+ programmatic API.
8
+
9
+ ## Install in Cursor
10
+
11
+ Add to `.cursor/mcp.json`:
12
+
13
+ ```json
14
+ {
15
+ "mcpServers": {
16
+ "scenar": { "command": "npx", "args": ["-y", "@scenar/mcp-server"] }
17
+ }
18
+ }
19
+ ```
20
+
21
+ Then add the bundled authoring skill so the model knows the scenario model:
22
+
23
+ ```bash
24
+ mkdir -p .cursor/skills
25
+ cp -R node_modules/@scenar/mcp-server/skill .cursor/skills/scenar
26
+ ```
27
+
28
+ Restart your editor.
29
+
30
+ ## Tools
31
+
32
+ | Tool | What it does |
33
+ |------|-------------|
34
+ | `scenar_preview_init` | Scan a React project → `.scenar/` registry + report |
35
+ | `scenar_preview_sync` | Re-scan after code changes (preserves your edits) |
36
+ | `scenar_validate` | Validate a scenario YAML or directory |
37
+ | `scenar_narrate` | Synthesize TTS audio for a scenario |
38
+ | `scenar_pack` | Bundle a scenario into a static embed |
39
+ | `scenar_serve` | Serve a packed bundle locally; returns the URL |
40
+ | `scenar_stop_serve` | Stop a server started by `scenar_serve` |
41
+ | `scenar_publish` | Deploy a packed bundle to GitHub Pages; returns the URL |
42
+ | `scenar_render` | Render a scenario to MP4 |
43
+
44
+ ## Resources
45
+
46
+ `scenar://registry/views`, `scenar://registry/report`,
47
+ `scenar://registry/providers`, `scenar://scenario/{name}/steps`, and
48
+ `scenar://scenario/{name}/manifest` expose read-only context the model can
49
+ inspect.
50
+
51
+ See the [Scenar docs](https://github.com/stigmer/scenar/blob/main/docs/mcp-server.md)
52
+ for configuration in other editors.
53
+
54
+ ## License
55
+
56
+ Apache-2.0
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=scenar-mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenar-mcp.d.ts","sourceRoot":"","sources":["../../bin/scenar-mcp.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "../src/index.js";
3
+ main().catch((error) => {
4
+ process.stderr.write(`scenar-mcp: ${error instanceof Error ? error.message : String(error)}\n`);
5
+ process.exit(1);
6
+ });
7
+ //# sourceMappingURL=scenar-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenar-mcp.js","sourceRoot":"","sources":["../../bin/scenar-mcp.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@scenar/mcp-server",
3
+ "version": "0.2.0",
4
+ "description": "Model Context Protocol server for Scenar — lets AI editors scan, author, narrate, pack, serve, and publish scenario tours.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/stigmer/scenar.git",
10
+ "directory": "packages/mcp-server"
11
+ },
12
+ "keywords": [
13
+ "scenar",
14
+ "mcp",
15
+ "model-context-protocol",
16
+ "cursor",
17
+ "ai",
18
+ "scenario",
19
+ "tour"
20
+ ],
21
+ "bin": {
22
+ "scenar-mcp": "./bin/scenar-mcp.js"
23
+ },
24
+ "main": "./src/index.js",
25
+ "types": "./src/index.d.ts",
26
+ "dependencies": {
27
+ "@modelcontextprotocol/sdk": "^1.29.0",
28
+ "@scenar/cli": "0.2.0",
29
+ "@scenar/preview": "0.2.0",
30
+ "zod": "^3.23.8"
31
+ }
32
+ }
package/skill/SKILL.md ADDED
@@ -0,0 +1,189 @@
1
+ ---
2
+ name: scenar
3
+ description: >-
4
+ Author Scenar scenario tours from a React app: scan components with `scenar
5
+ preview`, write steps.ts + index.tsx (or use the createScenario SDK), add
6
+ cursor/scroll/type interactions and narration, then pack, serve, and publish
7
+ the embed. Use when the user wants to build a product tour, demo, or
8
+ interactive embed with Scenar; mentions the @scenar/* packages; or asks to run
9
+ scenar preview/validate/narrate/pack/serve/publish (directly or via the
10
+ @scenar/mcp-server tools scenar_preview_init, scenar_pack, scenar_serve,
11
+ scenar_publish, etc.).
12
+ ---
13
+
14
+ # Authoring Scenar Scenarios
15
+
16
+ Scenar turns a React app into a narrated, interactive embed (and an MP4). You,
17
+ the AI, are the authoring engine: you scan the app, write the scenario, and run
18
+ the pipeline. This skill is the source of truth for the model and the workflow.
19
+
20
+ ## The pipeline
21
+
22
+ ```
23
+ scan → wire providers → author → narrate → pack → serve / publish
24
+ ```
25
+
26
+ | Step | CLI | MCP tool |
27
+ |------|-----|----------|
28
+ | Scan a React app into a view registry | `scenar preview init` | `scenar_preview_init` |
29
+ | Re-scan after code changes | `scenar preview sync` | `scenar_preview_sync` |
30
+ | Validate a scenario YAML | `scenar validate` | `scenar_validate` |
31
+ | Generate narration audio (TTS) | `scenar narrate` | `scenar_narrate` |
32
+ | Bundle into a static embed | `scenar pack` | `scenar_pack` |
33
+ | Preview locally | `scenar serve` | `scenar_serve` |
34
+ | Publish to GitHub Pages | `scenar publish` | `scenar_publish` |
35
+ | Render an MP4 | `scenar render` | `scenar_render` |
36
+
37
+ Prefer the MCP tools when available; they call the same code and return
38
+ structured results. Paths are resolved against the project root.
39
+
40
+ ## Two authoring paths
41
+
42
+ - **Path A — real components (recommended for real tours).** Run
43
+ `scenar preview init --source ./src`. It scans the project and writes a
44
+ `.scenar/` registry (`views.ts`, `views.custom.tsx`, `providers.tsx`,
45
+ `report.md`) plus an MSW service worker. You then author a scenario that
46
+ renders the user's *actual* components. The hard part is wiring
47
+ `.scenar/providers.tsx` (theme/router/data) and MSW handlers so the components
48
+ render without a live backend — do this deliberately, with the user.
49
+ - **Path B — illustrative components (fastest for generic flows).** Compose the
50
+ `@scenar/react` shells and page templates (no scan needed). The bundled
51
+ `welcome-tour` example is Path B; study it before authoring.
52
+
53
+ Both paths produce the same artifact: a **scenario directory**.
54
+
55
+ ## A scenario directory
56
+
57
+ ```
58
+ my-tour/
59
+ ├── steps.ts # the timeline (data + timing + captions + interactions)
60
+ ├── index.tsx # renderStep(data, stepIndex) → ReactNode
61
+ └── narration/ # generated by `scenar narrate` (do not hand-write)
62
+ ```
63
+
64
+ `pack`, `render`, and `preview` all consume this exact shape.
65
+
66
+ ### steps.ts — the timeline
67
+
68
+ Export `steps`, an array of `ScenarioStep<T>` where `T` is your per-step data:
69
+
70
+ ```ts
71
+ import type { ScenarioStep } from "@scenar/core";
72
+
73
+ export interface StepData { url: string; screen: "login" | "dashboard"; }
74
+
75
+ export const steps: ScenarioStep<StepData>[] = [
76
+ {
77
+ delayMs: 0, // dwell before reveal; first step is 0
78
+ caption: "Sign in to Acme Cloud", // short label under the player
79
+ narration: "Start by signing in to your workspace.", // TTS script (build-time)
80
+ data: { url: "app.acme.cloud/login", screen: "login" },
81
+ interactions: [ // optional timed actions (see below)
82
+ { atPercent: 0.4, type: "type", target: "email", text: "jordan@acme.cloud" },
83
+ { atPercent: 0.9, type: "click", target: "submit" },
84
+ ],
85
+ },
86
+ // ...more steps
87
+ ];
88
+ ```
89
+
90
+ Fields: `delayMs` (required), `data` (required), `caption?`, `narration?`,
91
+ `interactions?`. Keep one idea per step.
92
+
93
+ ### index.tsx — the render function
94
+
95
+ Export `renderStep(data, stepIndex): ReactNode`. Switch on the data to render a
96
+ **shell** wrapping the screen content:
97
+
98
+ ```tsx
99
+ import type { ReactNode } from "react";
100
+ import { BrowserView, LoginCardPage } from "@scenar/react";
101
+ import type { StepData } from "./steps";
102
+
103
+ export function renderStep(data: StepData, stepIndex: number): ReactNode {
104
+ return (
105
+ <BrowserView url={`https://${data.url}`} contentKey={String(stepIndex)}>
106
+ {data.screen === "login" ? <LoginCardPage appName="Acme Cloud" /* ... */ /> : /* ... */}
107
+ </BrowserView>
108
+ );
109
+ }
110
+ ```
111
+
112
+ `renderStep` must be **pure** `(data, stepIndex) → ReactNode`. Pass
113
+ `contentKey={String(stepIndex)}` so the shell animates between steps.
114
+
115
+ ## Interactions (cursor, type, scroll, zoom)
116
+
117
+ Add interactions to a step's `interactions` array. The engine drives a synthetic
118
+ cursor over elements you mark with data attributes in `renderStep`:
119
+
120
+ - `data-cursor-target="id"` — target for `set_cursor`, `click`, `type`, `hover`, `drag`
121
+ - `data-scroll-target="id"` — target for `scroll_to`
122
+
123
+ `StepAction` fields: `atPercent` (0.0–1.0 of the step's narration duration; falls
124
+ back to the next step's `delayMs` when muted), `type`, `target`, `dragTarget`
125
+ (drag destination), `text` + `typeDelay` (for `type`), `hoverDuration`,
126
+ `viewportZoom` + `viewportReset` (for `viewport_transition`).
127
+
128
+ `ActionType`: `set_cursor`, `clear_cursor`, `click`, `type`, `hover`, `drag`,
129
+ `scroll_to`, `viewport_transition`.
130
+
131
+ ```tsx
132
+ // in renderStep:
133
+ <button data-cursor-target="submit">Sign in</button>
134
+ <input data-cursor-target="email" />
135
+ ```
136
+ ```ts
137
+ // in steps.ts:
138
+ interactions: [
139
+ { atPercent: 0.2, type: "set_cursor", target: "email" },
140
+ { atPercent: 0.3, type: "type", target: "email", text: "jordan@acme.cloud" },
141
+ { atPercent: 0.8, type: "click", target: "submit" },
142
+ ]
143
+ ```
144
+
145
+ The engine sets `data-hover` during `hover` and `data-dragging` during `drag` —
146
+ style against these for realistic feedback.
147
+
148
+ ## Narration
149
+
150
+ Write `narration` as one or two plain sentences per step — concise, one idea
151
+ each, present tense. Then run `scenar narrate ./my-tour` (or `scenar_narrate`) to
152
+ synthesize audio into `narration/`. Interaction timing (`atPercent`) is measured
153
+ against each step's narration duration, so narration and motion stay in sync.
154
+ Do not hand-write the `narration/` folder.
155
+
156
+ ## Shells & page templates (`@scenar/react`)
157
+
158
+ Pick the shell that frames the medium, then fill it with page primitives or
159
+ templates. Common shells: `BrowserView`, `TerminalView`, `CodeEditorView`,
160
+ `MobileView`, `ChatView`, `SlideView`, `DashboardView`, `APIClientView`,
161
+ `DesktopView`. Common page parts: `LoginCardPage`, `DashboardPage`,
162
+ `SettingsFormPage`, `AdminListPage`, and primitives `AppBar`, `SideNav`,
163
+ `FormCard`, `DataTable`, `StatusBadge`, `PulseHighlight`.
164
+
165
+ See [reference.md](reference.md) for the full catalog, the `createScenario` SDK
166
+ (type-safe Path B), provider/MSW wiring for Path A, and the bundle constraints.
167
+
168
+ ## The one hard constraint: the bundle allowlist
169
+
170
+ `scenar pack` only ships: `html`, `js`, `css`, `json`, `mp3`, raster images
171
+ (`png`/`jpg`/`jpeg`/`gif`/`webp`/`avif`), and `woff2`/`woff`. **SVG is not a
172
+ served file** — inline it as a React component or a `data:` URI. Prefer
173
+ CSS-drawn UI; import raster assets normally (Vite hashes them at pack time).
174
+
175
+ ## Workflow checklist
176
+
177
+ ```
178
+ - [ ] Path A: scenar_preview_init, review report.md, wire providers.tsx + MSW
179
+ - [ ] Write steps.ts (timeline, captions, narration, interactions)
180
+ - [ ] Write index.tsx (renderStep with shells + data-cursor-target hooks)
181
+ - [ ] scenar_narrate to synthesize audio
182
+ - [ ] scenar_pack to bundle
183
+ - [ ] scenar_serve to preview, iterate on timing/captions
184
+ - [ ] scenar_publish for a public URL (or scenar_render for an MP4)
185
+ ```
186
+
187
+ Author for quality: realistic copy, sensible pacing (2–3s dwell per step),
188
+ captions that read as a story, and interactions that mirror what a real user
189
+ would do.
@@ -0,0 +1,153 @@
1
+ # Scenar Authoring Reference
2
+
3
+ Deep reference for the [scenar skill](SKILL.md): the shell catalog, page parts,
4
+ the `createScenario` SDK (Path B), provider/MSW wiring (Path A), the proto/YAML
5
+ shape, and bundle constraints.
6
+
7
+ ## Canonical example
8
+
9
+ The bundled example is the best reference — read it before authoring:
10
+
11
+ - `packages/cli/examples/welcome-tour/steps.ts` — a four-step `ScenarioStep<T>[]`
12
+ - `packages/cli/examples/welcome-tour/index.tsx` — `renderStep` switching on
13
+ `data.screen`, wrapping `@scenar/react` page templates in a `BrowserView`
14
+
15
+ ## Shell catalog (`@scenar/react`)
16
+
17
+ Every shell takes `contentKey: string` (pass `String(stepIndex)`) and an
18
+ optional `slideDirection?: "forward" | "backward"`.
19
+
20
+ | Shell | Frames | Key props |
21
+ |-------|--------|-----------|
22
+ | `BrowserView` | a web app | `url`, `children`, `zoom?` |
23
+ | `TerminalView` | a CLI session | `lines: TerminalLine[]`, `cwd?`, `title?`, `fontSize?` |
24
+ | `CodeEditorView` | an IDE | `files: FileTreeEntry[]`, plus active file/content |
25
+ | `MobileView` | a phone app | mobile chrome + `children` |
26
+ | `ChatView` | a messaging UI | messages; pair with `ChatBubble`, `TypingIndicator` |
27
+ | `SlideView` | a presentation slide | slide content |
28
+ | `DashboardView` | an app with sidebar | `sidebarItems: SidebarItem[]`, `children` |
29
+ | `APIClientView` | a Postman-style client | `method: HttpMethod`, request/response |
30
+ | `DesktopView` | a desktop window | window chrome + `children` |
31
+
32
+ `TerminalLine` is `{ type: "prompt" | "output" | "error" | "success" | "blank"; text: string }`.
33
+
34
+ ## Page primitives & templates
35
+
36
+ Use inside a `BrowserView`/`DashboardView` to draw realistic app screens
37
+ (all CSS-drawn; lucide icons inline as components):
38
+
39
+ - **Templates**: `LoginCardPage`, `DashboardPage`, `SettingsFormPage`, `AdminListPage`
40
+ - **Primitives**: `PageLayout`, `AppBar` (`navLinks: NavLink[]`), `SideNav`
41
+ (`items: SideNavItem[]`), `FormCard` (`fields: FormField[]`), `DataTable`
42
+ (`columns`, `rows`), `SettingsForm`, `Breadcrumb`, `StatusBadge`
43
+ (`variant: "success" | "info" | "warning" | ...`), `PulseHighlight` (draws
44
+ attention to a region).
45
+
46
+ `DashboardPage` props (as used by welcome-tour): `appName`, `userName`,
47
+ `navLinks: NavLink[]`, `sidebarItems: SideNavItem[]`, `children`. A `NavLink` is
48
+ `{ label: string; active?: boolean }`; a `SideNavItem` adds `isSection?: boolean`.
49
+
50
+ ## Interactions — full `StepAction` shape
51
+
52
+ ```ts
53
+ interface StepAction {
54
+ atPercent: number; // 0.0–1.0 of the step's narration duration
55
+ type: ActionType;
56
+ target?: string; // matches data-cursor-target / data-scroll-target
57
+ dragTarget?: string; // drag destination (data-cursor-target)
58
+ text?: string; // for "type"
59
+ typeDelay?: number; // ms/char (default 50)
60
+ hoverDuration?: number; // ms held during "hover" (default 1500)
61
+ viewportZoom?: number; // for "viewport_transition" (>1 zooms in; default 1.5)
62
+ viewportReset?: boolean; // reset viewport to identity (ignores target/zoom)
63
+ }
64
+ ```
65
+
66
+ `ActionType`: `set_cursor`, `clear_cursor`, `click`, `type`, `hover`, `drag`,
67
+ `scroll_to`, `viewport_transition`.
68
+
69
+ Targeting attributes (set them in `renderStep` output):
70
+ - `data-cursor-target="id"` — cursor actions (`set_cursor`/`click`/`type`/`hover`/`drag`)
71
+ - `data-scroll-target="id"` — `scroll_to`
72
+ - The engine sets `data-hover` during a hover and `data-dragging` during a drag;
73
+ style against them for feedback.
74
+
75
+ Timing rule: with narration, `atPercent` maps onto the clip's real duration; when
76
+ muted, it maps onto the next step's `delayMs`. So author narration first for
77
+ tight sync, or set deliberate `delayMs` values for muted tours.
78
+
79
+ ## Path B — the `createScenario` SDK (type-safe)
80
+
81
+ For code-authored scenarios, `createScenario` gives compile-time prop checking:
82
+ each step's `props` is typed against the component registered under its `view`.
83
+
84
+ ```ts
85
+ import { createScenario } from "@scenar/sdk";
86
+ import { LoginScreen, Dashboard } from "./screens";
87
+
88
+ export default createScenario({
89
+ viewport: { width: 896, height: 480 },
90
+ views: { login: LoginScreen, dashboard: Dashboard },
91
+ steps: [
92
+ { view: "login", delayMs: 0, caption: "Sign in",
93
+ narrationText: "Sign in to your workspace.",
94
+ props: { email: "jordan@acme.cloud" } }, // typed to LoginScreen's props
95
+ { view: "dashboard", delayMs: 2400, caption: "Your dashboard",
96
+ props: { userName: "Jordan" } },
97
+ ],
98
+ });
99
+ ```
100
+
101
+ `StepInput` uses `narrationText` (not `narration`) and carries `props` instead of
102
+ a free-form `data`. The output plugs straight into `<ScenarioPlayer>`.
103
+
104
+ ## Path A — real components: provider + MSW wiring
105
+
106
+ `scenar preview init --source ./src` writes `.scenar/`:
107
+
108
+ - `views.generated.ts` — scanner-owned; never edit
109
+ - `views.custom.tsx` — your hand-added views
110
+ - `views.ts` — the merged registry you author against
111
+ - `providers.tsx` — **you wire this**: wrap components in the theme/router/data
112
+ providers they need to render in isolation
113
+ - `report.md` — what was discovered/skipped and why (read this first)
114
+
115
+ Also generates an MSW service worker. Add MSW handlers so components that fetch
116
+ data render with realistic fixtures (no live backend). This wiring is the one
117
+ step that can't be automated — do it explicitly with the user, using `report.md`
118
+ to see what each component expects. Re-run `scenar preview sync` after code
119
+ changes (it preserves `views.custom.tsx` and `providers.tsx`).
120
+
121
+ ## YAML / proto scenarios
122
+
123
+ `scenar validate` checks a scenario **YAML** against the proto schema
124
+ (`ai.scenar.scenario.v1`). `ActionType` values match the proto enum names
125
+ verbatim, so YAML interactions use the same `scroll_to`/`set_cursor`/... strings.
126
+ Most authoring is TS-first (directory form); YAML is for proto-driven pipelines.
127
+
128
+ ## Bundle constraints (`scenar pack`)
129
+
130
+ The packed bundle must satisfy the deploy allowlist (enforced at pack time):
131
+
132
+ - Allowed file types: `html`, `js`, `css`, `json`, `mp3`, raster images
133
+ (`png`/`jpg`/`jpeg`/`gif`/`webp`/`avif`), `woff2`/`woff`.
134
+ - **No SVG files** — SVG is active content. Inline SVG as a React component or a
135
+ `data:` URI instead. (lucide-react icons are already inline components.)
136
+ - Prefer CSS-drawn UI. Import raster assets with a normal `import logo from
137
+ "./logo.png"` — Vite emits a hashed file at pack time.
138
+ - Relative asset URLs only (the bundle is served from an origin/subpath root):
139
+ pack sets Vite `base: "./"` for you.
140
+ - `scenar pack` writes `scenario.json` (records the canonical viewport for the
141
+ embed aspect ratio) and `pack-manifest.json` (every file + sha256 + content
142
+ type). Don't hand-edit these.
143
+
144
+ ## Hosting the embed
145
+
146
+ - `scenar serve <bundle>` → `http://localhost:4173/` (ephemeral local preview).
147
+ - `scenar publish <bundle>` → `https://<owner>.github.io/scenar-embeds/<slug>/`
148
+ (GitHub Pages; needs the `gh` CLI authenticated). Public and permanent. Many
149
+ tours share one repo (`--repo`, default `scenar-embeds`), each under its slug
150
+ (`--path`, default the scenario slug; `--path /` for the repo root); publishing
151
+ one tour preserves its siblings.
152
+ - Both print a responsive `<iframe>` snippet pinned to the bundle's aspect ratio.
153
+ - `scenar render <dir>` → an MP4 (same source, via Remotion).