* Get full attribution data from the provided AppState's attribution state. * Uses ALL tracked files from the attribution state (not just staged files) * because for PR attribution, files may not be staged yet. * Returns null if no attribution data is available.
( appState: AppState, )
| 183 | * Returns null if no attribution data is available. |
| 184 | */ |
| 185 | async function getPRAttributionData( |
| 186 | appState: AppState, |
| 187 | ): Promise<AttributionData | null> { |
| 188 | const attribution = appState.attribution |
| 189 | |
| 190 | if (!attribution) { |
| 191 | return null |
| 192 | } |
| 193 | |
| 194 | // Handle both Map and plain object (in case of serialization) |
| 195 | const fileStates = attribution.fileStates |
| 196 | const isMap = fileStates instanceof Map |
| 197 | const trackedFiles = isMap |
| 198 | ? Array.from(fileStates.keys()) |
| 199 | : Object.keys(fileStates) |
| 200 | |
| 201 | if (trackedFiles.length === 0) { |
| 202 | return null |
| 203 | } |
| 204 | |
| 205 | try { |
| 206 | return await calculateCommitAttribution([attribution], trackedFiles) |
| 207 | } catch (error) { |
| 208 | logError(error as Error) |
| 209 | return null |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | const MEMORY_ACCESS_TOOL_NAMES = new Set([ |
| 214 | FILE_READ_TOOL_NAME, |
no test coverage detected