mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-18 14:13:34 +00:00
fix: allow skill_manage companion files
Squash merge PR #104 after validation.
This commit is contained in:
1 parent
484bcc7b71
commit
df8a03df48
10 files changed
+1269
-62
No files matched your search
@@ -3,6 +3,7 @@ package http
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -32,3 +33,37 @@ func TestReadableSkillRootsDoesNotFallbackForCustomSkill(t *testing.T) {
|
||||
t.Fatalf("roots = %#v, want no custom fallback", roots)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSkillVersionReadbackListsAndReadsCompanionReferenceFiles(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmp := t.TempDir()
|
||||
versionDir := filepath.Join(tmp, "managed", "demo", "2")
|
||||
referencePath := filepath.Join(versionDir, "references", "ship-workflow.md")
|
||||
if err := os.MkdirAll(filepath.Dir(referencePath), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(versionDir, "SKILL.md"), []byte("---\nname: Demo\n---\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(referencePath, []byte("# Ship\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
files := walkSkillFiles(versionDir)
|
||||
if !slices.ContainsFunc(files, func(entry fileEntry) bool {
|
||||
return entry.Path == filepath.Join("references", "ship-workflow.md") && !entry.IsDir && entry.Size == int64(len("# Ship\n"))
|
||||
}) {
|
||||
t.Fatalf("files = %#v, want references/ship-workflow.md", files)
|
||||
}
|
||||
|
||||
data, info, err := readSkillFile(referencePath)
|
||||
if err != nil {
|
||||
t.Fatalf("readSkillFile: %v", err)
|
||||
}
|
||||
if string(data) != "# Ship\n" {
|
||||
t.Fatalf("content = %q", data)
|
||||
}
|
||||
if info.Size() != int64(len("# Ship\n")) {
|
||||
t.Fatalf("size = %d", info.Size())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user