GitHub Copilot SDK μƒ˜ν”Œ μ½”λ“œ (with File-based App + Native AOT)

GitHub Copilot SDKκ°€ μ •μ‹μœΌλ‘œ κ³΅κ°œλ˜μ–΄ λΉ λ₯΄κ²Œ λ‘˜λŸ¬λ³Ό 수 μžˆλŠ” μƒ˜ν”Œ μ½”λ“œλ₯Ό μž‘μ„±ν•΄λ΄€μŠ΅λ‹ˆλ‹€. μΆ”ν›„ 정식 λ²„μ „κΉŒμ§€ μ§€μΌœλ΄μ•Ό ν•˜κ² μœΌλ‚˜, 일단 μ‚΄νŽ΄λ³΄κΈ°λ‘œλŠ” AOT 지원도 ν•˜κ³  μžˆλŠ” κ²ƒμœΌλ‘œ λ³΄μ—¬μ„œ λ§Œμ‘±μŠ€λŸ½μŠ΅λ‹ˆλ‹€. :smiley:

GitHub Copilot SDKλŠ” μ‹œμŠ€ν…œμ— μ„€μΉ˜λœ GitHub Copilot CLIλ₯Ό μ°Ύμ•„μ„œ ν™œμš©ν•˜λŠ” λž˜νΌμ΄λ―€λ‘œ OS에 λ¬΄κ΄€ν•˜κ²Œ μ§€μ›λ˜λ©°, 원격 μ„œλ²„ ν˜•νƒœλ‘œλ„ 연결이 κ°€λŠ₯ν•œ κ²ƒμœΌλ‘œ λ³΄μž…λ‹ˆλ‹€.

μ•„λž˜ μ½”λ“œλ₯Ό ghcopilot.cs 둜 μ €μž₯ν•˜μ‹œκ³ , dotnet run ghcopilot.cs λ˜λŠ” chmod +x ghcopilot.cs; ./ghcopilot.cs λͺ…λ Ήμ–΄λ‘œ μ‹€ν–‰ν•˜λ©΄ μ‹€ν–‰ν•΄λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€.

#!/usr/bin/env dotnet
#:package GitHub.Copilot.SDK@0.*
#:property PublishAot=true

using GitHub.Copilot.SDK;
using System.Threading.Tasks;

await using var client = new CopilotClient(new()
{
	// Windows κΈ°μ€€. Linux, macOS의 경우 λ‹€λ₯Έ 경둜 탐색 κΈ°μ€€ ν•„μš”.
	CliPath = Path.Combine(
		Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
		"Microsoft", "WinGet", "Links", "copilot.exe"),
});
await client.StartAsync();

// Create a session (OnPermissionRequest is required)
await using var session = await client.CreateSessionAsync(new SessionConfig
{
	Model = "gpt-5.4",
	OnPermissionRequest = PermissionHandler.ApproveAll,
});

// Wait for response using session.idle event
var done = new TaskCompletionSource();

session.On(e =>
{
	if (e is AssistantMessageEvent msg)
	{
		Console.WriteLine(msg.Data.Content);
	}
	else if (e is SessionIdleEvent)
	{
		done.SetResult();
	}
});

// Send a message and wait for completion
await session.SendAsync(new MessageOptions { Prompt = "What is 2+2?" });
await done.Task;

1 Like