grepmax 0.7.30 → 0.7.31
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.
|
@@ -103,11 +103,18 @@ function startWatcher(opts) {
|
|
|
103
103
|
clearTimeout(debounceTimer);
|
|
104
104
|
debounceTimer = setTimeout(() => processBatch(), DEBOUNCE_MS);
|
|
105
105
|
};
|
|
106
|
+
const BATCH_TIMEOUT_MS = 120000;
|
|
106
107
|
const processBatch = () => __awaiter(this, void 0, void 0, function* () {
|
|
107
108
|
var _a;
|
|
108
109
|
if (closed || processing || pending.size === 0)
|
|
109
110
|
return;
|
|
110
111
|
processing = true;
|
|
112
|
+
const batchTimeout = setTimeout(() => {
|
|
113
|
+
if (processing) {
|
|
114
|
+
console.error("[watch] Batch processing timed out after 120s, resetting");
|
|
115
|
+
processing = false;
|
|
116
|
+
}
|
|
117
|
+
}, BATCH_TIMEOUT_MS);
|
|
111
118
|
const batch = new Map(pending);
|
|
112
119
|
pending.clear();
|
|
113
120
|
(0, logger_1.log)("watch", `Processing ${batch.size} changed files`);
|
|
@@ -209,39 +216,6 @@ function startWatcher(opts) {
|
|
|
209
216
|
finally {
|
|
210
217
|
yield lock.release();
|
|
211
218
|
}
|
|
212
|
-
// Summarize new/changed chunks outside the lock (sequential, no GPU contention)
|
|
213
|
-
if (changedIds.length > 0) {
|
|
214
|
-
try {
|
|
215
|
-
const table = yield vectorDb.ensureTable();
|
|
216
|
-
for (const id of changedIds) {
|
|
217
|
-
const escaped = (0, filter_builder_1.escapeSqlString)(id);
|
|
218
|
-
const rows = yield table
|
|
219
|
-
.query()
|
|
220
|
-
.select(["id", "path", "content"])
|
|
221
|
-
.where(`id = '${escaped}'`)
|
|
222
|
-
.limit(1)
|
|
223
|
-
.toArray();
|
|
224
|
-
if (rows.length === 0)
|
|
225
|
-
continue;
|
|
226
|
-
const r = rows[0];
|
|
227
|
-
const lang = path.extname(String(r.path || "")).replace(/^\./, "") ||
|
|
228
|
-
"unknown";
|
|
229
|
-
const summaries = yield (0, llm_client_1.summarizeChunks)([
|
|
230
|
-
{
|
|
231
|
-
code: String(r.content || ""),
|
|
232
|
-
language: lang,
|
|
233
|
-
file: String(r.path || ""),
|
|
234
|
-
},
|
|
235
|
-
]);
|
|
236
|
-
if (summaries === null || summaries === void 0 ? void 0 : summaries[0]) {
|
|
237
|
-
yield vectorDb.updateRows([id], "summary", [summaries[0]]);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch (_b) {
|
|
242
|
-
// Summarizer unavailable — skip silently
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
219
|
if (reindexed > 0) {
|
|
246
220
|
const duration = Date.now() - start;
|
|
247
221
|
onReindex === null || onReindex === void 0 ? void 0 : onReindex(reindexed, duration);
|
|
@@ -280,12 +254,48 @@ function startWatcher(opts) {
|
|
|
280
254
|
}
|
|
281
255
|
}
|
|
282
256
|
finally {
|
|
257
|
+
clearTimeout(batchTimeout);
|
|
283
258
|
processing = false;
|
|
284
259
|
// Process any events that came in while we were processing
|
|
285
260
|
if (pending.size > 0) {
|
|
286
261
|
scheduleBatch();
|
|
287
262
|
}
|
|
288
263
|
}
|
|
264
|
+
// Fire-and-forget summarization — doesn't block the next batch
|
|
265
|
+
if (changedIds.length > 0) {
|
|
266
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
try {
|
|
268
|
+
const table = yield vectorDb.ensureTable();
|
|
269
|
+
for (const id of changedIds) {
|
|
270
|
+
const escaped = (0, filter_builder_1.escapeSqlString)(id);
|
|
271
|
+
const rows = yield table
|
|
272
|
+
.query()
|
|
273
|
+
.select(["id", "path", "content"])
|
|
274
|
+
.where(`id = '${escaped}'`)
|
|
275
|
+
.limit(1)
|
|
276
|
+
.toArray();
|
|
277
|
+
if (rows.length === 0)
|
|
278
|
+
continue;
|
|
279
|
+
const r = rows[0];
|
|
280
|
+
const lang = path.extname(String(r.path || "")).replace(/^\./, "") ||
|
|
281
|
+
"unknown";
|
|
282
|
+
const summaries = yield (0, llm_client_1.summarizeChunks)([
|
|
283
|
+
{
|
|
284
|
+
code: String(r.content || ""),
|
|
285
|
+
language: lang,
|
|
286
|
+
file: String(r.path || ""),
|
|
287
|
+
},
|
|
288
|
+
]);
|
|
289
|
+
if (summaries === null || summaries === void 0 ? void 0 : summaries[0]) {
|
|
290
|
+
yield vectorDb.updateRows([id], "summary", [summaries[0]]);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
catch (_a) {
|
|
295
|
+
// Summarizer unavailable — skip
|
|
296
|
+
}
|
|
297
|
+
}))();
|
|
298
|
+
}
|
|
289
299
|
});
|
|
290
300
|
const onFileEvent = (event, absPath) => {
|
|
291
301
|
if (closed)
|
|
@@ -304,7 +314,7 @@ function startWatcher(opts) {
|
|
|
304
314
|
watcher.on("unlink", (p) => onFileEvent("unlink", p));
|
|
305
315
|
// Periodic FTS rebuild
|
|
306
316
|
const ftsInterval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
307
|
-
if (closed)
|
|
317
|
+
if (closed || processing)
|
|
308
318
|
return;
|
|
309
319
|
try {
|
|
310
320
|
yield vectorDb.createFTSIndex();
|
package/package.json
CHANGED