( log: LogOption, targetSessionId: SessionId, )
| 241 | * and forked sessions from clobbering each other's plan files. |
| 242 | */ |
| 243 | export 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 |
no test coverage detected