@clipy/cli 0.5.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -10
- package/dist/index.js +964 -40
- package/dist/skill.js +96 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
# @clipy/cli
|
|
2
2
|
|
|
3
|
-
> This repository is the public mirror of **`@clipy/cli`**. The package is developed in
|
|
4
|
-
> the Clipy monorepo and synced here with each npm release — browse the source or file
|
|
5
|
-
> issues here.
|
|
6
|
-
|
|
7
3
|
[](https://www.npmjs.com/package/@clipy/cli)
|
|
8
4
|
[](https://github.com/manovagyanik1/clipy-cli/blob/main/LICENSE)
|
|
9
5
|
[](https://www.npmjs.com/package/@clipy/cli)
|
|
@@ -73,8 +69,12 @@ clipy wait <id> --for both # block until transcript/summary are ready
|
|
|
73
69
|
clipy record --url <app> [--for 15] # record a web app headlessly → a Clipy recording
|
|
74
70
|
clipy session start --url <app> # start recording in the background while you work
|
|
75
71
|
clipy mark "reproduced the bug" # drop a live-timestamped note into the session
|
|
72
|
+
clipy mark "on redemptions" --assert-url '**/redemptions' # assert what you claim
|
|
73
|
+
clipy chapter "AFTER — fix applied" # split the recording into before/after sections
|
|
74
|
+
clipy session run --url <app> -- npm run demo # start, run a command, auto stop/abort
|
|
76
75
|
clipy session stop # finish + upload; your marks become the transcript
|
|
77
76
|
clipy doctor # health check: key, Mac bridge, Playwright, install mode
|
|
77
|
+
clipy playwright-path # node_modules dir of the Playwright this CLI resolves
|
|
78
78
|
clipy mcp # run the Clipy MCP server (npx -y @clipy/mcp)
|
|
79
79
|
```
|
|
80
80
|
|
|
@@ -126,6 +126,37 @@ still-compiling dev server's blank screen.
|
|
|
126
126
|
notes (and session marks, below) as the recording's transcript, summary input, and
|
|
127
127
|
agent-context — clearly marked as agent narration, never passed off as speech-to-text.
|
|
128
128
|
|
|
129
|
+
### Recording a logged-in app
|
|
130
|
+
|
|
131
|
+
To record an authenticated SPA, seed the session **before** the browser navigates —
|
|
132
|
+
Clipy applies all of these to the Playwright context ahead of the first page load, so the
|
|
133
|
+
app's route guard sees the auth state on first paint (seeding `localStorage` *after*
|
|
134
|
+
visiting a guarded route loses that race and bounces you to `/login`). These flags apply
|
|
135
|
+
to headless web capture on `record` and `session start`; they're rejected on
|
|
136
|
+
`--source mac-screen` (which records the real, already-logged-in screen).
|
|
137
|
+
|
|
138
|
+
- `--storage-state <file>` — a Playwright [`storageState`](https://playwright.dev/docs/auth)
|
|
139
|
+
JSON (cookies + per-origin `localStorage`), passed straight to `browser.newContext()`.
|
|
140
|
+
The easiest path: log in once with Playwright and save `context.storageState({ path })`,
|
|
141
|
+
then hand that file to Clipy. Its contents are never printed or logged.
|
|
142
|
+
- `--cookie "name=value[; Domain=d; Path=p; Secure; HttpOnly; SameSite=Lax]"` — set one
|
|
143
|
+
cookie (repeatable). Without a `Domain` it's scoped to the target URL; with one it's
|
|
144
|
+
domain-scoped.
|
|
145
|
+
- `--local-storage "key=value"` — set one `localStorage` pair for the target origin
|
|
146
|
+
(repeatable).
|
|
147
|
+
- `--init-script <file>` — run a JS file in every page before its own scripts (e.g. to
|
|
148
|
+
stub a feature flag or inject a token).
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Reuse a saved Playwright login
|
|
152
|
+
clipy record --url https://app.example.com/dashboard --for 20 \
|
|
153
|
+
--storage-state ./auth.json
|
|
154
|
+
|
|
155
|
+
# Or seed a token directly
|
|
156
|
+
clipy record --url https://app.example.com/dashboard \
|
|
157
|
+
--local-storage "authToken=eyJ…" --cookie "sid=abc; Domain=app.example.com; Secure"
|
|
158
|
+
```
|
|
159
|
+
|
|
129
160
|
## Session mode — you work, Clipy records
|
|
130
161
|
|
|
131
162
|
For recordings where an agent (or you) drives the app live, don't script the capture:
|
|
@@ -159,19 +190,120 @@ clipy session start --url http://localhost:3000 --expose-cdp --title "Overflow f
|
|
|
159
190
|
```js
|
|
160
191
|
const { chromium } = require("playwright");
|
|
161
192
|
const browser = await chromium.connectOverCDP(cdpHttpUrl); // from `clipy session status --json`
|
|
162
|
-
const page = browser.contexts()[0].pages()[0]; // the page being recorded
|
|
163
|
-
await page.goto("http://localhost:3000/settings");
|
|
193
|
+
const page = browser.contexts()[0].pages()[0]; // the page being recorded (a NEW context is not captured)
|
|
194
|
+
await page.goto("http://localhost:3000/settings"); // navigate / click / fill as usual
|
|
195
|
+
|
|
196
|
+
// page.viewportSize() is null over a CDP attach — resize via the device-metrics override:
|
|
197
|
+
const cdp = await browser.newCDPSession(page);
|
|
198
|
+
await cdp.send("Emulation.setDeviceMetricsOverride", { width: 1280, height: 720, deviceScaleFactor: 1, mobile: false });
|
|
199
|
+
|
|
164
200
|
await browser.close(); // detaches; the recording keeps going
|
|
165
201
|
```
|
|
166
202
|
|
|
167
|
-
|
|
168
|
-
context you open
|
|
203
|
+
Four things that otherwise cost a debugging round: attach with `connectOverCDP`; the
|
|
204
|
+
recorded page is `browser.contexts()[0].pages()[0]` (a brand-new context/page you open
|
|
205
|
+
won't be captured); `page.viewportSize()` is `null` on a CDP attach; and a resize needs a
|
|
206
|
+
CDP `Emulation.setDeviceMetricsOverride`, not `setViewportSize`. Your driver script
|
|
207
|
+
resolves Playwright from **its own** directory — if `require("playwright")` can't find it,
|
|
208
|
+
run the script with `NODE_PATH=$(clipy playwright-path) node driver.js`.
|
|
209
|
+
|
|
210
|
+
**In-page marks (zero spawn latency).** While `--expose-cdp` is on, the daemon also exposes
|
|
211
|
+
`window.__clipyMark("text")` and `window.__clipyChapter("label")` in the recorded page.
|
|
212
|
+
Calling them from your driver (`page.evaluate(() => window.__clipyMark("clicked Export"))`)
|
|
213
|
+
emits a mark or chapter *without* spawning a `clipy mark` process, so it lands exactly when
|
|
214
|
+
your code runs. These marks land in the same transcript and count toward the same 200-mark
|
|
215
|
+
cap. Note: while CDP is exposed the page's **own** scripts can call these too — that's the
|
|
216
|
+
same trust boundary as `--expose-cdp` itself (any local process can already drive the
|
|
217
|
+
browser), so only enable it when you intend to drive the session.
|
|
218
|
+
|
|
219
|
+
`session start` also accepts the same auth flags as `record`
|
|
220
|
+
(`--storage-state` / `--cookie` / `--local-storage` / `--init-script`) to record a
|
|
221
|
+
logged-in app; see [Recording a logged-in app](#recording-a-logged-in-app).
|
|
169
222
|
|
|
170
223
|
Safety rails are built in: the session **auto-stops and uploads** at `--max <sec>`
|
|
171
224
|
(default 600, hard cap 1800) so a forgotten session can never run away; `clipy session
|
|
172
225
|
abort` discards everything; a crashed daemon is detected and cleared on the next command;
|
|
173
226
|
corrupt captures are refused before upload, and a failed upload keeps the local file.
|
|
174
227
|
|
|
228
|
+
### Assertion marks — recordings as evidence
|
|
229
|
+
|
|
230
|
+
A plain mark is an unverified claim: an agent can write `clipy mark "the Redemptions
|
|
231
|
+
tab is active"` whether or not it is, and the transcript reads as authoritative either
|
|
232
|
+
way. Assertion marks fix that. The recording daemon owns the live Playwright page, so it
|
|
233
|
+
can **check the claim against the real DOM** and annotate the mark with what it actually
|
|
234
|
+
observed — a false claim can't pass as fact.
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Assert a URL (globs: ** = anything, * = any non-slash segment, no * = substring)
|
|
238
|
+
clipy mark "opened the redemptions tab" --assert-url "**/redemptions"
|
|
239
|
+
|
|
240
|
+
# Assert an element exists and contains text
|
|
241
|
+
clipy mark "status flipped to Active" --assert-selector ".status-badge" --assert-text "Active"
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
- **Pass** → the mark is stored as `status flipped to Active [assert ✓ .status-badge="Active"]`
|
|
245
|
+
and the CLI prints a green `✓`.
|
|
246
|
+
- **Fail** → it's stored as
|
|
247
|
+
`status flipped to Active [ASSERT ✗ expected "Active"; observed .status-badge="Pending"]`
|
|
248
|
+
and the CLI prints a red `✗`. The wrong claim is preserved *as a failed assertion*, not
|
|
249
|
+
as a fact.
|
|
250
|
+
|
|
251
|
+
`--assert-selector <css>` checks an element matches (its trimmed text becomes the
|
|
252
|
+
`observed` value); `--assert-text <substr>` requires that element's text to contain a
|
|
253
|
+
substring (it needs a selector); `--assert-url <glob>` matches the page URL. Combine them
|
|
254
|
+
freely — all provided checks must pass.
|
|
255
|
+
|
|
256
|
+
`--fail-mode` decides what a failed assertion does: `warn` (default) records the `✗` and
|
|
257
|
+
keeps recording; **`abort` discards the whole session** — nothing is uploaded and the CLI
|
|
258
|
+
exits non-zero, so a driver that asserts its way to a broken state doesn't ship a misleading
|
|
259
|
+
clip. If any assertions ran, a leading `[verification] N assertion(s): P passed, F failed`
|
|
260
|
+
note is prepended at 0 ms, so the transcript and the `.md` context open with the scorecard.
|
|
261
|
+
|
|
262
|
+
Assertions evaluate against a real page, so they need a **web** session (they're rejected on
|
|
263
|
+
`--source mac-screen`, which records the real screen with no page to probe).
|
|
264
|
+
|
|
265
|
+
### Before/after in one recording — `clipy chapter`
|
|
266
|
+
|
|
267
|
+
`clipy chapter "<label>"` drops a section boundary so a single video can carry both a
|
|
268
|
+
BEFORE and an AFTER state — exactly the shape of a PR-review recording:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
clipy session start --url http://localhost:3000/settings --title "Sidebar overflow fix"
|
|
272
|
+
# … demo the bug on the base branch …
|
|
273
|
+
clipy mark "sidebar overflows on mobile" --assert-selector ".sidebar.is-overflowing"
|
|
274
|
+
clipy chapter "AFTER — fix applied"
|
|
275
|
+
# … git switch fix-branch, restart the dev server, reload …
|
|
276
|
+
clipy mark "sidebar wraps correctly" --assert-selector ".sidebar:not(.is-overflowing)"
|
|
277
|
+
clipy session stop
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### `session run` — crash-safe wrapping
|
|
281
|
+
|
|
282
|
+
If a driver script crashes mid-session, a plain `session start` keeps recording dead air
|
|
283
|
+
up to `--max` and then uploads it. `session run` wraps a command so cleanup is guaranteed:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
clipy session run --url http://localhost:3000 --expose-cdp -- node driver.js
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
It starts the session, runs everything after `--` with inherited stdio, and then: **exit 0
|
|
290
|
+
→ `session stop`** (upload + share link); **any non-zero exit or a signal → `session abort`**
|
|
291
|
+
(discard) and the child's exit code is propagated. The command runs with `CLIPY_SESSION=1`
|
|
292
|
+
in its environment (and `CLIPY_CDP_URL=<cdpHttpUrl>` when `--expose-cdp` is set, so the
|
|
293
|
+
driver knows where to attach). `Ctrl-C` is forwarded to the child, then the session is
|
|
294
|
+
discarded. All the `session start` flags (`--url`, `--title`, `--max`, `--type`,
|
|
295
|
+
`--expose-cdp`, auth flags) apply before the `--`.
|
|
296
|
+
|
|
297
|
+
### Backdating a mark
|
|
298
|
+
|
|
299
|
+
Each `clipy mark` is a short process spawn (~100–300 ms), so a mark can land slightly after
|
|
300
|
+
the state it describes. Backdate it onto the recording clock:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
clipy mark "the toast appeared" --ago 2 # 2 seconds before now
|
|
304
|
+
clipy mark "page finished loading" --at 4 # at an absolute 4s on the recording clock
|
|
305
|
+
```
|
|
306
|
+
|
|
175
307
|
## Record the real screen — a window, a display (Mac)
|
|
176
308
|
|
|
177
309
|
`--source mac-screen` on `record` / `session start` records through the **running Clipy
|
|
@@ -196,8 +328,12 @@ clipy session stop # uploads, prints the share link
|
|
|
196
328
|
|
|
197
329
|
## Scripting
|
|
198
330
|
|
|
199
|
-
`--json`
|
|
200
|
-
`summary`, `moments`,
|
|
331
|
+
Every command has machine-readable output. `--json` is supported on **`list`, `search`,
|
|
332
|
+
`show`, `transcript`, `summary`, `moments`, `wait`, `record`, `session start/stop/status`,
|
|
333
|
+
`mark`, `chapter`, `doctor`, and `playwright-path`** — stdout is the JSON payload, stderr is progress
|
|
334
|
+
and hints, and errors exit non-zero with a message on stderr prefixed `error:`. For the
|
|
335
|
+
full capability manifest (every command, flag, env var, and exit code) run
|
|
336
|
+
`clipy guide --json`.
|
|
201
337
|
|
|
202
338
|
```bash
|
|
203
339
|
# Newest recording's id
|
|
@@ -206,6 +342,9 @@ clipy list -n 1 --json | jq -r '.recordings[0].id'
|
|
|
206
342
|
# Export subtitles for a recording
|
|
207
343
|
clipy transcript 3kelcef8wo8h --srt > recording.srt
|
|
208
344
|
|
|
345
|
+
# Record headlessly and capture the share link
|
|
346
|
+
clipy record --url http://localhost:3000 --for 20 --json | jq -r '.shareUrl'
|
|
347
|
+
|
|
209
348
|
# Record with anything, then block until Clipy finished transcribing
|
|
210
349
|
clipy wait 3kelcef8wo8h --for both && clipy summary 3kelcef8wo8h
|
|
211
350
|
```
|