mindlore 0.7.6 → 0.7.7

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 (148) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/README.md +3 -1
  4. package/dist/scripts/bundle-hooks.js +5 -1
  5. package/dist/scripts/bundle-hooks.js.map +1 -1
  6. package/dist/scripts/init.js +49 -10
  7. package/dist/scripts/init.js.map +1 -1
  8. package/dist/scripts/lib/constants.d.ts +8 -0
  9. package/dist/scripts/lib/constants.d.ts.map +1 -1
  10. package/dist/scripts/lib/constants.js +9 -1
  11. package/dist/scripts/lib/constants.js.map +1 -1
  12. package/dist/scripts/lib/db-helpers.d.ts +6 -0
  13. package/dist/scripts/lib/db-helpers.d.ts.map +1 -1
  14. package/dist/scripts/lib/db-helpers.js +6 -0
  15. package/dist/scripts/lib/db-helpers.js.map +1 -1
  16. package/dist/scripts/lib/read-guard-core.d.ts +21 -0
  17. package/dist/scripts/lib/read-guard-core.d.ts.map +1 -0
  18. package/dist/scripts/lib/read-guard-core.js +40 -0
  19. package/dist/scripts/lib/read-guard-core.js.map +1 -0
  20. package/dist/scripts/lib/search-cache.d.ts +1 -7
  21. package/dist/scripts/lib/search-cache.d.ts.map +1 -1
  22. package/dist/scripts/lib/search-cache.js +3 -25
  23. package/dist/scripts/lib/search-cache.js.map +1 -1
  24. package/dist/scripts/lib/search-throttle.d.ts +10 -0
  25. package/dist/scripts/lib/search-throttle.d.ts.map +1 -0
  26. package/dist/scripts/lib/search-throttle.js +32 -0
  27. package/dist/scripts/lib/search-throttle.js.map +1 -0
  28. package/dist/scripts/lib/settings-cleanup.d.ts.map +1 -1
  29. package/dist/scripts/lib/settings-cleanup.js +2 -1
  30. package/dist/scripts/lib/settings-cleanup.js.map +1 -1
  31. package/dist/scripts/lib/setup-wizard.d.ts +13 -0
  32. package/dist/scripts/lib/setup-wizard.d.ts.map +1 -0
  33. package/dist/scripts/lib/setup-wizard.js +51 -0
  34. package/dist/scripts/lib/setup-wizard.js.map +1 -0
  35. package/dist/scripts/lib/tool-adapters/decide-adapter.d.ts.map +1 -1
  36. package/dist/scripts/lib/tool-adapters/decide-adapter.js +3 -3
  37. package/dist/scripts/lib/tool-adapters/decide-adapter.js.map +1 -1
  38. package/dist/scripts/lib/tool-adapters/get-adapter.d.ts.map +1 -1
  39. package/dist/scripts/lib/tool-adapters/get-adapter.js +10 -2
  40. package/dist/scripts/lib/tool-adapters/get-adapter.js.map +1 -1
  41. package/dist/scripts/lib/tool-adapters/ingest-adapter.d.ts.map +1 -1
  42. package/dist/scripts/lib/tool-adapters/ingest-adapter.js +3 -3
  43. package/dist/scripts/lib/tool-adapters/ingest-adapter.js.map +1 -1
  44. package/dist/scripts/lib/transcript-token-estimator.d.ts +8 -0
  45. package/dist/scripts/lib/transcript-token-estimator.d.ts.map +1 -0
  46. package/dist/scripts/lib/transcript-token-estimator.js +164 -0
  47. package/dist/scripts/lib/transcript-token-estimator.js.map +1 -0
  48. package/dist/scripts/maintain-cleanup.d.ts.map +1 -1
  49. package/dist/scripts/maintain-cleanup.js +2 -1
  50. package/dist/scripts/maintain-cleanup.js.map +1 -1
  51. package/dist/scripts/mcp-server.js +3 -3
  52. package/dist/scripts/mcp-server.js.map +1 -1
  53. package/dist/scripts/mindlore-backup.d.ts.map +1 -1
  54. package/dist/scripts/mindlore-backup.js +3 -2
  55. package/dist/scripts/mindlore-backup.js.map +1 -1
  56. package/dist/scripts/mindlore-clean-cache.d.ts +4 -1
  57. package/dist/scripts/mindlore-clean-cache.d.ts.map +1 -1
  58. package/dist/scripts/mindlore-clean-cache.js +47 -20
  59. package/dist/scripts/mindlore-clean-cache.js.map +1 -1
  60. package/dist/scripts/mindlore-doctor.d.ts +4 -0
  61. package/dist/scripts/mindlore-doctor.d.ts.map +1 -1
  62. package/dist/scripts/mindlore-doctor.js +9 -1
  63. package/dist/scripts/mindlore-doctor.js.map +1 -1
  64. package/dist/scripts/mindlore-health-check.d.ts +7 -0
  65. package/dist/scripts/mindlore-health-check.d.ts.map +1 -1
  66. package/dist/scripts/mindlore-health-check.js +57 -4
  67. package/dist/scripts/mindlore-health-check.js.map +1 -1
  68. package/dist/scripts/mindlore-learnings.d.ts +6 -0
  69. package/dist/scripts/mindlore-learnings.d.ts.map +1 -0
  70. package/dist/scripts/mindlore-learnings.js +106 -0
  71. package/dist/scripts/mindlore-learnings.js.map +1 -0
  72. package/dist/scripts/mindlore-obsidian.js +6 -5
  73. package/dist/scripts/mindlore-obsidian.js.map +1 -1
  74. package/dist/scripts/quality-populate.js +2 -1
  75. package/dist/scripts/quality-populate.js.map +1 -1
  76. package/dist/scripts/uninstall.js +2 -1
  77. package/dist/scripts/uninstall.js.map +1 -1
  78. package/dist/tests/clean-cache-eperm.test.d.ts +2 -0
  79. package/dist/tests/clean-cache-eperm.test.d.ts.map +1 -0
  80. package/dist/tests/clean-cache-eperm.test.js +74 -0
  81. package/dist/tests/clean-cache-eperm.test.js.map +1 -0
  82. package/dist/tests/doctor.test.js +18 -0
  83. package/dist/tests/doctor.test.js.map +1 -1
  84. package/dist/tests/health-check.test.d.ts +2 -0
  85. package/dist/tests/health-check.test.d.ts.map +1 -0
  86. package/dist/tests/health-check.test.js +61 -0
  87. package/dist/tests/health-check.test.js.map +1 -0
  88. package/dist/tests/helpers/db.d.ts +7 -2
  89. package/dist/tests/helpers/db.d.ts.map +1 -1
  90. package/dist/tests/helpers/db.js +16 -14
  91. package/dist/tests/helpers/db.js.map +1 -1
  92. package/dist/tests/mindlore-ingest-extraction.test.d.ts +2 -0
  93. package/dist/tests/mindlore-ingest-extraction.test.d.ts.map +1 -0
  94. package/dist/tests/mindlore-ingest-extraction.test.js +48 -0
  95. package/dist/tests/mindlore-ingest-extraction.test.js.map +1 -0
  96. package/dist/tests/mindlore-learnings.test.d.ts +2 -0
  97. package/dist/tests/mindlore-learnings.test.d.ts.map +1 -0
  98. package/dist/tests/mindlore-learnings.test.js +63 -0
  99. package/dist/tests/mindlore-learnings.test.js.map +1 -0
  100. package/dist/tests/read-guard-perf.test.d.ts +2 -0
  101. package/dist/tests/read-guard-perf.test.d.ts.map +1 -0
  102. package/dist/tests/read-guard-perf.test.js +31 -0
  103. package/dist/tests/read-guard-perf.test.js.map +1 -0
  104. package/dist/tests/reflect-trigger.test.js +8 -1
  105. package/dist/tests/reflect-trigger.test.js.map +1 -1
  106. package/dist/tests/search-cache.test.js +0 -35
  107. package/dist/tests/search-cache.test.js.map +1 -1
  108. package/dist/tests/search-throttle.test.d.ts +2 -0
  109. package/dist/tests/search-throttle.test.d.ts.map +1 -0
  110. package/dist/tests/search-throttle.test.js +53 -0
  111. package/dist/tests/search-throttle.test.js.map +1 -0
  112. package/dist/tests/session-focus-reflect-nudge.test.js +3 -3
  113. package/dist/tests/session-focus-reflect-nudge.test.js.map +1 -1
  114. package/dist/tests/setup-wizard.test.d.ts +2 -0
  115. package/dist/tests/setup-wizard.test.d.ts.map +1 -0
  116. package/dist/tests/setup-wizard.test.js +35 -0
  117. package/dist/tests/setup-wizard.test.js.map +1 -0
  118. package/dist/tests/transcript-token-estimator.test.d.ts +2 -0
  119. package/dist/tests/transcript-token-estimator.test.d.ts.map +1 -0
  120. package/dist/tests/transcript-token-estimator.test.js +122 -0
  121. package/dist/tests/transcript-token-estimator.test.js.map +1 -0
  122. package/hooks/cc-memory-bulk-sync.cjs +9 -1
  123. package/hooks/cc-session-sync.cjs +9 -1
  124. package/hooks/lib/learnings-loader.cjs +21 -11
  125. package/hooks/lib/reflect-trigger.cjs +6 -3
  126. package/hooks/mindlore-cwd-changed.cjs +4 -5
  127. package/hooks/mindlore-dont-repeat.cjs +2 -1
  128. package/hooks/mindlore-post-read.cjs +2 -1
  129. package/hooks/mindlore-pre-compact.cjs +3 -2
  130. package/hooks/mindlore-read-guard.cjs +62 -35
  131. package/hooks/mindlore-search.cjs +231 -31
  132. package/hooks/mindlore-session-end.cjs +6 -8
  133. package/hooks/mindlore-session-focus.cjs +472 -23
  134. package/hooks/src/mindlore-cwd-changed.cjs +4 -5
  135. package/hooks/src/mindlore-dont-repeat.cjs +2 -1
  136. package/hooks/src/mindlore-post-read.cjs +2 -1
  137. package/hooks/src/mindlore-pre-compact.cjs +3 -2
  138. package/hooks/src/mindlore-read-guard.cjs +15 -55
  139. package/hooks/src/mindlore-search.cjs +39 -10
  140. package/hooks/src/mindlore-session-end.cjs +6 -8
  141. package/hooks/src/mindlore-session-focus.cjs +29 -21
  142. package/mcp-server.cjs +41 -25
  143. package/package.json +1 -1
  144. package/plugin.json +6 -1
  145. package/skills/mindlore-ingest/SKILL.md +21 -0
  146. package/skills/mindlore-learnings/SKILL.md +30 -0
  147. package/start.cjs +1 -1
  148. package/templates/config.json +1 -1
