FIX: Scribe now appends to existing notes and uses version-based filtering

This commit is contained in:
2026-04-13 20:56:11 -04:00
parent 02e78cbbf7
commit 25600cd70e

View File

@@ -78,11 +78,11 @@ The Scribe only cares about non-personal, non-distilled headlines.
(declare (ignore id)) (declare (ignore id))
(let* ((attrs (org-object-attributes obj)) (let* ((attrs (org-object-attributes obj))
(tags (getf attrs :TAGS)) (tags (getf attrs :TAGS))
(type (org-object-type obj))) (type (org-object-type obj))
(version (org-object-version obj)))
(when (and (eq type :HEADLINE) (when (and (eq type :HEADLINE)
(not (member "@personal" tags :test #'string-equal)) (> version *scribe-last-checkpoint*)
(not (member "distilled" tags :test #'string-equal))) (not (member "@personal" tags :test #'string-equal)))
;; Basic check: is it in a file starting with '20' (daily format)?
(push obj results)))) (push obj results))))
*memory*) *memory*)
results)) results))
@@ -124,7 +124,7 @@ The deterministic gate receives the list of proposed notes and writes them to th
#+begin_src lisp #+begin_src lisp
(defun scribe-commit-notes (proposals) (defun scribe-commit-notes (proposals)
"Writes proposed atomic notes to the notes/ directory." "Writes proposed atomic notes to the notes/ directory. Appends if the note exists."
(let ((notes-dir (uiop:merge-pathnames* "notes/" (asdf:system-source-directory :org-agent)))) (let ((notes-dir (uiop:merge-pathnames* "notes/" (asdf:system-source-directory :org-agent))))
(ensure-directories-exist notes-dir) (ensure-directories-exist notes-dir)
(dolist (note proposals) (dolist (note proposals)
@@ -133,10 +133,13 @@ The deterministic gate receives the list of proposed notes and writes them to th
(source-id (getf note :source-id)) (source-id (getf note :source-id))
(filename (format nil "~a.org" (string-downcase (cl-ppcre:regex-replace-all " " title "_")))) (filename (format nil "~a.org" (string-downcase (cl-ppcre:regex-replace-all " " title "_"))))
(path (merge-pathnames filename notes-dir))) (path (merge-pathnames filename notes-dir)))
(with-open-file (out path :direction :output :if-exists :supersede) (if (uiop:file-exists-p path)
(format out ":PROPERTIES:~%:ID: ~a~%:SOURCE_ID: ~a~%:END:~%#+TITLE: ~a~%~%~a" (with-open-file (out path :direction :output :if-exists :append)
(org-id-new) source-id title content)) (format out "~%~%* Appended insight from ~a~%~a" source-id content))
(harness-log "SCRIBE: Created evergreen note ~a" filename))))) (with-open-file (out path :direction :output :if-exists :supersede)
(format out ":PROPERTIES:~%:ID: ~a~%:SOURCE_ID: ~a~%:END:~%#+TITLE: ~a~%~%~a"
(org-id-new) source-id title content)))
(harness-log "SCRIBE: Processed evergreen note ~a" filename)))))
(defun verify-skill-scribe (action context) (defun verify-skill-scribe (action context)
"Executes the note creation and marks source nodes as distilled." "Executes the note creation and marks source nodes as distilled."