| 631 | } |
| 632 | |
| 633 | fn cursor_subagent_paths(transcript_path: &Path, parent_session_id: &str) -> Vec<PathBuf> { |
| 634 | let mut candidates = Vec::new(); |
| 635 | if let Some(parent_dir) = transcript_path.parent() { |
| 636 | if transcript_path.file_stem().and_then(|stem| stem.to_str()) == Some(parent_session_id) { |
| 637 | candidates.push(parent_dir.join(parent_session_id).join("subagents")); |
| 638 | } |
| 639 | if parent_dir.file_name().and_then(|name| name.to_str()) == Some(parent_session_id) { |
| 640 | candidates.push(parent_dir.join("subagents")); |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | let mut paths = Vec::new(); |
| 645 | for dir in candidates { |
| 646 | let Ok(entries) = std::fs::read_dir(dir) else { |
| 647 | continue; |
| 648 | }; |
| 649 | for entry in entries.flatten() { |
| 650 | let path = entry.path(); |
| 651 | if path.extension().and_then(|ext| ext.to_str()) == Some("jsonl") { |
| 652 | paths.push(path); |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | paths.sort(); |
| 657 | paths.dedup(); |
| 658 | paths |
| 659 | } |
| 660 | |
| 661 | fn cursor_subagent_identity(path: &Path, parent_session_id: &str) -> Option<(String, String)> { |
| 662 | let is_subagent_path = path |