diff --git a/lisp/channel-tui-main.lisp b/lisp/channel-tui-main.lisp index 5112dca..f66b166 100644 --- a/lisp/channel-tui-main.lisp +++ b/lisp/channel-tui-main.lisp @@ -161,13 +161,31 @@ (add-msg :system (format nil "Node ~a not found" node-id)))) (add-msg :system "Memory audit not available"))) ;; /tags command — tag stack + ;; /tags command — tag stack ((string-equal text "/tags") - (let ((cats (or passepartout::*tag-categories* nil))) - (if cats - (dolist (entry cats) - (add-msg :system (format nil "~a: ~a" (car entry) (cdr entry)))) - (add-msg :system "No tags configured. Set TAG_CATEGORIES env var."))) - (add-msg :system "Tag categories not loaded"))) + (let ((cats passepartout::*tag-categories*)) + (if cats + (dolist (entry cats) + (add-msg :system (format nil "~a: ~a" (car entry) (cdr entry)))) + (add-msg :system "No tags configured. Set TAG_CATEGORIES env var.")))) + ;; /context command — context visibility + ((string-equal text "/context") + (let* ((msg-count (length (st :messages))) + (focus (or (st :foveal-id) "none")) + (est-tokens (min 8192 (* msg-count 50)))) + (add-msg :system (format nil "Context: ~d msgs, focus=~a, est ~d/8192 tokens" + msg-count focus est-tokens)) + (let ((start (max 0 (- msg-count 5)))) + (loop for i from start below msg-count + for m = (aref (st :messages) i) + for content = (getf m :content) + for preview = (if (> (length content) 50) + (concatenate 'string (subseq content 0 47) "...") + content) + for role = (getf m :role) + do (add-msg :system (format nil " ~a: ~a" + (case role (:user "You") (:agent "Agent") (t "Sys")) + preview)))))) ((string-equal text "/help") (add-msg :system "/focus Set project context") diff --git a/org/channel-tui-main.org b/org/channel-tui-main.org index 2ae4d07..152c218 100644 --- a/org/channel-tui-main.org +++ b/org/channel-tui-main.org @@ -195,13 +195,31 @@ Event handlers + daemon I/O + main loop. (add-msg :system (format nil "Node ~a not found" node-id)))) (add-msg :system "Memory audit not available"))) ;; /tags command — tag stack + ;; /tags command — tag stack ((string-equal text "/tags") - (let ((cats (or passepartout::*tag-categories* nil))) - (if cats - (dolist (entry cats) - (add-msg :system (format nil "~a: ~a" (car entry) (cdr entry)))) - (add-msg :system "No tags configured. Set TAG_CATEGORIES env var."))) - (add-msg :system "Tag categories not loaded"))) + (let ((cats passepartout::*tag-categories*)) + (if cats + (dolist (entry cats) + (add-msg :system (format nil "~a: ~a" (car entry) (cdr entry)))) + (add-msg :system "No tags configured. Set TAG_CATEGORIES env var.")))) + ;; /context command — context visibility + ((string-equal text "/context") + (let* ((msg-count (length (st :messages))) + (focus (or (st :foveal-id) "none")) + (est-tokens (min 8192 (* msg-count 50)))) + (add-msg :system (format nil "Context: ~d msgs, focus=~a, est ~d/8192 tokens" + msg-count focus est-tokens)) + (let ((start (max 0 (- msg-count 5)))) + (loop for i from start below msg-count + for m = (aref (st :messages) i) + for content = (getf m :content) + for preview = (if (> (length content) 50) + (concatenate 'string (subseq content 0 47) "...") + content) + for role = (getf m :role) + do (add-msg :system (format nil " ~a: ~a" + (case role (:user "You") (:agent "Agent") (t "Sys")) + preview)))))) ((string-equal text "/help") (add-msg :system "/focus Set project context")