claude-dev-env 8.111.2 → 8.111.4
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/hooks/blocking/pr_lifecycle_skill_gate.py +45 -4
- package/hooks/blocking/test_code_rules_enforcer_duplicate_body.py +7 -7
- package/hooks/blocking/test_codex_apply_patch.py +1 -1
- package/hooks/blocking/test_pr_lifecycle_skill_gate.py +104 -0
- package/hooks/blocking/test_pull_request_proof.py +4 -4
- package/hooks/blocking/test_turn_review_gate.py +9 -4
- package/hooks/features/conduct-gates.md +1 -1
- package/hooks/hooks_constants/pr_lifecycle_skill_gate_constants.py +32 -2
- package/hooks/lifecycle/test_nested_project_hooks.py +1 -1
- package/hooks/routing/test_spawn_readiness_hook.py +6 -2
- package/hooks/session/test_npx_pele_guidance.py +2 -2
- package/package.json +1 -1
|
@@ -18,6 +18,8 @@ from hooks_constants.pr_lifecycle_skill_gate_constants import (
|
|
|
18
18
|
ALL_BUILD_EVAL_SKILL_NAMES,
|
|
19
19
|
ALL_API_ACTION_NAMES,
|
|
20
20
|
ALL_COMMAND_PREFIX_WORDS,
|
|
21
|
+
ALL_GH_PULL_REQUEST_READ_SUBCOMMANDS,
|
|
22
|
+
ALL_GH_PULL_REQUEST_SUBCOMMANDS,
|
|
21
23
|
ALL_GITHUB_MCP_TOOL_SUFFIXES,
|
|
22
24
|
ALL_PIECE_REPLACEMENT_TEXTS,
|
|
23
25
|
ALL_PREFIX_OPTIONS_WITH_VALUE,
|
|
@@ -28,6 +30,9 @@ from hooks_constants.pr_lifecycle_skill_gate_constants import (
|
|
|
28
30
|
BUILD_EVAL_ARGUMENT_WORD,
|
|
29
31
|
BUILD_EVAL_COMMAND_MARKER,
|
|
30
32
|
COMMAND_PIECE_PATTERN,
|
|
33
|
+
BACKTICK_SUBSTITUTION_GROUP,
|
|
34
|
+
COMMAND_SUBSTITUTION_PATTERN,
|
|
35
|
+
DOLLAR_SUBSTITUTION_GROUP,
|
|
31
36
|
COMMAND_WHITESPACE,
|
|
32
37
|
DENY_DECISION,
|
|
33
38
|
DENY_REASON,
|
|
@@ -48,6 +53,10 @@ from hooks_constants.pr_lifecycle_skill_gate_constants import (
|
|
|
48
53
|
PATH_SEPARATOR_PATTERN,
|
|
49
54
|
PERMISSION_DECISION_REASON_KEY,
|
|
50
55
|
PULL_REQUEST_SCRIPT_NAME,
|
|
56
|
+
ALL_NESTED_PROGRAM_NAMES,
|
|
57
|
+
ALL_NESTED_PROGRAM_WRAPPER_NAMES,
|
|
58
|
+
EVAL_ARGUMENT_SEPARATOR,
|
|
59
|
+
EVAL_PROGRAM_NAME,
|
|
51
60
|
PYTHON_OPTIONS_WITH_VALUE,
|
|
52
61
|
REMOVED_TEXT,
|
|
53
62
|
SEGMENT_BREAK,
|
|
@@ -185,10 +194,20 @@ def _is_git_action(all_words: list[str]) -> bool:
|
|
|
185
194
|
return action in GIT_ACTIONS
|
|
186
195
|
|
|
187
196
|
|
|
197
|
+
def _is_pull_request_action(all_gh_words: list[str]) -> bool:
|
|
198
|
+
all_subcommand_words = all_gh_words[1:]
|
|
199
|
+
if not all_subcommand_words:
|
|
200
|
+
return False
|
|
201
|
+
subcommand, *all_later_words = all_subcommand_words
|
|
202
|
+
if subcommand not in ALL_GH_PULL_REQUEST_READ_SUBCOMMANDS:
|
|
203
|
+
return True
|
|
204
|
+
return any(each_word in ALL_GH_PULL_REQUEST_SUBCOMMANDS for each_word in all_later_words)
|
|
205
|
+
|
|
206
|
+
|
|
188
207
|
def _is_gh_action(all_words: list[str]) -> bool:
|
|
189
208
|
all_gh_words = gh_command_words(all_words[1:])
|
|
190
209
|
if all_gh_words[:1] == [GH_PULL_REQUEST_COMMAND]:
|
|
191
|
-
return
|
|
210
|
+
return _is_pull_request_action(all_gh_words)
|
|
192
211
|
if all_gh_words[:1] != [GH_API_COMMAND]:
|
|
193
212
|
return False
|
|
194
213
|
all_api_arguments = all_words[all_words.index(GH_API_COMMAND, 1) + 1 :]
|
|
@@ -207,7 +226,7 @@ def _words_from_executable(all_words: list[str]) -> list[str]:
|
|
|
207
226
|
if re.match(ENVIRONMENT_ASSIGNMENT_PATTERN, each_word):
|
|
208
227
|
index += 1
|
|
209
228
|
continue
|
|
210
|
-
if each_word not in ALL_COMMAND_PREFIX_WORDS:
|
|
229
|
+
if file_name(each_word) not in ALL_COMMAND_PREFIX_WORDS:
|
|
211
230
|
return all_words[index:]
|
|
212
231
|
index += 1
|
|
213
232
|
while index < len(all_words) and all_words[index].startswith("-"):
|
|
@@ -247,12 +266,34 @@ def executable_word_lists(command: str) -> list[list[str]]:
|
|
|
247
266
|
all_command_words = _words_from_executable(each_segment)
|
|
248
267
|
if not all_command_words:
|
|
249
268
|
continue
|
|
250
|
-
all_word_lists.
|
|
251
|
-
|
|
269
|
+
all_word_lists.extend(_command_and_nested_word_lists(all_command_words))
|
|
270
|
+
for each_match in COMMAND_SUBSTITUTION_PATTERN.finditer(command):
|
|
271
|
+
inner_command = (
|
|
272
|
+
each_match.group(DOLLAR_SUBSTITUTION_GROUP)
|
|
273
|
+
if each_match.group(DOLLAR_SUBSTITUTION_GROUP) is not None
|
|
274
|
+
else each_match.group(BACKTICK_SUBSTITUTION_GROUP)
|
|
275
|
+
)
|
|
276
|
+
all_word_lists.extend(executable_word_lists(inner_command))
|
|
277
|
+
return all_word_lists
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def _command_and_nested_word_lists(all_command_words: list[str]) -> list[list[str]]:
|
|
281
|
+
return [all_command_words, *_wrapped_word_lists(all_command_words), *_nested_program_word_lists(all_command_words)]
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def _nested_program_word_lists(all_command_words: list[str]) -> list[list[str]]:
|
|
285
|
+
if file_name(all_command_words[0]) not in ALL_NESTED_PROGRAM_WRAPPER_NAMES:
|
|
286
|
+
return []
|
|
287
|
+
all_word_lists: list[list[str]] = []
|
|
288
|
+
for each_index in range(1, len(all_command_words)):
|
|
289
|
+
if file_name(all_command_words[each_index]) in ALL_NESTED_PROGRAM_NAMES:
|
|
290
|
+
all_word_lists.extend(_command_and_nested_word_lists(all_command_words[each_index:]))
|
|
252
291
|
return all_word_lists
|
|
253
292
|
|
|
254
293
|
|
|
255
294
|
def _wrapped_word_lists(all_command_words: list[str]) -> list[list[str]]:
|
|
295
|
+
if file_name(all_command_words[0]) == EVAL_PROGRAM_NAME:
|
|
296
|
+
return executable_word_lists(EVAL_ARGUMENT_SEPARATOR.join(all_command_words[1:]))
|
|
256
297
|
if file_name(all_command_words[0]) not in ALL_SHELL_WRAPPER_EXECUTABLES:
|
|
257
298
|
return []
|
|
258
299
|
return [
|
|
@@ -15,6 +15,7 @@ containing a test marker as exempt — the same way it would skip a real test fi
|
|
|
15
15
|
|
|
16
16
|
from __future__ import annotations
|
|
17
17
|
|
|
18
|
+
import contextlib
|
|
18
19
|
import importlib.util
|
|
19
20
|
import pathlib
|
|
20
21
|
import shutil
|
|
@@ -261,15 +262,14 @@ def test_should_scan_explicit_sibling_directory_for_relative_path(
|
|
|
261
262
|
|
|
262
263
|
def test_should_ignore_cwd_when_explicit_sibling_directory_given(
|
|
263
264
|
module_dir: pathlib.Path,
|
|
264
|
-
monkeypatch: pytest.MonkeyPatch,
|
|
265
265
|
) -> None:
|
|
266
266
|
_write(module_dir, "existing_blocker.py", SHARED_HELPER_SOURCE)
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
267
|
+
with contextlib.chdir(module_dir.parent):
|
|
268
|
+
issues = check_duplicate_function_body_across_files(
|
|
269
|
+
SHARED_HELPER_SOURCE,
|
|
270
|
+
"package/new_blocker.py",
|
|
271
|
+
sibling_directory=module_dir,
|
|
272
|
+
)
|
|
273
273
|
assert any("strip_code_and_quotes" in each_issue for each_issue in issues), (
|
|
274
274
|
"An explicit sibling directory must anchor the scan independent of the "
|
|
275
275
|
f"process working directory, got: {issues}"
|
|
@@ -25,7 +25,7 @@ def test_codex_patch_operation_targets_names_every_section_without_reading_conte
|
|
|
25
25
|
all_targets = codex_patch_operation_targets(three_operation_patch, str(tmp_path))
|
|
26
26
|
|
|
27
27
|
all_target_names = {
|
|
28
|
-
(each_operation,
|
|
28
|
+
(each_operation, Path(each_path).name)
|
|
29
29
|
for each_operation, each_path in all_targets
|
|
30
30
|
}
|
|
31
31
|
assert all_target_names == {
|
|
@@ -510,3 +510,107 @@ def test_deny_decision_should_carry_the_reason_as_a_deny() -> None:
|
|
|
510
510
|
output = gate.deny_decision("Load the skill first.")["hookSpecificOutput"]
|
|
511
511
|
assert output["permissionDecision"] == "deny"
|
|
512
512
|
assert output["permissionDecisionReason"] == "Load the skill first."
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
READ_ONLY_PULL_REQUEST_COMMANDS = (
|
|
516
|
+
"gh pr list",
|
|
517
|
+
"gh pr list --state all",
|
|
518
|
+
"gh pr view 12",
|
|
519
|
+
"gh pr view 12 --web",
|
|
520
|
+
"gh pr checks 12",
|
|
521
|
+
"gh pr diff 12",
|
|
522
|
+
"gh pr status",
|
|
523
|
+
"gh -R jl-cmd-projects/claude-dev-env pr view 12",
|
|
524
|
+
)
|
|
525
|
+
WRITE_PULL_REQUEST_COMMANDS = (
|
|
526
|
+
"gh pr create --title t --body b",
|
|
527
|
+
"gh pr merge 12 --squash",
|
|
528
|
+
"gh pr edit 12 --body b",
|
|
529
|
+
"gh pr comment 12 --body b",
|
|
530
|
+
"gh pr review 12 --approve",
|
|
531
|
+
"gh pr close 12",
|
|
532
|
+
"gh pr ready 12",
|
|
533
|
+
"gh pr frobnicate 12",
|
|
534
|
+
)
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
def test_read_only_pull_request_commands_should_pass_without_the_skill(tmp_path: Path) -> None:
|
|
538
|
+
path = _transcript(tmp_path)
|
|
539
|
+
for each_command in READ_ONLY_PULL_REQUEST_COMMANDS:
|
|
540
|
+
assert gate.decision_for(_payload(each_command, path)) is None, each_command
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
def test_read_only_pull_request_command_should_run_silently_without_the_skill(tmp_path: Path) -> None:
|
|
544
|
+
assert _run_main(_payload("gh pr list", _transcript(tmp_path))) == (0, "")
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
def test_write_pull_request_commands_should_be_denied_without_the_skill(tmp_path: Path) -> None:
|
|
548
|
+
path = _transcript(tmp_path)
|
|
549
|
+
for each_command in WRITE_PULL_REQUEST_COMMANDS:
|
|
550
|
+
_assert_denied(_payload(each_command, path))
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
OPTION_SHIFTED_WRITE_COMMANDS = (
|
|
554
|
+
"gh pr --subject view merge 12 --squash",
|
|
555
|
+
"gh pr --subject view 12 merge",
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
def test_write_behind_an_unlisted_option_should_be_denied_without_the_skill(tmp_path: Path) -> None:
|
|
560
|
+
path = _transcript(tmp_path)
|
|
561
|
+
for each_command in OPTION_SHIFTED_WRITE_COMMANDS:
|
|
562
|
+
_assert_denied(_payload(each_command, path))
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
XARGS_WRITE_COMMANDS = (
|
|
566
|
+
"gh pr view 12 | xargs gh pr merge",
|
|
567
|
+
"echo 12 | xargs -I {} gh pr merge {}",
|
|
568
|
+
"echo 12 | xargs -n 1 -P 4 gh pr merge",
|
|
569
|
+
"echo 12 | xargs -- gh pr merge",
|
|
570
|
+
"echo https://example.test | xargs git push origin HEAD",
|
|
571
|
+
)
|
|
572
|
+
XARGS_READ_COMMANDS = (
|
|
573
|
+
"echo 12 | xargs gh pr view",
|
|
574
|
+
"echo 12 | xargs -I {} gh pr checks {}",
|
|
575
|
+
)
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
def test_write_run_through_xargs_should_be_denied_without_the_skill(tmp_path: Path) -> None:
|
|
579
|
+
path = _transcript(tmp_path)
|
|
580
|
+
for each_command in XARGS_WRITE_COMMANDS:
|
|
581
|
+
_assert_denied(_payload(each_command, path))
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
def test_read_only_run_through_xargs_should_pass_without_the_skill(tmp_path: Path) -> None:
|
|
585
|
+
path = _transcript(tmp_path)
|
|
586
|
+
for each_command in XARGS_READ_COMMANDS:
|
|
587
|
+
assert gate.decision_for(_payload(each_command, path)) is None, each_command
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
WRAPPED_WRITE_COMMANDS = (
|
|
591
|
+
"timeout 10 gh pr merge 12",
|
|
592
|
+
"nice -n 5 gh pr merge 12",
|
|
593
|
+
"find . -maxdepth 1 -exec gh pr merge 12 {} ;",
|
|
594
|
+
"parallel gh pr merge 12 ::: 12",
|
|
595
|
+
'eval "gh pr merge 12"',
|
|
596
|
+
"eval gh pr merge 12",
|
|
597
|
+
'eval "gh pr" "merge 12"',
|
|
598
|
+
)
|
|
599
|
+
SUBSTITUTED_AND_GRAPHQL_WRITE_COMMANDS = (
|
|
600
|
+
'echo "$(gh pr merge 12 --squash)"',
|
|
601
|
+
"echo `gh pr merge 12`",
|
|
602
|
+
"/usr/bin/env gh pr merge 12",
|
|
603
|
+
"gh api graphql -f query='mutation { mergePullRequest(input: {pullRequestId: \"PR_x\"}) { clientMutationId } }'",
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def test_substituted_or_graphql_pull_request_write_should_be_denied_without_the_skill(tmp_path: Path) -> None:
|
|
608
|
+
path = _transcript(tmp_path)
|
|
609
|
+
for each_command in SUBSTITUTED_AND_GRAPHQL_WRITE_COMMANDS:
|
|
610
|
+
_assert_denied(_payload(each_command, path))
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
def test_write_run_through_a_wrapper_should_be_denied_without_the_skill(tmp_path: Path) -> None:
|
|
614
|
+
path = _transcript(tmp_path)
|
|
615
|
+
for each_command in WRAPPED_WRITE_COMMANDS:
|
|
616
|
+
_assert_denied(_payload(each_command, path))
|
|
@@ -527,7 +527,7 @@ def _shell_create_elsewhere(
|
|
|
527
527
|
) -> dict[str, object]:
|
|
528
528
|
body_path = tmp_path / "body.md"
|
|
529
529
|
body_path.write_text(body, encoding="utf-8")
|
|
530
|
-
return _shell(f
|
|
530
|
+
return _shell(f'gh pr create --title t --body-file "{body_path}" {extra_flags}', tmp_path)
|
|
531
531
|
|
|
532
532
|
|
|
533
533
|
def test_should_allow_a_python_only_change_the_compare_api_lists_when_git_cannot_read_it(
|
|
@@ -689,9 +689,9 @@ def test_should_report_unreadable_git_output_as_unknown() -> None:
|
|
|
689
689
|
assert gate._git_changes([":100644 100644 aaa bbb M", "a.html", "stray", ""]) is None
|
|
690
690
|
|
|
691
691
|
|
|
692
|
-
def
|
|
693
|
-
clone_path = _repository_with_change(tmp_path, '
|
|
694
|
-
assert gate.visible_changed_files(str(clone_path), "feature") == ['
|
|
692
|
+
def test_should_keep_a_page_whose_name_holds_an_apostrophe(tmp_path: Path) -> None:
|
|
693
|
+
clone_path = _repository_with_change(tmp_path, "q't.html")
|
|
694
|
+
assert gate.visible_changed_files(str(clone_path), "feature") == ["q't.html"]
|
|
695
695
|
|
|
696
696
|
|
|
697
697
|
def test_should_keep_a_page_whose_name_has_non_ascii_letters(tmp_path: Path) -> None:
|
|
@@ -57,9 +57,14 @@ def project(tmp_path: Path) -> Path:
|
|
|
57
57
|
def gate_environment(tmp_path: Path, project: Path) -> dict[str, str]:
|
|
58
58
|
stub_directory = tmp_path / "bin"
|
|
59
59
|
stub_directory.mkdir()
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
if os.name == "nt":
|
|
61
|
+
stub_script = stub_directory / "claude_stub.py"
|
|
62
|
+
stub_script.write_text(STUB_CLAUDE_SOURCE)
|
|
63
|
+
(stub_directory / "claude.cmd").write_text(f'@"{sys.executable}" "{stub_script}" %*\r\n')
|
|
64
|
+
else:
|
|
65
|
+
stub_claude = stub_directory / "claude"
|
|
66
|
+
stub_claude.write_text(STUB_CLAUDE_SOURCE)
|
|
67
|
+
stub_claude.chmod(0o755)
|
|
63
68
|
state_directory = tmp_path / "state"
|
|
64
69
|
state_directory.mkdir()
|
|
65
70
|
environment = {
|
|
@@ -373,7 +378,7 @@ def test_should_share_one_review_time_budget_across_the_checkouts(
|
|
|
373
378
|
monkeypatch.setenv(each_name, gate_environment[each_name])
|
|
374
379
|
monkeypatch.setenv("STUB_REVIEW_SECONDS", "5")
|
|
375
380
|
monkeypatch.setattr(tempfile, "tempdir", gate_environment["TMPDIR"])
|
|
376
|
-
monkeypatch.setattr(turn_review_gate, "REVIEW_TIMEOUT_SECONDS",
|
|
381
|
+
monkeypatch.setattr(turn_review_gate, "REVIEW_TIMEOUT_SECONDS", 4)
|
|
377
382
|
all_roots = turn_review_gate._opted_in_repository_roots(
|
|
378
383
|
turn_review_gate._opted_in_repository_slugs()
|
|
379
384
|
)
|
|
@@ -17,7 +17,7 @@ This family stops a chat reply, edited message, or tool call when its payload br
|
|
|
17
17
|
- `blocking/step_note_gate.py` requires a status line before a tool call while its opt-in flag is on.
|
|
18
18
|
- `blocking/wakeup_cap_gate.py` keeps a self-wakeup inside the 1-hour prompt cache. A wake over the step-down (57 minutes for `send_later` and Routines, 3480 seconds for `ScheduleWakeup`) and at most 60 minutes away runs with its delay rewritten to the step-down. A wake over 60 minutes away, or a cron with more than 57 minutes between wakes, is denied with a reason that says to stack wakes under the cap. A Routine that starts a fresh session on each firing passes.
|
|
19
19
|
- `blocking/verify_before_acting.py` blocks a completed mutating call when the agent's reasoning contains an unchecked claim.
|
|
20
|
-
- `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
|
+
- `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. Read-only `gh pr` subcommands (`view`, `list`, `checks`, `diff`, `status`) pass without it, unless a later argument names another `gh pr` subcommand.
|
|
21
21
|
- `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.
|
|
22
22
|
- `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.
|
|
23
23
|
- `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.
|
|
@@ -59,13 +59,43 @@ GIT_ACTIONS = frozenset({"commit", "push"})
|
|
|
59
59
|
GH_PULL_REQUEST_COMMAND = "pr"
|
|
60
60
|
GH_API_COMMAND = "api"
|
|
61
61
|
MERGE_PATH_SUFFIX = "/merge"
|
|
62
|
-
ALL_API_ACTION_NAMES = ("auto-merge", "enablePullRequestAutoMerge")
|
|
62
|
+
ALL_API_ACTION_NAMES = ("auto-merge", "enablePullRequestAutoMerge", "mergePullRequest", "createPullRequest")
|
|
63
|
+
COMMAND_SUBSTITUTION_PATTERN = re.compile(r"\$\(([^()]*)\)|`([^`]*)`")
|
|
64
|
+
DOLLAR_SUBSTITUTION_GROUP = 1
|
|
65
|
+
BACKTICK_SUBSTITUTION_GROUP = 2
|
|
63
66
|
ALL_COMMAND_PREFIX_WORDS = frozenset({"env", "sudo", "command", "exec", "nohup", "time"})
|
|
67
|
+
ALL_GH_PULL_REQUEST_READ_SUBCOMMANDS = frozenset({"checks", "diff", "list", "status", "view"})
|
|
68
|
+
ALL_GH_PULL_REQUEST_SUBCOMMANDS = ALL_GH_PULL_REQUEST_READ_SUBCOMMANDS | frozenset(
|
|
69
|
+
{
|
|
70
|
+
"checkout",
|
|
71
|
+
"close",
|
|
72
|
+
"comment",
|
|
73
|
+
"create",
|
|
74
|
+
"edit",
|
|
75
|
+
"lock",
|
|
76
|
+
"merge",
|
|
77
|
+
"ready",
|
|
78
|
+
"reopen",
|
|
79
|
+
"review",
|
|
80
|
+
"revert",
|
|
81
|
+
"unlock",
|
|
82
|
+
"update-branch",
|
|
83
|
+
}
|
|
84
|
+
)
|
|
64
85
|
ALL_PREFIX_OPTIONS_WITH_VALUE = frozenset({"-u", "--unset", "-C", "--chdir", "-g", "--group", "--user"})
|
|
65
86
|
ENVIRONMENT_ASSIGNMENT_PATTERN = r"^[A-Za-z_][A-Za-z0-9_]*="
|
|
66
|
-
ALL_SHELL_WRAPPER_EXECUTABLES = frozenset({"bash", "sh", "zsh", "dash", "pwsh", "pwsh.exe", "powershell", "powershell.exe"})
|
|
87
|
+
ALL_SHELL_WRAPPER_EXECUTABLES = frozenset({"bash", "sh", "zsh", "dash", "eval", "pwsh", "pwsh.exe", "powershell", "powershell.exe"})
|
|
67
88
|
ALL_PYTHON_EXECUTABLES = frozenset({"python", "python3", "python.exe", "python3.exe", "py", "py.exe"})
|
|
68
89
|
PULL_REQUEST_SCRIPT_NAME = "pull_request.py"
|
|
90
|
+
EVAL_PROGRAM_NAME = "eval"
|
|
91
|
+
EVAL_ARGUMENT_SEPARATOR = " "
|
|
92
|
+
ALL_NESTED_PROGRAM_WRAPPER_NAMES = frozenset({"xargs", "timeout", "nice", "ionice", "stdbuf", "parallel", "watch", "find"})
|
|
93
|
+
ALL_NESTED_PROGRAM_NAMES = (
|
|
94
|
+
frozenset({"gh", "gh.exe", "git", "git.exe", PULL_REQUEST_SCRIPT_NAME})
|
|
95
|
+
| ALL_PYTHON_EXECUTABLES
|
|
96
|
+
| ALL_SHELL_WRAPPER_EXECUTABLES
|
|
97
|
+
| ALL_NESTED_PROGRAM_WRAPPER_NAMES
|
|
98
|
+
)
|
|
69
99
|
PATH_SEPARATOR_PATTERN = r"[\\/]"
|
|
70
100
|
PYTHON_OPTIONS_WITH_VALUE = frozenset({"-X", "-W"})
|
|
71
101
|
ALL_BUILD_EVAL_SKILL_NAMES = ("claude-api",)
|
|
@@ -77,7 +77,7 @@ def test_should_run_a_child_session_start_hook_inside_that_child(
|
|
|
77
77
|
"SessionStart": [
|
|
78
78
|
_command_group(
|
|
79
79
|
"",
|
|
80
|
-
f'echo "$CLAUDE_PROJECT_DIR|$(pwd)" > "{record_path}"',
|
|
80
|
+
f'echo "$CLAUDE_PROJECT_DIR|$(pwd -W 2>/dev/null || pwd)" > "{record_path}"',
|
|
81
81
|
)
|
|
82
82
|
]
|
|
83
83
|
},
|
|
@@ -83,6 +83,10 @@ def _write_transcript(tmp_path: Path, all_entries: list[dict[str, object]]) -> P
|
|
|
83
83
|
return transcript_path
|
|
84
84
|
|
|
85
85
|
|
|
86
|
+
def _hook_environment(tmp_path: Path) -> dict[str, str]:
|
|
87
|
+
return {**os.environ, "HOME": str(tmp_path), "USERPROFILE": str(tmp_path)}
|
|
88
|
+
|
|
89
|
+
|
|
86
90
|
def _run_hook(tmp_path: Path, hook_payload: dict[str, object]) -> str:
|
|
87
91
|
completed = subprocess.run(
|
|
88
92
|
[sys.executable, str(HOOK_SCRIPT)],
|
|
@@ -91,7 +95,7 @@ def _run_hook(tmp_path: Path, hook_payload: dict[str, object]) -> str:
|
|
|
91
95
|
),
|
|
92
96
|
capture_output=True,
|
|
93
97
|
text=True,
|
|
94
|
-
env=
|
|
98
|
+
env=_hook_environment(tmp_path),
|
|
95
99
|
check=True,
|
|
96
100
|
)
|
|
97
101
|
return completed.stdout
|
|
@@ -390,7 +394,7 @@ def test_should_print_nothing_for_empty_stdin(tmp_path: Path) -> None:
|
|
|
390
394
|
input="",
|
|
391
395
|
capture_output=True,
|
|
392
396
|
text=True,
|
|
393
|
-
env=
|
|
397
|
+
env=_hook_environment(tmp_path),
|
|
394
398
|
check=True,
|
|
395
399
|
)
|
|
396
400
|
assert completed.stdout == ""
|
|
@@ -211,7 +211,7 @@ def test_installed_snippet_renders_an_svg_file(
|
|
|
211
211
|
monkeypatch.setenv(CLAUDE_CONFIG_DIRECTORY_VARIABLE, str(claude_root))
|
|
212
212
|
work_directory = tmp_path / "work"
|
|
213
213
|
work_directory.mkdir()
|
|
214
|
-
(work_directory / "diagram.mmd").
|
|
214
|
+
(work_directory / "diagram.mmd").write_bytes(CHAIN_TEXT.encode("utf-8"))
|
|
215
215
|
context_text = npx_pele_guidance.guidance_text()
|
|
216
216
|
snippet = context_text.split(JS_FENCE_OPEN, 1)[1].split(JS_FENCE_CLOSE, 1)[0]
|
|
217
217
|
(work_directory / "pele-render.mjs").write_text(snippet, encoding="utf-8")
|
|
@@ -270,7 +270,7 @@ def test_installed_guidance_points_at_the_manifest_main_entry(
|
|
|
270
270
|
entry_path.write_text("export function render(text) {\n return { svg: '' };\n}\n", encoding="utf-8")
|
|
271
271
|
manifest = npx_pele_guidance.installed_pele_manifest(package_directory)
|
|
272
272
|
assert npx_pele_guidance.installed_pele_entry(package_directory, manifest) == entry_path
|
|
273
|
-
assert str(entry_path) in npx_pele_guidance.guidance_text()
|
|
273
|
+
assert json.dumps(str(entry_path)) in npx_pele_guidance.guidance_text()
|
|
274
274
|
assert "pele.run" not in npx_pele_guidance.guidance_text()
|
|
275
275
|
|
|
276
276
|
|