Thanks to visit codestin.com
Credit goes to github.com

Skip to content

dylan-hachmann/naif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

a human notice

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.

Naif

na·if /naɪˈiːf/
noun: a naive person.
adjective: naive.

The Problem

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.


✨ GLORIOUS FEATURES ✨

🚀 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! 💨


Usage

Install via cargo:

cargo install --path .

To patch a file using a snippet in your clipboard:

naif <path-to-file>

Controls

  • Scroll: j/k or arrows.
  • Toggle: Click a change block or use navigation keys to select which version to keep.
  • Output: Press Enter to save the patch (or apply it if using -a).
  • Quit: Press q to exit without saving.

Flags

  • -a, --apply: Applies the changes directly to the file using the system patch utility.
  • -s, --stdout: Prints the unified diff to stdout instead of creating a .patch file.

Development

Build and run using the standard Rust toolchain:

cargo build --release
cargo test
cargo run -- <file1> <file2>

Note on just

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.

About

vibe coded tool for vibe coding

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published