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

@braintrust/pi-extension

v1.0.0

Published

Braintrust extension for pi. Includes automatic tracing for pi sessions, turns, LLM calls, and tool executions to Braintrust.

Readme

@braintrust/pi-extension

npm version

Braintrust extension for pi.

Today this extension automatically traces pi sessions, turns, model calls, and tool executions to Braintrust. The extension forwards native pi events to the installed bt tracing daemon; all span construction, authentication, recovery, and Braintrust delivery happen inside the daemon.

Version 1 requires a current bt CLI with the Pi daemon translator. If bt or the translator is unavailable, tracing fails open and Pi keeps running.

What gets traced

  • Session spans: one root span per pi session that actually produces at least one turn
  • Turn spans: one span per user prompt / agent run
  • LLM spans: one span per model response inside a turn, including canonical token, cache, reasoning, estimated-cost, and time-to-first-token metrics
  • Tool spans: one span per tool execution, including tools activated through pi's dynamic/deferred tool-loading flow
  • Compaction spans: one span per session compaction, including trigger/retry metadata when available
  • Branch summary spans: one span per summarized /tree navigation branch

Trace shape:

Session (task)
├── Turn 1 (task)
│   ├── anthropic/claude-sonnet-4 (llm)
│   │   ├── read: package.json (tool)
│   │   └── bash: pnpm test (tool)
│   └── anthropic/claude-sonnet-4 (llm)
├── Compaction (task)
├── Branch Summary (task)
└── Turn 2 (task)

Install

From npm

pi install npm:@braintrust/pi-extension

From this repo

pi install .

Or load it just for one run:

pi -e .

Compatibility

This package supports the latest patch release from each of the last five stable pi minor versions, currently excluding pi versions before 0.65.0.

Our GitHub Actions compatibility job automatically resolves and tests that compatibility window, so new pi releases are picked up without manually updating the matrix.

Quick start

bt auth login
bt trace setup pi
pi

For one invocation without changing Pi's global tracing configuration, use bt trace run --project <PROJECT> pi -- [PI_ARGS...].

In interactive mode, the footer shows a Braintrust status indicator while tracing is active, and a widget below the editor shows a shortened clickable trace link when available.

Configuration

You can configure the extension with environment variables or JSON config files.

Config precedence is:

  1. defaults
  2. ~/.pi/agent/braintrust.json
  3. .pi/braintrust.json
  4. environment variables
  5. bt trace run invocation settings (tracing only, highest priority)

Config file locations

  • Global: ~/.pi/agent/braintrust.json
  • Project: .pi/braintrust.json

Example:

{
  "trace_to_braintrust": true,
  "route": {
    "auth": { "profile": "work", "org_name": "acme" },
    "destination": { "type": "project_logs", "project_name": "pi" },
    "additional_metadata": { "team": "platform" }
  }
}

Supported settings

| Config key | Env var | Default | |---|---|---| | trace_to_braintrust | TRACE_TO_BRAINTRUST | false | | org_name | BRAINTRUST_ORG_NAME | unset | | profile | BRAINTRUST_PROFILE | default bt profile | | project | BRAINTRUST_PROJECT | pi | | additional_metadata | BRAINTRUST_ADDITIONAL_METADATA | {} | | show_ui | BRAINTRUST_SHOW_UI | true | | show_trace_link | BRAINTRUST_SHOW_TRACE_LINK | true |

Notes

  • Project config overrides global config.
  • Environment variables override both config files.
  • Project config follows pi's configured project config directory, which defaults to .pi.
  • The extension does not persist local span state; recovery and incomplete-operation cleanup are owned by the daemon journal.
  • Span construction and Braintrust delivery run in the installed bt tracing daemon.
  • The extension never reads or stores Braintrust credentials. Profile selection is non-secret, optional, and resolved by the daemon through bt authentication.
  • Provider request tracing is allowlisted to effective model, thinking, output-limit, and tool-count settings; full provider payloads and thinking signatures are never logged.
  • If Braintrust is unavailable, pi should continue working normally.

Contributing

See CONTRIBUTING.md for development setup, validation, and repository conventions.