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

Function ReadFile

coderd/x/chatd/chattool/readfile.go:21–39  ·  view source on GitHub ↗
(options ReadFileOptions)

Source from the content-addressed store, hash-verified

19}
20
21func ReadFile(options ReadFileOptions) fantasy.AgentTool {
22 return fantasy.NewAgentTool(
23 "read_file",
24 "Read a file from the workspace. Returns line-numbered content. "+
25 "The offset parameter is a 1-based line number (default: 1). "+
26 "The limit parameter is the number of lines to return (default: 2000). "+
27 "For large files, use offset and limit to paginate.",
28 func(ctx context.Context, args ReadFileArgs, _ fantasy.ToolCall) (fantasy.ToolResponse, error) {
29 if options.GetWorkspaceConn == nil {
30 return fantasy.NewTextErrorResponse("workspace connection resolver is not configured"), nil
31 }
32 conn, err := options.GetWorkspaceConn(ctx)
33 if err != nil {
34 return fantasy.NewTextErrorResponse(err.Error()), nil
35 }
36 return executeReadFileTool(ctx, conn, args)
37 },
38 )
39}
40
41func executeReadFileTool(
42 ctx context.Context,

Callers 1

runChatMethod · 0.92

Calls 2

executeReadFileToolFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected