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