mindlore 0.5.2 → 0.5.4

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 (127) hide show
  1. package/README.md +6 -5
  2. package/dist/scripts/cc-memory-bulk-sync.d.ts +26 -0
  3. package/dist/scripts/cc-memory-bulk-sync.d.ts.map +1 -0
  4. package/dist/scripts/cc-memory-bulk-sync.js +177 -0
  5. package/dist/scripts/cc-memory-bulk-sync.js.map +1 -0
  6. package/dist/scripts/fetch-raw.js +14 -7
  7. package/dist/scripts/fetch-raw.js.map +1 -1
  8. package/dist/scripts/init.js +38 -1
  9. package/dist/scripts/init.js.map +1 -1
  10. package/dist/scripts/lib/backfill.d.ts +9 -0
  11. package/dist/scripts/lib/backfill.d.ts.map +1 -0
  12. package/dist/scripts/lib/backfill.js +74 -0
  13. package/dist/scripts/lib/backfill.js.map +1 -0
  14. package/dist/scripts/lib/consolidation.d.ts +17 -0
  15. package/dist/scripts/lib/consolidation.d.ts.map +1 -0
  16. package/dist/scripts/lib/consolidation.js +55 -0
  17. package/dist/scripts/lib/consolidation.js.map +1 -0
  18. package/dist/scripts/lib/constants.d.ts +4 -1
  19. package/dist/scripts/lib/constants.d.ts.map +1 -1
  20. package/dist/scripts/lib/constants.js +6 -1
  21. package/dist/scripts/lib/constants.js.map +1 -1
  22. package/dist/scripts/lib/contradiction.d.ts +7 -0
  23. package/dist/scripts/lib/contradiction.d.ts.map +1 -0
  24. package/dist/scripts/lib/contradiction.js +205 -0
  25. package/dist/scripts/lib/contradiction.js.map +1 -0
  26. package/dist/scripts/lib/db-helpers.d.ts.map +1 -1
  27. package/dist/scripts/lib/db-helpers.js +7 -1
  28. package/dist/scripts/lib/db-helpers.js.map +1 -1
  29. package/dist/scripts/lib/decay.d.ts +26 -0
  30. package/dist/scripts/lib/decay.d.ts.map +1 -0
  31. package/dist/scripts/lib/decay.js +73 -0
  32. package/dist/scripts/lib/decay.js.map +1 -0
  33. package/dist/scripts/lib/git-snapshot.d.ts +3 -0
  34. package/dist/scripts/lib/git-snapshot.d.ts.map +1 -0
  35. package/dist/scripts/lib/git-snapshot.js +38 -0
  36. package/dist/scripts/lib/git-snapshot.js.map +1 -0
  37. package/dist/scripts/lib/migrations-v053.d.ts +3 -0
  38. package/dist/scripts/lib/migrations-v053.d.ts.map +1 -0
  39. package/dist/scripts/lib/migrations-v053.js +52 -0
  40. package/dist/scripts/lib/migrations-v053.js.map +1 -0
  41. package/dist/scripts/lib/session-payload.d.ts +19 -0
  42. package/dist/scripts/lib/session-payload.d.ts.map +1 -0
  43. package/dist/scripts/lib/session-payload.js +85 -0
  44. package/dist/scripts/lib/session-payload.js.map +1 -0
  45. package/dist/scripts/mindlore-backup.d.ts +1 -1
  46. package/dist/scripts/mindlore-backup.d.ts.map +1 -1
  47. package/dist/scripts/mindlore-backup.js +23 -0
  48. package/dist/scripts/mindlore-backup.js.map +1 -1
  49. package/dist/scripts/mindlore-fts5-index.js +20 -7
  50. package/dist/scripts/mindlore-fts5-index.js.map +1 -1
  51. package/dist/scripts/mindlore-health-check.d.ts.map +1 -1
  52. package/dist/scripts/mindlore-health-check.js +47 -1
  53. package/dist/scripts/mindlore-health-check.js.map +1 -1
  54. package/dist/tests/backfill.test.d.ts +2 -0
  55. package/dist/tests/backfill.test.d.ts.map +1 -0
  56. package/dist/tests/backfill.test.js +127 -0
  57. package/dist/tests/backfill.test.js.map +1 -0
  58. package/dist/tests/cc-memory-bulk-sync.test.d.ts +2 -0
  59. package/dist/tests/cc-memory-bulk-sync.test.d.ts.map +1 -0
  60. package/dist/tests/cc-memory-bulk-sync.test.js +116 -0
  61. package/dist/tests/cc-memory-bulk-sync.test.js.map +1 -0
  62. package/dist/tests/consolidation.test.d.ts +2 -0
  63. package/dist/tests/consolidation.test.d.ts.map +1 -0
  64. package/dist/tests/consolidation.test.js +77 -0
  65. package/dist/tests/consolidation.test.js.map +1 -0
  66. package/dist/tests/contradiction-extended.test.d.ts +2 -0
  67. package/dist/tests/contradiction-extended.test.d.ts.map +1 -0
  68. package/dist/tests/contradiction-extended.test.js +182 -0
  69. package/dist/tests/contradiction-extended.test.js.map +1 -0
  70. package/dist/tests/decay.test.d.ts +2 -0
  71. package/dist/tests/decay.test.d.ts.map +1 -0
  72. package/dist/tests/decay.test.js +143 -0
  73. package/dist/tests/decay.test.js.map +1 -0
  74. package/dist/tests/fts5.test.js +181 -0
  75. package/dist/tests/fts5.test.js.map +1 -1
  76. package/dist/tests/git-snapshot.test.d.ts +2 -0
  77. package/dist/tests/git-snapshot.test.d.ts.map +1 -0
  78. package/dist/tests/git-snapshot.test.js +79 -0
  79. package/dist/tests/git-snapshot.test.js.map +1 -0
  80. package/dist/tests/helpers/db.d.ts.map +1 -1
  81. package/dist/tests/helpers/db.js +3 -1
  82. package/dist/tests/helpers/db.js.map +1 -1
  83. package/dist/tests/init.test.js +36 -3
  84. package/dist/tests/init.test.js.map +1 -1
  85. package/dist/tests/migrations-v053.test.d.ts +2 -0
  86. package/dist/tests/migrations-v053.test.d.ts.map +1 -0
  87. package/dist/tests/migrations-v053.test.js +113 -0
  88. package/dist/tests/migrations-v053.test.js.map +1 -0
  89. package/dist/tests/recall-telemetry.test.d.ts +2 -0
  90. package/dist/tests/recall-telemetry.test.d.ts.map +1 -0
  91. package/dist/tests/recall-telemetry.test.js +56 -0
  92. package/dist/tests/recall-telemetry.test.js.map +1 -0
  93. package/dist/tests/research-guard-scope.test.d.ts +2 -0
  94. package/dist/tests/research-guard-scope.test.d.ts.map +1 -0
  95. package/dist/tests/research-guard-scope.test.js +154 -0
  96. package/dist/tests/research-guard-scope.test.js.map +1 -0
  97. package/dist/tests/research-guard.test.js +60 -0
  98. package/dist/tests/research-guard.test.js.map +1 -1
  99. package/dist/tests/search-hook.test.js +37 -0
  100. package/dist/tests/search-hook.test.js.map +1 -1
  101. package/dist/tests/session-focus.test.js +86 -0
  102. package/dist/tests/session-focus.test.js.map +1 -1
  103. package/dist/tests/session-payload.test.d.ts +5 -0
  104. package/dist/tests/session-payload.test.d.ts.map +1 -0
  105. package/dist/tests/session-payload.test.js +135 -0
  106. package/dist/tests/session-payload.test.js.map +1 -0
  107. package/dist/tests/skill-path-resolution.test.d.ts +2 -0
  108. package/dist/tests/skill-path-resolution.test.d.ts.map +1 -0
  109. package/dist/tests/skill-path-resolution.test.js +42 -0
  110. package/dist/tests/skill-path-resolution.test.js.map +1 -0
  111. package/hooks/lib/mindlore-common.cjs +42 -8
  112. package/hooks/mindlore-research-guard.cjs +25 -2
  113. package/hooks/mindlore-search.cjs +23 -10
  114. package/hooks/mindlore-session-end.cjs +35 -0
  115. package/hooks/mindlore-session-focus.cjs +35 -34
  116. package/package.json +3 -2
  117. package/plugin.json +6 -1
  118. package/skills/mindlore-decide/SKILL.md +9 -0
  119. package/skills/mindlore-diary/SKILL.md +12 -3
  120. package/skills/mindlore-evolve/SKILL.md +24 -1
  121. package/skills/mindlore-health/SKILL.md +10 -1
  122. package/skills/mindlore-ingest/SKILL.md +26 -6
  123. package/skills/mindlore-log/SKILL.md +9 -0
  124. package/skills/mindlore-maintain/SKILL.md +119 -0
  125. package/skills/mindlore-query/SKILL.md +9 -0
  126. package/skills/mindlore-reflect/SKILL.md +31 -4
  127. package/templates/config.json +18 -9
