diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-11 08:49:20 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-11 08:49:20 +0300 |
| commit | a5bd7dd1eb63a2be332ecda50fbeccfe5d5de0a8 (patch) | |
| tree | de9986add3f31b6af8b00c1cf99c5237416d8ed1 /internal/hexaimcp | |
| parent | 133ef49de26ae251c2c86417f9c673ebc7166f76 (diff) | |
appconfig: split FeatureConfig into cohesive per-subsystem structs
The FeatureConfig section was a grab-bag mixing five unrelated non-LLM
subsystems (ignore filtering, stats, tmux popup editor, tmux action menu,
MCP server). Decompose it into named per-subsystem structs
(IgnoreConfig, StatsConfig, TmuxEditConfig, TmuxActionConfig, MCPConfig)
embedded into FeatureConfig so the subsystem boundaries are explicit.
Embedding keeps Go field promotion intact, so existing flat read access
(e.g. cfg.MCPPromptsDir) and the JSON/TOML on-disk shape are unchanged;
only composite literals that set these leaf fields directly were updated
to the nested form.
Add fine-grained, defensive-copy section accessors on App
(IgnoreSection, StatsSection, TmuxEditSection, TmuxActionSection,
MCPSection) so consumers can depend on a single subsystem's config
instead of the whole App God-struct. Decouple slashcommands.NewSyncer
to accept appconfig.MCPConfig rather than appconfig.App.
All tests pass with -race; appconfig coverage 91.5%, total 86.2%.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/hexaimcp')
| -rw-r--r-- | internal/hexaimcp/run.go | 2 | ||||
| -rw-r--r-- | internal/hexaimcp/run_test.go | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/internal/hexaimcp/run.go b/internal/hexaimcp/run.go index 7c487c3..7043ed2 100644 --- a/internal/hexaimcp/run.go +++ b/internal/hexaimcp/run.go @@ -205,7 +205,7 @@ func expandPath(path string) (string, error) { // createSyncer creates a slash command syncer from config. // Returns nil syncer if sync is disabled. func createSyncer(cfg appconfig.App, logger *log.Logger) (*slashcommands.Syncer, error) { - syncer, err := slashcommands.NewSyncer(cfg) + syncer, err := slashcommands.NewSyncer(cfg.MCPSection()) if err != nil { return nil, err } diff --git a/internal/hexaimcp/run_test.go b/internal/hexaimcp/run_test.go index 09f4f87..d567f2e 100644 --- a/internal/hexaimcp/run_test.go +++ b/internal/hexaimcp/run_test.go @@ -113,7 +113,7 @@ func TestGetPromptsDir(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cfg := appconfig.App{ - FeatureConfig: appconfig.FeatureConfig{MCPPromptsDir: tt.cfgValue}, + FeatureConfig: appconfig.FeatureConfig{MCPConfig: appconfig.MCPConfig{MCPPromptsDir: tt.cfgValue}}, } result, err := getPromptsDir(cfg) @@ -425,7 +425,7 @@ func TestGetPromptsDir_XDGDataHome(t *testing.T) { // TestGetPromptsDir_TildeInConfig verifies tilde expansion for config path. func TestGetPromptsDir_TildeInConfig(t *testing.T) { cfg := appconfig.App{ - FeatureConfig: appconfig.FeatureConfig{MCPPromptsDir: "~/my-prompts"}, + FeatureConfig: appconfig.FeatureConfig{MCPConfig: appconfig.MCPConfig{MCPPromptsDir: "~/my-prompts"}}, } result, err := getPromptsDir(cfg) @@ -450,7 +450,7 @@ func TestGetPromptsDir_TildeInConfig(t *testing.T) { func TestCreateSyncer_Disabled(t *testing.T) { logger := log.New(io.Discard, "", 0) cfg := appconfig.App{ - FeatureConfig: appconfig.FeatureConfig{MCPSlashCommandSync: false}, + FeatureConfig: appconfig.FeatureConfig{MCPConfig: appconfig.MCPConfig{MCPSlashCommandSync: false}}, } syncer, err := createSyncer(cfg, logger) @@ -468,10 +468,10 @@ func TestCreateSyncer_Enabled(t *testing.T) { tmpDir := t.TempDir() logger := log.New(io.Discard, "", 0) cfg := appconfig.App{ - FeatureConfig: appconfig.FeatureConfig{ + FeatureConfig: appconfig.FeatureConfig{MCPConfig: appconfig.MCPConfig{ MCPSlashCommandSync: true, MCPSlashCommandDir: tmpDir, - }, + }}, } syncer, err := createSyncer(cfg, logger) @@ -488,10 +488,10 @@ func TestCreateSyncer_Enabled(t *testing.T) { func TestCreateSyncer_Error(t *testing.T) { logger := log.New(io.Discard, "", 0) cfg := appconfig.App{ - FeatureConfig: appconfig.FeatureConfig{ + FeatureConfig: appconfig.FeatureConfig{MCPConfig: appconfig.MCPConfig{ MCPSlashCommandSync: true, MCPSlashCommandDir: "", - }, + }}, } _, err := createSyncer(cfg, logger) @@ -651,11 +651,11 @@ func TestApplyOverrides(t *testing.T) { t.Run("does not overwrite with zero values", func(t *testing.T) { cfg := appconfig.App{ - FeatureConfig: appconfig.FeatureConfig{ + FeatureConfig: appconfig.FeatureConfig{MCPConfig: appconfig.MCPConfig{ MCPPromptsDir: "/existing/prompts", MCPSlashCommandSync: true, MCPSlashCommandDir: "/existing/cmds", - }, + }}, } overrides := MCPOverrides{} // all zero values applyOverrides(&cfg, overrides) |
