code-puppy 0.0.197__py3-none-any.whl → 0.0.198__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.
@@ -101,6 +101,14 @@ class JSONAgent(BaseAgent):
101
101
  """Get tool configuration from JSON config."""
102
102
  return self._config.get("tools_config")
103
103
 
104
+ def refresh_config(self) -> None:
105
+ """Reload the agent configuration from disk.
106
+
107
+ This keeps long-lived agent instances in sync after external edits.
108
+ """
109
+ self._config = self._load_config()
110
+ self._validate_config()
111
+
104
112
  def get_model_name(self) -> Optional[str]:
105
113
  """Get pinned model name from JSON config, if specified.
106
114
 
@@ -5,7 +5,11 @@ from pathlib import Path
5
5
  from code_puppy.command_line.model_picker_completion import update_model_in_input
6
6
  from code_puppy.command_line.motd import print_motd
7
7
  from code_puppy.command_line.utils import make_directory_table
8
- from code_puppy.config import CONTEXTS_DIR, get_config_keys
8
+ from code_puppy.config import (
9
+ CONTEXTS_DIR,
10
+ finalize_autosave_session,
11
+ get_config_keys,
12
+ )
9
13
  from code_puppy.session_storage import list_sessions, load_session, save_session
10
14
  from code_puppy.tools.tools_content import tools_content
11
15
 
@@ -429,31 +433,44 @@ def handle_command(command: str):
429
433
  import uuid
430
434
 
431
435
  group_id = str(uuid.uuid4())
436
+ available_agents = get_available_agents()
432
437
 
433
- if set_current_agent(agent_name):
434
- # Reload the agent with new configuration
435
- agent = get_current_agent()
436
- agent.reload_code_generation_agent()
437
- new_agent = get_current_agent()
438
- emit_success(
439
- f"Switched to agent: {new_agent.display_name}",
438
+ if agent_name not in available_agents:
439
+ emit_error(f"Agent '{agent_name}' not found", message_group=group_id)
440
+ emit_warning(
441
+ f"Available agents: {', '.join(available_agents.keys())}",
440
442
  message_group=group_id,
441
443
  )
442
- emit_info(f"[dim]{new_agent.description}[/dim]", message_group=group_id)
443
444
  return True
444
- else:
445
- # Generate a group ID for all messages in this command
446
- import uuid
447
445
 
448
- group_id = str(uuid.uuid4())
446
+ current_agent = get_current_agent()
447
+ if current_agent.name == agent_name:
448
+ emit_info(
449
+ f"Already using agent: {current_agent.display_name}",
450
+ message_group=group_id,
451
+ )
452
+ return True
449
453
 
450
- available_agents = get_available_agents()
451
- emit_error(f"Agent '{agent_name}' not found", message_group=group_id)
454
+ new_session_id = finalize_autosave_session()
455
+ if not set_current_agent(agent_name):
452
456
  emit_warning(
453
- f"Available agents: {', '.join(available_agents.keys())}",
457
+ "Agent switch failed after autosave rotation. Your context was preserved.",
454
458
  message_group=group_id,
455
459
  )
456
460
  return True
461
+
462
+ new_agent = get_current_agent()
463
+ new_agent.reload_code_generation_agent()
464
+ emit_success(
465
+ f"Switched to agent: {new_agent.display_name}",
466
+ message_group=group_id,
467
+ )
468
+ emit_info(f"[dim]{new_agent.description}[/dim]", message_group=group_id)
469
+ emit_info(
470
+ f"[dim]Auto-save session rotated to: {new_session_id}[/dim]",
471
+ message_group=group_id,
472
+ )
473
+ return True
457
474
  else:
458
475
  emit_warning("Usage: /agent [agent-name]")
459
476
  return True
@@ -593,12 +610,22 @@ def handle_command(command: str):
593
610
 
594
611
  emit_success(f"Model '{model_name}' pinned to agent '{agent_name}'")
595
612
 
596
- # If this is the current agent, reload it to use the new model
613
+ # If this is the current agent, refresh it so the prompt updates immediately
597
614
  from code_puppy.agents import get_current_agent
598
615
 
599
616
  current_agent = get_current_agent()
600
617
  if current_agent.name == agent_name:
601
- emit_info(f"Active agent reloaded with pinned model '{model_name}'")
618
+ try:
619
+ if is_json_agent and hasattr(current_agent, "refresh_config"):
620
+ current_agent.refresh_config()
621
+ current_agent.reload_code_generation_agent()
622
+ emit_info(
623
+ f"Active agent reloaded with pinned model '{model_name}'"
624
+ )
625
+ except Exception as reload_error:
626
+ emit_warning(
627
+ f"Pinned model applied but reload failed: {reload_error}"
628
+ )
602
629
 
603
630
  return True
604
631
 
code_puppy/config.py CHANGED
@@ -784,3 +784,9 @@ def auto_save_session_if_enabled() -> bool:
784
784
 
785
785
  Console().print(f"[dim]❌ Failed to auto-save session: {exc}[/dim]")
786
786
  return False
787
+
788
+
789
+ def finalize_autosave_session() -> str:
790
+ """Persist the current autosave snapshot and rotate to a fresh session."""
791
+ auto_save_session_if_enabled()
792
+ return rotate_autosave_id()
code_puppy/main.py CHANGED
@@ -24,6 +24,7 @@ from code_puppy.config import (
24
24
  AUTOSAVE_DIR,
25
25
  COMMAND_HISTORY_FILE,
26
26
  ensure_config_exists,
27
+ finalize_autosave_session,
27
28
  initialize_command_history_file,
28
29
  save_command_to_history,
29
30
  )
@@ -414,12 +415,14 @@ async def interactive_mode(message_renderer, initial_command: str = None) -> Non
414
415
 
415
416
  # Check for clear command (supports both `clear` and `/clear`)
416
417
  if task.strip().lower() in ("clear", "/clear"):
417
- from code_puppy.messaging import emit_system_message, emit_warning
418
+ from code_puppy.messaging import emit_info, emit_system_message, emit_warning
418
419
 
419
420
  agent = get_current_agent()
421
+ new_session_id = finalize_autosave_session()
420
422
  agent.clear_message_history()
421
423
  emit_warning("Conversation history cleared!")
422
424
  emit_system_message("The agent will not remember previous interactions.\n")
425
+ emit_info(f"[dim]Auto-save session rotated to: {new_session_id}[/dim]")
423
426
  continue
424
427
 
425
428
  # Handle / commands before anything else
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-puppy
3
- Version: 0.0.197
3
+ Version: 0.0.198
4
4
  Summary: Code generation agent
5
5
  Project-URL: repository, https://github.com/mpfaffenberger/code_puppy
6
6
  Project-URL: HomePage, https://github.com/mpfaffenberger/code_puppy
@@ -1,9 +1,9 @@
1
1
  code_puppy/__init__.py,sha256=ehbM1-wMjNmOXk_DBhhJECFyBv2dRHwwo7ucjHeM68E,107
2
2
  code_puppy/__main__.py,sha256=pDVssJOWP8A83iFkxMLY9YteHYat0EyWDQqMkKHpWp4,203
3
3
  code_puppy/callbacks.py,sha256=ukSgVFaEO68o6J09qFwDrnmNanrVv3toTLQhS504Meo,6162
4
- code_puppy/config.py,sha256=S-VcC97Syz8j-bVNBr85DlhOr6exxAHQQR9JdHYOODs,25877
4
+ code_puppy/config.py,sha256=xT-nU1U4n7u8pyzJPG18-cJZBKv5OZI2CtHLt9DGRzU,26065
5
5
  code_puppy/http_utils.py,sha256=YLd8Y16idbI32JGeBXG8n5rT4o4X_zxk9FgUvK9XFo8,8248
6
- code_puppy/main.py,sha256=bljWR8TQRy5GgQf3I_xCgnA5WaBXRS3g_0IcWmiCY3A,22062
6
+ code_puppy/main.py,sha256=TIFaySHV3um9Q3BDUjCjh6s-WWqcNnTY3EsD2WdW6MQ,22245
7
7
  code_puppy/model_factory.py,sha256=ZbIAJWMNKNdTCEMQK8Ig6TDDZlVNyGO9hOLHoLLPMYw,15397
8
8
  code_puppy/models.json,sha256=dClUciCo2RlVDs0ZAQCIur8MOavZUEAXHEecn0uPa-4,1629
9
9
  code_puppy/reopenable_async_client.py,sha256=4UJRaMp5np8cbef9F0zKQ7TPKOfyf5U-Kv-0zYUWDho,8274
@@ -28,9 +28,9 @@ code_puppy/agents/agent_qa_kitten.py,sha256=5PeFFSwCFlTUvP6h5bGntx0xv5NmRwBiw0Hn
28
28
  code_puppy/agents/agent_security_auditor.py,sha256=ADafi2x4gqXw6m-Nch5vjiKjO0Urcbj0x4zxHti3gDw,3712
29
29
  code_puppy/agents/agent_typescript_reviewer.py,sha256=EDY1mFkVpuJ1BPXsJFu2wQ2pfAV-90ipc_8w9ymrKPg,4054
30
30
  code_puppy/agents/base_agent.py,sha256=ikeV6Sui3HAagJBPTtI9T9pCDCFTCYDNEkFFw7XU21Y,39084
31
- code_puppy/agents/json_agent.py,sha256=KPS1q-Rr3b5ekem4i3wtu8eLJRDd5nSPiZ8duJ_tn0U,4630
31
+ code_puppy/agents/json_agent.py,sha256=lhopDJDoiSGHvD8A6t50hi9ZBoNRKgUywfxd0Po_Dzc,4886
32
32
  code_puppy/command_line/__init__.py,sha256=y7WeRemfYppk8KVbCGeAIiTuiOszIURCDjOMZv_YRmU,45
33
- code_puppy/command_line/command_handler.py,sha256=pLPnaASIezgODHXm0_pr5W2rB-ZoPyyRLhE2jLPncTE,30618
33
+ code_puppy/command_line/command_handler.py,sha256=alxMe5v_4jq8Sm6HETsgfF-VoDtgExj9dVzxP77fwmY,31614
34
34
  code_puppy/command_line/file_path_completion.py,sha256=gw8NpIxa6GOpczUJRyh7VNZwoXKKn-yvCqit7h2y6Gg,2931
35
35
  code_puppy/command_line/load_context_completion.py,sha256=6eZxV6Bs-EFwZjN93V8ZDZUC-6RaWxvtZk-04Wtikyw,2240
36
36
  code_puppy/command_line/model_picker_completion.py,sha256=vYNCZS1QWu6fxF__hTwpc7jwH7h_48wUxrnITawc83E,4140
@@ -122,9 +122,9 @@ code_puppy/tui/screens/help.py,sha256=eJuPaOOCp7ZSUlecearqsuX6caxWv7NQszUh0tZJjB
122
122
  code_puppy/tui/screens/mcp_install_wizard.py,sha256=vObpQwLbXjQsxmSg-WCasoev1usEi0pollKnL0SHu9U,27693
123
123
  code_puppy/tui/screens/settings.py,sha256=EsoL_gbN5FpEXGuDqhtdDznNZy_eGNMMuZnWuARSWi8,10790
124
124
  code_puppy/tui/screens/tools.py,sha256=3pr2Xkpa9Js6Yhf1A3_wQVRzFOui-KDB82LwrsdBtyk,1715
125
- code_puppy-0.0.197.data/data/code_puppy/models.json,sha256=dClUciCo2RlVDs0ZAQCIur8MOavZUEAXHEecn0uPa-4,1629
126
- code_puppy-0.0.197.dist-info/METADATA,sha256=8oE9DiR1mb1WzqTdKNjfWDkZrSB_87mr7_HMnm9VJkY,20759
127
- code_puppy-0.0.197.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
128
- code_puppy-0.0.197.dist-info/entry_points.txt,sha256=Tp4eQC99WY3HOKd3sdvb22vZODRq0XkZVNpXOag_KdI,91
129
- code_puppy-0.0.197.dist-info/licenses/LICENSE,sha256=31u8x0SPgdOq3izJX41kgFazWsM43zPEF9eskzqbJMY,1075
130
- code_puppy-0.0.197.dist-info/RECORD,,
125
+ code_puppy-0.0.198.data/data/code_puppy/models.json,sha256=dClUciCo2RlVDs0ZAQCIur8MOavZUEAXHEecn0uPa-4,1629
126
+ code_puppy-0.0.198.dist-info/METADATA,sha256=p-54EnWxhZ2h9yAcVbjToU39Fqch7Si6kmSVHCtqAWA,20759
127
+ code_puppy-0.0.198.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
128
+ code_puppy-0.0.198.dist-info/entry_points.txt,sha256=Tp4eQC99WY3HOKd3sdvb22vZODRq0XkZVNpXOag_KdI,91
129
+ code_puppy-0.0.198.dist-info/licenses/LICENSE,sha256=31u8x0SPgdOq3izJX41kgFazWsM43zPEF9eskzqbJMY,1075
130
+ code_puppy-0.0.198.dist-info/RECORD,,