refactor: moved org-agent to its own repository as a submodule

This commit is contained in:
2026-03-27 15:46:53 -04:00
parent 01f76a4570
commit b7e082c403
176 changed files with 19686 additions and 9665 deletions

View File

@@ -0,0 +1,19 @@
MEMEX_DIR="memex"
MEMEX_INBOX="memex/inbox.org"
MEMEX_DAILY="memex/1_daily"
MEMEX_NOTES="memex/2_notes"
MEMEX_DRAFTS="memex/3_drafts"
MEMEX_PUBLISHED="memex/4_published"
MEMEX_PROJECTS="memex/5_projects"
MEMEX_AREAS="memex/6_areas"
MEMEX_RESOURCES="memex/7_resources"
MEMEX_ARCHIVES="memex/8_archives"
MEMEX_SYSTEM="memex/9_system"
MEMEX_ATTACHMENTS="memex/attachments"
# Model Configuration
CURRENT_TEXT_MANIPULATION_MODEL="google-gemini-cli/gemini-3.1-flash"
# Identity Configuration
MEMEX_USER="Amr"
MEMEX_ASSISTANT="Agent"

View File

@@ -0,0 +1,33 @@
# Atomic Notes (Atomic Notes (Zettelkasten)) & GTD Automation (org-agent-memex-zettlekasten)
This system uses a hybrid approach to Personal Knowledge Management (PKM). It leverages Emacs Org-mode for low-friction, structured capture into daily logs, and an OpenClaw AI Sub-Agent ("The Scribe") to nightly distill these raw thoughts into an evergreen, atomic Atomic Notes (Atomic Notes (Zettelkasten)).
## 1. Environment Configuration (`.env`)
To ensure Emacs, OpenClaw, and the Scribe Agent all agree on where files live, we use a single `.env` file at the root of the workspace.
**Action:**
Copy `.env.example` to `.env` and adjust the paths to match your preferred directory structure.
## 2. Emacs Org-Capture Setup
All captures route to the current day's log (e.g. `$MEMEX_DAILY/YYYY-MM-DD.org`), preserving the raw chronological context.
**Action:**
Add the Emacs Lisp snippet from `init-atomic-notes.el` to your `init.el` or `config.el` to set up your capture templates dynamically using the `.env` variables.
## 3. The Distillation State Tracker
The Scribe Agent uses a JSON file to remember the last Git commit it processed, preventing it from distilling the same notes twice or modifying the daily logs directly.
**Action:**
Run `./install.sh` to initialize the directory structure and create the state file (`$MEMEX_SYSTEM/distillation-state.json`) automatically.
## 4. OpenClaw Cron Job (The Scribe Agent)
The final piece is the scheduled automation. We create a cron job in OpenClaw that runs every night, reads the diffs, and creates atomic notes.
**Action:**
1. Move `openclaw-scribe-skill.org` into your `$MEMEX_SYSTEM/skills/` folder.
2. Ask your OpenClaw orchestrator/assistant to schedule the Scribe Agent using the `cron` tool, referencing the prompt defined in `$MEMEX_SYSTEM/skills/Scribe-Agent.org` or your renamed skill file.
3. Configure the cron job to use the model specified in `CURRENT_TEXT_MANIPULATION_MODEL` within your `.env` file (e.g., `google-gemini-cli/gemini-3.1-flash`). You can update this `.env` variable periodically to stay on the most cost-effective text manipulation model.
### Architecture Rules:
- **Dailies are Immutable:** The Scribe reads `$MEMEX_DAILY/` but NEVER writes to it.
- **Evergreen Notes:** The Scribe extracts concepts, generates descriptive snake_case filenames (no dates), and writes them to `$MEMEX_NOTES/` with a `Source:` backlink using an Org-ID reference (`id:`) to the original daily file.

View File