@@ -1,16 +1,447 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
9
  var __commonJS = (cb, mod) => function __require() {
5
10
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
11
  };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+
29
+ // dist/scripts/lib/constants.js
30
+ var require_constants = __commonJS({
31
+ "dist/scripts/lib/constants.js"(exports2) {
32
+ "use strict";
33
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
34
+ return mod && mod.__esModule ? mod : { "default": mod };
35
+ };
36
+ Object.defineProperty(exports2, "__esModule", { value: true });
37
+ exports2.CACHE_STALE_AGE_MS = exports2.NUDGE_COOLDOWN_HOURS = exports2.REFLECT_THRESHOLD_DAYS = exports2.LEARNINGS_TOTAL_CHAR_BUDGET = exports2.LEARNINGS_MAX_LINES_PER_LESSON = exports2.LEARNINGS_MAX_LESSONS = exports2.CONSOLIDATION_THRESHOLD = exports2.STALE_THRESHOLD = exports2.DECAY_HALF_LIFE_DAYS = exports2.DEFAULT_TOKEN_BUDGET = exports2.TELEMETRY_FILE_ROTATE_BYTES = exports2.TELEMETRY_OUTPUT_MAX_BYTES = exports2.TELEMETRY_FILENAME = exports2.CC_MEMORY_BOOST = exports2.CC_SUBAGENT_CATEGORY = exports2.CC_SESSION_CATEGORY = exports2.CC_MEMORY_CATEGORY = exports2.CC_MEMORY_DIR = exports2.CC_MEMORY_PATH_MARKER = exports2.CC_PLUGIN_CACHE_DIR = exports2.SLUG_OPTIONAL_TYPES = exports2.NESTED_DIR_TYPES = exports2.TYPE_TO_DIR = exports2.PRIORITY_CASE = exports2.RELATED_OVERFETCH = exports2.MAX_RELATED_SOURCES = exports2.RELATION_PRIORITY = exports2.SYMMETRIC_TYPES = exports2.RELATION_TYPES = exports2.QUALITY_HEURISTICS = exports2.QUALITY_VALUES = exports2.FRONTMATTER_TYPES = exports2.FTS5_COLUMNS = exports2.STOP_WORDS = exports2.TURKISH_WORD_RE = exports2.STOP_WORDS_MIN_LENGTH = exports2.SESSION_CATEGORIES = exports2.CATEGORIES = exports2.SCHEMA_VERSION = exports2.DEFAULT_MODELS = exports2.CONFIG_FILE = exports2.MCP_BUSY_TIMEOUT_MS = exports2.DB_BUSY_TIMEOUT_MS = exports2.SKIP_FILES = exports2.DIRECTORIES = exports2.DB_NAME = exports2.GLOBAL_MINDLORE_DIR = exports2.MINDLORE_DIR = exports2.KNOWN_HOOK_EVENTS = void 0;
38
+ exports2.isKnownHookEvent = isKnownHookEvent;
39
+ exports2.isSessionCategory = isSessionCategory;
40
+ exports2.fixVersionTokens = fixVersionTokens;
41
+ exports2.homedir = homedir;
42
+ exports2.getActiveMindloreDir = getActiveMindloreDir;
43
+ exports2.getAllDbs = getAllDbs;
44
+ exports2.getProjectName = getProjectName2;
45
+ exports2.resolveProject = resolveProject;
46
+ exports2.resolveMindloreHome = resolveMindloreHome2;
47
+ exports2.resolveTelemetryPath = resolveTelemetryPath;
48
+ exports2.log = log;
49
+ exports2.isContentFile = isContentFile;
50
+ exports2.resolveHookCommon = resolveHookCommon;
51
+ exports2.hasYoutubeTranscript = hasYoutubeTranscript;
52
+ var os_1 = __importDefault(require("os"));
53
+ var fs_1 = __importDefault(require("fs"));
54
+ var path_1 = __importDefault(require("path"));
55
+ exports2.KNOWN_HOOK_EVENTS = [
56
+ "SessionStart",
57
+ "SessionEnd",
58
+ "UserPromptSubmit",
59
+ "FileChanged",
60
+ "PreToolUse",
61
+ "PostToolUse",
62
+ "PreCompact",
63
+ "PostCompact",
64
+ "CwdChanged"
65
+ ];
66
+ function isKnownHookEvent(s) {
67
+ return exports2.KNOWN_HOOK_EVENTS.includes(s);
68
+ }
69
+ exports2.MINDLORE_DIR = ".mindlore";
70
+ exports2.GLOBAL_MINDLORE_DIR = process.env.MINDLORE_HOME ?? path_1.default.join(os_1.default.homedir(), exports2.MINDLORE_DIR);
71
+ exports2.DB_NAME = "mindlore.db";
72
+ exports2.DIRECTORIES = [
73
+ "raw",
74
+ "sources",
75
+ "domains",
76
+ "analyses",
77
+ "insights",
78
+ "connections",
79
+ "learnings",
80
+ "diary",
81
+ "decisions",
82
+ "logs",
83
+ "memory"
84
+ ];
85
+ exports2.SKIP_FILES = /* @__PURE__ */ new Set(["INDEX.md", "SCHEMA.md", "log.md"]);
86
+ exports2.DB_BUSY_TIMEOUT_MS = 2e3;
87
+ exports2.MCP_BUSY_TIMEOUT_MS = 5e3;
88
+ exports2.CONFIG_FILE = "config.json";
89
+ exports2.DEFAULT_MODELS = {
90
+ ingest: "haiku",
91
+ evolve: "sonnet",
92
+ explore: "sonnet",
93
+ default: "haiku"
94
+ };
95
+ exports2.SCHEMA_VERSION = 1;
96
+ exports2.CATEGORIES = ["sources", "analyses", "domains", "episodes", "decisions", "raw", "sessions", "cc_memory", "cc-session", "cc-subagent", "diary", "insights", "connections", "learnings", "memory"];
97
+ exports2.SESSION_CATEGORIES = ["cc-subagent", "cc-session"];
98
+ function isSessionCategory(category) {
99
+ return exports2.SESSION_CATEGORIES.includes(category);
100
+ }
101
+ exports2.STOP_WORDS_MIN_LENGTH = 2;
102
+ exports2.TURKISH_WORD_RE = /[^\w\sçğıöşüÇĞİÖŞÜ-]/g;
103
+ exports2.STOP_WORDS = /* @__PURE__ */ new Set([
104
+ // English
105
+ "the",
106
+ "a",
107
+ "an",
108
+ "is",
109
+ "are",
110
+ "was",
111
+ "were",
112
+ "be",
113
+ "been",
114
+ "being",
115
+ "have",
116
+ "has",
117
+ "had",
118
+ "do",
119
+ "does",
120
+ "did",
121
+ "will",
122
+ "would",
123
+ "could",
124
+ "should",
125
+ "may",
126
+ "might",
127
+ "can",
128
+ "shall",
129
+ "to",
130
+ "of",
131
+ "in",
132
+ "for",
133
+ "on",
134
+ "with",
135
+ "at",
136
+ "by",
137
+ "from",
138
+ "as",
139
+ "into",
140
+ "through",
141
+ "during",
142
+ "it",
143
+ "its",
144
+ "this",
145
+ "that",
146
+ "these",
147
+ "those",
148
+ "what",
149
+ "which",
150
+ "who",
151
+ "whom",
152
+ "how",
153
+ "when",
154
+ "where",
155
+ "why",
156
+ "not",
157
+ "no",
158
+ "nor",
159
+ "so",
160
+ "if",
161
+ "or",
162
+ "but",
163
+ "all",
164
+ "each",
165
+ "every",
166
+ "both",
167
+ "few",
168
+ "more",
169
+ "most",
170
+ "other",
171
+ "some",
172
+ "such",
173
+ "only",
174
+ "own",
175
+ "same",
176
+ "than",
177
+ "and",
178
+ "about",
179
+ "between",
180
+ "after",
181
+ "before",
182
+ "above",
183
+ "below",
184
+ "up",
185
+ "down",
186
+ "out",
187
+ "very",
188
+ "just",
189
+ "also",
190
+ "now",
191
+ "then",
192
+ "here",
193
+ "there",
194
+ "too",
195
+ "yet",
196
+ "my",
197
+ "your",
198
+ "his",
199
+ "her",
200
+ "our",
201
+ "their",
202
+ "me",
203
+ "him",
204
+ "us",
205
+ "them",
206
+ "i",
207
+ "you",
208
+ "he",
209
+ "she",
210
+ "we",
211
+ "they",
212
+ // Turkish
213
+ "bir",
214
+ "bu",
215
+ "su",
216
+ "ne",
217
+ "nas\u0131l",
218
+ "neden",
219
+ "var",
220
+ "yok",
221
+ "mi",
222
+ "mu",
223
+ "m\u0131",
224
+ "ile",
225
+ "i\xE7in",
226
+ "de",
227
+ "da",
228
+ "ve",
229
+ "veya",
230
+ "ama",
231
+ "ise",
232
+ "hem",
233
+ "bakal\u0131m",
234
+ "gel",
235
+ "git",
236
+ "yap",
237
+ "et",
238
+ "al",
239
+ "ver",
240
+ "evet",
241
+ "hay\u0131r",
242
+ "tamam",
243
+ "ok",
244
+ "oldu",
245
+ "olur",
246
+ "dur",
247
+ "\u015Fimdi",
248
+ "sonra",
249
+ "\xF6nce",
250
+ "hemen",
251
+ "biraz",
252
+ "lan",
253
+ "ya",
254
+ "ki",
255
+ "abi",
256
+ "hadi",
257
+ "hey",
258
+ "selam",
259
+ "olarak",
260
+ "olan",
261
+ "gibi",
262
+ "kadar",
263
+ "daha",
264
+ "\xE7ok",
265
+ "en",
266
+ "bunu",
267
+ "buna",
268
+ "i\xE7inde",
269
+ "\xFCzerinde",
270
+ "aras\u0131nda",
271
+ "sonucu",
272
+ "taraf\u0131ndan",
273
+ "zaten",
274
+ "gayet",
275
+ "acaba",
276
+ "nedir",
277
+ "midir",
278
+ "mudur",
279
+ // Generic technical
280
+ "hook",
281
+ "file",
282
+ "dosya",
283
+ "kullan",
284
+ "ekle",
285
+ "yaz",
286
+ "oku",
287
+ "\xE7al\u0131\u015Ft\u0131r",
288
+ "kontrol",
289
+ "test",
290
+ "check",
291
+ "run",
292
+ "add",
293
+ "update",
294
+ "config",
295
+ "setup",
296
+ "install",
297
+ "start",
298
+ "stop",
299
+ "create",
300
+ "delete",
301
+ "remove",
302
+ "set",
303
+ "get",
304
+ "list",
305
+ "show",
306
+ "view",
307
+ "open",
308
+ "close",
309
+ "save",
310
+ "load"
311
+ ]);
312
+ var VERSION_RE = /v(\d+)\.(\d+)(?:\.(\d+))?/g;
313
+ function fixVersionTokens(query) {
314
+ return query.replace(VERSION_RE, (_m, a, b, c) => c ? `"v${a} ${b} ${c}"` : `"v${a} ${b}"`);
315
+ }
316
+ exports2.FTS5_COLUMNS = ["path", "slug", "description", "type", "category", "title", "content", "tags", "quality", "date_captured", "project"];
317
+ exports2.FRONTMATTER_TYPES = ["raw", "source", "domain", "analysis", "diary", "decision", "insight", "connection", "learning", "feedback", "user", "project", "reference", "note"];
318
+ exports2.QUALITY_VALUES = ["high", "medium", "low"];
319
+ exports2.QUALITY_HEURISTICS = {
320
+ "github-repo": "high",
321
+ "docs": "high",
322
+ "blog": "medium",
323
+ "video": "medium",
324
+ "x-thread": "medium",
325
+ "text-paste": "low",
326
+ "snippet": "low",
327
+ "forum": "low",
328
+ "cc-session": "low",
329
+ "cc-subagent": "low"
330
+ };
331
+ exports2.RELATION_TYPES = ["cites", "extends", "contradicts", "supersedes"];
332
+ exports2.SYMMETRIC_TYPES = /* @__PURE__ */ new Set(["contradicts"]);
333
+ exports2.RELATION_PRIORITY = {
334
+ supersedes: 1,
335
+ contradicts: 2,
336
+ extends: 3,
337
+ cites: 4
338
+ };
339
+ exports2.MAX_RELATED_SOURCES = 5;
340
+ exports2.RELATED_OVERFETCH = 10;
341
+ exports2.PRIORITY_CASE = "WHEN 'supersedes' THEN 1 WHEN 'contradicts' THEN 2 WHEN 'extends' THEN 3 WHEN 'cites' THEN 4";
342
+ exports2.TYPE_TO_DIR = {
343
+ raw: "raw",
344
+ source: "sources",
345
+ domain: "domains",
346
+ analysis: "analyses",
347
+ insight: "insights",
348
+ connection: "connections",
349
+ learning: "learnings",
350
+ decision: "decisions",
351
+ diary: "diary",
352
+ feedback: "memory",
353
+ user: "memory",
354
+ project: "memory",
355
+ reference: "memory",
356
+ note: "memory"
357
+ };
358
+ exports2.NESTED_DIR_TYPES = /* @__PURE__ */ new Set(["raw"]);
359
+ exports2.SLUG_OPTIONAL_TYPES = /* @__PURE__ */ new Set(["raw", "compaction-snapshot"]);
360
+ exports2.CC_PLUGIN_CACHE_DIR = path_1.default.join(os_1.default.homedir(), ".claude", "plugins", "cache");
361
+ exports2.CC_MEMORY_PATH_MARKER = path_1.default.join(".claude", "projects");
362
+ exports2.CC_MEMORY_DIR = "memory";
363
+ exports2.CC_MEMORY_CATEGORY = "cc-memory";
364
+ exports2.CC_SESSION_CATEGORY = "cc-session";
365
+ exports2.CC_SUBAGENT_CATEGORY = "cc-subagent";
366
+ exports2.CC_MEMORY_BOOST = 1.2;
367
+ function homedir() {
368
+ return os_1.default.homedir();
369
+ }
370
+ function getActiveMindloreDir() {
371
+ return exports2.GLOBAL_MINDLORE_DIR;
372
+ }
373
+ function getAllDbs() {
374
+ const dbPath = path_1.default.join(exports2.GLOBAL_MINDLORE_DIR, exports2.DB_NAME);
375
+ if (fs_1.default.existsSync(dbPath))
376
+ return [dbPath];
377
+ return [];
378
+ }
379
+ function getProjectName2() {
380
+ return path_1.default.basename(process.cwd());
381
+ }
382
+ function resolveProject() {
383
+ if (process.env.MINDLORE_PROJECT)
384
+ return process.env.MINDLORE_PROJECT;
385
+ return getProjectName2().toLowerCase();
386
+ }
387
+ function resolveMindloreHome2() {
388
+ return process.env.MINDLORE_HOME ?? path_1.default.join(os_1.default.homedir(), exports2.MINDLORE_DIR);
389
+ }
390
+ exports2.TELEMETRY_FILENAME = "telemetry.jsonl";
391
+ exports2.TELEMETRY_OUTPUT_MAX_BYTES = 4e3;
392
+ exports2.TELEMETRY_FILE_ROTATE_BYTES = 10 * 1024 * 1024;
393
+ function resolveTelemetryPath() {
394
+ return process.env.MINDLORE_TELEMETRY_PATH ?? path_1.default.join(resolveMindloreHome2(), exports2.TELEMETRY_FILENAME);
395
+ }
396
+ function log(msg) {
397
+ console.log(` ${msg}`);
398
+ }
399
+ function isContentFile(filePath) {
400
+ return !exports2.SKIP_FILES.has(path_1.default.basename(filePath));
401
+ }
402
+ function resolveHookCommon(callerDir) {
403
+ let dir = callerDir;
404
+ for (let i = 0; i < 5; i++) {
405
+ const target = path_1.default.join(dir, "hooks", "lib", "mindlore-common.cjs");
406
+ if (fs_1.default.existsSync(target))
407
+ return target;
408
+ const parent = path_1.default.dirname(dir);
409
+ if (parent === dir)
410
+ break;
411
+ dir = parent;
412
+ }
413
+ return path_1.default.resolve(callerDir, "..", "..", "hooks", "lib", "mindlore-common.cjs");
414
+ }
415
+ function hasYoutubeTranscript() {
416
+ try {
417
+ require.resolve("youtube-transcript");
418
+ return true;
419
+ } catch (_err) {
420
+ return false;
421
+ }
422
+ }
423
+ exports2.DEFAULT_TOKEN_BUDGET = {
424
+ sessionInject: 2e3,
425
+ searchResults: 1500,
426
+ perResult: 500
427
+ };
428
+ exports2.DECAY_HALF_LIFE_DAYS = 30;
429
+ exports2.STALE_THRESHOLD = 0.3;
430
+ exports2.CONSOLIDATION_THRESHOLD = 50;
431
+ exports2.LEARNINGS_MAX_LESSONS = 10;
432
+ exports2.LEARNINGS_MAX_LINES_PER_LESSON = 5;
433
+ exports2.LEARNINGS_TOTAL_CHAR_BUDGET = 6e3;
434
+ exports2.REFLECT_THRESHOLD_DAYS = 7;
435
+ exports2.NUDGE_COOLDOWN_HOURS = 24;
436
+ exports2.CACHE_STALE_AGE_MS = 24 * 3600 * 1e3;
437
+ }
438
+ });
7
439
 
