pi-codebuddy-sdk
Pi extension that uses CodeBuddy (via Agent SDK) as a model provider and adds an AskCodebuddy tool.
Package details
Install pi-codebuddy-sdk from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-codebuddy-sdk- Package
pi-codebuddy-sdk- Version
0.4.44- Published
- Nov 3, 2026
- Downloads
- 3,720/mo · 1,407/wk
- Author
- alexandre_ai
- License
- MIT
- Types
- extension
- Size
- 155.5 KB
- Dependencies
- 2 dependencies · 4 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
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 and skills 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
pi install npm:pi-codebuddy-sdk
Restart pi if it was already running.
Requirements
codebuddyon yourPATH— the extension spawns the same CLI you use standalone. Ifwhich codebuddyfails, either add it toPATHor setpathToCodebuddyCodeincodebuddy-sdk.json(see Configuration). That option selects the CLI entry point only; the JavaScript runtime used to run it comes from the host, and a Bun-compiled host without abunonPATHneedsprovider.executable(see below).- CodeBuddy auth already working — if
codebuddyworks 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.
pi install npm:pi-codebuddy-sdk- Restart
pi /model→ pickcodebuddy/...
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. Managed network environment
export CODEBUDDY_INTERNET_ENVIRONMENT=<environment>
codebuddy login
Set <environment> to the value your CodeBuddy deployment uses. Ask your CodeBuddy administrator if the value is not documented in your deployment's own README, and add CODEBUDDY_API_KEY as well if your environment requires it.
Usage
pi
/model
Pick any entry prefixed with codebuddy/ (for example codebuddy/deepseek-v4.1-flash).
Tools, skills, extensions, /compact, and steer behave the same as with other Pi providers.
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 the codebuddy CLI entry point when it is not on PATH; does not change the JS runtime |
provider.executable |
host runtime | Runtime used to spawn the CLI (e.g. "node"). Set it when the host is Bun-compiled (no bun on PATH); auto-detected otherwise |
provider.isolatedEnv |
false |
Opt in to a private CodeBuddy config dir with user, auto, and team memory disabled |
provider.codebuddyConfigDir |
~/.codebuddy-cli-isolated |
Config dir used when isolatedEnv is enabled |
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,
thinkingLevelMap.
thinkingLevelMap maps a pi thinking level to the effort string sent to the
CodeBuddy CLI. pi only offers xhigh and max when a model declares them here
(pi-ai getSupportedThinkingLevels), so a model that supports max upstream
stays unreachable until the map names it:
{
"provider": {
"modelOverrides": {
"deepseek-v4.1-flash": { "thinkingLevelMap": { "max": "max" } },
"space-bunny": { "thinkingLevelMap": { "xhigh": "xhigh", "max": "max" } }
}
}
}
Declare only the habits the model actually serves — an effort the backend rejects fails the turn.
Set provider.isolatedEnv to keep Pi turns away from the CodeBuddy IDE's rules,
projects, and memory. The extension sends both the CLI subprocess and its own
session files to one config dir:
{
"provider": {
"isolatedEnv": true,
"codebuddyConfigDir": "/path/to/private-codebuddy-config"
}
}
The first run against a new dir needs the CodeBuddy CLI login for that dir.
Window values the backend reports for a model are remembered per model id in
~/.pi/agent/codebuddy-sdk-learned-windows.json, so the next start registers the
last served values instead of the name estimate. Precedence: modelOverrides >
learned > served metadata > estimate. Delete that file to start from estimates
again (ids the backend no longer serves are dropped automatically).
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. - CodeBuddy loads project instructions, rules, and project memory independently of
--setting-sources; those files can add context that is not part of the Pi session. Setprovider.isolatedEnvto use a private config dir with memory disabled.
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). If the
model is still missing, share the debug log (CODEBUDDY_SDK_DEBUG=1) and the cache file.
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.