diff --git a/.gitignore b/.gitignore index 6a3d79b..5794af9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ dist/ *.tsbuildinfo .opencli/ +.mcp.json diff --git a/README.md b/README.md index 22f8a04..23bcb3d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Node.js Version](https://img.shields.io/node/v/@jackwener/opencli?style=flat-square)](https://nodejs.org) [![License](https://img.shields.io/npm/l/@jackwener/opencli?style=flat-square)](./LICENSE) -A CLI tool that turns **any website** into a command-line interface. **59 commands** across **18 sites** — bilibili, zhihu, xiaohongshu, twitter, reddit, xueqiu, github, v2ex, hackernews, bbc, weibo, boss, yahoo-finance, reuters, smzdm, ctrip, youtube, coupang — powered by browser session reuse and AI-native discovery. +A CLI tool that turns **any website** into a command-line interface — bilibili, zhihu, xiaohongshu, twitter, reddit, and many more — powered by browser session reuse and AI-native discovery. --- @@ -46,11 +46,21 @@ OpenCLI connects to your browser through the Playwright MCP Bridge extension. ### Playwright MCP Bridge Extension Setup 1. Install **[Playwright MCP Bridge](https://chromewebstore.google.com/detail/playwright-mcp-bridge/mmlmfjhmonkocbjadbfplnigmagldckm)** extension in Chrome. -2. Obtain your token by clicking the extension icon in the browser toolbar or from the extension settings page. +2. Run `opencli setup` — it auto-discovers your token and lets you choose which tools to configure: -**You must configure this token in BOTH your MCP configuration AND system environment variables.** +```bash +opencli setup +``` -First, add it to your MCP client config (e.g. Claude/Cursor): +The interactive TUI will: +- 🔍 Auto-discover your token from Chrome (no manual copy needed) +- ☑️ Show all detected tools (Codex, Cursor, Claude Code, Gemini CLI, etc.) +- ✏️ Update only the files you select (Space to toggle, Enter to confirm) + +
+Manual setup (alternative) + +Add token to your MCP client config (e.g. Claude/Cursor): ```json { @@ -66,13 +76,15 @@ First, add it to your MCP client config (e.g. Claude/Cursor): } ``` -And, so that `opencli` commands can use it directly in the terminal, export it in your shell environment (e.g. `~/.zshrc`): +Export in shell (e.g. `~/.zshrc`): ```bash export PLAYWRIGHT_MCP_EXTENSION_TOKEN="" ``` -After configuring, run `opencli doctor` to verify your token is correctly set up across all locations: +
+ +Verify with `opencli doctor` — shows colored status for all config locations: ```bash opencli doctor diff --git a/README.zh-CN.md b/README.zh-CN.md index 53714b6..71a9488 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -9,7 +9,7 @@ [![Node.js Version](https://img.shields.io/node/v/@jackwener/opencli?style=flat-square)](https://nodejs.org) [![License](https://img.shields.io/npm/l/@jackwener/opencli?style=flat-square)](./LICENSE) -OpenCLI 将任何网站变成命令行工具。**59 个命令**覆盖 **18 个站点** — B站、知乎、小红书、Twitter、Reddit、雪球、GitHub、V2EX、Hacker News、BBC、微博、BOSS直聘、Yahoo Finance、路透社、什么值得买、携程、YouTube、Coupang — 复用浏览器登录态,AI 驱动探索。 +OpenCLI 将任何网站变成命令行工具 — B站、知乎、小红书、Twitter、Reddit 等众多站点 — 复用浏览器登录态,AI 驱动探索。 --- @@ -29,7 +29,7 @@ OpenCLI 将任何网站变成命令行工具。**59 个命令**覆盖 **18 个 ## 亮点 -- **59 个命令,18 个站点** — B站、知乎、小红书、Twitter、Reddit、雪球(xueqiu)、GitHub、V2EX、Hacker News、BBC、微博、BOSS直聘、Yahoo Finance、路透社、什么值得买、携程、YouTube、Coupang +- **多站点覆盖** — B站、知乎、小红书、Twitter、Reddit 等众多站点 - **零风控** — 复用 Chrome 登录态,无需存储任何凭证 - **AI 原生** — `explore` 自动发现 API,`synthesize` 生成适配器,`cascade` 探测认证策略 - **动态加载引擎** — 声明式的 `.yaml` 或者底层定制的 `.ts` 适配器,放入 `clis/` 文件夹即可自动注册生效 @@ -46,11 +46,21 @@ OpenCLI 通过 Playwright MCP Bridge 扩展与你的浏览器通信。 ### Playwright MCP Bridge 扩展配置 1. 安装 **[Playwright MCP Bridge](https://chromewebstore.google.com/detail/playwright-mcp-bridge/mmlmfjhmonkocbjadbfplnigmagldckm)** 扩展 -2. 在浏览器插件栏点击该插件,或者在插件设置页获取你的 Extension Token。 +2. 运行 `opencli setup` — 自动发现 Token 并让你选择要配置哪些工具: -**你必须将这个 Token 同时配置到你的 MCP 配置文件 AND 环境变量中。** +```bash +opencli setup +``` -首先,配置你的 MCP 客户端(如 Claude/Cursor 等): +交互式 TUI 会: +- 🔍 从 Chrome 自动发现 Token(无需手动复制) +- ☑️ 显示所有支持的工具(Codex、Cursor、Claude Code、Gemini CLI 等) +- ✏️ 只更新你选中的文件(空格切换,回车确认) + +
+手动配置(备选方案) + +配置你的 MCP 客户端(如 Claude/Cursor 等): ```json { @@ -66,13 +76,15 @@ OpenCLI 通过 Playwright MCP Bridge 扩展与你的浏览器通信。 } ``` -并且,为了让 `opencli` 命令行也能直接使用它,你必须在你的终端系统环境变量中导出它(建议写进 `~/.zshrc` 或 `~/.bashrc`): +在终端环境变量中导出(建议写进 `~/.zshrc`): ```bash export PLAYWRIGHT_MCP_EXTENSION_TOKEN="<你的-token>" ``` -配置完成后,运行 `opencli doctor` 检测你的 Token 是否在所有位置都正确配置: +
+ +配置后运行 `opencli doctor` 检查所有位置的 Token 状态: ```bash opencli doctor diff --git a/SKILL.md b/SKILL.md index 9e9acae..d0ddac5 100644 --- a/SKILL.md +++ b/SKILL.md @@ -1,7 +1,7 @@ --- name: opencli description: "OpenCLI — Make any website your CLI. Zero risk, AI-powered, reuse Chrome login." -version: 0.5.1 +version: 0.6.0 author: jackwener tags: [cli, browser, web, mcp, playwright, bilibili, zhihu, twitter, github, v2ex, hackernews, reddit, xiaohongshu, xueqiu, AI, agent] --- @@ -34,7 +34,8 @@ npm update -g @jackwener/opencli Browser commands require: 1. Chrome browser running **(logged into target sites)** -2. [Playwright MCP Bridge](https://chromewebstore.google.com/detail/playwright-mcp-bridge/mmlmfjhmonkocbjadbfplnigmagldckm) extension installed and configured +2. [Playwright MCP Bridge](https://chromewebstore.google.com/detail/playwright-mcp-bridge/mmlmfjhmonkocbjadbfplnigmagldckm) extension installed +3. Run `opencli setup` to auto-discover token and configure all tools > **Note**: You must be logged into the target website in Chrome before running commands. Tabs opened during command execution are auto-closed afterwards. @@ -139,6 +140,9 @@ opencli list --json # JSON output opencli list -f yaml # YAML output opencli validate # Validate all CLI definitions opencli validate bilibili # Validate specific site +opencli setup # Interactive token setup (auto-discover + TUI checkbox) +opencli doctor # Diagnose token config across all tools +opencli doctor --fix -y # Auto-fix all config files (non-interactive) ``` ### AI Agent Workflow