added yaml file update with copilot fallback#56267
Conversation
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
There was a problem hiding this comment.
Pull request overview
This pull request refactors the Azure.GeneratorAgent tool to use the GitHub API instead of local git commands, introduces a new FileService for YAML file manipulation, and implements a migration workflow that updates tsp-location.yaml files. The changes involve significant architectural improvements including moving from the Azure.GeneratorAgent.Services namespace to the root namespace, renaming SdkValidator to ValidationService with enhanced validation capabilities, and adding comprehensive test coverage for the new services.
Changes:
- Refactored
GitServiceto use GitHub REST API viaHttpClientfor retrieving commit information from remote repositories - Added
FileServiceto read and update YAML configuration files using string-based parsing - Implemented migration workflow that validates SDK structure, reads repository paths from tsp-location.yaml, fetches latest commits, and updates configuration fields
- Enhanced
ValidationServicewith security-focused path validation including checks for path traversal patterns and invalid characters - Updated dependency injection configuration to register
HttpClientwith GitHub API headers and addedMicrosoft.Extensions.Httppackage
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/tools/ci.generator.yml | Formatting change: Added newline at end of file |
| sdk/tools/ci.analyzers.yml | Formatting change: Added newline at end of file |
| sdk/tools/Azure.GeneratorAgent/tests/ValidationServiceTests.cs | Updated tests for renamed ValidationService, removed namespace reference, simplified test structure |
| sdk/tools/Azure.GeneratorAgent/tests/ServiceCollectionTests.cs | Expanded DI tests to cover all new services with lifecycle verification and comprehensive integration checks |
| sdk/tools/Azure.GeneratorAgent/tests/GitServiceTests.cs | Completely rewrote tests to use mocked HttpClient for GitHub API calls instead of local git repository tests |
| sdk/tools/Azure.GeneratorAgent/tests/FileServiceTests.cs | New comprehensive test suite covering YAML reading/writing edge cases, quote handling, and cancellation scenarios |
| sdk/tools/Azure.GeneratorAgent/src/ValidationService.cs | Renamed from SdkValidator, moved to root namespace, added tsp-location.yaml validation and repository path security checks |
| sdk/tools/Azure.GeneratorAgent/src/ServiceConfiguration.cs | Added HttpClient configuration for GitService with GitHub API headers and registered new FileService |
| sdk/tools/Azure.GeneratorAgent/src/SdkValidator.cs | Deleted (renamed to ValidationService) |
| sdk/tools/Azure.GeneratorAgent/src/RootCommandFactory.cs | Implemented complete migrate command workflow with multi-step validation, commit fetching, and YAML updates |
| sdk/tools/Azure.GeneratorAgent/src/GitService.cs | Replaced local git command execution with GitHub REST API calls, added JSON parsing and response validation |
| sdk/tools/Azure.GeneratorAgent/src/FileService.cs | New service for reading and writing YAML fields using string operations with quote handling and error wrapping |
| sdk/tools/Azure.GeneratorAgent/src/Azure.GeneratorAgent.csproj | Added Microsoft.Extensions.Http package reference for HttpClient factory support |
| eng/Packages.Data.props | Added Microsoft.Extensions.Http version 10.0.1 to centralized package management |
Since we already discussed, I am dismissing it :)
This pull request introduces new Copilot-powered automation capabilities to the Azure SDK Generator Agent tool, focusing on integrating Copilot for migration guidance and specification path discovery. It also adds a utility service for YAML configuration file manipulation and updates package dependencies to support these features.
Copilot integration for migration and analysis:
CopilotServiceclass to encapsulate all interactions with the GitHub Copilot SDK, including initializing sessions, sending prompts, and retrieving responses for Azure SDK migration tasks and specification path discovery. This service manages Copilot client lifecycle and error handling.CopilotPromptsstatic class to centralize prompt engineering logic, providing standardized system messages and prompts for migration guidance and Typespec specification path analysis.YAML configuration file utilities:
FileServiceclass that provides methods for reading and updating fields intsp-location.yamlfiles using simple string operations, including robust error handling and logging.