- Refactored the initSandboxV2 function to return a structured result, consolidating the runner, computer, configuration, cleanup function, loading message ID, and roles into a single return type. - Updated the Stream method to utilize the new sandboxV2InitResult structure, improving clarity and reducing complexity in handling sandbox initialization. - Introduced role management enhancements, allowing for pre-resolved role connectors to be passed through the request, streamlining connector resolution during execution. - Adjusted various components to support the new roles structure, ensuring consistent handling across the agent's sandbox operations. - Added logging for connector resolution and role management, improving diagnostics and traceability during sandbox execution. - Updated .gitignore to include tools/TOOL-REGISTRATION.md for better project organization.
84 lines
1.8 KiB
Go
84 lines
1.8 KiB
Go
package tools
|
|
|
|
import (
|
|
"io/fs"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestSkillsFS_ContainsThreeSkills(t *testing.T) {
|
|
expected := map[string]bool{
|
|
"skills/yao-web/SKILL.md": false,
|
|
"skills/yao-process/SKILL.md": false,
|
|
"skills/yao-doc/SKILL.md": false,
|
|
}
|
|
|
|
err := fs.WalkDir(SkillsFS, "skills", func(path string, d fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if _, ok := expected[path]; ok {
|
|
expected[path] = true
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("WalkDir failed: %v", err)
|
|
}
|
|
|
|
for path, found := range expected {
|
|
if !found {
|
|
t.Errorf("expected file not found in SkillsFS: %s", path)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSkillsFS_FrontmatterFields(t *testing.T) {
|
|
skills := []struct {
|
|
path string
|
|
name string
|
|
}{
|
|
{"skills/yao-web/SKILL.md", "yao-web"},
|
|
{"skills/yao-process/SKILL.md", "yao-process"},
|
|
{"skills/yao-doc/SKILL.md", "yao-doc"},
|
|
}
|
|
|
|
for _, s := range skills {
|
|
data, err := fs.ReadFile(SkillsFS, s.path)
|
|
if err != nil {
|
|
t.Fatalf("ReadFile(%s): %v", s.path, err)
|
|
}
|
|
content := string(data)
|
|
|
|
if !strings.Contains(content, "name: "+s.name) {
|
|
t.Errorf("%s: missing 'name: %s' in frontmatter", s.path, s.name)
|
|
}
|
|
if !strings.Contains(content, "description:") {
|
|
t.Errorf("%s: missing 'description:' in frontmatter", s.path)
|
|
}
|
|
if !strings.Contains(content, "ALWAYS invoke this skill") {
|
|
t.Errorf("%s: description missing directive 'ALWAYS invoke this skill'", s.path)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSystemPrompt_NonEmpty(t *testing.T) {
|
|
if len(SystemPrompt) == 0 {
|
|
t.Fatal("SystemPrompt is empty")
|
|
}
|
|
|
|
content := string(SystemPrompt)
|
|
|
|
markers := []string{
|
|
"Yao Sandbox Environment",
|
|
"Yao System Tools",
|
|
"tai tool",
|
|
"$WORKDIR",
|
|
"$CTX_SKILLS_DIR",
|
|
}
|
|
for _, m := range markers {
|
|
if !strings.Contains(content, m) {
|
|
t.Errorf("SystemPrompt missing expected marker: %q", m)
|
|
}
|
|
}
|
|
}
|