claude-dev-env 8.116.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.
Files changed (28) hide show
  1. package/bin/install.prompt-context.test.mjs +5 -6
  2. package/hooks/blocking/final_reply_gate.py +7 -29
  3. package/hooks/blocking/test_final_reply_gate.py +4 -196
  4. package/hooks/features/conduct-gates.md +5 -12
  5. package/hooks/hooks.json +0 -41
  6. package/hooks/hooks_constants/background_silence_prompt_constants.py +2 -0
  7. package/hooks/hooks_constants/resolve_thread_reply_gate_constants.py +0 -8
  8. package/hooks/session/background_silence_prompt.py +1 -1
  9. package/hooks/test_context_budget_hooks.py +0 -1
  10. package/package.json +1 -1
  11. package/scripts/durable_post_lint.py +0 -12
  12. package/scripts/durable_post_lint_config/config/constants.py +1 -2
  13. package/scripts/policy_lint/adapter_configuration.py +0 -2
  14. package/scripts/policy_lint/config/constants.py +0 -2
  15. package/scripts/test_durable_post_lint.py +0 -53
  16. package/scripts/tests/test_adapter_configuration.py +0 -16
  17. package/hooks/blocking/chat_reply_gate.py +0 -260
  18. package/hooks/blocking/reply_length_gate.py +0 -804
  19. package/hooks/blocking/test_chat_reply_gate.py +0 -302
  20. package/hooks/blocking/test_reply_length_gate.py +0 -1324
  21. package/hooks/hooks_constants/chat_reply_gate_constants.py +0 -60
  22. package/hooks/hooks_constants/reply_length_gate_constants.py +0 -203
  23. package/hooks/hooks_constants/test_reply_length_gate_constants.py +0 -81
  24. package/hooks/hooks_constants/test_visual_reply_rules_constants.py +0 -50
  25. package/hooks/hooks_constants/visual_reply_rules_constants.py +0 -106
  26. package/hooks/test_visual_reply_rules.py +0 -362
  27. package/hooks/visual_reply_rules.py +0 -478
  28. package/rules/visual-reply-rules.json +0 -56
