@xbrowser/cli 1.22.0 → 1.23.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # xbrowser
2
2
 
3
- > **Browser automation CLI** for web scraping, headless browsing, SEO analysis, and AI agent workflows. 51 commands, 75 plugins. A command-line alternative to Playwright, Puppeteer, and Selenium — **no code required**.
3
+ > **Browser automation CLI** for web scraping, headless browsing, SEO analysis, and AI agent workflows. 57 commands, 132 plugins. A command-line alternative to Playwright, Puppeteer, and Selenium — **no code required**.
4
4
 
5
5
  [![CI Status](https://github.com/dyyz1993/xbrowser/workflows/CI/badge.svg)](https://github.com/dyyz1993/xbrowser/actions)
6
6
  [![codecov](https://codecov.io/gh/dyyz1993/xbrowser/branch/master/graph/badge.svg)](https://codecov.io/gh/dyyz1993/xbrowser)
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## 特性
11
11
 
12
- - **51 浏览器命令** — 导航、交互、查询、存储、截图,覆盖常见自动化场景
12
+ - **57 浏览器命令** — 导航、交互、查询、存储、截图,覆盖常见自动化场景
13
13
  - **命令链** — 用 `&&`、`,`、`+`、`->`、`;` 串联多个命令,一行搞定复杂流程
14
14
  - **管道 & Heredoc** — 支持 stdin 管道和 heredoc 批量执行
15
15
  - **录制 / 回放** — 录制浏览器操作为 YAML,随时回放,可转换为 JS/Python/Bash 脚本
@@ -57,6 +57,22 @@ xbrowser juejin publish --file article.md
57
57
  # (Each platform has its own plugin — run `xbrowser plugin list` to see available)
58
58
  ```
59
59
 
60
+ **Content Marketing — xbrowser promotes itself (dogfooding)**
61
+ ```bash
62
+ # Browse the built-in promo case library (self-healing replay, CLI for AI agents, stealth…)
63
+ xbrowser content cases
64
+
65
+ # Render a case into a platform-ready article (en/zh, {{VAR}} substituted)
66
+ xbrowser content draft --case self-healing-replay --lang zh
67
+
68
+ # Render an OG cover image with the browser itself — zero imaging libraries
69
+ xbrowser "set-viewport 1200 630 && content cover --title 'Self-Healing Replay' --output cover.png"
70
+
71
+ # Publish through any of the 18 platform plugins
72
+ xbrowser devto publish --file output/content/self-healing-replay-en.md --tags "typescript,automation"
73
+ ```
74
+ The full write → cover → publish loop that promotes xbrowser is itself built on xbrowser commands.
75
+
60
76
  ## 快速开始
61
77
 
62
78
  ### 安装
@@ -458,6 +474,19 @@ project > browser > page > element
458
474
  Error: 需要活跃的页面,请先执行 xbrowser goto <url>
459
475
  ```
460
476
 
477
+ ## MCP Server(AI Agent 接入)
478
+
479
+ xbrowser 内置 Model Context Protocol 服务器——让 Claude Desktop / Cursor / 任何 MCP 客户端直接使用浏览器能力:
480
+
481
+ ```bash
482
+ # 注册到 Claude Code
483
+ claude mcp add xbrowser -- xbrowser mcp
484
+
485
+ # 或手动配置(stdio):command: xbrowser, args: ["mcp"]
486
+ ```
487
+
488
+ 7 个工具:`browser_navigate` / `browser_act` / `browser_read` / `browser_snapshot`(accessibility tree,token 友好)/ `browser_screenshot` / `browser_network` / `browser_replay`(自愈回放)。协议冒烟:`node scripts/mcp-smoke.mjs`。
489
+
461
490
  ## 插件系统
462
491
 
463
492
  ### 插件加载顺序
@@ -546,6 +575,7 @@ xbrowser 自带以下插件:
546
575
  | **douyin** | `ai-summary`, `user-info`, `video-info` | 抖音视频信息提取 |
547
576
  | **github** | `update-profile`, `add-social-link`, `create-gist`, `get-profile` | GitHub 个人资料管理 |
548
577
  | **web-automation** | `extract`, `paginate`, `fill-and-submit`, `screenshot` | 通用 Web 自动化工具 |
578
+ | **content** | `cases`, `draft`, `cover` | 内容营销:内置推广 case 渲染成文 + 浏览器自渲染封面 |
549
579
 
550
580
  使用插件命令:
551
581
 
@@ -884,7 +914,7 @@ xbrowser/
884
914
  | **Setup** | `npm i -g` — 0 config | Install + browser download | Install + browser download | Install + WebDriver + drivers |
885
915
  | **Web Scraping** | Built-in (`scrape`, `crawl`, `map`) | Write custom scripts | Write custom scripts | Write custom scripts |
886
916
  | **Search** | Built-in multi-engine (`search`) | No | No | No |
887
- | **Plugin Ecosystem** | 75 plugins | Limited | Limited | No |
917
+ | **Plugin Ecosystem** | 132 plugins | Limited | Limited | No |
888
918
  | **No Code Required** | ✅ CLI commands | ❌ Must write JS/TS | ❌ Must write JS/TS | ❌ Must write code |
889
919
  | **Headless Mode** | ✅ Default | ✅ | ✅ | ✅ |
890
920
  | **Record/Replay** | ✅ Built-in (`record`/`replay`) | ✅ Codegen | ❌ | ❌ |
@@ -95,7 +95,7 @@ import { join } from "path";
95
95
  import { execSync } from "child_process";
96
96
  var SHARED_PLUGIN_DEPENDENCIES = {
97
97
  "zod": "^3.24.0",
98
- "@dyyz1993/xcli-core": "^0.12.1"
98
+ "@dyyz1993/xcli-core": "^0.19.0"
99
99
  };
100
100
  function ensurePluginDependencies(pluginsDir) {
101
101
  const zodPath = join(pluginsDir, "node_modules", "zod");
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-HBMEFSTB.js";
5
5
 
6
6
  // src/human-interaction.ts
7
- import { execSync } from "child_process";
7
+ import { execFile } from "child_process";
8
8
 
9
9
  // src/captcha-detector.ts
10
10
  var CAPTCHA_SELECTORS = [
@@ -138,11 +138,6 @@ var WebhookNotifier = class {
138
138
  }
139
139
  };
140
140
 
141
- // src/utils/shell-escape.ts
142
- function shellEscape(value) {
143
- return `'${value.replace(/'/g, "'\\''")}'`;
144
- }
145
-
146
141
  // src/human-interaction.ts
147
142
  var HumanInteractionManager = class {
148
143
  wsServer;
@@ -171,8 +166,10 @@ var HumanInteractionManager = class {
171
166
  tryAutoOpen(previewUrl) {
172
167
  if (!this.autoOpen) return;
173
168
  try {
174
- const cmd = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : "start";
175
- execSync(`${cmd} ${shellEscape(previewUrl)}`, { stdio: "ignore" });
169
+ const opener = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : "cmd";
170
+ const args = process.platform === "win32" ? ["/c", "start", "", previewUrl] : [previewUrl];
171
+ execFile(opener, args, { timeout: 1e4 }, () => {
172
+ });
176
173
  } catch {
177
174
  }
178
175
  }