Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ func main() {
}
```

## Distributing your application with an embedded GitHub Copilot CLI

The SDK supports bundling, using Go's `embed` package, the Copilot CLI binary within your application's distribution.
This allows you to bundle a specific CLI version and avoid external dependencies on the user's system.

Follow these steps to embed the CLI:

1. Run `go get -tool github.com/github/copilot-sdk/go/cmd/bundler`. This is a one-time setup step per project.
2. Run `go tool bundler` in your build environment just before building your application.

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.

## API Reference

### Client
Expand Down
4 changes: 4 additions & 0 deletions go/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"sync"
"time"

"github.com/github/copilot-sdk/go/internal/embeddedcli"
"github.com/github/copilot-sdk/go/internal/jsonrpc2"
)

Expand Down Expand Up @@ -182,6 +183,9 @@ func NewClient(options *ClientOptions) *Client {
// Check environment variable for CLI path
if cliPath := os.Getenv("COPILOT_CLI_PATH"); cliPath != "" {
opts.CLIPath = cliPath
} else if embeddedPath := embeddedcli.Path(); embeddedPath != "" && opts.CLIPath == "copilot" {
// Use the unpacked embedded CLI if available and no custom path was set
opts.CLIPath = embeddedPath
Comment thread
qmuntal marked this conversation as resolved.
Outdated
}

client.options = opts
Expand Down
Loading
Loading