mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
* feat(mcp): support Skills directory reads and metadata listing Expose accepted skill directories and SKILL.md metadata so MCP hosts can browse served packages without guessing manifest filenames. Reuse catalog selection and refresh boundaries, including empty directories and stable pagination, and normalize strict frontmatter for YAML 1.2 Core readback. Add regressions and a pinned official conformance runner, and update the runbook and MCP references to describe the browsing contract. Refs #895 * fix(mcp): preserve supporting file MIME types in directory listings Record UTF-8 classification from the same bounded bytes used for package digests so directory metadata agrees with resource reads for extensionless and unknown-extension text. Reuse the existing bounded reader without adding listing-time payload reads or changing package limits. Share pagination with skills/list, trust the SDK's typed request boundary, and repair the pagination regression to detect stale catalog snapshots. Refs #895 * fix(mcp): stream supporting file metadata inspection Buffering supporting files during catalog refresh allocated with asset size. Restore one bounded stream for digest, size and UTF-8 classification, retaining at most three incomplete rune bytes and consuming invalid text through EOF. Preserve the existing same-file checks, package caps and SKILL.md byte reader. Keep real package-load benchmarks and strengthen the existing MIME fixtures for split runes and bytes after invalid sequences. Use one first-match sed command for the conformance URL without a truncated pipeline under pipefail. Scoped packages, focused race tests, vet, shell syntax/shellcheck and all 45 pinned official checks pass. Allocation stays near 48 KB for 64 KiB and 8 MiB assets; multibyte UTF-8 validation still costs CPU versus digest-only loading. * test(mcp): consolidate directory and frontmatter coverage Check every directory continuation URI so a duplicated middle entry cannot hide a missing resource. Keep the existing before/after-cursor refresh cases. Merge nested-skill acceptance fixtures in the catalog owner, preserving all skill-count, skip-warning and directory assertions across configured and targetless cases. Move directory capability coverage to initialization and merge scalar, alias and rejection cases under the existing parser test. Give cached-page benchmark skills names that match their URI directories. Narrow tests, benchmark smoke and vet pass; duplicate-result and stale-catalog mutations both fail, then restored source passes. Production is unchanged.
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package skillpkg
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// Measure real package reloads, including supporting-file inspection, rather
|
|
// than cached catalog pages. Memory should not grow with supporting-file size.
|
|
func BenchmarkLoadSupportingFile(b *testing.B) {
|
|
for _, size := range []int{64 << 10, 8 << 20} {
|
|
for _, kind := range []string{"ASCII", "UTF8", "Invalid"} {
|
|
b.Run(fmt.Sprintf("%s/%dKiB", kind, size>>10), func(b *testing.B) {
|
|
dir := filepath.Join(b.TempDir(), "bench")
|
|
if err := os.Mkdir(dir, 0755); err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
data := bytes.Repeat([]byte("a"), size)
|
|
if kind == "UTF8" {
|
|
copy(data, bytes.Repeat([]byte("界"), size/3))
|
|
} else if kind == "Invalid" {
|
|
data[0] = 0xff
|
|
}
|
|
for name, content := range map[string][]byte{
|
|
"SKILL.md": []byte("---\nname: bench\ndescription: Benchmark package reload\n---\n"),
|
|
"asset": data,
|
|
} {
|
|
if err := os.WriteFile(filepath.Join(dir, name), content, 0644); err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(size))
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
if _, err := Load(dir); err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|