Skip to content

Commit 3b043c9

Browse files
committed
support bundling and auto installing the GitHub Copilot CLI
1 parent 96c8e8d commit 3b043c9

13 files changed

Lines changed: 1199 additions & 1 deletion

File tree

go/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ func main() {
6969
}
7070
```
7171

72+
## Distributing your application with an embedded GitHub Copilot CLI
73+
74+
The SDK supports bundling, using Go's `embed` package, the Copilot CLI binary within your application's distribution.
75+
This allows you to bundle a specific CLI version and avoid external dependencies on the user's system.
76+
77+
Follow these steps to embed the CLI:
78+
79+
1. Run `go get -tool github.com/github/copilot-sdk/go/cmd/bundler`. This is a one-time setup step per project.
80+
2. Run `go tool bundler` in your build environment just before building your application.
81+
82+
That's it! When your application calls `copilot.NewClient` without a `CLIPath` nor the `COPILOT_CLI_PATH` environment variable, the SDK will automatically install the embedded CLI to a temporary directory and use it for all operations. Subsequent calls to `copilot.NewClient`, even from different processes, will reuse the same installed CLI binary.
83+
7284
## API Reference
7385

7486
### Client

go/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
"sync"
4343
"time"
4444

45+
"github.com/github/copilot-sdk/go/internal/embeddedcli"
4546
"github.com/github/copilot-sdk/go/internal/jsonrpc2"
4647
)
4748

@@ -182,6 +183,9 @@ func NewClient(options *ClientOptions) *Client {
182183
// Check environment variable for CLI path
183184
if cliPath := os.Getenv("COPILOT_CLI_PATH"); cliPath != "" {
184185
opts.CLIPath = cliPath
186+
} else if embeddedPath := embeddedcli.Path(); embeddedPath != "" && opts.CLIPath == "copilot" {
187+
// Use the unpacked embedded CLI if available and no custom path was set
188+
opts.CLIPath = embeddedPath
185189
}
186190

187191
client.options = opts

0 commit comments

Comments
 (0)