fix(chaos): use standard getenv for absolute tangle paths

This commit is contained in:
2026-04-28 17:57:57 -04:00
parent d787981d0d
commit d55384fb65
35 changed files with 234 additions and 234 deletions

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/act.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/act.lisp" (expand-file-name ""))
#+TITLE: Stage 3: Act (act.lisp) #+TITLE: Stage 3: Act (act.lisp)
#+AUTHOR: Amr #+AUTHOR: Amr
#+FILETAGS: :harness:act: #+FILETAGS: :harness:act:
@@ -70,8 +70,8 @@ Example feedback chain:
3. :tui - Terminal UI output via reply stream" 3. :tui - Terminal UI output via reply stream"
;; Load environment configuration ;; Load environment configuration
(let ((def (uiop:getenv "DEFAULT_ACTUATOR")) (let ((def (getenv "DEFAULT_ACTUATOR"))
(silent (uiop:getenv "SILENT_ACTUATORS"))) (silent (getenv "SILENT_ACTUATORS")))
;; Set default actuator ;; Set default actuator
(when def (when def
@@ -393,7 +393,7 @@ Example feedback chain:
These tests verify the Act pipeline. Run with: These tests verify the Act pipeline. Run with:
~(fiveam:run! 'pipeline-act-suite)~ ~(fiveam:run! 'pipeline-act-suite)~
#+begin_src lisp :tangle (expand-file-name "pipeline-act-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "pipeline-act-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-pipeline-act-tests (defpackage :opencortex-pipeline-act-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:pipeline-act-suite)) (:export #:pipeline-act-suite))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/communication.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/communication.lisp" (expand-file-name ""))
#+TITLE: Communication Protocol (communication.lisp) #+TITLE: Communication Protocol (communication.lisp)
#+AUTHOR: Amr #+AUTHOR: Amr
#+FILETAGS: :harness:protocol: #+FILETAGS: :harness:protocol:
@@ -79,7 +79,7 @@ The ~communication.lisp~ module defines the low-level transport and framing logi
** Structural Validation (communication-validator.lisp) ** Structural Validation (communication-validator.lisp)
The validator ensures that incoming messages adhere to the strict property list schema of the communication protocol. The validator ensures that incoming messages adhere to the strict property list schema of the communication protocol.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/communication-validator.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/communication-validator.lisp" (expand-file-name ""))
(in-package :opencortex) (in-package :opencortex)
(defun validate-communication-protocol-schema (msg) (defun validate-communication-protocol-schema (msg)
@@ -154,7 +154,7 @@ Frames a message with a hex length prefix and ensures all data is serializable.
These tests verify the communication protocol functions. Run with: These tests verify the communication protocol functions. Run with:
~(fiveam:run! 'communication-protocol-suite)~ ~(fiveam:run! 'communication-protocol-suite)~
#+begin_src lisp :tangle (expand-file-name "communication-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "communication-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-communication-tests (defpackage :opencortex-communication-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:communication-protocol-suite)) (:export #:communication-protocol-suite))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/context.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/context.lisp" (expand-file-name ""))
#+TITLE: Peripheral Vision (context.lisp) #+TITLE: Peripheral Vision (context.lisp)
#+AUTHOR: Amr #+AUTHOR: Amr
#+FILETAGS: :harness:context: #+FILETAGS: :harness:context:
@@ -100,7 +100,7 @@ Reads the raw literate Org source of a specific skill. This is a foundational ca
(defun context-get-skill-source (skill-name) (defun context-get-skill-source (skill-name)
"Reads the raw literate source of a specific skill for inspection." "Reads the raw literate source of a specific skill for inspection."
(let* ((filename (format nil "~a.org" skill-name)) (let* ((filename (format nil "~a.org" skill-name))
(skills-dir-str (or (uiop:getenv "SKILLS_DIR") (namestring (merge-pathnames "notes/" (user-homedir-pathname))))) (skills-dir-str (or (getenv "SKILLS_DIR") (namestring (merge-pathnames "notes/" (user-homedir-pathname)))))
(skills-dir (uiop:ensure-directory-pathname (context-resolve-path skills-dir-str))) (skills-dir (uiop:ensure-directory-pathname (context-resolve-path skills-dir-str)))
(full-path (merge-pathnames filename skills-dir))) (full-path (merge-pathnames filename skills-dir)))
(if (uiop:file-exists-p full-path) (uiop:read-file-string full-path) nil))) (if (uiop:file-exists-p full-path) (uiop:read-file-string full-path) nil)))
@@ -112,7 +112,7 @@ Retrieves the most recent entries from the harness's internal circular log buffe
#+begin_src lisp #+begin_src lisp
(defun context-get-system-logs (&optional limit) (defun context-get-system-logs (&optional limit)
"Retrieves the most recent lines from the harness's internal log." "Retrieves the most recent lines from the harness's internal log."
(let ((log-limit (or limit (ignore-errors (parse-integer (uiop:getenv "CONTEXT_LOG_LIMIT"))) 20))) (let ((log-limit (or limit (ignore-errors (parse-integer (getenv "CONTEXT_LOG_LIMIT"))) 20)))
(bt:with-lock-held (*logs-lock*) (bt:with-lock-held (*logs-lock*)
(let ((count (min log-limit (length *system-logs*)))) (let ((count (min log-limit (length *system-logs*))))
(subseq *system-logs* 0 count))))) (subseq *system-logs* 0 count)))))
@@ -139,7 +139,7 @@ The semantic threshold is externalized to `CONTEXT_SEMANTIC_THRESHOLD`.
(children (org-object-children obj)) (children (org-object-children obj))
(stars (make-string depth :initial-element #\*)) (stars (make-string depth :initial-element #\*))
(obj-vector (org-object-vector obj)) (obj-vector (org-object-vector obj))
(threshold (or semantic-threshold (ignore-errors (read-from-string (uiop:getenv "CONTEXT_SEMANTIC_THRESHOLD"))) 0.75)) (threshold (or semantic-threshold (ignore-errors (read-from-string (getenv "CONTEXT_SEMANTIC_THRESHOLD"))) 0.75))
(similarity (if (and foveal-vector obj-vector (not is-foveal)) (similarity (if (and foveal-vector obj-vector (not is-foveal))
(cosine-similarity foveal-vector obj-vector) (cosine-similarity foveal-vector obj-vector)
0.0)) 0.0))
@@ -187,7 +187,7 @@ A utility function that expands environment variables (like ~$HOME~ or ~$MEMEX_R
(if (and (stringp path) (search "$" path)) (if (and (stringp path) (search "$" path))
(let ((result path)) (let ((result path))
(ppcre:do-register-groups (var-name) ("\\$([A-Za-z0-9_]+)" path) (ppcre:do-register-groups (var-name) ("\\$([A-Za-z0-9_]+)" path)
(let ((var-val (uiop:getenv var-name))) (let ((var-val (getenv var-name)))
(when var-val (when var-val
(setf result (ppcre:regex-replace (format nil "\\$~a" var-name) result var-val))))) (setf result (ppcre:regex-replace (format nil "\\$~a" var-name) result var-val)))))
result) result)
@@ -217,7 +217,7 @@ The primary entry point for context generation. This function identifies active
Following the Engineering Standards, the peripheral vision extraction and rendering logic must be empirically verified. Following the Engineering Standards, the peripheral vision extraction and rendering logic must be empirically verified.
** Test Suite Context ** Test Suite Context
#+begin_src lisp :tangle (expand-file-name "peripheral-vision-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "peripheral-vision-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-peripheral-vision-tests (defpackage :opencortex-peripheral-vision-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:vision-suite)) (:export #:vision-suite))
@@ -231,7 +231,7 @@ Following the Engineering Standards, the peripheral vision extraction and render
** Foveal Rendering Test ** Foveal Rendering Test
Verify that the foveal target is rendered with content, while siblings are skeletal. Verify that the foveal target is rendered with content, while siblings are skeletal.
#+begin_src lisp :tangle (expand-file-name "peripheral-vision-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "peripheral-vision-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(test test-foveal-rendering (test test-foveal-rendering
"Verify that the foveal target is rendered with content, while siblings are skeletal." "Verify that the foveal target is rendered with content, while siblings are skeletal."
(clrhash opencortex::*memory*) (clrhash opencortex::*memory*)
@@ -251,7 +251,7 @@ Verify that the foveal target is rendered with content, while siblings are skele
** Awareness Budget Test ** Awareness Budget Test
Verify that context-assemble-global-awareness handles multiple projects correctly. Verify that context-assemble-global-awareness handles multiple projects correctly.
#+begin_src lisp :tangle (expand-file-name "peripheral-vision-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "peripheral-vision-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(test test-awareness-budget (test test-awareness-budget
"Verify that context-assemble-global-awareness handles multiple projects." "Verify that context-assemble-global-awareness handles multiple projects."
(clrhash opencortex::*memory*) (clrhash opencortex::*memory*)

View File

@@ -18,31 +18,31 @@ To ensure OpenCortex behaves as a first-class POSIX citizen, we adopt the **XDG
4. **Bin (`~/.local/bin`)**: The CLI shim for global invocation. 4. **Bin (`~/.local/bin`)**: The CLI shim for global invocation.
** The Detection Invariant: Shell Probing ** The Detection Invariant: Shell Probing
Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure that missing variables are handled as logic failures, not type crashes. Furthermore, binary detection must use a shell probe (`command -v` or `which`) to account for varying `$PATH` inheritance between interactive and headless sessions. Common Lisp's `getenv` is strictly typed in SBCL. The Doctor must ensure that missing variables are handled as logic failures, not type crashes. Furthermore, binary detection must use a shell probe (`command -v` or `which`) to account for varying `$PATH` inheritance between interactive and headless sessions.
* Phase B: Protocol (Success Criteria) * Phase B: Protocol (Success Criteria)
** Package Context ** Package Context
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-doctor-tests (defpackage :opencortex-doctor-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:doctor-suite)) (:export #:doctor-suite))
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(in-package :opencortex-doctor-tests) (in-package :opencortex-doctor-tests)
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(def-suite doctor-suite :description "Verification of the System Doctor diagnostic logic") (def-suite doctor-suite :description "Verification of the System Doctor diagnostic logic")
#+end_src #+end_src
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(in-suite doctor-suite) (in-suite doctor-suite)
#+end_src #+end_src
** Dependency Tests ** Dependency Tests
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(test test-dependency-check-fail (test test-dependency-check-fail
"Verify that missing binaries are correctly identified as failures." "Verify that missing binaries are correctly identified as failures."
(let ((opencortex::*doctor-required-binaries* '("non-existent-binary-123"))) (let ((opencortex::*doctor-required-binaries* '("non-existent-binary-123")))
@@ -50,34 +50,34 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src #+end_src
** Environment Tests ** Environment Tests
#+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "doctor-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(test test-env-validation-fail (test test-env-validation-fail
"Verify that an invalid MEMEX_DIR triggers a critical failure." "Verify that an invalid MEMEX_DIR triggers a critical failure."
(let ((old-m (uiop:getenv "MEMEX_DIR")) (let ((old-m (getenv "MEMEX_DIR"))
(old-s (uiop:getenv "SKILLS_DIR"))) (old-s (getenv "SKILLS_DIR")))
(unwind-protect (unwind-protect
(progn (progn
(setf (uiop:getenv "MEMEX_DIR") "/non/existent/path/999") (setf (getenv "MEMEX_DIR") "/non/existent/path/999")
(is (null (opencortex:doctor-check-env)))) (is (null (opencortex:doctor-check-env))))
(setf (uiop:getenv "MEMEX_DIR") (or old-m "")) (setf (getenv "MEMEX_DIR") (or old-m ""))
(setf (uiop:getenv "SKILLS_DIR") (or old-s ""))))) (setf (getenv "SKILLS_DIR") (or old-s "")))))
#+end_src #+end_src
* Phase C: Implementation (Build) * Phase C: Implementation (Build)
** Package Context ** Package Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(in-package :opencortex) (in-package :opencortex)
#+end_src #+end_src
** Global Configuration ** Global Configuration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defvar *doctor-required-binaries* '("sbcl" "emacs" "git" "socat" "nc") (defvar *doctor-required-binaries* '("sbcl" "emacs" "git" "socat" "nc")
"List of external binaries required for full system operation.") "List of external binaries required for full system operation.")
#+end_src #+end_src
** Dependency Verification ** Dependency Verification
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-check-dependencies () (defun doctor-check-dependencies ()
"Verifies that required external binaries are available in the PATH via a shell probe." "Verifies that required external binaries are available in the PATH via a shell probe."
(let ((all-ok t)) (let ((all-ok t))
@@ -95,15 +95,15 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src #+end_src
** Environment & XDG Validation ** Environment & XDG Validation
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-check-env () (defun doctor-check-env ()
"Validates XDG directories and environment configuration against the POSIX standard." "Validates XDG directories and environment configuration against the POSIX standard."
(harness-log "DOCTOR: Checking XDG environment...") (harness-log "DOCTOR: Checking XDG environment...")
(let ((all-ok t) (let ((all-ok t)
(config-dir (uiop:getenv "OC_CONFIG_DIR")) (config-dir (getenv "OC_CONFIG_DIR"))
(data-dir (uiop:getenv "OC_DATA_DIR")) (data-dir (getenv "OC_DATA_DIR"))
(state-dir (uiop:getenv "OC_STATE_DIR")) (state-dir (getenv "OC_STATE_DIR"))
(memex-dir (uiop:getenv "MEMEX_DIR"))) (memex-dir (getenv "MEMEX_DIR")))
(flet ((check-dir (name path critical) (flet ((check-dir (name path critical)
(if (and path (> (length path) 0)) (if (and path (> (length path) 0))
@@ -124,11 +124,11 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src #+end_src
** LLM Connectivity ** LLM Connectivity
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-check-llm () (defun doctor-check-llm ()
"Tests connectivity to primary LLM providers. Non-critical fallback allowed." "Tests connectivity to primary LLM providers. Non-critical fallback allowed."
(harness-log "DOCTOR: Checking LLM connectivity...") (harness-log "DOCTOR: Checking LLM connectivity...")
(let ((openrouter-key (uiop:getenv "OPENROUTER_API_KEY"))) (let ((openrouter-key (getenv "OPENROUTER_API_KEY")))
(if (and openrouter-key (> (length openrouter-key) 0)) (if (and openrouter-key (> (length openrouter-key) 0))
(progn (progn
(harness-log " [OK] OpenRouter API Key detected.") (harness-log " [OK] OpenRouter API Key detected.")
@@ -139,7 +139,7 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src #+end_src
** Orchestration ** Orchestration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-run-all () (defun doctor-run-all ()
"Executes the full diagnostic suite and returns T if system is healthy." "Executes the full diagnostic suite and returns T if system is healthy."
(harness-log "==================================================") (harness-log "==================================================")
@@ -159,7 +159,7 @@ Common Lisp's `uiop:getenv` is strictly typed in SBCL. The Doctor must ensure th
#+end_src #+end_src
** CLI Entry Point ** CLI Entry Point
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/doctor.lisp" (expand-file-name ""))
(defun doctor-main () (defun doctor-main ()
"Entry point for the 'doctor' CLI command." "Entry point for the 'doctor' CLI command."
(if (doctor-run-all) (if (doctor-run-all)

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/loop.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/loop.lisp" (expand-file-name ""))
#+TITLE: The Metabolic Loop (loop.lisp) #+TITLE: The Metabolic Loop (loop.lisp)
#+AUTHOR: Amr #+AUTHOR: Amr
#+FILETAGS: :harness:loop: #+FILETAGS: :harness:loop:
@@ -210,8 +210,8 @@ The heartbeat thread ensures the agent remains alive even without external input
- HEARTBEAT_INTERVAL: Seconds between heartbeats (default: 60) - HEARTBEAT_INTERVAL: Seconds between heartbeats (default: 60)
- MEMORY_AUTO_SAVE_INTERVAL: Seconds between auto-saves (default: 300)" - MEMORY_AUTO_SAVE_INTERVAL: Seconds between auto-saves (default: 300)"
(let ((interval (or (ignore-errors (parse-integer (uiop:getenv "HEARTBEAT_INTERVAL"))) 60)) (let ((interval (or (ignore-errors (parse-integer (getenv "HEARTBEAT_INTERVAL"))) 60))
(auto-save (or (ignore-errors (parse-integer (uiop:getenv "MEMORY_AUTO_SAVE_INTERVAL"))) *auto-save-interval*))) (auto-save (or (ignore-errors (parse-integer (getenv "MEMORY_AUTO_SAVE_INTERVAL"))) *auto-save-interval*)))
(setf *auto-save-interval* auto-save) (setf *auto-save-interval* auto-save)
(setf *heartbeat-save-counter* 0) (setf *heartbeat-save-counter* 0)
@@ -275,7 +275,7 @@ The main function orchestrates system startup:
The idle loop checks for interrupts and saves memory before exit." The idle loop checks for interrupts and saves memory before exit."
;; Step 1: Load environment variables from standard location ;; Step 1: Load environment variables from standard location
(let* ((home (uiop:getenv "HOME")) (let* ((home (getenv "HOME"))
(env-file (uiop:merge-pathnames* (env-file (uiop:merge-pathnames*
".local/share/opencortex/.env" ".local/share/opencortex/.env"
(uiop:ensure-directory-pathname home)))) (uiop:ensure-directory-pathname home))))
@@ -305,7 +305,7 @@ The main function orchestrates system startup:
;; Step 7: Idle loop - sleep in chunks, checking for interrupts ;; Step 7: Idle loop - sleep in chunks, checking for interrupts
(let ((sleep-interval (or (ignore-errors (let ((sleep-interval (or (ignore-errors
(parse-integer (uiop:getenv "DAEMON_SLEEP_INTERVAL"))) (parse-integer (getenv "DAEMON_SLEEP_INTERVAL")))
3600))) 3600)))
(loop (loop
;; Check for interrupt before each sleep cycle ;; Check for interrupt before each sleep cycle
@@ -324,7 +324,7 @@ The main function orchestrates system startup:
These tests verify the metabolic loop and error recovery. Run with: These tests verify the metabolic loop and error recovery. Run with:
~(fiveam:run! 'immune-suite)~ ~(fiveam:run! 'immune-suite)~
#+begin_src lisp :tangle (expand-file-name "immune-system-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "immune-system-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-immune-system-tests (defpackage :opencortex-immune-system-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:immune-suite)) (:export #:immune-suite))

View File

@@ -9,7 +9,7 @@ The *System Manifest* defines the structural components of the OpenCortex. It se
* Implementation * Implementation
** Main System ** Main System
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/opencortex.asd") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/opencortex.asd")
(defsystem :opencortex (defsystem :opencortex
:name "opencortex" :name "opencortex"
:author "Amr Gharbeia" :author "Amr Gharbeia"
@@ -31,7 +31,7 @@ The *System Manifest* defines the structural components of the OpenCortex. It se
#+end_src #+end_src
** Test System ** Test System
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/opencortex.asd") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/opencortex.asd")
(defsystem :opencortex/tests (defsystem :opencortex/tests
:depends-on (:opencortex :fiveam) :depends-on (:opencortex :fiveam)
:components ((:file "tests/pipeline-act-tests") :components ((:file "tests/pipeline-act-tests")
@@ -55,17 +55,17 @@ The *System Manifest* defines the structural components of the OpenCortex. It se
#+end_src #+end_src
** TUI System ** TUI System
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/opencortex.asd") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/opencortex.asd")
(defsystem :opencortex/tui (defsystem :opencortex/tui
:depends-on (:opencortex :croatoan :usocket :bordeaux-threads) :depends-on (:opencortex :croatoan :usocket :bordeaux-threads)
:components ((:file "harness/tui-client"))) :components ((:file "harness/tui-client")))
#+end_src #+end_src
** Test Orchestrator ** Test Orchestrator
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/run-all-tests.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/run-all-tests.lisp")
(load (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))) (load (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname)))
(let ((oc-dir (or (uiop:getenv "OC_DATA_DIR") (let ((oc-dir (or (getenv "OC_DATA_DIR")
(namestring (truename "./"))))) (namestring (truename "./")))))
(push (uiop:ensure-directory-pathname oc-dir) asdf:*central-registry*)) (push (uiop:ensure-directory-pathname oc-dir) asdf:*central-registry*))

View File

@@ -31,14 +31,14 @@ flowchart TD
#+end_src #+end_src
** Package Context ** Package Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(in-package :opencortex) (in-package :opencortex)
#+end_src #+end_src
** The Object Repository ** The Object Repository
The `*memory*` is the global hash table that holds every Org element by its unique ID. This is the "live RAM" of the agent's memory. The `*memory*` is the global hash table that holds every Org element by its unique ID. This is the "live RAM" of the agent's memory.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defvar *memory* (make-hash-table :test 'equal)) (defvar *memory* (make-hash-table :test 'equal))
(defvar *history-store* (make-hash-table :test 'equal) (defvar *history-store* (make-hash-table :test 'equal)
@@ -48,7 +48,7 @@ The `*memory*` is the global hash table that holds every Org element by its uniq
** The Data Structure (org-object) ** The Data Structure (org-object)
Every element in the Memex (headlines, paragraphs, etc.) is represented by an `org-object` structure. It contains both semantic metadata (attributes, content) and structural metadata (parent/child pointers, Merkle hashes). Every element in the Memex (headlines, paragraphs, etc.) is represented by an `org-object` structure. It contains both semantic metadata (attributes, content) and structural metadata (parent/child pointers, Merkle hashes).
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defstruct org-object (defstruct org-object
id type attributes content vector parent-id children version last-sync hash) id type attributes content vector parent-id children version last-sync hash)
@@ -60,7 +60,7 @@ Every element in the Memex (headlines, paragraphs, etc.) is represented by an `o
** Merkle Tree Integrity (compute-merkle-hash) ** Merkle Tree Integrity (compute-merkle-hash)
The `compute-merkle-hash` function ensures the cryptographic integrity of the knowledge graph. A node's hash depends on its own properties and the hashes of all its children. This creates a recursive fingerprint where any change to a single note propagates up to the root hash. The `compute-merkle-hash` function ensures the cryptographic integrity of the knowledge graph. A node's hash depends on its own properties and the hashes of all its children. This creates a recursive fingerprint where any change to a single note propagates up to the root hash.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defun compute-merkle-hash (id type attributes content child-hashes) (defun compute-merkle-hash (id type attributes content child-hashes)
"Computes a SHA-256 Merkle hash for a node based on its core properties and children's hashes." "Computes a SHA-256 Merkle hash for a node based on its core properties and children's hashes."
(let* ((alist (loop for (k v) on attributes by #'cddr collect (cons k v))) (let* ((alist (loop for (k v) on attributes by #'cddr collect (cons k v)))
@@ -77,7 +77,7 @@ The `compute-merkle-hash` function ensures the cryptographic integrity of the kn
** Ingesting the AST (ingest-ast) ** Ingesting the AST (ingest-ast)
The `ingest-ast` function is the primary bridge between the external world (Emacs/JSON) and the internal Lisp machine. It recursively parses an Org-mode Abstract Syntax Tree (AST) into `org-object` structures and registers them in the store. The `ingest-ast` function is the primary bridge between the external world (Emacs/JSON) and the internal Lisp machine. It recursively parses an Org-mode Abstract Syntax Tree (AST) into `org-object` structures and registers them in the store.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defun ingest-ast (ast &optional parent-id) (defun ingest-ast (ast &optional parent-id)
"Parses an Org AST into the recursive Lisp Memory with Merkle hashing." "Parses an Org AST into the recursive Lisp Memory with Merkle hashing."
(let* ((type (getf ast :type)) (let* ((type (getf ast :type))
@@ -116,7 +116,7 @@ The `ingest-ast` function is the primary bridge between the external world (Emac
** Memory Snapshots (snapshot-memory) ** Memory Snapshots (snapshot-memory)
Because objects are stored immutably in the `*history-store*`, a snapshot is a lightweight shallow copy of the active `*memory*` pointers. The system maintains a rolling buffer of 20 snapshots, allowing for near-instant, zero-cost rollback. Because objects are stored immutably in the `*history-store*`, a snapshot is a lightweight shallow copy of the active `*memory*` pointers. The system maintains a rolling buffer of 20 snapshots, allowing for near-instant, zero-cost rollback.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defvar *object-store-snapshots* nil) (defvar *object-store-snapshots* nil)
(defun copy-hash-table (hash-table) (defun copy-hash-table (hash-table)
@@ -143,7 +143,7 @@ Because objects are stored immutably in the `*history-store*`, a snapshot is a l
** Memory Rollback (rollback-memory) ** Memory Rollback (rollback-memory)
Restores the state of the Memex from one of the previous snapshots. Restores the state of the Memex from one of the previous snapshots.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defun rollback-memory (&optional (index 0)) (defun rollback-memory (&optional (index 0))
"Restores the Memory to a previously captured snapshot using immutable history pointers." "Restores the Memory to a previously captured snapshot using immutable history pointers."
(let ((snapshot (nth index *object-store-snapshots*))) (let ((snapshot (nth index *object-store-snapshots*)))
@@ -156,14 +156,14 @@ Restores the state of the Memex from one of the previous snapshots.
** Disk Persistence (save-memory / load-memory) ** Disk Persistence (save-memory / load-memory)
Essential for surviving crashes. Saves the in-memory hash tables to disk and loads them back on restart. Essential for surviving crashes. Saves the in-memory hash tables to disk and loads them back on restart.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defvar *memory-snapshot-path* nil (defvar *memory-snapshot-path* nil
"Path to the memory snapshot file. Set from MEMORY_SNAPSHOT_PATH env or default.") "Path to the memory snapshot file. Set from MEMORY_SNAPSHOT_PATH env or default.")
(defun ensure-memory-snapshot-path () (defun ensure-memory-snapshot-path ()
"Initializes the snapshot path from environment or default location." "Initializes the snapshot path from environment or default location."
(or *memory-snapshot-path* (or *memory-snapshot-path*
(let ((env-path (uiop:getenv "MEMORY_SNAPSHOT_PATH"))) (let ((env-path (getenv "MEMORY_SNAPSHOT_PATH")))
(setf *memory-snapshot-path* (setf *memory-snapshot-path*
(or env-path (or env-path
(uiop:merge-pathnames* "memory.snap" (user-homedir-pathname))))))) (uiop:merge-pathnames* "memory.snap" (user-homedir-pathname)))))))
@@ -209,7 +209,7 @@ Reconstitutes alists into hash tables."
** Semantic Search (get-embedding, semantic-search) ** Semantic Search (get-embedding, semantic-search)
Support for vector embeddings via Ollama and semantic search with cosine similarity. Support for vector embeddings via Ollama and semantic search with cosine similarity.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defvar *embedding-cache* (make-hash-table :test 'equal) (defvar *embedding-cache* (make-hash-table :test 'equal)
"Cache for embeddings to avoid redundant API calls.") "Cache for embeddings to avoid redundant API calls.")
@@ -258,7 +258,7 @@ Returns up to LIMIT objects with similarity >= MIN-SIMILARITY, sorted by similar
#+end_src #+end_src
** Cognitive Tool: Semantic Search ** Cognitive Tool: Semantic Search
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(def-cognitive-tool :semantic-search (def-cognitive-tool :semantic-search
"Searches memory for objects semantically similar to a query." "Searches memory for objects semantically similar to a query."
((:query :type :string :description "The search query.") ((:query :type :string :description "The search query.")
@@ -271,7 +271,7 @@ Returns up to LIMIT objects with similarity >= MIN-SIMILARITY, sorted by similar
#+end_src #+end_src
** Cognitive Tool: Generate Embeddings ** Cognitive Tool: Generate Embeddings
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(def-cognitive-tool :generate-embeddings (def-cognitive-tool :generate-embeddings
"Generates vector embeddings for given text via the configured embedding backend (Ollama)." "Generates vector embeddings for given text via the configured embedding backend (Ollama)."
((:texts :type :list :description "List of text strings to embed.")) ((:texts :type :list :description "List of text strings to embed."))
@@ -294,7 +294,7 @@ Returns up to LIMIT objects with similarity >= MIN-SIMILARITY, sorted by similar
** Lookup Utilities ** Lookup Utilities
Basic functions for retrieving objects by ID or type. Basic functions for retrieving objects by ID or type.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defun org-id-new () (defun org-id-new ()
"Generates a new UUID string for Org-mode identification." "Generates a new UUID string for Org-mode identification."
(string-downcase (format nil "~a" (uuid:make-v4-uuid)))) (string-downcase (format nil "~a" (uuid:make-v4-uuid))))
@@ -324,7 +324,7 @@ Basic functions for retrieving objects by ID or type.
** Structural Helpers ** Structural Helpers
Utility functions for AST traversal and path resolution. Utility functions for AST traversal and path resolution.
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/memory.lisp" (expand-file-name ""))
(defun find-headline-missing-id (ast) (defun find-headline-missing-id (ast)
"Traverses an AST to find headlines that lack an :ID: property." "Traverses an AST to find headlines that lack an :ID: property."
(when (listp ast) (when (listp ast)
@@ -339,7 +339,7 @@ Utility functions for AST traversal and path resolution.
* Test Suite * Test Suite
#+begin_src lisp :tangle (expand-file-name "memory-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "memory-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-memory-tests (defpackage :opencortex-memory-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:memory-suite)) (:export #:memory-suite))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/package.lisp") #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/package.lisp")
#+TITLE: System Interface (package.lisp) #+TITLE: System Interface (package.lisp)
#+AUTHOR: Amr #+AUTHOR: Amr
#+FILETAGS: :harness:interface: #+FILETAGS: :harness:interface:

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/perceive.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/perceive.lisp" (expand-file-name ""))
#+TITLE: Stage 1: Perceive (perceive.lisp) #+TITLE: Stage 1: Perceive (perceive.lisp)
#+AUTHOR: Amr #+AUTHOR: Amr
#+FILETAGS: :harness:perceive: #+FILETAGS: :harness:perceive:
@@ -227,7 +227,7 @@ Other sensors (heartbeats, interrupts) are processed synchronously to maintain o
These tests verify the Perceive pipeline. Run with: These tests verify the Perceive pipeline. Run with:
~(fiveam:run! 'pipeline-perceive-suite)~ ~(fiveam:run! 'pipeline-perceive-suite)~
#+begin_src lisp :tangle (expand-file-name "pipeline-perceive-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "pipeline-perceive-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-pipeline-perceive-tests (defpackage :opencortex-pipeline-perceive-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:pipeline-perceive-suite)) (:export #:pipeline-perceive-suite))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/reason.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/reason.lisp" (expand-file-name ""))
#+TITLE: Stage 2: Reason (reason.lisp) #+TITLE: Stage 2: Reason (reason.lisp)
#+AUTHOR: Amr #+AUTHOR: Amr
#+FILETAGS: :harness:reason: #+FILETAGS: :harness:reason:
@@ -200,7 +200,7 @@ The `think` function is the heart of the probabilistic engine. It constructs a p
(tool-belt (generate-tool-belt-prompt)) (tool-belt (generate-tool-belt-prompt))
(global-context (context-assemble-global-awareness)) (global-context (context-assemble-global-awareness))
(system-logs (context-get-system-logs)) (system-logs (context-get-system-logs))
(assistant-name (or (uiop:getenv "MEMEX_ASSISTANT") "Agent")) (assistant-name (or (getenv "MEMEX_ASSISTANT") "Agent"))
(rejection-trace (proto-get (proto-get context :payload) :rejection-trace))) (rejection-trace (proto-get (proto-get context :payload) :rejection-trace)))
;; Generate prompt from skill or raw text ;; Generate prompt from skill or raw text
@@ -472,7 +472,7 @@ The deterministic engine runs all registered skills' verification functions. Thi
These tests verify the Reason (cognitive) pipeline. Run with: These tests verify the Reason (cognitive) pipeline. Run with:
~(fiveam:run! 'pipeline-reason-suite)~ ~(fiveam:run! 'pipeline-reason-suite)~
#+begin_src lisp :tangle (expand-file-name "pipeline-reason-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "pipeline-reason-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-pipeline-reason-tests (defpackage :opencortex-pipeline-reason-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:pipeline-reason-suite)) (:export #:pipeline-reason-suite))

View File

@@ -23,7 +23,7 @@ To maintain sovereignty, the harness must remain a "dumb" bus. It should not kno
** The Installer Script (opencortex.sh) ** The Installer Script (opencortex.sh)
The shell script is the primary entry point. It handles the initial git clone, dependency installation, and literate tangle. The shell script is the primary entry point. It handles the initial git clone, dependency installation, and literate tangle.
#+begin_src bash :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/../opencortex.sh") #+begin_src bash :tangle (concat (getenv "INSTALL_DIR") "/harness/../opencortex.sh")
#!/bin/bash #!/bin/bash
# (The content here is a duplicate of the main opencortex.sh for literate consistency) # (The content here is a duplicate of the main opencortex.sh for literate consistency)
# [Note: Implementation is already verified in the top-level script] # [Note: Implementation is already verified in the top-level script]

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/skills.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/skills.lisp" (expand-file-name ""))
#+TITLE: The Skill Engine (skills.lisp) #+TITLE: The Skill Engine (skills.lisp)
#+AUTHOR: Amr #+AUTHOR: Amr
#+FILETAGS: :harness:skills: #+FILETAGS: :harness:skills:
@@ -347,7 +347,7 @@ Only loads blocks that specify a .lisp tangle target, ignoring tests and example
(defun initialize-all-skills () (defun initialize-all-skills ()
"Scans the directory defined by SKILLS_DIR and hot-loads skills using topological order." "Scans the directory defined by SKILLS_DIR and hot-loads skills using topological order."
(let* ((env-path (uiop:getenv "SKILLS_DIR")) (let* ((env-path (getenv "SKILLS_DIR"))
(skills-dir-str (or env-path (namestring (merge-pathnames "notes/" (user-homedir-pathname))))) (skills-dir-str (or env-path (namestring (merge-pathnames "notes/" (user-homedir-pathname)))))
(resolved-path (context-resolve-path skills-dir-str)) (resolved-path (context-resolve-path skills-dir-str))
(skills-dir (if resolved-path (uiop:ensure-directory-pathname resolved-path) nil))) (skills-dir (if resolved-path (uiop:ensure-directory-pathname resolved-path) nil)))
@@ -357,7 +357,7 @@ Only loads blocks that specify a .lisp tangle target, ignoring tests and example
(return-from initialize-all-skills nil)) (return-from initialize-all-skills nil))
(let ((sorted-files (topological-sort-skills skills-dir))) (let ((sorted-files (topological-sort-skills skills-dir)))
(let* ((mandatory-env (uiop:getenv "MANDATORY_SKILLS")) (let* ((mandatory-env (getenv "MANDATORY_SKILLS"))
(mandatory-skills (if mandatory-env (mandatory-skills (if mandatory-env
(mapcar (lambda (s) (string-trim '(#\Space #\" #\') s)) (mapcar (lambda (s) (string-trim '(#\Space #\" #\') s))
(uiop:split-string mandatory-env :separator '( #\,))) (uiop:split-string mandatory-env :separator '( #\,)))
@@ -419,7 +419,7 @@ EXAMPLES:
*** The Eval Tool (Internal Inspection) *** The Eval Tool (Internal Inspection)
#+begin_src lisp #+begin_src lisp
** Cognitive Tool Registration ** Cognitive Tool Registration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/harness/skills.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/harness/skills.lisp" (expand-file-name ""))
;; Cognitive tools are registered in *cognitive-tools* (defined in package.lisp) ;; Cognitive tools are registered in *cognitive-tools* (defined in package.lisp)
;; using the def-cognitive-tool macro. ;; using the def-cognitive-tool macro.
#+end_src #+end_src
@@ -447,7 +447,7 @@ EXAMPLES:
(:dir :type :string :description "Directory to search in (default is project root)")) (:dir :type :string :description "Directory to search in (default is project root)"))
:body (lambda (args) :body (lambda (args)
(let ((pattern (getf args :pattern)) (let ((pattern (getf args :pattern))
(dir (or (getf args :dir) (uiop:getenv "MEMEX_DIR")))) (dir (or (getf args :dir) (getenv "MEMEX_DIR"))))
(uiop:run-program (list "grep" "-r" "-n" "--exclude-dir=node_modules" pattern dir) (uiop:run-program (list "grep" "-r" "-n" "--exclude-dir=node_modules" pattern dir)
:output :string :ignore-error-status t)))) :output :string :ignore-error-status t))))
#+end_src #+end_src
@@ -475,17 +475,17 @@ EXAMPLES:
(declare (ignore context)) (declare (ignore context))
(let ((skill (getf args :skill))) (let ((skill (getf args :skill)))
(or (uiop:file-exists-p skill) (or (uiop:file-exists-p skill)
(let ((skills-dir (or (ignore-errors (uiop:getenv "SKILLS_DIR")) (let ((skills-dir (or (ignore-errors (getenv "SKILLS_DIR"))
(namestring (merge-pathnames "notes/" (user-homedir-pathname)))))) (namestring (merge-pathnames "notes/" (user-homedir-pathname))))))
(uiop:file-exists-p (merge-pathnames (format nil "~a.org" skill) skills-dir)))))) (uiop:file-exists-p (merge-pathnames (format nil "~a.org" skill) skills-dir))))))
:body (lambda (args) :body (lambda (args)
(let ((skill (getf args :skill))) (let ((skill (getf args :skill)))
(snapshot-memory) (snapshot-memory)
(let ((skills-dir (or (ignore-errors (uiop:getenv "SKILLS_DIR")) (let ((skills-dir (or (ignore-errors (getenv "SKILLS_DIR"))
(namestring (merge-pathnames "notes/" (user-homedir-pathname))))) (namestring (merge-pathnames "notes/" (user-homedir-pathname)))))
(resolved-path (context-resolve-path skills-dir)) (resolved-path (context-resolve-path skills-dir))
(skills-dir-actual (if (ignore-errors (uiop:getenv "SKILLS_DIR")) (skills-dir-actual (if (ignore-errors (getenv "SKILLS_DIR"))
(uiop:ensure-directory-pathname (context-resolve-path (uiop:getenv "SKILLS_DIR"))) (uiop:ensure-directory-pathname (context-resolve-path (getenv "SKILLS_DIR")))
(uiop:ensure-directory-pathname (user-homedir-pathname))))) (uiop:ensure-directory-pathname (user-homedir-pathname)))))
(let ((file (if (uiop:file-exists-p skill) (let ((file (if (uiop:file-exists-p skill)
(uiop:ensure-pathname skill) (uiop:ensure-pathname skill)
@@ -510,7 +510,7 @@ EXAMPLES:
:guard (lambda (args context) :guard (lambda (args context)
(declare (ignore context)) (declare (ignore context))
(let* ((file (getf args :file)) (let* ((file (getf args :file))
(memex-root (or (uiop:getenv "MEMEX_DIR") "/home/user/memex")) (memex-root (or (getenv "MEMEX_DIR") "/home/user/memex"))
(abs-path (namestring (uiop:ensure-absolute-pathname file (uiop:getcwd))))) (abs-path (namestring (uiop:ensure-absolute-pathname file (uiop:getcwd)))))
(and (str:starts-with-p memex-root abs-path) (and (str:starts-with-p memex-root abs-path)
(not (search ".." abs-path))))) (not (search ".." abs-path)))))
@@ -531,7 +531,7 @@ EXAMPLES:
:guard (lambda (args context) :guard (lambda (args context)
(declare (ignore context)) (declare (ignore context))
(let* ((file (getf args :file)) (let* ((file (getf args :file))
(memex-root (or (uiop:getenv "MEMEX_DIR") "/home/user/memex")) (memex-root (or (getenv "MEMEX_DIR") "/home/user/memex"))
(abs-path (namestring (uiop:ensure-absolute-pathname file (uiop:getcwd))))) (abs-path (namestring (uiop:ensure-absolute-pathname file (uiop:getcwd)))))
(and (str:starts-with-p memex-root abs-path) (and (str:starts-with-p memex-root abs-path)
(not (search ".." abs-path)) (not (search ".." abs-path))
@@ -564,7 +564,7 @@ EXAMPLES:
:guard (lambda (args context) :guard (lambda (args context)
(declare (ignore context)) (declare (ignore context))
(let* ((file (getf args :file)) (let* ((file (getf args :file))
(memex-root (or (uiop:getenv "MEMEX_DIR") "/home/user/memex")) (memex-root (or (getenv "MEMEX_DIR") "/home/user/memex"))
(abs-path (namestring (uiop:ensure-absolute-pathname file (uiop:getcwd))))) (abs-path (namestring (uiop:ensure-absolute-pathname file (uiop:getcwd)))))
(and (str:starts-with-p memex-root abs-path) (and (str:starts-with-p memex-root abs-path)
(not (search ".." abs-path)) (not (search ".." abs-path))
@@ -589,7 +589,7 @@ EXAMPLES:
* Test Suite * Test Suite
#+begin_src lisp :tangle (expand-file-name "boot-sequence-tests.lisp" (concat (concat (or (uiop:getenv "INSTALL_DIR") ".") "/harness") "/tests")) #+begin_src lisp :tangle (expand-file-name "boot-sequence-tests.lisp" (concat (concat (or (getenv "INSTALL_DIR") ".") "/harness") "/tests"))
(defpackage :opencortex-boot-tests (defpackage :opencortex-boot-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:boot-suite)) (:export #:boot-suite))
@@ -643,7 +643,7 @@ EXAMPLES:
(let* ((tool (gethash "read-file" opencortex::*cognitive-tools*)) (let* ((tool (gethash "read-file" opencortex::*cognitive-tools*))
(guard (opencortex::cognitive-tool-guard tool))) (guard (opencortex::cognitive-tool-guard tool)))
;; Set a dummy MEMEX_DIR for the test ;; Set a dummy MEMEX_DIR for the test
(setf (uiop:getenv "MEMEX_DIR") "/home/user/memex") (setf (getenv "MEMEX_DIR") "/home/user/memex")
;; Valid internal paths should return true ;; Valid internal paths should return true
(is (not (null (funcall guard '(:file "/home/user/memex/safe.txt") nil)))) (is (not (null (funcall guard '(:file "/home/user/memex/safe.txt") nil))))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
:PROPERTIES: :PROPERTIES:
:ID: tui-client-spec :ID: tui-client-spec
:CREATED: [2026-04-17 Fri 11:00] :CREATED: [2026-04-17 Fri 11:00]
@@ -22,26 +22,26 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
* Phase B: Protocol (Success Criteria) * Phase B: Protocol (Success Criteria)
** Test Suite Context ** Test Suite Context
#+begin_src lisp :tangle ((concat (uiop:getenv "INSTALL_DIR") "/tests/tui-tests.lisp")) #+begin_src lisp :tangle ((concat (getenv "INSTALL_DIR") "/tests/tui-tests.lisp"))
(defpackage :opencortex-tui-tests (defpackage :opencortex-tui-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:tui-suite)) (:export #:tui-suite))
#+end_src #+end_src
#+begin_src lisp :tangle ((concat (uiop:getenv "INSTALL_DIR") "/tests/tui-tests.lisp")) #+begin_src lisp :tangle ((concat (getenv "INSTALL_DIR") "/tests/tui-tests.lisp"))
(in-package :opencortex-tui-tests) (in-package :opencortex-tui-tests)
#+end_src #+end_src
#+begin_src lisp :tangle ((concat (uiop:getenv "INSTALL_DIR") "/tests/tui-tests.lisp")) #+begin_src lisp :tangle ((concat (getenv "INSTALL_DIR") "/tests/tui-tests.lisp"))
(def-suite tui-suite :description "Verification of the TUI parsing and styling logic") (def-suite tui-suite :description "Verification of the TUI parsing and styling logic")
#+end_src #+end_src
#+begin_src lisp :tangle ((concat (uiop:getenv "INSTALL_DIR") "/tests/tui-tests.lisp")) #+begin_src lisp :tangle ((concat (getenv "INSTALL_DIR") "/tests/tui-tests.lisp"))
(in-suite tui-suite) (in-suite tui-suite)
#+end_src #+end_src
** Command Parsing Tests ** Command Parsing Tests
#+begin_src lisp :tangle ((concat (uiop:getenv "INSTALL_DIR") "/tests/tui-tests.lisp")) #+begin_src lisp :tangle ((concat (getenv "INSTALL_DIR") "/tests/tui-tests.lisp"))
(test test-tui-connection-drop (test test-tui-connection-drop
"Tier 2 Chaos: Verify that handle-return degrades gracefully when the daemon connection is lost." "Tier 2 Chaos: Verify that handle-return degrades gracefully when the daemon connection is lost."
(let ((opencortex.tui::*incoming-msgs* nil) (let ((opencortex.tui::*incoming-msgs* nil)
@@ -57,81 +57,81 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
* Phase C: Implementation (Build) * Phase C: Implementation (Build)
** Package Context ** Package Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(in-package :cl-user) (in-package :cl-user)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defpackage :opencortex.tui (defpackage :opencortex.tui
(:use :cl :croatoan) (:use :cl :croatoan)
(:export :main)) (:export :main))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(in-package :opencortex.tui) (in-package :opencortex.tui)
#+end_src #+end_src
** Global State ** Global State
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *daemon-host* "127.0.0.1") (defvar *daemon-host* "127.0.0.1")
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *daemon-port* 9105) (defvar *daemon-port* 9105)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *socket* nil) (defvar *socket* nil)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *stream* nil) (defvar *stream* nil)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *chat-history* (list) "Full chronological log of messages.") (defvar *chat-history* (list) "Full chronological log of messages.")
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *scroll-index* 0 "Offset for history rendering.") (defvar *scroll-index* 0 "Offset for history rendering.")
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *status-text* "Connecting...") (defvar *status-text* "Connecting...")
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *input-buffer* (make-array 0 :element-type 'char :fill-pointer 0 :adjustable t)) (defvar *input-buffer* (make-array 0 :element-type 'char :fill-pointer 0 :adjustable t))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *command-history* (make-array 0 :element-type 't :fill-pointer 0 :adjustable t)) (defvar *command-history* (make-array 0 :element-type 't :fill-pointer 0 :adjustable t))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *history-index* -1) (defvar *history-index* -1)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *is-running* t) (defvar *is-running* t)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *queue-lock* (bt:make-lock)) (defvar *queue-lock* (bt:make-lock))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defvar *incoming-msgs* nil) (defvar *incoming-msgs* nil)
#+end_src #+end_src
** Utilities ** Utilities
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defun enqueue-msg (msg) (defun enqueue-msg (msg)
"Thread-safe addition to incoming message queue." "Thread-safe addition to incoming message queue."
(bt:with-lock-held (*queue-lock*) (bt:with-lock-held (*queue-lock*)
(setf *incoming-msgs* (append *incoming-msgs* (list msg))))) (setf *incoming-msgs* (append *incoming-msgs* (list msg)))))
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defun dequeue-msgs () (defun dequeue-msgs ()
"Thread-safe retrieval of incoming messages." "Thread-safe retrieval of incoming messages."
(bt:with-lock-held (*queue-lock*) (bt:with-lock-held (*queue-lock*)
@@ -142,7 +142,7 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
#+end_src #+end_src
** Styling Engine ** Styling Engine
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defun get-line-style (text) (defun get-line-style (text)
"Determines croatoan attributes based on content patterns." "Determines croatoan attributes based on content patterns."
(cond (cond
@@ -154,7 +154,7 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
#+end_src #+end_src
** Rendering Orchestrator ** Rendering Orchestrator
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defun render-chat (win) (defun render-chat (win)
"Renders the chat history with scrolling and styling." "Renders the chat history with scrolling and styling."
(clear win) (clear win)
@@ -172,14 +172,14 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
#+end_src #+end_src
** Input Handling ** Input Handling
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defun handle-backspace () (defun handle-backspace ()
"Deletes last character from input buffer." "Deletes last character from input buffer."
(when (> (fill-pointer *input-buffer*) 0) (when (> (fill-pointer *input-buffer*) 0)
(decf (fill-pointer *input-buffer*)))) (decf (fill-pointer *input-buffer*))))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defun handle-return (stream) (defun handle-return (stream)
"Process input buffer as message or command." "Process input buffer as message or command."
(let ((cmd (coerce *input-buffer* 'string))) (let ((cmd (coerce *input-buffer* 'string)))
@@ -200,7 +200,7 @@ A simple MVP console is insufficient for a Lisp Machine. To reach v0.2.0, the TU
#+end_src #+end_src
** Main Entry Point ** Main Entry Point
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/tui-client.lisp") #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/tui-client.lisp")
(defun main () (defun main ()
"Initializes ncurses and starts the TUI event loop." "Initializes ncurses and starts the TUI event loop."
(handler-case (handler-case

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-bouncer.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-bouncer.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: bouncer-agent-skill :ID: bouncer-agent-skill
:CREATED: [2026-04-11 Sat 15:20] :CREATED: [2026-04-11 Sat 15:20]

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-cli-gateway.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-cli-gateway.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: cli-gateway-skill :ID: cli-gateway-skill
:CREATED: [2026-04-13 Mon 17:00] :CREATED: [2026-04-13 Mon 17:00]

View File

@@ -16,26 +16,26 @@ Secrets are appended to `~/.config/opencortex/.env`, while structural metadata i
* Phase B: Protocol (Success Criteria) * Phase B: Protocol (Success Criteria)
** Test Suite Context ** Test Suite Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-config-manager-tests (defpackage :opencortex-config-manager-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:config-suite)) (:export #:config-suite))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name ""))
(in-package :opencortex-config-manager-tests) (in-package :opencortex-config-manager-tests)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name ""))
(def-suite config-suite :description "Verification of the Config Manager skill") (def-suite config-suite :description "Verification of the Config Manager skill")
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name ""))
(in-suite config-suite) (in-suite config-suite)
#+end_src #+end_src
** Registry Tests ** Registry Tests
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/config-manager-tests.lisp" (expand-file-name ""))
(test test-provider-registration (test test-provider-registration
"Verify that multiple providers can be registered and saved." "Verify that multiple providers can be registered and saved."
(let ((opencortex::*providers* nil)) (let ((opencortex::*providers* nil))
@@ -44,36 +44,36 @@ Secrets are appended to `~/.config/opencortex/.env`, while structural metadata i
(test test-get-oc-config-dir-default (test test-get-oc-config-dir-default
"Verify get-oc-config-dir returns XDG-compliant path when env not set." "Verify get-oc-config-dir returns XDG-compliant path when env not set."
(let ((orig-env (uiop:getenv "OC_CONFIG_DIR"))) (let ((orig-env (getenv "OC_CONFIG_DIR")))
(unwind-protect (unwind-protect
(progn (progn
(setf (uiop:getenv "OC_CONFIG_DIR") nil) (setf (getenv "OC_CONFIG_DIR") nil)
(let ((dir (opencortex:get-oc-config-dir))) (let ((dir (opencortex:get-oc-config-dir)))
(is (search ".config/opencortex" (namestring dir))))) (is (search ".config/opencortex" (namestring dir)))))
(if orig-env (if orig-env
(setf (uiop:getenv "OC_CONFIG_DIR") orig-env) (setf (getenv "OC_CONFIG_DIR") orig-env)
(setf (uiop:getenv "OC_CONFIG_DIR") nil))))) (setf (getenv "OC_CONFIG_DIR") nil)))))
(test test-get-oc-config-dir-env-override (test test-get-oc-config-dir-env-override
"Verify get-oc-config-dir uses OC_CONFIG_DIR when set." "Verify get-oc-config-dir uses OC_CONFIG_DIR when set."
(let ((orig-env (uiop:getenv "OC_CONFIG_DIR"))) (let ((orig-env (getenv "OC_CONFIG_DIR")))
(unwind-protect (unwind-protect
(progn (progn
(setf (uiop:getenv "OC_CONFIG_DIR") "/tmp/test-opencortex-config") (setf (getenv "OC_CONFIG_DIR") "/tmp/test-opencortex-config")
(let ((dir (opencortex:get-oc-config-dir))) (let ((dir (opencortex:get-oc-config-dir)))
(is (string= "/tmp/test-opencortex-config/" (namestring dir))))) (is (string= "/tmp/test-opencortex-config/" (namestring dir)))))
(if orig-env (if orig-env
(setf (uiop:getenv "OC_CONFIG_DIR") orig-env) (setf (getenv "OC_CONFIG_DIR") orig-env)
(setf (uiop:getenv "OC_CONFIG_DIR") nil))))) (setf (getenv "OC_CONFIG_DIR") nil)))))
(test test-save-providers-roundtrip (test test-save-providers-roundtrip
"Verify save-providers writes and providers can be reloaded." "Verify save-providers writes and providers can be reloaded."
(let ((opencortex::*providers* nil) (let ((opencortex::*providers* nil)
(test-dir "/tmp/test-opencortex-config/") (test-dir "/tmp/test-opencortex-config/")
(orig-env (uiop:getenv "OC_CONFIG_DIR"))) (orig-env (getenv "OC_CONFIG_DIR")))
(unwind-protect (unwind-protect
(progn (progn
(setf (uiop:getenv "OC_CONFIG_DIR") test-dir) (setf (getenv "OC_CONFIG_DIR") test-dir)
(opencortex:register-provider :openai '(:key "test-key-123" :model "gpt-4")) (opencortex:register-provider :openai '(:key "test-key-123" :model "gpt-4"))
(opencortex:save-providers) (opencortex:save-providers)
(let ((loaded-provs (uiop:read-file-string (merge-pathnames "providers.lisp" (uiop:ensure-directory-pathname test-dir))))) (let ((loaded-provs (uiop:read-file-string (merge-pathnames "providers.lisp" (uiop:ensure-directory-pathname test-dir)))))
@@ -81,8 +81,8 @@ Secrets are appended to `~/.config/opencortex/.env`, while structural metadata i
(is (search "test-key-123" loaded-provs)))) (is (search "test-key-123" loaded-provs))))
(uiop:delete-directory-tree (uiop:ensure-directory-pathname test-dir) :validate t) (uiop:delete-directory-tree (uiop:ensure-directory-pathname test-dir) :validate t)
(if orig-env (if orig-env
(setf (uiop:getenv "OC_CONFIG_DIR") orig-env) (setf (getenv "OC_CONFIG_DIR") orig-env)
(setf (uiop:getenv "OC_CONFIG_DIR") nil))))) (setf (getenv "OC_CONFIG_DIR") nil)))))
(test test-configure-provider-validation (test test-configure-provider-validation
"Verify configure-provider validates required fields." "Verify configure-provider validates required fields."
@@ -95,12 +95,12 @@ Secrets are appended to `~/.config/opencortex/.env`, while structural metadata i
* Phase C: Implementation (Build) * Phase C: Implementation (Build)
** Package Context ** Package Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name ""))
(in-package :opencortex) (in-package :opencortex)
#+end_src #+end_src
** Skill Metadata ** Skill Metadata
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name ""))
(defparameter *skill-config-manager* (defparameter *skill-config-manager*
'(:name "config-manager" '(:name "config-manager"
:description "Manages system settings and LLM provider configurations." :description "Manages system settings and LLM provider configurations."
@@ -110,7 +110,7 @@ Secrets are appended to `~/.config/opencortex/.env`, while structural metadata i
#+end_src #+end_src
** Provider Templates ** Provider Templates
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name ""))
(defvar *provider-templates* (defvar *provider-templates*
'((:ollama . (:name "Ollama (Local)" :fields ((:url :label "URL") (:model :label "Model")) :default-url "http://localhost:11434" :default-model "llama3")) '((:ollama . (:name "Ollama (Local)" :fields ((:url :label "URL") (:model :label "Model")) :default-url "http://localhost:11434" :default-model "llama3"))
(:openrouter . (:name "OpenRouter" :fields ((:key :label "API Key" :secret t) (:model :label "Model")) :default-model "anthropic/claude-3-opus-20240229")) (:openrouter . (:name "OpenRouter" :fields ((:key :label "API Key" :secret t) (:model :label "Model")) :default-model "anthropic/claude-3-opus-20240229"))
@@ -122,12 +122,12 @@ Secrets are appended to `~/.config/opencortex/.env`, while structural metadata i
#+end_src #+end_src
** Registry Persistence ** Registry Persistence
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name ""))
(defvar *providers* nil "Global registry of configured LLM providers.") (defvar *providers* nil "Global registry of configured LLM providers.")
(defun get-oc-config-dir () (defun get-oc-config-dir ()
"Returns the XDG-compliant config directory for OpenCortex." "Returns the XDG-compliant config directory for OpenCortex."
(let ((env (uiop:getenv "OC_CONFIG_DIR"))) (let ((env (getenv "OC_CONFIG_DIR")))
(if (and env (> (length env) 0)) (if (and env (> (length env) 0))
(uiop:ensure-directory-pathname env) (uiop:ensure-directory-pathname env)
(uiop:merge-pathnames* ".config/opencortex/" (user-homedir-pathname))))) (uiop:merge-pathnames* ".config/opencortex/" (user-homedir-pathname)))))
@@ -155,18 +155,18 @@ Secrets are appended to `~/.config/opencortex/.env`, while structural metadata i
(ensure-directories-exist env-file) (ensure-directories-exist env-file)
(with-open-file (out env-file :direction :output :if-exists :append :if-does-not-exist :create) (with-open-file (out env-file :direction :output :if-exists :append :if-does-not-exist :create)
(format out "~a=~a~%" var-name val)) (format out "~a=~a~%" var-name val))
(setf (uiop:getenv var-name) val))) (setf (getenv var-name) val)))
#+end_src #+end_src
** Registry API ** Registry API
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name ""))
(defun register-provider (id config) (defun register-provider (id config)
"Update the global provider registry." "Update the global provider registry."
(setf (getf *providers* id) config)) (setf (getf *providers* id) config))
#+end_src #+end_src
** Setup Wizard Implementation ** Setup Wizard Implementation
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name ""))
(defun configure-provider (id) (defun configure-provider (id)
"Guided configuration for a specific LLM provider template." "Guided configuration for a specific LLM provider template."
(let* ((template (cdr (assoc id *provider-templates*))) (let* ((template (cdr (assoc id *provider-templates*)))
@@ -187,7 +187,7 @@ Secrets are appended to `~/.config/opencortex/.env`, while structural metadata i
(format t "✓ ~a metadata registered.~%" (getf template :name)))) (format t "✓ ~a metadata registered.~%" (getf template :name))))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-config-manager.lisp" (expand-file-name ""))
(defun run-setup-wizard () (defun run-setup-wizard ()
"Entry point for the interactive OpenCortex Lisp Setup Wizard." "Entry point for the interactive OpenCortex Lisp Setup Wizard."
(format t "=== OpenCortex: Advanced Setup Wizard ===~%") (format t "=== OpenCortex: Advanced Setup Wizard ===~%")

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-credentials-vault.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-credentials-vault.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: credentials-vault-skill :ID: credentials-vault-skill
:CREATED: [2026-04-09 Thu] :CREATED: [2026-04-09 Thu]
@@ -107,7 +107,7 @@ This function is the secure getter for all system secrets. It prioritizes the Va
(:matrix-token "MATRIX_ACCESS_TOKEN") (:matrix-token "MATRIX_ACCESS_TOKEN")
(t nil)))) (t nil))))
(when (and env-var (eq type :api-key)) (when (and env-var (eq type :api-key))
(uiop:getenv env-var)))))) (getenv env-var))))))
#+end_src #+end_src
** Persistence (vault-set-secret) ** Persistence (vault-set-secret)
@@ -154,7 +154,7 @@ Retained from the legacy Google skill, this provides the instructions for the au
Note: Tests disabled in jail load. Note: Tests disabled in jail load.
** 1. Unit Tests (FiveAM) ** 1. Unit Tests (FiveAM)
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-credentials-vault.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-credentials-vault.lisp" (expand-file-name ""))
#| #|
(defpackage :opencortex-vault-tests (defpackage :opencortex-vault-tests
(:use :cl :fiveam :opencortex)) (:use :cl :fiveam :opencortex))

View File

@@ -18,26 +18,26 @@ The skill strictly validates the POSIX standard paths resolved during bootstrap,
* Phase B: Protocol (Success Criteria) * Phase B: Protocol (Success Criteria)
** Test Suite Context ** Test Suite Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-diagnostics-tests (defpackage :opencortex-diagnostics-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:diagnostics-suite)) (:export #:diagnostics-suite))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name ""))
(in-package :opencortex-diagnostics-tests) (in-package :opencortex-diagnostics-tests)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name ""))
(def-suite diagnostics-suite :description "Verification of the Diagnostics skill") (def-suite diagnostics-suite :description "Verification of the Diagnostics skill")
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name ""))
(in-suite diagnostics-suite) (in-suite diagnostics-suite)
#+end_src #+end_src
** Dependency Tests ** Dependency Tests
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/diagnostics-tests.lisp" (expand-file-name ""))
(test test-dependency-check-fail (test test-dependency-check-fail
"Verify that missing binaries are correctly identified as failures." "Verify that missing binaries are correctly identified as failures."
(let ((opencortex::*doctor-required-binaries* '("non-existent-binary-123"))) (let ((opencortex::*doctor-required-binaries* '("non-existent-binary-123")))
@@ -47,12 +47,12 @@ The skill strictly validates the POSIX standard paths resolved during bootstrap,
* Phase C: Implementation (Build) * Phase C: Implementation (Build)
** Package Context ** Package Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name ""))
(in-package :opencortex) (in-package :opencortex)
#+end_src #+end_src
** Skill Metadata ** Skill Metadata
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name ""))
(defparameter *skill-diagnostics* (defparameter *skill-diagnostics*
'(:name "diagnostics" '(:name "diagnostics"
:description "Performs system health checks and environment validation." :description "Performs system health checks and environment validation."
@@ -62,13 +62,13 @@ The skill strictly validates the POSIX standard paths resolved during bootstrap,
#+end_src #+end_src
** Global Configuration ** Global Configuration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name ""))
(defvar *doctor-required-binaries* '("sbcl" "emacs" "git" "socat" "nc") (defvar *doctor-required-binaries* '("sbcl" "emacs" "git" "socat" "nc")
"List of external binaries required for full system operation.") "List of external binaries required for full system operation.")
#+end_src #+end_src
** Dependency Verification ** Dependency Verification
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name ""))
(defun doctor-check-dependencies () (defun doctor-check-dependencies ()
"Verifies that required external binaries are available in the PATH via a shell probe." "Verifies that required external binaries are available in the PATH via a shell probe."
(let ((all-ok t)) (let ((all-ok t))
@@ -86,15 +86,15 @@ The skill strictly validates the POSIX standard paths resolved during bootstrap,
#+end_src #+end_src
** Environment & XDG Validation ** Environment & XDG Validation
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name ""))
(defun doctor-check-env () (defun doctor-check-env ()
"Validates XDG directories and environment configuration against the POSIX standard." "Validates XDG directories and environment configuration against the POSIX standard."
(harness-log "DOCTOR: Checking XDG environment...") (harness-log "DOCTOR: Checking XDG environment...")
(let ((all-ok t) (let ((all-ok t)
(config-dir (uiop:getenv "OC_CONFIG_DIR")) (config-dir (getenv "OC_CONFIG_DIR"))
(data-dir (uiop:getenv "OC_DATA_DIR")) (data-dir (getenv "OC_DATA_DIR"))
(state-dir (uiop:getenv "OC_STATE_DIR")) (state-dir (getenv "OC_STATE_DIR"))
(memex-dir (uiop:getenv "MEMEX_DIR"))) (memex-dir (getenv "MEMEX_DIR")))
(flet ((check-dir (name path critical) (flet ((check-dir (name path critical)
(if (and path (> (length path) 0)) (if (and path (> (length path) 0))
@@ -115,11 +115,11 @@ The skill strictly validates the POSIX standard paths resolved during bootstrap,
#+end_src #+end_src
** LLM Connectivity ** LLM Connectivity
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name ""))
(defun doctor-check-llm () (defun doctor-check-llm ()
"Tests connectivity to primary LLM providers. Non-critical fallback allowed." "Tests connectivity to primary LLM providers. Non-critical fallback allowed."
(harness-log "DOCTOR: Checking LLM connectivity...") (harness-log "DOCTOR: Checking LLM connectivity...")
(let ((openrouter-key (uiop:getenv "OPENROUTER_API_KEY"))) (let ((openrouter-key (getenv "OPENROUTER_API_KEY")))
(if (and openrouter-key (> (length openrouter-key) 0)) (if (and openrouter-key (> (length openrouter-key) 0))
(progn (progn
(harness-log " [OK] OpenRouter API Key detected.") (harness-log " [OK] OpenRouter API Key detected.")
@@ -130,7 +130,7 @@ The skill strictly validates the POSIX standard paths resolved during bootstrap,
#+end_src #+end_src
** Orchestration ** Orchestration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name ""))
(defun doctor-run-all () (defun doctor-run-all ()
"Executes the full diagnostic suite and returns T if system is healthy." "Executes the full diagnostic suite and returns T if system is healthy."
(harness-log "==================================================") (harness-log "==================================================")
@@ -150,7 +150,7 @@ The skill strictly validates the POSIX standard paths resolved during bootstrap,
#+end_src #+end_src
** CLI Entry Point ** CLI Entry Point
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-diagnostics.lisp" (expand-file-name ""))
(defun doctor-main () (defun doctor-main ()
"Entry point for the 'doctor' CLI command." "Entry point for the 'doctor' CLI command."
(if (doctor-run-all) (if (doctor-run-all)

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-emacs-edit.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-emacs-edit.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: emacs-edit-skill :ID: emacs-edit-skill
:CREATED: [2026-04-23 Thu] :CREATED: [2026-04-23 Thu]
@@ -390,7 +390,7 @@ Use this AFTER modifications to save changes."
#+end_src #+end_src
* Phase E: Chaos (Verification) * Phase E: Chaos (Verification)
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/emacs-edit-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/emacs-edit-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-emacs-edit-tests (defpackage :opencortex-emacs-edit-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:emacs-edit-suite)) (:export #:emacs-edit-suite))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: 37f2b59f-4537-4cca-ac7f-5c24b9e2e773 :ID: 37f2b59f-4537-4cca-ac7f-5c24b9e2e773
:CREATED: [2026-03-30 Mon 21:16] :CREATED: [2026-03-30 Mon 21:16]
@@ -57,17 +57,17 @@ Every significant fix or architectural decision MUST be documented in an org fil
* Enforcement Implementation * Enforcement Implementation
** Package Context ** Package Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name ""))
(in-package :opencortex) (in-package :opencortex)
#+end_src #+end_src
** Global Configuration ** Global Configuration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name ""))
(defvar *engineering-std-project-root* nil (defvar *engineering-std-project-root* nil
"Path to the project root for enforcement checks.") "Path to the project root for enforcement checks.")
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name ""))
(defstruct engineering-violation (defstruct engineering-violation
(phase nil) (phase nil)
(rule nil) (rule nil)
@@ -76,7 +76,7 @@ Every significant fix or architectural decision MUST be documented in an org fil
#+end_src #+end_src
** CDD Utilities: Tier 1 ** CDD Utilities: Tier 1
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name ""))
(defun check-structural-balance (file-path) (defun check-structural-balance (file-path)
"Tier 1 Chaos: Verifies that a Lisp file is syntactically balanced." "Tier 1 Chaos: Verifies that a Lisp file is syntactically balanced."
(handler-case (handler-case
@@ -90,7 +90,7 @@ Every significant fix or architectural decision MUST be documented in an org fil
#+end_src #+end_src
** Git Protocol ** Git Protocol
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name ""))
(defun verify-git-clean-p (&optional (dir *engineering-std-project-root*)) (defun verify-git-clean-p (&optional (dir *engineering-std-project-root*))
"Returns T if the git repository at DIR has no uncommitted changes." "Returns T if the git repository at DIR has no uncommitted changes."
(when dir (when dir
@@ -101,42 +101,42 @@ Every significant fix or architectural decision MUST be documented in an org fil
#+end_src #+end_src
** Initializer ** Initializer
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name ""))
(defun engineering-std-init () (defun engineering-std-init ()
"Initialize the enforcement system." "Initialize the enforcement system."
(let ((env-root (or (uiop:getenv "OC_DATA_DIR") (let ((env-root (or (getenv "OC_DATA_DIR")
"/home/user/.local/share/opencortex"))) "/home/user/.local/share/opencortex")))
(setf *engineering-std-project-root* (uiop:ensure-directory-pathname env-root)) (setf *engineering-std-project-root* (uiop:ensure-directory-pathname env-root))
(harness-log "ENGINEERING STANDARDS: CDD Protocol Active."))) (harness-log "ENGINEERING STANDARDS: CDD Protocol Active.")))
#+end_src #+end_src
;; Auto-initialize on load ;; Auto-initialize on load
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-engineering-standards.lisp" (expand-file-name ""))
(engineering-std-init) (engineering-std-init)
#+end_src #+end_src
* Test Suite * Test Suite
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-engineering-standards-tests (defpackage :opencortex-engineering-standards-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:engineering-standards-suite)) (:export #:engineering-standards-suite))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name ""))
(in-package :opencortex-engineering-standards-tests) (in-package :opencortex-engineering-standards-tests)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name ""))
(def-suite engineering-standards-suite (def-suite engineering-standards-suite
:description "Tests for Engineering Standards enforcement") :description "Tests for Engineering Standards enforcement")
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name ""))
(in-suite engineering-standards-suite) (in-suite engineering-standards-suite)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/engineering-standards-tests.lisp" (expand-file-name ""))
(test git-clean-check-clean (test git-clean-check-clean
"verify-git-clean-p returns T when git tree is clean." "verify-git-clean-p returns T when git tree is clean."
(let ((tmp-dir "/tmp/eng-std-test-clean/")) (let ((tmp-dir "/tmp/eng-std-test-clean/"))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-gardener.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-gardener.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: gardener-skill :ID: gardener-skill
:CREATED: [2026-04-13 Mon 18:50] :CREATED: [2026-04-13 Mon 18:50]

View File

@@ -13,26 +13,26 @@ In a traditional AI wrapper, the user manually edits a config file to add a bot
* Phase B: Protocol (Success Criteria) * Phase B: Protocol (Success Criteria)
** Test Suite Context ** Test Suite Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-gateway-manager-tests (defpackage :opencortex-gateway-manager-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:gateway-suite)) (:export #:gateway-suite))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name ""))
(in-package :opencortex-gateway-manager-tests) (in-package :opencortex-gateway-manager-tests)
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name ""))
(def-suite gateway-suite :description "Verification of the Gateway Manager skill") (def-suite gateway-suite :description "Verification of the Gateway Manager skill")
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name ""))
(in-suite gateway-suite) (in-suite gateway-suite)
#+end_src #+end_src
** Logic Tests ** Logic Tests
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/gateway-manager-tests.lisp" (expand-file-name ""))
(test test-gateway-registration (test test-gateway-registration
"Verify that the skill can register a new gateway metadata block." "Verify that the skill can register a new gateway metadata block."
(let ((opencortex::*gateways* nil)) (let ((opencortex::*gateways* nil))
@@ -51,12 +51,12 @@ In a traditional AI wrapper, the user manually edits a config file to add a bot
* Phase C: Implementation (Build) * Phase C: Implementation (Build)
** Package Context ** Package Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name ""))
(in-package :opencortex) (in-package :opencortex)
#+end_src #+end_src
** Capability Definition ** Capability Definition
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name ""))
(defparameter *skill-gateway-manager* (defparameter *skill-gateway-manager*
'(:name "gateway-manager" '(:name "gateway-manager"
:description "Manages connections to external chat platforms." :description "Manages connections to external chat platforms."
@@ -66,12 +66,12 @@ In a traditional AI wrapper, the user manually edits a config file to add a bot
#+end_src #+end_src
** Registry Persistence ** Registry Persistence
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name ""))
(defvar *gateways* nil "The internal registry of configured gateways.") (defvar *gateways* nil "The internal registry of configured gateways.")
#+end_src #+end_src
** Persistence Stubs ** Persistence Stubs
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name ""))
(defun save-gateways () (defun save-gateways ()
"Persist gateway metadata to XDG Config directory." "Persist gateway metadata to XDG Config directory."
(let ((path (merge-pathnames "gateways.lisp" (get-oc-config-dir)))) (let ((path (merge-pathnames "gateways.lisp" (get-oc-config-dir))))
@@ -81,14 +81,14 @@ In a traditional AI wrapper, the user manually edits a config file to add a bot
#+end_src #+end_src
** Registration Logic ** Registration Logic
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name ""))
(defun skill-gateway-register (platform metadata) (defun skill-gateway-register (platform metadata)
"Internal function to update the gateway registry." "Internal function to update the gateway registry."
(setf (getf *gateways* platform) metadata)) (setf (getf *gateways* platform) metadata))
#+end_src #+end_src
** Telegram Verification ** Telegram Verification
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name ""))
(defun skill-gateway-verify-telegram (token) (defun skill-gateway-verify-telegram (token)
"Verifies a Telegram bot token via the getMe API." "Verifies a Telegram bot token via the getMe API."
(let ((url (format nil "https://api.telegram.org/bot~a/getMe" token))) (let ((url (format nil "https://api.telegram.org/bot~a/getMe" token)))
@@ -103,7 +103,7 @@ In a traditional AI wrapper, the user manually edits a config file to add a bot
#+end_src #+end_src
** Linkage Command ** Linkage Command
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name ""))
(defun skill-gateway-link (platform token) (defun skill-gateway-link (platform token)
"Primary capability to link a new platform. Returns status plist." "Primary capability to link a new platform. Returns status plist."
(harness-log "GATEWAY: Attempting to link ~a..." platform) (harness-log "GATEWAY: Attempting to link ~a..." platform)
@@ -120,7 +120,7 @@ In a traditional AI wrapper, the user manually edits a config file to add a bot
#+end_src #+end_src
** CLI Main Wrapper ** CLI Main Wrapper
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-gateway-manager.lisp" (expand-file-name ""))
(defun gateway-manager-main (platform token) (defun gateway-manager-main (platform token)
"Main entry point for CLI-driven linkage." "Main entry point for CLI-driven linkage."
(if (and platform token) (if (and platform token)

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-homoiconic-memory.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-homoiconic-memory.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: homoiconic-memory-skill :ID: homoiconic-memory-skill
:CREATED: [2026-04-10 Fri] :CREATED: [2026-04-10 Fri]

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-lisp-utils.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-lisp-utils.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: lisp-utils-skill :ID: lisp-utils-skill
:CREATED: [2026-04-23 Thu] :CREATED: [2026-04-23 Thu]
@@ -159,7 +159,7 @@ Returns (VALUES t nil) if clean, or (VALUES nil error-message nil nil)."
* Test Suite * Test Suite
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/lisp-utils-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/lisp-utils-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-lisp-utils-tests (defpackage :opencortex-lisp-utils-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:lisp-utils-suite)) (:export #:lisp-utils-suite))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-literate-programming.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-literate-programming.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: literate-programming-skill-2026 :ID: literate-programming-skill-2026
:CREATED: [2026-04-25 Sat] :CREATED: [2026-04-25 Sat]
@@ -225,8 +225,8 @@ The LP skill runs at priority 1100 (just below engineering-standards at 1000).
(defun lp-init () (defun lp-init ()
"Initialize the LP system with project root." "Initialize the LP system with project root."
(unless *lp-initialized* (unless *lp-initialized*
(let ((env-root (or (uiop:getenv "OPENCORTEX_ROOT") (let ((env-root (or (getenv "OPENCORTEX_ROOT")
(uiop:getenv "MEMEX_DIR") (getenv "MEMEX_DIR")
"/home/user/memex/projects/opencortex"))) "/home/user/memex/projects/opencortex")))
(lp-set-project-root env-root) (lp-set-project-root env-root)
(setf *lp-initialized* t) (setf *lp-initialized* t)
@@ -241,7 +241,7 @@ The LP skill runs at priority 1100 (just below engineering-standards at 1000).
These tests verify the LP enforcement logic. Run with: These tests verify the LP enforcement logic. Run with:
~(fiveam:run! 'literate-programming-suite)~ ~(fiveam:run! 'literate-programming-suite)~
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/literate-programming-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/literate-programming-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-literate-programming-tests (defpackage :opencortex-literate-programming-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:literate-programming-suite)) (:export #:literate-programming-suite))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-llama-backend.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-llama-backend.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: llama-backend-skill :ID: llama-backend-skill
:CREATED: [2026-04-17 Fri 20:00] :CREATED: [2026-04-17 Fri 20:00]
@@ -15,7 +15,7 @@ The *Llama.cpp Backend* allows the OpenCortex to use local, air-gapped inference
This skill acts as a proxy between the OpenCortex kernel and the Lisp-agnostic `llama.cpp` REST API. It implements the standard backend signature required by `register-probabilistic-backend`. This skill acts as a proxy between the OpenCortex kernel and the Lisp-agnostic `llama.cpp` REST API. It implements the standard backend signature required by `register-probabilistic-backend`.
** 2. Semantic Interfaces ** 2. Semantic Interfaces
- Endpoint: `(uiop:getenv "LLAMACPP_ENDPOINT")` (e.g., "http://10.10.10.x:8080") - Endpoint: `(getenv "LLAMACPP_ENDPOINT")` (e.g., "http://10.10.10.x:8080")
- Method: `POST /completion` - Method: `POST /completion`
- Response: JSON (parsed into Lisp) - Response: JSON (parsed into Lisp)
@@ -30,7 +30,7 @@ This skill acts as a proxy between the OpenCortex kernel and the Lisp-agnostic `
#+begin_src lisp #+begin_src lisp
(defun llama-inference (prompt system-prompt &key (model "local-model")) (defun llama-inference (prompt system-prompt &key (model "local-model"))
"Sends a completion request to the local llama.cpp server." "Sends a completion request to the local llama.cpp server."
(let ((endpoint (uiop:getenv "LLAMACPP_ENDPOINT"))) (let ((endpoint (getenv "LLAMACPP_ENDPOINT")))
(unless endpoint (unless endpoint
(harness-log "LLAMA ERROR: LLAMACPP_ENDPOINT not set in environment.") (harness-log "LLAMA ERROR: LLAMACPP_ENDPOINT not set in environment.")
(return-from llama-inference (list :error "LLAMACPP_ENDPOINT_MISSING"))) (return-from llama-inference (list :error "LLAMACPP_ENDPOINT_MISSING")))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: llm-gateway-spec :ID: llm-gateway-spec
:CREATED: [2026-04-10 Thu] :CREATED: [2026-04-10 Thu]
@@ -11,7 +11,7 @@
The *LLM Gateway* skill provides a unified interface for interacting with multiple Large Language Model providers. The *LLM Gateway* skill provides a unified interface for interacting with multiple Large Language Model providers.
* Test Suite * Test Suite
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/llm-gateway-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/llm-gateway-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-llm-gateway-tests (defpackage :opencortex-llm-gateway-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:llm-gateway-suite)) (:export #:llm-gateway-suite))
@@ -24,10 +24,10 @@ The *LLM Gateway* skill provides a unified interface for interacting with multip
(test test-llm-gateway-timeout (test test-llm-gateway-timeout
"Tier 2 Chaos: Verify that LLM Gateway handles connection failures gracefully." "Tier 2 Chaos: Verify that LLM Gateway handles connection failures gracefully."
;; Point to a non-existent port to force a connection error ;; Point to a non-existent port to force a connection error
(let ((old-host (uiop:getenv "OLLAMA_HOST"))) (let ((old-host (getenv "OLLAMA_HOST")))
(unwind-protect (unwind-protect
(progn (progn
(setf (uiop:getenv "OLLAMA_HOST") "localhost:1") (setf (getenv "OLLAMA_HOST") "localhost:1")
(let ((fn (or (find-symbol "EXECUTE-LLM-REQUEST" :opencortex.skills.org-skill-llm-gateway) (let ((fn (or (find-symbol "EXECUTE-LLM-REQUEST" :opencortex.skills.org-skill-llm-gateway)
(find-symbol "EXECUTE-LLM-REQUEST" :opencortex)))) (find-symbol "EXECUTE-LLM-REQUEST" :opencortex))))
(if fn (if fn
@@ -35,18 +35,18 @@ The *LLM Gateway* skill provides a unified interface for interacting with multip
(is (eq (getf result :status) :error)) (is (eq (getf result :status) :error))
(is (uiop:string-prefix-p "Ollama Failure" (getf result :message)))) (is (uiop:string-prefix-p "Ollama Failure" (getf result :message))))
(fail "Could not find EXECUTE-LLM-REQUEST symbol")))) (fail "Could not find EXECUTE-LLM-REQUEST symbol"))))
(setf (uiop:getenv "OLLAMA_HOST") old-host)))) (setf (getenv "OLLAMA_HOST") old-host))))
#+end_src #+end_src
* Implementation * Implementation
** Package Context ** Package Context
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name ""))
(in-package :opencortex) (in-package :opencortex)
#+end_src #+end_src
** Skill Metadata ** Skill Metadata
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name ""))
(defparameter *skill-llm-gateway* (defparameter *skill-llm-gateway*
'(:name "llm-gateway" '(:name "llm-gateway"
:description "Unified provider-agnostic LLM interface." :description "Unified provider-agnostic LLM interface."
@@ -56,15 +56,15 @@ The *LLM Gateway* skill provides a unified interface for interacting with multip
#+end_src #+end_src
** Request Execution ** Request Execution
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name ""))
(defun execute-llm-request (&key prompt system-prompt provider model) (defun execute-llm-request (&key prompt system-prompt provider model)
"Generic executor for all LLM providers." "Generic executor for all LLM providers."
(let* ((active-provider (or provider :ollama)) (let* ((active-provider (or provider :ollama))
(api-key (uiop:getenv (format nil "~:@(~a_API_KEY~)" active-provider))) (api-key (getenv (format nil "~:@(~a_API_KEY~)" active-provider)))
(full-prompt (if system-prompt (format nil "~a~%~%~a" system-prompt prompt) prompt))) (full-prompt (if system-prompt (format nil "~a~%~%~a" system-prompt prompt) prompt)))
(case active-provider (case active-provider
(:ollama (:ollama
(let* ((host (or (uiop:getenv "OLLAMA_HOST") "localhost:11434")) (let* ((host (or (getenv "OLLAMA_HOST") "localhost:11434"))
(url (format nil "http://~a/api/generate" host)) (url (format nil "http://~a/api/generate" host))
(body (cl-json:encode-json-to-string `((model . ,(or model "llama3")) (prompt . ,full-prompt) (stream . :false))))) (body (cl-json:encode-json-to-string `((model . ,(or model "llama3")) (prompt . ,full-prompt) (stream . :false)))))
(handler-case (handler-case
@@ -76,13 +76,13 @@ The *LLM Gateway* skill provides a unified interface for interacting with multip
#+end_src #+end_src
** Cognitive Tools ** Cognitive Tools
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name ""))
(def-cognitive-tool :get-ollama-embedding (def-cognitive-tool :get-ollama-embedding
"Generates vector embeddings via Ollama API." "Generates vector embeddings via Ollama API."
((:text :type :string :description "Text to embed.")) ((:text :type :string :description "Text to embed."))
:body (lambda (args) :body (lambda (args)
(let ((text (getf args :text))) (let ((text (getf args :text)))
(let* ((host (or (uiop:getenv "OLLAMA_HOST") "localhost:11434")) (let* ((host (or (getenv "OLLAMA_HOST") "localhost:11434"))
(url (format nil "http://~a/api/embeddings" host)) (url (format nil "http://~a/api/embeddings" host))
(body (cl-json:encode-json-to-string `((model . "nomic-embed-text") (prompt . ,text))))) (body (cl-json:encode-json-to-string `((model . "nomic-embed-text") (prompt . ,text)))))
(handler-case (handler-case
@@ -92,7 +92,7 @@ The *LLM Gateway* skill provides a unified interface for interacting with multip
(error (c) (harness-log "OLLAMA EMBED ERROR: ~a" c) nil)))))) (error (c) (harness-log "OLLAMA EMBED ERROR: ~a" c) nil))))))
#+end_src #+end_src
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name ""))
(def-cognitive-tool :ask-llm (def-cognitive-tool :ask-llm
"Unified interface for interacting with LLM providers." "Unified interface for interacting with LLM providers."
((:prompt :type :string :description "The user prompt") ((:prompt :type :string :description "The user prompt")
@@ -107,7 +107,7 @@ The *LLM Gateway* skill provides a unified interface for interacting with multip
#+end_src #+end_src
** Skill Registration ** Skill Registration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-llm-gateway.lisp" (expand-file-name ""))
(defskill :skill-llm-gateway (defskill :skill-llm-gateway
:priority 50 :priority 50
:trigger (lambda (ctx) (declare (ignore ctx)) t) :trigger (lambda (ctx) (declare (ignore ctx)) t)

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-peripheral-vision.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-peripheral-vision.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: org-skill-peripheral-vision :ID: org-skill-peripheral-vision
:CREATED: [2026-04-12 Sun 14:15] :CREATED: [2026-04-12 Sun 14:15]

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-policy.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-policy.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: 47425a43-2be0-423c-8509-22592cfe9c9e :ID: 47425a43-2be0-423c-8509-22592cfe9c9e
:CREATED: [2026-04-07 Tue 12:57] :CREATED: [2026-04-07 Tue 12:57]
@@ -50,7 +50,7 @@ Every skill executes within its own jailed package namespace, inheriting core ha
#+end_src #+end_src
* Global Policy Configuration * Global Policy Configuration
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-policy.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-policy.lisp" (expand-file-name ""))
(defvar *policy-invariant-priorities* (defvar *policy-invariant-priorities*
'((:transparency . 500) '((:transparency . 500)
(:autonomy . 400) (:autonomy . 400)

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-protocol-validator.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-protocol-validator.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: org-skill-communication-protocol-validator :ID: org-skill-communication-protocol-validator
:CREATED: [2026-04-12 Sun 14:35] :CREATED: [2026-04-12 Sun 14:35]

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-scribe.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-scribe.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: scribe-skill :ID: scribe-skill
:CREATED: [2026-04-13 Mon 18:40] :CREATED: [2026-04-13 Mon 18:40]

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-self-edit.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-self-edit.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: self-edit-001 :ID: self-edit-001
:END: :END:
@@ -239,7 +239,7 @@ Swap compiled skill files without breaking active sockets.
* Phase E: Verification * Phase E: Verification
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/self-edit-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/self-edit-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-self-edit-tests (defpackage :opencortex-self-edit-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:self-edit-suite)) (:export #:self-edit-suite))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-self-fix.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-self-fix.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: 65891ce2-a465-49e6-a0c1-be13d3288d55 :ID: 65891ce2-a465-49e6-a0c1-be13d3288d55
:CREATED: [2026-03-30 Mon 21:16] :CREATED: [2026-03-30 Mon 21:16]

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-shell-actuator.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-shell-actuator.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: shell-actuator-skill :ID: shell-actuator-skill
:CREATED: [2026-04-12 Sun] :CREATED: [2026-04-12 Sun]
@@ -12,7 +12,7 @@ The *Shell Actuator* provides a controlled interface for the OpenCortex to execu
* Implementation * Implementation
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-shell-actuator.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-shell-actuator.lisp" (expand-file-name ""))
(in-package :opencortex) (in-package :opencortex)
(defparameter *allowed-commands* '("ls" "git" "rg" "grep" "date" "echo" "cat" "node" "python3" "sbcl")) (defparameter *allowed-commands* '("ls" "git" "rg" "grep" "date" "echo" "cat" "node" "python3" "sbcl"))

View File

@@ -1,4 +1,4 @@
#+PROPERTY: header-args:lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/org-skill-tool-permissions.lisp" (expand-file-name "")) #+PROPERTY: header-args:lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/org-skill-tool-permissions.lisp" (expand-file-name ""))
:PROPERTIES: :PROPERTIES:
:ID: tool-permissions-skill-001 :ID: tool-permissions-skill-001
:CREATED: [2026-04-23 Thu] :CREATED: [2026-04-23 Thu]
@@ -56,12 +56,12 @@ Tool permissions and embedding generation via multiple providers.
((:text :type :string :description "Text to embed.")) ((:text :type :string :description "Text to embed."))
:body (lambda (args) :body (lambda (args)
(let* ((text (getf args :text)) (let* ((text (getf args :text))
(provider (or (uiop:getenv "EMBEDDING_PROVIDER") "ollama")) (provider (or (getenv "EMBEDDING_PROVIDER") "ollama"))
(model (or (uiop:getenv "EMBEDDING_MODEL") "nomic-embed-text")) (model (or (getenv "EMBEDDING_MODEL") "nomic-embed-text"))
(embedding nil)) (embedding nil))
(cond (cond
((string= provider "ollama") ((string= provider "ollama")
(let* ((host (or (uiop:getenv "OLLAMA_HOST") "localhost:11434")) (let* ((host (or (getenv "OLLAMA_HOST") "localhost:11434"))
(url (format nil "http://~a/api/embeddings" host)) (url (format nil "http://~a/api/embeddings" host))
(body (cl-json:encode-json-to-string `((model . ,model) (prompt . ,text))))) (body (cl-json:encode-json-to-string `((model . ,model) (prompt . ,text)))))
(handler-case (handler-case
@@ -71,7 +71,7 @@ Tool permissions and embedding generation via multiple providers.
(when vec (setf embedding vec))) (when vec (setf embedding vec)))
(error (c) (harness-log "EMBEDDING: Ollama failed: ~a" c))))) (error (c) (harness-log "EMBEDDING: Ollama failed: ~a" c)))))
((string= provider "llama.cpp") ((string= provider "llama.cpp")
(let* ((host (or (uiop:getenv "LLAMA_HOST") "localhost:8080")) (let* ((host (or (getenv "LLAMA_HOST") "localhost:8080"))
(url (format nil "http://~a/v1/embeddings" host)) (url (format nil "http://~a/v1/embeddings" host))
(body (cl-json:encode-json-to-string `((model . ,model) (input . ,text))))) (body (cl-json:encode-json-to-string `((model . ,model) (input . ,text)))))
(handler-case (handler-case
@@ -135,7 +135,7 @@ Tool permissions and embedding generation via multiple providers.
These tests verify tool permissions. Run with: These tests verify tool permissions. Run with:
~(fiveam:run! 'tool-permissions-suite)~ ~(fiveam:run! 'tool-permissions-suite)~
#+begin_src lisp :tangle (concat (uiop:getenv "INSTALL_DIR") "/skills/tool-permissions-tests.lisp" (expand-file-name "")) #+begin_src lisp :tangle (concat (getenv "INSTALL_DIR") "/skills/tool-permissions-tests.lisp" (expand-file-name ""))
(defpackage :opencortex-tool-permissions-tests (defpackage :opencortex-tool-permissions-tests
(:use :cl :fiveam :opencortex) (:use :cl :fiveam :opencortex)
(:export #:tool-permissions-suite)) (:export #:tool-permissions-suite))