ghostcode-canary 0.2.1-canary.1 → 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.
- package/cli.js +16 -2
- package/package.json +1 -1
- package/setup.js +15 -45
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 (
|
|
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(
|
|
107
|
+
const proc = spawn(pythonCmd(), ["-m", "ghostcode", ...args], {
|
|
94
108
|
stdio: "inherit",
|
|
95
109
|
cwd: process.cwd(),
|
|
96
110
|
});
|
package/package.json
CHANGED
package/setup.js
CHANGED
|
@@ -8,61 +8,34 @@ const pkg = path.join(root, "src");
|
|
|
8
8
|
|
|
9
9
|
const platform = process.platform;
|
|
10
10
|
const isWindows = platform === "win32";
|
|
11
|
-
const
|
|
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 = isTermux || isWindows ? "python" : "python3";
|
|
42
|
-
execSync(pythonCmd + " -m venv .venv", { cwd: root, stdio: "pipe" });
|
|
43
|
-
|
|
44
22
|
if (isTermux) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
execSync(python + " -m pip install --upgrade pip setuptools wheel", { cwd: root, stdio: "pipe" });
|
|
49
|
-
}
|
|
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" });
|
|
50
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" });
|
|
51
32
|
execSync(python + " -m pip install --upgrade pip setuptools wheel", { cwd: root, stdio: "pipe" });
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (isTermux) {
|
|
33
|
+
execSync(pip + " install -e " + pkg, { cwd: root, stdio: "pipe" });
|
|
55
34
|
try {
|
|
56
|
-
execSync(
|
|
35
|
+
execSync(python + ' -c "from ghostcode.tui.screens import ChatScreen; print(\'ok\')"', { stdio: "pipe" });
|
|
57
36
|
} catch {
|
|
58
|
-
|
|
37
|
+
throw new Error("Venv verification failed after install");
|
|
59
38
|
}
|
|
60
|
-
} else {
|
|
61
|
-
execSync(pip + " install -e " + pkg, { cwd: root, stdio: "pipe" });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!verifyVenv()) {
|
|
65
|
-
throw new Error("Venv verification failed after install");
|
|
66
39
|
}
|
|
67
40
|
|
|
68
41
|
console.log("GhostCode ready. Run 'ghostcode' to start.");
|
|
@@ -70,13 +43,10 @@ try {
|
|
|
70
43
|
console.error("Setup failed:", e.message);
|
|
71
44
|
if (isTermux) {
|
|
72
45
|
console.error("");
|
|
73
|
-
console.error(" Termux manual
|
|
46
|
+
console.error(" Termux manual:");
|
|
74
47
|
console.error(" pkg install python python-pip binutils");
|
|
75
|
-
console.error("
|
|
76
|
-
console.error(" python -m
|
|
77
|
-
console.error(" " + pip + " install --upgrade pip setuptools wheel");
|
|
78
|
-
console.error(" " + pip + " install " + pkg);
|
|
79
|
-
console.error(" " + python + " -m ghostcode");
|
|
48
|
+
console.error(" pip install " + pkg);
|
|
49
|
+
console.error(" python -m ghostcode");
|
|
80
50
|
} else {
|
|
81
51
|
const pythonCmd = isWindows ? "python" : "python3";
|
|
82
52
|
console.error(" Try: cd " + root + " && rm -rf " + venv + " && " + pythonCmd + " -m venv " + venv + " && " + pip + " install -e ./src");
|