feat(core): Skills consolidation and v0.2.0 TUI integration

- NEW: org-skill-utils-lisp (consolidated from org-skill-lisp-utils)
  * 3-phase validation: structural, syntactic, semantic
  * Sandboxed eval, AST extraction/injection/wrapping
  * Format, list-definitions utilities

- NEW: org-skill-utils-org (consolidated from org-skill-emacs-edit)
  * Read/update/delete org headlines
  * Property management, TODO state handling
  * ID-link and internal link support

- DELETE: org-skill-lisp-utils (merged into utils-lisp)
- DELETE: org-skill-emacs-edit (merged into utils-org)
- RENAME: run-all-tests.lisp -> run-tests.lisp

- HARDEN: Skill loader with improved lisp keyword handling
- FIX: Package jailing issues with def-cognitive-tool macro conflicts
- ADD: Setup wizard (opencortex setup) and doctor (opencortex doctor)
- ADD: TUI client with Croatoan for native terminal rendering

- REMOVE: Dynamic loading from opencortex.asd (use :force t instead)
- CLEANUP: Test file consolidation (removed duplicate test suites)

Co-authored-by: Agent <agent@memex>
This commit is contained in:
2026-04-30 10:52:20 -04:00
parent c0d3f066e8
commit 6a6f4479ac
95 changed files with 2069 additions and 4552 deletions

View File

