chrome-cdp-cli 2.0.5 → 2.1.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.
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HelpSystem = void 0;
4
4
  const CommandSchemaRegistry_1 = require("./CommandSchemaRegistry");
5
5
  const colors = {
6
- reset: '\x1b[0m',
7
- bright: '\x1b[1m',
8
- dim: '\x1b[2m',
9
- red: '\x1b[31m',
10
- green: '\x1b[32m',
11
- yellow: '\x1b[33m',
12
- blue: '\x1b[34m',
13
- magenta: '\x1b[35m',
14
- cyan: '\x1b[36m',
15
- white: '\x1b[37m',
16
- gray: '\x1b[90m',
6
+ reset: "\x1b[0m",
7
+ bright: "\x1b[1m",
8
+ dim: "\x1b[2m",
9
+ red: "\x1b[31m",
10
+ green: "\x1b[32m",
11
+ yellow: "\x1b[33m",
12
+ blue: "\x1b[34m",
13
+ magenta: "\x1b[35m",
14
+ cyan: "\x1b[36m",
15
+ white: "\x1b[37m",
16
+ gray: "\x1b[90m",
17
17
  };
18
18
  const colorize = {
19
19
  title: (text) => `${colors.bright}${colors.cyan}${text}${colors.reset}`,
@@ -44,40 +44,40 @@ class HelpSystem {
44
44
  if (!command) {
45
45
  return this.generateCommandNotFoundHelp(commandName);
46
46
  }
47
- let help = '';
47
+ let help = "";
48
48
  help += `${command.name.toUpperCase()}\n`;
49
- help += '='.repeat(command.name.length) + '\n\n';
49
+ help += "=".repeat(command.name.length) + "\n\n";
50
50
  help += `${command.description}\n\n`;
51
51
  if (command.usage) {
52
- help += 'USAGE\n';
53
- help += '-----\n';
52
+ help += "USAGE\n";
53
+ help += "-----\n";
54
54
  help += `${command.usage}\n\n`;
55
55
  }
56
56
  if (command.arguments.length > 0) {
57
- help += 'ARGUMENTS\n';
58
- help += '---------\n';
57
+ help += "ARGUMENTS\n";
58
+ help += "---------\n";
59
59
  for (const arg of command.arguments) {
60
- const required = arg.required ? ' (required)' : ' (optional)';
61
- const variadic = arg.variadic ? '...' : '';
60
+ const required = arg.required ? " (required)" : " (optional)";
61
+ const variadic = arg.variadic ? "..." : "";
62
62
  help += ` ${arg.name}${variadic}${required.padStart(30 - arg.name.length - variadic.length)}\n`;
63
63
  help += ` ${arg.description}\n`;
64
- if (arg.type !== 'string') {
64
+ if (arg.type !== "string") {
65
65
  help += ` Type: ${arg.type}\n`;
66
66
  }
67
- help += '\n';
67
+ help += "\n";
68
68
  }
69
69
  }
70
70
  if (command.options.length > 0) {
71
- help += 'OPTIONS\n';
72
- help += '-------\n';
71
+ help += "OPTIONS\n";
72
+ help += "-------\n";
73
73
  for (const option of command.options) {
74
- const shortFlag = option.short ? `-${option.short}, ` : ' ';
74
+ const shortFlag = option.short ? `-${option.short}, ` : " ";
75
75
  const longFlag = `--${option.name}`;
76
- const negation = option.type === 'boolean' ? `, --no-${option.name}` : '';
76
+ const negation = option.type === "boolean" ? `, --no-${option.name}` : "";
77
77
  const flags = `${shortFlag}${longFlag}${negation}`;
78
78
  help += ` ${flags}\n`;
79
79
  help += ` ${option.description}\n`;
80
- if (option.type !== 'string') {
80
+ if (option.type !== "string") {
81
81
  help += ` Type: ${option.type}\n`;
82
82
  }
83
83
  if (option.required) {
@@ -87,56 +87,58 @@ class HelpSystem {
87
87
  help += ` Default: ${option.default}\n`;
88
88
  }
89
89
  if (option.choices && option.choices.length > 0) {
90
- help += ` Choices: ${option.choices.join(', ')}\n`;
90
+ help += ` Choices: ${option.choices.join(", ")}\n`;
91
91
  }
92
- help += '\n';
92
+ help += "\n";
93
93
  }
94
94
  }
95
95
  if (command.examples && command.examples.length > 0) {
96
- help += 'EXAMPLES\n';
97
- help += '--------\n';
96
+ help += "EXAMPLES\n";
97
+ help += "--------\n";
98
98
  for (let i = 0; i < command.examples.length; i++) {
99
99
  const example = command.examples[i];
100
- help += `${i + 1}. ${example.description || 'Example usage'}\n`;
100
+ help += `${i + 1}. ${example.description || "Example usage"}\n`;
101
101
  help += ` $ ${example.command}\n\n`;
102
102
  }
103
103
  }
104
104
  if (command.aliases.length > 0) {
105
- help += 'ALIASES\n';
106
- help += '-------\n';
107
- help += `${command.aliases.join(', ')}\n\n`;
105
+ help += "ALIASES\n";
106
+ help += "-------\n";
107
+ help += `${command.aliases.join(", ")}\n\n`;
108
108
  }
109
109
  const relatedTopics = this.getRelatedHelpTopics(commandName);
110
110
  if (relatedTopics.length > 0) {
111
- help += 'SEE ALSO\n';
112
- help += '--------\n';
113
- help += `Help topics: ${relatedTopics.join(', ')}\n`;
114
- help += `Use 'chrome-cdp-cli help topic <topic-name>' for more information\n\n`;
111
+ help += "SEE ALSO\n";
112
+ help += "--------\n";
113
+ help += `Help topics: ${relatedTopics.join(", ")}\n`;
114
+ help += `Use 'cdp help topic <topic-name>' for more information\n\n`;
115
115
  }
116
116
  return help.trim();
117
117
  }
118
118
  generateGeneralHelp() {
119
- let help = '';
120
- help += `${colorize.title('CHROME DEVTOOLS CLI - ENHANCED HELP SYSTEM')}\n`;
121
- help += `${colors.cyan}${'='.repeat(42)}${colors.reset}\n\n`;
122
- help += 'A powerful command-line interface for Chrome DevTools Protocol automation.\n\n';
123
- help += `${colorize.section('USAGE')}\n`;
124
- help += `${colors.blue}${'-'.repeat(5)}${colors.reset}\n`;
125
- help += `${colorize.command('chrome-cdp-cli')} [global-options] <command> [command-options] [arguments]\n\n`;
126
- help += `${colorize.section('GLOBAL OPTIONS')}\n`;
127
- help += `${colors.blue}${'-'.repeat(15)}${colors.reset}\n`;
128
- help += ` ${colorize.option('-h, --host <host>')} Chrome host address (default: localhost)\n`;
129
- help += ` ${colorize.option('-p, --port <port>')} DevTools port (default: 9222)\n`;
130
- help += ` ${colorize.option('-f, --format <format>')} Output format: json|text (default: text)\n`;
131
- help += ` ${colorize.option('-v, --verbose')} Enable verbose logging\n`;
132
- help += ` ${colorize.option('--no-verbose')} Disable verbose logging\n`;
133
- help += ` ${colorize.option('-q, --quiet')} Enable quiet mode\n`;
134
- help += ` ${colorize.option('--no-quiet')} Disable quiet mode\n`;
135
- help += ` ${colorize.option('-t, --timeout <ms>')} Command timeout in milliseconds (default: 30000)\n`;
136
- help += ` ${colorize.option('-d, --debug')} Enable debug logging\n`;
137
- help += ` ${colorize.option('--no-debug')} Disable debug logging\n`;
138
- help += ` ${colorize.option('-c, --config <path>')} Configuration file path\n`;
139
- help += ` ${colorize.option('--version')} Show version number\n\n`;
119
+ let help = "";
120
+ help += `${colorize.title("CDP - Chrome DevTools Protocol CLI")}\n`;
121
+ help += `${colors.cyan}${"=".repeat(35)}${colors.reset}\n\n`;
122
+ help +=
123
+ "A command-line interface for Chrome DevTools Protocol automation.\n\n";
124
+ help += `${colorize.section("USAGE")}\n`;
125
+ help += `${colors.blue}${"-".repeat(5)}${colors.reset}\n`;
126
+ help += `${colorize.command("cdp")} [global-options] <command> [command-options] [arguments]\n\n`;
127
+ help += `${colorize.section("GLOBAL OPTIONS")}\n`;
128
+ help += `${colors.blue}${"-".repeat(15)}${colors.reset}\n`;
129
+ help += ` ${colorize.option("-h, --host <host>")} Chrome host address (default: localhost)\n`;
130
+ help += ` ${colorize.option("-p, --port <port>")} DevTools port (default: 9222)\n`;
131
+ help += ` ${colorize.option("-f, --format <format>")} Output format: json|text (default: text)\n`;
132
+ help += ` ${colorize.option("-v, --verbose")} Enable verbose logging\n`;
133
+ help += ` ${colorize.option("--no-verbose")} Disable verbose logging\n`;
134
+ help += ` ${colorize.option("-q, --quiet")} Enable quiet mode\n`;
135
+ help += ` ${colorize.option("--no-quiet")} Disable quiet mode\n`;
136
+ help += ` ${colorize.option("-t, --timeout <ms>")} Command timeout in milliseconds (default: 30000)\n`;
137
+ help += ` ${colorize.option("-d, --debug")} Enable debug logging\n`;
138
+ help += ` ${colorize.option("--no-debug")} Disable debug logging\n`;
139
+ help += ` ${colorize.option("-c, --config <path>")} Configuration file path\n`;
140
+ help += ` ${colorize.option("-i, --target-index <n>")} Target page index, 1-based, excludes DevTools windows\n`;
141
+ help += ` ${colorize.option("--version")} Show version number\n\n`;
140
142
  let commands;
141
143
  if (this.argumentParser && this.argumentParser.getCommands) {
142
144
  commands = this.argumentParser.getCommands();
@@ -145,25 +147,49 @@ class HelpSystem {
145
147
  commands = this.schemaRegistry.getAllCommands();
146
148
  }
147
149
  const categorizedCommands = this.categorizeCommands(commands);
148
- help += `${colorize.section('AVAILABLE COMMANDS')}\n`;
149
- help += `${colors.blue}${'-'.repeat(18)}${colors.reset}\n`;
150
- for (const [categoryName, categoryCommands] of categorizedCommands) {
150
+ const categoryOrder = [
151
+ "Help & Information",
152
+ "JavaScript Execution",
153
+ "Page Capture",
154
+ "Monitoring & Debugging",
155
+ "User Interaction",
156
+ "Navigation & Timing",
157
+ "Installation & Setup",
158
+ "General",
159
+ ];
160
+ const orderedCategories = [];
161
+ for (const cat of categoryOrder) {
162
+ if (categorizedCommands.has(cat)) {
163
+ orderedCategories.push([cat, categorizedCommands.get(cat)]);
164
+ }
165
+ }
166
+ for (const [cat, cmds] of categorizedCommands) {
167
+ if (!categoryOrder.includes(cat)) {
168
+ orderedCategories.push([cat, cmds]);
169
+ }
170
+ }
171
+ help += `${colorize.section("AVAILABLE COMMANDS")}\n`;
172
+ help += `${colors.blue}${"-".repeat(18)}${colors.reset}\n`;
173
+ for (const [categoryName, categoryCommands] of orderedCategories) {
151
174
  help += `\n${colorize.category(categoryName)}:\n`;
152
175
  for (const command of categoryCommands) {
153
176
  const commandName = colorize.command(command.name);
154
- const aliases = command.aliases.length > 0 ? ` ${colorize.alias(`(${command.aliases.join(', ')})`)}` : '';
177
+ const aliases = command.aliases.length > 0
178
+ ? ` ${colorize.alias(`(${command.aliases.join(", ")})`)}`
179
+ : "";
155
180
  const namePadding = Math.max(0, 20 - command.name.length);
156
- const aliasText = command.aliases.length > 0 ? `(${command.aliases.join(', ')})` : '';
181
+ const aliasText = command.aliases.length > 0 ? `(${command.aliases.join(", ")})` : "";
157
182
  const aliasPadding = Math.max(0, 15 - aliasText.length);
158
- help += ` ${commandName}${' '.repeat(namePadding)}${aliases}${' '.repeat(aliasPadding)} ${command.description}\n`;
183
+ help += ` ${commandName}${" ".repeat(namePadding)}${aliases}${" ".repeat(aliasPadding)} ${command.description}\n`;
159
184
  }
160
185
  }
161
- help += `\n${colorize.section('GETTING MORE HELP')}\n`;
162
- help += `${colors.blue}${'-'.repeat(18)}${colors.reset}\n`;
163
- help += 'For detailed help on a specific command:\n';
164
- help += ` ${colorize.command('chrome-cdp-cli')} ${colorize.option('help')} <command>\n\n`;
165
- help += 'For contextual help when commands fail:\n';
166
- help += ' Commands automatically show relevant help suggestions on errors\n\n';
186
+ help += `\n${colorize.section("GETTING MORE HELP")}\n`;
187
+ help += `${colors.blue}${"-".repeat(18)}${colors.reset}\n`;
188
+ help += "For detailed help on a specific command:\n";
189
+ help += ` ${colorize.command("cdp")} ${colorize.option("help")} <command>\n\n`;
190
+ help += "For contextual help when commands fail:\n";
191
+ help +=
192
+ " Commands automatically show relevant help suggestions on errors\n\n";
167
193
  return help.trim();
168
194
  }
169
195
  generateTopicHelp(topicName) {
@@ -171,70 +197,72 @@ class HelpSystem {
171
197
  if (!topic) {
172
198
  return this.generateTopicNotFoundHelp(topicName);
173
199
  }
174
- let help = '';
200
+ let help = "";
175
201
  help += `${topic.title.toUpperCase()}\n`;
176
- help += '='.repeat(topic.title.length) + '\n\n';
202
+ help += "=".repeat(topic.title.length) + "\n\n";
177
203
  help += `${topic.content}\n\n`;
178
204
  if (topic.examples && topic.examples.length > 0) {
179
- help += 'EXAMPLES\n';
180
- help += '--------\n';
205
+ help += "EXAMPLES\n";
206
+ help += "--------\n";
181
207
  for (let i = 0; i < topic.examples.length; i++) {
182
208
  help += `${i + 1}. ${topic.examples[i]}\n`;
183
209
  }
184
- help += '\n';
210
+ help += "\n";
185
211
  }
186
212
  if (topic.seeAlso && topic.seeAlso.length > 0) {
187
- help += 'SEE ALSO\n';
188
- help += '--------\n';
189
- help += `${topic.seeAlso.join(', ')}\n\n`;
213
+ help += "SEE ALSO\n";
214
+ help += "--------\n";
215
+ help += `${topic.seeAlso.join(", ")}\n\n`;
190
216
  }
191
217
  return help.trim();
192
218
  }
193
219
  generateContextualHelp(error, commandName) {
194
- let help = '';
220
+ let help = "";
195
221
  const suggestions = this.findContextualSuggestions(error, commandName);
196
222
  if (suggestions.length === 0) {
197
- help += 'HELP SUGGESTIONS\n';
198
- help += '----------------\n';
199
- help += 'No specific suggestions available for this error.\n\n';
200
- help += 'Try:\n';
201
- help += ' - Check command syntax with: chrome-cdp-cli help <command>\n';
202
- help += ' - Verify Chrome is running with --remote-debugging-port=9222\n';
203
- help += ' - Use --debug flag for detailed error information\n\n';
223
+ help += "HELP SUGGESTIONS\n";
224
+ help += "----------------\n";
225
+ help += "No specific suggestions available for this error.\n\n";
226
+ help += "Try:\n";
227
+ help += " - Check command syntax with: cdp help <command>\n";
228
+ help +=
229
+ " - Verify Chrome is running with --remote-debugging-port=9222\n";
230
+ help += " - Use --debug flag for detailed error information\n\n";
204
231
  }
205
232
  else {
206
- help += 'HELP SUGGESTIONS\n';
207
- help += '----------------\n';
233
+ help += "HELP SUGGESTIONS\n";
234
+ help += "----------------\n";
208
235
  for (let i = 0; i < suggestions.length; i++) {
209
236
  const suggestion = suggestions[i];
210
237
  help += `${i + 1}. ${suggestion.suggestion}\n`;
211
238
  if (suggestion.example) {
212
239
  help += ` Example: ${suggestion.example}\n`;
213
240
  }
214
- if (suggestion.relatedCommands && suggestion.relatedCommands.length > 0) {
215
- help += ` Related commands: ${suggestion.relatedCommands.join(', ')}\n`;
241
+ if (suggestion.relatedCommands &&
242
+ suggestion.relatedCommands.length > 0) {
243
+ help += ` Related commands: ${suggestion.relatedCommands.join(", ")}\n`;
216
244
  }
217
- help += '\n';
245
+ help += "\n";
218
246
  }
219
247
  }
220
248
  if (commandName) {
221
249
  help += `For detailed help on '${commandName}' command:\n`;
222
- help += ` chrome-cdp-cli help ${commandName}\n\n`;
250
+ help += ` cdp help ${commandName}\n\n`;
223
251
  }
224
252
  return help.trim();
225
253
  }
226
254
  generateCommandNotFoundHelp(commandName) {
227
- let help = '';
255
+ let help = "";
228
256
  help += `ERROR: Unknown command '${commandName}'\n\n`;
229
257
  const similarCommands = this.findSimilarCommands(commandName);
230
258
  if (similarCommands.length > 0) {
231
- help += 'Did you mean:\n';
259
+ help += "Did you mean:\n";
232
260
  for (const similar of similarCommands) {
233
261
  help += ` ${similar}\n`;
234
262
  }
235
- help += '\n';
263
+ help += "\n";
236
264
  }
237
- help += 'Available commands:\n';
265
+ help += "Available commands:\n";
238
266
  let commands;
239
267
  if (this.argumentParser && this.argumentParser.getCommands) {
240
268
  commands = this.argumentParser.getCommands();
@@ -245,20 +273,20 @@ class HelpSystem {
245
273
  for (const command of commands.sort((a, b) => a.name.localeCompare(b.name))) {
246
274
  help += ` ${command.name.padEnd(20)} ${command.description}\n`;
247
275
  }
248
- help += '\nFor more information:\n';
249
- help += ' chrome-cdp-cli help\n';
276
+ help += "\nFor more information:\n";
277
+ help += " cdp help\n";
250
278
  return help;
251
279
  }
252
280
  generateTopicNotFoundHelp(topicName) {
253
- let help = '';
281
+ let help = "";
254
282
  help += `ERROR: Unknown help topic '${topicName}'\n\n`;
255
- help += 'Available help topics:\n';
283
+ help += "Available help topics:\n";
256
284
  const topics = Array.from(this.helpTopics.values()).sort((a, b) => a.name.localeCompare(b.name));
257
285
  for (const topic of topics) {
258
286
  help += ` ${topic.name.padEnd(20)} ${topic.description}\n`;
259
287
  }
260
- help += '\nUsage:\n';
261
- help += ' chrome-cdp-cli help topic <topic-name>\n';
288
+ help += "\nUsage:\n";
289
+ help += " cdp help topic <topic-name>\n";
262
290
  return help;
263
291
  }
264
292
  findSimilarCommands(commandName) {
@@ -271,7 +299,8 @@ class HelpSystem {
271
299
  }
272
300
  const similar = [];
273
301
  for (const command of commands) {
274
- if (command.name.includes(commandName) || commandName.includes(command.name)) {
302
+ if (command.name.includes(commandName) ||
303
+ commandName.includes(command.name)) {
275
304
  similar.push(command.name);
276
305
  }
277
306
  for (const alias of command.aliases) {
@@ -301,28 +330,29 @@ class HelpSystem {
301
330
  categorizeCommands(commands) {
302
331
  const categories = new Map();
303
332
  for (const command of commands) {
304
- let category = 'General';
305
- if (['eval', 'execute', 'js'].includes(command.name)) {
306
- category = 'JavaScript Execution';
333
+ let category = "General";
334
+ if (["eval", "execute", "js"].includes(command.name)) {
335
+ category = "JavaScript Execution";
307
336
  }
308
- else if (['screenshot', 'capture', 'snapshot', 'dom'].includes(command.name)) {
309
- category = 'Page Capture';
337
+ else if (["screenshot", "capture", "snapshot", "dom"].includes(command.name)) {
338
+ category = "Page Capture";
310
339
  }
311
- else if (['click', 'hover', 'fill', 'type', 'drag', 'press', 'upload'].includes(command.name)) {
312
- category = 'User Interaction';
340
+ else if (["log", "console", "network", "logs", "requests"].includes(command.name) ||
341
+ command.name.includes("console") ||
342
+ command.name.includes("network")) {
343
+ category = "Monitoring & Debugging";
313
344
  }
314
- else if (['console', 'network', 'logs', 'requests'].includes(command.name) ||
315
- command.name.includes('console') || command.name.includes('network')) {
316
- category = 'Monitoring & Debugging';
345
+ else if (["click", "hover", "fill", "type", "drag", "press", "upload"].includes(command.name)) {
346
+ category = "User Interaction";
317
347
  }
318
- else if (['navigate', 'goto', 'open', 'wait'].includes(command.name)) {
319
- category = 'Navigation & Timing';
348
+ else if (["navigate", "goto", "open", "wait"].includes(command.name)) {
349
+ category = "Navigation & Timing";
320
350
  }
321
- else if (command.name.includes('install')) {
322
- category = 'Installation & Setup';
351
+ else if (command.name.includes("install")) {
352
+ category = "Installation & Setup";
323
353
  }
324
- else if (['help', 'version'].includes(command.name)) {
325
- category = 'Help & Information';
354
+ else if (["help", "version"].includes(command.name)) {
355
+ category = "Help & Information";
326
356
  }
327
357
  if (!categories.has(category)) {
328
358
  categories.set(category, []);
@@ -337,15 +367,15 @@ class HelpSystem {
337
367
  getRelatedHelpTopics(commandName) {
338
368
  const related = [];
339
369
  const topicMappings = {
340
- 'eval': ['configuration', 'scripting'],
341
- 'screenshot': ['configuration', 'output-formats'],
342
- 'click': ['selectors', 'automation'],
343
- 'fill': ['selectors', 'automation'],
344
- 'hover': ['selectors', 'automation'],
345
- 'console_messages': ['monitoring', 'debugging'],
346
- 'network_requests': ['monitoring', 'debugging'],
347
- 'install_cursor_command': ['installation', 'integration'],
348
- 'install_claude_skill': ['installation', 'integration']
370
+ eval: ["configuration", "scripting"],
371
+ screenshot: ["configuration", "output-formats"],
372
+ click: ["selectors", "automation"],
373
+ fill: ["selectors", "automation"],
374
+ hover: ["selectors", "automation"],
375
+ console_messages: ["monitoring", "debugging"],
376
+ network_requests: ["monitoring", "debugging"],
377
+ install_cursor_command: ["installation", "integration"],
378
+ install_claude_skill: ["installation", "integration"],
349
379
  };
350
380
  const mappedTopics = topicMappings[commandName];
351
381
  if (mappedTopics) {
@@ -358,10 +388,10 @@ class HelpSystem {
358
388
  return related;
359
389
  }
360
390
  initializeHelpTopics() {
361
- this.helpTopics.set('configuration', {
362
- name: 'configuration',
363
- title: 'Configuration Management',
364
- description: 'Advanced configuration options and file formats',
391
+ this.helpTopics.set("configuration", {
392
+ name: "configuration",
393
+ title: "Configuration Management",
394
+ description: "Advanced configuration options and file formats",
365
395
  content: `The Chrome DevTools CLI supports multiple configuration sources with a clear precedence order:
366
396
 
367
397
  1. Command-line arguments (highest priority)
@@ -378,16 +408,16 @@ Configuration files can be in YAML or JSON format and support:
378
408
 
379
409
  Environment variables follow the pattern CDP_<OPTION_NAME> (e.g., CDP_HOST, CDP_PORT).`,
380
410
  examples: [
381
- 'chrome-cdp-cli --config ~/.chrome-cdp-cli.yaml eval "document.title"',
382
- 'CDP_HOST=remote-chrome CDP_PORT=9223 chrome-cdp-cli screenshot',
383
- 'chrome-cdp-cli --profile production screenshot --full-page'
411
+ 'cdp --config ~/.cdp.yaml eval "document.title"',
412
+ "CDP_HOST=remote-chrome CDP_PORT=9223 cdp screenshot",
413
+ "cdp --profile production screenshot --full-page",
384
414
  ],
385
- seeAlso: ['profiles', 'environment-variables']
415
+ seeAlso: ["profiles", "environment-variables"],
386
416
  });
387
- this.helpTopics.set('selectors', {
388
- name: 'selectors',
389
- title: 'CSS Selectors Guide',
390
- description: 'Guide to using CSS selectors effectively',
417
+ this.helpTopics.set("selectors", {
418
+ name: "selectors",
419
+ title: "CSS Selectors Guide",
420
+ description: "Guide to using CSS selectors effectively",
391
421
  content: `CSS selectors are used to target elements for interaction commands like click, fill, and hover.
392
422
 
393
423
  Supported selector types:
@@ -403,16 +433,16 @@ Best practices:
403
433
  - Test selectors in browser DevTools first
404
434
  - Use :visible pseudo-selector for visible elements only`,
405
435
  examples: [
406
- 'chrome-cdp-cli click "#submit-button"',
407
- 'chrome-cdp-cli fill "[data-testid=username]" "user@example.com"',
408
- 'chrome-cdp-cli hover ".dropdown-menu > .first-item"'
436
+ 'cdp click "#submit-button"',
437
+ 'cdp fill "[data-testid=username]" "user@example.com"',
438
+ 'cdp hover ".dropdown-menu > .first-item"',
409
439
  ],
410
- seeAlso: ['automation', 'debugging']
440
+ seeAlso: ["automation", "debugging"],
411
441
  });
412
- this.helpTopics.set('automation', {
413
- name: 'automation',
414
- title: 'Browser Automation Best Practices',
415
- description: 'Guidelines for effective browser automation',
442
+ this.helpTopics.set("automation", {
443
+ name: "automation",
444
+ title: "Browser Automation Best Practices",
445
+ description: "Guidelines for effective browser automation",
416
446
  content: `Effective browser automation requires careful planning and robust selectors.
417
447
 
418
448
  Key principles:
@@ -428,15 +458,15 @@ Common patterns:
428
458
  - Take screenshots for debugging failed tests
429
459
  - Monitor console and network for errors`,
430
460
  examples: [
431
- 'chrome-cdp-cli navigate "https://example.com" && chrome-cdp-cli wait "#content" && chrome-cdp-cli click ".login"',
432
- 'chrome-cdp-cli fill "#username" "user" && chrome-cdp-cli fill "#password" "pass" && chrome-cdp-cli click "#login"'
461
+ 'cdp navigate "https://example.com" && cdp wait "#content" && cdp click ".login"',
462
+ 'cdp fill "#username" "user" && cdp fill "#password" "pass" && cdp click "#login"',
433
463
  ],
434
- seeAlso: ['selectors', 'debugging', 'scripting']
464
+ seeAlso: ["selectors", "debugging", "scripting"],
435
465
  });
436
- this.helpTopics.set('output-formats', {
437
- name: 'output-formats',
438
- title: 'Output Formats and Processing',
439
- description: 'Understanding different output formats and processing options',
466
+ this.helpTopics.set("output-formats", {
467
+ name: "output-formats",
468
+ title: "Output Formats and Processing",
469
+ description: "Understanding different output formats and processing options",
440
470
  content: `The CLI supports multiple output formats for different use cases:
441
471
 
442
472
  Text format (default):
@@ -459,16 +489,16 @@ Verbose mode:
459
489
  - Shows timing and performance data
460
490
  - Helpful for debugging and optimization`,
461
491
  examples: [
462
- 'chrome-cdp-cli --format json eval "document.title"',
463
- 'chrome-cdp-cli --quiet screenshot --filename result.png',
464
- 'chrome-cdp-cli --verbose --debug console_messages'
492
+ 'cdp --format json eval "document.title"',
493
+ "cdp --quiet screenshot --filename result.png",
494
+ "cdp --verbose --debug console_messages",
465
495
  ],
466
- seeAlso: ['configuration', 'scripting']
496
+ seeAlso: ["configuration", "scripting"],
467
497
  });
468
- this.helpTopics.set('debugging', {
469
- name: 'debugging',
470
- title: 'Debugging and Troubleshooting',
471
- description: 'Tools and techniques for debugging CLI issues',
498
+ this.helpTopics.set("debugging", {
499
+ name: "debugging",
500
+ title: "Debugging and Troubleshooting",
501
+ description: "Tools and techniques for debugging CLI issues",
472
502
  content: `When commands don't work as expected, use these debugging techniques:
473
503
 
474
504
  Debug mode (--debug):
@@ -492,16 +522,16 @@ Monitoring commands:
492
522
  - Use network_requests to verify API calls
493
523
  - Take screenshots to see current page state`,
494
524
  examples: [
495
- 'chrome-cdp-cli --debug --verbose click "#button"',
496
- 'chrome-cdp-cli console_messages --filter error',
497
- 'chrome-cdp-cli screenshot --filename debug.png'
525
+ 'cdp --debug --verbose click "#button"',
526
+ "cdp console_messages --filter error",
527
+ "cdp screenshot --filename debug.png",
498
528
  ],
499
- seeAlso: ['monitoring', 'automation']
529
+ seeAlso: ["monitoring", "automation"],
500
530
  });
501
- this.helpTopics.set('scripting', {
502
- name: 'scripting',
503
- title: 'Scripting and Integration',
504
- description: 'Using the CLI in scripts and automation workflows',
531
+ this.helpTopics.set("scripting", {
532
+ name: "scripting",
533
+ title: "Scripting and Integration",
534
+ description: "Using the CLI in scripts and automation workflows",
505
535
  content: `The CLI is designed for integration with shell scripts, CI/CD pipelines, and automation tools.
506
536
 
507
537
  Shell scripting tips:
@@ -524,15 +554,15 @@ CI/CD integration:
524
554
  - Capture screenshots on test failures
525
555
  - Monitor console errors in automated tests`,
526
556
  examples: [
527
- '#!/bin/bash\nif chrome-cdp-cli eval "document.readyState === \'complete\'"; then\n chrome-cdp-cli screenshot\nfi',
528
- 'chrome-cdp-cli --format json eval "performance.timing" | jq .data.loadEventEnd'
557
+ "#!/bin/bash\nif cdp eval \"document.readyState === 'complete'\"; then\n cdp screenshot\nfi",
558
+ 'cdp --format json eval "performance.timing" | jq .data.loadEventEnd',
529
559
  ],
530
- seeAlso: ['configuration', 'output-formats']
560
+ seeAlso: ["configuration", "output-formats"],
531
561
  });
532
- this.helpTopics.set('installation', {
533
- name: 'installation',
534
- title: 'Installation and Setup',
535
- description: 'Setting up the CLI and integrations',
562
+ this.helpTopics.set("installation", {
563
+ name: "installation",
564
+ title: "Installation and Setup",
565
+ description: "Setting up the CLI and integrations",
536
566
  content: `The CLI can be integrated with various development tools and IDEs.
537
567
 
538
568
  Chrome setup:
@@ -546,8 +576,8 @@ IDE integrations:
546
576
  - VS Code: Create custom tasks and snippets
547
577
 
548
578
  Configuration setup:
549
- - Create ~/.chrome-cdp-cli.yaml for global settings
550
- - Use project-specific .chrome-cdp-cli.yaml files
579
+ - Create ~/.cdp.yaml for global settings
580
+ - Use project-specific .cdp.yaml files
551
581
  - Set up environment variables for CI/CD
552
582
 
553
583
  Plugin development:
@@ -555,113 +585,113 @@ Plugin development:
555
585
  - Register commands with proper schemas
556
586
  - Include comprehensive help documentation`,
557
587
  examples: [
558
- 'chrome --remote-debugging-port=9222 --headless',
559
- 'chrome-cdp-cli install_cursor_command --target-directory ./commands',
560
- 'chrome-cdp-cli install_claude_skill --skill-type automation'
588
+ "chrome --remote-debugging-port=9222 --headless",
589
+ "cdp install_cursor_command --target-directory ./commands",
590
+ "cdp install_claude_skill --skill-type automation",
561
591
  ],
562
- seeAlso: ['configuration', 'integration']
592
+ seeAlso: ["configuration", "integration"],
563
593
  });
564
594
  }
565
595
  initializeContextualHelpers() {
566
- this.contextualHelpers.set('connection refused', [
596
+ this.contextualHelpers.set("connection refused", [
567
597
  {
568
- error: 'connection refused',
569
- suggestion: 'Make sure Chrome is running with remote debugging enabled',
570
- example: 'chrome --remote-debugging-port=9222',
571
- relatedCommands: ['help']
598
+ error: "connection refused",
599
+ suggestion: "Make sure Chrome is running with remote debugging enabled",
600
+ example: "chrome --remote-debugging-port=9222",
601
+ relatedCommands: ["help"],
572
602
  },
573
603
  {
574
- error: 'connection refused',
575
- suggestion: 'Check if the host and port are correct',
576
- example: 'chrome-cdp-cli --host localhost --port 9222 <command>',
577
- relatedCommands: ['help']
578
- }
604
+ error: "connection refused",
605
+ suggestion: "Check if the host and port are correct",
606
+ example: "cdp --host localhost --port 9222 <command>",
607
+ relatedCommands: ["help"],
608
+ },
579
609
  ]);
580
- this.contextualHelpers.set('element not found', [
610
+ this.contextualHelpers.set("element not found", [
581
611
  {
582
- error: 'element not found',
583
- suggestion: 'Verify the CSS selector in browser DevTools',
612
+ error: "element not found",
613
+ suggestion: "Verify the CSS selector in browser DevTools",
584
614
  example: 'Open DevTools → Console → document.querySelector("#your-selector")',
585
- relatedCommands: ['help topic selectors']
615
+ relatedCommands: ["help topic selectors"],
586
616
  },
587
617
  {
588
- error: 'element not found',
589
- suggestion: 'Wait for the page to load completely before interacting',
590
- example: 'chrome-cdp-cli wait "#element" && chrome-cdp-cli click "#element"',
591
- relatedCommands: ['wait']
592
- }
618
+ error: "element not found",
619
+ suggestion: "Wait for the page to load completely before interacting",
620
+ example: 'cdp wait "#element" && cdp click "#element"',
621
+ relatedCommands: ["wait"],
622
+ },
593
623
  ]);
594
- this.contextualHelpers.set('timeout', [
624
+ this.contextualHelpers.set("timeout", [
595
625
  {
596
- error: 'timeout',
597
- suggestion: 'Increase the timeout value for slow operations',
598
- example: 'chrome-cdp-cli --timeout 60000 <command>',
599
- relatedCommands: ['help']
626
+ error: "timeout",
627
+ suggestion: "Increase the timeout value for slow operations",
628
+ example: "cdp --timeout 60000 <command>",
629
+ relatedCommands: ["help"],
600
630
  },
601
631
  {
602
- error: 'timeout',
603
- suggestion: 'Check if the page is loading or if there are network issues',
604
- example: 'chrome-cdp-cli console_messages --filter error',
605
- relatedCommands: ['console_messages', 'network_requests']
606
- }
632
+ error: "timeout",
633
+ suggestion: "Check if the page is loading or if there are network issues",
634
+ example: "cdp console_messages --filter error",
635
+ relatedCommands: ["console_messages", "network_requests"],
636
+ },
607
637
  ]);
608
- this.contextualHelpers.set('parse error', [
638
+ this.contextualHelpers.set("parse error", [
609
639
  {
610
- error: 'parse error',
611
- suggestion: 'Check command syntax and argument order',
612
- example: 'chrome-cdp-cli help <command-name>',
613
- relatedCommands: ['help']
640
+ error: "parse error",
641
+ suggestion: "Check command syntax and argument order",
642
+ example: "cdp help <command-name>",
643
+ relatedCommands: ["help"],
614
644
  },
615
645
  {
616
- error: 'parse error',
617
- suggestion: 'Use quotes around arguments containing spaces or special characters',
618
- example: 'chrome-cdp-cli eval "document.querySelector(\'.my-class\')"',
619
- relatedCommands: ['help topic scripting']
620
- }
646
+ error: "parse error",
647
+ suggestion: "Use quotes around arguments containing spaces or special characters",
648
+ example: "cdp eval \"document.querySelector('.my-class')\"",
649
+ relatedCommands: ["help topic scripting"],
650
+ },
621
651
  ]);
622
- this.contextualHelpers.set('validation failed', [
652
+ this.contextualHelpers.set("validation failed", [
623
653
  {
624
- error: 'validation failed',
625
- suggestion: 'Check required arguments and option types',
626
- example: 'chrome-cdp-cli help <command-name>',
627
- relatedCommands: ['help']
654
+ error: "validation failed",
655
+ suggestion: "Check required arguments and option types",
656
+ example: "cdp help <command-name>",
657
+ relatedCommands: ["help"],
628
658
  },
629
659
  {
630
- error: 'validation failed',
631
- suggestion: 'Ensure file paths exist and URLs are valid',
632
- example: 'ls -la /path/to/file.js',
633
- relatedCommands: ['help topic debugging']
634
- }
660
+ error: "validation failed",
661
+ suggestion: "Ensure file paths exist and URLs are valid",
662
+ example: "ls -la /path/to/file.js",
663
+ relatedCommands: ["help topic debugging"],
664
+ },
635
665
  ]);
636
- this.contextualHelpers.set('permission denied', [
666
+ this.contextualHelpers.set("permission denied", [
637
667
  {
638
- error: 'permission denied',
639
- suggestion: 'Check file permissions and directory access',
640
- example: 'chmod +r /path/to/file',
641
- relatedCommands: ['help topic debugging']
668
+ error: "permission denied",
669
+ suggestion: "Check file permissions and directory access",
670
+ example: "chmod +r /path/to/file",
671
+ relatedCommands: ["help topic debugging"],
642
672
  },
643
673
  {
644
- error: 'permission denied',
645
- suggestion: 'Ensure the target directory exists and is writable',
646
- example: 'mkdir -p /path/to/directory && chmod +w /path/to/directory',
647
- relatedCommands: ['help topic installation']
648
- }
674
+ error: "permission denied",
675
+ suggestion: "Ensure the target directory exists and is writable",
676
+ example: "mkdir -p /path/to/directory && chmod +w /path/to/directory",
677
+ relatedCommands: ["help topic installation"],
678
+ },
649
679
  ]);
650
- this.contextualHelpers.set('command:eval', [
680
+ this.contextualHelpers.set("command:eval", [
651
681
  {
652
- error: 'eval',
653
- suggestion: 'Use proper JavaScript syntax and escape quotes',
654
- example: 'chrome-cdp-cli eval "document.querySelector(\\"#id\\").textContent"',
655
- relatedCommands: ['help eval', 'help topic scripting']
656
- }
682
+ error: "eval",
683
+ suggestion: "Use proper JavaScript syntax and escape quotes",
684
+ example: 'cdp eval "document.querySelector(\\"#id\\").textContent"',
685
+ relatedCommands: ["help eval", "help topic scripting"],
686
+ },
657
687
  ]);
658
- this.contextualHelpers.set('command:screenshot', [
688
+ this.contextualHelpers.set("command:screenshot", [
659
689
  {
660
- error: 'screenshot',
661
- suggestion: 'Ensure the output directory exists and is writable',
662
- example: 'mkdir -p screenshots && chrome-cdp-cli screenshot --filename screenshots/page.png',
663
- relatedCommands: ['help screenshot']
664
- }
690
+ error: "screenshot",
691
+ suggestion: "Ensure the output directory exists and is writable",
692
+ example: "mkdir -p screenshots && cdp screenshot --filename screenshots/page.png",
693
+ relatedCommands: ["help screenshot"],
694
+ },
665
695
  ]);
666
696
  }
667
697
  getAvailableTopics() {