mindlore 0.6.6 → 0.6.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 (184) 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 +47 -42
  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 +58 -48
  8. package/dist/scripts/cc-session-sync.js.map +1 -1
  9. package/dist/scripts/init.js +8 -8
  10. package/dist/scripts/init.js.map +1 -1
  11. package/dist/scripts/lib/all-migrations.d.ts.map +1 -1
  12. package/dist/scripts/lib/all-migrations.js +7 -1
  13. package/dist/scripts/lib/all-migrations.js.map +1 -1
  14. package/dist/scripts/lib/consolidation.d.ts +4 -3
  15. package/dist/scripts/lib/consolidation.d.ts.map +1 -1
  16. package/dist/scripts/lib/consolidation.js +10 -10
  17. package/dist/scripts/lib/consolidation.js.map +1 -1
  18. package/dist/scripts/lib/constants.d.ts +1 -7
  19. package/dist/scripts/lib/constants.d.ts.map +1 -1
  20. package/dist/scripts/lib/constants.js +2 -9
  21. package/dist/scripts/lib/constants.js.map +1 -1
  22. package/dist/scripts/lib/db-helpers.d.ts +0 -15
  23. package/dist/scripts/lib/db-helpers.d.ts.map +1 -1
  24. package/dist/scripts/lib/db-helpers.js +1 -51
  25. package/dist/scripts/lib/db-helpers.js.map +1 -1
  26. package/dist/scripts/lib/decay.d.ts.map +1 -1
  27. package/dist/scripts/lib/decay.js +9 -9
  28. package/dist/scripts/lib/decay.js.map +1 -1
  29. package/dist/scripts/lib/episodes.js +23 -23
  30. package/dist/scripts/lib/migrations-v061.js +21 -21
  31. package/dist/scripts/lib/migrations-v062.js +11 -11
  32. package/dist/scripts/lib/migrations-v063.js +14 -14
  33. package/dist/scripts/lib/migrations-v067.d.ts +7 -0
  34. package/dist/scripts/lib/migrations-v067.d.ts.map +1 -0
  35. package/dist/scripts/lib/migrations-v067.js +50 -0
  36. package/dist/scripts/lib/migrations-v067.js.map +1 -0
  37. package/dist/scripts/lib/migrations-v068.d.ts +3 -0
  38. package/dist/scripts/lib/migrations-v068.d.ts.map +1 -0
  39. package/dist/scripts/lib/migrations-v068.js +37 -0
  40. package/dist/scripts/lib/migrations-v068.js.map +1 -0
  41. package/dist/scripts/lib/migrations.d.ts.map +1 -1
  42. package/dist/scripts/lib/migrations.js +0 -15
  43. package/dist/scripts/lib/migrations.js.map +1 -1
  44. package/dist/scripts/lib/schema-version.js +6 -6
  45. package/dist/scripts/lib/search-cache.js +11 -11
  46. package/dist/scripts/lib/session-payload.d.ts +9 -1
  47. package/dist/scripts/lib/session-payload.d.ts.map +1 -1
  48. package/dist/scripts/lib/session-payload.js +11 -10
  49. package/dist/scripts/lib/session-payload.js.map +1 -1
  50. package/dist/scripts/lib/triage.js +3 -3
  51. package/dist/scripts/mindlore-backup.js +9 -9
  52. package/dist/scripts/mindlore-fts5-index.d.ts +1 -2
  53. package/dist/scripts/mindlore-fts5-index.d.ts.map +1 -1
  54. package/dist/scripts/mindlore-fts5-index.js +12 -64
  55. package/dist/scripts/mindlore-fts5-index.js.map +1 -1
  56. package/dist/scripts/mindlore-health-check.d.ts.map +1 -1
  57. package/dist/scripts/mindlore-health-check.js +0 -11
  58. package/dist/scripts/mindlore-health-check.js.map +1 -1
  59. package/dist/tests/cc-memory-bulk-sync.test.js +23 -0
  60. package/dist/tests/cc-memory-bulk-sync.test.js.map +1 -1
  61. package/dist/tests/cc-session-sync.test.js +25 -0
  62. package/dist/tests/cc-session-sync.test.js.map +1 -1
  63. package/dist/tests/compaction-snapshot.test.js +2 -2
  64. package/dist/tests/consolidation.test.js +5 -5
  65. package/dist/tests/consolidation.test.js.map +1 -1
  66. package/dist/tests/decay.test.js +9 -9
  67. package/dist/tests/diary.test.js +4 -4
  68. package/dist/tests/episode-kind-constant.test.d.ts +2 -0
  69. package/dist/tests/episode-kind-constant.test.d.ts.map +1 -0
  70. package/dist/tests/episode-kind-constant.test.js +28 -0
  71. package/dist/tests/episode-kind-constant.test.js.map +1 -0
  72. package/dist/tests/episodes-inject.test.js +14 -14
  73. package/dist/tests/episodes-inject.test.js.map +1 -1
  74. package/dist/tests/fts5.test.js +66 -125
  75. package/dist/tests/fts5.test.js.map +1 -1
  76. package/dist/tests/globalSetup.d.ts +2 -0
  77. package/dist/tests/globalSetup.d.ts.map +1 -0
  78. package/dist/tests/globalSetup.js +36 -0
  79. package/dist/tests/globalSetup.js.map +1 -0
  80. package/dist/tests/helpers/db.d.ts +13 -5
  81. package/dist/tests/helpers/db.d.ts.map +1 -1
  82. package/dist/tests/helpers/db.js +61 -33
  83. package/dist/tests/helpers/db.js.map +1 -1
  84. package/dist/tests/lesson-graduation.test.d.ts +2 -0
  85. package/dist/tests/lesson-graduation.test.d.ts.map +1 -0
  86. package/dist/tests/lesson-graduation.test.js +83 -0
  87. package/dist/tests/lesson-graduation.test.js.map +1 -0
  88. package/dist/tests/migrations-v053.test.js +16 -16
  89. package/dist/tests/migrations-v061.test.js +10 -10
  90. package/dist/tests/migrations-v063.test.js +2 -2
  91. package/dist/tests/migrations-v067.test.d.ts +2 -0
  92. package/dist/tests/migrations-v067.test.d.ts.map +1 -0
  93. package/dist/tests/migrations-v067.test.js +115 -0
  94. package/dist/tests/migrations-v067.test.js.map +1 -0
  95. package/dist/tests/migrations-v068.test.d.ts +2 -0
  96. package/dist/tests/migrations-v068.test.d.ts.map +1 -0
  97. package/dist/tests/migrations-v068.test.js +53 -0
  98. package/dist/tests/migrations-v068.test.js.map +1 -0
  99. package/dist/tests/nomination-counts.test.d.ts +2 -0
  100. package/dist/tests/nomination-counts.test.d.ts.map +1 -0
  101. package/dist/tests/nomination-counts.test.js +51 -0
  102. package/dist/tests/nomination-counts.test.js.map +1 -0
  103. package/dist/tests/recall-telemetry.test.js +8 -8
  104. package/dist/tests/schema-version.test.js +3 -7
  105. package/dist/tests/schema-version.test.js.map +1 -1
  106. package/dist/tests/search-hook.test.js +2 -2
  107. package/dist/tests/sec-regression.test.js +0 -50
  108. package/dist/tests/sec-regression.test.js.map +1 -1
  109. package/dist/tests/session-end-cleanup.test.d.ts +2 -0
  110. package/dist/tests/session-end-cleanup.test.d.ts.map +1 -0
  111. package/dist/tests/session-end-cleanup.test.js +59 -0
  112. package/dist/tests/session-end-cleanup.test.js.map +1 -0
  113. package/dist/tests/session-focus.test.js +69 -10
  114. package/dist/tests/session-focus.test.js.map +1 -1
  115. package/dist/tests/session-payload.test.js +11 -11
  116. package/dist/tests/session-payload.test.js.map +1 -1
  117. package/dist/tests/session-summary.test.js +2 -2
  118. package/dist/tests/session-summary.test.js.map +1 -1
  119. package/hooks/lib/constants.cjs +15 -0
  120. package/hooks/lib/mindlore-common.cjs +974 -1004
  121. package/hooks/mindlore-cwd-changed.cjs +57 -57
  122. package/hooks/mindlore-decision-detector.cjs +54 -54
  123. package/hooks/mindlore-dont-repeat.cjs +222 -222
  124. package/hooks/mindlore-fts5-sync.cjs +97 -88
  125. package/hooks/mindlore-index.cjs +229 -229
  126. package/hooks/mindlore-model-router.cjs +54 -54
  127. package/hooks/mindlore-post-compact.cjs +69 -69
  128. package/hooks/mindlore-post-read.cjs +106 -106
  129. package/hooks/mindlore-pre-compact.cjs +154 -154
  130. package/hooks/mindlore-read-guard.cjs +105 -105
  131. package/hooks/mindlore-research-guard.cjs +176 -176
  132. package/hooks/mindlore-search.cjs +200 -200
  133. package/hooks/mindlore-session-end.cjs +509 -523
  134. package/hooks/mindlore-session-focus.cjs +256 -245
  135. package/package.json +75 -78
  136. package/plugin.json +1 -1
  137. package/skills/mindlore-diary/SKILL.md +85 -85
  138. package/skills/mindlore-evolve/SKILL.md +126 -126
  139. package/skills/mindlore-explore/SKILL.md +109 -109
  140. package/skills/mindlore-ingest/SKILL.md +195 -195
  141. package/skills/mindlore-maintain/SKILL.md +125 -125
  142. package/skills/mindlore-query/SKILL.md +151 -151
  143. package/skills/mindlore-reflect/SKILL.md +141 -131
  144. package/skills/mindlore-stats/SKILL.md +106 -106
  145. package/templates/INDEX.md +14 -14
  146. package/templates/SCHEMA.md +292 -292
  147. package/templates/config.json +1 -1
  148. package/templates/extraction/article.md +15 -15
  149. package/templates/extraction/changelog.md +15 -15
  150. package/templates/extraction/default.md +15 -15
  151. package/templates/extraction/docs.md +15 -15
  152. package/templates/extraction/github-repo.md +17 -17
  153. package/dist/scripts/lib/daemon.d.ts +0 -16
  154. package/dist/scripts/lib/daemon.d.ts.map +0 -1
  155. package/dist/scripts/lib/daemon.js +0 -133
  156. package/dist/scripts/lib/daemon.js.map +0 -1
  157. package/dist/scripts/lib/embedding.d.ts +0 -5
  158. package/dist/scripts/lib/embedding.d.ts.map +0 -1
  159. package/dist/scripts/lib/embedding.js +0 -44
  160. package/dist/scripts/lib/embedding.js.map +0 -1
  161. package/dist/scripts/mindlore-daemon.d.ts +0 -2
  162. package/dist/scripts/mindlore-daemon.d.ts.map +0 -1
  163. package/dist/scripts/mindlore-daemon.js +0 -117
  164. package/dist/scripts/mindlore-daemon.js.map +0 -1
  165. package/dist/tests/daemon-integration.test.d.ts +0 -2
  166. package/dist/tests/daemon-integration.test.d.ts.map +0 -1
  167. package/dist/tests/daemon-integration.test.js +0 -37
  168. package/dist/tests/daemon-integration.test.js.map +0 -1
  169. package/dist/tests/daemon.test.d.ts +0 -2
  170. package/dist/tests/daemon.test.d.ts.map +0 -1
  171. package/dist/tests/daemon.test.js +0 -187
  172. package/dist/tests/daemon.test.js.map +0 -1
  173. package/dist/tests/embedding-hf-integration.test.d.ts +0 -2
  174. package/dist/tests/embedding-hf-integration.test.d.ts.map +0 -1
  175. package/dist/tests/embedding-hf-integration.test.js +0 -52
  176. package/dist/tests/embedding-hf-integration.test.js.map +0 -1
  177. package/dist/tests/embedding.test.d.ts +0 -6
  178. package/dist/tests/embedding.test.d.ts.map +0 -1
  179. package/dist/tests/embedding.test.js +0 -71
  180. package/dist/tests/embedding.test.js.map +0 -1
  181. package/dist/tests/sqlite-vec-v12.test.d.ts +0 -2
  182. package/dist/tests/sqlite-vec-v12.test.d.ts.map +0 -1
  183. package/dist/tests/sqlite-vec-v12.test.js +0 -72
  184. package/dist/tests/sqlite-vec-v12.test.js.map +0 -1
