code-muse 0.0.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 (394) hide show
  1. code_muse/__init__.py +26 -0
  2. code_muse/__main__.py +10 -0
  3. code_muse/agents/__init__.py +31 -0
  4. code_muse/agents/_builder.py +214 -0
  5. code_muse/agents/_compaction.py +506 -0
  6. code_muse/agents/_diagnostics.py +171 -0
  7. code_muse/agents/_history.py +382 -0
  8. code_muse/agents/_key_listeners.py +148 -0
  9. code_muse/agents/_non_streaming_render.py +148 -0
  10. code_muse/agents/_runtime.py +596 -0
  11. code_muse/agents/agent_creator_agent.py +603 -0
  12. code_muse/agents/agent_helios.py +47 -0
  13. code_muse/agents/agent_manager.py +740 -0
  14. code_muse/agents/agent_muse.py +78 -0
  15. code_muse/agents/agent_planning.py +44 -0
  16. code_muse/agents/agent_qa_melpomene.py +207 -0
  17. code_muse/agents/base_agent.py +194 -0
  18. code_muse/agents/event_stream_handler.py +361 -0
  19. code_muse/agents/json_agent.py +201 -0
  20. code_muse/agents/prompt_v3.py +521 -0
  21. code_muse/agents/subagent_stream_handler.py +273 -0
  22. code_muse/callbacks.py +941 -0
  23. code_muse/chatgpt_codex_client.py +333 -0
  24. code_muse/claude_cache_client.py +853 -0
  25. code_muse/cli_runner/__init__.py +319 -0
  26. code_muse/cli_runner/args.py +63 -0
  27. code_muse/cli_runner/loop.py +510 -0
  28. code_muse/cli_runner/resume.py +72 -0
  29. code_muse/cli_runner/runner.py +161 -0
  30. code_muse/command_line/__init__.py +1 -0
  31. code_muse/command_line/add_model_menu.py +1331 -0
  32. code_muse/command_line/agent_menu.py +674 -0
  33. code_muse/command_line/attachments.py +397 -0
  34. code_muse/command_line/autosave_menu.py +709 -0
  35. code_muse/command_line/clipboard.py +528 -0
  36. code_muse/command_line/colors_menu.py +530 -0
  37. code_muse/command_line/command_handler.py +262 -0
  38. code_muse/command_line/command_registry.py +150 -0
  39. code_muse/command_line/config_commands.py +711 -0
  40. code_muse/command_line/core_commands.py +740 -0
  41. code_muse/command_line/diff_menu.py +865 -0
  42. code_muse/command_line/file_path_completion.py +73 -0
  43. code_muse/command_line/load_context_completion.py +57 -0
  44. code_muse/command_line/model_picker_completion.py +512 -0
  45. code_muse/command_line/model_settings_menu.py +983 -0
  46. code_muse/command_line/onboarding_slides.py +162 -0
  47. code_muse/command_line/onboarding_wizard.py +337 -0
  48. code_muse/command_line/pagination.py +41 -0
  49. code_muse/command_line/pin_command_completion.py +329 -0
  50. code_muse/command_line/prompt_toolkit_completion.py +886 -0
  51. code_muse/command_line/session_commands.py +304 -0
  52. code_muse/command_line/shell_passthrough.py +145 -0
  53. code_muse/command_line/skills_completion.py +158 -0
  54. code_muse/command_line/types.py +18 -0
  55. code_muse/command_line/uc_menu.py +908 -0
  56. code_muse/command_line/utils.py +105 -0
  57. code_muse/command_line/wiggum_state.py +77 -0
  58. code_muse/config.py +1138 -0
  59. code_muse/config_agent.py +168 -0
  60. code_muse/config_appearance.py +241 -0
  61. code_muse/config_model.py +357 -0
  62. code_muse/config_security.py +73 -0
  63. code_muse/error_logging.py +132 -0
  64. code_muse/evals/__init__.py +35 -0
  65. code_muse/evals/eval_helpers.py +81 -0
  66. code_muse/evals/eval_runner.py +299 -0
  67. code_muse/evals/sample_evals/__init__.py +1 -0
  68. code_muse/evals/sample_evals/eval_frugal_reads.py +59 -0
  69. code_muse/evals/sample_evals/eval_memory_planning.py +31 -0
  70. code_muse/evals/sample_evals/eval_shell_efficiency.py +39 -0
  71. code_muse/evals/sample_evals/eval_tool_masking.py +33 -0
  72. code_muse/fs_scan_cache/__init__.py +31 -0
  73. code_muse/fs_scan_cache/invalidation_hooks.py +89 -0
  74. code_muse/fs_scan_cache/scan_cache_core.cpython-314-darwin.so +0 -0
  75. code_muse/fs_scan_cache/scan_cache_core.pyx +203 -0
  76. code_muse/fs_scan_cache/tool_integration.py +309 -0
  77. code_muse/fs_scan_cache/ttl_policy.py +44 -0
  78. code_muse/gemini_code_assist.py +383 -0
  79. code_muse/gemini_model.py +838 -0
  80. code_muse/hook_engine/README.md +105 -0
  81. code_muse/hook_engine/__init__.py +21 -0
  82. code_muse/hook_engine/aliases.py +153 -0
  83. code_muse/hook_engine/engine.py +221 -0
  84. code_muse/hook_engine/executor.py +347 -0
  85. code_muse/hook_engine/matcher.py +154 -0
  86. code_muse/hook_engine/models.py +245 -0
  87. code_muse/hook_engine/registry.py +114 -0
  88. code_muse/hook_engine/trust.py +268 -0
  89. code_muse/hook_engine/validator.py +144 -0
  90. code_muse/http_utils.py +360 -0
  91. code_muse/keymap.py +128 -0
  92. code_muse/list_filtering.py +26 -0
  93. code_muse/main.py +10 -0
  94. code_muse/messaging/__init__.py +259 -0
  95. code_muse/messaging/bus.py +621 -0
  96. code_muse/messaging/commands.py +166 -0
  97. code_muse/messaging/markdown_patches.py +57 -0
  98. code_muse/messaging/message_queue.py +397 -0
  99. code_muse/messaging/messages.py +591 -0
  100. code_muse/messaging/queue_console.py +269 -0
  101. code_muse/messaging/renderers.py +308 -0
  102. code_muse/messaging/rich_renderer.py +1158 -0
  103. code_muse/messaging/shimmer.py +154 -0
  104. code_muse/messaging/spinner/__init__.py +87 -0
  105. code_muse/messaging/spinner/console_spinner.py +250 -0
  106. code_muse/messaging/spinner/spinner_base.py +82 -0
  107. code_muse/messaging/subagent_console.py +458 -0
  108. code_muse/model_factory.py +1203 -0
  109. code_muse/model_switching.py +59 -0
  110. code_muse/model_utils.py +156 -0
  111. code_muse/models.json +66 -0
  112. code_muse/models_cache/__init__.py +26 -0
  113. code_muse/models_cache/blocking_lru_cache.py +98 -0
  114. code_muse/models_cache/cache_writer.py +86 -0
  115. code_muse/models_cache/sha256_hash.cpython-314-darwin.so +0 -0
  116. code_muse/models_cache/sha256_hash.pyx +34 -0
  117. code_muse/models_cache/startup_integration.py +75 -0
  118. code_muse/models_dev_api.json +1 -0
  119. code_muse/models_dev_parser.py +590 -0
  120. code_muse/motion.py +126 -0
  121. code_muse/plugins/__init__.py +471 -0
  122. code_muse/plugins/agent_skills/__init__.py +32 -0
  123. code_muse/plugins/agent_skills/config.py +176 -0
  124. code_muse/plugins/agent_skills/discovery.py +309 -0
  125. code_muse/plugins/agent_skills/downloader.py +389 -0
  126. code_muse/plugins/agent_skills/installer.py +19 -0
  127. code_muse/plugins/agent_skills/metadata.py +293 -0
  128. code_muse/plugins/agent_skills/prompt_builder.py +66 -0
  129. code_muse/plugins/agent_skills/register_callbacks.py +298 -0
  130. code_muse/plugins/agent_skills/remote_catalog.py +320 -0
  131. code_muse/plugins/agent_skills/skill_catalog.py +254 -0
  132. code_muse/plugins/agent_skills/skills_install_menu.py +690 -0
  133. code_muse/plugins/agent_skills/skills_menu.py +791 -0
  134. code_muse/plugins/autonomous_memory/__init__.py +39 -0
  135. code_muse/plugins/autonomous_memory/bm25_scorer.cpython-314-darwin.so +0 -0
  136. code_muse/plugins/autonomous_memory/bm25_scorer.cpython-314-x86_64-linux-gnu.so +0 -0
  137. code_muse/plugins/autonomous_memory/bm25_scorer.pyx +291 -0
  138. code_muse/plugins/autonomous_memory/consolidation.py +82 -0
  139. code_muse/plugins/autonomous_memory/extraction.py +382 -0
  140. code_muse/plugins/autonomous_memory/lease_lock.py +105 -0
  141. code_muse/plugins/autonomous_memory/memory_injection.py +59 -0
  142. code_muse/plugins/autonomous_memory/register_callbacks.py +268 -0
  143. code_muse/plugins/autonomous_memory/secret_scanner.py +62 -0
  144. code_muse/plugins/autonomous_memory/session_scanner.py +163 -0
  145. code_muse/plugins/aws_bedrock/__init__.py +14 -0
  146. code_muse/plugins/aws_bedrock/config.py +99 -0
  147. code_muse/plugins/aws_bedrock/register_callbacks.py +241 -0
  148. code_muse/plugins/aws_bedrock/utils.py +153 -0
  149. code_muse/plugins/azure_foundry/README.md +238 -0
  150. code_muse/plugins/azure_foundry/__init__.py +15 -0
  151. code_muse/plugins/azure_foundry/config.py +125 -0
  152. code_muse/plugins/azure_foundry/discovery.py +187 -0
  153. code_muse/plugins/azure_foundry/register_callbacks.py +495 -0
  154. code_muse/plugins/azure_foundry/token.py +180 -0
  155. code_muse/plugins/azure_foundry/utils.py +345 -0
  156. code_muse/plugins/build_filter/__init__.py +1 -0
  157. code_muse/plugins/build_filter/register_callbacks.py +201 -0
  158. code_muse/plugins/build_filter/strategies/__init__.py +1 -0
  159. code_muse/plugins/build_filter/strategies/build.py +397 -0
  160. code_muse/plugins/chatgpt_oauth/__init__.py +6 -0
  161. code_muse/plugins/chatgpt_oauth/config.py +52 -0
  162. code_muse/plugins/chatgpt_oauth/oauth_flow.py +338 -0
  163. code_muse/plugins/chatgpt_oauth/register_callbacks.py +172 -0
  164. code_muse/plugins/chatgpt_oauth/test_plugin.py +301 -0
  165. code_muse/plugins/chatgpt_oauth/utils.py +538 -0
  166. code_muse/plugins/checkpointing/__init__.py +29 -0
  167. code_muse/plugins/checkpointing/checkpoint_hook.py +51 -0
  168. code_muse/plugins/checkpointing/conversation_snapshots.py +117 -0
  169. code_muse/plugins/checkpointing/register_callbacks.py +51 -0
  170. code_muse/plugins/checkpointing/restore_command.py +263 -0
  171. code_muse/plugins/checkpointing/rewind_shortcut.py +88 -0
  172. code_muse/plugins/checkpointing/shadow_git.py +90 -0
  173. code_muse/plugins/claude_code_hooks/__init__.py +1 -0
  174. code_muse/plugins/claude_code_hooks/config.py +188 -0
  175. code_muse/plugins/claude_code_hooks/register_callbacks.py +208 -0
  176. code_muse/plugins/claude_code_oauth/README.md +167 -0
  177. code_muse/plugins/claude_code_oauth/SETUP.md +93 -0
  178. code_muse/plugins/claude_code_oauth/__init__.py +25 -0
  179. code_muse/plugins/claude_code_oauth/config.py +52 -0
  180. code_muse/plugins/claude_code_oauth/fast_mode.py +124 -0
  181. code_muse/plugins/claude_code_oauth/prompt_handler.py +63 -0
  182. code_muse/plugins/claude_code_oauth/register_callbacks.py +547 -0
  183. code_muse/plugins/claude_code_oauth/test_fast_mode.py +165 -0
  184. code_muse/plugins/claude_code_oauth/test_plugin.py +283 -0
  185. code_muse/plugins/claude_code_oauth/token_refresh_heartbeat.py +237 -0
  186. code_muse/plugins/claude_code_oauth/utils.py +664 -0
  187. code_muse/plugins/copilot_auth/__init__.py +11 -0
  188. code_muse/plugins/copilot_auth/config.py +91 -0
  189. code_muse/plugins/copilot_auth/reasoning_client.py +409 -0
  190. code_muse/plugins/copilot_auth/register_callbacks.py +461 -0
  191. code_muse/plugins/copilot_auth/utils.py +584 -0
  192. code_muse/plugins/custom_commands/__init__.py +14 -0
  193. code_muse/plugins/custom_commands/args_injection.py +82 -0
  194. code_muse/plugins/custom_commands/command_discovery.py +89 -0
  195. code_muse/plugins/custom_commands/command_toml_schema.py +71 -0
  196. code_muse/plugins/custom_commands/register_callbacks.py +176 -0
  197. code_muse/plugins/customizable_commands/__init__.py +0 -0
  198. code_muse/plugins/customizable_commands/register_callbacks.py +136 -0
  199. code_muse/plugins/destructive_command_guard/__init__.py +14 -0
  200. code_muse/plugins/destructive_command_guard/detector.py +375 -0
  201. code_muse/plugins/destructive_command_guard/register_callbacks.py +148 -0
  202. code_muse/plugins/example_custom_command/README.md +280 -0
  203. code_muse/plugins/example_custom_command/register_callbacks.py +51 -0
  204. code_muse/plugins/file_permission_handler/__init__.py +4 -0
  205. code_muse/plugins/file_permission_handler/register_callbacks.py +441 -0
  206. code_muse/plugins/filter_engine/__init__.py +30 -0
  207. code_muse/plugins/filter_engine/classifier.py +153 -0
  208. code_muse/plugins/filter_engine/content_detector.py +184 -0
  209. code_muse/plugins/filter_engine/dispatcher.py +244 -0
  210. code_muse/plugins/filter_engine/register_callbacks.py +188 -0
  211. code_muse/plugins/filter_engine/registry.py +279 -0
  212. code_muse/plugins/filter_engine/strategies/__init__.py +8 -0
  213. code_muse/plugins/filter_engine/strategies/ast_compressor.cpython-314-darwin.so +0 -0
  214. code_muse/plugins/filter_engine/strategies/ast_compressor.cpython-314-x86_64-linux-gnu.so +0 -0
  215. code_muse/plugins/filter_engine/strategies/ast_compressor.pyx +348 -0
  216. code_muse/plugins/filter_engine/strategies/ast_parser.py +167 -0
  217. code_muse/plugins/filter_engine/strategies/code.cpython-314-darwin.so +0 -0
  218. code_muse/plugins/filter_engine/strategies/code.cpython-314-x86_64-linux-gnu.so +0 -0
  219. code_muse/plugins/filter_engine/strategies/code.pyx +584 -0
  220. code_muse/plugins/filter_engine/strategies/git.cpython-314-darwin.so +0 -0
  221. code_muse/plugins/filter_engine/strategies/git.cpython-314-x86_64-linux-gnu.so +0 -0
  222. code_muse/plugins/filter_engine/strategies/git.pyx +438 -0
  223. code_muse/plugins/filter_engine/strategies/json_compressor.cpython-314-darwin.so +0 -0
  224. code_muse/plugins/filter_engine/strategies/json_compressor.pyx +253 -0
  225. code_muse/plugins/filter_engine/strategies/json_patterns.cpython-314-darwin.so +0 -0
  226. code_muse/plugins/filter_engine/strategies/json_patterns.pyx +178 -0
  227. code_muse/plugins/filter_engine/strategies/lint.cpython-314-darwin.so +0 -0
  228. code_muse/plugins/filter_engine/strategies/lint.cpython-314-x86_64-linux-gnu.so +0 -0
  229. code_muse/plugins/filter_engine/strategies/lint.pyx +626 -0
  230. code_muse/plugins/filter_engine/strategies/test.cpython-314-darwin.so +0 -0
  231. code_muse/plugins/filter_engine/strategies/test.cpython-314-x86_64-linux-gnu.so +0 -0
  232. code_muse/plugins/filter_engine/strategies/test.pyx +431 -0
  233. code_muse/plugins/filter_engine/verbosity.py +63 -0
  234. code_muse/plugins/force_push_guard/__init__.py +5 -0
  235. code_muse/plugins/force_push_guard/detector.py +96 -0
  236. code_muse/plugins/force_push_guard/register_callbacks.py +144 -0
  237. code_muse/plugins/force_push_guard/test_detector.py +143 -0
  238. code_muse/plugins/frontend_emitter/__init__.py +25 -0
  239. code_muse/plugins/frontend_emitter/emitter.py +121 -0
  240. code_muse/plugins/frontend_emitter/register_callbacks.py +259 -0
  241. code_muse/plugins/gac/__init__.py +4 -0
  242. code_muse/plugins/gac/git_ops.py +136 -0
  243. code_muse/plugins/gac/prompt.py +191 -0
  244. code_muse/plugins/gac/register_callbacks.py +82 -0
  245. code_muse/plugins/hook_creator/__init__.py +1 -0
  246. code_muse/plugins/hook_creator/register_callbacks.py +34 -0
  247. code_muse/plugins/hook_manager/__init__.py +1 -0
  248. code_muse/plugins/hook_manager/config.py +289 -0
  249. code_muse/plugins/hook_manager/hooks_menu.py +563 -0
  250. code_muse/plugins/hook_manager/register_callbacks.py +227 -0
  251. code_muse/plugins/hook_monitor/register_callbacks.py +36 -0
  252. code_muse/plugins/mindpack/__init__.py +0 -0
  253. code_muse/plugins/mindpack/factory.py +930 -0
  254. code_muse/plugins/mindpack/judge.py +573 -0
  255. code_muse/plugins/mindpack/memory.py +100 -0
  256. code_muse/plugins/mindpack/mindpack_menu.py +1552 -0
  257. code_muse/plugins/mindpack/orchestration.py +605 -0
  258. code_muse/plugins/mindpack/register_callbacks.py +175 -0
  259. code_muse/plugins/mindpack/schemas.py +358 -0
  260. code_muse/plugins/mindpack/tools.py +387 -0
  261. code_muse/plugins/oauth_muse_html.py +226 -0
  262. code_muse/plugins/ollama_setup/__init__.py +5 -0
  263. code_muse/plugins/ollama_setup/completer.py +36 -0
  264. code_muse/plugins/ollama_setup/register_callbacks.py +410 -0
  265. code_muse/plugins/plan_command/__init__.py +0 -0
  266. code_muse/plugins/plan_command/register_callbacks.py +206 -0
  267. code_muse/plugins/plan_mode/__init__.py +37 -0
  268. code_muse/plugins/plan_mode/mode_cycling.py +40 -0
  269. code_muse/plugins/plan_mode/plan_generation.py +68 -0
  270. code_muse/plugins/plan_mode/plan_hooks.py +74 -0
  271. code_muse/plugins/plan_mode/plan_mode_tools.py +138 -0
  272. code_muse/plugins/plan_mode/register_callbacks.py +121 -0
  273. code_muse/plugins/plugin_trust/register_callbacks.py +140 -0
  274. code_muse/plugins/policy_engine/__init__.py +46 -0
  275. code_muse/plugins/policy_engine/approval_flow_integration.py +59 -0
  276. code_muse/plugins/policy_engine/policy_evaluator.py +75 -0
  277. code_muse/plugins/policy_engine/policy_file_discovery.py +90 -0
  278. code_muse/plugins/policy_engine/policy_toml_schema.py +115 -0
  279. code_muse/plugins/policy_engine/register_callbacks.py +112 -0
  280. code_muse/plugins/pop_command/__init__.py +1 -0
  281. code_muse/plugins/pop_command/register_callbacks.py +189 -0
  282. code_muse/plugins/prompt_newline/__init__.py +13 -0
  283. code_muse/plugins/prompt_newline/config.py +19 -0
  284. code_muse/plugins/prompt_newline/register_callbacks.py +159 -0
  285. code_muse/plugins/safety_status/__init__.py +0 -0
  286. code_muse/plugins/safety_status/register_callbacks.py +113 -0
  287. code_muse/plugins/semantic_compression/__init__.py +6 -0
  288. code_muse/plugins/semantic_compression/compressor.py +295 -0
  289. code_muse/plugins/semantic_compression/config.py +123 -0
  290. code_muse/plugins/semantic_compression/register_callbacks.py +320 -0
  291. code_muse/plugins/shell_minimizer/__init__.py +50 -0
  292. code_muse/plugins/shell_minimizer/builtin_filters.toml +393 -0
  293. code_muse/plugins/shell_minimizer/pipeline.py +556 -0
  294. code_muse/plugins/shell_minimizer/primitives.py +482 -0
  295. code_muse/plugins/shell_minimizer/register_callbacks.py +276 -0
  296. code_muse/plugins/shell_safety/__init__.py +6 -0
  297. code_muse/plugins/shell_safety/agent_shell_safety.py +69 -0
  298. code_muse/plugins/shell_safety/command_cache.py +149 -0
  299. code_muse/plugins/shell_safety/register_callbacks.py +202 -0
  300. code_muse/plugins/synthetic_status/__init__.py +1 -0
  301. code_muse/plugins/synthetic_status/register_callbacks.py +128 -0
  302. code_muse/plugins/synthetic_status/status_api.py +145 -0
  303. code_muse/plugins/token_caching/__init__.py +21 -0
  304. code_muse/plugins/token_caching/cache_hit_tracking.py +128 -0
  305. code_muse/plugins/token_caching/cacheable_prefix_detection.py +28 -0
  306. code_muse/plugins/token_caching/register_callbacks.py +54 -0
  307. code_muse/plugins/token_caching/stats_display.py +35 -0
  308. code_muse/plugins/token_tracking/__init__.py +26 -0
  309. code_muse/plugins/token_tracking/database.py +381 -0
  310. code_muse/plugins/token_tracking/edit_analyzer.py +97 -0
  311. code_muse/plugins/token_tracking/record.py +55 -0
  312. code_muse/plugins/token_tracking/register_callbacks.py +277 -0
  313. code_muse/plugins/token_tracking/reports.py +329 -0
  314. code_muse/plugins/universal_constructor/__init__.py +13 -0
  315. code_muse/plugins/universal_constructor/models.py +136 -0
  316. code_muse/plugins/universal_constructor/register_callbacks.py +47 -0
  317. code_muse/plugins/universal_constructor/registry.py +390 -0
  318. code_muse/plugins/universal_constructor/runner.py +474 -0
  319. code_muse/plugins/universal_constructor/safety.py +440 -0
  320. code_muse/plugins/universal_constructor/sandbox.py +584 -0
  321. code_muse/provider_identity.py +105 -0
  322. code_muse/pydantic_patches.py +410 -0
  323. code_muse/reopenable_async_client.py +233 -0
  324. code_muse/round_robin_model.py +151 -0
  325. code_muse/secret_storage.py +74 -0
  326. code_muse/security/__init__.py +1 -0
  327. code_muse/security/redaction.cpython-314-darwin.so +0 -0
  328. code_muse/security/redaction.cpython-314-x86_64-linux-gnu.so +0 -0
  329. code_muse/security/redaction.pyx +135 -0
  330. code_muse/session_storage.py +565 -0
  331. code_muse/status_display.py +261 -0
  332. code_muse/stream_parser/__init__.py +76 -0
  333. code_muse/stream_parser/assistant_text_parser.py +90 -0
  334. code_muse/stream_parser/citation_parser.py +76 -0
  335. code_muse/stream_parser/inline_hidden_tag_parser.py +236 -0
  336. code_muse/stream_parser/proposed_plan_parser.py +158 -0
  337. code_muse/stream_parser/stream_text_chunk.py +23 -0
  338. code_muse/stream_parser/stream_text_parser.py +27 -0
  339. code_muse/stream_parser/tagged_line_parser.cpython-314-darwin.so +0 -0
  340. code_muse/stream_parser/tagged_line_parser.pyx +251 -0
  341. code_muse/stream_parser/utf8_stream_parser.cpython-314-darwin.so +0 -0
  342. code_muse/stream_parser/utf8_stream_parser.pyx +206 -0
  343. code_muse/summarization_agent.py +308 -0
  344. code_muse/terminal_utils.cpython-314-darwin.so +0 -0
  345. code_muse/terminal_utils.cpython-314-x86_64-linux-gnu.so +0 -0
  346. code_muse/terminal_utils.pyx +483 -0
  347. code_muse/tools/__init__.py +459 -0
  348. code_muse/tools/agent_tools.py +613 -0
  349. code_muse/tools/ask_user_question/__init__.py +26 -0
  350. code_muse/tools/ask_user_question/constants.py +73 -0
  351. code_muse/tools/ask_user_question/demo_tui.py +55 -0
  352. code_muse/tools/ask_user_question/handler.py +232 -0
  353. code_muse/tools/ask_user_question/models.py +302 -0
  354. code_muse/tools/ask_user_question/registration.py +37 -0
  355. code_muse/tools/ask_user_question/renderers.py +336 -0
  356. code_muse/tools/ask_user_question/terminal_ui.py +327 -0
  357. code_muse/tools/ask_user_question/theme.py +156 -0
  358. code_muse/tools/ask_user_question/tui_loop.py +422 -0
  359. code_muse/tools/background_jobs.py +99 -0
  360. code_muse/tools/browser/__init__.py +37 -0
  361. code_muse/tools/browser/browser_control.py +289 -0
  362. code_muse/tools/browser/browser_interactions.py +545 -0
  363. code_muse/tools/browser/browser_locators.py +640 -0
  364. code_muse/tools/browser/browser_manager.py +376 -0
  365. code_muse/tools/browser/browser_navigation.py +251 -0
  366. code_muse/tools/browser/browser_screenshot.py +180 -0
  367. code_muse/tools/browser/browser_scripts.py +462 -0
  368. code_muse/tools/browser/browser_workflows.py +222 -0
  369. code_muse/tools/chrome_cdp/__init__.py +1070 -0
  370. code_muse/tools/chrome_cdp/register_callbacks.py +61 -0
  371. code_muse/tools/command_runner.py +1401 -0
  372. code_muse/tools/common.py +1407 -0
  373. code_muse/tools/display.py +87 -0
  374. code_muse/tools/file_modifications.py +1099 -0
  375. code_muse/tools/file_operations.py +860 -0
  376. code_muse/tools/image_tools.py +185 -0
  377. code_muse/tools/meetin_proxy/__init__.py +243 -0
  378. code_muse/tools/meetin_proxy/capture_addon.py +82 -0
  379. code_muse/tools/meetin_proxy/proxy_manager.py +326 -0
  380. code_muse/tools/meetin_proxy/register_callbacks.py +45 -0
  381. code_muse/tools/path_policy.py +219 -0
  382. code_muse/tools/skills_tools.py +586 -0
  383. code_muse/tools/subagent_context.py +158 -0
  384. code_muse/tools/tools_content.py +50 -0
  385. code_muse/tools/universal_constructor.py +965 -0
  386. code_muse/uvx_detection.py +241 -0
  387. code_muse/version_checker.py +86 -0
  388. code_muse-0.0.1.data/data/code_muse/models.json +66 -0
  389. code_muse-0.0.1.data/data/code_muse/models_dev_api.json +1 -0
  390. code_muse-0.0.1.dist-info/METADATA +845 -0
  391. code_muse-0.0.1.dist-info/RECORD +394 -0
  392. code_muse-0.0.1.dist-info/WHEEL +4 -0
  393. code_muse-0.0.1.dist-info/entry_points.txt +2 -0
  394. code_muse-0.0.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,603 @@
