Skip to content

Commit fbd81ea

Browse files
taskbotclaude
andcommitted
Fix lint issues and regenerate CLI docs
- Rename pkg/llm types to drop LLM prefix (revive stutter: LLMConfig → Config, LLMOIDCConfig → OIDCConfig, etc.) - Fix unused cmd parameter in config show RunE (revive) - Use FormatJSON constant instead of raw "json" string (goconst) - Fix gci import ordering in pkg/config/config.go - Regenerate docs/cli/ for the new thv llm command group Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 020220c commit fbd81ea

4 files changed

Lines changed: 76 additions & 75 deletions

File tree

cmd/thv/app/llm.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import (
1818

1919
func newLLMCommand() *cobra.Command {
2020
cmd := &cobra.Command{
21-
Use: "llm",
22-
Short: "Manage LLM gateway authentication",
21+
Use: "llm",
22+
Hidden: true,
23+
Short: "Manage LLM gateway authentication",
2324
Long: `Configure and manage authentication for OIDC-protected LLM gateways.
2425
2526
The llm command bridges AI coding tools to LLM gateways by handling OIDC
@@ -34,7 +35,7 @@ authentication transparently. Two modes are supported:
3435
Run "thv llm setup" to get started.`,
3536
}
3637

37-
cmd.AddCommand(newLLMConfigCommand())
38+
cmd.AddCommand(newConfigCommand())
3839
cmd.AddCommand(newLLMSetupCommand())
3940
cmd.AddCommand(newLLMTeardownCommand())
4041
cmd.AddCommand(newLLMProxyCommand())
@@ -45,21 +46,21 @@ Run "thv llm setup" to get started.`,
4546

4647
// ── config subcommand group ───────────────────────────────────────────────────
4748

48-
func newLLMConfigCommand() *cobra.Command {
49+
func newConfigCommand() *cobra.Command {
4950
cmd := &cobra.Command{
5051
Use: "config",
5152
Short: "Manage LLM gateway configuration",
5253
Long: "The config command provides subcommands to manage LLM gateway connection settings.",
5354
}
5455

55-
cmd.AddCommand(newLLMConfigSetCommand())
56-
cmd.AddCommand(newLLMConfigShowCommand())
57-
cmd.AddCommand(newLLMConfigResetCommand())
56+
cmd.AddCommand(newConfigSetCommand())
57+
cmd.AddCommand(newConfigShowCommand())
58+
cmd.AddCommand(newConfigResetCommand())
5859

5960
return cmd
6061
}
6162

62-
func newLLMConfigSetCommand() *cobra.Command {
63+
func newConfigSetCommand() *cobra.Command {
6364
var (
6465
gatewayURL string
6566
issuer string
@@ -115,18 +116,18 @@ Example:
115116
return cmd
116117
}
117118

118-
func newLLMConfigShowCommand() *cobra.Command {
119+
func newConfigShowCommand() *cobra.Command {
119120
var outputFormat string
120121

121122
cmd := &cobra.Command{
122123
Use: "show",
123124
Short: "Display current LLM gateway configuration",
124125
Args: cobra.NoArgs,
125-
RunE: func(cmd *cobra.Command, _ []string) error {
126+
RunE: func(_ *cobra.Command, _ []string) error {
126127
provider := config.NewDefaultProvider()
127128
llmCfg := provider.GetConfig().LLM
128129

129-
if outputFormat == "json" {
130+
if outputFormat == FormatJSON {
130131
enc, err := json.MarshalIndent(llmCfg, "", " ")
131132
if err != nil {
132133
return fmt.Errorf("failed to encode config as JSON: %w", err)
@@ -164,7 +165,7 @@ func newLLMConfigShowCommand() *cobra.Command {
164165
return cmd
165166
}
166167

167-
func newLLMConfigResetCommand() *cobra.Command {
168+
func newConfigResetCommand() *cobra.Command {
168169
return &cobra.Command{
169170
Use: "reset",
170171
Short: "Clear all LLM gateway configuration and cached tokens",
@@ -179,7 +180,7 @@ tokens from the secrets provider.`,
179180
}
180181

181182
return config.UpdateConfig(func(c *config.Config) error {
182-
c.LLM = llm.LLMConfig{}
183+
c.LLM = llm.Config{}
183184
return nil
184185
})
185186
},

pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Config struct {
4848
BuildAuthFiles map[string]string `yaml:"build_auth_files,omitempty"`
4949
RuntimeConfigs map[string]*templates.RuntimeConfig `yaml:"runtime_configs,omitempty"`
5050
RegistryAuth RegistryAuth `yaml:"registry_auth,omitempty"`
51-
LLM llm.LLMConfig `yaml:"llm,omitempty"`
51+
LLM llm.Config `yaml:"llm,omitempty"`
5252
}
5353

5454
// RegistryAuthTypeOAuth is the auth type for OAuth/OIDC authentication.

