grepmax 0.12.13 → 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 +65 -43
- package/dist/commands/index.js +93 -62
- package/dist/commands/mcp.js +1 -0
- package/dist/commands/remove.js +19 -19
- package/dist/commands/summarize.js +52 -18
- package/dist/lib/daemon/daemon.js +214 -4
- package/dist/lib/daemon/ipc-handler.js +61 -1
- package/dist/lib/index/batch-processor.js +81 -97
- package/dist/lib/index/syncer.js +37 -27
- package/dist/lib/store/vector-db.js +11 -0
- package/dist/lib/utils/daemon-client.js +89 -0
- package/mlx-embed-server/uv.lock +50 -0
- package/package.json +2 -2
- package/plugins/grepmax/.claude-plugin/plugin.json +1 -1
package/dist/commands/add.js
CHANGED
|
@@ -67,7 +67,7 @@ Examples:
|
|
|
67
67
|
gmax add . --no-index Register only, index later with gmax index
|
|
68
68
|
`)
|
|
69
69
|
.action((dir, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
-
var _a, _b;
|
|
70
|
+
var _a, _b, _c, _d, _e;
|
|
71
71
|
let vectorDb = null;
|
|
72
72
|
try {
|
|
73
73
|
const targetDir = dir ? path.resolve(dir) : process.cwd();
|
|
@@ -116,50 +116,72 @@ Examples:
|
|
|
116
116
|
}
|
|
117
117
|
// Index the project
|
|
118
118
|
yield (0, setup_helpers_1.ensureSetup)();
|
|
119
|
-
const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
|
|
120
|
-
vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
|
|
121
119
|
yield (0, grammar_loader_1.ensureGrammars)(console.log, { silent: true });
|
|
122
120
|
const { spinner, onProgress } = (0, sync_helpers_1.createIndexingSpinner)(projectRoot, `Adding ${projectName}...`);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
lastIndexed: ""
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
121
|
+
const { ensureDaemonRunning, sendStreamingCommand } = yield Promise.resolve().then(() => __importStar(require("../lib/utils/daemon-client")));
|
|
122
|
+
const pendingEntry = {
|
|
123
|
+
root: projectRoot,
|
|
124
|
+
name: projectName,
|
|
125
|
+
vectorDim: globalConfig.vectorDim,
|
|
126
|
+
modelTier: globalConfig.modelTier,
|
|
127
|
+
embedMode: globalConfig.embedMode,
|
|
128
|
+
lastIndexed: "",
|
|
129
|
+
chunkCount: 0,
|
|
130
|
+
status: "error",
|
|
131
|
+
};
|
|
132
|
+
if (yield ensureDaemonRunning()) {
|
|
133
|
+
// Daemon mode: IPC streaming
|
|
134
|
+
try {
|
|
135
|
+
const done = yield sendStreamingCommand({ cmd: "add", root: projectRoot }, (msg) => {
|
|
136
|
+
var _a, _b, _c;
|
|
137
|
+
onProgress({
|
|
138
|
+
processed: (_a = msg.processed) !== null && _a !== void 0 ? _a : 0,
|
|
139
|
+
indexed: (_b = msg.indexed) !== null && _b !== void 0 ? _b : 0,
|
|
140
|
+
total: (_c = msg.total) !== null && _c !== void 0 ? _c : 0,
|
|
141
|
+
filePath: msg.filePath,
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
if (!done.ok) {
|
|
145
|
+
throw new Error((_c = done.error) !== null && _c !== void 0 ? _c : "daemon add failed");
|
|
146
|
+
}
|
|
147
|
+
(0, project_registry_1.registerProject)(Object.assign(Object.assign({}, pendingEntry), { lastIndexed: new Date().toISOString(), chunkCount: (_d = done.indexed) !== null && _d !== void 0 ? _d : 0, status: "indexed" }));
|
|
148
|
+
const failedFiles = (_e = done.failedFiles) !== null && _e !== void 0 ? _e : 0;
|
|
149
|
+
const failedSuffix = failedFiles > 0 ? ` · ${failedFiles} failed` : "";
|
|
150
|
+
spinner.succeed(`Added ${projectName} (${done.total} files, ${done.indexed} chunks${failedSuffix})`);
|
|
151
|
+
// Watcher already started by daemon's addProject
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
(0, project_registry_1.registerProject)(pendingEntry);
|
|
155
|
+
spinner.fail(`Failed to index ${projectName}`);
|
|
156
|
+
throw e;
|
|
157
|
+
}
|
|
160
158
|
}
|
|
161
|
-
else
|
|
162
|
-
|
|
159
|
+
else {
|
|
160
|
+
// Fallback: direct mode with lock
|
|
161
|
+
const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
|
|
162
|
+
vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
|
|
163
|
+
try {
|
|
164
|
+
const result = yield (0, syncer_1.initialSync)({
|
|
165
|
+
projectRoot,
|
|
166
|
+
onProgress,
|
|
167
|
+
});
|
|
168
|
+
(0, project_registry_1.registerProject)(Object.assign(Object.assign({}, pendingEntry), { lastIndexed: new Date().toISOString(), chunkCount: result.indexed, status: "indexed" }));
|
|
169
|
+
const failedSuffix = result.failedFiles > 0 ? ` · ${result.failedFiles} failed` : "";
|
|
170
|
+
spinner.succeed(`Added ${projectName} (${result.total} files, ${result.indexed} chunks${failedSuffix})`);
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
(0, project_registry_1.registerProject)(pendingEntry);
|
|
174
|
+
spinner.fail(`Failed to index ${projectName}`);
|
|
175
|
+
throw e;
|
|
176
|
+
}
|
|
177
|
+
// Start watcher (only in direct mode — daemon handles it in IPC mode)
|
|
178
|
+
const launched = yield (0, watcher_launcher_1.launchWatcher)(projectRoot);
|
|
179
|
+
if (launched.ok) {
|
|
180
|
+
console.log(`Watcher started (PID: ${launched.pid})`);
|
|
181
|
+
}
|
|
182
|
+
else if (launched.reason === "spawn-failed") {
|
|
183
|
+
console.warn(`[add] ${launched.message}`);
|
|
184
|
+
}
|
|
163
185
|
}
|
|
164
186
|
}
|
|
165
187
|
catch (error) {
|
|
@@ -172,7 +194,7 @@ Examples:
|
|
|
172
194
|
try {
|
|
173
195
|
yield vectorDb.close();
|
|
174
196
|
}
|
|
175
|
-
catch (
|
|
197
|
+
catch (_f) { }
|
|
176
198
|
}
|
|
177
199
|
yield (0, exit_1.gracefulExit)();
|
|
178
200
|
}
|
package/dist/commands/index.js
CHANGED
|
@@ -70,7 +70,7 @@ Examples:
|
|
|
70
70
|
gmax index --reset Full re-index from scratch
|
|
71
71
|
`)
|
|
72
72
|
.action((_args, cmd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
-
var _a;
|
|
73
|
+
var _a, _b, _c, _d;
|
|
74
74
|
const options = cmd.optsWithGlobals();
|
|
75
75
|
let vectorDb = null;
|
|
76
76
|
const ac = new AbortController();
|
|
@@ -95,31 +95,64 @@ Examples:
|
|
|
95
95
|
process.exitCode = 1;
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
|
|
99
|
-
vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
|
|
100
98
|
if (options.reset) {
|
|
101
|
-
console.log(
|
|
102
|
-
// We do NOT manually drop/rm here anymore to avoid race conditions.
|
|
103
|
-
// The syncer handles it inside the lock.
|
|
99
|
+
console.log("Resetting index...");
|
|
104
100
|
}
|
|
105
101
|
// Ensure grammars are present before indexing (silent if already exist)
|
|
106
102
|
yield (0, grammar_loader_1.ensureGrammars)(console.log, { silent: true });
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
103
|
+
const { ensureDaemonRunning, sendStreamingCommand } = yield Promise.resolve().then(() => __importStar(require("../lib/utils/daemon-client")));
|
|
104
|
+
if (yield ensureDaemonRunning()) {
|
|
105
|
+
// Daemon mode: IPC streaming — daemon handles watcher pause/resume internally
|
|
106
|
+
const { spinner, onProgress } = (0, sync_helpers_1.createIndexingSpinner)(projectRoot, "Indexing...", { verbose: options.verbose });
|
|
107
|
+
try {
|
|
108
|
+
const done = yield sendStreamingCommand({ cmd: "index", root: projectRoot, reset: options.reset, dryRun: options.dryRun }, (msg) => {
|
|
109
|
+
var _a, _b, _c;
|
|
110
|
+
onProgress({
|
|
111
|
+
processed: (_a = msg.processed) !== null && _a !== void 0 ? _a : 0,
|
|
112
|
+
indexed: (_b = msg.indexed) !== null && _b !== void 0 ? _b : 0,
|
|
113
|
+
total: (_c = msg.total) !== null && _c !== void 0 ? _c : 0,
|
|
114
|
+
filePath: msg.filePath,
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
if (!done.ok) {
|
|
118
|
+
throw new Error((_b = done.error) !== null && _b !== void 0 ? _b : "daemon index failed");
|
|
119
|
+
}
|
|
120
|
+
if (options.dryRun) {
|
|
121
|
+
spinner.succeed(`Dry run complete(${done.processed} / ${done.total}) • would have indexed ${done.indexed} `);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const globalConfig = (0, index_config_1.readGlobalConfig)();
|
|
125
|
+
(0, project_registry_1.registerProject)({
|
|
126
|
+
root: projectRoot,
|
|
127
|
+
name: path.basename(projectRoot),
|
|
128
|
+
vectorDim: globalConfig.vectorDim,
|
|
129
|
+
modelTier: globalConfig.modelTier,
|
|
130
|
+
embedMode: globalConfig.embedMode,
|
|
131
|
+
lastIndexed: new Date().toISOString(),
|
|
132
|
+
chunkCount: (_c = done.indexed) !== null && _c !== void 0 ? _c : 0,
|
|
133
|
+
status: "indexed",
|
|
134
|
+
});
|
|
135
|
+
const failedFiles = (_d = done.failedFiles) !== null && _d !== void 0 ? _d : 0;
|
|
136
|
+
const failedSuffix = failedFiles > 0 ? ` • ${failedFiles} failed` : "";
|
|
137
|
+
spinner.succeed(`Indexing complete(${done.processed} / ${done.total}) • indexed ${done.indexed}${failedSuffix} `);
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
spinner.fail("Indexing failed");
|
|
141
|
+
throw e;
|
|
142
|
+
}
|
|
114
143
|
}
|
|
115
144
|
else {
|
|
145
|
+
// Fallback: direct mode with lock — stop any watcher first
|
|
146
|
+
const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
|
|
147
|
+
vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
|
|
148
|
+
let restartWatcher = false;
|
|
116
149
|
const watcher = (0, watcher_store_1.getWatcherCoveringPath)(projectRoot);
|
|
117
150
|
if (watcher) {
|
|
118
151
|
console.log(`Stopping watcher (PID: ${watcher.pid}) for ${path.basename(watcher.projectRoot)}...`);
|
|
119
152
|
try {
|
|
120
153
|
process.kill(watcher.pid, "SIGTERM");
|
|
121
154
|
}
|
|
122
|
-
catch (
|
|
155
|
+
catch (_e) { }
|
|
123
156
|
for (let i = 0; i < 50; i++) {
|
|
124
157
|
if (!(0, watcher_store_1.isProcessRunning)(watcher.pid))
|
|
125
158
|
break;
|
|
@@ -128,56 +161,54 @@ Examples:
|
|
|
128
161
|
(0, watcher_store_1.unregisterWatcher)(watcher.pid);
|
|
129
162
|
restartWatcher = true;
|
|
130
163
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
164
|
+
const { spinner, onProgress } = (0, sync_helpers_1.createIndexingSpinner)(projectRoot, "Indexing...", { verbose: options.verbose });
|
|
165
|
+
try {
|
|
166
|
+
const result = yield (0, syncer_1.initialSync)({
|
|
167
|
+
projectRoot,
|
|
168
|
+
dryRun: options.dryRun,
|
|
169
|
+
reset: options.reset,
|
|
170
|
+
onProgress,
|
|
171
|
+
signal: ac.signal,
|
|
172
|
+
});
|
|
173
|
+
if (aborted) {
|
|
174
|
+
spinner.warn(`Indexing interrupted — partial progress saved (${result.indexed} indexed)`);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (options.dryRun) {
|
|
178
|
+
spinner.succeed(`Dry run complete(${result.processed} / ${result.total}) • would have indexed ${result.indexed} `);
|
|
179
|
+
console.log((0, sync_helpers_1.formatDryRunSummary)(result, {
|
|
180
|
+
actionDescription: "would have indexed",
|
|
181
|
+
includeTotal: true,
|
|
182
|
+
}));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const globalConfig = (0, index_config_1.readGlobalConfig)();
|
|
186
|
+
(0, project_registry_1.registerProject)({
|
|
187
|
+
root: projectRoot,
|
|
188
|
+
name: path.basename(projectRoot),
|
|
189
|
+
vectorDim: globalConfig.vectorDim,
|
|
190
|
+
modelTier: globalConfig.modelTier,
|
|
191
|
+
embedMode: globalConfig.embedMode,
|
|
192
|
+
lastIndexed: new Date().toISOString(),
|
|
193
|
+
chunkCount: result.indexed,
|
|
194
|
+
status: "indexed",
|
|
195
|
+
});
|
|
196
|
+
const failedSuffix = result.failedFiles > 0 ? ` • ${result.failedFiles} failed` : "";
|
|
197
|
+
spinner.succeed(`Indexing complete(${result.processed} / ${result.total}) • indexed ${result.indexed}${failedSuffix} `);
|
|
144
198
|
}
|
|
145
|
-
|
|
146
|
-
spinner.
|
|
147
|
-
|
|
148
|
-
actionDescription: "would have indexed",
|
|
149
|
-
includeTotal: true,
|
|
150
|
-
}));
|
|
151
|
-
return;
|
|
199
|
+
catch (e) {
|
|
200
|
+
spinner.fail("Indexing failed");
|
|
201
|
+
throw e;
|
|
152
202
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
chunkCount: result.indexed,
|
|
163
|
-
status: "indexed",
|
|
164
|
-
});
|
|
165
|
-
const failedSuffix = result.failedFiles > 0 ? ` • ${result.failedFiles} failed` : "";
|
|
166
|
-
spinner.succeed(`Indexing complete(${result.processed} / ${result.total}) • indexed ${result.indexed}${failedSuffix} `);
|
|
167
|
-
}
|
|
168
|
-
catch (e) {
|
|
169
|
-
spinner.fail("Indexing failed");
|
|
170
|
-
throw e;
|
|
171
|
-
}
|
|
172
|
-
finally {
|
|
173
|
-
// Restart the watcher if we stopped one
|
|
174
|
-
if (restartWatcher) {
|
|
175
|
-
const launched = yield (0, watcher_launcher_1.launchWatcher)(projectRoot);
|
|
176
|
-
if (launched.ok) {
|
|
177
|
-
console.log(`Restarted watcher for ${path.basename(projectRoot)} (PID: ${launched.pid})`);
|
|
178
|
-
}
|
|
179
|
-
else if (launched.reason === "spawn-failed") {
|
|
180
|
-
console.warn(`[index] ${launched.message}`);
|
|
203
|
+
finally {
|
|
204
|
+
if (restartWatcher) {
|
|
205
|
+
const launched = yield (0, watcher_launcher_1.launchWatcher)(projectRoot);
|
|
206
|
+
if (launched.ok) {
|
|
207
|
+
console.log(`Restarted watcher for ${path.basename(projectRoot)} (PID: ${launched.pid})`);
|
|
208
|
+
}
|
|
209
|
+
else if (launched.reason === "spawn-failed") {
|
|
210
|
+
console.warn(`[index] ${launched.message}`);
|
|
211
|
+
}
|
|
181
212
|
}
|
|
182
213
|
}
|
|
183
214
|
}
|
package/dist/commands/mcp.js
CHANGED
|
@@ -323,6 +323,7 @@ function err(text) {
|
|
|
323
323
|
exports.mcp = new commander_1.Command("mcp")
|
|
324
324
|
.description("Start MCP server (stdio, auto-started by plugins)")
|
|
325
325
|
.action((_optsArg, _cmd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
326
|
+
process.title = "gmax-mcp";
|
|
326
327
|
// --- Lifecycle ---
|
|
327
328
|
let _vectorDb = null;
|
|
328
329
|
let _searcher = null;
|
package/dist/commands/remove.js
CHANGED
|
@@ -77,7 +77,7 @@ Examples:
|
|
|
77
77
|
gmax remove --force Skip confirmation
|
|
78
78
|
`)
|
|
79
79
|
.action((dir, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
-
var _a;
|
|
80
|
+
var _a, _b;
|
|
81
81
|
let vectorDb = null;
|
|
82
82
|
let metaCache = null;
|
|
83
83
|
try {
|
|
@@ -99,33 +99,33 @@ Examples:
|
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
const { isDaemonRunning, sendDaemonCommand } = yield Promise.resolve().then(() => __importStar(require("../lib/utils/daemon-client")));
|
|
102
|
+
const { isDaemonRunning, sendStreamingCommand } = yield Promise.resolve().then(() => __importStar(require("../lib/utils/daemon-client")));
|
|
104
103
|
if (yield isDaemonRunning()) {
|
|
105
|
-
|
|
106
|
-
yield
|
|
104
|
+
// Daemon mode: IPC handles unwatch + LanceDB delete + MetaCache cleanup
|
|
105
|
+
const done = yield sendStreamingCommand({ cmd: "remove", root: projectRoot }, () => { });
|
|
106
|
+
if (!done.ok) {
|
|
107
|
+
throw new Error((_b = done.error) !== null && _b !== void 0 ? _b : "daemon remove failed");
|
|
108
|
+
}
|
|
107
109
|
}
|
|
108
110
|
else {
|
|
111
|
+
// Fallback: direct mode — stop watcher + delete directly
|
|
109
112
|
const watcher = (0, watcher_store_1.getWatcherForProject)(projectRoot);
|
|
110
113
|
if (watcher) {
|
|
111
114
|
console.log(`Stopping watcher (PID: ${watcher.pid})...`);
|
|
112
115
|
yield (0, process_1.killProcess)(watcher.pid);
|
|
113
116
|
(0, watcher_store_1.unregisterWatcher)(watcher.pid);
|
|
114
117
|
}
|
|
118
|
+
const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
|
|
119
|
+
vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
|
|
120
|
+
yield vectorDb.deletePathsWithPrefix(projectRoot);
|
|
121
|
+
metaCache = new meta_cache_1.MetaCache(paths.lmdbPath);
|
|
122
|
+
const keys = yield metaCache.getKeysWithPrefix(projectRoot);
|
|
123
|
+
for (const key of keys) {
|
|
124
|
+
metaCache.delete(key);
|
|
125
|
+
}
|
|
115
126
|
}
|
|
116
|
-
//
|
|
117
|
-
const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
|
|
118
|
-
vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
|
|
119
|
-
yield vectorDb.deletePathsWithPrefix(projectRoot);
|
|
120
|
-
// Clean MetaCache entries
|
|
121
|
-
metaCache = new meta_cache_1.MetaCache(paths.lmdbPath);
|
|
122
|
-
const keys = yield metaCache.getKeysWithPrefix(projectRoot);
|
|
123
|
-
for (const key of keys) {
|
|
124
|
-
metaCache.delete(key);
|
|
125
|
-
}
|
|
126
|
-
// Remove from registry
|
|
127
|
+
// Registry + marker cleanup in both paths
|
|
127
128
|
(0, project_registry_1.removeProject)(projectRoot);
|
|
128
|
-
// Delete marker file
|
|
129
129
|
(0, project_marker_1.removeMarker)(projectRoot);
|
|
130
130
|
console.log(`Removed ${projectName}${chunkStr}.`);
|
|
131
131
|
}
|
|
@@ -139,13 +139,13 @@ Examples:
|
|
|
139
139
|
try {
|
|
140
140
|
metaCache.close();
|
|
141
141
|
}
|
|
142
|
-
catch (
|
|
142
|
+
catch (_c) { }
|
|
143
143
|
}
|
|
144
144
|
if (vectorDb) {
|
|
145
145
|
try {
|
|
146
146
|
yield vectorDb.close();
|
|
147
147
|
}
|
|
148
|
-
catch (
|
|
148
|
+
catch (_d) { }
|
|
149
149
|
}
|
|
150
150
|
yield (0, exit_1.gracefulExit)();
|
|
151
151
|
}
|
|
@@ -54,31 +54,65 @@ exports.summarize = new commander_1.Command("summarize")
|
|
|
54
54
|
.description("Generate LLM summaries for indexed chunks without re-indexing")
|
|
55
55
|
.option("-p, --path <dir>", "Only summarize chunks under this directory")
|
|
56
56
|
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
var _a, _b, _c;
|
|
57
58
|
const paths = (0, project_root_1.ensureProjectPaths)(process.cwd());
|
|
58
|
-
const vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
|
|
59
59
|
const rootPrefix = options.path
|
|
60
60
|
? `${path.resolve(options.path)}/`
|
|
61
61
|
: "";
|
|
62
62
|
const { spinner } = (0, sync_helpers_1.createIndexingSpinner)("", "Summarizing...");
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
const { isDaemonRunning, sendStreamingCommand } = yield Promise.resolve().then(() => __importStar(require("../lib/utils/daemon-client")));
|
|
64
|
+
if (yield isDaemonRunning()) {
|
|
65
|
+
// Daemon mode: IPC streaming
|
|
66
|
+
try {
|
|
67
|
+
const done = yield sendStreamingCommand({ cmd: "summarize", root: paths.root, pathPrefix: rootPrefix || undefined }, (msg) => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
spinner.text = `Summarizing... (${(_a = msg.summarized) !== null && _a !== void 0 ? _a : 0}/${(_b = msg.total) !== null && _b !== void 0 ? _b : 0})`;
|
|
70
|
+
});
|
|
71
|
+
if (!done.ok) {
|
|
72
|
+
throw new Error((_a = done.error) !== null && _a !== void 0 ? _a : "daemon summarize failed");
|
|
73
|
+
}
|
|
74
|
+
const summarized = (_b = done.summarized) !== null && _b !== void 0 ? _b : 0;
|
|
75
|
+
const remaining = (_c = done.remaining) !== null && _c !== void 0 ? _c : 0;
|
|
76
|
+
if (summarized > 0) {
|
|
77
|
+
const remainMsg = remaining > 0 ? ` (${remaining}+ remaining — run again)` : "";
|
|
78
|
+
spinner.succeed(`Summarized ${summarized} chunks${remainMsg}`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
spinner.succeed("All chunks already have summaries (or summarizer unavailable)");
|
|
82
|
+
}
|
|
70
83
|
}
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
catch (err) {
|
|
85
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
86
|
+
spinner.fail(`Summarization failed: ${msg}`);
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
yield (0, exit_1.gracefulExit)();
|
|
73
91
|
}
|
|
74
92
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
else {
|
|
94
|
+
// Fallback: direct mode
|
|
95
|
+
const vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
|
|
96
|
+
try {
|
|
97
|
+
const { summarized, remaining } = yield (0, syncer_1.generateSummaries)(vectorDb, rootPrefix, (done, total) => {
|
|
98
|
+
spinner.text = `Summarizing... (${done}/${total})`;
|
|
99
|
+
});
|
|
100
|
+
if (summarized > 0) {
|
|
101
|
+
const remainMsg = remaining > 0 ? ` (${remaining}+ remaining — run again)` : "";
|
|
102
|
+
spinner.succeed(`Summarized ${summarized} chunks${remainMsg}`);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
spinner.succeed("All chunks already have summaries (or summarizer unavailable)");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
110
|
+
spinner.fail(`Summarization failed: ${msg}`);
|
|
111
|
+
process.exitCode = 1;
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
yield vectorDb.close();
|
|
115
|
+
yield (0, exit_1.gracefulExit)();
|
|
116
|
+
}
|
|
83
117
|
}
|
|
84
118
|
}));
|