Skip to content

Commit 7281217

Browse files
committed
revert extensions.py and test changes, keep commit.md template fix only
Address PR review: remove hook message changes from extensions.py (avoids changing $ARGUMENTS semantics for all hooks). The fix is now entirely in the speckit.git.commit.md command template which instructs agents to read the config file and documents the message fallback.
1 parent 27976bd commit 7281217

4 files changed

Lines changed: 14 additions & 21 deletions

File tree

extensions/git/commands/speckit.git.commit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ If the file does not exist, auto-commit is disabled. Exit silently.
2828
Look under the `auto_commit:` section in the config file you just read:
2929

3030
1. Find the key matching the event name (e.g., `after_tasks:`).
31-
2. If the event key exists **and** has `enabled: true` → auto-commit is **enabled**. Use the `message` value from that key.
31+
2. If the event key exists **and** has `enabled: true` → auto-commit is **enabled**. Use the `message` value from that key if present; if `message` is missing or empty, fall back to the default format `"[Spec Kit] Auto-commit <before|after> <command>"`.
3232
3. If the event key exists **and** has `enabled: false` → auto-commit is **disabled**. Exit silently.
3333
4. If the event key does **not** exist at all, check `auto_commit.default`:
3434
- `default: true` → auto-commit is **enabled**. Use a default message `"[Spec Kit] Auto-commit <before|after> <command>"` (e.g., `after_tasks``"[Spec Kit] Auto-commit after tasks"`).

src/specify_cli/extensions.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,18 +2785,16 @@ def format_hook_message(
27852785

27862786
if optional:
27872787
lines.append(f"\n**Optional Hook**: {extension}")
2788-
lines.append(f"Hook event: {event_name}")
27892788
lines.append(f"Command: `{display_invocation}`")
27902789
if description:
27912790
lines.append(f"Description: {description}")
27922791
lines.append(f"\nPrompt: {prompt}")
2793-
lines.append(f"To execute: `{display_invocation} {event_name}`")
2792+
lines.append(f"To execute: `{display_invocation}`")
27942793
else:
27952794
lines.append(f"\n**Automatic Hook**: {extension}")
2796-
lines.append(f"Hook event: {event_name}")
2797-
lines.append(f"Executing: `{display_invocation} {event_name}`")
2795+
lines.append(f"Executing: `{display_invocation}`")
27982796
lines.append(f"EXECUTE_COMMAND: {command_text}")
2799-
lines.append(f"EXECUTE_COMMAND_INVOCATION: {display_invocation} {event_name}")
2797+
lines.append(f"EXECUTE_COMMAND_INVOCATION: {display_invocation}")
28002798

28012799
return "\n".join(lines)
28022800

tests/integrations/test_integration_claude.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,9 @@ def test_claude_hooks_render_skill_invocation(self, tmp_path):
269269
],
270270
)
271271

272-
assert "Hook event: before_plan" in message
273-
assert "Executing: `/speckit-plan before_plan`" in message
272+
assert "Executing: `/speckit-plan`" in message
274273
assert "EXECUTE_COMMAND: speckit.plan" in message
275-
assert "EXECUTE_COMMAND_INVOCATION: /speckit-plan before_plan" in message
274+
assert "EXECUTE_COMMAND_INVOCATION: /speckit-plan" in message
276275

277276
def test_claude_preset_creates_new_skill_without_commands_dir(self, tmp_path):
278277
from specify_cli import save_init_options

tests/test_extensions.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4269,10 +4269,9 @@ def test_kimi_hooks_render_skill_invocation(self, project_dir):
42694269
],
42704270
)
42714271

4272-
assert "Hook event: before_plan" in message
4273-
assert "Executing: `/skill:speckit-plan before_plan`" in message
4272+
assert "Executing: `/skill:speckit-plan`" in message
42744273
assert "EXECUTE_COMMAND: speckit.plan" in message
4275-
assert "EXECUTE_COMMAND_INVOCATION: /skill:speckit-plan before_plan" in message
4274+
assert "EXECUTE_COMMAND_INVOCATION: /skill:speckit-plan" in message
42764275

42774276
def test_codex_hooks_render_dollar_skill_invocation(self, project_dir):
42784277
"""Codex projects with --ai-skills should render $speckit-* invocations."""
@@ -4310,10 +4309,9 @@ def test_non_skill_command_keeps_slash_invocation(self, project_dir):
43104309
],
43114310
)
43124311

4313-
assert "Hook event: before_tasks" in message
4314-
assert "Executing: `/pre_tasks_test before_tasks`" in message
4312+
assert "Executing: `/pre_tasks_test`" in message
43154313
assert "EXECUTE_COMMAND: pre_tasks_test" in message
4316-
assert "EXECUTE_COMMAND_INVOCATION: /pre_tasks_test before_tasks" in message
4314+
assert "EXECUTE_COMMAND_INVOCATION: /pre_tasks_test" in message
43174315

43184316
def test_extension_command_uses_hyphenated_skill_invocation(self, project_dir):
43194317
"""Multi-segment extension command ids should map to hyphenated skills."""
@@ -4333,10 +4331,9 @@ def test_extension_command_uses_hyphenated_skill_invocation(self, project_dir):
43334331
],
43344332
)
43354333

4336-
assert "Hook event: after_tasks" in message
4337-
assert "Executing: `/skill:speckit-test-ext-hello after_tasks`" in message
4334+
assert "Executing: `/skill:speckit-test-ext-hello`" in message
43384335
assert "EXECUTE_COMMAND: speckit.test-ext.hello" in message
4339-
assert "EXECUTE_COMMAND_INVOCATION: /skill:speckit-test-ext-hello after_tasks" in message
4336+
assert "EXECUTE_COMMAND_INVOCATION: /skill:speckit-test-ext-hello" in message
43404337

43414338
def test_hook_executor_caches_init_options_lookup(self, project_dir, monkeypatch):
43424339
"""Init options should be loaded once per executor instance."""
@@ -4371,10 +4368,9 @@ def test_hook_message_falls_back_when_invocation_is_empty(self, project_dir):
43714368
],
43724369
)
43734370

4374-
assert "Hook event: after_tasks" in message
4375-
assert "Executing: `/<missing command> after_tasks`" in message
4371+
assert "Executing: `/<missing command>`" in message
43764372
assert "EXECUTE_COMMAND: <missing command>" in message
4377-
assert "EXECUTE_COMMAND_INVOCATION: /<missing command> after_tasks" in message
4373+
assert "EXECUTE_COMMAND_INVOCATION: /<missing command>" in message
43784374

43794375

43804376
class TestExtensionRemoveCLI:

0 commit comments

Comments
 (0)