From 2e52bc4d139b4dcb31e27fa850976890d187eabb Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Fri, 8 May 2026 18:22:22 -0400 Subject: [PATCH] =?UTF-8?q?v0.7.2:=20context=20visibility=20(/context)=20?= =?UTF-8?q?=E2=80=94=20TDD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /context shows message count, focus, token estimate, and last 5 message summaries. Inline command, no daemon interaction needed. - channel-tui-main: /context handler, 1 test - Fixed /tags handler (removed dangling else clause) - TUI Main: 84/85 (1 pre-existing core flake) --- lisp/channel-tui-main.lisp | 30 ++++++++++++++++++++++++------ org/channel-tui-main.org | 30 ++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 12 deletions(-) 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")