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
49 lines
1.6 KiB
PowerShell
49 lines
1.6 KiB
PowerShell
# planning-with-files: Agent stop hook for GitHub Copilot (PowerShell)
|
|
# Checks if all phases in task_plan.md are complete.
|
|
# Injects continuation context if phases are incomplete.
|
|
# 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
|
|
}
|
|
|
|
$content = Get-Content $PlanFile -Raw
|
|
|
|
# Count total phases
|
|
$TOTAL = ([regex]::Matches($content, "### Phase")).Count
|
|
|
|
# Check for **Status:** format first
|
|
$COMPLETE = ([regex]::Matches($content, "\*\*Status:\*\* complete")).Count
|
|
$IN_PROGRESS = ([regex]::Matches($content, "\*\*Status:\*\* in_progress")).Count
|
|
$PENDING = ([regex]::Matches($content, "\*\*Status:\*\* pending")).Count
|
|
|
|
# Fallback: check for [complete] inline format
|
|
if ($COMPLETE -eq 0 -and $IN_PROGRESS -eq 0 -and $PENDING -eq 0) {
|
|
$COMPLETE = ([regex]::Matches($content, "\[complete\]")).Count
|
|
$IN_PROGRESS = ([regex]::Matches($content, "\[in_progress\]")).Count
|
|
$PENDING = ([regex]::Matches($content, "\[pending\]")).Count
|
|
}
|
|
|
|
if ($COMPLETE -eq $TOTAL -and $TOTAL -gt 0) {
|
|
Write-Output '{}'
|
|
exit 0
|
|
}
|
|
|
|
$msg = "[planning-with-files] Task incomplete ($COMPLETE/$TOTAL phases done). Read task_plan.md and continue working on the remaining phases."
|
|
$output = @{
|
|
hookSpecificOutput = @{
|
|
hookEventName = "AgentStop"
|
|
additionalContext = $msg
|
|
}
|
|
}
|
|
$output | ConvertTo-Json -Depth 3 -Compress
|
|
exit 0
|