neuronlayer 0.1.9 → 0.2.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.

Potentially problematic release.


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

Files changed (81) hide show
  1. package/README.md +3 -2
  2. package/dist/index.js +172 -90
  3. package/dist/index.js.map +7 -0
  4. package/package.json +6 -1
  5. package/esbuild.config.js +0 -26
  6. package/src/cli/commands.ts +0 -573
  7. package/src/core/adr-exporter.ts +0 -253
  8. package/src/core/architecture/architecture-enforcement.ts +0 -228
  9. package/src/core/architecture/duplicate-detector.ts +0 -288
  10. package/src/core/architecture/index.ts +0 -6
  11. package/src/core/architecture/pattern-learner.ts +0 -306
  12. package/src/core/architecture/pattern-library.ts +0 -403
  13. package/src/core/architecture/pattern-validator.ts +0 -324
  14. package/src/core/change-intelligence/bug-correlator.ts +0 -544
  15. package/src/core/change-intelligence/change-intelligence.ts +0 -264
  16. package/src/core/change-intelligence/change-tracker.ts +0 -334
  17. package/src/core/change-intelligence/fix-suggester.ts +0 -340
  18. package/src/core/change-intelligence/index.ts +0 -5
  19. package/src/core/code-verifier.ts +0 -843
  20. package/src/core/confidence/confidence-scorer.ts +0 -251
  21. package/src/core/confidence/conflict-checker.ts +0 -289
  22. package/src/core/confidence/index.ts +0 -5
  23. package/src/core/confidence/source-tracker.ts +0 -263
  24. package/src/core/confidence/warning-detector.ts +0 -241
  25. package/src/core/context-rot/compaction.ts +0 -284
  26. package/src/core/context-rot/context-health.ts +0 -243
  27. package/src/core/context-rot/context-rot-prevention.ts +0 -213
  28. package/src/core/context-rot/critical-context.ts +0 -221
  29. package/src/core/context-rot/drift-detector.ts +0 -255
  30. package/src/core/context-rot/index.ts +0 -7
  31. package/src/core/context.ts +0 -263
  32. package/src/core/decision-extractor.ts +0 -339
  33. package/src/core/decisions.ts +0 -69
  34. package/src/core/deja-vu.ts +0 -421
  35. package/src/core/engine.ts +0 -1646
  36. package/src/core/feature-context.ts +0 -726
  37. package/src/core/ghost-mode.ts +0 -465
  38. package/src/core/learning.ts +0 -519
  39. package/src/core/living-docs/activity-tracker.ts +0 -296
  40. package/src/core/living-docs/architecture-generator.ts +0 -428
  41. package/src/core/living-docs/changelog-generator.ts +0 -348
  42. package/src/core/living-docs/component-generator.ts +0 -230
  43. package/src/core/living-docs/doc-engine.ts +0 -134
  44. package/src/core/living-docs/doc-validator.ts +0 -282
  45. package/src/core/living-docs/index.ts +0 -8
  46. package/src/core/project-manager.ts +0 -301
  47. package/src/core/refresh/activity-gate.ts +0 -256
  48. package/src/core/refresh/git-staleness-checker.ts +0 -108
  49. package/src/core/refresh/index.ts +0 -27
  50. package/src/core/summarizer.ts +0 -290
  51. package/src/core/test-awareness/change-validator.ts +0 -499
  52. package/src/core/test-awareness/index.ts +0 -5
  53. package/src/index.ts +0 -90
  54. package/src/indexing/ast.ts +0 -868
  55. package/src/indexing/embeddings.ts +0 -85
  56. package/src/indexing/indexer.ts +0 -270
  57. package/src/indexing/watcher.ts +0 -78
  58. package/src/server/gateways/aggregator.ts +0 -374
  59. package/src/server/gateways/index.ts +0 -473
  60. package/src/server/gateways/memory-ghost.ts +0 -343
  61. package/src/server/gateways/memory-query.ts +0 -452
  62. package/src/server/gateways/memory-record.ts +0 -346
  63. package/src/server/gateways/memory-review.ts +0 -410
  64. package/src/server/gateways/memory-status.ts +0 -517
  65. package/src/server/gateways/memory-verify.ts +0 -392
  66. package/src/server/gateways/router.ts +0 -434
  67. package/src/server/gateways/types.ts +0 -610
  68. package/src/server/http.ts +0 -228
  69. package/src/server/mcp.ts +0 -154
  70. package/src/server/resources.ts +0 -85
  71. package/src/server/tools.ts +0 -2460
  72. package/src/storage/database.ts +0 -271
  73. package/src/storage/tier1.ts +0 -135
  74. package/src/storage/tier2.ts +0 -972
  75. package/src/storage/tier3.ts +0 -123
  76. package/src/types/documentation.ts +0 -619
  77. package/src/types/index.ts +0 -222
  78. package/src/utils/config.ts +0 -194
  79. package/src/utils/files.ts +0 -117
  80. package/src/utils/time.ts +0 -37
  81. package/src/utils/tokens.ts +0 -52
