devenv-ai 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.
- devenv_ai-0.1.0/PKG-INFO +225 -0
- devenv_ai-0.1.0/README.md +211 -0
- devenv_ai-0.1.0/core/__init__.py +1 -0
- devenv_ai-0.1.0/core/ai/__init__.py +4 -0
- devenv_ai-0.1.0/core/ai/engine.py +286 -0
- devenv_ai-0.1.0/core/ai/models.py +19 -0
- devenv_ai-0.1.0/core/env.py +60 -0
- devenv_ai-0.1.0/core/logging_utils.py +12 -0
- devenv_ai-0.1.0/core/memory/__init__.py +39 -0
- devenv_ai-0.1.0/core/memory/consolidation.py +84 -0
- devenv_ai-0.1.0/core/memory/embeddings.py +61 -0
- devenv_ai-0.1.0/core/memory/engine.py +209 -0
- devenv_ai-0.1.0/core/memory/extractors.py +97 -0
- devenv_ai-0.1.0/core/memory/interface.py +35 -0
- devenv_ai-0.1.0/core/memory/models.py +135 -0
- devenv_ai-0.1.0/core/memory/retrieval.py +180 -0
- devenv_ai-0.1.0/core/memory/storage.py +502 -0
- devenv_ai-0.1.0/core/memory/vector_index.py +157 -0
- devenv_ai-0.1.0/core/memory/working_memory.py +46 -0
- devenv_ai-0.1.0/core/runtime/__init__.py +27 -0
- devenv_ai-0.1.0/core/runtime/context_builder.py +1119 -0
- devenv_ai-0.1.0/core/runtime/context_stage.py +130 -0
- devenv_ai-0.1.0/core/runtime/kernel.py +4017 -0
- devenv_ai-0.1.0/core/runtime/local_model.py +106 -0
- devenv_ai-0.1.0/core/runtime/local_router.py +108 -0
- devenv_ai-0.1.0/core/runtime/mcp_client.py +187 -0
- devenv_ai-0.1.0/core/runtime/mcp_server.py +124 -0
- devenv_ai-0.1.0/core/runtime/metadata_stage.py +82 -0
- devenv_ai-0.1.0/core/runtime/models.py +302 -0
- devenv_ai-0.1.0/core/runtime/sandbox.py +42 -0
- devenv_ai-0.1.0/core/runtime/smoke.py +61 -0
- devenv_ai-0.1.0/core/runtime/state.py +21 -0
- devenv_ai-0.1.0/core/runtime/tooling.py +47 -0
- devenv_ai-0.1.0/core/runtime/tui.py +93 -0
- devenv_ai-0.1.0/core/runtime/web.py +356 -0
- devenv_ai-0.1.0/core/runtime/workspace.py +83 -0
- devenv_ai-0.1.0/core/tools/__init__.py +33 -0
- devenv_ai-0.1.0/core/tools/_common.py +118 -0
- devenv_ai-0.1.0/core/tools/audit_changes.py +96 -0
- devenv_ai-0.1.0/core/tools/base.py +25 -0
- devenv_ai-0.1.0/core/tools/edit_file.py +89 -0
- devenv_ai-0.1.0/core/tools/inspect_symbols.py +138 -0
- devenv_ai-0.1.0/core/tools/inspect_trace.py +88 -0
- devenv_ai-0.1.0/core/tools/list_directory.py +120 -0
- devenv_ai-0.1.0/core/tools/locate_files.py +80 -0
- devenv_ai-0.1.0/core/tools/manage_memory.py +81 -0
- devenv_ai-0.1.0/core/tools/peek_lines.py +119 -0
- devenv_ai-0.1.0/core/tools/read_file.py +196 -0
- devenv_ai-0.1.0/core/tools/remove_file.py +66 -0
- devenv_ai-0.1.0/core/tools/run_diagnostics.py +184 -0
- devenv_ai-0.1.0/core/tools/run_shell.py +99 -0
- devenv_ai-0.1.0/core/tools/search_text.py +146 -0
- devenv_ai-0.1.0/core/tools/track_symbol.py +131 -0
- devenv_ai-0.1.0/core/tools/write_file.py +78 -0
- devenv_ai-0.1.0/devenv_ai.egg-info/PKG-INFO +225 -0
- devenv_ai-0.1.0/devenv_ai.egg-info/SOURCES.txt +63 -0
- devenv_ai-0.1.0/devenv_ai.egg-info/dependency_links.txt +1 -0
- devenv_ai-0.1.0/devenv_ai.egg-info/entry_points.txt +5 -0
- devenv_ai-0.1.0/devenv_ai.egg-info/requires.txt +3 -0
- devenv_ai-0.1.0/devenv_ai.egg-info/top_level.txt +1 -0
- devenv_ai-0.1.0/interface/website/index.html +13 -0
- devenv_ai-0.1.0/interface/website/main.js +771 -0
- devenv_ai-0.1.0/interface/website/styles.css +612 -0
- devenv_ai-0.1.0/pyproject.toml +39 -0
- devenv_ai-0.1.0/setup.cfg +4 -0
devenv_ai-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: devenv-ai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local-first coding agent foundations.
|
|
5
|
+
Author: Devenv Contributors
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: lancedb>=0.16.0
|
|
12
|
+
Requires-Dist: mcp[cli]>=1.28.0
|
|
13
|
+
Requires-Dist: sentence-transformers>=3.0.0
|
|
14
|
+
|
|
15
|
+
# Devenv
|
|
16
|
+
|
|
17
|
+
Devenv is a local-first coding agent project. The current implemented foundation is the **Cognitive Memory Engine (CME)** described in the PRDs under [`core/memory/prd_objective.md`](/Users/samarthnaik/Desktop/Projects/devenv/core/memory/prd_objective.md:1) and [`core/memory/prd_tech.md`](/Users/samarthnaik/Desktop/Projects/devenv/core/memory/prd_tech.md:1).
|
|
18
|
+
|
|
19
|
+
Today, this repository is centered on a working Python package, `core.memory`, plus a small tools foundation. The memory engine is built to remove the idea of isolated chat sessions and instead support continuous, auditable memory across:
|
|
20
|
+
|
|
21
|
+
- working memory for the current task window
|
|
22
|
+
- episodic memory for timestamped interaction history
|
|
23
|
+
- associative memory for structured project, component, and preference recall
|
|
24
|
+
- consolidation for turning raw logs into reusable memory nodes
|
|
25
|
+
|
|
26
|
+
## What Is Done
|
|
27
|
+
|
|
28
|
+
The following PRD-driven functionality is implemented in this repository today:
|
|
29
|
+
|
|
30
|
+
- A decoupled `MemoryEngine` interface in `core.memory` with injectable storage, embeddings, vector index, and consolidation extractor.
|
|
31
|
+
- Working memory support with a bounded recent-message buffer and active session state snapshot.
|
|
32
|
+
- Episodic memory logging with timestamped user/agent interactions and optional metadata.
|
|
33
|
+
- Associative memory storage in SQLite using hierarchical nodes plus lateral graph edges.
|
|
34
|
+
- Vector-backed semantic lookup for associative summaries.
|
|
35
|
+
- Retrieval with spreading-activation behavior:
|
|
36
|
+
parent-chain expansion, sibling expansion, related-edge expansion, normalized ranking, and markdown context compilation.
|
|
37
|
+
- Dynamic ranking signals based on similarity, access frequency, and recency.
|
|
38
|
+
- Auditable retrieval traces through `get_context_trace()`, including matched nodes, expanded candidates, selected nodes, and the final injected markdown block.
|
|
39
|
+
- Manual memory correction through `forget_node()` with both `prune` and `rewrite` strategies.
|
|
40
|
+
- Consolidation flow that processes new episodic logs, creates new nodes, updates existing nodes, refreshes vectors, and stores a consolidation watermark.
|
|
41
|
+
- A deterministic heuristic extractor seam so consolidation is testable without a live LLM.
|
|
42
|
+
- Unit tests covering imports, storage, working memory, retrieval, consolidation, manual control, and vector lookup behavior.
|
|
43
|
+
|
|
44
|
+
## PRD Alignment
|
|
45
|
+
|
|
46
|
+
The current implementation covers a substantial part of the memory PRDs:
|
|
47
|
+
|
|
48
|
+
- **Working Memory Manager:** implemented
|
|
49
|
+
- **Episodic Memory timeline:** implemented
|
|
50
|
+
- **Associative tree / graph structure:** implemented with SQLite nodes and edges
|
|
51
|
+
- **Spreading activation retrieval:** implemented
|
|
52
|
+
- **Importance and decay scoring:** implemented through normalized similarity, frequency, and recency scoring
|
|
53
|
+
- **Auditable context trace:** implemented
|
|
54
|
+
- **Manual memory correction:** implemented
|
|
55
|
+
- **Asynchronous sleep consolidation:** partially implemented
|
|
56
|
+
the consolidation service exists and is ready to be called as a background task, but the repo does not yet include an always-on inactivity scheduler or terminal-event trigger loop
|
|
57
|
+
|
|
58
|
+
## Current Architecture
|
|
59
|
+
|
|
60
|
+
### `core.memory`
|
|
61
|
+
|
|
62
|
+
Main public entry point:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from core.memory import MemoryEngine
|
|
66
|
+
|
|
67
|
+
engine = MemoryEngine(db_path="memory.db", vector_dir="vectors")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Implemented responsibilities:
|
|
71
|
+
|
|
72
|
+
- `record_working_memory(messages, active_state)`
|
|
73
|
+
- `add_episodic_log(user_prompt, agent_response, node_id=None, metadata=None)`
|
|
74
|
+
- `update_associative_tree(node_data)`
|
|
75
|
+
- `retrieve_context(current_prompt, top_k=5)`
|
|
76
|
+
- `run_consolidation(since=None)`
|
|
77
|
+
- `forget_node(node_id, strategy="prune")`
|
|
78
|
+
- `get_context_trace()`
|
|
79
|
+
|
|
80
|
+
Storage model:
|
|
81
|
+
|
|
82
|
+
- **SQLite** stores:
|
|
83
|
+
`memory_nodes`, `node_edges`, `episodic_logs`, and engine state such as the last consolidation watermark.
|
|
84
|
+
- **LanceDB** is the production vector store for associative summaries.
|
|
85
|
+
- **In-memory test doubles** exist for the vector index and embedder so the system can be tested quickly and deterministically.
|
|
86
|
+
|
|
87
|
+
### `core.tools`
|
|
88
|
+
|
|
89
|
+
There is also a small tools foundation already implemented:
|
|
90
|
+
|
|
91
|
+
- `BaseTool`
|
|
92
|
+
- `ToolResult`
|
|
93
|
+
- `ReadFileTool`
|
|
94
|
+
|
|
95
|
+
`ReadFileTool` supports content reads plus optional metadata and extension analysis in one call.
|
|
96
|
+
|
|
97
|
+
## Repository Layout
|
|
98
|
+
|
|
99
|
+
```text
|
|
100
|
+
core/
|
|
101
|
+
memory/
|
|
102
|
+
README.md
|
|
103
|
+
prd_objective.md
|
|
104
|
+
prd_tech.md
|
|
105
|
+
interface.py
|
|
106
|
+
engine.py
|
|
107
|
+
retrieval.py
|
|
108
|
+
consolidation.py
|
|
109
|
+
storage.py
|
|
110
|
+
vector_index.py
|
|
111
|
+
embeddings.py
|
|
112
|
+
working_memory.py
|
|
113
|
+
extractors.py
|
|
114
|
+
models.py
|
|
115
|
+
tools/
|
|
116
|
+
base.py
|
|
117
|
+
read_file.py
|
|
118
|
+
tests/
|
|
119
|
+
memory/
|
|
120
|
+
pyproject.toml
|
|
121
|
+
README.md
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Setup
|
|
125
|
+
|
|
126
|
+
Python 3.12+ is required.
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python3 -m venv .venv
|
|
130
|
+
source .venv/bin/activate
|
|
131
|
+
python -m pip install -U pip
|
|
132
|
+
python -m pip install -e .
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The production memory stack expects these local dependencies:
|
|
136
|
+
|
|
137
|
+
- `lancedb`
|
|
138
|
+
- `sentence-transformers`
|
|
139
|
+
|
|
140
|
+
The test suite primarily uses lightweight in-memory test doubles instead of the production embedding/vector stack.
|
|
141
|
+
|
|
142
|
+
## Example
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from core.memory import MemoryEngine
|
|
146
|
+
|
|
147
|
+
engine = MemoryEngine(db_path="memory.db", vector_dir="vectors")
|
|
148
|
+
|
|
149
|
+
engine.record_working_memory(
|
|
150
|
+
messages=[{"role": "user", "content": "Fix the Django auth flow"}],
|
|
151
|
+
active_state={"file": "core/memory/engine.py"},
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
engine.update_associative_tree(
|
|
155
|
+
{
|
|
156
|
+
"node_id": "proj_rxgpt",
|
|
157
|
+
"label": "Project: RxGPT",
|
|
158
|
+
"category": "project",
|
|
159
|
+
"summary": "RxGPT uses React, Tailwind, and Django.",
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
engine.add_episodic_log(
|
|
164
|
+
"We introduced a Django auth component.",
|
|
165
|
+
"I'll remember the backend shape.",
|
|
166
|
+
node_id="proj_rxgpt",
|
|
167
|
+
metadata={
|
|
168
|
+
"project": "RxGPT",
|
|
169
|
+
"memory_entities": [
|
|
170
|
+
{
|
|
171
|
+
"node_id": "cmp_django_auth",
|
|
172
|
+
"label": "Django Auth Setup",
|
|
173
|
+
"category": "component",
|
|
174
|
+
"summary": "Django auth relies on session cookies and middleware.",
|
|
175
|
+
"parent_id": "proj_rxgpt",
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
engine.run_consolidation()
|
|
182
|
+
result = engine.retrieve_context("How do I fix my django authentication errors?")
|
|
183
|
+
|
|
184
|
+
print(result.markdown_context)
|
|
185
|
+
print(engine.get_context_trace())
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Tests
|
|
189
|
+
|
|
190
|
+
Run the memory test suite with:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
python3 -m unittest discover -s tests -p 'test_*.py'
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The current suite covers:
|
|
197
|
+
|
|
198
|
+
- import boundaries
|
|
199
|
+
- working memory bounds and snapshots
|
|
200
|
+
- episodic log persistence
|
|
201
|
+
- associative node and edge storage
|
|
202
|
+
- vector index ranking
|
|
203
|
+
- hierarchical retrieval and preference recall
|
|
204
|
+
- retrieval trace scoring normalization
|
|
205
|
+
- manual prune and rewrite behavior
|
|
206
|
+
- consolidation creation, update, and watermark behavior
|
|
207
|
+
|
|
208
|
+
## Not Done Yet
|
|
209
|
+
|
|
210
|
+
The README should be clear about what is still future scope from the PRDs:
|
|
211
|
+
|
|
212
|
+
- no CLI, web UI, or phone companion is implemented yet
|
|
213
|
+
- no always-on background scheduler for inactivity-based consolidation yet
|
|
214
|
+
- no cross-device sync yet
|
|
215
|
+
- no multi-repo memory sharing yet
|
|
216
|
+
- no full agent orchestration loop yet
|
|
217
|
+
- no secure remote execution layer yet
|
|
218
|
+
|
|
219
|
+
## Development Notes
|
|
220
|
+
|
|
221
|
+
- The code is organized to keep memory logic decoupled from future UI or agent layers.
|
|
222
|
+
- Tests use dependency injection heavily so memory behavior can be verified without external services.
|
|
223
|
+
- The local-first constraint from the PRDs is preserved in the package design: raw logs, structured memory, and vector lookup are intended to live on the user machine.
|
|
224
|
+
|
|
225
|
+
./.venv/bin/python -m core.runtime.web sample-test
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Devenv
|
|
2
|
+
|
|
3
|
+
Devenv is a local-first coding agent project. The current implemented foundation is the **Cognitive Memory Engine (CME)** described in the PRDs under [`core/memory/prd_objective.md`](/Users/samarthnaik/Desktop/Projects/devenv/core/memory/prd_objective.md:1) and [`core/memory/prd_tech.md`](/Users/samarthnaik/Desktop/Projects/devenv/core/memory/prd_tech.md:1).
|
|
4
|
+
|
|
5
|
+
Today, this repository is centered on a working Python package, `core.memory`, plus a small tools foundation. The memory engine is built to remove the idea of isolated chat sessions and instead support continuous, auditable memory across:
|
|
6
|
+
|
|
7
|
+
- working memory for the current task window
|
|
8
|
+
- episodic memory for timestamped interaction history
|
|
9
|
+
- associative memory for structured project, component, and preference recall
|
|
10
|
+
- consolidation for turning raw logs into reusable memory nodes
|
|
11
|
+
|
|
12
|
+
## What Is Done
|
|
13
|
+
|
|
14
|
+
The following PRD-driven functionality is implemented in this repository today:
|
|
15
|
+
|
|
16
|
+
- A decoupled `MemoryEngine` interface in `core.memory` with injectable storage, embeddings, vector index, and consolidation extractor.
|
|
17
|
+
- Working memory support with a bounded recent-message buffer and active session state snapshot.
|
|
18
|
+
- Episodic memory logging with timestamped user/agent interactions and optional metadata.
|
|
19
|
+
- Associative memory storage in SQLite using hierarchical nodes plus lateral graph edges.
|
|
20
|
+
- Vector-backed semantic lookup for associative summaries.
|
|
21
|
+
- Retrieval with spreading-activation behavior:
|
|
22
|
+
parent-chain expansion, sibling expansion, related-edge expansion, normalized ranking, and markdown context compilation.
|
|
23
|
+
- Dynamic ranking signals based on similarity, access frequency, and recency.
|
|
24
|
+
- Auditable retrieval traces through `get_context_trace()`, including matched nodes, expanded candidates, selected nodes, and the final injected markdown block.
|
|
25
|
+
- Manual memory correction through `forget_node()` with both `prune` and `rewrite` strategies.
|
|
26
|
+
- Consolidation flow that processes new episodic logs, creates new nodes, updates existing nodes, refreshes vectors, and stores a consolidation watermark.
|
|
27
|
+
- A deterministic heuristic extractor seam so consolidation is testable without a live LLM.
|
|
28
|
+
- Unit tests covering imports, storage, working memory, retrieval, consolidation, manual control, and vector lookup behavior.
|
|
29
|
+
|
|
30
|
+
## PRD Alignment
|
|
31
|
+
|
|
32
|
+
The current implementation covers a substantial part of the memory PRDs:
|
|
33
|
+
|
|
34
|
+
- **Working Memory Manager:** implemented
|
|
35
|
+
- **Episodic Memory timeline:** implemented
|
|
36
|
+
- **Associative tree / graph structure:** implemented with SQLite nodes and edges
|
|
37
|
+
- **Spreading activation retrieval:** implemented
|
|
38
|
+
- **Importance and decay scoring:** implemented through normalized similarity, frequency, and recency scoring
|
|
39
|
+
- **Auditable context trace:** implemented
|
|
40
|
+
- **Manual memory correction:** implemented
|
|
41
|
+
- **Asynchronous sleep consolidation:** partially implemented
|
|
42
|
+
the consolidation service exists and is ready to be called as a background task, but the repo does not yet include an always-on inactivity scheduler or terminal-event trigger loop
|
|
43
|
+
|
|
44
|
+
## Current Architecture
|
|
45
|
+
|
|
46
|
+
### `core.memory`
|
|
47
|
+
|
|
48
|
+
Main public entry point:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from core.memory import MemoryEngine
|
|
52
|
+
|
|
53
|
+
engine = MemoryEngine(db_path="memory.db", vector_dir="vectors")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Implemented responsibilities:
|
|
57
|
+
|
|
58
|
+
- `record_working_memory(messages, active_state)`
|
|
59
|
+
- `add_episodic_log(user_prompt, agent_response, node_id=None, metadata=None)`
|
|
60
|
+
- `update_associative_tree(node_data)`
|
|
61
|
+
- `retrieve_context(current_prompt, top_k=5)`
|
|
62
|
+
- `run_consolidation(since=None)`
|
|
63
|
+
- `forget_node(node_id, strategy="prune")`
|
|
64
|
+
- `get_context_trace()`
|
|
65
|
+
|
|
66
|
+
Storage model:
|
|
67
|
+
|
|
68
|
+
- **SQLite** stores:
|
|
69
|
+
`memory_nodes`, `node_edges`, `episodic_logs`, and engine state such as the last consolidation watermark.
|
|
70
|
+
- **LanceDB** is the production vector store for associative summaries.
|
|
71
|
+
- **In-memory test doubles** exist for the vector index and embedder so the system can be tested quickly and deterministically.
|
|
72
|
+
|
|
73
|
+
### `core.tools`
|
|
74
|
+
|
|
75
|
+
There is also a small tools foundation already implemented:
|
|
76
|
+
|
|
77
|
+
- `BaseTool`
|
|
78
|
+
- `ToolResult`
|
|
79
|
+
- `ReadFileTool`
|
|
80
|
+
|
|
81
|
+
`ReadFileTool` supports content reads plus optional metadata and extension analysis in one call.
|
|
82
|
+
|
|
83
|
+
## Repository Layout
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
core/
|
|
87
|
+
memory/
|
|
88
|
+
README.md
|
|
89
|
+
prd_objective.md
|
|
90
|
+
prd_tech.md
|
|
91
|
+
interface.py
|
|
92
|
+
engine.py
|
|
93
|
+
retrieval.py
|
|
94
|
+
consolidation.py
|
|
95
|
+
storage.py
|
|
96
|
+
vector_index.py
|
|
97
|
+
embeddings.py
|
|
98
|
+
working_memory.py
|
|
99
|
+
extractors.py
|
|
100
|
+
models.py
|
|
101
|
+
tools/
|
|
102
|
+
base.py
|
|
103
|
+
read_file.py
|
|
104
|
+
tests/
|
|
105
|
+
memory/
|
|
106
|
+
pyproject.toml
|
|
107
|
+
README.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Setup
|
|
111
|
+
|
|
112
|
+
Python 3.12+ is required.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
python3 -m venv .venv
|
|
116
|
+
source .venv/bin/activate
|
|
117
|
+
python -m pip install -U pip
|
|
118
|
+
python -m pip install -e .
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The production memory stack expects these local dependencies:
|
|
122
|
+
|
|
123
|
+
- `lancedb`
|
|
124
|
+
- `sentence-transformers`
|
|
125
|
+
|
|
126
|
+
The test suite primarily uses lightweight in-memory test doubles instead of the production embedding/vector stack.
|
|
127
|
+
|
|
128
|
+
## Example
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from core.memory import MemoryEngine
|
|
132
|
+
|
|
133
|
+
engine = MemoryEngine(db_path="memory.db", vector_dir="vectors")
|
|
134
|
+
|
|
135
|
+
engine.record_working_memory(
|
|
136
|
+
messages=[{"role": "user", "content": "Fix the Django auth flow"}],
|
|
137
|
+
active_state={"file": "core/memory/engine.py"},
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
engine.update_associative_tree(
|
|
141
|
+
{
|
|
142
|
+
"node_id": "proj_rxgpt",
|
|
143
|
+
"label": "Project: RxGPT",
|
|
144
|
+
"category": "project",
|
|
145
|
+
"summary": "RxGPT uses React, Tailwind, and Django.",
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
engine.add_episodic_log(
|
|
150
|
+
"We introduced a Django auth component.",
|
|
151
|
+
"I'll remember the backend shape.",
|
|
152
|
+
node_id="proj_rxgpt",
|
|
153
|
+
metadata={
|
|
154
|
+
"project": "RxGPT",
|
|
155
|
+
"memory_entities": [
|
|
156
|
+
{
|
|
157
|
+
"node_id": "cmp_django_auth",
|
|
158
|
+
"label": "Django Auth Setup",
|
|
159
|
+
"category": "component",
|
|
160
|
+
"summary": "Django auth relies on session cookies and middleware.",
|
|
161
|
+
"parent_id": "proj_rxgpt",
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
engine.run_consolidation()
|
|
168
|
+
result = engine.retrieve_context("How do I fix my django authentication errors?")
|
|
169
|
+
|
|
170
|
+
print(result.markdown_context)
|
|
171
|
+
print(engine.get_context_trace())
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Tests
|
|
175
|
+
|
|
176
|
+
Run the memory test suite with:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
python3 -m unittest discover -s tests -p 'test_*.py'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The current suite covers:
|
|
183
|
+
|
|
184
|
+
- import boundaries
|
|
185
|
+
- working memory bounds and snapshots
|
|
186
|
+
- episodic log persistence
|
|
187
|
+
- associative node and edge storage
|
|
188
|
+
- vector index ranking
|
|
189
|
+
- hierarchical retrieval and preference recall
|
|
190
|
+
- retrieval trace scoring normalization
|
|
191
|
+
- manual prune and rewrite behavior
|
|
192
|
+
- consolidation creation, update, and watermark behavior
|
|
193
|
+
|
|
194
|
+
## Not Done Yet
|
|
195
|
+
|
|
196
|
+
The README should be clear about what is still future scope from the PRDs:
|
|
197
|
+
|
|
198
|
+
- no CLI, web UI, or phone companion is implemented yet
|
|
199
|
+
- no always-on background scheduler for inactivity-based consolidation yet
|
|
200
|
+
- no cross-device sync yet
|
|
201
|
+
- no multi-repo memory sharing yet
|
|
202
|
+
- no full agent orchestration loop yet
|
|
203
|
+
- no secure remote execution layer yet
|
|
204
|
+
|
|
205
|
+
## Development Notes
|
|
206
|
+
|
|
207
|
+
- The code is organized to keep memory logic decoupled from future UI or agent layers.
|
|
208
|
+
- Tests use dependency injection heavily so memory behavior can be verified without external services.
|
|
209
|
+
- The local-first constraint from the PRDs is preserved in the package design: raw logs, structured memory, and vector lookup are intended to live on the user machine.
|
|
210
|
+
|
|
211
|
+
./.venv/bin/python -m core.runtime.web sample-test
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|