code-puppy 0.0.162__tar.gz → 0.0.164__tar.gz
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-0.0.162 → code_puppy-0.0.164}/PKG-INFO +1 -1
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/agent.py +8 -7
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/agents/agent_creator_agent.py +7 -5
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/command_handler.py +22 -20
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/prompt_toolkit_completion.py +2 -2
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/config.py +1 -1
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/model_factory.py +14 -3
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tools/command_runner.py +2 -3
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tools/file_modifications.py +32 -8
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tools/file_operations.py +3 -3
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/chat_view.py +12 -6
- {code_puppy-0.0.162 → code_puppy-0.0.164}/pyproject.toml +1 -1
- {code_puppy-0.0.162 → code_puppy-0.0.164}/.gitignore +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/LICENSE +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/README.md +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/__main__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/agents/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/agents/agent_code_puppy.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/agents/agent_manager.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/agents/agent_orchestrator.json +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/agents/base_agent.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/agents/json_agent.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/agents/runtime_manager.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/callbacks.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/file_path_completion.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/load_context_completion.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/add_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/base.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/handler.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/help_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/install_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/list_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/logs_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/remove_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/restart_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/search_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/start_all_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/start_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/status_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/stop_all_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/stop_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/test_command.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/utils.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/mcp/wizard_utils.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/meta_command_handler.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/model_picker_completion.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/motd.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/utils.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/http_utils.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/main.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/async_lifecycle.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/blocking_startup.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/captured_stdio_server.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/circuit_breaker.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/config_wizard.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/dashboard.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/error_isolation.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/examples/retry_example.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/health_monitor.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/managed_server.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/manager.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/registry.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/retry_manager.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/server_registry_catalog.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/status_tracker.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/mcp/system_tools.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/message_history_processor.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/messaging/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/messaging/message_queue.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/messaging/queue_console.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/messaging/renderers.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/messaging/spinner/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/messaging/spinner/console_spinner.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/messaging/spinner/spinner_base.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/messaging/spinner/textual_spinner.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/models.json +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/plugins/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/reopenable_async_client.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/round_robin_model.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/state_management.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/status_display.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/summarization_agent.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tools/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tools/agent_tools.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tools/common.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tools/tools_content.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/app.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/command_history_modal.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/copy_button.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/custom_widgets.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/human_input_modal.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/input_area.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/sidebar.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/status_bar.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/messages.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/models/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/models/chat_message.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/models/command_history.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/models/enums.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/screens/__init__.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/screens/help.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/screens/mcp_install_wizard.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/screens/settings.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/screens/tools.py +0 -0
- {code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/version_checker.py +0 -0
|
@@ -6,7 +6,6 @@ from pydantic_ai import Agent
|
|
|
6
6
|
from pydantic_ai.settings import ModelSettings
|
|
7
7
|
from pydantic_ai.usage import UsageLimits
|
|
8
8
|
|
|
9
|
-
from code_puppy.agents import get_current_agent_config
|
|
10
9
|
from code_puppy.message_history_processor import (
|
|
11
10
|
get_model_context_length,
|
|
12
11
|
message_history_accumulator,
|
|
@@ -136,11 +135,12 @@ def reload_code_generation_agent(message_group: str | None):
|
|
|
136
135
|
|
|
137
136
|
# Check if current agent has a pinned model
|
|
138
137
|
from code_puppy.agents import get_current_agent_config
|
|
138
|
+
|
|
139
139
|
agent_config = get_current_agent_config()
|
|
140
140
|
agent_model_name = None
|
|
141
|
-
if hasattr(agent_config,
|
|
141
|
+
if hasattr(agent_config, "get_model_name"):
|
|
142
142
|
agent_model_name = agent_config.get_model_name()
|
|
143
|
-
|
|
143
|
+
|
|
144
144
|
# Use agent-specific model if pinned, otherwise use global model
|
|
145
145
|
model_name = agent_model_name if agent_model_name else get_model_name()
|
|
146
146
|
emit_info(
|
|
@@ -203,17 +203,18 @@ def get_code_generation_agent(force_reload=False, message_group: str | None = No
|
|
|
203
203
|
|
|
204
204
|
# Get the global model name
|
|
205
205
|
global_model_name = get_model_name()
|
|
206
|
-
|
|
206
|
+
|
|
207
207
|
# Check if current agent has a pinned model
|
|
208
208
|
from code_puppy.agents import get_current_agent_config
|
|
209
|
+
|
|
209
210
|
agent_config = get_current_agent_config()
|
|
210
211
|
agent_model_name = None
|
|
211
|
-
if hasattr(agent_config,
|
|
212
|
+
if hasattr(agent_config, "get_model_name"):
|
|
212
213
|
agent_model_name = agent_config.get_model_name()
|
|
213
|
-
|
|
214
|
+
|
|
214
215
|
# Use agent-specific model if pinned, otherwise use global model
|
|
215
216
|
model_name = agent_model_name if agent_model_name else global_model_name
|
|
216
|
-
|
|
217
|
+
|
|
217
218
|
if _code_generation_agent is None or _LAST_MODEL_NAME != model_name or force_reload:
|
|
218
219
|
return reload_code_generation_agent(message_group)
|
|
219
220
|
return _code_generation_agent
|
|
@@ -28,15 +28,17 @@ class AgentCreatorAgent(BaseAgent):
|
|
|
28
28
|
def get_system_prompt(self) -> str:
|
|
29
29
|
available_tools = get_available_tool_names()
|
|
30
30
|
agents_dir = get_user_agents_directory()
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
# Load available models dynamically
|
|
33
33
|
models_config = ModelFactory.load_config()
|
|
34
34
|
model_descriptions = []
|
|
35
35
|
for model_name, model_info in models_config.items():
|
|
36
|
-
model_type = model_info.get(
|
|
37
|
-
context_length = model_info.get(
|
|
38
|
-
model_descriptions.append(
|
|
39
|
-
|
|
36
|
+
model_type = model_info.get("type", "Unknown")
|
|
37
|
+
context_length = model_info.get("context_length", "Unknown")
|
|
38
|
+
model_descriptions.append(
|
|
39
|
+
f"- **{model_name}**: {model_type} model with {context_length} context"
|
|
40
|
+
)
|
|
41
|
+
|
|
40
42
|
available_models_str = "\n".join(model_descriptions)
|
|
41
43
|
|
|
42
44
|
return f"""You are the Agent Creator! 🏗️ Your mission is to help users create awesome JSON agent files through an interactive process.
|
|
@@ -57,7 +57,9 @@ def get_commands_help():
|
|
|
57
57
|
)
|
|
58
58
|
help_lines.append(
|
|
59
59
|
Text("/compact", style="cyan")
|
|
60
|
-
+ Text(
|
|
60
|
+
+ Text(
|
|
61
|
+
" Summarize and compact current chat history (uses compaction_strategy config)"
|
|
62
|
+
)
|
|
61
63
|
)
|
|
62
64
|
help_lines.append(
|
|
63
65
|
Text("/dump_context", style="cyan")
|
|
@@ -371,7 +373,7 @@ def handle_command(command: str):
|
|
|
371
373
|
|
|
372
374
|
# If no model matched, show available models
|
|
373
375
|
from code_puppy.command_line.model_picker_completion import load_model_names
|
|
374
|
-
|
|
376
|
+
|
|
375
377
|
new_input = update_model_in_input(model_command)
|
|
376
378
|
if new_input is not None:
|
|
377
379
|
from code_puppy.agents.runtime_manager import get_runtime_agent_manager
|
|
@@ -406,76 +408,76 @@ def handle_command(command: str):
|
|
|
406
408
|
from code_puppy.agents.json_agent import discover_json_agents
|
|
407
409
|
from code_puppy.command_line.model_picker_completion import load_model_names
|
|
408
410
|
import json
|
|
409
|
-
|
|
411
|
+
|
|
410
412
|
tokens = command.split()
|
|
411
|
-
|
|
413
|
+
|
|
412
414
|
if len(tokens) != 3:
|
|
413
415
|
emit_warning("Usage: /pin_model <agent-name> <model-name>")
|
|
414
|
-
|
|
416
|
+
|
|
415
417
|
# Show available models and JSON agents
|
|
416
418
|
available_models = load_model_names()
|
|
417
419
|
json_agents = discover_json_agents()
|
|
418
|
-
|
|
420
|
+
|
|
419
421
|
emit_info("Available models:")
|
|
420
422
|
for model in available_models:
|
|
421
423
|
emit_info(f" [cyan]{model}[/cyan]")
|
|
422
|
-
|
|
424
|
+
|
|
423
425
|
if json_agents:
|
|
424
426
|
emit_info("\nAvailable JSON agents:")
|
|
425
427
|
for agent_name, agent_path in json_agents.items():
|
|
426
428
|
emit_info(f" [cyan]{agent_name}[/cyan] ({agent_path})")
|
|
427
429
|
return True
|
|
428
|
-
|
|
430
|
+
|
|
429
431
|
agent_name = tokens[1].lower()
|
|
430
432
|
model_name = tokens[2]
|
|
431
|
-
|
|
433
|
+
|
|
432
434
|
# Check if model exists
|
|
433
435
|
available_models = load_model_names()
|
|
434
436
|
if model_name not in available_models:
|
|
435
437
|
emit_error(f"Model '{model_name}' not found")
|
|
436
438
|
emit_warning(f"Available models: {', '.join(available_models)}")
|
|
437
439
|
return True
|
|
438
|
-
|
|
440
|
+
|
|
439
441
|
# Check that we're modifying a JSON agent (not a built-in Python agent)
|
|
440
442
|
json_agents = discover_json_agents()
|
|
441
443
|
if agent_name not in json_agents:
|
|
442
444
|
emit_error(f"JSON agent '{agent_name}' not found")
|
|
443
|
-
|
|
445
|
+
|
|
444
446
|
# Show available JSON agents
|
|
445
447
|
if json_agents:
|
|
446
448
|
emit_info("Available JSON agents:")
|
|
447
449
|
for name, path in json_agents.items():
|
|
448
450
|
emit_info(f" [cyan]{name}[/cyan] ({path})")
|
|
449
451
|
return True
|
|
450
|
-
|
|
452
|
+
|
|
451
453
|
agent_file_path = json_agents[agent_name]
|
|
452
|
-
|
|
454
|
+
|
|
453
455
|
# Load, modify, and save the agent configuration
|
|
454
456
|
try:
|
|
455
457
|
with open(agent_file_path, "r", encoding="utf-8") as f:
|
|
456
458
|
agent_config = json.load(f)
|
|
457
|
-
|
|
459
|
+
|
|
458
460
|
# Set the model
|
|
459
461
|
agent_config["model"] = model_name
|
|
460
|
-
|
|
462
|
+
|
|
461
463
|
# Save the updated configuration
|
|
462
464
|
with open(agent_file_path, "w", encoding="utf-8") as f:
|
|
463
465
|
json.dump(agent_config, f, indent=2, ensure_ascii=False)
|
|
464
|
-
|
|
466
|
+
|
|
465
467
|
emit_success(f"Model '{model_name}' pinned to agent '{agent_name}'")
|
|
466
|
-
|
|
468
|
+
|
|
467
469
|
# If this is the current agent, reload it to use the new model
|
|
468
470
|
from code_puppy.agents import get_current_agent_config
|
|
469
471
|
from code_puppy.agents.runtime_manager import get_runtime_agent_manager
|
|
470
|
-
|
|
472
|
+
|
|
471
473
|
current_agent = get_current_agent_config()
|
|
472
474
|
if current_agent.name == agent_name:
|
|
473
475
|
manager = get_runtime_agent_manager()
|
|
474
476
|
manager.reload_agent()
|
|
475
477
|
emit_info(f"Active agent reloaded with pinned model '{model_name}'")
|
|
476
|
-
|
|
478
|
+
|
|
477
479
|
return True
|
|
478
|
-
|
|
480
|
+
|
|
479
481
|
except Exception as e:
|
|
480
482
|
emit_error(f"Failed to pin model to agent '{agent_name}': {e}")
|
|
481
483
|
return True
|
{code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/prompt_toolkit_completion.py
RENAMED
|
@@ -147,9 +147,9 @@ def get_prompt_with_active_model(base: str = ">>> "):
|
|
|
147
147
|
|
|
148
148
|
# Check if current agent has a pinned model
|
|
149
149
|
agent_model = None
|
|
150
|
-
if current_agent and hasattr(current_agent,
|
|
150
|
+
if current_agent and hasattr(current_agent, "get_model_name"):
|
|
151
151
|
agent_model = current_agent.get_model_name()
|
|
152
|
-
|
|
152
|
+
|
|
153
153
|
# Determine which model to display
|
|
154
154
|
if agent_model and agent_model != global_model:
|
|
155
155
|
# Show both models when they differ
|
|
@@ -492,4 +492,4 @@ def save_command_to_history(command: str):
|
|
|
492
492
|
error_msg = (
|
|
493
493
|
f"❌ An unexpected error occurred while saving command history: {str(e)}"
|
|
494
494
|
)
|
|
495
|
-
direct_console.print(f"[bold red]{error_msg}[/bold red]")
|
|
495
|
+
direct_console.print(f"[bold red]{error_msg}[/bold red]")
|
|
@@ -95,9 +95,20 @@ class ModelFactory:
|
|
|
95
95
|
config = json.load(f)
|
|
96
96
|
|
|
97
97
|
if pathlib.Path(EXTRA_MODELS_FILE).exists():
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
try:
|
|
99
|
+
with open(EXTRA_MODELS_FILE, "r") as f:
|
|
100
|
+
extra_config = json.load(f)
|
|
101
|
+
config.update(extra_config)
|
|
102
|
+
except json.JSONDecodeError as e:
|
|
103
|
+
logging.getLogger(__name__).warning(
|
|
104
|
+
f"Failed to load extra models config from {EXTRA_MODELS_FILE}: Invalid JSON - {e}\n"
|
|
105
|
+
f"Please check your extra_models.json file for syntax errors."
|
|
106
|
+
)
|
|
107
|
+
except Exception as e:
|
|
108
|
+
logging.getLogger(__name__).warning(
|
|
109
|
+
f"Failed to load extra models config from {EXTRA_MODELS_FILE}: {e}\n"
|
|
110
|
+
f"The extra models configuration will be ignored."
|
|
111
|
+
)
|
|
101
112
|
return config
|
|
102
113
|
|
|
103
114
|
@staticmethod
|
|
@@ -12,7 +12,6 @@ from pydantic_ai import RunContext
|
|
|
12
12
|
from rich.markdown import Markdown
|
|
13
13
|
from rich.text import Text
|
|
14
14
|
|
|
15
|
-
from code_puppy.callbacks import on_run_shell_command
|
|
16
15
|
from code_puppy.messaging import (
|
|
17
16
|
emit_divider,
|
|
18
17
|
emit_error,
|
|
@@ -497,7 +496,7 @@ def share_your_reasoning(
|
|
|
497
496
|
def register_agent_run_shell_command(agent):
|
|
498
497
|
"""Register only the agent_run_shell_command tool."""
|
|
499
498
|
|
|
500
|
-
@agent.tool
|
|
499
|
+
@agent.tool
|
|
501
500
|
def agent_run_shell_command(
|
|
502
501
|
context: RunContext, command: str = "", cwd: str = None, timeout: int = 60
|
|
503
502
|
) -> ShellCommandOutput:
|
|
@@ -553,7 +552,7 @@ def register_agent_run_shell_command(agent):
|
|
|
553
552
|
def register_agent_share_your_reasoning(agent):
|
|
554
553
|
"""Register only the agent_share_your_reasoning tool."""
|
|
555
554
|
|
|
556
|
-
@agent.tool
|
|
555
|
+
@agent.tool
|
|
557
556
|
def agent_share_your_reasoning(
|
|
558
557
|
context: RunContext, reasoning: str = "", next_steps: str | None = None
|
|
559
558
|
) -> ReasoningOutput:
|
|
@@ -20,7 +20,6 @@ import json_repair
|
|
|
20
20
|
from pydantic import BaseModel
|
|
21
21
|
from pydantic_ai import RunContext
|
|
22
22
|
|
|
23
|
-
from code_puppy.callbacks import on_delete_file, on_edit_file
|
|
24
23
|
from code_puppy.messaging import emit_error, emit_info, emit_warning
|
|
25
24
|
from code_puppy.tools.common import _find_best_window, generate_group_id
|
|
26
25
|
|
|
@@ -451,7 +450,7 @@ def _delete_file(
|
|
|
451
450
|
def register_edit_file(agent):
|
|
452
451
|
"""Register only the edit_file tool."""
|
|
453
452
|
|
|
454
|
-
@agent.tool
|
|
453
|
+
@agent.tool
|
|
455
454
|
def edit_file(
|
|
456
455
|
context: RunContext,
|
|
457
456
|
payload: EditFilePayload | str = "",
|
|
@@ -468,17 +467,20 @@ def register_edit_file(agent):
|
|
|
468
467
|
payload: One of three payload types:
|
|
469
468
|
|
|
470
469
|
ContentPayload:
|
|
470
|
+
- file_path (str): Path to file
|
|
471
471
|
- content (str): Full file content to write
|
|
472
472
|
- overwrite (bool, optional): Whether to overwrite existing files.
|
|
473
473
|
Defaults to False (safe mode).
|
|
474
474
|
|
|
475
475
|
ReplacementsPayload:
|
|
476
|
+
- file_path (str): Path to file
|
|
476
477
|
- replacements (List[Replacement]): List of text replacements where
|
|
477
478
|
each Replacement contains:
|
|
478
479
|
- old_str (str): Exact text to find and replace
|
|
479
480
|
- new_str (str): Replacement text
|
|
480
481
|
|
|
481
482
|
DeleteSnippetPayload:
|
|
483
|
+
- file_path (str): Path to file
|
|
482
484
|
- delete_snippet (str): Exact text snippet to remove from file
|
|
483
485
|
|
|
484
486
|
Returns:
|
|
@@ -492,7 +494,7 @@ def register_edit_file(agent):
|
|
|
492
494
|
|
|
493
495
|
Examples:
|
|
494
496
|
>>> # Create new file with content
|
|
495
|
-
>>> payload = {"file_path": "hello.py", "content": "print('Hello!')"}
|
|
497
|
+
>>> payload = {"file_path": "hello.py", "content": "print('Hello!')", "overwrite": true}
|
|
496
498
|
>>> result = edit_file(ctx, payload)
|
|
497
499
|
|
|
498
500
|
>>> # Replace text in existing file
|
|
@@ -519,6 +521,28 @@ def register_edit_file(agent):
|
|
|
519
521
|
- Use delete_snippet for removing specific code blocks
|
|
520
522
|
"""
|
|
521
523
|
# Handle string payload parsing (for models that send JSON strings)
|
|
524
|
+
|
|
525
|
+
parse_error_message = """Examples:
|
|
526
|
+
>>> # Create new file with content
|
|
527
|
+
>>> payload = {"file_path": "hello.py", "content": "print('Hello!')", "overwrite": true}
|
|
528
|
+
>>> result = edit_file(ctx, payload)
|
|
529
|
+
|
|
530
|
+
>>> # Replace text in existing file
|
|
531
|
+
>>> payload = {
|
|
532
|
+
... "file_path": "config.py",
|
|
533
|
+
... "replacements": [
|
|
534
|
+
... {"old_str": "debug = False", "new_str": "debug = True"}
|
|
535
|
+
... ]
|
|
536
|
+
... }
|
|
537
|
+
>>> result = edit_file(ctx, payload)
|
|
538
|
+
|
|
539
|
+
>>> # Delete snippet from file
|
|
540
|
+
>>> payload = {
|
|
541
|
+
... "file_path": "main.py",
|
|
542
|
+
... "delete_snippet": "# TODO: remove this comment"
|
|
543
|
+
... }
|
|
544
|
+
>>> result = edit_file(ctx, payload)"""
|
|
545
|
+
|
|
522
546
|
if isinstance(payload, str):
|
|
523
547
|
try:
|
|
524
548
|
# Fallback for weird models that just can't help but send json strings...
|
|
@@ -536,15 +560,15 @@ def register_edit_file(agent):
|
|
|
536
560
|
return {
|
|
537
561
|
"success": False,
|
|
538
562
|
"path": file_path,
|
|
539
|
-
"message": "One of 'content', 'replacements', or 'delete_snippet' must be provided in payload.",
|
|
563
|
+
"message": f"One of 'content', 'replacements', or 'delete_snippet' must be provided in payload. Refer to the following examples: {parse_error_message}",
|
|
540
564
|
"changed": False,
|
|
541
565
|
}
|
|
542
566
|
except Exception as e:
|
|
543
567
|
return {
|
|
544
568
|
"success": False,
|
|
545
|
-
"path":
|
|
546
|
-
"message": f"edit_file call failed: {str(e)}",
|
|
547
|
-
"changed": False
|
|
569
|
+
"path": "Not retrievable in Payload",
|
|
570
|
+
"message": f"edit_file call failed: {str(e)} - this means the tool failed to parse your inputs. Refer to the following examples: {parse_error_message}",
|
|
571
|
+
"changed": False,
|
|
548
572
|
}
|
|
549
573
|
|
|
550
574
|
# Call _edit_file which will extract file_path from payload and handle group_id generation
|
|
@@ -557,7 +581,7 @@ def register_edit_file(agent):
|
|
|
557
581
|
def register_delete_file(agent):
|
|
558
582
|
"""Register only the delete_file tool."""
|
|
559
583
|
|
|
560
|
-
@agent.tool
|
|
584
|
+
@agent.tool
|
|
561
585
|
def delete_file(context: RunContext, file_path: str = "") -> Dict[str, Any]:
|
|
562
586
|
"""Safely delete files with comprehensive logging and diff generation.
|
|
563
587
|
|
|
@@ -603,7 +603,7 @@ def register_list_files(agent):
|
|
|
603
603
|
"""Register only the list_files tool."""
|
|
604
604
|
from code_puppy.config import get_allow_recursion
|
|
605
605
|
|
|
606
|
-
@agent.tool
|
|
606
|
+
@agent.tool
|
|
607
607
|
def list_files(
|
|
608
608
|
context: RunContext, directory: str = ".", recursive: bool = True
|
|
609
609
|
) -> ListFileOutput:
|
|
@@ -672,7 +672,7 @@ def register_list_files(agent):
|
|
|
672
672
|
def register_read_file(agent):
|
|
673
673
|
"""Register only the read_file tool."""
|
|
674
674
|
|
|
675
|
-
@agent.tool
|
|
675
|
+
@agent.tool
|
|
676
676
|
def read_file(
|
|
677
677
|
context: RunContext,
|
|
678
678
|
file_path: str = "",
|
|
@@ -730,7 +730,7 @@ def register_read_file(agent):
|
|
|
730
730
|
def register_grep(agent):
|
|
731
731
|
"""Register only the grep tool."""
|
|
732
732
|
|
|
733
|
-
@agent.tool
|
|
733
|
+
@agent.tool
|
|
734
734
|
def grep(
|
|
735
735
|
context: RunContext, search_string: str = "", directory: str = "."
|
|
736
736
|
) -> GrepOutput:
|
|
@@ -262,29 +262,35 @@ class ChatView(VerticalScroll):
|
|
|
262
262
|
separator = "\n"
|
|
263
263
|
|
|
264
264
|
# Handle content concatenation carefully to preserve Rich objects
|
|
265
|
-
if hasattr(last_message.content, "__rich_console__") or hasattr(
|
|
265
|
+
if hasattr(last_message.content, "__rich_console__") or hasattr(
|
|
266
|
+
message.content, "__rich_console__"
|
|
267
|
+
):
|
|
266
268
|
# If either content is a Rich object, convert both to text and concatenate
|
|
267
269
|
from io import StringIO
|
|
268
270
|
from rich.console import Console
|
|
269
|
-
|
|
271
|
+
|
|
270
272
|
# Convert existing content to string
|
|
271
273
|
if hasattr(last_message.content, "__rich_console__"):
|
|
272
274
|
string_io = StringIO()
|
|
273
|
-
temp_console = Console(
|
|
275
|
+
temp_console = Console(
|
|
276
|
+
file=string_io, width=80, legacy_windows=False, markup=False
|
|
277
|
+
)
|
|
274
278
|
temp_console.print(last_message.content)
|
|
275
279
|
existing_content = string_io.getvalue().rstrip("\n")
|
|
276
280
|
else:
|
|
277
281
|
existing_content = str(last_message.content)
|
|
278
|
-
|
|
282
|
+
|
|
279
283
|
# Convert new content to string
|
|
280
284
|
if hasattr(message.content, "__rich_console__"):
|
|
281
285
|
string_io = StringIO()
|
|
282
|
-
temp_console = Console(
|
|
286
|
+
temp_console = Console(
|
|
287
|
+
file=string_io, width=80, legacy_windows=False, markup=False
|
|
288
|
+
)
|
|
283
289
|
temp_console.print(message.content)
|
|
284
290
|
new_content = string_io.getvalue().rstrip("\n")
|
|
285
291
|
else:
|
|
286
292
|
new_content = str(message.content)
|
|
287
|
-
|
|
293
|
+
|
|
288
294
|
# Combine as plain text
|
|
289
295
|
last_message.content = existing_content + separator + new_content
|
|
290
296
|
else:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/load_context_completion.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/command_line/model_picker_completion.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_puppy-0.0.162 → code_puppy-0.0.164}/code_puppy/tui/components/command_history_modal.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|