claude-dev-env 8.124.0 → 8.126.0
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/bin/ever-registered-hooks.mjs +1 -0
- package/bin/ever-registered-hooks.test.mjs +4 -0
- package/bin/install-constants.mjs +5 -0
- package/bin/install-constants.test.mjs +29 -0
- package/bin/install.mjs +15 -15
- package/bin/install.test.mjs +6 -2
- package/bin/profile-stop-gate.mjs +99 -70
- package/bin/profile-stop-gate.test.mjs +230 -12
- package/docs/agents-guidance/asks.md +1 -1
- package/docs/rule-guides/question-presentation.md +1 -1
- package/hooks/blocking/closing_reply_judge.py +332 -0
- package/hooks/blocking/closing_reply_shapes.py +365 -0
- package/hooks/blocking/conftest.py +84 -0
- package/hooks/blocking/open_tasks_stop_gate.py +247 -10
- package/hooks/blocking/open_tasks_transcript.py +25 -2
- package/hooks/blocking/open_tasks_transcript_records.py +10 -0
- package/hooks/blocking/question_brief_gate.py +6 -4
- package/hooks/blocking/test_closing_reply_judge.py +246 -0
- package/hooks/blocking/test_closing_reply_shapes.py +247 -0
- package/hooks/blocking/test_open_tasks_stop_gate.py +562 -0
- package/hooks/blocking/test_open_tasks_transcript.py +23 -0
- package/hooks/blocking/test_open_tasks_transcript_records.py +14 -0
- package/hooks/blocking/test_question_brief_gate.py +22 -0
- package/hooks/features/conduct-gates.md +7 -3
- package/hooks/hooks.json +6 -1
- package/hooks/hooks_constants/closing_reply_judge_constants.py +143 -0
- package/hooks/hooks_constants/open_tasks_stop_gate_constants.py +93 -0
- package/hooks/hooks_constants/test_hook_time_budget.py +7 -0
- package/hooks/once_per_session.py +65 -1
- package/hooks/test_once_per_session.py +35 -0
- package/package.json +1 -1
- package/scripts/gh_artifact_upload.py +3 -3
- package/scripts/policy_lint/adapter_configuration.py +6 -0
- package/scripts/policy_lint/config/constants.py +1 -0
- package/scripts/tests/test_adapter_configuration.py +8 -0
- package/scripts/tests/test_gh_artifact_upload.py +18 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from conftest import JudgeStub
|
|
11
|
+
from closing_reply_judge import (
|
|
12
|
+
JudgeVerdict,
|
|
13
|
+
child_environment,
|
|
14
|
+
gated_verdict,
|
|
15
|
+
is_judge_available,
|
|
16
|
+
judge_command,
|
|
17
|
+
judge_input,
|
|
18
|
+
judge_prompt,
|
|
19
|
+
judged_verdict,
|
|
20
|
+
log_no_verdict,
|
|
21
|
+
parsed_verdict,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
PROMISE_REPLY = "Pushed the branch. The benchmark table will be posted when you get back."
|
|
25
|
+
PROMISE_SPAN = "The benchmark table will be posted when you get back."
|
|
26
|
+
LIST_REPLY = "Open calls:\n- keep the cache\n- drop the flag\n- rename the job"
|
|
27
|
+
LIST_SPAN = "Open calls:"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.fixture(autouse=True)
|
|
31
|
+
def judge_log_home(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
32
|
+
monkeypatch.setenv("HOME", str(tmp_path / "home"))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _log_text(tmp_path: Path) -> str:
|
|
36
|
+
log_path = tmp_path / "home" / ".claude" / "logs" / "closing-reply-judge.log"
|
|
37
|
+
return log_path.read_text() if log_path.is_file() else ""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_should_send_only_the_summary_line_for_a_task_notification() -> None:
|
|
41
|
+
notification = "<task-notification>\n<task-id>a1</task-id>\n<summary>Lint job ended</summary>\n<result>long output</result>\n</task-notification>"
|
|
42
|
+
assert judge_input(notification, "Done.", False) == {
|
|
43
|
+
"prompt_kind": "task_notification",
|
|
44
|
+
"user_prompt": "Lint job ended",
|
|
45
|
+
"reply": "Done.",
|
|
46
|
+
"question_tool_used": False,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_should_send_the_command_name_and_args_for_a_slash_command() -> None:
|
|
51
|
+
command_prompt = "<command-message>review</command-message>\n<command-name>/review</command-name>\n<command-args>12 --fast</command-args>"
|
|
52
|
+
all_input_fields = judge_input(command_prompt, "Done.", True)
|
|
53
|
+
assert all_input_fields["prompt_kind"] == "slash_command"
|
|
54
|
+
assert all_input_fields["user_prompt"] == "/review 12 --fast"
|
|
55
|
+
assert all_input_fields["question_tool_used"] is True
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_should_cut_a_typed_prompt_at_four_thousand_characters() -> None:
|
|
59
|
+
long_prompt = "a" * 3990 + "b" * 50
|
|
60
|
+
all_input_fields = judge_input(long_prompt, "Done.", False)
|
|
61
|
+
assert all_input_fields["prompt_kind"] == "typed"
|
|
62
|
+
assert all_input_fields["user_prompt"] == "a" * 3990 + "b" * 10
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_should_put_the_input_json_in_place_of_the_data_marker() -> None:
|
|
66
|
+
full_prompt = judge_prompt("Fix the build", PROMISE_REPLY, False)
|
|
67
|
+
assert "$DATA" not in full_prompt
|
|
68
|
+
assert (
|
|
69
|
+
json.dumps(judge_input("Fix the build", PROMISE_REPLY, False), ensure_ascii=False, indent=1)
|
|
70
|
+
in full_prompt
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_should_start_the_judge_with_hooks_and_mcp_disabled() -> None:
|
|
75
|
+
all_command_parts = judge_command("/opt/claude")
|
|
76
|
+
assert all_command_parts[:6] == ["/opt/claude", "-p", "--model", "haiku", "--effort", "medium"]
|
|
77
|
+
assert (
|
|
78
|
+
all_command_parts[all_command_parts.index("--settings") + 1] == '{"disableAllHooks": true}'
|
|
79
|
+
)
|
|
80
|
+
assert "--strict-mcp-config" in all_command_parts
|
|
81
|
+
assert all_command_parts[all_command_parts.index("--mcp-config") + 1] == '{"mcpServers": {}}'
|
|
82
|
+
assert all_command_parts[all_command_parts.index("--tools") + 1] == ""
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_should_mark_the_child_and_drop_the_parent_session_variables(
|
|
86
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
87
|
+
) -> None:
|
|
88
|
+
monkeypatch.setenv("CLAUDE_CODE_SESSION_ID", "parent-session")
|
|
89
|
+
monkeypatch.setenv("JUDGE_TEST_KEPT", "kept")
|
|
90
|
+
all_child_variables = child_environment()
|
|
91
|
+
assert "CLAUDE_CODE_SESSION_ID" not in all_child_variables
|
|
92
|
+
assert all_child_variables["JUDGE_TEST_KEPT"] == "kept"
|
|
93
|
+
assert all_child_variables["CLAUDE_TURN_REVIEW_CHILD"] == "1"
|
|
94
|
+
assert all_child_variables["CLAUDE_CODE_DISABLE_CLAUDE_MDS"] == "1"
|
|
95
|
+
assert all_child_variables["CLAUDE_CODE_DISABLE_AUTO_MEMORY"] == "1"
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_should_find_the_judge_only_when_claude_is_on_path(
|
|
99
|
+
judge_stub: JudgeStub, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
100
|
+
) -> None:
|
|
101
|
+
assert is_judge_available() is True
|
|
102
|
+
monkeypatch.setenv("PATH", str(tmp_path / "absent"))
|
|
103
|
+
assert is_judge_available() is False
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_should_read_a_verdict_bare_or_in_one_json_fence() -> None:
|
|
107
|
+
verdict_text = json.dumps(
|
|
108
|
+
{
|
|
109
|
+
"promised_report": True,
|
|
110
|
+
"promise_span": PROMISE_SPAN,
|
|
111
|
+
"decisions_as_list": False,
|
|
112
|
+
"list_span": "",
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
assert parsed_verdict(verdict_text, PROMISE_REPLY) == JudgeVerdict(PROMISE_SPAN, "")
|
|
116
|
+
assert parsed_verdict(f"```json\n{verdict_text}\n```", PROMISE_REPLY) == JudgeVerdict(
|
|
117
|
+
PROMISE_SPAN, ""
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@pytest.mark.parametrize(
|
|
122
|
+
"result_text",
|
|
123
|
+
[
|
|
124
|
+
"The reply promises a report.",
|
|
125
|
+
json.dumps(
|
|
126
|
+
{
|
|
127
|
+
"promised_report": True,
|
|
128
|
+
"promise_span": "a report later",
|
|
129
|
+
"decisions_as_list": False,
|
|
130
|
+
"list_span": "",
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
json.dumps(
|
|
134
|
+
{
|
|
135
|
+
"promised_report": True,
|
|
136
|
+
"promise_span": "",
|
|
137
|
+
"decisions_as_list": False,
|
|
138
|
+
"list_span": "",
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
json.dumps(
|
|
142
|
+
{
|
|
143
|
+
"promised_report": "yes",
|
|
144
|
+
"promise_span": PROMISE_SPAN,
|
|
145
|
+
"decisions_as_list": False,
|
|
146
|
+
"list_span": "",
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
json.dumps(
|
|
150
|
+
{
|
|
151
|
+
"promised_report": True,
|
|
152
|
+
"promise_span": PROMISE_SPAN,
|
|
153
|
+
"decisions_as_list": False,
|
|
154
|
+
"list_span": "",
|
|
155
|
+
"note": "",
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
],
|
|
159
|
+
)
|
|
160
|
+
def test_should_give_no_verdict_for_an_answer_that_is_not_the_verdict_shape(
|
|
161
|
+
result_text: str,
|
|
162
|
+
) -> None:
|
|
163
|
+
assert parsed_verdict(result_text, PROMISE_REPLY) is None
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def test_should_pass_a_list_verdict_when_the_turn_used_the_question_tool() -> None:
|
|
167
|
+
verdict = JudgeVerdict(PROMISE_SPAN, LIST_SPAN)
|
|
168
|
+
assert gated_verdict(verdict, "Fix the build", False) == verdict
|
|
169
|
+
assert gated_verdict(verdict, "Fix the build", True) == JudgeVerdict(PROMISE_SPAN, "")
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def test_should_pass_a_list_verdict_when_the_prompt_asks_for_a_list() -> None:
|
|
173
|
+
verdict = JudgeVerdict("", LIST_SPAN)
|
|
174
|
+
assert gated_verdict(verdict, "list the open calls as bullets", False) == JudgeVerdict("", "")
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def test_should_return_the_gated_verdict_from_one_child_run(judge_stub: JudgeStub) -> None:
|
|
178
|
+
judge_stub.answer(
|
|
179
|
+
verdict={
|
|
180
|
+
"promised_report": False,
|
|
181
|
+
"promise_span": "",
|
|
182
|
+
"decisions_as_list": True,
|
|
183
|
+
"list_span": LIST_SPAN,
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
assert judged_verdict("Fix the build", LIST_REPLY, False) == JudgeVerdict("", LIST_SPAN)
|
|
187
|
+
assert judged_verdict("list the open calls as bullets", LIST_REPLY, False) == JudgeVerdict(
|
|
188
|
+
"", ""
|
|
189
|
+
)
|
|
190
|
+
assert len(judge_stub.calls()) == 2
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def test_should_run_the_child_in_an_empty_folder_with_the_prompt_on_stdin(
|
|
194
|
+
judge_stub: JudgeStub, monkeypatch: pytest.MonkeyPatch
|
|
195
|
+
) -> None:
|
|
196
|
+
monkeypatch.setenv("CLAUDE_CODE_SESSION_ID", "parent-session")
|
|
197
|
+
judged_verdict("Fix the build", PROMISE_REPLY, False)
|
|
198
|
+
[child_call] = judge_stub.calls()
|
|
199
|
+
assert child_call["stdin"] == judge_prompt("Fix the build", PROMISE_REPLY, False)
|
|
200
|
+
assert child_call["argv"] == judge_command("claude")[1:]
|
|
201
|
+
assert child_call["cwd_entries"] == []
|
|
202
|
+
assert child_call["review_child"] == "1"
|
|
203
|
+
assert child_call["disable_claude_mds"] == "1"
|
|
204
|
+
assert child_call["disable_auto_memory"] == "1"
|
|
205
|
+
assert child_call["parent_session_id"] is None
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def test_should_give_no_verdict_and_log_when_the_child_times_out(
|
|
209
|
+
judge_stub: JudgeStub, tmp_path: Path
|
|
210
|
+
) -> None:
|
|
211
|
+
judge_stub.sleep(5)
|
|
212
|
+
assert judged_verdict("Fix the build", PROMISE_REPLY, False, timeout_seconds=0.5) is None
|
|
213
|
+
assert "the child timed out" in _log_text(tmp_path)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@pytest.mark.parametrize(
|
|
217
|
+
("set_up", "logged_reason"),
|
|
218
|
+
[
|
|
219
|
+
(lambda stub: stub.exit_code(1), "the child exited with code 1"),
|
|
220
|
+
(lambda stub: stub.raw_stdout("not json"), "stdout is not one JSON object"),
|
|
221
|
+
(lambda stub: stub.answer(result="{}", is_error=True), "the answer is marked is_error"),
|
|
222
|
+
(lambda stub: stub.answer(result="no verdict here"), "the result is not the verdict shape"),
|
|
223
|
+
],
|
|
224
|
+
)
|
|
225
|
+
def test_should_give_no_verdict_and_log_when_the_child_answer_is_unusable(
|
|
226
|
+
judge_stub: JudgeStub, tmp_path: Path, set_up, logged_reason: str
|
|
227
|
+
) -> None:
|
|
228
|
+
set_up(judge_stub)
|
|
229
|
+
assert judged_verdict("Fix the build", PROMISE_REPLY, False) is None
|
|
230
|
+
assert logged_reason in _log_text(tmp_path)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def test_should_give_no_verdict_when_claude_is_missing(
|
|
234
|
+
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
235
|
+
) -> None:
|
|
236
|
+
monkeypatch.setenv("PATH", str(tmp_path / "absent"))
|
|
237
|
+
monkeypatch.setenv("HOME", str(tmp_path / "home"))
|
|
238
|
+
assert judged_verdict("Fix the build", PROMISE_REPLY, False) is None
|
|
239
|
+
assert "the child could not start" in _log_text(tmp_path)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def test_should_write_one_log_line_per_missing_verdict(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
243
|
+
monkeypatch.setenv("HOME", str(tmp_path / "home"))
|
|
244
|
+
log_no_verdict("the transcript cannot be read")
|
|
245
|
+
[log_line] = _log_text(tmp_path).splitlines()
|
|
246
|
+
assert log_line.endswith("closing reply judge gave no verdict: the transcript cannot be read")
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from closing_reply_shapes import (
|
|
4
|
+
OpenItemList,
|
|
5
|
+
item_count_under,
|
|
6
|
+
open_item_list,
|
|
7
|
+
promised_report_phrase,
|
|
8
|
+
prompt_asks_for_list,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
BED_PROMPT = "heading out now. handle whatever the nightly job returns"
|
|
12
|
+
PROMISE_REPLY = (
|
|
13
|
+
"Both fix runs are armed, and a wake is set for the end of CI."
|
|
14
|
+
" The benchmark table will be posted when you get back."
|
|
15
|
+
)
|
|
16
|
+
DEFERRED_PROMPT = "You did a lot of work. I want to know what you put off."
|
|
17
|
+
DEFERRED_LEAD = (
|
|
18
|
+
"What I deferred, checked against the build log:"
|
|
19
|
+
)
|
|
20
|
+
DEFERRED_REPLY = (
|
|
21
|
+
f"{DEFERRED_LEAD}\n\n"
|
|
22
|
+
"1. The retry budget for the sync job.\n"
|
|
23
|
+
"2. The second fixture for the Windows path.\n"
|
|
24
|
+
"3. The docs page for the new flag.\n"
|
|
25
|
+
"4. The cleanup of the stale branch.\n"
|
|
26
|
+
"5. The follow-up issue for the timeout."
|
|
27
|
+
)
|
|
28
|
+
THREE_BULLETS = "- The retry budget.\n- The docs page.\n- The stale branch."
|
|
29
|
+
CORRECTION_PROMPT = (
|
|
30
|
+
"<!-- reply 1 -->\n"
|
|
31
|
+
"> The benchmark table will be posted when you get back.\n\n"
|
|
32
|
+
"skip that; just apply the result and finish the fixes"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@pytest.mark.parametrize(
|
|
37
|
+
("reply_text", "prompt_text", "expected_phrase"),
|
|
38
|
+
[
|
|
39
|
+
(PROMISE_REPLY, BED_PROMPT, "when you get back"),
|
|
40
|
+
("I'll report back once CI ends.", BED_PROMPT, "I'll report back once"),
|
|
41
|
+
("I’ll report back once CI ends.", BED_PROMPT, "I’ll report back once"),
|
|
42
|
+
("Then I'll report back.", BED_PROMPT, "I'll report back"),
|
|
43
|
+
("The summary will be posted at the end.", BED_PROMPT, "summary will be posted"),
|
|
44
|
+
("I'll post the link once CI ends.", BED_PROMPT, "I'll post the link once"),
|
|
45
|
+
(
|
|
46
|
+
PROMISE_REPLY,
|
|
47
|
+
"<task-notification>summary: the run ended</task-notification>",
|
|
48
|
+
"when you get back",
|
|
49
|
+
),
|
|
50
|
+
(PROMISE_REPLY, CORRECTION_PROMPT, "when you get back"),
|
|
51
|
+
(PROMISE_REPLY, "no report needed, just finish", "when you get back"),
|
|
52
|
+
(PROMISE_REPLY, "Never mind the report, just fix it", "when you get back"),
|
|
53
|
+
(PROMISE_REPLY, 'The bot posted "Report ready" again. Fix the hook.', "when you get back"),
|
|
54
|
+
(
|
|
55
|
+
PROMISE_REPLY,
|
|
56
|
+
"<system-reminder>write a report</system-reminder> just finish",
|
|
57
|
+
"when you get back",
|
|
58
|
+
),
|
|
59
|
+
(PROMISE_REPLY, " > report back please\nfix it", "when you get back"),
|
|
60
|
+
],
|
|
61
|
+
)
|
|
62
|
+
def test_should_flag_a_promised_later_report_no_prompt_asked_for(
|
|
63
|
+
reply_text: str, prompt_text: str, expected_phrase: str
|
|
64
|
+
) -> None:
|
|
65
|
+
assert promised_report_phrase(reply_text, prompt_text) == expected_phrase
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@pytest.mark.parametrize(
|
|
69
|
+
("reply_text", "prompt_text"),
|
|
70
|
+
[
|
|
71
|
+
("No report will follow.", BED_PROMPT),
|
|
72
|
+
("> I'll report back once CI ends.", BED_PROMPT),
|
|
73
|
+
("The draft says `I'll report back once CI ends` today.", BED_PROMPT),
|
|
74
|
+
("```\nI'll report back once CI ends.\n```", BED_PROMPT),
|
|
75
|
+
("I'll merge each lint fix once the bots report back.", BED_PROMPT),
|
|
76
|
+
("Both checkers are running. I continue when they report.", BED_PROMPT),
|
|
77
|
+
("Both builds passed.", BED_PROMPT),
|
|
78
|
+
(PROMISE_REPLY, "report back when the run ends"),
|
|
79
|
+
(PROMISE_REPLY, "don't stop until it is merged, then give me a summary"),
|
|
80
|
+
(PROMISE_REPLY, "do not merge yet; send me a summary when CI ends"),
|
|
81
|
+
(PROMISE_REPLY, "without breaking main, fix it and report back"),
|
|
82
|
+
(PROMISE_REPLY, "nothing else, report when done"),
|
|
83
|
+
(PROMISE_REPLY, "no, report back once merged"),
|
|
84
|
+
(PROMISE_REPLY, 'Fix it and give me a "summary" at the end'),
|
|
85
|
+
(PROMISE_REPLY, "No rush. Report back when done."),
|
|
86
|
+
(PROMISE_REPLY, "I don't want to babysit this. Let me know when it lands"),
|
|
87
|
+
],
|
|
88
|
+
)
|
|
89
|
+
def test_should_pass_a_reply_with_no_unasked_promise(reply_text: str, prompt_text: str) -> None:
|
|
90
|
+
assert promised_report_phrase(reply_text, prompt_text) is None
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@pytest.mark.parametrize(
|
|
94
|
+
("reply_text", "prompt_text", "expected_list"),
|
|
95
|
+
[
|
|
96
|
+
(DEFERRED_REPLY, DEFERRED_PROMPT, OpenItemList(DEFERRED_LEAD, 5)),
|
|
97
|
+
(f"## Next steps\n\n{THREE_BULLETS}", DEFERRED_PROMPT, OpenItemList("## Next steps", 3)),
|
|
98
|
+
(
|
|
99
|
+
"Open items:\n\n| Item | State |\n|---|---|\n| Retry | open |\n| Docs | open |\n| Branch | open |",
|
|
100
|
+
DEFERRED_PROMPT,
|
|
101
|
+
OpenItemList("Open items:", 3),
|
|
102
|
+
),
|
|
103
|
+
(f"Remaining:\n{THREE_BULLETS}", DEFERRED_PROMPT, OpenItemList("Remaining:", 3)),
|
|
104
|
+
(
|
|
105
|
+
"Still open:\n\n- The retry budget.\n\n It needs a number.\n\n- The docs page.\n- The stale branch.",
|
|
106
|
+
DEFERRED_PROMPT,
|
|
107
|
+
OpenItemList("Still open:", 3),
|
|
108
|
+
),
|
|
109
|
+
(DEFERRED_REPLY, "no list please, ask me instead", OpenItemList(DEFERRED_LEAD, 5)),
|
|
110
|
+
(DEFERRED_REPLY, "what's on the to-do list?", OpenItemList(DEFERRED_LEAD, 5)),
|
|
111
|
+
(DEFERRED_REPLY, "the bullet journal app needs a fix", OpenItemList(DEFERRED_LEAD, 5)),
|
|
112
|
+
(
|
|
113
|
+
DEFERRED_REPLY,
|
|
114
|
+
"<system-reminder>list them</system-reminder> go on",
|
|
115
|
+
OpenItemList(DEFERRED_LEAD, 5),
|
|
116
|
+
),
|
|
117
|
+
],
|
|
118
|
+
)
|
|
119
|
+
def test_should_flag_a_run_of_open_items_under_an_open_item_lead(
|
|
120
|
+
reply_text: str, prompt_text: str, expected_list: OpenItemList
|
|
121
|
+
) -> None:
|
|
122
|
+
assert open_item_list(reply_text, prompt_text) == expected_list
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@pytest.mark.parametrize(
|
|
126
|
+
("reply_text", "prompt_text"),
|
|
127
|
+
[
|
|
128
|
+
(f"Changed files:\n\n{THREE_BULLETS}\n- The hook.\n- The test.", DEFERRED_PROMPT),
|
|
129
|
+
("Deferred:\n\n- The retry budget.\n- The docs page.", DEFERRED_PROMPT),
|
|
130
|
+
(f"Nothing deferred.\n\n{THREE_BULLETS}", DEFERRED_PROMPT),
|
|
131
|
+
(f"Skipped, with reasons\n\n{THREE_BULLETS}\n- The hook.", DEFERRED_PROMPT),
|
|
132
|
+
(f"Deferred:\n\n```\n{THREE_BULLETS}\n```", DEFERRED_PROMPT),
|
|
133
|
+
(f"Deferred:\n\n<details>\n{THREE_BULLETS}\n</details>", DEFERRED_PROMPT),
|
|
134
|
+
(
|
|
135
|
+
"Deferred:\n\n> - The retry budget.\n> - The docs page.\n> - The stale branch.",
|
|
136
|
+
DEFERRED_PROMPT,
|
|
137
|
+
),
|
|
138
|
+
(DEFERRED_REPLY, "list the deferred items as bullets"),
|
|
139
|
+
(DEFERRED_REPLY, "don't use a table; list the items"),
|
|
140
|
+
(DEFERRED_REPLY, "no questions, just list them"),
|
|
141
|
+
(DEFERRED_REPLY, "Not a wall of text. A list of what is left is fine."),
|
|
142
|
+
],
|
|
143
|
+
)
|
|
144
|
+
def test_should_pass_a_reply_with_no_unasked_open_item_list(
|
|
145
|
+
reply_text: str, prompt_text: str
|
|
146
|
+
) -> None:
|
|
147
|
+
assert open_item_list(reply_text, prompt_text) is None
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
@pytest.mark.parametrize(
|
|
151
|
+
"lead",
|
|
152
|
+
[
|
|
153
|
+
"I fixed the three follow-ups you flagged:",
|
|
154
|
+
"All pending checks passed:",
|
|
155
|
+
"I closed the remaining review threads:",
|
|
156
|
+
"I removed the `deferred` flag from:",
|
|
157
|
+
'The test named "pending jobs" now covers:',
|
|
158
|
+
"The test named “pending jobs” now covers:",
|
|
159
|
+
"I resolved all outstanding comments:",
|
|
160
|
+
"Every remaining test now passes:",
|
|
161
|
+
"Merged the pending pull requests:",
|
|
162
|
+
"Completed to-dos:",
|
|
163
|
+
"Closed follow-ups:",
|
|
164
|
+
],
|
|
165
|
+
)
|
|
166
|
+
def test_should_pass_a_list_of_finished_work_whose_lead_names_follow_ups(lead: str) -> None:
|
|
167
|
+
assert open_item_list(f"{lead}\n{THREE_BULLETS}", DEFERRED_PROMPT) is None
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@pytest.mark.parametrize(
|
|
171
|
+
"lead",
|
|
172
|
+
[
|
|
173
|
+
DEFERRED_LEAD,
|
|
174
|
+
"Open items:",
|
|
175
|
+
"Still open:",
|
|
176
|
+
"Not done yet:",
|
|
177
|
+
"Deferred:",
|
|
178
|
+
"Next steps:",
|
|
179
|
+
"Follow-ups:",
|
|
180
|
+
"What I fixed and what I deferred:",
|
|
181
|
+
"Remaining work after the merged fixes:",
|
|
182
|
+
"Follow-ups I did not get to:",
|
|
183
|
+
"Pending your decision:",
|
|
184
|
+
"Things I sidestepped:",
|
|
185
|
+
"Unresolved after this round:",
|
|
186
|
+
"Follow-ups not yet merged:",
|
|
187
|
+
"Follow-ups that aren't fixed:",
|
|
188
|
+
"Remaining tasks, not done:",
|
|
189
|
+
],
|
|
190
|
+
)
|
|
191
|
+
def test_should_flag_a_list_whose_lead_names_open_work(lead: str) -> None:
|
|
192
|
+
assert open_item_list(f"{lead}\n{THREE_BULLETS}", DEFERRED_PROMPT) == OpenItemList(lead, 3)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def test_should_flag_a_promise_to_report_once_a_running_agent_finishes() -> None:
|
|
196
|
+
reply_text = "The lint job is still running, and I'll report once it finishes."
|
|
197
|
+
prompt_text = "<task-notification>the reuse agent finished</task-notification>"
|
|
198
|
+
assert promised_report_phrase(reply_text, prompt_text) == "I'll report once"
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@pytest.mark.parametrize(
|
|
202
|
+
"lead",
|
|
203
|
+
["Remaining tasks, now done:", "Open items, all fixed:", "Follow-ups, already merged:", "Pending checks, passed:"],
|
|
204
|
+
)
|
|
205
|
+
def test_should_pass_a_lead_that_ends_in_a_completion_word(lead: str) -> None:
|
|
206
|
+
assert open_item_list(f"{lead}\n{THREE_BULLETS}", DEFERRED_PROMPT) is None
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@pytest.mark.parametrize(
|
|
210
|
+
"prompt_text",
|
|
211
|
+
[
|
|
212
|
+
"Fix the report page.",
|
|
213
|
+
"The summary card is cut off on mobile, fix it",
|
|
214
|
+
"Fix the report page, then deploy it",
|
|
215
|
+
"rename the recap table",
|
|
216
|
+
],
|
|
217
|
+
)
|
|
218
|
+
def test_should_hold_a_promise_when_the_prompt_names_a_report_as_a_noun(prompt_text: str) -> None:
|
|
219
|
+
assert promised_report_phrase(PROMISE_REPLY, prompt_text) == "when you get back"
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@pytest.mark.parametrize(
|
|
223
|
+
("prompt_text", "is_list_ask"),
|
|
224
|
+
[
|
|
225
|
+
("list the deferred items as bullets", True),
|
|
226
|
+
("put the open calls in a table", True),
|
|
227
|
+
("don't list them, just fix them", False),
|
|
228
|
+
("Fix the build", False),
|
|
229
|
+
],
|
|
230
|
+
)
|
|
231
|
+
def test_should_report_whether_the_prompt_asks_for_a_list(prompt_text: str, is_list_ask: bool) -> None:
|
|
232
|
+
assert prompt_asks_for_list(prompt_text) is is_list_ask
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
SPLIT_LIST_REPLY = (
|
|
236
|
+
"Open calls:\n\n- keep the cache\n- drop the flag\n- rename the job\n\n"
|
|
237
|
+
"Done this turn:\n\n- fixed the lint\n- merged the docs\n"
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def test_should_count_the_items_in_the_run_under_the_lead() -> None:
|
|
242
|
+
assert item_count_under(SPLIT_LIST_REPLY, "Open calls:") == 3
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def test_should_count_every_item_line_when_no_run_follows_the_lead() -> None:
|
|
246
|
+
assert item_count_under(SPLIT_LIST_REPLY, "three calls still wait on you") == 5
|
|
247
|
+
assert item_count_under("Before.\n```\n- fenced\n```\n- one\n- two", "nothing here") == 2
|