-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.ps1
More file actions
125 lines (115 loc) · 5.01 KB
/
setup.ps1
File metadata and controls
125 lines (115 loc) · 5.01 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
# CEX Setup -- run once after cloning, then 'cex' works from any terminal
#
# First time:
# git clone https://github.com/anthropics/cex.git
# cd cex
# .\setup.ps1
# # restart terminal
# cex
#
# Flags:
# --uninstall Remove cex from profile and env var
#
# After setup, these commands are available from any directory:
# cex N07 Orchestrator (main entry point)
# cex-n01 N01 Intelligence (research, analysis)
# cex-n02 N02 Marketing (copy, brand, campaigns)
# cex-n03 N03 Engineering (build artifacts)
# cex-n04 N04 Knowledge (docs, RAG, indexing)
# cex-n05 N05 Operations (test, deploy, CI/CD)
# cex-n06 N06 Commercial (pricing, sales, monetization)
#
# Run multiple nuclei in parallel by opening separate terminals.
param([switch]$Uninstall)
$cexHome = $PSScriptRoot
$markerStart = "# --- CEX-AUTO-SETUP-BEGIN ---"
$markerEnd = "# --- CEX-AUTO-SETUP-END ---"
$profilePath = $PROFILE.CurrentUserAllHosts # works across PS 5.1 + PS 7
# --- Uninstall mode ---
if ($Uninstall) {
[Environment]::SetEnvironmentVariable("CEX_HOME", $null, "User")
if (Test-Path $profilePath) {
$lines = Get-Content $profilePath
$inBlock = $false
$clean = @()
foreach ($line in $lines) {
if ($line -match "CEX-AUTO-SETUP-BEGIN") { $inBlock = $true; continue }
if ($line -match "CEX-AUTO-SETUP-END") { $inBlock = $false; continue }
if (-not $inBlock) { $clean += $line }
}
$clean | Set-Content $profilePath -Encoding utf8
}
Write-Host "[OK] CEX removed from profile and environment." -ForegroundColor Green
Write-Host " Restart your terminal to apply." -ForegroundColor DarkGray
return
}
# --- Install mode ---
# 1. Set persistent env var (survives reboots)
$existing = [Environment]::GetEnvironmentVariable("CEX_HOME", "User")
if ($existing -and $existing -ne $cexHome) {
Write-Host "[WARN] CEX_HOME was: $existing" -ForegroundColor Yellow
Write-Host " Updating to: $cexHome" -ForegroundColor Yellow
}
[Environment]::SetEnvironmentVariable("CEX_HOME", $cexHome, "User")
$env:CEX_HOME = $cexHome
# 2. Ensure $PROFILE exists
if (-not (Test-Path $profilePath)) {
$profileDir = Split-Path $profilePath
if (-not (Test-Path $profileDir)) {
New-Item -Path $profileDir -ItemType Directory -Force | Out-Null
}
New-Item -Path $profilePath -ItemType File -Force | Out-Null
Write-Host "[OK] Created profile: $profilePath" -ForegroundColor Green
}
# 3. Remove old block if present (idempotent re-run)
$profileContent = Get-Content $profilePath -Raw -EA SilentlyContinue
if ($profileContent -and $profileContent.Contains("CEX-AUTO-SETUP")) {
$lines = Get-Content $profilePath
$inBlock = $false
$clean = @()
foreach ($line in $lines) {
if ($line -match "CEX-AUTO-SETUP-BEGIN|CEX-AUTO-SETUP ---$") { $inBlock = $true; continue }
if ($line -match "CEX-AUTO-SETUP-END|CEX-AUTO-SETUP ---$") {
if ($inBlock) { $inBlock = $false; continue }
}
if (-not $inBlock) { $clean += $line }
}
$clean | Set-Content $profilePath -Encoding utf8
}
# 4. Write fresh setup block
$block = @"
$markerStart
`$env:CEX_HOME = "$cexHome"
function cex { & "`$env:CEX_HOME\boot\cex.ps1" }
function cex-n01 { & "`$env:CEX_HOME\boot\n01.ps1" }
function cex-n02 { & "`$env:CEX_HOME\boot\n02.ps1" }
function cex-n03 { & "`$env:CEX_HOME\boot\n03.ps1" }
function cex-n04 { & "`$env:CEX_HOME\boot\n04.ps1" }
function cex-n05 { & "`$env:CEX_HOME\boot\n05.ps1" }
function cex-n06 { & "`$env:CEX_HOME\boot\n06.ps1" }
$markerEnd
"@
Add-Content -Path $profilePath -Value $block -Encoding utf8
Write-Host "[OK] CEX commands added to profile." -ForegroundColor Green
# 5. Summary
Write-Host ""
Write-Host " [OK] Setup complete." -ForegroundColor Green
Write-Host ""
Write-Host " CEX_HOME = $cexHome" -ForegroundColor Cyan
Write-Host ""
Write-Host " Next steps:" -ForegroundColor White
Write-Host " 1. Close this terminal" -ForegroundColor White
Write-Host " 2. Open a new PowerShell" -ForegroundColor White
Write-Host " 3. Type: cex" -ForegroundColor White
Write-Host ""
Write-Host " All commands (work from any directory):" -ForegroundColor White
Write-Host " cex N07 Orchestrator (start here)" -ForegroundColor Cyan
Write-Host " cex-n01 N01 Intelligence (research, analysis)" -ForegroundColor DarkCyan
Write-Host " cex-n02 N02 Marketing (copy, brand, campaigns)" -ForegroundColor DarkCyan
Write-Host " cex-n03 N03 Engineering (build artifacts)" -ForegroundColor DarkCyan
Write-Host " cex-n04 N04 Knowledge (docs, RAG, indexing)" -ForegroundColor DarkCyan
Write-Host " cex-n05 N05 Operations (test, deploy, CI/CD)" -ForegroundColor DarkCyan
Write-Host " cex-n06 N06 Commercial (pricing, sales)" -ForegroundColor DarkCyan
Write-Host ""
Write-Host " Parallel mode: open multiple terminals, run different nuclei." -ForegroundColor DarkGray
Write-Host " Uninstall: cd `"$cexHome`"; .\setup.ps1 -Uninstall" -ForegroundColor DarkGray