Code Agent
A comprehensive Visual Studio Code extension that serves as your AI-powered development assistant, streamlining your workflow with intelligent test generation, automated Git operations, and seamless Azure DevOps integration.
Features
🧪 AI-Powered Test Generation
- Smart Test Generation: Generate comprehensive unit tests for selected code or entire files using GitHub Copilot
- Context-Aware: Automatically attaches workspace context for better test quality
- Multiple Interfaces: Use via command palette, chat participant, or direct commands
🤖 Chat Participant Integration
- @code-agent: Interactive chat participant for conversational workflow
- Natural Language Commands: Use keywords like "test", "push", or "pr" to trigger actions
- Contextual Responses: Get helpful guidance and execute commands through chat
🚀 Automated Git Workflow
- Smart Commit & Push: Automatically stage changes, generate commit messages, and push to remote
- Branch Management: Auto-create feature branches when working on main/master
- Comprehensive Staging: Handles modified, deleted, and untracked files intelligently
📝 Azure DevOps Integration
- AI-Generated PRs: Create pull requests with AI-generated titles and descriptions
- Smart Authentication: Seamless Azure DevOps authentication with fallback options
- Duplicate Prevention: Checks for existing PRs and validates branch differences
- Multi-Format Support: Works with both dev.azure.com and visualstudio.com URLs
Troubleshooting
If you encounter issues, please refer to our Troubleshooting Guide for common problems and solutions.
Requirements
- Visual Studio Code 1.100.0 or higher
- GitHub Copilot extension must be installed and authenticated
- Git extension (built-in with VS Code)
- For Azure DevOps features: Azure CLI or interactive browser authentication
Usage
🧪 Generate Unit Tests
Method 1: Command Palette
- Select the code you want to write tests for (optional)
- Open the command palette (
Ctrl+Shift+P
/ Cmd+Shift+P
)
- Run "Generate Unit Test"
- Tests will be generated using GitHub Copilot with workspace context
Method 2: Chat Participant
- Open GitHub Copilot Chat
- Type
@code-agent test
or @code-agent generate unit tests
- The chat participant will guide you through the process
🚀 Automated Git Operations
Push Changes
- Command: "Commit and Push Changes"
- Chat:
@code-agent push
or @code-agent commit
- Automatically stages all changes, generates commit messages, and pushes to remote
- Creates feature branches automatically when working on main/master
📝 Create Pull Requests
Azure DevOps Integration
- Command: "Create Pull Request"
- Chat:
@code-agent pr
or @code-agent pull request
- Generates AI-powered PR titles and descriptions
- Creates draft PRs with appropriate labeling
- Validates branches and checks for existing PRs
💬 Chat Participant Commands
The @code-agent
chat participant understands natural language:
Command Type |
Example Phrases |
Test Generation |
"test", "unit test", "generate tests" |
Git Operations |
"push", "commit", "push changes" |
Pull Requests |
"pr", "pull request", "create pr" |
Help |
Any other input provides usage guidance |
Extension Settings
This extension doesn't add any VS Code settings yet, but it integrates with:
- GitHub Copilot settings and authentication
- Git configuration and credentials
- Azure CLI authentication (for Azure DevOps features)
Available Commands
Command |
Description |
Generate Unit Test |
Generate tests for selected code or active file |
Commit and Push Changes |
Stage, commit, and push all changes automatically |
Create Pull Request |
Create Azure DevOps PR with AI-generated content |
Known Issues
- Requires GitHub Copilot to be installed and properly configured
- Azure DevOps PR creation requires appropriate repository permissions and network access
- Git operations require a valid Git repository with remote configuration
- AI-generated content quality depends on GitHub Copilot model availability and workspace context
- Large repositories may experience slower performance during context analysis
Troubleshooting
Authentication Issues
- GitHub Copilot: Ensure you're signed in to GitHub Copilot in VS Code
- Azure DevOps: Run
az login
in terminal or allow interactive browser authentication
- Git: Verify Git is configured with your credentials (
git config --global user.name
and git config --global user.email
)
Git Operation Failures
- Verify you have write permissions to the repository
- Ensure Git remote is properly configured (
git remote -v
)
- Check that you're not working directly on protected branches (main/master)
- Confirm your working directory is clean or has the changes you want to commit
Git Add Fails with Ignored Files Error
If you encounter an error like:
Failed to push changes: Failed to execute git {
"exitCode": 1,
"gitCommand": "add",
"stderr": "The following paths are ignored by one of your .gitignore files..."
}
This occurs when the extension attempts to stage files that are ignored by .gitignore
. The extension has been updated to automatically detect and skip ignored files. If you still encounter this issue:
- Ensure you're using the latest version of the extension
- Check your
.gitignore
file configuration
- Use
git check-ignore <file_path>
to verify which files are being ignored
- The extension will now skip ignored files automatically during staging
PR Creation Issues
- Confirm the repository is hosted on Azure DevOps (dev.azure.com or visualstudio.com)
- Verify you have permission to create pull requests in the target repository
- Ensure your branch has commits that differ from the target branch
- Check that no existing PR exists for the same source/target branch combination
Creating PR from Master/Main Branch
When you attempt to create a pull request while on the default branch (master/main):
- With uncommitted changes: The extension will prompt you to run "Commit and Push Changes" first, which will automatically create a new feature branch
- Without uncommitted changes: You'll receive guidance to create a feature branch and make changes before creating a PR
- This prevents accidentally creating PRs from protected branches and ensures a proper Git workflow
Remote URL Validation
- The extension automatically detects problematic remote URLs with username prefixes (e.g.,
https://user@dev.azure.com/org/project/_git/repo
) during both push and pull request operations
- When detected, you'll be prompted to update to the recommended format (
https://user.visualstudio.com/project/_git/repo
)
- Choose "Copy Command" to copy the git command to your clipboard:
git remote set-url origin <new-url>
- After updating your remote URL in the terminal, retry the operation
Test Generation Issues
- Ensure GitHub Copilot is active and has sufficient context
- Try selecting specific code before running the command
- Verify the file you're working with is in a supported programming language
- Check that the workspace has relevant project files for better context
Release Notes
See the CHANGELOG for details on each release.
Latest Updates (v0.1.5)
- 📚 Enhanced documentation with comprehensive feature overview
- 🔧 Improved troubleshooting guide and usage examples
- ✨ Refined user interface and chat participant interactions
- 🛠️ Minor bug fixes and stability improvements
Previous Updates (v0.1.4)
- ✨ AI-powered PR title and description generation
- 🔧 Enhanced error handling and validation
- 🔐 Improved Azure DevOps authentication
- 🛡️ Duplicate PR prevention and branch validation
Contributing
This extension is part of an internal development workflow. For issues or feature requests, please contact the development team.
License
This extension is licensed under the MIT License.
Made with ❤️ using GitHub Copilot and VS Code Extension API