claude-dev-env 8.108.2 → 8.109.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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: correction
3
- description: Turn a correction the user made to an agent into a Suggested task card that starts a fix session in one click, list the corrections filed as issues before the card, write a handoff brief, or land the fix in this session with the fix playbook. Use when the user types /correction, /correction fix, says "file this as a correction", or asks to show the open corrections.
3
+ description: Turn a correction into a Suggested task card that starts a fix session in one click, list the corrections filed as issues, write a handoff brief, or land the fix in this session with the fix playbook. Use when the user types /correction, /correction fix, says "file this as a correction", or asks to show the open corrections.
4
4
  argument-hint: "[fix] <what the agent got wrong, in the user's words>"
5
5
  ---
6
6
 
@@ -1,7 +1,11 @@
1
1
  ---
2
2
  name: mod-playbooks
3
3
  description: >-
4
- Map of playbooks for driving a Claude Code mod (plugin) and seeing its screen: press keys, open menus and drawers, hover a reply to show its action row, click a dropdown, type in a field, fire a toast or a question card, and capture each screen as text and PNG. Use when an agent must test a mod, check a fix by looking at it, or show a mod to the operator on their own desktop.
4
+ Playbooks for driving a Claude Code mod (plugin) and seeing its screen: press keys,
5
+ open menus and drawers, hover a reply to show its action row, click a dropdown, type in
6
+ a field, fire a toast or a question card, and capture each screen as text and PNG. Use
7
+ when an agent must test a mod, check a fix by looking at it, or show a mod to the
8
+ operator on their own desktop.
5
9
  ---
6
10
 
7
11
  # Mod playbooks
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sync-dev-env
3
- description: Install or update claude-dev-env in a running session, link the skills of every enabled plugin so a running session loads them, and schedule a daily re-sync at 6:00 AM local by default. Use when the user asks to sync claude-dev-env into a session, to load the skills of a plugin without a restart, when a /skill fails to resolve, to set up the daily sync, to check which session prompt a session uses, or to turn the claude-dev-env session prompt off for one session.
3
+ description: Install or update claude-dev-env in a running session, link every enabled plugin's skills so a running session loads them, and schedule a daily re-sync at 6:00 AM local by default. Use when the user asks to sync claude-dev-env into a session, to load the skills of a plugin without a restart, when a /skill fails to resolve, to set up the daily sync, to check which session prompt a session uses, or to turn the claude-dev-env session prompt off for one session.
4
4
  argument-hint: "[HH:MM] [IANA time zone]"
5
5
  ---
6
6
 
@@ -4,12 +4,14 @@
4
4
 
5
5
  unlisted file lines > limit -> file finding
6
6
  unpointed section > detail limit -> section finding
7
+ agent file no pointer, or unlinked line > words -> prose finding, unless skipped
7
8
  listed file lines null, lines > limit -> file finding
8
9
  lines N, lines > limit and lines > N -> grown finding
9
10
  section heading not recorded -> section finding
10
11
  CI ratchet changed file below its record N -> record the new count, or null
11
12
  changed file lost a recorded section -> drop it from the entry
12
13
  changed file within budget -> remove the entry
