@t3lnet/sceneforge 1.0.9 → 1.0.10

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 (32) hide show
  1. package/README.md +57 -0
  2. package/cli/cli.js +6 -0
  3. package/cli/commands/context.js +791 -0
  4. package/context/context-builder.ts +318 -0
  5. package/context/index.ts +52 -0
  6. package/context/template-loader.ts +161 -0
  7. package/context/templates/base/actions-reference.md +299 -0
  8. package/context/templates/base/cli-reference.md +236 -0
  9. package/context/templates/base/project-overview.md +58 -0
  10. package/context/templates/base/selectors-guide.md +233 -0
  11. package/context/templates/base/yaml-schema.md +210 -0
  12. package/context/templates/skills/balance-timing.md +136 -0
  13. package/context/templates/skills/debug-selector.md +193 -0
  14. package/context/templates/skills/generate-actions.md +94 -0
  15. package/context/templates/skills/optimize-demo.md +218 -0
  16. package/context/templates/skills/review-demo-yaml.md +164 -0
  17. package/context/templates/skills/write-step-script.md +136 -0
  18. package/context/templates/stages/stage1-actions.md +236 -0
  19. package/context/templates/stages/stage2-scripts.md +197 -0
  20. package/context/templates/stages/stage3-balancing.md +229 -0
  21. package/context/templates/stages/stage4-rebalancing.md +228 -0
  22. package/context/tests/context-builder.test.ts +237 -0
  23. package/context/tests/template-loader.test.ts +181 -0
  24. package/context/tests/tool-formatter.test.ts +198 -0
  25. package/context/tool-formatter.ts +189 -0
  26. package/dist/index.cjs +416 -11
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +182 -1
  29. package/dist/index.d.ts +182 -1
  30. package/dist/index.js +391 -11
  31. package/dist/index.js.map +1 -1
  32. package/package.json +2 -1
