Files
jackwener__opencli/docs/adapters/desktop/codex.md
AlexYue 31f58ae699 docs: add VitePress documentation site (#112)
- Add VitePress with full navigation, sidebar, i18n (en/zh), local search
- Create 50+ doc pages: guide, adapters (browser + desktop), developer, advanced
- Migrate content from README.md, CONTRIBUTING.md, TESTING.md, CDP.md, CLI-ELECTRON.md
- Migrate all 11 adapter READMEs to structured documentation
- Add new pages: architecture, yaml-adapter guide, ts-adapter guide, ai-workflow
- Add GitHub Actions workflow for deploying to GitHub Pages
- Add Chinese locale pages (getting-started, installation, browser-bridge, etc.)
- Add docs:dev, docs:build, docs:preview npm scripts
2026-03-20 14:11:56 +08:00

1.3 KiB

Codex

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.

Prerequisites

  1. You must have the official OpenAI Codex app installed.
  2. Launch it via the terminal and expose the remote debugging port:
    # macOS
    /Applications/Codex.app/Contents/MacOS/Codex --remote-debugging-port=9222
    

Setup

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.

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, e.g., opencli codex send "/review".
  • opencli codex read: Extracts the entire current thread history and AI reasoning logs.
  • opencli codex extract-diff: Automatically scrapes any visual Patch chunks and Code Diffs.
  • opencli codex model: Get the currently active AI model.