claude-dev-env 4.1.0 → 4.3.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.
Files changed (89) hide show
  1. package/.agents/skills/_shared/pr-loop/scripts/durable_post_lint.py +242 -0
  2. package/.agents/skills/_shared/pr-loop/scripts/skills_pr_loop_constants/durable_post_lint_constants.py +106 -0
  3. package/.agents/skills/_shared/pr-loop/scripts/test_durable_post_lint.py +332 -0
  4. package/.agents/skills/_shared/pr-loop/scripts/test_durable_post_lint_constants.py +25 -0
  5. package/.agents/skills/everything-search/SKILL.md +18 -3
  6. package/.agents/skills/everything-search/scripts/everything_search.py +204 -0
  7. package/.agents/skills/everything-search/scripts/everything_search_command_constants/__init__.py +1 -0
  8. package/.agents/skills/everything-search/scripts/everything_search_command_constants/config/__init__.py +1 -0
  9. package/.agents/skills/everything-search/scripts/everything_search_command_constants/config/constants.py +11 -0
  10. package/.agents/skills/everything-search/scripts/test_everything_search.py +172 -0
  11. package/.agents/skills/issue-tracker/SKILL.md +6 -0
  12. package/.agents/skills/pull-request/SKILL.md +218 -0
  13. package/.agents/skills/pull-request/reference/publication-tasks.md +18 -0
  14. package/.agents/skills/pull-request/scripts/github_pr_command_constants/__init__.py +1 -0
  15. package/.agents/skills/pull-request/scripts/github_pr_command_constants/config/__init__.py +1 -0
  16. package/.agents/skills/pull-request/scripts/github_pr_command_constants/config/constants.py +61 -0
  17. package/.agents/skills/pull-request/scripts/pull_request.py +276 -0
  18. package/.agents/skills/pull-request/scripts/recover_legacy_author.py +251 -0
  19. package/.agents/skills/pull-request/scripts/test_github_pr_command_constants.py +49 -0
  20. package/.agents/skills/pull-request/scripts/test_pull_request.py +398 -0
  21. package/.agents/skills/pull-request/scripts/test_recover_legacy_author.py +221 -0
  22. package/.agents/skills/test-runner/SKILL.md +69 -0
  23. package/.agents/skills/test-runner/scripts/preflight_checks.py +365 -0
  24. package/.agents/skills/test-runner/scripts/run_tests.py +316 -0
  25. package/.agents/skills/test-runner/scripts/test_preflight_checks.py +185 -0
  26. package/.agents/skills/test-runner/scripts/test_run_tests.py +281 -0
  27. package/.agents/skills/test-runner/scripts/test_runner_constants/__init__.py +1 -0
  28. package/.agents/skills/test-runner/scripts/test_runner_constants/config/__init__.py +1 -0
  29. package/.agents/skills/test-runner/scripts/test_runner_constants/config/constants.py +96 -0
  30. package/.agents/skills-archived/pr-loop-cloud-transport/reference/identity-and-hooks.md +1 -1
  31. package/bin/ever-shipped-skills.mjs +2 -0
  32. package/bin/ever-shipped-skills.test.mjs +8 -0
  33. package/bin/install.mjs +9 -1
  34. package/bin/install.prune.test.mjs +149 -0
  35. package/bin/install.test.mjs +24 -7
  36. package/hooks/blocking/pii_prevention_blocker.py +32 -51
  37. package/hooks/blocking/test_bash_post_call_dispatcher.py +5 -28
  38. package/hooks/blocking/test_bash_pre_tool_use_dispatcher.py +1 -4
  39. package/hooks/blocking/test_code_rules_command_dispatch.py +2 -2
  40. package/hooks/blocking/test_pii_prevention_blocker.py +37 -89
  41. package/hooks/gh_post_body_texts.py +195 -0
  42. package/hooks/hooks.json +0 -15
  43. package/hooks/hooks_constants/bash_post_call_dispatcher_constants.py +0 -1
  44. package/hooks/hooks_constants/bash_pre_tool_use_dispatcher_constants.py +5 -16
  45. package/hooks/hooks_constants/gh_post_body_texts_constants.py +12 -0
  46. package/hooks/hooks_constants/test_bash_post_call_dispatcher_constants.py +0 -7
  47. package/hooks/hooks_constants/test_bash_pre_tool_use_dispatcher_constants.py +7 -20
  48. package/hooks/hooks_constants/test_failure_recorder_constants.py +3 -3
  49. package/hooks/hooks_constants/test_gh_post_body_texts_constants.py +19 -0
  50. package/hooks/observability/test_failure_recorder.py +1 -1
  51. package/hooks/pyproject.toml +1 -1
  52. package/hooks/test_gh_post_body_texts.py +79 -0
  53. package/package.json +1 -1
  54. package/rules/durable-post-artifacts.md +31 -20
  55. package/rules/filesystem-search.md +5 -5
  56. package/rules/gh-cli-conventions.md +23 -13
  57. package/rules/git-workflow.md +21 -8
  58. package/scripts/policy_lint/adapter_configuration.py +53 -12
  59. package/scripts/repository_checks/config/constants.py +0 -5
  60. package/scripts/tests/test_adapter_configuration.py +54 -0
  61. package/hooks/_gh_pr_author_swap_utils.py +0 -1225
  62. package/hooks/blocking/conventional_pr_title_gate.py +0 -443
  63. package/hooks/blocking/es_exe_path_rewriter.py +0 -159
  64. package/hooks/blocking/gh_body_arg_blocker.py +0 -176
  65. package/hooks/blocking/gh_pr_author_enforcer.py +0 -487
  66. package/hooks/blocking/gh_pr_author_restore.py +0 -105
  67. package/hooks/blocking/pr_description_writer_gate.py +0 -256
  68. package/hooks/blocking/test_conventional_pr_title_gate.py +0 -640
  69. package/hooks/blocking/test_es_exe_path_rewriter.py +0 -447
  70. package/hooks/blocking/test_gh_body_arg_blocker.py +0 -441
  71. package/hooks/blocking/test_gh_pr_author_enforcer.py +0 -1166
  72. package/hooks/blocking/test_gh_pr_author_restore.py +0 -513
  73. package/hooks/blocking/test_gh_pr_author_swap_utils.py +0 -910
  74. package/hooks/blocking/test_pr_description_writer_gate.py +0 -234
  75. package/hooks/blocking/test_preflight_check.py +0 -343
  76. package/hooks/blocking/test_test_preflight_check.py +0 -80
  77. package/hooks/blocking/test_volatile_path_in_post_blocker.py +0 -322
  78. package/hooks/blocking/volatile_path_in_post_blocker.py +0 -461
  79. package/hooks/hooks_constants/conventional_pr_title_gate_constants.py +0 -58
  80. package/hooks/hooks_constants/gh_pr_author_swap_constants.py +0 -76
  81. package/hooks/hooks_constants/path_rewriter_constants.py +0 -13
  82. package/hooks/hooks_constants/pr_description_writer_gate_constants.py +0 -73
  83. package/hooks/hooks_constants/test_path_rewriter_constants.py +0 -57
  84. package/hooks/hooks_constants/volatile_path_in_post_blocker_constants.py +0 -55
  85. package/hooks/observability/pr_description_writer_spawn_tracker.py +0 -113
  86. package/hooks/observability/test_pr_description_writer_spawn_tracker.py +0 -150
  87. package/hooks/session/gh_pr_author_session_cleanup.py +0 -175
  88. package/hooks/session/test_gh_pr_author_session_cleanup.py +0 -576
  89. package/hooks/test__gh_pr_author_swap_utils.py +0 -333
