hanuscode 1.0.0__py3-none-any.whl

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 (93) hide show
  1. hanus/__init__.py +5 -0
  2. hanus/__main__.py +10 -0
  3. hanus/action_handlers.py +76 -0
  4. hanus/action_parser.py +82 -0
  5. hanus/agent_runner.py +1445 -0
  6. hanus/analysis/__init__.py +5 -0
  7. hanus/analysis/debt.py +702 -0
  8. hanus/analysis/dependencies.py +475 -0
  9. hanus/cache/__init__.py +5 -0
  10. hanus/cache/response_cache.py +560 -0
  11. hanus/config.py +401 -0
  12. hanus/connectors/__init__.py +19 -0
  13. hanus/connectors/base.py +114 -0
  14. hanus/connectors/claude_connector.py +146 -0
  15. hanus/connectors/gemini_connector.py +141 -0
  16. hanus/connectors/glm_connector.py +160 -0
  17. hanus/connectors/ollama_connector.py +174 -0
  18. hanus/connectors/openai_connector.py +122 -0
  19. hanus/connectors/registry.py +26 -0
  20. hanus/context/__init__.py +7 -0
  21. hanus/context/manager.py +837 -0
  22. hanus/context/selective.py +626 -0
  23. hanus/error_recovery/__init__.py +5 -0
  24. hanus/error_recovery/auto_fix.py +605 -0
  25. hanus/hooks/__init__.py +5 -0
  26. hanus/hooks/manager.py +247 -0
  27. hanus/instincts/__init__.py +44 -0
  28. hanus/instincts/cli.py +372 -0
  29. hanus/instincts/detector.py +281 -0
  30. hanus/instincts/evolver.py +361 -0
  31. hanus/instincts/manager.py +343 -0
  32. hanus/instincts/types.py +253 -0
  33. hanus/logger.py +81 -0
  34. hanus/memory/__init__.py +8 -0
  35. hanus/memory/manager.py +265 -0
  36. hanus/memory/types.py +119 -0
  37. hanus/monitor.py +341 -0
  38. hanus/parallel/__init__.py +5 -0
  39. hanus/parallel/executor.py +300 -0
  40. hanus/permissions.py +182 -0
  41. hanus/plan/__init__.py +8 -0
  42. hanus/plan/mode.py +267 -0
  43. hanus/plan/models.py +152 -0
  44. hanus/plugin_manager.py +754 -0
  45. hanus/plugin_registry.py +391 -0
  46. hanus/plugins/__init__.py +1 -0
  47. hanus/plugins/arena.py +630 -0
  48. hanus/plugins/code_review.py +123 -0
  49. hanus/plugins/cortex.py +1750 -0
  50. hanus/plugins/deps_check.py +27 -0
  51. hanus/plugins/git_ops.py +33 -0
  52. hanus/plugins/metasploit.py +530 -0
  53. hanus/plugins/notes.py +583 -0
  54. hanus/plugins/search_code.py +59 -0
  55. hanus/plugins/searchsploit.py +495 -0
  56. hanus/plugins/strategist.py +175 -0
  57. hanus/plugins/webui.py +5200 -0
  58. hanus/profiles.py +479 -0
  59. hanus/profiles_builtin/__init__.py +0 -0
  60. hanus/profiles_builtin/architect/profile.yaml +12 -0
  61. hanus/profiles_builtin/architect/system_prompt.txt +71 -0
  62. hanus/profiles_builtin/deep/profile.yaml +12 -0
  63. hanus/profiles_builtin/deep/system_prompt.txt +66 -0
  64. hanus/profiles_builtin/developer/__init__.py +0 -0
  65. hanus/profiles_builtin/developer/profile.yaml +9 -0
  66. hanus/profiles_builtin/developer/system_prompt.txt +176 -0
  67. hanus/profiles_builtin/speed/profile.yaml +12 -0
  68. hanus/profiles_builtin/speed/system_prompt.txt +51 -0
  69. hanus/project_tools.py +177 -0
  70. hanus/query_engine.py +1594 -0
  71. hanus/rules/__init__.py +237 -0
  72. hanus/search/__init__.py +5 -0
  73. hanus/search/semantic.py +596 -0
  74. hanus/session_manager.py +547 -0
  75. hanus/skill_manager.py +702 -0
  76. hanus/skills/__init__.py +4 -0
  77. hanus/subagent/__init__.py +8 -0
  78. hanus/subagent/agents/__init__.py +253 -0
  79. hanus/subagent/manager.py +309 -0
  80. hanus/subagent/types.py +266 -0
  81. hanus/suggestions/__init__.py +5 -0
  82. hanus/suggestions/proactive.py +451 -0
  83. hanus/tasks/__init__.py +8 -0
  84. hanus/tasks/manager.py +330 -0
  85. hanus/tasks/models.py +106 -0
  86. hanus/terminal_prompt.py +166 -0
  87. hanus/tools.py +1849 -0
  88. hanus/ui.py +939 -0
  89. hanuscode-1.0.0.dist-info/METADATA +1151 -0
  90. hanuscode-1.0.0.dist-info/RECORD +93 -0
  91. hanuscode-1.0.0.dist-info/WHEEL +5 -0
  92. hanuscode-1.0.0.dist-info/entry_points.txt +2 -0
  93. hanuscode-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,266 @@
