cssprobe-cli 0.2.7 → 0.2.8

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/AGENTS.md CHANGED
@@ -55,6 +55,7 @@ src/
55
55
 
56
56
  ### Session Management
57
57
  - `open [url]` — Open browser in session mode (non-blocking)
58
+ - `--viewport <WxH>` — Set viewport size (e.g. `--viewport 1280x720`)
58
59
  - `close` — Close the browser session
59
60
  - `status` — Show current session status
60
61
 
@@ -68,8 +69,10 @@ src/
68
69
  - `inject-css <css>` — Inject CSS into the current page
69
70
 
70
71
  ### Browser
72
+ - `resize <width> <height>` — Resize browser viewport
73
+ - `eval <expression>` — Evaluate JavaScript (browser context)
74
+ - `playwright <call>` — Execute Playwright API call (Node.js context)
71
75
  - `screenshot` — Take a screenshot
72
- - `eval <expression>` — Evaluate JavaScript
73
76
 
74
77
  ### State
75
78
  - `state-import [file]` — Import cookies from Netscape format
package/README.md CHANGED
@@ -26,6 +26,9 @@ cssprobe-cli skill-install
26
26
  # Open browser (non-blocking, starts daemon session)
27
27
  cssprobe-cli open https://getbootstrap.com/docs/5.3/examples/checkout
28
28
 
29
+ # Open with custom viewport
30
+ cssprobe-cli open https://example.com --viewport 1280x720
31
+
29
32
  # Inspect with CSS selector
30
33
  cssprobe-cli inspect .container
31
34
 
@@ -113,6 +116,7 @@ cssprobe-cli close
113
116
 
114
117
  ```bash
115
118
  cssprobe-cli open [url] # Open browser in session mode (non-blocking)
119
+ cssprobe-cli open [url] --viewport 1280x720 # Open with custom viewport
116
120
  cssprobe-cli close # Close browser session
117
121
  cssprobe-cli status # Show session status
118
122
  ```
@@ -135,8 +139,10 @@ cssprobe-cli inject-css <css> # Inject CSS into current page
135
139
  ### Browser
136
140
 
137
141
  ```bash
142
+ cssprobe-cli resize <width> <height> # Resize browser viewport
143
+ cssprobe-cli eval <expression> # Evaluate JavaScript (browser context)
144
+ cssprobe-cli playwright <call> # Execute Playwright API (Node.js context)
138
145
  cssprobe-cli screenshot # Take screenshot
139
- cssprobe-cli eval <expression> # Evaluate JavaScript
140
146
  ```
141
147
 
142
148
  ### State
@@ -55,6 +55,7 @@ const open = (0, command_1.declareCommand)({
55
55
  options: z.object({
56
56
  browser: z.enum(['chromium', 'firefox', 'webkit']).optional().describe('browser engine (default chromium)'),
57
57
  headed: z.boolean().optional().describe('show the browser window'),
58
+ viewport: z.string().optional().describe('viewport size as WxH (e.g. 1280x720)'),
58
59
  }),
59
60
  });
60
61
  const close = (0, command_1.declareCommand)({
@@ -126,14 +127,31 @@ const screenshot = (0, command_1.declareCommand)({
126
127
  'full-page': z.boolean().optional().describe('take screenshot of the full scrollable page'),
127
128
  }),
128
129
  });
130
+ const resize = (0, command_1.declareCommand)({
131
+ name: 'resize',
132
+ category: 'core',
133
+ description: 'Resize the browser viewport',
134
+ args: z.object({
135
+ width: numberArg.describe('viewport width'),
136
+ height: numberArg.describe('viewport height'),
137
+ }),
138
+ });
129
139
  const evalCmd = (0, command_1.declareCommand)({
130
140
  name: 'eval',
131
141
  category: 'core',
132
- description: 'Evaluate JavaScript expression on the page',
142
+ description: 'Evaluate JavaScript expression on the page (browser context)',
133
143
  args: z.object({
134
144
  expression: z.string().describe('JavaScript expression to evaluate'),
135
145
  }),
136
146
  });
