* Extract the file path from a tool input for memdir detection. * Covers Read (file_path), Edit (file_path), and Write (file_path).
( toolName: string, toolInput: unknown, )
| 47 | * Covers Read (file_path), Edit (file_path), and Write (file_path). |
| 48 | */ |
| 49 | function getFilePathFromInput( |
| 50 | toolName: string, |
| 51 | toolInput: unknown, |
| 52 | ): string | null { |
| 53 | switch (toolName) { |
| 54 | case FILE_READ_TOOL_NAME: { |
| 55 | const parsed = FileReadTool.inputSchema.safeParse(toolInput) |
| 56 | return parsed.success ? parsed.data.file_path : null |
| 57 | } |
| 58 | case FILE_EDIT_TOOL_NAME: { |
| 59 | const parsed = editInputSchema().safeParse(toolInput) |
| 60 | return parsed.success ? parsed.data.file_path : null |
| 61 | } |
| 62 | case FILE_WRITE_TOOL_NAME: { |
| 63 | const parsed = FileWriteTool.inputSchema.safeParse(toolInput) |
| 64 | return parsed.success ? parsed.data.file_path : null |
| 65 | } |
| 66 | default: |
| 67 | return null |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Extract file type from tool input. |
no outgoing calls
no test coverage detected