You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+58-9Lines changed: 58 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
A Neovim plugin that shows a **diff preview before your AI coding agent applies any file change** — letting you review exactly what's changing before accepting.
4
4
5
-
Supports [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [OpenCode](https://opencode.ai), and [GitHub Copilot CLI](https://github.com/github/copilot-cli) as backends.
5
+
Supports [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [OpenCode](https://opencode.ai), [GitHub Copilot CLI](https://github.com/github/copilot-cli), and [OpenAI Codex CLI](https://github.com/openai/codex) as backends.
-[GitHub Copilot CLI](https://github.com/github/copilot-cli) (generally available since Feb 2026)
69
+
70
+
**For OpenAI Codex CLI backend:**
71
+
-[OpenAI Codex CLI](https://github.com/openai/codex) (recent enough to support `apply_patch` PreToolUse hooks; older builds only fired hooks for `Bash`)
65
72
-[jq](https://jqlang.github.io/jq/) — for hook payload translation
> **Note:** Copilot CLI does not fire post-tool hooks on rejection, so rejected diffs remain open until you dismiss them (same as Claude Code).
133
140
141
+
### OpenAI Codex CLI
142
+
143
+
1. Install the plugin and call `setup()`
144
+
2. Open a project in Neovim
145
+
3. Run `:CodePreviewInstallCodexCliHooks` — writes `.codex/hooks.json`
146
+
4. Codex requires a feature flag to enable hooks, and the diff-preview workflow only makes sense when Codex asks before applying edits. Create or edit `.codex/config.toml` (project-local) or `~/.codex/config.toml` (global) and add:
147
+
148
+
```toml
149
+
approval_policy = "on-request"
150
+
sandbox_mode = "read-only"
151
+
152
+
[features]
153
+
codex_hooks = true
154
+
```
155
+
156
+
`approval_policy = "on-request"` and `sandbox_mode = "read-only"` ensure Codex prompts you before every edit, so the diff preview has time to open and you have time to review. Without them, Codex may apply changes without prompting and the preview window will never block on your decision.
157
+
158
+
The installer warns you if `codex_hooks` is missing. You can re-check at any time with `:CodePreviewStatus` or `:checkhealth code-preview`, which both report whether the feature flag is detected.
159
+
5. Start Codex CLI in the project directory
160
+
6. Ask Codex to edit a file — a diff opens automatically in Neovim
161
+
7. Accept/reject in the CLI; the diff closes automatically on accept
162
+
8. If rejected, press `<leader>dq` to close the diff manually
163
+
164
+
> **Note:** Today's Codex models route all file edits through the `apply_patch` tool. New file creation that Codex performs via shell redirection (e.g. `printf … > foo.txt`) is not previewed — only `apply_patch` and edits via the dedicated `Edit`/`Write` tools (when emitted) are.
165
+
134
166
---
135
167
136
168
## How it works
@@ -155,6 +187,8 @@ AI Agent (terminal) Neovim
155
187
156
188
**GitHub Copilot CLI** uses shell-based hooks (`preToolUse`/`postToolUse`) configured in `.github/hooks/code-preview.json`. The adapter translates Copilot's tool vocabulary (`apply_patch`, `edit`, `create`, `bash`) into the same normalized format used by the other backends.
157
189
190
+
**OpenAI Codex CLI** uses shell-based hooks (`PreToolUse`/`PostToolUse`) configured in `.codex/hooks.json`, gated by `codex_hooks = true` under `[features]` in `.codex/config.toml`. The adapter passes `Bash` through and rewrites `apply_patch` (whose patch text lives in `tool_input.command`) into the canonical `ApplyPatch` shape with `tool_input.patch_text`.
191
+
158
192
All backends communicate with Neovim via RPC (`nvim --server <socket> --remote-send`).
0 commit comments