fix(agent): handle os.Getwd error in NewContextBuilder without behavior regression

This commit is contained in:
程智超0668000959
2026-06-08 16:52:00 +08:00
parent 12c36572a5
commit 8a246c2282
+7 -1
View File
@@ -102,7 +102,13 @@ func NewContextBuilder(workspace string) *ContextBuilder {
// Use the skills/ directory under the current working directory
builtinSkillsDir := strings.TrimSpace(os.Getenv(config.EnvBuiltinSkills))
if builtinSkillsDir == "" {
wd, _ := os.Getwd()
wd, err := os.Getwd()
if err != nil {
// os.Getwd failure is extremely rare; fall back to empty
// string so that filepath.Join produces a relative "skills"
// path, preserving the original lookup behavior.
wd = ""
}
builtinSkillsDir = filepath.Join(wd, "skills")
}
globalSkillsDir := filepath.Join(getGlobalConfigDir(), "skills")