claude-dev-env 8.121.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.
- package/bin/ever-registered-hooks.mjs +1 -0
- package/docs/rule-guides/question-presentation.md +4 -0
- package/hooks/blocking/closing_question_round_gate.py +387 -0
- package/hooks/blocking/closing_question_round_lines.py +109 -0
- package/hooks/blocking/closing_question_round_open_items.py +348 -0
- package/hooks/blocking/closing_question_round_transcript.py +344 -0
- package/hooks/blocking/sent_file_question_detector.py +340 -0
- package/hooks/blocking/sent_file_question_gate.py +307 -0
- package/hooks/blocking/sent_file_scan.py +209 -0
- package/hooks/blocking/test_closing_question_round_gate.py +983 -0
- package/hooks/blocking/test_closing_question_round_gate_declaration.py +307 -0
- package/hooks/blocking/test_closing_question_round_gate_work.py +349 -0
- package/hooks/blocking/test_closing_question_round_lines.py +70 -0
- package/hooks/blocking/test_closing_question_round_open_items.py +238 -0
- package/hooks/blocking/test_closing_question_round_transcript.py +236 -0
- package/hooks/blocking/test_sent_file_question_detector.py +68 -0
- package/hooks/blocking/test_sent_file_question_gate.py +688 -0
- package/hooks/blocking/test_sent_file_scan.py +71 -0
- package/hooks/blocking/test_user_step_wording.py +46 -0
- package/hooks/blocking/user_step_wording.py +113 -15
- package/hooks/features/conduct-gates.md +3 -0
- package/hooks/hooks.json +10 -0
- package/hooks/hooks_constants/closing_question_round_gate_constants.py +167 -0
- package/hooks/hooks_constants/sent_file_question_gate_constants.py +261 -0
- package/hooks/hooks_constants/test_closing_question_round_gate_constants.py +92 -0
- package/hooks/hooks_constants/user_step_wording_constants.py +4 -0
- package/package.json +1 -1
- package/scripts/policy_lint/adapter_configuration.py +5 -0
- package/scripts/policy_lint/config/constants.py +1 -0
- package/scripts/tests/test_adapter_configuration.py +8 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"""Constants for the gate that keeps questions for the user out of sent files and pages."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"ALLOW_EXIT_CODE",
|
|
7
|
+
"ALL_ANSWER_SAVING_CAPABILITIES",
|
|
8
|
+
"ALL_BOLD_MARKS",
|
|
9
|
+
"ALL_FULL_WIDTH_QUESTION_MARKS",
|
|
10
|
+
"ALL_INDENTED_CODE_PREFIXES",
|
|
11
|
+
"ALL_QUOTED_QUESTION_ENDINGS",
|
|
12
|
+
"ALL_SKIPPED_PUBLISH_INPUT_KEYS",
|
|
13
|
+
"ANSWER_LABEL_PATTERN",
|
|
14
|
+
"ANSWER_OPENER_PATTERN",
|
|
15
|
+
"ARTIFACT_ACTION_INPUT_KEY",
|
|
16
|
+
"ARTIFACT_CAPABILITIES_INPUT_KEY",
|
|
17
|
+
"ARTIFACT_FILE_PATH_INPUT_KEY",
|
|
18
|
+
"ARTIFACT_PUBLISH_ACTION",
|
|
19
|
+
"ARTIFACT_TOOL_NAME",
|
|
20
|
+
"BINARY_READ_MODE",
|
|
21
|
+
"BLOCK_BREAK",
|
|
22
|
+
"BLOCK_EXIT_CODE",
|
|
23
|
+
"BOLD_MARK_COUNT",
|
|
24
|
+
"CHECK_BLOCK_WORD_PATTERN",
|
|
25
|
+
"CHOICE_COMMAND_PATTERN",
|
|
26
|
+
"CLOSING_TAG_MARK",
|
|
27
|
+
"CWD_KEY",
|
|
28
|
+
"EMPHASIS_CHARACTERS",
|
|
29
|
+
"EMPHASIS_PATTERN",
|
|
30
|
+
"FILE_PARTS_SEPARATOR",
|
|
31
|
+
"FILE_PART_BYTES",
|
|
32
|
+
"FILE_PATH_SEPARATOR",
|
|
33
|
+
"GATE_EVENT_NAME",
|
|
34
|
+
"HEADING_CLOSE_MARKS",
|
|
35
|
+
"HEADING_MARK",
|
|
36
|
+
"HEADING_OPENER_PATTERN",
|
|
37
|
+
"LABEL_CHOICE_PATTERN",
|
|
38
|
+
"LABEL_COLON",
|
|
39
|
+
"LINE_BREAK",
|
|
40
|
+
"LIST_MARKER_PATTERN",
|
|
41
|
+
"MAXIMUM_CHOICE_WORDS",
|
|
42
|
+
"MAXIMUM_QUOTED_CHARACTERS",
|
|
43
|
+
"MAXIMUM_SENTENCE_CHARACTERS",
|
|
44
|
+
"MAXIMUM_UTF8_CONTINUATION_BYTES",
|
|
45
|
+
"MAXIMUM_WHOLE_FILE_BYTES",
|
|
46
|
+
"NUL_BYTE",
|
|
47
|
+
"OPEN_ASK_PATTERN",
|
|
48
|
+
"PARSED_READ_BUDGET_SECONDS",
|
|
49
|
+
"PARTIAL_READ_MESSAGE",
|
|
50
|
+
"PARTIAL_READ_NOTE",
|
|
51
|
+
"PLAIN_HEADING_BREAK",
|
|
52
|
+
"PLAIN_READ_BUDGET_SECONDS",
|
|
53
|
+
"QUESTION_FOUND_MESSAGE",
|
|
54
|
+
"QUESTION_LABEL_PATTERN",
|
|
55
|
+
"QUESTION_MARK",
|
|
56
|
+
"QUESTION_SECTION_PATTERN",
|
|
57
|
+
"QUOTED_SPAN_PATTERN",
|
|
58
|
+
"QUOTE_CUT_MARK",
|
|
59
|
+
"READER_ADDRESS_PATTERN",
|
|
60
|
+
"READER_CHOICE_PATTERN",
|
|
61
|
+
"READER_WISH_PATTERN",
|
|
62
|
+
"REPLY_OPTION_PATTERN",
|
|
63
|
+
"REPLY_REQUEST_PATTERN",
|
|
64
|
+
"REQUEST_OPENER_PATTERN",
|
|
65
|
+
"RESPONSE_PROMPT_PATTERN",
|
|
66
|
+
"SCAN_TIMEOUT_MESSAGE",
|
|
67
|
+
"SENTENCE_EDGE_CHARACTERS",
|
|
68
|
+
"SENTENCE_EDGE_JOIN",
|
|
69
|
+
"SENTENCE_PATTERN",
|
|
70
|
+
"SPACE",
|
|
71
|
+
"SPACE_RUN_PATTERN",
|
|
72
|
+
"SYSTEM_MESSAGE_KEY",
|
|
73
|
+
"TABLE_CELL_SEPARATOR",
|
|
74
|
+
"TABLE_DIVIDER_CELL_PATTERN",
|
|
75
|
+
"TABLE_ROW_PATTERN",
|
|
76
|
+
"TAG_CLOSE",
|
|
77
|
+
"TAG_OPEN",
|
|
78
|
+
"TASK_BOX_MARK",
|
|
79
|
+
"TASK_BOX_PATTERN",
|
|
80
|
+
"TASK_CHECK_PATTERN",
|
|
81
|
+
"TOOL_INPUT_KEY",
|
|
82
|
+
"TOOL_NAME_KEY",
|
|
83
|
+
"TRAILING_CLOSERS",
|
|
84
|
+
"TRAILING_MARKS",
|
|
85
|
+
"UNIT_START_PATTERN",
|
|
86
|
+
"UTF8_CONTINUATION_BYTES",
|
|
87
|
+
"UTF8_ENCODING",
|
|
88
|
+
"WH_CHOICE_PATTERN",
|
|
89
|
+
"WRITER_VOICE_HEADING_PATTERN",
|
|
90
|
+
"YES_OR_NO_REQUEST_PATTERN",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
ALLOW_EXIT_CODE = 0
|
|
94
|
+
BLOCK_EXIT_CODE = 2
|
|
95
|
+
GATE_EVENT_NAME = "PreToolUse"
|
|
96
|
+
TOOL_NAME_KEY = "tool_name"
|
|
97
|
+
TOOL_INPUT_KEY = "tool_input"
|
|
98
|
+
CWD_KEY = "cwd"
|
|
99
|
+
ARTIFACT_TOOL_NAME = "Artifact"
|
|
100
|
+
ARTIFACT_ACTION_INPUT_KEY = "action"
|
|
101
|
+
ARTIFACT_PUBLISH_ACTION = "publish"
|
|
102
|
+
ARTIFACT_FILE_PATH_INPUT_KEY = "file_path"
|
|
103
|
+
ARTIFACT_CAPABILITIES_INPUT_KEY = "capabilities"
|
|
104
|
+
ALL_SKIPPED_PUBLISH_INPUT_KEYS = ("asset", "type_url")
|
|
105
|
+
LINE_BREAK = "\n"
|
|
106
|
+
HEADING_MARK = "# "
|
|
107
|
+
QUESTION_MARK = "?"
|
|
108
|
+
TRAILING_MARKS = "*_\"'’”)] \t"
|
|
109
|
+
TABLE_CELL_SEPARATOR = "|"
|
|
110
|
+
TRAILING_CLOSERS = "*_)] \t"
|
|
111
|
+
ALL_QUOTED_QUESTION_ENDINGS = ('?"', "?'", "?’", "?”")
|
|
112
|
+
MAXIMUM_CHOICE_WORDS = 10
|
|
113
|
+
QUOTED_SPAN_PATTERN = re.compile(r'"[^"\n]{1,400}"|“[^”\n]{1,400}”')
|
|
114
|
+
HEADING_OPENER_PATTERN = re.compile(r"#{1,6}(?:[ \t]|$)")
|
|
115
|
+
HEADING_CLOSE_MARKS = "#"
|
|
116
|
+
ALL_BOLD_MARKS = ("**", "__")
|
|
117
|
+
EMPHASIS_CHARACTERS = "*_"
|
|
118
|
+
LABEL_COLON = ":"
|
|
119
|
+
ALL_INDENTED_CODE_PREFIXES = (" ", "\t")
|
|
120
|
+
ALL_FULL_WIDTH_QUESTION_MARKS = ("\uff1f", "\ufe56")
|
|
121
|
+
ALL_ANSWER_SAVING_CAPABILITIES = frozenset({"artifact", "self", "db"})
|
|
122
|
+
FILE_PART_BYTES = 131072
|
|
123
|
+
MAXIMUM_WHOLE_FILE_BYTES = 262144
|
|
124
|
+
BOLD_MARK_COUNT = 2
|
|
125
|
+
BINARY_READ_MODE = "rb"
|
|
126
|
+
NUL_BYTE = b"\x00"
|
|
127
|
+
UTF8_ENCODING = "utf-8"
|
|
128
|
+
UTF8_CONTINUATION_BYTES = range(0x80, 0xC0)
|
|
129
|
+
MAXIMUM_UTF8_CONTINUATION_BYTES = 3
|
|
130
|
+
FILE_PARTS_SEPARATOR = "\n\n"
|
|
131
|
+
MAXIMUM_QUOTED_CHARACTERS = 160
|
|
132
|
+
QUOTE_CUT_MARK = "..."
|
|
133
|
+
TABLE_ROW_PATTERN = re.compile(r"^\s*\|")
|
|
134
|
+
TABLE_DIVIDER_CELL_PATTERN = re.compile(r"^:?-+:?$")
|
|
135
|
+
LIST_MARKER_PATTERN = re.compile(r"^\s*(?:[-*+]|\d{1,3}[.)])\s+(?:\[[ xX]\]\s+)?")
|
|
136
|
+
QUESTION_LABEL_PATTERN = re.compile(r"^(?:q|question)\s*\d*\s*[:.]\s+", re.IGNORECASE)
|
|
137
|
+
ANSWER_LABEL_PATTERN = re.compile(r"^(?:a|answer)\s*\d*\s*[:.]\s+", re.IGNORECASE)
|
|
138
|
+
UNIT_START_PATTERN = re.compile(
|
|
139
|
+
r"^\s{0,3}#{1,6}\s|^\s*(?:\*\*|__)|^\s*\||^\s*(?:[-*+]|\d{1,3}[.)])\s+|^(?:q|question|a|answer)\s*\d*\s*[:.]\s+",
|
|
140
|
+
re.IGNORECASE,
|
|
141
|
+
)
|
|
142
|
+
EMPHASIS_PATTERN = re.compile(r"(?<!\w)[*_]{1,3}|[*_]{1,3}(?!\w)")
|
|
143
|
+
SPACE_RUN_PATTERN = re.compile(r"\s+")
|
|
144
|
+
SENTENCE_PATTERN = re.compile(r"\S.*?(?:[.!?][\"'’”)\]*_]*(?=\s|$)|$)")
|
|
145
|
+
QUESTION_SECTION_PATTERN = re.compile(
|
|
146
|
+
r"(?:open|pending|outstanding|unresolved|remaining|unanswered)\s+questions?(?:\s+.*)?"
|
|
147
|
+
r"|questions?\s+(?:for|to|from)\b.*"
|
|
148
|
+
r"|(?:open|pending|outstanding|unresolved|remaining)\s+decisions?(?:\s+.*)?"
|
|
149
|
+
r"|decisions?\s+(?:needed|required|pending|to\s+make|for)\b.*"
|
|
150
|
+
r"|(?:need|needs|needed)\s+(?:your|you\s+to)\b.*",
|
|
151
|
+
re.IGNORECASE,
|
|
152
|
+
)
|
|
153
|
+
READER_ADDRESS_PATTERN = re.compile(r"\b(?:you|your|yours|yourself)\b", re.IGNORECASE)
|
|
154
|
+
READER_WISH_PATTERN = re.compile(
|
|
155
|
+
r"\b(?:me|want|wants|prefer|like|approve|agree|think|mind|rather|ok|okay|happy|decide|choose|pick)\b",
|
|
156
|
+
re.IGNORECASE,
|
|
157
|
+
)
|
|
158
|
+
READER_CHOICE_PATTERN = re.compile(r"\bor\b", re.IGNORECASE)
|
|
159
|
+
REQUEST_OPENER_PATTERN = re.compile(
|
|
160
|
+
r"^(?:(?:so|and|also|then|now|ok|okay)\b,?\s+)?"
|
|
161
|
+
r"(?:(?:should|shall)\s+(?:i|we)\b"
|
|
162
|
+
r"|want\s+me\b"
|
|
163
|
+
r"|(?:ok|okay|fine)\s+(?:to|if|with)\b"
|
|
164
|
+
r"|(?:is|would)\s+(?:it|that|this)\s+(?:ok|okay|alright|fine)\b"
|
|
165
|
+
r"|(?:any\s+)?(?:objections?|preferences?|thoughts)\b"
|
|
166
|
+
r"|are\s+we\s+(?:good|ready|clear|ok|okay)\b"
|
|
167
|
+
r"|would\s+it\s+(?:make\s+sense|help|be\s+better)\b"
|
|
168
|
+
r"|(?:go\s+ahead|proceed|continue|merge|ship|approve|archive|delete|keep|drop|revert|rerun|retry)\b)",
|
|
169
|
+
re.IGNORECASE,
|
|
170
|
+
)
|
|
171
|
+
ANSWER_OPENER_PATTERN = re.compile(r"^(?:yes|no|nope|yep)(?:[.,;:!]|$)", re.IGNORECASE)
|
|
172
|
+
WH_CHOICE_PATTERN = re.compile(
|
|
173
|
+
r"^(?:which|what|when|who)\b.*?\b(?:works?\s+(?:best|better)|best|better|preferred|should\s+(?:i|we))\b",
|
|
174
|
+
re.IGNORECASE,
|
|
175
|
+
)
|
|
176
|
+
TASK_BOX_PATTERN = re.compile(r"^\s*(?:[-*+]|\d{1,3}[.)])\s+\[[ xX]\]\s")
|
|
177
|
+
PARSED_READ_BUDGET_SECONDS = 4
|
|
178
|
+
PLAIN_READ_BUDGET_SECONDS = 4
|
|
179
|
+
MAXIMUM_SENTENCE_CHARACTERS = 2000
|
|
180
|
+
SENTENCE_EDGE_CHARACTERS = 400
|
|
181
|
+
SENTENCE_EDGE_JOIN = " ... "
|
|
182
|
+
TAG_OPEN = "<"
|
|
183
|
+
TAG_CLOSE = ">"
|
|
184
|
+
CLOSING_TAG_MARK = "/"
|
|
185
|
+
BLOCK_BREAK = "\n\n"
|
|
186
|
+
PLAIN_HEADING_BREAK = "\n\n# "
|
|
187
|
+
SPACE = " "
|
|
188
|
+
TASK_CHECK_PATTERN = re.compile(
|
|
189
|
+
r"^(?:did|have)\s+you\s+(?:already\s+)?"
|
|
190
|
+
r"(?:save|saved|run|ran|test|tested|push|pushed|commit|committed|update|updated"
|
|
191
|
+
r"|add|added|remove|removed|check|checked|read|install|installed|restart|restarted"
|
|
192
|
+
r"|close|closed|fill\s+in|filled\s+in)\b",
|
|
193
|
+
re.IGNORECASE,
|
|
194
|
+
)
|
|
195
|
+
CHECK_BLOCK_WORD_PATTERN = re.compile(
|
|
196
|
+
r"\b(?:ok|okay|fine|good|sign(?:s|ed)?\s+off|approv\w*|happy|ready|want\w*|prefer\w*"
|
|
197
|
+
r"|decid\w*|decision|agree\w*|go\s+ahead|ship\w*|merg\w*|delet\w*"
|
|
198
|
+
r"|confirm\w*|choice\w*|choos\w*|chose\w*)\b",
|
|
199
|
+
re.IGNORECASE,
|
|
200
|
+
)
|
|
201
|
+
REPLY_REQUEST_PATTERN = re.compile(
|
|
202
|
+
r"^(?:please\s+)?(?:let\s+(?:me|us)\s+know|get\s+back\s+to\s+(?:me|us)"
|
|
203
|
+
r"|advise\s+(?:me|us|which|whether|if|on|how|when)"
|
|
204
|
+
r"|send\s+(?:me|us)\s+(?:your|(?:a|an|the)\s+(?:pick|choice|answer|reply|decision|preference|vote))"
|
|
205
|
+
r"|tell\s+(?:me|us)\s+(?:which|what|whether|if|how|when|where|who|your)"
|
|
206
|
+
r"|give\s+(?:me|us)\s+your)\b"
|
|
207
|
+
r"|^please\s+(?:advise|confirm|choose|pick|select|decide|approve|reply|respond)\b",
|
|
208
|
+
re.IGNORECASE,
|
|
209
|
+
)
|
|
210
|
+
CHOICE_COMMAND_PATTERN = re.compile(
|
|
211
|
+
r"^(?:reply|answer|respond|choose|pick|select|decide)\b", re.IGNORECASE
|
|
212
|
+
)
|
|
213
|
+
REPLY_OPTION_PATTERN = re.compile(
|
|
214
|
+
r"\byes\s+or\s+no\b|\bone\s+of\s+(?:the\s+)?(?:two|three|four|both|these|those|them)\b",
|
|
215
|
+
re.IGNORECASE,
|
|
216
|
+
)
|
|
217
|
+
YES_OR_NO_REQUEST_PATTERN = re.compile(
|
|
218
|
+
r"(?:^|,\s*|\bplease\s+)(?:reply|answer|respond|choose|pick)\s+(?:\w+\s+){0,3}?yes\s+or\s+no\b",
|
|
219
|
+
re.IGNORECASE,
|
|
220
|
+
)
|
|
221
|
+
LABEL_CHOICE_PATTERN = re.compile(
|
|
222
|
+
r"\b(?:[A-Z0-9]|[Oo]ption\s+\w+)\s+or\s+(?:[A-Z0-9]|[Oo]ption\s+\w+)\b"
|
|
223
|
+
)
|
|
224
|
+
TASK_BOX_MARK = "- [ ] "
|
|
225
|
+
WRITER_VOICE_HEADING_PATTERN = re.compile(
|
|
226
|
+
r"\b(?:should|shall)\s+(?:i|we)\b|\b(?:do|would|will|can)\s+you\b"
|
|
227
|
+
r"|\bwant\s+me\b|\byour\b|\bprefer\w*",
|
|
228
|
+
re.IGNORECASE,
|
|
229
|
+
)
|
|
230
|
+
SYSTEM_MESSAGE_KEY = "systemMessage"
|
|
231
|
+
FILE_PATH_SEPARATOR = ", "
|
|
232
|
+
SCAN_TIMEOUT_MESSAGE = (
|
|
233
|
+
"sent_file_question_gate could not finish reading {file_paths} within {budget_seconds} s, "
|
|
234
|
+
"with the HTML parser or with the plain tag-stripping read, "
|
|
235
|
+
"so it did not check them for questions for the user. "
|
|
236
|
+
"Ask any question through AskUserQuestion (Codex: request_user_input), not inside the file."
|
|
237
|
+
)
|
|
238
|
+
PARTIAL_READ_NOTE = (
|
|
239
|
+
" The gate read only the first and last 128 KB of {file_path}, which is over 256 KB."
|
|
240
|
+
)
|
|
241
|
+
PARTIAL_READ_MESSAGE = (
|
|
242
|
+
"sent_file_question_gate read only the first and last 128 KB of {file_paths}, "
|
|
243
|
+
"which is over 256 KB, and found no question for the user there. "
|
|
244
|
+
"The middle of the file was not checked."
|
|
245
|
+
)
|
|
246
|
+
OPEN_ASK_PATTERN = re.compile(r"^(?:can|could|may)\s+(?:i|we)\b", re.IGNORECASE)
|
|
247
|
+
RESPONSE_PROMPT_PATTERN = re.compile(
|
|
248
|
+
r"^(?:please\s+)?(?:reply|answer|respond|confirm|choose|pick|select|say|type|tell\s+me|let\s+me\s+know)\b",
|
|
249
|
+
re.IGNORECASE,
|
|
250
|
+
)
|
|
251
|
+
QUESTION_FOUND_MESSAGE = (
|
|
252
|
+
'{file_path} carries a question for the user: "{question}". '
|
|
253
|
+
"A question inside a sent file or page reaches the user with no answer card, "
|
|
254
|
+
"and the user may read only the question cards. "
|
|
255
|
+
"Ask each question through AskUserQuestion (Codex: request_user_input), one question per card, "
|
|
256
|
+
"with its context and each choice's effect in the card. "
|
|
257
|
+
"Remove the questions from the file, keep its facts and context, and send it again. "
|
|
258
|
+
"A page that collects the answer itself, such as option cards, declares the db or artifact "
|
|
259
|
+
"capability that saves the answer, and this gate lets it through. "
|
|
260
|
+
"When the line asks the user nothing, reword it as a statement."
|
|
261
|
+
)
|
|
@@ -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"
|
|
@@ -70,6 +70,10 @@ ALL_HTML_INLINE_TAGS = frozenset(
|
|
|
70
70
|
}
|
|
71
71
|
)
|
|
72
72
|
HTML_LINE_BREAK_TAG = "br"
|
|
73
|
+
HTML_INPUT_TAG = "input"
|
|
74
|
+
HTML_INPUT_TYPE_ATTRIBUTE = "type"
|
|
75
|
+
HTML_CHECKBOX_INPUT_TYPE = "checkbox"
|
|
76
|
+
ALL_HTML_HEADING_TAGS = frozenset({"h1", "h2", "h3", "h4", "h5", "h6", "summary", "dt"})
|
|
73
77
|
HTML_SOURCE_SPACE_PATTERN = re.compile(r"[ \t\r\n\f]+")
|
|
74
78
|
HTML_SOURCE_SPACE = " "
|
|
75
79
|
HTML_BLOCK_SEPARATOR = "\n\n"
|
package/package.json
CHANGED
|
@@ -137,6 +137,7 @@ def _names_exempt_registration_path(registered_string: str) -> bool:
|
|
|
137
137
|
hooks/blocking/task_subject_outcome_gate.py -> exempt
|
|
138
138
|
hooks/blocking/artifact_dark_mode_gate.py -> exempt
|
|
139
139
|
hooks/blocking/send_user_file_worktree_root_gate.py -> exempt
|
|
140
|
+
hooks/blocking/sent_file_question_gate.py -> exempt
|
|
140
141
|
hooks/blocking/question_brief_gate.py -> exempt
|
|
141
142
|
hooks/blocking/build_eval_before_eval_write_gate.py -> exempt
|
|
142
143
|
hooks/blocking/final_reply_gate.py -> exempt
|
|
@@ -189,6 +190,10 @@ def _names_exempt_registration_path(registered_string: str) -> bool:
|
|
|
189
190
|
working directory, which the desktop file pane cannot open. It decides
|
|
190
191
|
where a sent file sits and no code or safety policy.
|
|
191
192
|
|
|
193
|
+
The sent file question gate denies a sent file or page that asks the
|
|
194
|
+
user a question, so the question goes through the question tool. It
|
|
195
|
+
decides where a question is asked and no code or safety policy.
|
|
196
|
+
|
|
192
197
|
The question brief gate denies a question call when the chat text before
|
|
193
198
|
it in the same turn is too long to read at a glance. It decides the shape
|
|
194
199
|
of a brief and no code or safety policy.
|
|
@@ -75,6 +75,7 @@ ALL_ACTION_BOUNDARY_EXEMPT_REGISTRATION_PATHS = (
|
|
|
75
75
|
"blocking/image_read_size_gate.py",
|
|
76
76
|
"blocking/artifact_dark_mode_gate.py",
|
|
77
77
|
"blocking/send_user_file_worktree_root_gate.py",
|
|
78
|
+
"blocking/sent_file_question_gate.py",
|
|
78
79
|
"blocking/question_brief_gate.py",
|
|
79
80
|
"blocking/haiku_spawn_slim_gate.py",
|
|
80
81
|
"blocking/build_eval_before_eval_write_gate.py",
|
|
@@ -170,6 +170,14 @@ def test_new_send_user_file_gate_registration_is_clean(tmp_path: Path) -> None:
|
|
|
170
170
|
assert adapters.hook_configuration_diagnostics(current_document, tmp_path) == ()
|
|
171
171
|
|
|
172
172
|
|
|
173
|
+
def test_new_sent_file_question_gate_registration_is_clean(tmp_path: Path) -> None:
|
|
174
|
+
current_document = _hook_document(
|
|
175
|
+
["hooks/blocking/sent_file_question_gate.py"],
|
|
176
|
+
'{"hooks": {}}',
|
|
177
|
+
)
|
|
178
|
+
assert adapters.hook_configuration_diagnostics(current_document, tmp_path) == ()
|
|
179
|
+
|
|
180
|
+
|
|
173
181
|
def test_new_question_brief_gate_registration_is_clean(tmp_path: Path) -> None:
|
|
174
182
|
current_document = _hook_document(
|
|
175
183
|
["hooks/blocking/question_brief_gate.py"],
|