Anthropic native text editor extension for the pi coding agent.
This package is the standalone extraction of senpi's former builtin anthropic-text-editor extension.
When PI_ANTHROPIC_TEXT_EDITOR is enabled and API is anthropic-messages, the extension:
- Registers a function tool named
str_replace_based_edit_toolwith commands:viewcreatestr_replaceinsert
- Rewrites outgoing Anthropic tool payloads to ensure native
text_editor_20250728is present. - Strips function-shape
str_replace_based_edit_tool,read,write, andedittools from Anthropic payloads. - Appends a system-prompt section that instructs the model to use native text editor operations.
| Case | Result |
|---|---|
PI_ANTHROPIC_TEXT_EDITOR enabled, API anthropic-messages, no native tool present |
injects { type: "text_editor_20250728", name: "str_replace_based_edit_tool" } |
Native text_editor_* tool already present |
preserves caller-provided native tool, no duplication |
Function-shape str_replace_based_edit_tool / read / write / edit present |
strips function shapes from outgoing Anthropic payload |
| Env unset or disabled | no-op |
| API is non-Anthropic | no-op |
Truthy values for PI_ANTHROPIC_TEXT_EDITOR: 1, true, yes, on (case-insensitive; surrounding whitespace allowed).
# From npm (once published)
pi install npm:pi-anthropic-text-editor
# From git
pi install git:github.com/code-yeongyu/pi-anthropic-text-editor
# Manual placement
git clone https://github.com/code-yeongyu/pi-anthropic-text-editor ~/.pi/agent/extensions/pi-anthropic-text-editor
cd ~/.pi/agent/extensions/pi-anthropic-text-editor && npm install
# Dev / one-shot test
pi -e /path/to/pi-anthropic-text-editor/src/index.tsnpm install
npm test
npm run typecheck
npm run checkPorted from packages/coding-agent/src/core/extensions/builtin/anthropic-text-editor/index.ts in code-yeongyu/senpi-mono.
MIT.
- senpi — the fork/runtime these extensions are extracted from.
- Ultraworkers Discord — community link from the senpi README.
- Dori — the product powered by senpi under the hood.