* 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, )
| 169 | * Returns null if no attribution data is available. |
| 170 | */ |
| 171 | async function getPRAttributionData( |
| 172 | appState: AppState, |
| 173 | ): Promise<AttributionData | null> { |
| 174 | const attribution = appState.attribution |
| 175 | |
| 176 | if (!attribution) { |
| 177 | return null |
| 178 | } |
| 179 | |
| 180 | // Handle both Map and plain object (in case of serialization) |
| 181 | const fileStates = attribution.fileStates |
| 182 | const isMap = fileStates instanceof Map |
| 183 | const trackedFiles = isMap |
| 184 | ? Array.from(fileStates.keys()) |
| 185 | : Object.keys(fileStates) |
| 186 | |
| 187 | if (trackedFiles.length === 0) { |
| 188 | return null |
| 189 | } |
| 190 | |
| 191 | try { |
| 192 | return await calculateCommitAttribution([attribution], trackedFiles) |
| 193 | } catch (error) { |
| 194 | logError(error as Error) |
| 195 | return null |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | const MEMORY_ACCESS_TOOL_NAMES = new Set([ |
| 200 | FILE_READ_TOOL_NAME, |
no test coverage detected