From 75cf6abd55bfb60324fc47cf91eac08dbb8b87b4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 8 Sep 2025 12:02:40 +0300 Subject: docs: move tmux documentation to its own file --- internal/appconfig/config.go | 84 +++++++++++++++++++-------------------- internal/appconfig/config_test.go | 38 +++++++++--------- 2 files changed, 61 insertions(+), 61 deletions(-) (limited to 'internal/appconfig') diff --git a/internal/appconfig/config.go b/internal/appconfig/config.go index 87b5a29..2c4cee3 100644 --- a/internal/appconfig/config.go +++ b/internal/appconfig/config.go @@ -74,14 +74,14 @@ type App struct { // Code actions PromptCodeActionRewriteSystem string `json:"-" toml:"-"` PromptCodeActionDiagnosticsSystem string `json:"-" toml:"-"` - PromptCodeActionDocumentSystem string `json:"-" toml:"-"` - PromptCodeActionRewriteUser string `json:"-" toml:"-"` - PromptCodeActionDiagnosticsUser string `json:"-" toml:"-"` - PromptCodeActionDocumentUser string `json:"-" toml:"-"` - PromptCodeActionGoTestSystem string `json:"-" toml:"-"` - PromptCodeActionGoTestUser string `json:"-" toml:"-"` - PromptCodeActionSimplifySystem string `json:"-" toml:"-"` - PromptCodeActionSimplifyUser string `json:"-" toml:"-"` + PromptCodeActionDocumentSystem string `json:"-" toml:"-"` + PromptCodeActionRewriteUser string `json:"-" toml:"-"` + PromptCodeActionDiagnosticsUser string `json:"-" toml:"-"` + PromptCodeActionDocumentUser string `json:"-" toml:"-"` + PromptCodeActionGoTestSystem string `json:"-" toml:"-"` + PromptCodeActionGoTestUser string `json:"-" toml:"-"` + PromptCodeActionSimplifySystem string `json:"-" toml:"-"` + PromptCodeActionSimplifyUser string `json:"-" toml:"-"` // CLI PromptCLIDefaultSystem string `json:"-" toml:"-"` PromptCLIExplainSystem string `json:"-" toml:"-"` @@ -129,10 +129,10 @@ func newDefaultConfig() App { PromptCodeActionRewriteUser: "Instruction: {{instruction}}\n\nSelected code to transform:\n{{selection}}", PromptCodeActionDiagnosticsUser: "Diagnostics to resolve (selection only):\n{{diagnostics}}\n\nSelected code:\n{{selection}}", PromptCodeActionDocumentUser: "Add documentation comments to this code:\n{{selection}}", - PromptCodeActionGoTestSystem: "You are a precise Go unit test generator. Given a Go function, write one or more Test* functions using the testing package. Do NOT include package or imports, only the test function(s). Prefer table-driven tests. Keep it minimal and idiomatic.", - PromptCodeActionGoTestUser: "Function under test:\n{{function}}", - PromptCodeActionSimplifySystem: "You are a precise code improvement engine. Simplify and improve the given code while preserving behavior. Return only the improved code with no prose or backticks.", - PromptCodeActionSimplifyUser: "Improve this code:\n{{selection}}", + PromptCodeActionGoTestSystem: "You are a precise Go unit test generator. Given a Go function, write one or more Test* functions using the testing package. Do NOT include package or imports, only the test function(s). Prefer table-driven tests. Keep it minimal and idiomatic.", + PromptCodeActionGoTestUser: "Function under test:\n{{function}}", + PromptCodeActionSimplifySystem: "You are a precise code improvement engine. Simplify and improve the given code while preserving behavior. Return only the improved code with no prose or backticks.", + PromptCodeActionSimplifyUser: "Improve this code:\n{{selection}}", PromptCLIDefaultSystem: "You are Hexai CLI. Default to very short, concise answers. If the user asks for commands, output only the commands (one per line) with no commentary or explanation. Only when the word 'explain' appears in the prompt, produce a verbose explanation.", PromptCLIExplainSystem: "You are Hexai CLI. The user requested an explanation. Provide a clear, verbose explanation with reasoning and details. If commands are needed, include them with brief context.", @@ -260,16 +260,16 @@ type sectionPromptsChat struct { } type sectionPromptsCodeAction struct { - RewriteSystem string `toml:"rewrite_system"` - DiagnosticsSystem string `toml:"diagnostics_system"` - DocumentSystem string `toml:"document_system"` - RewriteUser string `toml:"rewrite_user"` - DiagnosticsUser string `toml:"diagnostics_user"` - DocumentUser string `toml:"document_user"` - GoTestSystem string `toml:"go_test_system"` - GoTestUser string `toml:"go_test_user"` - SimplifySystem string `toml:"simplify_system"` - SimplifyUser string `toml:"simplify_user"` + RewriteSystem string `toml:"rewrite_system"` + DiagnosticsSystem string `toml:"diagnostics_system"` + DocumentSystem string `toml:"document_system"` + RewriteUser string `toml:"rewrite_user"` + DiagnosticsUser string `toml:"diagnostics_user"` + DocumentUser string `toml:"document_user"` + GoTestSystem string `toml:"go_test_system"` + GoTestUser string `toml:"go_test_user"` + SimplifySystem string `toml:"simplify_system"` + SimplifyUser string `toml:"simplify_user"` } type sectionPromptsCLI struct { @@ -393,7 +393,7 @@ func (fc *fileConfig) toApp() App { out.PromptChatSystem = fc.Prompts.Chat.System } // code action - if (fc.Prompts.CodeAction != sectionPromptsCodeAction{}) { + if (fc.Prompts.CodeAction != sectionPromptsCodeAction{}) { if strings.TrimSpace(fc.Prompts.CodeAction.RewriteSystem) != "" { out.PromptCodeActionRewriteSystem = fc.Prompts.CodeAction.RewriteSystem } @@ -415,16 +415,16 @@ func (fc *fileConfig) toApp() App { if strings.TrimSpace(fc.Prompts.CodeAction.GoTestSystem) != "" { out.PromptCodeActionGoTestSystem = fc.Prompts.CodeAction.GoTestSystem } - if strings.TrimSpace(fc.Prompts.CodeAction.GoTestUser) != "" { - out.PromptCodeActionGoTestUser = fc.Prompts.CodeAction.GoTestUser - } - if strings.TrimSpace(fc.Prompts.CodeAction.SimplifySystem) != "" { - out.PromptCodeActionSimplifySystem = fc.Prompts.CodeAction.SimplifySystem - } - if strings.TrimSpace(fc.Prompts.CodeAction.SimplifyUser) != "" { - out.PromptCodeActionSimplifyUser = fc.Prompts.CodeAction.SimplifyUser - } - } + if strings.TrimSpace(fc.Prompts.CodeAction.GoTestUser) != "" { + out.PromptCodeActionGoTestUser = fc.Prompts.CodeAction.GoTestUser + } + if strings.TrimSpace(fc.Prompts.CodeAction.SimplifySystem) != "" { + out.PromptCodeActionSimplifySystem = fc.Prompts.CodeAction.SimplifySystem + } + if strings.TrimSpace(fc.Prompts.CodeAction.SimplifyUser) != "" { + out.PromptCodeActionSimplifyUser = fc.Prompts.CodeAction.SimplifyUser + } + } // cli if (fc.Prompts.CLI != sectionPromptsCLI{}) { if strings.TrimSpace(fc.Prompts.CLI.DefaultSystem) != "" { @@ -623,15 +623,15 @@ func (a *App) mergePrompts(other *App) { if strings.TrimSpace(other.PromptCodeActionGoTestSystem) != "" { a.PromptCodeActionGoTestSystem = other.PromptCodeActionGoTestSystem } - if strings.TrimSpace(other.PromptCodeActionGoTestUser) != "" { - a.PromptCodeActionGoTestUser = other.PromptCodeActionGoTestUser - } - if strings.TrimSpace(other.PromptCodeActionSimplifySystem) != "" { - a.PromptCodeActionSimplifySystem = other.PromptCodeActionSimplifySystem - } - if strings.TrimSpace(other.PromptCodeActionSimplifyUser) != "" { - a.PromptCodeActionSimplifyUser = other.PromptCodeActionSimplifyUser - } + if strings.TrimSpace(other.PromptCodeActionGoTestUser) != "" { + a.PromptCodeActionGoTestUser = other.PromptCodeActionGoTestUser + } + if strings.TrimSpace(other.PromptCodeActionSimplifySystem) != "" { + a.PromptCodeActionSimplifySystem = other.PromptCodeActionSimplifySystem + } + if strings.TrimSpace(other.PromptCodeActionSimplifyUser) != "" { + a.PromptCodeActionSimplifyUser = other.PromptCodeActionSimplifyUser + } // CLI if strings.TrimSpace(other.PromptCLIDefaultSystem) != "" { a.PromptCLIDefaultSystem = other.PromptCLIDefaultSystem diff --git a/internal/appconfig/config_test.go b/internal/appconfig/config_test.go index 5cb79a0..dc8c39c 100644 --- a/internal/appconfig/config_test.go +++ b/internal/appconfig/config_test.go @@ -25,15 +25,15 @@ func writeFile(t *testing.T, path, content string) { // clearHexaiEnv removes any HEXAI_* variables to prevent environment leakage // into tests that expect file-only configuration. func clearHexaiEnv(t *testing.T) { - t.Helper() - for _, e := range os.Environ() { - if strings.HasPrefix(e, "HEXAI_") { - kv := strings.SplitN(e, "=", 2) - if len(kv) > 0 { - t.Setenv(kv[0], "") - } - } - } + t.Helper() + for _, e := range os.Environ() { + if strings.HasPrefix(e, "HEXAI_") { + kv := strings.SplitN(e, "=", 2) + if len(kv) > 0 { + t.Setenv(kv[0], "") + } + } + } } func withEnv(t *testing.T, k, v string) { @@ -54,10 +54,10 @@ func TestLoad_Defaults_NoLogger(t *testing.T) { } func TestLoad_Defaults_WithLogger_NoFile_NoEnv(t *testing.T) { - clearHexaiEnv(t) - t.Setenv("XDG_CONFIG_HOME", t.TempDir()) - logger := newLogger() - cfg := Load(logger) + clearHexaiEnv(t) + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + logger := newLogger() + cfg := Load(logger) def := newDefaultConfig() if cfg.MaxTokens != def.MaxTokens || cfg.ContextMode != def.ContextMode || cfg.ContextWindowLines != def.ContextWindowLines { t.Fatalf("expected defaults; got %+v want %+v", cfg, def) @@ -207,9 +207,9 @@ func TestLoadFromFile_InvalidTOML(t *testing.T) { } func TestLoad_FileTables_Sectioned(t *testing.T) { - clearHexaiEnv(t) - dir := t.TempDir() - t.Setenv("XDG_CONFIG_HOME", dir) + clearHexaiEnv(t) + dir := t.TempDir() + t.Setenv("XDG_CONFIG_HOME", dir) cfgPath := filepath.Join(dir, "hexai", "config.toml") content := ` [general] @@ -290,9 +290,9 @@ temperature = 0.0 } func TestLoad_FileTables_Prompts_AllSections(t *testing.T) { - clearHexaiEnv(t) - dir := t.TempDir() - t.Setenv("XDG_CONFIG_HOME", dir) + clearHexaiEnv(t) + dir := t.TempDir() + t.Setenv("XDG_CONFIG_HOME", dir) cfgPath := filepath.Join(dir, "hexai", "config.toml") content := ` [prompts.completion] -- cgit v1.2.3