brain-memory 0.1.0-beta.8 → 0.1.0
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/CHANGELOG.md +555 -0
- package/README.md +411 -61
- package/SECURITY.md +100 -0
- package/assets/brand/README.md +28 -0
- package/assets/brand/icon-dark.svg +19 -0
- package/assets/brand/icon-light.svg +20 -0
- package/assets/brand/linkedin_cover.png +0 -0
- package/assets/brand/linkedin_cover_light.png +0 -0
- package/assets/brand/mark-dark.svg +19 -0
- package/assets/brand/mark-light.svg +20 -0
- package/assets/brand/png/icon-dark-1024.png +0 -0
- package/assets/brand/png/icon-dark-128.png +0 -0
- package/assets/brand/png/icon-dark-256.png +0 -0
- package/assets/brand/png/icon-dark-512.png +0 -0
- package/assets/brand/png/icon-dark-64.png +0 -0
- package/assets/brand/png/icon-light-1024.png +0 -0
- package/assets/brand/png/icon-light-128.png +0 -0
- package/assets/brand/png/icon-light-256.png +0 -0
- package/assets/brand/png/icon-light-512.png +0 -0
- package/assets/brand/png/icon-light-64.png +0 -0
- package/assets/brand/png/mark-dark-1024.png +0 -0
- package/assets/brand/png/mark-light-1024.png +0 -0
- package/assets/icon.png +0 -0
- package/assets/icon.svg +19 -0
- package/bin/audit.js +93 -0
- package/bin/brain.js +132 -0
- package/bin/cloud-sync.js +150 -0
- package/bin/forget.js +163 -0
- package/bin/import.js +132 -0
- package/bin/install.js +63 -31
- package/bin/memorize.js +637 -0
- package/bin/pin.js +44 -0
- package/bin/recall.js +287 -0
- package/bin/reinforce.js +191 -0
- package/bin/restore.js +122 -0
- package/bin/session-start.js +337 -0
- package/bin/skill.js +67 -0
- package/bin/unpin.js +38 -0
- package/bin/verify.js +154 -0
- package/commands/brain/forget.md +243 -13
- package/commands/brain/import.md +125 -0
- package/commands/brain/memorize.md +95 -137
- package/commands/brain/pin.md +79 -0
- package/commands/brain/remember.md +53 -103
- package/commands/brain/skills.md +60 -0
- package/commands/brain/sleep.md +93 -6
- package/commands/brain/status.md +15 -6
- package/commands/brain/sync.md +181 -17
- package/commands/brain/verify.md +57 -0
- package/integrations/README.md +29 -0
- package/integrations/agentskills/brain-memory/SKILL.md +115 -0
- package/integrations/agentskills/brain-memory/scripts/session-start.mjs +34 -0
- package/package.json +20 -7
- package/prompts/antigravity.md +201 -0
- package/prompts/claude.md +107 -40
- package/prompts/copilot.md +203 -0
- package/prompts/kilo.md +202 -0
- package/prompts/openai.md +112 -45
- package/prompts/opencode.md +200 -0
- package/src/anomaly.js +260 -0
- package/src/audit.js +71 -0
- package/src/cloud-sync.js +672 -0
- package/src/content-lint.js +118 -0
- package/src/export-import.js +45 -7
- package/src/git-sync.js +170 -11
- package/src/harvest.js +562 -0
- package/src/index-manager.js +250 -11
- package/src/installer.js +250 -29
- package/src/pinning.js +146 -0
- package/src/provenance.js +79 -0
- package/src/quarantine.js +111 -0
- package/src/receipt.js +81 -0
- package/src/scorer.js +69 -12
- package/src/skills.js +208 -0
- package/src/tfidf.js +520 -0
- package/commands/brain/consolidate.md +0 -153
- package/commands/brain/explore.md +0 -79
- package/commands/brain/init.md +0 -149
- package/commands/brain/review.md +0 -130
- package/commands/brain/sunshine.md +0 -337
- package/prompts/gemini.md +0 -134
package/bin/forget.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* brain forget <id> — archive a memory (recoverable). Deterministic helper used
|
|
5
|
+
* by the connector's `brain_forget` tool and by `brain verify reject`. Honors
|
|
6
|
+
* BRAIN_DIR.
|
|
7
|
+
*
|
|
8
|
+
* Archive (default): move the memory file into `_archived/`, record it in
|
|
9
|
+
* `_archived/index.json`, and remove it from the live index, associations,
|
|
10
|
+
* review queue, and search index — so it stops surfacing in recall but stays
|
|
11
|
+
* recoverable. Deep / forensic erasure remains the agent-driven `/brain:forget
|
|
12
|
+
* --deep` path; this primitive only archives.
|
|
13
|
+
*
|
|
14
|
+
* Every archival is recorded in audit.log (event: 'forget') — removal changes
|
|
15
|
+
* what the brain believes just as much as a write does.
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
* BRAIN_DIR=/path/to/.brain node bin/forget.js mem_20260101_abc123
|
|
19
|
+
*
|
|
20
|
+
* Output: JSON describing the result.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const path = require('path');
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
getBrainDir,
|
|
28
|
+
readIndex, writeIndex, removeMemory,
|
|
29
|
+
readAssociations, writeAssociations, removeEdgesForMemory,
|
|
30
|
+
readReviewQueue, writeReviewQueue, removeFromReviewQueue,
|
|
31
|
+
readArchiveIndex, writeArchiveIndex,
|
|
32
|
+
validateBrainPath,
|
|
33
|
+
} = require('../src/index-manager');
|
|
34
|
+
// Search-index helpers take (brainDir) — the same signature memorize/recall use.
|
|
35
|
+
// (index-manager exports same-named helpers with a (projectRoot) signature that
|
|
36
|
+
// re-appends `.brain`, which would silently no-op the search-index update here.)
|
|
37
|
+
const { removeDocument, readSearchIndex, writeSearchIndex } = require('../src/tfidf');
|
|
38
|
+
const { appendAudit } = require('../src/audit');
|
|
39
|
+
|
|
40
|
+
// CoALA salience protection: high-salience memories are "never auto-pruned"
|
|
41
|
+
// (the documented guarantee). Enforced deterministically here — the only
|
|
42
|
+
// archival primitive — instead of relying on the agent to honor it.
|
|
43
|
+
const SALIENCE_FLOOR = 0.7;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Archive one memory. The shared primitive behind `brain forget` and
|
|
47
|
+
* `brain verify reject`.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} brainDir - Path to ~/.brain/
|
|
50
|
+
* @param {string} id - Memory ID
|
|
51
|
+
* @param {Object} [opts] - { force = false, reason = 'forget' }
|
|
52
|
+
* @returns {Object} { archived, id, title, memory_count } or { error, protected? }
|
|
53
|
+
*/
|
|
54
|
+
function archiveMemory(brainDir, id, opts = {}) {
|
|
55
|
+
const { force = false, reason = 'forget' } = opts;
|
|
56
|
+
|
|
57
|
+
const index = readIndex();
|
|
58
|
+
if (!index) return { error: 'Brain not initialized.' };
|
|
59
|
+
const entry = index.memories[id];
|
|
60
|
+
if (!entry) return { error: `Memory not found: ${id}` };
|
|
61
|
+
|
|
62
|
+
if (!force && typeof entry.salience === 'number' && entry.salience >= SALIENCE_FLOOR) {
|
|
63
|
+
return {
|
|
64
|
+
error: `Refusing to archive high-salience memory ${id} (salience ${entry.salience} >= ${SALIENCE_FLOOR}). Pass --force to override.`,
|
|
65
|
+
protected: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const now = new Date().toISOString();
|
|
70
|
+
|
|
71
|
+
// 1. Move the memory file into _archived/ (recoverable). The path comes
|
|
72
|
+
// from index.json (which syncs), so validate both ends — a tampered entry
|
|
73
|
+
// must not turn archival into an arbitrary file move. On violation the file
|
|
74
|
+
// move is skipped; index removal below still proceeds.
|
|
75
|
+
let archivedPath = null;
|
|
76
|
+
if (entry.path) {
|
|
77
|
+
const src = path.join(brainDir, entry.path);
|
|
78
|
+
const dest = path.join(brainDir, '_archived', entry.path);
|
|
79
|
+
try {
|
|
80
|
+
validateBrainPath(src, brainDir);
|
|
81
|
+
validateBrainPath(dest, brainDir);
|
|
82
|
+
if (fs.existsSync(src)) {
|
|
83
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
84
|
+
fs.renameSync(src, dest);
|
|
85
|
+
archivedPath = path.join('_archived', entry.path);
|
|
86
|
+
}
|
|
87
|
+
} catch (_) { /* path violation — leave the file untouched */ }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 2. Record in the archive index.
|
|
91
|
+
const arch = readArchiveIndex() || { version: 1, archived_count: 0, memories: {} };
|
|
92
|
+
arch.memories[id] = {
|
|
93
|
+
path: entry.path, archived_path: archivedPath, title: entry.title, type: entry.type,
|
|
94
|
+
cognitive_type: entry.cognitive_type, strength: entry.strength, salience: entry.salience,
|
|
95
|
+
confidence: entry.confidence, tags: entry.tags || [], archived_date: now, archived_reason: reason,
|
|
96
|
+
};
|
|
97
|
+
arch.archived_count = Object.keys(arch.memories).length;
|
|
98
|
+
writeArchiveIndex(arch);
|
|
99
|
+
|
|
100
|
+
// 3. Remove from the live index.
|
|
101
|
+
removeMemory(index, id);
|
|
102
|
+
writeIndex(index);
|
|
103
|
+
|
|
104
|
+
// 4. Remove association edges.
|
|
105
|
+
const assoc = readAssociations() || { version: 1, edges: {} };
|
|
106
|
+
removeEdgesForMemory(assoc, id);
|
|
107
|
+
writeAssociations(assoc);
|
|
108
|
+
|
|
109
|
+
// 5. Remove from the review queue.
|
|
110
|
+
const queue = readReviewQueue();
|
|
111
|
+
if (queue) {
|
|
112
|
+
removeFromReviewQueue(queue, id);
|
|
113
|
+
writeReviewQueue(queue);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 6. Remove from the search index (so it stops being recalled).
|
|
117
|
+
const searchIndex = readSearchIndex(brainDir);
|
|
118
|
+
if (searchIndex) {
|
|
119
|
+
removeDocument(searchIndex, id);
|
|
120
|
+
writeSearchIndex(brainDir, searchIndex);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 7. Audit trail. Best-effort: the archival already happened; losing the
|
|
124
|
+
// trail is worse surfaced than thrown.
|
|
125
|
+
let auditError = null;
|
|
126
|
+
try {
|
|
127
|
+
appendAudit(brainDir, {
|
|
128
|
+
ts: now, event: 'forget', id, title: entry.title, path: entry.path,
|
|
129
|
+
origin: entry.origin, salience: entry.salience, reason, forced: force,
|
|
130
|
+
});
|
|
131
|
+
} catch (err) {
|
|
132
|
+
auditError = err.message;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
archived: true, id, title: entry.title, memory_count: index.memory_count,
|
|
137
|
+
...(auditError ? { audit_error: auditError } : {}),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function main(argv) {
|
|
142
|
+
const args = argv || process.argv.slice(2);
|
|
143
|
+
const id = args.find((a) => a && !a.startsWith('--'));
|
|
144
|
+
const force = args.includes('--force');
|
|
145
|
+
if (!id) {
|
|
146
|
+
console.error(JSON.stringify({ error: 'Usage: brain forget <id> [--force]' }));
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const brainDir = getBrainDir();
|
|
151
|
+
const result = archiveMemory(brainDir, id, { force });
|
|
152
|
+
if (result.error) {
|
|
153
|
+
console.error(JSON.stringify(result));
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
console.log(JSON.stringify(result));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (require.main === module) {
|
|
160
|
+
main(process.argv.slice(2));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
module.exports = { main, archiveMemory, SALIENCE_FLOOR };
|
package/bin/import.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* brain import — cold-start a brain from transcripts your agents already wrote.
|
|
5
|
+
*
|
|
6
|
+
* Emits a deterministic, budget-bounded digest of past sessions. The agent reads
|
|
7
|
+
* that digest and writes memories through the ordinary `brain memorize` path, so
|
|
8
|
+
* imported memories go through the same provenance gate, scoring, and index as
|
|
9
|
+
* anything else. Nothing here writes a memory.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* brain import [--source claude-code] [--project P] [--since ISO] [--limit N] [--all]
|
|
13
|
+
* brain import --sources List detected history stores
|
|
14
|
+
* brain import --mark <id> [<id>...] Record sessions as imported
|
|
15
|
+
*
|
|
16
|
+
* The `--mark` step is what makes import incremental: the agent calls it after a
|
|
17
|
+
* successful memorize so the next run offers only new sessions.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
|
|
23
|
+
const { getBrainDir } = require('../src/index-manager');
|
|
24
|
+
const { harvest, availableSources, markImported } = require('../src/harvest');
|
|
25
|
+
|
|
26
|
+
function parseArgs(argv) {
|
|
27
|
+
const args = {
|
|
28
|
+
source: 'claude-code',
|
|
29
|
+
project: null,
|
|
30
|
+
since: null,
|
|
31
|
+
limit: null,
|
|
32
|
+
all: false,
|
|
33
|
+
sources: false,
|
|
34
|
+
mark: [],
|
|
35
|
+
};
|
|
36
|
+
for (let i = 0; i < argv.length; i++) {
|
|
37
|
+
switch (argv[i]) {
|
|
38
|
+
case '--source': args.source = argv[++i]; break;
|
|
39
|
+
case '--project': args.project = argv[++i]; break;
|
|
40
|
+
case '--since': args.since = argv[++i]; break;
|
|
41
|
+
case '--limit': args.limit = parseInt(argv[++i], 10) || null; break;
|
|
42
|
+
case '--all': args.all = true; break;
|
|
43
|
+
case '--sources': args.sources = true; break;
|
|
44
|
+
case '--mark':
|
|
45
|
+
// Consume every following non-flag token as a session id.
|
|
46
|
+
while (argv[i + 1] && !argv[i + 1].startsWith('--')) args.mark.push(argv[++i]);
|
|
47
|
+
break;
|
|
48
|
+
default: break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return args;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Normalize `--since` into an ISO timestamp.
|
|
56
|
+
*
|
|
57
|
+
* Accepts a relative shorthand (`30d`, `6m`, `1y`) as well as any date string
|
|
58
|
+
* Date can parse, because "the last month of work" is the natural way to scope
|
|
59
|
+
* an import and computing that date by hand is friction.
|
|
60
|
+
*/
|
|
61
|
+
function normalizeSince(value) {
|
|
62
|
+
if (!value) return null;
|
|
63
|
+
const relative = /^(\d+)([dmy])$/i.exec(value.trim());
|
|
64
|
+
if (relative) {
|
|
65
|
+
const amount = parseInt(relative[1], 10);
|
|
66
|
+
const date = new Date();
|
|
67
|
+
if (relative[2].toLowerCase() === 'd') date.setDate(date.getDate() - amount);
|
|
68
|
+
if (relative[2].toLowerCase() === 'm') date.setMonth(date.getMonth() - amount);
|
|
69
|
+
if (relative[2].toLowerCase() === 'y') date.setFullYear(date.getFullYear() - amount);
|
|
70
|
+
return date.toISOString();
|
|
71
|
+
}
|
|
72
|
+
const parsed = new Date(value);
|
|
73
|
+
if (Number.isNaN(parsed.getTime())) return null;
|
|
74
|
+
return parsed.toISOString();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function main(argv = process.argv.slice(2)) {
|
|
78
|
+
const args = parseArgs(argv);
|
|
79
|
+
|
|
80
|
+
if (args.sources) {
|
|
81
|
+
console.log(JSON.stringify({ sources: availableSources() }, null, 2));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// A brain must exist before we offer to fill it — otherwise the agent gets a
|
|
86
|
+
// digest it has nowhere to write.
|
|
87
|
+
const brainDir = getBrainDir();
|
|
88
|
+
if (!fs.existsSync(path.join(brainDir, 'index.json'))) {
|
|
89
|
+
console.error(JSON.stringify({ error: 'Brain not initialized. Run `brain install` first.' }));
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (args.mark.length > 0) {
|
|
94
|
+
const result = markImported(args.source, args.mark);
|
|
95
|
+
console.log(JSON.stringify({
|
|
96
|
+
marked: args.mark.length - result.unknown.length,
|
|
97
|
+
...result,
|
|
98
|
+
source: args.source,
|
|
99
|
+
...(result.unknown.length
|
|
100
|
+
? { warning: `${result.unknown.length} id(s) matched no ${args.source} session and were not recorded — check for a truncated or mistyped session id.` }
|
|
101
|
+
: {}),
|
|
102
|
+
}, null, 2));
|
|
103
|
+
// A partial mark is a real failure: the caller believes those sessions are
|
|
104
|
+
// done, and nothing else will ever tell them otherwise.
|
|
105
|
+
if (result.unknown.length > 0) process.exit(1);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (args.since && !normalizeSince(args.since)) {
|
|
110
|
+
console.error(JSON.stringify({ error: `Could not parse --since "${args.since}" (try 30d, 6m, or 2026-01-01)` }));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const digest = harvest({
|
|
115
|
+
source: args.source,
|
|
116
|
+
project: args.project,
|
|
117
|
+
since: normalizeSince(args.since),
|
|
118
|
+
limit: args.limit,
|
|
119
|
+
all: args.all,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (digest.error) {
|
|
123
|
+
console.error(JSON.stringify({ error: digest.error }));
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
console.log(JSON.stringify(digest, null, 2));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (require.main === module) main();
|
|
131
|
+
|
|
132
|
+
module.exports = { main, parseArgs, normalizeSince };
|
package/bin/install.js
CHANGED
|
@@ -49,9 +49,16 @@ function parseArgs(argv) {
|
|
|
49
49
|
function resolveRuntimesFromFlags(flags) {
|
|
50
50
|
const runtimes = [];
|
|
51
51
|
if (flags.has('claude')) runtimes.push('claude');
|
|
52
|
-
if (flags.has('gemini')) runtimes.push('gemini');
|
|
53
52
|
if (flags.has('openai') || flags.has('codex')) runtimes.push('openai');
|
|
54
|
-
if (flags.has('
|
|
53
|
+
if (flags.has('opencode')) runtimes.push('opencode');
|
|
54
|
+
if (flags.has('antigravity')) runtimes.push('antigravity');
|
|
55
|
+
if (flags.has('copilot')) runtimes.push('copilot');
|
|
56
|
+
if (flags.has('kilo')) runtimes.push('kilo');
|
|
57
|
+
// --all installs the verified CLIs. Antigravity stays opt-in (--antigravity)
|
|
58
|
+
// because its native paths are experimental / pending live verification.
|
|
59
|
+
// Copilot's paths come from official GA docs but stay opt-in (--copilot)
|
|
60
|
+
// until confirmed against a live install.
|
|
61
|
+
if (flags.has('all')) return ['claude', 'openai', 'opencode'];
|
|
55
62
|
return runtimes;
|
|
56
63
|
}
|
|
57
64
|
|
|
@@ -61,6 +68,19 @@ function resolveScopeFromFlags(flags) {
|
|
|
61
68
|
return null;
|
|
62
69
|
}
|
|
63
70
|
|
|
71
|
+
// Kilo's global prompt must be listed in the `instructions` array of
|
|
72
|
+
// kilo.jsonc; the installer only edits that file when it can do so safely
|
|
73
|
+
// (strict JSON, no comments). Otherwise, tell the user the one manual step.
|
|
74
|
+
function warnIfManualRegistration(result, config) {
|
|
75
|
+
const reg = result.promptRegistration;
|
|
76
|
+
if (reg && reg.manual) {
|
|
77
|
+
const configPath = `${config.globalDir}/${config.instructionsConfig}`;
|
|
78
|
+
const promptPath = `${config.globalDir}/${config.promptFile}`;
|
|
79
|
+
console.log(` ⚠ Could not edit ${configPath} safely (${reg.reason}).`);
|
|
80
|
+
console.log(` Add "${promptPath}" to its "instructions" array to activate the global prompt.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
64
84
|
// ---------------------------------------------------------------------------
|
|
65
85
|
// Install (original behavior, refactored from main)
|
|
66
86
|
// ---------------------------------------------------------------------------
|
|
@@ -73,41 +93,53 @@ async function runInstall(flags) {
|
|
|
73
93
|
try {
|
|
74
94
|
// Interactive runtime selection
|
|
75
95
|
if (runtimes.length === 0) {
|
|
76
|
-
console.log('
|
|
77
|
-
console.log('
|
|
78
|
-
console.log('
|
|
79
|
-
console.log('
|
|
80
|
-
console.log('
|
|
96
|
+
console.log(' Which runtimes would you like to install for?\n');
|
|
97
|
+
console.log(' 1) Claude Code');
|
|
98
|
+
console.log(' 2) OpenAI Codex CLI');
|
|
99
|
+
console.log(' 3) OpenCode');
|
|
100
|
+
console.log(' 4) GitHub Copilot CLI');
|
|
101
|
+
console.log(' 5) Kilo');
|
|
102
|
+
console.log(' 6) Google Antigravity (experimental)');
|
|
103
|
+
console.log(' 7) All current CLIs (Claude Code + Codex + OpenCode)');
|
|
81
104
|
console.log('');
|
|
82
105
|
|
|
83
|
-
const choice = await ask(rl, '
|
|
106
|
+
const choice = await ask(rl, ' Select (1/2/3/4/5/6/7): ');
|
|
84
107
|
switch (choice.trim()) {
|
|
85
108
|
case '1':
|
|
86
109
|
runtimes = ['claude'];
|
|
87
110
|
break;
|
|
88
111
|
case '2':
|
|
89
|
-
runtimes = ['
|
|
112
|
+
runtimes = ['openai'];
|
|
90
113
|
break;
|
|
91
114
|
case '3':
|
|
92
|
-
runtimes = ['
|
|
115
|
+
runtimes = ['opencode'];
|
|
93
116
|
break;
|
|
94
117
|
case '4':
|
|
95
|
-
runtimes = ['
|
|
118
|
+
runtimes = ['copilot'];
|
|
119
|
+
break;
|
|
120
|
+
case '5':
|
|
121
|
+
runtimes = ['kilo'];
|
|
122
|
+
break;
|
|
123
|
+
case '6':
|
|
124
|
+
runtimes = ['antigravity'];
|
|
125
|
+
break;
|
|
126
|
+
case '7':
|
|
127
|
+
runtimes = ['claude', 'openai', 'opencode'];
|
|
96
128
|
break;
|
|
97
129
|
default:
|
|
98
|
-
console.log('
|
|
130
|
+
console.log(' Invalid choice. Defaulting to Claude Code.');
|
|
99
131
|
runtimes = ['claude'];
|
|
100
132
|
}
|
|
101
133
|
}
|
|
102
134
|
|
|
103
135
|
// Interactive scope selection
|
|
104
136
|
if (!scope) {
|
|
105
|
-
console.log('\n
|
|
106
|
-
console.log('
|
|
107
|
-
console.log('
|
|
137
|
+
console.log('\n Installation scope:\n');
|
|
138
|
+
console.log(' 1) Global — Available in all projects (~/.claude/, ~/.codex/, ~/.config/opencode/, ~/.agents/skills/)');
|
|
139
|
+
console.log(' 2) Local — This project only (./.claude/, ./.codex/, ./.opencode/, ./.agents/skills/)');
|
|
108
140
|
console.log('');
|
|
109
141
|
|
|
110
|
-
const choice = await ask(rl, '
|
|
142
|
+
const choice = await ask(rl, ' Select (1/2): ');
|
|
111
143
|
scope = choice.trim() === '2' ? 'local' : 'global';
|
|
112
144
|
}
|
|
113
145
|
|
|
@@ -123,8 +155,9 @@ async function runInstall(flags) {
|
|
|
123
155
|
for (const runtime of runtimes) {
|
|
124
156
|
const config = RUNTIMES[runtime];
|
|
125
157
|
console.log(`\n Installing for ${config.name} (${scope})...`);
|
|
126
|
-
installForRuntime(runtime, scope);
|
|
158
|
+
const result = installForRuntime(runtime, scope) || {};
|
|
127
159
|
console.log(` Done!`);
|
|
160
|
+
warnIfManualRegistration(result, config);
|
|
128
161
|
}
|
|
129
162
|
|
|
130
163
|
// Initialize .brain if requested
|
|
@@ -143,19 +176,17 @@ async function runInstall(flags) {
|
|
|
143
176
|
✓ Installation complete!
|
|
144
177
|
|
|
145
178
|
Available commands:
|
|
146
|
-
/brain:init Initialize brain structure
|
|
147
|
-
/brain:memorize Store a new memory
|
|
148
179
|
/brain:remember Recall relevant memories
|
|
149
|
-
/brain:
|
|
150
|
-
/brain:explore Browse the brain hierarchy
|
|
151
|
-
/brain:consolidate Merge related memories
|
|
152
|
-
/brain:forget Decay or remove memories
|
|
153
|
-
/brain:sunshine Deep forensic memory erasure
|
|
154
|
-
/brain:sleep Full maintenance cycle
|
|
180
|
+
/brain:memorize Store a new memory
|
|
155
181
|
/brain:status Brain overview dashboard
|
|
156
|
-
/brain:
|
|
157
|
-
|
|
158
|
-
|
|
182
|
+
/brain:pin Pin (or unpin) a memory in the always-present tier
|
|
183
|
+
/brain:forget Decay, archive, or forensically erase (--deep) memories
|
|
184
|
+
/brain:sync Sync via Brain Cloud, Git remote, or export/import
|
|
185
|
+
/brain:skills Manage procedural skills
|
|
186
|
+
/brain:sleep Full maintenance cycle (usually automatic)
|
|
187
|
+
|
|
188
|
+
Your brain is ready — recall and memorize happen automatically. Just start working,
|
|
189
|
+
or run /brain:status to see an overview.
|
|
159
190
|
`);
|
|
160
191
|
} finally {
|
|
161
192
|
rl.close();
|
|
@@ -187,7 +218,7 @@ async function runUpdate(flags) {
|
|
|
187
218
|
|
|
188
219
|
if (detections.length === 0) {
|
|
189
220
|
console.log(' No existing brain-memory installations found.\n');
|
|
190
|
-
console.log(' To install, run:
|
|
221
|
+
console.log(' To install, run: npm install -g brain-memory@beta && brain-memory');
|
|
191
222
|
if (filterRuntimes.length > 0) {
|
|
192
223
|
console.log(` (Searched for: ${filterRuntimes.join(', ')})`);
|
|
193
224
|
}
|
|
@@ -205,8 +236,9 @@ async function runUpdate(flags) {
|
|
|
205
236
|
console.log('\n Updating...');
|
|
206
237
|
for (const d of detections) {
|
|
207
238
|
console.log(`\n Updating ${d.runtimeName} (${d.scope})...`);
|
|
208
|
-
installForRuntime(d.runtime, d.scope);
|
|
239
|
+
const result = installForRuntime(d.runtime, d.scope) || {};
|
|
209
240
|
console.log(' Done!');
|
|
241
|
+
warnIfManualRegistration(result, RUNTIMES[d.runtime]);
|
|
210
242
|
}
|
|
211
243
|
|
|
212
244
|
console.log(`\n ✓ Updated to v${version}\n`);
|
|
@@ -303,7 +335,7 @@ async function main() {
|
|
|
303
335
|
console.log(`
|
|
304
336
|
╔══════════════════════════════════════════════════════╗
|
|
305
337
|
║ ║
|
|
306
|
-
║
|
|
338
|
+
║ ◉ Brain Memory — Installer ║
|
|
307
339
|
║ ║
|
|
308
340
|
║ Hierarchical memory system for AI coding agents ║
|
|
309
341
|
║ ║
|