MCPcopy
hub / github.com/codeaashu/claude-code / getChangedFiles

Function getChangedFiles

src/utils/attachments.ts:2063–2161  ·  view source on GitHub ↗
(
  toolUseContext: ToolUseContext,
)

Source from the content-addressed store, hash-verified

2061}
2062
2063export async function getChangedFiles(
2064 toolUseContext: ToolUseContext,
2065): Promise<Attachment[]> {
2066 const filePaths = cacheKeys(toolUseContext.readFileState)
2067 if (filePaths.length === 0) return []
2068
2069 const appState = toolUseContext.getAppState()
2070 const results = await Promise.all(
2071 filePaths.map(async filePath => {
2072 const fileState = toolUseContext.readFileState.get(filePath)
2073 if (!fileState) return null
2074
2075 // TODO: Implement offset/limit support for changed files
2076 if (fileState.offset !== undefined || fileState.limit !== undefined) {
2077 return null
2078 }
2079
2080 const normalizedPath = expandPath(filePath)
2081
2082 // Check if file has a deny rule configured
2083 if (isFileReadDenied(normalizedPath, appState.toolPermissionContext)) {
2084 return null
2085 }
2086
2087 try {
2088 const mtime = await getFileModificationTimeAsync(normalizedPath)
2089 if (mtime <= fileState.timestamp) {
2090 return null
2091 }
2092
2093 const fileInput = { file_path: normalizedPath }
2094
2095 // Validate file path is valid
2096 const isValid = await FileReadTool.validateInput(
2097 fileInput,
2098 toolUseContext,
2099 )
2100 if (!isValid.result) {
2101 return null
2102 }
2103
2104 const result = await FileReadTool.call(fileInput, toolUseContext)
2105 // Extract only the changed section
2106 if (result.data.type === 'text') {
2107 const snippet = getSnippetForTwoFileDiff(
2108 fileState.content,
2109 result.data.file.content,
2110 )
2111
2112 // File was touched but not modified
2113 if (snippet === '') {
2114 return null
2115 }
2116
2117 return {
2118 type: 'edited_text_file' as const,
2119 filename: normalizedPath,
2120 snippet,

Callers 1

getAttachmentsFunction · 0.70

Calls 11

cacheKeysFunction · 0.85
expandPathFunction · 0.85
isFileReadDeniedFunction · 0.85
getSnippetForTwoFileDiffFunction · 0.85
readImageWithTokenBudgetFunction · 0.85
logEventFunction · 0.85
isENOENTFunction · 0.85
logErrorFunction · 0.70
getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected