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

Function ReadSkill

coderd/x/chatd/chattool/skill.go:283–338  ·  view source on GitHub ↗

ReadSkill returns an AgentTool that reads the full instructions for a skill by name. The model should call this before following any skill's instructions.

(options ReadSkillOptions)

Source from the content-addressed store, hash-verified

281// for a skill by name. The model should call this before
282// following any skill's instructions.
283func ReadSkill(options ReadSkillOptions) fantasy.AgentTool {
284 return fantasy.NewAgentTool(
285 "read_skill",
286 "Read the full instructions for a skill by name. "+
287 "Returns the skill meta file body and a list of "+
288 "supporting files. Use read_skill before "+
289 "following a skill's instructions.",
290 func(ctx context.Context, args ReadSkillArgs, _ fantasy.ToolCall) (fantasy.ToolResponse, error) {
291 if args.Name == "" {
292 return fantasy.NewTextErrorResponse(
293 "name is required",
294 ), nil
295 }
296
297 resolved, err := resolveSkillAlias(options, args.Name)
298 if err != nil {
299 return skillResolveErrorResponse(args.Name, err), nil
300 }
301
302 switch resolved.Source {
303 case skillspkg.SourcePersonal:
304 if options.LoadPersonalSkillBody == nil {
305 return fantasy.NewTextErrorResponse(
306 "personal skill loader is not configured",
307 ), nil
308 }
309 content, err := options.LoadPersonalSkillBody(ctx, resolved.Name)
310 if err != nil {
311 if xerrors.Is(err, skillspkg.ErrSkillNotFound) {
312 return skillNotFoundResponse(args.Name), nil
313 }
314 return fantasy.NewTextErrorResponse(
315 fmt.Sprintf("failed to load personal skill %q", args.Name),
316 ), nil
317 }
318 return toolResponse(map[string]any{
319 "name": args.Name,
320 "body": content.Body,
321 "files": []string{},
322 }), nil
323 case skillspkg.SourceWorkspace:
324 content, response, ok := readWorkspaceSkillBody(ctx, options, args.Name, resolved.Name)
325 if ok {
326 return response, nil
327 }
328 return toolResponse(map[string]any{
329 "name": args.Name,
330 "body": content.Body,
331 "files": nonNilFiles(content.Files),
332 }), nil
333 default:
334 return skillNotFoundResponse(args.Name), nil
335 }
336 },
337 )
338}
339
340// ReadSkillFileArgs are the parameters accepted by

Callers 2

runChatMethod · 0.92
TestReadSkillToolFunction · 0.92

Calls 7

resolveSkillAliasFunction · 0.85
skillNotFoundResponseFunction · 0.85
toolResponseFunction · 0.85
readWorkspaceSkillBodyFunction · 0.85
nonNilFilesFunction · 0.85
IsMethod · 0.45

Tested by 1

TestReadSkillToolFunction · 0.74