VERSION 6.02.03

This commit is contained in:
2026-03-05 08:37:05 -06:00
parent eaa185bb6d
commit 60aa115e24
26 changed files with 834 additions and 2921 deletions

View File

@@ -1,81 +1,127 @@
# SCRIPT: _juntaBas.ps1 - Versión SYSTEM PROMPT CONDICIONAL + Ultimate (Corregido)
$OutputFile="_CODIGO_COMPLETO_PARA_LLM.txt"
# SCRIPT: _juntaBas_Master_FinalIA.ps1
# FIX: Corregida sintaxis de comillas y concatenación de tags XML.
# OBJETIVO: Fuente de verdad para IA con navegación ultra estructurada.
Remove-Item -Path $OutputFile -ErrorAction SilentlyContinue
Write-Host "Generando Código Maestro con Protocolo Condicional..."
$ErrorActionPreference = 'SilentlyContinue'
$Dir = Get-Location
$LT = [char]60; $GT = [char]62; $SL = [char]47
$NL = [Environment]::NewLine
$files = Get-ChildItem -Path ".\*" -Include @("*.bas", "*.b4a", "*.j")
Write-Output '--- GENERANDO MASTER IA DEFINITIVO (FIX ESTRUCTURAL) ---'
# --- 0. INYECCIÓN DE INSTRUCCIONES DE SISTEMA (CONDICIONALES) ---
# Se han reemplazado paréntesis conflictivos y comillas internas para evitar errores de PowerShell
Add-Content -Path $OutputFile -Value "''' ======================================================================================" -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' INSTRUCCIONES CRÍTICAS PARA EL ASISTENTE (PROTOCOLO B4A)" -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' 1. CONTEXTO: Este archivo contiene el código fuente ACTUAL del proyecto." -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' 2. ANTI-ALUCINACION: Antes de sugerir propiedades, VERIFICA si existen" -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' en las secciones [Variables Globales] o [Estructuras Types] del Manifiesto abajo." -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' 3. DOCUMENTACION EXTERNA (CONDICIONAL):" -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' - SI el usuario adjunta archivos de referencia (ej. _B4X_Library... o _B4A_Library...)," -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' PRIORIZA esos métodos sobre tu conocimiento general." -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' - SI NO se adjuntan referencias, apóyate en el código existente en Subs.bas." -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' 4. SCOPE: Respeta la visibilidad (Public/Private)." -Encoding UTF8
Add-Content -Path $OutputFile -Value "''' ======================================================================================`n" -Encoding UTF8
# 1. PARSEO DEL PROYECTO .B4A
$b4a = Get-ChildItem -Path ".\*" -Include "*.b4a" -Recurse | Select-Object -First 1
$Name = 'App'; $Ver = '0.0'; $ModulosValidos = @(); $Librerias = @()
# --- 1. GENERACIÓN DEL MANIFIESTO (TABLA DE CONTENIDO) ---
Add-Content -Path $OutputFile -Value "'======================================================================================" -Encoding UTF8
Add-Content -Path $OutputFile -Value "' MANIFIESTO DEL PROYECTO - Generado el $(Get-Date -Format 'yyyy-MM-dd HH:mm')" -Encoding UTF8
Add-Content -Path $OutputFile -Value "' Total de archivos: $($files.Count)" -Encoding UTF8
Add-Content -Path $OutputFile -Value "'======================================================================================" -Encoding UTF8
foreach ($file in $files) {
$content = Get-Content $file.FullName
$ext = $file.Extension.ToLower()
$lines = $content.Count
# Extraer (Subs, Globales, Types, Libs)
$subs = $content | Where-Object { $_ -match "^\s*Sub\s+" } | ForEach-Object { $_.Trim() -replace "'.*$", "" }
$globals = $content | Where-Object { $_ -match "^\s*(Private|Public|Dim)\s+\w+\s+As" } | ForEach-Object { $_.Trim() -replace "'.*$", "" }
$types = $content | Where-Object { $_ -match "^\s*Type\s+\w+" } | ForEach-Object { $_.Trim() }
$libs = @()
if ($ext -eq ".b4a") {
$libs = $content | Where-Object { $_ -match "^Library\d+=" } | ForEach-Object { $_ -replace "^Library\d+=", "" }
if ($b4a) {
$lines = [System.IO.File]::ReadAllLines($b4a.FullName)
foreach ($L in $lines) {
if ($L -match '#ApplicationLabel:\s*(.*)') { $Name = $Matches[1].Trim() }
if ($L -match '#VersionName:\s*(.*)') { $Ver = $Matches[1].Trim() }
if ($L -match '^Module\d+=(.*)') {
$m = [System.IO.Path]::GetFileName($Matches[1].Trim())
if (-not $m.EndsWith(".bas") -and $m -ne "Main") { $m += ".bas" }
$ModulosValidos += $m
}
if ($L -match '^Library\d+=(.*)') { $Librerias += $Matches[1].Trim() }
}
# Escribir Manifiesto
Add-Content -Path $OutputFile -Value "' [ ] Archivo: $($file.Name) ($lines líneas)" -Encoding UTF8
if ($libs) {
Add-Content -Path $OutputFile -Value "' --- Librerías Activas ---" -Encoding UTF8
foreach ($l in $libs) { Add-Content -Path $OutputFile -Value "' [LIB] $l" -Encoding UTF8 }
}
if ($types) {
Add-Content -Path $OutputFile -Value "' --- Estructuras (Types) ---" -Encoding UTF8
foreach ($t in $types) { Add-Content -Path $OutputFile -Value "' {TYPE} $t" -Encoding UTF8 }
}
if ($globals) {
Add-Content -Path $OutputFile -Value "' --- Variables Globales ---" -Encoding UTF8
foreach ($g in $globals) { Add-Content -Path $OutputFile -Value "' . $g" -Encoding UTF8 }
}
if ($subs) {
Add-Content -Path $OutputFile -Value "' --- Subrutinas ---" -Encoding UTF8
foreach ($s in $subs) { Add-Content -Path $OutputFile -Value "' > $s" -Encoding UTF8 }
}
Add-Content -Path $OutputFile -Value "' ------------------------------------------------------------------------------------" -Encoding UTF8
}
Add-Content -Path $OutputFile -Value "' FINAL DEL MANIFIESTO`n" -Encoding UTF8
Add-Content -Path $OutputFile -Value "'======================================================================================`n" -Encoding UTF8
# --- 2. VUELCO DE CONTENIDO ---
$files | ForEach-Object {
$currentFile = $_.Name
Write-Host "Procesando: $currentFile"
Add-Content -Path $OutputFile -Value "'======================================================================================" -Encoding UTF8
Add-Content -Path $OutputFile -Value "// ARCHIVO_INICIO: ${currentFile}" -Encoding UTF8
Add-Content -Path $OutputFile -Value "'======================================================================================`n" -Encoding UTF8
Get-Content -Encoding UTF8 -Path $_.FullName -Raw | Add-Content -Path $OutputFile -Encoding UTF8
Add-Content -Path $OutputFile -Value "`n'======================================================================================" -Encoding UTF8
Add-Content -Path $OutputFile -Value "// ARCHIVO_FIN: ${currentFile}" -Encoding UTF8
Add-Content -Path $OutputFile -Value "'======================================================================================`n" -Encoding UTF8
}
Write-Host "¡Listo! Archivo $OutputFile con Instrucciones Condicionales generado (Sin Errores)."
$OutName = "_" + $Name + "_" + $Ver + "_IA.md"
$OutFile = Join-Path $Dir $OutName
# 2. HEADER CON TUS INSTRUCCIONES CRÍTICAS
$CurrentDate = Get-Date -Format 'yyyy-MM-dd HH:mm'
$Header = @"
# PROYECTO: $Name
- Version: $Ver
- Fecha: $CurrentDate
- Librerias Activas: $($Librerias -join ", ")
## INSTRUCCIONES CRITICAS (B4A / BASIC4ANDROID)
0. **Integridad del Contexto:** Antes de procesar peticiones, cuenta si el numero de modulos listados en el indice coincide con los detallados en el cuerpo.
1. **Source of Truth (Codigo):** Este archivo contiene el codigo fuente ACTUAL del proyecto.
2. **Source of Truth (Librerias):** Basa tus sugerencias en la lista de 'Librerias Activas'.
3. **Anti-Alucinacion:** Antes de sugerir, VERIFICA la 'Interfaz Pública' o el código fuente del módulo.
4. **Existencia Estricta:** Si una variable/Sub no está en el texto, NO EXISTE.
5. **Formato:** Usa bloques 'vb'.
6. **Navegacion Estructural:** Usa los tags <module>, <interface> y <method> para localizar codigo.
7. **Inferencia de Datos:** Deduce la BD solo de los strings SQL presentes.
"@
Set-Content -Path $OutFile -Value $Header -Encoding UTF8
# 3. LISTAR ARCHIVOS
$files = Get-ChildItem -Path $Dir -Include *.bas,*.b4a -Recurse | Where-Object {
$_.FullName -notmatch 'Objects' -and ($_.Extension -eq '.b4a' -or $ModulosValidos -contains $_.Name)
}
# 4. INDICE DE MODULOS
Add-Content $OutFile ($NL + "## INDICE DE MODULOS" + $NL) -Encoding UTF8
foreach ($f in $files) {
$Ref = $f.Name.Replace('.', '').Replace(' ', '-').ToLower()
Add-Content $OutFile ("- [" + $f.Name + "](#modulo-" + $Ref + ")") -Encoding UTF8
}
# 5. CODIGO FUENTE ESTRUCTURADO
Add-Content $OutFile ($NL + '## CODIGO FUENTE DETALLADO' + $NL) -Encoding UTF8
foreach ($f in $files) {
Write-Host " -> $($f.Name)... " -NoNewline
$txt = [System.IO.File]::ReadAllLines($f.FullName)
# Pre-escaneo para <interface>
$Methods = @()
foreach ($line in $txt) {
if ($line.Trim() -match '^(?:Public\s+|Private\s+)?Sub\s+([\w\d_]+)') {
$Methods += $Matches[1]
}
}
$Ref = $f.Name.Replace('.', '').Replace(' ', '-').ToLower()
Add-Content $OutFile "$NL<module name='$($f.Name)' id='modulo-$Ref'>" -Encoding UTF8
Add-Content $OutFile " <interface>" -Encoding UTF8
foreach($m in $Methods) {
Add-Content $OutFile " <method_ref name='$m' />" -Encoding UTF8
}
Add-Content $OutFile " </interface>$NL" -Encoding UTF8
Add-Content $OutFile "```vb" -Encoding UTF8
$skip = ($f.Extension -eq '.b4a')
foreach ($l in $txt) {
$trim = $l.Trim()
if ($skip) {
if ($trim.StartsWith("#") -and -not $trim.StartsWith("#Region")) { Add-Content $OutFile $l -Encoding UTF8 }
if ($l.Contains("@EndOfDesignText@")) { $skip = $false }
continue
}
# Inicio de Método
if ($trim -match '^(?:Public\s+|Private\s+)?Sub\s+([\w\d_]+)') {
Add-Content $OutFile "<method name='$($Matches[1])'>" -Encoding UTF8
}
# Limpieza de comentarios y escritura de línea
if ($trim.StartsWith("'")) {
if (-not ($trim.StartsWith("'#") -or ($trim -match 'TODO:') -or ($trim -match 'FIX:'))) { continue }
}
if (-not [string]::IsNullOrWhiteSpace($trim)) {
Add-Content $OutFile $l -Encoding UTF8
}
# Fin de Método
if ($trim -eq "End Sub") {
Add-Content $OutFile "</method>" -Encoding UTF8
}
}
Add-Content $OutFile "```$NL</module>" -Encoding UTF8
Write-Host "OK" -ForegroundColor Green
}
Write-Output ("--- FINALIZADO: " + $OutName + " ---")