oc-mnemoria 0.1.0
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/LICENSE +21 -0
- package/README.md +292 -0
- package/commands/ask.md +7 -0
- package/commands/recent.md +7 -0
- package/commands/search.md +7 -0
- package/commands/stats.md +8 -0
- package/commands/timeline.md +7 -0
- package/dist/index.d.ts +300 -0
- package/dist/index.js +13294 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +14 -0
- package/dist/plugin.js +13279 -0
- package/dist/plugin.js.map +1 -0
- package/install.sh +134 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 one-bit
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# oc-mnemoria
|
|
2
|
+
|
|
3
|
+
[](https://github.com/one-bit/oc-mnemoria/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
Persistent shared memory for [OpenCode](https://opencode.ai) agents, powered
|
|
6
|
+
by [mnemoria](https://crates.io/crates/mnemoria).
|
|
7
|
+
|
|
8
|
+
## What it does
|
|
9
|
+
|
|
10
|
+
Every time you start a new OpenCode session, your AI assistant loses all
|
|
11
|
+
context from previous conversations. oc-mnemoria fixes this by giving all
|
|
12
|
+
agents a shared "hive mind" — a single persistent memory store where every
|
|
13
|
+
agent can read and write.
|
|
14
|
+
|
|
15
|
+
Each memory entry is tagged with the agent that created it (plan, build, ask,
|
|
16
|
+
review, ...) so any agent can tell who recorded what. The build agent can see
|
|
17
|
+
what the plan agent decided; the review agent can recall bugs the build agent
|
|
18
|
+
fixed. No context is lost between roles.
|
|
19
|
+
|
|
20
|
+
Memories are stored locally in an append-only binary file using
|
|
21
|
+
[mnemoria](https://github.com/one-bit/mnemoria) — a Rust engine with hybrid
|
|
22
|
+
BM25 + semantic search, CRC32 checksum chains, and corruption recovery.
|
|
23
|
+
|
|
24
|
+
## Prerequisites
|
|
25
|
+
|
|
26
|
+
- [Rust toolchain](https://rustup.rs/) (to install the mnemoria CLI)
|
|
27
|
+
- [OpenCode](https://opencode.ai/) (v0.1+)
|
|
28
|
+
- Node.js >= 18
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
### 1. Install the mnemoria CLI
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
cargo install mnemoria
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. Add the plugin to your project
|
|
39
|
+
|
|
40
|
+
Add `oc-mnemoria` to the `plugin` array in your `opencode.json`:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"$schema": "https://opencode.ai/config.json",
|
|
45
|
+
"plugin": ["oc-mnemoria"]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or use the install script:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
curl -fsSL https://raw.githubusercontent.com/one-bit/oc-mnemoria/main/install.sh | bash
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 3. Install slash commands (optional)
|
|
56
|
+
|
|
57
|
+
Copy the `commands/` directory to your OpenCode config:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
cp commands/*.md ~/.config/opencode/commands/
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## How it works
|
|
64
|
+
|
|
65
|
+
### Storage layout
|
|
66
|
+
|
|
67
|
+
All agents share a single memory store:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
.opencode/mnemoria/
|
|
71
|
+
log.bin # append-only binary log
|
|
72
|
+
manifest.json # metadata and checksums
|
|
73
|
+
mnemoria.lock # advisory file lock
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You can interact with the store directly using the `mnemoria` CLI:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
mnemoria --path .opencode stats
|
|
80
|
+
mnemoria --path .opencode search "authentication"
|
|
81
|
+
mnemoria --path .opencode export memories.json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Agent tagging
|
|
85
|
+
|
|
86
|
+
Every memory entry is tagged with the agent that created it via mnemoria's
|
|
87
|
+
native `--agent` flag. The agent name is a first-class field on each entry,
|
|
88
|
+
visible in search results, timeline output, and JSON exports.
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
# Search only the build agent's memories
|
|
92
|
+
mnemoria --path .opencode search -a build "authentication"
|
|
93
|
+
|
|
94
|
+
# Show only the plan agent's timeline
|
|
95
|
+
mnemoria --path .opencode timeline -a plan
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Automatic capture
|
|
99
|
+
|
|
100
|
+
The plugin automatically captures context from tool usage:
|
|
101
|
+
|
|
102
|
+
| Tool | What gets stored |
|
|
103
|
+
|--------|-------------------------------------------|
|
|
104
|
+
| `read` | File paths, function names, line counts |
|
|
105
|
+
| `bash` | Commands run, success/failure, file paths |
|
|
106
|
+
| `edit` | Files modified, type of change |
|
|
107
|
+
| `write`| Files created |
|
|
108
|
+
| `grep` | Search patterns, result counts |
|
|
109
|
+
| `glob` | Search patterns, matched files |
|
|
110
|
+
|
|
111
|
+
Each observation is linked to the user's intent (extracted from the
|
|
112
|
+
conversation) via chain IDs, so any agent can trace *why* something was done.
|
|
113
|
+
|
|
114
|
+
### System prompt injection
|
|
115
|
+
|
|
116
|
+
At the start of each session, recent observations and past user goals are
|
|
117
|
+
injected into the system prompt. Each entry shows which agent created it,
|
|
118
|
+
giving the current agent immediate cross-agent context.
|
|
119
|
+
|
|
120
|
+
## Tools
|
|
121
|
+
|
|
122
|
+
| Tool | Description |
|
|
123
|
+
|-----------------|-----------------------------------------------------|
|
|
124
|
+
| `remember` | Store a categorized observation in shared memory |
|
|
125
|
+
| `search_memory` | Search by keyword/semantic similarity |
|
|
126
|
+
| `ask_memory` | Ask a natural language question |
|
|
127
|
+
| `memory_stats` | View statistics for the shared store |
|
|
128
|
+
| `timeline` | Browse memories chronologically (all agents) |
|
|
129
|
+
|
|
130
|
+
### Entry types
|
|
131
|
+
|
|
132
|
+
Observations are categorized when stored:
|
|
133
|
+
|
|
134
|
+
`intent` `discovery` `decision` `problem` `solution` `pattern` `warning`
|
|
135
|
+
`success` `refactor` `bugfix` `feature`
|
|
136
|
+
|
|
137
|
+
## Slash commands
|
|
138
|
+
|
|
139
|
+
| Command | Description |
|
|
140
|
+
|----------------------|--------------------------------------|
|
|
141
|
+
| `/memory ask <q>` | Ask about past decisions |
|
|
142
|
+
| `/memory search <q>` | Search memories |
|
|
143
|
+
| `/memory stats` | Show memory statistics |
|
|
144
|
+
| `/memory recent` | Show recent memories |
|
|
145
|
+
| `/memory timeline` | Chronological view |
|
|
146
|
+
|
|
147
|
+
## Inspecting memories from the command line
|
|
148
|
+
|
|
149
|
+
You can use the `mnemoria` CLI directly to browse, search, and manage the
|
|
150
|
+
memory store outside of OpenCode. All commands use `--path .opencode` to
|
|
151
|
+
point at your project's store (mnemoria auto-appends `mnemoria/` to resolve
|
|
152
|
+
the actual data directory).
|
|
153
|
+
|
|
154
|
+
### Browse the timeline
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
# Most recent 20 entries (newest first)
|
|
158
|
+
mnemoria --path .opencode timeline -r
|
|
159
|
+
|
|
160
|
+
# Last 5 entries
|
|
161
|
+
mnemoria --path .opencode timeline -r -l 5
|
|
162
|
+
|
|
163
|
+
# Only entries from the build agent
|
|
164
|
+
mnemoria --path .opencode timeline -a build
|
|
165
|
+
|
|
166
|
+
# Entries from a specific time range (Unix ms timestamps)
|
|
167
|
+
mnemoria --path .opencode timeline -s 1700000000000 -u 1700100000000
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Output looks like:
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
Timeline (3 entries):
|
|
174
|
+
1. [discovery] (build) Found async pattern in auth module - 1700000100000
|
|
175
|
+
2. [decision] (plan) Use JWT for session tokens - 1700000050000
|
|
176
|
+
3. [intent] (plan) Fix authentication flow - 1700000000000
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Search memories
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
# Keyword + semantic hybrid search
|
|
183
|
+
mnemoria --path .opencode search "authentication"
|
|
184
|
+
|
|
185
|
+
# Limit results
|
|
186
|
+
mnemoria --path .opencode search "error handling" -l 5
|
|
187
|
+
|
|
188
|
+
# Search only one agent's memories
|
|
189
|
+
mnemoria --path .opencode search -a review "security"
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Ask a question
|
|
193
|
+
|
|
194
|
+
```sh
|
|
195
|
+
# Ask a natural language question against the memory store
|
|
196
|
+
mnemoria --path .opencode ask "What decisions were made about the database schema?"
|
|
197
|
+
|
|
198
|
+
# Scoped to a single agent
|
|
199
|
+
mnemoria --path .opencode ask -a plan "What was the original plan for auth?"
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### View statistics
|
|
203
|
+
|
|
204
|
+
```sh
|
|
205
|
+
mnemoria --path .opencode stats
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
Memory Statistics:
|
|
210
|
+
Total entries: 42
|
|
211
|
+
File size: 4096 bytes
|
|
212
|
+
Oldest entry: 1700000000000
|
|
213
|
+
Newest entry: 1700001000000
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Export to JSON
|
|
217
|
+
|
|
218
|
+
```sh
|
|
219
|
+
mnemoria --path .opencode export memories.json
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
This produces a JSON array with full entry data including `agent_name`,
|
|
223
|
+
`entry_type`, `summary`, `content`, `timestamp`, and checksum fields.
|
|
224
|
+
Useful for scripting, analysis, or migrating data.
|
|
225
|
+
|
|
226
|
+
### Add a memory manually
|
|
227
|
+
|
|
228
|
+
```sh
|
|
229
|
+
mnemoria --path .opencode add \
|
|
230
|
+
-a build \
|
|
231
|
+
-t decision \
|
|
232
|
+
-s "Switched from REST to GraphQL" \
|
|
233
|
+
"After benchmarking, GraphQL reduced payload size by 60%"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The `-t` flag accepts any entry type: `intent`, `discovery`, `decision`,
|
|
237
|
+
`problem`, `solution`, `pattern`, `warning`, `success`, `refactor`,
|
|
238
|
+
`bugfix`, `feature`. Defaults to `discovery` if omitted.
|
|
239
|
+
|
|
240
|
+
### Verify store integrity
|
|
241
|
+
|
|
242
|
+
```sh
|
|
243
|
+
mnemoria --path .opencode verify
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Checks the CRC32 checksum chain across all entries. Returns a non-zero exit
|
|
247
|
+
code on corruption, making it suitable for CI or pre-commit hooks.
|
|
248
|
+
|
|
249
|
+
## Git integration
|
|
250
|
+
|
|
251
|
+
Mnemoria's append-only binary format is designed for version control. You
|
|
252
|
+
can commit the memory store to track history alongside your code:
|
|
253
|
+
|
|
254
|
+
```sh
|
|
255
|
+
git add .opencode/
|
|
256
|
+
git commit -m "update agent memories"
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Or ignore it:
|
|
260
|
+
|
|
261
|
+
```sh
|
|
262
|
+
echo ".opencode/mnemoria/" >> .gitignore # ignore just the memory store
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## FAQ
|
|
266
|
+
|
|
267
|
+
**How much disk space does this use?**
|
|
268
|
+
The store starts empty. A typical entry is ~100-500 bytes. Active daily use
|
|
269
|
+
produces roughly 2-10 MB per year.
|
|
270
|
+
|
|
271
|
+
**Is my data sent anywhere?**
|
|
272
|
+
No. Everything stays on your local filesystem. The mnemoria engine runs
|
|
273
|
+
entirely offline.
|
|
274
|
+
|
|
275
|
+
**How fast is it?**
|
|
276
|
+
The mnemoria Rust engine delivers sub-millisecond search latency for
|
|
277
|
+
typical store sizes (<10k entries). The plugin shells out to the CLI, so
|
|
278
|
+
there's ~50ms overhead per operation from process spawning.
|
|
279
|
+
|
|
280
|
+
**Can I reset the memory?**
|
|
281
|
+
Delete the store directory:
|
|
282
|
+
```sh
|
|
283
|
+
rm -rf .opencode/mnemoria/
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Can I search only one agent's memories?**
|
|
287
|
+
Yes. Pass the `agent` parameter to `search_memory`, `ask_memory`, or
|
|
288
|
+
`timeline`. From the CLI: `mnemoria --path .opencode search -a build "auth"`.
|
|
289
|
+
|
|
290
|
+
## License
|
|
291
|
+
|
|
292
|
+
MIT
|
package/commands/ask.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Show memories in chronological order
|
|
3
|
+
agent: build
|
|
4
|
+
---
|
|
5
|
+
Show me the timeline of memories from our previous sessions. Use the timeline tool to display memories in chronological order.
|
|
6
|
+
|
|
7
|
+
By default, show the most recent 20 memories (newest first). Each entry shows which agent created it.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { Plugin } from '@opencode-ai/plugin';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* oc-mnemoria — OpenCode Plugin
|
|
5
|
+
*
|
|
6
|
+
* Persistent shared memory ("hive mind") for OpenCode agents, powered by
|
|
7
|
+
* the mnemoria Rust engine (v0.3.1+). All agents share a single memory
|
|
8
|
+
* store — each entry is tagged with the agent that created it via
|
|
9
|
+
* mnemoria's native --agent flag.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare const OcMnemoria: Plugin;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Types for oc-mnemoria — aligned with the mnemoria Rust crate.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Memory entry types matching mnemoria's EntryType enum.
|
|
19
|
+
*/
|
|
20
|
+
type EntryType = "intent" | "discovery" | "decision" | "problem" | "solution" | "pattern" | "warning" | "success" | "refactor" | "bugfix" | "feature";
|
|
21
|
+
/**
|
|
22
|
+
* A memory entry as returned by the mnemoria CLI (JSON output).
|
|
23
|
+
*/
|
|
24
|
+
interface MemoryEntry {
|
|
25
|
+
id: string;
|
|
26
|
+
agent_name: string;
|
|
27
|
+
entry_type: EntryType;
|
|
28
|
+
summary: string;
|
|
29
|
+
content: string;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
checksum: number;
|
|
32
|
+
prev_checksum: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A search result from mnemoria.
|
|
36
|
+
*/
|
|
37
|
+
interface SearchResult {
|
|
38
|
+
id: string;
|
|
39
|
+
entry: MemoryEntry;
|
|
40
|
+
score: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Statistics about a memory store.
|
|
44
|
+
*/
|
|
45
|
+
interface MemoryStats {
|
|
46
|
+
total_entries: number;
|
|
47
|
+
file_size_bytes: number;
|
|
48
|
+
oldest_timestamp: number | null;
|
|
49
|
+
newest_timestamp: number | null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Options for timeline queries.
|
|
53
|
+
*/
|
|
54
|
+
interface TimelineOptions {
|
|
55
|
+
limit: number;
|
|
56
|
+
since?: number;
|
|
57
|
+
until?: number;
|
|
58
|
+
reverse: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Known opencode agent types. Extensible — any string is accepted.
|
|
62
|
+
*/
|
|
63
|
+
type AgentName = "plan" | "build" | "ask" | "review" | (string & {});
|
|
64
|
+
/**
|
|
65
|
+
* Configuration for the plugin.
|
|
66
|
+
*/
|
|
67
|
+
interface PluginConfig {
|
|
68
|
+
/** Parent directory passed to `mnemoria --path`. The CLI appends `mnemoria/` automatically. Default: ".opencode" */
|
|
69
|
+
memoryDir: string;
|
|
70
|
+
/** Maximum context observations injected into the system prompt. Default: 20 */
|
|
71
|
+
maxContextObservations: number;
|
|
72
|
+
/** Maximum token budget for context injection. Default: 2000 */
|
|
73
|
+
maxContextTokens: number;
|
|
74
|
+
/** Enable debug logging. Default: false */
|
|
75
|
+
debug: boolean;
|
|
76
|
+
}
|
|
77
|
+
declare const DEFAULT_CONFIG: PluginConfig;
|
|
78
|
+
/**
|
|
79
|
+
* Observation stored through the plugin (enriched with plugin-level metadata).
|
|
80
|
+
*/
|
|
81
|
+
interface Observation {
|
|
82
|
+
id: string;
|
|
83
|
+
type: EntryType;
|
|
84
|
+
summary: string;
|
|
85
|
+
content: string;
|
|
86
|
+
timestamp: number;
|
|
87
|
+
/** The tool that produced this observation */
|
|
88
|
+
tool?: string;
|
|
89
|
+
/** The agent that owns this memory */
|
|
90
|
+
agent?: AgentName;
|
|
91
|
+
/** Metadata for chain linking */
|
|
92
|
+
chainId?: string;
|
|
93
|
+
parentId?: string;
|
|
94
|
+
metadata?: ObservationMetadata;
|
|
95
|
+
}
|
|
96
|
+
interface ObservationMetadata {
|
|
97
|
+
callId?: string;
|
|
98
|
+
filePaths?: string[];
|
|
99
|
+
findings?: string[];
|
|
100
|
+
patterns?: string[];
|
|
101
|
+
sessionId?: string;
|
|
102
|
+
userGoal?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* What gets returned from extracting a user's intent.
|
|
106
|
+
*/
|
|
107
|
+
interface UserIntent {
|
|
108
|
+
goal: string;
|
|
109
|
+
context: string[];
|
|
110
|
+
filePaths: string[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Mind — shared hive-mind memory manager.
|
|
115
|
+
*
|
|
116
|
+
* All agents share a single mnemoria store at `.opencode/mnemoria/`. Each
|
|
117
|
+
* memory entry is tagged with the agent that created it via mnemoria's
|
|
118
|
+
* native `--agent` flag, so agents can see each other's memories while
|
|
119
|
+
* still knowing who recorded what.
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
declare class Mind {
|
|
123
|
+
private cli;
|
|
124
|
+
private currentChainId;
|
|
125
|
+
private currentParentId;
|
|
126
|
+
private config;
|
|
127
|
+
private constructor();
|
|
128
|
+
/**
|
|
129
|
+
* Open (or create) the shared hive-mind store.
|
|
130
|
+
*/
|
|
131
|
+
static open(config?: Partial<PluginConfig>): Promise<Mind>;
|
|
132
|
+
/** The current intent chain ID. */
|
|
133
|
+
getCurrentChainId(): string | null;
|
|
134
|
+
/** The path to the memory store. */
|
|
135
|
+
getMemoryPath(): string;
|
|
136
|
+
/**
|
|
137
|
+
* Store a new observation, tagged with the agent that created it.
|
|
138
|
+
*/
|
|
139
|
+
remember(input: {
|
|
140
|
+
type: EntryType;
|
|
141
|
+
summary: string;
|
|
142
|
+
content: string;
|
|
143
|
+
agent: AgentName;
|
|
144
|
+
tool?: string;
|
|
145
|
+
metadata?: ObservationMetadata;
|
|
146
|
+
}): Promise<string>;
|
|
147
|
+
/**
|
|
148
|
+
* Store an observation linked to the current intent chain.
|
|
149
|
+
*/
|
|
150
|
+
rememberWithContext(input: {
|
|
151
|
+
type: EntryType;
|
|
152
|
+
summary: string;
|
|
153
|
+
content: string;
|
|
154
|
+
agent: AgentName;
|
|
155
|
+
tool?: string;
|
|
156
|
+
metadata?: ObservationMetadata;
|
|
157
|
+
}): Promise<string>;
|
|
158
|
+
/**
|
|
159
|
+
* Set the user's intent for this conversation turn.
|
|
160
|
+
* Creates a new chain ID that links subsequent observations.
|
|
161
|
+
*/
|
|
162
|
+
setIntent(message: string, extractedGoal: string, agent: AgentName): Promise<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Search the shared memory. Optionally filter by agent.
|
|
165
|
+
*/
|
|
166
|
+
search(query: string, limit?: number, agent?: AgentName): Promise<SearchResult[]>;
|
|
167
|
+
/**
|
|
168
|
+
* Ask a question against the shared memory. Optionally filter by agent.
|
|
169
|
+
*/
|
|
170
|
+
ask(question: string, agent?: AgentName): Promise<string>;
|
|
171
|
+
/**
|
|
172
|
+
* Get a timeline of memories. Optionally filter by agent.
|
|
173
|
+
*/
|
|
174
|
+
timeline(options?: Partial<TimelineOptions>, agent?: AgentName): Promise<Observation[]>;
|
|
175
|
+
/**
|
|
176
|
+
* Get memory statistics for the shared store.
|
|
177
|
+
*/
|
|
178
|
+
stats(): Promise<MemoryStats>;
|
|
179
|
+
/**
|
|
180
|
+
* Build context for system prompt injection.
|
|
181
|
+
* Returns recent observations capped by token budget.
|
|
182
|
+
*/
|
|
183
|
+
getContext(query?: string): Promise<{
|
|
184
|
+
recentObservations: Observation[];
|
|
185
|
+
relevantMemories: SearchResult[];
|
|
186
|
+
tokenCount: number;
|
|
187
|
+
}>;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get or create the shared Mind instance.
|
|
191
|
+
* All agents share this single instance (and single mnemoria store).
|
|
192
|
+
*/
|
|
193
|
+
declare function getMind(config?: Partial<PluginConfig>): Promise<Mind>;
|
|
194
|
+
/**
|
|
195
|
+
* Reset the shared Mind singleton (for testing).
|
|
196
|
+
*/
|
|
197
|
+
declare function resetMind(): void;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Wrapper around the `mnemoria` CLI binary (v0.3.1+).
|
|
201
|
+
*
|
|
202
|
+
* All interaction with the Rust mnemoria engine goes through this module.
|
|
203
|
+
* Each method shells out to the `mnemoria` binary, parses the output, and
|
|
204
|
+
* returns typed results.
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* MnemoriaCli — stateless wrapper for a single mnemoria store directory.
|
|
209
|
+
*
|
|
210
|
+
* `basePath` is the **parent** directory. The CLI appends `mnemoria/` when
|
|
211
|
+
* the path is a directory, so the actual store lives at `basePath/mnemoria/`.
|
|
212
|
+
*/
|
|
213
|
+
declare class MnemoriaCli {
|
|
214
|
+
readonly basePath: string;
|
|
215
|
+
constructor(basePath: string);
|
|
216
|
+
/** Check whether the mnemoria binary is available on PATH. */
|
|
217
|
+
static isAvailable(): Promise<boolean>;
|
|
218
|
+
/** Path to the actual store directory (basePath/mnemoria/). */
|
|
219
|
+
get storePath(): string;
|
|
220
|
+
/** Whether the store has been initialised. */
|
|
221
|
+
isInitialized(): boolean;
|
|
222
|
+
/** Initialise a new memory store. Idempotent if already initialised. */
|
|
223
|
+
init(): Promise<void>;
|
|
224
|
+
/** Ensure the store exists (init if needed) and return this instance. */
|
|
225
|
+
ensureReady(): Promise<this>;
|
|
226
|
+
/**
|
|
227
|
+
* Add a memory entry. Returns the entry ID.
|
|
228
|
+
*
|
|
229
|
+
* `agent` is required by mnemoria v0.3.1+.
|
|
230
|
+
*/
|
|
231
|
+
add(entryType: EntryType, summary: string, content: string, agent: string): Promise<string>;
|
|
232
|
+
/**
|
|
233
|
+
* Search memories. Returns parsed results.
|
|
234
|
+
*
|
|
235
|
+
* Output format (v0.3.1):
|
|
236
|
+
* Found N results:
|
|
237
|
+
* 1. [type] (agent) summary (score: 0.123)
|
|
238
|
+
*/
|
|
239
|
+
search(query: string, limit?: number, agent?: string): Promise<SearchResult[]>;
|
|
240
|
+
/**
|
|
241
|
+
* Ask a question. Returns the text answer.
|
|
242
|
+
*/
|
|
243
|
+
ask(question: string, agent?: string): Promise<string>;
|
|
244
|
+
/**
|
|
245
|
+
* Get memory statistics.
|
|
246
|
+
*
|
|
247
|
+
* Output format:
|
|
248
|
+
* Memory Statistics:
|
|
249
|
+
* Total entries: 5
|
|
250
|
+
* File size: 450 bytes
|
|
251
|
+
* Oldest entry: 1771178444990
|
|
252
|
+
* Newest entry: 1771178445123
|
|
253
|
+
*/
|
|
254
|
+
stats(): Promise<MemoryStats>;
|
|
255
|
+
/**
|
|
256
|
+
* Get timeline entries.
|
|
257
|
+
*
|
|
258
|
+
* Output format (v0.3.1):
|
|
259
|
+
* Timeline (N entries):
|
|
260
|
+
* 1. [type] (agent) summary - timestamp
|
|
261
|
+
*/
|
|
262
|
+
timeline(options?: Partial<TimelineOptions>, agent?: string): Promise<MemoryEntry[]>;
|
|
263
|
+
/**
|
|
264
|
+
* Export all entries as JSON. Uses a temp file and reads it back.
|
|
265
|
+
* This is the only reliable way to get full entry data with IDs.
|
|
266
|
+
*/
|
|
267
|
+
exportAll(): Promise<MemoryEntry[]>;
|
|
268
|
+
/**
|
|
269
|
+
* Verify the checksum chain integrity.
|
|
270
|
+
*/
|
|
271
|
+
verify(): Promise<boolean>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Utility functions for oc-mnemoria.
|
|
276
|
+
*
|
|
277
|
+
* Extraction, classification, and text helpers used by the plugin hooks.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
/** Generate a random 16-character hex ID. */
|
|
281
|
+
declare function generateId(): string;
|
|
282
|
+
/** Rough token estimate: ~4 chars per token. */
|
|
283
|
+
declare function estimateTokens(text: string): number;
|
|
284
|
+
/** Truncate text to fit within a token budget. */
|
|
285
|
+
declare function truncateToTokens(text: string, maxTokens: number): string;
|
|
286
|
+
interface ExtractedInfo {
|
|
287
|
+
summary: string;
|
|
288
|
+
content: string;
|
|
289
|
+
filePaths: string[];
|
|
290
|
+
findings: string[];
|
|
291
|
+
patterns: string[];
|
|
292
|
+
}
|
|
293
|
+
/** Extract key information from tool output based on the tool name. */
|
|
294
|
+
declare function extractKeyInfo(toolName: string, output: string, args?: Record<string, unknown>): ExtractedInfo;
|
|
295
|
+
/** Classify a tool's output into an observation type. */
|
|
296
|
+
declare function classifyObservationType(toolName: string, output: string): EntryType;
|
|
297
|
+
/** Extract the user's intent from their message. */
|
|
298
|
+
declare function extractUserIntent(message: string): UserIntent;
|
|
299
|
+
|
|
300
|
+
export { type AgentName, DEFAULT_CONFIG, type EntryType, type MemoryEntry, type MemoryStats, Mind, MnemoriaCli, type Observation, type ObservationMetadata, OcMnemoria, type PluginConfig, type SearchResult, type TimelineOptions, type UserIntent, classifyObservationType, OcMnemoria as default, estimateTokens, extractKeyInfo, extractUserIntent, generateId, getMind, resetMind, truncateToTokens };
|