Files
memex/notes/org-skill-hook-manager.org

1.6 KiB

SKILL: Hook Manager (Universal Literate Note)

Overview

The Hook Manager enables event-driven extensibility within the agent by allowing functions to be registered and executed at specific lifecycle points.

Phase A: Demand (PRD)

1. Purpose

Provide a hook-based event system.

2. User Needs

  • Registration: Register functions to be called on specific hooks.
  • Execution: Trigger all registered functions for a given hook.

Phase B: Blueprint (PROTOCOL)

1. Architectural Intent

Event-driven extension system.

2. Semantic Interfaces

(defun register-hook (hook-name fn) "Register FN on HOOK-NAME.")
(defun run-hooks (hook-name &rest args) "Run all functions on HOOK-NAME with ARGS.")

Phase D: Build (Implementation)

(defvar *hooks* (make-hash-table :test 'equal))

(defun register-hook (hook-name fn)
  "Registers a function FN for the given HOOK-NAME."
  (pushnew fn (gethash hook-name *hooks*))
  (kernel-log "HOOK - Registered function for ~a" hook-name))

(defun run-hooks (hook-name &rest args)
  "Executes all registered functions for HOOK-NAME with ARGS."
  (let ((fns (gethash hook-name *hooks*)))
    (dolist (fn fns)
      (apply fn args))))

Registration

(defskill :skill-hook-manager
  :priority 100
  :trigger (lambda (context) nil)
  :neuro (lambda (context) nil)
  :symbolic (lambda (action context) action))