claude-dev-env 8.115.0 → 8.116.1
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/install.prompt-context.test.mjs +5 -6
- package/docs/rule-guides/verified-work.md +1 -1
- package/hooks/advisory/commit_and_pull_request_words.py +346 -0
- package/hooks/advisory/piece_clauses.py +248 -0
- package/hooks/advisory/pieces_per_level_analysis.py +192 -0
- package/hooks/advisory/pieces_per_level_note.py +265 -0
- package/hooks/advisory/test_commit_and_pull_request_words.py +126 -0
- package/hooks/advisory/test_piece_clauses.py +183 -0
- package/hooks/advisory/test_pieces_per_level_note.py +389 -0
- package/hooks/advisory/test_pieces_per_level_note_bounds.py +215 -0
- package/hooks/advisory/test_pieces_per_level_note_deadline.py +282 -0
- package/hooks/blocking/final_reply_gate.py +7 -29
- package/hooks/blocking/test_final_reply_gate.py +4 -196
- package/hooks/features/README.md +1 -1
- package/hooks/features/conduct-gates.md +5 -12
- package/hooks/features/session-context.md +4 -1
- package/hooks/hooks.json +10 -41
- package/hooks/hooks_constants/background_silence_prompt_constants.py +2 -0
- package/hooks/hooks_constants/pieces_per_level_note_constants.py +255 -0
- package/hooks/hooks_constants/resolve_thread_reply_gate_constants.py +0 -8
- package/hooks/hooks_constants/shell_command_wrappers.py +20 -8
- package/hooks/hooks_constants/test_shell_command_wrappers.py +7 -0
- package/hooks/session/background_silence_prompt.py +1 -1
- package/hooks/test_context_budget_hooks.py +0 -1
- package/package.json +1 -1
- package/scripts/durable_post_lint.py +0 -12
- package/scripts/durable_post_lint_config/config/constants.py +1 -2
- package/scripts/policy_lint/adapter_configuration.py +0 -2
- package/scripts/policy_lint/config/constants.py +0 -2
- package/scripts/test_durable_post_lint.py +0 -53
- package/scripts/tests/test_adapter_configuration.py +0 -16
- package/scripts/tests/test_verified_work_rule.py +13 -0
- package/hooks/blocking/chat_reply_gate.py +0 -260
- package/hooks/blocking/reply_length_gate.py +0 -804
- package/hooks/blocking/test_chat_reply_gate.py +0 -302
- package/hooks/blocking/test_reply_length_gate.py +0 -1324
- package/hooks/hooks_constants/chat_reply_gate_constants.py +0 -60
- package/hooks/hooks_constants/reply_length_gate_constants.py +0 -203
- package/hooks/hooks_constants/test_reply_length_gate_constants.py +0 -81
- package/hooks/hooks_constants/test_visual_reply_rules_constants.py +0 -50
- package/hooks/hooks_constants/visual_reply_rules_constants.py +0 -106
- package/hooks/test_visual_reply_rules.py +0 -362
- package/hooks/visual_reply_rules.py +0 -478
- package/rules/visual-reply-rules.json +0 -56
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"""Patterns and note text for the pieces-per-level PreToolUse note.
|
|
2
|
+
|
|
3
|
+
Groups: the payload keys the hook reads, the commit and pull request option
|
|
4
|
+
names, the patterns that find verb-led clauses in a subject and topics in a
|
|
5
|
+
pull request body, and the note text. The note is context only.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
|
|
12
|
+
TOOL_NAME_KEY = "tool_name"
|
|
13
|
+
TOOL_INPUT_KEY = "tool_input"
|
|
14
|
+
COMMAND_INPUT_KEY = "command"
|
|
15
|
+
WORKING_DIRECTORY_KEY = "cwd"
|
|
16
|
+
PRE_TOOL_USE_EVENT_NAME = "PreToolUse"
|
|
17
|
+
ADDITIONAL_CONTEXT_KEY = "additionalContext"
|
|
18
|
+
TITLE_INPUT_KEY = "title"
|
|
19
|
+
BODY_INPUT_KEY = "body"
|
|
20
|
+
|
|
21
|
+
EXECUTABLE_SUFFIX = ".exe"
|
|
22
|
+
GIT_PROGRAM_NAME = "git"
|
|
23
|
+
GIT_COMMIT_WORD = "commit"
|
|
24
|
+
GH_PROGRAM_NAME = "gh"
|
|
25
|
+
ALL_GH_CREATE_WORDS = ("pr", "create")
|
|
26
|
+
ALL_QUICK_SCAN_WORDS = ("commit", "create", "pull_request")
|
|
27
|
+
ALL_SHELL_CONTROL_TOKENS = frozenset({"&&", "||", ";", "|", "&", "|&"})
|
|
28
|
+
BACKSLASH = "\\"
|
|
29
|
+
DOUBLED_BACKSLASH = "\\\\"
|
|
30
|
+
LONG_OPTION_PREFIX = "--"
|
|
31
|
+
OPTION_VALUE_SEPARATOR = "="
|
|
32
|
+
SHORT_OPTION_PREFIX = "-"
|
|
33
|
+
ALL_MESSAGE_LONG_OPTIONS = frozenset({"--message"})
|
|
34
|
+
ALL_FILE_LONG_OPTIONS = frozenset({"--file"})
|
|
35
|
+
MESSAGE_SHORT_FLAG = "m"
|
|
36
|
+
MESSAGE_KIND = "message"
|
|
37
|
+
FILE_KIND = "file"
|
|
38
|
+
FILE_SHORT_OPTION = "-F"
|
|
39
|
+
STANDARD_INPUT_PATH = "-"
|
|
40
|
+
MESSAGE_PARAGRAPH_SEPARATOR = "\n\n"
|
|
41
|
+
SHORT_CLUSTER_MINIMUM_LENGTH = 2
|
|
42
|
+
MAXIMUM_COMMAND_CHARACTERS = 8_000
|
|
43
|
+
MAXIMUM_FILE_BYTES = 65_536
|
|
44
|
+
MAXIMUM_PROGRAM_MENTIONS = 16
|
|
45
|
+
MAXIMUM_WRAPPED_TEXTS = 8
|
|
46
|
+
MAXIMUM_SUBSTITUTION_MARKERS = 16
|
|
47
|
+
MAXIMUM_TITLE_CHARACTERS = 300
|
|
48
|
+
MAXIMUM_BODY_CHARACTERS = 20_000
|
|
49
|
+
MAXIMUM_LINE_CHARACTERS = 500
|
|
50
|
+
TOTAL_DEADLINE_SECONDS = 1.0
|
|
51
|
+
EXIT_WAIT_SECONDS = 0.2
|
|
52
|
+
DEADLINE_ENVIRONMENT_VARIABLE = "PIECES_NOTE_TEST_DEADLINE_SECONDS"
|
|
53
|
+
ANALYZE_FLAG = "--analyze"
|
|
54
|
+
ANALYSIS_MODULE_NAME = "pieces_per_level_analysis"
|
|
55
|
+
CREATE_NO_WINDOW_ATTRIBUTE = "CREATE_NO_WINDOW"
|
|
56
|
+
PARSE_CACHE_SIZE = 2
|
|
57
|
+
ALL_SUBSTITUTION_MARKERS = ("$(", "`")
|
|
58
|
+
|
|
59
|
+
HEREDOC_MESSAGE_PATTERN = re.compile(
|
|
60
|
+
r"^\s*\$\(\s*cat\s+<<-?\s*(?P<quote>['\"]?)(?P<tag>\w+)(?P=quote)[ \t]*\n(?P<text>.*?)\n[ \t]*(?P=tag)[ \t]*\n?\s*\)\s*$",
|
|
61
|
+
re.DOTALL,
|
|
62
|
+
)
|
|
63
|
+
GIT_WORD_PATTERN = re.compile(r"\bgit\b")
|
|
64
|
+
COMMIT_WORD_PATTERN = re.compile(r"\bcommit\b")
|
|
65
|
+
HEREDOC_START_PATTERN = re.compile(
|
|
66
|
+
r"(?:-\w*m|--message)[ =]+\"?\$\(\s*cat\s+<<-?\s*(?P<quote>['\"]?)(?P<tag>\w+)(?P=quote)[ \t]*$"
|
|
67
|
+
)
|
|
68
|
+
HEREDOC_TAG_GROUP = "tag"
|
|
69
|
+
HEREDOC_TEXT_GROUP = "text"
|
|
70
|
+
LINE_LEADING_WORD_PATTERN = re.compile(r"[ \t]*(\w*)")
|
|
71
|
+
LINE_SEPARATOR = "\n"
|
|
72
|
+
CARRIAGE_RETURN = "\r"
|
|
73
|
+
CARRIAGE_RETURN_LINE_FEED = "\r\n"
|
|
74
|
+
MINIMUM_HEREDOC_BODY_LINE_OFFSET = 2
|
|
75
|
+
|
|
76
|
+
CONVENTIONAL_SUBJECT_PATTERN = re.compile(
|
|
77
|
+
r"^[a-z]+(?:\([^)\n]*\))?!?:[ \t]+(?P<description>\S.*)$", re.IGNORECASE
|
|
78
|
+
)
|
|
79
|
+
DESCRIPTION_GROUP = "description"
|
|
80
|
+
CODE_SPAN_PATTERN = re.compile(r"`[^`\n]*`")
|
|
81
|
+
PARENTHESIS_PATTERN = re.compile(r"\([^)\n]*\)")
|
|
82
|
+
QUOTED_TEXT_PATTERN = re.compile(r"\"[^\"\n]*\"|'[^'\n]*'")
|
|
83
|
+
MASKED_TEXT = "text"
|
|
84
|
+
REMOVED_TEXT = ""
|
|
85
|
+
MINIMUM_CLAUSE_WORD_COUNT = 1
|
|
86
|
+
CLAUSE_SEPARATOR_PATTERN = re.compile(r"\s*;\s*|\s*,\s*(?:and\s+)?|\s+and\s+", re.IGNORECASE)
|
|
87
|
+
WORD_EDGE_CHARACTERS = ".,;:!?\"'`*_()"
|
|
88
|
+
MINIMUM_PIECE_COUNT = 2
|
|
89
|
+
MAXIMUM_NAMED_PIECES = 6
|
|
90
|
+
MAXIMUM_PIECE_CHARACTERS = 80
|
|
91
|
+
PIECE_TRUNCATION_SUFFIX = "..."
|
|
92
|
+
|
|
93
|
+
ALL_ADJUNCT_WORDS = frozenset({"with", "using", "via", "without", "including", "plus"})
|
|
94
|
+
ALL_LEADING_ADVERBS = frozenset(
|
|
95
|
+
{"always", "also", "now", "never", "then", "only", "just", "finally", "still"}
|
|
96
|
+
)
|
|
97
|
+
ALL_PIECE_VERBS = frozenset(
|
|
98
|
+
{
|
|
99
|
+
"accept",
|
|
100
|
+
"add",
|
|
101
|
+
"align",
|
|
102
|
+
"allow",
|
|
103
|
+
"apply",
|
|
104
|
+
"ask",
|
|
105
|
+
"bind",
|
|
106
|
+
"block",
|
|
107
|
+
"build",
|
|
108
|
+
"bump",
|
|
109
|
+
"cache",
|
|
110
|
+
"center",
|
|
111
|
+
"change",
|
|
112
|
+
"check",
|
|
113
|
+
"clean",
|
|
114
|
+
"clear",
|
|
115
|
+
"close",
|
|
116
|
+
"collapse",
|
|
117
|
+
"convert",
|
|
118
|
+
"copy",
|
|
119
|
+
"create",
|
|
120
|
+
"darken",
|
|
121
|
+
"delete",
|
|
122
|
+
"detect",
|
|
123
|
+
"disable",
|
|
124
|
+
"draw",
|
|
125
|
+
"drop",
|
|
126
|
+
"emit",
|
|
127
|
+
"enable",
|
|
128
|
+
"end",
|
|
129
|
+
"ensure",
|
|
130
|
+
"expand",
|
|
131
|
+
"extract",
|
|
132
|
+
"fetch",
|
|
133
|
+
"finish",
|
|
134
|
+
"fix",
|
|
135
|
+
"format",
|
|
136
|
+
"handle",
|
|
137
|
+
"hide",
|
|
138
|
+
"ignore",
|
|
139
|
+
"install",
|
|
140
|
+
"keep",
|
|
141
|
+
"lighten",
|
|
142
|
+
"link",
|
|
143
|
+
"list",
|
|
144
|
+
"load",
|
|
145
|
+
"log",
|
|
146
|
+
"make",
|
|
147
|
+
"mark",
|
|
148
|
+
"merge",
|
|
149
|
+
"move",
|
|
150
|
+
"name",
|
|
151
|
+
"open",
|
|
152
|
+
"parse",
|
|
153
|
+
"pass",
|
|
154
|
+
"pin",
|
|
155
|
+
"point",
|
|
156
|
+
"prevent",
|
|
157
|
+
"print",
|
|
158
|
+
"publish",
|
|
159
|
+
"put",
|
|
160
|
+
"read",
|
|
161
|
+
"record",
|
|
162
|
+
"refactor",
|
|
163
|
+
"register",
|
|
164
|
+
"reject",
|
|
165
|
+
"remove",
|
|
166
|
+
"rename",
|
|
167
|
+
"render",
|
|
168
|
+
"replace",
|
|
169
|
+
"require",
|
|
170
|
+
"reset",
|
|
171
|
+
"resize",
|
|
172
|
+
"restore",
|
|
173
|
+
"retry",
|
|
174
|
+
"return",
|
|
175
|
+
"rewrite",
|
|
176
|
+
"route",
|
|
177
|
+
"run",
|
|
178
|
+
"save",
|
|
179
|
+
"scale",
|
|
180
|
+
"send",
|
|
181
|
+
"set",
|
|
182
|
+
"show",
|
|
183
|
+
"simplify",
|
|
184
|
+
"skip",
|
|
185
|
+
"split",
|
|
186
|
+
"start",
|
|
187
|
+
"stop",
|
|
188
|
+
"store",
|
|
189
|
+
"support",
|
|
190
|
+
"switch",
|
|
191
|
+
"sync",
|
|
192
|
+
"tell",
|
|
193
|
+
"tidy",
|
|
194
|
+
"track",
|
|
195
|
+
"trim",
|
|
196
|
+
"unpin",
|
|
197
|
+
"update",
|
|
198
|
+
"upgrade",
|
|
199
|
+
"use",
|
|
200
|
+
"validate",
|
|
201
|
+
"verify",
|
|
202
|
+
"wait",
|
|
203
|
+
"wire",
|
|
204
|
+
"wrap",
|
|
205
|
+
"write",
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
WHAT_THIS_DOES_SECTION_NAME = "What this does"
|
|
210
|
+
TOPIC_BULLET_PATTERN = re.compile(r"^[-*+][ \t]+(?:\*\*|__)(?P<topic>[^*_\n]+?)(?:\*\*|__)")
|
|
211
|
+
TOPIC_GROUP = "topic"
|
|
212
|
+
TOPIC_EDGE_CHARACTERS = " \t:.-"
|
|
213
|
+
ALL_LABEL_TOPICS = frozenset(
|
|
214
|
+
{"before", "after", "why", "who notices", "now", "then", "today", "effect", "note", "context"}
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
PROOF_LEAD_CHARACTERS = " \t>-*+_`#"
|
|
218
|
+
PROOF_NUMBER_PATTERN = re.compile(r"^\d+[.)]\s*")
|
|
219
|
+
WITHOUT_LINE_PATTERN = re.compile(r"^without\b")
|
|
220
|
+
WITH_LINE_PATTERN = re.compile(r"^with\b(?!out)")
|
|
221
|
+
WITH_SAME_LINE_PATTERN = re.compile(r"[;,.]\s+[*_`]*with\b(?!out)")
|
|
222
|
+
MINIMUM_PROOF_PAIR_COUNT = 2
|
|
223
|
+
|
|
224
|
+
COMMIT_KIND = "commit"
|
|
225
|
+
PULL_REQUEST_KIND = "pull request"
|
|
226
|
+
PIECE_SEPARATOR = "; "
|
|
227
|
+
MORE_PIECES_TEMPLATE = "and {count} more"
|
|
228
|
+
PROOF_PAIRS_PIECE_TEMPLATE = "{count} without/with proof pairs under Proof in practice"
|
|
229
|
+
QUOTED_PIECE_TEMPLATE = '"{piece}"'
|
|
230
|
+
|
|
231
|
+
COMMIT_NEXT_COMMAND = (
|
|
232
|
+
"The commit that is running holds every piece. To split it, run `git reset --soft HEAD~1`, "
|
|
233
|
+
"then `git add <paths of the first piece>` and commit, then put the next piece on its own "
|
|
234
|
+
"level with `gt create` (or `git switch -c <next-branch>` without Graphite)."
|
|
235
|
+
)
|
|
236
|
+
PULL_REQUEST_NEXT_COMMAND = (
|
|
237
|
+
"Next command: `gt create` (or `git switch -c <next-branch>` from the previous level) for "
|
|
238
|
+
"each further piece, then open one pull request per level with `gh pr create --base "
|
|
239
|
+
"<previous-branch>`."
|
|
240
|
+
)
|
|
241
|
+
NOTE_TEMPLATE = (
|
|
242
|
+
"Your own words name several pieces in this {kind}: {pieces}. Each piece gets its own "
|
|
243
|
+
"commit and its own stack level, committed as its verifier passes, so a reviewer reads "
|
|
244
|
+
"one purpose at a time. {next_command} This note is context only, and the {kind} runs."
|
|
245
|
+
)
|
|
246
|
+
ALL_NEXT_COMMAND_BY_KIND = {
|
|
247
|
+
COMMIT_KIND: COMMIT_NEXT_COMMAND,
|
|
248
|
+
PULL_REQUEST_KIND: PULL_REQUEST_NEXT_COMMAND,
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
COMMIT_MESSAGE_FLAG_PATTERN = re.compile(r"(?<!\S)(?:-[A-Za-z]*m|--message|-F|--file)(?![\w-])")
|
|
252
|
+
BODY_OPTION_PATTERN = re.compile(r"(?<!\S)(?:--body|--body-file|-b|-F|--file)(?![\w-])")
|
|
253
|
+
PULL_REQUEST_CREATE_PATTERN = re.compile(r"\bpr\s+create\b")
|
|
254
|
+
PULL_REQUEST_SCRIPT_CREATE_PATTERN = re.compile(r"\bpull_request\.py\b\s+create\b")
|
|
255
|
+
CLAUSE_SEPARATOR_PRECHECK_PATTERN = re.compile(r"[,;]|\band\b", re.IGNORECASE)
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
4
|
|
|
5
|
-
from hooks_constants.reply_length_gate_constants import (
|
|
6
|
-
MAXIMUM_SENTENCE_COUNT,
|
|
7
|
-
MAXIMUM_WORDS_PER_SENTENCE,
|
|
8
|
-
)
|
|
9
|
-
|
|
10
5
|
RESOLVE_TOOL_NAME_PATTERN = re.compile(r"^mcp__.+__resolve_review_thread$")
|
|
11
6
|
REVIEW_WRITE_TOOL_NAME_PATTERN = re.compile(r"^mcp__.+__pull_request_review_write$")
|
|
12
7
|
REVIEW_WRITE_METHOD_KEY = "method"
|
|
@@ -31,7 +26,4 @@ MISSING_REPLY_REASON = (
|
|
|
31
26
|
" or with gh api graphql addPullRequestReviewThreadReply and the thread's PRRT_ id, confirm its"
|
|
32
27
|
" result came back without an error, then resolve the thread by its PRRT_ id or by the comment id the reply answered. A comment id"
|
|
33
28
|
" ties to a thread only through a pull_request_read get_review_comments result in this session."
|
|
34
|
-
" A reply that a hook refused did not post; shorten it to"
|
|
35
|
-
f" at most {MAXIMUM_SENTENCE_COUNT} sentences of at most {MAXIMUM_WORDS_PER_SENTENCE} words each,"
|
|
36
|
-
" footer included, and send it again."
|
|
37
29
|
)
|
|
@@ -330,12 +330,22 @@ def _inner_commands(command: str, all_command_segments: list[list[str]]) -> list
|
|
|
330
330
|
return [each_command for each_command in all_inner_commands if each_command is not None]
|
|
331
331
|
|
|
332
332
|
|
|
333
|
-
def
|
|
333
|
+
def _command_segments(command: str) -> list[list[str]]:
|
|
334
|
+
return [
|
|
335
|
+
each_segment for each_segment, _following_operator in pipeline_segments_for_command(command)
|
|
336
|
+
]
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def _all_wrapped_command_parses(
|
|
340
|
+
command: str, maximum_texts: int | None = None
|
|
341
|
+
) -> list[tuple[str, list[list[str]]]]:
|
|
334
342
|
"""Return each command text with its segments, the command first, each text parsed once.
|
|
335
343
|
|
|
336
344
|
The texts after the command are the command string every shell wrapper,
|
|
337
345
|
evaluating program and command substitution inside it runs, unwrapped in
|
|
338
346
|
turn to ``MAXIMUM_UNWRAP_DEPTH`` levels. A text met twice is parsed once.
|
|
347
|
+
With ``maximum_texts`` set, no further text is parsed or unwrapped once that
|
|
348
|
+
many are held.
|
|
339
349
|
"""
|
|
340
350
|
all_parses: list[tuple[str, list[list[str]]]] = []
|
|
341
351
|
all_seen_texts: set[str] = set()
|
|
@@ -345,11 +355,10 @@ def _all_wrapped_command_parses(command: str) -> list[tuple[str, list[list[str]]
|
|
|
345
355
|
if each_text in all_seen_texts or each_depth > MAXIMUM_UNWRAP_DEPTH:
|
|
346
356
|
continue
|
|
347
357
|
all_seen_texts.add(each_text)
|
|
348
|
-
all_command_segments =
|
|
349
|
-
each_segment
|
|
350
|
-
for each_segment, _following_operator in pipeline_segments_for_command(each_text)
|
|
351
|
-
]
|
|
358
|
+
all_command_segments = _command_segments(each_text)
|
|
352
359
|
all_parses.append((each_text, all_command_segments))
|
|
360
|
+
if maximum_texts is not None and len(all_parses) >= maximum_texts:
|
|
361
|
+
break
|
|
353
362
|
all_pending_texts.extend(
|
|
354
363
|
(each_inner_command, each_depth + 1)
|
|
355
364
|
for each_inner_command in _inner_commands(each_text, all_command_segments)
|
|
@@ -357,15 +366,18 @@ def _all_wrapped_command_parses(command: str) -> list[tuple[str, list[list[str]]
|
|
|
357
366
|
return all_parses
|
|
358
367
|
|
|
359
368
|
|
|
360
|
-
def all_wrapped_command_texts(command: str) -> list[str]:
|
|
369
|
+
def all_wrapped_command_texts(command: str, maximum_texts: int | None = None) -> list[str]:
|
|
361
370
|
"""Return the command plus each command string a wrapper or substitution inside it runs.
|
|
362
371
|
|
|
363
372
|
The segments come from the quote-aware pipeline parser, so the quoted
|
|
364
373
|
script in ``powershell -Command "git add -A; git push"`` stays whole until
|
|
365
374
|
its own turn. Nested wrappers and ``$(...)`` or backtick substitutions
|
|
366
|
-
unwrap in turn.
|
|
375
|
+
unwrap in turn. With ``maximum_texts`` set, the list stops at that many texts.
|
|
367
376
|
"""
|
|
368
|
-
return [
|
|
377
|
+
return [
|
|
378
|
+
each_text
|
|
379
|
+
for each_text, _all_segments in _all_wrapped_command_parses(command, maximum_texts)
|
|
380
|
+
]
|
|
369
381
|
|
|
370
382
|
|
|
371
383
|
def all_wrapped_command_segments(command: str) -> list[list[str]]:
|
|
@@ -29,6 +29,13 @@ def test_should_return_the_command_string_a_shell_wrapper_runs(
|
|
|
29
29
|
assert inner_command in all_command_texts
|
|
30
30
|
|
|
31
31
|
|
|
32
|
+
def test_should_stop_the_list_at_the_text_count_cap() -> None:
|
|
33
|
+
command = "bash -c \"pwsh -Command 'git push'\""
|
|
34
|
+
assert shell_command_wrappers.all_wrapped_command_texts(command, 1) == [command]
|
|
35
|
+
assert len(shell_command_wrappers.all_wrapped_command_texts(command, 2)) == 2
|
|
36
|
+
assert len(shell_command_wrappers.all_wrapped_command_texts(command)) > 2
|
|
37
|
+
|
|
38
|
+
|
|
32
39
|
def test_should_return_only_the_command_when_no_wrapper_runs() -> None:
|
|
33
40
|
assert shell_command_wrappers.all_wrapped_command_texts("git push") == ["git push"]
|
|
34
41
|
|
|
@@ -35,6 +35,7 @@ if blocking_directory not in sys.path:
|
|
|
35
35
|
sys.path.insert(0, blocking_directory)
|
|
36
36
|
|
|
37
37
|
from hooks_constants.background_silence_prompt_constants import (
|
|
38
|
+
ADDITIONAL_CONTEXT_KEY,
|
|
38
39
|
ALL_LIFT_PATTERNS,
|
|
39
40
|
ALL_SET_PATTERNS,
|
|
40
41
|
BACKGROUND_EVENT_PATTERN,
|
|
@@ -63,7 +64,6 @@ from hooks_constants.open_tasks_stop_gate_constants import (
|
|
|
63
64
|
TRANSCRIPT_PATH_KEY,
|
|
64
65
|
)
|
|
65
66
|
from hooks_constants.pre_tool_use_stdin import read_hook_input_dictionary_from_stdin
|
|
66
|
-
from hooks_constants.reply_length_gate_constants import ADDITIONAL_CONTEXT_KEY
|
|
67
67
|
from hooks_constants.spawn_readiness_hook_constants import (
|
|
68
68
|
ALL_HARNESS_ENVELOPE_MARKERS,
|
|
69
69
|
HUMAN_SENDER_MARKER,
|
|
@@ -24,7 +24,6 @@ CONTEXT_OUTPUT_PATTERN = re.compile(r"additionalContext|ADDITIONAL_CONTEXT|addit
|
|
|
24
24
|
UNMEASURED_REASON_BY_SCRIPT = {
|
|
25
25
|
"blocking/pre_tool_use_dispatcher.py": "relays its hosted hooks' output",
|
|
26
26
|
"blocking/bash_pre_tool_use_dispatcher.py": "relays its hosted hooks' output",
|
|
27
|
-
"blocking/reply_length_gate.py": "advises only on a widget while visual reply mode is on",
|
|
28
27
|
"lifecycle/nested_project_hooks.py": "relays a nested project's own hooks",
|
|
29
28
|
"routing/thread_spawn_pace_hook.py": "quotes a usage reading capped by its own constant",
|
|
30
29
|
"session/issue_tracker_session_starter.py": "emits only for a repository the user's "
|
package/package.json
CHANGED
|
@@ -18,7 +18,6 @@ from dev_env_scripts_constants.private_term_constants import (
|
|
|
18
18
|
PRIVATE_TERM_MESSAGE_TEMPLATE,
|
|
19
19
|
)
|
|
20
20
|
from durable_post_lint_config.config.constants import (
|
|
21
|
-
ACTION_GITHUB_MCP_COMMENT,
|
|
22
21
|
ACTION_PR_CREATE,
|
|
23
22
|
ACTION_PR_EDIT,
|
|
24
23
|
ALL_BARE_VOLATILE_PATH_MARKERS,
|
|
@@ -33,7 +32,6 @@ from durable_post_lint_config.config.constants import (
|
|
|
33
32
|
BODY_MUST_NOT_BE_EMPTY_MESSAGE,
|
|
34
33
|
BODY_REQUIRED_MESSAGE,
|
|
35
34
|
CLEAN_EXIT_CODE,
|
|
36
|
-
COMMENT_LENGTH_FINDING_CODE,
|
|
37
35
|
CONTENT_FINDING_EXIT_CODE,
|
|
38
36
|
CONVENTIONAL_TITLE_PATTERN,
|
|
39
37
|
EDIT_INPUT_REQUIRED_MESSAGE,
|
|
@@ -73,7 +71,6 @@ from blocking.pull_request_proof import (
|
|
|
73
71
|
missing_proof_reason,
|
|
74
72
|
what_this_does_section,
|
|
75
73
|
)
|
|
76
|
-
from blocking.reply_length_gate import comment_length_violation
|
|
77
74
|
|
|
78
75
|
|
|
79
76
|
class DurablePostUsageError(ValueError):
|
|
@@ -211,13 +208,6 @@ def _pull_request_proof_findings(
|
|
|
211
208
|
]
|
|
212
209
|
|
|
213
210
|
|
|
214
|
-
def _comment_length_findings(body_text: str) -> list[DurablePostFinding]:
|
|
215
|
-
violation = comment_length_violation(body_text)
|
|
216
|
-
if violation is None:
|
|
217
|
-
return []
|
|
218
|
-
return [DurablePostFinding(code=COMMENT_LENGTH_FINDING_CODE, message=violation)]
|
|
219
|
-
|
|
220
|
-
|
|
221
211
|
def _contrast_framing_findings(text: str) -> list[DurablePostFinding]:
|
|
222
212
|
all_lines = text.splitlines()
|
|
223
213
|
return [
|
|
@@ -307,8 +297,6 @@ def _body_findings(
|
|
|
307
297
|
if action in (ACTION_PR_CREATE, ACTION_PR_EDIT):
|
|
308
298
|
all_findings.extend(_description_flowchart_findings(body_text)
|
|
309
299
|
)
|
|
310
|
-
if action == ACTION_GITHUB_MCP_COMMENT:
|
|
311
|
-
all_findings.extend(_comment_length_findings(body_text))
|
|
312
300
|
all_findings.extend(_contrast_framing_findings(body_text))
|
|
313
301
|
if find_volatile_path_marker(body_text) is not None:
|
|
314
302
|
all_findings.append(
|
|
@@ -109,5 +109,4 @@ REWRITTEN_RELEASE_BODY_MESSAGE = (
|
|
|
109
109
|
)
|
|
110
110
|
REPOSITORY_OWNER_SEPARATOR = "/"
|
|
111
111
|
PROOF_GATE_CREATE_TOOL_NAME = "mcp__github__create_pull_request"
|
|
112
|
-
PULL_REQUEST_PROOF_FINDING_CODE = "pull-request-proof-section"
|
|
113
|
-
COMMENT_LENGTH_FINDING_CODE = "github-comment-length"
|
|
112
|
+
PULL_REQUEST_PROOF_FINDING_CODE = "pull-request-proof-section"
|
|
@@ -130,8 +130,6 @@ def _names_exempt_registration_path(registered_string: str) -> bool:
|
|
|
130
130
|
hooks/blocking/pr_lifecycle_skill_gate.py -> exempt
|
|
131
131
|
hooks/blocking/verify_before_commit_gate.py -> exempt
|
|
132
132
|
hooks/blocking/step_note_gate.py -> exempt
|
|
133
|
-
hooks/blocking/reply_length_gate.py -> exempt
|
|
134
|
-
hooks/blocking/chat_reply_gate.py -> exempt
|
|
135
133
|
hooks/blocking/edit_marker_gate.py -> exempt
|
|
136
134
|
hooks/blocking/issue_close_handoff_gate.py -> exempt
|
|
137
135
|
hooks/blocking/verify_before_acting.py -> exempt
|
|
@@ -67,8 +67,6 @@ ALL_ACTION_BOUNDARY_EXEMPT_REGISTRATION_PATHS = (
|
|
|
67
67
|
"blocking/verify_before_commit_gate.py",
|
|
68
68
|
"blocking/merge_review_gate.py",
|
|
69
69
|
"blocking/step_note_gate.py",
|
|
70
|
-
"blocking/reply_length_gate.py",
|
|
71
|
-
"blocking/chat_reply_gate.py",
|
|
72
70
|
"blocking/edit_marker_gate.py",
|
|
73
71
|
"blocking/issue_close_handoff_gate.py",
|
|
74
72
|
"blocking/verify_before_acting.py",
|
|
@@ -10,10 +10,6 @@ from pathlib import Path
|
|
|
10
10
|
import pytest
|
|
11
11
|
|
|
12
12
|
import durable_post_lint
|
|
13
|
-
from hooks_constants.reply_length_gate_constants import (
|
|
14
|
-
MAXIMUM_SENTENCE_COUNT,
|
|
15
|
-
MAXIMUM_WORDS_PER_SENTENCE,
|
|
16
|
-
)
|
|
17
13
|
from dev_env_scripts_constants.private_term_constants import PrivateTermDigest
|
|
18
14
|
from hooks_constants.pull_request_proof_constants import (
|
|
19
15
|
MISSING_EVAL_SECTION_REASON,
|
|
@@ -64,11 +60,6 @@ Ran `python scripts/durable_post_lint.py --action pr-create --body-file body.md`
|
|
|
64
60
|
|
|
65
61
|
`python scripts/durable_post_lint.py --action pr-create --body-file eval_body.md`
|
|
66
62
|
"""
|
|
67
|
-
OVER_LONG_REPLY_BODY = (
|
|
68
|
-
"Fixed in `abc1234`.\n\n"
|
|
69
|
-
+ " ".join(f"Status line {each_number} is ready." for each_number in range(MAXIMUM_SENTENCE_COUNT + 1))
|
|
70
|
-
+ "\n\n---\nPosted by the review agent."
|
|
71
|
-
)
|
|
72
63
|
MINIMAL_PR_BODY = """## Why
|
|
73
64
|
|
|
74
65
|
Why text.
|
|
@@ -447,30 +438,6 @@ def should_exit_with_findings_for_a_create_body_with_no_existing_work_section(
|
|
|
447
438
|
assert completed_process.stderr == f"{MISSING_EXISTING_WORK_REASON}\n"
|
|
448
439
|
|
|
449
440
|
|
|
450
|
-
def should_report_a_review_reply_over_the_sentence_limit() -> None:
|
|
451
|
-
all_findings = durable_post_lint.lint_durable_post(
|
|
452
|
-
action="github-mcp-comment",
|
|
453
|
-
title=None,
|
|
454
|
-
body_text=OVER_LONG_REPLY_BODY,
|
|
455
|
-
)
|
|
456
|
-
assert [each_finding.code for each_finding in all_findings] == [
|
|
457
|
-
"github-comment-length"
|
|
458
|
-
]
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
def should_report_a_review_reply_sentence_over_the_word_limit() -> None:
|
|
462
|
-
all_findings = durable_post_lint.lint_durable_post(
|
|
463
|
-
action="github-mcp-comment",
|
|
464
|
-
title=None,
|
|
465
|
-
body_text=(
|
|
466
|
-
" ".join(f"word{each_number}" for each_number in range(MAXIMUM_WORDS_PER_SENTENCE + 1)) + "."
|
|
467
|
-
),
|
|
468
|
-
)
|
|
469
|
-
assert [each_finding.code for each_finding in all_findings] == [
|
|
470
|
-
"github-comment-length"
|
|
471
|
-
]
|
|
472
|
-
|
|
473
|
-
|
|
474
441
|
def should_accept_a_short_review_reply() -> None:
|
|
475
442
|
all_findings = durable_post_lint.lint_durable_post(
|
|
476
443
|
action="github-mcp-comment",
|
|
@@ -480,26 +447,6 @@ def should_accept_a_short_review_reply() -> None:
|
|
|
480
447
|
assert all_findings == ()
|
|
481
448
|
|
|
482
449
|
|
|
483
|
-
def should_exit_with_findings_for_an_over_long_review_reply(tmp_path: Path) -> None:
|
|
484
|
-
body_file = tmp_path / "reply.md"
|
|
485
|
-
body_file.write_text(OVER_LONG_REPLY_BODY, encoding="utf-8")
|
|
486
|
-
completed_process = subprocess.run(
|
|
487
|
-
[
|
|
488
|
-
sys.executable,
|
|
489
|
-
str(SCRIPT_PATH),
|
|
490
|
-
"--action",
|
|
491
|
-
"github-mcp-comment",
|
|
492
|
-
"--body-file",
|
|
493
|
-
str(body_file),
|
|
494
|
-
],
|
|
495
|
-
check=False,
|
|
496
|
-
capture_output=True,
|
|
497
|
-
text=True,
|
|
498
|
-
)
|
|
499
|
-
assert completed_process.returncode == 1
|
|
500
|
-
assert f"at most {MAXIMUM_SENTENCE_COUNT} short sentences" in completed_process.stderr
|
|
501
|
-
|
|
502
|
-
|
|
503
450
|
def should_exit_clean_for_a_short_review_reply(tmp_path: Path) -> None:
|
|
504
451
|
body_file = tmp_path / "reply.md"
|
|
505
452
|
body_file.write_text("Fixed in `abc1234`.\n", encoding="utf-8")
|
|
@@ -98,22 +98,6 @@ def test_new_step_note_gate_registration_is_clean(tmp_path: Path) -> None:
|
|
|
98
98
|
assert adapters.hook_configuration_diagnostics(current_document, tmp_path) == ()
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
def test_new_reply_length_gate_registration_is_clean(tmp_path: Path) -> None:
|
|
102
|
-
current_document = _hook_document(
|
|
103
|
-
["hooks/blocking/reply_length_gate.py"],
|
|
104
|
-
'{"hooks": {}}',
|
|
105
|
-
)
|
|
106
|
-
assert adapters.hook_configuration_diagnostics(current_document, tmp_path) == ()
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def test_new_chat_reply_gate_registration_is_clean(tmp_path: Path) -> None:
|
|
110
|
-
current_document = _hook_document(
|
|
111
|
-
["hooks/blocking/chat_reply_gate.py"],
|
|
112
|
-
'{"hooks": {}}',
|
|
113
|
-
)
|
|
114
|
-
assert adapters.hook_configuration_diagnostics(current_document, tmp_path) == ()
|
|
115
|
-
|
|
116
|
-
|
|
117
101
|
def test_new_edit_marker_gate_registration_is_clean(tmp_path: Path) -> None:
|
|
118
102
|
current_document = _hook_document(
|
|
119
103
|
["hooks/blocking/edit_marker_gate.py"],
|
|
@@ -87,3 +87,16 @@ def test_the_pull_request_skill_points_its_decision_tree_at_the_delivery_section
|
|
|
87
87
|
assert "independent piece" not in decision_tree
|
|
88
88
|
assert "`gt create`" not in decision_tree
|
|
89
89
|
assert "a plain branch from the previous level" not in decision_tree
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_the_enforcement_section_names_the_note_and_keeps_it_non_blocking() -> None:
|
|
93
|
+
enforcement_text = GUIDE_PATH.read_text(encoding="utf-8").split("## Enforcement", 1)[1]
|
|
94
|
+
assert "hooks/advisory/pieces_per_level_note.py" in enforcement_text
|
|
95
|
+
assert "it never denies or exits non-zero" in enforcement_text
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_the_enforcement_section_points_to_the_feature_page_for_the_note_details() -> None:
|
|
99
|
+
enforcement_text = GUIDE_PATH.read_text(encoding="utf-8").split("## Enforcement", 1)[1]
|
|
100
|
+
assert "(../../hooks/features/session-context.md)" in enforcement_text
|
|
101
|
+
assert "wall-clock deadline" not in enforcement_text
|
|
102
|
+
assert "split the commit or the pull request" not in enforcement_text
|