codegpt-ai 1.4.0 → 1.7.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.
- package/chat.py +117 -50
- package/package.json +1 -1
package/chat.py
CHANGED
|
@@ -702,15 +702,40 @@ def show_profile():
|
|
|
702
702
|
|
|
703
703
|
|
|
704
704
|
def setup_profile():
|
|
705
|
-
"""First-time profile setup wizard."""
|
|
705
|
+
"""First-time welcome & profile setup wizard."""
|
|
706
706
|
w = tw()
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
707
|
+
compact = is_compact()
|
|
708
|
+
|
|
709
|
+
# Big welcome popup
|
|
710
|
+
if compact:
|
|
711
|
+
console.print(Panel(
|
|
712
|
+
Text.from_markup(
|
|
713
|
+
"[bold bright_cyan]Welcome to CodeGPT![/]\n\n"
|
|
714
|
+
" Your local AI assistant.\n"
|
|
715
|
+
" 80+ commands. 8 agents.\n"
|
|
716
|
+
" 29 tools. No cloud needed.\n\n"
|
|
717
|
+
" Powered by [bold]Ollama[/].\n"
|
|
718
|
+
),
|
|
719
|
+
border_style="bright_cyan", padding=(0, 1), width=w,
|
|
720
|
+
))
|
|
721
|
+
else:
|
|
722
|
+
console.print(Panel(
|
|
723
|
+
Text.from_markup(
|
|
724
|
+
"[bold bright_cyan]Welcome to CodeGPT![/]\n\n"
|
|
725
|
+
" Your local AI assistant hub.\n\n"
|
|
726
|
+
" [bright_cyan]80+[/] slash commands\n"
|
|
727
|
+
" [bright_cyan]8[/] AI agents (coder, debugger, reviewer...)\n"
|
|
728
|
+
" [bright_cyan]29[/] AI tool integrations (Claude, Codex, Gemini...)\n"
|
|
729
|
+
" [bright_cyan]6[/] personas (hacker, teacher, architect...)\n"
|
|
730
|
+
" [bright_cyan]15[/] prompt templates\n\n"
|
|
731
|
+
" No cloud. No API keys. Powered by [bold]Ollama[/].\n\n"
|
|
732
|
+
" [dim]Let's set up your profile — takes 10 seconds.[/]"
|
|
733
|
+
),
|
|
734
|
+
title="[bold bright_cyan]CodeGPT v1.0[/]",
|
|
735
|
+
border_style="bright_cyan", padding=(1, 2), width=w,
|
|
736
|
+
))
|
|
737
|
+
|
|
738
|
+
console.print()
|
|
714
739
|
|
|
715
740
|
try:
|
|
716
741
|
name = prompt([("class:prompt", " Your name > ")], style=input_style).strip()
|
|
@@ -726,12 +751,38 @@ def setup_profile():
|
|
|
726
751
|
profile["total_sessions"] = 1
|
|
727
752
|
save_profile(profile)
|
|
728
753
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
754
|
+
# Post-setup quick start guide
|
|
755
|
+
if compact:
|
|
756
|
+
console.print(Panel(
|
|
757
|
+
Text.from_markup(
|
|
758
|
+
f"[bold green]Hey {profile['name']}![/]\n\n"
|
|
759
|
+
" [dim]Quick start:[/]\n"
|
|
760
|
+
" Just type to chat\n"
|
|
761
|
+
" [bright_cyan]/[/] see all commands\n"
|
|
762
|
+
" [bright_cyan]/help[/] full guide\n"
|
|
763
|
+
" [bright_cyan]/connect IP[/] link PC\n"
|
|
764
|
+
),
|
|
765
|
+
title="[bold green]Ready[/]",
|
|
766
|
+
border_style="green", padding=(0, 1), width=w,
|
|
767
|
+
))
|
|
768
|
+
else:
|
|
769
|
+
console.print(Panel(
|
|
770
|
+
Text.from_markup(
|
|
771
|
+
f"[bold green]Welcome, {profile['name']}![/]\n\n"
|
|
772
|
+
" [bold]Quick start:[/]\n"
|
|
773
|
+
" [bright_cyan]Just type[/] Chat with the AI\n"
|
|
774
|
+
" [bright_cyan]/[/] See all commands\n"
|
|
775
|
+
" [bright_cyan]/help[/] Full command list\n"
|
|
776
|
+
" [bright_cyan]/persona hacker[/] Change personality\n"
|
|
777
|
+
" [bright_cyan]/agent coder[/] Use a specialist agent\n"
|
|
778
|
+
" [bright_cyan]/all question[/] Ask all 8 agents at once\n"
|
|
779
|
+
" [bright_cyan]/tools[/] Browse 29 AI tools\n"
|
|
780
|
+
" [bright_cyan]/connect IP[/] Connect to remote Ollama\n\n"
|
|
781
|
+
" [dim]Tip: Press / to see autocomplete suggestions.[/]"
|
|
782
|
+
),
|
|
783
|
+
title="[bold green]You're all set[/]",
|
|
784
|
+
border_style="green", padding=(1, 2), width=w,
|
|
785
|
+
))
|
|
735
786
|
console.print()
|
|
736
787
|
|
|
737
788
|
|
|
@@ -4186,39 +4237,7 @@ def main():
|
|
|
4186
4237
|
available_models = models
|
|
4187
4238
|
break
|
|
4188
4239
|
|
|
4189
|
-
# Try 4:
|
|
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
|
|
4240
|
+
# Try 4: Load saved URL from last session
|
|
4222
4241
|
if not available_models:
|
|
4223
4242
|
saved_url = Path.home() / ".codegpt" / "ollama_url"
|
|
4224
4243
|
if saved_url.exists():
|
|
@@ -4232,6 +4251,9 @@ def main():
|
|
|
4232
4251
|
# Always continue — offline mode if no backend
|
|
4233
4252
|
if not available_models:
|
|
4234
4253
|
available_models = [MODEL] # Use default model name as placeholder
|
|
4254
|
+
offline_mode = True
|
|
4255
|
+
else:
|
|
4256
|
+
offline_mode = False
|
|
4235
4257
|
|
|
4236
4258
|
# Load profile
|
|
4237
4259
|
profile = load_profile()
|
|
@@ -4250,10 +4272,55 @@ def main():
|
|
|
4250
4272
|
system = PERSONAS.get(persona_name, SYSTEM_PROMPT)
|
|
4251
4273
|
|
|
4252
4274
|
print_header(model)
|
|
4275
|
+
|
|
4276
|
+
# Welcome popup — always show
|
|
4253
4277
|
if not first_time:
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4278
|
+
w = tw()
|
|
4279
|
+
compact = is_compact()
|
|
4280
|
+
name = profile.get("name", "User")
|
|
4281
|
+
is_local = "localhost" in OLLAMA_URL or "127.0.0.1" in OLLAMA_URL
|
|
4282
|
+
server = "local" if is_local else OLLAMA_URL.split("//")[1].split("/")[0] if "//" in OLLAMA_URL else "unknown"
|
|
4283
|
+
model_count = len(available_models)
|
|
4284
|
+
sessions = profile.get("total_sessions", 0)
|
|
4285
|
+
total_msgs = profile.get("total_messages", 0)
|
|
4286
|
+
|
|
4287
|
+
hour = datetime.now().hour
|
|
4288
|
+
greeting = "Good morning" if hour < 12 else "Good afternoon" if hour < 18 else "Good evening"
|
|
4289
|
+
|
|
4290
|
+
if compact:
|
|
4291
|
+
if offline_mode:
|
|
4292
|
+
status_line = "[yellow]offline[/] — /connect IP"
|
|
4293
|
+
else:
|
|
4294
|
+
status_line = f"[green]connected[/] {model_count} models"
|
|
4295
|
+
|
|
4296
|
+
console.print(Panel(
|
|
4297
|
+
Text.from_markup(
|
|
4298
|
+
f"[bold]{greeting}, {name}![/]\n\n"
|
|
4299
|
+
f" Model [bright_cyan]{model}[/]\n"
|
|
4300
|
+
f" Status {status_line}\n"
|
|
4301
|
+
f" Session [dim]#{sessions}[/]\n"
|
|
4302
|
+
),
|
|
4303
|
+
title="[bold bright_cyan]CodeGPT[/]",
|
|
4304
|
+
border_style="bright_cyan", padding=(0, 1), width=w,
|
|
4305
|
+
))
|
|
4306
|
+
else:
|
|
4307
|
+
if offline_mode:
|
|
4308
|
+
status_line = f" Server: [yellow]offline[/] — use [bright_cyan]/connect IP[/] to link"
|
|
4309
|
+
else:
|
|
4310
|
+
status_line = f" Server: [green]{server}[/] ({model_count} models)"
|
|
4311
|
+
|
|
4312
|
+
console.print(Panel(
|
|
4313
|
+
Text.from_markup(
|
|
4314
|
+
f"[bold]{greeting}, {name}![/]\n\n"
|
|
4315
|
+
f" Model: [bright_cyan]{model}[/]\n"
|
|
4316
|
+
f"{status_line}\n"
|
|
4317
|
+
f" Session: [dim]#{sessions}[/] ({total_msgs} lifetime msgs)\n\n"
|
|
4318
|
+
f" [dim]Type / for commands · /help for full list[/]"
|
|
4319
|
+
),
|
|
4320
|
+
title="[bold bright_cyan]Welcome[/]",
|
|
4321
|
+
border_style="bright_cyan", padding=(1, 2), width=w,
|
|
4322
|
+
))
|
|
4323
|
+
|
|
4257
4324
|
print_welcome(model, available_models)
|
|
4258
4325
|
|
|
4259
4326
|
while True:
|