ghostcode-canary 0.2.1-canary.0 → 0.2.1-canary.2

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 (4) hide show
  1. package/cli.js +16 -2
  2. package/package.json +1 -1
  3. package/promt.md +24 -0
  4. package/setup.js +20 -34
package/cli.js CHANGED
@@ -41,10 +41,24 @@ function checkPython() {
41
41
  }
42
42
 
43
43
  const root = __dirname;
44
+ const isTermuxFlag = isTermux();
44
45
  const venv = path.join(root, ".venv");
45
46
  const binDir = isWindows ? "Scripts" : "bin";
46
47
  const pythonExe = isWindows ? "python.exe" : "python";
47
48
  const python = path.join(venv, binDir, pythonExe);
49
+ const sysPython = "python";
50
+
51
+ function needSetup() {
52
+ if (isTermuxFlag) {
53
+ try { execSync(sysPython + ' -c "import ghostcode"', { stdio: "pipe" }); return false; }
54
+ catch { return true; }
55
+ }
56
+ return !fs.existsSync(python);
57
+ }
58
+
59
+ function pythonCmd() {
60
+ return isTermuxFlag ? sysPython : python;
61
+ }
48
62
 
49
63
  const args = process.argv.slice(2);
50
64
  if (args[0] === "uninstall") {
@@ -77,7 +91,7 @@ if (args[0] === "uninstall") {
77
91
  process.exit(0);
78
92
  }
79
93
 
80
- if (!fs.existsSync(python)) {
94
+ if (needSetup()) {
81
95
  console.error("First run detected — setting up...");
82
96
  checkPython();
83
97
  try {
@@ -90,7 +104,7 @@ if (!fs.existsSync(python)) {
90
104
  }
91
105
  }
92
106
 
93
- const proc = spawn(python, ["-m", "ghostcode", ...args], {
107
+ const proc = spawn(pythonCmd(), ["-m", "ghostcode", ...args], {
94
108
  stdio: "inherit",
95
109
  cwd: process.cwd(),
96
110
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ghostcode-canary",
3
- "version": "0.2.1-canary.0",
3
+ "version": "0.2.1-canary.2",
4
4
  "description": "Terminal AI coding assistant — chat with LLMs, generate and save code, all from your terminal",
5
5
  "bin": {
6
6
  "ghostcode": "cli.js"
package/promt.md ADDED
@@ -0,0 +1,24 @@
1
+ I am trying to install "ghostcode-ai" globally using npm inside a Termux/proot environment (Node v20.19.2). The installation fails with this error:
2
+
3
+ "Venv verification failed after install"
4
+
5
+ The setup script tries to create a Python virtual environment in:
6
+ /root/.npm-global/lib/node_modules/ghostcode-ai/.venv
7
+
8
+ But it fails even after installing python, pip, and binutils.
9
+
10
+ Environment details:
11
+ - Running on Termux (Android) with proot
12
+ - Node.js v20.19.2
13
+ - npm global install
14
+ - Python3 is installed
15
+
16
+ I need a solution that:
17
+ 1. Fixes the Python venv creation issue in Termux/proot
18
+ 2. Ensures pip works correctly inside the venv
19
+ 3. Avoids permission/path issues common in Termux
20
+ 4. Suggests any required environment variables or flags (like --unsafe-perm)
21
+
22
+ If ghostcode-ai is incompatible with Termux, suggest a workaround or alternative setup.
23
+
24
+ Explain the root cause and provide a working fix.
package/setup.js CHANGED
@@ -8,45 +8,34 @@ const pkg = path.join(root, "src");
8
8
 
9
9
  const platform = process.platform;
10
10
  const isWindows = platform === "win32";
11
- const isMac = platform === "darwin";
12
- const isLinux = platform === "linux";
13
- const isBSD = ["freebsd", "openbsd", "netbsd"].includes(platform);
14
- const isTermux = isLinux && fs.existsSync("/data/data/com.termux");
11
+ const isTermux = platform === "linux" && fs.existsSync("/data/data/com.termux");
15
12
  const binDir = isWindows ? "Scripts" : "bin";
16
13
  const pythonExe = isWindows ? "python.exe" : "python";
17
14
  const pipExe = isWindows ? "pip.exe" : "pip";
18
15
  const python = path.join(root, ".venv", binDir, pythonExe);
19
16
  const pip = path.join(root, ".venv", binDir, pipExe);
20
-
21
17
  const venv = path.join(root, ".venv");
22
18
 
23
- function verifyVenv() {
24
- try {
25
- execSync(python + ' -c "from ghostcode.tui.screens import ChatScreen; print(\'ok\')"', {
26
- stdio: "pipe",
27
- });
28
- return true;
29
- } catch {
30
- return false;
31
- }
32
- }
33
-
34
- if (fs.existsSync(venv)) {
35
- fs.rmSync(venv, { recursive: true, force: true });
36
- }
37
-
38
19
  console.log("Setting up GhostCode...");
39
20
 
40
21
  try {
41
- const pythonCmd = isWindows ? "python" : "python3";
42
- execSync(pythonCmd + " -m venv " + (isWindows ? "" : "") + ".venv", { cwd: root, stdio: "pipe" });
43
- execSync(python + " -m pip install --upgrade pip setuptools wheel", { cwd: root, stdio: "pipe" });
44
-
45
- const extra = isTermux ? " --no-build-isolation" : " -e";
46
- execSync(pip + " install" + extra + " " + pkg, { cwd: root, stdio: "pipe" });
47
-
48
- if (!verifyVenv()) {
49
- throw new Error("Venv verification failed after install");
22
+ if (isTermux) {
23
+ // Termux: skip venv (symlink isolation broken under proot)
24
+ execSync("pip install " + pkg, { cwd: root, stdio: "pipe" });
25
+ execSync('python -c "from ghostcode.tui.screens import ChatScreen; print(\'ok\')"', { stdio: "pipe" });
26
+ } else {
27
+ if (fs.existsSync(venv)) {
28
+ fs.rmSync(venv, { recursive: true, force: true });
29
+ }
30
+ const pythonCmd = isWindows ? "python" : "python3";
31
+ execSync(pythonCmd + " -m venv .venv", { cwd: root, stdio: "pipe" });
32
+ execSync(python + " -m pip install --upgrade pip setuptools wheel", { cwd: root, stdio: "pipe" });
33
+ execSync(pip + " install -e " + pkg, { cwd: root, stdio: "pipe" });
34
+ try {
35
+ execSync(python + ' -c "from ghostcode.tui.screens import ChatScreen; print(\'ok\')"', { stdio: "pipe" });
36
+ } catch {
37
+ throw new Error("Venv verification failed after install");
38
+ }
50
39
  }
51
40
 
52
41
  console.log("GhostCode ready. Run 'ghostcode' to start.");
@@ -56,11 +45,8 @@ try {
56
45
  console.error("");
57
46
  console.error(" Termux manual:");
58
47
  console.error(" pkg install python python-pip binutils");
59
- console.error(" rm -rf " + venv);
60
- console.error(" python3 -m venv " + venv);
61
- console.error(" " + pip + " install --upgrade pip setuptools wheel");
62
- console.error(" " + pip + " install " + pkg);
63
- console.error(" " + python + " -m ghostcode");
48
+ console.error(" pip install " + pkg);
49
+ console.error(" python -m ghostcode");
64
50
  } else {
65
51
  const pythonCmd = isWindows ? "python" : "python3";
66
52
  console.error(" Try: cd " + root + " && rm -rf " + venv + " && " + pythonCmd + " -m venv " + venv + " && " + pip + " install -e ./src");