refactor: Switch TUI/daemon communication from JSON to Lisp S-Expressions

This commit is contained in:
2026-04-17 13:36:54 -04:00
parent 47a2cf6478
commit 0debfe5a95
4 changed files with 30 additions and 20 deletions

View File

@@ -53,15 +53,20 @@ The OpenCortex TUI Client is a standalone Common Lisp executable providing a ric
(let ((line (read-line *stream* nil :eof)))
(if (eq line :eof)
(setf *is-running* nil)
(let ((json (ignore-errors (cl-json:decode-json-from-string line))))
(if json
(let* ((*read-eval* nil)
(sexp (ignore-errors (read-from-string line))))
(if (and sexp (listp sexp))
(cond
((string= (cdr (assoc :type json)) "status")
((eq (getf sexp :type) :status)
(setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]"
(cdr (assoc :scribe json))
(cdr (assoc :gardener json)))))
((string= (cdr (assoc :type json)) "chat")
(enqueue-msg (cdr (assoc :text json))))
(getf sexp :scribe)
(getf sexp :gardener))))
((eq (getf sexp :type) :chat)
(enqueue-msg (getf sexp :text)))
((eq (getf sexp :type) :info)
(enqueue-msg (format nil "*System*: ~a" (getf sexp :text))))
((eq (getf sexp :type) :error)
(enqueue-msg (format nil "*Error*: ~a" (getf sexp :text))))
(t (enqueue-msg line)))
(enqueue-msg line))))))
(error () (setf *is-running* nil)))