@arnowei/pi-remote-workspaces

SSH workspaces for pi, pi-web and PI-Desktop, powered by your OpenSSH config

Packages

Package details

extension

Install @arnowei/pi-remote-workspaces from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@arnowei/pi-remote-workspaces
Package
@arnowei/pi-remote-workspaces
Version
0.5.0
Published
Nov 19, 2026
Downloads
960/mo · 960/wk
Author
arnowei
License
MIT
Types
extension
Size
702.1 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/extension.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

Pi Remote

English | 简体中文

SSH workspaces for pi coding agent, pi-web, and PI-Desktop. Let your agent read and edit files, search projects, and run commands on a remote host. Inspired by the workspace experience in dsh-remote, implemented as both a native pi extension and a native PI-Desktop plugin.

  • Discover concrete host aliases dynamically from ~/.ssh/config, system configuration, and recursive Include directives. Supports glob includes, double-quoted paths, and multiple aliases per Host line.
  • Use your system OpenSSH client, including ProxyJump, ProxyCommand, IdentityFile, ssh-agent, and Host/Match rules. No private keys or passwords are copied or stored by this extension.
  • Save multiple workspaces and bind each session to its own host and directory. Bindings persist across session resume, model switches, and restarts.
  • Route pi's read, write, edit, bash, grep, find, and ls tools (plus user ! commands) to the remote workspace in pi / pi-web; in PI-Desktop, automatically activate remote_read, remote_write, remote_edit, remote_bash, remote_ls, remote_find, and remote_grep alongside local built-in tools.
  • Configure workspaces through /remote across TUI, pi-web, and PI-Desktop. The workbench runs both as a standalone browser dashboard and docked inside PI-Desktop's right Work Panel (SSH Remote / SSH 远程工作区) or standalone panel window with one-click session binding.
  • Write files through temporary files and atomic replacement. Editing and dashboard saves check for version conflicts and preserve existing file permissions. SSH failures never fall back to local execution.

Requirements

Local: Node.js 22.19 or later and the system ssh client. Remote: Linux or macOS with Python 3.8+ and bash. Remote search requires ripgrep; the Git panel requires git on the remote host.

First, confirm authentication and the host fingerprint in your terminal:

ssh your-ssh-alias

The extension uses BatchMode=yes and StrictHostKeyChecking=yes. Prepare a trusted host key and SSH key or ssh-agent authentication before connecting. Password prompts, interactive MFA, and first-time host-key confirmation must be handled in the terminal.

Install

Install the published extension:

pi install npm:@arnowei/pi-remote-workspaces

Try it for one invocation without saving it to your settings:

pi -e npm:@arnowei/pi-remote-workspaces

You can also install directly from the GitHub repository:

pi install git:github.com/buptweixin/pi-remote-workspaces

Restart pi or pi-web after installation, then send /remote in a conversation.

Install from a local checkout

From the repository directory:

npm install
npm run build

# Add this package to pi's global configuration, shared with pi-web.
pi install /absolute/path/to/pi_remote

If you do not have a global pi command:

npx @earendil-works/pi-coding-agent install /absolute/path/to/pi_remote

Restart pi or pi-web after installing. Alternatively, add the repository's absolute path to the packages array in ~/.pi/agent/settings.json, preserving existing entries:

{
  "packages": ["/absolute/path/to/pi_remote"]
}

The package declares src/extension.ts in package.json under pi.extensions. No pi-web source changes are required.

Get started

  1. Send /remote in a pi or pi-web conversation.
  2. Choose Add remote workspace (添加远程工作区), select an SSH alias, and enter the remote directory and workspace name. You can also create workspaces through the browser dashboard.
  3. Select the saved workspace in /remote, or send /remote use <id>. The session switches its tools to the remote project after verifying the connection.
  4. Ask the agent to work on your project. The status widget shows the active SSH host and project root.

The extension menus and dashboard currently use Simplified Chinese. Command names and configuration keys are shown below.

/remote                  Open the configuration and workspace menu
/remote add              Select an SSH host and add a workspace
/remote edit [id]        Edit a saved workspace configuration
/remote remove my-app    Remove a saved workspace configuration
/remote hosts            Reload SSH config and show or import host aliases
/remote anchors          Sync and print pi-web remote anchor directory paths
/remote use my-app-dev   Bind this session to a saved workspace
/remote files [path]     Browse, search, create, and edit remote files in native modals
/remote git              Inspect remote Git status and diffs in native modals
/remote test             Check connectivity and Python/Git/ripgrep availability
/remote status           Show the current workspace and check connectivity
/remote web              Start this session's standalone browser dashboard
/remote local            Unbind the remote workspace and restore local tools (alias: unbind)

To disconnect a session, send /remote local, or choose Switch to local (切换到本地) from /remote. Saved workspace configurations remain available.

The CLI also accepts a workspace at startup: pi --remote my-app-dev. If the requested workspace cannot connect, execution is blocked. Recover with /remote use <id> or explicitly switch back with /remote local.

pi-web

npx @agegr/pi-web@latest

