-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodex-context.ps1
More file actions
80 lines (66 loc) · 2.22 KB
/
Copy pathcodex-context.ps1
File metadata and controls
80 lines (66 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<#
.SYNOPSIS
Build locale del contesto per Codex su Windows.
.DESCRIPTION
Wrapper operativo per `agent-context build` in local mode.
Richiede un workspace root esplicito e prova a usare prima `.venv314`,
poi `.venv`, se presenti nella repo.
#>
param(
[Parameter(Mandatory = $true)]
[string]$WorkspaceRoot,
[string]$OutDir = "generated",
[string]$ConfigPath = "dataciviclab.config.yml",
[string]$VenvName = ""
)
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$resolvedOutDir = Join-Path $repoRoot $OutDir
$resolvedConfig = Join-Path $repoRoot $ConfigPath
$candidateVenvs = @()
if ($VenvName) {
$candidateVenvs += $VenvName
}
$candidateVenvs += @(".venv314", ".venv")
$python = $null
$agentContext = $null
$resolvedVenv = $null
foreach ($candidate in $candidateVenvs | Select-Object -Unique) {
$candidatePython = Join-Path $repoRoot "$candidate\Scripts\python.exe"
$candidateCli = Join-Path $repoRoot "$candidate\Scripts\agent-context.exe"
if ((Test-Path $candidatePython) -and (Test-Path $candidateCli)) {
$python = $candidatePython
$agentContext = $candidateCli
$resolvedVenv = $candidate
break
}
}
if (-not (Test-Path $WorkspaceRoot)) {
throw "Workspace root non trovato: $WorkspaceRoot"
}
if (-not (Test-Path $python)) {
throw "Nessun venv compatibile trovato. Attesi: .venv314 o .venv, oppure passa -VenvName."
}
if (-not (Test-Path $resolvedConfig)) {
throw "Config non trovata: $resolvedConfig"
}
$env:PYTHONIOENCODING = "utf-8"
$env:PYTHONUTF8 = "1"
$env:CURL_CA_BUNDLE = ""
Write-Host "Building agent context for Codex..." -ForegroundColor Cyan
Write-Host " repo: $repoRoot"
Write-Host " venv: $resolvedVenv"
Write-Host " workspace: $WorkspaceRoot"
Write-Host " out: $resolvedOutDir"
& $agentContext build `
--config $resolvedConfig `
--out $resolvedOutDir `
--workspace-root $WorkspaceRoot
if ($LASTEXITCODE -ne 0) {
throw "agent-context build fallito con exit code $LASTEXITCODE"
}
Write-Host ""
Write-Host "Artifacts pronti:" -ForegroundColor Green
Write-Host " $resolvedOutDir\session_bootstrap.md"
Write-Host " $resolvedOutDir\workspace_triage.json"
Write-Host " $resolvedOutDir\topic_index.json"