github / github/copilot-cli

sessionStart hook doesn't print to terminal and doesn't run at CLI startup

Đang mở
#2,201 3 bình luận 2 reaction 0 người được giao Xem trên GitHub
area:plugins
Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Mô tả

### Describe the bug

I followed the hooks tutorial here: https://docs.github.com/en/copilot/tutorials/copilot-cli-hooks

However, nothing gets printed at CLI startup.

I edited my session-banner script to add to the audit log that the tutorial sets up:

```
$ErrorActionPreference = "Stop"

Write-Host @"
COPILOT CLI POLICY ACTIVE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
• Prompts and tool use may be logged for auditing
• High-risk commands may be blocked automatically
• If something is blocked, follow the guidance shown
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
"@

# NEW CODE BELOW

$logDir = "./logs"
if (-not (Test-Path $logDir)) {
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
}

$logEntry = @{
event = "sessionStart"
timestamp = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
} | ConvertTo-Json -Compress

Add-Content -Path "$logDir/audit.jsonl" -Value $logEntry

Write-Host "🚀 XBC Copilot session started — hooks active."
exit 0
```

And when I look at the audit.jsonl, the sessionStart entry is _after_ the userPromptSubmitted:
```
{"event":"userPromptSubmitted","timestampMs":1774043873173,"cwd":"E:\\xbc1","prompt":"copilot launched at 2:57:45. It is now past that. There is no log in .github\\hooks\\logs. I followed the hooks guide here (https://docs.github.com/en/copilot/tutorials/copilot-cli-hooks) but sessionStart doesn't actually start at sessionStart."}
{"event":"sessionStart","timestamp":1774043874301}
{"toolName":"report_intent","toolArgs":"{\"intent\": \"Debugging CLI hooks setup\"}","event":"preToolUse"}
{"toolArgs":"","event":"preToolUse","toolName":"fetch_copilot_cli_documentation"}
```

### Affected version

GitHub Copilot CLI 1.0.10

### Steps to reproduce the behavior

Follow the guide https://docs.github.com/en/copilot/tutorials/copilot-cli-hooks , then open copilot. Observe that nothing gets printed at session startup.

Update the session-banner to the one I described above. Re-run copilot, ask it any question, then observe the log at `.github/hooks/logs/audit.jsonl`. It should show that sessionStart actually fires after userPromptSubmitted... which is weird???

### Expected behavior

I would have expected sessionStart to start at copilot CLI startup... _AND_ I would expect the sessionStart's stdout to show up in the CLI. Otherwise, what was the point of sessionStart? It explicitly states that the sessionStart hook "Shows an informational message when a new agent session starts or resumes.", which seems to be false. It also says "Any output from this hook is ignored by Copilot CLI, which makes it suitable for informational messages." , but if it doesn't actually show the message, how is it informational?

### Additional context

_No response_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.