neuronlayer 0.1.8 → 0.1.9

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.

Potentially problematic release.


This version of neuronlayer might be problematic. Click here for more details.

@@ -22,7 +22,7 @@ export function listProjects(): CommandResult {
22
22
  if (projects.length === 0) {
23
23
  return {
24
24
  success: true,
25
- message: 'No projects registered. Use "memorylayer projects add <path>" to add one.'
25
+ message: 'No projects registered. Use "neuronlayer projects add <path>" to add one.'
26
26
  };
27
27
  }
28
28
 
@@ -123,7 +123,7 @@ export function discoverProjects(): CommandResult {
123
123
  lines.push(` ${path}`);
124
124
  lines.push('');
125
125
  }
126
- lines.push('Use "memorylayer projects add <path>" to register a project.');
126
+ lines.push('Use "neuronlayer projects add <path>" to register a project.');
127
127
 
128
128
  return {
129
129
  success: true,
@@ -144,7 +144,7 @@ export function exportDecisions(
144
144
  if (!activeProject) {
145
145
  return {
146
146
  success: false,
147
- message: 'No project specified and no active project. Use "memorylayer projects switch <id>" first.'
147
+ message: 'No project specified and no active project. Use "neuronlayer projects switch <id>" first.'
148
148
  };
149
149
  }
150
150
  targetPath = activeProject.path;
@@ -155,7 +155,7 @@ export function exportDecisions(
155
155
  if (!projectInfo) {
156
156
  return {
157
157
  success: false,
158
- message: `Project not registered: ${targetPath}. Use "memorylayer projects add ${targetPath}" first.`
158
+ message: `Project not registered: ${targetPath}. Use "neuronlayer projects add ${targetPath}" first.`
159
159
  };
160
160
  }
161
161
 
@@ -216,7 +216,7 @@ export function showProject(projectId?: string): CommandResult {
216
216
  success: false,
217
217
  message: projectId
218
218
  ? `Project not found: ${projectId}`
219
- : 'No active project. Use "memorylayer projects switch <id>" first.'
219
+ : 'No active project. Use "neuronlayer projects switch <id>" first.'
220
220
  };
221
221
  }
222
222
 
@@ -278,6 +278,40 @@ function configureMCPClient(
278
278
  }
279
279
  }
280
280
 
281
+ // Helper to configure project-local .mcp.json for Claude Code
282
+ function configureProjectMCP(
283
+ configPath: string,
284
+ projectPath: string
285
+ ): { success: boolean; message: string } {
286
+ let config: { mcpServers?: Record<string, unknown> } = { mcpServers: {} };
287
+
288
+ try {
289
+ if (existsSync(configPath)) {
290
+ const content = readFileSync(configPath, 'utf-8');
291
+ config = JSON.parse(content);
292
+ }
293
+ } catch {
294
+ // Config doesn't exist or is invalid, start fresh
295
+ }
296
+
297
+ if (!config.mcpServers) {
298
+ config.mcpServers = {};
299
+ }
300
+
301
+ // Use simple name since this is project-specific
302
+ config.mcpServers['neuronlayer'] = {
303
+ command: 'npx',
304
+ args: ['-y', 'neuronlayer', '--project', '.']
305
+ };
306
+
307
+ try {
308
+ writeFileSync(configPath, JSON.stringify(config, null, 2));
309
+ return { success: true, message: `Claude Code: ${configPath} (project-local)` };
310
+ } catch (err) {
311
+ return { success: false, message: `Claude Code: Failed - ${err instanceof Error ? err.message : String(err)}` };
312
+ }
313
+ }
314
+
281
315
  // Initialize neuronlayer for current project + auto-configure Claude Desktop & OpenCode
282
316
  export function initProject(projectPath?: string): CommandResult {
283
317
  const targetPath = projectPath || process.cwd();
@@ -321,14 +355,29 @@ export function initProject(projectPath?: string): CommandResult {
321
355
  failedClients.push(openCodeResult.message);
322
356
  }
323
357
 
324
- // 4. Configure Claude Code (CLI) - uses same config location as Claude Desktop on some systems
325
- // Also check for .claude.json in home directory
326
- const claudeCodeConfigPath = join(homedir(), '.claude.json');
327
- const claudeCodeResult = configureMCPClient('Claude Code', claudeCodeConfigPath, serverName, targetPath);
358
+ // 4. Configure Claude Code (CLI) - use project-local .mcp.json
359
+ // This ensures only the current project's NeuronLayer connects
360
+ const claudeCodeConfigPath = join(targetPath, '.mcp.json');
361
+ const claudeCodeResult = configureProjectMCP(claudeCodeConfigPath, targetPath);
328
362
  if (claudeCodeResult.success) {
329
363
  configuredClients.push(claudeCodeResult.message);
330
364
  }
331
365
 
366
+ // 5. Configure Cursor
367
+ let cursorConfigPath: string;
368
+ if (platform === 'win32') {
369
+ cursorConfigPath = join(homedir(), 'AppData', 'Roaming', 'Cursor', 'User', 'globalStorage', 'cursor.mcp', 'mcp.json');
370
+ } else if (platform === 'darwin') {
371
+ cursorConfigPath = join(homedir(), 'Library', 'Application Support', 'Cursor', 'User', 'globalStorage', 'cursor.mcp', 'mcp.json');
372
+ } else {
373
+ cursorConfigPath = join(homedir(), '.config', 'Cursor', 'User', 'globalStorage', 'cursor.mcp', 'mcp.json');
374
+ }
375
+
376
+ const cursorResult = configureMCPClient('Cursor', cursorConfigPath, serverName, targetPath);
377
+ if (cursorResult.success) {
378
+ configuredClients.push(cursorResult.message);
379
+ }
380
+
332
381
  // Build result message
333
382
  let message = `
334
383
  NeuronLayer initialized!
@@ -357,14 +406,15 @@ ${configuredClients.map(c => ' ✓ ' + c).join('\n')}
357
406
  // Print help
358
407
  export function printHelp(): void {
359
408
  console.log(`
360
- MemoryLayer CLI - Persistent Memory for AI Coding Assistants
409
+ NeuronLayer CLI - Code Intelligence for AI Coding Assistants
361
410
 
362
411
  USAGE:
363
- memorylayer [command] [options]
412
+ neuronlayer [command] [options]
364
413
 
365
414
  COMMANDS:
366
- init [path] Initialize project + auto-configure Claude Desktop
367
- (no command) Start MCP server for Claude Desktop
415
+ init [path] Initialize project + auto-configure AI tools
416
+ serve [options] Start HTTP API server (for non-MCP tools)
417
+ (no command) Start MCP server
368
418
  projects list List all registered projects
369
419
  projects add <path> Add a project to the registry
370
420
  projects remove <id> Remove a project from the registry
@@ -376,6 +426,7 @@ COMMANDS:
376
426
 
377
427
  OPTIONS:
378
428
  --project, -p <path> Path to the project directory
429
+ --port <number> Port for HTTP server (default: 3333)
379
430
  --output, -o <dir> Output directory for exports
380
431
  --format <type> ADR format: madr, nygard, simple
381
432
 
@@ -388,19 +439,23 @@ EXAMPLES:
388
439
  neuronlayer --project /path/to/project
389
440
 
390
441
  # List all projects
391
- memorylayer projects list
442
+ neuronlayer projects list
392
443
 
393
444
  # Add a new project
394
- memorylayer projects add /path/to/my-project
445
+ neuronlayer projects add /path/to/my-project
395
446
 
396
447
  # Switch active project
397
- memorylayer projects switch abc123
448
+ neuronlayer projects switch abc123
398
449
 
399
450
  # Export decisions to ADR files
400
- memorylayer export --format madr
451
+ neuronlayer export --format madr
401
452
 
402
453
  # Discover projects
403
- memorylayer projects discover
454
+ neuronlayer projects discover
455
+
456
+ # Start HTTP API server (for tools without MCP support)
457
+ neuronlayer serve --project /path/to/project
458
+ neuronlayer serve --port 8080
404
459
 
405
460
  For more information, visit: https://github.com/abhisavakar/neuronlayer
406
461
  `);
@@ -435,7 +490,7 @@ export function executeCLI(args: string[]): void {
435
490
  const path = args[2];
436
491
  if (!path) {
437
492
  console.error('Error: Project path required.');
438
- console.error('Usage: memorylayer projects add <path>');
493
+ console.error('Usage: neuronlayer projects add <path>');
439
494
  process.exit(1);
440
495
  }
441
496
  const result = addProject(path);
@@ -447,7 +502,7 @@ export function executeCLI(args: string[]): void {
447
502
  const id = args[2];
448
503
  if (!id) {
449
504
  console.error('Error: Project ID required.');
450
- console.error('Usage: memorylayer projects remove <id>');
505
+ console.error('Usage: neuronlayer projects remove <id>');
451
506
  process.exit(1);
452
507
  }
453
508
  const result = removeProject(id);
@@ -459,7 +514,7 @@ export function executeCLI(args: string[]): void {
459
514
  const id = args[2];
460
515
  if (!id) {
461
516
  console.error('Error: Project ID required.');
462
- console.error('Usage: memorylayer projects switch <id>');
517
+ console.error('Usage: neuronlayer projects switch <id>');
463
518
  process.exit(1);
464
519
  }
465
520
  const result = switchProject(id);
@@ -107,7 +107,7 @@ export class ADRExporter {
107
107
  lines.push('');
108
108
  lines.push('---');
109
109
  lines.push('');
110
- lines.push('*Generated by MemoryLayer*');
110
+ lines.push('*Generated by NeuronLayer*');
111
111
 
112
112
  writeFileSync(indexPath, lines.join('\n'));
113
113
  return indexPath;
@@ -157,7 +157,7 @@ ${decision.supersededBy ? `## Superseded By
157
157
  This decision has been superseded by [ADR ${decision.supersededBy}](./${decision.supersededBy}.md).
158
158
  ` : ''}
159
159
  ---
160
- *Exported from MemoryLayer*
160
+ *Exported from NeuronLayer*
161
161
  `;
162
162
  }
163
163
 
@@ -192,7 +192,7 @@ ${decision.files.length > 0 ? `## Related Files
192
192
  ${decision.files.map(f => `- ${f}`).join('\n')}
193
193
  ` : ''}
194
194
  ---
195
- *Exported from MemoryLayer*
195
+ *Exported from NeuronLayer*
196
196
  `;
197
197
  }
198
198
 
@@ -216,7 +216,7 @@ ${decision.files.length > 0 ? `## Related Files
216
216
  ${decision.files.map(f => `- \`${f}\``).join('\n')}
217
217
  ` : ''}
218
218
  ---
219
- *Exported from MemoryLayer*
219
+ *Exported from NeuronLayer*
220
220
  `;
221
221
  }
222
222
 
@@ -24,15 +24,15 @@ import { DejaVuDetector, type DejaVuMatch } from './deja-vu.js';
24
24
  import { CodeVerifier, type VerificationResult, type VerificationCheck, type ImportVerification, type SecurityScanResult, type DependencyCheckResult } from './code-verifier.js';
25
25
  import { GitStalenessChecker, ActivityGate } from './refresh/index.js';
26
26
  import { detectLanguage, getPreview, countLines } from '../utils/files.js';
27
- import type { MemoryLayerConfig, AssembledContext, Decision, ProjectSummary, SearchResult, CodeSymbol, SymbolKind, ActiveFeatureContext, HotContext } from '../types/index.js';
27
+ import type { NeuronLayerConfig, AssembledContext, Decision, ProjectSummary, SearchResult, CodeSymbol, SymbolKind, ActiveFeatureContext, HotContext } from '../types/index.js';
28
28
  import type { ArchitectureDoc, ComponentDoc, DailyChangelog, ChangelogOptions, ValidationResult, ActivityResult, UndocumentedItem, ContextHealth, CompactionResult, CompactionOptions, CriticalContext, DriftResult, ConfidenceResult, ConfidenceLevel, ConfidenceSources, ConflictResult, ChangeQueryResult, ChangeQueryOptions, Diagnosis, PastBug, FixSuggestion, Change, Pattern, PatternCategory, PatternValidationResult, ExistingFunction, TestInfo, TestFramework, TestValidationResult, TestUpdate, TestCoverage } from '../types/documentation.js';
29
29
  import type Database from 'better-sqlite3';
30
30
 
31
31
  // Re-export types for external use
32
32
  export type { GhostInsight, ConflictWarning, DejaVuMatch, ResurrectedContext, VerificationResult, VerificationCheck, ImportVerification, SecurityScanResult, DependencyCheckResult };
33
33
 
34
- export class MemoryLayerEngine {
35
- private config: MemoryLayerConfig;
34
+ export class NeuronLayerEngine {
35
+ private config: NeuronLayerConfig;
36
36
  private db: Database.Database;
37
37
  private tier1: Tier1Storage;
38
38
  private tier2: Tier2Storage;
@@ -60,7 +60,7 @@ export class MemoryLayerEngine {
60
60
  private initializationStatus: 'pending' | 'indexing' | 'ready' | 'error' = 'pending';
61
61
  private indexingProgress: { indexed: number; total: number } = { indexed: 0, total: 0 };
62
62
 
63
- constructor(config: MemoryLayerConfig) {
63
+ constructor(config: NeuronLayerConfig) {
64
64
  this.config = config;
65
65
 
66
66
  // Ensure data directory exists
@@ -272,7 +272,7 @@ export class MemoryLayerEngine {
272
272
  async initialize(): Promise<void> {
273
273
  if (this.initialized) return;
274
274
 
275
- console.error(`Initializing MemoryLayer for: ${this.config.projectPath}`);
275
+ console.error(`Initializing NeuronLayer for: ${this.config.projectPath}`);
276
276
 
277
277
  try {
278
278
  // Perform initial indexing
@@ -314,7 +314,7 @@ export class MemoryLayerEngine {
314
314
 
315
315
  this.initialized = true;
316
316
  this.initializationStatus = 'ready';
317
- console.error('MemoryLayer initialized');
317
+ console.error('NeuronLayer initialized');
318
318
  } catch (error) {
319
319
  this.initializationStatus = 'error';
320
320
  throw error;
@@ -1636,7 +1636,7 @@ export class MemoryLayerEngine {
1636
1636
  }
1637
1637
 
1638
1638
  shutdown(): void {
1639
- console.error('Shutting down MemoryLayer...');
1639
+ console.error('Shutting down NeuronLayer...');
1640
1640
  this.indexer.stopWatching();
1641
1641
  this.activityGate.shutdown();
1642
1642
  this.tier1.save();
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Silently tracks what files Claude reads/writes. When code is written that
5
5
  * touches a file with recorded decisions, automatically checks for conflicts.
6
- * Makes MemoryLayer feel "telepathic" by surfacing relevant context proactively.
6
+ * Makes NeuronLayer feel "telepathic" by surfacing relevant context proactively.
7
7
  */
8
8
 
9
9
  import type { Decision } from '../types/index.js';
@@ -3,7 +3,7 @@ import { join, basename, resolve } from 'path';
3
3
  import { createHash } from 'crypto';
4
4
  import { homedir } from 'os';
5
5
  import Database from 'better-sqlite3';
6
- import type { MemoryLayerConfig } from '../types/index.js';
6
+ import type { NeuronLayerConfig } from '../types/index.js';
7
7
 
8
8
  export interface ProjectInfo {
9
9
  id: string;
@@ -177,7 +177,7 @@ export class ProjectManager {
177
177
  }
178
178
 
179
179
  // Get config for a project
180
- getProjectConfig(projectPath: string): MemoryLayerConfig {
180
+ getProjectConfig(projectPath: string): NeuronLayerConfig {
181
181
  const normalizedPath = resolve(projectPath);
182
182
  const dataDir = this.getProjectDataDir(normalizedPath);
183
183
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Intelligent Refresh System for MemoryLayer
2
+ * Intelligent Refresh System for NeuronLayer
3
3
  *
4
4
  * This module provides a tiered refresh architecture:
5
5
  *
package/src/index.ts CHANGED
@@ -1,7 +1,27 @@
1
1
  import { MCPServer } from './server/mcp.js';
2
+ import { HTTPServer } from './server/http.js';
2
3
  import { getDefaultConfig, parseArgs } from './utils/config.js';
3
4
  import { executeCLI, printHelp } from './cli/commands.js';
4
5
 
6
+ function parseServeArgs(args: string[]): { projectPath: string; port: number } {
7
+ let projectPath = process.cwd();
8
+ let port = 3333;
9
+
10
+ for (let i = 0; i < args.length; i++) {
11
+ const arg = args[i];
12
+ const nextArg = args[i + 1];
13
+ if ((arg === '--project' || arg === '-p') && nextArg) {
14
+ projectPath = nextArg;
15
+ i++;
16
+ } else if (arg === '--port' && nextArg) {
17
+ port = parseInt(nextArg) || 3333;
18
+ i++;
19
+ }
20
+ }
21
+
22
+ return { projectPath, port };
23
+ }
24
+
5
25
  async function main(): Promise<void> {
6
26
  const args = process.argv.slice(2);
7
27
 
@@ -15,10 +35,31 @@ async function main(): Promise<void> {
15
35
  return;
16
36
  }
17
37
 
38
+ // Handle serve command - start HTTP API server
39
+ if (firstArg === 'serve') {
40
+ const { projectPath, port } = parseServeArgs(args.slice(1));
41
+ const config = getDefaultConfig(projectPath);
42
+
43
+ console.log('NeuronLayer HTTP API starting...');
44
+ console.log(`Project: ${config.projectPath}`);
45
+ console.log(`Data directory: ${config.dataDir}`);
46
+ console.log('');
47
+
48
+ const server = new HTTPServer(config, port);
49
+ try {
50
+ await server.start();
51
+ } catch (error) {
52
+ console.error('Failed to start HTTP server:', error);
53
+ process.exit(1);
54
+ }
55
+ return;
56
+ }
57
+
18
58
  // No arguments and not piped - show help
19
59
  if (args.length === 0 && process.stdin.isTTY) {
20
60
  printHelp();
21
- console.log('\nTo start as MCP server, use: memorylayer --project <path>\n');
61
+ console.log('\nTo start as MCP server, use: neuronlayer --project <path>');
62
+ console.log('To start HTTP API, use: neuronlayer serve --project <path>\n');
22
63
  return;
23
64
  }
24
65
 
@@ -28,7 +69,7 @@ async function main(): Promise<void> {
28
69
  // Get configuration
29
70
  const config = getDefaultConfig(projectPath);
30
71
 
31
- console.error('MemoryLayer starting...');
72
+ console.error('NeuronLayer starting...');
32
73
  console.error(`Project: ${config.projectPath}`);
33
74
  console.error(`Data directory: ${config.dataDir}`);
34
75
 
@@ -38,7 +79,7 @@ async function main(): Promise<void> {
38
79
  try {
39
80
  await server.start();
40
81
  } catch (error) {
41
- console.error('Failed to start MemoryLayer:', error);
82
+ console.error('Failed to start NeuronLayer:', error);
42
83
  process.exit(1);
43
84
  }
44
85
  }
@@ -7,10 +7,10 @@ import { ASTParser } from './ast.js';
7
7
  import { FileWatcher, type FileEvent } from './watcher.js';
8
8
  import { Tier2Storage } from '../storage/tier2.js';
9
9
  import { isCodeFile, detectLanguage, hashContent, getPreview, countLines } from '../utils/files.js';
10
- import type { MemoryLayerConfig, IndexingProgress } from '../types/index.js';
10
+ import type { NeuronLayerConfig, IndexingProgress } from '../types/index.js';
11
11
 
12
12
  export class Indexer extends EventEmitter {
13
- private config: MemoryLayerConfig;
13
+ private config: NeuronLayerConfig;
14
14
  private embeddingGenerator: EmbeddingGenerator;
15
15
  private astParser: ASTParser;
16
16
  private watcher: FileWatcher;
@@ -19,7 +19,7 @@ export class Indexer extends EventEmitter {
19
19
  private pendingFiles: Set<string> = new Set();
20
20
  private processTimeout: NodeJS.Timeout | null = null;
21
21
 
22
- constructor(config: MemoryLayerConfig, tier2: Tier2Storage) {
22
+ constructor(config: NeuronLayerConfig, tier2: Tier2Storage) {
23
23
  super();
24
24
  this.config = config;
25
25
  this.tier2 = tier2;