dotmem 0.1.0 → 0.1.1

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,93 +1,122 @@
1
1
  # dotmem (.mem)
2
2
 
3
- ![banner](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dotmem/banner.svg)
3
+ ![Dotmem banner](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dotmem/banner.svg)
4
4
 
5
- AI memory and continuity infrastructure for agents and applications.
5
+ **AI memory and continuity infrastructure for agents and applications... Say `Hi Joy!`**
6
6
 
7
- Dotmem provides structured, queryable, policy-controlled memory for AI agents. It supports experience acquisition, bounded context projection, continuity across sessions, rule-based reasoning, and MCP integration. The memory substrate is independent of a specific model, vendor, host, or conversational client.
7
+ Dotmem provides structured, queryable, policy-controlled memory for AI agents and applications. It supports experience acquisition, bounded context projection, continuity across sessions, rule-based reasoning, and MCP integration.
8
8
 
9
- > **Retrieval model**: dotmem uses deterministic lexical/structured retrieval with applicability-based eligibility. It does not use embeddings, vector indexes, or semantic similarity search. The term "AI-oriented" refers to the memory lifecycle and API design (acquisition with evidence/provenance, applicability scoping, policy-gated writes, context projection for LLM consumption), not the underlying retrieval algorithm. For semantic/vector search, pair dotmem with a dedicated embedding store.
9
+ The memory substrate is independent of any specific model, vendor, host, or conversational client.
10
+
11
+ > **Retrieval:** deterministic lexical and structured matching. No embeddings or vector search. See [Retrieval model](#retrieval-model).
10
12
 
11
13
  ---
12
14
 
13
15
  ## What Dotmem is
14
16
 
15
- - **Acquired experience**: evidenced, applicability-scoped claims via `discover`, `project`, and `acquire`.
16
- - **Application memory**: typed key/value entries via `remember`, `recall`, `update`, `forget`, and `patch`.
17
- - **Continuity**: snapshots, checkpoints, compaction, and open loops across sessions.
18
- - **Policy**: separate authority domain with tiered enforcement and privileged out-of-band overrides.
19
- - **Agent namespaces**: logically partitioned memory via `dotmem/agent`.
20
- - **Notes and profiles**: short-lived notes and read-only built-in profiles (including the optional Joy profile).
21
- - **MCP and CLI**: stdio MCP server (`dotmem-mcp`) and command-line tools.
17
+ - **Acquired experience:** evidenced, applicability-scoped claims through `discover`, `project`, and `acquire`.
18
+ - **Application memory:** typed key/value entries through `remember`, `recall`, `update`, `forget`, and `patch`.
19
+ - **Continuity:** snapshots, checkpoints, compaction, and open loops across sessions.
20
+ - **Policy:** a separate authority domain with tiered enforcement and privileged out-of-band overrides.
21
+ - **Agent namespaces:** logically partitioned memory through `dotmem/agent`.
22
+ - **Notes and profiles:** short-lived notes and read-only built-in profiles, including the Joy profile.
23
+ - **MCP and CLI:** a stdio MCP server (`dotmem-mcp`) and command-line tools.
24
+
25
+ Dotmem owns memory, continuity, profiles, agents, and MCP capabilities end to end. MCP is an access interface, not the core.
22
26
 
23
27
  ---
24
28
 
25
- Dotmem is the active owner of memory, continuity, profiles, agents, and MCP capabilities. It is not a wrapper around an external memory service. MCP is an access interface, not the core.
29
+ ## Installation
26
30
 
27
- ---
31
+ ```bash
32
+ npm install dotmem
33
+ ```
28
34
 
29
- ## Install
35
+ Other supported package managers:
30
36
 
31
37
  ```bash
32
- npm i dotmem
33
- # or
34
- bun i dotmem
35
- # or
36
- pnpm i dotmem
38
+ bun add dotmem
39
+ pnpm add dotmem
37
40
  ```
38
41
 
39
- Requires Node.js >= 18.0.0.
42
+ **Requirements:** Node.js >= 20.0.0.
43
+
44
+ The MCP server is distributed separately as `dotmem-mcp`. See [MCP server](#mcp-server).
40
45
 
41
46
  ---
42
47
 
43
- ## Quick Start (continuos chat)
48
+ ## Quick Start — Continuous Chat
44
49
 
45
- ### Install dotmem global
50
+ Run the Dotmem MCP server on your machine so that your AI host and your terminal share the same local memory store.
46
51
 
47
- ```sh
48
- npm i -g dotmem memorio
52
+ 1. Add the server to your host configuration (example for Claude Desktop, read-only by default):
49
53
 
50
- ```
51
- ### See MCP section or
54
+ ```json
55
+ {
56
+ "mcpServers": {
57
+ "dotmem": {
58
+ "command": "npx",
59
+ "args": ["-y", "-p", "dotmem-mcp", "dotmem-mcp"]
60
+ }
61
+ }
62
+ }
63
+ ```
52
64
 
53
- ```chat
54
- npx -y -p dotmem dotmem-mcp
65
+ 2. Restart the host.
66
+ 3. Start the conversation with `Hi Joy!`.
55
67
 
56
- ```
68
+ To allow the host to write memory, add `"env": { "DOTMEM_MCP_WRITE": "1" }`. Configurations for other hosts are in [MCP server](#mcp-server).
69
+
70
+ ---
57
71
 
58
- ## Quick Start (coding)
72
+ ## Quick Start — Coding
59
73
 
60
- The runtime initializes lazily on first call; no explicit `init()` is required.
74
+ The runtime initializes lazily on the first call. No explicit `init()` is required.
61
75
 
62
76
  ```typescript
63
77
  import { memory } from 'dotmem'
64
78
 
65
79
  // Discover relevant acquired experience for a situation
66
- const discovery = await memory.discover('User needs a language recommendation for a new project', {
67
- depth: 'current',
68
- maxCandidates: 10
69
- })
80
+ const discovery = await memory.discover(
81
+ 'User needs a language recommendation for a new project',
82
+ {
83
+ depth: 'current',
84
+ maxCandidates: 10
85
+ }
86
+ )
70
87
 
71
88
  // Project a bounded context from discovered claims
72
- const projection = memory.project(discovery, { maxCandidates: 5, maxCharacters: 4000 })
89
+ const projection = memory.project(discovery, {
90
+ maxCandidates: 5,
91
+ maxCharacters: 4000
92
+ })
93
+
73
94
  console.info(projection.text)
74
95
 
75
- // Acquire durable experience (persists across restarts via .mem files)
96
+ // Acquire durable experience
97
+ // Persists across restarts through .mem files
76
98
  await memory.acquire({
77
99
  id: 'user.language-preference',
78
100
  knowledge: { language: 'TypeScript' },
79
101
  applicability: { area: 'language-selection' },
80
- evidence: [{ id: 'conv-001', source: 'conversation', observedAt: new Date().toISOString() }],
102
+ evidence: [
103
+ {
104
+ id: 'conv-001',
105
+ source: 'conversation',
106
+ observedAt: new Date().toISOString()
107
+ }
108
+ ],
81
109
  epistemicType: 'observed'
82
110
  })
83
111
  ```
84
112
 
85
- For agent-namespaced memory, use the `dotmem/agent` subpath:
113
+ ### Agent-namespaced memory
86
114
 
87
115
  ```typescript
88
116
  import { createAgentMemory } from 'dotmem/agent'
89
117
 
90
118
  const agent = createAgentMemory('support-agent')
119
+
91
120
  await agent.remember('greeting', 'Hello! How can I help?', {
92
121
  type: 'fact',
93
122
  confidence: 0.9,
@@ -96,68 +125,94 @@ await agent.remember('greeting', 'Hello! How can I help?', {
96
125
  })
97
126
  ```
98
127
 
99
- > `remember()` with scope `durable` uses IndexedDB and is browser-only. For Node/Bun, use `memory.acquire()`. See [MEMORY.md](./MEMORY.md) for scope details.
128
+ > ⚠️ **Persistence in Node.js, Bun, and Deno**
129
+ >
130
+ > - `remember()` with scope `durable` uses IndexedDB and is **browser-only**.
131
+ > - The internal `store` and `session` layers fall back to in-memory `Map` instances outside the browser. **Data stored there is lost on restart.**
132
+ > - To persist across restarts in Node.js and Bun, use `memory.acquire()`, which writes `.mem` files.
133
+ >
134
+ > See [MEMORY.md](./MEMORY.md) for scope details.
100
135
 
101
136
  ---
102
137
 
103
138
  ## Core capabilities
104
139
 
105
- - `memory.discover`, `memory.context`, `memory.project` — retrieval and bounded context projection.
106
- - `memory.acquire`, `memory.acquireStaged` — evidenced acquisition with policy evaluation.
107
- - `memory.remember`, `memory.recall`, `memory.update`, `memory.forget`, `memory.patch` — application memory.
108
- - `memory.journal`, `memory.note`, `memory.profile`, `memory.seed`, `memory.policy`, `memory.brain` — sub-facades.
109
- - `continuity` — snapshots, checkpoints, compaction, open loops.
110
- - `security`, `encryption` — RBAC/audit/consent and AES-GCM + PBKDF2 helpers.
111
- - Foundation re-exports: `state`, `store`, `session`, `idb`, `dispatch`, `hlc`.
140
+ | API | Purpose |
141
+ |---|---|
142
+ | `memory.discover`, `memory.context`, `memory.project` | Retrieval and bounded context projection |
143
+ | `memory.acquire`, `memory.acquireStaged` | Evidenced acquisition with policy evaluation |
144
+ | `memory.remember`, `memory.recall`, `memory.update`, `memory.forget`, `memory.patch` | Application memory operations |
145
+ | `memory.journal`, `memory.note`, `memory.profile`, `memory.seed`, `memory.policy`, `memory.brain` | Specialized memory facades |
146
+ | `continuity` | Snapshots, checkpoints, compaction, and open loops |
147
+ | `security`, `encryption` | RBAC, audit, consent, AES-GCM, and PBKDF2 helpers |
112
148
 
113
149
  ---
114
150
 
115
- ## Layers
151
+ ## Architecture and layers
116
152
 
117
- Dotmem exposes **6 user-facing layers** through its public entry points. `knowledge` and `logic` are not public runtime exports (`logic` is experimental/unverified and not exported; `knowledge` is internal). `profile` is available via `memory.profile.get(id)` and its stability depends on the package semver contract.
153
+ Dotmem exposes **six user-facing layers** through its public entry points.
118
154
 
119
155
  | Layer | Availability | Purpose |
120
- |-------|--------------|---------|
156
+ |---|---|---|
121
157
  | **memory** | `dotmem` (main) | Key/value memory, acquisition lifecycle, journal, and sub-facades |
122
- | **continuity** | `dotmem` (main) | USER + PROJECT + TASK context composition, snapshots, open loops |
158
+ | **continuity** | `dotmem` (main) | USER + PROJECT + TASK context composition, snapshots, and open loops |
123
159
  | **agent** | `dotmem/agent` (subpath) | Agent-facing memory with logical namespace partitioning |
124
- | **policy** | `memory.policy` | Policy definition, authority management, three-tier enforcement |
125
- | **profile** | `memory.profile.get(id)` | Identity and persona documents (read-only built-in profiles, including Joy) |
160
+ | **policy** | `memory.policy` | Policy definition, authority management, and three-tier enforcement |
161
+ | **profile** | `memory.profile.get(id)` | Identity and persona documents; read-only built-in profiles, including Joy |
126
162
  | **note** | `memory.note` | Short-lived notes with tags and origins |
127
163
 
128
- ### Internal / infrastructure
164
+ Not part of the public runtime surface:
129
165
 
130
- | Layer | Purpose | Notes |
131
- |-------|---------|-------|
132
- | **seed** | Development-only initial memory seed | `--dev` required |
133
- | **llm-cache** | LLM response cache types only; no verified runtime implementation | `types/llm-cache.d.ts` |
166
+ - `logic` is experimental and unverified.
167
+ - `knowledge` is internal.
168
+ - `seed` is development-only and requires `--dev`.
169
+ - `llm-cache` ships types only; there is no verified runtime implementation.
134
170
 
135
- > Dotmem re-exports foundational infrastructure: `state` (reactive state), `store` (key/value storage), `idb` (IndexedDB), and `sqlite` (SQL database integration). These are lower-level utilities, not additional AI memory layers.
171
+ The `profile` layer follows the package semver contract.
136
172
 
137
173
  ---
138
174
 
139
175
  ## Retrieval model
140
176
 
141
- dotmem uses **deterministic, verifiable retrieval** without embedding-model dependencies:
177
+ Dotmem uses **deterministic, verifiable retrieval** without embedding-model dependencies.
142
178
 
143
- - Lexical/structured matching with applicability-based eligibility.
179
+ - Lexical and structured matching with applicability-based eligibility.
144
180
  - No embeddings, vector indexes, or semantic similarity search.
145
181
  - Results are reproducible given the same store and query.
146
182
 
147
- "AI-oriented" refers to the memory lifecycle and API design (acquisition with evidence/provenance, applicability scoping, policy-gated writes, context projection for LLM consumption), not the underlying retrieval algorithm. For semantic/vector search, pair dotmem with a dedicated embedding store.
183
+ "AI-oriented" describes the memory lifecycle and API design, not the retrieval algorithm:
184
+
185
+ - Acquisition with evidence and provenance.
186
+ - Applicability scoping.
187
+ - Policy-gated writes.
188
+ - Context projection for LLM consumption.
189
+
190
+ For semantic or vector search, pair Dotmem with a dedicated embedding store.
148
191
 
149
192
  ---
150
193
 
151
194
  ## MCP server
152
195
 
153
- `dotmem-mcp` is the stdio MCP server. It runs on the operator's machine so a connected AI host and the terminal share the same store. Write access is gated by `DOTMEM_MCP_WRITE=1`.
196
+ `dotmem-mcp` is the stdio MCP server. It runs on the operator's machine, so a connected AI host and the terminal share the same local memory store.
197
+
198
+ ### Read-only by default
199
+
200
+ The server starts **read-only**. Write access is an explicit opt-in:
201
+
202
+ ```bash
203
+ DOTMEM_MCP_WRITE=1
204
+ ```
205
+
206
+ Enable it only if you want the connected host to be able to modify memory.
154
207
 
155
- Canonical launch command (use this form in all configurations):
208
+ ### Launch command
156
209
 
157
210
  ```bash
158
- npx -y -p dotmem-mcp
211
+ npx -y -p dotmem-mcp dotmem-mcp
159
212
  ```
160
213
 
214
+ > 💡 For long-lived setups, pin the version (`dotmem-mcp@x.y.z`) instead of taking the latest on every launch.
215
+
161
216
  ### Claude Desktop
162
217
 
163
218
  ```json
@@ -165,7 +220,20 @@ npx -y -p dotmem-mcp
165
220
  "mcpServers": {
166
221
  "dotmem": {
167
222
  "command": "npx",
168
- "args": ["-y", "-p", "dotmem-mcp"],
223
+ "args": ["-y", "-p", "dotmem-mcp", "dotmem-mcp"]
224
+ }
225
+ }
226
+ }
227
+ ```
228
+
229
+ With write access:
230
+
231
+ ```json
232
+ {
233
+ "mcpServers": {
234
+ "dotmem": {
235
+ "command": "npx",
236
+ "args": ["-y", "-p", "dotmem-mcp", "dotmem-mcp"],
169
237
  "env": { "DOTMEM_MCP_WRITE": "1" }
170
238
  }
171
239
  }
@@ -175,77 +243,97 @@ npx -y -p dotmem-mcp
175
243
  ### Claude Code
176
244
 
177
245
  ```bash
178
- claude mcp add --env DOTMEM_MCP_WRITE=1 --transport stdio dotmem -- npx -y -p dotmem-mcp
246
+ # read-only
247
+ claude mcp add --transport stdio dotmem -- npx -y -p dotmem-mcp dotmem-mcp
248
+
249
+ # with write access
250
+ claude mcp add \
251
+ --env DOTMEM_MCP_WRITE=1 \
252
+ --transport stdio \
253
+ dotmem -- npx -y -p dotmem-mcp dotmem-mcp
179
254
  ```
180
255
 
181
256
  ### Kilo / OpenCode
182
257
 
183
258
  ```jsonc
184
- "mcp": {
185
- "dotmem": {
186
- "type": "local",
187
- "command": ["npx", "-y", "-p", "dotmem-mcp"],
188
- "enabled": true,
189
- "environment": { "DOTMEM_MCP_WRITE": "1" }
259
+ {
260
+ "mcp": {
261
+ "dotmem": {
262
+ "type": "local",
263
+ "command": ["npx", "-y", "-p", "dotmem-mcp", "dotmem-mcp"],
264
+ "enabled": true
265
+ // For write access, add:
266
+ // "environment": { "DOTMEM_MCP_WRITE": "1" }
267
+ }
190
268
  }
191
269
  }
192
270
  ```
193
271
 
194
- ### Windows Command Prompt (cmd.exe)
272
+ ### Windows (cmd.exe)
195
273
 
196
- In Windows `cmd.exe`, `npx` may not be directly executable as a command. Use `cmd /c npx`:
274
+ On Windows, `npx` may not be directly executable by an MCP host. Use `cmd /c npx`:
197
275
 
198
276
  ```json
199
277
  {
200
278
  "mcpServers": {
201
279
  "dotmem": {
202
280
  "command": "cmd",
203
- "args": ["/c", "npx", "-y", "-p", "dotmem-mcp"],
204
- "env": { "DOTMEM_MCP_WRITE": "1" }
281
+ "args": ["/c", "npx", "-y", "-p", "dotmem-mcp", "dotmem-mcp"]
205
282
  }
206
283
  }
207
284
  }
208
285
  ```
209
286
 
210
- See [MEMORY.md](./MEMORY.md) for the full tool list and write-gating details.
287
+ Add `"env": { "DOTMEM_MCP_WRITE": "1" }` for write access.
288
+
289
+ See [MEMORY.md](./MEMORY.md) for the complete MCP tool list and write-gating details.
211
290
 
212
291
  ---
213
292
 
214
- ## Optional Joy identity
293
+ ## Joy identity
294
+
295
+ Dotmem core is model- and provider-independent.
215
296
 
216
- Dotmem core is model- and persona-independent. Joy/Jo is an optional agent identity and profile. See [docs/JOY.md](./JOY.md) for activation (exact phrase only), discovery order, and the optional profile.
297
+ **Joy/Jo is the native, Dotmem collaborator identity and profile.**
298
+
299
+ Joy is the canonical identity. Jo is its conversational abbreviation and alias; both resolve to the same identity.
300
+
301
+ The Joy profile is part of Dotmem's native profile system. It is not an optional plugin, external persona, or provider-specific feature.
302
+
303
+ See [JOY.md](./JOY.md) for activation rules, discovery order, identity resolution, profile requirements.
217
304
 
218
305
  ---
219
306
 
220
307
  ## Documentation
221
308
 
222
309
  | Document | Description |
223
- |----------|-------------|
224
- | [MEMORY.md](./MEMORY.md) | Full memory model: acquisition contract, policy language, epistemic typing, enforcement, continuity, identity |
225
- | [AGENTS.md](./AGENTS.md) | AI agent working rules, activation phrases, complete `memory.*` surface |
226
- | [SECURITY.md](./SECURITY.md) | Encryption, multitenancy, key management, trust model, JHF, sandbox |
227
- | [JOY.md](./JOY.md) | Optional Joy identity, activation matching, discovery order |
228
- | [PACKAGE.md](./PACKAGE.md) | Package contents, full quick-start, dependency graph |
310
+ |---|---|
311
+ | [MEMORY.md](./MEMORY.md) | Memory model: acquisition contract, policy language, epistemic typing, enforcement, continuity, and identity |
312
+ | [AGENTS.md](./AGENTS.md) | AI agent working rules, activation phrases, and complete `memory.*` surface |
313
+ | [SECURITY.md](./SECURITY.md) | Encryption, multitenancy, key management, trust model, JHF, and sandbox |
314
+ | [JOY.md](./JOY.md) | Joy identity, activation matching, and discovery order |
315
+ | [PACKAGE.md](./PACKAGE.md) | Package contents, complete quick start, and dependency graph |
229
316
  | [LICENSE.md](./LICENSE.md) | License |
230
317
 
231
318
  ---
232
319
 
233
320
  ## Compatibility
234
321
 
235
- **License**: MIT (SPDX: `MIT`)
322
+ | Runtime | Compatibility |
323
+ |---|---|
324
+ | Node.js >= 20.0.0 | Declared in `package.json` engines |
325
+ | Bun >= 1.0 | Tested in CI |
326
+ | Browser | ES2020+ with IndexedDB, localStorage, and sessionStorage |
327
+ | Deno | Compatible, not routinely tested |
236
328
 
237
- **Supported runtimes**:
238
- - Node.js >= 18.0.0 (declared in `package.json` engines)
239
- - Bun >= 1.0 (tested in CI)
240
- - Browser (ES2020+ with IndexedDB, localStorage, sessionStorage)
241
- - Deno (compatible, not routinely tested)
329
+ **Tested in CI:** Node.js 20.x, Node.js 22.x, Bun 1.x.
242
330
 
243
- **Tested in CI**: Node.js 20.x, 22.x; Bun 1.x
244
-
245
- **Note**: The `durable` scope in `memory.remember()` uses IndexedDB and is browser-only. For cross-restart persistence in Node/Bun, use `memory.acquire()` which writes `.mem` package files. The `store` and `session` layers fall back to in-memory `Map`s in Node/Bun/Deno and do not survive process restarts.
331
+ For persistence rules per runtime, see the [persistence warning](#agent-namespaced-memory) in Quick Start.
246
332
 
247
333
  ---
248
334
 
249
335
  ## License
250
336
 
251
- MIT (c) 2026 Dario Passariello.
337
+ MIT — Copyright (c) 2026 Dario Passariello.
338
+
339
+ SPDX-License-Identifier: `MIT`
package/SECURITY.md CHANGED
@@ -8,7 +8,7 @@ This document covers dotmem's optional encryption layer, client-side multitenanc
8
8
 
9
9
  This applies to every layer: `state`, `store`, `session`, `idb`, `memory`, `sqlite`. Treat browser storage as client-controlled unless you explicitly opt in.
10
10
 
11
- Core declares no production dependencies in package.json. `memorio` is listed under devDependencies, but the built ESM/CJS output imports it as an external runtime module; a published install therefore needs `memorio` available unless packaging changes. No `eval`, no dynamic code execution, no bundled telemetry, sanitized keys, validated inputs, bounded journal entries, UUID-based session identifiers. Independently checkable via Socket.dev / Snyk. (The optional MCP stdio entrypoint is the one declared-dependency surface: `zod` and `@modelcontextprotocol/server`.)
11
+ The published package declares production dependencies, including `@modelcontextprotocol/server`, `memorio` and `zod`. The MCP stdio entrypoint uses `zod` and `@modelcontextprotocol/server`. No `eval`, no dynamic code execution, no bundled telemetry, sanitized keys, validated inputs, bounded journal entries, UUID-based session identifiers. Independently checkable via Socket.dev / Snyk.
12
12
 
13
13
  ---
14
14
 
package/agent.cjs CHANGED
@@ -18,10 +18,10 @@ var __export = (target, all) => {
18
18
  __defProp(target, name, { get: all[name], enumerable: true });
19
19
  };
20
20
 
21
- // suppress-idb-warning.ts
21
+ // core/suppress-idb-warning.ts
22
22
  var orig;
23
23
  var init_suppress_idb_warning = __esm({
24
- "suppress-idb-warning.ts"() {
24
+ "core/suppress-idb-warning.ts"() {
25
25
  orig = console.warn.bind(console);
26
26
  console.warn = (...args) => {
27
27
  if (typeof args[0] === "string" && args[0].includes("IndexedDB is not available")) return;
package/agent.js CHANGED
@@ -16,10 +16,10 @@ var __export = (target, all) => {
16
16
  __defProp(target, name, { get: all[name], enumerable: true });
17
17
  };
18
18
 
19
- // suppress-idb-warning.ts
19
+ // core/suppress-idb-warning.ts
20
20
  var orig;
21
21
  var init_suppress_idb_warning = __esm({
22
- "suppress-idb-warning.ts"() {
22
+ "core/suppress-idb-warning.ts"() {
23
23
  orig = console.warn.bind(console);
24
24
  console.warn = (...args) => {
25
25
  if (typeof args[0] === "string" && args[0].includes("IndexedDB is not available")) return;