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

Function getChangedFiles

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

Source from the content-addressed store, hash-verified

2113}
2114
2115export async function getChangedFiles(
2116 toolUseContext: ToolUseContext,
2117): Promise<Attachment[]> {
2118 const filePaths = cacheKeys(toolUseContext.readFileState)
2119 if (filePaths.length === 0) return []
2120
2121 const appState = toolUseContext.getAppState()
2122 const results = await Promise.all(
2123 filePaths.map(async filePath => {
2124 const fileState = toolUseContext.readFileState.get(filePath)
2125 if (!fileState) return null
2126
2127 // TODO: Implement offset/limit support for changed files
2128 if (fileState.offset !== undefined || fileState.limit !== undefined) {
2129 return null
2130 }
2131
2132 const normalizedPath = expandPath(filePath)
2133
2134 // Check if file has a deny rule configured
2135 if (isFileReadDenied(normalizedPath, appState.toolPermissionContext)) {
2136 return null
2137 }
2138
2139 try {
2140 const mtime = await getFileModificationTimeAsync(normalizedPath)
2141 if (mtime <= fileState.timestamp) {
2142 return null
2143 }
2144
2145 const fileInput = { file_path: normalizedPath }
2146
2147 // Validate file path is valid
2148 const isValid = await FileReadTool.validateInput(
2149 fileInput,
2150 toolUseContext,
2151 )
2152 if (!isValid.result) {
2153 return null
2154 }
2155
2156 const result = await FileReadTool.call(fileInput, toolUseContext)
2157 // Extract only the changed section
2158 if (result.data.type === 'text') {
2159 const snippet = getSnippetForTwoFileDiff(
2160 fileState.content,
2161 result.data.file.content,
2162 )
2163
2164 // File was touched but not modified
2165 if (snippet === '') {
2166 return null
2167 }
2168
2169 return {
2170 type: 'edited_text_file' as const,
2171 filename: normalizedPath,
2172 snippet,

Callers 1

getAttachmentsFunction · 0.70

Calls 13

cacheKeysFunction · 0.85
expandPathFunction · 0.85
isFileReadDeniedFunction · 0.85
getSnippetForTwoFileDiffFunction · 0.85
readImageWithTokenBudgetFunction · 0.85
logEventFunction · 0.85
isENOENTFunction · 0.85
validateInputMethod · 0.80
callMethod · 0.80
logErrorFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected