-
Notifications
You must be signed in to change notification settings - Fork 7
Platform tool-registry contract: skill uses block + MCP tool annotations #309
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package mcp | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "testing" | ||
| ) | ||
|
|
||
| // tools/list responses may carry the MCP annotations object; decode must | ||
| // surface it (platform discovery seeds side-effect classes from these hints) | ||
| // and its absence must stay distinguishable from explicit false. | ||
| func TestMCPToolDescriptor_AnnotationsDecode(t *testing.T) { | ||
| raw := []byte(`[ | ||
| {"name":"list_issues","inputSchema":{},"annotations":{"readOnlyHint":true}}, | ||
| {"name":"delete_issue","inputSchema":{},"annotations":{"destructiveHint":true,"readOnlyHint":false}}, | ||
| {"name":"create_issue","inputSchema":{}} | ||
| ]`) | ||
| var descs []MCPToolDescriptor | ||
| if err := json.Unmarshal(raw, &descs); err != nil { | ||
| t.Fatalf("decode: %v", err) | ||
| } | ||
| if descs[0].Annotations == nil || descs[0].Annotations.ReadOnlyHint == nil || !*descs[0].Annotations.ReadOnlyHint { | ||
| t.Fatalf("readOnlyHint lost: %+v", descs[0].Annotations) | ||
| } | ||
| if descs[1].Annotations == nil || descs[1].Annotations.DestructiveHint == nil || !*descs[1].Annotations.DestructiveHint { | ||
| t.Fatalf("destructiveHint lost: %+v", descs[1].Annotations) | ||
| } | ||
| if descs[2].Annotations != nil { | ||
| t.Fatalf("absent annotations must stay nil, got %+v", descs[2].Annotations) | ||
| } | ||
| } |
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
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,59 @@ | ||
| package parser | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| const skillWithUses = `--- | ||
| name: linear-triage | ||
| description: Triage Linear issues | ||
| metadata: | ||
| forge: | ||
| requires: | ||
| bins: [jq] | ||
| uses: | ||
| - type: mcp | ||
| ref: mcp.linear | ||
| operations: [create_issue, list_issues] | ||
| - type: binary | ||
| ref: bin.jq | ||
| operations: [exec] | ||
| --- | ||
| # Linear triage | ||
| ` | ||
|
|
||
| func TestExtractForgeUses(t *testing.T) { | ||
| _, meta, err := ParseWithMetadata(strings.NewReader(skillWithUses)) | ||
| if err != nil { | ||
| t.Fatalf("parse: %v", err) | ||
| } | ||
| uses := ExtractForgeUses(meta) | ||
| if len(uses) != 2 { | ||
| t.Fatalf("want 2 deps, got %d: %+v", len(uses), uses) | ||
| } | ||
| if uses[0].Type != "mcp" || uses[0].Ref != "mcp.linear" || len(uses[0].Operations) != 2 { | ||
| t.Fatalf("mcp dep mismatch: %+v", uses[0]) | ||
| } | ||
| if uses[1].Type != "binary" || uses[1].Ref != "bin.jq" { | ||
| t.Fatalf("binary dep mismatch: %+v", uses[1]) | ||
| } | ||
| // requires.bins still parses beside it — the legacy surface is untouched. | ||
| reqs, _, _ := ExtractForgeReqs(meta) | ||
| if reqs == nil || len(reqs.Bins) != 1 || reqs.Bins[0].Name != "jq" { | ||
| t.Fatalf("requires.bins lost: %+v", reqs) | ||
| } | ||
| } | ||
|
|
||
| // A skill with no uses block — the universal pre-registry case — must parse | ||
| // exactly as before, with ExtractForgeUses returning nil. | ||
| func TestExtractForgeUses_AbsentIsNil(t *testing.T) { | ||
| const legacy = "---\nname: x\nmetadata:\n forge:\n requires:\n bins: [curl]\n---\nbody\n" | ||
| _, meta, err := ParseWithMetadata(strings.NewReader(legacy)) | ||
| if err != nil { | ||
| t.Fatalf("parse: %v", err) | ||
| } | ||
| if uses := ExtractForgeUses(meta); uses != nil { | ||
| t.Fatalf("want nil, got %+v", uses) | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor (godoc bug):
SkillToolDependencywas inserted between theSkillRequirementsdoc comment and its type.On the branch this now reads:
With no blank line between the two comment paragraphs, godoc attaches the merged comment ("SkillRequirements declares… SkillToolDependency is one governed tool dependency…") to
SkillToolDependency, andtype SkillRequirementsis left undocumented — its comment was orphaned onto the wrong type (go doc SkillRequirementsnow shows nothing).Fix: move the whole
SkillToolDependencyblock (with its own comment) above the// SkillRequirements declares…line, or below theSkillRequirementsstruct — anywhere that doesn't sit between a type's doc comment and itstypekeyword.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in aa47131 — moved the whole
SkillToolDependencyblock above theSkillRequirementsdoc comment. Verified withgo doc:SkillRequirementsshows its own comment again andSkillToolDependencycarries only its own. Tests re-run with-count=1, green.