From f50444594ff82a5eb2204a07beed601d39504381 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 30 Sep 2026 11:37:00 +1000 Subject: [PATCH] fix(config): expand plugin, module and skills dirs like every other operator path applyGeneralDefaults home-expanded secret_engine_dir, work_dir, state_dir and chat.workspace but not plugin_dir, module_dir or skills_dir, while config.example.toml tells operators to write all four as ~/.local/share/archie/. A literal "~" is not a directory: plugin.LoadDir returns an empty set for it, loadModules finds no kind file, and skill discovery falls back to the built-ins, all without an error naming the mistake. Expand the three in the same place as the rest, so a value the example advertises resolves to the directory the operator meant. Test first: TestLoadExpandsConfiguredHomePaths gains the three fields (and pins HOME to a temp dir instead of the runner's real one); it failed on the three new assertions before this change. No validator is added alongside: see the plugin-settings decision record for why these four directories stay free-form. Refs #1143 --- .../infrastructure/configuration/defaults.go | 3 +++ .../infrastructure/configuration/loader_test.go | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/infrastructure/configuration/defaults.go b/internal/infrastructure/configuration/defaults.go index 8a1d78c7e..c30198a36 100644 --- a/internal/infrastructure/configuration/defaults.go +++ b/internal/infrastructure/configuration/defaults.go @@ -223,6 +223,9 @@ func DefaultConfigPath() string { // section. func (l *Loader) applyGeneralDefaults(cfg *config.Config) { cfg.SecretEngineDir = expandHomePath(cfg.SecretEngineDir) + cfg.PluginDir = expandHomePath(cfg.PluginDir) + cfg.ModuleDir = expandHomePath(cfg.ModuleDir) + cfg.SkillsDir = expandHomePath(cfg.SkillsDir) cfg.WorkDir = expandHomePath(cfg.WorkDir) cfg.StateDir = expandHomePath(cfg.StateDir) cfg.Chat.Workspace = expandHomePath(cfg.Chat.Workspace) diff --git a/internal/infrastructure/configuration/loader_test.go b/internal/infrastructure/configuration/loader_test.go index 7ed43a3fe..b4a4bd547 100644 --- a/internal/infrastructure/configuration/loader_test.go +++ b/internal/infrastructure/configuration/loader_test.go @@ -42,16 +42,17 @@ func TestLoadDispatchAckReaction(t *testing.T) { } func TestLoadExpandsConfiguredHomePaths(t *testing.T) { - home, err := os.UserHomeDir() - if err != nil { - t.Fatal(err) - } + home := t.TempDir() + t.Setenv("HOME", home) path := filepath.Join(t.TempDir(), "config.toml") contents := ` bot_user = "widget" work_dir = "~/archie/work" state_dir = "~/archie/state" +plugin_dir = "~/archie/plugins" +module_dir = "~/archie/modules" +skills_dir = "~/archie/skills" [chat] workspace = "~/archie/workspace" @@ -75,6 +76,14 @@ name = "app" "work_dir": {got: cfg.WorkDir, want: filepath.Join(home, "archie", "work")}, "state_dir": {got: cfg.StateDir, want: filepath.Join(home, "archie", "state")}, "chat.workspace": {got: cfg.Chat.Workspace, want: filepath.Join(home, "archie", "workspace")}, + // The operator-facing plugin, module and skills directories take the + // same ~ as every other path in the file: config.example.toml tells + // operators to write them that way, and a value that stays literal is + // a directory that silently does not exist (no plugins load, no + // modules load, no skills beyond the built-ins). + "plugin_dir": {got: cfg.PluginDir, want: filepath.Join(home, "archie", "plugins")}, + "module_dir": {got: cfg.ModuleDir, want: filepath.Join(home, "archie", "modules")}, + "skills_dir": {got: cfg.SkillsDir, want: filepath.Join(home, "archie", "skills")}, } for name, tt := range wants { t.Run(name, func(t *testing.T) {