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

@dracondev/pi-codebuddy-sdk

v0.4.5

Published

Pi CodeBuddy provider with hy4-preview/max support and race-free MCP tool bridging.

Readme

pi-codebuddy-sdk

Pi extension that registers CodeBuddy as a model provider. You keep using Pi for the TUI, tools, skills, and extensions; CodeBuddy Agent SDK runs inference locally via the codebuddy CLI. No HTTP proxy and no changes to how you work in Pi beyond picking a model.

What it does

  • Exposes CodeBuddy models in Pi (codebuddy/... in /model)
  • Bridges Pi tools to the SDK (Pi still executes tools; CodeBuddy only plans and calls them)
  • Forwards Pi's system prompt, skills, and project AGENTS.md so the model acts as Pi—not as standalone CodeBuddy Code
  • Supports session resume, compaction, streaming, thinking levels, and images
  • Optional AskCodebuddy tool to delegate a focused sub-task to another CodeBuddy call

Install

This maintained fork is published on npm and can also be installed directly from GitHub:

# If the upstream npm package is already installed, replace it first.
pi remove npm:pi-codebuddy-sdk
pi install npm:@dracondev/pi-codebuddy-sdk

GitHub alternative:

pi install git:github.com/DraconDev/pi-codebuddy-sdk@main

Restart pi if it was already running. For a temporary test, use pi -e npm:@dracondev/pi-codebuddy-sdk.

Requirements

  • codebuddy on your PATH — the extension spawns the same CLI you use standalone. If which codebuddy fails, either add it to PATH or set pathToCodebuddyCode in codebuddy-sdk.json (see Configuration).
  • CodeBuddy auth already working — if codebuddy works in your terminal, you do not need extra setup for this extension.

Quick start (already using CodeBuddy)

No codebuddy-sdk.json and no plugin-specific env vars are required.

  1. pi install npm:@dracondev/pi-codebuddy-sdk
  2. Restart pi
  3. /model → pick codebuddy/...

Optional: set defaultProvider / defaultModel in ~/.pi/agent/settings.json so you skip /model each time.

The first query after startup may take a few seconds while models are discovered from the SDK.

Auth

The extension does not store credentials. The CodeBuddy CLI reads them from your machine. Use one of the following:

1. CLI login (recommended)

codebuddy login

Complete login in the browser. Credentials stay on your machine; Pi reuses them automatically.

2. API key

export CODEBUDDY_API_KEY="your-api-key"

Obtain the key from your CodeBuddy account. Do not commit it or store it in repo files.

3. Tencent iOA (internal network)

export CODEBUDDY_INTERNET_ENVIRONMENT=ioa
codebuddy login

Use this when CodeBuddy must run on the iOA network. Add CODEBUDDY_API_KEY as well if your environment requires it.

Usage

pi --model codebuddy/hy4-preview --thinking max

Or select a model interactively:

pi
/model

This fork keeps hy4-preview available even when the CodeBuddy CLI's model catalog omits it, and maps Pi's highest reasoning level (max) to CodeBuddy's runtime max effort. The model is account-dependent; if it is not enabled, choose another codebuddy/... model.

Tools, skills, extensions, /compact, and steer behave the same as with other Pi providers.

Tool-call race fix

The CodeBuddy SDK can start MCP tool handlers before it emits the stream event that contains each tool-call ID. The bridge now queues those handlers by tool name, binds them when the event arrives, and matches later Pi results by the real ID. This prevents the 1 tool handler(s) still waiting — provider may be stuck warning and supports multiple calls in the same turn.

Configuration

Optional. Defaults work for most users.

File: ~/.pi/agent/codebuddy-sdk.json or .pi/codebuddy-sdk.json in a project.

{
  "askCodebuddy": {
    "enabled": true,
    "allowFullMode": true
  },
  "provider": {
    "appendSystemPrompt": true,
    "strictMcpConfig": true,
    "pathToCodebuddyCode": "/path/to/codebuddy"
  }
}

| Option | Default | Meaning | |--------|---------|---------| | askCodebuddy.enabled | true | Register the AskCodebuddy delegation tool | | askCodebuddy.allowFullMode | true | Allow write-capable delegation mode | | provider.appendSystemPrompt | true | Use Pi's system prompt instead of CodeBuddy's default identity | | provider.strictMcpConfig | true | Use only Pi-bridged MCP tools | | provider.pathToCodebuddyCode | auto | Path to codebuddy when it is not on PATH | | provider.contextWindow | estimated | Override context window (tokens) for all models (e.g. 300000) | | provider.maxTokens | estimated | Override max output tokens for all models (e.g. 32768) | | provider.modelOverrides | — | Per-model overrides, keyed by model id or substring (see below) |

modelOverrides lets you fine-tune individual models; the longest matching key wins and beats the global contextWindow / maxTokens:

{
  "provider": {
    "modelOverrides": {
      "gpt-5": { "contextWindow": 1048576, "maxTokens": 64000, "images": false },
      "claude": { "reasoning": true }
    }
  }
}

Supported per-model keys: contextWindow, maxTokens, reasoning, images.

Privacy

  • The extension does not send conversation data to this repository or any third-party telemetry endpoint.
  • Credentials are handled entirely by the CodeBuddy CLI on your machine.
  • Optional debug mode (CODEBUDDY_SDK_DEBUG=1) writes local logs under ~/.pi/agent/; paths are redacted, prompts and tool payloads are not logged. Delete logs when finished.

Troubleshooting

export CODEBUDDY_SDK_DEBUG=1

Default log: ~/.pi/agent/codebuddy-sdk.log. See CONTRIBUTING.md for maintainer details.

After pi -r, the previously selected codebuddy model is gone from /model? The last-known-good model list is cached to ~/.pi/agent/codebuddy-sdk-models.json on every successful discovery, so a new pi process can re-register it synchronously at module load — even when SDK discovery is still in flight (new process, gate busy, or stale auth). The fork also adds hy4-preview as a fallback. If the model is still missing, share the debug log (CODEBUDDY_SDK_DEBUG=1) and the cache file.

A tool call is stuck or the provider warning appears? Restart the current Pi process after installing the fork. Then enable CODEBUDDY_SDK_DEBUG=1 and inspect ~/.pi/agent/codebuddy-sdk.log; successful binding includes mcp tool call: ... → bound waiting handler followed by a provider: resolving ... line.

Development

Maintainers: CONTRIBUTING.md.

License

MIT

Inspiration

Early MCP bridge patterns were inspired by pi-claude-bridge. This package is a separate codebase on @tencent-ai/agent-sdk.