diff --git a/pkg/agent/context.go b/pkg/agent/context.go index dcf59b02c..17d552e6d 100644 --- a/pkg/agent/context.go +++ b/pkg/agent/context.go @@ -46,8 +46,11 @@ func getGlobalConfigDir() string { func NewContextBuilder(workspace string) *ContextBuilder { // builtin skills: skills directory in current project // Use the skills/ directory under the current working directory - wd, _ := os.Getwd() - builtinSkillsDir := filepath.Join(wd, "skills") + builtinSkillsDir := strings.TrimSpace(os.Getenv("PICOCLAW_BUILTIN_SKILLS")) + if builtinSkillsDir == "" { + wd, _ := os.Getwd() + builtinSkillsDir = filepath.Join(wd, "skills") + } globalSkillsDir := filepath.Join(getGlobalConfigDir(), "skills") return &ContextBuilder{ diff --git a/pkg/agent/context_cache_test.go b/pkg/agent/context_cache_test.go index fc00fbc08..4044f34f5 100644 --- a/pkg/agent/context_cache_test.go +++ b/pkg/agent/context_cache_test.go @@ -439,7 +439,7 @@ description: global-v2 } // TestBuiltinSkillFileContentChange verifies that modifying a builtin skill -// ({cwd}/skills) invalidates the cached system prompt. +// invalidates the cached system prompt. func TestBuiltinSkillFileContentChange(t *testing.T) { tmpHome := t.TempDir() t.Setenv("HOME", tmpHome) @@ -448,18 +448,9 @@ func TestBuiltinSkillFileContentChange(t *testing.T) { defer os.RemoveAll(tmpDir) builtinRoot := t.TempDir() - oldWD, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - if err := os.Chdir(builtinRoot); err != nil { - t.Fatal(err) - } - t.Cleanup(func() { - _ = os.Chdir(oldWD) - }) + t.Setenv("PICOCLAW_BUILTIN_SKILLS", builtinRoot) - builtinSkillPath := filepath.Join(builtinRoot, "skills", "builtin-skill", "SKILL.md") + builtinSkillPath := filepath.Join(builtinRoot, "builtin-skill", "SKILL.md") if err := os.MkdirAll(filepath.Dir(builtinSkillPath), 0o755); err != nil { t.Fatal(err) }