check-complete.ps1 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Check if all phases in task_plan.md are complete
  2. # Always exits 0 -- uses stdout for status reporting
  3. # Used by Stop hook to report task completion status
  4. param(
  5. [string]$PlanFile = "task_plan.md"
  6. )
  7. if (-not (Test-Path $PlanFile)) {
  8. Write-Host '[planning-with-files] No task_plan.md found -- no active planning session.'
  9. exit 0
  10. }
  11. # Read file content
  12. $content = Get-Content $PlanFile -Raw
  13. # Count total phases
  14. $TOTAL = ([regex]::Matches($content, "### Phase")).Count
  15. # Check for **Status:** format first
  16. $COMPLETE = ([regex]::Matches($content, "\*\*Status:\*\* complete")).Count
  17. $IN_PROGRESS = ([regex]::Matches($content, "\*\*Status:\*\* in_progress")).Count
  18. $PENDING = ([regex]::Matches($content, "\*\*Status:\*\* pending")).Count
  19. # Fallback: check for [complete] inline format if **Status:** not found
  20. if ($COMPLETE -eq 0 -and $IN_PROGRESS -eq 0 -and $PENDING -eq 0) {
  21. $COMPLETE = ([regex]::Matches($content, "\[complete\]")).Count
  22. $IN_PROGRESS = ([regex]::Matches($content, "\[in_progress\]")).Count
  23. $PENDING = ([regex]::Matches($content, "\[pending\]")).Count
  24. }
  25. # Report status -- always exit 0, incomplete task is a normal state
  26. if ($COMPLETE -eq $TOTAL -and $TOTAL -gt 0) {
  27. Write-Host ('[planning-with-files] ALL PHASES COMPLETE (' + $COMPLETE + '/' + $TOTAL + '). If the user has additional work, add new phases to task_plan.md before starting.')
  28. } else {
  29. Write-Host ('[planning-with-files] Task in progress (' + $COMPLETE + '/' + $TOTAL + ' phases complete). Update progress.md before stopping.')
  30. if ($IN_PROGRESS -gt 0) {
  31. Write-Host ('[planning-with-files] ' + $IN_PROGRESS + ' phase(s) still in progress.')
  32. }
  33. if ($PENDING -gt 0) {
  34. Write-Host ('[planning-with-files] ' + $PENDING + ' phase(s) pending.')
  35. }
  36. }
  37. exit 0