codegpt-ai 1.3.0 → 1.5.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/setup.js +27 -18
  2. package/chat.py +37 -34
  3. package/package.json +1 -1
package/bin/setup.js CHANGED
@@ -1,5 +1,10 @@
1
1
  #!/usr/bin/env node
2
- // Post-install: ensure Python deps are installed
2
+ /**
3
+ * Post-install: check environment, DO NOT auto-install pip packages.
4
+ * Users must explicitly run `ai setup` or `pip install` themselves.
5
+ * This prevents supply chain attacks via transitive dependency hijacking.
6
+ */
7
+
3
8
  const { execSync } = require("child_process");
4
9
 
5
10
  const pythonCmds = process.platform === "win32"
@@ -18,23 +23,27 @@ function findPython() {
18
23
 
19
24
  const python = findPython();
20
25
 
21
- if (!python) {
22
- console.log("\n CodeGPT installed but Python not found.");
23
- console.log(" Install Python from https://python.org");
24
- console.log(" Then run: pip install requests rich prompt-toolkit\n");
25
- process.exit(0);
26
- }
26
+ console.log("\n CodeGPT installed successfully.\n");
27
27
 
28
- // Install Python deps
29
- console.log(" Installing Python dependencies...");
30
- try {
31
- execSync(`${python} -m pip install requests rich prompt-toolkit --quiet`, {
32
- stdio: "inherit",
33
- });
34
- console.log(" Python dependencies installed.");
35
- } catch {
36
- console.log(" Warning: Could not install Python deps.");
37
- console.log(" Run manually: pip install requests rich prompt-toolkit");
28
+ if (python) {
29
+ // Check if deps are already installed
30
+ let depsOk = true;
31
+ try {
32
+ execSync(`${python} -c "import requests, rich, prompt_toolkit"`, { stdio: "pipe" });
33
+ } catch {
34
+ depsOk = false;
35
+ }
36
+
37
+ if (depsOk) {
38
+ console.log(" Python dependencies: ready");
39
+ } else {
40
+ console.log(" Python found but dependencies missing.");
41
+ console.log(" Run: pip install requests rich prompt-toolkit");
42
+ }
43
+ } else {
44
+ console.log(" Python not found — Node.js mode will be used.");
45
+ console.log(" Install Python for the full 80+ command experience.");
38
46
  }
39
47
 
40
- console.log("\n CodeGPT ready! Type: ai\n");
48
+ console.log("\n Type: ai");
49
+ console.log(" Docs: https://github.com/CCguvycu/codegpt\n");
package/chat.py CHANGED
@@ -4186,39 +4186,7 @@ def main():
4186
4186
  available_models = models
4187
4187
  break
4188
4188
 
4189
- # Try 4: Ask user (but don't quit if they skip)
4190
- if not available_models:
4191
- clear_screen()
4192
- console.print(Panel(
4193
- Text.from_markup(
4194
- "[bold yellow]No AI backend found.[/]\n\n"
4195
- " [bold]Options:[/]\n"
4196
- " 1. Enter your PC's Ollama URL below\n"
4197
- " 2. Press Enter to start offline (commands still work)\n"
4198
- " 3. Install Ollama: [bright_cyan]https://ollama.com[/]\n"
4199
- ),
4200
- title="[bold yellow]Setup[/]",
4201
- border_style="yellow", padding=(1, 2),
4202
- ))
4203
- try:
4204
- remote = prompt([("class:prompt", " Ollama URL (or Enter to skip) > ")], style=input_style).strip()
4205
- if remote:
4206
- if not remote.startswith("http"):
4207
- remote = "http://" + remote
4208
- OLLAMA_URL = remote if "/api/chat" in remote else f"{remote.rstrip('/')}/api/chat"
4209
- available_models = try_connect(OLLAMA_URL)
4210
- if available_models:
4211
- console.print(Panel(Text(f"Connected: {OLLAMA_URL}", style="green"), border_style="green"))
4212
- # Save for next time
4213
- config_file = Path.home() / ".codegpt" / "ollama_url"
4214
- config_file.parent.mkdir(parents=True, exist_ok=True)
4215
- config_file.write_text(OLLAMA_URL)
4216
- else:
4217
- print_sys("Cannot reach that URL. Starting offline.")
4218
- except (KeyboardInterrupt, EOFError):
4219
- pass
4220
-
4221
- # Try 5: Load saved URL from last session
4189
+ # Try 4: Load saved URL from last session
4222
4190
  if not available_models:
4223
4191
  saved_url = Path.home() / ".codegpt" / "ollama_url"
4224
4192
  if saved_url.exists():
@@ -4232,6 +4200,9 @@ def main():
4232
4200
  # Always continue — offline mode if no backend
4233
4201
  if not available_models:
4234
4202
  available_models = [MODEL] # Use default model name as placeholder
4203
+ offline_mode = True
4204
+ else:
4205
+ offline_mode = False
4235
4206
 
4236
4207
  # Load profile
4237
4208
  profile = load_profile()
@@ -4250,10 +4221,42 @@ def main():
4250
4221
  system = PERSONAS.get(persona_name, SYSTEM_PROMPT)
4251
4222
 
4252
4223
  print_header(model)
4253
- if not first_time:
4224
+
4225
+ # Welcome popup
4226
+ if first_time:
4227
+ pass # Setup wizard already shown
4228
+ elif offline_mode:
4229
+ w = tw()
4230
+ compact = is_compact()
4231
+ name = profile.get("name", "User")
4232
+
4233
+ if compact:
4234
+ console.print(Panel(
4235
+ Text.from_markup(
4236
+ f"[bold]Hey {name}![/]\n\n"
4237
+ f" [dim]Offline mode[/]\n"
4238
+ f" [dim]Use /connect IP[/]\n"
4239
+ f" [dim]to link your PC[/]\n"
4240
+ ),
4241
+ title="[bold bright_cyan]Welcome[/]",
4242
+ border_style="bright_cyan", padding=(0, 1), width=w,
4243
+ ))
4244
+ else:
4245
+ console.print(Panel(
4246
+ Text.from_markup(
4247
+ f"[bold]Welcome back, {name}![/]\n\n"
4248
+ f" Status: [yellow]offline[/] — no Ollama found\n"
4249
+ f" Fix: [bright_cyan]/connect YOUR_PC_IP[/]\n\n"
4250
+ f" [dim]All commands work. AI responses need a connection.[/]"
4251
+ ),
4252
+ title="[bold bright_cyan]Welcome[/]",
4253
+ border_style="bright_cyan", padding=(1, 2), width=w,
4254
+ ))
4255
+ else:
4254
4256
  name = profile.get("name", "")
4255
4257
  if name:
4256
4258
  console.print(Align.center(Text(f"Welcome back, {name}.\n", style="bold white")), width=tw())
4259
+
4257
4260
  print_welcome(model, available_models)
4258
4261
 
4259
4262
  while True:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codegpt-ai",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Local AI Assistant Hub — 80+ commands, 29 tools, 8 agents, training, security",
5
5
  "author": "ArukuX",
6
6
  "license": "MIT",