diff --git a/ellie.el b/ellie.el index 54a9dce..89fa7a5 100644 --- a/ellie.el +++ b/ellie.el @@ -90,18 +90,39 @@ An alist of (KEY . VALUE) string pairs; valid keys are ;;;; ──────────────── Paths ──────────────── (defun ellie--sessions-dir () - (expand-file-name "s" ellie-mount-directory)) + (expand-file-name "session" ellie-mount-directory)) (defun ellie--sessions-new-path () (expand-file-name "new" (ellie--sessions-dir))) +(defun ellie--agent-dir () + "Return the path to the active agent directory for the current session. +Discovers the agent ID by reading the agent/ subdirectory." + (unless ellie--session-id + (user-error "No active ollie session")) + (let* ((agent-parent (expand-file-name + "agent" + (expand-file-name ellie--session-id (ellie--sessions-dir)))) + (entries (and (file-directory-p agent-parent) + (directory-files agent-parent nil "\\`[^.]")))) + (expand-file-name + (or (seq-find (lambda (e) + (file-directory-p (expand-file-name e agent-parent))) + entries) + "0") + agent-parent))) + (defun ellie--session-file (name) - "Return the full path to file NAME inside the current session directory. + "Return the full path to file NAME for the current session. +Agent files (chat, prompt, cfg, ctl, etc.) resolve under the agent directory. +Session-level files (plan, env) resolve under the session directory. Signals `user-error' if no session is active." (unless ellie--session-id (user-error "No active ollie session")) - (expand-file-name name - (expand-file-name ellie--session-id (ellie--sessions-dir)))) + (if (member name '("plan" "env")) + (expand-file-name name + (expand-file-name ellie--session-id (ellie--sessions-dir))) + (expand-file-name name (ellie--agent-dir)))) (defun ellie--last-session-path () (expand-file-name "~/.config/ollie/last-session"))