3.5 KiB
3.5 KiB
SKILL: Autonomous Groomer Agent (Universal Literate Note)
- Overview
- Phase A: Demand (PRD)
- Phase B: Blueprint (PROTOCOL)
- Phase D: Build (Implementation)
- Registration
Overview
The Groomer Agent is the system's "Immune System" for code and notes. It autonomously audits the PSF ecosystem for technical debt, duplication, and architectural drift, proposing surgical refactors to maintain the "Minimalist Core" mandate.
Phase A: Demand (PRD)
1. Purpose
Enforce zero-bloat and high-maintainability standards across the PSF.
2. User Needs
- Debt Detection: Identify duplicate Lisp logic or redundant Org headlines.
- Autonomous Refactoring: Propose surgical code changes to simplify implementation.
- Verification: Ensure refactors do not break functionality (via TDD Runner).
- Note Grooming: Consolidate fragmented atomic notes into coherent structures.
Phase B: Blueprint (PROTOCOL)
1. Architectural Intent
Interfaces for codebase auditing and symbolic refactoring.
2. Semantic Interfaces
(defun audit-skill-logic (skill-name)
"Neural audit of a skill's Lisp blocks for complexity.")
(defun propose-refactor (skill-name)
"Drafts a 'Phase D' update for a skill to simplify its logic.")
Phase D: Build (Implementation)
Audit & Refactoring Logic
(defun audit-skill-logic (skill-name)
"Retrieves skill source and asks Neuro for a 'Complexity Report'."
(let ((source (org-agent:context-get-skill-source skill-name)))
(if source
(org-agent:ask-neuro
(format nil "Audit this skill logic for technical debt and duplication: ~a" source)
:system-prompt "You are a PSF Senior Architect. Identify bloat and propose a MINIMAL refactor.")
(format nil "Skill ~a not found." skill-name))))
(defun audit-kernel-logic ()
"Performs a recursive self-audit of the core org-agent kernel files."
(let* ((kernel-files '("package.lisp" "protocol.lisp" "object-store.lisp" "embedding.lisp" "skills.lisp" "neuro.lisp" "symbolic.lisp" "core.lisp"))
(src-dir (asdf:system-source-directory :org-agent))
(full-report ""))
(dolist (file kernel-files)
(let* ((path (merge-pathnames (format nil "src/~a" file) src-dir))
(content (when (uiop:file-exists-p path) (uiop:read-file-string path))))
(when content
(setf full-report
(concatenate 'string full-report
(format nil "--- FILE: ~a ---~%~a~%~%" file
(org-agent:ask-neuro
(format nil "Audit this kernel file for technical debt: ~a" content)
:system-prompt "You are the Sovereign Architect. Identify critical bottlenecks and logic duplication.")))))))
full-report))
(defun propose-refactor (target type)
"Drafts a surgical refactor proposal. TARGET can be a skill name or a kernel file."
(org-agent:ask-neuro
(format nil "Draft a surgical refactor for ~a (~a). Focus on the 'Minimalist Core' mandate." target type)
:system-prompt "You are a PSF Senior Architect. Provide the refactored code in a Lisp block."))
Registration
(defskill :skill-groomer
:priority 50
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :grooming-cycle))
:neuro #'audit-skill-logic
:symbolic (lambda (action context) action))