MCPcopy Index your code
hub / github.com/codeaashu/claude-code / trackFileModification

Function trackFileModification

src/utils/commitAttribution.ts:402–433  ·  view source on GitHub ↗
(
  state: AttributionState,
  filePath: string,
  oldContent: string,
  newContent: string,
  _userModified: boolean,
  mtime: number = Date.now(),
)

Source from the content-addressed store, hash-verified

400 * Called after Edit/Write tool completes.
401 */
402export 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).

Callers 1

trackFileCreationFunction · 0.85

Calls 4

normalizeFilePathFunction · 0.85
logForDebuggingFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected