-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
576 lines (504 loc) · 25.3 KB
/
Copy pathinstall.ps1
File metadata and controls
576 lines (504 loc) · 25.3 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
param(
[ValidateSet("mixed", "maximum")]
[string]$ModelProfile = "maximum",
[ValidateSet("fable-high", "opus-4.8-xhigh")]
[string]$CrossModelReviewer = "fable-high"
)
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$minimumGpt56CodexVersion = [version]"0.144.0"
$touchedFiles = [System.Collections.Generic.List[string]]::new()
if (-not $PSBoundParameters.ContainsKey("CrossModelReviewer")) {
foreach ($reviewerSource in @(
@{ Path = ".codex-sdlc\manifest.json"; Parent = "model_profile" },
@{ Path = ".codex-sdlc\model-profile.json"; Parent = "policy" }
)) {
if (-not (Test-Path -LiteralPath $reviewerSource.Path)) { continue }
$reviewerDocument = Get-Content -LiteralPath $reviewerSource.Path -Raw | ConvertFrom-Json
$reviewerParent = $reviewerDocument.($reviewerSource.Parent)
if ($null -eq $reviewerParent) { continue }
$reviewerProperty = $reviewerParent.PSObject.Properties["cross_model_reviewer"]
if ($reviewerProperty -and $reviewerProperty.Value) {
$CrossModelReviewer = [string]$reviewerProperty.Value
break
}
}
}
function Add-TouchedFile {
param([string]$Path)
if (-not $script:touchedFiles.Contains($Path)) {
$script:touchedFiles.Add($Path)
}
}
function Assert-Gpt56CodexVersion {
$codexExecutable = if ($env:CODEX_SDLC_CODEX_BIN) { $env:CODEX_SDLC_CODEX_BIN } else { "codex" }
$codexCommand = Get-Command $codexExecutable -CommandType Application -ErrorAction SilentlyContinue
if ($null -eq $codexCommand) {
throw "GPT-5.6 profiles require Codex CLI $minimumGpt56CodexVersion or newer (Codex CLI is not installed or is unavailable: $codexExecutable).`nUpdate with: npm install -g @openai/codex@latest"
}
try {
$versionOutput = @(& $codexCommand.Source --version 2>&1)
$versionStatus = $LASTEXITCODE
} catch {
throw "GPT-5.6 profiles require Codex CLI $minimumGpt56CodexVersion or newer (the configured Codex binary could not report its version: $codexExecutable).`nUpdate with: npm install -g @openai/codex@latest"
}
if ($versionStatus -ne 0) {
throw "GPT-5.6 profiles require Codex CLI $minimumGpt56CodexVersion or newer (the configured Codex binary could not report its version: $codexExecutable).`nUpdate with: npm install -g @openai/codex@latest"
}
$versionMatch = [regex]::Match(($versionOutput -join "`n"), '(?im)^\s*(?:OpenAI\s+)?Codex(?:-CLI)?\s+v?(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?<prerelease>-[0-9A-Za-z.-]+)?(?:\s|$)')
$parsedVersion = if ($versionMatch.Success) {
[version]("{0}.{1}.{2}" -f $versionMatch.Groups["major"].Value, $versionMatch.Groups["minor"].Value, $versionMatch.Groups["patch"].Value)
} else {
$null
}
$isMinimumPrerelease = $null -ne $parsedVersion -and $parsedVersion -eq $minimumGpt56CodexVersion -and $versionMatch.Groups["prerelease"].Success
if ($null -eq $parsedVersion -or $parsedVersion -lt $minimumGpt56CodexVersion -or $isMinimumPrerelease) {
$foundVersion = if ($versionMatch.Success) {
$versionMatch.Groups["major"].Value + "." + $versionMatch.Groups["minor"].Value + "." + $versionMatch.Groups["patch"].Value + $versionMatch.Groups["prerelease"].Value
} else {
"an unparseable version"
}
throw "GPT-5.6 profiles require Codex CLI $minimumGpt56CodexVersion or newer (found $foundVersion).`nUpdate with: npm install -g @openai/codex@latest"
}
}
function Install-AgentsBaseline {
param(
[string]$Source,
[ValidateSet("mixed", "maximum")]
[string]$Profile
)
$reasoningBaseline = if ($Profile -eq "mixed") { "medium" } else { "high" }
$content = Get-Content -LiteralPath $Source -Raw
$content = $content.Replace("{{MODEL_PROFILE}}", $Profile).Replace("{{REASONING_BASELINE}}", $reasoningBaseline)
if (Test-Path -LiteralPath "AGENTS.md") {
if ($env:CODEX_SDLC_SETUP_GENERATED_AGENTS -eq "true") {
Write-Host "AGENTS.md generated earlier in this setup - keeping it"
} elseif ((Get-Content -LiteralPath "AGENTS.md" -Raw) -ceq $content) {
Write-Host "AGENTS.md already matches the wizard baseline - keeping it"
} elseif (Test-AgentsManifestMatch -Path "AGENTS.md") {
Write-Host "AGENTS.md is wizard-managed - keeping it; profile guidance will be refreshed if needed"
} else {
Write-Host "AGENTS.md is user-owned or customized - preserving it"
}
return
}
Set-Content -LiteralPath "AGENTS.md" -Value $content -NoNewline
Add-TouchedFile -Path "AGENTS.md"
Write-Host "Created AGENTS.md"
}
function Test-AgentsManifestMatch {
param([string]$Path)
$manifestPath = ".codex-sdlc\manifest.json"
if (-not (Test-Path -LiteralPath $manifestPath)) {
return $false
}
try {
$manifest = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Json
$expectedProperty = $manifest.generated_files.PSObject.Properties[$Path]
if (-not $expectedProperty -or -not $expectedProperty.Value) {
return $false
}
$expected = [string]$expectedProperty.Value
$hashHelper = Join-Path $PSScriptRoot "lib\managed-file-hash.cjs"
$actual = & node $hashHelper hash $Path
if ($LASTEXITCODE -ne 0) {
return $false
}
return $actual.Trim() -eq $expected
} catch {
return $false
}
}
function Copy-IfMissing {
param(
[string]$Source,
[string]$Destination,
[string]$Label
)
if (-not (Test-Path -LiteralPath $Destination)) {
Copy-Item -LiteralPath $Source -Destination $Destination
Add-TouchedFile -Path $Destination
Write-Host "Created $Label"
} else {
Write-Host "$Label already exists - skipping (review manually)"
}
}
function Install-RepoSkill {
param(
[string]$SourceRoot,
[string]$Name
)
$repoSkillSource = Join-Path $SourceRoot ".agents\skills\$Name\SKILL.md"
$repoSkillTarget = ".agents\skills\$Name\SKILL.md"
if (-not (Test-Path -LiteralPath $repoSkillSource -PathType Leaf)) {
throw "Expected repo skill is missing: .agents/skills/$Name/SKILL.md"
}
if (Test-Path -LiteralPath $repoSkillTarget) {
Write-Host "$repoSkillTarget already exists - skipping (review manually)"
return
}
New-Item -ItemType Directory -Path (Split-Path -Parent $repoSkillTarget) -Force | Out-Null
Copy-Item -LiteralPath $repoSkillSource -Destination $repoSkillTarget
Add-TouchedFile -Path ".agents/skills/$Name/SKILL.md"
Write-Host "Installed $repoSkillTarget"
}
function Test-WizardManagedSkill {
param(
[string]$SourceSkillPath,
[string]$InstalledSkillPath
)
if (-not (Test-Path -LiteralPath $SourceSkillPath -PathType Container) -or
-not (Test-Path -LiteralPath $InstalledSkillPath -PathType Container)) {
return $false
}
$sourceFiles = @(Get-ChildItem -LiteralPath $SourceSkillPath -File -Recurse)
$installedFiles = @(Get-ChildItem -LiteralPath $InstalledSkillPath -File -Recurse)
if ($sourceFiles.Count -ne $installedFiles.Count) {
return $false
}
foreach ($sourceFile in $sourceFiles) {
$relativePath = $sourceFile.FullName.Substring($SourceSkillPath.Length).TrimStart([char[]]@('\', '/'))
$installedRelativePath = if ($relativePath -eq "SKILL.template.md") { "SKILL.md" } else { $relativePath }
$installedFile = Join-Path $InstalledSkillPath $installedRelativePath
if (-not (Test-Path -LiteralPath $installedFile -PathType Leaf)) {
return $false
}
$sourceHash = (Get-FileHash -LiteralPath $sourceFile.FullName -Algorithm SHA256).Hash
$installedHash = (Get-FileHash -LiteralPath $installedFile -Algorithm SHA256).Hash
if ($sourceHash -ne $installedHash) {
return $false
}
}
return $true
}
function Install-Skills {
param(
[string]$SourceRoot
)
$codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $HOME ".codex" }
$skillsRoot = Join-Path $codexHome "skills"
$skillsBackupRoot = Join-Path $codexHome "backups\skills"
$sourceSkillsRoot = Join-Path $SourceRoot "skill-sources"
$globalHelperSkills = @("feedback", "setup-wizard", "update-wizard")
New-Item -ItemType Directory -Path $skillsRoot -Force | Out-Null
New-Item -ItemType Directory -Path $skillsBackupRoot -Force | Out-Null
$globalHelperSkills | ForEach-Object {
$skillName = $_
$sourceSkillPath = Join-Path $sourceSkillsRoot $skillName
$sourceTemplatePath = Join-Path $sourceSkillPath "SKILL.template.md"
$installedSkillPath = Join-Path $skillsRoot $skillName
$installedTemplatePath = Join-Path $installedSkillPath "SKILL.template.md"
$installedSkillFile = Join-Path $installedSkillPath "SKILL.md"
if (-not (Test-Path -LiteralPath $sourceTemplatePath -PathType Leaf)) {
throw "Expected wizard skill template is missing: skill-sources/$skillName/SKILL.template.md"
}
if (Test-Path -LiteralPath $installedSkillPath) {
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
$backupPath = Join-Path $skillsBackupRoot "$skillName.bak.$timestamp"
Copy-Item -LiteralPath $installedSkillPath -Destination $backupPath -Recurse
Remove-Item -LiteralPath $installedSkillPath -Recurse -Force
Write-Host "Backed up existing Codex skill: $skillName"
}
Copy-Item -LiteralPath $sourceSkillPath -Destination $skillsRoot -Recurse
Move-Item -LiteralPath $installedTemplatePath -Destination $installedSkillFile
Write-Host "Installed Codex skill: $skillName"
}
$collidingSdlcSourcePath = Join-Path $sourceSkillsRoot "sdlc"
$collidingSdlcPath = Join-Path $skillsRoot "sdlc"
if (Test-Path -LiteralPath $collidingSdlcPath -PathType Container) {
if (Test-WizardManagedSkill -SourceSkillPath $collidingSdlcSourcePath -InstalledSkillPath $collidingSdlcPath) {
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
$backupPath = Join-Path $skillsBackupRoot "sdlc.bak.$timestamp"
Copy-Item -LiteralPath $collidingSdlcPath -Destination $backupPath -Recurse
Remove-Item -LiteralPath $collidingSdlcPath -Recurse -Force
Write-Host "Removed wizard-managed global Codex skill: sdlc (repo-scoped .agents/skills/sdlc is canonical)"
} else {
Write-Host "Preserved user-owned global Codex skill: sdlc"
}
}
$legacySkillPath = Join-Path $skillsRoot "codex-sdlc"
if (Test-Path -LiteralPath $legacySkillPath) {
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
$backupPath = Join-Path $skillsBackupRoot "codex-sdlc.bak.$timestamp"
Copy-Item -LiteralPath $legacySkillPath -Destination $backupPath -Recurse
Remove-Item -LiteralPath $legacySkillPath -Recurse -Force
Write-Host "Removed legacy Codex skill: codex-sdlc (canonical: sdlc)"
}
}
function Merge-CodexModelConfig {
param(
[string]$ConfigPath,
[ValidateSet("mixed", "maximum")]
[string]$Profile
)
$profileConfig = switch ($Profile) {
"mixed" {
@{
model = "gpt-5.6-terra"
effort = "medium"
review = "gpt-5.6-sol"
}
}
"maximum" {
@{
model = "gpt-5.6-sol"
effort = "high"
review = "gpt-5.6-sol"
}
}
}
$configDir = Split-Path -Parent $ConfigPath
New-Item -ItemType Directory -Path $configDir -Force | Out-Null
$content = if (Test-Path -LiteralPath $ConfigPath) {
Get-Content -LiteralPath $ConfigPath -Raw
} else {
""
}
$lines = @()
if ($content.Length -gt 0) {
$normalized = ($content -replace "`r`n", "`n") -replace "`r", "`n"
$lines = @($normalized -split "`n")
if ($lines.Count -gt 0 -and $lines[$lines.Count - 1] -eq "") {
if ($lines.Count -eq 1) {
$lines = @()
} else {
$lines = @($lines[0..($lines.Count - 2)])
}
}
}
$stripped = New-Object System.Collections.Generic.List[string]
$tableName = $null
foreach ($line in $lines) {
if ($line -match '^\s*\[([^\]]+)\]\s*(#.*)?$') {
$tableName = $Matches[1].Trim()
$stripped.Add($line)
continue
}
if ($null -eq $tableName -and $line -match '^\s*(model|model_reasoning_effort|review_model)\s*=') {
continue
}
$stripped.Add($line)
}
$profileLines = New-Object System.Collections.Generic.List[string]
$profileLines.Add("model = `"$($profileConfig.model)`"")
$profileLines.Add("model_reasoning_effort = `"$($profileConfig.effort)`"")
if ($profileConfig.review) {
$profileLines.Add("review_model = `"$($profileConfig.review)`"")
}
$firstTableIndex = -1
for ($i = 0; $i -lt $stripped.Count; $i++) {
if ($stripped[$i] -match '^\s*\[[^\]]+\]\s*(#.*)?$') {
$firstTableIndex = $i
break
}
}
$withProfile = New-Object System.Collections.Generic.List[string]
if ($firstTableIndex -eq -1) {
foreach ($line in $stripped) { $withProfile.Add($line) }
if ($withProfile.Count -gt 0 -and $withProfile[$withProfile.Count - 1] -ne "") {
$withProfile.Add("")
}
foreach ($line in $profileLines) { $withProfile.Add($line) }
} else {
for ($i = 0; $i -lt $firstTableIndex; $i++) {
$withProfile.Add($stripped[$i])
}
if ($withProfile.Count -gt 0 -and $withProfile[$withProfile.Count - 1] -ne "") {
$withProfile.Add("")
}
foreach ($line in $profileLines) { $withProfile.Add($line) }
$withProfile.Add("")
for ($i = $firstTableIndex; $i -lt $stripped.Count; $i++) {
$withProfile.Add($stripped[$i])
}
}
$output = New-Object System.Collections.Generic.List[string]
$inFeatures = $false
$sawFeatures = $false
$insertedHooks = $false
foreach ($line in $withProfile) {
if ($line -match '^\s*\[([^\]]+)\]\s*(#.*)?$') {
if ($inFeatures -and -not $insertedHooks) {
$output.Add("hooks = true")
$insertedHooks = $true
}
$inFeatures = $Matches[1].Trim() -eq "features"
if ($inFeatures) {
$sawFeatures = $true
$insertedHooks = $false
}
$output.Add($line)
if ($inFeatures) {
$output.Add("hooks = true")
$insertedHooks = $true
}
continue
}
if ($inFeatures -and $line -match '^\s*(codex_hooks|hooks)\s*=') {
continue
}
$output.Add($line)
}
if ($inFeatures -and -not $insertedHooks) {
$output.Add("hooks = true")
}
if (-not $sawFeatures) {
if ($output.Count -gt 0 -and $output[$output.Count - 1] -ne "") {
$output.Add("")
}
$output.Add("[features]")
$output.Add("hooks = true")
}
Set-Content -LiteralPath $ConfigPath -Value (($output -join "`r`n") + "`r`n") -NoNewline
}
function Write-ModelProfile {
param(
[ValidateSet("mixed", "maximum")]
[string]$Profile,
[ValidateSet("fable-high", "opus-4.8-xhigh")]
[string]$Reviewer
)
New-Item -ItemType Directory -Path ".codex-sdlc" -Force | Out-Null
$metadata = [ordered]@{
schema_version = 2
selected_profile = $Profile
profiles = [ordered]@{
mixed = [ordered]@{
main_model = "gpt-5.6-terra"
main_reasoning = "medium"
review_model = "gpt-5.6-sol"
review_reasoning = "high"
review_effort_source = "explicit command override"
review_command = "codex -c 'model_reasoning_effort=`"high`"' review"
tradeoff = "Experimental explicit opt-in efficiency profile for measured, bounded work; not the normal quality-first driver."
}
maximum = [ordered]@{
main_model = "gpt-5.6-sol"
main_reasoning = "high"
review_model = "gpt-5.6-sol"
review_reasoning = "high"
review_effort_source = "profile baseline"
review_command = "codex review"
tradeoff = "Default quality-first profile with Sol high as the standing root driver."
}
}
policy = [ordered]@{
high_confidence_threshold_percent = 95
default_profile = "maximum"
default_driver = "gpt-5.6-sol"
default_reasoning = "high"
cross_model_reviewer = $Reviewer
low_confidence_rule = "Research more first. If confidence stays below 95%, escalate the difficult slice or review to xhigh."
reasoning_effort_rule = "Use Sol high as the normal root driver for meaningful SDLC work. Escalate only difficult or high-risk slices to xhigh."
mixed_profile_rule = "Mixed is experimental and requires explicit opt-in. Preserve an existing explicit selection, but do not select it automatically."
review_effort_rule = "review_model selects the review model only. Mixed reviews must explicitly override model_reasoning_effort to high."
lightweight_rule = "Use Terra or Luna only for bounded support work when the task and verification boundary make the tradeoff explicit."
escalation_rule = "Max is single-task reasoning; Ultra is subagent-backed parallel work. Most tasks do not need either, and neither is a default wizard profile."
}
}
$metadata | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath ".codex-sdlc\model-profile.json"
Add-TouchedFile -Path ".codex-sdlc/model-profile.json"
Write-Host "Wrote .codex-sdlc/model-profile.json ($Profile)"
}
Assert-Gpt56CodexVersion
$hooksPath = ".codex\hooks.json"
$hooksTemplate = Join-Path $scriptDir ".codex\windows-hooks.json"
$hooksMergeStatus = (& node (Join-Path $scriptDir "lib\merge-hooks.cjs") --status $hooksPath $hooksTemplate | Out-String).Trim()
if ($LASTEXITCODE -ne 0) {
throw "Failed to inspect .codex/hooks.json"
}
if ($hooksMergeStatus -eq "target-broken") {
throw ".codex/hooks.json must contain a valid hooks object before baseline installation"
}
Write-Host "Installing SDLC Wizard for Codex CLI..."
$gitAttributesStatus = (& node (Join-Path $scriptDir "lib\merge-gitattributes.cjs") --status ".gitattributes").Trim()
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& node (Join-Path $scriptDir "lib\merge-gitattributes.cjs") ".gitattributes"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
if ($gitAttributesStatus -eq "merge") {
Write-Host "Merged .gitattributes hook shell LF rule"
}
Install-AgentsBaseline -Source (Join-Path $scriptDir "templates\AGENTS.baseline.md") -Profile $ModelProfile
Copy-IfMissing -Source (Join-Path $scriptDir "SDLC-LOOP.md") -Destination "SDLC-LOOP.md" -Label "SDLC-LOOP.md"
Copy-IfMissing -Source (Join-Path $scriptDir "START-SDLC.md") -Destination "START-SDLC.md" -Label "START-SDLC.md"
Copy-IfMissing -Source (Join-Path $scriptDir "PROVE-IT.md") -Destination "PROVE-IT.md" -Label "PROVE-IT.md"
Copy-IfMissing -Source (Join-Path $scriptDir "start-sdlc.ps1") -Destination "start-sdlc.ps1" -Label "start-sdlc.ps1"
Install-Skills -SourceRoot $scriptDir
Install-RepoSkill -SourceRoot $scriptDir -Name "sdlc"
New-Item -ItemType Directory -Path ".codex" -Force | Out-Null
New-Item -ItemType Directory -Path ".codex\hooks" -Force | Out-Null
& node (Join-Path $scriptDir "lib\remove-retired-files.cjs")
if ($LASTEXITCODE -ne 0) {
throw "Failed to inspect retired wizard files"
}
$configPath = ".codex\config.toml"
Merge-CodexModelConfig -ConfigPath $configPath -Profile $ModelProfile
Add-TouchedFile -Path ".codex/config.toml"
Write-Host "Merged repo-local Codex config for model profile '$ModelProfile'"
Write-ModelProfile -Profile $ModelProfile -Reviewer $CrossModelReviewer
if (Test-Path -LiteralPath $hooksPath) {
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
Copy-Item -LiteralPath $hooksPath -Destination ".codex\hooks.json.bak.$timestamp"
Write-Host "Backed up existing hooks.json"
}
& node (Join-Path $scriptDir "lib\merge-hooks.cjs") $hooksPath $hooksTemplate
if ($LASTEXITCODE -ne 0) {
throw "Failed to merge .codex/hooks.json"
}
Copy-Item -LiteralPath (Join-Path $scriptDir ".codex\hooks\git-guard.cjs") -Destination ".codex\hooks\git-guard.cjs"
Copy-Item -LiteralPath (Join-Path $scriptDir ".codex\hooks\fable-review.cjs") -Destination ".codex\hooks\fable-review.cjs"
Copy-Item -LiteralPath (Join-Path $scriptDir ".codex\hooks\dual-review.cjs") -Destination ".codex\hooks\dual-review.cjs"
Copy-Item -LiteralPath (Join-Path $scriptDir ".codex\hooks\session-start.cjs") -Destination ".codex\hooks\session-start.cjs"
Copy-Item -LiteralPath (Join-Path $scriptDir ".codex\hooks\compact-guard.cjs") -Destination ".codex\hooks\compact-guard.cjs"
Copy-Item -LiteralPath (Join-Path $scriptDir ".codex\hooks\git-guard.ps1") -Destination ".codex\hooks\git-guard.ps1"
Copy-Item -LiteralPath (Join-Path $scriptDir ".codex\hooks\session-start.ps1") -Destination ".codex\hooks\session-start.ps1"
Remove-Item -LiteralPath ".codex\hooks\git-guard.js", ".codex\hooks\session-start.js" -ErrorAction SilentlyContinue
Add-TouchedFile -Path ".codex/hooks/git-guard.js"
Add-TouchedFile -Path ".codex/hooks/session-start.js"
foreach ($touchedHook in @(
".codex/hooks/git-guard.cjs",
".codex/hooks/fable-review.cjs",
".codex/hooks/dual-review.cjs",
".codex/hooks/session-start.cjs",
".codex/hooks/compact-guard.cjs",
".codex/hooks/git-guard.ps1",
".codex/hooks/session-start.ps1"
)) {
Add-TouchedFile -Path $touchedHook
}
if ($hooksMergeStatus -eq "merge") {
Add-TouchedFile -Path ".codex/hooks.json"
}
$touchedFileArgs = $touchedFiles.ToArray()
& node (Join-Path $scriptDir "lib\refresh-manifest-hashes.cjs") ".codex-sdlc\manifest.json" @touchedFileArgs
if ($LASTEXITCODE -ne 0) {
throw "Failed to refresh .codex-sdlc/manifest.json hashes"
}
Write-Host "Installed .codex/hooks.json (universal Node hooks)"
Write-Host "Installed Node and PowerShell hook scripts"
Write-Host ""
Write-Host "SDLC Wizard for Codex installed."
$startModel = if ($ModelProfile -eq "maximum") { "gpt-5.6-sol" } else { "gpt-5.6-terra" }
$startReasoning = if ($ModelProfile -eq "maximum") { "high" } else { "medium" }
Write-Host "Recommended start: codex -m $startModel -c 'model_reasoning_effort=`"$startReasoning`"'"
Write-Host "Use plain 'codex' instead if you want to rely on trusted repo-local config."
Write-Host "Fresh-session note: if you ran this from inside an existing Codex session, exit and reopen Codex in this repo so repo-local config, hooks, and skills load."
Write-Host "Hook review note: if Codex says hooks need review, open /hooks after restart and review pending repo hooks before relying on enforcement."
Write-Host "Start new with selected profile: codex -m $startModel -c 'model_reasoning_effort=`"$startReasoning`"'"
Write-Host "Resume with selected profile: codex resume -m $startModel -c 'model_reasoning_effort=`"$startReasoning`"'"
Write-Host "If resume warns it came back with a different model, resume explicitly with: codex resume -m gpt-5.6-sol -c 'model_reasoning_effort=`"high`"'"
Write-Host "If you normally use yolo-style sessions, use the canonical full-trust Codex flag:"
Write-Host " codex --dangerously-bypass-approvals-and-sandbox -m $startModel -c 'model_reasoning_effort=`"$startReasoning`"'"
Write-Host " codex resume --dangerously-bypass-approvals-and-sandbox -m $startModel -c 'model_reasoning_effort=`"$startReasoning`"'"
Write-Host "Codex may accept --yolo as shorthand; this wizard prints the canonical full-trust flag."
Write-Host "Full-auto is not full-trust: full-trust bypasses sandbox and approval prompts."
Write-Host "Full-trust warning: only use that variant in repos you fully trust."
Write-Host "Recommended: use full access during setup, environment repair, and auth-heavy workflows."
Write-Host "Model profile policy: Sol high is the default normal driver for meaningful SDLC work."
Write-Host "Mixed is an experimental explicit opt-in using Terra medium plus Sol review for measured speed, latency, or token-efficiency trials; invoke review with an explicit high effort override."
Write-Host "Reasoning effort policy: keep Sol high as the standing root driver; escalate only difficult or high-risk slices to xhigh."
Write-Host "Escalation policy: Max is single-task reasoning; Ultra is subagent-backed parallel work. Most tasks do not need either, and neither is a default wizard profile."
Write-Host "Wrote repo-local .codex/config.toml model keys for this profile; mixed is experimental wizard policy, not a native Codex mode."
Write-Host "Codex loads project config only after the repo is trusted, and trusted project config overrides your user-level ~/.codex/config.toml."
Write-Host "Codex does not have a native /sdlc command. Use `$sdlc plus START-SDLC.md and SDLC-LOOP.md as the honest equivalent."
Write-Host "After restart, use `$sdlc as the public workflow. Setup/update/feedback helpers are installed for Codex support, not as extra repo-scoped lifecycle entrypoints."