MCPcopy
hub / github.com/simstudioai/sim / grepReadResult

Function grepReadResult

apps/sim/lib/copilot/vfs/operations.ts:60–76  ·  view source on GitHub ↗
(
  path: string,
  result: { content: string; totalLines: number; attachment?: unknown },
  pattern: string,
  readHint: string,
  options?: GrepOptions
)

Source from the content-addressed store, hash-verified

58 * `path`. `readHint` is the path to suggest in the "use read(...)" message.
59 */
60export function grepReadResult(
61 path: string,
62 result: { content: string; totalLines: number; attachment?: unknown },
63 pattern: string,
64 readHint: string,
65 options?: GrepOptions
66): GrepMatch[] | string[] | GrepCountEntry[] {
67 if (result.attachment) {
68 throw new WorkspaceFileGrepError(
69 `Cannot grep "${path}" — it has no searchable text (image/binary). Use read("${readHint}") to view it.`
70 )
71 }
72 if (isNonGreppablePlaceholder(result.content, result.totalLines)) {
73 throw new WorkspaceFileGrepError(result.content)
74 }
75 return grep(new Map([[path, result.content]]), pattern, undefined, options)
76}
77
78export interface ReadResult {
79 content: string

Callers 1

grepChatUploadFunction · 0.90

Calls 2

grepFunction · 0.85

Tested by

no test coverage detected