param( [string]$PythonExecutable = "" ) $ErrorActionPreference = "Stop" $scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path $insightsHubRoot = (Resolve-Path (Join-Path $scriptDirectory "..")).Path $copyScript = Join-Path $scriptDirectory "copy_future_map_tagged_files.py" $runtimeDirectory = Join-Path $insightsHubRoot "runtime" $logDirectory = Join-Path $runtimeDirectory "logs" $logFile = Join-Path $logDirectory ("future-map-insights-hub-" + (Get-Date -Format "yyyy-MM-dd") + ".log") if (-not $PythonExecutable) { $pythonCommand = Get-Command python -ErrorAction Stop $PythonExecutable = $pythonCommand.Source } New-Item -ItemType Directory -Path $logDirectory -Force | Out-Null $started = Get-Date -Format "yyyy-MM-dd HH:mm:ss zzz" "[$started] Starting exact-tag Future Map intake copy." | Set-Content -LiteralPath $logFile -Encoding utf8 $pipelineOutput = & $PythonExecutable $copyScript 2>&1 $exitCode = $LASTEXITCODE $pipelineOutput | Add-Content -LiteralPath $logFile -Encoding utf8 $finished = Get-Date -Format "yyyy-MM-dd HH:mm:ss zzz" "[$finished] Finished exact-tag intake copy with exit code $exitCode. Public transformation and AI reasoning remain separate steps." | Add-Content -LiteralPath $logFile -Encoding utf8 if ($exitCode -ne 0) { throw "Future Map exact-tag intake copy failed with exit code $exitCode. See $logFile" }