Skip to content

ROKUMATE/extension-zero

Repository files navigation

Issue Agent - AI-Assisted GitHub Issue CodeFixer

A VS Code extension that integrates GitHub issues with an AI-assisted code-fixer workflow. Automatically generate, preview, and apply code patches to fix GitHub issues with LLM assistance.

✨ New: Auto-Detection!

No manual configuration needed! The extension now automatically detects your repository from Git. Just open any GitHub repo in VS Code and start working with issues immediately.

Learn more about Auto-Detection →

Features

  • 🎯 Auto-Detect Repository: Automatically detects GitHub repo from your git remote
  • 🐛 GitHub Issues Integration: View and manage open issues directly in VS Code sidebar
  • 🤖 AI-Powered Code Fixes: Send issue context to an LLM and receive automated code patches
  • 👀 Patch Preview: Review generated patches with syntax-highlighted diff view before applying
  • 🔧 Smart Application: Apply patches as unstaged changes for manual review
  • 🌿 Git Workflow: Automatically create branches, commit changes, and open PRs
  • Test Integration: Detect and run tests to verify fixes
  • 🔒 Privacy-First: Requires explicit user consent before sending code to external APIs
  • 💾 Secure Storage: API keys stored in VS Code SecretStorage
  • 📊 Status Bar: Shows current repository, click to change

Requirements

  • VS Code: Version 1.75.0 or higher
  • Node.js: Version 18+ recommended
  • Git: Installed and configured in your workspace
  • GitHub Personal Access Token: For accessing GitHub API
  • LLM API Key: OpenAI API key or compatible LLM service

Installation

From Source

  1. Clone this repository:
git clone <repository-url>
cd vscode-extension
  1. Install dependencies:
npm install
  1. Build the extension:
npm run build
  1. Run in development mode:
code --extensionDevelopmentPath=$PWD

Or press F5 in VS Code to launch Extension Development Host.

From VSIX

npm run package
code --install-extension issue-agent-0.1.0.vsix

Quick Start

🚀 New Simplified Workflow (with Auto-Detection)

  1. Open a GitHub repository:

    git clone https://github.com/microsoft/vscode.git
    cd vscode
    code .
  2. Press F5 to launch the Extension Development Host

  3. Configure your GitHub token (one-time setup):

    • Press Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux)
    • Run: Issue Agent: Configure GitHub Settings
    • Paste your GitHub token
    • Repository auto-detected!
  4. Start working with issues:

    • Click the GitHub icon in the Activity Bar
    • Issues load automatically!
    • Click any issue to open the AI composer

That's it! No manual repo configuration needed.

See detailed auto-detection docs →

📝 Traditional Setup (Manual Configuration)

If you're not in a git repository or want to use a different repo:

1. Configure GitHub Access

  1. Generate a GitHub Personal Access Token:

    • Go to GitHub Settings → Developer Settings → Personal Access Tokens
    • Create a token with repo scope
    • Copy the token
  2. In VS Code, run the command:

    Issue Agent: Configure GitHub Settings
    
  3. Enter your:

    • GitHub token
    • Choose "Enter manually" if not auto-detected
    • Repository owner (e.g., microsoft)
    • Repository name (e.g., vscode)

2. Configure LLM API

  1. Get an API key from your LLM provider (OpenAI, etc.)

  2. Run the command:

    Issue Agent: Configure LLM Settings
    
  3. Enter your:

    • LLM API key
    • API endpoint (default: OpenAI)
    • Model name (default: gpt-4)

3. Use the Extension

  1. View Issues: Open the "Issue Agent" sidebar to see open GitHub issues

  2. Check Status Bar: See current repo in status bar (bottom-left)

  3. Open Issue Composer: Click on any issue to open the composer

  4. Select Files: Choose relevant files to provide as context

  5. Add Context: Provide additional instructions or constraints

  6. Consent: Check the consent box to allow sending code to LLM

  7. Run Agent: Click "Run Agent" to generate a patch

  8. Review & Apply: Preview the patch and apply it to your workspace

  9. Create PR: Optionally create a branch and pull request

Workflow Example

1. Select Issue #123 from sidebar
2. Composer opens showing issue details
3. Select relevant files (auto-suggested based on issue)
4. Add context: "Maintain backward compatibility"
5. Check consent and click "Run Agent"
6. LLM generates a patch
7. Review the diff preview
8. Click "Apply Patch" → Changes appear as unstaged
9. Click "Run Tests" → Verify the fix works
10. Click "Create Branch" → Creates `issue-123-fix` branch
11. Click "Create PR" → Opens draft PR on GitHub

