From cbb684be010480c92627f92dda8e48f43d5f68e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Sun, 7 Jun 2026 21:05:16 +0800 Subject: [PATCH] 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. --- pkg/evolution/drafts.go | 5 ++++- pkg/evolution/skills_recall.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/evolution/drafts.go b/pkg/evolution/drafts.go index 0d48d6605..6b9e93fd8 100644 --- a/pkg/evolution/drafts.go +++ b/pkg/evolution/drafts.go @@ -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") } diff --git a/pkg/evolution/skills_recall.go b/pkg/evolution/skills_recall.go index fb7d2dfcc..f89a8e132 100644 --- a/pkg/evolution/skills_recall.go +++ b/pkg/evolution/skills_recall.go @@ -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") }