diff --git a/scripts/templates/memory/DAILY-LOG.md b/scripts/templates/memory/DAILY-LOG.md new file mode 100644 index 0000000..e55babc --- /dev/null +++ b/scripts/templates/memory/DAILY-LOG.md @@ -0,0 +1,42 @@ +# Daily Log: {{AGENT_NAME}} + +> Warm daily capture. One file per day. Filename: memory/YYYY-MM-DD.md +> Auto-rotated: the pipeline creates a new file each day. + +## {{DATE}} + +### Summary of Work + +[1-3 sentences describing what was accomplished today] + +### Decisions Made + +| Decision | Context | Outcome | +|----------|---------|---------| +| | | | + +### Files Modified + +- [file path] — [what changed and why] + +### Issues Encountered + +- [issue description] — [resolution or status] + +### Quality Scores + +| Pipeline run | Reviewer score | Notes | +|-------------|---------------|-------| +| | | | + +### Carry Forward + +> Items for the next session. These get checked on the next pipeline run. + +- [ ] [item that needs attention tomorrow] +- [ ] [follow-up from today's work] + +### Cost + +- Estimated tokens used: [if tracked] +- Pipeline runs: [count] diff --git a/scripts/templates/memory/MEMORY.md b/scripts/templates/memory/MEMORY.md new file mode 100644 index 0000000..2efa684 --- /dev/null +++ b/scripts/templates/memory/MEMORY.md @@ -0,0 +1,46 @@ +# Long-Term Memory: {{AGENT_NAME}} + +> Cold curated memory. Updated manually or after significant learnings. +> This is the last file read during compaction recovery. + +## Agent Identity + +- Name: {{AGENT_NAME}} +- Role: [what this agent does] +- Domain: {{DOMAIN}} +- Created: {{DATE}} + +## Key Learnings + +> Manually curated from daily logs. Only include insights that affect +> future behavior. Delete entries that are no longer relevant. + +- [learning 1 — date discovered] +- [learning 2 — date discovered] + +## Recurring Patterns + +> Patterns observed across multiple runs. Used to improve agent behavior. + +| Pattern | Frequency | Impact | Action taken | +|---------|-----------|--------|-------------| +| | | | | + +## Known Issues + +> Active issues that affect agent performance. + +- [issue] — [workaround] — [status: open/resolved] + +## Project Context + +> Static context that doesn't change often. + +- Project: {{PROJECT_DIR}} +- Pipeline: {{PIPELINE_NAME}} +- Schedule: {{SCHEDULE}} +- Deployment: [target] + +## Last Updated + +[date — update this when you curate this file] diff --git a/scripts/templates/memory/README.md b/scripts/templates/memory/README.md new file mode 100644 index 0000000..03b42b8 --- /dev/null +++ b/scripts/templates/memory/README.md @@ -0,0 +1,67 @@ +# 3-Tier Memory System + +Inspired by OpenClaw's proactive agent memory pattern. Three tiers serve +different purposes with different update frequencies. + +## Architecture + +``` +Tier 1: SESSION-STATE.md (hot) + - Updated every turn + - Read FIRST on session start and compaction recovery + - Contains: current task, decisions, pending actions, working buffer + +Tier 2: memory/YYYY-MM-DD.md (warm) + - One file per day, auto-rotated + - Updated at end of each pipeline run + - Contains: daily summary, decisions, files modified, issues, carry-forward + +Tier 3: memory/MEMORY.md (cold) + - Updated manually or after significant learnings + - Read LAST during compaction recovery + - Contains: identity, curated learnings, patterns, known issues +``` + +## WAL Protocol (Write-Ahead Logging) + +Before responding to the user with important information, write it to +SESSION-STATE.md first. This prevents data loss if: +- The session crashes mid-response +- Context compaction removes the exchange +- The user's connection drops + +## Working Buffer Protocol + +When context usage exceeds ~60% (the "danger zone"): +1. Activate the Working Buffer section in SESSION-STATE.md +2. Copy critical recent exchanges into the buffer +3. Extract and list key facts that would be lost on compaction +4. Continue working normally — the buffer is your safety net + +## Compaction Recovery + +When Claude resumes after context compaction, it reads in this order: +1. SESSION-STATE.md (current task, decisions, working buffer) +2. Today's daily log (what happened today) +3. MEMORY.md (long-term context, known issues) +4. Search older daily logs if needed for specific context + +## Integration with Agent Factory + +During `/agent-factory:build` Phase 2.5 (Memory Setup): +1. Copy these templates to the user's `memory/` directory +2. Replace `{{PLACEHOLDER}}` variables with project-specific values +3. Create the initial SESSION-STATE.md and MEMORY.md +4. Configure the pipeline skill to update daily logs after each run + +## File locations after scaffolding + +``` +project/ + memory/ + SESSION-STATE.md (from Tier 1 template) + MEMORY.md (from Tier 3 template) + 2026-04-11.md (generated daily, from Tier 2 template) + 2026-04-12.md + ... +``` diff --git a/scripts/templates/memory/SESSION-STATE.md b/scripts/templates/memory/SESSION-STATE.md new file mode 100644 index 0000000..b86425c --- /dev/null +++ b/scripts/templates/memory/SESSION-STATE.md @@ -0,0 +1,53 @@ +# Session State: {{AGENT_NAME}} + +> Hot working memory. Updated every turn. Read first on resume. + +## WAL Protocol + +**Write important details HERE before responding to the user.** +This prevents data loss if the session crashes or context compacts mid-response. + +## Current Task + +- Task: [what you're working on right now] +- Started: [timestamp] +- Status: [in progress / blocked / waiting] +- Key decision: [the most important choice made this session] + +## Context Window Usage + +- Estimated usage: [low / medium / high / DANGER ZONE] +- If above 60%: activate Working Buffer below + +## Active Decisions + +| Decision | Choice | Reason | Reversible? | +|----------|--------|--------|-------------| +| | | | | + +## Pending Actions + +- [ ] [action 1] +- [ ] [action 2] + +## Working Buffer + +> Activate when context usage exceeds 60%. Capture key exchanges here +> before they are lost to compaction. This is your safety net. + +### Recent exchanges to preserve + +[Paste critical user messages and your key responses here when in the danger zone] + +### Key facts from this session + +[Extract and list facts that would be lost on compaction] + +## Compaction Recovery + +If you're reading this after a context compaction: +1. Read this SESSION-STATE.md first (you're here) +2. Read today's daily log: `memory/$(date +%Y-%m-%d).md` +3. Read memory/MEMORY.md for long-term context +4. Search daily logs for relevant prior context +5. Resume from the Current Task and Pending Actions above