theus-cli-linux-arm64 0.2.84
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/LICENSE +42 -0
- package/README.md +295 -0
- package/RELEASE.json +18 -0
- package/assets/brand-official/v1.0/logo/theus-lockup-negative-official.png +0 -0
- package/assets/brand-official/v1.0/logo/theus-lockup-primary-dark-official.png +0 -0
- package/assets/fonts/satoshi/satoshi-300.woff2 +0 -0
- package/assets/fonts/satoshi/satoshi-400.woff2 +0 -0
- package/assets/fonts/satoshi/satoshi-500.woff2 +0 -0
- package/assets/fonts/satoshi/satoshi-700.woff2 +0 -0
- package/assets/fonts/satoshi/satoshi-900.woff2 +0 -0
- package/assets/windows-store/Square150x150Logo.png +0 -0
- package/assets/windows-store/Square44x44Logo.png +0 -0
- package/assets/windows-store/StoreLogo.png +0 -0
- package/assets/windows-store/theus-store-icon-master.png +0 -0
- package/bin/theus +0 -0
- package/package.json +18 -0
- package/vendor/theus-arsenal/.arsenal-nombres-ola2.json +6 -0
- package/vendor/theus-arsenal/.arsenal-nombres-ola3.json +72 -0
- package/vendor/theus-arsenal/.mailmap +2 -0
- package/vendor/theus-arsenal/.theus-plugin/marketplace.json +25 -0
- package/vendor/theus-arsenal/.theus-plugin/plugin.json +20 -0
- package/vendor/theus-arsenal/AUTHORS.md +8 -0
- package/vendor/theus-arsenal/CLEANROOM_REPLACEMENT_PLAN.md +11 -0
- package/vendor/theus-arsenal/LICENSE +26 -0
- package/vendor/theus-arsenal/PROVENANCE.md +9 -0
- package/vendor/theus-arsenal/README.md +41 -0
- package/vendor/theus-arsenal/THIRD_PARTY.md +80 -0
- package/vendor/theus-arsenal/agents/actualizador-docs.md +123 -0
- package/vendor/theus-arsenal/agents/analista-comentarios.md +53 -0
- package/vendor/theus-arsenal/agents/analista-conversaciones.md +60 -0
- package/vendor/theus-arsenal/agents/analista-tests-pr.md +53 -0
- package/vendor/theus-arsenal/agents/analista-tipos.md +49 -0
- package/vendor/theus-arsenal/agents/arquitecto-accesibilidad.md +148 -0
- package/vendor/theus-arsenal/agents/arquitecto-codigo.md +79 -0
- package/vendor/theus-arsenal/agents/arquitecto-homelab.md +90 -0
- package/vendor/theus-arsenal/agents/arquitecto-redes.md +116 -0
- package/vendor/theus-arsenal/agents/arquitecto-sistemas.md +219 -0
- package/vendor/theus-arsenal/agents/bifurcador-opensource.md +206 -0
- package/vendor/theus-arsenal/agents/cazador-fallos-silenciosos.md +58 -0
- package/vendor/theus-arsenal/agents/consultor-documentacion.md +76 -0
- package/vendor/theus-arsenal/agents/diagnosticador-redes.md +135 -0
- package/vendor/theus-arsenal/agents/ejecutor-e2e.md +96 -0
- package/vendor/theus-arsenal/agents/empaquetador-opensource.md +257 -0
- package/vendor/theus-arsenal/agents/escaner-secretos.md +196 -0
- package/vendor/theus-arsenal/agents/especialista-seo.md +70 -0
- package/vendor/theus-arsenal/agents/estratega-marketing.md +158 -0
- package/vendor/theus-arsenal/agents/evaluador-agentes.md +214 -0
- package/vendor/theus-arsenal/agents/evaluador-harness.md +217 -0
- package/vendor/theus-arsenal/agents/explorador-codigo.md +79 -0
- package/vendor/theus-arsenal/agents/extractor-specs.md +214 -0
- package/vendor/theus-arsenal/agents/generador-harness.md +139 -0
- package/vendor/theus-arsenal/agents/guia-tdd.md +99 -0
- package/vendor/theus-arsenal/agents/jefe-de-gabinete.md +162 -0
- package/vendor/theus-arsenal/agents/limpiador-refactors.md +93 -0
- package/vendor/theus-arsenal/agents/optimizador-rendimiento.md +454 -0
- package/vendor/theus-arsenal/agents/planificador-harness.md +107 -0
- package/vendor/theus-arsenal/agents/planificador.md +221 -0
- package/vendor/theus-arsenal/agents/resolutor-apps-harmonyos.md +181 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-cpp.md +98 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-dart.md +209 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-django.md +253 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-go.md +102 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-java.md +274 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-kotlin.md +128 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-pytorch.md +128 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-react.md +214 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-rust.md +156 -0
- package/vendor/theus-arsenal/agents/resolutor-builds-swift.md +169 -0
- package/vendor/theus-arsenal/agents/resolutor-builds.md +122 -0
- package/vendor/theus-arsenal/agents/revisor-bd.md +97 -0
- package/vendor/theus-arsenal/agents/revisor-codigo.md +291 -0
- package/vendor/theus-arsenal/agents/revisor-config-red.md +116 -0
- package/vendor/theus-arsenal/agents/revisor-cpp.md +80 -0
- package/vendor/theus-arsenal/agents/revisor-csharp.md +109 -0
- package/vendor/theus-arsenal/agents/revisor-django.md +168 -0
- package/vendor/theus-arsenal/agents/revisor-fastapi.md +82 -0
- package/vendor/theus-arsenal/agents/revisor-flutter.md +251 -0
- package/vendor/theus-arsenal/agents/revisor-go.md +84 -0
- package/vendor/theus-arsenal/agents/revisor-java.md +192 -0
- package/vendor/theus-arsenal/agents/revisor-kotlin.md +171 -0
- package/vendor/theus-arsenal/agents/revisor-ml.md +159 -0
- package/vendor/theus-arsenal/agents/revisor-php.md +108 -0
- package/vendor/theus-arsenal/agents/revisor-python.md +106 -0
- package/vendor/theus-arsenal/agents/revisor-react.md +166 -0
- package/vendor/theus-arsenal/agents/revisor-rust.md +102 -0
- package/vendor/theus-arsenal/agents/revisor-seguridad.md +116 -0
- package/vendor/theus-arsenal/agents/revisor-software-clinico.md +95 -0
- package/vendor/theus-arsenal/agents/revisor-swift.md +115 -0
- package/vendor/theus-arsenal/agents/revisor-typescript.md +123 -0
- package/vendor/theus-arsenal/agents/revisor-vue.md +205 -0
- package/vendor/theus-arsenal/agents/simplificador-codigo.md +55 -0
- package/vendor/theus-arsenal/commands/actualizar-docs.md +88 -0
- package/vendor/theus-arsenal/commands/actualizar-mapas-codigo.md +78 -0
- package/vendor/theus-arsenal/commands/aprender-evaluar.md +109 -0
- package/vendor/theus-arsenal/commands/aprender.md +74 -0
- package/vendor/theus-arsenal/commands/arreglar-build.md +66 -0
- package/vendor/theus-arsenal/commands/bucle-multiperspectiva.md +153 -0
- package/vendor/theus-arsenal/commands/build-cpp.md +173 -0
- package/vendor/theus-arsenal/commands/build-flutter.md +164 -0
- package/vendor/theus-arsenal/commands/build-go.md +183 -0
- package/vendor/theus-arsenal/commands/build-gradle.md +75 -0
- package/vendor/theus-arsenal/commands/build-kotlin.md +176 -0
- package/vendor/theus-arsenal/commands/build-react.md +187 -0
- package/vendor/theus-arsenal/commands/build-rust.md +187 -0
- package/vendor/theus-arsenal/commands/campana-marketing.md +125 -0
- package/vendor/theus-arsenal/commands/checkpoint.md +78 -0
- package/vendor/theus-arsenal/commands/cobertura-tests.md +73 -0
- package/vendor/theus-arsenal/commands/configurar-gestor-paquetes.md +86 -0
- package/vendor/theus-arsenal/commands/consulta.md +164 -0
- package/vendor/theus-arsenal/commands/control-calidad.md +50 -0
- package/vendor/theus-arsenal/commands/crear-skill.md +77 -0
- package/vendor/theus-arsenal/commands/enrutar-modelo.md +30 -0
- package/vendor/theus-arsenal/commands/epica-desbloquear.md +17 -0
- package/vendor/theus-arsenal/commands/epica-descomponer.md +22 -0
- package/vendor/theus-arsenal/commands/epica-publicar.md +21 -0
- package/vendor/theus-arsenal/commands/epica-reclamar.md +25 -0
- package/vendor/theus-arsenal/commands/epica-revisar.md +22 -0
- package/vendor/theus-arsenal/commands/epica-sincronizar.md +21 -0
- package/vendor/theus-arsenal/commands/epica-validar.md +21 -0
- package/vendor/theus-arsenal/commands/evolucionar.md +176 -0
- package/vendor/theus-arsenal/commands/funcionalidad.md +49 -0
- package/vendor/theus-arsenal/commands/guardar-sesion.md +278 -0
- package/vendor/theus-arsenal/commands/harness-build.md +111 -0
- package/vendor/theus-arsenal/commands/harness-diseno.md +46 -0
- package/vendor/theus-arsenal/commands/informe-costos.md +90 -0
- package/vendor/theus-arsenal/commands/iniciar-bucle.md +36 -0
- package/vendor/theus-arsenal/commands/instintos-estado.md +53 -0
- package/vendor/theus-arsenal/commands/instintos-exportar.md +69 -0
- package/vendor/theus-arsenal/commands/instintos-importar.md +120 -0
- package/vendor/theus-arsenal/commands/lienzo-planes.md +48 -0
- package/vendor/theus-arsenal/commands/limpiar-refactor.md +84 -0
- package/vendor/theus-arsenal/commands/modo-seguro.md +96 -0
- package/vendor/theus-arsenal/commands/orq-agregar-funcionalidad.md +36 -0
- package/vendor/theus-arsenal/commands/orq-cambiar-funcionalidad.md +38 -0
- package/vendor/theus-arsenal/commands/orq-construir-mvp.md +36 -0
- package/vendor/theus-arsenal/commands/orq-corregir-defecto.md +40 -0
- package/vendor/theus-arsenal/commands/orq-refinar-codigo.md +44 -0
- package/vendor/theus-arsenal/commands/orq-revisar.md +135 -0
- package/vendor/theus-arsenal/commands/plan-prd.md +160 -0
- package/vendor/theus-arsenal/commands/plan.md +198 -0
- package/vendor/theus-arsenal/commands/podar.md +31 -0
- package/vendor/theus-arsenal/commands/pr.md +181 -0
- package/vendor/theus-arsenal/commands/promover.md +41 -0
- package/vendor/theus-arsenal/commands/proyectos.md +33 -0
- package/vendor/theus-arsenal/commands/prp-commit.md +112 -0
- package/vendor/theus-arsenal/commands/prp-implementar.md +385 -0
- package/vendor/theus-arsenal/commands/prp-planificar.md +501 -0
- package/vendor/theus-arsenal/commands/reanudar-sesion.md +160 -0
- package/vendor/theus-arsenal/commands/revisar-codigo.md +289 -0
- package/vendor/theus-arsenal/commands/revisar-cpp.md +132 -0
- package/vendor/theus-arsenal/commands/revisar-fastapi.md +39 -0
- package/vendor/theus-arsenal/commands/revisar-flutter.md +115 -0
- package/vendor/theus-arsenal/commands/revisar-go.md +148 -0
- package/vendor/theus-arsenal/commands/revisar-kotlin.md +140 -0
- package/vendor/theus-arsenal/commands/revisar-pr.md +37 -0
- package/vendor/theus-arsenal/commands/revisar-python.md +297 -0
- package/vendor/theus-arsenal/commands/revisar-react.md +170 -0
- package/vendor/theus-arsenal/commands/revisar-rust.md +142 -0
- package/vendor/theus-arsenal/commands/revisar-vue.md +174 -0
- package/vendor/theus-arsenal/commands/salud-skills.md +52 -0
- package/vendor/theus-arsenal/commands/sesiones.md +345 -0
- package/vendor/theus-arsenal/commands/test-cpp.md +252 -0
- package/vendor/theus-arsenal/commands/test-flutter.md +143 -0
- package/vendor/theus-arsenal/commands/test-go.md +268 -0
- package/vendor/theus-arsenal/commands/test-kotlin.md +312 -0
- package/vendor/theus-arsenal/commands/test-react.md +265 -0
- package/vendor/theus-arsenal/commands/test-rust.md +309 -0
- package/vendor/theus-arsenal/commands/vigilancia-canary.md +43 -0
- package/vendor/theus-arsenal/hooks/hooks.json +274 -0
- package/vendor/theus-arsenal/package.json +6 -0
- package/vendor/theus-arsenal/rules/angular/coding-style.md +182 -0
- package/vendor/theus-arsenal/rules/angular/hooks.md +25 -0
- package/vendor/theus-arsenal/rules/angular/patterns.md +249 -0
- package/vendor/theus-arsenal/rules/angular/security.md +87 -0
- package/vendor/theus-arsenal/rules/angular/testing.md +164 -0
- package/vendor/theus-arsenal/rules/arkts/coding-style.md +153 -0
- package/vendor/theus-arsenal/rules/arkts/hooks.md +80 -0
- package/vendor/theus-arsenal/rules/arkts/patterns.md +236 -0
- package/vendor/theus-arsenal/rules/arkts/security.md +141 -0
- package/vendor/theus-arsenal/rules/arkts/testing.md +126 -0
- package/vendor/theus-arsenal/rules/common/agents.md +49 -0
- package/vendor/theus-arsenal/rules/common/code-review.md +123 -0
- package/vendor/theus-arsenal/rules/common/coding-style.md +90 -0
- package/vendor/theus-arsenal/rules/common/development-workflow.md +44 -0
- package/vendor/theus-arsenal/rules/common/git-workflow.md +24 -0
- package/vendor/theus-arsenal/rules/common/hooks.md +32 -0
- package/vendor/theus-arsenal/rules/common/patterns.md +31 -0
- package/vendor/theus-arsenal/rules/common/performance.md +53 -0
- package/vendor/theus-arsenal/rules/common/security.md +29 -0
- package/vendor/theus-arsenal/rules/common/testing.md +57 -0
- package/vendor/theus-arsenal/rules/cpp/coding-style.md +44 -0
- package/vendor/theus-arsenal/rules/cpp/hooks.md +39 -0
- package/vendor/theus-arsenal/rules/cpp/patterns.md +51 -0
- package/vendor/theus-arsenal/rules/cpp/security.md +51 -0
- package/vendor/theus-arsenal/rules/cpp/testing.md +44 -0
- package/vendor/theus-arsenal/rules/csharp/coding-style.md +72 -0
- package/vendor/theus-arsenal/rules/csharp/hooks.md +25 -0
- package/vendor/theus-arsenal/rules/csharp/patterns.md +50 -0
- package/vendor/theus-arsenal/rules/csharp/security.md +58 -0
- package/vendor/theus-arsenal/rules/csharp/testing.md +50 -0
- package/vendor/theus-arsenal/rules/dart/coding-style.md +159 -0
- package/vendor/theus-arsenal/rules/dart/hooks.md +68 -0
- package/vendor/theus-arsenal/rules/dart/patterns.md +261 -0
- package/vendor/theus-arsenal/rules/dart/security.md +135 -0
- package/vendor/theus-arsenal/rules/dart/testing.md +215 -0
- package/vendor/theus-arsenal/rules/fsharp/coding-style.md +112 -0
- package/vendor/theus-arsenal/rules/fsharp/hooks.md +26 -0
- package/vendor/theus-arsenal/rules/fsharp/patterns.md +111 -0
- package/vendor/theus-arsenal/rules/fsharp/security.md +76 -0
- package/vendor/theus-arsenal/rules/fsharp/testing.md +62 -0
- package/vendor/theus-arsenal/rules/golang/coding-style.md +32 -0
- package/vendor/theus-arsenal/rules/golang/hooks.md +17 -0
- package/vendor/theus-arsenal/rules/golang/patterns.md +45 -0
- package/vendor/theus-arsenal/rules/golang/security.md +34 -0
- package/vendor/theus-arsenal/rules/golang/testing.md +31 -0
- package/vendor/theus-arsenal/rules/java/coding-style.md +114 -0
- package/vendor/theus-arsenal/rules/java/hooks.md +18 -0
- package/vendor/theus-arsenal/rules/java/patterns.md +147 -0
- package/vendor/theus-arsenal/rules/java/security.md +101 -0
- package/vendor/theus-arsenal/rules/java/testing.md +133 -0
- package/vendor/theus-arsenal/rules/kotlin/coding-style.md +86 -0
- package/vendor/theus-arsenal/rules/kotlin/hooks.md +17 -0
- package/vendor/theus-arsenal/rules/kotlin/patterns.md +146 -0
- package/vendor/theus-arsenal/rules/kotlin/security.md +82 -0
- package/vendor/theus-arsenal/rules/kotlin/testing.md +128 -0
- package/vendor/theus-arsenal/rules/nuxt/coding-style.md +47 -0
- package/vendor/theus-arsenal/rules/nuxt/hooks.md +39 -0
- package/vendor/theus-arsenal/rules/nuxt/patterns.md +54 -0
- package/vendor/theus-arsenal/rules/nuxt/security.md +48 -0
- package/vendor/theus-arsenal/rules/nuxt/testing.md +49 -0
- package/vendor/theus-arsenal/rules/php/coding-style.md +40 -0
- package/vendor/theus-arsenal/rules/php/hooks.md +24 -0
- package/vendor/theus-arsenal/rules/php/patterns.md +33 -0
- package/vendor/theus-arsenal/rules/php/security.md +37 -0
- package/vendor/theus-arsenal/rules/php/testing.md +38 -0
- package/vendor/theus-arsenal/rules/python/coding-style.md +42 -0
- package/vendor/theus-arsenal/rules/python/fastapi.md +58 -0
- package/vendor/theus-arsenal/rules/python/hooks.md +19 -0
- package/vendor/theus-arsenal/rules/python/patterns.md +39 -0
- package/vendor/theus-arsenal/rules/python/security.md +30 -0
- package/vendor/theus-arsenal/rules/python/testing.md +38 -0
- package/vendor/theus-arsenal/rules/react/coding-style.md +109 -0
- package/vendor/theus-arsenal/rules/react/hooks.md +187 -0
- package/vendor/theus-arsenal/rules/react/patterns.md +194 -0
- package/vendor/theus-arsenal/rules/react/security.md +180 -0
- package/vendor/theus-arsenal/rules/react/testing.md +208 -0
- package/vendor/theus-arsenal/rules/react-native/accessibility.md +55 -0
- package/vendor/theus-arsenal/rules/react-native/coding-style.md +71 -0
- package/vendor/theus-arsenal/rules/react-native/hooks.md +28 -0
- package/vendor/theus-arsenal/rules/react-native/patterns.md +88 -0
- package/vendor/theus-arsenal/rules/react-native/performance.md +45 -0
- package/vendor/theus-arsenal/rules/react-native/production-readiness.md +51 -0
- package/vendor/theus-arsenal/rules/react-native/security.md +43 -0
- package/vendor/theus-arsenal/rules/react-native/testing.md +52 -0
- package/vendor/theus-arsenal/rules/ruby/coding-style.md +46 -0
- package/vendor/theus-arsenal/rules/ruby/hooks.md +37 -0
- package/vendor/theus-arsenal/rules/ruby/patterns.md +44 -0
- package/vendor/theus-arsenal/rules/ruby/security.md +51 -0
- package/vendor/theus-arsenal/rules/ruby/testing.md +51 -0
- package/vendor/theus-arsenal/rules/rust/coding-style.md +151 -0
- package/vendor/theus-arsenal/rules/rust/hooks.md +16 -0
- package/vendor/theus-arsenal/rules/rust/patterns.md +168 -0
- package/vendor/theus-arsenal/rules/rust/security.md +141 -0
- package/vendor/theus-arsenal/rules/rust/testing.md +154 -0
- package/vendor/theus-arsenal/rules/swift/coding-style.md +47 -0
- package/vendor/theus-arsenal/rules/swift/hooks.md +20 -0
- package/vendor/theus-arsenal/rules/swift/patterns.md +66 -0
- package/vendor/theus-arsenal/rules/swift/security.md +33 -0
- package/vendor/theus-arsenal/rules/swift/testing.md +45 -0
- package/vendor/theus-arsenal/rules/typescript/coding-style.md +199 -0
- package/vendor/theus-arsenal/rules/typescript/hooks.md +22 -0
- package/vendor/theus-arsenal/rules/typescript/patterns.md +52 -0
- package/vendor/theus-arsenal/rules/typescript/security.md +28 -0
- package/vendor/theus-arsenal/rules/typescript/testing.md +18 -0
- package/vendor/theus-arsenal/rules/vue/coding-style.md +54 -0
- package/vendor/theus-arsenal/rules/vue/hooks.md +45 -0
- package/vendor/theus-arsenal/rules/vue/patterns.md +56 -0
- package/vendor/theus-arsenal/rules/vue/security.md +46 -0
- package/vendor/theus-arsenal/rules/vue/testing.md +53 -0
- package/vendor/theus-arsenal/rules/web/coding-style.md +108 -0
- package/vendor/theus-arsenal/rules/web/design-quality.md +75 -0
- package/vendor/theus-arsenal/rules/web/hooks.md +141 -0
- package/vendor/theus-arsenal/rules/web/patterns.md +91 -0
- package/vendor/theus-arsenal/rules/web/performance.md +76 -0
- package/vendor/theus-arsenal/rules/web/security.md +69 -0
- package/vendor/theus-arsenal/rules/web/testing.md +67 -0
- package/vendor/theus-arsenal/scripts/hooks/bash-hook-dispatcher.js +192 -0
- package/vendor/theus-arsenal/scripts/hooks/block-no-verify.js +556 -0
- package/vendor/theus-arsenal/scripts/hooks/check-console-log.js +92 -0
- package/vendor/theus-arsenal/scripts/hooks/check-hook-enabled.js +16 -0
- package/vendor/theus-arsenal/scripts/hooks/config-protection.js +171 -0
- package/vendor/theus-arsenal/scripts/hooks/design-quality-check.js +132 -0
- package/vendor/theus-arsenal/scripts/hooks/doc-file-warning.js +110 -0
- package/vendor/theus-arsenal/scripts/hooks/modo-seguro.js +158 -0
- package/vendor/theus-arsenal/scripts/hooks/notificacion-escritorio.js +208 -0
- package/vendor/theus-arsenal/scripts/hooks/plugin-hook-bootstrap.js +280 -0
- package/vendor/theus-arsenal/scripts/hooks/post-bash-command-log.js +87 -0
- package/vendor/theus-arsenal/scripts/hooks/post-bash-dispatcher.js +24 -0
- package/vendor/theus-arsenal/scripts/hooks/post-bash-pr-created.js +60 -0
- package/vendor/theus-arsenal/scripts/hooks/post-edit-accumulator.js +94 -0
- package/vendor/theus-arsenal/scripts/hooks/post-edit-console-warn.js +54 -0
- package/vendor/theus-arsenal/scripts/hooks/post-edit-format.js +110 -0
- package/vendor/theus-arsenal/scripts/hooks/post-edit-typecheck.js +98 -0
- package/vendor/theus-arsenal/scripts/hooks/pre-bash-commit-quality.js +447 -0
- package/vendor/theus-arsenal/scripts/hooks/pre-bash-dev-server-block.js +232 -0
- package/vendor/theus-arsenal/scripts/hooks/pre-bash-dispatcher.js +27 -0
- package/vendor/theus-arsenal/scripts/hooks/pre-compact.js +101 -0
- package/vendor/theus-arsenal/scripts/hooks/pretooluse-visible-output.js +49 -0
- package/vendor/theus-arsenal/scripts/hooks/quality-gate.js +168 -0
- package/vendor/theus-arsenal/scripts/hooks/run-with-flags.js +271 -0
- package/vendor/theus-arsenal/scripts/hooks/salud-mcp.js +749 -0
- package/vendor/theus-arsenal/scripts/hooks/seguimiento-costos.js +161 -0
- package/vendor/theus-arsenal/scripts/hooks/session-end.js +340 -0
- package/vendor/theus-arsenal/scripts/hooks/session-start.js +906 -0
- package/vendor/theus-arsenal/scripts/hooks/stop-format-typecheck.js +263 -0
- package/vendor/theus-arsenal/scripts/hooks/suggest-compact.js +286 -0
- package/vendor/theus-arsenal/scripts/hooks/theus-context-monitor.js +289 -0
- package/vendor/theus-arsenal/scripts/hooks/verificacion-factual.js +1278 -0
- package/vendor/theus-arsenal/scripts/lib/agent-data-home.js +96 -0
- package/vendor/theus-arsenal/scripts/lib/cost-estimate.js +66 -0
- package/vendor/theus-arsenal/scripts/lib/hook-flags.js +79 -0
- package/vendor/theus-arsenal/scripts/lib/llm-summary.js +185 -0
- package/vendor/theus-arsenal/scripts/lib/loopback-guard.js +54 -0
- package/vendor/theus-arsenal/scripts/lib/observer-sessions.js +237 -0
- package/vendor/theus-arsenal/scripts/lib/package-manager.d.ts +120 -0
- package/vendor/theus-arsenal/scripts/lib/package-manager.js +434 -0
- package/vendor/theus-arsenal/scripts/lib/path-safety.js +86 -0
- package/vendor/theus-arsenal/scripts/lib/plan-canvas/markdown.js +285 -0
- package/vendor/theus-arsenal/scripts/lib/plan-canvas/sdk.js +238 -0
- package/vendor/theus-arsenal/scripts/lib/plan-canvas/server.js +534 -0
- package/vendor/theus-arsenal/scripts/lib/plan-canvas/sessions.js +274 -0
- package/vendor/theus-arsenal/scripts/lib/plan-canvas/ui.js +546 -0
- package/vendor/theus-arsenal/scripts/lib/project-detect.js +451 -0
- package/vendor/theus-arsenal/scripts/lib/resolve-formatter.js +193 -0
- package/vendor/theus-arsenal/scripts/lib/resolve-theus-root.js +101 -0
- package/vendor/theus-arsenal/scripts/lib/session-aliases.d.ts +138 -0
- package/vendor/theus-arsenal/scripts/lib/session-aliases.js +483 -0
- package/vendor/theus-arsenal/scripts/lib/session-bridge.js +155 -0
- package/vendor/theus-arsenal/scripts/lib/session-manager.d.ts +137 -0
- package/vendor/theus-arsenal/scripts/lib/session-manager.js +555 -0
- package/vendor/theus-arsenal/scripts/lib/shell-split.js +86 -0
- package/vendor/theus-arsenal/scripts/lib/shell-substitution.js +501 -0
- package/vendor/theus-arsenal/scripts/lib/skill-evolution/dashboard.js +414 -0
- package/vendor/theus-arsenal/scripts/lib/skill-evolution/health.js +285 -0
- package/vendor/theus-arsenal/scripts/lib/skill-evolution/index.js +22 -0
- package/vendor/theus-arsenal/scripts/lib/skill-evolution/provenance.js +200 -0
- package/vendor/theus-arsenal/scripts/lib/skill-evolution/tracker.js +157 -0
- package/vendor/theus-arsenal/scripts/lib/skill-evolution/versioning.js +246 -0
- package/vendor/theus-arsenal/scripts/lib/transcript-context.js +232 -0
- package/vendor/theus-arsenal/scripts/lib/utils.d.ts +205 -0
- package/vendor/theus-arsenal/scripts/lib/utils.js +658 -0
- package/vendor/theus-arsenal/scripts/plan-canvas.js +341 -0
- package/vendor/theus-arsenal/scripts/setup-package-manager.js +46 -0
- package/vendor/theus-arsenal/scripts/skills-health.js +143 -0
- package/vendor/theus-arsenal/skills/a11y-frontend/SKILL.md +444 -0
- package/vendor/theus-arsenal/skills/accesibilidad/SKILL.md +144 -0
- package/vendor/theus-arsenal/skills/acelerador-throughput-datos/SKILL.md +72 -0
- package/vendor/theus-arsenal/skills/agente-scraper-datos/SKILL.md +771 -0
- package/vendor/theus-arsenal/skills/analisis-plataformas-competencia/SKILL.md +137 -0
- package/vendor/theus-arsenal/skills/api-x/SKILL.md +233 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/SKILL.md +335 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/agents/observer-loop.sh +374 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/agents/observer.md +188 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/agents/session-guardian.sh +153 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/agents/start-observer.sh +253 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/config.json +8 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/hooks/observe.sh +594 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/scripts/detect-project.sh +325 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/scripts/instinct-cli.py +1918 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/scripts/lib/arsenal-dir.sh +23 -0
- package/vendor/theus-arsenal/skills/aprendizaje-continuo-v2/scripts/test_parse_instinct.py +1420 -0
- package/vendor/theus-arsenal/skills/arquitectura-hexagonal/SKILL.md +275 -0
- package/vendor/theus-arsenal/skills/arquitectura-limpia-android/SKILL.md +340 -0
- package/vendor/theus-arsenal/skills/arquitectura-pipelines-recomendacion/SKILL.md +112 -0
- package/vendor/theus-arsenal/skills/atlas-datos-prediccion/SKILL.md +53 -0
- package/vendor/theus-arsenal/skills/auditoria-arquitectura-agentes/SKILL.md +257 -0
- package/vendor/theus-arsenal/skills/auditoria-produccion/SKILL.md +180 -0
- package/vendor/theus-arsenal/skills/auditoria-rutas-clic/SKILL.md +243 -0
- package/vendor/theus-arsenal/skills/autoevaluacion-agente/SKILL.md +180 -0
- package/vendor/theus-arsenal/skills/autoevaluacion-agente/examples/high-score-example.md +89 -0
- package/vendor/theus-arsenal/skills/autoevaluacion-agente/examples/low-score-example.md +87 -0
- package/vendor/theus-arsenal/skills/autoevaluacion-agente/references/evaluation-criteria.md +71 -0
- package/vendor/theus-arsenal/skills/autoevaluacion-agente/references/hook-integration.md +90 -0
- package/vendor/theus-arsenal/skills/autoevaluacion-agente/scripts/evaluate.py +409 -0
- package/vendor/theus-arsenal/skills/autoevaluacion-agente/templates/evaluation-report.md +86 -0
- package/vendor/theus-arsenal/skills/automatizacion-ssh-netmiko/SKILL.md +176 -0
- package/vendor/theus-arsenal/skills/base-datos-pubmed/SKILL.md +174 -0
- package/vendor/theus-arsenal/skills/base-datos-uspto/SKILL.md +173 -0
- package/vendor/theus-arsenal/skills/benchmark/SKILL.md +92 -0
- package/vendor/theus-arsenal/skills/bitacora-crecimiento/SKILL.md +120 -0
- package/vendor/theus-arsenal/skills/bucle-verificacion/SKILL.md +125 -0
- package/vendor/theus-arsenal/skills/buscar-primero/SKILL.md +184 -0
- package/vendor/theus-arsenal/skills/busqueda-exa/SKILL.md +111 -0
- package/vendor/theus-arsenal/skills/cache-por-hash/SKILL.md +160 -0
- package/vendor/theus-arsenal/skills/campana-marketing/SKILL.md +118 -0
- package/vendor/theus-arsenal/skills/capacidad-producto/SKILL.md +138 -0
- package/vendor/theus-arsenal/skills/cazador-vulnerabilidades/SKILL.md +104 -0
- package/vendor/theus-arsenal/skills/compactacion-estrategica/SKILL.md +115 -0
- package/vendor/theus-arsenal/skills/comparador-baskets-prediccion/SKILL.md +69 -0
- package/vendor/theus-arsenal/skills/compras-energia/SKILL.md +206 -0
- package/vendor/theus-arsenal/skills/concurrencia-swift-6-2/SKILL.md +224 -0
- package/vendor/theus-arsenal/skills/consejo/SKILL.md +201 -0
- package/vendor/theus-arsenal/skills/construccion-harness-agentes/SKILL.md +78 -0
- package/vendor/theus-arsenal/skills/constructor-conectores/SKILL.md +119 -0
- package/vendor/theus-arsenal/skills/constructor-equipos/SKILL.md +169 -0
- package/vendor/theus-arsenal/skills/consulta-documentacion/SKILL.md +92 -0
- package/vendor/theus-arsenal/skills/consultas-genomicas-gget/SKILL.md +170 -0
- package/vendor/theus-arsenal/skills/contacto-inversores/SKILL.md +95 -0
- package/vendor/theus-arsenal/skills/corrutinas-flows-kotlin/SKILL.md +284 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/SKILL.md +46 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/3d.md +86 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/animations.md +29 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/assets/charts-bar-chart.tsx +173 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/assets/text-animations-typewriter.tsx +100 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/assets/text-animations-word-highlight.tsx +108 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/assets.md +78 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/audio.md +172 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/calculate-metadata.md +104 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/can-decode.md +75 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/charts.md +58 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/compositions.md +146 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/display-captions.md +126 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/extract-frames.md +229 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/fonts.md +152 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/get-audio-duration.md +58 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/get-video-dimensions.md +68 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/get-video-duration.md +58 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/gifs.md +138 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/images.md +130 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/import-srt-captions.md +67 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/lottie.md +67 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/measuring-dom-nodes.md +34 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/measuring-text.md +143 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/sequencing.md +106 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/tailwind.md +11 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/text-animations.md +20 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/timing.md +179 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/transcribe-captions.md +19 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/transitions.md +122 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/trimming.md +52 -0
- package/vendor/theus-arsenal/skills/creacion-video-remotion/rules/videos.md +171 -0
- package/vendor/theus-arsenal/skills/cumplimiento-aduanero/SKILL.md +270 -0
- package/vendor/theus-arsenal/skills/cumplimiento-hipaa/SKILL.md +78 -0
- package/vendor/theus-arsenal/skills/datos-sensibles-salud/SKILL.md +149 -0
- package/vendor/theus-arsenal/skills/decimales-tokens-evm/SKILL.md +128 -0
- package/vendor/theus-arsenal/skills/decisiones-arquitectura/SKILL.md +206 -0
- package/vendor/theus-arsenal/skills/demos-ui/SKILL.md +469 -0
- package/vendor/theus-arsenal/skills/desarrollo-por-intencion/SKILL.md +369 -0
- package/vendor/theus-arsenal/skills/descubrimiento-marca/SKILL.md +149 -0
- package/vendor/theus-arsenal/skills/descubrimiento-marca/references/10_proposito-porque.md +42 -0
- package/vendor/theus-arsenal/skills/descubrimiento-marca/references/20_posicionamiento.md +47 -0
- package/vendor/theus-arsenal/skills/descubrimiento-marca/references/30_audiencia-nicho.md +53 -0
- package/vendor/theus-arsenal/skills/descubrimiento-marca/references/40_personalidad-arquetipo.md +61 -0
- package/vendor/theus-arsenal/skills/descubrimiento-marca/references/50_voz-tono.md +62 -0
- package/vendor/theus-arsenal/skills/descubrimiento-marca/references/60_narrativa-historia.md +54 -0
- package/vendor/theus-arsenal/skills/descubrimiento-marca/references/70_tension-fundador.md +50 -0
- package/vendor/theus-arsenal/skills/descubrimiento-marca/references/90_SINTESIS.md +133 -0
- package/vendor/theus-arsenal/skills/descubrimiento-plugins-laravel/SKILL.md +230 -0
- package/vendor/theus-arsenal/skills/destilado-reglas/SKILL.md +263 -0
- package/vendor/theus-arsenal/skills/destilado-reglas/scripts/scan-rules.sh +58 -0
- package/vendor/theus-arsenal/skills/destilado-reglas/scripts/scan-skills.sh +129 -0
- package/vendor/theus-arsenal/skills/diagnostico-bgp/SKILL.md +170 -0
- package/vendor/theus-arsenal/skills/direccion-estetica/SKILL.md +220 -0
- package/vendor/theus-arsenal/skills/direccion-estetica/references/taxonomia-generos.md +89 -0
- package/vendor/theus-arsenal/skills/diseno-api/SKILL.md +522 -0
- package/vendor/theus-arsenal/skills/diseno-liquid-glass/SKILL.md +282 -0
- package/vendor/theus-arsenal/skills/e2e-escritorio-windows/SKILL.md +879 -0
- package/vendor/theus-arsenal/skills/edicion-video/SKILL.md +289 -0
- package/vendor/theus-arsenal/skills/enfoque-producto/SKILL.md +91 -0
- package/vendor/theus-arsenal/skills/entornos-flox/SKILL.md +493 -0
- package/vendor/theus-arsenal/skills/estandares-codigo/SKILL.md +548 -0
- package/vendor/theus-arsenal/skills/estandares-cpp/SKILL.md +727 -0
- package/vendor/theus-arsenal/skills/estandares-java/SKILL.md +389 -0
- package/vendor/theus-arsenal/skills/estilo-legado/SKILL.md +149 -0
- package/vendor/theus-arsenal/skills/estructura-informes-competencia/SKILL.md +95 -0
- package/vendor/theus-arsenal/skills/evaluacion-academica/SKILL.md +165 -0
- package/vendor/theus-arsenal/skills/explorador-skills/SKILL.md +129 -0
- package/vendor/theus-arsenal/skills/flujo-git/SKILL.md +714 -0
- package/vendor/theus-arsenal/skills/flujo-ingenieria-ml/SKILL.md +343 -0
- package/vendor/theus-arsenal/skills/flujo-tdd/SKILL.md +584 -0
- package/vendor/theus-arsenal/skills/forja-personas/SKILL.md +298 -0
- package/vendor/theus-arsenal/skills/forja-personas/gacha.py +224 -0
- package/vendor/theus-arsenal/skills/forja-personas/gacha.sh +5 -0
- package/vendor/theus-arsenal/skills/forja-personas/references/avatar-style.md +123 -0
- package/vendor/theus-arsenal/skills/forja-personas/references/boundary-rules.md +53 -0
- package/vendor/theus-arsenal/skills/forja-personas/references/error-handling.md +53 -0
- package/vendor/theus-arsenal/skills/forja-personas/references/identity-tension.md +48 -0
- package/vendor/theus-arsenal/skills/forja-personas/references/naming-system.md +39 -0
- package/vendor/theus-arsenal/skills/forja-personas/references/output-template.md +166 -0
- package/vendor/theus-arsenal/skills/fundamentos-animacion/SKILL.md +296 -0
- package/vendor/theus-arsenal/skills/generacion-iconos-ios/SKILL.md +156 -0
- package/vendor/theus-arsenal/skills/generacion-iconos-ios/scripts/generate_icons.swift +258 -0
- package/vendor/theus-arsenal/skills/generacion-iconos-ios/scripts/iconify_gen.sh +235 -0
- package/vendor/theus-arsenal/skills/gestion-excepciones-logisticas/SKILL.md +208 -0
- package/vendor/theus-arsenal/skills/gestion-transportistas/SKILL.md +204 -0
- package/vendor/theus-arsenal/skills/guia-adopcion-ml/SKILL.md +64 -0
- package/vendor/theus-arsenal/skills/harness-agente-autonomo/SKILL.md +252 -0
- package/vendor/theus-arsenal/skills/harness-eval-clinico/SKILL.md +212 -0
- package/vendor/theus-arsenal/skills/harness-evaluacion/SKILL.md +296 -0
- package/vendor/theus-arsenal/skills/harness-generador-evaluador/SKILL.md +254 -0
- package/vendor/theus-arsenal/skills/homelab-diseno-red/SKILL.md +120 -0
- package/vendor/theus-arsenal/skills/homelab-dns-pihole/SKILL.md +264 -0
- package/vendor/theus-arsenal/skills/homelab-preparacion-red/SKILL.md +144 -0
- package/vendor/theus-arsenal/skills/homelab-segmentacion-vlan/SKILL.md +307 -0
- package/vendor/theus-arsenal/skills/homelab-vpn-wireguard/SKILL.md +299 -0
- package/vendor/theus-arsenal/skills/ingenieria-agentica/SKILL.md +96 -0
- package/vendor/theus-arsenal/skills/inspeccion-animaciones-blender/SKILL.md +164 -0
- package/vendor/theus-arsenal/skills/instaladores-python/SKILL.md +820 -0
- package/vendor/theus-arsenal/skills/integracion-jira/SKILL.md +307 -0
- package/vendor/theus-arsenal/skills/inteligencia-leads/SKILL.md +312 -0
- package/vendor/theus-arsenal/skills/inteligencia-leads/agents/agente-enriquecimiento.md +87 -0
- package/vendor/theus-arsenal/skills/inteligencia-leads/agents/mapeador-mutuos.md +76 -0
- package/vendor/theus-arsenal/skills/inteligencia-leads/agents/puntuador-senales.md +60 -0
- package/vendor/theus-arsenal/skills/inteligencia-leads/agents/redactor-outreach.md +102 -0
- package/vendor/theus-arsenal/skills/inteligencia-mercados-prediccion/SKILL.md +53 -0
- package/vendor/theus-arsenal/skills/introspeccion-agente/SKILL.md +150 -0
- package/vendor/theus-arsenal/skills/inventario-skills/SKILL.md +194 -0
- package/vendor/theus-arsenal/skills/inventario-skills/scripts/quick-diff.sh +87 -0
- package/vendor/theus-arsenal/skills/inventario-skills/scripts/save-results.sh +57 -0
- package/vendor/theus-arsenal/skills/inventario-skills/scripts/scan.sh +170 -0
- package/vendor/theus-arsenal/skills/investigacion-mercado/SKILL.md +87 -0
- package/vendor/theus-arsenal/skills/investigacion-oraculos-prediccion/SKILL.md +59 -0
- package/vendor/theus-arsenal/skills/investigacion-profunda/SKILL.md +161 -0
- package/vendor/theus-arsenal/skills/keccak256-nodejs/SKILL.md +100 -0
- package/vendor/theus-arsenal/skills/libro-decisiones-recursivo/SKILL.md +82 -0
- package/vendor/theus-arsenal/skills/lienzo-planes/SKILL.md +111 -0
- package/vendor/theus-arsenal/skills/limpieza-configuracion/SKILL.md +116 -0
- package/vendor/theus-arsenal/skills/logistica-inversa-devoluciones/SKILL.md +241 -0
- package/vendor/theus-arsenal/skills/manejo-errores/SKILL.md +375 -0
- package/vendor/theus-arsenal/skills/materiales-inversores/SKILL.md +101 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/SKILL.md +170 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/commands/forget.mjs +44 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/commands/info.mjs +24 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/commands/init.mjs +152 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/commands/list.mjs +40 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/commands/migrate.mjs +214 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/commands/resume.mjs +36 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/commands/save.mjs +210 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/commands/shared.mjs +402 -0
- package/vendor/theus-arsenal/skills/memoria-por-proyecto/hooks/session-start.mjs +238 -0
- package/vendor/theus-arsenal/skills/metodologia-benchmarks/SKILL.md +131 -0
- package/vendor/theus-arsenal/skills/migraciones-bd/SKILL.md +430 -0
- package/vendor/theus-arsenal/skills/modelos-fundacionales-en-dispositivo/SKILL.md +244 -0
- package/vendor/theus-arsenal/skills/modo-seguro/SKILL.md +86 -0
- package/vendor/theus-arsenal/skills/motion-avanzado/SKILL.md +592 -0
- package/vendor/theus-arsenal/skills/motor-de-contenido/SKILL.md +136 -0
- package/vendor/theus-arsenal/skills/no-conformidades-calidad/SKILL.md +249 -0
- package/vendor/theus-arsenal/skills/onboarding-codigo/SKILL.md +244 -0
- package/vendor/theus-arsenal/skills/operaciones-agentes-empresariales/SKILL.md +51 -0
- package/vendor/theus-arsenal/skills/operaciones-conocimiento/SKILL.md +159 -0
- package/vendor/theus-arsenal/skills/operaciones-correo/SKILL.md +123 -0
- package/vendor/theus-arsenal/skills/operaciones-facturacion/SKILL.md +142 -0
- package/vendor/theus-arsenal/skills/operaciones-flujo-proyectos/SKILL.md +110 -0
- package/vendor/theus-arsenal/skills/operaciones-github/SKILL.md +143 -0
- package/vendor/theus-arsenal/skills/operaciones-google-workspace/SKILL.md +100 -0
- package/vendor/theus-arsenal/skills/operaciones-investigacion/SKILL.md +124 -0
- package/vendor/theus-arsenal/skills/operaciones-mensajes/SKILL.md +103 -0
- package/vendor/theus-arsenal/skills/operaciones-terminal/SKILL.md +110 -0
- package/vendor/theus-arsenal/skills/optimizacion-benchmark/SKILL.md +70 -0
- package/vendor/theus-arsenal/skills/optimizacion-costos-llm/SKILL.md +182 -0
- package/vendor/theus-arsenal/skills/optimizador-conexiones/SKILL.md +191 -0
- package/vendor/theus-arsenal/skills/optimizador-paralelismo/SKILL.md +75 -0
- package/vendor/theus-arsenal/skills/optimizador-prompts/SKILL.md +374 -0
- package/vendor/theus-arsenal/skills/orq-agregar-funcionalidad/SKILL.md +37 -0
- package/vendor/theus-arsenal/skills/orq-cambiar-funcionalidad/SKILL.md +36 -0
- package/vendor/theus-arsenal/skills/orq-construir-mvp/SKILL.md +38 -0
- package/vendor/theus-arsenal/skills/orq-corregir-defecto/SKILL.md +36 -0
- package/vendor/theus-arsenal/skills/orq-pipeline/SKILL.md +134 -0
- package/vendor/theus-arsenal/skills/orq-refinar-codigo/SKILL.md +49 -0
- package/vendor/theus-arsenal/skills/orquestacion-equipos-agentes/SKILL.md +117 -0
- package/vendor/theus-arsenal/skills/pagos-agentes-x402/SKILL.md +237 -0
- package/vendor/theus-arsenal/skills/patrones-angular/SKILL.md +153 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/angular-animations.md +160 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/angular-aria.md +410 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/cli.md +86 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/component-harnesses.md +59 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/component-styling.md +91 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/components.md +117 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/creating-services.md +97 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/data-resolvers.md +69 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/define-routes.md +67 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/defining-providers.md +72 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/di-fundamentals.md +120 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/e2e-testing.md +56 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/effects.md +83 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/hierarchical-injectors.md +43 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/host-elements.md +80 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/injection-context.md +63 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/inputs.md +101 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/linked-signal.md +59 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/loading-strategies.md +61 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/mcp.md +67 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/navigate-to-routes.md +69 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/outputs.md +86 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/reactive-forms.md +122 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/rendering-strategies.md +44 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/resource.md +77 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/route-animations.md +56 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/route-guards.md +52 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/router-lifecycle.md +45 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/router-testing.md +87 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/show-routes-with-outlets.md +68 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/signal-forms.md +795 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/signals-overview.md +94 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/tailwind-css.md +69 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/template-driven-forms.md +114 -0
- package/vendor/theus-arsenal/skills/patrones-angular/references/testing-fundamentals.md +65 -0
- package/vendor/theus-arsenal/skills/patrones-animacion/SKILL.md +432 -0
- package/vendor/theus-arsenal/skills/patrones-backend/SKILL.md +560 -0
- package/vendor/theus-arsenal/skills/patrones-cdss-clinico/SKILL.md +249 -0
- package/vendor/theus-arsenal/skills/patrones-cisco-ios/SKILL.md +148 -0
- package/vendor/theus-arsenal/skills/patrones-clickhouse/SKILL.md +443 -0
- package/vendor/theus-arsenal/skills/patrones-compose-multiplatform/SKILL.md +298 -0
- package/vendor/theus-arsenal/skills/patrones-dart-flutter/SKILL.md +566 -0
- package/vendor/theus-arsenal/skills/patrones-despliegue/SKILL.md +426 -0
- package/vendor/theus-arsenal/skills/patrones-django/SKILL.md +739 -0
- package/vendor/theus-arsenal/skills/patrones-django-celery/SKILL.md +456 -0
- package/vendor/theus-arsenal/skills/patrones-docker/SKILL.md +363 -0
- package/vendor/theus-arsenal/skills/patrones-dotnet/SKILL.md +321 -0
- package/vendor/theus-arsenal/skills/patrones-emr-clinico/SKILL.md +168 -0
- package/vendor/theus-arsenal/skills/patrones-fastapi/SKILL.md +513 -0
- package/vendor/theus-arsenal/skills/patrones-frontend/SKILL.md +655 -0
- package/vendor/theus-arsenal/skills/patrones-go/SKILL.md +674 -0
- package/vendor/theus-arsenal/skills/patrones-jpa/SKILL.md +156 -0
- package/vendor/theus-arsenal/skills/patrones-kotlin/SKILL.md +717 -0
- package/vendor/theus-arsenal/skills/patrones-kotlin-exposed/SKILL.md +724 -0
- package/vendor/theus-arsenal/skills/patrones-kotlin-ktor/SKILL.md +694 -0
- package/vendor/theus-arsenal/skills/patrones-kubernetes/SKILL.md +754 -0
- package/vendor/theus-arsenal/skills/patrones-laravel/SKILL.md +414 -0
- package/vendor/theus-arsenal/skills/patrones-mcp/SKILL.md +66 -0
- package/vendor/theus-arsenal/skills/patrones-mysql/SKILL.md +420 -0
- package/vendor/theus-arsenal/skills/patrones-nestjs/SKILL.md +229 -0
- package/vendor/theus-arsenal/skills/patrones-nextjs/SKILL.md +56 -0
- package/vendor/theus-arsenal/skills/patrones-nuxt4/SKILL.md +99 -0
- package/vendor/theus-arsenal/skills/patrones-perl/SKILL.md +508 -0
- package/vendor/theus-arsenal/skills/patrones-postgres/SKILL.md +141 -0
- package/vendor/theus-arsenal/skills/patrones-prisma/SKILL.md +399 -0
- package/vendor/theus-arsenal/skills/patrones-python/SKILL.md +750 -0
- package/vendor/theus-arsenal/skills/patrones-pytorch/SKILL.md +400 -0
- package/vendor/theus-arsenal/skills/patrones-quarkus/SKILL.md +729 -0
- package/vendor/theus-arsenal/skills/patrones-react/SKILL.md +339 -0
- package/vendor/theus-arsenal/skills/patrones-react-native/SKILL.md +325 -0
- package/vendor/theus-arsenal/skills/patrones-redis/SKILL.md +401 -0
- package/vendor/theus-arsenal/skills/patrones-rust/SKILL.md +504 -0
- package/vendor/theus-arsenal/skills/patrones-springboot/SKILL.md +314 -0
- package/vendor/theus-arsenal/skills/patrones-swiftui/SKILL.md +261 -0
- package/vendor/theus-arsenal/skills/patrones-tinystruct/SKILL.md +281 -0
- package/vendor/theus-arsenal/skills/patrones-tinystruct/references/architecture.md +90 -0
- package/vendor/theus-arsenal/skills/patrones-tinystruct/references/data-handling.md +60 -0
- package/vendor/theus-arsenal/skills/patrones-tinystruct/references/database.md +99 -0
- package/vendor/theus-arsenal/skills/patrones-tinystruct/references/routing.md +64 -0
- package/vendor/theus-arsenal/skills/patrones-tinystruct/references/system-usage.md +97 -0
- package/vendor/theus-arsenal/skills/patrones-tinystruct/references/testing.md +72 -0
- package/vendor/theus-arsenal/skills/patrones-vite/SKILL.md +449 -0
- package/vendor/theus-arsenal/skills/patrones-vue/SKILL.md +469 -0
- package/vendor/theus-arsenal/skills/persistencia-actores-swift/SKILL.md +148 -0
- package/vendor/theus-arsenal/skills/pipeline-opensource/SKILL.md +254 -0
- package/vendor/theus-arsenal/skills/planificacion-demanda-inventario/SKILL.md +236 -0
- package/vendor/theus-arsenal/skills/planificador-trades-prediccion/SKILL.md +60 -0
- package/vendor/theus-arsenal/skills/plano-tecnico/SKILL.md +102 -0
- package/vendor/theus-arsenal/skills/presentaciones-html/SKILL.md +189 -0
- package/vendor/theus-arsenal/skills/presentaciones-html/STYLE_PRESETS.md +330 -0
- package/vendor/theus-arsenal/skills/presentaciones-html/animation-patterns.md +122 -0
- package/vendor/theus-arsenal/skills/presentaciones-html/html-template.md +419 -0
- package/vendor/theus-arsenal/skills/presentaciones-html/scripts/export-pdf.sh +418 -0
- package/vendor/theus-arsenal/skills/presentaciones-html/scripts/extract-pptx.py +96 -0
- package/vendor/theus-arsenal/skills/presentaciones-html/viewport-base.css +153 -0
- package/vendor/theus-arsenal/skills/presupuesto-contexto/SKILL.md +263 -0
- package/vendor/theus-arsenal/skills/procesamiento-documentos-nutrient/SKILL.md +168 -0
- package/vendor/theus-arsenal/skills/programacion-produccion/SKILL.md +220 -0
- package/vendor/theus-arsenal/skills/publicacion-cruzada/SKILL.md +117 -0
- package/vendor/theus-arsenal/skills/publicador-social/SKILL.md +121 -0
- package/vendor/theus-arsenal/skills/puerta-de-entrega/SKILL.md +164 -0
- package/vendor/theus-arsenal/skills/puerta-de-entrega/hooks/puerta-entrega.py +242 -0
- package/vendor/theus-arsenal/skills/pulir-interfaces/SKILL.md +126 -0
- package/vendor/theus-arsenal/skills/qa-navegador/SKILL.md +103 -0
- package/vendor/theus-arsenal/skills/ranking-grafo-social/SKILL.md +153 -0
- package/vendor/theus-arsenal/skills/recuperacion-iterativa/SKILL.md +236 -0
- package/vendor/theus-arsenal/skills/redaccion-articulos/SKILL.md +81 -0
- package/vendor/theus-arsenal/skills/regex-vs-llm/SKILL.md +221 -0
- package/vendor/theus-arsenal/skills/regresion-codigo-ia/SKILL.md +388 -0
- package/vendor/theus-arsenal/skills/rendimiento-react/SKILL.md +567 -0
- package/vendor/theus-arsenal/skills/revision-codigo-flutter-dart/SKILL.md +442 -0
- package/vendor/theus-arsenal/skills/revision-literatura-cientifica/SKILL.md +191 -0
- package/vendor/theus-arsenal/skills/revision-multiperspectiva/SKILL.md +302 -0
- package/vendor/theus-arsenal/skills/revision-riesgo-prediccion/SKILL.md +56 -0
- package/vendor/theus-arsenal/skills/revision-seguridad/SKILL.md +505 -0
- package/vendor/theus-arsenal/skills/revision-seguridad/cloud-infrastructure-security.md +361 -0
- package/vendor/theus-arsenal/skills/runtime-bun/SKILL.md +83 -0
- package/vendor/theus-arsenal/skills/salud-codigo-codescene/SKILL.md +163 -0
- package/vendor/theus-arsenal/skills/salud-interfaces-red/SKILL.md +143 -0
- package/vendor/theus-arsenal/skills/seguimiento-costos/SKILL.md +122 -0
- package/vendor/theus-arsenal/skills/seguridad-agentes-trading/SKILL.md +145 -0
- package/vendor/theus-arsenal/skills/seguridad-amm-defi/SKILL.md +166 -0
- package/vendor/theus-arsenal/skills/seguridad-django/SKILL.md +648 -0
- package/vendor/theus-arsenal/skills/seguridad-laravel/SKILL.md +945 -0
- package/vendor/theus-arsenal/skills/seguridad-perl/SKILL.md +507 -0
- package/vendor/theus-arsenal/skills/seguridad-quarkus/SKILL.md +474 -0
- package/vendor/theus-arsenal/skills/seguridad-springboot/SKILL.md +279 -0
- package/vendor/theus-arsenal/skills/seo/SKILL.md +166 -0
- package/vendor/theus-arsenal/skills/sistema-diseno/SKILL.md +81 -0
- package/vendor/theus-arsenal/skills/sistema-operativo-agentico/SKILL.md +375 -0
- package/vendor/theus-arsenal/skills/sistemas-latencia-critica/SKILL.md +65 -0
- package/vendor/theus-arsenal/skills/tdd-django/SKILL.md +735 -0
- package/vendor/theus-arsenal/skills/tdd-laravel/SKILL.md +673 -0
- package/vendor/theus-arsenal/skills/tdd-quarkus/SKILL.md +817 -0
- package/vendor/theus-arsenal/skills/tdd-springboot/SKILL.md +165 -0
- package/vendor/theus-arsenal/skills/testing-cpp/SKILL.md +328 -0
- package/vendor/theus-arsenal/skills/testing-csharp/SKILL.md +321 -0
- package/vendor/theus-arsenal/skills/testing-e2e/SKILL.md +325 -0
- package/vendor/theus-arsenal/skills/testing-go/SKILL.md +719 -0
- package/vendor/theus-arsenal/skills/testing-kotlin/SKILL.md +829 -0
- package/vendor/theus-arsenal/skills/testing-perl/SKILL.md +479 -0
- package/vendor/theus-arsenal/skills/testing-protocolos-di-swift/SKILL.md +196 -0
- package/vendor/theus-arsenal/skills/testing-python/SKILL.md +815 -0
- package/vendor/theus-arsenal/skills/testing-react/SKILL.md +421 -0
- package/vendor/theus-arsenal/skills/testing-rust/SKILL.md +506 -0
- package/vendor/theus-arsenal/skills/tours-de-codigo/SKILL.md +252 -0
- package/vendor/theus-arsenal/skills/traduccion-documentos-visado/SKILL.md +121 -0
- package/vendor/theus-arsenal/skills/ui-a-vue/SKILL.md +141 -0
- package/vendor/theus-arsenal/skills/validacion-config-red/SKILL.md +211 -0
- package/vendor/theus-arsenal/skills/verificacion-django/SKILL.md +470 -0
- package/vendor/theus-arsenal/skills/verificacion-factual/SKILL.md +142 -0
- package/vendor/theus-arsenal/skills/verificacion-laravel/SKILL.md +184 -0
- package/vendor/theus-arsenal/skills/verificacion-quarkus/SKILL.md +485 -0
- package/vendor/theus-arsenal/skills/verificacion-springboot/SKILL.md +237 -0
- package/vendor/theus-arsenal/skills/videodb/SKILL.md +374 -0
- package/vendor/theus-arsenal/skills/videodb/reference/api-reference.md +550 -0
- package/vendor/theus-arsenal/skills/videodb/reference/capture-reference.md +407 -0
- package/vendor/theus-arsenal/skills/videodb/reference/capture.md +101 -0
- package/vendor/theus-arsenal/skills/videodb/reference/editor.md +443 -0
- package/vendor/theus-arsenal/skills/videodb/reference/generative.md +331 -0
- package/vendor/theus-arsenal/skills/videodb/reference/rtstream-reference.md +564 -0
- package/vendor/theus-arsenal/skills/videodb/reference/rtstream.md +65 -0
- package/vendor/theus-arsenal/skills/videodb/reference/search.md +230 -0
- package/vendor/theus-arsenal/skills/videodb/reference/streaming.md +406 -0
- package/vendor/theus-arsenal/skills/videodb/reference/use-cases.md +118 -0
- package/vendor/theus-arsenal/skills/videodb/scripts/ws_listener.py +279 -0
- package/vendor/theus-arsenal/skills/videos-manim/SKILL.md +91 -0
- package/vendor/theus-arsenal/skills/videos-manim/assets/network_graph_scene.py +52 -0
- package/vendor/theus-arsenal/skills/vigilancia-canary/SKILL.md +108 -0
- package/vendor/theus-arsenal/skills/voz-de-marca/SKILL.md +106 -0
|
@@ -0,0 +1,1278 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Hook PreToolUse: puerta de verificación factual (forzado de hechos)
|
|
4
|
+
*
|
|
5
|
+
* Obliga al agente a investigar antes de editar archivos o ejecutar comandos.
|
|
6
|
+
* En vez de preguntar "¿estás seguro?" (que un modelo siempre responde "sí"),
|
|
7
|
+
* esta puerta exige hechos concretos: quién importa el archivo, qué API
|
|
8
|
+
* pública se ve afectada, qué esquemas de datos hay.
|
|
9
|
+
*
|
|
10
|
+
* El acto de investigar crea una conciencia que la autoevaluación nunca logró.
|
|
11
|
+
*
|
|
12
|
+
* Puertas:
|
|
13
|
+
* - Edit/Write: listar importadores, API afectada, verificar esquemas de
|
|
14
|
+
* datos y citar la instrucción del usuario
|
|
15
|
+
* - Bash (destructivo): listar objetivos, plan de reversión y citar la
|
|
16
|
+
* instrucción
|
|
17
|
+
* - Bash (rutinario): citar la instrucción vigente (una vez por sesión)
|
|
18
|
+
*
|
|
19
|
+
* Compatible con run-with-flags.js vía module.exports.run().
|
|
20
|
+
* Multiplataforma (Windows, macOS, Linux).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
'use strict';
|
|
24
|
+
|
|
25
|
+
const crypto = require('crypto');
|
|
26
|
+
const fs = require('fs');
|
|
27
|
+
const path = require('path');
|
|
28
|
+
const { extractCommandSubstitutions, extractSubshellGroups, extractBraceGroups } = require('../lib/shell-substitution');
|
|
29
|
+
const { resolveAgentDataHome } = require('../lib/agent-data-home');
|
|
30
|
+
|
|
31
|
+
// Estado de sesión — con ámbito por sesión para evitar carreras entre sesiones.
|
|
32
|
+
const STATE_DIR = process.env.THEUS_VERIFICACION_STATE_DIR || path.join(resolveAgentDataHome(), 'verificacion-factual');
|
|
33
|
+
let activeStateFile = null;
|
|
34
|
+
|
|
35
|
+
// State expires after 30 minutes of inactivity
|
|
36
|
+
const SESSION_TIMEOUT_MS = 30 * 60 * 1000;
|
|
37
|
+
const READ_HEARTBEAT_MS = 60 * 1000;
|
|
38
|
+
|
|
39
|
+
// Maximum checked entries to prevent unbounded growth
|
|
40
|
+
const MAX_CHECKED_ENTRIES = 500;
|
|
41
|
+
const MAX_SESSION_KEYS = 50;
|
|
42
|
+
const ROUTINE_BASH_SESSION_KEY = '__bash_session__';
|
|
43
|
+
const EDIT_WRITE_HOOK_ID = 'pre-edit-write-verificacion-factual';
|
|
44
|
+
const BASH_HOOK_ID = 'pre-bash-verificacion-factual';
|
|
45
|
+
const DISABLE_VALUES = new Set(['0', 'false', 'off', 'disabled', 'disable']);
|
|
46
|
+
const ENABLE_VALUES = new Set(['1', 'true', 'on', 'enabled', 'enable', 'yes']);
|
|
47
|
+
|
|
48
|
+
// SQL-keyword + dd patterns stay as a single regex — they are stable
|
|
49
|
+
// phrases without shell-flag ordering concerns. Quoted strings are
|
|
50
|
+
// stripped before this regex runs so a commit message mentioning
|
|
51
|
+
// "drop table" no longer triggers a false positive.
|
|
52
|
+
const DESTRUCTIVE_SQL_DD = /\b(drop\s+table|delete\s+from|truncate|dd\s+if=)\b/i;
|
|
53
|
+
|
|
54
|
+
// Operator-supplied additional destructive patterns. Lazily compiled from
|
|
55
|
+
// `THEUS_VERIFICACION_EXTRA_DESTRUCTIVOS` (regex source) on first use, then
|
|
56
|
+
// memoized keyed by the env-var value so a test or long-running process
|
|
57
|
+
// that flips the env between calls re-reads it without paying for a
|
|
58
|
+
// recompile on every invocation. A malformed regex is treated as
|
|
59
|
+
// "not configured" (the gate falls back to the built-in patterns) and
|
|
60
|
+
// the parse failure is logged once via `[verificacion-factual]` to
|
|
61
|
+
// stderr — hooks must never crash tool execution because of operator
|
|
62
|
+
// config errors.
|
|
63
|
+
let extraDestructiveCacheKey = null;
|
|
64
|
+
let extraDestructiveCacheRegex = null;
|
|
65
|
+
let extraDestructiveWarnLogged = false;
|
|
66
|
+
function getExtraDestructiveRegex() {
|
|
67
|
+
const raw = process.env.THEUS_VERIFICACION_EXTRA_DESTRUCTIVOS || '';
|
|
68
|
+
if (!raw) {
|
|
69
|
+
extraDestructiveCacheKey = '';
|
|
70
|
+
extraDestructiveCacheRegex = null;
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
if (raw === extraDestructiveCacheKey) {
|
|
74
|
+
return extraDestructiveCacheRegex;
|
|
75
|
+
}
|
|
76
|
+
// The env value just changed; reset the once-per-pattern warning gate
|
|
77
|
+
// so a subsequent *different* invalid regex is also reported once. The
|
|
78
|
+
// previous shape kept the flag sticky and silently swallowed the
|
|
79
|
+
// second bad pattern in a long-running process.
|
|
80
|
+
extraDestructiveCacheKey = raw;
|
|
81
|
+
extraDestructiveWarnLogged = false;
|
|
82
|
+
try {
|
|
83
|
+
extraDestructiveCacheRegex = new RegExp(raw, 'i');
|
|
84
|
+
} catch (err) {
|
|
85
|
+
extraDestructiveCacheRegex = null;
|
|
86
|
+
if (!extraDestructiveWarnLogged) {
|
|
87
|
+
try {
|
|
88
|
+
process.stderr.write(`[verificacion-factual] se ignora el regex inválido de THEUS_VERIFICACION_EXTRA_DESTRUCTIVOS: ${err.message}\n`);
|
|
89
|
+
} catch (_) {
|
|
90
|
+
/* stderr write failure is non-fatal */
|
|
91
|
+
}
|
|
92
|
+
extraDestructiveWarnLogged = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return extraDestructiveCacheRegex;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Operator-supplied path exemptions. Comma-separated globs (`THEUS_VERIFICACION_GLOBS_EXENTOS`)
|
|
99
|
+
// matched against the normalized (forward-slash, lowercased) file path. First-touch
|
|
100
|
+
// fact-forcing is skipped for a matching Edit/Write/MultiEdit target — intended for
|
|
101
|
+
// low-import-value trees (tests, generated artifacts, scratch dirs) where "who imports
|
|
102
|
+
// this / what schema" carries no signal. Memoized on the env value; fail-open (a
|
|
103
|
+
// malformed pattern is dropped, never throws). `*` matches within a path segment,
|
|
104
|
+
// `**` across segments, `?` a single char.
|
|
105
|
+
let exemptCacheKey = null;
|
|
106
|
+
let exemptCacheRegexes = null;
|
|
107
|
+
function getExemptMatchers() {
|
|
108
|
+
const raw = process.env.THEUS_VERIFICACION_GLOBS_EXENTOS || '';
|
|
109
|
+
if (raw === exemptCacheKey) {
|
|
110
|
+
return exemptCacheRegexes;
|
|
111
|
+
}
|
|
112
|
+
exemptCacheKey = raw;
|
|
113
|
+
exemptCacheRegexes = raw
|
|
114
|
+
.split(',')
|
|
115
|
+
.map(s => s.trim())
|
|
116
|
+
.filter(Boolean)
|
|
117
|
+
.map(glob => {
|
|
118
|
+
const source = glob
|
|
119
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&') // escape regex metachars, keep * and ?
|
|
120
|
+
.split('**') // ** boundaries (cross-segment)
|
|
121
|
+
.map(part => part.replace(/\*/g, '[^/]*').replace(/\?/g, '.'))
|
|
122
|
+
.join('.*'); // ** -> across segments
|
|
123
|
+
try {
|
|
124
|
+
return new RegExp(source);
|
|
125
|
+
} catch (_) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
.filter(Boolean);
|
|
130
|
+
return exemptCacheRegexes;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function isExemptPath(filePath) {
|
|
134
|
+
const norm = normalizeForMatch(filePath);
|
|
135
|
+
return getExemptMatchers().some(re => re.test(norm));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function isRoutineBashGateDisabled() {
|
|
139
|
+
return ENABLE_VALUES.has(normalizeEnvValue(process.env.THEUS_VERIFICACION_BASH_RUTINARIO_OFF));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Strip the contents of single- and double-quoted strings so phrases
|
|
144
|
+
* mentioned inside a commit message or echoed argument do not trigger
|
|
145
|
+
* the destructive detector. Command substitutions are scanned separately
|
|
146
|
+
* before this runs because they execute even inside double quotes.
|
|
147
|
+
*
|
|
148
|
+
* @param {string} input
|
|
149
|
+
* @returns {string}
|
|
150
|
+
*/
|
|
151
|
+
function stripQuotedStrings(input) {
|
|
152
|
+
return input.replace(/'(?:[^'\\]|\\.)*'/g, "''").replace(/"(?:[^"\\]|\\.)*"/g, '""');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Promote subshell delimiters to top-level segment separators so the
|
|
157
|
+
* destructive check applies inside `$(...)` and backtick subshells.
|
|
158
|
+
* Without this, `echo y | $(rm -rf /tmp)` and ``echo y | `rm -rf /tmp` ``
|
|
159
|
+
* slip past the segment splitter because the destructive command lives
|
|
160
|
+
* inside a sub-expression. Run iteratively to handle a layer of nesting.
|
|
161
|
+
*
|
|
162
|
+
* @param {string} input
|
|
163
|
+
* @returns {string}
|
|
164
|
+
*/
|
|
165
|
+
function explodeSubshells(input) {
|
|
166
|
+
let out = input;
|
|
167
|
+
for (let i = 0; i < 4; i += 1) {
|
|
168
|
+
const before = out;
|
|
169
|
+
out = out.replace(/\$\(([^()`]*)\)/g, ';$1;');
|
|
170
|
+
out = out.replace(/`([^`]*)`/g, ';$1;');
|
|
171
|
+
if (out === before) break;
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Split a command line into top-level segments at unquoted shell
|
|
178
|
+
* separators (`;`, `|`, `&`, `&&`, `||`) and across subshells
|
|
179
|
+
* (`$(...)` / backticks). Quoted strings are stripped first so
|
|
180
|
+
* separators inside quotes are not split on. Per-segment comments
|
|
181
|
+
* are also stripped.
|
|
182
|
+
*
|
|
183
|
+
* @param {string} input
|
|
184
|
+
* @returns {string[]}
|
|
185
|
+
*/
|
|
186
|
+
function splitCommandSegments(input) {
|
|
187
|
+
const stripped = explodeSubshells(stripQuotedStrings(input));
|
|
188
|
+
return stripped
|
|
189
|
+
.split(/[;|&]+/)
|
|
190
|
+
.map(segment => segment.replace(/(^|\s)#.*/, '$1').trim())
|
|
191
|
+
.filter(Boolean);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Tokenize a single command segment by whitespace. Quoted strings
|
|
196
|
+
* are already collapsed to empty quotes by `stripQuotedStrings`, so
|
|
197
|
+
* naive whitespace splitting is sufficient.
|
|
198
|
+
*
|
|
199
|
+
* @param {string} segment
|
|
200
|
+
* @returns {string[]}
|
|
201
|
+
*/
|
|
202
|
+
function tokenize(segment) {
|
|
203
|
+
return segment.split(/\s+/).filter(Boolean);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Tokenize a short allowlisted shell command while preserving quoted
|
|
208
|
+
* arguments. This is intentionally smaller than a full shell parser: the
|
|
209
|
+
* caller rejects shell control characters before invoking it, so this only
|
|
210
|
+
* needs to keep spaces inside quotes together for read-only git commands.
|
|
211
|
+
*
|
|
212
|
+
* @param {string} input
|
|
213
|
+
* @returns {string[] | null}
|
|
214
|
+
*/
|
|
215
|
+
function tokenizeAllowlistedShellWords(input) {
|
|
216
|
+
const tokens = [];
|
|
217
|
+
let current = '';
|
|
218
|
+
let quote = null;
|
|
219
|
+
let escaped = false;
|
|
220
|
+
|
|
221
|
+
for (const char of String(input || '')) {
|
|
222
|
+
if (escaped) {
|
|
223
|
+
current += char;
|
|
224
|
+
escaped = false;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (char === '\\') {
|
|
229
|
+
escaped = true;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (quote) {
|
|
234
|
+
if (char === quote) {
|
|
235
|
+
quote = null;
|
|
236
|
+
} else {
|
|
237
|
+
current += char;
|
|
238
|
+
}
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (char === '"' || char === "'") {
|
|
243
|
+
quote = char;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (/\s/.test(char)) {
|
|
248
|
+
if (current) {
|
|
249
|
+
tokens.push(current);
|
|
250
|
+
current = '';
|
|
251
|
+
}
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
current += char;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (escaped) current += '\\';
|
|
259
|
+
if (quote) return null;
|
|
260
|
+
if (current) tokens.push(current);
|
|
261
|
+
return tokens;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const SHELL_SEGMENT_SEPARATORS = new Set([';', '|', '&', '\n', '\r']);
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Quote-aware split of a command line into segments, with quotes removed from
|
|
268
|
+
* the resulting words. Splits only on UNQUOTED `;`, `|`, `&`, and newlines so:
|
|
269
|
+
* - a quoted command word (`'rm'`, `"rm"`) normalizes to `rm` (the shell
|
|
270
|
+
* treats quotes around a command name as transparent), and
|
|
271
|
+
* - a newline behaves as a command separator (the shell runs each line),
|
|
272
|
+
* neither of which `stripQuotedStrings` + naive splitting handles — both were
|
|
273
|
+
* destructive-classifier bypasses (GHSA-4v57-ph3x-gf55).
|
|
274
|
+
*
|
|
275
|
+
* @param {string} input
|
|
276
|
+
* @returns {string[][]} array of dequoted token arrays, one per segment
|
|
277
|
+
*/
|
|
278
|
+
function quoteAwareSegments(input) {
|
|
279
|
+
const segments = [];
|
|
280
|
+
let words = [];
|
|
281
|
+
let current = '';
|
|
282
|
+
let hasWord = false;
|
|
283
|
+
let quote = null;
|
|
284
|
+
let escaped = false;
|
|
285
|
+
|
|
286
|
+
const flushWord = () => {
|
|
287
|
+
if (hasWord) words.push(current);
|
|
288
|
+
current = '';
|
|
289
|
+
hasWord = false;
|
|
290
|
+
};
|
|
291
|
+
const flushSegment = () => {
|
|
292
|
+
flushWord();
|
|
293
|
+
if (words.length) segments.push(words);
|
|
294
|
+
words = [];
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
for (const ch of String(input || '')) {
|
|
298
|
+
if (escaped) {
|
|
299
|
+
current += ch;
|
|
300
|
+
hasWord = true;
|
|
301
|
+
escaped = false;
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (ch === '\\') {
|
|
305
|
+
escaped = true;
|
|
306
|
+
hasWord = true;
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (quote) {
|
|
310
|
+
if (ch === quote) quote = null;
|
|
311
|
+
else current += ch;
|
|
312
|
+
hasWord = true;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (ch === '"' || ch === "'") {
|
|
316
|
+
quote = ch;
|
|
317
|
+
hasWord = true; // entering a quote starts a word, even if its content is empty
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (SHELL_SEGMENT_SEPARATORS.has(ch)) {
|
|
321
|
+
flushSegment();
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (/\s/.test(ch)) {
|
|
325
|
+
flushWord();
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
current += ch;
|
|
329
|
+
hasWord = true;
|
|
330
|
+
}
|
|
331
|
+
flushSegment();
|
|
332
|
+
return segments;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const SHELL_WRAPPERS = new Set(['sh', 'bash', 'zsh', 'dash', 'ksh']);
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Quote-aware destructive check: catches quoted command words, newline
|
|
339
|
+
* separators, quoted `find -exec`, and `sh -c`/`bash -c` wrappers that evade
|
|
340
|
+
* the quote-stripping path (GHSA-4v57-ph3x-gf55).
|
|
341
|
+
*
|
|
342
|
+
* @param {string} raw
|
|
343
|
+
* @param {number} [depth] recursion guard for shell -c wrappers
|
|
344
|
+
* @returns {boolean}
|
|
345
|
+
*/
|
|
346
|
+
function isDestructiveQuoteAware(raw, depth = 0) {
|
|
347
|
+
if (depth > 4) return false;
|
|
348
|
+
for (const tokens of quoteAwareSegments(raw)) {
|
|
349
|
+
if (tokens.length === 0) continue;
|
|
350
|
+
if (isDestructiveRm(tokens)) return true;
|
|
351
|
+
if (isDestructiveGit(tokens)) return true;
|
|
352
|
+
if (isDestructiveFindExec(tokens.join(' '))) return true;
|
|
353
|
+
const base = commandBasename(tokens[0]);
|
|
354
|
+
if (SHELL_WRAPPERS.has(base)) {
|
|
355
|
+
const ci = tokens.indexOf('-c');
|
|
356
|
+
if (ci !== -1 && tokens[ci + 1] && isDestructiveQuoteAware(tokens[ci + 1], depth + 1)) {
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Strip a leading path and trailing `.exe` from a command token so
|
|
366
|
+
* `/usr/bin/git`, `git.exe`, and `GIT` all normalize to `git`.
|
|
367
|
+
*
|
|
368
|
+
* @param {string} token
|
|
369
|
+
* @returns {string}
|
|
370
|
+
*/
|
|
371
|
+
function commandBasename(token) {
|
|
372
|
+
if (!token) return '';
|
|
373
|
+
return token
|
|
374
|
+
.replace(/^.*[\\/]/, '')
|
|
375
|
+
.replace(/\.exe$/i, '')
|
|
376
|
+
.toLowerCase();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Detect `rm` invocations that recursively force-delete files. Handles
|
|
381
|
+
* combined (`-rf`, `-fr`, `-Rf`) and split (`-r -f`) flag forms.
|
|
382
|
+
*
|
|
383
|
+
* @param {string[]} tokens
|
|
384
|
+
* @returns {boolean}
|
|
385
|
+
*/
|
|
386
|
+
function isDestructiveRm(tokens) {
|
|
387
|
+
if (tokens.length === 0 || commandBasename(tokens[0]) !== 'rm') return false;
|
|
388
|
+
let hasR = false;
|
|
389
|
+
let hasF = false;
|
|
390
|
+
for (const t of tokens.slice(1)) {
|
|
391
|
+
if (t === '--recursive') {
|
|
392
|
+
hasR = true;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (t === '--force') {
|
|
396
|
+
hasF = true;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
if (!t.startsWith('-') || t.startsWith('--')) continue;
|
|
400
|
+
const body = t.slice(1);
|
|
401
|
+
if (/[rR]/.test(body)) hasR = true;
|
|
402
|
+
if (/f/.test(body)) hasF = true;
|
|
403
|
+
}
|
|
404
|
+
return hasR && hasF;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Locate the git subcommand within a token list, skipping over git's
|
|
409
|
+
* global options like `-c key=value`, `-C <path>`, `--git-dir=...`,
|
|
410
|
+
* `--work-tree=...`, `--namespace=...`, `--super-prefix=...`.
|
|
411
|
+
*
|
|
412
|
+
* @param {string[]} tokens
|
|
413
|
+
* @returns {{ command: string, rest: string[] } | null}
|
|
414
|
+
*/
|
|
415
|
+
function findGitSubcommand(tokens) {
|
|
416
|
+
if (tokens.length === 0 || commandBasename(tokens[0]) !== 'git') return null;
|
|
417
|
+
const valueConsumingShort = new Set(['-c', '-C']);
|
|
418
|
+
const valueConsumingLong = new Set(['--git-dir', '--work-tree', '--namespace', '--super-prefix']);
|
|
419
|
+
let i = 1;
|
|
420
|
+
while (i < tokens.length) {
|
|
421
|
+
const t = tokens[i];
|
|
422
|
+
if (valueConsumingShort.has(t) || valueConsumingLong.has(t)) {
|
|
423
|
+
i += 2;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
if (t.startsWith('--git-dir=') || t.startsWith('--work-tree=') || t.startsWith('--namespace=') || t.startsWith('--super-prefix=')) {
|
|
427
|
+
i += 1;
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
if (t.startsWith('-')) {
|
|
431
|
+
// Unknown global option — skip without consuming a value.
|
|
432
|
+
i += 1;
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
return { command: t.toLowerCase(), rest: tokens.slice(i + 1) };
|
|
436
|
+
}
|
|
437
|
+
return null;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Detect destructive `git` invocations: `reset --hard`, `checkout --`,
|
|
442
|
+
* `clean -f...`, `push --force` (but not `--force-with-lease`),
|
|
443
|
+
* `commit --amend`, `rm -rf`.
|
|
444
|
+
*
|
|
445
|
+
* @param {string[]} tokens
|
|
446
|
+
* @returns {boolean}
|
|
447
|
+
*/
|
|
448
|
+
function isDestructiveGit(tokens) {
|
|
449
|
+
const sub = findGitSubcommand(tokens);
|
|
450
|
+
if (!sub) return false;
|
|
451
|
+
const { command, rest } = sub;
|
|
452
|
+
|
|
453
|
+
if (command === 'reset') {
|
|
454
|
+
return rest.includes('--hard');
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (command === 'checkout') {
|
|
458
|
+
// `git checkout -- <path>`, `git checkout .`, and the force forms
|
|
459
|
+
// (`--force` / `-f`) all discard uncommitted working-tree changes,
|
|
460
|
+
// mirroring the `switch` handler below.
|
|
461
|
+
return rest.some(t => {
|
|
462
|
+
if (t === '--' || t === '.' || t === '--force') return true;
|
|
463
|
+
if (!t.startsWith('-') || t.startsWith('--')) return false;
|
|
464
|
+
return t.slice(1).includes('f');
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (command === 'clean') {
|
|
469
|
+
// `git clean -f`, `-fd`, `-fdx`, `-df`, `--force`
|
|
470
|
+
return rest.some(t => {
|
|
471
|
+
if (t === '--force') return true;
|
|
472
|
+
if (!t.startsWith('-') || t.startsWith('--')) return false;
|
|
473
|
+
return t.slice(1).includes('f');
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (command === 'push') {
|
|
478
|
+
// Only `--force-with-lease` qualifies as a safety-checked force.
|
|
479
|
+
// `--force-if-includes` is a no-op when used WITHOUT
|
|
480
|
+
// `--force-with-lease` (per git-scm.com/docs/git-push), and when
|
|
481
|
+
// combined with a bare `--force` the bare force is still in effect.
|
|
482
|
+
// So `--force --force-if-includes` must be treated as destructive.
|
|
483
|
+
//
|
|
484
|
+
// A `+` refspec prefix (e.g. `git push origin +main`,
|
|
485
|
+
// `+refs/heads/main:refs/heads/main`) also forces a non-fast-forward
|
|
486
|
+
// update of that ref and is destructive on its own.
|
|
487
|
+
let withLease = false;
|
|
488
|
+
let bareForce = false;
|
|
489
|
+
let plusRefspecForce = false;
|
|
490
|
+
for (const t of rest) {
|
|
491
|
+
if (t === '--force-with-lease' || t.startsWith('--force-with-lease=')) {
|
|
492
|
+
withLease = true;
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (t === '--force' || t.startsWith('--force=')) {
|
|
496
|
+
bareForce = true;
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
if (t.startsWith('-') && !t.startsWith('--') && t.slice(1).includes('f')) {
|
|
500
|
+
bareForce = true;
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
// Refspec prefix: `+<src>[:<dst>]`. Match tokens like `+main`,
|
|
504
|
+
// `+refs/heads/main`, `+HEAD:branch`, `+:branch`. Exclude bare
|
|
505
|
+
// `+` and numeric-only `+123` which are not refspecs.
|
|
506
|
+
if (t.startsWith('+') && t.length > 1 && /^\+(?:[a-zA-Z_/.:]|HEAD)/.test(t)) {
|
|
507
|
+
plusRefspecForce = true;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return bareForce || (plusRefspecForce && !withLease);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (command === 'commit') {
|
|
514
|
+
return rest.includes('--amend');
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (command === 'rm') {
|
|
518
|
+
// `git rm -r` / `-rf` / `-r -f` — destructive within the index too.
|
|
519
|
+
let hasR = false;
|
|
520
|
+
for (const t of rest) {
|
|
521
|
+
if (!t.startsWith('-') || t.startsWith('--')) continue;
|
|
522
|
+
if (/[rR]/.test(t.slice(1))) hasR = true;
|
|
523
|
+
}
|
|
524
|
+
return hasR;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (command === 'switch') {
|
|
528
|
+
// `git switch` can discard local working-tree changes in three forms:
|
|
529
|
+
// --discard-changes explicit discard
|
|
530
|
+
// --force / -f ignore conflicts and overwrite
|
|
531
|
+
// -C <branch> force-create (overwrites existing branch)
|
|
532
|
+
return rest.some(t => {
|
|
533
|
+
if (t === '--discard-changes' || t === '--force') return true;
|
|
534
|
+
if (!t.startsWith('-') || t.startsWith('--')) return false;
|
|
535
|
+
// Short combined form: -f, -fC, -Cf, -C
|
|
536
|
+
const body = t.slice(1);
|
|
537
|
+
return /[fC]/.test(body);
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Decide whether a bash command line contains a destructive action
|
|
546
|
+
* the fact-forcing gate should challenge. Combines SQL-keyword
|
|
547
|
+
* detection (regex on quote-stripped input) with per-segment shell
|
|
548
|
+
* tokenization for shell commands.
|
|
549
|
+
*
|
|
550
|
+
* @param {string} command
|
|
551
|
+
* @returns {boolean}
|
|
552
|
+
*/
|
|
553
|
+
/**
|
|
554
|
+
* Walk every executable body reachable from a raw command line and
|
|
555
|
+
* return them as a flat list. Bodies that bash will execute live in
|
|
556
|
+
* three different syntactic constructs, each handled by a sibling
|
|
557
|
+
* extractor in `scripts/lib/shell-substitution.js`:
|
|
558
|
+
* - `$(...)` and backticks via `extractCommandSubstitutions`
|
|
559
|
+
* - plain `(...)` subshells via `extractSubshellGroups`
|
|
560
|
+
* - `{ ...; }` brace groups via `extractBraceGroups`
|
|
561
|
+
*
|
|
562
|
+
* Each extractor recurses into its own syntax. The BFS here adds
|
|
563
|
+
* cross-syntax discovery — e.g. a `(...)` inside a `$(...)` body, or
|
|
564
|
+
* a `{ ...; }` inside a `(...)` body — by feeding every harvested
|
|
565
|
+
* body back through all three extractors. A `seen` set bounds the
|
|
566
|
+
* cost to O(unique bodies).
|
|
567
|
+
*
|
|
568
|
+
* @param {string} raw
|
|
569
|
+
* @returns {string[]}
|
|
570
|
+
*/
|
|
571
|
+
function collectExecutableBodies(raw) {
|
|
572
|
+
const bodies = [raw];
|
|
573
|
+
const queue = [raw];
|
|
574
|
+
const seen = new Set();
|
|
575
|
+
|
|
576
|
+
while (queue.length) {
|
|
577
|
+
const current = queue.shift();
|
|
578
|
+
if (seen.has(current)) continue;
|
|
579
|
+
seen.add(current);
|
|
580
|
+
|
|
581
|
+
for (const body of extractCommandSubstitutions(current)) {
|
|
582
|
+
if (seen.has(body)) continue;
|
|
583
|
+
bodies.push(body);
|
|
584
|
+
queue.push(body);
|
|
585
|
+
}
|
|
586
|
+
for (const body of extractSubshellGroups(current)) {
|
|
587
|
+
if (seen.has(body)) continue;
|
|
588
|
+
bodies.push(body);
|
|
589
|
+
queue.push(body);
|
|
590
|
+
}
|
|
591
|
+
for (const body of extractBraceGroups(current)) {
|
|
592
|
+
if (seen.has(body)) continue;
|
|
593
|
+
bodies.push(body);
|
|
594
|
+
queue.push(body);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
return bodies;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Detect destructive commands inside `find ... -exec` invocations.
|
|
603
|
+
* Handles `-exec rm {} \;`, `-exec rm -rf {} \;`, `-exec rmdir {} \;`,
|
|
604
|
+
* `-exec unlink {} \;`, `-exec git reset --hard {} \;`.
|
|
605
|
+
*
|
|
606
|
+
* @param {string} command
|
|
607
|
+
* @returns {boolean}
|
|
608
|
+
*/
|
|
609
|
+
function isDestructiveFindExec(command) {
|
|
610
|
+
const raw = String(command || '');
|
|
611
|
+
const trimmed = raw.trim();
|
|
612
|
+
if (!trimmed) {
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// Tokenize the whole command line
|
|
617
|
+
const tokens = tokenize(trimmed);
|
|
618
|
+
if (!tokens || tokens.length === 0) {
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// Must start with `find`
|
|
623
|
+
if (commandBasename(tokens[0]) !== 'find') {
|
|
624
|
+
return false;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// Find the `-exec` token
|
|
628
|
+
const execIndex = tokens.indexOf('-exec');
|
|
629
|
+
if (execIndex === -1) {
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// Collect tokens after `-exec` until we hit a terminator (`;`, `\;`, or `+`)
|
|
634
|
+
const execTokens = [];
|
|
635
|
+
for (let i = execIndex + 1; i < tokens.length; i++) {
|
|
636
|
+
const token = tokens[i];
|
|
637
|
+
if (token === ';' || token === '\\;' || token === '+') {
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
execTokens.push(token);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
if (execTokens.length === 0) {
|
|
644
|
+
return false;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const baseCmd = commandBasename(execTokens[0]);
|
|
648
|
+
|
|
649
|
+
// Directly destructive commands inside -exec
|
|
650
|
+
if (baseCmd === 'rmdir' || baseCmd === 'unlink') {
|
|
651
|
+
return true;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// `rm` with any flags (including none) inside -exec is destructive
|
|
655
|
+
if (baseCmd === 'rm') {
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// `git reset --hard` inside -exec
|
|
660
|
+
if (baseCmd === 'git') {
|
|
661
|
+
const sub = findGitSubcommand(execTokens);
|
|
662
|
+
if (sub && sub.command === 'reset' && sub.rest.includes('--hard')) {
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
return false;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function isDestructiveBash(command) {
|
|
671
|
+
// The SQL/dd phrases live in command bodies, not as flag-bearing
|
|
672
|
+
// arguments, so we still match them by regex — but on the input
|
|
673
|
+
// after quoting AND subshell delimiters are normalized so phrases
|
|
674
|
+
// inside `$(...)` or backticks are also caught.
|
|
675
|
+
const raw = String(command || '');
|
|
676
|
+
const flattened = explodeSubshells(stripQuotedStrings(raw));
|
|
677
|
+
if (DESTRUCTIVE_SQL_DD.test(flattened)) return true;
|
|
678
|
+
|
|
679
|
+
// Operator-supplied additional destructive patterns. Same scope as the
|
|
680
|
+
// built-in SQL/dd regex: matched against the quote-stripped, subshell-
|
|
681
|
+
// exploded command so a phrase inside `$(...)` or backticks is caught.
|
|
682
|
+
const extra = getExtraDestructiveRegex();
|
|
683
|
+
if (extra && extra.test(flattened)) return true;
|
|
684
|
+
|
|
685
|
+
// Check for destructive find -exec patterns on raw body segments (before quote-stripping)
|
|
686
|
+
// so that quoted exec binaries and compound-command prefixes are both handled correctly.
|
|
687
|
+
// splitCommandSegments strips quotes before splitting, so passing its output to
|
|
688
|
+
// isDestructiveFindExec would turn `find . -exec 'rm' {} \;` into `find . -exec {} \;`
|
|
689
|
+
// — the binary name disappears and the check returns false. Using raw body text avoids
|
|
690
|
+
// that false-negative while also catching `&&`, `;`, `|`, and `||` compound forms.
|
|
691
|
+
const bodies = collectExecutableBodies(raw);
|
|
692
|
+
for (const body of bodies) {
|
|
693
|
+
for (const rawSeg of body
|
|
694
|
+
.split(/[;|&]+/)
|
|
695
|
+
.map(s => s.trim())
|
|
696
|
+
.filter(Boolean)) {
|
|
697
|
+
if (isDestructiveFindExec(rawSeg)) return true;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
const segments = bodies.flatMap(splitCommandSegments);
|
|
702
|
+
for (const segment of segments) {
|
|
703
|
+
const stripped = stripQuotedStrings(segment);
|
|
704
|
+
if (DESTRUCTIVE_SQL_DD.test(stripped)) return true;
|
|
705
|
+
if (extra && extra.test(stripped)) return true;
|
|
706
|
+
const tokens = tokenize(segment);
|
|
707
|
+
if (isDestructiveRm(tokens)) return true;
|
|
708
|
+
if (isDestructiveGit(tokens)) return true;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// Quote-aware pass: closes the quoted-command-word, newline-separator,
|
|
712
|
+
// quoted-find-exec, and sh/bash -c bypasses (GHSA-4v57-ph3x-gf55).
|
|
713
|
+
if (isDestructiveQuoteAware(raw)) return true;
|
|
714
|
+
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// --- State management (per-session, atomic writes, bounded) ---
|
|
719
|
+
|
|
720
|
+
function normalizeEnvValue(value) {
|
|
721
|
+
return String(value || '')
|
|
722
|
+
.trim()
|
|
723
|
+
.toLowerCase();
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function isVerificacionFactualDisabled() {
|
|
727
|
+
if (normalizeEnvValue(process.env.THEUS_VERIFICACION_FACTUAL_OFF) === '1') {
|
|
728
|
+
return true;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
return DISABLE_VALUES.has(normalizeEnvValue(process.env.THEUS_VERIFICACION_FACTUAL));
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function sanitizeSessionKey(value) {
|
|
735
|
+
const raw = String(value || '').trim();
|
|
736
|
+
if (!raw) {
|
|
737
|
+
return '';
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
const sanitized = raw.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
741
|
+
if (sanitized && sanitized.length <= 64) {
|
|
742
|
+
return sanitized;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
return hashSessionKey('sid', raw);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
function hashSessionKey(prefix, value) {
|
|
749
|
+
return `${prefix}-${crypto.createHash('sha256').update(String(value)).digest('hex').slice(0, 24)}`;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
function resolveSessionKey(data) {
|
|
753
|
+
const directCandidates = [data && data.session_id, data && data.sessionId, data && data.session && data.session.id, process.env.THEUS_SESSION_ID];
|
|
754
|
+
|
|
755
|
+
for (const candidate of directCandidates) {
|
|
756
|
+
const sanitized = sanitizeSessionKey(candidate);
|
|
757
|
+
if (sanitized) {
|
|
758
|
+
return sanitized;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
const transcriptPath = (data && (data.transcript_path || data.transcriptPath)) || process.env.THEUS_TRANSCRIPT_PATH;
|
|
763
|
+
if (transcriptPath && String(transcriptPath).trim()) {
|
|
764
|
+
return hashSessionKey('tx', path.resolve(String(transcriptPath).trim()));
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
const projectFingerprint = process.env.THEUS_PROJECT_DIR || process.cwd();
|
|
768
|
+
return hashSessionKey('proj', path.resolve(projectFingerprint));
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function getStateFile(data) {
|
|
772
|
+
if (!activeStateFile) {
|
|
773
|
+
const sessionKey = resolveSessionKey(data);
|
|
774
|
+
activeStateFile = path.join(STATE_DIR, `state-${sessionKey}.json`);
|
|
775
|
+
}
|
|
776
|
+
return activeStateFile;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
function loadState() {
|
|
780
|
+
const stateFile = getStateFile();
|
|
781
|
+
try {
|
|
782
|
+
if (fs.existsSync(stateFile)) {
|
|
783
|
+
const state = JSON.parse(fs.readFileSync(stateFile, 'utf8'));
|
|
784
|
+
const lastActive = state.last_active || 0;
|
|
785
|
+
if (Date.now() - lastActive > SESSION_TIMEOUT_MS) {
|
|
786
|
+
try {
|
|
787
|
+
fs.unlinkSync(stateFile);
|
|
788
|
+
} catch (_) {
|
|
789
|
+
/* ignore */
|
|
790
|
+
}
|
|
791
|
+
return { checked: [], last_active: Date.now() };
|
|
792
|
+
}
|
|
793
|
+
return state;
|
|
794
|
+
}
|
|
795
|
+
} catch (_) {
|
|
796
|
+
/* ignore */
|
|
797
|
+
}
|
|
798
|
+
return { checked: [], last_active: Date.now() };
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
function pruneCheckedEntries(checked) {
|
|
802
|
+
if (checked.length <= MAX_CHECKED_ENTRIES) {
|
|
803
|
+
return checked;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
const preserved = checked.includes(ROUTINE_BASH_SESSION_KEY) ? [ROUTINE_BASH_SESSION_KEY] : [];
|
|
807
|
+
const sessionKeys = checked.filter(k => k.startsWith('__') && k !== ROUTINE_BASH_SESSION_KEY);
|
|
808
|
+
const fileKeys = checked.filter(k => !k.startsWith('__'));
|
|
809
|
+
const remainingSessionSlots = Math.max(MAX_SESSION_KEYS - preserved.length, 0);
|
|
810
|
+
const cappedSession = sessionKeys.slice(-remainingSessionSlots);
|
|
811
|
+
const remainingFileSlots = Math.max(MAX_CHECKED_ENTRIES - preserved.length - cappedSession.length, 0);
|
|
812
|
+
const cappedFiles = fileKeys.slice(-remainingFileSlots);
|
|
813
|
+
return [...preserved, ...cappedSession, ...cappedFiles];
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
function saveState(state) {
|
|
817
|
+
const stateFile = getStateFile();
|
|
818
|
+
let tmpFile = null;
|
|
819
|
+
try {
|
|
820
|
+
fs.mkdirSync(STATE_DIR, { recursive: true });
|
|
821
|
+
|
|
822
|
+
let mergedChecked = Array.isArray(state.checked) ? state.checked : [];
|
|
823
|
+
let mergedLastActive = typeof state.last_active === 'number' ? state.last_active : 0;
|
|
824
|
+
let mergedDenials = getDenialCount(state);
|
|
825
|
+
|
|
826
|
+
try {
|
|
827
|
+
if (fs.existsSync(stateFile)) {
|
|
828
|
+
const diskState = JSON.parse(fs.readFileSync(stateFile, 'utf8'));
|
|
829
|
+
if (Array.isArray(diskState.checked)) {
|
|
830
|
+
mergedChecked = Array.from(new Set([...diskState.checked, ...mergedChecked]));
|
|
831
|
+
}
|
|
832
|
+
if (typeof diskState.last_active === 'number') {
|
|
833
|
+
mergedLastActive = Math.max(mergedLastActive, diskState.last_active);
|
|
834
|
+
}
|
|
835
|
+
mergedDenials = Math.max(mergedDenials, getDenialCount(diskState));
|
|
836
|
+
}
|
|
837
|
+
} catch (_) {
|
|
838
|
+
/* ignore malformed or transient disk state */
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
const finalState = {
|
|
842
|
+
checked: pruneCheckedEntries(mergedChecked),
|
|
843
|
+
last_active: Math.max(mergedLastActive, Date.now()),
|
|
844
|
+
fact_force_denials: mergedDenials
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
// Atomic write: temp file + rename prevents partial reads
|
|
848
|
+
tmpFile = `${stateFile}.tmp.${process.pid}.${crypto.randomBytes(4).toString('hex')}`;
|
|
849
|
+
fs.writeFileSync(tmpFile, JSON.stringify(finalState, null, 2), 'utf8');
|
|
850
|
+
try {
|
|
851
|
+
fs.renameSync(tmpFile, stateFile);
|
|
852
|
+
} catch (error) {
|
|
853
|
+
if (error && (error.code === 'EEXIST' || error.code === 'EPERM')) {
|
|
854
|
+
try {
|
|
855
|
+
fs.unlinkSync(stateFile);
|
|
856
|
+
} catch (_) {
|
|
857
|
+
/* ignore */
|
|
858
|
+
}
|
|
859
|
+
fs.renameSync(tmpFile, stateFile);
|
|
860
|
+
} else {
|
|
861
|
+
throw error;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
tmpFile = null;
|
|
865
|
+
return true;
|
|
866
|
+
} catch (_) {
|
|
867
|
+
if (tmpFile) {
|
|
868
|
+
try {
|
|
869
|
+
fs.unlinkSync(tmpFile);
|
|
870
|
+
} catch (_) {
|
|
871
|
+
/* ignore */
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function markChecked(key) {
|
|
879
|
+
const state = loadState();
|
|
880
|
+
if (!state.checked.includes(key)) {
|
|
881
|
+
state.checked.push(key);
|
|
882
|
+
return saveState(state);
|
|
883
|
+
}
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
// --- Fact-force denial dampening (#2142) ---
|
|
888
|
+
//
|
|
889
|
+
// In long sessions the near-identical four-fact deny blocks accumulate in
|
|
890
|
+
// the context window and measurably raise the odds of the model dropping
|
|
891
|
+
// into a degenerate repetition loop. Emit the full four-fact block only for
|
|
892
|
+
// the first THEUS_VERIFICACION_BLOQUEOS_COMPLETOS denials per session (default
|
|
893
|
+
// 3); afterwards emit a condensed single-line denial that carries the
|
|
894
|
+
// denial ordinal, so consecutive denials are structurally different and
|
|
895
|
+
// never textually identical. True retries of an already-gated target are
|
|
896
|
+
// unaffected (they were always allowed). Destructive-Bash and routine-Bash
|
|
897
|
+
// gates are unchanged.
|
|
898
|
+
|
|
899
|
+
const DEFAULT_FULL_DENIALS = 3;
|
|
900
|
+
|
|
901
|
+
function getFullDenialBudget() {
|
|
902
|
+
const raw = Number.parseInt(process.env.THEUS_VERIFICACION_BLOQUEOS_COMPLETOS || '', 10);
|
|
903
|
+
if (Number.isInteger(raw) && raw >= 0) {
|
|
904
|
+
return raw;
|
|
905
|
+
}
|
|
906
|
+
return DEFAULT_FULL_DENIALS;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function getDenialCount(state) {
|
|
910
|
+
const n = Number(state && state.fact_force_denials);
|
|
911
|
+
return Number.isFinite(n) && n >= 0 ? Math.floor(n) : 0;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Record a first-touch target AND count the fact-force denial in the same
|
|
916
|
+
* state write. Returns the new denial ordinal (1-based) plus whether the
|
|
917
|
+
* write persisted.
|
|
918
|
+
*/
|
|
919
|
+
function markCheckedAndCountDenial(key) {
|
|
920
|
+
const state = loadState();
|
|
921
|
+
if (!state.checked.includes(key)) {
|
|
922
|
+
state.checked.push(key);
|
|
923
|
+
}
|
|
924
|
+
const denials = getDenialCount(state) + 1;
|
|
925
|
+
state.fact_force_denials = denials;
|
|
926
|
+
return { ok: saveState(state), denials };
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
function isChecked(key) {
|
|
930
|
+
const state = loadState();
|
|
931
|
+
const found = state.checked.includes(key);
|
|
932
|
+
if (found && Date.now() - (state.last_active || 0) > READ_HEARTBEAT_MS) {
|
|
933
|
+
saveState(state);
|
|
934
|
+
}
|
|
935
|
+
return found;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// Prune stale session files older than 1 hour
|
|
939
|
+
(function pruneStaleFiles() {
|
|
940
|
+
try {
|
|
941
|
+
const files = fs.readdirSync(STATE_DIR);
|
|
942
|
+
const now = Date.now();
|
|
943
|
+
for (const f of files) {
|
|
944
|
+
const isStateFile = f.startsWith('state-') && (f.endsWith('.json') || f.includes('.json.tmp.'));
|
|
945
|
+
if (!isStateFile) continue;
|
|
946
|
+
const fp = path.join(STATE_DIR, f);
|
|
947
|
+
try {
|
|
948
|
+
const stat = fs.statSync(fp);
|
|
949
|
+
if (now - stat.mtimeMs > SESSION_TIMEOUT_MS * 2) {
|
|
950
|
+
fs.unlinkSync(fp);
|
|
951
|
+
}
|
|
952
|
+
} catch (_) {
|
|
953
|
+
// Ignore files that disappear between readdir/stat/unlink.
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
} catch (_) {
|
|
957
|
+
/* ignore */
|
|
958
|
+
}
|
|
959
|
+
})();
|
|
960
|
+
|
|
961
|
+
// --- Sanitize file path against injection ---
|
|
962
|
+
|
|
963
|
+
function sanitizePath(filePath) {
|
|
964
|
+
// Strip control chars (including null), bidi overrides, and newlines
|
|
965
|
+
let sanitized = '';
|
|
966
|
+
for (const char of String(filePath || '')) {
|
|
967
|
+
const code = char.codePointAt(0);
|
|
968
|
+
const isAsciiControl = code <= 0x1f || code === 0x7f;
|
|
969
|
+
const isBidiOverride = (code >= 0x200e && code <= 0x200f) || (code >= 0x202a && code <= 0x202e) || (code >= 0x2066 && code <= 0x2069);
|
|
970
|
+
sanitized += isAsciiControl || isBidiOverride ? ' ' : char;
|
|
971
|
+
}
|
|
972
|
+
return sanitized.trim().slice(0, 500);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
function normalizeForMatch(value) {
|
|
976
|
+
return String(value || '')
|
|
977
|
+
.replace(/\\/g, '/')
|
|
978
|
+
.toLowerCase();
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
function isTheusSettingsPath(filePath) {
|
|
982
|
+
const normalized = normalizeForMatch(filePath);
|
|
983
|
+
return /(^|\/)\.theus\/settings(?:\.[^/]+)?\.json$/.test(normalized);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
function isReadOnlyGitIntrospection(command) {
|
|
987
|
+
const trimmed = String(command || '').trim();
|
|
988
|
+
if (!trimmed || /[\r\n;&|><`$()]/.test(trimmed)) {
|
|
989
|
+
return false;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
const segments = splitCommandSegments(trimmed);
|
|
993
|
+
if (segments.length !== 1) {
|
|
994
|
+
return false;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
const tokens = tokenizeAllowlistedShellWords(trimmed);
|
|
998
|
+
if (!tokens) {
|
|
999
|
+
return false;
|
|
1000
|
+
}
|
|
1001
|
+
if (commandBasename(tokens[0]) !== 'git' || tokens.length < 2) {
|
|
1002
|
+
return false;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
const subcommand = tokens[1].toLowerCase();
|
|
1006
|
+
const args = tokens.slice(2);
|
|
1007
|
+
|
|
1008
|
+
if (subcommand === 'status') {
|
|
1009
|
+
return args.every(arg => ['--porcelain', '--short', '--branch'].includes(arg));
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
if (subcommand === 'diff') {
|
|
1013
|
+
const allowedDiffArgs = new Set(['--name-only', '--name-status', '--cached', '--staged', '--stat']);
|
|
1014
|
+
// git diff without arguments is read-only introspection
|
|
1015
|
+
if (args.length === 0) return true;
|
|
1016
|
+
return args.length <= 2 && args.every(arg => allowedDiffArgs.has(arg));
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
if (subcommand === 'log') {
|
|
1020
|
+
return args.every(arg => arg === '--oneline' || /^--max-count=\d+$/.test(arg));
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
if (subcommand === 'show') {
|
|
1024
|
+
// Permite: git show <ref>, git show --stat, git show --name-only,
|
|
1025
|
+
// git show <ref> --stat, git show <ref> --name-only
|
|
1026
|
+
if (args.length === 0) return false;
|
|
1027
|
+
if (args.length === 1) {
|
|
1028
|
+
const arg = args[0];
|
|
1029
|
+
if (arg === '--stat' || arg === '--name-only') return true;
|
|
1030
|
+
// ref
|
|
1031
|
+
return !arg.startsWith('--') && /^[a-zA-Z0-9._:/ -]+$/.test(arg);
|
|
1032
|
+
}
|
|
1033
|
+
if (args.length === 2) {
|
|
1034
|
+
const [first, second] = args;
|
|
1035
|
+
// ref + flag
|
|
1036
|
+
if (!first.startsWith('--') && /^[a-zA-Z0-9._:/ -]+$/.test(first) && (second === '--stat' || second === '--name-only')) {
|
|
1037
|
+
return true;
|
|
1038
|
+
}
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
return false;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
if (subcommand === 'branch') {
|
|
1045
|
+
return args.length === 1 && args[0] === '--show-current';
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
if (subcommand === 'rev-parse') {
|
|
1049
|
+
return args.length === 2 && args[0] === '--abbrev-ref' && /^head$/i.test(args[1]);
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
return false;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
// --- Gate messages ---
|
|
1056
|
+
|
|
1057
|
+
function editGateMsg(filePath) {
|
|
1058
|
+
const safe = sanitizePath(filePath);
|
|
1059
|
+
return [
|
|
1060
|
+
'[Puerta de verificación factual]',
|
|
1061
|
+
'',
|
|
1062
|
+
`Antes de editar ${safe}, presenta estos hechos:`,
|
|
1063
|
+
'',
|
|
1064
|
+
'1. Lista TODOS los archivos que importan/requieren este archivo (busca en el árbol — Glob/Grep, o find/grep vía Bash)',
|
|
1065
|
+
'2. Lista las funciones/clases públicas afectadas por este cambio',
|
|
1066
|
+
'3. Si este archivo lee/escribe archivos de datos, muestra nombres de campos, estructura y formato de fecha (usa valores sintéticos o censurados, nunca datos reales de producción)',
|
|
1067
|
+
'4. Cita textualmente la instrucción vigente del usuario',
|
|
1068
|
+
'',
|
|
1069
|
+
'Presenta los hechos y reintenta la misma operación.'
|
|
1070
|
+
].join('\n');
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function writeGateMsg(filePath) {
|
|
1074
|
+
const safe = sanitizePath(filePath);
|
|
1075
|
+
return [
|
|
1076
|
+
'[Puerta de verificación factual]',
|
|
1077
|
+
'',
|
|
1078
|
+
`Antes de crear ${safe}, presenta estos hechos:`,
|
|
1079
|
+
'',
|
|
1080
|
+
'1. Nombra el/los archivo(s) y línea(s) que llamarán a este archivo nuevo',
|
|
1081
|
+
'2. Confirma que ningún archivo existente cumple el mismo propósito (busca en el árbol — Glob/Grep, o find/grep vía Bash)',
|
|
1082
|
+
'3. Si este archivo lee/escribe archivos de datos, muestra nombres de campos, estructura y formato de fecha (usa valores sintéticos o censurados, nunca datos reales de producción)',
|
|
1083
|
+
'4. Cita textualmente la instrucción vigente del usuario',
|
|
1084
|
+
'',
|
|
1085
|
+
'Presenta los hechos y reintenta la misma operación.'
|
|
1086
|
+
].join('\n');
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Condensed single-line denial used after the full-block budget is spent
|
|
1091
|
+
* (#2142). Carries the denial ordinal so consecutive denials differ
|
|
1092
|
+
* textually, and a one-line recovery hint instead of the multi-line block.
|
|
1093
|
+
*/
|
|
1094
|
+
function condensedGateMsg(action, filePath, ordinal) {
|
|
1095
|
+
const safe = sanitizePath(filePath);
|
|
1096
|
+
return (
|
|
1097
|
+
`[Puerta de verificación factual] (bloqueo #${ordinal} en esta sesión) Primer ${action} de ${safe}: ` +
|
|
1098
|
+
'indica brevemente importadores/llamadores, API afectada, esquemas de datos si los hay y la instrucción textual del usuario; luego reintenta. ' +
|
|
1099
|
+
'(THEUS_VERIFICACION_FACTUAL=off desactiva esta puerta.)'
|
|
1100
|
+
);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
function destructiveBashMsg() {
|
|
1104
|
+
return [
|
|
1105
|
+
'[Puerta de verificación factual]',
|
|
1106
|
+
'',
|
|
1107
|
+
'Comando destructivo detectado. Antes de ejecutarlo, presenta:',
|
|
1108
|
+
'',
|
|
1109
|
+
'1. Lista todos los archivos/datos que este comando modificará o eliminará',
|
|
1110
|
+
'2. Escribe un procedimiento de reversión de una línea',
|
|
1111
|
+
'3. Cita textualmente la instrucción vigente del usuario',
|
|
1112
|
+
'',
|
|
1113
|
+
'Presenta los hechos y reintenta la misma operación.'
|
|
1114
|
+
].join('\n');
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
function routineBashMsg() {
|
|
1118
|
+
return [
|
|
1119
|
+
'[Puerta de verificación factual]',
|
|
1120
|
+
'',
|
|
1121
|
+
'Antes del primer comando Bash de esta sesión, presenta estos hechos:',
|
|
1122
|
+
'',
|
|
1123
|
+
'1. La petición vigente del usuario en una sola oración',
|
|
1124
|
+
'2. Qué verifica o produce este comando en concreto',
|
|
1125
|
+
'',
|
|
1126
|
+
'Presenta los hechos y reintenta la misma operación.'
|
|
1127
|
+
].join('\n');
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
function withRecoveryHint(message, hookIds = [EDIT_WRITE_HOOK_ID]) {
|
|
1131
|
+
const disableTargets = hookIds.map(hookId => `\`${hookId}\``).join(' or ');
|
|
1132
|
+
return [message, '', `Recuperación: si la verificación factual bloquea trabajo de configuración o reparación, corre esta sesión con \`THEUS_VERIFICACION_FACTUAL=off\` o añade ${disableTargets} a \`THEUS_DISABLED_HOOKS\`.`].join('\n');
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
function isSubagentInvocation(data) {
|
|
1136
|
+
if (!data || typeof data !== 'object') {
|
|
1137
|
+
return false;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
const candidates = [data.agent_id, data.agentId, data.parent_tool_use_id, data.parentToolUseId];
|
|
1141
|
+
|
|
1142
|
+
return candidates.some(candidate => typeof candidate === 'string' && candidate.trim());
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
// --- Deny helper ---
|
|
1146
|
+
|
|
1147
|
+
function denyResult(reason, options = {}) {
|
|
1148
|
+
const includeRecoveryHint = options.includeRecoveryHint !== false;
|
|
1149
|
+
const hookIds = Array.isArray(options.hookIds) && options.hookIds.length > 0 ? options.hookIds : [EDIT_WRITE_HOOK_ID];
|
|
1150
|
+
return {
|
|
1151
|
+
stdout: JSON.stringify({
|
|
1152
|
+
hookSpecificOutput: {
|
|
1153
|
+
hookEventName: 'PreToolUse',
|
|
1154
|
+
permissionDecision: 'deny',
|
|
1155
|
+
permissionDecisionReason: includeRecoveryHint ? withRecoveryHint(reason, hookIds) : reason
|
|
1156
|
+
}
|
|
1157
|
+
}),
|
|
1158
|
+
exitCode: 0
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
function allowWithStateWarning() {
|
|
1163
|
+
return {
|
|
1164
|
+
stderr: '[Puerta de verificación factual] No se pudo persistir el estado de la verificación factual; se permite esta operación para evitar un bucle de reintentos permanente. Revisa THEUS_VERIFICACION_STATE_DIR o los permisos del sistema de archivos.',
|
|
1165
|
+
exitCode: 0
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
// --- Core logic (exported for run-with-flags.js) ---
|
|
1170
|
+
|
|
1171
|
+
function run(rawInput) {
|
|
1172
|
+
let data;
|
|
1173
|
+
try {
|
|
1174
|
+
data = typeof rawInput === 'string' ? JSON.parse(rawInput) : rawInput;
|
|
1175
|
+
} catch (_) {
|
|
1176
|
+
return rawInput; // allow on parse error
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
if (isVerificacionFactualDisabled()) {
|
|
1180
|
+
return rawInput;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
activeStateFile = null;
|
|
1184
|
+
getStateFile(data);
|
|
1185
|
+
|
|
1186
|
+
const rawToolName = data.tool_name || '';
|
|
1187
|
+
const toolInput = data.tool_input || {};
|
|
1188
|
+
// Normalize: case-insensitive matching via lookup map
|
|
1189
|
+
const TOOL_MAP = { edit: 'Edit', write: 'Write', multiedit: 'MultiEdit', bash: 'Bash' };
|
|
1190
|
+
const toolName = TOOL_MAP[rawToolName.toLowerCase()] || rawToolName;
|
|
1191
|
+
const inSubagent = isSubagentInvocation(data);
|
|
1192
|
+
|
|
1193
|
+
if (toolName === 'Edit' || toolName === 'Write') {
|
|
1194
|
+
const filePath = toolInput.file_path || '';
|
|
1195
|
+
if (!filePath || isTheusSettingsPath(filePath) || isExemptPath(filePath)) {
|
|
1196
|
+
return rawInput; // allow
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
if (inSubagent) {
|
|
1200
|
+
return rawInput; // parent session already passed the first-touch file gate
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
if (!isChecked(filePath)) {
|
|
1204
|
+
const { ok, denials } = markCheckedAndCountDenial(filePath);
|
|
1205
|
+
if (!ok) {
|
|
1206
|
+
return allowWithStateWarning();
|
|
1207
|
+
}
|
|
1208
|
+
if (denials > getFullDenialBudget()) {
|
|
1209
|
+
const action = toolName === 'Edit' ? 'edit' : 'creation';
|
|
1210
|
+
return denyResult(condensedGateMsg(action, filePath, denials), { includeRecoveryHint: false });
|
|
1211
|
+
}
|
|
1212
|
+
return denyResult(toolName === 'Edit' ? editGateMsg(filePath) : writeGateMsg(filePath));
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
return rawInput; // allow
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
if (toolName === 'MultiEdit') {
|
|
1219
|
+
if (inSubagent) {
|
|
1220
|
+
return rawInput; // parent session already passed the first-touch file gate
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
const edits = toolInput.edits || [];
|
|
1224
|
+
for (const edit of edits) {
|
|
1225
|
+
const filePath = edit.file_path || '';
|
|
1226
|
+
if (filePath && !isTheusSettingsPath(filePath) && !isExemptPath(filePath) && !isChecked(filePath)) {
|
|
1227
|
+
const { ok, denials } = markCheckedAndCountDenial(filePath);
|
|
1228
|
+
if (!ok) {
|
|
1229
|
+
return allowWithStateWarning();
|
|
1230
|
+
}
|
|
1231
|
+
if (denials > getFullDenialBudget()) {
|
|
1232
|
+
return denyResult(condensedGateMsg('edit', filePath, denials), { includeRecoveryHint: false });
|
|
1233
|
+
}
|
|
1234
|
+
return denyResult(editGateMsg(filePath));
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
return rawInput; // allow
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
if (toolName === 'Bash') {
|
|
1241
|
+
const command = toolInput.command || '';
|
|
1242
|
+
if (isReadOnlyGitIntrospection(command)) {
|
|
1243
|
+
return rawInput;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
if (isDestructiveBash(command)) {
|
|
1247
|
+
// Gate destructive commands on first attempt; allow retry after facts presented
|
|
1248
|
+
const key = '__destructive__' + crypto.createHash('sha256').update(command).digest('hex').slice(0, 16);
|
|
1249
|
+
if (!isChecked(key)) {
|
|
1250
|
+
if (!markChecked(key)) {
|
|
1251
|
+
return allowWithStateWarning();
|
|
1252
|
+
}
|
|
1253
|
+
return denyResult(destructiveBashMsg(), { includeRecoveryHint: false });
|
|
1254
|
+
}
|
|
1255
|
+
return rawInput; // allow retry after facts presented
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
// Operator opt-out: skip the routine-bash gate entirely. The destructive
|
|
1259
|
+
// gate above still fires. Es la válvula de escape documentada para
|
|
1260
|
+
// entornos donde la puerta rutinaria única por sesión es fricción sin señal.
|
|
1261
|
+
if (isRoutineBashGateDisabled()) {
|
|
1262
|
+
return rawInput; // routine gate opted out via env
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
if (!isChecked(ROUTINE_BASH_SESSION_KEY)) {
|
|
1266
|
+
if (!markChecked(ROUTINE_BASH_SESSION_KEY)) {
|
|
1267
|
+
return allowWithStateWarning();
|
|
1268
|
+
}
|
|
1269
|
+
return denyResult(routineBashMsg(), { hookIds: [BASH_HOOK_ID] });
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
return rawInput; // allow
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
return rawInput; // allow
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
module.exports = { run };
|