brain-memory 0.1.0-beta.20 → 0.1.0-beta.23
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 +15 -17
- package/bin/install.js +9 -11
- package/bin/memorize.js +4 -1
- package/bin/recall.js +1 -1
- package/bin/skill.js +1 -1
- package/commands/brain/forget.md +240 -15
- package/commands/brain/pin.md +53 -11
- package/commands/brain/remember.md +1 -1
- package/commands/brain/sleep.md +1 -1
- package/commands/brain/status.md +5 -5
- package/commands/brain/sync.md +27 -1
- package/package.json +3 -3
- package/prompts/claude.md +13 -12
- package/prompts/gemini.md +13 -12
- package/prompts/openai.md +13 -12
- package/prompts/opencode.md +13 -12
- package/src/cloud-sync.js +16 -6
- package/src/export-import.js +19 -4
- package/src/installer.js +5 -1
- package/src/scorer.js +2 -0
- package/commands/brain/consolidate.md +0 -158
- package/commands/brain/explore.md +0 -84
- package/commands/brain/init.md +0 -153
- package/commands/brain/review.md +0 -135
- package/commands/brain/sunshine.md +0 -342
- package/commands/brain/unpin.md +0 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brain-memory",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.23",
|
|
4
4
|
"description": "A brain-inspired hierarchical memory system for AI coding agents. Deep nested file structure that mimics human memory with time-decay and strength-based recall.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"name": "Onur Karali",
|
|
21
21
|
"email": "onur@omelas.tech"
|
|
22
22
|
},
|
|
23
|
-
"homepage": "https://brainmemory.
|
|
23
|
+
"homepage": "https://brainmemory.ai/",
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/omelas-tech/brain/issues"
|
|
26
26
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"url": "git+https://github.com/omelas-tech/brain.git"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"test": "node --test test/index-manager.test.js test/scorer.test.js test/tfidf.test.js test/recall.test.js test/functional.test.js test/sunshine.test.js test/stress.test.js test/crypto.test.js test/git-sync.test.js test/export-import.test.js test/install.test.js test/prompts.test.js test/session-start.test.js test/pinning.test.js test/skills.test.js test/contradiction.test.js",
|
|
45
|
+
"test": "node --test test/index-manager.test.js test/scorer.test.js test/tfidf.test.js test/recall.test.js test/functional.test.js test/sunshine.test.js test/stress.test.js test/crypto.test.js test/git-sync.test.js test/cloud-sync.test.js test/export-import.test.js test/install.test.js test/prompts.test.js test/session-start.test.js test/memorize.test.js test/pinning.test.js test/skills.test.js test/contradiction.test.js",
|
|
46
46
|
"prerelease": "npm test",
|
|
47
47
|
"release:beta": "npm version prerelease --preid beta && npm publish --tag beta && npm dist-tag add brain-memory@$(node -p \"require('./package.json').version\") latest",
|
|
48
48
|
"release:patch": "npm version patch && npm publish",
|
package/prompts/claude.md
CHANGED
|
@@ -48,20 +48,21 @@ Memories store their encoding context (project, topics, task type). During recal
|
|
|
48
48
|
|
|
49
49
|
## Available Commands
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
The everyday loop is **ambient** — `remember` and `memorize` run automatically at session start/end; you rarely type them.
|
|
52
|
+
|
|
53
|
+
**Core**
|
|
53
54
|
- `/brain:remember [query]` — Recall relevant memories with spreading activation and context matching
|
|
54
|
-
- `/brain:
|
|
55
|
-
- `/brain:explore [category]` — Browse the brain hierarchy
|
|
56
|
-
- `/brain:consolidate [scope]` — Merge related weak memories into stronger ones
|
|
57
|
-
- `/brain:forget [target]` — Decay or archive memories
|
|
58
|
-
- `/brain:sunshine [target]` — Deep forensic erasure — trace and remove all references to a memory
|
|
59
|
-
- `/brain:sleep [scope]` — Full maintenance cycle: replay, synaptic homeostasis, knowledge propagation, semantic crystallization, reorganize, consolidate, prune, REM dreaming, and expertise detection
|
|
55
|
+
- `/brain:memorize [topic]` — Store memories from the current context
|
|
60
56
|
- `/brain:status` — Dashboard with brain health overview
|
|
61
|
-
- `/brain:
|
|
62
|
-
- `/brain:
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
- `/brain:pin [id|query]` — Pin a memory to the always-present tier (toggle — also unpins, e.g. `--off`)
|
|
58
|
+
- `/brain:forget [target]` — Decay or archive memories (`--deep` = forensic erasure of every reference)
|
|
59
|
+
|
|
60
|
+
**Sync & skills**
|
|
61
|
+
- `/brain:sync [subcommand]` — Sync via Brain Cloud, Git remote, or export/import (auto-initializes on first run)
|
|
62
|
+
- `/brain:skills [list|show|add|use|remove|export]` — Manage procedural skills
|
|
63
|
+
|
|
64
|
+
**Maintenance (usually automatic — runs in the background)**
|
|
65
|
+
- `/brain:sleep [scope]` — Full maintenance cycle: replay, homeostasis, propagation, crystallization, reorganize, consolidate, prune, review reinforcement, REM dreaming, expertise detection
|
|
65
66
|
|
|
66
67
|
## Session Start Behavior
|
|
67
68
|
|
package/prompts/gemini.md
CHANGED
|
@@ -49,20 +49,21 @@ Memories store their encoding context (project, topics, task type). During recal
|
|
|
49
49
|
## Available Commands
|
|
50
50
|
|
|
51
51
|
Commands are available via `/brain:` prefix:
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
The everyday loop is **ambient** — `remember` and `memorize` run automatically at session start/end; you rarely type them.
|
|
53
|
+
|
|
54
|
+
**Core**
|
|
54
55
|
- `/brain:remember [query]` — Recall relevant memories with spreading activation and context matching
|
|
55
|
-
- `/brain:
|
|
56
|
-
- `/brain:explore [category]` — Browse the brain hierarchy
|
|
57
|
-
- `/brain:consolidate [scope]` — Merge related weak memories into stronger ones
|
|
58
|
-
- `/brain:forget [target]` — Decay or archive memories
|
|
59
|
-
- `/brain:sunshine [target]` — Deep forensic erasure — trace and remove all references to a memory
|
|
60
|
-
- `/brain:sleep [scope]` — Full maintenance cycle: replay, synaptic homeostasis, knowledge propagation, semantic crystallization, reorganize, consolidate, prune, REM dreaming, and expertise detection
|
|
56
|
+
- `/brain:memorize [topic]` — Store memories from the current context
|
|
61
57
|
- `/brain:status` — Dashboard with brain health overview
|
|
62
|
-
- `/brain:
|
|
63
|
-
- `/brain:
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
- `/brain:pin [id|query]` — Pin a memory to the always-present tier (toggle — also unpins, e.g. `--off`)
|
|
59
|
+
- `/brain:forget [target]` — Decay or archive memories (`--deep` = forensic erasure of every reference)
|
|
60
|
+
|
|
61
|
+
**Sync & skills**
|
|
62
|
+
- `/brain:sync [subcommand]` — Sync via Brain Cloud, Git remote, or export/import (auto-initializes on first run)
|
|
63
|
+
- `/brain:skills [list|show|add|use|remove|export]` — Manage procedural skills
|
|
64
|
+
|
|
65
|
+
**Maintenance (usually automatic — runs in the background)**
|
|
66
|
+
- `/brain:sleep [scope]` — Full maintenance cycle: replay, homeostasis, propagation, crystallization, reorganize, consolidate, prune, review reinforcement, REM dreaming, expertise detection
|
|
66
67
|
|
|
67
68
|
## Session Start Behavior
|
|
68
69
|
|
package/prompts/openai.md
CHANGED
|
@@ -49,20 +49,21 @@ Memories store their encoding context (project, topics, task type). During recal
|
|
|
49
49
|
## Available Commands
|
|
50
50
|
|
|
51
51
|
Brain skills are available via `/brain-` prefix:
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
The everyday loop is **ambient** — `remember` and `memorize` run automatically at session start/end; you rarely type them.
|
|
53
|
+
|
|
54
|
+
Core:
|
|
54
55
|
- `/brain-remember [query]` — Recall relevant memories with spreading activation and context matching
|
|
55
|
-
- `/brain-
|
|
56
|
-
- `/brain-explore [category]` — Browse the brain hierarchy
|
|
57
|
-
- `/brain-consolidate [scope]` — Merge related weak memories into stronger ones
|
|
58
|
-
- `/brain-forget [target]` — Decay or archive memories
|
|
59
|
-
- `/brain-sunshine [target]` — Deep forensic erasure — trace and remove all references to a memory
|
|
60
|
-
- `/brain-sleep [scope]` — Full maintenance cycle: replay, synaptic homeostasis, knowledge propagation, semantic crystallization, reorganize, consolidate, prune, REM dreaming, and expertise detection
|
|
56
|
+
- `/brain-memorize [topic]` — Store memories from the current context
|
|
61
57
|
- `/brain-status` — Dashboard with brain health overview
|
|
62
|
-
- `/brain-
|
|
63
|
-
- `/brain-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
- `/brain-pin [id|query]` — Pin a memory to the always-present tier (toggle — also unpins, e.g. `--off`)
|
|
59
|
+
- `/brain-forget [target]` — Decay or archive memories (`--deep` = forensic erasure of every reference)
|
|
60
|
+
|
|
61
|
+
Sync & skills:
|
|
62
|
+
- `/brain-sync [subcommand]` — Sync via Brain Cloud, Git remote, or export/import (auto-initializes on first run)
|
|
63
|
+
- `/brain-skill [list|show|add|use|remove|export]` — Manage procedural skills
|
|
64
|
+
|
|
65
|
+
Maintenance (usually automatic — runs in the background):
|
|
66
|
+
- `/brain-sleep [scope]` — Full maintenance cycle: replay, homeostasis, propagation, crystallization, reorganize, consolidate, prune, review reinforcement, REM dreaming, expertise detection
|
|
66
67
|
|
|
67
68
|
## Session Start Behavior
|
|
68
69
|
|
package/prompts/opencode.md
CHANGED
|
@@ -48,20 +48,21 @@ Memories store their encoding context (project, topics, task type). During recal
|
|
|
48
48
|
|
|
49
49
|
## Available Commands
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
The everyday loop is **ambient** — `remember` and `memorize` run automatically at session start/end; you rarely type them.
|
|
52
|
+
|
|
53
|
+
**Core**
|
|
53
54
|
- `/brain:remember [query]` — Recall relevant memories with spreading activation and context matching
|
|
54
|
-
- `/brain:
|
|
55
|
-
- `/brain:explore [category]` — Browse the brain hierarchy
|
|
56
|
-
- `/brain:consolidate [scope]` — Merge related weak memories into stronger ones
|
|
57
|
-
- `/brain:forget [target]` — Decay or archive memories
|
|
58
|
-
- `/brain:sunshine [target]` — Deep forensic erasure — trace and remove all references to a memory
|
|
59
|
-
- `/brain:sleep [scope]` — Full maintenance cycle: replay, synaptic homeostasis, knowledge propagation, semantic crystallization, reorganize, consolidate, prune, REM dreaming, and expertise detection
|
|
55
|
+
- `/brain:memorize [topic]` — Store memories from the current context
|
|
60
56
|
- `/brain:status` — Dashboard with brain health overview
|
|
61
|
-
- `/brain:
|
|
62
|
-
- `/brain:
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
- `/brain:pin [id|query]` — Pin a memory to the always-present tier (toggle — also unpins, e.g. `--off`)
|
|
58
|
+
- `/brain:forget [target]` — Decay or archive memories (`--deep` = forensic erasure of every reference)
|
|
59
|
+
|
|
60
|
+
**Sync & skills**
|
|
61
|
+
- `/brain:sync [subcommand]` — Sync via Brain Cloud, Git remote, or export/import (auto-initializes on first run)
|
|
62
|
+
- `/brain:skills [list|show|add|use|remove|export]` — Manage procedural skills
|
|
63
|
+
|
|
64
|
+
**Maintenance (usually automatic — runs in the background)**
|
|
65
|
+
- `/brain:sleep [scope]` — Full maintenance cycle: replay, homeostasis, propagation, crystallization, reorganize, consolidate, prune, review reinforcement, REM dreaming, expertise detection
|
|
65
66
|
|
|
66
67
|
## Session Start Behavior
|
|
67
68
|
|
package/src/cloud-sync.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Brain Memory — Cloud Sync Engine
|
|
3
3
|
*
|
|
4
|
-
* Push/pull ~/.brain/ memories via the Brain Cloud API (api.brainmemory.
|
|
4
|
+
* Push/pull ~/.brain/ memories via the Brain Cloud API (api.brainmemory.ai).
|
|
5
5
|
* Uses the device code OAuth flow for CLI authentication.
|
|
6
6
|
*
|
|
7
7
|
* Zero external dependencies — uses Node.js built-in https, fs, child_process.
|
|
@@ -16,7 +16,7 @@ const http = require('http');
|
|
|
16
16
|
|
|
17
17
|
const CLOUD_DIR = '.cloud';
|
|
18
18
|
const CONFIG_FILE = 'config.json';
|
|
19
|
-
const DEFAULT_API_URL = 'https://api.brainmemory.
|
|
19
|
+
const DEFAULT_API_URL = 'https://api.brainmemory.ai';
|
|
20
20
|
|
|
21
21
|
// Files/dirs inside ~/.brain/ that should NOT be synced
|
|
22
22
|
const TAR_EXCLUDES = ['.sync', '.cloud', '.DS_Store', '_archived'];
|
|
@@ -53,10 +53,20 @@ function request(url, opts = {}, _redirectCount = 0) {
|
|
|
53
53
|
// Follow redirects
|
|
54
54
|
if ([301, 302, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
55
55
|
const redirectUrl = new URL(res.headers.location, url).href;
|
|
56
|
-
// For 307/308, preserve method and body; for 301/302, switch to GET
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
// For 307/308, preserve method and body; for 301/302, switch to GET.
|
|
57
|
+
// When dropping the body we must also drop the body-describing headers,
|
|
58
|
+
// or the redirected GET advertises a Content-Length it never sends and
|
|
59
|
+
// the socket hangs waiting to flush a body that isn't coming.
|
|
60
|
+
let newOpts;
|
|
61
|
+
if ([307, 308].includes(res.statusCode)) {
|
|
62
|
+
newOpts = opts;
|
|
63
|
+
} else {
|
|
64
|
+
const headers = { ...(opts.headers || {}) };
|
|
65
|
+
for (const h of Object.keys(headers)) {
|
|
66
|
+
if (/^content-(length|type)$/i.test(h)) delete headers[h];
|
|
67
|
+
}
|
|
68
|
+
newOpts = { ...opts, method: 'GET', body: undefined, headers };
|
|
69
|
+
}
|
|
60
70
|
res.resume(); // drain the response
|
|
61
71
|
return resolve(request(redirectUrl, newOpts, _redirectCount + 1));
|
|
62
72
|
}
|
package/src/export-import.js
CHANGED
|
@@ -25,7 +25,7 @@ const EXCLUDED = new Set(['.sync', '.DS_Store']);
|
|
|
25
25
|
*/
|
|
26
26
|
function exportBrain(brainDir, outputPath, passphrase) {
|
|
27
27
|
if (!fs.existsSync(brainDir)) {
|
|
28
|
-
throw new Error('~/.brain/ directory not found.
|
|
28
|
+
throw new Error('~/.brain/ directory not found. Reinstall with `npx brain-memory`, or run /brain:sync to create it.');
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const files = {};
|
|
@@ -105,7 +105,7 @@ function importBrain(inputPath, brainDir, passphrase, options = {}) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
if (!payload || !payload.files || typeof payload.files !== 'object') {
|
|
108
|
+
if (!payload || !payload.files || typeof payload.files !== 'object' || Array.isArray(payload.files)) {
|
|
109
109
|
throw new Error('Invalid export format: missing files object.');
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -151,9 +151,24 @@ function previewImport(inputPath, brainDir, passphrase) {
|
|
|
151
151
|
let payload;
|
|
152
152
|
|
|
153
153
|
if (passphrase) {
|
|
154
|
-
|
|
154
|
+
try {
|
|
155
|
+
payload = JSON.parse(decrypt(raw, passphrase));
|
|
156
|
+
} catch (err) {
|
|
157
|
+
if (err.message.includes('Unsupported state') || err.message.includes('unable to authenticate') || err.message.includes('Invalid encrypted data')) {
|
|
158
|
+
throw new Error('Decryption failed — wrong passphrase or corrupted file.');
|
|
159
|
+
}
|
|
160
|
+
throw err;
|
|
161
|
+
}
|
|
155
162
|
} else {
|
|
156
|
-
|
|
163
|
+
try {
|
|
164
|
+
payload = JSON.parse(raw.toString('utf8'));
|
|
165
|
+
} catch {
|
|
166
|
+
throw new Error('Invalid export file. If the file is encrypted, provide a passphrase.');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!payload || !payload.files || typeof payload.files !== 'object' || Array.isArray(payload.files)) {
|
|
171
|
+
throw new Error('Invalid export format: missing files object.');
|
|
157
172
|
}
|
|
158
173
|
|
|
159
174
|
const files = Object.keys(payload.files);
|
package/src/installer.js
CHANGED
|
@@ -114,7 +114,11 @@ function detectInstallations() {
|
|
|
114
114
|
let commandsFound = false;
|
|
115
115
|
if (config.commandStyle === 'skills') {
|
|
116
116
|
const skillsDir = path.join(targetDir, config.commandsSubdir);
|
|
117
|
-
commandsFound = fs.existsSync(
|
|
117
|
+
commandsFound = fs.existsSync(skillsDir) &&
|
|
118
|
+
fs.readdirSync(skillsDir).some(
|
|
119
|
+
(d) => d.startsWith('brain-') &&
|
|
120
|
+
fs.existsSync(path.join(skillsDir, d, 'SKILL.md'))
|
|
121
|
+
);
|
|
118
122
|
} else {
|
|
119
123
|
const commandsDir = path.join(targetDir, config.commandsSubdir, 'brain');
|
|
120
124
|
commandsFound = fs.existsSync(commandsDir) &&
|
package/src/scorer.js
CHANGED
|
@@ -293,6 +293,8 @@ function improveDecayRate(decayRate) {
|
|
|
293
293
|
* @returns {number} Consolidated strength (capped at 1.0)
|
|
294
294
|
*/
|
|
295
295
|
function computeConsolidatedStrength(sourceStrengths) {
|
|
296
|
+
// No sources to consolidate — Math.max(...[]) is -Infinity, so guard explicitly.
|
|
297
|
+
if (!Array.isArray(sourceStrengths) || sourceStrengths.length === 0) return 0;
|
|
296
298
|
const maxStrength = Math.max(...sourceStrengths);
|
|
297
299
|
return Math.min(1.0, maxStrength + 0.15);
|
|
298
300
|
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Merge related weak memories into stronger combined memories
|
|
3
|
-
argument-hint: "[scope]"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# /brain:consolidate — Merge Related Memories
|
|
7
|
-
|
|
8
|
-
You are consolidating memories in the Brain Memory system. Consolidation combines multiple related or weakening memories into a single stronger, more coherent memory — mimicking how human brains merge similar experiences into generalized knowledge.
|
|
9
|
-
|
|
10
|
-
**Target scope:** $ARGUMENTS
|
|
11
|
-
|
|
12
|
-
## Steps
|
|
13
|
-
|
|
14
|
-
### 1. Determine Scope
|
|
15
|
-
|
|
16
|
-
- If $ARGUMENTS specifies a category path, consolidate within that subtree
|
|
17
|
-
- If $ARGUMENTS is empty, scan the entire `~/.brain/` for consolidation candidates
|
|
18
|
-
- If $ARGUMENTS is "auto", perform automatic consolidation based on thresholds
|
|
19
|
-
|
|
20
|
-
### 2. Find Consolidation Candidates
|
|
21
|
-
|
|
22
|
-
Read `index.json` and identify candidate groups using these criteria:
|
|
23
|
-
|
|
24
|
-
**Automatic candidates (any of):**
|
|
25
|
-
- Memories with effective (decayed) strength below `consolidation_threshold` (default: 0.3)
|
|
26
|
-
- Clusters of 3+ memories in the same directory with overlapping tags
|
|
27
|
-
- Memories with the same type in the same category that are older than 30 days
|
|
28
|
-
|
|
29
|
-
**Compute decayed strength for each:**
|
|
30
|
-
```
|
|
31
|
-
days_elapsed = (now - last_accessed) / (1000 * 60 * 60 * 24)
|
|
32
|
-
decayed_strength = strength * (decay_rate ^ days_elapsed)
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 3. Group Related Memories
|
|
36
|
-
|
|
37
|
-
Group candidates by:
|
|
38
|
-
1. **Path proximity** — memories in the same or nearby directories
|
|
39
|
-
2. **Tag overlap** — memories sharing 2+ tags
|
|
40
|
-
3. **Type similarity** — same memory type
|
|
41
|
-
4. **Temporal proximity** — created within similar time periods
|
|
42
|
-
|
|
43
|
-
Present the proposed groups to the user:
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
## Consolidation Candidates
|
|
47
|
-
|
|
48
|
-
### Group 1: Kubernetes Deployments (professional/companies/acme/projects/)
|
|
49
|
-
- deployment-v1.md (strength: 0.22, type: experience)
|
|
50
|
-
- deployment-v2.md (strength: 0.18, type: experience)
|
|
51
|
-
- k8s-config-issue.md (strength: 0.15, type: learning)
|
|
52
|
-
→ Proposed: Merge into "kubernetes-deployment-lessons.md" (strength: 0.75)
|
|
53
|
-
|
|
54
|
-
### Group 2: TypeScript Learnings (personal/education/)
|
|
55
|
-
- ts-generics.md (strength: 0.28, type: learning)
|
|
56
|
-
- ts-utility-types.md (strength: 0.25, type: learning)
|
|
57
|
-
→ Proposed: Merge into "typescript-advanced-types.md" (strength: 0.65)
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 4. Get User Approval
|
|
61
|
-
|
|
62
|
-
Ask the user which groups to consolidate. They can:
|
|
63
|
-
- Approve all proposed groups
|
|
64
|
-
- Select specific groups
|
|
65
|
-
- Modify groupings
|
|
66
|
-
- Cancel
|
|
67
|
-
|
|
68
|
-
### 5. Perform Consolidation
|
|
69
|
-
|
|
70
|
-
For each approved group:
|
|
71
|
-
|
|
72
|
-
1. **Read all source memories** in the group
|
|
73
|
-
2. **Synthesize** a new consolidated memory that:
|
|
74
|
-
- Preserves all key details and insights from the sources
|
|
75
|
-
- Identifies patterns and evolution across the memories
|
|
76
|
-
- Creates a coherent narrative or structured summary
|
|
77
|
-
- Is more concise than the sum of its parts
|
|
78
|
-
3. **Calculate new strength**: `max(source_strengths) + 0.15` (capped at 1.0)
|
|
79
|
-
4. **Set new decay rate**: Use the slowest decay rate from the sources
|
|
80
|
-
5. **Merge tags**: Union of all source memory tags
|
|
81
|
-
6. **Set related**: Include all source memory IDs in the `related` field
|
|
82
|
-
7. **Salience anchoring**: The highest-salience memory in the group is the "anchor" — its framing and key details take priority in the synthesis. Inherit max salience.
|
|
83
|
-
8. **Confidence**: Inherit the maximum confidence from the group
|
|
84
|
-
9. **Cognitive type**: Set to `semantic` (consolidation abstracts knowledge)
|
|
85
|
-
|
|
86
|
-
### 6. Write Consolidated Memory
|
|
87
|
-
|
|
88
|
-
Create the new memory file in the appropriate location (same directory as the majority of sources, or in `_consolidated/` if sources span categories).
|
|
89
|
-
|
|
90
|
-
Use the standard memory format with an additional section:
|
|
91
|
-
|
|
92
|
-
```markdown
|
|
93
|
-
---
|
|
94
|
-
id: mem_<date>_<hex>
|
|
95
|
-
type: consolidated
|
|
96
|
-
cognitive_type: semantic
|
|
97
|
-
created: <now>
|
|
98
|
-
last_accessed: <now>
|
|
99
|
-
access_count: 0
|
|
100
|
-
recall_history: []
|
|
101
|
-
strength: <calculated>
|
|
102
|
-
decay_rate: <calculated>
|
|
103
|
-
salience: <max from sources>
|
|
104
|
-
confidence: <max from sources>
|
|
105
|
-
tags: [<merged tags>]
|
|
106
|
-
related: [<all source IDs>]
|
|
107
|
-
consolidated_from: [<source IDs>]
|
|
108
|
-
source: consolidation
|
|
109
|
-
encoding_context:
|
|
110
|
-
project: <project if shared, otherwise omit>
|
|
111
|
-
topics: [<merged key topics>]
|
|
112
|
-
task_type: <most common from sources>
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
# <Descriptive Title>
|
|
116
|
-
|
|
117
|
-
<Synthesized summary>
|
|
118
|
-
|
|
119
|
-
## Key Patterns
|
|
120
|
-
|
|
121
|
-
<Patterns identified across the source memories>
|
|
122
|
-
|
|
123
|
-
## Timeline
|
|
124
|
-
|
|
125
|
-
<Chronological evolution if applicable>
|
|
126
|
-
|
|
127
|
-
## Source Memories
|
|
128
|
-
|
|
129
|
-
<List of original memories that were merged, with their dates and original titles>
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### 7. Archive Source Memories
|
|
133
|
-
|
|
134
|
-
Move the original source memory files to a `~/.brain/_archived/` directory (create if needed), preserving their paths as subdirectories. This keeps them recoverable and searchable via `/brain:remember`.
|
|
135
|
-
|
|
136
|
-
Update `index.json`:
|
|
137
|
-
- Remove archived memory entries from `memories`
|
|
138
|
-
- Add the new consolidated memory
|
|
139
|
-
- Update `memory_count`
|
|
140
|
-
- Update `last_updated`
|
|
141
|
-
|
|
142
|
-
Update `_archived/index.json`:
|
|
143
|
-
- Add entries for each archived memory with original metadata and `archived_reason: "consolidation"`
|
|
144
|
-
|
|
145
|
-
Update `associations.json`:
|
|
146
|
-
- Transfer association edges from source memories to the new consolidated memory
|
|
147
|
-
- Remove edges pointing to archived source memories
|
|
148
|
-
|
|
149
|
-
Update `review-queue.json`:
|
|
150
|
-
- Remove entries for archived source memories
|
|
151
|
-
- Add entry for the new consolidated memory if applicable
|
|
152
|
-
|
|
153
|
-
### 8. Confirm
|
|
154
|
-
|
|
155
|
-
Print a summary:
|
|
156
|
-
- How many memories were consolidated into how many
|
|
157
|
-
- New consolidated memory titles, paths, and strengths
|
|
158
|
-
- Space saved (number of files reduced)
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Browse the brain memory hierarchy
|
|
3
|
-
argument-hint: "[category]"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# /brain:explore — Browse the Brain Structure
|
|
7
|
-
|
|
8
|
-
You are exploring the Brain Memory system's hierarchical structure. This gives the user a visual overview of their memory landscape.
|
|
9
|
-
|
|
10
|
-
**Target path:** $ARGUMENTS
|
|
11
|
-
|
|
12
|
-
## Steps
|
|
13
|
-
|
|
14
|
-
### 1. Determine Scope
|
|
15
|
-
|
|
16
|
-
- If $ARGUMENTS is empty, show the full top-level overview
|
|
17
|
-
- If $ARGUMENTS specifies a category or path (e.g., "professional" or "professional/companies"), explore that subtree
|
|
18
|
-
|
|
19
|
-
### 2. Read Structure
|
|
20
|
-
|
|
21
|
-
Read the directory structure of `~/.brain/` (or the specified subtree). For each directory, read its `_meta.json` to get metadata.
|
|
22
|
-
|
|
23
|
-
### 3. Display Tree View
|
|
24
|
-
|
|
25
|
-
Present the brain structure as a visual tree with statistics:
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
🧠 Brain Memory Overview
|
|
29
|
-
Last updated: <timestamp>
|
|
30
|
-
Total memories: <count>
|
|
31
|
-
|
|
32
|
-
~/.brain/
|
|
33
|
-
├── professional/ (12 memories)
|
|
34
|
-
│ ├── companies/ (8 memories)
|
|
35
|
-
│ │ ├── acme-corp/ (5 memories)
|
|
36
|
-
│ │ │ ├── projects/ (3 memories)
|
|
37
|
-
│ │ │ │ ├── alpha-launch.md ⚡ 0.82
|
|
38
|
-
│ │ │ │ ├── beta-planning.md ⚡ 0.65
|
|
39
|
-
│ │ │ │ └── tech-debt-review.md ⚡ 0.41
|
|
40
|
-
│ │ │ ├── team-dynamics.md ⚡ 0.70
|
|
41
|
-
│ │ │ └── joining-decision.md ⚡ 0.88
|
|
42
|
-
│ │ └── prev-startup/ (3 memories)
|
|
43
|
-
│ ├── skills/ (3 memories)
|
|
44
|
-
│ └── career/ (1 memory)
|
|
45
|
-
├── personal/ (6 memories)
|
|
46
|
-
│ ├── education/ (3 memories)
|
|
47
|
-
│ ├── health/ (2 memories)
|
|
48
|
-
│ └── goals/ (1 memory)
|
|
49
|
-
├── social/ (2 memories)
|
|
50
|
-
│ └── communities/ (2 memories)
|
|
51
|
-
├── family/ (3 memories)
|
|
52
|
-
│ └── events/ (3 memories)
|
|
53
|
-
└── _consolidated/ (1 memory)
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
The ⚡ indicator shows the current effective (decayed) strength of each memory.
|
|
57
|
-
|
|
58
|
-
### 4. Category Summary
|
|
59
|
-
|
|
60
|
-
For the explored scope, provide:
|
|
61
|
-
- **Strongest memory**: Title and path of the highest-strength memory
|
|
62
|
-
- **Most accessed**: Title and path of the most frequently recalled memory
|
|
63
|
-
- **Needs attention**: Memories with decayed strength below the consolidation threshold (0.3)
|
|
64
|
-
- **Recent additions**: Memories created in the last 7 days
|
|
65
|
-
|
|
66
|
-
### 5. Offer Navigation
|
|
67
|
-
|
|
68
|
-
Suggest next actions:
|
|
69
|
-
- "Use `/brain:explore <subcategory>` to drill deeper"
|
|
70
|
-
- "Use `/brain:remember <query>` to search for specific memories"
|
|
71
|
-
- "Use `/brain:consolidate <category>` to merge weak memories in a category"
|
|
72
|
-
- "Use `/brain:sleep` to reorganize, consolidate, and detect expertise areas"
|
|
73
|
-
|
|
74
|
-
### 6. Show Expertise (if available)
|
|
75
|
-
|
|
76
|
-
If any directories in the explored scope contain `_expertise.md` files, display a brief expertise summary:
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
## Expertise Areas
|
|
80
|
-
🟢 Expert — professional/skills/flutter/authentication/ (0.85)
|
|
81
|
-
🔵 Deep Knowledge — professional/skills/react/ (0.68)
|
|
82
|
-
🟡 Working Knowledge — personal/education/psychology/ (0.45)
|
|
83
|
-
⚪ Awareness — social/communities/open-source/ (0.28)
|
|
84
|
-
```
|