From fe8a6d49c50dcdc484d21df17b6b5b55a93828c7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 28 Jun 2026 22:45:01 +0000 Subject: [PATCH 1/2] Consolidate skill resource lookup internals Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- agent/skills/provider.go | 44 ++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/agent/skills/provider.go b/agent/skills/provider.go index 2ba0d4f2..bfeec849 100644 --- a/agent/skills/provider.go +++ b/agent/skills/provider.go @@ -82,6 +82,32 @@ type providedSkill struct { scripts map[string]Script } +func newProvidedSkill(skill *Skill) providedSkill { + resources := make(map[string]Resource, len(skill.Resources)) + for _, resource := range skill.Resources { + resources[resource.Name] = resource + } + scripts := make(map[string]Script, len(skill.Scripts)) + for _, script := range skill.Scripts { + scripts[script.Name] = script + } + return providedSkill{ + skill: skill, + resources: resources, + scripts: scripts, + } +} + +func (skill providedSkill) lookupResource(name string) (Resource, bool) { + resource, ok := skill.resources[name] + return resource, ok +} + +func (skill providedSkill) lookupScript(name string) (Script, bool) { + script, ok := skill.scripts[name] + return script, ok +} + type providedSkillSet struct { byName map[string]providedSkill } @@ -329,19 +355,7 @@ func deduplicateSkillsByName(skills []*Skill, logger *slog.Logger) []*Skill { func indexSkills(skills []*Skill) providedSkillSet { indexed := make(map[string]providedSkill, len(skills)) for _, skill := range skills { - resources := make(map[string]Resource) - for _, resource := range skill.Resources { - resources[resource.Name] = resource - } - scripts := make(map[string]Script) - for _, script := range skill.Scripts { - scripts[script.Name] = script - } - indexed[skill.Frontmatter.Name] = providedSkill{ - skill: skill, - resources: resources, - scripts: scripts, - } + indexed[skill.Frontmatter.Name] = newProvidedSkill(skill) } return providedSkillSet{byName: indexed} } @@ -425,7 +439,7 @@ func (p *providerState) readSkillResource(ctx context.Context, skills providedSk if lookupError != "" { return lookupError } - resource, ok := resolved.resources[resourceName] + resource, ok := resolved.lookupResource(resourceName) if !ok { return fmt.Sprintf("Error: Resource '%s' not found in skill '%s'.", resourceName, skillName) } @@ -452,7 +466,7 @@ func (p *providerState) runSkillScript(ctx context.Context, skills providedSkill if lookupError != "" { return lookupError } - script, ok := resolved.scripts[scriptName] + script, ok := resolved.lookupScript(scriptName) if !ok { return fmt.Sprintf("Error: Script '%s' not found in skill '%s'.", scriptName, skillName) } From 775a0fb98c9a96cedfbeb0fe443a72448d2b3461 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Jun 2026 22:30:18 +0000 Subject: [PATCH 2/2] Rename receiver name from `skill` to `ps` in lookupResource/lookupScript methods Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com> --- agent/skills/provider.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/agent/skills/provider.go b/agent/skills/provider.go index bfeec849..bf83d8ca 100644 --- a/agent/skills/provider.go +++ b/agent/skills/provider.go @@ -98,13 +98,13 @@ func newProvidedSkill(skill *Skill) providedSkill { } } -func (skill providedSkill) lookupResource(name string) (Resource, bool) { - resource, ok := skill.resources[name] +func (ps providedSkill) lookupResource(name string) (Resource, bool) { + resource, ok := ps.resources[name] return resource, ok } -func (skill providedSkill) lookupScript(name string) (Script, bool) { - script, ok := skill.scripts[name] +func (ps providedSkill) lookupScript(name string) (Script, bool) { + script, ok := ps.scripts[name] return script, ok }