story_player 0.1.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +14 -0
- data/CODE_OF_CONDUCT.md +26 -0
- data/CONTRIBUTING.md +23 -0
- data/GOVERNANCE.md +25 -0
- data/LICENSE +21 -0
- data/README.md +208 -0
- data/SECURITY.md +25 -0
- data/docs/host-integration.md +75 -0
- data/exe/story-player +67 -0
- data/lib/story_player/annotations.rb +54 -0
- data/lib/story_player/assets/accessibility_path.js +168 -0
- data/lib/story_player/assets/annotations.css +229 -0
- data/lib/story_player/assets/annotations.js +471 -0
- data/lib/story_player/assets/element_picker.js +209 -0
- data/lib/story_player/assets/offline_player.html +191 -0
- data/lib/story_player/assets/stage.css +65 -0
- data/lib/story_player/assets/stage.js +195 -0
- data/lib/story_player/bridge.rb +97 -0
- data/lib/story_player/capybara.rb +23 -0
- data/lib/story_player/history.rb +51 -0
- data/lib/story_player/integration.rb +40 -0
- data/lib/story_player/minitest.rb +45 -0
- data/lib/story_player/note_store.rb +126 -0
- data/lib/story_player/playback.rb +138 -0
- data/lib/story_player/playlist.rb +101 -0
- data/lib/story_player/polyrun.rb +23 -0
- data/lib/story_player/recording.rb +132 -0
- data/lib/story_player/review.rb +59 -0
- data/lib/story_player/rspec.rb +39 -0
- data/lib/story_player/run.rb +118 -0
- data/lib/story_player/session.rb +73 -0
- data/lib/story_player/version.rb +5 -0
- data/lib/story_player.rb +58 -0
- data/story_player.gemspec +50 -0
- metadata +174 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 8212ef4d85eb85f90708df5f5a8a44c4b75137465734adee5ce852188f2a041c
|
|
4
|
+
data.tar.gz: fdb4f486cfaa2de671e47261adc29cc1de4b0679e59dc793dccf3386374bb1f5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c13e0378c70ea6f6a1419b48a74bb5686f8bd6cffb4ff022f6a0eb11bf120f56b595f27bced9442de84bc817a29553e84c92069201f729b1fe9e66c6c3583d7a
|
|
7
|
+
data.tar.gz: c3f9858fc0b172233115eaa23000555648158f0264f9f5048589ffa2ed27f61f4b50daba300569e1421abbafced41e34e53eb68f220bfb6329d88ab3d6116e9a
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## 0.1.1 (2026-12-04)
|
|
4
|
+
|
|
5
|
+
- Keep playlist review controls inside the player pane on short viewports.
|
|
6
|
+
|
|
7
|
+
## 0.1.0 (2026-12-04)
|
|
8
|
+
|
|
9
|
+
- Extract Story Player as a standalone Ruby gem with the `story-player` command for live playback, playlists, recording, and history.
|
|
10
|
+
- Support RSpec, Minitest, Polyrun Quick, and direct Ruby integration.
|
|
11
|
+
- Add interactive playback controls, recovery, annotations, and offline HTML recordings.
|
|
12
|
+
- Add a Ruby 3.2–4.0 test matrix and an installed-package check.
|
|
13
|
+
- Add RuboCop with Standard and class/module length limits of 150 lines.
|
|
14
|
+
- Add Trunk, OpenSSF Scorecard, Dependabot, and community project files for the public repository.
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Pledge
|
|
4
|
+
|
|
5
|
+
Participation is a harassment-free experience. Treat each other with respect. Keep private context private.
|
|
6
|
+
|
|
7
|
+
## Expected behavior
|
|
8
|
+
|
|
9
|
+
- Engage with genuine curiosity. Admit uncertainty.
|
|
10
|
+
- Own every line you submit, including generated code.
|
|
11
|
+
- Correct errors politely.
|
|
12
|
+
- Use language that welcomes people and respects identity and privacy.
|
|
13
|
+
|
|
14
|
+
## Unacceptable behavior
|
|
15
|
+
|
|
16
|
+
- Harassment, trolling, or insulting comments, public or private.
|
|
17
|
+
- Using jargon or volume, including automated spam, to silence others.
|
|
18
|
+
- Sharing others' data or personal context without permission.
|
|
19
|
+
|
|
20
|
+
## Automation
|
|
21
|
+
|
|
22
|
+
You remain responsible for bugs, security holes, and bias in generated artifacts you submit.
|
|
23
|
+
|
|
24
|
+
## Enforcement
|
|
25
|
+
|
|
26
|
+
Report abusive or harassing behavior to contact@kiskolabs.com. Reports are reviewed and investigated.
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Contributing Guidelines
|
|
2
|
+
|
|
3
|
+
## Automation authorship
|
|
4
|
+
|
|
5
|
+
You may use AI and automation tools. You remain the author of every line you submit: review, debug, and understand the change.
|
|
6
|
+
|
|
7
|
+
Keep pull requests small enough to review. Annotate non-obvious logic.
|
|
8
|
+
|
|
9
|
+
Never send project secrets or private context to public models.
|
|
10
|
+
|
|
11
|
+
## How to contribute
|
|
12
|
+
|
|
13
|
+
### Reporting issues
|
|
14
|
+
|
|
15
|
+
Verify the facts before filing. Use issue templates for goals, constraints, and reproduction steps.
|
|
16
|
+
|
|
17
|
+
### Pull requests
|
|
18
|
+
|
|
19
|
+
Keep one pull request to one goal. Explain why the change is needed. Run smoke tests and regression checks locally before opening the request.
|
|
20
|
+
|
|
21
|
+
### Review
|
|
22
|
+
|
|
23
|
+
Reviewers will ask about approach and trade-offs. Treat suggested changes as part of the work.
|
data/GOVERNANCE.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Project Governance
|
|
2
|
+
|
|
3
|
+
## Roles
|
|
4
|
+
|
|
5
|
+
### Contributors
|
|
6
|
+
|
|
7
|
+
Anyone who submits code, documentation, or participates in discussions. Contributors take ownership of problems they identify and follow the project's quality standards.
|
|
8
|
+
|
|
9
|
+
### Maintainers
|
|
10
|
+
|
|
11
|
+
Maintainers:
|
|
12
|
+
|
|
13
|
+
1. Set scope and architectural direction.
|
|
14
|
+
2. Review contributions (human or automated) against security and logic standards.
|
|
15
|
+
3. Decide when the community is divided.
|
|
16
|
+
|
|
17
|
+
## Decision making
|
|
18
|
+
|
|
19
|
+
### Lazy consensus
|
|
20
|
+
|
|
21
|
+
For routine changes, a proposal that draws no objection within two weeks is approved.
|
|
22
|
+
|
|
23
|
+
### Maintainer approval
|
|
24
|
+
|
|
25
|
+
Major architectural changes, high-risk automation integrations, or changes that affect business logic need explicit maintainer approval. A change must solve a real problem.
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrei Makarov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Story Player
|
|
2
|
+
|
|
3
|
+
[](https://github.com/amkisko/story_player.rb/actions/workflows/test.yml)
|
|
4
|
+
|
|
5
|
+
Story Player runs existing browser tests as interactive demos, plays them as a playlist, and keeps recordings for later review. Use the `story_player` gem and the `story-player` command. The gem manages the test and local files in Ruby. The player and notes use browser JavaScript and CSS.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Story Player runs without Rails on Ruby 3.2 or newer. Recording, notes, playlists and history use Ruby's standard library. The browser and test-runner adapters are optional.
|
|
10
|
+
|
|
11
|
+
Add the gem to the project's Gemfile and run `bundle install`:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
group :development, :test do
|
|
15
|
+
gem "story_player", require: false
|
|
16
|
+
end
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For a local checkout, substitute a path gem:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
group :development, :test do
|
|
23
|
+
gem "story_player", path: "../story_player.rb", require: false
|
|
24
|
+
end
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Live playback and annotation use a Playwright Ruby page or a Capybara session with `capybara-playwright-driver`. Use the project's Playwright CLI and browser installation. The browser binding and init-script lifecycle are verified with Playwright Ruby 1.65 (Disposable handles). On older clients such as 1.58, Bridge skips `dispose` when the return value has no dispose API and still runs the in-page cleanup. Configure the project to run the browser headed when `ENV["HEADFUL"] == "1"`; the command sets that variable for live demos. Recording also accepts other Capybara drivers that implement screenshots.
|
|
28
|
+
|
|
29
|
+
## RSpec and Capybara
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
require "story_player/rspec"
|
|
33
|
+
|
|
34
|
+
StoryPlayer::RSpec.install!(automatic: true)
|
|
35
|
+
|
|
36
|
+
RSpec.describe "Checkout", demo: true do
|
|
37
|
+
include Capybara::DSL
|
|
38
|
+
|
|
39
|
+
it "reviews the order" do
|
|
40
|
+
visit "/checkout"
|
|
41
|
+
click_button "Review order"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
bundle exec story-player live checkout -- bundle exec rspec spec/system/checkout_spec.rb
|
|
48
|
+
bundle exec story-player record checkout -- bundle exec rspec spec/system/checkout_spec.rb
|
|
49
|
+
bundle exec story-player play checkout
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Automatic Capybara steps cover `visit`, `click_button`, `click_link`, `click_on` and `fill_in`. Omit `automatic: true` for explicit checkpoints only. For direct Playwright, set `page: -> { browser_page }` in `install!` and use explicit checkpoints.
|
|
53
|
+
|
|
54
|
+
## Minitest
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
require "story_player/minitest"
|
|
58
|
+
|
|
59
|
+
class CheckoutTest < Minitest::Test
|
|
60
|
+
include Capybara::DSL
|
|
61
|
+
include StoryPlayer::Minitest
|
|
62
|
+
|
|
63
|
+
def test_review
|
|
64
|
+
visit "/checkout"
|
|
65
|
+
demo_checkpoint!("Review the order", final: true)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
bundle exec story-player live checkout -- bundle exec ruby test/checkout_test.rb
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Override `demo_stage_page` if the browser is available through a different method. Return `{automatic: true}` from `demo_stage_options` for automatic Capybara steps.
|
|
75
|
+
|
|
76
|
+
## Polyrun
|
|
77
|
+
|
|
78
|
+
Polyrun uses the same adapters when it runs RSpec or Minitest. Select one example or file for interactive playback so one browser waits for input at a time. Keep any worker timeouts longer than the planned review.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
mkdir -p tmp
|
|
82
|
+
printf '%s\n' spec/system/checkout_spec.rb > tmp/demo-paths.txt
|
|
83
|
+
bundle exec story-player live checkout -- bundle exec polyrun parallel-rspec --workers 1 --paths-file tmp/demo-paths.txt
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
With Polyrun Quick 3 or newer, install the adapter in the group and call `demo_checkpoint!` from the example.
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
require "story_player/polyrun"
|
|
90
|
+
|
|
91
|
+
describe "Checkout" do
|
|
92
|
+
StoryPlayer::Polyrun.install!(self, title: "Checkout", page: -> { browser_page })
|
|
93
|
+
|
|
94
|
+
it "reviews the order" do
|
|
95
|
+
browser_page.goto("/checkout")
|
|
96
|
+
demo_checkpoint!("Review the order")
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
bundle exec story-player live checkout -- bundle exec polyrun quick test/checkout_test.rb
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Any Ruby runner
|
|
106
|
+
|
|
107
|
+
Call the block API around a journey in a Ruby script or test runner. Start the browser using the existing test setup.
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
require "story_player"
|
|
111
|
+
|
|
112
|
+
StoryPlayer.run(page: browser_page, title: "Checkout") do |stage|
|
|
113
|
+
browser_page.goto("/checkout")
|
|
114
|
+
stage.checkpoint("Review the order", restore: -> { restore_checkout_form }, final: true)
|
|
115
|
+
end
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Call `StoryPlayer.with_annotations(page: browser_page, title: "Checkout") { $stdin.gets }` for a notes-only review in a browser that is already open. End the block when review is complete.
|
|
119
|
+
|
|
120
|
+
## Applications and tests outside Ruby
|
|
121
|
+
|
|
122
|
+
The application does not need Ruby or Rails. Drive its UI with a separate Ruby Playwright script for live review, or assemble PNGs from its existing test or terminal runner for offline review. See the [host integration guide](docs/host-integration.md) for executable examples and the limits of wrapping commands.
|
|
123
|
+
|
|
124
|
+
## Playback and recovery
|
|
125
|
+
|
|
126
|
+
- Live playback starts paused. Use the app with the mouse and keyboard while the test waits. The player handles arrow keys only while a player button has focus. Use Hide to uncover the bottom of the page.
|
|
127
|
+
- **Play** returns to the checkpoint where the test is waiting and continues. **Forward** advances through visited steps and then releases the test one step at a time. **Backward** and the step selector revisit earlier checkpoints. **Stop** pauses at the first visited step. **Restore** reapplies the currently selected checkpoint. Set the speed to change the pause between automated steps.
|
|
128
|
+
- Recovery returns to the checkpoint URL, calls its optional Ruby `restore:` callback, then restores the viewport scroll. Use a repeatable callback for form fields, selections, application state, or fixtures that the next automated action needs. Restoring the browser location cannot undo writes the viewer made in the app.
|
|
129
|
+
- A checkpoint with `final: true` pauses before completing the test. **Check result** releases it for the remaining assertions. A failed recovery stays paused and shows a retry message.
|
|
130
|
+
- The controls follow navigation in the original tab on the initial web origin. For a demo across trusted origins, pass `allowed_origins: ["https://checkout.rails.fi"]`. Use browser Back to get to the controls again after visiting another origin.
|
|
131
|
+
|
|
132
|
+
## Playlists and results
|
|
133
|
+
|
|
134
|
+
List stories in a YAML file and run `bundle exec story-player playlist stories.yml`. A playlist runs its commands with your local privileges. Use playlists from your project or review them before running them. Select one example per story.
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
- title: Checkout
|
|
138
|
+
command: [bundle, exec, rspec, "spec/system/checkout_spec.rb:24"]
|
|
139
|
+
- title: Receipt
|
|
140
|
+
command: [bundle, exec, ruby, test/receipt_test.rb, --name, test_review]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Play or step through a story as usual. At the result, Story Player shows **Passed**, **Failed** or **Skipped** and leaves the browser and annotations available. The result comes from the test before its browser cleanup. The test runner still reports errors from later cleanup. Use **Previous story**, **Replay story**, **Next story** or **Open story** to move through the list. Each selection runs that story in a fresh test process. **Exit playlist** leaves the playlist. A single story has a **Close story** control. The command returns a failure exit status if any story's latest run failed.
|
|
144
|
+
|
|
145
|
+
The RSpec and Minitest adapters hold the result before their browser cleanup. When driving Playwright directly, keep the page open until the `StoryPlayer.run` block finishes reviewing. Set `inspect_results: false` in the adapter options or block API for unattended live runs.
|
|
146
|
+
|
|
147
|
+
## Notes and recordings
|
|
148
|
+
|
|
149
|
+
Open **Annotations** and write a page note, or use **Select element** to attach a pin. Click or focus the element and press Enter to select it. While writing a note, review its accessibility path, which shows the target role and name under landmarks such as a named region or form. Open **Element details** on a saved comment to revisit its path. Use the **Targeting warnings** button to see suggested fixes when a target has warnings. Drafts survive same-tab reloads. Escape closes the panel or cancels selection.
|
|
150
|
+
|
|
151
|
+
Pins use a unique stable identifier first. A target without an identifier can also match by role and name within the stored path. If several elements share the path, the pin stays on the selected element while it remains in the current document. The saved comment stays in the list across reloads. Targeting hints suggest adding a visible label, naming an icon-only action, distinguishing repeated controls, or adding a stable `id` or `data-testid` where needed.
|
|
152
|
+
|
|
153
|
+
The path uses common HTML and ARIA roles and names observed in the page. The saved Markdown includes this path alongside the element's locator. Existing CSS-only notes still open.
|
|
154
|
+
|
|
155
|
+
Notes are Markdown files under `tmp/demo-stage/annotations`, grouped by demo and page path. Use different titles for independent journeys. A host can opt into its own stable anchor attribute and named views using `anchor_attribute:`, `surface_attribute:` and `surfaces:`. The library leaves query strings and fragments out of note metadata. Page text used for pin labels and screenshots may still contain data from the running test.
|
|
156
|
+
|
|
157
|
+
Recordings contain PNGs, the outcome, a timestamp, and a self-contained HTML player in `tmp/demo-stage/recordings`. Live runs archive the visited steps and the final screen, including failures. Runs that end before a screen can be captured still appear in the history with their outcome. **Run history** opens the story's earlier recordings in a separate tab. Use `story-player history [TITLE]` to see the archive, or `story-player play [TITLE]` to open the latest recording. Copy an individual recording directory for offline review.
|
|
158
|
+
|
|
159
|
+
Set `DEMO_STAGE_RECORDINGS` to change the output directory and `DEMO_STAGE_HISTORY=0` to disable captures during live runs. The explicit `record` command still captures. Ordinary test runs have no gates or captures unless `DEMO_STAGE_MODE` is set.
|
|
160
|
+
|
|
161
|
+
## Development
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
make setup
|
|
165
|
+
make check
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`make check` runs Ruby syntax checks, the specs, and the installed-package check. `make test` uses Polyrun on Ruby 3.4 and 4.0, and runs RSpec directly on Ruby 3.2 and 3.3. Use `make test-rspec` to run serially on any supported Ruby.
|
|
169
|
+
|
|
170
|
+
Use the matching Appraisal Gemfile when testing a different Ruby. For example, with Ruby 3.2 active:
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
export BUNDLE_GEMFILE="$PWD/gemfiles/ruby32.gemfile"
|
|
174
|
+
make setup
|
|
175
|
+
make test
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Run `make appraisals` from the default bundle after changing `Gemfile` or `Appraisals`. Refresh each affected lockfile with `bundle install` under its matching Ruby.
|
|
179
|
+
|
|
180
|
+
Set `PLAYWRIGHT_CLI` to reuse a Playwright executable matching the Ruby client. Update the Playwright versions in `Gemfile` and `Makefile` together. `make package` builds and installs a `.gem` into a temporary directory, verifies recording and history, and limits the compressed package to 48 KiB. It reports build time separately.
|
|
181
|
+
|
|
182
|
+
Run `make pray-install` after changing `Prayfile` or `.agents/project.md` to refresh the shared instructions and community files. Run `make pray-verify` to check the generated files. Both commands use the Pray version in the development bundle.
|
|
183
|
+
|
|
184
|
+
Run `make audit` to update the Ruby advisory database and check `Gemfile.lock` plus every Appraisal lockfile.
|
|
185
|
+
|
|
186
|
+
## Links
|
|
187
|
+
|
|
188
|
+
- [OpenSSF Scorecard](https://scorecard.dev/viewer/?uri=github.com/amkisko/story_player.rb)
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
Released under the [MIT License](LICENSE). Copyright (c) 2026 Andrei Makarov.
|
|
193
|
+
|
|
194
|
+
## Contributing
|
|
195
|
+
|
|
196
|
+
Bug reports and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, tests, RuboCop, optional Trunk, and PR conventions. Community participation follows [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
|
|
197
|
+
|
|
198
|
+
## Security
|
|
199
|
+
|
|
200
|
+
Do not open public issues for security vulnerabilities. See [SECURITY.md](SECURITY.md) for how to report them.
|
|
201
|
+
|
|
202
|
+
## Sponsors
|
|
203
|
+
|
|
204
|
+
Sponsored by [Kisko Labs](https://www.kiskolabs.com).
|
|
205
|
+
|
|
206
|
+
<a href="https://www.kiskolabs.com">
|
|
207
|
+
<img src="kisko.svg" width="200" alt="Sponsored by Kisko Labs" />
|
|
208
|
+
</a>
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SECURITY
|
|
2
|
+
|
|
3
|
+
## Reporting a Vulnerability
|
|
4
|
+
|
|
5
|
+
Email security details to: security@kiskolabs.com
|
|
6
|
+
|
|
7
|
+
Send the report only to that address. Include description, steps to reproduce, potential impact, and a suggested fix when you have one.
|
|
8
|
+
|
|
9
|
+
### Response Timeline
|
|
10
|
+
|
|
11
|
+
- We will acknowledge receipt of your report.
|
|
12
|
+
- We will provide an initial assessment.
|
|
13
|
+
- We will keep you informed of our progress and resolution timeline.
|
|
14
|
+
|
|
15
|
+
### Disclosure Policy
|
|
16
|
+
|
|
17
|
+
- We will work with you to understand and resolve the issue.
|
|
18
|
+
- We will credit you for the discovery unless you prefer to remain anonymous.
|
|
19
|
+
- We will publish a security advisory after the vulnerability is patched.
|
|
20
|
+
- We will coordinate public disclosure with you.
|
|
21
|
+
|
|
22
|
+
## Automation Security
|
|
23
|
+
|
|
24
|
+
- Keep production credentials, API keys, and personal data out of prompts sent to third-party models or automation services.
|
|
25
|
+
- Verify automated dependencies.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Use Story Player with another stack
|
|
2
|
+
|
|
3
|
+
The application and its tests can run in any language. Story Player itself runs on Ruby 3.2 or newer. Choose the integration by what you want to review.
|
|
4
|
+
|
|
5
|
+
## Drive a browser journey live
|
|
6
|
+
|
|
7
|
+
Start the application with its own tools. For example, use the development server for a JavaScript app, `mix phx.server` for Phoenix, or the project's Cargo command for a Rust web service. Point a separate Ruby Playwright script at the local application URL. The process that owns the browser page also owns the Story Player checkpoints.
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
require "playwright"
|
|
11
|
+
require "story_player"
|
|
12
|
+
|
|
13
|
+
Playwright.create(playwright_cli_executable_path: ENV.fetch("PLAYWRIGHT_CLI")) do |playwright|
|
|
14
|
+
playwright.chromium.launch(headless: ENV["HEADFUL"] != "1") do |browser|
|
|
15
|
+
page = browser.new_page
|
|
16
|
+
page.goto(ENV.fetch("APP_URL"))
|
|
17
|
+
StoryPlayer.run(page:, title: ENV.fetch("DEMO_STAGE_TITLE")) do |story|
|
|
18
|
+
story.checkpoint("Start")
|
|
19
|
+
page.get_by_role("button", name: "Review order").click
|
|
20
|
+
story.checkpoint("Review the order", final: true)
|
|
21
|
+
raise "Order is missing" unless page.get_by_text("Order ready").visible?
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Use the project's actual button and result names. Keep the matching Playwright executable and browser installation available to the Ruby script. Run `story-player live "Review order" -- ruby demo.rb` in the bundle containing Story Player and the Playwright Ruby client. Use `record` in place of `live` for a headless capture. The application does not load the gem.
|
|
28
|
+
|
|
29
|
+
## Review images from an existing runner
|
|
30
|
+
|
|
31
|
+
If a JavaScript browser test, Elixir feature test, Rust program, or CLI harness already saves PNGs, keep that runner in charge of the test. Use a short Ruby script to assemble selected images into a labeled offline story. The assembler needs no browser, Rails, or test framework.
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
require "fileutils"
|
|
35
|
+
require "story_player"
|
|
36
|
+
|
|
37
|
+
class FrameSource
|
|
38
|
+
attr_writer :source
|
|
39
|
+
|
|
40
|
+
def screenshot(path:)
|
|
41
|
+
FileUtils.copy_file(@source, path)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
page = FrameSource.new
|
|
46
|
+
StoryPlayer.run(page:, title: "Check the report", mode: :record) do |story|
|
|
47
|
+
[["Report requested", "request.png"], ["Report ready", "report.png"]].each do |label, image|
|
|
48
|
+
page.source = image
|
|
49
|
+
story.checkpoint(label)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Run the assembler from the directory containing the images. Open the resulting story with `story-player play "Check the report"` or share its complete recording directory for offline review. The example archives a successful assembly; it does not determine the native runner's verdict. Keep the runner's own exit status and assertions as the CI result. Use test data and check the images before sharing them.
|
|
55
|
+
|
|
56
|
+
## Run a command without playback
|
|
57
|
+
|
|
58
|
+
To install from an authorized checkout without Bundler, build and install locally from the Story Player checkout:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
mkdir -p tmp
|
|
62
|
+
gem build story_player.gemspec --output tmp/story_player.gem
|
|
63
|
+
gem install --local tmp/story_player.gem
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Then run commands from the host project:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
story-player run "Inspect configuration" -- ./bin/my-cli config show
|
|
70
|
+
story-player run "Elixir tests" -- mix test
|
|
71
|
+
story-player run "JavaScript tests" -- npm test
|
|
72
|
+
story-player run "Rust tests" -- cargo test
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`run` passes through arguments and the launched program's exit status. It does not record standard output, emulate a terminal, or add checkpoints. `live` and `record` select a mode for an integration that reads it; wrapping an unmodified command does not create a recording. For a terminal application, use an existing terminal harness to produce PNGs if you want an offline story. Terminal input replay and live notes on terminal output are not supported.
|
data/exe/story-player
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "story_player"
|
|
5
|
+
require "rbconfig"
|
|
6
|
+
|
|
7
|
+
usage = <<~USAGE
|
|
8
|
+
Usage
|
|
9
|
+
story-player live|record|run TITLE -- COMMAND [ARGUMENTS…]
|
|
10
|
+
story-player play [TITLE]
|
|
11
|
+
story-player playlist FILE
|
|
12
|
+
story-player history [TITLE]
|
|
13
|
+
USAGE
|
|
14
|
+
|
|
15
|
+
def open_story_page(page)
|
|
16
|
+
case RbConfig::CONFIG.fetch("host_os")
|
|
17
|
+
when /darwin/ then exec("open", page)
|
|
18
|
+
when /mswin|mingw/ then exec("explorer", page)
|
|
19
|
+
else exec("xdg-open", page)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
command, title = ARGV.shift(2)
|
|
24
|
+
case command
|
|
25
|
+
when "live", "record", "run"
|
|
26
|
+
abort usage unless title && ARGV.shift == "--" && !ARGV.empty?
|
|
27
|
+
|
|
28
|
+
mode = command unless command == "run"
|
|
29
|
+
environment = {"DEMO_STAGE_MODE" => mode, "DEMO_STAGE_TITLE" => title}
|
|
30
|
+
environment["HEADFUL"] = "1" if command == "live"
|
|
31
|
+
executable, *arguments = ARGV
|
|
32
|
+
begin
|
|
33
|
+
exec(environment, [executable, executable], *arguments)
|
|
34
|
+
rescue Errno::ENOENT
|
|
35
|
+
warn "Command not found: #{executable}"
|
|
36
|
+
exit 127
|
|
37
|
+
rescue SystemCallError
|
|
38
|
+
warn "Could not start command: #{executable}"
|
|
39
|
+
exit 126
|
|
40
|
+
end
|
|
41
|
+
when "playlist"
|
|
42
|
+
abort usage unless title && ARGV.empty?
|
|
43
|
+
|
|
44
|
+
begin
|
|
45
|
+
exit StoryPlayer::Playlist.load(title).run
|
|
46
|
+
rescue StoryPlayer::Error => error
|
|
47
|
+
abort error.message
|
|
48
|
+
end
|
|
49
|
+
when "play", "history"
|
|
50
|
+
abort usage unless ARGV.empty?
|
|
51
|
+
|
|
52
|
+
root = ENV.fetch("DEMO_STAGE_RECORDINGS", "tmp/demo-stage/recordings")
|
|
53
|
+
begin
|
|
54
|
+
page = if command == "history"
|
|
55
|
+
StoryPlayer::History.write(root, title:)
|
|
56
|
+
else
|
|
57
|
+
File.expand_path("index.html", StoryPlayer::Recording.latest(root, title:))
|
|
58
|
+
end
|
|
59
|
+
rescue StoryPlayer::Error => error
|
|
60
|
+
abort error.message
|
|
61
|
+
end
|
|
62
|
+
open_story_page(page)
|
|
63
|
+
when nil, "-h", "--help"
|
|
64
|
+
puts usage
|
|
65
|
+
else
|
|
66
|
+
abort usage
|
|
67
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StoryPlayer
|
|
4
|
+
class Annotations
|
|
5
|
+
def initialize(page:, title:, notes_root: "tmp/demo-stage/annotations", allowed_origins: [],
|
|
6
|
+
surface_attribute: nil, surfaces: [], anchor_attribute: nil)
|
|
7
|
+
@bridge = Bridge.new(page, allowed_origins:)
|
|
8
|
+
@store = NoteStore.new(root: notes_root, title:)
|
|
9
|
+
@title = title.to_s
|
|
10
|
+
@surfaces = surfaces
|
|
11
|
+
@surface_attribute = checked_attribute(surface_attribute)
|
|
12
|
+
@anchor_attribute = checked_attribute(anchor_attribute)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def start
|
|
16
|
+
styles = File.read(File.join(ASSETS, "annotations.css"))
|
|
17
|
+
overlay = File.read(File.join(ASSETS, "annotations.js"))
|
|
18
|
+
picker = File.read(File.join(ASSETS, "element_picker.js"))
|
|
19
|
+
accessibility = File.read(File.join(ASSETS, "accessibility_path.js"))
|
|
20
|
+
options = {chapter: @title, surfaceAttribute: @surface_attribute, anchorAttribute: @anchor_attribute}
|
|
21
|
+
@bridge.start("void (#{overlay})(call, #{styles.to_json}, #{picker}, #{accessibility}, #{options.to_json});",
|
|
22
|
+
cleanup: 'window[Symbol.for("demoStage.annotations")]?.()', &method(:annotate))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def close
|
|
26
|
+
@bridge.close
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def checked_attribute(value)
|
|
32
|
+
return value if value.nil? || value.match?(/\Adata-[a-z0-9-]+\z/)
|
|
33
|
+
|
|
34
|
+
raise ArgumentError, "Expected a data attribute name"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def annotate(location, operation, payload)
|
|
38
|
+
return true if operation == "active"
|
|
39
|
+
|
|
40
|
+
path = location.path.empty? ? "/" : location.path
|
|
41
|
+
raise ArgumentError, "The annotation page changed" unless payload.is_a?(Hash) && payload["page"] == path
|
|
42
|
+
|
|
43
|
+
surface = payload["surface"]
|
|
44
|
+
raise ArgumentError, "Unknown annotation view" unless surface.nil? || @surfaces.include?(surface)
|
|
45
|
+
|
|
46
|
+
origin = location.origin unless location.origin == @bridge.primary_origin
|
|
47
|
+
case operation
|
|
48
|
+
when "list" then @store.list(page: path, surface:, origin:)
|
|
49
|
+
when "save" then @store.save(payload, page: path, surface:, origin:)
|
|
50
|
+
else raise ArgumentError, "Unknown annotation action"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|