grepmax 0.7.42 → 0.7.43
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.
|
@@ -47,14 +47,12 @@ exports.startWatcher = startWatcher;
|
|
|
47
47
|
const fs = __importStar(require("node:fs"));
|
|
48
48
|
const path = __importStar(require("node:path"));
|
|
49
49
|
const chokidar_1 = require("chokidar");
|
|
50
|
-
const filter_builder_1 = require("../utils/filter-builder");
|
|
51
50
|
const config_1 = require("../../config");
|
|
52
51
|
const cache_check_1 = require("../utils/cache-check");
|
|
53
52
|
const file_utils_1 = require("../utils/file-utils");
|
|
54
53
|
const logger_1 = require("../utils/logger");
|
|
55
54
|
const lock_1 = require("../utils/lock");
|
|
56
55
|
const pool_1 = require("../workers/pool");
|
|
57
|
-
const llm_client_1 = require("../workers/summarize/llm-client");
|
|
58
56
|
const watcher_batch_1 = require("./watcher-batch");
|
|
59
57
|
// Chokidar ignored — must exclude heavy directories to keep FD count low.
|
|
60
58
|
// On macOS, chokidar uses FSEvents (single FD) but falls back to fs.watch()
|
|
@@ -87,7 +85,6 @@ function startWatcher(opts) {
|
|
|
87
85
|
let closed = false;
|
|
88
86
|
let consecutiveLockFailures = 0;
|
|
89
87
|
let currentBatchAc = null;
|
|
90
|
-
let summarizationAc = null;
|
|
91
88
|
const MAX_RETRIES = 5;
|
|
92
89
|
// macOS: FSEvents is a single-FD kernel API — no EMFILE risk and no polling.
|
|
93
90
|
// Linux: inotify is event-driven but uses one FD per watch; fall back to
|
|
@@ -128,7 +125,6 @@ function startWatcher(opts) {
|
|
|
128
125
|
(0, logger_1.log)(wtag, `Processing ${batch.size} changed files: ${filenames.join(", ")}`);
|
|
129
126
|
const start = Date.now();
|
|
130
127
|
let reindexed = 0;
|
|
131
|
-
const changedIds = [];
|
|
132
128
|
try {
|
|
133
129
|
const lock = yield (0, lock_1.acquireWriterLockWithRetry)(dataDir, {
|
|
134
130
|
maxRetries: 3,
|
|
@@ -182,10 +178,6 @@ function startWatcher(opts) {
|
|
|
182
178
|
deletes.push(absPath);
|
|
183
179
|
if (result.vectors.length > 0) {
|
|
184
180
|
vectors.push(...result.vectors);
|
|
185
|
-
// Track IDs of new vectors for summarization
|
|
186
|
-
for (const v of result.vectors) {
|
|
187
|
-
changedIds.push(v.id);
|
|
188
|
-
}
|
|
189
181
|
}
|
|
190
182
|
metaUpdates.set(absPath, metaEntry);
|
|
191
183
|
reindexed++;
|
|
@@ -272,48 +264,6 @@ function startWatcher(opts) {
|
|
|
272
264
|
scheduleBatch();
|
|
273
265
|
}
|
|
274
266
|
}
|
|
275
|
-
// Cancel previous summarization before starting a new one
|
|
276
|
-
summarizationAc === null || summarizationAc === void 0 ? void 0 : summarizationAc.abort();
|
|
277
|
-
summarizationAc = new AbortController();
|
|
278
|
-
const sumSignal = summarizationAc.signal;
|
|
279
|
-
if (changedIds.length > 0) {
|
|
280
|
-
(() => __awaiter(this, void 0, void 0, function* () {
|
|
281
|
-
try {
|
|
282
|
-
const table = yield vectorDb.ensureTable();
|
|
283
|
-
for (const id of changedIds) {
|
|
284
|
-
if (sumSignal.aborted)
|
|
285
|
-
break;
|
|
286
|
-
const escaped = (0, filter_builder_1.escapeSqlString)(id);
|
|
287
|
-
const rows = yield table
|
|
288
|
-
.query()
|
|
289
|
-
.select(["id", "path", "content"])
|
|
290
|
-
.where(`id = '${escaped}'`)
|
|
291
|
-
.limit(1)
|
|
292
|
-
.toArray();
|
|
293
|
-
if (rows.length === 0)
|
|
294
|
-
continue;
|
|
295
|
-
const r = rows[0];
|
|
296
|
-
const lang = path.extname(String(r.path || "")).replace(/^\./, "") ||
|
|
297
|
-
"unknown";
|
|
298
|
-
const summaries = yield (0, llm_client_1.summarizeChunks)([
|
|
299
|
-
{
|
|
300
|
-
code: String(r.content || ""),
|
|
301
|
-
language: lang,
|
|
302
|
-
file: String(r.path || ""),
|
|
303
|
-
},
|
|
304
|
-
]);
|
|
305
|
-
if (sumSignal.aborted)
|
|
306
|
-
break;
|
|
307
|
-
if (summaries === null || summaries === void 0 ? void 0 : summaries[0]) {
|
|
308
|
-
yield vectorDb.updateRows([id], "summary", [summaries[0]]);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
catch (_a) {
|
|
313
|
-
// Summarizer unavailable or aborted — skip
|
|
314
|
-
}
|
|
315
|
-
}))();
|
|
316
|
-
}
|
|
317
267
|
});
|
|
318
268
|
const onFileEvent = (event, absPath) => {
|
|
319
269
|
if (closed)
|
|
@@ -346,7 +296,6 @@ function startWatcher(opts) {
|
|
|
346
296
|
close: () => __awaiter(this, void 0, void 0, function* () {
|
|
347
297
|
closed = true;
|
|
348
298
|
currentBatchAc === null || currentBatchAc === void 0 ? void 0 : currentBatchAc.abort();
|
|
349
|
-
summarizationAc === null || summarizationAc === void 0 ? void 0 : summarizationAc.abort();
|
|
350
299
|
if (debounceTimer)
|
|
351
300
|
clearTimeout(debounceTimer);
|
|
352
301
|
clearInterval(ftsInterval);
|
package/package.json
CHANGED