mindlore 0.5.6 → 0.5.8

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 (53) hide show
  1. package/README.md +1 -1
  2. package/dist/scripts/cc-memory-bulk-sync.d.ts.map +1 -1
  3. package/dist/scripts/cc-memory-bulk-sync.js +6 -15
  4. package/dist/scripts/cc-memory-bulk-sync.js.map +1 -1
  5. package/dist/scripts/cc-session-sync.d.ts +32 -0
  6. package/dist/scripts/cc-session-sync.d.ts.map +1 -0
  7. package/dist/scripts/cc-session-sync.js +289 -0
  8. package/dist/scripts/cc-session-sync.js.map +1 -0
  9. package/dist/scripts/lib/constants.d.ts +2 -0
  10. package/dist/scripts/lib/constants.d.ts.map +1 -1
  11. package/dist/scripts/lib/constants.js +3 -1
  12. package/dist/scripts/lib/constants.js.map +1 -1
  13. package/dist/scripts/lib/privacy-filter.d.ts.map +1 -1
  14. package/dist/scripts/lib/privacy-filter.js +32 -14
  15. package/dist/scripts/lib/privacy-filter.js.map +1 -1
  16. package/dist/scripts/lib/sync-helpers.d.ts +37 -0
  17. package/dist/scripts/lib/sync-helpers.d.ts.map +1 -0
  18. package/dist/scripts/lib/sync-helpers.js +17 -0
  19. package/dist/scripts/lib/sync-helpers.js.map +1 -0
  20. package/dist/tests/cc-memory-bulk-sync.test.js +3 -0
  21. package/dist/tests/cc-memory-bulk-sync.test.js.map +1 -1
  22. package/dist/tests/cc-session-sync.test.d.ts +2 -0
  23. package/dist/tests/cc-session-sync.test.d.ts.map +1 -0
  24. package/dist/tests/cc-session-sync.test.js +306 -0
  25. package/dist/tests/cc-session-sync.test.js.map +1 -0
  26. package/dist/tests/helpers/db.d.ts.map +1 -1
  27. package/dist/tests/helpers/db.js +9 -1
  28. package/dist/tests/helpers/db.js.map +1 -1
  29. package/dist/tests/init.test.js +2 -0
  30. package/dist/tests/init.test.js.map +1 -1
  31. package/dist/tests/pre-compact.test.d.ts +2 -0
  32. package/dist/tests/pre-compact.test.d.ts.map +1 -0
  33. package/dist/tests/pre-compact.test.js +46 -0
  34. package/dist/tests/pre-compact.test.js.map +1 -0
  35. package/dist/tests/privacy-filter.test.js +10 -0
  36. package/dist/tests/privacy-filter.test.js.map +1 -1
  37. package/hooks/mindlore-pre-compact.cjs +27 -9
  38. package/hooks/mindlore-search.cjs +5 -3
  39. package/hooks/mindlore-session-end.cjs +17 -17
  40. package/package.json +2 -2
  41. package/plugin.json +1 -1
  42. package/skills/mindlore-decide/SKILL.md +3 -4
  43. package/skills/mindlore-diary/SKILL.md +4 -4
  44. package/skills/mindlore-evolve/SKILL.md +4 -4
  45. package/skills/mindlore-explore/SKILL.md +1 -0
  46. package/skills/mindlore-health/SKILL.md +3 -5
  47. package/skills/mindlore-ingest/SKILL.md +3 -4
  48. package/skills/mindlore-log/SKILL.md +3 -4
  49. package/skills/mindlore-maintain/SKILL.md +10 -5
  50. package/skills/mindlore-query/SKILL.md +3 -4
  51. package/skills/mindlore-reflect/SKILL.md +4 -4
  52. package/templates/INDEX.md +2 -0
  53. package/templates/config.json +1 -1
@@ -5,8 +5,8 @@
5
5
  * mindlore-pre-compact — PreCompact hook
6
6
  *
7
7
  * Before context compaction:
8
- * 1. Write a delta snapshot to diary/ (if not already written this session)
9
- * 2. Ensure FTS5 index is up to date
8
+ * 1. Ensure FTS5 index is up to date
9
+ * 2. Write pre-compact episode to episodes/ and append log entry
10
10
  */
