Files
picoclaw/pkg/agent/pipeline_execute_test.go
T
lxowalle b3a7b7ad64 feat: agent self evolution (#2847)
* feat: add agent self-evolution

* fix ci

* delete unused doc

* fix lint

* fix evolution review issues
2026-05-11 16:13:27 +08:00

51 lines
1.3 KiB
Go

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)
}
}