Extension

unlight/zot-editor-bridge

localhost HTTP bridge that sends editor selections and instructions into the active zot session

extension

Install from GitHub and zot copies the extension into $ZOT_HOME/extensions/. Git-installed extensions update with zot update.

shell
zot ext install https://github.com/unlight/zot-editor-bridge
repository
unlight/zot-editor-bridge
author
unlight
stars
0
forks
0
open issues
0
language
Go
topics
zot-extension
created
Nov 14, 2026
updated
Nov 16, 2026

Security note: zot extensions can execute code. Review the source before installing third-party extensions.

Readme

zot-editor-bridge

A zot extension that exposes the active zot session to external editors over a localhost HTTP API. Select code in Sublime Text, VS Code, Neovim, or any script, send it with an instruction, and zot receives it as a normal user prompt.

  • Binds to 127.0.0.1 only.
  • No external Go dependencies, standard library only.
  • Publishes its port so editors can discover the running session.
  • Falls back to an ephemeral port when the default one is taken, so multiple zot windows can run side by side.

Supported editors

Any editor or script that can send JSON over HTTP can integrate directly; see HTTP API.

Requirements

  • zot with extension support (tested with zot 0.4.78).
  • Go 1.22 or newer on PATH.

The manifest runs the extension with go run ., so zot ext install . is enough on a machine with a Go toolchain. Build a standalone binary if you prefer:

go build -o zot-editor-bridge .

Then change exec in extension.json to "./zot-editor-bridge" and drop the args entry.

Install

zot ext install https://github.com/unlight/zot-editor-bridge.git

zot clones the repository into $ZOT_HOME/extensions/zot-editor-bridge/. The manifest runs go run ., so Go 1.22 or newer must stay available on PATH.

Restart zot. A startup note reports the listening port, and /editor-bridge shows the current /send and /health URLs, the session cwd, and the port file path.

Port discovery

On startup the extension tries to bind 127.0.0.1:47831, unless ZOT_EDITOR_BRIDGE_PORT is set. If the port is busy, it binds an ephemeral port (:0) instead.

The chosen port is written to a file scoped to the session's absolute cwd:

editor-bridge-<cwd-hash>.port

<cwd-hash> is the first 8 lowercase hex characters of SHA-256(filepath.Clean(cwd)) encoded as UTF-8. Example: /work/project hashes to 65d80d2c, so the file is editor-bridge-65d80d2c.port.

The file is written to:

  1. $ZOT_HOME/editor-bridge-<hash>.port when ZOT_HOME is set.
  2. Otherwise the zot state directory:
    • Linux: $XDG_STATE_HOME/zot/editor-bridge-<hash>.port, or ~/.local/state/zot/editor-bridge-<hash>.port
    • macOS: ~/Library/Application Support/zot/editor-bridge-<hash>.port
    • Windows: %LOCALAPPDATA%\zot\editor-bridge-<hash>.port

No other locations are written.

Editors compute the hash from their project root and read that file. The project root must match zot's cwd exactly after filepath.Clean; otherwise the hashes differ and the editor falls back to another directory or reports "zot not running". The file contains only the decimal port.

To confirm the file is live, call GET /health and check that cwd matches the project root. This rejects stale files left by a crashed process and files owned by a window whose cwd changed.

Two zot windows opened in the same cwd share one file name: the last started window wins. Windows opened in different project directories get different files and are addressed independently.

The file is removed on shutdown, SIGINT, and SIGTERM, but only when it still contains this process's port. If another zot window has overwritten it, the file is left alone.

To pin a port:

ZOT_EDITOR_BRIDGE_PORT=51234 zot

HTTP API

GET /health

HASH=$(printf %s "$PWD" | sha256sum | cut -c1-8)
PORT=$(cat ~/.local/state/zot/editor-bridge-$HASH.port)
curl http://127.0.0.1:$PORT/health
{"cwd":"/work/project","ok":true,"port":47831,"session_id":"LX347S3QQXA2XVCKVEW7K2GLCI"}

session_id is filled from zot lifecycle events and can be empty briefly during startup or when the host does not expose one.

POST /send

curl -X POST http://127.0.0.1:$PORT/send \
  -H 'Content-Type: application/json' \
  -d '{
    "code": "fmt.Println(\"hi\")",
    "instruction": "What does this code do?",
    "file": "main.go",
    "language": "go"
  }'

Fields:

field required meaning
instruction one of instruction / code what the user wants
code one of instruction / code selected code or text
file no file path shown to the agent
language no code fence language

The request is rejected with HTTP 400 when the JSON is malformed or both instruction and code are blank. Bodies over 1 MiB return HTTP 413.

Response:

{"ok":true,"port":47831,"session_id":"LX347S3QQXA2XVCKVEW7K2GLCI"}

The extension first pushes an info notification, then formats the request as Markdown and submits it as a user prompt:

File: main.go
Instruction: What does this code do?

```go
fmt.Println("hi")
```

If zot is busy, the prompt is queued by the host exactly like typed input.

Development

gofmt -w .
go vet ./...
go test ./...

Install a working copy for a single session without copying it:

zot --ext ./zot-editor-bridge

Logs and diagnostics:

zot ext doctor
zot ext logs editor-bridge -f

Security notes

The server listens on loopback only and accepts at most 1 MiB per request. It has no authentication: any local process that can reach the loopback port can submit a prompt to the agent. Do not bind it to a routable interface.