claude-dev-env 8.100.0 → 8.100.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.
@@ -43,13 +43,32 @@ TOOL_RESULT_ENTRY = {
43
43
  },
44
44
  }
45
45
 
46
+ REFUSED_TOOL_RESULT_ENTRY = {
47
+ "type": "user",
48
+ "message": {
49
+ "content": [
50
+ {
51
+ "type": "tool_result",
52
+ "tool_use_id": "toolu_1",
53
+ "content": "<tool_use_error>Skill verify cannot be used with Skill tool</tool_use_error>",
54
+ "is_error": True,
55
+ }
56
+ ]
57
+ },
58
+ }
59
+
46
60
 
47
61
  def _skill_entry(skill_name: str) -> dict[str, object]:
48
62
  return {
49
63
  "type": "assistant",
50
64
  "message": {
51
65
  "content": [
52
- {"type": "tool_use", "name": "Skill", "input": {"skill": skill_name}}
66
+ {
67
+ "type": "tool_use",
68
+ "id": "toolu_1",
69
+ "name": "Skill",
70
+ "input": {"skill": skill_name},
71
+ }
53
72
  ]
54
73
  },
55
74
  }
@@ -197,6 +216,33 @@ def test_docs_only_commit_passes(repository: Path, tmp_path: Path) -> None:
197
216
  )
198
217
 
199
218
 
219
+ def test_data_files_under_docs_folder_pass(repository: Path, tmp_path: Path) -> None:
220
+ (repository / "docs" / "records").mkdir(parents=True)
221
+ (repository / "docs" / "records" / "proof.json").write_text("{}\n", encoding="utf-8")
222
+ (repository / "docs" / "ruleset.yaml").write_text("rules: []\n", encoding="utf-8")
223
+ _git(repository, "add", "-A")
224
+ assert not _is_denied(
225
+ _payload("git commit -m records", repository, _unverified(tmp_path))
226
+ )
227
+
228
+
229
+ def test_code_under_docs_folder_is_denied(repository: Path, tmp_path: Path) -> None:
230
+ (repository / "docs").mkdir()
231
+ (repository / "docs" / "conf.py").write_text("VALUE = 2\n", encoding="utf-8")
232
+ _git(repository, "add", "-A")
233
+ assert _is_denied(
234
+ _payload("git commit -m conf", repository, _unverified(tmp_path))
235
+ )
236
+
237
+
238
+ def test_json_outside_docs_folder_is_denied(repository: Path, tmp_path: Path) -> None:
239
+ (repository / "config.json").write_text("{}\n", encoding="utf-8")
240
+ _git(repository, "add", "-A")
241
+ assert _is_denied(
242
+ _payload("git commit -m config", repository, _unverified(tmp_path))
243
+ )
244
+
245
+
200
246
  def test_tests_only_commit_passes(repository: Path, tmp_path: Path) -> None:
201
247
  (repository / "test_app.py").write_text(
202
248
  "def test_value() -> None:\n pass\n", encoding="utf-8"
@@ -219,6 +265,15 @@ def test_docs_plus_code_commit_is_denied(repository: Path, tmp_path: Path) -> No
219
265
  )
220
266
 
221
267
 
268
+ def test_refused_verify_skill_call_is_denied(repository: Path, tmp_path: Path) -> None:
269
+ (repository / "app.py").write_text("VALUE = 2\n", encoding="utf-8")
270
+ _git(repository, "add", "app.py")
271
+ transcript_path = _transcript(
272
+ tmp_path, PROMPT_ENTRY, _skill_entry("verify"), REFUSED_TOOL_RESULT_ENTRY
273
+ )
274
+ assert _is_denied(_payload("git commit -m change", repository, transcript_path))
275
+
276
+
222
277
  def test_verify_skill_call_after_the_last_prompt_passes(
223
278
  repository: Path, tmp_path: Path
224
279
  ) -> None:
