Files
memex/system/skills/org-skill-environment-config.org

2.5 KiB

SKILL: Environment Config Agent (Homoiconic Configuration)

Overview

The Environment Config Agent implements the "Homoiconic Configuration" pattern for the Memex. It provides a centralized API for retrieving system settings directly from Org-mode properties, ensuring that the user's environment is defined and managed within their own notes rather than opaque dotfiles.

The Configuration Mandate

  1. Single Source of Truth: All system configuration should be discoverable within the Memex notes.
  2. Centralization: Provide a unified interface for other skills to query global state.
  3. Hierarchy: Support tiered model selection (Fast vs. Powerful) based on user-defined properties.

Symbolic Implementation (The Logic)

The implementation focuses on high-performance hash-map lookups against the global object store.

Architectural Intent: Attribute Retrieval

This function scans the headline properties across the entire Memex to find specific configuration keys, enabling a truly decentralized yet queryable state.

(defun get-config-attribute (property-key &optional default)
  "Searches the global *object-store* for any headline containing PROPERTY-KEY."
  (let ((store org-agent:*object-store*))
    (maphash (lambda (id obj)
               (declare (ignore id))
               (when (eq (org-agent:org-object-type obj) :HEADLINE)
                 (let ((val (getf (org-agent:org-object-attributes obj) property-key)))
                   (when val
                     (return-from get-config-attribute val)))))
             store)
    default))

Architectural Intent: Tiered Model Selection

Abstracts the complexity of model selection by allowing other skills to request a "Tier" (e.g., :POWERFUL) which is then resolved to a specific model ID based on the user's environment.

(defun get-tiered-model (tier default-model)
  "Retrieves a model ID based on a tier keyword (:POWERFUL, :FAST, :FREE)."
  (let ((prop (case tier
                (:powerful :LLM_MODEL_POWERFUL)
                (:fast     :LLM_MODEL_FAST)
                (:free     :LLM_MODEL_FREE)
                (t         :LLM_MODEL_TEXT))))
    (get-config-attribute prop default-model)))

Registration

(defskill :skill-environment-config
  :priority 100 ; Foundational skill
  :trigger (lambda (context) nil) ; No cognitive trigger
  :neuro (lambda (context) nil)
  :symbolic (lambda (action context) action))