promptgraph-mcp 2.9.17 → 2.9.19
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/indexer.js +13 -4
- package/package.json +1 -1
package/indexer.js
CHANGED
|
@@ -70,13 +70,16 @@ export async function indexBatch(db, skills, { fast = false } = {}) {
|
|
|
70
70
|
if (!fast && allChunks.length) {
|
|
71
71
|
const texts = allChunks.map(c => c.text);
|
|
72
72
|
const total = texts.length;
|
|
73
|
-
const
|
|
74
|
-
|
|
73
|
+
const spin = spinner('Preparing model...');
|
|
74
|
+
spin.start();
|
|
75
|
+
let embedStart = null;
|
|
75
76
|
const embeddings = await embedBatch(texts, (done, tot) => {
|
|
77
|
+
if (!embedStart) { spin.stop(); embedStart = Date.now(); }
|
|
76
78
|
const elapsed = (Date.now() - embedStart) / 1000;
|
|
77
79
|
const eta = done > 0 ? Math.round((tot - done) * elapsed / done) : '?';
|
|
78
80
|
progress(done, tot, { eta });
|
|
79
81
|
});
|
|
82
|
+
if (!embedStart) spin.stop();
|
|
80
83
|
progressDone();
|
|
81
84
|
db.transaction(() => {
|
|
82
85
|
for (let i = 0; i < allChunks.length; i++) {
|
|
@@ -165,6 +168,8 @@ export async function indexAll({ fast = false } = {}) {
|
|
|
165
168
|
let classifierRemoved = 0;
|
|
166
169
|
let batch = [];
|
|
167
170
|
const start = Date.now();
|
|
171
|
+
let processedCount = 0;
|
|
172
|
+
let processedStart = null;
|
|
168
173
|
|
|
169
174
|
// Build a path→{hash,id} map from DB for O(1) lookups
|
|
170
175
|
const dbByPath = new Map();
|
|
@@ -190,7 +195,9 @@ export async function indexAll({ fast = false } = {}) {
|
|
|
190
195
|
if (dbRow?.hash === hash) {
|
|
191
196
|
skipped++; count++;
|
|
192
197
|
if (count % 200 === 0) {
|
|
193
|
-
const eta =
|
|
198
|
+
const eta = processedCount > 0 && processedStart
|
|
199
|
+
? Math.round((total - count) * (Date.now() - processedStart) / processedCount / 1000)
|
|
200
|
+
: '?';
|
|
194
201
|
progress(count, total, { skipped, eta, errors });
|
|
195
202
|
}
|
|
196
203
|
continue;
|
|
@@ -199,6 +206,7 @@ export async function indexAll({ fast = false } = {}) {
|
|
|
199
206
|
// 4. Only now check if it's a real skill (content already in memory)
|
|
200
207
|
if (!isSkillFile(file, raw)) { skipped++; count++; continue; }
|
|
201
208
|
|
|
209
|
+
if (!processedStart) processedStart = Date.now();
|
|
202
210
|
const parsed = parseSkillFile(file, source, { raw });
|
|
203
211
|
batch.push({ ...parsed, hash });
|
|
204
212
|
|
|
@@ -207,8 +215,9 @@ export async function indexAll({ fast = false } = {}) {
|
|
|
207
215
|
classifierRemoved += batch.length - filtered.length;
|
|
208
216
|
await indexBatch(db, filtered, { fast });
|
|
209
217
|
count += filtered.length;
|
|
218
|
+
processedCount += filtered.length;
|
|
210
219
|
batch = [];
|
|
211
|
-
const eta =
|
|
220
|
+
const eta = processedCount > 0 ? Math.round((total - count) * (Date.now() - processedStart) / processedCount / 1000) : '?';
|
|
212
221
|
progress(count, total, { skipped, eta, errors });
|
|
213
222
|
await new Promise(r => setImmediate ? setImmediate(r) : setTimeout(r, 0));
|
|
214
223
|
}
|