MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / readTruncatedFile

Function readTruncatedFile

source code/utils/attachments.ts:3130–3171  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3128 }
3129
3130 async function readTruncatedFile(): Promise<
3131 | FileAttachment
3132 | CompactFileReferenceAttachment
3133 | AlreadyReadFileAttachment
3134 | null
3135 > {
3136 if (mode === 'compact') {
3137 return {
3138 type: 'compact_file_reference',
3139 filename,
3140 displayPath: relative(getCwd(), filename),
3141 }
3142 }
3143
3144 // Check deny rules before reading truncated file
3145 const appState = toolUseContext.getAppState()
3146 if (isFileReadDenied(filename, appState.toolPermissionContext)) {
3147 return null
3148 }
3149
3150 try {
3151 // Read only the first MAX_LINES_TO_READ lines for files that are too large
3152 const truncatedInput = {
3153 file_path: filename,
3154 offset: offset ?? 1,
3155 limit: MAX_LINES_TO_READ,
3156 }
3157 const result = await FileReadTool.call(truncatedInput, toolUseContext)
3158 logEvent(successEventName, {})
3159
3160 return {
3161 type: 'file' as const,
3162 filename,
3163 content: result.data,
3164 truncated: true,
3165 displayPath: relative(getCwd(), filename),
3166 }
3167 } catch {
3168 logEvent(errorEventName, {})
3169 return null
3170 }
3171 }
3172
3173 // Validate file path is valid
3174 const isValid = await FileReadTool.validateInput(fileInput, toolUseContext)

Callers 1

generateFileAttachmentFunction · 0.85

Calls 3

getCwdFunction · 0.85
isFileReadDeniedFunction · 0.85
logEventFunction · 0.85

Tested by

no test coverage detected