Imported from hemantvirmani/DeskGenie (
AGENTS.md). Install upstream withnpx skills add hemantvirmani/DeskGenie. Copyright stays with the author.
AGENTS.md
This file provides guidance to Codex (Codex.ai/code) when working with code in this repository.
Commands
Backend
# Activate virtual environment (Windows)
venv\Scripts\activate
# Run backend / web server (no window)
python deskgenie.py --server
# Run a single query (CLI)
python deskgenie.py --query "your query here"
# Check all Python files compile
python -m compileall . -q
Frontend
cd frontend
npm install # install deps
npm run dev # dev server (port 5173, proxies API to port 8000)
npm run build # production build → frontend/dist
Desktop App (dev)
# GUI mode — native window with system tray
python deskgenie.py
# CLI mode — query via desktop entry point
python deskgenie.py --query "your query here"
# Enable DevTools (Edge inspector alongside the window)
DESKGENIE_DEBUG=1 python deskgenie.py
Production Build (exe)
# Builds frontend + packages everything into dist/windows/DeskGenie/DeskGenie.exe
python windows/build.py
Production (web server only)
Build frontend first (npm run build), then python deskgenie.py --server serves both API and static files on port 8000.
Architecture
DeskGenie is a desktop AI assistant. The user sends natural language commands via a React UI or CLI. A LangGraph agent backed by Google Gemini processes the request using 25+ tools (file ops, PDF, images, media, web search, HTTP requests, Python execution, classical ciphers), streaming logs back to the UI in real time.
React UI / CLI
↓
FastAPI (app/genie_api.py) ←→ SSE log streaming
↓
DeskGenieAgent (agents/agents.py)
↓
LangGraphAgent (agents/langgraphagent.py) ← Google Gemini
↓
Tools (tools/desktop_tools.py, tools/custom_tools.py)
Key flows
- Async chat: POST
/api/chat→ returnstask_id→ frontend polls/api/task/{id}for result, streams logs via SSE at/api/task/{id}/logs/stream. - Agent loop: LangGraphAgent builds a LangGraph state machine. State tracks
question,messages,answer,step_count,file_name. Max 25 steps per iteration, recursion limit 100.
Important files
| File | Purpose |
|---|---|
app/genie_api.py |
All REST endpoints, task store, SSE streaming |
app/config.py |
Internal engine constants (timeouts, retry, limits, ports) |
agents/langgraphagent.py |
Core LangGraph agent with Gemini |
agents/agents.py |
DeskGenieAgent wrapper — the single public interface |
tools/desktop_tools.py |
PDF, image, file, document, media tools |
tools/custom_tools.py |
Web search, Wikipedia, ArXiv, YouTube, HTTP requests, Python execution, classical ciphers, rate-limit wait, advisor |
utils/log_streamer.py |
LogStreamer (UI) and ConsoleLogger (CLI) |
utils/chat_storage.py |
JSON chat persistence (platform-specific dirs) |
resources/ui_strings.py |
All backend-facing strings (no hardcoding) |
frontend/src/uiStrings.js |
All frontend-facing strings (no hardcoding) |
resources/system_prompt.py |
Agent system prompt |
deskgenie.py |
Desktop app entry point (GUI + CLI modes) |
windows/server.py |
Port management and uvicorn server thread |
windows/single_instance.py |
Sentinel socket for single-instance enforcement |
windows/tray.py |
System tray icon (pystray) |
windows/icon.py |
Runtime icon generation (Pillow, no external file) |
windows/desktop.spec |
PyInstaller build spec |
windows/build.py |
One-command production build (frontend + exe) |
Coding Conventions (from .clinerules)
- No hardcoded strings — all user-facing strings go in
resources/ui_strings.py(backend) orfrontend/src/uiStrings.js/frontend/src/consoleStrings.js(frontend). - All function signatures must have type hints (
Optional[],List[],Dict[],Tuple[]). - Private methods prefixed with
_underscore. Constants inUPPER_SNAKE_CASE. Classes inPascalCase. - Public functions get Google-style docstrings (Args, Returns, Raises). Private functions get a one-liner.
- All agents implement the
__call__(question, file_name)interface. - Internal engine constants (timeouts, retry limits, ports) live in
app/config.py. User-facing settings (LLM provider/keys, MCP servers, agent tuning, observability) live inconfig.json.
Configuration
All user-facing settings live in config.json (platform config dir — Windows: %LOCALAPPDATA%\DeskGenie\config.json). See config.json.example at the repo root for the full schema. Key sections:
llm— active provider, API keys, model names, temperature, timeoutmcpServers— MCP server definitions (same schema as Codexsettings.json)agent— maxSteps, maxRetries, search result limitsobservability.langfuse— Langfuse tracing keyslogging.level— Python log level (DEBUG/INFO/WARNING/ERROR)folder_aliases— short names resolved in natural language commandspreferences— default output dir, image quality, PDF DPI
Multi-Model Architecture
DeskGenie deliberately routes different workloads to different models:
- Agent reasoning / orchestration — controlled by
llm.activeProviderinconfig.json. Supportsgoogle,anthropic,ollama,huggingface. - Vision workloads (image analysis, video understanding, YouTube Q&A) — always Google Gemini (
genai.Clientintools/custom_tools.py), regardless of active provider.
The two layers are independent: switching the primary LLM has no effect on vision tool behaviour.
LLM Configuration
Set via config.json → llm. Google provider has three model slots: agentModel (main loop), visionModel (image/video tools), advisorModel (hard-problem escalation). Temperature defaults to 0 (deterministic). LLM call timeout: 300s. Retry logic: 3 retries, 2s initial delay, 2× backoff (handles 504 DEADLINE_EXCEEDED).
CLI Tool Usage — Always Verify Before Suggesting
Never suggest CLI commands for third-party tools (fastmcp, uvx, npx, etc.) from memory. CLI APIs change between versions and remembered syntax is frequently wrong or outdated.
Before suggesting any CLI command for an installed tool:
- Run
<tool> --helpor<tool> <subcommand> --helpfirst - Read the actual output to confirm flags and syntax
- Only then suggest the command
This applies to: fastmcp, uvx, npx, pyinstaller, langchain-cli, and any other tool where the installed version may differ from training data.