( ctx context.Context, options ReadSkillOptions, requestedName string, canonicalName string, )
| 437 | } |
| 438 | |
| 439 | func readWorkspaceSkillBody( |
| 440 | ctx context.Context, |
| 441 | options ReadSkillOptions, |
| 442 | requestedName string, |
| 443 | canonicalName string, |
| 444 | ) (SkillContent, fantasy.ToolResponse, bool) { |
| 445 | skill, ok := findSkill(options.GetSkills, canonicalName) |
| 446 | if !ok { |
| 447 | return SkillContent{}, skillNotFoundResponse(requestedName), true |
| 448 | } |
| 449 | if options.GetWorkspaceConn == nil { |
| 450 | return SkillContent{}, fantasy.NewTextErrorResponse( |
| 451 | "workspace connection resolver is not configured", |
| 452 | ), true |
| 453 | } |
| 454 | |
| 455 | conn, err := options.GetWorkspaceConn(ctx) |
| 456 | if err != nil { |
| 457 | return SkillContent{}, fantasy.NewTextErrorResponse(err.Error()), true |
| 458 | } |
| 459 | |
| 460 | content, err := LoadSkillBody(ctx, conn, skill, cmp.Or(skill.MetaFile, DefaultSkillMetaFile)) |
| 461 | if err != nil { |
| 462 | return SkillContent{}, fantasy.NewTextErrorResponse(err.Error()), true |
| 463 | } |
| 464 | return content, fantasy.ToolResponse{}, false |
| 465 | } |
| 466 | |
| 467 | func skillResolveErrorResponse(name string, err error) fantasy.ToolResponse { |
| 468 | if xerrors.Is(err, skillspkg.ErrSkillNotFound) { |
no test coverage detected