MCPcopy Create free account
hub / github.com/WJX20/claude-code / getFilePathsFromReadMessage

Function getFilePathsFromReadMessage

src/utils/collapseReadSearch.ts:549–573  ·  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

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

Callers 1

collapseReadSearchGroupsFunction · 0.85

Calls 1

getFirstContentItemFunction · 0.85

Tested by

no test coverage detected