mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
b3a7b7ad64
* feat: add agent self-evolution * fix ci * delete unused doc * fix lint * fix evolution review issues
51 lines
1.3 KiB
Go
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)
|
|
}
|
|
}
|