@@ -1,478 +0,0 @@
1
- """The visual reply mode rule list and the checks the reply length gate runs from it.
2
-
3
- One JSON file, ``rules/visual-reply-rules.json``, holds the rules. The gate,
4
- the reminder and the evaluation read the same file, so all three name each
5
- rule with the same label and the same reminder text.
6
-
7
- The mode is off unless ``~/.claude/visual-reply-mode.json`` holds
8
- ``{"enabled": true}``.
9
- """
10
-
11
- from __future__ import annotations
12
-
13
- import json
14
- import re
15
- from collections.abc import Iterable, Iterator
16
- from dataclasses import dataclass
17
- from pathlib import Path
18
-
19
- from json_file_reader import read_json_object
20
- from hooks_constants.visual_reply_rules_constants import (
21
- ABBREVIATION_MESSAGE,
22
- VIOLATION_LINE_SEPARATOR,
23
- ABBREVIATIONS_RULE_KEY,
24
- ALL_ATTACHMENT_TEXT_KEYS,
25
- ALL_HOOK_MESSAGE_PREFIXES,
26
- ALL_HOOK_TEXT_ATTACHMENT_TYPES,
27
- ALL_REPLY_TOOL_NAME_SUFFIXES,
28
- ALL_VISUAL_TOOL_NAME_SUFFIXES,
29
- ALLOWED_CAPITALIZED_WORDS_KEY,
30
- ASSISTANT_ENTRY_TYPE,
31
- ATTACHMENT_ENTRY_TYPE,
32
- ATTACHMENT_KEY,
33
- BLOCK_ID_KEY,
34
- BLOCK_NAME_KEY,
35
- BLOCK_TEXT_KEY,
36
- BLOCK_TYPE_KEY,
37
- CAPITALIZED_ABBREVIATION_PATTERN,
38
- CONTENT_KEY,
39
- ENTRY_TYPE_KEY,
40
- IS_ERROR_KEY,
41
- IS_META_KEY,
42
- LOWERCASE_ABBREVIATION_TEMPLATE,
43
- LOWERCASE_ABBREVIATIONS_KEY,
44
- MAXIMUM_REPLIES_PER_TURN,
45
- MAXIMUM_SENTENCES_WITHOUT_VISUAL,
46
- MESSAGE_KEY,
47
- MODE_SWITCH_ENABLED_KEY,
48
- MODE_SWITCH_FILE_NAME,
49
- NO_PICTURE_RULE_KEY,
50
- NO_VISUAL_MESSAGE,
51
- ONE_ITEM_RULE_KEY,
52
- ORIGIN_KEY,
53
- ORIGIN_KIND_KEY,
54
- QUEUED_COMMAND_ATTACHMENT_TYPE,
55
- RULE_KEY_FIELD,
56
- RULE_LABEL_FIELD,
57
- RULE_REMINDER_FIELD,
58
- RESULT_TEXT_SEPARATOR,
59
- RULES_FILE_ENCODING,
60
- RULES_FILE_PATH,
61
- RULES_LIST_KEY,
62
- SECOND_REPLY_MESSAGE,
63
- TASK_NOTIFICATION_ORIGIN_KIND,
64
- TEXT_BLOCK_TYPE,
65
- TOOL_RESULT_BLOCK_TYPE,
66
- TOOL_USE_BLOCK_TYPE,
67
- TOOL_USE_ID_KEY,
68
- TRACKER_NUMBER_MESSAGE,
69
- TRACKER_NUMBER_PATTERN,
70
- TRANSCRIPT_ENCODING,
71
- USER_ENTRY_TYPE,
72
- WIDGET_ANCHOR_MESSAGE,
73
- FLOWCHART_ARROW_PATTERN,
74
- FLOWCHART_DIAMOND_PATTERN,
75
- FLOWCHART_MARKER_BLOCK_PATTERN,
76
- FLOWCHART_RULE_KEY,
77
- FLOWCHART_SVG_PATTERN,
78
- NOT_FLOWCHART_MESSAGE,
79
- WIDGET_CODE_KEY,
80
- WIDGET_INPUT_KEY,
81
- WIDGET_ANCHOR_PATTERN,
82
- WIDGET_TOOL_NAME_SUFFIX,
83
- ALL_PICTURE_SUFFIXES,
84
- ATTACHED_OUTPUTS_KEY,
85
- FIGURE_PATTERN,
86
- LIST_NUMBER_PATTERN,
87
- MARKDOWN_PICTURE_PATTERN,
88
- MAXIMUM_FIGURES_WITHOUT_PICTURE,
89
- OUTPUT_FILE_KIND,
90
- OUTPUT_FRAME_KIND,
91
- OUTPUT_KIND_KEY,
92
- OUTPUT_REF_KEY,
93
- RESULTS_PICTURE_MESSAGE,
94
- RESULTS_PICTURE_RULE_KEY,
95
- TABLE_SEPARATOR_PATTERN,
96
- )
97
- from hooks_constants.reply_length_gate_constants import FENCED_BLOCK_PATTERN, INLINE_CODE_PATTERN
98
-
99
-
100
- @dataclass(frozen=True)
101
- class ReplyRule:
102
- """One rule of the mode: its key, the label a flag shows, and the reminder text."""
103
-
104
- key: str
105
- label: str
106
- reminder: str
107
-
108
-
109
- @dataclass(frozen=True)
110
- class VisualReplyRules:
111
- """The parsed rule file."""
112
-
113
- all_rules: tuple[ReplyRule, ...]
114
- all_allowed_capitalized_words: frozenset[str]
115
- all_lowercase_abbreviations: tuple[str, ...]
116
-
117
- def reminder(self, rule_key: str) -> str:
118
- """Return the reminder text for one rule key."""
119
- return next(each.reminder for each in self.all_rules if each.key == rule_key)
120
-
121
-
122
- def _string_list(field_value: object) -> list[object]:
123
- return field_value if isinstance(field_value, list) else []
124
-
125
-
126
- def load_rules(rules_path: Path = RULES_FILE_PATH) -> VisualReplyRules | None:
127
- """Parse the rule file, or return None when it is missing or malformed."""
128
- document = read_json_object(rules_path, RULES_FILE_ENCODING)
129
- if document is None:
130
- return None
131
- all_rule_entries = document.get(RULES_LIST_KEY)
132
- if not isinstance(all_rule_entries, list):
133
- return None
134
- all_rules = tuple(
135
- ReplyRule(
136
- key=str(each[RULE_KEY_FIELD]),
137
- label=str(each[RULE_LABEL_FIELD]),
138
- reminder=str(each[RULE_REMINDER_FIELD]),
139
- )
140
- for each in all_rule_entries
141
- if isinstance(each, dict)
142
- and all(field in each for field in (RULE_KEY_FIELD, RULE_LABEL_FIELD, RULE_REMINDER_FIELD))
143
- )
144
- all_needed_keys = {
145
- ONE_ITEM_RULE_KEY,
146
- NO_PICTURE_RULE_KEY,
147
- ABBREVIATIONS_RULE_KEY,
148
- RESULTS_PICTURE_RULE_KEY,
149
- }
150
- if not all_needed_keys <= {each.key for each in all_rules}:
151
- return None
152
- return VisualReplyRules(
153
- all_rules=all_rules,
154
- all_allowed_capitalized_words=frozenset(
155
- str(each) for each in _string_list(document.get(ALLOWED_CAPITALIZED_WORDS_KEY))
156
- ),
157
- all_lowercase_abbreviations=tuple(
158
- str(each) for each in _string_list(document.get(LOWERCASE_ABBREVIATIONS_KEY))
159
- ),
160
- )
161
-
162
-
163
- def mode_enabled(claude_home: Path) -> bool:
164
- """Return True only when the switch file turns the mode on."""
165
- switch_document = read_json_object(claude_home / MODE_SWITCH_FILE_NAME, RULES_FILE_ENCODING)
166
- if switch_document is None:
167
- return False
168
- return switch_document.get(MODE_SWITCH_ENABLED_KEY) is True
169
-
170
-
171
- def abbreviation_violation(prose_text: str, rules: VisualReplyRules) -> str | None:
172
- """Return the deny reason naming each abbreviation and tracker number in prose with links and code removed.
173
-
174
- Each one gets its own line, so one refusal names them all.
175
- """
176
- reminder = rules.reminder(ABBREVIATIONS_RULE_KEY)
177
- all_abbreviations = [
178
- each_match.group(0)
179
- for each_match in CAPITALIZED_ABBREVIATION_PATTERN.finditer(prose_text)
180
- if each_match.group(0) not in rules.all_allowed_capitalized_words
181
- ] + [
182
- each_abbreviation
183
- for each_abbreviation in rules.all_lowercase_abbreviations
184
- if re.search(
185
- LOWERCASE_ABBREVIATION_TEMPLATE.format(abbreviation=re.escape(each_abbreviation)),
186
- prose_text,
187
- re.IGNORECASE,
188
- )
189
- ]
190
- all_violations = [
191
- *(
192
- ABBREVIATION_MESSAGE.format(abbreviation=each_abbreviation, reminder=reminder)
193
- for each_abbreviation in dict.fromkeys(all_abbreviations)
194
- ),
195
- *(
196
- TRACKER_NUMBER_MESSAGE.format(reference=each_match.group(0), reminder=reminder)
197
- for each_match in TRACKER_NUMBER_PATTERN.finditer(prose_text)
198
- ),
199
- ]
200
- return VIOLATION_LINE_SEPARATOR.join(all_violations) if all_violations else None
201
-
202
-
203
- def widget_anchor_violation(tool_name: str, all_tool_input: dict[str, object]) -> str | None:
204
- """Return the deny reason for an anchor link inside widget code."""
205
- if not tool_name.endswith(WIDGET_TOOL_NAME_SUFFIX):
206
- return None
207
- serialized_input = json.dumps(all_tool_input)
208
- return WIDGET_ANCHOR_MESSAGE if WIDGET_ANCHOR_PATTERN.search(serialized_input) else None
209
-
210
-
211
- def widget_flowchart_advice(
212
- tool_name: str, all_tool_input: dict[str, object], rules: VisualReplyRules
213
- ) -> str | None:
214
- """Return the advice for widget code that is not a flowchart, else None.
215
-
216
- The gate passes this advice to the session and still allows the call.
217
-
218
- A flowchart widget is one SVG with at least one arrow marker and one
219
- diamond shape for a yes or no check. Shapes inside a ``<marker>`` block
220
- are arrowheads, so they never count as the diamond::
221
-
222
- <svg><path d="M0 0L9 5L0 9L-9 5Z"/><path marker-end="url(#a)"/></svg>
223
- """
224
- all_rule_keys = {each.key for each in rules.all_rules}
225
- if not tool_name.endswith(WIDGET_TOOL_NAME_SUFFIX) or FLOWCHART_RULE_KEY not in all_rule_keys:
226
- return None
227
- widget_code = all_tool_input.get(WIDGET_CODE_KEY)
228
- if widget_code is None:
229
- widget_input = all_tool_input.get(WIDGET_INPUT_KEY)
230
- widget_code = widget_input.get(WIDGET_CODE_KEY) if isinstance(widget_input, dict) else None
231
- code_text = FLOWCHART_MARKER_BLOCK_PATTERN.sub(
232
- "", widget_code if isinstance(widget_code, str) else ""
233
- )
234
- all_shape_patterns = (FLOWCHART_SVG_PATTERN, FLOWCHART_ARROW_PATTERN, FLOWCHART_DIAMOND_PATTERN)
235
- if all(each_pattern.search(code_text) for each_pattern in all_shape_patterns):
236
- return None
237
- return NOT_FLOWCHART_MESSAGE.format(reminder=rules.reminder(FLOWCHART_RULE_KEY))
238
-
239
-
240
- def _parsed_entries(all_transcript_lines: Iterable[str]) -> list[dict[str, object]]:
241
- all_entries = []
242
- for each_line in all_transcript_lines:
243
- try:
244
- parsed_entry = json.loads(each_line)
245
- except json.JSONDecodeError:
246
- continue
247
- if isinstance(parsed_entry, dict):
248
- all_entries.append(parsed_entry)
249
- return all_entries
250
-
251
-
252
- def _is_prompt_entry(all_entry_fields: dict[str, object]) -> bool:
253
- if all_entry_fields.get(ENTRY_TYPE_KEY) != USER_ENTRY_TYPE or all_entry_fields.get(IS_META_KEY):
254
- return False
255
- message = all_entry_fields.get(MESSAGE_KEY)
256
- content = message.get(CONTENT_KEY) if isinstance(message, dict) else None
257
- if isinstance(content, str):
258
- return bool(content.strip())
259
- return isinstance(content, list) and any(
260
- isinstance(each_block, dict) and each_block.get(BLOCK_TYPE_KEY) == TEXT_BLOCK_TYPE
261
- for each_block in content
262
- )
263
-
264
-
265
- def _content_blocks(all_entry_fields: dict[str, object], entry_type: str) -> list[dict[str, object]]:
266
- if all_entry_fields.get(ENTRY_TYPE_KEY) != entry_type:
267
- return []
268
- message = all_entry_fields.get(MESSAGE_KEY)
269
- content = message.get(CONTENT_KEY) if isinstance(message, dict) else None
270
- return [each for each in (content if isinstance(content, list) else []) if isinstance(each, dict)]
271
-
272
-
273
- def _tool_uses(all_entry_fields: dict[str, object]) -> list[dict[str, object]]:
274
- return [
275
- each_block
276
- for each_block in _content_blocks(all_entry_fields, ASSISTANT_ENTRY_TYPE)
277
- if each_block.get(BLOCK_TYPE_KEY) == TOOL_USE_BLOCK_TYPE
278
- ]
279
-
280
-
281
- def _entries_this_turn(all_transcript_lines: Iterable[str]) -> list[dict[str, object]]:
282
- all_entries = _parsed_entries(all_transcript_lines)
283
- last_prompt_index = max(
284
- (index for index, each in enumerate(all_entries) if _is_prompt_entry(each)), default=-1
285
- )
286
- return all_entries[last_prompt_index + 1 :]
287
-
288
-
289
- def _read_transcript_lines(transcript_path: object) -> list[str] | None:
290
- if not isinstance(transcript_path, str):
291
- return None
292
- try:
293
- return Path(transcript_path).read_text(encoding=TRANSCRIPT_ENCODING).splitlines()
294
- except OSError:
295
- return None
296
-
297
-
298
- def _result_blocks(all_entries: Iterable[dict[str, object]], is_error: bool) -> Iterator[dict[str, object]]:
299
- return (
300
- each_block
301
- for each_entry in all_entries
302
- for each_block in _content_blocks(each_entry, USER_ENTRY_TYPE)
303
- if each_block.get(BLOCK_TYPE_KEY) == TOOL_RESULT_BLOCK_TYPE
304
- and bool(each_block.get(IS_ERROR_KEY)) is is_error
305
- )
306
-
307
-
308
- def _result_ids(all_entries: list[dict[str, object]], is_error: bool) -> set[object]:
309
- return {each_block.get(TOOL_USE_ID_KEY) for each_block in _result_blocks(all_entries, is_error)}
310
-
311
-
312
- def _result_texts(result_content: object) -> list[str]:
313
- if isinstance(result_content, str):
314
- return [result_content]
315
- return [
316
- each_block[BLOCK_TEXT_KEY]
317
- for each_block in (result_content if isinstance(result_content, list) else [])
318
- if isinstance(each_block, dict) and isinstance(each_block.get(BLOCK_TEXT_KEY), str)
319
- ]
320
-
321
-
322
- def successful_result_text(transcript_path: object) -> str | None:
323
- """Join the text of every tool result in the session that came back without an error.
324
-
325
- A subagent's report is the result of its Agent call, so it counts. Returns None
326
- when the transcript cannot be read.
327
- """
328
- all_lines = _read_transcript_lines(transcript_path)
329
- if all_lines is None:
330
- return None
331
- return RESULT_TEXT_SEPARATOR.join(
332
- each_text
333
- for each_block in _result_blocks(_parsed_entries(all_lines), is_error=False)
334
- for each_text in _result_texts(each_block.get(CONTENT_KEY))
335
- )
336
-
337
-
338
- def _attachment_texts(all_entry_fields: dict[str, object]) -> list[str]:
339
- attachment = all_entry_fields.get(ATTACHMENT_KEY)
340
- if not isinstance(attachment, dict):
341
- return []
342
- attachment_type = attachment.get(BLOCK_TYPE_KEY)
343
- if not isinstance(attachment_type, str) or attachment_type not in ALL_HOOK_TEXT_ATTACHMENT_TYPES:
344
- return []
345
- if attachment_type == QUEUED_COMMAND_ATTACHMENT_TYPE and not _is_task_notification(attachment):
346
- return []
347
- all_texts = []
348
- for each_key in ALL_ATTACHMENT_TEXT_KEYS:
349
- field_value = attachment.get(each_key)
350
- all_texts.extend(_result_texts(field_value))
351
- if isinstance(field_value, list):
352
- all_texts.extend(each_item for each_item in field_value if isinstance(each_item, str))
353
- return all_texts
354
-
355
-
356
- def _is_task_notification(all_entry_fields: dict[str, object]) -> bool:
357
- origin = all_entry_fields.get(ORIGIN_KEY)
358
- return isinstance(origin, dict) and origin.get(ORIGIN_KIND_KEY) == TASK_NOTIFICATION_ORIGIN_KIND
359
-
360
-
361
- def _hook_texts(all_entry_fields: dict[str, object]) -> list[str]:
362
- entry_type = all_entry_fields.get(ENTRY_TYPE_KEY)
363
- if entry_type == ATTACHMENT_ENTRY_TYPE:
364
- return _attachment_texts(all_entry_fields)
365
- if entry_type != USER_ENTRY_TYPE:
366
- return []
367
- message = all_entry_fields.get(MESSAGE_KEY)
368
- all_texts = _result_texts(message.get(CONTENT_KEY) if isinstance(message, dict) else None)
369
- if _is_task_notification(all_entry_fields):
370
- return all_texts
371
- if not all_entry_fields.get(IS_META_KEY):
372
- return []
373
- return [each_text for each_text in all_texts if each_text.lstrip().startswith(ALL_HOOK_MESSAGE_PREFIXES)]
374
-
375
-
376
- def hook_supplied_text(transcript_path: object) -> str | None:
377
- """Join the text hooks and the harness put in the session outside tool results.
378
-
379
- It covers stop-hook feedback, system reminders, a background agent's task
380
- notification, and hook additional context, hook system message, and queued
381
- task notification attachments. A skill body, or a prompt the user typed
382
- while the session worked, does not count. Returns None when the transcript
383
- cannot be read.
384
- """
385
- all_lines = _read_transcript_lines(transcript_path)
386
- if all_lines is None:
387
- return None
388
- return RESULT_TEXT_SEPARATOR.join(
389
- each_text for each_entry in _parsed_entries(all_lines) for each_text in _hook_texts(each_entry)
390
- )
391
-
392
-
393
- def visual_shown_this_turn(all_transcript_lines: Iterable[str]) -> bool:
394
- """Return True when a widget or page call after the last prompt did not come back with an error."""
395
- all_entries = _entries_this_turn(all_transcript_lines)
396
- all_errored_ids = _result_ids(all_entries, is_error=True)
397
- return any(
398
- str(each_use.get(BLOCK_NAME_KEY)).endswith(ALL_VISUAL_TOOL_NAME_SUFFIXES)
399
- and each_use.get(BLOCK_ID_KEY) not in all_errored_ids
400
- for each_entry in all_entries
401
- for each_use in _tool_uses(each_entry)
402
- )
403
-
404
-
405
- def replies_sent_this_turn(all_transcript_lines: Iterable[str]) -> int:
406
- """Count the reply calls after the last prompt that came back without an error."""
407
- all_entries = _entries_this_turn(all_transcript_lines)
408
- all_delivered_ids = _result_ids(all_entries, is_error=False)
409
- return sum(
410
- 1
411
- for each_entry in all_entries
412
- for each_use in _tool_uses(each_entry)
413
- if str(each_use.get(BLOCK_NAME_KEY)).endswith(ALL_REPLY_TOOL_NAME_SUFFIXES)
414
- and each_use.get(BLOCK_ID_KEY) in all_delivered_ids
415
- )
416
-
417
-
418
- def second_reply_violation(transcript_path: object, rules: VisualReplyRules) -> str | None:
419
- """Return the deny reason for a reply when this turn already delivered one."""
420
- all_lines = _read_transcript_lines(transcript_path)
421
- if all_lines is None or replies_sent_this_turn(all_lines) < MAXIMUM_REPLIES_PER_TURN:
422
- return None
423
- return SECOND_REPLY_MESSAGE.format(reminder=rules.reminder(ONE_ITEM_RULE_KEY))
424
-
425
-
426
- def visual_violation(
427
- sentence_count: int, transcript_path: object, rules: VisualReplyRules
428
- ) -> str | None:
429
- """Return the deny reason for a reply of several sentences with no visual this turn."""
430
- if sentence_count <= MAXIMUM_SENTENCES_WITHOUT_VISUAL:
431
- return None
432
- all_lines = _read_transcript_lines(transcript_path)
433
- if all_lines is None or visual_shown_this_turn(all_lines):
434
- return None
435
- return NO_VISUAL_MESSAGE.format(
436
- sentence_count=sentence_count, reminder=rules.reminder(NO_PICTURE_RULE_KEY)
437
- )
438
-
439
-
440
- def reports_results(prose_text: str) -> bool:
441
- """Return True when the prose holds a markdown table or more figures than a reply may state without a picture.
442
-
443
- The caller removes code spans, links, and URLs first, so figures inside them do not count.
444
- """
445
- if TABLE_SEPARATOR_PATTERN.search(prose_text):
446
- return True
447
- all_figures = FIGURE_PATTERN.findall(LIST_NUMBER_PATTERN.sub(" ", prose_text))
448
- return len(all_figures) > MAXIMUM_FIGURES_WITHOUT_PICTURE
449
-
450
-
451
- def attaches_picture(reply_text: str, all_tool_input: dict[str, object]) -> bool:
452
- """Return True when the call attaches an image file or a published page, or embeds a markdown picture outside code."""
453
- all_attached_outputs = all_tool_input.get(ATTACHED_OUTPUTS_KEY)
454
- has_attached_picture = isinstance(all_attached_outputs, list) and any(
455
- isinstance(each_output, dict)
456
- and (
457
- each_output.get(OUTPUT_KIND_KEY) == OUTPUT_FRAME_KIND
458
- or (
459
- each_output.get(OUTPUT_KIND_KEY) == OUTPUT_FILE_KIND
460
- and str(each_output.get(OUTPUT_REF_KEY, "")).casefold().endswith(ALL_PICTURE_SUFFIXES)
461
- )
462
- )
463
- for each_output in all_attached_outputs
464
- )
465
- without_code = INLINE_CODE_PATTERN.sub(" ", FENCED_BLOCK_PATTERN.sub(" ", reply_text))
466
- return has_attached_picture or MARKDOWN_PICTURE_PATTERN.search(without_code) is not None
467
-
468
-
469
- def results_picture_violation(
470
- prose_text: str,
471
- reply_text: str,
472
- all_tool_input: dict[str, object],
473
- rules: VisualReplyRules | None,
474
- ) -> str | None:
475
- """Return the deny reason for a reply that reports results with no picture attached, or None."""
476
- if rules is None or not reports_results(prose_text) or attaches_picture(reply_text, all_tool_input):
477
- return None
478
- return RESULTS_PICTURE_MESSAGE.format(reminder=rules.reminder(RESULTS_PICTURE_RULE_KEY))
@@ -1,56 +0,0 @@
1
- {
2
- "rules": [
3
- {
4
- "key": "one_item",
5
- "label": "More than one item",
6
- "reminder": "Show one item per turn: one visual of that item and one short reply beside it. Put progress in the status line, and send the next item after the user answers this one."
7
- },
8
- {
9
- "key": "no_picture",
10
- "label": "No picture",
11
- "reminder": "Show the item as one visual first, a widget or a published page. Prefer a flowchart that runs left to right, with boxes for steps, a diamond for each yes or no check, and arrows between them. Then send one reply of one to three short sentences that states the outcome and each fact the user needs, and links the page."
12
- },
13
- {
14
- "key": "too_many_words",
15
- "label": "Too many words",
16
- "reminder": "Cut the reply to three short sentences or fewer. Keep the outcome and each fact the user needs in the reply; the visual adds detail around them."
17
- },
18
- {
19
- "key": "abbreviations",
20
- "label": "Abbreviations",
21
- "reminder": "Write each name in plain descriptive words. Spell out every abbreviation and drop tracker and item numbers. A pull request number stays only inside its link."
22
- },
23
- {
24
- "key": "wall_of_text",
25
- "label": "Wall of text",
26
- "reminder": "Put each point, and each step the reader takes, on its own line."
27
- },
28
- {
29
- "key": "not_flowchart",
30
- "label": "No flowchart",
31
- "reminder": "Redraw this widget as one SVG flowchart that runs left to right, with boxes for steps, a diamond for each yes or no check, and arrows between them, unless the item has no steps or checks."
32
- },
33
- {
34
- "key": "use_flowchart",
35
- "label": "Use the flowchart",
36
- "reminder": "Show the status as the status flowchart from docs/templates/artifact-page/status-flowchart.html: done steps, yes-or-no checks, stuck steps with recheck loops, and the next step, each opening its detail on click, unless the person asked for another shape."
37
- },
38
- {
39
- "key": "results_picture",
40
- "label": "Results with no picture",
41
- "reminder": "Show results in one chart rendered with the pele renderer, saved as an SVG or PNG file and passed in attached_outputs, with every label and number on it."
42
- }
43
- ],
44
- "allowed_capitalized_words": [
45
- "I",
46
- "OK"
47
- ],
48
- "lowercase_abbreviations": [
49
- "e.g.",
50
- "i.e.",
51
- "etc.",
52
- "vs.",
53
- "approx.",
54
- "w/"
55
- ]
56
- }