@ornexus/neocortex 4.66.49 → 4.66.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/release-source.json +1 -1
- package/dist/sbom.cdx.json +1191 -1191
- package/install.js +8 -8
- package/install.ps1 +188 -162
- package/install.sh +1 -1
- package/package.json +2 -2
- package/packages/client/dist/commands/activate.js +6 -7
- package/packages/client/dist/commands/invoke.js +82 -82
- package/packages/client/dist/config/secure-config.d.ts +4 -0
- package/packages/client/dist/config/secure-config.js +6 -6
- package/packages/client/dist/git/git-lifecycle-store.d.ts +3 -1
- package/packages/client/dist/git/git-lifecycle-store.js +8 -8
- package/packages/client/dist/git/story-worktree-manager.d.ts +2 -0
- package/packages/client/dist/git/story-worktree-manager.js +3 -3
- package/packages/client/dist/migrations/project-identity.d.ts +3 -0
- package/packages/client/dist/migrations/project-identity.js +7 -7
- package/packages/client/dist/private-execution/isolated-admission.js +11 -11
- package/packages/client/dist/private-execution/isolated-workspace.js +1 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -5
- package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -3
- package/packages/client/dist/runner/headless/run-yoloop.d.ts +2 -0
- package/packages/client/dist/runner/headless/run-yoloop.js +4 -4
- package/packages/shared/dist/invocation/semantic-gate-remediation.d.ts +45 -0
- package/packages/shared/dist/invocation/semantic-gate-remediation.js +51 -0
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/neocortex.md +1 -1
- package/targets-stubs/antigravity/skill/SKILL.md +1 -1
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex-root.md +2 -2
- package/targets-stubs/claude-code/neocortex-sentinel.md +1 -1
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex.md +2 -2
- package/targets-stubs/codex/AGENTS.md +1 -1
- package/targets-stubs/codex/neocortex.toml +1 -1
- package/targets-stubs/cursor/agent.md +2 -2
- package/targets-stubs/deepseek-harness/SKILL.md +1 -1
- package/targets-stubs/gemini-cli/agent.md +2 -2
- package/targets-stubs/gemini-cli/agents/neocortex.md +2 -2
- package/targets-stubs/grok/SKILL.md +1 -1
- package/targets-stubs/kimi/neocortex.md +1 -1
- package/targets-stubs/lib/managed-config-merge.js +12 -4
- package/targets-stubs/openclaw/SKILL.md +1 -1
- package/targets-stubs/opencode/neocortex-root.md +2 -2
- package/targets-stubs/opencode/neocortex.md +2 -2
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
package/install.ps1
CHANGED
|
@@ -19,7 +19,7 @@ param(
|
|
|
19
19
|
[string]$ServerUrl = ('https://{0}.{1}.{2}' -f 'api','neocortex','sh')
|
|
20
20
|
)
|
|
21
21
|
|
|
22
|
-
$VERSION = "4.66.
|
|
22
|
+
$VERSION = "4.66.51"
|
|
23
23
|
|
|
24
24
|
# =============================================================================
|
|
25
25
|
# CONFIGURACOES
|
|
@@ -63,7 +63,7 @@ if ($Help) {
|
|
|
63
63
|
Write-Host " Uso: npx @ornexus/neocortex [opcoes]"
|
|
64
64
|
Write-Host ""
|
|
65
65
|
Write-Host " Opcoes:" -ForegroundColor DarkGray
|
|
66
|
-
Write-Host " -Yes Modo automatico
|
|
66
|
+
Write-Host " -Yes Modo automatico. Use -Targets para selecionar plataformas." -ForegroundColor Cyan
|
|
67
67
|
Write-Host " -Targets <lista> Plataformas separadas por virgula" -ForegroundColor Cyan
|
|
68
68
|
Write-Host " -CreateProject Instalar estrutura no projeto (opt-in)" -ForegroundColor Cyan
|
|
69
69
|
Write-Host " -SkipProject Instalacao somente global (padrao)" -ForegroundColor Cyan
|
|
@@ -310,25 +310,34 @@ function Get-ManagedManifestPath {
|
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
function Invoke-ManagedPolicy {
|
|
313
|
-
param([string]$BaseDir = $env:USERPROFILE)
|
|
313
|
+
param([string]$BaseDir = $env:USERPROFILE, [switch]$CheckOnly)
|
|
314
314
|
$helper = Get-ManagedConfigHelper
|
|
315
|
-
if (-not $helper) {
|
|
315
|
+
if (-not $helper) {
|
|
316
|
+
Write-Warn "managed-helper-unavailable. Reinstale o pacote npm e confira node.exe."
|
|
317
|
+
return $false
|
|
318
|
+
}
|
|
316
319
|
$configFile = Join-Path $BaseDir ".neocortex\config.json"
|
|
317
320
|
$manifest = Get-ManagedManifestPath -BaseDir $BaseDir
|
|
318
321
|
$arguments = @($helper, "policy", $configFile, $manifest, $BaseDir)
|
|
319
|
-
if ($DryRun) { $arguments += "--dry-run" }
|
|
320
|
-
& node @arguments 2
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
322
|
+
if ($DryRun -or $CheckOnly) { $arguments += "--dry-run" }
|
|
323
|
+
$output = @(& node @arguments 2>&1)
|
|
324
|
+
if ($LASTEXITCODE -eq 0) { return $true }
|
|
325
|
+
$reason = "managed-operation-failed"
|
|
326
|
+
foreach ($line in $output) {
|
|
327
|
+
try {
|
|
328
|
+
$report = $line.ToString() | ConvertFrom-Json -ErrorAction Stop
|
|
329
|
+
if ($report.action -eq "failed" -and $report.reasonCode -match '^managed-[a-z0-9-]{1,75}$') {
|
|
330
|
+
$reason = $report.reasonCode
|
|
331
|
+
break
|
|
332
|
+
}
|
|
333
|
+
} catch { }
|
|
334
|
+
}
|
|
335
|
+
if ($reason -eq "managed-config-access-denied") {
|
|
336
|
+
Write-Warn "$reason. Confira o acesso ao perfil usando a conta que o criou e feche programas que usam config.json."
|
|
337
|
+
} else {
|
|
338
|
+
Write-Warn "$reason. Confira a configuracao do perfil e a politica de aprovacao. Arquivos existentes preservados."
|
|
339
|
+
}
|
|
340
|
+
return $false
|
|
332
341
|
}
|
|
333
342
|
|
|
334
343
|
function Copy-ManagedFile {
|
|
@@ -351,7 +360,7 @@ function Copy-ManagedFile {
|
|
|
351
360
|
# P231.05 AC4: same tier transform as install.sh, applied by the helper before planning.
|
|
352
361
|
# Like install.sh: only an explicit config tier is forwarded (no implicit "free").
|
|
353
362
|
$tierValue = ""
|
|
354
|
-
$tierConfig = Join-Path (Join-Path $
|
|
363
|
+
$tierConfig = Join-Path (Join-Path $env:USERPROFILE ".neocortex") "config.json"
|
|
355
364
|
if (Test-Path $tierConfig -PathType Leaf) {
|
|
356
365
|
try { $tierCfg = Get-Content -Path $tierConfig -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop; if ($tierCfg.tier -is [string]) { $tierValue = $tierCfg.tier } } catch { }
|
|
357
366
|
}
|
|
@@ -550,18 +559,18 @@ function Test-NeocortexUserHome {
|
|
|
550
559
|
function Set-FileAcl {
|
|
551
560
|
param([string]$Path)
|
|
552
561
|
try {
|
|
553
|
-
$
|
|
554
|
-
if (-not $
|
|
555
|
-
& icacls $Path /inheritance:r /grant:r "
|
|
562
|
+
$sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
|
|
563
|
+
if (-not $sid) { return }
|
|
564
|
+
& "$env:SystemRoot\System32\icacls.exe" $Path /inheritance:r /grant:r "*${sid}:(F)" 2>$null | Out-Null
|
|
556
565
|
} catch { }
|
|
557
566
|
}
|
|
558
567
|
|
|
559
568
|
function Set-DirAcl {
|
|
560
569
|
param([string]$Path)
|
|
561
570
|
try {
|
|
562
|
-
$
|
|
563
|
-
if (-not $
|
|
564
|
-
& icacls $Path /inheritance:r /grant:r "
|
|
571
|
+
$sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
|
|
572
|
+
if (-not $sid) { return }
|
|
573
|
+
& "$env:SystemRoot\System32\icacls.exe" $Path /inheritance:r /grant:r "*${sid}:(OI)(CI)(F)" 2>$null | Out-Null
|
|
565
574
|
} catch { }
|
|
566
575
|
}
|
|
567
576
|
|
|
@@ -596,18 +605,18 @@ function Merge-JsonMcpConfig {
|
|
|
596
605
|
function Get-VsCodeUserMcpPath {
|
|
597
606
|
if ($env:VSCODE_MCP_FILE) { return $env:VSCODE_MCP_FILE }
|
|
598
607
|
if ($env:APPDATA) { return (Join-Path $env:APPDATA "Code\User\mcp.json") }
|
|
599
|
-
return (Join-Path $
|
|
608
|
+
return (Join-Path $env:USERPROFILE ".vscode\mcp.json")
|
|
600
609
|
}
|
|
601
610
|
|
|
602
611
|
function Get-OpenCodeHome {
|
|
603
612
|
if ($env:OPENCODE_HOME) { return $env:OPENCODE_HOME }
|
|
604
613
|
if ($env:XDG_CONFIG_HOME) { return (Join-Path $env:XDG_CONFIG_HOME "opencode") }
|
|
605
|
-
return (Join-Path $
|
|
614
|
+
return (Join-Path $env:USERPROFILE ".config\opencode")
|
|
606
615
|
}
|
|
607
616
|
|
|
608
617
|
function Get-KimiHome {
|
|
609
618
|
if ($env:KIMI_HOME) { return $env:KIMI_HOME }
|
|
610
|
-
return (Join-Path $
|
|
619
|
+
return (Join-Path $env:USERPROFILE ".kimi")
|
|
611
620
|
}
|
|
612
621
|
|
|
613
622
|
function Merge-CodexMcpToml {
|
|
@@ -908,59 +917,69 @@ function Invoke-AutoCleanupLegacy {
|
|
|
908
917
|
}
|
|
909
918
|
}
|
|
910
919
|
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
920
|
+
if ($script:SelectedTargets -contains "claude-code") {
|
|
921
|
+
# --- Categoria 2: Claude Code (~\.claude\) ---
|
|
922
|
+
# IP proprietaria de versoes anteriores
|
|
923
|
+
Remove-LegacyItem "$neocortexDir\core" "IP legada"
|
|
924
|
+
Remove-LegacyItem $skillsDir "skills legadas"
|
|
925
|
+
Remove-LegacyItem "$neocortexDir\workflow.md" "workflow removido no Tier 3"
|
|
926
|
+
Remove-LegacyItem "$neocortexDir\package.json" "arquivo desnecessario"
|
|
927
|
+
Remove-LegacyItem "$neocortexDir\README.md" "arquivo desnecessario"
|
|
918
928
|
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
929
|
+
# Step folders legados
|
|
930
|
+
foreach ($folder in @("steps-c", "steps-e", "steps-p", "steps-r", "steps-u")) {
|
|
931
|
+
Remove-LegacyItem "$neocortexDir\$folder" "steps legados"
|
|
932
|
+
}
|
|
923
933
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
934
|
+
# Artefatos de instalacoes anteriores
|
|
935
|
+
Remove-LegacyItem "$claudeDir\agents\.git" "repo git antigo"
|
|
936
|
+
Remove-LegacyItem "$claudeDir\.claude" "diretorio aninhado (erro BMAD)"
|
|
937
|
+
Remove-LegacyItem "$claudeDir\agents-ldtn" "diretorio legado"
|
|
938
|
+
Remove-LegacyItem "$claudeDir\.superclaude-metadata.json" "metadata SuperClaude"
|
|
929
939
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
940
|
+
# Backups SuperClaude antigos
|
|
941
|
+
if (Test-Path "$claudeDir\backups" -PathType Container) {
|
|
942
|
+
Get-ChildItem -Path "$claudeDir\backups" -Filter "superclaude_backup_*.tar.gz" -File -ErrorAction SilentlyContinue | ForEach-Object {
|
|
943
|
+
Remove-LegacyItem $_.FullName "backup SuperClaude antigo"
|
|
944
|
+
}
|
|
934
945
|
}
|
|
935
946
|
}
|
|
936
947
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
948
|
+
if ($script:SelectedTargets -contains "cursor") {
|
|
949
|
+
# --- Categoria 3: Cursor ---
|
|
950
|
+
Remove-LegacyItem "$env:USERPROFILE\.cursor\neocortex" "configs Cursor legadas"
|
|
951
|
+
# .cursorrules com referencias neocortex (verificar antes de remover)
|
|
952
|
+
$cursorrules = "$env:USERPROFILE\.cursorrules"
|
|
953
|
+
if (Test-Path $cursorrules -PathType Leaf) {
|
|
954
|
+
$content = Get-Content $cursorrules -Raw -ErrorAction SilentlyContinue
|
|
955
|
+
if ($content -match "(?i)neocortex|ornexus|synapse") {
|
|
956
|
+
Remove-LegacyItem $cursorrules "cursorrules com refs legadas"
|
|
957
|
+
}
|
|
945
958
|
}
|
|
946
959
|
}
|
|
947
960
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
961
|
+
if ($script:SelectedTargets -contains "vscode") {
|
|
962
|
+
# --- Categoria 4: VS Code ---
|
|
963
|
+
Remove-LegacyItem "$env:USERPROFILE\.vscode\neocortex" "configs VS Code legadas"
|
|
964
|
+
# .instructions.md com referencias neocortex antigo
|
|
965
|
+
$instructionsMd = "$env:USERPROFILE\.instructions.md"
|
|
966
|
+
if (Test-Path $instructionsMd -PathType Leaf) {
|
|
967
|
+
$content = Get-Content $instructionsMd -Raw -ErrorAction SilentlyContinue
|
|
968
|
+
if ($content -match "(?i)neocortex|ornexus|synapse") {
|
|
969
|
+
Remove-LegacyItem $instructionsMd "instructions.md com refs legadas"
|
|
970
|
+
}
|
|
956
971
|
}
|
|
957
972
|
}
|
|
958
973
|
|
|
959
|
-
|
|
960
|
-
|
|
974
|
+
if ($script:SelectedTargets -contains "gemini") {
|
|
975
|
+
# --- Categoria 5: Gemini CLI ---
|
|
976
|
+
Remove-LegacyItem "$env:USERPROFILE\.gemini\neocortex" "configs Gemini legadas"
|
|
977
|
+
}
|
|
961
978
|
|
|
962
|
-
|
|
963
|
-
|
|
979
|
+
if ($script:SelectedTargets -contains "codex") {
|
|
980
|
+
# --- Categoria 6: Codex ---
|
|
981
|
+
Remove-LegacyItem "$env:USERPROFILE\.codex\neocortex" "configs Codex legadas"
|
|
982
|
+
}
|
|
964
983
|
|
|
965
984
|
# --- Categoria 7: Antigravity ---
|
|
966
985
|
# Configs legadas de Antigravity sao gerenciadas pelo adapter, sem path fixo global
|
|
@@ -1042,15 +1061,11 @@ function Verify-Installation {
|
|
|
1042
1061
|
$warns = 0
|
|
1043
1062
|
$report = @()
|
|
1044
1063
|
|
|
1045
|
-
if ($script:SelectedTargets -notcontains "claude-code") {
|
|
1046
|
-
return $true
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
1064
|
# --- Layer 1: File existence + minimum size ---
|
|
1050
|
-
$criticalFiles = @(
|
|
1065
|
+
$criticalFiles = if ($script:SelectedTargets -contains "claude-code") { @(
|
|
1051
1066
|
@{ Name = "neocortex.md"; MinBytes = 512; Label = "Agent principal (stub)" },
|
|
1052
1067
|
@{ Name = "neocortex.agent.yaml"; MinBytes = 128; Label = "Agent config YAML (stub)" }
|
|
1053
|
-
)
|
|
1068
|
+
) } else { @() }
|
|
1054
1069
|
|
|
1055
1070
|
foreach ($entry in $criticalFiles) {
|
|
1056
1071
|
# Agent markdown lives at top-level agents\ (Claude Code discovery);
|
|
@@ -1097,13 +1112,14 @@ function Verify-Installation {
|
|
|
1097
1112
|
if (Test-Path $configFile -PathType Leaf) {
|
|
1098
1113
|
$report += @{ Status = "OK"; Detail = "~\.neocortex\config.json (thin client configured)" }
|
|
1099
1114
|
} else {
|
|
1100
|
-
$report += @{ Status = "
|
|
1101
|
-
$
|
|
1115
|
+
$report += @{ Status = "FAIL"; Detail = "~\.neocortex\config.json (nao encontrado)" }
|
|
1116
|
+
$fails++
|
|
1102
1117
|
}
|
|
1103
1118
|
|
|
1104
1119
|
# Verify NO IP directories exist
|
|
1105
1120
|
$ipFound = $false
|
|
1106
|
-
|
|
1121
|
+
$legacyDirs = if ($script:SelectedTargets -contains "claude-code") { @("core", "steps-c", "steps-e", "steps-p", "steps-r", "steps-u") } else { @() }
|
|
1122
|
+
foreach ($dir in $legacyDirs) {
|
|
1107
1123
|
if (Test-Path (Join-Path $script:DestDir $dir) -PathType Container) {
|
|
1108
1124
|
$report += @{ Status = "WARN"; Detail = "$dir/ ainda existe (deveria ter sido removido)" }
|
|
1109
1125
|
$warns++
|
|
@@ -1115,16 +1131,18 @@ function Verify-Installation {
|
|
|
1115
1131
|
}
|
|
1116
1132
|
|
|
1117
1133
|
# --- Layer 4: Tool availability (Story 66.4 AC1/AC2) ---
|
|
1118
|
-
$
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
$
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1134
|
+
if ($script:SelectedTargets -contains "claude-code") {
|
|
1135
|
+
$claudeCmd = Get-Command claude -ErrorAction SilentlyContinue
|
|
1136
|
+
if (-not $claudeCmd) {
|
|
1137
|
+
$claudeCmd = Get-Command claude.exe -ErrorAction SilentlyContinue
|
|
1138
|
+
}
|
|
1139
|
+
if (-not $claudeCmd) {
|
|
1140
|
+
$report += @{ Status = "WARN"; Detail = "Claude Code CLI nao encontrado no PATH" }
|
|
1141
|
+
$warns++
|
|
1142
|
+
Write-Info "Instale Claude Code: https://claude.ai/download"
|
|
1143
|
+
} else {
|
|
1144
|
+
$report += @{ Status = "OK"; Detail = "Claude Code CLI encontrado" }
|
|
1145
|
+
}
|
|
1128
1146
|
}
|
|
1129
1147
|
|
|
1130
1148
|
$ncCmd = Get-Command neocortex-client -ErrorAction SilentlyContinue
|
|
@@ -1182,22 +1200,28 @@ function Set-ThinClientConfig {
|
|
|
1182
1200
|
$configDir = "$env:USERPROFILE\.neocortex"
|
|
1183
1201
|
$configFile = "$configDir\config.json"
|
|
1184
1202
|
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1203
|
+
foreach ($privateDir in @($configDir, "$configDir\cache")) {
|
|
1204
|
+
if (-not (Test-Path -LiteralPath $privateDir -PathType Container)) {
|
|
1205
|
+
try {
|
|
1206
|
+
New-Item -ItemType Directory -Path $privateDir -ErrorAction Stop | Out-Null
|
|
1207
|
+
Set-DirAcl $privateDir
|
|
1208
|
+
} catch {
|
|
1209
|
+
Write-Warn "AUTH_PROFILE_CONFIG_WRITE_DENIED. Confira o acesso ao perfil com a conta que o criou."
|
|
1210
|
+
return $false
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1191
1214
|
|
|
1192
1215
|
if (Test-Path $configFile) {
|
|
1193
|
-
if (-not (
|
|
1194
|
-
Invoke-ManagedPolicy -BaseDir $env:USERPROFILE | Out-Null
|
|
1195
|
-
Write-Warn "Config ou approval policy invalida; backup criado e original preservado"
|
|
1196
|
-
return $false
|
|
1197
|
-
}
|
|
1216
|
+
if (-not (Invoke-ManagedPolicy -BaseDir $env:USERPROFILE -CheckOnly)) { return $false }
|
|
1198
1217
|
try {
|
|
1199
1218
|
$existingConfig = Get-Content $configFile -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
|
|
1200
|
-
if (
|
|
1219
|
+
if (-not $existingConfig.PSObject.Properties["mode"]) {
|
|
1220
|
+
$mode = if ($existingConfig.encryptedLicenseKey -or $existingConfig.licenseKey) { "remote" } else { "pending-activation" }
|
|
1221
|
+
$existingConfig | Add-Member -NotePropertyName mode -NotePropertyValue $mode
|
|
1222
|
+
Write-Utf8NoBomAtomic -Path $configFile -Content ($existingConfig | ConvertTo-Json -Depth 100)
|
|
1223
|
+
}
|
|
1224
|
+
if ($existingConfig.mode -in @("active", "local", "remote", "pending-activation")) {
|
|
1201
1225
|
# --- Config schema migration (Epic 62 - GAP 4) ---
|
|
1202
1226
|
if (-not $existingConfig.configVersion) {
|
|
1203
1227
|
Write-Dbg "Migrando schema do config.json (adicionando configVersion)"
|
|
@@ -1211,7 +1235,7 @@ function Set-ThinClientConfig {
|
|
|
1211
1235
|
if ($existingConfig.tier -eq 3 -and $existingConfig.mode -eq "pending-activation") {
|
|
1212
1236
|
$existingConfig.PSObject.Properties.Remove("tier")
|
|
1213
1237
|
}
|
|
1214
|
-
Write-Utf8NoBomAtomic -Path $configFile -Content ($existingConfig | ConvertTo-Json -Depth
|
|
1238
|
+
Write-Utf8NoBomAtomic -Path $configFile -Content ($existingConfig | ConvertTo-Json -Depth 100)
|
|
1215
1239
|
Write-Dbg "Config migrada para configVersion 1"
|
|
1216
1240
|
} catch {
|
|
1217
1241
|
Write-Dbg "Falha na migracao do config: $_"
|
|
@@ -1226,8 +1250,7 @@ function Set-ThinClientConfig {
|
|
|
1226
1250
|
Write-Dbg "Fixing stale localhost serverUrl to configured remote endpoint"
|
|
1227
1251
|
try {
|
|
1228
1252
|
$existingConfig.serverUrl = $NEOCORTEX_SERVER_URL
|
|
1229
|
-
Write-Utf8NoBomAtomic -Path $configFile -Content ($existingConfig | ConvertTo-Json -Depth
|
|
1230
|
-
Set-FileAcl $configFile
|
|
1253
|
+
Write-Utf8NoBomAtomic -Path $configFile -Content ($existingConfig | ConvertTo-Json -Depth 100)
|
|
1231
1254
|
Write-Dbg "serverUrl updated to configured remote endpoint"
|
|
1232
1255
|
} catch {
|
|
1233
1256
|
Write-Dbg "Failed to update serverUrl: $_"
|
|
@@ -1241,8 +1264,7 @@ function Set-ThinClientConfig {
|
|
|
1241
1264
|
Write-Dbg "Fixing legacy serverUrl to configured remote endpoint"
|
|
1242
1265
|
try {
|
|
1243
1266
|
$existingConfig.serverUrl = $NEOCORTEX_SERVER_URL
|
|
1244
|
-
Write-Utf8NoBomAtomic -Path $configFile -Content ($existingConfig | ConvertTo-Json -Depth
|
|
1245
|
-
Set-FileAcl $configFile
|
|
1267
|
+
Write-Utf8NoBomAtomic -Path $configFile -Content ($existingConfig | ConvertTo-Json -Depth 100)
|
|
1246
1268
|
Write-Dbg "serverUrl updated from legacy host to configured remote endpoint"
|
|
1247
1269
|
} catch {
|
|
1248
1270
|
Write-Dbg "Failed to update serverUrl: $_"
|
|
@@ -1250,15 +1272,15 @@ function Set-ThinClientConfig {
|
|
|
1250
1272
|
}
|
|
1251
1273
|
|
|
1252
1274
|
if (-not (Invoke-ManagedPolicy -BaseDir $env:USERPROFILE)) {
|
|
1253
|
-
Write-Warn "Approval policy invalida ou ownership ambiguo; config preservada"
|
|
1254
1275
|
return $false
|
|
1255
1276
|
}
|
|
1256
1277
|
Write-Dbg "Config existente preservada (mode=$($existingConfig.mode))"
|
|
1257
1278
|
return $true
|
|
1258
1279
|
}
|
|
1280
|
+
Write-Warn "AUTH_PROFILE_CONFIG_INVALID. O modo do perfil existente nao foi reconhecido. Config preservada."
|
|
1281
|
+
return $false
|
|
1259
1282
|
} catch {
|
|
1260
|
-
|
|
1261
|
-
Write-Warn "Config invalida; backup criado e original preservado"
|
|
1283
|
+
Write-Warn "AUTH_PROFILE_CONFIG_INVALID. Config preservada."
|
|
1262
1284
|
return $false
|
|
1263
1285
|
}
|
|
1264
1286
|
}
|
|
@@ -1281,7 +1303,12 @@ function Set-ThinClientConfig {
|
|
|
1281
1303
|
}
|
|
1282
1304
|
}
|
|
1283
1305
|
|
|
1284
|
-
|
|
1306
|
+
try {
|
|
1307
|
+
Write-Utf8NoBomAtomic -Path $configFile -Content ($config | ConvertTo-Json -Depth 5)
|
|
1308
|
+
} catch {
|
|
1309
|
+
Write-Warn "AUTH_PROFILE_CONFIG_WRITE_DENIED. Confira o acesso ao perfil com a conta que o criou."
|
|
1310
|
+
return $false
|
|
1311
|
+
}
|
|
1285
1312
|
# Story 66.1 AC4: Apply ACL on config.json
|
|
1286
1313
|
Set-FileAcl $configFile
|
|
1287
1314
|
if (-not (Invoke-ManagedPolicy -BaseDir $env:USERPROFILE)) { return $false }
|
|
@@ -1297,32 +1324,18 @@ function Set-ThinClientConfig {
|
|
|
1297
1324
|
# =============================================================================
|
|
1298
1325
|
|
|
1299
1326
|
function Install-Core {
|
|
1300
|
-
$script:ClaudeDir = "$env:USERPROFILE\.claude"
|
|
1301
|
-
$script:AgentsDir = "$script:ClaudeDir\agents"
|
|
1302
|
-
$script:DestDir = "$script:AgentsDir\neocortex"
|
|
1303
|
-
|
|
1304
|
-
Write-Dbg "DEST=$script:DestDir"
|
|
1305
|
-
|
|
1306
|
-
# Create directories with verification (Epic 65)
|
|
1307
|
-
if (-not (Test-Path $script:ClaudeDir)) {
|
|
1308
|
-
try { New-Item -ItemType Directory -Path $script:ClaudeDir -Force -ErrorAction Stop | Out-Null }
|
|
1309
|
-
catch { Write-Fail "Falha ao criar $script:ClaudeDir`: $_"; return $false }
|
|
1310
|
-
}
|
|
1311
|
-
try { New-Item -ItemType Directory -Path $script:AgentsDir -Force -ErrorAction Stop | Out-Null }
|
|
1312
|
-
catch { Write-Fail "Falha ao criar $script:AgentsDir`: $_"; return $false }
|
|
1313
|
-
|
|
1314
|
-
# P201.08: keep the destination and update only managed files additively.
|
|
1315
|
-
try { New-Item -ItemType Directory -Path $script:DestDir -Force -ErrorAction Stop | Out-Null }
|
|
1316
|
-
catch { Write-Fail "Falha ao criar $script:DestDir`: $_"; return $false }
|
|
1317
|
-
|
|
1318
|
-
# Verify directory was actually created (Epic 65: anti-silent-failure)
|
|
1319
|
-
if (-not (Test-Path $script:DestDir -PathType Container)) {
|
|
1320
|
-
Write-Fail "Diretorio $script:DestDir nao existe apos criacao"
|
|
1321
|
-
return $false
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
1327
|
# Thin-client invariant: configure the remote client and never copy core/**.
|
|
1325
1328
|
if (-not (Set-ThinClientConfig)) { return $false }
|
|
1329
|
+
$profileVersionPath = "$env:USERPROFILE\.neocortex\.version"
|
|
1330
|
+
$versionPaths = @($profileVersionPath)
|
|
1331
|
+
if ($script:SelectedTargets -contains "claude-code") {
|
|
1332
|
+
$script:ClaudeDir = "$env:USERPROFILE\.claude"
|
|
1333
|
+
$script:AgentsDir = "$script:ClaudeDir\agents"
|
|
1334
|
+
$script:DestDir = "$script:AgentsDir\neocortex"
|
|
1335
|
+
try { New-Item -ItemType Directory -Path $script:DestDir -Force -ErrorAction Stop | Out-Null }
|
|
1336
|
+
catch { Write-Fail "Falha ao preparar o diretorio de agentes do Claude Code."; return $false }
|
|
1337
|
+
$versionPaths += "$script:DestDir\.version"
|
|
1338
|
+
}
|
|
1326
1339
|
|
|
1327
1340
|
# --- Version-aware cache purge on upgrade (Epic 62 - GAP 2+3) ---
|
|
1328
1341
|
$pkgJsonPath = Join-Path $script:SourceDir "package.json"
|
|
@@ -1335,7 +1348,6 @@ function Install-Core {
|
|
|
1335
1348
|
if ($pkgVersion) {
|
|
1336
1349
|
$oldVersion = $null
|
|
1337
1350
|
# Read existing .version from either location
|
|
1338
|
-
$versionPaths = @("$script:DestDir\.version", "$env:USERPROFILE\.neocortex\.version")
|
|
1339
1351
|
foreach ($vp in $versionPaths) {
|
|
1340
1352
|
if (Test-Path $vp -PathType Leaf) {
|
|
1341
1353
|
$oldVersion = (Get-Content $vp -Raw -ErrorAction SilentlyContinue).Trim()
|
|
@@ -1365,8 +1377,10 @@ function Install-Core {
|
|
|
1365
1377
|
}
|
|
1366
1378
|
}
|
|
1367
1379
|
|
|
1368
|
-
|
|
1369
|
-
|
|
1380
|
+
foreach ($versionPath in $versionPaths) {
|
|
1381
|
+
try { Write-Utf8NoBomAtomic -Path $versionPath -Content $pkgVersion }
|
|
1382
|
+
catch { Write-Fail "Falha ao gravar marcador de versao no perfil."; return $false }
|
|
1383
|
+
}
|
|
1370
1384
|
}
|
|
1371
1385
|
|
|
1372
1386
|
Write-Ok "Remote mode configured (thin client ready)"
|
|
@@ -1591,13 +1605,16 @@ $script:PlatformRequiredTier = @{
|
|
|
1591
1605
|
# END NEOCORTEX PLATFORM TIER TABLE
|
|
1592
1606
|
|
|
1593
1607
|
function Get-TierFromConfig {
|
|
1594
|
-
$configPath = Join-Path (Join-Path $
|
|
1595
|
-
if (-not (Test-Path $configPath -PathType Leaf)) { return "
|
|
1608
|
+
$configPath = Join-Path (Join-Path $env:USERPROFILE ".neocortex") "config.json"
|
|
1609
|
+
if (-not (Test-Path $configPath -PathType Leaf)) { return "unverified" }
|
|
1596
1610
|
try {
|
|
1597
1611
|
$cfg = Get-Content -Path $configPath -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
|
|
1598
|
-
if ($cfg.tier -is [string]
|
|
1612
|
+
if ($cfg.tier -is [string]) {
|
|
1613
|
+
$tier = $cfg.tier.Trim().ToLowerInvariant()
|
|
1614
|
+
if ($tier -in @("free", "pro", "enterprise")) { return $tier }
|
|
1615
|
+
}
|
|
1599
1616
|
} catch { }
|
|
1600
|
-
return "
|
|
1617
|
+
return "unverified"
|
|
1601
1618
|
}
|
|
1602
1619
|
|
|
1603
1620
|
# Tier hierarchy (free < pro < enterprise). Unrecognized values rank as free,
|
|
@@ -1617,8 +1634,12 @@ function Test-PlatformTier {
|
|
|
1617
1634
|
if ($script:PlatformRequiredTier.ContainsKey($Platform)) { $required = $script:PlatformRequiredTier[$Platform] }
|
|
1618
1635
|
if ((Get-PlatformTierRank -Tier $Tier) -ge (Get-PlatformTierRank -Tier $required)) { return $true }
|
|
1619
1636
|
$requiredLabel = if ($required -eq "enterprise") { "Enterprise" } else { "Pro" }
|
|
1620
|
-
|
|
1621
|
-
|
|
1637
|
+
if ($Tier -eq "unverified") {
|
|
1638
|
+
Write-Warn "$Platform requer plano $requiredLabel. Ative a credencial neste perfil e repita a mesma selecao."
|
|
1639
|
+
} else {
|
|
1640
|
+
Write-Warn "$Platform requer plano $requiredLabel. Plano ativo: $Tier."
|
|
1641
|
+
Write-Info "Planos: https://neocortex.sh/portal/dashboard/plans"
|
|
1642
|
+
}
|
|
1622
1643
|
return $false
|
|
1623
1644
|
}
|
|
1624
1645
|
|
|
@@ -1826,7 +1847,11 @@ function Install-Targets {
|
|
|
1826
1847
|
if ($opencodeTargetDir -and (Test-Path "$opencodeTargetDir\neocortex.md")) {
|
|
1827
1848
|
New-Item -ItemType Directory -Path "$opencodeHome\agents" -Force | Out-Null
|
|
1828
1849
|
$opencodeBase = Get-ManagedPlatformBase -PlatformHome $opencodeHome -DefaultBase $homeDir
|
|
1829
|
-
|
|
1850
|
+
if (-not (Install-AgentRoleProfiles -Platform "opencode" -SourceDir $opencodeTargetDir -AgentsDir "$opencodeHome\agents" -BaseDir $opencodeBase -Scope "user")) {
|
|
1851
|
+
$script:TargetResults += "$target`:FAIL"
|
|
1852
|
+
Write-Fail "opencode. A instalacao do perfil falhou."
|
|
1853
|
+
continue
|
|
1854
|
+
}
|
|
1830
1855
|
if (Test-Path "$opencodeTargetDir\opencode-mcp.json") {
|
|
1831
1856
|
Merge-JsonMcpConfig -StubFile "$opencodeTargetDir\opencode-mcp.json" -DestFile "$opencodeHome\opencode.json" -RootKey "mcp"
|
|
1832
1857
|
}
|
|
@@ -2176,15 +2201,16 @@ function Show-Result {
|
|
|
2176
2201
|
Write-Host " Status: Ready to activate" -ForegroundColor DarkGray
|
|
2177
2202
|
Write-Host ""
|
|
2178
2203
|
Write-Host " Activate your license:" -ForegroundColor DarkGray
|
|
2179
|
-
Write-Host " neocortex activate YOUR-LICENSE-KEY" -ForegroundColor Cyan
|
|
2204
|
+
Write-Host " neocortex.cmd activate YOUR-LICENSE-KEY" -ForegroundColor Cyan
|
|
2180
2205
|
Write-Host ""
|
|
2181
2206
|
Write-Host " Get your key at: https://neocortex.sh/portal/login" -ForegroundColor DarkGray
|
|
2182
2207
|
Write-Host ""
|
|
2183
2208
|
Write-Host " After activation:" -ForegroundColor DarkGray
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2209
|
+
if ($script:SelectedTargets.Count -eq 0) {
|
|
2210
|
+
Write-Host " neocortex.cmd --targets=<plataformas>" -ForegroundColor Cyan
|
|
2211
|
+
} else {
|
|
2212
|
+
Write-Host " @neocortex *menu" -ForegroundColor Cyan
|
|
2213
|
+
}
|
|
2188
2214
|
Write-Host ""
|
|
2189
2215
|
return $true
|
|
2190
2216
|
} else {
|
|
@@ -2224,12 +2250,12 @@ if ($Targets) {
|
|
|
2224
2250
|
Write-Host " Validas: $($script:ValidTargets -join ', ')"
|
|
2225
2251
|
exit 1
|
|
2226
2252
|
}
|
|
2227
|
-
} elseif ($Yes) {
|
|
2228
|
-
$script:SelectedTargets = @("claude-code")
|
|
2229
2253
|
} else {
|
|
2230
|
-
$script:SelectedTargets = @(
|
|
2254
|
+
$script:SelectedTargets = @()
|
|
2231
2255
|
}
|
|
2232
2256
|
|
|
2257
|
+
if (-not (Invoke-ManagedPolicy -BaseDir $env:USERPROFILE -CheckOnly)) { exit 1 }
|
|
2258
|
+
|
|
2233
2259
|
# P228.05: filter tier-blocked platforms with the server table (narrow only).
|
|
2234
2260
|
$userTier = Get-TierFromConfig
|
|
2235
2261
|
Write-Dbg "User tier: $userTier"
|
|
@@ -2238,12 +2264,11 @@ $blockedTargets = @($script:SelectedTargets | Where-Object { $_ -notin $allowedT
|
|
|
2238
2264
|
if ($blockedTargets.Count -gt 0) {
|
|
2239
2265
|
Write-Info "Plataforma(s) bloqueada(s) por tier: $($blockedTargets -join ', ')"
|
|
2240
2266
|
}
|
|
2241
|
-
if ($
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
$script:SelectedTargets = @("claude-code")
|
|
2245
|
-
Write-Info "Usando plataforma padrao: claude-code"
|
|
2267
|
+
if ($script:SelectedTargets.Count -gt 0 -and $allowedTargets.Count -eq 0) {
|
|
2268
|
+
Write-Fail "installer-target-entitlement-blocked. Nenhuma plataforma solicitada pode ser instalada com o plano atual."
|
|
2269
|
+
exit 3
|
|
2246
2270
|
}
|
|
2271
|
+
$script:SelectedTargets = $allowedTargets
|
|
2247
2272
|
|
|
2248
2273
|
Write-Dbg "Targets: $($script:SelectedTargets -join ', ')"
|
|
2249
2274
|
|
|
@@ -2257,19 +2282,19 @@ if ($DryRun) {
|
|
|
2257
2282
|
$totalSteps = 4
|
|
2258
2283
|
if ($script:SelectedTargets -contains "claude-code") { $totalSteps = 5 }
|
|
2259
2284
|
|
|
2260
|
-
# Step 1:
|
|
2261
|
-
Write-Step 1 $totalSteps "
|
|
2262
|
-
Invoke-AutoCleanupLegacy
|
|
2263
|
-
|
|
2264
|
-
# Step 2: Core
|
|
2265
|
-
Write-Step 2 $totalSteps "Instalando core"
|
|
2285
|
+
# Step 1: Verify and prepare the selected user profile before cleanup.
|
|
2286
|
+
Write-Step 1 $totalSteps "Preparando perfil do Neocortex"
|
|
2266
2287
|
$coreSuccess = Install-Core
|
|
2267
2288
|
|
|
2268
2289
|
if (-not $coreSuccess) {
|
|
2269
|
-
Write-Fail "
|
|
2290
|
+
Write-Fail "O perfil do Neocortex nao pode ser preparado."
|
|
2270
2291
|
exit 1
|
|
2271
2292
|
}
|
|
2272
2293
|
|
|
2294
|
+
# Step 2: Legacy cleanup
|
|
2295
|
+
Write-Step 2 $totalSteps "Limpeza de versoes anteriores"
|
|
2296
|
+
Invoke-AutoCleanupLegacy
|
|
2297
|
+
|
|
2273
2298
|
# Step 3: Skills
|
|
2274
2299
|
Write-Step 3 $totalSteps "Instalando skills"
|
|
2275
2300
|
Install-Skills | Out-Null
|
|
@@ -2290,7 +2315,7 @@ if ($script:SelectedTargets -contains "claude-code") {
|
|
|
2290
2315
|
Install-MCPs
|
|
2291
2316
|
}
|
|
2292
2317
|
|
|
2293
|
-
$installSuccess = ($script:TargetResults | Where-Object { $_ -match ":FAIL$" }).Count -eq 0
|
|
2318
|
+
$installSuccess = ($script:TargetResults | Where-Object { $_ -match ":(FAIL|SKIP)$" }).Count -eq 0
|
|
2294
2319
|
$verifySuccess = Verify-Installation
|
|
2295
2320
|
$installSuccess = $installSuccess -and $verifySuccess
|
|
2296
2321
|
|
|
@@ -2305,6 +2330,7 @@ if (Show-Result $installSuccess) {
|
|
|
2305
2330
|
New-ProjectDirectories
|
|
2306
2331
|
Write-Host " Desenvolvido por OrNexus Team" -ForegroundColor DarkGray
|
|
2307
2332
|
Write-Host ""
|
|
2333
|
+
if ($blockedTargets.Count -gt 0) { exit 3 }
|
|
2308
2334
|
exit 0
|
|
2309
2335
|
} else {
|
|
2310
2336
|
exit 1
|
package/install.sh
CHANGED