MCPcopy Create free account
hub / github.com/Noumena-Network/code / getFilePathsFromReadMessage

Function getFilePathsFromReadMessage

src/utils/collapseReadSearch.ts:553–577  ·  view source on GitHub ↗

* Extract file paths from read tool inputs in a message. * Returns an array of file paths (may have duplicates if same file is read multiple times in one grouped message).

(msg: RenderableMessage)

Source from the content-addressed store, hash-verified

551 * Returns an array of file paths (may have duplicates if same file is read multiple times in one grouped message).
552 */
553function getFilePathsFromReadMessage(msg: RenderableMessage): string[] {
554 const paths: string[] = []
555
556 if (msg.type === 'assistant') {
557 const content = msg.message.content[0]
558 if (content?.type === 'tool_use') {
559 const input = content.input as { file_path?: string } | undefined
560 if (input?.file_path) {
561 paths.push(input.file_path)
562 }
563 }
564 } else if (msg.type === 'grouped_tool_use') {
565 for (const m of msg.messages) {
566 const content = m.message.content[0]
567 if (content?.type === 'tool_use') {
568 const input = content.input as { file_path?: string } | undefined
569 if (input?.file_path) {
570 paths.push(input.file_path)
571 }
572 }
573 }
574 }
575
576 return paths
577}
578
579/**
580 * Scan a bash tool result for commit SHAs and PR URLs and push them into the

Callers 1

collapseReadSearchGroupsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected