claude-memory-agent 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +107 -0
- package/README.md +200 -0
- package/agent_card.py +512 -0
- package/bin/cli.js +181 -0
- package/bin/postinstall.js +216 -0
- package/config.py +104 -0
- package/dashboard.html +2689 -0
- package/hooks/README.md +196 -0
- package/hooks/__pycache__/auto-detect-response.cpython-312.pyc +0 -0
- package/hooks/__pycache__/auto_capture.cpython-312.pyc +0 -0
- package/hooks/__pycache__/session_end.cpython-312.pyc +0 -0
- package/hooks/__pycache__/session_start.cpython-312.pyc +0 -0
- package/hooks/auto-detect-response.py +348 -0
- package/hooks/auto_capture.py +255 -0
- package/hooks/detect-correction.py +173 -0
- package/hooks/grounding-hook.py +348 -0
- package/hooks/log-tool-use.py +234 -0
- package/hooks/log-user-request.py +208 -0
- package/hooks/pre-tool-decision.py +218 -0
- package/hooks/problem-detector.py +343 -0
- package/hooks/session_end.py +192 -0
- package/hooks/session_start.py +227 -0
- package/install.py +887 -0
- package/main.py +2859 -0
- package/manager.py +997 -0
- package/package.json +55 -0
- package/requirements.txt +8 -0
- package/run_server.py +136 -0
- package/services/__init__.py +50 -0
- package/services/__pycache__/__init__.cpython-312.pyc +0 -0
- package/services/__pycache__/agent_registry.cpython-312.pyc +0 -0
- package/services/__pycache__/auth.cpython-312.pyc +0 -0
- package/services/__pycache__/auto_inject.cpython-312.pyc +0 -0
- package/services/__pycache__/claude_md_sync.cpython-312.pyc +0 -0
- package/services/__pycache__/cleanup.cpython-312.pyc +0 -0
- package/services/__pycache__/compaction_flush.cpython-312.pyc +0 -0
- package/services/__pycache__/confidence.cpython-312.pyc +0 -0
- package/services/__pycache__/daily_log.cpython-312.pyc +0 -0
- package/services/__pycache__/database.cpython-312.pyc +0 -0
- package/services/__pycache__/embeddings.cpython-312.pyc +0 -0
- package/services/__pycache__/insights.cpython-312.pyc +0 -0
- package/services/__pycache__/llm_analyzer.cpython-312.pyc +0 -0
- package/services/__pycache__/memory_md_sync.cpython-312.pyc +0 -0
- package/services/__pycache__/retry_queue.cpython-312.pyc +0 -0
- package/services/__pycache__/timeline.cpython-312.pyc +0 -0
- package/services/__pycache__/vector_index.cpython-312.pyc +0 -0
- package/services/__pycache__/websocket.cpython-312.pyc +0 -0
- package/services/agent_registry.py +753 -0
- package/services/auth.py +331 -0
- package/services/auto_inject.py +250 -0
- package/services/claude_md_sync.py +275 -0
- package/services/cleanup.py +667 -0
- package/services/compaction_flush.py +447 -0
- package/services/confidence.py +301 -0
- package/services/daily_log.py +333 -0
- package/services/database.py +2485 -0
- package/services/embeddings.py +358 -0
- package/services/insights.py +632 -0
- package/services/llm_analyzer.py +595 -0
- package/services/memory_md_sync.py +409 -0
- package/services/retry_queue.py +453 -0
- package/services/timeline.py +579 -0
- package/services/vector_index.py +398 -0
- package/services/websocket.py +257 -0
- package/skills/__init__.py +6 -0
- package/skills/__pycache__/__init__.cpython-312.pyc +0 -0
- package/skills/__pycache__/admin.cpython-312.pyc +0 -0
- package/skills/__pycache__/checkpoint.cpython-312.pyc +0 -0
- package/skills/__pycache__/claude_md.cpython-312.pyc +0 -0
- package/skills/__pycache__/cleanup.cpython-312.pyc +0 -0
- package/skills/__pycache__/grounding.cpython-312.pyc +0 -0
- package/skills/__pycache__/insights.cpython-312.pyc +0 -0
- package/skills/__pycache__/natural_language.cpython-312.pyc +0 -0
- package/skills/__pycache__/retrieve.cpython-312.pyc +0 -0
- package/skills/__pycache__/search.cpython-312.pyc +0 -0
- package/skills/__pycache__/state.cpython-312.pyc +0 -0
- package/skills/__pycache__/store.cpython-312.pyc +0 -0
- package/skills/__pycache__/summarize.cpython-312.pyc +0 -0
- package/skills/__pycache__/timeline.cpython-312.pyc +0 -0
- package/skills/__pycache__/verification.cpython-312.pyc +0 -0
- package/skills/admin.py +469 -0
- package/skills/checkpoint.py +198 -0
- package/skills/claude_md.py +363 -0
- package/skills/cleanup.py +241 -0
- package/skills/grounding.py +801 -0
- package/skills/insights.py +231 -0
- package/skills/natural_language.py +277 -0
- package/skills/retrieve.py +67 -0
- package/skills/search.py +213 -0
- package/skills/state.py +182 -0
- package/skills/store.py +179 -0
- package/skills/summarize.py +588 -0
- package/skills/timeline.py +387 -0
- package/skills/verification.py +391 -0
- package/start_daemon.py +155 -0
- package/test_automation.py +221 -0
- package/test_complete.py +338 -0
- package/test_full.py +322 -0
- package/update_system.py +817 -0
- package/verify_db.py +134 -0
package/.env.example
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# Claude Memory Agent - Environment Configuration
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Copy this file to .env and customize as needed.
|
|
5
|
+
# Default values are shown - uncomment and modify to override.
|
|
6
|
+
# =============================================================================
|
|
7
|
+
|
|
8
|
+
# -----------------------------------------------------------------------------
|
|
9
|
+
# SERVER CONFIGURATION
|
|
10
|
+
# -----------------------------------------------------------------------------
|
|
11
|
+
# Host address to bind to (0.0.0.0 for all interfaces, 127.0.0.1 for localhost only)
|
|
12
|
+
# HOST=0.0.0.0
|
|
13
|
+
|
|
14
|
+
# Port for the Memory Agent server
|
|
15
|
+
# PORT=8102
|
|
16
|
+
|
|
17
|
+
# -----------------------------------------------------------------------------
|
|
18
|
+
# API URL FOR HOOKS
|
|
19
|
+
# -----------------------------------------------------------------------------
|
|
20
|
+
# URL that hooks use to communicate with the Memory Agent
|
|
21
|
+
# This should match the server host:port configuration
|
|
22
|
+
# MEMORY_AGENT_URL=http://localhost:8102
|
|
23
|
+
|
|
24
|
+
# -----------------------------------------------------------------------------
|
|
25
|
+
# HOOK TIMEOUTS
|
|
26
|
+
# -----------------------------------------------------------------------------
|
|
27
|
+
# Timeout in seconds for API calls from hooks to the Memory Agent
|
|
28
|
+
# API_TIMEOUT=30
|
|
29
|
+
|
|
30
|
+
# -----------------------------------------------------------------------------
|
|
31
|
+
# OLLAMA / EMBEDDINGS CONFIGURATION
|
|
32
|
+
# -----------------------------------------------------------------------------
|
|
33
|
+
# Ollama server URL
|
|
34
|
+
# OLLAMA_HOST=http://localhost:11434
|
|
35
|
+
|
|
36
|
+
# Default embedding model to use
|
|
37
|
+
# Supported models: nomic-embed-text, mxbai-embed-large, all-minilm,
|
|
38
|
+
# snowflake-arctic-embed, bge-m3
|
|
39
|
+
# EMBEDDING_MODEL=nomic-embed-text
|
|
40
|
+
|
|
41
|
+
# Timeout for Ollama health checks (seconds)
|
|
42
|
+
# OLLAMA_HEALTH_TIMEOUT=2.0
|
|
43
|
+
|
|
44
|
+
# How long to cache Ollama health check results (seconds)
|
|
45
|
+
# OLLAMA_HEALTH_CACHE_TTL=30.0
|
|
46
|
+
|
|
47
|
+
# -----------------------------------------------------------------------------
|
|
48
|
+
# DATABASE CONFIGURATION
|
|
49
|
+
# -----------------------------------------------------------------------------
|
|
50
|
+
# Path to the SQLite database file
|
|
51
|
+
# DATABASE_PATH=./memories.db
|
|
52
|
+
|
|
53
|
+
# Enable FAISS vector indexing for faster similarity search
|
|
54
|
+
# USE_VECTOR_INDEX=true
|
|
55
|
+
|
|
56
|
+
# Connection pool size (number of concurrent connections)
|
|
57
|
+
# DB_POOL_SIZE=5
|
|
58
|
+
|
|
59
|
+
# Query timeout in seconds
|
|
60
|
+
# DB_TIMEOUT=30.0
|
|
61
|
+
|
|
62
|
+
# Maximum retry attempts for failed queries
|
|
63
|
+
# DB_MAX_RETRIES=3
|
|
64
|
+
|
|
65
|
+
# Base delay for exponential backoff on retries (seconds)
|
|
66
|
+
# DB_RETRY_BASE_DELAY=0.1
|
|
67
|
+
|
|
68
|
+
# -----------------------------------------------------------------------------
|
|
69
|
+
# AUTHENTICATION CONFIGURATION
|
|
70
|
+
# -----------------------------------------------------------------------------
|
|
71
|
+
# Enable/disable API key authentication
|
|
72
|
+
# Set to "true" to require API keys for protected endpoints
|
|
73
|
+
# AUTH_ENABLED=true
|
|
74
|
+
|
|
75
|
+
# Path to the API keys storage file
|
|
76
|
+
# AUTH_KEY_FILE=~/.claude/memory-agent-keys.json
|
|
77
|
+
|
|
78
|
+
# Default rate limit for API keys (requests per minute)
|
|
79
|
+
# AUTH_RATE_LIMIT=100
|
|
80
|
+
|
|
81
|
+
# Rate limit window in seconds
|
|
82
|
+
# AUTH_RATE_WINDOW=60
|
|
83
|
+
|
|
84
|
+
# -----------------------------------------------------------------------------
|
|
85
|
+
# LOGGING
|
|
86
|
+
# -----------------------------------------------------------------------------
|
|
87
|
+
# Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
88
|
+
# LOG_LEVEL=INFO
|
|
89
|
+
|
|
90
|
+
# -----------------------------------------------------------------------------
|
|
91
|
+
# EXAMPLE: FULL PRODUCTION CONFIGURATION
|
|
92
|
+
# -----------------------------------------------------------------------------
|
|
93
|
+
# Uncomment the following block for a production setup:
|
|
94
|
+
#
|
|
95
|
+
# HOST=0.0.0.0
|
|
96
|
+
# PORT=8102
|
|
97
|
+
# MEMORY_AGENT_URL=http://localhost:8102
|
|
98
|
+
# API_TIMEOUT=30
|
|
99
|
+
# OLLAMA_HOST=http://localhost:11434
|
|
100
|
+
# EMBEDDING_MODEL=nomic-embed-text
|
|
101
|
+
# DATABASE_PATH=/var/lib/claude-memory/memories.db
|
|
102
|
+
# USE_VECTOR_INDEX=true
|
|
103
|
+
# DB_POOL_SIZE=10
|
|
104
|
+
# DB_TIMEOUT=30.0
|
|
105
|
+
# AUTH_ENABLED=true
|
|
106
|
+
# AUTH_KEY_FILE=/etc/claude-memory/keys.json
|
|
107
|
+
# LOG_LEVEL=WARNING
|
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Claude Memory Agent
|
|
2
|
+
|
|
3
|
+
A persistent semantic memory system for Claude Code sessions. Stores memories, tracks decisions, and provides anti-hallucination grounding context.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Semantic Memory Storage** - Store and retrieve memories using natural language
|
|
8
|
+
- **Session Timeline** - Track decisions, actions, and observations
|
|
9
|
+
- **Anti-Hallucination** - Grounding context injection to prevent contradictions
|
|
10
|
+
- **Pattern Learning** - Store and reuse successful solution patterns
|
|
11
|
+
- **Dashboard** - Web UI for browsing and managing memories
|
|
12
|
+
- **Claude Code Integration** - Hooks for automatic session tracking
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### 1. Prerequisites
|
|
17
|
+
|
|
18
|
+
- Node.js 16+ (for npm installation)
|
|
19
|
+
- Python 3.9+
|
|
20
|
+
- [Ollama](https://ollama.ai/) with `nomic-embed-text` model
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Install Ollama, then pull the embedding model
|
|
24
|
+
ollama pull nomic-embed-text
|
|
25
|
+
ollama serve # Start Ollama server
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Installation
|
|
29
|
+
|
|
30
|
+
#### Option A: Install via npm (Recommended)
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Install globally
|
|
34
|
+
npm install -g claude-memory-agent
|
|
35
|
+
|
|
36
|
+
# Run the setup wizard
|
|
37
|
+
claude-memory-agent install
|
|
38
|
+
|
|
39
|
+
# Start the agent
|
|
40
|
+
claude-memory-agent start
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Option B: Install via npx (No global install)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Run directly without installing
|
|
47
|
+
npx claude-memory-agent install
|
|
48
|
+
npx claude-memory-agent start
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### Option C: Clone from GitHub
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Clone the repository
|
|
55
|
+
git clone https://github.com/yourusername/claude-memory-agent.git
|
|
56
|
+
cd claude-memory-agent
|
|
57
|
+
|
|
58
|
+
# Run the installation wizard
|
|
59
|
+
python install.py
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The installer will:
|
|
63
|
+
- Install Python dependencies
|
|
64
|
+
- Create `.env` configuration file
|
|
65
|
+
- Configure Claude Code MCP settings
|
|
66
|
+
- Set up session tracking hooks
|
|
67
|
+
- Create platform-specific startup scripts
|
|
68
|
+
|
|
69
|
+
### 3. Start the Agent
|
|
70
|
+
|
|
71
|
+
**Windows:**
|
|
72
|
+
```bash
|
|
73
|
+
# Option 1: Double-click start-memory-agent.vbs
|
|
74
|
+
# Option 2: Use CLI
|
|
75
|
+
memory-agent start
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Mac/Linux:**
|
|
79
|
+
```bash
|
|
80
|
+
./start-memory-agent.sh
|
|
81
|
+
# or
|
|
82
|
+
python memory-agent start
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 4. Open Dashboard
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
memory-agent dashboard
|
|
89
|
+
# or open http://localhost:8102/dashboard
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## CLI Commands
|
|
93
|
+
|
|
94
|
+
### If installed via npm:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
claude-memory-agent install # Run setup wizard
|
|
98
|
+
claude-memory-agent start # Start agent in background
|
|
99
|
+
claude-memory-agent stop # Stop running agent
|
|
100
|
+
claude-memory-agent status # Check if agent is running
|
|
101
|
+
claude-memory-agent dashboard # Open web dashboard
|
|
102
|
+
claude-memory-agent logs # View recent log output
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### If cloned from GitHub:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
python memory-agent start # Start agent in background
|
|
109
|
+
python memory-agent stop # Stop running agent
|
|
110
|
+
python memory-agent status # Check if agent is running
|
|
111
|
+
python memory-agent dashboard # Open web dashboard
|
|
112
|
+
python memory-agent logs # View recent log output
|
|
113
|
+
python memory-agent install # Re-run installation wizard
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
117
|
+
|
|
118
|
+
Configuration is stored in `.env` (created during installation):
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Server
|
|
122
|
+
PORT=8102
|
|
123
|
+
HOST=0.0.0.0
|
|
124
|
+
MEMORY_AGENT_URL=http://localhost:8102
|
|
125
|
+
|
|
126
|
+
# Ollama / Embeddings
|
|
127
|
+
OLLAMA_HOST=http://localhost:11434
|
|
128
|
+
EMBEDDING_MODEL=nomic-embed-text
|
|
129
|
+
|
|
130
|
+
# Database
|
|
131
|
+
DATABASE_PATH=./memories.db
|
|
132
|
+
USE_VECTOR_INDEX=true
|
|
133
|
+
|
|
134
|
+
# Logging
|
|
135
|
+
LOG_LEVEL=INFO
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
See `.env.example` for all available options.
|
|
139
|
+
|
|
140
|
+
## MCP Tools
|
|
141
|
+
|
|
142
|
+
The agent provides these tools to Claude Code:
|
|
143
|
+
|
|
144
|
+
| Tool | Description |
|
|
145
|
+
|------|-------------|
|
|
146
|
+
| `memory_store` | Store a memory with semantic embedding |
|
|
147
|
+
| `memory_search` | Search memories by natural language |
|
|
148
|
+
| `memory_context` | Load session context and relevant memories |
|
|
149
|
+
| `memory_search_patterns` | Find reusable solution patterns |
|
|
150
|
+
| `memory_store_pattern` | Save a successful solution pattern |
|
|
151
|
+
| `memory_get_project` | Get project-specific information |
|
|
152
|
+
| `memory_store_project` | Store project configuration |
|
|
153
|
+
| `memory_stats` | Get memory system statistics |
|
|
154
|
+
| `memory_dashboard` | Open the web dashboard |
|
|
155
|
+
|
|
156
|
+
## Project Structure
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
claude-memory-agent/
|
|
160
|
+
├── main.py # FastAPI server
|
|
161
|
+
├── config.py # Centralized configuration
|
|
162
|
+
├── install.py # Installation wizard
|
|
163
|
+
├── memory-agent # CLI tool
|
|
164
|
+
├── services/ # Core services
|
|
165
|
+
│ ├── database.py # SQLite with connection pooling
|
|
166
|
+
│ ├── embeddings.py # Ollama integration
|
|
167
|
+
│ ├── vector_index.py # FAISS similarity search
|
|
168
|
+
│ └── websocket.py # Real-time updates
|
|
169
|
+
├── skills/ # A2A skill implementations
|
|
170
|
+
├── hooks/ # Claude Code hooks
|
|
171
|
+
├── .env.example # Configuration template
|
|
172
|
+
└── .gitignore # Excludes user-specific files
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Uninstall
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
python install.py --uninstall
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
This removes Claude Code integration but preserves your data.
|
|
182
|
+
|
|
183
|
+
## Troubleshooting
|
|
184
|
+
|
|
185
|
+
**Agent won't start:**
|
|
186
|
+
- Check if Ollama is running: `ollama serve`
|
|
187
|
+
- Check if port is in use: `netstat -an | grep 8102`
|
|
188
|
+
- Check logs: `memory-agent logs`
|
|
189
|
+
|
|
190
|
+
**No embeddings:**
|
|
191
|
+
- Pull the model: `ollama pull nomic-embed-text`
|
|
192
|
+
- Check Ollama host in `.env`
|
|
193
|
+
|
|
194
|
+
**Hooks not working:**
|
|
195
|
+
- Restart Claude Code after installation
|
|
196
|
+
- Check `~/.claude/hooks.json` configuration
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
MIT
|