-
Notifications
You must be signed in to change notification settings - Fork 15
feat(sdk): harden pkg/kit embedder surface with scoped additions #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package config | ||
|
|
||
| import ( | ||
| "sync" | ||
| "testing" | ||
| ) | ||
|
|
||
| // TestConfigPathConcurrentAccess exercises the mutex guarding the package-level | ||
| // configPath global. Run with -race to detect the data race that motivated the | ||
| // guard (concurrent kit.New() calls discovering a .kit.yml). | ||
| func TestConfigPathConcurrentAccess(t *testing.T) { | ||
| t.Cleanup(func() { SetConfigPath("") }) | ||
|
|
||
| const goroutines = 32 | ||
| var wg sync.WaitGroup | ||
| wg.Add(goroutines * 2) | ||
| for range goroutines { | ||
| go func() { | ||
| defer wg.Done() | ||
| SetConfigPath("/tmp/kit.yml") | ||
| }() | ||
| go func() { | ||
| defer wg.Done() | ||
| _ = GetConfigPath() | ||
| }() | ||
| } | ||
| wg.Wait() | ||
|
|
||
| SetConfigPath("/tmp/final.yml") | ||
| if got := GetConfigPath(); got != "/tmp/final.yml" { | ||
| t.Fatalf("GetConfigPath() = %q, want /tmp/final.yml", got) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package skills | ||
|
|
||
| import ( | ||
| "testing" | ||
| "testing/fstest" | ||
| ) | ||
|
|
||
| func TestLoadSkillsFromFS(t *testing.T) { | ||
| fsys := fstest.MapFS{ | ||
| "top.md": {Data: []byte("---\nname: top-skill\ndescription: a top level skill\n---\nbody here")}, | ||
| "notes.txt": {Data: []byte("plain text skill")}, | ||
| "deep/SKILL.md": {Data: []byte("---\nname: deep-skill\n---\ndeep body")}, | ||
| "deep/other.md": {Data: []byte("ignored non-SKILL nested md")}, | ||
| "ignore.json": {Data: []byte("{}")}, | ||
| } | ||
|
|
||
| got, err := LoadSkillsFromFS(fsys, ".") | ||
| if err != nil { | ||
| t.Fatalf("LoadSkillsFromFS error: %v", err) | ||
| } | ||
|
|
||
| byName := map[string]*Skill{} | ||
| for _, s := range got { | ||
| byName[s.Name] = s | ||
| } | ||
|
|
||
| if _, ok := byName["top-skill"]; !ok { | ||
| t.Errorf("top-skill not loaded; got %v", names(got)) | ||
| } | ||
| if _, ok := byName["notes"]; !ok { | ||
| t.Errorf("notes (txt) not loaded; got %v", names(got)) | ||
| } | ||
| if _, ok := byName["deep-skill"]; !ok { | ||
| t.Errorf("deep SKILL.md not loaded; got %v", names(got)) | ||
| } | ||
| if _, ok := byName["other"]; ok { | ||
| t.Errorf("nested non-SKILL .md should be ignored; got %v", names(got)) | ||
| } | ||
| if len(got) != 3 { | ||
| t.Errorf("expected 3 skills, got %d: %v", len(got), names(got)) | ||
| } | ||
|
|
||
| // Content/description parsed from frontmatter. | ||
| if s := byName["top-skill"]; s != nil { | ||
| if s.Description != "a top level skill" { | ||
| t.Errorf("description = %q", s.Description) | ||
| } | ||
| if s.Content != "body here" { | ||
| t.Errorf("content = %q", s.Content) | ||
| } | ||
| if s.Path != "top.md" { | ||
| t.Errorf("path = %q, want top.md", s.Path) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestLoadSkillsFromFSNil(t *testing.T) { | ||
| got, err := LoadSkillsFromFS(nil, ".") | ||
| if err != nil || got != nil { | ||
| t.Fatalf("nil fs should yield (nil, nil), got (%v, %v)", got, err) | ||
| } | ||
| } | ||
|
|
||
| func names(skills []*Skill) []string { | ||
| out := make([]string, 0, len(skills)) | ||
| for _, s := range skills { | ||
| out = append(out, s.Name) | ||
| } | ||
| return out | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.