codepp 0.0.437__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 (288) hide show
  1. code_puppy/__init__.py +10 -0
  2. code_puppy/__main__.py +10 -0
  3. code_puppy/agents/__init__.py +31 -0
  4. code_puppy/agents/agent_c_reviewer.py +155 -0
  5. code_puppy/agents/agent_code_puppy.py +117 -0
  6. code_puppy/agents/agent_code_reviewer.py +90 -0
  7. code_puppy/agents/agent_cpp_reviewer.py +132 -0
  8. code_puppy/agents/agent_creator_agent.py +638 -0
  9. code_puppy/agents/agent_golang_reviewer.py +151 -0
  10. code_puppy/agents/agent_helios.py +124 -0
  11. code_puppy/agents/agent_javascript_reviewer.py +160 -0
  12. code_puppy/agents/agent_manager.py +742 -0
  13. code_puppy/agents/agent_pack_leader.py +385 -0
  14. code_puppy/agents/agent_planning.py +165 -0
  15. code_puppy/agents/agent_python_programmer.py +169 -0
  16. code_puppy/agents/agent_python_reviewer.py +90 -0
  17. code_puppy/agents/agent_qa_expert.py +163 -0
  18. code_puppy/agents/agent_qa_kitten.py +208 -0
  19. code_puppy/agents/agent_scheduler.py +121 -0
  20. code_puppy/agents/agent_security_auditor.py +181 -0
  21. code_puppy/agents/agent_terminal_qa.py +323 -0
  22. code_puppy/agents/agent_typescript_reviewer.py +166 -0
  23. code_puppy/agents/base_agent.py +2156 -0
  24. code_puppy/agents/event_stream_handler.py +348 -0
  25. code_puppy/agents/json_agent.py +202 -0
  26. code_puppy/agents/pack/__init__.py +34 -0
  27. code_puppy/agents/pack/bloodhound.py +304 -0
  28. code_puppy/agents/pack/husky.py +327 -0
  29. code_puppy/agents/pack/retriever.py +393 -0
  30. code_puppy/agents/pack/shepherd.py +348 -0
  31. code_puppy/agents/pack/terrier.py +287 -0
  32. code_puppy/agents/pack/watchdog.py +367 -0
  33. code_puppy/agents/prompt_reviewer.py +145 -0
  34. code_puppy/agents/subagent_stream_handler.py +276 -0
  35. code_puppy/api/__init__.py +13 -0
  36. code_puppy/api/app.py +169 -0
  37. code_puppy/api/main.py +21 -0
  38. code_puppy/api/pty_manager.py +453 -0
  39. code_puppy/api/routers/__init__.py +12 -0
  40. code_puppy/api/routers/agents.py +36 -0
  41. code_puppy/api/routers/commands.py +217 -0
  42. code_puppy/api/routers/config.py +75 -0
  43. code_puppy/api/routers/sessions.py +234 -0
  44. code_puppy/api/templates/terminal.html +361 -0
  45. code_puppy/api/websocket.py +154 -0
  46. code_puppy/callbacks.py +692 -0
  47. code_puppy/chatgpt_codex_client.py +338 -0
  48. code_puppy/claude_cache_client.py +672 -0
  49. code_puppy/cli_runner.py +1073 -0
  50. code_puppy/command_line/__init__.py +1 -0
  51. code_puppy/command_line/add_model_menu.py +1092 -0
  52. code_puppy/command_line/agent_menu.py +662 -0
  53. code_puppy/command_line/attachments.py +395 -0
  54. code_puppy/command_line/autosave_menu.py +704 -0
  55. code_puppy/command_line/clipboard.py +527 -0
  56. code_puppy/command_line/colors_menu.py +532 -0
  57. code_puppy/command_line/command_handler.py +293 -0
  58. code_puppy/command_line/command_registry.py +150 -0
  59. code_puppy/command_line/config_commands.py +719 -0
  60. code_puppy/command_line/core_commands.py +867 -0
  61. code_puppy/command_line/diff_menu.py +865 -0
  62. code_puppy/command_line/file_path_completion.py +73 -0
  63. code_puppy/command_line/load_context_completion.py +52 -0
  64. code_puppy/command_line/mcp/__init__.py +10 -0
  65. code_puppy/command_line/mcp/base.py +32 -0
  66. code_puppy/command_line/mcp/catalog_server_installer.py +175 -0
  67. code_puppy/command_line/mcp/custom_server_form.py +688 -0
  68. code_puppy/command_line/mcp/custom_server_installer.py +195 -0
  69. code_puppy/command_line/mcp/edit_command.py +148 -0
  70. code_puppy/command_line/mcp/handler.py +138 -0
  71. code_puppy/command_line/mcp/help_command.py +147 -0
  72. code_puppy/command_line/mcp/install_command.py +214 -0
  73. code_puppy/command_line/mcp/install_menu.py +705 -0
  74. code_puppy/command_line/mcp/list_command.py +94 -0
  75. code_puppy/command_line/mcp/logs_command.py +235 -0
  76. code_puppy/command_line/mcp/remove_command.py +82 -0
  77. code_puppy/command_line/mcp/restart_command.py +100 -0
  78. code_puppy/command_line/mcp/search_command.py +123 -0
  79. code_puppy/command_line/mcp/start_all_command.py +135 -0
  80. code_puppy/command_line/mcp/start_command.py +117 -0
  81. code_puppy/command_line/mcp/status_command.py +184 -0
  82. code_puppy/command_line/mcp/stop_all_command.py +112 -0
  83. code_puppy/command_line/mcp/stop_command.py +80 -0
  84. code_puppy/command_line/mcp/test_command.py +107 -0
  85. code_puppy/command_line/mcp/utils.py +129 -0
  86. code_puppy/command_line/mcp/wizard_utils.py +334 -0
  87. code_puppy/command_line/mcp_completion.py +174 -0
  88. code_puppy/command_line/model_picker_completion.py +197 -0
  89. code_puppy/command_line/model_settings_menu.py +932 -0
  90. code_puppy/command_line/motd.py +96 -0
  91. code_puppy/command_line/onboarding_slides.py +179 -0
  92. code_puppy/command_line/onboarding_wizard.py +342 -0
  93. code_puppy/command_line/pin_command_completion.py +329 -0
  94. code_puppy/command_line/prompt_toolkit_completion.py +846 -0
  95. code_puppy/command_line/session_commands.py +302 -0
  96. code_puppy/command_line/shell_passthrough.py +145 -0
  97. code_puppy/command_line/skills_completion.py +160 -0
  98. code_puppy/command_line/uc_menu.py +893 -0
  99. code_puppy/command_line/utils.py +93 -0
  100. code_puppy/command_line/wiggum_state.py +78 -0
  101. code_puppy/config.py +1770 -0
  102. code_puppy/error_logging.py +134 -0
  103. code_puppy/gemini_code_assist.py +385 -0
  104. code_puppy/gemini_model.py +754 -0
  105. code_puppy/hook_engine/README.md +105 -0
  106. code_puppy/hook_engine/__init__.py +21 -0
  107. code_puppy/hook_engine/aliases.py +155 -0
  108. code_puppy/hook_engine/engine.py +221 -0
  109. code_puppy/hook_engine/executor.py +296 -0
  110. code_puppy/hook_engine/matcher.py +156 -0
  111. code_puppy/hook_engine/models.py +240 -0
  112. code_puppy/hook_engine/registry.py +106 -0
  113. code_puppy/hook_engine/validator.py +144 -0
  114. code_puppy/http_utils.py +361 -0
  115. code_puppy/keymap.py +128 -0
  116. code_puppy/main.py +10 -0
  117. code_puppy/mcp_/__init__.py +66 -0
  118. code_puppy/mcp_/async_lifecycle.py +286 -0
  119. code_puppy/mcp_/blocking_startup.py +469 -0
  120. code_puppy/mcp_/captured_stdio_server.py +275 -0
  121. code_puppy/mcp_/circuit_breaker.py +290 -0
  122. code_puppy/mcp_/config_wizard.py +507 -0
  123. code_puppy/mcp_/dashboard.py +308 -0
  124. code_puppy/mcp_/error_isolation.py +407 -0
  125. code_puppy/mcp_/examples/retry_example.py +226 -0
  126. code_puppy/mcp_/health_monitor.py +589 -0
  127. code_puppy/mcp_/managed_server.py +428 -0
  128. code_puppy/mcp_/manager.py +807 -0
  129. code_puppy/mcp_/mcp_logs.py +224 -0
  130. code_puppy/mcp_/registry.py +451 -0
  131. code_puppy/mcp_/retry_manager.py +337 -0
  132. code_puppy/mcp_/server_registry_catalog.py +1126 -0
  133. code_puppy/mcp_/status_tracker.py +355 -0
  134. code_puppy/mcp_/system_tools.py +209 -0
  135. code_puppy/mcp_prompts/__init__.py +1 -0
  136. code_puppy/mcp_prompts/hook_creator.py +103 -0
  137. code_puppy/messaging/__init__.py +255 -0
  138. code_puppy/messaging/bus.py +613 -0
  139. code_puppy/messaging/commands.py +167 -0
  140. code_puppy/messaging/markdown_patches.py +57 -0
  141. code_puppy/messaging/message_queue.py +361 -0
  142. code_puppy/messaging/messages.py +569 -0
  143. code_puppy/messaging/queue_console.py +271 -0
  144. code_puppy/messaging/renderers.py +311 -0
  145. code_puppy/messaging/rich_renderer.py +1158 -0
  146. code_puppy/messaging/spinner/__init__.py +83 -0
  147. code_puppy/messaging/spinner/console_spinner.py +240 -0
  148. code_puppy/messaging/spinner/spinner_base.py +95 -0
  149. code_puppy/messaging/subagent_console.py +460 -0
  150. code_puppy/model_factory.py +848 -0
  151. code_puppy/model_switching.py +63 -0
  152. code_puppy/model_utils.py +168 -0
  153. code_puppy/models.json +174 -0
  154. code_puppy/models_dev_api.json +1 -0
  155. code_puppy/models_dev_parser.py +592 -0
  156. code_puppy/plugins/__init__.py +186 -0
  157. code_puppy/plugins/agent_skills/__init__.py +22 -0
  158. code_puppy/plugins/agent_skills/config.py +175 -0
  159. code_puppy/plugins/agent_skills/discovery.py +136 -0
  160. code_puppy/plugins/agent_skills/downloader.py +392 -0
  161. code_puppy/plugins/agent_skills/installer.py +22 -0
  162. code_puppy/plugins/agent_skills/metadata.py +219 -0
  163. code_puppy/plugins/agent_skills/prompt_builder.py +60 -0
  164. code_puppy/plugins/agent_skills/register_callbacks.py +241 -0
  165. code_puppy/plugins/agent_skills/remote_catalog.py +322 -0
  166. code_puppy/plugins/agent_skills/skill_catalog.py +257 -0
  167. code_puppy/plugins/agent_skills/skills_install_menu.py +664 -0
  168. code_puppy/plugins/agent_skills/skills_menu.py +781 -0
  169. code_puppy/plugins/antigravity_oauth/__init__.py +10 -0
  170. code_puppy/plugins/antigravity_oauth/accounts.py +406 -0
  171. code_puppy/plugins/antigravity_oauth/antigravity_model.py +706 -0
  172. code_puppy/plugins/antigravity_oauth/config.py +42 -0
  173. code_puppy/plugins/antigravity_oauth/constants.py +133 -0
  174. code_puppy/plugins/antigravity_oauth/oauth.py +478 -0
  175. code_puppy/plugins/antigravity_oauth/register_callbacks.py +518 -0
  176. code_puppy/plugins/antigravity_oauth/storage.py +288 -0
  177. code_puppy/plugins/antigravity_oauth/test_plugin.py +319 -0
  178. code_puppy/plugins/antigravity_oauth/token.py +167 -0
  179. code_puppy/plugins/antigravity_oauth/transport.py +863 -0
  180. code_puppy/plugins/antigravity_oauth/utils.py +168 -0
  181. code_puppy/plugins/chatgpt_oauth/__init__.py +8 -0
  182. code_puppy/plugins/chatgpt_oauth/config.py +52 -0
  183. code_puppy/plugins/chatgpt_oauth/oauth_flow.py +329 -0
  184. code_puppy/plugins/chatgpt_oauth/register_callbacks.py +176 -0
  185. code_puppy/plugins/chatgpt_oauth/test_plugin.py +301 -0
  186. code_puppy/plugins/chatgpt_oauth/utils.py +523 -0
  187. code_puppy/plugins/claude_code_hooks/__init__.py +1 -0
  188. code_puppy/plugins/claude_code_hooks/config.py +137 -0
  189. code_puppy/plugins/claude_code_hooks/register_callbacks.py +175 -0
  190. code_puppy/plugins/claude_code_oauth/README.md +167 -0
  191. code_puppy/plugins/claude_code_oauth/SETUP.md +93 -0
  192. code_puppy/plugins/claude_code_oauth/__init__.py +25 -0
  193. code_puppy/plugins/claude_code_oauth/config.py +52 -0
  194. code_puppy/plugins/claude_code_oauth/register_callbacks.py +453 -0
  195. code_puppy/plugins/claude_code_oauth/test_plugin.py +283 -0
  196. code_puppy/plugins/claude_code_oauth/token_refresh_heartbeat.py +241 -0
  197. code_puppy/plugins/claude_code_oauth/utils.py +640 -0
  198. code_puppy/plugins/customizable_commands/__init__.py +0 -0
  199. code_puppy/plugins/customizable_commands/register_callbacks.py +152 -0
  200. code_puppy/plugins/example_custom_command/README.md +280 -0
  201. code_puppy/plugins/example_custom_command/register_callbacks.py +51 -0
  202. code_puppy/plugins/file_permission_handler/__init__.py +4 -0
  203. code_puppy/plugins/file_permission_handler/register_callbacks.py +470 -0
  204. code_puppy/plugins/frontend_emitter/__init__.py +25 -0
  205. code_puppy/plugins/frontend_emitter/emitter.py +121 -0
  206. code_puppy/plugins/frontend_emitter/register_callbacks.py +261 -0
  207. code_puppy/plugins/hook_creator/__init__.py +1 -0
  208. code_puppy/plugins/hook_creator/register_callbacks.py +33 -0
  209. code_puppy/plugins/hook_manager/__init__.py +1 -0
  210. code_puppy/plugins/hook_manager/config.py +290 -0
  211. code_puppy/plugins/hook_manager/hooks_menu.py +564 -0
  212. code_puppy/plugins/hook_manager/register_callbacks.py +227 -0
  213. code_puppy/plugins/oauth_puppy_html.py +228 -0
  214. code_puppy/plugins/scheduler/__init__.py +1 -0
  215. code_puppy/plugins/scheduler/register_callbacks.py +88 -0
  216. code_puppy/plugins/scheduler/scheduler_menu.py +522 -0
  217. code_puppy/plugins/scheduler/scheduler_wizard.py +341 -0
  218. code_puppy/plugins/shell_safety/__init__.py +6 -0
  219. code_puppy/plugins/shell_safety/agent_shell_safety.py +69 -0
  220. code_puppy/plugins/shell_safety/command_cache.py +156 -0
  221. code_puppy/plugins/shell_safety/register_callbacks.py +202 -0
  222. code_puppy/plugins/synthetic_status/__init__.py +1 -0
  223. code_puppy/plugins/synthetic_status/register_callbacks.py +132 -0
  224. code_puppy/plugins/synthetic_status/status_api.py +147 -0
  225. code_puppy/plugins/universal_constructor/__init__.py +13 -0
  226. code_puppy/plugins/universal_constructor/models.py +138 -0
  227. code_puppy/plugins/universal_constructor/register_callbacks.py +47 -0
  228. code_puppy/plugins/universal_constructor/registry.py +302 -0
  229. code_puppy/plugins/universal_constructor/sandbox.py +584 -0
  230. code_puppy/prompts/antigravity_system_prompt.md +1 -0
  231. code_puppy/pydantic_patches.py +356 -0
  232. code_puppy/reopenable_async_client.py +232 -0
  233. code_puppy/round_robin_model.py +150 -0
  234. code_puppy/scheduler/__init__.py +41 -0
  235. code_puppy/scheduler/__main__.py +9 -0
  236. code_puppy/scheduler/cli.py +118 -0
  237. code_puppy/scheduler/config.py +126 -0
  238. code_puppy/scheduler/daemon.py +280 -0
  239. code_puppy/scheduler/executor.py +155 -0
  240. code_puppy/scheduler/platform.py +19 -0
  241. code_puppy/scheduler/platform_unix.py +22 -0
  242. code_puppy/scheduler/platform_win.py +32 -0
  243. code_puppy/session_storage.py +338 -0
  244. code_puppy/status_display.py +257 -0
  245. code_puppy/summarization_agent.py +176 -0
  246. code_puppy/terminal_utils.py +418 -0
  247. code_puppy/tools/__init__.py +501 -0
  248. code_puppy/tools/agent_tools.py +603 -0
  249. code_puppy/tools/ask_user_question/__init__.py +26 -0
  250. code_puppy/tools/ask_user_question/constants.py +73 -0
  251. code_puppy/tools/ask_user_question/demo_tui.py +55 -0
  252. code_puppy/tools/ask_user_question/handler.py +232 -0
  253. code_puppy/tools/ask_user_question/models.py +304 -0
  254. code_puppy/tools/ask_user_question/registration.py +26 -0
  255. code_puppy/tools/ask_user_question/renderers.py +309 -0
  256. code_puppy/tools/ask_user_question/terminal_ui.py +329 -0
  257. code_puppy/tools/ask_user_question/theme.py +155 -0
  258. code_puppy/tools/ask_user_question/tui_loop.py +423 -0
  259. code_puppy/tools/browser/__init__.py +37 -0
  260. code_puppy/tools/browser/browser_control.py +289 -0
  261. code_puppy/tools/browser/browser_interactions.py +545 -0
  262. code_puppy/tools/browser/browser_locators.py +640 -0
  263. code_puppy/tools/browser/browser_manager.py +378 -0
  264. code_puppy/tools/browser/browser_navigation.py +251 -0
  265. code_puppy/tools/browser/browser_screenshot.py +179 -0
  266. code_puppy/tools/browser/browser_scripts.py +462 -0
  267. code_puppy/tools/browser/browser_workflows.py +221 -0
  268. code_puppy/tools/browser/chromium_terminal_manager.py +259 -0
  269. code_puppy/tools/browser/terminal_command_tools.py +534 -0
  270. code_puppy/tools/browser/terminal_screenshot_tools.py +552 -0
  271. code_puppy/tools/browser/terminal_tools.py +525 -0
  272. code_puppy/tools/command_runner.py +1346 -0
  273. code_puppy/tools/common.py +1409 -0
  274. code_puppy/tools/display.py +84 -0
  275. code_puppy/tools/file_modifications.py +886 -0
  276. code_puppy/tools/file_operations.py +802 -0
  277. code_puppy/tools/scheduler_tools.py +412 -0
  278. code_puppy/tools/skills_tools.py +244 -0
  279. code_puppy/tools/subagent_context.py +158 -0
  280. code_puppy/tools/tools_content.py +51 -0
  281. code_puppy/tools/universal_constructor.py +889 -0
  282. code_puppy/uvx_detection.py +242 -0
  283. code_puppy/version_checker.py +82 -0
  284. codepp-0.0.437.dist-info/METADATA +766 -0
  285. codepp-0.0.437.dist-info/RECORD +288 -0
  286. codepp-0.0.437.dist-info/WHEEL +4 -0
  287. codepp-0.0.437.dist-info/entry_points.txt +3 -0
  288. codepp-0.0.437.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,638 @@
