cortex-mcp 2.5.0 → 2.7.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.
Files changed (166) hide show
  1. package/CHANGELOG.md +58 -279
  2. package/README.md +224 -393
  3. package/dist/cli/setup.js +60 -58
  4. package/dist/cli/setup.js.map +1 -1
  5. package/dist/config/config.js +2 -2
  6. package/dist/config/config.js.map +1 -1
  7. package/dist/db/database.d.ts +0 -8
  8. package/dist/db/database.d.ts.map +1 -1
  9. package/dist/db/database.js +2 -34
  10. package/dist/db/database.js.map +1 -1
  11. package/dist/db/event-log.d.ts +0 -4
  12. package/dist/db/event-log.d.ts.map +1 -1
  13. package/dist/db/event-log.js +10 -14
  14. package/dist/db/event-log.js.map +1 -1
  15. package/dist/db/memory-store.d.ts +3 -30
  16. package/dist/db/memory-store.d.ts.map +1 -1
  17. package/dist/db/memory-store.js +44 -140
  18. package/dist/db/memory-store.js.map +1 -1
  19. package/dist/embedding-worker.js +1 -1
  20. package/dist/embedding-worker.js.map +1 -1
  21. package/dist/hooks/git-capture.js +3 -3
  22. package/dist/hooks/git-hooks.js +2 -5
  23. package/dist/mcp-stdio.js +3 -34
  24. package/dist/mcp-stdio.js.map +1 -1
  25. package/dist/memory/anticipation-engine.d.ts.map +1 -1
  26. package/dist/memory/anticipation-engine.js +10 -18
  27. package/dist/memory/anticipation-engine.js.map +1 -1
  28. package/dist/memory/auto-learner.d.ts.map +1 -1
  29. package/dist/memory/auto-learner.js +43 -190
  30. package/dist/memory/auto-learner.js.map +1 -1
  31. package/dist/memory/confidence-decay.d.ts.map +1 -1
  32. package/dist/memory/confidence-decay.js +9 -13
  33. package/dist/memory/confidence-decay.js.map +1 -1
  34. package/dist/memory/embedding-manager.d.ts.map +1 -1
  35. package/dist/memory/embedding-manager.js +4 -6
  36. package/dist/memory/embedding-manager.js.map +1 -1
  37. package/dist/memory/export-import.js +2 -2
  38. package/dist/memory/export-import.js.map +1 -1
  39. package/dist/memory/git-memory.d.ts.map +1 -1
  40. package/dist/memory/git-memory.js +26 -20
  41. package/dist/memory/git-memory.js.map +1 -1
  42. package/dist/memory/learning-rate.js +7 -8
  43. package/dist/memory/learning-rate.js.map +1 -1
  44. package/dist/memory/llm-enhancer.d.ts +14 -2
  45. package/dist/memory/llm-enhancer.d.ts.map +1 -1
  46. package/dist/memory/llm-enhancer.js +46 -66
  47. package/dist/memory/llm-enhancer.js.map +1 -1
  48. package/dist/memory/memory-cache.d.ts.map +1 -1
  49. package/dist/memory/memory-cache.js +0 -10
  50. package/dist/memory/memory-cache.js.map +1 -1
  51. package/dist/memory/memory-consolidator.d.ts.map +1 -1
  52. package/dist/memory/memory-consolidator.js +14 -20
  53. package/dist/memory/memory-consolidator.js.map +1 -1
  54. package/dist/memory/memory-decay.d.ts.map +1 -1
  55. package/dist/memory/memory-decay.js +51 -77
  56. package/dist/memory/memory-decay.js.map +1 -1
  57. package/dist/memory/memory-quality.d.ts +1 -1
  58. package/dist/memory/memory-quality.d.ts.map +1 -1
  59. package/dist/memory/memory-quality.js +6 -9
  60. package/dist/memory/memory-quality.js.map +1 -1
  61. package/dist/memory/memory-ranker.d.ts.map +1 -1
  62. package/dist/memory/memory-ranker.js +3 -7
  63. package/dist/memory/memory-ranker.js.map +1 -1
  64. package/dist/memory/meta-memory.js +3 -3
  65. package/dist/memory/meta-memory.js.map +1 -1
  66. package/dist/memory/session-tracker.d.ts +0 -2
  67. package/dist/memory/session-tracker.d.ts.map +1 -1
  68. package/dist/memory/session-tracker.js +8 -26
  69. package/dist/memory/session-tracker.js.map +1 -1
  70. package/dist/memory/temporal-engine.d.ts.map +1 -1
  71. package/dist/memory/temporal-engine.js +13 -9
  72. package/dist/memory/temporal-engine.js.map +1 -1
  73. package/dist/retrieval/hybrid-retriever.d.ts +2 -0
  74. package/dist/retrieval/hybrid-retriever.d.ts.map +1 -1
  75. package/dist/retrieval/hybrid-retriever.js +13 -3
  76. package/dist/retrieval/hybrid-retriever.js.map +1 -1
  77. package/dist/scanners/architecture-graph.js +2 -2
  78. package/dist/scanners/architecture-graph.js.map +1 -1
  79. package/dist/scanners/code-verifier.d.ts +0 -1
  80. package/dist/scanners/code-verifier.d.ts.map +1 -1
  81. package/dist/scanners/code-verifier.js +14 -14
  82. package/dist/scanners/code-verifier.js.map +1 -1
  83. package/dist/scanners/context-builder.d.ts.map +1 -1
  84. package/dist/scanners/context-builder.js +45 -33
  85. package/dist/scanners/context-builder.js.map +1 -1
  86. package/dist/scanners/export-map.js +2 -2
  87. package/dist/scanners/export-map.js.map +1 -1
  88. package/dist/scanners/project-scanner.js +2 -2
  89. package/dist/scanners/project-scanner.js.map +1 -1
  90. package/dist/security/encryption.js +1 -1
  91. package/dist/security/encryption.js.map +1 -1
  92. package/dist/security/feature-gate.d.ts.map +1 -1
  93. package/dist/security/feature-gate.js +20 -62
  94. package/dist/security/feature-gate.js.map +1 -1
  95. package/dist/security/license.js +35 -282
  96. package/dist/security/license.js.map +1 -1
  97. package/dist/security/rate-limiter.d.ts +3 -4
  98. package/dist/security/rate-limiter.d.ts.map +1 -1
  99. package/dist/security/rate-limiter.js +29 -11
  100. package/dist/security/rate-limiter.js.map +1 -1
  101. package/dist/server/dashboard.js +327 -166
  102. package/dist/server/dashboard.js.map +1 -1
  103. package/dist/server/mcp-handler.d.ts.map +1 -1
  104. package/dist/server/mcp-handler.js +771 -891
  105. package/dist/server/mcp-handler.js.map +1 -1
  106. package/package.json +8 -18
  107. package/dist/memory/completion-resolver.d.ts +0 -38
  108. package/dist/memory/completion-resolver.d.ts.map +0 -1
  109. package/dist/memory/completion-resolver.js +0 -127
  110. package/dist/memory/completion-resolver.js.map +0 -1
  111. package/dist/memory/convention-detector.d.ts +0 -11
  112. package/dist/memory/convention-detector.d.ts.map +0 -1
  113. package/dist/memory/convention-detector.js +0 -294
  114. package/dist/memory/convention-detector.js.map +0 -1
  115. package/dist/memory/correction-detector.d.ts +0 -33
  116. package/dist/memory/correction-detector.d.ts.map +0 -1
  117. package/dist/memory/correction-detector.js +0 -129
  118. package/dist/memory/correction-detector.js.map +0 -1
  119. package/dist/memory/error-learner.d.ts +0 -26
  120. package/dist/memory/error-learner.d.ts.map +0 -1
  121. package/dist/memory/error-learner.js +0 -145
  122. package/dist/memory/error-learner.js.map +0 -1
  123. package/dist/memory/file-relationships.d.ts +0 -47
  124. package/dist/memory/file-relationships.d.ts.map +0 -1
  125. package/dist/memory/file-relationships.js +0 -130
  126. package/dist/memory/file-relationships.js.map +0 -1
  127. package/dist/memory/impact-analyzer.d.ts +0 -16
  128. package/dist/memory/impact-analyzer.d.ts.map +0 -1
  129. package/dist/memory/impact-analyzer.js +0 -189
  130. package/dist/memory/impact-analyzer.js.map +0 -1
  131. package/dist/memory/instructions-generator.d.ts +0 -30
  132. package/dist/memory/instructions-generator.d.ts.map +0 -1
  133. package/dist/memory/instructions-generator.js +0 -117
  134. package/dist/memory/instructions-generator.js.map +0 -1
  135. package/dist/memory/pre-flight.d.ts +0 -24
  136. package/dist/memory/pre-flight.d.ts.map +0 -1
  137. package/dist/memory/pre-flight.js +0 -121
  138. package/dist/memory/pre-flight.js.map +0 -1
  139. package/dist/memory/preference-learner.d.ts +0 -28
  140. package/dist/memory/preference-learner.d.ts.map +0 -1
  141. package/dist/memory/preference-learner.js +0 -144
  142. package/dist/memory/preference-learner.js.map +0 -1
  143. package/dist/memory/regression-guard.d.ts +0 -35
  144. package/dist/memory/regression-guard.d.ts.map +0 -1
  145. package/dist/memory/regression-guard.js +0 -90
  146. package/dist/memory/regression-guard.js.map +0 -1
  147. package/dist/memory/resume-work.d.ts +0 -37
  148. package/dist/memory/resume-work.d.ts.map +0 -1
  149. package/dist/memory/resume-work.js +0 -141
  150. package/dist/memory/resume-work.js.map +0 -1
  151. package/dist/memory/success-tracker.d.ts +0 -33
  152. package/dist/memory/success-tracker.d.ts.map +0 -1
  153. package/dist/memory/success-tracker.js +0 -75
  154. package/dist/memory/success-tracker.js.map +0 -1
  155. package/dist/memory/tool-recommender.d.ts +0 -29
  156. package/dist/memory/tool-recommender.d.ts.map +0 -1
  157. package/dist/memory/tool-recommender.js +0 -117
  158. package/dist/memory/tool-recommender.js.map +0 -1
  159. package/dist/memory/usage-stats.d.ts +0 -98
  160. package/dist/memory/usage-stats.d.ts.map +0 -1
  161. package/dist/memory/usage-stats.js +0 -345
  162. package/dist/memory/usage-stats.js.map +0 -1
  163. package/dist/utils/extract-tags.d.ts +0 -16
  164. package/dist/utils/extract-tags.d.ts.map +0 -1
  165. package/dist/utils/extract-tags.js +0 -40
  166. package/dist/utils/extract-tags.js.map +0 -1
