cssprobe-cli 0.2.22 → 0.2.24
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/dist/browser/launcher.d.ts +3 -1
- package/dist/browser/launcher.js +4 -0
- package/dist/cli/commands.js +9 -1
- package/dist/cli/program.js +43 -0
- package/dist/daemon/daemon.js +7 -0
- package/dist/help.json +8 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Page } from 'playwright-core';
|
|
1
|
+
import { type BrowserContext, type Page } from 'playwright-core';
|
|
2
2
|
import type { Snapshot, CollectConfig } from '../engine/types';
|
|
3
3
|
export interface LauncherOptions {
|
|
4
4
|
browser?: string;
|
|
@@ -23,5 +23,7 @@ export declare class BrowserLauncher {
|
|
|
23
23
|
navigate(url: string): Promise<void>;
|
|
24
24
|
/** Get the current page object. */
|
|
25
25
|
getPage(): Page | null;
|
|
26
|
+
/** Get the current browser context. */
|
|
27
|
+
getContext(): BrowserContext | null;
|
|
26
28
|
close(): Promise<void>;
|
|
27
29
|
}
|
package/dist/browser/launcher.js
CHANGED
|
@@ -129,6 +129,10 @@ class BrowserLauncher {
|
|
|
129
129
|
getPage() {
|
|
130
130
|
return this.page;
|
|
131
131
|
}
|
|
132
|
+
/** Get the current browser context. */
|
|
133
|
+
getContext() {
|
|
134
|
+
return this.context;
|
|
135
|
+
}
|
|
132
136
|
async close() {
|
|
133
137
|
if (this.context)
|
|
134
138
|
await this.context.close().catch(() => { });
|
package/dist/cli/commands.js
CHANGED
|
@@ -170,6 +170,14 @@ const stateImport = (0, command_1.declareCommand)({
|
|
|
170
170
|
merge: z.string().optional().describe('existing state file to merge into'),
|
|
171
171
|
}),
|
|
172
172
|
});
|
|
173
|
+
const stateSave = (0, command_1.declareCommand)({
|
|
174
|
+
name: 'state-save',
|
|
175
|
+
category: 'core',
|
|
176
|
+
description: 'Save current browser session state (cookies + localStorage)',
|
|
177
|
+
options: z.object({
|
|
178
|
+
name: z.string().optional().describe('state file name (default: session)'),
|
|
179
|
+
}),
|
|
180
|
+
});
|
|
173
181
|
// ── config ──
|
|
174
182
|
const configShow = (0, command_1.declareCommand)({
|
|
175
183
|
name: 'config-show',
|
|
@@ -247,7 +255,7 @@ const commandsArray = [
|
|
|
247
255
|
// browser
|
|
248
256
|
resize, evalCmd, playwrightCmd, screenshot,
|
|
249
257
|
// state
|
|
250
|
-
stateImport,
|
|
258
|
+
stateImport, stateSave,
|
|
251
259
|
// config
|
|
252
260
|
configShow, configSet, configList, configUse, configNew, configPath,
|
|
253
261
|
// skill
|
package/dist/cli/program.js
CHANGED
|
@@ -51,6 +51,9 @@ async function program() {
|
|
|
51
51
|
case 'state-import':
|
|
52
52
|
await handleStateImport(command, rawArgs, output);
|
|
53
53
|
return;
|
|
54
|
+
case 'state-save':
|
|
55
|
+
await handleStateSave(command, rawArgs, output);
|
|
56
|
+
return;
|
|
54
57
|
case 'inspect':
|
|
55
58
|
case 'tree':
|
|
56
59
|
case 'layout':
|
|
@@ -492,4 +495,44 @@ async function handleStateImport(command, args, output) {
|
|
|
492
495
|
output.error(e instanceof Error ? e.message : String(e));
|
|
493
496
|
}
|
|
494
497
|
}
|
|
498
|
+
// ── state-save ──
|
|
499
|
+
async function handleStateSave(command, args, output) {
|
|
500
|
+
try {
|
|
501
|
+
const session = await (0, session_1.loadSession)();
|
|
502
|
+
if (!session) {
|
|
503
|
+
output.error('No active session. Run: cssprobe-cli open <url>');
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
const cmdArgs = splitArgs(args);
|
|
507
|
+
const parsed = (0, command_1.parseCommand)(command, cmdArgs);
|
|
508
|
+
const name = parsed.name || 'session';
|
|
509
|
+
const fileName = name.endsWith('.json') ? name : `${name}.json`;
|
|
510
|
+
const outPath = path_1.default.join(os_1.default.homedir(), '.cssprobe-cli', 'states', fileName);
|
|
511
|
+
// Ask daemon to save state
|
|
512
|
+
const result = await session.run({ _: ['state-save'] });
|
|
513
|
+
const state = JSON.parse(result.text);
|
|
514
|
+
const resolvedOut = path_1.default.resolve(outPath);
|
|
515
|
+
const dir = path_1.default.dirname(resolvedOut);
|
|
516
|
+
if (!fs_1.default.existsSync(dir))
|
|
517
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
518
|
+
fs_1.default.writeFileSync(resolvedOut, JSON.stringify(state, null, 2) + '\n');
|
|
519
|
+
if (output.json) {
|
|
520
|
+
console.log(JSON.stringify({
|
|
521
|
+
saved: resolvedOut,
|
|
522
|
+
cookies: state.cookies?.length || 0,
|
|
523
|
+
origins: state.origins?.length || 0,
|
|
524
|
+
usage: `cssprobe-cli open <url> --state ${resolvedOut}`,
|
|
525
|
+
}, null, 2));
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
console.log(`State saved: ${resolvedOut}`);
|
|
529
|
+
console.log(`Cookies: ${state.cookies?.length || 0}`);
|
|
530
|
+
console.log(`Origins: ${state.origins?.length || 0}`);
|
|
531
|
+
console.log(`Usage: cssprobe-cli open <url> --state ${resolvedOut}`);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
catch (e) {
|
|
535
|
+
output.error(e instanceof Error ? e.message : String(e));
|
|
536
|
+
}
|
|
537
|
+
}
|
|
495
538
|
//# sourceMappingURL=program.js.map
|
package/dist/daemon/daemon.js
CHANGED
|
@@ -200,6 +200,13 @@ async function executeCommand(launcher, args) {
|
|
|
200
200
|
const result = await asyncFunction(page, browser);
|
|
201
201
|
return { text: JSON.stringify(result, null, 2) };
|
|
202
202
|
}
|
|
203
|
+
case 'state-save': {
|
|
204
|
+
const context = launcher.getContext();
|
|
205
|
+
if (!context)
|
|
206
|
+
throw new Error('Browser is not open. Run: cssprobe-cli open <url>');
|
|
207
|
+
const state = await context.storageState();
|
|
208
|
+
return { text: JSON.stringify(state) };
|
|
209
|
+
}
|
|
203
210
|
default:
|
|
204
211
|
throw new Error(`Unknown command: ${command}`);
|
|
205
212
|
}
|
package/dist/help.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"global": "Usage: cssprobe-cli <command> [args] [options]\n\n\nSession Management:\n open [url] open browser in session mode (non-blocking)\n close close the browser session\n status show current session status\n resize <width> <height> resize the browser viewport\n eval <expression> evaluate javascript expression on the page (browser context)\n playwright <call> execute playwright api call (node.js context)\n state-import [file] import cookies from netscape format file\n\nCSS Inspection:\n inspect <selector> inspect the runtime css of a page element\n tree <selector> show dom tree structure\n layout <selector> show ascii layout diagram\n findings <selector> show only issues/warnings/errors\n inject-css <css> inject css into the current page\n\nExport:\n screenshot take a screenshot of the current page\n\nConfiguration:\n config-show show current configuration\n config-set <key> <value> set a configuration value\n config-list list all profiles\n config-use <name> switch active profile\n config-new <name> create a new profile\n config-path show configuration file path\n\nAgent Skills:\n skill-install install agent skill for cssprobe-cli\n skill-uninstall remove agent skill for cssprobe-cli\n\nGlobal options:\n --help [command] print help\n --json output response as JSON\n --raw output only the result value\n --version print version\n -p, --profile <name> use named profile (or CSSPROBE_PROFILE env)",
|
|
2
|
+
"global": "Usage: cssprobe-cli <command> [args] [options]\n\n\nSession Management:\n open [url] open browser in session mode (non-blocking)\n close close the browser session\n status show current session status\n resize <width> <height> resize the browser viewport\n eval <expression> evaluate javascript expression on the page (browser context)\n playwright <call> execute playwright api call (node.js context)\n state-import [file] import cookies from netscape format file\n state-save save current browser session state (cookies + localstorage)\n\nCSS Inspection:\n inspect <selector> inspect the runtime css of a page element\n tree <selector> show dom tree structure\n layout <selector> show ascii layout diagram\n findings <selector> show only issues/warnings/errors\n inject-css <css> inject css into the current page\n\nExport:\n screenshot take a screenshot of the current page\n\nConfiguration:\n config-show show current configuration\n config-set <key> <value> set a configuration value\n config-list list all profiles\n config-use <name> switch active profile\n config-new <name> create a new profile\n config-path show configuration file path\n\nAgent Skills:\n skill-install install agent skill for cssprobe-cli\n skill-uninstall remove agent skill for cssprobe-cli\n\nGlobal options:\n --help [command] print help\n --json output response as JSON\n --raw output only the result value\n --version print version\n -p, --profile <name> use named profile (or CSSPROBE_PROFILE env)",
|
|
3
3
|
"commands": {
|
|
4
4
|
"open": {
|
|
5
5
|
"help": "cssprobe-cli open [url]\n\nOpen browser in session mode (non-blocking)\n\nArguments:\n [url] url, file:// path, or local html file path\nOptions:\n --browser browser engine (default chromium)\n --headed show the browser window\n --viewport viewport size as wxh (e.g. 1280x720)\n --state path to saved state file (cookies + localstorage)\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
|
|
@@ -107,6 +107,13 @@
|
|
|
107
107
|
"file"
|
|
108
108
|
]
|
|
109
109
|
},
|
|
110
|
+
"state-save": {
|
|
111
|
+
"help": "cssprobe-cli state-save \n\nSave current browser session state (cookies + localStorage)\n\nOptions:\n --name state file name (default: session)\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
|
|
112
|
+
"flags": {
|
|
113
|
+
"name": "string"
|
|
114
|
+
},
|
|
115
|
+
"args": []
|
|
116
|
+
},
|
|
110
117
|
"config-show": {
|
|
111
118
|
"help": "cssprobe-cli config-show \n\nShow current configuration\n\nOptions:\n --profile profile name",
|
|
112
119
|
"flags": {
|
package/package.json
CHANGED