( state: AttributionState, filePath: string, oldContent: string, )
| 392 | * Used when NCode deletes a file through a non-tracked mechanism. |
| 393 | */ |
| 394 | export function trackFileDeletion( |
| 395 | state: AttributionState, |
| 396 | filePath: string, |
| 397 | oldContent: string, |
| 398 | ): AttributionState { |
| 399 | const normalizedPath = normalizeFilePath(filePath) |
| 400 | const existingState = state.fileStates.get(normalizedPath) |
| 401 | const existingContribution = existingState?.assistantContribution ?? 0 |
| 402 | const deletedChars = oldContent.length |
| 403 | |
| 404 | const newFileState: FileAttributionState = { |
| 405 | contentHash: '', // Empty hash for deleted files |
| 406 | assistantContribution: existingContribution + deletedChars, |
| 407 | mtime: Date.now(), |
| 408 | } |
| 409 | |
| 410 | const newFileStates = new Map(state.fileStates) |
| 411 | newFileStates.set(normalizedPath, newFileState) |
| 412 | |
| 413 | logForDebugging( |
| 414 | `Attribution: Tracked deletion of ${normalizedPath} (${deletedChars} chars removed, total contribution: ${newFileState.assistantContribution})`, |
| 415 | ) |
| 416 | |
| 417 | return { |
| 418 | ...state, |
| 419 | fileStates: newFileStates, |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | // -- |
| 424 |
nothing calls this directly
no test coverage detected