npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@penumbral-labs/pi-copy-code

v0.2.0

Published

A pi extension for ergonomic copying of assistant code blocks.

Readme

pi-copy-code

A pi package for copying fenced code blocks from assistant messages without terminal selection padding.

pi-copy-code adds one command and one shortcut:

  • /copy-code
  • ctrl+alt+c

It reads the latest assistant message, extracts fenced code blocks, and copies the raw code text to your clipboard. If there is more than one block, it opens a small two-pane picker with a live preview.

Features

  • Copy raw fenced code instead of rendered terminal cells.
  • Preserve whitespace-sensitive YAML, shell, Python, and heredoc indentation.
  • Copy one block immediately when there is only one block.
  • Choose between multiple blocks with a preview picker.
  • Copy all blocks at once from the picker.
  • Edit a selected block in your external editor before copying.
  • Clipboard fallback order:
    • native clipboard command when available (pbcopy, wl-copy, xclip, xsel, clip.exe)
    • OSC 52 terminal clipboard sequence when native clipboard commands are unavailable

Install

From npm:

pi install npm:@penumbral-labs/pi-copy-code

From GitHub:

pi install git:github.com/penumbral-labs/pi-copy-code

Or from a local checkout:

cd /path/to/pi-copy-code
pi install "$(pwd)"

Then reload pi:

/reload

For a one-off run without installing:

pi -e npm:@penumbral-labs/pi-copy-code

or, from GitHub:

pi -e git:github.com/penumbral-labs/pi-copy-code

or, from a local checkout:

pi -e "$(pwd)"

Usage

Copy code from the latest assistant message:

/copy-code

or press:

ctrl+alt+c

Edit before copying:

/copy-code edit

When multiple blocks are available, the picker opens:

  • / or j / k — move selection
  • enter — run the default action
    • /copy-code: copy
    • /copy-code edit: edit, then copy
  • e — edit selected block, then copy
  • esc or q — cancel

The first picker item is All code blocks, which copies all blocks separated by blank lines.

External editor setup

Edit mode opens your external editor directly using $VISUAL, then $EDITOR.

For NeoVim:

export VISUAL=nvim
# or
export EDITOR=nvim

If neither variable is set, /copy-code edit shows a warning and cancels.

What counts as a code block?

pi-copy-code extracts fenced markdown blocks from the latest assistant message:

```bash
echo hello
```

~~~python
print("hello")
~~~

Indented markdown code blocks are not currently extracted.

Package shape

The package uses pi's package manifest in package.json:

{
  "keywords": ["pi-package"],
  "pi": {
    "extensions": ["./extensions/copy-code/index.ts"]
  }
}

Core pi packages are peer dependencies, per pi package guidance.

Development

Run tests:

npm test

Check publish contents:

npm pack --dry-run

Test fixture

Ask pi to emit multiple fenced blocks, then run /copy-code:

apiVersion: v1
kind: ConfigMap
metadata:
  name: test
data:
  script.sh: |
    if [ -n "$FOO" ]; then
      echo "$FOO"
    fi
from dataclasses import dataclass

@dataclass
class Config:
    host: str
    port: int = 8080

    @property
    def url(self) -> str:
        return f"http://{self.host}:{self.port}"