@hasna/mementos 0.14.5 → 0.14.7

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/README.md CHANGED
@@ -1,252 +1,50 @@
1
1
  # @hasna/mementos
2
2
 
3
- Universal memory system for AI agents. SQLite-backed with CLI, MCP server, REST API, and TypeScript library.
3
+ Universal memory system for AI agents - CLI + MCP server + library API
4
4
 
5
- Agents save, recall, search, and share memories across sessions. Memories are scoped (global/shared/private), categorized, importance-ranked, and injected into agent context on demand.
5
+ [![npm](https://img.shields.io/npm/v/@hasna/mementos)](https://www.npmjs.com/package/@hasna/mementos)
6
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
6
7
 
7
8
  ## Install
8
9
 
9
10
  ```bash
10
- bun add -g @hasna/mementos
11
- mementos init
11
+ npm install -g @hasna/mementos
12
12
  ```
13
13
 
14
- That's it. `init` registers the MCP with Claude Code, installs the session stop hook, and configures the server to start automatically on login.
15
-
16
- ## Quick Start
14
+ ## CLI Usage
17
15
 
18
16
  ```bash
19
- # Save a memory
20
- mementos save "project-stack" "Bun + TypeScript + SQLite" --scope shared --importance 8
21
-
22
- # Recall it
23
- mementos recall "project-stack"
24
-
25
- # Search
26
- mementos search "typescript stack"
27
-
28
- # Inject into agent context (compact = ~60% smaller)
29
- mementos inject --format compact --project-id <id>
30
-
31
- # Get stats
32
- mementos stats
33
-
34
- # Check everything is working
35
- mementos doctor
17
+ mementos --help
36
18
  ```
37
19
 
38
20
  ## MCP Server
39
21
 
40
- ### Install into Claude Code (recommended)
41
-
42
- ```bash
43
- # One-command setup (MCP + stop hook + auto-start):
44
- mementos init
45
-
46
- # Or just the MCP server:
47
- mementos mcp --claude
48
- # Or manually:
49
- claude mcp add --transport stdio --scope user mementos -- mementos-mcp
50
- ```
51
-
52
- ### Install into Codex / Gemini
53
-
54
- ```bash
55
- mementos mcp --codex
56
- mementos mcp --gemini
57
- mementos mcp --all # all agents at once
58
- ```
59
-
60
- ### Available Tools (40+)
61
-
62
- **Memory:** `memory_save`, `memory_recall`, `memory_get`, `memory_list`, `memory_update`, `memory_pin`, `memory_archive`, `memory_forget`, `memory_search`, `memory_stats`, `memory_export`, `memory_import`, `memory_inject`, `memory_context`, `session_extract`
63
-
64
- **Bulk:** `bulk_forget`, `bulk_update`
65
-
66
- **Agents:** `register_agent`, `list_agents`, `list_agents_by_project`, `get_agent`, `update_agent`
67
-
68
- **Projects:** `register_project`, `list_projects`, `get_project`
69
-
70
- **Knowledge Graph:** `entity_create`, `entity_get`, `entity_list`, `entity_delete`, `entity_merge`, `entity_link`, `relation_create`, `relation_delete`, `relation_list`, `graph_query`, `graph_path`, `graph_stats`
71
-
72
- **Meta:** `search_tools`, `describe_tools` (lean stubs — full docs on demand)
73
-
74
- **Utility:** `clean_expired`
75
-
76
- ## CLI Reference
77
-
78
22
  ```bash
79
- mementos save <key> <value> # Save/upsert a memory
80
- mementos recall <key> # Get memory by key
81
- mementos list # List memories (with filters)
82
- mementos update <id> # Update memory fields
83
- mementos pin <key|id> # Pin a memory
84
- mementos forget <key|id> # Delete a memory
85
- mementos search <query> # Full-text + fuzzy search
86
- mementos stats # Memory statistics
87
- mementos export # Export as JSON
88
- mementos import <file> # Import from JSON
89
- mementos clean # Remove expired + enforce quotas
90
- mementos inject # Output injection context
91
- mementos init <name> # Register agent
92
- mementos agents # List agents
93
- mementos projects # Manage projects
94
- mementos bulk forget <ids> # Batch delete
95
- mementos bulk update <ids> # Batch update
96
- mementos diff <id> # Show memory version history
97
- mementos doctor # Diagnose DB health
98
-
99
- # Profiles — isolated DBs per context
100
- mementos profile set work # Switch to work profile
101
- mementos profile list # List all profiles
102
- mementos profile get # Show active profile
103
- mementos profile unset # Back to default
23
+ mementos-mcp
104
24
  ```
105
25
 
106
- ## Profiles
107
-
108
- ```bash
109
- # Each profile is an isolated DB: ~/.mementos/profiles/<name>.db
110
- mementos profile set work
111
- MEMENTOS_PROFILE=work mementos list # per-command
112
- ```
26
+ 116 tools available.
113
27
 
114
28
  ## REST API
115
29
 
116
30
  ```bash
117
- mementos-serve --port 19428
31
+ mementos-serve
118
32
  ```
119
33
 
120
- Default port: **19428**. Binds to `127.0.0.1` (localhost only). Override with `MEMENTOS_HOST=0.0.0.0`.
121
-
122
- ### Key Endpoints
123
-
124
- | Method | Path | Description |
125
- |--------|------|-------------|
126
- | GET | `/api/memories?fields=key,value` | List memories (?fields, ?scope, ?session_id, ?status) |
127
- | POST | `/api/memories` | Create/upsert memory |
128
- | PATCH | `/api/memories/:id` | Update (version optional — auto-fetched) |
129
- | DELETE | `/api/memories/:id` | Delete |
130
- | POST | `/api/memories/search` | Full-text search |
131
- | POST | `/api/memories/extract` | Auto-extract memories from session summary |
132
- | POST | `/api/memories/bulk-forget` | Delete multiple |
133
- | POST | `/api/memories/bulk-update` | Update multiple |
134
- | GET | `/api/memories/stats` | Statistics |
135
- | POST | `/api/memories/export` | Export with filters |
136
- | GET | `/api/inject?format=compact` | Context injection (compact/markdown/json/xml) |
137
- | GET/POST | `/api/agents` | Agent registry |
138
- | PATCH | `/api/agents/:id` | Update agent (including active_project_id) |
139
- | GET/POST | `/api/projects` | Project registry |
140
- | GET | `/api/projects/:id/agents` | Agents active on a project |
141
- | GET | `/api/profile` | Active profile info |
142
- | GET | `/api/health` | Health check (includes profile, hostname) |
143
-
144
- ## SDK
34
+ ## Cloud Sync
145
35
 
146
- ```bash
147
- bun add @hasna/mementos-sdk
148
- ```
149
-
150
- ```typescript
151
- import { MementosClient } from "@hasna/mementos-sdk";
152
-
153
- // Auto-configure from MEMENTOS_URL env var
154
- const client = MementosClient.fromEnv();
155
-
156
- // Or explicit:
157
- const client = new MementosClient({ baseUrl: "http://localhost:19428" });
158
-
159
- // Save memory
160
- await client.saveMemory({ key: "db-convention", value: "snake_case", scope: "shared" });
161
-
162
- // Search
163
- const { results } = await client.searchMemories("database conventions");
164
-
165
- // Context injection (compact format — 60% smaller)
166
- const { context } = await client.getContext({ project_id: "...", format: "compact" });
167
-
168
- // Sessions → mementos integration
169
- await client.extractFromSession({
170
- session_id: "abc123",
171
- title: "Fix auth middleware",
172
- key_topics: ["jwt", "compliance"],
173
- project_id: "...",
174
- });
175
- ```
176
-
177
- ## Agent-Project Binding
178
-
179
- Track which agent is working on which project:
180
-
181
- ```typescript
182
- // On session start
183
- await client.updateAgent("my-agent", { active_project_id: "project-uuid" });
184
-
185
- // Query: who's on this project?
186
- const { agents } = await client.getProjectAgents("open-mementos");
187
- ```
188
-
189
- ## Context Injection
36
+ This package supports cloud sync via `@hasna/cloud`:
190
37
 
191
38
  ```bash
192
- # 60% smaller with compact format
193
- mementos inject --format compact --project-id <id> --max-tokens 400
39
+ cloud setup
40
+ cloud sync push --service mementos
41
+ cloud sync pull --service mementos
194
42
  ```
195
43
 
196
- MCP: `memory_inject(project_id="...", format="compact", max_tokens=400)`
197
-
198
- ## Sessions Integration
44
+ ## Data Directory
199
45
 
200
- After ingesting a session (open-sessions):
201
-
202
- ```bash
203
- sessions remember <session-id> --mementos-url http://localhost:19428
204
- # Creates: session-summary (history), session-topics (knowledge), session-notes (knowledge)
205
- ```
206
-
207
- REST:
208
- ```json
209
- POST /api/memories/extract
210
- { "session_id": "abc", "title": "Fix auth", "key_topics": ["jwt"] }
211
- ```
212
-
213
- ## Environment Variables
214
-
215
- | Variable | Purpose | Default |
216
- |----------|---------|---------|
217
- | `MEMENTOS_DB_PATH` | Override DB path (bypasses profiles) | `~/.mementos/mementos.db` |
218
- | `MEMENTOS_PROFILE` | Named profile → `~/.mementos/profiles/<name>.db` | none |
219
- | `MEMENTOS_DB_SCOPE` | `project` = git root `.mementos/mementos.db` | global |
220
- | `MEMENTOS_HOST` | Server bind address | `127.0.0.1` |
221
- | `PORT` | Server port | `19428` |
222
- | `MEMENTOS_URL` | SDK client base URL (`MementosClient.fromEnv()`) | `http://localhost:19428` |
223
-
224
- ## Library
225
-
226
- ```typescript
227
- import {
228
- createMemory, getMemoryByKey, listMemories, searchMemories,
229
- registerAgent, updateAgent, listAgentsByProject,
230
- registerProject, getProject,
231
- getActiveProfile, setActiveProfile,
232
- MemoryInjector,
233
- } from "@hasna/mementos";
234
- ```
235
-
236
- ## Architecture
237
-
238
- ```
239
- src/
240
- cli/ Commander.js + Ink TUI — 20+ commands
241
- mcp/ MCP server — 40+ tools (lean stubs)
242
- server/ REST API — 37+ endpoints (Bun.serve)
243
- db/ SQLite (bun:sqlite) — memories, agents, projects, entities, relations
244
- lib/ FTS5 search, injection, extraction, retention, config, profiles
245
- types/ TypeScript interfaces and errors
246
- sdk/ @hasna/mementos-sdk — zero-dep fetch client
247
- dashboard/ React+Vite web UI
248
- ```
46
+ Data is stored in `~/.hasna/mementos/`.
249
47
 
250
48
  ## License
251
49
 
252
- Apache-2.0
50
+ Apache-2.0 -- see [LICENSE](LICENSE)