/find-breaking-changes-in-vercel-ai

little ai script / experiment to find breaking changes for the upcoming ai@5

Primary LanguageJavaScript

fair warning: most of this repository, including this README, is AI generated. It works great, though!

Breaking Changes Analyzer for Vercel AI

This script analyzes pull requests in the Vercel AI repository to identify breaking changes using AI-powered analysis.

Features

  • Fetches all pull requests after PR #6283 that target the v5 branch
  • Downloads and analyzes the diff for each pull request
  • Uses the ai SDK and Anthropic to determine if breaking changes occurred
  • Generates detailed markdown reports with:
    • Breaking change descriptions
    • Before/after code examples
    • Migration guides
    • Impact analysis

Setup

  1. Install dependencies:

    npm install
  2. Set up environment variables: Create a .env file in the project root with the following variables:

    # GitHub Personal Access Token
    # Create at: https://github.com/settings/tokens
    # Permissions needed: public_repo (to read public repositories)
    GITHUB_TOKEN=ghp_your_github_token_here
    
    # ANTHROPIC_API_KEY API Key
    # Get from: https://console.anthropic.com/
    ANTHROPIC_API_KEY=sk-your_anthropic_api_key_here
    

Usage

Run the analysis script:

node find-breaking-changes.js

The script will:

  1. Fetch all qualifying pull requests from the Vercel AI repository
  2. Analyze each PR's diff for breaking changes
  3. Generate markdown files in the ./breaking-changes/ directory

Output Format

Generated files follow the naming convention:

<pr-number>-<changeset-filename>-YYYY-MM-DD.md

Each file contains:

  • Pull request metadata (title, author, link)
  • Summary of changes
  • Detailed breaking change analysis
  • Before/after code examples
  • Migration instructions
  • References to original changeset files

Configuration

You can modify the following constants in find-breaking-changes.js:

  • BASE_PR_NUMBER: Starting PR number (default: 6283)
  • TARGET_BRANCH: Target branch to analyze (default: 'v5')
  • REPO_OWNER: Repository owner (default: 'vercel')
  • REPO_NAME: Repository name (default: 'ai')

Rate Limiting

The script includes a 1-second delay between API calls to respect GitHub's rate limits. For large numbers of PRs, the analysis may take some time to complete.

Error Handling

The script includes robust error handling:

  • Continues processing other PRs if one fails
  • Logs detailed error messages
  • Provides summary statistics at completion

Requirements

  • Node.js 16+ (for ES modules support)
  • GitHub Personal Access Token with public repository access
  • Anthropic API key with sufficient credits