github / github/copilot-cli

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

オープン
#2,201 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る
area:plugins
主要言語
Shell
スター
11.2k
フォーク
1.9k
平均マージ
14時間 16分
マージ済み PR(30日)
6

説明

### 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_

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。