Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 17, 2025

Summary

Successfully extended the Add-Debug-Profile.ps1 script to support debugging the OpenAI plugin. The script now automates the entire manual process described in the issue and automatically detects whether it's working with an OpenAI plugin or Azure SDK repository.

Changes Made

Core Functionality

  • Added OpenAI Plugin Support: The script now handles both Azure SDK and OpenAI plugin debugging scenarios
  • Automatic Detection: The script automatically detects if the SDK directory is an OpenAI plugin repository by checking if the path contains "openai-dotnet" - no manual flag needed
  • Build Automation: Added Build-OpenAICodegen function that runs npm ci in the repo root and npm run build in the codegen folder
  • DLL Copying: Enhanced Copy-LocalGeneratorDlls to support copying DLLs to both Azure SDK (node_modules) and OpenAI (codegen/dist/generator) target paths
  • Generator Configuration: Added support for OpenAILibraryGenerator generator name for OpenAI scenarios
  • Debug Flag: All debug profiles now include the --debug flag for proper debugging experience

Usage

For OpenAI Plugin (automatically detected):

.\Add-Debug-Profile.ps1 -SdkDirectory "C:\path\to\openai-dotnet"

For Azure SDK (existing functionality):

.\Add-Debug-Profile.ps1 -SdkDirectory "C:\path\to\azure-sdk-dir"

Manual Process Automated

The script fully automates the 4-step manual process described in the issue:

  1. ✅ Runs npm ci in OpenAI repo root to install dependencies
  2. ✅ Runs npm run build in codegen folder to build the package
  3. ✅ Rebuilds local MTG generator and copies the 3 required DLL files to OpenAI's codegen/dist/generator directory
  4. ✅ Creates a debug profile with --debug flag and OpenAILibraryGenerator

Testing

  • ✅ PowerShell syntax validated
  • ✅ Automatic detection logic tested with multiple path scenarios
  • ✅ Help documentation verified
  • ✅ Code review completed
  • ✅ Backward compatibility confirmed - Azure SDK workflow unchanged

Fixes #8761

Original prompt

This section details on the original issue you should resolve

<issue_title>Update Add-Debug-Profile Script to Allow Debugging OAI</issue_title>
<issue_description>We should extend the Add-Debug-Profile script to also allow debugging the OpenAI plugin.

Here is the manual process today which should be automated to support any machine:

  1. Inside of the OAI repo, install the deps using npm ci and cd into the codegen folder & run npm run build.
  2. Ensure your forked/cloned copy of MTG is built by running npm run build from repo root.
  3. Copy the MTG artifacts into the OAI codegen artifacts directory, dist. Here is the commands I use pertaining to the paths on my machine:
Copy-Item "C:\Development\AzureSdk\typespec\packages\http-client-csharp\dist\generator\Microsoft.TypeSpec.Generator.dll", "C:\Development\AzureSdk\typespec\packages\http-client-csharp\dist\generator\Microsoft.TypeSpec.Generator.ClientModel.dll", "C:\Development\AzureSdk\typespec\packages\http-client-csharp\dist\generator\Microsoft.TypeSpec.Generator.Input.dll" -Destination "C:\Development\AzureSdk\openai-dotnet\codegen\dist\generator"
  1. Run the MTG dll file in debug mode:

dotnet C:\\Users\\jorgerangel\\Development\\AzureSdk\\openai-dotnet\\codegen\\dist\\generator\\Microsoft.TypeSpec.Generator.dll C:\\Users\\jorgerangel\\Development\\AzureSdk\\openai-dotnet -g OpenAILibraryGenerator --debug</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #8761


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI self-assigned this Oct 17, 2025
@Copilot Copilot AI changed the title [WIP] Update Add-Debug-Profile script for OpenAI debugging Update Add-Debug-Profile Script to Allow Debugging OpenAI Plugin Oct 17, 2025
@Copilot Copilot AI requested a review from jorgerangel-msft October 17, 2025 16:29
Copilot finished work on behalf of jorgerangel-msft October 17, 2025 16:29
@jorgerangel-msft
Copy link
Contributor

@copilot run npm format to address the formatting issues

Copy link
Contributor Author

Copilot AI commented Oct 17, 2025

@copilot run npm format to address the formatting issues

Done! Formatting applied with npm format. The changes added proper blank lines in the Markdown list formatting in CONTRIBUTING.md. (Commit: run npm format to fix formatting issues)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of jorgerangel-msft October 17, 2025 17:45
- [Getting Started](#getting-started)
- [Development Workflow](#development-workflow)
- [Testing](#testing)
- [Debugging](#debugging)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot don't update this file. Remove all the changes you made to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! All changes to CONTRIBUTING.md have been removed and the file has been reverted to its original state. (Commit: Revert all changes to CONTRIBUTING.md)

Copilot finished work on behalf of jorgerangel-msft October 17, 2025 19:17
@Copilot Copilot AI requested a review from jorgerangel-msft October 17, 2025 19:17
[string]$SdkDirectory,

[Parameter(Mandatory = $false)]
[switch]$IsOpenAIPlugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot why do we need an entire flag for this? Couldn't we simply improve the logic to check if the sdkdirectory contains the name of the repo "openai-dotnet" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion! I've replaced the -IsOpenAIPlugin flag with automatic detection. The script now checks if the SDK directory path contains "openai-dotnet" to determine the workflow. This simplifies usage - users just need to provide the path:

.\Add-Debug-Profile.ps1 -SdkDirectory "C:\path\to\openai-dotnet"

(Commit: Replace IsOpenAIPlugin flag with auto-detection based on path)

@Copilot Copilot AI requested a review from jorgerangel-msft October 17, 2025 20:25
Copilot finished work on behalf of jorgerangel-msft October 17, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Add-Debug-Profile Script to Allow Debugging OAI

2 participants