@clipy/cli 0.5.0 → 0.8.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.
Files changed (4) hide show
  1. package/README.md +209 -10
  2. package/dist/index.js +1163 -64
  3. package/dist/skill.js +141 -0
  4. package/package.json +4 -2
package/dist/skill.js CHANGED
@@ -15,6 +15,9 @@ description: Read and create Clipy screen recordings. Use when the user shares a
15
15
 
16
16
  # Clipy — recordings you can read AND make
17
17
 
18
+ Written for @clipy/cli + @clipy/mcp 0.8.1 (the two versions move in lockstep). If
19
+ \`clipy --version\` reports older, upgrade first: \`npm i -g @clipy/cli@latest\`.
20
+
18
21
  Clipy (clipy.online) is the screen recorder built to be agent-readable. Every
19
22
  recording has a share link, an AI transcript + summary, key moments, and a
20
23
  machine-readable context document. With the CLI you can also CREATE recordings:
@@ -78,6 +81,48 @@ Notes are absolute (\`"12: text"\`) or pass-scoped (\`"pass2: text"\`,
78
81
  \`"pass2@5: text"\`). Pass-scoped notes anchor to a --viewports pass's REAL start,
79
82
  so they stay aligned when load time shifts the pass boundaries.
80
83
 
84
+ ## Recording a logged-in app (headless web capture)
85
+
86
+ The headless browser starts signed out. To record a page behind auth, seed the
87
+ session BEFORE the first navigation — otherwise the app's route guard runs before
88
+ your credentials exist and redirects to /login (seeding localStorage AFTER visiting
89
+ a guarded route loses that race). \`--storage-state\` and \`--init-script\` apply
90
+ BEFORE any page script structurally, which is what avoids the trap. All four flags
91
+ work on both \`record\` and \`session start\` (web only; rejected on --source mac-screen):
92
+
93
+ # reuse a saved Playwright login (cookies + per-origin localStorage)
94
+ clipy record --url https://app.example.com/dashboard --for 20 --storage-state ./auth.json
95
+
96
+ # or seed a token / cookie directly
97
+ clipy session start --url https://app.example.com/dashboard \\
98
+ --local-storage "authToken=eyJ…" --cookie "sid=abc; Domain=app.example.com; Secure"
99
+
100
+ - \`--storage-state <file>\` — a Playwright storageState JSON (log in once, save
101
+ \`context.storageState({ path })\`); passed straight to newContext. Never printed.
102
+ - \`--cookie "name=value[; Domain=d; Path=p; Secure; HttpOnly; SameSite=Lax]"\` —
103
+ repeatable; without a Domain it's url-scoped to the target.
104
+ - \`--local-storage "key=value"\` — repeatable; origin-guarded to the target.
105
+ - \`--init-script <file>\` — a JS file run before every page's own scripts.
106
+ - \`--user-data-dir <dir>\` — launch a PERSISTENT Chromium profile from \`dir\`
107
+ (its whole logged-in identity, not just injected storage). Web only; mutually
108
+ exclusive with --storage-state; --cookie/--local-storage/--init-script still
109
+ compose. Point it at a COPY or a dedicated profile — never your live Chrome's
110
+ default profile (Chrome locks it; Clipy refuses a dir with a SingletonLock).
111
+
112
+ ### The auth boundary (read this if a login won't stick)
113
+
114
+ \`--storage-state\` seeds ONLY the cookies + localStorage the file CONTAINS — it
115
+ cannot conjure a whole browser identity, so an app that also needs cross-origin
116
+ or auth-host cookies (SSO, a separate API domain) can still bounce to /login.
117
+ Three reliable ways to record a real logged-in app:
118
+ 1. Produce the state file with a REAL interactive login (it captures cross-domain
119
+ cookies): \`npx playwright open --save-storage=auth.json https://<login-host>\`,
120
+ sign in, close — then \`--storage-state auth.json\`.
121
+ 2. \`--user-data-dir <dedicated-profile>\` — a persistent profile you logged into
122
+ once (copy it out of your real Chrome, or make a throwaway profile).
123
+ 3. \`--source mac-screen --window "Chrome"\` — record your REAL logged-in Chrome
124
+ window (Mac app), no headless auth to reproduce at all.
125
+
81
126
  ## Session mode — you drive the app, Clipy records
82
127
 
83
128
  clipy session start --url http://localhost:3000 --title "Overflow fix"
@@ -104,6 +149,102 @@ Headless captures are silent, so your notes/marks BECOME the transcript (honestl
104
149
  labeled as agent narration, never passed off as speech). Narrate every meaningful
105
150
  step.
106
151
 
152
+ ### Assert what you claim (assertion marks)
153
+
154
+ A plain mark is an unverified claim — you can write \`clipy mark "the Redemptions
155
+ tab is active"\` whether it's true or not, and the transcript reads as fact either
156
+ way. Make marks EVIDENCE by attaching an assertion the recording daemon checks
157
+ against its live page:
158
+
159
+ clipy mark "opened redemptions" --assert-url "**/redemptions"
160
+ clipy mark "status is Active" --assert-selector ".status-badge" --assert-text "Active"
161
+
162
+ - \`--assert-selector <css>\` — the element must match (its trimmed text is recorded
163
+ as the observed value).
164
+ - \`--assert-text <substr>\` — that element's text must contain the substring (needs
165
+ --assert-selector).
166
+ - \`--assert-url <glob>\` — the page URL must match (\`**\` = anything, \`*\` = any
167
+ non-slash segment, no \`*\` = substring). Combine freely; all checks must pass.
168
+
169
+ A pass annotates the mark \`… [assert ✓ <observed>]\`; a fail annotates it
170
+ \`… [ASSERT ✗ expected …; observed …]\` — a wrong claim is preserved AS a failed
171
+ assertion, it can never read as fact. \`--fail-mode warn\` (default) records the ✗
172
+ and keeps going; \`--fail-mode abort\` DISCARDS the whole session (nothing uploaded,
173
+ non-zero exit) so you never ship a clip that asserted its way into a broken state.
174
+ If any assertion was attempted, a leading \`[verification] N assertion(s): P passed,
175
+ F failed[, K unverified]\` note opens the transcript.
176
+
177
+ A mark is NEVER dropped: if the recording daemon can't be reached to evaluate an
178
+ assertion (e.g. its event loop is briefly starved during a dev-server recompile),
179
+ \`clipy mark\` still records the narration, tags it \`[ASSERT ⚠ could not evaluate —
180
+ <reason>]\`, prints a loud ⚠, and exits 0 — an unverified claim is flagged as
181
+ unverified (the K bucket), never passed off as a ✓. Assertions need a WEB session
182
+ (rejected on --source mac-screen — there's no page to probe). Prefer asserting the
183
+ specific claims a reviewer cares about over narrating them unverified.
184
+
185
+ ### Before/after in one recording (clipy chapter)
186
+
187
+ \`clipy chapter "<label>"\` marks a section boundary, so one video carries a BEFORE
188
+ and an AFTER — the PR-review shape:
189
+
190
+ clipy session start --url http://localhost:3000/settings --title "Overflow fix"
191
+ clipy mark "sidebar overflows" --assert-selector ".sidebar.is-overflowing"
192
+ clipy chapter "AFTER — fix applied"
193
+ # (git switch fix-branch, restart the dev server, reload)
194
+ clipy mark "sidebar wraps" --assert-selector ".sidebar:not(.is-overflowing)"
195
+ clipy session stop
196
+
197
+ ### Crash-safe wrapping (clipy session run)
198
+
199
+ If your driver script crashes, a plain \`session start\` keeps recording dead air to
200
+ \`--max\` and uploads it. \`session run\` guarantees cleanup:
201
+
202
+ clipy session run --url http://localhost:3000 --expose-cdp -- node driver.js
203
+
204
+ It starts the session, runs everything after \`--\` with inherited stdio, then: exit
205
+ 0 → \`session stop\` (upload); any non-zero exit or signal → \`session abort\` (discard)
206
+ with the child's exit code propagated. The command runs with \`CLIPY_SESSION=1\`,
207
+ \`CLIPY_SESSION_FILE=<path>\`, and (when --expose-cdp) \`CLIPY_CDP_URL=<cdpHttpUrl>\`.
208
+ All session-start flags apply before the \`--\`.
209
+
210
+ \`clipy mark\`/\`chapter\` find the session from \`CLIPY_SESSION_FILE\` first, then the
211
+ current directory — so a driver you \`session run\` can shell out \`clipy mark\` from
212
+ ANY cwd and still hit the right session (no "no recording session" surprise).
213
+
214
+ ### Mark timing (backdating + in-page marks)
215
+
216
+ Each \`clipy mark\` is a process spawn (~100-300ms), so a mark can land slightly after
217
+ the state it describes. Backdate onto the recording clock:
218
+
219
+ clipy mark "toast appeared" --ago 2 # 2s before now
220
+ clipy mark "page loaded" --at 4 # absolute 4s on the recording clock
221
+
222
+ When you drive over --expose-cdp, emit marks IN-PAGE with zero spawn latency by
223
+ calling the bindings the daemon exposes (they run daemon-side with the page in
224
+ hand — no \`clipy mark\` process, no shell-out latency):
225
+
226
+ await page.evaluate(() => window.__clipyMark("clicked Export"));
227
+ await page.evaluate(() => window.__clipyChapter("AFTER — fix applied"));
228
+
229
+ \`__clipyMark\` takes the SAME assertions as the CLI, via a second options arg —
230
+ evaluated daemon-side, annotated ✓/✗ identically:
231
+
232
+ await page.evaluate(() =>
233
+ window.__clipyMark("status is Active", {
234
+ assertSelector: ".status-badge", assertText: "Active", // assertText needs assertSelector
235
+ assertUrl: "**/redemptions", // optional
236
+ failMode: "abort", // optional; "warn" default
237
+ }),
238
+ );
239
+
240
+ It returns the annotated result (\`{ tMs, text, assert }\`); \`assertText\` without
241
+ \`assertSelector\` REJECTS so your driver sees the misuse, and \`failMode: "abort"\`
242
+ discards the session just like the CLI flag.
243
+
244
+ (While CDP is exposed the page's own scripts can call these too — same trust model as
245
+ --expose-cdp itself.) \`clipy playwright-path\` prints the node_modules dir to resolve
246
+ Playwright for your driver: \`NODE_PATH=$(clipy playwright-path) node driver.js\`.
247
+
107
248
  ## Record the real Mac screen — a window or a display
108
249
 
109
250
  Add \`--source mac-screen\` to \`record\` or \`session start\` to capture the REAL
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipy/cli",
3
- "version": "0.5.0",
3
+ "version": "0.8.1",
4
4
  "description": "Command-line interface for Clipy — list, search, and read your screen recordings' transcripts, AI summaries, and key moments from the terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,7 +38,9 @@
38
38
  "build": "tsc",
39
39
  "prepublishOnly": "npm run build",
40
40
  "start": "node dist/index.js",
41
- "test:auth": "npm run build && node scripts/mock-auth-server.test.mjs && node scripts/doctor.test.mjs"
41
+ "test:auth": "npm run build && node scripts/mock-auth-server.test.mjs && node scripts/doctor.test.mjs",
42
+ "test:session": "npm run build && node scripts/auth-guard.test.mjs && node scripts/session-control.test.mjs",
43
+ "test": "npm run test:auth && npm run test:session"
42
44
  },
43
45
  "devDependencies": {
44
46
  "@types/node": "^22.0.0",