copyPlanForFork method

Future<bool> copyPlanForFork({
  1. required LogOption log,
  2. required String targetSessionId,
})

Copy a plan file for a forked session.

Unlike copyPlanForResume (which reuses the original slug), this generates a NEW slug for the forked session and writes the original plan content to the new file.

Implementation

Future<bool> copyPlanForFork({
  required LogOption log,
  required String targetSessionId,
}) async {
  final originalSlug = _getSlugFromLog(log);
  if (originalSlug == null) return false;

  final originalPlanPath = '$plansDirectory/$originalSlug.md';
  final newSlug = getPlanSlug(targetSessionId);
  final newPlanPath = '$plansDirectory/$newSlug.md';

  try {
    await File(originalPlanPath).copy(newPlanPath);
    return true;
  } on FileSystemException {
    return false;
  }
}