@@ -1,222 +0,0 @@
1
- // Core types for NeuronLayer
2
-
3
- export interface Position {
4
- line: number;
5
- column: number;
6
- }
7
-
8
- export interface ActiveFile {
9
- path: string;
10
- content: string;
11
- cursorPosition?: Position;
12
- language: string;
13
- }
14
-
15
- export interface Session {
16
- startTime: Date;
17
- filesViewed: string[];
18
- currentGoal?: string;
19
- }
20
-
21
- export interface ContextSnippet {
22
- file: string;
23
- content: string;
24
- timestamp: Date;
25
- }
26
-
27
- export interface Tier1Context {
28
- activeFile: ActiveFile | null;
29
- recentDecisions: Decision[];
30
- session: Session;
31
- immediateContext: ContextSnippet[];
32
- }
33
-
34
- export interface Decision {
35
- id: string;
36
- title: string;
37
- description: string;
38
- files: string[];
39
- tags: string[];
40
- createdAt: Date;
41
- // Phase 4: Team features
42
- author?: string;
43
- status?: 'proposed' | 'accepted' | 'deprecated' | 'superseded';
44
- supersededBy?: string;
45
- }
46
-
47
- export interface SearchResult {
48
- file: string;
49
- preview: string;
50
- similarity: number;
51
- lineStart: number;
52
- lineEnd: number;
53
- lastModified: number;
54
- score?: number;
55
- }
56
-
57
- export interface FileMetadata {
58
- id: number;
59
- path: string;
60
- contentHash: string;
61
- preview: string;
62
- language: string;
63
- sizeBytes: number;
64
- lastModified: number;
65
- indexedAt: number;
66
- }
67
-
68
- export interface AssemblyOptions {
69
- maxTokens?: number;
70
- currentFile?: string;
71
- }
72
-
73
- export interface AssembledContext {
74
- context: string;
75
- sources: string[];
76
- tokenCount: number;
77
- decisions: Decision[];
78
- }
79
-
80
- export interface ProjectSummary {
81
- name: string;
82
- description: string;
83
- languages: string[];
84
- totalFiles: number;
85
- totalLines: number;
86
- keyDirectories: string[];
87
- recentDecisions: Decision[];
88
- dependencies: string[];
89
- architectureNotes: string;
90
- }
91
-
92
- export interface ContextParts {
93
- working: {
94
- activeFile: ActiveFile | null;
95
- };
96
- relevant: SearchResult[];
97
- archive: string[];
98
- decisions: Decision[];
99
- }
100
-
101
- export interface TokenBudgetAllocation {
102
- tier1: number;
103
- tier2: number;
104
- tier3: number;
105
- decisions: number;
106
- }
107
-
108
- export interface DependencyRelation {
109
- sourceFileId: number;
110
- targetFileId: number;
111
- relationship: 'imports' | 'exports' | 'calls' | 'type_reference';
112
- }
113
-
114
- export interface IndexingProgress {
115
- total: number;
116
- indexed: number;
117
- current?: string;
118
- }
119
-
120
- export interface NeuronLayerConfig {
121
- projectPath: string;
122
- dataDir: string;
123
- maxTokens: number;
124
- embeddingModel: string;
125
- watchIgnore: string[];
126
- }
127
-
128
- // Phase 2: AST & Symbol types
129
-
130
- export type SymbolKind = 'function' | 'class' | 'interface' | 'type' | 'variable' | 'method' | 'property' | 'enum' | 'constant';
131
-
132
- export interface CodeSymbol {
133
- id?: number;
134
- fileId: number;
135
- filePath: string;
136
- kind: SymbolKind;
137
- name: string;
138
- signature?: string;
139
- docstring?: string;
140
- lineStart: number;
141
- lineEnd: number;
142
- exported: boolean;
143
- }
144
-
145
- export interface Import {
146
- fileId: number;
147
- filePath: string;
148
- importedFrom: string; // The module/file being imported
149
- importedSymbols: string[]; // What's being imported (* for all)
150
- isDefault: boolean;
151
- isNamespace: boolean;
152
- lineNumber: number;
153
- }
154
-
155
- export interface Export {
156
- fileId: number;
157
- filePath: string;
158
- exportedName: string;
159
- localName?: string; // If renamed: export { foo as bar }
160
- isDefault: boolean;
161
- lineNumber: number;
162
- }
163
-
164
- export interface FileDependency {
165
- sourceFile: string;
166
- targetFile: string;
167
- imports: string[]; // What symbols are imported
168
- }
169
-
170
- export interface SymbolSearchResult {
171
- symbol: CodeSymbol;
172
- file: string;
173
- preview: string;
174
- relevance: number;
175
- }
176
-
177
- // Phase 5: Active Feature Context types
178
-
179
- export interface FeatureFile {
180
- path: string;
181
- lastTouched: Date;
182
- touchCount: number;
183
- recentLines: number[];
184
- }
185
-
186
- export interface FeatureChange {
187
- file: string;
188
- timestamp: Date;
189
- diff: string;
190
- linesChanged: number[];
191
- }
192
-
193
- export interface FeatureQuery {
194
- query: string;
195
- timestamp: Date;
196
- filesUsed: string[];
197
- }
198
-
199
- export interface ActiveFeatureContext {
200
- id: string;
201
- name: string;
202
- files: FeatureFile[];
203
- changes: FeatureChange[];
204
- queries: FeatureQuery[];
205
- startedAt: Date;
206
- lastActiveAt: Date;
207
- status: 'active' | 'paused' | 'completed';
208
- }
209
-
210
- export interface HotContext {
211
- files: Array<{
212
- path: string;
213
- content: string | null;
214
- touchCount: number;
215
- }>;
216
- changes: FeatureChange[];
217
- queries: FeatureQuery[];
218
- summary: string;
219
- }
220
-
221
- // Re-export documentation types
222
- export * from './documentation.js';
@@ -1,194 +0,0 @@
1
- import { join, resolve } from 'path';
2
- import type { NeuronLayerConfig } from '../types/index.js';
3
-
4
- export function getDefaultConfig(projectPath: string): NeuronLayerConfig {
5
- const normalizedPath = resolve(projectPath);
6
-
7
- return {
8
- projectPath: normalizedPath,
9
- // Store in project directory (standard practice like .git/, .vscode/)
10
- dataDir: join(normalizedPath, '.neuronlayer'),
11
- maxTokens: 6000,
12
- embeddingModel: 'Xenova/all-MiniLM-L6-v2', // Fallback model, faster and smaller
13
- watchIgnore: [
14
- // ===== NeuronLayer =====
15
- '**/.neuronlayer/**',
16
- '**/.memorylayer/**',
17
-
18
- // ===== Version Control =====
19
- '**/.git/**',
20
- '**/.svn/**',
21
- '**/.hg/**',
22
-
23
- // ===== Node.js / JavaScript =====
24
- '**/node_modules/**',
25
- '**/bower_components/**',
26
- '**/.npm/**',
27
- '**/.yarn/**',
28
- '**/.pnp.*',
29
-
30
- // ===== Build Outputs =====
31
- '**/dist/**',
32
- '**/build/**',
33
- '**/out/**',
34
- '**/output/**',
35
- '**/_build/**',
36
- '**/public/build/**',
37
-
38
- // ===== Next.js =====
39
- '**/.next/**',
40
- '**/.vercel/**',
41
-
42
- // ===== Nuxt.js =====
43
- '**/.nuxt/**',
44
- '**/.output/**',
45
-
46
- // ===== Vite / Rollup / Parcel =====
47
- '**/.vite/**',
48
- '**/.cache/**',
49
- '**/.parcel-cache/**',
50
- '**/.turbo/**',
51
- '**/.svelte-kit/**',
52
-
53
- // ===== Python =====
54
- '**/.venv/**',
55
- '**/venv/**',
56
- '**/env/**',
57
- '**/.env/**',
58
- '**/virtualenv/**',
59
- '**/__pycache__/**',
60
- '**/*.pyc',
61
- '**/*.pyo',
62
- '**/*.pyd',
63
- '**/.Python',
64
- '**/*.egg-info/**',
65
- '**/*.egg/**',
66
- '**/eggs/**',
67
- '**/.eggs/**',
68
- '**/pip-wheel-metadata/**',
69
- '**/.pytest_cache/**',
70
- '**/.mypy_cache/**',
71
- '**/.ruff_cache/**',
72
- '**/.tox/**',
73
- '**/.nox/**',
74
- '**/htmlcov/**',
75
- '**/.coverage',
76
- '**/.hypothesis/**',
77
-
78
- // ===== Django =====
79
- '**/staticfiles/**',
80
- '**/static_collected/**',
81
- '**/media/**',
82
- '**/*.sqlite3',
83
- '**/db.sqlite3',
84
-
85
- // ===== FastAPI / Flask =====
86
- '**/instance/**',
87
-
88
- // ===== Ruby / Rails =====
89
- '**/vendor/bundle/**',
90
- '**/.bundle/**',
91
- '**/tmp/**',
92
- '**/log/**',
93
-
94
- // ===== Go =====
95
- '**/vendor/**',
96
-
97
- // ===== Rust =====
98
- '**/target/**',
99
- '**/*.rlib',
100
-
101
- // ===== Java / Kotlin / Gradle / Maven =====
102
- '**/.gradle/**',
103
- '**/.mvn/**',
104
- '**/target/**',
105
- '**/*.class',
106
- '**/*.jar',
107
- '**/*.war',
108
-
109
- // ===== .NET / C# =====
110
- '**/bin/**',
111
- '**/obj/**',
112
- '**/packages/**',
113
- '**/*.dll',
114
- '**/*.exe',
115
-
116
- // ===== iOS / macOS =====
117
- '**/Pods/**',
118
- '**/.build/**',
119
- '**/DerivedData/**',
120
- '**/*.xcworkspace/**',
121
-
122
- // ===== Android =====
123
- '**/.gradle/**',
124
- '**/local.properties',
125
-
126
- // ===== IDE / Editor =====
127
- '**/.idea/**',
128
- '**/.vscode/**',
129
- '**/*.swp',
130
- '**/*.swo',
131
- '**/*.sublime-*',
132
- '**/.project',
133
- '**/.classpath',
134
- '**/.settings/**',
135
-
136
- // ===== Testing / Coverage =====
137
- '**/coverage/**',
138
- '**/.nyc_output/**',
139
- '**/test-results/**',
140
- '**/jest-cache/**',
141
-
142
- // ===== Misc Generated / Cache =====
143
- '**/.DS_Store',
144
- '**/Thumbs.db',
145
- '**/*.min.js',
146
- '**/*.min.css',
147
- '**/*.map',
148
- '**/*.chunk.js',
149
- '**/*.bundle.js',
150
-
151
- // ===== Lock Files =====
152
- '**/package-lock.json',
153
- '**/yarn.lock',
154
- '**/pnpm-lock.yaml',
155
- '**/Pipfile.lock',
156
- '**/poetry.lock',
157
- '**/Gemfile.lock',
158
- '**/Cargo.lock',
159
- '**/composer.lock',
160
- '**/go.sum',
161
-
162
- // ===== Environment / Secrets =====
163
- '**/.env',
164
- '**/.env.*',
165
- '**/*.env',
166
- '**/.envrc',
167
- '**/secrets/**',
168
- '**/*.pem',
169
- '**/*.key',
170
-
171
- // ===== Logs / Temp =====
172
- '**/*.log',
173
- '**/logs/**',
174
- '**/*.tmp',
175
- '**/*.temp',
176
- '**/temp/**'
177
- ]
178
- };
179
- }
180
-
181
- export function parseArgs(args: string[]): { projectPath: string } {
182
- let projectPath = process.cwd();
183
-
184
- for (let i = 0; i < args.length; i++) {
185
- const arg = args[i];
186
- const nextArg = args[i + 1];
187
- if (arg === '--project' && nextArg) {
188
- projectPath = nextArg;
189
- break;
190
- }
191
- }
192
-
193
- return { projectPath: resolve(projectPath) };
194
- }
@@ -1,117 +0,0 @@
1
- import { createHash } from 'crypto';
2
- import { extname } from 'path';
3
-
4
- const LANGUAGE_MAP: Record<string, string> = {
5
- '.ts': 'typescript',
6
- '.tsx': 'typescript',
7
- '.js': 'javascript',
8
- '.jsx': 'javascript',
9
- '.mjs': 'javascript',
10
- '.cjs': 'javascript',
11
- '.py': 'python',
12
- '.rb': 'ruby',
13
- '.go': 'go',
14
- '.rs': 'rust',
15
- '.java': 'java',
16
- '.kt': 'kotlin',
17
- '.scala': 'scala',
18
- '.cs': 'csharp',
19
- '.cpp': 'cpp',
20
- '.cc': 'cpp',
21
- '.c': 'c',
22
- '.h': 'c',
23
- '.hpp': 'cpp',
24
- '.php': 'php',
25
- '.swift': 'swift',
26
- '.m': 'objectivec',
27
- '.mm': 'objectivec',
28
- '.vue': 'vue',
29
- '.svelte': 'svelte',
30
- '.astro': 'astro',
31
- '.md': 'markdown',
32
- '.mdx': 'mdx',
33
- '.json': 'json',
34
- '.yaml': 'yaml',
35
- '.yml': 'yaml',
36
- '.toml': 'toml',
37
- '.xml': 'xml',
38
- '.html': 'html',
39
- '.htm': 'html',
40
- '.css': 'css',
41
- '.scss': 'scss',
42
- '.sass': 'sass',
43
- '.less': 'less',
44
- '.sql': 'sql',
45
- '.sh': 'bash',
46
- '.bash': 'bash',
47
- '.zsh': 'zsh',
48
- '.fish': 'fish',
49
- '.ps1': 'powershell',
50
- '.dockerfile': 'dockerfile',
51
- '.prisma': 'prisma',
52
- '.graphql': 'graphql',
53
- '.gql': 'graphql',
54
- '.proto': 'protobuf',
55
- '.tf': 'terraform',
56
- '.lua': 'lua',
57
- '.r': 'r',
58
- '.R': 'r',
59
- '.jl': 'julia',
60
- '.ex': 'elixir',
61
- '.exs': 'elixir',
62
- '.erl': 'erlang',
63
- '.hrl': 'erlang',
64
- '.clj': 'clojure',
65
- '.cljs': 'clojure',
66
- '.cljc': 'clojure',
67
- '.hs': 'haskell',
68
- '.ml': 'ocaml',
69
- '.mli': 'ocaml',
70
- '.fs': 'fsharp',
71
- '.fsi': 'fsharp',
72
- '.fsx': 'fsharp',
73
- '.dart': 'dart',
74
- '.nim': 'nim',
75
- '.zig': 'zig',
76
- '.v': 'v',
77
- '.odin': 'odin',
78
- };
79
-
80
- const CODE_EXTENSIONS = new Set(Object.keys(LANGUAGE_MAP));
81
-
82
- export function detectLanguage(filePath: string): string {
83
- const ext = extname(filePath).toLowerCase();
84
-
85
- // Handle special filenames
86
- const filename = filePath.split(/[/\\]/).pop()?.toLowerCase() || '';
87
- if (filename === 'dockerfile') return 'dockerfile';
88
- if (filename === 'makefile') return 'makefile';
89
- if (filename === 'cmakelists.txt') return 'cmake';
90
-
91
- return LANGUAGE_MAP[ext] || 'plaintext';
92
- }
93
-
94
- export function isCodeFile(filePath: string): boolean {
95
- const ext = extname(filePath).toLowerCase();
96
- const filename = filePath.split(/[/\\]/).pop()?.toLowerCase() || '';
97
-
98
- return CODE_EXTENSIONS.has(ext) ||
99
- filename === 'dockerfile' ||
100
- filename === 'makefile';
101
- }
102
-
103
- export function hashContent(content: string): string {
104
- return createHash('sha256').update(content).digest('hex');
105
- }
106
-
107
- export function getPreview(content: string, maxLength: number = 1000): string {
108
- if (content.length <= maxLength) {
109
- return content;
110
- }
111
- return content.slice(0, maxLength) + '\n... [truncated]';
112
- }
113
-
114
- export function countLines(content: string): number {
115
- if (!content) return 0;
116
- return content.split('\n').length;
117
- }
package/src/utils/time.ts DELETED
@@ -1,37 +0,0 @@
1
- /**
2
- * Time utilities
3
- */
4
-
5
- /**
6
- * Format a date as a human-readable "time ago" string
7
- */
8
- export function formatTimeAgo(date: Date): string {
9
- const now = new Date();
10
- const diffMs = now.getTime() - date.getTime();
11
- const diffMins = Math.floor(diffMs / (1000 * 60));
12
- const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
13
- const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
14
- const diffWeeks = Math.floor(diffDays / 7);
15
- const diffMonths = Math.floor(diffDays / 30);
16
-
17
- if (diffMins < 1) return 'just now';
18
- if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? 's' : ''} ago`;
19
- if (diffHours < 24) return `${diffHours} hour${diffHours > 1 ? 's' : ''} ago`;
20
- if (diffDays === 1) return 'yesterday';
21
- if (diffDays < 7) return `${diffDays} days ago`;
22
- if (diffWeeks === 1) return '1 week ago';
23
- if (diffWeeks < 4) return `${diffWeeks} weeks ago`;
24
- if (diffMonths === 1) return '1 month ago';
25
- if (diffMonths < 12) return `${diffMonths} months ago`;
26
-
27
- return date.toLocaleDateString();
28
- }
29
-
30
- /**
31
- * Format a date as "time ago" with an action and file context
32
- */
33
- export function formatTimeAgoWithContext(date: Date, action: string, file: string): string {
34
- const timeAgo = formatTimeAgo(date);
35
- const fileName = file.split(/[/\\]/).pop() || file;
36
- return `You ${action} in ${fileName} ${timeAgo === 'just now' ? 'just now' : timeAgo}`;
37
- }
@@ -1,52 +0,0 @@
1
- // Simple token estimation
2
- // For more accurate counting, consider using tiktoken or similar
3
- // This approximation is sufficient for budget management
4
-
5
- const AVG_CHARS_PER_TOKEN = 4;
6
-
7
- export function estimateTokens(text: string): number {
8
- if (!text) return 0;
9
- // Rough approximation: 1 token ≈ 4 characters for English/code
10
- // This is a simplification but works well enough for budgeting
11
- return Math.ceil(text.length / AVG_CHARS_PER_TOKEN);
12
- }
13
-
14
- export class TokenBudget {
15
- private total: number;
16
- private allocations: Map<string, number> = new Map();
17
-
18
- constructor(total: number) {
19
- this.total = total;
20
- }
21
-
22
- used(): number {
23
- let sum = 0;
24
- for (const tokens of this.allocations.values()) {
25
- sum += tokens;
26
- }
27
- return sum;
28
- }
29
-
30
- remaining(): number {
31
- return this.total - this.used();
32
- }
33
-
34
- canFit(text: string): boolean {
35
- return estimateTokens(text) <= this.remaining();
36
- }
37
-
38
- allocate(text: string, category: string): boolean {
39
- const tokens = estimateTokens(text);
40
- if (tokens > this.remaining()) {
41
- return false;
42
- }
43
-
44
- const current = this.allocations.get(category) || 0;
45
- this.allocations.set(category, current + tokens);
46
- return true;
47
- }
48
-
49
- getAllocations(): Record<string, number> {
50
- return Object.fromEntries(this.allocations);
51
- }
52
- }