@t3lnet/sceneforge 1.0.8 → 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,193 @@
1
+ # Skill: Debug Selector
2
+
3
+ Help diagnose and fix selector issues in SceneForge demo actions.
4
+
5
+ ## Task
6
+
7
+ Analyze a failing selector and provide working alternatives.
8
+
9
+ ## Input Required
10
+
11
+ Provide the following:
12
+ - **Current selector**: The selector that's not working
13
+ - **Target element description**: What element you're trying to select
14
+ - **Error message**: Error from Playwright (if available)
15
+ - **Page context**: What page/feature contains the element
16
+
17
+ ## Debugging Process
18
+
19
+ ### Step 1: Identify the Problem
20
+
21
+ Common selector issues:
22
+ - **Element not found**: Selector doesn't match anything
23
+ - **Multiple matches**: Selector is too broad
24
+ - **Timing issue**: Element not ready when selector runs
25
+ - **Dynamic content**: Element changes between loads
26
+
27
+ ### Step 2: Analyze Current Selector
28
+
29
+ Evaluate the selector:
30
+ - Is it using stable attributes?
31
+ - Is it too specific or too broad?
32
+ - Does it depend on DOM structure?
33
+
34
+ ### Step 3: Provide Alternatives
35
+
36
+ Generate multiple alternatives ordered by reliability.
37
+
38
+ ## Output Format
39
+
40
+ ```markdown
41
+ ## Selector Debug Report
42
+
43
+ ### Current Selector
44
+ `[selector]`
45
+
46
+ ### Problem Analysis
47
+ [Description of why it's failing]
48
+
49
+ ### Alternative Selectors (Best to Worst)
50
+
51
+ 1. **Best: data-testid**
52
+ ```yaml
53
+ selector: "[data-testid='element-id']"
54
+ ```
55
+ Stability: High | Reason: Direct test identifier
56
+
57
+ 2. **Good: aria-label**
58
+ ```yaml
59
+ selector: "[aria-label='Button description']"
60
+ ```
61
+ Stability: Good | Reason: Accessibility attribute
62
+
63
+ 3. **Acceptable: role + text**
64
+ ```yaml
65
+ selector: "button:has-text('Click Me')"
66
+ ```
67
+ Stability: Medium | Reason: Text may change
68
+
69
+ ### Recommended Wait Condition
70
+ [If timing is the issue]
71
+
72
+ ### Implementation
73
+ [Complete YAML action with recommended selector]
74
+ ```
75
+
76
+ ## Common Issues and Solutions
77
+
78
+ ### Issue: Element Not Found
79
+
80
+ **Cause**: Selector doesn't match element attributes
81
+
82
+ **Solution**: Inspect element in DevTools and find stable attributes
83
+
84
+ ```yaml
85
+ # Instead of
86
+ selector: ".btn-submit"
87
+
88
+ # Use
89
+ selector: "[data-testid='submit-form']"
90
+ # or
91
+ selector: "button:has-text('Submit')"
92
+ ```
93
+
94
+ ### Issue: Multiple Elements Match
95
+
96
+ **Cause**: Selector too broad
97
+
98
+ **Solution**: Add context or use more specific selector
99
+
100
+ ```yaml
101
+ # Instead of
102
+ selector: "button"
103
+
104
+ # Use
105
+ selector: ".modal-dialog >> button:has-text('Confirm')"
106
+ # or
107
+ selector: "[data-testid='modal-confirm-btn']"
108
+ ```
109
+
110
+ ### Issue: Timing/Race Condition
111
+
112
+ **Cause**: Element not yet in DOM when selector runs
113
+
114
+ **Solution**: Add wait condition before action
115
+
116
+ ```yaml
117
+ # Add wait before the problematic action
118
+ - action: wait
119
+ waitFor:
120
+ type: selector
121
+ value: ".content-loaded"
122
+ timeout: 10000
123
+
124
+ - action: click
125
+ target:
126
+ type: selector
127
+ selector: "[data-testid='element']"
128
+ ```
129
+
130
+ ### Issue: Dynamic ID/Classes
131
+
132
+ **Cause**: IDs like `element-abc123` change on each load
133
+
134
+ **Solution**: Use attribute starts-with or contains
135
+
136
+ ```yaml
137
+ # Instead of
138
+ selector: "#user-abc123"
139
+
140
+ # Use
141
+ selector: "[id^='user-']"
142
+ # or find a stable attribute
143
+ selector: "[data-user-id]"
144
+ ```
145
+
146
+ ### Issue: Element Inside Shadow DOM
147
+
148
+ **Cause**: Element in web component shadow root
149
+
150
+ **Solution**: Use Playwright's pierce selector
151
+
152
+ ```yaml
153
+ selector: "pierce/#shadow-element"
154
+ ```
155
+
156
+ ### Issue: Element in iframe
157
+
158
+ **Cause**: Element inside frame
159
+
160
+ **Solution**: Handle frames in Playwright
161
+
162
+ ```yaml
163
+ # Note: May require code changes
164
+ # Consider if action can be restructured
165
+ selector: "iframe[name='frame'] >> [data-testid='element']"
166
+ ```
167
+
168
+ ## Selector Testing Commands
169
+
170
+ Test selectors in browser DevTools:
171
+
172
+ ```javascript
173
+ // Test CSS selector
174
+ document.querySelector('[data-testid="element"]')
175
+
176
+ // Test multiple matches
177
+ document.querySelectorAll('button').length
178
+
179
+ // Test Playwright-style selector (conceptual)
180
+ // button:has-text('Submit')
181
+ Array.from(document.querySelectorAll('button'))
182
+ .filter(b => b.textContent.includes('Submit'))
183
+ ```
184
+
185
+ ## Checklist
186
+
187
+ - [ ] Element exists in DOM (check DevTools)
188
+ - [ ] Selector syntax is valid
189
+ - [ ] No typos in attribute names/values
190
+ - [ ] Element is visible (not display:none)
191
+ - [ ] Element is not inside iframe
192
+ - [ ] Timing is adequate (add wait if needed)
193
+ - [ ] Selected correct element (not duplicate)
@@ -0,0 +1,94 @@
1
+ # Skill: Generate Demo Actions
2
+
3
+ Generate SceneForge demo actions for a web page or workflow.
4
+
5
+ ## Task
6
+
7
+ Create a complete set of demo actions for the specified page or user workflow.
8
+
9
+ ## Input Required
10
+
11
+ Provide the following information:
12
+ - **Page URL or description**: What page/feature are we demoing?
13
+ - **User goal**: What should the user accomplish?
14
+ - **Key interactions**: What elements will be clicked/typed?
15
+ - **Expected outcome**: What happens when the workflow completes?
16
+
17
+ ## Output Format
18
+
19
+ Generate a YAML steps array with:
20
+ - Logical step groupings
21
+ - Descriptive step IDs
22
+ - Empty script fields (to be filled later)
23
+ - Reliable selectors
24
+ - Appropriate wait conditions
25
+
26
+ ## Process
27
+
28
+ 1. **Analyze the workflow**: Break into logical steps
29
+ 2. **Identify elements**: Determine selectors for each interaction
30
+ 3. **Add wait conditions**: Ensure stability between actions
31
+ 4. **Structure output**: Create valid YAML
32
+
33
+ ## Example Output
34
+
35
+ ```yaml
36
+ steps:
37
+ - id: navigate-to-form
38
+ script: ""
39
+ actions:
40
+ - action: navigate
41
+ path: /contact
42
+ waitFor:
43
+ type: idle
44
+
45
+ - id: fill-contact-form
46
+ script: ""
47
+ actions:
48
+ - action: type
49
+ target:
50
+ type: input
51
+ name: "name"
52
+ text: "John Smith"
53
+ - action: type
54
+ target:
55
+ type: input
56
+ name: "email"
57
+ text: "john@example.com"
58
+ - action: type
59
+ target:
60
+ type: selector
61
+ selector: "textarea[name='message']"
62
+ text: "I'm interested in learning more about your services."
63
+
64
+ - id: submit-form
65
+ script: ""
66
+ actions:
67
+ - action: click
68
+ target:
69
+ type: button
70
+ text: "Send Message"
71
+ highlight: true
72
+ waitFor:
73
+ type: text
74
+ value: "Thank you"
75
+ ```
76
+
77
+ ## Selector Guidelines
78
+
79
+ Use this priority when choosing selectors:
80
+ 1. `[data-testid="..."]` - Most reliable
81
+ 2. `[aria-label="..."]` - Accessibility labels
82
+ 3. `role=button[name="..."]` - Semantic roles
83
+ 4. `input[name="..."]` - Form inputs by name
84
+ 5. `button:has-text("...")` - Text fallback
85
+
86
+ ## Checklist
87
+
88
+ Before finalizing, verify:
89
+ - [ ] All user interactions are captured
90
+ - [ ] Steps are logically grouped
91
+ - [ ] IDs are descriptive (kebab-case)
92
+ - [ ] Wait conditions prevent race conditions
93
+ - [ ] Selectors are as stable as possible
94
+ - [ ] YAML syntax is valid
@@ -0,0 +1,218 @@
1
+ # Skill: Optimize Demo
2
+
3
+ Optimize a SceneForge demo for better flow, reliability, and viewer experience.
4
+
5
+ ## Task
6
+
7
+ Review and optimize a demo definition for:
8
+ - Smoother transitions
9
+ - Better pacing
10
+ - Improved reliability
11
+ - Enhanced viewer experience
12
+
13
+ ## Input Required
14
+
15
+ Provide the following:
16
+ - **Demo YAML content**: The full demo definition
17
+ - **Problem areas**: Known issues with flow/pacing (optional)
18
+ - **Target duration**: Desired total runtime (optional)
19
+ - **Audience**: Who will watch this demo (optional)
20
+
21
+ ## Optimization Areas
22
+
23
+ ### 1. Pacing Optimization
24
+ - Step duration balance
25
+ - Transition timing
26
+ - Information density
27
+
28
+ ### 2. Visual Flow
29
+ - Highlights for key actions
30
+ - Hover states for context
31
+ - Scroll to show content
32
+
33
+ ### 3. Reliability
34
+ - Selector stability
35
+ - Wait condition coverage
36
+ - Error resilience
37
+
38
+ ### 4. Narrative Flow
39
+ - Script coherence
40
+ - Logical progression
41
+ - Clear purpose
42
+
43
+ ## Output Format
44
+
45
+ ```markdown
46
+ ## Demo Optimization Report
47
+
48
+ ### Overview
49
+ - Current duration: ~Xm Xs
50
+ - Recommended duration: ~Ym Ys
51
+ - Optimization potential: High/Medium/Low
52
+
53
+ ### Pacing Issues
54
+ [List of pacing problems]
55
+
56
+ ### Flow Improvements
57
+ [Suggested improvements]
58
+
59
+ ### Reliability Enhancements
60
+ [Stability improvements]
61
+
62
+ ### Optimized YAML
63
+ [Updated demo definition]
64
+ ```
65
+
66
+ ## Optimization Techniques
67
+
68
+ ### Improve Transitions
69
+
70
+ **Add smooth navigation waits:**
71
+ ```yaml
72
+ # Before
73
+ - action: click
74
+ target: { type: link, text: "Dashboard" }
75
+
76
+ # After
77
+ - action: click
78
+ target: { type: link, text: "Dashboard" }
79
+ waitFor:
80
+ type: idle
81
+ - action: wait
82
+ duration: 500 # Let page settle
83
+ ```
84
+
85
+ ### Add Visual Emphasis
86
+
87
+ **Highlight important clicks:**
88
+ ```yaml
89
+ - action: click
90
+ target:
91
+ type: button
92
+ text: "Create Project"
93
+ highlight: true # Visual indicator for viewers
94
+ ```
95
+
96
+ **Add hover for context:**
97
+ ```yaml
98
+ # Before click, hover to draw attention
99
+ - action: hover
100
+ target:
101
+ type: selector
102
+ selector: "[data-testid='important-button']"
103
+ - action: wait
104
+ duration: 500
105
+ - action: click
106
+ target:
107
+ type: selector
108
+ selector: "[data-testid='important-button']"
109
+ ```
110
+
111
+ ### Optimize Step Grouping
112
+
113
+ **Split complex steps:**
114
+ ```yaml
115
+ # Before: One step with 8 actions
116
+ - id: complete-form
117
+ script: "Fill out the entire form."
118
+ actions: [... 8 actions ...]
119
+
120
+ # After: Logical groupings
121
+ - id: fill-personal-info
122
+ script: "Start by entering your personal information."
123
+ actions:
124
+ - action: type
125
+ target: { type: input, name: "name" }
126
+ text: "John Smith"
127
+ - action: type
128
+ target: { type: input, name: "email" }
129
+ text: "john@example.com"
130
+
131
+ - id: fill-company-info
132
+ script: "Next, add your company details."
133
+ actions:
134
+ - action: type
135
+ target: { type: input, name: "company" }
136
+ text: "Acme Corp"
137
+ - action: type
138
+ target: { type: input, name: "role" }
139
+ text: "Developer"
140
+ ```
141
+
142
+ ### Add Breathing Room
143
+
144
+ **Pause between major sections:**
145
+ ```yaml
146
+ - id: section-transition
147
+ script: "Now let's look at the reporting features."
148
+ actions:
149
+ - action: wait
150
+ duration: 1500
151
+ - action: click
152
+ target: { type: link, text: "Reports" }
153
+ ```
154
+
155
+ ### Improve Script Flow
156
+
157
+ **Connect steps narratively:**
158
+ ```yaml
159
+ # Step 1 ending
160
+ script: "...and that completes the basic setup."
161
+
162
+ # Step 2 beginning (flows from step 1)
163
+ script: "With the foundation in place, we can now configure advanced options."
164
+ ```
165
+
166
+ ### Add Recovery Points
167
+
168
+ **Ensure stable states:**
169
+ ```yaml
170
+ # After potentially flaky operations
171
+ - action: click
172
+ target: { type: button, text: "Process" }
173
+ waitFor:
174
+ type: selectorHidden
175
+ value: ".processing-spinner"
176
+ timeout: 30000 # Generous timeout
177
+ - action: wait
178
+ waitFor:
179
+ type: selector
180
+ value: ".success-indicator"
181
+ ```
182
+
183
+ ## Pacing Guidelines
184
+
185
+ | Step Type | Recommended Duration |
186
+ |-----------|---------------------|
187
+ | Intro | 5-10 seconds |
188
+ | Simple action | 3-5 seconds |
189
+ | Form entry | 8-15 seconds |
190
+ | Feature explanation | 10-20 seconds |
191
+ | Transition | 2-4 seconds |
192
+ | Outro | 5-10 seconds |
193
+
194
+ ## Optimization Checklist
195
+
196
+ ### Pacing
197
+ - [ ] No rushed steps (< 2 seconds)
198
+ - [ ] No overly long steps (> 30 seconds)
199
+ - [ ] Smooth transitions between sections
200
+ - [ ] Adequate intro and outro
201
+
202
+ ### Visual
203
+ - [ ] Key actions have highlights
204
+ - [ ] Complex UI has hover indicators
205
+ - [ ] Content scrolled into view
206
+ - [ ] No jarring jumps
207
+
208
+ ### Reliability
209
+ - [ ] All async operations have waits
210
+ - [ ] Timeouts are reasonable
211
+ - [ ] Selectors are stable
212
+ - [ ] Error states considered
213
+
214
+ ### Narrative
215
+ - [ ] Scripts connect logically
216
+ - [ ] Purpose is clear throughout
217
+ - [ ] Technical terms explained
218
+ - [ ] Conclusion summarizes value
@@ -0,0 +1,164 @@
1
+ # Skill: Review Demo YAML
2
+
3
+ Review and improve a SceneForge demo definition for quality, reliability, and best practices.
4
+
5
+ ## Task
6
+
7
+ Analyze a demo YAML file and provide feedback on:
8
+ - Action reliability
9
+ - Selector stability
10
+ - Script quality
11
+ - Timing considerations
12
+ - Overall structure
13
+
14
+ ## Input Required
15
+
16
+ Provide the following:
17
+ - **Demo YAML content**: The full demo definition
18
+ - **Issues encountered**: Any known problems (optional)
19
+ - **Focus areas**: Specific aspects to review (optional)
20
+
21
+ ## Review Categories
22
+
23
+ ### 1. Schema Compliance
24
+ - Valid YAML syntax
25
+ - Required fields present
26
+ - Correct action types
27
+ - Valid target types
28
+
29
+ ### 2. Selector Quality
30
+ - Stability score (data-testid > aria-label > text)
31
+ - Specificity (not too broad or narrow)
32
+ - Brittleness risk
33
+
34
+ ### 3. Wait Conditions
35
+ - Present after async operations
36
+ - Appropriate condition types
37
+ - Reasonable timeouts
38
+
39
+ ### 4. Script Quality
40
+ - Clarity and tone
41
+ - Length vs. action duration
42
+ - Grammar and punctuation
43
+
44
+ ### 5. Step Organization
45
+ - Logical groupings
46
+ - Descriptive IDs
47
+ - Appropriate granularity
48
+
49
+ ## Output Format
50
+
51
+ ```markdown
52
+ ## Demo Review: [demo-name]
53
+
54
+ ### Summary
55
+ - Overall quality: Good/Needs Work/Poor
56
+ - Critical issues: X
57
+ - Warnings: Y
58
+ - Suggestions: Z
59
+
60
+ ### Critical Issues
61
+ [List of must-fix problems]
62
+
63
+ ### Warnings
64
+ [List of should-fix problems]
65
+
66
+ ### Suggestions
67
+ [List of nice-to-have improvements]
68
+
69
+ ### Detailed Review
70
+
71
+ #### Step: [step-id]
72
+ - Actions: [assessment]
73
+ - Selectors: [assessment]
74
+ - Script: [assessment]
75
+ - Recommendations: [list]
76
+
77
+ [Repeat for each step]
78
+
79
+ ### Recommended Changes
80
+ [YAML snippets with improvements]
81
+ ```
82
+
83
+ ## Review Checklist
84
+
85
+ ### Schema
86
+ - [ ] Version field present
87
+ - [ ] Name follows naming convention
88
+ - [ ] Title is descriptive
89
+ - [ ] All steps have IDs
90
+ - [ ] All steps have script field
91
+ - [ ] All steps have actions array
92
+
93
+ ### Selectors
94
+ - [ ] No fragile CSS class selectors
95
+ - [ ] No position-based selectors
96
+ - [ ] Uses data-testid where available
97
+ - [ ] Fallbacks use semantic selectors
98
+
99
+ ### Wait Conditions
100
+ - [ ] Navigation actions have waitFor
101
+ - [ ] Clicks that trigger async have waitFor
102
+ - [ ] Timeouts are reasonable (not too short)
103
+
104
+ ### Scripts
105
+ - [ ] All steps have non-empty scripts (or intentionally empty)
106
+ - [ ] Language is clear and natural
107
+ - [ ] No spelling/grammar errors
108
+ - [ ] Appropriate length for actions
109
+
110
+ ### Structure
111
+ - [ ] Steps grouped logically
112
+ - [ ] IDs are descriptive
113
+ - [ ] Not too many actions per step
114
+ - [ ] Intro/outro provide context
115
+
116
+ ## Example Review
117
+
118
+ ```markdown
119
+ ## Demo Review: onboarding-flow
120
+
121
+ ### Summary
122
+ - Overall quality: Needs Work
123
+ - Critical issues: 2
124
+ - Warnings: 3
125
+ - Suggestions: 4
126
+
127
+ ### Critical Issues
128
+
129
+ 1. **Step "click-button" uses fragile selector**
130
+ ```yaml
131
+ # Current
132
+ selector: ".btn.btn-primary.mt-4"
133
+
134
+ # Recommended
135
+ selector: "[data-testid='submit-btn']"
136
+ ```
137
+
138
+ 2. **Step "load-data" missing wait condition**
139
+ ```yaml
140
+ # Current
141
+ - action: click
142
+ target: { type: button, text: "Load" }
143
+
144
+ # Recommended
145
+ - action: click
146
+ target: { type: button, text: "Load" }
147
+ waitFor:
148
+ type: selector
149
+ value: ".data-table"
150
+ ```
151
+
152
+ ### Warnings
153
+
154
+ 1. Script in step "intro" may be too short for video duration
155
+ 2. Step IDs not descriptive: "step1", "step2"
156
+ 3. No timeout on slow API wait condition
157
+
158
+ ### Suggestions
159
+
160
+ 1. Add highlight to key click actions
161
+ 2. Consider splitting "fill-large-form" into multiple steps
162
+ 3. Add brief pause after modal opens
163
+ 4. Include conclusion step
164
+ ```