nexusmemo 0.1.0__tar.gz
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.
- nexusmemo-0.1.0/.env.example +30 -0
- nexusmemo-0.1.0/.gitignore +37 -0
- nexusmemo-0.1.0/LICENSE +21 -0
- nexusmemo-0.1.0/PKG-INFO +177 -0
- nexusmemo-0.1.0/README.md +140 -0
- nexusmemo-0.1.0/memoryos_mvp_markdown_blueprint.md +543 -0
- nexusmemo-0.1.0/pyproject.toml +57 -0
- nexusmemo-0.1.0/src/nexusmemory/__init__.py +7 -0
- nexusmemo-0.1.0/src/nexusmemory/api.py +99 -0
- nexusmemo-0.1.0/src/nexusmemory/cli.py +129 -0
- nexusmemo-0.1.0/src/nexusmemory/config.py +57 -0
- nexusmemo-0.1.0/src/nexusmemory/core.py +287 -0
- nexusmemo-0.1.0/src/nexusmemory/database.py +120 -0
- nexusmemo-0.1.0/src/nexusmemory/embeddings.py +63 -0
- nexusmemo-0.1.0/src/nexusmemory/extraction.py +80 -0
- nexusmemo-0.1.0/src/nexusmemory/graph.py +208 -0
- nexusmemo-0.1.0/src/nexusmemory/importance.py +69 -0
- nexusmemo-0.1.0/src/nexusmemory/mcp_server.py +214 -0
- nexusmemo-0.1.0/src/nexusmemory/retrieval.py +205 -0
- nexusmemo-0.1.0/src/nexusmemory/schemas.py +117 -0
- nexusmemo-0.1.0/tests/__init__.py +1 -0
- nexusmemo-0.1.0/tests/test_core.py +192 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# NexusMemory Configuration
|
|
2
|
+
# Copy this file to .env and fill in your values
|
|
3
|
+
|
|
4
|
+
# --- LLM Provider ---
|
|
5
|
+
# Required: at least one API key
|
|
6
|
+
NEXUSMEMORY_OPENAI_API_KEY=sk-your-openai-key-here
|
|
7
|
+
# NEXUSMEMORY_ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
8
|
+
|
|
9
|
+
# Provider: "openai" or "anthropic"
|
|
10
|
+
NEXUSMEMORY_LLM_PROVIDER=openai
|
|
11
|
+
NEXUSMEMORY_EXTRACTION_MODEL=gpt-4o-mini
|
|
12
|
+
|
|
13
|
+
# --- Embeddings ---
|
|
14
|
+
# Provider: "openai" (default)
|
|
15
|
+
NEXUSMEMORY_EMBEDDING_PROVIDER=openai
|
|
16
|
+
NEXUSMEMORY_EMBEDDING_MODEL=text-embedding-3-small
|
|
17
|
+
NEXUSMEMORY_EMBEDDING_DIMENSIONS=1536
|
|
18
|
+
|
|
19
|
+
# --- Data ---
|
|
20
|
+
# Where to store the database (default: ~/.nexusmemory)
|
|
21
|
+
# NEXUSMEMORY_DATA_DIR=~/.nexusmemory
|
|
22
|
+
|
|
23
|
+
# --- Server ---
|
|
24
|
+
NEXUSMEMORY_HOST=127.0.0.1
|
|
25
|
+
NEXUSMEMORY_PORT=8765
|
|
26
|
+
|
|
27
|
+
# --- Retrieval ---
|
|
28
|
+
NEXUSMEMORY_MAX_RESULTS=10
|
|
29
|
+
NEXUSMEMORY_SIMILARITY_THRESHOLD=0.3
|
|
30
|
+
NEXUSMEMORY_GRAPH_EXPANSION_DEPTH=2
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
*.egg
|
|
9
|
+
.eggs/
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
env/
|
|
15
|
+
|
|
16
|
+
# IDE
|
|
17
|
+
.idea/
|
|
18
|
+
.vscode/
|
|
19
|
+
*.swp
|
|
20
|
+
*.swo
|
|
21
|
+
*~
|
|
22
|
+
|
|
23
|
+
# Environment
|
|
24
|
+
.env
|
|
25
|
+
|
|
26
|
+
# Database
|
|
27
|
+
*.db
|
|
28
|
+
data/
|
|
29
|
+
|
|
30
|
+
# OS
|
|
31
|
+
.DS_Store
|
|
32
|
+
Thumbs.db
|
|
33
|
+
|
|
34
|
+
# Testing
|
|
35
|
+
.pytest_cache/
|
|
36
|
+
htmlcov/
|
|
37
|
+
.coverage
|
nexusmemo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Byhunny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
nexusmemo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nexusmemo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local-first AI memory layer that gives LLMs persistent, structured memory
|
|
5
|
+
Project-URL: Homepage, https://github.com/Byhunny/nexusmemory
|
|
6
|
+
Project-URL: Repository, https://github.com/Byhunny/nexusmemory
|
|
7
|
+
Project-URL: Issues, https://github.com/Byhunny/nexusmemory/issues
|
|
8
|
+
Author-email: Byhunny <tansusam91@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,knowledge-graph,llm,mcp,memory
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Requires-Dist: click>=8.1.0
|
|
18
|
+
Requires-Dist: fastapi>=0.115.0
|
|
19
|
+
Requires-Dist: mcp[cli]>=1.0.0
|
|
20
|
+
Requires-Dist: networkx>=3.3
|
|
21
|
+
Requires-Dist: numpy>=1.26.0
|
|
22
|
+
Requires-Dist: openai>=1.30.0
|
|
23
|
+
Requires-Dist: pydantic-settings>=2.3.0
|
|
24
|
+
Requires-Dist: pydantic>=2.7.0
|
|
25
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
26
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
27
|
+
Requires-Dist: uvicorn[standard]>=0.30.0
|
|
28
|
+
Provides-Extra: anthropic
|
|
29
|
+
Requires-Dist: anthropic>=0.30.0; extra == 'anthropic'
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: httpx>=0.27; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
34
|
+
Provides-Extra: local-embeddings
|
|
35
|
+
Requires-Dist: sentence-transformers>=3.0.0; extra == 'local-embeddings'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# NexusMemory
|
|
39
|
+
|
|
40
|
+
Local-first AI memory layer that gives LLMs persistent, structured memory.
|
|
41
|
+
|
|
42
|
+
> "We are building the memory operating system that turns AI from a temporary assistant into a long-term collaborator."
|
|
43
|
+
|
|
44
|
+
## Problem
|
|
45
|
+
|
|
46
|
+
LLMs are stateless. They forget previous sessions, lose architectural context, repeat mistakes, and require repeated explanations. NexusMemory fixes this by building a persistent knowledge graph from your conversations.
|
|
47
|
+
|
|
48
|
+
## How It Works
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
conversation → entity extraction → relationship graph → retrieval → prompt injection
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
When you tell NexusMemory something, it:
|
|
55
|
+
1. **Extracts** entities, relationships, and decisions using LLM
|
|
56
|
+
2. **Embeds** the text for semantic search
|
|
57
|
+
3. **Builds** a knowledge graph with NetworkX
|
|
58
|
+
4. **Stores** everything in a local SQLite database
|
|
59
|
+
|
|
60
|
+
When you query, it:
|
|
61
|
+
1. **Searches** semantically similar memories
|
|
62
|
+
2. **Expands** through the knowledge graph
|
|
63
|
+
3. **Reranks** by importance and relevance
|
|
64
|
+
4. **Compresses** into context ready for LLM injection
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### Install
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install -e .
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Configure
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
cp .env.example .env
|
|
78
|
+
# Edit .env and add your OpenAI API key
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Use via CLI
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Add a memory
|
|
85
|
+
nexusmemory add "We replaced Airflow with Dagster because DAG maintenance became difficult"
|
|
86
|
+
|
|
87
|
+
# Search memories
|
|
88
|
+
nexusmemory search "What orchestration tool do we use?"
|
|
89
|
+
|
|
90
|
+
# Check status
|
|
91
|
+
nexusmemory status
|
|
92
|
+
|
|
93
|
+
# Get entity info
|
|
94
|
+
nexusmemory entity "Dagster"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Use via API
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Start the server
|
|
101
|
+
nexusmemory serve
|
|
102
|
+
|
|
103
|
+
# Add memory
|
|
104
|
+
curl -X POST http://localhost:8765/memory/add \
|
|
105
|
+
-H "Content-Type: application/json" \
|
|
106
|
+
-d '{"text": "We migrated from MongoDB to PostgreSQL for better ACID compliance"}'
|
|
107
|
+
|
|
108
|
+
# Query
|
|
109
|
+
curl -X POST http://localhost:8765/memory/query \
|
|
110
|
+
-H "Content-Type: application/json" \
|
|
111
|
+
-d '{"query": "What database do we use?"}'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Use with Claude Code (MCP)
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Add as MCP server
|
|
118
|
+
claude mcp add nexusmemory -- nexusmemory mcp
|
|
119
|
+
|
|
120
|
+
# Or if installed via pip in a specific path:
|
|
121
|
+
claude mcp add nexusmemory -- /path/to/venv/bin/nexusmemory mcp
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Available MCP tools:
|
|
125
|
+
- `add_memory` — Store project context
|
|
126
|
+
- `search_memory` — Query past memories
|
|
127
|
+
- `get_project_context` — Get rich context about a topic
|
|
128
|
+
- `find_related` — Explore knowledge graph relationships
|
|
129
|
+
- `get_decisions` — Review past decisions
|
|
130
|
+
- `memory_status` — Check system stats
|
|
131
|
+
|
|
132
|
+
## Architecture
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
┌──────────────┐
|
|
136
|
+
│ Interfaces │ CLI / FastAPI / MCP Server
|
|
137
|
+
├──────────────┤
|
|
138
|
+
│ Core │ NexusMemory orchestration class
|
|
139
|
+
├──────────────┤
|
|
140
|
+
│ Services │ Extraction, Embedding, Graph, Importance
|
|
141
|
+
├──────────────┤
|
|
142
|
+
│ Storage │ SQLite + NetworkX (in-memory)
|
|
143
|
+
└──────────────┘
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Tech Stack
|
|
147
|
+
|
|
148
|
+
- **Python 3.11+** with FastAPI
|
|
149
|
+
- **SQLite** for persistent storage
|
|
150
|
+
- **NetworkX** for in-memory knowledge graph
|
|
151
|
+
- **OpenAI API** for extraction and embeddings
|
|
152
|
+
- **MCP SDK** for Claude Code integration
|
|
153
|
+
|
|
154
|
+
## Database
|
|
155
|
+
|
|
156
|
+
Four tables:
|
|
157
|
+
- `memories` — Raw text with embeddings
|
|
158
|
+
- `nodes` — Knowledge graph entities
|
|
159
|
+
- `edges` — Relationships between entities
|
|
160
|
+
- `decisions` — Project decisions with reasoning
|
|
161
|
+
|
|
162
|
+
## Development
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Install with dev dependencies
|
|
166
|
+
pip install -e ".[dev]"
|
|
167
|
+
|
|
168
|
+
# Run tests
|
|
169
|
+
pytest
|
|
170
|
+
|
|
171
|
+
# Run API server in dev mode
|
|
172
|
+
nexusmemory serve
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# NexusMemory
|
|
2
|
+
|
|
3
|
+
Local-first AI memory layer that gives LLMs persistent, structured memory.
|
|
4
|
+
|
|
5
|
+
> "We are building the memory operating system that turns AI from a temporary assistant into a long-term collaborator."
|
|
6
|
+
|
|
7
|
+
## Problem
|
|
8
|
+
|
|
9
|
+
LLMs are stateless. They forget previous sessions, lose architectural context, repeat mistakes, and require repeated explanations. NexusMemory fixes this by building a persistent knowledge graph from your conversations.
|
|
10
|
+
|
|
11
|
+
## How It Works
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
conversation → entity extraction → relationship graph → retrieval → prompt injection
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
When you tell NexusMemory something, it:
|
|
18
|
+
1. **Extracts** entities, relationships, and decisions using LLM
|
|
19
|
+
2. **Embeds** the text for semantic search
|
|
20
|
+
3. **Builds** a knowledge graph with NetworkX
|
|
21
|
+
4. **Stores** everything in a local SQLite database
|
|
22
|
+
|
|
23
|
+
When you query, it:
|
|
24
|
+
1. **Searches** semantically similar memories
|
|
25
|
+
2. **Expands** through the knowledge graph
|
|
26
|
+
3. **Reranks** by importance and relevance
|
|
27
|
+
4. **Compresses** into context ready for LLM injection
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install -e .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Configure
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cp .env.example .env
|
|
41
|
+
# Edit .env and add your OpenAI API key
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Use via CLI
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Add a memory
|
|
48
|
+
nexusmemory add "We replaced Airflow with Dagster because DAG maintenance became difficult"
|
|
49
|
+
|
|
50
|
+
# Search memories
|
|
51
|
+
nexusmemory search "What orchestration tool do we use?"
|
|
52
|
+
|
|
53
|
+
# Check status
|
|
54
|
+
nexusmemory status
|
|
55
|
+
|
|
56
|
+
# Get entity info
|
|
57
|
+
nexusmemory entity "Dagster"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Use via API
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Start the server
|
|
64
|
+
nexusmemory serve
|
|
65
|
+
|
|
66
|
+
# Add memory
|
|
67
|
+
curl -X POST http://localhost:8765/memory/add \
|
|
68
|
+
-H "Content-Type: application/json" \
|
|
69
|
+
-d '{"text": "We migrated from MongoDB to PostgreSQL for better ACID compliance"}'
|
|
70
|
+
|
|
71
|
+
# Query
|
|
72
|
+
curl -X POST http://localhost:8765/memory/query \
|
|
73
|
+
-H "Content-Type: application/json" \
|
|
74
|
+
-d '{"query": "What database do we use?"}'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Use with Claude Code (MCP)
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Add as MCP server
|
|
81
|
+
claude mcp add nexusmemory -- nexusmemory mcp
|
|
82
|
+
|
|
83
|
+
# Or if installed via pip in a specific path:
|
|
84
|
+
claude mcp add nexusmemory -- /path/to/venv/bin/nexusmemory mcp
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Available MCP tools:
|
|
88
|
+
- `add_memory` — Store project context
|
|
89
|
+
- `search_memory` — Query past memories
|
|
90
|
+
- `get_project_context` — Get rich context about a topic
|
|
91
|
+
- `find_related` — Explore knowledge graph relationships
|
|
92
|
+
- `get_decisions` — Review past decisions
|
|
93
|
+
- `memory_status` — Check system stats
|
|
94
|
+
|
|
95
|
+
## Architecture
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
┌──────────────┐
|
|
99
|
+
│ Interfaces │ CLI / FastAPI / MCP Server
|
|
100
|
+
├──────────────┤
|
|
101
|
+
│ Core │ NexusMemory orchestration class
|
|
102
|
+
├──────────────┤
|
|
103
|
+
│ Services │ Extraction, Embedding, Graph, Importance
|
|
104
|
+
├──────────────┤
|
|
105
|
+
│ Storage │ SQLite + NetworkX (in-memory)
|
|
106
|
+
└──────────────┘
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Tech Stack
|
|
110
|
+
|
|
111
|
+
- **Python 3.11+** with FastAPI
|
|
112
|
+
- **SQLite** for persistent storage
|
|
113
|
+
- **NetworkX** for in-memory knowledge graph
|
|
114
|
+
- **OpenAI API** for extraction and embeddings
|
|
115
|
+
- **MCP SDK** for Claude Code integration
|
|
116
|
+
|
|
117
|
+
## Database
|
|
118
|
+
|
|
119
|
+
Four tables:
|
|
120
|
+
- `memories` — Raw text with embeddings
|
|
121
|
+
- `nodes` — Knowledge graph entities
|
|
122
|
+
- `edges` — Relationships between entities
|
|
123
|
+
- `decisions` — Project decisions with reasoning
|
|
124
|
+
|
|
125
|
+
## Development
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Install with dev dependencies
|
|
129
|
+
pip install -e ".[dev]"
|
|
130
|
+
|
|
131
|
+
# Run tests
|
|
132
|
+
pytest
|
|
133
|
+
|
|
134
|
+
# Run API server in dev mode
|
|
135
|
+
nexusmemory serve
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
MIT
|