Merge pull request #3055 from chengzhichao-xydt/codex/context-getwd-error

fix(agent): handle os.Getwd error in NewContextBuilder
This commit is contained in:
Mauro 2026-06-08 18:48:09 +02:00 committed by GitHub
commit 5b9f9c85a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -102,7 +102,13 @@ func NewContextBuilder(workspace string) *ContextBuilder {
// Use the skills/ directory under the current working directory // Use the skills/ directory under the current working directory
builtinSkillsDir := strings.TrimSpace(os.Getenv(config.EnvBuiltinSkills)) builtinSkillsDir := strings.TrimSpace(os.Getenv(config.EnvBuiltinSkills))
if builtinSkillsDir == "" { 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") builtinSkillsDir = filepath.Join(wd, "skills")
} }
globalSkillsDir := filepath.Join(getGlobalConfigDir(), "skills") globalSkillsDir := filepath.Join(getGlobalConfigDir(), "skills")