147
+ const playwrightCmd = (0, command_1.declareCommand)({
148
+ name: 'playwright',
149
+ category: 'core',
150
+ description: 'Execute Playwright API call (Node.js context)',
151
+ args: z.object({
152
+ call: z.string().describe('Playwright API call, e.g. "page.setViewportSize({width: 1280, height: 720})"'),
153
+ }),
154
+ });
137
155
  // ── state management ──
138
156
  const stateImport = (0, command_1.declareCommand)({
139
157
  name: 'state-import',
@@ -222,7 +240,7 @@ const commandsArray = [
222
240
  // cssprobe
223
241
  inspect, tree, layout, findings, injectCss,
224
242
  // browser
225
- screenshot, evalCmd,
243
+ resize, evalCmd, playwrightCmd, screenshot,
226
244
  // state
227
245
  stateImport,
228
246
  // config
@@ -58,6 +58,8 @@ async function program() {
58
58
  case 'inject-css':
59
59
  case 'screenshot':
60
60
  case 'eval':
61
+ case 'resize':
62
+ case 'playwright':
61
63
  await handleSessionCommand(commandName, command, rawArgs, output);
62
64
  return;
63
65
  }
@@ -109,10 +111,28 @@ async function handleOpen(command, args, output) {
109
111
  const url = parsed.url || 'about:blank';
110
112
  const browser = parsed.browser || 'chromium';
111
113
  const headed = !!parsed.headed;
114
+ const viewportStr = parsed.viewport;
115
+ // Parse viewport
116
+ let viewport;
117
+ if (viewportStr) {
118
+ const parts = viewportStr.split('x');
119
+ if (parts.length !== 2) {
120
+ output.error('Invalid viewport format. Use WxH (e.g. 1280x720)');
121
+ return;
122
+ }
123
+ const width = parseInt(parts[0], 10);
124
+ const height = parseInt(parts[1], 10);
125
+ if (isNaN(width) || isNaN(height)) {
126
+ output.error('Invalid viewport dimensions. Must be numbers.');
127
+ return;
128
+ }
129
+ viewport = { width, height };
130
+ }
112
131
  // Start daemon
113
132
  const { pid } = await session_1.Session.startDaemon({
114
133
  browser,
115
134
  headed,
135
+ viewport,
116
136
  _: ['open', url],
117
137
  }, 'open');
118
138
  // Wait a bit for daemon to start
@@ -126,6 +146,7 @@ async function handleOpen(command, args, output) {
126
146
  sessionId: 'default',
127
147
  pid,
128
148
  url,
149
+ viewport: viewport || { width: 1280, height: 720 },
129
150
  };
130
151
  if (output.json) {
131
152
  console.log(JSON.stringify(result, null, 2));
@@ -134,6 +155,7 @@ async function handleOpen(command, args, output) {
134
155
  console.log(`Browser opened at ${url}`);
135
156
  console.log(`Session ID: default`);
136
157
  console.log(`PID: ${pid}`);
158
+ console.log(`Viewport: ${viewport?.width || 1280}x${viewport?.height || 720}`);
137
159
  }
138
160
  }
139
161
  catch (e) {
@@ -7,5 +7,9 @@ import type { ClientInfo } from './session';
7
7
  export interface DaemonOptions {
8
8
  headed?: boolean;
9
9
  browser?: string;
10
+ viewport?: {
11
+ width: number;
12
+ height: number;
13
+ };
10
14
  }
11
15
  export declare function startDaemon(sessionName: string, clientInfo: ClientInfo, options: DaemonOptions): Promise<string>;
@@ -16,6 +16,7 @@ const socketConnection_1 = require("../utils/socketConnection");
16
16
  const launcher_1 = require("../browser/launcher");
17
17
  const analyzer_1 = require("../engine/analyzer");
18
18
  const renderer_1 = require("../engine/renderer");
19
+ const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
19
20
  async function startDaemon(sessionName, clientInfo, options) {
20
21
  const sessionConfig = createSessionConfig(clientInfo, sessionName, options);
21
22
  const { socketPath } = sessionConfig;
@@ -32,6 +33,7 @@ async function startDaemon(sessionName, clientInfo, options) {
32
33
  const launcher = new launcher_1.BrowserLauncher({
33
34
  browser: options.browser || 'chromium',
34
35
  headed: options.headed !== false,
36
+ viewport: options.viewport,
35
37
  });
36
38
  const server = net_1.default.createServer(socket => {
37
39
  const connection = new socketConnection_1.SocketConnection(socket);
@@ -173,6 +175,30 @@ async function executeCommand(launcher, args) {
173
175
  const result = await page.evaluate(expression);
174
176
  return { text: JSON.stringify(result, null, 2) };
175
177
  }
178
+ case 'resize': {
179
+ const width = parseInt(params[0], 10);
180
+ const height = parseInt(params[1], 10);
181
+ if (isNaN(width) || isNaN(height))
182
+ throw new Error('Usage: cssprobe-cli resize <width> <height>');
183
+ const page = launcher.getPage();
184
+ if (!page)
185
+ throw new Error('Browser is not open. Run: cssprobe-cli open <url>');
186
+ await page.setViewportSize({ width, height });
187
+ return { text: JSON.stringify({ width, height }) };
188
+ }
189
+ case 'playwright': {
190
+ const call = params[0];
191
+ if (!call)
192
+ throw new Error('Playwright API call is required');
193
+ const page = launcher.getPage();
194
+ if (!page)
195
+ throw new Error('Browser is not open. Run: cssprobe-cli open <url>');
196
+ // Create a safe eval context with page and browser objects
197
+ const asyncFunction = new AsyncFunction('page', 'browser', `return ${call}`);
198
+ const browser = page.context().browser();
199
+ const result = await asyncFunction(page, browser);
200
+ return { text: JSON.stringify(result, null, 2) };
201
+ }
176
202
  default:
177
203
  throw new Error(`Unknown command: ${command}`);
178
204
  }
@@ -31,7 +31,7 @@ var require_package = __commonJS({
31
31
  "package.json"(exports2, module2) {
32
32
  module2.exports = {
33
33
  name: "cssprobe-cli",
34
- version: "0.2.7",
34
+ version: "0.2.8",
35
35
  description: "Runtime CSS probe \u2014 inspect layout, colors, backgrounds, fonts and more in a live browser. AI agents and shell automation.",
36
36
  keywords: [
37
37
  "css",
@@ -1169,6 +1169,8 @@ function renderJSON(snapshot, findings, brief = false) {
1169
1169
  }
1170
1170
 
1171
1171
  // src/daemon/daemon.ts
1172
+ var AsyncFunction = Object.getPrototypeOf(async function() {
1173
+ }).constructor;
1172
1174
  async function startDaemon(sessionName2, clientInfo, options2) {
1173
1175
  const sessionConfig = createSessionConfig(clientInfo, sessionName2, options2);
1174
1176
  const { socketPath } = sessionConfig;
@@ -1181,7 +1183,8 @@ async function startDaemon(sessionName2, clientInfo, options2) {
1181
1183
  }
1182
1184
  const launcher = new BrowserLauncher({
1183
1185
  browser: options2.browser || "chromium",
1184
- headed: options2.headed !== false
1186
+ headed: options2.headed !== false,
1187
+ viewport: options2.viewport
1185
1188
  });
1186
1189
  const server = import_net.default.createServer((socket) => {
1187
1190
  const connection = new SocketConnection(socket);
@@ -1320,6 +1323,29 @@ async function executeCommand(launcher, args2) {
1320
1323
  const result = await page.evaluate(expression);
1321
1324
  return { text: JSON.stringify(result, null, 2) };
1322
1325
  }
1326
+ case "resize": {
1327
+ const width = parseInt(params[0], 10);
1328
+ const height = parseInt(params[1], 10);
1329
+ if (isNaN(width) || isNaN(height))
1330
+ throw new Error("Usage: cssprobe-cli resize <width> <height>");
1331
+ const page = launcher.getPage();
1332
+ if (!page)
1333
+ throw new Error("Browser is not open. Run: cssprobe-cli open <url>");
1334
+ await page.setViewportSize({ width, height });
1335
+ return { text: JSON.stringify({ width, height }) };
1336
+ }
1337
+ case "playwright": {
1338
+ const call = params[0];
1339
+ if (!call)
1340
+ throw new Error("Playwright API call is required");
1341
+ const page = launcher.getPage();
1342
+ if (!page)
1343
+ throw new Error("Browser is not open. Run: cssprobe-cli open <url>");
1344
+ const asyncFunction = new AsyncFunction("page", "browser", `return ${call}`);
1345
+ const browser = page.context().browser();
1346
+ const result = await asyncFunction(page, browser);
1347
+ return { text: JSON.stringify(result, null, 2) };
1348
+ }
1323
1349
  default:
1324
1350
  throw new Error(`Unknown command: ${command}`);
1325
1351
  }
package/dist/help.json CHANGED
@@ -1,11 +1,12 @@
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 eval <expression> evaluate javascript expression on the page\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\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
- "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\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
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\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
6
6
  "flags": {
7
7
  "browser": "string",
8
- "headed": "boolean"
8
+ "headed": "boolean",
9
+ "viewport": "string"
9
10
  },
10
11
  "args": [
11
12
  "url"
@@ -63,20 +64,35 @@
63
64
  "css"
64
65
  ]
65
66
  },
66
- "screenshot": {
67
- "help": "cssprobe-cli screenshot \n\nTake a screenshot of the current page\n\nOptions:\n --full-page take screenshot of the full scrollable page\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
68
- "flags": {
69
- "full-page": "boolean"
70
- },
71
- "args": []
67
+ "resize": {
68
+ "help": "cssprobe-cli resize <width> <height>\n\nResize the browser viewport\n\nArguments:\n <width> viewport width\n <height> viewport height\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
69
+ "flags": {},
70
+ "args": [
71
+ "width",
72
+ "height"
73
+ ]
72
74
  },
73
75
  "eval": {
74
- "help": "cssprobe-cli eval <expression>\n\nEvaluate JavaScript expression on the page\n\nArguments:\n <expression> javascript expression to evaluate\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
76
+ "help": "cssprobe-cli eval <expression>\n\nEvaluate JavaScript expression on the page (browser context)\n\nArguments:\n <expression> javascript expression to evaluate\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
75
77
  "flags": {},
76
78
  "args": [
77
79
  "expression"
78
80
  ]
79
81
  },
82
+ "playwright": {
83
+ "help": "cssprobe-cli playwright <call>\n\nExecute Playwright API call (Node.js context)\n\nArguments:\n <call> playwright api call, e.g. \"page.setviewportsize({width: 1280, height: 720})\"\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
84
+ "flags": {},
85
+ "args": [
86
+ "call"
87
+ ]
88
+ },
89
+ "screenshot": {
90
+ "help": "cssprobe-cli screenshot \n\nTake a screenshot of the current page\n\nOptions:\n --full-page take screenshot of the full scrollable page\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
91
+ "flags": {
92
+ "full-page": "boolean"
93
+ },
94
+ "args": []
95
+ },
80
96
  "state-import": {
81
97
  "help": "cssprobe-cli state-import [file]\n\nImport cookies from Netscape format file\n\nArguments:\n [file] netscape cookie file path (reads from stdin if omitted)\nOptions:\n --out output state file path (default: ~/.cssprobe-cli/states/imported.json)\n --merge existing state file to merge into\n\nGlobal options:\n --json output as JSON\n --profile, -p <name> use named profile",
82
98
  "flags": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cssprobe-cli",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Runtime CSS probe — inspect layout, colors, backgrounds, fonts and more in a live browser. AI agents and shell automation.",
5
5
  "keywords": [
6
6
  "css",