Extension

unlight/zot-copy-last

Copy the last agent response to the system clipboard

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-copy-last
repository
unlight/zot-copy-last
author
unlight
stars
0
forks
0
open issues
0
language
Python
topics
zot-extension
created
Nov 6, 2026
updated
Nov 6, 2026

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

Readme

zot-copy

Copy the last agent response to the system clipboard.

Install

zot ext install https://github.com/unlight/zot-copy-last

Or run ad-hoc:

zot --ext ./zot-copy-last

Restart zot after installing or updating.

Usage

Type:

/copy

Copies the most recent agent response from the current session to the system clipboard and posts a confirmation note back into the chat.

How it works

  • Event subscription — the extension subscribes to assistant_message and keeps the last non-empty text. turn_start and session_end clear the cache, so /copy never returns a preamble left over from an earlier step.
  • Clipboard write — on /copy the stored text is written through the platform clipboard tool: pbcopy on macOS, wl-copy / xclip / xsel on Linux. Candidates are tried in order; a broken tool does not stop the fallback chain.
  • Encoding — frames are read and written as UTF-8 regardless of the host locale, and clipboard payloads are handed over as UTF-8 too.
  • Transcript fallback — a session loaded with /sessions replays no events, so when the cache is empty /copy reads the last assistant message from <state dir>/sessions/<hash of cwd>/*.jsonl instead of failing.

Known limitations

  • A /btw side dialog emits assistant_message attributed to the active session (host behaviour), so its reply can replace the text /copy reads.
  • Only the Linux and macOS clipboard tools are supported.
  • The transcript fallback depends on zot's state layout (no host API exposes the session file), so a future change there degrades /copy back to "nothing to copy" rather than to a wrong answer.

Development

The extension is a single executable Python script — no build step.

chmod +x copy.py
python3 -m unittest test_copy -v

The tests drive the real subprocess over stdio and stub the clipboard tool, so no zot session and no clipboard access are needed.

Structure

zot-copy-last/
├── extension.json   # manifest
├── copy.py          # source code
└── test_copy.py     # wire-level tests

Requirements

  • Python 3.7+
  • zot 0.4.x
  • A system clipboard tool: pbcopy (macOS), wl-copy / xclip / xsel (Linux)

License

MIT, Copyright (c) 2026