(workspaceDir)
| 2 | import path from 'path' |
| 3 | |
| 4 | export function createSessionStore(workspaceDir) { |
| 5 | const sessionId = new Date().toISOString().replace(/[:.]/g, '-') |
| 6 | const rootDir = path.join(workspaceDir, '.compatible-shell', 'sessions') |
| 7 | const sessionPath = path.join(rootDir, `${sessionId}.json`) |
| 8 | |
| 9 | return { |
| 10 | sessionId, |
| 11 | sessionPath, |
| 12 | async save(snapshot) { |
| 13 | await fs.mkdir(rootDir, { recursive: true }) |
| 14 | await fs.writeFile(sessionPath, JSON.stringify(snapshot, null, 2), 'utf8') |
| 15 | return sessionPath |
| 16 | }, |
| 17 | } |
| 18 | } |