@timmeck/brain 1.0.0 → 1.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.
Files changed (198) hide show
  1. package/BRAIN_PLAN.md +3324 -3324
  2. package/LICENSE +21 -21
  3. package/README.md +194 -188
  4. package/dist/brain.js +2 -0
  5. package/dist/brain.js.map +1 -1
  6. package/dist/cli/colors.d.ts +50 -0
  7. package/dist/cli/colors.js +106 -0
  8. package/dist/cli/colors.js.map +1 -0
  9. package/dist/cli/commands/config.d.ts +2 -0
  10. package/dist/cli/commands/config.js +165 -0
  11. package/dist/cli/commands/config.js.map +1 -0
  12. package/dist/cli/commands/dashboard.js +222 -8
  13. package/dist/cli/commands/dashboard.js.map +1 -1
  14. package/dist/cli/commands/export.js +3 -0
  15. package/dist/cli/commands/export.js.map +1 -1
  16. package/dist/cli/commands/import.js +24 -15
  17. package/dist/cli/commands/import.js.map +1 -1
  18. package/dist/cli/commands/insights.js +33 -6
  19. package/dist/cli/commands/insights.js.map +1 -1
  20. package/dist/cli/commands/learn.d.ts +2 -0
  21. package/dist/cli/commands/learn.js +22 -0
  22. package/dist/cli/commands/learn.js.map +1 -0
  23. package/dist/cli/commands/modules.js +25 -6
  24. package/dist/cli/commands/modules.js.map +1 -1
  25. package/dist/cli/commands/network.js +15 -9
  26. package/dist/cli/commands/network.js.map +1 -1
  27. package/dist/cli/commands/query.js +92 -25
  28. package/dist/cli/commands/query.js.map +1 -1
  29. package/dist/cli/commands/start.js +5 -4
  30. package/dist/cli/commands/start.js.map +1 -1
  31. package/dist/cli/commands/status.js +19 -16
  32. package/dist/cli/commands/status.js.map +1 -1
  33. package/dist/cli/commands/stop.js +5 -4
  34. package/dist/cli/commands/stop.js.map +1 -1
  35. package/dist/cli/ipc-helper.js +4 -3
  36. package/dist/cli/ipc-helper.js.map +1 -1
  37. package/dist/db/migrations/001_core_schema.js +115 -115
  38. package/dist/db/migrations/002_learning_schema.js +33 -33
  39. package/dist/db/migrations/003_code_schema.js +48 -48
  40. package/dist/db/migrations/004_synapses_schema.js +52 -52
  41. package/dist/db/migrations/005_fts_indexes.js +73 -73
  42. package/dist/db/migrations/index.js +6 -6
  43. package/dist/db/repositories/antipattern.repository.js +3 -3
  44. package/dist/db/repositories/code-module.repository.d.ts +1 -0
  45. package/dist/db/repositories/code-module.repository.js +8 -0
  46. package/dist/db/repositories/code-module.repository.js.map +1 -1
  47. package/dist/db/repositories/error.repository.js +46 -46
  48. package/dist/db/repositories/insight.repository.js +3 -3
  49. package/dist/db/repositories/notification.repository.js +3 -3
  50. package/dist/db/repositories/project.repository.js +21 -21
  51. package/dist/db/repositories/rule.repository.js +24 -24
  52. package/dist/db/repositories/solution.repository.js +50 -50
  53. package/dist/db/repositories/synapse.repository.js +18 -18
  54. package/dist/db/repositories/terminal.repository.js +24 -24
  55. package/dist/index.js +4 -0
  56. package/dist/index.js.map +1 -1
  57. package/dist/ipc/router.d.ts +2 -0
  58. package/dist/ipc/router.js +7 -1
  59. package/dist/ipc/router.js.map +1 -1
  60. package/dist/services/code.service.d.ts +1 -1
  61. package/dist/services/code.service.js +5 -2
  62. package/dist/services/code.service.js.map +1 -1
  63. package/package.json +5 -4
  64. package/src/brain.ts +3 -0
  65. package/src/cli/colors.ts +116 -0
  66. package/src/cli/commands/config.ts +169 -0
  67. package/src/cli/commands/dashboard.ts +231 -8
  68. package/src/cli/commands/export.ts +4 -0
  69. package/src/cli/commands/import.ts +24 -15
  70. package/src/cli/commands/insights.ts +37 -5
  71. package/src/cli/commands/learn.ts +24 -0
  72. package/src/cli/commands/modules.ts +28 -5
  73. package/src/cli/commands/network.ts +15 -9
  74. package/src/cli/commands/query.ts +103 -26
  75. package/src/cli/commands/start.ts +5 -4
  76. package/src/cli/commands/status.ts +19 -16
  77. package/src/cli/commands/stop.ts +5 -4
  78. package/src/cli/ipc-helper.ts +4 -3
  79. package/src/code/analyzer.ts +77 -77
  80. package/src/code/fingerprint.ts +87 -87
  81. package/src/code/matcher.ts +64 -64
  82. package/src/code/parsers/generic.ts +29 -29
  83. package/src/code/parsers/python.ts +54 -54
  84. package/src/code/parsers/typescript.ts +65 -65
  85. package/src/code/registry.ts +60 -60
  86. package/src/code/scorer.ts +108 -108
  87. package/src/config.ts +111 -111
  88. package/src/db/connection.ts +22 -22
  89. package/src/db/migrations/001_core_schema.ts +120 -120
  90. package/src/db/migrations/002_learning_schema.ts +38 -38
  91. package/src/db/migrations/003_code_schema.ts +53 -53
  92. package/src/db/migrations/004_synapses_schema.ts +57 -57
  93. package/src/db/migrations/005_fts_indexes.ts +78 -78
  94. package/src/db/migrations/006_synapses_phase3.ts +17 -17
  95. package/src/db/migrations/index.ts +64 -64
  96. package/src/db/repositories/antipattern.repository.ts +66 -66
  97. package/src/db/repositories/code-module.repository.ts +9 -0
  98. package/src/db/repositories/error.repository.ts +149 -149
  99. package/src/db/repositories/insight.repository.ts +78 -78
  100. package/src/db/repositories/notification.repository.ts +66 -66
  101. package/src/db/repositories/project.repository.ts +93 -93
  102. package/src/db/repositories/rule.repository.ts +108 -108
  103. package/src/db/repositories/solution.repository.ts +154 -154
  104. package/src/db/repositories/synapse.repository.ts +153 -153
  105. package/src/db/repositories/terminal.repository.ts +101 -101
  106. package/src/hooks/post-tool-use.ts +90 -90
  107. package/src/hooks/post-write.ts +117 -117
  108. package/src/index.ts +4 -0
  109. package/src/ipc/client.ts +118 -118
  110. package/src/ipc/protocol.ts +35 -35
  111. package/src/ipc/router.ts +9 -1
  112. package/src/ipc/server.ts +110 -110
  113. package/src/learning/confidence-scorer.ts +47 -47
  114. package/src/learning/decay.ts +46 -46
  115. package/src/learning/learning-engine.ts +162 -162
  116. package/src/learning/pattern-extractor.ts +90 -90
  117. package/src/learning/rule-generator.ts +74 -74
  118. package/src/matching/error-matcher.ts +115 -115
  119. package/src/matching/fingerprint.ts +29 -29
  120. package/src/matching/similarity.ts +61 -61
  121. package/src/matching/tfidf.ts +74 -74
  122. package/src/matching/tokenizer.ts +41 -41
  123. package/src/mcp/auto-detect.ts +93 -93
  124. package/src/mcp/server.ts +73 -73
  125. package/src/mcp/tools.ts +290 -290
  126. package/src/parsing/error-parser.ts +28 -28
  127. package/src/parsing/parsers/compiler.ts +93 -93
  128. package/src/parsing/parsers/generic.ts +28 -28
  129. package/src/parsing/parsers/go.ts +97 -97
  130. package/src/parsing/parsers/node.ts +69 -69
  131. package/src/parsing/parsers/python.ts +62 -62
  132. package/src/parsing/parsers/rust.ts +50 -50
  133. package/src/parsing/parsers/shell.ts +42 -42
  134. package/src/parsing/types.ts +47 -47
  135. package/src/research/gap-analyzer.ts +135 -135
  136. package/src/research/insight-generator.ts +123 -123
  137. package/src/research/research-engine.ts +116 -116
  138. package/src/research/synergy-detector.ts +126 -126
  139. package/src/research/template-extractor.ts +130 -130
  140. package/src/research/trend-analyzer.ts +127 -127
  141. package/src/services/analytics.service.ts +87 -87
  142. package/src/services/code.service.ts +5 -2
  143. package/src/services/error.service.ts +164 -164
  144. package/src/services/notification.service.ts +41 -41
  145. package/src/services/prevention.service.ts +119 -119
  146. package/src/services/research.service.ts +93 -93
  147. package/src/services/solution.service.ts +116 -116
  148. package/src/services/synapse.service.ts +59 -59
  149. package/src/services/terminal.service.ts +81 -81
  150. package/src/synapses/activation.ts +80 -80
  151. package/src/synapses/decay.ts +38 -38
  152. package/src/synapses/hebbian.ts +69 -69
  153. package/src/synapses/pathfinder.ts +81 -81
  154. package/src/synapses/synapse-manager.ts +109 -109
  155. package/src/types/code.types.ts +52 -52
  156. package/src/types/config.types.ts +79 -79
  157. package/src/types/error.types.ts +67 -67
  158. package/src/types/ipc.types.ts +8 -8
  159. package/src/types/mcp.types.ts +53 -53
  160. package/src/types/research.types.ts +28 -28
  161. package/src/types/solution.types.ts +30 -30
  162. package/src/types/synapse.types.ts +49 -49
  163. package/src/utils/events.ts +45 -45
  164. package/src/utils/hash.ts +5 -5
  165. package/src/utils/logger.ts +48 -48
  166. package/src/utils/paths.ts +19 -19
  167. package/tests/fixtures/code-modules/modules.ts +83 -83
  168. package/tests/fixtures/errors/go.ts +9 -9
  169. package/tests/fixtures/errors/node.ts +24 -24
  170. package/tests/fixtures/errors/python.ts +21 -21
  171. package/tests/fixtures/errors/rust.ts +25 -25
  172. package/tests/fixtures/errors/shell.ts +15 -15
  173. package/tests/fixtures/solutions/solutions.ts +27 -27
  174. package/tests/helpers/setup-db.ts +52 -52
  175. package/tests/integration/code-flow.test.ts +86 -86
  176. package/tests/integration/error-flow.test.ts +83 -83
  177. package/tests/integration/ipc-flow.test.ts +166 -166
  178. package/tests/integration/learning-cycle.test.ts +82 -82
  179. package/tests/integration/synapse-flow.test.ts +117 -117
  180. package/tests/unit/code/analyzer.test.ts +58 -58
  181. package/tests/unit/code/fingerprint.test.ts +51 -51
  182. package/tests/unit/code/scorer.test.ts +55 -55
  183. package/tests/unit/learning/confidence-scorer.test.ts +60 -60
  184. package/tests/unit/learning/decay.test.ts +45 -45
  185. package/tests/unit/learning/pattern-extractor.test.ts +50 -50
  186. package/tests/unit/matching/error-matcher.test.ts +69 -69
  187. package/tests/unit/matching/fingerprint.test.ts +47 -47
  188. package/tests/unit/matching/similarity.test.ts +65 -65
  189. package/tests/unit/matching/tfidf.test.ts +71 -71
  190. package/tests/unit/matching/tokenizer.test.ts +83 -83
  191. package/tests/unit/parsing/parsers.test.ts +113 -113
  192. package/tests/unit/research/gap-analyzer.test.ts +45 -45
  193. package/tests/unit/research/trend-analyzer.test.ts +45 -45
  194. package/tests/unit/synapses/activation.test.ts +80 -80
  195. package/tests/unit/synapses/decay.test.ts +27 -27
  196. package/tests/unit/synapses/hebbian.test.ts +96 -96
  197. package/tests/unit/synapses/pathfinder.test.ts +72 -72
  198. package/tsconfig.json +18 -18
