MCPcopy
hub / github.com/codeaashu/claude-code / copyPlanForFork

Function copyPlanForFork

src/utils/plans.ts:239–264  ·  view source on GitHub ↗
(
  log: LogOption,
  targetSessionId: SessionId,
)

Source from the content-addressed store, hash-verified

237 * and forked sessions from clobbering each other's plan files.
238 */
239export async function copyPlanForFork(
240 log: LogOption,
241 targetSessionId: SessionId,
242): Promise<boolean> {
243 const originalSlug = getSlugFromLog(log)
244 if (!originalSlug) {
245 return false
246 }
247
248 const plansDir = getPlansDirectory()
249 const originalPlanPath = join(plansDir, `${originalSlug}.md`)
250
251 // Generate a new slug for the forked session (do NOT reuse the original)
252 const newSlug = getPlanSlug(targetSessionId)
253 const newPlanPath = join(plansDir, `${newSlug}.md`)
254 try {
255 await copyFile(originalPlanPath, newPlanPath)
256 return true
257 } catch (error) {
258 if (isENOENT(error)) {
259 return false
260 }
261 logError(error)
262 return false
263 }
264}
265
266/**
267 * Recover plan content from the message history. Plan content can appear in

Callers 1

REPLFunction · 0.85

Calls 4

getSlugFromLogFunction · 0.85
getPlanSlugFunction · 0.85
isENOENTFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected