CloudCode: AI-Powered Code Analysis & Refactoring Assistant
CloudCode is an intelligent VS Code extension that acts as your personal AI assistant for code quality, security, and understanding. It analyzes your entire workspace, identifies vulnerabilities, explains complex code, and provides powerful refactoring tools—all powered by Google's Gemini AI.
🌟 Introduction
In modern software development, maintaining a clean, secure, and well-documented codebase is a significant challenge. Technical debt accumulates, security risks go unnoticed, and developer productivity suffers when faced with legacy or unfamiliar code.
CloudCode is a tool designed to tackle these problems head-on. It integrates directly into your VS Code editor, providing deep, AI-driven insights and actions to help you write better, safer code, faster.
(A screenshot showing the beautiful, color-coded security vulnerability tree view would go here.)
✨ Key Features
🛡️ AI-Powered Security Scanner:
Scans your entire local workspace for security vulnerabilities.
Works on projects of any size by intelligently batching code for analysis.
Displays findings in a rich, interactive sidebar view, sorted by severity.
Provides color-coded severity levels (Critical, High, Medium, Low), the vulnerable line of code, a detailed description, a suggested solution, and a link to the official CWE page.
Click-to-Navigate: Instantly jump to the exact line of vulnerable code.
🧠 Interactive Code Explanation:
Features a dedicated "Explain Code" sidebar.
Automatically loads any code you select in the editor.
Provides a detailed, multi-line explanation from the AI about the code's purpose and logic.
🚀 AI-Powered Refactoring (Right-Click Menu):
Modernize Code: Automatically rewrite selected legacy code (e.g., old JavaScript) into its modern equivalent (async/await, let/const).
Generate Documentation: Instantly generate professional docstrings (JSDoc, Python Docstrings, etc.) for any selected function or class.
📊 Comprehensive Project Analysis:
Supports both remote Git repositories and local-only folders.
Generates a detailed report in the sidebar including language breakdown, file counts, commit history, contributor stats, and more.
🏗️ Architecture
CloudCode uses a decoupled frontend/backend architecture to ensure the VS Code editor remains fast and responsive while heavy processing is offloaded to a powerful backend service.
Frontend (VS Code Extension):
Written in TypeScript using the VS Code Extension API.
Provides all UI components (Activity Bar icons, sidebars, commands, context menus).
Handles workspace interaction, file aggregation, and communicates with the backend via a REST API.
Backend (Analysis & AI Service):
A Python server built with the Flask framework.
Contains all the logic for communicating with the Google Gemini API.
Exposes endpoints for security scanning, code explanation, and refactoring.
Uses tools like radon and cloc for the classic project analysis feature.
💻 Technology Stack
Frontend: TypeScript, VS Code API, node-fetch, markdown-it
Backend: Python 3.8+, Flask, Flask-CORS, google-generativeai, python-dotenv, radon
AI Model: Google Gemini 1.5 Pro
Tools: git, cloc
🚀 Getting Started: Setup & Installation
Follow these steps to set up and run the CloudCode project on your local machine.
Prerequisites
Node.js (v16.x or higher)
Python (v3.8 or higher)
Git
cloc (A command-line tool to count lines of code)
- Backend Setup (The AI Service)
First, set up and run the Python backend.
code
Bash
Navigate to the backend directory
cd cloudcode-backend
Create and activate a Python virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install the required Python packages
pip install -r requirements.txt
Create a .env file for your API key
Add this line to the new .env file:
GOOGLE_API_KEY="your_gemini_api_key_here"
Run the Flask server
flask run
The backend is now running on http://127.0.0.1:5000. Keep this terminal open.
2. Frontend Setup (The VS Code Extension)
Now, in a new terminal, set up and launch the VS Code extension.
code
Bash
Navigate to the frontend extension directory
cd cloudcode
Install the npm dependencies
npm install
Open the project in VS Code
code .
Once the project is open in VS Code, press F5 to start a debugging session. This will compile the TypeScript code and open a new [Extension Development Host] window with the CloudCode extension fully installed and running.
🎮 How to Use
Security Scan: Open the Command Palette (Ctrl+Shift+P) and type "CloudCode: Scan for Security Vulnerabilities". The results will stream into the "Security Vulnerabilities" view in the main CloudCode sidebar.
Explain Code: Click the "comment-question" icon in the Activity Bar to open the Explain Code view. Select code in your editor to see it appear automatically, then click the "Explain Code" button.
Refactoring: Select a function or code block in your editor, right-click, and choose "CloudCode: Modernize Selection" or "CloudCode: Generate Documentation".
🛣️ Roadmap
CloudCode is actively being developed. Future features include:
🤖 Automated Unit Test Generation: Right-click a function to generate a complete test file.
⚡ Performance Optimization Suggestions: Analyze code for inefficiencies and suggest improvements.
✅ "Apply Fix" for Security Issues: A one-click button in the security view to automatically apply the AI's suggested fix.
🔧 Advanced Code Quality Reviews: On-demand code reviews for maintainability, readability, and best practices.
🤝 Contributing
Contributions are welcome! If you'd like to help improve CloudCode, please follow these steps:
Fork the repository.
Create a new feature branch (git checkout -b feature/your-awesome-feature).
Make your changes.
Commit your changes (git commit -m 'Add some awesome feature').
Push to the branch (git push origin feature/your-awesome-feature).
Open a Pull Request.
📄 License
This project is licensed under the MIT License.