neuralbrain 0.0.2 → 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/.env.example +2 -2
- package/README.md +19 -4
- package/dist/ai/chat.d.ts +1 -2
- package/dist/ai/chat.d.ts.map +1 -1
- package/dist/ai/chat.js +1 -2
- package/dist/ai/chat.js.map +1 -1
- package/dist/ai/config.d.ts +1 -1
- package/dist/ai/config.js +2 -2
- package/dist/ai/config.js.map +1 -1
- package/dist/app.d.ts +1 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +417 -50
- package/dist/app.js.map +1 -1
- package/dist/cli.d.ts +53 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +437 -37
- package/dist/cli.js.map +1 -1
- package/dist/consolidation/candidates.d.ts.map +1 -1
- package/dist/consolidation/candidates.js +19 -4
- package/dist/consolidation/candidates.js.map +1 -1
- package/dist/consolidation/fixtures.js +1 -1
- package/dist/consolidation/fixtures.js.map +1 -1
- package/dist/consolidation/gate.d.ts.map +1 -1
- package/dist/consolidation/gate.js +145 -109
- package/dist/consolidation/gate.js.map +1 -1
- package/dist/consolidation/runner.d.ts +6 -0
- package/dist/consolidation/runner.d.ts.map +1 -1
- package/dist/consolidation/runner.js +22 -2
- package/dist/consolidation/runner.js.map +1 -1
- package/dist/dashboard/clientScript.d.ts +1 -1
- package/dist/dashboard/clientScript.d.ts.map +1 -1
- package/dist/dashboard/clientScript.js +3774 -905
- package/dist/dashboard/clientScript.js.map +1 -1
- package/dist/dashboard/html.d.ts.map +1 -1
- package/dist/dashboard/html.js +605 -101
- package/dist/dashboard/html.js.map +1 -1
- package/dist/dashboard/styles.d.ts +1 -1
- package/dist/dashboard/styles.d.ts.map +1 -1
- package/dist/dashboard/styles.js +1591 -359
- package/dist/dashboard/styles.js.map +1 -1
- package/dist/learning/embedWorker.d.ts +13 -0
- package/dist/learning/embedWorker.d.ts.map +1 -1
- package/dist/learning/embedWorker.js +329 -59
- package/dist/learning/embedWorker.js.map +1 -1
- package/dist/learning/embedding.d.ts +1 -0
- package/dist/learning/embedding.d.ts.map +1 -1
- package/dist/learning/embedding.js +101 -26
- package/dist/learning/embedding.js.map +1 -1
- package/dist/learning/engine.js +1 -1
- package/dist/learning/engine.js.map +1 -1
- package/dist/learning/search.d.ts +17 -1
- package/dist/learning/search.d.ts.map +1 -1
- package/dist/learning/search.js +2094 -354
- package/dist/learning/search.js.map +1 -1
- package/dist/learning/storeMeta.d.ts +9 -0
- package/dist/learning/storeMeta.d.ts.map +1 -1
- package/dist/learning/storeMeta.js +30 -24
- package/dist/learning/storeMeta.js.map +1 -1
- package/dist/learning/types.d.ts +57 -8
- package/dist/learning/types.d.ts.map +1 -1
- package/dist/lib/condenser.d.ts +112 -0
- package/dist/lib/condenser.d.ts.map +1 -0
- package/dist/lib/condenser.js +1337 -0
- package/dist/lib/condenser.js.map +1 -0
- package/dist/lib/db.d.ts +10 -0
- package/dist/lib/db.d.ts.map +1 -1
- package/dist/lib/db.js +654 -167
- package/dist/lib/db.js.map +1 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +3 -2
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/projectSlug.d.ts +12 -5
- package/dist/lib/projectSlug.d.ts.map +1 -1
- package/dist/lib/projectSlug.js +62 -23
- package/dist/lib/projectSlug.js.map +1 -1
- package/dist/lib/recurrence.d.ts +16 -0
- package/dist/lib/recurrence.d.ts.map +1 -0
- package/dist/lib/recurrence.js +293 -0
- package/dist/lib/recurrence.js.map +1 -0
- package/dist/lib/scope.d.ts +36 -1
- package/dist/lib/scope.d.ts.map +1 -1
- package/dist/lib/scope.js +183 -19
- package/dist/lib/scope.js.map +1 -1
- package/dist/lib/signalTags.d.ts +39 -0
- package/dist/lib/signalTags.d.ts.map +1 -0
- package/dist/lib/signalTags.js +203 -0
- package/dist/lib/signalTags.js.map +1 -0
- package/dist/lib/spool.d.ts +2 -0
- package/dist/lib/spool.d.ts.map +1 -1
- package/dist/lib/spool.js +176 -65
- package/dist/lib/spool.js.map +1 -1
- package/dist/lib/storeDiagnostics.d.ts +41 -0
- package/dist/lib/storeDiagnostics.d.ts.map +1 -0
- package/dist/lib/storeDiagnostics.js +148 -0
- package/dist/lib/storeDiagnostics.js.map +1 -0
- package/dist/lib/temporal.d.ts +44 -0
- package/dist/lib/temporal.d.ts.map +1 -0
- package/dist/lib/temporal.js +1063 -0
- package/dist/lib/temporal.js.map +1 -0
- package/dist/mcp/server.d.ts +93 -3
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +499 -68
- package/dist/mcp/server.js.map +1 -1
- package/dist/memory/actionStore.d.ts +94 -3
- package/dist/memory/actionStore.d.ts.map +1 -1
- package/dist/memory/actionStore.js +412 -124
- package/dist/memory/actionStore.js.map +1 -1
- package/dist/memory/deadLetterStore.d.ts.map +1 -1
- package/dist/memory/deadLetterStore.js +4 -2
- package/dist/memory/deadLetterStore.js.map +1 -1
- package/dist/memory/embedQueueStore.d.ts +19 -8
- package/dist/memory/embedQueueStore.d.ts.map +1 -1
- package/dist/memory/embedQueueStore.js +55 -25
- package/dist/memory/embedQueueStore.js.map +1 -1
- package/dist/memory/failurePatternStore.d.ts +17 -1
- package/dist/memory/failurePatternStore.d.ts.map +1 -1
- package/dist/memory/failurePatternStore.js +54 -31
- package/dist/memory/failurePatternStore.js.map +1 -1
- package/dist/memory/graphStore.d.ts +133 -3
- package/dist/memory/graphStore.d.ts.map +1 -1
- package/dist/memory/graphStore.js +980 -155
- package/dist/memory/graphStore.js.map +1 -1
- package/dist/memory/noteStore.d.ts +27 -2
- package/dist/memory/noteStore.d.ts.map +1 -1
- package/dist/memory/noteStore.js +89 -26
- package/dist/memory/noteStore.js.map +1 -1
- package/dist/memory/observationStore.d.ts +11 -1
- package/dist/memory/observationStore.d.ts.map +1 -1
- package/dist/memory/observationStore.js +90 -15
- package/dist/memory/observationStore.js.map +1 -1
- package/dist/memory/projectRename.d.ts.map +1 -1
- package/dist/memory/projectRename.js +5 -1
- package/dist/memory/projectRename.js.map +1 -1
- package/dist/memory/rollupSweeper.d.ts.map +1 -1
- package/dist/memory/rollupSweeper.js +43 -23
- package/dist/memory/rollupSweeper.js.map +1 -1
- package/dist/memory/sessionStore.d.ts +25 -7
- package/dist/memory/sessionStore.d.ts.map +1 -1
- package/dist/memory/sessionStore.js +145 -33
- package/dist/memory/sessionStore.js.map +1 -1
- package/dist/memory/trajectoryStore.d.ts +8 -0
- package/dist/memory/trajectoryStore.d.ts.map +1 -1
- package/dist/memory/trajectoryStore.js +196 -130
- package/dist/memory/trajectoryStore.js.map +1 -1
- package/dist/middleware/rateLimiter.d.ts.map +1 -1
- package/dist/middleware/rateLimiter.js +24 -1
- package/dist/middleware/rateLimiter.js.map +1 -1
- package/dist/routes/dashboard.d.ts.map +1 -1
- package/dist/routes/dashboard.js +181 -8
- package/dist/routes/dashboard.js.map +1 -1
- package/dist/routes/mcp.d.ts.map +1 -1
- package/dist/routes/mcp.js +173 -21
- package/dist/routes/mcp.js.map +1 -1
- package/dist/routes/memories.js +9 -1
- package/dist/routes/memories.js.map +1 -1
- package/dist/scripts/doctor.d.ts +26 -2
- package/dist/scripts/doctor.d.ts.map +1 -1
- package/dist/scripts/doctor.js +371 -259
- package/dist/scripts/doctor.js.map +1 -1
- package/dist/scripts/installAgent.d.ts.map +1 -1
- package/dist/scripts/installAgent.js +101 -19
- package/dist/scripts/installAgent.js.map +1 -1
- package/dist/scripts/migrateAgentMemory.js +2 -2
- package/dist/scripts/smokeTest.js +1 -1
- package/dist/scripts/smokeTest.js.map +1 -1
- package/docker-compose.yml +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugin/hooks/postToolUse.js +155 -50
- package/plugin/hooks/sessionStart.js +179 -27
- package/plugin/hooks/sessionStop.js +152 -37
- package/plugin/plugin.json +1 -1
- package/plugin/rules/AGENTS.md +10 -8
- package/plugin/skills/brain-memory/REFERENCE.md +15 -14
- package/plugin/skills/brain-memory/SKILL.md +2 -2
- package/plugin/skills/digest/SKILL.md +1 -1
- package/plugin/skills/handoff/SKILL.md +1 -1
- package/plugin/skills/save/SKILL.md +2 -2
- package/plugin/skills/search/SKILL.md +2 -2
- package/src/ai/chat.ts +1 -2
- package/src/ai/config.ts +2 -2
- package/src/app.ts +475 -54
- package/src/cli.ts +500 -38
- package/src/consolidation/candidates.ts +22 -4
- package/src/consolidation/fixtures.ts +1 -1
- package/src/consolidation/gate.ts +177 -140
- package/src/consolidation/runner.ts +26 -2
- package/src/dashboard/clientScript.ts +3774 -905
- package/src/dashboard/html.ts +605 -101
- package/src/dashboard/styles.ts +1591 -359
- package/src/learning/embedWorker.ts +350 -70
- package/src/learning/embedding.ts +141 -28
- package/src/learning/engine.ts +1 -1
- package/src/learning/search.ts +2533 -397
- package/src/learning/storeMeta.ts +36 -29
- package/src/learning/types.ts +66 -8
- package/src/lib/condenser.ts +1515 -0
- package/src/lib/db.ts +690 -171
- package/src/lib/logger.ts +4 -2
- package/src/lib/projectSlug.ts +77 -23
- package/src/lib/recurrence.ts +382 -0
- package/src/lib/scope.ts +220 -22
- package/src/lib/signalTags.ts +257 -0
- package/src/lib/spool.ts +181 -71
- package/src/lib/storeDiagnostics.ts +181 -0
- package/src/lib/temporal.ts +1250 -0
- package/src/mcp/server.ts +559 -88
- package/src/memory/actionStore.ts +642 -171
- package/src/memory/deadLetterStore.ts +4 -2
- package/src/memory/embedQueueStore.ts +63 -27
- package/src/memory/failurePatternStore.ts +84 -31
- package/src/memory/graphStore.ts +1396 -215
- package/src/memory/noteStore.ts +151 -30
- package/src/memory/observationStore.ts +117 -17
- package/src/memory/projectRename.ts +6 -2
- package/src/memory/rollupSweeper.ts +46 -23
- package/src/memory/sessionStore.ts +197 -38
- package/src/memory/trajectoryStore.ts +260 -140
- package/src/middleware/rateLimiter.ts +24 -1
- package/src/routes/dashboard.ts +194 -9
- package/src/routes/mcp.ts +185 -26
- package/src/routes/memories.ts +8 -1
- package/src/scripts/doctor.ts +461 -262
- package/src/scripts/installAgent.ts +106 -19
- package/src/scripts/migrateAgentMemory.ts +2 -2
- package/src/scripts/smokeTest.ts +1 -1
|
@@ -55,8 +55,8 @@ const AGENTMEMORY_BLOCK_REGEX = /<!-- agentmemory:start -->[\s\S]*?<!-- agentmem
|
|
|
55
55
|
*/
|
|
56
56
|
export function generateBrainRuleBlock(defaultProjectId?: string): string {
|
|
57
57
|
const projectScopeDesc = defaultProjectId
|
|
58
|
-
? `Use for repository-specific knowledge. You MUST supply project_id:
|
|
59
|
-
: `Use for repository-specific knowledge. You MUST supply project_id:
|
|
58
|
+
? `Use for repository-specific knowledge. You MUST supply project_id: if .brainrc (or .brain.json) in the project or an ancestor folder sets project_id, use that value verbatim (it wins over the folder name and may be a flat slug like 'neuralbrain' or a hierarchical slash-path slug like 'acme/socials/calendar'). Otherwise use the lowercase name of the project's ROOT folder: the git repository root (for a worktree, the main repository), otherwise the folder the session started in. Never a subfolder you are working in, never a filesystem path (current default: '${defaultProjectId}').`
|
|
59
|
+
: `Use for repository-specific knowledge. You MUST supply project_id: if .brainrc (or .brain.json) in the project or an ancestor folder sets project_id, use that value verbatim (it wins over the folder name and may be a flat slug like 'neuralbrain' or a hierarchical slash-path slug like 'acme/socials/calendar'). Otherwise use the lowercase name of the project's ROOT folder: the git repository root (for a worktree, the main repository), otherwise the folder the session started in. Never a subfolder you are working in, never a filesystem path. If the root is ambiguous, run \`neuralbrain init\` there rather than guessing.`;
|
|
60
60
|
const exampleProjectId = defaultProjectId || 'my-project';
|
|
61
61
|
|
|
62
62
|
return [
|
|
@@ -356,7 +356,7 @@ export function installRuntimeHooks(
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
// Copy helper libraries to hooks/lib/
|
|
359
|
-
const libFiles = ['projectSlug.js', 'spool.js', 'scope.js', 'brainHome.js', 'logger.js'];
|
|
359
|
+
const libFiles = ['projectSlug.js', 'spool.js', 'scope.js', 'brainHome.js', 'logger.js', 'redactSecrets.js', 'tls.js'];
|
|
360
360
|
for (const file of libFiles) {
|
|
361
361
|
let srcPath = path.join(brainRepoDir, 'dist', 'lib', file);
|
|
362
362
|
if (!fs.existsSync(srcPath)) {
|
|
@@ -374,6 +374,71 @@ export function installRuntimeHooks(
|
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
+
// Write zero-dependency shims for dotenv and pino in hooks/lib/node_modules/
|
|
378
|
+
// so installed hooks under ~/.neuralbrain/hooks/ are self-contained.
|
|
379
|
+
const hooksNodeModulesDir = path.join(installedHooksLibDir, 'node_modules');
|
|
380
|
+
const dotenvShim = [
|
|
381
|
+
'const fs = require("fs");',
|
|
382
|
+
'function parse(src) {',
|
|
383
|
+
' const out = {};',
|
|
384
|
+
' for (const rawLine of String(src).split(/\\r?\\n/)) {',
|
|
385
|
+
' const line = rawLine.trim();',
|
|
386
|
+
' if (!line || line.startsWith("#")) continue;',
|
|
387
|
+
' const cleaned = line.startsWith("export ") ? line.slice(7).trim() : line;',
|
|
388
|
+
' const eq = cleaned.indexOf("=");',
|
|
389
|
+
' if (eq <= 0) continue;',
|
|
390
|
+
' const key = cleaned.slice(0, eq).trim();',
|
|
391
|
+
' let val = cleaned.slice(eq + 1).trim();',
|
|
392
|
+
' if ((val.startsWith("\\"") && val.endsWith("\\"")) || (val.startsWith("\'") && val.endsWith("\'"))) {',
|
|
393
|
+
' val = val.slice(1, -1);',
|
|
394
|
+
' }',
|
|
395
|
+
' out[key] = val;',
|
|
396
|
+
' }',
|
|
397
|
+
' return out;',
|
|
398
|
+
'}',
|
|
399
|
+
'function config(opts) {',
|
|
400
|
+
' try {',
|
|
401
|
+
' const p = opts && opts.path ? opts.path : ".env";',
|
|
402
|
+
' if (!fs.existsSync(p)) return { parsed: {} };',
|
|
403
|
+
' const parsed = parse(fs.readFileSync(p, "utf8"));',
|
|
404
|
+
' const override = Boolean(opts && opts.override);',
|
|
405
|
+
' for (const [k, v] of Object.entries(parsed)) {',
|
|
406
|
+
' if (override || !(k in process.env)) process.env[k] = v;',
|
|
407
|
+
' }',
|
|
408
|
+
' return { parsed };',
|
|
409
|
+
' } catch (err) {',
|
|
410
|
+
' return { error: err };',
|
|
411
|
+
' }',
|
|
412
|
+
'}',
|
|
413
|
+
'module.exports = { parse, config, default: { parse, config } };',
|
|
414
|
+
'',
|
|
415
|
+
].join('\n');
|
|
416
|
+
safeWriteFile(path.join(hooksNodeModulesDir, 'dotenv', 'index.js'), dotenvShim, dryRun, report);
|
|
417
|
+
|
|
418
|
+
const pinoShim = [
|
|
419
|
+
'function noop() {}',
|
|
420
|
+
'function writeErr(level, objOrMsg, msg) {',
|
|
421
|
+
' const text = typeof objOrMsg === "string" ? objOrMsg : (msg || JSON.stringify(objOrMsg));',
|
|
422
|
+
' process.stderr.write(`[neuralbrain:${level}] ${text}\\n`);',
|
|
423
|
+
'}',
|
|
424
|
+
'function pino() {',
|
|
425
|
+
' const log = {',
|
|
426
|
+
' trace: noop,',
|
|
427
|
+
' debug: noop,',
|
|
428
|
+
' info: noop,',
|
|
429
|
+
' warn: (a, b) => writeErr("warn", a, b),',
|
|
430
|
+
' error: (a, b) => writeErr("error", a, b),',
|
|
431
|
+
' fatal: (a, b) => writeErr("fatal", a, b),',
|
|
432
|
+
' child: () => log,',
|
|
433
|
+
' };',
|
|
434
|
+
' return log;',
|
|
435
|
+
'}',
|
|
436
|
+
'module.exports = pino;',
|
|
437
|
+
'module.exports.default = pino;',
|
|
438
|
+
'',
|
|
439
|
+
].join('\n');
|
|
440
|
+
safeWriteFile(path.join(hooksNodeModulesDir, 'pino', 'index.js'), pinoShim, dryRun, report);
|
|
441
|
+
|
|
377
442
|
// Also copy dist/mcp/server.js to ~/.neuralbrain/mcp/
|
|
378
443
|
const installedMcpDir = getBrainMcpDir(homeDir);
|
|
379
444
|
let mcpSrc = path.join(brainRepoDir, 'dist', 'mcp', 'server.js');
|
|
@@ -531,7 +596,8 @@ function safeWriteFile(
|
|
|
531
596
|
filePath: string,
|
|
532
597
|
content: string,
|
|
533
598
|
dryRun: boolean,
|
|
534
|
-
report: InstallAgentReport
|
|
599
|
+
report: InstallAgentReport,
|
|
600
|
+
mode?: number
|
|
535
601
|
): void {
|
|
536
602
|
const exists = fs.existsSync(filePath);
|
|
537
603
|
if (exists) {
|
|
@@ -554,7 +620,14 @@ function safeWriteFile(
|
|
|
554
620
|
if (!fs.existsSync(dir)) {
|
|
555
621
|
fs.mkdirSync(dir, { recursive: true });
|
|
556
622
|
}
|
|
557
|
-
fs.writeFileSync(filePath, content, 'utf8');
|
|
623
|
+
fs.writeFileSync(filePath, content, mode !== undefined ? { encoding: 'utf8', mode } : 'utf8');
|
|
624
|
+
if (mode !== undefined) {
|
|
625
|
+
try {
|
|
626
|
+
fs.chmodSync(filePath, mode);
|
|
627
|
+
} catch {
|
|
628
|
+
// Ignore chmod errors on platforms that don't support posix permissions
|
|
629
|
+
}
|
|
630
|
+
}
|
|
558
631
|
}
|
|
559
632
|
}
|
|
560
633
|
|
|
@@ -562,10 +635,11 @@ function safeWriteJson(
|
|
|
562
635
|
filePath: string,
|
|
563
636
|
data: any,
|
|
564
637
|
dryRun: boolean,
|
|
565
|
-
report: InstallAgentReport
|
|
638
|
+
report: InstallAgentReport,
|
|
639
|
+
mode?: number
|
|
566
640
|
): void {
|
|
567
641
|
const content = JSON.stringify(data, null, 2) + '\n';
|
|
568
|
-
safeWriteFile(filePath, content, dryRun, report);
|
|
642
|
+
safeWriteFile(filePath, content, dryRun, report, mode);
|
|
569
643
|
}
|
|
570
644
|
|
|
571
645
|
/**
|
|
@@ -669,7 +743,7 @@ export function installAgentIntegration(options: InstallAgentOptions = {}): Inst
|
|
|
669
743
|
{
|
|
670
744
|
name: 'neuralbrain',
|
|
671
745
|
displayName: 'neuralbrain',
|
|
672
|
-
version: '0.0
|
|
746
|
+
version: '0.1.0',
|
|
673
747
|
description: 'neuralbrain persistent memory service integration for Antigravity',
|
|
674
748
|
},
|
|
675
749
|
dryRun,
|
|
@@ -691,7 +765,8 @@ export function installAgentIntegration(options: InstallAgentOptions = {}): Inst
|
|
|
691
765
|
},
|
|
692
766
|
},
|
|
693
767
|
dryRun,
|
|
694
|
-
report
|
|
768
|
+
report,
|
|
769
|
+
0o600
|
|
695
770
|
);
|
|
696
771
|
|
|
697
772
|
// 3. hooks.json in plugin
|
|
@@ -775,7 +850,7 @@ export function installAgentIntegration(options: InstallAgentOptions = {}): Inst
|
|
|
775
850
|
const claudeJsonPath = path.join(homeDir, '.claude.json');
|
|
776
851
|
const existingClaudeJson = safeReadJson(claudeJsonPath) || { mcpServers: {} };
|
|
777
852
|
const mergedClaudeJson = mergeMcpConfig(existingClaudeJson, globalMcpServerDef, replaceAgentMemory);
|
|
778
|
-
safeWriteJson(claudeJsonPath, mergedClaudeJson, dryRun, report);
|
|
853
|
+
safeWriteJson(claudeJsonPath, mergedClaudeJson, dryRun, report, 0o600);
|
|
779
854
|
|
|
780
855
|
// 2. ~/.claude/settings.json (hooks)
|
|
781
856
|
if (enableHooks) {
|
|
@@ -858,7 +933,7 @@ export function installAgentIntegration(options: InstallAgentOptions = {}): Inst
|
|
|
858
933
|
const cursorMcpPath = path.join(homeDir, '.cursor', 'mcp.json');
|
|
859
934
|
const existingCursorJson = safeReadJson(cursorMcpPath) || { mcpServers: {} };
|
|
860
935
|
const mergedCursorJson = mergeMcpConfig(existingCursorJson, globalMcpServerDef, replaceAgentMemory);
|
|
861
|
-
safeWriteJson(cursorMcpPath, mergedCursorJson, dryRun, report);
|
|
936
|
+
safeWriteJson(cursorMcpPath, mergedCursorJson, dryRun, report, 0o600);
|
|
862
937
|
|
|
863
938
|
report.configuredTargets.push('cursor');
|
|
864
939
|
}
|
|
@@ -877,7 +952,6 @@ export function installAgentIntegration(options: InstallAgentOptions = {}): Inst
|
|
|
877
952
|
env: {
|
|
878
953
|
BRAIN_API_URL: apiUrl,
|
|
879
954
|
BRAIN_DEFAULT_PROJECT_ID: normalizedSlug,
|
|
880
|
-
...(apiKey ? { BRAIN_API_KEY: apiKey } : {}),
|
|
881
955
|
},
|
|
882
956
|
};
|
|
883
957
|
|
|
@@ -889,7 +963,7 @@ export function installAgentIntegration(options: InstallAgentOptions = {}): Inst
|
|
|
889
963
|
const projectClaudeMcpPath = path.join(projectDir, '.mcp.json');
|
|
890
964
|
const existingClaudeMcp = safeReadJson(projectClaudeMcpPath) || { mcpServers: {} };
|
|
891
965
|
const mergedClaudeMcp = mergeMcpConfig(existingClaudeMcp, projectMcpServerDef, replaceAgentMemory);
|
|
892
|
-
safeWriteJson(projectClaudeMcpPath, mergedClaudeMcp, dryRun, report);
|
|
966
|
+
safeWriteJson(projectClaudeMcpPath, mergedClaudeMcp, dryRun, report, 0o600);
|
|
893
967
|
|
|
894
968
|
if (enableHooks) {
|
|
895
969
|
const projectClaudeSettingsPath = path.join(projectDir, '.claude', 'settings.json');
|
|
@@ -1028,7 +1102,7 @@ export function installAgentIntegration(options: InstallAgentOptions = {}): Inst
|
|
|
1028
1102
|
const projectCursorMcpPath = path.join(projectDir, '.cursor', 'mcp.json');
|
|
1029
1103
|
const existingCursorMcp = safeReadJson(projectCursorMcpPath) || { mcpServers: {} };
|
|
1030
1104
|
const mergedCursorMcp = mergeMcpConfig(existingCursorMcp, projectMcpServerDef, replaceAgentMemory);
|
|
1031
|
-
safeWriteJson(projectCursorMcpPath, mergedCursorMcp, dryRun, report);
|
|
1105
|
+
safeWriteJson(projectCursorMcpPath, mergedCursorMcp, dryRun, report, 0o600);
|
|
1032
1106
|
|
|
1033
1107
|
// 5. Project-level Rules (<projectDir>/CLAUDE.md / AGENTS.md)
|
|
1034
1108
|
const isBrainRepo = projectDir === brainRepoDir;
|
|
@@ -1072,6 +1146,14 @@ export function installAgentIntegration(options: InstallAgentOptions = {}): Inst
|
|
|
1072
1146
|
// CLI Argument Parsing & Runner
|
|
1073
1147
|
// -----------------------------------------------------------------------------
|
|
1074
1148
|
|
|
1149
|
+
function requireFlagValue(argv: string[], index: number, flag: string): string {
|
|
1150
|
+
const next = argv[index + 1];
|
|
1151
|
+
if (next === undefined || next.startsWith('--')) {
|
|
1152
|
+
throw new Error(`Missing value for ${flag}`);
|
|
1153
|
+
}
|
|
1154
|
+
return next;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1075
1157
|
export function parseCliArgs(argv: string[]): InstallAgentOptions {
|
|
1076
1158
|
const options: InstallAgentOptions = {};
|
|
1077
1159
|
|
|
@@ -1084,12 +1166,14 @@ export function parseCliArgs(argv: string[]): InstallAgentOptions {
|
|
|
1084
1166
|
}
|
|
1085
1167
|
|
|
1086
1168
|
if (arg === '--project-dir') {
|
|
1087
|
-
options.projectDir = argv
|
|
1169
|
+
options.projectDir = requireFlagValue(argv, i, arg);
|
|
1170
|
+
i++;
|
|
1088
1171
|
continue;
|
|
1089
1172
|
}
|
|
1090
1173
|
|
|
1091
1174
|
if (arg === '--project-id') {
|
|
1092
|
-
options.projectId = argv
|
|
1175
|
+
options.projectId = requireFlagValue(argv, i, arg);
|
|
1176
|
+
i++;
|
|
1093
1177
|
continue;
|
|
1094
1178
|
}
|
|
1095
1179
|
|
|
@@ -1099,7 +1183,8 @@ export function parseCliArgs(argv: string[]): InstallAgentOptions {
|
|
|
1099
1183
|
}
|
|
1100
1184
|
|
|
1101
1185
|
if (arg === '--api-key') {
|
|
1102
|
-
options.apiKey = argv
|
|
1186
|
+
options.apiKey = requireFlagValue(argv, i, arg);
|
|
1187
|
+
i++;
|
|
1103
1188
|
console.warn(
|
|
1104
1189
|
'\n[SECURITY WARNING] Passing --api-key on the command line can expose secrets in shell history (~/.bash_history) and process tables (ps aux).' +
|
|
1105
1190
|
'\nRecommended: Set BRAIN_API_KEY in your .env file instead and run `npm run install-agent`.\n'
|
|
@@ -1108,7 +1193,8 @@ export function parseCliArgs(argv: string[]): InstallAgentOptions {
|
|
|
1108
1193
|
}
|
|
1109
1194
|
|
|
1110
1195
|
if (arg === '--api-url') {
|
|
1111
|
-
options.apiUrl = argv
|
|
1196
|
+
options.apiUrl = requireFlagValue(argv, i, arg);
|
|
1197
|
+
i++;
|
|
1112
1198
|
continue;
|
|
1113
1199
|
}
|
|
1114
1200
|
|
|
@@ -1133,7 +1219,8 @@ export function parseCliArgs(argv: string[]): InstallAgentOptions {
|
|
|
1133
1219
|
}
|
|
1134
1220
|
|
|
1135
1221
|
if (arg === '--target' || arg === '--targets') {
|
|
1136
|
-
const rawTargets = (argv
|
|
1222
|
+
const rawTargets = requireFlagValue(argv, i, arg).split(',').map((t) => t.trim().toLowerCase());
|
|
1223
|
+
i++;
|
|
1137
1224
|
const validTargets: Array<'antigravity' | 'claude' | 'cursor' | 'project'> = [];
|
|
1138
1225
|
for (const t of rawTargets) {
|
|
1139
1226
|
if (t === 'antigravity' || t === 'claude' || t === 'cursor' || t === 'project') {
|
|
@@ -123,9 +123,9 @@ export async function migrateAgentMemoryNotes(
|
|
|
123
123
|
`);
|
|
124
124
|
|
|
125
125
|
const enqueueStmt = db.prepare(`
|
|
126
|
-
INSERT INTO embed_queue (record_id,
|
|
126
|
+
INSERT INTO embed_queue (record_id, record_type, status, attempts, last_error, target, queued_at)
|
|
127
127
|
VALUES (?, 'note', 'pending', 0, NULL, 'live', unixepoch())
|
|
128
|
-
ON CONFLICT(record_id,
|
|
128
|
+
ON CONFLICT(record_id, record_type, target) DO UPDATE SET
|
|
129
129
|
status = 'pending',
|
|
130
130
|
attempts = 0,
|
|
131
131
|
last_error = NULL,
|
package/src/scripts/smokeTest.ts
CHANGED
|
@@ -144,7 +144,7 @@ export async function runLiveSmokeTest(): Promise<SmokeTestReport> {
|
|
|
144
144
|
},
|
|
145
145
|
body: JSON.stringify({
|
|
146
146
|
q: 'local transformer embedding test',
|
|
147
|
-
|
|
147
|
+
record_types: ['note'],
|
|
148
148
|
project_id: 'smoke-test-project',
|
|
149
149
|
limit: 5,
|
|
150
150
|
}),
|