| 125 | } |
| 126 | |
| 127 | function extractPaths(payload: unknown, root: string): string[] { |
| 128 | if (typeof payload !== "object" || payload === null) { |
| 129 | return []; |
| 130 | } |
| 131 | const toolInput = |
| 132 | "tool_input" in payload && |
| 133 | typeof (payload as { tool_input?: unknown }).tool_input === "object" && |
| 134 | (payload as { tool_input?: unknown }).tool_input !== null |
| 135 | ? ((payload as { tool_input?: Record<string, unknown> }).tool_input ?? {}) |
| 136 | : {}; |
| 137 | const paths: string[] = []; |
| 138 | for (const key of ["file_path", "path"] as const) { |
| 139 | const value = toolInput[key]; |
| 140 | if (typeof value === "string" && value.length > 0) { |
| 141 | paths.push(normalize(value, root)); |
| 142 | } |
| 143 | } |
| 144 | return [...new Set(paths)].sort(); |
| 145 | } |
| 146 | |
| 147 | function isTest(path: string): boolean { |
| 148 | return TEST_PATTERNS.some((re) => re.test(path)); |