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

Function trackFileModification

src/utils/commitAttribution.ts:403–434  ·  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

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

Callers 1

trackFileCreationFunction · 0.85

Calls 5

normalizeFilePathFunction · 0.85
nowMethod · 0.80
setMethod · 0.80
logForDebuggingFunction · 0.70

Tested by

no test coverage detected