@timmeck/brain 1.0.0 → 1.1.1
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.
- package/BRAIN_PLAN.md +3324 -3324
- package/LICENSE +21 -21
- package/README.md +194 -188
- package/dist/brain.js +2 -0
- package/dist/brain.js.map +1 -1
- package/dist/cli/colors.d.ts +50 -0
- package/dist/cli/colors.js +106 -0
- package/dist/cli/colors.js.map +1 -0
- package/dist/cli/commands/config.d.ts +2 -0
- package/dist/cli/commands/config.js +165 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/dashboard.js +222 -8
- package/dist/cli/commands/dashboard.js.map +1 -1
- package/dist/cli/commands/export.js +3 -0
- package/dist/cli/commands/export.js.map +1 -1
- package/dist/cli/commands/import.js +24 -15
- package/dist/cli/commands/import.js.map +1 -1
- package/dist/cli/commands/insights.js +33 -6
- package/dist/cli/commands/insights.js.map +1 -1
- package/dist/cli/commands/learn.d.ts +2 -0
- package/dist/cli/commands/learn.js +22 -0
- package/dist/cli/commands/learn.js.map +1 -0
- package/dist/cli/commands/modules.js +25 -6
- package/dist/cli/commands/modules.js.map +1 -1
- package/dist/cli/commands/network.js +15 -9
- package/dist/cli/commands/network.js.map +1 -1
- package/dist/cli/commands/query.js +92 -25
- package/dist/cli/commands/query.js.map +1 -1
- package/dist/cli/commands/start.js +8 -5
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/status.js +21 -16
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/stop.js +5 -4
- package/dist/cli/commands/stop.js.map +1 -1
- package/dist/cli/ipc-helper.js +4 -3
- package/dist/cli/ipc-helper.js.map +1 -1
- package/dist/cli/update-check.d.ts +2 -0
- package/dist/cli/update-check.js +58 -0
- package/dist/cli/update-check.js.map +1 -0
- package/dist/db/migrations/001_core_schema.js +115 -115
- package/dist/db/migrations/002_learning_schema.js +33 -33
- package/dist/db/migrations/003_code_schema.js +48 -48
- package/dist/db/migrations/004_synapses_schema.js +52 -52
- package/dist/db/migrations/005_fts_indexes.js +73 -73
- package/dist/db/migrations/index.js +6 -6
- package/dist/db/repositories/antipattern.repository.js +3 -3
- package/dist/db/repositories/code-module.repository.d.ts +1 -0
- package/dist/db/repositories/code-module.repository.js +8 -0
- package/dist/db/repositories/code-module.repository.js.map +1 -1
- package/dist/db/repositories/error.repository.js +46 -46
- package/dist/db/repositories/insight.repository.js +3 -3
- package/dist/db/repositories/notification.repository.js +3 -3
- package/dist/db/repositories/project.repository.js +21 -21
- package/dist/db/repositories/rule.repository.js +24 -24
- package/dist/db/repositories/solution.repository.js +50 -50
- package/dist/db/repositories/synapse.repository.js +18 -18
- package/dist/db/repositories/terminal.repository.js +24 -24
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/ipc/router.d.ts +2 -0
- package/dist/ipc/router.js +7 -1
- package/dist/ipc/router.js.map +1 -1
- package/dist/services/code.service.d.ts +1 -1
- package/dist/services/code.service.js +5 -2
- package/dist/services/code.service.js.map +1 -1
- package/package.json +5 -4
- package/src/brain.ts +3 -0
- package/src/cli/colors.ts +116 -0
- package/src/cli/commands/config.ts +169 -0
- package/src/cli/commands/dashboard.ts +231 -8
- package/src/cli/commands/export.ts +4 -0
- package/src/cli/commands/import.ts +24 -15
- package/src/cli/commands/insights.ts +37 -5
- package/src/cli/commands/learn.ts +24 -0
- package/src/cli/commands/modules.ts +28 -5
- package/src/cli/commands/network.ts +15 -9
- package/src/cli/commands/query.ts +103 -26
- package/src/cli/commands/start.ts +8 -5
- package/src/cli/commands/status.ts +22 -16
- package/src/cli/commands/stop.ts +5 -4
- package/src/cli/ipc-helper.ts +4 -3
- package/src/cli/update-check.ts +63 -0
- package/src/code/analyzer.ts +77 -77
- package/src/code/fingerprint.ts +87 -87
- package/src/code/matcher.ts +64 -64
- package/src/code/parsers/generic.ts +29 -29
- package/src/code/parsers/python.ts +54 -54
- package/src/code/parsers/typescript.ts +65 -65
- package/src/code/registry.ts +60 -60
- package/src/code/scorer.ts +108 -108
- package/src/config.ts +111 -111
- package/src/db/connection.ts +22 -22
- package/src/db/migrations/001_core_schema.ts +120 -120
- package/src/db/migrations/002_learning_schema.ts +38 -38
- package/src/db/migrations/003_code_schema.ts +53 -53
- package/src/db/migrations/004_synapses_schema.ts +57 -57
- package/src/db/migrations/005_fts_indexes.ts +78 -78
- package/src/db/migrations/006_synapses_phase3.ts +17 -17
- package/src/db/migrations/index.ts +64 -64
- package/src/db/repositories/antipattern.repository.ts +66 -66
- package/src/db/repositories/code-module.repository.ts +9 -0
- package/src/db/repositories/error.repository.ts +149 -149
- package/src/db/repositories/insight.repository.ts +78 -78
- package/src/db/repositories/notification.repository.ts +66 -66
- package/src/db/repositories/project.repository.ts +93 -93
- package/src/db/repositories/rule.repository.ts +108 -108
- package/src/db/repositories/solution.repository.ts +154 -154
- package/src/db/repositories/synapse.repository.ts +153 -153
- package/src/db/repositories/terminal.repository.ts +101 -101
- package/src/hooks/post-tool-use.ts +90 -90
- package/src/hooks/post-write.ts +117 -117
- package/src/index.ts +4 -0
- package/src/ipc/client.ts +118 -118
- package/src/ipc/protocol.ts +35 -35
- package/src/ipc/router.ts +9 -1
- package/src/ipc/server.ts +110 -110
- package/src/learning/confidence-scorer.ts +47 -47
- package/src/learning/decay.ts +46 -46
- package/src/learning/learning-engine.ts +162 -162
- package/src/learning/pattern-extractor.ts +90 -90
- package/src/learning/rule-generator.ts +74 -74
- package/src/matching/error-matcher.ts +115 -115
- package/src/matching/fingerprint.ts +29 -29
- package/src/matching/similarity.ts +61 -61
- package/src/matching/tfidf.ts +74 -74
- package/src/matching/tokenizer.ts +41 -41
- package/src/mcp/auto-detect.ts +93 -93
- package/src/mcp/server.ts +73 -73
- package/src/mcp/tools.ts +290 -290
- package/src/parsing/error-parser.ts +28 -28
- package/src/parsing/parsers/compiler.ts +93 -93
- package/src/parsing/parsers/generic.ts +28 -28
- package/src/parsing/parsers/go.ts +97 -97
- package/src/parsing/parsers/node.ts +69 -69
- package/src/parsing/parsers/python.ts +62 -62
- package/src/parsing/parsers/rust.ts +50 -50
- package/src/parsing/parsers/shell.ts +42 -42
- package/src/parsing/types.ts +47 -47
- package/src/research/gap-analyzer.ts +135 -135
- package/src/research/insight-generator.ts +123 -123
- package/src/research/research-engine.ts +116 -116
- package/src/research/synergy-detector.ts +126 -126
- package/src/research/template-extractor.ts +130 -130
- package/src/research/trend-analyzer.ts +127 -127
- package/src/services/analytics.service.ts +87 -87
- package/src/services/code.service.ts +5 -2
- package/src/services/error.service.ts +164 -164
- package/src/services/notification.service.ts +41 -41
- package/src/services/prevention.service.ts +119 -119
- package/src/services/research.service.ts +93 -93
- package/src/services/solution.service.ts +116 -116
- package/src/services/synapse.service.ts +59 -59
- package/src/services/terminal.service.ts +81 -81
- package/src/synapses/activation.ts +80 -80
- package/src/synapses/decay.ts +38 -38
- package/src/synapses/hebbian.ts +69 -69
- package/src/synapses/pathfinder.ts +81 -81
- package/src/synapses/synapse-manager.ts +109 -109
- package/src/types/code.types.ts +52 -52
- package/src/types/config.types.ts +79 -79
- package/src/types/error.types.ts +67 -67
- package/src/types/ipc.types.ts +8 -8
- package/src/types/mcp.types.ts +53 -53
- package/src/types/research.types.ts +28 -28
- package/src/types/solution.types.ts +30 -30
- package/src/types/synapse.types.ts +49 -49
- package/src/utils/events.ts +45 -45
- package/src/utils/hash.ts +5 -5
- package/src/utils/logger.ts +48 -48
- package/src/utils/paths.ts +19 -19
- package/tests/fixtures/code-modules/modules.ts +83 -83
- package/tests/fixtures/errors/go.ts +9 -9
- package/tests/fixtures/errors/node.ts +24 -24
- package/tests/fixtures/errors/python.ts +21 -21
- package/tests/fixtures/errors/rust.ts +25 -25
- package/tests/fixtures/errors/shell.ts +15 -15
- package/tests/fixtures/solutions/solutions.ts +27 -27
- package/tests/helpers/setup-db.ts +52 -52
- package/tests/integration/code-flow.test.ts +86 -86
- package/tests/integration/error-flow.test.ts +83 -83
- package/tests/integration/ipc-flow.test.ts +166 -166
- package/tests/integration/learning-cycle.test.ts +82 -82
- package/tests/integration/synapse-flow.test.ts +117 -117
- package/tests/unit/code/analyzer.test.ts +58 -58
- package/tests/unit/code/fingerprint.test.ts +51 -51
- package/tests/unit/code/scorer.test.ts +55 -55
- package/tests/unit/learning/confidence-scorer.test.ts +60 -60
- package/tests/unit/learning/decay.test.ts +45 -45
- package/tests/unit/learning/pattern-extractor.test.ts +50 -50
- package/tests/unit/matching/error-matcher.test.ts +69 -69
- package/tests/unit/matching/fingerprint.test.ts +47 -47
- package/tests/unit/matching/similarity.test.ts +65 -65
- package/tests/unit/matching/tfidf.test.ts +71 -71
- package/tests/unit/matching/tokenizer.test.ts +83 -83
- package/tests/unit/parsing/parsers.test.ts +113 -113
- package/tests/unit/research/gap-analyzer.test.ts +45 -45
- package/tests/unit/research/trend-analyzer.test.ts +45 -45
- package/tests/unit/synapses/activation.test.ts +80 -80
- package/tests/unit/synapses/decay.test.ts +27 -27
- package/tests/unit/synapses/hebbian.test.ts +96 -96
- package/tests/unit/synapses/pathfinder.test.ts +72 -72
- package/tsconfig.json +18 -18
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
export function up(db) {
|
|
2
|
-
db.exec(`
|
|
3
|
-
CREATE TABLE IF NOT EXISTS synapses (
|
|
4
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
5
|
-
source_type TEXT NOT NULL,
|
|
6
|
-
source_id INTEGER NOT NULL,
|
|
7
|
-
target_type TEXT NOT NULL,
|
|
8
|
-
target_id INTEGER NOT NULL,
|
|
9
|
-
synapse_type TEXT NOT NULL,
|
|
10
|
-
weight REAL NOT NULL DEFAULT 0.5,
|
|
11
|
-
metadata TEXT,
|
|
12
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
13
|
-
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
14
|
-
UNIQUE(source_type, source_id, target_type, target_id, synapse_type)
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
CREATE TABLE IF NOT EXISTS insights (
|
|
18
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
19
|
-
type TEXT NOT NULL,
|
|
20
|
-
title TEXT NOT NULL,
|
|
21
|
-
description TEXT NOT NULL,
|
|
22
|
-
evidence TEXT NOT NULL DEFAULT '[]',
|
|
23
|
-
priority INTEGER NOT NULL DEFAULT 0,
|
|
24
|
-
project_id INTEGER,
|
|
25
|
-
active INTEGER NOT NULL DEFAULT 1,
|
|
26
|
-
expires_at TEXT,
|
|
27
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
28
|
-
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
CREATE TABLE IF NOT EXISTS notifications (
|
|
32
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
33
|
-
type TEXT NOT NULL,
|
|
34
|
-
title TEXT NOT NULL,
|
|
35
|
-
message TEXT NOT NULL,
|
|
36
|
-
priority INTEGER NOT NULL DEFAULT 0,
|
|
37
|
-
project_id INTEGER,
|
|
38
|
-
acknowledged INTEGER NOT NULL DEFAULT 0,
|
|
39
|
-
acknowledged_at TEXT,
|
|
40
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
41
|
-
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
CREATE INDEX IF NOT EXISTS idx_synapses_source ON synapses(source_type, source_id);
|
|
45
|
-
CREATE INDEX IF NOT EXISTS idx_synapses_target ON synapses(target_type, target_id);
|
|
46
|
-
CREATE INDEX IF NOT EXISTS idx_synapses_type ON synapses(synapse_type);
|
|
47
|
-
CREATE INDEX IF NOT EXISTS idx_synapses_weight ON synapses(weight);
|
|
48
|
-
CREATE INDEX IF NOT EXISTS idx_insights_type ON insights(type);
|
|
49
|
-
CREATE INDEX IF NOT EXISTS idx_insights_project ON insights(project_id);
|
|
50
|
-
CREATE INDEX IF NOT EXISTS idx_insights_active ON insights(active);
|
|
51
|
-
CREATE INDEX IF NOT EXISTS idx_insights_priority ON insights(priority);
|
|
52
|
-
CREATE INDEX IF NOT EXISTS idx_notifications_acknowledged ON notifications(acknowledged);
|
|
53
|
-
CREATE INDEX IF NOT EXISTS idx_notifications_project ON notifications(project_id);
|
|
2
|
+
db.exec(`
|
|
3
|
+
CREATE TABLE IF NOT EXISTS synapses (
|
|
4
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
5
|
+
source_type TEXT NOT NULL,
|
|
6
|
+
source_id INTEGER NOT NULL,
|
|
7
|
+
target_type TEXT NOT NULL,
|
|
8
|
+
target_id INTEGER NOT NULL,
|
|
9
|
+
synapse_type TEXT NOT NULL,
|
|
10
|
+
weight REAL NOT NULL DEFAULT 0.5,
|
|
11
|
+
metadata TEXT,
|
|
12
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
13
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
14
|
+
UNIQUE(source_type, source_id, target_type, target_id, synapse_type)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE IF NOT EXISTS insights (
|
|
18
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
19
|
+
type TEXT NOT NULL,
|
|
20
|
+
title TEXT NOT NULL,
|
|
21
|
+
description TEXT NOT NULL,
|
|
22
|
+
evidence TEXT NOT NULL DEFAULT '[]',
|
|
23
|
+
priority INTEGER NOT NULL DEFAULT 0,
|
|
24
|
+
project_id INTEGER,
|
|
25
|
+
active INTEGER NOT NULL DEFAULT 1,
|
|
26
|
+
expires_at TEXT,
|
|
27
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
28
|
+
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
CREATE TABLE IF NOT EXISTS notifications (
|
|
32
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
33
|
+
type TEXT NOT NULL,
|
|
34
|
+
title TEXT NOT NULL,
|
|
35
|
+
message TEXT NOT NULL,
|
|
36
|
+
priority INTEGER NOT NULL DEFAULT 0,
|
|
37
|
+
project_id INTEGER,
|
|
38
|
+
acknowledged INTEGER NOT NULL DEFAULT 0,
|
|
39
|
+
acknowledged_at TEXT,
|
|
40
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
41
|
+
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
CREATE INDEX IF NOT EXISTS idx_synapses_source ON synapses(source_type, source_id);
|
|
45
|
+
CREATE INDEX IF NOT EXISTS idx_synapses_target ON synapses(target_type, target_id);
|
|
46
|
+
CREATE INDEX IF NOT EXISTS idx_synapses_type ON synapses(synapse_type);
|
|
47
|
+
CREATE INDEX IF NOT EXISTS idx_synapses_weight ON synapses(weight);
|
|
48
|
+
CREATE INDEX IF NOT EXISTS idx_insights_type ON insights(type);
|
|
49
|
+
CREATE INDEX IF NOT EXISTS idx_insights_project ON insights(project_id);
|
|
50
|
+
CREATE INDEX IF NOT EXISTS idx_insights_active ON insights(active);
|
|
51
|
+
CREATE INDEX IF NOT EXISTS idx_insights_priority ON insights(priority);
|
|
52
|
+
CREATE INDEX IF NOT EXISTS idx_notifications_acknowledged ON notifications(acknowledged);
|
|
53
|
+
CREATE INDEX IF NOT EXISTS idx_notifications_project ON notifications(project_id);
|
|
54
54
|
`);
|
|
55
55
|
}
|
|
56
56
|
//# sourceMappingURL=004_synapses_schema.js.map
|
|
@@ -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,oB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wB,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;;;OAGlB,CAAC;YACF,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,yCAAyC,CAAC;YAC9D,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,uCAAuC,CAAC;YAC3D,iBAAiB,EAAE,EAAE,CAAC,OAAO,CAAC,kDAAkD,CAAC;YACjF,aAAa,EAAE,EAAE,CAAC,OAAO,CAAC,mEAAmE,CAAC;YAC9F,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,8CAA8C,CAAC;YACnE,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,4CAA4C,CAAC;YAClE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC;;;;;OAKlB,CAAC;SACH,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAsB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC,eAAyB,CAAC;IAC1C,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAiC,CAAC;IACpE,CAAC;IAED,MAAM,CAAC,EAAU,EAAE,IAAsB;QACvC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAE,IAAgC,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC;QACvG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uB,CAAC;IACvE,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAuB,CAAC;IAC5D,CAAC;IAED,OAAO,CAAC,KAAc;QACpB,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,sDAAsD,CAAC,CAAC;YACrF,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,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
|
}
|