@@ -24,65 +24,58 @@ Common Lisp's `getenv` is strictly typed in SBCL. The Doctor must ensure that mi
* Phase B: Protocol (Success Criteria)
** Package Context
#+begin_src lisp :tangle doctor.lisp (concat (concat (or (getenv "INSTALL_DIR ". "/harness "/tests)
#+begin_src lisp :tangle ../tests/doctor-tests.lisp
(defpackage :opencortex-doctor-tests
(:use :cl :fiveam :opencortex)
(:export #:doctor-suite))
#+end_src
#+begin_src lisp :tangle doctor.lisp (concat (concat (or (getenv "INSTALL_DIR ". "/harness "/tests)
(in-package :opencortex-doctor-tests)
#+end_src
#+begin_src lisp :tangle doctor.lisp (concat (concat (or (getenv "INSTALL_DIR ". "/harness "/tests)
(def-suite doctor-suite :description "Verification of the System Doctor diagnostic logic
#+end_src
#+begin_src lisp :tangle doctor.lisp (concat (concat (or (getenv "INSTALL_DIR ". "/harness "/tests)
(def-suite doctor-suite :description "Verification of the System Doctor diagnostic logic")
(in-suite doctor-suite)
#+end_src
** Dependency Tests
#+begin_src lisp :tangle doctor.lisp (concat (concat (or (getenv "INSTALL_DIR ". "/harness "/tests)
#+begin_src lisp :tangle ../tests/doctor-tests.lisp
(test test-dependency-check-fail
"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")))
(is (null (opencortex:doctor-check-dependencies)))))
#+end_src
** Environment Tests
#+begin_src lisp :tangle doctor.lisp (concat (concat (or (getenv "INSTALL_DIR ". "/harness "/tests)
#+begin_src lisp :tangle ../tests/doctor-tests.lisp
(test test-env-validation-fail
"Verify that an invalid MEMEX_DIR triggers a critical failure."
(let ((old-m (getenv "MEMEX_DIR)
(old-s (getenv "SKILLS_DIR))
(let ((old-m (uiop:getenv "MEMEX_DIR"))
(old-s (uiop:getenv "SKILLS_DIR")))
(unwind-protect
(progn
(setf (getenv "MEMEX_DIR "/non/existent/path/999
(setf (uiop:getenv "MEMEX_DIR") "/non/existent/path/999")
(is (null (opencortex:doctor-check-env))))
(setf (getenv "MEMEX_DIR (or old-m
(setf (getenv "SKILLS_DIR (or old-s )))
(setf (uiop:getenv "MEMEX_DIR") (or old-m ""))
(setf (uiop:getenv "SKILLS_DIR") (or old-s "")))))
#+end_src
* Phase C: Implementation (Build)
** Package Context
#+begin_src lisp :tangle doctor.lisp )
#+begin_src lisp
(in-package :opencortex)
#+end_src
** Global Configuration
#+begin_src lisp :tangle doctor.lisp )
(defvar *doctor-required-binaries* '("sbcl" "emacs" "git" "socat" "nc
"List of external binaries required for full system operation.
#+begin_src lisp
(defvar *doctor-required-binaries* '("sbcl" "emacs" "git" "socat" "nc")
"List of external binaries required for full system operation.")
#+end_src
** Dependency Verification
#+begin_src lisp :tangle doctor.lisp )
#+begin_src lisp
(defun doctor-check-dependencies ()
"Verifies that required external binaries are available in the PATH via a shell probe."
(let ((all-ok t))
(harness-log "DOCTOR: Checking system dependencies...
(harness-log "DOCTOR: Checking system dependencies...")
(dolist (dep *doctor-required-binaries*)
(let ((path (ignore-errors
(uiop:run-program (list "which" dep)
@@ -96,15 +89,15 @@ Common Lisp's `getenv` is strictly typed in SBCL. The Doctor must ensure that mi
#+end_src
** Environment & XDG Validation
#+begin_src lisp :tangle doctor.lisp )
#+begin_src lisp
(defun doctor-check-env ()
"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)
(config-dir (getenv "OC_CONFIG_DIR)
(data-dir (getenv "OC_DATA_DIR)
(state-dir (getenv "OC_STATE_DIR)
(memex-dir (getenv "MEMEX_DIR))
(config-dir (uiop:getenv "OC_CONFIG_DIR"))
(data-dir (uiop:getenv "OC_DATA_DIR"))
(state-dir (uiop:getenv "OC_STATE_DIR"))
(memex-dir (uiop:getenv "MEMEX_DIR")))
(flet ((check-dir (name path critical)
(if (and path (> (length path) 0))
@@ -125,42 +118,43 @@ Common Lisp's `getenv` is strictly typed in SBCL. The Doctor must ensure that mi
#+end_src
** LLM Connectivity
#+begin_src lisp :tangle doctor.lisp )
#+begin_src lisp
(defun doctor-check-llm ()
"Tests connectivity to primary LLM providers. Non-critical fallback allowed."
(harness-log "DOCTOR: Checking LLM connectivity...
(let ((openrouter-key (getenv "OPENROUTER_API_KEY))
(harness-log "DOCTOR: Checking LLM connectivity...")
(let ((openrouter-key (uiop:getenv "OPENROUTER_API_KEY")))
(if (and openrouter-key (> (length openrouter-key) 0))
(progn
(harness-log " [OK] OpenRouter API Key detected.
(harness-log " [OK] OpenRouter API Key detected.")
t)
(progn
(harness-log " [WARN] No OpenRouter API Key. Falling back to local inference only.
(harness-log " [WARN] No OpenRouter API Key. Falling back to local inference only.")
t))))
#+end_src
** Orchestration
#+begin_src lisp :tangle doctor.lisp )
#+begin_src lisp
(defun doctor-run-all ()
"Executes the full diagnostic suite and returns T if system is healthy."
(harness-log "==================================================
(harness-log " OPENCORTEX DOCTOR: Commencing Health Check
(harness-log "==================================================
(harness-log "==================================================")
(harness-log " OPENCORTEX DOCTOR: Commencing Health Check")
(harness-log "==================================================")
(let ((dep-ok (doctor-check-dependencies))
(env-ok (doctor-check-env))
(llm-ok (doctor-check-llm)))
(harness-log "==================================================
(declare (ignore llm-ok))
(harness-log "==================================================")
(if (and dep-ok env-ok)
(progn
(harness-log " ✓ SYSTEM HEALTHY: Ready for ignition.
(harness-log " ✓ SYSTEM HEALTHY: Ready for ignition.")
t)
(progn
(harness-log " SYSTEM UNHEALTHY: Fix the errors above.
(harness-log " ✗ SYSTEM UNHEALTHY: Fix the errors above.")
nil))))
#+end_src
** CLI Entry Point
#+begin_src lisp :tangle doctor.lisp )
#+begin_src lisp
(defun doctor-main ()
"Entry point for the 'doctor' CLI command."
(if (doctor-run-all)