@bunkercache/opencode-memoir 0.2.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/LICENSE +21 -0
- package/README.md +156 -0
- package/dist/index.js +14689 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 zenobi.us
|
|
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,156 @@
|
|
|
1
|
+
# @bunkercache/opencode-memoir
|
|
2
|
+
|
|
3
|
+
A local-first, repo-scoped memory plugin for OpenCode. Provides persistent project learnings and hierarchical session history with "blockchain-style" compaction.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Project Memory** - Store preferences, patterns, gotchas, and facts about your codebase
|
|
8
|
+
- **Session History** - Hierarchical chunk tree for traversing compacted conversation history
|
|
9
|
+
- **Full-Text Search** - SQLite FTS5 with BM25 ranking
|
|
10
|
+
- **Keyword Detection** - Auto-save when you say "remember", "don't forget", etc.
|
|
11
|
+
- **Vector Search Ready** - Schema supports sqlite-vec for future semantic search
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun add @bunkercache/opencode-memoir
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Add to your OpenCode config (`~/.config/opencode/config.json`):
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"plugins": ["@bunkercache/opencode-memoir"]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Tools
|
|
28
|
+
|
|
29
|
+
The plugin provides three tools for the LLM:
|
|
30
|
+
|
|
31
|
+
### `memoir`
|
|
32
|
+
|
|
33
|
+
Add, search, list, or forget project memories.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
memoir add "Always run tests before committing" --type preference
|
|
37
|
+
memoir search "testing patterns"
|
|
38
|
+
memoir list --limit 10
|
|
39
|
+
memoir forget mem_abc123
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### `memoir_expand`
|
|
43
|
+
|
|
44
|
+
Expand a compacted chunk to see full details.
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
memoir_expand ch_abc123
|
|
48
|
+
memoir_expand ch_abc123 --include-children
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `memoir_history`
|
|
52
|
+
|
|
53
|
+
Search session history chunks.
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
memoir_history "auth bug fix"
|
|
57
|
+
memoir_history "rate limiting" --session abc123
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Memory Types
|
|
61
|
+
|
|
62
|
+
| Type | Description | Example |
|
|
63
|
+
| ------------ | ----------------------------------- | ---------------------------------------- |
|
|
64
|
+
| `preference` | User/project preferences | "Always run tests after changes" |
|
|
65
|
+
| `pattern` | Coding patterns used in the project | "We use Result<T, E> for error handling" |
|
|
66
|
+
| `gotcha` | Known issues or things to avoid | "Don't use lodash, we have utilities" |
|
|
67
|
+
| `fact` | General facts about the project | "API is at /api/v2" |
|
|
68
|
+
| `learned` | Auto-detected patterns | "User prefers TypeScript strict mode" |
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
Create `~/.config/opencode/memoir.json` (global) or `<repo>/.opencode/memoir.json` (local):
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"$schema": "https://bunkercache.github.io/opencode-memoir/schema/config.json",
|
|
77
|
+
"memory": {
|
|
78
|
+
"maxInject": 10,
|
|
79
|
+
"maxSearchResults": 20,
|
|
80
|
+
"keywordDetection": true,
|
|
81
|
+
"customKeywords": ["note to self"]
|
|
82
|
+
},
|
|
83
|
+
"storage": {
|
|
84
|
+
"forceLocal": true
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
See [schema/config.schema.json](schema/config.schema.json) for all options.
|
|
90
|
+
|
|
91
|
+
## How It Works
|
|
92
|
+
|
|
93
|
+
### Context Injection
|
|
94
|
+
|
|
95
|
+
On the first message of each session, Memoir searches for relevant memories and injects them into the context.
|
|
96
|
+
|
|
97
|
+
### Keyword Detection
|
|
98
|
+
|
|
99
|
+
When you say things like "remember this" or "don't forget", Memoir nudges the LLM to save the information.
|
|
100
|
+
|
|
101
|
+
### Chunk Compaction
|
|
102
|
+
|
|
103
|
+
When OpenCode compacts a session, Memoir creates summary chunks that reference the original chunks. Use `memoir_expand` to drill down into details.
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
Session: abc123
|
|
107
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
108
|
+
│ Summary Chunk (ch_003) │
|
|
109
|
+
│ "Fixed auth bug [ch_001], added rate limiting [ch_002]" │
|
|
110
|
+
│ │ │
|
|
111
|
+
│ ├── ch_001: Full auth fix details │
|
|
112
|
+
│ └── ch_002: Full rate limiting details │
|
|
113
|
+
└─────────────────────────────────────────────────────────────┘
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Install dependencies
|
|
120
|
+
bun install
|
|
121
|
+
|
|
122
|
+
# Run tests
|
|
123
|
+
mise run test
|
|
124
|
+
|
|
125
|
+
# Build
|
|
126
|
+
mise run build
|
|
127
|
+
|
|
128
|
+
# Lint
|
|
129
|
+
mise run lint
|
|
130
|
+
mise run lint:fix
|
|
131
|
+
|
|
132
|
+
# Format
|
|
133
|
+
mise run format
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Storage Locations
|
|
137
|
+
|
|
138
|
+
**Local install** (when `.opencode/opencode.json` exists):
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
<repo>/.opencode/memoir/memory.db
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Global install**:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
~/.local/share/opencode/project/<project-id>/memoir/memory.db
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Contributing
|
|
151
|
+
|
|
152
|
+
Contributions welcome! Please read [STYLEGUIDE.md](STYLEGUIDE.md) before submitting PRs.
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
MIT License. See [LICENSE](LICENSE) for details.
|