fix(tui): use uiop:getenv for portability

This commit is contained in:
2026-04-28 17:40:29 -04:00
parent 6d3cfc7bdc
commit 545068e3c8

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+PROPERTY: header-args:lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
:PROPERTIES: :PROPERTIES:
:ID: tui-client-spec :ID: tui-client-spec
:CREATED: [2026-04-17 Fri 11:00] :CREATED: [2026-04-17 Fri 11:00]
@@ -57,81 +57,81 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
* Phase C: Implementation (Build) * Phase C: Implementation (Build)
** Package Context ** Package Context
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(in-package :cl-user) (in-package :cl-user)
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defpackage :opencortex.tui (defpackage :opencortex.tui
(:use :cl :croatoan) (:use :cl :croatoan)
(:export :main)) (:export :main))
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(in-package :opencortex.tui) (in-package :opencortex.tui)
#+end_src #+end_src
** Global State ** Global State
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *daemon-host* "127.0.0.1") (defvar *daemon-host* "127.0.0.1")
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *daemon-port* 9105) (defvar *daemon-port* 9105)
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *socket* nil) (defvar *socket* nil)
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *stream* nil) (defvar *stream* nil)
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *chat-history* (list) "Full chronological log of messages.") (defvar *chat-history* (list) "Full chronological log of messages.")
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *scroll-index* 0 "Offset for history rendering.") (defvar *scroll-index* 0 "Offset for history rendering.")
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *status-text* "Connecting...") (defvar *status-text* "Connecting...")
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *input-buffer* (make-array 0 :element-type 'char :fill-pointer 0 :adjustable t)) (defvar *input-buffer* (make-array 0 :element-type 'char :fill-pointer 0 :adjustable t))
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *command-history* (make-array 0 :element-type 't :fill-pointer 0 :adjustable t)) (defvar *command-history* (make-array 0 :element-type 't :fill-pointer 0 :adjustable t))
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *history-index* -1) (defvar *history-index* -1)
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *is-running* t) (defvar *is-running* t)
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *queue-lock* (bt:make-lock)) (defvar *queue-lock* (bt:make-lock))
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defvar *incoming-msgs* nil) (defvar *incoming-msgs* nil)
#+end_src #+end_src
** Utilities ** Utilities
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defun enqueue-msg (msg) (defun enqueue-msg (msg)
"Thread-safe addition to incoming message queue." "Thread-safe addition to incoming message queue."
(bt:with-lock-held (*queue-lock*) (bt:with-lock-held (*queue-lock*)
(setf *incoming-msgs* (append *incoming-msgs* (list msg))))) (setf *incoming-msgs* (append *incoming-msgs* (list msg)))))
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defun dequeue-msgs () (defun dequeue-msgs ()
"Thread-safe retrieval of incoming messages." "Thread-safe retrieval of incoming messages."
(bt:with-lock-held (*queue-lock*) (bt:with-lock-held (*queue-lock*)
@@ -142,7 +142,7 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
#+end_src #+end_src
** Styling Engine ** Styling Engine
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defun get-line-style (text) (defun get-line-style (text)
"Determines croatoan attributes based on content patterns." "Determines croatoan attributes based on content patterns."
(cond (cond
@@ -154,7 +154,7 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
#+end_src #+end_src
** Rendering Orchestrator ** Rendering Orchestrator
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defun render-chat (win) (defun render-chat (win)
"Renders the chat history with scrolling and styling." "Renders the chat history with scrolling and styling."
(clear win) (clear win)
@@ -172,14 +172,14 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
#+end_src #+end_src
** Input Handling ** Input Handling
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defun handle-backspace () (defun handle-backspace ()
"Deletes last character from input buffer." "Deletes last character from input buffer."
(when (> (fill-pointer *input-buffer*) 0) (when (> (fill-pointer *input-buffer*) 0)
(decf (fill-pointer *input-buffer*)))) (decf (fill-pointer *input-buffer*))))
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defun handle-return (stream) (defun handle-return (stream)
"Process input buffer as message or command." "Process input buffer as message or command."
(let ((cmd (coerce *input-buffer* 'string))) (let ((cmd (coerce *input-buffer* 'string)))
@@ -200,7 +200,7 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
#+end_src #+end_src
** Main Entry Point ** Main Entry Point
#+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (getenv "INSTALL_DIR") ".") "/harness")) #+begin_src lisp :tangle (expand-file-name "tui-client.lisp" (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness"))
(defun main () (defun main ()
"Initializes ncurses and starts the TUI event loop." "Initializes ncurses and starts the TUI event loop."
(handler-case (handler-case