analyze-session2.ps1 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. $ErrorActionPreference = 'SilentlyContinue'
  2. [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
  3. $OutputEncoding = [System.Text.Encoding]::UTF8
  4. $path = 'C:\Users\Administrator\.claude\projects\E--QMAI\282997c5-b3c4-46ce-9c34-e84e039e78a4.jsonl'
  5. $lines = Get-Content $path -Encoding UTF8
  6. $i = 0
  7. foreach ($l in $lines) {
  8. $i++
  9. try { $o = $l | ConvertFrom-Json } catch { continue }
  10. if ($o.type -eq 'user' -and $o.message.role -eq 'user') {
  11. $c = $o.message.content
  12. if ($c -is [array]) {
  13. foreach ($p in $c) {
  14. if ($p.type -eq 'text' -and $p.text) {
  15. $t = $p.text
  16. if ($t -notmatch '^\[Request interrupted' -and $t -notmatch 'tool_result' -and $t -notmatch 'task-notification' -and $t.Length -lt 1500) {
  17. if ($t.Length -gt 300) { $t = $t.Substring(0, 300) + '...' }
  18. Write-Output ("[" + $i + "] " + $t)
  19. Write-Output "----"
  20. }
  21. }
  22. }
  23. }
  24. elseif ($c -is [string]) {
  25. if ($c -notmatch '^\[Request interrupted' -and $c.Length -lt 1500) {
  26. $tt = $c
  27. if ($tt.Length -gt 300) { $tt = $tt.Substring(0, 300) + '...' }
  28. Write-Output ("[" + $i + "] " + $tt)
  29. Write-Output "----"
  30. }
  31. }
  32. }
  33. }