@@ -0,0 +1,299 @@
1
+ # SceneForge Actions Reference
2
+
3
+ ## Action Type Summary
4
+
5
+ | Action | Purpose | Required Fields |
6
+ |--------|---------|-----------------|
7
+ | `navigate` | Go to URL | `path` |
8
+ | `click` | Click element | `target` |
9
+ | `type` | Enter text | `target`, `text` |
10
+ | `hover` | Hover element | `target` |
11
+ | `scroll` | Scroll page | `duration` |
12
+ | `scrollTo` | Scroll to element | `target` |
13
+ | `wait` | Pause execution | `duration` or `waitFor` |
14
+ | `upload` | Upload file | `file` |
15
+ | `drag` | Drag element | `target`, `drag` |
16
+
17
+ ## Detailed Action Reference
18
+
19
+ ### navigate
20
+
21
+ Navigate the browser to a URL path. The path is appended to the base URL.
22
+
23
+ ```yaml
24
+ - action: navigate
25
+ path: /dashboard
26
+ ```
27
+
28
+ **Fields:**
29
+ - `path` (required): URL path to navigate to
30
+ - `waitFor` (optional): Condition to wait for after navigation
31
+
32
+ **Common patterns:**
33
+ ```yaml
34
+ # Navigate and wait for network idle
35
+ - action: navigate
36
+ path: /settings
37
+ waitFor:
38
+ type: idle
39
+
40
+ # Navigate and wait for specific element
41
+ - action: navigate
42
+ path: /users
43
+ waitFor:
44
+ type: selector
45
+ value: ".user-list"
46
+ ```
47
+
48
+ ### click
49
+
50
+ Click on an element identified by target.
51
+
52
+ ```yaml
53
+ - action: click
54
+ target:
55
+ type: button
56
+ text: "Submit"
57
+ ```
58
+
59
+ **Fields:**
60
+ - `target` (required): Element to click
61
+ - `highlight` (optional): Show visual highlight before click
62
+ - `waitFor` (optional): Condition to wait for after click
63
+
64
+ **Common patterns:**
65
+ ```yaml
66
+ # Click button with highlight
67
+ - action: click
68
+ target:
69
+ type: button
70
+ text: "Save"
71
+ highlight: true
72
+
73
+ # Click and wait for result
74
+ - action: click
75
+ target:
76
+ type: selector
77
+ selector: "[data-testid='submit']"
78
+ waitFor:
79
+ type: text
80
+ value: "Saved successfully"
81
+
82
+ # Click dropdown option
83
+ - action: click
84
+ target:
85
+ type: text
86
+ text: "Option 1"
87
+ ```
88
+
89
+ ### type
90
+
91
+ Type text into an input field. Clears existing content first.
92
+
93
+ ```yaml
94
+ - action: type
95
+ target:
96
+ type: input
97
+ name: "email"
98
+ text: "user@example.com"
99
+ ```
100
+
101
+ **Fields:**
102
+ - `target` (required): Input element to type into
103
+ - `text` (required): Text to enter
104
+ - `waitFor` (optional): Condition to wait for after typing
105
+
106
+ **Common patterns:**
107
+ ```yaml
108
+ # Type into named input
109
+ - action: type
110
+ target:
111
+ type: input
112
+ name: "search"
113
+ text: "query term"
114
+
115
+ # Type into input by placeholder
116
+ - action: type
117
+ target:
118
+ type: selector
119
+ selector: "[placeholder='Enter email']"
120
+ text: "test@example.com"
121
+
122
+ # Type and wait for autocomplete
123
+ - action: type
124
+ target:
125
+ type: input
126
+ name: "city"
127
+ text: "New York"
128
+ waitFor:
129
+ type: selector
130
+ value: ".autocomplete-dropdown"
131
+ ```
132
+
133
+ ### hover
134
+
135
+ Move cursor to hover over an element. Useful for triggering hover states, tooltips, or dropdown menus.
136
+
137
+ ```yaml
138
+ - action: hover
139
+ target:
140
+ type: selector
141
+ selector: "[data-testid='menu']"
142
+ ```
143
+
144
+ **Fields:**
145
+ - `target` (required): Element to hover over
146
+ - `waitFor` (optional): Condition to wait for after hover
147
+
148
+ **Common patterns:**
149
+ ```yaml
150
+ # Hover to show tooltip
151
+ - action: hover
152
+ target:
153
+ type: selector
154
+ selector: ".info-icon"
155
+ waitFor:
156
+ type: selector
157
+ value: ".tooltip"
158
+
159
+ # Hover to open dropdown menu
160
+ - action: hover
161
+ target:
162
+ type: text
163
+ text: "Products"
164
+ waitFor:
165
+ type: selector
166
+ value: ".dropdown-menu"
167
+ ```
168
+
169
+ ### scroll
170
+
171
+ Scroll the page for a specified duration. Creates smooth scrolling animation.
172
+
173
+ ```yaml
174
+ - action: scroll
175
+ duration: 1500
176
+ ```
177
+
178
+ **Fields:**
179
+ - `duration` (required): Scroll duration in milliseconds
180
+ - `waitFor` (optional): Condition to wait for after scrolling
181
+
182
+ ### scrollTo
183
+
184
+ Scroll the page to bring an element into view.
185
+
186
+ ```yaml
187
+ - action: scrollTo
188
+ target:
189
+ type: text
190
+ text: "Contact Section"
191
+ ```
192
+
193
+ **Fields:**
194
+ - `target` (required): Element to scroll to
195
+ - `waitFor` (optional): Condition to wait for after scrolling
196
+
197
+ ### wait
198
+
199
+ Pause demo execution for a duration or until a condition is met.
200
+
201
+ ```yaml
202
+ # Fixed duration wait
203
+ - action: wait
204
+ duration: 2000
205
+
206
+ # Conditional wait
207
+ - action: wait
208
+ waitFor:
209
+ type: selector
210
+ value: ".data-loaded"
211
+ ```
212
+
213
+ **Fields:**
214
+ - `duration` (optional): Wait time in milliseconds
215
+ - `waitFor` (optional): Condition to wait for
216
+
217
+ **Note:** Either `duration` or `waitFor` must be specified.
218
+
219
+ **Common patterns:**
220
+ ```yaml
221
+ # Wait for loading to complete
222
+ - action: wait
223
+ waitFor:
224
+ type: selectorHidden
225
+ value: ".spinner"
226
+
227
+ # Wait for text to appear
228
+ - action: wait
229
+ waitFor:
230
+ type: text
231
+ value: "Data loaded"
232
+ timeout: 10000
233
+
234
+ # Add padding between actions
235
+ - action: wait
236
+ duration: 500
237
+ ```
238
+
239
+ ### upload
240
+
241
+ Upload a file using a file input.
242
+
243
+ ```yaml
244
+ - action: upload
245
+ file: ./assets/image.png
246
+ ```
247
+
248
+ **Fields:**
249
+ - `file` (required): Path to file (relative to YAML or absolute)
250
+ - `target` (optional): Specific file input element
251
+ - `waitFor` (optional): Condition to wait for after upload
252
+
253
+ **Common patterns:**
254
+ ```yaml
255
+ # Upload to specific input
256
+ - action: upload
257
+ file: ./documents/report.pdf
258
+ target:
259
+ type: selector
260
+ selector: "#document-upload"
261
+
262
+ # Upload and wait for preview
263
+ - action: upload
264
+ file: ./images/photo.jpg
265
+ waitFor:
266
+ type: selector
267
+ value: ".preview-image"
268
+ ```
269
+
270
+ ### drag
271
+
272
+ Drag an element by specified delta.
273
+
274
+ ```yaml
275
+ - action: drag
276
+ target:
277
+ type: selector
278
+ selector: ".slider-handle"
279
+ drag:
280
+ deltaX: 100
281
+ deltaY: 0
282
+ steps: 20
283
+ ```
284
+
285
+ **Fields:**
286
+ - `target` (required): Element to drag
287
+ - `drag` (required): Drag configuration
288
+ - `deltaX`: Horizontal movement in pixels
289
+ - `deltaY`: Vertical movement in pixels
290
+ - `steps` (optional): Number of intermediate positions for smooth animation
291
+ - `waitFor` (optional): Condition to wait for after drag
292
+
293
+ ## Best Practices
294
+
295
+ 1. **Use specific selectors**: Prefer `data-testid` or unique attributes
296
+ 2. **Add waitFor conditions**: Ensure UI is ready before next action
297
+ 3. **Use highlight for important clicks**: Makes demos easier to follow
298
+ 4. **Group related actions**: Keep logical operations in the same step
299
+ 5. **Add wait actions for timing**: Control pacing of the demo
@@ -0,0 +1,236 @@
1
+ # SceneForge CLI Reference
2
+
3
+ ## Overview
4
+
5
+ ```bash
6
+ sceneforge <command> [options]
7
+ ```
8
+
9
+ ## Commands
10
+
11
+ ### record
12
+ Execute a demo definition and record video.
13
+
14
+ ```bash
15
+ sceneforge record --definition <path> [options]
16
+ ```
17
+
18
+ **Options:**
19
+ | Flag | Description |
20
+ |------|-------------|
21
+ | `--definition`, `-d` | Path to demo YAML file |
22
+ | `--base-url`, `-b` | Base URL for the application |
23
+ | `--output`, `-o` | Output directory (default: ./output) |
24
+ | `--headed` | Run browser in headed mode (visible) |
25
+ | `--storage` | Path to storage state JSON |
26
+ | `--slowmo` | Slow down actions by ms |
27
+ | `--env-file` | Path to .env file |
28
+
29
+ **Examples:**
30
+ ```bash
31
+ # Basic recording
32
+ sceneforge record -d demo.yaml -b http://localhost:3000
33
+
34
+ # Headed mode for debugging
35
+ sceneforge record -d demo.yaml -b http://localhost:3000 --headed
36
+
37
+ # With auth state
38
+ sceneforge record -d demo.yaml -b http://localhost:3000 --storage ./auth.json
39
+ ```
40
+
41
+ ### setup
42
+ Run a setup definition to create authentication state.
43
+
44
+ ```bash
45
+ sceneforge setup --definition <path> [options]
46
+ ```
47
+
48
+ **Options:**
49
+ | Flag | Description |
50
+ |------|-------------|
51
+ | `--definition`, `-d` | Path to setup YAML file |
52
+ | `--base-url`, `-b` | Base URL for the application |
53
+ | `--output`, `-o` | Output path for storage state |
54
+ | `--headed` | Run browser in headed mode |
55
+
56
+ **Example:**
57
+ ```bash
58
+ sceneforge setup -d login-setup.yaml -b http://localhost:3000 -o ./auth.json
59
+ ```
60
+
61
+ ### pipeline
62
+ Run the complete demo pipeline (record + voiceover + video processing).
63
+
64
+ ```bash
65
+ sceneforge pipeline --definition <path> [options]
66
+ ```
67
+
68
+ **Options:**
69
+ | Flag | Description |
70
+ |------|-------------|
71
+ | `--definition`, `-d` | Path to demo YAML file |
72
+ | `--base-url`, `-b` | Base URL for the application |
73
+ | `--output`, `-o` | Output directory |
74
+ | `--clean` | Clean output directory before running |
75
+ | `--headed` | Run browser in headed mode |
76
+ | `--storage` | Path to storage state JSON |
77
+ | `--skip-record` | Skip recording step |
78
+ | `--skip-voiceover` | Skip voiceover generation |
79
+ | `--skip-concat` | Skip final concatenation |
80
+ | `--resume` | Resume from last successful step |
81
+
82
+ **Examples:**
83
+ ```bash
84
+ # Full pipeline with clean output
85
+ sceneforge pipeline -d demo.yaml -b http://localhost:3000 --clean
86
+
87
+ # Resume after fixing issues
88
+ sceneforge pipeline -d demo.yaml -b http://localhost:3000 --resume
89
+
90
+ # Skip recording (use existing videos)
91
+ sceneforge pipeline -d demo.yaml --skip-record
92
+ ```
93
+
94
+ ### split
95
+ Split recorded video into per-step clips.
96
+
97
+ ```bash
98
+ sceneforge split --demo <name> [options]
99
+ ```
100
+
101
+ **Options:**
102
+ | Flag | Description |
103
+ |------|-------------|
104
+ | `--demo` | Demo name (folder in output) |
105
+ | `--output`, `-o` | Output directory |
106
+
107
+ ### voiceover
108
+ Generate voiceover audio from scripts.
109
+
110
+ ```bash
111
+ sceneforge voiceover --demo <name> [options]
112
+ ```
113
+
114
+ **Options:**
115
+ | Flag | Description |
116
+ |------|-------------|
117
+ | `--demo` | Demo name |
118
+ | `--output`, `-o` | Output directory |
119
+ | `--voice-id` | ElevenLabs voice ID |
120
+ | `--no-cache` | Disable voice cache |
121
+
122
+ **Environment Variables:**
123
+ - `ELEVENLABS_API_KEY` - Your ElevenLabs API key
124
+ - `ELEVENLABS_VOICE_ID` - Default voice ID
125
+
126
+ ### add-audio
127
+ Merge audio tracks with video clips.
128
+
129
+ ```bash
130
+ sceneforge add-audio --demo <name> [options]
131
+ ```
132
+
133
+ **Options:**
134
+ | Flag | Description |
135
+ |------|-------------|
136
+ | `--demo` | Demo name |
137
+ | `--output`, `-o` | Output directory |
138
+
139
+ ### concat
140
+ Concatenate step clips into final video.
141
+
142
+ ```bash
143
+ sceneforge concat --demo <name> [options]
144
+ ```
145
+
146
+ **Options:**
147
+ | Flag | Description |
148
+ |------|-------------|
149
+ | `--demo` | Demo name |
150
+ | `--output`, `-o` | Output directory |
151
+
152
+ ### doctor
153
+ Run environment diagnostics.
154
+
155
+ ```bash
156
+ sceneforge doctor [options]
157
+ ```
158
+
159
+ **Options:**
160
+ | Flag | Description |
161
+ |------|-------------|
162
+ | `--root` | Project root directory |
163
+ | `--env-file` | Environment file path |
164
+ | `--json` | Output as JSON |
165
+
166
+ **Checks:**
167
+ - ffmpeg installation
168
+ - ffprobe installation
169
+ - Environment variables (ELEVENLABS_API_KEY, etc.)
170
+
171
+ ### context
172
+ Manage LLM context files for AI coding assistants.
173
+
174
+ ```bash
175
+ sceneforge context <subcommand> [options]
176
+ ```
177
+
178
+ **Subcommands:**
179
+ - `deploy` - Deploy context files
180
+ - `list` - List deployed context
181
+ - `remove` - Remove context files
182
+ - `preview` - Preview context content
183
+ - `skill` - Manage skills
184
+
185
+ See dedicated context documentation for details.
186
+
187
+ ## Output Structure
188
+
189
+ ```
190
+ output/
191
+ <demo-name>/
192
+ videos/ # Raw step recordings
193
+ scripts/ # Generated script JSON
194
+ audio/ # Synthesized voiceover
195
+ final/ # Concatenated output
196
+ test-results/ # Playwright artifacts
197
+ ```
198
+
199
+ ## Common Workflows
200
+
201
+ ### First-time Demo Creation
202
+
203
+ ```bash
204
+ # 1. Create auth state if needed
205
+ sceneforge setup -d setup.yaml -b http://localhost:3000 -o auth.json
206
+
207
+ # 2. Record demo
208
+ sceneforge record -d demo.yaml -b http://localhost:3000 --storage auth.json --headed
209
+
210
+ # 3. Generate voiceover
211
+ sceneforge voiceover --demo my-demo
212
+
213
+ # 4. Process video
214
+ sceneforge add-audio --demo my-demo
215
+ sceneforge concat --demo my-demo
216
+ ```
217
+
218
+ ### Using Pipeline
219
+
220
+ ```bash
221
+ # Full automated pipeline
222
+ sceneforge pipeline -d demo.yaml -b http://localhost:3000 --clean
223
+
224
+ # After making script changes
225
+ sceneforge pipeline -d demo.yaml -b http://localhost:3000 --skip-record
226
+ ```
227
+
228
+ ### Debugging
229
+
230
+ ```bash
231
+ # Run diagnostics
232
+ sceneforge doctor
233
+
234
+ # Record in headed mode with slow motion
235
+ sceneforge record -d demo.yaml -b http://localhost:3000 --headed --slowmo 500
236
+ ```
@@ -0,0 +1,58 @@
1
+ # SceneForge Project Overview
2
+
3
+ SceneForge is a toolkit for creating automated browser demo videos with voiceover narration. It uses YAML definitions to describe demo workflows that are executed via Playwright, then processes the recordings into polished video content with synthesized voice narration.
4
+
5
+ ## Core Concepts
6
+
7
+ ### Demo Definition
8
+ A YAML file that describes a complete demo workflow. It contains:
9
+ - **Metadata**: name, title, description
10
+ - **Steps**: logical groupings of actions with voiceover scripts
11
+ - **Media config** (optional): intro/outro videos, background music
12
+
13
+ ### Demo Step
14
+ A logical unit within a demo. Each step contains:
15
+ - **id**: Unique identifier for the step
16
+ - **script**: Voiceover text that will be synthesized to speech
17
+ - **actions**: Array of browser interactions to execute
18
+
19
+ ### Demo Action
20
+ A single browser interaction within a step:
21
+ - **navigate**: Go to a URL
22
+ - **click**: Click an element
23
+ - **type**: Enter text into an input
24
+ - **hover**: Hover over an element
25
+ - **scroll/scrollTo**: Scroll the page or to an element
26
+ - **wait**: Pause for duration or condition
27
+ - **upload**: Upload a file
28
+ - **drag**: Drag and drop interaction
29
+
30
+ ## Project Architecture
31
+
32
+ ```
33
+ packages/
34
+ sceneforge/ # Main CLI and runtime library
35
+ cli/ # CLI commands
36
+ context/ # LLM context generation (this module)
37
+ src/ # Public API exports
38
+ shared/ # Shared types and schemas
39
+ playwright/ # Playwright demo runner
40
+ generation/ # Voice synthesis and script generation
41
+ extension/ # Chrome extension for recording
42
+ ```
43
+
44
+ ## Typical Workflow
45
+
46
+ 1. **Define demo** - Create a YAML file with steps and actions
47
+ 2. **Record** - Run `sceneforge record` to execute actions and capture video
48
+ 3. **Generate voiceover** - Run `sceneforge voiceover` to synthesize speech
49
+ 4. **Process video** - Run `sceneforge pipeline` for the full process
50
+ 5. **Iterate** - Adjust timing, scripts, and actions as needed
51
+
52
+ ## Key Files
53
+
54
+ - `*.yaml` - Demo definition files
55
+ - `output/videos/` - Recorded video clips per step
56
+ - `output/audio/` - Synthesized voiceover audio
57
+ - `output/scripts/` - Generated script JSON with timing data
58
+ - `output/final/` - Final concatenated video output