- session-audit.json: add SessionStop entry pointing to new end-of-session scripts - report-hook-event-end.sh/.ps1: log payload to hook-events.log and write TSV row to session-events.tsv - report-hook-event.sh/.ps1: also write SessionStart TSV row to session-events.tsv so start/end pairs are queryable for duration
23 lines
983 B
PowerShell
23 lines
983 B
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
$StateDir = if ($env:COPILOT_RESOURCES_STATE_DIR) { $env:COPILOT_RESOURCES_STATE_DIR } else { Join-Path $HOME '.copilot-resources-state' }
|
|
New-Item -ItemType Directory -Path $StateDir -Force | Out-Null
|
|
|
|
$Payload = [Console]::In.ReadToEnd()
|
|
$Payload | Add-Content -LiteralPath (Join-Path $StateDir 'hook-events.log')
|
|
|
|
# Append a TSV row to session-events.tsv for duration tracking.
|
|
"$(Get-Date -AsUTC -Format o)`tSessionStart" | Add-Content -LiteralPath (Join-Path $StateDir 'session-events.tsv')
|
|
|
|
$PortRegistryScript = Join-Path $PSScriptRoot 'update-port-registry.mjs'
|
|
$NodeCommand = Get-Command node -ErrorAction SilentlyContinue
|
|
if ($NodeCommand -and (Test-Path -LiteralPath $PortRegistryScript)) {
|
|
try {
|
|
$Payload | & $NodeCommand.Source $PortRegistryScript | Out-Null
|
|
} catch {
|
|
"$(Get-Date -AsUTC -Format o) update-port-registry failed" | Add-Content -LiteralPath (Join-Path $StateDir 'project-ports-errors.log')
|
|
}
|
|
}
|
|
|
|
'{"continue": true}'
|