@@ -1,447 +0,0 @@
1
- """Tests for es_exe_path_rewriter — PreToolUse hook that rewrites es.exe paths."""
2
-
3
- import json
4
- import sys
5
- from io import StringIO
6
- from pathlib import Path
7
- from unittest.mock import patch
8
-
9
- import pytest
10
-
11
- _BLOCKING_DIR = Path(__file__).resolve().parent
12
- _HOOKS_ROOT = _BLOCKING_DIR.parent
13
- for each_sys_path_entry in (str(_BLOCKING_DIR), str(_HOOKS_ROOT)):
14
- if each_sys_path_entry not in sys.path:
15
- sys.path.insert(0, each_sys_path_entry)
16
-
17
- import es_exe_path_rewriter as rewriter
18
-
19
-
20
- def test_rewriter_does_not_redefine_dynamic_stderr_handler_locally() -> None:
21
- """Pin PR #230 round 3 DRY fix: handler is imported from the shared module.
22
-
23
- Both project_paths_reader and es_exe_path_rewriter previously defined
24
- identical `_DynamicStderrHandler` classes. This test fails if the
25
- duplicate class reappears in es_exe_path_rewriter.
26
- """
27
- assert not hasattr(rewriter, "_DynamicStderrHandler")
28
-
29
-
30
- REGISTRY_WITH_ONE_REPO = {"my-repo": "Y:\\Projects\\my-repo"}
31
- REGISTRY_WITH_TWO_REPOS = {
32
- "my-repo": "Y:\\Projects\\my-repo",
33
- "other-repo": "C:\\Dev\\other-repo",
34
- }
35
- ABSOLUTE_PATH_ARGUMENT = "Y:\\Projects\\already-absolute\\file.py"
36
- KNOWN_REPO_NAME = "my-repo"
37
- KNOWN_REPO_PATH = "Y:\\Projects\\my-repo"
38
- OTHER_REPO_NAME = "other-repo"
39
- OTHER_REPO_PATH = "C:\\Dev\\other-repo"
40
-
41
-
42
- def _run_main_with_stdin_text(stdin_text: str) -> tuple[str, str, int]:
43
- """Return (stdout, stderr, exit_code) from running main() with the given stdin text."""
44
- captured_stdout = StringIO()
45
- captured_stderr = StringIO()
46
- exit_code = 0
47
- try:
48
- with (
49
- patch("sys.stdin", StringIO(stdin_text)),
50
- patch("sys.stdout", captured_stdout),
51
- patch("sys.stderr", captured_stderr),
52
- ):
53
- rewriter.main()
54
- except SystemExit as e:
55
- exit_code = e.code or 0
56
- return captured_stdout.getvalue(), captured_stderr.getvalue(), exit_code
57
-
58
-
59
- def _run_main_with_input(hook_input: dict) -> tuple[str, str, int]:
60
- """Return (stdout, stderr, exit_code) from running main() with the given hook input."""
61
- return _run_main_with_stdin_text(json.dumps(hook_input))
62
-
63
-
64
- def _make_bash_input(command: str, description: str = "search files") -> dict:
65
- return {
66
- "tool_name": "Bash",
67
- "tool_input": {"command": command, "description": description},
68
- }
69
-
70
-
71
- class TestTriggerRegex:
72
- def test_matches_bare_es_exe(self) -> None:
73
- assert rewriter.command_invokes_es_exe("es.exe my-repo")
74
-
75
- def test_matches_everything_forward_slash_path(self) -> None:
76
- assert rewriter.command_invokes_es_exe("Everything/es.exe my-repo")
77
-
78
- def test_matches_everything_backslash_path(self) -> None:
79
- assert rewriter.command_invokes_es_exe("Everything\\es.exe my-repo")
80
-
81
- def test_does_not_match_unrelated_command(self) -> None:
82
- assert not rewriter.command_invokes_es_exe("git status")
83
-
84
- def test_does_not_match_es_exe_inside_longer_word(self) -> None:
85
- assert not rewriter.command_invokes_es_exe("not_es.exe_here")
86
-
87
- def test_matches_case_insensitively(self) -> None:
88
- assert rewriter.command_invokes_es_exe("ES.EXE my-repo")
89
-
90
-
91
- class TestRewriteCommand:
92
- def test_bare_token_rewrite_substitutes_registry_path(self) -> None:
93
- rewritten = rewriter.rewrite_command(
94
- "es.exe my-repo config.py", REGISTRY_WITH_ONE_REPO
95
- )
96
- assert rewritten == f'es.exe "{KNOWN_REPO_PATH}" config.py'
97
-
98
- def test_placeholder_token_rewrite_substitutes_registry_path(self) -> None:
99
- rewritten = rewriter.rewrite_command(
100
- 'es.exe "{my-repo}" config.py', REGISTRY_WITH_ONE_REPO
101
- )
102
- assert rewritten == f'es.exe "{KNOWN_REPO_PATH}" config.py'
103
-
104
- def test_single_quoted_placeholder_rewrite_substitutes_registry_path(self) -> None:
105
- rewritten = rewriter.rewrite_command(
106
- "es.exe '{my-repo}' config.py", REGISTRY_WITH_ONE_REPO
107
- )
108
- assert rewritten == f'es.exe "{KNOWN_REPO_PATH}" config.py'
109
-
110
- def test_placeholder_without_quotes_rewrite_substitutes_registry_path(self) -> None:
111
- rewritten = rewriter.rewrite_command(
112
- "es.exe {my-repo} config.py", REGISTRY_WITH_ONE_REPO
113
- )
114
- assert rewritten == f'es.exe "{KNOWN_REPO_PATH}" config.py'
115
-
116
- def test_absolute_path_argument_is_never_modified(self) -> None:
117
- command = f'es.exe "{ABSOLUTE_PATH_ARGUMENT}" config.py'
118
- rewritten = rewriter.rewrite_command(command, REGISTRY_WITH_ONE_REPO)
119
- assert rewritten == command
120
-
121
- def test_unknown_token_is_never_touched(self) -> None:
122
- command = "es.exe unknown-name config.py"
123
- rewritten = rewriter.rewrite_command(command, REGISTRY_WITH_ONE_REPO)
124
- assert rewritten == command
125
-
126
- def test_multiple_tokens_all_rewrite(self) -> None:
127
- command = "es.exe my-repo other-repo config.py"
128
- rewritten = rewriter.rewrite_command(command, REGISTRY_WITH_TWO_REPOS)
129
- assert rewritten == f'es.exe "{KNOWN_REPO_PATH}" "{OTHER_REPO_PATH}" config.py'
130
-
131
- def test_empty_registry_returns_unchanged_command(self) -> None:
132
- command = "es.exe my-repo config.py"
133
- rewritten = rewriter.rewrite_command(command, {})
134
- assert rewritten == command
135
-
136
- def test_double_spaces_inside_quoted_arg_pass_through_unchanged_on_no_registry_hit(
137
- self,
138
- ) -> None:
139
- command = 'es.exe "foo bar" baz'
140
- rewritten = rewriter.rewrite_command(command, REGISTRY_WITH_ONE_REPO)
141
- assert rewritten == command
142
-
143
- def test_tab_separator_is_preserved_when_bare_token_is_rewritten(self) -> None:
144
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
145
- command = "es.exe my-repo\tconfig.py"
146
- rewritten = rewriter.rewrite_command(command, registry)
147
- assert rewritten == f'es.exe "Y:\\Projects\\my-repo"\tconfig.py'
148
-
149
- def test_multiple_substitutions_preserve_all_inter_token_whitespace(self) -> None:
150
- command = "es.exe my-repo other-repo config.py"
151
- rewritten = rewriter.rewrite_command(command, REGISTRY_WITH_TWO_REPOS)
152
- assert rewritten == f'es.exe "{KNOWN_REPO_PATH}" "{OTHER_REPO_PATH}" config.py'
153
-
154
-
155
- class TestEmittedJsonShape:
156
- def test_emitted_json_has_correct_hook_event_name(self) -> None:
157
- hook_input = _make_bash_input(f"es.exe {KNOWN_REPO_NAME} config.py")
158
- with patch(
159
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
160
- ):
161
- stdout, _, _ = _run_main_with_input(hook_input)
162
- emitted = json.loads(stdout)
163
- assert emitted["hookSpecificOutput"]["hookEventName"] == "PreToolUse"
164
-
165
- def test_emitted_json_has_allow_permission_decision(self) -> None:
166
- hook_input = _make_bash_input(f"es.exe {KNOWN_REPO_NAME} config.py")
167
- with patch(
168
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
169
- ):
170
- stdout, _, _ = _run_main_with_input(hook_input)
171
- emitted = json.loads(stdout)
172
- assert emitted["hookSpecificOutput"]["permissionDecision"] == "allow"
173
-
174
- def test_emitted_json_has_rewritten_command(self) -> None:
175
- hook_input = _make_bash_input(f"es.exe {KNOWN_REPO_NAME} config.py")
176
- with patch(
177
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
178
- ):
179
- stdout, _, _ = _run_main_with_input(hook_input)
180
- emitted = json.loads(stdout)
181
- updated_command = emitted["hookSpecificOutput"]["updatedInput"]["command"]
182
- assert updated_command == f'es.exe "{KNOWN_REPO_PATH}" config.py'
183
-
184
- def test_description_field_round_trips_unchanged(self) -> None:
185
- original_description = "my special search description"
186
- hook_input = _make_bash_input(
187
- f"es.exe {KNOWN_REPO_NAME} config.py", original_description
188
- )
189
- with patch(
190
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
191
- ):
192
- stdout, _, _ = _run_main_with_input(hook_input)
193
- emitted = json.loads(stdout)
194
- assert (
195
- emitted["hookSpecificOutput"]["updatedInput"]["description"]
196
- == original_description
197
- )
198
-
199
- def test_additional_unknown_fields_pass_through_into_updated_input(self) -> None:
200
- hook_input = {
201
- "tool_name": "Bash",
202
- "tool_input": {
203
- "command": f"es.exe {KNOWN_REPO_NAME} config.py",
204
- "description": "search",
205
- "extra_field": "extra_value",
206
- },
207
- }
208
- with patch(
209
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
210
- ):
211
- stdout, _, _ = _run_main_with_input(hook_input)
212
- emitted = json.loads(stdout)
213
- assert (
214
- emitted["hookSpecificOutput"]["updatedInput"]["extra_field"]
215
- == "extra_value"
216
- )
217
-
218
- def test_no_code_path_returns_deny_decision(self) -> None:
219
- for command in [
220
- f"es.exe {KNOWN_REPO_NAME} config.py",
221
- "es.exe unknown-token config.py",
222
- "git status",
223
- ]:
224
- hook_input = _make_bash_input(command)
225
- with patch(
226
- "es_exe_path_rewriter.load_registry",
227
- return_value=REGISTRY_WITH_ONE_REPO,
228
- ):
229
- stdout, _, _ = _run_main_with_input(hook_input)
230
- if stdout.strip():
231
- emitted = json.loads(stdout)
232
- decision = emitted.get("hookSpecificOutput", {}).get(
233
- "permissionDecision", ""
234
- )
235
- assert decision != "deny", f"deny returned for command: {command!r}"
236
-
237
-
238
- class TestStdinParsingRobustness:
239
- def test_empty_stdin_exits_zero_without_stdout_or_stderr(self) -> None:
240
- stdout, stderr, exit_code = _run_main_with_stdin_text("")
241
- assert exit_code == 0
242
- assert stdout.strip() == ""
243
- assert stderr.strip() == ""
244
-
245
- def test_whitespace_only_stdin_exits_zero_without_stdout_or_stderr(self) -> None:
246
- stdout, stderr, exit_code = _run_main_with_stdin_text(" \n\t ")
247
- assert exit_code == 0
248
- assert stdout.strip() == ""
249
- assert stderr.strip() == ""
250
-
251
- def test_invalid_json_stdin_exits_zero_without_stdout_or_stderr(self) -> None:
252
- stdout, stderr, exit_code = _run_main_with_stdin_text("{not valid")
253
- assert exit_code == 0
254
- assert stdout.strip() == ""
255
- assert stderr.strip() == ""
256
-
257
-
258
- class TestMalformedHookPayloadTypes:
259
- def test_null_tool_input_exits_zero_without_stdout_or_stderr(self) -> None:
260
- hook_input = {
261
- "tool_name": "Bash",
262
- "tool_input": None,
263
- }
264
- with patch(
265
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
266
- ):
267
- stdout, stderr, exit_code = _run_main_with_input(hook_input)
268
- assert exit_code == 0
269
- assert stdout.strip() == ""
270
- assert stderr.strip() == ""
271
-
272
- def test_list_tool_input_exits_zero_without_stdout_or_stderr(self) -> None:
273
- hook_input = {
274
- "tool_name": "Bash",
275
- "tool_input": ["es.exe", KNOWN_REPO_NAME],
276
- }
277
- with patch(
278
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
279
- ):
280
- stdout, stderr, exit_code = _run_main_with_input(hook_input)
281
- assert exit_code == 0
282
- assert stdout.strip() == ""
283
- assert stderr.strip() == ""
284
-
285
- def test_string_tool_input_exits_zero_without_stdout_or_stderr(self) -> None:
286
- hook_input = {
287
- "tool_name": "Bash",
288
- "tool_input": f"es.exe {KNOWN_REPO_NAME}",
289
- }
290
- with patch(
291
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
292
- ):
293
- stdout, stderr, exit_code = _run_main_with_input(hook_input)
294
- assert exit_code == 0
295
- assert stdout.strip() == ""
296
- assert stderr.strip() == ""
297
-
298
- def test_non_string_command_exits_zero_without_stdout_or_stderr(self) -> None:
299
- hook_input = {
300
- "tool_name": "Bash",
301
- "tool_input": {"command": 12345, "description": "search"},
302
- }
303
- with patch(
304
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
305
- ):
306
- stdout, stderr, exit_code = _run_main_with_input(hook_input)
307
- assert exit_code == 0
308
- assert stdout.strip() == ""
309
- assert stderr.strip() == ""
310
-
311
-
312
- class TestNoOutputCases:
313
- def test_non_es_exe_command_produces_no_output(self) -> None:
314
- hook_input = _make_bash_input("git status")
315
- with patch(
316
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
317
- ):
318
- stdout, _, _ = _run_main_with_input(hook_input)
319
- assert stdout.strip() == ""
320
-
321
- def test_empty_registry_produces_no_output(self) -> None:
322
- hook_input = _make_bash_input(f"es.exe {KNOWN_REPO_NAME} config.py")
323
- with patch("es_exe_path_rewriter.load_registry", return_value={}):
324
- stdout, _, _ = _run_main_with_input(hook_input)
325
- assert stdout.strip() == ""
326
-
327
- def test_unchanged_command_produces_no_output(self) -> None:
328
- hook_input = _make_bash_input("es.exe unknown-token config.py")
329
- with patch(
330
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
331
- ):
332
- stdout, _, _ = _run_main_with_input(hook_input)
333
- assert stdout.strip() == ""
334
-
335
- def test_malformed_registry_produces_no_output_and_one_stderr_line(self) -> None:
336
- hook_input = _make_bash_input(f"es.exe {KNOWN_REPO_NAME} config.py")
337
- with patch(
338
- "es_exe_path_rewriter.load_registry",
339
- side_effect=Exception("simulated read error"),
340
- ):
341
- stdout, stderr, _ = _run_main_with_input(hook_input)
342
- assert stdout.strip() == ""
343
- assert stderr.strip() != ""
344
- assert stderr.strip().count("\n") == 0
345
-
346
- def test_non_bash_tool_produces_no_output(self) -> None:
347
- hook_input = {
348
- "tool_name": "Write",
349
- "tool_input": {"command": f"es.exe {KNOWN_REPO_NAME}"},
350
- }
351
- with patch(
352
- "es_exe_path_rewriter.load_registry", return_value=REGISTRY_WITH_ONE_REPO
353
- ):
354
- stdout, _, _ = _run_main_with_input(hook_input)
355
- assert stdout.strip() == ""
356
-
357
-
358
- class TestQuoteAwareTokenizer:
359
- def test_double_quoted_multiword_arg_with_registry_key_prefix_is_not_substituted(
360
- self,
361
- ) -> None:
362
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
363
- command = 'es.exe "my-repo foo" baz'
364
- rewritten = rewriter.rewrite_command(command, registry)
365
- assert rewritten == command
366
-
367
- def test_single_quoted_multiword_arg_with_registry_key_prefix_is_not_substituted(
368
- self,
369
- ) -> None:
370
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
371
- command = "es.exe 'my-repo baz' config.py"
372
- rewritten = rewriter.rewrite_command(command, registry)
373
- assert rewritten == command
374
-
375
- def test_bare_token_matching_registry_key_is_rewritten(self) -> None:
376
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
377
- command = "es.exe my-repo config.py"
378
- rewritten = rewriter.rewrite_command(command, registry)
379
- assert rewritten == f'es.exe "Y:\\Projects\\my-repo" config.py'
380
-
381
- def test_whitespace_between_bare_tokens_is_preserved_after_rewrite(self) -> None:
382
- registry = {"my-repo": "Y:\\Projects\\my-repo", "other-repo": "C:\\Dev\\other"}
383
- command = "es.exe my-repo other-repo config.py"
384
- rewritten = rewriter.rewrite_command(command, registry)
385
- assert rewritten == f'es.exe "Y:\\Projects\\my-repo" "C:\\Dev\\other" config.py'
386
-
387
- def test_tab_separator_is_preserved_when_bare_token_is_rewritten(self) -> None:
388
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
389
- command = "es.exe my-repo\tconfig.py"
390
- rewritten = rewriter.rewrite_command(command, registry)
391
- assert rewritten == f'es.exe "Y:\\Projects\\my-repo"\tconfig.py'
392
-
393
-
394
- class TestQuotedSingleWordRewrite:
395
- def test_double_quoted_single_word_registry_key_is_rewritten(self) -> None:
396
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
397
- command = 'es.exe "my-repo" config.py'
398
- rewritten = rewriter.rewrite_command(command, registry)
399
- assert rewritten == f'es.exe "Y:\\Projects\\my-repo" config.py'
400
-
401
- def test_single_quoted_single_word_registry_key_is_rewritten(self) -> None:
402
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
403
- command = "es.exe 'my-repo' config.py"
404
- rewritten = rewriter.rewrite_command(command, registry)
405
- assert rewritten == f'es.exe "Y:\\Projects\\my-repo" config.py'
406
-
407
-
408
- class TestPlaceholderBoundaryEnforcement:
409
- def test_placeholder_inside_flag_argument_is_not_rewritten(self) -> None:
410
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
411
- command = "es.exe --regex=^{my-repo}$"
412
- rewritten = rewriter.rewrite_command(command, registry)
413
- assert rewritten == command
414
-
415
- def test_placeholder_embedded_in_token_is_not_rewritten(self) -> None:
416
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
417
- command = "es.exe foo{my-repo}bar"
418
- rewritten = rewriter.rewrite_command(command, registry)
419
- assert rewritten == command
420
-
421
- def test_standalone_placeholder_is_still_rewritten(self) -> None:
422
- registry = {"my-repo": "Y:\\Projects\\my-repo"}
423
- command = "es.exe {my-repo} config.py"
424
- rewritten = rewriter.rewrite_command(command, registry)
425
- assert rewritten == f'es.exe "Y:\\Projects\\my-repo" config.py'
426
-
427
-
428
- class TestAbsolutePathDetection:
429
- def test_windows_drive_letter_path_detected_as_absolute(self) -> None:
430
- assert rewriter._token_is_absolute_path("C:\\Users\\x")
431
-
432
- def test_windows_drive_letter_path_with_forward_slashes_detected_as_absolute(
433
- self,
434
- ) -> None:
435
- assert rewriter._token_is_absolute_path("Y:/Projects/foo")
436
-
437
- def test_unc_path_detected_as_absolute(self) -> None:
438
- assert rewriter._token_is_absolute_path("\\\\server\\share\\path")
439
-
440
- def test_posix_absolute_path_detected_as_absolute(self) -> None:
441
- assert rewriter._token_is_absolute_path("/etc/hosts")
442
-
443
- def test_relative_path_not_detected_as_absolute(self) -> None:
444
- assert not rewriter._token_is_absolute_path("./foo")
445
-
446
- def test_bare_registry_token_not_detected_as_absolute(self) -> None:
447
- assert not rewriter._token_is_absolute_path("my-repo")