Local bridge between a running Sublime Text instance and Pi over an authenticated Unix domain socket.
This repository contains both halves:
- this directory - Sublime Text package that runs an authenticated Unix-socket JSON-RPC server in-process.
pi-extension/sublime-bridge.ts- Pi extension that discovers the running bridge and exposes Sublime RPC methods as agent tools.
The bridge intentionally starts with a narrow, inspectable API instead of arbitrary Python eval.
-
Clone this repository at
~/Library/Application Support/Sublime Text/Packages/Agent Bridge. -
Install the bundled Pi package:
pi install "$HOME/Library/Application Support/Sublime Text/Packages/Agent Bridge"
Then restart Sublime or run Preferences: Browse Packages and confirm the package is loaded.
In Pi, run /reload if already running.
Command Palette:
Sublime Agent Bridge: Start ServerSublime Agent Bridge: Stop ServerSublime Agent Bridge: Show Status
The server writes discovery info, including the Unix socket path and bearer token, to:
~/Library/Caches/Sublime Text/Cache/Agent Bridge/connection.json
The bridge also persists its idle deadline to:
~/Library/Caches/Sublime Text/Cache/Agent Bridge/bridge-state.json
The server stops automatically after idle_timeout_seconds without an authorized RPC request. If Sublime restarts while that persisted deadline is still in the future, the package auto-starts the bridge again; otherwise it stays stopped.
scripts/rpc.py is an optional manual diagnostic client for calling the same JSON-RPC methods from a shell. The Pi extension must never shell out to it or use it for bridge access. All Pi tools and commands must make RPC calls only through the extension's internal callBridge() JSON-RPC client.
The Pi extension contributes a sublime-text-api skill via resources_discover. Pi only advertises the skill description in the system prompt; the full skill and reference files are loaded on demand. The skill points to the official Sublime Text API reference and includes a local bridge protocol reference:
https://www.sublimetext.com/docs/api_reference.html
pi-extension/skills/sublime-text-api/references/bridge-protocol.md
The Pi extension registers:
sublime_pingsublime_statussublime_list_windowssublime_list_viewssublime_scope_debugsublime_run_commandsublime_list_output_panelssublime_get_output_panel
- Uses a Unix domain socket under Sublime's cache directory by default.
- Requires a random bearer token.
- Stops automatically after the configured idle timeout.
- Discovery/state files and socket are written with mode
0600where supported. - No arbitrary Python eval endpoint.