mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
feat: Implement framework for AI Coding Assistant
This commit lays the groundwork for my AI Coding Assistant feature, focusing on Code Completion, Code Suggestions/Refactoring, and Bug Fixing. It includes the necessary Codemirror integrations, a backend service structure, and initial UI/UX elements. Key changes: 1. **Core AI Assistant Service:** * Defined types for communication between the editor and my AI service. * Created a service with a placeholder function capable of routing tasks (complete, suggest_refactor, fix_bug). Currently, it returns mock data. * Established a Remix action to expose this service via an HTTP POST endpoint. 2. **Codemirror Integration:** * **AI Code Completion:** * Implemented a custom Codemirror `CompletionSource`. * This source fetches suggestions from my API endpoint (task: 'complete') and maps them to Codemirror `Completion` objects. * Integrated this `CompletionSource` into the `autocompletion` configuration. * **AI Code Suggestions/Refactoring & Bug Fixing (Manual Triggers):** * Created functions to call my AI service with tasks 'suggest_refactor' and 'fix_bug' respectively. * These functions transform my responses into Codemirror `Diagnostic` objects with actionable fixes/suggestions. * Developed CodeMirror commands that invoke the respective fetch functions and use `setDiagnostics` (from `@codemirror/lint`) to display results. * Integrated these commands with keybindings: * `Mod-Alt-r` for Refactoring/Suggestions. * `Mod-Alt-f` for Bug Fixing. * Added and configured `@codemirror/lint` extensions to enable the display and interaction with these AI-generated diagnostics. 3. **UI/UX Enhancements:** * Improved language detection within AI features by using Codemirror's `languageFacet` instead of placeholder logic. * Added "loading" diagnostics that temporarily display in the editor when refactoring or bug-fixing tasks are initiated, providing immediate feedback to you. 4. **Documentation:** * Updated the README with a new "AI Coding Assistant (Experimental)" section, detailing the features, their keybindings, and how to interact with them via the lint panel. This work establishes the client-side and server-side framework. The next major step is to implement the actual LLM calls and prompt engineering within my service for each of my capabilities.
This commit is contained in:
parent
755e86559c
commit
0e89524789