mindlore 0.4.3 → 0.5.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 (68) hide show
  1. package/README.md +2 -1
  2. package/dist/scripts/lib/constants.d.ts +4 -0
  3. package/dist/scripts/lib/constants.d.ts.map +1 -1
  4. package/dist/scripts/lib/constants.js +5 -1
  5. package/dist/scripts/lib/constants.js.map +1 -1
  6. package/dist/scripts/lib/db-helpers.d.ts +15 -0
  7. package/dist/scripts/lib/db-helpers.d.ts.map +1 -1
  8. package/dist/scripts/lib/db-helpers.js +51 -0
  9. package/dist/scripts/lib/db-helpers.js.map +1 -1
  10. package/dist/scripts/lib/embedding.d.ts +5 -0
  11. package/dist/scripts/lib/embedding.d.ts.map +1 -0
  12. package/dist/scripts/lib/embedding.js +44 -0
  13. package/dist/scripts/lib/embedding.js.map +1 -0
  14. package/dist/scripts/lib/hybrid-search.d.ts +62 -0
  15. package/dist/scripts/lib/hybrid-search.d.ts.map +1 -0
  16. package/dist/scripts/lib/hybrid-search.js +150 -0
  17. package/dist/scripts/lib/hybrid-search.js.map +1 -0
  18. package/dist/scripts/lib/migrations.d.ts +3 -0
  19. package/dist/scripts/lib/migrations.d.ts.map +1 -0
  20. package/dist/scripts/lib/migrations.js +38 -0
  21. package/dist/scripts/lib/migrations.js.map +1 -0
  22. package/dist/scripts/lib/schema-version.d.ts +13 -0
  23. package/dist/scripts/lib/schema-version.d.ts.map +1 -0
  24. package/dist/scripts/lib/schema-version.js +37 -0
  25. package/dist/scripts/lib/schema-version.js.map +1 -0
  26. package/dist/scripts/lib/synonym.d.ts +4 -0
  27. package/dist/scripts/lib/synonym.d.ts.map +1 -0
  28. package/dist/scripts/lib/synonym.js +37 -0
  29. package/dist/scripts/lib/synonym.js.map +1 -0
  30. package/dist/scripts/mindlore-fts5-index.d.ts +2 -1
  31. package/dist/scripts/mindlore-fts5-index.d.ts.map +1 -1
  32. package/dist/scripts/mindlore-fts5-index.js +57 -5
  33. package/dist/scripts/mindlore-fts5-index.js.map +1 -1
  34. package/dist/scripts/mindlore-fts5-search.d.ts +3 -2
  35. package/dist/scripts/mindlore-fts5-search.d.ts.map +1 -1
  36. package/dist/scripts/mindlore-fts5-search.js +89 -35
  37. package/dist/scripts/mindlore-fts5-search.js.map +1 -1
  38. package/dist/scripts/mindlore-health-check.js +52 -0
  39. package/dist/scripts/mindlore-health-check.js.map +1 -1
  40. package/dist/tests/embedding.test.d.ts +6 -0
  41. package/dist/tests/embedding.test.d.ts.map +1 -0
  42. package/dist/tests/embedding.test.js +71 -0
  43. package/dist/tests/embedding.test.js.map +1 -0
  44. package/dist/tests/fts5.test.js +82 -0
  45. package/dist/tests/fts5.test.js.map +1 -1
  46. package/dist/tests/helpers/db.d.ts +5 -0
  47. package/dist/tests/helpers/db.d.ts.map +1 -1
  48. package/dist/tests/helpers/db.js +19 -0
  49. package/dist/tests/helpers/db.js.map +1 -1
  50. package/dist/tests/hybrid-search.test.d.ts +2 -0
  51. package/dist/tests/hybrid-search.test.d.ts.map +1 -0
  52. package/dist/tests/hybrid-search.test.js +114 -0
  53. package/dist/tests/hybrid-search.test.js.map +1 -0
  54. package/dist/tests/schema-version.test.d.ts +2 -0
  55. package/dist/tests/schema-version.test.d.ts.map +1 -0
  56. package/dist/tests/schema-version.test.js +99 -0
  57. package/dist/tests/schema-version.test.js.map +1 -0
  58. package/dist/tests/search-hook.test.js +11 -0
  59. package/dist/tests/search-hook.test.js.map +1 -1
  60. package/dist/tests/synonym.test.d.ts +2 -0
  61. package/dist/tests/synonym.test.d.ts.map +1 -0
  62. package/dist/tests/synonym.test.js +47 -0
  63. package/dist/tests/synonym.test.js.map +1 -0
  64. package/hooks/lib/mindlore-common.cjs +32 -0
  65. package/hooks/mindlore-search.cjs +58 -1
  66. package/package.json +3 -1
  67. package/plugin.json +1 -1
  68. package/templates/config.json +15 -1
@@ -10,12 +10,20 @@
10
10
 
11
11
  const fs = require('fs');
12
12
  const path = require('path');
13
- const { getAllDbs, requireDatabase, extractHeadings, readHookStdin, extractKeywords } = require('./lib/mindlore-common.cjs');
13
+ const { getAllDbs, requireDatabase, extractHeadings, readHookStdin, extractKeywords, readConfig, loadSqliteVecCjs, hasVecTableCjs } = require('./lib/mindlore-common.cjs');
14
14
 
15
15
  const MAX_RESULTS = 3;
16
16
  const MIN_QUERY_WORDS = 3;
17
17
  const MIN_KEYWORD_HITS = 2;
18
18
 
19
+ // Try to load hybrid search module (built TS)
20
+ let hybridSearchMod;
21
+ try {
22
+ hybridSearchMod = require('../dist/scripts/lib/hybrid-search.js');
23
+ } catch (_err) {
24
+ // hybrid-search not built yet — pure FTS5 mode
25
+ }
26
+
19
27
  /**
20
28
  * Search a single DB and return scored results with their baseDir.
21
29
  */
@@ -24,6 +32,55 @@ function searchDb(dbPath, keywords, Database) {
24
32
  const db = new Database(dbPath, { readonly: true });
25
33
  const results = [];
26
34
 
35
+ // v0.5.0: Try hybrid search with synonym expansion (no embedding — hooks are sync)
36
+ if (hybridSearchMod && loadSqliteVecCjs(db) && hasVecTableCjs(db)) {
37
+ try {
38
+ const config = readConfig(baseDir);
39
+ const synonyms = (config && config.synonyms) ? config.synonyms : {};
40
+
41
+ // Expand keywords with synonyms
42
+ const expandedTerms = keywords.slice();
43
+ for (const kw of keywords) {
44
+ const lower = kw.toLowerCase();
45
+ if (synonyms[lower]) {
46
+ expandedTerms.push(...synonyms[lower]);
47
+ }
48
+ }
49
+
50
+ const fusedResults = hybridSearchMod.hybridSearch(db, expandedTerms.join(' '), {
51
+ maxResults: MAX_RESULTS,
52
+ project: path.basename(process.cwd()),
53
+ });
54
+
55
+ if (fusedResults.length > 0) {
56
+ for (const r of fusedResults) {
57
+ const filePath = r.path || '';
58
+ let headings = [];
59
+ if (filePath && fs.existsSync(filePath)) {
60
+ const content = fs.readFileSync(filePath, 'utf8');
61
+ headings = extractHeadings(content, 3);
62
+ }
63
+ results.push({
64
+ path: filePath,
65
+ slug: r.slug,
66
+ description: r.description || '',
67
+ category: r.category || '',
68
+ title: r.title || '',
69
+ tags: r.tags || '',
70
+ headings,
71
+ hits: 1,
72
+ rank: r.score,
73
+ baseDir,
74
+ });
75
+ }
76
+ db.close();
77
+ return results;
78
+ }
79
+ } catch (_err) {
80
+ // Hybrid search failed — fall through to FTS5
81
+ }
82
+ }
83
+
27
84
  try {
28
85
  const allPaths = db.prepare('SELECT DISTINCT path FROM mindlore_fts').all();
29
86
  const matchStmt = db.prepare('SELECT rank FROM mindlore_fts WHERE path = ? AND mindlore_fts MATCH ?');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindlore",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "AI-native knowledge system for Claude Code",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -52,9 +52,11 @@
52
52
  "@types/node": "^25.6.0",
53
53
  "@typescript-eslint/eslint-plugin": "^8.58.1",
54
54
  "@typescript-eslint/parser": "^8.58.1",
55
+ "@xenova/transformers": "^2.17.2",
55
56
  "eslint": "^9.0.0",
56
57
  "globals": "^15.0.0",
57
58
  "jest": "^29.7.0",
59
+ "sqlite-vec": "^0.1.9",
58
60
  "ts-jest": "^29.4.9",
59
61
  "typescript": "^6.0.2"
60
62
  },
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mindlore",
3
3
  "description": "AI-native knowledge system for Claude Code. Persistent, searchable, evolving knowledge base with FTS5.",
4
- "version": "0.4.3",
4
+ "version": "0.5.0",
5
5
  "skills": [
6
6
  {
7
7
  "name": "mindlore-ingest",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.3",
2
+ "version": "0.5.0",
3
3
  "models": {
4
4
  "ingest": "haiku",
5
5
  "evolve": "sonnet",
@@ -12,5 +12,19 @@
12
12
  "session_focus": {
13
13
  "max_episodes": 3,
14
14
  "multi_session_days": 3
15
+ },
16
+ "synonyms": {
17
+ "auth": ["authentication", "login", "kimlik doğrulama"],
18
+ "güvenlik": ["security", "hardening", "sertleştirme"],
19
+ "db": ["database", "veritabanı", "sqlite"],
20
+ "api": ["endpoint", "rest", "graphql"],
21
+ "ui": ["frontend", "arayüz", "interface"],
22
+ "test": ["testing", "jest", "unit test"]
23
+ },
24
+ "hybrid": {
25
+ "enabled": true,
26
+ "ftsWeight": 0.4,
27
+ "vecWeight": 0.6,
28
+ "k": 60
15
29
  }
16
30
  }