brain-memory 0.1.0-beta.2 → 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 +272 -72
- package/assets/icon.png +0 -0
- package/assets/icon.svg +27 -0
- package/bin/brain.js +111 -0
- package/bin/cloud-sync.js +149 -0
- package/bin/install.js +217 -242
- package/bin/memorize.js +436 -0
- package/bin/pin.js +44 -0
- package/bin/recall.js +237 -0
- package/bin/reinforce.js +187 -0
- package/bin/session-start.js +292 -0
- package/bin/skill.js +67 -0
- package/bin/unpin.js +38 -0
- package/commands/brain/consolidate.md +7 -2
- package/commands/brain/explore.md +7 -2
- package/commands/brain/forget.md +7 -2
- package/commands/brain/init.md +8 -12
- package/commands/brain/memorize.md +76 -144
- package/commands/brain/pin.md +37 -0
- package/commands/brain/remember.md +48 -105
- package/commands/brain/review.md +7 -2
- package/commands/brain/skills.md +60 -0
- package/commands/brain/sleep.md +68 -27
- package/commands/brain/status.md +19 -5
- package/commands/brain/sunshine.md +18 -13
- package/commands/brain/sync.md +360 -0
- package/commands/brain/unpin.md +26 -0
- package/package.json +18 -8
- package/prompts/claude.md +115 -12
- package/prompts/gemini.md +115 -12
- package/prompts/openai.md +113 -10
- package/prompts/opencode.md +178 -0
- package/src/cloud-sync.js +534 -0
- package/src/crypto.js +130 -0
- package/src/export-import.js +200 -0
- package/src/git-sync.js +444 -0
- package/src/index-manager.js +205 -18
- package/src/installer.js +384 -0
- package/src/pinning.js +124 -0
- package/src/scorer.js +8 -2
- package/src/skills.js +208 -0
- package/src/tfidf.js +408 -0
- package/hooks/session-end.md +0 -48
- package/hooks/session-start.md +0 -48
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* brain cloud — CLI for Brain Cloud sync
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* brain cloud login [--api-url URL] Authenticate via device code flow
|
|
8
|
+
* brain cloud logout Clear stored credentials
|
|
9
|
+
* brain cloud push Upload ~/.brain/ to the cloud
|
|
10
|
+
* brain cloud pull Download from the cloud to ~/.brain/
|
|
11
|
+
* brain cloud status Show connection and sync status
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const os = require('os');
|
|
16
|
+
const cloud = require('../src/cloud-sync');
|
|
17
|
+
|
|
18
|
+
const BRAIN_DIR = path.join(os.homedir(), '.brain');
|
|
19
|
+
|
|
20
|
+
async function main() {
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
const command = args[0];
|
|
23
|
+
|
|
24
|
+
if (!command || command === '--help' || command === '-h') {
|
|
25
|
+
console.log(`
|
|
26
|
+
brain cloud — Brain Cloud sync CLI
|
|
27
|
+
|
|
28
|
+
Commands:
|
|
29
|
+
login [--api-url URL] Authenticate via device code flow
|
|
30
|
+
logout Clear stored credentials
|
|
31
|
+
push Upload ~/.brain/ to the cloud
|
|
32
|
+
pull Download from the cloud to ~/.brain/
|
|
33
|
+
status Show connection and sync status
|
|
34
|
+
`.trim());
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
switch (command) {
|
|
39
|
+
case 'login':
|
|
40
|
+
await cmdLogin(args);
|
|
41
|
+
break;
|
|
42
|
+
case 'logout':
|
|
43
|
+
cmdLogout();
|
|
44
|
+
break;
|
|
45
|
+
case 'push':
|
|
46
|
+
await cmdPush();
|
|
47
|
+
break;
|
|
48
|
+
case 'pull':
|
|
49
|
+
await cmdPull();
|
|
50
|
+
break;
|
|
51
|
+
case 'status':
|
|
52
|
+
await cmdStatus();
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
console.error(`Unknown command: ${command}`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function cmdLogin(args) {
|
|
61
|
+
let apiUrl;
|
|
62
|
+
const urlIdx = args.indexOf('--api-url');
|
|
63
|
+
if (urlIdx !== -1 && args[urlIdx + 1]) {
|
|
64
|
+
apiUrl = args[urlIdx + 1];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log('Requesting device code...');
|
|
68
|
+
const loginInfo = await cloud.login(BRAIN_DIR, apiUrl);
|
|
69
|
+
|
|
70
|
+
console.log();
|
|
71
|
+
console.log(' Open this URL in your browser to log in:');
|
|
72
|
+
console.log();
|
|
73
|
+
console.log(` ${loginInfo.verify_url}`);
|
|
74
|
+
console.log();
|
|
75
|
+
console.log(` Your code: ${loginInfo.user_code}`);
|
|
76
|
+
console.log();
|
|
77
|
+
console.log(` Waiting for approval (expires in ${Math.floor(loginInfo.expires_in / 60)} min)...`);
|
|
78
|
+
|
|
79
|
+
await loginInfo.waitForApproval();
|
|
80
|
+
|
|
81
|
+
const config = cloud.readConfig(BRAIN_DIR);
|
|
82
|
+
console.log();
|
|
83
|
+
console.log(`✓ Logged in as ${config.user_email || 'unknown'}`);
|
|
84
|
+
if (config.brain_id) {
|
|
85
|
+
console.log(` Brain ID: ${config.brain_id}`);
|
|
86
|
+
}
|
|
87
|
+
console.log(` API: ${config.api_url}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function cmdLogout() {
|
|
91
|
+
cloud.logout(BRAIN_DIR);
|
|
92
|
+
console.log('✓ Logged out. Credentials cleared.');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function cmdPush() {
|
|
96
|
+
console.log('Packing ~/.brain/ ...');
|
|
97
|
+
const result = await cloud.push(BRAIN_DIR);
|
|
98
|
+
console.log();
|
|
99
|
+
console.log('✓ Push complete!');
|
|
100
|
+
console.log(` Size: ${formatBytes(result.size_bytes)}`);
|
|
101
|
+
console.log(` Files: ${result.file_count}`);
|
|
102
|
+
console.log(` Checksum: ${result.checksum}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function cmdPull() {
|
|
106
|
+
console.log('Downloading from cloud...');
|
|
107
|
+
const result = await cloud.pull(BRAIN_DIR);
|
|
108
|
+
console.log();
|
|
109
|
+
console.log('✓ Pull complete!');
|
|
110
|
+
console.log(` Size: ${formatBytes(result.size_bytes)}`);
|
|
111
|
+
if (result.checksum) {
|
|
112
|
+
console.log(` Checksum: ${result.checksum}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function cmdStatus() {
|
|
117
|
+
const s = await cloud.status(BRAIN_DIR);
|
|
118
|
+
|
|
119
|
+
if (!s.connected) {
|
|
120
|
+
console.log('☁️ Not connected to Brain Cloud');
|
|
121
|
+
console.log(' Run: brain cloud login');
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
console.log('☁️ Brain Cloud Status');
|
|
126
|
+
console.log('─────────────────────────');
|
|
127
|
+
console.log(` API: ${s.api_url}`);
|
|
128
|
+
console.log(` User: ${s.user_email || 'unknown'}`);
|
|
129
|
+
console.log(` Brain ID: ${s.brain_id || 'none'}`);
|
|
130
|
+
if (s.brain_name) console.log(` Brain Name: ${s.brain_name}`);
|
|
131
|
+
if (s.brain_size !== null) console.log(` Cloud Size: ${formatBytes(s.brain_size)}`);
|
|
132
|
+
if (s.brain_files !== null) console.log(` Cloud Files: ${s.brain_files}`);
|
|
133
|
+
console.log(` Last Push: ${s.last_push || 'never'}`);
|
|
134
|
+
console.log(` Last Pull: ${s.last_pull || 'never'}`);
|
|
135
|
+
console.log(` Last Synced: ${s.last_synced || 'never'}`);
|
|
136
|
+
console.log(` Connected: ${s.connected_at || 'unknown'}`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function formatBytes(bytes) {
|
|
140
|
+
if (bytes === 0 || bytes === null || bytes === undefined) return '0 B';
|
|
141
|
+
const units = ['B', 'KB', 'MB', 'GB'];
|
|
142
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
143
|
+
return `${(bytes / Math.pow(1024, i)).toFixed(i === 0 ? 0 : 1)} ${units[i]}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
main().catch((err) => {
|
|
147
|
+
console.error(`Error: ${err.message}`);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
});
|