( filePath: string, )
| 38 | * Returns the type of session file or null if not a session file. |
| 39 | */ |
| 40 | export 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. |
no test coverage detected