mindlore 0.6.8 → 0.6.9

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 (124) hide show
  1. package/README.md +259 -259
  2. package/SCHEMA.md +292 -292
  3. package/dist/scripts/cc-memory-bulk-sync.d.ts.map +1 -1
  4. package/dist/scripts/cc-memory-bulk-sync.js +2 -1
  5. package/dist/scripts/cc-memory-bulk-sync.js.map +1 -1
  6. package/dist/scripts/cc-session-sync.d.ts.map +1 -1
  7. package/dist/scripts/cc-session-sync.js +6 -5
  8. package/dist/scripts/cc-session-sync.js.map +1 -1
  9. package/dist/scripts/fetch-raw.js +5 -4
  10. package/dist/scripts/fetch-raw.js.map +1 -1
  11. package/dist/scripts/init.js +12 -11
  12. package/dist/scripts/init.js.map +1 -1
  13. package/dist/scripts/lib/consolidation.js +10 -10
  14. package/dist/scripts/lib/constants.d.ts +2 -0
  15. package/dist/scripts/lib/constants.d.ts.map +1 -1
  16. package/dist/scripts/lib/constants.js +10 -1
  17. package/dist/scripts/lib/constants.js.map +1 -1
  18. package/dist/scripts/lib/decay.js +9 -9
  19. package/dist/scripts/lib/episodes.js +23 -23
  20. package/dist/scripts/lib/migrations-v061.js +21 -21
  21. package/dist/scripts/lib/migrations-v062.js +11 -11
  22. package/dist/scripts/lib/migrations-v063.js +14 -14
  23. package/dist/scripts/lib/migrations-v067.js +11 -11
  24. package/dist/scripts/lib/schema-version.js +6 -6
  25. package/dist/scripts/lib/search-cache.js +11 -11
  26. package/dist/scripts/lib/secure-io.d.ts +11 -0
  27. package/dist/scripts/lib/secure-io.d.ts.map +1 -0
  28. package/dist/scripts/lib/secure-io.js +26 -0
  29. package/dist/scripts/lib/secure-io.js.map +1 -0
  30. package/dist/scripts/lib/session-payload.js +7 -7
  31. package/dist/scripts/lib/triage.js +3 -3
  32. package/dist/scripts/lib/validate-manifest.d.ts +8 -0
  33. package/dist/scripts/lib/validate-manifest.d.ts.map +1 -0
  34. package/dist/scripts/lib/validate-manifest.js +80 -0
  35. package/dist/scripts/lib/validate-manifest.js.map +1 -0
  36. package/dist/scripts/mindlore-backup.js +9 -9
  37. package/dist/scripts/mindlore-fts5-index.js +10 -10
  38. package/dist/scripts/validate-manifest-cli.d.ts +2 -0
  39. package/dist/scripts/validate-manifest-cli.d.ts.map +1 -0
  40. package/dist/scripts/validate-manifest-cli.js +38 -0
  41. package/dist/scripts/validate-manifest-cli.js.map +1 -0
  42. package/dist/tests/cc-memory-sync.test.js +3 -3
  43. package/dist/tests/chunks-migration.test.js +1 -1
  44. package/dist/tests/compaction-snapshot.test.js +2 -2
  45. package/dist/tests/consolidation.test.js +3 -3
  46. package/dist/tests/decay.test.js +9 -9
  47. package/dist/tests/diary.test.js +4 -4
  48. package/dist/tests/episode-file.test.js +2 -1
  49. package/dist/tests/episode-file.test.js.map +1 -1
  50. package/dist/tests/episodes-inject.test.js +9 -9
  51. package/dist/tests/fetch-raw.test.js +1 -2
  52. package/dist/tests/fetch-raw.test.js.map +1 -1
  53. package/dist/tests/fts5.test.js +75 -75
  54. package/dist/tests/fuzzy.test.js +1 -1
  55. package/dist/tests/git-snapshot.test.js +3 -5
  56. package/dist/tests/git-snapshot.test.js.map +1 -1
  57. package/dist/tests/helpers/db.d.ts +1 -2
  58. package/dist/tests/helpers/db.d.ts.map +1 -1
  59. package/dist/tests/helpers/db.js +18 -26
  60. package/dist/tests/helpers/db.js.map +1 -1
  61. package/dist/tests/manifest-v2.test.d.ts +2 -0
  62. package/dist/tests/manifest-v2.test.d.ts.map +1 -0
  63. package/dist/tests/manifest-v2.test.js +74 -0
  64. package/dist/tests/manifest-v2.test.js.map +1 -0
  65. package/dist/tests/migrations-v053.test.js +16 -16
  66. package/dist/tests/migrations-v061.test.js +10 -10
  67. package/dist/tests/migrations-v063.test.js +4 -4
  68. package/dist/tests/migrations-v068.test.js +6 -3
  69. package/dist/tests/migrations-v068.test.js.map +1 -1
  70. package/dist/tests/nomination-counts.test.js +6 -6
  71. package/dist/tests/nomination-counts.test.js.map +1 -1
  72. package/dist/tests/pre-compact.test.js +2 -1
  73. package/dist/tests/pre-compact.test.js.map +1 -1
  74. package/dist/tests/recall-telemetry.test.js +12 -11
  75. package/dist/tests/recall-telemetry.test.js.map +1 -1
  76. package/dist/tests/rrf.test.js +3 -3
  77. package/dist/tests/search-engine.test.js +1 -1
  78. package/dist/tests/search-hook.test.js +2 -2
  79. package/dist/tests/search-offload.test.js +1 -1
  80. package/dist/tests/search-offload.test.js.map +1 -1
  81. package/dist/tests/secure-io.test.d.ts +2 -0
  82. package/dist/tests/secure-io.test.d.ts.map +1 -0
  83. package/dist/tests/secure-io.test.js +65 -0
  84. package/dist/tests/secure-io.test.js.map +1 -0
  85. package/dist/tests/session-payload.test.js +1 -1
  86. package/dist/tests/session-summary.test.js +1 -1
  87. package/dist/tests/similarity.test.js +1 -1
  88. package/dist/tests/skill-path-resolution.test.js +22 -3
  89. package/dist/tests/skill-path-resolution.test.js.map +1 -1
  90. package/dist/tests/triage.test.js +1 -1
  91. package/hooks/lib/constants.cjs +15 -15
  92. package/hooks/lib/mindlore-common.cjs +975 -974
  93. package/hooks/mindlore-cwd-changed.cjs +57 -57
  94. package/hooks/mindlore-decision-detector.cjs +54 -54
  95. package/hooks/mindlore-dont-repeat.cjs +222 -222
  96. package/hooks/mindlore-fts5-sync.cjs +98 -97
  97. package/hooks/mindlore-index.cjs +230 -229
  98. package/hooks/mindlore-model-router.cjs +54 -54
  99. package/hooks/mindlore-post-compact.cjs +69 -69
  100. package/hooks/mindlore-post-read.cjs +106 -106
  101. package/hooks/mindlore-pre-compact.cjs +154 -154
  102. package/hooks/mindlore-read-guard.cjs +105 -105
  103. package/hooks/mindlore-research-guard.cjs +176 -176
  104. package/hooks/mindlore-search.cjs +200 -200
  105. package/hooks/mindlore-session-end.cjs +510 -509
  106. package/hooks/mindlore-session-focus.cjs +256 -256
  107. package/package.json +76 -75
  108. package/plugin.json +2 -1
  109. package/skills/mindlore-diary/SKILL.md +85 -85
  110. package/skills/mindlore-evolve/SKILL.md +126 -126
  111. package/skills/mindlore-explore/SKILL.md +109 -109
  112. package/skills/mindlore-ingest/SKILL.md +195 -195
  113. package/skills/mindlore-maintain/SKILL.md +125 -125
  114. package/skills/mindlore-query/SKILL.md +151 -151
  115. package/skills/mindlore-reflect/SKILL.md +141 -141
  116. package/skills/mindlore-stats/SKILL.md +106 -106
  117. package/templates/INDEX.md +14 -14
  118. package/templates/SCHEMA.md +292 -292
  119. package/templates/config.json +1 -1
  120. package/templates/extraction/article.md +15 -15
  121. package/templates/extraction/changelog.md +15 -15
  122. package/templates/extraction/default.md +15 -15
  123. package/templates/extraction/docs.md +15 -15
  124. package/templates/extraction/github-repo.md +17 -17
