# Synopsis: Updates active state metadata settings.
# Description: Saves current project, goal, and action parameters to active_state.json.

param(
    [string]$Project = "Active Memory Management",
    [string]$Goal = "Establish session continuity",
    [string]$LastAction = "Generated Set-ActiveMemory and Clear-ActiveMemory skills.",
    [bool]$PendingVerification = $false,
    [string]$Blockers = "None"
)

$BaseDir = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
$ConfigDir = Join-Path $BaseDir "Config"
if (!(Test-Path $ConfigDir)) { New-Item -ItemType Directory -Path $ConfigDir -Force | Out-Null }
$StatePath = Join-Path $ConfigDir "active_state.json"

$State = @{
    timestamp = (Get-Date).ToString("yyyy-MM-ddTHH:mm:ssZ")
    current_project = $Project
    current_goal = $Goal
    last_action = $LastAction
    pending_verification = $PendingVerification
    blockers = $Blockers
}

$State | ConvertTo-Json | Set-Content -Path $StatePath -Force
Write-Output "=== ACTIVE MEMORY UPDATED ==="
Write-Output "State saved to: $StatePath"

