@chikhamx/voidx 2.2.1 → 3.0.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.
Files changed (2) hide show
  1. package/bin/voidx.js +65 -1
  2. package/package.json +1 -1
package/bin/voidx.js CHANGED
@@ -22,7 +22,12 @@ function main(argv = process.argv.slice(2), env = process.env) {
22
22
  const venvDir = resolveVenvDir(env);
23
23
  ensureVenv(python, venvDir, env);
24
24
  const executable = resolveVoidxExecutable(venvDir);
25
- const child = spawn(executable, argv, { stdio: "inherit" });
25
+ const childEnv = {
26
+ ...env,
27
+ VOIDX_LAUNCHED_BY_NPM: "1",
28
+ VOIDX_NPM_PACKAGE_VERSION: pkg.version,
29
+ };
30
+ const child = spawn(executable, argv, { stdio: "inherit", env: childEnv });
26
31
  child.on("exit", (code, signal) => {
27
32
  if (signal) {
28
33
  process.kill(process.pid, signal);
@@ -197,6 +202,9 @@ function ensureVenv(python, venvDir, env) {
197
202
  return;
198
203
  }
199
204
 
205
+ // v2 → v3 migration: clean up legacy data before first v3 run
206
+ runV2CleanupIfNeeded(venvDir, env);
207
+
200
208
  fs.mkdirSync(path.dirname(venvDir), { recursive: true });
201
209
  const venvPython = resolveVenvPython(venvDir);
202
210
 
@@ -292,6 +300,62 @@ function ensureVenv(python, venvDir, env) {
292
300
  fs.writeFileSync(markerPath, marker);
293
301
  }
294
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
+
295
359
  // ── Helpers ────────────────────────────────────────────────────────────────
296
360
 
297
361
  function readFile(filePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chikhamx/voidx",
3
- "version": "2.2.1",
3
+ "version": "3.0.0",
4
4
  "description": "npm launcher for voidx, a terminal AI coding agent.",
5
5
  "bin": {
6
6
  "voidx": "bin/voidx.js"