DSXpert - AI-Powered Data Structure Optimization
DSXpert is a VS Code extension that uses AI to automatically optimize code by replacing inefficient data structures with more optimal alternatives.
https://youtu.be/y7efJvrcHQQ?feature=shared
Features
- AI-Powered Code Optimization: Automatically detects and replaces inefficient data structures
- Multi-Language Support: Supports Python, Java, C++, JavaScript, TypeScript, C#, Ruby, PHP, Swift, Go, and Rust
- Syntax Validation: Validates code syntax before optimization
- Interactive Results: View original vs optimized code with detailed explanations
- One-Click Application: Accept or reject optimizations with a single click
Installation
Watch Youtube video for demo-
https://youtu.be/y7efJvrcHQQ?feature=shared
- Download the
.vsix file from the releases
- In VS Code, go to Extensions (Ctrl+Shift+X)
- Click the "..." menu and select "Install from VSIX..."
- Select the downloaded file
Usage
Optimize Code
- Open a file with code you want to optimize
- Press
Ctrl+Shift+P to open the command palette
- Type "Optimize Code" and select the command
- The extension will analyze your code and show optimization results
Validate Syntax
- Open a file with code you want to validate
- Press
Ctrl+Shift+P to open the command palette
- Type "Validate Syntax" and select the command
- The extension will check for syntax errors
Project Structure
dsxpert/
├── src/
│ ├── extension.js # Main extension entry point
│ ├── webview.js # Webview content generation
│ ├── services/
│ │ └── aiService.js # AI-related functionality
│ └── utils/
│ └── codeFormatter.js # Code formatting utilities
├── media/
│ ├── styles.css # Webview styles
│ ├── script.js # Webview scripts
│ └── logo.png # Extension logo
├── package.json # Extension manifest
└── README.md # This file
Architecture
Core Modules
- extension.js: Main extension file that registers commands and handles user interactions
- aiService.js: Contains all AI-related functionality including language detection, code optimization, and syntax validation
- webview.js: Generates HTML content for displaying optimization results
- codeFormatter.js: Handles code formatting for different programming languages
Key Features
- Language Detection: Uses AI to automatically detect the programming language of the code
- Code Optimization: Analyzes code and suggests optimal data structure replacements
- Syntax Validation: Validates code syntax before and after optimization
- Interactive UI: Provides a webview interface to compare original and optimized code
Development
Prerequisites
- Node.js (v14 or higher)
- VS Code
Setup
- Clone the repository
- Run
npm install to install dependencies
- Press F5 in VS Code to run the extension in debug mode
Building
npm run lint # Run ESLint
npm run test # Run tests
Configuration
The extension uses Google's Gemini AI API for code analysis and optimization. Make sure you have a valid API key configured.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Leave Feedback!
https://youtu.be/y7efJvrcHQQ?feature=shared
Head straight to the comment section!
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
Version 1.0.7
- Converted from TypeScript to pure JavaScript
- Improved file organization and structure
- Enhanced code documentation
- Removed unused dependencies
- Better error handling and user feedback
| |