brain-memory 0.1.0-beta.23 → 0.1.0-beta.24

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 CHANGED
@@ -452,13 +452,21 @@ Brain Memory is **model-agnostic** as well as agent-portable: because memory is
452
452
 
453
453
  To share memories across different machines, use `/brain:sync` (see below).
454
454
 
455
- ### Portable Sync
455
+ ### Portable Sync — your memory, no lock-in
456
456
 
457
- `/brain:sync` provides two ways to sync memories across devices — no OAuth apps, no cloud provider setup.
457
+ **Your brain is plain files in a folder — sync it however you already sync files.** No account or cloud provider is required.
458
458
 
459
- **Git remote** — Push/pull `~/.brain/` to any private Git repository. Works with GitHub, GitLab, Codeberg, or any self-hosted Git server. Uses your existing Git/SSH authentication — no additional credentials needed.
459
+ **Any synced folder** — Point `BRAIN_DIR` at a folder your existing tools already sync, and you're done:
460
460
 
461
- **Export/Import** — Pack the entire `~/.brain/` into a single encrypted file for manual transfer via USB, email, or any file-sharing service.
461
+ ```bash
462
+ export BRAIN_DIR="$HOME/Google Drive/brain" # or Dropbox, iCloud Drive, OneDrive, Syncthing…
463
+ ```
464
+
465
+ **Git remote** — `/brain:sync` push/pull `~/.brain/` to any private Git repository (GitHub, GitLab, Codeberg, or self-hosted), using your existing Git/SSH auth.
466
+
467
+ **Export/Import** — Pack the entire brain into a single encrypted file for manual transfer via USB, email, or any file-sharing service.
468
+
469
+ **Brain Cloud** (optional) — A hosted, zero-config hub if you'd rather not run your own. Entirely optional — everything above works without it.
462
470
 
463
471
  **Key features:**
464
472
  - **Manual push/pull** — No background watchers, no auto-sync. You control when data moves.
package/bin/cloud-sync.js CHANGED
@@ -11,11 +11,12 @@
11
11
  * brain cloud status Show connection and sync status
12
12
  */
13
13
 
14
- const path = require('path');
15
- const os = require('os');
16
14
  const cloud = require('../src/cloud-sync');
15
+ const { getBrainDir } = require('../src/index-manager');
17
16
 
18
- const BRAIN_DIR = path.join(os.homedir(), '.brain');
17
+ // Resolved via getBrainDir so Cloud sync targets the same brain as the rest of
18
+ // the CLI, including a $BRAIN_DIR override (synced folder, git working copy, …).
19
+ const BRAIN_DIR = getBrainDir();
19
20
 
20
21
  async function main() {
21
22
  const args = process.argv.slice(2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brain-memory",
3
- "version": "0.1.0-beta.23",
3
+ "version": "0.1.0-beta.24",
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",
@@ -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/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",
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/erasure.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",
@@ -63,11 +63,25 @@ function validateBrainPath(targetPath, brainDir) {
63
63
  /**
64
64
  * Resolve the brain directory path.
65
65
  *
66
+ * Precedence: explicit `overrideBase` arg (tests / project-local brains) >
67
+ * the `BRAIN_DIR` environment variable (point your brain at any synced folder —
68
+ * Google Drive, Dropbox, iCloud, a git working copy, …) > the default `~/.brain`.
69
+ *
70
+ * `BRAIN_DIR` is the brain directory itself (the folder holding `index.json`),
71
+ * not a parent. A leading `~/` is expanded since env vars are not shell-expanded.
72
+ *
66
73
  * @param {string} [overrideBase] - Override base directory (for testing)
67
- * @returns {string} Absolute path to ~/.brain/ (or overrideBase/.brain/ if provided)
74
+ * @returns {string} Absolute path to the brain directory
68
75
  */
69
76
  function getBrainDir(overrideBase) {
70
77
  if (overrideBase) return path.join(overrideBase, '.brain');
78
+ const env = process.env.BRAIN_DIR && process.env.BRAIN_DIR.trim();
79
+ if (env) {
80
+ const expanded = env === '~' || env.startsWith('~/')
81
+ ? path.join(os.homedir(), env.slice(1))
82
+ : env;
83
+ return path.resolve(expanded);
84
+ }
71
85
  return DEFAULT_BRAIN_DIR;
72
86
  }
73
87
 
package/src/installer.js CHANGED
@@ -2,6 +2,8 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const os = require('os');
4
4
 
5
+ const { getBrainDir } = require('./index-manager');
6
+
5
7
  const PACKAGE_ROOT = path.resolve(__dirname, '..');
6
8
 
7
9
  const RUNTIMES = {
@@ -254,7 +256,9 @@ function installForRuntime(runtime, scope) {
254
256
  }
255
257
 
256
258
  function initializeBrain(overrideBase) {
257
- const brainDir = path.join(overrideBase || os.homedir(), '.brain');
259
+ // Honors $BRAIN_DIR (via getBrainDir) so a fresh brain is created wherever the
260
+ // user points it — e.g. inside a Google Drive / Dropbox / iCloud synced folder.
261
+ const brainDir = overrideBase ? path.join(overrideBase, '.brain') : getBrainDir();
258
262
 
259
263
  if (fs.existsSync(brainDir)) {
260
264
  return { alreadyExists: true };