decorated-pi0.12.6
decorated-pi is a practical enhancement pack for pi coding agent — token-efficient workflow, cache-friendly design, and smarter tools.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
decorated-pi
decorated-pi is a practical enhancement pack for Pi — token-efficient workflow, cache-friendly design, and smarter tools.
Install
pi install npm:decorated-pi
# or
pi install git:github.com/lcwecker/decorated-pi
# or
pi install /path/to/decorated-pi
Features
1. Token Efficiency
Multiple layers of token savings that compound across every session.
Talk Normal Prompt — injects a response-style prompt adapted from talk-normal (prompt.md v0.6.2), trimming filler, summary stamps, conditional follow-up menus, negation-frame phrasing, and verbose framing. This reduces assistant output tokens and keeps visible reasoning / explanation blocks tighter.
Codegraph — integrates codegraph to offer a code map of your project, so the LLM can navigate symbols and call graphs without chaining ls → grep → read. Create and maintain the project index yourself; see the codegraph documentation.
Auxiliary Models — offloads heavy-but-dumb tasks to cheaper models so your primary model only pays for the hard work:
- Image Read Fallback — detects image type via magic bytes, calls a configured vision-capable model, and injects the analysis text, so your main model never touches image tokens
- PDF Read — reads PDFs with the configured model: a document of ten pages or fewer whole, a longer one in page ranges rendered to images, returning the extraction as text
- Compact Model — handles context compaction with a smaller model instead of burning main-model capacity, and carries the task on after an automatic compaction so the run does not stop early (a manual
/compactdoes not resume)
Configured via
/dp-model.
Cache‑friendly Design — stable system prompt prefix:
- tool definitions, guidelines, and skills are sorted alphabetically so the system prompt stays deterministic for the same project and configuration
- MCP servers are registered with pi's built-in MCP extension, so the session keeps one connection path and one tool list
Pi Native Prompt Slimming — moves the default Pi documentation block out of the system prompt and into a builtin pi-docs skill, so the docs reference loads on demand instead of sitting in every turn's prompt.
Large Result Externalization — a tool_result hook saves a tool's first text result when it exceeds 30,000 characters to /tmp/decorated-pi-results/<tool>-<callId>.txt, replacing it with a one-line pointer ([Output too long, saved to /tmp/…]) that the LLM can read on demand. Only the oversized part is replaced — an image or a second text part in the same result stays in context. The built-in bash tool is left to pi, which captures shell output itself (50 KB / 2000 lines, full text in a spill file). Earlier days' files are swept on session start.
2. Smarter Tools
LLM-callable tools and workflow upgrades with better UX and fewer wasted turns.
Patch Tool
| Capability | Pi native edit |
patch |
|---|---|---|
| Anchor‑based search | ❌ extending oldText for uniqueness |
✅ anchor bounds scope for precise matching |
| Fuzzy whitespace match | ❌ only reports "not found" | ✅ auto‑corrects tab↔space / trailing whitespace mismatches |
| Edit fault diagnostics | ❌ only reports "not found" | ✅ pinpoint faults for LLM comprehension |
| Stale‑read protection | ❌ Blind to external changes | ✅ read captures mtime, patch rejects stale targets |
LSP support
A language server answers from the compiler's binding graph: imports, re-exports and overloads resolve exactly, every reference to a symbol is enumerated, and a rename's complete edit set comes back across every file that references it. A model reading the files works from the subset it opened.
lsp_definition— where a symbol is definedlsp_references— every reference to a symbollsp_document_symbols— a file's symbol outline, to find a positionlsp_rename— the exact workspace edits for a rename, applied to disk (or previewed)
Language coverage — 34 languages over 31 servers, detected by extension, then by exact filename (Dockerfile, Gemfile), then by a #! line for an extensionless script: typescript/javascript, c, cpp, python, rust, go, ruby, java, lua, svelte, html, css, scss, less, json, markdown, bash, yaml, vue, astro, dockerfile, php, csharp, kotlin, swift, scala, dart, zig, haskell, ocaml, nix, clojure, terraform, toml. TypeScript is bundled (its tsc --lsp ships inside the pack); every other server is one the machine or the project already has — vscode-langservers-extracted for html/css/json/markdown, bash-language-server, yaml-language-server, @vue/language-server, @astrojs/language-server, dockerfile-language-server-nodejs, intelephense, plus the native servers of each language. Python has three, tried in order: ty server (Astral's Rust checker — uv tool install ty), then basedpyright-langserver, then pyright-langserver; whichever exists first wins, and the project's own node_modules/.bin beats PATH. A prompt section lists the supported languages of the current project and tells the model to reach for lsp_* first on a single file — renaming a symbol, locating a definition, finding every reference — so it does not spend a call discovering that the language has no server. It is computed once per session and cached, and it rides in as its own systemPromptOptions section so pi patches only that section. They are not dependencies: nothing is pre-installed and nothing is pre-announced. The first call for a language whose server is missing returns that server's own error and its install hint. A server installed outside PATH can be pointed at with dependencies["<command>"].path in decorated-pi.json.
Ask tool
Collect text, single-choice and multi-choice answers when the agent needs clarification. One question per page in the terminal: type for free text, ↑↓ or digits to pick an option, Space to toggle in a multi-choice, Enter/Tab to commit and advance, Shift+Tab to go back, Esc to cancel the whole call.
- Interactive only — a session without a UI gets an error instead of a guess, so the agent puts the questions in its reply and works in rpc/json/print sessions.
- Configuration —
/dp-settings→ Tools → Ask, ormodules.tools.askindecorated-pi.json.
PDF Reader
read_pdf reads a PDF one of two ways, decided by what the configuration can do.
A model whose API carries a PDF document (Anthropic's native document block, Google's inlineData) reads the whole file in one request — text layer plus vision, the most faithful read available.
Everything else is read locally, with no model and no external binary: pdfjs — shipped as unpdf, which bundles the engine in 3.5 MB instead of 38 — extracts the text layer in reading order, and embedded images are downscaled to 2000 px, re-encoded as JPEG and written under <tmp>/decorated-pi/pdf/<hash>/, with an [image: /path (WxH)] placeholder where each one sits on the page — so a figure stays attached to its caption. Encoding is sharp (libvips/mozjpeg): one pass for the 2000 px downscale and the JPEG, 22 ms and a 77 KB page for 2000×1414 pixels. A scan (no text layer) says so and lists its page images. The text is normalized: control and private-use characters dropped, runs of spaces collapsed, a word hyphenated across a line break rejoined, bare page numbers dropped, one [page N] marker per page.
pages ("1-5", 1-indexed) asks for a window, which only local extraction can honour, so it always takes that path; images follow the window (20 pages per call). The page count is stated in the result, so a long document is read in consecutive windows. A document model that refuses the file gets its own error back, with the page count, the size and a pages suggestion appended. read is untouched — a .pdf path handed to it still returns the file's raw bytes.
The model comes from /dp-model → PDF, falling back to the session's active model — and only when its API can carry a document, which /dp-model enforces by listing only those models. A configured model that cannot is cleared on the next read, with a warning, and that read is extracted locally. Without a model, read_pdf still works: the local path needs no provider at all.
3. Web Access
Two native tools, both keyless. Search runs through three hosted backends and falls over automatically; fetching reads the URL directly and only leaves the machine when a plain HTTP client cannot render the page.
websearch — AnySearch → Exa → Parallel, first backend that returns results wins. A filter only one backend understands pins that backend, so includeDomains never lands somewhere it would be ignored.
| Backend | Strength | Endpoint |
|---|---|---|
| AnySearch | widest coverage: 17 vertical domains, batched queries, URL extraction | https://api.anysearch.com/mcp |
| Exa | semantic search plus category, domain, date and summary filters | https://mcp.exa.ai/mcp |
| Parallel | objective-shaped retrieval ranked against a stated goal | https://search.parallel.ai/mcp |
webfetch — local HTTP GET first (localhost and intranet hosts work, the URL stays local), with markdown / text / html output and image URLs returned as attachments. When a bot challenge, an HTTP error or a client-rendered page defeats the local fetch, it retries through AnySearch extract and then Jina reader. Private and local hosts skip those backends, and allowRemote: false keeps every URL on the machine; non-HTTP URLs are refused before any request is made.
Behind an HTTP proxy, Node's
fetchconnects directly and times out even thoughcurlworks — setNODE_USE_ENV_PROXY=1on Node 24+ to make it honourHTTPS_PROXY. Failure messages say so when a proxy variable is set.
4. MCP Ecosystem
Protocol, connections, tool registration and /mcp come from pi's built-in MCP extension. The pack contributes the one server definition it cannot do without, handed over with pi.registerMcpServer() and named by pi as mcp__<server>__<tool>:
| Server | Tool Prefix | Source |
|---|---|---|
| codegraph | mcp__codegraph__* |
local codegraph CLI, only where a .codegraph index exists |
Custom servers in ~/.pi/agent/mcp.json (global) or .pi/mcp.json (project, trusted projects only). Project entries replace global entries with the same name, and an mcp.json entry of the same name takes precedence over the builtin registration.
{
"mcpServers": {
"my-server": {
"url": "https://my-mcp.example.com/mcp",
"enabled": true
},
"my-disabled": {
"url": "https://my-mcp.example.com/other",
"enabled": false
},
"my-stdio": {
"command": "npx",
"args": ["-y", "my-mcp-server"],
"env": { "DEBUG": "1" }
}
}
}
Use /mcp to sign in, reconnect, enable or disable a server and change its exposure — the servers the pack ships appear there with scope extension. Servers speak stdio or streamable HTTP; the SSE transport of the older MCP spec is not available. An mcp.json entry of the same name replaces a builtin server, and it has to carry a valid command/url for the override to be accepted — { "codegraph": { "command": "codegraph", "args": ["serve", "--mcp"], "enabled": false } } switches it off. Servers the pack used to read from a project's .pi/agent/mcp.json are moved to .pi/mcp.json the next time the pack loads with the MCP module enabled — and like any project entry they count only in a trusted project.
5. Other
/code-review [prompt]— offload review of current SCM changes, or of a scope described in the prompt (e.g. a file/directory path, also without a git/svn repository), to a separately configured model, avoiding a/modelswitch in the main session and preserving its prompt cache. Without a scope the reviewer inspects the working tree itself via read-only SCM commands, but requires at least one tracked change (A/M/D/R/…); a tree with only untracked files (or none at all) needs an explicit scope./usage— token stats with cache‑hit rate, per‑model breakdown (Session / Today / This Week / This Month / All Time)/retry— continue after interruption- Progressive context — supports subdirectory
AGENTS.md/CLAUDE.mddiscovery and injection - WakaTime — coding activity tracking via WakaTime
Configuration
Runtime settings live in ~/.pi/agent/decorated-pi.json. Run /dp-settings to configure modules and dependency paths, and /dp-model to configure auxiliary models.
{
"modules": {
"tools": {
"patchOverrideEdit": true,
"ask": true,
"lsp": true,
"mcp": true,
"websearch": true,
"webFetch": true
},
"hooks": {
"wakatime": true,
"tps": true
},
"commands": {
"retry": true,
"usage": true
}
},
"dependencies": {
"wakatime-cli": {
"dontBother": true
}
}
}
modulescan be toggled on/off to enable/disable features. All are enabled by default.dependencies[binaryName].pathoverrides the lookup location for a binary (file or directory).dependencies[binaryName].dontBothersilences missing-dependency notifications for that binary. Both are optional.wakatime-cliandcodegraphare the two binaries/dp-settings → Dependencieslists; a language server is configured the same way in the file, and reports itself through its own tool error when it is absent.
License
MIT