grepmax 0.16.9 → 0.16.10
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/watch.js +0 -3
- package/dist/lib/daemon/daemon.js +5 -5
- package/dist/lib/utils/watcher-store.js +0 -25
- package/dist/lib/workers/embeddings/mlx-client.js +0 -8
- package/package.json +1 -1
- package/plugins/grepmax/.claude-plugin/plugin.json +1 -1
- package/dist/lib/utils/watcher-registry.js +0 -121
package/dist/commands/watch.js
CHANGED
|
@@ -119,7 +119,6 @@ exports.watch = new commander_1.Command("watch")
|
|
|
119
119
|
process.exit(0);
|
|
120
120
|
}
|
|
121
121
|
// Daemon foreground
|
|
122
|
-
(0, watcher_store_1.migrateFromJson)();
|
|
123
122
|
const { Daemon } = yield Promise.resolve().then(() => __importStar(require("../lib/daemon/daemon")));
|
|
124
123
|
const daemon = new Daemon();
|
|
125
124
|
try {
|
|
@@ -176,8 +175,6 @@ exports.watch = new commander_1.Command("watch")
|
|
|
176
175
|
process.exit(0);
|
|
177
176
|
}
|
|
178
177
|
// --- Per-project foreground mode ---
|
|
179
|
-
// Migrate legacy watchers.json to LMDB on first use
|
|
180
|
-
(0, watcher_store_1.migrateFromJson)();
|
|
181
178
|
// Watcher requires project to be registered
|
|
182
179
|
if (!(0, project_registry_1.getProject)(projectRoot)) {
|
|
183
180
|
console.error(`[watch:${projectName}] Project not registered. Run: gmax add ${projectRoot}`);
|
|
@@ -398,11 +398,11 @@ class Daemon {
|
|
|
398
398
|
});
|
|
399
399
|
this.processors.set(root, processor);
|
|
400
400
|
// Subscribe with @parcel/watcher — native backend, no polling.
|
|
401
|
-
// If the kernel refuses (e.g. FSEvents slots stuck after a prior kill -9
|
|
402
|
-
//
|
|
403
|
-
//
|
|
404
|
-
//
|
|
405
|
-
//
|
|
401
|
+
// If the kernel refuses (e.g. FSEvents slots stuck after a prior kill -9),
|
|
402
|
+
// fall straight through to poll mode. The retry/backoff path inside
|
|
403
|
+
// recoverWatcher is for transient overflows, not hard kernel-level
|
|
404
|
+
// subscribe failures, so we skip it on startup by priming failCount past
|
|
405
|
+
// MAX before invoking it.
|
|
406
406
|
try {
|
|
407
407
|
yield this.subscribeWatcher(root, processor);
|
|
408
408
|
}
|
|
@@ -49,7 +49,6 @@ exports.unregisterWatcher = unregisterWatcher;
|
|
|
49
49
|
exports.getWatcherForProject = getWatcherForProject;
|
|
50
50
|
exports.getWatcherCoveringPath = getWatcherCoveringPath;
|
|
51
51
|
exports.listWatchers = listWatchers;
|
|
52
|
-
exports.migrateFromJson = migrateFromJson;
|
|
53
52
|
exports.registerDaemon = registerDaemon;
|
|
54
53
|
exports.unregisterDaemon = unregisterDaemon;
|
|
55
54
|
exports.getDaemonInfo = getDaemonInfo;
|
|
@@ -173,30 +172,6 @@ function listWatchers() {
|
|
|
173
172
|
}
|
|
174
173
|
return alive;
|
|
175
174
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Migrate from legacy watchers.json if it exists.
|
|
178
|
-
* Call once on startup.
|
|
179
|
-
*/
|
|
180
|
-
function migrateFromJson() {
|
|
181
|
-
const jsonPath = path.join(config_1.PATHS.globalRoot, "watchers.json");
|
|
182
|
-
if (!fs.existsSync(jsonPath))
|
|
183
|
-
return;
|
|
184
|
-
try {
|
|
185
|
-
const raw = fs.readFileSync(jsonPath, "utf-8");
|
|
186
|
-
const entries = JSON.parse(raw);
|
|
187
|
-
const db = getDb();
|
|
188
|
-
for (const entry of entries) {
|
|
189
|
-
if (entry.projectRoot && isProcessRunning(entry.pid)) {
|
|
190
|
-
db.put(entry.projectRoot, Object.assign(Object.assign({}, entry), { lastHeartbeat: Date.now() }));
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// Remove legacy file
|
|
194
|
-
fs.unlinkSync(jsonPath);
|
|
195
|
-
}
|
|
196
|
-
catch (_a) {
|
|
197
|
-
// Best effort — ignore
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
175
|
// --- Daemon registry ---
|
|
201
176
|
exports.DAEMON_KEY = "__daemon__";
|
|
202
177
|
function registerDaemon(pid) {
|
|
@@ -49,7 +49,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.isMlxUp = isMlxUp;
|
|
51
51
|
exports.mlxEmbed = mlxEmbed;
|
|
52
|
-
exports.resetMlxCache = resetMlxCache;
|
|
53
52
|
const http = __importStar(require("node:http"));
|
|
54
53
|
const logger_1 = require("../../utils/logger");
|
|
55
54
|
const MLX_PORT = parseInt(process.env.MLX_EMBED_PORT || "8100", 10);
|
|
@@ -192,10 +191,3 @@ function mlxEmbed(texts) {
|
|
|
192
191
|
return data.vectors.map((v) => new Float32Array(v));
|
|
193
192
|
});
|
|
194
193
|
}
|
|
195
|
-
/**
|
|
196
|
-
* Reset availability cache (e.g., after starting the server).
|
|
197
|
-
*/
|
|
198
|
-
function resetMlxCache() {
|
|
199
|
-
mlxAvailable = null;
|
|
200
|
-
lastCheck = 0;
|
|
201
|
-
}
|
package/package.json
CHANGED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Watcher registry — tracks background watcher processes per project.
|
|
4
|
-
* Ensures only one watcher runs per project root.
|
|
5
|
-
*
|
|
6
|
-
* Stored in ~/.gmax/watchers.json
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.isProcessRunning = isProcessRunning;
|
|
43
|
-
exports.registerWatcher = registerWatcher;
|
|
44
|
-
exports.updateWatcherStatus = updateWatcherStatus;
|
|
45
|
-
exports.unregisterWatcher = unregisterWatcher;
|
|
46
|
-
exports.getWatcherForProject = getWatcherForProject;
|
|
47
|
-
exports.getWatcherCoveringPath = getWatcherCoveringPath;
|
|
48
|
-
exports.listWatchers = listWatchers;
|
|
49
|
-
const fs = __importStar(require("node:fs"));
|
|
50
|
-
const path = __importStar(require("node:path"));
|
|
51
|
-
const config_1 = require("../../config");
|
|
52
|
-
const REGISTRY_PATH = path.join(config_1.PATHS.globalRoot, "watchers.json");
|
|
53
|
-
function loadRegistry() {
|
|
54
|
-
try {
|
|
55
|
-
const raw = fs.readFileSync(REGISTRY_PATH, "utf-8");
|
|
56
|
-
return JSON.parse(raw);
|
|
57
|
-
}
|
|
58
|
-
catch (_a) {
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function saveRegistry(entries) {
|
|
63
|
-
fs.mkdirSync(path.dirname(REGISTRY_PATH), { recursive: true });
|
|
64
|
-
fs.writeFileSync(REGISTRY_PATH, `${JSON.stringify(entries, null, 2)}\n`);
|
|
65
|
-
}
|
|
66
|
-
function isProcessRunning(pid) {
|
|
67
|
-
try {
|
|
68
|
-
process.kill(pid, 0);
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
catch (_a) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function registerWatcher(info) {
|
|
76
|
-
const entries = loadRegistry().filter((e) => e.projectRoot !== info.projectRoot);
|
|
77
|
-
entries.push(info);
|
|
78
|
-
saveRegistry(entries);
|
|
79
|
-
}
|
|
80
|
-
function updateWatcherStatus(pid, status, lastReindex) {
|
|
81
|
-
const entries = loadRegistry();
|
|
82
|
-
const match = entries.find((e) => e.pid === pid);
|
|
83
|
-
if (match) {
|
|
84
|
-
match.status = status;
|
|
85
|
-
if (lastReindex)
|
|
86
|
-
match.lastReindex = lastReindex;
|
|
87
|
-
saveRegistry(entries);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function unregisterWatcher(pid) {
|
|
91
|
-
const entries = loadRegistry().filter((e) => e.pid !== pid);
|
|
92
|
-
saveRegistry(entries);
|
|
93
|
-
}
|
|
94
|
-
function getWatcherForProject(projectRoot) {
|
|
95
|
-
const entries = loadRegistry();
|
|
96
|
-
const match = entries.find((e) => e.projectRoot === projectRoot);
|
|
97
|
-
if (match && isProcessRunning(match.pid))
|
|
98
|
-
return match;
|
|
99
|
-
// Clean stale entry
|
|
100
|
-
if (match) {
|
|
101
|
-
saveRegistry(entries.filter((e) => e.pid !== match.pid));
|
|
102
|
-
}
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
function getWatcherCoveringPath(dir) {
|
|
106
|
-
const resolved = path.resolve(dir);
|
|
107
|
-
const entries = loadRegistry();
|
|
108
|
-
for (const e of entries) {
|
|
109
|
-
if (resolved.startsWith(e.projectRoot) && isProcessRunning(e.pid))
|
|
110
|
-
return e;
|
|
111
|
-
}
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
function listWatchers() {
|
|
115
|
-
const entries = loadRegistry();
|
|
116
|
-
const active = entries.filter((e) => isProcessRunning(e.pid));
|
|
117
|
-
if (active.length !== entries.length) {
|
|
118
|
-
saveRegistry(active);
|
|
119
|
-
}
|
|
120
|
-
return active;
|
|
121
|
-
}
|