@pmaddire/gcie 0.1.2 → 0.1.3

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/README.md +1 -0
  2. package/bin/gcie.js +53 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -105,6 +105,7 @@ npx gcie@latest
105
105
  ```
106
106
 
107
107
  This runs `gcie setup .` in the current repo by default.
108
+ If Python deps are missing, GCIE now bootstraps a local package venv and installs required runtime dependencies automatically on first run.
108
109
 
109
110
  Optional setup flags are passed through:
110
111
 
package/bin/gcie.js CHANGED
@@ -5,19 +5,36 @@ const { spawnSync } = require("child_process");
5
5
  const { existsSync } = require("fs");
6
6
  const { join, resolve, delimiter } = require("path");
7
7
 
8
- function resolvePython(gcieRoot) {
8
+ function run(cmd, args, env, stdio = "inherit") {
9
+ return spawnSync(cmd, args, { stdio, env });
10
+ }
11
+
12
+ function resolveVenvPython(gcieRoot) {
9
13
  const winVenv = join(gcieRoot, ".venv", "Scripts", "python.exe");
10
14
  const nixVenv = join(gcieRoot, ".venv", "bin", "python");
11
-
12
15
  if (existsSync(winVenv)) return winVenv;
13
16
  if (existsSync(nixVenv)) return nixVenv;
14
-
15
17
  return null;
16
18
  }
17
19
 
18
- function tryCommand(cmd, args, env) {
19
- const result = spawnSync(cmd, args, { stdio: "inherit", env });
20
- return result.status === 0;
20
+ function createVenv(gcieRoot, env) {
21
+ const venvDir = join(gcieRoot, ".venv");
22
+
23
+ let r = run("py", ["-3", "-m", "venv", venvDir], env, "pipe");
24
+ if (r.status === 0) return true;
25
+
26
+ r = run("python", ["-m", "venv", venvDir], env, "pipe");
27
+ return r.status === 0;
28
+ }
29
+
30
+ function installDeps(venvPython, env) {
31
+ const deps = ["typer", "networkx", "GitPython"];
32
+ const r = run(venvPython, ["-m", "pip", "install", "--disable-pip-version-check", "--quiet", ...deps], env);
33
+ return r.status === 0;
34
+ }
35
+
36
+ function runCli(pythonCmd, cliArgs, env) {
37
+ return run(pythonCmd, ["-m", "cli.app", ...cliArgs], env);
21
38
  }
22
39
 
23
40
  function main() {
@@ -30,16 +47,39 @@ function main() {
30
47
  const env = { ...process.env };
31
48
  env.PYTHONPATH = env.PYTHONPATH ? `${gcieRoot}${delimiter}${env.PYTHONPATH}` : gcieRoot;
32
49
 
33
- const venvPython = resolvePython(gcieRoot);
34
- if (venvPython) {
35
- process.exit(spawnSync(venvPython, ["-m", "cli.app", ...cliArgs], { stdio: "inherit", env }).status || 0);
50
+ let venvPython = resolveVenvPython(gcieRoot);
51
+ if (!venvPython) {
52
+ console.error("[GCIE] No local venv found. Bootstrapping Python environment...");
53
+ if (!createVenv(gcieRoot, env)) {
54
+ console.error("No Python interpreter found. Install Python 3.11+ and retry.");
55
+ process.exit(1);
56
+ }
57
+ venvPython = resolveVenvPython(gcieRoot);
58
+ if (!venvPython) {
59
+ console.error("[GCIE] Failed to create .venv.");
60
+ process.exit(1);
61
+ }
62
+ if (!installDeps(venvPython, env)) {
63
+ console.error("[GCIE] Failed to install Python dependencies (typer, networkx, GitPython).");
64
+ process.exit(1);
65
+ }
36
66
  }
37
67
 
38
- if (tryCommand("python", ["-m", "cli.app", ...cliArgs], env)) return;
39
- if (tryCommand("py", ["-3", "-m", "cli.app", ...cliArgs], env)) return;
68
+ let result = runCli(venvPython, cliArgs, env);
69
+ if (result.status === 0) {
70
+ process.exit(0);
71
+ }
72
+
73
+ const stderr = (result.stderr || "").toString();
74
+ if (stderr.includes("No module named") || stderr.includes("ModuleNotFoundError")) {
75
+ console.error("[GCIE] Missing Python deps detected. Installing required dependencies...");
76
+ if (installDeps(venvPython, env)) {
77
+ result = runCli(venvPython, cliArgs, env);
78
+ process.exit(result.status || 0);
79
+ }
80
+ }
40
81
 
41
- console.error("No Python interpreter found. Create a .venv in the GCIE repo or install Python 3.11+.");
42
- process.exit(1);
82
+ process.exit(result.status || 1);
43
83
  }
44
84
 
45
85
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmaddire/gcie",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "GraphCode Intelligence Engine one-command setup and context CLI",
5
5
  "bin": {
6
6
  "gcie": "bin/gcie.js",