@vecanova/zana 3.0.5 → 3.2.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 (3) hide show
  1. package/bin/zana.js +33 -20
  2. package/package.json +1 -1
  3. package/postinstall.js +38 -20
package/bin/zana.js CHANGED
@@ -19,18 +19,18 @@ function findZanaBinary() {
19
19
  // 1. Check if already in PATH
20
20
  const which = process.platform === "win32" ? "where" : "which";
21
21
  try {
22
- const found = execFileSync(which, ["zana-py"], { encoding: "utf8" }).trim().split("\n")[0];
23
- if (found) return found;
22
+ const found = execFileSync(which, ["zana"], { encoding: "utf8" }).trim().split("\n")[0];
23
+ // Avoid infinite recursion if 'zana' points to this script
24
+ if (found && !found.includes("node") && !found.includes("zana-npm")) return found;
24
25
  } catch (_) {}
25
26
 
26
- // 2. Check common pip/uv install locations
27
+ // 2. Check common pipx/uv tool install locations
27
28
  const candidates = [
28
29
  path.join(os.homedir(), ".local", "bin", "zana"),
29
30
  path.join(os.homedir(), ".cargo", "bin", "zana"),
31
+ path.join(os.homedir(), ".local", "pipx", "venvs", "vecanova-zana", "bin", "zana"),
30
32
  "/usr/local/bin/zana",
31
33
  "/usr/bin/zana",
32
- // Windows pip
33
- path.join(os.homedir(), "AppData", "Local", "Programs", "Python", "Python312", "Scripts", "zana.exe"),
34
34
  ];
35
35
 
36
36
  for (const c of candidates) {
@@ -66,17 +66,31 @@ function bootstrap() {
66
66
  process.exit(1);
67
67
  }
68
68
 
69
- console.log("⚙️ Installing ZANA Python package (first run)...");
70
- const result = spawnSync(
71
- python,
72
- ["-m", "pip", "install", "--quiet", "--upgrade", "zana"],
73
- { stdio: "inherit" }
74
- );
69
+ console.log("⚙️ Installing ZANA (isolated environment)...");
75
70
 
76
- if (result.status !== 0) {
71
+ let success = false;
72
+ // Try uv tool install first (fastest)
73
+ try {
74
+ spawnSync("uv", ["tool", "install", "vecanova-zana", "--force"], { stdio: "inherit" });
75
+ success = true;
76
+ } catch (_) {
77
+ try {
78
+ // Fallback to pipx
79
+ spawnSync("pipx", ["install", "vecanova-zana", "--force"], { stdio: "inherit" });
80
+ success = true;
81
+ } catch (__) {
82
+ try {
83
+ // Last resort: pip --user
84
+ spawnSync(python, ["-m", "pip", "install", "--user", "vecanova-zana"], { stdio: "inherit" });
85
+ success = true;
86
+ } catch (___) {}
87
+ }
88
+ }
89
+
90
+ if (!success) {
77
91
  console.error(
78
- "\n❌ Failed to install ZANA Python package.\n" +
79
- " Try manually: pip install zana\n" +
92
+ "\n❌ Failed to install ZANA.\n" +
93
+ " Try manually: pipx install vecanova-zana\n" +
80
94
  " Or run the installer: bash <(curl -LsSf https://zana.vecanova.com/install.sh)\n"
81
95
  );
82
96
  process.exit(1);
@@ -94,23 +108,22 @@ if (!zanaBin) {
94
108
  zanaBin = findZanaBinary();
95
109
  }
96
110
 
111
+ const args = process.argv.slice(2);
112
+
97
113
  if (!zanaBin) {
98
- // Last resort: run via python -m cli.main
114
+ // Last resort: run via python -m zana.main
99
115
  const python = findPython();
100
116
  if (!python) {
101
- console.error("❌ Could not locate ZANA. Run: pip install zana");
117
+ console.error("❌ Could not locate ZANA. Run: pipx install vecanova-zana");
102
118
  process.exit(1);
103
119
  }
104
- zanaBin = null;
105
- const args = process.argv.slice(2);
106
- const result = spawnSync(python, ["-m", "cli.main", ...args], {
120
+ const result = spawnSync(python, ["-m", "zana.main", ...args], {
107
121
  stdio: "inherit",
108
122
  env: process.env,
109
123
  });
110
124
  process.exit(result.status ?? 1);
111
125
  }
112
126
 
113
- const args = process.argv.slice(2);
114
127
  const result = spawnSync(zanaBin, args, {
115
128
  stdio: "inherit",
116
129
  env: process.env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vecanova/zana",
3
- "version": "3.0.5",
3
+ "version": "3.2.0",
4
4
  "description": "ZANA — Zero Autonomous Neural Architecture. Every person deserves their own Aeon.",
5
5
  "keywords": [
6
6
  "ai",
package/postinstall.js CHANGED
@@ -32,21 +32,25 @@ function findPython() {
32
32
 
33
33
  function isZanaInstalled(python) {
34
34
  try {
35
- execFileSync(python, ["-c", "import cli.main"], {
36
- encoding: "utf8",
37
- stdio: ["pipe", "pipe", "pipe"],
38
- timeout: 5000,
39
- });
40
- return true;
41
- } catch (_) {}
42
- try {
43
- execFileSync(python, ["-m", "pip", "show", "zana"], {
35
+ execFileSync(python, ["-c", "import zana.main"], {
44
36
  encoding: "utf8",
45
37
  stdio: ["pipe", "pipe", "pipe"],
46
38
  timeout: 5000,
47
39
  });
48
40
  return true;
49
41
  } catch (_) {}
42
+ for (const bin of ["zana", "uv", "pipx"]) {
43
+ try {
44
+ const tool = bin === "zana" ? "uv" : bin;
45
+ const cmd = bin === "zana" ? ["tool", "list"] : ["list"];
46
+ const out = execFileSync(tool, cmd, {
47
+ encoding: "utf8",
48
+ stdio: ["pipe", "pipe", "pipe"],
49
+ timeout: 5000,
50
+ });
51
+ if (out.includes("vecanova-zana")) return true;
52
+ } catch (_) {}
53
+ }
50
54
  return false;
51
55
  }
52
56
 
@@ -68,22 +72,37 @@ if (!python) {
68
72
  console.log(`✓ Python found: ${python}`);
69
73
 
70
74
  if (isZanaInstalled(python)) {
71
- console.log("✓ ZANA Python package already installed.\n");
75
+ console.log("✓ ZANA is already installed and isolated.\n");
72
76
  console.log(" Run: zana init — to create your Aeon");
73
77
  console.log(" Run: zana --help — to explore commands\n");
74
78
  process.exit(0);
75
79
  }
76
80
 
77
- console.log("⚙️ Installing ZANA Python package via pip...");
78
- console.log(" This may take 1-2 minutes on first install.\n");
81
+ console.log("⚙️ Installing ZANA CLI (isolated environment)...");
82
+ console.log(" This ensures ZANA won't interfere with your system Python.\n");
79
83
 
80
- const result = spawnSync(
81
- python,
82
- ["-m", "pip", "install", "--upgrade", "--quiet", "zana"],
83
- { stdio: "inherit", timeout: 300_000 }
84
- );
84
+ // Strategy: 1. uv tool (fastest), 2. pipx (isolated), 3. pip --user (last resort)
85
+ let installed = false;
86
+
87
+ for (const method of ["uv", "pipx", "pip"]) {
88
+ try {
89
+ if (method === "uv") {
90
+ spawnSync("uv", ["tool", "install", "vecanova-zana", "--force"], { stdio: "inherit" });
91
+ installed = true;
92
+ break;
93
+ } else if (method === "pipx") {
94
+ spawnSync("pipx", ["install", "vecanova-zana", "--force"], { stdio: "inherit" });
95
+ installed = true;
96
+ break;
97
+ } else {
98
+ spawnSync(python, ["-m", "pip", "install", "--user", "--upgrade", "vecanova-zana"], { stdio: "inherit" });
99
+ installed = true;
100
+ break;
101
+ }
102
+ } catch (_) {}
103
+ }
85
104
 
86
- if (result.status === 0) {
105
+ if (installed) {
87
106
  console.log("\n✅ ZANA installed successfully!\n");
88
107
  console.log("╔══════════════════════════════════════════════════╗");
89
108
  console.log("║ Quick start: ║");
@@ -97,9 +116,8 @@ if (result.status === 0) {
97
116
  } else {
98
117
  console.warn(
99
118
  "\n⚠️ Could not auto-install ZANA Python package.\n" +
100
- " Run manually: pip install zana\n" +
119
+ " Run manually: pipx install vecanova-zana\n" +
101
120
  " Or: bash <(curl -LsSf https://zana.vecanova.com/install.sh)\n"
102
121
  );
103
- // non-fatal exit
104
122
  process.exit(0);
105
123
  }