mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
fix(mcp): keep a nested skill's file entries when its parent disagrees
A parent lists its nested skills' files under the same URIs and was loaded after them, so a file changed between the two reads had the nested skill's entry overwritten by the parent's newer digest, and reads of it no longer matched what the nested skill advertised. The parent is now skipped for that build and served after the next refresh.
This commit is contained in:
@@ -104,6 +104,14 @@ func (b *Builder) Build() (*Catalog, error) {
|
||||
if j := slices.IndexFunc(unserved, func(o string) bool { return strings.HasPrefix(o, s.RelPath+"/") }); reason == "" && j >= 0 {
|
||||
reason = fmt.Sprintf("contains %s, which is not served", unserved[j])
|
||||
}
|
||||
// A parent lists its nested skills' files under the same URIs. If one changed
|
||||
// between the two reads, the entries disagree; serve the parent next refresh
|
||||
// rather than overwrite what the nested skill advertises.
|
||||
for uri, f := range files {
|
||||
if old, ok := c.byFile[uri]; reason == "" && ok && old.digest != f.digest {
|
||||
reason = "a nested skill changed while it was read; it is served after the next refresh"
|
||||
}
|
||||
}
|
||||
if reason != "" {
|
||||
c.Skipped = append(c.Skipped, Skip{Path: s.RelPath, Reason: reason})
|
||||
unserved = append(unserved, s.RelPath)
|
||||
|
||||
@@ -122,6 +122,22 @@ func TestBuild_SkipsParentOfExcludedNestedSkill(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A parent and its nested skill list the same files under the same URIs; an
|
||||
// unchanged tree serves both.
|
||||
func TestBuild_ServesParentAndNestedSkillTogether(t *testing.T) {
|
||||
src := t.TempDir()
|
||||
writeFile(t, filepath.Join(src, "suite/SKILL.md"), skillMD("suite"))
|
||||
writeFile(t, filepath.Join(src, "suite/child/SKILL.md"), skillMD("child"))
|
||||
|
||||
c, err := (&Builder{Source: src}).Build()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(c.Skills) != 2 {
|
||||
t.Errorf("skills=%v warnings=%v, want suite and suite/child served", c.Skills, c.Skipped)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuild_SkipsParentOfInvalidNestedSkill(t *testing.T) {
|
||||
src := t.TempDir()
|
||||
writeFile(t, filepath.Join(src, "suite/SKILL.md"), skillMD("suite"))
|
||||
|
||||
Reference in New Issue
Block a user