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

Function copyPlanForFork

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

Source from the content-addressed store, hash-verified

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