omo-memory 0.1.11 → 0.1.13

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.
@@ -32,6 +32,7 @@ npx -y omo-memory session bootstrap --host codex --adapter lazycodex --limit 5
32
32
  npx -y omo-memory session start --host codex --adapter lazycodex
33
33
  npx -y omo-memory session start --host grok --adapter lfg
34
34
  npx -y omo-memory recent --limit 10
35
+ npx -y omo-memory recall --query "current roadmap decision" --limit 10
35
36
  ```
36
37
 
37
38
  For a source checkout:
@@ -45,6 +46,7 @@ node dist/cli.js event record --type decision --summary "Use OMO Memory as the s
45
46
  node dist/cli.js event record --type qa_evidence --summary "CLI smoke passed for init/session/event/recent."
46
47
  node dist/cli.js handoff write --summary "Continue from recent decision and qa_evidence events."
47
48
  node dist/cli.js recent --limit 10
49
+ node dist/cli.js recall --query "qa evidence" --limit 10
48
50
  node dist/cli.js export
49
51
  node dist/cli.js purge --yes
50
52
  ```
@@ -85,7 +87,7 @@ Register the same MCP server in every host that needs memory access. Do not crea
85
87
 
86
88
  ## Session Bootstrap Flow
87
89
 
88
- At the beginning of a Codex, OpenCode, or Grok adapter session, call `memory_bootstrap_session` instead of separately calling `memory_start_session` and `memory_recent_events`.
90
+ At the beginning of a Codex, OpenCode, or Grok adapter session, call `memory_bootstrap_session` only when the adapter needs a session id for subsequent writes. Do not use bootstrap as a prompt-time memory injection hook.
89
91
 
90
92
  ```json
91
93
  {
@@ -102,9 +104,8 @@ The tool returns:
102
104
 
103
105
  - `sessionId`: the new session row for subsequent event/handoff writes.
104
106
  - `project`: the current git/project namespace.
105
- - `recentEvents`: recent events from the same project namespace.
106
107
 
107
- During the session, write concise task state and evidence with the returned `sessionId`:
108
+ During the session, hooks should write concise user-action summaries, task state, decisions, and evidence with the returned `sessionId`:
108
109
 
109
110
  ```json
