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

2.0 KiB

SKILL: Context Manager (Universal Literate Note)

Overview

The Context Manager handles the cognitive stack of the agent, allowing for switching between different projects, areas, and tasks while maintaining a clean environment.

Phase A: Demand (PRD)

1. Purpose

Manage a stack-based context system for the agent.

2. User Needs

  • Push/Pop: Ability to enter and exit specific project contexts.
  • Path Resolution: Resolve relative paths based on the current context.

Phase B: Blueprint (PROTOCOL)

1. Architectural Intent

Stack-based context management.

2. Semantic Interfaces

(defun context-push (new-context) "Push a new context onto the stack.")
(defun context-pop () "Pop the current context.")
(defun context-resolve-path (path) "Resolve a path based on current context.")

Phase D: Build (Implementation)

(defvar *context-stack* nil)

(defun context-push (new-context)
  "Push a new context (usually a path or a plist) onto the stack."
  (push new-context *context-stack*)
  (kernel-log "CONTEXT - Pushed: ~a" new-context))

(defun context-pop ()
  "Pop the top context from the stack."
  (let ((old (pop *context-stack*)))
    (kernel-log "CONTEXT - Popped: ~a" old)
    old))

(defun context-resolve-path (path)
  "Resolve PATH relative to the current context if it's a directory, otherwise return as is."
  (let ((current (car *context-stack*)))
    (if (and current (stringp current) (uiop:directory-pathname-p current))
        (merge-pathnames path current)
        path)))

Registration

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