PowerShell scripts (all 4): - Add $OutputEncoding and [Console]::OutputEncoding = UTF8 before any output - Fixes diamond replacement characters (◆) caused by PowerShell 5.x defaulting to UTF-16LE stdout — Copilot reads stdout as UTF-8, causing the byte mismatch that produces garbled output on Windows systems Bash scripts (session-start.sh, pre-tool-use.sh): - Use json.dumps(..., ensure_ascii=False) instead of default ensure_ascii=True - Preserves UTF-8 characters (CJK, emojis, accented letters) in task_plan.md context instead of converting them to raw \uXXXX escape sequences README: - Move Contributors from ugly bottom section into collapsible near top - Add full contributors table with all PR authors since v2.8.0 - Add @Hexiaopi for Issue #82 bug report - Update version badge and releases table to v2.16.1 CHANGELOG: add [2.16.1] entry Fixes #82 — reported by @Hexiaopi
34 lines
991 B
PowerShell
34 lines
991 B
PowerShell
# planning-with-files: Pre-tool-use hook for GitHub Copilot (PowerShell)
|
|
# Reads the first 30 lines of task_plan.md to keep goals in context.
|
|
# Always allows tool execution — this hook never blocks tools.
|
|
# Always exits 0 — outputs JSON to stdout.
|
|
|
|
# Read stdin (required — Copilot pipes JSON to stdin)
|
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
$InputData = [Console]::In.ReadToEnd()
|
|
|
|
$PlanFile = "task_plan.md"
|
|
|
|
if (-not (Test-Path $PlanFile)) {
|
|
Write-Output '{}'
|
|
exit 0
|
|
}
|
|
|
|
$Context = (Get-Content $PlanFile -TotalCount 30 -ErrorAction SilentlyContinue) -join "`n"
|
|
|
|
if (-not $Context) {
|
|
Write-Output '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}'
|
|
exit 0
|
|
}
|
|
|
|
$output = @{
|
|
hookSpecificOutput = @{
|
|
hookEventName = "PreToolUse"
|
|
permissionDecision = "allow"
|
|
additionalContext = $Context
|
|
}
|
|
}
|
|
$output | ConvertTo-Json -Depth 3 -Compress
|
|
exit 0
|