feat: persist compact session state
This commit is contained in:
1 parent
a509509192
commit
9b5e862d8a
7 files changed
+31
-1
No files matched your search
@@ -19,6 +19,8 @@
|
|||||||
"command": "__STATUSLINE_COMMAND__ \"__AI_CONFIG_ROOT__/statusline/__STATUSLINE_SCRIPT__\""
|
"command": "__STATUSLINE_COMMAND__ \"__AI_CONFIG_ROOT__/statusline/__STATUSLINE_SCRIPT__\""
|
||||||
},
|
},
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
"PreCompact": [{"hooks": [{"type": "command", "command": "__HOOK_COMMAND__ \"__AI_CONFIG_ROOT__/hooks/scripts/__COMPACT_SCRIPT__\"", "timeout": 4}]}],
|
||||||
|
"SessionStart": [{"hooks": [{"type": "command", "command": "__HOOK_COMMAND__ \"__AI_CONFIG_ROOT__/hooks/scripts/__SESSION_POINTER_SCRIPT__\"", "timeout": 4}]}],
|
||||||
"Stop": [
|
"Stop": [
|
||||||
{
|
{
|
||||||
"hooks": [
|
"hooks": [
|
||||||
|
|||||||
+3
-1
@@ -190,7 +190,9 @@ foreach ($platform in @('windows','linux')) {
|
|||||||
$script = if ($platform -eq 'windows') { 'flashbang.ps1' } else { 'flashbang.sh' }
|
$script = if ($platform -eq 'windows') { 'flashbang.ps1' } else { 'flashbang.sh' }
|
||||||
$statusLineScript = if ($platform -eq 'windows') { 'statusline.ps1' } else { 'statusline.sh' }
|
$statusLineScript = if ($platform -eq 'windows') { 'statusline.ps1' } else { 'statusline.sh' }
|
||||||
$content = Get-Content -LiteralPath $path -Raw
|
$content = Get-Content -LiteralPath $path -Raw
|
||||||
$content = $content.Replace('__HOOK_COMMAND__', $command).Replace('__WINDOWS_HOOK_COMMAND__', $command).Replace('__HOOK_SCRIPT__', $script).Replace('__WINDOWS_HOOK_SCRIPT__', $script).Replace('__STATUSLINE_COMMAND__', $command).Replace('__STATUSLINE_SCRIPT__', $statusLineScript)
|
$compactScript = if ($platform -eq 'windows') { 'Record-Compact.ps1' } else { 'record-compact.sh' }
|
||||||
|
$pointerScript = if ($platform -eq 'windows') { 'Show-SessionStatePointer.ps1' } else { 'show-session-state-pointer.sh' }
|
||||||
|
$content = $content.Replace('__HOOK_COMMAND__', $command).Replace('__WINDOWS_HOOK_COMMAND__', $command).Replace('__HOOK_SCRIPT__', $script).Replace('__WINDOWS_HOOK_SCRIPT__', $script).Replace('__COMPACT_SCRIPT__', $compactScript).Replace('__SESSION_POINTER_SCRIPT__', $pointerScript).Replace('__STATUSLINE_COMMAND__', $command).Replace('__STATUSLINE_SCRIPT__', $statusLineScript)
|
||||||
Set-Content -LiteralPath $path -Value $content -Encoding UTF8
|
Set-Content -LiteralPath $path -Value $content -Encoding UTF8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,10 +188,14 @@ for client in codex claude; do
|
|||||||
command=bash
|
command=bash
|
||||||
script=flashbang.sh
|
script=flashbang.sh
|
||||||
statusline_script=statusline.sh
|
statusline_script=statusline.sh
|
||||||
|
compact_script=record-compact.sh
|
||||||
|
pointer_script=show-session-state-pointer.sh
|
||||||
if [ "$platform" = windows ]; then
|
if [ "$platform" = windows ]; then
|
||||||
command='powershell -NoProfile -ExecutionPolicy Bypass -File'
|
command='powershell -NoProfile -ExecutionPolicy Bypass -File'
|
||||||
script=flashbang.ps1
|
script=flashbang.ps1
|
||||||
statusline_script=statusline.ps1
|
statusline_script=statusline.ps1
|
||||||
|
compact_script=Record-Compact.ps1
|
||||||
|
pointer_script=Show-SessionStatePointer.ps1
|
||||||
fi
|
fi
|
||||||
path="$output/$client-$platform/$file"
|
path="$output/$client-$platform/$file"
|
||||||
content=$(<"$path")
|
content=$(<"$path")
|
||||||
@@ -199,6 +203,8 @@ for client in codex claude; do
|
|||||||
content=${content//__WINDOWS_HOOK_COMMAND__/$command}
|
content=${content//__WINDOWS_HOOK_COMMAND__/$command}
|
||||||
content=${content//__HOOK_SCRIPT__/$script}
|
content=${content//__HOOK_SCRIPT__/$script}
|
||||||
content=${content//__WINDOWS_HOOK_SCRIPT__/$script}
|
content=${content//__WINDOWS_HOOK_SCRIPT__/$script}
|
||||||
|
content=${content//__COMPACT_SCRIPT__/$compact_script}
|
||||||
|
content=${content//__SESSION_POINTER_SCRIPT__/$pointer_script}
|
||||||
content=${content//__STATUSLINE_COMMAND__/$command}
|
content=${content//__STATUSLINE_COMMAND__/$command}
|
||||||
content=${content//__STATUSLINE_SCRIPT__/$statusline_script}
|
content=${content//__STATUSLINE_SCRIPT__/$statusline_script}
|
||||||
printf '%s\n' "$content" > "$path"
|
printf '%s\n' "$content" > "$path"
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
param()
|
||||||
|
$root = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
|
||||||
|
$stateDir = Join-Path $root '.ai-session'
|
||||||
|
New-Item $stateDir -ItemType Directory -Force | Out-Null
|
||||||
|
('{"event":"compact","timestamp":"' + (Get-Date).ToUniversalTime().ToString('o') + '"}') | Add-Content (Join-Path $stateDir 'telemetry.jsonl')
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
param()
|
||||||
|
$root = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
|
||||||
|
if (Test-Path (Join-Path $root '.ai-session/state.json')) { Write-Output 'Task state is available in .ai-session/state.json; read it only if needed.' }
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||||
|
mkdir -p "$root/.ai-session"
|
||||||
|
printf '{"event":"compact","timestamp":"%s"}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$root/.ai-session/telemetry.jsonl"
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||||
|
[ -f "$root/.ai-session/state.json" ] && printf 'Task state is available in .ai-session/state.json; read it only if needed.\n'
|
||||||
Reference in new issue
Block a user