specmem-hardwicksoftware 3.5.24 → 3.5.25
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.
Potentially problematic release.
This version of specmem-hardwicksoftware might be problematic. Click here for more details.
- package/package.json +1 -1
- package/scripts/specmem-init.cjs +40 -0
package/package.json
CHANGED
package/scripts/specmem-init.cjs
CHANGED
|
@@ -5456,6 +5456,46 @@ async function main() {
|
|
|
5456
5456
|
console.log(`${c.brightYellow}⚡ TURBO MODE${c.reset}${c.dim} - Fast initialization enabled${c.reset}`);
|
|
5457
5457
|
console.log('');
|
|
5458
5458
|
|
|
5459
|
+
// ========== PRE-STAGE 0: Auto-run setup if not done ==========
|
|
5460
|
+
// Check if first-run setup has been completed (models downloaded, deps installed)
|
|
5461
|
+
const specmemPkgDir = path.dirname(__dirname);
|
|
5462
|
+
const modelsDir = path.join(specmemPkgDir, 'models', 'optimized');
|
|
5463
|
+
const setupMarker = path.join(specmemPkgDir, '.setup-complete');
|
|
5464
|
+
|
|
5465
|
+
// Check if setup is needed: no models dir OR no setup marker OR missing Python deps
|
|
5466
|
+
let needsSetup = false;
|
|
5467
|
+
if (!fs.existsSync(modelsDir) || !fs.existsSync(setupMarker)) {
|
|
5468
|
+
needsSetup = true;
|
|
5469
|
+
} else {
|
|
5470
|
+
// Also check if sentence_transformers is available
|
|
5471
|
+
try {
|
|
5472
|
+
execSync('python3 -c "import sentence_transformers" 2>/dev/null', { stdio: 'pipe' });
|
|
5473
|
+
} catch (e) {
|
|
5474
|
+
needsSetup = true;
|
|
5475
|
+
}
|
|
5476
|
+
}
|
|
5477
|
+
|
|
5478
|
+
if (needsSetup) {
|
|
5479
|
+
console.log(`${c.yellow}═══ First-time setup required ═══${c.reset}`);
|
|
5480
|
+
console.log(`${c.dim}Running specmem setup to download models and install dependencies...${c.reset}\n`);
|
|
5481
|
+
|
|
5482
|
+
try {
|
|
5483
|
+
// Run first-run-model-setup.cjs
|
|
5484
|
+
const setupScript = path.join(specmemPkgDir, 'scripts', 'first-run-model-setup.cjs');
|
|
5485
|
+
if (fs.existsSync(setupScript)) {
|
|
5486
|
+
execSync(`node "${setupScript}"`, { stdio: 'inherit', timeout: 600000 }); // 10 min timeout
|
|
5487
|
+
// Create marker file to indicate setup is complete
|
|
5488
|
+
fs.writeFileSync(setupMarker, new Date().toISOString());
|
|
5489
|
+
console.log(`\n${c.green}✓ Setup complete!${c.reset}\n`);
|
|
5490
|
+
} else {
|
|
5491
|
+
console.log(`${c.yellow}⚠ Setup script not found, continuing anyway...${c.reset}\n`);
|
|
5492
|
+
}
|
|
5493
|
+
} catch (e) {
|
|
5494
|
+
console.log(`${c.yellow}⚠ Setup had issues but continuing with init...${c.reset}`);
|
|
5495
|
+
console.log(`${c.dim}You can run 'specmem setup' manually later${c.reset}\n`);
|
|
5496
|
+
}
|
|
5497
|
+
}
|
|
5498
|
+
|
|
5459
5499
|
// ========== PRE-STAGE: Kill Old Stuck Init Processes ==========
|
|
5460
5500
|
// Prevent resource conflicts by killing old specmem-init processes for THIS PROJECT ONLY
|
|
5461
5501
|
// CRITICAL: Use realpath to normalize paths and avoid killing other projects' processes
|