From 813631e468720abf727bffb2118c810387fccdeb Mon Sep 17 00:00:00 2001 From: jackwener Date: Wed, 18 Mar 2026 19:42:45 +0800 Subject: [PATCH] docs: remove unnecessary --remote-allow-origins, add CDP launch to ChatGPT README - Remove --remote-allow-origins from antigravity README, README.zh-CN, SKILL.md (not needed for local usage) - Update ChatGPT README to document both AppleScript and CDP approaches - Document ChatGPT Electron launch: /Applications/ChatGPT.app/Contents/MacOS/ChatGPT --remote-debugging-port=9224 --- src/clis/antigravity/README.md | 5 ++-- src/clis/antigravity/README.zh-CN.md | 5 ++-- src/clis/antigravity/SKILL.md | 2 +- src/clis/chatgpt/README.md | 41 +++++++++++++++---------- src/clis/chatgpt/README.zh-CN.md | 45 +++++++++++++++++----------- 5 files changed, 57 insertions(+), 41 deletions(-) diff --git a/src/clis/antigravity/README.md b/src/clis/antigravity/README.md index c63f05d..2c2aa7d 100644 --- a/src/clis/antigravity/README.md +++ b/src/clis/antigravity/README.md @@ -12,9 +12,8 @@ Start the Antigravity desktop app with the Chrome DevTools `remote-debugging-por \`\`\`bash # Start Antigravity in the background -/Applications/Antigravity.app/Contents/MacOS/Electron \\ - --remote-debugging-port=9224 \\ - --remote-allow-origins="*" +/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\`.)* diff --git a/src/clis/antigravity/README.zh-CN.md b/src/clis/antigravity/README.zh-CN.md index 10dbf18..6baa709 100644 --- a/src/clis/antigravity/README.zh-CN.md +++ b/src/clis/antigravity/README.zh-CN.md @@ -15,9 +15,8 @@ CLI all electron!现在支持把所有 electron 应用 CLI 化,从而组合 \`\`\`bash # 在后台启动并驻留 -/Applications/Antigravity.app/Contents/MacOS/Electron \\ - --remote-debugging-port=9224 \\ - --remote-allow-origins="*" +/Applications/Antigravity.app/Contents/MacOS/Electron \ + --remote-debugging-port=9224 \`\`\` *(注意:如果你打包的应用重命名过主构建,可能需要把 `Electron` 换成实际的可执行文件名,如 `Antigravity`)* diff --git a/src/clis/antigravity/SKILL.md b/src/clis/antigravity/SKILL.md index 1f6f7b4..245aced 100644 --- a/src/clis/antigravity/SKILL.md +++ b/src/clis/antigravity/SKILL.md @@ -9,7 +9,7 @@ This skill allows AI agents to control the [Antigravity](https://github.com/chen ## Requirements The target Electron application MUST be launched with the remote-debugging-port flag: \`\`\`bash -/Applications/Antigravity.app/Contents/MacOS/Electron --remote-debugging-port=9224 --remote-allow-origins="*" +/Applications/Antigravity.app/Contents/MacOS/Electron --remote-debugging-port=9224 \`\`\` The agent must configure the endpoint environment variable locally before invoking standard commands: diff --git a/src/clis/chatgpt/README.md b/src/clis/chatgpt/README.md index 566094b..7d9b0d0 100644 --- a/src/clis/chatgpt/README.md +++ b/src/clis/chatgpt/README.md @@ -1,35 +1,44 @@ # ChatGPT Desktop Adapter for OpenCLI -Control the **ChatGPT macOS Desktop App** directly from the terminal via native AppleScript automation. Unlike Electron-based apps (Antigravity, Codex, Cursor), ChatGPT Desktop is a native macOS application — OpenCLI drives it using `osascript` and System Events. +Control the **ChatGPT macOS Desktop App** directly from the terminal. OpenCLI supports two automation approaches for ChatGPT. -## Prerequisites +## 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. -## Setup - -No extra environment variables needed — the adapter uses `osascript` directly. - -## Commands - -### Diagnostics +### Commands - `opencli chatgpt status`: Check if the ChatGPT app is currently running. - -### Chat Manipulation - `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 -Unlike CDP-based adapters, this adapter: -- Uses `osascript` to send AppleScript commands to System Events -- Leverages `pbcopy`/`pbpaste` for clipboard-based text transfer -- Requires no remote debugging port — works with the stock app +- **AppleScript mode**: Uses `osascript` and `pbcopy`/`pbpaste` for clipboard-based text transfer. No remote debugging port needed. +- **CDP mode**: Connects via Playwright to the Electron renderer process for direct DOM manipulation. ## Limitations - macOS only (AppleScript dependency) -- Requires Accessibility permissions for keystroke simulation +- AppleScript mode requires Accessibility permissions - `read` command copies the last response — earlier messages need manual scroll diff --git a/src/clis/chatgpt/README.zh-CN.md b/src/clis/chatgpt/README.zh-CN.md index d6ff280..cf30a16 100644 --- a/src/clis/chatgpt/README.zh-CN.md +++ b/src/clis/chatgpt/README.zh-CN.md @@ -1,35 +1,44 @@ # ChatGPT 桌面端适配器 -通过原生 AppleScript 自动化,在终端中直接控制 **ChatGPT macOS 桌面应用**。与基于 Electron 的应用(Antigravity、Codex、Cursor)不同,ChatGPT Desktop 是原生 macOS 应用 — OpenCLI 使用 `osascript` 和 System Events 来驱动它。 +在终端中直接控制 **ChatGPT macOS 桌面应用**。OpenCLI 支持两种自动化方式。 -## 前置条件 +## 方式一:AppleScript(默认,无需配置) +内置命令使用原生 AppleScript 自动化,无需额外启动参数。 + +### 前置条件 1. 安装官方 [ChatGPT Desktop App](https://openai.com/chatgpt/mac/)。 -2. 在 **系统设置 → 隐私与安全性 → 辅助功能** 中为终端应用(Terminal / iTerm / Warp)授予 **辅助功能权限**。这是 System Events 按键模拟所必需的。 +2. 在 **系统设置 → 隐私与安全性 → 辅助功能** 中为终端应用授予权限。 -## 配置 - -无需额外环境变量 — 适配器直接使用 `osascript`。 - -## 命令 - -### 诊断 +### 命令 - `opencli chatgpt status`:检查 ChatGPT 应用是否在运行。 - -### 对话操作 - `opencli chatgpt new`:激活 ChatGPT 并按 `Cmd+N` 开始新对话。 - `opencli chatgpt send "消息"`:将消息复制到剪贴板,激活 ChatGPT,粘贴并提交。 - `opencli chatgpt read`:通过 `Cmd+Shift+C` 复制最后一条 AI 回复并返回文本。 +## 方式二:CDP(高级,Electron 调试模式) + +ChatGPT Desktop 同样是 Electron 应用,可以通过远程调试端口启动以实现更深度的自动化: + +```bash +/Applications/ChatGPT.app/Contents/MacOS/ChatGPT \ + --remote-debugging-port=9224 +``` + +然后设置环境变量: +```bash +export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9224" +``` + +> **注意**:CDP 模式支持未来的高级命令(如 DOM 检查、模型切换、代码提取等),与 Cursor 和 Codex 适配器类似。 + ## 工作原理 -与基于 CDP 的适配器不同,此适配器: -- 使用 `osascript` 向 System Events 发送 AppleScript 命令 -- 利用 `pbcopy`/`pbpaste` 进行基于剪贴板的文本传输 -- 无需远程调试端口 — 直接与原生应用交互 +- **AppleScript 模式**:使用 `osascript` 和 `pbcopy`/`pbpaste` 进行剪贴板文本传输,无需远程调试端口。 +- **CDP 模式**:通过 Playwright 连接到 Electron 渲染进程,直接操作 DOM。 ## 限制 - 仅支持 macOS(AppleScript 依赖) -- 需要辅助功能权限以模拟按键 -- `read` 命令复制最后一条回复 — 更早的消息需要手动滚动 +- AppleScript 模式需要辅助功能权限 +- `read` 命令复制最后一条回复,更早的消息需手动滚动