33 lines
2.5 KiB
PowerShell
33 lines
2.5 KiB
PowerShell
# Ce face acum agentul Archon: ultima sesiune activa (Pi sau Claude), de cand tace, ultimii pasi.
|
|
# Folosire: urmareste.ps1 [-N 8] [-Watch] (-Watch = reimprospateaza la 15s, Ctrl+C iese)
|
|
param([int]$N = 8, [switch]$Watch)
|
|
$dirs = 'C:\Users\mmari\.pi\agent\sessions\--D--ROA-ROACONT--', 'C:\Users\mmari\.claude\projects\D--ROA-ROACONT'
|
|
|
|
function Scurt($s, $max = 160) { $s = ("$s" -replace '\s+', ' ').Trim(); if ($s.Length -gt $max) { $s.Substring(0, $max) + '...' } else { $s } }
|
|
|
|
function Arata {
|
|
$f = Get-ChildItem $dirs -Filter *.jsonl -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending |
|
|
Where-Object { $_.FullName -like '*\.pi\*' -or (Select-String -Path $_.FullName -Pattern '"entrypoint":"sdk-ts"' -SimpleMatch -Quiet) } | Select-Object -First 1 # doar sesiunile Archon (sdk), nu Claude Code interactiv
|
|
if (-not $f) { 'Nicio sesiune gasita.'; return }
|
|
$tace = [int]((Get-Date) - $f.LastWriteTime).TotalSeconds
|
|
$tip = if ($f.FullName -like '*\.pi\*') { 'Pi/DeepSeek' } else { 'Claude' }
|
|
"=== $tip $($f.Name)"
|
|
"=== ultima scriere: $($f.LastWriteTime.ToString('HH:mm:ss')) (tace de ${tace}s)" + $(if ($tace -gt 600) { ' <-- POSIBIL BLOCAT' } else { '' })
|
|
$pasi = foreach ($l in (Get-Content $f.FullName -Tail 200 -Encoding UTF8)) {
|
|
try { $e = $l | ConvertFrom-Json } catch { continue }
|
|
$m = $e.message; if (-not $m) { continue }
|
|
$ora = if ($e.timestamp) { ([datetime]$e.timestamp).ToLocalTime().ToString('HH:mm:ss') } else { '' }
|
|
foreach ($c in @($m.content)) {
|
|
switch ($c.type) {
|
|
'toolCall' { "$ora > $($c.name): $(Scurt ($c.arguments.command, $c.arguments.path, ($c.arguments | ConvertTo-Json -Compress) | Where-Object { $_ } | Select-Object -First 1))" }
|
|
'tool_use' { "$ora > $($c.name): $(Scurt ($c.input.command, $c.input.file_path, $c.input.pattern, ($c.input | ConvertTo-Json -Compress) | Where-Object { $_ } | Select-Object -First 1))" }
|
|
'text' { if ($m.role -eq 'assistant') { "$ora $(Scurt $c.text)" } elseif ($m.role -eq 'toolResult') { "$ora < $(if ($m.isError) { 'EROARE ' })$(Scurt $c.text 120)" } }
|
|
'tool_result' { $t = if ($c.content -is [string]) { $c.content } else { @($c.content)[0].text }; "$ora < $(if ($c.is_error) { 'EROARE ' })$(Scurt $t 120)" }
|
|
}
|
|
}
|
|
}
|
|
$pasi | Select-Object -Last $N
|
|
}
|
|
|
|
do { if ($Watch) { Clear-Host }; Arata; if ($Watch) { Start-Sleep 15 } } while ($Watch)
|