Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/integrations/copilot.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ Native events use `.github/hooks/speckit.json`.
`--integration-options="--events false"` disables Spec Kit event handlers.
See [runtime events](cli.md#runtime-events).

A `session_start` handler can supply model context through its stdout.
Spec Kit runs `user_prompt_submit` handlers with stdout suppressed because
Copilot discards command-hook output for `userPromptSubmitted`.

Workflow steps require Copilot CLI separately from the IDE setup. In skills
mode, command steps pass `/speckit-<command>` in the prompt. In commands mode,
they select `--agent speckit.<command>` and pass the user's arguments as the
Expand Down
8 changes: 3 additions & 5 deletions src/specify_cli/integrations/copilot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,11 @@ class CopilotIntegration(IntegrationBase):
}
events_config_file = ".github/hooks/speckit.json"
events_format = "copilot-json"
# Copilot sessionStart and userPromptSubmitted inject a top-level
# additionalContext field into the model-facing prompt (C13). Non-JSON
# stdout is discarded harmlessly by Copilot on other events, so no other
# event needs an envelope.
# Copilot consumes additionalContext from sessionStart and drops command
# hook output from userPromptSubmitted.
events_context_envelope = {
"session_start": "additionalContext",
"user_prompt_submit": "additionalContext",
"user_prompt_submit": "suppress",
}

# Mutable flag set by setup() — indicates the active scaffolding mode.
Expand Down
14 changes: 5 additions & 9 deletions tests/specify_cli/events/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ def test_copilot_json_generation(self, tmp_path):

events = {
"session_start": [{"command": "speckit.agent-context.update", "timeout": 60}],
"user_prompt_submit": [{"command": "speckit.agent-context.update"}],
}
install_integration_events(integration, tmp_path, manifest, events)

Expand Down Expand Up @@ -674,6 +675,10 @@ def test_copilot_json_generation(self, tmp_path):
# R2: native timeout gets the buffer (60 + 5 = 65) so the agent's
# outer cap fires after the dispatcher's inner subprocess timeout.
assert entry["timeoutSec"] == 65
prompt = data["hooks"]["userPromptSubmitted"][0]
for shell in ("bash", "powershell"):
assert shlex.split(entry[shell])[-2:] == ["60", "additionalContext"]
assert shlex.split(prompt[shell])[-2:] == ["60", "suppress"]


# -- Cursor hooks.json version + matcher grouping (#7, S3) -------------------
Expand Down Expand Up @@ -901,7 +906,6 @@ def test_envelope_resolution_and_command_formatting(self):
from specify_cli.events import _dispatcher_command, _context_envelope_for
from specify_cli.integrations.gemini import GeminiIntegration
from specify_cli.integrations.qwen import QwenIntegration
from specify_cli.integrations.copilot import CopilotIntegration
from specify_cli.integrations.cursor_agent import CursorAgentIntegration
from specify_cli.integrations.claude import ClaudeIntegration
from specify_cli.integrations.codex import CodexIntegration
Expand Down Expand Up @@ -932,14 +936,6 @@ def test_envelope_resolution_and_command_formatting(self):
cmd_qwen_prompt = _dispatcher_command(qwen, Path("/proj"), "speckit.prompt", "user_prompt_submit")
assert cmd_qwen_prompt.endswith(" 60 hookSpecificOutput UserPromptSubmit")

copilot = CopilotIntegration()
assert _context_envelope_for(copilot, "session_start") == "additionalContext"
assert _context_envelope_for(copilot, "user_prompt_submit") == "additionalContext"
cmd_copilot_start = _dispatcher_command(copilot, Path("/proj"), "speckit.boot", "session_start")
assert cmd_copilot_start.endswith(" 60 additionalContext")
cmd_copilot_prompt = _dispatcher_command(copilot, Path("/proj"), "speckit.prompt", "user_prompt_submit")
assert cmd_copilot_prompt.endswith(" 60 additionalContext")

cursor = CursorAgentIntegration()
assert _context_envelope_for(cursor, "session_start") == "additional_context"
assert _context_envelope_for(cursor, "user_prompt_submit") == "suppress"
Expand Down
Loading