screwlisp proposes kittens
#+TITLE: Lisp Tradition Intelligent Emacs Leonardo software-individual agents
#+AUTHOR: A very apologetically months late screwlisp.small-web.org
Thanks to Sacha and everyone at emacsconf, sorry I only submitted this several hours before emacsconf2025 convened!
I am https://screwlisp.small-web.org / Lispy Gopher Climate / https://gamerplus.org/@screwlisp
* «.Table of contents» (to "Talk")
** «.Using emacs as a human» TOC (to "Using emacs as a human")
*** «.using common lisp using emacs» (to "using common lisp using emacs")
**** «.jeremy_list's C base64encode included into embeddable common lisp» (to "jeremy_list's C base64encode included into embeddable common lisp")
***** «.embeddable common lisp» (to "embeddable common lisp")
***** «.Compile and load that into common lisp» (to "Compile and load that into common lisp")
***** «.higher level function.» (to "higher level function.")
**** «.decoding in emacs» (to "decoding in emacs")
**** «.Summary in org» (to "Summary in org")
*** «.using this via eev as a human» (to "using this via eev as a human")
** «.Software-individuals using eev in emacs like a human» (to "Software-individuals using eev in emacs like a human")
*** «.(some clos support in the appendix)» (to "(some clos support in the appendix)")
*** «.Start a loop for one leonardo software individual» (to "Start a loop for one leonardo software individual")
**** «.Agent 1: demus» (to "Agent 1: demus")
** «.Intelligence» (to "Intelligence")
*** «.Agents in 2025» (to "Agents in 2025")
** «.Appendix» (to "Appendix")
*** «.CLOS support for leonardo software individuals» (to "CLOS support for leonardo software individuals")
*** «.Software individual agents code blocks» (to "Software individual agents code blocks")
*** «.Setting up agent-1 in the leonardo system» (to "Setting up agent-1 in the leonardo system")
**** «.Agent leo file» (to "Agent leo file")
* «Talk» (to ".Table of contents")
** «Using emacs as a human» (to ".Using emacs as a human")
*** «using common lisp using emacs» (to ".using common lisp using emacs")
**** «jeremy_list's C base64encode included into embeddable common lisp» (to ".jeremy_list's C base64encode included into embeddable common lisp")
[[https://codeberg.org/jeremylist/habitat]]
Blog / Cxx version: [[https://screwlisp.small-web.org/fundamental/cxx-embeddable-common-lisp-habitat/]]
#+name: c-base64
#+HEADER: :eval never :output code
#+begin_src C
enum Variant {
STANDARD,
URL,
};
int
encode1(int byte, int variant)
{
if (byte <= 25) {
return byte + 'A';
} else if (byte <= 51) {
return byte - 26 + 'a';
} else if (byte <= 61) {
return byte - 52 + '0';
} else if (byte == 62) {
if (variant == STANDARD)
return '+';
else
return '-';
} else {
if (variant == STANDARD)
return '/';
else
return '_';
}
}
#+end_src
***** «embeddable common lisp» (to ".embeddable common lisp")
#+NAME: ecl-base64
#+HEADER: :noweb yes
#+HEADER: :tangle ~/ecl-base64.lisp
#+HEADER: :eval no
#+begin_src lisp
(ffi:clines "
<<c-base64>>
")
(ffi:defentry c-encode1
(:int :int)
(:int |encode1|))
#+end_src
***** «Compile and load that into common lisp» (to ".Compile and load that into common lisp")
#+HEADER: :cache yes
#+begin_src lisp :results file :file ecl-base64.fas
(compile-file "~/ecl-base64.lisp")
#+end_src
#+RESULTS[6355d5322a15353fb9cb710d1820860c75f6d5e3]:
[[file:ecl-base64.fas]]
and
#+HEADER: :cache yes
#+begin_src lisp
(load "~/ecl-base64.fas")
#+end_src
#+RESULTS[757ab418d166abee822cd0845ef25059059bcce7]:
: #P"/home/j86585o3/ecl-base64.fas"
***** «higher level function.» (to ".higher level function.")
#+begin_src lisp
(defun b64encode (bytes &optional (variant 0))
(loop
:with mask6 := #b111111
:for n :from 0 :by 4
:for byte-1 :in bytes :by #'cdddr
:for byte-2 :in (cdr bytes) :by #'cdddr ; I forgot this cdr
:for byte-3 :in (cddr bytes) :by #'cdddr ; and cddr originally here.
:for result-1
:= (c-encode1 (ash byte-1 -2) variant)
:for partial-1
:= (logand (ash byte-1 4)
mask6)
:for result-2
:= (c-encode1 (logior partial-1
(ash byte-2 -4))
variant)
:for partial-2
:= (logand (ash byte-2 2)
mask6)
:for result-3
:= (c-encode1 (logior (ash byte-3 -6)
partial-2)
variant)
:for result-4
:= (c-encode1 (logand byte-3 mask6)
variant)
:nconcing
(list
result-1 result-2 result-3 result-4)
:into b64s
:finally
(return
(coerce
(mapcar 'code-char b64s)
'string))))
#+end_src
#+RESULTS:
: B64ENCODE
****** Calls that.
#+NAME: cl-b64
#+HEADER: :var string="a default"
#+begin_src lisp
(b64encode (mapcar 'char-code (coerce string 'list)))
#+end_src
**** «decoding in emacs» (to ".decoding in emacs")
#+NAME: e-b64-decode
#+HEADER: :var string="YSBkZWZhdWx0"
#+begin_src elisp
(base64-decode-string string)
#+end_src
#+RESULTS: e-b64-decode
: a default
**** «Summary in org» (to ".Summary in org")
#+NAME:call-b64
#+HEADER: :cache yes
#+CALL: cl-b64(string="hello there!")
#+RESULTS: call-b64
: aGVsbG8gdGhlcmUh
#+CALL: e-b64-decode(string=call-b64())
#+RESULTS:
: hello there!
*** «using this via eev as a human» (to ".using this via eev as a human")
#+begin_src eev
(setq eepitch-buffer-name "*slime-repl ECL*")
"foo bar baZ!"
(coerce * 'list)
(mapcar 'char-code *)
(b64encode *)
`(base64-decode-string ,*)
(swank:eval-in-emacs *)
"foo bar baZ!"
#+end_src
** «Software-individuals using eev in emacs like a human» (to ".Software-individuals using eev in emacs like a human")
Blog: https://screwlisp.small-web.org/software-individuals/trivial-program-that-never-stops/
*** «(some clos support in the appendix)» (to ".(some clos support in the appendix)")
(to "CLOS support for leonardo software individuals")
#+HEADER: :results none
#+HEADER: :cache yes
#+CALL: clos-for-leonardo()
#+RESULTS:
: *AGENT*
*** Sandewall's leonardo system
#+begin_src eev
• (setq inferior-lisp-program "clisp -E iso-8859-1 -modern")
• (slime)
• (setq eepitch-buffer-name "*slime-repl clisp*")
• (eepitch-shell)
cd
git clone https://codeberg.org/tfw/pawn-75
mkdir -p leocommunity
cp -r Pawn-75/Pawn-75 leocommunity/saturn
• (setq eepitch-buffer-name "*slime-repl clisp*")
(uiop:chdir "~/leocommunity/saturn/demus/Process/main/")
(load #P"../../../remus/Startup/cl/acleo.leos")
(cle)
need to have emacsconf knowledgebase
loadk emacsconf-kb
(get emacsconf-kb contents)
loadk agent-1
#+end_src
*** «Start a loop for one leonardo software individual» (to ".Start a loop for one leonardo software individual")
#+begin_src lisp :eval yes :export code
#|
• (setq eepitch-buffer-name "*slime-repl ECL*")
• (setq *unique-leonardo-queue* '(("[show hello]")))
(server-start)
|#
(loop :with agent = *agent*
:for action-list :=
(swank:eval-in-emacs '(pop *unique-leonardo-queue*))
:when action-list :do
(print action-list)
(case (car action-list)
(:exit (return))
(:change (psetf (agent agent)
(get (cdr action-list) :agent)
(indiv-path agent)
(get (cdr action-list) :indiv-path)
(repl-name agent)
(get (cdr action-list) :repl-name)))
(t (emacsclient-pitch agent action-list)))
(sleep 30))
#+end_src
**** «Agent 1: demus» (to ".Agent 1: demus")
EDIT: I forgot to put *(ok-record)* at the end of the b64 actions, which soact checked and got upset about but the repl shrugs off.
#+begin_src elisp
(setq *unique-leonardo-queue*
'(("[show agent-1]")
("[put message-1 original \"foo bar baz!\" ]")
("[show (get message-1 original)]")
("[b64-encode message-1]")
("[show (get message-1 encoded)]")
("[b64-decode message-1]")
("[show (get message-1 decoded)]")))
#+end_src
#+RESULTS:
| [show agent-1] | [next-action] |
1. [show agent-1] [next-action]
2. [put message-1 original "the-message!"] [next-action]
3. [b64-encode message-1] [next-action]
4. [show (get message-1 encoded)] [next-action]
5. [b64-decode message-1] [next-action]
6. [show (get message-1 decoded)] [next-action]
7. [show "Next action would be the usual beliefs/desires/intents algorithm"]
** «Intelligence» (to ".Intelligence")
- nosrednA yduJ
- Erik Sandewall
*** «Agents in 2025» (to ".Agents in 2025")
- pizzapal
- Microsoft
** «Appendix» (to ".Appendix")
*** «CLOS support for leonardo software individuals» (to ".CLOS support for leonardo software individuals")
(to "(some clos support in the appendix)")
#+name:clos-for-leonardo
#+begin_src lisp
(defclass leonardo-companion ()
((agent :initarg :agent
:accessor agent)
(repl-name :initarg :repl-name
:accessor repl-name)
(indiv-path :initarg :indiv-path
:accessor indiv-path)))
(defmethod emacsclient-pitch ((obj leonardo-companion)
soact-strings
&key (long-wait 1))
(uiop:run-program
(let ((*print-pretty* nil) (*print-case* :downcase))
(format nil "emacsclient -e '(progn ~@{~s~^ ~})'"
`(setq eepitch-buffer-name ,(repl-name obj))
`(sleep-for ,long-wait)
`(eepitch-line
,(format nil ".(uiop:chdir ~s)"
(indiv-path obj)))
`(sleep-for ,long-wait)
`(eepitch-line
,(format nil "~
.(setf (get *my-id* `leoname) `~a~
(get *my-id* `self-location) "../../../~a/")"
(agent obj) (agent obj)))
`(sleep-for ,long-wait)
`(eepitch-line ".(load-ef `kb-catal)")
`(sleep-for ,long-wait)
`(eepitch-line ,(format nil "soact ~{~a~^ ~}"
soact-strings))
`(sleep-for ,long-wait)))
:wait nil))
(defparameter *agent*
(make-instance 'leonardo-companion
:agent "demus"
:repl-name "*slime-repl clisp*"
:indiv-path "~/leocommunity/saturn/demus/Process/main/"))
#+end_src
*** «Setting up agent-1 in the leonardo system» (to ".Setting up agent-1 in the leonardo system")
#+BEGIN_EXAMPLE
cs-user> (cle)
Starting or resuming interaction using the CLE command-loop
,****************************************************************************
ses.001) crek emacsconf-kb
Load-ef: kb-catal at Defblock/kb-catal.leo
;; Loading file ../../../remus/Process/main/Defblock/cl/kb-catal.leos ...
;; Loaded file ../../../remus/Process/main/Defblock/cl/kb-catal.leos
writeloc-file-leo: Defblock/kb-catal.leo
writeloc-file-leos: Defblock/cl/kb-catal.leos
writeloc-file-leo: ../../../demus/Emacsconf/emacsconf-kb.leo
writeloc-file-leos: ../../../demus/Emacsconf/cl/emacsconf-kb.leos
ses.002) loadk emacsconf-kb
Load-ef: emacsconf-kb at ../../../demus/Emacsconf/emacsconf-kb.leo
ses.003) setk emacsconf-kb
Done
ses.004) crefil agent-1
Load-ef: emacsconf-kb at ../../../demus/Emacsconf/emacsconf-kb.leo
writeloc-file-leo: ../../../demus/Emacsconf/emacsconf-kb.leo
writeloc-file-leos: ../../../demus/Emacsconf/cl/emacsconf-kb.leos
writeloc-file-leo: ../../../demus/Emacsconf/agent-1.leo
agent-1
ses.005) loadk agent-1
Load-ef: agent-1 at ../../../demus/Emacsconf/agent-1.leo
ses.006) put next-action type lispdef
put: next-action type lispdef
ses.007) addmember (get agent-1 contents) next-action
ses.008) put b64-encode type lispdef
put: b64-encode type lispdef
ses.009) put b64-decode type lispdef
put: b64-decode type lispdef
ses.010) put message type thingtype
put: message type thingtype
ses.011) put message attributes <original encoded decoded>
put: message attributes <original encoded decoded>
ses.012) put agent-1 contents (concat agent-1 contents) <b64-encode b64-decode message message-1>
actionlux-err: #<simple-type-error #x00001000007B4AA1>
Command execution failed on the Leonardo level
Reason:
cadr: agent-1 is not a list
ses.013) put agent-1 contents (concat (get agent-1 contents) <b64-encode b64-decode message message-1>)
put: agent-1 contents <agent-1 next-action b64-encode b64-decode message message-1>
ses.014) put message-1 type message
put: message-1 type message
ses.015) writefil agent-1
writeloc-file-leo: ../../../demus/Emacsconf/agent-1.leo
ses.016) loadk agent-1
Load-ef: agent-1 at ../../../demus/Emacsconf/agent-1.leo
ses.017) (get agent-1 contents)
=> <agent-1 next-action b64-encode b64-decode message message-1>
ses.018)
#+END_EXAMPLE
**** «Agent leo file» (to ".Agent leo file")
#+BEGIN_EXAMPLE
[: type entityfile]
[: latest-written "2025-12-04/21:06.+12"]
[: contents <agent-1 next-action b64-encode b64-decode message message-1>]
[: changed-since-archived t]
[: nullvalued {has-purpose has-author requires mustload removed-entities leos-extension has-profile overlay-on overlay-types overlay-own leos-use dont-display sections local-ents purpose author latest-archived-entity latest-rearchived}]
[: type lispdef]
[: latest-rearchived nil]
(leodef next-action next-action ()
(let ((next (pop *emacs-actions*)))
(when next
(swank:eval-in-emacs
`(push ,next *unique-leonardo-queue*)))))
[: type lispdef]
[: latest-rearchived nil]
(leodef b64-encode b64-encode (sym)
(progn (setf (get sym 'encoded)
(swank:eval-in-emacs
`(base64-encode-string ,(get sym 'original))))
(ok-record)))
[: type lispdef]
[: latest-rearchived nil]
(leodef b64-decode b64-decode (sym)
(progn (setf (get sym 'decoded)
(swank:eval-in-emacs
`(base64-decode-string ,(get sym 'encoded))))
(ok-record)))
[: type thingtype]
[: attributes <original encoded decoded>]
[: nullvalued {description subsumed-by has-attributes has-categories create-proc registr-proc latest-rearchived}]
[: type message]
[: nullvalued {original encoded decoded latest-rearchived}]
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
#+END_EXAMPLE
screwlisp proposes kittens