File tree Expand file tree Collapse file tree 12 files changed +207
-0
lines changed
Expand file tree Collapse file tree 12 files changed +207
-0
lines changed Original file line number Diff line number Diff line change 1010 <Folder Name =" /test/" >
1111 <Project Path =" test/GitHub.Copilot.SDK.Test.csproj" />
1212 </Folder >
13+ <Folder Name =" /samples/" >
14+ <Project Path =" samples/Chat.csproj" />
15+ </Folder >
1316</Solution >
Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ SDK for programmatic control of GitHub Copilot CLI.
1010dotnet add package GitHub.Copilot.SDK
1111```
1212
13+ ## Run the Sample
14+
15+ Try the interactive chat sample (from the repo root):
16+
17+ ``` bash
18+ cd dotnet/samples
19+ dotnet run
20+ ```
21+
1322## Quick Start
1423
1524``` csharp
Original file line number Diff line number Diff line change 1+ using GitHub . Copilot . SDK ;
2+
3+ await using var client = new CopilotClient ( ) ;
4+ await using var session = await client . CreateSessionAsync ( ) ;
5+
6+ using var _ = session . On ( evt =>
7+ {
8+ if ( evt is AssistantMessageDeltaEvent delta )
9+ Console . Write ( delta . Data ? . DeltaContent ) ;
10+ } ) ;
11+
12+ Console . WriteLine ( "Chat with Copilot (Ctrl+C to exit)\n " ) ;
13+
14+ while ( true )
15+ {
16+ Console . Write ( "You: " ) ;
17+ var input = Console . ReadLine ( ) ? . Trim ( ) ;
18+ if ( string . IsNullOrEmpty ( input ) ) continue ;
19+
20+ Console . Write ( "Assistant: " ) ;
21+ await session . SendAndWaitAsync ( new MessageOptions { Prompt = input } ) ;
22+ Console . WriteLine ( ) ;
23+ }
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+ <PropertyGroup >
3+ <OutputType >Exe</OutputType >
4+ <TargetFramework >net8.0</TargetFramework >
5+ <ImplicitUsings >enable</ImplicitUsings >
6+ <Nullable >enable</Nullable >
7+ </PropertyGroup >
8+ <ItemGroup >
9+ <ProjectReference Include =" ..\src\GitHub.Copilot.SDK.csproj" />
10+ </ItemGroup >
11+ </Project >
Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ A Go SDK for programmatic access to the GitHub Copilot CLI.
1010go get github.com/github/copilot-sdk/go
1111```
1212
13+ ## Run the Sample
14+
15+ Try the interactive chat sample (from the repo root):
16+
17+ ``` bash
18+ cd go/samples
19+ go run chat.go
20+ ```
21+
1322## Quick Start
1423
1524``` go
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "bufio"
5+ "context"
6+ "fmt"
7+ "os"
8+ "strings"
9+
10+ "github.com/github/copilot-sdk/go"
11+ )
12+
13+ func main () {
14+ ctx := context .Background ()
15+ client := copilot .NewClient (nil )
16+ if err := client .Start (ctx ); err != nil {
17+ panic (err )
18+ }
19+ defer client .Stop ()
20+
21+ session , err := client .CreateSession (ctx , nil )
22+ if err != nil {
23+ panic (err )
24+ }
25+ defer session .Destroy ()
26+
27+ session .On (func (event copilot.SessionEvent ) {
28+ if event .Type == copilot .AssistantMessageDelta && event .Data .DeltaContent != nil {
29+ fmt .Print (* event .Data .DeltaContent )
30+ }
31+ })
32+
33+ fmt .Println ("Chat with Copilot (Ctrl+C to exit)\n " )
34+ scanner := bufio .NewScanner (os .Stdin )
35+
36+ for {
37+ fmt .Print ("You: " )
38+ if ! scanner .Scan () {
39+ break
40+ }
41+ input := strings .TrimSpace (scanner .Text ())
42+ if input == "" {
43+ continue
44+ }
45+
46+ fmt .Print ("Assistant: " )
47+ session .SendAndWait (ctx , copilot.MessageOptions {Prompt : input })
48+ fmt .Println ()
49+ }
50+ }
Original file line number Diff line number Diff line change 1+ module github.com/github/copilot-sdk/go/samples
2+
3+ go 1.24
4+
5+ require github.com/github/copilot-sdk/go v0.0.0
6+
7+ require github.com/google/jsonschema-go v0.4.2 // indirect
8+
9+ replace github.com/github/copilot-sdk/go => ../
Original file line number Diff line number Diff line change @@ -10,6 +10,16 @@ TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC.
1010npm install @github/copilot-sdk
1111```
1212
13+ ## Run the Sample
14+
15+ Try the interactive chat sample (from the repo root):
16+
17+ ``` bash
18+ cd nodejs/samples
19+ npm install
20+ npm start
21+ ```
22+
1323## Quick Start
1424
1525``` typescript
Original file line number Diff line number Diff line change 1+ import * as readline from "node:readline" ;
2+ import { CopilotClient , type SessionEvent } from "@github/copilot-sdk" ;
3+
4+ async function main ( ) {
5+ const client = new CopilotClient ( ) ;
6+ const session = await client . createSession ( ) ;
7+
8+ session . on ( ( event : SessionEvent ) => {
9+ if ( event . type === "assistant.message_delta" ) {
10+ process . stdout . write ( event . data ?. delta ?? "" ) ;
11+ }
12+ } ) ;
13+
14+ const rl = readline . createInterface ( { input : process . stdin , output : process . stdout } ) ;
15+ const prompt = ( q : string ) => new Promise < string > ( ( r ) => rl . question ( q , r ) ) ;
16+
17+ console . log ( "Chat with Copilot (Ctrl+C to exit)\n" ) ;
18+
19+ while ( true ) {
20+ const input = await prompt ( "You: " ) ;
21+ if ( ! input . trim ( ) ) continue ;
22+
23+ process . stdout . write ( "Assistant: " ) ;
24+ await session . sendAndWait ( { prompt : input } ) ;
25+ console . log ( ) ;
26+ }
27+ }
28+
29+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " copilot-sdk-sample" ,
3+ "type" : " module" ,
4+ "scripts" : {
5+ "start" : " npx tsx chat.ts"
6+ },
7+ "dependencies" : {
8+ "@github/copilot-sdk" : " file:.."
9+ },
10+ "devDependencies" : {
11+ "tsx" : " ^4.20.6" ,
12+ "@types/node" : " ^22.0.0"
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments