diff --git a/README.md b/README.md index 0abbe0d5..a4b799aa 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,26 @@ Turn ANY Electron application into a CLI tool! Recombine, script, and extend app - **Dynamic Loader** — Simply drop `.ts` or `.yaml` adapters into the `clis/` folder for auto-registration. - **Dual-Engine Architecture** — Supports both YAML declarative data pipelines and robust browser runtime TypeScript injections. +## Why opencli? + +There are many great browser automation tools. Here's when opencli is the right choice: + +| Your need | Best tool | Why | +|-----------|-----------|-----| +| Scheduled data extraction from specific sites | **opencli** | Pre-built adapters, deterministic JSON, zero LLM cost | +| AI agent needs reliable site operations | **opencli** | Hundreds of commands, structured output, fast deterministic response | +| Explore an unknown website ad-hoc | Browser-Use, Stagehand | LLM-driven general browsing for one-off tasks | +| Large-scale web crawling | Crawl4AI, Scrapy | Purpose-built for throughput and scale | +| Control desktop Electron apps from terminal | **opencli** | CDP + AppleScript — the only CLI tool that does this | + +**What makes opencli different:** + +- **Zero LLM cost** — No tokens consumed at runtime. Run 10,000 times and pay nothing. +- **Deterministic** — Same command, same output schema, every time. Pipeable, scriptable, CI-friendly. +- **Broad coverage** — 50+ sites across global and Chinese platforms (Bilibili, Zhihu, Xiaohongshu, Reddit, HackerNews, and more), plus desktop Electron apps via CDP. + +> For a detailed comparison with Browser-Use, Crawl4AI, Firecrawl, and others, see the [Comparison Guide](./docs/comparison.md). + ## Prerequisites - **Node.js**: >= 20.0.0 diff --git a/README.zh-CN.md b/README.zh-CN.md index eb1154bc..0a27cf2d 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -30,6 +30,26 @@ CLI all electron!现在支持把所有 electron 应用 CLI 化,从而组合 - **AI 原生** — `explore` 自动发现 API,`synthesize` 生成适配器,`cascade` 探测认证策略 - **动态加载引擎** — 声明式的 `.yaml` 或者底层定制的 `.ts` 适配器,放入 `clis/` 文件夹即可自动注册生效 +## 为什么选 opencli? + +浏览器自动化工具很多,opencli 适合什么场景? + +| 你的需求 | 最佳工具 | 原因 | +|----------|----------|------| +| 定时从特定站点提取结构化数据 | **opencli** | 预定义适配器,确定性 JSON 输出,零 LLM 成本 | +| AI Agent 需要可靠的站点操作 | **opencli** | 数百条命令,结构化输出,快速确定性响应 | +| 临时探索未知网站 | Browser-Use、Stagehand | LLM 驱动的通用浏览,适合一次性任务 | +| 大规模网页爬取 | Crawl4AI、Scrapy | 专为吞吐量和规模设计 | +| 从终端控制桌面 Electron 应用 | **opencli** | CDP + AppleScript,目前唯一能做到这一点的 CLI 工具 | + +**opencli 的核心差异:** + +- **零 LLM 成本** — 运行时不消耗任何 token,跑一万次不花一分钱 +- **确定性** — 同一命令永远返回同一结构,可管道化、可脚本化、CI 友好 +- **覆盖广泛** — 50+ 站点,横跨全球与中国平台(B站、知乎、小红书、Reddit、HackerNews 等),并支持通过 CDP 控制桌面 Electron 应用 + +> 与 Browser-Use、Crawl4AI、Firecrawl 等工具的详细对比,请查看 [Comparison Guide](./docs/comparison.md)。 + ## 前置要求 - **Node.js**: >= 20.0.0 diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 27acd628..0e7a12a1 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -29,6 +29,7 @@ export default defineConfig({ items: [ { text: 'Getting Started', link: '/guide/getting-started' }, { text: 'Installation', link: '/guide/installation' }, + { text: 'Comparison', link: '/comparison' }, { text: 'Browser Bridge', link: '/guide/browser-bridge' }, { text: 'Troubleshooting', link: '/guide/troubleshooting' }, { text: 'Plugins', link: '/guide/plugins' }, diff --git a/docs/comparison.md b/docs/comparison.md new file mode 100644 index 00000000..40b8780a --- /dev/null +++ b/docs/comparison.md @@ -0,0 +1,125 @@ +# Comparison Guide + +OpenCLI occupies a specific niche in the browser automation ecosystem. This guide honestly evaluates where opencli excels, where it's a viable option, and where other tools are a better fit. + +## At a Glance + +| Tool | Approach | Best for | +|------|----------|----------| +| **opencli** | Pre-built adapters (YAML/TS) | Deterministic site commands, broad platform coverage, desktop apps | +| **Browser-Use** | LLM-driven browser control | General-purpose AI browser automation | +| **Crawl4AI** | Async web crawler | Large-scale data crawling | +| **Firecrawl** | Scraping API / self-hosted | Clean markdown extraction, managed or self-hosted infrastructure | +| **agent-browser** | Browser primitive CLI | Token-efficient AI agent browsing | +| **Stagehand** | AI browser framework | Developer-friendly browser automation | +| **Skyvern** | Visual AI automation | Cross-site generalized workflows | + +## Scenario Comparison + +### 1. Scheduled Batch Data Extraction + +> "I want to pull trending posts from Bilibili/Reddit/HackerNews every hour into my pipeline." + +| Tool | Fit | Notes | +|------|-----|-------| +| **opencli** | Best | One command, structured JSON output, zero runtime cost. Runs in cron/CI without tokens or API keys. | +| Crawl4AI | Good | Strong for large-scale crawling, but requires writing extraction logic per site. | +| Firecrawl | Viable | Managed service with clean output, but costs scale with volume. | +| Browser-Use / Stagehand | Poor | LLM inference on every run is slow, expensive, and non-deterministic for repeated tasks. | + +**Why opencli wins here:** A command like `opencli bilibili hot -f json` returns the same structured schema every time, costs nothing to run, and finishes in seconds. For recurring data extraction from known sites, pre-built adapters beat LLM-driven approaches on cost, speed, and reliability. + +### 2. AI Agent Site Operations + +> "My AI agent needs to search Twitter, read Reddit threads, or post to Xiaohongshu." + +| Tool | Fit | Notes | +|------|-----|-------| +| **opencli** | Best | Structured JSON output, fast deterministic execution, hundreds of commands ready to use. | +| agent-browser | Good | Token-efficient browser primitives, but requires LLM reasoning for every step. | +| Browser-Use | Viable | General-purpose, but each operation costs tokens and takes 10-60s. | +| Stagehand | Viable | Good DX, but same LLM-per-action cost model. | + +**Why opencli wins here:** When your agent needs `twitter search "AI news" -f json`, a deterministic command that returns in seconds is strictly better than an LLM clicking through a webpage. The agent saves tokens for reasoning, not navigation. + +### 3. Authenticated Operations (Login-Required Sites) + +> "I need to access my bookmarks, post content, or interact with sites that require login." + +| Tool | Fit | Notes | +|------|-----|-------| +| **opencli** | Best | Reuses your Chrome login session via Browser Bridge. No credentials stored or transmitted. | +| Browser-Use | Viable | Can use browser profiles, but credential management is manual. | +| Firecrawl | Poor | Cloud service cannot access your authenticated sessions. | +| Crawl4AI | Poor | Requires manual cookie/session injection. | + +**Why opencli wins here:** The Browser Bridge extension reuses your existing Chrome login state in real-time. You log in once in Chrome, and opencli commands work immediately. No OAuth setup, no API keys, no credential files. + +### 4. General Web Browsing & Exploration + +> "I need to explore an unknown website, fill forms, or navigate complex multi-step flows." + +| Tool | Fit | Notes | +|------|-----|-------| +| Browser-Use | Best | LLM-driven, handles arbitrary websites and flows. | +| Stagehand | Best | Clean API for `act()`, `extract()`, `observe()` on any page. | +| agent-browser | Good | Token-efficient primitives for AI agents. | +| Skyvern | Good | Visual AI that generalizes across sites. | +| **opencli** | Poor | Only works with sites that have pre-built adapters. Cannot handle arbitrary websites. | + +**opencli is not the right tool here.** If you need to explore unknown websites or handle one-off tasks on sites without adapters, use an LLM-driven browser tool. opencli trades generality for determinism and cost. + +### 5. Desktop App Control + +> "I want to script Cursor, ChatGPT, Notion, or other Electron apps from the terminal." + +| Tool | Fit | Notes | +|------|-----|-------| +| **opencli** | Best | 8 desktop adapters via CDP + AppleScript. The only CLI tool with this capability. | +| All others | N/A | Browser automation tools cannot control desktop applications. | + +**This is unique to opencli.** No other tool in this comparison can send a prompt to ChatGPT desktop, extract code from Cursor, or write to Notion pages via CLI. + +## Key Trade-offs + +### opencli's Strengths + +- **Zero LLM cost** — No tokens consumed at runtime. Run 10,000 times for free. +- **Deterministic output** — Same command always returns the same schema. Pipeable, scriptable, CI-friendly. +- **Speed** — Adapter commands return in seconds, not minutes. +- **Broad platform coverage** — 50+ sites spanning global platforms (Reddit, HackerNews, Twitter, YouTube) and Chinese platforms (Bilibili, Zhihu, Xiaohongshu, Douban, Weibo) with adapters that understand local anti-bot patterns. +- **Desktop app control** — CDP adapters for Cursor, Codex, Notion, ChatGPT, Discord, and more. +- **Easy to extend** — Drop a `.yaml` or `.ts` adapter into the `clis/` folder for auto-registration. Contributing a new site adapter is straightforward. + +### opencli's Limitations + +- **Coverage requires adapters** — opencli only works with sites that have pre-built adapters. Adding a new site means writing a YAML or TypeScript adapter. +- **Adapter maintenance** — When a website updates its DOM or API, the corresponding adapter may need updating. The community maintains these, but breakage is possible. +- **Not general-purpose** — Cannot handle arbitrary websites. For unknown sites, pair opencli with a general browser tool as a fallback. + +## Complementary Usage + +opencli works best alongside general-purpose browser tools, not as a replacement: + +``` +Has adapter? ──yes──▶ opencli (fast, free, deterministic) + │ + no + │ + ▼ +One-off task? ──yes──▶ Browser-Use / Stagehand (LLM-driven) + │ + no + │ + ▼ +Recurring? ──yes──▶ Write an opencli adapter, then use opencli +``` + +## Further Reading + +- [Architecture Overview](./developer/architecture.md) +- [Writing a YAML Adapter](./developer/yaml-adapter.md) +- [Writing a TypeScript Adapter](./developer/ts-adapter.md) +- [Testing Guide](./developer/testing.md) +- [AI Workflow](./developer/ai-workflow.md) +- [Contributing Guide](./developer/contributing.md)