@penumbral-labs/pi-copy-code
A pi extension for ergonomic copying of assistant code blocks.
Package details
Install @penumbral-labs/pi-copy-code from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@penumbral-labs/pi-copy-code- Package
@penumbral-labs/pi-copy-code- Version
0.3.0- Published
- Aug 11, 2026
- Downloads
- 84/mo · 17/wk
- Author
- aasmall
- License
- MIT
- Types
- extension
- Size
- 41.5 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./extensions/copy-code/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-copy-code
A Pi package for copying fenced code blocks from assistant messages without terminal-selection padding.
pi-copy-code adds /copy-code and shortcuts for copying the raw text of recent assistant code blocks. A single block
copies immediately. Multiple blocks or responses open a two-pane picker with a live preview and access to the last ten
assistant responses containing code.
Prerequisites
- Node.js 22.19.0 or newer
- npm 11.10.0 or newer when developing or releasing from a checkout
- Pi (tested against Pi 0.84.1; older releases are untested)
- A native clipboard command (
pbcopy,wl-copy,xclip,xsel, orclip.exe) or a terminal that supports OSC 52
Core Pi packages remain wildcard peer dependencies so the package uses the Pi installation that loads it. The
latest-pi CI lane checks current Pi releases on an advisory basis.
Install
From npm:
pi install npm:@penumbral-labs/pi-copy-code
Then reload Pi:
/reload
For a one-off run without installing:
pi -e npm:@penumbral-labs/pi-copy-code
You can also load a checkout directly:
git clone https://github.com/penumbral-labs/pi-copy-code.git
cd pi-copy-code
npm ci
pi -e "$(pwd)"
Usage
Copy code from recent assistant messages:
/copy-code
The extension captures these shortcut names:
ctrl+alt+c
ctrl+super+c
alt+c
Pi calls the Meta/Command modifier super. Super-modified shortcuts require a terminal that reports modifiers
separately, such as one using the Kitty keyboard protocol. The alt+c registration handles terminals where a physical
Ctrl+Meta+C chord is remapped and arrives as Alt+C. The tradeoff is that a real Alt+C chord can also invoke the
extension; use /copy-code or another captured chord if that conflicts with your terminal workflow.
Edit before copying:
/copy-code edit
Edit mode opens $VISUAL, then $EDITOR, with the selected text in private temporary storage; set one of these
variables to your preferred editor command before using edit mode. On Windows, only .exe and .com targets spawn
directly. All other values, including extension-less names and .cmd/.bat shims, use the explicitly constructed,
escaped cmd.exe /d /s /c path.
When the picker opens:
↑/↓orj/k— move within the current response→ortab— move to an older response←orshift+tab— move toward the current responseenter— copy, or edit then copy when invoked with/copy-code edite— edit the selected block, then copy/— fuzzy-search blocks in the current responsectrl+c,esc, orq— cancel
Response navigation wraps at both ends. The first picker item, All code blocks, joins all blocks in the selected
response with blank lines.
Clipboard behavior
Native clipboard success is confirmed by the clipboard command and reported as Copied N lines via <command>. When no
native command is available and standard output is a TTY, the extension sends OSC 52 and reports
Sent N lines to terminal clipboard via OSC 52 (best effort). OSC 52 support and size limits vary by terminal, so this
fallback cannot confirm that the clipboard changed. Without either path, the extension reports that the terminal
clipboard is unavailable.
Fences nested under Markdown indentation are de-indented by the opening fence's structural whitespace while preserving additional code indentation. Indented Markdown code blocks without fences are not extracted.
Support and contributing
- Use the bug report form for reproducible problems.
- Use the feature request form for focused proposals.
- Read CONTRIBUTING.md before sending a pull request.
- Report vulnerabilities privately as described in SECURITY.md.
- See CHANGELOG.md for release history.
Package shape
Pi loads the TypeScript source extension directly. The npm tarball contains only package.json, the source extension,
README.md, CHANGELOG.md, and LICENSE; it has no runtime dependencies or install scripts.