MCPcopy Create free account
hub / github.com/Noumena-Network/code / trackFileModification

Function trackFileModification

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

341 * Called after Edit/Write tool completes.
342 */
343export 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).

Callers 1

trackFileCreationFunction · 0.85

Calls 4

normalizeFilePathFunction · 0.85
setMethod · 0.80
logForDebuggingFunction · 0.70

Tested by

no test coverage detected