llm-tools.el

Opinionated tools for use by a (local) LLM
Log | Files | Refs | LICENSE

commit 204136e66ccc5a9675178987a5d34e9fd95ba174
parent 1d1102a024912b2d87e711cfd746eea156865af5
Author: Vineet Kumar <git@vineetk.net>
Date:   Sun, 24 May 2026 17:24:13 -0400

fix bug with negative indices in hashline computation

sxhash return type in elisp is signed instead of unsigned. this can
result in negative indices, which in elt seems to get interpreted as 0
(the "aa" bigram) resulting in same hashes for different content lines.

Diffstat:
Mllm-tools-hl.el | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llm-tools-hl.el b/llm-tools-hl.el @@ -55,7 +55,8 @@ Taken from https://github.com/can1357/oh-my-pi. Precisely: https://raw.githubusercontent.com/can1357/oh-my-pi/85003ca/packages/coding-agent/src/hashline/bigrams.json") (defun llm-tools--hl-hash (line) - (elt llm-tools--hl-bigrams (% (sxhash line) 647))) + ;; logand is to force unsigned number + (elt llm-tools--hl-bigrams (% (logand (sxhash line) #xffffffff) 647))) (defun llm-tools--hl-file-lines (file &optional beg end) "Return FILE contents as a list of strings.