elliot-stack 1.0.29 → 1.0.33

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 (128) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +5 -0
  3. package/bin/install.cjs +981 -950
  4. package/hooks/repo-search-nudge.js +32 -32
  5. package/package.json +1 -1
  6. package/skills/estack-active-learning-tutor/SKILL.md +339 -339
  7. package/skills/estack-better-title/SKILL.md +64 -64
  8. package/skills/estack-better-title/scripts/rename.sh +55 -55
  9. package/skills/estack-chris-voss/SKILL.md +80 -80
  10. package/skills/estack-chris-voss/references/elliot-notes.md +120 -120
  11. package/skills/estack-chris-voss/references/voss-principles.md +210 -210
  12. package/skills/estack-customer-discovery/SKILL.md +60 -60
  13. package/skills/estack-flight-planner/SKILL.md +332 -332
  14. package/skills/estack-flight-planner/references/config_schema.md +156 -156
  15. package/skills/estack-flight-planner/references/flight_history_schema.md +97 -97
  16. package/skills/estack-flight-planner/references/shuttle_schedules.md +98 -98
  17. package/skills/estack-flight-planner/scripts/check_setup.sh +89 -89
  18. package/skills/estack-flight-planner/scripts/fetch_flights.py +99 -99
  19. package/skills/estack-flight-planner/scripts/filter_flights.py +265 -265
  20. package/skills/estack-flight-planner/scripts/pair_shuttles.py +173 -173
  21. package/skills/estack-github-issue-tracker/SKILL.md +322 -322
  22. package/skills/estack-github-issue-tracker/bin/tracker-tools.cjs +1358 -1358
  23. package/skills/estack-github-issue-tracker/references/gh-cli-patterns.md +124 -124
  24. package/skills/estack-github-issue-tracker/references/result-file-schema.md +156 -156
  25. package/skills/estack-github-issue-tracker/references/tracker-schema.md +96 -96
  26. package/skills/estack-github-issue-tracker/tracker-template.md +58 -58
  27. package/skills/estack-leadership-coach/SKILL.md +235 -0
  28. package/skills/estack-leadership-coach/adding-references.md +280 -0
  29. package/skills/estack-leadership-coach/frameworks/delegation/flows/post-mortem.md +120 -0
  30. package/skills/estack-leadership-coach/frameworks/delegation/flows/pre-delegation.md +138 -0
  31. package/skills/estack-leadership-coach/frameworks/delegation/phases/1-intake.md +145 -0
  32. package/skills/estack-leadership-coach/frameworks/delegation/phases/2-trm-assessment.md +119 -0
  33. package/skills/estack-leadership-coach/frameworks/delegation/phases/3-enrollment.md +132 -0
  34. package/skills/estack-leadership-coach/frameworks/delegation/phases/4-build-brief.md +171 -0
  35. package/skills/estack-leadership-coach/frameworks/delegation/phases/5-monitoring.md +134 -0
  36. package/skills/estack-leadership-coach/frameworks/delegation/phases/6-reverse-delegation.md +118 -0
  37. package/skills/estack-leadership-coach/frameworks/delegation/phases/7-diagnose.md +200 -0
  38. package/skills/estack-leadership-coach/references/.source-files/deci-ryan_self-determination-theory__deci-olafsen-ryan-2017-self-determination-theory-in-work-organizations.md +1881 -0
  39. package/skills/estack-leadership-coach/references/.source-files/deci-ryan_self-determination-theory__gagne-deci-2005-self-determination-theory-and-work-motivation.md +2058 -0
  40. package/skills/estack-leadership-coach/references/.source-files/deci-ryan_self-determination-theory__selfdeterminationtheory-org-theory-overview-page.md +61 -0
  41. package/skills/estack-leadership-coach/references/.source-files/gallup_engagement-research__gallup-3-key-insights-into-the-global-workplace-2024.md +57 -0
  42. package/skills/estack-leadership-coach/references/.source-files/gallup_engagement-research__gallup-managers-account-for-70-percent-of-variance-in-employee-engagement-2015.md +40 -0
  43. package/skills/estack-leadership-coach/references/.source-files/gallup_engagement-research__gallup-state-of-the-global-workplace-2026-global-data-summary.md +73 -0
  44. package/skills/estack-leadership-coach/references/.source-files/gallup_engagement-research__gallup-state-of-the-global-workplace-2026-report-landing.md +42 -0
  45. package/skills/estack-leadership-coach/references/.source-files/hormozi-leila_4-stages__leila-hormozi-the-art-of-delegation-blog-post.md +91 -0
  46. package/skills/estack-leadership-coach/references/.source-files/oncken-wass_monkeys-hbr-1974__oncken-wass-management-time-whos-got-the-monkey-hbr-classic-1974.md +969 -0
  47. package/skills/estack-leadership-coach/references/.source-files/sanchez_main-street-millionaire__codie-sanchez-afford-anything-podcast-ep-565-show-notes.md +89 -0
  48. package/skills/estack-leadership-coach/references/.source-files/sullivan_who-not-how__dan-sullivan-impact-filter-tool-and-guide-booklet.md +565 -0
  49. package/skills/estack-leadership-coach/references/.source-files/van-edwards_cues__vanessa-van-edwards-lewis-howes-school-of-greatness-ep-1231-show-notes.md +122 -0
  50. package/skills/estack-leadership-coach/references/.source-files/van-edwards_cues__vanessa-van-edwards-roger-dooley-cues-interview.md +194 -0
  51. package/skills/estack-leadership-coach/references/deci-ryan_self-determination-theory.md +166 -0
  52. package/skills/estack-leadership-coach/references/doerr_measure-what-matters.md +154 -0
  53. package/skills/estack-leadership-coach/references/ferriss_4hww.md +189 -0
  54. package/skills/estack-leadership-coach/references/gallup_engagement-research.md +105 -0
  55. package/skills/estack-leadership-coach/references/gerber_e-myth-revisited.md +118 -0
  56. package/skills/estack-leadership-coach/references/grove_high-output-management.md +95 -0
  57. package/skills/estack-leadership-coach/references/hormozi-alex_followthrough.md +152 -0
  58. package/skills/estack-leadership-coach/references/hormozi-leila_4-stages.md +146 -0
  59. package/skills/estack-leadership-coach/references/oncken-wass_monkeys-hbr-1974.md +128 -0
  60. package/skills/estack-leadership-coach/references/sanchez_main-street-millionaire.md +196 -0
  61. package/skills/estack-leadership-coach/references/sullivan_who-not-how.md +137 -0
  62. package/skills/estack-leadership-coach/references/van-edwards_cues.md +189 -0
  63. package/skills/estack-migrate-claude-session-history/SKILL.md +226 -0
  64. package/skills/estack-migrate-claude-session-history/references/path-encoding.md +55 -0
  65. package/skills/estack-migrate-claude-session-history/references/troubleshooting.md +96 -0
  66. package/skills/estack-migrate-claude-session-history/scripts/migrate-claude-history.js +1123 -0
  67. package/skills/estack-migrate-claude-session-history/scripts/test-append-note.js +48 -0
  68. package/skills/estack-migrate-claude-session-history/scripts/test-validate-migration.py +326 -0
  69. package/skills/estack-migrate-claude-session-history/scripts/validate-migration.py +493 -0
  70. package/skills/estack-pdf-to-md/SKILL.md +180 -0
  71. package/skills/estack-pdf-to-md/scripts/pdf_to_md.py +596 -0
  72. package/skills/estack-productivity-prioritization-coach/SKILL.md +124 -0
  73. package/skills/estack-productivity-prioritization-coach/sources/01-tony-robbins-rpm.md +39 -0
  74. package/skills/estack-productivity-prioritization-coach/sources/02-justin-sung-task-prioritization.md +34 -0
  75. package/skills/estack-prompt-builder-coach/SKILL.md +81 -81
  76. package/skills/estack-prompt-builder-coach/definition-of-done-generator.md +42 -42
  77. package/skills/estack-prompt-builder-coach/prompt-builder.md +37 -37
  78. package/skills/estack-prompt-builder-coach/task-shaper.md +36 -36
  79. package/skills/estack-prompt-builder-coach/vague-ask-auditor.md +37 -37
  80. package/skills/estack-read-claude-session-history/SKILL.md +204 -204
  81. package/skills/estack-read-claude-session-history/references/jsonl-schema.md +126 -126
  82. package/skills/estack-read-claude-session-history/references/modes.md +423 -423
  83. package/skills/estack-read-claude-session-history/references/recipes.md +271 -271
  84. package/skills/estack-read-claude-session-history/scripts/lib/__init__.py +1 -1
  85. package/skills/estack-read-claude-session-history/scripts/lib/parser.py +460 -460
  86. package/skills/estack-read-claude-session-history/scripts/lib/paths.py +234 -234
  87. package/skills/estack-read-claude-session-history/scripts/lib/search.py +179 -179
  88. package/skills/estack-read-claude-session-history/scripts/lib/subagents.py +88 -88
  89. package/skills/estack-read-claude-session-history/scripts/lib/tools.py +144 -144
  90. package/skills/estack-read-claude-session-history/scripts/read_transcript.py +1776 -1776
  91. package/skills/estack-read-claude-session-history/scripts/tests/conftest.py +40 -40
  92. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/README.md +20 -20
  93. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/all-noise.jsonl +4 -4
  94. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/basic-session.jsonl +2 -2
  95. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-gaps.jsonl +9 -9
  96. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-noise.jsonl +7 -7
  97. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-parallel-a.jsonl +3 -3
  98. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-parallel-b.jsonl +3 -3
  99. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-waiting.jsonl +5 -5
  100. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/interrupted.jsonl +2 -2
  101. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/multi-compact.jsonl +8 -8
  102. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/pending-user.jsonl +2 -2
  103. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-no-meta/subagents/agent-aaa.jsonl +2 -2
  104. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-no-meta.jsonl +2 -2
  105. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent/subagents/agent-xyz123.jsonl +2 -2
  106. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent/subagents/agent-xyz123.meta.json +1 -1
  107. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent.jsonl +4 -4
  108. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/time-spread.jsonl +6 -6
  109. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/timeline-day-test.jsonl +5 -5
  110. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/tool-zoo.jsonl +10 -10
  111. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/truncated.jsonl +2 -2
  112. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/unicode.jsonl +2 -2
  113. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-advisor.jsonl +3 -3
  114. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-compact.jsonl +5 -5
  115. package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-thinking.jsonl +2 -2
  116. package/skills/estack-read-claude-session-history/scripts/tests/test_backup_roots.py +56 -56
  117. package/skills/estack-read-claude-session-history/scripts/tests/test_engagement.py +239 -239
  118. package/skills/estack-read-claude-session-history/scripts/tests/test_json_format.py +201 -201
  119. package/skills/estack-read-claude-session-history/scripts/tests/test_modes.py +199 -199
  120. package/skills/estack-read-claude-session-history/scripts/tests/test_parser.py +195 -195
  121. package/skills/estack-read-claude-session-history/scripts/tests/test_paths.py +133 -133
  122. package/skills/estack-read-claude-session-history/scripts/tests/test_search.py +78 -78
  123. package/skills/estack-read-claude-session-history/scripts/tests/test_subagents.py +43 -43
  124. package/skills/estack-read-claude-session-history/scripts/tests/test_timeline.py +179 -179
  125. package/skills/estack-read-claude-session-history/scripts/tests/test_timezone_and_project.py +212 -212
  126. package/skills/estack-read-claude-session-history/scripts/tests/test_tools.py +80 -80
  127. package/skills/estack-repo-search/SKILL.md +65 -65
  128. package/skills/estack-vscode-file-recovery/SKILL.md +188 -0