@@ -1,294 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.detectConventions = detectConventions;
37
- /**
38
- * Convention Detector — Auto-discovers coding patterns from source code.
39
- *
40
- * Scans actual project code to detect coding conventions:
41
- * - Arrow functions vs function declarations
42
- * - const vs let vs var usage
43
- * - Error handling patterns (try/catch, .catch(), Result type)
44
- * - Import style (named vs default, relative vs absolute)
45
- * - Naming conventions (camelCase, PascalCase, snake_case)
46
- * - File organization patterns
47
- *
48
- * Stores detected patterns as CONVENTION memories so the AI follows
49
- * the project's actual style, not generic defaults.
50
- */
51
- const fs = __importStar(require("fs"));
52
- const path = __importStar(require("path"));
53
- /**
54
- * Scan source files and detect coding conventions.
55
- */
56
- function detectConventions(workspaceRoot) {
57
- const conventions = [];
58
- const files = getSourceFiles(workspaceRoot);
59
- if (files.length === 0)
60
- return conventions;
61
- // Counters for pattern detection
62
- const counts = {
63
- arrowFunctions: 0,
64
- functionDeclarations: 0,
65
- constUsage: 0,
66
- letUsage: 0,
67
- varUsage: 0,
68
- tryCatch: 0,
69
- dotCatch: 0,
70
- namedImports: 0,
71
- defaultImports: 0,
72
- relativeImports: 0,
73
- absoluteImports: 0,
74
- semicolons: 0,
75
- noSemicolons: 0,
76
- singleQuotes: 0,
77
- doubleQuotes: 0,
78
- asyncAwait: 0,
79
- thenChain: 0,
80
- typeAnnotations: 0,
81
- interfaceCount: 0,
82
- enumCount: 0,
83
- classCount: 0,
84
- };
85
- // Sample up to 20 files for speed
86
- const sampleFiles = files.slice(0, 20);
87
- let _totalLines = 0;
88
- for (const file of sampleFiles) {
89
- try {
90
- const content = fs.readFileSync(path.join(workspaceRoot, file), 'utf-8');
91
- const lines = content.split('\n');
92
- _totalLines += lines.length;
93
- // Count patterns
94
- counts.arrowFunctions += (content.match(/=>\s*{/g) || []).length;
95
- counts.functionDeclarations += (content.match(/function\s+\w+/g) || []).length;
96
- counts.constUsage += (content.match(/\bconst\s+/g) || []).length;
97
- counts.letUsage += (content.match(/\blet\s+/g) || []).length;
98
- counts.varUsage += (content.match(/\bvar\s+/g) || []).length;
99
- counts.tryCatch += (content.match(/try\s*{/g) || []).length;
100
- counts.dotCatch += (content.match(/\.catch\(/g) || []).length;
101
- counts.namedImports += (content.match(/import\s+{/g) || []).length;
102
- counts.defaultImports += (content.match(/import\s+\w+\s+from/g) || []).length;
103
- counts.relativeImports += (content.match(/from\s+['"]\.\//g) || []).length;
104
- counts.absoluteImports += (content.match(/from\s+['"](?!\.)/g) || []).length;
105
- counts.asyncAwait += (content.match(/\basync\s+/g) || []).length;
106
- counts.thenChain += (content.match(/\.then\(/g) || []).length;
107
- counts.typeAnnotations += (content.match(/:\s*(string|number|boolean|any|void|never)/g) || []).length;
108
- counts.interfaceCount += (content.match(/\binterface\s+\w+/g) || []).length;
109
- counts.enumCount += (content.match(/\benum\s+\w+/g) || []).length;
110
- counts.classCount += (content.match(/\bclass\s+\w+/g) || []).length;
111
- // Sample lines for semicolon and quote detection
112
- for (const line of lines.slice(0, 50)) {
113
- const trimmed = line.trim();
114
- if (trimmed.length > 5 && !trimmed.startsWith('//') && !trimmed.startsWith('*')) {
115
- if (trimmed.endsWith(';'))
116
- counts.semicolons++;
117
- else
118
- counts.noSemicolons++;
119
- if (trimmed.includes("'"))
120
- counts.singleQuotes++;
121
- if (trimmed.includes('"'))
122
- counts.doubleQuotes++;
123
- }
124
- }
125
- }
126
- catch { /* skip unreadable files */ }
127
- }
128
- // ─── Derive Conventions ──────────────────────────────────────────────────
129
- const total = (a, b) => a + b || 1;
130
- const ratio = (a, b) => a / total(a, b);
131
- // Function style
132
- const arrowRatio = ratio(counts.arrowFunctions, counts.functionDeclarations);
133
- if (arrowRatio > 0.7) {
134
- conventions.push({
135
- pattern: 'Use arrow functions (=>) — this project strongly prefers arrow functions over function declarations',
136
- evidence: `${counts.arrowFunctions} arrow functions vs ${counts.functionDeclarations} function declarations (${Math.round(arrowRatio * 100)}% arrow)`,
137
- confidence: Math.min(0.9, 0.6 + arrowRatio * 0.3),
138
- category: 'functions',
139
- });
140
- }
141
- else if (arrowRatio < 0.3) {
142
- conventions.push({
143
- pattern: 'Use function declarations — this project prefers traditional function declarations over arrow functions',
144
- evidence: `${counts.functionDeclarations} function declarations vs ${counts.arrowFunctions} arrow functions`,
145
- confidence: Math.min(0.9, 0.6 + (1 - arrowRatio) * 0.3),
146
- category: 'functions',
147
- });
148
- }
149
- // Variable declarations
150
- if (counts.varUsage > 0 && counts.constUsage + counts.letUsage > 0) {
151
- const varRatio = counts.varUsage / total(counts.varUsage, counts.constUsage + counts.letUsage);
152
- if (varRatio < 0.1) {
153
- conventions.push({
154
- pattern: 'Never use var — this project uses const/let exclusively',
155
- evidence: `${counts.constUsage} const, ${counts.letUsage} let, only ${counts.varUsage} var`,
156
- confidence: 0.90,
157
- category: 'variables',
158
- });
159
- }
160
- }
161
- if (counts.constUsage > 0 && counts.letUsage > 0) {
162
- const constRatio = ratio(counts.constUsage, counts.letUsage);
163
- if (constRatio > 0.8) {
164
- conventions.push({
165
- pattern: 'Prefer const over let — this project heavily favors immutable bindings',
166
- evidence: `${counts.constUsage} const vs ${counts.letUsage} let (${Math.round(constRatio * 100)}% const)`,
167
- confidence: 0.80,
168
- category: 'variables',
169
- });
170
- }
171
- }
172
- // Async patterns
173
- const asyncRatio = ratio(counts.asyncAwait, counts.thenChain);
174
- if (asyncRatio > 0.8 && counts.asyncAwait > 3) {
175
- conventions.push({
176
- pattern: 'Use async/await — this project uses async/await pattern, avoid .then() chains',
177
- evidence: `${counts.asyncAwait} async/await vs ${counts.thenChain} .then() chains`,
178
- confidence: 0.85,
179
- category: 'functions',
180
- });
181
- }
182
- // Error handling
183
- if (counts.tryCatch > 3) {
184
- conventions.push({
185
- pattern: 'Use try/catch for error handling — project uses structured error handling',
186
- evidence: `${counts.tryCatch} try/catch blocks, ${counts.dotCatch} .catch() handlers`,
187
- confidence: 0.75,
188
- category: 'errors',
189
- });
190
- }
191
- // Import style
192
- if (counts.namedImports > counts.defaultImports * 2) {
193
- conventions.push({
194
- pattern: 'Prefer named imports over default imports: import { X } from "..."',
195
- evidence: `${counts.namedImports} named imports vs ${counts.defaultImports} default imports`,
196
- confidence: 0.75,
197
- category: 'imports',
198
- });
199
- }
200
- // TypeScript strictness
201
- if (counts.typeAnnotations > 10 && counts.interfaceCount > 3) {
202
- conventions.push({
203
- pattern: 'Use explicit TypeScript types — project uses strong typing with interfaces',
204
- evidence: `${counts.typeAnnotations} type annotations, ${counts.interfaceCount} interfaces, ${counts.enumCount} enums`,
205
- confidence: 0.85,
206
- category: 'naming',
207
- });
208
- }
209
- // Semicolons
210
- const semiRatio = ratio(counts.semicolons, counts.noSemicolons);
211
- if (semiRatio > 0.8) {
212
- conventions.push({
213
- pattern: 'Always use semicolons at end of statements',
214
- evidence: `${Math.round(semiRatio * 100)}% of lines end with semicolons`,
215
- confidence: 0.80,
216
- category: 'structure',
217
- });
218
- }
219
- else if (semiRatio < 0.2) {
220
- conventions.push({
221
- pattern: 'No semicolons — project uses ASI (automatic semicolon insertion)',
222
- evidence: `Only ${Math.round(semiRatio * 100)}% of lines have semicolons`,
223
- confidence: 0.80,
224
- category: 'structure',
225
- });
226
- }
227
- // Quote style
228
- const quoteRatio = ratio(counts.singleQuotes, counts.doubleQuotes);
229
- if (quoteRatio > 0.7) {
230
- conventions.push({
231
- pattern: 'Use single quotes for strings',
232
- evidence: `${counts.singleQuotes} single-quoted vs ${counts.doubleQuotes} double-quoted strings`,
233
- confidence: 0.75,
234
- category: 'structure',
235
- });
236
- }
237
- else if (quoteRatio < 0.3) {
238
- conventions.push({
239
- pattern: 'Use double quotes for strings',
240
- evidence: `${counts.doubleQuotes} double-quoted vs ${counts.singleQuotes} single-quoted strings`,
241
- confidence: 0.75,
242
- category: 'structure',
243
- });
244
- }
245
- // Class vs functional style
246
- if (counts.classCount > 5) {
247
- conventions.push({
248
- pattern: 'Uses class-based architecture (OOP style)',
249
- evidence: `${counts.classCount} classes found across ${sampleFiles.length} files`,
250
- confidence: 0.70,
251
- category: 'structure',
252
- });
253
- }
254
- else if (counts.classCount === 0 && counts.arrowFunctions > 10) {
255
- conventions.push({
256
- pattern: 'Uses functional architecture — no classes, prefer pure functions',
257
- evidence: `0 classes, ${counts.arrowFunctions} arrow functions`,
258
- confidence: 0.70,
259
- category: 'structure',
260
- });
261
- }
262
- return conventions;
263
- }
264
- // ─── Helpers ─────────────────────────────────────────────────────────────────
265
- function getSourceFiles(root) {
266
- const files = [];
267
- const ignore = new Set(['node_modules', '.git', 'dist', 'coverage', '.next', 'build']);
268
- const exts = new Set(['.ts', '.tsx', '.js', '.jsx']);
269
- function walk(dir, depth) {
270
- if (depth > 3 || files.length >= 30)
271
- return;
272
- try {
273
- const entries = fs.readdirSync(dir, { withFileTypes: true });
274
- for (const entry of entries) {
275
- if (ignore.has(entry.name) || entry.name.startsWith('.'))
276
- continue;
277
- const full = path.join(dir, entry.name);
278
- if (entry.isDirectory()) {
279
- walk(full, depth + 1);
280
- }
281
- else {
282
- const ext = path.extname(entry.name);
283
- if (exts.has(ext) && !entry.name.endsWith('.d.ts')) {
284
- files.push(path.relative(root, full).replace(/\\/g, '/'));
285
- }
286
- }
287
- }
288
- }
289
- catch { /* ignore */ }
290
- }
291
- walk(root, 0);
292
- return files;
293
- }
294
- //# sourceMappingURL=convention-detector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convention-detector.js","sourceRoot":"","sources":["../../src/memory/convention-detector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,8CAuNC;AAlPD;;;;;;;;;;;;;GAaG;AACH,uCAAyB;AACzB,2CAA6B;AAS7B;;GAEG;AACH,SAAgB,iBAAiB,CAAC,aAAqB;IACnD,MAAM,WAAW,GAAyB,EAAE,CAAC;IAC7C,MAAM,KAAK,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAE3C,iCAAiC;IACjC,MAAM,MAAM,GAAG;QACX,cAAc,EAAE,CAAC;QACjB,oBAAo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I,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;wBACjD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;oBAC9D,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACd,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Correction Detector — Catches user corrections automatically.
3
- *
4
- * The #1 gap in Cortex: when a user says "no, use X instead of Y",
5
- * that correction is LOST when the conversation ends.
6
- *
7
- * This module scans text (both AI responses and user context) for
8
- * correction patterns and auto-stores them as high-importance CORRECTION memories.
9
- *
10
- * Examples it catches:
11
- * - "no, use vectors not vectorCache"
12
- * - "that's wrong, it should be const"
13
- * - "actually the file is in src/db/"
14
- * - "I meant to use path.join"
15
- */
16
- export interface DetectedCorrection {
17
- original: string;
18
- corrected: string;
19
- fullContext: string;
20
- confidence: number;
21
- source: 'user_correction' | 'ai_acknowledgment';
22
- }
23
- /**
24
- * Detect corrections from user context text.
25
- * Call this when auto_learn receives context about what the user said.
26
- */
27
- export declare function detectUserCorrections(userText: string): DetectedCorrection[];
28
- /**
29
- * Detect when the AI acknowledges a mistake in its own response.
30
- * Call this from auto_learn on the AI's response text.
31
- */
32
- export declare function detectAIAcknowledgments(aiText: string): DetectedCorrection[];
33
- //# sourceMappingURL=correction-detector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"correction-detector.d.ts","sourceRoot":"","sources":["../../src/memory/correction-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,GAAG,mBAAmB,CAAC;CACnD;AA4DD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAyB5E;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAuB5E"}
@@ -1,129 +0,0 @@
1
- "use strict";
2
- /**
3
- * Correction Detector — Catches user corrections automatically.
4
- *
5
- * The #1 gap in Cortex: when a user says "no, use X instead of Y",
6
- * that correction is LOST when the conversation ends.
7
- *
8
- * This module scans text (both AI responses and user context) for
9
- * correction patterns and auto-stores them as high-importance CORRECTION memories.
10
- *
11
- * Examples it catches:
12
- * - "no, use vectors not vectorCache"
13
- * - "that's wrong, it should be const"
14
- * - "actually the file is in src/db/"
15
- * - "I meant to use path.join"
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.detectUserCorrections = detectUserCorrections;
19
- exports.detectAIAcknowledgments = detectAIAcknowledgments;
20
- // ─── Correction Patterns ─────────────────────────────────────────────────────
21
- const USER_CORRECTION_PATTERNS = [
22
- // "no, use X not Y" / "no use X instead of Y"
23
- {
24
- regex: /\bno[,.]?\s+(use|it'?s|it should be|should be|change to|switch to)\s+(.{3,50}?)(?:\s+(?:not|instead of|rather than)\s+(.{3,50}))?[.!]?\s*$/gim,
25
- extractGroups: (m) => ({ corrected: m[2]?.trim(), original: m[3]?.trim() }),
26
- confidence: 0.90,
27
- },
28
- // "that's wrong" / "that's incorrect" / "that's not right"
29
- {
30
- regex: /\b(that'?s|this is)\s+(wrong|incorrect|not right|not correct|a mistake)\b.{0,80}/gi,
31
- extractGroups: () => ({}),
32
- confidence: 0.85,
33
- },
34
- // "actually, X" / "actually it should be X"
35
- {
36
- regex: /\bactually[,.]?\s+(it\s+)?(should be|is|use|the\s+\w+\s+is)\s+(.{5,80})/gi,
37
- extractGroups: (m) => ({ corrected: m[3]?.trim() }),
38
- confidence: 0.80,
39
- },
40
- // "I meant X" / "I mean X"
41
- {
42
- regex: /\bI\s+mean[t]?\s+(.{5,80})/gi,
43
- extractGroups: (m) => ({ corrected: m[1]?.trim() }),
44
- confidence: 0.75,
45
- },
46
- // "not X, but Y" / "not X, Y"
47
- {
48
- regex: /\bnot\s+(.{3,40}?)[,]\s*(but\s+)?(.{3,40})/gi,
49
- extractGroups: (m) => ({ original: m[1]?.trim(), corrected: m[3]?.trim() }),
50
- confidence: 0.70,
51
- },
52
- // "X is wrong" / "X is incorrect"
53
- {
54
- regex: /\b(.{5,40})\s+is\s+(wrong|incorrect|broken|outdated|deprecated)/gi,
55
- extractGroups: (m) => ({ original: m[1]?.trim() }),
56
- confidence: 0.75,
57
- },
58
- ];
59
- // AI acknowledgment patterns — when the AI itself admits a mistake
60
- const AI_ACKNOWLEDGMENT_PATTERNS = [
61
- { regex: /\b(I apologize|sorry|my mistake|my bad|you'?re right|good catch)\b/gi, confidence: 0.85 },
62
- { regex: /\b(let me fix that|let me correct|I was wrong|I made an error)\b/gi, confidence: 0.90 },
63
- { regex: /\b(should have (used|been|done)|instead of .{3,30} I should)\b/gi, confidence: 0.85 },
64
- { regex: /\b(the (correct|right|actual|proper) (way|approach|method|answer) is)\b/gi, confidence: 0.80 },
65
- ];
66
- // ─── Main Detector ───────────────────────────────────────────────────────────
67
- /**
68
- * Detect corrections from user context text.
69
- * Call this when auto_learn receives context about what the user said.
70
- */
71
- function detectUserCorrections(userText) {
72
- if (!userText || userText.length < 10)
73
- return [];
74
- const results = [];
75
- const sentences = splitIntoSentences(userText);
76
- for (const sentence of sentences) {
77
- for (const pattern of USER_CORRECTION_PATTERNS) {
78
- pattern.regex.lastIndex = 0;
79
- const match = pattern.regex.exec(sentence);
80
- if (match) {
81
- const groups = pattern.extractGroups(match);
82
- results.push({
83
- original: groups.original || '',
84
- corrected: groups.corrected || '',
85
- fullContext: sentence.trim().slice(0, 200),
86
- confidence: pattern.confidence,
87
- source: 'user_correction',
88
- });
89
- break; // One match per sentence
90
- }
91
- }
92
- }
93
- return results;
94
- }
95
- /**
96
- * Detect when the AI acknowledges a mistake in its own response.
97
- * Call this from auto_learn on the AI's response text.
98
- */
99
- function detectAIAcknowledgments(aiText) {
100
- if (!aiText || aiText.length < 15)
101
- return [];
102
- const results = [];
103
- const sentences = splitIntoSentences(aiText);
104
- for (const sentence of sentences) {
105
- for (const pattern of AI_ACKNOWLEDGMENT_PATTERNS) {
106
- pattern.regex.lastIndex = 0;
107
- if (pattern.regex.test(sentence)) {
108
- results.push({
109
- original: '',
110
- corrected: '',
111
- fullContext: sentence.trim().slice(0, 200),
112
- confidence: pattern.confidence,
113
- source: 'ai_acknowledgment',
114
- });
115
- break;
116
- }
117
- }
118
- }
119
- return results;
120
- }
121
- // ─── Helper ──────────────────────────────────────────────────────────────────
122
- function splitIntoSentences(text) {
123
- return text
124
- .replace(/\n+/g, '. ')
125
- .split(/(?<=[.!?])\s+/)
126
- .map(s => s.trim())
127
- .filter(s => s.length > 8 && s.length < 300);
128
- }
129
- //# sourceMappingURL=correction-detector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"correction-detector.js","sourceRoot":"","sources":["../../src/memory/correction-detector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAwEH,sDAyBC;AAMD,0DAuBC;AApHD,gFAAgF;AAEhF,MAAM,wBAAwB,GAIzB;IACD,8CAA8C;IAC9C;QACI,KAAK,EAAE,+IAA+I;QACtJ,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;QAC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IAE7C,MAAM,OAAO,GAAyB,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAE7C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC/B,KAAK,MAAM,OAAO,IAAI,0BAA0B,EAAE,CAAC;YAC/C,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;YAC5B,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC/B,OAAO,CAAC,IAAI,CAAC;oBACT,QAAQ,EAAE,EAAE;oBACZ,SAAS,EAAE,EAAE;oBACb,WAAW,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;oBAC1C,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,mBAAmB;iBAC9B,CAAC,CAAC;gBACH,MAAM;YACV,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,gFAAgF;AAEhF,SAAS,kBAAkB,CAAC,IAAY;IACpC,OAAO,IAAI;SACN,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;SACrB,KAAK,CAAC,eAAe,CAAC;SACtB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAClB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AACrD,CAAC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * Error Learner — Auto-captures build/test error patterns.
3
- *
4
- * When build output or test output contains errors, this module:
5
- * 1. Extracts the error pattern (TS error codes, common messages)
6
- * 2. Maps to a human-readable lesson ("TS2345: argument type mismatch")
7
- * 3. Stores as BUG_FIX memory so the AI avoids repeating the same mistake
8
- *
9
- * This is the #1 gap: the AI keeps making the same TS compile errors
10
- * because it forgets what went wrong last time.
11
- */
12
- export interface ErrorPattern {
13
- errorType: string;
14
- message: string;
15
- file?: string;
16
- confidence: number;
17
- }
18
- /**
19
- * Extract error patterns from build/test output text.
20
- */
21
- export declare function extractErrorPatterns(text: string): ErrorPattern[];
22
- /**
23
- * Check if text contains build/test error indicators.
24
- */
25
- export declare function containsErrors(text: string): boolean;
26
- //# sourceMappingURL=error-learner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-learner.d.ts","sourceRoot":"","sources":["../../src/memory/error-learner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,YAAY;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACtB;AAyBD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CAwFjE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAcpD"}
@@ -1,145 +0,0 @@
1
- "use strict";
2
- /**
3
- * Error Learner — Auto-captures build/test error patterns.
4
- *
5
- * When build output or test output contains errors, this module:
6
- * 1. Extracts the error pattern (TS error codes, common messages)
7
- * 2. Maps to a human-readable lesson ("TS2345: argument type mismatch")
8
- * 3. Stores as BUG_FIX memory so the AI avoids repeating the same mistake
9
- *
10
- * This is the #1 gap: the AI keeps making the same TS compile errors
11
- * because it forgets what went wrong last time.
12
- */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.extractErrorPatterns = extractErrorPatterns;
15
- exports.containsErrors = containsErrors;
16
- // ─── TypeScript Error Patterns ────────────────────────────────────────────────
17
- const TS_ERROR_LESSONS = {
18
- 'TS2345': 'Argument type mismatch — check function parameter types match expected signatures',
19
- 'TS2322': 'Type assignment error — ensure the value matches the declared type',
20
- 'TS2339': 'Property does not exist — check spelling or add the property to the interface',
21
- 'TS2304': 'Cannot find name — missing import or undeclared variable',
22
- 'TS2305': 'Module has no exported member — check the export name matches exactly',
23
- 'TS2307': 'Cannot find module — check the import path is correct',
24
- 'TS2554': 'Wrong number of arguments — check function signature for required params',
25
- 'TS2769': 'No overload matches this call — check argument types against all overload signatures',
26
- 'TS7006': 'Parameter implicitly has any type — add explicit type annotation',
27
- 'TS2741': 'Missing property in type — add required properties to the object',
28
- 'TS18046': 'Variable is of type unknown — add type assertion or type guard',
29
- 'TS2352': 'Conversion of type may be a mistake — use "as unknown as T" for forced cast',
30
- 'TS1005': 'Expected token — syntax error, check for missing brackets/semicolons',
31
- 'TS2531': 'Object is possibly null — add null check or use optional chaining',
32
- 'TS2532': 'Object is possibly undefined — add undefined check or use optional chaining',
33
- 'TS2349': 'Not callable — value is not a function, check the type',
34
- 'TS2551': 'Property does not exist, did you mean? — typo in property name',
35
- 'TS6133': 'Declared but never used — remove unused variable or prefix with _',
36
- };
37
- /**
38
- * Extract error patterns from build/test output text.
39
- */
40
- function extractErrorPatterns(text) {
41
- const errors = [];
42
- const seen = new Set();
43
- // 1. TypeScript errors: TS2345, TS2322, etc.
44
- const tsErrorRegex = /(?:error\s+)?(TS\d{4,5})\s*:\s*(.+?)(?:\r?\n|$)/gi;
45
- let match;
46
- while ((match = tsErrorRegex.exec(text)) !== null) {
47
- const code = match[1].toUpperCase();
48
- const msg = match[2].trim().slice(0, 150);
49
- if (seen.has(code))
50
- continue;
51
- seen.add(code);
52
- const lesson = TS_ERROR_LESSONS[code] || `${code}: ${msg}`;
53
- errors.push({
54
- errorType: code,
55
- message: lesson,
56
- confidence: 0.90,
57
- });
58
- }
59
- // 2. TypeScript "not assignable" pattern (without error code)
60
- if (!seen.has('TYPE_MISMATCH')) {
61
- const assignRegex = /Type '([^']+)' is not assignable to type '([^']+)'/gi;
62
- while ((match = assignRegex.exec(text)) !== null) {
63
- if (seen.has('TYPE_MISMATCH'))
64
- break;
65
- seen.add('TYPE_MISMATCH');
66
- errors.push({
67
- errorType: 'TYPE_MISMATCH',
68
- message: `Type mismatch: '${match[1].slice(0, 40)}' cannot be assigned to '${match[2].slice(0, 40)}' — check type compatibility`,
69
- confidence: 0.85,
70
- });
71
- }
72
- }
73
- // 3. Module not found
74
- const moduleRegex = /(?:Cannot find module|Module not found)[:\s]+['"]([^'"]+)['"]/gi;
75
- while ((match = moduleRegex.exec(text)) !== null) {
76
- const mod = match[1];
77
- if (seen.has(`MOD:${mod}`))
78
- continue;
79
- seen.add(`MOD:${mod}`);
80
- errors.push({
81
- errorType: 'MODULE_NOT_FOUND',
82
- message: `Module '${mod}' not found — verify it's installed in package.json and the import path is correct`,
83
- confidence: 0.90,
84
- });
85
- }
86
- // 4. Property does not exist on type
87
- const propRegex = /Property '(\w+)' does not exist on type '([^']+)'/gi;
88
- while ((match = propRegex.exec(text)) !== null) {
89
- const key = `PROP:${match[1]}`;
90
- if (seen.has(key))
91
- continue;
92
- seen.add(key);
93
- errors.push({
94
- errorType: 'MISSING_PROPERTY',
95
- message: `Property '${match[1]}' not on type '${match[2].slice(0, 40)}' — check interface definition or use type assertion`,
96
- confidence: 0.85,
97
- });
98
- }
99
- // 5. Test failures
100
- const testFailRegex = /(?:FAIL|FAILED|Error)[\s:]+(.+?test.+?)(?:\r?\n|$)/gi;
101
- while ((match = testFailRegex.exec(text)) !== null) {
102
- const key = `TEST:${match[1].slice(0, 30)}`;
103
- if (seen.has(key))
104
- continue;
105
- seen.add(key);
106
- errors.push({
107
- errorType: 'TEST_FAILURE',
108
- message: `Test failed: ${match[1].trim().slice(0, 100)}`,
109
- file: match[1].trim(),
110
- confidence: 0.75,
111
- });
112
- }
113
- // 6. Function signature mismatch
114
- const sigRegex = /Expected (\d+) arguments?, but got (\d+)/gi;
115
- while ((match = sigRegex.exec(text)) !== null) {
116
- if (seen.has('SIG_MISMATCH'))
117
- continue;
118
- seen.add('SIG_MISMATCH');
119
- errors.push({
120
- errorType: 'SIGNATURE_MISMATCH',
121
- message: `Wrong argument count: expected ${match[1]} but got ${match[2]} — check the function signature`,
122
- confidence: 0.90,
123
- });
124
- }
125
- return errors;
126
- }
127
- /**
128
- * Check if text contains build/test error indicators.
129
- */
130
- function containsErrors(text) {
131
- const errorIndicators = [
132
- /error TS\d{4}/i,
133
- /\bFAIL\b.*test/i,
134
- /Build failed/i,
135
- /compilation error/i,
136
- /Cannot find module/i,
137
- /SyntaxError:/i,
138
- /TypeError:/i,
139
- /ReferenceError:/i,
140
- /npm ERR!/,
141
- /Exit code: [1-9]/,
142
- ];
143
- return errorIndicators.some(r => r.test(text));
144
- }
145
- //# sourceMappingURL=error-learner.js.map