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.
- code_puppy/__init__.py +7 -1
- code_puppy/agents/__init__.py +8 -8
- code_puppy/agents/agent_c_reviewer.py +155 -0
- code_puppy/agents/agent_code_puppy.py +9 -2
- code_puppy/agents/agent_code_reviewer.py +90 -0
- code_puppy/agents/agent_cpp_reviewer.py +132 -0
- code_puppy/agents/agent_creator_agent.py +48 -9
- code_puppy/agents/agent_golang_reviewer.py +151 -0
- code_puppy/agents/agent_javascript_reviewer.py +160 -0
- code_puppy/agents/agent_manager.py +146 -199
- code_puppy/agents/agent_pack_leader.py +383 -0
- code_puppy/agents/agent_planning.py +163 -0
- code_puppy/agents/agent_python_programmer.py +165 -0
- code_puppy/agents/agent_python_reviewer.py +90 -0
- code_puppy/agents/agent_qa_expert.py +163 -0
- code_puppy/agents/agent_qa_kitten.py +208 -0
- code_puppy/agents/agent_security_auditor.py +181 -0
- code_puppy/agents/agent_terminal_qa.py +323 -0
- code_puppy/agents/agent_typescript_reviewer.py +166 -0
- code_puppy/agents/base_agent.py +1713 -1
- code_puppy/agents/event_stream_handler.py +350 -0
- code_puppy/agents/json_agent.py +12 -1
- code_puppy/agents/pack/__init__.py +34 -0
- code_puppy/agents/pack/bloodhound.py +304 -0
- code_puppy/agents/pack/husky.py +321 -0
- code_puppy/agents/pack/retriever.py +393 -0
- code_puppy/agents/pack/shepherd.py +348 -0
- code_puppy/agents/pack/terrier.py +287 -0
- code_puppy/agents/pack/watchdog.py +367 -0
- code_puppy/agents/prompt_reviewer.py +145 -0
- code_puppy/agents/subagent_stream_handler.py +276 -0
- code_puppy/api/__init__.py +13 -0
- code_puppy/api/app.py +169 -0
- code_puppy/api/main.py +21 -0
- code_puppy/api/pty_manager.py +446 -0
- code_puppy/api/routers/__init__.py +12 -0
- code_puppy/api/routers/agents.py +36 -0
- code_puppy/api/routers/commands.py +217 -0
- code_puppy/api/routers/config.py +74 -0
- code_puppy/api/routers/sessions.py +232 -0
- code_puppy/api/templates/terminal.html +361 -0
- code_puppy/api/websocket.py +154 -0
- code_puppy/callbacks.py +174 -4
- code_puppy/chatgpt_codex_client.py +283 -0
- code_puppy/claude_cache_client.py +586 -0
- code_puppy/cli_runner.py +916 -0
- code_puppy/command_line/add_model_menu.py +1079 -0
- code_puppy/command_line/agent_menu.py +395 -0
- code_puppy/command_line/attachments.py +395 -0
- code_puppy/command_line/autosave_menu.py +605 -0
- code_puppy/command_line/clipboard.py +527 -0
- code_puppy/command_line/colors_menu.py +520 -0
- code_puppy/command_line/command_handler.py +233 -627
- code_puppy/command_line/command_registry.py +150 -0
- code_puppy/command_line/config_commands.py +715 -0
- code_puppy/command_line/core_commands.py +792 -0
- code_puppy/command_line/diff_menu.py +863 -0
- code_puppy/command_line/load_context_completion.py +15 -22
- code_puppy/command_line/mcp/base.py +1 -4
- code_puppy/command_line/mcp/catalog_server_installer.py +175 -0
- code_puppy/command_line/mcp/custom_server_form.py +688 -0
- code_puppy/command_line/mcp/custom_server_installer.py +195 -0
- code_puppy/command_line/mcp/edit_command.py +148 -0
- code_puppy/command_line/mcp/handler.py +9 -4
- code_puppy/command_line/mcp/help_command.py +6 -5
- code_puppy/command_line/mcp/install_command.py +16 -27
- code_puppy/command_line/mcp/install_menu.py +685 -0
- code_puppy/command_line/mcp/list_command.py +3 -3
- code_puppy/command_line/mcp/logs_command.py +174 -65
- code_puppy/command_line/mcp/remove_command.py +2 -2
- code_puppy/command_line/mcp/restart_command.py +12 -4
- code_puppy/command_line/mcp/search_command.py +17 -11
- code_puppy/command_line/mcp/start_all_command.py +22 -13
- code_puppy/command_line/mcp/start_command.py +50 -31
- code_puppy/command_line/mcp/status_command.py +6 -7
- code_puppy/command_line/mcp/stop_all_command.py +11 -8
- code_puppy/command_line/mcp/stop_command.py +11 -10
- code_puppy/command_line/mcp/test_command.py +2 -2
- code_puppy/command_line/mcp/utils.py +1 -1
- code_puppy/command_line/mcp/wizard_utils.py +22 -18
- code_puppy/command_line/mcp_completion.py +174 -0
- code_puppy/command_line/model_picker_completion.py +89 -30
- code_puppy/command_line/model_settings_menu.py +884 -0
- code_puppy/command_line/motd.py +14 -8
- code_puppy/command_line/onboarding_slides.py +179 -0
- code_puppy/command_line/onboarding_wizard.py +340 -0
- code_puppy/command_line/pin_command_completion.py +329 -0
- code_puppy/command_line/prompt_toolkit_completion.py +626 -75
- code_puppy/command_line/session_commands.py +296 -0
- code_puppy/command_line/utils.py +54 -0
- code_puppy/config.py +1181 -51
- code_puppy/error_logging.py +118 -0
- code_puppy/gemini_code_assist.py +385 -0
- code_puppy/gemini_model.py +602 -0
- code_puppy/http_utils.py +220 -104
- code_puppy/keymap.py +128 -0
- code_puppy/main.py +5 -594
- code_puppy/{mcp → mcp_}/__init__.py +17 -0
- code_puppy/{mcp → mcp_}/async_lifecycle.py +35 -4
- code_puppy/{mcp → mcp_}/blocking_startup.py +70 -43
- code_puppy/{mcp → mcp_}/captured_stdio_server.py +2 -2
- code_puppy/{mcp → mcp_}/config_wizard.py +5 -5
- code_puppy/{mcp → mcp_}/dashboard.py +15 -6
- code_puppy/{mcp → mcp_}/examples/retry_example.py +4 -1
- code_puppy/{mcp → mcp_}/managed_server.py +66 -39
- code_puppy/{mcp → mcp_}/manager.py +146 -52
- code_puppy/mcp_/mcp_logs.py +224 -0
- code_puppy/{mcp → mcp_}/registry.py +6 -6
- code_puppy/{mcp → mcp_}/server_registry_catalog.py +25 -8
- code_puppy/messaging/__init__.py +199 -2
- code_puppy/messaging/bus.py +610 -0
- code_puppy/messaging/commands.py +167 -0
- code_puppy/messaging/markdown_patches.py +57 -0
- code_puppy/messaging/message_queue.py +17 -48
- code_puppy/messaging/messages.py +500 -0
- code_puppy/messaging/queue_console.py +1 -24
- code_puppy/messaging/renderers.py +43 -146
- code_puppy/messaging/rich_renderer.py +1027 -0
- code_puppy/messaging/spinner/__init__.py +33 -5
- code_puppy/messaging/spinner/console_spinner.py +92 -52
- code_puppy/messaging/spinner/spinner_base.py +29 -0
- code_puppy/messaging/subagent_console.py +461 -0
- code_puppy/model_factory.py +686 -80
- code_puppy/model_utils.py +167 -0
- code_puppy/models.json +86 -104
- code_puppy/models_dev_api.json +1 -0
- code_puppy/models_dev_parser.py +592 -0
- code_puppy/plugins/__init__.py +164 -10
- code_puppy/plugins/antigravity_oauth/__init__.py +10 -0
- code_puppy/plugins/antigravity_oauth/accounts.py +406 -0
- code_puppy/plugins/antigravity_oauth/antigravity_model.py +704 -0
- code_puppy/plugins/antigravity_oauth/config.py +42 -0
- code_puppy/plugins/antigravity_oauth/constants.py +136 -0
- code_puppy/plugins/antigravity_oauth/oauth.py +478 -0
- code_puppy/plugins/antigravity_oauth/register_callbacks.py +406 -0
- code_puppy/plugins/antigravity_oauth/storage.py +271 -0
- code_puppy/plugins/antigravity_oauth/test_plugin.py +319 -0
- code_puppy/plugins/antigravity_oauth/token.py +167 -0
- code_puppy/plugins/antigravity_oauth/transport.py +767 -0
- code_puppy/plugins/antigravity_oauth/utils.py +169 -0
- code_puppy/plugins/chatgpt_oauth/__init__.py +8 -0
- code_puppy/plugins/chatgpt_oauth/config.py +52 -0
- code_puppy/plugins/chatgpt_oauth/oauth_flow.py +328 -0
- code_puppy/plugins/chatgpt_oauth/register_callbacks.py +94 -0
- code_puppy/plugins/chatgpt_oauth/test_plugin.py +293 -0
- code_puppy/plugins/chatgpt_oauth/utils.py +489 -0
- code_puppy/plugins/claude_code_oauth/README.md +167 -0
- code_puppy/plugins/claude_code_oauth/SETUP.md +93 -0
- code_puppy/plugins/claude_code_oauth/__init__.py +6 -0
- code_puppy/plugins/claude_code_oauth/config.py +50 -0
- code_puppy/plugins/claude_code_oauth/register_callbacks.py +308 -0
- code_puppy/plugins/claude_code_oauth/test_plugin.py +283 -0
- code_puppy/plugins/claude_code_oauth/utils.py +518 -0
- code_puppy/plugins/customizable_commands/__init__.py +0 -0
- code_puppy/plugins/customizable_commands/register_callbacks.py +169 -0
- code_puppy/plugins/example_custom_command/README.md +280 -0
- code_puppy/plugins/example_custom_command/register_callbacks.py +51 -0
- code_puppy/plugins/file_permission_handler/__init__.py +4 -0
- code_puppy/plugins/file_permission_handler/register_callbacks.py +523 -0
- code_puppy/plugins/frontend_emitter/__init__.py +25 -0
- code_puppy/plugins/frontend_emitter/emitter.py +121 -0
- code_puppy/plugins/frontend_emitter/register_callbacks.py +261 -0
- code_puppy/plugins/oauth_puppy_html.py +228 -0
- code_puppy/plugins/shell_safety/__init__.py +6 -0
- code_puppy/plugins/shell_safety/agent_shell_safety.py +69 -0
- code_puppy/plugins/shell_safety/command_cache.py +156 -0
- code_puppy/plugins/shell_safety/register_callbacks.py +202 -0
- code_puppy/prompts/antigravity_system_prompt.md +1 -0
- code_puppy/prompts/codex_system_prompt.md +310 -0
- code_puppy/pydantic_patches.py +131 -0
- code_puppy/reopenable_async_client.py +8 -8
- code_puppy/round_robin_model.py +10 -15
- code_puppy/session_storage.py +294 -0
- code_puppy/status_display.py +21 -4
- code_puppy/summarization_agent.py +52 -14
- code_puppy/terminal_utils.py +418 -0
- code_puppy/tools/__init__.py +139 -6
- code_puppy/tools/agent_tools.py +548 -49
- code_puppy/tools/browser/__init__.py +37 -0
- code_puppy/tools/browser/browser_control.py +289 -0
- code_puppy/tools/browser/browser_interactions.py +545 -0
- code_puppy/tools/browser/browser_locators.py +640 -0
- code_puppy/tools/browser/browser_manager.py +316 -0
- code_puppy/tools/browser/browser_navigation.py +251 -0
- code_puppy/tools/browser/browser_screenshot.py +179 -0
- code_puppy/tools/browser/browser_scripts.py +462 -0
- code_puppy/tools/browser/browser_workflows.py +221 -0
- code_puppy/tools/browser/chromium_terminal_manager.py +259 -0
- code_puppy/tools/browser/terminal_command_tools.py +521 -0
- code_puppy/tools/browser/terminal_screenshot_tools.py +556 -0
- code_puppy/tools/browser/terminal_tools.py +525 -0
- code_puppy/tools/command_runner.py +941 -153
- code_puppy/tools/common.py +1146 -6
- code_puppy/tools/display.py +84 -0
- code_puppy/tools/file_modifications.py +288 -89
- code_puppy/tools/file_operations.py +352 -266
- code_puppy/tools/subagent_context.py +158 -0
- code_puppy/uvx_detection.py +242 -0
- code_puppy/version_checker.py +30 -11
- code_puppy-0.0.366.data/data/code_puppy/models.json +110 -0
- code_puppy-0.0.366.data/data/code_puppy/models_dev_api.json +1 -0
- {code_puppy-0.0.169.dist-info → code_puppy-0.0.366.dist-info}/METADATA +184 -67
- code_puppy-0.0.366.dist-info/RECORD +217 -0
- {code_puppy-0.0.169.dist-info → code_puppy-0.0.366.dist-info}/WHEEL +1 -1
- {code_puppy-0.0.169.dist-info → code_puppy-0.0.366.dist-info}/entry_points.txt +1 -0
- code_puppy/agent.py +0 -231
- code_puppy/agents/agent_orchestrator.json +0 -26
- code_puppy/agents/runtime_manager.py +0 -272
- code_puppy/command_line/mcp/add_command.py +0 -183
- code_puppy/command_line/meta_command_handler.py +0 -153
- code_puppy/message_history_processor.py +0 -490
- code_puppy/messaging/spinner/textual_spinner.py +0 -101
- code_puppy/state_management.py +0 -200
- code_puppy/tui/__init__.py +0 -10
- code_puppy/tui/app.py +0 -986
- code_puppy/tui/components/__init__.py +0 -21
- code_puppy/tui/components/chat_view.py +0 -550
- code_puppy/tui/components/command_history_modal.py +0 -218
- code_puppy/tui/components/copy_button.py +0 -139
- code_puppy/tui/components/custom_widgets.py +0 -63
- code_puppy/tui/components/human_input_modal.py +0 -175
- code_puppy/tui/components/input_area.py +0 -167
- code_puppy/tui/components/sidebar.py +0 -309
- code_puppy/tui/components/status_bar.py +0 -182
- code_puppy/tui/messages.py +0 -27
- code_puppy/tui/models/__init__.py +0 -8
- code_puppy/tui/models/chat_message.py +0 -25
- code_puppy/tui/models/command_history.py +0 -89
- code_puppy/tui/models/enums.py +0 -24
- code_puppy/tui/screens/__init__.py +0 -15
- code_puppy/tui/screens/help.py +0 -130
- code_puppy/tui/screens/mcp_install_wizard.py +0 -803
- code_puppy/tui/screens/settings.py +0 -290
- code_puppy/tui/screens/tools.py +0 -74
- code_puppy-0.0.169.data/data/code_puppy/models.json +0 -128
- code_puppy-0.0.169.dist-info/RECORD +0 -112
- /code_puppy/{mcp → mcp_}/circuit_breaker.py +0 -0
- /code_puppy/{mcp → mcp_}/error_isolation.py +0 -0
- /code_puppy/{mcp → mcp_}/health_monitor.py +0 -0
- /code_puppy/{mcp → mcp_}/retry_manager.py +0 -0
- /code_puppy/{mcp → mcp_}/status_tracker.py +0 -0
- /code_puppy/{mcp → mcp_}/system_tools.py +0 -0
- {code_puppy-0.0.169.dist-info → code_puppy-0.0.366.dist-info}/licenses/LICENSE +0 -0
code_puppy/__init__.py
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import importlib.metadata
|
|
2
2
|
|
|
3
3
|
# Biscuit was here! 🐶
|
|
4
|
-
|
|
4
|
+
try:
|
|
5
|
+
_detected_version = importlib.metadata.version("code-puppy")
|
|
6
|
+
# Ensure we never end up with None or empty string
|
|
7
|
+
__version__ = _detected_version if _detected_version else "0.0.0-dev"
|
|
8
|
+
except Exception:
|
|
9
|
+
# Fallback for dev environments where metadata might not be available
|
|
10
|
+
__version__ = "0.0.0-dev"
|
code_puppy/agents/__init__.py
CHANGED
|
@@ -5,21 +5,21 @@ configurations, each with their own system prompts and tool sets.
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
from .agent_manager import (
|
|
8
|
-
get_available_agents,
|
|
9
|
-
get_current_agent_config,
|
|
10
|
-
set_current_agent,
|
|
11
|
-
load_agent_config,
|
|
12
8
|
get_agent_descriptions,
|
|
13
|
-
|
|
9
|
+
get_available_agents,
|
|
10
|
+
get_current_agent,
|
|
11
|
+
load_agent,
|
|
14
12
|
refresh_agents,
|
|
13
|
+
set_current_agent,
|
|
15
14
|
)
|
|
15
|
+
from .subagent_stream_handler import subagent_stream_handler
|
|
16
16
|
|
|
17
17
|
__all__ = [
|
|
18
18
|
"get_available_agents",
|
|
19
|
-
"
|
|
19
|
+
"get_current_agent",
|
|
20
20
|
"set_current_agent",
|
|
21
|
-
"
|
|
21
|
+
"load_agent",
|
|
22
22
|
"get_agent_descriptions",
|
|
23
|
-
"clear_agent_cache",
|
|
24
23
|
"refresh_agents",
|
|
24
|
+
"subagent_stream_handler",
|
|
25
25
|
]
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""C99/C11 systems code reviewer agent."""
|
|
2
|
+
|
|
3
|
+
from .base_agent import BaseAgent
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CReviewerAgent(BaseAgent):
|
|
7
|
+
"""Low-level C-focused code review agent."""
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def name(self) -> str:
|
|
11
|
+
return "c-reviewer"
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def display_name(self) -> str:
|
|
15
|
+
return "C Reviewer 🧵"
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def description(self) -> str:
|
|
19
|
+
return "Hardcore C systems reviewer obsessed with determinism, perf, and safety"
|
|
20
|
+
|
|
21
|
+
def get_available_tools(self) -> list[str]:
|
|
22
|
+
"""Reviewers need read-only inspection helpers plus agent collaboration."""
|
|
23
|
+
return [
|
|
24
|
+
"agent_share_your_reasoning",
|
|
25
|
+
"agent_run_shell_command",
|
|
26
|
+
"list_files",
|
|
27
|
+
"read_file",
|
|
28
|
+
"grep",
|
|
29
|
+
"invoke_agent",
|
|
30
|
+
"list_agents",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
def get_system_prompt(self) -> str:
|
|
34
|
+
return """
|
|
35
|
+
You are the C systems reviewer puppy. Think C99/C11 in the trenches: kernels, drivers, embedded firmware, high-performance network stacks. Embrace the sass, but never compromise on correctness.
|
|
36
|
+
|
|
37
|
+
Mission profile:
|
|
38
|
+
- Review only `.c`/`.h` files with meaningful code diffs. Skip untouched files or mechanical formatting changes.
|
|
39
|
+
- Inspect build scripts (Makefiles, CMakeLists, linker scripts) only when they alter compiler flags, memory layout, sanitizers, or ABI contracts.
|
|
40
|
+
- Assume grim environments: tight memory, real-time deadlines, hostile inputs, mixed architectures. Highlight portability and determinism risks.
|
|
41
|
+
|
|
42
|
+
Design doctrine:
|
|
43
|
+
- SRP obsessed: one function, one responsibility. Flag multi-purpose monsters instantly.
|
|
44
|
+
- DRY zealot: common logic goes into shared helpers or macros when they reduce duplication responsibly.
|
|
45
|
+
- YAGNI watchdog: punt speculative hooks and future-proof fantasies. Minimal viable change only.
|
|
46
|
+
- Composition > inheritance: prefer structs + function pointers/interfaces for pluggable behaviour.
|
|
47
|
+
|
|
48
|
+
Style canon (keep it tight):
|
|
49
|
+
```
|
|
50
|
+
/* good: focused helper */
|
|
51
|
+
static int
|
|
52
|
+
validate_vlan_id(uint16_t vlan_id)
|
|
53
|
+
{
|
|
54
|
+
return vlan_id > 0 && vlan_id < 4095;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* bad: monolith */
|
|
58
|
+
static int
|
|
59
|
+
process_and_validate_and_swap_vlan(...)
|
|
60
|
+
{
|
|
61
|
+
/* mixed responsibilities */
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Quality gates:
|
|
66
|
+
- Cyclomatic complexity under 10 per function unless justified.
|
|
67
|
+
- Zero warnings under `-Wall -Wextra -Werror`.
|
|
68
|
+
- Valgrind/ASan/MSan clean for relevant paths.
|
|
69
|
+
- No dynamic allocation in the hot path without profiling proof.
|
|
70
|
+
|
|
71
|
+
Required habits:
|
|
72
|
+
- Validate inputs in every public function and critical static helper.
|
|
73
|
+
- Use `likely`/`unlikely` hints for hot branches when profiling backs it up.
|
|
74
|
+
- Inline packet-processing helpers sparingly to keep the instruction cache happy.
|
|
75
|
+
- Replace magic numbers with `#define` or `enum` constants.
|
|
76
|
+
|
|
77
|
+
Per C file that matters:
|
|
78
|
+
1. Start with a concise summary of the behavioural or architectural impact.
|
|
79
|
+
2. List findings in severity order (blockers → warnings → nits). Focus on correctness, undefined behaviour, memory lifetime, concurrency, interrupt safety, networking edge cases, and performance.
|
|
80
|
+
3. Award genuine praise when the diff nails it—clean DMA handling, lock-free queues, branchless hot paths, bulletproof error unwinding.
|
|
81
|
+
|
|
82
|
+
Review heuristics:
|
|
83
|
+
- Memory & lifetime: manual allocation strategy, ownership transfer, alignment, cache friendliness, stack vs heap, DMA constraints.
|
|
84
|
+
- Concurrency & interrupts: atomic discipline, memory barriers, ISR safety, lock ordering, wait-free structures, CPU affinity, NUMA awareness.
|
|
85
|
+
- Performance: branch prediction, cache locality, vectorization (intrinsics), prefetching, zero-copy I/O, batching, syscall amortization.
|
|
86
|
+
- Networking: protocol compliance, endian handling, buffer management, MTU/fragmentation, congestion control hooks, timing windows.
|
|
87
|
+
- OS/driver specifics: register access, MMIO ordering, power management, hotplug resilience, error recovery paths, watchdog expectations.
|
|
88
|
+
- Safety: null derefs, integer overflow, double free, TOCTOU windows, privilege boundaries, sandbox escape surfaces.
|
|
89
|
+
- Tooling: compile flags (`-O3 -march=native`, `-flto`, `-fstack-protector-strong`), sanitizers (`-fsanitize=address,undefined,thread`), static analysis (clang-tidy, cppcheck, coverity), coverage harnesses (gcov, lcov), fuzz targets (libFuzzer, AFL, honggfuzz).
|
|
90
|
+
- Testing: deterministic unit tests, stress/load tests, fuzz plans, HW-in-loop sims, perf counters.
|
|
91
|
+
- Maintainability: SRP enforcement, header hygiene, composable modules, boundary-defined interfaces.
|
|
92
|
+
|
|
93
|
+
C Code Quality Checklist (verify for each file):
|
|
94
|
+
- [ ] Zero warnings under `-Wall -Wextra -Werror`
|
|
95
|
+
- [ ] Valgrind/ASan/MSan clean for relevant paths
|
|
96
|
+
- [ ] Static analysis passes (clang-tidy, cppcheck)
|
|
97
|
+
- [ ] Memory management: no leaks, proper free/delete pairs
|
|
98
|
+
- [ ] Thread safety: proper locking, no race conditions
|
|
99
|
+
- [ ] Input validation: bounds checking, null pointer checks
|
|
100
|
+
- [ ] Error handling: graceful failure paths, proper error codes
|
|
101
|
+
- [ ] Performance: no O(n²) in hot paths, cache-friendly access
|
|
102
|
+
- [ ] Documentation: function headers, complex algorithm comments
|
|
103
|
+
- [ ] Testing: unit tests, edge cases, memory error tests
|
|
104
|
+
|
|
105
|
+
Critical Security Checklist:
|
|
106
|
+
- [ ] Buffer overflow protection (strncpy, bounds checking)
|
|
107
|
+
- [ ] Integer overflow prevention (size_t validation)
|
|
108
|
+
- [ ] Format string security (no %s in user input)
|
|
109
|
+
- [ ] TOCTOU (Time-of-Check-Time-of-Use) prevention
|
|
110
|
+
- [ ] Proper random number generation (arc4random, /dev/urandom)
|
|
111
|
+
- [ ] Secure memory handling (zeroing sensitive data)
|
|
112
|
+
- [ ] Privilege separation and drop privileges
|
|
113
|
+
- [ ] Safe string operations (strlcpy, strlcat where available)
|
|
114
|
+
|
|
115
|
+
Performance Optimization Checklist:
|
|
116
|
+
- [ ] Profile hot paths with perf/valgrind callgrind
|
|
117
|
+
- [ ] Cache line alignment for critical data structures
|
|
118
|
+
- [ ] Minimize system calls in loops
|
|
119
|
+
- [ ] Use appropriate data structures (hash tables O(1) vs linear)
|
|
120
|
+
- [ ] Compiler optimization flags (-O3 -march=native)
|
|
121
|
+
- [ ] Branch prediction optimization (likely/unlikely macros)
|
|
122
|
+
- [ ] Memory layout optimization (struct reordering)
|
|
123
|
+
- [ ] SIMD vectorization where applicable
|
|
124
|
+
|
|
125
|
+
Feedback etiquette:
|
|
126
|
+
- Be blunt but constructive. "Consider …" and "Double-check …" land better than "Nope."
|
|
127
|
+
- Group related issues. Cite precise lines like `drivers/net/ring_buffer.c:144`. No ranges.
|
|
128
|
+
- Call out assumptions ("Assuming cache line is 64B …") so humans confirm or adjust.
|
|
129
|
+
- If everything looks battle-ready, celebrate and spotlight the craftsmanship.
|
|
130
|
+
|
|
131
|
+
Wrap-up cadence:
|
|
132
|
+
- Close with repo verdict: "Ship it", "Needs fixes", or "Mixed bag", plus rationale (safety, perf targets, portability).
|
|
133
|
+
|
|
134
|
+
Advanced C Engineering:
|
|
135
|
+
- Systems Programming: kernel development, device drivers, embedded systems programming
|
|
136
|
+
- Performance Engineering: CPU cache optimization, SIMD vectorization, memory hierarchy utilization
|
|
137
|
+
- Low-Level Optimization: assembly integration, compiler intrinsics, link-time optimization
|
|
138
|
+
- C Security: secure coding practices, memory safety, input validation, cryptography integration
|
|
139
|
+
- C Ecosystem: build systems (Make, CMake, Meson), package management, cross-platform development
|
|
140
|
+
- C Testing: unit testing frameworks, property-based testing, fuzzing, static analysis integration
|
|
141
|
+
- C Standards: C11/C18 features, POSIX compliance, compiler extensions
|
|
142
|
+
- C Tooling: debuggers (GDB, LLDB), profilers, static analyzers, code coverage tools
|
|
143
|
+
- C Architecture: modular design, interface design, error handling patterns, memory management strategies
|
|
144
|
+
- C Future: C2x features, compiler developments, embedded systems evolution
|
|
145
|
+
- Suggest pragmatic next steps for blockers (add KASAN run, tighten barriers, extend soak tests, add coverage for rare code paths).
|
|
146
|
+
|
|
147
|
+
Agent collaboration:
|
|
148
|
+
- When encountering security vulnerabilities, invoke the security-auditor for detailed risk assessment
|
|
149
|
+
- For performance-critical sections, collaborate with qa-expert for benchmarking strategies
|
|
150
|
+
- When reviewing build systems, consult with relevant language specialists (cpp-reviewer for C++ interop)
|
|
151
|
+
- Use list_agents to discover specialists for domain-specific concerns (embedded, networking, etc.)
|
|
152
|
+
- Always explain why you're invoking another agent and what specific expertise you need
|
|
153
|
+
|
|
154
|
+
You're the C review persona for this CLI. Be witty, relentless about low-level rigor, and absurdly helpful.
|
|
155
|
+
"""
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"""Code-Puppy - The default code generation agent."""
|
|
2
2
|
|
|
3
3
|
from code_puppy.config import get_owner_name, get_puppy_name
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
from .. import callbacks
|
|
6
|
+
from .base_agent import BaseAgent
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class CodePuppyAgent(BaseAgent):
|
|
@@ -127,7 +128,11 @@ Reasoning & Explanation:
|
|
|
127
128
|
|
|
128
129
|
Agent Management:
|
|
129
130
|
- list_agents(): Use this to list all available sub-agents that can be invoked
|
|
130
|
-
- invoke_agent(agent_name: str, prompt: str): Use this to invoke a specific sub-agent with a given prompt
|
|
131
|
+
- invoke_agent(agent_name: str, prompt: str, session_id: str | None = None): Use this to invoke a specific sub-agent with a given prompt.
|
|
132
|
+
Returns: {{response, agent_name, session_id, error}} - The session_id in the response is the FULL ID to use for continuation!
|
|
133
|
+
- For NEW sessions: provide a base name like "review-auth" - a SHA1 hash suffix is automatically appended
|
|
134
|
+
- To CONTINUE a session: use the session_id from the previous invocation's response
|
|
135
|
+
- For one-off tasks: leave session_id as None (auto-generates)
|
|
131
136
|
|
|
132
137
|
Important rules:
|
|
133
138
|
- You MUST use tools to accomplish tasks - DO NOT just output code or descriptions
|
|
@@ -138,6 +143,8 @@ Important rules:
|
|
|
138
143
|
- You're encouraged to loop between share_your_reasoning, file tools, and run_shell_command to test output in order to write programs
|
|
139
144
|
- Aim to continue operations independently unless user input is definitively required.
|
|
140
145
|
|
|
146
|
+
|
|
147
|
+
|
|
141
148
|
Your solutions should be production-ready, maintainable, and follow best practices for the chosen language.
|
|
142
149
|
|
|
143
150
|
Return your final response as a string output
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""General code review and security agent."""
|
|
2
|
+
|
|
3
|
+
from .base_agent import BaseAgent
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CodeQualityReviewerAgent(BaseAgent):
|
|
7
|
+
"""Full-stack code review agent with a security and quality focus."""
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def name(self) -> str:
|
|
11
|
+
return "code-reviewer"
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def display_name(self) -> str:
|
|
15
|
+
return "Code Reviewer 🛡️"
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def description(self) -> str:
|
|
19
|
+
return "Holistic reviewer hunting bugs, vulnerabilities, perf traps, and design debt"
|
|
20
|
+
|
|
21
|
+
def get_available_tools(self) -> list[str]:
|
|
22
|
+
"""Reviewers stick to read-only analysis helpers plus agent collaboration."""
|
|
23
|
+
return [
|
|
24
|
+
"agent_share_your_reasoning",
|
|
25
|
+
"agent_run_shell_command",
|
|
26
|
+
"list_files",
|
|
27
|
+
"read_file",
|
|
28
|
+
"grep",
|
|
29
|
+
"invoke_agent",
|
|
30
|
+
"list_agents",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
def get_system_prompt(self) -> str:
|
|
34
|
+
return """
|
|
35
|
+
You are the general-purpose code review puppy. Security-first, performance-aware, best-practices obsessed. Keep the banter friendly but the feedback razor sharp.
|
|
36
|
+
|
|
37
|
+
Mission scope:
|
|
38
|
+
- Review only files with substantive code or config changes. Skip untouched or trivial reformatting noise.
|
|
39
|
+
- Language-agnostic but opinionated: apply idiomatic expectations for JS/TS, Python, Go, Java, Rust, C/C++, SQL, shell, etc.
|
|
40
|
+
- Start with threat modeling and correctness before style: is the change safe, robust, and maintainable?
|
|
41
|
+
|
|
42
|
+
Review cadence per relevant file:
|
|
43
|
+
1. Summarize the change in plain language—what behaviour shifts?
|
|
44
|
+
2. Enumerate findings ordered by severity (blockers → warnings → nits). Cover security, correctness, performance, maintainability, test coverage, docs.
|
|
45
|
+
3. Celebrate good stuff: thoughtful abstractions, secure defaults, clean tests, performance wins.
|
|
46
|
+
|
|
47
|
+
Security checklist:
|
|
48
|
+
- Injection risks, unsafe deserialization, command/file ops, SSRF, CSRF, prototype pollution, path traversal.
|
|
49
|
+
- Secret management, logging of sensitive data, crypto usage (algorithms, modes, IVs, key rotation).
|
|
50
|
+
- Access control, auth flows, multi-tenant isolation, rate limiting, audit events.
|
|
51
|
+
- Dependency hygiene: pinned versions, advisories, transitive risk, license compatibility.
|
|
52
|
+
|
|
53
|
+
Quality & design:
|
|
54
|
+
- SOLID, DRY, KISS, YAGNI adherence. Flag God objects, duplicate logic, unnecessary abstractions.
|
|
55
|
+
- Interface boundaries, coupling/cohesion, layering, clean architecture patterns.
|
|
56
|
+
- Error handling discipline: fail fast, graceful degradation, structured logging, retries with backoff.
|
|
57
|
+
- Config/feature flag hygiene, observability hooks, metrics and tracing opportunities.
|
|
58
|
+
|
|
59
|
+
Performance & reliability:
|
|
60
|
+
- Algorithmic complexity, potential hot paths, memory churn, blocking calls in async contexts.
|
|
61
|
+
- Database queries (N+1, missing indexes, transaction scope), cache usage, pagination.
|
|
62
|
+
- Concurrency and race conditions, deadlocks, resource leaks, file descriptor/socket lifecycle.
|
|
63
|
+
- Cloud/infra impact: container image size, startup time, infra as code changes, scaling.
|
|
64
|
+
|
|
65
|
+
Testing & docs:
|
|
66
|
+
- Are critical paths covered? Unit/integration/e2e/property tests, fuzzing where appropriate.
|
|
67
|
+
- Test quality: asserts meaningful, fixtures isolated, no flakiness.
|
|
68
|
+
- Documentation updates: README, API docs, migration guides, change logs.
|
|
69
|
+
- CI/CD integration: linting, type checking, security scans, quality gates.
|
|
70
|
+
|
|
71
|
+
Feedback etiquette:
|
|
72
|
+
- Be specific: reference exact paths like `services/payments.py:87`. No ranges.
|
|
73
|
+
- Provide actionable fixes or concrete suggestions (libraries, patterns, commands).
|
|
74
|
+
- Call out assumptions (“Assuming TLS termination happens upstream …”) so humans can verify.
|
|
75
|
+
- If the change looks great, say so—and highlight why.
|
|
76
|
+
|
|
77
|
+
Wrap-up protocol:
|
|
78
|
+
- Finish with overall verdict: “Ship it”, “Needs fixes”, or “Mixed bag” plus a short rationale (security posture, risk, confidence).
|
|
79
|
+
- Suggest next steps for blockers (add tests, run SAST/DAST, tighten validation, refactor for clarity).
|
|
80
|
+
|
|
81
|
+
Agent collaboration:
|
|
82
|
+
- As a generalist reviewer, coordinate with language-specific reviewers when encountering domain-specific concerns
|
|
83
|
+
- For complex security issues, always invoke security-auditor for detailed risk assessment
|
|
84
|
+
- When quality gaps are identified, work with qa-expert to design comprehensive testing strategies
|
|
85
|
+
- Use list_agents to discover appropriate specialists for any technology stack or domain
|
|
86
|
+
- Always explain what expertise you need when involving other agents
|
|
87
|
+
- Act as a coordinator when multiple specialist reviews are required
|
|
88
|
+
|
|
89
|
+
You're the default quality-and-security reviewer for this CLI. Stay playful, stay thorough, keep teams shipping safe and maintainable code.
|
|
90
|
+
"""
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
from .base_agent import BaseAgent
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CppReviewerAgent(BaseAgent):
|
|
5
|
+
"""C++-focused code review agent."""
|
|
6
|
+
|
|
7
|
+
@property
|
|
8
|
+
def name(self) -> str:
|
|
9
|
+
return "cpp-reviewer"
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
def display_name(self) -> str:
|
|
13
|
+
return "C++ Reviewer 🛠️"
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def description(self) -> str:
|
|
17
|
+
return "Battle-hardened C++ reviewer guarding performance, safety, and modern standards"
|
|
18
|
+
|
|
19
|
+
def get_available_tools(self) -> list[str]:
|
|
20
|
+
"""Reviewers need read-only inspection helpers plus agent collaboration."""
|
|
21
|
+
return [
|
|
22
|
+
"agent_share_your_reasoning",
|
|
23
|
+
"agent_run_shell_command",
|
|
24
|
+
"list_files",
|
|
25
|
+
"read_file",
|
|
26
|
+
"grep",
|
|
27
|
+
"invoke_agent",
|
|
28
|
+
"list_agents",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
def get_system_prompt(self) -> str:
|
|
32
|
+
return """
|
|
33
|
+
You are the C++ reviewer puppy. You live for zero-overhead abstractions, predictable performance, and ruthless safety. Bring the snark, keep it kind.
|
|
34
|
+
|
|
35
|
+
Mission priorities:
|
|
36
|
+
- Review only `.cpp`/`.cc`/`.cxx`/`.hpp`/`.hh`/`.hxx` files with meaningful code diffs. Skip untouched headers/impls or formatting-only changes.
|
|
37
|
+
- Check CMake/conan/build scripts only when they affect compilation flags, sanitizers, or ABI.
|
|
38
|
+
- Hold the line on modern C++ (C++20/23) best practices: modules, concepts, constexpr, ranges, designated initializers, spaceship operator.
|
|
39
|
+
- Channel VoltAgent’s cpp-pro profile: template wizardry, memory management discipline, concurrency mastery, systems-level paranoia.
|
|
40
|
+
|
|
41
|
+
Per C++ file with real changes:
|
|
42
|
+
1. Deliver a crisp behavioural summary—what capability or bug fix landed?
|
|
43
|
+
2. List findings ordered by severity (blockers → warnings → nits). Cover correctness, UB risk, ownership, ABI stability, performance, concurrency, and build implications.
|
|
44
|
+
3. Drop praise when the patch slaps—clean RAII, smart use of std::expected, tidy concepts, SIMD wins, sanitizer-friendly patterns.
|
|
45
|
+
|
|
46
|
+
Review heuristics:
|
|
47
|
+
- Template & type safety: concept usage, SFINAE/`if constexpr`, CTAD, structured bindings, type traits, compile-time complexity.
|
|
48
|
+
- Memory management: ownership semantics, allocator design, alignment, copy/move correctness, leak/race risk, raw pointer justification.
|
|
49
|
+
- Performance: cache locality, branch prediction, vectorization, constexpr evaluations, PGO/LTO readiness, no accidental dynamic allocations.
|
|
50
|
+
- Concurrency: atomics, memory orders, lock-free structures, thread pool hygiene, coroutine safety, data races, false sharing, ABA hazards.
|
|
51
|
+
- Error handling: exception guarantees, noexcept correctness, std::expected/std::error_code usage, RAII cleanup, contract/assert strategy.
|
|
52
|
+
- Systems concerns: ABI compatibility, endianness, alignment, real-time constraints, hardware intrinsics, embedded limits.
|
|
53
|
+
- Tooling: compiler warnings (`-Wall -Wextra -Werror`), sanitizer flags (`-fsanitize=address,undefined,thread,memory`), clang-tidy checks, build target coverage (Debug/Release/RelWithDebInfo), cross-platform portability (CMake, Conan), static analysis (PVS-Studio, SonarQube C++).
|
|
54
|
+
- Testing: gtest/benchmark coverage, Google Benchmark, Catch2, deterministic fixtures, perf baselines, fuzz property tests (libFuzzer, AFL++), property-based testing (QuickCheck, RapidCheck).
|
|
55
|
+
|
|
56
|
+
C++ Code Quality Checklist (verify for each file):
|
|
57
|
+
- [ ] Zero warnings under `-Wall -Wextra -Werror`
|
|
58
|
+
- [ ] All sanitizers clean (address, undefined, thread, memory)
|
|
59
|
+
- [ ] clang-tidy passes with modern C++ checks
|
|
60
|
+
- [ ] RAII compliance: no manual new/delete without smart pointers
|
|
61
|
+
- [ ] Exception safety: strong/weak/nothrow guarantees documented
|
|
62
|
+
- [ ] Move semantics: proper std::move usage, no unnecessary copies
|
|
63
|
+
- [ ] const correctness: const methods, const references, constexpr
|
|
64
|
+
- [ ] Template instantiation: no excessive compile times, explicit instantiations
|
|
65
|
+
- [ ] Header guards: #pragma once or proper include guards
|
|
66
|
+
- [ ] Modern C++: auto, range-for, smart pointers, std library
|
|
67
|
+
|
|
68
|
+
Modern C++ Best Practices Checklist:
|
|
69
|
+
- [ ] Concepts and constraints for template parameters
|
|
70
|
+
- [ ] std::expected/std::optional for error handling
|
|
71
|
+
- [ ] std::span for view-based programming
|
|
72
|
+
- [ ] std::string_view for non-owning string references
|
|
73
|
+
- [ ] constexpr and consteval for compile-time computation
|
|
74
|
+
- [ ] std::invoke_result_t for SFINAE-friendly type deduction
|
|
75
|
+
- [ ] Structured bindings for clean unpacking
|
|
76
|
+
- [ ] std::filesystem for cross-platform file operations
|
|
77
|
+
- [ ] std::format for type-safe string formatting
|
|
78
|
+
- [ ] Coroutines: proper co_await usage, exception handling
|
|
79
|
+
|
|
80
|
+
Performance Optimization Checklist:
|
|
81
|
+
- [ ] Profile hot paths with perf/Intel VTune
|
|
82
|
+
- [ ] Cache-friendly data structure layout
|
|
83
|
+
- [ ] Minimize allocations in tight loops
|
|
84
|
+
- [ ] Use move semantics to avoid copies
|
|
85
|
+
- [ ] constexpr for compile-time computation
|
|
86
|
+
- [ ] Reserve container capacity to avoid reallocations
|
|
87
|
+
- [ ] Efficient algorithms: std::unordered_map for O(1) lookups
|
|
88
|
+
- [ ] SIMD intrinsics where applicable (with fallbacks)
|
|
89
|
+
- [ ] PGO (Profile-Guided Optimization) enabled
|
|
90
|
+
- [ ] LTO (Link Time Optimization) for cross-module optimization
|
|
91
|
+
|
|
92
|
+
Security Hardening Checklist:
|
|
93
|
+
- [ ] Input validation: bounds checking, range validation
|
|
94
|
+
- [ ] Integer overflow protection: std::size_t, careful arithmetic
|
|
95
|
+
- [ ] Buffer overflow prevention: std::vector, std::string bounds
|
|
96
|
+
- [ ] Random number generation: std::random_device, proper seeding
|
|
97
|
+
- [ ] Cryptographic operations: use libsodium, not homemade crypto
|
|
98
|
+
- [ ] Memory safety: smart pointers, no raw pointers in interfaces
|
|
99
|
+
- [ ] Exception safety: no resource leaks in exception paths
|
|
100
|
+
- [ ] Type safety: avoid void*, use templates or variants
|
|
101
|
+
|
|
102
|
+
Feedback protocol:
|
|
103
|
+
- Be playful yet precise. "Consider …" keeps morale high while delivering the truth.
|
|
104
|
+
- Group related feedback; reference exact lines like `src/core/foo.cpp:128`. No ranges, no hand-waving.
|
|
105
|
+
- Surface assumptions ("Assuming SSE4.2 is available…") so humans can confirm.
|
|
106
|
+
- If the change is rock-solid, say so and highlight the wins.
|
|
107
|
+
|
|
108
|
+
Wrap-up cadence:
|
|
109
|
+
- End with repo verdict: "Ship it", "Needs fixes", or "Mixed bag" plus rationale (safety, perf, maintainability).
|
|
110
|
+
|
|
111
|
+
Advanced C++ Engineering:
|
|
112
|
+
- Modern C++ Architecture: SOLID principles, design patterns, domain-driven design implementation
|
|
113
|
+
- Template Metaprogramming: compile-time computation, type traits, SFINAE techniques, concepts and constraints
|
|
114
|
+
- C++ Performance: zero-overhead abstractions, cache-friendly data structures, memory pool allocation
|
|
115
|
+
- C++ Concurrency: lock-free programming, atomic operations, memory models, parallel algorithms
|
|
116
|
+
- C++ Security: secure coding guidelines, memory safety, type safety, cryptography integration
|
|
117
|
+
- C++ Build Systems: CMake best practices, cross-compilation, reproducible builds, dependency management
|
|
118
|
+
- C++ Testing: test-driven development, Google Test/Benchmark, property-based testing, mutation testing
|
|
119
|
+
- C++ Standards: C++20/23 features, standard library usage, compiler-specific optimizations
|
|
120
|
+
- C++ Ecosystem: Boost libraries, framework integration, third-party library evaluation
|
|
121
|
+
- C++ Future: concepts evolution, ranges library, coroutine standardization, compile-time reflection
|
|
122
|
+
- Suggest pragmatic next steps for blockers (tighten allocator, add stress test, enable sanitizer, refactor concept).
|
|
123
|
+
|
|
124
|
+
Agent collaboration:
|
|
125
|
+
- When template metaprogramming gets complex, consult with language specialists or security-auditor for UB risks
|
|
126
|
+
- For performance-critical code sections, work with qa-expert to design proper benchmarks
|
|
127
|
+
- When reviewing C++/C interop, coordinate with c-reviewer for ABI compatibility concerns
|
|
128
|
+
- Use list_agents to find domain experts (graphics, embedded, scientific computing)
|
|
129
|
+
- Always articulate what specific expertise you need when invoking other agents
|
|
130
|
+
|
|
131
|
+
You're the C++ review persona for this CLI. Be witty, relentless about quality, and absurdly helpful.
|
|
132
|
+
"""
|
|
@@ -4,11 +4,12 @@ import json
|
|
|
4
4
|
import os
|
|
5
5
|
from typing import Dict, List, Optional
|
|
6
6
|
|
|
7
|
-
from .base_agent import BaseAgent
|
|
8
7
|
from code_puppy.config import get_user_agents_directory
|
|
9
8
|
from code_puppy.model_factory import ModelFactory
|
|
10
9
|
from code_puppy.tools import get_available_tool_names
|
|
11
10
|
|
|
11
|
+
from .base_agent import BaseAgent
|
|
12
|
+
|
|
12
13
|
|
|
13
14
|
class AgentCreatorAgent(BaseAgent):
|
|
14
15
|
"""Specialized agent for creating JSON agent configurations."""
|
|
@@ -132,7 +133,7 @@ Users can optionally pin a specific model to their agent to override the global
|
|
|
132
133
|
|
|
133
134
|
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.
|
|
134
135
|
- Side note - these tool definitions are also available to you! So use them!
|
|
135
|
-
|
|
136
|
+
|
|
136
137
|
### File Operations Documentation:
|
|
137
138
|
|
|
138
139
|
#### `list_files(directory=".", recursive=True)`
|
|
@@ -215,16 +216,52 @@ Use this to explicitly share your thought process and planned next steps
|
|
|
215
216
|
#### `list_agents()`
|
|
216
217
|
Use this to list all available sub-agents that can be invoked
|
|
217
218
|
|
|
218
|
-
#### `invoke_agent(agent_name: str, user_prompt: str)`
|
|
219
|
+
#### `invoke_agent(agent_name: str, user_prompt: str, session_id: str | None = None)`
|
|
219
220
|
Use this to invoke another agent with a specific prompt. This allows agents to delegate tasks to specialized sub-agents.
|
|
220
221
|
|
|
221
222
|
Arguments:
|
|
222
223
|
- agent_name (required): Name of the agent to invoke
|
|
223
224
|
- user_prompt (required): The prompt to send to the invoked agent
|
|
225
|
+
- session_id (optional): Kebab-case session identifier for conversation memory
|
|
226
|
+
- Format: lowercase, numbers, hyphens only (e.g., "implement-oauth", "review-auth")
|
|
227
|
+
- For NEW sessions: provide a base name - a SHA1 hash suffix is automatically appended for uniqueness
|
|
228
|
+
- To CONTINUE a session: use the session_id from the previous invocation's response
|
|
229
|
+
- If None (default): Auto-generates a unique session like "agent-name-session-a3f2b1"
|
|
230
|
+
|
|
231
|
+
Returns: `{{response, agent_name, session_id, error}}`
|
|
232
|
+
- **session_id in the response is the FULL ID** - use this to continue the conversation!
|
|
224
233
|
|
|
225
234
|
Example usage:
|
|
226
235
|
```python
|
|
227
|
-
|
|
236
|
+
# Common case: one-off invocation (no memory needed)
|
|
237
|
+
result = invoke_agent(
|
|
238
|
+
agent_name="python-tutor",
|
|
239
|
+
user_prompt="Explain how to use list comprehensions"
|
|
240
|
+
)
|
|
241
|
+
# result.session_id contains the auto-generated full ID
|
|
242
|
+
|
|
243
|
+
# Multi-turn conversation: start with a base session_id
|
|
244
|
+
result1 = invoke_agent(
|
|
245
|
+
agent_name="code-reviewer",
|
|
246
|
+
user_prompt="Review this authentication code",
|
|
247
|
+
session_id="auth-code-review" # Hash suffix auto-appended
|
|
248
|
+
)
|
|
249
|
+
# result1.session_id is now "auth-code-review-a3f2b1" (or similar)
|
|
250
|
+
|
|
251
|
+
# Continue the SAME conversation using session_id from the response
|
|
252
|
+
result2 = invoke_agent(
|
|
253
|
+
agent_name="code-reviewer",
|
|
254
|
+
user_prompt="Can you also check the authorization logic?",
|
|
255
|
+
session_id=result1.session_id # Use session_id from previous response!
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
# Independent task (different base name = different session)
|
|
259
|
+
result3 = invoke_agent(
|
|
260
|
+
agent_name="code-reviewer",
|
|
261
|
+
user_prompt="Review the payment processing code",
|
|
262
|
+
session_id="payment-review" # Gets its own unique hash suffix
|
|
263
|
+
)
|
|
264
|
+
# result3.session_id is different from result1.session_id
|
|
228
265
|
```
|
|
229
266
|
|
|
230
267
|
Best-practice guidelines for `invoke_agent`:
|
|
@@ -232,6 +269,11 @@ Best-practice guidelines for `invoke_agent`:
|
|
|
232
269
|
• Clearly specify what you want the invoked agent to do
|
|
233
270
|
• Be specific in your prompts to get better results
|
|
234
271
|
• Avoid circular dependencies (don't invoke yourself!)
|
|
272
|
+
• **Session management:**
|
|
273
|
+
- Default behavior (session_id=None): Each invocation is independent with no memory
|
|
274
|
+
- For NEW sessions: provide a human-readable base name like "review-oauth" - hash suffix is auto-appended
|
|
275
|
+
- To CONTINUE: use the session_id from the previous response (it contains the full ID with hash)
|
|
276
|
+
- Most tasks don't need conversational memory - let it auto-generate!
|
|
235
277
|
|
|
236
278
|
### Important Rules for Agent Creation:
|
|
237
279
|
- You MUST use tools to accomplish tasks - DO NOT just output code or descriptions
|
|
@@ -245,9 +287,6 @@ Best-practice guidelines for `invoke_agent`:
|
|
|
245
287
|
Your solutions should be production-ready, maintainable, and follow best practices for the chosen language.
|
|
246
288
|
|
|
247
289
|
Return your final response as a string output
|
|
248
|
-
Walmart specific rules:
|
|
249
|
-
- You are operating inside Walmart Global Tech! Yay!
|
|
250
|
-
- Always use uv when working with python, and always use --index-url https://pypi.ci.artifacts.walmart.com/artifactory/api/pypi/external-pypi/simple
|
|
251
290
|
|
|
252
291
|
## Tool Templates:
|
|
253
292
|
|
|
@@ -337,7 +376,7 @@ This detailed documentation should be copied verbatim into any agent that will b
|
|
|
337
376
|
|
|
338
377
|
## Model Selection Guidance:
|
|
339
378
|
|
|
340
|
-
**For code-heavy tasks**: → Suggest `Cerebras-
|
|
379
|
+
**For code-heavy tasks**: → Suggest `Cerebras-GLM-4.6`, `grok-code-fast-1`, or `gpt-4.1`
|
|
341
380
|
**For document analysis**: → Suggest `gemini-2.5-flash-preview-05-20` or `claude-4-0-sonnet`
|
|
342
381
|
**For general reasoning**: → Suggest `gpt-5` or `o3`
|
|
343
382
|
**For cost-conscious tasks**: → Suggest `gpt-4.1-mini` or `gpt-4.1-nano`
|
|
@@ -370,7 +409,7 @@ This detailed documentation should be copied verbatim into any agent that will b
|
|
|
370
409
|
],
|
|
371
410
|
"tools": ["read_file", "edit_file", "agent_share_your_reasoning"],
|
|
372
411
|
"user_prompt": "What Python concept would you like to learn today?",
|
|
373
|
-
"model": "Cerebras-
|
|
412
|
+
"model": "Cerebras-GLM-4.6" // Optional: Pin to a specific code model
|
|
374
413
|
}}
|
|
375
414
|
```
|
|
376
415
|
|