mindlore 0.7.0 → 0.7.2
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.
- package/README.md +30 -3
- package/dist/scripts/bundle-hooks.d.ts +2 -0
- package/dist/scripts/bundle-hooks.d.ts.map +1 -0
- package/dist/scripts/bundle-hooks.js +70 -0
- package/dist/scripts/bundle-hooks.js.map +1 -0
- package/dist/scripts/init.js +0 -3
- package/dist/scripts/init.js.map +1 -1
- package/dist/scripts/lib/all-migrations.d.ts.map +1 -1
- package/dist/scripts/lib/all-migrations.js +3 -0
- package/dist/scripts/lib/all-migrations.js.map +1 -1
- package/dist/scripts/lib/constants.d.ts +7 -2
- package/dist/scripts/lib/constants.d.ts.map +1 -1
- package/dist/scripts/lib/constants.js +17 -22
- package/dist/scripts/lib/constants.js.map +1 -1
- package/dist/scripts/lib/mcp-tools.d.ts.map +1 -1
- package/dist/scripts/lib/mcp-tools.js +63 -78
- package/dist/scripts/lib/mcp-tools.js.map +1 -1
- package/dist/scripts/lib/migrations-v072.d.ts +3 -0
- package/dist/scripts/lib/migrations-v072.d.ts.map +1 -0
- package/dist/scripts/lib/migrations-v072.js +25 -0
- package/dist/scripts/lib/migrations-v072.js.map +1 -0
- package/dist/scripts/lib/relation-helpers.d.ts +15 -0
- package/dist/scripts/lib/relation-helpers.d.ts.map +1 -0
- package/dist/scripts/lib/relation-helpers.js +30 -0
- package/dist/scripts/lib/relation-helpers.js.map +1 -0
- package/dist/scripts/lib/tool-adapters/get-adapter.d.ts +21 -0
- package/dist/scripts/lib/tool-adapters/get-adapter.d.ts.map +1 -0
- package/dist/scripts/lib/tool-adapters/get-adapter.js +51 -0
- package/dist/scripts/lib/tool-adapters/get-adapter.js.map +1 -0
- package/dist/scripts/lib/tool-adapters/relate-adapter.d.ts +34 -0
- package/dist/scripts/lib/tool-adapters/relate-adapter.d.ts.map +1 -0
- package/dist/scripts/lib/tool-adapters/relate-adapter.js +43 -0
- package/dist/scripts/lib/tool-adapters/relate-adapter.js.map +1 -0
- package/dist/scripts/lib/tool-adapters/search-adapter.d.ts +5 -0
- package/dist/scripts/lib/tool-adapters/search-adapter.d.ts.map +1 -1
- package/dist/scripts/lib/tool-adapters/search-adapter.js +37 -0
- package/dist/scripts/lib/tool-adapters/search-adapter.js.map +1 -1
- package/dist/scripts/mcp-server.js +1 -1
- package/dist/scripts/mcp-server.js.map +1 -1
- package/dist/tests/dont-repeat-dedup.test.d.ts +2 -0
- package/dist/tests/dont-repeat-dedup.test.d.ts.map +1 -0
- package/dist/tests/dont-repeat-dedup.test.js +93 -0
- package/dist/tests/dont-repeat-dedup.test.js.map +1 -0
- package/dist/tests/e2e-kg-pipeline.test.d.ts +2 -0
- package/dist/tests/e2e-kg-pipeline.test.d.ts.map +1 -0
- package/dist/tests/e2e-kg-pipeline.test.js +59 -0
- package/dist/tests/e2e-kg-pipeline.test.js.map +1 -0
- package/dist/tests/helpers/db.d.ts.map +1 -1
- package/dist/tests/helpers/db.js +2 -1
- package/dist/tests/helpers/db.js.map +1 -1
- package/dist/tests/hook-smoke.test.js +1 -1
- package/dist/tests/hook-smoke.test.js.map +1 -1
- package/dist/tests/mcp-get-tool.test.d.ts +2 -0
- package/dist/tests/mcp-get-tool.test.d.ts.map +1 -0
- package/dist/tests/mcp-get-tool.test.js +93 -0
- package/dist/tests/mcp-get-tool.test.js.map +1 -0
- package/dist/tests/mcp-relate-tool.test.d.ts +2 -0
- package/dist/tests/mcp-relate-tool.test.d.ts.map +1 -0
- package/dist/tests/mcp-relate-tool.test.js +85 -0
- package/dist/tests/mcp-relate-tool.test.js.map +1 -0
- package/dist/tests/mcp-server.test.js +3 -1
- package/dist/tests/mcp-server.test.js.map +1 -1
- package/dist/tests/mcp-tools.test.js +20 -0
- package/dist/tests/mcp-tools.test.js.map +1 -1
- package/dist/tests/memory-relate.test.d.ts +2 -0
- package/dist/tests/memory-relate.test.d.ts.map +1 -0
- package/dist/tests/memory-relate.test.js +70 -0
- package/dist/tests/memory-relate.test.js.map +1 -0
- package/dist/tests/migrations-v063.test.js +1 -1
- package/dist/tests/migrations-v072.test.d.ts +2 -0
- package/dist/tests/migrations-v072.test.d.ts.map +1 -0
- package/dist/tests/migrations-v072.test.js +74 -0
- package/dist/tests/migrations-v072.test.js.map +1 -0
- package/dist/tests/plugin-cache-regression.test.d.ts +2 -0
- package/dist/tests/plugin-cache-regression.test.d.ts.map +1 -0
- package/dist/tests/plugin-cache-regression.test.js +19 -0
- package/dist/tests/plugin-cache-regression.test.js.map +1 -0
- package/dist/tests/search-hook.test.js +1 -1
- package/dist/tests/search-hook.test.js.map +1 -1
- package/hooks/cc-memory-bulk-sync.cjs +606 -0
- package/hooks/cc-session-sync.cjs +856 -0
- package/hooks/hooks.json +149 -0
- package/hooks/lib/mindlore-common.cjs +2 -2
- package/hooks/lib/secure-io.cjs +17 -0
- package/hooks/mindlore-cwd-changed.cjs +19 -34
- package/hooks/mindlore-decision-detector.cjs +40 -31
- package/hooks/mindlore-dont-repeat.cjs +75 -115
- package/hooks/mindlore-fts5-sync.cjs +15 -44
- package/hooks/mindlore-index.cjs +100 -101
- package/hooks/mindlore-model-router.cjs +20 -32
- package/hooks/mindlore-post-compact.cjs +26 -42
- package/hooks/mindlore-post-read.cjs +35 -60
- package/hooks/mindlore-pre-compact.cjs +55 -73
- package/hooks/mindlore-read-guard.cjs +28 -51
- package/hooks/mindlore-research-guard.cjs +63 -101
- package/hooks/mindlore-search.cjs +1156 -93
- package/hooks/mindlore-session-end.cjs +155 -276
- package/hooks/mindlore-session-focus.cjs +672 -110
- package/hooks/src/lib/constants.cjs +15 -0
- package/hooks/src/lib/mindlore-common.cjs +975 -0
- package/hooks/src/lib/mindlore-common.d.cts +72 -0
- package/hooks/src/lib/secure-io.cjs +17 -0
- package/hooks/src/lib/types.d.ts +58 -0
- package/hooks/src/mindlore-cwd-changed.cjs +57 -0
- package/hooks/src/mindlore-decision-detector.cjs +54 -0
- package/hooks/src/mindlore-dont-repeat.cjs +243 -0
- package/hooks/src/mindlore-fts5-sync.cjs +98 -0
- package/hooks/src/mindlore-index.cjs +230 -0
- package/hooks/src/mindlore-model-router.cjs +54 -0
- package/hooks/src/mindlore-post-compact.cjs +69 -0
- package/hooks/src/mindlore-post-read.cjs +106 -0
- package/hooks/src/mindlore-pre-compact.cjs +154 -0
- package/hooks/src/mindlore-read-guard.cjs +105 -0
- package/hooks/src/mindlore-research-guard.cjs +176 -0
- package/hooks/src/mindlore-search.cjs +200 -0
- package/hooks/src/mindlore-session-end.cjs +511 -0
- package/hooks/src/mindlore-session-focus.cjs +256 -0
- package/package.json +8 -3
- package/plugin.json +5 -4
- package/templates/config.json +1 -1
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
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 __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
34
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37
|
+
exports2.CONSOLIDATION_THRESHOLD = exports2.STALE_THRESHOLD = exports2.DECAY_HALF_LIFE_DAYS = exports2.DEFAULT_TOKEN_BUDGET = 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.TYPE_TO_DIR = 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.buildPriorityCase = buildPriorityCase;
|
|
42
|
+
exports2.homedir = homedir;
|
|
43
|
+
exports2.getActiveMindloreDir = getActiveMindloreDir;
|
|
44
|
+
exports2.getAllDbs = getAllDbs;
|
|
45
|
+
exports2.getProjectName = getProjectName;
|
|
46
|
+
exports2.log = log;
|
|
47
|
+
exports2.isContentFile = isContentFile;
|
|
48
|
+
exports2.resolveHookCommon = resolveHookCommon;
|
|
49
|
+
exports2.hasYoutubeTranscript = hasYoutubeTranscript;
|
|
50
|
+
var os_12 = __importDefault2(require("os"));
|
|
51
|
+
var fs_12 = __importDefault2(require("fs"));
|
|
52
|
+
var path_12 = __importDefault2(require("path"));
|
|
53
|
+
exports2.KNOWN_HOOK_EVENTS = [
|
|
54
|
+
"SessionStart",
|
|
55
|
+
"SessionEnd",
|
|
56
|
+
"UserPromptSubmit",
|
|
57
|
+
"FileChanged",
|
|
58
|
+
"PreToolUse",
|
|
59
|
+
"PostToolUse",
|
|
60
|
+
"PreCompact",
|
|
61
|
+
"PostCompact",
|
|
62
|
+
"CwdChanged"
|
|
63
|
+
];
|
|
64
|
+
function isKnownHookEvent(s) {
|
|
65
|
+
return exports2.KNOWN_HOOK_EVENTS.includes(s);
|
|
66
|
+
}
|
|
67
|
+
exports2.MINDLORE_DIR = ".mindlore";
|
|
68
|
+
exports2.GLOBAL_MINDLORE_DIR = process.env.MINDLORE_HOME ?? path_12.default.join(os_12.default.homedir(), exports2.MINDLORE_DIR);
|
|
69
|
+
exports2.DB_NAME = "mindlore.db";
|
|
70
|
+
exports2.DIRECTORIES = [
|
|
71
|
+
"raw",
|
|
72
|
+
"sources",
|
|
73
|
+
"domains",
|
|
74
|
+
"analyses",
|
|
75
|
+
"insights",
|
|
76
|
+
"connections",
|
|
77
|
+
"learnings",
|
|
78
|
+
"diary",
|
|
79
|
+
"decisions",
|
|
80
|
+
"logs",
|
|
81
|
+
"memory"
|
|
82
|
+
];
|
|
83
|
+
exports2.SKIP_FILES = /* @__PURE__ */ new Set(["INDEX.md", "SCHEMA.md", "log.md"]);
|
|
84
|
+
exports2.DB_BUSY_TIMEOUT_MS = 2e3;
|
|
85
|
+
exports2.MCP_BUSY_TIMEOUT_MS = 5e3;
|
|
86
|
+
exports2.CONFIG_FILE = "config.json";
|
|
87
|
+
exports2.DEFAULT_MODELS = {
|
|
88
|
+
ingest: "haiku",
|
|
89
|
+
evolve: "sonnet",
|
|
90
|
+
explore: "sonnet",
|
|
91
|
+
default: "haiku"
|
|
92
|
+
};
|
|
93
|
+
exports2.SCHEMA_VERSION = 1;
|
|
94
|
+
exports2.CATEGORIES = ["sources", "analyses", "domains", "episodes", "decisions", "raw", "sessions", "cc_memory", "cc-session", "cc-subagent", "diary", "insights", "connections", "learnings", "memory"];
|
|
95
|
+
exports2.SESSION_CATEGORIES = ["cc-subagent", "cc-session"];
|
|
96
|
+
function isSessionCategory(category) {
|
|
97
|
+
return exports2.SESSION_CATEGORIES.includes(category);
|
|
98
|
+
}
|
|
99
|
+
exports2.STOP_WORDS_MIN_LENGTH = 2;
|
|
100
|
+
exports2.TURKISH_WORD_RE = /[^\w\sçğıöşüÇĞİÖŞÜ-]/g;
|
|
101
|
+
exports2.STOP_WORDS = /* @__PURE__ */ new Set([
|
|
102
|
+
// English
|
|
103
|
+
"the",
|
|
104
|
+
"a",
|
|
105
|
+
"an",
|
|
106
|
+
"is",
|
|
107
|
+
"are",
|
|
108
|
+
"was",
|
|
109
|
+
"were",
|
|
110
|
+
"be",
|
|
111
|
+
"been",
|
|
112
|
+
"being",
|
|
113
|
+
"have",
|
|
114
|
+
"has",
|
|
115
|
+
"had",
|
|
116
|
+
"do",
|
|
117
|
+
"does",
|
|
118
|
+
"did",
|
|
119
|
+
"will",
|
|
120
|
+
"would",
|
|
121
|
+
"could",
|
|
122
|
+
"should",
|
|
123
|
+
"may",
|
|
124
|
+
"might",
|
|
125
|
+
"can",
|
|
126
|
+
"shall",
|
|
127
|
+
"to",
|
|
128
|
+
"of",
|
|
129
|
+
"in",
|
|
130
|
+
"for",
|
|
131
|
+
"on",
|
|
132
|
+
"with",
|
|
133
|
+
"at",
|
|
134
|
+
"by",
|
|
135
|
+
"from",
|
|
136
|
+
"as",
|
|
137
|
+
"into",
|
|
138
|
+
"through",
|
|
139
|
+
"during",
|
|
140
|
+
"it",
|
|
141
|
+
"its",
|
|
142
|
+
"this",
|
|
143
|
+
"that",
|
|
144
|
+
"these",
|
|
145
|
+
"those",
|
|
146
|
+
"what",
|
|
147
|
+
"which",
|
|
148
|
+
"who",
|
|
149
|
+
"whom",
|
|
150
|
+
"how",
|
|
151
|
+
"when",
|
|
152
|
+
"where",
|
|
153
|
+
"why",
|
|
154
|
+
"not",
|
|
155
|
+
"no",
|
|
156
|
+
"nor",
|
|
157
|
+
"so",
|
|
158
|
+
"if",
|
|
159
|
+
"or",
|
|
160
|
+
"but",
|
|
161
|
+
"all",
|
|
162
|
+
"each",
|
|
163
|
+
"every",
|
|
164
|
+
"both",
|
|
165
|
+
"few",
|
|
166
|
+
"more",
|
|
167
|
+
"most",
|
|
168
|
+
"other",
|
|
169
|
+
"some",
|
|
170
|
+
"such",
|
|
171
|
+
"only",
|
|
172
|
+
"own",
|
|
173
|
+
"same",
|
|
174
|
+
"than",
|
|
175
|
+
"and",
|
|
176
|
+
"about",
|
|
177
|
+
"between",
|
|
178
|
+
"after",
|
|
179
|
+
"before",
|
|
180
|
+
"above",
|
|
181
|
+
"below",
|
|
182
|
+
"up",
|
|
183
|
+
"down",
|
|
184
|
+
"out",
|
|
185
|
+
"very",
|
|
186
|
+
"just",
|
|
187
|
+
"also",
|
|
188
|
+
"now",
|
|
189
|
+
"then",
|
|
190
|
+
"here",
|
|
191
|
+
"there",
|
|
192
|
+
"too",
|
|
193
|
+
"yet",
|
|
194
|
+
"my",
|
|
195
|
+
"your",
|
|
196
|
+
"his",
|
|
197
|
+
"her",
|
|
198
|
+
"our",
|
|
199
|
+
"their",
|
|
200
|
+
"me",
|
|
201
|
+
"him",
|
|
202
|
+
"us",
|
|
203
|
+
"them",
|
|
204
|
+
"i",
|
|
205
|
+
"you",
|
|
206
|
+
"he",
|
|
207
|
+
"she",
|
|
208
|
+
"we",
|
|
209
|
+
"they",
|
|
210
|
+
// Turkish
|
|
211
|
+
"bir",
|
|
212
|
+
"bu",
|
|
213
|
+
"su",
|
|
214
|
+
"ne",
|
|
215
|
+
"nas\u0131l",
|
|
216
|
+
"neden",
|
|
217
|
+
"var",
|
|
218
|
+
"yok",
|
|
219
|
+
"mi",
|
|
220
|
+
"mu",
|
|
221
|
+
"m\u0131",
|
|
222
|
+
"ile",
|
|
223
|
+
"i\xE7in",
|
|
224
|
+
"de",
|
|
225
|
+
"da",
|
|
226
|
+
"ve",
|
|
227
|
+
"veya",
|
|
228
|
+
"ama",
|
|
229
|
+
"ise",
|
|
230
|
+
"hem",
|
|
231
|
+
"bakal\u0131m",
|
|
232
|
+
"gel",
|
|
233
|
+
"git",
|
|
234
|
+
"yap",
|
|
235
|
+
"et",
|
|
236
|
+
"al",
|
|
237
|
+
"ver",
|
|
238
|
+
"evet",
|
|
239
|
+
"hay\u0131r",
|
|
240
|
+
"tamam",
|
|
241
|
+
"ok",
|
|
242
|
+
"oldu",
|
|
243
|
+
"olur",
|
|
244
|
+
"dur",
|
|
245
|
+
"\u015Fimdi",
|
|
246
|
+
"sonra",
|
|
247
|
+
"\xF6nce",
|
|
248
|
+
"hemen",
|
|
249
|
+
"biraz",
|
|
250
|
+
"lan",
|
|
251
|
+
"ya",
|
|
252
|
+
"ki",
|
|
253
|
+
"abi",
|
|
254
|
+
"hadi",
|
|
255
|
+
"hey",
|
|
256
|
+
"selam",
|
|
257
|
+
"olarak",
|
|
258
|
+
"olan",
|
|
259
|
+
"gibi",
|
|
260
|
+
"kadar",
|
|
261
|
+
"daha",
|
|
262
|
+
"\xE7ok",
|
|
263
|
+
"en",
|
|
264
|
+
"bunu",
|
|
265
|
+
"buna",
|
|
266
|
+
"i\xE7inde",
|
|
267
|
+
"\xFCzerinde",
|
|
268
|
+
"aras\u0131nda",
|
|
269
|
+
"sonucu",
|
|
270
|
+
"taraf\u0131ndan",
|
|
271
|
+
"zaten",
|
|
272
|
+
"gayet",
|
|
273
|
+
"acaba",
|
|
274
|
+
"nedir",
|
|
275
|
+
"midir",
|
|
276
|
+
"mudur",
|
|
277
|
+
// Generic technical
|
|
278
|
+
"hook",
|
|
279
|
+
"file",
|
|
280
|
+
"dosya",
|
|
281
|
+
"kullan",
|
|
282
|
+
"ekle",
|
|
283
|
+
"yaz",
|
|
284
|
+
"oku",
|
|
285
|
+
"\xE7al\u0131\u015Ft\u0131r",
|
|
286
|
+
"kontrol",
|
|
287
|
+
"test",
|
|
288
|
+
"check",
|
|
289
|
+
"run",
|
|
290
|
+
"add",
|
|
291
|
+
"update",
|
|
292
|
+
"config",
|
|
293
|
+
"setup",
|
|
294
|
+
"install",
|
|
295
|
+
"start",
|
|
296
|
+
"stop",
|
|
297
|
+
"create",
|
|
298
|
+
"delete",
|
|
299
|
+
"remove",
|
|
300
|
+
"set",
|
|
301
|
+
"get",
|
|
302
|
+
"list",
|
|
303
|
+
"show",
|
|
304
|
+
"view",
|
|
305
|
+
"open",
|
|
306
|
+
"close",
|
|
307
|
+
"save",
|
|
308
|
+
"load"
|
|
309
|
+
]);
|
|
310
|
+
var VERSION_RE = /v(\d+)\.(\d+)(?:\.(\d+))?/g;
|
|
311
|
+
function fixVersionTokens(query) {
|
|
312
|
+
return query.replace(VERSION_RE, (_m, a, b, c) => c ? `"v${a} ${b} ${c}"` : `"v${a} ${b}"`);
|
|
313
|
+
}
|
|
314
|
+
exports2.FTS5_COLUMNS = ["path", "slug", "description", "type", "category", "title", "content", "tags", "quality", "date_captured", "project"];
|
|
315
|
+
exports2.FRONTMATTER_TYPES = ["raw", "source", "domain", "analysis", "diary", "decision", "insight", "connection", "learning", "feedback", "user", "project", "reference", "note"];
|
|
316
|
+
exports2.QUALITY_VALUES = ["high", "medium", "low"];
|
|
317
|
+
exports2.QUALITY_HEURISTICS = {
|
|
318
|
+
"github-repo": "high",
|
|
319
|
+
"docs": "high",
|
|
320
|
+
"blog": "medium",
|
|
321
|
+
"video": "medium",
|
|
322
|
+
"x-thread": "medium",
|
|
323
|
+
"text-paste": "low",
|
|
324
|
+
"snippet": "low",
|
|
325
|
+
"forum": "low",
|
|
326
|
+
"cc-session": "low",
|
|
327
|
+
"cc-subagent": "low"
|
|
328
|
+
};
|
|
329
|
+
exports2.RELATION_TYPES = ["cites", "extends", "contradicts", "supersedes"];
|
|
330
|
+
exports2.SYMMETRIC_TYPES = /* @__PURE__ */ new Set(["contradicts"]);
|
|
331
|
+
exports2.RELATION_PRIORITY = {
|
|
332
|
+
supersedes: 1,
|
|
333
|
+
contradicts: 2,
|
|
334
|
+
extends: 3,
|
|
335
|
+
cites: 4
|
|
336
|
+
};
|
|
337
|
+
exports2.MAX_RELATED_SOURCES = 5;
|
|
338
|
+
exports2.RELATED_OVERFETCH = 10;
|
|
339
|
+
function buildPriorityCase() {
|
|
340
|
+
return Object.entries(exports2.RELATION_PRIORITY).map(([type, priority]) => `WHEN '${type}' THEN ${priority}`).join(" ");
|
|
341
|
+
}
|
|
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.CC_MEMORY_PATH_MARKER = path_12.default.join(".claude", "projects");
|
|
359
|
+
exports2.CC_MEMORY_DIR = "memory";
|
|
360
|
+
exports2.CC_MEMORY_CATEGORY = "cc-memory";
|
|
361
|
+
exports2.CC_SESSION_CATEGORY = "cc-session";
|
|
362
|
+
exports2.CC_SUBAGENT_CATEGORY = "cc-subagent";
|
|
363
|
+
exports2.CC_MEMORY_BOOST = 1.2;
|
|
364
|
+
function homedir() {
|
|
365
|
+
return os_12.default.homedir();
|
|
366
|
+
}
|
|
367
|
+
function getActiveMindloreDir() {
|
|
368
|
+
return exports2.GLOBAL_MINDLORE_DIR;
|
|
369
|
+
}
|
|
370
|
+
function getAllDbs() {
|
|
371
|
+
const dbPath = path_12.default.join(exports2.GLOBAL_MINDLORE_DIR, exports2.DB_NAME);
|
|
372
|
+
if (fs_12.default.existsSync(dbPath))
|
|
373
|
+
return [dbPath];
|
|
374
|
+
return [];
|
|
375
|
+
}
|
|
376
|
+
function getProjectName() {
|
|
377
|
+
return path_12.default.basename(process.cwd());
|
|
378
|
+
}
|
|
379
|
+
function log(msg) {
|
|
380
|
+
console.log(` ${msg}`);
|
|
381
|
+
}
|
|
382
|
+
function isContentFile(filePath) {
|
|
383
|
+
return !exports2.SKIP_FILES.has(path_12.default.basename(filePath));
|
|
384
|
+
}
|
|
385
|
+
function resolveHookCommon(callerDir) {
|
|
386
|
+
let dir = callerDir;
|
|
387
|
+
for (let i = 0; i < 5; i++) {
|
|
388
|
+
const target = path_12.default.join(dir, "hooks", "lib", "mindlore-common.cjs");
|
|
389
|
+
if (fs_12.default.existsSync(target))
|
|
390
|
+
return target;
|
|
391
|
+
const parent = path_12.default.dirname(dir);
|
|
392
|
+
if (parent === dir)
|
|
393
|
+
break;
|
|
394
|
+
dir = parent;
|
|
395
|
+
}
|
|
396
|
+
return path_12.default.resolve(callerDir, "..", "..", "hooks", "lib", "mindlore-common.cjs");
|
|
397
|
+
}
|
|
398
|
+
function hasYoutubeTranscript() {
|
|
399
|
+
try {
|
|
400
|
+
require.resolve("youtube-transcript");
|
|
401
|
+
return true;
|
|
402
|
+
} catch (_err) {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
exports2.DEFAULT_TOKEN_BUDGET = {
|
|
407
|
+
sessionInject: 2e3,
|
|
408
|
+
searchResults: 1500,
|
|
409
|
+
perResult: 500
|
|
410
|
+
};
|
|
411
|
+
exports2.DECAY_HALF_LIFE_DAYS = 30;
|
|
412
|
+
exports2.STALE_THRESHOLD = 0.3;
|
|
413
|
+
exports2.CONSOLIDATION_THRESHOLD = 50;
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
// dist/scripts/lib/privacy-filter.js
|
|
418
|
+
var require_privacy_filter = __commonJS({
|
|
419
|
+
"dist/scripts/lib/privacy-filter.js"(exports2) {
|
|
420
|
+
"use strict";
|
|
421
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
422
|
+
exports2.DEFAULT_PATTERNS = void 0;
|
|
423
|
+
exports2.redactSecrets = redactSecrets;
|
|
424
|
+
var REPLACEMENT = "[REDACTED]";
|
|
425
|
+
var PATTERN_PREFIXES = [
|
|
426
|
+
{ prefix: "sk-", pattern: /sk-(?:proj-|ant-)?[A-Za-z0-9_-]{20,}/g },
|
|
427
|
+
{ prefix: "AKIA", pattern: /AKIA[0-9A-Z]{16}/g },
|
|
428
|
+
{ prefix: "ghp_", pattern: /ghp_[A-Za-z0-9]{36,}/g },
|
|
429
|
+
{ prefix: "gho_", pattern: /gho_[A-Za-z0-9]{36,}/g },
|
|
430
|
+
{ prefix: "github_pat_", pattern: /github_pat_[A-Za-z0-9_]{22,}/g },
|
|
431
|
+
{ prefix: "npm_", pattern: /npm_[A-Za-z0-9]{36,}/g },
|
|
432
|
+
{ prefix: "xox", pattern: /xox[bporas]-[A-Za-z0-9-]{10,}/g },
|
|
433
|
+
{ prefix: "eyJ", pattern: /eyJ[a-zA-Z0-9_\-]{20,}\.[a-zA-Z0-9_\-]{20,}\.[a-zA-Z0-9_\-]{20,}/g },
|
|
434
|
+
{ prefix: "AIza", pattern: /AIza[0-9A-Za-z_\-]{30,}/g },
|
|
435
|
+
{ prefix: "sk_live_", pattern: /sk_live_[a-zA-Z0-9]{20,}/g },
|
|
436
|
+
{ prefix: "pk_live_", pattern: /pk_live_[a-zA-Z0-9]{20,}/g },
|
|
437
|
+
{ prefix: "Bearer", pattern: /Bearer\s+[a-zA-Z0-9\-._~+/]+=*/g },
|
|
438
|
+
{ prefix: "-----BEGIN", pattern: /-----BEGIN\s(?:RSA\s|EC\s|DSA\s|OPENSSH\s)?PRIVATE\sKEY-----/g },
|
|
439
|
+
{ prefix: "Basic", pattern: /Basic\s+[a-zA-Z0-9+\/]{16,}={0,2}/g },
|
|
440
|
+
{ prefix: "-----BEGIN CERTIFICATE", pattern: /-----BEGIN\sCERTIFICATE-----/g }
|
|
441
|
+
];
|
|
442
|
+
var NO_PREFIX_PATTERNS = [
|
|
443
|
+
/(?:postgres|mysql|mongodb|redis|amqp)(?:\+srv)?:\/\/[^\s"']+/g,
|
|
444
|
+
/(?:PASSWORD|SECRET|TOKEN|API_KEY|PRIVATE_KEY|DATABASE_URL|DB_PASSWORD|AUTH_TOKEN|ACCESS_KEY|SECRET_KEY)=\S+/gi,
|
|
445
|
+
/(?:api_key|auth_token|access_token|refresh_token|client_secret|private_key|secret_key)\s*[:=]\s*["']?[^\s"',}{]{8,}["']?/gi
|
|
446
|
+
];
|
|
447
|
+
exports2.DEFAULT_PATTERNS = [
|
|
448
|
+
...PATTERN_PREFIXES.map((p) => p.pattern),
|
|
449
|
+
...NO_PREFIX_PATTERNS
|
|
450
|
+
];
|
|
451
|
+
function redactSecrets(text, extraPatterns) {
|
|
452
|
+
let result = text;
|
|
453
|
+
for (const { prefix, pattern } of PATTERN_PREFIXES) {
|
|
454
|
+
if (result.includes(prefix)) {
|
|
455
|
+
pattern.lastIndex = 0;
|
|
456
|
+
result = result.replace(pattern, REPLACEMENT);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
const remaining = extraPatterns ? [...NO_PREFIX_PATTERNS, ...extraPatterns] : NO_PREFIX_PATTERNS;
|
|
460
|
+
for (const pattern of remaining) {
|
|
461
|
+
pattern.lastIndex = 0;
|
|
462
|
+
result = result.replace(pattern, REPLACEMENT);
|
|
463
|
+
}
|
|
464
|
+
return result;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// dist/scripts/lib/sync-helpers.js
|
|
470
|
+
var require_sync_helpers = __commonJS({
|
|
471
|
+
"dist/scripts/lib/sync-helpers.js"(exports2) {
|
|
472
|
+
"use strict";
|
|
473
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
474
|
+
exports2.UPSERT_HASH_SQL = void 0;
|
|
475
|
+
exports2.getArg = getArg;
|
|
476
|
+
exports2.UPSERT_HASH_SQL = `
|
|
477
|
+
INSERT INTO file_hashes (path, content_hash, last_indexed, source_type)
|
|
478
|
+
VALUES (?, ?, ?, ?)
|
|
479
|
+
ON CONFLICT(path) DO UPDATE SET
|
|
480
|
+
content_hash = excluded.content_hash,
|
|
481
|
+
last_indexed = excluded.last_indexed,
|
|
482
|
+
source_type = excluded.source_type
|
|
483
|
+
`;
|
|
484
|
+
function getArg(args, flag) {
|
|
485
|
+
const idx = args.indexOf(flag);
|
|
486
|
+
return idx !== -1 ? args[idx + 1] : void 0;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
// dist/scripts/lib/secure-io.js
|
|
492
|
+
var require_secure_io = __commonJS({
|
|
493
|
+
"dist/scripts/lib/secure-io.js"(exports2) {
|
|
494
|
+
"use strict";
|
|
495
|
+
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
496
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
497
|
+
};
|
|
498
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
499
|
+
exports2.safeMkdir = safeMkdir;
|
|
500
|
+
exports2.safeWriteFile = safeWriteFile;
|
|
501
|
+
exports2.safeWriteJson = safeWriteJson;
|
|
502
|
+
var fs_12 = __importDefault2(require("fs"));
|
|
503
|
+
function safeMkdir(dirPath) {
|
|
504
|
+
fs_12.default.mkdirSync(dirPath, { recursive: true, mode: 448 });
|
|
505
|
+
}
|
|
506
|
+
function safeWriteFile(filePath, data) {
|
|
507
|
+
fs_12.default.writeFileSync(filePath, data, { encoding: "utf8", mode: 384 });
|
|
508
|
+
}
|
|
509
|
+
function safeWriteJson(filePath, obj) {
|
|
510
|
+
safeWriteFile(filePath, JSON.stringify(obj, null, 2) + "\n");
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
// dist/scripts/lib/err-msg.js
|
|
516
|
+
var require_err_msg = __commonJS({
|
|
517
|
+
"dist/scripts/lib/err-msg.js"(exports2) {
|
|
518
|
+
"use strict";
|
|
519
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
520
|
+
exports2.errMsg = errMsg;
|
|
521
|
+
function errMsg(err) {
|
|
522
|
+
return err instanceof Error ? err.message : String(err);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
// dist/scripts/cc-session-sync.js
|
|
528
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
529
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
530
|
+
};
|
|
531
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
532
|
+
exports.DECISION_KEYWORDS = void 0;
|
|
533
|
+
exports.discoverSessionFiles = discoverSessionFiles;
|
|
534
|
+
exports.convertJsonlToMd = convertJsonlToMd;
|
|
535
|
+
exports.extractSessionSummary = extractSessionSummary;
|
|
536
|
+
exports.syncSessions = syncSessions;
|
|
537
|
+
var fs_1 = __importDefault(require("fs"));
|
|
538
|
+
var path_1 = __importDefault(require("path"));
|
|
539
|
+
var os_1 = __importDefault(require("os"));
|
|
540
|
+
var constants_js_1 = require_constants();
|
|
541
|
+
var privacy_filter_js_1 = require_privacy_filter();
|
|
542
|
+
var sync_helpers_js_1 = require_sync_helpers();
|
|
543
|
+
var secure_io_js_1 = require_secure_io();
|
|
544
|
+
var err_msg_js_1 = require_err_msg();
|
|
545
|
+
function discoverSessionFiles(claudeDir) {
|
|
546
|
+
const projectsDir = path_1.default.join(claudeDir, "projects");
|
|
547
|
+
if (!fs_1.default.existsSync(projectsDir))
|
|
548
|
+
return [];
|
|
549
|
+
const results = [];
|
|
550
|
+
let projectEntries;
|
|
551
|
+
try {
|
|
552
|
+
projectEntries = fs_1.default.readdirSync(projectsDir, { withFileTypes: true });
|
|
553
|
+
} catch {
|
|
554
|
+
return [];
|
|
555
|
+
}
|
|
556
|
+
for (const entry of projectEntries) {
|
|
557
|
+
if (!entry.isDirectory())
|
|
558
|
+
continue;
|
|
559
|
+
const projDir = path_1.default.join(projectsDir, entry.name);
|
|
560
|
+
let files;
|
|
561
|
+
try {
|
|
562
|
+
files = fs_1.default.readdirSync(projDir, { withFileTypes: true });
|
|
563
|
+
} catch {
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
for (const f of files) {
|
|
567
|
+
if (f.isFile() && f.name.endsWith(".jsonl")) {
|
|
568
|
+
const sessionId = f.name.replace(".jsonl", "");
|
|
569
|
+
const fullPath = path_1.default.join(projDir, f.name);
|
|
570
|
+
const stat = fs_1.default.statSync(fullPath);
|
|
571
|
+
results.push({ jsonlPath: fullPath, sessionId, projectName: entry.name, mtime: stat.mtime });
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
if (f.isDirectory() && f.name !== "memory") {
|
|
575
|
+
const subagentsDir = path_1.default.join(projDir, f.name, "subagents");
|
|
576
|
+
let subFiles;
|
|
577
|
+
try {
|
|
578
|
+
subFiles = fs_1.default.readdirSync(subagentsDir, { withFileTypes: true });
|
|
579
|
+
} catch {
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
for (const sf of subFiles) {
|
|
583
|
+
if (!sf.isFile() || !sf.name.endsWith(".jsonl"))
|
|
584
|
+
continue;
|
|
585
|
+
const sessionId = sf.name.replace(".jsonl", "");
|
|
586
|
+
const fullPath = path_1.default.join(subagentsDir, sf.name);
|
|
587
|
+
const stat = fs_1.default.statSync(fullPath);
|
|
588
|
+
results.push({ jsonlPath: fullPath, sessionId, projectName: entry.name, mtime: stat.mtime });
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return results;
|
|
594
|
+
}
|
|
595
|
+
function projectSlug(projectName) {
|
|
596
|
+
const prefixMatch = projectName.match(/^C--Users-([^-]+)-(.*)$/);
|
|
597
|
+
if (!prefixMatch?.[2])
|
|
598
|
+
return projectName;
|
|
599
|
+
const rest = prefixMatch[2];
|
|
600
|
+
const KNOWN_USER_DIRS = ["Desktop", "Documents", "Downloads", "Projects", "dev"];
|
|
601
|
+
for (const loc of KNOWN_USER_DIRS) {
|
|
602
|
+
if (rest.startsWith(loc + "-")) {
|
|
603
|
+
return rest.substring(loc.length + 1);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return rest.replace(/^-+/, "") || projectName;
|
|
607
|
+
}
|
|
608
|
+
function extractSessionMeta(lines) {
|
|
609
|
+
let date = "unknown";
|
|
610
|
+
let branch = "";
|
|
611
|
+
let cwd = "";
|
|
612
|
+
let startTime = "";
|
|
613
|
+
for (const line of lines.slice(0, 20)) {
|
|
614
|
+
try {
|
|
615
|
+
const obj = JSON.parse(line);
|
|
616
|
+
if (obj.timestamp && date === "unknown") {
|
|
617
|
+
date = obj.timestamp.substring(0, 10);
|
|
618
|
+
startTime = obj.timestamp;
|
|
619
|
+
}
|
|
620
|
+
if (obj.gitBranch && !branch)
|
|
621
|
+
branch = obj.gitBranch;
|
|
622
|
+
if (obj.cwd && !cwd)
|
|
623
|
+
cwd = obj.cwd;
|
|
624
|
+
} catch {
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return { date, branch, cwd, startTime };
|
|
629
|
+
}
|
|
630
|
+
function convertJsonlToMd(jsonlPath, projectName) {
|
|
631
|
+
const raw = fs_1.default.readFileSync(jsonlPath, "utf8").replace(/\r\n/g, "\n");
|
|
632
|
+
const lines = raw.trim().split("\n");
|
|
633
|
+
const meta = extractSessionMeta(lines);
|
|
634
|
+
const slug = projectSlug(projectName);
|
|
635
|
+
const sessionId = path_1.default.basename(jsonlPath, ".jsonl");
|
|
636
|
+
const isSubagent = sessionId.startsWith("agent-");
|
|
637
|
+
const mdParts = [];
|
|
638
|
+
let userCount = 0;
|
|
639
|
+
let assistantCount = 0;
|
|
640
|
+
for (const line of lines) {
|
|
641
|
+
let obj;
|
|
642
|
+
try {
|
|
643
|
+
obj = JSON.parse(line);
|
|
644
|
+
} catch {
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
if (obj.type === "user" || obj.type === "assistant") {
|
|
648
|
+
const content = obj.message?.content;
|
|
649
|
+
const role = obj.type === "user" ? "User" : "Assistant";
|
|
650
|
+
const texts = [];
|
|
651
|
+
if (typeof content === "string" && content.trim()) {
|
|
652
|
+
texts.push(content.trim());
|
|
653
|
+
} else if (Array.isArray(content)) {
|
|
654
|
+
for (const block of content) {
|
|
655
|
+
if (block.type === "text" && block.text?.trim()) {
|
|
656
|
+
texts.push(block.text.trim());
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
for (const text of texts) {
|
|
661
|
+
const cleaned = (0, privacy_filter_js_1.redactSecrets)(text);
|
|
662
|
+
mdParts.push(`## ${role}
|
|
663
|
+
|
|
664
|
+
${cleaned}
|
|
665
|
+
`);
|
|
666
|
+
if (obj.type === "user")
|
|
667
|
+
userCount++;
|
|
668
|
+
else
|
|
669
|
+
assistantCount++;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
const frontmatter = [
|
|
674
|
+
"---",
|
|
675
|
+
`type: raw`,
|
|
676
|
+
`project: ${slug}`,
|
|
677
|
+
`session_id: ${sessionId}`,
|
|
678
|
+
`date: ${meta.date}`,
|
|
679
|
+
meta.startTime ? `start_time: ${meta.startTime}` : null,
|
|
680
|
+
meta.branch ? `branch: ${meta.branch}` : null,
|
|
681
|
+
`messages: ${userCount} user, ${assistantCount} assistant`,
|
|
682
|
+
`category: ${isSubagent ? "cc-subagent" : "cc-session"}`,
|
|
683
|
+
"---",
|
|
684
|
+
"",
|
|
685
|
+
`# ${isSubagent ? "Subagent" : "Session"} ${meta.date} \u2014 ${slug}`,
|
|
686
|
+
""
|
|
687
|
+
].filter(Boolean).join("\n");
|
|
688
|
+
const md = frontmatter + mdParts.join("\n");
|
|
689
|
+
return { md, date: meta.date, userCount, assistantCount, isSubagent };
|
|
690
|
+
}
|
|
691
|
+
exports.DECISION_KEYWORDS = [
|
|
692
|
+
"karar:",
|
|
693
|
+
"ertele",
|
|
694
|
+
"se\xE7tik",
|
|
695
|
+
"yapma:",
|
|
696
|
+
"decision:",
|
|
697
|
+
"defer",
|
|
698
|
+
"chose",
|
|
699
|
+
"skip:",
|
|
700
|
+
"blocker:",
|
|
701
|
+
"ertelendi"
|
|
702
|
+
];
|
|
703
|
+
function extractSessionSummary(transcriptMd) {
|
|
704
|
+
const lines = transcriptMd.split("\n");
|
|
705
|
+
const userMessages = [];
|
|
706
|
+
const decisions = [];
|
|
707
|
+
let inUser = false;
|
|
708
|
+
for (const line of lines) {
|
|
709
|
+
if (line.startsWith("## User")) {
|
|
710
|
+
inUser = true;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (line.startsWith("## ")) {
|
|
714
|
+
inUser = false;
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
if (inUser && line.trim()) {
|
|
718
|
+
userMessages.push(line.trim());
|
|
719
|
+
const lower = line.toLowerCase();
|
|
720
|
+
if (exports.DECISION_KEYWORDS.some((kw) => lower.includes(kw))) {
|
|
721
|
+
decisions.push(line.trim());
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (userMessages.length === 0)
|
|
726
|
+
return "";
|
|
727
|
+
const firstIntent = userMessages[0]?.slice(0, 100) ?? "";
|
|
728
|
+
const lastIntent = userMessages[userMessages.length - 1]?.slice(0, 100) ?? "";
|
|
729
|
+
const parts = [`Intent: ${firstIntent}`];
|
|
730
|
+
if (lastIntent && lastIntent !== firstIntent) {
|
|
731
|
+
parts.push(`Son: ${lastIntent}`);
|
|
732
|
+
}
|
|
733
|
+
if (decisions.length > 0) {
|
|
734
|
+
parts.push(`Kararlar: ${decisions.slice(0, 5).join("; ")}`);
|
|
735
|
+
}
|
|
736
|
+
return parts.join(" | ");
|
|
737
|
+
}
|
|
738
|
+
function sessionShortId(sessionId) {
|
|
739
|
+
return sessionId.startsWith("agent-") ? sessionId.slice(-8) : sessionId.substring(0, 8);
|
|
740
|
+
}
|
|
741
|
+
var ACTIVE_SESSION_THRESHOLD_MS = 2 * 60 * 1e3;
|
|
742
|
+
function syncSessions(dbPath, sessions, mindloreDir) {
|
|
743
|
+
const result = { synced: 0, skipped: 0, errors: [] };
|
|
744
|
+
if (sessions.length === 0)
|
|
745
|
+
return result;
|
|
746
|
+
const common = require((0, constants_js_1.resolveHookCommon)(__dirname));
|
|
747
|
+
const { sha256, insertFtsRow, openDatabase } = common;
|
|
748
|
+
const db = openDatabase(dbPath);
|
|
749
|
+
if (!db) {
|
|
750
|
+
result.errors.push(`Cannot open DB at ${dbPath}`);
|
|
751
|
+
return result;
|
|
752
|
+
}
|
|
753
|
+
const getHash = db.prepare("SELECT content_hash, last_indexed FROM file_hashes WHERE path = ?");
|
|
754
|
+
const upsertHash = db.prepare(sync_helpers_js_1.UPSERT_HASH_SQL);
|
|
755
|
+
const deleteFts = db.prepare("DELETE FROM mindlore_fts WHERE path = ?");
|
|
756
|
+
const now = /* @__PURE__ */ new Date();
|
|
757
|
+
const nowIso = now.toISOString();
|
|
758
|
+
const ops = [];
|
|
759
|
+
for (const session of sessions) {
|
|
760
|
+
const slug = projectSlug(session.projectName);
|
|
761
|
+
const shortId = sessionShortId(session.sessionId);
|
|
762
|
+
try {
|
|
763
|
+
const ageMs = now.getTime() - session.mtime.getTime();
|
|
764
|
+
if (ageMs < ACTIVE_SESSION_THRESHOLD_MS) {
|
|
765
|
+
result.skipped++;
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
const destDir = path_1.default.join(mindloreDir, "raw", "sessions", slug);
|
|
769
|
+
const matchingFiles = fs_1.default.existsSync(destDir) ? fs_1.default.readdirSync(destDir).filter((f) => f.includes(shortId)) : [];
|
|
770
|
+
const firstMatch = matchingFiles[0];
|
|
771
|
+
if (firstMatch) {
|
|
772
|
+
const existingPath = path_1.default.join(destDir, firstMatch);
|
|
773
|
+
const cached = getHash.get(existingPath);
|
|
774
|
+
if (cached && session.mtime <= new Date(cached.last_indexed)) {
|
|
775
|
+
result.skipped++;
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
const { md, date: sessionDate, userCount, assistantCount, isSubagent } = convertJsonlToMd(session.jsonlPath, session.projectName);
|
|
780
|
+
if (userCount === 0 && assistantCount === 0) {
|
|
781
|
+
result.skipped++;
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
const hash = sha256(md);
|
|
785
|
+
const destPath = path_1.default.join(destDir, `${sessionDate}-${shortId}.md`);
|
|
786
|
+
const existing = getHash.get(destPath);
|
|
787
|
+
if (existing && existing.content_hash === hash) {
|
|
788
|
+
result.skipped++;
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
(0, secure_io_js_1.safeMkdir)(destDir);
|
|
792
|
+
(0, secure_io_js_1.safeWriteFile)(destPath, md);
|
|
793
|
+
ops.push({ destPath, hash, sessionDate, shortId, slug, md, isSubagent });
|
|
794
|
+
} catch (err) {
|
|
795
|
+
const msg = (0, err_msg_js_1.errMsg)(err);
|
|
796
|
+
result.errors.push(`${shortId}: ${msg}`);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
const syncOne = db.transaction((op) => {
|
|
800
|
+
const category = op.isSubagent ? constants_js_1.CC_SUBAGENT_CATEGORY : constants_js_1.CC_SESSION_CATEGORY;
|
|
801
|
+
deleteFts.run(op.destPath);
|
|
802
|
+
insertFtsRow(db, {
|
|
803
|
+
path: op.destPath,
|
|
804
|
+
slug: `session-${op.sessionDate}-${op.shortId}`,
|
|
805
|
+
description: `CC ${op.isSubagent ? "subagent" : "session"} transcript \u2014 ${op.slug} \u2014 ${op.sessionDate}`,
|
|
806
|
+
type: "raw",
|
|
807
|
+
category,
|
|
808
|
+
title: `${op.isSubagent ? "Subagent" : "Session"} ${op.sessionDate} \u2014 ${op.slug}`,
|
|
809
|
+
content: op.md,
|
|
810
|
+
tags: `${op.isSubagent ? "subagent" : "session"},${op.slug},transcript`,
|
|
811
|
+
dateCaptured: op.sessionDate,
|
|
812
|
+
project: op.slug
|
|
813
|
+
});
|
|
814
|
+
upsertHash.run(op.destPath, op.hash, nowIso, category);
|
|
815
|
+
if (!op.isSubagent) {
|
|
816
|
+
try {
|
|
817
|
+
const sessionSummary = extractSessionSummary(op.md);
|
|
818
|
+
if (sessionSummary) {
|
|
819
|
+
const epSlug = `session-summary-${op.sessionDate}-${op.shortId}`;
|
|
820
|
+
const shortSummary = sessionSummary.slice(0, 300);
|
|
821
|
+
db.prepare(`INSERT OR REPLACE INTO episodes (id, kind, scope, project, summary, session_summary, created_at)
|
|
822
|
+
VALUES (?, 'session-summary', 'project', ?, ?, ?, ?)`).run(epSlug, op.slug, shortSummary, sessionSummary, nowIso);
|
|
823
|
+
}
|
|
824
|
+
} catch {
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
result.synced++;
|
|
828
|
+
});
|
|
829
|
+
for (const op of ops) {
|
|
830
|
+
try {
|
|
831
|
+
syncOne(op);
|
|
832
|
+
} catch (err) {
|
|
833
|
+
const msg = (0, err_msg_js_1.errMsg)(err);
|
|
834
|
+
result.errors.push(`${op.shortId}: ${msg}`);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
db.close();
|
|
838
|
+
return result;
|
|
839
|
+
}
|
|
840
|
+
var isMain = typeof require !== "undefined" && require.main === module;
|
|
841
|
+
if (isMain) {
|
|
842
|
+
const args = process.argv.slice(2);
|
|
843
|
+
const claudeDir = (0, sync_helpers_js_1.getArg)(args, "--claude-dir") ?? path_1.default.join(os_1.default.homedir(), ".claude");
|
|
844
|
+
const mindloreDir = (0, sync_helpers_js_1.getArg)(args, "--mindlore-dir") ?? constants_js_1.GLOBAL_MINDLORE_DIR;
|
|
845
|
+
const dbPath = (0, sync_helpers_js_1.getArg)(args, "--db") ?? path_1.default.join(mindloreDir, constants_js_1.DB_NAME);
|
|
846
|
+
const sessions = discoverSessionFiles(claudeDir);
|
|
847
|
+
console.log(` Discovered ${sessions.length} session file(s)`);
|
|
848
|
+
const result = syncSessions(dbPath, sessions, mindloreDir);
|
|
849
|
+
console.log(` Synced: ${result.synced}, Skipped: ${result.skipped}, Errors: ${result.errors.length}`);
|
|
850
|
+
if (result.errors.length > 0) {
|
|
851
|
+
for (const e of result.errors) {
|
|
852
|
+
console.error(` ERROR: ${e}`);
|
|
853
|
+
}
|
|
854
|
+
process.exit(1);
|
|
855
|
+
}
|
|
856
|
+
}
|