60 lines
1.6 KiB
Org Mode
60 lines
1.6 KiB
Org Mode
#+TITLE: SKILL: Hook Manager (Universal Literate Note)
|
|
#+ID: skill-hook-manager
|
|
#+STARTUP: content
|
|
#+FILETAGS: :hooks:event-driven:system:psf:
|
|
|
|
* 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)
|
|
:PROPERTIES:
|
|
:STATUS: FROZEN
|
|
:END:
|
|
|
|
** 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)
|
|
:PROPERTIES:
|
|
:STATUS: SIGNED
|
|
:END:
|
|
|
|
** 1. Architectural Intent
|
|
Event-driven extension system.
|
|
|
|
** 2. Semantic Interfaces
|
|
#+begin_src lisp
|
|
(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.")
|
|
#+end_src
|
|
|
|
* Phase D: Build (Implementation)
|
|
|
|
#+begin_src lisp :tangle ../projects/org-skill-hook-manager/src/hook-manager.lisp
|
|
(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))))
|
|
#+end_src
|
|
|
|
* Registration
|
|
#+begin_src lisp
|
|
(defskill :skill-hook-manager
|
|
:priority 100
|
|
:trigger (lambda (context) nil)
|
|
:neuro (lambda (context) nil)
|
|
:symbolic (lambda (action context) action))
|
|
#+end_src
|