Files
CursorInitGeneral/.cursor/hooks/session-init.ps1

49 lines
1.4 KiB
PowerShell

# sessionStart: reset changelog runtime markers and skip checks outside agent mode.
$utf8 = New-Object System.Text.UTF8Encoding($false)
[Console]::InputEncoding = $utf8
[Console]::OutputEncoding = $utf8
$inputPayload = [Console]::In.ReadToEnd()
$mode = $null
try {
if (-not [string]::IsNullOrWhiteSpace($inputPayload)) {
$data = $inputPayload | ConvertFrom-Json
if ($data.composer_mode -is [string]) {
$mode = $data.composer_mode
}
}
} catch {
$mode = $null
}
$cursorDir = Split-Path -Parent $PSScriptRoot
$ackFile = Join-Path $cursorDir 'changelog\.changelog-ack'
$sessionMarker = Join-Path $cursorDir 'changelog\.session-start'
Remove-Item -LiteralPath $ackFile -Force -ErrorAction SilentlyContinue
try {
$stream = [System.IO.File]::Open(
$sessionMarker,
[System.IO.FileMode]::Create,
[System.IO.FileAccess]::Write,
[System.IO.FileShare]::ReadWrite
)
$stream.Dispose()
} catch {
# Runtime marker failure must not block session startup.
}
if (-not [string]::IsNullOrWhiteSpace($mode) -and $mode -ne 'agent') {
$result = [ordered]@{
env = [ordered]@{
CURSOR_SKIP_CHANGELOG = '1'
CURSOR_COMPOSER_MODE = $mode
}
}
[Console]::Out.WriteLine(($result | ConvertTo-Json -Compress -Depth 4))
} else {
[Console]::Out.WriteLine('{}')
}
exit 0