@ornexus/neocortex 3.8.1 → 3.8.2

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.
Files changed (3) hide show
  1. package/install.ps1 +218 -210
  2. package/install.sh +157 -222
  3. package/package.json +2 -2
package/install.ps1 CHANGED
@@ -15,7 +15,7 @@ param(
15
15
  [string]$ServerUrl = "https://api.neocortex.ornexus.com"
16
16
  )
17
17
 
18
- $VERSION = "3.8.1"
18
+ $VERSION = "3.8.2"
19
19
 
20
20
  # =============================================================================
21
21
  # CONFIGURACOES
@@ -65,7 +65,7 @@ if ($Help) {
65
65
  Write-Host " -CreateProject Instalar estrutura no projeto" -ForegroundColor Cyan
66
66
  Write-Host " -SkipProject Nao perguntar sobre projeto" -ForegroundColor Cyan
67
67
  Write-Host " -Quiet Modo silencioso" -ForegroundColor Cyan
68
- Write-Host " -CleanupLegacy Remover artefatos legados de ~/.claude/" -ForegroundColor Cyan
68
+ Write-Host " -CleanupLegacy (Redundante) Limpeza agora e automatica" -ForegroundColor Cyan
69
69
  Write-Host " -Local Modo local (copia IP para desenvolvimento)" -ForegroundColor Cyan
70
70
  Write-Host " -ServerUrl <url> URL do server Neocortex" -ForegroundColor Cyan
71
71
  Write-Host " -Debug Modo debug" -ForegroundColor Cyan
@@ -264,136 +264,178 @@ function Test-ProjectMigrationNeeds {
264
264
  }
265
265
 
266
266
  # =============================================================================
267
- # DETECCAO DE ARTEFATOS LEGADOS
267
+ # LIMPEZA AUTOMATICA DE ARTEFATOS LEGADOS (Invoke-AutoCleanupLegacy)
268
+ # Unifica: Test-LegacyArtifacts + Invoke-CleanupLegacy + Remove-LegacyIP
269
+ # + Remove-LegacyIPProject + npm globals + cross-platform cleanup
270
+ # Roda AUTOMATICAMENTE a cada instalacao - sem necessidade de -CleanupLegacy
271
+ # Idempotente: rodar multiplas vezes sem efeitos colaterais
272
+ # Seguro: NAO remove dados do usuario (stories, epics, state.json, config.json)
268
273
  # =============================================================================
269
274
 
270
- function Test-LegacyArtifacts {
271
- $warnings = 0
272
- $script:LegacyItems = @()
275
+ function Invoke-AutoCleanupLegacy {
276
+ $removed = 0
277
+ $claudeDir = "$env:USERPROFILE\.claude"
278
+ $neocortexDir = "$claudeDir\agents\neocortex"
279
+ $skillsDir = "$claudeDir\skills\neocortex"
280
+
281
+ Write-Dbg "Executando limpeza automatica de artefatos legados..."
282
+
283
+ # --- Helper: remove e loga ---
284
+ function Remove-LegacyItem {
285
+ param([string]$Target, [string]$Label)
286
+ if (Test-Path $Target) {
287
+ $displayItem = $Target -replace [regex]::Escape($env:USERPROFILE), "~"
288
+ try {
289
+ Remove-Item -Path $Target -Recurse -Force -ErrorAction Stop
290
+ Write-Info "Removido: $displayItem ($Label)"
291
+ $script:autoRemoved++
292
+ } catch {
293
+ Write-Dbg "Falha ao remover: $displayItem"
294
+ }
295
+ }
296
+ }
273
297
 
274
- Write-Dbg "Verificando artefatos legados em ~/.claude/..."
298
+ $script:autoRemoved = 0
275
299
 
276
- $claudeDir = "$env:USERPROFILE\.claude"
300
+ # --- Categoria 1: Pacotes NPM globais legados ---
301
+ $npmCmd = Get-Command npm -ErrorAction SilentlyContinue
302
+ if ($npmCmd) {
303
+ foreach ($pkg in @("@ornexus/neocortex-cli", "@ornexus-ai/neocortex")) {
304
+ $npmList = & npm list -g $pkg --depth=0 2>$null
305
+ if ($npmList -match [regex]::Escape($pkg)) {
306
+ try {
307
+ & npm uninstall -g $pkg 2>$null
308
+ if ($LASTEXITCODE -eq 0) {
309
+ Write-Info "Removido: $pkg (pacote npm global legado)"
310
+ $script:autoRemoved++
311
+ }
312
+ } catch {
313
+ Write-Dbg "Falha ao remover pacote npm: $pkg"
314
+ }
315
+ }
316
+ }
277
317
 
278
- # Check 1: .git inside agents/ (leftover from contains-studio/agents repo)
279
- if (Test-Path "$claudeDir\agents\.git" -PathType Container) {
280
- Write-Warn "Repositorio .git detectado em ~\.claude\agents\"
281
- Write-Info "Pode conflitar com instalacoes do Neocortex"
282
- Write-Info "Execute com -CleanupLegacy para remover"
283
- $script:LegacyItems += "$claudeDir\agents\.git"
284
- $warnings++
318
+ # Verificar binario neocortex-cli no PATH
319
+ $ncliCmd = Get-Command neocortex-cli -ErrorAction SilentlyContinue
320
+ if ($ncliCmd -and $ncliCmd.Source -match "node_modules|npm") {
321
+ try {
322
+ Remove-Item -Path $ncliCmd.Source -Force -ErrorAction Stop
323
+ Write-Info "Removido: $($ncliCmd.Source) (binario neocortex-cli legado)"
324
+ $script:autoRemoved++
325
+ } catch {
326
+ Write-Dbg "Falha ao remover binario neocortex-cli"
327
+ }
328
+ }
285
329
  }
286
330
 
287
- # Check 2: Nested .claude\.claude\ (BMAD installation error)
288
- if (Test-Path "$claudeDir\.claude" -PathType Container) {
289
- Write-Warn "Diretorio aninhado detectado: ~\.claude\.claude\"
290
- Write-Info "Possivelmente erro de instalacao anterior (BMAD)"
291
- Write-Info "Execute com -CleanupLegacy para remover"
292
- $script:LegacyItems += "$claudeDir\.claude"
293
- $warnings++
294
- }
331
+ # --- Categoria 2: Claude Code (~\.claude\) ---
332
+ # IP proprietaria de versoes anteriores
333
+ Remove-LegacyItem "$neocortexDir\core" "IP legada"
334
+ Remove-LegacyItem $skillsDir "skills legadas"
335
+ Remove-LegacyItem "$neocortexDir\workflow.md" "workflow removido no Tier 3"
336
+ Remove-LegacyItem "$neocortexDir\package.json" "arquivo desnecessario"
337
+ Remove-LegacyItem "$neocortexDir\README.md" "arquivo desnecessario"
295
338
 
296
- # Check 3: Loose agents without namespace (files directly in agents\, not in subdirs)
297
- $looseFiles = @()
298
- if (Test-Path "$claudeDir\agents" -PathType Container) {
299
- $looseFiles = Get-ChildItem -Path "$claudeDir\agents" -Filter "*.md" -File -ErrorAction SilentlyContinue
339
+ # Step folders legados
340
+ foreach ($folder in @("steps-c", "steps-e", "steps-p", "steps-r", "steps-u")) {
341
+ Remove-LegacyItem "$neocortexDir\$folder" "steps legados"
300
342
  }
301
- if ($looseFiles.Count -gt 0) {
302
- Write-Info "$($looseFiles.Count) arquivo(s) .md solto(s) em ~\.claude\agents\"
303
- foreach ($f in $looseFiles) {
304
- Write-Dbg " Solto: $($f.Name)"
343
+
344
+ # Artefatos de instalacoes anteriores
345
+ Remove-LegacyItem "$claudeDir\agents\.git" "repo git antigo"
346
+ Remove-LegacyItem "$claudeDir\.claude" "diretorio aninhado (erro BMAD)"
347
+ Remove-LegacyItem "$claudeDir\agents-ldtn" "diretorio legado"
348
+ Remove-LegacyItem "$claudeDir\.superclaude-metadata.json" "metadata SuperClaude"
349
+
350
+ # Backups SuperClaude antigos
351
+ if (Test-Path "$claudeDir\backups" -PathType Container) {
352
+ Get-ChildItem -Path "$claudeDir\backups" -Filter "superclaude_backup_*.tar.gz" -File -ErrorAction SilentlyContinue | ForEach-Object {
353
+ Remove-LegacyItem $_.FullName "backup SuperClaude antigo"
305
354
  }
306
- Write-Info "Considere organizar em namespaces (ex: agents\neocortex\)"
307
- $warnings++
308
355
  }
309
356
 
310
- # Check 4: Legacy agents-ldtn\ directory
311
- if (Test-Path "$claudeDir\agents-ldtn" -PathType Container) {
312
- Write-Warn "Diretorio legado detectado: ~\.claude\agents-ldtn\"
313
- Write-Info "Execute com -CleanupLegacy para remover"
314
- $script:LegacyItems += "$claudeDir\agents-ldtn"
315
- $warnings++
357
+ # --- Categoria 3: Cursor ---
358
+ Remove-LegacyItem "$env:USERPROFILE\.cursor\neocortex" "configs Cursor legadas"
359
+ # .cursorrules com referencias neocortex (verificar antes de remover)
360
+ $cursorrules = "$env:USERPROFILE\.cursorrules"
361
+ if (Test-Path $cursorrules -PathType Leaf) {
362
+ $content = Get-Content $cursorrules -Raw -ErrorAction SilentlyContinue
363
+ if ($content -match "(?i)neocortex|ornexus|synapse") {
364
+ Remove-LegacyItem $cursorrules "cursorrules com refs legadas"
365
+ }
316
366
  }
317
367
 
318
- # Check 5: .superclaude-metadata.json
319
- if (Test-Path "$claudeDir\.superclaude-metadata.json" -PathType Leaf) {
320
- Write-Warn "Metadata legado detectado: ~\.claude\.superclaude-metadata.json"
321
- Write-Info "Execute com -CleanupLegacy para remover"
322
- $script:LegacyItems += "$claudeDir\.superclaude-metadata.json"
323
- $warnings++
368
+ # --- Categoria 4: VS Code ---
369
+ Remove-LegacyItem "$env:USERPROFILE\.vscode\neocortex" "configs VS Code legadas"
370
+ # .instructions.md com referencias neocortex antigo
371
+ $instructionsMd = "$env:USERPROFILE\.instructions.md"
372
+ if (Test-Path $instructionsMd -PathType Leaf) {
373
+ $content = Get-Content $instructionsMd -Raw -ErrorAction SilentlyContinue
374
+ if ($content -match "(?i)neocortex|ornexus|synapse") {
375
+ Remove-LegacyItem $instructionsMd "instructions.md com refs legadas"
376
+ }
324
377
  }
325
378
 
326
- # Check 6: superclaude_backup_*.tar.gz in backups\
327
- $backupCount = 0
328
- if (Test-Path "$claudeDir\backups" -PathType Container) {
329
- $backupCount = (Get-ChildItem -Path "$claudeDir\backups" -Filter "superclaude_backup_*.tar.gz" -File -ErrorAction SilentlyContinue).Count
330
- }
331
- if ($backupCount -gt 0) {
332
- Write-Info "$backupCount backup(s) SuperClaude antigo(s) em ~\.claude\backups\"
333
- $warnings++
334
- }
379
+ # --- Categoria 5: Gemini CLI ---
380
+ Remove-LegacyItem "$env:USERPROFILE\.gemini\neocortex" "configs Gemini legadas"
381
+
382
+ # --- Categoria 6: Codex ---
383
+ Remove-LegacyItem "$env:USERPROFILE\.codex\neocortex" "configs Codex legadas"
384
+
385
+ # --- Categoria 7: Antigravity ---
386
+ # Configs legadas de Antigravity sao gerenciadas pelo adapter, sem path fixo global
335
387
 
336
- if ($warnings -gt 0) {
337
- Write-Warn "$warnings artefato(s) legado(s) detectado(s)"
388
+ # --- Resultado ---
389
+ $removed = $script:autoRemoved
390
+ if ($removed -gt 0) {
391
+ Write-Ok "$removed artefato(s) legado(s) removido(s) automaticamente"
392
+ } else {
393
+ Write-Dbg "Nenhum artefato legado encontrado"
338
394
  }
339
395
 
340
- $script:LegacyWarnings = $warnings
341
- return $warnings
396
+ # Resetar contadores legados (compatibilidade)
397
+ $script:LegacyItems = @()
398
+ $script:LegacyWarnings = 0
342
399
  }
343
400
 
344
- function Invoke-CleanupLegacy {
345
- if (-not $CleanupLegacy) { return }
401
+ # Cleanup de IP legada em projetos individuais (project-level)
402
+ function Invoke-AutoCleanupLegacyProject {
403
+ param([string]$ProjectDir)
346
404
 
347
- if ($script:LegacyWarnings -eq 0 -or $script:LegacyItems.Count -eq 0) {
348
- Write-Info "Nenhum artefato legado encontrado para limpeza"
349
- return
350
- }
405
+ $neocortexDir = "$ProjectDir\.claude\agents\neocortex"
406
+ $skillsDir = "$ProjectDir\.claude\skills\neocortex"
407
+ $cleaned = $false
351
408
 
352
- # Safety: refuse cleanup in -Yes mode (protect against automated deletion)
353
- if ($AUTO_YES) {
354
- Write-Warn "Cleanup requer confirmacao interativa (-Yes ignorado para seguranca)"
355
- return
409
+ # Remover core/ e seus subdiretorios
410
+ if (Test-Path "$neocortexDir\core") {
411
+ Remove-Item -Path "$neocortexDir\core" -Recurse -Force -ErrorAction SilentlyContinue
412
+ $cleaned = $true
356
413
  }
357
414
 
358
- # Show what will be removed
359
- Write-Host ""
360
- Write-Warn "Os seguintes artefatos serao removidos:"
361
- foreach ($item in $script:LegacyItems) {
362
- $displayItem = $item -replace [regex]::Escape($env:USERPROFILE), "~"
363
- if (Test-Path $item -PathType Container) {
364
- Write-Info " - $displayItem\ (diretorio)"
365
- } else {
366
- Write-Info " - $displayItem (arquivo)"
415
+ # Remover step folders
416
+ foreach ($folder in @("steps-c", "steps-e", "steps-p", "steps-r", "steps-u")) {
417
+ if (Test-Path "$neocortexDir\$folder") {
418
+ Remove-Item -Path "$neocortexDir\$folder" -Recurse -Force -ErrorAction SilentlyContinue
419
+ $cleaned = $true
367
420
  }
368
421
  }
369
422
 
370
- Write-Host " Confirmar remocao? [s/N]: " -NoNewline -ForegroundColor White
371
- $response = Read-HostWithTimeout -TimeoutSeconds 30 -Default "n"
372
-
373
- if ($response -notmatch "^[sS]([iI][mM]?)?$|^[yY]([eE][sS]?)?$") {
374
- Write-Info "Cleanup cancelado"
375
- return
423
+ # Remover skills
424
+ if (Test-Path $skillsDir) {
425
+ Remove-Item -Path $skillsDir -Recurse -Force -ErrorAction SilentlyContinue
426
+ $cleaned = $true
376
427
  }
377
428
 
378
- # Execute cleanup
379
- $removed = 0
380
- $failed = 0
381
- foreach ($item in $script:LegacyItems) {
382
- $displayItem = $item -replace [regex]::Escape($env:USERPROFILE), "~"
383
- try {
384
- Remove-Item -Path $item -Recurse -Force -ErrorAction Stop
385
- Write-Ok "Removido: $displayItem"
386
- $removed++
387
- } catch {
388
- Write-Fail "Falha ao remover: $displayItem"
389
- $failed++
429
+ # Remover arquivos desnecessarios
430
+ foreach ($file in @("package.json", "README.md", "workflow.md")) {
431
+ if (Test-Path "$neocortexDir\$file") {
432
+ Remove-Item -Path "$neocortexDir\$file" -Force -ErrorAction SilentlyContinue
433
+ $cleaned = $true
390
434
  }
391
435
  }
392
436
 
393
- if ($failed -eq 0) {
394
- Write-Ok "$removed artefato(s) removido(s) com sucesso"
395
- } else {
396
- Write-Warn "$removed removido(s), $failed falha(s)"
437
+ if ($cleaned) {
438
+ Write-Info "IP proprietaria removida do projeto (agora servida via server remoto)"
397
439
  }
398
440
  }
399
441
 
@@ -450,30 +492,54 @@ function Verify-Installation {
450
492
  }
451
493
  }
452
494
 
453
- # --- Layer 3: Step directories ---
454
- foreach ($dir in @("steps-c", "steps-e", "steps-p", "steps-r", "steps-u")) {
455
- $dirPath = Join-Path $script:DestDir $dir
456
- if (-not (Test-Path $dirPath -PathType Container)) {
457
- $report += @{ Status = "FAIL"; Detail = "$dir/ (diretorio nao encontrado)" }
458
- $fails++
459
- } else {
460
- $mdCount = (Get-ChildItem -Path $dirPath -Filter "*.md" -File -ErrorAction SilentlyContinue).Count
461
- if ($mdCount -eq 0) {
462
- $report += @{ Status = "WARN"; Detail = "$dir/ (vazio - nenhum arquivo .md)" }
463
- $warns++
495
+ if ($LOCAL_MODE) {
496
+ # --- Layer 3: Step directories (local mode only) ---
497
+ foreach ($dir in @("steps-c", "steps-e", "steps-p", "steps-r", "steps-u")) {
498
+ $dirPath = Join-Path $script:DestDir $dir
499
+ if (-not (Test-Path $dirPath -PathType Container)) {
500
+ $report += @{ Status = "FAIL"; Detail = "$dir/ (diretorio nao encontrado)" }
501
+ $fails++
464
502
  } else {
465
- $report += @{ Status = "OK"; Detail = "$dir/ ($mdCount arquivos)" }
503
+ $mdCount = (Get-ChildItem -Path $dirPath -Filter "*.md" -File -ErrorAction SilentlyContinue).Count
504
+ if ($mdCount -eq 0) {
505
+ $report += @{ Status = "WARN"; Detail = "$dir/ (vazio - nenhum arquivo .md)" }
506
+ $warns++
507
+ } else {
508
+ $report += @{ Status = "OK"; Detail = "$dir/ ($mdCount arquivos)" }
509
+ }
466
510
  }
467
511
  }
468
- }
469
512
 
470
- # --- Layer 3b: Core directory ---
471
- $corePath = Join-Path $script:DestDir "core"
472
- if (-not (Test-Path $corePath -PathType Container)) {
473
- $report += @{ Status = "FAIL"; Detail = "core/ (diretorio nao encontrado)" }
474
- $fails++
513
+ # --- Layer 3b: Core directory (local mode only) ---
514
+ $corePath = Join-Path $script:DestDir "core"
515
+ if (-not (Test-Path $corePath -PathType Container)) {
516
+ $report += @{ Status = "FAIL"; Detail = "core/ (diretorio nao encontrado)" }
517
+ $fails++
518
+ } else {
519
+ $report += @{ Status = "OK"; Detail = "core/" }
520
+ }
475
521
  } else {
476
- $report += @{ Status = "OK"; Detail = "core/" }
522
+ # --- Layer 3: Thin client config (remote mode) ---
523
+ $configFile = "$env:USERPROFILE\.neocortex\config.json"
524
+ if (Test-Path $configFile -PathType Leaf) {
525
+ $report += @{ Status = "OK"; Detail = "~\.neocortex\config.json (thin client configurado)" }
526
+ } else {
527
+ $report += @{ Status = "WARN"; Detail = "~\.neocortex\config.json (nao encontrado)" }
528
+ $warns++
529
+ }
530
+
531
+ # Verify NO IP directories exist
532
+ $ipFound = $false
533
+ foreach ($dir in @("core", "steps-c", "steps-e", "steps-p", "steps-r", "steps-u")) {
534
+ if (Test-Path (Join-Path $script:DestDir $dir) -PathType Container) {
535
+ $report += @{ Status = "WARN"; Detail = "$dir/ ainda existe (deveria ter sido removido)" }
536
+ $warns++
537
+ $ipFound = $true
538
+ }
539
+ }
540
+ if (-not $ipFound) {
541
+ $report += @{ Status = "OK"; Detail = "Zero IP no filesystem (modo remoto)" }
542
+ }
477
543
  }
478
544
 
479
545
  # --- Display report ---
@@ -503,47 +569,9 @@ function Verify-Installation {
503
569
  }
504
570
 
505
571
  # =============================================================================
506
- # TIER 3: CLEANUP DE IP LEGADA E CONFIG DO THIN CLIENT
572
+ # TIER 3: CONFIG DO THIN CLIENT
507
573
  # =============================================================================
508
574
 
509
- function Remove-LegacyIP {
510
- $neocortexDir = "$env:USERPROFILE\.claude\agents\neocortex"
511
- $skillsDir = "$env:USERPROFILE\.claude\skills\neocortex"
512
- $cleaned = $false
513
-
514
- # Remover core/ e seus subdiretorios
515
- if (Test-Path "$neocortexDir\core") {
516
- Remove-Item -Path "$neocortexDir\core" -Recurse -Force -ErrorAction SilentlyContinue
517
- $cleaned = $true
518
- }
519
-
520
- # Remover step folders
521
- foreach ($folder in @("steps-c", "steps-e", "steps-p", "steps-r", "steps-u")) {
522
- if (Test-Path "$neocortexDir\$folder") {
523
- Remove-Item -Path "$neocortexDir\$folder" -Recurse -Force -ErrorAction SilentlyContinue
524
- $cleaned = $true
525
- }
526
- }
527
-
528
- # Remover skills
529
- if (Test-Path $skillsDir) {
530
- Remove-Item -Path $skillsDir -Recurse -Force -ErrorAction SilentlyContinue
531
- $cleaned = $true
532
- }
533
-
534
- # Remover arquivos desnecessarios
535
- foreach ($file in @("package.json", "README.md")) {
536
- if (Test-Path "$neocortexDir\$file") {
537
- Remove-Item -Path "$neocortexDir\$file" -Force -ErrorAction SilentlyContinue
538
- $cleaned = $true
539
- }
540
- }
541
-
542
- if ($cleaned) {
543
- Write-Info "IP proprietaria removida de versao anterior (agora servida via server remoto)"
544
- }
545
- }
546
-
547
575
  function Set-ThinClientConfig {
548
576
  $configDir = "$env:USERPROFILE\.neocortex"
549
577
  $configFile = "$configDir\config.json"
@@ -584,41 +612,8 @@ function Set-ThinClientConfig {
584
612
  Write-Dbg "Thin client config criada: $configFile"
585
613
  }
586
614
 
587
- function Remove-LegacyIPProject {
588
- param([string]$ProjectDir)
589
-
590
- $neocortexDir = "$ProjectDir\.claude\agents\neocortex"
591
- $skillsDir = "$ProjectDir\.claude\skills\neocortex"
592
- $cleaned = $false
593
-
594
- if (Test-Path "$neocortexDir\core") {
595
- Remove-Item -Path "$neocortexDir\core" -Recurse -Force -ErrorAction SilentlyContinue
596
- $cleaned = $true
597
- }
598
-
599
- foreach ($folder in @("steps-c", "steps-e", "steps-p", "steps-r", "steps-u")) {
600
- if (Test-Path "$neocortexDir\$folder") {
601
- Remove-Item -Path "$neocortexDir\$folder" -Recurse -Force -ErrorAction SilentlyContinue
602
- $cleaned = $true
603
- }
604
- }
605
-
606
- if (Test-Path $skillsDir) {
607
- Remove-Item -Path $skillsDir -Recurse -Force -ErrorAction SilentlyContinue
608
- $cleaned = $true
609
- }
610
-
611
- foreach ($file in @("package.json", "README.md")) {
612
- if (Test-Path "$neocortexDir\$file") {
613
- Remove-Item -Path "$neocortexDir\$file" -Force -ErrorAction SilentlyContinue
614
- $cleaned = $true
615
- }
616
- }
617
-
618
- if ($cleaned) {
619
- Write-Info "IP proprietaria removida do projeto (agora servida via server remoto)"
620
- }
621
- }
615
+ # Remove-LegacyIPProject substituida por Invoke-AutoCleanupLegacyProject
616
+ # (definida na secao de limpeza automatica acima)
622
617
 
623
618
  # =============================================================================
624
619
  # INSTALACAO CORE
@@ -654,7 +649,7 @@ function Install-Core {
654
649
  Copy-Silent "$($script:SourceDir)\README.md" "$script:DestDir\" | Out-Null
655
650
  } else {
656
651
  # Tier 3 Remote Mode: NAO copiar IP
657
- Remove-LegacyIP
652
+ # Nota: Invoke-AutoCleanupLegacy ja rodou no inicio - aqui apenas config
658
653
  Set-ThinClientConfig
659
654
  }
660
655
 
@@ -1239,7 +1234,7 @@ function New-ProjectDirectories {
1239
1234
  }
1240
1235
  } else {
1241
1236
  # Tier 3 Remote Mode: limpar IP de versoes anteriores no projeto
1242
- Remove-LegacyIPProject -ProjectDir $projectDir
1237
+ Invoke-AutoCleanupLegacyProject -ProjectDir $projectDir
1243
1238
  }
1244
1239
  $targetSummary += "claude-code"
1245
1240
  }
@@ -1379,9 +1374,20 @@ function Show-Result {
1379
1374
  Write-Host ""
1380
1375
  Write-Host " Instalacao concluida!" -ForegroundColor Green
1381
1376
  Write-Host ""
1382
- Write-Host " Locais:" -ForegroundColor DarkGray
1383
- Write-Host " Agente: ~\.claude\agents\neocortex\" -ForegroundColor DarkGray
1384
- Write-Host " Skills: ~\.claude\skills\neocortex\" -ForegroundColor DarkGray
1377
+ if ($LOCAL_MODE) {
1378
+ Write-Host " Modo: Local (IP completa copiada)" -ForegroundColor DarkGray
1379
+ Write-Host " Locais:" -ForegroundColor DarkGray
1380
+ Write-Host " Agente: ~\.claude\agents\neocortex\" -ForegroundColor DarkGray
1381
+ Write-Host " Skills: ~\.claude\skills\neocortex\" -ForegroundColor DarkGray
1382
+ } else {
1383
+ Write-Host " Modo: Remoto (Tier 3 - thin client)" -ForegroundColor DarkGray
1384
+ Write-Host " Locais:" -ForegroundColor DarkGray
1385
+ Write-Host " Agente: ~\.claude\agents\neocortex\ (3 arquivos)" -ForegroundColor DarkGray
1386
+ Write-Host " Config: ~\.neocortex\config.json" -ForegroundColor DarkGray
1387
+ Write-Host ""
1388
+ Write-Host " Ative sua licenca:" -ForegroundColor DarkGray
1389
+ Write-Host " npx @ornexus/neocortex-client activate NX-PRO-xxx" -ForegroundColor Cyan
1390
+ }
1385
1391
  Write-Host ""
1386
1392
  Write-Host " Proximo passo:" -ForegroundColor DarkGray
1387
1393
  Write-Host " @neocortex *init @docs/epics.md" -ForegroundColor Cyan
@@ -1407,8 +1413,6 @@ function Show-Result {
1407
1413
  Show-Banner
1408
1414
  Get-SourceDirectory
1409
1415
  Test-OldInstallation
1410
- Test-LegacyArtifacts | Out-Null
1411
- Invoke-CleanupLegacy
1412
1416
 
1413
1417
  # Determine targets
1414
1418
  if ($Targets) {
@@ -1427,11 +1431,15 @@ if ($Targets) {
1427
1431
 
1428
1432
  Write-Dbg "Targets: $($script:SelectedTargets -join ', ')"
1429
1433
 
1430
- $totalSteps = 3
1431
- if ($script:SelectedTargets -contains "claude-code") { $totalSteps = 5 }
1434
+ $totalSteps = 4
1435
+ if ($script:SelectedTargets -contains "claude-code") { $totalSteps = 6 }
1436
+
1437
+ # Step 1: Limpeza automatica de versoes anteriores
1438
+ Write-Step 1 $totalSteps "Limpeza de versoes anteriores"
1439
+ Invoke-AutoCleanupLegacy
1432
1440
 
1433
- # Step 1: Core
1434
- Write-Step 1 $totalSteps "Instalando core"
1441
+ # Step 2: Core
1442
+ Write-Step 2 $totalSteps "Instalando core"
1435
1443
  $coreSuccess = Install-Core
1436
1444
 
1437
1445
  if (-not $coreSuccess) {
@@ -1439,23 +1447,23 @@ if (-not $coreSuccess) {
1439
1447
  exit 1
1440
1448
  }
1441
1449
 
1442
- # Step 2: Skills
1443
- Write-Step 2 $totalSteps "Instalando skills"
1450
+ # Step 3: Skills
1451
+ Write-Step 3 $totalSteps "Instalando skills"
1444
1452
  Install-Skills | Out-Null
1445
1453
 
1446
- # Step 3: Targets
1447
- Write-Step 3 $totalSteps "Instalando $($script:SelectedTargets.Count) plataforma(s)"
1454
+ # Step 4: Targets
1455
+ Write-Step 4 $totalSteps "Instalando $($script:SelectedTargets.Count) plataforma(s)"
1448
1456
  Install-Targets -TargetList $script:SelectedTargets
1449
1457
 
1450
- # Step 4-5: Claude Code extras
1458
+ # Step 5-6: Claude Code extras
1451
1459
  if ($script:SelectedTargets -contains "claude-code") {
1452
1460
  Import-EnvFile | Out-Null
1453
1461
  Request-Tokens
1454
1462
 
1455
- Write-Step 4 $totalSteps "Configurando MCPs"
1463
+ Write-Step 5 $totalSteps "Configurando MCPs"
1456
1464
  Install-MCPs
1457
1465
 
1458
- Write-Step 5 $totalSteps "Verificando ferramentas"
1466
+ Write-Step 6 $totalSteps "Verificando ferramentas"
1459
1467
  Install-CodeRabbit
1460
1468
  }
1461
1469
 
package/install.sh CHANGED
@@ -4,7 +4,7 @@
4
4
  # Epic & Story Development Orchestrator
5
5
 
6
6
  # Versao do instalador
7
- VERSION="3.8.1"
7
+ VERSION="3.8.2"
8
8
 
9
9
  # Flags
10
10
  MIGRATION_DETECTED=false
@@ -74,7 +74,7 @@ while [[ $# -gt 0 ]]; do
74
74
  echo " --create-project Instalar estrutura no projeto"
75
75
  echo " -s, --skip-project Nao perguntar sobre projeto"
76
76
  echo " -q, --quiet Modo silencioso"
77
- echo " --cleanup-legacy Remover artefatos legados de ~/.claude/"
77
+ echo " --cleanup-legacy (Redundante) Limpeza agora e automatica"
78
78
  echo " --local Modo local (copia IP para desenvolvimento)"
79
79
  echo " --server-url=<url> URL do server Neocortex (padrao: api.neocortex.ornexus.com)"
80
80
  echo " -d, --debug Modo debug"
@@ -240,165 +240,172 @@ detect_old_installation() {
240
240
  fi
241
241
  }
242
242
 
243
- detect_legacy_artifacts() {
244
- local warnings=0
245
- local legacy_items=""
246
- local claude_dir="$HOME/.claude"
243
+ # =============================================================================
244
+ # LIMPEZA AUTOMATICA DE ARTEFATOS LEGADOS (auto_cleanup_legacy)
245
+ # Unifica: detect_legacy_artifacts + cleanup_legacy_artifacts + cleanup_legacy_ip
246
+ # + cleanup_legacy_ip_project + npm globals + cross-platform cleanup
247
+ # Roda AUTOMATICAMENTE a cada instalacao - sem necessidade de --cleanup-legacy
248
+ # Idempotente: rodar multiplas vezes sem efeitos colaterais
249
+ # Seguro: NAO remove dados do usuario (stories, epics, state.json, config.json)
250
+ # =============================================================================
247
251
 
248
- debug "Verificando artefatos legados em ~/.claude/..."
252
+ auto_cleanup_legacy() {
253
+ local removed=0
254
+ local claude_dir="$HOME/.claude"
255
+ local neocortex_dir="$claude_dir/agents/neocortex"
256
+ local skills_dir="$claude_dir/skills/neocortex"
257
+
258
+ debug "Executando limpeza automatica de artefatos legados..."
259
+
260
+ # ─── Helper: remove e loga ───────────────────────────────────────────
261
+ _remove_legacy() {
262
+ local target="$1"
263
+ local label="$2"
264
+ if [ -e "$target" ]; then
265
+ local display="${target/#$HOME/~}"
266
+ if rm -rf "$target" 2>/dev/null; then
267
+ info "Removido: $display ($label)"
268
+ removed=$((removed + 1))
269
+ else
270
+ debug "Falha ao remover: $display"
271
+ fi
272
+ fi
273
+ }
274
+
275
+ # ─── Categoria 1: Pacotes NPM globais legados ────────────────────────
276
+ if command -v npm >/dev/null 2>&1; then
277
+ # Verificar e remover pacotes npm globais legados
278
+ for pkg in "@ornexus/neocortex-cli" "@ornexus-ai/neocortex"; do
279
+ if npm list -g "$pkg" --depth=0 2>/dev/null | grep -q "$pkg"; then
280
+ if npm uninstall -g "$pkg" 2>/dev/null; then
281
+ info "Removido: $pkg (pacote npm global legado)"
282
+ removed=$((removed + 1))
283
+ else
284
+ debug "Falha ao remover pacote npm: $pkg"
285
+ fi
286
+ fi
287
+ done
249
288
 
250
- # Check 1: .git inside agents/ (leftover from contains-studio/agents repo)
251
- if [ -d "$claude_dir/agents/.git" ]; then
252
- warn "Repositorio .git detectado em ~/.claude/agents/"
253
- info "Pode conflitar com instalacoes do Neocortex"
254
- info "Execute com --cleanup-legacy para remover"
255
- legacy_items="${legacy_items}${claude_dir}/agents/.git
256
- "
257
- warnings=$((warnings + 1))
289
+ # Verificar binario neocortex-cli no PATH
290
+ local ncli_path
291
+ ncli_path=$(command -v neocortex-cli 2>/dev/null || true)
292
+ if [ -n "$ncli_path" ]; then
293
+ # Verificar se e um link/binario npm (nao remover se for outro tool)
294
+ if [[ "$ncli_path" == *"node_modules"* ]] || [[ "$ncli_path" == *"npm"* ]]; then
295
+ rm -f "$ncli_path" 2>/dev/null && {
296
+ info "Removido: $ncli_path (binario neocortex-cli legado)"
297
+ removed=$((removed + 1))
298
+ }
299
+ fi
300
+ fi
258
301
  fi
259
302
 
260
- # Check 2: Nested .claude/.claude/ (BMAD installation error)
261
- if [ -d "$claude_dir/.claude" ]; then
262
- warn "Diretorio aninhado detectado: ~/.claude/.claude/"
263
- info "Possivelmente erro de instalacao anterior (BMAD)"
264
- info "Execute com --cleanup-legacy para remover"
265
- legacy_items="${legacy_items}${claude_dir}/.claude
266
- "
267
- warnings=$((warnings + 1))
268
- fi
303
+ # ─── Categoria 2: Claude Code (~/.claude/) ────────────────────────────
304
+ # IP proprietaria de versoes anteriores
305
+ _remove_legacy "$neocortex_dir/core" "IP legada"
306
+ _remove_legacy "$skills_dir" "skills legadas"
307
+ _remove_legacy "$neocortex_dir/workflow.md" "workflow removido no Tier 3"
308
+ _remove_legacy "$neocortex_dir/package.json" "arquivo desnecessario"
309
+ _remove_legacy "$neocortex_dir/README.md" "arquivo desnecessario"
269
310
 
270
- # Check 3: Loose agents without namespace (files directly in agents/, not in subdirs)
271
- local loose_count=0
272
- if [ -d "$claude_dir/agents" ]; then
273
- for f in "$claude_dir/agents"/*.md; do
274
- [ -f "$f" ] || continue
275
- loose_count=$((loose_count + 1))
276
- debug " Solto: $(basename "$f")"
277
- done
278
- fi
279
- if [ $loose_count -gt 0 ]; then
280
- info "$loose_count arquivo(s) .md solto(s) em ~/.claude/agents/"
281
- info "Considere organizar em namespaces (ex: agents/neocortex/)"
282
- warnings=$((warnings + 1))
283
- fi
284
-
285
- # Check 4: Legacy agents-ldtn/ directory
286
- if [ -d "$claude_dir/agents-ldtn" ]; then
287
- warn "Diretorio legado detectado: ~/.claude/agents-ldtn/"
288
- info "Execute com --cleanup-legacy para remover"
289
- legacy_items="${legacy_items}${claude_dir}/agents-ldtn
290
- "
291
- warnings=$((warnings + 1))
292
- fi
311
+ # Step folders legados
312
+ for folder in steps-c steps-e steps-p steps-r steps-u; do
313
+ _remove_legacy "$neocortex_dir/$folder" "steps legados"
314
+ done
293
315
 
294
- # Check 5: .superclaude-metadata.json
295
- if [ -f "$claude_dir/.superclaude-metadata.json" ]; then
296
- warn "Metadata legado detectado: ~/.claude/.superclaude-metadata.json"
297
- info "Execute com --cleanup-legacy para remover"
298
- legacy_items="${legacy_items}${claude_dir}/.superclaude-metadata.json
299
- "
300
- warnings=$((warnings + 1))
301
- fi
316
+ # Artefatos de instalacoes anteriores
317
+ _remove_legacy "$claude_dir/agents/.git" "repo git antigo"
318
+ _remove_legacy "$claude_dir/.claude" "diretorio aninhado (erro BMAD)"
319
+ _remove_legacy "$claude_dir/agents-ldtn" "diretorio legado"
320
+ _remove_legacy "$claude_dir/.superclaude-metadata.json" "metadata SuperClaude"
302
321
 
303
- # Check 6: superclaude_backup_*.tar.gz in backups/
304
- local backup_count=0
322
+ # Backups SuperClaude antigos
305
323
  if [ -d "$claude_dir/backups" ]; then
306
324
  for f in "$claude_dir/backups"/superclaude_backup_*.tar.gz; do
307
325
  [ -f "$f" ] || continue
308
- backup_count=$((backup_count + 1))
326
+ _remove_legacy "$f" "backup SuperClaude antigo"
309
327
  done
310
328
  fi
311
- if [ $backup_count -gt 0 ]; then
312
- info "$backup_count backup(s) SuperClaude antigo(s) em ~/.claude/backups/"
313
- warnings=$((warnings + 1))
329
+
330
+ # ─── Categoria 3: Cursor ──────────────────────────────────────────────
331
+ _remove_legacy "$HOME/.cursor/neocortex" "configs Cursor legadas"
332
+ # .cursorrules com referencias neocortex (verificar antes de remover)
333
+ if [ -f "$HOME/.cursorrules" ]; then
334
+ if grep -qi "neocortex\|ornexus\|synapse" "$HOME/.cursorrules" 2>/dev/null; then
335
+ _remove_legacy "$HOME/.cursorrules" "cursorrules com refs legadas"
336
+ fi
314
337
  fi
315
338
 
316
- if [ $warnings -gt 0 ]; then
317
- warn "$warnings artefato(s) legado(s) detectado(s)"
339
+ # ─── Categoria 4: VS Code ─────────────────────────────────────────────
340
+ _remove_legacy "$HOME/.vscode/neocortex" "configs VS Code legadas"
341
+ # .instructions.md com referencias neocortex antigo
342
+ if [ -f "$HOME/.instructions.md" ]; then
343
+ if grep -qi "neocortex\|ornexus\|synapse" "$HOME/.instructions.md" 2>/dev/null; then
344
+ _remove_legacy "$HOME/.instructions.md" "instructions.md com refs legadas"
345
+ fi
318
346
  fi
319
347
 
320
- # Export for cleanup (newline-separated for paths with spaces)
321
- LEGACY_ITEMS="$legacy_items"
322
- LEGACY_WARNINGS=$warnings
348
+ # ─── Categoria 5: Gemini CLI ──────────────────────────────────────────
349
+ _remove_legacy "$HOME/.gemini/neocortex" "configs Gemini legadas"
323
350
 
324
- return 0 # Never block installation
325
- }
351
+ # ─── Categoria 6: Codex ───────────────────────────────────────────────
352
+ _remove_legacy "$HOME/.codex/neocortex" "configs Codex legadas"
326
353
 
327
- cleanup_legacy_artifacts() {
328
- # Only run if --cleanup-legacy was passed
329
- if [ "$CLEANUP_LEGACY" != true ]; then
330
- return 0
331
- fi
354
+ # ─── Categoria 7: Antigravity ─────────────────────────────────────────
355
+ # Configs legadas de Antigravity sao gerenciadas pelo adapter, sem path fixo global
332
356
 
333
- # Check if there are items to clean
334
- if [ $LEGACY_WARNINGS -eq 0 ] || [ -z "$LEGACY_ITEMS" ]; then
335
- info "Nenhum artefato legado encontrado para limpeza"
336
- return 0
357
+ # ─── Resultado ────────────────────────────────────────────────────────
358
+ if [ $removed -gt 0 ]; then
359
+ ok "$removed artefato(s) legado(s) removido(s) automaticamente"
360
+ else
361
+ debug "Nenhum artefato legado encontrado"
337
362
  fi
338
363
 
339
- # Safety: refuse cleanup in --yes mode (protect against automated deletion)
340
- if [ "$AUTO_YES" = true ]; then
341
- warn "Cleanup requer confirmacao interativa (--yes ignorado para seguranca)"
342
- return 0
343
- fi
364
+ # Resetar contadores legados (compatibilidade)
365
+ LEGACY_ITEMS=""
366
+ LEGACY_WARNINGS=0
344
367
 
345
- # Show what will be removed
346
- echo ""
347
- warn "Os seguintes artefatos serao removidos:"
348
- local item_count=0
349
- while IFS= read -r item; do
350
- [ -z "$item" ] && continue
351
- local display_item="${item/#$HOME/~}"
352
- if [ -d "$item" ]; then
353
- info " - ${display_item}/ (diretorio)"
354
- else
355
- info " - ${display_item} (arquivo)"
356
- fi
357
- item_count=$((item_count + 1))
358
- done <<EOF
359
- $LEGACY_ITEMS
360
- EOF
368
+ return 0
369
+ }
361
370
 
362
- echo -ne " Confirmar remocao? ${BOLD}[s/N]:${NC} "
371
+ # Cleanup de IP legada em projetos individuais (project-level)
372
+ auto_cleanup_legacy_project() {
373
+ local project_dir="$1"
374
+ local neocortex_dir="$project_dir/.claude/agents/neocortex"
375
+ local skills_dir="$project_dir/.claude/skills/neocortex"
376
+ local cleaned=false
363
377
 
364
- local response=""
365
- if read -r -t 30 response 2>/dev/null; then
366
- : # response received
367
- else
368
- echo ""
369
- info "Timeout - cleanup cancelado"
370
- return 0
378
+ # Remover core/ e seus subdiretorios
379
+ if [ -d "$neocortex_dir/core" ]; then
380
+ rm -rf "$neocortex_dir/core"
381
+ cleaned=true
371
382
  fi
372
383
 
373
- if [[ ! "$response" =~ ^([sS][iI]?[mM]?|[yY][eE]?[sS]?)$ ]]; then
374
- info "Cleanup cancelado"
375
- return 0
384
+ # Remover step folders
385
+ for folder in steps-c steps-e steps-p steps-r steps-u; do
386
+ if [ -d "$neocortex_dir/$folder" ]; then
387
+ rm -rf "$neocortex_dir/$folder"
388
+ cleaned=true
389
+ fi
390
+ done
391
+
392
+ # Remover skills
393
+ if [ -d "$skills_dir" ]; then
394
+ rm -rf "$skills_dir"
395
+ cleaned=true
376
396
  fi
377
397
 
378
- # Execute cleanup
379
- local removed=0
380
- local failed=0
381
- while IFS= read -r item; do
382
- [ -z "$item" ] && continue
383
- local display_item="${item/#$HOME/~}"
384
- if rm -rf "$item" 2>/dev/null; then
385
- ok "Removido: $display_item"
386
- removed=$((removed + 1))
387
- else
388
- fail "Falha ao remover: $display_item"
389
- failed=$((failed + 1))
398
+ # Remover arquivos desnecessarios
399
+ for file in package.json README.md workflow.md; do
400
+ if [ -f "$neocortex_dir/$file" ]; then
401
+ rm -f "$neocortex_dir/$file"
402
+ cleaned=true
390
403
  fi
391
- done <<EOF
392
- $LEGACY_ITEMS
393
- EOF
404
+ done
394
405
 
395
- if [ $failed -eq 0 ]; then
396
- ok "$removed artefato(s) removido(s) com sucesso"
397
- else
398
- warn "$removed removido(s), $failed falha(s)"
406
+ if [ "$cleaned" = true ]; then
407
+ info "IP proprietaria removida do projeto (agora servida via server remoto)"
399
408
  fi
400
-
401
- return 0
402
409
  }
403
410
 
404
411
  detect_project_migration_needs() {
@@ -491,47 +498,9 @@ detect_source_dir() {
491
498
  }
492
499
 
493
500
  # =============================================================================
494
- # TIER 3: CLEANUP DE IP LEGADA E CONFIG DO THIN CLIENT
501
+ # TIER 3: CONFIG DO THIN CLIENT
495
502
  # =============================================================================
496
503
 
497
- cleanup_legacy_ip() {
498
- local neocortex_dir="${HOME}/.claude/agents/neocortex"
499
- local skills_dir="${HOME}/.claude/skills/neocortex"
500
- local cleaned=false
501
-
502
- # Remover core/ e seus subdiretorios
503
- if [ -d "$neocortex_dir/core" ]; then
504
- rm -rf "$neocortex_dir/core"
505
- cleaned=true
506
- fi
507
-
508
- # Remover step folders (steps-c, steps-e, steps-p, steps-r, steps-u)
509
- for folder in steps-c steps-e steps-p steps-r steps-u; do
510
- if [ -d "$neocortex_dir/$folder" ]; then
511
- rm -rf "$neocortex_dir/$folder"
512
- cleaned=true
513
- fi
514
- done
515
-
516
- # Remover skills
517
- if [ -d "$skills_dir" ]; then
518
- rm -rf "$skills_dir"
519
- cleaned=true
520
- fi
521
-
522
- # Remover arquivos desnecessarios
523
- for file in package.json README.md; do
524
- if [ -f "$neocortex_dir/$file" ]; then
525
- rm -f "$neocortex_dir/$file"
526
- cleaned=true
527
- fi
528
- done
529
-
530
- if [ "$cleaned" = true ]; then
531
- info "IP proprietaria removida de versao anterior (agora servida via server remoto)"
532
- fi
533
- }
534
-
535
504
  setup_thin_client_config() {
536
505
  local config_dir="${HOME}/.neocortex"
537
506
  local config_file="${config_dir}/config.json"
@@ -575,44 +544,8 @@ EOFCONFIG
575
544
  debug "Thin client config criada: $config_file"
576
545
  }
577
546
 
578
- cleanup_legacy_ip_project() {
579
- local project_dir="$1"
580
- local neocortex_dir="$project_dir/.claude/agents/neocortex"
581
- local skills_dir="$project_dir/.claude/skills/neocortex"
582
- local cleaned=false
583
-
584
- # Remover core/ e seus subdiretorios
585
- if [ -d "$neocortex_dir/core" ]; then
586
- rm -rf "$neocortex_dir/core"
587
- cleaned=true
588
- fi
589
-
590
- # Remover step folders
591
- for folder in steps-c steps-e steps-p steps-r steps-u; do
592
- if [ -d "$neocortex_dir/$folder" ]; then
593
- rm -rf "$neocortex_dir/$folder"
594
- cleaned=true
595
- fi
596
- done
597
-
598
- # Remover skills
599
- if [ -d "$skills_dir" ]; then
600
- rm -rf "$skills_dir"
601
- cleaned=true
602
- fi
603
-
604
- # Remover arquivos desnecessarios
605
- for file in package.json README.md; do
606
- if [ -f "$neocortex_dir/$file" ]; then
607
- rm -f "$neocortex_dir/$file"
608
- cleaned=true
609
- fi
610
- done
611
-
612
- if [ "$cleaned" = true ]; then
613
- info "IP proprietaria removida do projeto (agora servida via server remoto)"
614
- fi
615
- }
547
+ # cleanup_legacy_ip_project() substituida por auto_cleanup_legacy_project()
548
+ # (definida na secao de limpeza automatica acima)
616
549
 
617
550
  # =============================================================================
618
551
  # INSTALACAO CORE
@@ -654,7 +587,7 @@ install_core() {
654
587
  else
655
588
  # Tier 3 Remote Mode: NÃO copiar IP
656
589
  # Apenas setup do thin client - steps/skills/standards vem do server
657
- cleanup_legacy_ip
590
+ # Nota: auto_cleanup_legacy() ja rodou no inicio - aqui apenas config
658
591
  setup_thin_client_config
659
592
  fi
660
593
 
@@ -1250,7 +1183,7 @@ create_project_dirs() {
1250
1183
  fi
1251
1184
  else
1252
1185
  # Tier 3 Remote Mode: limpar IP de versoes anteriores no projeto
1253
- cleanup_legacy_ip_project "$project_dir"
1186
+ auto_cleanup_legacy_project "$project_dir"
1254
1187
  fi
1255
1188
  target_summary="${target_summary}claude-code, "
1256
1189
  fi
@@ -1335,14 +1268,12 @@ show_migration_info() {
1335
1268
  # MAIN
1336
1269
  # =============================================================================
1337
1270
 
1338
- TOTAL_STEPS=3
1271
+ TOTAL_STEPS=4
1339
1272
 
1340
1273
  main() {
1341
1274
  show_banner
1342
1275
  detect_source_dir
1343
1276
  detect_old_installation
1344
- detect_legacy_artifacts
1345
- cleanup_legacy_artifacts
1346
1277
 
1347
1278
  # Determine targets
1348
1279
  if [ -z "$SELECTED_TARGETS" ]; then
@@ -1366,11 +1297,15 @@ main() {
1366
1297
  # Count targets for step total
1367
1298
  local target_count=$(echo "$SELECTED_TARGETS" | tr ',' ' ' | wc -w | tr -d ' ')
1368
1299
  if echo "$SELECTED_TARGETS" | grep -q "claude-code"; then
1369
- TOTAL_STEPS=5 # core + skills + targets + mcps + tools
1300
+ TOTAL_STEPS=6 # cleanup + core + skills + targets + mcps + tools
1370
1301
  fi
1371
1302
 
1372
- # Step 1: Core
1373
- step 1 $TOTAL_STEPS "Instalando core"
1303
+ # Step 1: Limpeza automatica de versoes anteriores
1304
+ step 1 $TOTAL_STEPS "Limpeza de versoes anteriores"
1305
+ auto_cleanup_legacy
1306
+
1307
+ # Step 2: Core
1308
+ step 2 $TOTAL_STEPS "Instalando core"
1374
1309
  install_core
1375
1310
  local core_result=$?
1376
1311
  if [ $core_result -ne 0 ]; then
@@ -1378,23 +1313,23 @@ main() {
1378
1313
  exit 1
1379
1314
  fi
1380
1315
 
1381
- # Step 2: Skills
1382
- step 2 $TOTAL_STEPS "Instalando skills"
1316
+ # Step 3: Skills
1317
+ step 3 $TOTAL_STEPS "Instalando skills"
1383
1318
  install_skills
1384
1319
 
1385
- # Step 3: Targets
1386
- step 3 $TOTAL_STEPS "Instalando ${BOLD}$target_count${NC} plataforma(s)"
1320
+ # Step 4: Targets
1321
+ step 4 $TOTAL_STEPS "Instalando ${BOLD}$target_count${NC} plataforma(s)"
1387
1322
  install_targets "$SELECTED_TARGETS"
1388
1323
 
1389
- # Step 4-5: Claude Code extras
1324
+ # Step 5-6: Claude Code extras
1390
1325
  if echo "$SELECTED_TARGETS" | grep -q "claude-code"; then
1391
1326
  load_env_file
1392
1327
  prompt_tokens
1393
1328
 
1394
- step 4 $TOTAL_STEPS "Configurando MCPs"
1329
+ step 5 $TOTAL_STEPS "Configurando MCPs"
1395
1330
  install_mcps
1396
1331
 
1397
- step 5 $TOTAL_STEPS "Verificando ferramentas"
1332
+ step 6 $TOTAL_STEPS "Verificando ferramentas"
1398
1333
  install_coderabbit
1399
1334
  fi
1400
1335
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ornexus/neocortex",
3
- "version": "3.8.1",
4
- "description": "Neocortex v3.8.1 - Orquestrador de Desenvolvimento de Epics & Stories para Claude Code",
3
+ "version": "3.8.2",
4
+ "description": "Neocortex v3.8.2 - Orquestrador de Desenvolvimento de Epics & Stories para Claude Code",
5
5
  "keywords": [
6
6
  "claude",
7
7
  "claude-code",