-
Notifications
You must be signed in to change notification settings - Fork 790
Bundling #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Bundling #382
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
eb92e08
Fetch Copilot CLI at build time
SteveSandersonMS 35fd9d2
Update tests to use bundled CLI
SteveSandersonMS 69eca40
Always get from NPM
SteveSandersonMS 82729d4
CR feedback
SteveSandersonMS de46143
Node: use bundled CLI
SteveSandersonMS 059c53b
Bundling for Python
SteveSandersonMS 025403f
Formatting
SteveSandersonMS 8b473e8
Update test_client.py
SteveSandersonMS fd6f983
Python test fix
SteveSandersonMS 9ce97da
Consistent node version for CI
SteveSandersonMS 4df7711
Make publish.yml safer - don't actually deploy to package managers if…
SteveSandersonMS b5c5323
Fix license file
SteveSandersonMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,56 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| <Version>0.1.0</Version> | ||
| <Description>SDK for programmatic control of GitHub Copilot CLI</Description> | ||
| <Authors>GitHub</Authors> | ||
| <Company>GitHub</Company> | ||
| <Copyright>Copyright (c) Microsoft Corporation. All rights reserved.</Copyright> | ||
| <PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
| <PackageReadmeFile>README.md</PackageReadmeFile> | ||
| <RepositoryUrl>https://github.com/github/copilot-sdk</RepositoryUrl> | ||
| <PackageTags>github;copilot;sdk;jsonrpc;agent</PackageTags> | ||
| <IsAotCompatible>true</IsAotCompatible> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Include="../README.md" Pack="true" PackagePath="/" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="10.2.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.2" /> | ||
| <PackageReference Include="StreamJsonRpc" Version="2.24.84" PrivateAssets="compile" /> | ||
| <PackageReference Include="System.Text.Json" Version="10.0.2" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- Generate version props file at build time (gitignored) --> | ||
| <Target Name="_GenerateVersionProps" BeforeTargets="BeforeBuild"> | ||
| <Exec Command="node -e "console.log(require('./nodejs/package-lock.json').packages['node_modules/@github/copilot'].version)"" WorkingDirectory="$(MSBuildThisFileDirectory)../.." ConsoleToMSBuild="true" StandardOutputImportance="low"> | ||
SteveSandersonMS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <Output TaskParameter="ConsoleOutput" PropertyName="CopilotCliVersion" /> | ||
| </Exec> | ||
| <Error Condition="'$(CopilotCliVersion)' == ''" Text="CopilotCliVersion could not be read from nodejs/package-lock.json" /> | ||
SteveSandersonMS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <PropertyGroup> | ||
| <_VersionPropsContent> | ||
| <![CDATA[<Project> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| <Version>0.1.0</Version> | ||
| <Description>SDK for programmatic control of GitHub Copilot CLI</Description> | ||
| <Authors>GitHub</Authors> | ||
| <Company>GitHub</Company> | ||
| <Copyright>Copyright (c) Microsoft Corporation. All rights reserved.</Copyright> | ||
| <PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
| <PackageReadmeFile>README.md</PackageReadmeFile> | ||
| <RepositoryUrl>https://github.com/github/copilot-sdk</RepositoryUrl> | ||
| <PackageTags>github;copilot;sdk;jsonrpc;agent</PackageTags> | ||
| <IsAotCompatible>true</IsAotCompatible> | ||
| <CopilotCliVersion>$(CopilotCliVersion)</CopilotCliVersion> | ||
| </PropertyGroup> | ||
| </Project>]]> | ||
| </_VersionPropsContent> | ||
| </PropertyGroup> | ||
| <WriteLinesToFile File="$(MSBuildThisFileDirectory)build\GitHub.Copilot.SDK.props" Lines="$(_VersionPropsContent)" Overwrite="true" WriteOnlyWhenDifferent="true" /> | ||
| </Target> | ||
|
|
||
| <ItemGroup> | ||
| <None Include="../README.md" Pack="true" PackagePath="/" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="10.2.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.2" /> | ||
| <PackageReference Include="StreamJsonRpc" Version="2.24.84" PrivateAssets="compile" /> | ||
| <PackageReference Include="System.Text.Json" Version="10.0.2" /> | ||
| </ItemGroup> | ||
| <!-- Include .targets and .props files in package --> | ||
| <!-- Also import the .targets for local dev (same logic consumers get) --> | ||
| <ItemGroup> | ||
| <None Include="build\GitHub.Copilot.SDK.*" Pack="true" PackagePath="build\" CopyToOutputDirectory="Never" /> | ||
| </ItemGroup> | ||
| <Import Project="build\GitHub.Copilot.SDK.targets" /> | ||
SteveSandersonMS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <Project> | ||
| <!-- These targets run in consuming projects when they build --> | ||
| <!-- CopilotCliVersion is imported from GitHub.Copilot.SDK.props (generated at SDK build time, packaged alongside) --> | ||
| <Import Project="$(MSBuildThisFileDirectory)GitHub.Copilot.SDK.props" Condition="'$(CopilotCliVersion)' == '' And Exists('$(MSBuildThisFileDirectory)GitHub.Copilot.SDK.props')" /> | ||
|
|
||
| <!-- Resolve RID: use explicit RuntimeIdentifier, or infer from current machine --> | ||
| <PropertyGroup> | ||
| <_CopilotRid Condition="'$(RuntimeIdentifier)' != ''">$(RuntimeIdentifier)</_CopilotRid> | ||
| <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('Windows')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">win-x64</_CopilotRid> | ||
| <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('Windows')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">win-arm64</_CopilotRid> | ||
| <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('Linux')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">linux-x64</_CopilotRid> | ||
| <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('Linux')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">linux-arm64</_CopilotRid> | ||
| <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('OSX')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">osx-x64</_CopilotRid> | ||
| <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('OSX')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">osx-arm64</_CopilotRid> | ||
SteveSandersonMS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </PropertyGroup> | ||
|
|
||
| <!-- Map RID to platform name used in npm packages --> | ||
| <PropertyGroup> | ||
| <_CopilotPlatform Condition="'$(_CopilotRid)' == 'win-x64'">win32-x64</_CopilotPlatform> | ||
| <_CopilotPlatform Condition="'$(_CopilotRid)' == 'win-arm64'">win32-arm64</_CopilotPlatform> | ||
| <_CopilotPlatform Condition="'$(_CopilotRid)' == 'linux-x64'">linux-x64</_CopilotPlatform> | ||
| <_CopilotPlatform Condition="'$(_CopilotRid)' == 'linux-arm64'">linux-arm64</_CopilotPlatform> | ||
| <_CopilotPlatform Condition="'$(_CopilotRid)' == 'osx-x64'">darwin-x64</_CopilotPlatform> | ||
| <_CopilotPlatform Condition="'$(_CopilotRid)' == 'osx-arm64'">darwin-arm64</_CopilotPlatform> | ||
| <_CopilotBinary Condition="$(_CopilotRid.StartsWith('win-'))">copilot.exe</_CopilotBinary> | ||
| <_CopilotBinary Condition="'$(_CopilotBinary)' == ''">copilot</_CopilotBinary> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Download and extract CLI binary --> | ||
| <Target Name="_DownloadCopilotCli" BeforeTargets="BeforeBuild" Condition="'$(_CopilotPlatform)' != ''"> | ||
| <Error Condition="'$(CopilotCliVersion)' == ''" Text="CopilotCliVersion is not set. The GitHub.Copilot.SDK.props file may be missing from the NuGet package." /> | ||
|
|
||
| <!-- Compute paths using version (now available) --> | ||
| <PropertyGroup> | ||
| <_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)</_CopilotCacheDir> | ||
| <_CopilotCliBinaryPath>$(_CopilotCacheDir)\$(_CopilotBinary)</_CopilotCliBinaryPath> | ||
| <_CopilotArchivePath>$(_CopilotCacheDir)\copilot.tgz</_CopilotArchivePath> | ||
| <_CopilotDownloadUrl>https://registry.npmjs.org/@github/copilot-$(_CopilotPlatform)/-/copilot-$(_CopilotPlatform)-$(CopilotCliVersion).tgz</_CopilotDownloadUrl> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Delete archive if binary missing (handles partial/corrupted downloads) --> | ||
| <Delete Files="$(_CopilotArchivePath)" Condition="!Exists('$(_CopilotCliBinaryPath)') And Exists('$(_CopilotArchivePath)')" /> | ||
|
|
||
| <!-- Download if not cached --> | ||
| <MakeDir Directories="$(_CopilotCacheDir)" Condition="!Exists('$(_CopilotCliBinaryPath)')" /> | ||
| <Message Importance="high" Text="Downloading Copilot CLI $(CopilotCliVersion) for $(_CopilotPlatform)..." Condition="!Exists('$(_CopilotCliBinaryPath)')" /> | ||
| <DownloadFile SourceUrl="$(_CopilotDownloadUrl)" DestinationFolder="$(_CopilotCacheDir)" DestinationFileName="copilot.tgz" | ||
| Condition="!Exists('$(_CopilotCliBinaryPath)')" /> | ||
|
|
||
| <!-- Extract using tar (use Windows system tar explicitly to avoid Git bash tar issues) --> | ||
| <PropertyGroup> | ||
| <_TarCommand Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(SystemRoot)\System32\tar.exe</_TarCommand> | ||
| <_TarCommand Condition="'$(_TarCommand)' == ''">tar</_TarCommand> | ||
| </PropertyGroup> | ||
| <Exec Command=""$(_TarCommand)" -xzf "$(_CopilotArchivePath)" --strip-components=1 -C "$(_CopilotCacheDir)"" | ||
| Condition="!Exists('$(_CopilotCliBinaryPath)')" /> | ||
|
|
||
| <Error Condition="!Exists('$(_CopilotCliBinaryPath)')" Text="Failed to extract Copilot CLI binary to $(_CopilotCliBinaryPath)" /> | ||
| </Target> | ||
|
|
||
| <!-- Copy CLI binary to output runtimes folder and register for transitive copy --> | ||
| <Target Name="_CopyCopilotCliToOutput" AfterTargets="Build" DependsOnTargets="_DownloadCopilotCli" Condition="'$(_CopilotPlatform)' != ''"> | ||
| <PropertyGroup> | ||
| <_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)</_CopilotCacheDir> | ||
| <_CopilotCliBinaryPath>$(_CopilotCacheDir)\$(_CopilotBinary)</_CopilotCliBinaryPath> | ||
| <_CopilotOutputDir>$(OutDir)runtimes\$(_CopilotRid)\native</_CopilotOutputDir> | ||
| </PropertyGroup> | ||
| <MakeDir Directories="$(_CopilotOutputDir)" /> | ||
| <Copy SourceFiles="$(_CopilotCliBinaryPath)" DestinationFolder="$(_CopilotOutputDir)" SkipUnchangedFiles="true" /> | ||
| </Target> | ||
|
|
||
| <!-- Register CLI binary as content so it flows through project references --> | ||
| <Target Name="_RegisterCopilotCliForCopy" BeforeTargets="GetCopyToOutputDirectoryItems" DependsOnTargets="_DownloadCopilotCli" Condition="'$(_CopilotPlatform)' != ''"> | ||
| <PropertyGroup> | ||
| <_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)</_CopilotCacheDir> | ||
| <_CopilotCliBinaryPath>$(_CopilotCacheDir)\$(_CopilotBinary)</_CopilotCliBinaryPath> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <ContentWithTargetPath Include="$(_CopilotCliBinaryPath)" | ||
| TargetPath="runtimes\$(_CopilotRid)\native\$(_CopilotBinary)" | ||
| CopyToOutputDirectory="PreserveNewest" /> | ||
| </ItemGroup> | ||
| </Target> | ||
| </Project> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.