build: 内置 norma 模块,构建不再依赖上游仓库
把 github.com/Autumn-27/norma v0.4.3(commit 320ae32)的源码复制到 third_party/norma,并用 go.mod 的 replace 指向本地副本。上游删除仓库或 改写 tag 都不再影响本仓库构建。 - 已验证 GOPROXY=off 下可完整编译并打出发行包 - go.sum 中该模块的两条校验记录随之删除(本地 replace 不需要哈希) - 升级方法与授权注意事项见 third_party/README.md
This commit is contained in:
1 parent
a819fa3230
commit
f782b612ec
213 files changed
+37401
-2
No files matched your search
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
package skill
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseMCPsFrontmatter(t *testing.T) {
|
||||
cases := map[string][]string{
|
||||
"---\nname: a\nmcps: browser\n---\nbody": {"browser"},
|
||||
"---\nname: b\nmcps: browser, nmap\n---\nbody": {"browser", "nmap"},
|
||||
"---\nname: c\nmcps: [browser, \"nmap\"]\n---\nbody": {"browser", "nmap"},
|
||||
}
|
||||
for src, want := range cases {
|
||||
sk := parse(src)
|
||||
if strings.Join(sk.MCPs, ",") != strings.Join(want, ",") {
|
||||
t.Fatalf("MCPs=%v want %v (src=%q)", sk.MCPs, want, src)
|
||||
}
|
||||
}
|
||||
// no mcps → nil
|
||||
if sk := parse("---\nname: d\n---\nbody"); sk.MCPs != nil {
|
||||
t.Fatalf("expected nil MCPs, got %v", sk.MCPs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOnInvokeAppendsAndFires(t *testing.T) {
|
||||
reg := NewRegistry(Skill{Name: "browsing", Description: "d", Instructions: "do it", MCPs: []string{"browser"}})
|
||||
var firedFor string
|
||||
reg.OnInvoke = func(s Skill) string {
|
||||
firedFor = s.Name
|
||||
return "UNLOCKED:" + strings.Join(s.MCPs, ",")
|
||||
}
|
||||
tl := reg.Tool()
|
||||
r, err := tl.Call(context.Background(), json.RawMessage(`{"name":"browsing"}`), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
txt := r.Content[0].Text
|
||||
if firedFor != "browsing" {
|
||||
t.Fatalf("OnInvoke not fired for browsing, got %q", firedFor)
|
||||
}
|
||||
if !strings.Contains(txt, "UNLOCKED:browser") {
|
||||
t.Fatalf("OnInvoke output not appended:\n%s", txt)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user