11
11
 
12
12
  const fs = require('fs');
@@ -31,16 +31,34 @@ function main() {
31
31
  }
32
32
  }
33
33
 
34
- // Write a pre-compact marker to diary
35
- const diaryDir = path.join(baseDir, 'diary');
36
- if (!fs.existsSync(diaryDir)) return;
34
+ const now = new Date();
35
+ const iso = now.toISOString();
37
36
 
37
+ // Write pre-compact episode
38
+ const episodesDir = path.join(baseDir, 'episodes');
39
+ try {
40
+ const ts = iso.replace(/[:.]/g, '-');
41
+ const episodePath = path.join(episodesDir, `pre-compact-${ts}.md`);
42
+ const content = [
43
+ '---',
44
+ 'type: episode',
45
+ 'subtype: pre-compact',
46
+ `date: ${iso.slice(0, 10)}`,
47
+ `project: ${path.basename(process.cwd())}`,
48
+ '---',
49
+ '',
50
+ `Pre-compact snapshot at ${iso}.`,
51
+ `Working directory: ${process.cwd()}`,
52
+ ].join('\n');
53
+ fs.writeFileSync(episodePath, content, 'utf8');
54
+ } catch (_err) { /* episodes dir may not exist */ }
55
+
56
+ // Append log entry
38
57
  const logPath = path.join(baseDir, 'log.md');
39
- if (fs.existsSync(logPath)) {
40
- const now = new Date().toISOString();
41
- const entry = `| ${now.slice(0, 10)} | pre-compact | FTS5 flush before compaction |\n`;
58
+ try {
59
+ const entry = `| ${iso.slice(0, 10)} | pre-compact | FTS5 flush before compaction |\n`;
42
60
  fs.appendFileSync(logPath, entry, 'utf8');
43
- }
61
+ } catch (_err) { /* log file may not exist */ }
44
62
 
45
63
  process.stdout.write('[Mindlore: pre-compact FTS5 flush complete]\n');
46
64
  }
