Skip to content

An AI-powered Git assistant that stages files, generates commit messages, and pushes changes directly from VS Code.

License

Notifications You must be signed in to change notification settings

subhamyadav580/vscode-git-copilot

Repository files navigation

Git Copilot

AI copilot for Git workflows in VS Code.

Git Copilot is a VS Code extension that automates common Git operations using an intelligent agent.
It detects the current repository, guides you through staging files, generates commit messages using AI, and pushes changes β€” all with real-time progress updates inside VS Code.


✨ Features

  • πŸ” Automatic Git repository detection
  • πŸ“ Detects current working directory or workspace
  • πŸ—‚ Lists unstaged files
  • βœ… Interactive file staging
    • Select all files
    • Manually select files
    • Cancel safely
  • ✍️ AI-generated commit messages
  • πŸš€ Commit and push workflow
  • πŸ“‘ Live progress streaming inside VS Code
  • πŸ” Safe-by-default Git operations

🧠 How It Works

Git Copilot consists of two layers:

1️⃣ VS Code Extension (TypeScript)

  • Detects repository context
  • Displays progress banners
  • Collects user input (file selection, confirmations)
  • Streams agent updates in real time

2️⃣ Python Agent (LangGraph)

  • Executes Git workflow as a state graph
  • Streams structured status events back to VS Code
  • Uses AI to generate commit messages

πŸš€ Installation & Setup

Prerequisites

  • VS Code β‰₯ 1.108
  • Git installed and available in PATH
  • Python 3.10+
  • Node.js 18+ (for development)
  • OpenAI API Key (for AI-generated commit messages)

Option 1: Install from VSIX (Recommended for Users)

  1. Download the latest .vsix file from releases
  2. Install the extension:
   code --install-extension git-copilot-0.0.1.vsix

Or via VS Code:

  • Open Command Palette (Cmd/Ctrl + Shift + P)
  • Type: Extensions: Install from VSIX...
  • Select the downloaded .vsix file
  1. Reload VS Code

    • Cmd/Ctrl + Shift + P β†’ Developer: Reload Window
  2. Configure OpenAI API Key

    • Run Git Copilot: Run Agent command
    • Enter your OpenAI API key when prompted
    • The key is stored securely in VS Code's secret storage

Option 2: Local Development Setup

1️⃣ Clone the Repository

git clone https://github.com/yourusername/git-copilot.git
cd git-copilot

2️⃣ Install Dependencies

TypeScript/Node.js:

npm install

Python:

cd python
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cd ..

3️⃣ Set Up OpenAI API Key

The extension will prompt you for your API key on first run and store it securely.

Alternatively, for development/testing, create a .env file:

# python/.env
OPENAI_API_KEY=sk-your-openai-api-key-here

You may also set:

ANTHROPIC_API_KEY=...
GROQ_API_KEY=...
GEMINI_API_KEY=...
MISTRAL_API_KEY=...

Note: The .env file is only for local development. When installed as an extension, the API key is stored in VS Code's secure storage.

4️⃣ Compile TypeScript

npm run compile

Or watch mode for development:

npm run watch

5️⃣ Run the Extension

Press F5 in VS Code to:

  • Compile the code
  • Launch Extension Development Host
  • Test the extension in a new VS Code window

πŸ”§ Building & Packaging

Package the Extension

npm install -g @vscode/vsce
vsce package

This creates git-copilot-0.0.1.vsix that you can:

  • Install locally: code --install-extension git-copilot-0.0.1.vsix
  • Share with others
  • Publish to VS Code Marketplace

Publishing to Marketplace

vsce publish

▢️ Usage

  1. Open any Git repository in VS Code
  2. Open Command Palette
    • macOS: Cmd + Shift + P
    • Windows/Linux: Ctrl + Shift + P
  3. Run: Git Copilot: Run Agent
  4. Follow the prompts:
    • Select files to stage
    • Review AI-generated commit message
    • Confirm push to remote

πŸ“ Project Structure

git-copilot/
β”œβ”€β”€ src/
β”‚   └── extension.ts          # VS Code extension entry point
β”œβ”€β”€ python/
β”‚   β”œβ”€β”€ main.py               # Python agent entry point
β”‚   β”œβ”€β”€ requirements.txt      # Python dependencies
β”‚   β”œβ”€β”€ venv/                 # Python virtual environment (created on setup)
β”‚   └── core/
β”‚       β”œβ”€β”€ agent_schemas.py  # Data schemas
β”‚       β”œβ”€β”€ git_utils.py      # Git operations
β”‚       β”œβ”€β”€ pagent.py         # Agent orchestration
β”‚       └── review_agent.py   # Commit message generation
β”œβ”€β”€ out/                      # Compiled TypeScript output
β”œβ”€β”€ package.json              # Extension manifest
β”œβ”€β”€ tsconfig.json             # TypeScript configuration
└── .vscodeignore             # Files excluded from packaging

πŸ” Security

  • API Keys: Stored securely using VS Code's Secret Storage API
  • Git Operations: Read-only by default; writes only with explicit user confirmation
  • Network: Only communicates with OpenAI API for commit message generation

πŸ› Troubleshooting

Extension Not Working

  1. Check Output Panel:

    • View β†’ Output
    • Select Extension Host from dropdown
    • Look for [git-copilot] logs
  2. Verify Python Setup:

   cd python
   source venv/bin/activate
   python --version  # Should be 3.10+
   pip list          # Check installed packages
  1. Verify Git Repository:
   git status  # Should show repository status

Python Process Fails

  • Ensure Python virtual environment exists: python/venv/
  • Reinstall dependencies:
  cd python
  source venv/bin/activate
  pip install -r requirements.txt --force-reinstall

API Key Issues

  • Delete and re-enter your API key:
    • Run command again and enter key when prompted
    • Or clear VS Code secrets and restart

πŸ“ Development

Running Tests

npm test

Linting

npm run lint

Watch Mode

npm run watch

Debug Extension

  1. Open project in VS Code
  2. Press F5 to launch Extension Development Host
  3. Set breakpoints in src/extension.ts
  4. Run Git Copilot: Run Agent in the debug window

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

πŸ“„ License

MIT License - see LICENSE.txt for details


πŸ™ Acknowledgments


πŸ“§ Support

Found a bug or have a feature request?
Open an issue

About

An AI-powered Git assistant that stages files, generates commit messages, and pushes changes directly from VS Code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published