Skip to content

Commit

Permalink
fix(internal): ensure prompt filenames have .yml suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
nullswan committed Oct 5, 2024
1 parent ff309cb commit 2ac9b38
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/prompt/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/nullswan/golem/internal/config"
"gopkg.in/yaml.v2"
Expand All @@ -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
}
Expand Down

0 comments on commit 2ac9b38

Please sign in to comment.