commit 389f1a7e240eca36443649d6b283c21cfeb51c08
parent 9ff38dcde67b1c0d597eaa0bee00c395f2f272e6
Author: Vineet Kumar <git@vineetk.net>
Date: Thu, 28 May 2026 14:29:57 -0400
get ready for packaging
Diffstat:
4 files changed, 109 insertions(+), 7 deletions(-)
diff --git a/llm-tools-hl.el b/llm-tools-hl.el
@@ -1,4 +1,35 @@
-;; -*- lexical-binding: t; -*-
+;; llm-tools-hl.el --- Hashline file operations for llm-tools -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2026 Vineet K
+
+;; Author: Vineet K <git@vineetk.net>
+;; Version: 1.0
+;; Keywords: llm, gptel
+;; Package-Requires: ((emacs "28.1"))
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Hashline-based file operations for the llm-tools package.
+;; Provides functions for reading, editing, and verifying files using
+;; a content-addressed line format.
+
+;;; Code:
+
+(require 'cl-lib)
+
(defvar llm-tools--hl-bigrams
(list "aa" "ab" "ac" "ad" "ae" "af" "ag" "ah" "ai" "aj" "ak" "al" "am" "an"
"ao" "ap" "aq" "ar" "as" "at" "au" "av" "aw" "ax" "ay" "az" "ba" "bb"
@@ -119,7 +150,7 @@ single string."
(not (string-prefix-p "#" trimmed)))))
(defun llm-tools--hl-parse-op-line-for-verify (line)
- "Parse a single operation LINE (e.g. \"+ 4ei\") into a `hl-verify-op`."
+ "Parse a single operation LINE (e.g. \"+ 4ei\") into a `hl-verify-op'."
(let* ((trimmed (string-trim line))
(ch (substring trimmed 0 1)))
(make-hl-verify-op
@@ -334,7 +365,7 @@ line in the on-disk file."
(string-to-number (substring anchor 0 (- (length anchor) 2))))
(defun llm-tools--hl-parse-op-line (line)
- "Parse a single operation LINE into an `hl-op` struct.
+ "Parse a single operation LINE into an `hl-op' struct.
LINE must start with `+`, `<`, `-`, or `=`, followed by a space,
followed by an anchor (or range)."
(string-match "^[+<=-] \\(.*\\)" line) ; returns index or nil
@@ -349,7 +380,7 @@ followed by an anchor (or range)."
("=" (make-hl-op :type 'replace :range (split-string anchor "\\.\\."))))))
(defun llm-tools--hl-parse-section (section)
- "Parse SECTION (body after `@@ PATH`) into a list of `hl-op` structs.
+ "Parse SECTION (body after `@@ PATH`) into a list of `hl-op' structs.
Skips comment lines (starting with `#`) and blank lines."
(let (ops op)
(dolist (line (string-lines section))
@@ -414,7 +445,7 @@ FILENAME."
(- offset (- b a 1)))))
(defun llm-tools--hl-apply-replace (range payload content offset)
- "Replace lines from (car RANGE) to (cadr RANGE) with PAYLOAD (nil → '(\"\"))"
+ "Replace lines from (car RANGE) to (cadr RANGE) with PAYLOAD (nil to '(\"\"))"
(let ((a (+ (llm-tools--hl-anchor-to-line-num (car range)) offset))
(b (+ (llm-tools--hl-anchor-to-line-num (cadr range)) offset))
(payload (or payload '(""))))
diff --git a/llm-tools-pkg.el b/llm-tools-pkg.el
@@ -0,0 +1,5 @@
+(define-package 'llm-tools "1.0"
+ "Opinionated tools for use by an LLM."
+ '((emacs "28.1") (gptel "0.9.6") (magit "3.3.0"))
+ :keywords '("llm" "gptel")
+ :url "https://git.vineetk.net/llm-tools.el/")
+\ No newline at end of file
diff --git a/llm-tools-web.el b/llm-tools-web.el
@@ -1,4 +1,34 @@
-;;; Web tools, taken from gptel-agent -*- lexical-binding: t; -*-
+;;; llm-tools-web.el --- Web tools for llm-tools -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2026 Vineet K
+
+;; Author: Vineet K <git@vineetk.net>
+;; Version: 1.0
+;; Keywords: llm, gptel, processes
+;; Package-Requires: ((emacs "28.1"))
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Web tools for the llm-tools package, adapted from gptel-agent.
+;; Provides functions for web searching and URL fetching.
+
+;;; Code:
+
+(require 'cl-lib)
+
(defun llm-tools--fetch-with-timeout (url url-cb tool-cb failed-msg &rest args)
"Fetch URL and call URL-CB in the result buffer.
diff --git a/llm-tools.el b/llm-tools.el
@@ -1,4 +1,39 @@
-;; -*- lexical-binding: t; -*-
+;; llm-tools.el --- Opinionated tools for use by an LLM -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2026 Vineet K
+
+;; Author: Vineet K <git@vineetk.net>
+;; Version: 1.0
+;; Keywords: llm, gptel
+;; Package-Requires: ((emacs "28.1") (gptel "0.9.6") (magit "3.3.0"))
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This package provides a set of opinionated tools for use by an LLM via GPTel.
+;; It includes tools for file operations, web search, and bash execution.
+
+;;; Code:
+
+(require 'cl-lib)
+(require 'magit)
+
+(defgroup llm-tools nil
+ "Opinionated tools for use by an LLM."
+ :group 'convenience)
+
(require 'llm-tools-hl)
(require 'llm-tools-web)