/lazygit

This is an VsCode IDE extension, to automate git commands

Primary LanguageTypeScript

Lazygit VS Code Extension Documentation

Overview

Lazygit is a VS Code extension that provides a webview-based chat interface allowing users to convert natural language commands into Git commands using Google Generative AI and execute these commands directly in the VS Code terminal.


image

Resources I Used


Project Structure

  • src/extension.ts: Main entry point for the extension. It handles activation, command registration, and message communication between the webview and the extension.
  • src/webview.ts: Contains the HTML and JavaScript for the webview content, including the React-based chat interface.

Dependencies

  • vscode: Core VS Code API module.
  • @google/generative-ai: Google Generative AI SDK.

Setup Instructions

  1. Install Dependencies

    • Install necessary npm packages including the Google Generative AI SDK.
  2. Activate the Extension

    • Register the lazygit.openChat command.
    • Set up the webview panel to display the chat interface.
  3. Webview Content

    • The webview displays a chat interface where users can input natural language commands.
    • Messages are sent to the extension to be processed and converted into Git commands.

Key Components

  1. Activation and Command Registration

    • Registers the command that opens the chat interface.
    • Creates a webview panel and loads the content from webview.ts.
  2. Webview Content

    • HTML and CSS for a styled chat interface.
    • React component to handle user input and display messages.
    • JavaScript to communicate with the VS Code extension.
  3. Message Handling

    • Handles messages sent from the webview to the extension.
    • Processes user input to convert natural language commands into Git commands using Google Generative AI.
    • Sends the resulting Git commands back to the webview for display and execution.
  4. Executing Git Commands

    • Opens a terminal within VS Code to run the Git commands generated by the AI.

Usage

  1. Open Chat Interface

    • Use the command lazygit.openChat to open the chat interface.
  2. Input Natural Language Commands

    • Type a natural language command into the chat input box and send it.
  3. Receive and Run Git Commands

    • The AI will convert the input into Git commands.
    • The Git commands will be displayed with an option to run them directly in the terminal.

Challenges

First time making extension, felt overpowered 🥹

There is a little problem with inserting fetched commands into terminal, it worked fine on windows but on linux it is making some error 😅, I will solve it asap as documentation from vscode dosent cover it.