elliot-stack 1.0.38 β†’ 1.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/package.json +1 -1
  2. package/skills/estack-migrate-claude-session-history/SKILL.md +3 -2
  3. package/skills/estack-migrate-claude-session-history/scripts/__pycache__/validate-migration.cpython-313.pyc +0 -0
  4. package/skills/estack-read-claude-session-history/SKILL.md +30 -4
  5. package/skills/estack-read-claude-session-history/references/modes.md +65 -9
  6. package/skills/estack-read-claude-session-history/references/recipes.md +7 -1
  7. package/skills/estack-read-claude-session-history/scripts/__pycache__/read_transcript.cpython-313.pyc +0 -0
  8. package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/__init__.cpython-313.pyc +0 -0
  9. package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/parser.cpython-313.pyc +0 -0
  10. package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/paths.cpython-313.pyc +0 -0
  11. package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/search.cpython-313.pyc +0 -0
  12. package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/subagents.cpython-313.pyc +0 -0
  13. package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/tools.cpython-313.pyc +0 -0
  14. package/skills/estack-read-claude-session-history/scripts/lib/parser.py +2 -1
  15. package/skills/estack-read-claude-session-history/scripts/lib/search.py +27 -9
  16. package/skills/estack-read-claude-session-history/scripts/read_transcript.py +267 -84
  17. package/skills/estack-migrate-claude-session-history/scripts/test-append-note.js +0 -48
  18. package/skills/estack-migrate-claude-session-history/scripts/test-validate-migration.py +0 -326
  19. package/skills/estack-read-claude-session-history/scripts/tests/conftest.py +0 -40
  20. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/README.md +0 -20
  21. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/all-noise.jsonl +0 -4
  22. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/basic-session.jsonl +0 -2
  23. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-gaps.jsonl +0 -9
  24. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-noise.jsonl +0 -7
  25. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-parallel-a.jsonl +0 -3
  26. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-parallel-b.jsonl +0 -3
  27. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-waiting.jsonl +0 -5
  28. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/interrupted.jsonl +0 -2
  29. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/multi-compact.jsonl +0 -8
  30. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/pending-user.jsonl +0 -2
  31. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-no-meta/subagents/agent-aaa.jsonl +0 -2
  32. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-no-meta.jsonl +0 -2
  33. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent/subagents/agent-xyz123.jsonl +0 -2
  34. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent/subagents/agent-xyz123.meta.json +0 -1
  35. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent.jsonl +0 -4
  36. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/time-spread.jsonl +0 -6
  37. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/timeline-day-test.jsonl +0 -5
  38. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/tool-usage-parent/subagents/agent-sub1.jsonl +0 -3
  39. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/tool-usage-parent.jsonl +0 -3
  40. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/tool-zoo.jsonl +0 -10
  41. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/truncated.jsonl +0 -3
  42. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/unicode.jsonl +0 -2
  43. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-advisor.jsonl +0 -3
  44. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-compact.jsonl +0 -5
  45. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-thinking.jsonl +0 -2
  46. package/skills/estack-read-claude-session-history/scripts/tests/test_backup_roots.py +0 -56
  47. package/skills/estack-read-claude-session-history/scripts/tests/test_engagement.py +0 -239
  48. package/skills/estack-read-claude-session-history/scripts/tests/test_json_format.py +0 -201
  49. package/skills/estack-read-claude-session-history/scripts/tests/test_modes.py +0 -323
  50. package/skills/estack-read-claude-session-history/scripts/tests/test_parser.py +0 -195
  51. package/skills/estack-read-claude-session-history/scripts/tests/test_paths.py +0 -133
  52. package/skills/estack-read-claude-session-history/scripts/tests/test_search.py +0 -78
  53. package/skills/estack-read-claude-session-history/scripts/tests/test_subagents.py +0 -43
  54. package/skills/estack-read-claude-session-history/scripts/tests/test_timeline.py +0 -179
  55. package/skills/estack-read-claude-session-history/scripts/tests/test_timezone_and_project.py +0 -212
  56. package/skills/estack-read-claude-session-history/scripts/tests/test_tools.py +0 -80