@@ -33,6 +33,8 @@ from hooks_constants.verify_before_commit_gate_constants import (
33
33
  ALL_ADD_EVERYTHING_OPTIONS,
34
34
  ALL_COMMIT_ALL_OPTIONS,
35
35
  ALL_COMMIT_VALUED_SHORT_FLAGS,
36
+ ALL_DOCS_DATA_EXTENSIONS,
37
+ ALL_DOCS_DIRECTORY_NAMES,
36
38
  ALL_DOCS_EXTENSIONS,
37
39
  ALL_GIT_EXECUTABLES,
38
40
  ALL_SLASH_COMMAND_MARKERS,
@@ -176,7 +178,12 @@ def _is_docs_or_test_path(repository_path: str) -> bool:
176
178
  path = PurePosixPath(repository_path)
177
179
  if path.suffix.lower() in ALL_DOCS_EXTENSIONS or path.name in ALL_TEST_FILE_NAMES:
178
180
  return True
179
- if any(each_part in ALL_TEST_DIRECTORY_NAMES for each_part in path.parts[:-1]):
181
+ all_directory_parts = path.parts[:-1]
182
+ if path.suffix.lower() in ALL_DOCS_DATA_EXTENSIONS and any(
183
+ each_part in ALL_DOCS_DIRECTORY_NAMES for each_part in all_directory_parts
184
+ ):
185
+ return True
186
+ if any(each_part in ALL_TEST_DIRECTORY_NAMES for each_part in all_directory_parts):
180
187
  return True
181
188
  return (
182
189
  path.name.startswith(ALL_TEST_FILE_PREFIXES)
@@ -245,6 +252,9 @@ def decision_for(all_payload_fields: dict[str, object]) -> dict[str, object] | N
245
252
  git commit, code staged, no verify since the last prompt -> DENY_REASON
246
253
  git add app.py; git commit, empty index, no verify -> DENY_REASON
247
254
  git commit, only docs or test files -> None
255
+ git commit, only data files (.json, .jsonl, .yaml, .yml,
256
+ .csv) under a docs folder -> None
257
+ git commit, a .py file under a docs folder -> DENY_REASON
248
258
  git commit after a verify Skill call or a /verify prompt -> None
249
259
  git commit in a repository with no verify skill directory -> None
250
260
  transcript missing or unreadable, or git fails -> None
@@ -18,7 +18,7 @@ This family stops a chat reply, edited message, or tool call when its payload br
18
18
  - `blocking/verify_before_acting.py` blocks a completed mutating call when the agent's reasoning contains an unchecked claim.
19
19
  - `blocking/pr_lifecycle_skill_gate.py` denies a commit, push, pull request action, or merge until the `pr-lifecycle` skill appears in the transcript since the last compaction.
20
20
  - `blocking/resolve_thread_reply_gate.py` denies a review thread resolve until the agent's own transcript shows a reply on that same thread that posted after the last user prompt and that no successful resolve of the thread has spent. A resolve is a `resolve_review_thread` call, which names the thread by `threadID`; a `pull_request_review_write` call with method `resolve_thread`, which names it by `threadId`; a shell command with a `gh api graphql` `resolveReviewThread` mutation, which names it by a literal `PRRT_` id; or a shell call to `pulls/<n>/ccr/comments/<id>/resolve`, which names it by a comment id. A graphql resolve that names no `PRRT_` id is denied. A reply is an `add_reply_to_pull_request_comment` call, or a `gh api` call to a comment's `replies` endpoint or to `addPullRequestReviewThreadReply`, which names its thread by `PRRT_` id. A reply and a resolve by comment id match when they name the same comment, or when a successful tool result in the transcript, such as `pull_request_read` `get_review_comments`, lists the comment under the thread by its `discussion_r` anchor or `databaseId`. A reply whose result is an error, such as a refusal from `blocking/reply_length_gate.py`, does not count. With no readable transcript, the resolve passes.
21
- - `blocking/verify_before_commit_gate.py` denies a `git commit` in a repository with a `.claude/skills/verify` or `.agents/skills/verify` directory until the `verify` skill loads after the last user prompt, through a Skill call or the `/verify` command in that prompt. It reads the committed paths from the staged diff, the tracked changes for `-a`, and the paths of each `git add` earlier in the same command, and passes a commit whose paths are all docs, images, or test files.
21
+ - `blocking/verify_before_commit_gate.py` denies a `git commit` in a repository with a `.claude/skills/verify` or `.agents/skills/verify` directory until the `verify` skill loads after the last user prompt, through a Skill call whose result comes back without an error, or the `/verify` command in that prompt. It reads the committed paths from the staged diff, the tracked changes for `-a`, and the paths of each `git add` earlier in the same command, and passes a commit whose paths are all docs, images, test files, or `.json`, `.jsonl`, `.yaml`, `.yml`, or `.csv` files under a `docs` folder.
22
22
  - `blocking/build_eval_before_eval_write_gate.py` denies a write to an eval file until a Skill call named exactly `claude-api` with args `build-eval`, or the `/claude-api build-eval` command, appears in the transcript.
23
23
  - `blocking/merge_review_gate.py` denies an agent's merge until a review pass on the merged head reported zero findings, or ruled out every finding and linked the posted rulings. It reads the receipt `scripts/merge_review_receipt.py` writes, requires the merge, auto-merge or merge-queue entry to be pinned to that head, and skips repositories listed in `CLAUDE_MERGE_REVIEW_EXEMPT_REPOSITORIES`. Its deny reason names the review command `CLAUDE_MERGE_REVIEW_COMMAND` sets. The reason tells the agent to run that command for the first three passes and `/code-review low --fix <number>` for each later pass; the gate itself counts no passes. It also denies a pull request open, through `gh pr create`, `pull_request.py create` or a `create_pull_request` tool, until a pass recorded as `merge_review_receipt.py <owner/name> open <head> 0` covers the head the pull request opens with. A merge pinned to that same head passes on the open receipt.
24
24
  - `blocking/merge_over_review_offer_gate.py` denies a decision card or question that offers a merge while it names open review findings, a red check, unaddressed review comments, or an override. It reads the whole card as one text: every question, header, context, reason, and option, whether the option is a string or a label with a consequence or description.
@@ -68,7 +68,7 @@ Preconditions:
68
68
  - **Step note.** Input is a tool call after a transcript message without a status line while the flag is on. Run `python -m pytest packages/claude-dev-env/hooks/blocking/test_step_note_gate.py -q`. The adjacent test observes a block until a status line appears.
69
69
  - **Checked claim.** Input is a Write after hedged reasoning in the transcript. Run `python -m pytest packages/claude-dev-env/hooks/blocking/test_verify_before_acting.py -q`. The adjacent test observes a block and a logged blocked outcome.
70
70
  - **Lifecycle skill.** Input is a `git commit` or `gh pr create` command with no `pr-lifecycle` invocation in the transcript. Run `python -m pytest packages/claude-dev-env/hooks/blocking/test_pr_lifecycle_skill_gate.py -q`. The adjacent test observes a denial, then a silent allow once the skill or its slash command appears.
71
- - **Verify before commit.** Input is `git add app.py; git commit -m change` in a temporary repository with `.agents/skills/verify`, and a transcript with no `verify` load after its last prompt. Run `python -m pytest packages/claude-dev-env/hooks/blocking/test_verify_before_commit_gate.py -q`. The adjacent test observes a denial, then a silent allow after a `verify` Skill call or a `/verify` prompt. A load before the last prompt still denies. A docs-only commit, a tests-only commit, and a repository with no verify skill pass.
71
+ - **Verify before commit.** Input is `git add app.py; git commit -m change` in a temporary repository with `.agents/skills/verify`, and a transcript with no `verify` load after its last prompt. Run `python -m pytest packages/claude-dev-env/hooks/blocking/test_verify_before_commit_gate.py -q`. The adjacent test observes a denial, then a silent allow after a `verify` Skill call or a `/verify` prompt. A load before the last prompt still denies. A docs-only commit, a commit of data files under a `docs` folder, a tests-only commit, and a repository with no verify skill pass. A `.py` file under `docs` and a `.json` file outside `docs` still deny.
72
72
  - **Eval write.** Input is a Write to `evals/cases.json` with no build-eval call in the transcript. Run `python -m pytest packages/claude-dev-env/hooks/blocking/test_build_eval_before_eval_write_gate.py -q`. The adjacent test observes a denial, then an allow once the call appears; a write outside an eval path passes.
73
73
  - **Clean review.** Input is a merge with no receipt, a receipt with findings, a merge pinned to a newer head, an unpinned merge, or auto-merge with no head. Run `python -m pytest packages/claude-dev-env/hooks/blocking/test_merge_review_gate.py -q`. The adjacent test observes a denial for each; a merge or auto-merge pinned to the clean head and a merge in an exempt repository pass. An open with no clean open receipt at its head is denied; an open reviewed clean at its head, and a merge pinned to that head, pass.
74
74
  - **Merge offer.** Input is a decision card or AskUserQuestion that offers "Merge now", the merge queue, or a yes to "Merge it now?" while any part of the card names open findings or unaddressed review comments. Run `python -m pytest packages/claude-dev-env/hooks/blocking/test_merge_over_review_offer_gate.py -q`. The adjacent test observes a denial for each, including an offer and findings in separate questions; a card with no merge offer, a card about the merge review check itself, a card about shipping a docs change, and a merge offer after a clean review pass.
@@ -3,7 +3,7 @@
3
3
  DENY_REASON = (
4
4
  "This repository has a verify skill, and this commit changes code. Invoke the verify "
5
5
  "skill with the Skill tool, run the check it routes you to, then run the same command again. "
6
- "A commit that changes only docs or tests passes without it."
6
+ "A commit that changes only docs, data files under a docs folder, or tests passes without it."
7
7
  )
8
8
  SKILL_NAME = "verify"
9
9
  ALL_SLASH_COMMAND_MARKERS = ("<command-name>/verify</command-name>",)
@@ -47,6 +47,8 @@ ALL_DOCS_EXTENSIONS = frozenset(
47
47
  ".ico",
48
48
  }
49
49
  )
50
+ ALL_DOCS_DIRECTORY_NAMES = frozenset({"docs"})
51
+ ALL_DOCS_DATA_EXTENSIONS = frozenset({".json", ".jsonl", ".yaml", ".yml", ".csv"})
50
52
  ALL_TEST_DIRECTORY_NAMES = frozenset({"tests", "test", "__tests__"})
51
53
  ALL_TEST_FILE_PREFIXES = ("test_",)
52
54
  ALL_TEST_FILE_SUFFIXES = ("_test.py",)
@@ -18,9 +18,14 @@ from transcript_skill_scan import (
18
18
  )
19
19
 
20
20
 
21
- def _skill_entry(name: str) -> str:
21
+ def _skill_entry(name: str, tool_use_id: str = "toolu_skill") -> str:
22
22
  return json.dumps(
23
- {"type": "assistant", "message": {"content": [{"type": "tool_use", "name": "Skill", "input": {"skill": name}}]}}
23
+ {
24
+ "type": "assistant",
25
+ "message": {
26
+ "content": [{"type": "tool_use", "id": tool_use_id, "name": "Skill", "input": {"skill": name}}]
27
+ },
28
+ }
24
29
  )
25
30
 
26
31
 
@@ -144,12 +149,40 @@ def _prompt_entry(content: object) -> str:
144
149
 
145
150
 
146
151
  def test_skill_since_last_prompt_survives_tool_results_and_skill_bodies() -> None:
147
- tool_result = _prompt_entry([{"type": "tool_result", "content": "Launching skill: verify"}])
152
+ tool_result = _prompt_entry(
153
+ [{"type": "tool_result", "tool_use_id": "toolu_skill", "content": "Launching skill: verify"}]
154
+ )
148
155
  skill_body = json.dumps({"type": "user", "isMeta": True, "message": {"content": "Base directory for this skill"}})
149
156
  lines = [_prompt_entry("Commit it."), _skill_entry("verify"), tool_result, skill_body]
150
157
  assert is_skill_loaded_since_last_prompt(lines, ("verify",), ())
151
158
 
152
159
 
160
+ def test_refused_skill_load_leaves_the_skill_unloaded() -> None:
161
+ refused_result = _prompt_entry(
162
+ [
163
+ {
164
+ "type": "tool_result",
165
+ "tool_use_id": "toolu_skill",
166
+ "content": "<tool_use_error>Skill verify cannot be used with Skill tool</tool_use_error>",
167
+ "is_error": True,
168
+ }
169
+ ]
170
+ )
171
+ lines = [_prompt_entry("Commit it."), _skill_entry("verify"), refused_result]
172
+ assert not is_skill_loaded_since_last_prompt(lines, ("verify",), ())
173
+
174
+
175
+ def test_skill_call_with_no_result_yet_leaves_the_skill_unloaded() -> None:
176
+ lines = [_prompt_entry("Commit it."), _skill_entry("verify")]
177
+ assert not is_skill_loaded_since_last_prompt(lines, ("verify",), ())
178
+
179
+
180
+ def test_result_for_another_call_leaves_the_skill_unloaded() -> None:
181
+ other_result = _prompt_entry([{"type": "tool_result", "tool_use_id": "toolu_other", "content": "done"}])
182
+ lines = [_prompt_entry("Commit it."), _skill_entry("verify"), other_result]
183
+ assert not is_skill_loaded_since_last_prompt(lines, ("verify",), ())
184
+
185
+
153
186
  def test_next_prompt_drops_a_skill_loaded_in_the_last_turn() -> None:
154
187
  lines = [_prompt_entry("First."), _skill_entry("verify"), _prompt_entry([{"type": "text", "text": "Second."}])]
155
188
  assert not is_skill_loaded_since_last_prompt(lines, ("verify",), ())
@@ -44,6 +44,17 @@ def _named_skill_inputs(
44
44
  all_entry_fields: dict[str, object],
45
45
  skill_names: Collection[str],
46
46
  accepts_plugin_prefix: bool = True,
47
+ ) -> Iterator[dict[str, object]]:
48
+ for each_block in _named_skill_blocks(all_entry_fields, skill_names, accepts_plugin_prefix):
49
+ skill_input = each_block["input"]
50
+ if isinstance(skill_input, dict):
51
+ yield skill_input
52
+
53
+
54
+ def _named_skill_blocks(
55
+ all_entry_fields: dict[str, object],
56
+ skill_names: Collection[str],
57
+ accepts_plugin_prefix: bool = True,
47
58
  ) -> Iterator[dict[str, object]]:
48
59
  message = all_entry_fields.get("message")
49
60
  if all_entry_fields.get("type") != ASSISTANT_ENTRY_TYPE or not isinstance(message, dict):
@@ -61,7 +72,7 @@ def _named_skill_inputs(
61
72
  invoked_name == name or (accepts_plugin_prefix and invoked_name.endswith(":" + name))
62
73
  for name in skill_names
63
74
  ):
64
- yield each_block["input"]
75
+ yield each_block
65
76
 
66
77
 
67
78
  def _invokes_skill(
@@ -183,11 +194,15 @@ def is_skill_loaded_since_last_prompt(
183
194
  ::
184
195
 
185
196
  prompt, Skill verify, tool result, skill body -> True
197
+ prompt, Skill verify, tool result with is_error -> False
198
+ prompt, Skill verify, no tool result yet -> False
186
199
  prompt, Skill verify, prompt -> False
187
200
  prompt carrying the /verify command marker -> True
188
201
  prompt with the marker, compact boundary -> False
189
202
 
190
- A tool result and a meta entry, such as the skill body, leave the turn open.
203
+ A Skill call counts once its tool result comes back without an error, so a
204
+ refused load leaves the skill unloaded. A tool result and a meta entry, such
205
+ as the skill body, leave the turn open.
191
206
 
192
207
  Args:
193
208
  all_transcript_lines: JSON transcript entries, one per line.
@@ -195,13 +210,23 @@ def is_skill_loaded_since_last_prompt(
195
210
  slash_command_markers: Accepted user command tags.
196
211
  """
197
212
  loaded = False
213
+ all_pending_ids: set[object] = set()
198
214
  for each_line in all_transcript_lines:
199
215
  all_entry_fields = _parsed_entry(each_line)
200
216
  if all_entry_fields is None:
201
217
  continue
202
218
  if all_entry_fields.get("subtype") == COMPACT_BOUNDARY_SUBTYPE or _is_user_prompt(all_entry_fields):
203
219
  loaded = False
204
- loaded = loaded or _invokes_skill(all_entry_fields, skill_names, slash_command_markers)
220
+ all_pending_ids = set()
221
+ command_text = _user_command_text(all_entry_fields)
222
+ if command_text is not None:
223
+ loaded = loaded or any(marker in command_text for marker in slash_command_markers)
224
+ all_pending_ids.update(
225
+ each_block["id"]
226
+ for each_block in _named_skill_blocks(all_entry_fields, skill_names)
227
+ if each_block.get("id") is not None
228
+ )
229
+ loaded = loaded or bool(all_pending_ids & _succeeded_result_ids(all_entry_fields))
205
230
  return loaded
206
231
 
207
232
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-dev-env",
3
- "version": "8.100.0",
3
+ "version": "8.100.1",
4
4
  "description": "Claude Code development standards — rules, hooks, agents, commands, and skills",
5
5
  "type": "module",
6
6
  "bin": {