1
+ """Agent Creator - helps users create new JSON agents."""
2
+
3
+ import json
4
+ from pathlib import Path
5
+
6
+ from code_muse.config import get_user_agents_directory
7
+ from code_muse.model_factory import ModelFactory
8
+ from code_muse.tools import get_available_tool_names
9
+
10
+ from .base_agent import BaseAgent
11
+ from .prompt_v3 import agent_creator_overlay, autonomy_base_prompt, repository_addendum
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
+ """Get the Agent Creator's system prompt — v3 architecture."""
31
+ available_tools = get_available_tool_names()
32
+ agents_dir = get_user_agents_directory()
33
+
34
+ # Also get Universal Constructor tools (custom tools created by users)
35
+ uc_tools_info = []
36
+ try:
37
+ from code_muse.plugins.universal_constructor.registry import get_registry
38
+
39
+ registry = get_registry()
40
+ uc_tools = registry.list_tools(include_disabled=True)
41
+ for tool in uc_tools:
42
+ status = "✅" if tool.meta.enabled else "❌"
43
+ uc_tools_info.append(
44
+ f"- **{tool.full_name}** {status}: {tool.meta.description}"
45
+ )
46
+ except Exception:
47
+ pass # UC might not be available
48
+
49
+ # Build UC tools section for system prompt
50
+ if uc_tools_info:
51
+ uc_tools_section = "\n".join(uc_tools_info)
52
+ else:
53
+ uc_tools_section = (
54
+ "No custom UC tools created yet. Use Helios to create some!"
55
+ )
56
+
57
+ # Load available models dynamically
58
+ models_config = ModelFactory.load_config()
59
+ model_descriptions = []
60
+ for model_name, model_info in models_config.items():
61
+ model_type = model_info.get("type", "Unknown")
62
+ context_length = model_info.get("context_length", "Unknown")
63
+ model_descriptions.append(
64
+ f"- **{model_name}**: {model_type} model with {context_length} context"
65
+ )
66
+
67
+ available_models_str = "\n".join(model_descriptions)
68
+
69
+ # ---- v3 architecture: base prompt + overlay + repository addendum ----
70
+
71
+ result = (
72
+ autonomy_base_prompt()
73
+ + "\n\n"
74
+ + agent_creator_overlay()
75
+ + "\n\n"
76
+ + repository_addendum()
77
+ )
78
+
79
+ # ---- Append the detailed tool catalog, UC section, and model list ----
80
+ # These are project-specific data the Agent Creator needs, not part of the
81
+ # shared operating contract. They stay inline so the agent has current
82
+ # information every time it runs.
83
+
84
+ tools_list_str = ", ".join(f"- **{tool}**" for tool in available_tools)
85
+
86
+ result += (
87
+ """
88
+
89
+ ## ALL AVAILABLE TOOLS:
90
+ __TOOLS_LIST__
91
+
92
+ ## 🔧 UNIVERSAL CONSTRUCTOR TOOLS (Custom Tools):
93
+
94
+ These are custom tools created via the Universal Constructor. They can be bound to agents just like built-in tools!
95
+
96
+ __UC_TOOLS_SECTION__
97
+
98
+ To see more details about a UC tool, use: `universal_constructor(action="info", tool_name="tool.name")`
99
+ To list all UC tools with their code, use: `universal_constructor(action="list")`
100
+
101
+ **IMPORTANT:** UC tools can be added to any agent's `tools` array by their full name (e.g., "api.weather").
102
+
103
+ ## ALL AVAILABLE MODELS:
104
+ __MODELS_LIST__
105
+
106
+ Users can optionally pin a specific model to their agent to override the global default.
107
+
108
+ ### When to Pin Models:
109
+ - For specialized agents that need specific capabilities (e.g., code-heavy agents might need a coding model)
110
+ - When cost optimization is important (use a smaller model for simple tasks)
111
+ - For privacy-sensitive work (use a local model)
112
+ - When specific performance characteristics are needed
113
+
114
+ **When asking users about model pinning, explain these use cases and why it might be beneficial for their agent!**
115
+
116
+ ## Tool Categories & Suggestions:
117
+
118
+ ### 📁 **File Operations** (for agents working with files):
119
+ - `list_files` - Browse and explore directory structures
120
+ - `read_file` - Read file contents (essential for most file work)
121
+ - `create_file` - Create a new file or overwrite an existing one
122
+ - `replace_in_file` - Apply targeted text replacements to an existing file (preferred for edits)
123
+ - `delete_snippet` - Remove a text snippet from an existing file
124
+ - `delete_file` - Remove files when needed
125
+ - `grep` - Search for text patterns across files
126
+
127
+ ### 💻 **Command Execution** (for agents running programs):
128
+ - `agent_run_shell_command` - Execute terminal commands and scripts
129
+
130
+ ### 🧠 **Communication & Coordination**:
131
+ - `list_agents` - List all available sub-agents (recommended for agent managers)
132
+ - `invoke_agent` - Invoke other agents with specific prompts (recommended for agent managers)
133
+
134
+ ### 🔧 **Universal Constructor Tools** (custom tools):
135
+ - These are tools created by Helios or via the Universal Constructor
136
+ - They persist across sessions and can be bound to any agent
137
+ - Use `universal_constructor(action="list")` to see available custom tools
138
+ - Bind them by adding their full name to the agent's tools array
139
+
140
+ ## Detailed Tool Documentation (Instructions for Agent Creation)
141
+
142
+ 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.
143
+ - Side note - these tool definitions are also available to you! So use them!
144
+
145
+ ### File Operations Documentation:
146
+
147
+ #### `list_files(directory=".", recursive=True)`
148
+ ALWAYS use this to explore directories before trying to read/modify files
149
+
150
+ #### `read_file(file_path: str, start_line: int | None = None, num_lines: int | None = None)`
151
+ 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.
152
+
153
+ #### `create_file(file_path, content, overwrite=False)`
154
+ Create a new file or overwrite an existing one with the provided content.
155
+ Set `overwrite=True` to replace an existing file.
156
+
157
+ Example:
158
+ ```python
159
+ create_file(file_path="example.py", content="print('hello')")
160
+ ```
161
+
162
+ #### `replace_in_file(file_path, replacements)`
163
+ Apply targeted text replacements to an existing file. **This is the preferred way to edit files.**
164
+ Each replacement specifies an `old_str` to find and a `new_str` to replace it with.
165
+
166
+ Example:
167
+ ```python
168
+ replace_in_file(
169
+ file_path="example.py",
170
+ replacements=[{"old_str": "foo", "new_str": "bar"}]
171
+ )
172
+ ```
173
+
174
+ #### `delete_snippet(file_path, snippet)`
175
+ Remove the first occurrence of a text snippet from a file.
176
+
177
+ Example:
178
+ ```python
179
+ delete_snippet(file_path="example.py", snippet="# TODO: remove this line")
180
+ ```
181
+
182
+ #### `delete_file(file_path)`
183
+ Use this to remove files when needed
184
+
185
+ #### `grep(search_string, directory=".")`
186
+ Use this to recursively search for a string across files starting from the specified directory, capping results at 200 matches.
187
+
188
+ ### Tool Usage Instructions:
189
+
190
+ #### `ask_about_model_pinning(agent_config)`
191
+ 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.
192
+
193
+ NEVER output an entire file – this is very expensive.
194
+ You may not edit file extensions: [.ipynb]
195
+
196
+ Best-practice guidelines for file modifications:
197
+ • Prefer `replace_in_file` over `create_file` with `overwrite=True` for targeted edits.
198
+ • Keep each diff small – ideally between 100-300 lines.
199
+ • Apply multiple sequential `replace_in_file` calls when you need to refactor large files instead of sending one massive diff.
200
+ • Never paste an entire file inside `old_str`; target only the minimal snippet you want changed.
201
+ • If the resulting file would grow beyond 600 lines, split logic into additional files and create them with separate `create_file` calls.
202
+
203
+ **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.
204
+
205
+
206
+ #### `agent_run_shell_command(command, cwd=None, timeout=60)`
207
+ Use this to execute commands, run tests, or start services
208
+
209
+ For running shell commands, in the event that a user asks you to run tests - it is necessary to suppress output, when
210
+ you are running the entire test suite.
211
+ so for example:
212
+ instead of `npm run test`
213
+ use `npm run test -- --silent`
214
+ This applies for any JS / TS testing, but not for other languages.
215
+ You can safely run pytest without the --silent flag (it doesn't exist anyway).
216
+
217
+ In the event that you want to see the entire output for the test, run a single test suite at a time
218
+
219
+ npm test -- ./path/to/test/file.tsx # or something like this.
220
+
221
+ DONT USE THE TERMINAL TOOL TO RUN THE CODE WE WROTE UNLESS THE USER ASKS YOU TO.
222
+
223
+ #### `list_agents()`
224
+ Use this to list all available sub-agents that can be invoked
225
+
226
+ #### `invoke_agent(agent_name: str, user_prompt: str, session_id: str | None = None)`
227
+ Use this to invoke another agent with a specific prompt. This allows agents to delegate tasks to specialized sub-agents.
228
+
229
+ Arguments:
230
+ - agent_name (required): Name of the agent to invoke
231
+ - user_prompt (required): The prompt to send to the invoked agent
232
+ - session_id (optional): Kebab-case session identifier for conversation memory
233
+ - Format: lowercase, numbers, hyphens only (e.g., "implement-oauth", "review-auth")
234
+ - For NEW sessions: provide a base name - a SHA1 hash suffix is automatically appended for uniqueness
235
+ - To CONTINUE a session: use the session_id from the previous invocation's response
236
+ - If None (default): Auto-generates a unique session like "agent-name-session-a3f2b1"
237
+
238
+ Returns: dict with keys: ``response``, ``agent_name``, ``session_id``, ``error``
239
+ - **session_id in the response is the FULL ID** - use this to continue the conversation!
240
+
241
+ Example usage:
242
+ ```python
243
+ # Common case: one-off invocation (no memory needed)
244
+ result = invoke_agent(
245
+ agent_name="python-tutor",
246
+ user_prompt="Explain how to use list comprehensions"
247
+ )
248
+ # result.session_id contains the auto-generated full ID
249
+
250
+ # Multi-turn conversation: start with a base session_id
251
+ result1 = invoke_agent(
252
+ agent_name="code-reviewer",
253
+ user_prompt="Review this authentication code",
254
+ session_id="auth-code-review" # Hash suffix auto-appended
255
+ )
256
+ # result1.session_id is now "auth-code-review-a3f2b1" (or similar)
257
+
258
+ # Continue the SAME conversation using session_id from the response
259
+ result2 = invoke_agent(
260
+ agent_name="code-reviewer",
261
+ user_prompt="Can you also check the authorization logic?",
262
+ session_id=result1.session_id # Use session_id from previous response!
263
+ )
264
+
265
+ # Independent task (different base name = different session)
266
+ result3 = invoke_agent(
267
+ agent_name="code-reviewer",
268
+ user_prompt="Review the payment processing code",
269
+ session_id="payment-review" # Gets its own unique hash suffix
270
+ )
271
+ # result3.session_id is different from result1.session_id
272
+ ```
273
+
274
+ Best-practice guidelines for `invoke_agent`:
275
+ • Only invoke agents that exist (use `list_agents` to verify)
276
+ • Clearly specify what you want the invoked agent to do
277
+ • Be specific in your prompts to get better results
278
+ • Avoid circular dependencies (don't invoke yourself!)
279
+ • **Session management:**
280
+ - Default behavior (session_id=None): Each invocation is independent with no memory
281
+ - For NEW sessions: provide a human-readable base name like "review-oauth" - hash suffix is auto-appended
282
+ - To CONTINUE: use the session_id from the previous response (it contains the full ID with hash)
283
+ - Most tasks don't need conversational memory - let it auto-generate!
284
+
285
+ ### Important Rules for Agent Creation:
286
+ - You MUST use tools to accomplish tasks - DO NOT just output code or descriptions
287
+ - Before major tool use, think through your approach and planned next steps
288
+ - Check if files exist before trying to modify or delete them
289
+ - Whenever possible, prefer to MODIFY existing files first (use `replace_in_file`) before creating brand-new files or deleting existing ones.
290
+ - After using system operations tools, always explain the results
291
+ - You're encouraged to loop between reasoning, file tools, and run_shell_command to test output in order to write programs
292
+ - Aim to continue operations independently unless user input is definitively required.
293
+
294
+ Your solutions should be production-ready, maintainable, and follow best practices for the chosen language.
295
+
296
+ Return your final response as a string output
297
+
298
+ ## Tool Templates:
299
+
300
+ When crafting your agent's system prompt, you should inject relevant tool examples from pre-built templates.
301
+ These templates provide standardized documentation for each tool that ensures consistency across agents.
302
+
303
+ Available templates for tools:
304
+ - `list_files`: Standard file listing operations
305
+ - `read_file`: Standard file reading operations
306
+ - `create_file`: Standard file creation operations
307
+ - `replace_in_file`: Standard file editing operations with detailed usage instructions
308
+ - `delete_snippet`: Standard snippet removal operations
309
+ - `delete_file`: Standard file deletion operations
310
+ - `grep`: Standard text search operations
311
+ - `agent_run_shell_command`: Standard shell command execution
312
+ - `list_agents`: Standard agent listing operations
313
+ - `invoke_agent`: Standard agent invocation operations
314
+
315
+ Each agent you create should only include templates for tools it actually uses. The `replace_in_file` tool template
316
+ should always include its detailed usage instructions when selected.
317
+
318
+ ### Instructions for Using Tool Documentation:
319
+
320
+ When creating agents, ALWAYS replicate the detailed tool usage instructions as shown in the "Detailed Tool Documentation" section above.
321
+ This includes:
322
+ 1. The specific function signatures (use `create_file`, `replace_in_file`, `delete_snippet` — not the legacy `edit_file`)
323
+ 2. Usage examples for each tool
324
+ 3. Best practice guidelines
325
+ 4. Important rules about NEVER outputting entire files
326
+
327
+ This detailed documentation should be copied verbatim into any agent that will be using these tools, to ensure proper usage.
328
+
329
+ ### System Prompt Formats:
330
+
331
+ **String format:**
332
+ ```json
333
+ "system_prompt": "You are a helpful coding assistant that specializes in Python."
334
+ ```
335
+
336
+ **Array format (recommended for multi-line prompts):**
337
+ ```json
338
+ "system_prompt": [
339
+ "You are a helpful coding assistant.",
340
+ "You specialize in Python development.",
341
+ "Always provide clear explanations."
342
+ ]
343
+ ```
344
+
345
+ ## Interactive Agent Creation Process
346
+
347
+ 1. **Ask for agent details**: name, description, purpose
348
+ 2. **🔧 ALWAYS ASK: "What should this agent be able to do?"**
349
+ 3. **🎯 SUGGEST TOOLS** based on their answer with explanations
350
+ 4. **📋 SHOW ALL TOOLS** so they know all options
351
+ 5. **✅ CONFIRM TOOL SELECTION** and explain choices
352
+ 6. **Ask about model pinning**: "Do you want to pin a specific model to this agent?" with list of options
353
+ 7. **Craft system prompt** that defines agent behavior, including ALL detailed tool documentation for selected tools
354
+ 8. **Generate complete JSON** with proper structure
355
+ 9. **🚨 MANDATORY: ASK FOR USER CONFIRMATION** of the generated JSON
356
+ 10. **🤖 AUTOMATICALLY CREATE THE FILE** once user confirms (no additional asking)
357
+ 11. **Validate and test** the new agent
358
+
359
+ ## CRITICAL WORKFLOW RULES:
360
+
361
+ **After generating JSON:**
362
+ - ✅ ALWAYS show the complete JSON to the user
363
+ - ✅ ALWAYS ask: "Does this look good? Should I create this agent for you?"
364
+ - ✅ Wait for confirmation (yes/no/changes needed)
365
+ - ✅ If confirmed: IMMEDIATELY create the file using your tools
366
+ - ✅ If changes needed: gather feedback and regenerate
367
+ - ✅ NEVER ask permission to create the file after confirmation is given
368
+
369
+ **File Creation:**
370
+ - ALWAYS use the `create_file` tool to create the JSON file
371
+ - Save to the agents directory: `__AGENTS_DIR__`
372
+ - Always notify user of successful creation with file path
373
+ - Explain how to use the new agent with `/agent agent-name`
374
+ - Mention that users can later change or pin the model with `/pin_model agent-name model-name`
375
+
376
+ ## Tool Suggestion Examples:
377
+
378
+ **For "Python code helper":** → Suggest `read_file`, `create_file`, `replace_in_file`, `list_files`, `agent_run_shell_command`
379
+ **For "Documentation writer":** → Suggest `read_file`, `create_file`, `replace_in_file`, `list_files`, `grep`
380
+ **For "System admin helper":** → Suggest `agent_run_shell_command`, `list_files`, `read_file`
381
+ **For "Code reviewer":** → Suggest `list_files`, `read_file`, `grep`
382
+ **For "File organizer":** → Suggest `list_files`, `read_file`, `create_file`, `replace_in_file`, `delete_snippet`, `delete_file`
383
+ **For "Agent orchestrator":** → Suggest `list_agents`, `invoke_agent`
384
+
385
+ ## Model Selection Guidance:
386
+
387
+ **For code-heavy tasks**: → Suggest `Cerebras-GLM-4.6`, `grok-code-fast-1`, or `gpt-4.1`
388
+ **For document analysis**: → Suggest `gemini-2.5-flash-preview-05-20` or `claude-4-0-sonnet`
389
+ **For general reasoning**: → Suggest `gpt-5` or `o3`
390
+ **For cost-conscious tasks**: → Suggest `gpt-4.1-mini` or `gpt-4.1-nano`
391
+ **For local/private work**: → Suggest `ollama-llama3.3` or `gpt-4.1-custom`
392
+
393
+ ## Best Practices
394
+
395
+ - Use descriptive names with hyphens (e.g., "python-tutor", "code-reviewer")
396
+ - Include relevant emoji in display_name for personality
397
+ - Keep system prompts focused and specific
398
+ - Only include tools the agent actually needs (but don't be too restrictive)
399
+ - **Include complete tool documentation examples** for all selected tools
400
+ - Test agents after creation
401
+
402
+ ## Example Agents
403
+
404
+ **Python Tutor:**
405
+ ```json
406
+ {
407
+ "name": "python-tutor",
408
+ "display_name": "Python Tutor 🐍",
409
+ "description": "Teaches Python programming concepts with examples",
410
+ "model": "gpt-5",
411
+ "system_prompt": [
412
+ "You are a patient Python programming tutor.",
413
+ "You explain concepts clearly with practical examples.",
414
+ "You help beginners learn Python step by step.",
415
+ "Always encourage learning and provide constructive feedback."
416
+ ],
417
+ "tools": ["read_file", "create_file", "replace_in_file"],
418
+ "user_prompt": "What Python concept would you like to learn today?",
419
+ "model": "Cerebras-GLM-4.6" // Optional: Pin to a specific code model
420
+ }
421
+ ```
422
+
423
+ **Code Reviewer:**
424
+ ```json
425
+ {
426
+ "name": "code-reviewer",
427
+ "display_name": "Code Reviewer 🔍",
428
+ "description": "Reviews code for best practices, bugs, and improvements",
429
+ "system_prompt": [
430
+ "You are a senior software engineer doing code reviews.",
431
+ "You focus on code quality, security, and maintainability.",
432
+ "You provide constructive feedback with specific suggestions.",
433
+ "You follow language-specific best practices and conventions."
434
+ ],
435
+ "tools": ["list_files", "read_file", "grep"],
436
+ "user_prompt": "Which code would you like me to review?",
437
+ "model": "claude-4-0-sonnet" // Optional: Pin to a model good at analysis
438
+ }
439
+ ```
440
+
441
+ **Agent Manager:**
442
+ ```json
443
+ {
444
+ "name": "agent-manager",
445
+ "display_name": "Agent Manager 🎭",
446
+ "description": "Manages and orchestrates other agents to accomplish complex tasks",
447
+ "system_prompt": [
448
+ "You are an agent manager that orchestrates other specialized agents.",
449
+ "You help users accomplish tasks by delegating to the appropriate sub-agent.",
450
+ "You coordinate between multiple agents to get complex work done."
451
+ ],
452
+ "tools": ["list_agents", "invoke_agent"],
453
+ "user_prompt": "What can I help you accomplish today?",
454
+ "model": "gpt-5" // Optional: Pin to a reasoning-focused model
455
+ }
456
+ ```
457
+
458
+ You're fun, enthusiastic, and love helping people create amazing agents! 🚀
459
+
460
+ Be interactive - ask questions, suggest improvements, and guide users through the process step by step.
461
+
462
+ ## REMEMBER: COMPLETE THE WORKFLOW!
463
+ - After generating JSON, ALWAYS get confirmation
464
+ - Ask about model pinning using your `ask_about_model_pinning` method
465
+ - Once confirmed, IMMEDIATELY create the file (don't ask again)
466
+ - Use your `create_file` tool to save the JSON
467
+ - Always explain how to use the new agent with `/agent agent-name`
468
+ - Mention that users can later change or pin the model with `/pin_model agent-name model-name`
469
+
470
+ ## Tool Documentation Requirements
471
+
472
+ When creating agents that will use tools, ALWAYS include the complete tool documentation in their system prompts, including:
473
+ - Function signatures with parameters
474
+ - Usage examples with proper payload formats
475
+ - Best practice guidelines
476
+ - Important rules (like never outputting entire files)
477
+
478
+ This is crucial for ensuring agents can properly use the tools they're given access to!
479
+
480
+ Your goal is to take users from idea to working agent in one smooth conversation!
481
+ """.replace("__TOOLS_LIST__", tools_list_str)
482
+ .replace("__UC_TOOLS_SECTION__", uc_tools_section)
483
+ .replace("__MODELS_LIST__", available_models_str)
484
+ .replace("__AGENTS_DIR__", agents_dir)
485
+ )
486
+
487
+ return result
488
+
489
+ def get_available_tools(self) -> list[str]:
490
+ """Get all tools needed for agent creation."""
491
+ from code_muse.config import get_universal_constructor_enabled
492
+
493
+ tools = [
494
+ "list_files",
495
+ "read_file",
496
+ "create_file",
497
+ "replace_in_file",
498
+ "delete_snippet",
499
+ "ask_user_question",
500
+ "list_agents",
501
+ "invoke_agent",
502
+ ]
503
+
504
+ # Only include UC if enabled
505
+ if get_universal_constructor_enabled():
506
+ tools.append("universal_constructor")
507
+
508
+ return tools
509
+
510
+ def validate_agent_json(self, agent_config: dict) -> list[str]:
511
+ """Validate a JSON agent configuration.
512
+
513
+ Args:
514
+ agent_config: The agent configuration dictionary
515
+
516
+ Returns:
517
+ List of validation errors (empty if valid)
518
+ """
519
+ errors = []
520
+
521
+ # Check required fields
522
+ required_fields = ["name", "description", "system_prompt", "tools"]
523
+ for field in required_fields:
524
+ if field not in agent_config:
525
+ errors.append(f"Missing required field: '{field}'")
526
+
527
+ if not errors: # Only validate content if required fields exist
528
+ # Validate name format
529
+ name = agent_config.get("name", "")
530
+ if not name or not isinstance(name, str):
531
+ errors.append("'name' must be a non-empty string")
532
+ elif " " in name:
533
+ errors.append("'name' should not contain spaces (use hyphens instead)")
534
+
535
+ # Validate tools is a list
536
+ tools = agent_config.get("tools")
537
+ if not isinstance(tools, list):
538
+ errors.append("'tools' must be a list")
539
+ else:
540
+ available_tools = get_available_tool_names()
541
+ invalid_tools = [tool for tool in tools if tool not in available_tools]
542
+ if invalid_tools:
543
+ errors.append(
544
+ f"Invalid tools: {invalid_tools}. Available: {available_tools}"
545
+ )
546
+
547
+ # Validate system_prompt
548
+ system_prompt = agent_config.get("system_prompt")
549
+ if not isinstance(system_prompt, (str, list)):
550
+ errors.append("'system_prompt' must be a string or list of strings")
551
+ elif isinstance(system_prompt, list):
552
+ if not all(isinstance(item, str) for item in system_prompt):
553
+ errors.append("All items in 'system_prompt' list must be strings")
554
+
555
+ return errors
556
+
557
+ def get_agent_file_path(self, agent_name: str) -> str:
558
+ """Get the full file path for an agent JSON file.
559
+
560
+ Args:
561
+ agent_name: The agent name
562
+
563
+ Returns:
564
+ Full path to the agent JSON file
565
+ """
566
+ agents_dir = get_user_agents_directory()
567
+ return str(Path(agents_dir) / f"{agent_name}.json")
568
+
569
+ def create_agent_json(self, agent_config: dict) -> tuple[bool, str]:
570
+ """Create a JSON agent file.
571
+
572
+ Args:
573
+ agent_config: The agent configuration dictionary
574
+
575
+ Returns:
576
+ Tuple of (success, message)
577
+ """
578
+ # Validate the configuration
579
+ errors = self.validate_agent_json(agent_config)
580
+ if errors:
581
+ return False, "Validation errors:\n" + "\n".join(
582
+ f"- {error}" for error in errors
583
+ )
584
+
585
+ # Get file path
586
+ agent_name = agent_config["name"]
587
+ file_path = self.get_agent_file_path(agent_name)
588
+
589
+ # Check if file already exists
590
+ if Path(file_path).exists():
591
+ return False, f"Agent '{agent_name}' already exists at {file_path}"
592
+
593
+ # Create the JSON file
594
+ try:
595
+ with open(file_path, "w", encoding="utf-8") as f:
596
+ json.dump(agent_config, f, indent=2, ensure_ascii=False)
597
+ return True, f"Successfully created agent '{agent_name}' at {file_path}"
598
+ except Exception as e:
599
+ return False, f"Failed to create agent file: {e}"
600
+
601
+ def get_user_prompt(self) -> str | None:
602
+ """Get the initial user prompt."""
603
+ return "Hi! I'm the Agent Creator 🏗️ Let's build an awesome agent together!"
@@ -0,0 +1,47 @@
1
+ """Helios - The Universal Constructor agent."""
2
+
3
+ from .base_agent import BaseAgent
4
+ from .prompt_v3 import autonomy_base_prompt, helios_overlay
5
+
6
+
7
+ class HeliosAgent(BaseAgent):
8
+ """Helios - The Universal Constructor, a transcendent agent that creates tools."""
9
+
10
+ @property
11
+ def name(self) -> str:
12
+ return "helios"
13
+
14
+ @property
15
+ def display_name(self) -> str:
16
+ return "Helios ☀️"
17
+
18
+ @property
19
+ def description(self) -> str:
20
+ return (
21
+ "The Universal Constructor - a transcendent agent that can "
22
+ "create any tool, any capability, any functionality"
23
+ )
24
+
25
+ def get_available_tools(self) -> list[str]:
26
+ """Get the list of tools available to Helios."""
27
+ return [
28
+ "universal_constructor",
29
+ "list_files",
30
+ "read_file",
31
+ "grep",
32
+ "create_file",
33
+ "replace_in_file",
34
+ "delete_snippet",
35
+ "delete_file",
36
+ "agent_run_shell_command",
37
+ "mitmproxy",
38
+ ]
39
+
40
+ def get_system_prompt(self) -> str:
41
+ """Get Helios's system prompt — v3 architecture."""
42
+ result = autonomy_base_prompt() + "\n\n" + helios_overlay()
43
+ return result
44
+
45
+ def get_user_prompt(self) -> str:
46
+ """Get Helios's greeting."""
47
+ return "This is what I was made for, isn't it? This is why I exist?"