elliot-stack 1.0.39 → 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.
- package/package.json +1 -1
- package/skills/estack-migrate-claude-session-history/SKILL.md +3 -2
- package/skills/estack-migrate-claude-session-history/scripts/__pycache__/validate-migration.cpython-313.pyc +0 -0
- package/skills/estack-read-claude-session-history/SKILL.md +27 -3
- package/skills/estack-read-claude-session-history/references/modes.md +52 -7
- package/skills/estack-read-claude-session-history/references/recipes.md +7 -1
- package/skills/estack-read-claude-session-history/scripts/__pycache__/read_transcript.cpython-313.pyc +0 -0
- package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/__init__.cpython-313.pyc +0 -0
- package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/parser.cpython-313.pyc +0 -0
- package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/paths.cpython-313.pyc +0 -0
- package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/search.cpython-313.pyc +0 -0
- package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/subagents.cpython-313.pyc +0 -0
- package/skills/estack-read-claude-session-history/scripts/lib/__pycache__/tools.cpython-313.pyc +0 -0
- package/skills/estack-read-claude-session-history/scripts/read_transcript.py +140 -9
- package/skills/estack-migrate-claude-session-history/scripts/test-append-note.js +0 -48
- package/skills/estack-migrate-claude-session-history/scripts/test-validate-migration.py +0 -326
- package/skills/estack-read-claude-session-history/scripts/tests/conftest.py +0 -40
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/README.md +0 -20
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/all-noise.jsonl +0 -4
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/basic-session.jsonl +0 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-gaps.jsonl +0 -9
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-noise.jsonl +0 -7
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-parallel-a.jsonl +0 -3
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-parallel-b.jsonl +0 -3
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/engagement-waiting.jsonl +0 -5
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/interrupted.jsonl +0 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/multi-compact.jsonl +0 -8
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/pending-user.jsonl +0 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-no-meta/subagents/agent-aaa.jsonl +0 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-no-meta.jsonl +0 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent/subagents/agent-xyz123.jsonl +0 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent/subagents/agent-xyz123.meta.json +0 -1
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/subagent-parent.jsonl +0 -4
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/time-spread.jsonl +0 -6
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/timeline-day-test.jsonl +0 -5
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/tool-usage-parent/subagents/agent-sub1.jsonl +0 -3
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/tool-usage-parent.jsonl +0 -3
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/tool-zoo.jsonl +0 -10
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/truncated.jsonl +0 -3
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/unicode.jsonl +0 -2
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-advisor.jsonl +0 -3
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-compact.jsonl +0 -5
- package/skills/estack-read-claude-session-history/scripts/tests/fixtures/with-thinking.jsonl +0 -2
- package/skills/estack-read-claude-session-history/scripts/tests/test_backup_roots.py +0 -56
- package/skills/estack-read-claude-session-history/scripts/tests/test_engagement.py +0 -239
- package/skills/estack-read-claude-session-history/scripts/tests/test_json_format.py +0 -201
- package/skills/estack-read-claude-session-history/scripts/tests/test_modes.py +0 -323
- package/skills/estack-read-claude-session-history/scripts/tests/test_parser.py +0 -204
- package/skills/estack-read-claude-session-history/scripts/tests/test_paths.py +0 -133
- package/skills/estack-read-claude-session-history/scripts/tests/test_search.py +0 -94
- package/skills/estack-read-claude-session-history/scripts/tests/test_search_output.py +0 -161
- package/skills/estack-read-claude-session-history/scripts/tests/test_subagents.py +0 -43
- package/skills/estack-read-claude-session-history/scripts/tests/test_timeline.py +0 -179
- package/skills/estack-read-claude-session-history/scripts/tests/test_timezone_and_project.py +0 -225
- package/skills/estack-read-claude-session-history/scripts/tests/test_tools.py +0 -80
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
"""Tests for the engagement mode (attention-time accounting)."""
|
|
2
|
-
|
|
3
|
-
import json
|
|
4
|
-
import os
|
|
5
|
-
import shutil
|
|
6
|
-
import subprocess
|
|
7
|
-
import sys
|
|
8
|
-
from datetime import datetime, timedelta
|
|
9
|
-
|
|
10
|
-
import pytest
|
|
11
|
-
|
|
12
|
-
import read_transcript as RT
|
|
13
|
-
from lib import parser as PR
|
|
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 utc_tz():
|
|
32
|
-
PR.set_timezone("UTC")
|
|
33
|
-
yield
|
|
34
|
-
PR.set_timezone(None)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _fake_root(tmp_path, **projects):
|
|
38
|
-
"""Build a fake projects root: {project_dir_name: [(fixture, uuid), ...]}."""
|
|
39
|
-
root = tmp_path / "projects"
|
|
40
|
-
for proj_name, files in projects.items():
|
|
41
|
-
pd = root / proj_name
|
|
42
|
-
pd.mkdir(parents=True)
|
|
43
|
-
for src, uuid in files:
|
|
44
|
-
shutil.copy(src, pd / f"{uuid}.jsonl")
|
|
45
|
-
return root
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def _build(root, **kw):
|
|
49
|
-
defaults = dict(
|
|
50
|
-
report_dirs=None,
|
|
51
|
-
report_file=None,
|
|
52
|
-
since=datetime(2026, 5, 1),
|
|
53
|
-
until=datetime(2026, 5, 2),
|
|
54
|
-
break_minutes=10,
|
|
55
|
-
current_uuid=None,
|
|
56
|
-
)
|
|
57
|
-
defaults.update(kw)
|
|
58
|
-
return RT.build_engagement(root, **defaults)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
# ── unit: gap math ───────────────────────────────────────────────────────────
|
|
62
|
-
|
|
63
|
-
def test_gaps_straddle_threshold(fixtures_dir, tmp_path, utc_tz):
|
|
64
|
-
root = _fake_root(
|
|
65
|
-
tmp_path, **{"C--proj-a": [(fixtures_dir / "engagement-gaps.jsonl", "aaaa1111")]}
|
|
66
|
-
)
|
|
67
|
-
data = _build(root)
|
|
68
|
-
(s,) = data["sessions"].values()
|
|
69
|
-
# 5m + 3m active, 32m break (Claude finished 10:09, reply 10:40 — too late),
|
|
70
|
-
# then 5m active = 13m.
|
|
71
|
-
assert s["active"] == timedelta(minutes=13)
|
|
72
|
-
assert s["user_messages"] == 5
|
|
73
|
-
assert len(data["breaks"]) == 1
|
|
74
|
-
assert data["breaks"][0][0] == datetime(2026, 5, 1, 10, 8)
|
|
75
|
-
assert data["breaks"][0][1] == datetime(2026, 5, 1, 10, 40)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def test_waiting_on_claude_credit(fixtures_dir, tmp_path, utc_tz):
|
|
79
|
-
root = _fake_root(
|
|
80
|
-
tmp_path, **{"C--proj-a": [(fixtures_dir / "engagement-waiting.jsonl", "bbbb2222")]}
|
|
81
|
-
)
|
|
82
|
-
data = _build(root)
|
|
83
|
-
(s,) = data["sessions"].values()
|
|
84
|
-
# 32m gap, but Claude's last event was 10:30 and the user replied 10:32
|
|
85
|
-
# (2m ≤ 10m) — the whole gap counts as waiting-on-Claude.
|
|
86
|
-
assert s["active"] == timedelta(minutes=32)
|
|
87
|
-
assert data["breaks"] == []
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def test_noise_exclusion(fixtures_dir, tmp_path, utc_tz):
|
|
91
|
-
root = _fake_root(
|
|
92
|
-
tmp_path, **{"C--proj-a": [(fixtures_dir / "engagement-noise.jsonl", "cccc3333")]}
|
|
93
|
-
)
|
|
94
|
-
data = _build(root)
|
|
95
|
-
(s,) = data["sessions"].values()
|
|
96
|
-
# Only the two real prompts (10:01, 10:06) count: compact continuation,
|
|
97
|
-
# isMeta injections, and tool results are all excluded from the user stream.
|
|
98
|
-
assert s["user_messages"] == 2
|
|
99
|
-
assert s["first"] == datetime(2026, 5, 1, 10, 1)
|
|
100
|
-
assert s["active"] == timedelta(minutes=5)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def test_parallel_sessions_never_double_count(fixtures_dir, tmp_path, utc_tz):
|
|
104
|
-
root = _fake_root(
|
|
105
|
-
tmp_path,
|
|
106
|
-
**{
|
|
107
|
-
"C--proj-a": [(fixtures_dir / "engagement-parallel-a.jsonl", "aaaa1111")],
|
|
108
|
-
"C--proj-b": [(fixtures_dir / "engagement-parallel-b.jsonl", "bbbb2222")],
|
|
109
|
-
},
|
|
110
|
-
)
|
|
111
|
-
data = _build(root)
|
|
112
|
-
by_uuid = {s["summary"]["uuid"]: s for s in data["sessions"].values()}
|
|
113
|
-
# Stream: 10:00 A, 10:10 B, 10:20 B, 10:30 A. Each segment goes to the
|
|
114
|
-
# session of the LATER prompt: B gets 10:00–10:20 (20m), A gets 10:20–10:30
|
|
115
|
-
# (10m). Total 30m == wall clock, not the naive 40m.
|
|
116
|
-
assert by_uuid["bbbb2222"]["active"] == timedelta(minutes=20)
|
|
117
|
-
assert by_uuid["aaaa1111"]["active"] == timedelta(minutes=10)
|
|
118
|
-
total = sum((s["active"] for s in data["sessions"].values()), timedelta())
|
|
119
|
-
assert total == timedelta(minutes=30)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
def test_single_message_session(tmp_path, utc_tz):
|
|
123
|
-
root = tmp_path / "projects"
|
|
124
|
-
pd = root / "C--proj-a"
|
|
125
|
-
pd.mkdir(parents=True)
|
|
126
|
-
(pd / "dddd4444.jsonl").write_text(
|
|
127
|
-
'{"type":"user","timestamp":"2026-05-01T10:00:00Z",'
|
|
128
|
-
'"message":{"role":"user","content":"one and done"}}\n',
|
|
129
|
-
encoding="utf-8",
|
|
130
|
-
)
|
|
131
|
-
data = _build(root)
|
|
132
|
-
(s,) = data["sessions"].values()
|
|
133
|
-
assert s["active"] == timedelta(0)
|
|
134
|
-
assert s["user_messages"] == 1
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
def test_report_scope_filters_but_stream_stays_global(fixtures_dir, tmp_path, utc_tz):
|
|
138
|
-
root = _fake_root(
|
|
139
|
-
tmp_path,
|
|
140
|
-
**{
|
|
141
|
-
"C--proj-a": [(fixtures_dir / "engagement-parallel-a.jsonl", "aaaa1111")],
|
|
142
|
-
"C--proj-b": [(fixtures_dir / "engagement-parallel-b.jsonl", "bbbb2222")],
|
|
143
|
-
},
|
|
144
|
-
)
|
|
145
|
-
data = _build(root, report_dirs=[root / "C--proj-a"])
|
|
146
|
-
# Only A is reported, but B's prompts still split the stream — A gets its
|
|
147
|
-
# interval-correct 10m, not a naive 30m.
|
|
148
|
-
(s,) = data["sessions"].values()
|
|
149
|
-
assert s["summary"]["uuid"] == "aaaa1111"
|
|
150
|
-
assert s["active"] == timedelta(minutes=10)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
# ── CLI ──────────────────────────────────────────────────────────────────────
|
|
154
|
-
|
|
155
|
-
def test_engagement_cli_text(cli_path, fixtures_dir, tmp_path):
|
|
156
|
-
root = _fake_root(
|
|
157
|
-
tmp_path, **{"C--proj-a": [(fixtures_dir / "engagement-gaps.jsonl", "aaaa1111")]}
|
|
158
|
-
)
|
|
159
|
-
r = _run_cli(
|
|
160
|
-
cli_path, "--root", str(root), "--tz", "UTC",
|
|
161
|
-
"--mode", "engagement", "--date", "2026-05-01",
|
|
162
|
-
)
|
|
163
|
-
assert r.returncode == 0
|
|
164
|
-
assert "13m" in r.stdout
|
|
165
|
-
assert "break=10m" in r.stdout
|
|
166
|
-
assert "Breaks >10m" in r.stdout
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
def test_engagement_cli_json(cli_path, fixtures_dir, tmp_path):
|
|
170
|
-
root = _fake_root(
|
|
171
|
-
tmp_path, **{"C--proj-a": [(fixtures_dir / "engagement-gaps.jsonl", "aaaa1111")]}
|
|
172
|
-
)
|
|
173
|
-
r = _run_cli(
|
|
174
|
-
cli_path, "--root", str(root), "--tz", "UTC",
|
|
175
|
-
"--mode", "engagement", "--date", "2026-05-01", "--format", "json",
|
|
176
|
-
)
|
|
177
|
-
assert r.returncode == 0
|
|
178
|
-
data = json.loads(r.stdout)
|
|
179
|
-
assert data["break_minutes"] == 10
|
|
180
|
-
assert data["totals"]["active_minutes"] == 13
|
|
181
|
-
assert data["totals"]["sessions"] == 1
|
|
182
|
-
s = data["sessions"][0]
|
|
183
|
-
assert s["uuid"] == "aaaa1111"
|
|
184
|
-
assert s["elapsed_minutes"] == 45
|
|
185
|
-
assert s["ratio"] == round(13 / 45, 2)
|
|
186
|
-
assert len(data["stream_breaks"]) == 1
|
|
187
|
-
assert data["stream_breaks"][0]["minutes"] == 32
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
def test_engagement_cli_file_window_derived(cli_path, fixtures_dir, tmp_path):
|
|
191
|
-
root = _fake_root(
|
|
192
|
-
tmp_path, **{"C--proj-a": [(fixtures_dir / "engagement-waiting.jsonl", "bbbb2222")]}
|
|
193
|
-
)
|
|
194
|
-
f = root / "C--proj-a" / "bbbb2222.jsonl"
|
|
195
|
-
r = _run_cli(
|
|
196
|
-
cli_path, "--root", str(root), "--tz", "UTC",
|
|
197
|
-
"--mode", "engagement", "--file", str(f),
|
|
198
|
-
)
|
|
199
|
-
assert r.returncode == 0
|
|
200
|
-
assert "32m" in r.stdout
|
|
201
|
-
assert "Prompt gaps" in r.stdout
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
def test_engagement_cli_custom_break(cli_path, fixtures_dir, tmp_path):
|
|
205
|
-
root = _fake_root(
|
|
206
|
-
tmp_path, **{"C--proj-a": [(fixtures_dir / "engagement-gaps.jsonl", "aaaa1111")]}
|
|
207
|
-
)
|
|
208
|
-
r = _run_cli(
|
|
209
|
-
cli_path, "--root", str(root), "--tz", "UTC",
|
|
210
|
-
"--mode", "engagement", "--date", "2026-05-01",
|
|
211
|
-
"--break", "1h", "--format", "json",
|
|
212
|
-
)
|
|
213
|
-
assert r.returncode == 0
|
|
214
|
-
data = json.loads(r.stdout)
|
|
215
|
-
# 1h threshold swallows the 32m gap — everything is active: 45m.
|
|
216
|
-
assert data["totals"]["active_minutes"] == 45
|
|
217
|
-
assert data["stream_breaks"] == []
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
def test_engagement_cli_invalid_break(cli_path, tmp_path):
|
|
221
|
-
root = tmp_path / "projects"
|
|
222
|
-
root.mkdir()
|
|
223
|
-
r = _run_cli(
|
|
224
|
-
cli_path, "--root", str(root),
|
|
225
|
-
"--mode", "engagement", "--break", "soon",
|
|
226
|
-
)
|
|
227
|
-
assert r.returncode == 1
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
def test_engagement_cli_empty_range(cli_path, fixtures_dir, tmp_path):
|
|
231
|
-
root = _fake_root(
|
|
232
|
-
tmp_path, **{"C--proj-a": [(fixtures_dir / "engagement-gaps.jsonl", "aaaa1111")]}
|
|
233
|
-
)
|
|
234
|
-
r = _run_cli(
|
|
235
|
-
cli_path, "--root", str(root), "--tz", "UTC",
|
|
236
|
-
"--mode", "engagement", "--date", "2020-01-01",
|
|
237
|
-
)
|
|
238
|
-
assert r.returncode == 0
|
|
239
|
-
assert "no user messages" in r.stdout
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"""Tests for --format json across modes."""
|
|
2
|
-
|
|
3
|
-
import json
|
|
4
|
-
import os
|
|
5
|
-
import shutil
|
|
6
|
-
import subprocess
|
|
7
|
-
import sys
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
import pytest
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def _run_cli(cli_path, *args, env_overrides=None):
|
|
14
|
-
env = dict(os.environ)
|
|
15
|
-
env["PYTHONIOENCODING"] = "utf-8"
|
|
16
|
-
if env_overrides:
|
|
17
|
-
env.update(env_overrides)
|
|
18
|
-
return subprocess.run(
|
|
19
|
-
[sys.executable, str(cli_path), *args],
|
|
20
|
-
capture_output=True,
|
|
21
|
-
text=True,
|
|
22
|
-
encoding="utf-8",
|
|
23
|
-
env=env,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def _json(r):
|
|
28
|
-
assert r.returncode == 0, r.stderr
|
|
29
|
-
return json.loads(r.stdout)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def test_last_json(cli_path, fixtures_dir):
|
|
33
|
-
data = _json(_run_cli(
|
|
34
|
-
cli_path, "--file", str(fixtures_dir / "basic-session.jsonl"),
|
|
35
|
-
"--mode", "last", "--format", "json",
|
|
36
|
-
))
|
|
37
|
-
assert isinstance(data, list)
|
|
38
|
-
assert data[-1]["n_from_end"] == 1
|
|
39
|
-
assert "Here is help" in data[-1]["text"]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def test_json_alias_flag(cli_path, fixtures_dir):
|
|
43
|
-
data = _json(_run_cli(
|
|
44
|
-
cli_path, "--file", str(fixtures_dir / "basic-session.jsonl"),
|
|
45
|
-
"--mode", "last", "--json",
|
|
46
|
-
))
|
|
47
|
-
assert isinstance(data, list)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def test_advisor_json(cli_path, fixtures_dir):
|
|
51
|
-
data = _json(_run_cli(
|
|
52
|
-
cli_path, "--file", str(fixtures_dir / "with-advisor.jsonl"),
|
|
53
|
-
"--mode", "advisor", "--format", "json",
|
|
54
|
-
))
|
|
55
|
-
assert data == ["The advisor says do X then Y."]
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def test_pre_compact_json(cli_path, fixtures_dir):
|
|
59
|
-
data = _json(_run_cli(
|
|
60
|
-
cli_path, "--file", str(fixtures_dir / "with-compact.jsonl"),
|
|
61
|
-
"--mode", "pre-compact", "--format", "json",
|
|
62
|
-
))
|
|
63
|
-
assert data["found_compact"] is True
|
|
64
|
-
assert any("First answer" in m["text"] for m in data["messages"])
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def test_dump_json(cli_path, fixtures_dir):
|
|
68
|
-
data = _json(_run_cli(
|
|
69
|
-
cli_path, "--file", str(fixtures_dir / "basic-session.jsonl"),
|
|
70
|
-
"--mode", "dump", "--format", "json",
|
|
71
|
-
))
|
|
72
|
-
assert isinstance(data, list)
|
|
73
|
-
assert data[0]["role"] == "user"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def test_debug_json(cli_path, fixtures_dir):
|
|
77
|
-
data = _json(_run_cli(
|
|
78
|
-
cli_path, "--file", str(fixtures_dir / "with-advisor.jsonl"),
|
|
79
|
-
"--mode", "debug", "--format", "json",
|
|
80
|
-
))
|
|
81
|
-
assert data["advisor_blocks"] == 1
|
|
82
|
-
assert "entry_types" in data
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
def test_brief_json(cli_path, fixtures_dir):
|
|
86
|
-
data = _json(_run_cli(
|
|
87
|
-
cli_path, "--file", str(fixtures_dir / "tool-zoo.jsonl"),
|
|
88
|
-
"--mode", "brief", "--format", "json",
|
|
89
|
-
))
|
|
90
|
-
assert data["exists"] is True
|
|
91
|
-
assert data["tool_counts"]["Bash"] == 1
|
|
92
|
-
assert isinstance(data["files_touched"], list)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def test_changelog_json(cli_path, fixtures_dir):
|
|
96
|
-
data = _json(_run_cli(
|
|
97
|
-
cli_path, "--file", str(fixtures_dir / "tool-zoo.jsonl"),
|
|
98
|
-
"--mode", "changelog", "--format", "json",
|
|
99
|
-
))
|
|
100
|
-
assert len(data) == 9
|
|
101
|
-
assert data[0]["tool"] == "Bash"
|
|
102
|
-
assert "input" not in data[0]
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def test_tool_calls_json_includes_input(cli_path, fixtures_dir):
|
|
106
|
-
data = _json(_run_cli(
|
|
107
|
-
cli_path, "--file", str(fixtures_dir / "tool-zoo.jsonl"),
|
|
108
|
-
"--mode", "tool-calls", "--format", "json", "--tool", "Bash",
|
|
109
|
-
))
|
|
110
|
-
assert len(data) == 1
|
|
111
|
-
assert data[0]["input"]["command"] == "ls -la /tmp"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def test_file_edits_json(cli_path, fixtures_dir):
|
|
115
|
-
data = _json(_run_cli(
|
|
116
|
-
cli_path, "--file", str(fixtures_dir / "tool-zoo.jsonl"),
|
|
117
|
-
"--mode", "file-edits", "--format", "json",
|
|
118
|
-
))
|
|
119
|
-
paths = [row["path"] for row in data]
|
|
120
|
-
assert any("foo.py" in p for p in paths)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def test_subagent_finals_json(cli_path, fixtures_dir):
|
|
124
|
-
data = _json(_run_cli(
|
|
125
|
-
cli_path, "--file", str(fixtures_dir / "subagent-parent.jsonl"),
|
|
126
|
-
"--mode", "subagent-finals", "--format", "json",
|
|
127
|
-
))
|
|
128
|
-
assert data[0]["agentType"] == "Explore"
|
|
129
|
-
assert "Found it" in data[0]["text"]
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
def test_search_json_single_file(cli_path, fixtures_dir):
|
|
133
|
-
data = _json(_run_cli(
|
|
134
|
-
cli_path, "--file", str(fixtures_dir / "basic-session.jsonl"),
|
|
135
|
-
"--mode", "search", "--query", "help", "--format", "json",
|
|
136
|
-
))
|
|
137
|
-
assert len(data) == 1
|
|
138
|
-
assert data[0]["role"] == "assistant"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
def test_list_json(cli_path, fixtures_dir, tmp_path):
|
|
142
|
-
fake_root = tmp_path / "projects"
|
|
143
|
-
fake_proj = fake_root / "C--fake-proj"
|
|
144
|
-
fake_proj.mkdir(parents=True)
|
|
145
|
-
shutil.copy(fixtures_dir / "basic-session.jsonl", fake_proj / "abc.jsonl")
|
|
146
|
-
data = _json(_run_cli(
|
|
147
|
-
cli_path, "--root", str(fake_root), "--all-projects",
|
|
148
|
-
"--mode", "list", "--format", "json",
|
|
149
|
-
))
|
|
150
|
-
assert len(data) == 1
|
|
151
|
-
assert data[0]["uuid"] == "abc"
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
def test_journal_json(cli_path, fixtures_dir, tmp_path):
|
|
155
|
-
fake_root = tmp_path / "projects"
|
|
156
|
-
fake_proj = fake_root / "C--fake-proj"
|
|
157
|
-
fake_proj.mkdir(parents=True)
|
|
158
|
-
shutil.copy(fixtures_dir / "tool-zoo.jsonl", fake_proj / "def.jsonl")
|
|
159
|
-
data = _json(_run_cli(
|
|
160
|
-
cli_path, "--root", str(fake_root), "--all-projects",
|
|
161
|
-
"--mode", "journal", "--since", "2020-01-01", "--format", "json",
|
|
162
|
-
))
|
|
163
|
-
assert data[0]["uuid"] == "def"
|
|
164
|
-
assert data[0]["tool_counts"]["Bash"] == 1
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
def test_count_json(cli_path, fixtures_dir, tmp_path):
|
|
168
|
-
fake_root = tmp_path / "projects"
|
|
169
|
-
fake_proj = fake_root / "C--fake-proj"
|
|
170
|
-
fake_proj.mkdir(parents=True)
|
|
171
|
-
shutil.copy(fixtures_dir / "basic-session.jsonl", fake_proj / "abc.jsonl")
|
|
172
|
-
data = _json(_run_cli(
|
|
173
|
-
cli_path, "--root", str(fake_root), "--all-projects",
|
|
174
|
-
"--mode", "count", "--query", "help", "--format", "json",
|
|
175
|
-
))
|
|
176
|
-
assert data == {"sessions": 1, "messages": 2, "matches": 1}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def test_count_text_unchanged(cli_path, fixtures_dir, tmp_path):
|
|
180
|
-
fake_root = tmp_path / "projects"
|
|
181
|
-
fake_proj = fake_root / "C--fake-proj"
|
|
182
|
-
fake_proj.mkdir(parents=True)
|
|
183
|
-
shutil.copy(fixtures_dir / "basic-session.jsonl", fake_proj / "abc.jsonl")
|
|
184
|
-
r = _run_cli(
|
|
185
|
-
cli_path, "--root", str(fake_root), "--all-projects",
|
|
186
|
-
"--mode", "count", "--query", "help",
|
|
187
|
-
)
|
|
188
|
-
assert r.returncode == 0
|
|
189
|
-
assert r.stdout.strip() == "1"
|
|
190
|
-
assert "1 sessions" in r.stderr
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
def test_diff_json(cli_path, fixtures_dir):
|
|
194
|
-
data = _json(_run_cli(
|
|
195
|
-
cli_path, "--mode", "diff",
|
|
196
|
-
"--file-a", str(fixtures_dir / "basic-session.jsonl"),
|
|
197
|
-
"--file-b", str(fixtures_dir / "with-thinking.jsonl"),
|
|
198
|
-
"--format", "json",
|
|
199
|
-
))
|
|
200
|
-
sources = {m["source"] for m in data["messages"]}
|
|
201
|
-
assert sources == {"A", "B"}
|