(in-package :opencortex) (defun context-get-active-projects () "Retrieves a list of project headlines currently marked as NEXT or in progress." (let ((all-projects (list-objects-with-attribute :CATEGORY "Project"))) (loop for p in all-projects collect (list :id (org-object-id p) :title (getf (org-object-attributes p) :TITLE))))) (defun context-get-recent-completed-tasks (&optional (limit 5)) "Retrieves the last N tasks marked as DONE from the memory history." (let ((all-completed (list-objects-with-attribute :TODO "DONE"))) (subseq (sort all-completed #'> :key #'org-object-version) 0 (min limit (length all-completed))))) (defun context-list-all-skills () "Returns a list of registered skills and their documentation." (let ((results nil)) (maphash (lambda (id skill) (push (list :id id :name (skill-name skill)) results)) *skills-registry*) results)) (defun context-get-system-logs () "Retrieves the in-memory circular log buffer." (bt:with-lock-held (*logs-lock*) (format nil "~{~a~%~}" (reverse *system-logs*)))) (defun context-assemble-global-awareness () "Assembles the full context block for a neural request." (let ((projects (context-get-active-projects)) (time (multiple-value-bind (s m h d mo y) (get-decoded-time) (format nil "~a-~a-~a ~a:~a:~a" y mo d h m s)))) (format nil "CURRENT_TIME: ~a. ACTIVE_PROJECTS: ~s. FOVEAL_FOCUS: ~a" time projects (or *foveal-focus-id* "None")))) (defun context-query-store (query &key (limit 5)) "Placeholder for semantic/vector search over the Memex." (declare (ignore query limit)) nil)