diff --git a/README.md b/README.md index 0598e41..d21071e 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,31 @@ # aigpt -Simple memory storage for Claude with MCP support. +AI memory system with psychological analysis for Claude via MCP. -**Layer 1: Pure Memory Storage** - A clean, SQLite-based memory system with ULID identifiers. +**Current: Layers 1-3 Complete** - Memory storage, AI interpretation, and personality analysis. ## Features +### Layer 1: Pure Memory Storage - ๐Ÿ—„๏ธ **SQLite Storage**: Reliable database with ACID guarantees - ๐Ÿ”– **ULID IDs**: Time-sortable, 26-character unique identifiers - ๐Ÿ” **Search**: Fast content-based search +- ๐Ÿ“ **CRUD Operations**: Complete memory management + +### Layer 2: AI Memory +- ๐Ÿง  **AI Interpretation**: Claude interprets and evaluates memories +- ๐Ÿ“Š **Priority Scoring**: Importance ratings (0.0-1.0) +- ๐ŸŽฏ **Smart Storage**: Memory + evaluation in one step + +### Layer 3: Personality Analysis +- ๐Ÿ”ฌ **Big Five Model**: Scientifically validated personality assessment +- ๐Ÿ“ˆ **Pattern Recognition**: Analyzes memory patterns to build user profile +- ๐Ÿ’พ **Historical Tracking**: Save and compare analyses over time + +### General - ๐Ÿ› ๏ธ **MCP Integration**: Works seamlessly with Claude Code - ๐Ÿงช **Well-tested**: Comprehensive test coverage +- ๐Ÿš€ **Simple & Fast**: Minimal dependencies, pure Rust ## Quick Start @@ -47,30 +62,87 @@ aigpt stats claude mcp add aigpt /path/to/aigpt/target/release/aigpt server ``` -Then use in Claude Code: -- "Remember that tomorrow will be sunny" -- "Search for weather information" -- "Show all my memories" +## MCP Tools + +### Layer 1: Basic Memory (6 tools) +- `create_memory` - Simple memory creation +- `get_memory` - Retrieve by ID +- `list_memories` - List all memories +- `search_memories` - Content-based search +- `update_memory` - Update existing memory +- `delete_memory` - Remove memory + +### Layer 2: AI Memory (1 tool) +- `create_ai_memory` - Create with AI interpretation and priority score + +### Layer 3: Personality Analysis (2 tools) +- `save_user_analysis` - Save Big Five personality analysis +- `get_user_analysis` - Retrieve latest personality profile + +## Usage Examples in Claude Code + +### Layer 1: Simple Memory +``` +Remember that the project deadline is next Friday. +``` +Claude will use `create_memory` automatically. + +### Layer 2: AI Memory with Evaluation +``` +create_ai_memory({ + content: "Designed a new microservices architecture", + ai_interpretation: "Shows technical creativity and strategic thinking", + priority_score: 0.85 +}) +``` + +### Layer 3: Personality Analysis +``` +# After accumulating memories, analyze personality +save_user_analysis({ + openness: 0.8, + conscientiousness: 0.7, + extraversion: 0.4, + agreeableness: 0.65, + neuroticism: 0.3, + summary: "High creativity and planning ability, introverted personality" +}) + +# Retrieve analysis +get_user_analysis() +``` + +## Big Five Personality Traits + +- **Openness**: Creativity, curiosity, openness to new experiences +- **Conscientiousness**: Organization, planning, reliability +- **Extraversion**: Social energy, assertiveness, outgoingness +- **Agreeableness**: Cooperation, empathy, kindness +- **Neuroticism**: Emotional stability (low = stable, high = sensitive) + +Scores range from 0.0 to 1.0, where higher scores indicate stronger trait expression. ## Storage Location -Memories are stored in: `~/.config/syui/ai/gpt/memory.db` +All data stored in: `~/.config/syui/ai/gpt/memory.db` ## Architecture -This is **Layer 1** of a planned multi-layer system: +Multi-layer system design: -- **Layer 1** (Current): Pure memory storage -- **Layer 2** (Planned): AI interpretation with priority scoring -- **Layer 3** (Planned): User evaluation and diagnosis -- **Layer 4** (Planned): Game systems and companion features +- **Layer 1** โœ… Complete: Pure memory storage +- **Layer 2** โœ… Complete: AI interpretation with priority scoring +- **Layer 3** โœ… Complete: Big Five personality analysis +- **Layer 4** ๐Ÿ”ต Planned: Game systems and companion features +- **Layer 5** ๐Ÿ”ต Future: Distribution and sharing See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for details. ## Documentation -- [Layer 1 Details](docs/LAYER1.md) - Technical details of current implementation - [Architecture](docs/ARCHITECTURE.md) - Multi-layer system design +- [Layer 1 Details](docs/LAYER1.md) - Technical details of memory storage +- [Old Versions](docs/archive/old-versions/) - Previous documentation ## Development @@ -85,6 +157,10 @@ cargo build --release RUST_LOG=debug aigpt server ``` +## Design Philosophy + +**"AI evolves, tools don't"** - This tool provides simple, reliable storage while AI (Claude) handles interpretation, evaluation, and analysis. The tool focuses on being maintainable and stable. + ## License MIT diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 8875b0b..bd644e9 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -12,29 +12,29 @@ aigptใฏใ€็‹ฌ็ซ‹ใ—ใŸใƒฌใ‚คใƒคใƒผใ‚’็ฉใฟ้‡ใญใ‚‹่จญ่จˆใงใ™ใ€‚ๅ„ใƒฌใ‚คใƒค ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ Layer 5: Distribution & Sharing โ”‚ Future +โ”‚ Layer 5: Distribution & Sharing โ”‚ ๐Ÿ”ต Future โ”‚ (Game streaming, public/private) โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ Layer 4b: AI Companion โ”‚ Future +โ”‚ Layer 4b: AI Companion โ”‚ ๐Ÿ”ต Planned โ”‚ (Romance system, personality growth) โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ Layer 4a: Game Systems โ”‚ Future +โ”‚ Layer 4a: Game Systems โ”‚ ๐Ÿ”ต Planned โ”‚ (Ranking, rarity, XP, visualization) โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ Layer 3: User Evaluation โ”‚ Future -โ”‚ (Personality diagnosis from patterns) โ”‚ +โ”‚ Layer 3: User Evaluation โ”‚ โœ… Complete +โ”‚ (Big Five personality analysis) โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ Layer 2: AI Memory โ”‚ Future +โ”‚ Layer 2: AI Memory โ”‚ โœ… Complete โ”‚ (Claude interpretation, priority_score)โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ Layer 1: Pure Memory Storage โ”‚ โœ… Current +โ”‚ Layer 1: Pure Memory Storage โ”‚ โœ… Complete โ”‚ (SQLite, ULID, CRUD operations) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` -## Layer 1: Pure Memory Storage (Current) +## Layer 1: Pure Memory Storage -**Status**: โœ… **Implemented & Tested** +**Status**: โœ… **Complete** ### Purpose ๆญฃ็ขบใชใƒ‡ใƒผใ‚ฟใฎไฟๅญ˜ใจๅ‚็…งใ€‚ใ‚ทใƒณใƒ—ใƒซใงไฟก้ ผใงใใ‚‹ๅŸบ็›คใ€‚ @@ -86,16 +86,16 @@ src/ --- -## Layer 2: AI Memory (Planned) +## Layer 2: AI Memory -**Status**: ๐Ÿ”ต **Planned** +**Status**: โœ… **Complete** ### Purpose -ClaudeใŒ่จ˜ๆ†ถๅ†…ๅฎนใ‚’่งฃ้‡ˆใ—ใ€้‡่ฆๅบฆใ‚’่ฉ•ไพกใ€‚ +ClaudeใŒ่จ˜ๆ†ถๅ†…ๅฎนใ‚’่งฃ้‡ˆใ—ใ€้‡่ฆๅบฆใ‚’่ฉ•ไพกใ€‚ไบบ้–“ใฎ่จ˜ๆ†ถใƒ—ใƒญใ‚ปใ‚น๏ผˆ่จ˜ๆ†ถใจๅŒๆ™‚ใซ่ฉ•ไพก๏ผ‰ใ‚’ๆจกๅ€ฃใ€‚ ### Extended Data Model ```rust -pub struct AIMemory { +pub struct Memory { // Layer 1 fields pub id: String, pub content: String, @@ -103,63 +103,75 @@ pub struct AIMemory { pub updated_at: DateTime, // Layer 2 additions - pub interpreted_content: String, // Claude's interpretation - pub priority_score: f32, // 0.0 - 1.0 - pub psychological_factors: PsychologicalFactors, -} - -pub struct PsychologicalFactors { - pub emotional_weight: f32, // 0.0 - 1.0 - pub personal_relevance: f32, // 0.0 - 1.0 - pub novelty: f32, // 0.0 - 1.0 - pub utility: f32, // 0.0 - 1.0 + pub ai_interpretation: Option, // Claude's interpretation + pub priority_score: Option, // 0.0 - 1.0 } ``` -### MCP Tools (Additional) -- `create_memory_with_ai` - Create with Claude interpretation -- `reinterpret_memory` - Re-evaluate existing memory -- `get_high_priority` - Get memories above threshold +### MCP Tools +- `create_ai_memory` - Create memory with AI interpretation and priority score + - `content`: Memory content + - `ai_interpretation`: Optional AI interpretation + - `priority_score`: Optional priority (0.0-1.0) -### Implementation Strategy -- Feature flag: `--features ai-memory` -- Backward compatible with Layer 1 +### Philosophy +"AIใฏ้€ฒๅŒ–ใ—ใพใ™ใŒใ€ใƒ„ใƒผใƒซใฏ้€ฒๅŒ–ใ—ใพใ›ใ‚“" - AIใŒๅˆคๆ–ญใ—ใ€ใƒ„ใƒผใƒซใฏ่จ˜้Œฒใฎใฟใ€‚ + +### Implementation +- Backward compatible with Layer 1 (Optional fields) +- Automatic schema migration from Layer 1 - Claude Code does interpretation (no external API) --- -## Layer 3: User Evaluation (Planned) +## Layer 3: User Evaluation -**Status**: ๐Ÿ”ต **Planned** +**Status**: โœ… **Complete** ### Purpose -ใƒกใƒขใƒชใƒ‘ใ‚ฟใƒผใƒณใ‹ใ‚‰ใƒฆใƒผใ‚ถใƒผใฎๆ€งๆ ผใ‚’่จบๆ–ญใ€‚ +Layer 2ใฎใƒกใƒขใƒชใƒ‘ใ‚ฟใƒผใƒณใ‹ใ‚‰ใƒฆใƒผใ‚ถใƒผใฎๆ€งๆ ผใ‚’ๅˆ†ๆžใ€‚Big Fiveๅฟƒ็†ๅญฆใƒขใƒ‡ใƒซใ‚’ไฝฟ็”จใ€‚ -### Diagnosis Types +### Data Model ```rust -pub enum DiagnosisType { - Innovator, // ้ฉๆ–ฐ่€… - Philosopher, // ๅ“ฒๅญฆ่€… - Pragmatist, // ๅฎŸ็”จไธป็พฉ่€… - Explorer, // ๆŽขๆคœๅฎถ - Protector, // ไฟ่ญท่€… - Visionary, // ๆœชๆฅๅฟ—ๅ‘ +pub struct UserAnalysis { + pub id: String, + pub openness: f32, // 0.0-1.0: ๅ‰ต้€ ๆ€งใ€ๅฅฝๅฅ‡ๅฟƒ + pub conscientiousness: f32, // 0.0-1.0: ่จˆ็”ปๆ€งใ€ไฟก้ ผๆ€ง + pub extraversion: f32, // 0.0-1.0: ๅค–ๅ‘ๆ€งใ€็คพไบคๆ€ง + pub agreeableness: f32, // 0.0-1.0: ๅ”่ชฟๆ€งใ€ๅ…ฑๆ„Ÿๆ€ง + pub neuroticism: f32, // 0.0-1.0: ็ฅž็ตŒ่ณชใ•๏ผˆไฝŽใ„=ๅฎ‰ๅฎš๏ผ‰ + pub summary: String, // ๅˆ†ๆžใ‚ตใƒžใƒชใƒผ + pub analyzed_at: DateTime, } ``` -### Analysis -- Memory content patterns -- Priority score distribution -- Creation frequency -- Topic diversity +### Big Five Model +ๅฟƒ็†ๅญฆใงๆœ€ใ‚‚ไฟก้ ผๆ€งใฎ้ซ˜ใ„ๆ€งๆ ผใƒขใƒ‡ใƒซ๏ผˆOCEAN๏ผ‰๏ผš +- **O**penness: ๆ–ฐใ—ใ„็ตŒ้จ“ใธใฎ้–‹ใ‹ใ‚Œใ• +- **C**onscientiousness: ่ช ๅฎŸๆ€งใ€่จˆ็”ปๆ€ง +- **E**xtraversion: ๅค–ๅ‘ๆ€ง +- **A**greeableness: ๅ”่ชฟๆ€ง +- **N**euroticism: ็ฅž็ตŒ่ณชใ• -### MCP Tools (Additional) -- `diagnose_user` - Run personality diagnosis -- `get_user_profile` - Get analysis summary +### Analysis Process +1. Layer 2ใƒกใƒขใƒชใ‚’่“„็ฉ +2. AIใŒใƒ‘ใ‚ฟใƒผใƒณใ‚’ๅˆ†ๆž๏ผˆๆดปๅ‹•ใฎ็จฎ้กžใ€ๅ„ชๅ…ˆๅบฆใฎๅ‚พๅ‘ใชใฉ๏ผ‰ +3. Big Fiveใ‚นใ‚ณใ‚ขใ‚’ๆŽจๆธฌ +4. ๅˆ†ๆž็ตๆžœใ‚’ไฟๅญ˜ + +### MCP Tools +- `save_user_analysis` - Save Big Five personality analysis + - All 5 traits (0.0-1.0) + summary +- `get_user_analysis` - Get latest personality profile + +### Storage +- SQLite table: `user_analyses` +- Historical tracking: Compare analyses over time +- Helper methods: `dominant_trait()`, `is_high()` --- -## Layer 4a: Game Systems (Planned) +## Layer 4a: Game Systems **Status**: ๐Ÿ”ต **Planned** @@ -184,7 +196,7 @@ pub struct GameMemory { --- -## Layer 4b: AI Companion (Planned) +## Layer 4b: AI Companion **Status**: ๐Ÿ”ต **Planned** @@ -236,21 +248,27 @@ pub struct Companion { - [x] Tests - [x] Documentation -### Phase 2: Layer 2 (Next) -- [ ] Add AI interpretation fields to schema -- [ ] Implement priority scoring logic -- [ ] Create `create_memory_with_ai` tool -- [ ] Update MCP server -- [ ] Write tests for AI features +### Phase 2: Layer 2 โœ… (Complete) +- [x] Add AI interpretation fields to schema +- [x] Implement priority scoring logic +- [x] Create `create_ai_memory` tool +- [x] Update MCP server +- [x] Automatic schema migration +- [x] Backward compatibility -### Phase 3: Layers 3-4 (Future) -- [ ] User diagnosis system -- [ ] Game mechanics -- [ ] Companion system +### Phase 3: Layer 3 โœ… (Complete) +- [x] Big Five personality model +- [x] UserAnalysis data structure +- [x] user_analyses table +- [x] `save_user_analysis` tool +- [x] `get_user_analysis` tool +- [x] Historical tracking support -### Phase 4: Layer 5 (Future) -- [ ] Sharing mechanisms -- [ ] Public/private modes +### Phase 4: Layers 4-5 (Next) +- [ ] Game mechanics (Layer 4a) +- [ ] Companion system (Layer 4b) +- [ ] Sharing mechanisms (Layer 5) +- [ ] Public/private modes (Layer 5) ## Design Principles @@ -330,5 +348,5 @@ src/ --- **Version**: 0.2.0 -**Last Updated**: 2025-11-05 -**Current Layer**: 1 +**Last Updated**: 2025-11-06 +**Current Status**: Layers 1-3 Complete, Layer 4 Planned diff --git a/docs/archive/old-versions/ARCHITECTURE.md.layer1 b/docs/archive/old-versions/ARCHITECTURE.md.layer1 new file mode 100644 index 0000000..8875b0b --- /dev/null +++ b/docs/archive/old-versions/ARCHITECTURE.md.layer1 @@ -0,0 +1,334 @@ +# Architecture: Multi-Layer Memory System + +## Design Philosophy + +aigptใฏใ€็‹ฌ็ซ‹ใ—ใŸใƒฌใ‚คใƒคใƒผใ‚’็ฉใฟ้‡ใญใ‚‹่จญ่จˆใงใ™ใ€‚ๅ„ใƒฌใ‚คใƒคใƒผใฏ๏ผš + +- **็‹ฌ็ซ‹ๆ€ง**: ๅ˜็‹ฌใงๅ‹•ไฝœๅฏ่ƒฝ +- **ๆŽฅ็ถšๆ€ง**: ไป–ใฎใƒฌใ‚คใƒคใƒผใจ้€ฃๆบๅฏ่ƒฝ +- **ๆฎต้šŽ็š„**: 1ใคใšใคๅฎŸ่ฃ…ใƒปใƒ†ใ‚นใƒˆ + +## Layer Overview + +``` +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ Layer 5: Distribution & Sharing โ”‚ Future +โ”‚ (Game streaming, public/private) โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ Layer 4b: AI Companion โ”‚ Future +โ”‚ (Romance system, personality growth) โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ Layer 4a: Game Systems โ”‚ Future +โ”‚ (Ranking, rarity, XP, visualization) โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ Layer 3: User Evaluation โ”‚ Future +โ”‚ (Personality diagnosis from patterns) โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ Layer 2: AI Memory โ”‚ Future +โ”‚ (Claude interpretation, priority_score)โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ Layer 1: Pure Memory Storage โ”‚ โœ… Current +โ”‚ (SQLite, ULID, CRUD operations) โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +## Layer 1: Pure Memory Storage (Current) + +**Status**: โœ… **Implemented & Tested** + +### Purpose +ๆญฃ็ขบใชใƒ‡ใƒผใ‚ฟใฎไฟๅญ˜ใจๅ‚็…งใ€‚ใ‚ทใƒณใƒ—ใƒซใงไฟก้ ผใงใใ‚‹ๅŸบ็›คใ€‚ + +### Technology Stack +- **Database**: SQLite with ACID guarantees +- **IDs**: ULID (time-sortable, 26 chars) +- **Language**: Rust with thiserror/anyhow +- **Protocol**: MCP (Model Context Protocol) via stdio + +### Data Model +```rust +pub struct Memory { + pub id: String, // ULID + pub content: String, // User content + pub created_at: DateTime, + pub updated_at: DateTime, +} +``` + +### Operations +- `create()` - Insert new memory +- `get(id)` - Retrieve by ID +- `update()` - Update existing memory +- `delete(id)` - Remove memory +- `list()` - List all (sorted by created_at DESC) +- `search(query)` - Content-based search +- `count()` - Total count + +### File Structure +``` +src/ +โ”œโ”€โ”€ core/ +โ”‚ โ”œโ”€โ”€ error.rs - Error types (thiserror) +โ”‚ โ”œโ”€โ”€ memory.rs - Memory struct +โ”‚ โ”œโ”€โ”€ store.rs - SQLite operations +โ”‚ โ””โ”€โ”€ mod.rs - Module exports +โ”œโ”€โ”€ mcp/ +โ”‚ โ”œโ”€โ”€ base.rs - MCP server +โ”‚ โ””โ”€โ”€ mod.rs - Module exports +โ”œโ”€โ”€ lib.rs - Library root +โ””โ”€โ”€ main.rs - CLI application +``` + +### Storage +- Location: `~/.config/syui/ai/gpt/memory.db` +- Schema: Single table with indexes on timestamps +- No migrations (fresh start for Layer 1) + +--- + +## Layer 2: AI Memory (Planned) + +**Status**: ๐Ÿ”ต **Planned** + +### Purpose +ClaudeใŒ่จ˜ๆ†ถๅ†…ๅฎนใ‚’่งฃ้‡ˆใ—ใ€้‡่ฆๅบฆใ‚’่ฉ•ไพกใ€‚ + +### Extended Data Model +```rust +pub struct AIMemory { + // Layer 1 fields + pub id: String, + pub content: String, + pub created_at: DateTime, + pub updated_at: DateTime, + + // Layer 2 additions + pub interpreted_content: String, // Claude's interpretation + pub priority_score: f32, // 0.0 - 1.0 + pub psychological_factors: PsychologicalFactors, +} + +pub struct PsychologicalFactors { + pub emotional_weight: f32, // 0.0 - 1.0 + pub personal_relevance: f32, // 0.0 - 1.0 + pub novelty: f32, // 0.0 - 1.0 + pub utility: f32, // 0.0 - 1.0 +} +``` + +### MCP Tools (Additional) +- `create_memory_with_ai` - Create with Claude interpretation +- `reinterpret_memory` - Re-evaluate existing memory +- `get_high_priority` - Get memories above threshold + +### Implementation Strategy +- Feature flag: `--features ai-memory` +- Backward compatible with Layer 1 +- Claude Code does interpretation (no external API) + +--- + +## Layer 3: User Evaluation (Planned) + +**Status**: ๐Ÿ”ต **Planned** + +### Purpose +ใƒกใƒขใƒชใƒ‘ใ‚ฟใƒผใƒณใ‹ใ‚‰ใƒฆใƒผใ‚ถใƒผใฎๆ€งๆ ผใ‚’่จบๆ–ญใ€‚ + +### Diagnosis Types +```rust +pub enum DiagnosisType { + Innovator, // ้ฉๆ–ฐ่€… + Philosopher, // ๅ“ฒๅญฆ่€… + Pragmatist, // ๅฎŸ็”จไธป็พฉ่€… + Explorer, // ๆŽขๆคœๅฎถ + Protector, // ไฟ่ญท่€… + Visionary, // ๆœชๆฅๅฟ—ๅ‘ +} +``` + +### Analysis +- Memory content patterns +- Priority score distribution +- Creation frequency +- Topic diversity + +### MCP Tools (Additional) +- `diagnose_user` - Run personality diagnosis +- `get_user_profile` - Get analysis summary + +--- + +## Layer 4a: Game Systems (Planned) + +**Status**: ๐Ÿ”ต **Planned** + +### Purpose +ใ‚ฒใƒผใƒ ็š„่ฆ็ด ใง่จ˜ๆ†ถ็ฎก็†ใ‚’ๆฅฝใ—ใใ€‚ + +### Features +- **Rarity Levels**: Common โ†’ Uncommon โ†’ Rare โ†’ Epic โ†’ Legendary +- **XP System**: Memory creation earns XP +- **Rankings**: Based on total priority score +- **Visualization**: Game-style output formatting + +### Data Additions +```rust +pub struct GameMemory { + // Previous layers... + pub rarity: RarityLevel, + pub xp_value: u32, + pub discovered_at: DateTime, +} +``` + +--- + +## Layer 4b: AI Companion (Planned) + +**Status**: ๐Ÿ”ต **Planned** + +### Purpose +่‚ฒๆˆๅฏ่ƒฝใชๆ‹ๆ„›ใ‚ณใƒณใƒ‘ใƒ‹ใ‚ชใƒณใ€‚ + +### Features +- Personality types (Tsundere, Kuudere, Genki, etc.) +- Relationship level (0-100) +- Memory-based interactions +- Growth through conversations + +### Data Model +```rust +pub struct Companion { + pub id: String, + pub name: String, + pub personality: CompanionPersonality, + pub relationship_level: u8, // 0-100 + pub memories_shared: Vec, + pub last_interaction: DateTime, +} +``` + +--- + +## Layer 5: Distribution (Future) + +**Status**: ๐Ÿ”ต **Future Consideration** + +### Purpose +ใ‚ฒใƒผใƒ ้…ไฟกใ‚„ๅ…ฑๆœ‰ๆฉŸ่ƒฝใ€‚ + +### Ideas +- Share memory rankings +- Export as shareable format +- Public/private memory modes +- Integration with streaming platforms + +--- + +## Implementation Strategy + +### Phase 1: Layer 1 โœ… (Complete) +- [x] Core memory storage +- [x] SQLite integration +- [x] MCP server +- [x] CLI interface +- [x] Tests +- [x] Documentation + +### Phase 2: Layer 2 (Next) +- [ ] Add AI interpretation fields to schema +- [ ] Implement priority scoring logic +- [ ] Create `create_memory_with_ai` tool +- [ ] Update MCP server +- [ ] Write tests for AI features + +### Phase 3: Layers 3-4 (Future) +- [ ] User diagnosis system +- [ ] Game mechanics +- [ ] Companion system + +### Phase 4: Layer 5 (Future) +- [ ] Sharing mechanisms +- [ ] Public/private modes + +## Design Principles + +1. **Simplicity First**: Each layer adds complexity incrementally +2. **Backward Compatibility**: New layers don't break old ones +3. **Feature Flags**: Optional features via Cargo features +4. **Independent Testing**: Each layer has its own test suite +5. **Clear Boundaries**: Layers communicate through defined interfaces + +## Technology Choices + +### Why SQLite? +- ACID guarantees +- Better querying than JSON +- Built-in indexes +- Single-file deployment +- No server needed + +### Why ULID? +- Time-sortable (unlike UUID v4) +- Lexicographically sortable +- 26 characters (compact) +- No collision concerns + +### Why Rust? +- Memory safety +- Performance +- Excellent error handling +- Strong type system +- Great tooling (cargo, clippy) + +### Why MCP? +- Standard protocol for AI tools +- Works with Claude Code/Desktop +- Simple stdio-based communication +- No complex networking + +## Future Considerations + +### Potential Enhancements +- Full-text search (SQLite FTS5) +- Tag system +- Memory relationships/links +- Export/import functionality +- Multiple databases +- Encryption for sensitive data + +### Scalability +- Layer 1: Handles 10K+ memories easily +- Consider pagination for Layer 4 (UI display) +- Indexing strategy for search performance + +## Development Guidelines + +### Adding a New Layer + +1. **Design**: Document data model and operations +2. **Feature Flag**: Add to Cargo.toml +3. **Schema**: Extend database schema (migrations) +4. **Implementation**: Write code in new module +5. **Tests**: Comprehensive test coverage +6. **MCP Tools**: Add new MCP tools if needed +7. **Documentation**: Update this file + +### Code Organization + +``` +src/ +โ”œโ”€โ”€ core/ # Layer 1: Pure storage +โ”œโ”€โ”€ ai/ # Layer 2: AI features (future) +โ”œโ”€โ”€ evaluation/ # Layer 3: User diagnosis (future) +โ”œโ”€โ”€ game/ # Layer 4a: Game systems (future) +โ”œโ”€โ”€ companion/ # Layer 4b: Companion (future) +โ””โ”€โ”€ mcp/ # MCP server (all layers) +``` + +--- + +**Version**: 0.2.0 +**Last Updated**: 2025-11-05 +**Current Layer**: 1 diff --git a/docs/archive/old-versions/README.md.layer1 b/docs/archive/old-versions/README.md.layer1 new file mode 100644 index 0000000..0598e41 --- /dev/null +++ b/docs/archive/old-versions/README.md.layer1 @@ -0,0 +1,94 @@ +# aigpt + +Simple memory storage for Claude with MCP support. + +**Layer 1: Pure Memory Storage** - A clean, SQLite-based memory system with ULID identifiers. + +## Features + +- ๐Ÿ—„๏ธ **SQLite Storage**: Reliable database with ACID guarantees +- ๐Ÿ”– **ULID IDs**: Time-sortable, 26-character unique identifiers +- ๐Ÿ” **Search**: Fast content-based search +- ๐Ÿ› ๏ธ **MCP Integration**: Works seamlessly with Claude Code +- ๐Ÿงช **Well-tested**: Comprehensive test coverage + +## Quick Start + +### Installation + +```bash +# Build +cargo build --release + +# Install (optional) +cp target/release/aigpt ~/.cargo/bin/ +``` + +### CLI Usage + +```bash +# Create a memory +aigpt create "Remember this information" + +# List all memories +aigpt list + +# Search memories +aigpt search "keyword" + +# Show statistics +aigpt stats +``` + +### MCP Integration with Claude Code + +```bash +# Add to Claude Code +claude mcp add aigpt /path/to/aigpt/target/release/aigpt server +``` + +Then use in Claude Code: +- "Remember that tomorrow will be sunny" +- "Search for weather information" +- "Show all my memories" + +## Storage Location + +Memories are stored in: `~/.config/syui/ai/gpt/memory.db` + +## Architecture + +This is **Layer 1** of a planned multi-layer system: + +- **Layer 1** (Current): Pure memory storage +- **Layer 2** (Planned): AI interpretation with priority scoring +- **Layer 3** (Planned): User evaluation and diagnosis +- **Layer 4** (Planned): Game systems and companion features + +See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for details. + +## Documentation + +- [Layer 1 Details](docs/LAYER1.md) - Technical details of current implementation +- [Architecture](docs/ARCHITECTURE.md) - Multi-layer system design + +## Development + +```bash +# Run tests +cargo test + +# Build for release +cargo build --release + +# Run with verbose logging +RUST_LOG=debug aigpt server +``` + +## License + +MIT + +## Author + +syui