File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ require (
15
15
github.com/mark3labs/mcp-go v0.31.0
16
16
github.com/spf13/cobra v1.9.1
17
17
github.com/spf13/pflag v1.0.6
18
+ golang.org/x/term v0.31.0
18
19
k8s.io/klog/v2 v2.130.1
19
20
mvdan.cc/sh/v3 v3.11.0
20
21
sigs.k8s.io/yaml v1.4.0
@@ -80,7 +81,6 @@ require (
80
81
golang.org/x/crypto v0.36.0 // indirect
81
82
golang.org/x/net v0.38.0 // indirect
82
83
golang.org/x/sys v0.32.0 // indirect
83
- golang.org/x/term v0.31.0 // indirect
84
84
golang.org/x/text v0.24.0 // indirect
85
85
google.golang.org/genai v1.8.0 // indirect
86
86
google.golang.org/genproto/googleapis/rpc v0.0.0-20250219182151-9fdb1cabc7b2 // indirect
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import (
27
27
"github.com/GoogleCloudPlatform/kubectl-ai/pkg/journal"
28
28
"github.com/charmbracelet/glamour"
29
29
"github.com/chzyer/readline"
30
+ "golang.org/x/term"
30
31
"k8s.io/klog/v2"
31
32
)
32
33
@@ -57,6 +58,18 @@ var _ UI = &TerminalUI{}
57
58
func getCustomTerminalWidth () int {
58
59
// Check for user-configured width via environment variable
59
60
if widthStr := os .Getenv ("KUBECTL_AI_TERM_WIDTH" ); widthStr != "" {
61
+
62
+ if widthStr == "auto" {
63
+ width , _ , err := term .GetSize (int (os .Stdout .Fd ()))
64
+
65
+ if err != nil {
66
+ klog .Warningf ("Failed to get terminal size: %v, using default width" , err )
67
+ return 0
68
+ }
69
+
70
+ return width
71
+ }
72
+
60
73
if width , err := strconv .Atoi (widthStr ); err == nil && width > 0 {
61
74
return width
62
75
}
You can’t perform that action at this time.
0 commit comments