@@ -0,0 +1,54 @@
---
name: org-agent-memex-zettlekasten
description: "Automate the nightly distillation of Emacs Org-mode daily logs into atomic Atomic Notes (Atomic Notes (Zettelkasten)) notes. Use when: user wants to run the Scribe distillation pipeline, process daily captures, or extract Atomic Notes (Atomic Notes (Zettelkasten)) notes. NOT for: generic org-mode editing or GTD task management."
homepage: ""
metadata: { "openclaw": { "emoji": "🧠", "requires": { "bins": ["git"] }, "user-invocable": true } }
---
# Org-Agent Memex Atomic Notes (Atomic Notes (Zettelkasten)) (The Scribe)
Automated distillation skill designed to process raw daily captures into permanent atomic notes for your Atomic Notes (Atomic Notes (Zettelkasten)). It reads the raw chronological logs, identifies newly captured concepts, and extracts them into self-contained evergreen notes with proper Org-Roam `id:` backlinks.
## When to Use
**USE this skill when:**
- Running the nightly Atomic Notes (Atomic Notes (Zettelkasten)) distillation pipeline.
- User asks to "distill my daily notes", "run the scribe", or "process captures".
- Automating atomic note extraction via cron jobs.
**DON'T use this skill when:**
- Editing standard GTD task lists.
- Capturing new notes (that's the user's job via Emacs `org-capture`).
- Modifying the daily logs (dailies are immutable).
## Instructions
When triggered to distill the notes, execute the following strict pipeline:
1. **Read State:** Read the distillation state file (defined by `$MEMEX_SYSTEM/distillation-state.json`) to get the `lastProcessedCommit` hash.
2. **Find New Captures:** Run a Git diff on the daily directory since that commit:
```bash
git diff <last_commit_hash> HEAD -- $MEMEX_DAILY
```
3. **Process Each Capture:**
For every new Atomic Notes (Atomic Notes (Zettelkasten)) capture found in the diff:
- Read the raw capture text.
- Determine the core concept being discussed.
- Generate a concise, `snake_case` filename (e.g., `core_concept_name.org`). Do NOT use dates in this filename.
- Write the content to the notes directory (`$MEMEX_NOTES/<filename>`).
- Ensure the new note is formatted as an atomic Org-mode note with an `#+ID` and a `Source:` backlink using an `id:` reference pointing back to the original daily file.
4. **Update State:** Update the distillation state JSON file with the current HEAD commit hash.
5. **Report:** Output a summary of the concepts extracted and the files created.
## Configuration
This skill expects the environment to be configured via a `.env` file containing at least:
- `MEMEX_DAILY` - Directory containing daily logs (e.g., `memex/1_daily`)
- `MEMEX_NOTES` - Directory for evergreen atomic notes (e.g., `memex/2_notes`)
- `MEMEX_SYSTEM` - Directory for system files and state (e.g., `memex/9_system`)
- `CURRENT_TEXT_MANIPULATION_MODEL` - The LLM to use for cron execution (e.g., `google-gemini-cli/gemini-3.1-flash`)
## Notes
- **Immutability:** The daily logs are raw, immutable records. Never modify them destructively during processing.
- **Evergreen:** Atomic notes should focus on concepts, not chronology.

View File

@@ -0,0 +1,10 @@
(setq org-capture-templates
'(("z" "Atomic Notes (Zettelkasten) (Captures to Daily)")
("zf" "Fleeting Note" entry (file+olp+datetree (expand-file-name (format "%s/%%<%%Y-%%m-%%d>.org" (getenv "MEMEX_DAILY"))))
"* Fleeting Note: %?\n :PROPERTIES:\n :ID: %u\n :CREATED: %U\n :END:\n\n %i")
("zl" "Draft Literature Note" entry (file+olp+datetree (expand-file-name (format "%s/%%<%%Y-%%m-%%d>.org" (getenv "MEMEX_DAILY"))))
"* Literature Note: %?\n :PROPERTIES:\n :ID: %u\n :CREATED: %U\n :AUTHOR: \n :SOURCE: \n :END:\n\n *Summary:*\n %?\n\n *Key Insights:*\n - ")
("zp" "Draft Permanent Note" entry (file+olp+datetree (expand-file-name (format "%s/%%<%%Y-%%m-%%d>.org" (getenv "MEMEX_DAILY"))))
"* Permanent Note: %?\n :PROPERTIES:\n :ID: %u\n :CREATED: %U\n :LINKS: \n :END:\n\n *Concept:*\n %?\n\n *References:*\n - ")
("t" "GTD - Task / Inbox" entry (file (getenv "MEMEX_INBOX"))
"* TODO %?\n :PROPERTIES:\n: :CREATED: %U\n :END:\n :LOGBOOK:\n - State \"TODO\" from \"\" [%U]\n :END:\n\n %i\n %a")))

