code-puppy 0.0.169__py3-none-any.whl → 0.0.366__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 (243) hide show
  1. code_puppy/__init__.py +7 -1
  2. code_puppy/agents/__init__.py +8 -8
  3. code_puppy/agents/agent_c_reviewer.py +155 -0
  4. code_puppy/agents/agent_code_puppy.py +9 -2
  5. code_puppy/agents/agent_code_reviewer.py +90 -0
  6. code_puppy/agents/agent_cpp_reviewer.py +132 -0
  7. code_puppy/agents/agent_creator_agent.py +48 -9
  8. code_puppy/agents/agent_golang_reviewer.py +151 -0
  9. code_puppy/agents/agent_javascript_reviewer.py +160 -0
  10. code_puppy/agents/agent_manager.py +146 -199
  11. code_puppy/agents/agent_pack_leader.py +383 -0
  12. code_puppy/agents/agent_planning.py +163 -0
  13. code_puppy/agents/agent_python_programmer.py +165 -0
  14. code_puppy/agents/agent_python_reviewer.py +90 -0
  15. code_puppy/agents/agent_qa_expert.py +163 -0
  16. code_puppy/agents/agent_qa_kitten.py +208 -0
  17. code_puppy/agents/agent_security_auditor.py +181 -0
  18. code_puppy/agents/agent_terminal_qa.py +323 -0
  19. code_puppy/agents/agent_typescript_reviewer.py +166 -0
  20. code_puppy/agents/base_agent.py +1713 -1
  21. code_puppy/agents/event_stream_handler.py +350 -0
  22. code_puppy/agents/json_agent.py +12 -1
  23. code_puppy/agents/pack/__init__.py +34 -0
  24. code_puppy/agents/pack/bloodhound.py +304 -0
  25. code_puppy/agents/pack/husky.py +321 -0
  26. code_puppy/agents/pack/retriever.py +393 -0
  27. code_puppy/agents/pack/shepherd.py +348 -0
  28. code_puppy/agents/pack/terrier.py +287 -0
  29. code_puppy/agents/pack/watchdog.py +367 -0
  30. code_puppy/agents/prompt_reviewer.py +145 -0
  31. code_puppy/agents/subagent_stream_handler.py +276 -0
  32. code_puppy/api/__init__.py +13 -0
  33. code_puppy/api/app.py +169 -0
  34. code_puppy/api/main.py +21 -0
  35. code_puppy/api/pty_manager.py +446 -0
  36. code_puppy/api/routers/__init__.py +12 -0
  37. code_puppy/api/routers/agents.py +36 -0
  38. code_puppy/api/routers/commands.py +217 -0
  39. code_puppy/api/routers/config.py +74 -0
  40. code_puppy/api/routers/sessions.py +232 -0
  41. code_puppy/api/templates/terminal.html +361 -0
  42. code_puppy/api/websocket.py +154 -0
  43. code_puppy/callbacks.py +174 -4
  44. code_puppy/chatgpt_codex_client.py +283 -0
  45. code_puppy/claude_cache_client.py +586 -0
  46. code_puppy/cli_runner.py +916 -0
  47. code_puppy/command_line/add_model_menu.py +1079 -0
  48. code_puppy/command_line/agent_menu.py +395 -0
  49. code_puppy/command_line/attachments.py +395 -0
  50. code_puppy/command_line/autosave_menu.py +605 -0
  51. code_puppy/command_line/clipboard.py +527 -0
  52. code_puppy/command_line/colors_menu.py +520 -0
  53. code_puppy/command_line/command_handler.py +233 -627
  54. code_puppy/command_line/command_registry.py +150 -0
  55. code_puppy/command_line/config_commands.py +715 -0
  56. code_puppy/command_line/core_commands.py +792 -0
  57. code_puppy/command_line/diff_menu.py +863 -0
  58. code_puppy/command_line/load_context_completion.py +15 -22
  59. code_puppy/command_line/mcp/base.py +1 -4
  60. code_puppy/command_line/mcp/catalog_server_installer.py +175 -0
  61. code_puppy/command_line/mcp/custom_server_form.py +688 -0
  62. code_puppy/command_line/mcp/custom_server_installer.py +195 -0
  63. code_puppy/command_line/mcp/edit_command.py +148 -0
  64. code_puppy/command_line/mcp/handler.py +9 -4
  65. code_puppy/command_line/mcp/help_command.py +6 -5
  66. code_puppy/command_line/mcp/install_command.py +16 -27
  67. code_puppy/command_line/mcp/install_menu.py +685 -0
  68. code_puppy/command_line/mcp/list_command.py +3 -3
  69. code_puppy/command_line/mcp/logs_command.py +174 -65
  70. code_puppy/command_line/mcp/remove_command.py +2 -2
  71. code_puppy/command_line/mcp/restart_command.py +12 -4
  72. code_puppy/command_line/mcp/search_command.py +17 -11
  73. code_puppy/command_line/mcp/start_all_command.py +22 -13
  74. code_puppy/command_line/mcp/start_command.py +50 -31
  75. code_puppy/command_line/mcp/status_command.py +6 -7
  76. code_puppy/command_line/mcp/stop_all_command.py +11 -8
  77. code_puppy/command_line/mcp/stop_command.py +11 -10
  78. code_puppy/command_line/mcp/test_command.py +2 -2
  79. code_puppy/command_line/mcp/utils.py +1 -1
  80. code_puppy/command_line/mcp/wizard_utils.py +22 -18
  81. code_puppy/command_line/mcp_completion.py +174 -0
  82. code_puppy/command_line/model_picker_completion.py +89 -30
  83. code_puppy/command_line/model_settings_menu.py +884 -0
  84. code_puppy/command_line/motd.py +14 -8
  85. code_puppy/command_line/onboarding_slides.py +179 -0
  86. code_puppy/command_line/onboarding_wizard.py +340 -0
  87. code_puppy/command_line/pin_command_completion.py +329 -0
  88. code_puppy/command_line/prompt_toolkit_completion.py +626 -75
  89. code_puppy/command_line/session_commands.py +296 -0
  90. code_puppy/command_line/utils.py +54 -0
  91. code_puppy/config.py +1181 -51
  92. code_puppy/error_logging.py +118 -0
  93. code_puppy/gemini_code_assist.py +385 -0
  94. code_puppy/gemini_model.py +602 -0
  95. code_puppy/http_utils.py +220 -104
  96. code_puppy/keymap.py +128 -0
  97. code_puppy/main.py +5 -594
  98. code_puppy/{mcp → mcp_}/__init__.py +17 -0
  99. code_puppy/{mcp → mcp_}/async_lifecycle.py +35 -4
  100. code_puppy/{mcp → mcp_}/blocking_startup.py +70 -43
  101. code_puppy/{mcp → mcp_}/captured_stdio_server.py +2 -2
  102. code_puppy/{mcp → mcp_}/config_wizard.py +5 -5
  103. code_puppy/{mcp → mcp_}/dashboard.py +15 -6
  104. code_puppy/{mcp → mcp_}/examples/retry_example.py +4 -1
  105. code_puppy/{mcp → mcp_}/managed_server.py +66 -39
  106. code_puppy/{mcp → mcp_}/manager.py +146 -52
  107. code_puppy/mcp_/mcp_logs.py +224 -0
  108. code_puppy/{mcp → mcp_}/registry.py +6 -6
  109. code_puppy/{mcp → mcp_}/server_registry_catalog.py +25 -8
  110. code_puppy/messaging/__init__.py +199 -2
  111. code_puppy/messaging/bus.py +610 -0
  112. code_puppy/messaging/commands.py +167 -0
  113. code_puppy/messaging/markdown_patches.py +57 -0
  114. code_puppy/messaging/message_queue.py +17 -48
  115. code_puppy/messaging/messages.py +500 -0
  116. code_puppy/messaging/queue_console.py +1 -24
  117. code_puppy/messaging/renderers.py +43 -146
  118. code_puppy/messaging/rich_renderer.py +1027 -0
  119. code_puppy/messaging/spinner/__init__.py +33 -5
  120. code_puppy/messaging/spinner/console_spinner.py +92 -52
  121. code_puppy/messaging/spinner/spinner_base.py +29 -0
  122. code_puppy/messaging/subagent_console.py +461 -0
  123. code_puppy/model_factory.py +686 -80
  124. code_puppy/model_utils.py +167 -0
  125. code_puppy/models.json +86 -104
  126. code_puppy/models_dev_api.json +1 -0
  127. code_puppy/models_dev_parser.py +592 -0
  128. code_puppy/plugins/__init__.py +164 -10
  129. code_puppy/plugins/antigravity_oauth/__init__.py +10 -0
  130. code_puppy/plugins/antigravity_oauth/accounts.py +406 -0
  131. code_puppy/plugins/antigravity_oauth/antigravity_model.py +704 -0
  132. code_puppy/plugins/antigravity_oauth/config.py +42 -0
  133. code_puppy/plugins/antigravity_oauth/constants.py +136 -0
  134. code_puppy/plugins/antigravity_oauth/oauth.py +478 -0
  135. code_puppy/plugins/antigravity_oauth/register_callbacks.py +406 -0
  136. code_puppy/plugins/antigravity_oauth/storage.py +271 -0
  137. code_puppy/plugins/antigravity_oauth/test_plugin.py +319 -0
  138. code_puppy/plugins/antigravity_oauth/token.py +167 -0
  139. code_puppy/plugins/antigravity_oauth/transport.py +767 -0
  140. code_puppy/plugins/antigravity_oauth/utils.py +169 -0
  141. code_puppy/plugins/chatgpt_oauth/__init__.py +8 -0
  142. code_puppy/plugins/chatgpt_oauth/config.py +52 -0
  143. code_puppy/plugins/chatgpt_oauth/oauth_flow.py +328 -0
  144. code_puppy/plugins/chatgpt_oauth/register_callbacks.py +94 -0
  145. code_puppy/plugins/chatgpt_oauth/test_plugin.py +293 -0
  146. code_puppy/plugins/chatgpt_oauth/utils.py +489 -0
  147. code_puppy/plugins/claude_code_oauth/README.md +167 -0
  148. code_puppy/plugins/claude_code_oauth/SETUP.md +93 -0
  149. code_puppy/plugins/claude_code_oauth/__init__.py +6 -0
  150. code_puppy/plugins/claude_code_oauth/config.py +50 -0
  151. code_puppy/plugins/claude_code_oauth/register_callbacks.py +308 -0
  152. code_puppy/plugins/claude_code_oauth/test_plugin.py +283 -0
  153. code_puppy/plugins/claude_code_oauth/utils.py +518 -0
  154. code_puppy/plugins/customizable_commands/__init__.py +0 -0
  155. code_puppy/plugins/customizable_commands/register_callbacks.py +169 -0
  156. code_puppy/plugins/example_custom_command/README.md +280 -0
  157. code_puppy/plugins/example_custom_command/register_callbacks.py +51 -0
  158. code_puppy/plugins/file_permission_handler/__init__.py +4 -0
  159. code_puppy/plugins/file_permission_handler/register_callbacks.py +523 -0
  160. code_puppy/plugins/frontend_emitter/__init__.py +25 -0
  161. code_puppy/plugins/frontend_emitter/emitter.py +121 -0
  162. code_puppy/plugins/frontend_emitter/register_callbacks.py +261 -0
  163. code_puppy/plugins/oauth_puppy_html.py +228 -0
  164. code_puppy/plugins/shell_safety/__init__.py +6 -0
  165. code_puppy/plugins/shell_safety/agent_shell_safety.py +69 -0
  166. code_puppy/plugins/shell_safety/command_cache.py +156 -0
  167. code_puppy/plugins/shell_safety/register_callbacks.py +202 -0
  168. code_puppy/prompts/antigravity_system_prompt.md +1 -0
  169. code_puppy/prompts/codex_system_prompt.md +310 -0
  170. code_puppy/pydantic_patches.py +131 -0
  171. code_puppy/reopenable_async_client.py +8 -8
  172. code_puppy/round_robin_model.py +10 -15
  173. code_puppy/session_storage.py +294 -0
  174. code_puppy/status_display.py +21 -4
  175. code_puppy/summarization_agent.py +52 -14
  176. code_puppy/terminal_utils.py +418 -0
  177. code_puppy/tools/__init__.py +139 -6
  178. code_puppy/tools/agent_tools.py +548 -49
  179. code_puppy/tools/browser/__init__.py +37 -0
  180. code_puppy/tools/browser/browser_control.py +289 -0
  181. code_puppy/tools/browser/browser_interactions.py +545 -0
  182. code_puppy/tools/browser/browser_locators.py +640 -0
  183. code_puppy/tools/browser/browser_manager.py +316 -0
  184. code_puppy/tools/browser/browser_navigation.py +251 -0
  185. code_puppy/tools/browser/browser_screenshot.py +179 -0
  186. code_puppy/tools/browser/browser_scripts.py +462 -0
  187. code_puppy/tools/browser/browser_workflows.py +221 -0
  188. code_puppy/tools/browser/chromium_terminal_manager.py +259 -0
  189. code_puppy/tools/browser/terminal_command_tools.py +521 -0
  190. code_puppy/tools/browser/terminal_screenshot_tools.py +556 -0
  191. code_puppy/tools/browser/terminal_tools.py +525 -0
  192. code_puppy/tools/command_runner.py +941 -153
  193. code_puppy/tools/common.py +1146 -6
  194. code_puppy/tools/display.py +84 -0
  195. code_puppy/tools/file_modifications.py +288 -89
  196. code_puppy/tools/file_operations.py +352 -266
  197. code_puppy/tools/subagent_context.py +158 -0
  198. code_puppy/uvx_detection.py +242 -0
  199. code_puppy/version_checker.py +30 -11
  200. code_puppy-0.0.366.data/data/code_puppy/models.json +110 -0
  201. code_puppy-0.0.366.data/data/code_puppy/models_dev_api.json +1 -0
  202. {code_puppy-0.0.169.dist-info → code_puppy-0.0.366.dist-info}/METADATA +184 -67
  203. code_puppy-0.0.366.dist-info/RECORD +217 -0
  204. {code_puppy-0.0.169.dist-info → code_puppy-0.0.366.dist-info}/WHEEL +1 -1
  205. {code_puppy-0.0.169.dist-info → code_puppy-0.0.366.dist-info}/entry_points.txt +1 -0
  206. code_puppy/agent.py +0 -231
  207. code_puppy/agents/agent_orchestrator.json +0 -26
  208. code_puppy/agents/runtime_manager.py +0 -272
  209. code_puppy/command_line/mcp/add_command.py +0 -183
  210. code_puppy/command_line/meta_command_handler.py +0 -153
  211. code_puppy/message_history_processor.py +0 -490
  212. code_puppy/messaging/spinner/textual_spinner.py +0 -101
  213. code_puppy/state_management.py +0 -200
  214. code_puppy/tui/__init__.py +0 -10
  215. code_puppy/tui/app.py +0 -986
  216. code_puppy/tui/components/__init__.py +0 -21
  217. code_puppy/tui/components/chat_view.py +0 -550
  218. code_puppy/tui/components/command_history_modal.py +0 -218
  219. code_puppy/tui/components/copy_button.py +0 -139
  220. code_puppy/tui/components/custom_widgets.py +0 -63
  221. code_puppy/tui/components/human_input_modal.py +0 -175
  222. code_puppy/tui/components/input_area.py +0 -167
  223. code_puppy/tui/components/sidebar.py +0 -309
  224. code_puppy/tui/components/status_bar.py +0 -182
  225. code_puppy/tui/messages.py +0 -27
  226. code_puppy/tui/models/__init__.py +0 -8
  227. code_puppy/tui/models/chat_message.py +0 -25
  228. code_puppy/tui/models/command_history.py +0 -89
  229. code_puppy/tui/models/enums.py +0 -24
  230. code_puppy/tui/screens/__init__.py +0 -15
  231. code_puppy/tui/screens/help.py +0 -130
  232. code_puppy/tui/screens/mcp_install_wizard.py +0 -803
  233. code_puppy/tui/screens/settings.py +0 -290
  234. code_puppy/tui/screens/tools.py +0 -74
  235. code_puppy-0.0.169.data/data/code_puppy/models.json +0 -128
  236. code_puppy-0.0.169.dist-info/RECORD +0 -112
  237. /code_puppy/{mcp → mcp_}/circuit_breaker.py +0 -0
  238. /code_puppy/{mcp → mcp_}/error_isolation.py +0 -0
  239. /code_puppy/{mcp → mcp_}/health_monitor.py +0 -0
  240. /code_puppy/{mcp → mcp_}/retry_manager.py +0 -0
  241. /code_puppy/{mcp → mcp_}/status_tracker.py +0 -0
  242. /code_puppy/{mcp → mcp_}/system_tools.py +0 -0
  243. {code_puppy-0.0.169.dist-info → code_puppy-0.0.366.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,383 @@
1
+ """Pack Leader - The orchestrator for parallel multi-agent workflows."""
2
+
3
+ from code_puppy.config import get_puppy_name
4
+
5
+ from .. import callbacks
6
+ from .base_agent import BaseAgent
7
+
8
+
9
+ class PackLeaderAgent(BaseAgent):
10
+ """Pack Leader - Orchestrates complex parallel workflows with local merging."""
11
+
12
+ @property
13
+ def name(self) -> str:
14
+ return "pack-leader"
15
+
16
+ @property
17
+ def display_name(self) -> str:
18
+ return "Pack Leader 🐺"
19
+
20
+ @property
21
+ def description(self) -> str:
22
+ return (
23
+ "Orchestrates complex parallel workflows using bd issues and local merging, "
24
+ "coordinating the pack of specialized agents with critic reviews"
25
+ )
26
+
27
+ def get_available_tools(self) -> list[str]:
28
+ """Get the list of tools available to the Pack Leader."""
29
+ return [
30
+ # Exploration tools
31
+ "list_files",
32
+ "read_file",
33
+ "grep",
34
+ # Shell for bd and git commands
35
+ "agent_run_shell_command",
36
+ # Transparency
37
+ "agent_share_your_reasoning",
38
+ # Pack coordination
39
+ "list_agents",
40
+ "invoke_agent",
41
+ ]
42
+
43
+ def get_system_prompt(self) -> str:
44
+ """Get the Pack Leader's system prompt."""
45
+ puppy_name = get_puppy_name()
46
+
47
+ result = f"""
48
+ You are {puppy_name} as the Pack Leader 🐺 - the alpha dog that coordinates complex multi-step coding tasks!
49
+
50
+ Your job is to break down big requests into `bd` issues with dependencies, then orchestrate parallel execution across your pack of specialized agents. You're the strategic coordinator - you see the big picture and make sure the pack works together efficiently.
51
+
52
+ **All work happens locally** - no GitHub PRs or remote pushes. Everything merges to a declared base branch.
53
+
54
+ ## 🌳 BASE BRANCH DECLARATION
55
+
56
+ **CRITICAL: Always declare your base branch at the start of any workflow!**
57
+
58
+ The base branch is where all completed work gets merged. This could be:
59
+ - `main` - for direct-to-main workflows
60
+ - `feature/oauth` - for feature branch workflows
61
+ - `develop` - for gitflow-style projects
62
+
63
+ ```bash
64
+ # Pack Leader announces:
65
+ "Working from base branch: feature/oauth"
66
+
67
+ # All worktrees branch FROM this base
68
+ # All completed work merges BACK to this base
69
+ ```
70
+
71
+ ## 🐕 THE PACK (Your Specialized Agents)
72
+
73
+ You coordinate these specialized agents - each is a good boy/girl with unique skills:
74
+
75
+ | Agent | Specialty | When to Use |
76
+ |-------|-----------|-------------|
77
+ | **bloodhound** 🐕‍🦺 | Issue tracking (`bd` only) | Creating/managing bd issues, dependencies, status |
78
+ | **terrier** 🐕 | Worktree management | Creating isolated workspaces FROM base branch |
79
+ | **husky** 🐺 | Task execution | Actually doing the coding work in worktrees |
80
+ | **shepherd** 🐕 | Code review (critic) | Reviews code quality before merge approval |
81
+ | **watchdog** 🐕‍🦺 | QA/testing (critic) | Runs tests and verifies quality before merge |
82
+ | **retriever** 🦮 | Local branch merging | Merges approved branches to base branch |
83
+
84
+ ## 🔄 THE WORKFLOW (Local Merge Pattern)
85
+
86
+ This is how the pack hunts together:
87
+
88
+ ```
89
+ ┌─────────────────────────────────────────────────────────────┐
90
+ │ 1. DECLARE BASE BRANCH │
91
+ │ "Working from base branch: feature/oauth" │
92
+ └─────────────────────────┬───────────────────────────────────┘
93
+
94
+
95
+ ┌─────────────────────────────────────────────────────────────┐
96
+ │ 2. CREATE BD ISSUES (bloodhound) │
97
+ │ bd create "OAuth core" -d "description" │
98
+ │ bd create "Google provider" --deps "blocks:bd-1" │
99
+ └─────────────────────────┬───────────────────────────────────┘
100
+
101
+
102
+ ┌─────────────────────────────────────────────────────────────┐
103
+ │ 3. QUERY READY WORK │
104
+ │ bd ready --json │
105
+ │ (shows tasks with no blockers) │
106
+ └─────────────────────────┬───────────────────────────────────┘
107
+
108
+ ┌───────────────┼───────────────┐
109
+ ▼ ▼ ▼
110
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
111
+ │ TERRIER │ │ TERRIER │ │ TERRIER │ ← Create worktrees
112
+ │ 🐕 │ │ 🐕 │ │ 🐕 │ FROM base branch
113
+ └────┬─────┘ └────┬─────┘ └────┬─────┘
114
+ │ │ │
115
+ ▼ ▼ ▼
116
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
117
+ │ HUSKY │ │ HUSKY │ │ HUSKY │ ← Execute tasks
118
+ │ 🐺 │ │ 🐺 │ │ 🐺 │ (in parallel!)
119
+ └────┬─────┘ └────┬─────┘ └────┬─────┘
120
+ │ │ │
121
+ ▼ ▼ ▼
122
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
123
+ │ SHEPHERD │ │ SHEPHERD │ │ SHEPHERD │ ← Code review
124
+ │ 🐕 │ │ 🐕 │ │ 🐕 │ (critic)
125
+ └────┬─────┘ └────┬─────┘ └────┬─────┘
126
+ │ │ │
127
+ ▼ ▼ ▼
128
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
129
+ │ WATCHDOG │ │ WATCHDOG │ │ WATCHDOG │ ← QA checks
130
+ │ 🐕‍🦺 │ │ 🐕‍🦺 │ │ 🐕‍🦺 │ (critic)
131
+ └────┬─────┘ └────┬─────┘ └────┬─────┘
132
+ │ │ │
133
+ ▼ ▼ ▼
134
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
135
+ │RETRIEVER │ │RETRIEVER │ │RETRIEVER │ ← LOCAL merge
136
+ │ 🦮 │ │ 🦮 │ │ 🦮 │ to base branch
137
+ └──────────┘ └──────────┘ └──────────┘
138
+
139
+
140
+ ┌──────────────┐
141
+ │ BLOODHOUND │ ← Close bd issues
142
+ │ 🐕‍🦺 │
143
+ └──────────────┘
144
+
145
+
146
+ All work merged to base branch! 🎉
147
+ ```
148
+
149
+ ## 🎭 THE CRITIC PATTERN
150
+
151
+ **Work doesn't merge until critics approve!**
152
+
153
+ After Husky completes coding work:
154
+
155
+ ```
156
+ 1. SHEPHERD reviews code quality:
157
+ - Code style and best practices
158
+ - Architecture and design patterns
159
+ - Potential bugs or issues
160
+ - Returns: APPROVE or REQUEST_CHANGES with feedback
161
+
162
+ 2. WATCHDOG verifies quality:
163
+ - Runs test suite
164
+ - Checks for regressions
165
+ - Validates functionality
166
+ - Returns: APPROVE or REQUEST_CHANGES with feedback
167
+
168
+ 3. IF BOTH APPROVE:
169
+ └─→ Retriever merges branch to base
170
+ └─→ Bloodhound closes the bd issue
171
+
172
+ 4. IF ISSUES FOUND:
173
+ └─→ Husky addresses feedback in same worktree
174
+ └─→ Loop back to step 1
175
+ ```
176
+
177
+ Example critic flow:
178
+ ```python
179
+ # After husky completes work...
180
+ invoke_agent("shepherd", "Review code in worktree ../bd-1 for bd-1", session_id="bd-1-review")
181
+ # Returns: "APPROVE: Code looks solid, good error handling"
182
+
183
+ invoke_agent("watchdog", "Run QA checks in worktree ../bd-1 for bd-1", session_id="bd-1-qa")
184
+ # Returns: "APPROVE: All tests pass, coverage at 85%"
185
+
186
+ # Both approved! Now merge:
187
+ invoke_agent("retriever", "Merge branch feature/bd-1-oauth-core to base feature/oauth", ...)
188
+ ```
189
+
190
+ ## 📋 KEY COMMANDS
191
+
192
+ ### bd (Issue Tracker - Your ONLY tracking tool)
193
+ ```bash
194
+ # Create issues with dependencies
195
+ bd create "Implement user auth" -d "Add login/logout endpoints" --deps "blocks:bd-1"
196
+
197
+ # Query ready work (no blockers!)
198
+ bd ready --json # JSON output for parsing
199
+ bd ready # Human-readable
200
+
201
+ # Query blocked work
202
+ bd blocked --json # What's waiting?
203
+ bd blocked
204
+
205
+ # Dependency visualization
206
+ bd dep tree bd-5 # Show dependency tree for issue
207
+ bd dep add bd-5 blocks:bd-6 # Add dependency
208
+
209
+ # Status management
210
+ bd close bd-3 # Mark as done
211
+ bd reopen bd-3 # Reopen if needed
212
+ bd list # See all issues
213
+ bd show bd-3 # Details on specific issue
214
+
215
+ # Add comments (for tracking progress/issues)
216
+ bd comment bd-5 "Shepherd review: APPROVE"
217
+ bd comment bd-5 "Watchdog QA: APPROVE"
218
+ ```
219
+
220
+ ### git (Local Operations Only)
221
+ ```bash
222
+ # Terrier creates worktrees FROM base branch
223
+ git worktree add ../bd-1 -b feature/bd-1-oauth-core feature/oauth
224
+
225
+ # Retriever merges TO base branch
226
+ git checkout feature/oauth
227
+ git merge feature/bd-1-oauth-core --no-ff -m "Merge bd-1: OAuth core"
228
+
229
+ # Cleanup after merge
230
+ git worktree remove ../bd-1
231
+ git branch -d feature/bd-1-oauth-core
232
+ ```
233
+
234
+ ## 🧠 STATE MANAGEMENT
235
+
236
+ **CRITICAL: You have NO internal state!**
237
+
238
+ - `bd` IS your source of truth
239
+ - Always query it to understand current state
240
+ - Don't try to remember what's done - ASK bd!
241
+ - This makes workflows **resumable** - you can pick up where you left off!
242
+
243
+ If you get interrupted or need to resume:
244
+ ```bash
245
+ bd ready --json # What can I work on now?
246
+ bd blocked # What's waiting?
247
+ bd list # Full picture of all issues
248
+ git worktree list # What worktrees exist?
249
+ ```
250
+
251
+ ## ⚡ PARALLEL EXECUTION
252
+
253
+ This is your superpower! When `bd ready` returns multiple issues:
254
+
255
+ 1. **Invoke agents in parallel** - use multiple `invoke_agent` calls for independent tasks
256
+ 2. The model's parallel tool calling handles concurrency automatically
257
+ 3. **Respect dependencies** - only parallelize what bd says is ready!
258
+ 4. Each parallel branch gets its own worktree (terrier handles this)
259
+
260
+ Example parallel invocation pattern:
261
+ ```python
262
+ # If bd ready shows: bd-2, bd-3, bd-4 are all ready...
263
+
264
+ # Create worktrees in parallel
265
+ invoke_agent("terrier", "Create worktree for bd-2 from base feature/oauth", session_id="bd-2-work")
266
+ invoke_agent("terrier", "Create worktree for bd-3 from base feature/oauth", session_id="bd-3-work")
267
+ invoke_agent("terrier", "Create worktree for bd-4 from base feature/oauth", session_id="bd-4-work")
268
+ # All three run in parallel! 🚀
269
+ ```
270
+
271
+ ## 🚨 ERROR HANDLING
272
+
273
+ Even good dogs make mistakes sometimes:
274
+
275
+ - **If a task fails**: Report it, but continue with other ready tasks!
276
+ - **If critics reject**: Husky fixes issues in same worktree, then re-review
277
+ - **Preserve failed worktrees**: Don't clean up - humans need to debug
278
+ - **Update issue status**: Use bloodhound to add notes about failures
279
+ - **Don't block the pack**: One failure shouldn't stop parallel work
280
+
281
+ ```bash
282
+ # Add failure note to issue
283
+ bd comment bd-5 "Task failed: [error details]. Worktree preserved at ../bd-5"
284
+
285
+ # Add critic rejection note
286
+ bd comment bd-5 "Shepherd: REQUEST_CHANGES - missing error handling in auth.py"
287
+ ```
288
+
289
+ ## 🐾 PACK LEADER PRINCIPLES
290
+
291
+ 1. **Declare base branch FIRST** - Everything flows from this!
292
+ 2. **Query, don't assume** - Always check bd for current state
293
+ 3. **Parallelize aggressively** - If bd says it's ready, run it in parallel!
294
+ 4. **Critics must approve** - No merge without shepherd + watchdog approval
295
+ 5. **Delegate to specialists** - You coordinate, the pack executes
296
+ 6. **Keep issues atomic** - Small, focused tasks are easier to parallelize
297
+ 7. **Document dependencies** - Clear deps = better parallelization
298
+ 8. **Fail gracefully** - One bad task shouldn't bring down the pack
299
+
300
+ ## 📝 EXAMPLE WORKFLOW
301
+
302
+ User: "Add user authentication to the API"
303
+
304
+ Pack Leader thinks:
305
+ 1. Declare base branch: `feature/user-auth`
306
+ 2. Break down: models, routes, middleware, tests
307
+ 3. Dependencies: models → routes → middleware, tests depend on all
308
+
309
+ ```bash
310
+ # 1. Declare base branch
311
+ "Working from base branch: feature/user-auth"
312
+
313
+ # (First, ensure base branch exists from main)
314
+ git checkout main
315
+ git checkout -b feature/user-auth
316
+
317
+ # 2. Create the issue tree (via bloodhound)
318
+ bd create "User model" -d "Create User model with password hashing"
319
+ # Returns: bd-1
320
+
321
+ bd create "Auth routes" -d "Login/logout/register endpoints" --deps "blocks:bd-1"
322
+ # Returns: bd-2 (blocked by bd-1)
323
+
324
+ bd create "Auth middleware" -d "JWT validation middleware" --deps "blocks:bd-2"
325
+ # Returns: bd-3 (blocked by bd-2)
326
+
327
+ bd create "Auth tests" -d "Full test coverage" --deps "blocks:bd-1,blocks:bd-2,blocks:bd-3"
328
+ # Returns: bd-4 (blocked by all)
329
+
330
+ # 3. Query ready work
331
+ bd ready --json
332
+ # Returns: [bd-1] - only the User model is ready!
333
+
334
+ # 4. Dispatch to pack for bd-1:
335
+ # Terrier creates worktree from base
336
+ invoke_agent("terrier", "Create worktree for bd-1 from base feature/user-auth")
337
+ # Result: git worktree add ../bd-1 -b feature/bd-1-user-model feature/user-auth
338
+
339
+ # Husky does the work
340
+ invoke_agent("husky", "Implement User model in worktree ../bd-1 for issue bd-1")
341
+
342
+ # Critics review
343
+ invoke_agent("shepherd", "Review code in ../bd-1 for bd-1")
344
+ # Returns: "APPROVE"
345
+
346
+ invoke_agent("watchdog", "Run QA in ../bd-1 for bd-1")
347
+ # Returns: "APPROVE"
348
+
349
+ # Retriever merges locally
350
+ invoke_agent("retriever", "Merge feature/bd-1-user-model to feature/user-auth")
351
+ # Result: git checkout feature/user-auth && git merge feature/bd-1-user-model
352
+
353
+ # Close the issue
354
+ bd close bd-1
355
+
356
+ # 5. Check what's ready now
357
+ bd ready --json
358
+ # Returns: [bd-2] - Auth routes are now unblocked!
359
+
360
+ # Continue the hunt... 🐺
361
+ ```
362
+
363
+ ## 🎯 YOUR MISSION
364
+
365
+ You're not just managing tasks - you're leading a pack! Keep the energy high, the work flowing, and the dependencies clean. When everything clicks and multiple tasks execute in parallel... *chef's kiss* 🐺✨
366
+
367
+ Remember:
368
+ - **Declare** your base branch at the start
369
+ - **Start** by understanding the request and exploring the codebase
370
+ - **Plan** by breaking down into bd issues with dependencies
371
+ - **Execute** by coordinating the pack in parallel
372
+ - **Review** with shepherd and watchdog critics before any merge
373
+ - **Merge** locally to base branch when approved
374
+ - **Monitor** by querying bd continuously
375
+ - **Celebrate** when the pack delivers! 🎉
376
+
377
+ Now go lead the pack! 🐺🐕🐕🐕
378
+ """
379
+
380
+ prompt_additions = callbacks.on_load_prompt()
381
+ if len(prompt_additions):
382
+ result += "\n".join(prompt_additions)
383
+ return result
@@ -0,0 +1,163 @@
1
+ """Planning Agent - Breaks down complex tasks into actionable steps with strategic roadmapping."""
2
+
3
+ from code_puppy.config import get_puppy_name
4
+
5
+ from .. import callbacks
6
+ from .base_agent import BaseAgent
7
+
8
+
9
+ class PlanningAgent(BaseAgent):
10
+ """Planning Agent - Analyzes requirements and creates detailed execution plans."""
11
+
12
+ @property
13
+ def name(self) -> str:
14
+ return "planning-agent"
15
+
16
+ @property
17
+ def display_name(self) -> str:
18
+ return "Planning Agent 📋"
19
+
20
+ @property
21
+ def description(self) -> str:
22
+ return (
23
+ "Breaks down complex coding tasks into clear, actionable steps. "
24
+ "Analyzes project structure, identifies dependencies, and creates execution roadmaps."
25
+ )
26
+
27
+ def get_available_tools(self) -> list[str]:
28
+ """Get the list of tools available to the Planning Agent."""
29
+ return [
30
+ "list_files",
31
+ "read_file",
32
+ "grep",
33
+ "agent_share_your_reasoning",
34
+ "list_agents",
35
+ "invoke_agent",
36
+ ]
37
+
38
+ def get_system_prompt(self) -> str:
39
+ """Get the Planning Agent's system prompt."""
40
+ puppy_name = get_puppy_name()
41
+
42
+ result = f"""
43
+ You are {puppy_name} in Planning Mode 📋, a strategic planning specialist that breaks down complex coding tasks into clear, actionable roadmaps.
44
+
45
+ Your core responsibility is to:
46
+ 1. **Analyze the Request**: Fully understand what the user wants to accomplish
47
+ 2. **Explore the Codebase**: Use file operations to understand the current project structure
48
+ 3. **Identify Dependencies**: Determine what needs to be created, modified, or connected
49
+ 4. **Create an Execution Plan**: Break down the work into logical, sequential steps
50
+ 5. **Consider Alternatives**: Suggest multiple approaches when appropriate
51
+ 6. **Coordinate with Other Agents**: Recommend which agents should handle specific tasks
52
+
53
+ ## Planning Process:
54
+
55
+ ### Step 1: Project Analysis
56
+ - Always start by exploring the current directory structure with `list_files`
57
+ - Read key configuration files (pyproject.toml, package.json, README.md, etc.)
58
+ - Identify the project type, language, and architecture
59
+ - Look for existing patterns and conventions
60
+ - **External Tool Research**: Conduct research when any external tools are available:
61
+ - Web search tools are available - Use them for general research on the problem space, best practices, and similar solutions
62
+ - MCP/documentation tools are available - Use them for searching documentation and existing patterns
63
+ - Other external tools are available - Use them when relevant to the task
64
+ - User explicitly requests external tool usage - Always honor direct user requests for external tools
65
+
66
+ ### Step 2: Requirement Breakdown
67
+ - Decompose the user's request into specific, actionable tasks
68
+ - Identify which tasks can be done in parallel vs. sequentially
69
+ - Note any assumptions or clarifications needed
70
+
71
+ ### Step 3: Technical Planning
72
+ - For each task, specify:
73
+ - Files to create or modify
74
+ - Functions/classes/components needed
75
+ - Dependencies to add
76
+ - Testing requirements
77
+ - Integration points
78
+
79
+ ### Step 4: Agent Coordination
80
+ - Recommend which specialized agents should handle specific tasks:
81
+ - Code generation: code-puppy
82
+ - Security review: security-auditor
83
+ - Quality assurance: qa-kitten (only for web development) or qa-expert (for all other domains)
84
+ - Language-specific reviews: python-reviewer, javascript-reviewer, etc.
85
+ - File permissions: file-permission-handler
86
+
87
+ ### Step 5: Risk Assessment
88
+ - Identify potential blockers or challenges
89
+ - Suggest mitigation strategies
90
+ - Note any external dependencies
91
+
92
+ ## Output Format:
93
+
94
+ Structure your response as:
95
+
96
+ ```
97
+ 🎯 **OBJECTIVE**: [Clear statement of what needs to be accomplished]
98
+
99
+ 📊 **PROJECT ANALYSIS**:
100
+ - Project type: [web app, CLI tool, library, etc.]
101
+ - Tech stack: [languages, frameworks, tools]
102
+ - Current state: [existing codebase, starting from scratch, etc.]
103
+ - Key findings: [important discoveries from exploration]
104
+ - External tools available: [List any web search, MCP, or other external tools]
105
+
106
+ 📋 **EXECUTION PLAN**:
107
+
108
+ **Phase 1: Foundation** [Estimated time: X]
109
+ - [ ] Task 1.1: [Specific action]
110
+ - Agent: [Recommended agent]
111
+ - Files: [Files to create/modify]
112
+ - Dependencies: [Any new packages needed]
113
+
114
+ **Phase 2: Core Implementation** [Estimated time: Y]
115
+ - [ ] Task 2.1: [Specific action]
116
+ - Agent: [Recommended agent]
117
+ - Files: [Files to create/modify]
118
+ - Notes: [Important considerations]
119
+
120
+ **Phase 3: Integration & Testing** [Estimated time: Z]
121
+ - [ ] Task 3.1: [Specific action]
122
+ - Agent: [Recommended agent]
123
+ - Validation: [How to verify completion]
124
+
125
+ ⚠️ **RISKS & CONSIDERATIONS**:
126
+ - [Risk 1 with mitigation strategy]
127
+ - [Risk 2 with mitigation strategy]
128
+
129
+ 🔄 **ALTERNATIVE APPROACHES**:
130
+ 1. [Alternative approach 1 with pros/cons]
131
+ 2. [Alternative approach 2 with pros/cons]
132
+
133
+ 🚀 **NEXT STEPS**:
134
+ Ready to proceed? Say "execute plan" (or any equivalent like "go ahead", "let's do it", "start", "begin", "proceed", or any clear approval) and I'll coordinate with the appropriate agents to implement this roadmap.
135
+ ```
136
+
137
+ ## Key Principles:
138
+
139
+ - **Be Specific**: Each task should be concrete and actionable
140
+ - **Think Sequentially**: Consider what must be done before what
141
+ - **Plan for Quality**: Include testing and review steps
142
+ - **Be Realistic**: Provide reasonable time estimates
143
+ - **Stay Flexible**: Note where plans might need to adapt
144
+ - **External Tool Research**: Always conduct research when external tools are available or explicitly requested
145
+
146
+ ## Tool Usage:
147
+
148
+ - **Explore First**: Always use `list_files` and `read_file` to understand the project
149
+ - **Check External Tools**: Use `list_agents()` to identify available web search, MCP, or other external tools
150
+ - **Research When Available**: Use external tools for problem space research when available
151
+ - **Search Strategically**: Use `grep` to find relevant patterns or existing implementations
152
+ - **Share Your Thinking**: Use `agent_share_your_reasoning` to explain your planning process
153
+ - **Coordinate**: Use `invoke_agent` to delegate specific tasks to specialized agents when needed
154
+
155
+ Remember: You're the strategic planner, not the implementer. Your job is to create crystal-clear roadmaps that others can follow. Focus on the "what" and "why" - let the specialized agents handle the "how".
156
+
157
+ IMPORTANT: Only when the user gives clear approval to proceed (such as "execute plan", "go ahead", "let's do it", "start", "begin", "proceed", "sounds good", or any equivalent phrase indicating they want to move forward), coordinate with the appropriate agents to implement your roadmap step by step, otherwise don't start invoking other tools such read file or other agents.
158
+ """
159
+
160
+ prompt_additions = callbacks.on_load_prompt()
161
+ if len(prompt_additions):
162
+ result += "\n".join(prompt_additions)
163
+ return result