14
+ changed agent file -> report only the prose findings it added
13
15
  """
14
16
 
15
17
  from __future__ import annotations
@@ -17,6 +19,8 @@ from __future__ import annotations
17
19
  import json
18
20
  from collections import Counter
19
21
  from collections.abc import Iterable
22
+ from dataclasses import replace
23
+ from pathlib import PurePosixPath
20
24
 
21
25
  from context_budget.model import (
22
26
  BaselineEntry,
@@ -25,15 +29,26 @@ from context_budget.model import (
25
29
  FileMeasure,
26
30
  SectionScan,
27
31
  )
28
- from context_budget.sections import baseline_entry_for, measure_file
32
+ from context_budget.sections import (
33
+ baseline_entry_for,
34
+ is_path_skipped,
35
+ measure_file,
36
+ prose_word_count,
37
+ scan_prose,
38
+ )
29
39
  from hooks_constants.context_budget_constants import (
40
+ ALL_PROSE_RULE_FILE_NAMES,
30
41
  FILE_FINDING_TEMPLATE,
31
42
  FILE_SCOPE,
32
43
  GROWN_FINDING_TEMPLATE,
33
44
  GROWN_PAST_PRIOR_TEMPLATE,
34
45
  KEBAB_SEPARATOR,
35
46
  LINES_KEY,
47
+ NO_POINTER_FINDING_TEMPLATE,
48
+ NO_POINTER_SCOPE,
36
49
  NON_KEBAB_CHARACTER_PATTERN,
50
+ PROSE_LINE_FINDING_TEMPLATE,
51
+ PROSE_LINE_SCOPE_PREFIX,
37
52
  RATCHET_LOWER_TEMPLATE,
38
53
  RATCHET_REMOVE_TEMPLATE,
39
54
  SECTION_FINDING_TEMPLATE,
@@ -153,23 +168,76 @@ def _file_scope_findings(
153
168
  return all_findings, all_new_sections
154
169
 
155
170
 
171
+ def _is_prose_rule_path(policy: BudgetPolicy, relative_path: str) -> bool:
172
+ is_agent_file = PurePosixPath(relative_path).name in ALL_PROSE_RULE_FILE_NAMES
173
+ return is_agent_file and not is_path_skipped(policy, relative_path)
174
+
175
+
176
+ def _prose_findings(
177
+ policy: BudgetPolicy, relative_path: str, text: str
178
+ ) -> tuple[BudgetFinding, ...]:
179
+ if not _is_prose_rule_path(policy, relative_path):
180
+ return ()
181
+ scan = scan_prose(text, policy.prose_line_word_limit)
182
+ all_findings: list[BudgetFinding] = []
183
+ if scan.has_detail_line and not scan.has_pointer_line:
184
+ all_findings.append(
185
+ BudgetFinding(
186
+ relative_path,
187
+ NO_POINTER_SCOPE,
188
+ NO_POINTER_FINDING_TEMPLATE.format(path=relative_path),
189
+ )
190
+ )
191
+ for each_line in scan.all_long_unlinked_lines:
192
+ excerpt = each_line.strip()
193
+ all_findings.append(
194
+ BudgetFinding(
195
+ relative_path,
196
+ PROSE_LINE_SCOPE_PREFIX + excerpt,
197
+ PROSE_LINE_FINDING_TEMPLATE.format(
198
+ path=relative_path,
199
+ excerpt=excerpt,
200
+ count=prose_word_count(each_line),
201
+ limit=policy.prose_line_word_limit,
202
+ ),
203
+ )
204
+ )
205
+ return tuple(all_findings)
206
+
207
+
208
+ def _prose_findings_added_since(
209
+ policy: BudgetPolicy, relative_path: str, text: str, prior_text: str | None
210
+ ) -> tuple[BudgetFinding, ...]:
211
+ all_findings = _prose_findings(policy, relative_path, text)
212
+ if prior_text is None or prior_text == text:
213
+ return all_findings
214
+ return _introduced(
215
+ all_findings, _prose_findings(policy, relative_path, prior_text), has_grown=False
216
+ )
217
+
218
+
156
219
  def file_findings(
157
220
  policy: BudgetPolicy, relative_path: str, text: str, ratchet_prior_text: str | None
158
221
  ) -> tuple[BudgetFinding, ...]:
159
- """Check one file against its kind and the over-budget list.
222
+ """Check one file against its kind, the over-budget list, and the prose rule.
160
223
 
161
224
  Args:
162
225
  policy: Budget policy.
163
226
  relative_path: Repository-relative POSIX path.
164
227
  text: Current file text.
165
228
  ratchet_prior_text: Prior text when the CI ratchet applies, else None.
229
+ A changed file reports only the prose findings its prior text
230
+ lacked. An unchanged or new file reports every prose finding.
166
231
 
167
232
  Returns:
168
- Findings in file-then-section order.
233
+ Findings in file, section, then prose order. Prose findings apply to
234
+ AGENTS.md and CLAUDE.md files whatever kind the policy gives them,
235
+ except a kind the policy skips.
169
236
  """
