brain-memory 0.1.0-beta.20 → 0.1.0-beta.21
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 +4 -2
- package/bin/memorize.js +4 -1
- package/bin/skill.js +1 -1
- package/package.json +3 -3
- package/src/cloud-sync.js +16 -6
- package/src/export-import.js +18 -3
- package/src/scorer.js +2 -0
package/README.md
CHANGED
|
@@ -450,7 +450,9 @@ Failed recalls reset the interval to 1 day. Successful recalls extend the interv
|
|
|
450
450
|
|
|
451
451
|
### Cross-Agent Memory Sharing
|
|
452
452
|
|
|
453
|
-
`~/.brain/` is a single global directory in the user's home folder. All memories are shared across every project and every supported agent automatically. A decision stored by Claude Code in one project is immediately available to Gemini CLI
|
|
453
|
+
`~/.brain/` is a single global directory in the user's home folder. All memories are shared across every project and every supported agent automatically. A decision stored by Claude Code in one project is immediately available to Gemini CLI, OpenAI Codex CLI, or OpenCode in any other project — no configuration, no export, no per-project setup. The format is agent-agnostic: plain Markdown files with YAML frontmatter, readable by any tool.
|
|
454
|
+
|
|
455
|
+
Brain Memory is **model-agnostic** as well as agent-portable: because memory is plain files rather than embeddings welded to a particular model, the LLM underneath your agent can be anything — GPT, Claude, Gemini, or any model routed through a gateway — and your memory is unaffected. **Switch your model or switch your agent, and you keep remembering and pick up exactly where you left off.**
|
|
454
456
|
|
|
455
457
|
To share memories across different machines, use `/brain:sync` (see below).
|
|
456
458
|
|
|
@@ -612,7 +614,7 @@ npm test # Unit tests
|
|
|
612
614
|
node harness/runner.js # Full benchmark (cloud APIs)
|
|
613
615
|
```
|
|
614
616
|
|
|
615
|
-
Live methodology and per-scenario detail: [brainmemory.
|
|
617
|
+
Live methodology and per-scenario detail: [brainmemory.ai/docs/benchmarks](https://brainmemory.ai/docs/benchmarks) · Source: [`benchmark/`](benchmark/)
|
|
616
618
|
|
|
617
619
|
## Contributing
|
|
618
620
|
|
package/bin/memorize.js
CHANGED
|
@@ -246,7 +246,10 @@ async function main() {
|
|
|
246
246
|
process.exit(1);
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
// Read from fd 0 rather than the '/dev/stdin' path: the path form fails with
|
|
250
|
+
// ENXIO on Linux CI runners and doesn't exist on Windows, whereas fd 0 reads
|
|
251
|
+
// piped stdin portably across Linux, macOS, and Windows.
|
|
252
|
+
inputData = fs.readFileSync(0, 'utf-8');
|
|
250
253
|
|
|
251
254
|
let input;
|
|
252
255
|
try {
|
package/bin/skill.js
CHANGED
|
@@ -51,7 +51,7 @@ function main(argv) {
|
|
|
51
51
|
case 'add': {
|
|
52
52
|
if (process.stdin.isTTY) return fail({ error: 'Pipe a skill JSON via stdin' });
|
|
53
53
|
let input;
|
|
54
|
-
try { input = JSON.parse(fs.readFileSync(
|
|
54
|
+
try { input = JSON.parse(fs.readFileSync(0, 'utf-8')); }
|
|
55
55
|
catch (e) { return fail({ error: `Invalid JSON: ${e.message}` }); }
|
|
56
56
|
return done(addSkill(undefined, input));
|
|
57
57
|
}
|
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.21",
|
|
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/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
|
@@ -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/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
|
}
|