1.9 KiB
1.9 KiB
SKILL: Log Aggregator (Universal Literate Note)
- Overview
- Phase A: Demand (PRD)
- Phase B: Blueprint (PROTOCOL)
- Phase D: Build (Implementation)
- Registration
Overview
The Log Aggregator monitors and summarizes system logs to provide insights into agent behavior and system health.
Phase A: Demand (PRD)
1. Purpose
Collect and summarize agent logs.
2. User Needs
- Scan: Retrieve logs from the system.
- Summarize: Provide a high-level summary of recent activities.
Phase B: Blueprint (PROTOCOL)
1. Architectural Intent
Observability and log analysis system.
2. Semantic Interfaces
(defun log-scan (&optional (lines 100)) "Scan the last N lines of the log.")
(defun log-summarize (logs) "Neural or symbolic summary of LOGS.")
Phase D: Build (Implementation)
(defun log-scan (&optional (lines 100))
"Reads the last LINES lines of the system log file."
(let ((log-file (merge-pathnames "logs/agent.log" (uiop:getenv "SYSTEM_DIR"))))
(if (uiop:file-exists-p log-file)
(uiop:run-program `("tail" "-n" ,(write-to-string lines) ,(namestring log-file)) :output :string)
"Log file not found.")))
(defun log-summarize (logs)
"Symbolic summary of LOGS focusing on errors and warnings."
(let ((lines (uiop:split-string logs :separator '(#\Newline)))
(errors 0)
(warnings 0))
(dolist (line lines)
(cond
((cl-ppcre:scan "ERROR" line) (incf errors))
((cl-ppcre:scan "WARN" line) (incf warnings))))
(format nil "Log Summary: ~a errors, ~a warnings found in scan." errors warnings)))
Registration
(defskill :skill-log-aggregator
:priority 30
:trigger (lambda (context) nil)
:neuro (lambda (context) nil)
:symbolic (lambda (action context) action))