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) {