@alex900530/claude-persistent-memory 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/bin/setup.js +39 -4
  2. package/package.json +1 -1
package/bin/setup.js CHANGED
@@ -161,9 +161,9 @@ function setupHooks() {
161
161
  ok(' Hooks configured (5 hooks).');
162
162
  }
163
163
 
164
- // ── [4/5] .gitignore ────────────────────────────────────────────────────────
164
+ // ── [4/6] .gitignore ────────────────────────────────────────────────────────
165
165
  function setupGitignore() {
166
- log('[4/5] Updating .gitignore ...');
166
+ log('[4/6] Updating .gitignore ...');
167
167
 
168
168
  const entries = ['.claude-memory/', '.claude-memory.config.js', '.claude/', '.mcp.json'];
169
169
  let content = '';
@@ -187,9 +187,43 @@ function setupGitignore() {
187
187
  }
188
188
  }
189
189
 
190
- // ── [5/5] Services ──────────────────────────────────────────────────────────
190
+ // ── [5/6] Pre-download embedding model ───────────────────────────────────────
191
+ async function setupModel() {
192
+ log('[5/6] Preparing embedding model (bge-m3) ...');
193
+
194
+ const os = require('os');
195
+ const cacheDir = path.join(os.homedir(), '.cache', 'huggingface', 'transformers-js');
196
+ const modelDir = path.join(cacheDir, 'Xenova', 'bge-m3', 'onnx');
197
+
198
+ // Check if model is already cached
199
+ if (fs.existsSync(path.join(modelDir, 'model.onnx_data'))) {
200
+ const stat = fs.statSync(path.join(modelDir, 'model.onnx_data'));
201
+ if (stat.size > 300 * 1024 * 1024) { // > 300MB = likely complete
202
+ ok(` Model already cached (${(stat.size / 1024 / 1024 / 1024).toFixed(1)}GB).`);
203
+ return;
204
+ }
205
+ warn(' Incomplete model cache detected, re-downloading ...');
206
+ }
207
+
208
+ log(' Downloading model (~2GB, this may take a few minutes) ...');
209
+ try {
210
+ // Resolve from package's own dependencies
211
+ const transformersPath = require.resolve('@huggingface/transformers', { paths: [PKG_DIR] });
212
+ const { pipeline, env } = await import(transformersPath);
213
+ env.cacheDir = cacheDir;
214
+ const extractor = await pipeline('feature-extraction', 'Xenova/bge-m3', { device: 'cpu' });
215
+ // Quick test to verify model works
216
+ await extractor('test', { pooling: 'cls', normalize: true });
217
+ ok(' Model downloaded and verified.');
218
+ } catch (e) {
219
+ warn(` Model download failed: ${e.message}`);
220
+ warn(' The embedding server will retry on first start.');
221
+ }
222
+ }
223
+
224
+ // ── [6/6] Services ──────────────────────────────────────────────────────────
191
225
  function setupServices() {
192
- log('[5/5] Setting up background services ...');
226
+ log('[6/6] Setting up background services ...');
193
227
 
194
228
  // Check if Azure credentials are configured
195
229
  let hasCredentials = false;
@@ -411,6 +445,7 @@ async function main() {
411
445
  setupMCP();
412
446
  setupHooks();
413
447
  setupGitignore();
448
+ await setupModel();
414
449
  setupServices();
415
450
  }
416
451
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alex900530/claude-persistent-memory",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Persistent memory system for Claude Code — hybrid BM25 + vector search, LLM-driven structuring, automatic clustering",
5
5
  "main": "lib/memory-db.js",
6
6
  "bin": {