0.5.0 • Published 4 months ago

@autodev/github-agent-action v0.5.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

AutoDev GitHub Agent Action

šŸ¤– Automated GitHub issue analysis using AI-powered code analysis. This action automatically analyzes GitHub issues when they are created or updated, providing intelligent insights and recommendations.

Features

  • šŸ” Intelligent Issue Analysis: AI-powered analysis of GitHub issues with code context
  • šŸ’¬ Automated Comments: Automatically add analysis results as comments to issues
  • šŸ·ļø Smart Labeling: Automatically apply relevant labels based on analysis
  • 🌐 Webhook Support: Standalone webhook server for real-time issue processing
  • āš™ļø Configurable: Flexible configuration options for different workflows
  • šŸ”— Integration Ready: Built on top of the proven AutoDev GitHub Agent

Quick Start

GitHub Actions Usage

Add this action to your workflow file (e.g., .github/workflows/issue-analysis.yml):

name: Analyze Issues
on:
  issues:
    types: [opened, edited]

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      
      - name: Analyze Issue
        uses: ./packages/github-agent-action
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          analysis-depth: medium
          auto-comment: true
          auto-label: true

Standalone Webhook Server

# Install dependencies
npm install

# Set environment variables
export GITHUB_TOKEN="your-github-token"
export WEBHOOK_SECRET="your-webhook-secret"

# Start the server
npx autodev-github-action server --port 3000

CLI Usage

# Analyze a specific issue
npx autodev-github-action analyze \
  --owner unit-mesh \
  --repo autodev-workbench \
  --issue 81 \
  --depth deep

# Start webhook server
npx autodev-github-action server --port 3000

# Validate configuration
npx autodev-github-action validate

Configuration

Action Inputs

InputDescriptionDefaultRequired
github-tokenGitHub token for API access${{ github.token }}Yes
workspace-pathPath to repository workspace${{ github.workspace }}No
analysis-depthAnalysis depth (shallow/medium/deep)mediumNo
auto-commentAdd analysis comment to issuestrueNo
auto-labelAdd labels based on analysistrueNo
trigger-eventsEvents that trigger analysisopened,edited,reopenedNo
exclude-labelsLabels to exclude from analysis | No
include-labelsLabels to include for analysis | No

Environment Variables

VariableDescriptionDefault
GITHUB_TOKENGitHub personal access tokenRequired
WEBHOOK_SECRETSecret for webhook verificationOptional
WORKSPACE_PATHRepository workspace pathprocess.cwd()
AUTO_COMMENTAuto-add commentstrue
AUTO_LABELAuto-add labelstrue
ANALYSIS_DEPTHAnalysis depthmedium
TRIGGER_EVENTSTrigger eventsopened,edited,reopened
EXCLUDE_LABELSExclude labels
INCLUDE_LABELSInclude labels

Analysis Depths

Shallow

  • Quick analysis focusing on obvious patterns
  • Fast execution (< 30 seconds)
  • Basic code references
  • Suitable for high-volume repositories

Medium (Default)

  • Balanced analysis with meaningful insights
  • Moderate execution time (30-60 seconds)
  • Comprehensive code exploration
  • Good for most use cases

Deep

  • In-depth analysis including dependencies
  • Longer execution time (60-120 seconds)
  • Architectural pattern analysis
  • Best for complex issues

Examples

Basic Issue Analysis

- name: Analyze Issues
  uses: ./packages/github-agent-action
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}

Advanced Configuration

- name: Advanced Issue Analysis
  uses: ./packages/github-agent-action
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    analysis-depth: deep
    auto-comment: true
    auto-label: true
    exclude-labels: 'wontfix,duplicate'
    include-labels: 'bug,enhancement'

Webhook Server Setup

const { startWebhookServer } = require('@autodev/github-agent-action');

const server = await startWebhookServer({
  port: 3000,
  webhookSecret: process.env.WEBHOOK_SECRET,
  githubToken: process.env.GITHUB_TOKEN
});

API Reference

GitHubActionService

Main service class for processing issues.

const service = new GitHubActionService({
  githubToken: 'your-token',
  workspacePath: '/path/to/repo',
  autoComment: true,
  autoLabel: true
});

const result = await service.processIssue({
  owner: 'unit-mesh',
  repo: 'autodev-workbench',
  issueNumber: 81
});

IssueAnalyzer

Core analysis engine.

const analyzer = new IssueAnalyzer(context);
const result = await analyzer.analyzeIssue({
  depth: 'medium',
  includeCodeSearch: true,
  includeSymbolAnalysis: true
});

WebhookHandler

Webhook server for real-time processing.

const handler = new WebhookHandler(actionService, {
  port: 3000,
  secret: 'webhook-secret',
  onIssueOpened: async (payload) => {
    console.log('Issue opened:', payload.issue.number);
  }
});

await handler.start();

Development

Setup

# Clone the repository
git clone https://github.com/unit-mesh/autodev-worker.git
cd autodev-worker/packages/github-agent-action

# Install dependencies
pnpm install

# Build the package
pnpm run build

# Run tests
pnpm test

Project Structure

packages/github-agent-action/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ action.ts           # Main action service
│   ā”œā”€ā”€ issue-analyzer.ts   # Issue analysis logic
│   ā”œā”€ā”€ webhook-handler.ts  # Webhook server
│   ā”œā”€ā”€ types/             # Type definitions
│   └── index.ts           # Main entry point
ā”œā”€ā”€ bin/
│   └── action.js          # CLI entry point
ā”œā”€ā”€ action.yml             # GitHub Action definition
ā”œā”€ā”€ package.json
└── README.md

Contributing

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

License

MIT License - see LICENSE for details.

Related Projects

Support