Files
memex/notes/skill-chat.org

1.9 KiB

Agent Chat Skill

This skill provides a conversational interface within Emacs via the `*org-agent-chat*` buffer.

Trigger

Triggers on direct chat messages from Emacs.

(defun trigger-skill-chat (context)
  (let* ((payload (getf context :payload))
         (sensor (getf payload :sensor)))
    (eq sensor :chat-message)))

Neuro Prompt

System 1 acts as a conversational partner, using the agent's identity and persona.

(defun neuro-skill-chat (context)
  (let* ((payload (getf context :payload))
         (text (getf payload :text))
         (identity-pkg (find-package :org-agent.skills.skill-agent-identity))
         (persona-fn (when identity-pkg (find-symbol "GET-AGENT-PERSONA" identity-pkg)))
         (persona (if (and persona-fn (fboundp persona-fn))
                      (funcall persona-fn)
                      "You are a helpful Lisp agent.")))
    (format nil "
      ~a
      
      The user is talking to you in a dedicated chat buffer.
      CHAT HISTORY / CURRENT BUFFER -
      ---
      ~a
      ---
      
      Provide a helpful, conversational response in Org-mode format.
      Return a Lisp plist - (:target :emacs :action :insert-at-end :buffer \"*org-agent-chat*\" :text \"\\n** Agent\\n<your response>\\n\")
    " persona text)))

Symbolic Verification

(defun verify-skill-chat (proposed-action context)
  "Ensure the chat response is properly targeted."
  (if (and (eq (getf proposed-action :target) :emacs)
           (eq (getf (getf proposed-action :payload) :action) :insert-at-end))
      proposed-action
      '(:target :emacs :action :message :text "Chat skill failed to format response correctly.")))

Registration

(defskill :skill-chat
  :priority 100 ; Chat is high-priority direct interaction
  :trigger #'trigger-skill-chat
  :neuro #'neuro-skill-chat
  :symbolic #'verify-skill-chat)