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.
- package/README.md +380 -955
- package/dist/cli/ArgumentParser.js +172 -92
- package/dist/cli/CLIApplication.js +155 -82
- package/dist/cli/CommandRouter.js +98 -74
- package/dist/cli/CommandSchemaRegistry.js +506 -398
- package/dist/cli/HelpSystem.js +286 -256
- package/dist/handlers/ClickHandler.js +91 -27
- package/dist/handlers/InstallClaudeSkillHandler.js +220 -220
- package/dist/handlers/InstallCursorCommandHandler.js +60 -60
- package/dist/handlers/ListConsoleMessagesHandler.js +126 -178
- package/dist/handlers/ListNetworkRequestsHandler.js +128 -108
- package/dist/handlers/RestartProxyHandler.js +4 -4
- package/dist/handlers/TakeScreenshotHandler.js +70 -59
- package/dist/handlers/TakeSnapshotHandler.js +223 -165
- package/dist/handlers/index.js +0 -1
- package/dist/monitors/ConsoleMonitor.js +29 -0
- package/dist/monitors/NetworkMonitor.js +43 -19
- package/dist/proxy/server/CDPProxyServer.js +5 -1
- package/dist/proxy/server/CommandExecutionService.js +1 -1
- package/dist/proxy/server/ProxyAPIServer.js +11 -6
- package/package.json +3 -2
package/dist/cli/HelpSystem.js
CHANGED
|
@@ -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:
|
|
7
|
-
bright:
|
|
8
|
-
dim:
|
|
9
|
-
red:
|
|
10
|
-
green:
|
|
11
|
-
yellow:
|
|
12
|
-
blue:
|
|
13
|
-
magenta:
|
|
14
|
-
cyan:
|
|
15
|
-
white:
|
|
16
|
-
gray:
|
|
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 +=
|
|
49
|
+
help += "=".repeat(command.name.length) + "\n\n";
|
|
50
50
|
help += `${command.description}\n\n`;
|
|
51
51
|
if (command.usage) {
|
|
52
|
-
help +=
|
|
53
|
-
help +=
|
|
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 +=
|
|
58
|
-
help +=
|
|
57
|
+
help += "ARGUMENTS\n";
|
|
58
|
+
help += "---------\n";
|
|
59
59
|
for (const arg of command.arguments) {
|
|
60
|
-
const required = arg.required ?
|
|
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 !==
|
|
64
|
+
if (arg.type !== "string") {
|
|
65
65
|
help += ` Type: ${arg.type}\n`;
|
|
66
66
|
}
|
|
67
|
-
help +=
|
|
67
|
+
help += "\n";
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
if (command.options.length > 0) {
|
|
71
|
-
help +=
|
|
72
|
-
help +=
|
|
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 ===
|
|
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 !==
|
|
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(
|
|
90
|
+
help += ` Choices: ${option.choices.join(", ")}\n`;
|
|
91
91
|
}
|
|
92
|
-
help +=
|
|
92
|
+
help += "\n";
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
if (command.examples && command.examples.length > 0) {
|
|
96
|
-
help +=
|
|
97
|
-
help +=
|
|
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 ||
|
|
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 +=
|
|
106
|
-
help +=
|
|
107
|
-
help += `${command.aliases.join(
|
|
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 +=
|
|
112
|
-
help +=
|
|
113
|
-
help += `Help topics: ${relatedTopics.join(
|
|
114
|
-
help += `Use '
|
|
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(
|
|
121
|
-
help += `${colors.cyan}${
|
|
122
|
-
help +=
|
|
123
|
-
|
|
124
|
-
help += `${
|
|
125
|
-
help += `${
|
|
126
|
-
help += `${colorize.
|
|
127
|
-
help += `${
|
|
128
|
-
help +=
|
|
129
|
-
help += ` ${colorize.option(
|
|
130
|
-
help += ` ${colorize.option(
|
|
131
|
-
help += ` ${colorize.option(
|
|
132
|
-
help += `
|
|
133
|
-
help += `
|
|
134
|
-
help += `
|
|
135
|
-
help += `
|
|
136
|
-
help += ` ${colorize.option(
|
|
137
|
-
help += `
|
|
138
|
-
help += `
|
|
139
|
-
help += `
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
|
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}${
|
|
183
|
+
help += ` ${commandName}${" ".repeat(namePadding)}${aliases}${" ".repeat(aliasPadding)} ${command.description}\n`;
|
|
159
184
|
}
|
|
160
185
|
}
|
|
161
|
-
help += `\n${colorize.section(
|
|
162
|
-
help += `${colors.blue}${
|
|
163
|
-
help +=
|
|
164
|
-
help += ` ${colorize.command(
|
|
165
|
-
help +=
|
|
166
|
-
help +=
|
|
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 +=
|
|
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 +=
|
|
180
|
-
help +=
|
|
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 +=
|
|
210
|
+
help += "\n";
|
|
185
211
|
}
|
|
186
212
|
if (topic.seeAlso && topic.seeAlso.length > 0) {
|
|
187
|
-
help +=
|
|
188
|
-
help +=
|
|
189
|
-
help += `${topic.seeAlso.join(
|
|
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 +=
|
|
198
|
-
help +=
|
|
199
|
-
help +=
|
|
200
|
-
help +=
|
|
201
|
-
help +=
|
|
202
|
-
help +=
|
|
203
|
-
|
|
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 +=
|
|
207
|
-
help +=
|
|
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 &&
|
|
215
|
-
|
|
241
|
+
if (suggestion.relatedCommands &&
|
|
242
|
+
suggestion.relatedCommands.length > 0) {
|
|
243
|
+
help += ` Related commands: ${suggestion.relatedCommands.join(", ")}\n`;
|
|
216
244
|
}
|
|
217
|
-
help +=
|
|
245
|
+
help += "\n";
|
|
218
246
|
}
|
|
219
247
|
}
|
|
220
248
|
if (commandName) {
|
|
221
249
|
help += `For detailed help on '${commandName}' command:\n`;
|
|
222
|
-
help += `
|
|
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 +=
|
|
259
|
+
help += "Did you mean:\n";
|
|
232
260
|
for (const similar of similarCommands) {
|
|
233
261
|
help += ` ${similar}\n`;
|
|
234
262
|
}
|
|
235
|
-
help +=
|
|
263
|
+
help += "\n";
|
|
236
264
|
}
|
|
237
|
-
help +=
|
|
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 +=
|
|
249
|
-
help +=
|
|
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 +=
|
|
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 +=
|
|
261
|
-
help +=
|
|
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) ||
|
|
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 =
|
|
305
|
-
if ([
|
|
306
|
-
category =
|
|
333
|
+
let category = "General";
|
|
334
|
+
if (["eval", "execute", "js"].includes(command.name)) {
|
|
335
|
+
category = "JavaScript Execution";
|
|
307
336
|
}
|
|
308
|
-
else if ([
|
|
309
|
-
category =
|
|
337
|
+
else if (["screenshot", "capture", "snapshot", "dom"].includes(command.name)) {
|
|
338
|
+
category = "Page Capture";
|
|
310
339
|
}
|
|
311
|
-
else if ([
|
|
312
|
-
|
|
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 ([
|
|
315
|
-
|
|
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 ([
|
|
319
|
-
category =
|
|
348
|
+
else if (["navigate", "goto", "open", "wait"].includes(command.name)) {
|
|
349
|
+
category = "Navigation & Timing";
|
|
320
350
|
}
|
|
321
|
-
else if (command.name.includes(
|
|
322
|
-
category =
|
|
351
|
+
else if (command.name.includes("install")) {
|
|
352
|
+
category = "Installation & Setup";
|
|
323
353
|
}
|
|
324
|
-
else if ([
|
|
325
|
-
category =
|
|
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
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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(
|
|
362
|
-
name:
|
|
363
|
-
title:
|
|
364
|
-
description:
|
|
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
|
-
'
|
|
382
|
-
|
|
383
|
-
|
|
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: [
|
|
415
|
+
seeAlso: ["profiles", "environment-variables"],
|
|
386
416
|
});
|
|
387
|
-
this.helpTopics.set(
|
|
388
|
-
name:
|
|
389
|
-
title:
|
|
390
|
-
description:
|
|
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
|
-
'
|
|
407
|
-
'
|
|
408
|
-
'
|
|
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: [
|
|
440
|
+
seeAlso: ["automation", "debugging"],
|
|
411
441
|
});
|
|
412
|
-
this.helpTopics.set(
|
|
413
|
-
name:
|
|
414
|
-
title:
|
|
415
|
-
description:
|
|
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
|
-
'
|
|
432
|
-
'
|
|
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: [
|
|
464
|
+
seeAlso: ["selectors", "debugging", "scripting"],
|
|
435
465
|
});
|
|
436
|
-
this.helpTopics.set(
|
|
437
|
-
name:
|
|
438
|
-
title:
|
|
439
|
-
description:
|
|
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
|
-
'
|
|
463
|
-
|
|
464
|
-
|
|
492
|
+
'cdp --format json eval "document.title"',
|
|
493
|
+
"cdp --quiet screenshot --filename result.png",
|
|
494
|
+
"cdp --verbose --debug console_messages",
|
|
465
495
|
],
|
|
466
|
-
seeAlso: [
|
|
496
|
+
seeAlso: ["configuration", "scripting"],
|
|
467
497
|
});
|
|
468
|
-
this.helpTopics.set(
|
|
469
|
-
name:
|
|
470
|
-
title:
|
|
471
|
-
description:
|
|
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
|
-
'
|
|
496
|
-
|
|
497
|
-
|
|
525
|
+
'cdp --debug --verbose click "#button"',
|
|
526
|
+
"cdp console_messages --filter error",
|
|
527
|
+
"cdp screenshot --filename debug.png",
|
|
498
528
|
],
|
|
499
|
-
seeAlso: [
|
|
529
|
+
seeAlso: ["monitoring", "automation"],
|
|
500
530
|
});
|
|
501
|
-
this.helpTopics.set(
|
|
502
|
-
name:
|
|
503
|
-
title:
|
|
504
|
-
description:
|
|
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
|
-
|
|
528
|
-
'
|
|
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: [
|
|
560
|
+
seeAlso: ["configuration", "output-formats"],
|
|
531
561
|
});
|
|
532
|
-
this.helpTopics.set(
|
|
533
|
-
name:
|
|
534
|
-
title:
|
|
535
|
-
description:
|
|
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 ~/.
|
|
550
|
-
- Use project-specific .
|
|
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
|
-
|
|
559
|
-
|
|
560
|
-
|
|
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: [
|
|
592
|
+
seeAlso: ["configuration", "integration"],
|
|
563
593
|
});
|
|
564
594
|
}
|
|
565
595
|
initializeContextualHelpers() {
|
|
566
|
-
this.contextualHelpers.set(
|
|
596
|
+
this.contextualHelpers.set("connection refused", [
|
|
567
597
|
{
|
|
568
|
-
error:
|
|
569
|
-
suggestion:
|
|
570
|
-
example:
|
|
571
|
-
relatedCommands: [
|
|
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:
|
|
575
|
-
suggestion:
|
|
576
|
-
example:
|
|
577
|
-
relatedCommands: [
|
|
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(
|
|
610
|
+
this.contextualHelpers.set("element not found", [
|
|
581
611
|
{
|
|
582
|
-
error:
|
|
583
|
-
suggestion:
|
|
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: [
|
|
615
|
+
relatedCommands: ["help topic selectors"],
|
|
586
616
|
},
|
|
587
617
|
{
|
|
588
|
-
error:
|
|
589
|
-
suggestion:
|
|
590
|
-
example: '
|
|
591
|
-
relatedCommands: [
|
|
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(
|
|
624
|
+
this.contextualHelpers.set("timeout", [
|
|
595
625
|
{
|
|
596
|
-
error:
|
|
597
|
-
suggestion:
|
|
598
|
-
example:
|
|
599
|
-
relatedCommands: [
|
|
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:
|
|
603
|
-
suggestion:
|
|
604
|
-
example:
|
|
605
|
-
relatedCommands: [
|
|
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(
|
|
638
|
+
this.contextualHelpers.set("parse error", [
|
|
609
639
|
{
|
|
610
|
-
error:
|
|
611
|
-
suggestion:
|
|
612
|
-
example:
|
|
613
|
-
relatedCommands: [
|
|
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:
|
|
617
|
-
suggestion:
|
|
618
|
-
example:
|
|
619
|
-
relatedCommands: [
|
|
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(
|
|
652
|
+
this.contextualHelpers.set("validation failed", [
|
|
623
653
|
{
|
|
624
|
-
error:
|
|
625
|
-
suggestion:
|
|
626
|
-
example:
|
|
627
|
-
relatedCommands: [
|
|
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:
|
|
631
|
-
suggestion:
|
|
632
|
-
example:
|
|
633
|
-
relatedCommands: [
|
|
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(
|
|
666
|
+
this.contextualHelpers.set("permission denied", [
|
|
637
667
|
{
|
|
638
|
-
error:
|
|
639
|
-
suggestion:
|
|
640
|
-
example:
|
|
641
|
-
relatedCommands: [
|
|
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:
|
|
645
|
-
suggestion:
|
|
646
|
-
example:
|
|
647
|
-
relatedCommands: [
|
|
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(
|
|
680
|
+
this.contextualHelpers.set("command:eval", [
|
|
651
681
|
{
|
|
652
|
-
error:
|
|
653
|
-
suggestion:
|
|
654
|
-
example: '
|
|
655
|
-
relatedCommands: [
|
|
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(
|
|
688
|
+
this.contextualHelpers.set("command:screenshot", [
|
|
659
689
|
{
|
|
660
|
-
error:
|
|
661
|
-
suggestion:
|
|
662
|
-
example:
|
|
663
|
-
relatedCommands: [
|
|
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() {
|