@@ -1,326 +0,0 @@
1
- """Self-test for validate-migration.py.
2
-
3
- Builds synthetic transcripts with known defects, runs each check against
4
- them, and confirms each check catches what it's supposed to catch (and
5
- doesn't false-positive on clean inputs).
6
-
7
- Run from the skill's scripts/ directory:
8
- python test-validate-migration.py
9
-
10
- Exit 0 on full pass, 1 if any case fails.
11
- """
12
-
13
- from __future__ import annotations
14
-
15
- import importlib.util
16
- import json
17
- import os
18
- import shutil
19
- import sys
20
- import tempfile
21
- from pathlib import Path
22
-
23
- # Import validate-migration.py despite the hyphen in the filename.
24
- SCRIPT_DIR = Path(__file__).parent
25
- spec = importlib.util.spec_from_file_location(
26
- "validate_migration",
27
- SCRIPT_DIR / "validate-migration.py",
28
- )
29
- vm = importlib.util.module_from_spec(spec)
30
- assert spec.loader is not None
31
- # Register before exec so @dataclass can resolve the module via sys.modules (Python 3.13+).
32
- sys.modules["validate_migration"] = vm
33
- spec.loader.exec_module(vm)
34
-
35
-
36
- SESSION_ID = "11111111-2222-3333-4444-555555555555"
37
- OLD_REPO = r"C:\fake\old"
38
- NEW_REPO = r"C:\fake\new"
39
- NEW_REPO_SUBDIR = r"C:\fake\old\subproject" # for prefix-containment tests
40
-
41
-
42
- def make_clean_entries(
43
- session_id: str = SESSION_ID,
44
- new_cwd: str = NEW_REPO,
45
- with_migration_note: bool = True,
46
- ) -> list[dict]:
47
- entries = [
48
- {
49
- "type": "permission-mode",
50
- "permissionMode": "default",
51
- "sessionId": session_id,
52
- },
53
- {
54
- "type": "user",
55
- "message": {"role": "user", "content": "Hello"},
56
- "uuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
57
- "parentUuid": None,
58
- "sessionId": session_id,
59
- "cwd": new_cwd,
60
- "timestamp": "2026-01-01T00:00:00.000Z",
61
- },
62
- {
63
- "type": "assistant",
64
- "message": {"role": "assistant", "content": "Hi back"},
65
- "uuid": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
66
- "parentUuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
67
- "sessionId": session_id,
68
- "cwd": new_cwd,
69
- "timestamp": "2026-01-01T00:00:01.000Z",
70
- },
71
- ]
72
- if with_migration_note:
73
- entries.append({
74
- "type": "user",
75
- "message": {
76
- "role": "user",
77
- "content": "<session-migration-note>\nMigrated from x to y.\n</session-migration-note>",
78
- },
79
- "uuid": "cccccccc-cccc-cccc-cccc-cccccccccccc",
80
- "parentUuid": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
81
- "sessionId": session_id,
82
- "cwd": new_cwd,
83
- "timestamp": "2026-01-01T00:00:02.000Z",
84
- })
85
- return entries
86
-
87
-
88
- def write_jsonl(path: Path, entries: list[dict], raw_lines: list[str] | None = None) -> None:
89
- if raw_lines is not None:
90
- path.write_text("\n".join(raw_lines) + "\n", encoding="utf-8")
91
- else:
92
- path.write_text(
93
- "\n".join(json.dumps(e) for e in entries) + "\n",
94
- encoding="utf-8",
95
- )
96
-
97
-
98
- # Track results
99
- results: list[tuple[str, bool, str]] = []
100
-
101
-
102
- def record(test_name: str, expected_pass: bool, result_obj, *, expect_detail_contains: str | None = None) -> None:
103
- matches_expected = result_obj.passed == expected_pass
104
- detail_ok = True
105
- if expect_detail_contains and not matches_expected:
106
- # If the check unexpectedly went the wrong way, don't penalize detail.
107
- pass
108
- elif expect_detail_contains:
109
- detail_ok = expect_detail_contains.lower() in result_obj.detail.lower()
110
- ok = matches_expected and detail_ok
111
- results.append((test_name, ok, result_obj.detail))
112
- label = "PASS" if ok else "FAIL"
113
- expected = "should PASS" if expected_pass else "should FAIL"
114
- print(f"[{label}] {test_name:<60s} ({expected}; got {'PASS' if result_obj.passed else 'FAIL'}) {result_obj.detail}")
115
-
116
-
117
- def main() -> int:
118
- with tempfile.TemporaryDirectory() as tmp_str:
119
- tmp = Path(tmp_str)
120
-
121
- # --- HAPPY PATH: a clean synthetic transcript ---
122
- clean_entries = make_clean_entries()
123
- clean_file = tmp / f"{SESSION_ID}.jsonl"
124
- write_jsonl(clean_file, clean_entries)
125
-
126
- print("\n--- Happy path: all checks should PASS ---")
127
- record("happy.parse_integrity", True, vm.check_parse_integrity(clean_file))
128
- record("happy.schema", True, vm.check_schema(clean_entries))
129
- record("happy.session_id", True, vm.check_session_id_consistency(clean_entries, SESSION_ID))
130
- record("happy.parent_chain", True, vm.check_parent_uuid_chains(clean_entries))
131
- record("happy.cwd", True, vm.check_cwd_consistency(clean_entries, NEW_REPO))
132
- record("happy.migration_note", True, vm.check_migration_note(clean_entries))
133
- record("happy.stale_refs", True, vm.check_stale_path_references(clean_entries, OLD_REPO, NEW_REPO))
134
- record("happy.sidecar", True, vm.check_sidecar_integrity(clean_file, SESSION_ID))
135
-
136
- # --- Failure cases: one per check ---
137
- print("\n--- Failure cases: each should be detected ---")
138
-
139
- # 1. Malformed JSON line
140
- bad_parse_file = tmp / "bad_parse.jsonl"
141
- write_jsonl(
142
- bad_parse_file,
143
- [],
144
- raw_lines=[json.dumps(clean_entries[0]), "{not valid json", json.dumps(clean_entries[1])],
145
- )
146
- record("fail.parse_integrity", False, vm.check_parse_integrity(bad_parse_file))
147
-
148
- # 2. Schema violation: user entry with malformed message
149
- bad_schema = list(clean_entries)
150
- bad_schema[1] = {**clean_entries[1], "message": "not-a-dict"}
151
- record("fail.schema (bad message)", False, vm.check_schema(bad_schema))
152
-
153
- # 3. Schema violation: bad uuid format
154
- bad_uuid = list(clean_entries)
155
- bad_uuid[1] = {**clean_entries[1], "uuid": "not-a-uuid"}
156
- record("fail.schema (bad uuid)", False, vm.check_schema(bad_uuid))
157
-
158
- # 4. SessionId inconsistency
159
- mixed_sids = list(clean_entries)
160
- mixed_sids[2] = {**clean_entries[2], "sessionId": "00000000-0000-0000-0000-000000000000"}
161
- record("fail.session_id (mixed sids)", False, vm.check_session_id_consistency(mixed_sids, SESSION_ID))
162
-
163
- # 5. Broken parent uuid chain
164
- broken_parent = list(clean_entries)
165
- broken_parent[2] = {**clean_entries[2], "parentUuid": "99999999-9999-9999-9999-999999999999"}
166
- record("fail.parent_chain (orphan parent)", False, vm.check_parent_uuid_chains(broken_parent))
167
-
168
- # 6. Multiple distinct cwd values
169
- mixed_cwd = list(clean_entries)
170
- mixed_cwd[2] = {**clean_entries[2], "cwd": r"C:\different\cwd"}
171
- record("fail.cwd (multiple distinct)", False, vm.check_cwd_consistency(mixed_cwd, NEW_REPO))
172
-
173
- # 7. Cwd doesn't match expected new_repo
174
- wrong_new_cwd = make_clean_entries(new_cwd=r"C:\unexpected\path")
175
- record("fail.cwd (wrong new_repo)", False, vm.check_cwd_consistency(wrong_new_cwd, NEW_REPO))
176
-
177
- # 8. No migration note
178
- no_note = make_clean_entries(with_migration_note=False)
179
- record("fail.migration_note (missing)", False, vm.check_migration_note(no_note))
180
-
181
- # 9. Multiple migration notes (duplicate append)
182
- dup_note = list(clean_entries) + [{
183
- "type": "user",
184
- "message": {"role": "user", "content": "<session-migration-note>\nduplicate\n</session-migration-note>"},
185
- "uuid": "dddddddd-dddd-dddd-dddd-dddddddddddd",
186
- "parentUuid": "cccccccc-cccc-cccc-cccc-cccccccccccc",
187
- "sessionId": SESSION_ID,
188
- "cwd": NEW_REPO,
189
- "timestamp": "2026-01-01T00:00:03.000Z",
190
- }]
191
- record("fail.migration_note (duplicate)", False, vm.check_migration_note(dup_note))
192
-
193
- # 10. Migration note with isMeta=True (should be regular user message)
194
- meta_note = make_clean_entries(with_migration_note=False) + [{
195
- "type": "user",
196
- "message": {"role": "user", "content": "<session-migration-note>\nmeta version\n</session-migration-note>"},
197
- "isMeta": True,
198
- "uuid": "eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee",
199
- "parentUuid": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
200
- "sessionId": SESSION_ID,
201
- "cwd": NEW_REPO,
202
- }]
203
- record("fail.migration_note (isMeta=true)", False, vm.check_migration_note(meta_note))
204
-
205
- # 11. Truly-stale old path in pre-note entry (unrelated old vs new)
206
- stale_entries = make_clean_entries(new_cwd=NEW_REPO)
207
- stale_entries[1] = {
208
- **stale_entries[1],
209
- "message": {
210
- "role": "user",
211
- "content": f"Check the file at {OLD_REPO}\\stuff.txt please",
212
- },
213
- }
214
- record("fail.stale_refs (unrelated paths)", False, vm.check_stale_path_references(stale_entries, OLD_REPO, NEW_REPO))
215
-
216
- # 12. Prefix-containment false-positive shouldn't trigger
217
- # When new_repo is a subdir of old_repo, references to old-path-as-prefix-of-new-path are NOT stale.
218
- prefix_clean = make_clean_entries(new_cwd=NEW_REPO_SUBDIR)
219
- record(
220
- "happy.stale_refs (subdir new path, no actual stale refs)",
221
- True,
222
- vm.check_stale_path_references(prefix_clean, OLD_REPO, NEW_REPO_SUBDIR),
223
- )
224
-
225
- # 13. Post-note stale refs should NOT trigger (out of scope)
226
- post_note_stale = list(clean_entries) + [{
227
- "type": "tool_result",
228
- "uuid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
229
- "parentUuid": "cccccccc-cccc-cccc-cccc-cccccccccccc",
230
- "sessionId": SESSION_ID,
231
- "cwd": NEW_REPO,
232
- "message": {
233
- "role": "user",
234
- "content": f"Tool output mentioning {OLD_REPO}\\somefile.txt β€” but this is AFTER migration",
235
- },
236
- }]
237
- record(
238
- "happy.stale_refs (post-note refs ignored)",
239
- True,
240
- vm.check_stale_path_references(post_note_stale, OLD_REPO, NEW_REPO),
241
- )
242
-
243
- # 14. Sidecar with parse error
244
- sidecar_file = tmp / SESSION_ID
245
- sidecar_file.mkdir()
246
- (sidecar_file / "agent-test.jsonl").write_text(
247
- json.dumps({"type": "user", "sessionId": SESSION_ID, "uuid": "11111111-1111-1111-1111-111111111111"}) + "\n{bad json line\n",
248
- encoding="utf-8",
249
- )
250
- record("fail.sidecar (bad parse in subagent)", False, vm.check_sidecar_integrity(clean_file, SESSION_ID))
251
-
252
- # 15. Sidecar with wrong sessionId
253
- shutil.rmtree(sidecar_file)
254
- sidecar_file.mkdir()
255
- (sidecar_file / "agent-mismatch.jsonl").write_text(
256
- json.dumps({"type": "user", "sessionId": "different-session-id", "uuid": "11111111-1111-1111-1111-111111111111"}) + "\n",
257
- encoding="utf-8",
258
- )
259
- record("fail.sidecar (wrong sessionId)", False, vm.check_sidecar_integrity(clean_file, SESSION_ID))
260
-
261
- # 16. Sidecar clean
262
- shutil.rmtree(sidecar_file)
263
- sidecar_file.mkdir()
264
- (sidecar_file / "agent-good.jsonl").write_text(
265
- json.dumps({"type": "user", "sessionId": SESSION_ID, "uuid": "11111111-1111-1111-1111-111111111111"}) + "\n",
266
- encoding="utf-8",
267
- )
268
- record("happy.sidecar (clean)", True, vm.check_sidecar_integrity(clean_file, SESSION_ID))
269
-
270
- # 17. Backup cross-validation happy path
271
- backup_file = tmp / f"backup-{SESSION_ID}.jsonl"
272
- # Source backup = clean entries WITHOUT the migration note (note is added by migration)
273
- source_entries = make_clean_entries(with_migration_note=False)
274
- write_jsonl(backup_file, source_entries)
275
- live_entries = make_clean_entries(with_migration_note=True) # = source + note
276
- # Sidecar live present + matching backup absent (skipped sub-check)
277
- result = vm.check_backup_cross_validation(
278
- migrated_entries=live_entries,
279
- source_backup_path=backup_file,
280
- sidecar_live=tmp / "no-sidecar-live", # doesn't exist; counts as 0
281
- sidecar_backup=None,
282
- target_backup_dir=None,
283
- target_live_dir=tmp,
284
- )
285
- record("happy.backup_cross_validation", True, result)
286
-
287
- # 18. Backup cross-validation: entry count mismatch
288
- truncated = make_clean_entries(with_migration_note=True)[:-2] # drop note + one entry
289
- result = vm.check_backup_cross_validation(
290
- migrated_entries=truncated,
291
- source_backup_path=backup_file,
292
- sidecar_live=tmp / "no-sidecar-live",
293
- sidecar_backup=None,
294
- target_backup_dir=None,
295
- target_live_dir=tmp,
296
- )
297
- record("fail.backup_cross_validation (entry count)", False, result)
298
-
299
- # 19. Backup cross-validation: uuid order broken
300
- reordered = list(live_entries)
301
- reordered[1], reordered[2] = reordered[2], reordered[1]
302
- result = vm.check_backup_cross_validation(
303
- migrated_entries=reordered,
304
- source_backup_path=backup_file,
305
- sidecar_live=tmp / "no-sidecar-live",
306
- sidecar_backup=None,
307
- target_backup_dir=None,
308
- target_live_dir=tmp,
309
- )
310
- record("fail.backup_cross_validation (uuid order)", False, result)
311
-
312
- # --- Summary ---
313
- passed = sum(1 for _, ok, _ in results if ok)
314
- total = len(results)
315
- print(f"\n=== test-validate-migration: {passed}/{total} cases passed ===")
316
- if passed != total:
317
- print("\nFailing cases:")
318
- for name, ok, detail in results:
319
- if not ok:
320
- print(f" - {name}: {detail}")
321
- return 1
322
- return 0
323
-
324
-
325
- if __name__ == "__main__":
326
- sys.exit(main())
@@ -1,40 +0,0 @@
1
- """Shared pytest fixtures and import-path setup."""
2
-
3
- from __future__ import annotations
4
-
5
- import sys
6
- from pathlib import Path
7
-
8
- import pytest
9
-
10
-
11
- # Ensure UTF-8 output regardless of console code page (Windows)
12
- if sys.stdout.encoding and sys.stdout.encoding.lower() != "utf-8":
13
- try:
14
- sys.stdout.reconfigure(encoding="utf-8", errors="replace")
15
- except (AttributeError, OSError):
16
- pass
17
-
18
-
19
- THIS_DIR = Path(__file__).resolve().parent
20
- SCRIPTS_DIR = THIS_DIR.parent
21
- FIXTURES_DIR = THIS_DIR / "fixtures"
22
-
23
- # Make `from lib...` work in tests
24
- if str(SCRIPTS_DIR) not in sys.path:
25
- sys.path.insert(0, str(SCRIPTS_DIR))
26
-
27
-
28
- @pytest.fixture
29
- def fixtures_dir() -> Path:
30
- return FIXTURES_DIR
31
-
32
-
33
- @pytest.fixture
34
- def scripts_dir() -> Path:
35
- return SCRIPTS_DIR
36
-
37
-
38
- @pytest.fixture
39
- def cli_path() -> Path:
40
- return SCRIPTS_DIR / "read_transcript.py"
@@ -1,20 +0,0 @@
1
- # Test fixtures
2
-
3
- Hand-crafted minimal JSONL files, one scenario per file. Keep them small (≀50 lines) β€” they're easier to reason about than real session snapshots and don't carry PII.
4
-
5
- | File | Purpose |
6
- |---|---|
7
- | `basic-session.jsonl` | One user + one assistant exchange. Sanity check for the parser. |
8
- | `with-compact.jsonl` | Conversation interrupted by a single `/compact` marker. |
9
- | `multi-compact.jsonl` | Two `/compact` markers β€” exercises "most recent" logic. |
10
- | `with-advisor.jsonl` | Contains an `advisor_tool_result` block. |
11
- | `with-thinking.jsonl` | Contains a `thinking` block plus normal text. |
12
- | `all-noise.jsonl` | Only `ai-title` + `attachment` entries β€” should look empty to signal queries. |
13
- | `subagent-parent.jsonl` | Parent session that spawns one subagent via the `Agent` tool. |
14
- | `subagent-no-meta.jsonl` | Parent session with a sibling subagent file but no `.meta.json` sidecar β€” `load_meta` must fall back. |
15
- | `tool-zoo.jsonl` | One call to each of Bash, Read, Edit, Write, Agent, Skill, Glob, Grep. |
16
- | `time-spread.jsonl` | Six messages over a known time range β€” exercises `--since`/`--until`. |
17
- | `truncated.jsonl` | Final line is missing its newline AND is malformed JSON β€” should be dropped silently. |
18
- | `unicode.jsonl` | Contains emoji + CJK characters β€” exercises UTF-8 decoding. |
19
- | `pending-user.jsonl` | Last assistant message ends with `?` β€” `infer_status` should return `pending-user`. |
20
- | `interrupted.jsonl` | Final assistant message has a `tool_use` block with no matching `tool_result` β€” status `interrupted`. |
@@ -1,4 +0,0 @@
1
- {"type":"ai-title","aiTitle":"Test session"}
2
- {"type":"attachment","data":{"path":"foo.png"}}
3
- {"type":"permission-mode","mode":"plan"}
4
- {"type":"file-history-snapshot","content":{"file":"bar.py"}}
@@ -1,2 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Hello Claude"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"Hi there. Here is help."}]}}
@@ -1,9 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Start the analysis"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:01:00Z","message":{"role":"assistant","content":[{"type":"text","text":"On it."}]}}
3
- {"type":"user","timestamp":"2026-05-01T10:05:00Z","message":{"role":"user","content":"Looks good, continue"}}
4
- {"type":"assistant","timestamp":"2026-05-01T10:06:00Z","message":{"role":"assistant","content":[{"type":"text","text":"Done with phase 1."}]}}
5
- {"type":"user","timestamp":"2026-05-01T10:08:00Z","message":{"role":"user","content":"Next phase"}}
6
- {"type":"assistant","timestamp":"2026-05-01T10:09:00Z","message":{"role":"assistant","content":[{"type":"text","text":"Phase 2 complete."}]}}
7
- {"type":"user","timestamp":"2026-05-01T10:40:00Z","message":{"role":"user","content":"Back from a break, keep going"}}
8
- {"type":"assistant","timestamp":"2026-05-01T10:41:00Z","message":{"role":"assistant","content":[{"type":"text","text":"Resumed."}]}}
9
- {"type":"user","timestamp":"2026-05-01T10:45:00Z","message":{"role":"user","content":"Wrap it up"}}
@@ -1,7 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T09:00:00Z","isMeta":true,"message":{"role":"user","content":[{"type":"text","text":"SessionStart hook output β€” not a human action"}]}}
2
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"This session is being continued from a previous conversation. Summary: we were doing things."}}
3
- {"type":"user","timestamp":"2026-05-01T10:01:00Z","message":{"role":"user","content":"Real prompt one"}}
4
- {"type":"assistant","timestamp":"2026-05-01T10:02:00Z","message":{"role":"assistant","content":[{"type":"tool_use","name":"Read","input":{"file_path":"x"},"id":"t9"}]}}
5
- {"type":"user","timestamp":"2026-05-01T10:03:00Z","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"t9","content":"file contents"}]}}
6
- {"type":"user","timestamp":"2026-05-01T10:05:00Z","isMeta":true,"message":{"role":"user","content":[{"type":"text","text":"Skill expansion injected text"}]}}
7
- {"type":"user","timestamp":"2026-05-01T10:06:00Z","message":{"role":"user","content":"Real prompt two"}}
@@ -1,3 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Chat A start"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:01:00Z","message":{"role":"assistant","content":[{"type":"text","text":"Working in A."}]}}
3
- {"type":"user","timestamp":"2026-05-01T10:30:00Z","message":{"role":"user","content":"Chat A follow-up"}}
@@ -1,3 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:10:00Z","message":{"role":"user","content":"Chat B start"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:11:00Z","message":{"role":"assistant","content":[{"type":"text","text":"Working in B."}]}}
3
- {"type":"user","timestamp":"2026-05-01T10:20:00Z","message":{"role":"user","content":"Chat B follow-up"}}
@@ -1,5 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Run the long migration"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:02:00Z","message":{"role":"assistant","content":[{"type":"tool_use","name":"Bash","input":{"command":"migrate"},"id":"t1"}]}}
3
- {"type":"user","timestamp":"2026-05-01T10:15:00Z","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"t1","content":"step 1 done"}]}}
4
- {"type":"assistant","timestamp":"2026-05-01T10:30:00Z","message":{"role":"assistant","content":[{"type":"text","text":"Migration finished."}]}}
5
- {"type":"user","timestamp":"2026-05-01T10:32:00Z","message":{"role":"user","content":"Great, now verify it"}}
@@ -1,2 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Run a tool"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"Running."},{"type":"tool_use","id":"toolu_999","name":"Bash","input":{"command":"sleep 999"}}]}}
@@ -1,8 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"First"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"R1"}]}}
3
- {"type":"user","timestamp":"2026-05-01T10:30:00Z","message":{"role":"user","content":"This session is being continued from a previous conversation. Round 1"}}
4
- {"type":"user","timestamp":"2026-05-01T11:00:00Z","message":{"role":"user","content":"Mid"}}
5
- {"type":"assistant","timestamp":"2026-05-01T11:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"R2"}]}}
6
- {"type":"user","timestamp":"2026-05-01T11:30:00Z","message":{"role":"user","content":"This session is being continued from a previous conversation. Round 2"}}
7
- {"type":"user","timestamp":"2026-05-01T12:00:00Z","message":{"role":"user","content":"Last"}}
8
- {"type":"assistant","timestamp":"2026-05-01T12:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"R3"}]}}
@@ -1,2 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Hello"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"Sure, do you want me to A, B, or C?"}]}}
@@ -1,2 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:10Z","message":{"role":"user","content":"Do thing"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:20Z","message":{"role":"assistant","content":[{"type":"text","text":"Done."}]}}
@@ -1,2 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Run an agent"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"Agent ran."}]}}
@@ -1,2 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:10Z","message":{"role":"user","content":"Find the bug in foo.py"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:20Z","message":{"role":"assistant","content":[{"type":"text","text":"Found it: foo.py line 42 β€” off-by-one in loop bound."}]}}
@@ -1 +0,0 @@
1
- {"agentType": "Explore", "description": "Find the bug in foo.py"}
@@ -1,4 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Investigate the bug"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"toolu_01abc","name":"Agent","input":{"description":"Find the bug","prompt":"Look at file X","subagent_type":"Explore"}}]}}
3
- {"type":"user","timestamp":"2026-05-01T10:00:30Z","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_01abc","content":"Found it in foo.py:42"}]}}
4
- {"type":"assistant","timestamp":"2026-05-01T10:00:35Z","message":{"role":"assistant","content":[{"type":"text","text":"Got the report, patching foo.py."}]}}
@@ -1,6 +0,0 @@
1
- {"type":"user","timestamp":"2026-04-15T08:00:00Z","message":{"role":"user","content":"Apr 15 morning"}}
2
- {"type":"assistant","timestamp":"2026-04-15T08:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"Apr 15 reply"}]}}
3
- {"type":"user","timestamp":"2026-05-01T12:00:00Z","message":{"role":"user","content":"May 1 noon"}}
4
- {"type":"assistant","timestamp":"2026-05-01T12:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"May 1 reply"}]}}
5
- {"type":"user","timestamp":"2026-05-15T20:00:00Z","message":{"role":"user","content":"May 15 evening"}}
6
- {"type":"assistant","timestamp":"2026-05-15T20:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"May 15 reply"}]}}
@@ -1,5 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Start the CRM cleanup"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:05:00Z","message":{"role":"assistant","content":[{"type":"text","text":"Working on it."}]}}
3
- {"type":"assistant","timestamp":"2026-05-01T10:08:00Z","message":{"role":"assistant","content":[{"type":"text","text":"First pass done."}]}}
4
- {"type":"user","timestamp":"2026-05-01T12:00:00Z","message":{"role":"user","content":"Back β€” continue"}}
5
- {"type":"assistant","timestamp":"2026-05-01T12:02:00Z","message":{"role":"assistant","content":[{"type":"text","text":"Resumed and finished."}]}}
@@ -1,3 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:03Z","message":{"role":"user","content":"sub task"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:04Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"s1","name":"Skill","input":{"skill":"estack-repo-search"}}]}}
3
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"s2","name":"Bash","input":{"command":"ls"}}]}}
@@ -1,3 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"do it"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:01Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"p1","name":"Skill","input":{"skill":"commit"}}]}}
3
- {"type":"assistant","timestamp":"2026-05-01T10:00:02Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"p2","name":"Agent","input":{"description":"sub","subagent_type":"Explore"}}]}}
@@ -1,10 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Run all the tools"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:01Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"t1","name":"Bash","input":{"command":"ls -la /tmp"}}]}}
3
- {"type":"assistant","timestamp":"2026-05-01T10:00:02Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"t2","name":"PowerShell","input":{"command":"Get-ChildItem"}}]}}
4
- {"type":"assistant","timestamp":"2026-05-01T10:00:03Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"t3","name":"Read","input":{"file_path":"C:\\foo.py","offset":1,"limit":50}}]}}
5
- {"type":"assistant","timestamp":"2026-05-01T10:00:04Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"t4","name":"Edit","input":{"file_path":"C:\\foo.py","old_string":"a","new_string":"b"}}]}}
6
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"t5","name":"Write","input":{"file_path":"C:\\bar.py","content":"print('hi')"}}]}}
7
- {"type":"assistant","timestamp":"2026-05-01T10:00:06Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"t6","name":"Agent","input":{"description":"Find X","subagent_type":"Explore"}}]}}
8
- {"type":"assistant","timestamp":"2026-05-01T10:00:07Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"t7","name":"Skill","input":{"skill":"using-superpowers"}}]}}
9
- {"type":"assistant","timestamp":"2026-05-01T10:00:08Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"t8","name":"Glob","input":{"pattern":"**/*.py"}}]}}
10
- {"type":"assistant","timestamp":"2026-05-01T10:00:09Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"t9","name":"Grep","input":{"pattern":"TODO"}}]}}
@@ -1,3 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Valid line"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"Valid reply"}]}}
3
- {"type":"user","timestamp":"2026-05-01T10:01:00Z","message":{"role":"user","content":"Trunc
@@ -1,2 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Hello 🌍, δ½ ε₯½"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"ΠŸΡ€ΠΈΠ²Π΅Ρ‚ β€” μ•ˆλ…•ν•˜μ„Έμš”!"}]}}
@@ -1,3 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Get advice"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"Calling advisor..."},{"type":"advisor_tool_result","content":{"text":"The advisor says do X then Y."}}]}}
3
- {"type":"assistant","timestamp":"2026-05-01T10:00:10Z","message":{"role":"assistant","content":[{"type":"text","text":"OK, doing X."}]}}
@@ -1,5 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"First question"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"First answer"}]}}
3
- {"type":"user","timestamp":"2026-05-01T11:00:00Z","message":{"role":"user","content":"This session is being continued from a previous conversation. Summary follows..."}}
4
- {"type":"user","timestamp":"2026-05-01T11:00:10Z","message":{"role":"user","content":"After compact"}}
5
- {"type":"assistant","timestamp":"2026-05-01T11:00:15Z","message":{"role":"assistant","content":[{"type":"text","text":"Post-compact reply"}]}}
@@ -1,2 +0,0 @@
1
- {"type":"user","timestamp":"2026-05-01T10:00:00Z","message":{"role":"user","content":"Solve this"}}
2
- {"type":"assistant","timestamp":"2026-05-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"thinking","thinking":"Let me think step by step..."},{"type":"text","text":"The answer is 42."}]}}
@@ -1,56 +0,0 @@
1
- """Tests for backup-root resolution (--root mirror|snapshot-*|<abs-path>)."""
2
-
3
- from pathlib import Path
4
-
5
- import pytest
6
-
7
- from lib import paths as P
8
-
9
-
10
- def test_root_live_default():
11
- assert P.resolve_root(None) == P.DEFAULT_LIVE_PROJECTS
12
- assert P.resolve_root("live") == P.DEFAULT_LIVE_PROJECTS
13
-
14
-
15
- def test_root_mirror_path_shape():
16
- r = P.resolve_root("mirror")
17
- parts = r.parts
18
- assert ".claude-backups" in parts
19
- assert "mirror" in parts
20
- assert parts[-1] == "projects"
21
-
22
-
23
- def test_root_snapshot_24h_path_shape():
24
- r = P.resolve_root("snapshot-24h")
25
- assert "snapshot-24h" in r.parts
26
- assert r.name == "projects"
27
-
28
-
29
- def test_root_all_known():
30
- for name in ("mirror", "snapshot-24h", "snapshot-1w", "snapshot-1mo"):
31
- r = P.resolve_root(name)
32
- assert name in r.parts
33
-
34
-
35
- def test_root_absolute_path(tmp_path: Path):
36
- fake = tmp_path / "weird-root"
37
- fake.mkdir()
38
- assert P.resolve_root(str(fake)) == fake
39
-
40
-
41
- def test_root_unknown_relative_raises():
42
- with pytest.raises(ValueError):
43
- P.resolve_root("bogus")
44
-
45
-
46
- def test_find_project_dir_uses_root(tmp_path: Path):
47
- # Build a fake root with a fake project dir
48
- proj = tmp_path / "C--Users-foo-bar"
49
- proj.mkdir()
50
- found = P.find_project_dir("C:\\Users\\foo\\bar", root=tmp_path)
51
- assert found == proj
52
-
53
-
54
- def test_find_project_dir_not_found(tmp_path: Path):
55
- with pytest.raises(FileNotFoundError):
56
- P.find_project_dir("C:\\does\\not\\exist", root=tmp_path)