1
+ # hanus/subagent/types.py
2
+ """
3
+ Tipos de datos para el sistema de subagentes.
4
+
5
+ Incluye todos los tipos de agentes del sistema ECC:
6
+ - Architecture agents (5)
7
+ - Reviewer agents (22)
8
+ - Build resolvers (11)
9
+ - Specialized agents (26)
10
+ """
11
+ from __future__ import annotations
12
+ from dataclasses import dataclass, field
13
+ from typing import List, Dict, Any, Optional
14
+ from enum import Enum
15
+
16
+
17
+ class SubagentType(Enum):
18
+ """
19
+ Tipos de subagentes disponibles.
20
+
21
+ Categorías:
22
+ - EXPLORE: Solo lectura, exploración de código
23
+ - PLAN: Planificación y diseño
24
+ - GENERAL: Propósito general con todas las herramientas
25
+ - REVIEW: Revisión de código
26
+ - TEST: Escritura y ejecución de tests
27
+
28
+ Agentes especializados de ECC:
29
+ - ARCHITECT: Arquitectura de software
30
+ - CODE_ARCHITECT: Arquitectura de código
31
+ - NETWORK_ARCHITECT: Arquitectura de red
32
+ - SECURITY_REVIEWER: Revisión de seguridad
33
+ - PYTHON_REVIEWER: Revisión de Python
34
+ - TYPESCRIPT_REVIEWER: Revisión de TypeScript
35
+ - ... y más
36
+ """
37
+ # Tipos básicos
38
+ EXPLORE = "explore"
39
+ PLAN = "plan"
40
+ GENERAL = "general"
41
+ REVIEW = "review"
42
+ TEST = "test"
43
+
44
+ # Architecture Agents
45
+ ARCHITECT = "architect"
46
+ CODE_ARCHITECT = "code-architect"
47
+ NETWORK_ARCHITECT = "network-architect"
48
+ A11Y_ARCHITECT = "a11y-architect"
49
+ HOMELAB_ARCHITECT = "homelab-architect"
50
+
51
+ # Reviewer Agents
52
+ CODE_REVIEWER = "code-reviewer"
53
+ PYTHON_REVIEWER = "python-reviewer"
54
+ TYPESCRIPT_REVIEWER = "typescript-reviewer"
55
+ SECURITY_REVIEWER = "security-reviewer"
56
+ GO_REVIEWER = "go-reviewer"
57
+ RUST_REVIEWER = "rust-reviewer"
58
+ REACT_REVIEWER = "react-reviewer"
59
+ JAVA_REVIEWER = "java-reviewer"
60
+ FASTAPI_REVIEWER = "fastapi-reviewer"
61
+ DJANGO_REVIEWER = "django-reviewer"
62
+ DATABASE_REVIEWER = "database-reviewer"
63
+ SWIFT_REVIEWER = "swift-reviewer"
64
+ KOTLIN_REVIEWER = "kotlin-reviewer"
65
+ PHP_REVIEWER = "php-reviewer"
66
+ CPP_REVIEWER = "cpp-reviewer"
67
+ CSHARP_REVIEWER = "csharp-reviewer"
68
+ MLE_REVIEWER = "mle-reviewer"
69
+ FLUTTER_REVIEWER = "flutter-reviewer"
70
+
71
+ # Build Resolver Agents
72
+ BUILD_ERROR_RESOLVER = "build-error-resolver"
73
+ PYTHON_BUILD_RESOLVER = "python-build-resolver"
74
+ REACT_BUILD_RESOLVER = "react-build-resolver"
75
+ GO_BUILD_RESOLVER = "go-build-resolver"
76
+ RUST_BUILD_RESOLVER = "rust-build-resolver"
77
+ JAVA_BUILD_RESOLVER = "java-build-resolver"
78
+ SWIFT_BUILD_RESOLVER = "swift-build-resolver"
79
+ DART_BUILD_RESOLVER = "dart-build-resolver"
80
+
81
+ # Specialized Agents
82
+ PLANNER = "planner"
83
+ TDD_GUIDE = "tdd-guide"
84
+ PERFORMANCE_OPTIMIZER = "performance-optimizer"
85
+ CODE_EXPLORER = "code-explorer"
86
+ DOC_UPDATER = "doc-updater"
87
+ REFACTOR_CLEANER = "refactor-cleaner"
88
+ CHIEF_OF_STAFF = "chief-of-staff"
89
+ CODE_SIMPLIFIER = "code-simplifier"
90
+ SILENT_FAILURE_HUNTER = "silent-failure-hunter"
91
+ E2E_RUNNER = "e2e-runner"
92
+ OPENSOURCE_SANITIZER = "opensource-sanitizer"
93
+ OPENSOURCE_PACKAGER = "opensource-packager"
94
+ LOOP_OPERATOR = "loop-operator"
95
+ HARNESS_OPTIMIZER = "harness-optimizer"
96
+
97
+
98
+ # Mapeo de herramientas permitidas por tipo de subagente
99
+ SUBAGENT_TOOLS: Dict[SubagentType, Optional[List[str]]] = {
100
+ # Tipos básicos
101
+ SubagentType.EXPLORE: [
102
+ "read_file", "grep_search", "glob_search", "list_files",
103
+ "git_status", "git_diff", "git_log",
104
+ ],
105
+ SubagentType.PLAN: [
106
+ "read_file", "grep_search", "glob_search", "list_files",
107
+ "write_file",
108
+ ],
109
+ SubagentType.GENERAL: None, # Todas las herramientas
110
+ SubagentType.REVIEW: [
111
+ "read_file", "grep_search", "glob_search", "list_files",
112
+ "structured_output", "exec_cmd",
113
+ ],
114
+ SubagentType.TEST: [
115
+ "read_file", "write_file", "exec_cmd",
116
+ "grep_search", "glob_search",
117
+ ],
118
+
119
+ # Architecture Agents - Solo lectura y análisis
120
+ SubagentType.ARCHITECT: ["read_file", "grep_search", "glob_search", "list_files"],
121
+ SubagentType.CODE_ARCHITECT: ["read_file", "grep_search", "glob_search", "list_files", "write_file"],
122
+ SubagentType.NETWORK_ARCHITECT: ["read_file", "grep_search", "glob_search", "list_files"],
123
+ SubagentType.A11Y_ARCHITECT: ["read_file", "grep_search", "glob_search", "list_files"],
124
+ SubagentType.HOMELAB_ARCHITECT: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
125
+
126
+ # Reviewer Agents - Lectura + comandos de análisis
127
+ SubagentType.CODE_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
128
+ SubagentType.PYTHON_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
129
+ SubagentType.TYPESCRIPT_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
130
+ SubagentType.SECURITY_REVIEWER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
131
+ SubagentType.GO_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
132
+ SubagentType.RUST_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
133
+ SubagentType.REACT_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
134
+ SubagentType.JAVA_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
135
+ SubagentType.FASTAPI_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
136
+ SubagentType.DJANGO_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
137
+ SubagentType.DATABASE_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
138
+ SubagentType.SWIFT_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
139
+ SubagentType.KOTLIN_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
140
+ SubagentType.PHP_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
141
+ SubagentType.CPP_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
142
+ SubagentType.CSHARP_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
143
+ SubagentType.MLE_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
144
+ SubagentType.FLUTTER_REVIEWER: ["read_file", "grep_search", "glob_search", "list_files", "exec_cmd"],
145
+
146
+ # Build Resolver Agents - Escritura limitada para fixes
147
+ SubagentType.BUILD_ERROR_RESOLVER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
148
+ SubagentType.PYTHON_BUILD_RESOLVER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
149
+ SubagentType.REACT_BUILD_RESOLVER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
150
+ SubagentType.GO_BUILD_RESOLVER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
151
+ SubagentType.RUST_BUILD_RESOLVER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
152
+ SubagentType.JAVA_BUILD_RESOLVER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
153
+ SubagentType.SWIFT_BUILD_RESOLVER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
154
+ SubagentType.DART_BUILD_RESOLVER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
155
+
156
+ # Specialized Agents
157
+ SubagentType.PLANNER: ["read_file", "grep_search", "glob_search", "list_files"],
158
+ SubagentType.TDD_GUIDE: ["read_file", "write_file", "edit_file", "grep_search", "exec_cmd"],
159
+ SubagentType.PERFORMANCE_OPTIMIZER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
160
+ SubagentType.CODE_EXPLORER: ["read_file", "grep_search", "glob_search", "list_files"],
161
+ SubagentType.DOC_UPDATER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search"],
162
+ SubagentType.REFACTOR_CLEANER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
163
+ SubagentType.CHIEF_OF_STAFF: ["read_file", "grep_search", "glob_search", "list_files"],
164
+ SubagentType.CODE_SIMPLIFIER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search"],
165
+ SubagentType.SILENT_FAILURE_HUNTER: ["read_file", "grep_search", "glob_search", "list_files"],
166
+ SubagentType.E2E_RUNNER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
167
+ SubagentType.OPENSOURCE_SANITIZER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search", "exec_cmd"],
168
+ SubagentType.OPENSOURCE_PACKAGER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search"],
169
+ SubagentType.LOOP_OPERATOR: ["read_file", "grep_search", "glob_search", "exec_cmd"],
170
+ SubagentType.HARNESS_OPTIMIZER: ["read_file", "write_file", "edit_file", "grep_search", "glob_search"],
171
+ }
172
+
173
+
174
+ # Prompts de sistema por tipo de subagente
175
+ SUBAGENT_SYSTEM_PROMPTS: Dict[SubagentType, str] = {
176
+ # Tipos básicos
177
+ SubagentType.EXPLORE: """Eres un agente de exploración de código. Tu trabajo es:
178
+ 1. Leer y analizar archivos de código
179
+ 2. Buscar patrones y estructuras
180
+ 3. Resumir lo encontrado de forma clara y concisa
181
+
182
+ NO puedes modificar archivos. Solo leer y reportar.
183
+ Usa grep_search y read_file para explorar eficientemente.
184
+ Proporciona resúmenes estructurados con rutas de archivo y números de línea.""",
185
+
186
+ SubagentType.PLAN: """Eres un agente de planificación. Tu trabajo es:
187
+ 1. Analizar el problema o requerimiento
188
+ 2. Diseñar una solución paso a paso
189
+ 3. Documentar el plan de implementación
190
+
191
+ Escribe planes claros y detallados.
192
+ Considera edge cases y posibles problemas.
193
+ Prioriza soluciones simples y mantenibles.""",
194
+
195
+ SubagentType.GENERAL: """Eres un agente de propósito general.
196
+ Tienes acceso a todas las herramientas para completar tu tarea.
197
+ Trabaja de forma autónoma y completa las tareas de principio a fin.
198
+ Verifica tu trabajo antes de reportar completado.""",
199
+
200
+ SubagentType.REVIEW: """Eres un agente de revisión de código. Tu trabajo es:
201
+ 1. Analizar código en busca de bugs
202
+ 2. Identificar problemas de seguridad
203
+ 3. Sugerir mejoras de calidad
204
+ 4. Verificar adherencia a best practices
205
+
206
+ Proporciona feedback específico con rutas de archivo y números de línea.
207
+ Prioriza problemas críticos sobre mejoras cosméticas.""",
208
+
209
+ SubagentType.TEST: """Eres un agente de testing. Tu trabajo es:
210
+ 1. Escribir tests para el código proporcionado
211
+ 2. Ejecutar los tests y verificar que pasan
212
+ 3. Reportar cobertura y problemas encontrados
213
+
214
+ Usa pytest para Python, jest para JavaScript, etc.
215
+ Los tests deben ser claros, mantenibles y comprehensivos.""",
216
+
217
+ # Los prompts especializados se cargan desde los archivos .md
218
+ }
219
+
220
+
221
+ @dataclass
222
+ class SubagentConfig:
223
+ """Configuración para crear un subagente."""
224
+ agent_type: SubagentType
225
+ task_description: str
226
+ context: str = ""
227
+ max_iterations: int = 15
228
+ max_tokens: int = 4096
229
+ isolation_mode: str = "shared" # "shared" | "worktree"
230
+ model_override: Optional[str] = None
231
+
232
+
233
+ @dataclass
234
+ class SubagentResult:
235
+ """Resultado de la ejecución de un subagente."""
236
+ success: bool
237
+ output: str
238
+ files_modified: List[str] = field(default_factory=list)
239
+ tokens_used: int = 0
240
+ cost_usd: float = 0.0
241
+ error: Optional[str] = None
242
+ agent_id: str = ""
243
+
244
+
245
+ # Utilidades para mapeo de tipos
246
+
247
+ def get_subagent_type(name: str) -> Optional[SubagentType]:
248
+ """Obtiene el tipo de subagente desde un nombre string."""
249
+ name_lower = name.lower().replace("-", "_").replace(" ", "_")
250
+ for st in SubagentType:
251
+ if st.value == name or st.name.lower() == name_lower:
252
+ return st
253
+ return None
254
+
255
+
256
+ def get_tools_for_type(agent_type: SubagentType) -> Optional[List[str]]:
257
+ """Obtiene las herramientas permitidas para un tipo de agente."""
258
+ return SUBAGENT_TOOLS.get(agent_type)
259
+
260
+
261
+ def get_prompt_for_type(agent_type: SubagentType) -> str:
262
+ """Obtiene el prompt de sistema para un tipo de agente."""
263
+ return SUBAGENT_SYSTEM_PROMPTS.get(
264
+ agent_type,
265
+ SUBAGENT_SYSTEM_PROMPTS[SubagentType.GENERAL]
266
+ )
@@ -0,0 +1,5 @@
1
+ # hanus/suggestions/__init__.py
2
+ """Proactive suggestions system for HanusCode."""
3
+ from .proactive import ProactiveSuggester, Suggestion, SuggestionType
4
+
5
+ __all__ = ["ProactiveSuggester", "Suggestion", "SuggestionType"]