I don't know if I'll end up using this. More than anything else, this project was a way for me to play with the latest AIs.
This notice is the only thing I've written. Don't take any other claims in here for truth.
na·if /naɪˈiːf/
noun: a naive person.
adjective: naive.
You're coding with an AI agent. You copy a part of your file into the chat, the AI modifies it, and gives you back a snippet. Now you have to find exactly where that snippet belongs in the original file and manually merge the changes.
Naif automates this.
Copy the AI's response to your clipboard and run naif on your local file. It uses a sliding-window heuristic to find the best match for that snippet within your file—even if the AI included slightly different surrounding lines or hallucinated the context. Once aligned, you can interactively review and toggle every change before applying them.
This tool was vibe-coded specifically for vibe coding. It doesn't try to be a full IDE; it just tries to help you stick AI code back where it belongs.
🚀 SNIPPET ALIGNMENT 🚀
Naif finds where your code goes using a sliding-window algorithm. No more manual searching! 🏠
🌈 SIDE-BY-SIDE DIFFS 🌈
Review changes in a side-by-side terminal UI with full syntax highlighting! 💅
✅ TOGGLE SELECTIONS ✅
Press a key to choose between ORIGINAL and MODIFIED lines for every block! 👆
🖱️ MOUSE SUPPORT 🖱️
Click the scrollbar to jump around or click diff blocks to toggle them! ☕
🔥 ONE-TAP APPLY 🔥
Use the -a flag to instantly patch your file once you're done reviewing! 💨
Install via cargo:
cargo install --path .To patch a file using a snippet in your clipboard:
naif <path-to-file>- Scroll:
j/kor arrows. - Toggle: Click a change block or use navigation keys to select which version to keep.
- Output: Press
Enterto save the patch (or apply it if using-a). - Quit: Press
qto exit without saving.
-a,--apply: Applies the changes directly to the file using the systempatchutility.-s,--stdout: Prints the unified diff to stdout instead of creating a.patchfile.
Build and run using the standard Rust toolchain:
cargo build --release
cargo test
cargo run -- <file1> <file2>The included justfile is used by AI agents to maintain project standards. While just is optional for manual development, it ensures consistent testing and linting:
cargo test: Run all unit tests.cargo clippy: Check for lints.cargo fmt: Format the codebase.