@@ -29,12 +29,10 @@ package copilot
2929
3030import (
3131 "bufio"
32- "bytes"
3332 "context"
3433 "encoding/json"
3534 "errors"
3635 "fmt"
37- "io"
3836 "net"
3937 "os"
4038 "os/exec"
@@ -49,11 +47,6 @@ import (
4947 "github.com/github/copilot-sdk/go/rpc"
5048)
5149
52- // readAll reads all data from r until EOF or error, returning the data read.
53- func readAll (r io.Reader ) ([]byte , error ) {
54- return io .ReadAll (r )
55- }
56-
5750// Client manages the connection to the Copilot CLI server and provides session management.
5851//
5952// The Client can either spawn a CLI server process or connect to an existing server.
@@ -92,7 +85,6 @@ type Client struct {
9285 lifecycleHandlers []SessionLifecycleHandler
9386 typedLifecycleHandlers map [SessionLifecycleEventType ][]SessionLifecycleHandler
9487 lifecycleHandlersMux sync.Mutex
95- stderrBuf bytes.Buffer // captures CLI stderr for error messages
9688 processDone chan struct {} // closed when CLI process exits
9789 processError error // set before processDone is closed
9890
@@ -1098,34 +1090,15 @@ func (c *Client) startCLIServer(ctx context.Context) error {
10981090 return fmt .Errorf ("failed to create stdout pipe: %w" , err )
10991091 }
11001092
1101- stderr , err := c .process .StderrPipe ()
1102- if err != nil {
1103- return fmt .Errorf ("failed to create stderr pipe: %w" , err )
1104- }
1105-
11061093 if err := c .process .Start (); err != nil {
11071094 return fmt .Errorf ("failed to start CLI server: %w" , err )
11081095 }
11091096
1110- // Read stderr in background - reads until EOF (process exit) then signals completion
1111- stderrDone := make (chan struct {})
1112- go func () {
1113- // ReadAll reads until EOF, which happens when process terminates
1114- data , _ := readAll (stderr )
1115- c .stderrBuf .Write (data )
1116- close (stderrDone )
1117- }()
1118-
11191097 // Monitor process exit to signal pending requests
11201098 c .processDone = make (chan struct {})
11211099 go func () {
11221100 waitErr := c .process .Wait ()
1123- // Wait for stderr reader to finish before accessing buffer
1124- <- stderrDone
1125- stderrOutput := strings .TrimSpace (c .stderrBuf .String ())
1126- if stderrOutput != "" {
1127- c .processError = fmt .Errorf ("CLI process exited: %v\n stderr: %s" , waitErr , stderrOutput )
1128- } else if waitErr != nil {
1101+ if waitErr != nil {
11291102 c .processError = fmt .Errorf ("CLI process exited: %v" , waitErr )
11301103 } else {
11311104 c .processError = fmt .Errorf ("CLI process exited unexpectedly" )
0 commit comments