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,78 +1,78 @@
1
- """Tests for lib.search."""
2
-
3
- from datetime import datetime
4
- from pathlib import Path
5
-
6
- from lib import search as S
7
-
8
-
9
- def test_search_session_text(fixtures_dir):
10
- matches = S.search_session(
11
- fixtures_dir / "basic-session.jsonl", "Hello", role="both", in_channel="text"
12
- )
13
- assert len(matches) >= 1
14
-
15
-
16
- def test_search_session_assistant_only(fixtures_dir):
17
- matches = S.search_session(
18
- fixtures_dir / "basic-session.jsonl", "Hello",
19
- role="assistant", in_channel="text",
20
- )
21
- # "Hello" is in the user message only
22
- assert len(matches) == 0
23
-
24
-
25
- def test_search_session_user_only(fixtures_dir):
26
- matches = S.search_session(
27
- fixtures_dir / "basic-session.jsonl", "Hello",
28
- role="user", in_channel="text",
29
- )
30
- assert len(matches) >= 1
31
-
32
-
33
- def test_search_in_tool_use(fixtures_dir):
34
- matches = S.search_session(
35
- fixtures_dir / "tool-zoo.jsonl", "ls -la",
36
- role="both", in_channel="tool_use",
37
- )
38
- assert len(matches) >= 1
39
- assert matches[0].where == "tool_use"
40
-
41
-
42
- def test_search_in_thinking(fixtures_dir):
43
- matches = S.search_session(
44
- fixtures_dir / "with-thinking.jsonl", "step by step",
45
- role="both", in_channel="thinking",
46
- )
47
- assert len(matches) >= 1
48
- assert matches[0].where == "thinking"
49
-
50
-
51
- def test_search_no_match(fixtures_dir):
52
- matches = S.search_session(
53
- fixtures_dir / "basic-session.jsonl", "this-string-not-present",
54
- role="both", in_channel="text",
55
- )
56
- assert matches == []
57
-
58
-
59
- def test_search_with_time_filter(fixtures_dir):
60
- # "Hello" appears in basic-session.jsonl at 2026-05-01T10:00:00Z
61
- # Excluding that date should yield no matches
62
- matches = S.search_session(
63
- fixtures_dir / "basic-session.jsonl", "Hello",
64
- role="both", in_channel="text",
65
- since=datetime(2026, 6, 1),
66
- )
67
- assert matches == []
68
-
69
-
70
- def test_search_project(fixtures_dir, tmp_path):
71
- # Copy 2 fixtures into a fake project dir and search
72
- import shutil
73
- pd = tmp_path / "fake-proj"
74
- pd.mkdir()
75
- shutil.copy(fixtures_dir / "basic-session.jsonl", pd / "session-a.jsonl")
76
- shutil.copy(fixtures_dir / "tool-zoo.jsonl", pd / "session-b.jsonl")
77
- matches = list(S.search_project(pd, "Hello", progress=False))
78
- assert len(matches) >= 1
1
+ """Tests for lib.search."""
2
+
3
+ from datetime import datetime
4
+ from pathlib import Path
5
+
6
+ from lib import search as S
7
+
8
+
9
+ def test_search_session_text(fixtures_dir):
10
+ matches = S.search_session(
11
+ fixtures_dir / "basic-session.jsonl", "Hello", role="both", in_channel="text"
12
+ )
13
+ assert len(matches) >= 1
14
+
15
+
16
+ def test_search_session_assistant_only(fixtures_dir):
17
+ matches = S.search_session(
18
+ fixtures_dir / "basic-session.jsonl", "Hello",
19
+ role="assistant", in_channel="text",
20
+ )
21
+ # "Hello" is in the user message only
22
+ assert len(matches) == 0
23
+
24
+
25
+ def test_search_session_user_only(fixtures_dir):
26
+ matches = S.search_session(
27
+ fixtures_dir / "basic-session.jsonl", "Hello",
28
+ role="user", in_channel="text",
29
+ )
30
+ assert len(matches) >= 1
31
+
32
+
33
+ def test_search_in_tool_use(fixtures_dir):
34
+ matches = S.search_session(
35
+ fixtures_dir / "tool-zoo.jsonl", "ls -la",
36
+ role="both", in_channel="tool_use",
37
+ )
38
+ assert len(matches) >= 1
39
+ assert matches[0].where == "tool_use"
40
+
41
+
42
+ def test_search_in_thinking(fixtures_dir):
43
+ matches = S.search_session(
44
+ fixtures_dir / "with-thinking.jsonl", "step by step",
45
+ role="both", in_channel="thinking",
46
+ )
47
+ assert len(matches) >= 1
48
+ assert matches[0].where == "thinking"
49
+
50
+
51
+ def test_search_no_match(fixtures_dir):
52
+ matches = S.search_session(
53
+ fixtures_dir / "basic-session.jsonl", "this-string-not-present",
54
+ role="both", in_channel="text",
55
+ )
56
+ assert matches == []
57
+
58
+
59
+ def test_search_with_time_filter(fixtures_dir):
60
+ # "Hello" appears in basic-session.jsonl at 2026-05-01T10:00:00Z
61
+ # Excluding that date should yield no matches
62
+ matches = S.search_session(
63
+ fixtures_dir / "basic-session.jsonl", "Hello",
64
+ role="both", in_channel="text",
65
+ since=datetime(2026, 6, 1),
66
+ )
67
+ assert matches == []
68
+
69
+
70
+ def test_search_project(fixtures_dir, tmp_path):
71
+ # Copy 2 fixtures into a fake project dir and search
72
+ import shutil
73
+ pd = tmp_path / "fake-proj"
74
+ pd.mkdir()
75
+ shutil.copy(fixtures_dir / "basic-session.jsonl", pd / "session-a.jsonl")
76
+ shutil.copy(fixtures_dir / "tool-zoo.jsonl", pd / "session-b.jsonl")
77
+ matches = list(S.search_project(pd, "Hello", progress=False))
78
+ assert len(matches) >= 1
@@ -1,43 +1,43 @@
1
- """Tests for lib.subagents."""
2
-
3
- from pathlib import Path
4
-
5
- from lib import subagents as SA
6
- from lib import paths as P
7
-
8
-
9
- def test_load_meta_hit(fixtures_dir):
10
- agent_file = fixtures_dir / "subagent-parent" / "subagents" / "agent-xyz123.jsonl"
11
- meta = SA.load_meta(agent_file)
12
- assert meta["agentType"] == "Explore"
13
- assert "bug" in meta["description"].lower()
14
-
15
-
16
- def test_load_meta_miss(fixtures_dir):
17
- agent_file = fixtures_dir / "subagent-no-meta" / "subagents" / "agent-aaa.jsonl"
18
- meta = SA.load_meta(agent_file)
19
- assert meta["agentType"] == "unknown"
20
- assert meta["description"] == ""
21
-
22
-
23
- def test_agent_finals(fixtures_dir):
24
- parent = fixtures_dir / "subagent-parent.jsonl"
25
- finals = SA.agent_finals(parent)
26
- assert len(finals) == 1
27
- agent_id, meta, text = finals[0]
28
- assert agent_id == "agent-xyz123"
29
- assert meta["agentType"] == "Explore"
30
- assert "Found it" in text
31
-
32
-
33
- def test_agent_finals_no_subagents(fixtures_dir):
34
- parent = fixtures_dir / "basic-session.jsonl"
35
- finals = SA.agent_finals(parent)
36
- assert finals == []
37
-
38
-
39
- def test_list_subagents(fixtures_dir):
40
- parent = fixtures_dir / "subagent-parent.jsonl"
41
- subs = P.list_subagents(parent)
42
- assert len(subs) == 1
43
- assert subs[0].stem == "agent-xyz123"
1
+ """Tests for lib.subagents."""
2
+
3
+ from pathlib import Path
4
+
5
+ from lib import subagents as SA
6
+ from lib import paths as P
7
+
8
+
9
+ def test_load_meta_hit(fixtures_dir):
10
+ agent_file = fixtures_dir / "subagent-parent" / "subagents" / "agent-xyz123.jsonl"
11
+ meta = SA.load_meta(agent_file)
12
+ assert meta["agentType"] == "Explore"
13
+ assert "bug" in meta["description"].lower()
14
+
15
+
16
+ def test_load_meta_miss(fixtures_dir):
17
+ agent_file = fixtures_dir / "subagent-no-meta" / "subagents" / "agent-aaa.jsonl"
18
+ meta = SA.load_meta(agent_file)
19
+ assert meta["agentType"] == "unknown"
20
+ assert meta["description"] == ""
21
+
22
+
23
+ def test_agent_finals(fixtures_dir):
24
+ parent = fixtures_dir / "subagent-parent.jsonl"
25
+ finals = SA.agent_finals(parent)
26
+ assert len(finals) == 1
27
+ agent_id, meta, text = finals[0]
28
+ assert agent_id == "agent-xyz123"
29
+ assert meta["agentType"] == "Explore"
30
+ assert "Found it" in text
31
+
32
+
33
+ def test_agent_finals_no_subagents(fixtures_dir):
34
+ parent = fixtures_dir / "basic-session.jsonl"
35
+ finals = SA.agent_finals(parent)
36
+ assert finals == []
37
+
38
+
39
+ def test_list_subagents(fixtures_dir):
40
+ parent = fixtures_dir / "subagent-parent.jsonl"
41
+ subs = P.list_subagents(parent)
42
+ assert len(subs) == 1
43
+ assert subs[0].stem == "agent-xyz123"
@@ -1,179 +1,179 @@
1
- """Tests for the timeline mode (build/render/gap parsing + CLI)."""
2
-
3
- import json
4
- import os
5
- import shutil
6
- import subprocess
7
- import sys
8
- from datetime import datetime, timedelta
9
- from pathlib import Path
10
-
11
- import pytest
12
-
13
- import read_transcript as RT
14
-
15
-
16
- def _run_cli(cli_path, *args, env_overrides=None):
17
- env = dict(os.environ)
18
- env["PYTHONIOENCODING"] = "utf-8"
19
- if env_overrides:
20
- env.update(env_overrides)
21
- return subprocess.run(
22
- [sys.executable, str(cli_path), *args],
23
- capture_output=True,
24
- text=True,
25
- encoding="utf-8",
26
- env=env,
27
- )
28
-
29
-
30
- @pytest.fixture
31
- def fake_root(fixtures_dir, tmp_path):
32
- root = tmp_path / "projects"
33
- proj = root / "C--fake-proj"
34
- proj.mkdir(parents=True)
35
- shutil.copy(fixtures_dir / "timeline-day-test.jsonl", proj / "abc12345.jsonl")
36
- return root
37
-
38
-
39
- # ── unit: gap + duration helpers ─────────────────────────────────────────────
40
-
41
- def test_parse_gap_default():
42
- assert RT._parse_gap(None) == 15
43
-
44
-
45
- def test_parse_gap_minutes():
46
- assert RT._parse_gap("20m") == 20
47
- assert RT._parse_gap("20") == 20
48
-
49
-
50
- def test_parse_gap_hours():
51
- assert RT._parse_gap("1h") == 60
52
-
53
-
54
- def test_parse_gap_invalid():
55
- with pytest.raises(ValueError):
56
- RT._parse_gap("soon")
57
-
58
-
59
- def test_fmt_dur():
60
- assert RT._fmt_dur(timedelta(minutes=8)) == "8m"
61
- assert RT._fmt_dur(timedelta(minutes=72)) == "1h12m"
62
- assert RT._fmt_dur(timedelta(seconds=30)) == "<1m"
63
-
64
-
65
- # ── unit: block grouping ─────────────────────────────────────────────────────
66
-
67
- def test_build_timeline_blocks(fake_root):
68
- from lib import parser as PR
69
- PR.set_timezone("UTC")
70
- try:
71
- data = RT.build_timeline(
72
- [fake_root / "C--fake-proj"],
73
- since=datetime(2026, 5, 1),
74
- until=datetime(2026, 5, 2),
75
- gap_minutes=15,
76
- current_uuid=None,
77
- )
78
- finally:
79
- PR.set_timezone(None)
80
- blocks = data["blocks"]
81
- assert len(blocks) == 2
82
- assert blocks[0]["start"] == datetime(2026, 5, 1, 10, 0)
83
- assert blocks[0]["end"] == datetime(2026, 5, 1, 10, 8)
84
- assert blocks[1]["start"] == datetime(2026, 5, 1, 12, 0)
85
- assert blocks[1]["end"] == datetime(2026, 5, 1, 12, 2)
86
-
87
-
88
- def test_build_timeline_wide_gap_merges(fake_root):
89
- from lib import parser as PR
90
- PR.set_timezone("UTC")
91
- try:
92
- data = RT.build_timeline(
93
- [fake_root / "C--fake-proj"],
94
- since=datetime(2026, 5, 1),
95
- until=datetime(2026, 5, 2),
96
- gap_minutes=180, # 3h gap threshold swallows the 1h52m idle
97
- current_uuid=None,
98
- )
99
- finally:
100
- PR.set_timezone(None)
101
- assert len(data["blocks"]) == 1
102
-
103
-
104
- # ── CLI ──────────────────────────────────────────────────────────────────────
105
-
106
- def test_timeline_cli_text(cli_path, fake_root):
107
- r = _run_cli(
108
- cli_path, "--root", str(fake_root), "--tz", "UTC",
109
- "--mode", "timeline", "--date", "2026-05-01",
110
- )
111
- assert r.returncode == 0
112
- assert "10:00" in r.stdout
113
- assert "12:02" in r.stdout
114
- assert "idle" in r.stdout
115
- assert "2 block(s)" in r.stdout
116
- # Timeline makes no attention claim — that's engagement mode's job.
117
- assert "active" not in r.stdout
118
-
119
-
120
- def test_timeline_cli_json(cli_path, fake_root):
121
- r = _run_cli(
122
- cli_path, "--root", str(fake_root), "--tz", "UTC",
123
- "--mode", "timeline", "--date", "2026-05-01", "--format", "json",
124
- )
125
- assert r.returncode == 0
126
- data = json.loads(r.stdout)
127
- assert data["totals"]["blocks"] == 2
128
- assert data["totals"]["sessions"] == 1
129
- assert data["totals"]["span_minutes"] == 122 # 10:00 → 12:02
130
- assert "active_minutes" not in data["totals"]
131
- assert data["blocks"][0]["start"].endswith("10:00:00")
132
- assert data["blocks"][0]["sessions"][0]["uuid"] == "abc12345"
133
-
134
-
135
- def test_timeline_cli_empty_range(cli_path, fake_root):
136
- r = _run_cli(
137
- cli_path, "--root", str(fake_root), "--tz", "UTC",
138
- "--mode", "timeline", "--date", "2020-01-01",
139
- )
140
- assert r.returncode == 0
141
- assert "no activity" in r.stdout
142
-
143
-
144
- def test_timeline_cli_project_filter(cli_path, fake_root):
145
- r = _run_cli(
146
- cli_path, "--root", str(fake_root), "--tz", "UTC",
147
- "--mode", "timeline", "--date", "2026-05-01", "--project", "fake",
148
- )
149
- assert r.returncode == 0
150
- assert "10:00" in r.stdout
151
-
152
-
153
- def test_timeline_cli_exclude_current(cli_path, fake_root):
154
- r = _run_cli(
155
- cli_path, "--root", str(fake_root), "--tz", "UTC",
156
- "--mode", "timeline", "--date", "2026-05-01", "--exclude-current",
157
- env_overrides={"CLAUDE_SESSION_ID": "abc12345"},
158
- )
159
- assert r.returncode == 0
160
- assert "no activity" in r.stdout
161
-
162
-
163
- def test_journal_cli_exclude_current(cli_path, fake_root):
164
- r = _run_cli(
165
- cli_path, "--root", str(fake_root),
166
- "--mode", "journal", "--since", "2020-01-01", "--all-projects",
167
- "--exclude-current",
168
- env_overrides={"CLAUDE_SESSION_ID": "abc12345"},
169
- )
170
- assert r.returncode == 0
171
- assert "abc12345" not in r.stdout
172
-
173
-
174
- def test_timeline_cli_project_no_match(cli_path, fake_root):
175
- r = _run_cli(
176
- cli_path, "--root", str(fake_root), "--tz", "UTC",
177
- "--mode", "timeline", "--date", "2026-05-01", "--project", "zzz-nope",
178
- )
179
- assert r.returncode == 1
1
+ """Tests for the timeline mode (build/render/gap parsing + CLI)."""
2
+
3
+ import json
4
+ import os
5
+ import shutil
6
+ import subprocess
7
+ import sys
8
+ from datetime import datetime, timedelta
9
+ from pathlib import Path
10
+
11
+ import pytest
12
+
13
+ import read_transcript as RT
14
+
15
+
16
+ def _run_cli(cli_path, *args, env_overrides=None):
17
+ env = dict(os.environ)
18
+ env["PYTHONIOENCODING"] = "utf-8"
19
+ if env_overrides:
20
+ env.update(env_overrides)
21
+ return subprocess.run(
22
+ [sys.executable, str(cli_path), *args],
23
+ capture_output=True,
24
+ text=True,
25
+ encoding="utf-8",
26
+ env=env,
27
+ )
28
+
29
+
30
+ @pytest.fixture
31
+ def fake_root(fixtures_dir, tmp_path):
32
+ root = tmp_path / "projects"
33
+ proj = root / "C--fake-proj"
34
+ proj.mkdir(parents=True)
35
+ shutil.copy(fixtures_dir / "timeline-day-test.jsonl", proj / "abc12345.jsonl")
36
+ return root
37
+
38
+
39
+ # ── unit: gap + duration helpers ─────────────────────────────────────────────
40
+
41
+ def test_parse_gap_default():
42
+ assert RT._parse_gap(None) == 15
43
+
44
+
45
+ def test_parse_gap_minutes():
46
+ assert RT._parse_gap("20m") == 20
47
+ assert RT._parse_gap("20") == 20
48
+
49
+
50
+ def test_parse_gap_hours():
51
+ assert RT._parse_gap("1h") == 60
52
+
53
+
54
+ def test_parse_gap_invalid():
55
+ with pytest.raises(ValueError):
56
+ RT._parse_gap("soon")
57
+
58
+
59
+ def test_fmt_dur():
60
+ assert RT._fmt_dur(timedelta(minutes=8)) == "8m"
61
+ assert RT._fmt_dur(timedelta(minutes=72)) == "1h12m"
62
+ assert RT._fmt_dur(timedelta(seconds=30)) == "<1m"
63
+
64
+
65
+ # ── unit: block grouping ─────────────────────────────────────────────────────
66
+
67
+ def test_build_timeline_blocks(fake_root):
68
+ from lib import parser as PR
69
+ PR.set_timezone("UTC")
70
+ try:
71
+ data = RT.build_timeline(
72
+ [fake_root / "C--fake-proj"],
73
+ since=datetime(2026, 5, 1),
74
+ until=datetime(2026, 5, 2),
75
+ gap_minutes=15,
76
+ current_uuid=None,
77
+ )
78
+ finally:
79
+ PR.set_timezone(None)
80
+ blocks = data["blocks"]
81
+ assert len(blocks) == 2
82
+ assert blocks[0]["start"] == datetime(2026, 5, 1, 10, 0)
83
+ assert blocks[0]["end"] == datetime(2026, 5, 1, 10, 8)
84
+ assert blocks[1]["start"] == datetime(2026, 5, 1, 12, 0)
85
+ assert blocks[1]["end"] == datetime(2026, 5, 1, 12, 2)
86
+
87
+
88
+ def test_build_timeline_wide_gap_merges(fake_root):
89
+ from lib import parser as PR
90
+ PR.set_timezone("UTC")
91
+ try:
92
+ data = RT.build_timeline(
93
+ [fake_root / "C--fake-proj"],
94
+ since=datetime(2026, 5, 1),
95
+ until=datetime(2026, 5, 2),
96
+ gap_minutes=180, # 3h gap threshold swallows the 1h52m idle
97
+ current_uuid=None,
98
+ )
99
+ finally:
100
+ PR.set_timezone(None)
101
+ assert len(data["blocks"]) == 1
102
+
103
+
104
+ # ── CLI ──────────────────────────────────────────────────────────────────────
105
+
106
+ def test_timeline_cli_text(cli_path, fake_root):
107
+ r = _run_cli(
108
+ cli_path, "--root", str(fake_root), "--tz", "UTC",
109
+ "--mode", "timeline", "--date", "2026-05-01",
110
+ )
111
+ assert r.returncode == 0
112
+ assert "10:00" in r.stdout
113
+ assert "12:02" in r.stdout
114
+ assert "idle" in r.stdout
115
+ assert "2 block(s)" in r.stdout
116
+ # Timeline makes no attention claim — that's engagement mode's job.
117
+ assert "active" not in r.stdout
118
+
119
+
120
+ def test_timeline_cli_json(cli_path, fake_root):
121
+ r = _run_cli(
122
+ cli_path, "--root", str(fake_root), "--tz", "UTC",
123
+ "--mode", "timeline", "--date", "2026-05-01", "--format", "json",
124
+ )
125
+ assert r.returncode == 0
126
+ data = json.loads(r.stdout)
127
+ assert data["totals"]["blocks"] == 2
128
+ assert data["totals"]["sessions"] == 1
129
+ assert data["totals"]["span_minutes"] == 122 # 10:00 → 12:02
130
+ assert "active_minutes" not in data["totals"]
131
+ assert data["blocks"][0]["start"].endswith("10:00:00")
132
+ assert data["blocks"][0]["sessions"][0]["uuid"] == "abc12345"
133
+
134
+
135
+ def test_timeline_cli_empty_range(cli_path, fake_root):
136
+ r = _run_cli(
137
+ cli_path, "--root", str(fake_root), "--tz", "UTC",
138
+ "--mode", "timeline", "--date", "2020-01-01",
139
+ )
140
+ assert r.returncode == 0
141
+ assert "no activity" in r.stdout
142
+
143
+
144
+ def test_timeline_cli_project_filter(cli_path, fake_root):
145
+ r = _run_cli(
146
+ cli_path, "--root", str(fake_root), "--tz", "UTC",
147
+ "--mode", "timeline", "--date", "2026-05-01", "--project", "fake",
148
+ )
149
+ assert r.returncode == 0
150
+ assert "10:00" in r.stdout
151
+
152
+
153
+ def test_timeline_cli_exclude_current(cli_path, fake_root):
154
+ r = _run_cli(
155
+ cli_path, "--root", str(fake_root), "--tz", "UTC",
156
+ "--mode", "timeline", "--date", "2026-05-01", "--exclude-current",
157
+ env_overrides={"CLAUDE_SESSION_ID": "abc12345"},
158
+ )
159
+ assert r.returncode == 0
160
+ assert "no activity" in r.stdout
161
+
162
+
163
+ def test_journal_cli_exclude_current(cli_path, fake_root):
164
+ r = _run_cli(
165
+ cli_path, "--root", str(fake_root),
166
+ "--mode", "journal", "--since", "2020-01-01", "--all-projects",
167
+ "--exclude-current",
168
+ env_overrides={"CLAUDE_SESSION_ID": "abc12345"},
169
+ )
170
+ assert r.returncode == 0
171
+ assert "abc12345" not in r.stdout
172
+
173
+
174
+ def test_timeline_cli_project_no_match(cli_path, fake_root):
175
+ r = _run_cli(
176
+ cli_path, "--root", str(fake_root), "--tz", "UTC",
177
+ "--mode", "timeline", "--date", "2026-05-01", "--project", "zzz-nope",
178
+ )
179
+ assert r.returncode == 1