@random-long-int/pi-context
Pi extension that adds a /context modal for context budget breakdowns.
Package details
Install @random-long-int/pi-context from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@random-long-int/pi-context- Package
@random-long-int/pi-context- Version
0.1.0- Published
- May 20, 2026
- Downloads
- not available
- Author
- random-long-int
- License
- unknown
- Types
- extension
- Size
- 29.6 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi context modal extension
Adds /context, a floating overlay that estimates current context usage by segment:
- system prompt
- tool schemas
- rules/context files
- skills
- conversation
- segments contributed by other extensions
Install
From npm:
pi install npm:@random-long-int/pi-context
Or try it for one run:
pi -e npm:@random-long-int/pi-context
Then, from inside pi:
/context
For local development, this directory can also be placed in an auto-discovered extension location:
~/.pi/agent/extensions/context-modal/index.ts
After local edits, run:
/reload
/context
Development
cd ~/.pi/agent/extensions/context-modal
bun install
bun run check
npm pack --dry-run
Extension hook for MCP or other context sources
Another extension can add a segment synchronously through pi's shared event bus:
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
export default function (pi: ExtensionAPI) {
pi.events.on("context-modal:collect", (payload: unknown) => {
const p = payload as {
add(provider: (args: { estimateJsonTokens(value: unknown): number }) => unknown): void;
};
p.add(({ estimateJsonTokens }) => ({
id: "mcp",
label: "MCP",
shortcut: "m",
letter: "m",
color: "thinkingHigh",
tokens: estimateJsonTokens({ servers: discoverYourMcpServersSomehow() }),
details: ["2 servers", "8 tools"],
order: 50,
}));
});
}
The listener must call payload.add(...) synchronously. The provider itself may be async.