@@ -10,7 +10,7 @@
10
10
 
11
11
  const fs = require('fs');
12
12
  const path = require('path');
13
- const { findMindloreDir, readConfig, openDatabase, hasEpisodesTable, queryRecentEpisodes, querySupersededChains, formatSupersededChains, queryMultiSessionEpisodes, formatMultiSessionEpisodes, getAllMdFiles, getRecentHookErrors, hookLog } = require('./lib/mindlore-common.cjs');
13
+ const { findMindloreDir, readConfig, openDatabase, hasEpisodesTable, querySupersededChains, formatSupersededChains, getAllMdFiles, hookLog, getProjectName, parseFrontmatter } = require('./lib/mindlore-common.cjs');
14
14
 
15
15
  function main() {
16
16
  const baseDir = findMindloreDir();
@@ -32,13 +32,17 @@ function main() {
32
32
  try {
33
33
  const diaryFiles = fs.readdirSync(diaryDir).filter(f => f.startsWith('delta-') && f.endsWith('.md'));
34
34
 
35
- // Latest delta
36
35
  if (diaryFiles.length > 0) {
37
36
  const sorted = [...diaryFiles].sort();
38
37
  const latestName = sorted[sorted.length - 1];
39
38
  const latestPath = path.join(diaryDir, latestName);
40
39
  const deltaContent = fs.readFileSync(latestPath, 'utf8').trim();
41
- output.push(`[Mindlore Delta: ${latestName}]\n${deltaContent}`);
40
+ const { meta } = parseFrontmatter(deltaContent);
41
+ const deltaProject = meta.project || null;
42
+ const currentProject = getProjectName();
43
+ if (!deltaProject || deltaProject.toLowerCase() === currentProject.toLowerCase()) {
44
+ output.push(`[Mindlore Delta: ${latestName}]\n${deltaContent}`);
45
+ }
42
46
  }
43
47
 
44
48
  // Reflect trigger
@@ -63,41 +67,47 @@ function main() {
63
67
  }
64
68
  } catch (_err) { /* skip */ }
65
69
 
66
- // v0.4.0: Inject recent episodes
70
+ // v0.5.4: Consolidated session payload (replaces scattered episodes/activity/alerts injection)
67
71
  try {
68
72
  const dbPath = path.join(baseDir, 'mindlore.db');
69
73
  const db = openDatabase(dbPath, { readonly: true });
70
74
  if (db) {
71
75
  try {
72
- if (hasEpisodesTable(db)) {
73
- const maxEpisodes = config?.session_focus?.max_episodes ?? 3;
76
+ // Session payload: Session summary, Decisions, Friction, Learnings
77
+ try {
78
+ const { buildSessionPayload } = require('../dist/scripts/lib/session-payload.js');
74
79
  const project = path.basename(process.cwd());
75
- const episodes = queryRecentEpisodes(db, { project, limit: maxEpisodes });
76
-
77
- if (episodes.length > 0) {
78
- const lines = episodes.map(ep => {
79
- const date = (ep.created_at || '').slice(0, 10);
80
- const summary = String(ep.summary || '').slice(0, 100);
81
- return `- [${date}] ${ep.kind}: ${summary}`;
82
- });
83
- output.push(`[Mindlore Episodes]\n${lines.join('\n')}`);
84
- }
85
-
86
- // v0.4.1: Enriched multi-session episodes
87
- const multiDays = config?.session_focus?.multi_session_days ?? 3;
88
- const enriched = queryMultiSessionEpisodes(db, { project, days: multiDays, limit: 20 });
89
- if (enriched.length > 0) {
90
- const formatted = formatMultiSessionEpisodes(enriched);
91
- if (formatted) {
92
- output.push(`[Mindlore Recent Activity]\n${formatted}`);
80
+ const payloadBudget = config?.tokenBudget?.sessionInject ?? 2000;
81
+ const payload = buildSessionPayload(db, baseDir, project, payloadBudget);
82
+ if (!payload.skipInjection) {
83
+ for (const section of payload.sections) {
84
+ output.push(`[Mindlore ${section.label}]\n${section.content}`);
93
85
  }
94
86
  }
87
+ } catch (_payloadErr) {
88
+ // Session payload is optional — don't break session start
89
+ }
90
+
91
+ // v0.4.1: Supersedes chain display (kept — not covered by session-payload)
92
+ if (hasEpisodesTable(db)) {
93
+ const project = path.basename(process.cwd());
95
94
 
96
- // v0.4.1: Supersedes chain display
97
95
  const chains = querySupersededChains(db, { project, days: 7, limit: 5 });
98
96
  if (chains.length > 0) {
99
97
  output.push(`[Mindlore Supersedes]\n${formatSupersededChains(chains)}`);
100
98
  }
99
+
100
+ // v0.5.3: Episode consolidation reminder (kept — threshold-based reminder)
101
+ try {
102
+ const rawCount = db.prepare(
103
+ "SELECT COUNT(*) as cnt FROM episodes WHERE consolidation_status = 'raw' OR consolidation_status IS NULL"
104
+ ).get();
105
+ const cnt = rawCount?.cnt ?? 0;
106
+ const consolThreshold = config?.consolidation?.threshold ?? 50;
107
+ if (cnt >= consolThreshold) {
108
+ output.push(`[Mindlore] ${cnt} raw episode birikti — \`/mindlore-maintain consolidate\` ile birleştirmeyi düşün.`);
109
+ }
110
+ } catch (_err) { /* consolidation_status column may not exist yet */ }
101
111
  }
102
112
  } finally {
103
113
  db.close();
@@ -117,15 +127,6 @@ function main() {
117
127
  }
118
128
  } catch (_healthErr) { /* skip */ }
119
129
 
120
- // Check for recent hook errors — inject warnings into CC context
121
- try {
122
- const errors = getRecentHookErrors();
123
- if (errors.length > 0) {
124
- const lines = errors.map(e => `- [${e.ts.slice(0, 19)}] **${e.hook}** (${e.level}): ${e.msg}`);
125
- output.push(`[Mindlore Hook Alerts]\n${lines.join('\n')}`);
126
- }
127
- } catch (_hookLogErr) { /* skip */ }
128
-
129
130
  hookLog('session-focus', 'info', 'session started');
130
131
 
131
132
  // Token budget for session inject
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindlore",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "AI-native knowledge system for Claude Code",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -18,7 +18,8 @@
18
18
  "index": "node dist/scripts/mindlore-fts5-index.js",
19
19
  "search": "node dist/scripts/mindlore-fts5-search.js",
20
20
  "quality": "node dist/scripts/quality-populate.js",
21
- "fetch-raw": "node dist/scripts/fetch-raw.js"
21
+ "fetch-raw": "node dist/scripts/fetch-raw.js",
22
+ "cc-sync": "node dist/scripts/cc-memory-bulk-sync.js"
22
23
  },
23
24
  "keywords": [
24
25
  "claude-code",
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.2",
4
+ "version": "0.5.4",
5
5
  "skills": [
6
6
  {
7
7
  "name": "mindlore-ingest",
@@ -47,6 +47,11 @@
47
47
  "name": "mindlore-explore",
48
48
  "path": "skills/mindlore-explore/SKILL.md",
49
49
  "description": "Discover unexpected connections between knowledge sources — undirected exploration mode. Cross-references domains, sources, analyses, and episodes to find non-obvious relationships. Identifies: shared entities across sources, pattern convergence between domains, episodic evidence supporting or contradicting domain claims. Default scope: project + global (--scope project|global|all)."
50
+ },
51
+ {
52
+ "name": "mindlore-maintain",
53
+ "path": "skills/mindlore-maintain/SKILL.md",
54
+ "description": "KB maintenance — decay/archive stale documents, consolidate 50+ episodes into learnings/insights, detect contradictions. Modes: decay (stale doc archive with git snapshot), consolidate (episode→file promotion), contradictions (wiki-lint + semantic), restore (undo archive). Run without flags for full report."
50
55
  }
51
56
  ],
52
57
  "agents": [
@@ -2,6 +2,15 @@
2
2
 
3
3
  Record and list decisions in the `.mindlore/decisions/` directory.
4
4
 
5
+ ## Script Resolution
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.
9
+
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
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
13
+
5
14
  ## Scope
6
15
 
7
16
  Determine target using `getActiveMindloreDir()` logic:
@@ -3,6 +3,15 @@ name: mindlore-diary
3
3
  description: LLM-powered session analysis — decisions, discoveries, frictions, learnings. Promotes episodes to semantic knowledge.
4
4
  ---
5
5
 
6
+ ## Script Resolution
7
+
8
+ All script paths are relative to this skill's package root.
9
+ Package root = 2 directories up from this skill's base directory.
10
+
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
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
14
+
6
15
  # /mindlore-diary
7
16
 
8
17
  ## Scope
@@ -18,7 +27,7 @@ Determine target using `getActiveMindloreDir()` logic:
18
27
  ## On Start — Read skill_memory
19
28
 
20
29
  ```bash
21
- node dist/scripts/lib/skill-memory.js get mindlore-diary last_diary_date
30
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" get mindlore-diary last_diary_date
22
31
  ```
23
32
  If last_diary_date is today, warn: "Diary already ran today. Continue anyway?"
24
33
 
@@ -64,8 +73,8 @@ If last_diary_date is today, warn: "Diary already ran today. Continue anyway?"
64
73
  ## On End — Write skill_memory
65
74
 
66
75
  ```bash
67
- node dist/scripts/lib/skill-memory.js set mindlore-diary last_diary_date "$(date -I)"
68
- node dist/scripts/lib/skill-memory.js set mindlore-diary last_episode_count "{N}"
76
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" set mindlore-diary last_diary_date "$(date -I)"
77
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" set mindlore-diary last_episode_count "{N}"
69
78
  ```
70
79
 
71
80
  ## Rules
@@ -5,6 +5,15 @@ effort: medium
5
5
  allowed-tools: [Read, Write, Edit, Bash, Grep, Glob, Agent]
6
6
  ---
7
7
 
8
+ ## Script Resolution
9
+
10
+ All script paths are relative to this skill's package root.
11
+ Package root = 2 directories up from this skill's base directory.
12
+
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
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
16
+
8
17
  # /mindlore-evolve
9
18
 
10
19
  Knowledge schema co-evolution. Karpathy's 4th operation (ingest/query/health/**evolve**).
@@ -30,6 +39,20 @@ User says `/mindlore-evolve`, "knowledge evolve", "bilgi sistemi evrimle", "sema
30
39
 
31
40
  Scan all domains and sources for inconsistencies.
32
41
 
42
+ **Pre-check (before scan):**
43
+
44
+ Before spawning the agent, check KB maturity:
45
+ ```bash
46
+ # Count domains and sources
47
+ DOMAIN_COUNT=$(ls ~/.mindlore/domains/ 2>/dev/null | grep -c '.md$' || echo 0)
48
+ SOURCE_COUNT=$(ls ~/.mindlore/sources/ 2>/dev/null | grep -c '.md$' || echo 0)
49
+ ```
50
+
51
+ If `DOMAIN_COUNT == 0`:
52
+ - Show: "Fresh KB detected (0 domains, N sources). Evolve works best with at least 1 domain. Run `/mindlore-ingest` to add sources, then manually create domain files to organize them."
53
+ - If `SOURCE_COUNT < 3`: Show "Too few sources for meaningful evolution scan. Add more knowledge first." and STOP.
54
+ - If `SOURCE_COUNT >= 3` but 0 domains: Show warning but continue scan — findings will be limited to orphan/tag checks.
55
+
33
56
  **Agent Delegation:** Tarama işini subagent'a delege et (context koruma).
34
57
 
35
58
  **Flow:**
@@ -84,7 +107,7 @@ Apply suggested changes with user approval.
84
107
  **Rules:**
85
108
  - NEVER make automatic changes — always require user approval
86
109
  - Show diff preview before applying
87
- - After changes, run `node dist/scripts/mindlore-fts5-index.js` for FTS5 sync
110
+ - After changes, run `node "$MINDLORE_PKG/dist/scripts/mindlore-fts5-index.js"` for FTS5 sync
88
111
  - Log every change to log.md with timestamp
89
112
  - The `[mindlore:evolve]` marker in the Agent prompt is required — it triggers the model-router hook to use the cost-optimized model (sonnet by default)
90
113
 
@@ -5,6 +5,15 @@ effort: low
5
5
  allowed-tools: [Bash, Read]
6
6
  ---
7
7
 
8
+ ## Script Resolution
9
+
10
+ All script paths are relative to this skill's package root.
11
+ Package root = 2 directories up from this skill's base directory.
12
+
13
+ When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-health".
14
+ Compute: `MINDLORE_PKG = {base_directory}/../..`
15
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
16
+
8
17
  # /mindlore-health
9
18
 
10
19
  Run the 16-point structural health check on the `.mindlore/` knowledge base.
@@ -25,7 +34,7 @@ User says "health check", "mindlore health", "bilgi sistemi kontrol", "saglik ko
25
34
 
26
35
  1. Run the health check script:
27
36
  ```bash
28
- node scripts/mindlore-health-check.cjs
37
+ node "$MINDLORE_PKG/dist/scripts/mindlore-health-check.js"
29
38
  ```
30
39
 
31
40
  2. Read the output and provide LLM interpretation:
@@ -7,6 +7,15 @@ context: fork
7
7
  agent: coder
8
8
  ---
9
9
 
10
+ ## Script Resolution
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.
14
+
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
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
18
+
10
19
  # /mindlore-ingest
11
20
 
12
21
  Add a new knowledge source to the `.mindlore/` knowledge base.
@@ -31,7 +40,7 @@ User shares a URL, text, file, or says "kaynak ekle", "source ingest", "bu linki
31
40
 
32
41
  **Pre-check (before fetch):**
33
42
  ```bash
34
- node dist/scripts/lib/skill-memory.js get mindlore-ingest last_ingest_urls
43
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" get mindlore-ingest last_ingest_urls
35
44
  ```
36
45
  If URL already in the list, warn user: "This URL was ingested recently. Re-ingest?"
37
46
 
@@ -39,7 +48,7 @@ If URL already in the list, warn user: "This URL was ingested recently. Re-inges
39
48
 
40
49
  1. **Fetch raw content (zero token):**
41
50
  ```bash
42
- node dist/scripts/fetch-raw.js "$URL" --out-dir "$MINDLORE_DIR/raw"
51
+ node "$MINDLORE_PKG/dist/scripts/fetch-raw.js" "$URL" --out-dir "$MINDLORE_DIR/raw"
43
52
  ```
44
53
  Script output: `{ "saved": "/path/to/raw/2026-04-18-abc123.md", "chars": 14823, "method": "curl" }`
45
54
 
@@ -52,13 +61,14 @@ If URL already in the list, warn user: "This URL was ingested recently. Re-inges
52
61
  3. **Write sources/ summary from truncated content:**
53
62
  - Extract: title, description (first paragraph), key topics
54
63
  - Generate frontmatter: slug, type: source, source_url, date_captured, tags, quality
64
+ - `source_type` is auto-detected from URL pattern (see Source Summary Format)
55
65
  - Write to `$MINDLORE_DIR/sources/{slug}.md`
56
66
 
57
67
  4. **Update INDEX.md** with new source entry
58
68
 
59
69
  5. **Update skill_memory:**
60
70
  ```bash
61
- node dist/scripts/lib/skill-memory.js set mindlore-ingest last_ingest_urls "$URL"
71
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" set mindlore-ingest last_ingest_urls "$URL"
62
72
  ```
63
73
 
64
74
  6. **Return to caller (this is all the ana session sees):**
@@ -95,6 +105,16 @@ The sources/ file should contain:
95
105
  - **Relevance to project** (why this matters)
96
106
  - **Related** links to other sources/domains in .mindlore/
97
107
 
108
+ Required frontmatter fields include `source_type` — auto-detected:
109
+ - `github-repo` if URL contains `github.com/{owner}/{repo}` (not a file/blob URL)
110
+ - `docs` if URL contains `/docs/`, `/documentation/`, or `/api/`
111
+ - `blog` if URL contains `/blog/`, `/post/`, or `/article/`
112
+ - `video` if URL contains `youtube.com`, `youtu.be`, or `vimeo.com`
113
+ - `url-fetch` as default fallback for all other URLs
114
+ - `text-paste` for Text Mode
115
+ - `pdf` for PDF Mode
116
+ - `file` for File Mode
117
+
98
118
  ## Quality Assessment
99
119
 
100
120
  Assign quality automatically during ingest using this heuristic:
@@ -125,7 +145,7 @@ After every ingest, verify all 7 checkpoints before reporting success:
125
145
 
126
146
  0. **Duplicate check** — Ingest öncesi mevcut DB'de benzer içerik ara:
127
147
  ```bash
128
- node dist/scripts/lib/similarity.js "<title or first 100 chars>"
148
+ node "$MINDLORE_PKG/dist/scripts/lib/similarity.js" "<title or first 100 chars>"
129
149
  ```
130
150
  Eğer score > 0.7 olan sonuç varsa KULLANICIYA SOR: "Bu içerik '${slug}' ile benzer görünüyor. Yine de eklensin mi?"
131
151
  Kullanıcı onaylarsa devam et, yoksa atla.
@@ -134,11 +154,11 @@ After every ingest, verify all 7 checkpoints before reporting success:
134
154
  3. **INDEX.md updated** — stats line incremented, Recent section has new entry
135
155
  4. **Domain updated** — if relevant domain exists, new finding added (max 1 domain per ingest)
136
156
  5. **log.md entry** — append `| {date} | ingest | {slug}.md |`
137
- 6. **FTS5 indexed** — FileChanged hook auto-triggers, but verify: `node scripts/mindlore-fts5-search.cjs "{keyword}"` returns the new file
157
+ 6. **FTS5 indexed** — FileChanged hook auto-triggers, but verify: `node "$MINDLORE_PKG/dist/scripts/mindlore-fts5-search.js" "{keyword}"` returns the new file
138
158
 
139
159
  If any checkpoint fails, fix it before reporting "ingest complete". Do NOT skip steps.
140
160
 
141
161
  Optional: run full health check for structural integrity:
142
162
  ```bash
143
- node scripts/mindlore-health-check.cjs
163
+ node "$MINDLORE_PKG/dist/scripts/mindlore-health-check.js"
144
164
  ```
@@ -2,6 +2,15 @@
2
2
 
3
3
  Session logging, pattern extraction, and wiki updates.
4
4
 
5
+ ## Script Resolution
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.
9
+
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
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
13
+
5
14
  ## Scope
6
15
 
7
16
  Determine target using `getActiveMindloreDir()` logic:
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: mindlore-maintain
3
+ description: KB maintenance — decay/archive, episode consolidation, contradiction detection
4
+ effort: medium
5
+ allowed-tools: [Read, Write, Edit, Bash, Grep, Glob]
6
+ ---
7
+
8
+ ## Script Resolution
9
+
10
+ All script paths are relative to this skill's package root.
11
+ Package root = 2 directories up from this skill's base directory.
12
+
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
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
16
+
17
+ # /mindlore-maintain
18
+
19
+ KB bakım skill'i. Reflect düşünür, maintain temizler.
20
+
21
+ ## Trigger
22
+
23
+ - `/mindlore-maintain` — full rapor (decay + consolidation + contradiction)
24
+ - `/mindlore-maintain decay` — stale doc listesi + archive flow
25
+ - `/mindlore-maintain consolidate` — episode gruplama + dosyaya promote
26
+ - `/mindlore-maintain contradictions` — çelişki analizi
27
+
28
+ ## Decay Mode
29
+
30
+ 1. Stale documents listele:
31
+ ```bash
32
+ DECAY_MOD="$MINDLORE_PKG/dist/scripts/lib/decay.js"
33
+ node -e "
34
+ const { listStaleDocuments } = require(process.argv[1]);
35
+ const Database = require('better-sqlite3');
36
+ const path = require('path'), os = require('os');
37
+ const dbPath = path.join(os.homedir(), '.mindlore', 'mindlore.db');
38
+ const db = new Database(dbPath, {readonly: true});
39
+ const stale = listStaleDocuments(db);
40
+ console.log(JSON.stringify(stale, null, 2));
41
+ db.close();
42
+ " "$DECAY_MOD"
43
+ ```
44
+
45
+ 2. Rapor sun:
46
+ ```
47
+ -- Decay Report --
48
+ | # | File | Score | Last Access | Recalls | Action |
49
+ |---|------|-------|-------------|---------|--------|
50
+ | 1 | sources/old-api.md | 0.12 | 2025-11-01 | 0 | Archive? |
51
+ ```
52
+
53
+ 3. Kullanıcı onaylarsa:
54
+ a. Git snapshot: `createPreEvictionTag`
55
+ b. Arşivle: `archiveDocument(db, path)`
56
+ c. Rapor: "Archived N docs. Git tag: pre-eviction-2026-04-18. Restore: `/mindlore-maintain restore <path>`"
57
+
58
+ **Kurallar:**
59
+ - Onay almadan ARŞİVLEME
60
+ - Arşiv öncesi HER ZAMAN git snapshot
61
+ - Score + last access + recall count göster
62
+
63
+ ## Consolidation Mode
64
+
65
+ 1. Raw episode sayısını kontrol et
66
+ 2. Gruplama önerisi sun:
67
+ ```
68
+ -- Consolidation Önerisi --
69
+ 3 learning episode → learnings/typescript-strict-patterns.md
70
+ 2 discovery episode → insights/sqlite-vec-windows-gotchas.md
71
+ ```
72
+
73
+ 3. Kind→dizin mapping (deterministik):
74
+ - learning → `learnings/`
75
+ - discovery → `insights/`
76
+ - friction → `analyses/`
77
+ - decision → `decisions/`
78
+ - preference → CC memory'de var mı kontrol et, varsa skip, yoksa `learnings/`
79
+
80
+ 4. Kullanıcı onaylarsa:
81
+ a. Hedef dosya yaz (frontmatter zorunlu: consolidated_from, consolidated_at, kind_source)
82
+ b. Episode'ları işaretle: `markConsolidated(db, ids, targetFile)`
83
+ c. Rapor: "N episode → M dosya promote edildi"
84
+
85
+ **Kurallar:**
86
+ - session/event episode'ları CONSOLİDATE EDİLMEZ
87
+ - Onay almadan dosya YAZMA
88
+ - `consolidated_from` frontmatter ZORUNLU (provenance)
89
+
90
+ ## Contradiction Mode
91
+
92
+ 1. Deterministic wiki-lint:
93
+ ```bash
94
+ node "$MINDLORE_PKG/dist/scripts/mindlore-health-check.js" ~/.mindlore 2>/dev/null | grep -A 5 'contradiction'
95
+ ```
96
+
97
+ 2. Semantic analiz (opsiyonel, token harcar)
98
+
99
+ **Kurallar:**
100
+ - Deterministic check HER ZAMAN çalışır
101
+ - Çelişkileri OTOMATİK düzeltme — kullanıcıya sor
102
+
103
+ ## Full Report Mode (flagsız)
104
+
105
+ ```
106
+ -- Maintain Report --
107
+ Decay: 3 stale document (score < 0.3)
108
+ Consolidation: 52 raw episode (learning: 15, discovery: 8, friction: 4)
109
+ Contradictions: 1 found
110
+
111
+ Aksiyon için:
112
+ /mindlore-maintain decay
113
+ /mindlore-maintain consolidate
114
+ /mindlore-maintain contradictions
115
+ ```
116
+
117
+ ## Restore Mode
118
+
119
+ `/mindlore-maintain restore <path>` — arşivlenmiş dokümanı geri yükler.
@@ -2,6 +2,15 @@
2
2
 
3
3
  Search, ask, analyze, and retrieve knowledge from `.mindlore/`.
4
4
 
5
+ ## Script Resolution
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.
9
+
10
+ When CC loads this skill, it shows "Base directory for this skill: /path/to/skills/mindlore-query".
11
+ Compute: `MINDLORE_PKG = {base_directory}/../..`
12
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
13
+
5
14
  ## Scope
6
15
 
7
16
  Determine search scope using `getActiveMindloreDir()` / `getAllDbs()` logic:
@@ -3,6 +3,15 @@ name: mindlore-reflect
3
3
  description: Pattern extraction from episodes — 3-tier confidence, nomination pipeline, CLAUDE.md update proposals.
4
4
  ---
5
5
 
6
+ ## Script Resolution
7
+
8
+ All script paths are relative to this skill's package root.
9
+ Package root = 2 directories up from this skill's base directory.
10
+
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
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
14
+
6
15
  # /mindlore-reflect
7
16
 
8
17
  ## Scope
@@ -16,8 +25,8 @@ Scans both project + global `~/.mindlore/` diary/ for patterns.
16
25
  ## On Start — Check pending nominations + skill_memory
17
26
 
18
27
  ```bash
19
- node dist/scripts/lib/skill-memory.js get mindlore-reflect last_reflect_date
20
- node dist/scripts/lib/skill-memory.js get mindlore-reflect nomination_count
28
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" get mindlore-reflect last_reflect_date
29
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" get mindlore-reflect nomination_count
21
30
  ```
22
31
 
23
32
  Check pending nominations:
@@ -91,8 +100,26 @@ Onaylamak istediklerini sec, veya 'skip':
91
100
  ## On End — Write skill_memory
92
101
 
93
102
  ```bash
94
- node dist/scripts/lib/skill-memory.js set mindlore-reflect last_reflect_date "$(date -I)"
95
- node dist/scripts/lib/skill-memory.js set mindlore-reflect nomination_count "{staged_count}"
103
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" set mindlore-reflect last_reflect_date "$(date -I)"
104
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" set mindlore-reflect nomination_count "{staged_count}"
105
+ ```
106
+
107
+ ## Quick Health Summary (v0.5.3)
108
+
109
+ After pattern extraction, run quick SQL checks (0 token, <1ms):
110
+ ```bash
111
+ node -e "
112
+ const db = require('better-sqlite3')(require('path').join(require('os').homedir(), '.mindlore', 'mindlore.db'), {readonly:true});
113
+ const stale = db.prepare(\"SELECT COUNT(*) as c FROM file_hashes WHERE recall_count = 0 AND archived_at IS NULL AND last_indexed < datetime('now','-60 days')\").get()?.c ?? 0;
114
+ const raw = db.prepare(\"SELECT COUNT(*) as c FROM episodes WHERE (consolidation_status = 'raw' OR consolidation_status IS NULL) AND kind IN ('learning','discovery','friction','decision')\").get()?.c ?? 0;
115
+ console.log(JSON.stringify({stale, raw}));
116
+ db.close();
117
+ "
118
+ ```
119
+
120
+ Rapor sonuna ekle:
121
+ ```
122
+ Stale: {stale} doc | Raw episodes: {raw} | → Detay: /mindlore-maintain
96
123
  ```
97
124
 
98
125
  ## Rules
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.2",
2
+ "version": "0.5.4",
3
3
  "models": {
4
4
  "ingest": "haiku",
5
5
  "evolve": "sonnet",
@@ -13,14 +13,7 @@
13
13
  "max_episodes": 3,
14
14
  "multi_session_days": 3
15
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
- },
16
+ "synonyms": {},
24
17
  "hybrid": {
25
18
  "enabled": true,
26
19
  "ftsWeight": 0.4,
@@ -31,5 +24,21 @@
31
24
  "sessionInject": 2000,
32
25
  "searchResults": 1500,
33
26
  "perResult": 500
27
+ },
28
+ "decay": {
29
+ "halfLifeDays": 30,
30
+ "staleThreshold": 0.3
31
+ },
32
+ "consolidation": {
33
+ "threshold": 50
34
+ },
35
+ "backup": {
36
+ "autoOnSessionEnd": false,
37
+ "remote": null
38
+ },
39
+ "reminders": {
40
+ "diaryReflectThreshold": 10,
41
+ "consolidationThreshold": 50,
42
+ "evolveIntervalDays": 30
34
43
  }
35
44
  }