@xbrowser/cli 1.5.3 → 1.5.5

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.
@@ -289,11 +289,28 @@ function saveConfig(config) {
289
289
  coreSaveConfig(getConfigSource(), config);
290
290
  }
291
291
  function getConfigValue(key) {
292
- return loadConfig()[key];
292
+ const parts = key.split(".");
293
+ let obj = loadConfig();
294
+ for (const part of parts) {
295
+ if (obj && typeof obj === "object") {
296
+ obj = obj[part];
297
+ } else {
298
+ return void 0;
299
+ }
300
+ }
301
+ return obj;
293
302
  }
294
303
  function setConfigValue(key, value) {
295
304
  const config = loadConfig();
296
- config[key] = value;
305
+ const parts = key.split(".");
306
+ let obj = config;
307
+ for (let i = 0; i < parts.length - 1; i++) {
308
+ if (!obj[parts[i]] || typeof obj[parts[i]] !== "object") {
309
+ obj[parts[i]] = {};
310
+ }
311
+ obj = obj[parts[i]];
312
+ }
313
+ obj[parts[parts.length - 1]] = value;
297
314
  saveConfig(config);
298
315
  }
299
316
  var DEFAULT_MARKETPLACE_URL = "https://marketplace.xbrowser.dev";
package/dist/cli.js CHANGED
@@ -7088,7 +7088,44 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7088
7088
  if (!command) {
7089
7089
  const available = getAllCommands().map((c) => c.name);
7090
7090
  const suggestions = available.map((name) => ({ name, dist: levenshtein(commandName, name) })).filter((s) => s.dist <= 3).sort((a, b) => a.dist - b.dist).slice(0, 3).map((s) => s.name);
7091
- const hint = suggestions.length > 0 ? ` Did you mean: ${suggestions.join(" or ")}?` : "";
7091
+ let hint = suggestions.length > 0 ? ` Did you mean: ${suggestions.join(" or ")}?` : "";
7092
+ const knownPlugins = [
7093
+ "douyin",
7094
+ "xiaohongshu",
7095
+ "zhihu",
7096
+ "chatgpt",
7097
+ "deepseek",
7098
+ "baidu",
7099
+ "bilibili",
7100
+ "github",
7101
+ "medium",
7102
+ "juejin",
7103
+ "devto",
7104
+ "twitter",
7105
+ "reddit",
7106
+ "steam",
7107
+ "doubao",
7108
+ "qianwen",
7109
+ "yuanbao",
7110
+ "claude",
7111
+ "gemini",
7112
+ "suno",
7113
+ "mureka",
7114
+ "wanx",
7115
+ "taobao",
7116
+ "google",
7117
+ "wordpress",
7118
+ "csdn",
7119
+ "quora",
7120
+ "producthunt",
7121
+ "hashnode",
7122
+ "blogger",
7123
+ "facebook",
7124
+ "instagram"
7125
+ ];
7126
+ if (knownPlugins.includes(commandName)) {
7127
+ hint = ` Plugin "${commandName}" may need to be installed. Try: xbrowser plugin install @xbrowser/${commandName}`;
7128
+ }
7092
7129
  return errorResult(
7093
7130
  `Unknown command: ${commandName}.${hint} Available: ${available.join(", ")}`
7094
7131
  );
@@ -7695,11 +7732,28 @@ function saveConfig(config) {
7695
7732
  coreSaveConfig(getConfigSource(), config);
7696
7733
  }
7697
7734
  function getConfigValue(key) {
7698
- return loadConfig()[key];
7735
+ const parts = key.split(".");
7736
+ let obj = loadConfig();
7737
+ for (const part of parts) {
7738
+ if (obj && typeof obj === "object") {
7739
+ obj = obj[part];
7740
+ } else {
7741
+ return void 0;
7742
+ }
7743
+ }
7744
+ return obj;
7699
7745
  }
7700
7746
  function setConfigValue(key, value) {
7701
7747
  const config = loadConfig();
7702
- config[key] = value;
7748
+ const parts = key.split(".");
7749
+ let obj = config;
7750
+ for (let i = 0; i < parts.length - 1; i++) {
7751
+ if (!obj[parts[i]] || typeof obj[parts[i]] !== "object") {
7752
+ obj[parts[i]] = {};
7753
+ }
7754
+ obj = obj[parts[i]];
7755
+ }
7756
+ obj[parts[parts.length - 1]] = value;
7703
7757
  saveConfig(config);
7704
7758
  }
7705
7759
  var DEFAULT_MARKETPLACE_URL = "https://marketplace.xbrowser.dev";
@@ -12503,6 +12557,11 @@ async function routeCommand(argvIn, stdinCommands) {
12503
12557
  await handleChainInput(argv[0], argv);
12504
12558
  return;
12505
12559
  }
12560
+ const jsonBeforeChain = (argv[0] === "--json" || argv[0] === "--yaml") && argv[1] && isChainInput(argv[1]);
12561
+ if (jsonBeforeChain) {
12562
+ await handleChainInput(argv[1], argv);
12563
+ return;
12564
+ }
12506
12565
  const globalFlags = /* @__PURE__ */ new Set(["--session", "--cdp", "--json", "--yaml", "--output", "--timeout", "--help", "-h", "--version"]);
12507
12566
  let chainArgIdx = -1;
12508
12567
  for (let i = 0; i < argv.length; i++) {
@@ -12527,11 +12586,13 @@ async function routeCommand(argvIn, stdinCommands) {
12527
12586
  outputError(e instanceof Error ? e.message : String(e));
12528
12587
  return;
12529
12588
  }
12589
+ const hasJsonFlag = argv.some((a) => a === "--json" || a.startsWith("--json="));
12590
+ const hasYamlFlag = argv.some((a) => a === "--yaml" || a.startsWith("--yaml="));
12530
12591
  const parsed = parseArgs(argv);
12531
12592
  const { positional, options } = parsed;
12532
12593
  const command = positional[0];
12533
12594
  const cmdArgs = positional.slice(1);
12534
- const mode = options.json ? "json" : options.yaml ? "yaml" : "text";
12595
+ const mode = options.json || hasJsonFlag ? "json" : options.yaml || hasYamlFlag ? "yaml" : "text";
12535
12596
  const sessionName = options.session || process.env.XBROWSER_SESSION || "default";
12536
12597
  const cdpEndpoint = options.cdp || process.env.XBROWSER_CDP;
12537
12598
  if (options.version || options.v && positional.length === 0) {
@@ -12539,8 +12600,13 @@ async function routeCommand(argvIn, stdinCommands) {
12539
12600
  return;
12540
12601
  }
12541
12602
  if (positional.length === 0) {
12542
- showMainHelp();
12543
- return;
12603
+ const chainHints = [options.json, options.yaml, options.session, options.cdp].filter(Boolean).find((v) => typeof v === "string" && v.includes(" "));
12604
+ if (chainHints) {
12605
+ positional.push(chainHints);
12606
+ } else {
12607
+ showMainHelp();
12608
+ return;
12609
+ }
12544
12610
  }
12545
12611
  if ((options.help || options.h) && positional.length > 0) {
12546
12612
  const loader = await getPluginLoader();
@@ -6619,7 +6619,44 @@ async function executeCommand(commandName, params, sessionName = "default", extr
6619
6619
  if (!command) {
6620
6620
  const available = getAllCommands().map((c) => c.name);
6621
6621
  const suggestions = available.map((name) => ({ name, dist: levenshtein(commandName, name) })).filter((s) => s.dist <= 3).sort((a, b) => a.dist - b.dist).slice(0, 3).map((s) => s.name);
6622
- const hint = suggestions.length > 0 ? ` Did you mean: ${suggestions.join(" or ")}?` : "";
6622
+ let hint = suggestions.length > 0 ? ` Did you mean: ${suggestions.join(" or ")}?` : "";
6623
+ const knownPlugins = [
6624
+ "douyin",
6625
+ "xiaohongshu",
6626
+ "zhihu",
6627
+ "chatgpt",
6628
+ "deepseek",
6629
+ "baidu",
6630
+ "bilibili",
6631
+ "github",
6632
+ "medium",
6633
+ "juejin",
6634
+ "devto",
6635
+ "twitter",
6636
+ "reddit",
6637
+ "steam",
6638
+ "doubao",
6639
+ "qianwen",
6640
+ "yuanbao",
6641
+ "claude",
6642
+ "gemini",
6643
+ "suno",
6644
+ "mureka",
6645
+ "wanx",
6646
+ "taobao",
6647
+ "google",
6648
+ "wordpress",
6649
+ "csdn",
6650
+ "quora",
6651
+ "producthunt",
6652
+ "hashnode",
6653
+ "blogger",
6654
+ "facebook",
6655
+ "instagram"
6656
+ ];
6657
+ if (knownPlugins.includes(commandName)) {
6658
+ hint = ` Plugin "${commandName}" may need to be installed. Try: xbrowser plugin install @xbrowser/${commandName}`;
6659
+ }
6623
6660
  return errorResult(
6624
6661
  `Unknown command: ${commandName}.${hint} Available: ${available.join(", ")}`
6625
6662
  );
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HumanInteractionManager
3
- } from "./chunk-MDAPTB7C.js";
3
+ } from "./chunk-ZJHQPMCY.js";
4
4
  import "./chunk-KFQGP6VL.js";
5
5
  export {
6
6
  HumanInteractionManager
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  loadConfig,
40
40
  resolveNpmPackageWithFallback,
41
41
  setConfigValue
42
- } from "./chunk-MDAPTB7C.js";
42
+ } from "./chunk-ZJHQPMCY.js";
43
43
  import {
44
44
  generateBashScript,
45
45
  generateJSScript,
@@ -7408,7 +7408,44 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7408
7408
  if (!command) {
7409
7409
  const available = getAllCommands().map((c) => c.name);
7410
7410
  const suggestions = available.map((name) => ({ name, dist: levenshtein(commandName, name) })).filter((s) => s.dist <= 3).sort((a, b) => a.dist - b.dist).slice(0, 3).map((s) => s.name);
7411
- const hint = suggestions.length > 0 ? ` Did you mean: ${suggestions.join(" or ")}?` : "";
7411
+ let hint = suggestions.length > 0 ? ` Did you mean: ${suggestions.join(" or ")}?` : "";
7412
+ const knownPlugins = [
7413
+ "douyin",
7414
+ "xiaohongshu",
7415
+ "zhihu",
7416
+ "chatgpt",
7417
+ "deepseek",
7418
+ "baidu",
7419
+ "bilibili",
7420
+ "github",
7421
+ "medium",
7422
+ "juejin",
7423
+ "devto",
7424
+ "twitter",
7425
+ "reddit",
7426
+ "steam",
7427
+ "doubao",
7428
+ "qianwen",
7429
+ "yuanbao",
7430
+ "claude",
7431
+ "gemini",
7432
+ "suno",
7433
+ "mureka",
7434
+ "wanx",
7435
+ "taobao",
7436
+ "google",
7437
+ "wordpress",
7438
+ "csdn",
7439
+ "quora",
7440
+ "producthunt",
7441
+ "hashnode",
7442
+ "blogger",
7443
+ "facebook",
7444
+ "instagram"
7445
+ ];
7446
+ if (knownPlugins.includes(commandName)) {
7447
+ hint = ` Plugin "${commandName}" may need to be installed. Try: xbrowser plugin install @xbrowser/${commandName}`;
7448
+ }
7412
7449
  return errorResult(
7413
7450
  `Unknown command: ${commandName}.${hint} Available: ${available.join(", ")}`
7414
7451
  );
@@ -7917,7 +7954,7 @@ function attachWaitForHuman(ctx, getOrCreateWSServer) {
7917
7954
  if (!ctx.page) {
7918
7955
  throw new Error("waitForHuman requires an active page");
7919
7956
  }
7920
- const { HumanInteractionManager: HumanInteractionManager2 } = await import("./human-interaction-UKAS5ZXV.js");
7957
+ const { HumanInteractionManager: HumanInteractionManager2 } = await import("./human-interaction-2DZK4MW7.js");
7921
7958
  const wsServer2 = await getOrCreateWSServer(ctx.browserContext);
7922
7959
  const manager = new HumanInteractionManager2(wsServer2, ctx.page);
7923
7960
  return manager.waitForHuman(options);
@@ -12843,6 +12880,11 @@ async function routeCommand(argvIn, stdinCommands) {
12843
12880
  await handleChainInput(argv[0], argv);
12844
12881
  return;
12845
12882
  }
12883
+ const jsonBeforeChain = (argv[0] === "--json" || argv[0] === "--yaml") && argv[1] && isChainInput(argv[1]);
12884
+ if (jsonBeforeChain) {
12885
+ await handleChainInput(argv[1], argv);
12886
+ return;
12887
+ }
12846
12888
  const globalFlags = /* @__PURE__ */ new Set(["--session", "--cdp", "--json", "--yaml", "--output", "--timeout", "--help", "-h", "--version"]);
12847
12889
  let chainArgIdx = -1;
12848
12890
  for (let i = 0; i < argv.length; i++) {
@@ -12867,11 +12909,13 @@ async function routeCommand(argvIn, stdinCommands) {
12867
12909
  outputError(e instanceof Error ? e.message : String(e));
12868
12910
  return;
12869
12911
  }
12912
+ const hasJsonFlag = argv.some((a) => a === "--json" || a.startsWith("--json="));
12913
+ const hasYamlFlag = argv.some((a) => a === "--yaml" || a.startsWith("--yaml="));
12870
12914
  const parsed = parseArgs(argv);
12871
12915
  const { positional, options } = parsed;
12872
12916
  const command = positional[0];
12873
12917
  const cmdArgs = positional.slice(1);
12874
- const mode = options.json ? "json" : options.yaml ? "yaml" : "text";
12918
+ const mode = options.json || hasJsonFlag ? "json" : options.yaml || hasYamlFlag ? "yaml" : "text";
12875
12919
  const sessionName = options.session || process.env.XBROWSER_SESSION || "default";
12876
12920
  const cdpEndpoint = options.cdp || process.env.XBROWSER_CDP;
12877
12921
  if (options.version || options.v && positional.length === 0) {
@@ -12879,8 +12923,13 @@ async function routeCommand(argvIn, stdinCommands) {
12879
12923
  return;
12880
12924
  }
12881
12925
  if (positional.length === 0) {
12882
- showMainHelp();
12883
- return;
12926
+ const chainHints = [options.json, options.yaml, options.session, options.cdp].filter(Boolean).find((v) => typeof v === "string" && v.includes(" "));
12927
+ if (chainHints) {
12928
+ positional.push(chainHints);
12929
+ } else {
12930
+ showMainHelp();
12931
+ return;
12932
+ }
12884
12933
  }
12885
12934
  if ((options.help || options.h) && positional.length > 0) {
12886
12935
  const loader = await getPluginLoader();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xbrowser/cli",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "description": "Browser automation CLI for web scraping, headless browsing, SEO analysis, and AI agent workflows. A command-line alternative to Playwright, Puppeteer, and Selenium.",
5
5
  "type": "module",
6
6
  "bin": {