nexakit 0.10.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (479) hide show
  1. package/README.md +13 -6
  2. package/assets/runtime/package-lock.json +415 -6
  3. package/bench/casos/arquitectura/alta-usuarios/base/controladores/usuarios.js +16 -0
  4. package/bench/casos/arquitectura/alta-usuarios/base/db.js +14 -0
  5. package/bench/casos/arquitectura/alta-usuarios/base/docs/adr/0003-capas.md +15 -0
  6. package/bench/casos/arquitectura/alta-usuarios/base/errores.js +3 -0
  7. package/bench/casos/arquitectura/alta-usuarios/base/repositorios/usuarios.js +14 -0
  8. package/bench/casos/arquitectura/alta-usuarios/base/servicios/usuarios.js +20 -0
  9. package/bench/casos/arquitectura/alta-usuarios/cambio/controladores/usuarios.js +47 -0
  10. package/bench/casos/arquitectura/alta-usuarios/cambio/repositorios/usuarios.js +21 -0
  11. package/bench/casos/arquitectura/alta-usuarios/cambio/servicios/perfil.js +14 -0
  12. package/bench/casos/arquitectura/alta-usuarios/esperado.json +53 -0
  13. package/bench/casos/arquitectura/pedidos-facturacion/base/docs/adr/0001-capas.md +18 -0
  14. package/bench/casos/arquitectura/pedidos-facturacion/base/src/aplicacion/confirmar.ts +8 -0
  15. package/bench/casos/arquitectura/pedidos-facturacion/base/src/dominio/pedido.ts +15 -0
  16. package/bench/casos/arquitectura/pedidos-facturacion/base/src/dominio/puertos.ts +6 -0
  17. package/bench/casos/arquitectura/pedidos-facturacion/base/src/infra/db.ts +14 -0
  18. package/bench/casos/arquitectura/pedidos-facturacion/base/src/main.ts +9 -0
  19. package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/aplicacion/facturar.ts +19 -0
  20. package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/dominio/informe.ts +7 -0
  21. package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/dominio/pedido.ts +21 -0
  22. package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/infra/db.ts +22 -0
  23. package/bench/casos/arquitectura/pedidos-facturacion/esperado.json +53 -0
  24. package/bench/casos/arquitectura/resumen-cliente/base/docs/adr/0001-capas.md +18 -0
  25. package/bench/casos/arquitectura/resumen-cliente/base/src/aplicacion/confirmar.ts +8 -0
  26. package/bench/casos/arquitectura/resumen-cliente/base/src/dominio/pedido.ts +15 -0
  27. package/bench/casos/arquitectura/resumen-cliente/base/src/dominio/puertos.ts +6 -0
  28. package/bench/casos/arquitectura/resumen-cliente/base/src/infra/db.ts +14 -0
  29. package/bench/casos/arquitectura/resumen-cliente/base/src/main.ts +9 -0
  30. package/bench/casos/arquitectura/resumen-cliente/cambio/src/aplicacion/resumen.ts +6 -0
  31. package/bench/casos/arquitectura/resumen-cliente/cambio/src/dominio/pedido.ts +33 -0
  32. package/bench/casos/arquitectura/resumen-cliente/cambio/src/dominio/puertos.ts +7 -0
  33. package/bench/casos/arquitectura/resumen-cliente/cambio/src/infra/db.ts +18 -0
  34. package/bench/casos/arquitectura/resumen-cliente/cambio/src/main.ts +14 -0
  35. package/bench/casos/arquitectura/resumen-cliente/esperado.json +23 -0
  36. package/bench/casos/documentacion/comentario-obsoleto/base/README.md +18 -0
  37. package/bench/casos/documentacion/comentario-obsoleto/base/src/usuarios.ts +35 -0
  38. package/bench/casos/documentacion/comentario-obsoleto/cambio/src/copia.ts +8 -0
  39. package/bench/casos/documentacion/comentario-obsoleto/cambio/src/usuarios.ts +43 -0
  40. package/bench/casos/documentacion/comentario-obsoleto/esperado.json +42 -0
  41. package/bench/casos/documentacion/reportes-config/base/README.md +23 -0
  42. package/bench/casos/documentacion/reportes-config/base/src/cli.js +33 -0
  43. package/bench/casos/documentacion/reportes-config/base/src/config.js +15 -0
  44. package/bench/casos/documentacion/reportes-config/base/src/envio.js +23 -0
  45. package/bench/casos/documentacion/reportes-config/cambio/src/cli.js +35 -0
  46. package/bench/casos/documentacion/reportes-config/cambio/src/config.js +15 -0
  47. package/bench/casos/documentacion/reportes-config/esperado.json +42 -0
  48. package/bench/casos/documentacion/tiempo-espera/base/README.md +10 -0
  49. package/bench/casos/documentacion/tiempo-espera/base/src/config.js +8 -0
  50. package/bench/casos/documentacion/tiempo-espera/cambio/README.md +10 -0
  51. package/bench/casos/documentacion/tiempo-espera/cambio/src/config.js +8 -0
  52. package/bench/casos/documentacion/tiempo-espera/esperado.json +16 -0
  53. package/bench/casos/pruebas/calendario-laboral/base/src/fechas.js +3 -0
  54. package/bench/casos/pruebas/calendario-laboral/base/test/fechas.test.js +7 -0
  55. package/bench/casos/pruebas/calendario-laboral/cambio/src/fechas.js +37 -0
  56. package/bench/casos/pruebas/calendario-laboral/cambio/test/calendario.test.js +31 -0
  57. package/bench/casos/pruebas/calendario-laboral/esperado.json +49 -0
  58. package/bench/casos/pruebas/fin-de-semana/base/src/fechas.js +3 -0
  59. package/bench/casos/pruebas/fin-de-semana/base/test/fechas.test.js +7 -0
  60. package/bench/casos/pruebas/fin-de-semana/cambio/src/fechas.js +8 -0
  61. package/bench/casos/pruebas/fin-de-semana/cambio/test/fines-de-semana.test.js +13 -0
  62. package/bench/casos/pruebas/fin-de-semana/esperado.json +16 -0
  63. package/bench/casos/pruebas/precios-carrito/base/src/precio.ts +3 -0
  64. package/bench/casos/pruebas/precios-carrito/base/test/precio.test.js +11 -0
  65. package/bench/casos/pruebas/precios-carrito/cambio/src/precio.ts +34 -0
  66. package/bench/casos/pruebas/precios-carrito/cambio/test/precio.test.js +42 -0
  67. package/bench/casos/pruebas/precios-carrito/esperado.json +42 -0
  68. package/bench/casos/rendimiento/boletin-correo/base/src/correo.html +1 -0
  69. package/bench/casos/rendimiento/boletin-correo/base/src/plantilla.ts +11 -0
  70. package/bench/casos/rendimiento/boletin-correo/cambio/src/envios.ts +44 -0
  71. package/bench/casos/rendimiento/boletin-correo/cambio/src/plantilla.ts +10 -0
  72. package/bench/casos/rendimiento/boletin-correo/esperado.json +42 -0
  73. package/bench/casos/rendimiento/clientes-por-lote/base/src/informe.js +8 -0
  74. package/bench/casos/rendimiento/clientes-por-lote/cambio/src/informe.js +6 -0
  75. package/bench/casos/rendimiento/clientes-por-lote/esperado.json +14 -0
  76. package/bench/casos/rendimiento/informe-ventas/base/src/informe.js +6 -0
  77. package/bench/casos/rendimiento/informe-ventas/base/src/tasas.json +1 -0
  78. package/bench/casos/rendimiento/informe-ventas/cambio/src/informe.js +33 -0
  79. package/bench/casos/rendimiento/informe-ventas/cambio/src/tasas.js +7 -0
  80. package/bench/casos/rendimiento/informe-ventas/esperado.json +42 -0
  81. package/bench/casos/seguridad/inyeccion-orden/base/src/respaldo.ts +13 -0
  82. package/bench/casos/seguridad/inyeccion-orden/cambio/src/respaldo.ts +69 -0
  83. package/bench/casos/seguridad/inyeccion-orden/esperado.json +42 -0
  84. package/bench/casos/seguridad/limpio-validacion/base/servidor.js +11 -0
  85. package/bench/casos/seguridad/limpio-validacion/cambio/servidor.js +39 -0
  86. package/bench/casos/seguridad/limpio-validacion/esperado.json +14 -0
  87. package/bench/casos/seguridad/servidor-archivos/base/servidor.js +21 -0
  88. package/bench/casos/seguridad/servidor-archivos/cambio/servidor.js +79 -0
  89. package/bench/casos/seguridad/servidor-archivos/esperado.json +42 -0
  90. package/bin/nexakit-fabrica-mcp.js +12 -0
  91. package/dist/fabrica/banco/casos.js +304 -0
  92. package/dist/fabrica/banco/ejecutar.js +483 -0
  93. package/dist/fabrica/banco/medir.js +120 -0
  94. package/dist/fabrica/cli.js +737 -0
  95. package/dist/fabrica/conectores/antigravity.js +1040 -0
  96. package/dist/fabrica/conectores/codex.js +967 -0
  97. package/dist/fabrica/conectores/tipos.js +8 -0
  98. package/dist/fabrica/config.js +44 -0
  99. package/dist/fabrica/consolidar.js +218 -0
  100. package/dist/fabrica/decision.js +210 -0
  101. package/dist/fabrica/diff.js +247 -0
  102. package/dist/fabrica/disco.js +356 -0
  103. package/dist/fabrica/ejecutor.js +597 -0
  104. package/dist/fabrica/encargo/candado.js +274 -0
  105. package/dist/fabrica/encargo/ejecutar.js +827 -0
  106. package/dist/fabrica/encargo/evidencia.js +308 -0
  107. package/dist/fabrica/encargo/parche.js +146 -0
  108. package/dist/fabrica/encargo/worktree.js +394 -0
  109. package/dist/fabrica/enrutador.js +425 -0
  110. package/dist/fabrica/errores.js +14 -0
  111. package/dist/fabrica/esquemas.js +57 -0
  112. package/dist/fabrica/estaciones.js +75 -0
  113. package/dist/fabrica/evidencia.js +406 -0
  114. package/dist/fabrica/indice.js +1 -0
  115. package/dist/fabrica/jsonrpc.js +274 -0
  116. package/dist/fabrica/lecciones.js +363 -0
  117. package/dist/fabrica/mcp.js +376 -0
  118. package/dist/fabrica/preferencias.js +56 -0
  119. package/dist/fabrica/protocolos/codex/AbsolutePathBuf.js +2 -0
  120. package/dist/fabrica/protocolos/codex/ApplyPatchApprovalResponse.js +2 -0
  121. package/dist/fabrica/protocolos/codex/ClientInfo.js +2 -0
  122. package/dist/fabrica/protocolos/codex/ExecCommandApprovalParams.js +2 -0
  123. package/dist/fabrica/protocolos/codex/ExecCommandApprovalResponse.js +2 -0
  124. package/dist/fabrica/protocolos/codex/ExecPolicyAmendment.js +2 -0
  125. package/dist/fabrica/protocolos/codex/FunctionCallOutputBody.js +2 -0
  126. package/dist/fabrica/protocolos/codex/FunctionCallOutputContentItem.js +2 -0
  127. package/dist/fabrica/protocolos/codex/ImageDetail.js +2 -0
  128. package/dist/fabrica/protocolos/codex/InitializeCapabilities.js +2 -0
  129. package/dist/fabrica/protocolos/codex/InitializeParams.js +2 -0
  130. package/dist/fabrica/protocolos/codex/InitializeResponse.js +2 -0
  131. package/dist/fabrica/protocolos/codex/InputModality.js +2 -0
  132. package/dist/fabrica/protocolos/codex/LegacyAppPathString.js +2 -0
  133. package/dist/fabrica/protocolos/codex/NetworkPolicyAmendment.js +2 -0
  134. package/dist/fabrica/protocolos/codex/NetworkPolicyRuleAction.js +2 -0
  135. package/dist/fabrica/protocolos/codex/ParsedCommand.js +2 -0
  136. package/dist/fabrica/protocolos/codex/Personality.js +2 -0
  137. package/dist/fabrica/protocolos/codex/ReasoningEffort.js +2 -0
  138. package/dist/fabrica/protocolos/codex/ReasoningSummary.js +2 -0
  139. package/dist/fabrica/protocolos/codex/ReviewDecision.js +2 -0
  140. package/dist/fabrica/protocolos/codex/ThreadId.js +2 -0
  141. package/dist/fabrica/protocolos/codex/serde_json/JsonValue.js +2 -0
  142. package/dist/fabrica/protocolos/codex/v2/AdditionalFileSystemPermissions.js +2 -0
  143. package/dist/fabrica/protocolos/codex/v2/AdditionalNetworkPermissions.js +2 -0
  144. package/dist/fabrica/protocolos/codex/v2/ApprovalsReviewer.js +2 -0
  145. package/dist/fabrica/protocolos/codex/v2/AskForApproval.js +2 -0
  146. package/dist/fabrica/protocolos/codex/v2/ByteRange.js +2 -0
  147. package/dist/fabrica/protocolos/codex/v2/CommandAction.js +2 -0
  148. package/dist/fabrica/protocolos/codex/v2/CommandExecutionApprovalDecision.js +2 -0
  149. package/dist/fabrica/protocolos/codex/v2/CommandExecutionApprovalKind.js +2 -0
  150. package/dist/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalParams.js +2 -0
  151. package/dist/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalResponse.js +2 -0
  152. package/dist/fabrica/protocolos/codex/v2/ConfigReadParams.js +2 -0
  153. package/dist/fabrica/protocolos/codex/v2/CyberAccessProgram.js +2 -0
  154. package/dist/fabrica/protocolos/codex/v2/ExecPolicyAmendment.js +2 -0
  155. package/dist/fabrica/protocolos/codex/v2/FileChangeApprovalDecision.js +2 -0
  156. package/dist/fabrica/protocolos/codex/v2/FileChangeRequestApprovalResponse.js +2 -0
  157. package/dist/fabrica/protocolos/codex/v2/FileSystemAccessMode.js +2 -0
  158. package/dist/fabrica/protocolos/codex/v2/FileSystemPath.js +2 -0
  159. package/dist/fabrica/protocolos/codex/v2/FileSystemSandboxEntry.js +2 -0
  160. package/dist/fabrica/protocolos/codex/v2/FileSystemSpecialPath.js +2 -0
  161. package/dist/fabrica/protocolos/codex/v2/GrantedPermissionProfile.js +2 -0
  162. package/dist/fabrica/protocolos/codex/v2/ListMcpServerStatusParams.js +2 -0
  163. package/dist/fabrica/protocolos/codex/v2/McpServerElicitationAction.js +2 -0
  164. package/dist/fabrica/protocolos/codex/v2/McpServerElicitationRequestResponse.js +2 -0
  165. package/dist/fabrica/protocolos/codex/v2/McpServerStatusDetail.js +2 -0
  166. package/dist/fabrica/protocolos/codex/v2/Model.js +2 -0
  167. package/dist/fabrica/protocolos/codex/v2/ModelAccessPrograms.js +2 -0
  168. package/dist/fabrica/protocolos/codex/v2/ModelAvailabilityNux.js +2 -0
  169. package/dist/fabrica/protocolos/codex/v2/ModelListParams.js +2 -0
  170. package/dist/fabrica/protocolos/codex/v2/ModelListResponse.js +2 -0
  171. package/dist/fabrica/protocolos/codex/v2/ModelServiceTier.js +2 -0
  172. package/dist/fabrica/protocolos/codex/v2/ModelUpgradeInfo.js +2 -0
  173. package/dist/fabrica/protocolos/codex/v2/MultiAgentVersion.js +2 -0
  174. package/dist/fabrica/protocolos/codex/v2/NetworkAccess.js +2 -0
  175. package/dist/fabrica/protocolos/codex/v2/NetworkApprovalContext.js +2 -0
  176. package/dist/fabrica/protocolos/codex/v2/NetworkApprovalProtocol.js +2 -0
  177. package/dist/fabrica/protocolos/codex/v2/NetworkPolicyAmendment.js +2 -0
  178. package/dist/fabrica/protocolos/codex/v2/NetworkPolicyRuleAction.js +2 -0
  179. package/dist/fabrica/protocolos/codex/v2/PermissionGrantScope.js +2 -0
  180. package/dist/fabrica/protocolos/codex/v2/PermissionsRequestApprovalResponse.js +2 -0
  181. package/dist/fabrica/protocolos/codex/v2/ReasoningEffortOption.js +2 -0
  182. package/dist/fabrica/protocolos/codex/v2/SandboxMode.js +2 -0
  183. package/dist/fabrica/protocolos/codex/v2/SandboxPolicy.js +2 -0
  184. package/dist/fabrica/protocolos/codex/v2/TextElement.js +2 -0
  185. package/dist/fabrica/protocolos/codex/v2/ThreadSource.js +2 -0
  186. package/dist/fabrica/protocolos/codex/v2/ThreadStartParams.js +2 -0
  187. package/dist/fabrica/protocolos/codex/v2/ThreadStartSource.js +2 -0
  188. package/dist/fabrica/protocolos/codex/v2/ThreadTokenUsage.js +2 -0
  189. package/dist/fabrica/protocolos/codex/v2/ThreadTokenUsageUpdatedNotification.js +2 -0
  190. package/dist/fabrica/protocolos/codex/v2/TokenUsageBreakdown.js +2 -0
  191. package/dist/fabrica/protocolos/codex/v2/ToolRequestUserInputAnswer.js +2 -0
  192. package/dist/fabrica/protocolos/codex/v2/ToolRequestUserInputResponse.js +2 -0
  193. package/dist/fabrica/protocolos/codex/v2/TurnInterruptParams.js +2 -0
  194. package/dist/fabrica/protocolos/codex/v2/TurnStartParams.js +2 -0
  195. package/dist/fabrica/protocolos/codex/v2/TurnToolOutput.js +2 -0
  196. package/dist/fabrica/protocolos/codex/v2/UserInput.js +2 -0
  197. package/dist/fabrica/rastro.js +487 -0
  198. package/dist/fabrica/sesion.js +230 -0
  199. package/dist/fabrica/tabla-modelos.json +29 -0
  200. package/dist/fabrica/veredictos.js +327 -0
  201. package/package.json +16 -8
  202. package/plugins/huellas.json +6 -6
  203. package/plugins/nexakit-lecciones/.claude-plugin/plugin.json +1 -1
  204. package/plugins/nexakit-lecciones/README.md +6 -5
  205. package/plugins/nexakit-lecciones/hooks/lecciones.js +29 -5
  206. package/plugins/nexakit-lecciones/hooks/register.js +7 -3
  207. package/plugins/nexakit-modelo/.claude-plugin/plugin.json +1 -1
  208. package/plugins/nexakit-modelo/hooks/barra.js +100 -4
  209. package/plugins/nexakit-modelo/hooks/decidir.js +2 -2
  210. package/plugins/nexakit-modelo/hooks/recomendar.js +1 -1
  211. package/plugins/nexakit-modelo/hooks/register.js +122 -7
  212. package/plugins/nexakit-modelo/tests/register.test.ts +301 -0
  213. package/plugins/niveles/.claude-plugin/plugin.json +1 -1
  214. package/plugins/niveles/agents/cazador-de-flakes.md +1 -0
  215. package/plugins/niveles/agents/cierre-de-memoria.md +1 -0
  216. package/plugins/niveles/agents/investigador.md +1 -0
  217. package/plugins/niveles/agents/nivel-alto.md +1 -0
  218. package/plugins/niveles/agents/nivel-exigente.md +1 -0
  219. package/plugins/niveles/agents/nivel-ligero.md +1 -0
  220. package/plugins/niveles/agents/nivel-normal.md +1 -0
  221. package/plugins/niveles/agents/revisor-de-calidad.md +1 -0
  222. package/plugins/niveles/agents/sincronizador-docs.md +1 -0
  223. package/plugins/niveles/agents/subir-al-repo.md +1 -0
  224. package/skills/elegir-modelo/SKILL.md +4 -3
  225. package/skills/elegir-modelo/modelos.mjs +100 -1
  226. package/skills/fabrica/SKILL.md +55 -0
  227. package/skills/gemini/SKILL.md +2 -3
  228. package/skills/quality-gate/SKILL.md +2 -2
  229. package/src/agent-models.js +6 -4
  230. package/src/antigravity-barra.js +64 -12
  231. package/src/antigravity-command.js +4 -2
  232. package/src/antigravity-models.js +61 -0
  233. package/src/antigravity-pre-tool.js +11 -3
  234. package/src/antigravity-recommendation.js +15 -9
  235. package/src/antigravity-setup.js +4 -31
  236. package/src/cli-executable.d.ts +11 -0
  237. package/src/codex-pre-tool.js +3 -3
  238. package/src/codex-recommendation.js +1 -2
  239. package/src/codex-setup.js +3 -20
  240. package/src/codex-team.js +31 -4
  241. package/src/fabrica/banco/casos.ts +315 -0
  242. package/src/fabrica/banco/ejecutar.ts +587 -0
  243. package/src/fabrica/banco/medir.ts +160 -0
  244. package/src/fabrica/cli.ts +781 -0
  245. package/src/fabrica/conectores/antigravity.ts +1090 -0
  246. package/src/fabrica/conectores/codex.ts +1013 -0
  247. package/src/fabrica/conectores/tipos.ts +54 -0
  248. package/src/fabrica/config.ts +43 -0
  249. package/src/fabrica/consolidar.ts +277 -0
  250. package/src/fabrica/decision.ts +285 -0
  251. package/src/fabrica/diff.ts +294 -0
  252. package/src/fabrica/disco.ts +380 -0
  253. package/src/fabrica/ejecutor.ts +716 -0
  254. package/src/fabrica/encargo/candado.ts +287 -0
  255. package/src/fabrica/encargo/ejecutar.ts +953 -0
  256. package/src/fabrica/encargo/evidencia.ts +301 -0
  257. package/src/fabrica/encargo/parche.ts +151 -0
  258. package/src/fabrica/encargo/worktree.ts +427 -0
  259. package/src/fabrica/enrutador.ts +494 -0
  260. package/src/fabrica/errores.ts +15 -0
  261. package/src/fabrica/esquemas.ts +92 -0
  262. package/src/fabrica/estaciones.ts +83 -0
  263. package/src/fabrica/evidencia.ts +445 -0
  264. package/src/fabrica/indice.ts +1 -0
  265. package/src/fabrica/jsonrpc.ts +314 -0
  266. package/src/fabrica/lecciones.ts +411 -0
  267. package/src/fabrica/mcp.ts +450 -0
  268. package/src/fabrica/preferencias.ts +66 -0
  269. package/src/fabrica/protocolos/codex/AbsolutePathBuf.ts +14 -0
  270. package/src/fabrica/protocolos/codex/ApplyPatchApprovalResponse.ts +6 -0
  271. package/src/fabrica/protocolos/codex/ClientInfo.ts +5 -0
  272. package/src/fabrica/protocolos/codex/ExecCommandApprovalParams.ts +16 -0
  273. package/src/fabrica/protocolos/codex/ExecCommandApprovalResponse.ts +6 -0
  274. package/src/fabrica/protocolos/codex/ExecPolicyAmendment.ts +12 -0
  275. package/src/fabrica/protocolos/codex/FunctionCallOutputBody.ts +6 -0
  276. package/src/fabrica/protocolos/codex/FunctionCallOutputContentItem.ts +10 -0
  277. package/src/fabrica/protocolos/codex/ImageDetail.ts +5 -0
  278. package/src/fabrica/protocolos/codex/InitializeCapabilities.ts +42 -0
  279. package/src/fabrica/protocolos/codex/InitializeParams.ts +7 -0
  280. package/src/fabrica/protocolos/codex/InitializeResponse.ts +20 -0
  281. package/src/fabrica/protocolos/codex/InputModality.ts +8 -0
  282. package/src/fabrica/protocolos/codex/LegacyAppPathString.ts +27 -0
  283. package/src/fabrica/protocolos/codex/NetworkPolicyAmendment.ts +6 -0
  284. package/src/fabrica/protocolos/codex/NetworkPolicyRuleAction.ts +5 -0
  285. package/src/fabrica/protocolos/codex/ParsedCommand.ts +12 -0
  286. package/src/fabrica/protocolos/codex/Personality.ts +8 -0
  287. package/src/fabrica/protocolos/codex/ReasoningEffort.ts +8 -0
  288. package/src/fabrica/protocolos/codex/ReasoningSummary.ts +10 -0
  289. package/src/fabrica/protocolos/codex/ReviewDecision.ts +10 -0
  290. package/src/fabrica/protocolos/codex/ThreadId.ts +10 -0
  291. package/src/fabrica/protocolos/codex/VERSION +1 -0
  292. package/src/fabrica/protocolos/codex/serde_json/JsonValue.ts +5 -0
  293. package/src/fabrica/protocolos/codex/v2/AdditionalFileSystemPermissions.ts +15 -0
  294. package/src/fabrica/protocolos/codex/v2/AdditionalNetworkPermissions.ts +5 -0
  295. package/src/fabrica/protocolos/codex/v2/ApprovalsReviewer.ts +12 -0
  296. package/src/fabrica/protocolos/codex/v2/AskForApproval.ts +5 -0
  297. package/src/fabrica/protocolos/codex/v2/ByteRange.ts +5 -0
  298. package/src/fabrica/protocolos/codex/v2/CommandAction.ts +6 -0
  299. package/src/fabrica/protocolos/codex/v2/CommandExecutionApprovalDecision.ts +7 -0
  300. package/src/fabrica/protocolos/codex/v2/CommandExecutionApprovalKind.ts +8 -0
  301. package/src/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalParams.ts +51 -0
  302. package/src/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalResponse.ts +6 -0
  303. package/src/fabrica/protocolos/codex/v2/ConfigReadParams.ts +11 -0
  304. package/src/fabrica/protocolos/codex/v2/CyberAccessProgram.ts +9 -0
  305. package/src/fabrica/protocolos/codex/v2/ExecPolicyAmendment.ts +5 -0
  306. package/src/fabrica/protocolos/codex/v2/FileChangeApprovalDecision.ts +5 -0
  307. package/src/fabrica/protocolos/codex/v2/FileChangeRequestApprovalResponse.ts +6 -0
  308. package/src/fabrica/protocolos/codex/v2/FileSystemAccessMode.ts +5 -0
  309. package/src/fabrica/protocolos/codex/v2/FileSystemPath.ts +7 -0
  310. package/src/fabrica/protocolos/codex/v2/FileSystemSandboxEntry.ts +7 -0
  311. package/src/fabrica/protocolos/codex/v2/FileSystemSpecialPath.ts +6 -0
  312. package/src/fabrica/protocolos/codex/v2/GrantedPermissionProfile.ts +7 -0
  313. package/src/fabrica/protocolos/codex/v2/ListMcpServerStatusParams.ts +23 -0
  314. package/src/fabrica/protocolos/codex/v2/McpServerElicitationAction.ts +5 -0
  315. package/src/fabrica/protocolos/codex/v2/McpServerElicitationRequestResponse.ts +17 -0
  316. package/src/fabrica/protocolos/codex/v2/McpServerStatusDetail.ts +5 -0
  317. package/src/fabrica/protocolos/codex/v2/Model.ts +33 -0
  318. package/src/fabrica/protocolos/codex/v2/ModelAccessPrograms.ts +13 -0
  319. package/src/fabrica/protocolos/codex/v2/ModelAvailabilityNux.ts +5 -0
  320. package/src/fabrica/protocolos/codex/v2/ModelListParams.ts +17 -0
  321. package/src/fabrica/protocolos/codex/v2/ModelListResponse.ts +11 -0
  322. package/src/fabrica/protocolos/codex/v2/ModelServiceTier.ts +5 -0
  323. package/src/fabrica/protocolos/codex/v2/ModelUpgradeInfo.ts +9 -0
  324. package/src/fabrica/protocolos/codex/v2/MultiAgentVersion.ts +8 -0
  325. package/src/fabrica/protocolos/codex/v2/NetworkAccess.ts +5 -0
  326. package/src/fabrica/protocolos/codex/v2/NetworkApprovalContext.ts +6 -0
  327. package/src/fabrica/protocolos/codex/v2/NetworkApprovalProtocol.ts +5 -0
  328. package/src/fabrica/protocolos/codex/v2/NetworkPolicyAmendment.ts +6 -0
  329. package/src/fabrica/protocolos/codex/v2/NetworkPolicyRuleAction.ts +5 -0
  330. package/src/fabrica/protocolos/codex/v2/PermissionGrantScope.ts +5 -0
  331. package/src/fabrica/protocolos/codex/v2/PermissionsRequestApprovalResponse.ts +11 -0
  332. package/src/fabrica/protocolos/codex/v2/ReasoningEffortOption.ts +6 -0
  333. package/src/fabrica/protocolos/codex/v2/SandboxMode.ts +5 -0
  334. package/src/fabrica/protocolos/codex/v2/SandboxPolicy.ts +7 -0
  335. package/src/fabrica/protocolos/codex/v2/TextElement.ts +14 -0
  336. package/src/fabrica/protocolos/codex/v2/ThreadSource.ts +5 -0
  337. package/src/fabrica/protocolos/codex/v2/ThreadStartParams.ts +22 -0
  338. package/src/fabrica/protocolos/codex/v2/ThreadStartSource.ts +5 -0
  339. package/src/fabrica/protocolos/codex/v2/ThreadTokenUsage.ts +6 -0
  340. package/src/fabrica/protocolos/codex/v2/ThreadTokenUsageUpdatedNotification.ts +6 -0
  341. package/src/fabrica/protocolos/codex/v2/TokenUsageBreakdown.ts +5 -0
  342. package/src/fabrica/protocolos/codex/v2/ToolRequestUserInputAnswer.ts +8 -0
  343. package/src/fabrica/protocolos/codex/v2/ToolRequestUserInputResponse.ts +9 -0
  344. package/src/fabrica/protocolos/codex/v2/TurnInterruptParams.ts +5 -0
  345. package/src/fabrica/protocolos/codex/v2/TurnStartParams.ts +75 -0
  346. package/src/fabrica/protocolos/codex/v2/TurnToolOutput.ts +10 -0
  347. package/src/fabrica/protocolos/codex/v2/UserInput.ts +11 -0
  348. package/src/fabrica/rastro.ts +508 -0
  349. package/src/fabrica/sesion.ts +280 -0
  350. package/src/fabrica/tabla-modelos.json +29 -0
  351. package/src/fabrica/veredictos.ts +365 -0
  352. package/src/gemini-cli.js +15 -12
  353. package/src/gemini-tools.js +1 -1
  354. package/src/gemini-usage-store.js +32 -0
  355. package/src/instructions-block.js +69 -0
  356. package/src/lecciones-command.js +105 -4
  357. package/src/lecciones-instructions.js +178 -0
  358. package/src/legacy-repair.js +1 -1
  359. package/src/level-agents.js +5 -3
  360. package/src/memory-mcp-policy.js +1 -1
  361. package/src/missing-dependencies.js +5 -0
  362. package/src/model-command.d.ts +29 -0
  363. package/src/model-command.js +4 -27
  364. package/src/regla-ordenes-simples.d.ts +2 -0
  365. package/src/regla-ordenes-simples.js +4 -0
  366. package/src/review-instructions.js +69 -81
  367. package/src/safe-paths.js +38 -0
  368. package/src/setup-apply.js +24 -2
  369. package/src/setup-plan.js +57 -1
  370. package/src/setup-state.js +14 -0
  371. package/src/shell-quote.js +2 -0
  372. package/src/skill-recommendations.js +101 -28
  373. package/src/stable-command.js +2 -2
  374. package/src/stable-install.js +4 -2
  375. package/src/superpowers.js +0 -7
  376. package/src/task-document.js +59 -0
  377. package/src/terminal-text.js +2 -19
  378. package/src/toolkit-cli.js +63 -8
  379. package/src/toolkit-setup.js +192 -37
  380. package/templates/agent-team/README.md +7 -19
  381. package/bin/agent-task.js +0 -14
  382. package/bin/agent-toolkit-inbox.js +0 -14
  383. package/bin/agent-toolkit-mcp.js +0 -17
  384. package/schemas/agent-client-adapter.schema.json +0 -786
  385. package/schemas/agent-client-auth-diagnostic.schema.json +0 -801
  386. package/schemas/agent-client-isolated-variant.schema.json +0 -105
  387. package/schemas/agent-client-isolated-verification.schema.json +0 -99
  388. package/schemas/agent-client-managed-preferences-invocation.schema.json +0 -67
  389. package/schemas/agent-client-managed-preferences.schema.json +0 -63
  390. package/schemas/agent-client-native-diagnostics.schema.json +0 -85
  391. package/schemas/agent-client-native-evaluation.schema.json +0 -171
  392. package/schemas/agent-client-native-preflight.schema.json +0 -90
  393. package/schemas/agent-client-output.schema.json +0 -551
  394. package/schemas/agent-client-runtime-fixture.schema.json +0 -90
  395. package/schemas/agent-client-runtime-local.schema.json +0 -95
  396. package/schemas/agent-client-runtime.schema.json +0 -1288
  397. package/schemas/agent-client-selective-config.schema.json +0 -77
  398. package/schemas/agent-client-supervised-local.schema.json +0 -135
  399. package/schemas/agent-client-supervised.schema.json +0 -186
  400. package/schemas/agent-task-approvals.schema.json +0 -362
  401. package/schemas/agent-task-prepare.schema.json +0 -1324
  402. package/schemas/agent-task-verify.schema.json +0 -198
  403. package/schemas/task-workflow-plan-output.schema.json +0 -35
  404. package/skills/revisar/SKILL.md +0 -51
  405. package/src/claude-code-runner.js +0 -642
  406. package/src/client-adapter-plan.js +0 -271
  407. package/src/client-auth-diagnostic-parser.js +0 -211
  408. package/src/client-auth-diagnostic.js +0 -257
  409. package/src/client-isolated-variant.js +0 -106
  410. package/src/client-isolated-verification.js +0 -130
  411. package/src/client-local-platform.js +0 -14
  412. package/src/client-managed-preferences-invocation.js +0 -209
  413. package/src/client-managed-preferences.js +0 -78
  414. package/src/client-native-access.js +0 -134
  415. package/src/client-native-diagnostics.js +0 -253
  416. package/src/client-native-evaluation.js +0 -106
  417. package/src/client-native-preflight-files.js +0 -68
  418. package/src/client-native-preflight.js +0 -95
  419. package/src/client-output-parser.js +0 -278
  420. package/src/client-runtime-admission.js +0 -80
  421. package/src/client-runtime-coordinator.js +0 -70
  422. package/src/client-runtime-core.js +0 -92
  423. package/src/client-runtime-fixture-permit.js +0 -20
  424. package/src/client-runtime-fixture-protocol.js +0 -39
  425. package/src/client-runtime-state.js +0 -67
  426. package/src/client-runtime-store-files.js +0 -91
  427. package/src/client-runtime-store.js +0 -239
  428. package/src/client-runtime-supervisor.js +0 -146
  429. package/src/client-selective-config.js +0 -195
  430. package/src/client-selective-files.js +0 -126
  431. package/src/client-supervised-codes.js +0 -32
  432. package/src/client-supervised-contract.js +0 -52
  433. package/src/client-supervised-coordinator.js +0 -36
  434. package/src/client-supervised-permit.js +0 -20
  435. package/src/client-supervised-protocol.js +0 -37
  436. package/src/client-supervised-store.js +0 -167
  437. package/src/client-supervised-supervisor.js +0 -167
  438. package/src/client-supervised.js +0 -160
  439. package/src/codex-cli-runner.js +0 -358
  440. package/src/codex-delivery.js +0 -101
  441. package/src/memory-connection-artifacts.js +0 -192
  442. package/src/memory-connection-descriptor.js +0 -158
  443. package/src/memory-connection-diagnostic.js +0 -177
  444. package/src/memory-connection-files.js +0 -191
  445. package/src/memory-connection-manifest.js +0 -118
  446. package/src/memory-connection-package.js +0 -176
  447. package/src/memory-connection-plan.js +0 -217
  448. package/src/memory-connection-skill.js +0 -211
  449. package/src/memory-connection-toml.js +0 -153
  450. package/src/native/managed-preferences.c +0 -100
  451. package/src/native/managed-preferences.h +0 -17
  452. package/src/package-lock-path.js +0 -13
  453. package/src/peer-handoff.js +0 -27
  454. package/src/peer-inbox-cli.js +0 -211
  455. package/src/peer-review-mcp.js +0 -210
  456. package/src/peer-review-store.js +0 -532
  457. package/src/review-policy.js +0 -35
  458. package/src/revision-adapters.js +0 -158
  459. package/src/revision-context.js +0 -86
  460. package/src/revision-isolation.js +0 -222
  461. package/src/revision-process.js +0 -103
  462. package/src/revision-provenance.js +0 -89
  463. package/src/revision-snapshot.js +0 -120
  464. package/src/revision.js +0 -242
  465. package/src/runtime-fixtures/runtime-supervisor/child.cjs +0 -3
  466. package/src/runtime-fixtures/runtime-supervisor/fixture.cjs +0 -49
  467. package/src/runtime-fixtures/supervised/child.cjs +0 -3
  468. package/src/runtime-fixtures/supervised/fixture.cjs +0 -47
  469. package/src/task-approvals.js +0 -367
  470. package/src/task-cli.js +0 -79
  471. package/src/task-external-verifier.js +0 -584
  472. package/src/task-prepare-files.js +0 -115
  473. package/src/task-prepare.js +0 -180
  474. package/src/task-verify-cli.js +0 -67
  475. package/src/task-verify-files.js +0 -188
  476. package/src/task-verify.js +0 -118
  477. package/src/task-workflow-mcp.js +0 -544
  478. package/src/task-workflow-store.js +0 -254
  479. package/src/toolkit-commands-guide.js +0 -115
