@a1knowhow/demo-maker 0.1.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.
Files changed (44) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +104 -0
  3. package/SECURITY.md +33 -0
  4. package/bin/demo-maker.mjs +14 -0
  5. package/docs/README.md +35 -0
  6. package/docs/actions.md +160 -0
  7. package/docs/cli.md +73 -0
  8. package/docs/getting-started.md +220 -0
  9. package/docs/imports-and-fragments.md +78 -0
  10. package/docs/library-api.md +64 -0
  11. package/docs/locators.md +119 -0
  12. package/docs/recording.md +59 -0
  13. package/docs/repairing-scenarios.md +73 -0
  14. package/docs/scenario-schema.md +80 -0
  15. package/docs/url-capture.md +75 -0
  16. package/docs/variables.md +48 -0
  17. package/docs/video-and-pacing.md +109 -0
  18. package/examples/demo1-introduction.yaml +166 -0
  19. package/examples/demo2-github-actions.yaml +109 -0
  20. package/examples/files/demo1-introduction-run.log +50 -0
  21. package/examples/fragments/open-repository.yaml +15 -0
  22. package/examples/smoke.yaml +18 -0
  23. package/llms.txt +32 -0
  24. package/package.json +66 -0
  25. package/src/cli.ts +226 -0
  26. package/src/env.ts +112 -0
  27. package/src/export-chapters.ts +99 -0
  28. package/src/ffmpeg.ts +168 -0
  29. package/src/index.ts +54 -0
  30. package/src/load.ts +143 -0
  31. package/src/logger.ts +126 -0
  32. package/src/main.ts +68 -0
  33. package/src/parse-errors.ts +99 -0
  34. package/src/parse.ts +622 -0
  35. package/src/playwright-selector-to-locator.ts +328 -0
  36. package/src/record-cli.ts +179 -0
  37. package/src/recorder.ts +442 -0
  38. package/src/recording-to-yaml.ts +435 -0
  39. package/src/runner.ts +1582 -0
  40. package/src/selector-to-locator.ts +69 -0
  41. package/src/templates.ts +48 -0
  42. package/src/types.ts +319 -0
  43. package/src/url-capture.ts +105 -0
  44. package/src/variables.ts +64 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
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 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 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 those 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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # demo-maker
2
+
3
+ 🎬 **Demo videos as code** — configure once, re-run forever. YAML + Playwright → polished, consistent product feature videos.
4
+
5
+ Turn versioned scenario configs into consistent product feature videos — reconfigure, re-run, no manual re-recording.
6
+
7
+ ## Why?
8
+
9
+ Product UIs keep changing, so demo videos go stale. Re-recording by hand (or asking an agent to “just make a video”) is slow, costly, and still needs a human check.
10
+
11
+ With demo-maker you version the walkthrough as YAML: edit steps, re-run, get the same MP4. Fragments and imports make flows reusable; you or an agent can maintain the scripts like code.
12
+
13
+ **Side effect:** writing stable locators surfaces real UI gaps—missing labels, duplicate accessible names, hard-to-target list rows—so you often fix accessibility while building the demo.
14
+
15
+ ## Requirements
16
+
17
+ - **Node.js** 20+
18
+ - **Playwright Chromium** (`npx playwright install chromium`)
19
+ - **ffmpeg** on `PATH` (MP4 re-encode, `cut_video` splice, background audio)
20
+
21
+ ## Install
22
+
23
+ Published on npm as [`@a1knowhow/demo-maker`](https://www.npmjs.com/package/@a1knowhow/demo-maker):
24
+
25
+ ```bash
26
+ npm install -D @a1knowhow/demo-maker
27
+ npx playwright install chromium
28
+ ```
29
+
30
+ Or from a clone:
31
+
32
+ ```bash
33
+ npm install
34
+ npx playwright install chromium
35
+ ```
36
+
37
+ The package ships TypeScript source and runs via `tsx`. Library imports (`import … from "@a1knowhow/demo-maker"`) need a TypeScript-capable toolchain (tsx, Vitest, or a bundler). See [Security](./SECURITY.md) for runtime capabilities.
38
+
39
+ ## Quick start
40
+
41
+ ```bash
42
+ npx demo-maker run examples/smoke.yaml --headless --fast
43
+ ```
44
+
45
+ Step-by-step (install → first MP4 → record → fragments): **[docs/getting-started.md](./docs/getting-started.md)**
46
+
47
+ ## Example walkthrough
48
+
49
+ Intro tour: open this repo on GitHub and walk getting-started → actions → locators (imports, title cards, captions, pacing):
50
+
51
+ ```bash
52
+ npx demo-maker run examples/demo1-introduction.yaml
53
+ ```
54
+
55
+ <video src="https://github.com/user-attachments/assets/4f1ded4a-5874-43f9-9d67-17843164ac61" controls width="720"></video>
56
+
57
+ [View logs](./examples/files/demo1-introduction-run.log)
58
+
59
+ Richer CI walkthrough (Actions → green run → test job):
60
+
61
+ ```bash
62
+ npx demo-maker run examples/demo2-github-actions.yaml
63
+ ```
64
+
65
+ ([`examples/demo1-introduction.yaml`](./examples/demo1-introduction.yaml) · [`examples/demo2-github-actions.yaml`](./examples/demo2-github-actions.yaml) · [`examples/smoke.yaml`](./examples/smoke.yaml) for a minimal check)
66
+
67
+ ## Documentation
68
+
69
+
70
+ | Topic | Link |
71
+ | ----------------------- | ------------------------------------------------------------ |
72
+ | Index | [docs/README.md](./docs/README.md) |
73
+ | Getting started | [docs/getting-started.md](./docs/getting-started.md) |
74
+ | CLI | [docs/cli.md](./docs/cli.md) |
75
+ | Actions | [docs/actions.md](./docs/actions.md) |
76
+ | Locators | [docs/locators.md](./docs/locators.md) |
77
+ | Video & pacing | [docs/video-and-pacing.md](./docs/video-and-pacing.md) |
78
+ | Recording | [docs/recording.md](./docs/recording.md) |
79
+ | Repair after UI changes | [docs/repairing-scenarios.md](./docs/repairing-scenarios.md) |
80
+
81
+
82
+ Typed schema: `[src/types.ts](./src/types.ts)`.
83
+
84
+ ## Commands
85
+
86
+
87
+ | Command | Purpose |
88
+ | ---------------------------------- | --------------------------------------- |
89
+ | `demo-maker run <scenario.yaml>` | Execute scenario (optional video) |
90
+ | `demo-maker check <scenario.yaml>` | `run` with `--fail-fast --fast` |
91
+ | `demo-maker record` | Live-record actions to YAML |
92
+ | `demo-maker import` | Convert DevTools / recorder JSON → YAML |
93
+ | `demo-maker export-chapters` | Timing JSON → YouTube chapter lines |
94
+
95
+
96
+
97
+
98
+ ## Security
99
+
100
+ Report vulnerabilities privately — see [SECURITY.md](./SECURITY.md). Do not open public issues for security bugs.
101
+
102
+ ## License
103
+
104
+ Apache License 2.0 — see [LICENSE](./LICENSE).
package/SECURITY.md ADDED
@@ -0,0 +1,33 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ Security fixes are applied to the latest release on the default branch (`main`). Older versions are not patched.
6
+
7
+ ## Runtime capabilities
8
+
9
+ demo-maker is a CLI that runs only when invoked (there are **no** `preinstall` / `install` / `postinstall` scripts). When you run it, it may:
10
+
11
+ - Drive a browser via Playwright (network access to the URLs in your scenarios)
12
+ - Read named auth env vars or an `--env-file` for login steps
13
+ - Substitute `{{ placeholders }}` from that env file, scenario-referenced env keys, and `BASE_URL` (it does **not** copy the entire process environment into templates)
14
+ - Spawn `ffmpeg` on your `PATH` for video processing
15
+ - Read/write scenario files and video output on the local filesystem
16
+
17
+ Install Playwright browsers separately (`npx playwright install chromium`); this package does not download browsers at install time.
18
+
19
+ ## Reporting a vulnerability
20
+
21
+ **Do not open a public GitHub issue** for security vulnerabilities.
22
+
23
+ Please report privately using [GitHub private vulnerability reporting](https://github.com/a1knowhow/demo-maker/security/advisories/new).
24
+
25
+ Include:
26
+
27
+ - Affected version / commit
28
+ - Description and impact
29
+ - Steps to reproduce (PoC welcome)
30
+
31
+ We aim to acknowledge reports within **7 days** and share a remediation plan when we confirm the issue. Coordinated disclosure is preferred (typical window: up to 90 days).
32
+
33
+ Thank you for helping keep demo-maker and its users safe.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { createRequire } from "node:module";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const require = createRequire(import.meta.url);
9
+ const tsxCli = require.resolve("tsx/cli");
10
+ const entry = join(__dirname, "../src/main.ts");
11
+ const result = spawnSync(process.execPath, [tsxCli, entry, ...process.argv.slice(2)], {
12
+ stdio: "inherit",
13
+ });
14
+ process.exit(result.status ?? 1);
package/docs/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Documentation
2
+
3
+ Purpose: Index for humans and AI agents working with `@a1knowhow/demo-maker`.
4
+
5
+ **Read this first:** [Getting started](./getting-started.md) (install → first run → first MP4).
6
+
7
+ Typed schema source of truth: [`src/types.ts`](../src/types.ts).
8
+
9
+ ## Topic map
10
+
11
+ | Doc | When to open it |
12
+ |-----|-----------------|
13
+ | [Getting started](./getting-started.md) | Zero → first successful run and video |
14
+ | [CLI](./cli.md) | Commands and flags |
15
+ | [Scenario schema](./scenario-schema.md) | Top-level YAML fields |
16
+ | [Actions](./actions.md) | What each `action:` does |
17
+ | [Locators](./locators.md) | Targeting UI elements |
18
+ | [Variables](./variables.md) | `{{ }}` and filename template functions |
19
+ | [Imports and fragments](./imports-and-fragments.md) | Reusable YAML composition |
20
+ | [Recording](./recording.md) | Live record, continue-from, import |
21
+ | [Video and pacing](./video-and-pacing.md) | MP4, captions, title cards, cut_video |
22
+ | [Repairing scenarios](./repairing-scenarios.md) | Fix YAML after UI changes |
23
+ | [Library API](./library-api.md) | Use from TypeScript |
24
+ | [URL capture](./url-capture.md) | Capture IDs from page URLs into `{{ vars }}` |
25
+
26
+ ## Agent loading tips
27
+
28
+ - Prefer opening **one topic file** over the whole tree.
29
+ - For a new scenario: getting-started → actions → locators → video-and-pacing.
30
+ - For a failing step: repairing-scenarios → locators.
31
+ - For composition: imports-and-fragments.
32
+
33
+ ## Similar tools (brief)
34
+
35
+ Demo-maker is in the “demo as code” family: declarative steps → Playwright → video. Close peers include [demo-machine](https://github.com/45ck/demo-machine), [Clipwise](https://github.com/kwakseongjae/clipwise), and [SceneForge](https://github.com/jhandel/sceneforge). Strengths here: composable imports, locator abstraction, storage-state auth, captions/chapters, and a repair loop (`record --continue-from`).
@@ -0,0 +1,160 @@
1
+ # Actions
2
+
3
+ Purpose: Reference for every `action:` value in scenario steps. Schema: [`src/types.ts`](../src/types.ts).
4
+
5
+ Any step may include optional `caption:` (overlay/log) and `timeout_ms:` (default 10000 unless overridden by `action_timeout_ms`).
6
+
7
+ ## Action table
8
+
9
+ | Action | Required | What it does |
10
+ |--------|----------|--------------|
11
+ | **navigate** | `url` | Opens a URL (relative to `base_url`). Waits for DOM ready, rAF paint, then `navigate_hold_ms`. |
12
+ | **click** | `locator` | Clicks the matched element. Optional `settle_until` after click. Then `post_click_delay_ms`. |
13
+ | **drag** | `locator`, `offset_x` | Press at element center, drag by `offset_x` / `offset_y` (default `offset_y: 0`), release. Honors pre/post click delays. |
14
+ | **type** | `locator`, `value` | Clears then types character-by-character (unless `clear_before_type: false`). Real input events. `{{ variables }}` in `value`. Optional per-step `typing_delay_ms`. |
15
+ | **fill** | `locator`, `value` | Sets value in one go (faster; fewer input events). `{{ variables }}` supported. |
16
+ | **wait** | see modes | Fixed delay, URL match, or until locator hidden (optional page refresh). |
17
+ | **expect_visible** | `locator` | Waits until element is visible; fails if not within timeout. |
18
+ | **screenshot** | `screenshots.dir` | HD PNG of page or `locator`. Optional `screenshot: { file, full_page, omit_background, scale }`. |
19
+ | **pause** | — | Wait for Enter in terminal. Skipped in `--headless`. |
20
+ | **log** | `message` | Log line (use `── Scene N: …` for chapter export). |
21
+ | **title_card** | `text` | Full-screen scene title (fade/hold). Optional `hold_ms` (default 1800), `fade_ms` (default 400). |
22
+ | **transition** | — | Fade-to-black. Optional `fade_ms` (default 500). Optional `hold_ms` holds black (outro). |
23
+ | **cut_video** | `steps` | Run nested steps in browser but splice them out of the final video (ffmpeg). Optional `placeholder` (`title_card`). |
24
+ | **repeat_while_visible** | `locator`, `steps` | Loop nested steps while locator visible; optional `max_iterations` (default 100). |
25
+
26
+ ## Wait modes
27
+
28
+ | Mode | YAML | Use when |
29
+ |------|------|----------|
30
+ | Fixed delay | `wait` + `timeout_ms` only | Video pacing, brief pause |
31
+ | URL | `until: url` + `url_pattern` | SPA navigation finished |
32
+ | Until hidden | `until: hidden` + `locator` + `timeout_ms` | Poll until no matches |
33
+ | Hidden + refresh | above + `refresh_every_ms` (≥ 500) | SPA status that only updates on reload |
34
+
35
+ `url_pattern` supports `{{ variables }}`. If the string is slash-wrapped (`"/edit-doc/"`), the inner part is the RegExp source. Optional flags: `/pattern/gimsuy`. Uses `waitUntil: "commit"` for SPA client navigations.
36
+
37
+ ```yaml
38
+ - action: wait
39
+ timeout_ms: 2000
40
+
41
+ - action: wait
42
+ until: url
43
+ url_pattern: "/dashboard"
44
+
45
+ - action: wait
46
+ until: hidden
47
+ locator:
48
+ selector: '[aria-label="Document status: Processing"]'
49
+ timeout_ms: 180000
50
+ refresh_every_ms: 5000
51
+ ```
52
+
53
+ ## `settle_until` (click only)
54
+
55
+ Exactly one of:
56
+
57
+ - `settle_until: { locator: … }` — wait until that element is **visible**
58
+ - `settle_until: { text: "Exact visible string" }` — exact text (`getByText` exact); supports `{{ variables }}`
59
+
60
+ ```yaml
61
+ - action: click
62
+ locator: { role: button, name: Create }
63
+ settle_until:
64
+ locator: { label: Name }
65
+ ```
66
+
67
+ ## `select_confirm` (`fill` / `type` on `<select>`)
68
+
69
+ When `select_confirm: true` on a fill/type targeting a `<select>`:
70
+
71
+ 1. Wait until an `<option>` exists whose visible text or `value` equals the step `value`
72
+ 2. Select (label-first, then value)
73
+ 3. Verify selection applied
74
+
75
+ Use for dynamic dropdowns where options load asynchronously.
76
+
77
+ ## `drag`
78
+
79
+ ```yaml
80
+ - action: drag
81
+ locator:
82
+ selector: .splitpanes--vertical .splitpanes__splitter
83
+ offset_x: -180
84
+ - action: wait
85
+ timeout_ms: 400
86
+ ```
87
+
88
+ Negative `offset_x` drags left.
89
+
90
+ ## Screenshots
91
+
92
+ ```yaml
93
+ screenshots:
94
+ dir: "output/screenshots"
95
+ device_scale_factor: 2
96
+
97
+ steps:
98
+ - action: navigate
99
+ url: "/app"
100
+ - action: screenshot
101
+ caption: "Main list"
102
+ screenshot:
103
+ file: "list.png"
104
+ scale: device
105
+ - action: screenshot
106
+ locator: { role: heading, name: Settings }
107
+ screenshot:
108
+ file: "heading.png"
109
+ ```
110
+
111
+ ## `cut_video` and `video_exclude`
112
+
113
+ Run long waits in the browser but keep them out of the MP4:
114
+
115
+ ```yaml
116
+ - action: cut_video
117
+ placeholder:
118
+ action: title_card
119
+ text: "Indexing…"
120
+ hold_ms: 2000
121
+ steps:
122
+ - action: wait
123
+ timeout_ms: 2000
124
+ - action: wait
125
+ until: hidden
126
+ locator:
127
+ selector: '[aria-label="Status: Processing"]'
128
+ timeout_ms: 180000
129
+ refresh_every_ms: 5000
130
+ ```
131
+
132
+ Single-step exclude: set `video_exclude: true` on any step. Requires ffmpeg. See [Video and pacing](./video-and-pacing.md).
133
+
134
+ ## `repeat_while_visible`
135
+
136
+ ```yaml
137
+ - action: repeat_while_visible
138
+ locator: { role: button, name: /Delete/i }
139
+ max_iterations: 50
140
+ steps:
141
+ - action: click
142
+ locator: { role: button, name: /Delete/i }
143
+ - action: click
144
+ locator: { role: button, name: /Confirm/i }
145
+ ```
146
+
147
+ ## Pause (debug)
148
+
149
+ ```yaml
150
+ - action: pause
151
+ caption: "Inspect the page, then press Enter."
152
+ ```
153
+
154
+ Skipped in `--headless`. Prefer `wait` + `timeout_ms` for video pacing.
155
+
156
+ ## Related
157
+
158
+ - [Locators](./locators.md)
159
+ - [Scenario schema](./scenario-schema.md)
160
+ - [Video and pacing](./video-and-pacing.md)
package/docs/cli.md ADDED
@@ -0,0 +1,73 @@
1
+ # CLI
2
+
3
+ Purpose: Commands and flags for the `demo-maker` binary.
4
+
5
+ ```bash
6
+ demo-maker --help
7
+ demo-maker <command> …
8
+ ```
9
+
10
+ ## Commands
11
+
12
+ | Command | Purpose |
13
+ |---------|---------|
14
+ | `run <scenario.yaml>` | Execute a scenario (optional video) |
15
+ | `check <scenario.yaml>` | Same as `run --fail-fast --fast` (runtime smoke) |
16
+ | `record` | Live-record browser actions to YAML |
17
+ | `import <recording.json> -o <out.yaml>` | Convert recorder / DevTools JSON → YAML |
18
+ | `export-chapters <timing.json\|dir>` | Emit YouTube chapter lines |
19
+
20
+ Back-compat: if the first argument ends in `.yaml` / `.yml`, it is treated as `run`.
21
+
22
+ ## `run` / `check` flags
23
+
24
+ | Flag | Purpose |
25
+ |------|---------|
26
+ | `--env-file=PATH` | Load `KEY=value` for auth and `{{ VAR }}`; `BASE_URL` overrides scenario `base_url` |
27
+ | `--base-url=URL` | Override `base_url` (wins over env `BASE_URL`) |
28
+ | `--headless` | No browser window |
29
+ | `--fast` | Zero/minimal pacing delays |
30
+ | `--fail-fast` | Stop on first step failure |
31
+ | `--end-step=N` | Run only steps 1..N (1-based inclusive) |
32
+ | `--pause-at-end` | Headed: wait for Enter before closing browser |
33
+ | `--debug-dir=PATH` | Save PNG on step failure |
34
+ | `--storage-state=PATH` | Load Playwright storage state (cookies/localStorage) |
35
+ | `--save-storage-state=PATH` | Save storage state after the run |
36
+ | `--capture-from-url VAR=regex` | Capture first regex group from page URLs into `{{ VAR }}` (repeatable) |
37
+ | `--url-capture-file=PATH` | JSON array of `{ variable, pattern }` rules (see [URL capture](./url-capture.md)) |
38
+
39
+ Examples:
40
+
41
+ ```bash
42
+ npx demo-maker run scenarios/demo.yaml --env-file scenarios/u2.env --fast
43
+ demo-maker check scenarios/demo.yaml --env-file scenarios/u2.env --storage-state=scenarios/session.json
44
+ npx demo-maker run scenarios/demo.yaml --end-step=7 --pause-at-end --env-file scenarios/u2.env
45
+ ```
46
+
47
+ ## `record` flags (summary)
48
+
49
+ | Flag | Purpose |
50
+ |------|---------|
51
+ | `--save-to=PATH` | Output YAML path |
52
+ | `--save-json=PATH` | Also write raw recording JSON |
53
+ | `--url=URL` / `--base-url=URL` | Start URL / base |
54
+ | `--continue-from=PATH` | Replay YAML then record additional steps |
55
+ | `--from=PATH` | Import from JSON instead of live record |
56
+ | `--fast` | Fast replay when using `--continue-from` |
57
+ | `--env-file=PATH` | Env for replay auth / variables |
58
+ | `--end-step=N` | With continue-from: replay only 1..N |
59
+
60
+ See [Recording](./recording.md).
61
+
62
+ ## `export-chapters`
63
+
64
+ ```bash
65
+ demo-maker export-chapters path/to/video.timing.json
66
+ demo-maker export-chapters output/videos # newest *.timing.json in dir
67
+ ```
68
+
69
+ ## Requirements
70
+
71
+ - Node 20+
72
+ - Playwright Chromium (`npx playwright install chromium`)
73
+ - ffmpeg on `PATH` for `.mp4`, `cut_video` splice, background audio