diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c61ceb4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# Python +__pycache__/ +*.py[cod] +*.pyo +*.egg-info/ +dist/ +build/ +*.egg +*.whl + +# Virtual environments +venv/ +.venv/ +env/ +.env/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# User config & credentials +.npmai_agent/ +Desktop_App/app_config.json + +# Build artifacts +*.exe +*.zip +*.dmg + +# Logs +*.log diff --git a/Desktop_App/app.py b/Desktop_App/app.py index a74c7e5..4df2d8b 100644 --- a/Desktop_App/app.py +++ b/Desktop_App/app.py @@ -5,7 +5,7 @@ THIS IS NOT YET DEPLOYED. Here it is about Desktop APP. """ -import sys, os, math, random, threading, json +import sys, os, math, random, json from pathlib import Path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) @@ -77,7 +77,7 @@ def _load_llm_stage_config() -> dict: cfg = {} for stage_key, _, _ in AGENT_STAGES: - if stage_key not in cfg: # ← only this line changed + if stage_key not in cfg: cfg[stage_key] = { "provider": "npmai", "model": LLM_PROVIDERS["npmai"]["model_default"] @@ -315,8 +315,8 @@ def _tick(self): if self._pulse<=0: self._pd=1 self.update() - def enterEvent(self,e): self._h=1.0 - def leaveEvent(self,e): self._h=0.0 + def enterEvent(self,e): self._h=1.0; super().enterEvent(e) + def leaveEvent(self,e): self._h=0.0; super().leaveEvent(e) def mousePressEvent(self,e): self._press=True; super().mousePressEvent(e) def mouseReleaseEvent(self,e): self._press=False; super().mouseReleaseEvent(e) @@ -345,8 +345,8 @@ def __init__(self,text,accent="#2AFFA0",parent=None): self.setFont(QFont("Segoe UI",11,QFont.DemiBold)) QTimer(self,timeout=self.update,interval=16).start() - def enterEvent(self,e): self._h=1.0 - def leaveEvent(self,e): self._h=0.0 + def enterEvent(self,e): self._h=1.0; super().enterEvent(e) + def leaveEvent(self,e): self._h=0.0; super().leaveEvent(e) def paintEvent(self,_): p=QPainter(self); p.setRenderHint(QPainter.Antialiasing) @@ -456,8 +456,8 @@ def _tick(self): self._h+=(t-self._h)*0.1; self.update() def set_active(self,v): self._active=v; self.update() - def enterEvent(self,e): self._hf=True - def leaveEvent(self,e): self._hf=False + def enterEvent(self,e): self._hf=True; super().enterEvent(e) + def leaveEvent(self,e): self._hf=False; super().leaveEvent(e) def mousePressEvent(self,e): self.clicked.emit(self._idx) def paintEvent(self,_): @@ -893,8 +893,8 @@ def _log(self, html:str): self._log_box.verticalScrollBar().setValue(self._log_box.verticalScrollBar().maximum()) def _voice_input(self): - """ If you are working with voice input kindly read the documentation of npmai_agents and this code uses - npmai_agents version 1.0.2, npmai_agents change frequently although not syntax but it will be better to read + """If you are working with voice input kindly read the documentation of npmai_agents and this code uses + npmai_agents version 1.0.2, npmai_agents change frequently although not syntax but it will be better to read before making any change.""" """ old VoiceTool.listen(): SpeechAITool.transcribe_realtime """ from npmai_agents.Tools_security_ai import SpeechAITool diff --git a/Desktop_App/app_config.json b/Desktop_App/app_config.json index fe3d1d8..efb9c7e 100644 --- a/Desktop_App/app_config.json +++ b/Desktop_App/app_config.json @@ -1,5 +1,5 @@ { "url": "https://qyxuvuhhaspkuhbognyk.supabase.co", - "annon_key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InF5eHV2dWhoYXNwa3VoYm9nbnlrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3ODQ3MDYwNzYsImV4cCI6MjEwMDI4MjA3Nn0.h3hyVr_OV38SfY2_2qQ6Hgtm6_FbvNQ31AG5YO7mVko", + "anon_key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InF5eHV2dWhoYXNwa3VoYm9nbnlrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3ODQ3MDYwNzYsImV4cCI6MjEwMDI4MjA3Nn0.h3hyVr_OV38SfY2_2qQ6Hgtm6_FbvNQ31AG5YO7mVko", "mcp_base_url": "https://your-mcp-server.hf.space/mcp" } diff --git a/Desktop_App/mcp_link.py b/Desktop_App/mcp_link.py index be23d74..b89541f 100644 --- a/Desktop_App/mcp_link.py +++ b/Desktop_App/mcp_link.py @@ -1,4 +1,3 @@ -import os import json import uuid import threading @@ -13,13 +12,20 @@ CONFIG_URL = "https://raw.githubusercontent.com/npmaiecosystem/NPM-AutoCode-AI/refs/heads/main/Desktop_App/app_config.json" def load_config() -> dict: - """Fetch latest config from GitHub""" + """Fetch latest config from GitHub (primary), fall back to bundled file.""" try: response = requests.get(CONFIG_URL, timeout=8) if response.status_code == 200: return response.json() except Exception as e: print(f"Failed to fetch remote config: {e}") + bundled = Path(__file__).resolve().parent / "app_config.json" + if bundled.exists(): + try: + return json.loads(bundled.read_text()) + except Exception: + pass + return {} def save_config(url: str, anon_key: str, mcp_base_url: str = None): @@ -61,12 +67,12 @@ def _get_client(self): "The 'supabase' package isn't installed. Run: pip install supabase" ) cfg = load_config() - if not cfg.get("SUPABASE_URL") or not cfg.get("SUPABASE_ANNON_KEY"): + if not cfg.get("url") or not cfg.get("anon_key"): raise SupabaseAuthError( "Supabase isn't configured yet. Set SUPABASE_URL and SUPABASE_ANON_KEY " "env vars, or call mcp_link.save_config(url, anon_key) once from Settings." ) - self._client = create_client(cfg["SUPABASE_URL"], cfg["SUPABASE_ANNON_KEY"]) + self._client = create_client(cfg["url"], cfg["anon_key"]) return self._client def sign_up(self, email: str, password: str): diff --git a/Desktop_App/requirements.txt b/Desktop_App/requirements.txt index 8c420a1..25bd6c8 100644 --- a/Desktop_App/requirements.txt +++ b/Desktop_App/requirements.txt @@ -5,3 +5,5 @@ langchain-community npmai==0.1.9 npmai-agents==1.0.2 supabase +cryptography +requests diff --git a/Docs/Docs.md b/Docs/Docs.md index ae924c0..3c07c81 100644 --- a/Docs/Docs.md +++ b/Docs/Docs.md @@ -5,7 +5,7 @@ Install the app: [Download Latest Release](https://github.com/sonuramashishnpm/NPM-AutoCode-AI/releases/download/v2.0/NPM_AutoCode_AI.zip) 1. Unzip the file. -2. Run `NPM_AutoCode_AI.exe` (Windows) or `python main.py` (Python 3.12+). +2. Run `NPM_AutoCode_AI.exe` (Windows) or `python Desktop_App/app.py` (Python 3.12+). 3. Enter your task in the input box (e.g., "Plot a sine wave"). 4. Click **Generate & Execute**. 5. Watch logs and progress bar – AI generates, checks safety, executes, and fixes errors if needed. diff --git a/README.md b/README.md index d76f6cf..136576b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Install the app: [Download Latest Release](https://github.com/sonuramashishnpm/NPM-AutoCode-AI/releases/download/v2.2/NPM_AutoCode_AI.zip) 1. Unzip the file. -2. Run `NPM_AutoCode_AI.exe` (Windows) or `python main.py` (Python 3.12+). +2. Run `NPM_AutoCode_AI.exe` (Windows) or `python Desktop_App/app.py` (Python 3.12+). 3. Enter your task in the input box (e.g., "Plot a sine wave"). 4. Click **Generate & Execute**. 5. Watch logs and progress bar – AI generates, checks safety, executes, and fixes errors if needed.