/** * context-usage — a Pi extension that analyzes current context usage, * similar to Claude Code's context meter. * * Commands: * - `/context` overview (tokens / window / percent / compaction * threshold) + breakdown by section: system prompt, * messages by role, tools by source * - `/context skills` scrollable list of loaded skills, sorted by * estimated prompt footprint * - `/context tools` scrollable list of registered tools with their * source, sorted by estimated definition size * - `/context files` list of loaded context files (AGENTS.md etc.) * * Structure: this file is a thin registration stub. The implementation lives * in `src/`: * - `src/command.ts` subcommand routing + output-sink selection * - `src/breakdown/` per-section data collectors (system prompt, messages, * tools) — pure functions, unit-tested in `test/` * - `src/report.ts` renders the overview report as plain text * - `src/ui/` TUI panels (static panel, scrollable list) * - `src/estimate.ts` token estimation — the seam for a future real * tokenizer (currently chars/4, see `src/format.ts` for * rendering helpers and `src/types.ts` for the data model) */ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; import { contextCommand } from "./src/command"; export default function (pi: ExtensionAPI) { pi.registerCommand("context", { description: "Show context usage: overview + breakdown, or lists (skills/tools/files)", handler: contextCommand(pi), }); }