mirror of
https://github.com/KeymonSoft/Intmex_Reparto_2026.git
synced 2026-04-17 12:56:12 +00:00
- Se agrego que mande la bandera de "reprogramado" - Se agrego que mande al tmp_drop fin dia, carga y envio.
127 lines
4.7 KiB
PowerShell
127 lines
4.7 KiB
PowerShell
# 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.
|
|
|
|
$ErrorActionPreference = 'SilentlyContinue'
|
|
$Dir = Get-Location
|
|
$LT = [char]60; $GT = [char]62; $SL = [char]47
|
|
$NL = [Environment]::NewLine
|
|
|
|
Write-Output '--- GENERANDO MASTER IA DEFINITIVO (FIX ESTRUCTURAL) ---'
|
|
|
|
# 1. PARSEO DEL PROYECTO .B4A
|
|
$b4a = Get-ChildItem -Path ".\*" -Include "*.b4a" -Recurse | Select-Object -First 1
|
|
$Name = 'App'; $Ver = '0.0'; $ModulosValidos = @(); $Librerias = @()
|
|
|
|
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() }
|
|
}
|
|
}
|
|
|
|
$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 + " ---") |