|
7 | 7 | are rejected by ``matches_payload`` and fall through to the allow-and-skip path. |
8 | 8 |
|
9 | 9 | VS Code sends Claude-style payloads (``hook_event_name``, ``tool_name``, |
10 | | -``tool_input``) with structural differences that ``matches_payload`` keys on: |
11 | | -a top-level ISO ``timestamp`` and no ``transcript_path``. Copilot hooks have no |
| 10 | +``tool_input``), told apart by the one field Claude Code never sends: a top-level |
| 11 | +ISO ``timestamp``. VS Code also sends a ``transcript_path`` of its own once a |
| 12 | +workspace has chat history, so that field cannot discriminate. Copilot hooks have no |
12 | 13 | matchers, so ``preToolUse`` fires for every tool; tools we don't scan pass |
13 | 14 | through as raw event names, which match no handler and allow immediately. |
14 | 15 | """ |
@@ -340,14 +341,9 @@ def entry(command: str) -> dict: |
340 | 341 | } |
341 | 342 |
|
342 | 343 | def matches_payload(self, raw_payload: dict) -> bool: |
343 | | - # Structural discrimination, no magic strings: VS Code Copilot events carry |
344 | | - # a top-level ISO timestamp and no transcript_path; real Claude Code events |
345 | | - # always carry transcript_path; Copilot CLI payloads have no hook_event_name. |
346 | | - return ( |
347 | | - raw_payload.get('hook_event_name', '') in _COPILOT_SCAN_EVENT_NAMES |
348 | | - and 'timestamp' in raw_payload |
349 | | - and 'transcript_path' not in raw_payload |
350 | | - ) |
| 344 | + # Structural discrimination, no magic strings: Copilot events carry a top-level |
| 345 | + # timestamp, Claude Code events never do. |
| 346 | + return raw_payload.get('hook_event_name', '') in _COPILOT_SCAN_EVENT_NAMES and 'timestamp' in raw_payload |
351 | 347 |
|
352 | 348 | def parse_hook_payload(self, raw_payload: dict) -> AIHookPayload: |
353 | 349 | hook_event_name = raw_payload.get('hook_event_name', '') |
|
0 commit comments