CompBuddy
A local-first computer-use agent for macOS.
面向 macOS 的本地优先电脑操作 Agent。
中文 · English
---
## 中文
CompBuddy 是一个原生风格的 macOS 桌面 Agent。它能够观察指定窗口、理解界面、点击控件、输入文字并验证操作结果。默认操作路径通过 macOS Accessibility 与 PID 定向事件完成,不移动系统实体鼠标;淡蓝色虚拟指针用于展示 Agent 当前的操作位置。
### 主要能力
- 窗口级截图与无障碍树联合感知
- 平滑虚拟指针与 PID 定向点击
- 单次投递、短时去重的安全文字输入
- 多轮会话、258k 上下文预算与自动压缩
- 运行中止、屏幕锁定检测和结果验证
- OpenAI 兼容接口、模型列表拉取和本地设置存储
### 系统要求
- macOS 13 或更高版本
- Python 3.11 或更高版本
- 辅助功能与屏幕录制权限
- 支持 Chat Completions、函数调用和图像输入的 OpenAI 兼容模型
仓库内的 `CompBuddy.app` 是开发启动器,不是独立安装包。双击启动器时,当前构建依赖 Apple Silicon Homebrew Python 3.13 和仓库中的 `.venv`。
### 安装与启动
```bash
git clone https://github.com/lewiswlker/CompBuddy.git
cd CompBuddy
/opt/homebrew/opt/python@3.13/bin/python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"
compbuddy app
```
也可以运行 `scripts/build_app.sh` 后双击 `CompBuddy.app`。首次启动时,请在“系统设置 → 隐私与安全性”中授予辅助功能和屏幕录制权限。通过终端启动时,macOS 可能要求给终端或 Python 授权;通过应用包启动时,请给 CompBuddy 授权。
### 配置
推荐在应用的“设置与模型”面板中填写 API Key、Base URL 和模型。也可以使用环境变量:
```bash
export COMPBUDDY_API_KEY="..."
export COMPBUDDY_BASE_URL="https://api.openai.com/v1"
export COMPBUDDY_MODEL="gpt-4.1-mini"
```
设置与会话默认保存在 `~/.compbuddy/`,不会写入仓库。任务执行期间,窗口截图和必要的工具上下文会发送到你配置的模型服务商;请勿在敏感窗口中运行任务。
### 命令与开发
```bash
compbuddy status
compbuddy list-apps
compbuddy list-windows --pid 1234
compbuddy run "打开计算器,计算 6×7"
pytest -q
```
核心模块位于 `src/compbuddy/`,桌面 UI 位于 `src/compbuddy/ui/`。贡献前请阅读 [AGENTS.md](AGENTS.md),安全相关变更请同时参考 [SECURITY.md](SECURITY.md)。
---
## English
CompBuddy is a native-style computer-use agent for macOS. It observes a selected window, interprets its interface, clicks controls, enters text, and verifies the resulting state. Its normal action path uses macOS Accessibility and PID-scoped events without moving the physical system pointer; a light-blue virtual pointer shows where the agent is acting.
### Highlights
- Window-level screenshots combined with Accessibility trees
- Smooth virtual pointer and PID-scoped interaction
- Single-delivery text input with short-term duplicate suppression
- Multi-turn sessions with a 258k context budget and automatic compaction
- Task cancellation, lock-screen detection, and post-action verification
- OpenAI-compatible endpoints, model discovery, and local settings storage
### Requirements
- macOS 13 or later
- Python 3.11 or later
- Accessibility and Screen Recording permissions
- An OpenAI-compatible model with Chat Completions, function calling, and image input
The bundled `CompBuddy.app` is a development launcher, not a standalone distribution. The current launcher build expects Apple Silicon Homebrew Python 3.13 and the repository-local `.venv`.
### Install and run
```bash
git clone https://github.com/lewiswlker/CompBuddy.git
cd CompBuddy
/opt/homebrew/opt/python@3.13/bin/python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"
compbuddy app
```
Alternatively, run `scripts/build_app.sh` and open `CompBuddy.app`. On first launch, grant Accessibility and Screen Recording under System Settings → Privacy & Security. CLI launches may require permission for Terminal or Python; bundle launches should grant permission to CompBuddy.
### Configuration
Use the in-app **Settings & Model** panel, or provide environment variables:
```bash
export COMPBUDDY_API_KEY="..."
export COMPBUDDY_BASE_URL="https://api.openai.com/v1"
export COMPBUDDY_MODEL="gpt-4.1-mini"
```
Settings and chats are stored under `~/.compbuddy/` and are excluded from the repository. During a task, window screenshots and necessary tool context are sent to the configured model provider. Do not run the agent against sensitive windows unless that provider is trusted.
### Commands and development
```bash
compbuddy status
compbuddy list-apps
compbuddy list-windows --pid 1234
compbuddy run "Open Calculator and calculate 6×7"
pytest -q
```
Core modules live in `src/compbuddy/`; the desktop UI is in `src/compbuddy/ui/`. Read [AGENTS.md](AGENTS.md) before contributing and [SECURITY.md](SECURITY.md) before changing capture, permission, clipboard, or input-injection behavior.
## License
CompBuddy is released under the [MIT License](LICENSE).