gipity 1.1.16 → 1.1.20
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 +58 -75
- package/dist/adopt-cwd.js +2 -13
- package/dist/api.js +27 -45
- package/dist/auth.js +1 -1
- package/dist/banner.js +3 -7
- package/dist/catalog.js +8 -7
- package/dist/commands/add.js +26 -9
- package/dist/commands/approval.js +1 -1
- package/dist/commands/ask.js +112 -0
- package/dist/commands/bug.js +5 -5
- package/dist/commands/build.js +10 -35
- package/dist/commands/credits.js +3 -3
- package/dist/commands/doctor.js +7 -8
- package/dist/commands/email.js +6 -56
- package/dist/commands/generate.js +12 -12
- package/dist/commands/init.js +40 -30
- package/dist/commands/key.js +1 -1
- package/dist/commands/load.js +2 -12
- package/dist/commands/logs.js +2 -2
- package/dist/commands/memory.js +5 -17
- package/dist/commands/notify.js +1 -1
- package/dist/commands/page-eval.js +55 -38
- package/dist/commands/page-inspect.js +6 -6
- package/dist/commands/page-screenshot.js +51 -54
- package/dist/commands/page-test.js +188 -14
- package/dist/commands/payments.js +2 -2
- package/dist/commands/project.js +66 -15
- package/dist/commands/realtime.js +96 -4
- package/dist/commands/records.js +4 -6
- package/dist/commands/sandbox.js +2 -3
- package/dist/commands/skill.js +50 -22
- package/dist/commands/status.js +7 -9
- package/dist/commands/test.js +2 -2
- package/dist/commands/token.js +4 -4
- package/dist/commands/workflow.js +45 -8
- package/dist/config.js +22 -6
- package/dist/flag-aliases.js +75 -18
- package/dist/help-skills.js +2 -2
- package/dist/hooks/capture-runner.js +5 -3
- package/dist/index.js +1631 -1517
- package/dist/knowledge.js +24 -21
- package/dist/login-flow.js +4 -4
- package/dist/net.js +91 -0
- package/dist/opencode-setup.js +2 -2
- package/dist/page-fixtures.js +3 -3
- package/dist/project-setup.js +2 -3
- package/dist/prompts.js +1 -1
- package/dist/provider-docs.js +22 -25
- package/dist/realtime-bench.js +12040 -0
- package/dist/relay/agent-token.js +1 -1
- package/dist/relay/daemon.js +0 -1
- package/dist/relay/setup.js +13 -2
- package/dist/setup.js +11 -12
- package/dist/sync.js +3 -3
- package/dist/utils.js +1 -1
- package/package.json +10 -4
- package/dist/commands/agent.js +0 -251
- package/dist/commands/chat.js +0 -137
- package/dist/commands/claude.js +0 -1056
- package/dist/commands/plan.js +0 -93
|
@@ -43,7 +43,7 @@ export const pageInspectCommand = new Command('inspect')
|
|
|
43
43
|
.option('--all', 'Include render-blocking, large resources, oversized images, overflow culprits, and LCP detail')
|
|
44
44
|
.option('--no-fake-media', "Inspect with NO camera or microphone present, so a getUserMedia app takes its no-device error path (use this only when that fallback IS what you're inspecting)")
|
|
45
45
|
.option('--device <name>', `Inspect as a real touch device: ${INSPECT_DEVICES.join(', ')}. Emulates touch events, mobile user-agent and DPR, so a touch-gated mobile layout is what gets inspected.`)
|
|
46
|
-
.option('--auth', 'Load the page signed in as you (your Gipity account), so pages behind a Sign-in-with-Gipity login are reachable. Only works for apps using Sign in with Gipity, hosted on *.gipity.ai. Without this flag the page loads as a genuinely anonymous, signed-out visitor
|
|
46
|
+
.option('--auth', 'Load the page signed in as you (your Gipity account), so pages behind a Sign-in-with-Gipity login are reachable. Only works for apps using Sign in with Gipity, hosted on *.gipity.ai. Without this flag the page loads as a genuinely anonymous, signed-out visitor: nothing carries over from earlier --auth runs.')
|
|
47
47
|
// Hidden redirect: agents reach for `page inspect --screenshot`. We don't take
|
|
48
48
|
// an image here (`page screenshot` is the single path for that) — just point there.
|
|
49
49
|
.addOption(new Option('--screenshot [path]', 'Capture a screenshot').hideHelp())
|
|
@@ -94,7 +94,7 @@ export async function inspectPage(url, opts = {}) {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
console.log(`${brand('Inspecting')} ${bold(url)}`);
|
|
97
|
-
console.log(warning('Captured no page data
|
|
97
|
+
console.log(warning('Captured no page data: the page returned an empty response.'));
|
|
98
98
|
console.log(muted('The page may have failed to load, redirected away, or rendered nothing server-side. Retry once; if it persists pass --wait-for <selector> to wait for a specific element to appear, or --auth if it is behind Sign in with Gipity.'));
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
@@ -188,7 +188,7 @@ export async function inspectPage(url, opts = {}) {
|
|
|
188
188
|
const who = getAuth()?.email;
|
|
189
189
|
console.log(b.auth.established
|
|
190
190
|
? `${muted('Auth:')} ${success('session established')}${who ? muted(` as ${who}`) : ''} ${muted('(what the page renders with it is app-defined)')}`
|
|
191
|
-
: `${warning('Auth: session NOT established')}${b.auth.detail ?
|
|
191
|
+
: `${warning('Auth: session NOT established')}${b.auth.detail ? `: ${b.auth.detail}` : ''} ${muted('(this is the anonymous view)')}`);
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
194
194
|
console.log(muted('Auth: anonymous visitor (signed out; pass --auth to load as your Gipity account)'));
|
|
@@ -202,7 +202,7 @@ export async function inspectPage(url, opts = {}) {
|
|
|
202
202
|
// real story is "client render or auth gate produced nothing yet." Flag it
|
|
203
203
|
// so the agent knows to wait for the render or sign in, not to trust silence.
|
|
204
204
|
if ((b.elementCount || 0) === 0 && !b.title) {
|
|
205
|
-
console.log(`${warning('⚠ Rendered no DOM (0 elements, no title)')} ${muted('
|
|
205
|
+
console.log(`${warning('⚠ Rendered no DOM (0 elements, no title)')} ${muted('The client-side render likely had not run yet (try --wait-for <selector>), the page failed to load, or it is behind a sign-in gate (try --auth).')}`);
|
|
206
206
|
}
|
|
207
207
|
// ── Timing ──
|
|
208
208
|
console.log(`\n${bold('Timing:')}`);
|
|
@@ -228,12 +228,12 @@ export async function inspectPage(url, opts = {}) {
|
|
|
228
228
|
for (const line of transientErrors) {
|
|
229
229
|
console.log(muted(line));
|
|
230
230
|
}
|
|
231
|
-
console.log(muted('One-time cold-load artifact (first hit of freshly-deployed assets)
|
|
231
|
+
console.log(muted('One-time cold-load artifact (first hit of freshly-deployed assets): not reproducible, not in your app code. Ignore unless it recurs.'));
|
|
232
232
|
}
|
|
233
233
|
// ── Cross-origin console errors (message-less; source hidden by the browser) ──
|
|
234
234
|
if (crossOriginErrors.length > 0) {
|
|
235
235
|
console.log(`\n${bold('Cross-origin console errors')} ${muted(`(${crossOriginErrors.length}, source hidden by the browser)`)}:`);
|
|
236
|
-
console.log(muted("Message-less
|
|
236
|
+
console.log(muted("Message-less: the throwing <script> lacks CORS, so the browser hides its source and there's no own-code stack to chase. Gipity's injected SDK is itself cross-origin, so if your app loads no third-party CDN scripts these are platform noise; ignore them. If your app DOES load a third-party <script>, add crossorigin=\"anonymous\" to that tag to surface the real error."));
|
|
237
237
|
}
|
|
238
238
|
// ── Failed Resources ──
|
|
239
239
|
// Browsers auto-request /favicon.ico at the site root for every page, so a
|
|
@@ -43,7 +43,7 @@ function printAuthLine(auth) {
|
|
|
43
43
|
const who = getAuth()?.email;
|
|
44
44
|
console.log(auth.established
|
|
45
45
|
? `${label('Auth')} ${success('session established')}${who ? muted(` as ${who}`) : ''} ${muted('(what the page renders with it is app-defined)')}`
|
|
46
|
-
: `${warning('Auth: session NOT established')}${auth.detail ?
|
|
46
|
+
: `${warning('Auth: session NOT established')}${auth.detail ? `: ${auth.detail}` : ''} ${muted('(this is the anonymous view)')}`);
|
|
47
47
|
}
|
|
48
48
|
/** A failed pre-capture script still yields a screenshot - of the page it never
|
|
49
49
|
* touched. Silence there is the trap: the image looks plausible and the command
|
|
@@ -70,7 +70,7 @@ export function augmentSandboxTimeout(message) {
|
|
|
70
70
|
return message;
|
|
71
71
|
return (`${message}\n` +
|
|
72
72
|
`A pre-capture script was set (--action and/or the --wait-for gate), and its runtime is spent INSIDE ` +
|
|
73
|
-
`that same sandbox budget
|
|
73
|
+
`that same sandbox budget: a script that waits on slow work (a WASM/model download, a network fetch, ` +
|
|
74
74
|
`a long animation) can exhaust the budget on its own. Keep --action to the interaction itself (a click, ` +
|
|
75
75
|
`a keypress), let the page do the slow work on load, and absorb that with --wait <ms> or a tighter ` +
|
|
76
76
|
`--wait-for '<selector>' gate instead.`);
|
|
@@ -101,15 +101,16 @@ function dimSuffix(vp) {
|
|
|
101
101
|
const dpr = vp.deviceScaleFactor ?? 1;
|
|
102
102
|
return dpr === 1 ? `${vp.width}x${vp.height}` : `${vp.width}x${vp.height}@${dpr}`;
|
|
103
103
|
}
|
|
104
|
-
/** Default screenshot directory: `<project-root>/screenshots`, falling
|
|
105
|
-
* to `./screenshots` in one-off mode (no linked project).
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
|
|
104
|
+
/** Default screenshot directory: `<project-root>/tmp/screenshots`, falling
|
|
105
|
+
* back to `./tmp/screenshots` in one-off mode (no linked project). A
|
|
106
|
+
* verification capture is scratch: `tmp/` is the one place that never syncs
|
|
107
|
+
* and never deploys, so a shot of a signed-in, private view can't leak into
|
|
108
|
+
* the project and nothing needs cleaning up afterwards. A capture worth
|
|
109
|
+
* keeping is a deliberate `-o docs/<name>.png` (synced, never deployed).
|
|
110
|
+
* Timestamped filenames keep a run's shots in order. */
|
|
111
|
+
export function defaultScreenshotDir() {
|
|
111
112
|
const root = getProjectRoot();
|
|
112
|
-
return join(root ?? '.', 'screenshots');
|
|
113
|
+
return join(root ?? '.', 'tmp', 'screenshots');
|
|
113
114
|
}
|
|
114
115
|
/** `yyyy-mm-dd_hh-mm-ss` per the repo timestamp convention - sorts chronologically,
|
|
115
116
|
* filesystem-safe. One stamp per invocation; viewport suffixes keep multi-shot
|
|
@@ -200,6 +201,16 @@ function appendOption(value, previous = []) {
|
|
|
200
201
|
// which swallowed the script and errored with a redirect: when the guess is
|
|
201
202
|
// unambiguous, making it WORK beats making it a better error.)
|
|
202
203
|
const ACTION_ALIAS_FLAGS = ['--eval', '--js', '--javascript', '--script', '--code', '--exec'];
|
|
204
|
+
// Same accept-the-reflex-guess pattern for the output file: `--path` and `--out`
|
|
205
|
+
// are what agents type for "save it here" (commander answered `--path` with
|
|
206
|
+
// "Did you mean --auth?", which points nowhere useful). Working hidden aliases
|
|
207
|
+
// for -o/--output.
|
|
208
|
+
const OUTPUT_ALIAS_FLAGS = ['--path', '--out'];
|
|
209
|
+
/** True when `--file` names an image: the caller meant the OUTPUT file, but
|
|
210
|
+
* --file is the pre-capture SCRIPT. Caught before it is read as JavaScript. */
|
|
211
|
+
export function looksLikeImagePath(p) {
|
|
212
|
+
return /\.(png|jpe?g|webp|gif)$/i.test(p);
|
|
213
|
+
}
|
|
203
214
|
/** A capture is worthless if it fires before the app reaches the state you meant
|
|
204
215
|
* to photograph, and the only lever used to be a blind millisecond delay — so a
|
|
205
216
|
* camera/vision app got screenshotted with a guessed duration (`--wait 22000`).
|
|
@@ -214,7 +225,7 @@ export function buildWaitForGate(selector, timeoutMs) {
|
|
|
214
225
|
`while (Date.now() - __t0 < ${timeoutMs}) { ` +
|
|
215
226
|
`try { if (document.querySelector(${sel})) return; } catch (e) { throw new Error('wait-for: invalid selector ' + ${sel}); } ` +
|
|
216
227
|
`await new Promise((r) => setTimeout(r, 100)); } ` +
|
|
217
|
-
`throw new Error('wait-for: nothing matched ' + ${sel} + ' within ${timeoutMs}ms
|
|
228
|
+
`throw new Error('wait-for: nothing matched ' + ${sel} + ' within ${timeoutMs}ms: the page never reached that state (raise --wait-timeout, fix the selector, or check the app actually gets there headlessly)'); })();`);
|
|
218
229
|
}
|
|
219
230
|
/** Max ms the selector gate may wait. The gate runs inside the capture's sandbox
|
|
220
231
|
* exec budget (page load + delay + script + settle + render), and 15s is what
|
|
@@ -240,7 +251,7 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
240
251
|
// the single most common reason to screenshot, and agents routinely read the
|
|
241
252
|
// help through `--help | head -N` — buried below the timing flags, these two
|
|
242
253
|
// fell off the bottom and the run proceeded at desktop width.
|
|
243
|
-
.option('--device <names>', `Device preset(s): ${Object.keys(DEVICE_PRESETS).join(', ')} (comma-separated or repeat flag). mobile/tablet emulate a real touch device
|
|
254
|
+
.option('--device <names>', `Device preset(s): ${Object.keys(DEVICE_PRESETS).join(', ')} (comma-separated or repeat flag). mobile/tablet emulate a real touch device (touch events, mobile user-agent, DPR) so touch-gated mobile UI actually renders.`, appendOption, [])
|
|
244
255
|
.option('--viewport <dims>', 'Raw viewport(s): WxH or WxH@dpr (comma-separated or repeat flag), e.g. --viewport 390x844 for a phone-sized window', appendOption, [])
|
|
245
256
|
// No commander default: a default here would make the value always set, so the
|
|
246
257
|
// merge below could not tell "caller chose a delay" from "nobody did" — which
|
|
@@ -251,12 +262,11 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
251
262
|
.option('--action <js>', 'Run JS in the page before capturing - e.g. click a button to enter a state ("document.getElementById(\'play\').click()"). Runs as an async function body, so const/await and app-relative import(\'./...\') work. Runs after the post-load delay, then settles again before the shot. If it throws, the capture still happens and the failure is reported.')
|
|
252
263
|
.option('--file <path>', 'Read the pre-capture script from a file instead of inline --action (mutually exclusive), or --file - to read it from stdin (pipe a heredoc: --file - <<\'EOF\' ... EOF) with no tmp file. For a multi-step driver - click through a flow, wait for it to render - then capture. Same async-function-body semantics as --action; same --file flag as page eval.')
|
|
253
264
|
.option('--full', 'Capture the full scrollable page (default: viewport only). Scrolls the page through first so scroll-reveal/fade-in-on-scroll (IntersectionObserver) sections render into the shot instead of capturing blank.')
|
|
254
|
-
.option('-o, --output <file>', 'Output path (default
|
|
265
|
+
.option('-o, --output <file>', 'Output path (default tmp/screenshots/ss-<host>-<timestamp>.png in the project: scratch, never synced or deployed). To keep a capture, write it under docs/ (-o docs/home.png: synced, never deployed). With several viewports it is a stem: -o tmp/shot.png --device desktop,mobile writes tmp/shot-desktop.png and tmp/shot-mobile.png.')
|
|
255
266
|
.option('--no-reload-between', 'Skip reload between viewports (faster, lower fidelity - only safe for static pages)')
|
|
256
|
-
.option('--fake-media', 'Grant a synthetic microphone + camera and auto-accept the getUserMedia prompt, so voice/camera apps render headlessly. The video feed is a built-in test pattern
|
|
257
|
-
.option('--camera <path>', 'Play a local image or video (.png/.jpg/.webp/.mp4/.webm/.y4m/.mjpeg) as the browser\'s WEBCAM feed, then capture
|
|
258
|
-
.option('--auth', 'Capture the page signed in as you (your Gipity account), so UI behind a Sign-in-with-Gipity login is shown. Only works for apps using Sign in with Gipity, hosted on *.gipity.ai. Without this flag the page loads as a genuinely anonymous, signed-out visitor
|
|
259
|
-
.option('--ephemeral', 'Skip the project screenshot history: do not persist this capture to Gipity (screenshots/ in the project). Local file is still written.')
|
|
267
|
+
.option('--fake-media', 'Grant a synthetic microphone + camera and auto-accept the getUserMedia prompt, so voice/camera apps render headlessly. The video feed is a built-in test pattern. To capture what the app does with a REAL frame (a hand, a face, an object), use --camera <path> instead.')
|
|
268
|
+
.option('--camera <path>', 'Play a local image or video (.png/.jpg/.webp/.mp4/.webm/.y4m/.mjpeg) as the browser\'s WEBCAM feed, then capture, so the shot shows the app reacting to a frame you chose (detected gesture, boxes, labels). Implies --fake-media.')
|
|
269
|
+
.option('--auth', 'Capture the page signed in as you (your Gipity account), so UI behind a Sign-in-with-Gipity login is shown. Only works for apps using Sign in with Gipity, hosted on *.gipity.ai. Without this flag the page loads as a genuinely anonymous, signed-out visitor: nothing carries over from earlier --auth runs.')
|
|
260
270
|
.option('--json', 'Output JSON metadata instead of a friendly summary')
|
|
261
271
|
.addOption(new Option('--post-load-delay <ms>', 'Alias for --wait').hideHelp())
|
|
262
272
|
// (--eval and the other JS-intent guesses are registered in one place from
|
|
@@ -277,7 +287,7 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
277
287
|
// so the next call uses it.
|
|
278
288
|
const aliasFlag = ACTION_ALIAS_FLAGS.find((f) => opts[f.slice(2)] !== undefined);
|
|
279
289
|
if (aliasFlag) {
|
|
280
|
-
console.error(muted(`Note: treating ${aliasFlag} as --action
|
|
290
|
+
console.error(muted(`Note: treating ${aliasFlag} as --action: it runs your JS in the page before the capture. --action is the canonical flag.`));
|
|
281
291
|
}
|
|
282
292
|
// The pre-capture script can come inline (--action / its JS-intent aliases) or
|
|
283
293
|
// from a file/stdin (--file, the same script-passing ergonomics as page eval).
|
|
@@ -290,6 +300,9 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
290
300
|
throw new Error('Pass either --file <path> or an inline --action script, not both');
|
|
291
301
|
}
|
|
292
302
|
let actionScript = inlineAction;
|
|
303
|
+
if (opts.file && looksLikeImagePath(opts.file)) {
|
|
304
|
+
throw new Error(`--file is the pre-capture SCRIPT (JavaScript to run before the shot), not the output image: save the PNG with -o ${opts.file}`);
|
|
305
|
+
}
|
|
293
306
|
if (opts.file) {
|
|
294
307
|
try {
|
|
295
308
|
actionScript = readScriptFile(opts.file);
|
|
@@ -310,7 +323,7 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
310
323
|
throw new Error('--wait must be a non-negative integer (ms)');
|
|
311
324
|
}
|
|
312
325
|
if (postLoadDelayMs > MAX_POST_LOAD_DELAY_MS) {
|
|
313
|
-
console.error(warning(`--wait ${postLoadDelayMs}ms exceeds the ${MAX_POST_LOAD_DELAY_MS}ms cap
|
|
326
|
+
console.error(warning(`--wait ${postLoadDelayMs}ms exceeds the ${MAX_POST_LOAD_DELAY_MS}ms cap: using ${MAX_POST_LOAD_DELAY_MS}ms. ` +
|
|
314
327
|
`Waiting longer is rarely the fix: gate on the state you want with --wait-for '<selector>' instead of guessing a duration.`));
|
|
315
328
|
postLoadDelayMs = MAX_POST_LOAD_DELAY_MS;
|
|
316
329
|
}
|
|
@@ -320,7 +333,7 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
320
333
|
}
|
|
321
334
|
const waitForTimeoutMs = Math.min(waitForTimeoutRaw, WAIT_FOR_MAX_MS);
|
|
322
335
|
if (waitForTimeoutRaw > WAIT_FOR_MAX_MS) {
|
|
323
|
-
console.error(warning(`--wait-timeout ${waitForTimeoutRaw}ms exceeds the ${WAIT_FOR_MAX_MS}ms the capture's browser budget covers
|
|
336
|
+
console.error(warning(`--wait-timeout ${waitForTimeoutRaw}ms exceeds the ${WAIT_FOR_MAX_MS}ms the capture's browser budget covers: using ${WAIT_FOR_MAX_MS}ms. ` +
|
|
324
337
|
`A state that takes longer than that to appear is not a screenshot problem: watch for it with ` +
|
|
325
338
|
`\`gipity page eval <url> --wait-for '<selector>' --wait-timeout 30000\` (a wider budget), then capture it.`));
|
|
326
339
|
}
|
|
@@ -342,7 +355,7 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
342
355
|
// pair is a mis-invocation worth one precise line, not a range error.
|
|
343
356
|
if (opts.width !== undefined || opts.height !== undefined) {
|
|
344
357
|
if (opts.width === undefined || opts.height === undefined) {
|
|
345
|
-
pageScreenshotCommand.error('error: --width and --height go together (both in px, equivalent to --viewport WxH)
|
|
358
|
+
pageScreenshotCommand.error('error: --width and --height go together (both in px, equivalent to --viewport WxH): ' +
|
|
346
359
|
'or use a preset like --device mobile for a real handset (touch events, mobile user-agent, DPR)');
|
|
347
360
|
}
|
|
348
361
|
if (!/^\d+$/.test(String(opts.width)) || !/^\d+$/.test(String(opts.height))) {
|
|
@@ -353,7 +366,7 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
353
366
|
// renders its desktop variant. Say so once, on the path where the caller
|
|
354
367
|
// was clearly after a phone.
|
|
355
368
|
if (parseInt(String(opts.width), 10) <= 500) {
|
|
356
|
-
console.error(muted('Tip: --device mobile emulates a real handset (touch events, mobile user-agent, DPR)
|
|
369
|
+
console.error(muted('Tip: --device mobile emulates a real handset (touch events, mobile user-agent, DPR): a raw viewport only resizes the window.'));
|
|
357
370
|
}
|
|
358
371
|
}
|
|
359
372
|
const customViewports = [
|
|
@@ -369,16 +382,12 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
369
382
|
// Server defaults to 1280×720 when viewports is omitted - don't send it in
|
|
370
383
|
// the no-flag case so the filename stays unsuffixed (no viewport segment).
|
|
371
384
|
const userSpecifiedViewports = customViewports.length > 0;
|
|
372
|
-
// Filenames are decided before the request so the server can persist the
|
|
373
|
-
// captures to the project VFS under the SAME names the local files get —
|
|
374
|
-
// the local screenshots/ dir and the VFS screenshot history stay 1:1 and
|
|
375
|
-
// sync reconciles them by content hash instead of duplicating.
|
|
376
385
|
const slug = slugFromUrl(url);
|
|
377
386
|
const ts = timestampSlug();
|
|
378
387
|
const shotName = (vp) => defaultFilename(slug, ts, vp && userSpecifiedViewports ? dimSuffix(vp) : undefined);
|
|
379
388
|
const names = userSpecifiedViewports ? customViewports.map(shotName) : [shotName()];
|
|
380
389
|
const projectGuid = getConfig()?.projectGuid;
|
|
381
|
-
const
|
|
390
|
+
const outputArg = opts.output ?? OUTPUT_ALIAS_FLAGS.map((f) => opts[f.slice(2)]).find(Boolean);
|
|
382
391
|
// The webcam frame is hosted in the project's public file store for the
|
|
383
392
|
// browser container to fetch, so it needs a linked project. Validate the
|
|
384
393
|
// file locally first — a bad file type costs one instant error, not an
|
|
@@ -387,7 +396,7 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
387
396
|
if (opts.camera) {
|
|
388
397
|
assertCameraFile(opts.camera);
|
|
389
398
|
if (!projectGuid)
|
|
390
|
-
throw new Error('--camera needs a linked project (the frame is hosted for the browser to fetch)
|
|
399
|
+
throw new Error('--camera needs a linked project (the frame is hosted for the browser to fetch): run `gipity link` first.');
|
|
391
400
|
console.log(muted(`Hosting camera feed ${opts.camera}...`));
|
|
392
401
|
camera = await uploadCameraFeed(projectGuid, opts.camera);
|
|
393
402
|
}
|
|
@@ -412,7 +421,6 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
412
421
|
...(camera ? { cameraUrl: camera.url } : {}),
|
|
413
422
|
...(opts.auth ? { auth: true } : {}),
|
|
414
423
|
...(preCapture ? { action: preCapture } : {}),
|
|
415
|
-
...(save ? { save } : {}),
|
|
416
424
|
};
|
|
417
425
|
// Load + render across viewports runs server-side and can take many
|
|
418
426
|
// seconds; animate the wait, then clear so the saved-files summary is the
|
|
@@ -439,7 +447,7 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
439
447
|
await deleteFixture(projectGuid, camera.guid);
|
|
440
448
|
}
|
|
441
449
|
catch (err) {
|
|
442
|
-
console.error(warning(`⚠ Could not auto-delete camera feed "${camera.name}" (${camera.guid})
|
|
450
|
+
console.error(warning(`⚠ Could not auto-delete camera feed "${camera.name}" (${camera.guid}): still hosted at ${camera.url}: ${err.message}`));
|
|
443
451
|
}
|
|
444
452
|
}
|
|
445
453
|
}
|
|
@@ -458,19 +466,19 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
458
466
|
const usedStems = new Set();
|
|
459
467
|
const outputPath = (i) => {
|
|
460
468
|
if (pngs.length === 1)
|
|
461
|
-
return
|
|
469
|
+
return outputArg;
|
|
462
470
|
let suffix = viewportLabels[i] ?? dimSuffix(meta.screenshots[i].viewport);
|
|
463
471
|
while (usedStems.has(suffix))
|
|
464
472
|
suffix += `-${i + 1}`;
|
|
465
473
|
usedStems.add(suffix);
|
|
466
|
-
return stemPath(
|
|
474
|
+
return stemPath(outputArg, suffix);
|
|
467
475
|
};
|
|
468
476
|
for (let i = 0; i < pngs.length; i++) {
|
|
469
|
-
const target =
|
|
477
|
+
const target = outputArg
|
|
470
478
|
? outputPath(i)
|
|
471
479
|
: join(dir, names[i] ?? shotName(meta.screenshots[i].viewport));
|
|
472
480
|
// Create the target's parent dir so a `-o` path under a not-yet-existing
|
|
473
|
-
// directory (e.g.
|
|
481
|
+
// directory (e.g. docs/shots/home.png) writes cleanly instead of
|
|
474
482
|
// failing with a raw ENOENT and forcing a manual `mkdir -p`.
|
|
475
483
|
mkdirSync(dirname(target), { recursive: true });
|
|
476
484
|
writeFileSync(target, pngs[i].buffer);
|
|
@@ -501,22 +509,10 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
501
509
|
size_bytes: s.screenshotSizeBytes,
|
|
502
510
|
full_page: meta.full,
|
|
503
511
|
phase: s.phase,
|
|
504
|
-
...(s.vfs ? { gipity: s.vfs } : {}),
|
|
505
512
|
})),
|
|
506
513
|
}));
|
|
507
514
|
return;
|
|
508
515
|
}
|
|
509
|
-
/** One-line VFS-history status for a screenshot ("saved to Gipity" or why not). */
|
|
510
|
-
const printVfsLine = (s) => {
|
|
511
|
-
if (!s.vfs)
|
|
512
|
-
return;
|
|
513
|
-
if ('error' in s.vfs) {
|
|
514
|
-
console.log(`${warning('⚠ Gipity save failed:')} ${s.vfs.error} ${muted('(local file is fine)')}`);
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
console.log(`${label('Gipity history')} ${s.vfs.path} ${muted('(synced, not deployed)')}`);
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
516
|
if (meta.screenshots.length === 1) {
|
|
521
517
|
const s = meta.screenshots[0];
|
|
522
518
|
console.log(`${brand('Screenshot')} ${bold(url)}`);
|
|
@@ -537,7 +533,6 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
537
533
|
if (s.width && s.height)
|
|
538
534
|
console.log(`${label('Screenshot dims')} ${s.width} × ${s.height}`);
|
|
539
535
|
console.log(`${label('Screenshot file')} ${success(savedFiles[0])}`);
|
|
540
|
-
printVfsLine(s);
|
|
541
536
|
return;
|
|
542
537
|
}
|
|
543
538
|
console.log(`${brand('Loading')} ${bold(url)} ${muted(`once → ${meta.screenshots.length} viewports`)}`);
|
|
@@ -554,20 +549,21 @@ export const pageScreenshotCommand = new Command('screenshot')
|
|
|
554
549
|
for (let i = 0; i < meta.screenshots.length; i++) {
|
|
555
550
|
const s = meta.screenshots[i];
|
|
556
551
|
const dims = `${s.viewport.width}×${s.viewport.height}${s.viewport.deviceScaleFactor > 1 ? ` @${s.viewport.deviceScaleFactor}x` : ''}`;
|
|
557
|
-
const deviceTag = s.viewport.device ? muted(`
|
|
552
|
+
const deviceTag = s.viewport.device ? muted(` (${s.viewport.device}, touch)`) : '';
|
|
558
553
|
console.log(`\n${brand('@ ' + dims)}${deviceTag}`);
|
|
559
554
|
const sizePart = formatSize(s.screenshotSizeBytes) + (meta.full ? ' (full page)' : '');
|
|
560
555
|
console.log(`${label('Screenshot size')} ${sizePart}`);
|
|
561
556
|
if (s.width && s.height)
|
|
562
557
|
console.log(`${label('Screenshot dims')} ${s.width} × ${s.height}`);
|
|
563
558
|
console.log(`${label('Screenshot file')} ${success(savedFiles[i])}`);
|
|
564
|
-
printVfsLine(s);
|
|
565
559
|
}
|
|
566
560
|
}));
|
|
567
561
|
// Register the JS-intent guesses as hidden aliases for --action (value-taking,
|
|
568
562
|
// so they capture the script) — the action folds them into the pre-capture body.
|
|
569
563
|
for (const f of ACTION_ALIAS_FLAGS)
|
|
570
564
|
pageScreenshotCommand.addOption(new Option(`${f} <js>`, 'Alias for --action').hideHelp());
|
|
565
|
+
for (const f of OUTPUT_ALIAS_FLAGS)
|
|
566
|
+
pageScreenshotCommand.addOption(new Option(`${f} <file>`, 'Alias for -o/--output').hideHelp());
|
|
571
567
|
// `screenshot` captures the page AFTER load + settle (+ optional --wait-for gate
|
|
572
568
|
// and --action). There is no scroll-to-a-position lever (agents reach for
|
|
573
569
|
// --scroll and get an unknown-option detour) — but `--full` does walk the page
|
|
@@ -578,23 +574,24 @@ for (const f of ACTION_ALIAS_FLAGS)
|
|
|
578
574
|
// --full + crop covers off-screen regions; `page eval` reads data, no picture.
|
|
579
575
|
pageScreenshotCommand.addHelpText('after', `
|
|
580
576
|
Examples:
|
|
581
|
-
gipity page screenshot "https://dev.gipity.ai/me/app/"
|
|
577
|
+
gipity page screenshot "https://dev.gipity.ai/me/app/" # -> tmp/screenshots/ (scratch: never synced or deployed)
|
|
578
|
+
gipity page screenshot "https://dev.gipity.ai/me/app/" -o docs/home.png # keep it (docs/ syncs, never deploys)
|
|
582
579
|
gipity page screenshot "https://dev.gipity.ai/me/app/" --full # whole scrollable page (scroll-reveal sections triggered)
|
|
583
580
|
gipity page screenshot "https://dev.gipity.ai/me/app/" --device mobile,desktop
|
|
584
581
|
gipity page screenshot "https://dev.gipity.ai/me/app/" \\
|
|
585
582
|
--action "document.getElementById('play').click()" # capture an in-game frame
|
|
586
583
|
# Camera / vision app: play a real frame in as the webcam and shoot once the app
|
|
587
|
-
# says it's ready
|
|
584
|
+
# says it's ready: same --camera / --wait-for flags as 'page eval', no guessed delay:
|
|
588
585
|
gipity page screenshot "https://dev.gipity.ai/me/app/" --camera fist.png \\
|
|
589
586
|
--wait-for '[data-vision="ready"]'
|
|
590
587
|
|
|
591
588
|
Waiting for the page to reach a state before the shot?
|
|
592
589
|
--wait-for '<selector>' gates the capture on the app's own signal (deterministic).
|
|
593
|
-
Reach for --wait <ms> only when there is nothing to gate on
|
|
590
|
+
Reach for --wait <ms> only when there is nothing to gate on: a guessed duration
|
|
594
591
|
either shoots too early or wastes the difference.
|
|
595
592
|
|
|
596
593
|
Capturing a state that needs an interaction (start a game, open a menu, dismiss a modal)?
|
|
597
|
-
Use --action to run JS in the page before the shot
|
|
594
|
+
Use --action to run JS in the page before the shot: it fires after the wait
|
|
598
595
|
(and after any --wait-for gate), then settles again so the result has painted. For
|
|
599
596
|
a multi-step driver (click, wait, click) pipe it as a heredoc with --file - (same
|
|
600
597
|
as 'page eval') instead of cramming it into one inline string:
|
|
@@ -610,6 +607,6 @@ Capturing a state that needs an interaction (start a game, open a menu, dismiss
|
|
|
610
607
|
Capturing an off-screen region or reading element data?
|
|
611
608
|
• --full captures the ENTIRE scrollable page (then crop to the region).
|
|
612
609
|
• 'gipity page eval <url> "<expr>"' reads any (even off-screen) element's
|
|
613
|
-
data/state/rect without a picture
|
|
610
|
+
data/state/rect without a picture: e.g. read the chart's bar values
|
|
614
611
|
directly instead of screenshotting the slide.`);
|
|
615
612
|
//# sourceMappingURL=page-screenshot.js.map
|