154 lines
5.1 KiB
Markdown
154 lines
5.1 KiB
Markdown
# AISE AI Code Editor
|
|
|
|
AI-Supported Lightweight Code Editor built with Streamlit (AISE501 Spring 2026)
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
AISE_AIAgent/
|
|
├── frontend/ # Streamlit UI Components
|
|
│ ├── __init__.py
|
|
│ ├── app.py # Main Streamlit application entry point
|
|
│ ├── sidebar.py # File navigation sidebar component
|
|
│ ├── editor.py # Code editor pane component
|
|
│ └── chat.py # Chat interface component
|
|
│
|
|
├── backend/ # Backend Logic Modules
|
|
│ ├── __init__.py
|
|
│ ├── managers/ # Business logic for UI operations
|
|
│ │ ├── __init__.py
|
|
│ │ ├── file_manager.py # File I/O operations for UI (read, write, list files)
|
|
│ │ ├── chat_manager.py # AI chat management and history
|
|
│ │ ├── system_prompter.py # System prompts and context injection
|
|
│ │ ├── search_manager.py # Internet search functionality
|
|
│ │ ├── execution_engine.py # Code execution and sandboxing
|
|
│ │ └── debug_logger.py # Logging, error handling, debug messages
|
|
│ │
|
|
│ ├── agents/ # AI Agent System
|
|
│ │ ├── __init__.py
|
|
│ │ ├── coding_agent.py # Main agent loop (plan-act-observe cycle)
|
|
│ │ └── tools.py # Tools available to agent (7 functions + dispatcher)
|
|
│ │
|
|
│ └── utils/ # Helper Utilities
|
|
│ ├── __init__.py
|
|
│ └── server_utils.py # LLM client init, chat functions, formatters
|
|
│
|
|
├── tests/ # Unit Tests
|
|
│ ├── __init__.py
|
|
│ ├── test_file_manager.py # Tests for file operations
|
|
│ ├── test_chat_manager.py # Tests for chat functionality
|
|
│ ├── test_execution_engine.py # Tests for code execution
|
|
│ └── test_main.py # Integration tests
|
|
│
|
|
├── workspace/ # Agent Sandbox Directory
|
|
│ └── .gitkeep # Placeholder for agent to work safely in isolation
|
|
│
|
|
├── .gitignore # Git exclusions (venv, .env, __pycache__, etc.)
|
|
├── .env # Local environment variables (NOT committed)
|
|
├── .env.example # Template for environment variables (IS committed)
|
|
├── requirements.txt # Python dependencies
|
|
├── README.md # This file
|
|
└── project_exercise.pdf # Project specification
|
|
```
|
|
|
|
## Component Responsibilities
|
|
|
|
### Frontend (`frontend/`)
|
|
- **app.py**: Main Streamlit application, layout orchestration
|
|
- **sidebar.py**: File browser and project navigation
|
|
- **editor.py**: Code editing interface with syntax highlighting
|
|
- **chat.py**: AI assistant chat interface
|
|
|
|
### Backend Managers (`backend/managers/`)
|
|
Used directly by Frontend for UI operations:
|
|
- **file_manager.py**: CRUD operations on project files
|
|
- **chat_manager.py**: Chat history, message management
|
|
- **system_prompter.py**: System prompt generation and file context
|
|
- **execution_engine.py**: Safe code execution with output capture
|
|
- **debug_logger.py**: Error tracking and log formatting
|
|
- **search_manager.py**: Web search integration
|
|
|
|
### Backend Agents (`backend/agents/`)
|
|
Independent AI agent system for complex tasks:
|
|
- **coding_agent.py**: Agent loop (Plan → Act → Observe → Repeat)
|
|
- **tools.py**: 7 tools agent can use (read/write/run/search/validate/grep/done)
|
|
|
|
### Backend Utils (`backend/utils/`)
|
|
- **server_utils.py**: LLM client initialization, chat helpers, message formatters
|
|
|
|
### Workspace (`workspace/`)
|
|
- Sandbox directory where agent executes and stores files
|
|
- Prevents agent from accessing files outside this directory
|
|
|
|
## Features
|
|
|
|
- **File Display & Management**: Browse and edit code files
|
|
- **Chat Interface**: AI-powered code assistant
|
|
- **Code Execution**: Run Python code with debugging
|
|
- **Internet Search**: Fetch documentation and examples
|
|
- **System Prompts**: Context-aware AI interactions
|
|
|
|
## Setup
|
|
|
|
### 1. Project Clonen
|
|
|
|
1. In den Zielordner wechseln
|
|
cd /pfad/zum/zielordner
|
|
|
|
2. Repository klonen
|
|
git clone https://gitea.fhgr.ch/meulilivio/AISE1_Project.git
|
|
|
|
3. In das Projekt wechseln
|
|
cd AISE1_Project
|
|
|
|
### 2. Activate Virtual Environment
|
|
|
|
```bash
|
|
# Windows
|
|
.\.venv\Scripts\Activate.ps1
|
|
|
|
# macOS/Linux
|
|
source .venv/bin/activate
|
|
```
|
|
|
|
### 3. Install Dependencies
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
### 4. Run Application
|
|
|
|
```bash
|
|
streamlit run frontend/app.py
|
|
```
|
|
|
|
### 5. Run Tests
|
|
|
|
```bash
|
|
pytest tests/
|
|
```
|
|
|
|
## Architecture
|
|
|
|
The application follows a frontend-backend split:
|
|
|
|
- **Frontend**: Streamlit UI components (sidebar, editor, chat)
|
|
- **Backend**: Specialized manager modules
|
|
- FileManager: File operations
|
|
- ChatManager: AI interaction
|
|
- SystemPrompter: Prompt management
|
|
- SearchManager: Internet search
|
|
- ExecutionEngine: Code execution
|
|
- DebugLogger: Error handling & logging
|
|
|
|
## Development
|
|
|
|
Use Git to track changes:
|
|
|
|
```bash
|
|
git add .
|
|
git commit -m "Your message"
|
|
git push origin sturcture
|
|
```
|