MCPcopy Index your code
hub / github.com/coder/coder / readWorkspaceSkillBody

Function readWorkspaceSkillBody

coderd/x/chatd/chattool/skill.go:439–465  ·  view source on GitHub ↗
(
	ctx context.Context,
	options ReadSkillOptions,
	requestedName string,
	canonicalName string,
)

Source from the content-addressed store, hash-verified

437}
438
439func 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
467func skillResolveErrorResponse(name string, err error) fantasy.ToolResponse {
468 if xerrors.Is(err, skillspkg.ErrSkillNotFound) {

Callers 1

ReadSkillFunction · 0.85

Calls 4

findSkillFunction · 0.85
skillNotFoundResponseFunction · 0.85
LoadSkillBodyFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected