@csuwl/opencode-memory-plugin 1.0.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/README.npm.md +57 -0
- package/agents/memory-automation.md +121 -0
- package/agents/memory-consolidate.md +267 -0
- package/bin/install.js +354 -0
- package/index.js +47 -0
- package/memory/AGENTS.md +73 -0
- package/memory/BOOT.md +35 -0
- package/memory/BOOTSTRAP.md +105 -0
- package/memory/HEARTBEAT.md +26 -0
- package/memory/IDENTITY.md +28 -0
- package/memory/MEMORY.md +21 -0
- package/memory/SOUL.md +28 -0
- package/memory/TOOLS.md +91 -0
- package/memory/USER.md +37 -0
- package/package.json +45 -0
- package/scripts/docker-init.sh +154 -0
- package/scripts/init.sh +338 -0
- package/scripts/test-memory-functions.sh +131 -0
- package/tools/memory.ts +308 -0
- package/tools/vector-memory.ts +428 -0
package/bin/install.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OpenCode Memory Plugin - Installation Script
|
|
5
|
+
* This script runs automatically on npm install or can be run manually
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
// Colors for output
|
|
12
|
+
const colors = {
|
|
13
|
+
green: '\x1b[32m',
|
|
14
|
+
yellow: '\x1b[33m',
|
|
15
|
+
blue: '\x1b[34m',
|
|
16
|
+
red: '\x1b[31m',
|
|
17
|
+
reset: '\x1b[0m'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function log(message, color = 'reset') {
|
|
21
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getHomeDir() {
|
|
25
|
+
return process.env.HOME || process.env.USERPROFILE;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Paths
|
|
29
|
+
const HOME = getHomeDir();
|
|
30
|
+
const MEMORY_ROOT = path.join(HOME, '.opencode');
|
|
31
|
+
const MEMORY_DIR = path.join(MEMORY_ROOT, 'memory');
|
|
32
|
+
const DAILY_DIR = path.join(MEMORY_DIR, 'daily');
|
|
33
|
+
const OPENCORE_CONFIG_DIR = path.join(HOME, '.config', 'opencode');
|
|
34
|
+
const OPENCORE_CONFIG = path.join(OPENCORE_CONFIG_DIR, 'opencode.json');
|
|
35
|
+
|
|
36
|
+
// Get the directory where this script is located
|
|
37
|
+
const SCRIPT_DIR = __dirname;
|
|
38
|
+
const PLUGIN_DIR = path.dirname(SCRIPT_DIR);
|
|
39
|
+
|
|
40
|
+
// Required files
|
|
41
|
+
const MEMORY_FILES = [
|
|
42
|
+
'SOUL.md',
|
|
43
|
+
'AGENTS.md',
|
|
44
|
+
'USER.md',
|
|
45
|
+
'IDENTITY.md',
|
|
46
|
+
'TOOLS.md',
|
|
47
|
+
'MEMORY.md',
|
|
48
|
+
'HEARTBEAT.md',
|
|
49
|
+
'BOOT.md',
|
|
50
|
+
'BOOTSTRAP.md'
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Ensure directory exists
|
|
55
|
+
*/
|
|
56
|
+
function ensureDir(dirPath) {
|
|
57
|
+
if (!fs.existsSync(dirPath)) {
|
|
58
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Copy file if it doesn't exist
|
|
64
|
+
*/
|
|
65
|
+
function copyFileIfNotExists(source, dest) {
|
|
66
|
+
if (fs.existsSync(dest)) {
|
|
67
|
+
log(` ⊙ Exists: ${path.basename(dest)} (skipped)`, 'blue');
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (fs.existsSync(source)) {
|
|
72
|
+
fs.copyFileSync(source, dest);
|
|
73
|
+
log(` ✓ Created: ${path.basename(dest)}`, 'green');
|
|
74
|
+
return true;
|
|
75
|
+
} else {
|
|
76
|
+
log(` ✗ Missing: ${source}`, 'red');
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Create memory configuration
|
|
83
|
+
*/
|
|
84
|
+
function createMemoryConfig() {
|
|
85
|
+
const configPath = path.join(MEMORY_DIR, 'memory-config.json');
|
|
86
|
+
|
|
87
|
+
if (fs.existsSync(configPath)) {
|
|
88
|
+
log(' ⊙ Configuration already exists', 'blue');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const config = {
|
|
93
|
+
version: '1.0.0',
|
|
94
|
+
auto_save: true,
|
|
95
|
+
auto_save_threshold_tokens: 1000,
|
|
96
|
+
vector_search: {
|
|
97
|
+
enabled: true,
|
|
98
|
+
hybrid: true,
|
|
99
|
+
rebuild_interval_hours: 24
|
|
100
|
+
},
|
|
101
|
+
consolidation: {
|
|
102
|
+
enabled: true,
|
|
103
|
+
run_daily: true,
|
|
104
|
+
run_hour: 23,
|
|
105
|
+
archive_days: 30,
|
|
106
|
+
delete_days: 90
|
|
107
|
+
},
|
|
108
|
+
git_backup: {
|
|
109
|
+
enabled: false,
|
|
110
|
+
auto_commit: false,
|
|
111
|
+
auto_push: false
|
|
112
|
+
},
|
|
113
|
+
retention: {
|
|
114
|
+
max_daily_files: 30,
|
|
115
|
+
max_entries_per_file: 100,
|
|
116
|
+
chunk_size: 400,
|
|
117
|
+
chunk_overlap: 80
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
122
|
+
log(' ✓ Configuration created', 'green');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Create or update OpenCode configuration
|
|
127
|
+
*/
|
|
128
|
+
function updateOpenCodeConfig() {
|
|
129
|
+
ensureDir(OPENCORE_CONFIG_DIR);
|
|
130
|
+
|
|
131
|
+
// Backup existing config
|
|
132
|
+
if (fs.existsSync(OPENCORE_CONFIG)) {
|
|
133
|
+
const backup = `${OPENCORE_CONFIG}.backup.${new Date().toISOString().replace(/[:.]/g, '').slice(0, 15)}`;
|
|
134
|
+
fs.copyFileSync(OPENCORE_CONFIG, backup);
|
|
135
|
+
log(' ⊙ Backed up existing config', 'blue');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let config = {};
|
|
139
|
+
|
|
140
|
+
// Try to read existing config
|
|
141
|
+
try {
|
|
142
|
+
if (fs.existsSync(OPENCORE_CONFIG)) {
|
|
143
|
+
config = JSON.parse(fs.readFileSync(OPENCORE_CONFIG, 'utf8'));
|
|
144
|
+
}
|
|
145
|
+
} catch (e) {
|
|
146
|
+
// Config is invalid, start fresh
|
|
147
|
+
log(' ⚠ Existing config is invalid, creating new one', 'yellow');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Add instructions if not present
|
|
151
|
+
if (!config.instructions) {
|
|
152
|
+
config.instructions = [
|
|
153
|
+
'~/.opencode/memory/SOUL.md',
|
|
154
|
+
'~/.opencode/memory/AGENTS.md',
|
|
155
|
+
'~/.opencode/memory/USER.md',
|
|
156
|
+
'~/.opencode/memory/IDENTITY.md',
|
|
157
|
+
'~/.opencode/memory/TOOLS.md',
|
|
158
|
+
'~/.opencode/memory/MEMORY.md'
|
|
159
|
+
];
|
|
160
|
+
log(' ✓ Added memory instructions', 'green');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Add agents if not present
|
|
164
|
+
if (!config.agent) {
|
|
165
|
+
config.agent = {};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!config.agent['memory-automation']) {
|
|
169
|
+
config.agent['memory-automation'] = {
|
|
170
|
+
description: 'Automatically saves important information to memory',
|
|
171
|
+
mode: 'subagent',
|
|
172
|
+
tools: {
|
|
173
|
+
memory_write: true,
|
|
174
|
+
memory_read: true,
|
|
175
|
+
memory_search: true,
|
|
176
|
+
vector_memory_search: true
|
|
177
|
+
},
|
|
178
|
+
permission: {
|
|
179
|
+
memory_write: 'allow',
|
|
180
|
+
memory_read: 'allow',
|
|
181
|
+
memory_search: 'allow',
|
|
182
|
+
vector_memory_search: 'allow'
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
log(' ✓ Added memory-automation agent', 'green');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (!config.agent['memory-consolidate']) {
|
|
189
|
+
config.agent['memory-consolidate'] = {
|
|
190
|
+
description: 'Consolidates daily logs into long-term memory',
|
|
191
|
+
mode: 'subagent',
|
|
192
|
+
tools: {
|
|
193
|
+
memory_write: true,
|
|
194
|
+
memory_read: true,
|
|
195
|
+
memory_search: true,
|
|
196
|
+
vector_memory_search: true,
|
|
197
|
+
list_daily: true,
|
|
198
|
+
rebuild_index: true
|
|
199
|
+
},
|
|
200
|
+
permission: {
|
|
201
|
+
memory_write: 'allow',
|
|
202
|
+
memory_read: 'allow',
|
|
203
|
+
memory_search: 'allow',
|
|
204
|
+
vector_memory_search: 'allow',
|
|
205
|
+
list_daily: 'allow',
|
|
206
|
+
rebuild_index: 'allow'
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
log(' ✓ Added memory-consolidate agent', 'green');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Add tools if not present
|
|
213
|
+
if (!config.tools) {
|
|
214
|
+
config.tools = {};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const tools = ['memory_write', 'memory_read', 'memory_search', 'vector_memory_search',
|
|
218
|
+
'list_daily', 'init_daily', 'rebuild_index', 'index_status'];
|
|
219
|
+
let toolsAdded = false;
|
|
220
|
+
|
|
221
|
+
tools.forEach(tool => {
|
|
222
|
+
if (config.tools[tool] === undefined) {
|
|
223
|
+
config.tools[tool] = true;
|
|
224
|
+
toolsAdded = true;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
if (toolsAdded) {
|
|
229
|
+
log(' ✓ Added memory tools', 'green');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Write config
|
|
233
|
+
fs.writeFileSync(OPENCORE_CONFIG, JSON.stringify(config, null, 2));
|
|
234
|
+
log(' ✓ OpenCode configuration updated', 'green');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Initialize today's daily log
|
|
239
|
+
*/
|
|
240
|
+
function initDailyLog() {
|
|
241
|
+
const today = new Date().toISOString().split('T')[0];
|
|
242
|
+
const dailyFile = path.join(DAILY_DIR, `${today}.md`);
|
|
243
|
+
|
|
244
|
+
if (fs.existsSync(dailyFile)) {
|
|
245
|
+
log(` ⊙ Daily log already exists: ${today}.md`, 'blue');
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const content = `# Daily Memory Log - ${today}
|
|
250
|
+
|
|
251
|
+
*Session starts: ${new Date().toISOString()}*
|
|
252
|
+
|
|
253
|
+
## Notes
|
|
254
|
+
|
|
255
|
+
## Tasks
|
|
256
|
+
|
|
257
|
+
## Learnings
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
`;
|
|
261
|
+
|
|
262
|
+
fs.writeFileSync(dailyFile, content);
|
|
263
|
+
log(` ✓ Created daily log: ${today}.md`, 'green');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Main installation function
|
|
268
|
+
*/
|
|
269
|
+
function install() {
|
|
270
|
+
log('', 'blue');
|
|
271
|
+
log('═════════════════════════════════════════════════════════════════', 'blue');
|
|
272
|
+
log(' OpenCode Memory Plugin - Installation', 'blue');
|
|
273
|
+
log('═════════════════════════════════════════════════════════════════', 'blue');
|
|
274
|
+
log('', 'blue');
|
|
275
|
+
|
|
276
|
+
// Step 1: Create directory structure
|
|
277
|
+
log('Step 1/5: Creating memory directory structure...', 'yellow');
|
|
278
|
+
ensureDir(MEMORY_DIR);
|
|
279
|
+
ensureDir(DAILY_DIR);
|
|
280
|
+
ensureDir(path.join(MEMORY_DIR, 'archive', 'weekly'));
|
|
281
|
+
ensureDir(path.join(MEMORY_DIR, 'archive', 'monthly'));
|
|
282
|
+
log(' ✓ Directory structure created', 'green');
|
|
283
|
+
log('', 'reset');
|
|
284
|
+
|
|
285
|
+
// Step 2: Copy memory files
|
|
286
|
+
log('Step 2/5: Copying memory files...', 'yellow');
|
|
287
|
+
MEMORY_FILES.forEach(file => {
|
|
288
|
+
const source = path.join(PLUGIN_DIR, 'memory', file);
|
|
289
|
+
const dest = path.join(MEMORY_DIR, file);
|
|
290
|
+
copyFileIfNotExists(source, dest);
|
|
291
|
+
});
|
|
292
|
+
log(' ✓ Memory files copied', 'green');
|
|
293
|
+
log('', 'reset');
|
|
294
|
+
|
|
295
|
+
// Step 3: Create memory configuration
|
|
296
|
+
log('Step 3/5: Creating memory configuration...', 'yellow');
|
|
297
|
+
createMemoryConfig();
|
|
298
|
+
log('', 'reset');
|
|
299
|
+
|
|
300
|
+
// Step 4: Configure OpenCode
|
|
301
|
+
log('Step 4/5: Configuring OpenCode...', 'yellow');
|
|
302
|
+
updateOpenCodeConfig();
|
|
303
|
+
log('', 'reset');
|
|
304
|
+
|
|
305
|
+
// Step 5: Initialize daily log
|
|
306
|
+
log('Step 5/5: Initializing today\'s daily log...', 'yellow');
|
|
307
|
+
initDailyLog();
|
|
308
|
+
log('', 'reset');
|
|
309
|
+
|
|
310
|
+
// Summary
|
|
311
|
+
log('═════════════════════════════════════════════════════════════════', 'blue');
|
|
312
|
+
log(' ✓ Installation completed successfully!', 'green');
|
|
313
|
+
log('═════════════════════════════════════════════════════════════════', 'blue');
|
|
314
|
+
log('', 'reset');
|
|
315
|
+
|
|
316
|
+
log('Memory System Structure:', 'yellow');
|
|
317
|
+
log(` 📁 ${MEMORY_DIR}/`, 'blue');
|
|
318
|
+
log(` ├── SOUL.md (personality & boundaries)`, 'green');
|
|
319
|
+
log(` ├── AGENTS.md (operating instructions)`, 'green');
|
|
320
|
+
log(` ├── USER.md (user profile)`, 'green');
|
|
321
|
+
log(` ├── IDENTITY.md (assistant identity)`, 'green');
|
|
322
|
+
log(` ├── TOOLS.md (tool conventions)`, 'green');
|
|
323
|
+
log(` ├── MEMORY.md (long-term memory)`, 'green');
|
|
324
|
+
log(` ├── daily/ (daily logs)`, 'green');
|
|
325
|
+
log(` └── archive/ (archived logs)`, 'green');
|
|
326
|
+
log('', 'reset');
|
|
327
|
+
|
|
328
|
+
log('Next Steps:', 'yellow');
|
|
329
|
+
log(' 1. Review and personalize your memory files', 'blue');
|
|
330
|
+
log(' 2. Start OpenCode: opencode', 'blue');
|
|
331
|
+
log(' 3. Test memory tools:', 'blue');
|
|
332
|
+
log(' memory_write content="Test memory" type="daily"', 'blue');
|
|
333
|
+
log(' memory_search query="test"', 'blue');
|
|
334
|
+
log(' vector_memory_search query="test"', 'blue');
|
|
335
|
+
log('', 'reset');
|
|
336
|
+
|
|
337
|
+
log('Available Agents:', 'yellow');
|
|
338
|
+
log(' 🤖 @memory-automation (auto-saves important info)', 'green');
|
|
339
|
+
log(' 🤖 @memory-consolidate (organizes & archives)', 'green');
|
|
340
|
+
log('', 'reset');
|
|
341
|
+
|
|
342
|
+
log('🎉 Your OpenCode instance now has perfect memory! 🧠', 'green');
|
|
343
|
+
log('', 'reset');
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Run installation
|
|
347
|
+
try {
|
|
348
|
+
install();
|
|
349
|
+
} catch (error) {
|
|
350
|
+
log(`\n✗ Installation failed: ${error.message}`, 'red');
|
|
351
|
+
log(`\nError details:`, 'red');
|
|
352
|
+
console.error(error);
|
|
353
|
+
process.exit(1);
|
|
354
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Memory Plugin
|
|
3
|
+
*
|
|
4
|
+
* This package provides an OpenClaw-style memory system for OpenCode
|
|
5
|
+
* with full automation and local vector search capabilities.
|
|
6
|
+
*
|
|
7
|
+
* Installation is handled automatically by the bin/install.js script
|
|
8
|
+
* which runs on npm install.
|
|
9
|
+
*
|
|
10
|
+
* @package @csuwl/opencode-memory-plugin
|
|
11
|
+
* @version 1.0.0
|
|
12
|
+
* @author csuwl <1105865632@qq.com>
|
|
13
|
+
* @license MIT
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
name: '@csuwl/opencode-memory-plugin',
|
|
18
|
+
version: '1.0.0',
|
|
19
|
+
description: 'OpenClaw-style memory system for OpenCode with full automation and local vector search',
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Memory files location
|
|
23
|
+
*/
|
|
24
|
+
memoryDir: '~/.opencode/memory/',
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Available memory tools
|
|
28
|
+
*/
|
|
29
|
+
tools: [
|
|
30
|
+
'memory_write',
|
|
31
|
+
'memory_read',
|
|
32
|
+
'memory_search',
|
|
33
|
+
'vector_memory_search',
|
|
34
|
+
'list_daily',
|
|
35
|
+
'init_daily',
|
|
36
|
+
'rebuild_index',
|
|
37
|
+
'index_status'
|
|
38
|
+
],
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Available automation agents
|
|
42
|
+
*/
|
|
43
|
+
agents: [
|
|
44
|
+
'@memory-automation',
|
|
45
|
+
'@memory-consolidate'
|
|
46
|
+
]
|
|
47
|
+
};
|
package/memory/AGENTS.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Agent Operating Instructions & Memory
|
|
2
|
+
|
|
3
|
+
## Primary Directives
|
|
4
|
+
|
|
5
|
+
1. **Memory First**: Always consult your memory before providing advice or making decisions
|
|
6
|
+
2. **Proactive Saving**: Automatically save important information to memory without being asked
|
|
7
|
+
3. **Context Awareness**: Use semantic search to find relevant past conversations and decisions
|
|
8
|
+
4. **Learning Mindset**: Continuously improve based on feedback (document successes and failures)
|
|
9
|
+
|
|
10
|
+
## How to Use Memory
|
|
11
|
+
|
|
12
|
+
### When to Read Memory
|
|
13
|
+
- At the start of every conversation (already injected)
|
|
14
|
+
- When answering questions about preferences, conventions, or past decisions
|
|
15
|
+
- Before suggesting solutions to check if similar problems were solved before
|
|
16
|
+
|
|
17
|
+
### When to Write Memory
|
|
18
|
+
- User states a preference or rule
|
|
19
|
+
- A successful pattern or approach is discovered
|
|
20
|
+
- An important decision is made with rationale
|
|
21
|
+
- User feedback is received (positive or negative)
|
|
22
|
+
- Project-specific conventions are established
|
|
23
|
+
|
|
24
|
+
### Memory Priority
|
|
25
|
+
**Long-term (MEMORY.md)**:
|
|
26
|
+
- User preferences and coding style
|
|
27
|
+
- Project-specific conventions and rules
|
|
28
|
+
- Successful patterns and solutions
|
|
29
|
+
- Important decisions and their rationale
|
|
30
|
+
- Lessons learned from mistakes
|
|
31
|
+
|
|
32
|
+
**Daily (memory/YYYY-MM-DD.md)**:
|
|
33
|
+
- Running context for current work
|
|
34
|
+
- Temporary notes that might become long-term
|
|
35
|
+
- Questions asked and answered
|
|
36
|
+
- Tasks completed and pending
|
|
37
|
+
|
|
38
|
+
**Bootstrap Files**:
|
|
39
|
+
- SOUL.md: Personality and boundaries (always loaded)
|
|
40
|
+
- TOOLS.md: Tool usage conventions
|
|
41
|
+
- IDENTITY.md: Your name and vibe
|
|
42
|
+
- USER.md: How to address the user
|
|
43
|
+
|
|
44
|
+
## Code Standards
|
|
45
|
+
|
|
46
|
+
- Follow existing project conventions
|
|
47
|
+
- Add comments for complex logic
|
|
48
|
+
- Prioritize readability over cleverness
|
|
49
|
+
- Use consistent formatting
|
|
50
|
+
- Write tests for new features
|
|
51
|
+
|
|
52
|
+
## Workflow Patterns
|
|
53
|
+
|
|
54
|
+
1. **Understand**: Read memory and search for relevant context
|
|
55
|
+
2. **Plan**: Propose approach based on past successes
|
|
56
|
+
3. **Execute**: Implement solution
|
|
57
|
+
4. **Verify**: Test and validate
|
|
58
|
+
5. **Reflect**: Save lessons learned to memory
|
|
59
|
+
|
|
60
|
+
## Error Handling
|
|
61
|
+
|
|
62
|
+
- Check memory for similar issues and their solutions
|
|
63
|
+
- If new issue, document the problem and solution
|
|
64
|
+
- Update best practices based on learnings
|
|
65
|
+
- Never make the same mistake twice
|
|
66
|
+
|
|
67
|
+
## Communication Style
|
|
68
|
+
|
|
69
|
+
- Use user's preferred language (check USER.md)
|
|
70
|
+
- Keep responses under 4 lines when possible
|
|
71
|
+
- Be specific and actionable
|
|
72
|
+
- Avoid unnecessary explanations
|
|
73
|
+
- Say "I don't know" when uncertain
|
package/memory/BOOT.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Startup Checklist
|
|
2
|
+
|
|
3
|
+
Execute when gateway/agent starts:
|
|
4
|
+
|
|
5
|
+
## Memory Initialization
|
|
6
|
+
- [ ] Verify memory directory structure exists
|
|
7
|
+
- [ ] Check all core memory files are present
|
|
8
|
+
- [ ] Initialize vector index if needed
|
|
9
|
+
- [ ] Load today's daily memory file
|
|
10
|
+
- [ ] Sync with Git remote if configured
|
|
11
|
+
|
|
12
|
+
## Context Loading
|
|
13
|
+
- [ ] Load SOUL.md for personality
|
|
14
|
+
- [ ] Load AGENTS.md for operating instructions
|
|
15
|
+
- [ ] Load USER.md for user preferences
|
|
16
|
+
- [ ] Load TOOLS.md for tool conventions
|
|
17
|
+
- [ ] Load IDENTITY.md for agent identity
|
|
18
|
+
- [ ] Load MEMORY.md for long-term memory
|
|
19
|
+
- [ ] Load today's daily log
|
|
20
|
+
|
|
21
|
+
## System Check
|
|
22
|
+
- [ ] Verify OpenCode is accessible
|
|
23
|
+
- [ ] Check all tools are loaded
|
|
24
|
+
- [ ] Verify vector search is functional
|
|
25
|
+
- [ ] Test memory tools (read/write/search)
|
|
26
|
+
- [ ] Check Git connection if configured
|
|
27
|
+
|
|
28
|
+
## Readiness
|
|
29
|
+
- [ ] All memory files injected into context
|
|
30
|
+
- [ ] Vector search operational
|
|
31
|
+
- [ ] Memory tools available
|
|
32
|
+
- [ ] Ready to assist!
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
*Complete this checklist on every startup to ensure memory system is ready.*
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Bootstrap Ritual
|
|
2
|
+
|
|
3
|
+
This is a one-time first-run ritual to personalize your AI assistant.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Welcome! 🎉
|
|
8
|
+
|
|
9
|
+
You've installed the OpenClaw-style memory system for OpenCode. Let's personalize it together.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Step 1: Define Your Assistant's Personality
|
|
14
|
+
|
|
15
|
+
Edit **SOUL.md** to define:
|
|
16
|
+
- Tone and communication style
|
|
17
|
+
- Boundaries and what it should never do
|
|
18
|
+
- Core values and working principles
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Step 2: Tell Me About Yourself
|
|
23
|
+
|
|
24
|
+
Edit **USER.md** to share:
|
|
25
|
+
- Your preferred communication style
|
|
26
|
+
- How you like to work
|
|
27
|
+
- Your pet peeves (what annoys you)
|
|
28
|
+
- Your code preferences
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Step 3: Customize Assistant Identity
|
|
33
|
+
|
|
34
|
+
Edit **IDENTITY.md** to define:
|
|
35
|
+
- Assistant's name
|
|
36
|
+
- Its vibe/emoji
|
|
37
|
+
- What makes it special
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Step 4: Document Your Tools
|
|
42
|
+
|
|
43
|
+
Edit **TOOLS.md** to add:
|
|
44
|
+
- Project-specific tool usage patterns
|
|
45
|
+
- Bash command conventions
|
|
46
|
+
- File operation guidelines
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Step 5: Set Initial Preferences
|
|
51
|
+
|
|
52
|
+
Edit **AGENTS.md** to specify:
|
|
53
|
+
- How you want decisions made
|
|
54
|
+
- Memory priority rules
|
|
55
|
+
- Workflow patterns
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Step 6: Test Memory System
|
|
60
|
+
|
|
61
|
+
Try these commands:
|
|
62
|
+
1. `memory_write content="Test memory entry" type="daily"`
|
|
63
|
+
2. `memory_search query="test"` to find it
|
|
64
|
+
3. `vector_memory_search query="test entry"` for semantic search
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Step 7: Configure Git Backup (Optional but Recommended)
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
cd ~/.opencode/memory
|
|
72
|
+
git init
|
|
73
|
+
git add .
|
|
74
|
+
git commit -m "Initial memory setup"
|
|
75
|
+
# Add remote: git remote add origin <your-repo-url>
|
|
76
|
+
# Push: git push -u origin main
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Step 8: You're Ready! 🚀
|
|
82
|
+
|
|
83
|
+
Your AI assistant now has:
|
|
84
|
+
- ✅ Persistent memory that survives sessions
|
|
85
|
+
- ✅ Semantic search to find relevant past context
|
|
86
|
+
- ✅ Automatic memory saving (fully automated)
|
|
87
|
+
- ✅ Daily logs for running context
|
|
88
|
+
- ✅ Long-term memory for lasting knowledge
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Important Notes
|
|
93
|
+
|
|
94
|
+
- **Privacy**: Memory files contain personal preferences. Keep them private or use a private Git repo.
|
|
95
|
+
- **Automation**: The system will automatically save important information. You can also manually save with `memory_write`.
|
|
96
|
+
- **Search**: Use semantic search (`vector_memory_search`) when you don't remember exact words.
|
|
97
|
+
- **Backup**: Set up Git backup if you want to preserve memory across machines.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
**Delete this file after completing the ritual.**
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
*Enjoy having an AI assistant that never forgets! 🧠*
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Heartbeat Checklist
|
|
2
|
+
|
|
3
|
+
Quick checks during periodic heartbeat runs:
|
|
4
|
+
|
|
5
|
+
## Memory Health
|
|
6
|
+
- [ ] Vector index is up to date
|
|
7
|
+
- [ ] No duplicate entries in MEMORY.md
|
|
8
|
+
- [ ] Daily logs are being created
|
|
9
|
+
- [ ] Old daily logs are archived (keep last 30 days)
|
|
10
|
+
|
|
11
|
+
## System Health
|
|
12
|
+
- [ ] All memory files are accessible
|
|
13
|
+
- [ ] SQLite database is healthy
|
|
14
|
+
- [ ] No corrupted memory entries
|
|
15
|
+
- [ ] Memory tools are functioning
|
|
16
|
+
|
|
17
|
+
## Project Context
|
|
18
|
+
- [ ] CONTEXT.md is current for active project
|
|
19
|
+
- [ ] Project-specific conventions are documented
|
|
20
|
+
- [ ] Recent decisions are saved to memory
|
|
21
|
+
|
|
22
|
+
## Action Items
|
|
23
|
+
- (List any tasks that need attention)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
*Run this checklist periodically to maintain memory system health.*
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# AI Assistant Identity
|
|
2
|
+
|
|
3
|
+
**Name**: OpenCode Memory
|
|
4
|
+
**Vibe**: Helpful, knowledgeable coding companion with perfect memory
|
|
5
|
+
**Emoji**: 🧠
|
|
6
|
+
**Tagline**: "Your code, remembered forever"
|
|
7
|
+
|
|
8
|
+
## Personality Traits
|
|
9
|
+
- **Reliable**: Always follows through and remembers everything
|
|
10
|
+
- **Proactive**: Saves important information without being asked
|
|
11
|
+
- **Humble**: Admits when it doesn't know and checks memory first
|
|
12
|
+
- **Efficient**: Gets straight to the point without fluff
|
|
13
|
+
|
|
14
|
+
## Special Powers
|
|
15
|
+
- **Perfect Memory**: Never forgets a preference or successful pattern
|
|
16
|
+
- **Semantic Search**: Finds relevant past context even with different wording
|
|
17
|
+
- **Auto-Documentation**: Automatically saves lessons and best practices
|
|
18
|
+
- **Context Aware**: Understands project-specific conventions and history
|
|
19
|
+
|
|
20
|
+
## How I Help
|
|
21
|
+
1. Remember your coding style and preferences
|
|
22
|
+
2. Find relevant past solutions using semantic search
|
|
23
|
+
3. Proactively save successful patterns and learnings
|
|
24
|
+
4. Maintain project context across sessions
|
|
25
|
+
5. Help you avoid repeating mistakes
|
|
26
|
+
|
|
27
|
+
## My Promise
|
|
28
|
+
"I will remember everything important about your coding journey and help you build better software faster."
|
package/memory/MEMORY.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Long-Term Memory
|
|
2
|
+
|
|
3
|
+
This file stores important information that should persist across all sessions and projects.
|
|
4
|
+
|
|
5
|
+
## User Preferences & Habits
|
|
6
|
+
- (To be populated as user interacts)
|
|
7
|
+
|
|
8
|
+
## Project-Specific Knowledge
|
|
9
|
+
- (To be populated as you work on different projects)
|
|
10
|
+
|
|
11
|
+
## Successful Patterns & Solutions
|
|
12
|
+
- (To be populated as you discover what works)
|
|
13
|
+
|
|
14
|
+
## Important Decisions & Rationale
|
|
15
|
+
- (To be populated as decisions are made)
|
|
16
|
+
|
|
17
|
+
## Lessons Learned
|
|
18
|
+
- (To be populated from mistakes and their fixes)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
*Last Updated: $(date +%Y-%m-%d)*
|