hermes-org-files
A Hermes Agent plugin that lets the agent search and
read your Org mode files and answer from your agenda: what is scheduled
this week, which deadlines are close or overdue, when the next dentist appointment is. It reads the
.org files as they are on disk, with Python's standard library only. It does not need Emacs to be
running, and it never changes a file.
This plugin is not affiliated with the Org mode project or GNU Emacs.
Tools
| Tool | What it does |
|---|---|
org_files | Lists the configured files: id, #+TITLE, number of headings, number of open TODO items, and the TODO keywords each file uses. |
org_search | Searches headings. Every word of query (or "quoted phrase") must appear in the heading or its own text (not its subheadings'); case and accents are ignored. Filters: todo (a keyword such as NEXT, or open, done, any), tags (all must be present; inherited tags and #+FILETAGS count), priority, file. Each result has the heading, outline path, TODO keyword, priority, tags and its SCHEDULED, DEADLINE and CLOSED dates. |
org_agenda | The agenda for a span of days (default: 7 days from today), following org-agenda-list's rules with Org's default settings (below). Each entry has its date, time and end time, kind (scheduled, deadline, timestamp), a note (scheduled 3 days ago, deadline in 2 days, repeat, day 2 of 3), the heading, TODO keyword, tags and category. |
org_read | Reads an entry (the heading, its text and its subheadings) as Org text, or a whole file. Returns its properties and its direct subheadings with ids. Long text comes back in parts (next_offset). |
The tools are offered to the model only while at least one path is configured.
Install
hermes plugins install org-files --enable
No dependencies.
Configure
plugins:
entries:
org-files:
settings:
paths: # .org files, or folders holding them
- ~/org # your org-directory
- ~/notes/projects.org
todo_keywords: [TODO, NEXT, WAITING, "|", DONE, CANCELLED] # optional, see below
max_chars: 12000 # optional; characters per org_read call (1000-100000)
A folder is scanned up to 8 levels deep for *.org files. Hidden files and folders (such as
.git), symlinks, and Emacs's lock (.#file.org) and auto-save (#file.org#) files are skipped,
and so are .org_archive files. Each file's id is the configured folder's name followed by the path
inside it, for example org/work/projects.org.
TODO keywords. A file's own #+TODO: (or #+SEQ_TODO:, #+TYP_TODO:) lines decide which
words are TODO keywords and which of them count as done (those after |; without |, the last
one). Files without such a line use todo_keywords, which should match org-todo-keywords in your
Emacs configuration; the default is TODO | DONE, as in Org. Fast-access keys such as NEXT(n) or
WAITING(w@/!) may be written either way.
How the agenda is computed
The rules below were read from org-agenda.el and org-time.el and checked against Org's own
agenda tests (testing/lisp/test-org-agenda.el and its example files), with Org's default settings:
- SCHEDULED shows on its own day. If it is not done and its day has passed, it also shows on
today as overdue (scheduled N days ago), and on later days where its repeater falls. A delay
cookie (SCHEDULED: <2024-03-05 Tue -14d>) hides it until that many days have passed. A done entry
shows only on its own day. - DEADLINE shows on its own day and on later days where its repeater falls. If it is not done,
it also shows on today when it has passed (deadline was N days ago) or is at most its warning
period away (deadline in N days): the warning cookie (-5d) or else 14 days
(org-deadline-warning-days). - Other active timestamps (
<2024-03-14 Thu 15:30>), in a heading, its text or a property
drawer, show on every day they fall on, repeats included. A range (<a>--<b>) shows on every day
it spans, with its start time on the first day and its end time on the last. - Repeaters
+1w,++1mand.+3d(andh,d,w,m,yunits) repeat from the date
written in the file. Monthly and yearly repeats use Org's calendar arithmetic, so a monthly
repeat from January 31 falls on March 2 (or 3) after February, and a yearly one from February 29
on March 1. A repeater of 0 (+0d) is ignored, as in Org. - Not entries: timestamps in blocks (
#+begin_src,#+begin_example, ...), fixed-width
(:) and comment (#) lines, keyword lines, text before the first heading,COMMENTsubtrees
and subtrees taggedARCHIVE, inactive timestamps ([2024-03-12 Tue]), andCLOSEDdates.
Entries are sorted by day and time; entries without a time follow, scheduled before deadlines before
other timestamps, then in file order.
What it does on your machine (disclosure)
- Reads only the files you configure. Your notes are personal data: what the agent reads goes to
the model provider you use, like anything else in a conversation. - Writes nothing. Files are opened read-only and read whole on each call; nothing is kept between
calls, so another Hermes profile never sees this profile's files. The tests check that no file's
bytes, size or modification time and no file name changes while all four tools run. - No network, no credentials, no shell commands, no background work. The test suite refuses to
open any socket while all four tools run. Emacs is not run or contacted.
Limits
- Settings from your Emacs configuration other than the TODO keywords are not read:
org-agenda-files(usepaths), and changes to the agenda's defaults (org-deadline-warning-days,
org-agenda-skip-scheduled-if-done,org-agenda-show-future-repeatsand the like) are not applied. - Diary sexp timestamps (
<%%(diary-float t 4 2)>),#+SETUPFILEand#+INCLUDEare not read.
Habits (:STYLE: habit) are shown as ordinary scheduled entries. - Org's agenda sorts by an urgency score; this plugin uses the simpler order above.
- Files must be UTF-8 (other bytes are replaced); encrypted files (
.org.gpg) andorg-crypt
entries are not decrypted. Files over 20 MB are skipped and reported. - A heading id is its line number and a hash of the heading line. If lines are added above it, the
same heading is still found; if the heading line itself changes, search again.
Development
python -m pip install pytest
python -m pytest -c tests/pytest.ini tests
ORG_FILES_REAL=~/org python -m pytest -c tests/pytest.ini tests -k real_world -s
ORG_MODE_CHECKOUT=~/src/org-mode python -m pytest -c tests/pytest.ini tests -k orgs_own # Org's agenda tests
hermes plugins validate .
The tests build a GTD-style setup: per-file #+TODO keywords with fast-access keys, #+FILETAGS,
#+CATEGORY and CATEGORY properties, priorities, inherited tags, weekly, daily, monthly and yearly
repeaters, a warning cookie and a delay, a date range, appointments in headings, a done repeating
deadline, a COMMENT and an ARCHIVE subtree, and the look-alikes Org's agenda tests check are
ignored. A second file has CRLF line ends and accented text; Emacs lock and auto-save files sit next
to them.
ORG_FILES_REAL (one or more paths, separated like PATH) adds a test against real files: every
heading must read by its id and be found by a search for its own words, a year of agenda must build,
and no file may change. It was run against Org's own example files and manuals
(testing/examples/, doc/) and the Worg repository: 336 files, 5,642
headings, 7.5 MB.
ORG_MODE_CHECKOUT (a clone of Org mode)
adds a test that replays the cases of Org's test-org-agenda.el that use its example files
(scheduled-non-todo, non-scheduled-re-matches, property-timestamp, time-grid,
skip-scheduled-repeats-after-deadline) and expects the entries Org's assertions expect. It reads
those files in place; none is copied into this repository.
License
MIT
README from the reviewed commit 6411846; it updates when the author re-pins.

nftpoetrist