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

Function trackFileDeletion

src/utils/commitAttribution.ts:394–421  ·  view source on GitHub ↗
(
  state: AttributionState,
  filePath: string,
  oldContent: string,
)

Source from the content-addressed store, hash-verified

392 * Used when NCode deletes a file through a non-tracked mechanism.
393 */
394export 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

Callers

nothing calls this directly

Calls 4

normalizeFilePathFunction · 0.85
setMethod · 0.80
logForDebuggingFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected