package agent import ( "os" "path/filepath" "testing" ) func TestInferSkillNamesFromToolCall_ReadFileSkillMarkdown(t *testing.T) { workspace := t.TempDir() skillDir := filepath.Join(workspace, "skills", "three-one") if err := os.MkdirAll(skillDir, 0o755); err != nil { t.Fatalf("MkdirAll: %v", err) } if err := os.WriteFile( filepath.Join(skillDir, "SKILL.md"), []byte("---\nname: three-one\ndescription: test\n---\n# Three One\n"), 0o644, ); err != nil { t.Fatalf("WriteFile: %v", err) } cb := NewContextBuilder(workspace) ts := &turnState{ workspace: workspace, agent: &AgentInstance{ Workspace: workspace, ContextBuilder: cb, }, } got := inferSkillNamesFromToolCall(ts, "read_file", map[string]any{ "path": filepath.Join(workspace, "skills", "three-one", "SKILL.md"), }) if len(got) != 1 || got[0] != "three-one" { t.Fatalf("inferSkillNamesFromToolCall = %v, want [three-one]", got) } } func TestInferSkillNamesFromToolCall_NonSkillFileIgnored(t *testing.T) { workspace := t.TempDir() ts := &turnState{workspace: workspace} got := inferSkillNamesFromToolCall(ts, "read_file", map[string]any{ "path": filepath.Join(workspace, "README.md"), }) if len(got) != 0 { t.Fatalf("inferSkillNamesFromToolCall = %v, want empty", got) } }