https://github.com/aboutlo/pi-smart-edit
https://github.com/aboutlo/pi-smart-edit
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/aboutlo/pi-smart-edit
- Owner: aboutlo
- License: mit
- Created: 2026-04-19T20:45:39.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2026-04-19T20:55:51.000Z (2 months ago)
- Last Synced: 2026-04-19T22:32:22.737Z (2 months ago)
- Language: TypeScript
- Size: 67.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
# pi-extension-smart-edit
A [pi](https://github.com/badlogic/pi) extension that overrides the built-in `edit` tool with whitespace-tolerant matching, designed for local/quantized LLMs.
**smart-edit is a drop-in replacement for `edit` that makes local/quantized LLM coding more reliable.**
## TL;DR
With Qwen 3.6 int4 runs (10 vs 10), smart-edit improved **edit success from 46% to 89%** and **task pass from 40% to 80%** on my local benchmark\*.
It also reduced average runtime from **707s to 492s** (**~30% faster**) on that benchmark set.
For Qwen 3.6 nvfp4, the latest patched run improved task pass (10% → 20%) but has lower edit success and slower runtime by far in my use case (see table).
---
## Problem
Local LLMs often fail exact-text edits because of tiny formatting drift (indentation, quotes, trailing spaces). This causes retry loops and wasted tokens.
## Solution
`smart-edit` keeps `edit` precise, but more tolerant for local models:
1. Exact match (same behavior as built-in)
2. Normalized line match (whitespace/quote tolerant)
So you keep strict edits, but avoid brittle failures from tiny formatting drift.
It supports the current `edit` contract and keeps compatibility with older argument shapes, so resumed sessions continue to work.
## Install
```bash
# npm
pi install npm:@aboutlo/pi-smart-edit
pi install npm:@aboutlo/pi-smart-edit@0.4.0 # pinned version
# git
pi install git:github.com/aboutlo/pi-extension-smart-edit
pi install git:github.com/aboutlo/pi-extension-smart-edit@v0.4.0 # tag or commit
```
Or for quick local testing:
```bash
pi -e /path/to/pi-extension-smart-edit/src/index.ts
```
## Usage
After loading the extension, use `edit` normally in pi. The model/tooling handles the argument shape automatically.
## Benchmark summary
This benchmark runs the same medium coding task 10 times per model, then reports:
- `edit` success rate,
- end-to-end task pass rate (typecheck + tests + no timeout),
- runtime.
### Results
| Model | Edit Success (without) | Edit Success (with) | Task Pass (without) | Task Pass (with) | Avg Time (without) | Avg Time (with) |
| -------------- | ---------------------: | ------------------: | ------------------: | ---------------: | -----------------: | --------------: |
| Qwen 3.5 int4 | 69% | 90% | 20% | 40% | 620s | 655s |
| Qwen 3.5 nvfp4 | 98% | 86% | 20% | 20% | 651s | 814s |
| Qwen 3.6 int4 | 46% | 89% 🔥 | 40% | 80% 🔥 | 707s | 492s 🔥 |
| Qwen 3.6 nvfp4 | 74% | 72% | 10% | 20% | 706s | 839s |
- Benchmark code isn't shared. I may do it later once I open source the other repo that I'm developing with only local LLMs
### Tips
Int4 models are not always available but you can encode one on your mac following the below steps
- `huggingface-cli download Qwen/Qwen3.6-27B`
- `vi ~/my/path/Modelfile-Qwen3.6-27B-coding` or `vi ~/my/path/Modelfile-Qwen3.6-27B-general`
### for coding
```
FROM /Users/[USER]/.cache/huggingface/hub/models--Qwen--Qwen3.6-35B-A3B/snapshots/7da1103448ba36029c34ce1a9a741dfe93ee0c50 # TODO CHANGE THE HASH
RENDERER qwen3.5
PARSER qwen3.5
PARAMETER num_ctx 32768
PARAMETER temperature 0.15
PARAMETER top_k 40
PARAMETER top_p 0.92
PARAMETER min_p 0.03
PARAMETER repeat_penalty 1.08
PARAMETER repeat_last_n 256
PARAMETER presence_penalty 0 or for general
```
### for general purpose tasks
```
FROM /Users/[USER]/.cache/huggingface/hub/models--Qwen--Qwen3.6-35B-A3B/snapshots/7da1103448ba36029c34ce1a9a741dfe93ee0c50 # TODO CHANGE THE HASH
RENDERER qwen3.5
PARSER qwen3.5
PARAMETER num_ctx 32768
PARAMETER temperature 0.6
PARAMETER top_k 20
PARAMETER top_p 0.95
PARAMETER min_p 0
PARAMETER repeat_penalty 1
PARAMETER presence_penalty 03- ollama create --experimental -q int4 aboutlo/qwen3.6-27B-int4 -f ~/Desktop/Modelfile-Qwen-3.6-27B-general
```
- `ollama create --experimental -q int4 aboutlo/qwen3.6-27B-int4 -f ~/Desktop/Modelfile-Qwen-3.6-27B-general`
Enjoy :)