grepmax 0.13.0 → 0.13.1
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/dist/commands/add.js
CHANGED
|
@@ -118,7 +118,7 @@ Examples:
|
|
|
118
118
|
yield (0, setup_helpers_1.ensureSetup)();
|
|
119
119
|
yield (0, grammar_loader_1.ensureGrammars)(console.log, { silent: true });
|
|
120
120
|
const { spinner, onProgress } = (0, sync_helpers_1.createIndexingSpinner)(projectRoot, `Adding ${projectName}...`);
|
|
121
|
-
const {
|
|
121
|
+
const { ensureDaemonRunning, sendStreamingCommand } = yield Promise.resolve().then(() => __importStar(require("../lib/utils/daemon-client")));
|
|
122
122
|
const pendingEntry = {
|
|
123
123
|
root: projectRoot,
|
|
124
124
|
name: projectName,
|
|
@@ -129,7 +129,7 @@ Examples:
|
|
|
129
129
|
chunkCount: 0,
|
|
130
130
|
status: "error",
|
|
131
131
|
};
|
|
132
|
-
if (yield
|
|
132
|
+
if (yield ensureDaemonRunning()) {
|
|
133
133
|
// Daemon mode: IPC streaming
|
|
134
134
|
try {
|
|
135
135
|
const done = yield sendStreamingCommand({ cmd: "add", root: projectRoot }, (msg) => {
|
package/dist/commands/index.js
CHANGED
|
@@ -100,8 +100,8 @@ Examples:
|
|
|
100
100
|
}
|
|
101
101
|
// Ensure grammars are present before indexing (silent if already exist)
|
|
102
102
|
yield (0, grammar_loader_1.ensureGrammars)(console.log, { silent: true });
|
|
103
|
-
const {
|
|
104
|
-
if (yield
|
|
103
|
+
const { ensureDaemonRunning, sendStreamingCommand } = yield Promise.resolve().then(() => __importStar(require("../lib/utils/daemon-client")));
|
|
104
|
+
if (yield ensureDaemonRunning()) {
|
|
105
105
|
// Daemon mode: IPC streaming — daemon handles watcher pause/resume internally
|
|
106
106
|
const { spinner, onProgress } = (0, sync_helpers_1.createIndexingSpinner)(projectRoot, "Indexing...", { verbose: options.verbose });
|
|
107
107
|
try {
|
|
@@ -323,6 +323,8 @@ class Daemon {
|
|
|
323
323
|
(0, ipc_handler_1.writeDone)(conn, { ok: false, error: "daemon resources not ready" });
|
|
324
324
|
return;
|
|
325
325
|
}
|
|
326
|
+
const ac = new AbortController();
|
|
327
|
+
conn.on("close", () => ac.abort());
|
|
326
328
|
this.vectorDb.pauseMaintenanceLoop();
|
|
327
329
|
let lastProgressTime = 0;
|
|
328
330
|
try {
|
|
@@ -330,6 +332,7 @@ class Daemon {
|
|
|
330
332
|
projectRoot: root,
|
|
331
333
|
vectorDb: this.vectorDb,
|
|
332
334
|
metaCache: this.metaCache,
|
|
335
|
+
signal: ac.signal,
|
|
333
336
|
onProgress: (info) => {
|
|
334
337
|
this.resetActivity();
|
|
335
338
|
const now = Date.now();
|
|
@@ -383,6 +386,8 @@ class Daemon {
|
|
|
383
386
|
yield sub.unsubscribe();
|
|
384
387
|
this.subscriptions.delete(root);
|
|
385
388
|
}
|
|
389
|
+
const ac = new AbortController();
|
|
390
|
+
conn.on("close", () => ac.abort());
|
|
386
391
|
this.vectorDb.pauseMaintenanceLoop();
|
|
387
392
|
let lastProgressTime = 0;
|
|
388
393
|
try {
|
|
@@ -392,6 +397,7 @@ class Daemon {
|
|
|
392
397
|
dryRun: opts.dryRun,
|
|
393
398
|
vectorDb: this.vectorDb,
|
|
394
399
|
metaCache: this.metaCache,
|
|
400
|
+
signal: ac.signal,
|
|
395
401
|
onProgress: (info) => {
|
|
396
402
|
this.resetActivity();
|
|
397
403
|
const now = Date.now();
|
|
@@ -44,6 +44,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.sendDaemonCommand = sendDaemonCommand;
|
|
46
46
|
exports.isDaemonRunning = isDaemonRunning;
|
|
47
|
+
exports.ensureDaemonRunning = ensureDaemonRunning;
|
|
47
48
|
exports.sendStreamingCommand = sendStreamingCommand;
|
|
48
49
|
const net = __importStar(require("node:net"));
|
|
49
50
|
const config_1 = require("../../config");
|
|
@@ -107,6 +108,26 @@ function isDaemonRunning() {
|
|
|
107
108
|
return resp.ok === true;
|
|
108
109
|
});
|
|
109
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Ensure the daemon is running — start it if needed, poll up to 5s.
|
|
113
|
+
* Returns true if daemon is ready, false if it couldn't be started.
|
|
114
|
+
*/
|
|
115
|
+
function ensureDaemonRunning() {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
if (yield isDaemonRunning())
|
|
118
|
+
return true;
|
|
119
|
+
const { spawnDaemon } = yield Promise.resolve().then(() => __importStar(require("./daemon-launcher")));
|
|
120
|
+
const pid = spawnDaemon();
|
|
121
|
+
if (!pid)
|
|
122
|
+
return false;
|
|
123
|
+
for (let i = 0; i < 25; i++) {
|
|
124
|
+
yield new Promise((r) => setTimeout(r, 200));
|
|
125
|
+
if (yield isDaemonRunning())
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
110
131
|
const DEFAULT_STREAMING_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes
|
|
111
132
|
/**
|
|
112
133
|
* Send a streaming command to the daemon. The daemon streams
|
package/package.json
CHANGED