110
111
  {
@@ -119,6 +120,13 @@ During the session, write concise task state and evidence with the returned `ses
119
120
 
120
121
  This package is the local MCP-to-SQLite router. It does not scrape host transcripts or centralize cloud state. Hosts and adapters must call the MCP tools at their own lifecycle points.
121
122
 
123
+ Retrieval is opt-in or intent-gated:
124
+
125
+ - Use `memory_recent_events` only when the user explicitly asks for recent OMO Memory context.
126
+ - Use `memory_recall_events` when the current user input has a concrete query that can be matched to recorded summaries, decisions, or evidence.
127
+ - Do not automatically attach the last session to every user prompt.
128
+ - Do not store raw user prompts by default; record concise, redacted action summaries.
129
+
122
130
  Use these tools:
123
131
 
124
132
  - `memory_init`
@@ -127,9 +135,58 @@ Use these tools:
127
135
  - `memory_start_session`
128
136
  - `memory_record_event`
129
137
  - `memory_recent_events`
138
+ - `memory_recall_events`
130
139
  - `memory_write_handoff`
131
140
  - `memory_export`
132
141
  - `memory_purge`
142
+ - `memory_global_scan`
143
+ - `memory_global_migrate`
144
+ - `memory_global_list`
145
+ - `memory_ontology_candidates`
146
+ - `memory_ontology_extract`
147
+ - `memory_ontology_score`
148
+ - `memory_ontology_promote`
149
+ - `memory_ontology_demote`
150
+ - `memory_ontology_supersede`
151
+ - `memory_ontology_recall`
152
+
153
+ CLI updates: normal CLI commands automatically launch a quiet background `npm install -g omo-memory@latest` at most once per day. MCP startup intentionally does not auto-update because stdout/stderr must remain reserved for the protocol. Hosts that need pinned installs should set `OMO_MEMORY_AUTO_UPDATE=0` in the CLI environment.
154
+
155
+ Global migration is copy/import only. Adapters may scan for existing project-local `.omo/memory/state.sqlite` databases and import them into a user-selected global SQLite file, but they must preserve source DBs and retain source provenance in the global store.
156
+
157
+ Global migration also materializes an aggregate OMO schema view inside the global SQLite file. This lets existing ontology extraction, retention scoring, recall, and OpenTUI graph code operate on integrated cross-project events while `global_*` tables retain source database provenance.
158
+
159
+ Example global second-brain flow:
160
+
161
+ ```sh
162
+ omo-memory global scan --root /Users/ilseoblee/workspace
163
+ omo-memory global migrate --root /Users/ilseoblee/workspace --global-db ~/.omo/memory/global.sqlite
164
+ OMO_MEMORY_DB=~/.omo/memory/global.sqlite omo-memory ontology candidates
165
+ OMO_MEMORY_DB=~/.omo/memory/global.sqlite omo-memory ontology score
166
+ bun --version
167
+ omo-memory graph tui --db ~/.omo/memory/global.sqlite --query linaforge
168
+ ```
169
+
170
+ `graph tui` requires `bun` on `PATH` for the OpenTUI terminal renderer. Other CLI and MCP commands run on Node.
171
+
172
+ Lifecycle commands:
173
+
174
+ - `memory_ontology_candidates`: derive candidate terms from concise summaries.
175
+ - `memory_ontology_extract`: explicitly extract candidates from one summary/event.
176
+ - `memory_ontology_score`: recompute deterministic scores and retention classes.
177
+ - `memory_ontology_promote`: curate a concept into durable memory.
178
+ - `memory_ontology_demote`: lower a durable memory's retention class.
179
+ - `memory_ontology_supersede`: preserve the old memory and create a replacement.
180
+ - `memory_ontology_recall`: retrieve ontology-backed memories only for an explicit query.
181
+
182
+ OpenTUI graph controls:
183
+
184
+ - `q`: quit.
185
+ - `Up` / `Down`: move selected concept.
186
+ - `Tab`: move to the next concept.
187
+ - `/` or `f`: focus filter input when supported by the terminal runtime.
188
+
189
+ The graph UI is local terminal UI. It does not require a browser, web server, cloud account, or vector service.
133
190
 
134
191
  Example session start:
135
192
 
@@ -162,3 +219,58 @@ Example QA evidence:
162
219
  - Store sanitized summaries and evidence references instead of full logs.
163
220
  - Host-specific values may appear only in small redacted metadata payloads and must not require schema branches.
164
221
  - Export and purge are explicit lifecycle commands; purge requires explicit confirmation.
222
+
223
+ ## Ontology Schema Boundary
224
+
225
+ OMO Memory's chronological ledger remains authoritative: sessions, events, and handoffs record what happened in a project. The ontology schema is an additive layer for durable memory derived from that ledger:
226
+
227
+ - `concepts` stores vocabulary entries such as project terms, practices, tools, and recurring ideas.
228
+ - `relations` stores typed links between concepts, decisions, events, sessions, and handoffs.
229
+ - `durable_memories` stores approved long-term facts, preferences, and working rules.
230
+ - `decision_records` stores important choices with rationale, evidence, status, reversibility, and provenance.
231
+
232
+ Adapters must treat ontology rows as curated local memory, not as raw capture. Do not write full transcripts, raw logs, `.env` contents, auth files, cookies, bearer headers, or secret-bearing payloads into ontology tables. User-authored text must pass through the same redaction boundary used by event and handoff writes before it is promoted into durable memory.
233
+
234
+ The ontology layer is intentionally not a new adapter surface by itself. CLI and MCP commands should continue to call shared core functions, and future concept/decision commands must not create host-specific schemas or side databases.
235
+
236
+ ## Retention Scoring Policy (Deterministic Contract)
237
+
238
+ Retention classification is strictly deterministic. There is no ML, embeddings, or hidden model. A pure function maps explicit signals to a numeric score and then to one of five classes.
239
+
240
+ Classes (in ascending durability):
241
+
242
+ - `forget`: score < 30 (or after decay/contradiction). Safe to drop.
243
+ - `temporary`: 30 <= score < 50. Short-term context only.
244
+ - `working`: 50 <= score < 75. Active task/iteration memory.
245
+ - `durable`: 75 <= score < 90. Cross-session value; survives typical decay.
246
+ - `permanent`: score >= 90, or any manually pinned item. Manual pin is a hard override.
247
+
248
+ Manual pin rule (critical): an item with `manualPin: true` is always classified `permanent` regardless of raw score, age, or frequency. Decay jobs and age-based expiration MUST NOT remove or downgrade pinned permanent memory; only explicit supersede/demote/purge may change it.
249
+
250
+ ### Score Formula (pure, exposed)
251
+
252
+ Exported constants (see `src/retentionPolicy.ts`):
253
+
254
+ - `RETENTION_CLASSES = ["forget", "temporary", "working", "durable", "permanent"] as const`
255
+ - `RETENTION_THRESHOLDS = { forget: 0, temporary: 30, working: 50, durable: 75, permanent: 90 } as const`
256
+ - `RETENTION_WEIGHTS = { frequency: 4.5, spread: 7, decision: 12, qa: 10, relation: 4, confidence: 10, recencyBase: 18, recencyPerDay: 0.55, agePerDay: 0.12, ageCap: 22, contradiction: 9 } as const`
257
+
258
+ ```
259
+ score = clamp(
260
+ frequency * 4.5
261
+ + spread * 7
262
+ + decisionWeight * 12
263
+ + qaWeight * 10
264
+ + relationDegree * 4
265
+ + confidence * 10
266
+ + max(0, 18 - recencyDays * 0.55)
267
+ - min(22, ageDays * 0.12)
268
+ - contradictionCount * 9
269
+ , 0, 110)
270
+ ```
271
+
272
+ `computeRetentionScore(input)` returns the rounded integer. `classifyRetention(score, manualPin)` returns the class, applying the pin override first.
273
+
274
+ Boundary cases (score, pin=false): 29→forget, 30→temporary, 49→temporary, 50→working, 74→working, 75→durable, 89→durable, 90→permanent. These are verified by the focused contract test.
275
+
276
+ All scoring inputs are derived from ledger signals (event counts, last-seen deltas, project spread from index, decision/qa event types, explicit relation degree, stored confidence, manual pin flag, contradiction markers). No raw transcripts or secrets are inputs.
@@ -1,13 +1,13 @@
1
- # Epic: OMO Memory — shared local session DB for OMO adapters
1
+ # Epic: OMO Memory — shared local second-brain DB for OMO adapters
2
2
 
3
3
  ## Goal
4
4
 
5
- Build a host-neutral local memory layer for OMO so lazycodex, omo-on-opencode, lfg, and future adapters can share task context across coding-tool sessions.
5
+ Build a host-neutral local memory layer for OMO so lazycodex, omo-on-opencode, lfg, and future adapters can share task context, durable decisions, and ontology-backed project knowledge across coding-tool sessions.
6
6
 
7
7
  The product ships as both:
8
8
 
9
- - CLI: install, inspect, search, export, purge, and handoff operations.
10
- - MCP server: standard stdio tools for agents and coding tools to read/write OMO memory.
9
+ - CLI: install, inspect, global migration, ontology lifecycle, graph, search, export, purge, and handoff operations.
10
+ - MCP server: standard stdio tools for agents and coding tools to explicitly read/write OMO memory.
11
11
 
12
12
  ## Problem
13
13
 
@@ -18,32 +18,64 @@ Codegraph solves code intelligence, not work/session memory. OMO needs a separat
18
18
  ## Product direction
19
19
 
20
20
  - Project-local DB: `<project-root>/.omo/memory/state.sqlite`
21
+ - Optional global DB: user-selected SQLite path such as `~/.omo/memory/global.sqlite`, populated by copy/import from local project ledgers
21
22
  - Project namespace: derive from git remote + repo root hash, with branch/head metadata
22
23
  - Local-first privacy: no cloud sync and no secret storage by default
23
24
  - Adapter-neutral schema: `host` and `adapter` are metadata, not separate products
24
25
  - Shared API: CLI and MCP use the same core DB layer
26
+ - Second-brain lifecycle: candidate extraction, deterministic retention scoring, promotion, demotion, supersession, explicit recall, and OpenTUI graph inspection
25
27
 
26
28
  ## In scope
27
29
 
28
30
  - SQLite schema and migrations
29
31
  - CLI commands:
30
32
  - `init`
33
+ - `global scan`
34
+ - `global migrate`
31
35
  - `session start`
36
+ - `session bootstrap`
32
37
  - `event record`
33
38
  - `recent`
39
+ - `recall`
34
40
  - `handoff write`
35
41
  - `doctor`
42
+ - `ontology candidates`
43
+ - `ontology score`
44
+ - `ontology promote`
45
+ - `ontology demote`
46
+ - `ontology supersede`
47
+ - `ontology recall`
48
+ - `graph tui`
36
49
  - MCP stdio server with tools:
37
50
  - `memory_init`
38
51
  - `memory_project_context`
52
+ - `memory_bootstrap_session`
53
+ - `memory_start_session`
39
54
  - `memory_record_event`
40
55
  - `memory_recent_events`
56
+ - `memory_recall_events`
41
57
  - `memory_write_handoff`
58
+ - `memory_global_scan`
59
+ - `memory_global_migrate`
60
+ - `memory_global_list`
61
+ - `memory_ontology_candidates`
62
+ - `memory_ontology_extract`
63
+ - `memory_ontology_score`
64
+ - `memory_ontology_promote`
65
+ - `memory_ontology_demote`
66
+ - `memory_ontology_supersede`
67
+ - `memory_ontology_recall`
42
68
  - Privacy guardrails:
43
69
  - local-only default
44
70
  - no API key/token/env capture
45
71
  - explicit purge/export commands
46
72
  - Adapter integration notes for lazycodex, omo-on-opencode, and lfg
73
+ - Retention classes:
74
+ - `forget`: safe to drop after low score or decay
75
+ - `temporary`: short-term task context
76
+ - `working`: active project memory
77
+ - `durable`: cross-session knowledge
78
+ - `permanent`: manual-pin or high-score knowledge; only explicit demote/supersede/purge changes it
47
79
 
48
80
  ## Out of scope
49
81
 
@@ -51,6 +83,8 @@ Codegraph solves code intelligence, not work/session memory. OMO needs a separat
51
83
  - Team sharing by default
52
84
  - Full transcript capture by default
53
85
  - Vector/embedding search in MVP
86
+ - Browser-only graph UI
87
+ - Automatic prompt injection from the last session
54
88
  - Replacing codegraph
55
89
  - Host-specific private APIs as required dependencies
56
90
 
@@ -59,33 +93,51 @@ Codegraph solves code intelligence, not work/session memory. OMO needs a separat
59
93
  ### CLI
60
94
 
61
95
  - `omo-memory init` creates or migrates `<project-root>/.omo/memory/state.sqlite`.
96
+ - `omo-memory global scan --root <path>` discovers project-local OMO DBs and reports schema versions.
97
+ - `omo-memory global migrate --root <path> --global-db <path>` copies source DB data into one global SQLite file without mutating source DBs.
62
98
  - `omo-memory session start --host grok --adapter lfg` records a session for the current project.
99
+ - `omo-memory session bootstrap --host codex --adapter lazycodex` returns a session id and project metadata without injecting recent events.
63
100
  - `omo-memory event record --type decision --summary "..."` appends a project/session event.
64
101
  - `omo-memory recent` lists recent project events.
102
+ - `omo-memory recall --query "..."` performs explicit query-gated event recall.
65
103
  - `omo-memory handoff write --summary-file path.md` stores a handoff summary.
104
+ - `omo-memory ontology candidates` extracts vocabulary candidates from concise summaries.
105
+ - `omo-memory ontology score` recomputes deterministic retention classes.
106
+ - `omo-memory ontology promote/demote/supersede/recall` supports curated durable memory lifecycle.
107
+ - `omo-memory graph tui --db <path> --query <term>` opens an OpenTUI graph with `q` quit, arrow/tab selection, retention class, score, provenance, and detail pane. It requires `bun` on `PATH`; other CLI and MCP commands run on Node.
66
108
 
67
109
  ### MCP
68
110
 
69
111
  - `omo-memory mcp` starts a stdio MCP server.
70
- - MCP tools can initialize the DB, read project context, record events, list recent events, and write handoffs.
112
+ - MCP tools can initialize the DB, read project context, record events, list/retrieve explicit memory, write handoffs, migrate global memory, and manage ontology lifecycle.
71
113
  - MCP tool responses are structured JSON text.
114
+ - `memory_bootstrap_session` remains write-only/session-only and does not return `recentEvents`.
72
115
 
73
116
  ### Privacy and safety
74
117
 
75
118
  - No secrets are read from `.env`, auth files, or host config by default.
76
119
  - DB path can be overridden only by explicit `OMO_MEMORY_DB`.
77
120
  - `doctor` reports DB path, schema version, and project identity without leaking sensitive values.
121
+ - Global migration is copy/import only; source project DB mtimes and row counts must remain unchanged.
122
+ - Graph and recall are local-first and explicit; no cloud sync, browser server, raw transcript capture, or embeddings are required.
78
123
 
79
124
  ### QA evidence
80
125
 
81
126
  - `npm run typecheck`
82
127
  - `npm run build`
128
+ - `npm run check`
83
129
  - CLI smoke:
84
130
  - `node dist/cli.js init`
131
+ - `node dist/cli.js global scan --root <tmp-workspace>`
132
+ - `node dist/cli.js global migrate --root <tmp-workspace> --global-db <tmp-global.sqlite>`
85
133
  - `node dist/cli.js session start --host grok --adapter lfg`
86
134
  - `node dist/cli.js event record --type decision --summary "smoke"`
135
+ - `node dist/cli.js ontology candidates`
136
+ - `node dist/cli.js ontology score`
137
+ - `bun dist/cli.js graph tui --db <tmp-db> --query smoke`
87
138
  - `node dist/cli.js recent`
88
139
  - MCP smoke: start `node dist/cli.js mcp` and verify `tools/list` includes memory tools.
140
+ - Backfill verifier: synthetic Linaforge/omo-memory/lfg/omo-phone DB replicas plus read-only scan of real local DB paths.
89
141
 
90
142
  ## Follow-up issue breakdown
91
143
 
@@ -94,5 +146,9 @@ Codegraph solves code intelligence, not work/session memory. OMO needs a separat
94
146
  3. MCP stdio server
95
147
  4. Project identity and git metadata
96
148
  5. Privacy/redaction/purge/export
97
- 6. Adapter integration docs for lazycodex, omo-on-opencode, and lfg
98
- 7. QA harness for CLI and MCP smoke tests
149
+ 6. Global SQLite migration and source provenance
150
+ 7. Deterministic ontology extraction and retention scoring
151
+ 8. Durable memory promote/demote/supersede lifecycle
152
+ 9. OpenTUI graph visualization
153
+ 10. Adapter integration docs for lazycodex, omo-on-opencode, and lfg
154
+ 11. QA harness for CLI, MCP, global backfill, and TUI smoke tests
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omo-memory",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Host-neutral local SQLite memory and session ledger for OMO adapters, exposed through CLI and MCP.",
5
5
  "type": "module",
6
6
  "files": [
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsc -p tsconfig.json",
27
+ "postbuild": "chmod 755 dist/cli.js",
27
28
  "typecheck": "tsc --noEmit",
28
29
  "lint": "biome check .",
29
30
  "format": "biome format --write .",
@@ -39,6 +40,7 @@
39
40
  },
40
41
  "dependencies": {
41
42
  "@modelcontextprotocol/sdk": "^1.29.0",
43
+ "@opentui/core": "0.4.2",
42
44
  "better-sqlite3": "^12.11.1",
43
45
  "zod": "^4.4.3"
44
46
  },