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

Function getSessionFileTypeFromInput

src/utils/sessionFileAccessHooks.ts:75–116  ·  view source on GitHub ↗

* Extract file type from tool input. * Returns the detected session file type or null.

(
  toolName: string,
  toolInput: unknown,
)

Source from the content-addressed store, hash-verified

73 * Returns the detected session file type or null.
74 */
75function getSessionFileTypeFromInput(
76 toolName: string,
77 toolInput: unknown,
78): 'session_memory' | 'session_transcript' | null {
79 switch (toolName) {
80 case FILE_READ_TOOL_NAME: {
81 const parsed = FileReadTool.inputSchema.safeParse(toolInput)
82 if (!parsed.success) return null
83 return detectSessionFileType(parsed.data.file_path)
84 }
85 case GREP_TOOL_NAME: {
86 const parsed = GrepTool.inputSchema.safeParse(toolInput)
87 if (!parsed.success) return null
88 // Check path if provided
89 if (parsed.data.path) {
90 const pathType = detectSessionFileType(parsed.data.path)
91 if (pathType) return pathType
92 }
93 // Check glob pattern
94 if (parsed.data.glob) {
95 const globType = detectSessionPatternType(parsed.data.glob)
96 if (globType) return globType
97 }
98 return null
99 }
100 case GLOB_TOOL_NAME: {
101 const parsed = GlobTool.inputSchema.safeParse(toolInput)
102 if (!parsed.success) return null
103 // Check path if provided
104 if (parsed.data.path) {
105 const pathType = detectSessionFileType(parsed.data.path)
106 if (pathType) return pathType
107 }
108 // Check pattern
109 const patternType = detectSessionPatternType(parsed.data.pattern)
110 if (patternType) return patternType
111 return null
112 }
113 default:
114 return null
115 }
116}
117
118/**
119 * Check if a tool use constitutes a memory file access.

Callers 2

isMemoryFileAccessFunction · 0.85
handleSessionFileAccessFunction · 0.85

Calls 2

detectSessionPatternTypeFunction · 0.85
detectSessionFileTypeFunction · 0.70

Tested by

no test coverage detected