cssprobe-cli 0.2.5 → 0.2.6
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 +3 -0
- package/dist/browser/launcher.d.ts +5 -0
- package/dist/browser/launcher.js +4 -2
- package/dist/cli/commands.d.ts +3 -0
- package/dist/cli/commands.js +3 -1
- package/dist/cli/program.js +4 -3
- package/dist/config/config.d.ts +5 -0
- package/dist/config/config.js +14 -0
- package/dist/help.json +7 -5
- package/docs/guide/installation.md +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -142,6 +142,7 @@ Options:
|
|
|
142
142
|
--brief Compact output: tree sketch + warnings/errors only
|
|
143
143
|
--layout ASCII layout diagram showing element positions and sizes
|
|
144
144
|
--wait Wait for user interaction before collecting (implies --headed)
|
|
145
|
+
--viewport <WxH> Viewport size (e.g. 375x812, default 1280x720)
|
|
145
146
|
```
|
|
146
147
|
|
|
147
148
|
---
|
|
@@ -189,6 +190,7 @@ The report header shows: `confidence: DEFINITE 8 | INDEFINITE 0 | UNVERIFIABLE 1
|
|
|
189
190
|
# Set values
|
|
190
191
|
cssprobe-cli config-set browser chromium
|
|
191
192
|
cssprobe-cli config-set depth 8
|
|
193
|
+
cssprobe-cli config-set viewport 375x812
|
|
192
194
|
|
|
193
195
|
# Show current config
|
|
194
196
|
cssprobe-cli config-show
|
|
@@ -206,6 +208,7 @@ Priority: CLI flags > Environment variables > Config file
|
|
|
206
208
|
--browser CSSPROBE_BROWSER
|
|
207
209
|
--depth CSSPROBE_DEPTH
|
|
208
210
|
--headed CSSPROBE_HEADED
|
|
211
|
+
--viewport CSSPROBE_VIEWPORT
|
|
209
212
|
-p, --profile CSSPROBE_PROFILE
|
|
210
213
|
```
|
|
211
214
|
|
|
@@ -4,6 +4,11 @@ export interface LauncherOptions {
|
|
|
4
4
|
headed?: boolean;
|
|
5
5
|
/** Path to a Playwright storage state file (cookies + localStorage). */
|
|
6
6
|
state?: string;
|
|
7
|
+
/** Custom viewport size. Defaults to 1280×720. */
|
|
8
|
+
viewport?: {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
7
12
|
}
|
|
8
13
|
export declare class BrowserLauncher {
|
|
9
14
|
private options;
|
package/dist/browser/launcher.js
CHANGED
|
@@ -75,7 +75,8 @@ class BrowserLauncher {
|
|
|
75
75
|
}
|
|
76
76
|
this.browser = await factory.launch(launchOptions);
|
|
77
77
|
// Load saved state if provided
|
|
78
|
-
const
|
|
78
|
+
const vp = this.options.viewport || { width: 1280, height: 720 };
|
|
79
|
+
const contextOptions = { viewport: vp };
|
|
79
80
|
if (this.options.state && fs_1.default.existsSync(this.options.state)) {
|
|
80
81
|
contextOptions.storageState = this.options.state;
|
|
81
82
|
}
|
|
@@ -212,7 +213,8 @@ class BrowserLauncher {
|
|
|
212
213
|
if (execPath)
|
|
213
214
|
launchOptions.executablePath = execPath;
|
|
214
215
|
this.browser = await factory.launch(launchOptions);
|
|
215
|
-
|
|
216
|
+
const vp = this.options.viewport || { width: 1280, height: 720 };
|
|
217
|
+
this.context = await this.browser.newContext({ viewport: vp });
|
|
216
218
|
this.page = await this.context.newPage();
|
|
217
219
|
// Navigate to the target URL
|
|
218
220
|
if (url.startsWith('http://') || url.startsWith('https://')) {
|
package/dist/cli/commands.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare const inspectCommand: import("./command").CommandSchema<z.ZodObje
|
|
|
24
24
|
brief: z.ZodOptional<z.ZodBoolean>;
|
|
25
25
|
layout: z.ZodOptional<z.ZodBoolean>;
|
|
26
26
|
wait: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
viewport: z.ZodOptional<z.ZodString>;
|
|
27
28
|
}, "strip", z.ZodTypeAny, {
|
|
28
29
|
json?: boolean | undefined;
|
|
29
30
|
headed?: boolean | undefined;
|
|
@@ -36,6 +37,7 @@ export declare const inspectCommand: import("./command").CommandSchema<z.ZodObje
|
|
|
36
37
|
brief?: boolean | undefined;
|
|
37
38
|
layout?: boolean | undefined;
|
|
38
39
|
wait?: boolean | undefined;
|
|
40
|
+
viewport?: string | undefined;
|
|
39
41
|
}, {
|
|
40
42
|
json?: boolean | undefined;
|
|
41
43
|
headed?: boolean | undefined;
|
|
@@ -48,4 +50,5 @@ export declare const inspectCommand: import("./command").CommandSchema<z.ZodObje
|
|
|
48
50
|
brief?: boolean | undefined;
|
|
49
51
|
layout?: boolean | undefined;
|
|
50
52
|
wait?: boolean | undefined;
|
|
53
|
+
viewport?: string | undefined;
|
|
51
54
|
}>>;
|
package/dist/cli/commands.js
CHANGED
|
@@ -65,6 +65,7 @@ const inspect = (0, command_1.declareCommand)({
|
|
|
65
65
|
brief: z.boolean().optional().describe('compact output: tree sketch + warnings/errors only'),
|
|
66
66
|
layout: z.boolean().optional().describe('ASCII layout diagram showing element positions and sizes'),
|
|
67
67
|
wait: z.boolean().optional().describe('wait for user interaction before collecting (implies --headed)'),
|
|
68
|
+
viewport: z.string().optional().describe('viewport size as WxH (e.g. 375x812, default 1280x720)'),
|
|
68
69
|
}),
|
|
69
70
|
});
|
|
70
71
|
const login = (0, command_1.declareCommand)({
|
|
@@ -93,7 +94,7 @@ const configSet = (0, command_1.declareCommand)({
|
|
|
93
94
|
category: 'config',
|
|
94
95
|
description: 'Set a configuration value',
|
|
95
96
|
args: z.object({
|
|
96
|
-
key: z.string().describe('Config key (browser, depth, headed)'),
|
|
97
|
+
key: z.string().describe('Config key (browser, depth, headed, viewport)'),
|
|
97
98
|
value: z.string().describe('Config value'),
|
|
98
99
|
}),
|
|
99
100
|
options: z.object({
|
|
@@ -170,6 +171,7 @@ const interactive = (0, command_1.declareCommand)({
|
|
|
170
171
|
browser: z.enum(['chromium', 'firefox', 'webkit']).optional().describe('browser engine (default chromium)'),
|
|
171
172
|
state: z.string().optional().describe('path to saved state file (cookies + localStorage)'),
|
|
172
173
|
depth: numberArg.optional().describe('DOM tree depth (default: auto, max 20)'),
|
|
174
|
+
viewport: z.string().optional().describe('viewport size as WxH (e.g. 375x812, default 1280x720)'),
|
|
173
175
|
}),
|
|
174
176
|
});
|
|
175
177
|
const commandsArray = [
|
package/dist/cli/program.js
CHANGED
|
@@ -125,7 +125,7 @@ async function handleInspect(command, cmdEntry, args, output) {
|
|
|
125
125
|
// Auto-detect root selector if not provided
|
|
126
126
|
let rootSelector = selector;
|
|
127
127
|
if (!rootSelector) {
|
|
128
|
-
const detected = await autoDetectRoot(url, { browser, headed, state });
|
|
128
|
+
const detected = await autoDetectRoot(url, { browser, headed, state, viewport: config.viewport });
|
|
129
129
|
if (!detected) {
|
|
130
130
|
output.error('Could not auto-detect a root element. Please provide a selector: cssprobe-cli inspect <url> <selector>');
|
|
131
131
|
return;
|
|
@@ -133,7 +133,7 @@ async function handleInspect(command, cmdEntry, args, output) {
|
|
|
133
133
|
rootSelector = detected;
|
|
134
134
|
console.error(`Auto-detected root: ${rootSelector}`);
|
|
135
135
|
}
|
|
136
|
-
const launcher = new launcher_1.BrowserLauncher({ browser, headed, state });
|
|
136
|
+
const launcher = new launcher_1.BrowserLauncher({ browser, headed, state, viewport: config.viewport });
|
|
137
137
|
await launcher.open(url);
|
|
138
138
|
// Wait for user interaction if --wait
|
|
139
139
|
if (wait) {
|
|
@@ -427,7 +427,8 @@ async function handleInteractive(command, cmdEntry, args, _output) {
|
|
|
427
427
|
console.error('Error: URL is required. Usage: cssprobe-cli interactive <url>');
|
|
428
428
|
process.exit(1);
|
|
429
429
|
}
|
|
430
|
-
const
|
|
430
|
+
const config = (0, config_1.loadConfig)(args);
|
|
431
|
+
const launcher = new launcher_1.BrowserLauncher({ browser, headed: true, state, viewport: config.viewport });
|
|
431
432
|
await launcher.open(url);
|
|
432
433
|
let currentUrl = url;
|
|
433
434
|
// Resolve auto depth
|
package/dist/config/config.d.ts
CHANGED
|
@@ -3,11 +3,16 @@ export interface ProfileConfig {
|
|
|
3
3
|
browser?: string;
|
|
4
4
|
depth?: string;
|
|
5
5
|
headed?: string;
|
|
6
|
+
viewport?: string;
|
|
6
7
|
}
|
|
7
8
|
export interface Config {
|
|
8
9
|
browser: string;
|
|
9
10
|
depth: number;
|
|
10
11
|
headed: boolean;
|
|
12
|
+
viewport?: {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
11
16
|
output: 'text' | 'json';
|
|
12
17
|
raw: boolean;
|
|
13
18
|
}
|
package/dist/config/config.js
CHANGED
|
@@ -77,16 +77,29 @@ function resolveProfile(args) {
|
|
|
77
77
|
const rc = readRcFile();
|
|
78
78
|
return rc.profiles[name] || {};
|
|
79
79
|
}
|
|
80
|
+
function parseViewport(raw) {
|
|
81
|
+
const match = raw.match(/^(\d+)\s*[xX*](\d+)$/);
|
|
82
|
+
if (!match)
|
|
83
|
+
return undefined;
|
|
84
|
+
const width = Number(match[1]);
|
|
85
|
+
const height = Number(match[2]);
|
|
86
|
+
if (width > 0 && height > 0)
|
|
87
|
+
return { width, height };
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
80
90
|
function loadConfig(args) {
|
|
81
91
|
const profile = resolveProfile(args);
|
|
82
92
|
const browser = args.browser || process.env.CSSPROBE_BROWSER || profile.browser || 'chromium';
|
|
83
93
|
const depthRaw = args.depth ?? process.env.CSSPROBE_DEPTH ?? profile.depth;
|
|
84
94
|
const depth = depthRaw ? Number(depthRaw) : 6;
|
|
85
95
|
const headed = !!(args.headed || process.env.CSSPROBE_HEADED === 'true' || profile.headed === 'true');
|
|
96
|
+
const viewportRaw = args.viewport || process.env.CSSPROBE_VIEWPORT || profile.viewport;
|
|
97
|
+
const viewport = viewportRaw ? parseViewport(viewportRaw) : undefined;
|
|
86
98
|
return {
|
|
87
99
|
browser,
|
|
88
100
|
depth: Number.isNaN(depth) ? 6 : depth,
|
|
89
101
|
headed,
|
|
102
|
+
viewport,
|
|
90
103
|
output: args.json ? 'json' : 'text',
|
|
91
104
|
raw: !!args.raw,
|
|
92
105
|
};
|
|
@@ -96,6 +109,7 @@ function maskConfig(config) {
|
|
|
96
109
|
browser: config.browser,
|
|
97
110
|
depth: String(config.depth),
|
|
98
111
|
headed: String(config.headed),
|
|
112
|
+
...(config.viewport ? { viewport: `${config.viewport.width}x${config.viewport.height}` } : {}),
|
|
99
113
|
};
|
|
100
114
|
}
|
|
101
115
|
function writeRcConfig(key, value, profileName) {
|
package/dist/help.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"global": "Usage: cssprobe-cli <command> [args] [options]\n\n\nInspection:\n inspect <url> [selector] inspect the runtime css of a page (layout, scroll, colors, fonts, backgrounds)\n login <url> open browser for interactive login, then save state for later use\n state-import [file] import cookies from netscape format file into a playwright state file\n interactive <url> open browser and inspect interactively (repl mode)\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 (teaches agents how to use the 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
|
"inspect": {
|
|
5
|
-
"help": "cssprobe-cli inspect <url> [selector]\n\nInspect the runtime CSS of a page (layout, scroll, colors, fonts, backgrounds)\n\nArguments:\n <url> url, file:// path, or local html file path\n [selector] css selector for the root element (auto-detected if omitted)\nOptions:\n --json output structured json instead of markdown\n --headed show the browser window\n --browser browser engine (default chromium)\n --zoom run 1x/0.5x viewport diagnosis\n --depth dom tree depth (default: auto, max 20)\n --max-nodes node count cap (default 60)\n --up-to ancestor stop tag (default html)\n --state path to saved state file (cookies + localstorage)\n --brief compact output: tree sketch + warnings/errors only\n --layout ascii layout diagram showing element positions and sizes\n --wait wait for user interaction before collecting (implies --headed)\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
|
|
5
|
+
"help": "cssprobe-cli inspect <url> [selector]\n\nInspect the runtime CSS of a page (layout, scroll, colors, fonts, backgrounds)\n\nArguments:\n <url> url, file:// path, or local html file path\n [selector] css selector for the root element (auto-detected if omitted)\nOptions:\n --json output structured json instead of markdown\n --headed show the browser window\n --browser browser engine (default chromium)\n --zoom run 1x/0.5x viewport diagnosis\n --depth dom tree depth (default: auto, max 20)\n --max-nodes node count cap (default 60)\n --up-to ancestor stop tag (default html)\n --state path to saved state file (cookies + localstorage)\n --brief compact output: tree sketch + warnings/errors only\n --layout ascii layout diagram showing element positions and sizes\n --wait wait for user interaction before collecting (implies --headed)\n --viewport viewport size as wxh (e.g. 375x812, default 1280x720)\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
|
|
6
6
|
"flags": {
|
|
7
7
|
"json": "boolean",
|
|
8
8
|
"headed": "boolean",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"state": "string",
|
|
15
15
|
"brief": "boolean",
|
|
16
16
|
"layout": "boolean",
|
|
17
|
-
"wait": "boolean"
|
|
17
|
+
"wait": "boolean",
|
|
18
|
+
"viewport": "string"
|
|
18
19
|
},
|
|
19
20
|
"args": [
|
|
20
21
|
"url",
|
|
@@ -42,11 +43,12 @@
|
|
|
42
43
|
]
|
|
43
44
|
},
|
|
44
45
|
"interactive": {
|
|
45
|
-
"help": "cssprobe-cli interactive <url>\n\nOpen browser and inspect interactively (REPL mode)\n\nArguments:\n <url> url, file:// path, or local html file path\nOptions:\n --browser browser engine (default chromium)\n --state path to saved state file (cookies + localstorage)\n --depth dom tree depth (default: auto, max 20)\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
|
|
46
|
+
"help": "cssprobe-cli interactive <url>\n\nOpen browser and inspect interactively (REPL mode)\n\nArguments:\n <url> url, file:// path, or local html file path\nOptions:\n --browser browser engine (default chromium)\n --state path to saved state file (cookies + localstorage)\n --depth dom tree depth (default: auto, max 20)\n --viewport viewport size as wxh (e.g. 375x812, default 1280x720)\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
|
|
46
47
|
"flags": {
|
|
47
48
|
"browser": "string",
|
|
48
49
|
"state": "string",
|
|
49
|
-
"depth": "string"
|
|
50
|
+
"depth": "string",
|
|
51
|
+
"viewport": "string"
|
|
50
52
|
},
|
|
51
53
|
"args": [
|
|
52
54
|
"url"
|
|
@@ -60,7 +62,7 @@
|
|
|
60
62
|
"args": []
|
|
61
63
|
},
|
|
62
64
|
"config-set": {
|
|
63
|
-
"help": "cssprobe-cli config-set <key> <value>\n\nSet a configuration value\n\nArguments:\n <key> config key (browser, depth, headed)\n <value> config value\nOptions:\n --profile profile name",
|
|
65
|
+
"help": "cssprobe-cli config-set <key> <value>\n\nSet a configuration value\n\nArguments:\n <key> config key (browser, depth, headed, viewport)\n <value> config value\nOptions:\n --profile profile name",
|
|
64
66
|
"flags": {
|
|
65
67
|
"profile": "string"
|
|
66
68
|
},
|
|
@@ -238,12 +238,13 @@ confidence: DEFINITE 8 | INDEFINITE 0 | UNVERIFIABLE 1
|
|
|
238
238
|
export CSSPROBE_BROWSER=chromium
|
|
239
239
|
export CSSPROBE_DEPTH=6
|
|
240
240
|
export CSSPROBE_HEADED=true
|
|
241
|
+
export CSSPROBE_VIEWPORT=375x812
|
|
241
242
|
export CSSPROBE_PROFILE=default
|
|
242
243
|
```
|
|
243
244
|
|
|
244
245
|
Priority (highest to lowest):
|
|
245
|
-
1. CLI flags: `--browser`, `--depth`, `--headed`
|
|
246
|
-
2. Environment variables: `CSSPROBE_BROWSER`, `CSSPROBE_DEPTH`, `CSSPROBE_HEADED`
|
|
246
|
+
1. CLI flags: `--browser`, `--depth`, `--headed`, `--viewport`
|
|
247
|
+
2. Environment variables: `CSSPROBE_BROWSER`, `CSSPROBE_DEPTH`, `CSSPROBE_HEADED`, `CSSPROBE_VIEWPORT`
|
|
247
248
|
3. Config file: `~/.cssprobe-clirc`
|
|
248
249
|
|
|
249
250
|
---
|
package/package.json
CHANGED