8
440
  // hooks/lib/reflect-trigger.cjs
9
441
  var require_reflect_trigger = __commonJS({
10
442
  "hooks/lib/reflect-trigger.cjs"(exports2, module2) {
11
443
  "use strict";
12
- var REFLECT_THRESHOLD_DAYS = 7;
13
- var NUDGE_COOLDOWN_HOURS = 24;
444
+ var { REFLECT_THRESHOLD_DAYS, NUDGE_COOLDOWN_HOURS } = require_constants();
14
445
  function isValidDate(iso) {
15
446
  if (!iso) return false;
16
447
  const d = new Date(iso);
@@ -33,7 +464,10 @@ var require_reflect_trigger = __commonJS({
33
464
  }
34
465
  return true;
35
466
  }
36
- module2.exports = { shouldNudgeReflect: shouldNudgeReflect2, REFLECT_THRESHOLD_DAYS, NUDGE_COOLDOWN_HOURS };
467
+ function buildNudgeMessage2(params) {
468
+ return `[Mindlore] Son reflect'inden ${params.daysSince} g\xFCn ge\xE7ti. ${params.episodeCount} episode + ${params.diaryCount} diary birikti \u2014 \`/mindlore-reflect\` ile pattern \xF6zetle.`;
469
+ }
470
+ module2.exports = { shouldNudgeReflect: shouldNudgeReflect2, buildNudgeMessage: buildNudgeMessage2, REFLECT_THRESHOLD_DAYS, NUDGE_COOLDOWN_HOURS };
37
471
  }
38
472
  });
39
473
 
@@ -617,7 +1051,7 @@ var fs = require("fs");
617
1051
  var path = require("path");
618
1052
  var { findMindloreDir, readConfig, openDatabase, hasEpisodesTable, querySupersededChains, formatSupersededChains, hookLog, getProjectName, parseFrontmatter, withTelemetry, withTimeoutDb, listSnapshots, isCorruptionError, recoverCorruptDb, getNominationCounts, resolveMindloreHome } = require("./lib/mindlore-common.cjs");
619
1053
  var { loadLearningsBlock } = require("./lib/learnings-loader.cjs");
620
- var { shouldNudgeReflect } = require_reflect_trigger();
1054
+ var { shouldNudgeReflect, buildNudgeMessage } = require_reflect_trigger();
621
1055
  function truncateSection(content, sectionRegex, keepCount, label) {
622
1056
  const match = content.match(sectionRegex);
623
1057
  if (!match) return content;
@@ -733,11 +1167,17 @@ function main() {
733
1167
  let sourceChars = 0;
734
1168
  const tIndex = Date.now();
735
1169
  const indexPath = path.join(baseDir, "INDEX.md");
736
- if (fs.existsSync(indexPath)) {
737
- const content = fs.readFileSync(indexPath, "utf8").trim();
738
- sourceChars += content.length;
1170
+ let indexContent;
1171
+ try {
1172
+ indexContent = fs.readFileSync(indexPath, "utf8").trim();
1173
+ } catch (err) {
1174
+ if (err.code !== "ENOENT") throw err;
1175
+ indexContent = null;
1176
+ }
1177
+ if (indexContent !== null) {
1178
+ sourceChars += indexContent.length;
739
1179
  output.push(`[Mindlore INDEX]
740
- ${content}`);
1180
+ ${indexContent}`);
741
1181
  }
742
1182
  timings.index_read = Date.now() - tIndex;
743
1183
  const tDiary = Date.now();
@@ -771,15 +1211,20 @@ ${truncateChangedFiles(truncateCommits(deltaContent))}`);
771
1211
  const tVersion = Date.now();
772
1212
  const versionPath = path.join(baseDir, ".version");
773
1213
  const pkgVersionPath = path.join(baseDir, ".pkg-version");
1214
+ let installed;
774
1215
  try {
775
- if (fs.existsSync(versionPath) && fs.existsSync(pkgVersionPath)) {
776
- const installed = fs.readFileSync(versionPath, "utf8").trim();
777
- const pkgVersion = fs.readFileSync(pkgVersionPath, "utf8").trim();
778
- if (pkgVersion && pkgVersion !== installed) {
779
- output.push(`[Mindlore: Guncelleme mevcut (${installed} \u2192 ${pkgVersion}). \`npx mindlore init\` calistirin.]`);
780
- }
781
- }
782
- } catch (_err) {
1216
+ installed = fs.readFileSync(versionPath, "utf8").trim();
1217
+ } catch (err) {
1218
+ if (err.code !== "ENOENT") throw err;
1219
+ }
1220
+ let pkgVersion;
1221
+ try {
1222
+ pkgVersion = fs.readFileSync(pkgVersionPath, "utf8").trim();
1223
+ } catch (err) {
1224
+ if (err.code !== "ENOENT") throw err;
1225
+ }
1226
+ if (installed !== void 0 && pkgVersion !== void 0 && pkgVersion !== installed) {
1227
+ output.push(`[Mindlore: Guncelleme mevcut (${installed} \u2192 ${pkgVersion}). \`npx mindlore init\` calistirin.]`);
783
1228
  }
784
1229
  timings.version_check = Date.now() - tVersion;
785
1230
  const tDb = Date.now();
@@ -805,14 +1250,18 @@ ${truncateChangedFiles(truncateCommits(deltaContent))}`);
805
1250
  timings.schema_check = Date.now() - tSchema;
806
1251
  loadDbContent({ db, baseDir, config, output, timings, latestDeltaContent, sessionId });
807
1252
  try {
808
- const reflectRow = db.prepare(
809
- "SELECT value FROM skill_memory WHERE skill_name = 'mindlore-reflect' AND key = 'last_reflect_date'"
810
- ).get();
811
- const nudgeRow = db.prepare(
812
- "SELECT value FROM skill_memory WHERE skill_name = 'mindlore-reflect' AND key = 'last_nudge_date'"
813
- ).get();
1253
+ const rows = db.prepare(
1254
+ "SELECT key, value FROM skill_memory WHERE skill_name = 'mindlore-reflect' AND key IN ('last_reflect_date', 'last_nudge_date')"
1255
+ ).all();
1256
+ const byKey = Object.fromEntries(rows.map((r) => [r.key, r.value]));
1257
+ const reflectRow = byKey["last_reflect_date"] ? { value: byKey["last_reflect_date"] } : void 0;
1258
+ const nudgeRow = byKey["last_nudge_date"] ? { value: byKey["last_nudge_date"] } : void 0;
814
1259
  if (shouldNudgeReflect(reflectRow?.value ?? null, nudgeRow?.value ?? null, /* @__PURE__ */ new Date())) {
815
- output.push("[Mindlore] 7+ g\xFCn reflect yap\u0131lmad\u0131 \u2014 `/mindlore-reflect` \xE7al\u0131\u015Ft\u0131r");
1260
+ const daysSince = reflectRow?.value ? Math.floor((Date.now() - new Date(reflectRow.value).getTime()) / 864e5) : 999;
1261
+ const episodeCount = hasEpisodesTable(db) ? db.prepare("SELECT count(*) AS c FROM episodes").get()?.c ?? 0 : 0;
1262
+ const diaryDirPath = path.join(baseDir, "diary");
1263
+ const diaryCount = fs.existsSync(diaryDirPath) ? fs.readdirSync(diaryDirPath).length : 0;
1264
+ output.push(buildNudgeMessage({ daysSince, episodeCount, diaryCount }));
816
1265
  const nowIso = (/* @__PURE__ */ new Date()).toISOString();
817
1266
  db.prepare(`
818
1267
  INSERT INTO skill_memory (skill_name, key, value, updated_at)
@@ -16,6 +16,7 @@
16
16
  const fs = require('fs');
17
17
  const path = require('path');
18
18
  const { findMindloreDir, globalDir, hookLog, withTelemetry } = require('./lib/mindlore-common.cjs');
19
+ const { safeMkdir, safeWriteFile } = require('./lib/secure-io.cjs');
19
20
 
20
21
  function main() {
21
22
  const cwd = process.cwd();
@@ -24,9 +25,7 @@ function main() {
24
25
 
25
26
  if (activeDir) {
26
27
  const diaryDir = path.join(activeDir, 'diary');
27
- if (!fs.existsSync(diaryDir)) {
28
- fs.mkdirSync(diaryDir, { recursive: true });
29
- }
28
+ safeMkdir(diaryDir);
30
29
 
31
30
  // Dirty-check: skip write if scope hasn't changed
32
31
  const scopePath = path.join(diaryDir, '_scope.json');
@@ -39,12 +38,12 @@ function main() {
39
38
  }
40
39
  }
41
40
 
42
- fs.writeFileSync(scopePath, JSON.stringify({
41
+ safeWriteFile(scopePath, JSON.stringify({
43
42
  scope,
44
43
  dir: activeDir,
45
44
  cwd,
46
45
  timestamp: new Date().toISOString(),
47
- }, null, 2), 'utf8');
46
+ }, null, 2));
48
47
  }
49
48
 
50
49
  if (scope === 'none') {
@@ -19,6 +19,7 @@ const fs = require('fs');
19
19
  const path = require('path');
20
20
  const os = require('os');
21
21
  const { findMindloreDir, getProjectName, hookLog, withTelemetrySync } = require('./lib/mindlore-common.cjs');
22
+ const { safeWriteFile } = require('./lib/secure-io.cjs');
22
23
 
23
24
  /**
24
25
  * File-persisted pattern cache — survives across process invocations.
@@ -41,7 +42,7 @@ function readCache(cachePath) {
41
42
  function writeCache(cachePath, cache) {
42
43
  if (!cachePath || !cacheDirty) return;
43
44
  try {
44
- fs.writeFileSync(cachePath, JSON.stringify(cache), 'utf8');
45
+ safeWriteFile(cachePath, JSON.stringify(cache));
45
46
  } catch (_err) { /* write failure is non-fatal */ }
46
47
  }
47
48
 
@@ -14,6 +14,7 @@
14
14
  const fs = require('fs');
15
15
  const path = require('path');
16
16
  const { findMindloreDir, getProjectName, hookLog, withTelemetry } = require('./lib/mindlore-common.cjs');
17
+ const { safeWriteFile } = require('./lib/secure-io.cjs');
17
18
 
18
19
  const CODE_EXTS = new Set(['.ts', '.tsx', '.js', '.jsx', '.py', '.rs', '.go', '.java', '.c', '.cpp', '.h', '.css', '.scss', '.sql', '.sh', '.yaml', '.yml', '.json', '.toml', '.xml', '.cjs', '.mjs']);
19
20
  const PROSE_EXTS = new Set(['.md', '.txt', '.rst', '.adoc']);
@@ -86,7 +87,7 @@ function main() {
86
87
  reads[key] = { count: 1, tokens, chars: charCount };
87
88
  }
88
89
 
89
- fs.writeFileSync(readsPath, JSON.stringify(reads, null, 2), 'utf8');
90
+ safeWriteFile(readsPath, JSON.stringify(reads, null, 2));
90
91
 
91
92
  // Output token estimate to Claude via additionalContext
92
93
  const basename = path.basename(filePath);
@@ -12,6 +12,7 @@
12
12
  const fs = require('fs');
13
13
  const path = require('path');
14
14
  const { findMindloreDir, openDatabase, hookLog, withTelemetry, listSnapshots } = require('./lib/mindlore-common.cjs');
15
+ const { safeWriteFile } = require('./lib/secure-io.cjs');
15
16
 
16
17
  function collectRecentEpisodes(baseDir) {
17
18
  try {
@@ -107,7 +108,7 @@ function main() {
107
108
  `Pre-compact snapshot at ${iso}.`,
108
109
  `Working directory: ${process.cwd()}`,
109
110
  ].join('\n');
110
- fs.writeFileSync(episodePath, content, 'utf8');
111
+ safeWriteFile(episodePath, content);
111
112
  } catch (_err) { /* episodes dir may not exist */ }
112
113
 
113
114
  // Append log entry
@@ -135,7 +136,7 @@ function main() {
135
136
  '',
136
137
  ...sections,
137
138
  ].join('\n');
138
- fs.writeFileSync(path.join(diaryDir, `compaction-snapshot-${ts}.md`), snapshotContent);
139
+ safeWriteFile(path.join(diaryDir, `compaction-snapshot-${ts}.md`), snapshotContent);
139
140
  }
140
141
 
141
142
  const snapshots = listSnapshots(diaryDir).filter(f => f.startsWith('compaction-'));