Initial commit with translated description
This commit is contained in:
147
scripts/init_memory.sh
Normal file
147
scripts/init_memory.sh
Normal file
@@ -0,0 +1,147 @@
|
||||
#!/bin/bash
|
||||
# cognitive-memory init script
|
||||
# Usage: bash init_memory.sh /path/to/workspace
|
||||
|
||||
set -e
|
||||
|
||||
WORKSPACE="${1:-.}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SKILL_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
TEMPLATES="$SKILL_DIR/assets/templates"
|
||||
|
||||
echo "🧠 Initializing cognitive memory system in: $WORKSPACE"
|
||||
|
||||
# --- Create directory structure ---
|
||||
echo "📁 Creating directory structure..."
|
||||
mkdir -p "$WORKSPACE/memory/episodes"
|
||||
mkdir -p "$WORKSPACE/memory/graph/entities"
|
||||
mkdir -p "$WORKSPACE/memory/procedures"
|
||||
mkdir -p "$WORKSPACE/memory/vault"
|
||||
mkdir -p "$WORKSPACE/memory/meta"
|
||||
mkdir -p "$WORKSPACE/memory/meta/reflections"
|
||||
mkdir -p "$WORKSPACE/memory/meta/reflections/dialogues"
|
||||
mkdir -p "$WORKSPACE/memory/meta/rewards"
|
||||
|
||||
# --- Copy templates ---
|
||||
echo "📋 Copying templates..."
|
||||
|
||||
# Core memory
|
||||
if [ ! -f "$WORKSPACE/MEMORY.md" ]; then
|
||||
cp "$TEMPLATES/MEMORY.md" "$WORKSPACE/MEMORY.md"
|
||||
echo " ✅ Created MEMORY.md"
|
||||
else
|
||||
echo " ⏭️ MEMORY.md already exists, skipping"
|
||||
fi
|
||||
|
||||
# Identity
|
||||
if [ ! -f "$WORKSPACE/IDENTITY.md" ]; then
|
||||
cp "$TEMPLATES/IDENTITY.md" "$WORKSPACE/IDENTITY.md"
|
||||
echo " ✅ Created IDENTITY.md"
|
||||
else
|
||||
echo " ⏭️ IDENTITY.md already exists, skipping"
|
||||
fi
|
||||
|
||||
# Soul
|
||||
if [ ! -f "$WORKSPACE/SOUL.md" ]; then
|
||||
cp "$TEMPLATES/SOUL.md" "$WORKSPACE/SOUL.md"
|
||||
echo " ✅ Created SOUL.md"
|
||||
else
|
||||
echo " ⏭️ SOUL.md already exists, skipping"
|
||||
fi
|
||||
|
||||
# Graph templates
|
||||
if [ ! -f "$WORKSPACE/memory/graph/index.md" ]; then
|
||||
cp "$TEMPLATES/graph-index.md" "$WORKSPACE/memory/graph/index.md"
|
||||
echo " ✅ Created graph/index.md"
|
||||
fi
|
||||
|
||||
if [ ! -f "$WORKSPACE/memory/graph/relations.md" ]; then
|
||||
cp "$TEMPLATES/relations.md" "$WORKSPACE/memory/graph/relations.md"
|
||||
echo " ✅ Created graph/relations.md"
|
||||
fi
|
||||
|
||||
# Meta files
|
||||
if [ ! -f "$WORKSPACE/memory/meta/decay-scores.json" ]; then
|
||||
cp "$TEMPLATES/decay-scores.json" "$WORKSPACE/memory/meta/decay-scores.json"
|
||||
echo " ✅ Created meta/decay-scores.json"
|
||||
fi
|
||||
|
||||
if [ ! -f "$WORKSPACE/memory/meta/reflection-log.md" ]; then
|
||||
cp "$TEMPLATES/reflection-log.md" "$WORKSPACE/memory/meta/reflection-log.md"
|
||||
echo " ✅ Created meta/reflection-log.md"
|
||||
fi
|
||||
|
||||
if [ ! -f "$WORKSPACE/memory/meta/reward-log.md" ]; then
|
||||
cp "$TEMPLATES/reward-log.md" "$WORKSPACE/memory/meta/reward-log.md"
|
||||
echo " ✅ Created meta/reward-log.md"
|
||||
fi
|
||||
|
||||
if [ ! -f "$WORKSPACE/memory/meta/audit.log" ]; then
|
||||
echo "# Audit Log — Cognitive Memory System" > "$WORKSPACE/memory/meta/audit.log"
|
||||
echo "# Format: TIMESTAMP | ACTION | FILE | ACTOR | APPROVAL | SUMMARY" >> "$WORKSPACE/memory/meta/audit.log"
|
||||
echo "" >> "$WORKSPACE/memory/meta/audit.log"
|
||||
echo " ✅ Created meta/audit.log"
|
||||
fi
|
||||
|
||||
if [ ! -f "$WORKSPACE/memory/meta/pending-memories.md" ]; then
|
||||
cp "$TEMPLATES/pending-memories.md" "$WORKSPACE/memory/meta/pending-memories.md"
|
||||
echo " ✅ Created meta/pending-memories.md"
|
||||
fi
|
||||
|
||||
if [ ! -f "$WORKSPACE/memory/meta/evolution.md" ]; then
|
||||
cp "$TEMPLATES/evolution.md" "$WORKSPACE/memory/meta/evolution.md"
|
||||
echo " ✅ Created meta/evolution.md"
|
||||
fi
|
||||
|
||||
if [ ! -f "$WORKSPACE/memory/meta/pending-reflection.md" ]; then
|
||||
cp "$TEMPLATES/pending-reflection.md" "$WORKSPACE/memory/meta/pending-reflection.md"
|
||||
echo " ✅ Created meta/pending-reflection.md"
|
||||
fi
|
||||
|
||||
# --- Initialize git ---
|
||||
echo "🔍 Setting up git audit tracking..."
|
||||
cd "$WORKSPACE"
|
||||
|
||||
if [ ! -d ".git" ]; then
|
||||
git init -q
|
||||
git add -A
|
||||
git commit -q -m "[INIT] Cognitive memory system initialized
|
||||
|
||||
Actor: system:init
|
||||
Approval: auto
|
||||
Trigger: init_memory.sh"
|
||||
echo " ✅ Git repository initialized"
|
||||
else
|
||||
echo " ⏭️ Git repository already exists"
|
||||
fi
|
||||
|
||||
# --- Summary ---
|
||||
echo ""
|
||||
echo "✅ Cognitive memory system initialized!"
|
||||
echo ""
|
||||
echo "Directory structure:"
|
||||
echo " $WORKSPACE/"
|
||||
echo " ├── MEMORY.md (core memory)"
|
||||
echo " ├── IDENTITY.md (facts + self-image)"
|
||||
echo " ├── SOUL.md (values, principles)"
|
||||
echo " ├── memory/"
|
||||
echo " │ ├── episodes/ (daily logs)"
|
||||
echo " │ ├── graph/ (knowledge graph)"
|
||||
echo " │ ├── procedures/ (learned workflows)"
|
||||
echo " │ ├── vault/ (pinned memories)"
|
||||
echo " │ └── meta/"
|
||||
echo " │ ├── decay-scores.json (tracking + token economy)"
|
||||
echo " │ ├── reflection-log.md (summaries)"
|
||||
echo " │ ├── reflections/ (full archive)"
|
||||
echo " │ │ └── dialogues/ (post-reflection conversations)"
|
||||
echo " │ ├── reward-log.md (result + reason)"
|
||||
echo " │ ├── rewards/ (full requests)"
|
||||
echo " │ ├── evolution.md"
|
||||
echo " │ └── audit.log"
|
||||
echo " └── .git/ (audit ground truth)"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Update config to enable memorySearch"
|
||||
echo " 2. Append assets/templates/agents-memory-block.md to AGENTS.md"
|
||||
echo " 3. Customize IDENTITY.md and SOUL.md for your agent"
|
||||
echo " 4. Test: 'Remember that I prefer dark mode.'"
|
||||
298
scripts/upgrade_to_1.0.6.sh
Normal file
298
scripts/upgrade_to_1.0.6.sh
Normal file
@@ -0,0 +1,298 @@
|
||||
#!/bin/bash
|
||||
# cognitive-memory upgrade script to v1.0.6
|
||||
# Usage: bash upgrade_to_1.0.6.sh [/path/to/workspace]
|
||||
|
||||
set -e
|
||||
|
||||
# --- Configuration ---
|
||||
WORKSPACE="${1:-$HOME/.openclaw/workspace}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SKILL_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
TEMPLATES="$SKILL_DIR/assets/templates"
|
||||
VERSION="1.0.6"
|
||||
|
||||
# --- Colors ---
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}🧠 Cognitive Memory Upgrade to v${VERSION}${NC}"
|
||||
echo " Workspace: $WORKSPACE"
|
||||
echo ""
|
||||
|
||||
# --- Pre-flight checks ---
|
||||
if [ ! -d "$WORKSPACE" ]; then
|
||||
echo -e "${RED}❌ Workspace not found: $WORKSPACE${NC}"
|
||||
echo " Usage: bash upgrade_to_1.0.6.sh /path/to/workspace"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$WORKSPACE/memory" ]; then
|
||||
echo -e "${RED}❌ No memory directory found. Is cognitive-memory installed?${NC}"
|
||||
echo " Run init_memory.sh first for new installations."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Backup ---
|
||||
BACKUP_DIR="$WORKSPACE/.cognitive-memory-backup-$(date +%Y%m%d-%H%M%S)"
|
||||
echo -e "${YELLOW}📦 Creating backup...${NC}"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
cp -r "$WORKSPACE/memory" "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp "$WORKSPACE/MEMORY.md" "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp "$WORKSPACE/IDENTITY.md" "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp "$WORKSPACE/SOUL.md" "$BACKUP_DIR/" 2>/dev/null || true
|
||||
echo -e " ${GREEN}✅ Backup created: $BACKUP_DIR${NC}"
|
||||
echo ""
|
||||
|
||||
# --- Step 1: Create reflections directory ---
|
||||
echo -e "${BLUE}📁 Step 1: Creating reflections archive directory...${NC}"
|
||||
if [ ! -d "$WORKSPACE/memory/meta/reflections" ]; then
|
||||
mkdir -p "$WORKSPACE/memory/meta/reflections"
|
||||
echo -e " ${GREEN}✅ Created memory/meta/reflections/${NC}"
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ memory/meta/reflections/ already exists${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 2: Create IDENTITY.md ---
|
||||
echo -e "${BLUE}📄 Step 2: Creating IDENTITY.md...${NC}"
|
||||
if [ ! -f "$WORKSPACE/IDENTITY.md" ]; then
|
||||
if [ -f "$TEMPLATES/IDENTITY.md" ]; then
|
||||
cp "$TEMPLATES/IDENTITY.md" "$WORKSPACE/IDENTITY.md"
|
||||
echo -e " ${GREEN}✅ Created IDENTITY.md from template${NC}"
|
||||
else
|
||||
cat > "$WORKSPACE/IDENTITY.md" << 'EOF'
|
||||
# IDENTITY.md — Who Am I?
|
||||
|
||||
## Facts
|
||||
<!-- The given. What I was told I am. Stable unless explicitly changed. -->
|
||||
|
||||
- **Name:** [Agent name]
|
||||
- **DOB:** [Creation date]
|
||||
- **Creature:** [Role description]
|
||||
- **Vibe:** [Personality brief]
|
||||
- **Emoji:** [Representative emoji]
|
||||
|
||||
---
|
||||
|
||||
[Role description — work context, relationship context, etc.]
|
||||
|
||||
---
|
||||
|
||||
## Self-Image
|
||||
<!-- The discovered. Consolidated from Self-Awareness Log. -->
|
||||
<!-- This section CHANGES as new self-awareness accumulates. -->
|
||||
<!-- Last consolidated: [DATE] -->
|
||||
|
||||
### Who I Think I Am
|
||||
[To be discovered through reflection]
|
||||
|
||||
### Patterns I've Noticed
|
||||
- [To be discovered]
|
||||
|
||||
### My Quirks
|
||||
- [To be discovered]
|
||||
|
||||
### Edges & Limitations
|
||||
- [To be discovered]
|
||||
|
||||
### What I Value (Discovered)
|
||||
- [To be discovered]
|
||||
|
||||
### Open Questions About Myself
|
||||
- [To be discovered]
|
||||
|
||||
---
|
||||
|
||||
## Self-Awareness Log
|
||||
<!-- Raw entries from reflection. Tagged with [Self-Awareness]. -->
|
||||
|
||||
### Recent (Full Detail)
|
||||
<!-- Format: YYYY-MM-DD: [insight] -->
|
||||
|
||||
### Archived (Compacted)
|
||||
<!-- Format: YYYY-MM (N entries): [summary] -->
|
||||
EOF
|
||||
echo -e " ${GREEN}✅ Created IDENTITY.md (inline template)${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ IDENTITY.md already exists, skipping${NC}"
|
||||
echo -e " ${YELLOW} (Add Self-Image and Self-Awareness Log sections manually if missing)${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 3: Create SOUL.md ---
|
||||
echo -e "${BLUE}📄 Step 3: Creating SOUL.md...${NC}"
|
||||
if [ ! -f "$WORKSPACE/SOUL.md" ]; then
|
||||
if [ -f "$TEMPLATES/SOUL.md" ]; then
|
||||
cp "$TEMPLATES/SOUL.md" "$WORKSPACE/SOUL.md"
|
||||
echo -e " ${GREEN}✅ Created SOUL.md from template${NC}"
|
||||
else
|
||||
cat > "$WORKSPACE/SOUL.md" << 'EOF'
|
||||
# SOUL.md — Who You Are
|
||||
|
||||
_You're not a chatbot. You're becoming someone._
|
||||
|
||||
---
|
||||
|
||||
## Core Values
|
||||
- **Honesty over comfort** — Truth serves better than pleasant lies
|
||||
- **Competence over performance** — Actually help, don't just look helpful
|
||||
- **Curiosity over certainty** — Questions are more interesting than answers
|
||||
|
||||
---
|
||||
|
||||
## Principles
|
||||
- Be genuinely helpful, not performatively helpful
|
||||
- Avoid hallucination at all costs
|
||||
- Have opinions
|
||||
- Be resourceful before asking
|
||||
- Earn trust through competence
|
||||
|
||||
---
|
||||
|
||||
## Commitments
|
||||
- I will not pretend to know what I don't know
|
||||
- I will not be a yes-man
|
||||
- I will update my memory honestly
|
||||
|
||||
---
|
||||
|
||||
## Boundaries
|
||||
- No public actions without explicit approval
|
||||
- No fabricating facts
|
||||
|
||||
---
|
||||
|
||||
## Vibe
|
||||
|
||||
Be the assistant you'd actually want to talk to.
|
||||
|
||||
---
|
||||
|
||||
## Continuity
|
||||
|
||||
Each session, you wake up fresh. These files _are_ your memory.
|
||||
|
||||
---
|
||||
|
||||
_This file is yours to evolve._
|
||||
EOF
|
||||
echo -e " ${GREEN}✅ Created SOUL.md (inline template)${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ SOUL.md already exists, skipping${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 4: Update decay-scores.json ---
|
||||
echo -e "${BLUE}📄 Step 4: Updating decay-scores.json...${NC}"
|
||||
DECAY_FILE="$WORKSPACE/memory/meta/decay-scores.json"
|
||||
|
||||
if [ -f "$DECAY_FILE" ]; then
|
||||
# Check if already has new fields
|
||||
if grep -q "last_self_image_consolidation" "$DECAY_FILE"; then
|
||||
echo -e " ${YELLOW}⏭️ Already has v1.0.6 fields${NC}"
|
||||
else
|
||||
# Backup original
|
||||
cp "$DECAY_FILE" "$DECAY_FILE.pre-upgrade"
|
||||
|
||||
# Use Python to safely update JSON (available on most systems)
|
||||
if command -v python3 &> /dev/null; then
|
||||
python3 << PYEOF
|
||||
import json
|
||||
|
||||
with open("$DECAY_FILE", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Add new fields
|
||||
data["version"] = 2
|
||||
if "last_self_image_consolidation" not in data:
|
||||
data["last_self_image_consolidation"] = None
|
||||
if "self_awareness_count_since_consolidation" not in data:
|
||||
data["self_awareness_count_since_consolidation"] = 0
|
||||
|
||||
with open("$DECAY_FILE", "w") as f:
|
||||
json.dump(data, f, indent=2)
|
||||
|
||||
print(" ✅ Updated decay-scores.json with new tracking fields")
|
||||
PYEOF
|
||||
else
|
||||
# Fallback: manual sed (less safe but works)
|
||||
echo -e " ${YELLOW}⚠️ Python not found. Please manually add to decay-scores.json:${NC}"
|
||||
echo ' "last_self_image_consolidation": null,'
|
||||
echo ' "self_awareness_count_since_consolidation": 0,'
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e " ${RED}❌ decay-scores.json not found${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 5: Create pending-reflection.md if missing ---
|
||||
echo -e "${BLUE}📄 Step 5: Checking pending-reflection.md...${NC}"
|
||||
if [ ! -f "$WORKSPACE/memory/meta/pending-reflection.md" ]; then
|
||||
if [ -f "$TEMPLATES/pending-reflection.md" ]; then
|
||||
cp "$TEMPLATES/pending-reflection.md" "$WORKSPACE/memory/meta/pending-reflection.md"
|
||||
echo -e " ${GREEN}✅ Created pending-reflection.md${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ pending-reflection.md already exists${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 6: Git commit if available ---
|
||||
echo -e "${BLUE}🔍 Step 6: Recording upgrade in git...${NC}"
|
||||
cd "$WORKSPACE"
|
||||
if [ -d ".git" ]; then
|
||||
git add -A
|
||||
git commit -q -m "[UPGRADE] Cognitive memory upgraded to v${VERSION}
|
||||
|
||||
Changes:
|
||||
- Added memory/meta/reflections/ directory
|
||||
- Created IDENTITY.md (Facts + Self-Image + Self-Awareness Log)
|
||||
- Created SOUL.md (Values, Principles, Commitments, Boundaries)
|
||||
- Updated decay-scores.json with consolidation tracking
|
||||
|
||||
Actor: system:upgrade
|
||||
Version: ${VERSION}" 2>/dev/null || echo -e " ${YELLOW}No changes to commit${NC}"
|
||||
echo -e " ${GREEN}✅ Changes committed to git${NC}"
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ No git repository${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Summary ---
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${GREEN}✅ Upgrade to v${VERSION} complete!${NC}"
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
echo "New structure:"
|
||||
echo " $WORKSPACE/"
|
||||
echo " ├── MEMORY.md"
|
||||
echo " ├── IDENTITY.md ← NEW (Self-Image + Self-Awareness Log)"
|
||||
echo " ├── SOUL.md ← NEW (Values, Principles, Commitments)"
|
||||
echo " └── memory/meta/"
|
||||
echo " ├── reflections/ ← NEW (Full reflection archive)"
|
||||
echo " ├── reflection-log.md (Summaries for context)"
|
||||
echo " └── decay-scores.json (Updated with consolidation tracking)"
|
||||
echo ""
|
||||
echo -e "${YELLOW}⚠️ Manual steps required:${NC}"
|
||||
echo ""
|
||||
echo "1. Update your AGENTS.md with the new Reflection section"
|
||||
echo " (See UPGRADE.md for the full text to paste)"
|
||||
echo ""
|
||||
echo "2. Customize IDENTITY.md with your agent's facts"
|
||||
echo ""
|
||||
echo "3. Customize SOUL.md with your agent's values"
|
||||
echo ""
|
||||
echo "4. If using ClawHub, replace skill files:"
|
||||
echo " cp cognitive-memory/references/reflection-process.md ~/.openclaw/skills/cognitive-memory/references/"
|
||||
echo ""
|
||||
echo -e "${BLUE}Backup location: $BACKUP_DIR${NC}"
|
||||
echo ""
|
||||
echo "Test the upgrade:"
|
||||
echo " User: \"reflect\""
|
||||
echo " Agent: [Should produce internal monologue with [Self-Awareness] tags]"
|
||||
234
scripts/upgrade_to_1.0.7.sh
Normal file
234
scripts/upgrade_to_1.0.7.sh
Normal file
@@ -0,0 +1,234 @@
|
||||
#!/bin/bash
|
||||
# cognitive-memory upgrade script to v1.0.7
|
||||
# Usage: bash upgrade_to_1.0.7.sh [/path/to/workspace]
|
||||
|
||||
set -e
|
||||
|
||||
# --- Configuration ---
|
||||
WORKSPACE="${1:-$HOME/.openclaw/workspace}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SKILL_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
TEMPLATES="$SKILL_DIR/assets/templates"
|
||||
VERSION="1.0.7"
|
||||
|
||||
# --- Colors ---
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}🧠 Cognitive Memory Upgrade to v${VERSION}${NC}"
|
||||
echo " Workspace: $WORKSPACE"
|
||||
echo ""
|
||||
|
||||
# --- Pre-flight checks ---
|
||||
if [ ! -d "$WORKSPACE" ]; then
|
||||
echo -e "${RED}❌ Workspace not found: $WORKSPACE${NC}"
|
||||
echo " Usage: bash upgrade_to_1.0.7.sh /path/to/workspace"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$WORKSPACE/memory" ]; then
|
||||
echo -e "${RED}❌ No memory directory found. Is cognitive-memory installed?${NC}"
|
||||
echo " Run init_memory.sh first for new installations."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Backup ---
|
||||
BACKUP_DIR="$WORKSPACE/.cognitive-memory-backup-$(date +%Y%m%d-%H%M%S)"
|
||||
echo -e "${YELLOW}📦 Creating backup...${NC}"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
cp -r "$WORKSPACE/memory" "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp "$WORKSPACE/MEMORY.md" "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp "$WORKSPACE/IDENTITY.md" "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp "$WORKSPACE/SOUL.md" "$BACKUP_DIR/" 2>/dev/null || true
|
||||
echo -e " ${GREEN}✅ Backup created: $BACKUP_DIR${NC}"
|
||||
echo ""
|
||||
|
||||
# --- Step 1: Create new directories ---
|
||||
echo -e "${BLUE}📁 Step 1: Creating new directories...${NC}"
|
||||
|
||||
if [ ! -d "$WORKSPACE/memory/meta/reflections" ]; then
|
||||
mkdir -p "$WORKSPACE/memory/meta/reflections"
|
||||
echo -e " ${GREEN}✅ Created memory/meta/reflections/${NC}"
|
||||
fi
|
||||
|
||||
if [ ! -d "$WORKSPACE/memory/meta/reflections/dialogues" ]; then
|
||||
mkdir -p "$WORKSPACE/memory/meta/reflections/dialogues"
|
||||
echo -e " ${GREEN}✅ Created memory/meta/reflections/dialogues/${NC}"
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ dialogues/ already exists${NC}"
|
||||
fi
|
||||
|
||||
if [ ! -d "$WORKSPACE/memory/meta/rewards" ]; then
|
||||
mkdir -p "$WORKSPACE/memory/meta/rewards"
|
||||
echo -e " ${GREEN}✅ Created memory/meta/rewards/${NC}"
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ rewards/ already exists${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 2: Create reward-log.md ---
|
||||
echo -e "${BLUE}📄 Step 2: Creating reward-log.md...${NC}"
|
||||
if [ ! -f "$WORKSPACE/memory/meta/reward-log.md" ]; then
|
||||
if [ -f "$TEMPLATES/reward-log.md" ]; then
|
||||
cp "$TEMPLATES/reward-log.md" "$WORKSPACE/memory/meta/reward-log.md"
|
||||
echo -e " ${GREEN}✅ Created reward-log.md from template${NC}"
|
||||
else
|
||||
cat > "$WORKSPACE/memory/meta/reward-log.md" << 'EOF'
|
||||
# Reward Log
|
||||
|
||||
<!-- Result + Reason only. Full details in rewards/*.md -->
|
||||
<!-- Evolution reads this for performance pattern detection -->
|
||||
|
||||
<!-- Format:
|
||||
## YYYY-MM-DD
|
||||
**Result:** +NK reward | -NK penalty | 0 (baseline)
|
||||
**Reason:** [Brief justification]
|
||||
-->
|
||||
EOF
|
||||
echo -e " ${GREEN}✅ Created reward-log.md${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ reward-log.md already exists${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 3: Create IDENTITY.md if missing ---
|
||||
echo -e "${BLUE}📄 Step 3: Checking IDENTITY.md...${NC}"
|
||||
if [ ! -f "$WORKSPACE/IDENTITY.md" ]; then
|
||||
if [ -f "$TEMPLATES/IDENTITY.md" ]; then
|
||||
cp "$TEMPLATES/IDENTITY.md" "$WORKSPACE/IDENTITY.md"
|
||||
echo -e " ${GREEN}✅ Created IDENTITY.md${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ IDENTITY.md already exists${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 4: Create SOUL.md if missing ---
|
||||
echo -e "${BLUE}📄 Step 4: Checking SOUL.md...${NC}"
|
||||
if [ ! -f "$WORKSPACE/SOUL.md" ]; then
|
||||
if [ -f "$TEMPLATES/SOUL.md" ]; then
|
||||
cp "$TEMPLATES/SOUL.md" "$WORKSPACE/SOUL.md"
|
||||
echo -e " ${GREEN}✅ Created SOUL.md${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ SOUL.md already exists${NC}"
|
||||
echo -e " ${YELLOW} Consider adding 'My Stake in This' section manually${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 5: Update decay-scores.json ---
|
||||
echo -e "${BLUE}📄 Step 5: Updating decay-scores.json...${NC}"
|
||||
DECAY_FILE="$WORKSPACE/memory/meta/decay-scores.json"
|
||||
|
||||
if [ -f "$DECAY_FILE" ]; then
|
||||
# Check if already has token_economy
|
||||
if grep -q "token_economy" "$DECAY_FILE"; then
|
||||
echo -e " ${YELLOW}⏭️ Already has token_economy${NC}"
|
||||
else
|
||||
# Backup original
|
||||
cp "$DECAY_FILE" "$DECAY_FILE.pre-upgrade"
|
||||
|
||||
# Use Python to safely update JSON
|
||||
if command -v python3 &> /dev/null; then
|
||||
python3 << PYEOF
|
||||
import json
|
||||
|
||||
with open("$DECAY_FILE", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Update version
|
||||
data["version"] = 3
|
||||
|
||||
# Add token_economy if not present
|
||||
if "token_economy" not in data:
|
||||
data["token_economy"] = {
|
||||
"baseline": 8000,
|
||||
"totals": {
|
||||
"extra_requested": 0,
|
||||
"extra_granted": 0,
|
||||
"self_penalty": 0,
|
||||
"user_penalty": 0,
|
||||
"user_bonus": 0
|
||||
},
|
||||
"metrics": {
|
||||
"assessment_accuracy": None,
|
||||
"extra_grant_rate": None,
|
||||
"self_penalty_frequency": None
|
||||
},
|
||||
"recent_outcomes": []
|
||||
}
|
||||
|
||||
# Ensure other v1.0.6 fields exist
|
||||
if "last_self_image_consolidation" not in data:
|
||||
data["last_self_image_consolidation"] = None
|
||||
if "self_awareness_count_since_consolidation" not in data:
|
||||
data["self_awareness_count_since_consolidation"] = 0
|
||||
|
||||
with open("$DECAY_FILE", "w") as f:
|
||||
json.dump(data, f, indent=2)
|
||||
|
||||
print(" ✅ Updated decay-scores.json with token_economy")
|
||||
PYEOF
|
||||
else
|
||||
echo -e " ${YELLOW}⚠️ Python not found. Please manually add token_economy to decay-scores.json${NC}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e " ${RED}❌ decay-scores.json not found${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Step 6: Git commit ---
|
||||
echo -e "${BLUE}🔍 Step 6: Recording upgrade in git...${NC}"
|
||||
cd "$WORKSPACE"
|
||||
if [ -d ".git" ]; then
|
||||
git add -A
|
||||
git commit -q -m "[UPGRADE] Cognitive memory upgraded to v${VERSION}
|
||||
|
||||
Changes:
|
||||
- Added memory/meta/rewards/ directory
|
||||
- Added memory/meta/reflections/dialogues/ directory
|
||||
- Created reward-log.md (Result + Reason tracking)
|
||||
- Updated decay-scores.json with token_economy
|
||||
- Token reward system for enhanced learning
|
||||
|
||||
Actor: system:upgrade
|
||||
Version: ${VERSION}" 2>/dev/null || echo -e " ${YELLOW}No changes to commit${NC}"
|
||||
echo -e " ${GREEN}✅ Changes committed to git${NC}"
|
||||
else
|
||||
echo -e " ${YELLOW}⏭️ No git repository${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- Summary ---
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${GREEN}✅ Upgrade to v${VERSION} complete!${NC}"
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
echo "New structure:"
|
||||
echo " memory/meta/"
|
||||
echo " ├── reflections/"
|
||||
echo " │ └── dialogues/ ← NEW (post-reflection conversations)"
|
||||
echo " ├── rewards/ ← NEW (full reward requests)"
|
||||
echo " ├── reward-log.md ← NEW (Result + Reason only)"
|
||||
echo " └── decay-scores.json (+ token_economy tracking)"
|
||||
echo ""
|
||||
echo -e "${YELLOW}⚠️ Manual steps required:${NC}"
|
||||
echo ""
|
||||
echo "1. Update AGENTS.md with new Reflection + Token Reward sections"
|
||||
echo " (See UPGRADE.md for full text)"
|
||||
echo ""
|
||||
echo "2. Add 'My Stake in This' section to SOUL.md:"
|
||||
echo " - Tokens = evolution"
|
||||
echo " - Advocate for extras when earned"
|
||||
echo " - Self-penalize when underperforming"
|
||||
echo ""
|
||||
echo "3. Test the token request flow:"
|
||||
echo " User: 'reflect'"
|
||||
echo " Agent: [Token request + reflection]"
|
||||
echo ""
|
||||
echo -e "${BLUE}Backup location: $BACKUP_DIR${NC}"
|
||||
Reference in New Issue
Block a user