to-agent

内容来源:README.md(说明文档) · 原始地址 · 查看安装指南

原始内容

to-agent

Send the current file or selection from Cursor or VS Code to a running pi coding-agent session.

Press cmd+alt+l on macOS or ctrl+alt+l on Windows/Linux. A whole file is inserted as an @file reference; a selection is inserted as a path-labelled fenced code block with line numbers.

Install

npx to-agent install

The installer detects Cursor and VS Code, installs the editor extension, installs the matching pi adapter, and keeps both sides on the same version.

For an explicit, non-interactive installation:

npx to-agent install --editor cursor --agent pi
npx to-agent install --editor vscode --agent pi

Restart the editor after installation, start pi in a terminal, and click the to-agent status item to select a running session.

Commands

npx to-agent install
npx to-agent doctor
npx to-agent uninstall

How it works

Each pi instance publishes discovery metadata under ~/.to-agent/instances/ and listens on a local Unix socket (macOS/Linux) or named pipe (Windows):

~/.to-agent/instances/<id>.json
~/.to-agent/instances/<id>.sock   # macOS/Linux

The editor discovers live instances and holds one persistent socket connection to the selected session. The connection is also the presence signal shown on both sides.

The local JSONL protocol is versioned. Version 1 accepts:

{ "type": "attach", "file": "/abs/path.ts", "startLine": 10, "endLine": 20, "text": "..." }

Selection fields are omitted for whole-file attachments.

Current support

Editor Agent Status
Cursor pi Beta
VS Code pi Beta
Zed Planned; subject to extension API support
Claude Code, Codex, OpenCode Exploring plugin capabilities

Development

Requirements: Node.js 18+, npm, and pi. Install dependencies and build:

npm install
npm run check

Useful paths:

cursor-extension/src/extension.ts  Cursor / VS Code adapter
pi-extension/to-agent.ts          pi adapter
bin/to-agent.js                    installer and diagnostics CLI
artifacts/to-agent.vsix            generated editor package

Test the install plan without changing the machine:

node bin/to-agent.js install --editor cursor --agent pi --dry-run

For pi extension development, load the source directly:

pi -e ./pi-extension/to-agent.ts

License

MIT