summaryrefslogtreecommitdiff
path: root/internal/hexaicli
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-16 03:51:43 +0200
committerPaul Buetow <paul@buetow.org>2026-03-16 03:51:43 +0200
commitde3e878ad12bbd3e609bd5b7d741fc792c72f255 (patch)
tree06d92b93ea0ad532c5d3a761033baac05abe2a5e /internal/hexaicli
parent2e9cabb1c8bf1f0246e513fe1f86a552e07eee94 (diff)
Decompose App God struct into embedded section structs
Replace 60+ flat fields in App with 4 embedded section structs: CoreConfig, ProviderConfig, PromptConfig, FeatureConfig. Go field promotion preserves all existing field access patterns. Updated flattenAppConfig to recurse into embedded structs for runtimeconfig. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/hexaicli')
-rw-r--r--internal/hexaicli/run_more_test.go2
-rw-r--r--internal/hexaicli/run_output_test.go24
-rw-r--r--internal/hexaicli/run_test.go48
3 files changed, 56 insertions, 18 deletions
diff --git a/internal/hexaicli/run_more_test.go b/internal/hexaicli/run_more_test.go
index 469f0c0..125b0ff 100644
--- a/internal/hexaicli/run_more_test.go
+++ b/internal/hexaicli/run_more_test.go
@@ -36,7 +36,7 @@ func TestRunChat_Streaming(t *testing.T) {
}
func TestBuildMessagesFromConfig(t *testing.T) {
- cfg := appconfig.App{PromptCLIDefaultSystem: "DEF", PromptCLIExplainSystem: "EXP"}
+ cfg := appconfig.App{PromptConfig: appconfig.PromptConfig{PromptCLIDefaultSystem: "DEF", PromptCLIExplainSystem: "EXP"}}
msgs := buildMessagesFromConfig(cfg, "tell me")
if msgs[0].Content != "DEF" {
t.Fatalf("default system wrong: %q", msgs[0].Content)
diff --git a/internal/hexaicli/run_output_test.go b/internal/hexaicli/run_output_test.go
index f4e47fe..77a7c6a 100644
--- a/internal/hexaicli/run_output_test.go
+++ b/internal/hexaicli/run_output_test.go
@@ -350,8 +350,20 @@ func TestRunCLIJobs_MultiJob_WritesOutputs(t *testing.T) {
t.Setenv("XDG_CACHE_HOME", t.TempDir())
jobs := []cliJob{
- {index: 0, provider: "a", cfg: appconfig.App{Provider: "a", OllamaBaseURL: "http://x", OllamaModel: "m"}, req: requestArgs{model: "m"}},
- {index: 1, provider: "b", cfg: appconfig.App{Provider: "b", OllamaBaseURL: "http://x", OllamaModel: "m"}, req: requestArgs{model: "m"}},
+ {index: 0, provider: "a", cfg: appconfig.App{
+ CoreConfig: appconfig.CoreConfig{Provider: "a"},
+ ProviderConfig: appconfig.ProviderConfig{
+ OllamaBaseURL: "http://x",
+ OllamaModel: "m",
+ },
+ }, req: requestArgs{model: "m"}},
+ {index: 1, provider: "b", cfg: appconfig.App{
+ CoreConfig: appconfig.CoreConfig{Provider: "b"},
+ ProviderConfig: appconfig.ProviderConfig{
+ OllamaBaseURL: "http://x",
+ OllamaModel: "m",
+ },
+ }, req: requestArgs{model: "m"}},
}
msgs := buildMessages("hello")
var stdout, stderr bytes.Buffer
@@ -378,7 +390,13 @@ func TestRunCLIJobs_MultiJob_WritesOutputs(t *testing.T) {
// Also test the runCLIJobs single-job (streaming) path.
singleJobs := []cliJob{
- {index: 0, provider: "a", cfg: appconfig.App{Provider: "a", OllamaBaseURL: "http://x", OllamaModel: "m"}, req: requestArgs{model: "m"}},
+ {index: 0, provider: "a", cfg: appconfig.App{
+ CoreConfig: appconfig.CoreConfig{Provider: "a"},
+ ProviderConfig: appconfig.ProviderConfig{
+ OllamaBaseURL: "http://x",
+ OllamaModel: "m",
+ },
+ }, req: requestArgs{model: "m"}},
}
stdout.Reset()
stderr.Reset()
diff --git a/internal/hexaicli/run_test.go b/internal/hexaicli/run_test.go
index be7bf6b..9711399 100644
--- a/internal/hexaicli/run_test.go
+++ b/internal/hexaicli/run_test.go
@@ -211,14 +211,20 @@ func TestExecuteCLIJobs_MultiProviderHeaderUsesStderr(t *testing.T) {
{
index: 0,
provider: "openai",
- cfg: appconfig.App{Provider: "openai", OpenAIModel: "gpt-4.1"},
- req: requestArgs{model: "gpt-4.1"},
+ cfg: appconfig.App{
+ CoreConfig: appconfig.CoreConfig{Provider: "openai"},
+ ProviderConfig: appconfig.ProviderConfig{OpenAIModel: "gpt-4.1"},
+ },
+ req: requestArgs{model: "gpt-4.1"},
},
{
index: 1,
provider: "anthropic",
- cfg: appconfig.App{Provider: "anthropic", AnthropicModel: "claude"},
- req: requestArgs{model: "claude"},
+ cfg: appconfig.App{
+ CoreConfig: appconfig.CoreConfig{Provider: "anthropic"},
+ ProviderConfig: appconfig.ProviderConfig{AnthropicModel: "claude"},
+ },
+ req: requestArgs{model: "claude"},
},
}
@@ -240,8 +246,8 @@ func TestExecuteCLIJobs_MultiProviderHeaderUsesStderr(t *testing.T) {
func TestBuildCLIRequest_Override(t *testing.T) {
cfg := appconfig.App{
- Provider: "openai",
- AnthropicModel: "claude-3-5-sonnet",
+ CoreConfig: appconfig.CoreConfig{Provider: "openai"},
+ ProviderConfig: appconfig.ProviderConfig{AnthropicModel: "claude-3-5-sonnet"},
}
entry := appconfig.SurfaceConfig{Provider: "anthropic", Model: "override", Temperature: floatPtr(0.7)}
req := buildCLIRequest(entry, "anthropic", cfg)
@@ -258,7 +264,7 @@ func TestBuildCLIRequest_Override(t *testing.T) {
}
func TestBuildCLIRequest_Gpt5Temp(t *testing.T) {
- cfg := appconfig.App{Provider: "openai", CodingTemperature: floatPtr(0.2)}
+ cfg := appconfig.App{CoreConfig: appconfig.CoreConfig{Provider: "openai", CodingTemperature: floatPtr(0.2)}}
entry := appconfig.SurfaceConfig{}
cfg.OpenAIModel = "gpt-5.1"
req := buildCLIRequest(entry, "openai", cfg)
@@ -276,11 +282,13 @@ func TestBuildCLIRequest_Gpt5Temp(t *testing.T) {
func TestBuildCLIJobs_MultiEntries(t *testing.T) {
cfg := appconfig.App{
- Provider: "ollama",
- OllamaModel: "llama3",
- CLIConfigs: []appconfig.SurfaceConfig{
- {Provider: "openai", Model: "gpt-4o"},
- {Provider: "anthropic", Model: "claude"},
+ CoreConfig: appconfig.CoreConfig{Provider: "ollama"},
+ ProviderConfig: appconfig.ProviderConfig{
+ OllamaModel: "llama3",
+ CLIConfigs: []appconfig.SurfaceConfig{
+ {Provider: "openai", Model: "gpt-4o"},
+ {Provider: "anthropic", Model: "claude"},
+ },
},
}
jobs, err := buildCLIJobs(cfg)
@@ -319,7 +327,13 @@ func TestFilterJobsBySelection(t *testing.T) {
}
func TestNewClientFromConfig_Ollama(t *testing.T) {
- cfg := appconfig.App{Provider: "ollama", OllamaBaseURL: "http://x", OllamaModel: "m"}
+ cfg := appconfig.App{
+ CoreConfig: appconfig.CoreConfig{Provider: "ollama"},
+ ProviderConfig: appconfig.ProviderConfig{
+ OllamaBaseURL: "http://x",
+ OllamaModel: "m",
+ },
+ }
c, err := newClientFromConfig(cfg)
if err != nil || c == nil {
t.Fatalf("expected client: %v %v", c, err)
@@ -327,7 +341,13 @@ func TestNewClientFromConfig_Ollama(t *testing.T) {
}
func TestNewClientFromConfig_OpenAI_MissingKey(t *testing.T) {
- cfg := appconfig.App{Provider: "openai", OpenAIBaseURL: "https://api", OpenAIModel: "gpt"}
+ cfg := appconfig.App{
+ CoreConfig: appconfig.CoreConfig{Provider: "openai"},
+ ProviderConfig: appconfig.ProviderConfig{
+ OpenAIBaseURL: "https://api",
+ OpenAIModel: "gpt",
+ },
+ }
t.Setenv("HEXAI_OPENAI_API_KEY", "")
t.Setenv("OPENAI_API_KEY", "")
if _, err := newClientFromConfig(cfg); err == nil {