| 1 | package frontmatter |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | // TestSplitParsesYAMLList probes a YAML list value (the form skills authored for |
| 6 | // other agent tools use for allowed-tools). The parser must surface the items so |
| 7 | // a subagent skill keeps its tool scoping; dropping them silently widens the |
| 8 | // skill to the full parent registry. |
| 9 | func TestSplitParsesYAMLList(t *testing.T) { |
| 10 | in := "---\n" + |
| 11 | "name: review\n" + |
| 12 | "allowed-tools:\n" + |
| 13 | " - read_file\n" + |
| 14 | " - grep\n" + |
| 15 | "---\n" + |
| 16 | "body here\n" |
| 17 | fm, body := Split(in) |
| 18 | if fm["name"] != "review" { |
| 19 | t.Fatalf("name = %q", fm["name"]) |
| 20 | } |
| 21 | got := fm["allowed-tools"] |
| 22 | if got == "" { |
| 23 | t.Fatalf("allowed-tools list was dropped entirely (got empty)") |
| 24 | } |
| 25 | for _, want := range []string{"read_file", "grep"} { |
| 26 | if !contains(got, want) { |
| 27 | t.Errorf("allowed-tools %q missing %q", got, want) |
| 28 | } |
| 29 | } |
| 30 | if body != "body here\n" { |
| 31 | t.Errorf("body = %q", body) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | func contains(s, sub string) bool { |
| 36 | for i := 0; i+len(sub) <= len(s); i++ { |
| 37 | if s[i:i+len(sub)] == sub { |
| 38 | return true |
| 39 | } |
| 40 | } |
| 41 | return false |
| 42 | } |
| 43 |