@@ -1,131 +1,141 @@
1
- ---
2
- name: mindlore-reflect
3
- description: Pattern extraction from episodes — 3-tier confidence, nomination pipeline, CLAUDE.md update proposals.
4
- context: fork
5
- ---
6
-
7
- ## Script Resolution
8
-
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')))"`
12
-
13
- Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
14
-
15
- # /mindlore-reflect
16
-
17
- ## Scope
18
-
19
- Scans both project + global `~/.mindlore/` diary/ for patterns.
20
-
21
- ## Trigger
22
-
23
- `/mindlore-reflect` or `/mindlore-log reflect`
24
-
25
- ## On Start — Check pending nominations + skill_memory
26
-
27
- ```bash
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
30
- ```
31
-
32
- Check pending nominations:
33
- ```sql
34
- SELECT id, summary, body, created_at FROM episodes
35
- WHERE kind = 'nomination' AND status = 'staged' AND project = ?
36
- ORDER BY created_at ASC
37
- ```
38
-
39
- If pending nominations exist, present them first:
40
- ```
41
- -- Bekleyen Nomination'lar ({N} adet) --
42
- 1. "{summary}" (staged {days} gun once)
43
- Target: learnings | Confidence: 3x
44
-
45
- Onaylamak istediklerini sec, veya 'skip':
46
- ```
47
-
48
- ## Flow
49
-
50
- 1. Read active episodes: `WHERE status = 'active' AND source IN ('hook', 'diary')`
51
- 2. Filter by time: `--days 7` (default), `--days 30`
52
- 3. Present summary: "Found N episodes spanning DATE1 to DATE2"
53
- 4. LLM analyzes episodes for recurring patterns:
54
- - Repeated decisions (same choice 2+ times)
55
- - Recurring frictions (same blocker/error)
56
- - Discovery patterns (assumptions that keep breaking)
57
- - Workflow patterns that worked well
58
-
59
- 5. **3-Tier Confidence Assessment:**
60
-
61
- | Tekrar | Tier | Aksiyon |
62
- |--------|------|---------|
63
- | 1x | Note | Sessiz — episode olarak kalir, raporda goster |
64
- | 2x | Learning | `kind: learning` episode olustur, learnings/ dosyasina yaz |
65
- | 3x+ | Nomination | `kind: nomination, status: staged, source: reflect` episode olustur |
66
-
67
- 6. **Structured report:**
68
- ```
69
- -- Reflect Raporu (son {days} gun, {N} episode) --
70
-
71
- Friction ({count}):
72
- - {summary} — {repeat_count}x tekrar
73
-
74
- Discoveries ({count}):
75
- - {summary}
76
-
77
- Patterns:
78
- - "{pattern}" -> 3x tekrar -> NOMINATION (staged)
79
- - "{pattern}" -> 2x tekrar -> LEARNING
80
- - "{pattern}" -> 1x -> NOTE
81
-
82
- Onerilen:
83
- [ ] {rule} ({repeat_count}x, {confidence} confidence)
84
- ```
85
-
86
- 7. **Nomination creation (3x+ tekrar):**
87
- ```sql
88
- INSERT INTO episodes (summary, body, kind, status, source, project, created_at)
89
- VALUES (?, ?, 'nomination', 'staged', 'reflect', ?, ?)
90
- ```
91
-
92
- 8. **Nomination approval flow:**
93
- User approves -> `status: staged -> approved` -> write to target:
94
- - `learnings` -> `learnings/{topic}.md`
95
- - `claude.md` -> project CLAUDE.md'ye kural ekle
96
- - `domain:{slug}` -> ilgili domain sayfasina ekle
97
-
98
- User rejects -> `status: staged -> rejected` + rejection reason
99
-
100
- ## On End Write skill_memory
101
-
102
- ```bash
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
123
- ```
124
-
125
- ## Rules
126
-
127
- - NEVER write learnings or nominations without user approval
128
- - Group related patterns into existing topic files
129
- - Reflect READS episodes, diary WRITES episodes — clear separation
130
- - Mark processed episodes so future reflect skips them
131
- - Append to `log.md`: `| {date} | reflect | {N} episodes processed, {M} learnings written |`
1
+ ---
2
+ name: mindlore-reflect
3
+ description: Pattern extraction from episodes — 3-tier confidence, nomination pipeline, CLAUDE.md update proposals.
4
+ context: fork
5
+ ---
6
+
7
+ ## Script Resolution
8
+
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')))"`
12
+
13
+ Use: `node "$MINDLORE_PKG/dist/scripts/..."` for all script commands.
14
+
15
+ # /mindlore-reflect
16
+
17
+ ## Scope
18
+
19
+ Scans both project + global `~/.mindlore/` diary/ for patterns.
20
+
21
+ ## Trigger
22
+
23
+ `/mindlore-reflect` or `/mindlore-log reflect`
24
+
25
+ ## On Start — Check pending nominations + skill_memory
26
+
27
+ ```bash
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
30
+ ```
31
+
32
+ Check pending nominations:
33
+ ```sql
34
+ SELECT id, summary, body, created_at FROM episodes
35
+ WHERE kind = 'nomination' AND status = 'staged' AND project = ?
36
+ ORDER BY created_at ASC
37
+ ```
38
+
39
+ If pending nominations exist, present them first:
40
+ ```
41
+ -- Bekleyen Nomination'lar ({N} adet) --
42
+ 1. "{summary}" (staged {days} gun once)
43
+ Target: learnings | Confidence: 3x
44
+
45
+ Onaylamak istediklerini sec, veya 'skip':
46
+ ```
47
+
48
+ ## Flow
49
+
50
+ 1. Read active episodes: `WHERE status = 'active' AND source IN ('hook', 'diary')`
51
+ 2. Filter by time: `--days 7` (default), `--days 30`
52
+ 3. Present summary: "Found N episodes spanning DATE1 to DATE2"
53
+ 4. LLM analyzes episodes for recurring patterns:
54
+ - Repeated decisions (same choice 2+ times)
55
+ - Recurring frictions (same blocker/error)
56
+ - Discovery patterns (assumptions that keep breaking)
57
+ - Workflow patterns that worked well
58
+
59
+ 5. **3-Tier Confidence Assessment:**
60
+
61
+ | Tekrar | Tier | Aksiyon |
62
+ |--------|------|---------|
63
+ | 1x | Note | Sessiz — episode olarak kalir, raporda goster |
64
+ | 2x | Learning | `kind: learning` episode olustur, learnings/ dosyasina yaz |
65
+ | 3x+ | Nomination | `kind: nomination, status: staged, source: reflect` episode olustur |
66
+
67
+ 6. **Structured report:**
68
+ ```
69
+ -- Reflect Raporu (son {days} gun, {N} episode) --
70
+
71
+ Friction ({count}):
72
+ - {summary} — {repeat_count}x tekrar
73
+
74
+ Discoveries ({count}):
75
+ - {summary}
76
+
77
+ Patterns:
78
+ - "{pattern}" -> 3x tekrar -> NOMINATION (staged)
79
+ - "{pattern}" -> 2x tekrar -> LEARNING
80
+ - "{pattern}" -> 1x -> NOTE
81
+
82
+ Onerilen:
83
+ [ ] {rule} ({repeat_count}x, {confidence} confidence)
84
+ ```
85
+
86
+ 7. **Nomination creation (3x+ tekrar):**
87
+ ```sql
88
+ INSERT INTO episodes (summary, body, kind, status, source, project, created_at)
89
+ VALUES (?, ?, 'nomination', 'staged', 'reflect', ?, ?)
90
+ ```
91
+
92
+ 8. **Nomination approval flow:**
93
+ User approves -> `status: staged -> approved` -> write to target:
94
+ - `learnings` -> `learnings/{topic}.md`
95
+ - `claude.md` -> project CLAUDE.md'ye kural ekle
96
+ - `domain:{slug}` -> ilgili domain sayfasina ekle
97
+
98
+ Approval SQL:
99
+ ```sql
100
+ UPDATE episodes SET status = 'approved', graduated_at = datetime('now') WHERE id = ?
101
+ ```
102
+
103
+ User rejects -> `status: staged -> rejected` + rejection reason
104
+
105
+ Rejection SQL:
106
+ ```sql
107
+ UPDATE episodes SET status = 'rejected', rejected_at = datetime('now'), rejection_reason = ? WHERE id = ?
108
+ ```
109
+
110
+ ## On End — Write skill_memory
111
+
112
+ ```bash
113
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" set mindlore-reflect last_reflect_date "$(date -I)"
114
+ node "$MINDLORE_PKG/dist/scripts/lib/skill-memory.js" set mindlore-reflect nomination_count "{staged_count}"
115
+ ```
116
+
117
+ ## Quick Health Summary (v0.5.3)
118
+
119
+ After pattern extraction, run quick SQL checks (0 token, <1ms):
120
+ ```bash
121
+ node -e "
122
+ const db = require('better-sqlite3')(require('path').join(require('os').homedir(), '.mindlore', 'mindlore.db'), {readonly:true});
123
+ 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;
124
+ 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;
125
+ console.log(JSON.stringify({stale, raw}));
126
+ db.close();
127
+ "
128
+ ```
129
+
130
+ Rapor sonuna ekle:
131
+ ```
132
+ Stale: {stale} doc | Raw episodes: {raw} | → Detay: /mindlore-maintain
133
+ ```
134
+
135
+ ## Rules
136
+
137
+ - NEVER write learnings or nominations without user approval
138
+ - Group related patterns into existing topic files
139
+ - Reflect READS episodes, diary WRITES episodes — clear separation
140
+ - Mark processed episodes so future reflect skips them
141
+ - Append to `log.md`: `| {date} | reflect | {N} episodes processed, {M} learnings written |`
@@ -1,106 +1,106 @@
1
- ---
2
- name: mindlore-stats
3
- description: Show context contribution and cost per session — hook calls, durations, DB stats.
4
- effort: low
5
- context: fork
6
- allowed-tools: [Bash, Read]
7
- ---
8
-
9
- ## Script Resolution
10
-
11
- Resolve `MINDLORE_DIR` (active knowledge base directory) using:
12
- 1. If project `.mindlore/` exists → use it
13
- 2. Else → use `~/.mindlore/`
14
-
15
- # /mindlore-stats
16
-
17
- Show context contribution and cost per session — hook calls, durations, DB stats.
18
-
19
- ## Trigger
20
-
21
- User says "mindlore stats", "stats", "context cost", "hook performance", "ne kadar yer kaplıyor".
22
-
23
- ## Execution
24
-
25
- ### 1. Telemetry Analysis
26
-
27
- Read `$MINDLORE_DIR/telemetry.jsonl` (each line is a JSON object):
28
-
29
- ```bash
30
- # Count lines and read last 500 for session estimate
31
- wc -l "$MINDLORE_DIR/telemetry.jsonl"
32
- tail -500 "$MINDLORE_DIR/telemetry.jsonl"
33
- ```
34
-
35
- Parse each line as JSON with fields: `hook` (string), `duration` (number, ms), `ts` (ISO timestamp), optionally `injectSize` (number, chars).
36
-
37
- Calculate:
38
- - **Total hook calls (all time)**: total line count
39
- - **Hook calls (session)**: lines where `ts` is within last 8 hours
40
- - **Avg duration per hook**: group by `hook`, compute mean `duration`
41
- - **Session inject avg**: from events where `hook === "mindlore-session-focus"`, average `injectSize` (chars ÷ 4 ≈ tokens)
42
- - **Search inject avg**: from events where `hook === "mindlore-search"`, average `injectSize` (chars ÷ 4 ≈ tokens)
43
-
44
- ### 2. DB Stats
45
-
46
- Query `$MINDLORE_DIR/mindlore.db`:
47
-
48
- ```bash
49
- # Indexed docs
50
- node -e "
51
- const DB = require('better-sqlite3');
52
- const db = new DB('$MINDLORE_DIR/mindlore.db', {readonly:true});
53
- const total = db.prepare('SELECT COUNT(*) as n FROM file_hashes').get().n;
54
- const stale = db.prepare(\"SELECT COUNT(*) as n FROM file_hashes WHERE last_indexed < datetime('now','-30 days')\").get().n;
55
- const epRows = db.prepare('SELECT kind, COUNT(*) as n FROM episodes GROUP BY kind').all();
56
- const sessions = db.prepare('SELECT COUNT(*) as n FROM mindlore_fts_sessions').get()?.n ?? 'N/A';
57
- console.log(JSON.stringify({total, stale, epRows, sessions}));
58
- db.close();
59
- "
60
- ```
61
-
62
- Get DB file size:
63
-
64
- ```bash
65
- node -e "const fs=require('fs'); const s=fs.statSync('$MINDLORE_DIR/mindlore.db'); console.log((s.size/1024/1024).toFixed(2)+' MB');"
66
- ```
67
-
68
- ### 3. Format Output
69
-
70
- Print a compact stats table:
71
-
72
- ```
73
- ## Mindlore Stats
74
-
75
- | Metric | Value |
76
- |--------|-------|
77
- | DB Size | X MB |
78
- | Indexed Docs | N |
79
- | Stale Docs (30d+) | N |
80
- | Episodes (active) | N |
81
- | Hook Calls (session) | N |
82
- | Hook Calls (all time) | N |
83
- | Avg Hook Duration | Xms |
84
- | Session Inject Avg | ~N tokens |
85
- | Search Inject Avg | ~N tokens |
86
- ```
87
-
88
- Then add a per-hook breakdown if hook calls > 0:
89
-
90
- ```
91
- ### Hook Breakdown (session)
92
-
93
- | Hook | Calls | Avg Duration |
94
- |------|-------|-------------|
95
- | mindlore-session-focus | N | Xms |
96
- | mindlore-search | N | Xms |
97
- | ... | | |
98
- ```
99
-
100
- ## Notes
101
-
102
- - If `telemetry.jsonl` does not exist: report "No telemetry data yet"
103
- - If `mindlore.db` does not exist: report "DB not found — run `npx mindlore init`"
104
- - If `episodes` table missing: skip episode count, show "—"
105
- - Inject size in tokens is approximate (chars ÷ 4)
106
- - "Session" = last 8 hours from current time
1
+ ---
2
+ name: mindlore-stats
3
+ description: Show context contribution and cost per session — hook calls, durations, DB stats.
4
+ effort: low
5
+ context: fork
6
+ allowed-tools: [Bash, Read]
7
+ ---
8
+
9
+ ## Script Resolution
10
+
11
+ Resolve `MINDLORE_DIR` (active knowledge base directory) using:
12
+ 1. If project `.mindlore/` exists → use it
13
+ 2. Else → use `~/.mindlore/`
14
+
15
+ # /mindlore-stats
16
+
17
+ Show context contribution and cost per session — hook calls, durations, DB stats.
18
+
19
+ ## Trigger
20
+
21
+ User says "mindlore stats", "stats", "context cost", "hook performance", "ne kadar yer kaplıyor".
22
+
23
+ ## Execution
24
+
25
+ ### 1. Telemetry Analysis
26
+
27
+ Read `$MINDLORE_DIR/telemetry.jsonl` (each line is a JSON object):
28
+
29
+ ```bash
30
+ # Count lines and read last 500 for session estimate
31
+ wc -l "$MINDLORE_DIR/telemetry.jsonl"
32
+ tail -500 "$MINDLORE_DIR/telemetry.jsonl"
33
+ ```
34
+
35
+ Parse each line as JSON with fields: `hook` (string), `duration` (number, ms), `ts` (ISO timestamp), optionally `injectSize` (number, chars).
36
+
37
+ Calculate:
38
+ - **Total hook calls (all time)**: total line count
39
+ - **Hook calls (session)**: lines where `ts` is within last 8 hours
40
+ - **Avg duration per hook**: group by `hook`, compute mean `duration`
41
+ - **Session inject avg**: from events where `hook === "mindlore-session-focus"`, average `injectSize` (chars ÷ 4 ≈ tokens)
42
+ - **Search inject avg**: from events where `hook === "mindlore-search"`, average `injectSize` (chars ÷ 4 ≈ tokens)
43
+
44
+ ### 2. DB Stats
45
+
46
+ Query `$MINDLORE_DIR/mindlore.db`:
47
+
48
+ ```bash
49
+ # Indexed docs
50
+ node -e "
51
+ const DB = require('better-sqlite3');
52
+ const db = new DB('$MINDLORE_DIR/mindlore.db', {readonly:true});
53
+ const total = db.prepare('SELECT COUNT(*) as n FROM file_hashes').get().n;
54
+ const stale = db.prepare(\"SELECT COUNT(*) as n FROM file_hashes WHERE last_indexed < datetime('now','-30 days')\").get().n;
55
+ const epRows = db.prepare('SELECT kind, COUNT(*) as n FROM episodes GROUP BY kind').all();
56
+ const sessions = db.prepare('SELECT COUNT(*) as n FROM mindlore_fts_sessions').get()?.n ?? 'N/A';
57
+ console.log(JSON.stringify({total, stale, epRows, sessions}));
58
+ db.close();
59
+ "
60
+ ```
61
+
62
+ Get DB file size:
63
+
64
+ ```bash
65
+ node -e "const fs=require('fs'); const s=fs.statSync('$MINDLORE_DIR/mindlore.db'); console.log((s.size/1024/1024).toFixed(2)+' MB');"
66
+ ```
67
+
68
+ ### 3. Format Output
69
+
70
+ Print a compact stats table:
71
+
72
+ ```
73
+ ## Mindlore Stats
74
+
75
+ | Metric | Value |
76
+ |--------|-------|
77
+ | DB Size | X MB |
78
+ | Indexed Docs | N |
79
+ | Stale Docs (30d+) | N |
80
+ | Episodes (active) | N |
81
+ | Hook Calls (session) | N |
82
+ | Hook Calls (all time) | N |
83
+ | Avg Hook Duration | Xms |
84
+ | Session Inject Avg | ~N tokens |
85
+ | Search Inject Avg | ~N tokens |
86
+ ```
87
+
88
+ Then add a per-hook breakdown if hook calls > 0:
89
+
90
+ ```
91
+ ### Hook Breakdown (session)
92
+
93
+ | Hook | Calls | Avg Duration |
94
+ |------|-------|-------------|
95
+ | mindlore-session-focus | N | Xms |
96
+ | mindlore-search | N | Xms |
97
+ | ... | | |
98
+ ```
99
+
100
+ ## Notes
101
+
102
+ - If `telemetry.jsonl` does not exist: report "No telemetry data yet"
103
+ - If `mindlore.db` does not exist: report "DB not found — run `npx mindlore init`"
104
+ - If `episodes` table missing: skip episode count, show "—"
105
+ - Inject size in tokens is approximate (chars ÷ 4)
106
+ - "Session" = last 8 hours from current time
@@ -1,14 +1,14 @@
1
- # Mindlore Index
2
-
3
- ## Domains
4
-
5
- ### Entities
6
-
7
- ### Concepts
8
-
9
- ## Connections
10
-
11
- ## Recent
12
-
13
- ## Stats
14
- 0 source, 0 analysis, 0 total
1
+ # Mindlore Index
2
+
3
+ ## Domains
4
+
5
+ ### Entities
6
+
7
+ ### Concepts
8
+
9
+ ## Connections
10
+
11
+ ## Recent
12
+
13
+ ## Stats
14
+ 0 source, 0 analysis, 0 total