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