@@ -90,9 +90,11 @@ function searchDb(dbPath, keywords) {
90
90
  for (const r of fusedResults) {
91
91
  const filePath = r.path || '';
92
92
  let headings = [];
93
- if (filePath && fs.existsSync(filePath)) {
94
- const content = fs.readFileSync(filePath, 'utf8');
95
- headings = extractHeadings(content, 3);
93
+ if (filePath) {
94
+ try {
95
+ const content = fs.readFileSync(filePath, 'utf8');
96
+ headings = extractHeadings(content, 3);
97
+ } catch (_err) { /* file may have been deleted */ }
96
98
  }
97
99
  results.push({
98
100
  path: filePath,
@@ -12,7 +12,7 @@
12
12
  const fs = require('fs');
13
13
  const path = require('path');
14
14
  const os = require('os');
15
- const { execSync, spawn } = require('child_process');
15
+ const { execSync, execFileSync, spawn } = require('child_process');
16
16
  const { findMindloreDir, globalDir, getProjectName, openDatabase, ensureEpisodesTable, hasEpisodesTable, insertBareEpisode, insertFtsRow, hookLog, SHARED_EXPORT_DIRS, resolveWin32Bin } = require('./lib/mindlore-common.cjs');
17
17
 
18
18
  const EXPORT_DIRS = SHARED_EXPORT_DIRS;
@@ -46,23 +46,23 @@ if (process.argv.includes('--worker')) {
46
46
  await safeRunAsync(() => writeBareEpisode(baseDir, project, commits, changedFiles, reads), 'episode');
47
47
  await safeRunAsync(() => writeEpisodeFile(baseDir, project, commits, changedFiles, reads), 'episode-file');
48
48
 
49
- // CC memory bulk sync — synchronous with timeout
50
- await safeRunAsync(async () => {
51
- const syncScript = path.join(__dirname, '..', 'dist', 'scripts', 'cc-memory-bulk-sync.js');
52
- if (fs.existsSync(syncScript)) {
53
- const nodeExe = resolveWin32Bin('node') || process.execPath;
54
- const { execFileSync } = require('child_process');
55
- try {
56
- execFileSync(nodeExe, [syncScript, '--auto'], {
57
- timeout: 10000,
58
- env: { ...process.env, MINDLORE_HOME: baseDir },
59
- });
60
- hookLog('session-end', 'info', 'CC memory sync completed');
61
- } catch (syncErr) {
62
- hookLog('session-end', 'warn', `CC memory sync failed: ${syncErr?.message || syncErr}`);
63
- }
49
+ function runSyncScript(scriptName, args, timeoutMs, label) {
50
+ const scriptPath = path.join(__dirname, '..', 'dist', 'scripts', scriptName);
51
+ if (!fs.existsSync(scriptPath)) return;
52
+ const nodeExe = resolveWin32Bin('node') || process.execPath;
53
+ try {
54
+ execFileSync(nodeExe, [scriptPath, ...args], {
55
+ timeout: timeoutMs,
56
+ env: { ...process.env, MINDLORE_HOME: baseDir },
57
+ });
58
+ hookLog('session-end', 'info', label + ' completed');
59
+ } catch (err) {
60
+ hookLog('session-end', 'warn', `${label} failed: ${err?.message || err}`);
64
61
  }
65
- }, 'cc-memory-sync');
62
+ }
63
+
64
+ await safeRunAsync(() => runSyncScript('cc-memory-bulk-sync.js', ['--auto'], 10000, 'CC memory sync'), 'cc-memory-sync');
65
+ await safeRunAsync(() => runSyncScript('cc-session-sync.js', [], 30000, 'CC session sync'), 'cc-session-sync');
66
66
 
67
67
  // Embed trigger — detached, fire-and-forget
68
68
  await safeRunAsync(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindlore",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "AI-native knowledge system for Claude Code",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -57,7 +57,7 @@
57
57
  "@xenova/transformers": "^2.17.2",
58
58
  "eslint": "^10.2.0",
59
59
  "globals": "^17.5.0",
60
- "jest": "^29.7.0",
60
+ "jest": "^30.3.0",
61
61
  "sqlite-vec": "^0.1.9",
62
62
  "ts-jest": "^29.4.9",
63
63
  "typescript": "^6.0.2"
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.5.6",
4
+ "version": "0.5.8",
5
5
  "skills": [
6
6
  {
7
7
  "name": "mindlore-ingest",
@@ -4,11 +4,10 @@ Record and list decisions in the `.mindlore/decisions/` directory.
4
4
 
5
5
  ## Script Resolution
6
6
 
7
- All script paths are relative to this skill's package root.
8
- Package root = 2 directories up from this skill's base directory.
7
+ Resolve `MINDLORE_PKG` (package root) using one of these methods, in order:
8
+ 1. If CC injected "Base directory for this skill: /path/to/skills/mindlore-decide" → `MINDLORE_PKG = {base_directory}/../..`
9
+ 2. Fallback: run `node -e "console.log(require('path').join(require('child_process').execSync('npm root -g',{encoding:'utf8'}).trim(),'mindlore')))"`
9
10
 
10
- When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-decide".
11
- Compute: `MINDLORE_PKG = {base_directory}/../..`
12
11
  Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
13
12
 
14
13
  ## Scope
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  name: mindlore-diary
3
3
  description: LLM-powered session analysis — decisions, discoveries, frictions, learnings. Promotes episodes to semantic knowledge.
4
+ context: fork
4
5
  ---
5
6
 
6
7
  ## Script Resolution
7
8
 
8
- All script paths are relative to this skill's package root.
9
- Package root = 2 directories up from this skill's base directory.
9
+ Resolve `MINDLORE_PKG` (package root) using one of these methods, in order:
10
+ 1. If CC injected "Base directory for this skill: /path/to/skills/mindlore-diary" → `MINDLORE_PKG = {base_directory}/../..`
11
+ 2. Fallback: run `node -e "console.log(require('path').join(require('child_process').execSync('npm root -g',{encoding:'utf8'}).trim(),'mindlore')))"`
10
12
 
11
- When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-diary".
12
- Compute: `MINDLORE_PKG = {base_directory}/../..`
13
13
  Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
14
14
 
15
15
  # /mindlore-diary
@@ -2,16 +2,16 @@
2
2
  name: mindlore-evolve
3
3
  description: Knowledge schema co-evolution — scan domains+sources, detect inconsistencies, suggest updates
4
4
  effort: medium
5
+ context: fork
5
6
  allowed-tools: [Read, Write, Edit, Bash, Grep, Glob, Agent]
6
7
  ---
7
8
 
8
9
  ## Script Resolution
9
10
 
10
- All script paths are relative to this skill's package root.
11
- Package root = 2 directories up from this skill's base directory.
11
+ Resolve `MINDLORE_PKG` (package root) using one of these methods, in order:
12
+ 1. If CC injected "Base directory for this skill: /path/to/skills/mindlore-evolve" → `MINDLORE_PKG = {base_directory}/../..`
13
+ 2. Fallback: run `node -e "console.log(require('path').join(require('child_process').execSync('npm root -g',{encoding:'utf8'}).trim(),'mindlore')))"`
12
14
 
13
- When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-evolve".
14
- Compute: `MINDLORE_PKG = {base_directory}/../..`
15
15
  Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
16
16
 
17
17
  # /mindlore-evolve
@@ -2,6 +2,7 @@
2
2
  name: mindlore-explore
3
3
  description: Discover unexpected connections between sources — undirected knowledge exploration
4
4
  effort: medium
5
+ context: fork
5
6
  allowed-tools: [Read, Write, Edit, Bash, Grep, Glob, Agent]
6
7
  ---
7
8
 
@@ -8,11 +8,9 @@ allowed-tools: [Bash, Read]
8
8
 
9
9
  ## Script Resolution
10
10
 
11
- All script paths are relative to this skill's package root.
12
- Package root = 2 directories up from this skill's base directory.
13
-
14
- When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-health".
15
- Compute: `MINDLORE_PKG = {base_directory}/../..`
11
+ Resolve `MINDLORE_PKG` (package root) using one of these methods, in order:
12
+ 1. If CC injected "Base directory for this skill: /path/to/skills/mindlore-health" → `MINDLORE_PKG = {base_directory}/../..`
13
+ 2. Fallback: run `node -e "console.log(require('path').join(require('child_process').execSync('npm root -g',{encoding:'utf8'}).trim(),'mindlore')))"`
16
14
  Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
17
15
 
18
16
  # /mindlore-health
@@ -9,11 +9,10 @@ agent: coder
9
9
 
10
10
  ## Script Resolution
11
11
 
12
- All script paths are relative to this skill's package root.
13
- Package root = 2 directories up from this skill's base directory.
12
+ Resolve `MINDLORE_PKG` (package root) using one of these methods, in order:
13
+ 1. If CC injected "Base directory for this skill: /path/to/skills/mindlore-ingest" → `MINDLORE_PKG = {base_directory}/../..`
14
+ 2. Fallback: run `node -e "console.log(require('path').join(require('child_process').execSync('npm root -g',{encoding:'utf8'}).trim(),'mindlore')))"`
14
15
 
15
- When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-ingest".
16
- Compute: `MINDLORE_PKG = {base_directory}/../..`
17
16
  Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
18
17
 
19
18
  # /mindlore-ingest
@@ -4,11 +4,10 @@ Session logging, pattern extraction, and wiki updates.
4
4
 
5
5
  ## Script Resolution
6
6
 
7
- All script paths are relative to this skill's package root.
8
- Package root = 2 directories up from this skill's base directory.
7
+ Resolve `MINDLORE_PKG` (package root) using one of these methods, in order:
8
+ 1. If CC injected "Base directory for this skill: /path/to/skills/mindlore-log" → `MINDLORE_PKG = {base_directory}/../..`
9
+ 2. Fallback: run `node -e "console.log(require('path').join(require('child_process').execSync('npm root -g',{encoding:'utf8'}).trim(),'mindlore')))"`
9
10
 
10
- When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-log".
11
- Compute: `MINDLORE_PKG = {base_directory}/../..`
12
11
  Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
13
12
 
14
13
  ## Scope
@@ -2,16 +2,16 @@
2
2
  name: mindlore-maintain
3
3
  description: KB maintenance — decay/archive, episode consolidation, contradiction detection
4
4
  effort: medium
5
+ context: fork
5
6
  allowed-tools: [Read, Write, Edit, Bash, Grep, Glob]
6
7
  ---
7
8
 
8
9
  ## Script Resolution
9
10
 
10
- All script paths are relative to this skill's package root.
11
- Package root = 2 directories up from this skill's base directory.
11
+ Resolve `MINDLORE_PKG` (package root) using one of these methods, in order:
12
+ 1. If CC injected "Base directory for this skill: /path/to/skills/mindlore-maintain" → `MINDLORE_PKG = {base_directory}/../..`
13
+ 2. Fallback: run `node -e "console.log(require('path').join(require('child_process').execSync('npm root -g',{encoding:'utf8'}).trim(),'mindlore')))"`
12
14
 
13
- When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-maintain".
14
- Compute: `MINDLORE_PKG = {base_directory}/../..`
15
15
  Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
16
16
 
17
17
  # /mindlore-maintain
@@ -36,7 +36,12 @@ KB bakım skill'i. Reflect düşünür, maintain temizler.
36
36
  const path = require('path'), os = require('os');
37
37
  const dbPath = path.join(os.homedir(), '.mindlore', 'mindlore.db');
38
38
  const db = new Database(dbPath, {readonly: true});
39
- const stale = listStaleDocuments(db);
39
+ let decayConfig = {};
40
+ try {
41
+ const configPath = path.join(os.homedir(), '.mindlore', 'config.json');
42
+ decayConfig = JSON.parse(require('fs').readFileSync(configPath, 'utf8')).decay || {};
43
+ } catch (_err) { /* use defaults if config missing or malformed */ }
44
+ const stale = listStaleDocuments(db, undefined, decayConfig);
40
45
  console.log(JSON.stringify(stale, null, 2));
41
46
  db.close();
42
47
  " "$DECAY_MOD"
@@ -11,11 +11,10 @@ Search, ask, analyze, and retrieve knowledge from `.mindlore/`.
11
11
 
12
12
  ## Script Resolution
13
13
 
14
- All script paths are relative to this skill's package root.
15
- Package root = 2 directories up from this skill's base directory.
14
+ Resolve `MINDLORE_PKG` (package root) using one of these methods, in order:
15
+ 1. If CC injected "Base directory for this skill: /path/to/skills/mindlore-query" → `MINDLORE_PKG = {base_directory}/../..`
16
+ 2. Fallback: run `node -e "console.log(require('path').join(require('child_process').execSync('npm root -g',{encoding:'utf8'}).trim(),'mindlore')))"`
16
17
 
17
- When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-query".
18
- Compute: `MINDLORE_PKG = {base_directory}/../..`
19
18
  Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
20
19
 
21
20
  ## Scope
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  name: mindlore-reflect
3
3
  description: Pattern extraction from episodes — 3-tier confidence, nomination pipeline, CLAUDE.md update proposals.
4
+ context: fork
4
5
  ---
5
6
 
6
7
  ## Script Resolution
7
8
 
8
- All script paths are relative to this skill's package root.
9
- Package root = 2 directories up from this skill's base directory.
9
+ Resolve `MINDLORE_PKG` (package root) using one of these methods, in order:
10
+ 1. If CC injected "Base directory for this skill: /path/to/skills/mindlore-reflect" → `MINDLORE_PKG = {base_directory}/../..`
11
+ 2. Fallback: run `node -e "console.log(require('path').join(require('child_process').execSync('npm root -g',{encoding:'utf8'}).trim(),'mindlore')))"`
10
12
 
11
- When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-reflect".
12
- Compute: `MINDLORE_PKG = {base_directory}/../..`
13
13
  Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
14
14
 
15
15
  # /mindlore-reflect
@@ -6,6 +6,8 @@
6
6
 
7
7
  ### Concepts
8
8
 
9
+ ## Connections
10
+
9
11
  ## Recent
10
12
 
11
13
  ## Stats
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.6",
2
+ "version": "0.5.8",
3
3
  "models": {
4
4
  "ingest": "haiku",
5
5
  "evolve": "sonnet",