Files
memex/notes/skill-atomic-notes.org

2.3 KiB

#+TITLE - Atomic Notes (Zettelkasten) Retrieval Skill (Sparse Tree) #+AUTHOR - org-agent #+SKILL_NAME - skill-atomic-notes

This skill provides Deep Memory by performing sparse tree perception over ripgrep results. It reduces token waste by pruning irrelevant parts of the AST.

Trigger

(defun trigger-skill-atomic-notes (context)
  (let ((type (getf context :type))
        (payload (getf context :payload)))
    (and (eq type :EVENT)
         (eq (getf payload :sensor) :delegation)
         (eq (getf payload :target-skill) :atomic-notes))))

Neuro Prompt

System 1 synthesizes an answer from a pruned, highly relevant Sparse AST.

(defun neuro-skill-atomic-notes (context)
  (let* ((query (getf (getf context :payload) :query))
         (memex-dir (org-agent::get-env "MEMEX_DIR" "/app/memex"))
         ;; Search for files containing the query
         (rg-cmd (format nil "rg -i -l '~a' ~a" query memex-dir))
         (files (ignore-errors 
                 (uiop:split-string 
                  (uiop:run-program rg-cmd :output :string :ignore-error-status t)
                  :separator '(#\Newline)))))
    
    ;; For the first 3 relevant files, build a Sparse Tree
    (let ((sparse-trees nil))
      (dolist (file (subseq files 0 (min 3 (length files))))
        (when (and file (> (length file) 0))
          ;; In a real Phase 3, we would look up the AST from the store.
          ;; For this prototype, we'll note the file being indexed.
          (push (format nil "FILE - ~a" file) sparse-trees)))
      
      (format nil "
        You are the Atomic Notes (Zettelkasten) Memory synthesizer.
        The user asked - '~a'
        
        SPARSE PERCEPTION (Relevant Files) -
        ~a
        
        Synthesize an answer. If you need more detail from a specific file, 
        ask the user to 'Focus' on that file.
        Return a Lisp plist - (:target :emacs :action :message :text \"your answer\")
      " query sparse-trees))))

Symbolic Verification

(defun verify-skill-atomic-notes (proposed-action context)
  proposed-action)

Registration

(defskill :skill-atomic-notes
  :priority 80
  :trigger #'trigger-skill-atomic-notes
  :neuro #'neuro-skill-atomic-notes
  :symbolic #'verify-skill-atomic-notes)