Configuration

Settings

Configure via VS Code settings (Cmd/Ctrl + ,):

{
  "issue-agent.repo.owner": "your-org",
  "issue-agent.repo.name": "your-repo",
  "issue-agent.test.command": "npm test",
  "issue-agent.llm.endpoint": "https://api.openai.com/v1/chat/completions",
  "issue-agent.llm.model": "gpt-4"
}

Secrets

API keys are stored securely in VS Code SecretStorage:

  • github-token: GitHub Personal Access Token
  • llm-api-key: LLM API key

Development

Build

npm run build

Run Tests

# Unit tests
npm test

# Integration tests
npm run test:integration

Watch Mode

npm run watch

Package Extension

npm run package

Testing

The extension includes comprehensive tests:

Unit Tests

  • PromptBuilder: Tests prompt generation with correct format, metadata, and size limits
  • PatchApplier: Tests patch validation and application to files

Run unit tests:

npm test

Integration Tests

Full workflow test including:

  • Git repository initialization
  • File creation and modification
  • Patch application
  • Branch creation and commits
  • Prompt building

Run integration tests:

npm run test:integration

Architecture

src/
├── extension.ts          # Extension activation and configuration
├── issueProvider.ts      # GitHub issues tree view provider
├── agentRunner.ts        # Orchestrates LLM workflow and webview
├── promptBuilder.ts      # Builds structured prompts for LLM
├── patchApplier.ts       # Applies unified diff patches
├── gitUtils.ts           # Git operations wrapper
└── test/
    ├── promptBuilder.test.ts
    ├── patchApplier.test.ts
    ├── integration.test.js
    └── fixtures/
        └── llm_response_example.txt

webview/
└── composer.html         # Issue composer UI

LLM Prompt Format

The extension sends structured prompts to the LLM:

--METADATA-BEGIN--
repo: owner/repo
issue: #123
files: src/file1.ts, src/file2.ts
test-command: npm test
--METADATA-END--

--INPUT-BEGIN--
# Issue #123: Fix bug in greet function
Author: @username

## Description
[Issue body]

## Additional Context from User
[User-provided context]

## Repository Files
### File: src/hello.ts

[File contents]

--INPUT-END--

--INSTRUCTIONS-BEGIN--
1) Analyze the issue and the provided code.
2) Generate a fix as a unified diff patch.
3) Put the patch between --PATCH-BEGIN-- and --PATCH-END-- markers.
...
--INSTRUCTIONS-END--

Expected LLM Response Format

--PATCH-BEGIN--
*** Begin Patch
*** Update File: src/hello.ts
@@
-export function greet() {
-  return "hello";
-}
+export function greet(name: string = "world") {
+  return `hello ${name}`;
+}
*** End Patch
--PATCH-END--

--PR-BODY-BEGIN--
Title: Fix greeting to accept a name

Body:
This change updates greet() to accept an optional name parameter.
Fixes #123
--PR-BODY-END--

Security & Privacy

Privacy Controls

  • Never auto-uploads code - Requires explicit user consent
  • Consent checkbox - Must be checked before each LLM call
  • 🔒 Secure storage - API keys stored in VS Code SecretStorage
  • 👁️ Transparency - Clear warnings before external API calls

Best Practices

  1. Review patches before applying
  2. Run tests after applying patches
  3. Only send necessary files to LLM
  4. Use draft PRs for review before merging
  5. Never commit API keys to version control

Troubleshooting

Issues not loading

  • Verify GitHub token has repo scope
  • Check repository owner/name are correct
  • Ensure you have internet connection

Patch fails to apply

  • The LLM response may not match the expected format
  • Try running the agent again with more specific context
  • Manually review and apply the patch from the preview

Tests fail to run

  • Check that test command is configured correctly
  • Ensure dependencies are installed (npm install)
  • Verify workspace has a package.json with test script

LLM not responding

  • Verify API key is configured correctly
  • Check API endpoint is accessible
  • Review VS Code Developer Console for errors

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with tests
  4. Run npm test and npm run test:integration
  5. Submit a pull request

License

MIT

Credits

Built with:

Changelog

0.1.0 (Initial Release)

  • GitHub issues sidebar view
  • Issue composer with file selection
  • LLM integration for patch generation
  • Patch preview and application
  • Git workflow automation
  • Test runner integration
  • PR creation support

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors