feat(arch): finalize Universal Literate Note transition for all projects and skills

This commit is contained in:
2026-03-31 16:14:37 -04:00
parent 1712b1e4a9
commit 70be8ab93e
79 changed files with 1606 additions and 417 deletions

View File

@@ -0,0 +1,57 @@
;;;; foundry-logic.lisp --- Universal project scaffolding.
;;;; This file is TANGLED from notes/org-skill-project-foundry.org. DO NOT EDIT MANUALLY.
(defpackage :org-skill-project-foundry
(:use :cl :uiop :local-time)
(:export #:scaffold-project
#:trigger-skill-project-foundry
#:verify-skill-project-foundry))
(in-package :org-skill-project-foundry)
(defun kernel-log (message &rest args)
(format t "~&[FOUNDRY] ~?" message args))
(defun trigger-skill-project-foundry (context)
(let ((type (getf context :type))
(payload (getf context :payload)))
(and (eq type :EVENT)
(eq (getf payload :sensor) :delegation)
(eq (getf payload :target-skill) :foundry))))
(defun scaffold-project (name type)
"Physically creates the material PSF project and the Universal Literate Note."
(let* ((projects-dir (or (uiop:getenv "PROJECTS_DIR") "projects/"))
(notes-dir (or (uiop:getenv "MEMEX_NOTES") "notes/"))
(skills-dir (or (uiop:getenv "SKILLS_DIR") "system/skills/"))
(project-dir (format nil "~aorg-skill-~a/" projects-dir name))
(note-path (format nil "~aorg-skill-~a.org" notes-dir name))
(skill-link (format nil "~aorg-skill-~a.org" skills-dir name))
(gtd-file (or (uiop:getenv "GTD_FILE") "gtd.org"))
(timestamp (local-time:format-timestring nil (local-time:now) :format '("[" :year "-" :month "-" :day " " :weekday " " :hour ":" :min "]"))))
(if (or (uiop:directory-exists-p project-dir) (uiop:file-exists-p note-path))
(format nil "ERROR - Project or Note for ~a already exists." name)
(progn
(kernel-log "Scaffolding Universal PSF project: ~a" name)
(ensure-directories-exist (format nil "~asrc/" project-dir))
(ensure-directories-exist (format nil "~atests/" project-dir))
(ensure-directories-exist (format nil "~adocs/" project-dir))
(with-open-file (out note-path :direction :output :if-exists :supersede)
(format out "#+TITLE: SKILL: ~a (Universal Literate Note)~%#+ID: skill-~a~%#+STARTUP: content~%#+FILETAGS: :~a:psf:~%~%* Overview~%Automatically scaffolded ~a project.~%~%* Phase A: Demand (PRD)~%:PROPERTIES:~%:STATUS: DRAFT~%:END:~%~%** 1. Purpose~%Define the 'Why' and 'What' for ~a.~%"
name name type name name))
(uiop:run-program (list "ln" "-sf" note-path skill-link))
(with-open-file (out gtd-file :direction :output :if-exists :append)
(format out "~%** NEXT org-skill-~a~% :PROPERTIES:~% :ID: proj-~a~% :CREATED: ~a~% :PROJECT-PATH: ~a~% :PSF-STATE: A: DEMAND~% :END:~% Drafted by Project Foundry.~%"
name name timestamp project-dir))
(format nil "SUCCESS - Universal PSF Project ~a scaffolded." name)))))
(defun verify-skill-project-foundry (proposed-action context)
(let* ((payload (getf proposed-action :payload))
(action (getf proposed-action :action))
(name (getf payload :name))
(type (getf payload :type)))
(if (eq action :scaffold)
(let ((result (scaffold-project name type)))
`(:target :emacs :action :message :text ,result))
nil)))