MCPcopy
hub / github.com/claude-code-best/claude-code / writeSessionLog

Function writeSessionLog

src/commands/share/__tests__/share.test.ts:150–170  ·  view source on GitHub ↗
(entries?: string[])

Source from the content-addressed store, hash-verified

148}
149
150async function writeSessionLog(entries?: string[]): Promise<void> {
151 // Write the session log at the path share/index.ts will compute at runtime.
152 // We use the real state values (no mock) to match the actual path.
153 const { sanitizePath } = await import('../../../utils/path.js')
154 const { getSessionId, getOriginalCwd } = await import(
155 '../../../bootstrap/state.js'
156 )
157 const sessionId = getSessionId()
158 const cwd = getOriginalCwd()
159 const encoded = sanitizePath(cwd)
160 const dir = join(claudeDir, 'projects', encoded)
161 mkdirSync(dir, { recursive: true })
162 const content = entries ?? [
163 JSON.stringify({ role: 'user', content: 'hello world' }),
164 JSON.stringify({
165 role: 'assistant',
166 content: [{ type: 'text', text: 'hi there' }],
167 }),
168 ]
169 writeFileSync(join(dir, `${sessionId}.jsonl`), content.join('\n') + '\n')
170}
171
172// Activate child_process stubs only for this suite.
173beforeAll(() => {

Callers 1

share.test.tsFile · 0.70

Calls 4

getSessionIdFunction · 0.85
getOriginalCwdFunction · 0.85
mkdirSyncFunction · 0.85
sanitizePathFunction · 0.50

Tested by

no test coverage detected