@chikhamx/voidx 2.3.0 → 3.1.0

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.
@@ -418,10 +418,12 @@ function buildPythonDownloadUrl(mirrorBase, tag, filename) {
418
418
  return `${mirrorBase}/${tag}/${filename}`;
419
419
  }
420
420
 
421
- main().catch((err) => {
422
- console.error(`\n❌ Setup failed: ${err.message}\n`);
423
- process.exit(1);
424
- });
421
+ if (require.main === module) {
422
+ main().catch((err) => {
423
+ console.error(`\n❌ Setup failed: ${err.message}\n`);
424
+ process.exit(1);
425
+ });
426
+ }
425
427
 
426
428
  module.exports = {
427
429
  buildPythonDownloadUrl,
package/bin/voidx.js CHANGED
@@ -202,6 +202,9 @@ function ensureVenv(python, venvDir, env) {
202
202
  return;
203
203
  }
204
204
 
205
+ // v2 → v3 migration: clean up legacy data before first v3 run
206
+ runV2CleanupIfNeeded(venvDir, env);
207
+
205
208
  fs.mkdirSync(path.dirname(venvDir), { recursive: true });
206
209
  const venvPython = resolveVenvPython(venvDir);
207
210
 
@@ -297,6 +300,62 @@ function ensureVenv(python, venvDir, env) {
297
300
  fs.writeFileSync(markerPath, marker);
298
301
  }
299
302
 
303
+ // ── v2 → v3 migration ─────────────────────────────────────────────────────
304
+
305
+ function runV2CleanupIfNeeded(venvDir, env) {
306
+ const markerPath = path.join(venvDir, ".voidx-install-version");
307
+ const oldMarker = readFile(markerPath).trim();
308
+ if (!oldMarker) return; // fresh install, nothing to migrate
309
+
310
+ const oldVersion = parseVersion(oldMarker.split("\n")[0]);
311
+ if (!oldVersion) return;
312
+
313
+ // Only run cleanup when upgrading from < 3.0.0
314
+ const v3 = [3, 0, 0];
315
+ if (
316
+ oldVersion[0] > v3[0] ||
317
+ (oldVersion[0] === v3[0] && oldVersion[1] > v3[1]) ||
318
+ (oldVersion[0] === v3[0] && oldVersion[1] === v3[1] && oldVersion[2] >= v3[2])
319
+ ) {
320
+ return;
321
+ }
322
+
323
+ console.error("\n🔄 Upgrading from v2 — cleaning up legacy data…\n");
324
+
325
+ const venvPython = resolveVenvPython(venvDir);
326
+ if (!fs.existsSync(venvPython)) return; // venv not built yet, will clean after install
327
+
328
+ // Download and run the cleanup script from GitHub
329
+ const scriptUrl =
330
+ "https://raw.githubusercontent.com/chikhamx/voidx/master/scripts/clean_v2_data.py";
331
+ const tmpScript = path.join(os.tmpdir(), "voidx-clean-v2-data.py");
332
+
333
+ try {
334
+ const curlResult = spawnSync(
335
+ process.platform === "win32" ? "curl.exe" : "curl",
336
+ ["-fsSL", scriptUrl, "-o", tmpScript],
337
+ { encoding: "utf8", windowsHide: true, timeout: 15000 }
338
+ );
339
+ if (curlResult.error || curlResult.status !== 0) {
340
+ console.error(" ⚠️ Could not download v2 cleanup script, skipping.");
341
+ return;
342
+ }
343
+
344
+ const pyResult = spawnSync(
345
+ venvPython,
346
+ [tmpScript],
347
+ { encoding: "utf8", stdio: "inherit", windowsHide: true, timeout: 30000 }
348
+ );
349
+ if (pyResult.error || pyResult.status !== 0) {
350
+ console.error(" ⚠️ v2 cleanup script failed, continuing anyway.");
351
+ }
352
+
353
+ try { fs.unlinkSync(tmpScript); } catch {}
354
+ } catch (err) {
355
+ console.error(` ⚠️ v2 cleanup error: ${err.message}`);
356
+ }
357
+ }
358
+
300
359
  // ── Helpers ────────────────────────────────────────────────────────────────
301
360
 
302
361
  function readFile(filePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chikhamx/voidx",
3
- "version": "2.3.0",
3
+ "version": "3.1.0",
4
4
  "description": "npm launcher for voidx, a terminal AI coding agent.",
5
5
  "bin": {
6
6
  "voidx": "bin/voidx.js"