pkg/llm/config.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,41 @@ const (
1818
DefaultOIDCScopes = "openid offline_access"
1919
)
2020

21-
// LLMConfig holds all LLM gateway settings persisted under the llm: key in
21+
// Config holds all LLM gateway settings persisted under the llm: key in
2222
// ToolHive's config.yaml.
23-
type LLMConfig struct {
24-
GatewayURL string `yaml:"gateway_url,omitempty"`
25-
OIDC LLMOIDCConfig `yaml:"oidc,omitempty"`
26-
Proxy LLMProxyConfig `yaml:"proxy,omitempty"`
27-
Auth LLMAuthState `yaml:"auth,omitempty"`
28-
ConfiguredTools []LLMToolConfig `yaml:"configured_tools,omitempty"`
23+
type Config struct {
24+
GatewayURL string `yaml:"gateway_url,omitempty"`
25+
OIDC OIDCConfig `yaml:"oidc,omitempty"`
26+
Proxy ProxyConfig `yaml:"proxy,omitempty"`
27+
Auth AuthState `yaml:"auth,omitempty"`
28+
ConfiguredTools []ToolConfig `yaml:"configured_tools,omitempty"`
2929
}
3030

31-
// LLMOIDCConfig holds OIDC provider settings for the LLM gateway.
32-
type LLMOIDCConfig struct {
31+
// OIDCConfig holds OIDC provider settings for the LLM gateway.
32+
type OIDCConfig struct {
3333
Issuer string `yaml:"issuer,omitempty"`
3434
ClientID string `yaml:"client_id,omitempty"`
3535
Scopes []string `yaml:"scopes,omitempty"`
3636
Audience string `yaml:"audience,omitempty"`
3737
CallbackPort int `yaml:"callback_port,omitempty"`
3838
}
3939

40-
// LLMProxyConfig holds configuration for the localhost reverse proxy.
41-
type LLMProxyConfig struct {
40+
// ProxyConfig holds configuration for the localhost reverse proxy.
41+
type ProxyConfig struct {
4242
ListenPort int `yaml:"listen_port,omitempty"`
4343
}
4444

45-
// LLMAuthState records token lifecycle metadata persisted to config (no token
45+
// AuthState records token lifecycle metadata persisted to config (no token
4646
// values — those live in the secrets provider or memory only).
47-
type LLMAuthState struct {
47+
type AuthState struct {
4848
// CachedTokenExpiry is the expiry time of the most recently cached access
4949
// token. Used to surface helpful messages when the token is about to expire.
5050
CachedTokenExpiry time.Time `yaml:"cached_token_expiry,omitempty"`
5151
}
5252

53-
// LLMToolConfig records a tool that setup has configured, so teardown knows
53+
// ToolConfig records a tool that setup has configured, so teardown knows
5454
// exactly what to reverse.
55-
type LLMToolConfig struct {
55+
type ToolConfig struct {
5656
// Tool is the canonical tool identifier (e.g. "claude-code", "cursor").
5757
Tool string `yaml:"tool"`
5858
// Mode is the authentication mode: "direct" or "proxy".
@@ -63,13 +63,13 @@ type LLMToolConfig struct {
6363

6464
// IsConfigured reports whether the minimum required fields are present for the
6565
// LLM gateway to be usable: gateway URL, OIDC issuer, and OIDC client ID.
66-
func (c *LLMConfig) IsConfigured() bool {
66+
func (c *Config) IsConfigured() bool {
6767
return c.GatewayURL != "" && c.OIDC.Issuer != "" && c.OIDC.ClientID != ""
6868
}
6969

7070
// Validate performs full validation of the LLM config, including HTTPS
7171
// enforcement, port range checks, and OIDC field requirements.
72-
func (c *LLMConfig) Validate() error {
72+
func (c *Config) Validate() error {
7373
var errs []error
7474

7575
if c.GatewayURL == "" {
@@ -99,7 +99,7 @@ func (c *LLMConfig) Validate() error {
9999

100100
// EffectiveProxyPort returns the configured proxy listen port, or
101101
// DefaultProxyListenPort if none is set.
102-
func (c *LLMConfig) EffectiveProxyPort() int {
102+
func (c *Config) EffectiveProxyPort() int {
103103
if c.Proxy.ListenPort > 0 {
104104
return c.Proxy.ListenPort
105105
}
@@ -108,7 +108,7 @@ func (c *LLMConfig) EffectiveProxyPort() int {
108108

109109
// EffectiveScopes returns the configured OIDC scopes, or the default scopes
110110
// (openid, offline_access) if none are set.
111-
func (c *LLMOIDCConfig) EffectiveScopes() []string {
111+
func (c *OIDCConfig) EffectiveScopes() []string {
112112
if len(c.Scopes) > 0 {
113113
return c.Scopes
114114
}

0 commit comments

Comments
 (0)