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,296 +0,0 @@
1
- import { execSync } from 'child_process';
2
- import { existsSync } from 'fs';
3
- import { join } from 'path';
4
- import type Database from 'better-sqlite3';
5
- import type { Tier2Storage } from '../../storage/tier2.js';
6
- import type {
7
- ActivityResult,
8
- ActivityChange,
9
- ActivityDecision
10
- } from '../../types/documentation.js';
11
-
12
- export class ActivityTracker {
13
- private projectPath: string;
14
- private db: Database.Database;
15
- private tier2: Tier2Storage;
16
- private isGitRepo: boolean;
17
-
18
- constructor(projectPath: string, db: Database.Database, tier2: Tier2Storage) {
19
- this.projectPath = projectPath;
20
- this.db = db;
21
- this.tier2 = tier2;
22
- this.isGitRepo = existsSync(join(projectPath, '.git'));
23
- }
24
-
25
- async whatHappened(since: string, scope?: string): Promise<ActivityResult> {
26
- const sinceDate = this.parseSinceString(since);
27
- const untilDate = new Date();
28
-
29
- const gitActivity = this.getGitActivity(sinceDate, untilDate, scope);
30
- const decisions = this.getDecisionActivity(sinceDate, untilDate);
31
- const filesAffected = this.getAffectedFiles(gitActivity);
32
-
33
- return {
34
- timeRange: { since: sinceDate, until: untilDate },
35
- scope: scope || 'all',
36
- summary: this.generateSummary(gitActivity, decisions),
37
- changes: gitActivity,
38
- decisions,
39
- filesAffected
40
- };
41
- }
42
-
43
- logActivity(
44
- activityType: string,
45
- description: string,
46
- filePath?: string,
47
- metadata?: Record<string, unknown>,
48
- commitHash?: string
49
- ): void {
50
- try {
51
- const stmt = this.db.prepare(`
52
- INSERT INTO activity_log (activity_type, description, file_path, metadata, commit_hash)
53
- VALUES (?, ?, ?, ?, ?)
54
- `);
55
- stmt.run(
56
- activityType,
57
- description,
58
- filePath || null,
59
- metadata ? JSON.stringify(metadata) : null,
60
- commitHash || null
61
- );
62
- } catch {
63
- // Ignore logging errors
64
- }
65
- }
66
-
67
- private parseSinceString(since: string): Date {
68
- const now = new Date();
69
- const lower = since.toLowerCase();
70
-
71
- if (lower === 'yesterday') {
72
- const yesterday = new Date(now);
73
- yesterday.setDate(yesterday.getDate() - 1);
74
- yesterday.setHours(0, 0, 0, 0);
75
- return yesterday;
76
- }
77
- if (lower === 'today') {
78
- const today = new Date(now);
79
- today.setHours(0, 0, 0, 0);
80
- return today;
81
- }
82
- if (lower === 'this week') {
83
- const dayOfWeek = now.getDay();
84
- const startOfWeek = new Date(now);
85
- startOfWeek.setDate(now.getDate() - dayOfWeek);
86
- startOfWeek.setHours(0, 0, 0, 0);
87
- return startOfWeek;
88
- }
89
- if (lower === 'this month') {
90
- return new Date(now.getFullYear(), now.getMonth(), 1);
91
- }
92
- if (lower === 'last week') {
93
- const dayOfWeek = now.getDay();
94
- const startOfLastWeek = new Date(now);
95
- startOfLastWeek.setDate(now.getDate() - dayOfWeek - 7);
96
- startOfLastWeek.setHours(0, 0, 0, 0);
97
- return startOfLastWeek;
98
- }
99
- if (lower === 'last month') {
100
- const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
101
- return lastMonth;
102
- }
103
-
104
- // Try parsing as a date string
105
- const parsed = new Date(since);
106
- return isNaN(parsed.getTime()) ? new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000) : parsed;
107
- }
108
-
109
- private getGitActivity(since: Date, until: Date, scope?: string): ActivityChange[] {
110
- const changes: ActivityChange[] = [];
111
-
112
- if (!this.isGitRepo) {
113
- return changes;
114
- }
115
-
116
- try {
117
- const sinceStr = since.toISOString().split('T')[0];
118
- const untilStr = until.toISOString().split('T')[0];
119
-
120
- let gitCmd = `git log --since="${sinceStr}" --until="${untilStr}" --format="%H|%s|%an|%ad" --date=iso-strict`;
121
-
122
- // If scope is provided, filter by path
123
- if (scope && scope !== 'all') {
124
- gitCmd += ` -- "${scope}"`;
125
- }
126
-
127
- const output = execSync(gitCmd, {
128
- cwd: this.projectPath,
129
- encoding: 'utf-8',
130
- maxBuffer: 5 * 1024 * 1024
131
- });
132
-
133
- const lines = output.trim().split('\n').filter(Boolean);
134
-
135
- for (const line of lines) {
136
- const [hash, subject, author, dateStr] = line.split('|');
137
- if (!hash || !subject) continue;
138
-
139
- // Get files changed in this commit
140
- const files = this.getCommitFiles(hash);
141
-
142
- changes.push({
143
- timestamp: new Date(dateStr || Date.now()),
144
- type: 'commit',
145
- description: subject,
146
- details: {
147
- hash: hash.slice(0, 8),
148
- author,
149
- files
150
- }
151
- });
152
- }
153
- } catch {
154
- // Git command failed
155
- }
156
-
157
- // Also get activity from activity_log table
158
- try {
159
- const sinceUnix = Math.floor(since.getTime() / 1000);
160
- const untilUnix = Math.floor(until.getTime() / 1000);
161
-
162
- let query = `
163
- SELECT timestamp, activity_type, description, file_path, metadata
164
- FROM activity_log
165
- WHERE timestamp >= ? AND timestamp <= ?
166
- `;
167
- const params: (number | string)[] = [sinceUnix, untilUnix];
168
-
169
- if (scope && scope !== 'all') {
170
- query += ' AND file_path LIKE ?';
171
- params.push(`%${scope}%`);
172
- }
173
-
174
- query += ' ORDER BY timestamp DESC';
175
-
176
- const stmt = this.db.prepare(query);
177
- const rows = stmt.all(...params) as Array<{
178
- timestamp: number;
179
- activity_type: string;
180
- description: string;
181
- file_path: string | null;
182
- metadata: string | null;
183
- }>;
184
-
185
- for (const row of rows) {
186
- changes.push({
187
- timestamp: new Date(row.timestamp * 1000),
188
- type: 'file_change',
189
- description: row.description,
190
- details: {
191
- activityType: row.activity_type,
192
- filePath: row.file_path,
193
- ...(row.metadata ? JSON.parse(row.metadata) : {})
194
- }
195
- });
196
- }
197
- } catch {
198
- // Database query failed
199
- }
200
-
201
- // Sort by timestamp descending
202
- changes.sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
203
-
204
- return changes;
205
- }
206
-
207
- private getCommitFiles(hash: string): string[] {
208
- try {
209
- const output = execSync(
210
- `git show --name-only --format="" "${hash}"`,
211
- { cwd: this.projectPath, encoding: 'utf-8', maxBuffer: 1024 * 1024 }
212
- );
213
- return output.trim().split('\n').filter(Boolean);
214
- } catch {
215
- return [];
216
- }
217
- }
218
-
219
- private getDecisionActivity(since: Date, until: Date): ActivityDecision[] {
220
- const decisions: ActivityDecision[] = [];
221
-
222
- try {
223
- const sinceUnix = Math.floor(since.getTime() / 1000);
224
- const untilUnix = Math.floor(until.getTime() / 1000);
225
-
226
- const stmt = this.db.prepare(`
227
- SELECT id, title, created_at
228
- FROM decisions
229
- WHERE created_at >= ? AND created_at <= ?
230
- ORDER BY created_at DESC
231
- `);
232
-
233
- const rows = stmt.all(sinceUnix, untilUnix) as Array<{
234
- id: string;
235
- title: string;
236
- created_at: number;
237
- }>;
238
-
239
- for (const row of rows) {
240
- decisions.push({
241
- id: row.id,
242
- title: row.title,
243
- date: new Date(row.created_at * 1000)
244
- });
245
- }
246
- } catch {
247
- // Database query failed
248
- }
249
-
250
- return decisions;
251
- }
252
-
253
- private getAffectedFiles(changes: ActivityChange[]): string[] {
254
- const filesSet = new Set<string>();
255
-
256
- for (const change of changes) {
257
- if (change.details.files && Array.isArray(change.details.files)) {
258
- for (const file of change.details.files) {
259
- filesSet.add(file as string);
260
- }
261
- }
262
- if (change.details.filePath) {
263
- filesSet.add(change.details.filePath as string);
264
- }
265
- }
266
-
267
- return Array.from(filesSet).sort();
268
- }
269
-
270
- private generateSummary(changes: ActivityChange[], decisions: ActivityDecision[]): string {
271
- const commits = changes.filter(c => c.type === 'commit').length;
272
- const fileChanges = changes.filter(c => c.type === 'file_change').length;
273
- const decisionCount = decisions.length;
274
-
275
- const parts: string[] = [];
276
-
277
- if (commits > 0) {
278
- parts.push(`${commits} commit${commits !== 1 ? 's' : ''}`);
279
- }
280
- if (fileChanges > 0) {
281
- parts.push(`${fileChanges} file change${fileChanges !== 1 ? 's' : ''}`);
282
- }
283
- if (decisionCount > 0) {
284
- parts.push(`${decisionCount} decision${decisionCount !== 1 ? 's' : ''}`);
285
- }
286
-
287
- if (parts.length === 0) {
288
- return 'No activity in this time period';
289
- }
290
-
291
- // Get unique files affected
292
- const filesAffected = this.getAffectedFiles(changes);
293
-
294
- return `${parts.join(', ')} affecting ${filesAffected.length} file${filesAffected.length !== 1 ? 's' : ''}`;
295
- }
296
- }