From 9eb7a1eaa1231c4070265ce46a3b7da5edccdf0e Mon Sep 17 00:00:00 2001 From: AlexYue Date: Fri, 20 Mar 2026 16:08:34 +0800 Subject: [PATCH] docs: add VitePress documentation site with GitHub Pages deployment (#127) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: deduplicate documentation — single source of truth in docs/ - Remove root CDP.md, CDP.zh-CN.md, CLI-ELECTRON.md (now in docs/advanced/) - Slim adapter READMEs to one-liner + link to docs/ (11 files) - Update README.md adapter table links to point to docs/ * docs: set VitePress base path for GitHub Pages deployment --- CDP.md | 103 -------------------------- CDP.zh-CN.md | 103 -------------------------- CLI-ELECTRON.md | 125 -------------------------------- README.md | 20 ++--- docs/.vitepress/config.mts | 1 + src/clis/antigravity/README.md | 49 +------------ src/clis/chaoxing/README.md | 26 +------ src/clis/chatgpt/README.md | 45 +----------- src/clis/chatwise/README.md | 39 +--------- src/clis/codex/README.md | 35 +-------- src/clis/cursor/README.md | 34 +-------- src/clis/discord-app/README.md | 27 +------ src/clis/feishu/README.md | 19 +---- src/clis/neteasemusic/README.md | 32 +------- src/clis/notion/README.md | 28 +------ src/clis/wechat/README.md | 27 +------ 16 files changed, 39 insertions(+), 674 deletions(-) delete mode 100644 CDP.md delete mode 100644 CDP.zh-CN.md delete mode 100644 CLI-ELECTRON.md diff --git a/CDP.md b/CDP.md deleted file mode 100644 index 09079f3..0000000 --- a/CDP.md +++ /dev/null @@ -1,103 +0,0 @@ -# Connecting OpenCLI via CDP (Remote/Headless Servers) - -If you cannot use the opencli Browser Bridge extension (e.g., in a remote headless server environment without a UI), OpenCLI provides an alternative: connecting directly to Chrome via **CDP (Chrome DevTools Protocol)**. - -Because CDP binds to `localhost` by default for security reasons, accessing it from a remote server requires an additional networking tunnel. - -This guide is broken down into three phases: -1. **Preparation**: Start Chrome with CDP enabled locally. -2. **Network Tunnels**: Expose that CDP port to your remote server using either **SSH Tunnels** or **Reverse Proxies**. -3. **Execution**: Run OpenCLI on your server. - ---- - -## Phase 1: Preparation (Local Machine) - -First, you need to start a Chrome browser on your local machine with remote debugging enabled. - -**macOS:** -```bash -/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \ - --remote-debugging-port=9222 \ - --user-data-dir="$HOME/chrome-debug-profile" \ - --remote-allow-origins="*" -``` - -**Linux:** -```bash -google-chrome \ - --remote-debugging-port=9222 \ - --user-data-dir="$HOME/chrome-debug-profile" \ - --remote-allow-origins="*" -``` - -**Windows:** -```cmd -"C:\Program Files\Google\Chrome\Application\chrome.exe" ^ - --remote-debugging-port=9222 ^ - --user-data-dir="%USERPROFILE%\chrome-debug-profile" ^ - --remote-allow-origins="*" -``` - -> **Note**: The `--remote-allow-origins="*"` flag is often required for modern Chrome versions to accept cross-origin CDP WebSocket connections (e.g. from reverse proxies like ngrok). - -Once this browser instance opens, **log into the target websites you want to use** (e.g., bilibili.com, zhihu.com) so that the session contains the correct cookies. - ---- - -## Phase 2: Remote Access Methods - -Once CDP is running locally on port `9222`, you must securely expose this port to your remote server. Choose one of the two methods below depending on your network conditions. - -### Method A: SSH Tunnel (Recommended) - -If your local machine has SSH access to the remote server, this is the most secure and straightforward method. - -Run this command on your **Local Machine** to forward the remote server's port `9222` back to your local port `9222`: - -```bash -ssh -R 9222:localhost:9222 your-server-user@your-server-ip -``` - -Leave this SSH session running in the background. - -### Method B: Reverse Proxy (ngrok / frp / socat) - -If you cannot establish a direct SSH connection (e.g., due to NAT or firewalls), you can use an intranet penetration tool like `ngrok`. - -Run this command on your **Local Machine** to expose your local port `9222` to the public internet securely via ngrok: - -```bash -ngrok http 9222 -``` - -This will print a forwarding URL, such as `https://abcdef.ngrok.app`. **Copy this URL**. - ---- - -## Phase 3: Execution (Remote Server) - -Now switch to your **Remote Server** where OpenCLI is installed. - -Depending on the network tunnel method you chose in Phase 2, set the `OPENCLI_CDP_ENDPOINT` environment variable and run your commands. - -### If you used Method A (SSH Tunnel): - -```bash -export OPENCLI_CDP_ENDPOINT="http://localhost:9222" -opencli doctor # Verify connection -opencli bilibili hot --limit 5 # Test a command -``` - -### If you used Method B (Reverse Proxy like ngrok): - -```bash -# Use the URL you copied from ngrok earlier -export OPENCLI_CDP_ENDPOINT="https://abcdef.ngrok.app" -opencli doctor # Verify connection -opencli bilibili hot --limit 5 # Test a command -``` - -> *Tip: If you provide a standard HTTP/HTTPS CDP endpoint, OpenCLI requests the `/json` target list and picks the most likely inspectable app/page target automatically. If multiple app targets exist, you can further narrow selection with `OPENCLI_CDP_TARGET` (for example `antigravity` or `codex`).* - -If you plan to use this setup frequently, you can persist the environment variable by adding the `export` line to your `~/.bashrc` or `~/.zshrc` on the server. diff --git a/CDP.zh-CN.md b/CDP.zh-CN.md deleted file mode 100644 index 94930f3..0000000 --- a/CDP.zh-CN.md +++ /dev/null @@ -1,103 +0,0 @@ -# 通过 CDP 远程连接 OpenCLI (服务器/无头环境) - -如果你无法使用 opencli Browser Bridge 浏览器扩展(例如:在无界面的远程服务器上运行 OpenCLI 时),OpenCLI 提供了备选方案:通过连接 **CDP (Chrome DevTools Protocol,即 Chrome 开发者工具协议)** 来直接控制本地 Chrome。 - -出于安全考虑,CDP 默认仅绑定在 `localhost` 的本地端口。所以,若是想让**远程服务器**调用本地的 CDP 服务,我们需要依靠一层额外的网络隧道。 - -本指南将整个过程拆分为三个阶段: -1. **阶段一:准备工作**(在本地启动允许 CDP 调试的 Chrome)。 -2. **阶段二:建立网络隧道**(通过 **SSH反向隧道** 或 **反向代理工具**,将本地的 CDP 端口暴露给服务器)。 -3. **阶段三:执行命令**(在服务器端运行 OpenCLI)。 - ---- - -## 阶段一:准备工作 (本地电脑) - -首先,你需要在你的本地电脑上,通过命令行参数启动一个开启了远程调试端口的 Chrome 实例。 - -**macOS:** -```bash -/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \ - --remote-debugging-port=9222 \ - --user-data-dir="$HOME/chrome-debug-profile" \ - --remote-allow-origins="*" -``` - -**Linux:** -```bash -google-chrome \ - --remote-debugging-port=9222 \ - --user-data-dir="$HOME/chrome-debug-profile" \ - --remote-allow-origins="*" -``` - -**Windows:** -```cmd -"C:\Program Files\Google\Chrome\Application\chrome.exe" ^ - --remote-debugging-port=9222 ^ - --user-data-dir="%USERPROFILE%\chrome-debug-profile" ^ - --remote-allow-origins="*" -``` - -> **注意**:此处增加的 `--remote-allow-origins="*"` 参数对于较新版本的 Chrome 来说通常是[必需的],以允许来自反向代理(如 ngrok)的跨域 WebSocket 连接请求。 - -待这个新的浏览器实例打开后,**手工登录那些你打算使用的网站**(如 bilibili.com、zhihu.com 等),这可以让该浏览器的运行资料(Profile)保留上这些网站登录用的 Cookie。 - ---- - -## 阶段二:建立网络隧道 - -现在你的本地已经有了一个监听在 `9222` 端口的 CDP 服务,接下来,选择以下任意一种方式将其实际暴露给你的远端服务器。 - -### 方法 A:SSH 反向端口转发 (推荐) - -如果你的本地电脑可以直连远程服务器的 SSH,那么这是最简单且最安全的做法。 - -在你的 **本地电脑** 终端上直接运行这条 ssh 命令,将远程服务器的 `9222` 端口反向映射回本地的 `9222` 端口: - -```bash -ssh -R 9222:localhost:9222 your-server-user@your-server-ip -``` - -保持此 SSH 会话在后台运行即可。 - -### 方法 B:反向代理 / 内网穿透 (ngrok / frp / socat) - -如果因为 NAT 或防火墙等因素导致无法直连 SSH 服务器,你可以使用 `ngrok` 等内网穿透工具。 - -在 **本地电脑** 运行 ngrok 将本地的 `9222` 端口暴露到公网: - -```bash -ngrok http 9222 -``` - -此时终端里会打印出一段专属的转发 URL 地址(如:`https://abcdef.ngrok.app`)。**复制这一段 URL 地址备用**。 - ---- - -## 阶段三:执行命令 (远程服务器) - -现在,所有的准备工作已结束。请切换到你已安装好 OpenCLI 的 **远程服务器** 终端上。 - -根据你在上方阶段二所选择的隧道方案,在终端中配置对应的 `OPENCLI_CDP_ENDPOINT` 环境变量: - -### 若使用 方法 A (SSH 反向隧道): - -```bash -export OPENCLI_CDP_ENDPOINT="http://localhost:9222" -opencli doctor # 查看并验证连接是否通畅 -opencli bilibili hot --limit 5 # 执行目标命令 -``` - -### 若使用 方法 B (Ngrok 等反向代理): - -```bash -# 将刚刚使用 ngrok 得到的地址填入这里 -export OPENCLI_CDP_ENDPOINT="https://abcdef.ngrok.app" -opencli doctor # 查看并验证连接是否通畅 -opencli bilibili hot --limit 5 # 执行目标命令 -``` - -> *Tip: 如果你填写的是一个普通 HTTP/HTTPS 的 CDP 地址,OpenCLI 会自动请求 `/json` target 列表,并挑选最可能的 app/page target;如果同一个端口下暴露了多个应用 target,还可以通过 `OPENCLI_CDP_TARGET`(例如 `antigravity`、`codex`)进一步缩小匹配范围。* - -如果你想在此服务器上永久启用该配置,可以将对应的 `export` 语句追加进入你的 `~/.bashrc` 或 `~/.zshrc` 配置文件中。 diff --git a/CLI-ELECTRON.md b/CLI-ELECTRON.md deleted file mode 100644 index ec298b9..0000000 --- a/CLI-ELECTRON.md +++ /dev/null @@ -1,125 +0,0 @@ ---- -description: How to CLI-ify and automate any Electron Desktop Application via CDP ---- - -# CLI-ifying Electron Applications (Skill Guide) - -Based on the successful automation of **Cursor**, **Codex**, **Antigravity**, **ChatWise**, **Notion**, and **Discord** desktop apps, this guide serves as the standard operating procedure (SOP) for adapting ANY Electron-based application into an OpenCLI adapter. - -## Core Concept - -Electron apps are essentially local Chromium browser instances. By exposing a debugging port (CDP — Chrome DevTools Protocol) at launch time, we can use the Browser Bridge to pierce through the UI layer, accessing and controlling all underlying state including React/Vue components and Shadow DOM. - -> **Note:** Not all desktop apps are Electron. WeChat (native Cocoa) and Feishu/Lark (custom Lark Framework) embed Chromium but do NOT expose CDP. For those apps, use the AppleScript + clipboard approach instead (see [Non-Electron Pattern](#non-electron-pattern-applescript)). - -### Launching the Target App -```bash -/Applications/AppName.app/Contents/MacOS/AppName --remote-debugging-port=9222 -``` - -### Verifying Electron -```bash -# Check for Electron Framework in the app bundle -ls /Applications/AppName.app/Contents/Frameworks/Electron\ Framework.framework -# If this directory exists → Electron → CDP works -# If not → check for libEGL.dylib (embedded Chromium/CEF, CDP may not work) -``` - -## The 5-Command Pattern (CDP / Electron) - -Every new Electron adapter should implement these 5 commands in `src/clis//`: - -### 1. `status.ts` — Connection Test -```typescript -export const statusCommand = cli({ - site: 'myapp', - name: 'status', - domain: 'localhost', - strategy: Strategy.UI, - browser: true, // Requires CDP connection - args: [], - columns: ['Status', 'Url', 'Title'], - func: async (page: IPage) => { - const url = await page.evaluate('window.location.href'); - const title = await page.evaluate('document.title'); - return [{ Status: 'Connected', Url: url, Title: title }]; - }, -}); -``` - -### 2. `dump.ts` — Reverse Engineering Core -Modern app DOMs are huge and obfuscated. **Never guess selectors.** Dump first, then extract precise class names with AI or `grep`: -```typescript -const dom = await page.evaluate('document.body.innerHTML'); -fs.writeFileSync('/tmp/app-dom.html', dom); -const snap = await page.snapshot({ interactive: false }); -fs.writeFileSync('/tmp/app-snapshot.json', JSON.stringify(snap, null, 2)); -``` - -### 3. `send.ts` — Advanced Text Injection -Electron apps often use complex rich-text editors (Monaco, Lexical, ProseMirror). Setting `.value` directly is ignored by React state. - -**Best practice:** Use `document.execCommand('insertText')` to perfectly simulate real user input, fully piercing React state: -```javascript -const composer = document.querySelector('[contenteditable="true"]'); -composer.focus(); -document.execCommand('insertText', false, 'Hello'); -``` -Then submit with `await page.pressKey('Enter')`. - -### 4. `read.ts` — Context Extraction -Don't extract the entire page text. Use `dump.ts` output to find the real "conversation container": -- Look for semantic selectors: `[role="log"]`, `[data-testid="conversation"]`, `[data-content-search-turn-key]` -- Format output as Markdown — readable by both humans and LLMs - -### 5. `new.ts` — Keyboard Shortcuts -Many GUI actions respond to native shortcuts rather than button clicks: -```typescript -const isMac = process.platform === 'darwin'; -await page.pressKey(isMac ? 'Meta+N' : 'Control+N'); -await page.wait(1); // Wait for re-render -``` - -## Environment Variable -```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9222" -``` - -## Non-Electron Pattern (AppleScript) - -For native macOS apps (WeChat, Feishu) that don't expose CDP: -```typescript -export const statusCommand = cli({ - site: 'myapp', - strategy: Strategy.PUBLIC, - browser: false, // No browser needed - func: async (page: IPage | null) => { - const output = execSync("osascript -e 'application \"MyApp\" is running'", { encoding: 'utf-8' }).trim(); - return [{ Status: output === 'true' ? 'Running' : 'Stopped' }]; - }, -}); -``` - -Core techniques: -- **status**: `osascript -e 'application "AppName" is running'` -- **send**: `pbcopy` → activate window → `Cmd+V` → `Enter` -- **read**: `Cmd+A` → `Cmd+C` → `pbpaste` -- **search**: Activate → `Cmd+F`/`Cmd+K` → `keystroke "query"` - -## Pitfalls & Gotchas - -1. **Port conflicts (EADDRINUSE)**: Only one app per port. Use unique ports: Codex=9222, ChatGPT=9224, Cursor=9226, ChatWise=9228, Notion=9230, Discord=9232 -2. **IPage abstraction**: OpenCLI wraps the browser page as `IPage` (`src/types.ts`). Use `page.pressKey()` and `page.evaluate()`, NOT direct DOM APIs -3. **Timing**: Always add `await page.wait(0.5)` to `1.0` after DOM mutations. Returning too early disconnects prematurely -4. **AppleScript requires Accessibility**: Terminal app must be granted permission in System Settings → Privacy & Security → Accessibility - -## Port Assignment Table - -| App | Port | Mode | -|-----|------|------| -| Codex | 9222 | CDP | -| ChatGPT | 9224 | CDP / AppleScript | -| Cursor | 9226 | CDP | -| ChatWise | 9228 | CDP | -| Notion | 9230 | CDP | -| Discord App | 9232 | CDP | diff --git a/README.md b/README.md index fee583d..27c7653 100644 --- a/README.md +++ b/README.md @@ -150,16 +150,16 @@ Each desktop adapter has its own detailed documentation with commands reference, | App | Description | Doc | |-----|-------------|-----| -| **Cursor** | Control Cursor IDE — Composer, chat, code extraction | [README](./src/clis/cursor/README.md) | -| **Codex** | Drive OpenAI Codex CLI agent headlessly | [README](./src/clis/codex/README.md) | -| **Antigravity** | Control Antigravity Ultra from terminal | [README](./src/clis/antigravity/README.md) | -| **ChatGPT** | Automate ChatGPT macOS desktop app | [README](./src/clis/chatgpt/README.md) | -| **ChatWise** | Multi-LLM client (GPT-4, Claude, Gemini) | [README](./src/clis/chatwise/README.md) | -| **Notion** | Search, read, write Notion pages | [README](./src/clis/notion/README.md) | -| **Discord** | Discord Desktop — messages, channels, servers | [README](./src/clis/discord-app/README.md) | -| **Feishu** | 飞书/Lark Desktop via AppleScript | [README](./src/clis/feishu/README.md) | -| **WeChat** | 微信 Desktop via AppleScript + Accessibility | [README](./src/clis/wechat/README.md) | -| **NeteaseMusic** | 网易云音乐 Desktop via CEF/CDP | [README](./src/clis/neteasemusic/README.md) | +| **Cursor** | Control Cursor IDE — Composer, chat, code extraction | [Doc](./docs/adapters/desktop/cursor.md) | +| **Codex** | Drive OpenAI Codex CLI agent headlessly | [Doc](./docs/adapters/desktop/codex.md) | +| **Antigravity** | Control Antigravity Ultra from terminal | [Doc](./docs/adapters/desktop/antigravity.md) | +| **ChatGPT** | Automate ChatGPT macOS desktop app | [Doc](./docs/adapters/desktop/chatgpt.md) | +| **ChatWise** | Multi-LLM client (GPT-4, Claude, Gemini) | [Doc](./docs/adapters/desktop/chatwise.md) | +| **Notion** | Search, read, write Notion pages | [Doc](./docs/adapters/desktop/notion.md) | +| **Discord** | Discord Desktop — messages, channels, servers | [Doc](./docs/adapters/desktop/discord.md) | +| **Feishu** | 飞书/Lark Desktop via AppleScript | [Doc](./docs/adapters/desktop/feishu.md) | +| **WeChat** | 微信 Desktop via AppleScript + Accessibility | [Doc](./docs/adapters/desktop/wechat.md) | +| **NeteaseMusic** | 网易云音乐 Desktop via CEF/CDP | [Doc](./docs/adapters/desktop/neteasemusic.md) | ## Download Support diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 4fa4f8f..885f1ea 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -1,6 +1,7 @@ import { defineConfig } from 'vitepress' export default defineConfig({ + base: '/opencli/', title: 'OpenCLI', description: 'Make any website or Electron App your CLI — AI-powered, account-safe, self-healing.', diff --git a/src/clis/antigravity/README.md b/src/clis/antigravity/README.md index 2c2aa7d..789d03e 100644 --- a/src/clis/antigravity/README.md +++ b/src/clis/antigravity/README.md @@ -1,48 +1,5 @@ -# Antigravity CLI Adapter +# Antigravity Adapter -🔥 **CLI All Electron Apps! The Most Powerful Update Has Arrived!** 🔥 +Control **Antigravity Ultra** from the terminal via Chrome DevTools Protocol (CDP). -Turn ANY Electron application into a CLI tool! Recombine, script, and extend applications like Antigravity Ultra seamlessly. Now AI can control itself natively. Unlimited possibilities await! - -Turn your local Antigravity desktop application into a programmable AI node via Chrome DevTools Protocol (CDP). This allows you to compose complex LLM workflows entirely through the terminal by manipulating the actual UI natively, bypassing any API restrictions. - -## Prerequisites - -Start the Antigravity desktop app with the Chrome DevTools `remote-debugging-port` flag: - -\`\`\`bash -# Start Antigravity in the background -/Applications/Antigravity.app/Contents/MacOS/Electron \ - --remote-debugging-port=9224 -\`\`\` - -*(Note: Depending on your installation, the executable might be named differently, e.g., \`Antigravity\` instead of \`Electron\`.)* - -Next, set the target port in your terminal session to tell OpenCLI where to connect: - -\`\`\`bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9224" -\`\`\` - -## Available Commands - -### \`opencli antigravity status\` -Check the Chromium CDP connection. Returns the current window title and active internal URL. - -### \`opencli antigravity send \` -Send a text prompt to the AI. Automatically locates the Lexical editor input box, types the prompt securely, and hits Enter. - -### \`opencli antigravity read\` -Scrape the entire current conversation history block as pure text. Useful for feeding the context to another script. - -### \`opencli antigravity new\` -Click the "New Conversation" button to instantly clear the UI state and start fresh. - -### \`opencli antigravity extract-code\` -Extract any multi-line code blocks from the current conversation view. Ideal for automated script extraction (e.g. \`opencli antigravity extract-code > script.sh\`). - -### \`opencli antigravity model \` -Quickly target and switch the active LLM engine. Example: \`opencli antigravity model claude\` or \`opencli antigravity model gemini\`. - -### \`opencli antigravity watch\` -A long-running, streaming process that continuously polls the Antigravity UI for chat updates and outputs them in real-time to standard output. +📖 **Full documentation**: [docs/adapters/desktop/antigravity](../../../docs/adapters/desktop/antigravity.md) diff --git a/src/clis/chaoxing/README.md b/src/clis/chaoxing/README.md index 012dbcc..881c467 100644 --- a/src/clis/chaoxing/README.md +++ b/src/clis/chaoxing/README.md @@ -2,35 +2,13 @@ View your Chaoxing assignments and exams from the terminal by reusing your Chrome login session. -## Prerequisites - -1. Chrome must be running and already logged into Chaoxing (`i.chaoxing.com`). -2. The opencli Browser Bridge extension must be installed. +📖 **Full documentation**: See commands and usage below. ## Commands | Command | Description | |---------|-------------| | `opencli chaoxing assignments` | List assignments across all courses | -| `opencli chaoxing assignments --course "数学"` | Filter by course name (fuzzy match) | -| `opencli chaoxing assignments --status pending` | Filter: `all` / `pending` / `submitted` / `graded` | | `opencli chaoxing exams` | List exams across all courses | -| `opencli chaoxing exams --course "数学"` | Filter by course name | -| `opencli chaoxing exams --status upcoming` | Filter: `all` / `upcoming` / `ongoing` / `finished` | -## How It Works - -Chaoxing has no flat API for listing assignments/exams. The adapter follows the same -flow a student would in the browser: - -1. Establish session via the interaction page -2. Fetch enrolled course list (`backclazzdata` JSON API) -3. Enter each course via `stucoursemiddle` redirect (obtains session `enc`) -4. Click the 作业/考试 tab and capture the iframe URL -5. Navigate to that URL and parse the DOM - -## Limitations - -- Requires `--course` filter for practical use (scanning all 40+ courses is slow) -- Does not submit homework or exams -- If Chaoxing changes page structure, the DOM parser may need updates +Supports `--course` and `--status` filters. Requires Chrome logged into `i.chaoxing.com` with Browser Bridge extension installed. diff --git a/src/clis/chatgpt/README.md b/src/clis/chatgpt/README.md index 7d491e2..dd23a62 100644 --- a/src/clis/chatgpt/README.md +++ b/src/clis/chatgpt/README.md @@ -1,44 +1,5 @@ -# ChatGPT Desktop Adapter for OpenCLI +# ChatGPT Adapter -Control the **ChatGPT macOS Desktop App** directly from the terminal. OpenCLI supports two automation approaches for ChatGPT. +Control the **ChatGPT macOS Desktop App** from the terminal via AppleScript or CDP. -## Approach 1: AppleScript (Default, No Setup) - -The current built-in commands use native AppleScript automation — no extra launch flags needed. - -### Prerequisites -1. Install the official [ChatGPT Desktop App](https://openai.com/chatgpt/mac/) from OpenAI. -2. Grant **Accessibility permissions** to your terminal app (Terminal / iTerm / Warp) in **System Settings → Privacy & Security → Accessibility**. This is required for System Events keystroke simulation. - -### Commands -- `opencli chatgpt status`: Check if the ChatGPT app is currently running. -- `opencli chatgpt new`: Activate ChatGPT and press `Cmd+N` to start a new conversation. -- `opencli chatgpt send "message"`: Copy your message to clipboard, activate ChatGPT, paste, and submit. -- `opencli chatgpt read`: Copy the last AI response via `Cmd+Shift+C` and return it as text. - -## Approach 2: CDP (Advanced, Electron Debug Mode) - -ChatGPT Desktop is also an Electron app and can be launched with a remote debugging port for deeper automation via CDP: - -```bash -/Applications/ChatGPT.app/Contents/MacOS/ChatGPT \ - --remote-debugging-port=9224 -``` - -Then set the endpoint: -```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9224" -``` - -> **Note**: The CDP approach enables future advanced commands like DOM inspection, model switching, and code extraction — similar to the Cursor and Codex adapters. - -## How It Works - -- **AppleScript mode**: Uses `osascript` and `pbcopy`/`pbpaste` for clipboard-based text transfer. No remote debugging port needed. -- **CDP mode**: Connects via Chrome DevTools Protocol to the Electron renderer process for direct DOM manipulation. - -## Limitations - -- macOS only (AppleScript dependency) -- AppleScript mode requires Accessibility permissions -- `read` command copies the last response — earlier messages need manual scroll +📖 **Full documentation**: [docs/adapters/desktop/chatgpt](../../../docs/adapters/desktop/chatgpt.md) diff --git a/src/clis/chatwise/README.md b/src/clis/chatwise/README.md index e343c0d..1ac07a5 100644 --- a/src/clis/chatwise/README.md +++ b/src/clis/chatwise/README.md @@ -1,38 +1,5 @@ -# ChatWise Adapter for OpenCLI +# ChatWise Adapter -Control the **ChatWise Desktop App** from the terminal via Chrome DevTools Protocol (CDP). ChatWise is an Electron-based multi-LLM client supporting GPT-4, Claude, Gemini, and more. +Control the **ChatWise Desktop App** (multi-LLM client) from the terminal via CDP. -## Prerequisites - -1. Install [ChatWise](https://chatwise.app/). -2. Launch with remote debugging port: - ```bash - /Applications/ChatWise.app/Contents/MacOS/ChatWise \ - --remote-debugging-port=9228 - ``` - -## Setup - -```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9228" -``` - -## Commands - -### Diagnostics -- `opencli chatwise status`: Check CDP connection status. -- `opencli chatwise screenshot`: Export DOM + accessibility snapshot. - -### Chat -- `opencli chatwise new`: Start a new conversation (`Cmd+N`). -- `opencli chatwise send "message"`: Send a message to the active chat. -- `opencli chatwise read`: Read the current conversation. -- `opencli chatwise ask "prompt"`: Send + wait for response + return it (one-shot). - -### AI Features -- `opencli chatwise model`: Get the current AI model. -- `opencli chatwise model gpt-4`: Switch to a different model. - -### Organization -- `opencli chatwise history`: List conversations from the sidebar. -- `opencli chatwise export`: Export conversation as Markdown. +📖 **Full documentation**: [docs/adapters/desktop/chatwise](../../../docs/adapters/desktop/chatwise.md) diff --git a/src/clis/codex/README.md b/src/clis/codex/README.md index ef24abe..120d0b2 100644 --- a/src/clis/codex/README.md +++ b/src/clis/codex/README.md @@ -1,34 +1,5 @@ -# OpenAI Codex Adapter for OpenCLI +# Codex Adapter -Control the **OpenAI Codex Desktop App** headless or headfully via Chrome DevTools Protocol (CDP). -Because Codex is built on Electron, OpenCLI can directly drive its internal UI, automate slash commands, and manipulate its AI agent threads. +Control the **OpenAI Codex Desktop App** via Chrome DevTools Protocol (CDP). -## Prerequisites - -1. You must have the official OpenAI Codex app installed. -2. Launch it via the terminal and expose the remote debugging port: - ```bash - # macOS - /Applications/Codex.app/Contents/MacOS/Codex --remote-debugging-port=9222 - ``` - -## Setup - -Export the CDP endpoint in your shell: -```bash -export OPENCLI_CODEX_CDP_ENDPOINT="http://127.0.0.1:9222" -``` - -## Commands - -### Diagnostics -- `opencli codex status`: Checks connection and reads the current active window URL/title. -- `opencli codex dump`: Dumps the full UI DOM and Accessibility tree into `/tmp` (ideal for building AI automation tools on top of it). - -### Agent Manipulation -- `opencli codex new`: Simulates `Cmd+N` to start a completely fresh and isolated Git Worktree thread context. -- `opencli codex send "message"`: Robustly finds the active Thread Composer and injects your text. - - *Pro-tip*: You can trigger internal shortcuts by sending them, e.g., `opencli codex send "/review"` or `opencli codex send "$imagegen draw a cat"`. -- `opencli codex read`: Extracts the entire current thread history and AI reasoning logs into readable text. -- `opencli codex extract-diff`: Automatically scrapes any visual Patch chunks and Code Diffs the AI generated inside the review UI. -- `opencli codex model`: Get the currently active AI model. +📖 **Full documentation**: [docs/adapters/desktop/codex](../../../docs/adapters/desktop/codex.md) diff --git a/src/clis/cursor/README.md b/src/clis/cursor/README.md index a4eb5a4..1666d61 100644 --- a/src/clis/cursor/README.md +++ b/src/clis/cursor/README.md @@ -1,33 +1,5 @@ -# Cursor Adapter for OpenCLI +# Cursor Adapter -Control the **Cursor IDE** from the terminal via Chrome DevTools Protocol (CDP). Since Cursor is built on Electron (VS Code fork), OpenCLI can drive its internal UI, automate Composer interactions, and manipulate chat sessions. +Control the **Cursor IDE** from the terminal via Chrome DevTools Protocol (CDP). -## Prerequisites - -1. Install [Cursor](https://cursor.sh/). -2. Launch it with the remote debugging port: - ```bash - /Applications/Cursor.app/Contents/MacOS/Cursor --remote-debugging-port=9226 - ``` - -## Setup - -```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9226" -``` - -## Commands - -### Diagnostics -- `opencli cursor status`: Check CDP connection status. -- `opencli cursor dump`: Dump the full DOM and Accessibility snapshot to `/tmp/cursor-dom.html` and `/tmp/cursor-snapshot.json`. - -### Chat Manipulation -- `opencli cursor new`: Press `Cmd+N` to start a new file/tab. -- `opencli cursor send "message"`: Inject text into the active Composer/Chat input and submit. -- `opencli cursor read`: Extract the full conversation history from the active chat panel. - -### AI Features -- `opencli cursor composer "prompt"`: Open the Composer panel (`Cmd+I`) and send a prompt for inline AI editing. -- `opencli cursor model`: Get the currently active AI model (e.g., `claude-4.5-sonnet`). -- `opencli cursor extract-code`: Extract all code blocks from the current conversation. +📖 **Full documentation**: [docs/adapters/desktop/cursor](../../../docs/adapters/desktop/cursor.md) diff --git a/src/clis/discord-app/README.md b/src/clis/discord-app/README.md index 6bfbd90..695519c 100644 --- a/src/clis/discord-app/README.md +++ b/src/clis/discord-app/README.md @@ -1,28 +1,5 @@ -# Discord Desktop Adapter +# Discord Adapter Control the **Discord Desktop App** from the terminal via Chrome DevTools Protocol (CDP). -## Prerequisites - -Launch with remote debugging port: -```bash -/Applications/Discord.app/Contents/MacOS/Discord --remote-debugging-port=9232 -``` - -## Setup - -```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9232" -``` - -## Commands - -| Command | Description | -|---------|-------------| -| `discord status` | Check CDP connection | -| `discord send "message"` | Send a message in the active channel | -| `discord read` | Read recent messages | -| `discord channels` | List channels in the current server | -| `discord servers` | List all joined servers | -| `discord search "query"` | Search messages (Cmd+F) | -| `discord members` | List online members | +📖 **Full documentation**: [docs/adapters/desktop/discord](../../../docs/adapters/desktop/discord.md) diff --git a/src/clis/feishu/README.md b/src/clis/feishu/README.md index ea7848f..088ab73 100644 --- a/src/clis/feishu/README.md +++ b/src/clis/feishu/README.md @@ -1,20 +1,5 @@ -# Feishu (飞书/Lark) Desktop Adapter +# Feishu (飞书/Lark) Adapter Control **Feishu/Lark Desktop** from the terminal via AppleScript. -> **Note:** Feishu uses a custom `Lark Framework` (Chromium-based but NOT Electron). CDP is not available, so this adapter uses AppleScript + clipboard. - -## Prerequisites - -1. Feishu/Lark must be running and logged in -2. Terminal must have **Accessibility permission** - -## Commands - -| Command | Description | -|---------|-------------| -| `feishu status` | Check if Feishu/Lark is running | -| `feishu send "msg"` | Send message in active chat (paste + Enter) | -| `feishu read` | Read current chat (Cmd+A → Cmd+C) | -| `feishu search "query"` | Global search (Cmd+K) | -| `feishu new` | New message/document (Cmd+N) | +📖 **Full documentation**: [docs/adapters/desktop/feishu](../../../docs/adapters/desktop/feishu.md) diff --git a/src/clis/neteasemusic/README.md b/src/clis/neteasemusic/README.md index 88d027e..7690709 100644 --- a/src/clis/neteasemusic/README.md +++ b/src/clis/neteasemusic/README.md @@ -1,31 +1,5 @@ -# NeteaseMusic Desktop Adapter (网易云音乐) +# NeteaseMusic (网易云音乐) Adapter -Control **NeteaseMusic** (网易云音乐) from the terminal via Chrome DevTools Protocol (CDP). The app uses Chromium Embedded Framework (CEF). +Control **NeteaseMusic** from the terminal via Chrome DevTools Protocol (CDP/CEF). -## Prerequisites - -Launch with remote debugging port: -```bash -/Applications/NeteaseMusic.app/Contents/MacOS/NeteaseMusic --remote-debugging-port=9234 -``` - -## Setup - -```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9234" -``` - -## Commands - -| Command | Description | -|---------|-------------| -| `neteasemusic status` | Check CDP connection | -| `neteasemusic playing` | Current song info (title, artist, album) | -| `neteasemusic play` | Play / Pause toggle | -| `neteasemusic next` | Skip to next song | -| `neteasemusic prev` | Go to previous song | -| `neteasemusic search "query"` | Search songs, artists | -| `neteasemusic playlist` | Show current playback queue | -| `neteasemusic like` | Like / unlike current song | -| `neteasemusic lyrics` | Get lyrics of current song | -| `neteasemusic volume [0-100]` | Get or set volume | +📖 **Full documentation**: [docs/adapters/desktop/neteasemusic](../../../docs/adapters/desktop/neteasemusic.md) diff --git a/src/clis/notion/README.md b/src/clis/notion/README.md index 6eb729c..41790f5 100644 --- a/src/clis/notion/README.md +++ b/src/clis/notion/README.md @@ -1,29 +1,5 @@ -# Notion Desktop Adapter +# Notion Adapter Control the **Notion Desktop App** from the terminal via Chrome DevTools Protocol (CDP). -## Prerequisites - -Launch with remote debugging port: -```bash -/Applications/Notion.app/Contents/MacOS/Notion --remote-debugging-port=9230 -``` - -## Setup - -```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9230" -``` - -## Commands - -| Command | Description | -|---------|-------------| -| `notion status` | Check CDP connection | -| `notion search "query"` | Quick Find search (Cmd+P) | -| `notion read` | Read the current page content | -| `notion new "title"` | Create a new page (Cmd+N) | -| `notion write "text"` | Append text to the current page | -| `notion sidebar` | List pages from the sidebar | -| `notion favorites` | List pages from the Favorites section | -| `notion export` | Export page as Markdown | +📖 **Full documentation**: [docs/adapters/desktop/notion](../../../docs/adapters/desktop/notion.md) diff --git a/src/clis/wechat/README.md b/src/clis/wechat/README.md index b5c8466..3c16534 100644 --- a/src/clis/wechat/README.md +++ b/src/clis/wechat/README.md @@ -1,28 +1,5 @@ -# WeChat (微信) Desktop Adapter +# WeChat (微信) Adapter Control **WeChat Mac Desktop** from the terminal via AppleScript + Accessibility API. -> **Note:** WeChat is a native macOS app (not Electron), so CDP is not available. This adapter uses AppleScript keyboard simulation and clipboard operations. - -## Prerequisites - -1. WeChat must be running and logged in -2. Terminal must have **Accessibility permission** (System Settings → Privacy & Security → Accessibility) - -## Commands - -| Command | Description | -|---------|-------------| -| `wechat status` | Check if WeChat is running | -| `wechat send "msg"` | Send message in the active chat (clipboard paste + Enter) | -| `wechat read` | Read current chat content (Cmd+A → Cmd+C) | -| `wechat search "keyword"` | Open search and type a query (Cmd+F) | -| `wechat chats` | Switch to Chats tab (Cmd+1) | -| `wechat contacts` | Switch to Contacts tab (Cmd+2) | - -## Limitations - -- **No CDP support** — WeChat is native Cocoa, not Electron -- `send` requires the correct conversation to be already open -- `read` captures whatever is visible via select-all + copy -- `search` types the query but cannot programmatically click results +📖 **Full documentation**: [docs/adapters/desktop/wechat](../../../docs/adapters/desktop/wechat.md)