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

Function detectSessionFileType

src/utils/memoryFileDetection.ts:40–59  ·  view source on GitHub ↗
(
  filePath: string,
)

Source from the content-addressed store, hash-verified

38 * Returns the type of session file or null if not a session file.
39 */
40export function detectSessionFileType(
41 filePath: string,
42): 'session_memory' | 'session_transcript' | null {
43 const configDir = getClaudeConfigHomeDir()
44 // Compare in forward-slash form; on Windows also case-fold. The caller
45 // (isShellCommandTargetingMemory) converts MinGW /c/... → native before
46 // reaching here, so we only need separator + case normalization.
47 const normalized = toComparable(filePath)
48 const configDirCmp = toComparable(configDir)
49 if (!normalized.startsWith(configDirCmp)) {
50 return null
51 }
52 if (normalized.includes('/session-memory/') && normalized.endsWith('.md')) {
53 return 'session_memory'
54 }
55 if (normalized.includes('/projects/') && normalized.endsWith('.jsonl')) {
56 return 'session_transcript'
57 }
58 return null
59}
60
61/**
62 * Checks if a glob/pattern string indicates session file access intent.

Callers 2

isAutoManagedMemoryFileFunction · 0.70

Calls 1

toComparableFunction · 0.85

Tested by

no test coverage detected