https://github.com/code-yeongyu/pi-anthropic-text-editor
Anthropic native text editor policy extension for the pi coding agent. Registers str_replace_based_edit_tool and ensures text_editor_20250728 is used on anthropic-messages payloads when opt-in is enabled.
https://github.com/code-yeongyu/pi-anthropic-text-editor
anthropic claude coding-agent pi pi-coding-agent pi-extension pi-mono str-replace text-editor typescript
Last synced: 11 days ago
JSON representation
Anthropic native text editor policy extension for the pi coding agent. Registers str_replace_based_edit_tool and ensures text_editor_20250728 is used on anthropic-messages payloads when opt-in is enabled.
- Host: GitHub
- URL: https://github.com/code-yeongyu/pi-anthropic-text-editor
- Owner: code-yeongyu
- License: mit
- Created: 2026-05-12T04:08:35.000Z (21 days ago)
- Default Branch: main
- Last Pushed: 2026-05-14T03:17:59.000Z (19 days ago)
- Last Synced: 2026-05-14T05:17:21.106Z (19 days ago)
- Topics: anthropic, claude, coding-agent, pi, pi-coding-agent, pi-extension, pi-mono, str-replace, text-editor, typescript
- Language: TypeScript
- Size: 49.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Notice: NOTICE
- Agents: AGENTS.md
Awesome Lists containing this project
- awesome-pi-coding-agent - code-yeongyu-pi-anthropic-text-editor - messages payloads when opt-in is enab | | 12d ago | (Extensions)
README
# pi-anthropic-text-editor
[](https://github.com/code-yeongyu/pi-anthropic-text-editor/actions/workflows/ci.yml) [](LICENSE)
Anthropic native text editor extension for the [pi coding agent](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent).
This package is the standalone extraction of senpi's former builtin `anthropic-text-editor` extension.
## Behavior
When `PI_ANTHROPIC_TEXT_EDITOR` is enabled and API is `anthropic-messages`, the extension:
1. Registers a function tool named `str_replace_based_edit_tool` with commands:
- `view`
- `create`
- `str_replace`
- `insert`
2. Rewrites outgoing Anthropic tool payloads to ensure native `text_editor_20250728` is present.
3. Strips function-shape `str_replace_based_edit_tool`, `read`, `write`, and `edit` tools from Anthropic payloads.
4. 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).
## Installation
```bash
# 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.ts
```
## Development
```bash
npm install
npm test
npm run typecheck
npm run check
```
## Origin
Ported from `packages/coding-agent/src/core/extensions/builtin/anthropic-text-editor/index.ts` in `code-yeongyu/senpi-mono`.
## License
[MIT](LICENSE).
## Related
- [senpi](https://github.com/code-yeongyu/senpi) — the fork/runtime these extensions are extracted from.
- [Ultraworkers Discord](https://discord.gg/PUwSMR9XNk) — community link from the senpi README.
- [Dori](https://sisyphuslabs.ai) — the product powered by senpi under the hood.