branch: externals/ellama
commit d9ee61b4da10245c335cac8519e22e53d8eb8774
Merge: f0f4589c72 1358d67657
Author: Sergey Kostyaev <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #373 from s-kostyaev/support-agents-md
Add AGENTS.md support to system message
---
AGENTS.md | 3 ++-
NEWS.org | 7 +++++++
docs/instructions.org | 12 ------------
ellama.el | 32 +++++++++++++++++++++++++++++++-
4 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/AGENTS.md b/AGENTS.md
index 885178adb9..1d1b1b3828 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -15,7 +15,8 @@
- In `ellama-tools.el` in tool spec use `snake_case`.
- **Error handling**: Wrap risky calls in `(condition-case err ...)` and
signal with `(error "msg")` when appropriate.
- **Docstrings**: Oneāline summary, then optional details; keep under 80 chars
- per line. Do not add empty lines.
+ per line. Do not add empty lines. If there are multiple sentences on one
line,
+ sentences should be separated by two spaces.
- **Comments**: Prefix with `;;` for buffer comments; avoid inline `#` clutter.
## Operation Guidelines
diff --git a/NEWS.org b/NEWS.org
index 0b7cadbbb6..7d7b87cb24 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,3 +1,10 @@
+* Version 1.11.1
+- Add AGENTS.md support to system message. Include the AGENTS.md file content
+ from the current project or subproject in the system message by adding helper
+ functions to locate and read the file from the directory tree up to the
+ project root.
+- Refine style guidelines and remove old instructions. Updated docstring
+ formatting rules in AGENTS.md and removed legacy instructions.org file.
* Version 1.11.0
- Add skills system to Ellama.
- Add Agent Skills to the documentation.
diff --git a/docs/instructions.org b/docs/instructions.org
deleted file mode 100644
index 21b393f887..0000000000
--- a/docs/instructions.org
+++ /dev/null
@@ -1,12 +0,0 @@
-* About this project
-
-This project is written in emacs lisp.
-
-* Rules
-
-- Write simple and readable code.
-- Always use ~ert~ for tests.
-- All function names and custom variable names should start with ~ellama-~.
-- Function docstrings should contain all arguments in uppercase, like SOME-ARG.
-- In docstrings, if there are multiple sentences on one line,
- sentences should be separated by two spaces.
diff --git a/ellama.el b/ellama.el
index df6b8f1e16..4ce5142f05 100644
--- a/ellama.el
+++ b/ellama.el
@@ -6,7 +6,7 @@
;; URL: http://github.com/s-kostyaev/ellama
;; Keywords: help local tools
;; Package-Requires: ((emacs "28.1") (llm "0.24.0") (plz "0.8") (transient
"0.7") (compat "29.1") (yaml "1.2.3"))
-;; Version: 1.11.0
+;; Version: 1.11.1
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Created: 8th Oct 2023
@@ -1213,9 +1213,39 @@ Otherwire return current active session."
(defvar ellama-global-system nil)
+(defun ellama-get-agents-md-path ()
+ "Search for AGENTS.md file from current directory up to project root.
+Returns the full path to AGENTS.md if found, or nil if not found."
+ (let* ((current-dir (file-name-directory (expand-file-name
default-directory)))
+ (project-root
+ (file-name-directory (expand-file-name
+ (or (project-root (project-current))
current-dir))))
+ found-path)
+ ;; Walk up from current directory to project root
+ (while (and (not found-path)
+ (or (string= current-dir project-root)
+ (string> current-dir project-root)))
+ (let ((agents-path (expand-file-name "AGENTS.md" current-dir)))
+ (when (file-exists-p agents-path)
+ (setq found-path agents-path)))
+ ;; Move to parent directory
+ (setq current-dir (file-name-directory (expand-file-name ".."
current-dir))))
+ found-path))
+
+(defun ellama-get-agents-md ()
+ "Return current project or subproject AGENTS.md content."
+ (or (when-let ((path (ellama-get-agents-md-path)))
+ (concat
+ "\n"
+ (with-temp-buffer
+ (insert-file-contents path)
+ (buffer-string))))
+ ""))
+
(defun ellama-get-system-message ()
"Return the effective system message, including dynamically scanned skills."
(let ((msg (concat (or ellama-global-system "")
+ (ellama-get-agents-md)
(ellama-skills-generate-prompt))))
(when (not (string= msg ""))
msg)))