Feat(ADN): Implementado y ejecutado archivar:md para mover Markdowns obsoletos a histórico DB-First
This commit is contained in:
+37
-1
@@ -53,6 +53,9 @@ require_relative 'comando/backup'
|
||||
require_relative 'comando/sync'
|
||||
require_relative 'comando/triggers'
|
||||
require_relative 'comando/conocimiento'
|
||||
require_relative 'comando/cierre'
|
||||
require_relative 'comando/inicio'
|
||||
require_relative 'core/conciliador'
|
||||
|
||||
# ─── Colores para terminal ───────────────────────────────────────────────
|
||||
module Color
|
||||
@@ -707,6 +710,8 @@ class SubcomandoAyuda
|
||||
#{Color::YELLOW}generar proyecto <código>#{Color::RESET} Generar manifiesto de proyecto
|
||||
#{Color::YELLOW}backup <nodo> [--mode MODO]#{Color::RESET} Ejecutar backup seguro de un nodo
|
||||
#{Color::YELLOW}sync [ruta|fecha]#{Color::RESET} Sincronizar con API dtic-BITACORAs
|
||||
#{Color::YELLOW}inicio de jornada [presencial|remoto]#{Color::RESET} Inicio de jornada laboral
|
||||
#{Color::YELLOW}cierre de jornada [presencial|remoto]#{Color::RESET} Cierre de jornada laboral
|
||||
#{Color::YELLOW}triggers [opciones]#{Color::RESET} Gestión del motor de triggers
|
||||
#{Color::YELLOW}ayuda [subcomando]#{Color::RESET} Mostrar esta ayuda o ayuda específica
|
||||
|
||||
@@ -794,6 +799,10 @@ class ADNCLI
|
||||
end
|
||||
|
||||
subcomando = ARGV[0]
|
||||
|
||||
# Saneamiento preventivo de pendientes (con cooldown de 5 minutos para performance)
|
||||
ejecutar_saneamiento_preventivo(subcomando)
|
||||
|
||||
args = ARGV[1..-1] || []
|
||||
|
||||
case subcomando
|
||||
@@ -809,12 +818,16 @@ class ADNCLI
|
||||
ADN::SubcomandoConocimiento.new(args, @logger).ejecutar
|
||||
when 'db'
|
||||
ADN::SubcomandoDB.new(args, @logger).ejecutar
|
||||
when 'backup'
|
||||
when 'backup', 'backups'
|
||||
ADN::SubcomandoBackup.new(args, @logger).ejecutar
|
||||
when 'sync'
|
||||
ADN::SubcomandoSync.new(args, @logger).ejecutar
|
||||
when 'triggers'
|
||||
ADN::SubcomandoTriggers.new(args, @logger).ejecutar
|
||||
when 'cierre'
|
||||
ADN::SubcomandoCierre.new(args, @logger).ejecutar
|
||||
when 'inicio'
|
||||
ADN::SubcomandoInicio.new(args, @logger).ejecutar
|
||||
when 'ayuda', 'help', '-h', '--help'
|
||||
SubcomandoAyuda.new(args, @logger).ejecutar
|
||||
when 'evolucion'
|
||||
@@ -842,6 +855,29 @@ class ADNCLI
|
||||
puts "#{Color::DIM}#{e.backtrace.first}#{Color::RESET}" if ENV['ADN_DEBUG']
|
||||
exit 1
|
||||
end
|
||||
private
|
||||
|
||||
def ejecutar_saneamiento_preventivo(subcomando)
|
||||
# No sanear si es ayuda o db (para evitar bucles o lentitud en info rápida)
|
||||
return if ['ayuda', 'help', 'db', 'salud', '-h', '--help'].include?(subcomando)
|
||||
|
||||
archivo_cooldown = "/tmp/adn_sanity_cooldown"
|
||||
cooldown_segundo = 300 # 5 minutos
|
||||
|
||||
if File.exist?(archivo_cooldown)
|
||||
last_run = File.mtime(archivo_cooldown)
|
||||
return if (Time.now - last_run) < cooldown_segundo
|
||||
end
|
||||
|
||||
# Ejecutar conciliación
|
||||
begin
|
||||
# Tocamos el archivo primero para evitar que otras instancias concurrentes lo lancen
|
||||
FileUtils.touch(archivo_cooldown)
|
||||
ADN::Conciliador.new(@logger).ejecutar(silencioso: true)
|
||||
rescue => e
|
||||
@logger.advertencia("No se pudo completar el saneamiento preventivo: #{e.message}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# ─── Punto de entrada ───────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user