mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
fix(mcp): reject an empty compatibility
The Agent Skills format requires a compatibility value, when present, to hold 1 to 500 characters, so an empty one is skipped like an overlong one.
This commit is contained in:
@@ -75,8 +75,8 @@ func Load(dir string) (*Package, error) {
|
||||
// metadata is left unchecked: the format wants string values, but lists there are
|
||||
// common and tool clients read them fine, so skipping those skills would cost more.
|
||||
compat, ok := fm["compatibility"].(string)
|
||||
if _, set := fm["compatibility"]; set && !ok {
|
||||
return nil, fmt.Errorf("compatibility must be text")
|
||||
if _, set := fm["compatibility"]; set && (!ok || compat == "") {
|
||||
return nil, fmt.Errorf("compatibility must be non-empty text")
|
||||
}
|
||||
if n := utf8.RuneCountInString(compat); n > MaxCompatibility {
|
||||
return nil, fmt.Errorf("compatibility has %d characters; the limit is %d", n, MaxCompatibility)
|
||||
|
||||
@@ -174,12 +174,13 @@ func TestBuild_SkipsSkillWhoseDescriptionOrCompatibilityIsTooLong(t *testing.T)
|
||||
writeFile(t, filepath.Join(src, "long/SKILL.md"), skill("long", strings.Repeat("a", 1025)))
|
||||
writeFile(t, filepath.Join(src, "wide/SKILL.md"), skill("wide", strings.Repeat("技", 1024)))
|
||||
writeFile(t, filepath.Join(src, "compat/SKILL.md"), "---\nname: compat\ndescription: Use when testing\ncompatibility: "+strings.Repeat("a", 501)+"\n---\n")
|
||||
writeFile(t, filepath.Join(src, "blank/SKILL.md"), "---\nname: blank\ndescription: Use when testing\ncompatibility: \"\"\n---\n")
|
||||
|
||||
c, err := (&Builder{Source: src}).Build()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(c.Skills) != 1 || c.Skills[0].URI != "skill://wide/SKILL.md" || !hasWarning(c, "skipped long") || !hasWarning(c, "skipped compat") {
|
||||
if len(c.Skills) != 1 || c.Skills[0].URI != "skill://wide/SKILL.md" || !hasWarning(c, "skipped long") || !hasWarning(c, "skipped compat") || !hasWarning(c, "skipped blank") {
|
||||
t.Errorf("skills=%v warnings=%v, want long and compat skipped, wide served", c.Skills, c.Skipped)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user