claude-dev-env 8.122.0 → 8.123.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.
@@ -0,0 +1,167 @@
1
+ """Constants for the closing question round Stop gate.
2
+
3
+ Groups: the payload and transcript fields that mark a stop the gate leaves
4
+ alone, the transcript text each cheap scan looks for, the time and size
5
+ budget, the wording that marks an open item, the masking of indented code,
6
+ the declaration line, the hold cap, and the two hold reasons.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import re
12
+
13
+ from hooks_constants.open_tasks_stop_gate_constants import (
14
+ ALL_QUESTION_TOOL_NAMES,
15
+ TOOL_RESULT_BLOCK_TYPE,
16
+ )
17
+
18
+ SUBAGENT_ID_KEY = "agent_id"
19
+ BACKGROUND_TASKS_KEY = "background_tasks"
20
+ SESSION_ATTENDED_ENVIRONMENT_VARIABLE = "CLAUDE_CODE_SESSION_ATTENDED"
21
+ HEADLESS_SESSION_ATTENDED_TEXT = "0"
22
+ TURN_ORIGIN_KEY = "turnOrigin"
23
+ HUMAN_TURN_ORIGIN = "human"
24
+ IS_SIDECHAIN_KEY = "isSidechain"
25
+ ATTENDED_SESSION_TEXT = "1"
26
+ LAST_ASSISTANT_MESSAGE_KEY = "last_assistant_message"
27
+ TOOL_USE_BLOCK_ID_KEY = "id"
28
+ IS_ERROR_KEY = "is_error"
29
+
30
+ TURN_ORIGIN_SCAN_TEXT = f'"{TURN_ORIGIN_KEY}"'
31
+ USER_ROLE_SCAN_TEXT = '"user"'
32
+ TOOL_RESULT_SCAN_TEXT = f'"{TOOL_RESULT_BLOCK_TYPE}"'
33
+ ASSISTANT_SCAN_TEXT = '"assistant"'
34
+ ALL_QUESTION_TOOL_NAME_SCAN_TEXTS = tuple(
35
+ f'"{each_tool_name}"' for each_tool_name in sorted(ALL_QUESTION_TOOL_NAMES)
36
+ )
37
+
38
+ STOP_DEADLINE_SECONDS = 7.0
39
+ WATCHDOG_GRACE_SECONDS = 1.0
40
+ DECISION_PROCESS_FLAG = "--decide"
41
+ STDIN_WATCHDOG_SECONDS = 8.5
42
+ OUTPUT_WATCHDOG_SECONDS = 1.0
43
+ MAXIMUM_SCANNED_BYTES = 16 * 1024 * 1024
44
+ MAXIMUM_PAYLOAD_BYTES = 16 * 1024 * 1024
45
+ MAXIMUM_SCANNED_TEXT_BYTES = 2 * 1024 * 1024
46
+ LINE_FEED_BYTES = b"\n"
47
+ ESCAPED_ASCII_TEXT = "\\u00"
48
+ ESCAPED_PRINTABLE_ASCII_PATTERN = re.compile(r"\\u00[2-7][0-9a-fA-F]")
49
+ MARKER_SCAN_WINDOW_CHARACTERS = 1024 * 1024
50
+ MARKER_SCAN_OVERLAP_CHARACTERS = 128
51
+ MARKER_SCAN_LOOKAHEAD_CHARACTERS = 4
52
+ SEPARATOR_RUN_PATTERN = re.compile(r"[\s-]{2,}")
53
+ HYPHEN_CHARACTER = "-"
54
+
55
+ OPEN_ITEM_MARKER_PATTERN = re.compile(
56
+ r"(?<![^\W_])(?<![^\W_]_)(?<![^\W_]__)(?<![^\W_]___)(?:"
57
+ r"deferred|defer|defers|deferring|deferrals?"
58
+ r"|follow-?ups?"
59
+ r"|(?:a|the|another|one)\s+follow\s+ups?"
60
+ r"|follow\s+up\s+(?:pr|pull\s+request|issue|task|ticket|change|commit)"
61
+ r"|parked"
62
+ r"|out[\s-]+of[\s-]+scope"
63
+ r"|not\s+covered"
64
+ r"|for\s+later"
65
+ r"|later\s+(?:pull\s+request|pr)"
66
+ r"|known\s+(?:gap|limitation)s?"
67
+ r"|open\s+questions?"
68
+ r"|unresolved"
69
+ r"|uncertain|uncertainty"
70
+ r"|not\s+sure"
71
+ r"|unsure"
72
+ r"|unclear"
73
+ r"|i\s+assumed|we\s+assumed|(?:i|we)\s+assume"
74
+ r"|assuming"
75
+ r"|assumptions?"
76
+ r"|unverified"
77
+ r"|(?:could\s+not|couldn['\u2019]t|did\s+not)\s+verify"
78
+ r"|untested"
79
+ r"|not\s+tested"
80
+ r"|(?:didn['’]t|did\s+not)\s+test"
81
+ r"|you\s+may\s+want\s+to"
82
+ r"|your\s+judge?ment"
83
+ r"|(?:could\s+not|couldn['’]t|unable\s+to)\s+confirm"
84
+ r"|separate\s+(?:pr|pull\s+request)"
85
+ r"|not\s+yet\s+implemented"
86
+ r"|judge?ment\s+calls?"
87
+ r"|your\s+call"
88
+ r"|up\s+to\s+you"
89
+ r"|needs\s+your\s+(?:decision|judge?ment|approval)"
90
+ r"|needs?\s+your\s+input"
91
+ r"|i\s+need\s+you\s+to"
92
+ r"|pending"
93
+ r"|todo|tbd"
94
+ r"|skipped|skipping"
95
+ r"|not\s+done"
96
+ r"|blocked"
97
+ r"|(?:didn['’]t|not)\s+run"
98
+ r"|(?:could\s+not|couldn['’]t)\s+reproduce"
99
+ r"|left\s+(?:it|this|that|them|these)\s+for\s+you"
100
+ r"|for\s+you\s+to\s+decide"
101
+ r"|(?:waiting|waits)\s+on\s+you"
102
+ r")(?![^\W_])(?!_{1,3}[^\W_])",
103
+ re.IGNORECASE,
104
+ )
105
+ INDENTED_CODE_LINE_PATTERN = re.compile(r"^(?: {4}|\t)")
106
+ LIST_ITEM_LINE_PATTERN = re.compile(r"^ {0,3}(?:[-*+]|\d{1,9}[.)])[ \t]+\S")
107
+ PATH_JOINING_CHARACTERS = "./\\"
108
+ PATH_SEPARATOR_PATTERN = re.compile(r"[/\\]")
109
+ PATH_BREAK_PATTERN = re.compile(r"\s")
110
+ FILE_NAME_PATTERN = re.compile(r"[^\s/\\]+\.(?P<extension>[a-z0-9]{1,5})")
111
+ PATH_EDGE_CHARACTERS = "\"'`()[]<>{},;:!?.*_~\u201c\u201d\u2018\u2019\u00ab\u00bb\u2039\u203a\u2026"
112
+ PATH_REACH_CHARACTERS = 96
113
+ MINIMUM_PATH_SEGMENT_COUNT = 2
114
+ NO_OPEN_ITEMS_DECLARATION = "Open items: none."
115
+ DECLARATION_LINE_PATTERN = re.compile(
116
+ r"(?P<mark>\*\*|__|\*|_|)"
117
+ + re.escape(NO_OPEN_ITEMS_DECLARATION.removesuffix("."))
118
+ + r"\.?(?P=mark)"
119
+ )
120
+
121
+ MAXIMUM_HOLD_COUNT = 2
122
+ FEEDBACK_OPENING_LENGTH = 200
123
+ MAXIMUM_QUOTED_LINE_COUNT = 8
124
+ MAXIMUM_QUOTED_LINE_LENGTH = 160
125
+ CLIPPED_LINE_END = "..."
126
+
127
+ CLOSING_ROUND_REASON_LEAD = (
128
+ "This session wrote about open items and sent no question card after them."
129
+ )
130
+ WORK_REASON_LEAD = (
131
+ "This session did work and ended without a question card or the declaration line."
132
+ )
133
+ ALL_REASON_LEADS = (CLOSING_ROUND_REASON_LEAD, WORK_REASON_LEAD)
134
+ OPEN_ITEM_LINES_LABEL = "The lines:"
135
+ QUOTED_LINE_TEMPLATE = '"{line}"'
136
+ REMAINING_LINES_TEMPLATE = "Earlier lines left out here: {remaining_count}."
137
+ CODE_SPAN_SHOWN_TEXT = "`...`"
138
+ READ_ITEMS_INSTRUCTION = (
139
+ "Read the task list, your notes, and the live state of each item. Drop each item that is done."
140
+ )
141
+ CARD_INSTRUCTION = (
142
+ "Write one short chat brief that covers every item that still stands, with each link in it."
143
+ " question_brief_gate.py counts every chat word and every list or table item this turn wrote"
144
+ " since the last typed prompt or question result, the reply above included, and refuses a"
145
+ " question past 450 words or 15 items. Keep the brief short enough that the total stays"
146
+ " inside that limit. When the reply above is already over it, write a one-line brief and send"
147
+ " the cards: that first call is refused, and a refused question starts a new count, so send"
148
+ " the same cards again at once with no new text. Send each item as its own AskUserQuestion"
149
+ " question. Put at most four questions in one call, so a longer round takes more calls. Give"
150
+ " each question a header of 12 characters or fewer and two or three options, your"
151
+ " recommendation first. Give each option a one-sentence description. A card shows plain"
152
+ " text, so write a link in a card as a bare URL. After the user answers, act on each answer"
153
+ " and close with what you did with it. Do not restate the items, because open-item lines"
154
+ " written after the cards start a new round. When that work leaves nothing open, end the"
155
+ f" reply with the line {NO_OPEN_ITEMS_DECLARATION}"
156
+ )
157
+ CLOSING_ROUND_INSTRUCTION = (
158
+ f"{READ_ITEMS_INSTRUCTION} {CARD_INSTRUCTION} When the lines name nothing that is still open,"
159
+ " send one question that says so and lets the user add an item."
160
+ )
161
+ WORK_INSTRUCTION = (
162
+ f"{READ_ITEMS_INSTRUCTION} When something is deferred, uncertain, or needs or can use the"
163
+ " user's judgment, brief it and send the cards, as follows."
164
+ f" {CARD_INSTRUCTION} When nothing is, do not list what is not open: end the reply with this"
165
+ f" exact line alone, in plain text with no backticks or list marker: {NO_OPEN_ITEMS_DECLARATION}"
166
+ )
167
+ REASON_PART_SEPARATOR = "\n"
@@ -0,0 +1,92 @@
1
+ import pytest
2
+
3
+ from hooks_constants.closing_question_round_gate_constants import (
4
+ ALL_REASON_LEADS,
5
+ CLOSING_ROUND_INSTRUCTION,
6
+ DECLARATION_LINE_PATTERN,
7
+ ESCAPED_PRINTABLE_ASCII_PATTERN,
8
+ FILE_NAME_PATTERN,
9
+ PATH_EDGE_CHARACTERS,
10
+ NO_OPEN_ITEMS_DECLARATION,
11
+ OPEN_ITEM_MARKER_PATTERN,
12
+ OUTPUT_WATCHDOG_SECONDS,
13
+ STDIN_WATCHDOG_SECONDS,
14
+ WORK_INSTRUCTION,
15
+ )
16
+
17
+
18
+ def test_marker_pattern_should_find_follow_up_and_pending() -> None:
19
+ all_markers = [
20
+ each_match.group(0)
21
+ for each_match in OPEN_ITEM_MARKER_PATTERN.finditer("A follow-up is pending.")
22
+ ]
23
+ assert all_markers == ["follow-up", "pending"]
24
+
25
+
26
+ @pytest.mark.parametrize(
27
+ ("open_line", "marker"),
28
+ [
29
+ ("You may want to decide on the timeout.", "You may want to"),
30
+ ("I didn't test the retry path.", "didn't test"),
31
+ ("I'll do the docs in a separate PR.", "separate PR"),
32
+ ("I was unable to confirm the size.", "unable to confirm"),
33
+ ("The warm-up is not yet implemented.", "not yet implemented"),
34
+ ("This rests on your judgment.", "your judgment"),
35
+ ],
36
+ )
37
+ def test_marker_pattern_should_find_each_added_wording(open_line: str, marker: str) -> None:
38
+ marker_match = OPEN_ITEM_MARKER_PATTERN.search(open_line)
39
+ assert marker_match is not None
40
+ assert marker_match.group(0) == marker
41
+
42
+
43
+ def test_declaration_should_carry_no_marker_and_end_both_instructions() -> None:
44
+ assert OPEN_ITEM_MARKER_PATTERN.search(NO_OPEN_ITEMS_DECLARATION) is None
45
+ assert WORK_INSTRUCTION.endswith(NO_OPEN_ITEMS_DECLARATION)
46
+ assert NO_OPEN_ITEMS_DECLARATION in CLOSING_ROUND_INSTRUCTION
47
+ assert len(set(ALL_REASON_LEADS)) == 2
48
+
49
+
50
+ @pytest.mark.parametrize(
51
+ ("json_text", "is_escaped_printable"),
52
+ [('"\\u0074urnOrigin"', True), ('"\\u007E"', True), ('"\\u001b[0m"', False), ('"\\u00e9"', False)],
53
+ )
54
+ def test_escaped_printable_ascii_pattern_should_find_only_printable_ascii_escapes(
55
+ json_text: str, is_escaped_printable: bool
56
+ ) -> None:
57
+ assert bool(ESCAPED_PRINTABLE_ASCII_PATTERN.search(json_text)) is is_escaped_printable
58
+
59
+
60
+ def test_watchdogs_should_end_a_held_stop_inside_the_host_timeout_of_ten_seconds() -> None:
61
+ assert STDIN_WATCHDOG_SECONDS + OUTPUT_WATCHDOG_SECONDS < 10
62
+
63
+
64
+ @pytest.mark.parametrize(
65
+ ("declaration_line", "is_declaration"),
66
+ [
67
+ ("Open items: none.", True),
68
+ ("Open items: none", True),
69
+ ("**Open items: none**", True),
70
+ ("Open items: none..", False),
71
+ ("**Open items: none*", False),
72
+ ],
73
+ )
74
+ def test_declaration_line_pattern_should_leave_the_final_period_optional(
75
+ declaration_line: str, is_declaration: bool
76
+ ) -> None:
77
+ assert (DECLARATION_LINE_PATTERN.fullmatch(declaration_line) is not None) is is_declaration
78
+
79
+
80
+ @pytest.mark.parametrize(
81
+ ("segment_text", "is_file_name"),
82
+ [("todo.md", True), ("notes.json", True), ("TODO.Ship", False), ("e.g.pending", False)],
83
+ )
84
+ def test_file_name_pattern_should_take_a_short_lower_case_extension(
85
+ segment_text: str, is_file_name: bool
86
+ ) -> None:
87
+ assert (FILE_NAME_PATTERN.fullmatch(segment_text) is not None) is is_file_name
88
+
89
+
90
+ def test_path_edge_characters_should_strip_quotes_and_emphasis_around_a_file_name() -> None:
91
+ for each_wrapped_name in ["**todo.md**", "_todo.md_", "~~todo.md~~", "\u201ctodo.md\u201d", "\u2039todo.md\u203a", "(todo.md)."]:
92
+ assert each_wrapped_name.strip(PATH_EDGE_CHARACTERS) == "todo.md"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-dev-env",
3
- "version": "8.122.0",
3
+ "version": "8.123.0",
4
4
  "description": "Claude Code development standards — rules, hooks, agents, commands, and skills",
5
5
  "type": "module",
6
6
  "bin": {