From c1195746d17bfa6ffd674a7cb2956bee16c1dfc4 Mon Sep 17 00:00:00 2001 From: pashpashpash Date: Mon, 6 Oct 2025 18:57:40 -0700 Subject: [PATCH] implemented GetHostVersionResponse rpc in the cli (#6663) * implemented GetHostVersionResponse rpc in the cli * undoing machine id * removed unused uuid import --- cli/go.mod | 3 ++- cli/go.sum | 2 ++ cli/pkg/hostbridge/env.go | 37 ++++++++++++++++++++++++++++--------- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/cli/go.mod b/cli/go.mod index 7430f44b..5cd0d780 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -3,10 +3,12 @@ module github.com/cline/cli go 1.23.0 require ( + github.com/atotto/clipboard v0.1.4 github.com/cline/grpc-go v0.0.0 github.com/mattn/go-sqlite3 v1.14.24 github.com/spf13/cobra v1.8.0 google.golang.org/grpc v1.75.0 + google.golang.org/protobuf v1.36.6 ) replace github.com/cline/grpc-go => ../src/generated/grpc-go @@ -18,5 +20,4 @@ require ( golang.org/x/sys v0.33.0 // indirect golang.org/x/text v0.26.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect - google.golang.org/protobuf v1.36.6 // indirect ) diff --git a/cli/go.sum b/cli/go.sum index d723b6b3..4d6131a3 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -1,3 +1,5 @@ +github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= +github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= diff --git a/cli/pkg/hostbridge/env.go b/cli/pkg/hostbridge/env.go index b72945c4..6d7be458 100644 --- a/cli/pkg/hostbridge/env.go +++ b/cli/pkg/hostbridge/env.go @@ -4,8 +4,11 @@ import ( "context" "log" + "github.com/atotto/clipboard" + "github.com/cline/cli/pkg/cli" "github.com/cline/grpc-go/cline" "github.com/cline/grpc-go/host" + "google.golang.org/protobuf/proto" ) // Global shutdown channel - simple approach @@ -31,11 +34,17 @@ func NewEnvService(verbose bool) *EnvService { // ClipboardWriteText writes text to the system clipboard func (s *EnvService) ClipboardWriteText(ctx context.Context, req *cline.StringRequest) (*cline.Empty, error) { if s.verbose { - log.Printf("ClipboardWriteText called with: %s", req.GetValue()) + log.Printf("ClipboardWriteText called with text length: %d", len(req.GetValue())) + } + + err := clipboard.WriteAll(req.GetValue()) + if err != nil { + if s.verbose { + log.Printf("Failed to write to clipboard: %v", err) + } + // Don't fail if clipboard is not available (e.g., headless environment) } - // TODO: Implement actual clipboard functionality - // For now, just return success return &cline.Empty{}, nil } @@ -45,10 +54,17 @@ func (s *EnvService) ClipboardReadText(ctx context.Context, req *cline.EmptyRequ log.Printf("ClipboardReadText called") } - // TODO: Implement actual clipboard functionality - // For now, return empty string + text, err := clipboard.ReadAll() + if err != nil { + if s.verbose { + log.Printf("Failed to read from clipboard: %v", err) + } + // Return empty string if clipboard is not available + text = "" + } + return &cline.String{ - Value: "", + Value: text, }, nil } @@ -71,9 +87,12 @@ func (s *EnvService) GetHostVersion(ctx context.Context, req *cline.EmptyRequest log.Printf("GetHostVersion called") } - // TODO: Implement actual host version functionality - // For now, return empty response - return &host.GetHostVersionResponse{}, nil + return &host.GetHostVersionResponse{ + Platform: proto.String("Cline CLI"), + Version: proto.String(""), + ClineType: proto.String("CLI"), + ClineVersion: proto.String(cli.Version), + }, nil } // Shutdown initiates a graceful shutdown of the host bridge service