@@ -1,195 +1,195 @@
1
- """Tests for lib.parser."""
2
-
3
- import json
4
- from datetime import datetime
5
- from pathlib import Path
6
-
7
- import pytest
8
-
9
- from lib import parser as PR
10
-
11
-
12
- def _load(fixtures_dir, name):
13
- return PR.parse_lines(fixtures_dir / name)
14
-
15
-
16
- def test_parse_basic(fixtures_dir):
17
- lines = _load(fixtures_dir, "basic-session.jsonl")
18
- assert len(lines) == 2
19
- assert lines[0]["type"] == "user"
20
-
21
-
22
- def test_get_messages_basic(fixtures_dir):
23
- lines = _load(fixtures_dir, "basic-session.jsonl")
24
- msgs = PR.get_messages(lines)
25
- assert len(msgs) == 2
26
- assert msgs[0]["role"] == "user"
27
- assert msgs[1]["role"] == "assistant"
28
-
29
-
30
- def test_compact_marker_single(fixtures_dir):
31
- lines = _load(fixtures_dir, "with-compact.jsonl")
32
- msgs = PR.get_messages(lines)
33
- compact = [m for m in msgs if m["is_compact"]]
34
- assert len(compact) == 1
35
-
36
-
37
- def test_compact_marker_multiple(fixtures_dir):
38
- lines = _load(fixtures_dir, "multi-compact.jsonl")
39
- msgs = PR.get_messages(lines)
40
- compact = [m for m in msgs if m["is_compact"]]
41
- assert len(compact) == 2
42
-
43
-
44
- def test_compact_marker_absent(fixtures_dir):
45
- lines = _load(fixtures_dir, "basic-session.jsonl")
46
- msgs = PR.get_messages(lines)
47
- assert all(not m["is_compact"] for m in msgs)
48
-
49
-
50
- def test_extract_text_blocks_string():
51
- assert PR.extract_text_blocks("hello") == ["hello"]
52
-
53
-
54
- def test_extract_text_blocks_empty_string():
55
- assert PR.extract_text_blocks("") == []
56
- assert PR.extract_text_blocks(" ") == []
57
-
58
-
59
- def test_extract_text_blocks_array():
60
- blocks = [{"type": "text", "text": "hi"}, {"type": "tool_use", "name": "X"}]
61
- assert PR.extract_text_blocks(blocks) == ["hi"]
62
-
63
-
64
- def test_extract_text_blocks_with_thinking():
65
- blocks = [
66
- {"type": "thinking", "thinking": "reasoning..."},
67
- {"type": "text", "text": "answer"},
68
- ]
69
- out = PR.extract_text_blocks(blocks, include_thinking=True)
70
- assert any("THINKING" in t for t in out)
71
- assert "answer" in out
72
-
73
-
74
- def test_extract_text_blocks_with_tool_use():
75
- blocks = [{"type": "tool_use", "name": "Bash", "input": {"command": "ls"}}]
76
- out = PR.extract_text_blocks(blocks, include_tool_use=True)
77
- assert any("TOOL_USE Bash" in t for t in out)
78
-
79
-
80
- def test_extract_advisor():
81
- blocks = [{"type": "advisor_tool_result", "content": {"text": "advice"}}]
82
- out = PR.extract_text_blocks(blocks)
83
- assert any("[ADVISOR]" in t for t in out)
84
- assert any("advice" in t for t in out)
85
-
86
-
87
- def test_classify_entry_user():
88
- obj = {"type": "user", "message": {"role": "user", "content": "hi"}}
89
- assert PR.classify_entry(obj) == "user"
90
-
91
-
92
- def test_classify_entry_compact():
93
- obj = {
94
- "type": "user",
95
- "message": {"role": "user", "content": PR.COMPACT_MARKER + " more"},
96
- }
97
- assert PR.classify_entry(obj) == "compact"
98
-
99
-
100
- def test_classify_entry_assistant():
101
- obj = {"type": "assistant", "message": {"role": "assistant", "content": []}}
102
- assert PR.classify_entry(obj) == "assistant"
103
-
104
-
105
- def test_classify_entry_noise():
106
- obj = {"type": "ai-title", "aiTitle": "X"}
107
- assert PR.classify_entry(obj) == "title"
108
-
109
-
110
- def test_all_noise_fixture_yields_no_messages(fixtures_dir):
111
- lines = _load(fixtures_dir, "all-noise.jsonl")
112
- msgs = PR.get_messages(lines)
113
- assert msgs == []
114
-
115
-
116
- def test_filter_by_role(fixtures_dir):
117
- lines = _load(fixtures_dir, "basic-session.jsonl")
118
- msgs = PR.get_messages(lines)
119
- user_only = PR.filter_by_role(msgs, "user")
120
- assert all(m["role"] == "user" for m in user_only)
121
- assert len(user_only) == 1
122
-
123
-
124
- def test_filter_by_time(fixtures_dir):
125
- lines = _load(fixtures_dir, "time-spread.jsonl")
126
- msgs = PR.get_messages(lines)
127
- since = datetime(2026, 5, 1)
128
- filtered = PR.filter_by_time(msgs, since=since, until=None)
129
- assert all(
130
- PR._parse_timestamp(m["timestamp"]).replace(tzinfo=None) >= since
131
- for m in filtered if m["timestamp"]
132
- )
133
-
134
-
135
- def test_truncated_line_dropped(fixtures_dir, capsys):
136
- # Should not raise, and warning should be on stderr
137
- lines = _load(fixtures_dir, "truncated.jsonl")
138
- # 2 valid + 1 truncated = 2 valid records
139
- assert len(lines) == 2
140
-
141
-
142
- def test_unicode_roundtrip(fixtures_dir):
143
- lines = _load(fixtures_dir, "unicode.jsonl")
144
- msgs = PR.get_messages(lines)
145
- user_text = msgs[0]["texts"][0]
146
- assert "🌍" in user_text or "你好" in user_text
147
-
148
-
149
- def test_infer_status_clean(fixtures_dir):
150
- lines = _load(fixtures_dir, "basic-session.jsonl")
151
- mtime = (fixtures_dir / "basic-session.jsonl").stat().st_mtime
152
- status = PR.infer_status(lines, mtime, current_session_id=None, session_uuid=None)
153
- assert status == "clean"
154
-
155
-
156
- def test_infer_status_pending_user(fixtures_dir):
157
- lines = _load(fixtures_dir, "pending-user.jsonl")
158
- mtime = (fixtures_dir / "pending-user.jsonl").stat().st_mtime
159
- status = PR.infer_status(lines, mtime, current_session_id=None, session_uuid=None)
160
- assert status == "pending-user"
161
-
162
-
163
- def test_infer_status_interrupted(fixtures_dir):
164
- lines = _load(fixtures_dir, "interrupted.jsonl")
165
- mtime = (fixtures_dir / "interrupted.jsonl").stat().st_mtime
166
- status = PR.infer_status(lines, mtime, current_session_id=None, session_uuid=None)
167
- assert status == "interrupted"
168
-
169
-
170
- def test_infer_status_active(fixtures_dir):
171
- import time
172
- # Touch the fixture to make it fresh, then set CLAUDE_SESSION_ID to its stem
173
- f = fixtures_dir / "basic-session.jsonl"
174
- mtime = time.time()
175
- lines = _load(fixtures_dir, "basic-session.jsonl")
176
- status = PR.infer_status(
177
- lines, mtime, current_session_id="basic-session", session_uuid="basic-session"
178
- )
179
- assert status == "active"
180
-
181
-
182
- def test_session_summary_fields(fixtures_dir):
183
- s = PR.session_summary(fixtures_dir / "tool-zoo.jsonl")
184
- assert s["exists"]
185
- assert s["msg_count"] > 0
186
- assert "Bash" in s["tool_counts"]
187
- assert "Read" in s["tool_counts"]
188
-
189
-
190
- def test_parse_lines_cache(fixtures_dir):
191
- f = fixtures_dir / "basic-session.jsonl"
192
- a = PR.parse_lines(f)
193
- b = PR.parse_lines(f)
194
- # Same object thanks to cache
195
- assert a is b
1
+ """Tests for lib.parser."""
2
+
3
+ import json
4
+ from datetime import datetime
5
+ from pathlib import Path
6
+
7
+ import pytest
8
+
9
+ from lib import parser as PR
10
+
11
+
12
+ def _load(fixtures_dir, name):
13
+ return PR.parse_lines(fixtures_dir / name)
14
+
15
+
16
+ def test_parse_basic(fixtures_dir):
17
+ lines = _load(fixtures_dir, "basic-session.jsonl")
18
+ assert len(lines) == 2
19
+ assert lines[0]["type"] == "user"
20
+
21
+
22
+ def test_get_messages_basic(fixtures_dir):
23
+ lines = _load(fixtures_dir, "basic-session.jsonl")
24
+ msgs = PR.get_messages(lines)
25
+ assert len(msgs) == 2
26
+ assert msgs[0]["role"] == "user"
27
+ assert msgs[1]["role"] == "assistant"
28
+
29
+
30
+ def test_compact_marker_single(fixtures_dir):
31
+ lines = _load(fixtures_dir, "with-compact.jsonl")
32
+ msgs = PR.get_messages(lines)
33
+ compact = [m for m in msgs if m["is_compact"]]
34
+ assert len(compact) == 1
35
+
36
+
37
+ def test_compact_marker_multiple(fixtures_dir):
38
+ lines = _load(fixtures_dir, "multi-compact.jsonl")
39
+ msgs = PR.get_messages(lines)
40
+ compact = [m for m in msgs if m["is_compact"]]
41
+ assert len(compact) == 2
42
+
43
+
44
+ def test_compact_marker_absent(fixtures_dir):
45
+ lines = _load(fixtures_dir, "basic-session.jsonl")
46
+ msgs = PR.get_messages(lines)
47
+ assert all(not m["is_compact"] for m in msgs)
48
+
49
+
50
+ def test_extract_text_blocks_string():
51
+ assert PR.extract_text_blocks("hello") == ["hello"]
52
+
53
+
54
+ def test_extract_text_blocks_empty_string():
55
+ assert PR.extract_text_blocks("") == []
56
+ assert PR.extract_text_blocks(" ") == []
57
+
58
+
59
+ def test_extract_text_blocks_array():
60
+ blocks = [{"type": "text", "text": "hi"}, {"type": "tool_use", "name": "X"}]
61
+ assert PR.extract_text_blocks(blocks) == ["hi"]
62
+
63
+
64
+ def test_extract_text_blocks_with_thinking():
65
+ blocks = [
66
+ {"type": "thinking", "thinking": "reasoning..."},
67
+ {"type": "text", "text": "answer"},
68
+ ]
69
+ out = PR.extract_text_blocks(blocks, include_thinking=True)
70
+ assert any("THINKING" in t for t in out)
71
+ assert "answer" in out
72
+
73
+
74
+ def test_extract_text_blocks_with_tool_use():
75
+ blocks = [{"type": "tool_use", "name": "Bash", "input": {"command": "ls"}}]
76
+ out = PR.extract_text_blocks(blocks, include_tool_use=True)
77
+ assert any("TOOL_USE Bash" in t for t in out)
78
+
79
+
80
+ def test_extract_advisor():
81
+ blocks = [{"type": "advisor_tool_result", "content": {"text": "advice"}}]
82
+ out = PR.extract_text_blocks(blocks)
83
+ assert any("[ADVISOR]" in t for t in out)
84
+ assert any("advice" in t for t in out)
85
+
86
+
87
+ def test_classify_entry_user():
88
+ obj = {"type": "user", "message": {"role": "user", "content": "hi"}}
89
+ assert PR.classify_entry(obj) == "user"
90
+
91
+
92
+ def test_classify_entry_compact():
93
+ obj = {
94
+ "type": "user",
95
+ "message": {"role": "user", "content": PR.COMPACT_MARKER + " more"},
96
+ }
97
+ assert PR.classify_entry(obj) == "compact"
98
+
99
+
100
+ def test_classify_entry_assistant():
101
+ obj = {"type": "assistant", "message": {"role": "assistant", "content": []}}
102
+ assert PR.classify_entry(obj) == "assistant"
103
+
104
+
105
+ def test_classify_entry_noise():
106
+ obj = {"type": "ai-title", "aiTitle": "X"}
107
+ assert PR.classify_entry(obj) == "title"
108
+
109
+
110
+ def test_all_noise_fixture_yields_no_messages(fixtures_dir):
111
+ lines = _load(fixtures_dir, "all-noise.jsonl")
112
+ msgs = PR.get_messages(lines)
113
+ assert msgs == []
114
+
115
+
116
+ def test_filter_by_role(fixtures_dir):
117
+ lines = _load(fixtures_dir, "basic-session.jsonl")
118
+ msgs = PR.get_messages(lines)
119
+ user_only = PR.filter_by_role(msgs, "user")
120
+ assert all(m["role"] == "user" for m in user_only)
121
+ assert len(user_only) == 1
122
+
123
+
124
+ def test_filter_by_time(fixtures_dir):
125
+ lines = _load(fixtures_dir, "time-spread.jsonl")
126
+ msgs = PR.get_messages(lines)
127
+ since = datetime(2026, 5, 1)
128
+ filtered = PR.filter_by_time(msgs, since=since, until=None)
129
+ assert all(
130
+ PR._parse_timestamp(m["timestamp"]).replace(tzinfo=None) >= since
131
+ for m in filtered if m["timestamp"]
132
+ )
133
+
134
+
135
+ def test_truncated_line_dropped(fixtures_dir, capsys):
136
+ # Should not raise, and warning should be on stderr
137
+ lines = _load(fixtures_dir, "truncated.jsonl")
138
+ # 2 valid + 1 truncated = 2 valid records
139
+ assert len(lines) == 2
140
+
141
+
142
+ def test_unicode_roundtrip(fixtures_dir):
143
+ lines = _load(fixtures_dir, "unicode.jsonl")
144
+ msgs = PR.get_messages(lines)
145
+ user_text = msgs[0]["texts"][0]
146
+ assert "🌍" in user_text or "你好" in user_text
147
+
148
+
149
+ def test_infer_status_clean(fixtures_dir):
150
+ lines = _load(fixtures_dir, "basic-session.jsonl")
151
+ mtime = (fixtures_dir / "basic-session.jsonl").stat().st_mtime
152
+ status = PR.infer_status(lines, mtime, current_session_id=None, session_uuid=None)
153
+ assert status == "clean"
154
+
155
+
156
+ def test_infer_status_pending_user(fixtures_dir):
157
+ lines = _load(fixtures_dir, "pending-user.jsonl")
158
+ mtime = (fixtures_dir / "pending-user.jsonl").stat().st_mtime
159
+ status = PR.infer_status(lines, mtime, current_session_id=None, session_uuid=None)
160
+ assert status == "pending-user"
161
+
162
+
163
+ def test_infer_status_interrupted(fixtures_dir):
164
+ lines = _load(fixtures_dir, "interrupted.jsonl")
165
+ mtime = (fixtures_dir / "interrupted.jsonl").stat().st_mtime
166
+ status = PR.infer_status(lines, mtime, current_session_id=None, session_uuid=None)
167
+ assert status == "interrupted"
168
+
169
+
170
+ def test_infer_status_active(fixtures_dir):
171
+ import time
172
+ # Touch the fixture to make it fresh, then set CLAUDE_SESSION_ID to its stem
173
+ f = fixtures_dir / "basic-session.jsonl"
174
+ mtime = time.time()
175
+ lines = _load(fixtures_dir, "basic-session.jsonl")
176
+ status = PR.infer_status(
177
+ lines, mtime, current_session_id="basic-session", session_uuid="basic-session"
178
+ )
179
+ assert status == "active"
180
+
181
+
182
+ def test_session_summary_fields(fixtures_dir):
183
+ s = PR.session_summary(fixtures_dir / "tool-zoo.jsonl")
184
+ assert s["exists"]
185
+ assert s["msg_count"] > 0
186
+ assert "Bash" in s["tool_counts"]
187
+ assert "Read" in s["tool_counts"]
188
+
189
+
190
+ def test_parse_lines_cache(fixtures_dir):
191
+ f = fixtures_dir / "basic-session.jsonl"
192
+ a = PR.parse_lines(f)
193
+ b = PR.parse_lines(f)
194
+ # Same object thanks to cache
195
+ assert a is b
@@ -1,133 +1,133 @@
1
- """Tests for lib.paths."""
2
-
3
- import os
4
- from datetime import datetime, timedelta
5
- from pathlib import Path
6
-
7
- import pytest
8
-
9
- from lib import paths as P
10
-
11
-
12
- def test_encode_cwd_basic():
13
- assert P.encode_cwd("C:\\Users\\foo\\bar") == "C--Users-foo-bar"
14
-
15
-
16
- def test_encode_cwd_spaces():
17
- assert P.encode_cwd("C:\\Users\\2supe\\Other Claude Code") == "C--Users-2supe-Other-Claude-Code"
18
-
19
-
20
- def test_encode_cwd_mixed_slashes():
21
- assert P.encode_cwd("C:/Users/foo bar") == "C--Users-foo-bar"
22
-
23
-
24
- def test_decode_project_name_strips_prefix():
25
- enc = "C--Users-elliot-Other-Claude-Code-Personal-Brand-Project"
26
- decoded = P.decode_project_name(enc)
27
- assert "Other" in decoded
28
- assert "Personal" in decoded
29
- assert "C--Users" not in decoded
30
-
31
-
32
- def test_decode_project_name_fallback_when_unparseable():
33
- decoded = P.decode_project_name("totally-weird-thing")
34
- assert decoded # Non-empty, falls back gracefully
35
-
36
-
37
- def test_resolve_root_live():
38
- assert P.resolve_root("live").name == "projects"
39
-
40
-
41
- def test_resolve_root_mirror():
42
- r = P.resolve_root("mirror")
43
- assert "mirror" in str(r)
44
- assert r.name == "projects"
45
-
46
-
47
- def test_resolve_root_unknown_relative_raises():
48
- with pytest.raises(ValueError):
49
- P.resolve_root("not-a-known-root")
50
-
51
-
52
- def test_resolve_root_absolute_passes_through(tmp_path: Path):
53
- r = P.resolve_root(str(tmp_path))
54
- assert r == tmp_path
55
-
56
-
57
- def test_current_session_id_unset(monkeypatch):
58
- monkeypatch.delenv("CLAUDE_SESSION_ID", raising=False)
59
- assert P.current_session_id() is None
60
-
61
-
62
- def test_current_session_id_set(monkeypatch):
63
- monkeypatch.setenv("CLAUDE_SESSION_ID", "abc-123")
64
- assert P.current_session_id() == "abc-123"
65
-
66
-
67
- def test_parse_timespec_relative():
68
- now = datetime.now()
69
- delta = now - P.parse_timespec("1h")
70
- assert timedelta(seconds=3590) <= delta <= timedelta(seconds=3610)
71
-
72
-
73
- def test_parse_timespec_iso_date():
74
- assert P.parse_timespec("2026-05-01") == datetime(2026, 5, 1)
75
-
76
-
77
- def test_parse_timespec_yesterday():
78
- y = P.parse_timespec("yesterday")
79
- assert y.hour == 0
80
- assert y.minute == 0
81
-
82
-
83
- def test_parse_timespec_invalid():
84
- with pytest.raises(ValueError):
85
- P.parse_timespec("not-a-time")
86
-
87
-
88
- def test_list_transcripts_empty(tmp_path: Path):
89
- assert P.list_transcripts(tmp_path) == []
90
-
91
-
92
- def test_list_transcripts_excludes_agent_prefix(tmp_path: Path):
93
- (tmp_path / "real.jsonl").write_text("{}\n")
94
- (tmp_path / "agent-foo.jsonl").write_text("{}\n")
95
- files = P.list_transcripts(tmp_path)
96
- names = [f.name for f in files]
97
- assert "real.jsonl" in names
98
- assert "agent-foo.jsonl" not in names
99
-
100
-
101
- def test_list_transcripts_time_filter(tmp_path: Path):
102
- old = tmp_path / "old.jsonl"
103
- new = tmp_path / "new.jsonl"
104
- old.write_text("{}\n")
105
- new.write_text("{}\n")
106
- # Backdate old
107
- past = datetime.now() - timedelta(days=10)
108
- os.utime(old, (past.timestamp(), past.timestamp()))
109
-
110
- since = datetime.now() - timedelta(days=5)
111
- files = P.list_transcripts(tmp_path, since=since)
112
- assert [f.name for f in files] == ["new.jsonl"]
113
-
114
-
115
- def test_list_projects_empty(tmp_path: Path):
116
- assert P.list_projects(tmp_path) == []
117
-
118
-
119
- def test_list_subagents_returns_empty_when_no_dir(tmp_path: Path):
120
- f = tmp_path / "session.jsonl"
121
- f.write_text("{}\n")
122
- assert P.list_subagents(f) == []
123
-
124
-
125
- def test_list_subagents_finds_agent_files(tmp_path: Path):
126
- f = tmp_path / "session.jsonl"
127
- f.write_text("{}\n")
128
- sub_dir = tmp_path / "session" / "subagents"
129
- sub_dir.mkdir(parents=True)
130
- (sub_dir / "agent-x.jsonl").write_text("{}\n")
131
- (sub_dir / "agent-y.jsonl").write_text("{}\n")
132
- subs = P.list_subagents(f)
133
- assert len(subs) == 2
1
+ """Tests for lib.paths."""
2
+
3
+ import os
4
+ from datetime import datetime, timedelta
5
+ from pathlib import Path
6
+
7
+ import pytest
8
+
9
+ from lib import paths as P
10
+
11
+
12
+ def test_encode_cwd_basic():
13
+ assert P.encode_cwd("C:\\Users\\foo\\bar") == "C--Users-foo-bar"
14
+
15
+
16
+ def test_encode_cwd_spaces():
17
+ assert P.encode_cwd("C:\\Users\\2supe\\Other Claude Code") == "C--Users-2supe-Other-Claude-Code"
18
+
19
+
20
+ def test_encode_cwd_mixed_slashes():
21
+ assert P.encode_cwd("C:/Users/foo bar") == "C--Users-foo-bar"
22
+
23
+
24
+ def test_decode_project_name_strips_prefix():
25
+ enc = "C--Users-elliot-Other-Claude-Code-Personal-Brand-Project"
26
+ decoded = P.decode_project_name(enc)
27
+ assert "Other" in decoded
28
+ assert "Personal" in decoded
29
+ assert "C--Users" not in decoded
30
+
31
+
32
+ def test_decode_project_name_fallback_when_unparseable():
33
+ decoded = P.decode_project_name("totally-weird-thing")
34
+ assert decoded # Non-empty, falls back gracefully
35
+
36
+
37
+ def test_resolve_root_live():
38
+ assert P.resolve_root("live").name == "projects"
39
+
40
+
41
+ def test_resolve_root_mirror():
42
+ r = P.resolve_root("mirror")
43
+ assert "mirror" in str(r)
44
+ assert r.name == "projects"
45
+
46
+
47
+ def test_resolve_root_unknown_relative_raises():
48
+ with pytest.raises(ValueError):
49
+ P.resolve_root("not-a-known-root")
50
+
51
+
52
+ def test_resolve_root_absolute_passes_through(tmp_path: Path):
53
+ r = P.resolve_root(str(tmp_path))
54
+ assert r == tmp_path
55
+
56
+
57
+ def test_current_session_id_unset(monkeypatch):
58
+ monkeypatch.delenv("CLAUDE_SESSION_ID", raising=False)
59
+ assert P.current_session_id() is None
60
+
61
+
62
+ def test_current_session_id_set(monkeypatch):
63
+ monkeypatch.setenv("CLAUDE_SESSION_ID", "abc-123")
64
+ assert P.current_session_id() == "abc-123"
65
+
66
+
67
+ def test_parse_timespec_relative():
68
+ now = datetime.now()
69
+ delta = now - P.parse_timespec("1h")
70
+ assert timedelta(seconds=3590) <= delta <= timedelta(seconds=3610)
71
+
72
+
73
+ def test_parse_timespec_iso_date():
74
+ assert P.parse_timespec("2026-05-01") == datetime(2026, 5, 1)
75
+
76
+
77
+ def test_parse_timespec_yesterday():
78
+ y = P.parse_timespec("yesterday")
79
+ assert y.hour == 0
80
+ assert y.minute == 0
81
+
82
+
83
+ def test_parse_timespec_invalid():
84
+ with pytest.raises(ValueError):
85
+ P.parse_timespec("not-a-time")
86
+
87
+
88
+ def test_list_transcripts_empty(tmp_path: Path):
89
+ assert P.list_transcripts(tmp_path) == []
90
+
91
+
92
+ def test_list_transcripts_excludes_agent_prefix(tmp_path: Path):
93
+ (tmp_path / "real.jsonl").write_text("{}\n")
94
+ (tmp_path / "agent-foo.jsonl").write_text("{}\n")
95
+ files = P.list_transcripts(tmp_path)
96
+ names = [f.name for f in files]
97
+ assert "real.jsonl" in names
98
+ assert "agent-foo.jsonl" not in names
99
+
100
+
101
+ def test_list_transcripts_time_filter(tmp_path: Path):
102
+ old = tmp_path / "old.jsonl"
103
+ new = tmp_path / "new.jsonl"
104
+ old.write_text("{}\n")
105
+ new.write_text("{}\n")
106
+ # Backdate old
107
+ past = datetime.now() - timedelta(days=10)
108
+ os.utime(old, (past.timestamp(), past.timestamp()))
109
+
110
+ since = datetime.now() - timedelta(days=5)
111
+ files = P.list_transcripts(tmp_path, since=since)
112
+ assert [f.name for f in files] == ["new.jsonl"]
113
+
114
+
115
+ def test_list_projects_empty(tmp_path: Path):
116
+ assert P.list_projects(tmp_path) == []
117
+
118
+
119
+ def test_list_subagents_returns_empty_when_no_dir(tmp_path: Path):
120
+ f = tmp_path / "session.jsonl"
121
+ f.write_text("{}\n")
122
+ assert P.list_subagents(f) == []
123
+
124
+
125
+ def test_list_subagents_finds_agent_files(tmp_path: Path):
126
+ f = tmp_path / "session.jsonl"
127
+ f.write_text("{}\n")
128
+ sub_dir = tmp_path / "session" / "subagents"
129
+ sub_dir.mkdir(parents=True)
130
+ (sub_dir / "agent-x.jsonl").write_text("{}\n")
131
+ (sub_dir / "agent-y.jsonl").write_text("{}\n")
132
+ subs = P.list_subagents(f)
133
+ assert len(subs) == 2