You are an expert Python developer. Recreate the application described below as a fully implemented, production-ready single-file Python script named app.py. This script must be directly executable without stubs, placeholders, or missing logic. Do not generate partial or example code.
The app you are to recreate is already implemented in another file I have, named gemini_app.py. You must match its structure and capabilities as closely as possible, using the same agents, features, and layout — but with small, specific upgrades described below. This is not a skeleton. You are to write the full app.
🔧 Use These APIs Exactly
- Use the
google-genai library — do NOT use google-generativeai
- Use model name
"gemini-2.5-flash" for text
- Use model name
"gemini-2.0-flash-preview-image-generation" for images
🧠 Agents (All Must Be Included)
Recreate and fully implement all the following agents from the original app:
- CoderAgent
- CritiqueAgent
- ArtAgent
- CodeImproverAgent
- ErrorFixerAgent
- ExecutionAgent
- TextReplaceAgent ← This is an enhancement. Add this agent to replace specific code snippets inside files instead of rewriting entire files.
Each agent must:
- Use Gemini 2.5 or image model (where appropriate)
- Be fully asynchronous (
async def) and integrated into the app's workflow
- Include a system prompt defined at the top of the file as a constant (e.g.,
CRITIQUE_AGENT_PROMPT)
- Handle errors robustly and notify the user via messageboxes when necessary
⚙️ Command API (All Fully Implemented)
The app must include and expose all of the following agent-accessible commands:
create_file(path, content)
write_to_file(path, content)
replace_file_snippet(path, old_snippet, new_snippet) # ← NEW, must be fully working
delete_file(path)
rename_file(old_path, new_path)
run_command(command)
generate_image(path, prompt) # saves 3 images
list_directory_contents(target_path=".", recursive=True)
set_user_preference(key, value)
get_user_preference(key)
🖼️ GUI (Tkinter)
Create a fully functional, resizable GUI using Tkinter. It must match the layout of the original app:
- Image viewer must be on the LEFT of the window — never in a tab, never on the right
- Use
Pygments for code syntax highlighting
- Add menus/buttons for generating code, saving, running, improving code, generating images, etc.
- Add a file browser/tree view of the project directory
- Add a status bar for task updates and errors
- Optionally use
watchdog for live file change detection
🧠 Functionality & Behavior
- All tasks should be asynchronous using
asyncio
- Use
configparser to load/save preferences to config.ini
- Store preferences like last open path, UI layout, etc.
- Use
google.genai.Client() properly to send prompts and handle streaming or blocking responses
- Image generation must produce 3 unique variations and save them to disk with unique filenames
🏗️ Structure
Follow this high-level layout:
-
Agent system prompts and constants (TEXT_MODEL_NAME, IMAGE_MODEL_NAME)
-
@dataclass definitions if needed
-
Agent class definitions
-
All helper functions for file I/O, commands, etc.
-
Main GUI class setup
-
asyncio integration with Tkinter (root.after(...))
-
Entrypoint:
if __name__ == "__main__":
asyncio.run(App().run())
✅ Deliverable
Provide the full contents of app.py in one code block, fully working, no stubs or skipped logic. It must exactly recreate the functionality and design of the app from my file, using the updated Gemini 2.5 Pro system, the google-genai library, and include all specified enhancements.
Do not summarize or explain. Output only the complete, executable Python script.
The code should be atleast 2500 lines of code.