@@ -1,77 +1,77 @@
1
1
  export function up(db) {
2
- db.exec(`
3
- -- Full-text search for errors
4
- CREATE VIRTUAL TABLE IF NOT EXISTS errors_fts USING fts5(
5
- type, message, raw_output, context, file_path,
6
- content='errors',
7
- content_rowid='id'
8
- );
9
-
10
- -- Sync triggers for errors_fts
11
- CREATE TRIGGER IF NOT EXISTS errors_ai AFTER INSERT ON errors BEGIN
12
- INSERT INTO errors_fts(rowid, type, message, raw_output, context, file_path)
13
- VALUES (new.id, new.type, new.message, new.raw_output, new.context, new.file_path);
14
- END;
15
-
16
- CREATE TRIGGER IF NOT EXISTS errors_ad AFTER DELETE ON errors BEGIN
17
- INSERT INTO errors_fts(errors_fts, rowid, type, message, raw_output, context, file_path)
18
- VALUES ('delete', old.id, old.type, old.message, old.raw_output, old.context, old.file_path);
19
- END;
20
-
21
- CREATE TRIGGER IF NOT EXISTS errors_au AFTER UPDATE ON errors BEGIN
22
- INSERT INTO errors_fts(errors_fts, rowid, type, message, raw_output, context, file_path)
23
- VALUES ('delete', old.id, old.type, old.message, old.raw_output, old.context, old.file_path);
24
- INSERT INTO errors_fts(rowid, type, message, raw_output, context, file_path)
25
- VALUES (new.id, new.type, new.message, new.raw_output, new.context, new.file_path);
26
- END;
27
-
28
- -- Full-text search for solutions
29
- CREATE VIRTUAL TABLE IF NOT EXISTS solutions_fts USING fts5(
30
- description, commands, code_change,
31
- content='solutions',
32
- content_rowid='id'
33
- );
34
-
35
- CREATE TRIGGER IF NOT EXISTS solutions_ai AFTER INSERT ON solutions BEGIN
36
- INSERT INTO solutions_fts(rowid, description, commands, code_change)
37
- VALUES (new.id, new.description, new.commands, new.code_change);
38
- END;
39
-
40
- CREATE TRIGGER IF NOT EXISTS solutions_ad AFTER DELETE ON solutions BEGIN
41
- INSERT INTO solutions_fts(solutions_fts, rowid, description, commands, code_change)
42
- VALUES ('delete', old.id, old.description, old.commands, old.code_change);
43
- END;
44
-
45
- CREATE TRIGGER IF NOT EXISTS solutions_au AFTER UPDATE ON solutions BEGIN
46
- INSERT INTO solutions_fts(solutions_fts, rowid, description, commands, code_change)
47
- VALUES ('delete', old.id, old.description, old.commands, old.code_change);
48
- INSERT INTO solutions_fts(rowid, description, commands, code_change)
49
- VALUES (new.id, new.description, new.commands, new.code_change);
50
- END;
51
-
52
- -- Full-text search for code modules
53
- CREATE VIRTUAL TABLE IF NOT EXISTS code_modules_fts USING fts5(
54
- name, file_path, description, language,
55
- content='code_modules',
56
- content_rowid='id'
57
- );
58
-
59
- CREATE TRIGGER IF NOT EXISTS code_modules_ai AFTER INSERT ON code_modules BEGIN
60
- INSERT INTO code_modules_fts(rowid, name, file_path, description, language)
61
- VALUES (new.id, new.name, new.file_path, new.description, new.language);
62
- END;
63
-
64
- CREATE TRIGGER IF NOT EXISTS code_modules_ad AFTER DELETE ON code_modules BEGIN
65
- INSERT INTO code_modules_fts(code_modules_fts, rowid, name, file_path, description, language)
66
- VALUES ('delete', old.id, old.name, old.file_path, old.description, old.language);
67
- END;
68
-
69
- CREATE TRIGGER IF NOT EXISTS code_modules_au AFTER UPDATE ON code_modules BEGIN
70
- INSERT INTO code_modules_fts(code_modules_fts, rowid, name, file_path, description, language)
71
- VALUES ('delete', old.id, old.name, old.file_path, old.description, old.language);
72
- INSERT INTO code_modules_fts(rowid, name, file_path, description, language)
73
- VALUES (new.id, new.name, new.file_path, new.description, new.language);
74
- END;
2
+ db.exec(`
3
+ -- Full-text search for errors
4
+ CREATE VIRTUAL TABLE IF NOT EXISTS errors_fts USING fts5(
5
+ type, message, raw_output, context, file_path,
6
+ content='errors',
7
+ content_rowid='id'
8
+ );
9
+
10
+ -- Sync triggers for errors_fts
11
+ CREATE TRIGGER IF NOT EXISTS errors_ai AFTER INSERT ON errors BEGIN
12
+ INSERT INTO errors_fts(rowid, type, message, raw_output, context, file_path)
13
+ VALUES (new.id, new.type, new.message, new.raw_output, new.context, new.file_path);
14
+ END;
15
+
16
+ CREATE TRIGGER IF NOT EXISTS errors_ad AFTER DELETE ON errors BEGIN
17
+ INSERT INTO errors_fts(errors_fts, rowid, type, message, raw_output, context, file_path)
18
+ VALUES ('delete', old.id, old.type, old.message, old.raw_output, old.context, old.file_path);
19
+ END;
20
+
21
+ CREATE TRIGGER IF NOT EXISTS errors_au AFTER UPDATE ON errors BEGIN
22
+ INSERT INTO errors_fts(errors_fts, rowid, type, message, raw_output, context, file_path)
23
+ VALUES ('delete', old.id, old.type, old.message, old.raw_output, old.context, old.file_path);
24
+ INSERT INTO errors_fts(rowid, type, message, raw_output, context, file_path)
25
+ VALUES (new.id, new.type, new.message, new.raw_output, new.context, new.file_path);
26
+ END;
27
+
28
+ -- Full-text search for solutions
29
+ CREATE VIRTUAL TABLE IF NOT EXISTS solutions_fts USING fts5(
30
+ description, commands, code_change,
31
+ content='solutions',
32
+ content_rowid='id'
33
+ );
34
+
35
+ CREATE TRIGGER IF NOT EXISTS solutions_ai AFTER INSERT ON solutions BEGIN
36
+ INSERT INTO solutions_fts(rowid, description, commands, code_change)
37
+ VALUES (new.id, new.description, new.commands, new.code_change);
38
+ END;
39
+
40
+ CREATE TRIGGER IF NOT EXISTS solutions_ad AFTER DELETE ON solutions BEGIN
41
+ INSERT INTO solutions_fts(solutions_fts, rowid, description, commands, code_change)
42
+ VALUES ('delete', old.id, old.description, old.commands, old.code_change);
43
+ END;
44
+
45
+ CREATE TRIGGER IF NOT EXISTS solutions_au AFTER UPDATE ON solutions BEGIN
46
+ INSERT INTO solutions_fts(solutions_fts, rowid, description, commands, code_change)
47
+ VALUES ('delete', old.id, old.description, old.commands, old.code_change);
48
+ INSERT INTO solutions_fts(rowid, description, commands, code_change)
49
+ VALUES (new.id, new.description, new.commands, new.code_change);
50
+ END;
51
+
52
+ -- Full-text search for code modules
53
+ CREATE VIRTUAL TABLE IF NOT EXISTS code_modules_fts USING fts5(
54
+ name, file_path, description, language,
55
+ content='code_modules',
56
+ content_rowid='id'
57
+ );
58
+
59
+ CREATE TRIGGER IF NOT EXISTS code_modules_ai AFTER INSERT ON code_modules BEGIN
60
+ INSERT INTO code_modules_fts(rowid, name, file_path, description, language)
61
+ VALUES (new.id, new.name, new.file_path, new.description, new.language);
62
+ END;
63
+
64
+ CREATE TRIGGER IF NOT EXISTS code_modules_ad AFTER DELETE ON code_modules BEGIN
65
+ INSERT INTO code_modules_fts(code_modules_fts, rowid, name, file_path, description, language)
66
+ VALUES ('delete', old.id, old.name, old.file_path, old.description, old.language);
67
+ END;
68
+
69
+ CREATE TRIGGER IF NOT EXISTS code_modules_au AFTER UPDATE ON code_modules BEGIN
70
+ INSERT INTO code_modules_fts(code_modules_fts, rowid, name, file_path, description, language)
71
+ VALUES ('delete', old.id, old.name, old.file_path, old.description, old.language);
72
+ INSERT INTO code_modules_fts(rowid, name, file_path, description, language)
73
+ VALUES (new.id, new.name, new.file_path, new.description, new.language);
74
+ END;
75
75
  `);
76
76
  }
77
77
  //# sourceMappingURL=005_fts_indexes.js.map
@@ -14,12 +14,12 @@ const migrations = [
14
14
  { version: 6, name: '006_synapses_phase3', up: synapsesPhase3 },
15
15
  ];
16
16
  function ensureMigrationsTable(db) {
17
- db.exec(`
18
- CREATE TABLE IF NOT EXISTS migrations (
19
- version INTEGER PRIMARY KEY,
20
- name TEXT NOT NULL,
21
- applied_at TEXT NOT NULL DEFAULT (datetime('now'))
22
- );
17
+ db.exec(`
18
+ CREATE TABLE IF NOT EXISTS migrations (
19
+ version INTEGER PRIMARY KEY,
20
+ name TEXT NOT NULL,
21
+ applied_at TEXT NOT NULL DEFAULT (datetime('now'))
22
+ );
23
23
  `);
24
24
  }
25
25
  function getCurrentVersion(db) {
@@ -4,9 +4,9 @@ export class AntipatternRepository {
4
4
  constructor(db) {
5
5
  this.db = db;
6
6
  this.stmts = {
7
- create: db.prepare(`
8
- INSERT INTO antipatterns (pattern, description, severity, suggestion, occurrences, project_id, global)
9
- VALUES (@pattern, @description, @severity, @suggestion, @occurrences, @project_id, @global)
7
+ create: db.prepare(`
8
+ INSERT INTO antipatterns (pattern, description, severity, suggestion, occurrences, project_id, global)
9
+ VALUES (@pattern, @description, @severity, @suggestion, @occurrences, @project_id, @global)
10
10
  `),
11
11
  getById: db.prepare('SELECT * FROM antipatterns WHERE id = ?'),
12
12
  delete: db.prepare('DELETE FROM antipatterns WHERE id = ?'),
@@ -14,6 +14,7 @@ export declare class CodeModuleRepository {
14
14
  findByLanguage(language: string, limit?: number): CodeModuleRecord[];
15
15
  findByProject(projectId: number): CodeModuleRecord[];
16
16
  search(query: string): CodeModuleRecord[];
17
+ findAll(limit?: number): CodeModuleRecord[];
17
18
  countAll(): number;
18
19
  }
19
20
  export {};
@@ -12,6 +12,7 @@ export class CodeModuleRepository {
12
12
  delete: db.prepare('DELETE FROM code_modules WHERE id = ?'),
13
13
  findByFingerprint: db.prepare('SELECT * FROM code_modules WHERE fingerprint = ?'),
14
14
  findByProject: db.prepare('SELECT * FROM code_modules WHERE project_id = ? ORDER BY name ASC'),
15
+ findAll: db.prepare('SELECT * FROM code_modules ORDER BY name ASC'),
15
16
  countAll: db.prepare('SELECT COUNT(*) as count FROM code_modules'),
16
17
  search: db.prepare(`
17
18
  SELECT cm.* FROM code_modules cm
@@ -57,6 +58,13 @@ export class CodeModuleRepository {
57
58
  search(query) {
58
59
  return this.stmts.search.all(query);
59
60
  }
61
+ findAll(limit) {
62
+ if (limit) {
63
+ const stmt = this.db.prepare('SELECT * FROM code_modules ORDER BY name ASC LIMIT ?');
64
+ return stmt.all(limit);
65
+ }
66
+ return this.stmts.findAll.all();
67
+ }
60
68
  countAll() {
61
69
  return this.stmts.countAll.get().count;
62
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"code-module.repository.js","sourceRoot":"","sources":["../../../src/db/repositories/code-module.repository.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,oBAAoB;IAGX;IAFZ,KAAK,CAA4B;IAEzC,YAAoB,EAAqB;QAArB,OAAE,GAAF,EAAE,CAAmB;QACvC,IAAI,CAAC,KAAK,GAAG;YACX,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC;;;OAGlB,CAAC;YACF,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,yCAAyC,CAAC;YAC9D,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,uCAAuC,CAAC;YAC3D,iBAAiB,EAA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IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzC,OAAO,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,iBAAiB,CAAC,WAAmB;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,WAAW,CAAiC,CAAC;IACvF,CAAC;IAED,cAAc,CAAC,QAAgB,EAAE,KAAc;QAC7C,MAAM,GAAG,GAAG,KAAK;YACf,CAAC,CAAC,yEAAyE;YAC3E,CAAC,CAAC,iEAAiE,CAAC;QACtE,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAuB,CAAC;IACxF,CAAC;IAED,aAAa,CAAC,SAAiB;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAuB,CAAC;IACvE,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAuB,CAAC;IAC5D,CAAC;IAED,QAAQ;QACN,OAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAwB,CAAC,KAAK,CAAC;IAChE,CAAC;CACF"}
1
+ {"version":3,"file":"code-module.repository.js","sourceRoot":"","sources":["../../../src/db/repositories/code-module.repository.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,oBAAoB;IAGX;IAFZ,KAAK,CAA4B;IAEzC,YAAoB,EAAqB;QAArB,OAAE,GAAF,EAAE,CAAmB;QACvC,IAAI,CAAC,KAAK,GAAG;YACX,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC;;;O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CAAuB,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAwB,CAAC;IACxD,CAAC;IAED,QAAQ;QACN,OAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAwB,CAAC,KAAK,CAAC;IAChE,CAAC;CACF"}
@@ -4,63 +4,63 @@ export class ErrorRepository {
4
4
  constructor(db) {
5
5
  this.db = db;
6
6
  this.stmts = {
7
- create: this.db.prepare(`
8
- INSERT INTO errors (project_id, terminal_id, fingerprint, type, message, raw_output, context, file_path, line_number, column_number)
9
- VALUES (@project_id, @terminal_id, @fingerprint, @type, @message, @raw_output, @context, @file_path, @line_number, @column_number)
7
+ create: this.db.prepare(`
8
+ INSERT INTO errors (project_id, terminal_id, fingerprint, type, message, raw_output, context, file_path, line_number, column_number)
9
+ VALUES (@project_id, @terminal_id, @fingerprint, @type, @message, @raw_output, @context, @file_path, @line_number, @column_number)
10
10
  `),
11
- getById: this.db.prepare(`
12
- SELECT * FROM errors WHERE id = ?
11
+ getById: this.db.prepare(`
12
+ SELECT * FROM errors WHERE id = ?
13
13
  `),
14
- update: this.db.prepare(`
15
- UPDATE errors
16
- SET project_id = COALESCE(@project_id, project_id),
17
- terminal_id = COALESCE(@terminal_id, terminal_id),
18
- fingerprint = COALESCE(@fingerprint, fingerprint),
19
- type = COALESCE(@type, type),
20
- message = COALESCE(@message, message),
21
- raw_output = COALESCE(@raw_output, raw_output),
22
- context = COALESCE(@context, context),
23
- file_path = COALESCE(@file_path, file_path),
24
- line_number = COALESCE(@line_number, line_number),
25
- column_number = COALESCE(@column_number, column_number),
26
- occurrence_count = COALESCE(@occurrence_count, occurrence_count),
27
- last_seen = COALESCE(@last_seen, last_seen),
28
- resolved = COALESCE(@resolved, resolved),
29
- resolved_at = COALESCE(@resolved_at, resolved_at)
30
- WHERE id = @id
14
+ update: this.db.prepare(`
15
+ UPDATE errors
16
+ SET project_id = COALESCE(@project_id, project_id),
17
+ terminal_id = COALESCE(@terminal_id, terminal_id),
18
+ fingerprint = COALESCE(@fingerprint, fingerprint),
19
+ type = COALESCE(@type, type),
20
+ message = COALESCE(@message, message),
21
+ raw_output = COALESCE(@raw_output, raw_output),
22
+ context = COALESCE(@context, context),
23
+ file_path = COALESCE(@file_path, file_path),
24
+ line_number = COALESCE(@line_number, line_number),
25
+ column_number = COALESCE(@column_number, column_number),
26
+ occurrence_count = COALESCE(@occurrence_count, occurrence_count),
27
+ last_seen = COALESCE(@last_seen, last_seen),
28
+ resolved = COALESCE(@resolved, resolved),
29
+ resolved_at = COALESCE(@resolved_at, resolved_at)
30
+ WHERE id = @id
31
31
  `),
32
- delete: this.db.prepare(`
33
- DELETE FROM errors WHERE id = ?
32
+ delete: this.db.prepare(`
33
+ DELETE FROM errors WHERE id = ?
34
34
  `),
35
- findByFingerprint: this.db.prepare(`
36
- SELECT * FROM errors WHERE fingerprint = ? ORDER BY last_seen DESC
35
+ findByFingerprint: this.db.prepare(`
36
+ SELECT * FROM errors WHERE fingerprint = ? ORDER BY last_seen DESC
37
37
  `),
38
- findByProject: this.db.prepare(`
39
- SELECT * FROM errors WHERE project_id = ? ORDER BY last_seen DESC
38
+ findByProject: this.db.prepare(`
39
+ SELECT * FROM errors WHERE project_id = ? ORDER BY last_seen DESC
40
40
  `),
41
- findUnresolvedAll: this.db.prepare(`
42
- SELECT * FROM errors WHERE resolved = 0 ORDER BY last_seen DESC
41
+ findUnresolvedAll: this.db.prepare(`
42
+ SELECT * FROM errors WHERE resolved = 0 ORDER BY last_seen DESC
43
43
  `),
44
- findUnresolvedByProject: this.db.prepare(`
45
- SELECT * FROM errors WHERE resolved = 0 AND project_id = ? ORDER BY last_seen DESC
44
+ findUnresolvedByProject: this.db.prepare(`
45
+ SELECT * FROM errors WHERE resolved = 0 AND project_id = ? ORDER BY last_seen DESC
46
46
  `),
47
- countSinceAll: this.db.prepare(`
48
- SELECT COUNT(*) as count FROM errors WHERE first_seen >= ?
47
+ countSinceAll: this.db.prepare(`
48
+ SELECT COUNT(*) as count FROM errors WHERE first_seen >= ?
49
49
  `),
50
- countSinceByProject: this.db.prepare(`
51
- SELECT COUNT(*) as count FROM errors WHERE first_seen >= ? AND project_id = ?
50
+ countSinceByProject: this.db.prepare(`
51
+ SELECT COUNT(*) as count FROM errors WHERE first_seen >= ? AND project_id = ?
52
52
  `),
53
- search: this.db.prepare(`
54
- SELECT errors.* FROM errors
55
- JOIN errors_fts ON errors.id = errors_fts.rowid
56
- WHERE errors_fts MATCH ?
57
- ORDER BY rank
53
+ search: this.db.prepare(`
54
+ SELECT errors.* FROM errors
55
+ JOIN errors_fts ON errors.id = errors_fts.rowid
56
+ WHERE errors_fts MATCH ?
57
+ ORDER BY rank
58
58
  `),
59
- incrementOccurrence: this.db.prepare(`
60
- UPDATE errors
61
- SET occurrence_count = occurrence_count + 1,
62
- last_seen = datetime('now')
63
- WHERE id = ?
59
+ incrementOccurrence: this.db.prepare(`
60
+ UPDATE errors
61
+ SET occurrence_count = occurrence_count + 1,
62
+ last_seen = datetime('now')
63
+ WHERE id = ?
64
64
  `),
65
65
  };
66
66
  }
@@ -4,9 +4,9 @@ export class InsightRepository {
4
4
  constructor(db) {
5
5
  this.db = db;
6
6
  this.stmts = {
7
- create: db.prepare(`
8
- INSERT INTO insights (type, title, description, evidence, priority, project_id, active, expires_at)
9
- VALUES (@type, @title, @description, @evidence, @priority, @project_id, @active, @expires_at)
7
+ create: db.prepare(`
8
+ INSERT INTO insights (type, title, description, evidence, priority, project_id, active, expires_at)
9
+ VALUES (@type, @title, @description, @evidence, @priority, @project_id, @active, @expires_at)
10
10
  `),
11
11
  getById: db.prepare('SELECT * FROM insights WHERE id = ?'),
12
12
  delete: db.prepare('DELETE FROM insights WHERE id = ?'),
@@ -4,9 +4,9 @@ export class NotificationRepository {
4
4
  constructor(db) {
5
5
  this.db = db;
6
6
  this.stmts = {
7
- create: db.prepare(`
8
- INSERT INTO notifications (type, title, message, priority, project_id)
9
- VALUES (@type, @title, @message, @priority, @project_id)
7
+ create: db.prepare(`
8
+ INSERT INTO notifications (type, title, message, priority, project_id)
9
+ VALUES (@type, @title, @message, @priority, @project_id)
10
10
  `),
11
11
  getById: db.prepare('SELECT * FROM notifications WHERE id = ?'),
12
12
  delete: db.prepare('DELETE FROM notifications WHERE id = ?'),
@@ -4,33 +4,33 @@ export class ProjectRepository {
4
4
  constructor(db) {
5
5
  this.db = db;
6
6
  this.stmts = {
7
- create: this.db.prepare(`
8
- INSERT INTO projects (name, path, language, framework)
9
- VALUES (@name, @path, @language, @framework)
7
+ create: this.db.prepare(`
8
+ INSERT INTO projects (name, path, language, framework)
9
+ VALUES (@name, @path, @language, @framework)
10
10
  `),
11
- getById: this.db.prepare(`
12
- SELECT * FROM projects WHERE id = ?
11
+ getById: this.db.prepare(`
12
+ SELECT * FROM projects WHERE id = ?
13
13
  `),
14
- update: this.db.prepare(`
15
- UPDATE projects
16
- SET name = COALESCE(@name, name),
17
- path = COALESCE(@path, path),
18
- language = COALESCE(@language, language),
19
- framework = COALESCE(@framework, framework),
20
- updated_at = datetime('now')
21
- WHERE id = @id
14
+ update: this.db.prepare(`
15
+ UPDATE projects
16
+ SET name = COALESCE(@name, name),
17
+ path = COALESCE(@path, path),
18
+ language = COALESCE(@language, language),
19
+ framework = COALESCE(@framework, framework),
20
+ updated_at = datetime('now')
21
+ WHERE id = @id
22
22
  `),
23
- delete: this.db.prepare(`
24
- DELETE FROM projects WHERE id = ?
23
+ delete: this.db.prepare(`
24
+ DELETE FROM projects WHERE id = ?
25
25
  `),
26
- findByName: this.db.prepare(`
27
- SELECT * FROM projects WHERE name = ?
26
+ findByName: this.db.prepare(`
27
+ SELECT * FROM projects WHERE name = ?
28
28
  `),
29
- findByPath: this.db.prepare(`
30
- SELECT * FROM projects WHERE path = ?
29
+ findByPath: this.db.prepare(`
30
+ SELECT * FROM projects WHERE path = ?
31
31
  `),
32
- getAll: this.db.prepare(`
33
- SELECT * FROM projects ORDER BY name
32
+ getAll: this.db.prepare(`
33
+ SELECT * FROM projects ORDER BY name
34
34
  `),
35
35
  };
36
36
  }
@@ -4,36 +4,36 @@ export class RuleRepository {
4
4
  constructor(db) {
5
5
  this.db = db;
6
6
  this.stmts = {
7
- create: this.db.prepare(`
8
- INSERT INTO rules (pattern, action, description, confidence, occurrences, active, project_id)
9
- VALUES (@pattern, @action, @description, @confidence, @occurrences, @active, @project_id)
7
+ create: this.db.prepare(`
8
+ INSERT INTO rules (pattern, action, description, confidence, occurrences, active, project_id)
9
+ VALUES (@pattern, @action, @description, @confidence, @occurrences, @active, @project_id)
10
10
  `),
11
- getById: this.db.prepare(`
12
- SELECT * FROM rules WHERE id = ?
11
+ getById: this.db.prepare(`
12
+ SELECT * FROM rules WHERE id = ?
13
13
  `),
14
- update: this.db.prepare(`
15
- UPDATE rules
16
- SET pattern = COALESCE(@pattern, pattern),
17
- action = COALESCE(@action, action),
18
- description = COALESCE(@description, description),
19
- confidence = COALESCE(@confidence, confidence),
20
- occurrences = COALESCE(@occurrences, occurrences),
21
- active = COALESCE(@active, active),
22
- project_id = COALESCE(@project_id, project_id),
23
- updated_at = datetime('now')
24
- WHERE id = @id
14
+ update: this.db.prepare(`
15
+ UPDATE rules
16
+ SET pattern = COALESCE(@pattern, pattern),
17
+ action = COALESCE(@action, action),
18
+ description = COALESCE(@description, description),
19
+ confidence = COALESCE(@confidence, confidence),
20
+ occurrences = COALESCE(@occurrences, occurrences),
21
+ active = COALESCE(@active, active),
22
+ project_id = COALESCE(@project_id, project_id),
23
+ updated_at = datetime('now')
24
+ WHERE id = @id
25
25
  `),
26
- delete: this.db.prepare(`
27
- DELETE FROM rules WHERE id = ?
26
+ delete: this.db.prepare(`
27
+ DELETE FROM rules WHERE id = ?
28
28
  `),
29
- findActiveAll: this.db.prepare(`
30
- SELECT * FROM rules WHERE active = 1 ORDER BY confidence DESC
29
+ findActiveAll: this.db.prepare(`
30
+ SELECT * FROM rules WHERE active = 1 ORDER BY confidence DESC
31
31
  `),
32
- findActiveByProject: this.db.prepare(`
33
- SELECT * FROM rules WHERE active = 1 AND (project_id = ? OR project_id IS NULL) ORDER BY confidence DESC
32
+ findActiveByProject: this.db.prepare(`
33
+ SELECT * FROM rules WHERE active = 1 AND (project_id = ? OR project_id IS NULL) ORDER BY confidence DESC
34
34
  `),
35
- findByPattern: this.db.prepare(`
36
- SELECT * FROM rules WHERE pattern = ?
35
+ findByPattern: this.db.prepare(`
36
+ SELECT * FROM rules WHERE pattern = ?
37
37
  `),
38
38
  };
39
39
  }
@@ -4,67 +4,67 @@ export class SolutionRepository {
4
4
  constructor(db) {
5
5
  this.db = db;
6
6
  this.stmts = {
7
- create: this.db.prepare(`
8
- INSERT INTO solutions (description, commands, code_change, source, confidence)
9
- VALUES (@description, @commands, @code_change, @source, @confidence)
7
+ create: this.db.prepare(`
8
+ INSERT INTO solutions (description, commands, code_change, source, confidence)
9
+ VALUES (@description, @commands, @code_change, @source, @confidence)
10
10
  `),
11
- getById: this.db.prepare(`
12
- SELECT * FROM solutions WHERE id = ?
11
+ getById: this.db.prepare(`
12
+ SELECT * FROM solutions WHERE id = ?
13
13
  `),
14
- update: this.db.prepare(`
15
- UPDATE solutions
16
- SET description = COALESCE(@description, description),
17
- commands = COALESCE(@commands, commands),
18
- code_change = COALESCE(@code_change, code_change),
19
- source = COALESCE(@source, source),
20
- confidence = COALESCE(@confidence, confidence),
21
- success_count = COALESCE(@success_count, success_count),
22
- fail_count = COALESCE(@fail_count, fail_count),
23
- updated_at = datetime('now')
24
- WHERE id = @id
14
+ update: this.db.prepare(`
15
+ UPDATE solutions
16
+ SET description = COALESCE(@description, description),
17
+ commands = COALESCE(@commands, commands),
18
+ code_change = COALESCE(@code_change, code_change),
19
+ source = COALESCE(@source, source),
20
+ confidence = COALESCE(@confidence, confidence),
21
+ success_count = COALESCE(@success_count, success_count),
22
+ fail_count = COALESCE(@fail_count, fail_count),
23
+ updated_at = datetime('now')
24
+ WHERE id = @id
25
25
  `),
26
- delete: this.db.prepare(`
27
- DELETE FROM solutions WHERE id = ?
26
+ delete: this.db.prepare(`
27
+ DELETE FROM solutions WHERE id = ?
28
28
  `),
29
- findForError: this.db.prepare(`
30
- SELECT s.* FROM solutions s
31
- JOIN error_solutions es ON s.id = es.solution_id
32
- WHERE es.error_id = ?
33
- ORDER BY s.confidence DESC
29
+ findForError: this.db.prepare(`
30
+ SELECT s.* FROM solutions s
31
+ JOIN error_solutions es ON s.id = es.solution_id
32
+ WHERE es.error_id = ?
33
+ ORDER BY s.confidence DESC
34
34
  `),
35
- linkToError: this.db.prepare(`
36
- INSERT OR IGNORE INTO error_solutions (error_id, solution_id)
37
- VALUES (@error_id, @solution_id)
35
+ linkToError: this.db.prepare(`
36
+ INSERT OR IGNORE INTO error_solutions (error_id, solution_id)
37
+ VALUES (@error_id, @solution_id)
38
38
  `),
39
- recordAttempt: this.db.prepare(`
40
- INSERT INTO solution_attempts (error_solution_id, terminal_id, success, output, duration_ms)
41
- VALUES (@error_solution_id, @terminal_id, @success, @output, @duration_ms)
39
+ recordAttempt: this.db.prepare(`
40
+ INSERT INTO solution_attempts (error_solution_id, terminal_id, success, output, duration_ms)
41
+ VALUES (@error_solution_id, @terminal_id, @success, @output, @duration_ms)
42
42
  `),
43
- getAttempts: this.db.prepare(`
44
- SELECT * FROM solution_attempts WHERE error_solution_id = ? ORDER BY attempted_at DESC
43
+ getAttempts: this.db.prepare(`
44
+ SELECT * FROM solution_attempts WHERE error_solution_id = ? ORDER BY attempted_at DESC
45
45
  `),
46
- getAll: this.db.prepare(`
47
- SELECT * FROM solutions
46
+ getAll: this.db.prepare(`
47
+ SELECT * FROM solutions
48
48
  `),
49
- successRate: this.db.prepare(`
50
- SELECT
51
- COUNT(*) as total,
52
- SUM(CASE WHEN sa.success = 1 THEN 1 ELSE 0 END) as successes
53
- FROM solution_attempts sa
54
- JOIN error_solutions es ON sa.error_solution_id = es.id
55
- WHERE es.solution_id = ?
49
+ successRate: this.db.prepare(`
50
+ SELECT
51
+ COUNT(*) as total,
52
+ SUM(CASE WHEN sa.success = 1 THEN 1 ELSE 0 END) as successes
53
+ FROM solution_attempts sa
54
+ JOIN error_solutions es ON sa.error_solution_id = es.id
55
+ WHERE es.solution_id = ?
56
56
  `),
57
- updateSuccessCount: this.db.prepare(`
58
- UPDATE solutions
59
- SET success_count = success_count + 1,
60
- updated_at = datetime('now')
61
- WHERE id = ?
57
+ updateSuccessCount: this.db.prepare(`
58
+ UPDATE solutions
59
+ SET success_count = success_count + 1,
60
+ updated_at = datetime('now')
61
+ WHERE id = ?
62
62
  `),
63
- updateFailCount: this.db.prepare(`
64
- UPDATE solutions
65
- SET fail_count = fail_count + 1,
66
- updated_at = datetime('now')
67
- WHERE id = ?
63
+ updateFailCount: this.db.prepare(`
64
+ UPDATE solutions
65
+ SET fail_count = fail_count + 1,
66
+ updated_at = datetime('now')
67
+ WHERE id = ?
68
68
  `),
69
69
  };
70
70
  }