@@ -1,97 +1,98 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- /**
5
- * mindlore-fts5-sync — FileChanged hook (incremental re-index)
6
- *
7
- * Handles bulk file changes by checking all .mindlore/ .md files
8
- * against their content hashes and re-indexing only changed ones.
9
- *
10
- * Lightweight complement to mindlore-index.cjs which handles single files.
11
- * This hook catches cases where multiple files change at once (e.g., git pull).
12
- */
13
-
14
- const fs = require('fs');
15
- const path = require('path');
16
- const { DB_NAME, sha256, openDatabase, getAllMdFiles, parseFrontmatter, extractFtsMetadata, insertFtsRow, readHookStdin, getActiveMindloreDir, getProjectName, resolveProject, hookLog, withTelemetry, SQL_FTS_SESSIONS_INSERT, isSessionCategory, isInsideMindloreDir } = require('./lib/mindlore-common.cjs');
17
-
18
- function main() {
19
- const filePath = readHookStdin(['path', 'file_path']);
20
-
21
- if (!filePath) return;
22
- const resolved = path.resolve(filePath);
23
- if (!isInsideMindloreDir(resolved)) return;
24
-
25
- // Skip if this is a single .md file change — mindlore-index.cjs handles those.
26
- // This hook is for bulk changes (git pull, manual batch edits).
27
- if (filePath.endsWith('.md')) return;
28
-
29
- const baseDir = getActiveMindloreDir();
30
- if (!fs.existsSync(baseDir)) return;
31
-
32
- const dbPath = path.join(baseDir, DB_NAME);
33
- if (!fs.existsSync(dbPath)) return;
34
-
35
- const db = openDatabase(dbPath);
36
- if (!db) return;
37
-
38
- const mdFiles = getAllMdFiles(baseDir);
39
-
40
-
41
- const getHash = db.prepare('SELECT content_hash FROM file_hashes WHERE path = ?');
42
- const deleteFts = db.prepare('DELETE FROM mindlore_fts WHERE path = ?');
43
- const deleteFtsSessions = db.prepare('DELETE FROM mindlore_fts_sessions WHERE path = ?');
44
- const insertFtsSessions = db.prepare(SQL_FTS_SESSIONS_INSERT);
45
- const upsertHash = db.prepare(`
46
- INSERT INTO file_hashes (path, content_hash, last_indexed)
47
- VALUES (?, ?, ?)
48
- ON CONFLICT(path) DO UPDATE SET
49
- content_hash = excluded.content_hash,
50
- last_indexed = excluded.last_indexed
51
- `);
52
-
53
- const now = new Date().toISOString();
54
-
55
- try {
56
- const project = getProjectName();
57
-
58
- // Pre-read all files outside the DB transaction to avoid holding
59
- // the write lock during slow file I/O (R4 root cause fix).
60
- const changedFiles = [];
61
- for (const file of mdFiles) {
62
- const content = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n');
63
- const hash = sha256(content);
64
-
65
- const existing = getHash.get(file);
66
- if (existing && existing.content_hash === hash) continue;
67
-
68
- const { meta, body } = parseFrontmatter(content);
69
- const { slug, description, type, category, title, tags, quality, dateCaptured, project: ftsProject } = extractFtsMetadata(meta, body, file, baseDir);
70
- const resolvedProject = resolveProject(ftsProject, file, project);
71
- changedFiles.push({ file, hash, slug, description, type, category, title, tags, quality, dateCaptured, resolvedProject, body });
72
- }
73
-
74
- // DB transaction: only DB writes — no file I/O inside to minimize lock hold time
75
- const transaction = db.transaction(() => {
76
- for (const item of changedFiles) {
77
- deleteFts.run(item.file);
78
- deleteFtsSessions.run(item.file);
79
- if (isSessionCategory(item.category)) {
80
- insertFtsSessions.run(item.file, item.slug, item.description, item.type, item.category, item.title, item.body, item.tags, item.quality ?? null, item.dateCaptured ?? null, item.resolvedProject);
81
- } else {
82
- insertFtsRow(db, { path: item.file, slug: item.slug, description: item.description, type: item.type, category: item.category, title: item.title, content: item.body, tags: item.tags, quality: item.quality, dateCaptured: item.dateCaptured, project: item.resolvedProject });
83
- }
84
- upsertHash.run(item.file, item.hash, now);
85
- }
86
- });
87
- transaction();
88
- } finally {
89
- db.close();
90
- }
91
-
92
- }
93
-
94
- withTelemetry('mindlore-fts5-sync', main).catch(err => {
95
- hookLog('mindlore-fts5-sync', 'error', err?.message ?? String(err));
96
- process.exit(0);
97
- });
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * mindlore-fts5-sync — FileChanged hook (incremental re-index)
6
+ *
7
+ * Handles bulk file changes by checking all .mindlore/ .md files
8
+ * against their content hashes and re-indexing only changed ones.
9
+ *
10
+ * Lightweight complement to mindlore-index.cjs which handles single files.
11
+ * This hook catches cases where multiple files change at once (e.g., git pull).
12
+ */
13
+
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+ const { DB_NAME, sha256, openDatabase, getAllMdFiles, parseFrontmatter, extractFtsMetadata, insertFtsRow, readHookStdin, getActiveMindloreDir, getProjectName, resolveProject, hookLog, withTelemetry, SQL_FTS_SESSIONS_INSERT, isSessionCategory, isInsideMindloreDir } = require('./lib/mindlore-common.cjs');
17
+
18
+ function main() {
19
+ const filePath = readHookStdin(['path', 'file_path']);
20
+
21
+ if (!filePath) return;
22
+ const resolved = path.resolve(filePath);
23
+ if (!isInsideMindloreDir(resolved)) return;
24
+
25
+ // Skip if this is a single .md file change — mindlore-index.cjs handles those.
26
+ // This hook is for bulk changes (git pull, manual batch edits).
27
+ if (filePath.endsWith('.md')) return;
28
+
29
+ const baseDir = getActiveMindloreDir();
30
+ if (!fs.existsSync(baseDir)) return;
31
+
32
+ const dbPath = path.join(baseDir, DB_NAME);
33
+ if (!fs.existsSync(dbPath)) return;
34
+
35
+ const db = openDatabase(dbPath);
36
+ if (!db) return;
37
+
38
+ const mdFiles = getAllMdFiles(baseDir);
39
+
40
+ const allHashes = new Map();
41
+ for (const row of db.prepare('SELECT path, content_hash FROM file_hashes').all()) {
42
+ allHashes.set(row.path, row.content_hash);
43
+ }
44
+
45
+ const deleteFts = db.prepare('DELETE FROM mindlore_fts WHERE path = ?');
46
+ const deleteFtsSessions = db.prepare('DELETE FROM mindlore_fts_sessions WHERE path = ?');
47
+ const insertFtsSessions = db.prepare(SQL_FTS_SESSIONS_INSERT);
48
+ const upsertHash = db.prepare(`
49
+ INSERT INTO file_hashes (path, content_hash, last_indexed)
50
+ VALUES (?, ?, ?)
51
+ ON CONFLICT(path) DO UPDATE SET
52
+ content_hash = excluded.content_hash,
53
+ last_indexed = excluded.last_indexed
54
+ `);
55
+
56
+ const now = new Date().toISOString();
57
+
58
+ try {
59
+ const project = getProjectName();
60
+
61
+ const changedFiles = [];
62
+ for (const file of mdFiles) {
63
+ const content = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n');
64
+ const hash = sha256(content);
65
+
66
+ const existingHash = allHashes.get(file);
67
+ if (existingHash === hash) continue;
68
+
69
+ const { meta, body } = parseFrontmatter(content);
70
+ const { slug, description, type, category, title, tags, quality, dateCaptured, project: ftsProject } = extractFtsMetadata(meta, body, file, baseDir);
71
+ const resolvedProject = resolveProject(ftsProject, file, project);
72
+ changedFiles.push({ file, hash, slug, description, type, category, title, tags, quality, dateCaptured, resolvedProject, body });
73
+ }
74
+
75
+ // No file I/O inside — minimize lock hold time
76
+ const transaction = db.transaction(() => {
77
+ for (const item of changedFiles) {
78
+ deleteFts.run(item.file);
79
+ deleteFtsSessions.run(item.file);
80
+ if (isSessionCategory(item.category)) {
81
+ insertFtsSessions.run(item.file, item.slug, item.description, item.type, item.category, item.title, item.body, item.tags, item.quality ?? null, item.dateCaptured ?? null, item.resolvedProject);
82
+ } else {
83
+ insertFtsRow(db, { path: item.file, slug: item.slug, description: item.description, type: item.type, category: item.category, title: item.title, content: item.body, tags: item.tags, quality: item.quality, dateCaptured: item.dateCaptured, project: item.resolvedProject });
84
+ }
85
+ upsertHash.run(item.file, item.hash, now);
86
+ }
87
+ });
88
+ transaction();
89
+ } finally {
90
+ db.close();
91
+ }
92
+
93
+ }
94
+
95
+ withTelemetry('mindlore-fts5-sync', main).catch(err => {
96
+ hookLog('mindlore-fts5-sync', 'error', err?.message ?? String(err));
97
+ process.exit(0);
98
+ });