Native Neovim integration for the Pi coding agent.
- 🚀 Native RPC - Direct communication with Pi via TCP/JSON-RPC
- 📊 Real-time Status - Live control panel showing agent state
- 📝 Log Streaming - Watch agent output in real-time
- 🔄 Diff Viewer - Review changes side-by-side before applying
- ✅ Approval Workflow - Approve or reject agent modifications
- 💬 Chat Interface - Interactive conversation with the agent
- 📁 Session Management - Save and restore agent sessions
- 🗂️ File Tree - Track pending and modified files
Using lazy.nvim
{
"your-username/pi.nvim",
config = function()
require("pi").setup({
-- Auto-connect on startup
auto_connect = true,
-- Require approval before applying changes
approval_mode = true,
-- Custom keymaps
keymaps = {
toggle_panel = "<leader>pt",
toggle_logs = "<leader>pl",
toggle_chat = "<leader>pc",
attach_image = "<leader>pI",
approve = "<leader>pa",
reject = "<leader>pr",
}
})
end
}Using packer.nvim
use {
"your-username/pi.nvim",
config = function()
require("pi").setup()
end
}- Neovim >= 0.8.0
- Pi agent running with RPC enabled (default port: 43863)
-
Start Pi agent with RPC enabled:
pi --rpc
-
Connect from Neovim:
:PiConnect
-
Start a task:
:PiStart "Refactor the utils module to use TypeScript" -
Monitor progress:
:PiToggle " Show control panel :PiLogs " Show log stream
-
Review changes:
:PiApprove " Apply the current change :PiReject " Discard the current change
| Command | Description |
|---|---|
:PiConnect |
Connect to Pi RPC server |
:PiDisconnect |
Disconnect from server |
:PiStart <task> |
Start agent with task description |
:PiPause |
Pause the running agent |
:PiResume |
Resume a paused agent |
:PiStop |
Stop the running agent |
:PiToggle |
Toggle control panel |
:PiLogs |
Toggle logs viewer |
:PiChat |
Toggle chat interface |
:PiChatAttach [file] |
Attach png/jpeg to next chat prompt |
:PiDiff [file] |
Show diff for file |
:PiApprove |
Approve pending change |
:PiReject |
Reject pending change |
:PiSessionList |
List saved sessions |
:PiSessionLoad <id> |
Load a session |
:PiSessionSave [name] |
Save current session |
require("pi").setup({
-- Connection settings
host = "127.0.0.1",
port = 43863,
auto_connect = false,
-- UI settings
auto_open_panel = true,
auto_open_logs = false,
panel_position = "top-right",
-- Feature settings
auto_stream_logs = true,
approval_mode = true,
watch_files = true,
-- Display settings
max_log_entries = 1000,
log_format = "timestamp",
-- Chat/UI options
ui = {
streaming_prompt_default = "follow_up",
show_tool_streaming = true,
show_retry_status = true,
show_compaction_status = true,
extension_status_panel = true,
allow_image_attachments = true,
},
-- Keymaps (set to false to disable)
keymaps = {
toggle_panel = "<leader>pt",
toggle_logs = "<leader>pl",
toggle_chat = "<leader>pc",
attach_image = "<leader>pI",
approve = "<leader>pa",
reject = "<leader>pr",
}
})User Command → RPC Client → Pi Agent
↓
RPC Response/Event
↓
State Manager (single source of truth)
↓
Event System (notify listeners)
↓
UI Components (update displays)
local pi = require("pi")
-- Initialize
pi.setup({ auto_connect = true })
-- Connection
pi.connect()
pi.disconnect()
-- Agent control
pi.start("Write a function to...")
pi.pause()
pi.resume()
pi.stop()
-- UI
require("pi.ui.control_panel").toggle()
require("pi.ui.logs_viewer").toggle()
require("pi.ui.diff_viewer").show("/path/to/file")
-- State
local state = require("pi.state")
state.update("agent.running", true)
local is_running = state.get("agent.running")
-- Events
local events = require("pi.events")
events.on("agent_started", function(data)
print("Agent started!")
end)- Ensure Pi agent is running with RPC:
pi --rpc - Check the port matches (default: 43863)
- Try manually connecting:
:PiConnect
- Check that events are being emitted:
events.emit("state_updated", path, value) - Verify UI components subscribe to events:
events.on("state_updated", callback)
- Ensure file watcher is active
- Check that the file is in the watched directory
- Verify approval mode is enabled
MIT
Contributions welcome! Please read the PLAN.md for the implementation roadmap.