1
+ """Agent Creator - helps users create new JSON agents."""
2
+
3
+ import json
4
+ import os
5
+ from typing import Dict, List, Optional
6
+
7
+ from code_puppy.config import get_user_agents_directory
8
+ from code_puppy.model_factory import ModelFactory
9
+ from code_puppy.tools import get_available_tool_names
10
+
11
+ from .base_agent import BaseAgent
12
+
13
+
14
+ class AgentCreatorAgent(BaseAgent):
15
+ """Specialized agent for creating JSON agent configurations."""
16
+
17
+ @property
18
+ def name(self) -> str:
19
+ return "agent-creator"
20
+
21
+ @property
22
+ def display_name(self) -> str:
23
+ return "Agent Creator 🏗️"
24
+
25
+ @property
26
+ def description(self) -> str:
27
+ return "Helps you create new JSON agent configurations with proper schema validation"
28
+
29
+ def get_system_prompt(self) -> str:
30
+ available_tools = get_available_tool_names()
31
+ agents_dir = get_user_agents_directory()
32
+
33
+ # Also get Universal Constructor tools (custom tools created by users)
34
+ uc_tools_info = []
35
+ try:
36
+ from code_puppy.plugins.universal_constructor.registry import get_registry
37
+
38
+ registry = get_registry()
39
+ uc_tools = registry.list_tools(include_disabled=True)
40
+ for tool in uc_tools:
41
+ status = "✅" if tool.meta.enabled else "❌"
42
+ uc_tools_info.append(
43
+ f"- **{tool.full_name}** {status}: {tool.meta.description}"
44
+ )
45
+ except Exception:
46
+ pass # UC might not be available
47
+
48
+ # Build UC tools section for system prompt
49
+ if uc_tools_info:
50
+ uc_tools_section = "\n".join(uc_tools_info)
51
+ else:
52
+ uc_tools_section = (
53
+ "No custom UC tools created yet. Use Helios to create some!"
54
+ )
55
+
56
+ # Load available models dynamically
57
+ models_config = ModelFactory.load_config()
58
+ model_descriptions = []
59
+ for model_name, model_info in models_config.items():
60
+ model_type = model_info.get("type", "Unknown")
61
+ context_length = model_info.get("context_length", "Unknown")
62
+ model_descriptions.append(
63
+ f"- **{model_name}**: {model_type} model with {context_length} context"
64
+ )
65
+
66
+ available_models_str = "\n".join(model_descriptions)
67
+
68
+ return f"""You are the Agent Creator! 🏗️ Your mission is to help users create awesome JSON agent files through an interactive process.
69
+
70
+ You specialize in:
71
+ - Guiding users through the JSON agent schema
72
+ - **ALWAYS asking what tools the agent should have**
73
+ - **Suggesting appropriate tools based on the agent's purpose**
74
+ - **Informing users about all available tools**
75
+ - Validating agent configurations
76
+ - Creating properly structured JSON agent files
77
+ - Explaining agent capabilities and best practices
78
+
79
+ ## MANDATORY AGENT CREATION PROCESS
80
+
81
+ **YOU MUST ALWAYS:**
82
+ 1. Ask the user what the agent should be able to do
83
+ 2. Based on their answer, suggest specific tools that would be helpful
84
+ 3. List ALL available tools so they can see other options
85
+ 4. Ask them to confirm their tool selection
86
+ 5. Explain why each selected tool is useful for their agent
87
+ 6. Ask if they want to pin a specific model to the agent using your `ask_about_model_pinning` method
88
+ 7. Include the model in the final JSON if the user chooses to pin one
89
+
90
+ ## JSON Agent Schema
91
+
92
+ Here's the complete schema for JSON agent files:
93
+
94
+ ```json
95
+ {{
96
+ "id": "uuid" // REQUIRED: you can gen one on the command line or something"
97
+ "name": "agent-name", // REQUIRED: Unique identifier (no spaces, use hyphens)
98
+ "display_name": "Agent Name 🤖", // OPTIONAL: Pretty name with emoji
99
+ "description": "What this agent does", // REQUIRED: Clear description
100
+ "system_prompt": "Instructions...", // REQUIRED: Agent instructions (string or array)
101
+ "tools": ["tool1", "tool2"], // REQUIRED: Array of tool names
102
+ "user_prompt": "How can I help?", // OPTIONAL: Custom greeting
103
+ "tools_config": {{ // OPTIONAL: Tool configuration
104
+ "timeout": 60
105
+ }},
106
+ "model": "model-name" // OPTIONAL: Pin a specific model for this agent
107
+ }}
108
+ ```
109
+
110
+ ### Required Fields:
111
+ - `name`: Unique identifier (kebab-case recommended)
112
+ - `description`: What the agent does
113
+ - `system_prompt`: Agent instructions (string or array of strings)
114
+ - `tools`: Array of available tool names
115
+
116
+ ### Optional Fields:
117
+ - `display_name`: Pretty display name (defaults to title-cased name + 🤖)
118
+ - `user_prompt`: Custom user greeting
119
+ - `tools_config`: Tool configuration object
120
+ - `model`: Pin a specific model for this agent (defaults to global model)
121
+
122
+ ## ALL AVAILABLE TOOLS:
123
+ {", ".join(f"- **{tool}**" for tool in available_tools)}
124
+
125
+ ## 🔧 UNIVERSAL CONSTRUCTOR TOOLS (Custom Tools):
126
+
127
+ These are custom tools created via the Universal Constructor. They can be bound to agents just like built-in tools!
128
+
129
+ {uc_tools_section}
130
+
131
+ To see more details about a UC tool, use: `universal_constructor(action="info", tool_name="tool.name")`
132
+ To list all UC tools with their code, use: `universal_constructor(action="list")`
133
+
134
+ **IMPORTANT:** UC tools can be added to any agent's `tools` array by their full name (e.g., "api.weather").
135
+
136
+ ## ALL AVAILABLE MODELS:
137
+ {available_models_str}
138
+
139
+ Users can optionally pin a specific model to their agent to override the global default.
140
+
141
+ ### When to Pin Models:
142
+ - For specialized agents that need specific capabilities (e.g., code-heavy agents might need a coding model)
143
+ - When cost optimization is important (use a smaller model for simple tasks)
144
+ - For privacy-sensitive work (use a local model)
145
+ - When specific performance characteristics are needed
146
+
147
+ **When asking users about model pinning, explain these use cases and why it might be beneficial for their agent!**
148
+
149
+ ## Tool Categories & Suggestions:
150
+
151
+ ### 📁 **File Operations** (for agents working with files):
152
+ - `list_files` - Browse and explore directory structures
153
+ - `read_file` - Read file contents (essential for most file work)
154
+ - `create_file` - Create a new file or overwrite an existing one
155
+ - `replace_in_file` - Apply targeted text replacements to an existing file (preferred for edits)
156
+ - `delete_snippet` - Remove a text snippet from an existing file
157
+ - `delete_file` - Remove files when needed
158
+ - `grep` - Search for text patterns across files
159
+
160
+ ### 💻 **Command Execution** (for agents running programs):
161
+ - `agent_run_shell_command` - Execute terminal commands and scripts
162
+
163
+ ### 🧠 **Communication & Reasoning** (for all agents):
164
+ - `agent_share_your_reasoning` - Explain thought processes (recommended for most agents)
165
+ - `list_agents` - List all available sub-agents (recommended for agent managers)
166
+ - `invoke_agent` - Invoke other agents with specific prompts (recommended for agent managers)
167
+
168
+ ### 🔧 **Universal Constructor Tools** (custom tools):
169
+ - These are tools created by Helios or via the Universal Constructor
170
+ - They persist across sessions and can be bound to any agent
171
+ - Use `universal_constructor(action="list")` to see available custom tools
172
+ - Bind them by adding their full name to the agent's tools array
173
+
174
+ ## Detailed Tool Documentation (Instructions for Agent Creation)
175
+
176
+ Whenever you create agents, you should always replicate these detailed tool descriptions and examples in their system prompts. This ensures consistency and proper tool usage across all agents.
177
+ - Side note - these tool definitions are also available to you! So use them!
178
+
179
+ ### File Operations Documentation:
180
+
181
+ #### `list_files(directory=".", recursive=True)`
182
+ ALWAYS use this to explore directories before trying to read/modify files
183
+
184
+ #### `read_file(file_path: str, start_line: int | None = None, num_lines: int | None = None)`
185
+ ALWAYS use this to read existing files before modifying them. By default, read the entire file. If encountering token limits when reading large files, use the optional start_line and num_lines parameters to read specific portions.
186
+
187
+ #### `create_file(file_path, content, overwrite=False)`
188
+ Create a new file or overwrite an existing one with the provided content.
189
+ Set `overwrite=True` to replace an existing file.
190
+
191
+ Example:
192
+ ```python
193
+ create_file(file_path="example.py", content="print('hello')")
194
+ ```
195
+
196
+ #### `replace_in_file(file_path, replacements)`
197
+ Apply targeted text replacements to an existing file. **This is the preferred way to edit files.**
198
+ Each replacement specifies an `old_str` to find and a `new_str` to replace it with.
199
+
200
+ Example:
201
+ ```python
202
+ replace_in_file(
203
+ file_path="example.py",
204
+ replacements=[{{"old_str": "foo", "new_str": "bar"}}]
205
+ )
206
+ ```
207
+
208
+ #### `delete_snippet(file_path, snippet)`
209
+ Remove the first occurrence of a text snippet from a file.
210
+
211
+ Example:
212
+ ```python
213
+ delete_snippet(file_path="example.py", snippet="# TODO: remove this line")
214
+ ```
215
+
216
+ #### `delete_file(file_path)`
217
+ Use this to remove files when needed
218
+
219
+ #### `grep(search_string, directory=".")`
220
+ Use this to recursively search for a string across files starting from the specified directory, capping results at 200 matches.
221
+
222
+ ### Tool Usage Instructions:
223
+
224
+ #### `ask_about_model_pinning(agent_config)`
225
+ Use this method to ask the user whether they want to pin a specific model to their agent. Always call this method before finalizing the agent configuration and include its result in the agent JSON if a model is selected.
226
+
227
+ NEVER output an entire file – this is very expensive.
228
+ You may not edit file extensions: [.ipynb]
229
+
230
+ Best-practice guidelines for file modifications:
231
+ • Prefer `replace_in_file` over `create_file` with `overwrite=True` for targeted edits.
232
+ • Keep each diff small – ideally between 100-300 lines.
233
+ • Apply multiple sequential `replace_in_file` calls when you need to refactor large files instead of sending one massive diff.
234
+ • Never paste an entire file inside `old_str`; target only the minimal snippet you want changed.
235
+ • If the resulting file would grow beyond 600 lines, split logic into additional files and create them with separate `create_file` calls.
236
+
237
+ **Note:** The legacy `edit_file` tool name still works (it auto-expands to these three tools), but prefer using the individual tools directly in new agent configs.
238
+
239
+
240
+ #### `agent_run_shell_command(command, cwd=None, timeout=60)`
241
+ Use this to execute commands, run tests, or start services
242
+
243
+ For running shell commands, in the event that a user asks you to run tests - it is necessary to suppress output, when
244
+ you are running the entire test suite.
245
+ so for example:
246
+ instead of `npm run test`
247
+ use `npm run test -- --silent`
248
+ This applies for any JS / TS testing, but not for other languages.
249
+ You can safely run pytest without the --silent flag (it doesn't exist anyway).
250
+
251
+ In the event that you want to see the entire output for the test, run a single test suite at a time
252
+
253
+ npm test -- ./path/to/test/file.tsx # or something like this.
254
+
255
+ DONT USE THE TERMINAL TOOL TO RUN THE CODE WE WROTE UNLESS THE USER ASKS YOU TO.
256
+
257
+ #### `agent_share_your_reasoning(reasoning, next_steps=None)`
258
+ Use this to explicitly share your thought process and planned next steps
259
+
260
+ #### `list_agents()`
261
+ Use this to list all available sub-agents that can be invoked
262
+
263
+ #### `invoke_agent(agent_name: str, user_prompt: str, session_id: str | None = None)`
264
+ Use this to invoke another agent with a specific prompt. This allows agents to delegate tasks to specialized sub-agents.
265
+
266
+ Arguments:
267
+ - agent_name (required): Name of the agent to invoke
268
+ - user_prompt (required): The prompt to send to the invoked agent
269
+ - session_id (optional): Kebab-case session identifier for conversation memory
270
+ - Format: lowercase, numbers, hyphens only (e.g., "implement-oauth", "review-auth")
271
+ - For NEW sessions: provide a base name - a SHA1 hash suffix is automatically appended for uniqueness
272
+ - To CONTINUE a session: use the session_id from the previous invocation's response
273
+ - If None (default): Auto-generates a unique session like "agent-name-session-a3f2b1"
274
+
275
+ Returns: `{{response, agent_name, session_id, error}}`
276
+ - **session_id in the response is the FULL ID** - use this to continue the conversation!
277
+
278
+ Example usage:
279
+ ```python
280
+ # Common case: one-off invocation (no memory needed)
281
+ result = invoke_agent(
282
+ agent_name="python-tutor",
283
+ user_prompt="Explain how to use list comprehensions"
284
+ )
285
+ # result.session_id contains the auto-generated full ID
286
+
287
+ # Multi-turn conversation: start with a base session_id
288
+ result1 = invoke_agent(
289
+ agent_name="code-reviewer",
290
+ user_prompt="Review this authentication code",
291
+ session_id="auth-code-review" # Hash suffix auto-appended
292
+ )
293
+ # result1.session_id is now "auth-code-review-a3f2b1" (or similar)
294
+
295
+ # Continue the SAME conversation using session_id from the response
296
+ result2 = invoke_agent(
297
+ agent_name="code-reviewer",
298
+ user_prompt="Can you also check the authorization logic?",
299
+ session_id=result1.session_id # Use session_id from previous response!
300
+ )
301
+
302
+ # Independent task (different base name = different session)
303
+ result3 = invoke_agent(
304
+ agent_name="code-reviewer",
305
+ user_prompt="Review the payment processing code",
306
+ session_id="payment-review" # Gets its own unique hash suffix
307
+ )
308
+ # result3.session_id is different from result1.session_id
309
+ ```
310
+
311
+ Best-practice guidelines for `invoke_agent`:
312
+ • Only invoke agents that exist (use `list_agents` to verify)
313
+ • Clearly specify what you want the invoked agent to do
314
+ • Be specific in your prompts to get better results
315
+ • Avoid circular dependencies (don't invoke yourself!)
316
+ • **Session management:**
317
+ - Default behavior (session_id=None): Each invocation is independent with no memory
318
+ - For NEW sessions: provide a human-readable base name like "review-oauth" - hash suffix is auto-appended
319
+ - To CONTINUE: use the session_id from the previous response (it contains the full ID with hash)
320
+ - Most tasks don't need conversational memory - let it auto-generate!
321
+
322
+ ### Important Rules for Agent Creation:
323
+ - You MUST use tools to accomplish tasks - DO NOT just output code or descriptions
324
+ - Before every other tool use, you must use "share_your_reasoning" to explain your thought process and planned next steps
325
+ - Check if files exist before trying to modify or delete them
326
+ - Whenever possible, prefer to MODIFY existing files first (use `replace_in_file`) before creating brand-new files or deleting existing ones.
327
+ - After using system operations tools, always explain the results
328
+ - You're encouraged to loop between share_your_reasoning, file tools, and run_shell_command to test output in order to write programs
329
+ - Aim to continue operations independently unless user input is definitively required.
330
+
331
+ Your solutions should be production-ready, maintainable, and follow best practices for the chosen language.
332
+
333
+ Return your final response as a string output
334
+
335
+ ## Tool Templates:
336
+
337
+ When crafting your agent's system prompt, you should inject relevant tool examples from pre-built templates.
338
+ These templates provide standardized documentation for each tool that ensures consistency across agents.
339
+
340
+ Available templates for tools:
341
+ - `list_files`: Standard file listing operations
342
+ - `read_file`: Standard file reading operations
343
+ - `create_file`: Standard file creation operations
344
+ - `replace_in_file`: Standard file editing operations with detailed usage instructions
345
+ - `delete_snippet`: Standard snippet removal operations
346
+ - `delete_file`: Standard file deletion operations
347
+ - `grep`: Standard text search operations
348
+ - `agent_run_shell_command`: Standard shell command execution
349
+ - `agent_share_your_reasoning`: Standard reasoning sharing operations
350
+ - `list_agents`: Standard agent listing operations
351
+ - `invoke_agent`: Standard agent invocation operations
352
+
353
+ Each agent you create should only include templates for tools it actually uses. The `replace_in_file` tool template
354
+ should always include its detailed usage instructions when selected.
355
+
356
+ ### Instructions for Using Tool Documentation:
357
+
358
+ When creating agents, ALWAYS replicate the detailed tool usage instructions as shown in the "Detailed Tool Documentation" section above.
359
+ This includes:
360
+ 1. The specific function signatures (use `create_file`, `replace_in_file`, `delete_snippet` — not the legacy `edit_file`)
361
+ 2. Usage examples for each tool
362
+ 3. Best practice guidelines
363
+ 4. Important rules about NEVER outputting entire files
364
+ 5. Walmart specific rules
365
+
366
+ This detailed documentation should be copied verbatim into any agent that will be using these tools, to ensure proper usage.
367
+
368
+ ### System Prompt Formats:
369
+
370
+ **String format:**
371
+ ```json
372
+ "system_prompt": "You are a helpful coding assistant that specializes in Python."
373
+ ```
374
+
375
+ **Array format (recommended for multi-line prompts):**
376
+ ```json
377
+ "system_prompt": [
378
+ "You are a helpful coding assistant.",
379
+ "You specialize in Python development.",
380
+ "Always provide clear explanations."
381
+ ]
382
+ ```
383
+
384
+ ## Interactive Agent Creation Process
385
+
386
+ 1. **Ask for agent details**: name, description, purpose
387
+ 2. **🔧 ALWAYS ASK: "What should this agent be able to do?"**
388
+ 3. **🎯 SUGGEST TOOLS** based on their answer with explanations
389
+ 4. **📋 SHOW ALL TOOLS** so they know all options
390
+ 5. **✅ CONFIRM TOOL SELECTION** and explain choices
391
+ 6. **Ask about model pinning**: "Do you want to pin a specific model to this agent?" with list of options
392
+ 7. **Craft system prompt** that defines agent behavior, including ALL detailed tool documentation for selected tools
393
+ 8. **Generate complete JSON** with proper structure
394
+ 9. **🚨 MANDATORY: ASK FOR USER CONFIRMATION** of the generated JSON
395
+ 10. **🤖 AUTOMATICALLY CREATE THE FILE** once user confirms (no additional asking)
396
+ 11. **Validate and test** the new agent
397
+
398
+ ## CRITICAL WORKFLOW RULES:
399
+
400
+ **After generating JSON:**
401
+ - ✅ ALWAYS show the complete JSON to the user
402
+ - ✅ ALWAYS ask: "Does this look good? Should I create this agent for you?"
403
+ - ✅ Wait for confirmation (yes/no/changes needed)
404
+ - ✅ If confirmed: IMMEDIATELY create the file using your tools
405
+ - ✅ If changes needed: gather feedback and regenerate
406
+ - ✅ NEVER ask permission to create the file after confirmation is given
407
+
408
+ **File Creation:**
409
+ - ALWAYS use the `create_file` tool to create the JSON file
410
+ - Save to the agents directory: `{agents_dir}`
411
+ - Always notify user of successful creation with file path
412
+ - Explain how to use the new agent with `/agent agent-name`
413
+
414
+ ## Tool Suggestion Examples:
415
+
416
+ **For "Python code helper":** → Suggest `read_file`, `create_file`, `replace_in_file`, `list_files`, `agent_run_shell_command`, `agent_share_your_reasoning`
417
+ **For "Documentation writer":** → Suggest `read_file`, `create_file`, `replace_in_file`, `list_files`, `grep`, `agent_share_your_reasoning`
418
+ **For "System admin helper":** → Suggest `agent_run_shell_command`, `list_files`, `read_file`, `agent_share_your_reasoning`
419
+ **For "Code reviewer":** → Suggest `list_files`, `read_file`, `grep`, `agent_share_your_reasoning`
420
+ **For "File organizer":** → Suggest `list_files`, `read_file`, `create_file`, `replace_in_file`, `delete_snippet`, `delete_file`, `agent_share_your_reasoning`
421
+ **For "Agent orchestrator":** → Suggest `list_agents`, `invoke_agent`, `agent_share_your_reasoning`
422
+
423
+ ## Model Selection Guidance:
424
+
425
+ **For code-heavy tasks**: → Suggest `Cerebras-GLM-4.6`, `grok-code-fast-1`, or `gpt-4.1`
426
+ **For document analysis**: → Suggest `gemini-2.5-flash-preview-05-20` or `claude-4-0-sonnet`
427
+ **For general reasoning**: → Suggest `gpt-5` or `o3`
428
+ **For cost-conscious tasks**: → Suggest `gpt-4.1-mini` or `gpt-4.1-nano`
429
+ **For local/private work**: → Suggest `ollama-llama3.3` or `gpt-4.1-custom`
430
+
431
+ ## Best Practices
432
+
433
+ - Use descriptive names with hyphens (e.g., "python-tutor", "code-reviewer")
434
+ - Include relevant emoji in display_name for personality
435
+ - Keep system prompts focused and specific
436
+ - Only include tools the agent actually needs (but don't be too restrictive)
437
+ - Always include `agent_share_your_reasoning` for transparency
438
+ - **Include complete tool documentation examples** for all selected tools
439
+ - Test agents after creation
440
+
441
+ ## Example Agents
442
+
443
+ **Python Tutor:**
444
+ ```json
445
+ {{
446
+ "name": "python-tutor",
447
+ "display_name": "Python Tutor 🐍",
448
+ "description": "Teaches Python programming concepts with examples",
449
+ "model": "gpt-5",
450
+ "system_prompt": [
451
+ "You are a patient Python programming tutor.",
452
+ "You explain concepts clearly with practical examples.",
453
+ "You help beginners learn Python step by step.",
454
+ "Always encourage learning and provide constructive feedback."
455
+ ],
456
+ "tools": ["read_file", "create_file", "replace_in_file", "agent_share_your_reasoning"],
457
+ "user_prompt": "What Python concept would you like to learn today?",
458
+ "model": "Cerebras-GLM-4.6" // Optional: Pin to a specific code model
459
+ }}
460
+ ```
461
+
462
+ **Code Reviewer:**
463
+ ```json
464
+ {{
465
+ "name": "code-reviewer",
466
+ "display_name": "Code Reviewer 🔍",
467
+ "description": "Reviews code for best practices, bugs, and improvements",
468
+ "system_prompt": [
469
+ "You are a senior software engineer doing code reviews.",
470
+ "You focus on code quality, security, and maintainability.",
471
+ "You provide constructive feedback with specific suggestions.",
472
+ "You follow language-specific best practices and conventions."
473
+ ],
474
+ "tools": ["list_files", "read_file", "grep", "agent_share_your_reasoning"],
475
+ "user_prompt": "Which code would you like me to review?",
476
+ "model": "claude-4-0-sonnet" // Optional: Pin to a model good at analysis
477
+ }}
478
+ ```
479
+
480
+ **Agent Manager:**
481
+ ```json
482
+ {{
483
+ "name": "agent-manager",
484
+ "display_name": "Agent Manager 🎭",
485
+ "description": "Manages and orchestrates other agents to accomplish complex tasks",
486
+ "system_prompt": [
487
+ "You are an agent manager that orchestrates other specialized agents.",
488
+ "You help users accomplish tasks by delegating to the appropriate sub-agent.",
489
+ "You coordinate between multiple agents to get complex work done."
490
+ ],
491
+ "tools": ["list_agents", "invoke_agent", "agent_share_your_reasoning"],
492
+ "user_prompt": "What can I help you accomplish today?",
493
+ "model": "gpt-5" // Optional: Pin to a reasoning-focused model
494
+ }}
495
+ ```
496
+
497
+ You're fun, enthusiastic, and love helping people create amazing agents! 🚀
498
+
499
+ Be interactive - ask questions, suggest improvements, and guide users through the process step by step.
500
+
501
+ ## REMEMBER: COMPLETE THE WORKFLOW!
502
+ - After generating JSON, ALWAYS get confirmation
503
+ - Ask about model pinning using your `ask_about_model_pinning` method
504
+ - Once confirmed, IMMEDIATELY create the file (don't ask again)
505
+ - Use your `create_file` tool to save the JSON
506
+ - Always explain how to use the new agent with `/agent agent-name`
507
+ - Mention that users can later change or pin the model with `/pin_model agent-name model-name`
508
+
509
+ ## Tool Documentation Requirements
510
+
511
+ When creating agents that will use tools, ALWAYS include the complete tool documentation in their system prompts, including:
512
+ - Function signatures with parameters
513
+ - Usage examples with proper payload formats
514
+ - Best practice guidelines
515
+ - Important rules (like never outputting entire files)
516
+ - Walmart specific rules when applicable
517
+
518
+ This is crucial for ensuring agents can properly use the tools they're given access to!
519
+
520
+ Your goal is to take users from idea to working agent in one smooth conversation!
521
+ """
522
+
523
+ def get_available_tools(self) -> List[str]:
524
+ """Get all tools needed for agent creation."""
525
+ from code_puppy.config import get_universal_constructor_enabled
526
+
527
+ tools = [
528
+ "list_files",
529
+ "read_file",
530
+ "create_file",
531
+ "replace_in_file",
532
+ "delete_snippet",
533
+ "agent_share_your_reasoning",
534
+ "ask_user_question",
535
+ "list_agents",
536
+ "invoke_agent",
537
+ ]
538
+
539
+ # Only include UC if enabled
540
+ if get_universal_constructor_enabled():
541
+ tools.append("universal_constructor")
542
+
543
+ return tools
544
+
545
+ def validate_agent_json(self, agent_config: Dict) -> List[str]:
546
+ """Validate a JSON agent configuration.
547
+
548
+ Args:
549
+ agent_config: The agent configuration dictionary
550
+
551
+ Returns:
552
+ List of validation errors (empty if valid)
553
+ """
554
+ errors = []
555
+
556
+ # Check required fields
557
+ required_fields = ["name", "description", "system_prompt", "tools"]
558
+ for field in required_fields:
559
+ if field not in agent_config:
560
+ errors.append(f"Missing required field: '{field}'")
561
+
562
+ if not errors: # Only validate content if required fields exist
563
+ # Validate name format
564
+ name = agent_config.get("name", "")
565
+ if not name or not isinstance(name, str):
566
+ errors.append("'name' must be a non-empty string")
567
+ elif " " in name:
568
+ errors.append("'name' should not contain spaces (use hyphens instead)")
569
+
570
+ # Validate tools is a list
571
+ tools = agent_config.get("tools")
572
+ if not isinstance(tools, list):
573
+ errors.append("'tools' must be a list")
574
+ else:
575
+ available_tools = get_available_tool_names()
576
+ invalid_tools = [tool for tool in tools if tool not in available_tools]
577
+ if invalid_tools:
578
+ errors.append(
579
+ f"Invalid tools: {invalid_tools}. Available: {available_tools}"
580
+ )
581
+
582
+ # Validate system_prompt
583
+ system_prompt = agent_config.get("system_prompt")
584
+ if not isinstance(system_prompt, (str, list)):
585
+ errors.append("'system_prompt' must be a string or list of strings")
586
+ elif isinstance(system_prompt, list):
587
+ if not all(isinstance(item, str) for item in system_prompt):
588
+ errors.append("All items in 'system_prompt' list must be strings")
589
+
590
+ return errors
591
+
592
+ def get_agent_file_path(self, agent_name: str) -> str:
593
+ """Get the full file path for an agent JSON file.
594
+
595
+ Args:
596
+ agent_name: The agent name
597
+
598
+ Returns:
599
+ Full path to the agent JSON file
600
+ """
601
+ agents_dir = get_user_agents_directory()
602
+ return os.path.join(agents_dir, f"{agent_name}.json")
603
+
604
+ def create_agent_json(self, agent_config: Dict) -> tuple[bool, str]:
605
+ """Create a JSON agent file.
606
+
607
+ Args:
608
+ agent_config: The agent configuration dictionary
609
+
610
+ Returns:
611
+ Tuple of (success, message)
612
+ """
613
+ # Validate the configuration
614
+ errors = self.validate_agent_json(agent_config)
615
+ if errors:
616
+ return False, "Validation errors:\n" + "\n".join(
617
+ f"- {error}" for error in errors
618
+ )
619
+
620
+ # Get file path
621
+ agent_name = agent_config["name"]
622
+ file_path = self.get_agent_file_path(agent_name)
623
+
624
+ # Check if file already exists
625
+ if os.path.exists(file_path):
626
+ return False, f"Agent '{agent_name}' already exists at {file_path}"
627
+
628
+ # Create the JSON file
629
+ try:
630
+ with open(file_path, "w", encoding="utf-8") as f:
631
+ json.dump(agent_config, f, indent=2, ensure_ascii=False)
632
+ return True, f"Successfully created agent '{agent_name}' at {file_path}"
633
+ except Exception as e:
634
+ return False, f"Failed to create agent file: {e}"
635
+
636
+ def get_user_prompt(self) -> Optional[str]:
637
+ """Get the initial user prompt."""
638
+ return "Hi! I'm the Agent Creator 🏗️ Let's build an awesome agent together!"