From 2ac9b3841e949b15c24d125a25b537b28435b23a Mon Sep 17 00:00:00 2001 From: nullswan Date: Sat, 5 Oct 2024 23:22:02 +0200 Subject: [PATCH] fix(internal): ensure prompt filenames have .yml suffix --- internal/prompt/loader.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/prompt/loader.go b/internal/prompt/loader.go index d1a77a0..256c2f7 100644 --- a/internal/prompt/loader.go +++ b/internal/prompt/loader.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "github.com/nullswan/golem/internal/config" "gopkg.in/yaml.v2" @@ -13,7 +14,11 @@ import ( var ErrPromptNotFound = errors.New("prompt not found") func LoadPrompt(filename string) (*Prompt, error) { - fp := filepath.Join(config.GetPromptDirectory(), filename+".yml") + if !strings.HasSuffix(filename, ".yml") { + filename += ".yml" + } + + fp := filepath.Join(config.GetPromptDirectory(), filename) if _, err := os.Stat(fp); os.IsNotExist(err) { return nil, ErrPromptNotFound }