( state: AttributionState, filePath: string, oldContent: string, newContent: string, _userModified: boolean, mtime: number = Date.now(), )
| 341 | * Called after Edit/Write tool completes. |
| 342 | */ |
| 343 | export function trackFileModification( |
| 344 | state: AttributionState, |
| 345 | filePath: string, |
| 346 | oldContent: string, |
| 347 | newContent: string, |
| 348 | _userModified: boolean, |
| 349 | mtime: number = Date.now(), |
| 350 | ): AttributionState { |
| 351 | const normalizedPath = normalizeFilePath(filePath) |
| 352 | const newFileState = computeFileModificationState( |
| 353 | state.fileStates, |
| 354 | filePath, |
| 355 | oldContent, |
| 356 | newContent, |
| 357 | mtime, |
| 358 | ) |
| 359 | if (!newFileState) { |
| 360 | return state |
| 361 | } |
| 362 | |
| 363 | const newFileStates = new Map(state.fileStates) |
| 364 | newFileStates.set(normalizedPath, newFileState) |
| 365 | |
| 366 | logForDebugging( |
| 367 | `Attribution: Tracked ${newFileState.assistantContribution} chars for ${normalizedPath}`, |
| 368 | ) |
| 369 | |
| 370 | return { |
| 371 | ...state, |
| 372 | fileStates: newFileStates, |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * Track a file creation by NCode (e.g., via bash command). |
no test coverage detected