1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
use crateTimeRange;
use Result;
use ;
use WalkDir;
/// Information about a file found during directory traversal
/// Process directory and collect files with their modification dates
///
/// # Arguments
/// * `dir` - Directory to process
/// * `filter_fn` - Function to determine if a file should be included
/// * `time_range` - Time range filter to apply
///
/// Returns a vector of FileInfo structs for matching files
/// Same as [`collect_files_with_dates`] but with an optional traversal depth cap.
///
/// `max_depth` is counted from the root directory: `None` walks the whole
/// tree, `Some(2)` only descends two levels. Callers that know the exact
/// nesting of the file they want (e.g. Copilot's
/// `session-state/<sessionId>/events.jsonl` is always at depth 2) can use
/// this to avoid paying the cost of `WalkDir` visiting large sibling
/// subtrees such as `rewind-snapshots/backups/` that never contain a
/// match but can hold hundreds of files per session.
/// Maximum traversal depth for Copilot CLI session scans.
///
/// Copilot writes `~/.copilot/session-state/<sessionId>/events.jsonl`, so
/// the event log is always exactly two directory levels below
/// `session-state/`. Anything deeper belongs to companion subtrees we
/// intentionally ignore (`rewind-snapshots/backups/`, `checkpoints/`,
/// `files/`, `research/`) — some of which can hold dozens of files per
/// session and would otherwise make `WalkDir` visit hundreds of entries
/// per session just to have `is_copilot_session_file` reject them.
pub const COPILOT_SESSION_MAX_DEPTH: usize = 2;
/// Filter for Codex session files under `~/.codex/sessions/YYYY/MM/DD/`.
///
/// Codex writes `rollout-*.jsonl` files directly into the dated sub-folders.
/// We also accept `.json` defensively in case an older dump ever gets dropped
/// into the tree, but reject Claude Code's `*.meta.json` / `*.meta.jsonl`
/// subagent sidecar files (those live under `~/.claude/projects/` in
/// practice, but the filter still guards against the unlikely collision).
///
/// Intentionally separated from the other per-provider filters
/// (`is_claude_session_file`, `is_copilot_session_file`,
/// `is_gemini_session_file`) even though the body is currently trivial:
/// keeping one filter per provider means future format changes on one
/// provider do not require teasing apart a shared implementation.
/// Filter for Claude Code session files (`.jsonl` only)
///
/// Matches both top-level sessions (`~/.claude/projects/<project>/<session>.jsonl`)
/// and subagent sessions (`~/.claude/projects/<project>/<session>/subagents/agent-*.jsonl`).
/// Rejects meta sidecars (`*.meta.json` / `*.meta.jsonl`) and any non-JSONL artifact
/// that ends up under the projects directory (e.g. screenshots pasted into prompts).
/// Filter for Gemini CLI session files
///
/// Current Gemini CLI stores each chat as a line-delimited event stream at
/// `~/.gemini/tmp/<project>/chats/session-*.jsonl`. Only `.jsonl` files
/// directly under a `chats/` directory are accepted — sibling artifacts
/// (`discordbot/logs.json`, the `bin/rg` binary, `.project_root`) are
/// rejected by the parent-directory check.
///
/// Legacy single-object exports (`chats/<session>.json`) are intentionally
/// not matched: the JSONL format is the only shape the analyzer understands
/// today, and silently scanning `.json` files we can no longer parse just
/// yields `Warning: Failed to analyze ...` noise on every run.
/// Filter for Copilot CLI session files
///
/// Copilot CLI stores each session as a directory under
/// `~/.copilot/session-state/<sessionId>/` containing the event log
/// (`events.jsonl`) plus sibling subdirectories for file snapshots
/// (`rewind-snapshots/`, `files/`, `research/`, `checkpoints/`) and a
/// per-workspace YAML file. Only `events.jsonl` carries the conversation
/// stream we want to analyze — if we fell back to the generic JSON filter,
/// `rewind-snapshots/index.json` would be mis-picked up as a session log
/// and fail to parse.
///
/// The historical single-file layout
/// (`~/.copilot/history-session-state/<sessionId>.json`) is not matched
/// and no longer supported by the analyzer at all.
/// Returns true if the path is a Claude Code meta sidecar file
///
/// Claude Code writes these next to subagent session logs with metadata like
/// `agentType` / `description`. Today they're `*.meta.json`; we also reject
/// `*.meta.jsonl` pre-emptively so the filter stays correct if the format
/// ever switches to line-delimited JSON.