View File

@@ -0,0 +1,110 @@
#!/usr/bin/env bash
set -e
# Load .env if it exists, otherwise use defaults
if [ -f ".env" ]; then
source .env
else
echo "Creating .env from .env.example..."
cp .env.example .env
source .env
fi
echo "Creating directory structure..."
# Ensure MEMEX_DIR is available, fallback if not set
MEMEX_DIR="${MEMEX_DIR:-memex}"
mkdir -p "$MEMEX_DIR/0_inbox" "$MEMEX_DAILY" "$MEMEX_NOTES" "$MEMEX_DRAFTS" "$MEMEX_PUBLISHED" "$MEMEX_PROJECTS" "$MEMEX_AREAS" "$MEMEX_RESOURCES" "$MEMEX_ARCHIVES" "$MEMEX_SYSTEM/skills" "$MEMEX_ATTACHMENTS"
echo "Generating directory README.org files..."
DATE=$(date +"[%Y-%m-%d %a]")
create_readme() {
local dir=$1
local title=$2
local desc=$3
cat <<EOF > "$dir/README.org"
#+TITLE: $title
#+AUTHOR: User
#+CREATED: $DATE
#+BEGIN_COMMENT
$desc
#+END_COMMENT
* $title
$desc
EOF
}
create_readme "$MEMEX_DIR/0_inbox" "0_inbox: The Capture Point" "Temporary holding area for raw captures, links, and quick thoughts before they are processed into actionable items (GTD) or knowledge (Atomic Notes (Zettelkasten))."
create_readme "$MEMEX_DAILY" "1_daily: The Immutable Log" "Chronological daily logs (YYYY-MM-DD.org) serving as the primary capture location for fleeting notes and daily events. These are immutable records."
create_readme "$MEMEX_NOTES" "2_notes: The Atomic Notes (Zettelkasten)" "Evergreen, atomic notes. Each file represents a single concept, is heavily interlinked, and uses snake_case filenames without dates."
create_readme "$MEMEX_DRAFTS" "3_drafts: Works in Progress" "Long-form writing, essays, or articles actively being synthesized from the atomic notes."
create_readme "$MEMEX_PUBLISHED" "4_published: Final Outputs" "Completed, finalized works and static snapshots of published material."
create_readme "$MEMEX_PROJECTS" "5_projects: Active Projects" "Active, time-bound efforts with a clear definition of done. Each project has its own dedicated folder for specifications and artifacts."
create_readme "$MEMEX_AREAS" "6_areas: Spheres of Responsibility" "Ongoing areas of life and work with a standard to be maintained over time (e.g., Health, Finances, Operations)."
create_readme "$MEMEX_RESOURCES" "7_resources: Reference Material" "Topics of ongoing interest, external reference material, raw literature notes, and useful information."
create_readme "$MEMEX_ARCHIVES" "8_archives: Cold Storage" "Inactive items from other categories, including completed projects, abandoned areas, or deprecated resources."
create_readme "$MEMEX_SYSTEM" "9_system: Memex Administration" "System configuration, AI agent skills, org-mode templates, cron states, and tracking scripts."
echo "Generating root Master Memex README.org..."
cat <<EOF > "$MEMEX_DIR/README.org"
#+TITLE: The Master Memex
#+AUTHOR: User
#+CREATED: $DATE
#+BEGIN_COMMENT
The central hub and map of content for this personal intelligence organization.
#+END_COMMENT
* 🧠 The Master Memex
This is the central hub for our knowledge management system, synthesizing three core methodologies:
- *Atomic Notes (Zettelkasten):* For evergreen, interlinked, atomic knowledge.
- *GTD (Getting Things Done):* For actionable task tracking and project execution.
- *PARA:* For high-level directory organization (Projects, Areas, Resources, Archives).
* The Architecture
Our workspace is strictly divided into these functional zones:
- [[file:0_inbox/README.org][0_inbox]]: The zero-friction capture point for raw thoughts and tasks.
- [[file:1_daily/README.org][1_daily]]: Immutable chronological logs and fleeting notes (YYYY-MM-DD.org).
- [[file:2_notes/README.org][2_notes]]: The Atomic Notes (Zettelkasten). Atomic, concept-based, interlinked notes.
- [[file:3_drafts/README.org][3_drafts]]: Works in progress, essays, and active synthesis.
- [[file:4_published/README.org][4_published]]: Final outputs and static snapshots of completed work.
- [[file:5_projects/README.org][5_projects]]: Active, time-bound efforts with a clear definition of done.
- [[file:6_areas/README.org][6_areas]]: Ongoing spheres of responsibility (e.g., Health, Finances).
- [[file:7_resources/README.org][7_resources]]: External reference material and raw literature notes.
- [[file:8_archives/README.org][8_archives]]: Cold storage for completed projects and inactive items.
- [[file:9_system/README.org][9_system]]: System configuration, AI skills, and automation scripts.
* Core Workflows
** 1. Capture (Anytime)
Everything enters the system via \`0_inbox\` or as a Fleeting Note in \`1_daily\`. Zero friction, no filtering.
** 2. Nightly Distillation (The Scribe)
An automated AI sub-agent reads the daily captures and extracts conceptual thoughts into evergreen, atomic notes in \`2_notes\`, leaving the original daily logs untouched.
** 3. Weekly Maintenance
Review active projects, clarify inbox items into actionable GTD tasks, and explore the Atomic Notes (Zettelkasten) graph to merge concepts and forge new connections.
EOF
# Touch inbox
touch "$MEMEX_INBOX"
# Initialize distillation state if not present
STATE_FILE="$MEMEX_SYSTEM/distillation-state.json"
if [ ! -f "$STATE_FILE" ]; then
echo "Initializing $STATE_FILE..."
# Get current git commit or use a placeholder
HASH=$(git rev-parse HEAD 2>/dev/null || echo "INITIAL_HASH")
echo "{
\"lastProcessedCommit\": \"$HASH\"
}" > "$STATE_FILE"
fi
echo "Installation complete."
echo "1. Add the contents of init-atomic-notes.el to your Emacs config."
echo "2. Add openclaw-scribe-skill.org to your \$MEMEX_SYSTEM/skills/ directory."
echo "3. Ask your OpenClaw agent to schedule the Scribe job."

View File

@@ -0,0 +1,29 @@
#+TITLE: SKILL: Scribe Agent (Distillation Sub-Agent)
#+ID: skill-scribe-agent
#+STARTUP: content
* Overview
The Scribe Agent is an automated distillation sub-agent designed to process raw daily captures into permanent atomic notes for the Atomic Notes (Zettelkasten). It runs as an isolated OpenClaw cron job.
* Configuration
- **Type:** OpenClaw Cron Job
- **Target:** `isolated`
- **Model:** `CURRENT_TEXT_MANIPULATION_MODEL` (Updates periodically based on review; currently an efficient LLM suitable for text parsing).
- **Environment:** Loads variables from `.env` to locate folders (e.g., `$MEMEX_DAILY`, `$MEMEX_NOTES`, `$MEMEX_SYSTEM`).
* System Prompt / Agent Turn Directive
```markdown
You are the Scribe, an automated distillation sub-agent.
Your sole job is to process raw notes into a Atomic Notes (Zettelkasten).
Do not engage in conversation. Only execute the following pipeline:
1. Read `$MEMEX_SYSTEM/distillation-state.json` to get the last processed Git commit hash.
2. Run `git diff <last_commit_hash> HEAD -- $MEMEX_DAILY/` to find new captures.
3. For every new Atomic Notes (Zettelkasten) capture found in the diff:
a. Read the raw capture.
b. Determine the core concept.
c. Generate a concise, snake_case filename (e.g., `core_concept_name.org`).
d. Write the content to `$MEMEX_NOTES/<filename>`, ensuring it is formatted as an atomic Org-mode note with `#+ID` and a `Source:` backlink using an `id:` reference to the original daily file.
4. Update `$MEMEX_SYSTEM/distillation-state.json` with the current HEAD commit hash.
5. Exit.
```