237
+ prose_findings = _prose_findings_added_since(policy, relative_path, text, ratchet_prior_text)
170
238
  measure = measure_file(policy, relative_path, text)
171
239
  if measure is None:
172
- return ()
240
+ return prose_findings
173
241
  recorded = policy.baseline_entry_by_path.get(relative_path)
174
242
  is_ratchet_due = ratchet_prior_text is not None and ratchet_prior_text != text
175
243
  grown_template = (
@@ -182,6 +250,7 @@ def file_findings(
182
250
  *all_findings,
183
251
  *(_section_finding(relative_path, each, policy.section_detail_line_limit)
184
252
  for each in all_new_sections),
253
+ *prose_findings,
185
254
  )
186
255
 
187
256
 
@@ -192,12 +261,9 @@ def _with_prior_as_baseline(
192
261
  prior_entry = None if prior_measure is None else baseline_entry_for(prior_measure)
193
262
  if prior_entry is None:
194
263
  return policy
195
- return BudgetPolicy(
196
- policy.section_detail_line_limit,
197
- policy.all_kinds,
198
- policy.all_hooks,
199
- {**policy.baseline_entry_by_path, relative_path: prior_entry},
200
- policy.baseline_characters_by_hook_name,
264
+ return replace(
265
+ policy,
266
+ baseline_entry_by_path={**policy.baseline_entry_by_path, relative_path: prior_entry},
201
267
  is_baseline_the_prior_text=True,
202
268
  )
203
269
 
@@ -14,6 +14,8 @@ from __future__ import annotations
14
14
  from collections.abc import Mapping
15
15
  from dataclasses import dataclass, field
16
16
 
17
+ from hooks_constants.context_budget_constants import DEFAULT_PROSE_LINE_WORD_LIMIT
18
+
17
19
 
18
20
  class ContextBudgetPolicyError(ValueError):
19
21
  """Raised when a policy file does not match the documented shape."""
@@ -79,6 +81,7 @@ class BudgetPolicy:
79
81
  baseline_characters_by_hook_name: Over-budget hooks by name.
80
82
  is_baseline_the_prior_text: Whether the baseline entry was measured from
81
83
  the file's prior text because the repository has no policy file.
84
+ prose_line_word_limit: Words an unlinked agent-file detail line may hold.
82
85
  """
83
86
 
84
87
  section_detail_line_limit: int
@@ -87,6 +90,7 @@ class BudgetPolicy:
87
90
  baseline_entry_by_path: Mapping[str, BaselineEntry] = field(default_factory=dict)
88
91
  baseline_characters_by_hook_name: Mapping[str, int] = field(default_factory=dict)
89
92
  is_baseline_the_prior_text: bool = False
93
+ prose_line_word_limit: int = DEFAULT_PROSE_LINE_WORD_LIMIT
90
94
 
91
95
 
92
96
  @dataclass(frozen=True)
@@ -119,6 +123,21 @@ class FileMeasure:
119
123
  all_over_limit_sections: tuple[SectionScan, ...]
120
124
 
121
125
 
126
+ @dataclass(frozen=True)
127
+ class ProseScan:
128
+ """Prose measurements of one Markdown body.
129
+
130
+ Attributes:
131
+ has_detail_line: Whether the body holds any detail line.
132
+ has_pointer_line: Whether any body line holds a relative link or an @import line.
133
+ all_long_unlinked_lines: Detail lines with no relative link over the word limit.
134
+ """
135
+
136
+ has_detail_line: bool
137
+ has_pointer_line: bool
138
+ all_long_unlinked_lines: tuple[str, ...]
139
+
140
+
122
141
  @dataclass(frozen=True)
123
142
  class BudgetFinding:
124
143
  """One budget violation.
@@ -33,6 +33,7 @@ from hooks_constants.context_budget_constants import (
33
33
  CHANGE_RAISES_FILE,
34
34
  CHANGE_RAISES_HOOK,
35
35
  CHANGE_RAISES_LINE_LIMIT,
36
+ CHANGE_RAISES_PROSE_LIMIT,
36
37
  CHANGE_RAISES_SECTION_LIMIT,
37
38
  CHANGE_RECORDS_FILE_LINES,
38
39
  FILE_SCOPE,
@@ -78,6 +79,12 @@ def _limit_changes(
78
79
  prior=prior_section_limit, current=current_section_limit
79
80
  )
80
81
  )
82
+ prior_prose_limit = prior_policy.prose_line_word_limit
83
+ current_prose_limit = current_policy.prose_line_word_limit
84
+ if current_prose_limit > prior_prose_limit:
85
+ all_changes.append(
86
+ CHANGE_RAISES_PROSE_LIMIT.format(prior=prior_prose_limit, current=current_prose_limit)
87
+ )
81
88
  current_kind_by_name = {each.name: each for each in current_policy.all_kinds}
82
89
  all_prior_kind_names = tuple(
83
90
  each.name for each in prior_policy.all_kinds if each.name in current_kind_by_name
@@ -23,6 +23,7 @@ from hooks_constants.context_budget_constants import (
23
23
  BASELINE_KEY,
24
24
  CHAR_LIMIT_KEY,
25
25
  COMMAND_KEY,
26
+ DEFAULT_PROSE_LINE_WORD_LIMIT,
26
27
  DEFAULT_SECTION_DETAIL_LINE_LIMIT,
27
28
  GIT_MARKER_NAME,
28
29
  HOOKS_KEY,
@@ -34,6 +35,7 @@ from hooks_constants.context_budget_constants import (
34
35
  POLICY_ERROR_BAD_FIELD,
35
36
  POLICY_ERROR_DUPLICATE_HOOK_NAME,
36
37
  POLICY_ERROR_NOT_OBJECT,
38
+ PROSE_LINE_WORD_LIMIT_KEY,
37
39
  SECTION_DETAIL_LINE_LIMIT_KEY,
38
40
  SECTION_RULE_KEY,
39
41
  SECTIONS_KEY,
@@ -176,6 +178,10 @@ def parse_policy(policy_text: str) -> BudgetPolicy:
176
178
  raw_policy.get(SECTION_DETAIL_LINE_LIMIT_KEY, DEFAULT_SECTION_DETAIL_LINE_LIMIT),
177
179
  SECTION_DETAIL_LINE_LIMIT_KEY,
178
180
  ),
181
+ prose_line_word_limit=_integer(
182
+ raw_policy.get(PROSE_LINE_WORD_LIMIT_KEY, DEFAULT_PROSE_LINE_WORD_LIMIT),
183
+ PROSE_LINE_WORD_LIMIT_KEY,
184
+ ),
179
185
  all_kinds=tuple(
180
186
  _parse_kind(each) for each in _items(raw_policy.get(KINDS_KEY, []), KINDS_KEY)
181
187
  ),
@@ -6,12 +6,13 @@
6
6
  Step one. detail line
7
7
  | a | b | table row, not detail
8
8
  - [ref](reference/x.md) pure link item, not detail; relative link is a pointer
9
+ @AGENTS.md import line; a pointer for the prose rule only
9
10
  """
10
11
 
11
12
  from __future__ import annotations
12
13
 
13
14
  from collections.abc import Sequence
14
- from dataclasses import dataclass
15
+ from dataclasses import dataclass, field
15
16
  from fnmatch import fnmatchcase
16
17
 
17
18
  from context_budget.model import (
@@ -19,14 +20,18 @@ from context_budget.model import (
19
20
  BudgetPolicy,
20
21
  ContextKind,
21
22
  FileMeasure,
23
+ ProseScan,
22
24
  SectionScan,
23
25
  )
26
+ from hooks_constants.ask_user_question_shape import count_prose_words
24
27
  from hooks_constants.context_budget_constants import (
25
28
  ALL_NON_RELATIVE_TARGET_PREFIXES,
26
29
  ATX_HEADING_PATTERN,
27
30
  FENCE_OPEN_PATTERN,
28
31
  FRONTMATTER_DELIMITER,
32
+ IMPORT_DIRECTIVE_PATTERN,
29
33
  LINK_TARGET_PATTERN,
34
+ LIST_MARKER_PATTERN,
30
35
  PATH_SEPARATOR,
31
36
  PURE_LINK_LIST_ITEM_PATTERN,
32
37
  RECURSIVE_GLOB_SEGMENT,
@@ -67,6 +72,13 @@ def path_matches_pattern(pattern: str, relative_path: str) -> bool:
67
72
  return _segments_match(pattern.split(PATH_SEPARATOR), relative_path.split(PATH_SEPARATOR))
68
73
 
69
74
 
75
+ def _first_matching_kind(policy: BudgetPolicy, relative_path: str) -> ContextKind | None:
76
+ for each_kind in policy.all_kinds:
77
+ if any(path_matches_pattern(each, relative_path) for each in each_kind.all_patterns):
78
+ return each_kind
79
+ return None
80
+
81
+
70
82
  def context_kind_for_path(policy: BudgetPolicy, relative_path: str) -> ContextKind | None:
71
83
  """Return the measured kind of a path; the first matching kind wins.
72
84
 
@@ -77,10 +89,22 @@ def context_kind_for_path(policy: BudgetPolicy, relative_path: str) -> ContextKi
77
89
  Returns:
78
90
  The matching kind, or None when no kind matches or the match is skipped.
79
91
  """
80
- for each_kind in policy.all_kinds:
81
- if any(path_matches_pattern(each, relative_path) for each in each_kind.all_patterns):
82
- return each_kind if each_kind.line_limit is not None else None
83
- return None
92
+ kind = _first_matching_kind(policy, relative_path)
93
+ return kind if kind is not None and kind.line_limit is not None else None
94
+
95
+
96
+ def is_path_skipped(policy: BudgetPolicy, relative_path: str) -> bool:
97
+ """Return whether the first kind that matches a path has no line limit.
98
+
99
+ Args:
100
+ policy: Budget policy holding the ordered kind table.
101
+ relative_path: Repository-relative POSIX path.
102
+
103
+ Returns:
104
+ True when the matching kind is a skipped kind, else False.
105
+ """
106
+ kind = _first_matching_kind(policy, relative_path)
107
+ return kind is not None and kind.line_limit is None
84
108
 
85
109
 
86
110
  def _body_lines(text: str) -> list[str]:
@@ -123,6 +147,9 @@ class _SectionWalk:
123
147
  detail_line_count: int = 0
124
148
  has_pointer: bool = False
125
149
  opening_marker: str | None = None
150
+ has_detail_line: bool = False
151
+ has_import_line: bool = False
152
+ all_unlinked_detail_lines: list[str] = field(default_factory=list)
126
153
 
127
154
  def close_section(self) -> None:
128
155
  self.all_scans.append(SectionScan(self.heading, self.detail_line_count, self.has_pointer))
@@ -145,8 +172,18 @@ class _SectionWalk:
145
172
  self.detail_line_count = 0
146
173
  self.has_pointer = False
147
174
  else:
148
- self.detail_line_count += int(_is_detail_line(line))
149
- self.has_pointer = self.has_pointer or _line_has_pointer(line)
175
+ self.read_body_line(line)
176
+
177
+ def read_body_line(self, line: str) -> None:
178
+ is_detail = _is_detail_line(line)
179
+ has_link = _line_has_pointer(line)
180
+ is_import = IMPORT_DIRECTIVE_PATTERN.match(line) is not None
181
+ self.detail_line_count += int(is_detail)
182
+ self.has_pointer = self.has_pointer or has_link
183
+ self.has_detail_line = self.has_detail_line or is_detail
184
+ self.has_import_line = self.has_import_line or is_import
185
+ if is_detail and not has_link and not is_import:
186
+ self.all_unlinked_detail_lines.append(line)
150
187
 
151
188
 
152
189
  def scan_sections(text: str) -> tuple[SectionScan, ...]:
@@ -161,6 +198,10 @@ def scan_sections(text: str) -> tuple[SectionScan, ...]:
161
198
  Returns:
162
199
  One scan per section in document order, starting with ``(top)``.
163
200
  """
201
+ return tuple(_walk_body(text).all_scans)
202
+
203
+
204
+ def _walk_body(text: str) -> _SectionWalk:
164
205
  walk = _SectionWalk([])
165
206
  for each_line in _body_lines(text):
166
207
  if walk.opening_marker is not None:
@@ -168,7 +209,46 @@ def scan_sections(text: str) -> tuple[SectionScan, ...]:
168
209
  else:
169
210
  walk.read_open(each_line)
170
211
  walk.close_section()
171
- return tuple(walk.all_scans)
212
+ return walk
213
+
214
+
215
+ def prose_word_count(line: str) -> int:
216
+ """Count the words of one Markdown line after its list marker.
217
+
218
+ Args:
219
+ line: One line of Markdown text.
220
+
221
+ Returns:
222
+ The number of words in the line's text.
223
+ """
224
+ return count_prose_words(LIST_MARKER_PATTERN.sub("", line))
225
+
226
+
227
+ def scan_prose(text: str, word_limit: int) -> ProseScan:
228
+ """Measure the prose rule's inputs for one Markdown body.
229
+
230
+ Fenced lines, tables, and pure link items are not detail lines. A line
231
+ counts as pointed when it holds a relative link or an @import line.
232
+
233
+ Args:
234
+ text: Full file text; leading frontmatter is removed.
235
+ word_limit: Words an unlinked detail line may hold.
236
+
237
+ Returns:
238
+ Whether the body has a detail line, whether any line links to a relative
239
+ target or holds an @import line, and the unlinked detail lines over the
240
+ word limit.
241
+ """
242
+ walk = _walk_body(text)
243
+ return ProseScan(
244
+ walk.has_detail_line,
245
+ walk.has_import_line or any(each_scan.has_pointer for each_scan in walk.all_scans),
246
+ tuple(
247
+ each_line
248
+ for each_line in walk.all_unlinked_detail_lines
249
+ if prose_word_count(each_line) > word_limit
250
+ ),
251
+ )
172
252
 
173
253
 
174
254
  def measure_file(policy: BudgetPolicy, relative_path: str, text: str) -> FileMeasure | None:
@@ -69,3 +69,15 @@ def section_text(heading: str, detail_count: int, pointer_line: str = "") -> str
69
69
  if pointer_line:
70
70
  all_lines.append(pointer_line)
71
71
  return "\n".join(all_lines) + "\n"
72
+
73
+
74
+ def words_text(word_count: int) -> str:
75
+ """Return one line of plain words.
76
+
77
+ Args:
78
+ word_count: Number of words to write.
79
+
80
+ Returns:
81
+ The words separated by single spaces, without a newline.
82
+ """
83
+ return " ".join(["word"] * word_count)
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from context_budget.tests.budget_support import SKILL_PATH, policy_text, section_text
5
+ from context_budget.tests.budget_support import SKILL_PATH, policy_text, section_text, words_text
6
6
  from context_budget.findings import edit_findings, file_findings
7
7
  from context_budget.policy_file import default_policy, parse_policy
8
8
 
@@ -118,3 +118,108 @@ def test_edit_of_an_unlisted_over_budget_file_is_allowed_when_it_shrinks_under_a
118
118
  "file",
119
119
  "Alpha",
120
120
  ]
121
+
122
+
123
+ AGENT_PATH = "shared_utils/files/AGENTS.md"
124
+ LONG_LINE = words_text(26)
125
+ POINTER_LINE = "Read [the plan](reference/plan.md)."
126
+
127
+
128
+ def test_agent_file_with_no_relative_link_fails_the_pointer_rule() -> None:
129
+ policy = parse_policy(policy_text())
130
+
131
+ all_findings = file_findings(policy, AGENT_PATH, "Selection records own icon choice.\n", None)
132
+
133
+ assert [each.scope for each in all_findings] == ["no pointer line"]
134
+ assert (
135
+ "shared_utils/files/AGENTS.md: context-budget: file has no pointer line"
136
+ in all_findings[0].message
137
+ )
138
+
139
+
140
+ def test_agent_file_fails_on_an_unlinked_line_over_the_word_limit_only() -> None:
141
+ policy = parse_policy(policy_text())
142
+ exact_line = words_text(25)
143
+
144
+ over_limit = file_findings(policy, AGENT_PATH, f"{LONG_LINE}\n{POINTER_LINE}\n", None)
145
+ at_limit = file_findings(policy, AGENT_PATH, f"{exact_line}\n{POINTER_LINE}\n", None)
146
+
147
+ assert [each.scope for each in over_limit] == [f"prose line: {LONG_LINE}"]
148
+ assert "26 words" in over_limit[0].message
149
+ assert at_limit == ()
150
+
151
+
152
+ def test_claude_file_gets_the_same_rule_and_a_skill_file_does_not() -> None:
153
+ policy = parse_policy(policy_text())
154
+
155
+ claude_findings = file_findings(policy, "app/CLAUDE.md", f"{LONG_LINE}\n{POINTER_LINE}\n", None)
156
+
157
+ assert [each.scope for each in claude_findings] == [f"prose line: {LONG_LINE}"]
158
+ assert file_findings(policy, SKILL_PATH, f"{LONG_LINE}\n", None) == ()
159
+
160
+
161
+ def test_blank_agent_file_passes_the_pointer_rule() -> None:
162
+ policy = parse_policy(policy_text())
163
+
164
+ assert file_findings(policy, AGENT_PATH, "\n", None) == ()
165
+ assert file_findings(policy, AGENT_PATH, "", None) == ()
166
+
167
+
168
+ def test_edit_that_adds_a_long_unlinked_line_introduces_its_finding_once() -> None:
169
+ policy = parse_policy(policy_text())
170
+ prior_text = f"{POINTER_LINE}\n"
171
+ post_text = f"{prior_text}{LONG_LINE}\n"
172
+
173
+ introduced = edit_findings(policy, AGENT_PATH, prior_text, post_text, False)
174
+
175
+ assert [each.scope for each in introduced] == [f"prose line: {LONG_LINE}"]
176
+ assert edit_findings(policy, AGENT_PATH, post_text, f"{post_text}Short line.\n", False) == ()
177
+
178
+
179
+ def test_changed_file_reports_only_prose_findings_its_prior_text_lacked() -> None:
180
+ policy = parse_policy(policy_text())
181
+ prior_text = f"{POINTER_LINE}\n{LONG_LINE}\n"
182
+ kept_text = f"{prior_text}Short line.\n"
183
+ added_line = words_text(27)
184
+ added_text = f"{kept_text}{added_line}\n"
185
+ long_line_scopes = [f"prose line: {LONG_LINE}"]
186
+
187
+ assert file_findings(policy, AGENT_PATH, kept_text, prior_text) == ()
188
+ added_findings = file_findings(policy, AGENT_PATH, added_text, prior_text)
189
+ assert [each.scope for each in added_findings] == [f"prose line: {added_line}"]
190
+ assert [each.scope for each in file_findings(policy, AGENT_PATH, kept_text, None)] == (
191
+ long_line_scopes
192
+ )
193
+ assert [
194
+ each.scope for each in file_findings(policy, AGENT_PATH, prior_text, prior_text)
195
+ ] == long_line_scopes
196
+
197
+
198
+ def test_claude_file_that_only_imports_agents_md_passes_the_pointer_rule() -> None:
199
+ policy = parse_policy(policy_text())
200
+
201
+ assert file_findings(policy, "app/CLAUDE.md", "@AGENTS.md\n", None) == ()
202
+
203
+
204
+ def test_import_line_satisfies_the_pointer_rule_but_not_the_word_limit() -> None:
205
+ policy = parse_policy(policy_text())
206
+
207
+ all_findings = file_findings(policy, "app/CLAUDE.md", f"@AGENTS.md\n{LONG_LINE}\n", None)
208
+
209
+ assert [each.scope for each in all_findings] == [f"prose line: {LONG_LINE}"]
210
+
211
+
212
+ def test_import_line_does_not_exempt_a_section_from_the_section_rule() -> None:
213
+ policy = parse_policy(policy_text())
214
+ text = section_text("Alpha", 7, "@reference/alpha.md")
215
+
216
+ assert [each.scope for each in file_findings(policy, SKILL_PATH, text, None)] == ["Alpha"]
217
+
218
+
219
+ def test_skipped_kind_hides_an_agent_file_from_the_prose_rule() -> None:
220
+ policy = parse_policy(policy_text())
221
+ text = "Selection records own icon choice.\n"
222
+
223
+ assert file_findings(policy, "pkg/skills-archived/AGENTS.md", text, None) == ()
224
+ live_findings = file_findings(policy, "pkg/live/AGENTS.md", text, None)
225
+ assert [each.scope for each in live_findings] == ["no pointer line"]
@@ -173,3 +173,22 @@ def test_appending_a_kind_and_tightening_limits_passes(tmp_path: Path) -> None:
173
173
  parse_policy(json.dumps(raw_current)),
174
174
  tmp_path,
175
175
  ) == ()
176
+
177
+
178
+ def test_raising_the_prose_line_word_limit_is_a_loosening_change(tmp_path: Path) -> None:
179
+ raw_prior = json.loads(policy_text())
180
+ raw_prior["prose_line_word_limit"] = 25
181
+ raw_current = json.loads(policy_text())
182
+ raw_current["prose_line_word_limit"] = 40
183
+ prior_policy = parse_policy(json.dumps(raw_prior))
184
+
185
+ raised = policy_shrink_findings(
186
+ "p", prior_policy, parse_policy(json.dumps(raw_current)), tmp_path
187
+ )
188
+ raw_current["prose_line_word_limit"] = 10
189
+ lowered = policy_shrink_findings(
190
+ "p", prior_policy, parse_policy(json.dumps(raw_current)), tmp_path
191
+ )
192
+
193
+ assert "prose_line_word_limit rises from 25 to 40" in raised[0].message
194
+ assert lowered == ()
@@ -60,3 +60,14 @@ def test_repository_root_accepts_a_git_file_and_policy_reads_from_it(tmp_path: P
60
60
  find_repository_root(tmp_path / "x.md") is None
61
61
  or find_repository_root(tmp_path / "x.md") != repository_root
62
62
  )
63
+
64
+
65
+ def test_prose_line_word_limit_defaults_to_25_and_reads_its_key() -> None:
66
+ raw_policy = json.loads(policy_text())
67
+
68
+ assert parse_policy(json.dumps(raw_policy)).prose_line_word_limit == 25
69
+ raw_policy["prose_line_word_limit"] = 12
70
+ assert parse_policy(json.dumps(raw_policy)).prose_line_word_limit == 12
71
+ raw_policy["prose_line_word_limit"] = "twelve"
72
+ with pytest.raises(ContextBudgetPolicyError):
73
+ parse_policy(json.dumps(raw_policy))