( state: AttributionState, filePath: string, oldContent: string, )
| 451 | * Used when Claude deletes a file through a non-tracked mechanism. |
| 452 | */ |
| 453 | export function trackFileDeletion( |
| 454 | state: AttributionState, |
| 455 | filePath: string, |
| 456 | oldContent: string, |
| 457 | ): AttributionState { |
| 458 | const normalizedPath = normalizeFilePath(filePath) |
| 459 | const existingState = state.fileStates.get(normalizedPath) |
| 460 | const existingContribution = existingState?.claudeContribution ?? 0 |
| 461 | const deletedChars = oldContent.length |
| 462 | |
| 463 | const newFileState: FileAttributionState = { |
| 464 | contentHash: '', // Empty hash for deleted files |
| 465 | claudeContribution: existingContribution + deletedChars, |
| 466 | mtime: Date.now(), |
| 467 | } |
| 468 | |
| 469 | const newFileStates = new Map(state.fileStates) |
| 470 | newFileStates.set(normalizedPath, newFileState) |
| 471 | |
| 472 | logForDebugging( |
| 473 | `Attribution: Tracked deletion of ${normalizedPath} (${deletedChars} chars removed, total contribution: ${newFileState.claudeContribution})`, |
| 474 | ) |
| 475 | |
| 476 | return { |
| 477 | ...state, |
| 478 | fileStates: newFileStates, |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | // -- |
| 483 |
nothing calls this directly
no test coverage detected