Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion agent/agentcontextconfig/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ var skillNamePattern = regexp.MustCompile(

// Default values for agent-internal configuration. These are
// used when the corresponding env vars are unset.
//
// DefaultSkillsDir is a comma-separated list so home-scoped
// skills override project-scoped ones with the same name
// (discoverSkills picks the first occurrence per skill name).
const (
DefaultInstructionsDir = "~/.coder"
DefaultInstructionsFile = "AGENTS.md"
DefaultSkillsDir = ".agents/skills"
DefaultSkillsDir = "~/.coder/skills,.agents/skills"
DefaultSkillMetaFile = "SKILL.md"
DefaultMCPConfigFile = ".mcp.json"
)
Expand Down
31 changes: 31 additions & 0 deletions agent/agentcontextconfig/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,37 @@ func TestResolve(t *testing.T) {
require.Len(t, skillParts, 1)
require.Equal(t, "from skills1", skillParts[0].SkillDescription)
})

//nolint:paralleltest // Uses t.Setenv to mutate HOME.
t.Run("DefaultDiscoversHomeAndProjectSkillsHomeWins", func(t *testing.T) {
fakeHome := t.TempDir()
t.Setenv("HOME", fakeHome)
t.Setenv("USERPROFILE", fakeHome)
workDir := t.TempDir()

homeSkills := filepath.Join(fakeHome, ".coder", "skills")
writeSkillMetaFileInRoot(t, homeSkills, "home-only", "home only")
writeSkillMetaFileInRoot(t, homeSkills, "shared", "from home")
writeSkillMetaFile(t, workDir, "project-only", "project only")
writeSkillMetaFile(t, workDir, "shared", "from project")

// Construct the Config directly with the package defaults
// to verify the default skills list (and only the defaults).
cfg, _ := agentcontextconfig.Resolve(workDir, agentcontextconfig.Config{
SkillsDirs: agentcontextconfig.DefaultSkillsDir,
SkillMetaFile: agentcontextconfig.DefaultSkillMetaFile,
})

got := map[string]string{}
for _, p := range filterParts(cfg.Parts, codersdk.ChatMessagePartTypeSkill) {
got[p.SkillName] = p.SkillDescription
}
require.Equal(t, map[string]string{
"home-only": "home only",
"project-only": "project only",
"shared": "from home",
}, got)
})
}

func TestNewAPI_LazyDirectory(t *testing.T) {
Expand Down
Loading