fix: handle os.Getwd error in evolution skills_recall and drafts

When os.Getwd fails, wd is empty and builtinSkillsDir resolves to relative path, causing confusing downstream errors. Fall back to config.GetHome on error.
This commit is contained in:
程智超0668000959
2026-06-07 21:05:16 +08:00
parent 10115f941c
commit cbb684be01
2 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -67,7 +67,10 @@ type DefaultDraftGenerator struct {
func NewDefaultDraftGenerator(workspace string) *DefaultDraftGenerator {
builtinSkillsDir := strings.TrimSpace(os.Getenv(config.EnvBuiltinSkills))
if builtinSkillsDir == "" {
wd, _ := os.Getwd()
wd, err := os.Getwd()
if err != nil {
wd = config.GetHome()
}
builtinSkillsDir = filepath.Join(wd, "skills")
}
+4 -1
View File
@@ -18,7 +18,10 @@ type SkillsRecaller struct {
func NewSkillsRecaller(workspace string) *SkillsRecaller {
builtinSkillsDir := strings.TrimSpace(os.Getenv(config.EnvBuiltinSkills))
if builtinSkillsDir == "" {
wd, _ := os.Getwd()
wd, err := os.Getwd()
if err != nil {
wd = config.GetHome()
}
builtinSkillsDir = filepath.Join(wd, "skills")
}