brain-memory 0.1.0-beta.3 → 0.1.0-beta.4
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 +64 -16
- package/bin/install.js +4 -0
- package/commands/brain/init.md +0 -8
- package/commands/brain/remember.md +2 -2
- package/commands/brain/sleep.md +0 -19
- package/commands/brain/status.md +12 -1
- package/commands/brain/sync.md +220 -0
- package/package.json +7 -2
- package/prompts/claude.md +5 -0
- package/prompts/gemini.md +5 -0
- package/prompts/openai.md +5 -0
- package/src/sync/crypto-utils.js +217 -0
- package/src/sync/oauth.js +430 -0
- package/src/sync/provider.js +144 -0
- package/src/sync/providers/dropbox.js +288 -0
- package/src/sync/providers/google-drive.js +496 -0
- package/src/sync/providers/onedrive.js +308 -0
- package/src/sync/sync-engine.js +774 -0
package/README.md
CHANGED
|
@@ -95,6 +95,7 @@ Then append the contents of the corresponding prompt file to your agent's instru
|
|
|
95
95
|
| `/brain:sunshine [target]` | Deep forensic erasure — trace and remove all references |
|
|
96
96
|
| `/brain:sleep [scope]` | Full maintenance cycle — 9 neuroscience-inspired phases |
|
|
97
97
|
| `/brain:status` | Dashboard with brain health metrics and recommendations |
|
|
98
|
+
| `/brain:sync [subcommand]` | Cloud sync — push/pull memories to Dropbox, Google Drive, or OneDrive |
|
|
98
99
|
|
|
99
100
|
## How It Works
|
|
100
101
|
|
|
@@ -117,7 +118,7 @@ Create → Store → Decay → Recall → Reinforce → Review → Sleep → Arc
|
|
|
117
118
|
|
|
118
119
|
### Neuroscience Foundations
|
|
119
120
|
|
|
120
|
-
Brain Memory
|
|
121
|
+
Brain Memory is grounded in peer-reviewed neuroscience research. Here's how each mechanism maps to the brain:
|
|
121
122
|
|
|
122
123
|
| Brain Mechanism | Implementation |
|
|
123
124
|
|-----------------|---------------|
|
|
@@ -226,8 +227,6 @@ score = 0.38 * relevance
|
|
|
226
227
|
- **context_match** (0.14) — How similar the encoding context is to the current session
|
|
227
228
|
- **salience** (0.08) — Emotional/motivational significance
|
|
228
229
|
|
|
229
|
-
The formula gracefully degrades for v1 memories missing newer fields — weights are renormalized across available terms.
|
|
230
|
-
|
|
231
230
|
The agent then decides the response strategy:
|
|
232
231
|
- **Single strong match** (top score > 0.7) → Return the full memory
|
|
233
232
|
- **Multiple related** (2-5 candidates > 0.4) → Synthesize a consolidated response
|
|
@@ -261,7 +260,7 @@ Memories are connected via weighted edges in `.brain/associations.json`:
|
|
|
261
260
|
|
|
262
261
|
### Spaced Reinforcement
|
|
263
262
|
|
|
264
|
-
|
|
263
|
+
Spaced reinforcement rewards optimal recall timing:
|
|
265
264
|
|
|
266
265
|
```
|
|
267
266
|
spacingMultiplier = min(3.0, 1.0 + log2(1 + daysSinceLastAccess))
|
|
@@ -328,15 +327,24 @@ Each expertise area gets an `_expertise.md` profile documenting what you know we
|
|
|
328
327
|
|
|
329
328
|
Failed recalls reset the interval to 1 day. Successful recalls extend the interval by the ease factor. This ensures you spend time on memories that need reinforcement, not ones you already know well.
|
|
330
329
|
|
|
331
|
-
###
|
|
330
|
+
### Cloud Sync
|
|
331
|
+
|
|
332
|
+
`/brain:sync` lets you push and pull your `.brain/` memories to a cloud provider for cross-device access. Supports **Dropbox**, **Google Drive**, and **OneDrive** with zero npm dependencies (uses Node.js 18+ built-in `fetch`).
|
|
332
333
|
|
|
333
|
-
|
|
334
|
-
-
|
|
335
|
-
-
|
|
336
|
-
-
|
|
337
|
-
-
|
|
334
|
+
**Key features:**
|
|
335
|
+
- **Manual push/pull** — No background watchers, no auto-sync. You control when data moves.
|
|
336
|
+
- **Three-way diff** — Compares local state, remote state, and last-known sync state to detect changes and conflicts.
|
|
337
|
+
- **Conflict resolution** — When the same file is modified locally and remotely, sync detects the conflict and lets you choose: keep local, keep remote, or keep both.
|
|
338
|
+
- **Optional encryption** — AES-256-GCM encryption with a user-provided passphrase. When enabled, all files are encrypted before upload and decrypted after download. The cloud provider only ever sees opaque bytes.
|
|
339
|
+
- **OAuth2 authentication** — PKCE authorization code flow with a Device Code Flow fallback for headless/SSH environments. Users register their own OAuth app with the provider and supply their client ID.
|
|
338
340
|
|
|
339
|
-
|
|
341
|
+
**Setup:**
|
|
342
|
+
1. Register an OAuth app with your chosen provider (Dropbox / Google Drive / OneDrive)
|
|
343
|
+
2. Run `/brain:sync login <provider>` and provide your client ID
|
|
344
|
+
3. Authorize in the browser (or enter the device code for headless environments)
|
|
345
|
+
4. Use `/brain:sync push` and `/brain:sync pull` to keep memories in sync
|
|
346
|
+
|
|
347
|
+
Sync state is stored locally in `.brain/.sync/` and is never uploaded to the cloud.
|
|
340
348
|
|
|
341
349
|
## File Structure
|
|
342
350
|
|
|
@@ -368,9 +376,13 @@ No data is lost. All new scoring gracefully falls back when newer fields are abs
|
|
|
368
376
|
│ └── events/
|
|
369
377
|
├── _consolidated/ # Merged memories from consolidation
|
|
370
378
|
│ └── _meta.json
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
379
|
+
├── _archived/ # Decayed memories (recoverable + searchable)
|
|
380
|
+
│ ├── _meta.json
|
|
381
|
+
│ └── index.json # Searchable archive index
|
|
382
|
+
└── .sync/ # Cloud sync state (never synced, local only)
|
|
383
|
+
├── config.json # Provider, client ID, encryption flag
|
|
384
|
+
├── credentials.enc # AES-256-GCM encrypted OAuth tokens
|
|
385
|
+
└── sync-state.json # Per-file revisions, cursor, conflicts
|
|
374
386
|
```
|
|
375
387
|
|
|
376
388
|
Subdirectories are created **on demand** — the agent decides placement depth based on how specific the memory is. A generic career thought lands in `professional/`, but a specific deployment incident goes to `professional/companies/acme/projects/alpha/`.
|
|
@@ -430,7 +442,8 @@ brain/
|
|
|
430
442
|
│ ├── forget.md
|
|
431
443
|
│ ├── sunshine.md
|
|
432
444
|
│ ├── sleep.md
|
|
433
|
-
│
|
|
445
|
+
│ ├── status.md
|
|
446
|
+
│ └── sync.md
|
|
434
447
|
├── prompts/
|
|
435
448
|
│ ├── claude.md # CLAUDE.md content (injected by installer)
|
|
436
449
|
│ ├── gemini.md # GEMINI.md content (injected by installer)
|
|
@@ -442,12 +455,47 @@ brain/
|
|
|
442
455
|
│ └── default-categories.json # Default brain category definitions
|
|
443
456
|
├── src/
|
|
444
457
|
│ ├── scorer.js # Decay, spreading activation, context matching, spaced reinforcement
|
|
445
|
-
│
|
|
458
|
+
│ ├── index-manager.js # Index, associations, contexts, review queue, archive CRUD
|
|
459
|
+
│ └── sync/ # Cloud sync module
|
|
460
|
+
│ ├── crypto-utils.js # AES-256-GCM encryption + credential storage
|
|
461
|
+
│ ├── oauth.js # OAuth2 PKCE + Device Code Flow
|
|
462
|
+
│ ├── provider.js # SyncProvider base class + factory
|
|
463
|
+
│ ├── sync-engine.js # Local-first sync with 3-way diff
|
|
464
|
+
│ └── providers/
|
|
465
|
+
│ ├── dropbox.js # Dropbox API v2
|
|
466
|
+
│ ├── google-drive.js # Google Drive API v3
|
|
467
|
+
│ └── onedrive.js # Microsoft Graph API
|
|
446
468
|
├── CLAUDE.md # Development guide for this repo
|
|
447
469
|
├── package.json
|
|
448
470
|
└── README.md
|
|
449
471
|
```
|
|
450
472
|
|
|
473
|
+
## Releasing
|
|
474
|
+
|
|
475
|
+
Tests run automatically before every release via the `prerelease` script.
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
# Beta release (bumps 0.1.0-beta.3 → 0.1.0-beta.4)
|
|
479
|
+
npm run release:beta
|
|
480
|
+
|
|
481
|
+
# Stable releases
|
|
482
|
+
npm run release:patch # 0.1.0 → 0.1.1
|
|
483
|
+
npm run release:minor # 0.1.1 → 0.2.0
|
|
484
|
+
npm run release:major # 0.2.0 → 1.0.0
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Each release command:
|
|
488
|
+
1. Runs the full test suite
|
|
489
|
+
2. Bumps the version in `package.json`
|
|
490
|
+
3. Creates a git commit and tag
|
|
491
|
+
4. Publishes to npm
|
|
492
|
+
|
|
493
|
+
After publishing, push the commit and tag:
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
git push && git push --tags
|
|
497
|
+
```
|
|
498
|
+
|
|
451
499
|
## Inspired By
|
|
452
500
|
|
|
453
501
|
- [get-shit-done](https://github.com/gsd-build/get-shit-done) — Structured file-based workflow orchestration for AI agents
|
package/bin/install.js
CHANGED
|
@@ -232,6 +232,7 @@ async function main() {
|
|
|
232
232
|
/brain:sunshine Deep forensic memory erasure
|
|
233
233
|
/brain:sleep Full maintenance cycle
|
|
234
234
|
/brain:status Brain overview dashboard
|
|
235
|
+
/brain:sync Cloud sync (Dropbox/Google Drive/OneDrive)
|
|
235
236
|
|
|
236
237
|
Get started by running /brain:init in your agent session.
|
|
237
238
|
`);
|
|
@@ -353,6 +354,9 @@ function initializeBrain() {
|
|
|
353
354
|
}
|
|
354
355
|
|
|
355
356
|
console.log(' .brain/ initialized successfully.');
|
|
357
|
+
console.log('');
|
|
358
|
+
console.log(' ☁️ Cloud sync is available! Use /brain:sync login to connect');
|
|
359
|
+
console.log(' Dropbox, Google Drive, or OneDrive for cross-device access.');
|
|
356
360
|
}
|
|
357
361
|
|
|
358
362
|
main().catch((err) => {
|
package/commands/brain/init.md
CHANGED
|
@@ -147,11 +147,3 @@ Print a summary of what was created, including the full tree structure. Inform t
|
|
|
147
147
|
- `/brain:status` — View brain overview
|
|
148
148
|
- `/brain:review` — Spaced repetition review of memories due for reinforcement
|
|
149
149
|
|
|
150
|
-
### Migration Note
|
|
151
|
-
|
|
152
|
-
If upgrading an existing v1 brain, the first `/brain:sleep` after upgrade will run a **Migration phase** (Phase 0) that:
|
|
153
|
-
- Creates `associations.json` from existing `related` fields
|
|
154
|
-
- Creates `contexts.json`, `review-queue.json`, and `_archived/index.json`
|
|
155
|
-
- Backfills `recall_history` from `access_count` (using `last_accessed` as sole entry)
|
|
156
|
-
- Sets default values for new frontmatter fields (`cognitive_type: semantic`, `salience: 0.5`, `confidence: 0.8`)
|
|
157
|
-
- Bumps `index.json` version to 2
|
|
@@ -67,7 +67,7 @@ effective_score = 0.38 * relevance
|
|
|
67
67
|
+ 0.08 * salience_bonus
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
**Note:** If a memory lacks
|
|
70
|
+
**Note:** If a memory lacks some fields (spreading_bonus, context_match, salience), the formula renormalizes weights across the available terms.
|
|
71
71
|
|
|
72
72
|
### 5. Decide Response Strategy
|
|
73
73
|
|
|
@@ -110,7 +110,7 @@ diminishingFactor = 1.0 / (1.0 + 0.1 * recallCount)
|
|
|
110
110
|
boost = 0.05 * spacingMultiplier * diminishingFactor
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
Examples: 1 day gap = +0.05
|
|
113
|
+
Examples: 1 day gap = +0.05, 7 days = +0.08, 30 days = +0.10, cramming same day 20th recall = +0.02.
|
|
114
114
|
|
|
115
115
|
**Update in both the memory file AND index.json:**
|
|
116
116
|
- `last_accessed` → current timestamp
|
package/commands/brain/sleep.md
CHANGED
|
@@ -18,24 +18,6 @@ Sleep performs nine phases, mimicking real neuroscience:
|
|
|
18
18
|
8. **REM Dreaming** — Discover creative cross-domain associations via analogical reasoning
|
|
19
19
|
9. **Expertise Detection** — Identify dense knowledge areas and generate expertise profiles
|
|
20
20
|
|
|
21
|
-
### Migration Phase (Phase 0)
|
|
22
|
-
|
|
23
|
-
If the brain's `index.json` has `version: 1` (pre-v2), run migration first:
|
|
24
|
-
|
|
25
|
-
1. Create `associations.json` from existing `related` fields — for each memory with `related` entries, create edges with weight 0.20 and origin `manual`
|
|
26
|
-
2. Auto-discover associations: for any two memories sharing 2+ tags, create edges with weight 0.10 and origin `tag_overlap`
|
|
27
|
-
3. Create `contexts.json` with `{"version": 1, "sessions": []}`
|
|
28
|
-
4. Create `review-queue.json` with `{"version": 1, "items": []}`
|
|
29
|
-
5. Create `_archived/index.json` if not present with `{"version": 1, "archived_count": 0, "memories": {}}`
|
|
30
|
-
6. For each memory: backfill `recall_history` from `access_count` (if `access_count > 0`, set `recall_history: [last_accessed]`; otherwise `recall_history: []`)
|
|
31
|
-
7. Set defaults for missing fields: `cognitive_type: "semantic"`, `salience: 0.5`, `confidence: 0.8`
|
|
32
|
-
8. Update both memory files (frontmatter) and `index.json` entries
|
|
33
|
-
9. Set `index.json` version to 2
|
|
34
|
-
|
|
35
|
-
Present migration summary, then proceed to Phase 1.
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
21
|
## Phase 1: Replay (Hippocampal Scan)
|
|
40
22
|
|
|
41
23
|
During sleep, the hippocampus replays the day's events. Here, we scan and assess the full brain state.
|
|
@@ -532,4 +514,3 @@ After all phases complete, present a comprehensive sleep report:
|
|
|
532
514
|
7. **Idempotent expertise** — if `_expertise.md` already exists, update it rather than creating a duplicate.
|
|
533
515
|
8. **Skip empty phases** — if there's nothing to do in a phase (e.g., no flat clusters to reorganize), briefly note it and move on.
|
|
534
516
|
9. **Salience protection** — never auto-prune memories with salience >= 0.7.
|
|
535
|
-
10. **Run migration** — if `index.json` version is 1, run Phase 0 migration before proceeding.
|
package/commands/brain/status.md
CHANGED
|
@@ -12,6 +12,8 @@ Also read (if they exist):
|
|
|
12
12
|
- `.brain/associations.json` — for association network stats
|
|
13
13
|
- `.brain/review-queue.json` — for review schedule info
|
|
14
14
|
- `.brain/_archived/index.json` — for archive stats
|
|
15
|
+
- `.brain/.sync/config.json` — for cloud sync configuration
|
|
16
|
+
- `.brain/.sync/sync-state.json` — for sync state and pending changes
|
|
15
17
|
|
|
16
18
|
### 2. Compute Statistics
|
|
17
19
|
|
|
@@ -104,6 +106,13 @@ Calculate aggregate stats:
|
|
|
104
106
|
+ <title> (<path>) — <date>
|
|
105
107
|
+ <title> (<path>) — <date>
|
|
106
108
|
...
|
|
109
|
+
|
|
110
|
+
## Cloud Sync
|
|
111
|
+
Provider: <provider or "not configured">
|
|
112
|
+
Encryption: <enabled/disabled>
|
|
113
|
+
Last Sync: <timestamp or "never">
|
|
114
|
+
Pending Changes: <count> files modified since last sync
|
|
115
|
+
Conflicts: <count>
|
|
107
116
|
```
|
|
108
117
|
|
|
109
118
|
### 4. Health Check
|
|
@@ -119,4 +128,6 @@ Analyze the brain's health and provide recommendations:
|
|
|
119
128
|
- **"Needs sleep"** — Multiple flat clusters detected, OR many memories in moderate/weak tiers, OR no `_expertise.md` profiles exist despite having 10+ memories. Suggest `/brain:sleep`
|
|
120
129
|
- **"Low confidence"** — More than 30% of memories have confidence < 0.5. Suggest reviewing and validating uncertain memories.
|
|
121
130
|
- **"Review overdue"** — More than 10 memories are past their review date. Suggest `/brain:review`
|
|
122
|
-
- **"
|
|
131
|
+
- **"Sync available"** — Cloud sync is not configured. Suggest `/brain:sync login` for cross-device access.
|
|
132
|
+
- **"Sync stale"** — Last sync was more than 7 days ago. Suggest `/brain:sync push` or `/brain:sync pull`.
|
|
133
|
+
- **"Sync conflicts"** — Unresolved sync conflicts exist. Suggest `/brain:sync resolve`.
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# /brain:sync — Cloud Sync
|
|
2
|
+
|
|
3
|
+
You are managing cloud synchronization for the Brain Memory system. This enables manual push/pull of `.brain/` memories to Dropbox, Google Drive, or OneDrive.
|
|
4
|
+
|
|
5
|
+
**CRITICAL RULES:**
|
|
6
|
+
- NEVER auto-sync — always require explicit user action
|
|
7
|
+
- NEVER silently overwrite files — always show a preview first
|
|
8
|
+
- NEVER display OAuth tokens, credentials, or secrets in output
|
|
9
|
+
- ALWAYS show what will change before executing push/pull
|
|
10
|
+
|
|
11
|
+
## Subcommands
|
|
12
|
+
|
|
13
|
+
Parse the user's input to determine the subcommand:
|
|
14
|
+
- `login [provider]` → Setup OAuth + configure sync
|
|
15
|
+
- `push` → Upload local changes to cloud
|
|
16
|
+
- `pull` → Download remote changes to local
|
|
17
|
+
- `status` → Show sync state and pending changes
|
|
18
|
+
- `logout` → Remove credentials and disconnect
|
|
19
|
+
- `resolve [file]` → Resolve a sync conflict
|
|
20
|
+
|
|
21
|
+
If no subcommand is given, show available subcommands.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## `/brain:sync login [provider]`
|
|
26
|
+
|
|
27
|
+
### Steps
|
|
28
|
+
|
|
29
|
+
1. **Check prerequisites:**
|
|
30
|
+
- Verify `.brain/` exists. If not, suggest `/brain:init` first.
|
|
31
|
+
- Check if sync is already configured (`.brain/.sync/config.json`). If so, ask if they want to reconfigure.
|
|
32
|
+
|
|
33
|
+
2. **Select provider** (if not specified):
|
|
34
|
+
- Present options: `dropbox`, `google-drive`, `onedrive`
|
|
35
|
+
- Explain each briefly:
|
|
36
|
+
- **Dropbox**: Simplest setup, App Folder isolation
|
|
37
|
+
- **Google Drive**: Uses hidden appDataFolder (invisible in Drive UI)
|
|
38
|
+
- **OneDrive**: Microsoft Graph API, App Folder isolation
|
|
39
|
+
|
|
40
|
+
3. **Get OAuth Client ID:**
|
|
41
|
+
- Explain that Brain Memory requires the user to register their own OAuth app
|
|
42
|
+
- Provide provider-specific instructions:
|
|
43
|
+
|
|
44
|
+
**Dropbox:**
|
|
45
|
+
- Go to https://www.dropbox.com/developers/apps
|
|
46
|
+
- Create app → Scoped access → App folder → Name it "BrainMemory"
|
|
47
|
+
- Under Permissions, enable: `files.metadata.read`, `files.metadata.write`, `files.content.read`, `files.content.write`
|
|
48
|
+
- Copy the App Key (this is the client ID)
|
|
49
|
+
- Add `http://127.0.0.1` to Redirect URIs (any port)
|
|
50
|
+
|
|
51
|
+
**Google Drive:**
|
|
52
|
+
- Go to https://console.cloud.google.com → Create project
|
|
53
|
+
- Enable "Google Drive API"
|
|
54
|
+
- Create OAuth 2.0 credentials → Desktop app
|
|
55
|
+
- Copy the Client ID
|
|
56
|
+
- Add `http://127.0.0.1` to Authorized redirect URIs
|
|
57
|
+
|
|
58
|
+
**OneDrive:**
|
|
59
|
+
- Go to https://portal.azure.com → App registrations
|
|
60
|
+
- New registration → Personal Microsoft accounts
|
|
61
|
+
- Add redirect URI: `http://localhost` (Mobile and desktop applications)
|
|
62
|
+
- Copy Application (client) ID
|
|
63
|
+
|
|
64
|
+
4. **Ask for Client ID** from the user.
|
|
65
|
+
|
|
66
|
+
5. **Ask about encryption** (optional):
|
|
67
|
+
- "Would you like to encrypt memories before uploading? (recommended for sensitive data)"
|
|
68
|
+
- If yes, ask for a passphrase (will be needed on every push/pull and on other devices)
|
|
69
|
+
|
|
70
|
+
6. **Run OAuth flow:**
|
|
71
|
+
- Use `setupSync()` from `src/sync/sync-engine.js`
|
|
72
|
+
- This will open the browser for authorization
|
|
73
|
+
- If in SSH/headless environment, offer Device Code Flow as alternative
|
|
74
|
+
|
|
75
|
+
7. **Show result:**
|
|
76
|
+
```
|
|
77
|
+
✓ Cloud sync configured!
|
|
78
|
+
Provider: [provider]
|
|
79
|
+
Account: [email/name]
|
|
80
|
+
Encryption: [enabled/disabled]
|
|
81
|
+
Remote files: [count]
|
|
82
|
+
|
|
83
|
+
Use /brain:sync push to upload your memories.
|
|
84
|
+
Use /brain:sync pull to download from cloud.
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## `/brain:sync push`
|
|
90
|
+
|
|
91
|
+
### Steps
|
|
92
|
+
|
|
93
|
+
1. **Check sync is configured.** If not, suggest `/brain:sync login`.
|
|
94
|
+
|
|
95
|
+
2. **Preview changes** (always show before executing):
|
|
96
|
+
- Use `push()` with `{ dryRun: true }` from `src/sync/sync-engine.js`
|
|
97
|
+
- Display summary:
|
|
98
|
+
```
|
|
99
|
+
📤 Push Preview:
|
|
100
|
+
Upload: [count] files ([new] new, [modified] modified)
|
|
101
|
+
Delete: [count] files (deleted locally)
|
|
102
|
+
Skip: [count] unchanged
|
|
103
|
+
⚠️ Conflicts: [count] (modified both locally and remotely)
|
|
104
|
+
```
|
|
105
|
+
- If there are conflicts, list them and explain options
|
|
106
|
+
|
|
107
|
+
3. **Ask for confirmation** before proceeding.
|
|
108
|
+
|
|
109
|
+
4. **Execute push:**
|
|
110
|
+
- Use `push()` from `src/sync/sync-engine.js`
|
|
111
|
+
- Show progress for each file
|
|
112
|
+
- Show final results:
|
|
113
|
+
```
|
|
114
|
+
✓ Push complete!
|
|
115
|
+
Uploaded: [count] files
|
|
116
|
+
Deleted: [count] files
|
|
117
|
+
Conflicts: [count] (use /brain:sync resolve to fix)
|
|
118
|
+
Errors: [count]
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## `/brain:sync pull`
|
|
124
|
+
|
|
125
|
+
### Steps
|
|
126
|
+
|
|
127
|
+
1. **Check sync is configured.**
|
|
128
|
+
|
|
129
|
+
2. **Preview changes** (always show before executing):
|
|
130
|
+
- Use `pull()` with `{ dryRun: true }`
|
|
131
|
+
- Display summary:
|
|
132
|
+
```
|
|
133
|
+
📥 Pull Preview:
|
|
134
|
+
Download: [count] files ([new] new, [modified] modified)
|
|
135
|
+
Delete: [count] files (deleted remotely)
|
|
136
|
+
Skip: [count] unchanged
|
|
137
|
+
⚠️ Conflicts: [count]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
3. **Ask for confirmation.**
|
|
141
|
+
|
|
142
|
+
4. **Execute pull:**
|
|
143
|
+
- Use `pull()` from `src/sync/sync-engine.js`
|
|
144
|
+
- Show results:
|
|
145
|
+
```
|
|
146
|
+
✓ Pull complete!
|
|
147
|
+
Downloaded: [count] files
|
|
148
|
+
Deleted: [count] files
|
|
149
|
+
Conflicts: [count]
|
|
150
|
+
Errors: [count]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## `/brain:sync status`
|
|
156
|
+
|
|
157
|
+
### Steps
|
|
158
|
+
|
|
159
|
+
1. **Read sync status** using `syncStatus()` from `src/sync/sync-engine.js`
|
|
160
|
+
|
|
161
|
+
2. **Display dashboard:**
|
|
162
|
+
```
|
|
163
|
+
☁️ Cloud Sync Status
|
|
164
|
+
─────────────────────
|
|
165
|
+
Provider: [provider]
|
|
166
|
+
Account: [account]
|
|
167
|
+
Connected: [yes/no]
|
|
168
|
+
Encryption: [enabled/disabled]
|
|
169
|
+
Last Sync: [timestamp or "never"]
|
|
170
|
+
Tracked Files: [count]
|
|
171
|
+
Pending Changes:[count] local files modified since last sync
|
|
172
|
+
|
|
173
|
+
Conflicts: [count]
|
|
174
|
+
[list conflict files if any]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## `/brain:sync logout`
|
|
180
|
+
|
|
181
|
+
### Steps
|
|
182
|
+
|
|
183
|
+
1. **Show current config** (provider, account).
|
|
184
|
+
2. **Ask for confirmation:** "This will remove stored credentials. Your cloud data will NOT be deleted."
|
|
185
|
+
3. **Execute:** Use `logout()` from `src/sync/sync-engine.js`
|
|
186
|
+
4. **Confirm:** "✓ Logged out from [provider]. Credentials removed."
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## `/brain:sync resolve [file]`
|
|
191
|
+
|
|
192
|
+
### Steps
|
|
193
|
+
|
|
194
|
+
1. **List conflicts** if no file specified using `listConflicts()`.
|
|
195
|
+
|
|
196
|
+
2. **For a specific file:**
|
|
197
|
+
- Show the conflict details (reason, local hash, remote hash)
|
|
198
|
+
- Present resolution options:
|
|
199
|
+
- **keep-local**: Push your local version (overwrites remote)
|
|
200
|
+
- **keep-remote**: Pull the remote version (overwrites local)
|
|
201
|
+
- **keep-both**: Save local as `filename.local.ext`, pull remote as `filename.ext`
|
|
202
|
+
|
|
203
|
+
3. **Execute resolution** using `resolveConflict()` from `src/sync/sync-engine.js`
|
|
204
|
+
|
|
205
|
+
4. **Show result:**
|
|
206
|
+
```
|
|
207
|
+
✓ Conflict resolved for [file]
|
|
208
|
+
Action: [description]
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Key Implementation Notes
|
|
214
|
+
|
|
215
|
+
- All sync functions are in `src/sync/sync-engine.js`
|
|
216
|
+
- Crypto utilities in `src/sync/crypto-utils.js`
|
|
217
|
+
- OAuth in `src/sync/oauth.js`
|
|
218
|
+
- Provider implementations in `src/sync/providers/`
|
|
219
|
+
- Sync state stored in `.brain/.sync/` (never synced to cloud)
|
|
220
|
+
- Uses three-way diff: local state vs remote state vs last-known sync state
|
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.4",
|
|
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",
|
|
@@ -37,7 +37,12 @@
|
|
|
37
37
|
"url": "git+https://github.com/onurkarali/brain.git"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
|
-
"test": "node --test test/index-manager.test.js test/scorer.test.js test/functional.test.js test/sunshine.test.js test/stress.test.js"
|
|
40
|
+
"test": "node --test test/index-manager.test.js test/scorer.test.js test/functional.test.js test/sunshine.test.js test/stress.test.js test/oauth.test.js test/sync-provider.test.js test/sync-engine.test.js",
|
|
41
|
+
"prerelease": "npm test",
|
|
42
|
+
"release:beta": "npm version prerelease --preid beta && npm publish --tag beta",
|
|
43
|
+
"release:patch": "npm version patch && npm publish",
|
|
44
|
+
"release:minor": "npm version minor && npm publish",
|
|
45
|
+
"release:major": "npm version major && npm publish"
|
|
41
46
|
},
|
|
42
47
|
"license": "MIT",
|
|
43
48
|
"engines": {
|
package/prompts/claude.md
CHANGED
|
@@ -58,6 +58,7 @@ Memories store their encoding context (project, topics, task type). During recal
|
|
|
58
58
|
- `/brain:sunshine [target]` — Deep forensic erasure — trace and remove all references to a memory
|
|
59
59
|
- `/brain:sleep [scope]` — Full maintenance cycle: replay, synaptic homeostasis, knowledge propagation, semantic crystallization, reorganize, consolidate, prune, REM dreaming, and expertise detection
|
|
60
60
|
- `/brain:status` — Dashboard with brain health overview
|
|
61
|
+
- `/brain:sync [subcommand]` — Cloud sync: push/pull memories to Dropbox, Google Drive, or OneDrive
|
|
61
62
|
|
|
62
63
|
## Auto-Memorize Guidance
|
|
63
64
|
|
|
@@ -73,3 +74,7 @@ When the user asks you to "remember" something, or when context from past sessio
|
|
|
73
74
|
5. Apply spaced reinforcement (spacing-aware boost) and improve decay rate
|
|
74
75
|
6. Strengthen Hebbian links between co-retrieved memories
|
|
75
76
|
7. If no active matches, search the archive (`.brain/_archived/`)
|
|
77
|
+
|
|
78
|
+
## Cloud Sync
|
|
79
|
+
|
|
80
|
+
Brain memories can be synced across devices via `/brain:sync`. Supports Dropbox, Google Drive, and OneDrive with optional AES-256-GCM encryption. Sync is always manual (push/pull) — never automatic. Run `/brain:sync login` to set up, then use `/brain:sync push` and `/brain:sync pull` to keep memories in sync.
|
package/prompts/gemini.md
CHANGED
|
@@ -59,6 +59,7 @@ Commands are available via `/brain:` prefix:
|
|
|
59
59
|
- `/brain:sunshine [target]` — Deep forensic erasure — trace and remove all references to a memory
|
|
60
60
|
- `/brain:sleep [scope]` — Full maintenance cycle: replay, synaptic homeostasis, knowledge propagation, semantic crystallization, reorganize, consolidate, prune, REM dreaming, and expertise detection
|
|
61
61
|
- `/brain:status` — Dashboard with brain health overview
|
|
62
|
+
- `/brain:sync [subcommand]` — Cloud sync: push/pull memories to Dropbox, Google Drive, or OneDrive
|
|
62
63
|
|
|
63
64
|
## Auto-Memorize Guidance
|
|
64
65
|
|
|
@@ -74,3 +75,7 @@ When the user asks you to "remember" something, or when context from past sessio
|
|
|
74
75
|
5. Apply spaced reinforcement (spacing-aware boost) and improve decay rate
|
|
75
76
|
6. Strengthen Hebbian links between co-retrieved memories
|
|
76
77
|
7. If no active matches, search the archive (`.brain/_archived/`)
|
|
78
|
+
|
|
79
|
+
## Cloud Sync
|
|
80
|
+
|
|
81
|
+
Brain memories can be synced across devices via `/brain:sync`. Supports Dropbox, Google Drive, and OneDrive with optional AES-256-GCM encryption. Sync is always manual (push/pull) — never automatic. Run `/brain:sync login` to set up, then use `/brain:sync push` and `/brain:sync pull` to keep memories in sync.
|
package/prompts/openai.md
CHANGED
|
@@ -59,6 +59,7 @@ Brain skills are available via `/brain-` prefix:
|
|
|
59
59
|
- `/brain-sunshine [target]` — Deep forensic erasure — trace and remove all references to a memory
|
|
60
60
|
- `/brain-sleep [scope]` — Full maintenance cycle: replay, synaptic homeostasis, knowledge propagation, semantic crystallization, reorganize, consolidate, prune, REM dreaming, and expertise detection
|
|
61
61
|
- `/brain-status` — Dashboard with brain health overview
|
|
62
|
+
- `/brain-sync [subcommand]` — Cloud sync: push/pull memories to Dropbox, Google Drive, or OneDrive
|
|
62
63
|
|
|
63
64
|
## Auto-Memorize Guidance
|
|
64
65
|
|
|
@@ -74,3 +75,7 @@ When the user asks you to "remember" something, or when context from past sessio
|
|
|
74
75
|
5. Apply spaced reinforcement (spacing-aware boost) and improve decay rate
|
|
75
76
|
6. Strengthen Hebbian links between co-retrieved memories
|
|
76
77
|
7. If no active matches, search the archive (`.brain/_archived/`)
|
|
78
|
+
|
|
79
|
+
## Cloud Sync
|
|
80
|
+
|
|
81
|
+
Brain memories can be synced across devices via `/brain-sync`. Supports Dropbox, Google Drive, and OneDrive with optional AES-256-GCM encryption. Sync is always manual (push/pull) — never automatic. Run `/brain-sync login` to set up, then use `/brain-sync push` and `/brain-sync pull` to keep memories in sync.
|