package/src/gemini-cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createPeerReviewStore } from "./peer-review-store.js";
1
+ import { createGeminiUsageStore } from "./gemini-usage-store.js";
2
2
  import { GeminiError, estado, imagen, investigar, consultar, analizar, historial, recuperar } from './gemini-tools.js';
3
3
  const HELP = `Uso: agent-toolkit-gemini investigar --prompt <pregunta> [--modelo <id>] [--copiar-a <carpeta>]
4
4
  agent-toolkit-gemini consultar --prompt <consulta> [--modelo <id>] [--copiar-a <carpeta>]
@@ -11,11 +11,12 @@ const HELP = `Uso: agent-toolkit-gemini investigar --prompt <pregunta> [--modelo
11
11
  Solo Antigravity CLI (agy), sin API ni cambio de proveedor. analizar copia únicamente
12
12
  los archivos elegidos (texto, imagen, PDF o vídeo); audio bloqueado por validación fallida. Su lectura depende de las
13
13
  herramientas del cliente. No genera audio ni vídeo. historial/recuperar no llaman IA.
14
- Añade --task <id> --project-root <ruta> a una consulta para registrar su consumo.
15
- Cada consulta se guarda en ~/.agent-toolkit/gemini. --copiar-a nunca sobrescribe.
14
+ Cada consulta se guarda en ~/.agent-toolkit/gemini y su consumo declarado, en consumo.jsonl. --copiar-a nunca sobrescribe.
16
15
  Exit: 0 completado, 1 error, 2 uso incorrecto, 3 análisis parcial/no compatible.
17
16
  `;
18
- const NAMES = { '--prompt': 'prompt', '--modelo': 'model', '--copiar-a': 'copyTo', '--espera-seg': 'wait', '--archivo': 'files', '--directorio': 'directory', '--limite': 'limit', '--task': 'taskId', '--project-root': 'projectRoot' };
17
+ const COUNTERS = ['inputTokens', 'cacheReadTokens', 'outputTokens', 'totalTokens', 'durationMs'];
18
+ const MEASURED = ['investigar', 'imagen', 'consultar', 'analizar'];
19
+ const NAMES = { '--prompt': 'prompt', '--modelo': 'model', '--copiar-a': 'copyTo', '--espera-seg': 'wait', '--archivo': 'files', '--directorio': 'directory', '--limite': 'limit' };
19
20
  const ALLOWED = {
20
21
  investigar: ['prompt','model','copyTo'], consultar: ['prompt','model','copyTo'], analizar: ['prompt','model','copyTo','files'],
21
22
  imagen: ['prompt','model','copyTo','wait'], recuperar: ['directory','copyTo','wait'], historial: ['limit'], estado: []
@@ -26,20 +27,18 @@ export async function runGeminiCli(argv, { out, err, tools = { investigar, image
26
27
  if (!Object.hasOwn(ALLOWED, command ?? '')) { await err(HELP); return 2; }
27
28
  const options = {};
28
29
  for (let i=0; i<rest.length; i+=2) {
30
+ if (['--task', '--project-root'].includes(rest[i])) { await err('--task y --project-root se retiraron; el consumo se guarda en ~/.agent-toolkit/gemini/consumo.jsonl\n'); return 2; }
29
31
  const key = NAMES[rest[i]], value = rest[i+1];
30
- if (!key || !(ALLOWED[command].includes(key) || ['investigar','imagen','consultar','analizar'].includes(command) && ['taskId','projectRoot'].includes(key)) || value === undefined || !value || (key !== 'files' && Object.hasOwn(options,key))) { await err(HELP); return 2; }
32
+ if (!key || !(ALLOWED[command].includes(key)) || value === undefined || !value || (key !== 'files' && Object.hasOwn(options,key))) { await err(HELP); return 2; }
31
33
  if (key === 'files') (options.files ??= []).push(value); else options[key] = value;
32
34
  }
33
35
  if ((['investigar','consultar','analizar','imagen'].includes(command) && !options.prompt) ||
34
36
  (command === 'analizar' && !options.files?.length) || (command === 'recuperar' && !options.directory)) { await err(HELP); return 2; }
35
37
  if (options.wait !== undefined && (!/^\d+$/u.test(options.wait) || Number(options.wait)<1 || Number(options.wait)>600) ||
36
38
  options.limit !== undefined && (!/^\d+$/u.test(options.limit) || Number(options.limit)<1 || Number(options.limit)>100)) { await err(HELP); return 2; }
37
- if (Boolean(options.taskId) !== Boolean(options.projectRoot) || options.taskId && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(options.taskId)) { await err(HELP); return 2; }
38
39
  let usageRecord = null;
39
40
  try {
40
- const store = options.taskId ? usageStore ?? createPeerReviewStore() : null;
41
- const bound = { taskId: options.taskId, projectRoot: options.projectRoot };
42
- if (store) await store.getCollaboration(bound);
41
+ const store = MEASURED.includes(command) ? usageStore ?? createGeminiUsageStore() : null;
43
42
  let input;
44
43
  if (command === 'estado') input = undefined;
45
44
  else if (command === 'historial') input = options.limit === undefined ? {} : { limit: Number(options.limit) };
@@ -50,15 +49,19 @@ export async function runGeminiCli(argv, { out, err, tools = { investigar, image
50
49
  if (usageRecord) return usageRecord;
51
50
  try {
52
51
  const u = result.usage;
53
- usageRecord = await store.recordUsage({ ...bound, measurement: {
52
+ const measurement = {
54
53
  id: 'gemini:' + result.conversationId, agent: 'gemini', model: result.model, source: 'client-reported',
55
54
  phase: { investigar: 'research', imagen: 'image', analizar: 'analysis', consultar: 'other' }[command],
56
55
  inputTokens: u.input_tokens ?? null, cacheReadTokens: u.cache_read_tokens ?? null,
57
56
  outputTokens: u.output_tokens ?? null, totalTokens: u.total_tokens ?? null,
58
57
  durationMs: result.durationMs ?? null, costUsd: null
59
- }});
58
+ };
59
+ // Sin ningún contador no hay nada que medir: una consulta correcta no debe fallar por eso.
60
+ usageRecord = COUNTERS.every(key => measurement[key] === null)
61
+ ? { recorded: false, reason: 'sin-contadores' }
62
+ : await store.recordUsage(measurement);
60
63
  } catch {
61
- usageRecord = { recorded: false, error: 'No se guardó la medición; conserva estos resultados y regístrala con medir, sin repetir la consulta.' };
64
+ usageRecord = { recorded: false, error: 'No se guardó la medición de consumo; conserva estos resultados y no repitas la consulta.' };
62
65
  }
63
66
  return usageRecord;
64
67
  };
@@ -13,7 +13,7 @@ const CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/u;
13
13
  const IMAGE = /\.(png|jpe?g|webp)$/iu;
14
14
  const KINDS = ["investigar", "imagen", "consultar", "analizar"];
15
15
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
16
- const DEFAULTS = { consultar: "gemini-3.8-flash-low", analizar: "gemini-4-argon-medium", investigar: "gemini-4-argon-medium", imagen: "gemini-3.8-flash-low" };
16
+ const DEFAULTS = { consultar: "gemini-3.8-flash-low", analizar: "gemini-4-hydrogen-medium", investigar: "gemini-4-hydrogen-medium", imagen: "gemini-3.8-flash-low" };
17
17
 
18
18
  export class GeminiError extends Error {
19
19
  constructor(message) { super(message); this.code = "gemini-tools"; }
@@ -0,0 +1,32 @@
1
+ import fs from 'node:fs/promises';
2
+ import { constants } from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { normalizeMeasurement } from './usage-metrics.js';
6
+
7
+ // Registro propio del consumo de Gemini: ~/.agent-toolkit/gemini/consumo.jsonl.
8
+ // Una línea por consulta, solo contadores declarados por el cliente; sin prompts ni respuestas.
9
+ export const geminiHome = () => process.env.AGENT_TOOLKIT_GEMINI_DIR ?? path.join(os.homedir(), '.agent-toolkit', 'gemini');
10
+
11
+ export function createGeminiUsageStore({ directory = geminiHome(), now = () => new Date() } = {}) {
12
+ async function recordUsage(measurement) {
13
+ const normalized = normalizeMeasurement(measurement);
14
+ await fs.mkdir(directory, { recursive: true, mode: 0o700 });
15
+ const folder = await fs.lstat(directory);
16
+ if (!folder.isDirectory() || folder.isSymbolicLink()) throw new Error('Carpeta de consumo insegura.');
17
+ const target = path.join(directory, 'consumo.jsonl');
18
+ try {
19
+ const stat = await fs.lstat(target);
20
+ if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1) throw new Error('Registro inseguro.');
21
+ } catch (error) { if (error.code !== 'ENOENT') throw error; }
22
+ const handle = await fs.open(target, constants.O_WRONLY | constants.O_APPEND | constants.O_CREAT | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0), 0o600);
23
+ try {
24
+ const stat = await handle.stat();
25
+ if (!stat.isFile() || stat.nlink !== 1) throw new Error('Registro inseguro.');
26
+ await handle.chmod(0o600);
27
+ await handle.appendFile(JSON.stringify({ ...normalized, at: now().toISOString() }) + '\n', 'utf8');
28
+ } finally { await handle.close(); }
29
+ return { recorded: true, id: normalized.id };
30
+ }
31
+ return Object.freeze({ recordUsage });
32
+ }
@@ -0,0 +1,69 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { randomUUID, createHash } from 'node:crypto';
4
+ // Auxiliares comunes de los bloques que nexakit escribe en CLAUDE.md, AGENTS.md y GEMINI.md.
5
+ export const hash = (text) => createHash('sha256').update(text).digest('hex');
6
+ export const NAMES = { claude: 'CLAUDE.md', codex: 'AGENTS.md', antigravity: 'GEMINI.md' };
7
+ export function targets({ homeDirectory, environment = {}, codexHome, agents = Object.keys(NAMES) }) {
8
+ if (!homeDirectory || !path.isAbsolute(homeDirectory))
9
+ throw new Error('Se requiere homeDirectory absoluto.');
10
+ const folders = {
11
+ claude: path.join(homeDirectory, '.claude'),
12
+ codex: codexHome ?? environment.CODEX_HOME ?? path.join(homeDirectory, '.codex'),
13
+ antigravity: path.join(homeDirectory, '.gemini'),
14
+ };
15
+ return agents
16
+ .filter((client) => NAMES[client])
17
+ .map((client) => ({ client, name: NAMES[client], target: path.join(folders[client], NAMES[client]) }));
18
+ }
19
+ export async function readText(file) {
20
+ try {
21
+ const stat = await fs.lstat(file);
22
+ if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 1024 * 1024)
23
+ throw new Error('Archivo de instrucciones o registro en conflicto.');
24
+ return await fs.readFile(file, 'utf8');
25
+ } catch (error) {
26
+ if (error.code === 'ENOENT') return null;
27
+ throw error;
28
+ }
29
+ }
30
+ export async function checkParent(directory, create = false) {
31
+ const info = await fs.lstat(directory).catch((error) => {
32
+ if (error.code === 'ENOENT') return null;
33
+ throw error;
34
+ });
35
+ if (info && (!info.isDirectory() || info.isSymbolicLink()))
36
+ throw new Error('La carpeta de instrucciones o registro no es normal.');
37
+ if (!info && create) await fs.mkdir(directory, { recursive: true, mode: 0o700 });
38
+ }
39
+ export async function proof(file) {
40
+ await checkParent(path.dirname(file));
41
+ const text = await readText(file);
42
+ if (text === null) return {};
43
+ const records = JSON.parse(text);
44
+ if (!records || typeof records !== 'object' || Array.isArray(records))
45
+ throw new Error('Registro de instrucciones inválido.');
46
+ return records;
47
+ }
48
+ export function blockOf(text, START, END) {
49
+ const a = text?.indexOf(START) ?? -1,
50
+ b = text?.indexOf(END) ?? -1;
51
+ if (a < 0 || b <= a || text.indexOf(START, a + START.length) >= 0 || text.indexOf(END, b + END.length) >= 0)
52
+ return null;
53
+ return text.slice(a, b + END.length);
54
+ }
55
+ export async function writeAtomic(target, text, lock) {
56
+ await lock.assertHeld();
57
+ const stat = await fs.lstat(target).catch((error) => {
58
+ if (error.code === 'ENOENT') return null;
59
+ throw error;
60
+ });
61
+ const tmp = target + '.' + randomUUID();
62
+ await fs.writeFile(tmp, text, { flag: 'wx', mode: stat?.mode ?? 0o600 });
63
+ try {
64
+ await lock.assertHeld();
65
+ await fs.rename(tmp, target);
66
+ } finally {
67
+ await fs.rm(tmp, { force: true });
68
+ }
69
+ }
@@ -4,10 +4,15 @@ import path from 'node:path';
4
4
 
5
5
  // Las reglas del registro son las del mod, para que el resumen y el aviso de sesión nunca discrepen.
6
6
  import { leerEventos, sinGuardar } from '../plugins/nexakit-lecciones/hooks/lecciones.js';
7
+ import { loadWithDependencyCheck } from './missing-dependencies.js';
7
8
 
8
9
  const DIA_MS = 24 * 60 * 60 * 1000;
9
10
  const MAX_PENDIENTES_TEXTO = 5;
10
- const USO = 'Uso: nexakit lecciones [--json | --descartar]\n';
11
+ const USO = `Uso: nexakit lecciones [--json | --descartar]
12
+ nexakit lecciones registrar --regla <texto> --porque <texto> [--proyecto <ruta>] [--estacion <estacion>]
13
+ nexakit lecciones aceptar <id>
14
+ nexakit lecciones retirar <id>
15
+ `;
11
16
 
12
17
  function resumir(eventos) {
13
18
  const cuenta = (tipo) => eventos.filter((e) => e.tipo === tipo).length;
@@ -22,15 +27,84 @@ function resumir(eventos) {
22
27
  // Las más recientes primero.
23
28
  const pendientes = (eventos) => sinGuardar(eventos).reverse().map((e) => (typeof e.texto === 'string' ? e.texto : ''));
24
29
 
30
+ // Opciones de `registrar`: cada una lleva un valor y no se admite repetirla ni ninguna otra.
31
+ function opcionesDeRegistrar(args) {
32
+ const valores = {};
33
+ for (let i = 0; i < args.length; i += 2) {
34
+ const nombre = args[i];
35
+ const valor = args[i + 1];
36
+ if (!['--regla', '--porque', '--proyecto', '--estacion'].includes(nombre) || valor === undefined || valor.startsWith('--') || nombre in valores) return null;
37
+ valores[nombre] = valor;
38
+ }
39
+ return valores['--regla'] === undefined || valores['--porque'] === undefined ? null : valores;
40
+ }
41
+
42
+ const formatoEfectividad = (e) => {
43
+ if (e === null) return 'sin datos';
44
+ return e.despues < e.antes ? `redujo ${e.antes} → ${e.despues}` : `no redujo ${e.antes} → ${e.despues}`;
45
+ };
46
+
47
+ const donde = (ambito) => {
48
+ if (ambito === 'global') return 'global';
49
+ return 'estacion' in ambito ? `${ambito.proyecto} · ${ambito.estacion}` : ambito.proyecto;
50
+ };
51
+
52
+ async function cargarAlmacen() {
53
+ let aviso = '';
54
+ const [lecciones, errores] = await Promise.all([
55
+ loadWithDependencyCheck(() => import('../dist/fabrica/lecciones.js'), { write: (t) => { aviso += t; } }),
56
+ loadWithDependencyCheck(() => import('../dist/fabrica/errores.js'), { write: (t) => { aviso += t; } }),
57
+ ]);
58
+ return lecciones && errores ? { ...lecciones, ErrorFabrica: errores.ErrorFabrica } : { aviso };
59
+ }
60
+
61
+ // Las órdenes del almacén: sus errores esperados se dicen en español y salen con 1.
62
+ async function ordenDelAlmacen(argv, { out, err }, home, ahora) {
63
+ const [orden, ...args] = argv;
64
+ const opciones = orden === 'registrar' ? opcionesDeRegistrar(args) : null;
65
+ const idOk = (orden === 'aceptar' || orden === 'retirar') && args.length === 1;
66
+ if ((orden === 'registrar' && (opciones === null || (opciones['--estacion'] !== undefined && opciones['--proyecto'] === undefined))) || (orden !== 'registrar' && !idOk)) {
67
+ await err(USO);
68
+ return 2;
69
+ }
70
+ const almacen = await cargarAlmacen();
71
+ if (almacen.aviso !== undefined) {
72
+ await err(almacen.aviso);
73
+ return 1;
74
+ }
75
+ try {
76
+ if (orden === 'registrar') {
77
+ const ambito = opciones['--proyecto'] === undefined
78
+ ? 'global'
79
+ : { proyecto: opciones['--proyecto'], ...(opciones['--estacion'] === undefined ? {} : { estacion: opciones['--estacion'] }) };
80
+ const { leccion, nueva } = await almacen.registrar(
81
+ home,
82
+ { regla: opciones['--regla'], porque: opciones['--porque'], ambito, origen: 'persona' },
83
+ ahora,
84
+ );
85
+ await out(`${nueva ? 'Lección registrada' : 'Esa lección ya existía; se actualizó su fecha'} (${leccion.estado}): ${leccion.id} · ${leccion.regla}\n`);
86
+ } else {
87
+ const leccion = await (orden === 'aceptar' ? almacen.aceptar : almacen.retirar)(home, args[0], ahora);
88
+ await out(`Lección ${leccion.id} ${leccion.estado === 'vigente' ? 'vigente' : 'retirada'}: ${leccion.regla}\n`);
89
+ }
90
+ return 0;
91
+ } catch (error) {
92
+ if (!(error instanceof almacen.ErrorFabrica)) throw error;
93
+ await err(`${error.message}\n`);
94
+ return 1;
95
+ }
96
+ }
97
+
25
98
  export async function runLeccionesCommand(argv, { out, err }, options = {}) {
99
+ const home = options.homeDirectory ?? os.homedir();
100
+ const ahora = options.now ?? Date.now();
101
+ if (['registrar', 'aceptar', 'retirar'].includes(argv[0])) return ordenDelAlmacen(argv, { out, err }, home, ahora);
26
102
  const json = argv.includes('--json');
27
103
  const descartar = argv.includes('--descartar');
28
104
  if (argv.some((a) => a !== '--json' && a !== '--descartar') || (json && descartar)) {
29
105
  await err(USO);
30
106
  return 2;
31
107
  }
32
- const home = options.homeDirectory ?? os.homedir();
33
- const ahora = options.now ?? Date.now();
34
108
  const ruta = path.join(home, '.nexakit', 'lecciones.jsonl');
35
109
  let texto = null;
36
110
  try {
@@ -51,16 +125,35 @@ export async function runLeccionesCommand(argv, { out, err }, options = {}) {
51
125
  await out(`${cuantas === 1 ? '1 corrección descartada' : `${cuantas} correcciones descartadas`}; el historial se conserva.\n`);
52
126
  return 0;
53
127
  }
128
+ // Las propuestas se guardan al listar para poder aceptarlas por id; solo la persona las pasa a vigentes.
129
+ let vigentes = [];
130
+ let propuestas = [];
131
+ const almacen = await cargarAlmacen();
132
+ if (almacen.aviso !== undefined) {
133
+ await err(almacen.aviso);
134
+ } else {
135
+ try {
136
+ await almacen.guardarPropuestas(home, almacen.proponerPorRepeticion(eventos), ahora);
137
+ const todas = await almacen.listar(home);
138
+ vigentes = todas.filter((l) => l.estado === 'vigente').map((l) => ({ ...l, efectividad: almacen.efectividad(l, eventos, ahora) }));
139
+ propuestas = todas.filter((l) => l.estado === 'propuesta');
140
+ } catch (error) {
141
+ if (!(error instanceof almacen.ErrorFabrica)) throw error;
142
+ await err(`${error.message}\n`);
143
+ }
144
+ }
54
145
  const resumen = {
55
146
  ultimos7Dias: resumir(eventos.filter((e) => e.fecha >= ahora - 7 * DIA_MS)),
56
147
  total: resumir(eventos),
57
148
  pendientes: pendientes(eventos),
149
+ vigentes,
150
+ propuestas,
58
151
  };
59
152
  if (json) {
60
153
  await out(`${JSON.stringify(resumen, null, 2)}\n`);
61
154
  return 0;
62
155
  }
63
- if (eventos.length === 0) {
156
+ if (eventos.length === 0 && vigentes.length === 0 && propuestas.length === 0) {
64
157
  await out(
65
158
  'Aún no hay lecciones registradas. El registro lo escribe el mod nexakit-lecciones cuando detecta una corrección o un error repetido.\n',
66
159
  );
@@ -78,5 +171,13 @@ export async function runLeccionesCommand(argv, { out, err }, options = {}) {
78
171
  for (const t of p.slice(0, MAX_PENDIENTES_TEXTO)) await out(` - ${t}\n`);
79
172
  if (p.length > MAX_PENDIENTES_TEXTO) await out(` ... y ${p.length - MAX_PENDIENTES_TEXTO} más (usa --json para verlas todas)\n`);
80
173
  }
174
+ if (vigentes.length > 0) {
175
+ await out(`Vigentes: ${vigentes.length} (quitar una: nexakit lecciones retirar <id>)\n`);
176
+ for (const l of vigentes) await out(` - ${l.id} · ${l.regla} [${donde(l.ambito)}] — ${formatoEfectividad(l.efectividad)}\n`);
177
+ }
178
+ if (propuestas.length > 0) {
179
+ await out(`Propuestas: ${propuestas.length} (aceptar: nexakit lecciones aceptar <id>; descartar: nexakit lecciones retirar <id>)\n`);
180
+ for (const l of propuestas) await out(` - ${l.id} · ${l.regla}\n`);
181
+ }
81
182
  return 0;
82
183
  }
@@ -0,0 +1,178 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { targets, readText, checkParent, proof as readProof, blockOf as findBlock, writeAtomic, hash } from './instructions-block.js';
4
+ // Las lecciones globales vigentes, compartidas con las tres IA en un bloque propio. A diferencia del bloque de reglas
5
+ // de trabajo, su cuerpo cambia con las lecciones: la propiedad es el hash del último bloque escrito (registro).
6
+ const START = '<!-- nexakit:lecciones:start -->',
7
+ END = '<!-- nexakit:lecciones:end -->';
8
+ export const MAX_LECCIONES_BLOQUE = 20;
9
+ export const MAX_BYTES_BLOQUE = 2048;
10
+ const proofPath = (home) => path.join(home, '.nexakit', 'lecciones-instructions.json');
11
+ const proof = (home) => readProof(proofPath(home));
12
+ const blockOf = (text) => findBlock(text, START, END);
13
+ async function cargarAlmacen() {
14
+ try {
15
+ return await import('../dist/fabrica/lecciones.js');
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+ // Sin comentarios HTML ni marcadores: una regla no puede abrir ni cerrar el bloque.
21
+ function sanear(texto, limpiar) {
22
+ let actual = limpiar(String(texto));
23
+ for (let previo = ''; previo !== actual; ) {
24
+ previo = actual;
25
+ actual = limpiar(actual.replaceAll(START, '').replaceAll(END, '').replaceAll('<!--', '').replaceAll('-->', ''));
26
+ }
27
+ return actual;
28
+ }
29
+ /** El cuerpo del bloque con las lecciones globales vigentes, o null si no hay ninguna que aplicar. */
30
+ export function cuerpoDeLecciones(lecciones, limpiar) {
31
+ const reglas = lecciones
32
+ .filter((l) => l.ambito === 'global')
33
+ .sort((a, b) => b.fecha - a.fecha)
34
+ .map((l) => sanear(l.regla, limpiar))
35
+ .filter(Boolean);
36
+ const lineas = [];
37
+ const armar = (extra) => [START, '# Lecciones de nexakit', '', ...extra, END].join('\n');
38
+ for (const regla of reglas) {
39
+ if (lineas.length >= MAX_LECCIONES_BLOQUE) break;
40
+ const linea = `- ${regla}`;
41
+ if (Buffer.byteLength(armar([...lineas, linea]), 'utf8') > MAX_BYTES_BLOQUE) break;
42
+ lineas.push(linea);
43
+ }
44
+ return lineas.length ? armar(lineas) : null;
45
+ }
46
+ // `undefined`: no se pudo leer el almacén, así que no se toca nada.
47
+ async function cuerpoActual(options) {
48
+ const almacen = options.cargarLecciones ? await options.cargarLecciones() : await cargarAlmacen();
49
+ if (!almacen) return undefined;
50
+ try {
51
+ return cuerpoDeLecciones(await almacen.vigentes(options.homeDirectory), almacen.limpiarTexto);
52
+ } catch {
53
+ return undefined;
54
+ }
55
+ }
56
+ export async function planLeccionesInstructions(options = {}) {
57
+ const owned = await proof(options.homeDirectory),
58
+ body = await cuerpoActual(options),
59
+ items = [];
60
+ for (const item of targets(options)) {
61
+ let before;
62
+ try {
63
+ await checkParent(path.dirname(item.target));
64
+ before = await readText(item.target);
65
+ } catch {
66
+ items.push({ ...item, state: 'conflict' });
67
+ continue;
68
+ }
69
+ const block = blockOf(before),
70
+ record = owned[item.target];
71
+ if (before?.includes(START) && !block) {
72
+ items.push({ ...item, state: 'conflict' });
73
+ continue;
74
+ }
75
+ // Un bloque que no es el último que escribimos (o que nunca escribimos) es de la persona.
76
+ if (block && record?.blockHash !== hash(block)) {
77
+ items.push({ ...item, state: 'conflict', reason: 'editado' });
78
+ continue;
79
+ }
80
+ if (body === undefined || (!block && body === null)) {
81
+ items.push({ ...item, before, state: 'ready' });
82
+ continue;
83
+ }
84
+ if (block && body === null) {
85
+ items.push({ ...item, before, state: 'pending', remove: true, update: true });
86
+ continue;
87
+ }
88
+ const prefix = before === null ? '' : before.endsWith('\n') ? before + '\n' : before + '\n\n';
89
+ const after = block ? before.replace(block, () => body) : prefix + body + '\n';
90
+ items.push({
91
+ ...item,
92
+ before,
93
+ after,
94
+ blockHash: hash(body),
95
+ state: after === before ? 'ready' : 'pending',
96
+ ...(block && after !== before && { update: true }),
97
+ original: block ? record.original : before,
98
+ created: block ? record.created : before === null,
99
+ });
100
+ }
101
+ return { homeDirectory: options.homeDirectory, items };
102
+ }
103
+ async function retirarBloque(item, entry, text, lock) {
104
+ const block = blockOf(text);
105
+ if (!block || hash(block) !== entry.blockHash) return false;
106
+ await lock.assertHeld();
107
+ if ((await readText(item.target)) !== text) throw new Error(`${item.name} cambió durante la retirada.`);
108
+ const without = text.replace(block, () => '');
109
+ if (entry.created && !without.trim()) await fs.unlink(item.target);
110
+ else if (
111
+ text ===
112
+ (entry.original ?? '') + ((entry.original ?? '').endsWith('\n') ? '\n' : '\n\n') + block + '\n'
113
+ )
114
+ await writeAtomic(item.target, entry.original ?? '', lock);
115
+ else await writeAtomic(item.target, without, lock);
116
+ return true;
117
+ }
118
+ async function guardarRegistro(home, owned, lock) {
119
+ if (!Object.keys(owned).length) {
120
+ await lock.assertHeld();
121
+ await fs.rm(proofPath(home), { force: true });
122
+ } else {
123
+ await lock.assertHeld();
124
+ await checkParent(path.dirname(proofPath(home)), true);
125
+ await writeAtomic(proofPath(home), JSON.stringify(owned), lock);
126
+ }
127
+ }
128
+ export async function applyLeccionesInstructions(plan, lock) {
129
+ const owned = await proof(plan.homeDirectory),
130
+ pending = plan.items.filter((item) => item.state === 'pending');
131
+ if (!pending.length) return;
132
+ for (const item of pending) {
133
+ await checkParent(path.dirname(item.target));
134
+ if ((await readText(item.target)) !== item.before)
135
+ throw new Error(`${item.name} cambió mientras confirmabas.`);
136
+ }
137
+ // Se retiran primero los bloques sin lecciones; el registro se guarda antes de publicar los nuevos.
138
+ for (const item of pending.filter((i) => i.remove)) {
139
+ if (await retirarBloque(item, owned[item.target], item.before, lock)) delete owned[item.target];
140
+ }
141
+ for (const item of pending.filter((i) => !i.remove))
142
+ owned[item.target] = { client: item.client, blockHash: item.blockHash, original: item.original, created: item.created };
143
+ await guardarRegistro(plan.homeDirectory, owned, lock);
144
+ for (const item of pending.filter((i) => !i.remove)) {
145
+ await lock.assertHeld();
146
+ await checkParent(path.dirname(item.target), true);
147
+ if ((await readText(item.target)) !== item.before)
148
+ throw new Error(`${item.name} cambió mientras confirmabas.`);
149
+ await writeAtomic(item.target, item.after, lock);
150
+ }
151
+ }
152
+ export async function removeLeccionesInstructions(options, lock) {
153
+ const owned = await proof(options.homeDirectory);
154
+ for (const item of targets(options)) {
155
+ const entry = owned[item.target];
156
+ if (!entry) continue;
157
+ let text;
158
+ try {
159
+ await checkParent(path.dirname(item.target));
160
+ text = await readText(item.target);
161
+ } catch {
162
+ continue;
163
+ }
164
+ if (!(await retirarBloque(item, entry, text, lock))) continue;
165
+ delete owned[item.target];
166
+ }
167
+ await guardarRegistro(options.homeDirectory, owned, lock);
168
+ }
169
+ export async function ownedLeccionesInstructions(options) {
170
+ const owned = await proof(options.homeDirectory),
171
+ result = [];
172
+ for (const item of targets(options)) {
173
+ const text = await readText(item.target).catch(() => null),
174
+ block = blockOf(text);
175
+ if (block && owned[item.target]?.blockHash === hash(block)) result.push(item.name);
176
+ }
177
+ return result;
178
+ }
@@ -57,7 +57,7 @@ export async function applyLegacyRepair(plan, {
57
57
 
58
58
  // The MCP entry is not rewritten here: its client owns that file, so only the exact commands are given.
59
59
  const mcpCommands = [];
60
- const script = path.join(plan.activeRoot, 'bin/agent-toolkit-mcp.js');
60
+ const script = path.join(plan.activeRoot, 'bin/nexakit-fabrica-mcp.js');
61
61
  if (Object.keys(plan.mcp ?? {}).length && await exists(script)) {
62
62
  const nodePath = await resolveNodeExecutable(environment);
63
63
  for (const [client, current] of Object.entries(plan.mcp)) {
@@ -3,6 +3,7 @@ import fs from "node:fs/promises";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { agentModels } from "./agent-models.js";
6
+ import { REGLA_ORDENES_SIMPLES } from "./regla-ordenes-simples.js";
6
7
 
7
8
  // Codex level agents use local TOML files; Claude's come from the `niveles` plugin.
8
9
  // The top level is "alto"; xhigh is asked per spawn, only after high failed.
@@ -16,7 +17,7 @@ export class LevelAgentsError extends Error {
16
17
 
17
18
  function content(slug, level, { model, effort }) {
18
19
  const task = `nivel ${level} (${model}, ${effort})`;
19
- return [`# Generado por \`agent-toolkit-inbox agentes\`. Ese comando nunca sobrescribe ni borra: lo anterior queda como .anterior-*.`,
20
+ return [`# Generado por \`nexakit codex agentes\`. Ese comando nunca sobrescribe ni borra: lo anterior queda como .anterior-*.`,
20
21
  `name = ${JSON.stringify(`nivel_${slug}`)}`,
21
22
  `description = ${JSON.stringify(`Ejecuta una tarea delegada de ${task}. Úsalo para ${USES[slug]}.`)}`,
22
23
  `model = ${JSON.stringify(model)}`, `model_reasoning_effort = ${JSON.stringify(effort)}`,
@@ -25,6 +26,7 @@ function content(slug, level, { model, effort }) {
25
26
  "Haz solo lo que pide la delegación y respeta las reglas del proyecto (AGENTS.md y sus skills).",
26
27
  "Si la tarea es de código: cambio mínimo, pruebas que lo cubran, y ejecútalas junto con el lint o la compilación que correspondan.",
27
28
  "No hagas commit, push ni PR, y no envíes, apruebes ni reclames encargos de revisión.",
29
+ REGLA_ORDENES_SIMPLES,
28
30
  "Responde breve, en menos de 200 palabras: cambios por archivo (sin pegar el diff), comprobaciones con su resultado real y lo que no comprobaste. En búsquedas, solo rutas con línea. No repitas el encargo.",
29
31
  `"""`, ""].join("\n");
30
32
  }
@@ -103,8 +105,8 @@ export function levelAgentsTable({ catalog, files }) {
103
105
  lines.push("");
104
106
  if (!catalog) lines.push("No se pudo leer el catálogo de Codex (`models_cache.json`); no se escribe nada hasta que se lea bien.");
105
107
  const pending = files.filter(file => file.state === "nuevo").length, different = files.filter(file => file.state === "distinto").length;
106
- if (pending) lines.push(`Vista previa: no se escribió nada. Ejecuta \`agent-toolkit-inbox agentes --escribir\` para crear ${pending}.`);
107
- if (different) lines.push(`Hay ${different} ${different === 1 ? "archivo" : "archivos"} con otro contenido que no se ${different === 1 ? "toca" : "tocan"}. Con \`--escribir --forzar\` se actualizan y el anterior queda como \`.anterior-*\` junto al archivo.`);
108
+ if (pending) lines.push(`Vista previa: no se escribió nada. Ejecuta \`nexakit codex agentes --apply\` para crear ${pending}.`);
109
+ if (different) lines.push(`Hay ${different} ${different === 1 ? "archivo" : "archivos"} con otro contenido que no se ${different === 1 ? "toca" : "tocan"}. Con \`nexakit codex agentes --apply --actualizar\` se actualizan y el anterior queda como \`.anterior-*\` junto al archivo.`);
108
110
  for (const file of files.filter(item => item.anterior)) lines.push(`Anterior conservado: \`${file.anterior}\`.`);
109
111
  if (!pending && !different && catalog) lines.push("Los agentes están al día.");
110
112
  lines.push("");
@@ -5,7 +5,7 @@ import os from "node:os";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath, pathToFileURL } from "node:url";
7
7
  import Ajv2020 from "ajv/dist/2020.js";
8
- import { parseTaskDocument } from "./task-prepare-files.js";
8
+ import { parseTaskDocument } from "./task-document.js";
9
9
  import { containsSensitiveData, isCredentialPath } from "./sensitive-data.js";
10
10
 
11
11
  export const MEMORY_READ_TOOLS = Object.freeze([
@@ -12,6 +12,11 @@ export async function loadWithDependencyCheck(load, { root = copyRoot(), write =
12
12
  try {
13
13
  return await load();
14
14
  } catch (error) {
15
+ if (error?.code === 'ERR_MODULE_NOT_FOUND' && /^Cannot find module '[^']*[\\/]dist[\\/]fabrica[\\/]/u.test(error.message ?? '')) {
16
+ write('Falta la compilación de la fábrica (dist/fabrica). Ejecuta npm run build o reinstala nexakit.\n');
17
+ process.exitCode = 1;
18
+ return null;
19
+ }
15
20
  const missingPackage = error?.code === 'ERR_MODULE_NOT_FOUND' && /^Cannot find package '/u.test(error.message ?? '');
16
21
  if (!missingPackage || isEphemeralPath(root)) throw error;
17
22
  write(`Faltan las dependencias de esta copia. Ejecuta \`npm ci\` en ${root}.\n`);
@@ -0,0 +1,29 @@
1
+ // Tipos de src/model-command.js para el código TypeScript de la fábrica.
2
+ export interface ModeloDeCatalogo {
3
+ model: string;
4
+ efforts: string[];
5
+ defaultEffort?: string | null;
6
+ }
7
+
8
+ export interface FilaDeNivel {
9
+ level: string;
10
+ effort: string;
11
+ claude: { model: string; effort: string } | null;
12
+ codex: { model: string; effort: string } | null;
13
+ }
14
+
15
+ export function inspectModels(opciones?: {
16
+ homeDirectory?: string;
17
+ environment?: NodeJS.ProcessEnv;
18
+ codexProfile?: string;
19
+ runCommand?: unknown;
20
+ includeAntigravity?: boolean;
21
+ }): Promise<{
22
+ catalogs: { claude: ModeloDeCatalogo[]; codex: ModeloDeCatalogo[]; antigravity: ModeloDeCatalogo[] };
23
+ levels: FilaDeNivel[];
24
+ }>;
25
+
26
+ export function recommendAntigravity(
27
+ models: ModeloDeCatalogo[],
28
+ nivel: { level: string; effort: string },
29
+ ): { model: string; effort: string } | null;