MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / GetReadTextFileToolDefinition

Function GetReadTextFileToolDefinition

pkg/aiusechat/tools_readfile.go:327–410  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

325}
326
327func GetReadTextFileToolDefinition() uctypes.ToolDefinition {
328 return uctypes.ToolDefinition{
329 Name: "read_text_file",
330 DisplayName: "Read Text File",
331 Description: "Read a text file from the filesystem. Can read specific line ranges or from the end. Detects and rejects binary files.",
332 ToolLogName: "gen:readfile",
333 Strict: false,
334 InputSchema: map[string]any{
335 "type": "object",
336 "properties": map[string]any{
337 "filename": map[string]any{
338 "type": "string",
339 "description": "Absolute path to the file to read. Supports '~' for the user's home directory. Relative paths are not supported.",
340 },
341 "origin": map[string]any{
342 "type": "string",
343 "enum": []string{"start", "end"},
344 "default": "start",
345 "description": "Where to read from: 'start' (default) or 'end' of file",
346 },
347 "offset": map[string]any{
348 "type": "integer",
349 "minimum": 0,
350 "default": 0,
351 "description": "Lines to skip. From 'start': 0-based line index. From 'end': lines to skip from the end (0 = very last line)",
352 },
353 "count": map[string]any{
354 "type": "integer",
355 "minimum": 1,
356 "default": ReadFileDefaultLineCount,
357 "description": "Number of lines to return",
358 },
359 "max_bytes": map[string]any{
360 "type": "integer",
361 "minimum": 1,
362 "default": ReadFileDefaultMaxBytes,
363 "description": "Maximum bytes to return. If the result exceeds this, it will be truncated at line boundaries",
364 },
365 },
366 "required": []string{"filename"},
367 "additionalProperties": false,
368 },
369 ToolCallDesc: func(input any, output any, toolUseData *uctypes.UIMessageDataToolUse) string {
370 parsed, err := parseReadTextFileInput(input)
371 if err != nil {
372 return fmt.Sprintf("error parsing input: %v", err)
373 }
374
375 origin := *parsed.Origin
376 offset := *parsed.Offset
377 count := *parsed.Count
378
379 readFullFile := false
380 if output != nil {
381 if outputMap, ok := output.(map[string]any); ok {
382 _, wasTruncated := outputMap["truncated"]
383 readFullFile = !wasTruncated
384 }

Callers 1

GenerateTabStateAndToolsFunction · 0.85

Calls 1

parseReadTextFileInputFunction · 0.85

Tested by

no test coverage detected