How it works
In a signed chat, nvim-ai hashes the full conversation history and latest response immediately after getting a reply from the LLM. It inserts that hash into the buffer as a signature block.
Separately, the :NAIVerify command hashes the full buffer, compares it to the signature, and displays the "Verified" text (as an extended mark) if it matches.
Also:
- The hashing algorithm uses a persistent, secret key. This prevents the user from simply editing the text in the buffer, then re-hashing it and tampering with the signature themselves.
- As soon as the buffer is edited the "Verified" text disappears (since we can no longer guarantee it matches) but you can check it again by running :NAIVerify.
The hashing algorithm will ignore previous signature blocks and blank lines. Other formatting changes count as differences.
Re uses -- besides arbitration like in the README, you could use it for habit contracts (e.g. beeminder or forfeit). For example, I have a template that I use for a weekly review and have AI evaluate it and make sure it includes all the sections it's supposed to have. If it does the AI responds "Review meets requirements". This verification could prevent one mode of cheating, which would be me just typing in "Review meets requirements" myself.