( state: AttributionState, filePath: string, oldContent: string, newContent: string, _userModified: boolean, mtime: number = Date.now(), )
| 400 | * Called after Edit/Write tool completes. |
| 401 | */ |
| 402 | export function trackFileModification( |
| 403 | state: AttributionState, |
| 404 | filePath: string, |
| 405 | oldContent: string, |
| 406 | newContent: string, |
| 407 | _userModified: boolean, |
| 408 | mtime: number = Date.now(), |
| 409 | ): AttributionState { |
| 410 | const normalizedPath = normalizeFilePath(filePath) |
| 411 | const newFileState = computeFileModificationState( |
| 412 | state.fileStates, |
| 413 | filePath, |
| 414 | oldContent, |
| 415 | newContent, |
| 416 | mtime, |
| 417 | ) |
| 418 | if (!newFileState) { |
| 419 | return state |
| 420 | } |
| 421 | |
| 422 | const newFileStates = new Map(state.fileStates) |
| 423 | newFileStates.set(normalizedPath, newFileState) |
| 424 | |
| 425 | logForDebugging( |
| 426 | `Attribution: Tracked ${newFileState.claudeContribution} chars for ${normalizedPath}`, |
| 427 | ) |
| 428 | |
| 429 | return { |
| 430 | ...state, |
| 431 | fileStates: newFileStates, |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | /** |
| 436 | * Track a file creation by Claude (e.g., via bash command). |
no test coverage detected