Classify a `.jsonl` file under `projects/` into transcript metadata.
(path: &Path, projects_dir: &Path)
| 83 | |
| 84 | /// Classify a `.jsonl` file under `projects/` into transcript metadata. |
| 85 | fn classify_project_file(path: &Path, projects_dir: &Path) -> Option<TranscriptFile> { |
| 86 | let rel = path.strip_prefix(projects_dir).ok()?; |
| 87 | let components: Vec<&str> = rel |
| 88 | .components() |
| 89 | .filter_map(|c| c.as_os_str().to_str()) |
| 90 | .collect(); |
| 91 | |
| 92 | let source_file = file_name_string(path); |
| 93 | let stem = path.file_stem().and_then(|s| s.to_str())?.to_string(); |
| 94 | |
| 95 | match components.as_slice() { |
| 96 | // <slug>/<sessionId>.jsonl |
| 97 | [slug, _file] => Some(TranscriptFile { |
| 98 | path: path.to_path_buf(), |
| 99 | source_file, |
| 100 | session_id: stem, |
| 101 | project: Some(slug.to_string()), |
| 102 | agent_id: None, |
| 103 | }), |
| 104 | // <slug>/<sessionId>/subagents/agent-<id>.jsonl |
| 105 | [slug, session_id, "subagents", _file] => Some(TranscriptFile { |
| 106 | path: path.to_path_buf(), |
| 107 | source_file, |
| 108 | session_id: session_id.to_string(), |
| 109 | project: Some(slug.to_string()), |
| 110 | agent_id: Some(stem), |
| 111 | }), |
| 112 | _ => None, |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /// Flattened `model` / `usage_*` column values for an assistant transcript |
| 117 | /// record, extracted from `message.model` and `message.usage.*`. |
no test coverage detected