Native pi-web UI integration works out of the box without patching pi-web:

  • Clickable status-shelf toolbar buttons (ExtensionStatusBar command: protocol): Shows a clickable SSH: 本地 button right below the chat input when unbound (opening the native workspace switcher/creator modal with one click, no typing /remote needed), and ● SSH <host> · <path>, 远程文件, Git 状态, 探测连接, and 切回本地 buttons plus a collapsible ANSI details drawer (▲ pi-remote) when bound. Note: pi-web lazily spawns an agent runtime only on the first prompt or / command lookup, so an untouched empty composer will not show extension status buttons until that first interaction.
  • Connect without piggybacking on a local project (remote anchor directories): Automatically maintains empty local anchor directories under ~/.pi/remote-workspaces (viewable via /remote anchors, pi-remote anchors, or copy buttons in the dashboard):
    • Opening a workspace anchor ~/.pi/remote-workspaces/<workspace-id> automatically binds that SSH workspace during session_start without running /remote use first (and can be pinned in pi-web's sidebar).
    • Opening the shared picker anchor ~/.pi/remote-workspaces automatically opens an SSH workspace selector on your first message or /.
  • In-page native modal file browser/editor & Git inspector: Click 远程文件 (/remote files) to navigate remote directories, run find/grep searches, create files, or edit and atomically save remote UTF-8 files (with optimistic etag conflict checks) inside pi-web's built-in monospace editor modal; click Git 状态 (/remote git) to inspect dirty files and per-file or full diffs.
  • Official session-liveness integration (@agegr/pi-web/session-liveness/v1): Registers a session-scoped liveness lease so active interactive flows or an open /remote web standalone dashboard are not evicted by pi-web's 10-minute idle timer.

Integration has been tested with pi-web 0.17.0 and @earendil-works/pi-coding-agent 1.5.2, covering package loading, clickable command: status-shelf buttons, real SSH binding, native modals, and cancellation through Stop. These tests require no model credentials or LLM calls.

Pi-web's built-in right sidebar file explorer and terminal still point to its local server directory; use the 远程文件 / Git 状态 toolbar modals, bound agent tools, or /remote web dashboard for remote files and commands.

PI-Desktop

Supports vastsa/PI-Desktop (verified against PI-Desktop 0.22.0+) with zero runtime npm dependencies. Three installation options are supported:

  1. Install the .piplug plugin package (recommended): Run npm run build locally (or download the .piplug from GitHub Releases), open PI-Desktop → Plugins → overflow menu Install plugin package, and select release-artifacts/io.github.buptweixin.pi-remote-<version>.piplug.
  2. Load as a development plugin (with hot reload): Run npm run build, open PI-Desktop → Plugins → Load development plugin, and select the pi-desktop/ folder in this repository.
  3. Import as a pi extension (agent extension only): Open PI-Desktop → Plugins → overflow menu Import pi extension, and select the repository root (zero runtime npm dependencies; imports offline).

What you get in PI-Desktop:

  • In-composer SSH pill & native right Work Panel: Mounts a native SSH selector pill directly inside PI-Desktop's chat composer toolbar (composerControl slot using host --ds-* tokens) with an in-window modal for switching, adding, probing, and unbinding SSH workspaces; docks a compact Light/Dark-synced SSH Remote (SSH 远程) view in the right work panel matching PI-Desktop's built-in File Manager, with collapsible file tree, colored Git diffs, click-to-open search hits, and remote bash execution.
  • Dual-end tool coexistence: Because PI-Desktop reserves built-in core tool names (Read/Write/Edit/Bash/Glob/Grep), binding a session automatically activates remote_read, remote_write, remote_edit, remote_bash, remote_ls, remote_find, and remote_grep and injects remote AGENTS.md / CLAUDE.md context while keeping local built-in tools available when needed.
  • /remote slash command: All /remote subcommands work natively through PI-Desktop's modal dialogs, toasts, and session status bar.

Standalone browser dashboard

Configure workspaces without starting an agent:

npx --yes --package @arnowei/pi-remote-workspaces pi-remote serve

From a local checkout:

npm run dev
# Or, after building:
node dist/cli.js serve
node dist/cli.js serve --port 30142

Open the complete URL printed by the command. The server listens on 127.0.0.1 only, authenticates API requests with a random token, and validates Host and Origin headers. The access token is supplied in the URL fragment and removed from the address bar after the page reads it.

Use the sidebar to refresh SSH config and add or edit workspaces. Connection settings let you choose a configuration file and timeouts. Within a workspace, you can browse and edit UTF-8 text files, search, inspect Git diffs, and run commands. Saving is rejected if the remote file has changed since it was read.

The dashboard and pi session select workspaces independently. Copy the /remote use <id> command from the dashboard to bind a conversation. Editing a saved workspace does not silently change an existing session binding; run /remote use <id> again to apply it.

If pi-web runs on another server, the /remote web URL refers to that server's loopback interface. Forward its dashboard port with SSH, for example ssh -L 30142:127.0.0.1:<dashboard-port> server, then open the URL using your local forwarded port and retain #token=.... Use serve --port for a fixed dashboard port.

Configuration

Configuration is stored in ~/.pi/agent/remote.json by default, with file permissions 0600. Updates use a cross-process lock and atomic replacement.

  • PI_CODING_AGENT_DIR: override the pi configuration directory; use the same value for pi-web and PI-Desktop.
  • PI_REMOTE_CONFIG: override the remote workspace configuration file path.
  • PI_REMOTE_ANCHOR_DIR: override the local pi-web anchor root directory (defaults to ~/.pi/remote-workspaces, or <dirname(PI_REMOTE_CONFIG)>/remote-workspaces when PI_REMOTE_CONFIG / PI_CODING_AGENT_DIR is customized).
  • PI_REMOTE_SESSIONS: override the durable PI-Desktop session-binding file path (defaults to remote-sessions.json beside remote.json).
{
  "version": 1,
  "connectTimeoutSeconds": 10,
  "commandTimeoutSeconds": 120,
  "workspaces": [
    {
      "id": "my-app-dev",
      "name": "My App / Development",
      "host": "dev-server",
      "path": "~/projects/my-app"
    }
  ]
}

The optional sshConfigPath and anchorRoot fields must be absolute paths. Leave sshConfigPath unset to use OpenSSH's default configuration; setting it passes ssh -F, which disables the system configuration. Host discovery follows the same file-selection rules. Relative Include paths are resolved against the user's ~/.ssh or the system's /etc/ssh, as appropriate. Leave anchorRoot unset to use the default anchor root.

Refreshing the host list rereads configuration files and their includes. Each SSH operation applies the current OpenSSH connection configuration, so changes do not require a restart. Wildcard and negated aliases such as Host * and Host *.example.com are not listed; enter a concrete hostname manually instead. Discovery scans declarations without executing Match exec. OpenSSH evaluates effective settings when connecting or explicitly resolving a host. Aliases discovered in conditional includes remain candidates whose connectivity depends on those rules.

CLI

node dist/cli.js hosts          # SSH aliases and source locations
node dist/cli.js list           # Saved workspaces and anchor paths
node dist/cli.js anchors        # Sync and print pi-web anchor paths
node dist/cli.js test my-app-dev
node dist/cli.js remove my-app-dev
node dist/cli.js --help

Limitations

  • File tools and dashboard file operations stay within the bound root, rejecting traversal and symlinks that point outside it. Bash runs with the SSH user's privileges and is not a filesystem sandbox. Tools from other extensions are not automatically made remote. Built-in PowerShell is blocked in SSH mode; use bash.
  • The dashboard runs one-shot commands. It does not provide a PTY, persistent interactive terminal, language server, remote debugger, or editor syntax highlighting.
  • Files are limited to 8 MiB; directory listings to 5,000 entries. Dashboard command output is limited to 1 MiB. Search and Git output may be truncated. The dashboard edits UTF-8 text; files with consistent CRLF line endings retain CRLF when saved.
  • Cancellation and timeouts terminate the local SSH process group. Remote commands, background jobs, or detached processes may keep running. Use tmux or another remote process manager for long-running work that needs reliable lifecycle management.
  • Model calls, session storage, and skills remain on the machine running pi. When bound to a remote workspace, the extension sets the prompt working directory to the remote root and replaces local project context with remote AGENTS.md / CLAUDE.md instructions when present inside the bound root. Prefer separate sessions when switching machines or privilege levels.
  • The supported host is the current @earendil-works/pi-coding-agent. Older @mariozechner/pi-coding-agent releases have not been tested.

Development and verification

npm run check
npm test                    # Config discovery, concurrency, file protocol, tools, API access
npm run test:integration     # Temporary local sshd, real OpenSSH, SDK session isolation/resume
npm run test:pi-web          # Launch the latest pi-web through npx and test integration
npm run test:package         # Install the actual tarball without development dependencies
npm run build
npm pack --dry-run

Integration tests generate temporary host and client keys, known_hosts, SSH config, and pi directories. They connect only to a temporary local sshd and do not read or modify your SSH or pi configuration. Tests require ssh-keygen and /usr/sbin/sshd; set PI_REMOTE_SSHD to use a different daemon path. The pi-web test needs network access and runs npx @agegr/pi-web@latest by default. Set PI_REMOTE_PI_WEB_PACKAGE to pin the version under test.

Source layout:

Path Purpose
src/extension.ts Pi lifecycle, commands, and session bindings
src/tools.ts Native tool adapters
src/ssh-config.ts SSH configuration discovery and resolution
src/remote.ts, src/remote-script.ts SSH transport and remote protocol
src/server.ts, public/ Browser dashboard

The Python helper runs on demand through SSH; no persistent remote service is installed.

Release instructions, version tags, and npm Trusted Publishing setup are documented in the release guide. See CHANGELOG.md for release history.

References

License

Pi Remote's original code is licensed under the MIT License. Upstream acknowledgments, the pi SSH example's license notice, and the locked runtime dependency notices are in THIRD_PARTY_NOTICES.md. Third-party components retain their own licenses.

Pi Remote is an independent extension and is not an official release of pi, pi-web, or dsh-remote.

Maintained by Arno Wei.