MCPcopy Index your code
hub / github.com/codeaashu/claude-code / readTruncatedFile

Function readTruncatedFile

src/utils/attachments.ts:3128–3169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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