Skip to content

Commit da6c20d

Browse files
committed
refactor: rework integration events per maintainer review
- Rename hooks terminology to 'events' (events:, --events flag, events.py). - Use snake_case names for canonical events consistent with spec-kit vocabulary. - Fold event config adapters into integration classes via class attributes (CANONICAL_TO_NATIVE, events_config_file, events_format). - Lift event command-script resolution to core 'specify event run' command. - Split events sourcing from integration config writing. - Support first-class Copilot CLI events JSON generation under '.github/hooks/speckit.json'. - Rewrite and expand full test suite under 'tests/integrations/test_events.py'. Assisted-by: opencode (model: litellm/gemini-3.5-flash, autonomous)
1 parent c5f1e96 commit da6c20d

20 files changed

Lines changed: 1399 additions & 1686 deletions

File tree

‎src/specify_cli/__init__.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,11 @@ def version(
508508
from .integrations._commands import register as _register_integration_cmds # noqa: E402
509509
_register_integration_cmds(app)
510510

511+
512+
# ===== Event Commands =====
513+
from .commands.event import register as _register_event_cmds
514+
_register_event_cmds(app)
515+
511516
# Re-export selected helpers to preserve the public import surface.
512517
from .integrations._helpers import ( # noqa: E402
513518
_clear_init_options_for_integration as _clear_init_options_for_integration,

‎src/specify_cli/commands/event.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""specify event * command handlers."""
2+
3+
from __future__ import annotations
4+
5+
from pathlib import Path
6+
import sys
7+
import typer
8+
9+
from .._console import console
10+
11+
event_app = typer.Typer(
12+
name="event",
13+
help="Manage and execute event-driven commands",
14+
add_completion=False,
15+
)
16+
17+
18+
@event_app.command("run")
19+
def event_run(
20+
command_name: str = typer.Argument(..., help="Name of the command to execute"),
21+
event_name: str = typer.Argument(..., help="Canonical event name (e.g., session_start)"),
22+
):
23+
"""Resolve and run an event-driven command script with stdin payload."""
24+
from ..events import resolve_and_run_event_command
25+
26+
# Read payload from stdin if available
27+
payload = sys.stdin.read() if not sys.stdin.isatty() else "{}"
28+
29+
# Run the event command
30+
project_root = Path.cwd() # The agent runs events from project root
31+
exit_code = resolve_and_run_event_command(command_name, event_name, payload, project_root)
32+
raise typer.Exit(code=exit_code)
33+
34+
35+
def register(app: typer.Typer) -> None:
36+
app.add_typer(event_app, name="event")

‎src/specify_cli/commands/init.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,20 @@ def init(
442442
if extra:
443443
integration_parsed_options.update(extra)
444444

445+
from ..events import resolve_events
446+
events_map = resolve_events(
447+
resolved_integration.key,
448+
resolved_integration.config,
449+
project_path,
450+
integration_parsed_options or None,
451+
)
445452
resolved_integration.setup(
446453
project_path,
447454
manifest,
448455
parsed_options=integration_parsed_options or None,
449456
script_type=selected_script,
450457
raw_options=integration_options,
458+
events=events_map,
451459
)
452460
manifest.save()
453461

0 commit comments

Comments
 (0)